@mortenbrudvik/waveui 0.10.0 → 0.11.0

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.
Files changed (184) hide show
  1. package/README.md +357 -72
  2. package/dist/components/button/Toolbar.cjs +1 -1
  3. package/dist/components/button/Toolbar.cjs.map +1 -1
  4. package/dist/components/button/Toolbar.mjs +25 -30
  5. package/dist/components/button/Toolbar.mjs.map +1 -1
  6. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  7. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  8. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  9. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  10. package/dist/components/data-display/Avatar.cjs +1 -1
  11. package/dist/components/data-display/Avatar.cjs.map +1 -1
  12. package/dist/components/data-display/Avatar.context.cjs +2 -0
  13. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  14. package/dist/components/data-display/Avatar.context.mjs +9 -0
  15. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  16. package/dist/components/data-display/Avatar.mjs +66 -61
  17. package/dist/components/data-display/Avatar.mjs.map +1 -1
  18. package/dist/components/data-display/InteractionTag.cjs +2 -0
  19. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  20. package/dist/components/data-display/InteractionTag.mjs +234 -0
  21. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  22. package/dist/components/data-display/Tag.cjs +1 -1
  23. package/dist/components/data-display/Tag.cjs.map +1 -1
  24. package/dist/components/data-display/Tag.mjs +222 -90
  25. package/dist/components/data-display/Tag.mjs.map +1 -1
  26. package/dist/components/data-display/TagGroup.cjs +2 -0
  27. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  28. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  29. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  30. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  31. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  32. package/dist/components/data-display/TagGroup.mjs +149 -0
  33. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  34. package/dist/components/data-display/tagStyles.cjs +2 -0
  35. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  36. package/dist/components/data-display/tagStyles.mjs +108 -0
  37. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  38. package/dist/components/feedback/Toaster.cjs +1 -1
  39. package/dist/components/feedback/Toaster.cjs.map +1 -1
  40. package/dist/components/feedback/Toaster.mjs +213 -181
  41. package/dist/components/feedback/Toaster.mjs.map +1 -1
  42. package/dist/components/input/Combobox.expand.cjs +1 -1
  43. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  44. package/dist/components/input/Combobox.expand.mjs +7 -7
  45. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  46. package/dist/components/input/Option.cjs +1 -1
  47. package/dist/components/input/Option.cjs.map +1 -1
  48. package/dist/components/input/Option.mjs +16 -11
  49. package/dist/components/input/Option.mjs.map +1 -1
  50. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  51. package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
  52. package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
  53. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  54. package/dist/components/input/TagPicker.cjs +1 -1
  55. package/dist/components/input/TagPicker.cjs.map +1 -1
  56. package/dist/components/input/TagPicker.context.cjs +2 -0
  57. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  58. package/dist/components/input/TagPicker.context.mjs +20 -0
  59. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  60. package/dist/components/input/TagPicker.create.cjs +2 -0
  61. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  62. package/dist/components/input/TagPicker.create.mjs +24 -0
  63. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  64. package/dist/components/input/TagPicker.mjs +13 -279
  65. package/dist/components/input/TagPicker.mjs.map +1 -1
  66. package/dist/components/input/TagPicker.option.cjs +2 -0
  67. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  68. package/dist/components/input/TagPicker.option.mjs +45 -0
  69. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  70. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  71. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  72. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  73. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  74. package/dist/components/input/TagPicker.parts.cjs +2 -0
  75. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  76. package/dist/components/input/TagPicker.parts.mjs +425 -0
  77. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  78. package/dist/components/input/TagPicker.root.cjs +2 -0
  79. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  80. package/dist/components/input/TagPicker.root.mjs +416 -0
  81. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  82. package/dist/components/layout/Accordion.cjs.map +1 -1
  83. package/dist/components/layout/Accordion.mjs.map +1 -1
  84. package/dist/components/navigation/Hamburger.cjs +2 -0
  85. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  86. package/dist/components/navigation/Hamburger.mjs +54 -0
  87. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  88. package/dist/components/navigation/Nav.cjs +1 -1
  89. package/dist/components/navigation/Nav.cjs.map +1 -1
  90. package/dist/components/navigation/Nav.context.cjs +2 -0
  91. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  92. package/dist/components/navigation/Nav.context.mjs +137 -0
  93. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  94. package/dist/components/navigation/Nav.mjs +151 -258
  95. package/dist/components/navigation/Nav.mjs.map +1 -1
  96. package/dist/components/navigation/Nav.parts.cjs +2 -0
  97. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  98. package/dist/components/navigation/Nav.parts.mjs +77 -0
  99. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  100. package/dist/components/navigation/Nav.root.cjs +2 -0
  101. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  102. package/dist/components/navigation/Nav.root.mjs +78 -0
  103. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  104. package/dist/components/navigation/NavDrawer.cjs +2 -0
  105. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  106. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  107. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  108. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  109. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  110. package/dist/components/navigation/NavDrawer.mjs +179 -0
  111. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  112. package/dist/components/overlays/Dialog.cjs +1 -1
  113. package/dist/components/overlays/Dialog.cjs.map +1 -1
  114. package/dist/components/overlays/Dialog.mjs +190 -125
  115. package/dist/components/overlays/Dialog.mjs.map +1 -1
  116. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  117. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  118. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  119. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  120. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  121. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  122. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  123. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  124. package/dist/components/overlays/Drawer.cjs +1 -1
  125. package/dist/components/overlays/Drawer.cjs.map +1 -1
  126. package/dist/components/overlays/Drawer.context.cjs +2 -0
  127. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  128. package/dist/components/overlays/Drawer.context.mjs +29 -0
  129. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  130. package/dist/components/overlays/Drawer.mjs +12 -187
  131. package/dist/components/overlays/Drawer.mjs.map +1 -1
  132. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  133. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  134. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  135. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  136. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  137. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  138. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  139. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  140. package/dist/components/overlays/Drawer.root.cjs +2 -0
  141. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  142. package/dist/components/overlays/Drawer.root.mjs +207 -0
  143. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  144. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  145. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  146. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  147. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  148. package/dist/hooks/useDismiss.cjs.map +1 -1
  149. package/dist/hooks/useDismiss.mjs.map +1 -1
  150. package/dist/hooks/useFocusTrap.cjs +1 -1
  151. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  152. package/dist/hooks/useFocusTrap.mjs +115 -98
  153. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  154. package/dist/hooks/useModalLayer.cjs +1 -1
  155. package/dist/hooks/useModalLayer.cjs.map +1 -1
  156. package/dist/hooks/useModalLayer.mjs +35 -22
  157. package/dist/hooks/useModalLayer.mjs.map +1 -1
  158. package/dist/hooks/useRestoreFocus.cjs +1 -1
  159. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  160. package/dist/hooks/useRestoreFocus.mjs +91 -78
  161. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  162. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  163. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  164. package/dist/hooks/useRovingTabIndex.mjs +102 -78
  165. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  166. package/dist/index.cjs +1 -1
  167. package/dist/index.d.cts +2226 -221
  168. package/dist/index.d.ts +2226 -221
  169. package/dist/index.mjs +115 -107
  170. package/dist/lib/classNames.cjs +1 -1
  171. package/dist/lib/classNames.cjs.map +1 -1
  172. package/dist/lib/classNames.mjs +137 -77
  173. package/dist/lib/classNames.mjs.map +1 -1
  174. package/dist/lib/icons.cjs +1 -1
  175. package/dist/lib/icons.cjs.map +1 -1
  176. package/dist/lib/icons.mjs +13 -6
  177. package/dist/lib/icons.mjs.map +1 -1
  178. package/dist/lib/layers.cjs +1 -1
  179. package/dist/lib/layers.cjs.map +1 -1
  180. package/dist/lib/layers.mjs +53 -47
  181. package/dist/lib/layers.mjs.map +1 -1
  182. package/dist/styles.css +1 -1
  183. package/package.json +1 -1
  184. package/src/styles/tokens.css +25 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.cjs","names":["React","inertModalTrigger","useRequiredContext","useModalOpenState","useIsClient","useModalTrigger","useModalTriggerPart","useModalClosePart","useId","useTitleRegistry","useMergedRefs","useBackdropPress","useModalDismiss","useModalLayer","slotRendersContent","Portal","cn","dialogContentClassNames","ModalSurfaceContext","dialogTitleClassNames","Button","DismissIcon","useModalTitle","dialogFooterClassNames","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_useId","require_useMergedRefs","require_useIsClient","require_Portal","require_Button","require_icons","require_useModalLayer","require_Dialog_shared","react","react_jsx_runtime","DialogContext","inertDialogContext","useDialogContext","componentName","DialogRoot","openState","requestOpen","open","defaultOpen","onOpenChange","isClient","isOpen","trigger","contentId","setContentId","registerContentId","id","current","context","modalType","finalFocusRef","DialogTrigger","props","DialogClose","sizeClasses","DialogContent","rest","generatedId","propTitleId","titles","surface","setSurface","surfaceRef","attachSurface","node","registerId","mergedRef","ref","closesOnBackdropPress","backdropPress","onDismiss","layer","footerHeight","setFooterHeight","surfaceContext","hasTitle","title","size","className","closeLabel","event","DialogTitle","titleId","titleRef","stickyFooterClasses","footerRowClasses","DialogFooter","outsideContent","footer","setFooter","observer","entry","entries","Dialog"],"sources":["../../../src/components/overlays/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n dialogContentClassNames,\n dialogFooterClassNames,\n dialogTitleClassNames,\n} from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport { DismissIcon } from '../../lib/icons';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { ModalOpenChangeReason, ModalType, OpenChangeDetails } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useModalLayer } from '../../hooks/useModalLayer';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport {\n inertModalTrigger,\n ModalSurfaceContext,\n useBackdropPress,\n useModalClosePart,\n useModalDismiss,\n useModalOpenState,\n useModalTitle,\n useModalTrigger,\n useModalTriggerPart,\n useModalTriggerSession,\n useRequiredContext,\n useTitleRegistry,\n useUnnamedModalWarning,\n type ModalRequestOpen,\n type ModalSurfaceContextValue,\n type ModalTrigger,\n} from './Dialog.shared';\n\n/**\n * Why a {@link Dialog} asks to open or close: `trigger` (`Dialog.Trigger`), `close`\n * (`Dialog.Close`), `close-button` (the built-in Close button), `escape`, `outside-press` (the\n * backdrop). The shared `ModalOpenChangeReason`.\n */\nexport type DialogOpenChangeReason = ModalOpenChangeReason;\n\n/** The second argument of a {@link Dialog}'s `onOpenChange`: the reason and the DOM event. */\nexport type DialogOpenChangeDetails = OpenChangeDetails<DialogOpenChangeReason>;\n\n/**\n * How a {@link Dialog} blocks the page (the shared `ModalType`; Drawer reuses it when it gains\n * `modalType`).\n */\nexport type DialogModalType = ModalType;\n\n/** Properties for the Dialog component. */\nexport interface DialogProps {\n /**\n * Controlled open state of the dialog. The surface renders only in the browser: an open dialog\n * is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Default open state for uncontrolled usage. The surface renders only in the browser: a dialog\n * open by default is closed in the server HTML and opens once it has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the new open state when it changes. `details.reason` tells how — `trigger`,\n * `close` (a `.Close` part), `close-button` (the built-in Close button), `escape` or\n * `outside-press` (the backdrop) — so a controlled dialog can refuse only some ways of closing\n * (for example keep a form with unsaved changes open on `outside-press`); `details.event` is the\n * DOM event behind the request. WaveUI always passes `details`; it is typed optional until 1.0\n * so that code which calls this prop itself keeps compiling.\n *\n * Fires only when the value changes; a controlled dialog stays as it is until the parent updates\n * `open`.\n */\n onOpenChange?: (open: boolean, details?: DialogOpenChangeDetails) => void;\n /**\n * `modal`: a backdrop press, Escape, the Close button and `Dialog.Close` close it. `alert`: a\n * confirmation that needs an answer — `role=\"alertdialog\"`, and a backdrop press does not close\n * it (Escape still does). Initial focus goes to the first focusable element, the built-in Close\n * button; give the least destructive action `autoFocus` to focus it instead. (`'non-modal'` is\n * planned.)\n * @default 'modal'\n */\n modalType?: DialogModalType;\n /**\n * Where focus goes when the dialog closes, if it can take focus. Otherwise focus returns to the\n * element that had focus when the dialog opened, then to the trigger, then to an element next to\n * where that opener was (the next row's action after a confirm dialog deleted the row). Use it to\n * send focus somewhere else.\n */\n finalFocusRef?: React.RefObject<HTMLElement | null>;\n /** `Dialog.Trigger` and `Dialog.Content`. */\n children: React.ReactNode;\n}\n\n/** Properties for the DialogContent sub-component. */\nexport interface DialogContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /**\n * Title rendered as the dialog's heading; it names the dialog (`aria-labelledby`). Without it,\n * render a `Dialog.Title` or pass `aria-label`/`aria-labelledby`. A title that renders nothing\n * (`''`, `[]`, `true`) counts as none.\n */\n title?: React.ReactNode;\n /** Maximum width of the dialog: 400px (`small`) or 600px (`medium`); it never exceeds the viewport.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /** Content rendered inside the dialog body (put `Dialog.Footer` here as well). */\n children: React.ReactNode;\n /** Ref to the dialog surface (`role=\"dialog\"`, or `alertdialog` with `modalType=\"alert\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the DialogFooter sub-component. */\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Footer content, typically action buttons (wrap closing buttons in `Dialog.Close`). */\n children: React.ReactNode;\n /** Ref to the footer element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the DialogTitle sub-component. */\nexport interface DialogTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /** The title; any content. */\n children: React.ReactNode;\n /** Ref to the heading element. */\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\n/** Props a `Dialog.Trigger` puts on its element (and passes to a render-prop child). */\nexport interface DialogTriggerRenderProps extends React.HTMLAttributes<HTMLElement> {\n 'aria-haspopup': 'dialog';\n 'aria-expanded': boolean;\n /** The dialog surface's id, while the dialog is open. */\n 'aria-controls'?: string;\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DialogTrigger sub-component. */\nexport interface DialogTriggerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that opens the dialog. A single element receives the trigger props (merged with\n * its own: handlers composed, classes joined, its own `id` kept); a function receives them.\n */\n children: React.ReactNode | ((props: DialogTriggerRenderProps) => React.ReactNode);\n /**\n * `false` renders the 0.4 wrapper `<span>` around the children instead of merging the trigger\n * props onto the child. The span carries the click handler; `aria-haspopup`, `aria-expanded`\n * and `aria-controls` go to the first element in the tab order inside it.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Props a `Dialog.Close` puts on its element (and passes to a render-prop child). */\nexport interface DialogCloseRenderProps extends React.HTMLAttributes<HTMLElement> {\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DialogClose sub-component. */\nexport interface DialogCloseProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that closes the dialog, typically a footer button. A single element receives an\n * `onClick` composed with its own (its handler runs first; `preventDefault()` keeps the dialog\n * open); a function receives the props.\n */\n children: React.ReactNode | ((props: DialogCloseRenderProps) => React.ReactNode);\n /** `false` renders a wrapper `<span>` that closes the dialog on click. @default true */\n asChild?: boolean;\n /** Ref to the close element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\ninterface DialogContextValue {\n open: boolean;\n /** Asks the root to open or close, with the reason and event for `onOpenChange`. */\n requestOpen: ModalRequestOpen;\n /** The resolved `modalType`. */\n modalType: DialogModalType;\n /** The trigger element (`attach`) and the focus-restore target resolved from it (`focusRef`). */\n trigger: ModalTrigger;\n finalFocusRef: React.RefObject<HTMLElement | null> | undefined;\n /** The id of the open dialog surface (for the trigger's `aria-controls`), or `undefined`. */\n contentId: string | undefined;\n /** Registers the surface's id while it is mounted; returns the unregister function. */\n registerContentId: (id: string) => () => void;\n}\n\nconst DialogContext = React.createContext<DialogContextValue | null>(null);\nDialogContext.displayName = 'DialogContext';\n\nconst inertDialogContext: DialogContextValue = {\n open: false,\n requestOpen: () => {},\n modalType: 'modal',\n trigger: inertModalTrigger,\n finalFocusRef: undefined,\n contentId: undefined,\n registerContentId: () => () => {},\n};\n\nfunction useDialogContext(componentName: string): DialogContextValue {\n return useRequiredContext(DialogContext, componentName, 'Dialog', () => inertDialogContext);\n}\n\n// The root of `Dialog` (documented on the export below). A const arrow (like DrawerRoot): its type\n// can be named in consumers' declaration files, e.g. a story's `satisfies Meta<typeof Dialog>` (a\n// function declaration's `typeof` cannot, TS4023).\nconst DialogRoot = ({\n open,\n defaultOpen,\n onOpenChange,\n modalType = 'modal',\n finalFocusRef,\n children,\n}: DialogProps) => {\n const [openState, requestOpen] = useModalOpenState(open, defaultOpen, onOpenChange);\n // The surface lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the dialog reports itself closed, so the trigger's aria-expanded never\n // describes a dialog that is not there.\n const isClient = useIsClient();\n const isOpen = openState && isClient;\n const trigger = useModalTrigger();\n // After Dialog.Content's focus restore (a child's layout effects run first), start the trigger\n // session, or end it and forget the trigger that opened it.\n useModalTriggerSession(trigger, isOpen);\n const [contentId, setContentId] = React.useState<string | undefined>(undefined);\n const registerContentId = React.useCallback((id: string) => {\n setContentId(id);\n return () => setContentId((current) => (current === id ? undefined : current));\n }, []);\n\n const context = React.useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n requestOpen,\n modalType,\n trigger,\n finalFocusRef,\n contentId,\n registerContentId,\n }),\n [isOpen, requestOpen, modalType, trigger, finalFocusRef, contentId, registerContentId],\n );\n\n return <DialogContext.Provider value={context}>{children}</DialogContext.Provider>;\n};\nDialogRoot.displayName = 'Dialog';\n\n/**\n * Opens the dialog. Puts `aria-haspopup=\"dialog\"`, `aria-expanded`, `aria-controls` (while open), a\n * click handler and a ref on its single child (no wrapper element), or passes them to a\n * render-prop child. A custom child component must forward `ref` and spread its props; one that\n * does not is wrapped in a `<span>` automatically (with a development warning), the span that\n * `asChild={false}` renders. Focus returns to the trigger when the dialog closes (with several\n * triggers, to the one that opened it). On the span, the state ARIA goes to the first element in\n * the tab order inside it, and focus returns to that element (to the span when you made it the\n * trigger with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take\n * focus).\n */\nexport const DialogTrigger = (props: DialogTriggerProps) => {\n const { open, requestOpen, trigger, contentId } = useDialogContext('Dialog.Trigger');\n return useModalTriggerPart<DialogTriggerRenderProps>(\n { open, requestOpen, trigger, controlsId: contentId },\n props,\n 'Dialog.Trigger',\n );\n};\nDialogTrigger.displayName = 'DialogTrigger';\n\n/**\n * Closes the dialog: composes a click handler onto its single child (its own `onClick` runs first;\n * calling `preventDefault()` there keeps the dialog open), or passes it to a render-prop child.\n *\n * @example\n * <Dialog.Close><Button appearance=\"subtle\">Cancel</Button></Dialog.Close>\n */\nexport const DialogClose = (props: DialogCloseProps) => {\n const { requestOpen } = useDialogContext('Dialog.Close');\n return useModalClosePart<DialogCloseRenderProps>(requestOpen, props, 'Dialog.Close');\n};\nDialogClose.displayName = 'DialogClose';\n\nconst sizeClasses: Record<'small' | 'medium', string> = {\n small: 'max-w-[400px]',\n medium: 'max-w-[600px]',\n};\n\n/**\n * The dialog surface, rendered in a portal (inheriting the WaveProvider theme) while the dialog is\n * open: backdrop, title, Close button and a scrolling body. It takes the full width up to its\n * `size` and never exceeds the viewport (the body scrolls, also sideways for content wider than\n * the dialog). Its 1rem gap to the viewport edges is its own margin, so a margin in `className`\n * replaces the gap: with the width and height caps lifted as well and its height set to the\n * viewport's, it fills the viewport (a full-screen dialog). It is `role=\"dialog\"`, or\n * `role=\"alertdialog\"` when the Dialog has `modalType=\"alert\"` (a `role` you pass wins), and\n * carries `data-modal-type` with the resolved type.\n */\nexport const DialogContent = ({\n title,\n size = 'medium',\n closeLabel = 'Close',\n children,\n className,\n id,\n ref,\n ...rest\n}: DialogContentProps) => {\n const { open, requestOpen, modalType, trigger, finalFocusRef, registerContentId } =\n useDialogContext('Dialog.Content');\n const generatedId = useId('wave-dialog');\n const contentId = id ?? generatedId;\n const propTitleId = useId('wave-dialog-title');\n const titles = useTitleRegistry();\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const attachSurface = React.useCallback((node: HTMLDivElement | null) => {\n surfaceRef.current = node;\n setSurface(node);\n }, []);\n // Reports the surface's id to the root (the trigger's `aria-controls`) while it is mounted. A new\n // `id` makes a new callback, which useMergedRefs re-attaches after the commit (re-registering).\n const registerId = React.useCallback(\n (node: HTMLDivElement | null) => (node ? registerContentId(contentId) : undefined),\n [registerContentId, contentId],\n );\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, attachSurface, registerId);\n\n // An alert dialog needs an answer: a backdrop press does not close it (Escape still does).\n const closesOnBackdropPress = modalType !== 'alert';\n const backdropPress = useBackdropPress(surfaceRef, closesOnBackdropPress);\n const onDismiss = useModalDismiss(requestOpen, 'Dialog', backdropPress.afterOutsidePress);\n const layer = useModalLayer({\n open,\n onDismiss,\n refs: [surfaceRef],\n outsidePress: closesOnBackdropPress,\n container: surface,\n triggerRef: trigger.focusRef,\n finalFocusRef,\n });\n useUnnamedModalWarning(open ? surface : null, titles.hasTitle, 'Dialog.Content', 'Dialog.Title');\n\n // The height of the sticky Dialog.Footer, reserved as the body's scroll padding.\n const [footerHeight, setFooterHeight] = React.useState<number | null>(null);\n const surfaceContext = React.useMemo<ModalSurfaceContextValue>(\n () => ({ ...titles.context, setFooterHeight }),\n [titles.context],\n );\n\n if (!open) return null;\n\n const hasTitle = slotRendersContent(title);\n\n return (\n <Portal layerId={layer.layerId}>\n <div\n className={cn(\n dialogContentClassNames.backdrop,\n 'fixed inset-0 flex items-center justify-center bg-backdrop',\n )}\n onMouseDown={backdropPress.onMouseDown}\n >\n <div\n ref={mergedRef}\n role={modalType === 'alert' ? 'alertdialog' : 'dialog'}\n id={contentId}\n aria-labelledby={hasTitle ? propTitleId : titles.titleId}\n tabIndex={-1}\n data-modal-type={modalType}\n {...rest}\n className={cn(\n dialogContentClassNames.root,\n // The border marks the surface where the shadow cannot: in high contrast the page,\n // the backdrop and the surface are black, and forced colors drop shadows. The 1rem gap\n // to the viewport edges is the surface's own margin, not the backdrop's padding, so a\n // margin in `className` replaces it and a full-screen dialog can reach the edges. Its\n // minimum width is zero, so content wider than the room inside the gap scrolls in the\n // body instead of pushing the surface over the gap.\n 'relative m-4 flex min-w-0 max-h-[calc(100dvh-2rem)] w-full flex-col rounded-lg border border-border bg-background p-6 text-foreground shadow-64',\n sizeClasses[size],\n className,\n )}\n >\n <ModalSurfaceContext.Provider value={surfaceContext}>\n {hasTitle && (\n <h2\n id={propTitleId}\n className={cn(dialogTitleClassNames.root, 'pe-8 text-subtitle-1 font-semibold')}\n >\n {title}\n </h2>\n )}\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n onClick={(event) =>\n requestOpen(false, { reason: 'close-button', event: event.nativeEvent })\n }\n className={cn(\n dialogContentClassNames.closeButton,\n 'absolute end-4 top-4 text-muted-foreground',\n )}\n />\n <div\n // The scroll padding keeps a focused field above the sticky footer (WCAG 2.4.11).\n className={cn(\n dialogContentClassNames.body,\n '-mx-1 mt-1 min-h-0 flex-1 overflow-y-auto scroll-pb-(--wave-dialog-footer-height) p-1 text-body-1',\n )}\n style={\n footerHeight === null\n ? undefined\n : ({ '--wave-dialog-footer-height': `${footerHeight}px` } as React.CSSProperties)\n }\n >\n {children}\n </div>\n </ModalSurfaceContext.Provider>\n </div>\n </div>\n </Portal>\n );\n};\nDialogContent.displayName = 'DialogContent';\n\n/**\n * A heading that names the dialog (`aria-labelledby`), for rich titles or custom layouts. Render it\n * inside `Dialog.Content` (instead of the `title` prop). Like the `title` heading it reserves end\n * padding (`pe-8`) so a long first line stays clear of the Close button; a `className` padding wins.\n */\nexport const DialogTitle = ({ id, className, children, ref, ...rest }: DialogTitleProps) => {\n const { id: titleId, ref: titleRef } = useModalTitle('Dialog.Title', 'Dialog.Content', id, ref);\n return (\n <h2\n {...rest}\n id={titleId}\n ref={titleRef}\n className={cn(\n dialogTitleClassNames.root,\n 'pe-8 text-subtitle-1 font-semibold text-foreground',\n className,\n )}\n >\n {children}\n </h2>\n );\n};\nDialogTitle.displayName = 'DialogTitle';\n\n/**\n * `Dialog.Footer` inside `Dialog.Content`. The body is `p-1`, and sticky positioning stops at its\n * padding edge: `-bottom-1` with `-mb-1 pb-2` covers the body's bottom padding, `-mx-1 px-1` its\n * focus-ring inset, and `pt-3` separates the actions from the content scrolling under them.\n */\nconst stickyFooterClasses =\n 'sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-background px-1 pb-2 pt-3';\n\n/**\n * `Dialog.Footer` where no body reserves its height as scroll padding (a Drawer's body): a plain\n * action row, which never covers a focused field.\n */\nconst footerRowClasses = 'mt-6 flex justify-end gap-2';\n\n/**\n * Action row at the end of the dialog body. It stays where you render it in the DOM and sticks to\n * the bottom of the body while long content scrolls under it (with an opaque background); the body\n * reserves its height as scroll padding, so a focused field is never hidden behind it. Inside a\n * `<form>` that wraps the fields and the footer it sticks too: make it the form's last child.\n * Render it inside `Dialog.Content`: outside it, it would stay on the page while the dialog is\n * closed (a development warning says so). Inside a `Drawer`, whose body reserves no footer height,\n * it does not stick: it is an action row at the end of the content. Render one `Dialog.Footer` per\n * `Dialog.Content`: with two at once, the body reserves the height of the one measured last, and\n * unmounting either clears it until the other resizes (swapping one footer for another is fine).\n */\nexport const DialogFooter = ({ children, className, ref, ...rest }: DialogFooterProps) => {\n const surfaceContext = React.useContext(ModalSurfaceContext);\n const outsideContent = surfaceContext === null;\n const setFooterHeight = surfaceContext?.setFooterHeight;\n const [footer, setFooter] = React.useState<HTMLDivElement | null>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, setFooter);\n\n React.useEffect(() => {\n if (!outsideContent) return;\n warnOnce(\n 'Dialog.Footer:outside-content',\n 'Dialog.Footer must be rendered inside Dialog.Content. Outside it, the footer stays on the page while the dialog is closed.',\n );\n }, [outsideContent]);\n\n // Reports the footer's border-box height to Dialog.Content. The observer's first callback,\n // delivered before the next paint, supplies the first value; without ResizeObserver the body\n // keeps its default scroll padding.\n React.useLayoutEffect(() => {\n if (!footer || !setFooterHeight || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n if (!entry) return;\n setFooterHeight(entry.borderBoxSize?.[0]?.blockSize ?? footer.offsetHeight);\n });\n observer.observe(footer, { box: 'border-box' });\n return () => {\n observer.disconnect();\n setFooterHeight(null);\n };\n }, [footer, setFooterHeight]);\n\n return (\n <div\n ref={mergedRef}\n {...rest}\n // Sticky only where the surface reserves the footer's height (Dialog.Content).\n className={cn(\n dialogFooterClassNames.root,\n setFooterHeight ? stickyFooterClasses : footerRowClasses,\n className,\n )}\n >\n {children}\n </div>\n );\n};\nDialogFooter.displayName = 'DialogFooter';\n\n/**\n * A modal dialog (Fluent UI v2 style): `Dialog` holds the open state; `Dialog.Trigger` opens it and\n * `Dialog.Content` renders the surface in a portal while open.\n *\n * - **Modal**: focus moves into the dialog and Tab stays inside it (toasts included), the rest of\n * the page is `inert` (instead of `aria-modal`, so toasts and live regions stay announced), and\n * the page does not scroll.\n * - **Closing**: Escape (only the topmost layer: a popup opened inside closes first), a click on\n * the backdrop (a drag that starts inside does not close it), the Close button and `Dialog.Close`.\n * `onOpenChange` gets the reason as its second argument (`details.reason`), so a controlled\n * dialog can refuse some of them. A backdrop press blurs the focused field before the dialog\n * closes, so a typed value is committed as with the Close button; when a controlled dialog\n * refuses the press, the field gets focus back (an alert dialog's press leaves focus where it\n * was). Focus returns to the first of these that can take focus: `finalFocusRef`, the element\n * that had focus when the dialog opened, the trigger, an element next to where that opener was.\n * - **Alert dialogs**: `modalType=\"alert\"` renders `role=\"alertdialog\"` for a confirmation that\n * needs an answer; a backdrop press does not close it.\n * - **Footer**: `Dialog.Footer` sticks to the bottom of the scrolling body, and the body keeps a\n * focused field above it.\n * - **Naming**: give `Dialog.Content` a `title`, a `Dialog.Title`, or `aria-label`.\n *\n * The sub-components are also exported under flat names (`DialogTrigger`, `DialogContent`,\n * `DialogFooter`, `DialogTitle`, `DialogClose`) for React Server Components, which cannot use the\n * dotted form; dotted access (`Dialog.Content`) needs a client file.\n *\n * @example\n * <Dialog>\n * <Dialog.Trigger><Button>Delete</Button></Dialog.Trigger>\n * <Dialog.Content title=\"Delete file?\">\n * This cannot be undone.\n * <Dialog.Footer>\n * <Dialog.Close><Button appearance=\"subtle\">Cancel</Button></Dialog.Close>\n * <Button appearance=\"primary\" onClick={remove}>Delete</Button>\n * </Dialog.Footer>\n * </Dialog.Content>\n * </Dialog>\n */\nexport const Dialog = /* @__PURE__ */ Object.assign(DialogRoot, {\n Trigger: DialogTrigger,\n Content: DialogContent,\n Footer: DialogFooter,\n Title: DialogTitle,\n Close: DialogClose,\n});\n"],"mappings":"2jBA0MA,IAAMuC,EAAgBvC,EAAM,cAAyC,IAAI,EACzE,EAAc,YAAc,gBAE5B,IAAMwC,EAAyC,CAC7C,KAAM,GACN,gBAAmB,CAAC,EACpB,UAAW,QACX,QAASvC,EAAAA,kBACT,cAAe,IAAA,GACf,UAAW,IAAA,GACX,0BAA+B,CAAC,CAClC,EAEA,SAASwC,EAAiB,EAA2C,CACnE,OAAOvC,EAAAA,mBAAmBqC,EAAeG,EAAe,aAAgBF,CAAkB,CAC5F,CAKA,IAAMG,GAAc,CAClB,OACA,cACA,eACA,YAAY,QACZ,gBACA,cACiB,CACjB,GAAM,CAACC,EAAWC,GAAe1C,EAAAA,kBAAkB2C,EAAMC,EAAaC,CAAY,EAI5EC,EAAW7C,EAAAA,YAAY,EACvB8C,EAASN,GAAaK,EACtBE,EAAU9C,EAAAA,gBAAgB,EAGhC+B,EAAA,uBAAuBe,EAASD,CAAM,EACtC,GAAM,CAACE,EAAWC,GAAgBrD,EAAM,SAA6B,IAAA,EAAS,EACxEsD,EAAoBtD,EAAM,YAAa,IAC3CqD,EAAaE,CAAE,MACFF,EAAc,GAAaG,IAAYD,EAAK,IAAA,GAAYC,CAAQ,GAC5E,CAAC,CAAC,EAECC,EAAUzD,EAAM,aACb,CACL,KAAMkD,EACN,cACA,YACA,UACA,gBACA,YACA,mBACF,GACA,CAACA,EAAQL,EAAaa,EAAWP,EAASQ,EAAeP,EAAWE,CAAiB,CACvF,EAEA,OAAO,EAAAhB,EAAA,IAAA,CAACC,EAAc,SAAf,CAAwB,MAAOkB,EAAU,UAAiC,CAAA,CACnF,EACA,EAAW,YAAc,SAazB,IAAaG,EAAiB,GAA8B,CAC1D,GAAM,CAAE,OAAM,cAAa,UAAS,aAAcnB,EAAiB,gBAAgB,EACnF,O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ED,OADAE,EAAS,QAAQF,EAAQ,CAAE,IAAK,YAAa,CAAC,MACjC,CACXE,EAAS,WAAW,EACpBjB,EAAgB,IAAI,CACtB,CACF,EAAG,CAACe,EAAQf,CAAe,CAAC,GAG1B,EAAA5C,EAAA,IAAA,CAAC,MAAD,CACE,IAAKqC,EACL,GAAIV,EAEJ,UAAWjD,EAAAA,GACTO,EAAAA,uBAAuB,KACvB2D,EAAkBW,EAAsBC,EACxCP,CACF,EAEC,UACE,CAAA,CAET,EACA,EAAa,YAAc,eAuC3B,IAAae,EAAyB,OAAO,OAAO3D,EAAY,CAC9D,QAASiB,EACT,QAASI,EACT,OAAQ+B,EACR,MAAOL,EACP,MAAO5B,CACT,CAAC"}
1
+ {"version":3,"file":"Dialog.cjs","names":["React","inertModalTrigger","useRequiredContext","useModalOpenState","useIsClient","useModalTrigger","useModalTriggerPart","useModalClosePart","usePresence","useId","useTitleRegistry","useMergedRefs","useBackdropPress","useModalDismiss","useModalLayer","useModalOpener","usePopoverTabOrder","getTabbableThrough","slotRendersContent","Portal","ModalBackdrop","dialogContentClassNames","cn","composeEventHandlers","ModalSurfaceContext","dialogTitleClassNames","renderSlot","ModalCloseButton","useModalTitle","_Fragment","createPortal","dialogFooterClassNames","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useId","require_useMergedRefs","require_useIsClient","require_usePresence","require_Portal","require_Popover_shared","require_Dialog_shared","require_useModalLayer","require_Dialog_slots","react","react_jsx_runtime","react_dom","DialogContext","inertDialogContext","useDialogContext","componentName","DialogRoot","openState","requestOpen","open","defaultOpen","onOpenChange","isClient","isOpen","trigger","contentId","setContentId","registerContentId","id","current","context","modalType","finalFocusRef","unmountOnClose","DialogTrigger","props","DialogClose","sizeClasses","fullTitleActionsClasses","TITLE_ACTIONS_GAP","BACKDROP_IGNORED_WARNING_KEY","BACKDROP_IGNORED_WARNING","NON_MODAL_FULL_WARNING_KEY","NON_MODAL_FULL_WARNING","useTitleActionsWidth","width","setWidth","area","observer","entry","entries","DialogContent","rest","presenceRef","keptMounted","generatedId","propTitleId","titles","surface","setSurface","surfaceRef","attachSurface","node","registerId","mergedRef","ref","portalRef","backdropPress","onDismiss","layer","nonModal","opener","onTabOrderKeyDown","backdropIgnored","backdrop","coversUsablePage","size","titleActionsArea","setTitleActionsArea","titleActionsOutlet","setTitleActionsOutlet","titleActionsWidth","footerHeight","setFooterHeight","surfaceContext","isMounted","hasTitle","title","titleEndPadding","surfaceStyle","style","presenceProps","onKeyDown","className","titleAction","DialogTitle","titleId","titleRef","outlet","heading","action","actionElement","stickyFooterClasses","footerRowClasses","DialogFooter","outsideContent","footer","setFooter","Dialog"],"sources":["../../../src/components/overlays/Dialog.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../lib/cn';\nimport {\n dialogContentClassNames,\n dialogFooterClassNames,\n dialogTitleClassNames,\n} from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { renderSlot, slotRendersContent, type Slot, type SlotObject } from '../../lib/slot';\nimport type {\n BackdropAppearance,\n ModalOpenChangeReason,\n ModalType,\n OpenChangeDetails,\n SurfaceSize,\n} from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useModalLayer } from '../../hooks/useModalLayer';\nimport { usePresence } from '../../hooks/usePresence';\nimport { Portal } from '../portal/Portal';\nimport {\n inertModalTrigger,\n ModalSurfaceContext,\n useBackdropPress,\n useModalClosePart,\n useModalDismiss,\n useModalOpener,\n useModalOpenState,\n useModalTitle,\n useModalTrigger,\n useModalTriggerPart,\n useModalTriggerSession,\n useOpenInsideWarning,\n useRaiseOnOpen,\n useRequiredContext,\n useTitleRegistry,\n useUnnamedModalWarning,\n type ModalRequestOpen,\n type ModalSurfaceContextValue,\n type ModalTrigger,\n} from './Dialog.shared';\nimport { ModalBackdrop, ModalCloseButton } from './Dialog.slots';\nimport { getTabbableThrough, usePopoverTabOrder } from './Popover.shared';\n\n/**\n * Why a {@link Dialog} asks to open or close: `trigger` (`Dialog.Trigger`), `close`\n * (`Dialog.Close`), `close-button` (the built-in Close button), `escape`, `outside-press` (the\n * backdrop). The shared `ModalOpenChangeReason`.\n */\nexport type DialogOpenChangeReason = ModalOpenChangeReason;\n\n/** The second argument of a {@link Dialog}'s `onOpenChange`: the reason and the DOM event. */\nexport type DialogOpenChangeDetails = OpenChangeDetails<DialogOpenChangeReason>;\n\n/**\n * How a {@link Dialog} relates to the page: `modal`, `alert` or `non-modal` (the shared\n * `ModalType`; `DrawerModalType` is the same type).\n */\nexport type DialogModalType = ModalType;\n\n/**\n * The width cap of a {@link Dialog}'s surface: `small` 400px, `medium` 600px, `large` 940px, or\n * `full`, the whole viewport (the shared `SurfaceSize`; `DrawerSize` is the same type).\n */\nexport type DialogSize = SurfaceSize;\n\n/** Properties for the Dialog component. */\nexport interface DialogProps {\n /**\n * Controlled open state of the dialog. The surface renders only in the browser: an open dialog\n * is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Default open state for uncontrolled usage. The surface renders only in the browser: a dialog\n * open by default is closed in the server HTML and opens once it has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the new open state when it changes. `details.reason` tells how — `trigger`,\n * `close` (a `.Close` part), `close-button` (the built-in Close button), `escape` or\n * `outside-press` (the backdrop) — so a controlled dialog can refuse only some ways of closing\n * (for example keep a form with unsaved changes open on `outside-press`); `details.event` is the\n * DOM event behind the request. WaveUI always passes `details`; it is typed optional until 1.0\n * so that code which calls this prop itself keeps compiling.\n *\n * Fires only when the value changes; a controlled dialog stays as it is until the parent updates\n * `open`.\n */\n onOpenChange?: (open: boolean, details?: DialogOpenChangeDetails) => void;\n /**\n * `modal`: the page behind is `inert` and does not scroll; a backdrop press, Escape, the Close\n * button and `Dialog.Close` close it. `alert`: a confirmation that needs an answer —\n * `role=\"alertdialog\"`, and a backdrop press does not close it (Escape still does). `non-modal`:\n * the page stays usable — no backdrop, no focus trap, nothing inert, the page scrolls; Tab and\n * Shift+Tab leave the dialog in the page's order right after the element that opened it, Escape\n * closes it while focus is inside it, presses on the page never close it, and focus returns to\n * the opener only when it was inside the dialog. A non-modal dialog covers the page under it\n * while Tab still reaches that page: keep the controls the user works with outside it, or use\n * `modal` (with `size=\"full\"` it covers everything, and a development warning says so). Every\n * type moves focus to the first focusable element on open (a title action, else the built-in\n * Close button); give another element `autoFocus` to start there (an alert dialog's least\n * destructive action). `Dialog.Trigger` toggles the dialog. Fluent's `modalType`.\n * @default 'modal'\n */\n modalType?: DialogModalType;\n /**\n * Where focus goes when the dialog closes, if it can take focus. Otherwise focus returns to the\n * element that had focus when the dialog opened, then to the trigger, then to an element next to\n * where that opener was (the next row's action after a confirm dialog deleted the row). Use it to\n * send focus somewhere else.\n */\n finalFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * Removes `Dialog.Content` (the surface and everything in it) when the dialog closes. `false`\n * keeps it mounted while closed, `hidden` and `inert`, so a form inside keeps what was typed and\n * the components inside keep their state; the surface then mounts with the Dialog, closed (in\n * the browser only, as an open one), and an `autoFocus` inside it never applies (each open\n * focuses the first focusable element). A popup opened inside that is still open when the\n * dialog closes stays open over the page (a development warning says so): close it first.\n * Fluent's `unmountOnClose`.\n * @default true\n */\n unmountOnClose?: boolean;\n /** `Dialog.Trigger` and `Dialog.Content`. */\n children: React.ReactNode;\n}\n\n/** Properties for the DialogContent sub-component. */\nexport interface DialogContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /**\n * Title rendered as the dialog's heading; it names the dialog (`aria-labelledby`). Without it,\n * render a `Dialog.Title` or pass `aria-label`/`aria-labelledby`. A title that renders nothing\n * (`''`, `[]`, `true`) counts as none.\n */\n title?: React.ReactNode;\n /**\n * Width cap: 400px (`small`), 600px (`medium`) or 940px (`large`), never wider than the viewport\n * (a 1rem margin). `full` covers the viewport: no margin, radius or border, the viewport's\n * dynamic height, and the safe-area insets as padding (with `viewport-fit=cover`); the body\n * scrolls under the sticky `Dialog.Footer`. Rendered as `data-size`. Fluent has no size. For\n * another width, put a width cap in `className` (it replaces the size's).\n * @default 'medium'\n */\n size?: DialogSize;\n /**\n * The backdrop of a modal or alert dialog: a `div` behind the dialog, `aria-hidden`. Shorthand\n * content renders inside it; a slot object's `className` (merged last), `style`, data\n * attributes, `ref` and handlers go to it, and its `appearance` (`'dimmed'` or `'transparent'`)\n * overrides the automatic one: while another modal Dialog or Drawer is open below this one the\n * backdrop is transparent, so the page is dimmed once. `null` renders no backdrop (the page stays\n * inert, and a press outside still closes a modal dialog); a boolean is no slot. Ignored with\n * `modalType=\"non-modal\"` (a development warning says so). Fluent's `backdrop`.\n */\n backdrop?: Slot<'div'> | (SlotObject<'div'> & { appearance?: BackdropAppearance });\n /**\n * Content of the built-in Close button (the dismiss glyph by default). It renders inside the\n * button, decorative (`aria-hidden`), so the button keeps the name `closeLabel`; a slot object's\n * `aria-label`, `aria-labelledby` or `title` names it instead, and its handlers run before the\n * close (`preventDefault()` keeps the dialog open). `null` hides the button (Escape and\n * `Dialog.Close` still close); a boolean is no slot, so `closeButton={cond && <MyIcon />}` keeps\n * the default; content that renders nothing keeps the default glyph. A `<button>` or Wave\n * `Button` passed here is merged into the built-in button, never nested (a development warning\n * says so): its props apply, its text label (`<button>Done</button>`) names the button instead\n * of `closeLabel`, and a Button's `icon`, `iconPosition` and `disabledFocusable` apply while\n * `appearance` and `size` are ignored. Fluent's `DialogTitle` `action` holds Fluent's close\n * button; WaveUI renders its own.\n */\n closeButton?: Slot<'span'>;\n /**\n * Header buttons for the `title` prop form, placed before the built-in Close button in the\n * dialog's top end corner, in DOM and Tab order (an expand toggle, a menu). The title's end\n * padding makes room for them. Interactive: name icon-only buttons. Renders nothing when empty.\n * See also `Dialog.Title`'s `action`. Fluent's `DialogTitle` `action`, for the `title` prop\n * form.\n */\n titleAction?: Slot<'span'>;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language. A text label of a button merged into `closeButton` names it instead.\n * @default 'Close'\n */\n closeLabel?: string;\n /** Content rendered inside the dialog body (put `Dialog.Footer` here as well). */\n children: React.ReactNode;\n /** Ref to the dialog surface (`role=\"dialog\"`, or `alertdialog` with `modalType=\"alert\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the DialogFooter sub-component. */\nexport interface DialogFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Footer content, typically action buttons (wrap closing buttons in `Dialog.Close`). */\n children: React.ReactNode;\n /** Ref to the footer element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the DialogTitle sub-component. */\nexport interface DialogTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /** The title; any content. */\n children: React.ReactNode;\n /**\n * Header buttons for this title, placed before the built-in Close button in the dialog's top end\n * corner (after `Dialog.Content`'s `titleAction`), not inside the heading, so they never become\n * part of the dialog's name. Outside `Dialog.Content` (in a Drawer) they render right after the\n * heading. Interactive: name icon-only buttons. Renders nothing when empty. Fluent's\n * `DialogTitle` `action`; unlike Fluent's, it is never filled by default (the Close button is\n * the Content's).\n */\n action?: Slot<'span'>;\n /** Ref to the heading element. */\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\n/** Props a `Dialog.Trigger` puts on its element (and passes to a render-prop child). */\nexport interface DialogTriggerRenderProps extends React.HTMLAttributes<HTMLElement> {\n 'aria-haspopup': 'dialog';\n 'aria-expanded': boolean;\n /** The dialog surface's id, while the dialog is open. */\n 'aria-controls'?: string;\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DialogTrigger sub-component. */\nexport interface DialogTriggerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that opens and closes the dialog. A single element receives the trigger props\n * (merged with its own: handlers composed, classes joined, its own `id` kept); a function\n * receives them.\n */\n children: React.ReactNode | ((props: DialogTriggerRenderProps) => React.ReactNode);\n /**\n * `false` renders the 0.4 wrapper `<span>` around the children instead of merging the trigger\n * props onto the child. The span carries the click handler; `aria-haspopup`, `aria-expanded`\n * and `aria-controls` go to the first element in the tab order inside it.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Props a `Dialog.Close` puts on its element (and passes to a render-prop child). */\nexport interface DialogCloseRenderProps extends React.HTMLAttributes<HTMLElement> {\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DialogClose sub-component. */\nexport interface DialogCloseProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that closes the dialog, typically a footer button. A single element receives an\n * `onClick` composed with its own (its handler runs first; `preventDefault()` keeps the dialog\n * open); a function receives the props.\n */\n children: React.ReactNode | ((props: DialogCloseRenderProps) => React.ReactNode);\n /** `false` renders a wrapper `<span>` that closes the dialog on click. @default true */\n asChild?: boolean;\n /** Ref to the close element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\ninterface DialogContextValue {\n open: boolean;\n /** Asks the root to open or close, with the reason and event for `onOpenChange`. */\n requestOpen: ModalRequestOpen;\n /** The resolved `modalType`. */\n modalType: DialogModalType;\n /** The trigger element (`attach`) and the focus-restore target resolved from it (`focusRef`). */\n trigger: ModalTrigger;\n finalFocusRef: React.RefObject<HTMLElement | null> | undefined;\n /** The resolved `unmountOnClose`: `false` keeps `Dialog.Content` mounted while closed. */\n unmountOnClose: boolean;\n /** The id of the open dialog surface (for the trigger's `aria-controls`), or `undefined`. */\n contentId: string | undefined;\n /** Registers the surface's id while it is mounted; returns the unregister function. */\n registerContentId: (id: string) => () => void;\n}\n\nconst DialogContext = React.createContext<DialogContextValue | null>(null);\nDialogContext.displayName = 'DialogContext';\n\nconst inertDialogContext: DialogContextValue = {\n open: false,\n requestOpen: () => {},\n modalType: 'modal',\n trigger: inertModalTrigger,\n finalFocusRef: undefined,\n unmountOnClose: true,\n contentId: undefined,\n registerContentId: () => () => {},\n};\n\nfunction useDialogContext(componentName: string): DialogContextValue {\n return useRequiredContext(DialogContext, componentName, 'Dialog', () => inertDialogContext);\n}\n\n// The root of `Dialog` (documented on the export below). A const arrow (like DrawerRoot): its type\n// can be named in consumers' declaration files, e.g. a story's `satisfies Meta<typeof Dialog>` (a\n// function declaration's `typeof` cannot, TS4023).\nconst DialogRoot = ({\n open,\n defaultOpen,\n onOpenChange,\n modalType = 'modal',\n finalFocusRef,\n unmountOnClose = true,\n children,\n}: DialogProps) => {\n const [openState, requestOpen] = useModalOpenState(open, defaultOpen, onOpenChange);\n // The surface lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the dialog reports itself closed, so the trigger's aria-expanded never\n // describes a dialog that is not there.\n const isClient = useIsClient();\n const isOpen = openState && isClient;\n const trigger = useModalTrigger();\n // After Dialog.Content's focus restore (a child's layout effects run first), start the trigger\n // session, or end it and forget the trigger that opened it.\n useModalTriggerSession(trigger, isOpen);\n const [contentId, setContentId] = React.useState<string | undefined>(undefined);\n const registerContentId = React.useCallback((id: string) => {\n setContentId(id);\n return () => setContentId((current) => (current === id ? undefined : current));\n }, []);\n\n const context = React.useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n requestOpen,\n modalType,\n trigger,\n finalFocusRef,\n unmountOnClose,\n contentId,\n registerContentId,\n }),\n [\n isOpen,\n requestOpen,\n modalType,\n trigger,\n finalFocusRef,\n unmountOnClose,\n contentId,\n registerContentId,\n ],\n );\n\n return <DialogContext.Provider value={context}>{children}</DialogContext.Provider>;\n};\nDialogRoot.displayName = 'Dialog';\n\n/**\n * Opens and closes the dialog: a click while it is open asks it to close (reason `trigger`). Only a\n * non-modal dialog's trigger, or a trigger rendered inside the dialog's own content, can receive\n * one (a modal dialog makes the page inert). Fluent's `DialogTrigger` never toggles (outside the\n * surface it only opens, inside it only closes); this trigger always does. Puts\n * `aria-haspopup=\"dialog\"`, `aria-expanded`, `aria-controls` (while open), a click handler and a\n * ref on its single child (no wrapper element), or passes them to a render-prop child. A custom\n * child component must forward `ref` and spread its props; one that does not is wrapped in a\n * `<span>` automatically (with a development warning), the span that `asChild={false}` renders.\n * Focus returns to the trigger when the dialog closes (with several triggers, to the one that\n * opened it). On the span, the state ARIA goes to the first element in the tab order inside it,\n * and focus returns to that element (to the span when you made it the trigger with a `role` such\n * as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n */\nexport const DialogTrigger = (props: DialogTriggerProps) => {\n const { open, requestOpen, trigger, contentId } = useDialogContext('Dialog.Trigger');\n return useModalTriggerPart<DialogTriggerRenderProps>(\n { open, requestOpen, trigger, controlsId: contentId },\n props,\n 'Dialog.Trigger',\n );\n};\nDialogTrigger.displayName = 'DialogTrigger';\n\n/**\n * Closes the dialog: composes a click handler onto its single child (its own `onClick` runs first;\n * calling `preventDefault()` there keeps the dialog open), or passes it to a render-prop child.\n *\n * @example\n * <Dialog.Close><Button appearance=\"subtle\">Cancel</Button></Dialog.Close>\n */\nexport const DialogClose = (props: DialogCloseProps) => {\n const { requestOpen } = useDialogContext('Dialog.Close');\n return useModalClosePart<DialogCloseRenderProps>(requestOpen, props, 'Dialog.Close');\n};\nDialogClose.displayName = 'DialogClose';\n\n/**\n * The surface's width cap per size. `full` lifts the caps, the margin, the radius and the border,\n * takes the viewport's dynamic height and pads the safe-area insets (`max()` keeps the 24px\n * padding where there is no inset, and never adds the two). The side insets are physical (the\n * left inset pads the left side in either direction), so the side padding is too: one class per\n * side, with no direction override that a consumer's padding class would leave behind.\n */\nconst sizeClasses: Record<DialogSize, string> = {\n small: 'max-w-[400px]',\n medium: 'max-w-[600px]',\n large: 'max-w-[940px]',\n full: 'm-0 h-dvh max-h-none max-w-none rounded-none border-0 pt-[max(1.5rem,env(safe-area-inset-top))] pb-[max(1.5rem,env(safe-area-inset-bottom))] pl-[max(1.5rem,env(safe-area-inset-left))] pr-[max(1.5rem,env(safe-area-inset-right))]', // wave-allow-physical: the safe-area insets are physical sides\n};\n\n/** The title-actions area of a `full` dialog moves by the safe-area insets, as the padding does. */\nconst fullTitleActionsClasses =\n 'top-[max(1rem,env(safe-area-inset-top))] end-[max(1rem,env(safe-area-inset-right))] wave-rtl:end-[max(1rem,env(safe-area-inset-left))]';\n\n/** The gap (px) between the titles' text and the title-actions area. */\nconst TITLE_ACTIONS_GAP = 8;\n\nconst BACKDROP_IGNORED_WARNING_KEY = 'Dialog.Content:backdrop-ignored';\nconst BACKDROP_IGNORED_WARNING =\n 'Dialog.Content: `backdrop` is ignored with `modalType=\"non-modal\"`: a non-modal dialog has no backdrop, so the page behind it stays usable.';\n\nconst NON_MODAL_FULL_WARNING_KEY = 'Dialog.Content:non-modal-full';\nconst NON_MODAL_FULL_WARNING =\n 'Dialog.Content: `size=\"full\"` with `modalType=\"non-modal\"` covers the whole page while leaving it usable, so Tab reaches controls hidden behind the dialog. Use `modalType=\"modal\"`, or a smaller size with the page\\'s controls kept clear of it.';\n\n/**\n * The width (px) of the title-actions area, measured with a `ResizeObserver` (`null` until the\n * first measurement, and without `ResizeObserver`). The observer's first callback arrives before\n * the next paint.\n */\nfunction useTitleActionsWidth(area: HTMLElement | null): number | null {\n const [width, setWidth] = React.useState<number | null>(null);\n React.useLayoutEffect(() => {\n if (!area || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n if (!entry) return;\n setWidth(entry.borderBoxSize?.[0]?.inlineSize ?? area.offsetWidth);\n });\n observer.observe(area, { box: 'border-box' });\n return () => {\n observer.disconnect();\n setWidth(null);\n };\n }, [area]);\n return width;\n}\n\n/**\n * The dialog surface, rendered in a portal (inheriting the WaveProvider theme) while the dialog is\n * open, and kept there while it is closed, `hidden` and `inert`, when the Dialog has\n * `unmountOnClose={false}`: the backdrop, and the surface centred in the positioner (the\n * backdrop's sibling) with the title, the title-actions area (title actions, then the Close\n * button) and a scrolling body. It takes the full width up to its `size` and never exceeds the\n * viewport (the body scrolls, also sideways for content wider than the dialog); `size=\"full\"`\n * fills the viewport. Its 1rem gap to the viewport edges is its own margin, so a margin in\n * `className` replaces the gap: with the width and height caps lifted as well and its height set\n * to the viewport's, it fills the viewport. It is `role=\"dialog\"`, or `role=\"alertdialog\"` when the\n * Dialog has `modalType=\"alert\"` (a `role` you pass wins), and carries `data-modal-type` and\n * `data-size` with the resolved values. A non-modal dialog has no backdrop: the positioner only\n * centres the surface and lets presses through to the page. The titles' end padding follows the\n * width of the title-actions area (`--wave-dialog-title-end-padding`, 2rem until it is measured).\n *\n * It mounts through the presence core: the backdrop, the positioner and the surface render\n * `data-presence` (`entered` while open, `exited` while kept closed; `entering` and `exiting`\n * only while a motion of yours runs on the surface), and the backdrop and the positioner are\n * `inert` while exiting and `hidden` and `inert` while kept closed. No motion ships: animate the\n * surface with `data-[presence=…]:` classes in `className` (an enter's start as\n * `data-[presence=entering]:starting:`, each with a `motion-reduce:` counterpart); a closed\n * surface waits for that motion before it unmounts or hides, while focus, the trap and the\n * isolation follow the open state at once.\n */\nexport const DialogContent = ({\n title,\n size = 'medium',\n backdrop,\n closeButton,\n titleAction,\n closeLabel = 'Close',\n children,\n className,\n style,\n id,\n onKeyDown,\n ref,\n ...rest\n}: DialogContentProps) => {\n const {\n open,\n requestOpen,\n modalType,\n trigger,\n finalFocusRef,\n unmountOnClose,\n registerContentId,\n } = useDialogContext('Dialog.Content');\n // Every surface mounts through the presence core (D5, D103), with no motion of its own: kept\n // mounted while closed with `unmountOnClose={false}`, else removed once it has exited.\n const {\n isMounted,\n ref: presenceRef,\n presenceProps,\n } = usePresence(open, { unmountOnExit: unmountOnClose });\n const keptMounted = !unmountOnClose;\n const generatedId = useId('wave-dialog');\n const contentId = id ?? generatedId;\n const propTitleId = useId('wave-dialog-title');\n const titles = useTitleRegistry();\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const attachSurface = React.useCallback((node: HTMLDivElement | null) => {\n surfaceRef.current = node;\n setSurface(node);\n }, []);\n // Reports the surface's id to the root (the trigger's `aria-controls`) while it is mounted. A new\n // `id` makes a new callback, which useMergedRefs re-attaches after the commit (re-registering).\n const registerId = React.useCallback(\n (node: HTMLDivElement | null) => (node ? registerContentId(contentId) : undefined),\n [registerContentId, contentId],\n );\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, attachSurface, registerId, presenceRef);\n // The portal wrapper: a kept-mounted surface moves to the top of its stack when it opens\n // (before the layer registers and the trap moves focus in).\n const portalRef = React.useRef<HTMLDivElement | null>(null);\n useRaiseOnOpen(open, keptMounted, portalRef);\n\n // An alert dialog needs an answer: a backdrop press does not close it (Escape still does;\n // useModalLayer registers its layer without outside presses).\n const backdropPress = useBackdropPress(surfaceRef, modalType !== 'alert');\n const onDismiss = useModalDismiss(requestOpen, 'Dialog', backdropPress.afterOutsidePress);\n const layer = useModalLayer({\n open,\n modalType,\n onDismiss,\n refs: [surfaceRef],\n container: surface,\n triggerRef: trigger.focusRef,\n finalFocusRef,\n });\n // A non-modal dialog keeps its place in the page's keyboard order right after its opener. The\n // opener is captured whenever the dialog opens, so a modal dialog that turns non-modal while open\n // (focus inside it by then) still knows it.\n const nonModal = modalType === 'non-modal';\n const opener = useModalOpener(open, trigger, surface);\n const onTabOrderKeyDown = usePopoverTabOrder({\n enabled: open && nonModal,\n surface,\n anchorRef: opener,\n getPreviousStop: getTabbableThrough,\n });\n useUnnamedModalWarning(open ? surface : null, titles.hasTitle, 'Dialog.Content', 'Dialog.Title');\n useOpenInsideWarning(open, keptMounted, layer.layerId, 'Dialog');\n\n // A non-modal dialog has no backdrop: a given slot (not undefined, null or a boolean) is ignored.\n const backdropIgnored =\n nonModal && backdrop !== undefined && backdrop !== null && typeof backdrop !== 'boolean';\n React.useEffect(() => {\n if (backdropIgnored) warnOnce(BACKDROP_IGNORED_WARNING_KEY, BACKDROP_IGNORED_WARNING);\n }, [backdropIgnored]);\n // A full non-modal dialog covers the page it leaves usable (D87.8).\n const coversUsablePage = open && nonModal && size === 'full';\n React.useEffect(() => {\n if (coversUsablePage) warnOnce(NON_MODAL_FULL_WARNING_KEY, NON_MODAL_FULL_WARNING);\n }, [coversUsablePage]);\n\n // The title-actions area (held in state) and the outlet `Dialog.Title` actions portal into. Both\n // attach in the commit that mounts the surface, so a title's action is in the DOM in the next\n // commit, the one in which the focus trap starts (it waits for the surface held in state). The\n // area is measured only while the dialog is open (a kept-mounted closed one measures nothing).\n const [titleActionsArea, setTitleActionsArea] = React.useState<HTMLDivElement | null>(null);\n const [titleActionsOutlet, setTitleActionsOutlet] = React.useState<HTMLSpanElement | null>(null);\n const titleActionsWidth = useTitleActionsWidth(open ? titleActionsArea : null);\n\n // The height of the sticky Dialog.Footer, reserved as the body's scroll padding.\n const [footerHeight, setFooterHeight] = React.useState<number | null>(null);\n const surfaceContext = React.useMemo<ModalSurfaceContextValue>(\n () => ({ ...titles.context, setFooterHeight, titleActionsOutlet }),\n [titles.context, titleActionsOutlet],\n );\n\n if (!isMounted) return null;\n\n const hasTitle = slotRendersContent(title);\n // The titles' end padding: the area's width and a gap while it has a size, none while it is\n // empty; unset (the 2rem fallback) until it is measured.\n const titleEndPadding =\n titleActionsWidth === null\n ? undefined\n : titleActionsWidth > 0\n ? `${titleActionsWidth + TITLE_ACTIONS_GAP}px`\n : '0px';\n const surfaceStyle =\n titleEndPadding === undefined\n ? style\n : ({ '--wave-dialog-title-end-padding': titleEndPadding, ...style } as React.CSSProperties);\n\n return (\n <Portal ref={portalRef} layerId={layer.layerId}>\n {/* Each top-level element carries the presence attributes (D7, D103): hidden and inert while\n kept closed, so a closed dialog leaves no backdrop over the page. */}\n {!nonModal && (\n <ModalBackdrop\n backdrop={backdrop}\n className={dialogContentClassNames.backdrop}\n layerId={layer.layerId}\n open={open}\n onMouseDown={backdropPress.onMouseDown}\n presenceProps={presenceProps}\n />\n )}\n <div\n {...presenceProps}\n // Centres the surface and lets presses through to the backdrop (modal) or the page\n // (non-modal) around it.\n className={cn(\n dialogContentClassNames.positioner,\n 'pointer-events-none fixed inset-0 flex items-center justify-center',\n )}\n >\n <div\n ref={mergedRef}\n role={modalType === 'alert' ? 'alertdialog' : 'dialog'}\n id={contentId}\n aria-labelledby={hasTitle ? propTitleId : titles.titleId}\n tabIndex={-1}\n data-modal-type={modalType}\n data-size={size}\n {...rest}\n data-presence={presenceProps['data-presence']}\n style={surfaceStyle}\n onKeyDown={composeEventHandlers(onKeyDown, onTabOrderKeyDown)}\n className={cn(\n dialogContentClassNames.root,\n // The border marks the surface where the shadow cannot: in high contrast the page,\n // the backdrop and the surface are black, and forced colors drop shadows. The 1rem gap\n // to the viewport edges is the surface's own margin, not the positioner's padding, so\n // a margin in `className` replaces it and a full-screen dialog can reach the edges.\n // Its minimum width is zero, so content wider than the room inside the gap scrolls in\n // the body instead of pushing the surface over the gap.\n 'pointer-events-auto relative m-4 flex min-w-0 max-h-[calc(100dvh-2rem)] w-full flex-col rounded-lg border border-border bg-background p-6 text-foreground shadow-64',\n sizeClasses[size],\n className,\n )}\n >\n <ModalSurfaceContext.Provider value={surfaceContext}>\n {hasTitle && (\n <h2\n id={propTitleId}\n className={cn(\n dialogTitleClassNames.root,\n 'pe-[var(--wave-dialog-title-end-padding,2rem)] text-subtitle-1 font-semibold',\n )}\n >\n {title}\n </h2>\n )}\n <div\n ref={setTitleActionsArea}\n className={cn(\n dialogContentClassNames.titleActions,\n 'absolute end-4 top-4 flex items-start gap-1',\n size === 'full' && fullTitleActionsClasses,\n )}\n >\n {slotRendersContent(titleAction)\n ? renderSlot(\n titleAction,\n 'span',\n cn(dialogContentClassNames.titleAction, 'inline-flex items-center gap-1'),\n )\n : null}\n {/* Each Dialog.Title action portals here, in mount order. */}\n <span ref={setTitleActionsOutlet} className=\"contents\" />\n <ModalCloseButton\n componentName=\"Dialog.Content\"\n closeButton={closeButton}\n closeLabel={closeLabel}\n onClose={(event) => requestOpen(false, { reason: 'close-button', event })}\n className={cn(dialogContentClassNames.closeButton, 'text-muted-foreground')}\n />\n </div>\n <div\n // The scroll padding keeps a focused field above the sticky footer (WCAG 2.4.11).\n className={cn(\n dialogContentClassNames.body,\n '-mx-1 mt-1 min-h-0 flex-1 overflow-y-auto scroll-pb-(--wave-dialog-footer-height) p-1 text-body-1',\n )}\n style={\n footerHeight === null\n ? undefined\n : ({ '--wave-dialog-footer-height': `${footerHeight}px` } as React.CSSProperties)\n }\n >\n {children}\n </div>\n </ModalSurfaceContext.Provider>\n </div>\n </div>\n </Portal>\n );\n};\nDialogContent.displayName = 'DialogContent';\n\n/**\n * A heading that names the dialog (`aria-labelledby`), for rich titles or custom layouts. Render it\n * inside `Dialog.Content` (instead of the `title` prop). Like the `title` heading, its end padding\n * follows the width of the dialog's title-actions area (2rem until it is measured), so a long first\n * line stays clear of the title actions and the Close button; a `className` padding wins. Its\n * `action` renders in that area, before the Close button, and never inside the heading.\n */\nexport const DialogTitle = ({\n id,\n action,\n className,\n children,\n ref,\n ...rest\n}: DialogTitleProps) => {\n const { id: titleId, ref: titleRef } = useModalTitle('Dialog.Title', 'Dialog.Content', id, ref);\n // `undefined` outside Dialog.Content (a Drawer), `null` until the content's outlet is attached.\n const outlet = React.useContext(ModalSurfaceContext)?.titleActionsOutlet;\n const heading = (\n <h2\n {...rest}\n id={titleId}\n ref={titleRef}\n className={cn(\n dialogTitleClassNames.root,\n 'pe-[var(--wave-dialog-title-end-padding,2rem)] text-subtitle-1 font-semibold text-foreground',\n className,\n )}\n >\n {children}\n </h2>\n );\n if (!slotRendersContent(action)) return heading;\n const actionElement = renderSlot(\n action,\n 'span',\n cn(dialogTitleClassNames.action, 'inline-flex items-center gap-1'),\n );\n return (\n <>\n {heading}\n {outlet === undefined ? actionElement : outlet && createPortal(actionElement, outlet)}\n </>\n );\n};\nDialogTitle.displayName = 'DialogTitle';\n\n/**\n * `Dialog.Footer` inside `Dialog.Content`. The body is `p-1`, and sticky positioning stops at its\n * padding edge: `-bottom-1` with `-mb-1 pb-2` covers the body's bottom padding, `-mx-1 px-1` its\n * focus-ring inset, and `pt-3` separates the actions from the content scrolling under them.\n */\nconst stickyFooterClasses =\n 'sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-background px-1 pb-2 pt-3';\n\n/**\n * `Dialog.Footer` where no body reserves its height as scroll padding (a Drawer's body): a plain\n * action row, which never covers a focused field.\n */\nconst footerRowClasses = 'mt-6 flex justify-end gap-2';\n\n/**\n * Action row at the end of the dialog body. It stays where you render it in the DOM and sticks to\n * the bottom of the body while long content scrolls under it (with an opaque background); the body\n * reserves its height as scroll padding, so a focused field is never hidden behind it. Inside a\n * `<form>` that wraps the fields and the footer it sticks too: make it the form's last child.\n * Render it inside `Dialog.Content`: outside it, it would stay on the page while the dialog is\n * closed (a development warning says so). Inside a `Drawer`, whose body reserves no footer height,\n * it does not stick: it is an action row at the end of the content. Render one `Dialog.Footer` per\n * `Dialog.Content`: with two at once, the body reserves the height of the one measured last, and\n * unmounting either clears it until the other resizes (swapping one footer for another is fine).\n */\nexport const DialogFooter = ({ children, className, ref, ...rest }: DialogFooterProps) => {\n const surfaceContext = React.useContext(ModalSurfaceContext);\n const outsideContent = surfaceContext === null;\n const setFooterHeight = surfaceContext?.setFooterHeight;\n const [footer, setFooter] = React.useState<HTMLDivElement | null>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, setFooter);\n\n React.useEffect(() => {\n if (!outsideContent) return;\n warnOnce(\n 'Dialog.Footer:outside-content',\n 'Dialog.Footer must be rendered inside Dialog.Content. Outside it, the footer stays on the page while the dialog is closed.',\n );\n }, [outsideContent]);\n\n // Reports the footer's border-box height to Dialog.Content. The observer's first callback,\n // delivered before the next paint, supplies the first value; without ResizeObserver the body\n // keeps its default scroll padding.\n React.useLayoutEffect(() => {\n if (!footer || !setFooterHeight || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver((entries) => {\n const entry = entries[entries.length - 1];\n if (!entry) return;\n setFooterHeight(entry.borderBoxSize?.[0]?.blockSize ?? footer.offsetHeight);\n });\n observer.observe(footer, { box: 'border-box' });\n return () => {\n observer.disconnect();\n setFooterHeight(null);\n };\n }, [footer, setFooterHeight]);\n\n return (\n <div\n ref={mergedRef}\n {...rest}\n // Sticky only where the surface reserves the footer's height (Dialog.Content).\n className={cn(\n dialogFooterClassNames.root,\n setFooterHeight ? stickyFooterClasses : footerRowClasses,\n className,\n )}\n >\n {children}\n </div>\n );\n};\nDialogFooter.displayName = 'DialogFooter';\n\n/**\n * A dialog (Fluent UI v2 style), modal by default: `Dialog` holds the open state; `Dialog.Trigger`\n * opens and closes it and `Dialog.Content` renders the surface in a portal while open (and, with\n * `unmountOnClose={false}`, keeps it there while closed, `hidden` and `inert`).\n *\n * - **Modal**: focus moves into the dialog and Tab stays inside it (toasts included), the rest of\n * the page is `inert` (instead of `aria-modal`, so toasts and live regions stay announced), and\n * the page does not scroll.\n * - **Closing**: Escape (only the topmost layer: a popup opened inside closes first), a click on\n * the backdrop (a drag that starts inside does not close it), the Close button and `Dialog.Close`.\n * `onOpenChange` gets the reason as its second argument (`details.reason`), so a controlled\n * dialog can refuse some of them. A backdrop press blurs the focused field before the dialog\n * closes, so a typed value is committed as with the Close button; when a controlled dialog\n * refuses the press, the field gets focus back (an alert dialog's press leaves focus where it\n * was). Focus returns to the first of these that can take focus: `finalFocusRef`, the element\n * that had focus when the dialog opened, the trigger, an element next to where that opener was.\n * - **Alert dialogs**: `modalType=\"alert\"` renders `role=\"alertdialog\"` for a confirmation that\n * needs an answer; a backdrop press does not close it.\n * - **Non-modal dialogs**: `modalType=\"non-modal\"` leaves the page usable (no backdrop, no focus\n * trap, nothing inert, the page scrolls). Focus moves in on open; Tab and Shift+Tab leave the\n * dialog in the page's order right after the element that opened it; Escape closes it only while\n * focus is inside it; presses on the page never close it; focus returns to the opener only from\n * inside. Keep the page's controls clear of the dialog, which covers the page under it.\n * - **Size**: `Dialog.Content` `size` caps the width at 400px (`small`), 600px (`medium`, the\n * default) or 940px (`large`); `full` covers the viewport and pads its safe-area insets.\n * - **Backdrop**: the backdrop is the surface's sibling and a slot (`backdrop`: `null` removes it,\n * `appearance` picks `dimmed` or `transparent`). A modal opened over another modal dims the page\n * once: its backdrop is transparent while the lower one is open.\n * - **Close button and title actions**: `closeButton` sets the built-in Close button's content, or\n * hides it (`null`); a button passed there is merged into it. `titleAction` and `Dialog.Title`'s\n * `action` place header buttons before the Close button in the top end corner, in DOM and Tab\n * order, and the titles' end padding makes room for them. Initial focus goes to the first\n * focusable element: a title action, else the Close button.\n * - **Footer**: `Dialog.Footer` sticks to the bottom of the scrolling body, and the body keeps a\n * focused field above it.\n * - **Kept mounted**: `unmountOnClose={false}` keeps the content mounted while the dialog is\n * closed, so a form keeps what was typed and the components inside keep their state; each open\n * focuses the first focusable element again (an `autoFocus` inside never applies), and a kept\n * dialog opened while another overlay is open stacks above it.\n * - **Presence**: the surface mounts through the presence core and renders `data-presence`; no\n * motion ships, and `data-[presence=…]:` classes on `Dialog.Content` animate it.\n * - **Naming**: give `Dialog.Content` a `title`, a `Dialog.Title`, or `aria-label`.\n *\n * The sub-components are also exported under flat names (`DialogTrigger`, `DialogContent`,\n * `DialogFooter`, `DialogTitle`, `DialogClose`) for React Server Components, which cannot use the\n * dotted form; dotted access (`Dialog.Content`) needs a client file.\n *\n * @example\n * <Dialog>\n * <Dialog.Trigger><Button>Delete</Button></Dialog.Trigger>\n * <Dialog.Content title=\"Delete file?\">\n * This cannot be undone.\n * <Dialog.Footer>\n * <Dialog.Close><Button appearance=\"subtle\">Cancel</Button></Dialog.Close>\n * <Button appearance=\"primary\" onClick={remove}>Delete</Button>\n * </Dialog.Footer>\n * </Dialog.Content>\n * </Dialog>\n */\nexport const Dialog = /* @__PURE__ */ Object.assign(DialogRoot, {\n Trigger: DialogTrigger,\n Content: DialogContent,\n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C,EAAM,gBAAgB,EAAE,EAAE,WAAayD,EAAO,YAAY,CAC5E,CAAC,EAED,OADA1D,EAAS,QAAQ0D,EAAQ,CAAE,IAAK,YAAa,CAAC,MACjC,CACX1D,EAAS,WAAW,EACpBmC,EAAgB,IAAI,CACtB,CACF,EAAG,CAACuB,EAAQvB,CAAe,CAAC,GAG1B,EAAAzE,EAAA,IAAA,CAAC,MAAD,CACE,IAAKsD,EACL,GAAIZ,EAEJ,UAAWpE,EAAAA,GACTS,EAAAA,uBAAuB,KACvB0F,EAAkBmB,EAAsBC,EACxCV,CACF,EAEC,UACE,CAAA,CAET,EACA,EAAa,YAAc,eA6D3B,IAAae,EAAyB,OAAO,OAAO5F,EAAY,CAC9D,QAASkB,EACT,QAASiB,EACT,OAAQqD,EACR,MAAOT,EACP,MAAO3D,CACT,CAAC"}
@@ -1,157 +1,222 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { warnOnce as t } from "../../lib/dev.mjs";
4
- import { slotRendersContent as n } from "../../lib/slot.mjs";
5
- import { dialogContentClassNames as r, dialogFooterClassNames as i, dialogTitleClassNames as a } from "../../lib/classNames.mjs";
6
- import { useId as o } from "../../hooks/useId.mjs";
7
- import { useMergedRefs as s } from "../../hooks/useMergedRefs.mjs";
8
- import { useIsClient as c } from "../../hooks/useIsClient.mjs";
9
- import { Portal as l } from "../portal/Portal.mjs";
10
- import { Button as u } from "../button/Button.mjs";
11
- import { DismissIcon as d } from "../../lib/icons.mjs";
12
- import { useModalLayer as f } from "../../hooks/useModalLayer.mjs";
13
- import { ModalSurfaceContext as p, inertModalTrigger as m, useBackdropPress as h, useModalClosePart as g, useModalDismiss as _, useModalOpenState as v, useModalTitle as y, useModalTrigger as b, useModalTriggerPart as x, useModalTriggerSession as S, useRequiredContext as C, useTitleRegistry as w, useUnnamedModalWarning as T } from "./Dialog.shared.mjs";
14
- import * as E from "react";
15
- import { jsx as D, jsxs as O } from "react/jsx-runtime";
4
+ import { renderSlot as n, slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
6
+ import { dialogContentClassNames as a, dialogFooterClassNames as o, dialogTitleClassNames as s } from "../../lib/classNames.mjs";
7
+ import { useId as c } from "../../hooks/useId.mjs";
8
+ import { useMergedRefs as l } from "../../hooks/useMergedRefs.mjs";
9
+ import { useIsClient as u } from "../../hooks/useIsClient.mjs";
10
+ import { usePresence as d } from "../../hooks/usePresence.mjs";
11
+ import { Portal as f } from "../portal/Portal.mjs";
12
+ import { getTabbableThrough as p, usePopoverTabOrder as m } from "./Popover.shared.mjs";
13
+ import { ModalSurfaceContext as h, inertModalTrigger as g, useBackdropPress as ee, useModalClosePart as _, useModalDismiss as te, useModalOpenState as v, useModalOpener as ne, useModalTitle as y, useModalTrigger as b, useModalTriggerPart as re, useModalTriggerSession as x, useOpenInsideWarning as ie, useRaiseOnOpen as ae, useRequiredContext as S, useTitleRegistry as oe, useUnnamedModalWarning as se } from "./Dialog.shared.mjs";
14
+ import { useModalLayer as ce } from "../../hooks/useModalLayer.mjs";
15
+ import { ModalBackdrop as le, ModalCloseButton as ue } from "./Dialog.slots.mjs";
16
+ import * as C from "react";
17
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
18
+ import { createPortal as D } from "react-dom";
16
19
  //#region src/components/overlays/Dialog.tsx
17
- var k = E.createContext(null);
18
- k.displayName = "DialogContext";
19
- var A = {
20
+ var O = C.createContext(null);
21
+ O.displayName = "DialogContext";
22
+ var k = {
20
23
  open: !1,
21
24
  requestOpen: () => {},
22
25
  modalType: "modal",
23
- trigger: m,
26
+ trigger: g,
24
27
  finalFocusRef: void 0,
28
+ unmountOnClose: !0,
25
29
  contentId: void 0,
26
30
  registerContentId: () => () => {}
27
31
  };
28
- function j(e) {
29
- return C(k, e, "Dialog", () => A);
32
+ function A(e) {
33
+ return S(O, e, "Dialog", () => k);
30
34
  }
31
- var M = ({ open: e, defaultOpen: t, onOpenChange: n, modalType: r = "modal", finalFocusRef: i, children: a }) => {
32
- let [o, s] = v(e, t, n), l = c(), u = o && l, d = b();
33
- S(d, u);
34
- let [f, p] = E.useState(void 0), m = E.useCallback((e) => (p(e), () => p((t) => t === e ? void 0 : t)), []), h = E.useMemo(() => ({
35
- open: u,
36
- requestOpen: s,
35
+ var j = ({ open: e, defaultOpen: t, onOpenChange: n, modalType: r = "modal", finalFocusRef: i, unmountOnClose: a = !0, children: o }) => {
36
+ let [s, c] = v(e, t, n), l = u(), d = s && l, f = b();
37
+ x(f, d);
38
+ let [p, m] = C.useState(void 0), h = C.useCallback((e) => (m(e), () => m((t) => t === e ? void 0 : t)), []), g = C.useMemo(() => ({
39
+ open: d,
40
+ requestOpen: c,
37
41
  modalType: r,
38
- trigger: d,
42
+ trigger: f,
39
43
  finalFocusRef: i,
40
- contentId: f,
41
- registerContentId: m
44
+ unmountOnClose: a,
45
+ contentId: p,
46
+ registerContentId: h
42
47
  }), [
43
- u,
44
- s,
45
- r,
46
48
  d,
47
- i,
49
+ c,
50
+ r,
48
51
  f,
49
- m
52
+ i,
53
+ a,
54
+ p,
55
+ h
50
56
  ]);
51
- return /* @__PURE__ */ D(k.Provider, {
52
- value: h,
53
- children: a
57
+ return /* @__PURE__ */ T(O.Provider, {
58
+ value: g,
59
+ children: o
54
60
  });
55
61
  };
56
- M.displayName = "Dialog";
57
- var N = (e) => {
58
- let { open: t, requestOpen: n, trigger: r, contentId: i } = j("Dialog.Trigger");
59
- return x({
62
+ j.displayName = "Dialog";
63
+ var M = (e) => {
64
+ let { open: t, requestOpen: n, trigger: r, contentId: i } = A("Dialog.Trigger");
65
+ return re({
60
66
  open: t,
61
67
  requestOpen: n,
62
68
  trigger: r,
63
69
  controlsId: i
64
70
  }, e, "Dialog.Trigger");
65
71
  };
66
- N.displayName = "DialogTrigger";
67
- var P = (e) => {
68
- let { requestOpen: t } = j("Dialog.Close");
69
- return g(t, e, "Dialog.Close");
72
+ M.displayName = "DialogTrigger";
73
+ var N = (e) => {
74
+ let { requestOpen: t } = A("Dialog.Close");
75
+ return _(t, e, "Dialog.Close");
70
76
  };
71
- P.displayName = "DialogClose";
72
- var F = {
77
+ N.displayName = "DialogClose";
78
+ var de = {
73
79
  small: "max-w-[400px]",
74
- medium: "max-w-[600px]"
75
- }, I = ({ title: t, size: i = "medium", closeLabel: c = "Close", children: m, className: g, id: v, ref: y, ...b }) => {
76
- let { open: x, requestOpen: S, modalType: C, trigger: k, finalFocusRef: A, registerContentId: M } = j("Dialog.Content"), N = o("wave-dialog"), P = v ?? N, I = o("wave-dialog-title"), L = w(), [R, z] = E.useState(null), B = E.useRef(null), V = E.useCallback((e) => {
77
- B.current = e, z(e);
78
- }, []), H = E.useCallback((e) => e ? M(P) : void 0, [M, P]), U = s(y, V, H), W = C !== "alert", G = h(B, W), K = _(S, "Dialog", G.afterOutsidePress), q = f({
79
- open: x,
80
- onDismiss: K,
81
- refs: [B],
82
- outsidePress: W,
83
- container: R,
84
- triggerRef: k.focusRef,
85
- finalFocusRef: A
80
+ medium: "max-w-[600px]",
81
+ large: "max-w-[940px]",
82
+ full: "m-0 h-dvh max-h-none max-w-none rounded-none border-0 pt-[max(1.5rem,env(safe-area-inset-top))] pb-[max(1.5rem,env(safe-area-inset-bottom))] pl-[max(1.5rem,env(safe-area-inset-left))] pr-[max(1.5rem,env(safe-area-inset-right))]"
83
+ }, fe = "top-[max(1rem,env(safe-area-inset-top))] end-[max(1rem,env(safe-area-inset-right))] wave-rtl:end-[max(1rem,env(safe-area-inset-left))]", pe = 8, me = "Dialog.Content:backdrop-ignored", he = "Dialog.Content: `backdrop` is ignored with `modalType=\"non-modal\"`: a non-modal dialog has no backdrop, so the page behind it stays usable.", ge = "Dialog.Content:non-modal-full", _e = "Dialog.Content: `size=\"full\"` with `modalType=\"non-modal\"` covers the whole page while leaving it usable, so Tab reaches controls hidden behind the dialog. Use `modalType=\"modal\"`, or a smaller size with the page's controls kept clear of it.";
84
+ function ve(e) {
85
+ let [t, n] = C.useState(null);
86
+ return C.useLayoutEffect(() => {
87
+ if (!e || typeof ResizeObserver > "u") return;
88
+ let t = new ResizeObserver((t) => {
89
+ let r = t[t.length - 1];
90
+ r && n(r.borderBoxSize?.[0]?.inlineSize ?? e.offsetWidth);
91
+ });
92
+ return t.observe(e, { box: "border-box" }), () => {
93
+ t.disconnect(), n(null);
94
+ };
95
+ }, [e]), t;
96
+ }
97
+ var P = ({ title: o, size: u = "medium", backdrop: g, closeButton: _, titleAction: v, closeLabel: y = "Close", children: b, className: re, style: x, id: S, onKeyDown: w, ref: D, ...O }) => {
98
+ let { open: k, requestOpen: j, modalType: M, trigger: N, finalFocusRef: P, unmountOnClose: F, registerContentId: I } = A("Dialog.Content"), { isMounted: L, ref: R, presenceProps: z } = d(k, { unmountOnExit: F }), B = !F, ye = c("wave-dialog"), V = S ?? ye, H = c("wave-dialog-title"), U = oe(), [W, be] = C.useState(null), G = C.useRef(null), xe = C.useCallback((e) => {
99
+ G.current = e, be(e);
100
+ }, []), Se = C.useCallback((e) => e ? I(V) : void 0, [I, V]), Ce = l(D, xe, Se, R), K = C.useRef(null);
101
+ ae(k, B, K);
102
+ let q = ee(G, M !== "alert"), we = te(j, "Dialog", q.afterOutsidePress), J = ce({
103
+ open: k,
104
+ modalType: M,
105
+ onDismiss: we,
106
+ refs: [G],
107
+ container: W,
108
+ triggerRef: N.focusRef,
109
+ finalFocusRef: P
110
+ }), Y = M === "non-modal", Te = ne(k, N, W), Ee = m({
111
+ enabled: k && Y,
112
+ surface: W,
113
+ anchorRef: Te,
114
+ getPreviousStop: p
86
115
  });
87
- T(x ? R : null, L.hasTitle, "Dialog.Content", "Dialog.Title");
88
- let [J, Y] = E.useState(null), X = E.useMemo(() => ({
89
- ...L.context,
90
- setFooterHeight: Y
91
- }), [L.context]);
92
- if (!x) return null;
93
- let Z = n(t);
94
- return /* @__PURE__ */ D(l, {
95
- layerId: q.layerId,
96
- children: /* @__PURE__ */ D("div", {
97
- className: e(r.backdrop, "fixed inset-0 flex items-center justify-center bg-backdrop"),
98
- onMouseDown: G.onMouseDown,
99
- children: /* @__PURE__ */ D("div", {
100
- ref: U,
101
- role: C === "alert" ? "alertdialog" : "dialog",
102
- id: P,
103
- "aria-labelledby": Z ? I : L.titleId,
116
+ se(k ? W : null, U.hasTitle, "Dialog.Content", "Dialog.Title"), ie(k, B, J.layerId, "Dialog");
117
+ let X = Y && g != null && typeof g != "boolean";
118
+ C.useEffect(() => {
119
+ X && t(me, he);
120
+ }, [X]);
121
+ let Z = k && Y && u === "full";
122
+ C.useEffect(() => {
123
+ Z && t(ge, _e);
124
+ }, [Z]);
125
+ let [De, Oe] = C.useState(null), [Q, ke] = C.useState(null), $ = ve(k ? De : null), [Ae, je] = C.useState(null), Me = C.useMemo(() => ({
126
+ ...U.context,
127
+ setFooterHeight: je,
128
+ titleActionsOutlet: Q
129
+ }), [U.context, Q]);
130
+ if (!L) return null;
131
+ let Ne = r(o), Pe = $ === null ? void 0 : $ > 0 ? `${$ + pe}px` : "0px", Fe = Pe === void 0 ? x : {
132
+ "--wave-dialog-title-end-padding": Pe,
133
+ ...x
134
+ };
135
+ return /* @__PURE__ */ E(f, {
136
+ ref: K,
137
+ layerId: J.layerId,
138
+ children: [!Y && /* @__PURE__ */ T(le, {
139
+ backdrop: g,
140
+ className: a.backdrop,
141
+ layerId: J.layerId,
142
+ open: k,
143
+ onMouseDown: q.onMouseDown,
144
+ presenceProps: z
145
+ }), /* @__PURE__ */ T("div", {
146
+ ...z,
147
+ className: e(a.positioner, "pointer-events-none fixed inset-0 flex items-center justify-center"),
148
+ children: /* @__PURE__ */ T("div", {
149
+ ref: Ce,
150
+ role: M === "alert" ? "alertdialog" : "dialog",
151
+ id: V,
152
+ "aria-labelledby": Ne ? H : U.titleId,
104
153
  tabIndex: -1,
105
- "data-modal-type": C,
106
- ...b,
107
- className: e(r.root, "relative m-4 flex min-w-0 max-h-[calc(100dvh-2rem)] w-full flex-col rounded-lg border border-border bg-background p-6 text-foreground shadow-64", F[i], g),
108
- children: /* @__PURE__ */ O(p.Provider, {
109
- value: X,
154
+ "data-modal-type": M,
155
+ "data-size": u,
156
+ ...O,
157
+ "data-presence": z["data-presence"],
158
+ style: Fe,
159
+ onKeyDown: i(w, Ee),
160
+ className: e(a.root, "pointer-events-auto relative m-4 flex min-w-0 max-h-[calc(100dvh-2rem)] w-full flex-col rounded-lg border border-border bg-background p-6 text-foreground shadow-64", de[u], re),
161
+ children: /* @__PURE__ */ E(h.Provider, {
162
+ value: Me,
110
163
  children: [
111
- Z && /* @__PURE__ */ D("h2", {
112
- id: I,
113
- className: e(a.root, "pe-8 text-subtitle-1 font-semibold"),
114
- children: t
164
+ Ne && /* @__PURE__ */ T("h2", {
165
+ id: H,
166
+ className: e(s.root, "pe-[var(--wave-dialog-title-end-padding,2rem)] text-subtitle-1 font-semibold"),
167
+ children: o
115
168
  }),
116
- /* @__PURE__ */ D(u, {
117
- appearance: "subtle",
118
- size: "small",
119
- icon: /* @__PURE__ */ D(d, {}),
120
- "aria-label": c,
121
- onClick: (e) => S(!1, {
122
- reason: "close-button",
123
- event: e.nativeEvent
124
- }),
125
- className: e(r.closeButton, "absolute end-4 top-4 text-muted-foreground")
169
+ /* @__PURE__ */ E("div", {
170
+ ref: Oe,
171
+ className: e(a.titleActions, "absolute end-4 top-4 flex items-start gap-1", u === "full" && fe),
172
+ children: [
173
+ r(v) ? n(v, "span", e(a.titleAction, "inline-flex items-center gap-1")) : null,
174
+ /* @__PURE__ */ T("span", {
175
+ ref: ke,
176
+ className: "contents"
177
+ }),
178
+ /* @__PURE__ */ T(ue, {
179
+ componentName: "Dialog.Content",
180
+ closeButton: _,
181
+ closeLabel: y,
182
+ onClose: (e) => j(!1, {
183
+ reason: "close-button",
184
+ event: e
185
+ }),
186
+ className: e(a.closeButton, "text-muted-foreground")
187
+ })
188
+ ]
126
189
  }),
127
- /* @__PURE__ */ D("div", {
128
- className: e(r.body, "-mx-1 mt-1 min-h-0 flex-1 overflow-y-auto scroll-pb-(--wave-dialog-footer-height) p-1 text-body-1"),
129
- style: J === null ? void 0 : { "--wave-dialog-footer-height": `${J}px` },
130
- children: m
190
+ /* @__PURE__ */ T("div", {
191
+ className: e(a.body, "-mx-1 mt-1 min-h-0 flex-1 overflow-y-auto scroll-pb-(--wave-dialog-footer-height) p-1 text-body-1"),
192
+ style: Ae === null ? void 0 : { "--wave-dialog-footer-height": `${Ae}px` },
193
+ children: b
131
194
  })
132
195
  ]
133
196
  })
134
197
  })
135
- })
198
+ })]
136
199
  });
137
200
  };
138
- I.displayName = "DialogContent";
139
- var L = ({ id: t, className: n, children: r, ref: i, ...o }) => {
140
- let { id: s, ref: c } = y("Dialog.Title", "Dialog.Content", t, i);
141
- return /* @__PURE__ */ D("h2", {
142
- ...o,
143
- id: s,
144
- ref: c,
145
- className: e(a.root, "pe-8 text-subtitle-1 font-semibold text-foreground", n),
146
- children: r
201
+ P.displayName = "DialogContent";
202
+ var F = ({ id: t, action: i, className: a, children: o, ref: c, ...l }) => {
203
+ let { id: u, ref: d } = y("Dialog.Title", "Dialog.Content", t, c), f = C.useContext(h)?.titleActionsOutlet, p = /* @__PURE__ */ T("h2", {
204
+ ...l,
205
+ id: u,
206
+ ref: d,
207
+ className: e(s.root, "pe-[var(--wave-dialog-title-end-padding,2rem)] text-subtitle-1 font-semibold text-foreground", a),
208
+ children: o
147
209
  });
210
+ if (!r(i)) return p;
211
+ let m = n(i, "span", e(s.action, "inline-flex items-center gap-1"));
212
+ return /* @__PURE__ */ E(w, { children: [p, f === void 0 ? m : f && D(m, f)] });
148
213
  };
149
- L.displayName = "DialogTitle";
150
- var R = "sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-background px-1 pb-2 pt-3", z = "mt-6 flex justify-end gap-2", B = ({ children: n, className: r, ref: a, ...o }) => {
151
- let c = E.useContext(p), l = c === null, u = c?.setFooterHeight, [d, f] = E.useState(null), m = s(a, f);
152
- return E.useEffect(() => {
153
- l && t("Dialog.Footer:outside-content", "Dialog.Footer must be rendered inside Dialog.Content. Outside it, the footer stays on the page while the dialog is closed.");
154
- }, [l]), E.useLayoutEffect(() => {
214
+ F.displayName = "DialogTitle";
215
+ var I = "sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-background px-1 pb-2 pt-3", L = "mt-6 flex justify-end gap-2", R = ({ children: n, className: r, ref: i, ...a }) => {
216
+ let s = C.useContext(h), c = s === null, u = s?.setFooterHeight, [d, f] = C.useState(null), p = l(i, f);
217
+ return C.useEffect(() => {
218
+ c && t("Dialog.Footer:outside-content", "Dialog.Footer must be rendered inside Dialog.Content. Outside it, the footer stays on the page while the dialog is closed.");
219
+ }, [c]), C.useLayoutEffect(() => {
155
220
  if (!d || !u || typeof ResizeObserver > "u") return;
156
221
  let e = new ResizeObserver((e) => {
157
222
  let t = e[e.length - 1];
@@ -160,22 +225,22 @@ var R = "sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-backgr
160
225
  return e.observe(d, { box: "border-box" }), () => {
161
226
  e.disconnect(), u(null);
162
227
  };
163
- }, [d, u]), /* @__PURE__ */ D("div", {
164
- ref: m,
165
- ...o,
166
- className: e(i.root, u ? R : z, r),
228
+ }, [d, u]), /* @__PURE__ */ T("div", {
229
+ ref: p,
230
+ ...a,
231
+ className: e(o.root, u ? I : L, r),
167
232
  children: n
168
233
  });
169
234
  };
170
- B.displayName = "DialogFooter";
171
- var V = /* @__PURE__ */ Object.assign(M, {
172
- Trigger: N,
173
- Content: I,
174
- Footer: B,
175
- Title: L,
176
- Close: P
235
+ R.displayName = "DialogFooter";
236
+ var z = /* @__PURE__ */ Object.assign(j, {
237
+ Trigger: M,
238
+ Content: P,
239
+ Footer: R,
240
+ Title: F,
241
+ Close: N
177
242
  });
178
243
  //#endregion
179
- export { V as Dialog, P as DialogClose, I as DialogContent, B as DialogFooter, L as DialogTitle, N as DialogTrigger };
244
+ export { z as Dialog, N as DialogClose, P as DialogContent, R as DialogFooter, F as DialogTitle, M as DialogTrigger };
180
245
 
181
246
  //# sourceMappingURL=Dialog.mjs.map