@tamagui/dialog 1.61.3 → 1.62.1

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.
@@ -1,4 +1,3 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
1
  import { Adapt, useAdaptParent } from "@tamagui/adapt";
3
2
  import { AnimatePresence } from "@tamagui/animate-presence";
4
3
  import { hideOthers } from "@tamagui/aria-hidden";
@@ -25,18 +24,12 @@ import { ThemeableStack, YStack } from "@tamagui/stacks";
25
24
  import { H2, Paragraph } from "@tamagui/text";
26
25
  import { useControllableState } from "@tamagui/use-controllable-state";
27
26
  import * as React from "react";
28
- const DIALOG_NAME = "Dialog";
29
- const [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
30
- const [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
31
- const TRIGGER_NAME = "DialogTrigger";
32
- const DialogTriggerFrame = styled(View, {
27
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
+ const DIALOG_NAME = "Dialog", [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME), [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME), TRIGGER_NAME = "DialogTrigger", DialogTriggerFrame = styled(View, {
33
29
  name: TRIGGER_NAME
34
- });
35
- const DialogTrigger = React.forwardRef(
30
+ }), DialogTrigger = React.forwardRef(
36
31
  (props, forwardedRef) => {
37
- const { __scopeDialog, ...triggerProps } = props;
38
- const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
39
- const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
32
+ const { __scopeDialog, ...triggerProps } = props, context = useDialogContext(TRIGGER_NAME, __scopeDialog), composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
40
33
  return /* @__PURE__ */ jsx(
41
34
  DialogTriggerFrame,
42
35
  {
@@ -53,20 +46,18 @@ const DialogTrigger = React.forwardRef(
53
46
  }
54
47
  );
55
48
  DialogTrigger.displayName = TRIGGER_NAME;
56
- const PORTAL_NAME = "DialogPortal";
57
- const [PortalProvider, usePortalContext] = createDialogContext(
49
+ const PORTAL_NAME = "DialogPortal", [PortalProvider, usePortalContext] = createDialogContext(
58
50
  PORTAL_NAME,
59
51
  {
60
52
  forceMount: void 0
61
53
  }
62
- );
63
- const DialogPortalFrame = styled(YStack, {
54
+ ), DialogPortalFrame = styled(YStack, {
64
55
  variants: {
65
56
  unstyled: {
66
57
  false: {
67
58
  alignItems: "center",
68
59
  justifyContent: "center",
69
- fullscreen: true,
60
+ fullscreen: !0,
70
61
  zIndex: 1e5,
71
62
  ...isWeb && {
72
63
  maxHeight: "100vh",
@@ -76,12 +67,10 @@ const DialogPortalFrame = styled(YStack, {
76
67
  }
77
68
  },
78
69
  defaultVariants: {
79
- unstyled: false
70
+ unstyled: !1
80
71
  }
81
- });
82
- const DialogPortalItem = (props) => {
83
- const themeName = useThemeName();
84
- const context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
72
+ }), DialogPortalItem = (props) => {
73
+ const themeName = useThemeName(), context = useDialogContext(PORTAL_NAME, props.__scopeDialog);
85
74
  return /* @__PURE__ */ jsx(PortalItem, { hostName: props.hostName, children: /* @__PURE__ */ jsx(DialogPortalItemContent, { ...props, themeName, context }) });
86
75
  };
87
76
  function DialogPortalItemContent(props) {
@@ -95,63 +84,35 @@ function DialogPortalItemContent(props) {
95
84
  separator
96
85
  } = props;
97
86
  let childrenSpaced = children;
98
- if (space || separator) {
99
- childrenSpaced = spacedChildren({
100
- children,
101
- separator,
102
- space,
103
- direction: spaceDirection
104
- });
105
- }
106
- return /* @__PURE__ */ jsx(DialogProvider, { scope: __scopeDialog, ...context, children: /* @__PURE__ */ jsx(Theme, { name: themeName, children: childrenSpaced }) });
87
+ return (space || separator) && (childrenSpaced = spacedChildren({
88
+ children,
89
+ separator,
90
+ space,
91
+ direction: spaceDirection
92
+ })), /* @__PURE__ */ jsx(DialogProvider, { scope: __scopeDialog, ...context, children: /* @__PURE__ */ jsx(Theme, { name: themeName, children: childrenSpaced }) });
107
93
  }
108
94
  const DialogPortal = (props) => {
109
- const { __scopeDialog, forceMount, children, ...frameProps } = props;
110
- const context = useDialogContext(PORTAL_NAME, __scopeDialog);
111
- const isShowing = forceMount || context.open;
112
- const [isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
113
- if (isShowing && isFullyHidden) {
114
- setIsFullyHidden(false);
115
- }
95
+ const { __scopeDialog, forceMount, children, ...frameProps } = props, context = useDialogContext(PORTAL_NAME, __scopeDialog), isShowing = forceMount || context.open, [isFullyHidden, setIsFullyHidden] = React.useState(!isShowing);
96
+ isShowing && isFullyHidden && setIsFullyHidden(!1);
116
97
  const contents = /* @__PURE__ */ jsx(
117
98
  AnimatePresence,
118
99
  {
119
100
  onExitComplete: () => {
120
- setIsFullyHidden(true);
101
+ setIsFullyHidden(!0);
121
102
  },
122
103
  children: isShowing ? children : null
123
104
  }
124
105
  );
125
- const isSheet = useShowDialogSheet(context);
126
- if (isSheet) {
127
- return children;
128
- }
129
- if (context.modal) {
130
- if (isFullyHidden) {
131
- return null;
132
- }
133
- return /* @__PURE__ */ jsx(DialogPortalItem, { __scopeDialog, children: /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: /* @__PURE__ */ jsx(DialogPortalFrame, { pointerEvents: isShowing ? "auto" : "none", ...frameProps, children: contents }) }) });
134
- }
135
- return contents;
106
+ return useShowDialogSheet(context) ? children : context.modal ? isFullyHidden ? null : /* @__PURE__ */ jsx(DialogPortalItem, { __scopeDialog, children: /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeDialog, forceMount, children: /* @__PURE__ */ jsx(DialogPortalFrame, { pointerEvents: isShowing ? "auto" : "none", ...frameProps, children: contents }) }) }) : contents;
136
107
  };
137
108
  DialogPortal.displayName = PORTAL_NAME;
138
- const OVERLAY_NAME = "DialogOverlay";
139
- const DialogOverlayFrame = styled(Overlay, {
109
+ const OVERLAY_NAME = "DialogOverlay", DialogOverlayFrame = styled(Overlay, {
140
110
  name: OVERLAY_NAME
141
- });
142
- const DialogOverlay = DialogOverlayFrame.extractable(
111
+ }), DialogOverlay = DialogOverlayFrame.extractable(
143
112
  React.forwardRef(
144
113
  ({ __scopeDialog, ...props }, forwardedRef) => {
145
- const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog);
146
- const { forceMount = portalContext.forceMount, ...overlayProps } = props;
147
- const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
148
- const showSheet = useShowDialogSheet(context);
149
- if (!forceMount) {
150
- if (!context.modal || showSheet) {
151
- return null;
152
- }
153
- }
154
- return /* @__PURE__ */ jsx(DialogOverlayImpl, { context, ...overlayProps, ref: forwardedRef });
114
+ const portalContext = usePortalContext(OVERLAY_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...overlayProps } = props, context = useDialogContext(OVERLAY_NAME, __scopeDialog), showSheet = useShowDialogSheet(context);
115
+ return !forceMount && (!context.modal || showSheet) ? null : /* @__PURE__ */ jsx(DialogOverlayImpl, { context, ...overlayProps, ref: forwardedRef });
155
116
  }
156
117
  )
157
118
  );
@@ -173,52 +134,41 @@ const DialogOverlayImpl = React.forwardRef(
173
134
  )
174
135
  );
175
136
  }
176
- );
177
- const CONTENT_NAME = "DialogContent";
178
- const DialogContentFrame = styled(ThemeableStack, {
137
+ ), CONTENT_NAME = "DialogContent", DialogContentFrame = styled(ThemeableStack, {
179
138
  name: CONTENT_NAME,
180
139
  tag: "dialog",
181
140
  variants: {
182
141
  size: {
183
- "...size": (val, extras) => {
184
- return {};
185
- }
142
+ "...size": (val, extras) => ({})
186
143
  },
187
144
  unstyled: {
188
145
  false: {
189
146
  position: "relative",
190
- backgrounded: true,
191
- padded: true,
192
- radiused: true,
193
- elevate: true,
147
+ backgrounded: !0,
148
+ padded: !0,
149
+ radiused: !0,
150
+ elevate: !0,
194
151
  zIndex: 1e5
195
152
  }
196
153
  }
197
154
  },
198
155
  defaultVariants: {
199
156
  size: "$true",
200
- unstyled: false
157
+ unstyled: !1
201
158
  }
202
- });
203
- const DialogContent = DialogContentFrame.extractable(
159
+ }), DialogContent = DialogContentFrame.extractable(
204
160
  React.forwardRef(
205
161
  ({ __scopeDialog, ...props }, forwardedRef) => {
206
- const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog);
207
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
208
- const context = useDialogContext(CONTENT_NAME, __scopeDialog);
209
- const contents = context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { context, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { context, ...contentProps, ref: forwardedRef });
210
- if (!isWeb || context.disableRemoveScroll) {
211
- return contents;
212
- }
213
- return /* @__PURE__ */ jsx(
162
+ const portalContext = usePortalContext(CONTENT_NAME, __scopeDialog), { forceMount = portalContext.forceMount, ...contentProps } = props, context = useDialogContext(CONTENT_NAME, __scopeDialog), contents = context.modal ? /* @__PURE__ */ jsx(DialogContentModal, { context, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(DialogContentNonModal, { context, ...contentProps, ref: forwardedRef });
163
+ return !isWeb || context.disableRemoveScroll ? contents : /* @__PURE__ */ jsx(
214
164
  RemoveScroll,
215
165
  {
216
- forwardProps: true,
166
+ forwardProps: !0,
217
167
  enabled: context.open,
218
168
  allowPinchZoom: context.allowPinchZoom,
219
169
  shards: [context.contentRef],
220
- removeScrollBar: false,
221
- children: /* @__PURE__ */ jsx("div", { "data-remove-scroll-container": true, className: "_dsp_contents", children: contents })
170
+ removeScrollBar: !1,
171
+ children: /* @__PURE__ */ jsx("div", { "data-remove-scroll-container": !0, className: "_dsp_contents", children: contents })
222
172
  }
223
173
  );
224
174
  }
@@ -227,37 +177,28 @@ const DialogContent = DialogContentFrame.extractable(
227
177
  DialogContent.displayName = CONTENT_NAME;
228
178
  const DialogContentModal = React.forwardRef(
229
179
  ({ children, context, ...props }, forwardedRef) => {
230
- const contentRef = React.useRef(null);
231
- const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
232
- if (isWeb) {
233
- React.useEffect(() => {
234
- if (!context.open)
235
- return;
236
- const content = contentRef.current;
237
- if (content)
238
- return hideOthers(content);
239
- }, [context.open]);
240
- }
241
- return /* @__PURE__ */ jsx(
180
+ const contentRef = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
181
+ return isWeb && React.useEffect(() => {
182
+ if (!context.open)
183
+ return;
184
+ const content = contentRef.current;
185
+ if (content)
186
+ return hideOthers(content);
187
+ }, [context.open]), /* @__PURE__ */ jsx(
242
188
  DialogContentImpl,
243
189
  {
244
190
  ...props,
245
191
  context,
246
192
  ref: composedRefs,
247
- disableOutsidePointerEvents: true,
193
+ disableOutsidePointerEvents: !0,
248
194
  onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
249
- var _a;
250
- event.preventDefault();
251
- (_a = context.triggerRef.current) == null ? void 0 : _a.focus();
195
+ event.preventDefault(), context.triggerRef.current?.focus();
252
196
  }),
253
197
  onPointerDownOutside: composeEventHandlers(
254
198
  props.onPointerDownOutside,
255
199
  (event) => {
256
- const originalEvent = event["detail"].originalEvent;
257
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
258
- const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
259
- if (isRightClick)
260
- event.preventDefault();
200
+ const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0;
201
+ (originalEvent.button === 2 || ctrlLeftClick) && event.preventDefault();
261
202
  }
262
203
  ),
263
204
  onFocusOutside: composeEventHandlers(
@@ -268,46 +209,30 @@ const DialogContentModal = React.forwardRef(
268
209
  }
269
210
  );
270
211
  }
271
- );
272
- const DialogContentNonModal = React.forwardRef(
212
+ ), DialogContentNonModal = React.forwardRef(
273
213
  (props, forwardedRef) => {
274
- const hasInteractedOutsideRef = React.useRef(false);
214
+ const hasInteractedOutsideRef = React.useRef(!1);
275
215
  return /* @__PURE__ */ jsx(
276
216
  DialogContentImpl,
277
217
  {
278
218
  ...props,
279
219
  ref: forwardedRef,
280
- trapFocus: false,
281
- disableOutsidePointerEvents: false,
220
+ trapFocus: !1,
221
+ disableOutsidePointerEvents: !1,
282
222
  onCloseAutoFocus: (event) => {
283
- var _a, _b;
284
- (_a = props.onCloseAutoFocus) == null ? void 0 : _a.call(props, event);
285
- if (!event.defaultPrevented) {
286
- if (!hasInteractedOutsideRef.current) {
287
- (_b = props.context.triggerRef.current) == null ? void 0 : _b.focus();
288
- }
289
- event.preventDefault();
290
- }
291
- hasInteractedOutsideRef.current = false;
223
+ props.onCloseAutoFocus?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current || props.context.triggerRef.current?.focus(), event.preventDefault()), hasInteractedOutsideRef.current = !1;
292
224
  },
293
225
  onInteractOutside: (event) => {
294
- var _a;
295
- (_a = props.onInteractOutside) == null ? void 0 : _a.call(props, event);
296
- if (!event.defaultPrevented)
297
- hasInteractedOutsideRef.current = true;
298
- const target = event.target;
299
- const trigger = props.context.triggerRef.current;
226
+ props.onInteractOutside?.(event), event.defaultPrevented || (hasInteractedOutsideRef.current = !0);
227
+ const target = event.target, trigger = props.context.triggerRef.current;
300
228
  if (!(trigger instanceof HTMLElement))
301
229
  return;
302
- const targetIsTrigger = trigger.contains(target);
303
- if (targetIsTrigger)
304
- event.preventDefault();
230
+ trigger.contains(target) && event.preventDefault();
305
231
  }
306
232
  }
307
233
  );
308
234
  }
309
- );
310
- const DialogContentImpl = React.forwardRef(
235
+ ), DialogContentImpl = React.forwardRef(
311
236
  (props, forwardedRef) => {
312
237
  const {
313
238
  __scopeDialog,
@@ -321,11 +246,7 @@ const DialogContentImpl = React.forwardRef(
321
246
  onInteractOutside,
322
247
  context,
323
248
  ...contentProps
324
- } = props;
325
- const contentRef = React.useRef(null);
326
- const composedRefs = useComposedRefs(forwardedRef, contentRef);
327
- const showSheet = useShowDialogSheet(context);
328
- const contents = /* @__PURE__ */ jsx(
249
+ } = props, contentRef = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, contentRef), showSheet = useShowDialogSheet(context), contents = /* @__PURE__ */ jsx(
329
250
  DialogContentFrame,
330
251
  {
331
252
  id: context.contentId,
@@ -335,17 +256,11 @@ const DialogContentImpl = React.forwardRef(
335
256
  ...contentProps
336
257
  }
337
258
  );
338
- if (showSheet) {
339
- return /* @__PURE__ */ jsx(DialogPortalItem, { hostName: getSheetContentsName(context), children: contentProps.children });
340
- }
341
- if (!isWeb) {
342
- return contents;
343
- }
344
- return /* @__PURE__ */ jsxs(Fragment, { children: [
259
+ return showSheet ? /* @__PURE__ */ jsx(DialogPortalItem, { hostName: getSheetContentsName(context), children: contentProps.children }) : isWeb ? /* @__PURE__ */ jsxs(Fragment, { children: [
345
260
  /* @__PURE__ */ jsx(
346
261
  FocusScope,
347
262
  {
348
- loop: true,
263
+ loop: !0,
349
264
  enabled: context.open,
350
265
  trapped: trapFocus,
351
266
  onMountAutoFocus: onOpenAutoFocus,
@@ -361,7 +276,7 @@ const DialogContentImpl = React.forwardRef(
361
276
  onFocusOutside,
362
277
  onInteractOutside,
363
278
  ref: composedRefs,
364
- onDismiss: () => context.onOpenChange(false),
279
+ onDismiss: () => context.onOpenChange(!1),
365
280
  children: contents
366
281
  }
367
282
  )
@@ -377,28 +292,21 @@ const DialogContentImpl = React.forwardRef(
377
292
  }
378
293
  )
379
294
  ] })
380
- ] });
295
+ ] }) : contents;
381
296
  }
382
- );
383
- const TITLE_NAME = "DialogTitle";
384
- const DialogTitleFrame = styled(H2, {
297
+ ), TITLE_NAME = "DialogTitle", DialogTitleFrame = styled(H2, {
385
298
  name: TITLE_NAME
386
- });
387
- const DialogTitle = React.forwardRef(
299
+ }), DialogTitle = React.forwardRef(
388
300
  (props, forwardedRef) => {
389
- const { __scopeDialog, ...titleProps } = props;
390
- const context = useDialogContext(TITLE_NAME, __scopeDialog);
301
+ const { __scopeDialog, ...titleProps } = props, context = useDialogContext(TITLE_NAME, __scopeDialog);
391
302
  return /* @__PURE__ */ jsx(DialogTitleFrame, { id: context.titleId, ...titleProps, ref: forwardedRef });
392
303
  }
393
304
  );
394
305
  DialogTitle.displayName = TITLE_NAME;
395
306
  const DialogDescriptionFrame = styled(Paragraph, {
396
307
  name: "DialogDescription"
397
- });
398
- const DESCRIPTION_NAME = "DialogDescription";
399
- const DialogDescription = React.forwardRef((props, forwardedRef) => {
400
- const { __scopeDialog, ...descriptionProps } = props;
401
- const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
308
+ }), DESCRIPTION_NAME = "DialogDescription", DialogDescription = React.forwardRef((props, forwardedRef) => {
309
+ const { __scopeDialog, ...descriptionProps } = props, context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
402
310
  return /* @__PURE__ */ jsx(
403
311
  DialogDescriptionFrame,
404
312
  {
@@ -409,8 +317,7 @@ const DialogDescription = React.forwardRef((props, forwardedRef) => {
409
317
  );
410
318
  });
411
319
  DialogDescription.displayName = DESCRIPTION_NAME;
412
- const CLOSE_NAME = "DialogClose";
413
- const DialogCloseFrame = styled(View, {
320
+ const CLOSE_NAME = "DialogClose", DialogCloseFrame = styled(View, {
414
321
  name: CLOSE_NAME,
415
322
  tag: "button",
416
323
  variants: {
@@ -421,21 +328,15 @@ const DialogCloseFrame = styled(View, {
421
328
  }
422
329
  },
423
330
  defaultVariants: {
424
- unstyled: false
331
+ unstyled: !1
425
332
  }
426
- });
427
- const DialogClose = DialogCloseFrame.styleable(
333
+ }), DialogClose = DialogCloseFrame.styleable(
428
334
  (props, forwardedRef) => {
429
- const { __scopeDialog, displayWhenAdapted, ...closeProps } = props;
430
- const context = useDialogContext(CLOSE_NAME, __scopeDialog, {
431
- warn: false,
335
+ const { __scopeDialog, displayWhenAdapted, ...closeProps } = props, context = useDialogContext(CLOSE_NAME, __scopeDialog, {
336
+ warn: !1,
432
337
  fallback: {}
433
338
  });
434
- const isSheet = useShowDialogSheet(context);
435
- if (isSheet && !displayWhenAdapted) {
436
- return null;
437
- }
438
- return /* @__PURE__ */ jsx(
339
+ return useShowDialogSheet(context) && !displayWhenAdapted ? null : /* @__PURE__ */ jsx(
439
340
  DialogCloseFrame,
440
341
  {
441
342
  accessibilityLabel: "Dialog Close",
@@ -443,7 +344,7 @@ const DialogClose = DialogCloseFrame.styleable(
443
344
  ref: forwardedRef,
444
345
  onPress: composeEventHandlers(
445
346
  props.onPress,
446
- () => context.onOpenChange(false)
347
+ () => context.onOpenChange(!1)
447
348
  )
448
349
  }
449
350
  );
@@ -452,87 +353,55 @@ const DialogClose = DialogCloseFrame.styleable(
452
353
  function getState(open) {
453
354
  return open ? "open" : "closed";
454
355
  }
455
- const TITLE_WARNING_NAME = "DialogTitleWarning";
456
- const [DialogWarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {
356
+ const TITLE_WARNING_NAME = "DialogTitleWarning", [DialogWarningProvider, useWarningContext] = createContext(TITLE_WARNING_NAME, {
457
357
  contentName: CONTENT_NAME,
458
358
  titleName: TITLE_NAME,
459
359
  docsSlug: "dialog"
460
- });
461
- const TitleWarning = ({ titleId }) => {
360
+ }), TitleWarning = ({ titleId }) => {
462
361
  if (process.env.NODE_ENV === "development") {
463
- const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
464
- const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
362
+ const titleWarningContext = useWarningContext(TITLE_WARNING_NAME), MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
465
363
 
466
364
  If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.`;
467
365
  React.useEffect(() => {
468
- if (!isWeb)
469
- return;
470
- if (titleId) {
471
- const hasTitle = document.getElementById(titleId);
472
- if (!hasTitle) {
473
- console.warn(MESSAGE);
474
- }
475
- }
366
+ isWeb && titleId && (document.getElementById(titleId) || console.warn(MESSAGE));
476
367
  }, [MESSAGE, titleId]);
477
368
  }
478
369
  return null;
479
- };
480
- const DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
481
- const DescriptionWarning = ({
370
+ }, DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning", DescriptionWarning = ({
482
371
  contentRef,
483
372
  descriptionId
484
373
  }) => {
485
374
  if (process.env.NODE_ENV === "development") {
486
- const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
487
- const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
375
+ const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${useWarningContext(DESCRIPTION_WARNING_NAME).contentName}}.`;
488
376
  React.useEffect(() => {
489
377
  if (!isWeb)
490
378
  return;
491
379
  const contentNode = contentRef.current;
492
- if (!(contentNode instanceof HTMLElement)) {
380
+ if (!(contentNode instanceof HTMLElement))
493
381
  return;
494
- }
495
382
  const describedById = contentNode.getAttribute("aria-describedby");
496
- if (descriptionId && describedById) {
497
- const hasDescription = document.getElementById(descriptionId);
498
- if (!hasDescription) {
499
- console.warn(MESSAGE);
500
- }
501
- }
383
+ descriptionId && describedById && (document.getElementById(descriptionId) || console.warn(MESSAGE));
502
384
  }, [MESSAGE, contentRef, descriptionId]);
503
385
  }
504
386
  return null;
505
- };
506
- const Dialog = withStaticProperties(
507
- React.forwardRef(function Dialog2(props, ref) {
387
+ }, Dialog = withStaticProperties(
388
+ React.forwardRef(function(props, ref) {
508
389
  const {
509
390
  __scopeDialog,
510
391
  children,
511
392
  open: openProp,
512
- defaultOpen = false,
393
+ defaultOpen = !1,
513
394
  onOpenChange,
514
- modal = true,
515
- allowPinchZoom = false,
516
- disableRemoveScroll = false
517
- } = props;
518
- const baseId = React.useId();
519
- const scopeId = `scope-${baseId}`;
520
- const contentId = `content-${baseId}`;
521
- const titleId = `title-${baseId}`;
522
- const descriptionId = `description-${baseId}`;
523
- const scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId;
524
- const sheetContentsName = getSheetContentsName({ scopeKey, contentId });
525
- const triggerRef = React.useRef(null);
526
- const contentRef = React.useRef(null);
527
- const [open, setOpen] = useControllableState({
395
+ modal = !0,
396
+ allowPinchZoom = !1,
397
+ disableRemoveScroll = !1
398
+ } = props, baseId = React.useId(), scopeId = `scope-${baseId}`, contentId = `content-${baseId}`, titleId = `title-${baseId}`, descriptionId = `description-${baseId}`, scopeKey = __scopeDialog ? Object.keys(__scopeDialog)[0] : scopeId, sheetContentsName = getSheetContentsName({ scopeKey, contentId }), triggerRef = React.useRef(null), contentRef = React.useRef(null), [open, setOpen] = useControllableState({
528
399
  prop: openProp,
529
400
  defaultProp: defaultOpen,
530
401
  onChange: onOpenChange
531
- });
532
- const onOpenToggle = React.useCallback(() => {
402
+ }), onOpenToggle = React.useCallback(() => {
533
403
  setOpen((prevOpen) => !prevOpen);
534
- }, [setOpen]);
535
- const context = {
404
+ }, [setOpen]), context = {
536
405
  scope: __scopeDialog,
537
406
  scopeKey,
538
407
  triggerRef,
@@ -545,23 +414,19 @@ const Dialog = withStaticProperties(
545
414
  onOpenToggle,
546
415
  modal,
547
416
  allowPinchZoom
548
- };
549
- const { when, AdaptProvider } = useAdaptParent({
417
+ }, { when, AdaptProvider } = useAdaptParent({
550
418
  Contents: React.useCallback(
551
- (props2) => {
552
- return /* @__PURE__ */ jsx(PortalHost, { forwardProps: props2, name: sheetContentsName });
553
- },
419
+ (props2) => /* @__PURE__ */ jsx(PortalHost, { forwardProps: props2, name: sheetContentsName }),
554
420
  [sheetContentsName]
555
421
  )
556
422
  });
557
- React.useImperativeHandle(
423
+ return React.useImperativeHandle(
558
424
  ref,
559
425
  () => ({
560
426
  open: setOpen
561
427
  }),
562
428
  [setOpen]
563
- );
564
- return /* @__PURE__ */ jsx(AdaptProvider, { children: /* @__PURE__ */ jsx(
429
+ ), /* @__PURE__ */ jsx(AdaptProvider, { children: /* @__PURE__ */ jsx(
565
430
  DialogProvider,
566
431
  {
567
432
  ...context,
@@ -582,49 +447,33 @@ const Dialog = withStaticProperties(
582
447
  Sheet: Sheet.Controlled,
583
448
  Adapt
584
449
  }
585
- );
586
- const SHEET_CONTENTS_NAME = "DialogSheetContents";
587
- const DialogSheetContents = ({
450
+ ), SHEET_CONTENTS_NAME = "DialogSheetContents", DialogSheetContents = ({
588
451
  name,
589
452
  ...props
590
- }) => {
591
- return /* @__PURE__ */ jsx(PortalHost, { forwardProps: props, name });
592
- };
453
+ }) => /* @__PURE__ */ jsx(PortalHost, { forwardProps: props, name });
593
454
  DialogSheetContents.displayName = SHEET_CONTENTS_NAME;
594
455
  const getSheetContentsName = ({
595
456
  scopeKey,
596
457
  contentId
597
- }) => `${scopeKey || contentId}SheetContents`;
598
- const DialogSheetController = (props) => {
599
- const context = useDialogContext("DialogSheetController", props.__scopeDialog);
600
- const showSheet = useShowDialogSheet(context);
601
- const breakpointActive = useSheetBreakpointActive(context);
602
- const getShowSheet = useGet(showSheet);
458
+ }) => `${scopeKey || contentId}SheetContents`, DialogSheetController = (props) => {
459
+ const context = useDialogContext("DialogSheetController", props.__scopeDialog), showSheet = useShowDialogSheet(context), breakpointActive = useSheetBreakpointActive(context), getShowSheet = useGet(showSheet);
603
460
  return /* @__PURE__ */ jsx(
604
461
  SheetController,
605
462
  {
606
463
  onOpenChange: (val) => {
607
- if (getShowSheet()) {
608
- props.onOpenChange(val);
609
- }
464
+ getShowSheet() && props.onOpenChange(val);
610
465
  },
611
466
  open: context.open,
612
- hidden: breakpointActive === false,
467
+ hidden: breakpointActive === !1,
613
468
  children: props.children
614
469
  }
615
470
  );
616
- };
617
- const useSheetBreakpointActive = (context) => {
471
+ }, useSheetBreakpointActive = (context) => {
618
472
  const media = useMedia();
619
- if (!context.sheetBreakpoint)
620
- return false;
621
- if (context.sheetBreakpoint === true)
622
- return true;
623
- return media[context.sheetBreakpoint];
624
- };
625
- const useShowDialogSheet = (context) => {
473
+ return context.sheetBreakpoint ? context.sheetBreakpoint === !0 ? !0 : media[context.sheetBreakpoint] : !1;
474
+ }, useShowDialogSheet = (context) => {
626
475
  const breakpointActive = useSheetBreakpointActive(context);
627
- return context.open === false ? false : breakpointActive;
476
+ return context.open === !1 ? !1 : breakpointActive;
628
477
  };
629
478
  export {
630
479
  Dialog,