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

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 (176) hide show
  1. package/dist/alert-dialog/alert-dialog-root.mjs +2 -1
  2. package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -1
  3. package/dist/avatar/avatar-context.mjs +24 -0
  4. package/dist/avatar/avatar-context.mjs.map +1 -0
  5. package/dist/avatar/avatar-fallback.d.mts +32 -0
  6. package/dist/avatar/avatar-fallback.d.mts.map +1 -0
  7. package/dist/avatar/avatar-fallback.mjs +31 -0
  8. package/dist/avatar/avatar-fallback.mjs.map +1 -0
  9. package/dist/avatar/avatar-image.d.mts +37 -0
  10. package/dist/avatar/avatar-image.d.mts.map +1 -0
  11. package/dist/avatar/avatar-image.mjs +91 -0
  12. package/dist/avatar/avatar-image.mjs.map +1 -0
  13. package/dist/avatar/avatar-root.d.mts +48 -0
  14. package/dist/avatar/avatar-root.d.mts.map +1 -0
  15. package/dist/avatar/avatar-root.mjs +81 -0
  16. package/dist/avatar/avatar-root.mjs.map +1 -0
  17. package/dist/avatar/index.d.mts +24 -0
  18. package/dist/avatar/index.d.mts.map +1 -0
  19. package/dist/avatar/index.mjs +24 -0
  20. package/dist/avatar/index.mjs.map +1 -0
  21. package/dist/dialog/dialog-close.d.mts.map +1 -1
  22. package/dist/dialog/dialog-close.mjs +14 -3
  23. package/dist/dialog/dialog-close.mjs.map +1 -1
  24. package/dist/dialog/dialog-context.mjs +7 -1
  25. package/dist/dialog/dialog-context.mjs.map +1 -1
  26. package/dist/dialog/dialog-popup.d.mts +1 -0
  27. package/dist/dialog/dialog-popup.d.mts.map +1 -1
  28. package/dist/dialog/dialog-popup.mjs +20 -2
  29. package/dist/dialog/dialog-popup.mjs.map +1 -1
  30. package/dist/dialog/dialog-root.mjs +6 -4
  31. package/dist/dialog/dialog-root.mjs.map +1 -1
  32. package/dist/docs/components/avatar.md +354 -0
  33. package/dist/docs/components/drawer.md +622 -0
  34. package/dist/docs/components/menu.md +1 -1
  35. package/dist/docs/components/menubar.md +309 -0
  36. package/dist/docs/components/meter.md +1 -1
  37. package/dist/docs/components/navigation-menu.md +501 -0
  38. package/dist/docs/components/number-field.md +2 -2
  39. package/dist/docs/components/otp-field.md +508 -0
  40. package/dist/docs/components/progress.md +1 -1
  41. package/dist/docs/components/radio-group.md +1 -1
  42. package/dist/docs/components/scroll-area.md +294 -0
  43. package/dist/docs/components/slider.md +1 -1
  44. package/dist/docs/concepts/direction-and-locales.md +106 -0
  45. package/dist/docs/index.md +8 -1
  46. package/dist/docs/roadmap.md +13 -0
  47. package/dist/drawer/drawer-close.d.mts +26 -0
  48. package/dist/drawer/drawer-close.d.mts.map +1 -0
  49. package/dist/drawer/drawer-close.mjs +19 -0
  50. package/dist/drawer/drawer-close.mjs.map +1 -0
  51. package/dist/drawer/drawer-description.d.mts +23 -0
  52. package/dist/drawer/drawer-description.d.mts.map +1 -0
  53. package/dist/drawer/drawer-description.mjs +18 -0
  54. package/dist/drawer/drawer-description.mjs.map +1 -0
  55. package/dist/drawer/drawer-form.d.mts +24 -0
  56. package/dist/drawer/drawer-form.d.mts.map +1 -0
  57. package/dist/drawer/drawer-form.mjs +19 -0
  58. package/dist/drawer/drawer-form.mjs.map +1 -0
  59. package/dist/drawer/drawer-popup.d.mts +77 -0
  60. package/dist/drawer/drawer-popup.d.mts.map +1 -0
  61. package/dist/drawer/drawer-popup.mjs +124 -0
  62. package/dist/drawer/drawer-popup.mjs.map +1 -0
  63. package/dist/drawer/drawer-root.d.mts +31 -0
  64. package/dist/drawer/drawer-root.d.mts.map +1 -0
  65. package/dist/drawer/drawer-root.mjs +23 -0
  66. package/dist/drawer/drawer-root.mjs.map +1 -0
  67. package/dist/drawer/drawer-swipe.d.mts +5 -0
  68. package/dist/drawer/drawer-swipe.d.mts.map +1 -0
  69. package/dist/drawer/drawer-swipe.mjs +193 -0
  70. package/dist/drawer/drawer-swipe.mjs.map +1 -0
  71. package/dist/drawer/drawer-title.d.mts +23 -0
  72. package/dist/drawer/drawer-title.d.mts.map +1 -0
  73. package/dist/drawer/drawer-title.mjs +18 -0
  74. package/dist/drawer/drawer-title.mjs.map +1 -0
  75. package/dist/drawer/drawer-trigger.d.mts +23 -0
  76. package/dist/drawer/drawer-trigger.d.mts.map +1 -0
  77. package/dist/drawer/drawer-trigger.mjs +18 -0
  78. package/dist/drawer/drawer-trigger.mjs.map +1 -0
  79. package/dist/drawer/index.d.mts +34 -0
  80. package/dist/drawer/index.d.mts.map +1 -0
  81. package/dist/drawer/index.mjs +33 -0
  82. package/dist/drawer/index.mjs.map +1 -0
  83. package/dist/index.d.mts +29 -2
  84. package/dist/index.mjs +6 -1
  85. package/dist/internal/menubar-context.mjs +12 -0
  86. package/dist/internal/menubar-context.mjs.map +1 -0
  87. package/dist/internal/overlay/trigger-ref.mjs +1 -1
  88. package/dist/internal/overlay/trigger-ref.mjs.map +1 -1
  89. package/dist/internal/overlay/use-overlay-root.mjs +3 -2
  90. package/dist/internal/overlay/use-overlay-root.mjs.map +1 -1
  91. package/dist/internal/overlay/use-popover-trigger.mjs +2 -2
  92. package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -1
  93. package/dist/internal/range-value.mjs +5 -3
  94. package/dist/internal/range-value.mjs.map +1 -1
  95. package/dist/internal/swipe-arithmetic.mjs +75 -0
  96. package/dist/internal/swipe-arithmetic.mjs.map +1 -0
  97. package/dist/internal/swipe.mjs +169 -0
  98. package/dist/internal/swipe.mjs.map +1 -0
  99. package/dist/menu/menu-context-trigger.mjs +1 -1
  100. package/dist/menu/menu-popup.d.mts.map +1 -1
  101. package/dist/menu/menu-popup.mjs +34 -7
  102. package/dist/menu/menu-popup.mjs.map +1 -1
  103. package/dist/menu/menu-trigger.d.mts +10 -3
  104. package/dist/menu/menu-trigger.d.mts.map +1 -1
  105. package/dist/menu/menu-trigger.mjs +53 -5
  106. package/dist/menu/menu-trigger.mjs.map +1 -1
  107. package/dist/menubar/index.d.mts +3 -0
  108. package/dist/menubar/index.mjs +1 -0
  109. package/dist/menubar/menubar.d.mts +49 -0
  110. package/dist/menubar/menubar.d.mts.map +1 -0
  111. package/dist/menubar/menubar.mjs +147 -0
  112. package/dist/menubar/menubar.mjs.map +1 -0
  113. package/dist/meter/meter-root.d.mts +3 -2
  114. package/dist/meter/meter-root.d.mts.map +1 -1
  115. package/dist/meter/meter-root.mjs.map +1 -1
  116. package/dist/multi-select/multi-select-root.mjs +1 -1
  117. package/dist/multi-select/multi-select-trigger.mjs +1 -1
  118. package/dist/navigation-menu/index.d.mts +32 -0
  119. package/dist/navigation-menu/index.d.mts.map +1 -0
  120. package/dist/navigation-menu/index.mjs +32 -0
  121. package/dist/navigation-menu/index.mjs.map +1 -0
  122. package/dist/navigation-menu/navigation-menu-context.mjs +19 -0
  123. package/dist/navigation-menu/navigation-menu-context.mjs.map +1 -0
  124. package/dist/navigation-menu/navigation-menu-item.d.mts +79 -0
  125. package/dist/navigation-menu/navigation-menu-item.d.mts.map +1 -0
  126. package/dist/navigation-menu/navigation-menu-item.mjs +80 -0
  127. package/dist/navigation-menu/navigation-menu-item.mjs.map +1 -0
  128. package/dist/navigation-menu/navigation-menu-link.d.mts +48 -0
  129. package/dist/navigation-menu/navigation-menu-link.d.mts.map +1 -0
  130. package/dist/navigation-menu/navigation-menu-link.mjs +66 -0
  131. package/dist/navigation-menu/navigation-menu-link.mjs.map +1 -0
  132. package/dist/navigation-menu/navigation-menu-list.d.mts +33 -0
  133. package/dist/navigation-menu/navigation-menu-list.d.mts.map +1 -0
  134. package/dist/navigation-menu/navigation-menu-list.mjs +30 -0
  135. package/dist/navigation-menu/navigation-menu-list.mjs.map +1 -0
  136. package/dist/navigation-menu/navigation-menu-popup.d.mts +102 -0
  137. package/dist/navigation-menu/navigation-menu-popup.d.mts.map +1 -0
  138. package/dist/navigation-menu/navigation-menu-popup.mjs +93 -0
  139. package/dist/navigation-menu/navigation-menu-popup.mjs.map +1 -0
  140. package/dist/navigation-menu/navigation-menu-root.d.mts +33 -0
  141. package/dist/navigation-menu/navigation-menu-root.d.mts.map +1 -0
  142. package/dist/navigation-menu/navigation-menu-root.mjs +27 -0
  143. package/dist/navigation-menu/navigation-menu-root.mjs.map +1 -0
  144. package/dist/navigation-menu/navigation-menu-trigger.d.mts +32 -0
  145. package/dist/navigation-menu/navigation-menu-trigger.d.mts.map +1 -0
  146. package/dist/navigation-menu/navigation-menu-trigger.mjs +42 -0
  147. package/dist/navigation-menu/navigation-menu-trigger.mjs.map +1 -0
  148. package/dist/otp-field/index.d.mts +23 -0
  149. package/dist/otp-field/index.d.mts.map +1 -0
  150. package/dist/otp-field/index.mjs +23 -0
  151. package/dist/otp-field/index.mjs.map +1 -0
  152. package/dist/otp-field/otp-field-context.mjs +13 -0
  153. package/dist/otp-field/otp-field-context.mjs.map +1 -0
  154. package/dist/otp-field/otp-field-filter.d.mts +5 -0
  155. package/dist/otp-field/otp-field-filter.d.mts.map +1 -0
  156. package/dist/otp-field/otp-field-filter.mjs +135 -0
  157. package/dist/otp-field/otp-field-filter.mjs.map +1 -0
  158. package/dist/otp-field/otp-field-input.d.mts +41 -0
  159. package/dist/otp-field/otp-field-input.d.mts.map +1 -0
  160. package/dist/otp-field/otp-field-input.mjs +177 -0
  161. package/dist/otp-field/otp-field-input.mjs.map +1 -0
  162. package/dist/otp-field/otp-field-root.d.mts +152 -0
  163. package/dist/otp-field/otp-field-root.d.mts.map +1 -0
  164. package/dist/otp-field/otp-field-root.mjs +400 -0
  165. package/dist/otp-field/otp-field-root.mjs.map +1 -0
  166. package/dist/otp-field/otp-field-slot.d.mts +52 -0
  167. package/dist/otp-field/otp-field-slot.d.mts.map +1 -0
  168. package/dist/otp-field/otp-field-slot.mjs +67 -0
  169. package/dist/otp-field/otp-field-slot.mjs.map +1 -0
  170. package/dist/popover/index.d.mts +1 -1
  171. package/dist/popover/popover-trigger.mjs +1 -1
  172. package/dist/progress/progress-root.d.mts +3 -2
  173. package/dist/progress/progress-root.d.mts.map +1 -1
  174. package/dist/progress/progress-root.mjs.map +1 -1
  175. package/package.json +7 -1
  176. package/skills/funstack-ui-knowledge/SKILL.md +8 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer-trigger.d.mts","names":[],"sources":["../../src/drawer/drawer-trigger.tsx"],"mappings":";;;YAKY,qBAAqB;;;;;;YAOrB,qBAAqB;;;;;;;;wBASjB,cAAc,OAAO,qCAAkB;yBAAvC"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useDialogTrigger } from "../dialog/dialog-trigger.mjs";
