index.mjs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import $5WXm8$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
  2. import {forwardRef as $5WXm8$forwardRef, createElement as $5WXm8$createElement} from "react";
  3. import {Primitive as $5WXm8$Primitive} from "@radix-ui/react-primitive";
  4. /* -------------------------------------------------------------------------------------------------
  5. * Separator
  6. * -----------------------------------------------------------------------------------------------*/ const $89eedd556c436f6a$var$NAME = 'Separator';
  7. const $89eedd556c436f6a$var$DEFAULT_ORIENTATION = 'horizontal';
  8. const $89eedd556c436f6a$var$ORIENTATIONS = [
  9. 'horizontal',
  10. 'vertical'
  11. ];
  12. const $89eedd556c436f6a$export$1ff3c3f08ae963c0 = /*#__PURE__*/ $5WXm8$forwardRef((props, forwardedRef)=>{
  13. const { decorative: decorative , orientation: orientationProp = $89eedd556c436f6a$var$DEFAULT_ORIENTATION , ...domProps } = props;
  14. const orientation = $89eedd556c436f6a$var$isValidOrientation(orientationProp) ? orientationProp : $89eedd556c436f6a$var$DEFAULT_ORIENTATION; // `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical
  15. const ariaOrientation = orientation === 'vertical' ? orientation : undefined;
  16. const semanticProps = decorative ? {
  17. role: 'none'
  18. } : {
  19. 'aria-orientation': ariaOrientation,
  20. role: 'separator'
  21. };
  22. return /*#__PURE__*/ $5WXm8$createElement($5WXm8$Primitive.div, $5WXm8$babelruntimehelpersesmextends({
  23. "data-orientation": orientation
  24. }, semanticProps, domProps, {
  25. ref: forwardedRef
  26. }));
  27. });
  28. /*#__PURE__*/ Object.assign($89eedd556c436f6a$export$1ff3c3f08ae963c0, {
  29. displayName: $89eedd556c436f6a$var$NAME
  30. });
  31. $89eedd556c436f6a$export$1ff3c3f08ae963c0.propTypes = {
  32. orientation (props, propName, componentName) {
  33. const propValue = props[propName];
  34. const strVal = String(propValue);
  35. if (propValue && !$89eedd556c436f6a$var$isValidOrientation(propValue)) return new Error($89eedd556c436f6a$var$getInvalidOrientationError(strVal, componentName));
  36. return null;
  37. }
  38. };
  39. /* -----------------------------------------------------------------------------------------------*/ // Split this out for clearer readability of the error message.
  40. function $89eedd556c436f6a$var$getInvalidOrientationError(value, componentName) {
  41. return `Invalid prop \`orientation\` of value \`${value}\` supplied to \`${componentName}\`, expected one of:
  42. - horizontal
  43. - vertical
  44. Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
  45. }
  46. function $89eedd556c436f6a$var$isValidOrientation(orientation) {
  47. return $89eedd556c436f6a$var$ORIENTATIONS.includes(orientation);
  48. }
  49. const $89eedd556c436f6a$export$be92b6f5f03c0fe9 = $89eedd556c436f6a$export$1ff3c3f08ae963c0;
  50. export {$89eedd556c436f6a$export$1ff3c3f08ae963c0 as Separator, $89eedd556c436f6a$export$be92b6f5f03c0fe9 as Root};
  51. //# sourceMappingURL=index.mjs.map