index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. var $aJCrN$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
  2. var $aJCrN$react = require("react");
  3. var $aJCrN$radixuiprimitive = require("@radix-ui/primitive");
  4. var $aJCrN$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
  5. var $aJCrN$radixuireactcontext = require("@radix-ui/react-context");
  6. var $aJCrN$radixuireactid = require("@radix-ui/react-id");
  7. var $aJCrN$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
  8. var $aJCrN$radixuireactdismissablelayer = require("@radix-ui/react-dismissable-layer");
  9. var $aJCrN$radixuireactfocusscope = require("@radix-ui/react-focus-scope");
  10. var $aJCrN$radixuireactportal = require("@radix-ui/react-portal");
  11. var $aJCrN$radixuireactpresence = require("@radix-ui/react-presence");
  12. var $aJCrN$radixuireactprimitive = require("@radix-ui/react-primitive");
  13. var $aJCrN$radixuireactfocusguards = require("@radix-ui/react-focus-guards");
  14. var $aJCrN$reactremovescroll = require("react-remove-scroll");
  15. var $aJCrN$ariahidden = require("aria-hidden");
  16. var $aJCrN$radixuireactslot = require("@radix-ui/react-slot");
  17. function $parcel$export(e, n, v, s) {
  18. Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
  19. }
  20. function $parcel$interopDefault(a) {
  21. return a && a.__esModule ? a.default : a;
  22. }
  23. $parcel$export(module.exports, "createDialogScope", () => $f4833395aa1bca1a$export$cc702773b8ea3e41);
  24. $parcel$export(module.exports, "Dialog", () => $f4833395aa1bca1a$export$3ddf2d174ce01153);
  25. $parcel$export(module.exports, "DialogTrigger", () => $f4833395aa1bca1a$export$2e1e1122cf0cba88);
  26. $parcel$export(module.exports, "DialogPortal", () => $f4833395aa1bca1a$export$dad7c95542bacce0);
  27. $parcel$export(module.exports, "DialogOverlay", () => $f4833395aa1bca1a$export$bd1d06c79be19e17);
  28. $parcel$export(module.exports, "DialogContent", () => $f4833395aa1bca1a$export$b6d9565de1e068cf);
  29. $parcel$export(module.exports, "DialogTitle", () => $f4833395aa1bca1a$export$16f7638e4a34b909);
  30. $parcel$export(module.exports, "DialogDescription", () => $f4833395aa1bca1a$export$94e94c2ec2c954d5);
  31. $parcel$export(module.exports, "DialogClose", () => $f4833395aa1bca1a$export$fba2fb7cd781b7ac);
  32. $parcel$export(module.exports, "Root", () => $f4833395aa1bca1a$export$be92b6f5f03c0fe9);
  33. $parcel$export(module.exports, "Trigger", () => $f4833395aa1bca1a$export$41fb9f06171c75f4);
  34. $parcel$export(module.exports, "Portal", () => $f4833395aa1bca1a$export$602eac185826482c);
  35. $parcel$export(module.exports, "Overlay", () => $f4833395aa1bca1a$export$c6fdb837b070b4ff);
  36. $parcel$export(module.exports, "Content", () => $f4833395aa1bca1a$export$7c6e2c02157bb7d2);
  37. $parcel$export(module.exports, "Title", () => $f4833395aa1bca1a$export$f99233281efd08a0);
  38. $parcel$export(module.exports, "Description", () => $f4833395aa1bca1a$export$393edc798c47379d);
  39. $parcel$export(module.exports, "Close", () => $f4833395aa1bca1a$export$f39c2d165cd861fe);
  40. $parcel$export(module.exports, "WarningProvider", () => $f4833395aa1bca1a$export$69b62a49393917d6);
  41. /* -------------------------------------------------------------------------------------------------
  42. * Dialog
  43. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$DIALOG_NAME = 'Dialog';
  44. const [$f4833395aa1bca1a$var$createDialogContext, $f4833395aa1bca1a$export$cc702773b8ea3e41] = $aJCrN$radixuireactcontext.createContextScope($f4833395aa1bca1a$var$DIALOG_NAME);
  45. const [$f4833395aa1bca1a$var$DialogProvider, $f4833395aa1bca1a$var$useDialogContext] = $f4833395aa1bca1a$var$createDialogContext($f4833395aa1bca1a$var$DIALOG_NAME);
  46. const $f4833395aa1bca1a$export$3ddf2d174ce01153 = (props)=>{
  47. const { __scopeDialog: __scopeDialog , children: children , open: openProp , defaultOpen: defaultOpen , onOpenChange: onOpenChange , modal: modal = true } = props;
  48. const triggerRef = $aJCrN$react.useRef(null);
  49. const contentRef = $aJCrN$react.useRef(null);
  50. const [open = false, setOpen] = $aJCrN$radixuireactusecontrollablestate.useControllableState({
  51. prop: openProp,
  52. defaultProp: defaultOpen,
  53. onChange: onOpenChange
  54. });
  55. return /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogProvider, {
  56. scope: __scopeDialog,
  57. triggerRef: triggerRef,
  58. contentRef: contentRef,
  59. contentId: $aJCrN$radixuireactid.useId(),
  60. titleId: $aJCrN$radixuireactid.useId(),
  61. descriptionId: $aJCrN$radixuireactid.useId(),
  62. open: open,
  63. onOpenChange: setOpen,
  64. onOpenToggle: $aJCrN$react.useCallback(()=>setOpen((prevOpen)=>!prevOpen
  65. )
  66. , [
  67. setOpen
  68. ]),
  69. modal: modal
  70. }, children);
  71. };
  72. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$3ddf2d174ce01153, {
  73. displayName: $f4833395aa1bca1a$var$DIALOG_NAME
  74. });
  75. /* -------------------------------------------------------------------------------------------------
  76. * DialogTrigger
  77. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$TRIGGER_NAME = 'DialogTrigger';
  78. const $f4833395aa1bca1a$export$2e1e1122cf0cba88 = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  79. const { __scopeDialog: __scopeDialog , ...triggerProps } = props;
  80. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$TRIGGER_NAME, __scopeDialog);
  81. const composedTriggerRef = $aJCrN$radixuireactcomposerefs.useComposedRefs(forwardedRef, context.triggerRef);
  82. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  83. type: "button",
  84. "aria-haspopup": "dialog",
  85. "aria-expanded": context.open,
  86. "aria-controls": context.contentId,
  87. "data-state": $f4833395aa1bca1a$var$getState(context.open)
  88. }, triggerProps, {
  89. ref: composedTriggerRef,
  90. onClick: $aJCrN$radixuiprimitive.composeEventHandlers(props.onClick, context.onOpenToggle)
  91. }));
  92. });
  93. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$2e1e1122cf0cba88, {
  94. displayName: $f4833395aa1bca1a$var$TRIGGER_NAME
  95. });
  96. /* -------------------------------------------------------------------------------------------------
  97. * DialogPortal
  98. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$PORTAL_NAME = 'DialogPortal';
  99. const [$f4833395aa1bca1a$var$PortalProvider, $f4833395aa1bca1a$var$usePortalContext] = $f4833395aa1bca1a$var$createDialogContext($f4833395aa1bca1a$var$PORTAL_NAME, {
  100. forceMount: undefined
  101. });
  102. const $f4833395aa1bca1a$export$dad7c95542bacce0 = (props)=>{
  103. const { __scopeDialog: __scopeDialog , forceMount: forceMount , children: children , container: container } = props;
  104. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$PORTAL_NAME, __scopeDialog);
  105. return /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$PortalProvider, {
  106. scope: __scopeDialog,
  107. forceMount: forceMount
  108. }, $aJCrN$react.Children.map(children, (child)=>/*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactpresence.Presence, {
  109. present: forceMount || context.open
  110. }, /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactportal.Portal, {
  111. asChild: true,
  112. container: container
  113. }, child))
  114. ));
  115. };
  116. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$dad7c95542bacce0, {
  117. displayName: $f4833395aa1bca1a$var$PORTAL_NAME
  118. });
  119. /* -------------------------------------------------------------------------------------------------
  120. * DialogOverlay
  121. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$OVERLAY_NAME = 'DialogOverlay';
  122. const $f4833395aa1bca1a$export$bd1d06c79be19e17 = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  123. const portalContext = $f4833395aa1bca1a$var$usePortalContext($f4833395aa1bca1a$var$OVERLAY_NAME, props.__scopeDialog);
  124. const { forceMount: forceMount = portalContext.forceMount , ...overlayProps } = props;
  125. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$OVERLAY_NAME, props.__scopeDialog);
  126. return context.modal ? /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactpresence.Presence, {
  127. present: forceMount || context.open
  128. }, /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogOverlayImpl, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({}, overlayProps, {
  129. ref: forwardedRef
  130. }))) : null;
  131. });
  132. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$bd1d06c79be19e17, {
  133. displayName: $f4833395aa1bca1a$var$OVERLAY_NAME
  134. });
  135. const $f4833395aa1bca1a$var$DialogOverlayImpl = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  136. const { __scopeDialog: __scopeDialog , ...overlayProps } = props;
  137. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$OVERLAY_NAME, __scopeDialog);
  138. return(/*#__PURE__*/ // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
  139. // ie. when `Overlay` and `Content` are siblings
  140. $aJCrN$react.createElement($aJCrN$reactremovescroll.RemoveScroll, {
  141. as: $aJCrN$radixuireactslot.Slot,
  142. allowPinchZoom: true,
  143. shards: [
  144. context.contentRef
  145. ]
  146. }, /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactprimitive.Primitive.div, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  147. "data-state": $f4833395aa1bca1a$var$getState(context.open)
  148. }, overlayProps, {
  149. ref: forwardedRef // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.
  150. ,
  151. style: {
  152. pointerEvents: 'auto',
  153. ...overlayProps.style
  154. }
  155. }))));
  156. });
  157. /* -------------------------------------------------------------------------------------------------
  158. * DialogContent
  159. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$CONTENT_NAME = 'DialogContent';
  160. const $f4833395aa1bca1a$export$b6d9565de1e068cf = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  161. const portalContext = $f4833395aa1bca1a$var$usePortalContext($f4833395aa1bca1a$var$CONTENT_NAME, props.__scopeDialog);
  162. const { forceMount: forceMount = portalContext.forceMount , ...contentProps } = props;
  163. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$CONTENT_NAME, props.__scopeDialog);
  164. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactpresence.Presence, {
  165. present: forceMount || context.open
  166. }, context.modal ? /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogContentModal, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({}, contentProps, {
  167. ref: forwardedRef
  168. })) : /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogContentNonModal, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({}, contentProps, {
  169. ref: forwardedRef
  170. })));
  171. });
  172. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$b6d9565de1e068cf, {
  173. displayName: $f4833395aa1bca1a$var$CONTENT_NAME
  174. });
  175. /* -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$DialogContentModal = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  176. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$CONTENT_NAME, props.__scopeDialog);
  177. const contentRef = $aJCrN$react.useRef(null);
  178. const composedRefs = $aJCrN$radixuireactcomposerefs.useComposedRefs(forwardedRef, context.contentRef, contentRef); // aria-hide everything except the content (better supported equivalent to setting aria-modal)
  179. $aJCrN$react.useEffect(()=>{
  180. const content = contentRef.current;
  181. if (content) return $aJCrN$ariahidden.hideOthers(content);
  182. }, []);
  183. return /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogContentImpl, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({}, props, {
  184. ref: composedRefs // we make sure focus isn't trapped once `DialogContent` has been closed
  185. ,
  186. trapFocus: context.open,
  187. disableOutsidePointerEvents: true,
  188. onCloseAutoFocus: $aJCrN$radixuiprimitive.composeEventHandlers(props.onCloseAutoFocus, (event)=>{
  189. var _context$triggerRef$c;
  190. event.preventDefault();
  191. (_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
  192. }),
  193. onPointerDownOutside: $aJCrN$radixuiprimitive.composeEventHandlers(props.onPointerDownOutside, (event)=>{
  194. const originalEvent = event.detail.originalEvent;
  195. const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
  196. const isRightClick = originalEvent.button === 2 || ctrlLeftClick; // If the event is a right-click, we shouldn't close because
  197. // it is effectively as if we right-clicked the `Overlay`.
  198. if (isRightClick) event.preventDefault();
  199. }) // When focus is trapped, a `focusout` event may still happen.
  200. ,
  201. onFocusOutside: $aJCrN$radixuiprimitive.composeEventHandlers(props.onFocusOutside, (event)=>event.preventDefault()
  202. )
  203. }));
  204. });
  205. /* -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$DialogContentNonModal = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  206. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$CONTENT_NAME, props.__scopeDialog);
  207. const hasInteractedOutsideRef = $aJCrN$react.useRef(false);
  208. const hasPointerDownOutsideRef = $aJCrN$react.useRef(false);
  209. return /*#__PURE__*/ $aJCrN$react.createElement($f4833395aa1bca1a$var$DialogContentImpl, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({}, props, {
  210. ref: forwardedRef,
  211. trapFocus: false,
  212. disableOutsidePointerEvents: false,
  213. onCloseAutoFocus: (event)=>{
  214. var _props$onCloseAutoFoc;
  215. (_props$onCloseAutoFoc = props.onCloseAutoFocus) === null || _props$onCloseAutoFoc === void 0 || _props$onCloseAutoFoc.call(props, event);
  216. if (!event.defaultPrevented) {
  217. var _context$triggerRef$c2;
  218. if (!hasInteractedOutsideRef.current) (_context$triggerRef$c2 = context.triggerRef.current) === null || _context$triggerRef$c2 === void 0 || _context$triggerRef$c2.focus(); // Always prevent auto focus because we either focus manually or want user agent focus
  219. event.preventDefault();
  220. }
  221. hasInteractedOutsideRef.current = false;
  222. hasPointerDownOutsideRef.current = false;
  223. },
  224. onInteractOutside: (event)=>{
  225. var _props$onInteractOuts, _context$triggerRef$c3;
  226. (_props$onInteractOuts = props.onInteractOutside) === null || _props$onInteractOuts === void 0 || _props$onInteractOuts.call(props, event);
  227. if (!event.defaultPrevented) {
  228. hasInteractedOutsideRef.current = true;
  229. if (event.detail.originalEvent.type === 'pointerdown') hasPointerDownOutsideRef.current = true;
  230. } // Prevent dismissing when clicking the trigger.
  231. // As the trigger is already setup to close, without doing so would
  232. // cause it to close and immediately open.
  233. const target = event.target;
  234. const targetIsTrigger = (_context$triggerRef$c3 = context.triggerRef.current) === null || _context$triggerRef$c3 === void 0 ? void 0 : _context$triggerRef$c3.contains(target);
  235. if (targetIsTrigger) event.preventDefault(); // On Safari if the trigger is inside a container with tabIndex={0}, when clicked
  236. // we will get the pointer down outside event on the trigger, but then a subsequent
  237. // focus outside event on the container, we ignore any focus outside event when we've
  238. // already had a pointer down outside event.
  239. if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) event.preventDefault();
  240. }
  241. }));
  242. });
  243. /* -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$DialogContentImpl = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  244. const { __scopeDialog: __scopeDialog , trapFocus: trapFocus , onOpenAutoFocus: onOpenAutoFocus , onCloseAutoFocus: onCloseAutoFocus , ...contentProps } = props;
  245. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$CONTENT_NAME, __scopeDialog);
  246. const contentRef = $aJCrN$react.useRef(null);
  247. const composedRefs = $aJCrN$radixuireactcomposerefs.useComposedRefs(forwardedRef, contentRef); // Make sure the whole tree has focus guards as our `Dialog` will be
  248. // the last element in the DOM (beacuse of the `Portal`)
  249. $aJCrN$radixuireactfocusguards.useFocusGuards();
  250. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$react.Fragment, null, /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactfocusscope.FocusScope, {
  251. asChild: true,
  252. loop: true,
  253. trapped: trapFocus,
  254. onMountAutoFocus: onOpenAutoFocus,
  255. onUnmountAutoFocus: onCloseAutoFocus
  256. }, /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactdismissablelayer.DismissableLayer, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  257. role: "dialog",
  258. id: context.contentId,
  259. "aria-describedby": context.descriptionId,
  260. "aria-labelledby": context.titleId,
  261. "data-state": $f4833395aa1bca1a$var$getState(context.open)
  262. }, contentProps, {
  263. ref: composedRefs,
  264. onDismiss: ()=>context.onOpenChange(false)
  265. }))), false);
  266. });
  267. /* -------------------------------------------------------------------------------------------------
  268. * DialogTitle
  269. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$TITLE_NAME = 'DialogTitle';
  270. const $f4833395aa1bca1a$export$16f7638e4a34b909 = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  271. const { __scopeDialog: __scopeDialog , ...titleProps } = props;
  272. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$TITLE_NAME, __scopeDialog);
  273. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactprimitive.Primitive.h2, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  274. id: context.titleId
  275. }, titleProps, {
  276. ref: forwardedRef
  277. }));
  278. });
  279. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$16f7638e4a34b909, {
  280. displayName: $f4833395aa1bca1a$var$TITLE_NAME
  281. });
  282. /* -------------------------------------------------------------------------------------------------
  283. * DialogDescription
  284. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$DESCRIPTION_NAME = 'DialogDescription';
  285. const $f4833395aa1bca1a$export$94e94c2ec2c954d5 = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  286. const { __scopeDialog: __scopeDialog , ...descriptionProps } = props;
  287. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$DESCRIPTION_NAME, __scopeDialog);
  288. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactprimitive.Primitive.p, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  289. id: context.descriptionId
  290. }, descriptionProps, {
  291. ref: forwardedRef
  292. }));
  293. });
  294. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$94e94c2ec2c954d5, {
  295. displayName: $f4833395aa1bca1a$var$DESCRIPTION_NAME
  296. });
  297. /* -------------------------------------------------------------------------------------------------
  298. * DialogClose
  299. * -----------------------------------------------------------------------------------------------*/ const $f4833395aa1bca1a$var$CLOSE_NAME = 'DialogClose';
  300. const $f4833395aa1bca1a$export$fba2fb7cd781b7ac = /*#__PURE__*/ $aJCrN$react.forwardRef((props, forwardedRef)=>{
  301. const { __scopeDialog: __scopeDialog , ...closeProps } = props;
  302. const context = $f4833395aa1bca1a$var$useDialogContext($f4833395aa1bca1a$var$CLOSE_NAME, __scopeDialog);
  303. return /*#__PURE__*/ $aJCrN$react.createElement($aJCrN$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($aJCrN$babelruntimehelpersextends))({
  304. type: "button"
  305. }, closeProps, {
  306. ref: forwardedRef,
  307. onClick: $aJCrN$radixuiprimitive.composeEventHandlers(props.onClick, ()=>context.onOpenChange(false)
  308. )
  309. }));
  310. });
  311. /*#__PURE__*/ Object.assign($f4833395aa1bca1a$export$fba2fb7cd781b7ac, {
  312. displayName: $f4833395aa1bca1a$var$CLOSE_NAME
  313. });
  314. /* -----------------------------------------------------------------------------------------------*/ function $f4833395aa1bca1a$var$getState(open) {
  315. return open ? 'open' : 'closed';
  316. }
  317. const $f4833395aa1bca1a$var$TITLE_WARNING_NAME = 'DialogTitleWarning';
  318. const [$f4833395aa1bca1a$export$69b62a49393917d6, $f4833395aa1bca1a$var$useWarningContext] = $aJCrN$radixuireactcontext.createContext($f4833395aa1bca1a$var$TITLE_WARNING_NAME, {
  319. contentName: $f4833395aa1bca1a$var$CONTENT_NAME,
  320. titleName: $f4833395aa1bca1a$var$TITLE_NAME,
  321. docsSlug: 'dialog'
  322. });
  323. const $f4833395aa1bca1a$var$TitleWarning = ({ titleId: titleId })=>{
  324. const titleWarningContext = $f4833395aa1bca1a$var$useWarningContext($f4833395aa1bca1a$var$TITLE_WARNING_NAME);
  325. const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
  326. If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
  327. For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
  328. $aJCrN$react.useEffect(()=>{
  329. if (titleId) {
  330. const hasTitle = document.getElementById(titleId);
  331. if (!hasTitle) throw new Error(MESSAGE);
  332. }
  333. }, [
  334. MESSAGE,
  335. titleId
  336. ]);
  337. return null;
  338. };
  339. const $f4833395aa1bca1a$var$DESCRIPTION_WARNING_NAME = 'DialogDescriptionWarning';
  340. const $f4833395aa1bca1a$var$DescriptionWarning = ({ contentRef: contentRef , descriptionId: descriptionId })=>{
  341. const descriptionWarningContext = $f4833395aa1bca1a$var$useWarningContext($f4833395aa1bca1a$var$DESCRIPTION_WARNING_NAME);
  342. const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
  343. $aJCrN$react.useEffect(()=>{
  344. var _contentRef$current;
  345. const describedById = (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.getAttribute('aria-describedby'); // if we have an id and the user hasn't set aria-describedby={undefined}
  346. if (descriptionId && describedById) {
  347. const hasDescription = document.getElementById(descriptionId);
  348. if (!hasDescription) console.warn(MESSAGE);
  349. }
  350. }, [
  351. MESSAGE,
  352. contentRef,
  353. descriptionId
  354. ]);
  355. return null;
  356. };
  357. const $f4833395aa1bca1a$export$be92b6f5f03c0fe9 = $f4833395aa1bca1a$export$3ddf2d174ce01153;
  358. const $f4833395aa1bca1a$export$41fb9f06171c75f4 = $f4833395aa1bca1a$export$2e1e1122cf0cba88;
  359. const $f4833395aa1bca1a$export$602eac185826482c = $f4833395aa1bca1a$export$dad7c95542bacce0;
  360. const $f4833395aa1bca1a$export$c6fdb837b070b4ff = $f4833395aa1bca1a$export$bd1d06c79be19e17;
  361. const $f4833395aa1bca1a$export$7c6e2c02157bb7d2 = $f4833395aa1bca1a$export$b6d9565de1e068cf;
  362. const $f4833395aa1bca1a$export$f99233281efd08a0 = $f4833395aa1bca1a$export$16f7638e4a34b909;
  363. const $f4833395aa1bca1a$export$393edc798c47379d = $f4833395aa1bca1a$export$94e94c2ec2c954d5;
  364. const $f4833395aa1bca1a$export$f39c2d165cd861fe = $f4833395aa1bca1a$export$fba2fb7cd781b7ac;
  365. //# sourceMappingURL=index.js.map