3
+ //#region src/drawer/drawer-trigger.tsx
4
+ /**
5
+ * The opener: exactly `Dialog.Trigger` (`<button type="button" commandfor command="show-modal">`
6
+ * for a modal drawer). JS-free mode: the browser runs the command. Library mode: the click is a
7
+ * request through the Root (`data-pending` until the drawer has opened).
8
+ *
9
+ * @see https://ui.funstack.work/components/drawer
10
+ */
11
+ function DrawerTrigger(props) {
12
+ return useDialogTrigger(props, "Drawer");
13
+ }
14
+ DrawerTrigger.displayName = "DrawerTrigger";
15
+ //#endregion
16
+ export { DrawerTrigger };
17
+
18
+ //# sourceMappingURL=drawer-trigger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer-trigger.mjs","names":[],"sources":["../../src/drawer/drawer-trigger.tsx"],"sourcesContent":["\"use client\";\nimport { useDialogTrigger } from \"../dialog/dialog-trigger.js\";\nimport type { DialogTriggerProps, DialogTriggerState } from \"../dialog/dialog-trigger.js\";\n\n/** State of `Drawer.Trigger`: Dialog's. */\nexport type DrawerTriggerState = DialogTriggerState;\n\n/**\n * Props of `Drawer.Trigger`: `Dialog.Trigger`'s.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport type DrawerTriggerProps = DialogTriggerProps;\n\n/**\n * The opener: exactly `Dialog.Trigger` (`<button type=\"button\" commandfor command=\"show-modal\">`\n * for a modal drawer). JS-free mode: the browser runs the command. Library mode: the click is a\n * request through the Root (`data-pending` until the drawer has opened).\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport function DrawerTrigger(props: DrawerTriggerProps) {\n return useDialogTrigger(props, \"Drawer\");\n}\n\nDrawerTrigger.displayName = \"DrawerTrigger\";\n"],"mappings":";;;;;;;;;;AAqBA,SAAgB,cAAc,OAA2B;CACvD,OAAO,iBAAiB,OAAO,QAAQ;AACzC;AAEA,cAAc,cAAc"}
@@ -0,0 +1,34 @@
1
+ import "../internal/platform-attributes.mjs";
2
+ import { DrawerClose, DrawerCloseDetails, DrawerCloseProps, DrawerCloseState } from "./drawer-close.mjs";
3
+ import { DrawerDescription, DrawerDescriptionProps, DrawerDescriptionState } from "./drawer-description.mjs";
4
+ import { DrawerForm, DrawerFormProps, DrawerFormState } from "./drawer-form.mjs";
5
+ import { DrawerSide } from "./drawer-swipe.mjs";
6
+ import { DrawerPopup, DrawerPopupProps, DrawerPopupState } from "./drawer-popup.mjs";
7
+ import { DrawerOpenChangeDetails, DrawerRoot, DrawerRootProps, DrawerRootState } from "./drawer-root.mjs";
8
+ import { DrawerTitle, DrawerTitleProps, DrawerTitleState } from "./drawer-title.mjs";
9
+ import { DrawerTrigger, DrawerTriggerProps, DrawerTriggerState } from "./drawer-trigger.mjs";
10
+ //#region src/drawer/index.d.ts
11
+ /**
12
+ * A Dialog attached to an edge of the viewport that the user can swipe back to it: `Root` (no
13
+ * DOM) > `Trigger` + `Popup` (`dialog[data-side]`) > `Title`, `Description`, `Close`, `Form`.
14
+ * Every part runs the code of the matching Dialog part (JS-free mode included). The Popup adds
15
+ * `side` (default `"bottom"`, rendered as `data-side`; your CSS places it) and `swipeDismiss`
16
+ * (default on): a drag toward the edge writes `data-swiping` and `--drawer-swipe-x` / `-y` /
17
+ * `-progress`, and a release past a quarter or a flick slides the drawer out and closes it, a
18
+ * dismissal reported to `onOpenChange`. `lightDismiss` defaults to the Root's `modal`.
19
+ * Transition types: `fsui-drawer`, `fsui-drawer-open`, `fsui-drawer-close`.
20
+ *
21
+ * @see https://ui.funstack.work/components/drawer
22
+ */
23
+ export declare const Drawer: {
24
+ readonly Root: typeof DrawerRoot;
25
+ readonly Trigger: typeof DrawerTrigger;
26
+ readonly Popup: typeof DrawerPopup;
27
+ readonly Title: typeof DrawerTitle;
28
+ readonly Description: typeof DrawerDescription;
29
+ readonly Close: typeof DrawerClose;
30
+ readonly Form: typeof DrawerForm;
31
+ };
32
+ //#endregion
33
+ export type { DrawerCloseDetails, DrawerCloseProps, DrawerCloseState, DrawerDescriptionProps, DrawerDescriptionState, DrawerFormProps, DrawerFormState, DrawerOpenChangeDetails, DrawerPopupProps, DrawerPopupState, DrawerRootProps, DrawerRootState, DrawerSide, DrawerTitleProps, DrawerTitleState, DrawerTriggerProps, DrawerTriggerState };
34
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/drawer/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;qBAuBa;WACX,aAAI;WACJ,gBAAO;WACP,cAAK;WACL,cAAK;WACL,oBAAW;WACX,cAAK;WACL,aAAI"}
@@ -0,0 +1,33 @@
1
+ import { DrawerClose } from "./drawer-close.mjs";
2
+ import { DrawerDescription } from "./drawer-description.mjs";
3
+ import { DrawerForm } from "./drawer-form.mjs";
4
+ import { DrawerPopup } from "./drawer-popup.mjs";
5
+ import { DrawerRoot } from "./drawer-root.mjs";
6
+ import { DrawerTitle } from "./drawer-title.mjs";
7
+ import { DrawerTrigger } from "./drawer-trigger.mjs";
8
+ //#region src/drawer/index.ts
9
+ /**
10
+ * A Dialog attached to an edge of the viewport that the user can swipe back to it: `Root` (no
11
+ * DOM) > `Trigger` + `Popup` (`dialog[data-side]`) > `Title`, `Description`, `Close`, `Form`.
12
+ * Every part runs the code of the matching Dialog part (JS-free mode included). The Popup adds
13
+ * `side` (default `"bottom"`, rendered as `data-side`; your CSS places it) and `swipeDismiss`
14
+ * (default on): a drag toward the edge writes `data-swiping` and `--drawer-swipe-x` / `-y` /
15
+ * `-progress`, and a release past a quarter or a flick slides the drawer out and closes it, a
16
+ * dismissal reported to `onOpenChange`. `lightDismiss` defaults to the Root's `modal`.
17
+ * Transition types: `fsui-drawer`, `fsui-drawer-open`, `fsui-drawer-close`.
18
+ *
19
+ * @see https://ui.funstack.work/components/drawer
20
+ */
21
+ const Drawer = {
22
+ Root: DrawerRoot,
23
+ Trigger: DrawerTrigger,
24
+ Popup: DrawerPopup,
25
+ Title: DrawerTitle,
26
+ Description: DrawerDescription,
27
+ Close: DrawerClose,
28
+ Form: DrawerForm
29
+ };
30
+ //#endregion
31
+ export { Drawer };
32
+
33
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/drawer/index.ts"],"sourcesContent":["// Ships the platform attribute typings (`command`, `commandfor`) with this subpath\n// (conventions 7.4). Type-only: the built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { DrawerClose } from \"./drawer-close.js\";\nimport { DrawerDescription } from \"./drawer-description.js\";\nimport { DrawerForm } from \"./drawer-form.js\";\nimport { DrawerPopup } from \"./drawer-popup.js\";\nimport { DrawerRoot } from \"./drawer-root.js\";\nimport { DrawerTitle } from \"./drawer-title.js\";\nimport { DrawerTrigger } from \"./drawer-trigger.js\";\n\n/**\n * A Dialog attached to an edge of the viewport that the user can swipe back to it: `Root` (no\n * DOM) > `Trigger` + `Popup` (`dialog[data-side]`) > `Title`, `Description`, `Close`, `Form`.\n * Every part runs the code of the matching Dialog part (JS-free mode included). The Popup adds\n * `side` (default `\"bottom\"`, rendered as `data-side`; your CSS places it) and `swipeDismiss`\n * (default on): a drag toward the edge writes `data-swiping` and `--drawer-swipe-x` / `-y` /\n * `-progress`, and a release past a quarter or a flick slides the drawer out and closes it, a\n * dismissal reported to `onOpenChange`. `lightDismiss` defaults to the Root's `modal`.\n * Transition types: `fsui-drawer`, `fsui-drawer-open`, `fsui-drawer-close`.\n *\n * @see https://ui.funstack.work/components/drawer\n */\nexport const Drawer = {\n Root: DrawerRoot,\n Trigger: DrawerTrigger,\n Popup: DrawerPopup,\n Title: DrawerTitle,\n Description: DrawerDescription,\n Close: DrawerClose,\n Form: DrawerForm,\n} as const;\n\nexport type { DrawerRootProps, DrawerRootState, DrawerOpenChangeDetails } from \"./drawer-root.js\";\nexport type { DrawerTriggerProps, DrawerTriggerState } from \"./drawer-trigger.js\";\nexport type { DrawerPopupProps, DrawerPopupState, DrawerSide } from \"./drawer-popup.js\";\nexport type { DrawerTitleProps, DrawerTitleState } from \"./drawer-title.js\";\nexport type { DrawerDescriptionProps, DrawerDescriptionState } from \"./drawer-description.js\";\nexport type { DrawerCloseProps, DrawerCloseState, DrawerCloseDetails } from \"./drawer-close.js\";\nexport type { DrawerFormProps, DrawerFormState } from \"./drawer-form.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,MAAM;AACR"}
package/dist/index.d.mts CHANGED
@@ -21,6 +21,10 @@ import { AlertDialogTitleProps, AlertDialogTitleState } from "./alert-dialog/ale
21
21
  import { DialogTriggerProps, DialogTriggerState } from "./dialog/dialog-trigger.mjs";
22
22
  import { AlertDialogTriggerProps, AlertDialogTriggerState } from "./alert-dialog/alert-dialog-trigger.mjs";
23
23
  import { AlertDialog } from "./alert-dialog/index.mjs";
24
+ import { AvatarRootProps, AvatarState, AvatarStatus } from "./avatar/avatar-root.mjs";
25
+ import { AvatarFallbackProps } from "./avatar/avatar-fallback.mjs";
26
+ import { AvatarImageProps } from "./avatar/avatar-image.mjs";
27
+ import { Avatar } from "./avatar/index.mjs";
24
28
  import { Button, ButtonActionDetails, ButtonProps, ButtonState } from "./button/button.mjs";
25
29
  import "./button/index.mjs";
26
30
  import { CheckboxGroupItemProps, CheckboxGroupItemState } from "./checkbox-group/checkbox-group-item.mjs";
@@ -49,6 +53,15 @@ import { CSPProvider, CSPProviderProps } from "./csp/csp-provider.mjs";
49
53
  import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
50
54
  import "./csp/index.mjs";
51
55
  import { Dialog } from "./dialog/index.mjs";
56
+ import { DrawerCloseDetails, DrawerCloseProps, DrawerCloseState } from "./drawer/drawer-close.mjs";
57
+ import { DrawerDescriptionProps, DrawerDescriptionState } from "./drawer/drawer-description.mjs";
58
+ import { DrawerFormProps, DrawerFormState } from "./drawer/drawer-form.mjs";
59
+ import { DrawerSide } from "./drawer/drawer-swipe.mjs";
60
+ import { DrawerPopupProps, DrawerPopupState } from "./drawer/drawer-popup.mjs";
61
+ import { DrawerOpenChangeDetails, DrawerRootProps, DrawerRootState } from "./drawer/drawer-root.mjs";
62
+ import { DrawerTitleProps, DrawerTitleState } from "./drawer/drawer-title.mjs";
63
+ import { DrawerTriggerProps, DrawerTriggerState } from "./drawer/drawer-trigger.mjs";
64
+ import { Drawer } from "./drawer/index.mjs";
52
65
  import { FieldErrorValue, FieldValidity, FormErrors } from "./internal/form/validity.mjs";
53
66
  import { FieldState } from "./internal/form/field-context.mjs";
54
67
  import { FieldControlProps } from "./field/field-control.mjs";
@@ -88,6 +101,14 @@ import { TooltipPopupProps, TooltipPopupState } from "./tooltip/tooltip-popup.mj
88
101
  import { TooltipRootProps, TooltipRootState } from "./tooltip/tooltip-root.mjs";
89
102
  import { TooltipTriggerProps, TooltipTriggerState } from "./tooltip/tooltip-trigger.mjs";
90
103
  import { Tooltip } from "./tooltip/index.mjs";
104
+ import { NavigationMenuItemProps, NavigationMenuItemState, NavigationMenuOpenChangeDetails } from "./navigation-menu/navigation-menu-item.mjs";
105
+ import { NavigationMenuLinkProps, NavigationMenuLinkState } from "./navigation-menu/navigation-menu-link.mjs";
106
+ import { NavigationMenuListProps, NavigationMenuListState } from "./navigation-menu/navigation-menu-list.mjs";
107
+ import { NavigationMenuAlign, NavigationMenuPopupProps, NavigationMenuPopupState, NavigationMenuSide } from "./navigation-menu/navigation-menu-popup.mjs";
108
+ import { NavigationMenuRootProps, NavigationMenuRootState } from "./navigation-menu/navigation-menu-root.mjs";
109
+ import { PopoverTriggerProps, PopoverTriggerState } from "./popover/popover-trigger.mjs";
110
+ import { NavigationMenuTriggerProps, NavigationMenuTriggerState } from "./navigation-menu/navigation-menu-trigger.mjs";
111
+ import { NavigationMenu } from "./navigation-menu/index.mjs";
91
112
  import { Switch, SwitchCheckedChangeDetails, SwitchProps, SwitchState } from "./switch/switch.mjs";
92
113
  import "./switch/index.mjs";
93
114
  import { PopoverCloseProps, PopoverCloseState } from "./popover/popover-close.mjs";
@@ -95,7 +116,6 @@ import { PopoverAlign, PopoverPopupProps, PopoverPopupState, PopoverSide } from
95
116
  import { PopoverDescriptionProps, PopoverDescriptionState } from "./popover/popover-description.mjs";
96
117
  import { PopoverOpenChangeDetails, PopoverRootProps, PopoverRootState } from "./popover/popover-root.mjs";
97
118
  import { PopoverTitleProps, PopoverTitleState } from "./popover/popover-title.mjs";
98
- import { PopoverTriggerProps, PopoverTriggerState } from "./popover/popover-trigger.mjs";
99
119
  import { Popover } from "./popover/index.mjs";
100
120
  import { MenuItemDetails, MenuItemProps, MenuItemState } from "./menu/menu-item.mjs";
101
121
  import { MenuCheckboxItemProps, MenuCheckboxItemState } from "./menu/menu-checkbox-item.mjs";
@@ -108,6 +128,8 @@ import { MenuRadioItemProps, MenuRadioItemState } from "./menu/menu-radio-item.m
108
128
  import { MenuOpenChangeDetails, MenuRootProps, MenuRootState } from "./menu/menu-root.mjs";
109
129
  import { MenuSubmenuTriggerProps, MenuSubmenuTriggerState } from "./menu/menu-submenu-trigger.mjs";
110
130
  import { Menu } from "./menu/index.mjs";
131
+ import { Menubar, MenubarProps, MenubarState } from "./menubar/menubar.mjs";
132
+ import "./menubar/index.mjs";
111
133
  import { RadioGroupItemProps, RadioGroupItemState } from "./radio-group/radio-group-item.mjs";
112
134
  import { RadioGroupRootProps, RadioGroupRootState, RadioGroupValueChangeDetails } from "./radio-group/radio-group-root.mjs";
113
135
  import { RadioGroupLabelProps } from "./radio-group/radio-group-label.mjs";
@@ -149,6 +171,11 @@ import { NumberFieldButtonState, NumberFieldDecrementProps, NumberFieldIncrement
149
171
  import { NumberFieldInputProps } from "./number-field/number-field-input.mjs";
150
172
  import { NumberFieldLabelProps } from "./number-field/number-field-label.mjs";
151
173
  import { NumberField } from "./number-field/index.mjs";
174
+ import { OTPFieldCharset } from "./otp-field/otp-field-filter.mjs";
175
+ import { OTPFieldCompleteDetails, OTPFieldRootProps, OTPFieldState, OTPFieldValueChangeDetails } from "./otp-field/otp-field-root.mjs";
176
+ import { OTPFieldInputProps } from "./otp-field/otp-field-input.mjs";
177
+ import { OTPFieldSlotProps, OTPFieldSlotState } from "./otp-field/otp-field-slot.mjs";
178
+ import { OTPField } from "./otp-field/index.mjs";
152
179
  import { ProgressRootProps, ProgressState } from "./progress/progress-root.mjs";
153
180
  import { ProgressIndicatorProps } from "./progress/progress-indicator.mjs";
154
181
  import { ProgressLabelProps } from "./progress/progress-label.mjs";
@@ -162,4 +189,4 @@ import { MeterLabelProps } from "./meter/meter-label.mjs";
162
189
  import { MeterTrackProps } from "./meter/meter-track.mjs";
163
190
  import { MeterValueProps } from "./meter/meter-value.mjs";
164
191
  import { Meter } from "./meter/index.mjs";
165
- export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, AlertDialog, type AlertDialogActionDetails, type AlertDialogActionProps, type AlertDialogActionState, type AlertDialogCancelDetails, type AlertDialogCancelProps, type AlertDialogCancelState, type AlertDialogDescriptionProps, type AlertDialogDescriptionState, type AlertDialogFormProps, type AlertDialogFormState, type AlertDialogOpenChangeDetails, type AlertDialogPopupProps, type AlertDialogPopupState, type AlertDialogRootProps, type AlertDialogRootState, type AlertDialogTitleProps, type AlertDialogTitleState, type AlertDialogTriggerProps, type AlertDialogTriggerState, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Collapsible, type CollapsibleOpenChangeDetails, type CollapsiblePanelProps, type CollapsiblePanelState, type CollapsibleRootProps, type CollapsibleRootState, type CollapsibleTriggerProps, type CollapsibleTriggerState, Combobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxChipRemoveState, type ComboboxChipState, type ComboboxChipsProps, type ComboboxChipsState, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxMultipleProps, type ComboboxMultipleRootState, type ComboboxMultipleValueChangeDetails, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxSingleProps, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, HoverCard, type HoverCardAlign, type HoverCardOpenChangeDetails, type HoverCardPopupProps, type HoverCardPopupState, type HoverCardRootProps, type HoverCardRootState, type HoverCardSide, type HoverCardTriggerProps, type HoverCardTriggerState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, MultiSelect, type MultiSelectEmptyProps, type MultiSelectEmptyState, type MultiSelectGroupLabelProps, type MultiSelectGroupLabelState, type MultiSelectGroupProps, type MultiSelectGroupState, type MultiSelectLabelProps, type MultiSelectLabelState, type MultiSelectListProps, type MultiSelectListState, type MultiSelectOpenChangeDetails, type MultiSelectOptionProps, type MultiSelectOptionState, type MultiSelectPopupProps, type MultiSelectPopupState, type MultiSelectRootProps, type MultiSelectRootState, type MultiSelectStatusProps, type MultiSelectStatusState, type MultiSelectTriggerProps, type MultiSelectTriggerState, type MultiSelectValueChangeDetails, type MultiSelectValueProps, type MultiSelectValueState, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, type SeparatorState, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
192
+ export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, AlertDialog, type AlertDialogActionDetails, type AlertDialogActionProps, type AlertDialogActionState, type AlertDialogCancelDetails, type AlertDialogCancelProps, type AlertDialogCancelState, type AlertDialogDescriptionProps, type AlertDialogDescriptionState, type AlertDialogFormProps, type AlertDialogFormState, type AlertDialogOpenChangeDetails, type AlertDialogPopupProps, type AlertDialogPopupState, type AlertDialogRootProps, type AlertDialogRootState, type AlertDialogTitleProps, type AlertDialogTitleState, type AlertDialogTriggerProps, type AlertDialogTriggerState, Avatar, type AvatarFallbackProps, type AvatarImageProps, type AvatarRootProps, type AvatarState, type AvatarStatus, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Collapsible, type CollapsibleOpenChangeDetails, type CollapsiblePanelProps, type CollapsiblePanelState, type CollapsibleRootProps, type CollapsibleRootState, type CollapsibleTriggerProps, type CollapsibleTriggerState, Combobox, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxChipRemoveState, type ComboboxChipState, type ComboboxChipsProps, type ComboboxChipsState, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxMultipleProps, type ComboboxMultipleRootState, type ComboboxMultipleValueChangeDetails, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxSingleProps, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Drawer, type DrawerCloseDetails, type DrawerCloseProps, type DrawerCloseState, type DrawerDescriptionProps, type DrawerDescriptionState, type DrawerFormProps, type DrawerFormState, type DrawerOpenChangeDetails, type DrawerPopupProps, type DrawerPopupState, type DrawerRootProps, type DrawerRootState, type DrawerSide, type DrawerTitleProps, type DrawerTitleState, type DrawerTriggerProps, type DrawerTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, HoverCard, type HoverCardAlign, type HoverCardOpenChangeDetails, type HoverCardPopupProps, type HoverCardPopupState, type HoverCardRootProps, type HoverCardRootState, type HoverCardSide, type HoverCardTriggerProps, type HoverCardTriggerState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Menubar, type MenubarProps, type MenubarState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, MultiSelect, type MultiSelectEmptyProps, type MultiSelectEmptyState, type MultiSelectGroupLabelProps, type MultiSelectGroupLabelState, type MultiSelectGroupProps, type MultiSelectGroupState, type MultiSelectLabelProps, type MultiSelectLabelState, type MultiSelectListProps, type MultiSelectListState, type MultiSelectOpenChangeDetails, type MultiSelectOptionProps, type MultiSelectOptionState, type MultiSelectPopupProps, type MultiSelectPopupState, type MultiSelectRootProps, type MultiSelectRootState, type MultiSelectStatusProps, type MultiSelectStatusState, type MultiSelectTriggerProps, type MultiSelectTriggerState, type MultiSelectValueChangeDetails, type MultiSelectValueProps, type MultiSelectValueState, NavigationMenu, type NavigationMenuAlign, type NavigationMenuItemProps, type NavigationMenuItemState, type NavigationMenuLinkProps, type NavigationMenuLinkState, type NavigationMenuListProps, type NavigationMenuListState, type NavigationMenuOpenChangeDetails, type NavigationMenuPopupProps, type NavigationMenuPopupState, type NavigationMenuRootProps, type NavigationMenuRootState, type NavigationMenuSide, type NavigationMenuTriggerProps, type NavigationMenuTriggerState, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, OTPField, type OTPFieldCharset, type OTPFieldCompleteDetails, type OTPFieldInputProps, type OTPFieldRootProps, type OTPFieldSlotProps, type OTPFieldSlotState, type OTPFieldState, type OTPFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, type SeparatorState, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, type UrgentHandler, type WhilePending, createToastManager, toast };
package/dist/index.mjs CHANGED
@@ -8,12 +8,15 @@ import { Collapsible } from "./collapsible/index.mjs";
8
8
  import { Tabs } from "./tabs/index.mjs";
