@astryxdesign/core 0.7.2-canary.f16dc9f → 0.7.2-canary.f2b60a0

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 (307) hide show
  1. package/dist/AppShell/AppShell.d.ts.map +1 -1
  2. package/dist/AppShell/AppShell.js +40 -1
  3. package/dist/AspectRatio/AspectRatio.d.ts +6 -8
  4. package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
  5. package/dist/AspectRatio/AspectRatio.js +44 -3
  6. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  7. package/dist/Breadcrumbs/BreadcrumbItem.js +5 -2
  8. package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
  9. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  10. package/dist/CheckboxInput/CheckboxInput.js +3 -1
  11. package/dist/CheckboxList/CheckboxListItem.d.ts +9 -1
  12. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  13. package/dist/CheckboxList/CheckboxListItem.js +4 -2
  14. package/dist/CommandPalette/CommandPaletteInput.d.ts +1 -1
  15. package/dist/CommandPalette/CommandPaletteInput.d.ts.map +1 -1
  16. package/dist/CommandPalette/CommandPaletteInput.js +37 -5
  17. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  18. package/dist/ContextMenu/ContextMenu.js +5 -2
  19. package/dist/Dialog/Dialog.d.ts.map +1 -1
  20. package/dist/Dialog/Dialog.js +20 -8
  21. package/dist/Drawer/Drawer.d.ts +191 -0
  22. package/dist/Drawer/Drawer.d.ts.map +1 -0
  23. package/dist/Drawer/Drawer.js +382 -0
  24. package/dist/Drawer/DrawerHeader.d.ts +85 -0
  25. package/dist/Drawer/DrawerHeader.d.ts.map +1 -0
  26. package/dist/Drawer/DrawerHeader.js +134 -0
  27. package/dist/Drawer/index.d.ts +11 -0
  28. package/dist/Drawer/index.d.ts.map +1 -0
  29. package/dist/Drawer/index.js +11 -0
  30. package/dist/Drawer/useDrawerDialogPresence.d.ts +42 -0
  31. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -0
  32. package/dist/Drawer/useDrawerDialogPresence.js +236 -0
  33. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -1
  34. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  35. package/dist/DropdownMenu/DropdownMenu.js +83 -11
  36. package/dist/DropdownMenu/DropdownMenuContext.d.ts +17 -0
  37. package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
  38. package/dist/DropdownMenu/DropdownMenuContext.js +21 -0
  39. package/dist/DropdownMenu/DropdownMenuDivider.d.ts +5 -3
  40. package/dist/DropdownMenu/DropdownMenuDivider.d.ts.map +1 -1
  41. package/dist/DropdownMenu/DropdownMenuDivider.js +7 -3
  42. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  43. package/dist/DropdownMenu/DropdownMenuSubMenu.js +19 -8
  44. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +24 -0
  45. package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -0
  46. package/dist/DropdownMenu/lazyMenuBottomSheet.js +46 -0
  47. package/dist/EmptyState/EmptyState.d.ts.map +1 -1
  48. package/dist/EmptyState/EmptyState.js +4 -10
  49. package/dist/Field/Field.d.ts +1 -1
  50. package/dist/Field/Field.d.ts.map +1 -1
  51. package/dist/Field/Field.js +8 -4
  52. package/dist/Grid/GridSpan.d.ts.map +1 -1
  53. package/dist/Grid/GridSpan.js +1 -0
  54. package/dist/Heading/Heading.d.ts.map +1 -1
  55. package/dist/Heading/Heading.js +4 -2
  56. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  57. package/dist/HoverCard/useHoverCard.js +10 -2
  58. package/dist/Item/Item.d.ts +6 -2
  59. package/dist/Item/Item.d.ts.map +1 -1
  60. package/dist/Item/Item.js +19 -4
  61. package/dist/Layer/layerViewportInset.stylex.d.ts +6 -2
  62. package/dist/Layer/layerViewportInset.stylex.d.ts.map +1 -1
  63. package/dist/Layer/layerViewportInset.stylex.js +6 -2
  64. package/dist/Layer/useLayer.d.ts.map +1 -1
  65. package/dist/Layer/useLayer.js +13 -7
  66. package/dist/Layer/useLayerDismissal.d.ts +1 -1
  67. package/dist/Layer/useLayerDismissal.js +1 -1
  68. package/dist/Layout/container.stylex.d.ts +5 -5
  69. package/dist/Layout/container.stylex.js +4 -4
  70. package/dist/List/List.d.ts +46 -19
  71. package/dist/List/List.d.ts.map +1 -1
  72. package/dist/List/List.js +28 -10
  73. package/dist/List/ListContext.d.ts +8 -3
  74. package/dist/List/ListContext.d.ts.map +1 -1
  75. package/dist/List/ListContext.js +7 -2
  76. package/dist/List/ListItem.d.ts +13 -5
  77. package/dist/List/ListItem.d.ts.map +1 -1
  78. package/dist/List/ListItem.js +21 -8
  79. package/dist/List/index.d.ts +1 -1
  80. package/dist/List/index.d.ts.map +1 -1
  81. package/dist/Markdown/Markdown.d.ts.map +1 -1
  82. package/dist/Markdown/Markdown.js +8 -1
  83. package/dist/Markdown/plugins/frontmatter.d.ts.map +1 -1
  84. package/dist/Markdown/plugins/frontmatter.js +7 -3
  85. package/dist/MetadataList/MetadataList.d.ts.map +1 -1
  86. package/dist/MetadataList/MetadataList.js +5 -1
  87. package/dist/MetadataList/MetadataListContext.d.ts +1 -1
  88. package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
  89. package/dist/MobileNav/MobileNav.d.ts +9 -0
  90. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  91. package/dist/MobileNav/MobileNav.js +30 -3
  92. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  93. package/dist/MultiSelector/MultiSelector.js +22 -8
  94. package/dist/MultiSelector/OptionActions.a11y.chromium.spec.js +100 -2
  95. package/dist/Popover/Popover.js +2 -2
  96. package/dist/RadioList/RadioList.d.ts +1 -1
  97. package/dist/RadioList/RadioList.d.ts.map +1 -1
  98. package/dist/RadioList/RadioList.js +6 -2
  99. package/dist/RadioList/RadioListItem.d.ts +9 -1
  100. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  101. package/dist/RadioList/RadioListItem.js +2 -0
  102. package/dist/SideNav/SideNavItem.d.ts +8 -1
  103. package/dist/SideNav/SideNavItem.d.ts.map +1 -1
  104. package/dist/SideNav/SideNavItem.js +71 -9
  105. package/dist/TabList/TabMenu.d.ts +2 -2
  106. package/dist/TabList/TabMenu.d.ts.map +1 -1
  107. package/dist/TabList/TabMenu.js +6 -3
  108. package/dist/Text/Text.d.ts.map +1 -1
  109. package/dist/Text/Text.js +4 -2
  110. package/dist/Text/useTruncation.d.ts +7 -5
  111. package/dist/Text/useTruncation.d.ts.map +1 -1
  112. package/dist/Text/useTruncation.js +16 -5
  113. package/dist/ToggleButton/ToggleButton.d.ts +3 -2
  114. package/dist/ToggleButton/ToggleButton.d.ts.map +1 -1
  115. package/dist/ToggleButton/ToggleButton.js +12 -1
  116. package/dist/TopNav/TopNavMegaMenu.d.ts.map +1 -1
  117. package/dist/TopNav/TopNavMegaMenu.js +3 -3
  118. package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
  119. package/dist/TopNav/TopNavMenu.js +3 -3
  120. package/dist/TreeList/TreeList.d.ts.map +1 -1
  121. package/dist/TreeList/TreeList.js +1 -0
  122. package/dist/TreeList/TreeListBranches.d.ts.map +1 -1
  123. package/dist/TreeList/TreeListBranches.js +2 -2
  124. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  125. package/dist/TreeList/TreeListItem.js +57 -9
  126. package/dist/astryx.css +46 -13
  127. package/dist/hooks/useEntryAnimation.d.ts +2 -1
  128. package/dist/hooks/useEntryAnimation.d.ts.map +1 -1
  129. package/dist/hooks/useEntryAnimation.js +14 -12
  130. package/dist/hooks/useIsHydrating.d.ts +6 -0
  131. package/dist/hooks/useIsHydrating.d.ts.map +1 -0
  132. package/dist/hooks/useIsHydrating.js +30 -0
  133. package/dist/hooks/useMenuHover.d.ts.map +1 -1
  134. package/dist/hooks/useMenuHover.js +18 -13
  135. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  136. package/dist/i18n/generated-locales/en.generated.js +93 -1
  137. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  138. package/dist/i18n/generated-locales/pseudo.generated.js +93 -1
  139. package/dist/index.d.ts +1 -0
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +1 -0
  142. package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
  143. package/dist/theme/derivedVarRegistry.js +0 -3
  144. package/dist/utils/focusOutline.stylex.d.ts +4 -0
  145. package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
  146. package/dist/utils/focusOutline.stylex.js +4 -0
  147. package/dist/utils/plainDate.d.ts.map +1 -1
  148. package/dist/utils/plainDate.js +15 -9
  149. package/dist/utils/sharedMutationObserver.d.ts +21 -0
  150. package/dist/utils/sharedMutationObserver.d.ts.map +1 -0
  151. package/dist/utils/sharedMutationObserver.js +69 -0
  152. package/locales/en.json +368 -0
  153. package/locales/pseudo.json +276 -0
  154. package/package.json +8 -3
  155. package/scripts/agent-doc-state.mjs +38 -0
  156. package/scripts/postinstall.mjs +1 -1
  157. package/src/AppShell/AppShell.tsx +45 -1
  158. package/src/AspectRatio/AspectRatio.test.tsx +44 -43
  159. package/src/AspectRatio/AspectRatio.tsx +38 -18
  160. package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +157 -0
  161. package/src/Avatar/Avatar.doc.mjs +5 -3
  162. package/src/AvatarGroup/AvatarGroup.doc.mjs +3 -2
  163. package/src/Breadcrumbs/BreadcrumbItem.tsx +4 -1
  164. package/src/Breadcrumbs/Breadcrumbs.test.tsx +30 -1
  165. package/src/Card/Card.doc.mjs +1 -1
  166. package/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts +3 -1
  167. package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
  168. package/src/CheckboxInput/CheckboxInput.tsx +3 -1
  169. package/src/CheckboxList/CheckboxList.test.tsx +22 -0
  170. package/src/CheckboxList/CheckboxListItem.doc.mjs +16 -0
  171. package/src/CheckboxList/CheckboxListItem.tsx +10 -0
  172. package/src/CommandPalette/CommandPaletteInput.test.tsx +53 -4
  173. package/src/CommandPalette/CommandPaletteInput.tsx +33 -3
  174. package/src/CommandPalette/__tests__/CommandPaletteInputAudit.a11y.chromium.spec.ts +335 -0
  175. package/src/CommandPalette/__tests__/CommandPaletteItemAudit.a11y.chromium.spec.ts +292 -0
  176. package/src/ContextMenu/ContextMenu.doc.mjs +2 -3
  177. package/src/ContextMenu/ContextMenu.tsx +4 -1
  178. package/src/ContextMenu/__tests__/ContextMenuAudit.a11y.chromium.spec.ts +438 -0
  179. package/src/Dialog/Dialog.test.tsx +46 -0
  180. package/src/Dialog/Dialog.tsx +20 -7
  181. package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -14
  182. package/src/Drawer/Drawer.doc.mjs +472 -0
  183. package/src/Drawer/Drawer.spec.md +357 -0
  184. package/src/Drawer/Drawer.test.tsx +1300 -0
  185. package/src/Drawer/Drawer.tsx +613 -0
  186. package/src/Drawer/DrawerDirection.test.tsx +127 -0
  187. package/src/Drawer/DrawerHeader.doc.mjs +293 -0
  188. package/src/Drawer/DrawerHeader.test.tsx +102 -0
  189. package/src/Drawer/DrawerHeader.tsx +235 -0
  190. package/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts +401 -0
  191. package/src/Drawer/__tests__/DrawerHeaderAudit.a11y.chromium.spec.ts +297 -0
  192. package/src/Drawer/index.ts +13 -0
  193. package/src/Drawer/useDrawerDialogPresence.ts +284 -0
  194. package/src/DropdownMenu/DropdownMenu.ssr.test.tsx +57 -0
  195. package/src/DropdownMenu/DropdownMenu.test.tsx +76 -14
  196. package/src/DropdownMenu/DropdownMenu.tsx +83 -12
  197. package/src/DropdownMenu/DropdownMenuContext.tsx +24 -0
  198. package/src/DropdownMenu/DropdownMenuDivider.doc.mjs +2 -2
  199. package/src/DropdownMenu/DropdownMenuDivider.spec.md +192 -0
  200. package/src/DropdownMenu/DropdownMenuDivider.tsx +9 -5
  201. package/src/DropdownMenu/DropdownMenuLazySheet.test.tsx +126 -0
  202. package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +185 -0
  203. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +19 -5
  204. package/src/DropdownMenu/__tests__/DropdownMenuDividerAudit.a11y.chromium.spec.ts +280 -0
  205. package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +145 -0
  206. package/src/DropdownMenu/__tests__/Menu.a11y.known-failures.ts +26 -0
  207. package/src/DropdownMenu/__tests__/Menu.a11y.renders.tsx +65 -0
  208. package/src/DropdownMenu/__tests__/Menu.a11y.states.ts +138 -0
  209. package/src/DropdownMenu/__tests__/Menu.a11y.test.tsx +136 -0
  210. package/src/DropdownMenu/__tests__/warmMenuBottomSheet.tsx +43 -0
  211. package/src/DropdownMenu/lazyMenuBottomSheet.ts +71 -0
  212. package/src/EmptyState/EmptyState.doc.mjs +3 -2
  213. package/src/EmptyState/EmptyState.spec.md +189 -0
  214. package/src/EmptyState/EmptyState.test.tsx +74 -3
  215. package/src/EmptyState/EmptyState.tsx +4 -8
  216. package/src/Field/Field.doc.mjs +14 -8
  217. package/src/Field/Field.spec.md +217 -0
  218. package/src/Field/Field.test.tsx +60 -2
  219. package/src/Field/Field.tsx +17 -8
  220. package/src/Grid/GridSpan.tsx +3 -0
  221. package/src/Heading/Heading.test.tsx +57 -0
  222. package/src/Heading/Heading.tsx +6 -2
  223. package/src/HoverCard/HoverCard.test.tsx +58 -0
  224. package/src/HoverCard/useHoverCard.tsx +10 -2
  225. package/src/Item/Item.doc.mjs +12 -8
  226. package/src/Item/Item.spec.md +226 -0
  227. package/src/Item/Item.test.tsx +61 -0
  228. package/src/Item/Item.tsx +40 -4
  229. package/src/Layer/layerViewportInset.source-build.test.mjs +90 -0
  230. package/src/Layer/layerViewportInset.stylex.ts +6 -2
  231. package/src/Layer/layerViewportInset.test.ts +1 -0
  232. package/src/Layer/useLayer.tsx +24 -13
  233. package/src/Layer/useLayerDismissal.ts +1 -1
  234. package/src/Layout/container.stylex.ts +6 -6
  235. package/src/List/List.doc.mjs +14 -1
  236. package/src/List/List.spec.md +129 -77
  237. package/src/List/List.test.tsx +163 -94
  238. package/src/List/List.tsx +74 -18
  239. package/src/List/ListContext.tsx +9 -3
  240. package/src/List/ListItem.doc.mjs +16 -0
  241. package/src/List/ListItem.tsx +56 -27
  242. package/src/List/index.ts +1 -1
  243. package/src/Markdown/Markdown.tsx +14 -1
  244. package/src/Markdown/plugins/frontmatter.test.tsx +25 -0
  245. package/src/Markdown/plugins/frontmatter.ts +7 -3
  246. package/src/MetadataList/MetadataList.doc.mjs +2 -2
  247. package/src/MetadataList/MetadataList.test.tsx +38 -0
  248. package/src/MetadataList/MetadataList.tsx +8 -1
  249. package/src/MetadataList/MetadataListContext.tsx +1 -1
  250. package/src/MobileNav/MobileNav.tsx +30 -3
  251. package/src/MobileNav/MobileNavCloseEdgeCases.test.tsx +173 -15
  252. package/src/MoreMenu/MoreMenu.test.tsx +5 -1
  253. package/src/MultiSelector/MultiSelector.test.tsx +159 -0
  254. package/src/MultiSelector/MultiSelector.tsx +40 -7
  255. package/src/MultiSelector/OptionActions.a11y.chromium.spec.ts +112 -2
  256. package/src/Popover/Popover.test.tsx +2 -2
  257. package/src/Popover/Popover.tsx +4 -4
  258. package/src/RadioList/RadioList.fr10.test.tsx +45 -2
  259. package/src/RadioList/RadioList.test.tsx +22 -0
  260. package/src/RadioList/RadioList.tsx +4 -1
  261. package/src/RadioList/RadioListItem.doc.mjs +16 -0
  262. package/src/RadioList/RadioListItem.tsx +10 -1
  263. package/src/SideNav/SideNav.test.tsx +179 -0
  264. package/src/SideNav/SideNavItem.doc.mjs +2 -2
  265. package/src/SideNav/SideNavItem.tsx +96 -17
  266. package/src/Slider/Slider.spec.md +39 -18
  267. package/src/TabList/TabList.spec.md +57 -44
  268. package/src/TabList/TabList.test.tsx +67 -0
  269. package/src/TabList/TabMenu.doc.mjs +4 -3
  270. package/src/TabList/TabMenu.tsx +7 -4
  271. package/src/Text/Text.test.tsx +57 -0
  272. package/src/Text/Text.tsx +6 -2
  273. package/src/Text/useTruncation.test.tsx +69 -0
  274. package/src/Text/useTruncation.ts +16 -5
  275. package/src/TimeInput/TimeInput.fr10.test.tsx +15 -0
  276. package/src/ToggleButton/ToggleButton.test.tsx +95 -0
  277. package/src/ToggleButton/ToggleButton.tsx +12 -1
  278. package/src/Tooltip/Tooltip.test.tsx +31 -0
  279. package/src/TopNav/TopNavMegaMenu.test.tsx +22 -0
  280. package/src/TopNav/TopNavMegaMenu.tsx +7 -3
  281. package/src/TopNav/TopNavMenu.test.tsx +19 -0
  282. package/src/TopNav/TopNavMenu.tsx +11 -3
  283. package/src/TreeList/TreeList.doc.mjs +1 -0
  284. package/src/TreeList/TreeList.spec.md +29 -17
  285. package/src/TreeList/TreeList.test.tsx +327 -6
  286. package/src/TreeList/TreeList.tsx +5 -1
  287. package/src/TreeList/TreeListBranches.tsx +6 -0
  288. package/src/TreeList/TreeListItem.tsx +88 -13
  289. package/src/docPropLiterals.test.ts +36 -10
  290. package/src/hooks/useEntryAnimation.doc.mjs +4 -4
  291. package/src/hooks/useEntryAnimation.ssr.test.tsx +143 -0
  292. package/src/hooks/useEntryAnimation.ts +15 -16
  293. package/src/hooks/useIsHydrating.test.tsx +70 -0
  294. package/src/hooks/useIsHydrating.ts +31 -0
  295. package/src/hooks/useMenuHover.ts +18 -13
  296. package/src/i18n/generated-locales/en.generated.ts +100 -0
  297. package/src/i18n/generated-locales/pseudo.generated.ts +100 -0
  298. package/src/index.ts +1 -0
  299. package/src/postinstall.test.mjs +46 -0
  300. package/src/reset.css +0 -29
  301. package/src/theme/derivedVarRegistry.test.ts +7 -3
  302. package/src/theme/derivedVarRegistry.ts +0 -3
  303. package/src/utils/focusOutline.stylex.ts +4 -0
  304. package/src/utils/plainDate.test.ts +37 -1
  305. package/src/utils/plainDate.ts +15 -5
  306. package/src/utils/sharedMutationObserver.test.ts +53 -0
  307. package/src/utils/sharedMutationObserver.ts +78 -0
