index.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var $3sOcx$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
  2. var $3sOcx$react = require("react");
  3. var $3sOcx$radixuireactprimitive = require("@radix-ui/react-primitive");
  4. function $parcel$export(e, n, v, s) {
  5. Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
  6. }
  7. function $parcel$interopDefault(a) {
  8. return a && a.__esModule ? a.default : a;
  9. }
  10. $parcel$export(module.exports, "Separator", () => $1d2e81bd6a105992$export$1ff3c3f08ae963c0);
  11. $parcel$export(module.exports, "Root", () => $1d2e81bd6a105992$export$be92b6f5f03c0fe9);
  12. /* -------------------------------------------------------------------------------------------------
  13. * Separator
  14. * -----------------------------------------------------------------------------------------------*/ const $1d2e81bd6a105992$var$NAME = 'Separator';
  15. const $1d2e81bd6a105992$var$DEFAULT_ORIENTATION = 'horizontal';
  16. const $1d2e81bd6a105992$var$ORIENTATIONS = [
  17. 'horizontal',
  18. 'vertical'
  19. ];
  20. const $1d2e81bd6a105992$export$1ff3c3f08ae963c0 = /*#__PURE__*/ $3sOcx$react.forwardRef((props, forwardedRef)=>{
  21. const { decorative: decorative , orientation: orientationProp = $1d2e81bd6a105992$var$DEFAULT_ORIENTATION , ...domProps } = props;
  22. const orientation = $1d2e81bd6a105992$var$isValidOrientation(orientationProp) ? orientationProp : $1d2e81bd6a105992$var$DEFAULT_ORIENTATION; // `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical
  23. const ariaOrientation = orientation === 'vertical' ? orientation : undefined;
  24. const semanticProps = decorative ? {
  25. role: 'none'
  26. } : {
  27. 'aria-orientation': ariaOrientation,
  28. role: 'separator'
  29. };
  30. return /*#__PURE__*/ $3sOcx$react.createElement($3sOcx$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($3sOcx$babelruntimehelpersextends))({
  31. "data-orientation": orientation
  32. }, semanticProps, domProps, {
  33. ref: forwardedRef
  34. }));
  35. });
  36. /*#__PURE__*/ Object.assign($1d2e81bd6a105992$export$1ff3c3f08ae963c0, {
  37. displayName: $1d2e81bd6a105992$var$NAME
  38. });
  39. $1d2e81bd6a105992$export$1ff3c3f08ae963c0.propTypes = {
  40. orientation (props, propName, componentName) {
  41. const propValue = props[propName];
  42. const strVal = String(propValue);
  43. if (propValue && !$1d2e81bd6a105992$var$isValidOrientation(propValue)) return new Error($1d2e81bd6a105992$var$getInvalidOrientationError(strVal, componentName));
  44. return null;
  45. }
  46. };
  47. /* -----------------------------------------------------------------------------------------------*/ // Split this out for clearer readability of the error message.
  48. function $1d2e81bd6a105992$var$getInvalidOrientationError(value, componentName) {
  49. return `Invalid prop \`orientation\` of value \`${value}\` supplied to \`${componentName}\`, expected one of:
  50. - horizontal
  51. - vertical
  52. Defaulting to \`${$1d2e81bd6a105992$var$DEFAULT_ORIENTATION}\`.`;
  53. }
  54. function $1d2e81bd6a105992$var$isValidOrientation(orientation) {
  55. return $1d2e81bd6a105992$var$ORIENTATIONS.includes(orientation);
  56. }
  57. const $1d2e81bd6a105992$export$be92b6f5f03c0fe9 = $1d2e81bd6a105992$export$1ff3c3f08ae963c0;
  58. //# sourceMappingURL=index.js.map