9
9
  import { Tooltip } from "./tooltip/index.mjs";
10
10
  import { HoverCard } from "./hover-card/index.mjs";
11
+ import { NavigationMenu } from "./navigation-menu/index.mjs";
11
12
  import { Switch } from "./switch/switch.mjs";
12
13
  import { Checkbox } from "./checkbox/checkbox.mjs";
13
14
  import { Dialog } from "./dialog/index.mjs";
14
15
  import { AlertDialog } from "./alert-dialog/index.mjs";
16
+ import { Drawer } from "./drawer/index.mjs";
15
17
  import { Popover } from "./popover/index.mjs";
16
18
  import { Menu } from "./menu/index.mjs";
19
+ import { Menubar } from "./menubar/menubar.mjs";
17
20
  import { RadioGroup } from "./radio-group/index.mjs";
18
21
  import { CheckboxGroup } from "./checkbox-group/index.mjs";
19
22
  import { Select } from "./select/index.mjs";
@@ -23,10 +26,12 @@ import { createToastManager, toast } from "./toast/toast.mjs";
23
26
  import { Toast } from "./toast/index.mjs";
24
27
  import { Slider } from "./slider/index.mjs";
25
28
  import { NumberField } from "./number-field/index.mjs";
29
+ import { OTPField } from "./otp-field/index.mjs";
26
30
  import { Field } from "./field/index.mjs";
27
31
  import { Form } from "./form/index.mjs";
28
32
  import { Progress } from "./progress/index.mjs";
29
33
  import { Meter } from "./meter/index.mjs";
34
+ import { Avatar } from "./avatar/index.mjs";
30
35
  import { CSPProvider } from "./csp/csp-provider.mjs";
31
36
  import { STYLE_SHA256 } from "./csp/style-hashes.mjs";