@@ -0,0 +1,134 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file DrawerHeader.tsx
7
+ * @input Uses React, StyleX, LayoutHeader, Button, Icon, Heading, Text, i18n, BaseProps, isRenderable, mergeProps, themeProps
8
+ * @output Exports DrawerHeader component and DrawerHeaderProps
9
+ * @position Drawer header; composed in a Layout header slot inside Drawer, tested by DrawerHeader.test.tsx
10
+ *
11
+ * Mirrors DialogHeader's API: a title, an optional subtitle, start/end content
12
+ * slots, and a close button that renders only when `onOpenChange` is passed.
13
+ * Two differences follow from Drawer's contract:
14
+ * - It does not move focus on mount. Drawer owns focus entry through
15
+ * `data-autofocus` once its native host is presented.
16
+ * - It does not name the drawer. Drawer's required `label` does.
17
+ *
18
+ * SYNC: When modified, update these files to stay in sync:
19
+ * - /packages/core/src/Drawer/DrawerHeader.doc.mjs (props, anatomy, theming)
20
+ * - /packages/core/src/Drawer/DrawerHeader.test.tsx (tests for new/changed behavior)
21
+ * - /packages/core/src/Drawer/index.ts (exports if types change)
22
+ * - /packages/cli/assets/templates/blocks/components/Drawer/ (showcase blocks)
23
+ * - /packages/cli/assets/templates/blocks/components/DrawerHeader/ (showcase blocks)
24
+ * - /apps/storybook/stories/Drawer.stories.tsx (examples and visual coverage)
25
+ * - /apps/storybook/stories/DrawerHeader.stories.tsx (component audit fixture)
26
+ */
27
+ import * as stylex from '@stylexjs/stylex';
28
+ import "../theme/tokens.stylex.js";
29
+ import { sizeVars, spacingVars, typeScaleVars } from "../theme/tokens.stylex.js";
30
+ import { Button } from "../Button/index.js";
31
+ import { Heading } from "../Heading/index.js";
32
+ import { Icon } from "../Icon/index.js";
33
+ import { LayoutHeader } from "../Layout/index.js";
34
+ import { Text } from "../Text/index.js";
35
+ import { useTranslator } from "../i18n/index.js";
36
+ import { isRenderable, mergeProps, themeProps } from "../utils/index.js";
37
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
38
+ /**
39
+ * Header for a Drawer: a title, optional subtitle and start/end content, and a
40
+ * close button when `onOpenChange` is passed. Same API as DialogHeader.
41
+ *
42
+ * Uses LayoutHeader internally for consistent styling with other layout headers.
43
+ *
44
+ * @example
45
+ * ```
46
+ * <Drawer isOpen={isOpen} onOpenChange={setIsOpen} label="Details">
47
+ * <DrawerHeader title="Details" onOpenChange={setIsOpen} />
48
+ * <Section padding={4}>Content</Section>
49
+ * </Drawer>
50
+ * ```
51
+ */
52
+ export function DrawerHeader({
53
+ title,
54
+ subtitle,
55
+ onOpenChange,
56
+ startContent,
57
+ endContent,
58
+ endContentEdgeCompensation,
59
+ hasDivider,
60
+ xstyle,
61
+ className,
62
+ style,
63
+ ref,
64
+ ...rest
65
+ }) {
66
+ const t = useTranslator();
67
+ const hasSubtitle = isRenderable(subtitle);
68
+ const hasStartContent = isRenderable(startContent);
69
+ const hasEndContent = isRenderable(endContent);
70
+ const shouldCompensateEndBlock = endContentEdgeCompensation == null ? onOpenChange != null : endContentEdgeCompensation === 'block' || endContentEdgeCompensation === 'all';
71
+ const shouldCompensateEndInline = endContentEdgeCompensation == null ? onOpenChange != null : endContentEdgeCompensation === 'inline' || endContentEdgeCompensation === 'all';
72
+ return /*#__PURE__*/_jsx(LayoutHeader, {
73
+ ref: ref,
74
+ hasDivider: hasDivider,
75
+ xstyle: xstyle,
76
+ className: className,
77
+ style: style,
78
+ ...rest,
79
+ children: /*#__PURE__*/_jsxs("div", {
80
+ ...mergeProps(themeProps('drawer-header'), {
81
+ className: "x78zum5 x1cy8zhl x1qughib xjcht0a"
82
+ }),
83
+ children: [hasStartContent && /*#__PURE__*/_jsx("div", {
84
+ ...mergeProps(themeProps('drawer-header-start-content'), {
85
+ className: "x78zum5 x6s0dn4 x1txdalj x2lah0s"
86
+ }),
87
+ children: startContent
88
+ }), /*#__PURE__*/_jsxs("div", {
89
+ ...mergeProps(themeProps('drawer-header-title-block'), {
90
+ className: "x78zum5 xdt5ytf xsn7fz1 x98rzlu xeuugli xqixskq"
91
+ }),
92
+ children: [/*#__PURE__*/_jsx(Heading, {
93
+ level: 2,
94
+ children: title
95
+ }), hasSubtitle && /*#__PURE__*/_jsx(Text, {
96
+ type: "body",
97
+ size: "sm",
98
+ color: "secondary",
99
+ children: subtitle
100
+ })]
101
+ }), (hasEndContent || onOpenChange != null) && /*#__PURE__*/_jsxs("div", {
102
+ ...mergeProps(themeProps('drawer-header-end-content'), {
103
+ 0: {
104
+ className: "x78zum5 x6s0dn4 x1txdalj x2lah0s"
105
+ },
106
+ 2: {
107
+ className: "x78zum5 x6s0dn4 x1txdalj x2lah0s xhzvc8f"
108
+ },
109
+ 1: {
110
+ className: "x78zum5 x6s0dn4 x1txdalj x2lah0s x3kzqx6"
111
+ },
112
+ 3: {
113
+ className: "x78zum5 x6s0dn4 x1txdalj x2lah0s xhzvc8f x3kzqx6"
114
+ }
115
+ }[!!shouldCompensateEndBlock << 1 | !!shouldCompensateEndInline << 0]),
116
+ children: [endContent, onOpenChange && /*#__PURE__*/_jsx(Button, {
117
+ variant: "ghost",
118
+ label: t('@astryx.dialog.close'),
119
+ tooltip: t('@astryx.dialog.close'),
120
+ icon: /*#__PURE__*/_jsx(Icon, {
121
+ icon: "close",
122
+ color: "inherit",
123
+ ...themeProps('drawer-header-close-icon')
124
+ }),
125
+ onClick: () => {
126
+ onOpenChange(false);
127
+ },
128
+ isIconOnly: true
129
+ })]
130
+ })]
131
+ })
132
+ });
133
+ }
134
+ DrawerHeader.displayName = 'DrawerHeader';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file index.ts
3
+ * @input Drawer.tsx, DrawerHeader.tsx
4
+ * @output Re-exports Drawer and DrawerHeader components and their prop types
5
+ * @position Core entry point for the Drawer directory (`@astryxdesign/core/Drawer`)
6
+ */
7
+ export { Drawer } from './Drawer';
8
+ export type { DrawerProps } from './Drawer';
9
+ export { DrawerHeader } from './DrawerHeader';
10
+ export type { DrawerHeaderProps } from './DrawerHeader';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Drawer/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,YAAY,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file index.ts
5
+ * @input Drawer.tsx, DrawerHeader.tsx
6
+ * @output Re-exports Drawer and DrawerHeader components and their prop types
7
+ * @position Core entry point for the Drawer directory (`@astryxdesign/core/Drawer`)
8
+ */
9
+
10
+ export { Drawer } from "./Drawer.js";
11
+ export { DrawerHeader } from "./DrawerHeader.js";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file useDrawerDialogPresence.ts
3
+ * @input Controlled open state, modal mode, dialog ref, and rendered-state setter
4
+ * @output Coordinates native top-layer presence, exit timing, focus restoration, and unmount cleanup
5
+ * @position Drawer-internal hook; consumed only by Drawer.tsx
6
+ *
7
+ * The drawer has two independent notions of presence:
8
+ * - React's rendered state keeps the panel visible for its CSS exit.
9
+ * - Native `showModal()` or `showPopover()` state keeps it in the browser top
10
+ * layer.
11
+ *
12
+ * Their close ordering is a browser-visible invariant: the panel must finish
13
+ * its exit, then leave the active native host and hide in the same task. If the
14
+ * hide lands a frame later, a transformed ancestor becomes the containing block
15
+ * for the now-non-top-layer `position: fixed` panel and it paints back inside
16
+ * the page for one frame.
17
+ *
18
+ * SYNC: When modified, update:
19
+ * - /packages/core/src/Drawer/Drawer.test.tsx
20
+ * - /.github/scripts/modal-close-visibility.js
21
+ */
22
+ import { type Dispatch, type RefObject, type SetStateAction } from 'react';
23
+ type UseDrawerDialogPresenceOptions = {
24
+ dialogRef: RefObject<HTMLDialogElement | null>;
25
+ isOpen: boolean;
26
+ isModal: boolean;
27
+ setIsRendered: Dispatch<SetStateAction<boolean>>;
28
+ };
29
+ /**
30
+ * Coordinates the native dialog and React-rendered presence for Drawer.
31
+ *
32
+ * Opening captures the trigger, enters the modal-dialog or manual-popover host,
33
+ * and honours the component's `data-autofocus` contract. Closing waits for the
34
+ * actual transform transition (with a computed-duration backstop), then leaves
35
+ * the native host and synchronously hides the panel before the browser can paint
36
+ * it outside the top layer, restores focus to the captured trigger, and only
37
+ * then dispatches the popover host's synthetic `close`. Unmount cleanup closes
38
+ * a host left open by React Activity or a removed subtree.
39
+ */
40
+ export declare function useDrawerDialogPresence({ dialogRef, isOpen, isModal, setIsRendered, }: UseDrawerDialogPresenceOptions): void;
41
+ export {};
42
+ //# sourceMappingURL=useDrawerDialogPresence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDrawerDialogPresence.d.ts","sourceRoot":"","sources":["../../src/Drawer/useDrawerDialogPresence.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAaf,KAAK,8BAA8B,GAAG;IACpC,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAClD,CAAC;AAuDF;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,SAAS,EACT,MAAM,EACN,OAAO,EACP,aAAa,GACd,EAAE,8BAA8B,GAAG,IAAI,CAoEvC"}
@@ -0,0 +1,236 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useDrawerDialogPresence.ts
7
+ * @input Controlled open state, modal mode, dialog ref, and rendered-state setter
8
+ * @output Coordinates native top-layer presence, exit timing, focus restoration, and unmount cleanup
9
+ * @position Drawer-internal hook; consumed only by Drawer.tsx
10
+ *
11
+ * The drawer has two independent notions of presence:
12
+ * - React's rendered state keeps the panel visible for its CSS exit.
13
+ * - Native `showModal()` or `showPopover()` state keeps it in the browser top
14
+ * layer.
15
+ *
16
+ * Their close ordering is a browser-visible invariant: the panel must finish
17
+ * its exit, then leave the active native host and hide in the same task. If the
18
+ * hide lands a frame later, a transformed ancestor becomes the containing block
19
+ * for the now-non-top-layer `position: fixed` panel and it paints back inside
20
+ * the page for one frame.
21
+ *
22
+ * SYNC: When modified, update:
23
+ * - /packages/core/src/Drawer/Drawer.test.tsx
24
+ * - /.github/scripts/modal-close-visibility.js
25
+ */
26
+ import { useEffect, useRef } from 'react';
27
+ import { flushSync } from 'react-dom';
28
+
29
+ /** Slack past the computed transition before the backstop gives up waiting. */
30
+ const EXIT_BACKSTOP_BUFFER_MS = 50;
31
+
32
+ /**
33
+ * Hold used when the transition duration cannot be read — an unresolved
34
+ * `var()` outside a real browser. Picking a fixed number would otherwise make
35
+ * an assumption about the consumer's theme.
36
+ */
37
+ const EXIT_FALLBACK_MS = 250;
38
+ function isPopoverOpen(dialog) {
39
+ try {
40
+ return dialog.matches(':popover-open');
41
+ } catch {
42
+ // jsdom and pre-Popover browsers do not recognize :popover-open.
43
+ return false;
44
+ }
45
+ }
46
+ function isDrawerHostOpen(dialog, isModal) {
47
+ return isModal ? dialog.open : isPopoverOpen(dialog) || dialog.open;
48
+ }
49
+ function showDrawerHost(dialog, isModal) {
50
+ if (isModal) {
51
+ dialog.showModal();
52
+ } else if (typeof dialog.showPopover === 'function') {
53
+ dialog.showPopover();
54
+ } else {
55
+ // Reduced fallback for browsers below the Popover API support floor.
56
+ dialog.show();
57
+ }
58
+ }
59
+ function dispatchDialogClose(dialog) {
60
+ const EventConstructor = dialog.ownerDocument.defaultView?.Event ?? Event;
61
+ dialog.dispatchEvent(new EventConstructor('close'));
62
+ }
63
+
64
+ /**
65
+ * Leaves the active native host. Returns whether the caller owes a synthetic
66
+ * `close` dispatch: `dialog.close()` used to power the non-modal path, and
67
+ * consumers observe its native `close` event through refs/onClose. Popover
68
+ * dismissal has no equivalent event, so that public DOM contract is preserved
69
+ * explicitly — but by the caller, not here. Native `close` is queued as a
70
+ * task, so a consumer's listener always ran after this hook's own focus
71
+ * restore; the synthetic event must keep that ordering (and fire exactly once
72
+ * per exit, including the unmount path).
73
+ */
74
+ function hideDrawerHost(dialog, isModal) {
75
+ if (!isModal && typeof dialog.hidePopover === 'function') {
76
+ dialog.hidePopover();
77
+ return true;
78
+ }
79
+ if (dialog.open) {
80
+ dialog.close();
81
+ }
82
+ return false;
83
+ }
84
+
85
+ /**
86
+ * Coordinates the native dialog and React-rendered presence for Drawer.
87
+ *
88
+ * Opening captures the trigger, enters the modal-dialog or manual-popover host,
89
+ * and honours the component's `data-autofocus` contract. Closing waits for the
90
+ * actual transform transition (with a computed-duration backstop), then leaves
91
+ * the native host and synchronously hides the panel before the browser can paint
92
+ * it outside the top layer, restores focus to the captured trigger, and only
93
+ * then dispatches the popover host's synthetic `close`. Unmount cleanup closes
94
+ * a host left open by React Activity or a removed subtree.
95
+ */
96
+ export function useDrawerDialogPresence({
97
+ dialogRef,
98
+ isOpen,
99
+ isModal,
100
+ setIsRendered
101
+ }) {
102
+ // Element focused when the drawer opened — restored on close.
103
+ const triggerElementRef = useRef(null);
104
+ useEffect(() => {
105
+ const dialog = dialogRef.current;
106
+ if (!dialog) {
107
+ return;
108
+ }
109
+ if (isOpen) {
110
+ if (!isDrawerHostOpen(dialog, isModal)) {
111
+ triggerElementRef.current = document.activeElement;
112
+ showDrawerHost(dialog, isModal);
113
+ // React's autoFocus calls .focus() during commit, before the native host
114
+ // is visible, so it silently fails — honour data-autofocus instead (same
115
+ // contract as Dialog).
116
+ dialog.querySelector('[data-autofocus]')?.focus();
117
+ }
118
+ return;
119
+ }
120
+ if (!isDrawerHostOpen(dialog, isModal)) {
121
+ return;
122
+ }
123
+ return waitForDrawerExit(dialog, () => {
124
+ const owesCloseEvent = hideDrawerHost(dialog, isModal);
125
+ // flushSync, not a plain setState: React's default scheduling can land
126
+ // the commit after the next paint, and that one frame is exactly the
127
+ // bug — the panel paints outside the top layer. Both happen in this
128
+ // task, so the browser never gets to paint between them.
129
+ // eslint-disable-next-line @eslint-react/dom-no-flush-sync -- the panel must stop painting in the task the native host closes
130
+ flushSync(() => {
131
+ setIsRendered(false);
132
+ });
133
+ // Return focus after leaving the native host: a modal dialog makes the
134
+ // rest of the document inert, so focusing earlier silently fails.
135
+ triggerElementRef.current?.focus();
136
+ triggerElementRef.current = null;
137
+ // The synthetic popover close fires after the focus restore above,
138
+ // mirroring the task-queued native event: a consumer close listener
139
+ // that retargets focus (master-detail row switching) gets the last word.
140
+ if (owesCloseEvent) {
141
+ dispatchDialogClose(dialog);
142
+ }
143
+ });
144
+ }, [dialogRef, isModal, isOpen, setIsRendered]);
145
+
146
+ // Leave the active native host on unmount. When the drawer is mounted inside
147
+ // an <Activity> that flips to mode="hidden", React runs effect cleanups (with
148
+ // stale isOpen) instead of re-running the effect with isOpen=false. Leaving
149
+ // the host active would strand the top-layer surface and skip the next open.
150
+ // This is deliberately separate from the open/close effect: putting it in
151
+ // that cleanup would cut off every delayed slide-out.
152
+ useEffect(() => {
153
+ const dialog = dialogRef.current;
154
+ return () => {
155
+ if (dialog && isDrawerHostOpen(dialog, isModal)) {
156
+ if (hideDrawerHost(dialog, isModal)) {
157
+ // No focus restore on this path — the drawer is being torn down, so
158
+ // the owed synthetic close fires immediately (still exactly once).
159
+ dispatchDialogClose(dialog);
160
+ }
161
+ }
162
+ };
163
+ }, [dialogRef, isModal]);
164
+ }
165
+
166
+ /**
167
+ * Wait for the panel's transform transition, with a computed-duration
168
+ * backstop. Mirrors BottomSheetPanel.waitForTransition: the native event is
169
+ * authoritative, and the timeout only prevents a lost event from stranding an
170
+ * open dialog.
171
+ */
172
+ function waitForDrawerExit(element, complete) {
173
+ let done = false;
174
+ let timer = null;
175
+ const finish = () => {
176
+ if (done) {
177
+ return;
178
+ }
179
+ done = true;
180
+ if (timer != null) {
181
+ clearTimeout(timer);
182
+ }
183
+ element.removeEventListener('transitionend', handleTransitionEnd);
184
+ element.removeEventListener('transitioncancel', handleTransitionEnd);
185
+ complete();
186
+ };
187
+ const handleTransitionEnd = event => {
188
+ if (event.target === element && event.propertyName === 'transform') {
189
+ finish();
190
+ }
191
+ };
192
+ element.addEventListener('transitionend', handleTransitionEnd);
193
+ element.addEventListener('transitioncancel', handleTransitionEnd);
194
+ const transitionMs = readTransformTransitionMs(element);
195
+ timer = setTimeout(finish, (transitionMs ?? EXIT_FALLBACK_MS) + EXIT_BACKSTOP_BUFFER_MS);
196
+ return () => {
197
+ done = true;
198
+ if (timer != null) {
199
+ clearTimeout(timer);
200
+ }
201
+ element.removeEventListener('transitionend', handleTransitionEnd);
202
+ element.removeEventListener('transitioncancel', handleTransitionEnd);
203
+ };
204
+ }
205
+
206
+ /** Read the transform transition's duration + delay from computed CSS. */
207
+ function readTransformTransitionMs(element) {
208
+ const computed = window.getComputedStyle(element);
209
+ const properties = computed.transitionProperty.split(',').map(value => value.trim());
210
+ const durations = parseTimes(computed.transitionDuration);
211
+ const delays = parseTimes(computed.transitionDelay);
212
+ if (properties.length === 0 || durations.length === 0 || delays.length === 0 || durations.includes(null) || delays.includes(null)) {
213
+ return null;
214
+ }
215
+ return properties.reduce((longest, property, index) => {
216
+ if (property !== 'transform' && property !== 'all') {
217
+ return longest;
218
+ }
219
+ const duration = durations[index % durations.length];
220
+ const delay = delays[index % delays.length];
221
+ return Math.max(longest, (duration ?? 0) + (delay ?? 0));
222
+ }, 0);
223
+ }
224
+ function parseTimes(value) {
225
+ return value.split(',').map(part => {
226
+ const trimmed = part.trim();
227
+ const time = Number.parseFloat(trimmed);
228
+ if (!Number.isFinite(time)) {
229
+ return null;
230
+ }
231
+ if (trimmed.endsWith('ms')) {
232
+ return time;
233
+ }
234
+ return trimmed.endsWith('s') ? time * 1000 : null;
235
+ });
236
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file DropdownMenu.tsx
3
- * @input Uses React, StyleX, usePopover, MenuBottomSheet, Button, List,
3
+ * @input Uses React, StyleX, usePopover, MenuBottomSheet (lazy), Button, List,
4
4
  * useListFocus, and the shared viewport-safe menu-width resolver
5
5
  * @output Exports DropdownMenu with caller-selected popover or bottom-sheet
6
6
  * presentation
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenu.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,EAAS,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAKnD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAyB9D,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAC,cAAc,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAStE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAmQ5C;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,qBAAqB,EACnB,MAAM,GACN,SAAS,GACT,YAAY,GACZ,SAAS,GACT,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,MAAM,GACN,QAAQ,GACR,KAAK,CACR;IACC;;;;;;OAMG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA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AS,CAAC;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAE3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IAEnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,qBAAsB,SAAQ,qBAAqB;IAC3D;;;;;OAKG;IACH,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,UAAU,yBAA0B,SAAQ,qBAAqB;IAC/D,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,iBAAiB,GAC3B,qBAAqB,GAAG,yBAAyB,CAAC;AAiuCpD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBA4CpD;yBA5Ce,YAAY"}
@@ -4,7 +4,7 @@
4
4
 
5
5
  /**
6
6
  * @file DropdownMenu.tsx
7
- * @input Uses React, StyleX, usePopover, MenuBottomSheet, Button, List,
7
+ * @input Uses React, StyleX, usePopover, MenuBottomSheet (lazy), Button, List,
8
8
  * useListFocus, and the shared viewport-safe menu-width resolver
9
9
  * @output Exports DropdownMenu with caller-selected popover or bottom-sheet
10
10
  * presentation
@@ -42,7 +42,7 @@ import { Heading } from "../Heading/index.js";
42
42
  import { Icon } from "../Icon/index.js";
43
43
  import { renderDropdownItems } from "./renderDropdownItems.js";
44
44
  import { MENU_ITEM_ROLES, MENU_ITEM_SELECTOR, MENU_BOUNDARY_SELECTOR, activateMenuItem } from "./menuItemRoles.js";
45
- import { DropdownMenuContext } from "./DropdownMenuContext.js";
45
+ import { DropdownMenuContext, DropdownMenuRootOpenContext } from "./DropdownMenuContext.js";
46
46
  import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
47
47
  import { useListFocus } from "../hooks/useListFocus.js";
48
48
  import { useMenuPress } from "../hooks/useMenuPress.js";
@@ -58,8 +58,8 @@ import { resolveMenuWidth } from "./menuWidth.js";
58
58
  import "../Layer/layerViewportInset.stylex.js";
59
59
  import { layerViewportInset } from "../Layer/layerViewportInset.stylex.js";
60
60
  import { useAdaptivePresentation } from "../hooks/useAdaptivePresentation.js";
61
- import { MenuBottomSheet } from "./MenuBottomSheet.js";
62
- import { MenuBottomSheetActionList } from "./MenuBottomSheetActionList.js";
61
+ // Loaded on demand: only the bottom-sheet presentation renders the sheet.
62
+ import { MenuBottomSheet, MenuBottomSheetActionList } from "./lazyMenuBottomSheet.js";
63
63
  import { layerAnimations } from "../Layer/layerAnimations.stylex.js";
64
64
  import "../theme/tokens.stylex.js";
65
65
  import { spacingVars, colorVars, radiusVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
@@ -172,7 +172,7 @@ const styles = {
172
172
  kI3sdo: "x1a2a7pz",
173
173
  k7VYTy: "xpdipgo",
174
174
  kfSwDN: "x87ps6o",
175
- ks0D6T: "x1p5vr2b",
175
+ ks0D6T: "xc0b1yq",
176
176
  kskxy: "x1uh1i8a",
177
177
  "--_dropdown-menu-radius": "x1fcsqxe",
178
178
  "--_dropdown-menu-padding": "xgory14",
@@ -491,12 +491,41 @@ function DropdownMenuBottomSheet({
491
491
  if (!isOpen || openModalityRef.current !== 'keyboard') {
492
492
  return;
493
493
  }
494
- const frame = requestAnimationFrame(() => {
495
- actionListRef.current?.querySelector('button:not(:disabled), a[href]')?.focus({
496
- preventScroll: true
494
+ const findFirstAction = () => actionListRef.current?.querySelector('button:not(:disabled), a[href]') ?? null;
495
+ let observer = null;
496
+ let frame = requestAnimationFrame(() => {
497
+ const action = findFirstAction();
498
+ if (action != null) {
499
+ action.focus({
500
+ preventScroll: true
501
+ });
502
+ return;
503
+ }
504
+ // The sheet loads on demand, so a keyboard open can arrive before its
505
+ // rows exist. Wait for them, then focus a frame later so the sheet's
506
+ // own open-focus has already run.
507
+ observer = new MutationObserver(() => {
508
+ const loaded = findFirstAction();
509
+ if (loaded == null) {
510
+ return;
511
+ }
512
+ observer?.disconnect();
513
+ observer = null;
514
+ frame = requestAnimationFrame(() => {
515
+ loaded.focus({
516
+ preventScroll: true
517
+ });
518
+ });
519
+ });
520
+ observer.observe(document.body, {
521
+ childList: true,
522
+ subtree: true
497
523
  });
498
524
  });
499
- return () => cancelAnimationFrame(frame);
525
+ return () => {
526
+ cancelAnimationFrame(frame);
527
+ observer?.disconnect();
528
+ };
500
529
  }, [currentItems, isOpen]);
501
530
  useEffect(() => {
502
531
  if (!isOpen) {
@@ -693,6 +722,43 @@ function DropdownMenuPopover({
693
722
  // above it ends the gesture in flight through this ref.
694
723
  const cancelMenuPressRef = useRef(() => {});
695
724
 
725
+ // Submenu flyouts are `popover="manual"` elements nested inside the menu's
726
+ // `popover="auto"` element, so the browser's light dismiss of the menu never
727
+ // reaches them: without a sweep they keep their open state and their
728
+ // top-layer entry while the menu is hidden, and re-anchor to the viewport
729
+ // corner when the menu reopens (#6893). Closing them through the popover
730
+ // API lets useLayer's toggle handling reset their state. Only flyouts that
731
+ // are actually open are touched: `:popover-open` ships wherever
732
+ // `hidePopover` does (they are one API), and the display fallback keeps its
733
+ // own open signal (`display: block`) so it is guarded the same way.
734
+ const hideOpenFlyouts = useCallback(() => {
735
+ const menuPopover = contentRef.current;
736
+ if (!menuPopover) {
737
+ return;
738
+ }
739
+ // Innermost first: hiding a flyout may unmount the flyouts nested inside
740
+ // it, and a detached element no longer has the toggle listener that
741
+ // resets its open state.
742
+ const flyouts = [...menuPopover.querySelectorAll('[popover]')].reverse();
743
+ for (const flyout of flyouts) {
744
+ if (typeof flyout.hidePopover === 'function') {
745
+ if (flyout.matches(':popover-open')) {
746
+ flyout.hidePopover();
747
+ }
748
+ } else if (flyout.style.display === 'block') {
749
+ flyout.style.display = 'none';
750
+ const toggle = new Event('toggle', {
751
+ bubbles: false
752
+ });
753
+ Object.defineProperty(toggle, 'newState', {
754
+ value: 'closed',
755
+ configurable: true
756
+ });
757
+ flyout.dispatchEvent(toggle);
758
+ }
759
+ }
760
+ }, []);
761
+
696
762
  // Focus lands somewhere stated when the menu closes. A press outside that
697
763
  // landed on a focusable control has already moved focus there; leave it.
698
764
  // Otherwise — a row acted, Escape, a press on nothing — focus returns to
@@ -700,6 +766,9 @@ function DropdownMenuPopover({
700
766
  // keyboard (the modality tracker decides; the suppressed style hides the
701
767
  // pointer case, which Safari would otherwise paint after a touch pick).
702
768
  const handleLayerHide = useCallback(() => {
769
+ // Whatever closed the menu — light dismiss, the dismissal stack, Escape
770
+ // or a controlled close — its flyouts close with it.
771
+ hideOpenFlyouts();
703
772
  if (suppressControlledRollbackHideRef.current) {
704
773
  suppressControlledRollbackHideRef.current = false;
705
774
  return;
@@ -728,7 +797,7 @@ function DropdownMenuPopover({
728
797
  focusForLastInput(trigger, {
729
798
  preventScroll: true
730
799
  });
731
- }, [isControlled, onOpenChange, prepareFocusReturn]);
800
+ }, [hideOpenFlyouts, isControlled, onOpenChange, prepareFocusReturn]);
732
801
 
733
802
  // Defer item focus until the layer has committed open, so focus restore
734
803
  // captures the trigger instead of the first menu item.
@@ -1260,7 +1329,10 @@ function DropdownMenuPopover({
1260
1329
  value: hasRegions,
1261
1330
  children: /*#__PURE__*/_jsx(DropdownMenuContext, {
1262
1331
  value: contextValue,
1263
- children: menuContent
1332
+ children: /*#__PURE__*/_jsx(DropdownMenuRootOpenContext, {
1333
+ value: isOpen,
1334
+ children: menuContent
1335
+ })
1264
1336
  })
1265
1337
  })
