@radix-ui/react-dialog 1.3.1 → 1.3.2-rc.1791984254107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -20
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +76 -20
- package/dist/index.mjs.map +2 -2
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -68,8 +68,9 @@ var import_react_primitive = require("@radix-ui/react-primitive");
|
|
|
68
68
|
var import_react_focus_guards = require("@radix-ui/react-focus-guards");
|
|
69
69
|
var import_react_use_layout_effect = require("@radix-ui/react-use-layout-effect");
|
|
70
70
|
var import_react_remove_scroll = require("react-remove-scroll");
|
|
71
|
-
var
|
|
71
|
+
var import_primitive2 = require("@radix-ui/primitive");
|
|
72
72
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
73
|
+
var import_is_development = require("@radix-ui/env-check/is-development");
|
|
73
74
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
74
75
|
var DIALOG_NAME = "Dialog";
|
|
75
76
|
var [createDialogContext, createDialogScope] = (0, import_react_context.createContextScope)(DIALOG_NAME);
|
|
@@ -92,21 +93,37 @@ var Dialog = /* @__PURE__ */ __name((props) => {
|
|
|
92
93
|
onChange: onOpenChange,
|
|
93
94
|
caller: DIALOG_NAME
|
|
94
95
|
});
|
|
96
|
+
const defaultTitleId = (0, import_react_id.useId)();
|
|
97
|
+
const defaultContentId = (0, import_react_id.useId)();
|
|
98
|
+
const [titleId, setTitleId] = React.useState(defaultTitleId);
|
|
99
|
+
const [contentId, setContentId] = React.useState(defaultContentId);
|
|
100
|
+
const [descriptionIds, setDescriptionIds] = React.useState(() => /* @__PURE__ */ new Set());
|
|
95
101
|
const [titleCount, setTitleCount] = React.useState(0);
|
|
96
|
-
|
|
102
|
+
if (import_is_development.IS_DEVELOPMENT) {
|
|
103
|
+
const hasMultipleTitles = titleCount > 1;
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
if (hasMultipleTitles) {
|
|
106
|
+
console.warn(
|
|
107
|
+
"Dialog has multiple titles. This is not supported and will lead to accessibility issues."
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}, [hasMultipleTitles]);
|
|
111
|
+
}
|
|
97
112
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
113
|
DialogProvider,
|
|
99
114
|
{
|
|
100
115
|
scope: __scopeDialog,
|
|
101
116
|
triggerRef,
|
|
102
117
|
contentRef,
|
|
103
|
-
contentId:
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
contentId: contentId || defaultContentId,
|
|
119
|
+
setContentId,
|
|
120
|
+
titleId: titleId || defaultTitleId,
|
|
121
|
+
setTitleId,
|
|
122
|
+
descriptionIds,
|
|
123
|
+
setDescriptionIds,
|
|
106
124
|
titlePresent: titleCount > 0,
|
|
107
|
-
descriptionPresent:
|
|
125
|
+
descriptionPresent: descriptionIds.size > 0,
|
|
108
126
|
setTitleCount,
|
|
109
|
-
setDescriptionCount,
|
|
110
127
|
open,
|
|
111
128
|
onOpenChange: setOpen,
|
|
112
129
|
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
@@ -209,7 +226,10 @@ var DialogContentModal = /* @__PURE__ */ React.forwardRef(
|
|
|
209
226
|
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.contentRef, contentRef);
|
|
210
227
|
React.useEffect(() => {
|
|
211
228
|
const content = contentRef.current;
|
|
212
|
-
if (content)
|
|
229
|
+
if (content) {
|
|
230
|
+
const ownerDocument = content.ownerDocument;
|
|
231
|
+
return (0, import_primitive2.hideOthers)(/* @__PURE__ */ new Set([content]), ownerDocument.body);
|
|
232
|
+
}
|
|
213
233
|
}, []);
|
|
214
234
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
215
235
|
DialogContentImpl,
|
|
@@ -287,10 +307,16 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
287
307
|
onCloseAutoFocus,
|
|
288
308
|
"aria-describedby": ariaDescribedby,
|
|
289
309
|
children,
|
|
310
|
+
id: idProp,
|
|
290
311
|
...contentProps
|
|
291
312
|
} = props;
|
|
292
313
|
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
293
314
|
(0, import_react_focus_guards.useFocusGuards)();
|
|
315
|
+
const { setContentId } = context;
|
|
316
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
317
|
+
setContentId(toValidId(idProp) || void 0);
|
|
318
|
+
return () => setContentId(void 0);
|
|
319
|
+
}, [idProp, setContentId]);
|
|
294
320
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_focus_scope.FocusScopeBranchProvider, { registry: context.branchRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
321
|
import_react_focus_scope.FocusScope,
|
|
296
322
|
{
|
|
@@ -306,7 +332,7 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
306
332
|
role: "dialog",
|
|
307
333
|
id: context.contentId,
|
|
308
334
|
"aria-labelledby": context.titlePresent ? context.titleId : void 0,
|
|
309
|
-
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, context.
|
|
335
|
+
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, ...context.descriptionIds) : ariaDescribedby,
|
|
310
336
|
"data-state": getState(context.open),
|
|
311
337
|
...contentProps,
|
|
312
338
|
ref: forwardedRef,
|
|
@@ -321,27 +347,46 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
321
347
|
);
|
|
322
348
|
var DialogTitle = /* @__PURE__ */ React.forwardRef(
|
|
323
349
|
/* @__PURE__ */ __name(function DialogTitle2(props, forwardedRef) {
|
|
324
|
-
const { __scopeDialog, ...titleProps } = props;
|
|
350
|
+
const { __scopeDialog, id: idProp, ...titleProps } = props;
|
|
325
351
|
const context = useDialogContext("DialogTitle", __scopeDialog);
|
|
326
|
-
const { setTitleCount } = context;
|
|
352
|
+
const { setTitleCount, setTitleId } = context;
|
|
327
353
|
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
328
354
|
setTitleCount((count) => count + 1);
|
|
329
355
|
return () => setTitleCount((count) => count - 1);
|
|
330
356
|
}, [setTitleCount]);
|
|
357
|
+
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
358
|
+
setTitleId(toValidId(idProp) || void 0);
|
|
359
|
+
return () => setTitleId(void 0);
|
|
360
|
+
}, [idProp, setTitleId]);
|
|
331
361
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
332
362
|
}, "DialogTitle")
|
|
333
363
|
);
|
|
334
364
|
var DialogDescription = /* @__PURE__ */ React.forwardRef(
|
|
335
365
|
// blank line to reduce diff noise
|
|
336
366
|
/* @__PURE__ */ __name(function DialogDescription2(props, forwardedRef) {
|
|
337
|
-
const { __scopeDialog, ...descriptionProps } = props;
|
|
367
|
+
const { __scopeDialog, id: idProp, ...descriptionProps } = props;
|
|
338
368
|
const context = useDialogContext("DialogDescription", __scopeDialog);
|
|
339
|
-
const {
|
|
369
|
+
const { setDescriptionIds } = context;
|
|
370
|
+
const generatedId = (0, import_react_id.useId)();
|
|
371
|
+
const id = toValidId(idProp) || generatedId;
|
|
340
372
|
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
373
|
+
setDescriptionIds((descriptionIds) => {
|
|
374
|
+
if (descriptionIds.has(id)) {
|
|
375
|
+
return descriptionIds;
|
|
376
|
+
}
|
|
377
|
+
const newDescriptionIds = new Set(descriptionIds);
|
|
378
|
+
newDescriptionIds.add(id);
|
|
379
|
+
return newDescriptionIds;
|
|
380
|
+
});
|
|
381
|
+
return () => {
|
|
382
|
+
setDescriptionIds((descriptionIds) => {
|
|
383
|
+
const newDescriptionIds = new Set(descriptionIds);
|
|
384
|
+
newDescriptionIds.delete(id);
|
|
385
|
+
return newDescriptionIds.size === descriptionIds.size ? descriptionIds : newDescriptionIds;
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
}, [setDescriptionIds, id]);
|
|
389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.p, { id, ...descriptionProps, ref: forwardedRef });
|
|
345
390
|
}, "DialogDescription")
|
|
346
391
|
);
|
|
347
392
|
var CLOSE_NAME = "DialogClose";
|
|
@@ -366,9 +411,13 @@ var WarningProvider = /* @__PURE__ */ __name((props) => {
|
|
|
366
411
|
function concatAriaDescribedby(...values) {
|
|
367
412
|
const ids = /* @__PURE__ */ new Set();
|
|
368
413
|
for (const value of values) {
|
|
369
|
-
if (typeof value !== "string")
|
|
370
|
-
|
|
371
|
-
|
|
414
|
+
if (typeof value !== "string") {
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
for (const id of value.trim().split(/\s+/)) {
|
|
418
|
+
if (id) {
|
|
419
|
+
ids.add(id);
|
|
420
|
+
}
|
|
372
421
|
}
|
|
373
422
|
}
|
|
374
423
|
return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
|
|
@@ -378,4 +427,11 @@ function getState(open) {
|
|
|
378
427
|
return open ? "open" : "closed";
|
|
379
428
|
}
|
|
380
429
|
__name(getState, "getState");
|
|
430
|
+
function toValidId(value) {
|
|
431
|
+
if (typeof value === "number") {
|
|
432
|
+
return String(value);
|
|
433
|
+
}
|
|
434
|
+
return value;
|
|
435
|
+
}
|
|
436
|
+
__name(toValidId, "toValidId");
|
|
381
437
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/dialog.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n /** @deprecated Noop component to avoid breaking changes. */\n WarningProvider,\n} from './dialog';\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n} from './dialog';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer, useDismissableLayerSurface } from '@radix-ui/react-dismissable-layer';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { createSlot } from '@radix-ui/react-slot';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope | undefined };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentRef: React.RefObject<DialogContentElement | null>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setDescriptionCount: React.Dispatch<React.SetStateAction<number>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n // Nodes of nested, portalled layers (eg. a non-modal `Popover`) that should\n // be treated as part of this Dialog for focus trapping and scroll locking.\n // See https://github.com/radix-ui/primitives/issues/3423\n branchNodes: HTMLElement[];\n branchRegistry: FocusScopeBranchRegistry;\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode | undefined;\n open?: boolean | undefined;\n defaultOpen?: boolean | undefined;\n onOpenChange?: { bivarianceHack(open: boolean): void }['bivarianceHack'] | undefined;\n modal?: boolean | undefined;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: DIALOG_NAME,\n });\n\n const [titleCount, setTitleCount] = React.useState(0);\n const [descriptionCount, setDescriptionCount] = React.useState(0);\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionCount > 0}\n setTitleCount={setTitleCount}\n setDescriptionCount={setDescriptionCount}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n >\n {children}\n </DialogProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = /* @__PURE__ */ React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n function DialogTrigger(props: ScopedProps<DialogTriggerProps>, forwardedRef) {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalContextValue = { forceMount?: true | undefined };\nconst [PortalProvider, usePortalContext] = createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode | undefined;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'] | undefined;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <PortalProvider scope={__scopeDialog} forceMount={forceMount}>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {child}\n </PortalPrimitive>\n </Presence>\n ))}\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogOverlay = /* @__PURE__ */ React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n function DialogOverlay(props: ScopedProps<DialogOverlayProps>, forwardedRef) {\n const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n },\n);\n\ntype DialogOverlayImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst Slot = createSlot('DialogOverlay.RemoveScroll');\n\nconst DialogOverlayImpl = /* @__PURE__ */ React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>(\n // blank line to reduce diff noise\n function DialogOverlayImpl(props: ScopedProps<DialogOverlayImplProps>, forwardedRef) {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n\n // Register the overlay as a dismiss surface so a consumer calling\n // `stopPropagation` on it (eg. to avoid triggering parent handlers) does not\n // prevent the dialog from closing. See: https://github.com/radix-ui/primitives/issues/3346\n const registerDismissableSurface = useDismissableLayerSurface();\n const composedRefs = useComposedRefs(forwardedRef, registerDismissableSurface);\n\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside\n // `RemoveScroll` (eg. when `Overlay` and `Content` are siblings). Nested\n // layers are registered as branches and added as shards so they remain\n // scrollable too. See https://github.com/radix-ui/primitives/issues/3423\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [context.contentRef, ...context.branchNodes.map((node) => ({ current: node }))],\n [context.contentRef, context.branchNodes],\n )}\n >\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={composedRefs}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogContent = /* @__PURE__ */ React.forwardRef<DialogContentElement, DialogContentProps>(\n function DialogContent(props: ScopedProps<DialogContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps extends Omit<\n DialogContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst DialogContentModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents={context.open}\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault(),\n )}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentNonModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ComponentRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'] | undefined;\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'] | undefined;\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'] | undefined;\n}\n\nconst DialogContentImpl = /* @__PURE__ */ React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>(\n // blank line to reduce diff noise\n function DialogContentImpl(props: ScopedProps<DialogContentImplProps>, forwardedRef) {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n 'aria-describedby': ariaDescribedby,\n children,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScopeBranchProvider registry={context.branchRegistry}>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={context.branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, context.descriptionId)\n : ariaDescribedby\n }\n data-state={getState(context.open)}\n {...contentProps}\n ref={forwardedRef}\n deferPointerDownOutside\n onDismiss={() => context.onOpenChange(false)}\n >\n {children}\n </DismissableLayer>\n </FocusScope>\n </FocusScopeBranchProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = /* @__PURE__ */ React.forwardRef<DialogTitleElement, DialogTitleProps>(\n function DialogTitle(props: ScopedProps<DialogTitleProps>, forwardedRef) {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext('DialogTitle', __scopeDialog);\n const { setTitleCount } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = /* @__PURE__ */ React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>(\n // blank line to reduce diff noise\n function DialogDescription(props: ScopedProps<DialogDescriptionProps>, forwardedRef) {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext('DialogDescription', __scopeDialog);\n const { setDescriptionCount } = context;\n useLayoutEffect(() => {\n setDescriptionCount((count) => count + 1);\n return () => setDescriptionCount((count) => count - 1);\n }, [setDescriptionCount]);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = /* @__PURE__ */ React.forwardRef<DialogCloseElement, DialogCloseProps>(\n function DialogClose(props: ScopedProps<DialogCloseProps>, forwardedRef) {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/** @deprecated Noop component to avoid breaking changes. */\nexport const WarningProvider: React.FC<\n ScopedProps<{\n children?: React.ReactNode | undefined;\n contentName: string;\n titleName: string;\n docsSlug: 'dialog';\n }>\n> = (props) => {\n return props.children;\n};\n\n/* -----------------------------------------------------------------------------------------------*/\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Dialog as Root,\n DialogTrigger as Trigger,\n DialogPortal as Portal,\n DialogOverlay as Overlay,\n DialogContent as Content,\n DialogTitle as Title,\n DialogDescription as Description,\n DialogClose as Close,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,gCAAgC;AAChC,2BAAmC;AACnC,sBAAsB;AACtB,0CAAqC;AACrC,qCAA6D;AAC7D,+BAIO;AACP,0BAA0C;AAC1C,4BAAyB;AACzB,6BAA0B;AAC1B,gCAA+B;AAC/B,qCAAgC;AAChC,iCAA6B;AAC7B,
|
|
6
|
-
"names": ["DialogTrigger", "PortalPrimitive", "DialogOverlay", "DialogOverlayImpl", "DialogContent", "DialogContentModal", "DialogContentNonModal", "DialogContentImpl", "DialogTitle", "DialogDescription", "DialogClose"]
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Root,\n Trigger,\n Portal,\n Overlay,\n Content,\n Title,\n Description,\n Close,\n /** @deprecated Noop component to avoid breaking changes. */\n WarningProvider,\n} from './dialog';\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n} from './dialog';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer, useDismissableLayerSurface } from '@radix-ui/react-dismissable-layer';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from '@radix-ui/primitive';\nimport { createSlot } from '@radix-ui/react-slot';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\nimport { IS_DEVELOPMENT } from '@radix-ui/env-check/is-development';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope | undefined };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ninterface DialogContextValue {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentRef: React.RefObject<DialogContentElement | null>;\n contentId: string;\n setContentId: React.Dispatch<React.SetStateAction<string | undefined>>;\n titleId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setTitleId: React.Dispatch<React.SetStateAction<string | undefined>>;\n descriptionIds: Set<string>;\n setDescriptionIds: React.Dispatch<React.SetStateAction<Set<string>>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n // Nodes of nested, portalled layers (eg. a non-modal `Popover`) that should\n // be treated as part of this Dialog for focus trapping and scroll locking.\n // See https://github.com/radix-ui/primitives/issues/3423\n branchNodes: HTMLElement[];\n branchRegistry: FocusScopeBranchRegistry;\n}\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode | undefined;\n open?: boolean | undefined;\n defaultOpen?: boolean | undefined;\n onOpenChange?: { bivarianceHack(open: boolean): void }['bivarianceHack'] | undefined;\n modal?: boolean | undefined;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: DIALOG_NAME,\n });\n\n const defaultTitleId = useId();\n const defaultContentId = useId();\n const [titleId, setTitleId] = React.useState<string | undefined>(defaultTitleId);\n const [contentId, setContentId] = React.useState<string | undefined>(defaultContentId);\n const [descriptionIds, setDescriptionIds] = React.useState(() => new Set<string>());\n\n const [titleCount, setTitleCount] = React.useState(0);\n if (IS_DEVELOPMENT) {\n const hasMultipleTitles = titleCount > 1;\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (hasMultipleTitles) {\n console.warn(\n 'Dialog has multiple titles. This is not supported and will lead to accessibility issues.',\n );\n }\n }, [hasMultipleTitles]);\n }\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={contentId || defaultContentId}\n setContentId={setContentId}\n titleId={titleId || defaultTitleId}\n setTitleId={setTitleId}\n descriptionIds={descriptionIds}\n setDescriptionIds={setDescriptionIds}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionIds.size > 0}\n setTitleCount={setTitleCount}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n >\n {children}\n </DialogProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = /* @__PURE__ */ React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n function DialogTrigger(props: ScopedProps<DialogTriggerProps>, forwardedRef) {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalContextValue = { forceMount?: true | undefined };\nconst [PortalProvider, usePortalContext] = createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode | undefined;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'] | undefined;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <PortalProvider scope={__scopeDialog} forceMount={forceMount}>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {child}\n </PortalPrimitive>\n </Presence>\n ))}\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogOverlay = /* @__PURE__ */ React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n function DialogOverlay(props: ScopedProps<DialogOverlayProps>, forwardedRef) {\n const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n },\n);\n\ntype DialogOverlayImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst Slot = createSlot('DialogOverlay.RemoveScroll');\n\nconst DialogOverlayImpl = /* @__PURE__ */ React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>(\n // blank line to reduce diff noise\n function DialogOverlayImpl(props: ScopedProps<DialogOverlayImplProps>, forwardedRef) {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n\n // Register the overlay as a dismiss surface so a consumer calling\n // `stopPropagation` on it (eg. to avoid triggering parent handlers) does not\n // prevent the dialog from closing. See: https://github.com/radix-ui/primitives/issues/3346\n const registerDismissableSurface = useDismissableLayerSurface();\n const composedRefs = useComposedRefs(forwardedRef, registerDismissableSurface);\n\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside\n // `RemoveScroll` (eg. when `Overlay` and `Content` are siblings). Nested\n // layers are registered as branches and added as shards so they remain\n // scrollable too. See https://github.com/radix-ui/primitives/issues/3423\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [context.contentRef, ...context.branchNodes.map((node) => ({ current: node }))],\n [context.contentRef, context.branchNodes],\n )}\n >\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={composedRefs}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogContent = /* @__PURE__ */ React.forwardRef<DialogContentElement, DialogContentProps>(\n function DialogContent(props: ScopedProps<DialogContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps extends Omit<\n DialogContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst DialogContentModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) {\n const ownerDocument = content.ownerDocument;\n return hideOthers(new Set([content]), ownerDocument.body);\n }\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents={context.open}\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault(),\n )}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentNonModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ComponentRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'] | undefined;\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'] | undefined;\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'] | undefined;\n}\n\nconst DialogContentImpl = /* @__PURE__ */ React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>(\n // blank line to reduce diff noise\n function DialogContentImpl(props: ScopedProps<DialogContentImplProps>, forwardedRef) {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n 'aria-describedby': ariaDescribedby,\n children,\n id: idProp,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n const { setContentId } = context;\n useLayoutEffect(() => {\n setContentId(toValidId(idProp) || undefined);\n return () => setContentId(undefined);\n }, [idProp, setContentId]);\n\n return (\n <FocusScopeBranchProvider registry={context.branchRegistry}>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={context.branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, ...context.descriptionIds)\n : ariaDescribedby\n }\n data-state={getState(context.open)}\n {...contentProps}\n ref={forwardedRef}\n deferPointerDownOutside\n onDismiss={() => context.onOpenChange(false)}\n >\n {children}\n </DismissableLayer>\n </FocusScope>\n </FocusScopeBranchProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = /* @__PURE__ */ React.forwardRef<DialogTitleElement, DialogTitleProps>(\n function DialogTitle(props: ScopedProps<DialogTitleProps>, forwardedRef) {\n const { __scopeDialog, id: idProp, ...titleProps } = props;\n const context = useDialogContext('DialogTitle', __scopeDialog);\n const { setTitleCount, setTitleId } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n useLayoutEffect(() => {\n setTitleId(toValidId(idProp) || undefined);\n return () => setTitleId(undefined);\n }, [idProp, setTitleId]);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = /* @__PURE__ */ React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>(\n // blank line to reduce diff noise\n function DialogDescription(props: ScopedProps<DialogDescriptionProps>, forwardedRef) {\n const { __scopeDialog, id: idProp, ...descriptionProps } = props;\n const context = useDialogContext('DialogDescription', __scopeDialog);\n const { setDescriptionIds } = context;\n\n const generatedId = useId();\n const id = toValidId(idProp) || generatedId;\n\n useLayoutEffect(() => {\n setDescriptionIds((descriptionIds) => {\n if (descriptionIds.has(id)) {\n return descriptionIds;\n }\n\n const newDescriptionIds = new Set(descriptionIds);\n newDescriptionIds.add(id);\n return newDescriptionIds;\n });\n return () => {\n setDescriptionIds((descriptionIds) => {\n const newDescriptionIds = new Set(descriptionIds);\n newDescriptionIds.delete(id);\n return newDescriptionIds.size === descriptionIds.size\n ? descriptionIds\n : newDescriptionIds;\n });\n };\n }, [setDescriptionIds, id]);\n\n return <Primitive.p id={id} {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = /* @__PURE__ */ React.forwardRef<DialogCloseElement, DialogCloseProps>(\n function DialogClose(props: ScopedProps<DialogCloseProps>, forwardedRef) {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/** @deprecated Noop component to avoid breaking changes. */\nexport const WarningProvider: React.FC<\n ScopedProps<{\n children?: React.ReactNode | undefined;\n contentName: string;\n titleName: string;\n docsSlug: 'dialog';\n }>\n> = (props) => {\n return props.children;\n};\n\n/* -----------------------------------------------------------------------------------------------*/\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: (string | null | undefined)[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') {\n continue;\n }\n for (const id of value.trim().split(/\\s+/)) {\n if (id) {\n ids.add(id);\n }\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nfunction toValidId(value: number | string | undefined) {\n // We type id's internally as strings, but in some version of React's types a\n // number can be passed without type errors.\n if (typeof value === 'number') {\n return String(value);\n }\n return value;\n}\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Dialog as Root,\n DialogTrigger as Trigger,\n DialogPortal as Portal,\n DialogOverlay as Overlay,\n DialogContent as Content,\n DialogTitle as Title,\n DialogDescription as Description,\n DialogClose as Close,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,gCAAgC;AAChC,2BAAmC;AACnC,sBAAsB;AACtB,0CAAqC;AACrC,qCAA6D;AAC7D,+BAIO;AACP,0BAA0C;AAC1C,4BAAyB;AACzB,6BAA0B;AAC1B,gCAA+B;AAC/B,qCAAgC;AAChC,iCAA6B;AAC7B,IAAAA,oBAA2B;AAC3B,wBAA2B;AAI3B,4BAA+B;AAmF3B;AA7EJ,IAAM,cAAc;AAGpB,IAAM,CAAC,qBAAqB,iBAAiB,QAAI,yCAAmB,WAAW;AAyB/E,IAAM,CAAC,gBAAgB,gBAAgB,IAAI,oBAAwC,WAAW;AAU9F,IAAM,SAAgC,wBAAC,UAAoC;AACzE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AA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5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,UAAU;AAC7B;AAAA,IACF;AACA,eAAW,MAAM,MAAM,KAAK,EAAE,MAAM,KAAK,GAAG;AAC1C,UAAI,IAAI;AACN,YAAI,IAAI,EAAE;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAdS;AAgBT,SAAS,SAAS,MAAe;AAC/B,SAAO,OAAO,SAAS;AACzB;AAFS;AAIT,SAAS,UAAU,OAAoC;AAGrD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO;AACT;AAPS;",
|
|
6
|
+
"names": ["import_primitive", "DialogTrigger", "PortalPrimitive", "DialogOverlay", "DialogOverlayImpl", "DialogContent", "DialogContentModal", "DialogContentNonModal", "DialogContentImpl", "DialogTitle", "DialogDescription", "DialogClose"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -21,8 +21,9 @@ import { Primitive } from "@radix-ui/react-primitive";
|
|
|
21
21
|
import { useFocusGuards } from "@radix-ui/react-focus-guards";
|
|
22
22
|
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
23
23
|
import { RemoveScroll } from "react-remove-scroll";
|
|
24
|
-
import { hideOthers } from "
|
|
24
|
+
import { hideOthers } from "@radix-ui/primitive";
|
|
25
25
|
import { createSlot } from "@radix-ui/react-slot";
|
|
26
|
+
import { IS_DEVELOPMENT } from "@radix-ui/env-check/is-development";
|
|
26
27
|
import { jsx } from "react/jsx-runtime";
|
|
27
28
|
var DIALOG_NAME = "Dialog";
|
|
28
29
|
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
@@ -45,21 +46,37 @@ var Dialog = /* @__PURE__ */ __name((props) => {
|
|
|
45
46
|
onChange: onOpenChange,
|
|
46
47
|
caller: DIALOG_NAME
|
|
47
48
|
});
|
|
49
|
+
const defaultTitleId = useId();
|
|
50
|
+
const defaultContentId = useId();
|
|
51
|
+
const [titleId, setTitleId] = React.useState(defaultTitleId);
|
|
52
|
+
const [contentId, setContentId] = React.useState(defaultContentId);
|
|
53
|
+
const [descriptionIds, setDescriptionIds] = React.useState(() => /* @__PURE__ */ new Set());
|
|
48
54
|
const [titleCount, setTitleCount] = React.useState(0);
|
|
49
|
-
|
|
55
|
+
if (IS_DEVELOPMENT) {
|
|
56
|
+
const hasMultipleTitles = titleCount > 1;
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
if (hasMultipleTitles) {
|
|
59
|
+
console.warn(
|
|
60
|
+
"Dialog has multiple titles. This is not supported and will lead to accessibility issues."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}, [hasMultipleTitles]);
|
|
64
|
+
}
|
|
50
65
|
return /* @__PURE__ */ jsx(
|
|
51
66
|
DialogProvider,
|
|
52
67
|
{
|
|
53
68
|
scope: __scopeDialog,
|
|
54
69
|
triggerRef,
|
|
55
70
|
contentRef,
|
|
56
|
-
contentId:
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
contentId: contentId || defaultContentId,
|
|
72
|
+
setContentId,
|
|
73
|
+
titleId: titleId || defaultTitleId,
|
|
74
|
+
setTitleId,
|
|
75
|
+
descriptionIds,
|
|
76
|
+
setDescriptionIds,
|
|
59
77
|
titlePresent: titleCount > 0,
|
|
60
|
-
descriptionPresent:
|
|
78
|
+
descriptionPresent: descriptionIds.size > 0,
|
|
61
79
|
setTitleCount,
|
|
62
|
-
setDescriptionCount,
|
|
63
80
|
open,
|
|
64
81
|
onOpenChange: setOpen,
|
|
65
82
|
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
@@ -162,7 +179,10 @@ var DialogContentModal = /* @__PURE__ */ React.forwardRef(
|
|
|
162
179
|
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
163
180
|
React.useEffect(() => {
|
|
164
181
|
const content = contentRef.current;
|
|
165
|
-
if (content)
|
|
182
|
+
if (content) {
|
|
183
|
+
const ownerDocument = content.ownerDocument;
|
|
184
|
+
return hideOthers(/* @__PURE__ */ new Set([content]), ownerDocument.body);
|
|
185
|
+
}
|
|
166
186
|
}, []);
|
|
167
187
|
return /* @__PURE__ */ jsx(
|
|
168
188
|
DialogContentImpl,
|
|
@@ -240,10 +260,16 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
240
260
|
onCloseAutoFocus,
|
|
241
261
|
"aria-describedby": ariaDescribedby,
|
|
242
262
|
children,
|
|
263
|
+
id: idProp,
|
|
243
264
|
...contentProps
|
|
244
265
|
} = props;
|
|
245
266
|
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
246
267
|
useFocusGuards();
|
|
268
|
+
const { setContentId } = context;
|
|
269
|
+
useLayoutEffect(() => {
|
|
270
|
+
setContentId(toValidId(idProp) || void 0);
|
|
271
|
+
return () => setContentId(void 0);
|
|
272
|
+
}, [idProp, setContentId]);
|
|
247
273
|
return /* @__PURE__ */ jsx(FocusScopeBranchProvider, { registry: context.branchRegistry, children: /* @__PURE__ */ jsx(
|
|
248
274
|
FocusScope,
|
|
249
275
|
{
|
|
@@ -259,7 +285,7 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
259
285
|
role: "dialog",
|
|
260
286
|
id: context.contentId,
|
|
261
287
|
"aria-labelledby": context.titlePresent ? context.titleId : void 0,
|
|
262
|
-
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, context.
|
|
288
|
+
"aria-describedby": context.descriptionPresent ? concatAriaDescribedby(ariaDescribedby, ...context.descriptionIds) : ariaDescribedby,
|
|
263
289
|
"data-state": getState(context.open),
|
|
264
290
|
...contentProps,
|
|
265
291
|
ref: forwardedRef,
|
|
@@ -274,27 +300,46 @@ var DialogContentImpl = /* @__PURE__ */ React.forwardRef(
|
|
|
274
300
|
);
|
|
275
301
|
var DialogTitle = /* @__PURE__ */ React.forwardRef(
|
|
276
302
|
/* @__PURE__ */ __name(function DialogTitle2(props, forwardedRef) {
|
|
277
|
-
const { __scopeDialog, ...titleProps } = props;
|
|
303
|
+
const { __scopeDialog, id: idProp, ...titleProps } = props;
|
|
278
304
|
const context = useDialogContext("DialogTitle", __scopeDialog);
|
|
279
|
-
const { setTitleCount } = context;
|
|
305
|
+
const { setTitleCount, setTitleId } = context;
|
|
280
306
|
useLayoutEffect(() => {
|
|
281
307
|
setTitleCount((count) => count + 1);
|
|
282
308
|
return () => setTitleCount((count) => count - 1);
|
|
283
309
|
}, [setTitleCount]);
|
|
310
|
+
useLayoutEffect(() => {
|
|
311
|
+
setTitleId(toValidId(idProp) || void 0);
|
|
312
|
+
return () => setTitleId(void 0);
|
|
313
|
+
}, [idProp, setTitleId]);
|
|
284
314
|
return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
285
315
|
}, "DialogTitle")
|
|
286
316
|
);
|
|
287
317
|
var DialogDescription = /* @__PURE__ */ React.forwardRef(
|
|
288
318
|
// blank line to reduce diff noise
|
|
289
319
|
/* @__PURE__ */ __name(function DialogDescription2(props, forwardedRef) {
|
|
290
|
-
const { __scopeDialog, ...descriptionProps } = props;
|
|
320
|
+
const { __scopeDialog, id: idProp, ...descriptionProps } = props;
|
|
291
321
|
const context = useDialogContext("DialogDescription", __scopeDialog);
|
|
292
|
-
const {
|
|
322
|
+
const { setDescriptionIds } = context;
|
|
323
|
+
const generatedId = useId();
|
|
324
|
+
const id = toValidId(idProp) || generatedId;
|
|
293
325
|
useLayoutEffect(() => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
326
|
+
setDescriptionIds((descriptionIds) => {
|
|
327
|
+
if (descriptionIds.has(id)) {
|
|
328
|
+
return descriptionIds;
|
|
329
|
+
}
|
|
330
|
+
const newDescriptionIds = new Set(descriptionIds);
|
|
331
|
+
newDescriptionIds.add(id);
|
|
332
|
+
return newDescriptionIds;
|
|
333
|
+
});
|
|
334
|
+
return () => {
|
|
335
|
+
setDescriptionIds((descriptionIds) => {
|
|
336
|
+
const newDescriptionIds = new Set(descriptionIds);
|
|
337
|
+
newDescriptionIds.delete(id);
|
|
338
|
+
return newDescriptionIds.size === descriptionIds.size ? descriptionIds : newDescriptionIds;
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
}, [setDescriptionIds, id]);
|
|
342
|
+
return /* @__PURE__ */ jsx(Primitive.p, { id, ...descriptionProps, ref: forwardedRef });
|
|
298
343
|
}, "DialogDescription")
|
|
299
344
|
);
|
|
300
345
|
var CLOSE_NAME = "DialogClose";
|
|
@@ -319,9 +364,13 @@ var WarningProvider = /* @__PURE__ */ __name((props) => {
|
|
|
319
364
|
function concatAriaDescribedby(...values) {
|
|
320
365
|
const ids = /* @__PURE__ */ new Set();
|
|
321
366
|
for (const value of values) {
|
|
322
|
-
if (typeof value !== "string")
|
|
323
|
-
|
|
324
|
-
|
|
367
|
+
if (typeof value !== "string") {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
for (const id of value.trim().split(/\s+/)) {
|
|
371
|
+
if (id) {
|
|
372
|
+
ids.add(id);
|
|
373
|
+
}
|
|
325
374
|
}
|
|
326
375
|
}
|
|
327
376
|
return ids.size > 0 ? Array.from(ids).join(" ") : void 0;
|
|
@@ -331,6 +380,13 @@ function getState(open) {
|
|
|
331
380
|
return open ? "open" : "closed";
|
|
332
381
|
}
|
|
333
382
|
__name(getState, "getState");
|
|
383
|
+
function toValidId(value) {
|
|
384
|
+
if (typeof value === "number") {
|
|
385
|
+
return String(value);
|
|
386
|
+
}
|
|
387
|
+
return value;
|
|
388
|
+
}
|
|
389
|
+
__name(toValidId, "toValidId");
|
|
334
390
|
export {
|
|
335
391
|
DialogClose as Close,
|
|
336
392
|
DialogContent as Content,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/dialog.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer, useDismissableLayerSurface } from '@radix-ui/react-dismissable-layer';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from 'aria-hidden';\nimport { createSlot } from '@radix-ui/react-slot';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope | undefined };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentRef: React.RefObject<DialogContentElement | null>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setDescriptionCount: React.Dispatch<React.SetStateAction<number>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n // Nodes of nested, portalled layers (eg. a non-modal `Popover`) that should\n // be treated as part of this Dialog for focus trapping and scroll locking.\n // See https://github.com/radix-ui/primitives/issues/3423\n branchNodes: HTMLElement[];\n branchRegistry: FocusScopeBranchRegistry;\n};\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode | undefined;\n open?: boolean | undefined;\n defaultOpen?: boolean | undefined;\n onOpenChange?: { bivarianceHack(open: boolean): void }['bivarianceHack'] | undefined;\n modal?: boolean | undefined;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: DIALOG_NAME,\n });\n\n const [titleCount, setTitleCount] = React.useState(0);\n const [descriptionCount, setDescriptionCount] = React.useState(0);\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionCount > 0}\n setTitleCount={setTitleCount}\n setDescriptionCount={setDescriptionCount}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n >\n {children}\n </DialogProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = /* @__PURE__ */ React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n function DialogTrigger(props: ScopedProps<DialogTriggerProps>, forwardedRef) {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalContextValue = { forceMount?: true | undefined };\nconst [PortalProvider, usePortalContext] = createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode | undefined;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'] | undefined;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <PortalProvider scope={__scopeDialog} forceMount={forceMount}>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {child}\n </PortalPrimitive>\n </Presence>\n ))}\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogOverlay = /* @__PURE__ */ React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n function DialogOverlay(props: ScopedProps<DialogOverlayProps>, forwardedRef) {\n const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n },\n);\n\ntype DialogOverlayImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst Slot = createSlot('DialogOverlay.RemoveScroll');\n\nconst DialogOverlayImpl = /* @__PURE__ */ React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>(\n // blank line to reduce diff noise\n function DialogOverlayImpl(props: ScopedProps<DialogOverlayImplProps>, forwardedRef) {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n\n // Register the overlay as a dismiss surface so a consumer calling\n // `stopPropagation` on it (eg. to avoid triggering parent handlers) does not\n // prevent the dialog from closing. See: https://github.com/radix-ui/primitives/issues/3346\n const registerDismissableSurface = useDismissableLayerSurface();\n const composedRefs = useComposedRefs(forwardedRef, registerDismissableSurface);\n\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside\n // `RemoveScroll` (eg. when `Overlay` and `Content` are siblings). Nested\n // layers are registered as branches and added as shards so they remain\n // scrollable too. See https://github.com/radix-ui/primitives/issues/3423\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [context.contentRef, ...context.branchNodes.map((node) => ({ current: node }))],\n [context.contentRef, context.branchNodes],\n )}\n >\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={composedRefs}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogContent = /* @__PURE__ */ React.forwardRef<DialogContentElement, DialogContentProps>(\n function DialogContent(props: ScopedProps<DialogContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps extends Omit<\n DialogContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst DialogContentModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents={context.open}\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault(),\n )}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentNonModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ComponentRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'] | undefined;\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'] | undefined;\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'] | undefined;\n}\n\nconst DialogContentImpl = /* @__PURE__ */ React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>(\n // blank line to reduce diff noise\n function DialogContentImpl(props: ScopedProps<DialogContentImplProps>, forwardedRef) {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n 'aria-describedby': ariaDescribedby,\n children,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n return (\n <FocusScopeBranchProvider registry={context.branchRegistry}>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={context.branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, context.descriptionId)\n : ariaDescribedby\n }\n data-state={getState(context.open)}\n {...contentProps}\n ref={forwardedRef}\n deferPointerDownOutside\n onDismiss={() => context.onOpenChange(false)}\n >\n {children}\n </DismissableLayer>\n </FocusScope>\n </FocusScopeBranchProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = /* @__PURE__ */ React.forwardRef<DialogTitleElement, DialogTitleProps>(\n function DialogTitle(props: ScopedProps<DialogTitleProps>, forwardedRef) {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext('DialogTitle', __scopeDialog);\n const { setTitleCount } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = /* @__PURE__ */ React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>(\n // blank line to reduce diff noise\n function DialogDescription(props: ScopedProps<DialogDescriptionProps>, forwardedRef) {\n const { __scopeDialog, ...descriptionProps } = props;\n const context = useDialogContext('DialogDescription', __scopeDialog);\n const { setDescriptionCount } = context;\n useLayoutEffect(() => {\n setDescriptionCount((count) => count + 1);\n return () => setDescriptionCount((count) => count - 1);\n }, [setDescriptionCount]);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = /* @__PURE__ */ React.forwardRef<DialogCloseElement, DialogCloseProps>(\n function DialogClose(props: ScopedProps<DialogCloseProps>, forwardedRef) {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/** @deprecated Noop component to avoid breaking changes. */\nexport const WarningProvider: React.FC<\n ScopedProps<{\n children?: React.ReactNode | undefined;\n contentName: string;\n titleName: string;\n docsSlug: 'dialog';\n }>\n> = (props) => {\n return props.children;\n};\n\n/* -----------------------------------------------------------------------------------------------*/\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: unknown[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') continue;\n for (const id of String(value).trim().split(/\\s+/)) {\n if (id) ids.add(id);\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Dialog as Root,\n DialogTrigger as Trigger,\n DialogPortal as Portal,\n DialogOverlay as Overlay,\n DialogContent as Content,\n DialogTitle as Title,\n DialogDescription as Description,\n DialogClose as Close,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,kBAAkB,kCAAkC;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,uBAAuB;AAC1C,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useId } from '@radix-ui/react-id';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { DismissableLayer, useDismissableLayerSurface } from '@radix-ui/react-dismissable-layer';\nimport {\n FocusScope,\n FocusScopeBranchProvider,\n useFocusScopeBranchRegistry,\n} from '@radix-ui/react-focus-scope';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { useFocusGuards } from '@radix-ui/react-focus-guards';\nimport { useLayoutEffect } from '@radix-ui/react-use-layout-effect';\nimport { RemoveScroll } from 'react-remove-scroll';\nimport { hideOthers } from '@radix-ui/primitive';\nimport { createSlot } from '@radix-ui/react-slot';\n\nimport type { Scope } from '@radix-ui/react-context';\nimport type { FocusScopeBranchRegistry } from '@radix-ui/react-focus-scope';\nimport { IS_DEVELOPMENT } from '@radix-ui/env-check/is-development';\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nconst DIALOG_NAME = 'Dialog';\n\ntype ScopedProps<P> = P & { __scopeDialog?: Scope | undefined };\nconst [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);\n\ninterface DialogContextValue {\n triggerRef: React.RefObject<HTMLButtonElement | null>;\n contentRef: React.RefObject<DialogContentElement | null>;\n contentId: string;\n setContentId: React.Dispatch<React.SetStateAction<string | undefined>>;\n titleId: string;\n titlePresent: boolean;\n descriptionPresent: boolean;\n setTitleCount: React.Dispatch<React.SetStateAction<number>>;\n setTitleId: React.Dispatch<React.SetStateAction<string | undefined>>;\n descriptionIds: Set<string>;\n setDescriptionIds: React.Dispatch<React.SetStateAction<Set<string>>>;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n // Nodes of nested, portalled layers (eg. a non-modal `Popover`) that should\n // be treated as part of this Dialog for focus trapping and scroll locking.\n // See https://github.com/radix-ui/primitives/issues/3423\n branchNodes: HTMLElement[];\n branchRegistry: FocusScopeBranchRegistry;\n}\n\nconst [DialogProvider, useDialogContext] = createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode | undefined;\n open?: boolean | undefined;\n defaultOpen?: boolean | undefined;\n onOpenChange?: { bivarianceHack(open: boolean): void }['bivarianceHack'] | undefined;\n modal?: boolean | undefined;\n}\n\nconst Dialog: React.FC<DialogProps> = (props: ScopedProps<DialogProps>) => {\n const {\n __scopeDialog,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = true,\n } = props;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const contentRef = React.useRef<DialogContentElement>(null);\n const { nodes: branchNodes, registry: branchRegistry } = useFocusScopeBranchRegistry();\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: DIALOG_NAME,\n });\n\n const defaultTitleId = useId();\n const defaultContentId = useId();\n const [titleId, setTitleId] = React.useState<string | undefined>(defaultTitleId);\n const [contentId, setContentId] = React.useState<string | undefined>(defaultContentId);\n const [descriptionIds, setDescriptionIds] = React.useState(() => new Set<string>());\n\n const [titleCount, setTitleCount] = React.useState(0);\n if (IS_DEVELOPMENT) {\n const hasMultipleTitles = titleCount > 1;\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (hasMultipleTitles) {\n console.warn(\n 'Dialog has multiple titles. This is not supported and will lead to accessibility issues.',\n );\n }\n }, [hasMultipleTitles]);\n }\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={contentId || defaultContentId}\n setContentId={setContentId}\n titleId={titleId || defaultTitleId}\n setTitleId={setTitleId}\n descriptionIds={descriptionIds}\n setDescriptionIds={setDescriptionIds}\n titlePresent={titleCount > 0}\n descriptionPresent={descriptionIds.size > 0}\n setTitleCount={setTitleCount}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen])}\n modal={modal}\n branchNodes={branchNodes}\n branchRegistry={branchRegistry}\n >\n {children}\n </DialogProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'DialogTrigger';\n\ntype DialogTriggerElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = /* @__PURE__ */ React.forwardRef<DialogTriggerElement, DialogTriggerProps>(\n function DialogTrigger(props: ScopedProps<DialogTriggerProps>, forwardedRef) {\n const { __scopeDialog, ...triggerProps } = props;\n const context = useDialogContext(TRIGGER_NAME, __scopeDialog);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n return (\n <Primitive.button\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n aria-controls={context.open ? context.contentId : undefined}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'DialogPortal';\n\ntype PortalContextValue = { forceMount?: true | undefined };\nconst [PortalProvider, usePortalContext] = createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode | undefined;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'] | undefined;\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (props: ScopedProps<DialogPortalProps>) => {\n const { __scopeDialog, forceMount, children, container } = props;\n const context = useDialogContext(PORTAL_NAME, __scopeDialog);\n return (\n <PortalProvider scope={__scopeDialog} forceMount={forceMount}>\n {React.Children.map(children, (child) => (\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {child}\n </PortalPrimitive>\n </Presence>\n ))}\n </PortalProvider>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DialogOverlay\n * -----------------------------------------------------------------------------------------------*/\n\nconst OVERLAY_NAME = 'DialogOverlay';\n\ntype DialogOverlayElement = DialogOverlayImplElement;\ninterface DialogOverlayProps extends DialogOverlayImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogOverlay = /* @__PURE__ */ React.forwardRef<DialogOverlayElement, DialogOverlayProps>(\n function DialogOverlay(props: ScopedProps<DialogOverlayProps>, forwardedRef) {\n const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);\n return context.modal ? (\n <Presence present={forceMount || context.open}>\n <DialogOverlayImpl {...overlayProps} ref={forwardedRef} />\n </Presence>\n ) : null;\n },\n);\n\ntype DialogOverlayImplElement = React.ComponentRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst Slot = createSlot('DialogOverlay.RemoveScroll');\n\nconst DialogOverlayImpl = /* @__PURE__ */ React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>(\n // blank line to reduce diff noise\n function DialogOverlayImpl(props: ScopedProps<DialogOverlayImplProps>, forwardedRef) {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n\n // Register the overlay as a dismiss surface so a consumer calling\n // `stopPropagation` on it (eg. to avoid triggering parent handlers) does not\n // prevent the dialog from closing. See: https://github.com/radix-ui/primitives/issues/3346\n const registerDismissableSurface = useDismissableLayerSurface();\n const composedRefs = useComposedRefs(forwardedRef, registerDismissableSurface);\n\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside\n // `RemoveScroll` (eg. when `Overlay` and `Content` are siblings). Nested\n // layers are registered as branches and added as shards so they remain\n // scrollable too. See https://github.com/radix-ui/primitives/issues/3423\n <RemoveScroll\n as={Slot}\n allowPinchZoom\n shards={React.useMemo(\n () => [context.contentRef, ...context.branchNodes.map((node) => ({ current: node }))],\n [context.contentRef, context.branchNodes],\n )}\n >\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={composedRefs}\n // We re-enable pointer-events prevented by `Dialog.Content` to allow scrolling the overlay.\n style={{ pointerEvents: 'auto', ...overlayProps.style }}\n />\n </RemoveScroll>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'DialogContent';\n\ntype DialogContentElement = DialogContentTypeElement;\ninterface DialogContentProps extends DialogContentTypeProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true | undefined;\n}\n\nconst DialogContent = /* @__PURE__ */ React.forwardRef<DialogContentElement, DialogContentProps>(\n function DialogContent(props: ScopedProps<DialogContentProps>, forwardedRef) {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n return (\n <Presence present={forceMount || context.open}>\n {context.modal ? (\n <DialogContentModal {...contentProps} ref={forwardedRef} />\n ) : (\n <DialogContentNonModal {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps extends Omit<\n DialogContentImplProps,\n 'trapFocus' | 'disableOutsidePointerEvents'\n> {}\n\nconst DialogContentModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) {\n const ownerDocument = content.ownerDocument;\n return hideOthers(new Set([content]), ownerDocument.body);\n }\n }, []);\n\n return (\n <DialogContentImpl\n {...props}\n ref={composedRefs}\n // we make sure focus isn't trapped once `DialogContent` has been closed\n // (closed !== unmounted when animating out)\n trapFocus={context.open}\n disableOutsidePointerEvents={context.open}\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n })}\n onPointerDownOutside={composeEventHandlers(props.onPointerDownOutside, (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n\n // If the event is a right-click, we shouldn't close because\n // it is effectively as if we right-clicked the `Overlay`.\n if (isRightClick) event.preventDefault();\n })}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(props.onFocusOutside, (event) =>\n event.preventDefault(),\n )}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DialogContentNonModal = /* @__PURE__ */ React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>(\n // blank line to reduce diff noise\n function DialogContentNonModal(props: ScopedProps<DialogContentTypeProps>, forwardedRef) {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n\n return (\n <DialogContentImpl\n {...props}\n ref={forwardedRef}\n trapFocus={false}\n disableOutsidePointerEvents={false}\n onCloseAutoFocus={(event) => {\n props.onCloseAutoFocus?.(event);\n\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n }}\n onInteractOutside={(event) => {\n props.onInteractOutside?.(event);\n\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef.current = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }}\n />\n );\n },\n);\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ComponentRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps extends Omit<DismissableLayerProps, 'onDismiss'> {\n /**\n * When `true`, focus cannot escape the `Content` via keyboard,\n * pointer, or a programmatic focus.\n * @defaultValue false\n */\n trapFocus?: FocusScopeProps['trapped'] | undefined;\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'] | undefined;\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'] | undefined;\n}\n\nconst DialogContentImpl = /* @__PURE__ */ React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>(\n // blank line to reduce diff noise\n function DialogContentImpl(props: ScopedProps<DialogContentImplProps>, forwardedRef) {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n 'aria-describedby': ariaDescribedby,\n children,\n id: idProp,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (because of the `Portal`)\n useFocusGuards();\n\n const { setContentId } = context;\n useLayoutEffect(() => {\n setContentId(toValidId(idProp) || undefined);\n return () => setContentId(undefined);\n }, [idProp, setContentId]);\n\n return (\n <FocusScopeBranchProvider registry={context.branchRegistry}>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n branches={context.branchNodes}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-labelledby={context.titlePresent ? context.titleId : undefined}\n aria-describedby={\n context.descriptionPresent\n ? concatAriaDescribedby(ariaDescribedby, ...context.descriptionIds)\n : ariaDescribedby\n }\n data-state={getState(context.open)}\n {...contentProps}\n ref={forwardedRef}\n deferPointerDownOutside\n onDismiss={() => context.onOpenChange(false)}\n >\n {children}\n </DismissableLayer>\n </FocusScope>\n </FocusScopeBranchProvider>\n );\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogTitle\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogTitleElement = React.ComponentRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<typeof Primitive.h2>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = /* @__PURE__ */ React.forwardRef<DialogTitleElement, DialogTitleProps>(\n function DialogTitle(props: ScopedProps<DialogTitleProps>, forwardedRef) {\n const { __scopeDialog, id: idProp, ...titleProps } = props;\n const context = useDialogContext('DialogTitle', __scopeDialog);\n const { setTitleCount, setTitleId } = context;\n useLayoutEffect(() => {\n setTitleCount((count) => count + 1);\n return () => setTitleCount((count) => count - 1);\n }, [setTitleCount]);\n useLayoutEffect(() => {\n setTitleId(toValidId(idProp) || undefined);\n return () => setTitleId(undefined);\n }, [idProp, setTitleId]);\n return <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogDescription\n * -----------------------------------------------------------------------------------------------*/\n\ntype DialogDescriptionElement = React.ComponentRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<typeof Primitive.p>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = /* @__PURE__ */ React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>(\n // blank line to reduce diff noise\n function DialogDescription(props: ScopedProps<DialogDescriptionProps>, forwardedRef) {\n const { __scopeDialog, id: idProp, ...descriptionProps } = props;\n const context = useDialogContext('DialogDescription', __scopeDialog);\n const { setDescriptionIds } = context;\n\n const generatedId = useId();\n const id = toValidId(idProp) || generatedId;\n\n useLayoutEffect(() => {\n setDescriptionIds((descriptionIds) => {\n if (descriptionIds.has(id)) {\n return descriptionIds;\n }\n\n const newDescriptionIds = new Set(descriptionIds);\n newDescriptionIds.add(id);\n return newDescriptionIds;\n });\n return () => {\n setDescriptionIds((descriptionIds) => {\n const newDescriptionIds = new Set(descriptionIds);\n newDescriptionIds.delete(id);\n return newDescriptionIds.size === descriptionIds.size\n ? descriptionIds\n : newDescriptionIds;\n });\n };\n }, [setDescriptionIds, id]);\n\n return <Primitive.p id={id} {...descriptionProps} ref={forwardedRef} />;\n },\n);\n\n/* -------------------------------------------------------------------------------------------------\n * DialogClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'DialogClose';\n\ntype DialogCloseElement = React.ComponentRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = /* @__PURE__ */ React.forwardRef<DialogCloseElement, DialogCloseProps>(\n function DialogClose(props: ScopedProps<DialogCloseProps>, forwardedRef) {\n const { __scopeDialog, ...closeProps } = props;\n const context = useDialogContext(CLOSE_NAME, __scopeDialog);\n return (\n <Primitive.button\n type=\"button\"\n {...closeProps}\n ref={forwardedRef}\n onClick={composeEventHandlers(props.onClick, () => context.onOpenChange(false))}\n />\n );\n },\n);\n\n/** @deprecated Noop component to avoid breaking changes. */\nexport const WarningProvider: React.FC<\n ScopedProps<{\n children?: React.ReactNode | undefined;\n contentName: string;\n titleName: string;\n docsSlug: 'dialog';\n }>\n> = (props) => {\n return props.children;\n};\n\n/* -----------------------------------------------------------------------------------------------*/\n\n// TODO: Move to primitive once that package exposed individual sub-modules\nfunction concatAriaDescribedby(...values: (string | null | undefined)[]): string | undefined {\n const ids = new Set<string>();\n for (const value of values) {\n if (typeof value !== 'string') {\n continue;\n }\n for (const id of value.trim().split(/\\s+/)) {\n if (id) {\n ids.add(id);\n }\n }\n }\n\n return ids.size > 0 ? Array.from(ids).join(' ') : undefined;\n}\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed';\n}\n\nfunction toValidId(value: number | string | undefined) {\n // We type id's internally as strings, but in some version of React's types a\n // number can be passed without type errors.\n if (typeof value === 'number') {\n return String(value);\n }\n return value;\n}\n\nexport {\n createDialogScope,\n //\n Dialog,\n DialogTrigger,\n DialogPortal,\n DialogOverlay,\n DialogContent,\n DialogTitle,\n DialogDescription,\n DialogClose,\n //\n Dialog as Root,\n DialogTrigger as Trigger,\n DialogPortal as Portal,\n DialogOverlay as Overlay,\n DialogContent as Content,\n DialogTitle as Title,\n DialogDescription as Description,\n DialogClose as Close,\n};\nexport type {\n DialogProps,\n DialogTriggerProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogContentProps,\n DialogTitleProps,\n DialogDescriptionProps,\n DialogCloseProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,kBAAkB,kCAAkC;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAA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C,gCAASC,aAAY,OAAsC,cAAc;AACvE,UAAM,EAAE,eAAe,GAAG,WAAW,IAAI;AACzC,UAAM,UAAU,iBAAiB,YAAY,aAAa;AAC1D,WACE;AAAA,MAAC,UAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACJ,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,qBAAqB,MAAM,SAAS,MAAM,QAAQ,aAAa,KAAK,CAAC;AAAA;AAAA,IAChF;AAAA,EAEJ,GAXA;AAYF;AAGO,IAAM,kBAOT,wBAAC,UAAU;AACb,SAAO,MAAM;AACf,GAFI;AAOJ,SAAS,yBAAyB,QAA2D;AAC3F,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,SAAS,QAAQ;AAC1B,QAAI,OAAO,UAAU,UAAU;AAC7B;AAAA,IACF;AACA,eAAW,MAAM,MAAM,KAAK,EAAE,MAAM,KAAK,GAAG;AAC1C,UAAI,IAAI;AACN,YAAI,IAAI,EAAE;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO,IAAI,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG,IAAI;AACpD;AAdS;AAgBT,SAAS,SAAS,MAAe;AAC/B,SAAO,OAAO,SAAS;AACzB;AAFS;AAIT,SAAS,UAAU,OAAoC;AAGrD,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,KAAK;AAAA,EACrB;AACA,SAAO;AACT;AAPS;",
|
|
6
6
|
"names": ["DialogTrigger", "DialogOverlay", "DialogOverlayImpl", "DialogContent", "DialogContentModal", "DialogContentNonModal", "DialogContentImpl", "DialogTitle", "DialogDescription", "DialogClose"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-dialog",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2-rc.1791984254107",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,21 +11,21 @@
|
|
|
11
11
|
],
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"aria-hidden": "^1.2.4",
|
|
15
14
|
"react-remove-scroll": "^2.7.2",
|
|
16
|
-
"@radix-ui/
|
|
15
|
+
"@radix-ui/env-check": "0.0.2-rc.1791984254107",
|
|
16
|
+
"@radix-ui/primitive": "1.2.1-rc.1791984254107",
|
|
17
17
|
"@radix-ui/react-compose-refs": "1.1.5",
|
|
18
|
-
"@radix-ui/react-context": "1.3.
|
|
19
|
-
"@radix-ui/react-dismissable-layer": "1.2.
|
|
18
|
+
"@radix-ui/react-context": "1.3.1-rc.1791984254107",
|
|
19
|
+
"@radix-ui/react-dismissable-layer": "1.2.2-rc.1791984254107",
|
|
20
20
|
"@radix-ui/react-focus-guards": "1.2.0",
|
|
21
|
-
"@radix-ui/react-focus-scope": "1.3.
|
|
22
|
-
"@radix-ui/react-id": "1.1.4",
|
|
23
|
-
"@radix-ui/react-portal": "1.2.0",
|
|
24
|
-
"@radix-ui/react-presence": "1.1.11",
|
|
21
|
+
"@radix-ui/react-focus-scope": "1.3.2-rc.1791984254107",
|
|
25
22
|
"@radix-ui/react-primitive": "2.2.0",
|
|
23
|
+
"@radix-ui/react-portal": "1.2.0",
|
|
26
24
|
"@radix-ui/react-slot": "1.5.0",
|
|
27
|
-
"@radix-ui/react-
|
|
28
|
-
"@radix-ui/react-use-layout-effect": "1.1.4"
|
|
25
|
+
"@radix-ui/react-presence": "1.1.11",
|
|
26
|
+
"@radix-ui/react-use-layout-effect": "1.1.4",
|
|
27
|
+
"@radix-ui/react-use-controllable-state": "1.3.1-rc.1791984254107",
|
|
28
|
+
"@radix-ui/react-id": "1.1.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.3.0",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"react": "^19.3.0",
|
|
34
34
|
"react-dom": "^19.3.0",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
|
-
"@repo/
|
|
37
|
-
"@repo/
|
|
36
|
+
"@repo/typescript-config": "0.0.0",
|
|
37
|
+
"@repo/builder": "0.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@types/react": "*",
|