32
- export { Accordion, AlertDialog, Button, CSPProvider, Checkbox, CheckboxGroup, Collapsible, Combobox, Dialog, Field, Form, HoverCard, Menu, Meter, MultiSelect, NumberField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
37
+ export { Accordion, AlertDialog, Avatar, Button, CSPProvider, Checkbox, CheckboxGroup, Collapsible, Combobox, Dialog, Drawer, Field, Form, HoverCard, Menu, Menubar, Meter, MultiSelect, NavigationMenu, NumberField, OTPField, Popover, Progress, RadioGroup, STYLE_SHA256, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToastManager, toast };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { createContext, use } from "react";
3
+ //#region src/internal/menubar-context.ts
4
+ const MenubarContext = createContext(null);
5
+ /** The enclosing Menubar, or `null` outside one (and inside a `Menu.Popup`). */
6
+ function useMenubarContext() {
7
+ return use(MenubarContext);
8
+ }
9
+ //#endregion
10
+ export { MenubarContext, useMenubarContext };
11
+
12
+ //# sourceMappingURL=menubar-context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menubar-context.mjs","names":[],"sources":["../../src/internal/menubar-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\n\n/**\n * Where focus goes when a switch opens a menu of the bar (design/components/menubar.md 2.2): the\n * first item (`\"first\"`, a switch from inside a menu), or nowhere (`\"none\"`: the arrow keys on a\n * Trigger and the pointer leave focus on the Trigger).\n */\nexport type MenubarOpenFocus = \"first\" | \"none\";\n\n/**\n * What a menu of the bar registers with it (menubar.md 2.1): read and called by the bar's\n * handlers only. Registered by `Menu.Trigger` from its ref callback, keyed by its element.\n */\nexport interface MenubarMenu {\n /** The `disabled` prop of the Trigger: focused by a switch, never opened. */\n readonly disabled: () => boolean;\n /** The menu's `intended()` (an open requested or shown). */\n readonly intended: () => boolean;\n /**\n * The browser hid the popup and its `toggle` has not arrived yet: the menu's own rule (Tab,\n * focus leaving the popup) already dismissed it, so there is nothing to supersede.\n */\n readonly hiddenBeforeToggle: () => boolean;\n /** The popup element (`:popover-open` tells whether it is shown). */\n readonly popup: () => HTMLElement | null;\n /** Request the open (`openChangeAction(true, \"activate\")`) with this focus target. */\n readonly open: (event: Event, focus: MenubarOpenFocus) => void;\n /** Supersede a pending open: `requestClose(event, \"dismiss\")`. */\n readonly supersede: (event: Event) => void;\n}\n\n/**\n * Provided by `Menubar`; read across folders by `Menu.Trigger` (an item of the bar, its\n * registration and the hover switch) and the top-level `Menu.Popup` (the arrow keys that switch\n * from inside a menu). A `Menu.Popup` provides `null` to its content: the bar's context ends\n * there, so a submenu is not a menu of the bar (menubar.md 1). Conventions 7.1.\n */\nexport interface MenubarContextValue {\n /** Register the menu whose Trigger is `trigger`; returns the unregistration. */\n readonly register: (trigger: HTMLElement, menu: MenubarMenu) => () => void;\n /**\n * The switch of menubar.md 2.2: focus `target` (quietly for the pointer), close the other\n * menus of the bar at once, request `target`'s open (unless it is disabled).\n */\n readonly switchTo: (\n target: HTMLElement,\n focus: MenubarOpenFocus,\n event: Event,\n pointer: boolean,\n ) => void;\n /**\n * From inside the menu whose Trigger is `from`: switch to the next (`1`) or previous (`-1`)\n * menu of the bar, first item focused. Wraps with the bar's `loop`. Returns whether it\n * switched (`false` at an end without `loop`, in a one-menu bar, or from a menu that is not\n * one of the bar's), so the caller consumes the key only then.\n */\n readonly step: (from: HTMLElement, delta: 1 | -1, event: Event) => boolean;\n /** Some menu of the bar other than `trigger`'s is intended open (menu mode, 2.1). */\n readonly otherIntended: (trigger: HTMLElement) => boolean;\n /** The bar's computed `direction` is `rtl`, read at the event (conventions 14.1). */\n readonly rtl: () => boolean;\n}\n\nexport const MenubarContext = createContext<MenubarContextValue | null>(null);\n\n/** The enclosing Menubar, or `null` outside one (and inside a `Menu.Popup`). */\nexport function useMenubarContext(): MenubarContextValue | null {\n return use(MenubarContext);\n}\n"],"mappings":";;;AAgEA,MAAa,iBAAiB,cAA0C,IAAI;;AAG5E,SAAgB,oBAAgD;CAC9D,OAAO,IAAI,cAAc;AAC3B"}
@@ -12,7 +12,7 @@ function registerTrigger(triggerRef, element, part) {
12
12
  if (isDev && triggerRef.current !== null) {
13
13
  if (!warned.has(triggerRef)) {
14
14
  warned.add(triggerRef);
15
- console.error(`${part}: a second ${part} mounted in the same Root. A Root supports one ${part}: the popup only follows the last one mounted (its anchor, focus return and, without an action, data-open). Render one ${part} per Root.`);
15
+ console.error(`${part}: a second ${part} mounted for the same popup. A popup supports one ${part}: it only follows the last one mounted (its anchor, focus return and, without an action, data-open). Render one ${part} per popup.`);
16
16
  }
17
17
  }
18
18
  triggerRef.current = element;
@@ -1 +1 @@
1
- {"version":3,"file":"trigger-ref.mjs","names":[],"sources":["../../../src/internal/overlay/trigger-ref.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The Roots that already warned about a second Trigger, keyed by their `triggerRef`. */\nconst warned = new WeakSet<RefObject<HTMLElement | null>>();\n\n/**\n * Registers `element` as the Root's one Trigger (`triggerRef`, last mounted wins) and returns\n * the ref cleanup. In development, a second Trigger mounting while another is registered\n * warns once per Root (popover.md 14.2): only the registered one is the popup's `source` (anchor,\n * focus return) and, in JS-free mode, the one whose `data-open` is kept current.\n */\nexport function registerTrigger(\n triggerRef: RefObject<HTMLElement | null>,\n element: HTMLElement,\n part: string,\n): () => void {\n // A Trigger's own cleanup clears the ref first (a remount, StrictMode, a ref change), so a\n // registered element here is another, still mounted Trigger.\n if (isDev && triggerRef.current !== null) {\n if (!warned.has(triggerRef)) {\n warned.add(triggerRef);\n console.error(\n `${part}: a second ${part} mounted in the same Root. A Root supports one ${part}: ` +\n \"the popup only follows the last one mounted (its anchor, focus return and, \" +\n `without an action, data-open). Render one ${part} per Root.`,\n );\n }\n }\n triggerRef.current = element;\n return () => {\n if (triggerRef.current === element) triggerRef.current = null;\n };\n}\n"],"mappings":";AAEA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAGvC,MAAM,yBAAS,IAAI,QAAuC;;;;;;;AAQ1D,SAAgB,gBACd,YACA,SACA,MACY;CAGZ,IAAI,SAAS,WAAW,YAAY,MAC9B;MAAA,CAAC,OAAO,IAAI,UAAU,GAAG;GAC3B,OAAO,IAAI,UAAU;GACrB,QAAQ,MACN,GAAG,KAAK,aAAa,KAAK,iDAAiD,KAAK,yHAEjC,KAAK,WACtD;EACF;;CAEF,WAAW,UAAU;CACrB,aAAa;EACX,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;CAC3D;AACF"}
1
+ {"version":3,"file":"trigger-ref.mjs","names":[],"sources":["../../../src/internal/overlay/trigger-ref.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The Roots that already warned about a second Trigger, keyed by their `triggerRef`. */\nconst warned = new WeakSet<RefObject<HTMLElement | null>>();\n\n/**\n * Registers `element` as the Root's one Trigger (`triggerRef`, last mounted wins) and returns\n * the ref cleanup. In development, a second Trigger mounting while another is registered\n * warns once per Root (popover.md 14.2): only the registered one is the popup's `source` (anchor,\n * focus return) and, in JS-free mode, the one whose `data-open` is kept current.\n */\nexport function registerTrigger(\n triggerRef: RefObject<HTMLElement | null>,\n element: HTMLElement,\n part: string,\n): () => void {\n // A Trigger's own cleanup clears the ref first (a remount, StrictMode, a ref change), so a\n // registered element here is another, still mounted Trigger.\n if (isDev && triggerRef.current !== null) {\n if (!warned.has(triggerRef)) {\n warned.add(triggerRef);\n console.error(\n `${part}: a second ${part} mounted for the same popup. A popup supports one ${part}: ` +\n \"it only follows the last one mounted (its anchor, focus return and, \" +\n `without an action, data-open). Render one ${part} per popup.`,\n );\n }\n }\n triggerRef.current = element;\n return () => {\n if (triggerRef.current === element) triggerRef.current = null;\n };\n}\n"],"mappings":";AAEA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAGvC,MAAM,yBAAS,IAAI,QAAuC;;;;;;;AAQ1D,SAAgB,gBACd,YACA,SACA,MACY;CAGZ,IAAI,SAAS,WAAW,YAAY,MAC9B;MAAA,CAAC,OAAO,IAAI,UAAU,GAAG;GAC3B,OAAO,IAAI,UAAU;GACrB,QAAQ,MACN,GAAG,KAAK,aAAa,KAAK,oDAAoD,KAAK,kHAEpC,KAAK,YACtD;EACF;;CAEF,WAAW,UAAU;CACrB,aAAa;EACX,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;CAC3D;AACF"}
@@ -20,7 +20,8 @@ function clearLater(intentRef, intent, popupRef, isShown) {
20
20
  /** What the popup is called in the controlled-without-`onOpenChange` warning. */
21
21
  const nouns = {
22
22
  combobox: "listbox",
23
- "hover-card": "card"
23
+ "hover-card": "card",
24
+ "navigation-menu": "panel"
24
25
  };
25
26
  /** The `details` of a popover-like component: `{ reason }` (and `event`). */
26
27
  const popoverDetails = (event, reason) => createActionDetails(event, { reason });
@@ -35,7 +36,7 @@ function useOverlayRoot(options) {
35
36
  const mode = useMountFixed(isLibraryNow ? "library" : "static", isDev && `${part}: the mode changed after mount (\`open\`, \`defaultOpen\`, \`openChangeAction\` and \`onOpenChange\` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.`);
36
37
  const isLibrary = mode === "library";
37
38
  const noun = nouns[component] ?? component;
38
- useDevWarning(isLibrary && open !== void 0 && onOpenChange === void 0, isDev && `${part}: \`open\` is set without \`onOpenChange\`. The browser can close this ${noun} without asking (Escape, a click outside), and \`onOpenChange\` is where a controlled Root is told. Without it the ${noun} re-opens after every dismissal. Pass \`onOpenChange={setOpen}\`, or \`onOpenChange={() => {}}\` if re-opening is what you want.`);
39
+ useDevWarning(isLibrary && open !== void 0 && onOpenChange === void 0, isDev && `${part}: \`open\` is set without \`onOpenChange\`. The browser can close this ${noun} without asking (Escape, a click outside), and \`onOpenChange\` is where a controlled ${part} is told. Without it the ${noun} re-opens after every dismissal. Pass \`onOpenChange={setOpen}\`, or \`onOpenChange={() => {}}\` if re-opening is what you want.`);
39
40
  const { committed, optimistic, pending, dispatch, latestInFlight, adoptFact, epoch } = useControllableAction({
40
41
  controlled: isLibrary ? open : void 0,
41
42
  defaultValue: isLibrary ? defaultOpen : void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"use-overlay-root.mjs","names":[],"sources":["../../../src/internal/overlay/use-overlay-root.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport { createActionDetails } from \"../action/action-details.js\";\nimport { callUrgentHandler } from \"../action/call-urgent-handler.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport { transitionTypes } from \"../transition-types.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason, UrgentChangeHandler } from \"../types.js\";\nimport { intendedValue, useControllableAction } from \"../action/use-controllable-action.js\";\nimport { useDevWarning } from \"../use-dev-warning.js\";\nimport { useMountFixed } from \"../use-mount-fixed.js\";\nimport { useLatest } from \"../use-latest.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * \"static\": JS-free mode, the browser owns open and close through Invoker Commands. \"library\":\n * opening and part-initiated closing are library-owned requests (transitions keyed on committed\n * state, `openChangeAction`); dismissals are the browser's facts, adopted urgently and reported to\n * `onOpenChange` (design/components/popover.md section 2, conventions 3.9).\n */\nexport type OverlayMode = \"static\" | \"library\";\n\n/**\n * What caused the next close, recorded just before it happens (design 2.3). The `toggle` event\n * names no cause beyond its invoker (`ToggleEvent.source`: a `popovertarget`, `commandfor` or\n * `interestfor` button); without an intent a close is a `\"dismiss\"`.\n */\nexport interface OverlayCloseIntent {\n readonly reason: ChangeReason;\n readonly event: Event | undefined;\n}\n\n/**\n * The `details` every overlay `openChangeAction` and `onOpenChange` receives (Dialog's adds\n * `returnValue`).\n */\nexport interface OverlayDetails extends ActionDetails {\n readonly reason: ChangeReason;\n}\n\n/** What the parts render from (every part). */\nexport interface OverlayRootState {\n readonly mode: OverlayMode;\n /** `useId`-based ids: the popup, its Title and its Description. */\n readonly ids: { readonly popup: string; readonly title: string; readonly description: string };\n /** Committed open state (library mode); `false` in JS-free mode. */\n readonly committed: boolean;\n /** Optimistic open state (library mode); `false` in JS-free mode. */\n readonly optimistic: boolean;\n /** The Root's transition is pending (library mode). */\n readonly pending: boolean;\n /**\n * Grows with every fact (`notifyClosed`). No part reads it: it is part of the memoised value so\n * that a fact always re-renders the parts, even when a controlled parent keeps `open={true}` and\n * nothing else changed: the Popup's apply effect then re-opens the popup (design 2.4).\n */\n readonly epoch: number;\n}\n\n/**\n * How a part asks for an open or a close, from its handlers: the Triggers, the Close parts,\n * Menu's items, keys and hover intent, Combobox's handlers, Dialog's Form; the Popup too, for a\n * foreign open or close it catches.\n */\nexport interface OverlayRootRequests<CloseArgs extends unknown[]> {\n /**\n * What the user already intends: the latest in-flight dispatch's `next`, else the optimistic\n * value of the last commit. Safe to call from handlers and effects (layout effects included,\n * also in the commit that changed it), and after an `await`. Not during render.\n */\n readonly intended: () => boolean;\n /**\n * Open through the Root's transition (library mode): a Trigger click, a foreign open caught at\n * `beforetoggle`, or mount reconciliation. A no-op when `true` is already intended.\n */\n readonly requestOpen: (event: Event | undefined, reason: ChangeReason) => void;\n /**\n * A library-owned close (library mode): a Trigger click while open, a Close part, Menu's item\n * activation. `openChangeAction(false)` is awaited and the popup hides in the commit. A no-op\n * when `false` is already intended.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /**\n * A counter that grows with every open (a requested open, or the popup being shown). A part\n * whose close runs after an `await` records it first and drops the close when it changed: the\n * user dismissed and re-opened meanwhile (Popover.Close, design 3.4). Handlers only.\n */\n readonly openGeneration: () => number;\n /**\n * Record what causes the next close. Cleared after a task if the popover did not close.\n * `unlessRecorded`: keep an intent already recorded for this close (the `command` listener runs\n * before the `beforetoggle` of the same click).\n */\n readonly recordCloseIntent: (\n intent: OverlayCloseIntent | undefined,\n options?: { readonly unlessRecorded?: boolean },\n ) => void;\n}\n\n/**\n * What only the Popup implementation calls (`usePopoverPopup`, Dialog.Popup and their shared\n * `useApplyOpenState`): the platform events' bookkeeping and the apply effect's in-flight check.\n */\nexport interface OverlayRootPopupChannel<CloseArgs extends unknown[]> {\n /**\n * A fact (#148, conventions 3.9.2): the browser hid the popup and the library did not\n * hide it (the caller has already excluded the library's own hide). Supersedes every request in\n * flight, writes committed `false` urgently (uncontrolled), and calls `onOpenChange(false,\n * details)` synchronously through the handler rule (`callUrgentHandler`). Call it from the\n * platform event's listener (`toggle` / `close`), never inside a transition.\n */\n readonly notifyClosed: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /** Advance `openGeneration` (the Popup's `beforetoggle` for an open). */\n readonly nextOpenGeneration: () => void;\n /** Read and clear the recorded intent (the Popup's `toggle` / `close` listener). */\n readonly takeCloseIntent: () => OverlayCloseIntent | undefined;\n /**\n * From `useControllableAction`: the latest in-flight intent, or `null`. Also read by\n * Dialog.Root, for its pending `returnValue`.\n */\n readonly latestInFlight: () => { readonly next: boolean } | null;\n}\n\n/** The two elements, each set by its own part and read by the others. */\nexport interface OverlayRootRefs<Popup extends HTMLElement> {\n /** The registered Trigger: `showPopover({ source })` and the focus-return fallback. */\n readonly triggerRef: RefObject<HTMLElement | null>;\n /** The popup element, set by the Popup's ref; how Close reaches `hidePopover()` / `close()`. */\n readonly popupRef: RefObject<Popup | null>;\n}\n\n/**\n * The Root's state and machinery, shared by Popover, Menu, Combobox (design 14) and Dialog,\n * grouped by who uses it. The component puts it in its own context (the popover-like ones\n * extend it, `PopoverRootValue`). `Popup` is the popup element's type; `CloseArgs` are the extra\n * arguments of a close (Dialog's `returnValue`), passed on to the `details` builder.\n */\nexport interface OverlayRootValue<Popup extends HTMLElement, CloseArgs extends unknown[]>\n extends\n OverlayRootState,\n OverlayRootRequests<CloseArgs>,\n OverlayRootPopupChannel<CloseArgs>,\n OverlayRootRefs<Popup> {}\n\n/**\n * The root value of the popover-like components (Popover, Menu, Combobox), from `usePopoverRoot`:\n * the overlay Root plus the `shown` mirror that their Popup (`usePopoverPopup`) writes and their\n * Triggers (`usePopoverTrigger`, Combobox.Trigger) and the Combobox Input read. Dialog has none.\n */\nexport interface PopoverRootValue extends OverlayRootValue<HTMLElement, []> {\n /**\n * The popup is in the top layer, mirrored from its `toggle` (urgent, conventions 3.5): what\n * `aria-expanded` renders on a non-button Trigger and the Combobox Input (a `<button>`\n * Trigger renders none). Written by the Popup in library mode.\n */\n readonly shown: boolean;\n /** Writes `shown` from the DOM (`:popover-open`); the Popup's `toggle`, ref attach and detach. */\n readonly setShown: (shown: boolean) => void;\n /**\n * The popup was shown at its last `toggle` and the DOM has it hidden now: the browser hid it\n * and its `toggle` has not arrived yet. A non-button Trigger's click lands in that window after\n * light dismiss hid the popup at `pointerup` (#115): it records an `\"activate\"` intent for the\n * fact instead of requesting a close. Handlers only.\n */\n readonly hiddenBeforeToggle: () => boolean;\n}\n\nexport interface UseOverlayRootOptions<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n> {\n /** Transition types and messages: `\"popover\"` gives `fsui-popover`, `fsui-popover-open`, … */\n readonly component: string;\n /** Public name of the Root part for development warnings (`\"Popover.Root\"`). */\n readonly part: string;\n readonly open: boolean | undefined;\n readonly defaultOpen: boolean | undefined;\n readonly openChangeAction: ChangeAction<boolean, Details> | undefined;\n /** The fact handler (#148): called for a hide the library did not perform. */\n readonly onOpenChange: UrgentChangeHandler<boolean, Details> | undefined;\n /**\n * `\"library\"` forces library mode whatever the props (Menu, which has no JS-free mode). Default:\n * detected from `open` / `defaultOpen` / `openChangeAction` / `onOpenChange` on the first\n * render.\n */\n readonly mode?: \"library\";\n /**\n * Called synchronously for every dispatch, before the action runs, and for every fact, before\n * `onOpenChange` (Menu: cancel hover timers, read the open cause).\n */\n readonly onDispatch?: (next: boolean, details: Details) => void;\n /** Builds the `details` of a dispatch (`popoverDetails`: `{ reason }`); an open passes no args. */\n readonly details: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs | []\n ) => Details;\n /**\n * Whether the popup is shown, for a stale close intent: `:popover-open` (`usePopoverRoot`), a\n * `<dialog>`'s `open` (Dialog).\n */\n readonly isShown: (popup: Popup) => boolean;\n}\n\n/** How long a recorded close intent survives when the popup did not close (design 2.3). */\nfunction clearLater<Popup extends HTMLElement>(\n intentRef: { current: OverlayCloseIntent | undefined },\n intent: OverlayCloseIntent,\n popupRef: { current: Popup | null },\n isShown: (popup: Popup) => boolean,\n): void {\n setTimeout(() => {\n // Closed: its `toggle` / `close` event (queued as a task) consumes the intent. Still open: the\n // close was cancelled or invalid, so the intent is stale.\n const popup = popupRef.current;\n if (intentRef.current === intent && popup !== null && isShown(popup)) {\n intentRef.current = undefined;\n }\n }, 0);\n}\n\n/** What the popup is called in the controlled-without-`onOpenChange` warning. */\nconst nouns: Record<string, string> = { combobox: \"listbox\", \"hover-card\": \"card\" };\n\n/** The `details` of a popover-like component: `{ reason }` (and `event`). */\nexport const popoverDetails = (event: Event | undefined, reason: ChangeReason): OverlayDetails =>\n createActionDetails(event, { reason });\n\n/**\n * The Root of an overlay without its public props: mode detection (once, from the first\n * render), `useControllableAction<boolean>`, ids, refs, close intents, the open generation and\n * the intent-aware `requestOpen` / `requestClose`, and `notifyClosed` for facts.\n */\nexport function useOverlayRoot<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n>(options: UseOverlayRootOptions<Details, Popup, CloseArgs>): OverlayRootValue<Popup, CloseArgs> {\n const {\n component,\n part,\n open,\n defaultOpen,\n openChangeAction,\n onOpenChange,\n details,\n onDispatch,\n } = options;\n\n // Mode is decided once, from the first render's props (design 2).\n const isLibraryNow =\n options.mode === \"library\" ||\n open !== undefined ||\n defaultOpen !== undefined ||\n openChangeAction !== undefined ||\n onOpenChange !== undefined;\n const mode = useMountFixed<OverlayMode>(\n isLibraryNow ? \"library\" : \"static\",\n isDev &&\n `${part}: the mode changed after mount (\\`open\\`, \\`defaultOpen\\`, \\`openChangeAction\\` ` +\n \"and `onOpenChange` were all absent on one render and present on another). Switching \" +\n \"between JS-free and library mode is not supported.\",\n );\n const isLibrary = mode === \"library\";\n // W1 (conventions 3.9.13): React's `value` without `onChange`. Static only: a handler\n // that adopts late (in a transition, after an `await`) cannot be told from an intentional\n // re-open, so nothing at runtime warns.\n const noun = nouns[component] ?? component;\n useDevWarning(\n isLibrary && open !== undefined && onOpenChange === undefined,\n isDev &&\n `${part}: \\`open\\` is set without \\`onOpenChange\\`. The browser can close this ${noun} ` +\n \"without asking (Escape, a click outside), and `onOpenChange` is where a controlled Root \" +\n `is told. Without it the ${noun} re-opens after every dismissal. Pass ` +\n \"`onOpenChange={setOpen}`, or `onOpenChange={() => {}}` if re-opening is what you want.\",\n );\n\n // Hooks cannot be conditional: JS-free mode calls the hook too and never dispatches.\n const { committed, optimistic, pending, dispatch, latestInFlight, adoptFact, epoch } =\n useControllableAction<boolean, Details>({\n controlled: isLibrary ? open : undefined,\n defaultValue: isLibrary ? defaultOpen : undefined,\n initialValue: false,\n action: isLibrary ? openChangeAction : undefined,\n transitionTypes: (next) => transitionTypes(component, next ? \"open\" : \"close\"),\n warn: { component: part, prop: \"open\" },\n });\n\n const id = useId();\n const triggerRef = useRef<HTMLElement | null>(null);\n const popupRef = useRef<Popup | null>(null);\n const closeIntent = useRef<OverlayCloseIntent | undefined>(undefined);\n\n // The optimistic value of the last commit, for callers that run after an `await` (a Close\n // action's continuation) and would otherwise read the value of the render they were created in.\n // An insertion effect runs in the mutation phase, before any layout effect of the same commit\n // (a child's included), so `intended()` is current there too.\n const committedOptimistic = useLatest(optimistic);\n // `details`, `onDispatch` and `isShown` are usually inline functions: read the committed render's\n // through a ref so that the functions below, and with them the returned value, stay stable.\n const callbacks = useLatest({ details, onDispatch, onOpenChange, isShown: options.isShown });\n const generation = useRef(0);\n const openGeneration = useCallback(() => generation.current, []);\n const nextOpenGeneration = useCallback(() => {\n generation.current++;\n }, []);\n\n const recordCloseIntent = useCallback(\n (intent: OverlayCloseIntent | undefined, options?: { readonly unlessRecorded?: boolean }) => {\n if (options?.unlessRecorded === true && closeIntent.current !== undefined) return;\n closeIntent.current = intent;\n if (intent !== undefined) {\n clearLater(closeIntent, intent, popupRef, callbacks.current.isShown);\n }\n },\n [callbacks],\n );\n const takeCloseIntent = useCallback(() => {\n const intent = closeIntent.current;\n closeIntent.current = undefined;\n return intent;\n }, []);\n\n // Conventions 3.8 rule 1: judge no-ops against what the user already intends. That also\n // deduplicates the StrictMode re-run of the mount reconciliation and recognises the library's\n // own `hidePopover()` echoing back through `toggle`.\n const intended = useCallback(\n (): boolean => intendedValue(latestInFlight, committedOptimistic.current),\n [latestInFlight, committedOptimistic],\n );\n\n const send = useCallback(\n (next: boolean, event: Event | undefined, reason: ChangeReason, args: CloseArgs | []): void => {\n const { details, onDispatch } = callbacks.current;\n const built = details(event, reason, ...args);\n if (next) nextOpenGeneration();\n onDispatch?.(next, built);\n dispatch(next, built);\n },\n [callbacks, nextOpenGeneration, dispatch],\n );\n\n const requestOpen = useCallback(\n (event: Event | undefined, reason: ChangeReason): void => {\n if (!isLibrary || intended()) return;\n send(true, event, reason, []);\n },\n [isLibrary, intended, send],\n );\n\n const requestClose = useCallback(\n (event: Event | undefined, reason: ChangeReason, ...args: CloseArgs): void => {\n if (!isLibrary || !intended()) return;\n send(false, event, reason, args);\n },\n [isLibrary, intended, send],\n );\n\n const notifyClosed = useCallback(\n (event: Event | undefined, reason: ChangeReason, ...args: CloseArgs): void => {\n if (!isLibrary) return;\n const { details, onDispatch, onOpenChange } = callbacks.current;\n const built = details(event, reason, ...args);\n onDispatch?.(false, built);\n // Supersede the requests in flight and write committed `false` (urgent), then tell the\n // consumer; both in the platform event, so one discrete commit follows (design 2.3).\n adoptFact(false);\n callUrgentHandler(onOpenChange, false, built);\n },\n [isLibrary, callbacks, adoptFact],\n );\n\n const ids = useMemo(\n () => ({ popup: id, title: `${id}-title`, description: `${id}-description` }),\n [id],\n );\n\n // Memoised: every function above is stable, so the value changes only with the open state and\n // pending, and the components' context values built on it are reused otherwise.\n return useMemo(\n () => ({\n mode,\n ids,\n committed: isLibrary && committed,\n optimistic: isLibrary && optimistic,\n pending: isLibrary && pending,\n epoch,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n notifyClosed,\n latestInFlight,\n triggerRef,\n popupRef,\n recordCloseIntent,\n takeCloseIntent,\n }),\n [\n mode,\n ids,\n isLibrary,\n committed,\n optimistic,\n pending,\n epoch,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n notifyClosed,\n latestInFlight,\n recordCloseIntent,\n takeCloseIntent,\n ],\n );\n}\n\n/**\n * The Root of a popover-like component (Popover, Menu, Combobox): `useOverlayRoot` over a\n * `popover` element (`:popover-open`), plus the `shown` mirror and `hiddenBeforeToggle`.\n */\nexport function usePopoverRoot<Details extends ActionDetails>(\n options: Omit<UseOverlayRootOptions<Details>, \"isShown\">,\n): PopoverRootValue {\n const root = useOverlayRoot<Details>({ ...options, isShown: isPopoverOpen });\n const { popupRef } = root;\n\n const [shown, setShownState] = useState(false);\n // The last value written, for handlers (`hiddenBeforeToggle`).\n const shownNow = useRef(false);\n const setShown = useCallback((next: boolean) => {\n shownNow.current = next;\n setShownState(next);\n }, []);\n const hiddenBeforeToggle = useCallback((): boolean => {\n const popup = popupRef.current;\n return shownNow.current && popup !== null && !isPopoverOpen(popup);\n }, [popupRef]);\n\n // Changes only with `root` and `shown`, so as rarely as `root` itself does.\n return useMemo(\n () => ({ ...root, shown, setShown, hiddenBeforeToggle }),\n [root, shown, setShown, hiddenBeforeToggle],\n );\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"use-overlay-root.mjs","names":[],"sources":["../../../src/internal/overlay/use-overlay-root.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport { createActionDetails } from \"../action/action-details.js\";\nimport { callUrgentHandler } from \"../action/call-urgent-handler.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport { transitionTypes } from \"../transition-types.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason, UrgentChangeHandler } from \"../types.js\";\nimport { intendedValue, useControllableAction } from \"../action/use-controllable-action.js\";\nimport { useDevWarning } from \"../use-dev-warning.js\";\nimport { useMountFixed } from \"../use-mount-fixed.js\";\nimport { useLatest } from \"../use-latest.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * \"static\": JS-free mode, the browser owns open and close through Invoker Commands. \"library\":\n * opening and part-initiated closing are library-owned requests (transitions keyed on committed\n * state, `openChangeAction`); dismissals are the browser's facts, adopted urgently and reported to\n * `onOpenChange` (design/components/popover.md section 2, conventions 3.9).\n */\nexport type OverlayMode = \"static\" | \"library\";\n\n/**\n * What caused the next close, recorded just before it happens (design 2.3). The `toggle` event\n * names no cause beyond its invoker (`ToggleEvent.source`: a `popovertarget`, `commandfor` or\n * `interestfor` button); without an intent a close is a `\"dismiss\"`.\n */\nexport interface OverlayCloseIntent {\n readonly reason: ChangeReason;\n readonly event: Event | undefined;\n}\n\n/**\n * The `details` every overlay `openChangeAction` and `onOpenChange` receives (Dialog's adds\n * `returnValue`).\n */\nexport interface OverlayDetails extends ActionDetails {\n readonly reason: ChangeReason;\n}\n\n/** What the parts render from (every part). */\nexport interface OverlayRootState {\n readonly mode: OverlayMode;\n /** `useId`-based ids: the popup, its Title and its Description. */\n readonly ids: { readonly popup: string; readonly title: string; readonly description: string };\n /** Committed open state (library mode); `false` in JS-free mode. */\n readonly committed: boolean;\n /** Optimistic open state (library mode); `false` in JS-free mode. */\n readonly optimistic: boolean;\n /** The Root's transition is pending (library mode). */\n readonly pending: boolean;\n /**\n * Grows with every fact (`notifyClosed`). No part reads it: it is part of the memoised value so\n * that a fact always re-renders the parts, even when a controlled parent keeps `open={true}` and\n * nothing else changed: the Popup's apply effect then re-opens the popup (design 2.4).\n */\n readonly epoch: number;\n}\n\n/**\n * How a part asks for an open or a close, from its handlers: the Triggers, the Close parts,\n * Menu's items, keys and hover intent, Combobox's handlers, Dialog's Form; the Popup too, for a\n * foreign open or close it catches.\n */\nexport interface OverlayRootRequests<CloseArgs extends unknown[]> {\n /**\n * What the user already intends: the latest in-flight dispatch's `next`, else the optimistic\n * value of the last commit. Safe to call from handlers and effects (layout effects included,\n * also in the commit that changed it), and after an `await`. Not during render.\n */\n readonly intended: () => boolean;\n /**\n * Open through the Root's transition (library mode): a Trigger click, a foreign open caught at\n * `beforetoggle`, or mount reconciliation. A no-op when `true` is already intended.\n */\n readonly requestOpen: (event: Event | undefined, reason: ChangeReason) => void;\n /**\n * A library-owned close (library mode): a Trigger click while open, a Close part, Menu's item\n * activation. `openChangeAction(false)` is awaited and the popup hides in the commit. A no-op\n * when `false` is already intended.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /**\n * A counter that grows with every open (a requested open, or the popup being shown). A part\n * whose close runs after an `await` records it first and drops the close when it changed: the\n * user dismissed and re-opened meanwhile (Popover.Close, design 3.4). Handlers only.\n */\n readonly openGeneration: () => number;\n /**\n * Record what causes the next close. Cleared after a task if the popover did not close.\n * `unlessRecorded`: keep an intent already recorded for this close (the `command` listener runs\n * before the `beforetoggle` of the same click).\n */\n readonly recordCloseIntent: (\n intent: OverlayCloseIntent | undefined,\n options?: { readonly unlessRecorded?: boolean },\n ) => void;\n}\n\n/**\n * What only the Popup implementation calls (`usePopoverPopup`, Dialog.Popup and their shared\n * `useApplyOpenState`): the platform events' bookkeeping and the apply effect's in-flight check.\n */\nexport interface OverlayRootPopupChannel<CloseArgs extends unknown[]> {\n /**\n * A fact (#148, conventions 3.9.2): the browser hid the popup and the library did not\n * hide it (the caller has already excluded the library's own hide). Supersedes every request in\n * flight, writes committed `false` urgently (uncontrolled), and calls `onOpenChange(false,\n * details)` synchronously through the handler rule (`callUrgentHandler`). Call it from the\n * platform event's listener (`toggle` / `close`), never inside a transition.\n */\n readonly notifyClosed: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /** Advance `openGeneration` (the Popup's `beforetoggle` for an open). */\n readonly nextOpenGeneration: () => void;\n /** Read and clear the recorded intent (the Popup's `toggle` / `close` listener). */\n readonly takeCloseIntent: () => OverlayCloseIntent | undefined;\n /**\n * From `useControllableAction`: the latest in-flight intent, or `null`. Also read by\n * Dialog.Root, for its pending `returnValue`.\n */\n readonly latestInFlight: () => { readonly next: boolean } | null;\n}\n\n/** The two elements, each set by its own part and read by the others. */\nexport interface OverlayRootRefs<Popup extends HTMLElement> {\n /** The registered Trigger: `showPopover({ source })` and the focus-return fallback. */\n readonly triggerRef: RefObject<HTMLElement | null>;\n /** The popup element, set by the Popup's ref; how Close reaches `hidePopover()` / `close()`. */\n readonly popupRef: RefObject<Popup | null>;\n}\n\n/**\n * The Root's state and machinery, shared by Popover, Menu, Combobox (design 14) and Dialog,\n * grouped by who uses it. The component puts it in its own context (the popover-like ones\n * extend it, `PopoverRootValue`). `Popup` is the popup element's type; `CloseArgs` are the extra\n * arguments of a close (Dialog's `returnValue`), passed on to the `details` builder.\n */\nexport interface OverlayRootValue<Popup extends HTMLElement, CloseArgs extends unknown[]>\n extends\n OverlayRootState,\n OverlayRootRequests<CloseArgs>,\n OverlayRootPopupChannel<CloseArgs>,\n OverlayRootRefs<Popup> {}\n\n/**\n * The root value of the popover-like components (Popover, Menu, Combobox), from `usePopoverRoot`:\n * the overlay Root plus the `shown` mirror that their Popup (`usePopoverPopup`) writes and their\n * Triggers (`usePopoverTrigger`, Combobox.Trigger) and the Combobox Input read. Dialog has none.\n */\nexport interface PopoverRootValue extends OverlayRootValue<HTMLElement, []> {\n /**\n * The popup is in the top layer, mirrored from its `toggle` (urgent, conventions 3.5): what\n * `aria-expanded` renders on a non-button Trigger and the Combobox Input (a `<button>`\n * Trigger renders none). Written by the Popup in library mode.\n */\n readonly shown: boolean;\n /** Writes `shown` from the DOM (`:popover-open`); the Popup's `toggle`, ref attach and detach. */\n readonly setShown: (shown: boolean) => void;\n /**\n * The popup was shown at its last `toggle` and the DOM has it hidden now: the browser hid it\n * and its `toggle` has not arrived yet. A non-button Trigger's click lands in that window after\n * light dismiss hid the popup at `pointerup` (#115): it records an `\"activate\"` intent for the\n * fact instead of requesting a close. Handlers only.\n */\n readonly hiddenBeforeToggle: () => boolean;\n}\n\nexport interface UseOverlayRootOptions<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n> {\n /** Transition types and messages: `\"popover\"` gives `fsui-popover`, `fsui-popover-open`, … */\n readonly component: string;\n /** Public name of the Root part for development warnings (`\"Popover.Root\"`). */\n readonly part: string;\n readonly open: boolean | undefined;\n readonly defaultOpen: boolean | undefined;\n readonly openChangeAction: ChangeAction<boolean, Details> | undefined;\n /** The fact handler (#148): called for a hide the library did not perform. */\n readonly onOpenChange: UrgentChangeHandler<boolean, Details> | undefined;\n /**\n * `\"library\"` forces library mode whatever the props (Menu, which has no JS-free mode). Default:\n * detected from `open` / `defaultOpen` / `openChangeAction` / `onOpenChange` on the first\n * render.\n */\n readonly mode?: \"library\";\n /**\n * Called synchronously for every dispatch, before the action runs, and for every fact, before\n * `onOpenChange` (Menu: cancel hover timers, read the open cause).\n */\n readonly onDispatch?: (next: boolean, details: Details) => void;\n /** Builds the `details` of a dispatch (`popoverDetails`: `{ reason }`); an open passes no args. */\n readonly details: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs | []\n ) => Details;\n /**\n * Whether the popup is shown, for a stale close intent: `:popover-open` (`usePopoverRoot`), a\n * `<dialog>`'s `open` (Dialog).\n */\n readonly isShown: (popup: Popup) => boolean;\n}\n\n/** How long a recorded close intent survives when the popup did not close (design 2.3). */\nfunction clearLater<Popup extends HTMLElement>(\n intentRef: { current: OverlayCloseIntent | undefined },\n intent: OverlayCloseIntent,\n popupRef: { current: Popup | null },\n isShown: (popup: Popup) => boolean,\n): void {\n setTimeout(() => {\n // Closed: its `toggle` / `close` event (queued as a task) consumes the intent. Still open: the\n // close was cancelled or invalid, so the intent is stale.\n const popup = popupRef.current;\n if (intentRef.current === intent && popup !== null && isShown(popup)) {\n intentRef.current = undefined;\n }\n }, 0);\n}\n\n/** What the popup is called in the controlled-without-`onOpenChange` warning. */\nconst nouns: Record<string, string> = {\n combobox: \"listbox\",\n \"hover-card\": \"card\",\n \"navigation-menu\": \"panel\",\n};\n\n/** The `details` of a popover-like component: `{ reason }` (and `event`). */\nexport const popoverDetails = (event: Event | undefined, reason: ChangeReason): OverlayDetails =>\n createActionDetails(event, { reason });\n\n/**\n * The Root of an overlay without its public props: mode detection (once, from the first\n * render), `useControllableAction<boolean>`, ids, refs, close intents, the open generation and\n * the intent-aware `requestOpen` / `requestClose`, and `notifyClosed` for facts.\n */\nexport function useOverlayRoot<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n>(options: UseOverlayRootOptions<Details, Popup, CloseArgs>): OverlayRootValue<Popup, CloseArgs> {\n const {\n component,\n part,\n open,\n defaultOpen,\n openChangeAction,\n onOpenChange,\n details,\n onDispatch,\n } = options;\n\n // Mode is decided once, from the first render's props (design 2).\n const isLibraryNow =\n options.mode === \"library\" ||\n open !== undefined ||\n defaultOpen !== undefined ||\n openChangeAction !== undefined ||\n onOpenChange !== undefined;\n const mode = useMountFixed<OverlayMode>(\n isLibraryNow ? \"library\" : \"static\",\n isDev &&\n `${part}: the mode changed after mount (\\`open\\`, \\`defaultOpen\\`, \\`openChangeAction\\` ` +\n \"and `onOpenChange` were all absent on one render and present on another). Switching \" +\n \"between JS-free and library mode is not supported.\",\n );\n const isLibrary = mode === \"library\";\n // W1 (conventions 3.9.13): React's `value` without `onChange`. Static only: a handler\n // that adopts late (in a transition, after an `await`) cannot be told from an intentional\n // re-open, so nothing at runtime warns.\n const noun = nouns[component] ?? component;\n useDevWarning(\n isLibrary && open !== undefined && onOpenChange === undefined,\n isDev &&\n `${part}: \\`open\\` is set without \\`onOpenChange\\`. The browser can close this ${noun} ` +\n \"without asking (Escape, a click outside), and `onOpenChange` is where a controlled \" +\n `${part} is told. Without it the ${noun} re-opens after every dismissal. Pass ` +\n \"`onOpenChange={setOpen}`, or `onOpenChange={() => {}}` if re-opening is what you want.\",\n );\n\n // Hooks cannot be conditional: JS-free mode calls the hook too and never dispatches.\n const { committed, optimistic, pending, dispatch, latestInFlight, adoptFact, epoch } =\n useControllableAction<boolean, Details>({\n controlled: isLibrary ? open : undefined,\n defaultValue: isLibrary ? defaultOpen : undefined,\n initialValue: false,\n action: isLibrary ? openChangeAction : undefined,\n transitionTypes: (next) => transitionTypes(component, next ? \"open\" : \"close\"),\n warn: { component: part, prop: \"open\" },\n });\n\n const id = useId();\n const triggerRef = useRef<HTMLElement | null>(null);\n const popupRef = useRef<Popup | null>(null);\n const closeIntent = useRef<OverlayCloseIntent | undefined>(undefined);\n\n // The optimistic value of the last commit, for callers that run after an `await` (a Close\n // action's continuation) and would otherwise read the value of the render they were created in.\n // An insertion effect runs in the mutation phase, before any layout effect of the same commit\n // (a child's included), so `intended()` is current there too.\n const committedOptimistic = useLatest(optimistic);\n // `details`, `onDispatch` and `isShown` are usually inline functions: read the committed render's\n // through a ref so that the functions below, and with them the returned value, stay stable.\n const callbacks = useLatest({ details, onDispatch, onOpenChange, isShown: options.isShown });\n const generation = useRef(0);\n const openGeneration = useCallback(() => generation.current, []);\n const nextOpenGeneration = useCallback(() => {\n generation.current++;\n }, []);\n\n const recordCloseIntent = useCallback(\n (intent: OverlayCloseIntent | undefined, options?: { readonly unlessRecorded?: boolean }) => {\n if (options?.unlessRecorded === true && closeIntent.current !== undefined) return;\n closeIntent.current = intent;\n if (intent !== undefined) {\n clearLater(closeIntent, intent, popupRef, callbacks.current.isShown);\n }\n },\n [callbacks],\n );\n const takeCloseIntent = useCallback(() => {\n const intent = closeIntent.current;\n closeIntent.current = undefined;\n return intent;\n }, []);\n\n // Conventions 3.8 rule 1: judge no-ops against what the user already intends. That also\n // deduplicates the StrictMode re-run of the mount reconciliation and recognises the library's\n // own `hidePopover()` echoing back through `toggle`.\n const intended = useCallback(\n (): boolean => intendedValue(latestInFlight, committedOptimistic.current),\n [latestInFlight, committedOptimistic],\n );\n\n const send = useCallback(\n (next: boolean, event: Event | undefined, reason: ChangeReason, args: CloseArgs | []): void => {\n const { details, onDispatch } = callbacks.current;\n const built = details(event, reason, ...args);\n if (next) nextOpenGeneration();\n onDispatch?.(next, built);\n dispatch(next, built);\n },\n [callbacks, nextOpenGeneration, dispatch],\n );\n\n const requestOpen = useCallback(\n (event: Event | undefined, reason: ChangeReason): void => {\n if (!isLibrary || intended()) return;\n send(true, event, reason, []);\n },\n [isLibrary, intended, send],\n );\n\n const requestClose = useCallback(\n (event: Event | undefined, reason: ChangeReason, ...args: CloseArgs): void => {\n if (!isLibrary || !intended()) return;\n send(false, event, reason, args);\n },\n [isLibrary, intended, send],\n );\n\n const notifyClosed = useCallback(\n (event: Event | undefined, reason: ChangeReason, ...args: CloseArgs): void => {\n if (!isLibrary) return;\n const { details, onDispatch, onOpenChange } = callbacks.current;\n const built = details(event, reason, ...args);\n onDispatch?.(false, built);\n // Supersede the requests in flight and write committed `false` (urgent), then tell the\n // consumer; both in the platform event, so one discrete commit follows (design 2.3).\n adoptFact(false);\n callUrgentHandler(onOpenChange, false, built);\n },\n [isLibrary, callbacks, adoptFact],\n );\n\n const ids = useMemo(\n () => ({ popup: id, title: `${id}-title`, description: `${id}-description` }),\n [id],\n );\n\n // Memoised: every function above is stable, so the value changes only with the open state and\n // pending, and the components' context values built on it are reused otherwise.\n return useMemo(\n () => ({\n mode,\n ids,\n committed: isLibrary && committed,\n optimistic: isLibrary && optimistic,\n pending: isLibrary && pending,\n epoch,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n notifyClosed,\n latestInFlight,\n triggerRef,\n popupRef,\n recordCloseIntent,\n takeCloseIntent,\n }),\n [\n mode,\n ids,\n isLibrary,\n committed,\n optimistic,\n pending,\n epoch,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n notifyClosed,\n latestInFlight,\n recordCloseIntent,\n takeCloseIntent,\n ],\n );\n}\n\n/**\n * The Root of a popover-like component (Popover, Menu, Combobox): `useOverlayRoot` over a\n * `popover` element (`:popover-open`), plus the `shown` mirror and `hiddenBeforeToggle`.\n */\nexport function usePopoverRoot<Details extends ActionDetails>(\n options: Omit<UseOverlayRootOptions<Details>, \"isShown\">,\n): PopoverRootValue {\n const root = useOverlayRoot<Details>({ ...options, isShown: isPopoverOpen });\n const { popupRef } = root;\n\n const [shown, setShownState] = useState(false);\n // The last value written, for handlers (`hiddenBeforeToggle`).\n const shownNow = useRef(false);\n const setShown = useCallback((next: boolean) => {\n shownNow.current = next;\n setShownState(next);\n }, []);\n const hiddenBeforeToggle = useCallback((): boolean => {\n const popup = popupRef.current;\n return shownNow.current && popup !== null && !isPopoverOpen(popup);\n }, [popupRef]);\n\n // Changes only with `root` and `shown`, so as rarely as `root` itself does.\n return useMemo(\n () => ({ ...root, shown, setShown, hiddenBeforeToggle }),\n [root, shown, setShown, hiddenBeforeToggle],\n );\n}\n"],"mappings":"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"}
@@ -68,7 +68,7 @@ function nonInvokerMessage(part, tag, popover, popup) {
68
68
  * Menu adds `aria-haspopup="menu"` and its own key handling on top.
69
69
  */
70
70
  function usePopoverTrigger(ctx, options) {
71
- const { part, disabled, render, handlers, onActivate, submenuItem = false } = options;
71
+ const { part, disabled, render, handlers, onActivate, submenuItem = false, alwaysFocusable = false } = options;
72
72
  const isLibrary = ctx.mode === "library";
73
73
  const { ids, triggerRef, popupRef } = ctx;
74
74
  const state = {
@@ -110,7 +110,7 @@ function usePopoverTrigger(ctx, options) {
110
110
  }
111
111
  const disabledProps = disabledButton(render, disabled, {
112
112
  handlesClick: isLibrary,
113
- alwaysFocusable: submenuItem
113
+ alwaysFocusable: submenuItem || alwaysFocusable
114
114
  });
115
115
  if (!isLibrary && !disabledProps.invoker) {
116
116
  const extra = handlers?.onClick;
@@ -1 +1 @@
1
- {"version":3,"file":"use-popover-trigger.mjs","names":[],"sources":["../../../src/internal/overlay/use-popover-trigger.ts"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type { ComponentPropsWithRef, DOMAttributes, MouseEvent } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport { registerTrigger } from \"./trigger-ref.js\";\nimport type { RenderProp } from \"../types.js\";\nimport { useElementCheck } from \"../use-element-check.js\";\nimport { cancelClick, disabledButton, rendersButton } from \"../use-render.js\";\nimport type { DataAttributes } from \"../use-render.js\";\nimport type { PopoverRootValue } from \"./use-overlay-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * The click rule of a Trigger that toggles a popover-kind Root (popover.md 2.8): Popover.Trigger,\n * Menu.Trigger, Menu.SubmenuTrigger (through `usePopoverTrigger`) and Combobox.Trigger. It toggles\n * against what the user already intends (`intended()`, conventions 3.8 rule 1), not the DOM:\n *\n * - intended open, and the browser already hid the popup (a non-button Trigger, #115: light\n * dismiss hid it at `pointerup`, before this click): the hide is a fact, reported by its pending\n * `toggle`; the click only names its cause, an `\"activate\"` close intent;\n * - intended open otherwise: `requestClose(event, \"activate\")`;\n * - intended closed: `beforeOpen()`, then `requestOpen(event, \"activate\")`. First, because what\n * it records (Menu's open cause) must be in place before anything can show the popup. Today the\n * show waits for the apply effect, so the order is not observable.\n *\n * The caller cancels the click and checks `disabled` first. Handlers only.\n */\nexport function toggleFromTrigger(\n ctx: PopoverRootValue,\n event: Event,\n beforeOpen?: () => void,\n): void {\n if (ctx.intended()) {\n if (ctx.hiddenBeforeToggle()) {\n ctx.recordCloseIntent({ reason: \"activate\", event });\n return;\n }\n ctx.requestClose(event, \"activate\");\n } else {\n beforeOpen?.();\n ctx.requestOpen(event, \"activate\");\n }\n}\n\n/**\n * Owned and never written on an overlay Trigger (Popover, Menu, Combobox): the default\n * `popovertarget` action, which a render element must not change, and an Invoker Command, which\n * would take precedence over `popovertarget` and act on another element.\n */\nexport const RESERVED_INVOKER_KEYS = {\n popoverTargetAction: undefined,\n commandfor: undefined,\n command: undefined,\n} as const;\n\n/**\n * The library-mode dev warning for a Trigger rendered as another element than a `<button>`: only\n * an invoker button is spared by the popover's light dismiss, so a press while the popup is open\n * hides it before the click. `popover` and `popup` are the nouns the text uses for it.\n */\nexport function nonInvokerMessage(\n part: string,\n tag: string,\n popover: string,\n popup: string,\n): string {\n return (\n `${part}: rendered a <${tag}>. Only a <button> is the ${popover}'s invoker: a press on ` +\n `this element while the ${popup} is open closes it through light dismiss before the ` +\n \"click, so the close is a dismissal (reported to onOpenChange) rather than a request: \" +\n \"openChangeAction(false) is not called, cannot veto it and there is no view transition. \" +\n \"Render a <button>.\"\n );\n}\n\n/** The state of an overlay Trigger (Popover.Trigger, Menu.Trigger and its siblings). */\nexport interface PopoverTriggerHookState {\n /** Optimistic open state. A Popover in JS-free mode (the browser owns it) reports `false`. */\n readonly open: boolean;\n /** The Root's transition is pending: an open or a part-initiated close (never a dismissal). */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/** Event handlers a component layers onto the Trigger's own (Menu's keys and hover intent). */\nexport type PopoverTriggerHandlers = Pick<\n DOMAttributes<HTMLButtonElement>,\n \"onClick\" | \"onKeyDown\" | \"onMouseDown\" | \"onPointerMove\" | \"onPointerEnter\" | \"onPointerLeave\"\n>;\n\nexport interface UsePopoverTriggerOptions<State> {\n /** Public name of the part for development warnings (`\"Popover.Trigger\"`). */\n readonly part: string;\n readonly disabled: boolean;\n readonly render: RenderProp<ComponentPropsWithRef<\"button\">, State> | undefined;\n /**\n * Extra handlers, merged in front of the Trigger's own: for a key both define, the extra one\n * runs first (the consumer's pass-through handler still runs before both, conventions 1.2).\n */\n readonly handlers?: PopoverTriggerHandlers;\n /**\n * What a click does in library mode, after the command has been cancelled and `disabled`\n * checked. Default: `toggleFromTrigger(ctx, event.nativeEvent)`, the toggle against\n * `intended()` (`requestOpen` / `requestClose`). Menu.Trigger toggles with its open cause;\n * Menu.SubmenuTrigger opens, or moves focus into an already open submenu.\n */\n readonly onActivate?: (event: MouseEvent<HTMLElement>) => void;\n /**\n * Menu.SubmenuTrigger: the Trigger is also an item of the parent menu, whose click\n * (`onActivate`) never closes the popup. `disabled` renders `aria-disabled=\"true\"` and no\n * `disabled` attribute, so the item stays focusable (the click handler still refuses); without\n * it `disabled` is the native attribute, so the button is no invoker at all (in library mode a\n * link or component `render` still gets `aria-disabled`, because native `disabled` means\n * nothing on a link and the installed click handler is what refuses). And the library-mode\n * non-button warning says a press while open dismisses the popup instead of moving focus into\n * it.\n */\n readonly submenuItem?: boolean;\n}\n\nexport interface PopoverTriggerHook {\n readonly state: PopoverTriggerHookState;\n /** Owned props (conventions 1.2) for `useRender`'s `libraryProps`. */\n readonly libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes;\n /** Registers the element as the Root's Trigger; pass as `useRender`'s `ref`. */\n readonly ref: (element: HTMLElement) => () => void;\n}\n\n/**\n * The Trigger of a popover-like component (design/components/popover.md 14.3):\n * `button[popoverTarget]`, with no `aria-expanded` on an invoker: every engine exposes the\n * popover's shown state from the invoker relationship. In JS-free mode the browser toggles\n * the popover and the Popup keeps `data-open` current on the element. In library mode the click\n * is cancelled (so the activation does not run) and toggles against what the user already\n * intends: an open through `requestOpen`, a library-owned close through `requestClose`. There\n * `data-open` and `state.open` are optimistic; a non-button `render` (no invoker) renders\n * `aria-expanded` from whether the popup is shown (in the top layer).\n *\n * Menu adds `aria-haspopup=\"menu\"` and its own key handling on top.\n */\nexport function usePopoverTrigger<State>(\n ctx: PopoverRootValue,\n options: UsePopoverTriggerOptions<State>,\n): PopoverTriggerHook {\n const { part, disabled, render, handlers, onActivate, submenuItem = false } = options;\n const isLibrary = ctx.mode === \"library\";\n const { ids, triggerRef, popupRef } = ctx;\n\n const state: PopoverTriggerHookState = {\n open: ctx.optimistic,\n // Opens and part-initiated closes belong to the Trigger (4.2); a dismissal is a fact and\n // pends nothing (conventions 3.9.7).\n pending: ctx.pending,\n disabled,\n };\n\n const checkElement = useElementCheck(\n isDev &&\n ((element) => {\n if (element.tagName === \"BUTTON\") return null;\n const tag = element.tagName.toLowerCase();\n // Library mode: the click handler works, but only an invoker button is spared by the\n // popover's light dismiss, so a press while open hides the popup before the click.\n if (isLibrary && submenuItem) {\n return (\n `${part}: rendered a <${tag}>. Only a <button> is the popover's invoker: a press on ` +\n \"this element while its popup is open dismisses the popup through light dismiss \" +\n \"instead of moving focus into it. Render a <button>.\"\n );\n }\n return isLibrary\n ? nonInvokerMessage(part, tag, \"popover\", \"popup\")\n : `${part}: rendered a <${tag}> in JS-free mode. Only a <button> is a ` +\n \"`popovertarget` invoker; this trigger will not open the popover. Render a \" +\n \"<button>, or put the component in library mode (`defaultOpen={false}`).\";\n }),\n );\n const ref = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n const unregister = registerTrigger(triggerRef, element, part);\n // JS-free mode: the DOM owns `data-open` (design 9). A Trigger that mounts after the\n // Popup (or is re-created) picks up the current state here.\n if (!isLibrary && popupRef.current !== null) {\n element.toggleAttribute(\"data-open\", isPopoverOpen(popupRef.current));\n }\n return unregister;\n },\n [isLibrary, checkElement, triggerRef, popupRef, part],\n );\n\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Cancelling the click cancels the popover toggle (it runs as the button's activation\n // behaviour, only if the click was not cancelled). Enter and Space synthesise the same click.\n event.preventDefault();\n if (disabled) return;\n if (onActivate !== undefined) onActivate(event);\n else toggleFromTrigger(ctx, event.nativeEvent);\n };\n\n // The component's handlers first, then the Trigger's (design/components/menu.md 14). The click\n // handler is only owned when installed, so a render element keeps its own `onClick` in JS-free\n // mode.\n const merged: PopoverTriggerHandlers = { ...handlers };\n if (isLibrary) {\n const extra = handlers?.onClick;\n merged.onClick =\n extra === undefined\n ? onClick\n : (event) => {\n extra(event);\n onClick(event);\n };\n }\n // The click handler is installed in library mode only; in JS-free mode the activation needs\n // native `disabled` to stop it.\n const disabledProps = disabledButton(render, disabled, {\n handlesClick: isLibrary,\n alwaysFocusable: submenuItem,\n });\n if (!isLibrary && !disabledProps.invoker) {\n // JS-free mode, disabled in the `aria-disabled` branch (a host link): nothing native stops the\n // click, so cancel it (a disabled link must not navigate). Only while disabled, after the\n // component's own handler.\n const extra = handlers?.onClick;\n merged.onClick =\n extra === undefined\n ? cancelClick\n : (event) => {\n extra(event);\n cancelClick(event);\n };\n }\n\n const invoker = disabledProps.invoker && rendersButton(render);\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n // `type` only applies to a <button>; on any other element the key is not owned.\n ...(rendersButton(render) && { type: \"button\" as const }),\n // Owned: a render element must not re-enable a disabled Trigger (in JS-free mode the browser\n // would toggle the popover).\n ...disabledProps.props,\n // Only on a button (or a component, assumed to render one): another element is no invoker,\n // and the attribute would claim otherwise.\n popoverTarget: invoker ? ids.popup : undefined,\n ...RESERVED_INVOKER_KEYS,\n // No `aria-expanded` on an invoker: every engine exposes the popover's shown state from\n // `popovertarget`, and ARIA in HTML forbids the attribute there. Otherwise nothing else\n // exposes the state: library mode renders shown (the popup is in the top layer; `data-open`\n // is the optimistic one), JS-free mode cannot know it and renders \"false\".\n \"aria-expanded\": invoker ? undefined : isLibrary ? ctx.shown : false,\n ...merged,\n \"data-open\": dataAttr(state.open),\n \"data-pending\": dataAttr(state.pending),\n // Every mode: the styling hook agrees with the rendered `disabled` / `aria-disabled`\n // (conventions 1.2).\n \"data-disabled\": dataAttr(disabled),\n };\n\n return { state, libraryProps, ref };\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;AAiBvC,SAAgB,kBACd,KACA,OACA,YACM;CACN,IAAI,IAAI,SAAS,GAAG;EAClB,IAAI,IAAI,mBAAmB,GAAG;GAC5B,IAAI,kBAAkB;IAAE,QAAQ;IAAY;GAAM,CAAC;GACnD;EACF;EACA,IAAI,aAAa,OAAO,UAAU;CACpC,OAAO;EACL,aAAa;EACb,IAAI,YAAY,OAAO,UAAU;CACnC;AACF;;;;;;AAOA,MAAa,wBAAwB;CACnC,qBAAqB,KAAA;CACrB,YAAY,KAAA;CACZ,SAAS,KAAA;AACX;;;;;;AAOA,SAAgB,kBACd,MACA,KACA,SACA,OACQ;CACR,OACE,GAAG,KAAK,gBAAgB,IAAI,4BAA4B,QAAQ,gDACtC,MAAM;AAKpC;;;;;;;;;;;;;AAoEA,SAAgB,kBACd,KACA,SACoB;CACpB,MAAM,EAAE,MAAM,UAAU,QAAQ,UAAU,YAAY,cAAc,UAAU;CAC9E,MAAM,YAAY,IAAI,SAAS;CAC/B,MAAM,EAAE,KAAK,YAAY,aAAa;CAEtC,MAAM,QAAiC;EACrC,MAAM,IAAI;EAGV,SAAS,IAAI;EACb;CACF;CAEA,MAAM,eAAe,gBACnB,WACI,YAAY;EACZ,IAAI,QAAQ,YAAY,UAAU,OAAO;EACzC,MAAM,MAAM,QAAQ,QAAQ,YAAY;EAGxC,IAAI,aAAa,aACf,OACE,GAAG,KAAK,gBAAgB,IAAI;EAKhC,OAAO,YACH,kBAAkB,MAAM,KAAK,WAAW,OAAO,IAC/C,GAAG,KAAK,gBAAgB,IAAI;CAGlC,EACJ;CACA,MAAM,MAAM,aACT,YAAyB;EACxB,eAAe,OAAO;EACtB,MAAM,aAAa,gBAAgB,YAAY,SAAS,IAAI;EAG5D,IAAI,CAAC,aAAa,SAAS,YAAY,MACrC,QAAQ,gBAAgB,aAAa,cAAc,SAAS,OAAO,CAAC;EAEtE,OAAO;CACT,GACA;EAAC;EAAW;EAAc;EAAY;EAAU;CAAI,CACtD;CAEA,MAAM,WAAW,UAAmC;EAGlD,MAAM,eAAe;EACrB,IAAI,UAAU;EACd,IAAI,eAAe,KAAA,GAAW,WAAW,KAAK;OACzC,kBAAkB,KAAK,MAAM,WAAW;CAC/C;CAKA,MAAM,SAAiC,EAAE,GAAG,SAAS;CACrD,IAAI,WAAW;EACb,MAAM,QAAQ,UAAU;EACxB,OAAO,UACL,UAAU,KAAA,IACN,WACC,UAAU;GACT,MAAM,KAAK;GACX,QAAQ,KAAK;EACf;CACR;CAGA,MAAM,gBAAgB,eAAe,QAAQ,UAAU;EACrD,cAAc;EACd,iBAAiB;CACnB,CAAC;CACD,IAAI,CAAC,aAAa,CAAC,cAAc,SAAS;EAIxC,MAAM,QAAQ,UAAU;EACxB,OAAO,UACL,UAAU,KAAA,IACN,eACC,UAAU;GACT,MAAM,KAAK;GACX,YAAY,KAAK;EACnB;CACR;CAEA,MAAM,UAAU,cAAc,WAAW,cAAc,MAAM;CAyB7D,OAAO;EAAE;EAAO,cAAA;GArBd,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;GAGvD,GAAG,cAAc;GAGjB,eAAe,UAAU,IAAI,QAAQ,KAAA;GACrC,GAAG;GAKH,iBAAiB,UAAU,KAAA,IAAY,YAAY,IAAI,QAAQ;GAC/D,GAAG;GACH,aAAa,SAAS,MAAM,IAAI;GAChC,gBAAgB,SAAS,MAAM,OAAO;GAGtC,iBAAiB,SAAS,QAAQ;EAGT;EAAG;CAAI;AACpC"}
1
+ {"version":3,"file":"use-popover-trigger.mjs","names":[],"sources":["../../../src/internal/overlay/use-popover-trigger.ts"],"sourcesContent":["\"use client\";\nimport { useCallback } from \"react\";\nimport type { ComponentPropsWithRef, DOMAttributes, MouseEvent } from \"react\";\nimport { dataAttr } from \"../data-attr.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport { registerTrigger } from \"./trigger-ref.js\";\nimport type { RenderProp } from \"../types.js\";\nimport { useElementCheck } from \"../use-element-check.js\";\nimport { cancelClick, disabledButton, rendersButton } from \"../use-render.js\";\nimport type { DataAttributes } from \"../use-render.js\";\nimport type { PopoverRootValue } from \"./use-overlay-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * The click rule of a Trigger that toggles a popover-kind Root (popover.md 2.8): Popover.Trigger,\n * Menu.Trigger, Menu.SubmenuTrigger (through `usePopoverTrigger`) and Combobox.Trigger. It toggles\n * against what the user already intends (`intended()`, conventions 3.8 rule 1), not the DOM:\n *\n * - intended open, and the browser already hid the popup (a non-button Trigger, #115: light\n * dismiss hid it at `pointerup`, before this click): the hide is a fact, reported by its pending\n * `toggle`; the click only names its cause, an `\"activate\"` close intent;\n * - intended open otherwise: `requestClose(event, \"activate\")`;\n * - intended closed: `beforeOpen()`, then `requestOpen(event, \"activate\")`. First, because what\n * it records (Menu's open cause) must be in place before anything can show the popup. Today the\n * show waits for the apply effect, so the order is not observable.\n *\n * The caller cancels the click and checks `disabled` first. Handlers only.\n */\nexport function toggleFromTrigger(\n ctx: PopoverRootValue,\n event: Event,\n beforeOpen?: () => void,\n): void {\n if (ctx.intended()) {\n if (ctx.hiddenBeforeToggle()) {\n ctx.recordCloseIntent({ reason: \"activate\", event });\n return;\n }\n ctx.requestClose(event, \"activate\");\n } else {\n beforeOpen?.();\n ctx.requestOpen(event, \"activate\");\n }\n}\n\n/**\n * Owned and never written on an overlay Trigger (Popover, Menu, Combobox): the default\n * `popovertarget` action, which a render element must not change, and an Invoker Command, which\n * would take precedence over `popovertarget` and act on another element.\n */\nexport const RESERVED_INVOKER_KEYS = {\n popoverTargetAction: undefined,\n commandfor: undefined,\n command: undefined,\n} as const;\n\n/**\n * The library-mode dev warning for a Trigger rendered as another element than a `<button>`: only\n * an invoker button is spared by the popover's light dismiss, so a press while the popup is open\n * hides it before the click. `popover` and `popup` are the nouns the text uses for it.\n */\nexport function nonInvokerMessage(\n part: string,\n tag: string,\n popover: string,\n popup: string,\n): string {\n return (\n `${part}: rendered a <${tag}>. Only a <button> is the ${popover}'s invoker: a press on ` +\n `this element while the ${popup} is open closes it through light dismiss before the ` +\n \"click, so the close is a dismissal (reported to onOpenChange) rather than a request: \" +\n \"openChangeAction(false) is not called, cannot veto it and there is no view transition. \" +\n \"Render a <button>.\"\n );\n}\n\n/** The state of an overlay Trigger (Popover.Trigger, Menu.Trigger and its siblings). */\nexport interface PopoverTriggerHookState {\n /** Optimistic open state. A Popover in JS-free mode (the browser owns it) reports `false`. */\n readonly open: boolean;\n /** The Root's transition is pending: an open or a part-initiated close (never a dismissal). */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/** Event handlers a component layers onto the Trigger's own (Menu's keys and hover intent). */\nexport type PopoverTriggerHandlers = Pick<\n DOMAttributes<HTMLButtonElement>,\n \"onClick\" | \"onKeyDown\" | \"onMouseDown\" | \"onPointerMove\" | \"onPointerEnter\" | \"onPointerLeave\"\n>;\n\nexport interface UsePopoverTriggerOptions<State> {\n /** Public name of the part for development warnings (`\"Popover.Trigger\"`). */\n readonly part: string;\n readonly disabled: boolean;\n readonly render: RenderProp<ComponentPropsWithRef<\"button\">, State> | undefined;\n /**\n * Extra handlers, merged in front of the Trigger's own: for a key both define, the extra one\n * runs first (the consumer's pass-through handler still runs before both, conventions 1.2).\n */\n readonly handlers?: PopoverTriggerHandlers;\n /**\n * What a click does in library mode, after the command has been cancelled and `disabled`\n * checked. Default: `toggleFromTrigger(ctx, event.nativeEvent)`, the toggle against\n * `intended()` (`requestOpen` / `requestClose`). Menu.Trigger toggles with its open cause;\n * Menu.SubmenuTrigger opens, or moves focus into an already open submenu.\n */\n readonly onActivate?: (event: MouseEvent<HTMLElement>) => void;\n /**\n * Menu.SubmenuTrigger: the Trigger is also an item of the parent menu, whose click\n * (`onActivate`) never closes the popup. `disabled` renders `aria-disabled=\"true\"` and no\n * `disabled` attribute, so the item stays focusable (the click handler still refuses); without\n * it `disabled` is the native attribute, so the button is no invoker at all (in library mode a\n * link or component `render` still gets `aria-disabled`, because native `disabled` means\n * nothing on a link and the installed click handler is what refuses). And the library-mode\n * non-button warning says a press while open dismisses the popup instead of moving focus into\n * it.\n */\n readonly submenuItem?: boolean;\n /**\n * `Menu.Trigger` inside a `Menubar`: an item of the bar, so `disabled` renders\n * `aria-disabled=\"true\"` and the element stays focusable, as with `submenuItem`; the click\n * still toggles and the non-button warning is the ordinary one\n * (design/components/menubar.md 5).\n */\n readonly alwaysFocusable?: boolean;\n}\n\nexport interface PopoverTriggerHook {\n readonly state: PopoverTriggerHookState;\n /** Owned props (conventions 1.2) for `useRender`'s `libraryProps`. */\n readonly libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes;\n /** Registers the element as the Root's Trigger; pass as `useRender`'s `ref`. */\n readonly ref: (element: HTMLElement) => () => void;\n}\n\n/**\n * The Trigger of a popover-like component (design/components/popover.md 14.3):\n * `button[popoverTarget]`, with no `aria-expanded` on an invoker: every engine exposes the\n * popover's shown state from the invoker relationship. In JS-free mode the browser toggles\n * the popover and the Popup keeps `data-open` current on the element. In library mode the click\n * is cancelled (so the activation does not run) and toggles against what the user already\n * intends: an open through `requestOpen`, a library-owned close through `requestClose`. There\n * `data-open` and `state.open` are optimistic; a non-button `render` (no invoker) renders\n * `aria-expanded` from whether the popup is shown (in the top layer).\n *\n * Menu adds `aria-haspopup=\"menu\"` and its own key handling on top.\n */\nexport function usePopoverTrigger<State>(\n ctx: PopoverRootValue,\n options: UsePopoverTriggerOptions<State>,\n): PopoverTriggerHook {\n const {\n part,\n disabled,\n render,\n handlers,\n onActivate,\n submenuItem = false,\n alwaysFocusable = false,\n } = options;\n const isLibrary = ctx.mode === \"library\";\n const { ids, triggerRef, popupRef } = ctx;\n\n const state: PopoverTriggerHookState = {\n open: ctx.optimistic,\n // Opens and part-initiated closes belong to the Trigger (4.2); a dismissal is a fact and\n // pends nothing (conventions 3.9.7).\n pending: ctx.pending,\n disabled,\n };\n\n const checkElement = useElementCheck(\n isDev &&\n ((element) => {\n if (element.tagName === \"BUTTON\") return null;\n const tag = element.tagName.toLowerCase();\n // Library mode: the click handler works, but only an invoker button is spared by the\n // popover's light dismiss, so a press while open hides the popup before the click.\n if (isLibrary && submenuItem) {\n return (\n `${part}: rendered a <${tag}>. Only a <button> is the popover's invoker: a press on ` +\n \"this element while its popup is open dismisses the popup through light dismiss \" +\n \"instead of moving focus into it. Render a <button>.\"\n );\n }\n return isLibrary\n ? nonInvokerMessage(part, tag, \"popover\", \"popup\")\n : `${part}: rendered a <${tag}> in JS-free mode. Only a <button> is a ` +\n \"`popovertarget` invoker; this trigger will not open the popover. Render a \" +\n \"<button>, or put the component in library mode (`defaultOpen={false}`).\";\n }),\n );\n const ref = useCallback(\n (element: HTMLElement) => {\n checkElement?.(element);\n const unregister = registerTrigger(triggerRef, element, part);\n // JS-free mode: the DOM owns `data-open` (design 9). A Trigger that mounts after the\n // Popup (or is re-created) picks up the current state here.\n if (!isLibrary && popupRef.current !== null) {\n element.toggleAttribute(\"data-open\", isPopoverOpen(popupRef.current));\n }\n return unregister;\n },\n [isLibrary, checkElement, triggerRef, popupRef, part],\n );\n\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Cancelling the click cancels the popover toggle (it runs as the button's activation\n // behaviour, only if the click was not cancelled). Enter and Space synthesise the same click.\n event.preventDefault();\n if (disabled) return;\n if (onActivate !== undefined) onActivate(event);\n else toggleFromTrigger(ctx, event.nativeEvent);\n };\n\n // The component's handlers first, then the Trigger's (design/components/menu.md 14). The click\n // handler is only owned when installed, so a render element keeps its own `onClick` in JS-free\n // mode.\n const merged: PopoverTriggerHandlers = { ...handlers };\n if (isLibrary) {\n const extra = handlers?.onClick;\n merged.onClick =\n extra === undefined\n ? onClick\n : (event) => {\n extra(event);\n onClick(event);\n };\n }\n // The click handler is installed in library mode only; in JS-free mode the activation needs\n // native `disabled` to stop it.\n const disabledProps = disabledButton(render, disabled, {\n handlesClick: isLibrary,\n alwaysFocusable: submenuItem || alwaysFocusable,\n });\n if (!isLibrary && !disabledProps.invoker) {\n // JS-free mode, disabled in the `aria-disabled` branch (a host link): nothing native stops the\n // click, so cancel it (a disabled link must not navigate). Only while disabled, after the\n // component's own handler.\n const extra = handlers?.onClick;\n merged.onClick =\n extra === undefined\n ? cancelClick\n : (event) => {\n extra(event);\n cancelClick(event);\n };\n }\n\n const invoker = disabledProps.invoker && rendersButton(render);\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n // `type` only applies to a <button>; on any other element the key is not owned.\n ...(rendersButton(render) && { type: \"button\" as const }),\n // Owned: a render element must not re-enable a disabled Trigger (in JS-free mode the browser\n // would toggle the popover).\n ...disabledProps.props,\n // Only on a button (or a component, assumed to render one): another element is no invoker,\n // and the attribute would claim otherwise.\n popoverTarget: invoker ? ids.popup : undefined,\n ...RESERVED_INVOKER_KEYS,\n // No `aria-expanded` on an invoker: every engine exposes the popover's shown state from\n // `popovertarget`, and ARIA in HTML forbids the attribute there. Otherwise nothing else\n // exposes the state: library mode renders shown (the popup is in the top layer; `data-open`\n // is the optimistic one), JS-free mode cannot know it and renders \"false\".\n \"aria-expanded\": invoker ? undefined : isLibrary ? ctx.shown : false,\n ...merged,\n \"data-open\": dataAttr(state.open),\n \"data-pending\": dataAttr(state.pending),\n // Every mode: the styling hook agrees with the rendered `disabled` / `aria-disabled`\n // (conventions 1.2).\n \"data-disabled\": dataAttr(disabled),\n };\n\n return { state, libraryProps, ref };\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;AAiBvC,SAAgB,kBACd,KACA,OACA,YACM;CACN,IAAI,IAAI,SAAS,GAAG;EAClB,IAAI,IAAI,mBAAmB,GAAG;GAC5B,IAAI,kBAAkB;IAAE,QAAQ;IAAY;GAAM,CAAC;GACnD;EACF;EACA,IAAI,aAAa,OAAO,UAAU;CACpC,OAAO;EACL,aAAa;EACb,IAAI,YAAY,OAAO,UAAU;CACnC;AACF;;;;;;AAOA,MAAa,wBAAwB;CACnC,qBAAqB,KAAA;CACrB,YAAY,KAAA;CACZ,SAAS,KAAA;AACX;;;;;;AAOA,SAAgB,kBACd,MACA,KACA,SACA,OACQ;CACR,OACE,GAAG,KAAK,gBAAgB,IAAI,4BAA4B,QAAQ,gDACtC,MAAM;AAKpC;;;;;;;;;;;;;AA2EA,SAAgB,kBACd,KACA,SACoB;CACpB,MAAM,EACJ,MACA,UACA,QACA,UACA,YACA,cAAc,OACd,kBAAkB,UAChB;CACJ,MAAM,YAAY,IAAI,SAAS;CAC/B,MAAM,EAAE,KAAK,YAAY,aAAa;CAEtC,MAAM,QAAiC;EACrC,MAAM,IAAI;EAGV,SAAS,IAAI;EACb;CACF;CAEA,MAAM,eAAe,gBACnB,WACI,YAAY;EACZ,IAAI,QAAQ,YAAY,UAAU,OAAO;EACzC,MAAM,MAAM,QAAQ,QAAQ,YAAY;EAGxC,IAAI,aAAa,aACf,OACE,GAAG,KAAK,gBAAgB,IAAI;EAKhC,OAAO,YACH,kBAAkB,MAAM,KAAK,WAAW,OAAO,IAC/C,GAAG,KAAK,gBAAgB,IAAI;CAGlC,EACJ;CACA,MAAM,MAAM,aACT,YAAyB;EACxB,eAAe,OAAO;EACtB,MAAM,aAAa,gBAAgB,YAAY,SAAS,IAAI;EAG5D,IAAI,CAAC,aAAa,SAAS,YAAY,MACrC,QAAQ,gBAAgB,aAAa,cAAc,SAAS,OAAO,CAAC;EAEtE,OAAO;CACT,GACA;EAAC;EAAW;EAAc;EAAY;EAAU;CAAI,CACtD;CAEA,MAAM,WAAW,UAAmC;EAGlD,MAAM,eAAe;EACrB,IAAI,UAAU;EACd,IAAI,eAAe,KAAA,GAAW,WAAW,KAAK;OACzC,kBAAkB,KAAK,MAAM,WAAW;CAC/C;CAKA,MAAM,SAAiC,EAAE,GAAG,SAAS;CACrD,IAAI,WAAW;EACb,MAAM,QAAQ,UAAU;EACxB,OAAO,UACL,UAAU,KAAA,IACN,WACC,UAAU;GACT,MAAM,KAAK;GACX,QAAQ,KAAK;EACf;CACR;CAGA,MAAM,gBAAgB,eAAe,QAAQ,UAAU;EACrD,cAAc;EACd,iBAAiB,eAAe;CAClC,CAAC;CACD,IAAI,CAAC,aAAa,CAAC,cAAc,SAAS;EAIxC,MAAM,QAAQ,UAAU;EACxB,OAAO,UACL,UAAU,KAAA,IACN,eACC,UAAU;GACT,MAAM,KAAK;GACX,YAAY,KAAK;EACnB;CACR;CAEA,MAAM,UAAU,cAAc,WAAW,cAAc,MAAM;CAyB7D,OAAO;EAAE;EAAO,cAAA;GArBd,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;GAGvD,GAAG,cAAc;GAGjB,eAAe,UAAU,IAAI,QAAQ,KAAA;GACrC,GAAG;GAKH,iBAAiB,UAAU,KAAA,IAAY,YAAY,IAAI,QAAQ;GAC/D,GAAG;GACH,aAAa,SAAS,MAAM,IAAI;GAChC,gBAAgB,SAAS,MAAM,OAAO;GAGtC,iBAAiB,SAAS,QAAQ;EAGT;EAAG;CAAI;AACpC"}
@@ -20,14 +20,16 @@ const CACHE_LIMIT = 32;
20
20
  const formatters = /* @__PURE__ */ new Map();
21
21
  /**
22
22
  * One `Intl.NumberFormat` per `locale` + `format`, so an update loop does not construct one per
23
- * render. Bounded: past 32 entries the oldest is dropped.
23
+ * render. Bounded: past 32 entries the oldest is dropped. The key is JSON, as in
24
+ * `number-field/number-field-format.ts`, so a list and a string never collide.
24
25
  */
25
26
  function getNumberFormat(locale, format) {
26
27
  const options = format ?? PERCENT;
27
- const key = `${locale ?? ""}\u0000${JSON.stringify(options)}`;
28
+ const key = JSON.stringify([locale ?? null, options]);
28
29
  let formatter = formatters.get(key);
29
30
  if (formatter === void 0) {
30
- formatter = new Intl.NumberFormat(locale, options);
31
+ const locales = typeof locale === "string" || locale === void 0 ? locale : [...locale];
32
+ formatter = new Intl.NumberFormat(locales, options);
31
33
  if (formatters.size >= CACHE_LIMIT) {
32
34
  const oldest = formatters.keys().next().value;
33
35
  if (oldest !== void 0) formatters.delete(oldest);
@@ -1 +1 @@
1
- {"version":3,"file":"range-value.mjs","names":[],"sources":["../../src/internal/range-value.ts"],"sourcesContent":["// No \"use client\": pure arithmetic and formatting shared by the directive-free `Progress.Root`\n// and `Meter.Root` (design/components/progress.md 2.1, 2.2 and implementation note 14.4).\n\n/** The platform's clamp (`<progress>` 150 of 100 is 100). A degenerate range yields `min`. */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\n/** Whether `[min, max]` is empty or a point (`max <= min`): a bug at the call site. */\nexport function isDegenerate(min: number, max: number): boolean {\n return !(max > min);\n}\n\n/** `(value - min) / (max - min)`, `0` for a degenerate range. */\nexport function fraction(value: number, min: number, max: number): number {\n return isDegenerate(min, max) ? 0 : (value - min) / (max - min);\n}\n\n/** The fraction as a number 0–100. */\nexport function percentage(value: number, min: number, max: number): number {\n return fraction(value, min, max) * 100;\n}\n\nconst PERCENT: Intl.NumberFormatOptions = { style: \"percent\" };\nconst CACHE_LIMIT = 32;\nconst formatters = new Map<string, Intl.NumberFormat>();\n\n/**\n * One `Intl.NumberFormat` per `locale` + `format`, so an update loop does not construct one per\n * render. Bounded: past 32 entries the oldest is dropped.\n */\nexport function getNumberFormat(\n locale: string | undefined,\n format: Intl.NumberFormatOptions | undefined,\n): Intl.NumberFormat {\n const options = format ?? PERCENT;\n const key = `${locale ?? \"\"}\\u0000${JSON.stringify(options)}`;\n let formatter = formatters.get(key);\n if (formatter === undefined) {\n formatter = new Intl.NumberFormat(locale, options);\n if (formatters.size >= CACHE_LIMIT) {\n const oldest = formatters.keys().next().value;\n if (oldest !== undefined) formatters.delete(oldest);\n }\n formatters.set(key, formatter);\n }\n return formatter;\n}\n\n/**\n * The visible text of a (clamped) value: the fraction of the range for the `percent` style (the\n * default when `format` is absent), the value itself for any other style. A `format` without\n * `style` is `decimal` per `Intl` and formats the value.\n */\nexport function formatRangeValue(\n value: number,\n min: number,\n max: number,\n format: Intl.NumberFormatOptions | undefined,\n locale: string | undefined,\n): string {\n const percentStyle = format === undefined || format.style === \"percent\";\n return getNumberFormat(locale, format).format(percentStyle ? fraction(value, min, max) : value);\n}\n"],"mappings":";;AAIA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAC3C;;AAGA,SAAgB,aAAa,KAAa,KAAsB;CAC9D,OAAO,EAAE,MAAM;AACjB;;AAGA,SAAgB,SAAS,OAAe,KAAa,KAAqB;CACxE,OAAO,aAAa,KAAK,GAAG,IAAI,KAAK,QAAQ,QAAQ,MAAM;AAC7D;;AAGA,SAAgB,WAAW,OAAe,KAAa,KAAqB;CAC1E,OAAO,SAAS,OAAO,KAAK,GAAG,IAAI;AACrC;AAEA,MAAM,UAAoC,EAAE,OAAO,UAAU;AAC7D,MAAM,cAAc;AACpB,MAAM,6BAAa,IAAI,IAA+B;;;;;AAMtD,SAAgB,gBACd,QACA,QACmB;CACnB,MAAM,UAAU,UAAU;CAC1B,MAAM,MAAM,GAAG,UAAU,GAAG,QAAQ,KAAK,UAAU,OAAO;CAC1D,IAAI,YAAY,WAAW,IAAI,GAAG;CAClC,IAAI,cAAc,KAAA,GAAW;EAC3B,YAAY,IAAI,KAAK,aAAa,QAAQ,OAAO;EACjD,IAAI,WAAW,QAAQ,aAAa;GAClC,MAAM,SAAS,WAAW,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GACxC,IAAI,WAAW,KAAA,GAAW,WAAW,OAAO,MAAM;EACpD;EACA,WAAW,IAAI,KAAK,SAAS;CAC/B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,iBACd,OACA,KACA,KACA,QACA,QACQ;CACR,MAAM,eAAe,WAAW,KAAA,KAAa,OAAO,UAAU;CAC9D,OAAO,gBAAgB,QAAQ,MAAM,CAAC,CAAC,OAAO,eAAe,SAAS,OAAO,KAAK,GAAG,IAAI,KAAK;AAChG"}
1
+ {"version":3,"file":"range-value.mjs","names":[],"sources":["../../src/internal/range-value.ts"],"sourcesContent":["// No \"use client\": pure arithmetic and formatting shared by the directive-free `Progress.Root`\n// and `Meter.Root` (design/components/progress.md 2.1, 2.2 and implementation note 14.4).\n\n/** The platform's clamp (`<progress>` 150 of 100 is 100). A degenerate range yields `min`. */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n\n/** Whether `[min, max]` is empty or a point (`max <= min`): a bug at the call site. */\nexport function isDegenerate(min: number, max: number): boolean {\n return !(max > min);\n}\n\n/** `(value - min) / (max - min)`, `0` for a degenerate range. */\nexport function fraction(value: number, min: number, max: number): number {\n return isDegenerate(min, max) ? 0 : (value - min) / (max - min);\n}\n\n/** The fraction as a number 0–100. */\nexport function percentage(value: number, min: number, max: number): number {\n return fraction(value, min, max) * 100;\n}\n\nconst PERCENT: Intl.NumberFormatOptions = { style: \"percent\" };\nconst CACHE_LIMIT = 32;\nconst formatters = new Map<string, Intl.NumberFormat>();\n\n/** A tag or a preference list of tags, what the `Intl` constructors take (conventions 14.2). */\nexport type RangeLocale = string | readonly string[];\n\n/**\n * One `Intl.NumberFormat` per `locale` + `format`, so an update loop does not construct one per\n * render. Bounded: past 32 entries the oldest is dropped. The key is JSON, as in\n * `number-field/number-field-format.ts`, so a list and a string never collide.\n */\nexport function getNumberFormat(\n locale: RangeLocale | undefined,\n format: Intl.NumberFormatOptions | undefined,\n): Intl.NumberFormat {\n const options = format ?? PERCENT;\n const key = JSON.stringify([locale ?? null, options]);\n let formatter = formatters.get(key);\n if (formatter === undefined) {\n // `Intl` takes a mutable `string[]`: copy a readonly list rather than cast it.\n const locales = typeof locale === \"string\" || locale === undefined ? locale : [...locale];\n formatter = new Intl.NumberFormat(locales, options);\n if (formatters.size >= CACHE_LIMIT) {\n const oldest = formatters.keys().next().value;\n if (oldest !== undefined) formatters.delete(oldest);\n }\n formatters.set(key, formatter);\n }\n return formatter;\n}\n\n/**\n * The visible text of a (clamped) value: the fraction of the range for the `percent` style (the\n * default when `format` is absent), the value itself for any other style. A `format` without\n * `style` is `decimal` per `Intl` and formats the value.\n */\nexport function formatRangeValue(\n value: number,\n min: number,\n max: number,\n format: Intl.NumberFormatOptions | undefined,\n locale: RangeLocale | undefined,\n): string {\n const percentStyle = format === undefined || format.style === \"percent\";\n return getNumberFormat(locale, format).format(percentStyle ? fraction(value, min, max) : value);\n}\n"],"mappings":";;AAIA,SAAgB,MAAM,OAAe,KAAa,KAAqB;CACrE,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAC3C;;AAGA,SAAgB,aAAa,KAAa,KAAsB;CAC9D,OAAO,EAAE,MAAM;AACjB;;AAGA,SAAgB,SAAS,OAAe,KAAa,KAAqB;CACxE,OAAO,aAAa,KAAK,GAAG,IAAI,KAAK,QAAQ,QAAQ,MAAM;AAC7D;;AAGA,SAAgB,WAAW,OAAe,KAAa,KAAqB;CAC1E,OAAO,SAAS,OAAO,KAAK,GAAG,IAAI;AACrC;AAEA,MAAM,UAAoC,EAAE,OAAO,UAAU;AAC7D,MAAM,cAAc;AACpB,MAAM,6BAAa,IAAI,IAA+B;;;;;;AAUtD,SAAgB,gBACd,QACA,QACmB;CACnB,MAAM,UAAU,UAAU;CAC1B,MAAM,MAAM,KAAK,UAAU,CAAC,UAAU,MAAM,OAAO,CAAC;CACpD,IAAI,YAAY,WAAW,IAAI,GAAG;CAClC,IAAI,cAAc,KAAA,GAAW;EAE3B,MAAM,UAAU,OAAO,WAAW,YAAY,WAAW,KAAA,IAAY,SAAS,CAAC,GAAG,MAAM;EACxF,YAAY,IAAI,KAAK,aAAa,SAAS,OAAO;EAClD,IAAI,WAAW,QAAQ,aAAa;GAClC,MAAM,SAAS,WAAW,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GACxC,IAAI,WAAW,KAAA,GAAW,WAAW,OAAO,MAAM;EACpD;EACA,WAAW,IAAI,KAAK,SAAS;CAC/B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,iBACd,OACA,KACA,KACA,QACA,QACQ;CACR,MAAM,eAAe,WAAW,KAAA,KAAa,OAAO,UAAU;CAC9D,OAAO,gBAAgB,QAAQ,MAAM,CAAC,CAAC,OAAO,eAAe,SAAS,OAAO,KAAK,GAAG,IAAI,KAAK;AAChG"}