@funstack/ui 0.1.0-alpha.19 → 0.1.0-alpha.20

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 (276) hide show
  1. package/dist/accordion/accordion-item.mjs +2 -2
  2. package/dist/accordion/accordion-item.mjs.map +1 -1
  3. package/dist/accordion/accordion-trigger.d.mts.map +1 -1
  4. package/dist/accordion/accordion-trigger.mjs +3 -20
  5. package/dist/accordion/accordion-trigger.mjs.map +1 -1
  6. package/dist/alert-dialog/alert-dialog-action.d.mts +73 -0
  7. package/dist/alert-dialog/alert-dialog-action.d.mts.map +1 -0
  8. package/dist/alert-dialog/alert-dialog-action.mjs +23 -0
  9. package/dist/alert-dialog/alert-dialog-action.mjs.map +1 -0
  10. package/dist/alert-dialog/alert-dialog-cancel.d.mts +31 -0
  11. package/dist/alert-dialog/alert-dialog-cancel.d.mts.map +1 -0
  12. package/dist/alert-dialog/alert-dialog-cancel.mjs +50 -0
  13. package/dist/alert-dialog/alert-dialog-cancel.mjs.map +1 -0
  14. package/dist/alert-dialog/alert-dialog-context.mjs +24 -0
  15. package/dist/alert-dialog/alert-dialog-context.mjs.map +1 -0
  16. package/dist/alert-dialog/alert-dialog-description.d.mts +25 -0
  17. package/dist/alert-dialog/alert-dialog-description.d.mts.map +1 -0
  18. package/dist/alert-dialog/alert-dialog-description.mjs +20 -0
  19. package/dist/alert-dialog/alert-dialog-description.mjs.map +1 -0
  20. package/dist/alert-dialog/alert-dialog-form.d.mts +27 -0
  21. package/dist/alert-dialog/alert-dialog-form.d.mts.map +1 -0
  22. package/dist/alert-dialog/alert-dialog-form.mjs +22 -0
  23. package/dist/alert-dialog/alert-dialog-form.mjs.map +1 -0
  24. package/dist/alert-dialog/alert-dialog-popup.d.mts +42 -0
  25. package/dist/alert-dialog/alert-dialog-popup.d.mts.map +1 -0
  26. package/dist/alert-dialog/alert-dialog-popup.mjs +53 -0
  27. package/dist/alert-dialog/alert-dialog-popup.mjs.map +1 -0
  28. package/dist/alert-dialog/alert-dialog-root.d.mts +31 -0
  29. package/dist/alert-dialog/alert-dialog-root.d.mts.map +1 -0
  30. package/dist/alert-dialog/alert-dialog-root.mjs +22 -0
  31. package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -0
  32. package/dist/alert-dialog/alert-dialog-title.d.mts +23 -0
  33. package/dist/alert-dialog/alert-dialog-title.d.mts.map +1 -0
  34. package/dist/alert-dialog/alert-dialog-title.mjs +18 -0
  35. package/dist/alert-dialog/alert-dialog-title.mjs.map +1 -0
  36. package/dist/alert-dialog/alert-dialog-trigger.d.mts +23 -0
  37. package/dist/alert-dialog/alert-dialog-trigger.d.mts.map +1 -0
  38. package/dist/alert-dialog/alert-dialog-trigger.mjs +18 -0
  39. package/dist/alert-dialog/alert-dialog-trigger.mjs.map +1 -0
  40. package/dist/alert-dialog/index.d.mts +33 -0
  41. package/dist/alert-dialog/index.d.mts.map +1 -0
  42. package/dist/alert-dialog/index.mjs +33 -0
  43. package/dist/alert-dialog/index.mjs.map +1 -0
  44. package/dist/checkbox-group/checkbox-group-parent.mjs +1 -1
  45. package/dist/collapsible/collapsible-context.mjs +8 -0
  46. package/dist/collapsible/collapsible-context.mjs.map +1 -0
  47. package/dist/collapsible/collapsible-panel.d.mts +53 -0
  48. package/dist/collapsible/collapsible-panel.d.mts.map +1 -0
  49. package/dist/collapsible/collapsible-panel.mjs +41 -0
  50. package/dist/collapsible/collapsible-panel.mjs.map +1 -0
  51. package/dist/collapsible/collapsible-root.d.mts +108 -0
  52. package/dist/collapsible/collapsible-root.d.mts.map +1 -0
  53. package/dist/collapsible/collapsible-root.mjs +147 -0
  54. package/dist/collapsible/collapsible-root.mjs.map +1 -0
  55. package/dist/collapsible/collapsible-trigger.d.mts +45 -0
  56. package/dist/collapsible/collapsible-trigger.d.mts.map +1 -0
  57. package/dist/collapsible/collapsible-trigger.mjs +62 -0
  58. package/dist/collapsible/collapsible-trigger.mjs.map +1 -0
  59. package/dist/collapsible/index.d.mts +21 -0
  60. package/dist/collapsible/index.d.mts.map +1 -0
  61. package/dist/collapsible/index.mjs +21 -0
  62. package/dist/collapsible/index.mjs.map +1 -0
  63. package/dist/combobox/chip-text.mjs +24 -0
  64. package/dist/combobox/chip-text.mjs.map +1 -0
  65. package/dist/combobox/combobox-chips.d.mts +159 -0
  66. package/dist/combobox/combobox-chips.d.mts.map +1 -0
  67. package/dist/combobox/combobox-chips.mjs +198 -0
  68. package/dist/combobox/combobox-chips.mjs.map +1 -0
  69. package/dist/combobox/combobox-clear.d.mts +5 -2
  70. package/dist/combobox/combobox-clear.d.mts.map +1 -1
  71. package/dist/combobox/combobox-clear.mjs +3 -1
  72. package/dist/combobox/combobox-clear.mjs.map +1 -1
  73. package/dist/combobox/combobox-context.mjs +4 -5
  74. package/dist/combobox/combobox-context.mjs.map +1 -1
  75. package/dist/combobox/combobox-input.d.mts +10 -3
  76. package/dist/combobox/combobox-input.d.mts.map +1 -1
  77. package/dist/combobox/combobox-input.mjs +13 -5
  78. package/dist/combobox/combobox-input.mjs.map +1 -1
  79. package/dist/combobox/combobox-keyboard.mjs +50 -4
  80. package/dist/combobox/combobox-keyboard.mjs.map +1 -1
  81. package/dist/combobox/combobox-list.d.mts +1 -1
  82. package/dist/combobox/combobox-list.mjs +2 -1
  83. package/dist/combobox/combobox-list.mjs.map +1 -1
  84. package/dist/combobox/combobox-option.d.mts +5 -2
  85. package/dist/combobox/combobox-option.d.mts.map +1 -1
  86. package/dist/combobox/combobox-option.mjs +4 -3
  87. package/dist/combobox/combobox-option.mjs.map +1 -1
  88. package/dist/combobox/combobox-root.d.mts +127 -35
  89. package/dist/combobox/combobox-root.d.mts.map +1 -1
  90. package/dist/combobox/combobox-root.mjs +396 -44
  91. package/dist/combobox/combobox-root.mjs.map +1 -1
  92. package/dist/combobox/index.d.mts +8 -2
  93. package/dist/combobox/index.d.mts.map +1 -1
  94. package/dist/combobox/index.mjs +7 -1
  95. package/dist/combobox/index.mjs.map +1 -1
  96. package/dist/combobox/use-combobox-form.mjs +2 -3
  97. package/dist/combobox/use-combobox-form.mjs.map +1 -1
  98. package/dist/dialog/dialog-close.d.mts +9 -5
  99. package/dist/dialog/dialog-close.d.mts.map +1 -1
  100. package/dist/dialog/dialog-close.mjs +19 -8
  101. package/dist/dialog/dialog-close.mjs.map +1 -1
  102. package/dist/dialog/dialog-context.d.mts +2 -0
  103. package/dist/dialog/dialog-context.mjs +14 -2
  104. package/dist/dialog/dialog-context.mjs.map +1 -1
  105. package/dist/dialog/dialog-description.d.mts +2 -1
  106. package/dist/dialog/dialog-description.d.mts.map +1 -1
  107. package/dist/dialog/dialog-description.mjs +8 -4
  108. package/dist/dialog/dialog-description.mjs.map +1 -1
  109. package/dist/dialog/dialog-form.d.mts +2 -1
  110. package/dist/dialog/dialog-form.d.mts.map +1 -1
  111. package/dist/dialog/dialog-form.mjs +11 -6
  112. package/dist/dialog/dialog-form.mjs.map +1 -1
  113. package/dist/dialog/dialog-popup.d.mts +2 -1
  114. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  115. package/dist/dialog/dialog-popup.mjs +23 -14
  116. package/dist/dialog/dialog-popup.mjs.map +1 -1
  117. package/dist/dialog/dialog-root.d.mts +2 -1
  118. package/dist/dialog/dialog-root.d.mts.map +1 -1
  119. package/dist/dialog/dialog-root.mjs +15 -5
  120. package/dist/dialog/dialog-root.mjs.map +1 -1
  121. package/dist/dialog/dialog-title.d.mts +2 -1
  122. package/dist/dialog/dialog-title.d.mts.map +1 -1
  123. package/dist/dialog/dialog-title.mjs +8 -4
  124. package/dist/dialog/dialog-title.mjs.map +1 -1
  125. package/dist/dialog/dialog-trigger.d.mts +2 -1
  126. package/dist/dialog/dialog-trigger.d.mts.map +1 -1
  127. package/dist/dialog/dialog-trigger.mjs +14 -9
  128. package/dist/dialog/dialog-trigger.mjs.map +1 -1
  129. package/dist/docs/components/accordion.md +2 -0
  130. package/dist/docs/components/alert-dialog.md +546 -0
  131. package/dist/docs/components/collapsible.md +408 -0
  132. package/dist/docs/components/combobox.md +288 -26
  133. package/dist/docs/components/dialog.md +7 -5
  134. package/dist/docs/components/field.md +180 -3
  135. package/dist/docs/components/hover-card.md +494 -0
  136. package/dist/docs/components/multi-select.md +622 -0
  137. package/dist/docs/components/number-field.md +1 -1
  138. package/dist/docs/components/popover.md +4 -4
  139. package/dist/docs/components/select.md +9 -1
  140. package/dist/docs/components/separator.md +182 -0
  141. package/dist/docs/components/slider.md +1 -1
  142. package/dist/docs/components/tooltip.md +1 -1
  143. package/dist/docs/concepts/experimental.md +3 -3
  144. package/dist/docs/concepts/server-components.md +1 -1
  145. package/dist/docs/index.md +7 -2
  146. package/dist/docs/roadmap.md +8 -0
  147. package/dist/field/field-control.d.mts +13 -4
  148. package/dist/field/field-control.d.mts.map +1 -1
  149. package/dist/field/field-control.mjs +39 -10
  150. package/dist/field/field-control.mjs.map +1 -1
  151. package/dist/field/field-label.d.mts +6 -2
  152. package/dist/field/field-label.d.mts.map +1 -1
  153. package/dist/field/field-label.mjs +12 -2
  154. package/dist/field/field-label.mjs.map +1 -1
  155. package/dist/field/field-root.mjs +9 -1
  156. package/dist/field/field-root.mjs.map +1 -1
  157. package/dist/hover-card/hover-card-context.mjs +13 -0
  158. package/dist/hover-card/hover-card-context.mjs.map +1 -0
  159. package/dist/hover-card/hover-card-popup.d.mts +102 -0
  160. package/dist/hover-card/hover-card-popup.d.mts.map +1 -0
  161. package/dist/hover-card/hover-card-popup.mjs +80 -0
  162. package/dist/hover-card/hover-card-popup.mjs.map +1 -0
  163. package/dist/hover-card/hover-card-root.d.mts +94 -0
  164. package/dist/hover-card/hover-card-root.d.mts.map +1 -0
  165. package/dist/hover-card/hover-card-root.mjs +74 -0
  166. package/dist/hover-card/hover-card-root.mjs.map +1 -0
  167. package/dist/hover-card/hover-card-trigger.d.mts +65 -0
  168. package/dist/hover-card/hover-card-trigger.d.mts.map +1 -0
  169. package/dist/hover-card/hover-card-trigger.mjs +109 -0
  170. package/dist/hover-card/hover-card-trigger.mjs.map +1 -0
  171. package/dist/hover-card/index.d.mts +24 -0
  172. package/dist/hover-card/index.d.mts.map +1 -0
  173. package/dist/hover-card/index.mjs +24 -0
  174. package/dist/hover-card/index.mjs.map +1 -0
  175. package/dist/hover-card/use-hover-card-interest.mjs +242 -0
  176. package/dist/hover-card/use-hover-card-interest.mjs.map +1 -0
  177. package/dist/index.d.mts +38 -9
  178. package/dist/index.mjs +6 -1
  179. package/dist/internal/action/use-multiple-selection.mjs +83 -0
  180. package/dist/internal/action/use-multiple-selection.mjs.map +1 -0
  181. package/dist/internal/details-summary.mjs +56 -0
  182. package/dist/internal/details-summary.mjs.map +1 -0
  183. package/dist/internal/form/field-context.mjs.map +1 -1
  184. package/dist/internal/form/hidden-values.mjs +29 -0
  185. package/dist/internal/form/hidden-values.mjs.map +1 -0
  186. package/dist/internal/form/validity.mjs +3 -1
  187. package/dist/internal/form/validity.mjs.map +1 -1
  188. package/dist/internal/overlay/use-interest-dismiss.mjs +2 -1
  189. package/dist/internal/overlay/use-interest-dismiss.mjs.map +1 -1
  190. package/dist/internal/overlay/use-overlay-close.mjs +5 -3
  191. package/dist/internal/overlay/use-overlay-close.mjs.map +1 -1
  192. package/dist/internal/overlay/use-overlay-root.mjs +4 -1
  193. package/dist/internal/overlay/use-overlay-root.mjs.map +1 -1
  194. package/dist/internal/overlay/use-popover-popup.mjs +20 -7
  195. package/dist/internal/overlay/use-popover-popup.mjs.map +1 -1
  196. package/dist/internal/overlay/use-popover-trigger.d.mts +1 -1
  197. package/dist/internal/typeahead.mjs +52 -0
  198. package/dist/internal/typeahead.mjs.map +1 -0
  199. package/dist/{combobox → internal}/use-active-option.mjs +8 -6
  200. package/dist/internal/use-active-option.mjs.map +1 -0
  201. package/dist/{combobox → internal}/use-deferred-leave.mjs +20 -12
  202. package/dist/internal/use-deferred-leave.mjs.map +1 -0
  203. package/dist/internal/use-name-warning.mjs +57 -1
  204. package/dist/internal/use-name-warning.mjs.map +1 -1
  205. package/dist/internal/use-option-registry.mjs +70 -0
  206. package/dist/internal/use-option-registry.mjs.map +1 -0
  207. package/dist/menu/use-menu-keyboard.mjs +7 -27
  208. package/dist/menu/use-menu-keyboard.mjs.map +1 -1
  209. package/dist/multi-select/index.d.mts +37 -0
  210. package/dist/multi-select/index.d.mts.map +1 -0
  211. package/dist/multi-select/index.mjs +37 -0
  212. package/dist/multi-select/index.mjs.map +1 -0
  213. package/dist/multi-select/multi-select-context.mjs +19 -0
  214. package/dist/multi-select/multi-select-context.mjs.map +1 -0
  215. package/dist/multi-select/multi-select-group.d.mts +120 -0
  216. package/dist/multi-select/multi-select-group.d.mts.map +1 -0
  217. package/dist/multi-select/multi-select-group.mjs +111 -0
  218. package/dist/multi-select/multi-select-group.mjs.map +1 -0
  219. package/dist/multi-select/multi-select-keyboard.mjs +145 -0
  220. package/dist/multi-select/multi-select-keyboard.mjs.map +1 -0
  221. package/dist/multi-select/multi-select-label.d.mts +42 -0
  222. package/dist/multi-select/multi-select-label.d.mts.map +1 -0
  223. package/dist/multi-select/multi-select-label.mjs +41 -0
  224. package/dist/multi-select/multi-select-label.mjs.map +1 -0
  225. package/dist/multi-select/multi-select-list.d.mts +47 -0
  226. package/dist/multi-select/multi-select-list.d.mts.map +1 -0
  227. package/dist/multi-select/multi-select-list.mjs +65 -0
  228. package/dist/multi-select/multi-select-list.mjs.map +1 -0
  229. package/dist/multi-select/multi-select-option.d.mts +68 -0
  230. package/dist/multi-select/multi-select-option.d.mts.map +1 -0
  231. package/dist/multi-select/multi-select-option.mjs +93 -0
  232. package/dist/multi-select/multi-select-option.mjs.map +1 -0
  233. package/dist/multi-select/multi-select-popup.d.mts +58 -0
  234. package/dist/multi-select/multi-select-popup.d.mts.map +1 -0
  235. package/dist/multi-select/multi-select-popup.mjs +71 -0
  236. package/dist/multi-select/multi-select-popup.mjs.map +1 -0
  237. package/dist/multi-select/multi-select-root.d.mts +125 -0
  238. package/dist/multi-select/multi-select-root.d.mts.map +1 -0
  239. package/dist/multi-select/multi-select-root.mjs +257 -0
  240. package/dist/multi-select/multi-select-root.mjs.map +1 -0
  241. package/dist/multi-select/multi-select-trigger.d.mts +66 -0
  242. package/dist/multi-select/multi-select-trigger.d.mts.map +1 -0
  243. package/dist/multi-select/multi-select-trigger.mjs +169 -0
  244. package/dist/multi-select/multi-select-trigger.mjs.map +1 -0
  245. package/dist/multi-select/multi-select-value.d.mts +57 -0
  246. package/dist/multi-select/multi-select-value.d.mts.map +1 -0
  247. package/dist/multi-select/multi-select-value.mjs +41 -0
  248. package/dist/multi-select/multi-select-value.mjs.map +1 -0
  249. package/dist/number-field/number-field-root.mjs +1 -1
  250. package/dist/number-field/use-step-button.d.mts.map +1 -1
  251. package/dist/number-field/use-step-button.mjs +11 -2
  252. package/dist/number-field/use-step-button.mjs.map +1 -1
  253. package/dist/popover/popover-close.d.mts +6 -3
  254. package/dist/popover/popover-close.d.mts.map +1 -1
  255. package/dist/popover/popover-close.mjs +3 -2
  256. package/dist/popover/popover-close.mjs.map +1 -1
  257. package/dist/popover/popover-popup.mjs +1 -1
  258. package/dist/select/select-root.d.mts +1 -1
  259. package/dist/select/select-root.d.mts.map +1 -1
  260. package/dist/select/select-root.mjs +5 -1
  261. package/dist/select/select-root.mjs.map +1 -1
  262. package/dist/separator/index.d.mts +3 -0
  263. package/dist/separator/index.mjs +1 -0
  264. package/dist/separator/separator.d.mts +58 -0
  265. package/dist/separator/separator.d.mts.map +1 -0
  266. package/dist/separator/separator.mjs +41 -0
  267. package/dist/separator/separator.mjs.map +1 -0
  268. package/dist/slider/slider-root.mjs +1 -0
  269. package/dist/slider/slider-root.mjs.map +1 -1
  270. package/dist/toast/toast-viewport.mjs +1 -1
  271. package/package.json +6 -1
  272. package/skills/funstack-ui-knowledge/SKILL.md +14 -9
  273. package/dist/combobox/use-active-option.mjs.map +0 -1
  274. package/dist/combobox/use-deferred-leave.mjs.map +0 -1
  275. package/dist/combobox/use-option-registry.mjs +0 -52
  276. package/dist/combobox/use-option-registry.mjs.map +0 -1
