@huin-core/react-dialog 1.0.4 → 1.0.6
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.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +42 -56
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +42 -56
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { Primitive } from '@huin-core/react-primitive';
|
|
4
4
|
import { Portal } from '@huin-core/react-portal';
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
5
|
import { DismissableLayer } from '@huin-core/react-dismissable-layer';
|
|
7
6
|
import { FocusScope } from '@huin-core/react-focus-scope';
|
|
8
7
|
|
|
@@ -54,7 +53,7 @@ declare const WarningProvider: {
|
|
|
54
53
|
docsSlug: string;
|
|
55
54
|
} & {
|
|
56
55
|
children: React__default.ReactNode;
|
|
57
|
-
}):
|
|
56
|
+
}): React__default.JSX.Element;
|
|
58
57
|
displayName: string;
|
|
59
58
|
};
|
|
60
59
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { Primitive } from '@huin-core/react-primitive';
|
|
4
4
|
import { Portal } from '@huin-core/react-portal';
|
|
5
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
5
|
import { DismissableLayer } from '@huin-core/react-dismissable-layer';
|
|
7
6
|
import { FocusScope } from '@huin-core/react-focus-scope';
|
|
8
7
|
|
|
@@ -54,7 +53,7 @@ declare const WarningProvider: {
|
|
|
54
53
|
docsSlug: string;
|
|
55
54
|
} & {
|
|
56
55
|
children: React__default.ReactNode;
|
|
57
|
-
}):
|
|
56
|
+
}): React__default.JSX.Element;
|
|
58
57
|
displayName: string;
|
|
59
58
|
};
|
|
60
59
|
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,6 @@ var React = __toESM(require("react"));
|
|
|
50
50
|
var import_react_context = require("@huin-core/react-context");
|
|
51
51
|
var import_react_id = require("@huin-core/react-id");
|
|
52
52
|
var import_react_use_controllable_state = require("@huin-core/react-use-controllable-state");
|
|
53
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
53
|
var DIALOG_NAME = "Dialog";
|
|
55
54
|
var [createDialogContext, createDialogScope] = (0, import_react_context.createContextScope)(DIALOG_NAME);
|
|
56
55
|
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
@@ -70,7 +69,7 @@ var Dialog = (props) => {
|
|
|
70
69
|
defaultProp: defaultOpen,
|
|
71
70
|
onChange: onOpenChange
|
|
72
71
|
});
|
|
73
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ React.createElement(
|
|
74
73
|
DialogProvider,
|
|
75
74
|
{
|
|
76
75
|
scope: __scopeDialog,
|
|
@@ -85,9 +84,9 @@ var Dialog = (props) => {
|
|
|
85
84
|
() => setOpen((prevOpen) => !prevOpen),
|
|
86
85
|
[setOpen]
|
|
87
86
|
),
|
|
88
|
-
modal
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
modal
|
|
88
|
+
},
|
|
89
|
+
children
|
|
91
90
|
);
|
|
92
91
|
};
|
|
93
92
|
Dialog.displayName = DIALOG_NAME;
|
|
@@ -101,13 +100,12 @@ var import_react = __toESM(require("react"));
|
|
|
101
100
|
var import_react_primitive = require("@huin-core/react-primitive");
|
|
102
101
|
var import_react_compose_refs = require("@huin-core/react-compose-refs");
|
|
103
102
|
var import_primitive = require("@huin-core/primitive");
|
|
104
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
105
103
|
var TRIGGER_NAME = "DialogTrigger";
|
|
106
104
|
var DialogTrigger = import_react.default.forwardRef((props, forwardedRef) => {
|
|
107
105
|
const { __scopeDialog, ...triggerProps } = props;
|
|
108
106
|
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
109
107
|
const composedTriggerRef = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
110
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
111
109
|
import_react_primitive.Primitive.button,
|
|
112
110
|
{
|
|
113
111
|
type: "button",
|
|
@@ -128,7 +126,6 @@ var import_react2 = __toESM(require("react"));
|
|
|
128
126
|
var import_react_context2 = require("@huin-core/react-context");
|
|
129
127
|
var import_react_portal = require("@huin-core/react-portal");
|
|
130
128
|
var import_react_presence = require("@huin-core/react-presence");
|
|
131
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
132
129
|
var PORTAL_NAME = "DialogPortal";
|
|
133
130
|
var [createDialogContext2] = (0, import_react_context2.createContextScope)(DIALOG_NAME);
|
|
134
131
|
var [PortalProvider, usePortalContext] = createDialogContext2(PORTAL_NAME, {
|
|
@@ -137,7 +134,7 @@ var [PortalProvider, usePortalContext] = createDialogContext2(PORTAL_NAME, {
|
|
|
137
134
|
var DialogPortal = (props) => {
|
|
138
135
|
const { __scopeDialog, forceMount, children, container } = props;
|
|
139
136
|
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
140
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ import_react2.default.createElement(PortalProvider, { scope: __scopeDialog, forceMount }, import_react2.default.Children.map(children, (child) => /* @__PURE__ */ import_react2.default.createElement(import_react_presence.Presence, { present: forceMount || context.open }, /* @__PURE__ */ import_react2.default.createElement(import_react_portal.Portal, { asChild: true, container }, child))));
|
|
141
138
|
};
|
|
142
139
|
DialogPortal.displayName = PORTAL_NAME;
|
|
143
140
|
|
|
@@ -147,13 +144,12 @@ var import_react_primitive2 = require("@huin-core/react-primitive");
|
|
|
147
144
|
var import_react_remove_scroll = require("react-remove-scroll");
|
|
148
145
|
var import_react_presence2 = require("@huin-core/react-presence");
|
|
149
146
|
var import_react_slot = require("@huin-core/react-slot");
|
|
150
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
151
147
|
var OVERLAY_NAME = "DialogOverlay";
|
|
152
148
|
var DialogOverlay = import_react3.default.forwardRef((props, forwardedRef) => {
|
|
153
149
|
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
154
150
|
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
155
151
|
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
156
|
-
return context.modal ? /* @__PURE__ */
|
|
152
|
+
return context.modal ? /* @__PURE__ */ import_react3.default.createElement(import_react_presence2.Presence, { present: forceMount || context.open }, /* @__PURE__ */ import_react3.default.createElement(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef })) : null;
|
|
157
153
|
});
|
|
158
154
|
DialogOverlay.displayName = OVERLAY_NAME;
|
|
159
155
|
var DialogOverlayImpl = import_react3.default.forwardRef((props, forwardedRef) => {
|
|
@@ -162,7 +158,7 @@ var DialogOverlayImpl = import_react3.default.forwardRef((props, forwardedRef) =
|
|
|
162
158
|
return (
|
|
163
159
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
164
160
|
// ie. when `Overlay` and `Content` are siblings
|
|
165
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ import_react3.default.createElement(import_react_remove_scroll.RemoveScroll, { as: import_react_slot.Slot, allowPinchZoom: true, shards: [context.contentRef] }, /* @__PURE__ */ import_react3.default.createElement(
|
|
166
162
|
import_react_primitive2.Primitive.div,
|
|
167
163
|
{
|
|
168
164
|
"data-state": getState(context.open),
|
|
@@ -170,7 +166,7 @@ var DialogOverlayImpl = import_react3.default.forwardRef((props, forwardedRef) =
|
|
|
170
166
|
ref: forwardedRef,
|
|
171
167
|
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
172
168
|
}
|
|
173
|
-
)
|
|
169
|
+
))
|
|
174
170
|
);
|
|
175
171
|
});
|
|
176
172
|
|
|
@@ -188,25 +184,23 @@ var import_react_context3 = require("@huin-core/react-context");
|
|
|
188
184
|
// packages/react/dialog/src/DialogTitle.tsx
|
|
189
185
|
var import_react4 = __toESM(require("react"));
|
|
190
186
|
var import_react_primitive3 = require("@huin-core/react-primitive");
|
|
191
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
192
187
|
var TITLE_NAME = "DialogTitle";
|
|
193
188
|
var DialogTitle = import_react4.default.forwardRef(
|
|
194
189
|
(props, forwardedRef) => {
|
|
195
190
|
const { __scopeDialog, ...titleProps } = props;
|
|
196
191
|
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
197
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react_primitive3.Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
198
193
|
}
|
|
199
194
|
);
|
|
200
195
|
DialogTitle.displayName = TITLE_NAME;
|
|
201
196
|
|
|
202
197
|
// packages/react/dialog/src/DialogContent.tsx
|
|
203
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
204
198
|
var CONTENT_NAME = "DialogContent";
|
|
205
199
|
var DialogContent = import_react5.default.forwardRef((props, forwardedRef) => {
|
|
206
200
|
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
207
201
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
208
202
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
209
|
-
return /* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_presence3.Presence, { present: forceMount || context.open }, context.modal ? /* @__PURE__ */ import_react5.default.createElement(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ import_react5.default.createElement(DialogContentNonModal, { ...contentProps, ref: forwardedRef }));
|
|
210
204
|
});
|
|
211
205
|
DialogContent.displayName = CONTENT_NAME;
|
|
212
206
|
var DialogContentModal = import_react5.default.forwardRef((props, forwardedRef) => {
|
|
@@ -221,7 +215,7 @@ var DialogContentModal = import_react5.default.forwardRef((props, forwardedRef)
|
|
|
221
215
|
const content = contentRef.current;
|
|
222
216
|
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
223
217
|
}, []);
|
|
224
|
-
return /* @__PURE__ */
|
|
218
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
225
219
|
DialogContentImpl,
|
|
226
220
|
{
|
|
227
221
|
...props,
|
|
@@ -255,7 +249,7 @@ var DialogContentNonModal = import_react5.default.forwardRef((props, forwardedRe
|
|
|
255
249
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
256
250
|
const hasInteractedOutsideRef = import_react5.default.useRef(false);
|
|
257
251
|
const hasPointerDownOutsideRef = import_react5.default.useRef(false);
|
|
258
|
-
return /* @__PURE__ */
|
|
252
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
259
253
|
DialogContentImpl,
|
|
260
254
|
{
|
|
261
255
|
...props,
|
|
@@ -302,41 +296,35 @@ var DialogContentImpl = import_react5.default.forwardRef((props, forwardedRef) =
|
|
|
302
296
|
const contentRef = import_react5.default.useRef(null);
|
|
303
297
|
const composedRefs = (0, import_react_compose_refs2.useComposedRefs)(forwardedRef, contentRef);
|
|
304
298
|
(0, import_react_focus_guards.useFocusGuards)();
|
|
305
|
-
return /* @__PURE__ */
|
|
306
|
-
|
|
307
|
-
|
|
299
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(
|
|
300
|
+
import_react_focus_scope.FocusScope,
|
|
301
|
+
{
|
|
302
|
+
asChild: true,
|
|
303
|
+
loop: true,
|
|
304
|
+
trapped: trapFocus,
|
|
305
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
306
|
+
onUnmountAutoFocus: onCloseAutoFocus
|
|
307
|
+
},
|
|
308
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
309
|
+
import_react_dismissable_layer.DismissableLayer,
|
|
308
310
|
{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
role: "dialog",
|
|
318
|
-
id: context.contentId,
|
|
319
|
-
"aria-describedby": context.descriptionId,
|
|
320
|
-
"aria-labelledby": context.titleId,
|
|
321
|
-
"data-state": getState(context.open),
|
|
322
|
-
...contentProps,
|
|
323
|
-
ref: composedRefs,
|
|
324
|
-
onDismiss: () => context.onOpenChange(false)
|
|
325
|
-
}
|
|
326
|
-
)
|
|
311
|
+
role: "dialog",
|
|
312
|
+
id: context.contentId,
|
|
313
|
+
"aria-describedby": context.descriptionId,
|
|
314
|
+
"aria-labelledby": context.titleId,
|
|
315
|
+
"data-state": getState(context.open),
|
|
316
|
+
...contentProps,
|
|
317
|
+
ref: composedRefs,
|
|
318
|
+
onDismiss: () => context.onOpenChange(false)
|
|
327
319
|
}
|
|
328
|
-
)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
)
|
|
338
|
-
] })
|
|
339
|
-
] });
|
|
320
|
+
)
|
|
321
|
+
), /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, /* @__PURE__ */ import_react5.default.createElement(TitleWarning, { titleId: context.titleId }), /* @__PURE__ */ import_react5.default.createElement(
|
|
322
|
+
DescriptionWarning,
|
|
323
|
+
{
|
|
324
|
+
contentRef,
|
|
325
|
+
descriptionId: context.descriptionId
|
|
326
|
+
}
|
|
327
|
+
)));
|
|
340
328
|
});
|
|
341
329
|
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
342
330
|
var [WarningProvider, useWarningContext] = (0, import_react_context3.createContext)(TITLE_WARNING_NAME, {
|
|
@@ -379,12 +367,11 @@ var DescriptionWarning = ({
|
|
|
379
367
|
// packages/react/dialog/src/DialogDescription.tsx
|
|
380
368
|
var import_react6 = __toESM(require("react"));
|
|
381
369
|
var import_react_primitive4 = require("@huin-core/react-primitive");
|
|
382
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
383
370
|
var DESCRIPTION_NAME = "DialogDescription";
|
|
384
371
|
var DialogDescription = import_react6.default.forwardRef((props, forwardedRef) => {
|
|
385
372
|
const { __scopeDialog, className, ...descriptionProps } = props;
|
|
386
373
|
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
387
|
-
return /* @__PURE__ */
|
|
374
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_primitive4.Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
388
375
|
});
|
|
389
376
|
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
390
377
|
|
|
@@ -392,13 +379,12 @@ DialogDescription.displayName = DESCRIPTION_NAME;
|
|
|
392
379
|
var import_react7 = __toESM(require("react"));
|
|
393
380
|
var import_react_primitive5 = require("@huin-core/react-primitive");
|
|
394
381
|
var import_primitive3 = require("@huin-core/primitive");
|
|
395
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
396
382
|
var CLOSE_NAME = "DialogClose";
|
|
397
383
|
var DialogClose = import_react7.default.forwardRef(
|
|
398
384
|
(props, forwardedRef) => {
|
|
399
385
|
const { __scopeDialog, ...closeProps } = props;
|
|
400
386
|
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
401
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
402
388
|
import_react_primitive5.Primitive.button,
|
|
403
389
|
{
|
|
404
390
|
type: "button",
|
package/dist/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/Dialog.tsx", "../src/DialogTrigger.tsx", "../src/DialogPortal.tsx", "../src/DialogOverlay.tsx", "../src/DialogContent.tsx", "../src/DialogTitle.tsx", "../src/DialogDescription.tsx", "../src/DialogClose.tsx"],
|
|
4
4
|
"sourcesContent": ["\"use client\";\nexport { createDialogScope, Dialog, Root } from \"./Dialog\";\nexport { DialogTrigger } from \"./DialogTrigger\";\nexport { DialogPortal } from \"./DialogPortal\";\nexport { DialogOverlay } from \"./DialogOverlay\";\nexport { DialogContent, WarningProvider } from \"./DialogContent\";\nexport { DialogTitle } from \"./DialogTitle\";\nexport { DialogDescription } from \"./DialogDescription\";\nexport { DialogClose } from \"./DialogClose\";\n\nexport type { DialogProps } from \"./Dialog\";\nexport type { DialogTriggerProps } from \"./DialogTrigger\";\nexport type { DialogPortalProps } from \"./DialogPortal\";\nexport type { DialogOverlayProps } from \"./DialogOverlay\";\nexport type { DialogContentProps } from \"./DialogContent\";\nexport type { DialogTitleProps } from \"./DialogTitle\";\nexport type { DialogDescriptionProps } from \"./DialogDescription\";\nexport type { DialogCloseProps } from \"./DialogClose\";\n", "import * as React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { useId } from \"@huin-core/react-id\";\nimport { useControllableState } from \"@huin-core/react-use-controllable-state\";\nimport type { Scope } from \"@huin-core/react-context\";\nimport { DialogContentElement } from \"./DialogContent\";\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nexport const DIALOG_NAME = \"Dialog\";\n\nexport type ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] =\n createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentRef: React.RefObject<DialogContentElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n};\n\nexport const [DialogProvider, useDialogContext] =\n createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\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 [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(\n () => setOpen((prevOpen) => !prevOpen),\n [setOpen]\n )}\n modal={modal}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport function getState(open: boolean) {\n return open ? \"open\" : \"closed\";\n}\n\nconst Root = Dialog;\n\nexport { createDialogScope, Dialog, Root };\nexport type { DialogProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst TRIGGER_NAME = \"DialogTrigger\";\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\nexport type PrimitiveButtonProps = React.ComponentPropsWithoutRef<\n typeof Primitive.button\n>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<\n DialogTriggerElement,\n DialogTriggerProps\n>((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.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n});\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\nexport { DialogTrigger };\nexport type { DialogTriggerProps };\n", "import React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { DIALOG_NAME, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { Portal as PortalPrimitive } from \"@huin-core/react-portal\";\nimport { Presence } from \"@huin-core/react-presence\";\n\nconst PORTAL_NAME = \"DialogPortal\";\n\ntype PortalContextValue = { forceMount?: true };\nconst [createDialogContext] =\n createContextScope(DIALOG_NAME);\n\nexport const [PortalProvider, usePortalContext] =\n createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n });\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps[\"container\"];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (\n props: ScopedProps<DialogPortalProps>\n) => {\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\nDialogPortal.displayName = PORTAL_NAME;\n\nexport { DialogPortal };\nexport type { DialogPortalProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { usePortalContext } from \"./DialogPortal\";\nimport { Slot } from \"@huin-core/react-slot\";\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;\n}\n\nconst DialogOverlay = React.forwardRef<\n DialogOverlayElement,\n DialogOverlayProps\n>((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\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>((props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`\n // ie. when `Overlay` and `Content` are siblings\n <RemoveScroll as={Slot} allowPinchZoom shards={[context.contentRef]}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\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\nexport { DialogOverlay };\nexport type { DialogOverlayProps };\n", "import React from \"react\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { usePortalContext } from \"./DialogPortal\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { hideOthers } from \"aria-hidden\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\nimport { DismissableLayer } from \"@huin-core/react-dismissable-layer\";\nimport { FocusScope } from \"@huin-core/react-focus-scope\";\nimport { useFocusGuards } from \"@huin-core/react-focus-guards\";\nimport { createContext } from \"@huin-core/react-context\";\nimport { TITLE_NAME } from \"./DialogTitle\";\n\nconst CONTENT_NAME = \"DialogContent\";\n\nexport type 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;\n}\nconst DialogContent = React.forwardRef<\n DialogContentElement,\n DialogContentProps\n>((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\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<\n DialogContentImplProps,\n \"trapFocus\" | \"disableOutsidePointerEvents\"\n > {}\n\nconst DialogContentModal = React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>((props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(\n forwardedRef,\n context.contentRef,\n contentRef\n );\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\n onCloseAutoFocus={composeEventHandlers(\n props.onCloseAutoFocus,\n (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n }\n )}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick =\n 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 )}\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\nconst DialogContentNonModal = React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>((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)\n 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 (\n event.detail.originalEvent.type === \"focusin\" &&\n hasPointerDownOutsideRef.current\n ) {\n event.preventDefault();\n }\n }}\n />\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<\n typeof DismissableLayer\n>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps\n 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\"];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps[\"onMountAutoFocus\"];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps[\"onUnmountAutoFocus\"];\n}\n\nconst DialogContentImpl = React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>((props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={context.descriptionId}\n aria-labelledby={context.titleId}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <TitleWarning titleId={context.titleId} />\n <DescriptionWarning\n contentRef={contentRef}\n descriptionId={context.descriptionId}\n />\n </>\n )}\n </>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_WARNING_NAME = \"DialogTitleWarning\";\n\nconst [WarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: \"dialog\",\n});\n\ntype TitleWarningProps = { titleId?: string };\n\nconst TitleWarning: React.FC<TitleWarningProps> = ({ titleId }) => {\n const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);\n\n const MESSAGE = `\\`${titleWarningContext.contentName}\\` requires a \\`${titleWarningContext.titleName}\\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \\`${titleWarningContext.titleName}\\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://huinhub.com/primitives/docs/components/${titleWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n if (titleId) {\n const hasTitle = document.getElementById(titleId);\n if (!hasTitle) console.error(MESSAGE);\n }\n }, [MESSAGE, titleId]);\n\n return null;\n};\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_WARNING_NAME = \"DialogDescriptionWarning\";\n\ntype DescriptionWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n descriptionId?: string;\n};\n\nconst DescriptionWarning: React.FC<DescriptionWarningProps> = ({\n contentRef,\n descriptionId,\n}) => {\n const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);\n const MESSAGE = `Warning: Missing \\`Description\\` or \\`aria-describedby={undefined}\\` for {${descriptionWarningContext.contentName}}.`;\n\n React.useEffect(() => {\n const describedById = contentRef.current?.getAttribute(\"aria-describedby\");\n // if we have an id and the user hasn't set aria-describedby={undefined}\n if (descriptionId && describedById) {\n const hasDescription = document.getElementById(descriptionId);\n if (!hasDescription) console.warn(MESSAGE);\n }\n }, [MESSAGE, contentRef, descriptionId]);\n\n return null;\n};\n\nexport { DialogContent, WarningProvider };\nexport type { DialogContentProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\n\nexport const TITLE_NAME = \"DialogTitle\";\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<\n typeof Primitive.h2\n>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return (\n <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />\n );\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\nexport { DialogTitle };\nexport type { DialogTitleProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\n\nconst DESCRIPTION_NAME = \"DialogDescription\";\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<\n typeof Primitive.p\n>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>((props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, className, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n\n});\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\nexport { DialogDescription };\nexport type { DialogDescriptionProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { PrimitiveButtonProps } from \"./DialogTrigger\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst CLOSE_NAME = \"DialogClose\";\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (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, () =>\n context.onOpenChange(false)\n )}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\nexport { DialogClose };\nexport type { DialogCloseProps };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,2BAAmC;AACnC,sBAAsB;AACtB,0CAAqC;
|
|
6
|
-
"names": ["
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC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AC,kCAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACJ,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,aAAS;AAAA,UAAqB,MAAM;AAAA,UAAS,MAC3C,QAAQ,aAAa,KAAK;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;",
|
|
6
|
+
"names": ["React", "import_react", "import_react_context", "createDialogContext", "React", "PortalPrimitive", "import_react", "import_react_primitive", "import_react_presence", "React", "import_react", "import_react_presence", "import_react_compose_refs", "import_primitive", "import_react_context", "import_react", "import_react_primitive", "React", "React", "import_react", "import_react_primitive", "React", "import_react", "import_react_primitive", "import_primitive", "React"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import * as React from "react";
|
|
|
5
5
|
import { createContextScope } from "@huin-core/react-context";
|
|
6
6
|
import { useId } from "@huin-core/react-id";
|
|
7
7
|
import { useControllableState } from "@huin-core/react-use-controllable-state";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
8
|
var DIALOG_NAME = "Dialog";
|
|
10
9
|
var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
|
|
11
10
|
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
@@ -25,7 +24,7 @@ var Dialog = (props) => {
|
|
|
25
24
|
defaultProp: defaultOpen,
|
|
26
25
|
onChange: onOpenChange
|
|
27
26
|
});
|
|
28
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ React.createElement(
|
|
29
28
|
DialogProvider,
|
|
30
29
|
{
|
|
31
30
|
scope: __scopeDialog,
|
|
@@ -40,9 +39,9 @@ var Dialog = (props) => {
|
|
|
40
39
|
() => setOpen((prevOpen) => !prevOpen),
|
|
41
40
|
[setOpen]
|
|
42
41
|
),
|
|
43
|
-
modal
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
modal
|
|
43
|
+
},
|
|
44
|
+
children
|
|
46
45
|
);
|
|
47
46
|
};
|
|
48
47
|
Dialog.displayName = DIALOG_NAME;
|
|
@@ -56,13 +55,12 @@ import React2 from "react";
|
|
|
56
55
|
import { Primitive } from "@huin-core/react-primitive";
|
|
57
56
|
import { useComposedRefs } from "@huin-core/react-compose-refs";
|
|
58
57
|
import { composeEventHandlers } from "@huin-core/primitive";
|
|
59
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
60
58
|
var TRIGGER_NAME = "DialogTrigger";
|
|
61
59
|
var DialogTrigger = React2.forwardRef((props, forwardedRef) => {
|
|
62
60
|
const { __scopeDialog, ...triggerProps } = props;
|
|
63
61
|
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
64
62
|
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
65
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ React2.createElement(
|
|
66
64
|
Primitive.button,
|
|
67
65
|
{
|
|
68
66
|
type: "button",
|
|
@@ -83,7 +81,6 @@ import React3 from "react";
|
|
|
83
81
|
import { createContextScope as createContextScope2 } from "@huin-core/react-context";
|
|
84
82
|
import { Portal as PortalPrimitive } from "@huin-core/react-portal";
|
|
85
83
|
import { Presence } from "@huin-core/react-presence";
|
|
86
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
87
84
|
var PORTAL_NAME = "DialogPortal";
|
|
88
85
|
var [createDialogContext2] = createContextScope2(DIALOG_NAME);
|
|
89
86
|
var [PortalProvider, usePortalContext] = createDialogContext2(PORTAL_NAME, {
|
|
@@ -92,7 +89,7 @@ var [PortalProvider, usePortalContext] = createDialogContext2(PORTAL_NAME, {
|
|
|
92
89
|
var DialogPortal = (props) => {
|
|
93
90
|
const { __scopeDialog, forceMount, children, container } = props;
|
|
94
91
|
const context = useDialogContext(PORTAL_NAME, __scopeDialog);
|
|
95
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ React3.createElement(PortalProvider, { scope: __scopeDialog, forceMount }, React3.Children.map(children, (child) => /* @__PURE__ */ React3.createElement(Presence, { present: forceMount || context.open }, /* @__PURE__ */ React3.createElement(PortalPrimitive, { asChild: true, container }, child))));
|
|
96
93
|
};
|
|
97
94
|
DialogPortal.displayName = PORTAL_NAME;
|
|
98
95
|
|
|
@@ -102,13 +99,12 @@ import { Primitive as Primitive2 } from "@huin-core/react-primitive";
|
|
|
102
99
|
import { RemoveScroll } from "react-remove-scroll";
|
|
103
100
|
import { Presence as Presence2 } from "@huin-core/react-presence";
|
|
104
101
|
import { Slot } from "@huin-core/react-slot";
|
|
105
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
106
102
|
var OVERLAY_NAME = "DialogOverlay";
|
|
107
103
|
var DialogOverlay = React4.forwardRef((props, forwardedRef) => {
|
|
108
104
|
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
109
105
|
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
110
106
|
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
111
|
-
return context.modal ? /* @__PURE__ */
|
|
107
|
+
return context.modal ? /* @__PURE__ */ React4.createElement(Presence2, { present: forceMount || context.open }, /* @__PURE__ */ React4.createElement(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef })) : null;
|
|
112
108
|
});
|
|
113
109
|
DialogOverlay.displayName = OVERLAY_NAME;
|
|
114
110
|
var DialogOverlayImpl = React4.forwardRef((props, forwardedRef) => {
|
|
@@ -117,7 +113,7 @@ var DialogOverlayImpl = React4.forwardRef((props, forwardedRef) => {
|
|
|
117
113
|
return (
|
|
118
114
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
119
115
|
// ie. when `Overlay` and `Content` are siblings
|
|
120
|
-
/* @__PURE__ */
|
|
116
|
+
/* @__PURE__ */ React4.createElement(RemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef] }, /* @__PURE__ */ React4.createElement(
|
|
121
117
|
Primitive2.div,
|
|
122
118
|
{
|
|
123
119
|
"data-state": getState(context.open),
|
|
@@ -125,7 +121,7 @@ var DialogOverlayImpl = React4.forwardRef((props, forwardedRef) => {
|
|
|
125
121
|
ref: forwardedRef,
|
|
126
122
|
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
127
123
|
}
|
|
128
|
-
)
|
|
124
|
+
))
|
|
129
125
|
);
|
|
130
126
|
});
|
|
131
127
|
|
|
@@ -143,25 +139,23 @@ import { createContext } from "@huin-core/react-context";
|
|
|
143
139
|
// packages/react/dialog/src/DialogTitle.tsx
|
|
144
140
|
import React5 from "react";
|
|
145
141
|
import { Primitive as Primitive3 } from "@huin-core/react-primitive";
|
|
146
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
147
142
|
var TITLE_NAME = "DialogTitle";
|
|
148
143
|
var DialogTitle = React5.forwardRef(
|
|
149
144
|
(props, forwardedRef) => {
|
|
150
145
|
const { __scopeDialog, ...titleProps } = props;
|
|
151
146
|
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
152
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ React5.createElement(Primitive3.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
153
148
|
}
|
|
154
149
|
);
|
|
155
150
|
DialogTitle.displayName = TITLE_NAME;
|
|
156
151
|
|
|
157
152
|
// packages/react/dialog/src/DialogContent.tsx
|
|
158
|
-
import { Fragment, jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
159
153
|
var CONTENT_NAME = "DialogContent";
|
|
160
154
|
var DialogContent = React6.forwardRef((props, forwardedRef) => {
|
|
161
155
|
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
162
156
|
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
163
157
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
164
|
-
return /* @__PURE__ */
|
|
158
|
+
return /* @__PURE__ */ React6.createElement(Presence3, { present: forceMount || context.open }, context.modal ? /* @__PURE__ */ React6.createElement(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ React6.createElement(DialogContentNonModal, { ...contentProps, ref: forwardedRef }));
|
|
165
159
|
});
|
|
166
160
|
DialogContent.displayName = CONTENT_NAME;
|
|
167
161
|
var DialogContentModal = React6.forwardRef((props, forwardedRef) => {
|
|
@@ -176,7 +170,7 @@ var DialogContentModal = React6.forwardRef((props, forwardedRef) => {
|
|
|
176
170
|
const content = contentRef.current;
|
|
177
171
|
if (content) return hideOthers(content);
|
|
178
172
|
}, []);
|
|
179
|
-
return /* @__PURE__ */
|
|
173
|
+
return /* @__PURE__ */ React6.createElement(
|
|
180
174
|
DialogContentImpl,
|
|
181
175
|
{
|
|
182
176
|
...props,
|
|
@@ -210,7 +204,7 @@ var DialogContentNonModal = React6.forwardRef((props, forwardedRef) => {
|
|
|
210
204
|
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
211
205
|
const hasInteractedOutsideRef = React6.useRef(false);
|
|
212
206
|
const hasPointerDownOutsideRef = React6.useRef(false);
|
|
213
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ React6.createElement(
|
|
214
208
|
DialogContentImpl,
|
|
215
209
|
{
|
|
216
210
|
...props,
|
|
@@ -257,41 +251,35 @@ var DialogContentImpl = React6.forwardRef((props, forwardedRef) => {
|
|
|
257
251
|
const contentRef = React6.useRef(null);
|
|
258
252
|
const composedRefs = useComposedRefs2(forwardedRef, contentRef);
|
|
259
253
|
useFocusGuards();
|
|
260
|
-
return /* @__PURE__ */
|
|
261
|
-
|
|
262
|
-
|
|
254
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
|
|
255
|
+
FocusScope,
|
|
256
|
+
{
|
|
257
|
+
asChild: true,
|
|
258
|
+
loop: true,
|
|
259
|
+
trapped: trapFocus,
|
|
260
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
261
|
+
onUnmountAutoFocus: onCloseAutoFocus
|
|
262
|
+
},
|
|
263
|
+
/* @__PURE__ */ React6.createElement(
|
|
264
|
+
DismissableLayer,
|
|
263
265
|
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
role: "dialog",
|
|
273
|
-
id: context.contentId,
|
|
274
|
-
"aria-describedby": context.descriptionId,
|
|
275
|
-
"aria-labelledby": context.titleId,
|
|
276
|
-
"data-state": getState(context.open),
|
|
277
|
-
...contentProps,
|
|
278
|
-
ref: composedRefs,
|
|
279
|
-
onDismiss: () => context.onOpenChange(false)
|
|
280
|
-
}
|
|
281
|
-
)
|
|
266
|
+
role: "dialog",
|
|
267
|
+
id: context.contentId,
|
|
268
|
+
"aria-describedby": context.descriptionId,
|
|
269
|
+
"aria-labelledby": context.titleId,
|
|
270
|
+
"data-state": getState(context.open),
|
|
271
|
+
...contentProps,
|
|
272
|
+
ref: composedRefs,
|
|
273
|
+
onDismiss: () => context.onOpenChange(false)
|
|
282
274
|
}
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
] })
|
|
294
|
-
] });
|
|
275
|
+
)
|
|
276
|
+
), /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(TitleWarning, { titleId: context.titleId }), /* @__PURE__ */ React6.createElement(
|
|
277
|
+
DescriptionWarning,
|
|
278
|
+
{
|
|
279
|
+
contentRef,
|
|
280
|
+
descriptionId: context.descriptionId
|
|
281
|
+
}
|
|
282
|
+
)));
|
|
295
283
|
});
|
|
296
284
|
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
297
285
|
var [WarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {
|
|
@@ -334,12 +322,11 @@ var DescriptionWarning = ({
|
|
|
334
322
|
// packages/react/dialog/src/DialogDescription.tsx
|
|
335
323
|
import React7 from "react";
|
|
336
324
|
import { Primitive as Primitive4 } from "@huin-core/react-primitive";
|
|
337
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
338
325
|
var DESCRIPTION_NAME = "DialogDescription";
|
|
339
326
|
var DialogDescription = React7.forwardRef((props, forwardedRef) => {
|
|
340
327
|
const { __scopeDialog, className, ...descriptionProps } = props;
|
|
341
328
|
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
342
|
-
return /* @__PURE__ */
|
|
329
|
+
return /* @__PURE__ */ React7.createElement(Primitive4.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
343
330
|
});
|
|
344
331
|
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
345
332
|
|
|
@@ -347,13 +334,12 @@ DialogDescription.displayName = DESCRIPTION_NAME;
|
|
|
347
334
|
import React8 from "react";
|
|
348
335
|
import { Primitive as Primitive5 } from "@huin-core/react-primitive";
|
|
349
336
|
import { composeEventHandlers as composeEventHandlers3 } from "@huin-core/primitive";
|
|
350
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
351
337
|
var CLOSE_NAME = "DialogClose";
|
|
352
338
|
var DialogClose = React8.forwardRef(
|
|
353
339
|
(props, forwardedRef) => {
|
|
354
340
|
const { __scopeDialog, ...closeProps } = props;
|
|
355
341
|
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
356
|
-
return /* @__PURE__ */
|
|
342
|
+
return /* @__PURE__ */ React8.createElement(
|
|
357
343
|
Primitive5.button,
|
|
358
344
|
{
|
|
359
345
|
type: "button",
|
package/dist/index.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/Dialog.tsx", "../src/DialogTrigger.tsx", "../src/DialogPortal.tsx", "../src/DialogOverlay.tsx", "../src/DialogContent.tsx", "../src/DialogTitle.tsx", "../src/DialogDescription.tsx", "../src/DialogClose.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { useId } from \"@huin-core/react-id\";\nimport { useControllableState } from \"@huin-core/react-use-controllable-state\";\nimport type { Scope } from \"@huin-core/react-context\";\nimport { DialogContentElement } from \"./DialogContent\";\n\n/* -------------------------------------------------------------------------------------------------\n * Dialog\n * -----------------------------------------------------------------------------------------------*/\n\nexport const DIALOG_NAME = \"Dialog\";\n\nexport type ScopedProps<P> = P & { __scopeDialog?: Scope };\nconst [createDialogContext, createDialogScope] =\n createContextScope(DIALOG_NAME);\n\ntype DialogContextValue = {\n triggerRef: React.RefObject<HTMLButtonElement>;\n contentRef: React.RefObject<DialogContentElement>;\n contentId: string;\n titleId: string;\n descriptionId: string;\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpenToggle(): void;\n modal: boolean;\n};\n\nexport const [DialogProvider, useDialogContext] =\n createDialogContext<DialogContextValue>(DIALOG_NAME);\n\ninterface DialogProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?(open: boolean): void;\n modal?: boolean;\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 [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n return (\n <DialogProvider\n scope={__scopeDialog}\n triggerRef={triggerRef}\n contentRef={contentRef}\n contentId={useId()}\n titleId={useId()}\n descriptionId={useId()}\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={React.useCallback(\n () => setOpen((prevOpen) => !prevOpen),\n [setOpen]\n )}\n modal={modal}\n >\n {children}\n </DialogProvider>\n );\n};\n\nDialog.displayName = DIALOG_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport function getState(open: boolean) {\n return open ? \"open\" : \"closed\";\n}\n\nconst Root = Dialog;\n\nexport { createDialogScope, Dialog, Root };\nexport type { DialogProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst TRIGGER_NAME = \"DialogTrigger\";\n\ntype DialogTriggerElement = React.ElementRef<typeof Primitive.button>;\nexport type PrimitiveButtonProps = React.ComponentPropsWithoutRef<\n typeof Primitive.button\n>;\ninterface DialogTriggerProps extends PrimitiveButtonProps {}\n\nconst DialogTrigger = React.forwardRef<\n DialogTriggerElement,\n DialogTriggerProps\n>((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.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onClick={composeEventHandlers(props.onClick, context.onOpenToggle)}\n />\n );\n});\n\nDialogTrigger.displayName = TRIGGER_NAME;\n\nexport { DialogTrigger };\nexport type { DialogTriggerProps };\n", "import React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { DIALOG_NAME, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { Portal as PortalPrimitive } from \"@huin-core/react-portal\";\nimport { Presence } from \"@huin-core/react-presence\";\n\nconst PORTAL_NAME = \"DialogPortal\";\n\ntype PortalContextValue = { forceMount?: true };\nconst [createDialogContext] =\n createContextScope(DIALOG_NAME);\n\nexport const [PortalProvider, usePortalContext] =\n createDialogContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n });\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface DialogPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps[\"container\"];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst DialogPortal: React.FC<DialogPortalProps> = (\n props: ScopedProps<DialogPortalProps>\n) => {\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\nDialogPortal.displayName = PORTAL_NAME;\n\nexport { DialogPortal };\nexport type { DialogPortalProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { usePortalContext } from \"./DialogPortal\";\nimport { Slot } from \"@huin-core/react-slot\";\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;\n}\n\nconst DialogOverlay = React.forwardRef<\n DialogOverlayElement,\n DialogOverlayProps\n>((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\nDialogOverlay.displayName = OVERLAY_NAME;\n\ntype DialogOverlayImplElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DialogOverlayImplProps extends PrimitiveDivProps {}\n\nconst DialogOverlayImpl = React.forwardRef<\n DialogOverlayImplElement,\n DialogOverlayImplProps\n>((props: ScopedProps<DialogOverlayImplProps>, forwardedRef) => {\n const { __scopeDialog, ...overlayProps } = props;\n const context = useDialogContext(OVERLAY_NAME, __scopeDialog);\n return (\n // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`\n // ie. when `Overlay` and `Content` are siblings\n <RemoveScroll as={Slot} allowPinchZoom shards={[context.contentRef]}>\n <Primitive.div\n data-state={getState(context.open)}\n {...overlayProps}\n ref={forwardedRef}\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\nexport { DialogOverlay };\nexport type { DialogOverlayProps };\n", "import React from \"react\";\nimport { getState, ScopedProps, useDialogContext } from \"./Dialog\";\nimport { usePortalContext } from \"./DialogPortal\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { hideOthers } from \"aria-hidden\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\nimport { DismissableLayer } from \"@huin-core/react-dismissable-layer\";\nimport { FocusScope } from \"@huin-core/react-focus-scope\";\nimport { useFocusGuards } from \"@huin-core/react-focus-guards\";\nimport { createContext } from \"@huin-core/react-context\";\nimport { TITLE_NAME } from \"./DialogTitle\";\n\nconst CONTENT_NAME = \"DialogContent\";\n\nexport type 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;\n}\nconst DialogContent = React.forwardRef<\n DialogContentElement,\n DialogContentProps\n>((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\nDialogContent.displayName = CONTENT_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentTypeElement = DialogContentImplElement;\ninterface DialogContentTypeProps\n extends Omit<\n DialogContentImplProps,\n \"trapFocus\" | \"disableOutsidePointerEvents\"\n > {}\n\nconst DialogContentModal = React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>((props: ScopedProps<DialogContentTypeProps>, forwardedRef) => {\n const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(\n forwardedRef,\n context.contentRef,\n contentRef\n );\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\n onCloseAutoFocus={composeEventHandlers(\n props.onCloseAutoFocus,\n (event) => {\n event.preventDefault();\n context.triggerRef.current?.focus();\n }\n )}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick =\n 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 )}\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\nconst DialogContentNonModal = React.forwardRef<\n DialogContentTypeElement,\n DialogContentTypeProps\n>((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)\n 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 (\n event.detail.originalEvent.type === \"focusin\" &&\n hasPointerDownOutsideRef.current\n ) {\n event.preventDefault();\n }\n }}\n />\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype DialogContentImplElement = React.ElementRef<typeof DismissableLayer>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<\n typeof DismissableLayer\n>;\ntype FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusScope>;\ninterface DialogContentImplProps\n 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\"];\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps[\"onMountAutoFocus\"];\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps[\"onUnmountAutoFocus\"];\n}\n\nconst DialogContentImpl = React.forwardRef<\n DialogContentImplElement,\n DialogContentImplProps\n>((props: ScopedProps<DialogContentImplProps>, forwardedRef) => {\n const {\n __scopeDialog,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n ...contentProps\n } = props;\n const context = useDialogContext(CONTENT_NAME, __scopeDialog);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n\n // Make sure the whole tree has focus guards as our `Dialog` will be\n // the last element in the DOM (beacuse of the `Portal`)\n useFocusGuards();\n\n return (\n <>\n <FocusScope\n asChild\n loop\n trapped={trapFocus}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n <DismissableLayer\n role=\"dialog\"\n id={context.contentId}\n aria-describedby={context.descriptionId}\n aria-labelledby={context.titleId}\n data-state={getState(context.open)}\n {...contentProps}\n ref={composedRefs}\n onDismiss={() => context.onOpenChange(false)}\n />\n </FocusScope>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <TitleWarning titleId={context.titleId} />\n <DescriptionWarning\n contentRef={contentRef}\n descriptionId={context.descriptionId}\n />\n </>\n )}\n </>\n );\n});\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst TITLE_WARNING_NAME = \"DialogTitleWarning\";\n\nconst [WarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {\n contentName: CONTENT_NAME,\n titleName: TITLE_NAME,\n docsSlug: \"dialog\",\n});\n\ntype TitleWarningProps = { titleId?: string };\n\nconst TitleWarning: React.FC<TitleWarningProps> = ({ titleId }) => {\n const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);\n\n const MESSAGE = `\\`${titleWarningContext.contentName}\\` requires a \\`${titleWarningContext.titleName}\\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \\`${titleWarningContext.titleName}\\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://huinhub.com/primitives/docs/components/${titleWarningContext.docsSlug}`;\n\n React.useEffect(() => {\n if (titleId) {\n const hasTitle = document.getElementById(titleId);\n if (!hasTitle) console.error(MESSAGE);\n }\n }, [MESSAGE, titleId]);\n\n return null;\n};\n/* -----------------------------------------------------------------------------------------------*/\n\nconst DESCRIPTION_WARNING_NAME = \"DialogDescriptionWarning\";\n\ntype DescriptionWarningProps = {\n contentRef: React.RefObject<DialogContentElement>;\n descriptionId?: string;\n};\n\nconst DescriptionWarning: React.FC<DescriptionWarningProps> = ({\n contentRef,\n descriptionId,\n}) => {\n const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);\n const MESSAGE = `Warning: Missing \\`Description\\` or \\`aria-describedby={undefined}\\` for {${descriptionWarningContext.contentName}}.`;\n\n React.useEffect(() => {\n const describedById = contentRef.current?.getAttribute(\"aria-describedby\");\n // if we have an id and the user hasn't set aria-describedby={undefined}\n if (descriptionId && describedById) {\n const hasDescription = document.getElementById(descriptionId);\n if (!hasDescription) console.warn(MESSAGE);\n }\n }, [MESSAGE, contentRef, descriptionId]);\n\n return null;\n};\n\nexport { DialogContent, WarningProvider };\nexport type { DialogContentProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\n\nexport const TITLE_NAME = \"DialogTitle\";\n\ntype DialogTitleElement = React.ElementRef<typeof Primitive.h2>;\ntype PrimitiveHeading2Props = React.ComponentPropsWithoutRef<\n typeof Primitive.h2\n>;\ninterface DialogTitleProps extends PrimitiveHeading2Props {}\n\nconst DialogTitle = React.forwardRef<DialogTitleElement, DialogTitleProps>(\n (props: ScopedProps<DialogTitleProps>, forwardedRef) => {\n const { __scopeDialog, ...titleProps } = props;\n const context = useDialogContext(TITLE_NAME, __scopeDialog);\n return (\n <Primitive.h2 id={context.titleId} {...titleProps} ref={forwardedRef} />\n );\n }\n);\n\nDialogTitle.displayName = TITLE_NAME;\n\nexport { DialogTitle };\nexport type { DialogTitleProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\n\nconst DESCRIPTION_NAME = \"DialogDescription\";\n\ntype DialogDescriptionElement = React.ElementRef<typeof Primitive.p>;\ntype PrimitiveParagraphProps = React.ComponentPropsWithoutRef<\n typeof Primitive.p\n>;\ninterface DialogDescriptionProps extends PrimitiveParagraphProps {}\n\nconst DialogDescription = React.forwardRef<\n DialogDescriptionElement,\n DialogDescriptionProps\n>((props: ScopedProps<DialogDescriptionProps>, forwardedRef) => {\n const { __scopeDialog, className, ...descriptionProps } = props;\n const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);\n return <Primitive.p id={context.descriptionId} {...descriptionProps} ref={forwardedRef} />;\n\n});\n\nDialogDescription.displayName = DESCRIPTION_NAME;\n\nexport { DialogDescription };\nexport type { DialogDescriptionProps };\n", "import React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport { PrimitiveButtonProps } from \"./DialogTrigger\";\nimport { ScopedProps, useDialogContext } from \"./Dialog\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst CLOSE_NAME = \"DialogClose\";\n\ntype DialogCloseElement = React.ElementRef<typeof Primitive.button>;\ninterface DialogCloseProps extends PrimitiveButtonProps {}\n\nconst DialogClose = React.forwardRef<DialogCloseElement, DialogCloseProps>(\n (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, () =>\n context.onOpenChange(false)\n )}\n />\n );\n }\n);\n\nDialogClose.displayName = CLOSE_NAME;\n\nexport { DialogClose };\nexport type { DialogCloseProps };\n"],
|
|
5
|
-
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,4BAA4B;
|
|
6
|
-
"names": ["React", "
|
|
5
|
+
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,4BAA4B;AAQ9B,IAAM,cAAc;AAG3B,IAAM,CAAC,qBAAqB,iBAAiB,IAC3C,mBAAmB,WAAW;AAczB,IAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAUrD,IAAM,SAAgC,CAAC,UAAoC;AACzE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,EACV,IAAI;AACJ,QAAM,aAAmB,aAA0B,IAAI;AACvD,QAAM,aAAmB,aAA6B,IAAI;AAC1D,QAAM,CAAC,OAAO,OAAO,OAAO,IAAI,qBAAqB;AAAA,IACnD,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EACZ,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,WAAW,MAAM;AAAA,MACjB,SAAS,MAAM;AAAA,MACf,eAAe,MAAM;AAAA,MACrB;AAAA,MACA,cAAc;AAAA,MACd,cAAoB;AAAA,QAClB,MAAM,QAAQ,CAAC,aAAa,CAAC,QAAQ;AAA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QAAM,EAAE,eAAe,WAAW,GAAG,iBAAiB,IAAI;AAC1D,QAAM,UAAU,iBAAiB,kBAAkB,aAAa;AAChE,SAAO,gBAAAA,OAAA,cAACC,WAAU,GAAV,EAAY,IAAI,QAAQ,eAAgB,GAAG,kBAAkB,KAAK,cAAc;AAE1F,CAAC;AAED,kBAAkB,cAAc;;;ACtBhC,OAAOC,YAAW;AAClB,SAAS,aAAAC,kBAAiB;AAG1B,SAAS,wBAAAC,6BAA4B;AAErC,IAAM,aAAa;AAKnB,IAAM,cAAcC,OAAM;AAAA,EACxB,CAAC,OAAsC,iBAAiB;AACtD,UAAM,EAAE,eAAe,GAAG,WAAW,IAAI;AACzC,UAAM,UAAU,iBAAiB,YAAY,aAAa;AAC1D,WACE,gBAAAA,OAAA;AAAA,MAACC,WAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACJ,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAASF;AAAA,UAAqB,MAAM;AAAA,UAAS,MAC3C,QAAQ,aAAa,KAAK;AAAA,QAC5B;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;",
|
|
6
|
+
"names": ["React", "React", "React", "createContextScope", "createDialogContext", "createContextScope", "React", "React", "Primitive", "Presence", "React", "Presence", "Primitive", "React", "Presence", "useComposedRefs", "composeEventHandlers", "React", "Primitive", "React", "Primitive", "React", "Presence", "useComposedRefs", "composeEventHandlers", "React", "Primitive", "React", "Primitive", "React", "Primitive", "composeEventHandlers", "React", "Primitive"]
|
|
7
7
|
}
|