1266
1338
  })), {
@@ -43,6 +43,23 @@ export interface DropdownMenuContextValue {
43
43
  */
44
44
  menuLabel?: string;
45
45
  }
46
+ /**
47
+ * Whether the root menu of this layer tree is open; internal companion to
48
+ * `DropdownMenuContext`, on its own unexported context so the public
49
+ * `DropdownMenuContextValue` surface stays unchanged. A sub-menu's hover
50
+ * intent must die with the menu: a hover-open scheduled on its trigger
51
+ * before the menu closed from elsewhere would otherwise fire into the
52
+ * hidden menu and reopen the flyout behind it (#6893). `null` means no
53
+ * signal, treated as open, matching providers that have no state to give.
54
+ * @internal
55
+ */
56
+ export declare const DropdownMenuRootOpenContext: import("react").Context<boolean | null>;
57
+ /**
58
+ * Whether the root menu backing these compound items is open. True when no
59
+ * provider gave a signal.
60
+ * @internal
61
+ */
62
+ export declare function useDropdownMenuRootOpen(): boolean;
46
63
  export declare const DropdownMenuContext: import("react").Context<DropdownMenuContextValue | null>;
47
64
  /**
48
65
  * Hook for compound menu items to access menu state.
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenuContext.d.ts","sourceRoot":"","sources":["../../src/DropdownMenu/DropdownMenuContext.tsx"],"names":[],"mappings":"AAmBA,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACjC,wEAAwE;IACxE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,2DAA2D;IAC3D,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,kDAAkD;IAClD,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