@@ -3,7 +3,7 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
4
4
  import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
- import { useElementCheck } from "../internal/use-element-check.mjs";
6
+ import { useDetailsCheck } from "../internal/details-summary.mjs";
7
7
  import { AccordionItemContext, AccordionRootContext } from "./accordion-context.mjs";
8
8
  import { use, useCallback, useMemo, useState } from "react";
9
9
  import { jsx } from "react/jsx-runtime";
@@ -28,7 +28,7 @@ function AccordionItem({ value, defaultOpen = false, disabled: disabledProp = fa
28
28
  useDevWarning(isLibrary && defaultOpen, isDev && "Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on Accordion.Root instead.");
29
29
  useDevWarning(!isLibrary && transition !== void 0, isDev && "Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition. Animate `::details-content` with CSS instead.");
30
30
  const registerItem = root?.registerItem;
31
- const checkElement = useElementCheck(isDev && ((element) => element.tagName !== "DETAILS" ? `Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.` : null));
31
+ const checkElement = useDetailsCheck("Accordion.Item", isDev && "toggle, find-in-page, exclusive groups");
32
32
  const libraryRef = useCallback((element) => {
33
33
  checkElement?.(element);
34
34
  const unregister = registerItem?.(value, element);
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-item.mjs","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useMemo, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n SyntheticEvent,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext, AccordionRootContext } from \"./accordion-context.js\";\nimport type { AccordionItemContextValue } from \"./accordion-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Accordion.Item`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface AccordionItemState {\n /** The Item's `value` prop. */\n readonly value: string;\n /** Optimistic open state. `undefined` in JS-free mode (browser-owned, unknown to React). */\n readonly open: boolean | undefined;\n /** This item's open state is changing through an in-flight action. */\n readonly pending: boolean;\n /** Disabled by its own prop or by the Root. */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `Accordion.Item`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport interface AccordionItemProps extends Omit<\n ComponentPropsWithRef<\"details\">,\n \"open\" | \"name\" | \"onToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /** Identifies the item in the Root's `value`. Required in both modes. */\n value: string;\n /**\n * JS-free mode only: renders the initial `open` attribute; the browser owns it from then on.\n * Ignored (dev warning) in library mode, where the Root's `defaultValue` / `value` decide.\n *\n * @defaultValue `false`\n */\n defaultOpen?: boolean;\n /**\n * Disables this item: the Trigger renders `aria-disabled` and never toggles. Enforced by a\n * click handler, so in JS-free mode it does not hold before hydration or with JS off.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<details>`;\n * animates the commit that ends an action (the `open` attribute flip), not the optimistic\n * `data-open` flip. Ignored (dev warning) in JS-free mode.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, AccordionItemState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, AccordionItemState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, AccordionItemState>;\n /** Must render a `<details>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"details\">, AccordionItemState>;\n}\n\n/**\n * One accordion entry: the `<details>` element. In library mode its `open` attribute follows\n * committed state and `data-open` / `data-pending` follow optimistic state; in JS-free mode (or\n * outside any Root, as a standalone disclosure) the browser owns `open`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport function AccordionItem({\n value,\n defaultOpen = false,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionItemProps) {\n const root = use(AccordionRootContext);\n const isLibrary = root?.mode === \"library\";\n const disabled = disabledProp || (root?.disabled ?? false);\n const committedOpen = isLibrary ? root.committed.has(value) : undefined;\n const optimisticOpen = isLibrary ? root.optimistic.has(value) : undefined;\n const rootPending = root?.pending ?? false;\n const pending = isLibrary && rootPending && committedOpen !== optimisticOpen;\n // JS-free mode: the prop React writes never changes after the first render, so React never\n // rewrites the attribute the browser now owns.\n const [staticOpen] = useState(defaultOpen);\n\n useDevWarning(\n isLibrary && defaultOpen,\n isDev &&\n \"Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on \" +\n \"Accordion.Root instead.\",\n );\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition. Animate `::details-content` with CSS instead.\",\n );\n\n const registerItem = root?.registerItem;\n const checkElement = useElementCheck<HTMLDetailsElement>(\n isDev &&\n ((element) =>\n element.tagName !== \"DETAILS\"\n ? `Accordion.Item: expected to render a <details> element but got <${element.tagName.toLowerCase()}>. ` +\n \"The platform semantics (toggle, find-in-page, exclusive groups) need a real <details>.\"\n : null),\n );\n const libraryRef = useCallback(\n (element: HTMLDetailsElement) => {\n checkElement?.(element);\n const unregister = registerItem?.(value, element);\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerItem, value],\n );\n\n // Platform path (design 2.3): the Root reconciles pre-hydration clicks on mount and re-applies\n // committed state once nothing is in flight; this handler reports the browser's own flips.\n const onToggle = isLibrary\n ? (event: SyntheticEvent<HTMLDetailsElement>) => {\n const element = event.currentTarget;\n // Read `details.open`, never `ToggleEvent.newState`: `toggle` is coalesced.\n if (element.open === committedOpen) return; // our own commit echoing back\n if (disabled) {\n // A disabled item cannot be opened by the browser either; close it again now or, while\n // an action is in flight, when the Root re-applies committed state.\n if (!rootPending) element.open = committedOpen === true;\n return;\n }\n root.dispatchFromDom(value, element.open, event.nativeEvent);\n }\n : undefined;\n\n const state: AccordionItemState = { value, open: optimisticOpen, pending, disabled };\n const dispatch = root?.dispatch;\n const registerTrigger = root?.registerTrigger;\n // Memoised: changes only with this item's own values, not with every Root change.\n const itemContext = useMemo<AccordionItemContextValue>(\n () => ({\n value,\n disabled,\n committedOpen,\n optimisticOpen,\n pending,\n library: isLibrary,\n dispatch,\n registerTrigger,\n }),\n [value, disabled, committedOpen, optimisticOpen, pending, isLibrary, dispatch, registerTrigger],\n );\n\n const element = useRender<ComponentPropsWithRef<\"details\">, AccordionItemState>({\n defaultElement: \"details\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: `open`, `name` and `onToggle` are owned by the library in at\n // least one mode, so a `render` element cannot override them either (conventions 1.2).\n libraryProps: {\n open: isLibrary ? committedOpen : staticOpen,\n // A click before hydration changes `open` under React's feet in both modes; the mismatch is\n // expected and reconciled (library mode) or the browser's business (JS-free mode).\n suppressHydrationWarning: true,\n // Owned in both modes: in library mode there is one writer of `open`, so a render element's\n // `name` (a second, platform-level writer) is removed.\n name: !isLibrary ? root?.name : undefined,\n // Only installed in library mode; owning the key in static mode would strip a render\n // element's own `onToggle`.\n ...(isLibrary && { onToggle }),\n \"data-open\": dataAttr(optimisticOpen === true),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n });\n\n return useTransitionBoundary(\n \"Accordion.Item\",\n isLibrary ? transition : undefined,\n <AccordionItemContext value={itemContext}>{element}</AccordionItemContext>,\n );\n}\n\nAccordionItem.displayName = \"AccordionItem\";\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;AAqEvC,SAAgB,cAAc,EAC5B,OACA,cAAc,OACd,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,OAAO,IAAI,oBAAoB;CACrC,MAAM,YAAY,MAAM,SAAS;CACjC,MAAM,WAAW,iBAAiB,MAAM,YAAY;CACpD,MAAM,gBAAgB,YAAY,KAAK,UAAU,IAAI,KAAK,IAAI,KAAA;CAC9D,MAAM,iBAAiB,YAAY,KAAK,WAAW,IAAI,KAAK,IAAI,KAAA;CAChE,MAAM,cAAc,MAAM,WAAW;CACrC,MAAM,UAAU,aAAa,eAAe,kBAAkB;CAG9D,MAAM,CAAC,cAAc,SAAS,WAAW;CAEzC,cACE,aAAa,aACb,SACE,oHAEJ;CACA,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,sKAEJ;CAEA,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,gBACnB,WACI,YACA,QAAQ,YAAY,YAChB,mEAAmE,QAAQ,QAAQ,YAAY,EAAE,6FAEjG,KACV;CACA,MAAM,aAAa,aAChB,YAAgC;EAC/B,eAAe,OAAO;EACtB,MAAM,aAAa,eAAe,OAAO,OAAO;EAChD,aAAa;GACX,aAAa;EACf;CACF,GACA;EAAC;EAAc;EAAc;CAAK,CACpC;CAIA,MAAM,WAAW,aACZ,UAA8C;EAC7C,MAAM,UAAU,MAAM;EAEtB,IAAI,QAAQ,SAAS,eAAe;EACpC,IAAI,UAAU;GAGZ,IAAI,CAAC,aAAa,QAAQ,OAAO,kBAAkB;GACnD;EACF;EACA,KAAK,gBAAgB,OAAO,QAAQ,MAAM,MAAM,WAAW;CAC7D,IACA,KAAA;CAEJ,MAAM,QAA4B;EAAE;EAAO,MAAM;EAAgB;EAAS;CAAS;CACnF,MAAM,WAAW,MAAM;CACvB,MAAM,kBAAkB,MAAM;CAE9B,MAAM,cAAc,eACX;EACL;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;CACF,IACA;EAAC;EAAO;EAAU;EAAe;EAAgB;EAAS;EAAW;EAAU;CAAe,CAChG;CAEA,MAAM,UAAU,UAAgE;EAC9E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAGP,cAAc;GACZ,MAAM,YAAY,gBAAgB;GAGlC,0BAA0B;GAG1B,MAAM,CAAC,YAAY,MAAM,OAAO,KAAA;GAGhC,GAAI,aAAa,EAAE,SAAS;GAC5B,aAAa,SAAS,mBAAmB,IAAI;GAC7C,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;CACF,CAAC;CAED,OAAO,sBACL,kBACA,YAAY,aAAa,KAAA,GACzB,oBAAC,sBAAD;EAAsB,OAAO;EAAc,UAAA;CAA8B,CAAA,CAC3E;AACF;AAEA,cAAc,cAAc"}
1
+ {"version":3,"file":"accordion-item.mjs","names":[],"sources":["../../src/accordion/accordion-item.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useMemo, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n SyntheticEvent,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { useDetailsCheck } from \"../internal/details-summary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext, AccordionRootContext } from \"./accordion-context.js\";\nimport type { AccordionItemContextValue } from \"./accordion-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Accordion.Item`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface AccordionItemState {\n /** The Item's `value` prop. */\n readonly value: string;\n /** Optimistic open state. `undefined` in JS-free mode (browser-owned, unknown to React). */\n readonly open: boolean | undefined;\n /** This item's open state is changing through an in-flight action. */\n readonly pending: boolean;\n /** Disabled by its own prop or by the Root. */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `Accordion.Item`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport interface AccordionItemProps extends Omit<\n ComponentPropsWithRef<\"details\">,\n \"open\" | \"name\" | \"onToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /** Identifies the item in the Root's `value`. Required in both modes. */\n value: string;\n /**\n * JS-free mode only: renders the initial `open` attribute; the browser owns it from then on.\n * Ignored (dev warning) in library mode, where the Root's `defaultValue` / `value` decide.\n *\n * @defaultValue `false`\n */\n defaultOpen?: boolean;\n /**\n * Disables this item: the Trigger renders `aria-disabled` and never toggles. Enforced by a\n * click handler, so in JS-free mode it does not hold before hydration or with JS off.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<details>`;\n * animates the commit that ends an action (the `open` attribute flip), not the optimistic\n * `data-open` flip. Ignored (dev warning) in JS-free mode.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, AccordionItemState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, AccordionItemState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, AccordionItemState>;\n /** Must render a `<details>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"details\">, AccordionItemState>;\n}\n\n/**\n * One accordion entry: the `<details>` element. In library mode its `open` attribute follows\n * committed state and `data-open` / `data-pending` follow optimistic state; in JS-free mode (or\n * outside any Root, as a standalone disclosure) the browser owns `open`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport function AccordionItem({\n value,\n defaultOpen = false,\n disabled: disabledProp = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionItemProps) {\n const root = use(AccordionRootContext);\n const isLibrary = root?.mode === \"library\";\n const disabled = disabledProp || (root?.disabled ?? false);\n const committedOpen = isLibrary ? root.committed.has(value) : undefined;\n const optimisticOpen = isLibrary ? root.optimistic.has(value) : undefined;\n const rootPending = root?.pending ?? false;\n const pending = isLibrary && rootPending && committedOpen !== optimisticOpen;\n // JS-free mode: the prop React writes never changes after the first render, so React never\n // rewrites the attribute the browser now owns.\n const [staticOpen] = useState(defaultOpen);\n\n useDevWarning(\n isLibrary && defaultOpen,\n isDev &&\n \"Accordion.Item: `defaultOpen` is ignored in library mode. Use `defaultValue` or `value` on \" +\n \"Accordion.Root instead.\",\n );\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Item: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition. Animate `::details-content` with CSS instead.\",\n );\n\n const registerItem = root?.registerItem;\n const checkElement = useDetailsCheck(\n \"Accordion.Item\",\n isDev && \"toggle, find-in-page, exclusive groups\",\n );\n const libraryRef = useCallback(\n (element: HTMLDetailsElement) => {\n checkElement?.(element);\n const unregister = registerItem?.(value, element);\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerItem, value],\n );\n\n // Platform path (design 2.3): the Root reconciles pre-hydration clicks on mount and re-applies\n // committed state once nothing is in flight; this handler reports the browser's own flips.\n const onToggle = isLibrary\n ? (event: SyntheticEvent<HTMLDetailsElement>) => {\n const element = event.currentTarget;\n // Read `details.open`, never `ToggleEvent.newState`: `toggle` is coalesced.\n if (element.open === committedOpen) return; // our own commit echoing back\n if (disabled) {\n // A disabled item cannot be opened by the browser either; close it again now or, while\n // an action is in flight, when the Root re-applies committed state.\n if (!rootPending) element.open = committedOpen === true;\n return;\n }\n root.dispatchFromDom(value, element.open, event.nativeEvent);\n }\n : undefined;\n\n const state: AccordionItemState = { value, open: optimisticOpen, pending, disabled };\n const dispatch = root?.dispatch;\n const registerTrigger = root?.registerTrigger;\n // Memoised: changes only with this item's own values, not with every Root change.\n const itemContext = useMemo<AccordionItemContextValue>(\n () => ({\n value,\n disabled,\n committedOpen,\n optimisticOpen,\n pending,\n library: isLibrary,\n dispatch,\n registerTrigger,\n }),\n [value, disabled, committedOpen, optimisticOpen, pending, isLibrary, dispatch, registerTrigger],\n );\n\n const element = useRender<ComponentPropsWithRef<\"details\">, AccordionItemState>({\n defaultElement: \"details\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: `open`, `name` and `onToggle` are owned by the library in at\n // least one mode, so a `render` element cannot override them either (conventions 1.2).\n libraryProps: {\n open: isLibrary ? committedOpen : staticOpen,\n // A click before hydration changes `open` under React's feet in both modes; the mismatch is\n // expected and reconciled (library mode) or the browser's business (JS-free mode).\n suppressHydrationWarning: true,\n // Owned in both modes: in library mode there is one writer of `open`, so a render element's\n // `name` (a second, platform-level writer) is removed.\n name: !isLibrary ? root?.name : undefined,\n // Only installed in library mode; owning the key in static mode would strip a render\n // element's own `onToggle`.\n ...(isLibrary && { onToggle }),\n \"data-open\": dataAttr(optimisticOpen === true),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n });\n\n return useTransitionBoundary(\n \"Accordion.Item\",\n isLibrary ? transition : undefined,\n <AccordionItemContext value={itemContext}>{element}</AccordionItemContext>,\n );\n}\n\nAccordionItem.displayName = \"AccordionItem\";\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;AAqEvC,SAAgB,cAAc,EAC5B,OACA,cAAc,OACd,UAAU,eAAe,OACzB,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,OAAO,IAAI,oBAAoB;CACrC,MAAM,YAAY,MAAM,SAAS;CACjC,MAAM,WAAW,iBAAiB,MAAM,YAAY;CACpD,MAAM,gBAAgB,YAAY,KAAK,UAAU,IAAI,KAAK,IAAI,KAAA;CAC9D,MAAM,iBAAiB,YAAY,KAAK,WAAW,IAAI,KAAK,IAAI,KAAA;CAChE,MAAM,cAAc,MAAM,WAAW;CACrC,MAAM,UAAU,aAAa,eAAe,kBAAkB;CAG9D,MAAM,CAAC,cAAc,SAAS,WAAW;CAEzC,cACE,aAAa,aACb,SACE,oHAEJ;CACA,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,sKAEJ;CAEA,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,gBACnB,kBACA,SAAS,wCACX;CACA,MAAM,aAAa,aAChB,YAAgC;EAC/B,eAAe,OAAO;EACtB,MAAM,aAAa,eAAe,OAAO,OAAO;EAChD,aAAa;GACX,aAAa;EACf;CACF,GACA;EAAC;EAAc;EAAc;CAAK,CACpC;CAIA,MAAM,WAAW,aACZ,UAA8C;EAC7C,MAAM,UAAU,MAAM;EAEtB,IAAI,QAAQ,SAAS,eAAe;EACpC,IAAI,UAAU;GAGZ,IAAI,CAAC,aAAa,QAAQ,OAAO,kBAAkB;GACnD;EACF;EACA,KAAK,gBAAgB,OAAO,QAAQ,MAAM,MAAM,WAAW;CAC7D,IACA,KAAA;CAEJ,MAAM,QAA4B;EAAE;EAAO,MAAM;EAAgB;EAAS;CAAS;CACnF,MAAM,WAAW,MAAM;CACvB,MAAM,kBAAkB,MAAM;CAE9B,MAAM,cAAc,eACX;EACL;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;CACF,IACA;EAAC;EAAO;EAAU;EAAe;EAAgB;EAAS;EAAW;EAAU;CAAe,CAChG;CAEA,MAAM,UAAU,UAAgE;EAC9E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAGP,cAAc;GACZ,MAAM,YAAY,gBAAgB;GAGlC,0BAA0B;GAG1B,MAAM,CAAC,YAAY,MAAM,OAAO,KAAA;GAGhC,GAAI,aAAa,EAAE,SAAS;GAC5B,aAAa,SAAS,mBAAmB,IAAI;GAC7C,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;CACF,CAAC;CAED,OAAO,sBACL,kBACA,YAAY,aAAa,KAAA,GACzB,oBAAC,sBAAD;EAAsB,OAAO;EAAc,UAAA;CAA8B,CAAA,CAC3E;AACF;AAEA,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-trigger.d.mts","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"mappings":";;;;;YAqBY,wBAAwB;;;;;;iBAOnB,8BAA8B,KAC7C;;;;;;;;;;EAYA,aAAa;;EAEb,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;;;;wBA+BxC,mBACd,YACA,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBAPR"}
1
+ {"version":3,"file":"accordion-trigger.d.mts","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"mappings":";;;;;YAqBY,wBAAwB;;;;;;iBAOnB,8BAA8B,KAC7C;;;;;;;;;;EAYA,aAAa;;EAEb,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,kCAAkC;;;;;;;;;;wBAWxC,mBACd,YACA,WACA,OACA,UACA,WACG,QACF,wBAAqB;yBAPR"}
@@ -3,23 +3,11 @@ import { dataAttr } from "../internal/data-attr.mjs";
3
3
  import { useDevWarning } from "../internal/use-dev-warning.mjs";
4
4
  import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
5
5
  import { useRender } from "../internal/use-render.mjs";
6
- import { useElementCheck } from "../internal/use-element-check.mjs";
6
+ import { interceptSummaryClick, useSummaryCheck } from "../internal/details-summary.mjs";
7
7
  import { AccordionItemContext } from "./accordion-context.mjs";
8
8
  import { use, useCallback } from "react";
9
9
  //#region src/accordion/accordion-trigger.tsx
10
10
  const isDev = process.env.NODE_ENV !== "production";
11
- const NESTED_INTERACTIVE = "a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])";
12
- /**
13
- * Nested controls with an activation behaviour of their own. The browser runs theirs instead of
14
- * the summary's (no toggle), so their click must keep its default: navigation, check, submit.
15
- */
16
- const SELF_ACTIVATING = "a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], [type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])";
17
- /** The interactive descendant of the summary that was clicked (a link in the heading), if any. */
18
- function nestedInteractive(target, summary) {
19
- if (!(target instanceof Element) || target === summary) return null;
20
- const interactive = target.closest(NESTED_INTERACTIVE);
21
- return interactive !== null && interactive !== summary && summary.contains(interactive) ? interactive : null;
22
- }
23
11
  /**
24
12
  * The item's disclosure control: the `<summary>`, which must be the first child of the Item. In
25
13
  * library mode the click is intercepted and dispatched through the Root's transition; the
@@ -34,7 +22,7 @@ function AccordionTrigger({ transition, className, style, children, render, ...r
34
22
  const isLibrary = item.library;
35
23
  useDevWarning(!isLibrary && transition !== void 0, isDev && "Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item outside any React transition.");
36
24
  const registerTrigger = item.registerTrigger;
37
- const checkElement = useElementCheck(isDev && ((element) => element.tagName !== "SUMMARY" ? `Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. Only a <summary> toggles its parent <details>.` : null));
25
+ const checkElement = useSummaryCheck("Accordion.Trigger");
38
26
  const libraryRef = useCallback((element) => {
39
27
  checkElement?.(element);
40
28
  const unregister = registerTrigger?.(element);
@@ -49,12 +37,7 @@ function AccordionTrigger({ transition, className, style, children, render, ...r
49
37
  disabled: item.disabled
50
38
  };
51
39
  const onClick = isLibrary || item.disabled ? (event) => {
52
- const nested = nestedInteractive(event.target, event.currentTarget);
53
- if (nested !== null) {
54
- if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();
55
- return;
56
- }
57
- event.preventDefault();
40
+ if (!interceptSummaryClick(event)) return;
58
41
  if (item.disabled || !isLibrary) return;
59
42
  item.dispatch?.(item.value, !item.optimisticOpen, event.nativeEvent);
60
43
  } : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"accordion-trigger.mjs","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\nimport type { AccordionItemState } from \"./accordion-item.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The trigger is the item's control; it renders the item's state object. */\nexport type AccordionTriggerState = AccordionItemState;\n\n/**\n * Props of `Accordion.Trigger`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport interface AccordionTriggerProps extends Omit<\n ComponentPropsWithRef<\"summary\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<summary>`.\n * Animates only the commit that ends an action (for example a spinner rendered from `pending`\n * disappearing); the optimistic `data-open` flip is a CSS job.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, AccordionTriggerState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, AccordionTriggerState>;\n /** Rendered from optimistic state; must not suspend. A heading inside is recommended. */\n children?: StateValue<ReactNode, AccordionTriggerState>;\n /** Must render a `<summary>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>;\n}\n\nconst NESTED_INTERACTIVE =\n \"a[href], button, label, input, select, textarea, [contenteditable]:not([contenteditable='false'])\";\n\n/**\n * Nested controls with an activation behaviour of their own. The browser runs theirs instead of\n * the summary's (no toggle), so their click must keep its default: navigation, check, submit.\n */\nconst SELF_ACTIVATING =\n \"a[href], button, label, input:is([type='button'], [type='submit'], [type='reset'], \" +\n \"[type='image'], [type='checkbox'], [type='radio'], [type='file'], [type='color'])\";\n\n/** The interactive descendant of the summary that was clicked (a link in the heading), if any. */\nfunction nestedInteractive(target: EventTarget | null, summary: HTMLElement): Element | null {\n if (!(target instanceof Element) || target === summary) return null;\n const interactive = target.closest(NESTED_INTERACTIVE);\n return interactive !== null && interactive !== summary && summary.contains(interactive)\n ? interactive\n : null;\n}\n\n/**\n * The item's disclosure control: the `<summary>`, which must be the first child of the Item. In\n * library mode the click is intercepted and dispatched through the Root's transition; the\n * element shows optimistic `data-open` and `data-pending`. The platform forbids `aria-expanded`\n * on a summary, so assistive technology hears the committed state (from `<details open>`).\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport function AccordionTrigger({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionTriggerProps) {\n // Only the Item's context (memoised per item), which carries what is needed of the Root's.\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Trigger must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const registerTrigger = item.registerTrigger;\n const checkElement = useElementCheck(\n isDev &&\n ((element) =>\n element.tagName !== \"SUMMARY\"\n ? `Accordion.Trigger: expected to render a <summary> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Only a <summary> toggles its parent <details>.\"\n : null),\n );\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n const unregister = registerTrigger?.(element);\n // Always return a cleanup so the merged ref never calls back with `null`.\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerTrigger],\n );\n\n const state: AccordionTriggerState = {\n value: item.value,\n open: item.optimisticOpen,\n pending: item.pending,\n disabled: item.disabled,\n };\n\n // JS-free mode attaches no click handler unless the item is disabled (design 2.1 / section 6).\n const onClick =\n isLibrary || item.disabled\n ? (event: MouseEvent<HTMLElement>) => {\n const nested = nestedInteractive(event.target, event.currentTarget);\n if (nested !== null) {\n // A nested control never toggles. Controls without their own activation behaviour\n // (text input, select, textarea, contenteditable) would let the click fall through to\n // the summary's toggle, so cancel it; focus and pickers happen on mousedown and are\n // unaffected. Self-activating controls already pre-empt the summary's behaviour.\n if (!nested.matches(SELF_ACTIVATING)) event.preventDefault();\n return;\n }\n // Cancelling the click is what keeps the browser from touching `open`.\n event.preventDefault();\n if (item.disabled || !isLibrary) return;\n item.dispatch?.(item.value, !item.optimisticOpen, event.nativeEvent);\n }\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>({\n defaultElement: \"summary\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"aria-disabled\": item.disabled ? true : undefined,\n \"data-open\": dataAttr(item.optimisticOpen === true),\n \"data-pending\": dataAttr(item.pending),\n \"data-disabled\": dataAttr(item.disabled),\n // Only owned when installed, so a render element keeps its own `onClick` in JS-free mode.\n ...(onClick && { onClick }),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Trigger\", isLibrary ? transition : undefined, element);\n}\n\nAccordionTrigger.displayName = \"AccordionTrigger\";\n"],"mappings":";;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAkCvC,MAAM,qBACJ;;;;;AAMF,MAAM,kBACJ;;AAIF,SAAS,kBAAkB,QAA4B,SAAsC;CAC3F,IAAI,EAAE,kBAAkB,YAAY,WAAW,SAAS,OAAO;CAC/D,MAAM,cAAc,OAAO,QAAQ,kBAAkB;CACrD,OAAO,gBAAgB,QAAQ,gBAAgB,WAAW,QAAQ,SAAS,WAAW,IAClF,cACA;AACN;;;;;;;;;AAUA,SAAgB,iBAAiB,EAC/B,YACA,WACA,OACA,UACA,QACA,GAAG,QACqB;CAExB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8DAA8D;CAEhF,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,2HAEJ;CAEA,MAAM,kBAAkB,KAAK;CAC7B,MAAM,eAAe,gBACnB,WACI,YACA,QAAQ,YAAY,YAChB,sEAAsE,QAAQ,QAAQ,YAAY,EAAE,qDAEpG,KACV;CACA,MAAM,aAAa,aAChB,YAAyB;EACxB,eAAe,OAAO;EACtB,MAAM,aAAa,kBAAkB,OAAO;EAE5C,aAAa;GACX,aAAa;EACf;CACF,GACA,CAAC,cAAc,eAAe,CAChC;CAEA,MAAM,QAA+B;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,SAAS,KAAK;EACd,UAAU,KAAK;CACjB;CAGA,MAAM,UACJ,aAAa,KAAK,YACb,UAAmC;EAClC,MAAM,SAAS,kBAAkB,MAAM,QAAQ,MAAM,aAAa;EAClE,IAAI,WAAW,MAAM;GAKnB,IAAI,CAAC,OAAO,QAAQ,eAAe,GAAG,MAAM,eAAe;GAC3D;EACF;EAEA,MAAM,eAAe;EACrB,IAAI,KAAK,YAAY,CAAC,WAAW;EACjC,KAAK,WAAW,KAAK,OAAO,CAAC,KAAK,gBAAgB,MAAM,WAAW;CACrE,IACA,KAAA;CAEN,MAAM,UAAU,UAAmE;EACjF,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAEP,cAAc;GACZ,iBAAiB,KAAK,WAAW,OAAO,KAAA;GACxC,aAAa,SAAS,KAAK,mBAAmB,IAAI;GAClD,gBAAgB,SAAS,KAAK,OAAO;GACrC,iBAAiB,SAAS,KAAK,QAAQ;GAEvC,GAAI,WAAW,EAAE,QAAQ;EAC3B;CACF,CAAC;CAED,OAAO,sBAAsB,qBAAqB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC/F;AAEA,iBAAiB,cAAc"}
1
+ {"version":3,"file":"accordion-trigger.mjs","names":[],"sources":["../../src/accordion/accordion-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { interceptSummaryClick, useSummaryCheck } from \"../internal/details-summary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { AccordionItemContext } from \"./accordion-context.js\";\nimport type { AccordionItemState } from \"./accordion-item.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The trigger is the item's control; it renders the item's state object. */\nexport type AccordionTriggerState = AccordionItemState;\n\n/**\n * Props of `Accordion.Trigger`.\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport interface AccordionTriggerProps extends Omit<\n ComponentPropsWithRef<\"summary\">,\n \"onClick\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode only. Forwarded as `default` to the `<ViewTransition>` around the `<summary>`.\n * Animates only the commit that ends an action (for example a spinner rendered from `pending`\n * disappearing); the optimistic `data-open` flip is a CSS job.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, AccordionTriggerState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, AccordionTriggerState>;\n /** Rendered from optimistic state; must not suspend. A heading inside is recommended. */\n children?: StateValue<ReactNode, AccordionTriggerState>;\n /** Must render a `<summary>` element. */\n render?: RenderProp<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>;\n}\n\n/**\n * The item's disclosure control: the `<summary>`, which must be the first child of the Item. In\n * library mode the click is intercepted and dispatched through the Root's transition; the\n * element shows optimistic `data-open` and `data-pending`. The platform forbids `aria-expanded`\n * on a summary, so assistive technology hears the committed state (from `<details open>`).\n *\n * @see https://ui.funstack.work/components/accordion\n */\nexport function AccordionTrigger({\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: AccordionTriggerProps) {\n // Only the Item's context (memoised per item), which carries what is needed of the Root's.\n const item = use(AccordionItemContext);\n if (item === null) {\n throw new Error(\"Accordion.Trigger must be rendered inside an Accordion.Item.\");\n }\n const isLibrary = item.library;\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n isDev &&\n \"Accordion.Trigger: `transition` has no effect in JS-free mode; the browser toggles the item \" +\n \"outside any React transition.\",\n );\n\n const registerTrigger = item.registerTrigger;\n const checkElement = useSummaryCheck(\"Accordion.Trigger\");\n const libraryRef = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n const unregister = registerTrigger?.(element);\n // Always return a cleanup so the merged ref never calls back with `null`.\n return () => {\n unregister?.();\n };\n },\n [checkElement, registerTrigger],\n );\n\n const state: AccordionTriggerState = {\n value: item.value,\n open: item.optimisticOpen,\n pending: item.pending,\n disabled: item.disabled,\n };\n\n // JS-free mode attaches no click handler unless the item is disabled (design 2.1 / section 6).\n const onClick =\n isLibrary || item.disabled\n ? (event: MouseEvent<HTMLElement>) => {\n // A nested control never toggles; any other click is cancelled, which is what keeps the\n // browser from touching `open`.\n if (!interceptSummaryClick(event)) return;\n if (item.disabled || !isLibrary) return;\n item.dispatch?.(item.value, !item.optimisticOpen, event.nativeEvent);\n }\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"summary\">, AccordionTriggerState>({\n defaultElement: \"summary\",\n render,\n state,\n className,\n style,\n children,\n ref: libraryRef,\n props: rest,\n // Library-controlled layer: wins over a `render` element's props (conventions 1.2).\n libraryProps: {\n \"aria-disabled\": item.disabled ? true : undefined,\n \"data-open\": dataAttr(item.optimisticOpen === true),\n \"data-pending\": dataAttr(item.pending),\n \"data-disabled\": dataAttr(item.disabled),\n // Only owned when installed, so a render element keeps its own `onClick` in JS-free mode.\n ...(onClick && { onClick }),\n },\n });\n\n return useTransitionBoundary(\"Accordion.Trigger\", isLibrary ? transition : undefined, element);\n}\n\nAccordionTrigger.displayName = \"AccordionTrigger\";\n"],"mappings":";;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;AA0CvC,SAAgB,iBAAiB,EAC/B,YACA,WACA,OACA,UACA,QACA,GAAG,QACqB;CAExB,MAAM,OAAO,IAAI,oBAAoB;CACrC,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,8DAA8D;CAEhF,MAAM,YAAY,KAAK;CAEvB,cACE,CAAC,aAAa,eAAe,KAAA,GAC7B,SACE,2HAEJ;CAEA,MAAM,kBAAkB,KAAK;CAC7B,MAAM,eAAe,gBAAgB,mBAAmB;CACxD,MAAM,aAAa,aAChB,YAAyB;EACxB,eAAe,OAAO;EACtB,MAAM,aAAa,kBAAkB,OAAO;EAE5C,aAAa;GACX,aAAa;EACf;CACF,GACA,CAAC,cAAc,eAAe,CAChC;CAEA,MAAM,QAA+B;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,SAAS,KAAK;EACd,UAAU,KAAK;CACjB;CAGA,MAAM,UACJ,aAAa,KAAK,YACb,UAAmC;EAGlC,IAAI,CAAC,sBAAsB,KAAK,GAAG;EACnC,IAAI,KAAK,YAAY,CAAC,WAAW;EACjC,KAAK,WAAW,KAAK,OAAO,CAAC,KAAK,gBAAgB,MAAM,WAAW;CACrE,IACA,KAAA;CAEN,MAAM,UAAU,UAAmE;EACjF,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,KAAK;EACL,OAAO;EAEP,cAAc;GACZ,iBAAiB,KAAK,WAAW,OAAO,KAAA;GACxC,aAAa,SAAS,KAAK,mBAAmB,IAAI;GAClD,gBAAgB,SAAS,KAAK,OAAO;GACrC,iBAAiB,SAAS,KAAK,QAAQ;GAEvC,GAAI,WAAW,EAAE,QAAQ;EAC3B;CACF,CAAC;CAED,OAAO,sBAAsB,qBAAqB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC/F;AAEA,iBAAiB,cAAc"}
@@ -0,0 +1,73 @@
1
+ import { Action, RenderProp, StateValue, WhilePending } from "../internal/types.mjs";
2
+ import { DialogCloseDetails, DialogCloseState } from "../dialog/dialog-close.mjs";
3
+ import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
4
+ //#region src/alert-dialog/alert-dialog-action.d.ts
5
+ /** State of `AlertDialog.Action`, passed to the function forms of `className`, `style`, `children` and `render`. */
6
+ export type AlertDialogActionState = DialogCloseState;
7
+ /** Details passed to `AlertDialog.Action`'s `action`. */
8
+ export type AlertDialogActionDetails = DialogCloseDetails;
9
+ /**
10
+ * Props of `AlertDialog.Action`.
11
+ *
12
+ * @see https://ui.funstack.work/components/alert-dialog
13
+ */
14
+ export interface AlertDialogActionProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "value" | "className" | "style" | "children"> {
15
+ /**
16
+ * The confirmed work. Runs inside this part's own transition (`data-pending` on the button),
17
+ * then closes the dialog with `value` as `returnValue`: in library mode through the Root
18
+ * (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with
19
+ * `close(value)`. A rejection reaches the nearest Error Boundary above this part and leaves
20
+ * the dialog open. If the dialog was dismissed and opened again while the action ran, the
21
+ * close is dropped. Escape or a Cancel while it runs closes the dialog; the action keeps
22
+ * running (it is hidden, not aborted).
23
+ *
24
+ * With `action` the button is no native close invoker (no `commandfor` / `command`): a click
25
+ * before hydration does nothing, rather than closing the dialog as if the work had been done.
26
+ * The confirm that works before hydration is `AlertDialog.Form`. Without `action` the button
27
+ * only closes the dialog (read `returnValue` in `openChangeAction`).
28
+ */
29
+ action?: Action<[details: AlertDialogActionDetails]>;
30
+ /**
31
+ * What a click does while the `action` is pending. `"ignore"`: nothing (the click is
32
+ * cancelled, `aria-disabled="true"` meanwhile). `"run"`: the action runs again; the dialog
33
+ * closes once, after the last run and only if the latest one resolved.
34
+ *
35
+ * @defaultValue `"ignore"`
36
+ */
37
+ whilePending?: WhilePending;
38
+ /** Becomes `dialog.returnValue` (and `details.returnValue` of the close request). */
39
+ value?: string;
40
+ /**
41
+ * Never runs or closes. Native `disabled` on a `<button>`; owned. With a link or component
42
+ * `render`, `aria-disabled="true"` instead.
43
+ *
44
+ * @defaultValue `false`
45
+ */
46
+ disabled?: boolean;
47
+ /** Class name, or a function of the part's state that returns one. */
48
+ className?: StateValue<string | undefined, AlertDialogActionState>;
49
+ /** Inline style, or a function of the part's state that returns one. */
50
+ style?: StateValue<CSSProperties | undefined, AlertDialogActionState>;
51
+ /** Content, or a function of the part's state (`pending ? "Deleting…" : "Delete"`). */
52
+ children?: StateValue<ReactNode, AlertDialogActionState>;
53
+ /** Replace the default `<button>` (element form) or take over rendering (function form). */
54
+ render?: RenderProp<ComponentPropsWithRef<"button">, AlertDialogActionState>;
55
+ }
56
+ /**
57
+ * The confirm button: `Dialog.Close` with an `action` (design 3.2). The action runs in this
58
+ * part's own transition (`data-pending` and, by default, `aria-disabled` on the button), then
59
+ * the dialog closes; a rejection leaves it open. Unlike `Dialog.Close`, an Action with `action`
60
+ * renders no `commandfor` / `command`.
61
+ *
62
+ * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,
63
+ * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`,
64
+ * `data-pending`, `data-disabled`.
65
+ *
66
+ * @see https://ui.funstack.work/components/alert-dialog
67
+ */
68
+ export declare function AlertDialogAction(props: AlertDialogActionProps): ReactNode;
69
+ export declare namespace AlertDialogAction {
70
+ var displayName: string;
71
+ }
72
+ //#endregion
73
+ //# sourceMappingURL=alert-dialog-action.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-action.d.mts","names":[],"sources":["../../src/alert-dialog/alert-dialog-action.tsx"],"mappings":";;;;;YAOY,yBAAyB;;YAGzB,2BAA2B;;;;;;iBAOtB,+BAA+B,KAC9C;;;;;;;;;;;;;;;EAiBA,SAAS,QAAQ,SAAS;;;;;;;;EAQ1B,eAAe;;EAEf;;;;;;;EAOA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;wBAevC,kBAAkB,OAAO,yBAAsB;yBAA/C"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useDialogClose } from "../dialog/dialog-close.mjs";
3
+ //#region src/alert-dialog/alert-dialog-action.tsx
4
+ /**
5
+ * The confirm button: `Dialog.Close` with an `action` (design 3.2). The action runs in this
6
+ * part's own transition (`data-pending` and, by default, `aria-disabled` on the button), then
7
+ * the dialog closes; a rejection leaves it open. Unlike `Dialog.Close`, an Action with `action`
8
+ * renders no `commandfor` / `command`.
9
+ *
10
+ * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,
11
+ * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`,
12
+ * `data-pending`, `data-disabled`.
13
+ *
14
+ * @see https://ui.funstack.work/components/alert-dialog
15
+ */
16
+ function AlertDialogAction(props) {
17
+ return useDialogClose(props, { part: "AlertDialog.Action" });
18
+ }
19
+ AlertDialogAction.displayName = "AlertDialogAction";
20
+ //#endregion
21
+ export { AlertDialogAction };
22
+
23
+ //# sourceMappingURL=alert-dialog-action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-action.mjs","names":[],"sources":["../../src/alert-dialog/alert-dialog-action.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { useDialogClose } from \"../dialog/dialog-close.js\";\nimport type { DialogCloseDetails, DialogCloseState } from \"../dialog/dialog-close.js\";\nimport type { Action, RenderProp, StateValue, WhilePending } from \"../internal/types.js\";\n\n/** State of `AlertDialog.Action`, passed to the function forms of `className`, `style`, `children` and `render`. */\nexport type AlertDialogActionState = DialogCloseState;\n\n/** Details passed to `AlertDialog.Action`'s `action`. */\nexport type AlertDialogActionDetails = DialogCloseDetails;\n\n/**\n * Props of `AlertDialog.Action`.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport interface AlertDialogActionProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * The confirmed work. Runs inside this part's own transition (`data-pending` on the button),\n * then closes the dialog with `value` as `returnValue`: in library mode through the Root\n * (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with\n * `close(value)`. A rejection reaches the nearest Error Boundary above this part and leaves\n * the dialog open. If the dialog was dismissed and opened again while the action ran, the\n * close is dropped. Escape or a Cancel while it runs closes the dialog; the action keeps\n * running (it is hidden, not aborted).\n *\n * With `action` the button is no native close invoker (no `commandfor` / `command`): a click\n * before hydration does nothing, rather than closing the dialog as if the work had been done.\n * The confirm that works before hydration is `AlertDialog.Form`. Without `action` the button\n * only closes the dialog (read `returnValue` in `openChangeAction`).\n */\n action?: Action<[details: AlertDialogActionDetails]>;\n /**\n * What a click does while the `action` is pending. `\"ignore\"`: nothing (the click is\n * cancelled, `aria-disabled=\"true\"` meanwhile). `\"run\"`: the action runs again; the dialog\n * closes once, after the last run and only if the latest one resolved.\n *\n * @defaultValue `\"ignore\"`\n */\n whilePending?: WhilePending;\n /** Becomes `dialog.returnValue` (and `details.returnValue` of the close request). */\n value?: string;\n /**\n * Never runs or closes. Native `disabled` on a `<button>`; owned. With a link or component\n * `render`, `aria-disabled=\"true\"` instead.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, AlertDialogActionState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, AlertDialogActionState>;\n /** Content, or a function of the part's state (`pending ? \"Deleting…\" : \"Delete\"`). */\n children?: StateValue<ReactNode, AlertDialogActionState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, AlertDialogActionState>;\n}\n\n/**\n * The confirm button: `Dialog.Close` with an `action` (design 3.2). The action runs in this\n * part's own transition (`data-pending` and, by default, `aria-disabled` on the button), then\n * the dialog closes; a rejection leaves it open. Unlike `Dialog.Close`, an Action with `action`\n * renders no `commandfor` / `command`.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,\n * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`,\n * `data-pending`, `data-disabled`.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport function AlertDialogAction(props: AlertDialogActionProps) {\n // With `action` no native command, as every Close part (#182).\n return useDialogClose(props, { part: \"AlertDialog.Action\" });\n}\n\nAlertDialogAction.displayName = \"AlertDialogAction\";\n"],"mappings":";;;;;;;;;;;;;;;AA2EA,SAAgB,kBAAkB,OAA+B;CAE/D,OAAO,eAAe,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC7D;AAEA,kBAAkB,cAAc"}
@@ -0,0 +1,31 @@
1
+ import { DialogCloseDetails, DialogCloseProps, DialogCloseState } from "../dialog/dialog-close.mjs";
2
+ //#region src/alert-dialog/alert-dialog-cancel.d.ts
3
+ /** State of `AlertDialog.Cancel`: Dialog.Close's. */
4
+ export type AlertDialogCancelState = DialogCloseState;
5
+ /** Details passed to `AlertDialog.Cancel`'s `action`: Dialog.Close's. */
6
+ export type AlertDialogCancelDetails = DialogCloseDetails;
7
+ /**
8
+ * Props of `AlertDialog.Cancel`: `Dialog.Close`'s (`value` defaults to `""`, what Escape
9
+ * leaves in `returnValue`).
10
+ *
11
+ * @see https://ui.funstack.work/components/alert-dialog
12
+ */
13
+ export type AlertDialogCancelProps = DialogCloseProps;
14
+ /**
15
+ * The safe answer: `Dialog.Close` under another name (`<button type="button" commandfor
16
+ * command="request-close">` in JS-free mode, a close through the Root in library mode), and the
17
+ * default initial focus target (design 3.4): when the Popup has no `initialFocus`, the dialog
18
+ * opens with focus on the first enabled Cancel. In JS-free mode it carries `autofocus`, in the
19
+ * server HTML too, so the focus is right before hydration.
20
+ *
21
+ * Owned keys (conventions 1.2): Dialog.Close's, and `autoFocus` in the server and hydration render
22
+ * while it is the default target in JS-free mode.
23
+ *
24
+ * @see https://ui.funstack.work/components/alert-dialog
25
+ */
26
+ export declare function AlertDialogCancel({ disabled, ref, ...rest }: AlertDialogCancelProps): import("react").ReactNode;
27
+ export declare namespace AlertDialogCancel {
28
+ var displayName: string;
29
+ }
30
+ //#endregion
31
+ //# sourceMappingURL=alert-dialog-cancel.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-cancel.d.mts","names":[],"sources":["../../src/alert-dialog/alert-dialog-cancel.tsx"],"mappings":";;;YAcY,yBAAyB;;YAGzB,2BAA2B;;;;;;;YAQ3B,yBAAyB;;;;;;;;;;;;;wBAcrB,oBAAoB,UAAU,QAAQ,QAAQ,yCAAsB;yBAApE"}
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { useMergedRefs } from "../internal/use-merged-refs.mjs";
3
+ import { useDialogContext } from "../dialog/dialog-context.mjs";
4
+ import { useDialogClose } from "../dialog/dialog-close.mjs";
5
+ import { useHydratedMount } from "../internal/use-hydrated-mount.mjs";
6
+ import { AlertDialogCancelContext } from "./alert-dialog-context.mjs";
7
+ import { use, useCallback } from "react";
8
+ //#region src/alert-dialog/alert-dialog-cancel.tsx
9
+ /**
10
+ * The safe answer: `Dialog.Close` under another name (`<button type="button" commandfor
11
+ * command="request-close">` in JS-free mode, a close through the Root in library mode), and the
12
+ * default initial focus target (design 3.4): when the Popup has no `initialFocus`, the dialog
13
+ * opens with focus on the first enabled Cancel. In JS-free mode it carries `autofocus`, in the
14
+ * server HTML too, so the focus is right before hydration.
15
+ *
16
+ * Owned keys (conventions 1.2): Dialog.Close's, and `autoFocus` in the server and hydration render
17
+ * while it is the default target in JS-free mode.
18
+ *
19
+ * @see https://ui.funstack.work/components/alert-dialog
20
+ */
21
+ function AlertDialogCancel({ disabled, ref, ...rest }) {
22
+ const ctx = useDialogContext("AlertDialog.Cancel");
23
+ const cancels = use(AlertDialogCancelContext);
24
+ const register = cancels?.register;
25
+ const autofocus = ctx.mode !== "library" && cancels !== null && cancels.defaultFocus && disabled !== true;
26
+ const serverOrHydrating = useHydratedMount();
27
+ const attach = useCallback((element) => {
28
+ if (element === null) return;
29
+ const unregister = register?.(element);
30
+ if (autofocus) element.setAttribute("autofocus", "");
31
+ return () => {
32
+ unregister?.();
33
+ if (autofocus) element.removeAttribute("autofocus");
34
+ };
35
+ }, [register, autofocus]);
36
+ const mergedRef = useMergedRefs(attach, ref);
37
+ return useDialogClose({
38
+ ...rest,
39
+ disabled,
40
+ ref: mergedRef
41
+ }, {
42
+ part: "AlertDialog.Cancel",
43
+ ownProps: autofocus && serverOrHydrating ? { autoFocus: true } : void 0
44
+ });
45
+ }
46
+ AlertDialogCancel.displayName = "AlertDialogCancel";
47
+ //#endregion
48
+ export { AlertDialogCancel };
49
+
50
+ //# sourceMappingURL=alert-dialog-cancel.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-cancel.mjs","names":[],"sources":["../../src/alert-dialog/alert-dialog-cancel.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback } from \"react\";\nimport { useDialogClose } from \"../dialog/dialog-close.js\";\nimport type {\n DialogCloseDetails,\n DialogCloseProps,\n DialogCloseState,\n} from \"../dialog/dialog-close.js\";\nimport { useDialogContext } from \"../dialog/dialog-context.js\";\nimport { useHydratedMount } from \"../internal/use-hydrated-mount.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { AlertDialogCancelContext } from \"./alert-dialog-context.js\";\n\n/** State of `AlertDialog.Cancel`: Dialog.Close's. */\nexport type AlertDialogCancelState = DialogCloseState;\n\n/** Details passed to `AlertDialog.Cancel`'s `action`: Dialog.Close's. */\nexport type AlertDialogCancelDetails = DialogCloseDetails;\n\n/**\n * Props of `AlertDialog.Cancel`: `Dialog.Close`'s (`value` defaults to `\"\"`, what Escape\n * leaves in `returnValue`).\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport type AlertDialogCancelProps = DialogCloseProps;\n\n/**\n * The safe answer: `Dialog.Close` under another name (`<button type=\"button\" commandfor\n * command=\"request-close\">` in JS-free mode, a close through the Root in library mode), and the\n * default initial focus target (design 3.4): when the Popup has no `initialFocus`, the dialog\n * opens with focus on the first enabled Cancel. In JS-free mode it carries `autofocus`, in the\n * server HTML too, so the focus is right before hydration.\n *\n * Owned keys (conventions 1.2): Dialog.Close's, and `autoFocus` in the server and hydration render\n * while it is the default target in JS-free mode.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport function AlertDialogCancel({ disabled, ref, ...rest }: AlertDialogCancelProps) {\n const ctx = useDialogContext(\"AlertDialog.Cancel\");\n const cancels = use(AlertDialogCancelContext);\n const register = cancels?.register;\n // JS-free mode: the browser opens the dialog itself, so the attribute has to be on the element\n // already (design 3.4). React renders `autoFocus` in the server HTML but does not write it on\n // a client render; the ref writes it there. Not on a disabled Cancel: the rule is the first\n // enabled one.\n const autofocus =\n ctx.mode !== \"library\" && cancels !== null && cancels.defaultFocus && disabled !== true;\n // React's `autoFocus` prop only where it writes the attribute: the server render and the\n // render that hydrates it (no `.focus()` there). On a client-created mount React would call\n // `.focus()` instead, so a Cancel mounting or remounting into an open dialog would take focus\n // (and of two, the last would win); there the ref's attribute is enough.\n const serverOrHydrating = useHydratedMount();\n\n const attach = useCallback(\n (element: HTMLElement | null) => {\n if (element === null) return;\n const unregister = register?.(element);\n // Owned while it is the target: removed when it stops being one (disabled, or an\n // `initialFocus` given), the server-rendered attribute included.\n if (autofocus) element.setAttribute(\"autofocus\", \"\");\n return () => {\n unregister?.();\n if (autofocus) element.removeAttribute(\"autofocus\");\n };\n },\n [register, autofocus],\n );\n const mergedRef = useMergedRefs<HTMLButtonElement | null>(attach, ref);\n\n return useDialogClose(\n { ...rest, disabled, ref: mergedRef },\n {\n part: \"AlertDialog.Cancel\",\n ownProps: autofocus && serverOrHydrating ? { autoFocus: true } : undefined,\n },\n );\n}\n\nAlertDialogCancel.displayName = \"AlertDialogCancel\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,kBAAkB,EAAE,UAAU,KAAK,GAAG,QAAgC;CACpF,MAAM,MAAM,iBAAiB,oBAAoB;CACjD,MAAM,UAAU,IAAI,wBAAwB;CAC5C,MAAM,WAAW,SAAS;CAK1B,MAAM,YACJ,IAAI,SAAS,aAAa,YAAY,QAAQ,QAAQ,gBAAgB,aAAa;CAKrF,MAAM,oBAAoB,iBAAiB;CAE3C,MAAM,SAAS,aACZ,YAAgC;EAC/B,IAAI,YAAY,MAAM;EACtB,MAAM,aAAa,WAAW,OAAO;EAGrC,IAAI,WAAW,QAAQ,aAAa,aAAa,EAAE;EACnD,aAAa;GACX,aAAa;GACb,IAAI,WAAW,QAAQ,gBAAgB,WAAW;EACpD;CACF,GACA,CAAC,UAAU,SAAS,CACtB;CACA,MAAM,YAAY,cAAwC,QAAQ,GAAG;CAErE,OAAO,eACL;EAAE,GAAG;EAAM;EAAU,KAAK;CAAU,GACpC;EACE,MAAM;EACN,UAAU,aAAa,oBAAoB,EAAE,WAAW,KAAK,IAAI,KAAA;CACnE,CACF;AACF;AAEA,kBAAkB,cAAc"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { compareDocumentOrder } from "../internal/dom-order.mjs";
3
+ import { createContext } from "react";
4
+ //#region src/alert-dialog/alert-dialog-context.ts
5
+ const AlertDialogCancelContext = createContext(null);
6
+ function isDisabled(element) {
7
+ return element.matches(":disabled") || element.getAttribute("aria-disabled") === "true";
8
+ }
9
+ /**
10
+ * The first registered Cancel, in tree order, that belongs to `dialog` (not to a dialog nested
11
+ * in it) and is not disabled; `null` without one, and the platform chooses (design 3.4).
12
+ */
13
+ function firstEnabledCancel(dialog, cancels) {
14
+ let first = null;
15
+ for (const element of cancels) {
16
+ if (element.closest("dialog") !== dialog || isDisabled(element)) continue;
17
+ if (first === null || compareDocumentOrder(element, first) < 0) first = element;
18
+ }
19
+ return first;
20
+ }
21
+ //#endregion
22
+ export { AlertDialogCancelContext, firstEnabledCancel };
23
+
24
+ //# sourceMappingURL=alert-dialog-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-context.mjs","names":[],"sources":["../../src/alert-dialog/alert-dialog-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext } from \"react\";\nimport { compareDocumentOrder } from \"../internal/dom-order.js\";\n\n/**\n * What `AlertDialog.Popup` tells the Cancels inside it (design 3.4): whether they are the\n * default initial focus target (the Popup has no `initialFocus`), and where they register their\n * element so that a library open can pick the first enabled one.\n */\nexport interface AlertDialogCancelContextValue {\n /** The Popup has no `initialFocus`: the first enabled Cancel is the target. */\n readonly defaultFocus: boolean;\n /** Registers a Cancel's element; returns the unregister function. */\n readonly register: (element: HTMLElement) => () => void;\n}\n\nexport const AlertDialogCancelContext = createContext<AlertDialogCancelContextValue | null>(null);\n\nfunction isDisabled(element: HTMLElement): boolean {\n return element.matches(\":disabled\") || element.getAttribute(\"aria-disabled\") === \"true\";\n}\n\n/**\n * The first registered Cancel, in tree order, that belongs to `dialog` (not to a dialog nested\n * in it) and is not disabled; `null` without one, and the platform chooses (design 3.4).\n */\nexport function firstEnabledCancel(\n dialog: HTMLDialogElement,\n cancels: ReadonlySet<HTMLElement>,\n): HTMLElement | null {\n let first: HTMLElement | null = null;\n for (const element of cancels) {\n if (element.closest(\"dialog\") !== dialog || isDisabled(element)) continue;\n if (first === null || compareDocumentOrder(element, first) < 0) first = element;\n }\n return first;\n}\n"],"mappings":";;;;AAgBA,MAAa,2BAA2B,cAAoD,IAAI;AAEhG,SAAS,WAAW,SAA+B;CACjD,OAAO,QAAQ,QAAQ,WAAW,KAAK,QAAQ,aAAa,eAAe,MAAM;AACnF;;;;;AAMA,SAAgB,mBACd,QACA,SACoB;CACpB,IAAI,QAA4B;CAChC,KAAK,MAAM,WAAW,SAAS;EAC7B,IAAI,QAAQ,QAAQ,QAAQ,MAAM,UAAU,WAAW,OAAO,GAAG;EACjE,IAAI,UAAU,QAAQ,qBAAqB,SAAS,KAAK,IAAI,GAAG,QAAQ;CAC1E;CACA,OAAO;AACT"}
@@ -0,0 +1,25 @@
1
+ import { DialogDescriptionProps, DialogDescriptionState } from "../dialog/dialog-description.mjs";
2
+ //#region src/alert-dialog/alert-dialog-description.d.ts
3
+ /** State of `AlertDialog.Description`: the Popup's state. */
4
+ export type AlertDialogDescriptionState = DialogDescriptionState;
5
+ /**
6
+ * Props of `AlertDialog.Description`: `Dialog.Description`'s.
7
+ *
8
+ * @see https://ui.funstack.work/components/alert-dialog
9
+ */
10
+ export type AlertDialogDescriptionProps = DialogDescriptionProps;
11
+ /**
12
+ * The alert message: a `<p>` whose id the Popup references with `aria-describedby`. A screen
13
+ * reader announces an alert dialog by its name and this description; without one, development
14
+ * warns (design 2.2).
15
+ *
16
+ * Owned key (conventions 1.2): `id`.
17
+ *
18
+ * @see https://ui.funstack.work/components/alert-dialog
19
+ */
20
+ export declare function AlertDialogDescription(props: AlertDialogDescriptionProps): import("react").ReactNode;
21
+ export declare namespace AlertDialogDescription {
22
+ var displayName: string;
23
+ }
24
+ //#endregion
25
+ //# sourceMappingURL=alert-dialog-description.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-description.d.mts","names":[],"sources":["../../src/alert-dialog/alert-dialog-description.tsx"],"mappings":";;;YAQY,8BAA8B;;;;;;YAO9B,8BAA8B;;;;;;;;;;wBAW1B,uBAAuB,OAAO,8CAA2B;yBAAzD"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { useDialogDescription } from "../dialog/dialog-description.mjs";
3
+ //#region src/alert-dialog/alert-dialog-description.tsx
4
+ /**
5
+ * The alert message: a `<p>` whose id the Popup references with `aria-describedby`. A screen
6
+ * reader announces an alert dialog by its name and this description; without one, development
7
+ * warns (design 2.2).
8
+ *
9
+ * Owned key (conventions 1.2): `id`.
10
+ *
11
+ * @see https://ui.funstack.work/components/alert-dialog
12
+ */
13
+ function AlertDialogDescription(props) {
14
+ return useDialogDescription(props, "AlertDialog");
15
+ }
16
+ AlertDialogDescription.displayName = "AlertDialogDescription";
17
+ //#endregion
18
+ export { AlertDialogDescription };
19
+
20
+ //# sourceMappingURL=alert-dialog-description.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-description.mjs","names":[],"sources":["../../src/alert-dialog/alert-dialog-description.tsx"],"sourcesContent":["\"use client\";\nimport { useDialogDescription } from \"../dialog/dialog-description.js\";\nimport type {\n DialogDescriptionProps,\n DialogDescriptionState,\n} from \"../dialog/dialog-description.js\";\n\n/** State of `AlertDialog.Description`: the Popup's state. */\nexport type AlertDialogDescriptionState = DialogDescriptionState;\n\n/**\n * Props of `AlertDialog.Description`: `Dialog.Description`'s.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport type AlertDialogDescriptionProps = DialogDescriptionProps;\n\n/**\n * The alert message: a `<p>` whose id the Popup references with `aria-describedby`. A screen\n * reader announces an alert dialog by its name and this description; without one, development\n * warns (design 2.2).\n *\n * Owned key (conventions 1.2): `id`.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport function AlertDialogDescription(props: AlertDialogDescriptionProps) {\n return useDialogDescription(props, \"AlertDialog\");\n}\n\nAlertDialogDescription.displayName = \"AlertDialogDescription\";\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,uBAAuB,OAAoC;CACzE,OAAO,qBAAqB,OAAO,aAAa;AAClD;AAEA,uBAAuB,cAAc"}
@@ -0,0 +1,27 @@
1
+ import { DialogFormProps, DialogFormState } from "../dialog/dialog-form.mjs";
2
+ //#region src/alert-dialog/alert-dialog-form.d.ts
3
+ /** State of `AlertDialog.Form`: Dialog's (`useFormStatus().pending` of this form). */
4
+ export type AlertDialogFormState = DialogFormState;
5
+ /**
6
+ * Props of `AlertDialog.Form`: `Dialog.Form`'s.
7
+ *
8
+ * @see https://ui.funstack.work/components/alert-dialog
9
+ */
10
+ export type AlertDialogFormProps = DialogFormProps;
11
+ /**
12
+ * The confirm that works without JavaScript (design 6): `Dialog.Form`, unchanged. With a
13
+ * function `action` (a Server Function) and a plain submit button, the form posts before
14
+ * hydration through React's progressive enhancement; after hydration React runs the action and
15
+ * the dialog closes when its transition settles (`closeOnSettle`). Without `action`:
16
+ * `method="dialog"`.
17
+ *
18
+ * Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
19
+ *
20
+ * @see https://ui.funstack.work/components/alert-dialog
21
+ */
22
+ export declare function AlertDialogForm(props: AlertDialogFormProps): import("react").ReactNode;
23
+ export declare namespace AlertDialogForm {
24
+ var displayName: string;
25
+ }
26
+ //#endregion
27
+ //# sourceMappingURL=alert-dialog-form.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-form.d.mts","names":[],"sources":["../../src/alert-dialog/alert-dialog-form.tsx"],"mappings":";;;YAKY,uBAAuB;;;;;;YAOvB,uBAAuB;;;;;;;;;;;;wBAanB,gBAAgB,OAAO,uCAAoB;yBAA3C"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useDialogForm } from "../dialog/dialog-form.mjs";
3
+ //#region src/alert-dialog/alert-dialog-form.tsx
4
+ /**
5
+ * The confirm that works without JavaScript (design 6): `Dialog.Form`, unchanged. With a
6
+ * function `action` (a Server Function) and a plain submit button, the form posts before
7
+ * hydration through React's progressive enhancement; after hydration React runs the action and
8
+ * the dialog closes when its transition settles (`closeOnSettle`). Without `action`:
9
+ * `method="dialog"`.
10
+ *
11
+ * Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
12
+ *
13
+ * @see https://ui.funstack.work/components/alert-dialog
14
+ */
15
+ function AlertDialogForm(props) {
16
+ return useDialogForm(props, "AlertDialog");
17
+ }
18
+ AlertDialogForm.displayName = "AlertDialogForm";
19
+ //#endregion
20
+ export { AlertDialogForm };
21
+
22
+ //# sourceMappingURL=alert-dialog-form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-form.mjs","names":[],"sources":["../../src/alert-dialog/alert-dialog-form.tsx"],"sourcesContent":["\"use client\";\nimport { useDialogForm } from \"../dialog/dialog-form.js\";\nimport type { DialogFormProps, DialogFormState } from \"../dialog/dialog-form.js\";\n\n/** State of `AlertDialog.Form`: Dialog's (`useFormStatus().pending` of this form). */\nexport type AlertDialogFormState = DialogFormState;\n\n/**\n * Props of `AlertDialog.Form`: `Dialog.Form`'s.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport type AlertDialogFormProps = DialogFormProps;\n\n/**\n * The confirm that works without JavaScript (design 6): `Dialog.Form`, unchanged. With a\n * function `action` (a Server Function) and a plain submit button, the form posts before\n * hydration through React's progressive enhancement; after hydration React runs the action and\n * the dialog closes when its transition settles (`closeOnSettle`). Without `action`:\n * `method=\"dialog\"`.\n *\n * Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.\n *\n * @see https://ui.funstack.work/components/alert-dialog\n */\nexport function AlertDialogForm(props: AlertDialogFormProps) {\n return useDialogForm(props, \"AlertDialog\");\n}\n\nAlertDialogForm.displayName = \"AlertDialogForm\";\n"],"mappings":";;;;;;;;;;;;;;AAyBA,SAAgB,gBAAgB,OAA6B;CAC3D,OAAO,cAAc,OAAO,aAAa;AAC3C;AAEA,gBAAgB,cAAc"}
@@ -0,0 +1,42 @@
1
+ import { DialogPopupProps, DialogPopupState } from "../dialog/dialog-popup.mjs";
2
+ import { ReactNode, RefObject } from "react";
3
+ //#region src/alert-dialog/alert-dialog-popup.d.ts
4
+ /** State of `AlertDialog.Popup`: Dialog's, with `modal` always `true`. */
5
+ export type AlertDialogPopupState = DialogPopupState;
6
+ /**
7
+ * Props of `AlertDialog.Popup`: `Dialog.Popup`'s without `role` (owned: `alertdialog`),
8
+ * `lightDismiss` and `experimental_closedBy` (a click on the backdrop never closes an alert
9
+ * dialog).
10
+ *
11
+ * @see https://ui.funstack.work/components/alert-dialog
12
+ */
13
+ export interface AlertDialogPopupProps extends Omit<DialogPopupProps, "role" | "lightDismiss" | "experimental_closedBy"> {
14
+ /**
15
+ * Element to focus when the dialog opens: a ref, or a selector resolved inside the dialog.
16
+ * With it, no Cancel renders `autofocus`. Point it at the Title with `tabIndex={-1}` for a
17
+ * long message, so that it is read from the top (APG).
18
+ *
19
+ * @defaultValue the first enabled `AlertDialog.Cancel`; without one, the platform's choice
20
+ * (the first focusable element)
21
+ */
22
+ initialFocus?: RefObject<HTMLElement | null> | string;
23
+ }
24
+ /**
25
+ * The alert dialog: `Dialog.Popup` rendering `<dialog role="alertdialog">`, always opened with
26
+ * `showModal()`, without light dismiss (a modal `<dialog>` without `closedby` closes on Escape and
27
+ * not on a backdrop click, in every engine and before hydration). Escape closes it: the
28
+ * platform's close request, reported to `onOpenChange(false, { reason: "dismiss" })`; there is no
29
+ * prop to turn it off. Opens with focus on the first enabled `AlertDialog.Cancel` unless
30
+ * `initialFocus` is given.
31
+ *
32
+ * Owned keys (conventions 1.2): Dialog.Popup's (`id`, `open`, `closedby`, `aria-labelledby` and
33
+ * `aria-describedby` token-merged, `data-modal`, `suppressHydrationWarning`) and `role`.
34
+ *
35
+ * @see https://ui.funstack.work/components/alert-dialog
36
+ */
37
+ export declare function AlertDialogPopup(props: AlertDialogPopupProps): ReactNode;
38
+ export declare namespace AlertDialogPopup {
39
+ var displayName: string;
40
+ }
41
+ //#endregion
42
+ //# sourceMappingURL=alert-dialog-popup.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dialog-popup.d.mts","names":[],"sources":["../../src/alert-dialog/alert-dialog-popup.tsx"],"mappings":";;;;YAaY,wBAAwB;;;;;;;;iBASnB,8BAA8B,KAC7C;;;;;;;;;EAWA,eAAe,UAAU;;;;;;;;;;;;;;;wBAgBX,iBAAiB,OAAO,wBAAqB;yBAA7C"}