@primer/react 0.0.0-20260428150519 → 0.0.0-20260428191209

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 (362) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/ActionBar/ActionBar.js +705 -502
  3. package/dist/ActionBar/ActionBar.module.css.js +5 -10
  4. package/dist/ActionBar/index.js +8 -8
  5. package/dist/ActionList/{ActionList-53389912.css → ActionList-09f5c4a8.css} +2 -2
  6. package/dist/ActionList/ActionList-09f5c4a8.css.map +1 -0
  7. package/dist/ActionList/ActionList.module.css.js +5 -31
  8. package/dist/ActionList/ActionListContainerContext.js +5 -4
  9. package/dist/ActionList/Description.js +133 -117
  10. package/dist/ActionList/Divider.js +38 -31
  11. package/dist/ActionList/Group.js +349 -292
  12. package/dist/ActionList/Group.module.css.js +5 -10
  13. package/dist/ActionList/Heading.js +106 -88
  14. package/dist/ActionList/Heading.module.css.js +5 -5
  15. package/dist/ActionList/Item.js +811 -668
  16. package/dist/ActionList/LinkItem.js +56 -36
  17. package/dist/ActionList/List.js +210 -168
  18. package/dist/ActionList/Selection.d.ts +2 -3
  19. package/dist/ActionList/Selection.d.ts.map +1 -1
  20. package/dist/ActionList/Selection.js +112 -83
  21. package/dist/ActionList/TrailingAction.js +112 -97
  22. package/dist/ActionList/Visuals.js +191 -143
  23. package/dist/ActionList/index.d.ts +7 -0
  24. package/dist/ActionList/index.d.ts.map +1 -1
  25. package/dist/ActionList/index.js +38 -33
  26. package/dist/ActionList/shared.js +9 -5
  27. package/dist/ActionMenu/ActionMenu.js +310 -223
  28. package/dist/ActionMenu/ActionMenu.module.css.js +5 -5
  29. package/dist/AnchoredOverlay/AnchoredOverlay.js +280 -206
  30. package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +5 -9
  31. package/dist/Autocomplete/Autocomplete.js +141 -125
  32. package/dist/Autocomplete/AutocompleteContext.js +20 -18
  33. package/dist/Autocomplete/AutocompleteInput.js +146 -108
  34. package/dist/Autocomplete/AutocompleteMenu.js +238 -201
  35. package/dist/Autocomplete/AutocompleteMenu.module.css.js +5 -8
  36. package/dist/Autocomplete/AutocompleteOverlay.js +79 -54
  37. package/dist/Autocomplete/AutocompleteOverlay.module.css.js +5 -5
  38. package/dist/Avatar/Avatar.js +133 -106
  39. package/dist/Avatar/Avatar.module.css.js +5 -5
  40. package/dist/AvatarStack/AvatarStack.js +143 -102
  41. package/dist/AvatarStack/AvatarStack.module.css.js +5 -9
  42. package/dist/Banner/Banner.js +186 -133
  43. package/dist/Banner/Banner.module.css.js +5 -14
  44. package/dist/Banner/index.js +7 -7
  45. package/dist/BaseStyles.js +91 -74
  46. package/dist/BaseStyles.module.css.js +5 -5
  47. package/dist/Blankslate/Blankslate.js +328 -266
  48. package/dist/Blankslate/Blankslate.module.css.js +5 -12
  49. package/dist/Blankslate/BlankslateContext.js +9 -7
  50. package/dist/Blankslate/index.js +9 -9
  51. package/dist/BranchName/BranchName.js +59 -49
  52. package/dist/BranchName/BranchName.module.css.js +5 -5
  53. package/dist/Breadcrumbs/Breadcrumbs.js +431 -371
  54. package/dist/Breadcrumbs/Breadcrumbs.module.css.js +5 -15
  55. package/dist/Button/Button.js +18 -15
  56. package/dist/Button/ButtonBase.js +139 -76
  57. package/dist/Button/ButtonBase.module.css.js +5 -16
  58. package/dist/Button/IconButton.js +74 -42
  59. package/dist/Button/LinkButton.js +17 -13
  60. package/dist/ButtonGroup/ButtonGroup.js +97 -80
  61. package/dist/ButtonGroup/ButtonGroup.module.css.js +5 -5
  62. package/dist/Card/Card.js +491 -401
  63. package/dist/Card/Card.module.css.js +5 -18
  64. package/dist/Card/index.js +9 -9
  65. package/dist/Checkbox/Checkbox.js +71 -52
  66. package/dist/Checkbox/Checkbox.module.css.js +5 -9
  67. package/dist/Checkbox/shared.module.css.js +5 -5
  68. package/dist/CheckboxGroup/CheckboxGroup.js +132 -111
  69. package/dist/CheckboxGroup/CheckboxGroupContext.js +4 -4
  70. package/dist/CircleBadge/CircleBadge.js +90 -77
  71. package/dist/CircleBadge/CircleBadge.module.css.js +5 -8
  72. package/dist/ConfirmationDialog/ConfirmationDialog.js +92 -68
  73. package/dist/CounterLabel/CounterLabel.js +99 -83
  74. package/dist/CounterLabel/CounterLabel.module.css.js +5 -5
  75. package/dist/DataTable/DataTable.js +140 -100
  76. package/dist/DataTable/ErrorDialog.js +45 -33
  77. package/dist/DataTable/Pagination.js +592 -464
  78. package/dist/DataTable/Pagination.module.css.js +5 -13
  79. package/dist/DataTable/Table.js +710 -527
  80. package/dist/DataTable/Table.module.css.js +5 -26
  81. package/dist/DataTable/column.js +11 -10
  82. package/dist/DataTable/index.js +20 -22
  83. package/dist/DataTable/sorting.js +103 -65
  84. package/dist/DataTable/useTable.js +290 -207
  85. package/dist/Details/Details.js +126 -100
  86. package/dist/Details/Details.module.css.js +5 -5
  87. package/dist/Dialog/Dialog.js +351 -259
  88. package/dist/Dialog/Dialog.module.css.js +5 -22
  89. package/dist/FeatureFlags/DefaultFeatureFlags.js +7 -7
  90. package/dist/FeatureFlags/FeatureFlagContext.js +5 -5
  91. package/dist/FeatureFlags/FeatureFlagScope.js +44 -36
  92. package/dist/FeatureFlags/FeatureFlags.js +37 -29
  93. package/dist/FeatureFlags/useFeatureFlag.js +19 -17
  94. package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
  95. package/dist/FilteredActionList/FilteredActionList.js +559 -454
  96. package/dist/FilteredActionList/FilteredActionList.module.css.js +5 -15
  97. package/dist/FilteredActionList/FilteredActionListInput.d.ts +15 -0
  98. package/dist/FilteredActionList/FilteredActionListInput.d.ts.map +1 -0
  99. package/dist/FilteredActionList/FilteredActionListInput.js +119 -0
  100. package/dist/FilteredActionList/FilteredActionListLoaders.js +150 -119
  101. package/dist/FilteredActionList/FilteredActionListLoaders.module.css.js +5 -9
  102. package/dist/FilteredActionList/index.d.ts +9 -1
  103. package/dist/FilteredActionList/index.d.ts.map +1 -1
  104. package/dist/FilteredActionList/index.js +11 -0
  105. package/dist/FilteredActionList/useAnnouncements.js +180 -167
  106. package/dist/Flash/Flash.js +69 -57
  107. package/dist/Flash/Flash.module.css.js +5 -5
  108. package/dist/FormControl/FormControl.js +227 -211
  109. package/dist/FormControl/FormControl.module.css.js +5 -11
  110. package/dist/FormControl/FormControlCaption.js +49 -37
  111. package/dist/FormControl/FormControlCaption.module.css.js +5 -5
  112. package/dist/FormControl/FormControlLabel.js +115 -95
  113. package/dist/FormControl/FormControlLeadingVisual.js +37 -29
  114. package/dist/FormControl/FormControlLeadingVisual.module.css.js +5 -5
  115. package/dist/FormControl/_FormControlContext.js +48 -41
  116. package/dist/FormControl/_FormControlValidation.js +39 -29
  117. package/dist/Header/Header.js +165 -138
  118. package/dist/Header/Header.module.css.js +5 -9
  119. package/dist/Heading/Heading.js +37 -26
  120. package/dist/Heading/Heading.module.css.js +5 -5
  121. package/dist/Hidden/Hidden.js +77 -54
  122. package/dist/Hidden/Hidden.module.css.js +5 -5
  123. package/dist/InlineMessage/InlineMessage.js +116 -88
  124. package/dist/InlineMessage/InlineMessage.module.css.js +5 -8
  125. package/dist/KeybindingHint/KeybindingHint.js +88 -70
  126. package/dist/KeybindingHint/KeybindingHint.module.css.js +5 -5
  127. package/dist/KeybindingHint/components/Chord.js +93 -81
  128. package/dist/KeybindingHint/components/Chord.module.css.js +5 -11
  129. package/dist/KeybindingHint/components/Key.js +66 -49
  130. package/dist/KeybindingHint/components/Sequence.js +24 -12
  131. package/dist/KeybindingHint/key-names.js +114 -99
  132. package/dist/Label/Label.js +66 -56
  133. package/dist/Label/Label.module.css.js +5 -5
  134. package/dist/Label/index.js +5 -5
  135. package/dist/LabelGroup/LabelGroup.js +344 -260
  136. package/dist/LabelGroup/LabelGroup.module.css.js +5 -12
  137. package/dist/Link/Link.js +47 -31
  138. package/dist/Link/Link.module.css.js +5 -5
  139. package/dist/NavList/NavList.js +614 -424
  140. package/dist/NavList/NavList.module.css.js +5 -5
  141. package/dist/Octicon/Octicon.js +37 -35
  142. package/dist/Overlay/Overlay.js +318 -264
  143. package/dist/Overlay/Overlay.module.css.js +5 -8
  144. package/dist/PageHeader/PageHeader.js +823 -579
  145. package/dist/PageHeader/PageHeader.module.css.js +5 -21
  146. package/dist/PageLayout/PageLayout.js +913 -631
  147. package/dist/PageLayout/PageLayout.module.css.js +5 -31
  148. package/dist/PageLayout/paneUtils.js +29 -15
  149. package/dist/PageLayout/usePaneWidth.js +437 -334
  150. package/dist/Pagehead/Pagehead.js +14 -10
  151. package/dist/Pagehead/Pagehead.module.css.js +5 -5
  152. package/dist/Pagination/Pagination.js +114 -84
  153. package/dist/Pagination/Pagination.module.css.js +5 -9
  154. package/dist/Pagination/index.js +5 -5
  155. package/dist/Pagination/model.js +194 -118
  156. package/dist/Popover/Popover.js +151 -126
  157. package/dist/Popover/Popover.module.css.js +5 -8
  158. package/dist/Portal/Portal.js +85 -65
  159. package/dist/Portal/index.js +6 -5
  160. package/dist/ProgressBar/ProgressBar.js +255 -210
  161. package/dist/ProgressBar/ProgressBar.module.css.js +5 -9
  162. package/dist/ProgressBar/index.js +8 -6
  163. package/dist/Radio/Radio.js +115 -97
  164. package/dist/Radio/Radio.module.css.js +5 -5
  165. package/dist/RadioGroup/RadioGroup.js +118 -99
  166. package/dist/RelativeTime/RelativeTime.js +76 -64
  167. package/dist/ScrollableRegion/ScrollableRegion.js +79 -67
  168. package/dist/ScrollableRegion/ScrollableRegion.module.css.js +5 -5
  169. package/dist/SegmentedControl/SegmentedControl.js +287 -238
  170. package/dist/SegmentedControl/SegmentedControl.module.css.js +5 -15
  171. package/dist/SegmentedControl/SegmentedControlButton.js +187 -156
  172. package/dist/SegmentedControl/SegmentedControlIconButton.js +161 -133
  173. package/dist/Select/Select.js +234 -185
  174. package/dist/Select/Select.module.css.js +5 -10
  175. package/dist/SelectPanel/SelectPanel.d.ts +1 -0
  176. package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
  177. package/dist/SelectPanel/SelectPanel.js +829 -620
  178. package/dist/SelectPanel/SelectPanel.module.css.js +5 -27
  179. package/dist/SelectPanel/SelectPanelMessage.js +39 -37
  180. package/dist/SelectPanel/index.d.ts +1 -0
  181. package/dist/SelectPanel/index.d.ts.map +1 -1
  182. package/dist/SideNav.js +47 -24
  183. package/dist/SideNav.module.css.js +5 -12
  184. package/dist/Skeleton/SkeletonBox.js +111 -94
  185. package/dist/Skeleton/SkeletonBox.module.css.js +5 -8
  186. package/dist/SkeletonAvatar/SkeletonAvatar.js +120 -95
  187. package/dist/SkeletonAvatar/SkeletonAvatar.module.css.js +5 -5
  188. package/dist/SkeletonText/SkeletonText.js +137 -114
  189. package/dist/SkeletonText/SkeletonText.module.css.js +5 -8
  190. package/dist/Spinner/Spinner.js +211 -183
  191. package/dist/Spinner/Spinner.module.css.js +5 -9
  192. package/dist/SplitPageLayout/SplitPageLayout.js +276 -215
  193. package/dist/Stack/Stack.js +255 -207
  194. package/dist/Stack/Stack.module.css.js +5 -8
  195. package/dist/Stack/index.js +6 -4
  196. package/dist/StateLabel/StateLabel.js +123 -110
  197. package/dist/StateLabel/StateLabel.module.css.js +5 -8
  198. package/dist/SubNav/SubNav.js +197 -159
  199. package/dist/SubNav/SubNav.module.css.js +5 -11
  200. package/dist/TabNav/TabNav.js +199 -167
  201. package/dist/TabNav/TabNav.module.css.js +5 -10
  202. package/dist/Text/Text.js +67 -56
  203. package/dist/Text/Text.module.css.js +5 -5
  204. package/dist/TextInput/TextInput.js +228 -195
  205. package/dist/TextInput/TextInput.module.css.js +5 -8
  206. package/dist/TextInputWithTokens/TextInputWithTokens.js +673 -567
  207. package/dist/TextInputWithTokens/TextInputWithTokens.module.css.js +5 -14
  208. package/dist/Textarea/TextArea.module.css.js +5 -9
  209. package/dist/Textarea/Textarea.js +294 -264
  210. package/dist/ThemeProvider.js +257 -199
  211. package/dist/Timeline/Timeline.js +247 -204
  212. package/dist/Timeline/Timeline.module.css.js +5 -12
  213. package/dist/ToggleSwitch/ToggleSwitch.js +471 -403
  214. package/dist/ToggleSwitch/ToggleSwitch.module.css.js +5 -16
  215. package/dist/Token/IssueLabelToken.js +297 -256
  216. package/dist/Token/IssueLabelToken.module.css.js +5 -8
  217. package/dist/Token/Token.js +280 -232
  218. package/dist/Token/Token.module.css.js +5 -9
  219. package/dist/Token/TokenBase.js +126 -99
  220. package/dist/Token/TokenBase.module.css.js +5 -5
  221. package/dist/Token/_RemoveTokenButton.js +48 -27
  222. package/dist/Token/_RemoveTokenButton.module.css.js +5 -5
  223. package/dist/Token/_TokenTextContainer.js +65 -54
  224. package/dist/Token/_TokenTextContainer.module.css.js +5 -5
  225. package/dist/Tooltip/Tooltip.js +56 -49
  226. package/dist/Tooltip/Tooltip.module.css.js +5 -20
  227. package/dist/TooltipV2/Tooltip.js +305 -222
  228. package/dist/TooltipV2/Tooltip.module.css.js +5 -11
  229. package/dist/TopicTag/TopicTag.js +55 -46
  230. package/dist/TopicTag/TopicTag.module.css.js +5 -5
  231. package/dist/TopicTag/TopicTagGroup.js +48 -40
  232. package/dist/TopicTag/TopicTagGroup.module.css.js +5 -5
  233. package/dist/TopicTag/index.js +7 -5
  234. package/dist/TreeView/TreeView.js +1414 -1082
  235. package/dist/TreeView/TreeView.module.css.js +5 -24
  236. package/dist/TreeView/shared.js +9 -10
  237. package/dist/TreeView/useRovingTabIndex.js +203 -129
  238. package/dist/TreeView/useTreeItemCache.js +79 -64
  239. package/dist/TreeView/useTypeahead.js +112 -90
  240. package/dist/Truncate/Truncate.js +33 -21
  241. package/dist/Truncate/Truncate.module.css.js +5 -5
  242. package/dist/UnderlineNav/UnderlineNav.js +375 -278
  243. package/dist/UnderlineNav/UnderlineNav.module.css.js +5 -8
  244. package/dist/UnderlineNav/UnderlineNavContext.js +8 -8
  245. package/dist/UnderlineNav/UnderlineNavItem.js +72 -56
  246. package/dist/UnderlineNav/UnderlineNavItem.module.css.js +5 -5
  247. package/dist/UnderlineNav/index.js +7 -5
  248. package/dist/UnderlineNav/styles.js +15 -11
  249. package/dist/VisuallyHidden/VisuallyHidden.js +49 -51
  250. package/dist/VisuallyHidden/VisuallyHidden.module.css.js +5 -5
  251. package/dist/_VisuallyHidden.js +62 -50
  252. package/dist/_VisuallyHidden.module.css.js +5 -5
  253. package/dist/deprecated/ActionList/Divider.js +23 -23
  254. package/dist/deprecated/ActionList/Divider.module.css.js +5 -5
  255. package/dist/deprecated/ActionList/Group.js +50 -43
  256. package/dist/deprecated/ActionList/Header.js +81 -69
  257. package/dist/deprecated/ActionList/Header.module.css.js +5 -5
  258. package/dist/deprecated/ActionList/Item.js +352 -308
  259. package/dist/deprecated/ActionList/Item.module.css.js +5 -18
  260. package/dist/deprecated/ActionList/List.js +196 -157
  261. package/dist/deprecated/ActionList/List.module.css.js +5 -5
  262. package/dist/deprecated/ActionList/index.js +14 -14
  263. package/dist/deprecated/ActionMenu.js +190 -159
  264. package/dist/deprecated/DialogV1/Dialog.js +200 -166
  265. package/dist/deprecated/DialogV1/Dialog.module.css.js +5 -11
  266. package/dist/deprecated/FilteredSearch/FilteredSearch.js +51 -43
  267. package/dist/deprecated/FilteredSearch/FilteredSearch.module.css.js +5 -5
  268. package/dist/deprecated/UnderlineNav/UnderlineNav.js +160 -132
  269. package/dist/deprecated/UnderlineNav/UnderlineNav.module.css.js +5 -14
  270. package/dist/deprecated/index.js +9 -20
  271. package/dist/experimental/IssueLabel/IssueLabel.js +158 -134
  272. package/dist/experimental/IssueLabel/IssueLabel.module.css.js +5 -5
  273. package/dist/experimental/SelectPanel2/SelectPanel.js +567 -419
  274. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +5 -32
  275. package/dist/experimental/Tabs/Tabs.js +297 -234
  276. package/dist/experimental/UnderlinePanels/UnderlinePanels.js +215 -165
  277. package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +5 -5
  278. package/dist/experimental/index.d.ts +2 -2
  279. package/dist/experimental/index.d.ts.map +1 -1
  280. package/dist/experimental/index.js +34 -44
  281. package/dist/hooks/useAnchoredPosition.js +144 -123
  282. package/dist/hooks/useControllableState.js +59 -34
  283. package/dist/hooks/useDetails.js +99 -84
  284. package/dist/hooks/useDialog.js +178 -140
  285. package/dist/hooks/useFocusTrap.js +71 -57
  286. package/dist/hooks/useFocusZone.js +38 -32
  287. package/dist/hooks/useId.js +16 -14
  288. package/dist/hooks/useIsMacOS.js +26 -21
  289. package/dist/hooks/useMedia.js +68 -54
  290. package/dist/hooks/useMenuInitialFocus.js +62 -65
  291. package/dist/hooks/useMenuKeyboardNavigation.js +126 -129
  292. package/dist/hooks/useMergedRefs.js +78 -63
  293. package/dist/hooks/useMnemonics.js +107 -77
  294. package/dist/hooks/useOnEscapePress.js +56 -45
  295. package/dist/hooks/useOnOutsideClick.js +63 -32
  296. package/dist/hooks/useOpenAndCloseFocus.js +43 -40
  297. package/dist/hooks/useOverflow.js +36 -32
  298. package/dist/hooks/useOverlay.js +75 -56
  299. package/dist/hooks/useProvidedRefOrCreate.js +24 -24
  300. package/dist/hooks/useProvidedStateOrCreate.js +39 -33
  301. package/dist/hooks/useRefObjectAsForwardedRef.js +32 -30
  302. package/dist/hooks/useRenderForcingRef.js +46 -42
  303. package/dist/hooks/useResizeObserver.js +43 -32
  304. package/dist/hooks/useResponsiveValue.js +57 -37
  305. package/dist/hooks/useSafeTimeout.js +29 -26
  306. package/dist/hooks/useScrollFlash.js +23 -16
  307. package/dist/hooks/useSlots.js +136 -102
  308. package/dist/hooks/useSyncedState.js +37 -31
  309. package/dist/index.d.ts +2 -2
  310. package/dist/index.d.ts.map +1 -1
  311. package/dist/index.js +86 -88
  312. package/dist/internal/components/ButtonReset.js +50 -45
  313. package/dist/internal/components/ButtonReset.module.css.js +5 -5
  314. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +105 -79
  315. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.module.css.js +5 -12
  316. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.js +21 -16
  317. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupContext.js +4 -4
  318. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.js +35 -26
  319. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation.js +19 -14
  320. package/dist/internal/components/ConditionalWrapper.js +51 -41
  321. package/dist/internal/components/InputLabel.js +113 -92
  322. package/dist/internal/components/InputLabel.module.css.js +5 -8
  323. package/dist/internal/components/InputValidation.js +87 -67
  324. package/dist/internal/components/InputValidation.module.css.js +5 -9
  325. package/dist/internal/components/TextInputInnerAction.js +173 -134
  326. package/dist/internal/components/TextInputInnerAction.module.css.js +5 -9
  327. package/dist/internal/components/TextInputInnerVisualSlot.js +110 -89
  328. package/dist/internal/components/TextInputInnerVisualSlot.module.css.js +5 -11
  329. package/dist/internal/components/TextInputWrapper.js +230 -187
  330. package/dist/internal/components/TextInputWrapper.module.css.js +5 -8
  331. package/dist/internal/components/UnderlineTabbedInterface.js +238 -191
  332. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +5 -11
  333. package/dist/internal/components/UnstyledTextInput.js +47 -40
  334. package/dist/internal/components/UnstyledTextInput.module.css.js +5 -5
  335. package/dist/internal/components/ValidationAnimationContainer.js +66 -55
  336. package/dist/internal/components/ValidationAnimationContainer.module.css.js +5 -8
  337. package/dist/internal/hooks/useEffectCallback.js +38 -35
  338. package/dist/internal/hooks/useEffectOnce.js +25 -23
  339. package/dist/internal/utils/getResponsiveAttributes.js +26 -23
  340. package/dist/internal/utils/hasInteractiveNodes.js +46 -34
  341. package/dist/legacy-theme/ts/color-schemes.js +4732 -4250
  342. package/dist/live-region/Announce.js +183 -144
  343. package/dist/live-region/AriaAlert.js +22 -20
  344. package/dist/live-region/AriaStatus.js +22 -20
  345. package/dist/next/index.js +1 -3
  346. package/dist/test-helpers.js +62 -40
  347. package/dist/theme.js +47 -83
  348. package/dist/utils/character-counter.js +63 -45
  349. package/dist/utils/create-component.js +16 -15
  350. package/dist/utils/descendant-registry.js +218 -182
  351. package/dist/utils/environment.js +7 -7
  352. package/dist/utils/getBreakpointDeclarations.js +10 -9
  353. package/dist/utils/invariant.js +23 -17
  354. package/dist/utils/is-slot.js +11 -10
  355. package/dist/utils/isNumeric.js +3 -3
  356. package/dist/utils/modern-polymorphic.js +20 -12
  357. package/dist/utils/scroll.js +11 -8
  358. package/dist/utils/theme.js +10 -5
  359. package/dist/utils/useIsomorphicLayoutEffect.js +9 -4
  360. package/dist/utils/warning.js +21 -14
  361. package/package.json +10 -5
  362. package/dist/ActionList/ActionList-53389912.css.map +0 -1
@@ -1,653 +1,935 @@
1
- import { useRefObjectAsForwardedRef } from "../hooks/useRefObjectAsForwardedRef.js";
2
- import { useId as useId$1 } from "../hooks/useId.js";
3
- import { warning } from "../utils/warning.js";
4
- import { isResponsiveValue } from "../hooks/useResponsiveValue.js";
5
- import { useSlots } from "../hooks/useSlots.js";
6
- import { useOverflow } from "../hooks/useOverflow.js";
7
- import { getResponsiveAttributes } from "../internal/utils/getResponsiveAttributes.js";
8
- import PageLayout_module_css_default from "./PageLayout.module.css.js";
9
- import { isCustomWidthOptions, isPaneWidth, updateAriaValues, usePaneWidth } from "./usePaneWidth.js";
10
- import { removeDraggingStyles, setDraggingStyles } from "./paneUtils.js";
11
- import { clsx } from "clsx";
12
- import { jsx, jsxs } from "react/jsx-runtime";
13
- import React, { memo, useRef } from "react";
14
- //#region src/PageLayout/PageLayout.tsx
15
- const isArrowKey = (key) => key === "ArrowLeft" || key === "ArrowRight" || key === "ArrowUp" || key === "ArrowDown";
16
- const isShrinkKey = (key) => key === "ArrowLeft" || key === "ArrowDown";
17
- const PageLayoutContext = /* @__PURE__ */ React.createContext({
18
- padding: "normal",
19
- rowGap: "normal",
20
- columnGap: "normal",
21
- paneRef: { current: null },
22
- contentWrapperRef: { current: null },
23
- sidebarRef: { current: null },
24
- sidebarContentWrapperRef: { current: null }
1
+ import React, { useRef, memo } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { useId } from '../hooks/useId.js';
4
+ import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
5
+ import { isResponsiveValue } from '../hooks/useResponsiveValue.js';
6
+ import { useSlots } from '../hooks/useSlots.js';
7
+ import { useOverflow } from '../hooks/useOverflow.js';
8
+ import { warning } from '../utils/warning.js';
9
+ import { getResponsiveAttributes } from '../internal/utils/getResponsiveAttributes.js';
10
+ import classes from './PageLayout.module.css.js';
11
+ import { usePaneWidth, isPaneWidth, isCustomWidthOptions, updateAriaValues, ARROW_KEY_STEP } from './usePaneWidth.js';
12
+ import { setDraggingStyles, removeDraggingStyles } from './paneUtils.js';
13
+ import { jsx, jsxs } from 'react/jsx-runtime';
14
+
15
+ const isArrowKey = key => key === 'ArrowLeft' || key === 'ArrowRight' || key === 'ArrowUp' || key === 'ArrowDown';
16
+ const isShrinkKey = key => key === 'ArrowLeft' || key === 'ArrowDown';
17
+ const PageLayoutContext = /*#__PURE__*/React.createContext({
18
+ padding: 'normal',
19
+ rowGap: 'normal',
20
+ columnGap: 'normal',
21
+ paneRef: {
22
+ current: null
23
+ },
24
+ contentWrapperRef: {
25
+ current: null
26
+ },
27
+ sidebarRef: {
28
+ current: null
29
+ },
30
+ sidebarContentWrapperRef: {
31
+ current: null
32
+ }
25
33
  });
26
- const Root = ({ containerWidth = "xlarge", padding = "normal", rowGap = "normal", columnGap = "normal", children, className, style, _slotsConfig: slotsConfig }) => {
27
- const paneRef = useRef(null);
28
- const contentWrapperRef = useRef(null);
29
- const sidebarRef = useRef(null);
30
- const sidebarContentWrapperRef = useRef(null);
31
- const [slots, rest] = useSlots(children, slotsConfig !== null && slotsConfig !== void 0 ? slotsConfig : {
32
- header: Header,
33
- footer: Footer,
34
- sidebar: Sidebar
35
- });
36
- const memoizedContextValue = React.useMemo(() => {
37
- return {
38
- padding,
39
- rowGap,
40
- columnGap,
41
- paneRef,
42
- contentWrapperRef,
43
- sidebarRef,
44
- sidebarContentWrapperRef
45
- };
46
- }, [
47
- padding,
48
- rowGap,
49
- columnGap,
50
- paneRef,
51
- contentWrapperRef,
52
- sidebarRef,
53
- sidebarContentWrapperRef
54
- ]);
55
- return /* @__PURE__ */ jsx(PageLayoutContext.Provider, {
56
- value: memoizedContextValue,
57
- children: /* @__PURE__ */ jsxs(RootWrapper, {
58
- style,
59
- padding,
60
- className,
61
- hasSidebar: !!slots.sidebar,
62
- children: [slots.sidebar, /* @__PURE__ */ jsxs("div", {
63
- ref: sidebarContentWrapperRef,
64
- className: PageLayout_module_css_default.PageLayoutWrapper,
65
- "data-width": containerWidth,
66
- children: [
67
- slots.header,
68
- /* @__PURE__ */ jsx("div", {
69
- className: clsx(PageLayout_module_css_default.PageLayoutContent),
70
- children: rest
71
- }),
72
- slots.footer
73
- ]
74
- })]
75
- })
76
- });
34
+
35
+ // ----------------------------------------------------------------------------
36
+ // PageLayout
37
+
38
+ // TODO: refs
39
+ const Root = ({
40
+ containerWidth = 'xlarge',
41
+ padding = 'normal',
42
+ rowGap = 'normal',
43
+ columnGap = 'normal',
44
+ children,
45
+ className,
46
+ style,
47
+ _slotsConfig: slotsConfig
48
+ }) => {
49
+ const paneRef = useRef(null);
50
+ const contentWrapperRef = useRef(null);
51
+ const sidebarRef = useRef(null);
52
+ const sidebarContentWrapperRef = useRef(null);
53
+ const [slots, rest] = useSlots(children, slotsConfig !== null && slotsConfig !== void 0 ? slotsConfig : {
54
+ header: Header,
55
+ footer: Footer,
56
+ sidebar: Sidebar
57
+ });
58
+ const memoizedContextValue = React.useMemo(() => {
59
+ return {
60
+ padding,
61
+ rowGap,
62
+ columnGap,
63
+ paneRef,
64
+ contentWrapperRef,
65
+ sidebarRef,
66
+ sidebarContentWrapperRef
67
+ };
68
+ }, [padding, rowGap, columnGap, paneRef, contentWrapperRef, sidebarRef, sidebarContentWrapperRef]);
69
+ return /*#__PURE__*/jsx(PageLayoutContext.Provider, {
70
+ value: memoizedContextValue,
71
+ children: /*#__PURE__*/jsxs(RootWrapper, {
72
+ style: style,
73
+ padding: padding,
74
+ className: className,
75
+ hasSidebar: !!slots.sidebar,
76
+ children: [slots.sidebar, /*#__PURE__*/jsxs("div", {
77
+ ref: sidebarContentWrapperRef,
78
+ className: classes.PageLayoutWrapper,
79
+ "data-width": containerWidth,
80
+ children: [slots.header, /*#__PURE__*/jsx("div", {
81
+ className: clsx(classes.PageLayoutContent),
82
+ children: rest
83
+ }), slots.footer]
84
+ })]
85
+ })
86
+ });
77
87
  };
78
88
  Root.displayName = "Root";
79
- const RootWrapper = /* @__PURE__ */ memo(({ style, padding, children, className, hasSidebar }) => {
80
- return /* @__PURE__ */ jsx("div", {
81
- style: {
82
- "--spacing": `var(--spacing-${padding})`,
83
- ...style
84
- },
85
- className: clsx(PageLayout_module_css_default.PageLayoutRoot, className),
86
- "data-has-sidebar": hasSidebar || void 0,
87
- children
88
- });
89
+ const RootWrapper = /*#__PURE__*/memo(({
90
+ style,
91
+ padding,
92
+ children,
93
+ className,
94
+ hasSidebar
95
+ }) => {
96
+ return /*#__PURE__*/jsx("div", {
97
+ style: {
98
+ '--spacing': `var(--spacing-${padding})`,
99
+ ...style
100
+ },
101
+ className: clsx(classes.PageLayoutRoot, className),
102
+ "data-has-sidebar": hasSidebar || undefined,
103
+ children: children
104
+ });
89
105
  });
90
- Root.displayName = "PageLayout";
91
- const HorizontalDivider = /* @__PURE__ */ memo(({ variant = "none", className, position, style }) => {
92
- const { padding } = React.useContext(PageLayoutContext);
93
- return /* @__PURE__ */ jsx("div", {
94
- className: clsx(PageLayout_module_css_default.HorizontalDivider, className),
95
- ...getResponsiveAttributes("variant", variant),
96
- ...getResponsiveAttributes("position", position),
97
- style: {
98
- "--spacing-divider": `var(--spacing-${padding})`,
99
- ...style
100
- }
101
- });
106
+ Root.displayName = 'PageLayout';
107
+
108
+ // ----------------------------------------------------------------------------
109
+ // Divider (internal)
110
+
111
+ const HorizontalDivider = /*#__PURE__*/memo(({
112
+ variant = 'none',
113
+ className,
114
+ position,
115
+ style
116
+ }) => {
117
+ const {
118
+ padding
119
+ } = React.useContext(PageLayoutContext);
120
+ return /*#__PURE__*/jsx("div", {
121
+ className: clsx(classes.HorizontalDivider, className),
122
+ ...getResponsiveAttributes('variant', variant),
123
+ ...getResponsiveAttributes('position', position),
124
+ style: {
125
+ '--spacing-divider': `var(--spacing-${padding})`,
126
+ ...style
127
+ }
128
+ });
102
129
  });
103
- HorizontalDivider.displayName = "HorizontalDivider";
104
- const VerticalDivider = /* @__PURE__ */ memo(({ variant = "none", position, className, style, children }) => {
105
- return /* @__PURE__ */ jsx("div", {
106
- className: clsx(PageLayout_module_css_default.VerticalDivider, className),
107
- ...getResponsiveAttributes("variant", variant),
108
- ...getResponsiveAttributes("position", position),
109
- style,
110
- children
111
- });
130
+ HorizontalDivider.displayName = 'HorizontalDivider';
131
+ const VerticalDivider = /*#__PURE__*/memo(({
132
+ variant = 'none',
133
+ position,
134
+ className,
135
+ style,
136
+ children
137
+ }) => {
138
+ return /*#__PURE__*/jsx("div", {
139
+ className: clsx(classes.VerticalDivider, className),
140
+ ...getResponsiveAttributes('variant', variant),
141
+ ...getResponsiveAttributes('position', position),
142
+ style: style,
143
+ children: children
144
+ });
112
145
  });
113
- VerticalDivider.displayName = "VerticalDivider";
114
- const SidebarDivider = /* @__PURE__ */ memo(function SidebarDivider({ position, divider, resizable, minPaneWidth, maxPaneWidth, currentWidth, currentWidthRef, handleRef, sidebarRef, dragStartClientXRef, dragStartWidthRef, dragMaxWidthRef, getMaxPaneWidth, getDefaultWidth, saveWidth }) {
115
- const { columnGap } = React.useContext(PageLayoutContext);
116
- return /* @__PURE__ */ jsx(VerticalDivider, {
117
- variant: resizable ? "line" : divider,
118
- position,
119
- className: PageLayout_module_css_default.SidebarVerticalDivider,
120
- style: { "--spacing": `var(--spacing-${columnGap})` },
121
- children: resizable ? /* @__PURE__ */ jsx(DragHandle, {
122
- handleRef,
123
- "aria-valuemin": minPaneWidth,
124
- "aria-valuemax": maxPaneWidth,
125
- "aria-valuenow": currentWidth,
126
- onDragStart: (clientX) => {
127
- var _sidebarRef$current$g, _sidebarRef$current;
128
- dragStartClientXRef.current = clientX;
129
- dragStartWidthRef.current = (_sidebarRef$current$g = (_sidebarRef$current = sidebarRef.current) === null || _sidebarRef$current === void 0 ? void 0 : _sidebarRef$current.getBoundingClientRect().width) !== null && _sidebarRef$current$g !== void 0 ? _sidebarRef$current$g : currentWidthRef.current;
130
- dragMaxWidthRef.current = getMaxPaneWidth();
131
- },
132
- onDrag: (value, isKeyboard) => {
133
- const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
134
- if (isKeyboard) {
135
- const delta = position === "end" ? -value : value;
136
- const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
137
- if (newWidth !== currentWidthRef.current) {
138
- var _sidebarRef$current2;
139
- currentWidthRef.current = newWidth;
140
- (_sidebarRef$current2 = sidebarRef.current) === null || _sidebarRef$current2 === void 0 || _sidebarRef$current2.style.setProperty("--pane-width", `${newWidth}px`);
141
- updateAriaValues(handleRef.current, {
142
- current: newWidth,
143
- max: maxWidth
144
- });
145
- }
146
- } else if (sidebarRef.current) {
147
- const deltaX = value - dragStartClientXRef.current;
148
- const directedDelta = position === "end" ? -deltaX : deltaX;
149
- const newWidth = dragStartWidthRef.current + directedDelta;
150
- const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
151
- if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
152
- sidebarRef.current.style.setProperty("--pane-width", `${clampedWidth}px`);
153
- currentWidthRef.current = clampedWidth;
154
- updateAriaValues(handleRef.current, {
155
- current: Math.round(clampedWidth),
156
- max: maxWidth
157
- });
158
- }
159
- }
160
- },
161
- onDragEnd: () => {
162
- saveWidth(currentWidthRef.current);
163
- },
164
- onDoubleClick: () => {
165
- const resetWidth = getDefaultWidth();
166
- if (sidebarRef.current) {
167
- sidebarRef.current.style.setProperty("--pane-width", `${resetWidth}px`);
168
- currentWidthRef.current = resetWidth;
169
- updateAriaValues(handleRef.current, { current: resetWidth });
170
- }
171
- saveWidth(resetWidth);
172
- }
173
- }) : null
174
- });
146
+ VerticalDivider.displayName = 'VerticalDivider';
147
+ const SidebarDivider = /*#__PURE__*/memo(function SidebarDivider({
148
+ position,
149
+ divider,
150
+ resizable,
151
+ minPaneWidth,
152
+ maxPaneWidth,
153
+ currentWidth,
154
+ currentWidthRef,
155
+ handleRef,
156
+ sidebarRef,
157
+ dragStartClientXRef,
158
+ dragStartWidthRef,
159
+ dragMaxWidthRef,
160
+ getMaxPaneWidth,
161
+ getDefaultWidth,
162
+ saveWidth
163
+ }) {
164
+ const {
165
+ columnGap
166
+ } = React.useContext(PageLayoutContext);
167
+ return /*#__PURE__*/jsx(VerticalDivider, {
168
+ variant: resizable ? 'line' : divider,
169
+ position: position,
170
+ className: classes.SidebarVerticalDivider,
171
+ style: {
172
+ '--spacing': `var(--spacing-${columnGap})`
173
+ },
174
+ children: resizable ? /*#__PURE__*/jsx(DragHandle, {
175
+ handleRef: handleRef,
176
+ "aria-valuemin": minPaneWidth,
177
+ "aria-valuemax": maxPaneWidth,
178
+ "aria-valuenow": currentWidth,
179
+ onDragStart: clientX => {
180
+ var _sidebarRef$current$g, _sidebarRef$current;
181
+ dragStartClientXRef.current = clientX;
182
+ dragStartWidthRef.current = (_sidebarRef$current$g = (_sidebarRef$current = sidebarRef.current) === null || _sidebarRef$current === void 0 ? void 0 : _sidebarRef$current.getBoundingClientRect().width) !== null && _sidebarRef$current$g !== void 0 ? _sidebarRef$current$g : currentWidthRef.current;
183
+ dragMaxWidthRef.current = getMaxPaneWidth();
184
+ },
185
+ onDrag: (value, isKeyboard) => {
186
+ const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
187
+ if (isKeyboard) {
188
+ // For position='end': invert the delta so arrow keys feel natural
189
+ // ArrowRight should shrink (move divider right), ArrowLeft should expand
190
+ const delta = position === 'end' ? -value : value;
191
+ const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
192
+ if (newWidth !== currentWidthRef.current) {
193
+ var _sidebarRef$current2;
194
+ currentWidthRef.current = newWidth;
195
+ (_sidebarRef$current2 = sidebarRef.current) === null || _sidebarRef$current2 === void 0 ? void 0 : _sidebarRef$current2.style.setProperty('--pane-width', `${newWidth}px`);
196
+ updateAriaValues(handleRef.current, {
197
+ current: newWidth,
198
+ max: maxWidth
199
+ });
200
+ }
201
+ } else {
202
+ if (sidebarRef.current) {
203
+ const deltaX = value - dragStartClientXRef.current;
204
+ // For position='end': cursor moving left (negative delta) increases width
205
+ // For position='start': cursor moving right (positive delta) increases width
206
+ const directedDelta = position === 'end' ? -deltaX : deltaX;
207
+ const newWidth = dragStartWidthRef.current + directedDelta;
208
+ const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
209
+ if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
210
+ sidebarRef.current.style.setProperty('--pane-width', `${clampedWidth}px`);
211
+ currentWidthRef.current = clampedWidth;
212
+ updateAriaValues(handleRef.current, {
213
+ current: Math.round(clampedWidth),
214
+ max: maxWidth
215
+ });
216
+ }
217
+ }
218
+ }
219
+ },
220
+ onDragEnd: () => {
221
+ saveWidth(currentWidthRef.current);
222
+ },
223
+ onDoubleClick: () => {
224
+ const resetWidth = getDefaultWidth();
225
+ if (sidebarRef.current) {
226
+ sidebarRef.current.style.setProperty('--pane-width', `${resetWidth}px`);
227
+ currentWidthRef.current = resetWidth;
228
+ updateAriaValues(handleRef.current, {
229
+ current: resetWidth
230
+ });
231
+ }
232
+ saveWidth(resetWidth);
233
+ }
234
+ }) : null
235
+ });
175
236
  });
176
237
  /**
177
- * DragHandle - handles all pointer and keyboard interactions for resizing
178
- * ARIA values are set in JSX for SSR accessibility,
179
- * then updated via DOM manipulation during drag for performance
180
- */
181
- const DragHandle = /* @__PURE__ */ memo(function DragHandle({ handleRef, onDragStart, onDrag, onDragEnd, onDoubleClick, "aria-valuemin": ariaValueMin, "aria-valuemax": ariaValueMax, "aria-valuenow": ariaValueNow }) {
182
- const stableOnDragStart = React.useRef(onDragStart);
183
- const stableOnDrag = React.useRef(onDrag);
184
- const stableOnDragEnd = React.useRef(onDragEnd);
185
- React.useEffect(() => {
186
- stableOnDragStart.current = onDragStart;
187
- stableOnDrag.current = onDrag;
188
- stableOnDragEnd.current = onDragEnd;
189
- });
190
- const { paneRef, contentWrapperRef } = React.useContext(PageLayoutContext);
191
- const isDraggingRef = React.useRef(false);
192
- const startDragging = React.useCallback(() => {
193
- if (isDraggingRef.current) return;
194
- setDraggingStyles({
195
- handle: handleRef.current,
196
- pane: paneRef.current,
197
- contentWrapper: contentWrapperRef.current
198
- });
199
- isDraggingRef.current = true;
200
- }, [
201
- handleRef,
202
- contentWrapperRef,
203
- paneRef
204
- ]);
205
- const endDragging = React.useCallback(() => {
206
- if (!isDraggingRef.current) return;
207
- removeDraggingStyles({
208
- handle: handleRef.current,
209
- pane: paneRef.current,
210
- contentWrapper: contentWrapperRef.current
211
- });
212
- isDraggingRef.current = false;
213
- }, [
214
- handleRef,
215
- contentWrapperRef,
216
- paneRef
217
- ]);
218
- /**
219
- * Pointer down starts a drag operation
220
- * Capture the pointer to continue receiving events outside the handle area
221
- */
222
- const handlePointerDown = React.useCallback((event) => {
223
- if (event.button !== 0) return;
224
- event.preventDefault();
225
- const target = event.currentTarget;
226
- try {
227
- target.setPointerCapture(event.pointerId);
228
- } catch {}
229
- stableOnDragStart.current(event.clientX);
230
- startDragging();
231
- }, [startDragging]);
232
- const rafIdRef = React.useRef(null);
233
- const pendingClientXRef = React.useRef(null);
234
- /**
235
- * Pointer move during drag
236
- * Calls onDrag with absolute cursor X position
237
- * Uses rAF to coalesce updates to one per frame
238
- */
239
- const handlePointerMove = React.useCallback((event) => {
240
- if (!isDraggingRef.current) return;
241
- event.preventDefault();
242
- pendingClientXRef.current = event.clientX;
243
- if (rafIdRef.current === null) rafIdRef.current = requestAnimationFrame(() => {
244
- rafIdRef.current = null;
245
- if (pendingClientXRef.current !== null) {
246
- stableOnDrag.current(pendingClientXRef.current, false);
247
- pendingClientXRef.current = null;
248
- }
249
- });
250
- }, []);
251
- /**
252
- * Pointer up - cleanup is handled by onLostPointerCapture event
253
- * which fires when pointer capture is released (including on pointerup)
254
- */
255
- const handlePointerUp = React.useCallback((event) => {
256
- if (!isDraggingRef.current) return;
257
- event.preventDefault();
258
- }, []);
259
- /**
260
- * Lost pointer capture ends a drag operation
261
- * Cleans up dragging state and cancels any pending rAF
262
- * Calls onDragEnd callback
263
- */
264
- const handleLostPointerCapture = React.useCallback(() => {
265
- if (!isDraggingRef.current) return;
266
- if (rafIdRef.current !== null) {
267
- cancelAnimationFrame(rafIdRef.current);
268
- rafIdRef.current = null;
269
- pendingClientXRef.current = null;
270
- }
271
- endDragging();
272
- stableOnDragEnd.current();
273
- }, [endDragging]);
274
- /**
275
- * Keyboard handling for accessibility
276
- * Arrow keys adjust the pane size in 3px increments
277
- * Prevents default scrolling behavior
278
- * Sets and clears dragging state via data attribute
279
- * Calls onDrag
280
- */
281
- const handleKeyDown = React.useCallback((event) => {
282
- if (!isArrowKey(event.key)) return;
283
- event.preventDefault();
284
- const delta = isShrinkKey(event.key) ? -3 : 3;
285
- if (!isDraggingRef.current) startDragging();
286
- stableOnDrag.current(delta, true);
287
- }, [startDragging]);
288
- const handleKeyUp = React.useCallback((event) => {
289
- if (!isArrowKey(event.key)) return;
290
- event.preventDefault();
291
- endDragging();
292
- stableOnDragEnd.current();
293
- }, [endDragging]);
294
- React.useEffect(() => {
295
- return () => {
296
- if (rafIdRef.current !== null) {
297
- cancelAnimationFrame(rafIdRef.current);
298
- rafIdRef.current = null;
299
- }
300
- };
301
- }, []);
302
- return /* @__PURE__ */ jsx("div", {
303
- ref: handleRef,
304
- className: PageLayout_module_css_default.DraggableHandle,
305
- role: "slider",
306
- "aria-label": "Draggable pane splitter",
307
- "aria-valuemin": ariaValueMin,
308
- "aria-valuemax": ariaValueMax,
309
- "aria-valuenow": ariaValueNow,
310
- "aria-valuetext": ariaValueNow !== void 0 ? `Pane width ${ariaValueNow} pixels` : void 0,
311
- tabIndex: 0,
312
- onPointerDown: handlePointerDown,
313
- onPointerMove: handlePointerMove,
314
- onPointerUp: handlePointerUp,
315
- onLostPointerCapture: handleLostPointerCapture,
316
- onKeyDown: handleKeyDown,
317
- onKeyUp: handleKeyUp,
318
- onDoubleClick
319
- });
238
+ * DragHandle - handles all pointer and keyboard interactions for resizing
239
+ * ARIA values are set in JSX for SSR accessibility,
240
+ * then updated via DOM manipulation during drag for performance
241
+ */
242
+ const DragHandle = /*#__PURE__*/memo(function DragHandle({
243
+ handleRef,
244
+ onDragStart,
245
+ onDrag,
246
+ onDragEnd,
247
+ onDoubleClick,
248
+ 'aria-valuemin': ariaValueMin,
249
+ 'aria-valuemax': ariaValueMax,
250
+ 'aria-valuenow': ariaValueNow
251
+ }) {
252
+ const stableOnDragStart = React.useRef(onDragStart);
253
+ const stableOnDrag = React.useRef(onDrag);
254
+ const stableOnDragEnd = React.useRef(onDragEnd);
255
+ React.useEffect(() => {
256
+ stableOnDragStart.current = onDragStart;
257
+ stableOnDrag.current = onDrag;
258
+ stableOnDragEnd.current = onDragEnd;
259
+ });
260
+ const {
261
+ paneRef,
262
+ contentWrapperRef
263
+ } = React.useContext(PageLayoutContext);
264
+
265
+ // Dragging state as a ref - cheaper than reading from DOM style
266
+ const isDraggingRef = React.useRef(false);
267
+
268
+ // Set inline styles for drag optimizations - zero overhead at rest
269
+ const startDragging = React.useCallback(() => {
270
+ if (isDraggingRef.current) return;
271
+ setDraggingStyles({
272
+ handle: handleRef.current,
273
+ pane: paneRef.current,
274
+ contentWrapper: contentWrapperRef.current
275
+ });
276
+ isDraggingRef.current = true;
277
+ }, [handleRef, contentWrapperRef, paneRef]);
278
+ const endDragging = React.useCallback(() => {
279
+ if (!isDraggingRef.current) return;
280
+ removeDraggingStyles({
281
+ handle: handleRef.current,
282
+ pane: paneRef.current,
283
+ contentWrapper: contentWrapperRef.current
284
+ });
285
+ isDraggingRef.current = false;
286
+ }, [handleRef, contentWrapperRef, paneRef]);
287
+
288
+ /**
289
+ * Pointer down starts a drag operation
290
+ * Capture the pointer to continue receiving events outside the handle area
291
+ */
292
+ const handlePointerDown = React.useCallback(event => {
293
+ if (event.button !== 0) return;
294
+ event.preventDefault();
295
+ const target = event.currentTarget;
296
+ // Try to capture pointer - may fail in test environments or if pointer is already released
297
+ try {
298
+ target.setPointerCapture(event.pointerId);
299
+ } catch {
300
+ // Ignore - pointer capture is a nice-to-have for dragging outside the element
301
+ }
302
+ stableOnDragStart.current(event.clientX);
303
+ startDragging();
304
+ }, [startDragging]);
305
+
306
+ // Simple rAF throttle - one update per frame, latest position wins
307
+ const rafIdRef = React.useRef(null);
308
+ const pendingClientXRef = React.useRef(null);
309
+
310
+ /**
311
+ * Pointer move during drag
312
+ * Calls onDrag with absolute cursor X position
313
+ * Uses rAF to coalesce updates to one per frame
314
+ */
315
+ const handlePointerMove = React.useCallback(event => {
316
+ if (!isDraggingRef.current) return;
317
+ event.preventDefault();
318
+
319
+ // Store latest position - only the final position before rAF fires matters
320
+ pendingClientXRef.current = event.clientX;
321
+
322
+ // Schedule update if not already scheduled
323
+ if (rafIdRef.current === null) {
324
+ rafIdRef.current = requestAnimationFrame(() => {
325
+ rafIdRef.current = null;
326
+ if (pendingClientXRef.current !== null) {
327
+ stableOnDrag.current(pendingClientXRef.current, false);
328
+ pendingClientXRef.current = null;
329
+ }
330
+ });
331
+ }
332
+ }, []);
333
+
334
+ /**
335
+ * Pointer up - cleanup is handled by onLostPointerCapture event
336
+ * which fires when pointer capture is released (including on pointerup)
337
+ */
338
+ const handlePointerUp = React.useCallback(event => {
339
+ if (!isDraggingRef.current) return;
340
+ event.preventDefault();
341
+ }, []);
342
+
343
+ /**
344
+ * Lost pointer capture ends a drag operation
345
+ * Cleans up dragging state and cancels any pending rAF
346
+ * Calls onDragEnd callback
347
+ */
348
+ const handleLostPointerCapture = React.useCallback(() => {
349
+ if (!isDraggingRef.current) return;
350
+ // Cancel any pending rAF to prevent stale updates
351
+ if (rafIdRef.current !== null) {
352
+ cancelAnimationFrame(rafIdRef.current);
353
+ rafIdRef.current = null;
354
+ pendingClientXRef.current = null;
355
+ }
356
+ endDragging();
357
+ stableOnDragEnd.current();
358
+ }, [endDragging]);
359
+
360
+ /**
361
+ * Keyboard handling for accessibility
362
+ * Arrow keys adjust the pane size in 3px increments
363
+ * Prevents default scrolling behavior
364
+ * Sets and clears dragging state via data attribute
365
+ * Calls onDrag
366
+ */
367
+ const handleKeyDown = React.useCallback(event => {
368
+ if (!isArrowKey(event.key)) return;
369
+ event.preventDefault();
370
+
371
+ // https://github.com/github/accessibility/issues/5101#issuecomment-1822870655
372
+ const delta = isShrinkKey(event.key) ? -ARROW_KEY_STEP : ARROW_KEY_STEP;
373
+
374
+ // Only set dragging on first keydown (not repeats)
375
+ if (!isDraggingRef.current) {
376
+ startDragging();
377
+ }
378
+ stableOnDrag.current(delta, true);
379
+ }, [startDragging]);
380
+ const handleKeyUp = React.useCallback(event => {
381
+ if (!isArrowKey(event.key)) return;
382
+ event.preventDefault();
383
+ endDragging();
384
+ stableOnDragEnd.current();
385
+ }, [endDragging]);
386
+
387
+ // Cleanup rAF on unmount to prevent stale callbacks
388
+ React.useEffect(() => {
389
+ return () => {
390
+ if (rafIdRef.current !== null) {
391
+ cancelAnimationFrame(rafIdRef.current);
392
+ rafIdRef.current = null;
393
+ }
394
+ };
395
+ }, []);
396
+ return /*#__PURE__*/jsx("div", {
397
+ ref: handleRef,
398
+ className: classes.DraggableHandle,
399
+ role: "slider",
400
+ "aria-label": "Draggable pane splitter",
401
+ "aria-valuemin": ariaValueMin,
402
+ "aria-valuemax": ariaValueMax,
403
+ "aria-valuenow": ariaValueNow,
404
+ "aria-valuetext": ariaValueNow !== undefined ? `Pane width ${ariaValueNow} pixels` : undefined,
405
+ tabIndex: 0,
406
+ onPointerDown: handlePointerDown,
407
+ onPointerMove: handlePointerMove,
408
+ onPointerUp: handlePointerUp,
409
+ onLostPointerCapture: handleLostPointerCapture,
410
+ onKeyDown: handleKeyDown,
411
+ onKeyUp: handleKeyUp,
412
+ onDoubleClick: onDoubleClick
413
+ });
320
414
  });
321
- const Header = ({ "aria-label": label, "aria-labelledby": labelledBy, padding = "none", divider = "none", dividerWhenNarrow = "inherit", hidden = false, children, style, className }) => {
322
- const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== "inherit" ? {
323
- regular: divider,
324
- narrow: dividerWhenNarrow
325
- } : divider;
326
- const { rowGap } = React.useContext(PageLayoutContext);
327
- return /* @__PURE__ */ jsxs("header", {
328
- "aria-label": label,
329
- "aria-labelledby": labelledBy,
330
- ...getResponsiveAttributes("hidden", hidden),
331
- className: clsx(PageLayout_module_css_default.Header, className),
332
- style: {
333
- "--spacing": `var(--spacing-${rowGap})`,
334
- ...style
335
- },
336
- children: [/* @__PURE__ */ jsx("div", {
337
- className: PageLayout_module_css_default.HeaderContent,
338
- style: { "--spacing": `var(--spacing-${padding})` },
339
- children
340
- }), /* @__PURE__ */ jsx(HorizontalDivider, {
341
- variant: dividerProp,
342
- className: PageLayout_module_css_default.HeaderHorizontalDivider,
343
- style: { "--spacing": `var(--spacing-${rowGap})` }
344
- })]
345
- });
415
+
416
+ // ----------------------------------------------------------------------------
417
+ // PageLayout.Header
418
+
419
+ const Header = ({
420
+ 'aria-label': label,
421
+ 'aria-labelledby': labelledBy,
422
+ padding = 'none',
423
+ divider = 'none',
424
+ dividerWhenNarrow = 'inherit',
425
+ hidden = false,
426
+ children,
427
+ style,
428
+ className
429
+ }) => {
430
+ // Combine divider and dividerWhenNarrow for backwards compatibility
431
+ const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== 'inherit' ? {
432
+ regular: divider,
433
+ narrow: dividerWhenNarrow
434
+ } : divider;
435
+ const {
436
+ rowGap
437
+ } = React.useContext(PageLayoutContext);
438
+ return /*#__PURE__*/jsxs("header", {
439
+ "aria-label": label,
440
+ "aria-labelledby": labelledBy,
441
+ ...getResponsiveAttributes('hidden', hidden),
442
+ className: clsx(classes.Header, className),
443
+ style: {
444
+ '--spacing': `var(--spacing-${rowGap})`,
445
+ ...style
446
+ },
447
+ children: [/*#__PURE__*/jsx("div", {
448
+ className: classes.HeaderContent,
449
+ style: {
450
+ '--spacing': `var(--spacing-${padding})`
451
+ },
452
+ children: children
453
+ }), /*#__PURE__*/jsx(HorizontalDivider, {
454
+ variant: dividerProp,
455
+ className: classes.HeaderHorizontalDivider,
456
+ style: {
457
+ '--spacing': `var(--spacing-${rowGap})`
458
+ }
459
+ })]
460
+ });
346
461
  };
347
462
  Header.displayName = "Header";
348
- Header.displayName = "PageLayout.Header";
349
- const Content = ({ as = "main", "aria-label": label, "aria-labelledby": labelledBy, width = "full", padding = "none", hidden = false, children, className, style }) => {
350
- const Component = as;
351
- const { contentWrapperRef } = React.useContext(PageLayoutContext);
352
- return /* @__PURE__ */ jsx(Component, {
353
- ref: contentWrapperRef,
354
- "aria-label": label,
355
- "aria-labelledby": labelledBy,
356
- style,
357
- className: clsx(PageLayout_module_css_default.ContentWrapper, className),
358
- ...getResponsiveAttributes("is-hidden", hidden),
359
- children: /* @__PURE__ */ jsx("div", {
360
- className: PageLayout_module_css_default.Content,
361
- "data-width": width,
362
- style: { "--spacing": `var(--spacing-${padding})` },
363
- children
364
- })
365
- });
463
+ Header.displayName = 'PageLayout.Header';
464
+
465
+ // ----------------------------------------------------------------------------
466
+ // PageLayout.Content
467
+
468
+ // TODO: Account for pane width when centering content
469
+ const Content = ({
470
+ as = 'main',
471
+ 'aria-label': label,
472
+ 'aria-labelledby': labelledBy,
473
+ width = 'full',
474
+ padding = 'none',
475
+ hidden = false,
476
+ children,
477
+ className,
478
+ style
479
+ }) => {
480
+ const Component = as;
481
+ const {
482
+ contentWrapperRef
483
+ } = React.useContext(PageLayoutContext);
484
+ return /*#__PURE__*/jsx(Component, {
485
+ ref: contentWrapperRef,
486
+ "aria-label": label,
487
+ "aria-labelledby": labelledBy,
488
+ style: style,
489
+ className: clsx(classes.ContentWrapper, className),
490
+ ...getResponsiveAttributes('is-hidden', hidden),
491
+ children: /*#__PURE__*/jsx("div", {
492
+ className: classes.Content,
493
+ "data-width": width,
494
+ style: {
495
+ '--spacing': `var(--spacing-${padding})`
496
+ },
497
+ children: children
498
+ })
499
+ });
366
500
  };
367
501
  Content.displayName = "Content";
368
- Content.displayName = "PageLayout.Content";
502
+ Content.displayName = 'PageLayout.Content';
503
+
504
+ // ----------------------------------------------------------------------------
505
+ // PageLayout.Pane
506
+
369
507
  const overflowProps = {
370
- tabIndex: 0,
371
- role: "region"
508
+ tabIndex: 0,
509
+ role: 'region'
372
510
  };
373
- const Pane = /* @__PURE__ */ React.forwardRef(({ "aria-label": label, "aria-labelledby": labelledBy, position: responsivePosition = "end", positionWhenNarrow = "inherit", width = "medium", minWidth = 256, currentWidth: controlledWidth, onResizeEnd, padding = "none", resizable = false, widthStorageKey = "paneWidth", divider: responsiveDivider = "none", dividerWhenNarrow = "inherit", sticky = false, offsetHeader = 0, hidden: responsiveHidden = false, children, id, className, style }, forwardRef) => {
374
- const positionProp = !isResponsiveValue(responsivePosition) && positionWhenNarrow !== "inherit" ? {
375
- regular: responsivePosition,
376
- narrow: positionWhenNarrow
377
- } : responsivePosition;
378
- const dividerProp = !isResponsiveValue(responsiveDivider) && dividerWhenNarrow !== "inherit" ? {
379
- regular: responsiveDivider,
380
- narrow: dividerWhenNarrow
381
- } : responsiveDivider;
382
- const position = isResponsiveValue(positionProp) ? "end" : positionProp;
383
- const dividerVariant = isResponsiveValue(dividerProp) ? "none" : dividerProp;
384
- const { rowGap, columnGap, paneRef, contentWrapperRef } = React.useContext(PageLayoutContext);
385
- const handleRef = React.useRef(null);
386
- const dragStartClientXRef = React.useRef(0);
387
- const dragStartWidthRef = React.useRef(0);
388
- const dragMaxWidthRef = React.useRef(0);
389
- const { currentWidth, currentWidthRef, minPaneWidth, maxPaneWidth, getMaxPaneWidth, saveWidth, getDefaultWidth } = usePaneWidth({
390
- width,
391
- minWidth,
392
- resizable,
393
- widthStorageKey,
394
- paneRef,
395
- handleRef,
396
- contentWrapperRef,
397
- onResizeEnd,
398
- currentWidth: controlledWidth
399
- });
400
- useRefObjectAsForwardedRef(forwardRef, paneRef);
401
- const hasOverflow = useOverflow(paneRef);
402
- const paneId = useId$1(id);
403
- const labelProp = {};
404
- if (hasOverflow) {
405
- warning(label === void 0 && labelledBy === void 0, "The <PageLayout.Pane> has overflow and `aria-label` or `aria-labelledby` has not been set. Please provide `aria-label` or `aria-labelledby` to <PageLayout.Pane> in order to label this region.");
406
- if (labelledBy) labelProp["aria-labelledby"] = labelledBy;
407
- else if (label) labelProp["aria-label"] = label;
408
- }
409
- return /* @__PURE__ */ jsxs("div", {
410
- className: clsx(PageLayout_module_css_default.PaneWrapper, className),
411
- style: {
412
- "--offset-header": typeof offsetHeader === "number" ? `${offsetHeader}px` : offsetHeader,
413
- "--spacing-row": `var(--spacing-${rowGap})`,
414
- "--spacing-column": `var(--spacing-${columnGap})`,
415
- ...style
416
- },
417
- ...getResponsiveAttributes("is-hidden", responsiveHidden),
418
- ...getResponsiveAttributes("position", positionProp),
419
- "data-sticky": sticky || void 0,
420
- children: [
421
- /* @__PURE__ */ jsx(HorizontalDivider, {
422
- variant: isResponsiveValue(dividerProp) ? dividerProp : {
423
- narrow: dividerVariant,
424
- regular: "none"
425
- },
426
- className: PageLayout_module_css_default.PaneHorizontalDivider,
427
- style: { "--spacing": `var(--spacing-${rowGap})` },
428
- position: positionProp
429
- }),
430
- /* @__PURE__ */ jsx("div", {
431
- ref: paneRef,
432
- suppressHydrationWarning: resizable === true && !onResizeEnd,
433
- ...hasOverflow ? overflowProps : {},
434
- ...labelProp,
435
- ...id && { id: paneId },
436
- className: PageLayout_module_css_default.Pane,
437
- "data-resizable": resizable || void 0,
438
- style: {
439
- "--spacing": `var(--spacing-${padding})`,
440
- "--pane-min-width": isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
441
- "--pane-max-width": isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--pane-max-width-diff))`,
442
- "--pane-width-custom": isCustomWidthOptions(width) ? width.default : void 0,
443
- "--pane-width-size": `var(--pane-width-${isPaneWidth(width) ? width : "custom"})`,
444
- "--pane-width": `${currentWidth}px`
445
- },
446
- children
447
- }),
448
- /* @__PURE__ */ jsx(VerticalDivider, {
449
- variant: isResponsiveValue(dividerProp) ? {
450
- narrow: "none",
451
- regular: resizable ? "line" : dividerProp.regular || "none",
452
- wide: resizable ? "line" : dividerProp.wide || dividerProp.regular || "none"
453
- } : {
454
- narrow: "none",
455
- regular: resizable ? "line" : dividerVariant
456
- },
457
- draggable: resizable,
458
- position: positionProp,
459
- className: PageLayout_module_css_default.PaneVerticalDivider,
460
- style: { "--spacing": `var(--spacing-${columnGap})` },
461
- children: resizable ? /* @__PURE__ */ jsx(DragHandle, {
462
- handleRef,
463
- "aria-valuemin": minPaneWidth,
464
- "aria-valuemax": maxPaneWidth,
465
- "aria-valuenow": currentWidth,
466
- onDragStart: (clientX) => {
467
- var _paneRef$current$getB, _paneRef$current;
468
- dragStartClientXRef.current = clientX;
469
- dragStartWidthRef.current = (_paneRef$current$getB = (_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.getBoundingClientRect().width) !== null && _paneRef$current$getB !== void 0 ? _paneRef$current$getB : currentWidthRef.current;
470
- dragMaxWidthRef.current = getMaxPaneWidth();
471
- },
472
- onDrag: (value, isKeyboard) => {
473
- const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
474
- if (isKeyboard) {
475
- const delta = value;
476
- const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
477
- if (newWidth !== currentWidthRef.current) {
478
- var _paneRef$current2;
479
- currentWidthRef.current = newWidth;
480
- (_paneRef$current2 = paneRef.current) === null || _paneRef$current2 === void 0 || _paneRef$current2.style.setProperty("--pane-width", `${newWidth}px`);
481
- updateAriaValues(handleRef.current, {
482
- current: newWidth,
483
- max: maxWidth
484
- });
485
- }
486
- } else if (paneRef.current) {
487
- const deltaX = value - dragStartClientXRef.current;
488
- const directedDelta = position === "end" ? -deltaX : deltaX;
489
- const newWidth = dragStartWidthRef.current + directedDelta;
490
- const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
491
- if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
492
- paneRef.current.style.setProperty("--pane-width", `${clampedWidth}px`);
493
- currentWidthRef.current = clampedWidth;
494
- updateAriaValues(handleRef.current, {
495
- current: Math.round(clampedWidth),
496
- max: maxWidth
497
- });
498
- }
499
- }
500
- },
501
- onDragEnd: () => {
502
- saveWidth(currentWidthRef.current);
503
- },
504
- onDoubleClick: () => {
505
- const resetWidth = getDefaultWidth();
506
- if (paneRef.current) {
507
- paneRef.current.style.setProperty("--pane-width", `${resetWidth}px`);
508
- currentWidthRef.current = resetWidth;
509
- updateAriaValues(handleRef.current, { current: resetWidth });
510
- }
511
- saveWidth(resetWidth);
512
- }
513
- }) : null
514
- })
515
- ]
516
- });
511
+ const Pane = /*#__PURE__*/React.forwardRef(({
512
+ 'aria-label': label,
513
+ 'aria-labelledby': labelledBy,
514
+ position: responsivePosition = 'end',
515
+ positionWhenNarrow = 'inherit',
516
+ width = 'medium',
517
+ minWidth = 256,
518
+ currentWidth: controlledWidth,
519
+ onResizeEnd,
520
+ padding = 'none',
521
+ resizable = false,
522
+ widthStorageKey = 'paneWidth',
523
+ divider: responsiveDivider = 'none',
524
+ dividerWhenNarrow = 'inherit',
525
+ sticky = false,
526
+ offsetHeader = 0,
527
+ hidden: responsiveHidden = false,
528
+ children,
529
+ id,
530
+ className,
531
+ style
532
+ }, forwardRef) => {
533
+ // Combine position and positionWhenNarrow for backwards compatibility
534
+ const positionProp = !isResponsiveValue(responsivePosition) && positionWhenNarrow !== 'inherit' ? {
535
+ regular: responsivePosition,
536
+ narrow: positionWhenNarrow
537
+ } : responsivePosition;
538
+
539
+ // Combine divider and dividerWhenNarrow for backwards compatibility
540
+ const dividerProp = !isResponsiveValue(responsiveDivider) && dividerWhenNarrow !== 'inherit' ? {
541
+ regular: responsiveDivider,
542
+ narrow: dividerWhenNarrow
543
+ } : responsiveDivider;
544
+
545
+ // For components that need responsive values in JavaScript logic, we'll use a fallback value
546
+ // The actual responsive behavior will be handled by CSS through data attributes
547
+ const position = isResponsiveValue(positionProp) ? 'end' : positionProp;
548
+ const dividerVariant = isResponsiveValue(dividerProp) ? 'none' : dividerProp;
549
+ const {
550
+ rowGap,
551
+ columnGap,
552
+ paneRef,
553
+ contentWrapperRef
554
+ } = React.useContext(PageLayoutContext);
555
+
556
+ // Ref to the drag handle for updating ARIA attributes
557
+ const handleRef = React.useRef(null);
558
+
559
+ // Cache drag start values to calculate relative delta during drag
560
+ // This approach is immune to layout shifts (scrollbars appearing/disappearing)
561
+ const dragStartClientXRef = React.useRef(0);
562
+ const dragStartWidthRef = React.useRef(0);
563
+ // Cache max width at drag start - won't change during a drag operation
564
+ const dragMaxWidthRef = React.useRef(0);
565
+ const {
566
+ currentWidth,
567
+ currentWidthRef,
568
+ minPaneWidth,
569
+ maxPaneWidth,
570
+ getMaxPaneWidth,
571
+ saveWidth,
572
+ getDefaultWidth
573
+ } = usePaneWidth({
574
+ width,
575
+ minWidth,
576
+ resizable,
577
+ widthStorageKey,
578
+ paneRef,
579
+ handleRef,
580
+ contentWrapperRef,
581
+ onResizeEnd,
582
+ currentWidth: controlledWidth
583
+ });
584
+ useRefObjectAsForwardedRef(forwardRef, paneRef);
585
+ const hasOverflow = useOverflow(paneRef);
586
+ const paneId = useId(id);
587
+ const labelProp = {};
588
+ if (hasOverflow) {
589
+ process.env.NODE_ENV !== "production" ? warning(label === undefined && labelledBy === undefined, 'The <PageLayout.Pane> has overflow and `aria-label` or `aria-labelledby` has not been set. ' + 'Please provide `aria-label` or `aria-labelledby` to <PageLayout.Pane> in order to label this ' + 'region.') : void 0;
590
+ if (labelledBy) {
591
+ labelProp['aria-labelledby'] = labelledBy;
592
+ } else if (label) {
593
+ labelProp['aria-label'] = label;
594
+ }
595
+ }
596
+ return /*#__PURE__*/jsxs("div", {
597
+ className: clsx(classes.PaneWrapper, className),
598
+ style: {
599
+ '--offset-header': typeof offsetHeader === 'number' ? `${offsetHeader}px` : offsetHeader,
600
+ '--spacing-row': `var(--spacing-${rowGap})`,
601
+ '--spacing-column': `var(--spacing-${columnGap})`,
602
+ ...style
603
+ },
604
+ ...getResponsiveAttributes('is-hidden', responsiveHidden),
605
+ ...getResponsiveAttributes('position', positionProp),
606
+ "data-sticky": sticky || undefined,
607
+ children: [/*#__PURE__*/jsx(HorizontalDivider, {
608
+ variant: isResponsiveValue(dividerProp) ? dividerProp : {
609
+ narrow: dividerVariant,
610
+ regular: 'none'
611
+ },
612
+ className: classes.PaneHorizontalDivider,
613
+ style: {
614
+ '--spacing': `var(--spacing-${rowGap})`
615
+ },
616
+ position: positionProp
617
+ }), /*#__PURE__*/jsx("div", {
618
+ ref: paneRef
619
+ // Suppress hydration mismatch for --pane-width when localStorage
620
+ // provides a width that differs from the server-rendered default.
621
+ // Not needed when onResizeEnd is provided (localStorage isn't read).
622
+ ,
623
+ suppressHydrationWarning: resizable === true && !onResizeEnd,
624
+ ...(hasOverflow ? overflowProps : {}),
625
+ ...labelProp,
626
+ ...(id && {
627
+ id: paneId
628
+ }),
629
+ className: classes.Pane,
630
+ "data-resizable": resizable || undefined,
631
+ style: {
632
+ '--spacing': `var(--spacing-${padding})`,
633
+ '--pane-min-width': isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
634
+ '--pane-max-width': isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--pane-max-width-diff))`,
635
+ '--pane-width-custom': isCustomWidthOptions(width) ? width.default : undefined,
636
+ '--pane-width-size': `var(--pane-width-${isPaneWidth(width) ? width : 'custom'})`,
637
+ '--pane-width': `${currentWidth}px`
638
+ },
639
+ children: children
640
+ }), /*#__PURE__*/jsx(VerticalDivider, {
641
+ variant: isResponsiveValue(dividerProp) ? {
642
+ narrow: 'none',
643
+ regular: resizable ? 'line' : dividerProp.regular || 'none',
644
+ wide: resizable ? 'line' : dividerProp.wide || dividerProp.regular || 'none'
645
+ } : {
646
+ narrow: 'none',
647
+ // If pane is resizable, always show a vertical divider on regular viewports
648
+ regular: resizable ? 'line' : dividerVariant
649
+ }
650
+ // If pane is resizable, the divider should be draggable
651
+ ,
652
+ draggable: resizable,
653
+ position: positionProp,
654
+ className: classes.PaneVerticalDivider,
655
+ style: {
656
+ '--spacing': `var(--spacing-${columnGap})`
657
+ },
658
+ children: resizable ? /*#__PURE__*/jsx(DragHandle, {
659
+ handleRef: handleRef,
660
+ "aria-valuemin": minPaneWidth,
661
+ "aria-valuemax": maxPaneWidth,
662
+ "aria-valuenow": currentWidth,
663
+ onDragStart: clientX => {
664
+ var _paneRef$current$getB, _paneRef$current;
665
+ // Cache cursor position and pane width at drag start
666
+ // Using relative delta (current - start) is immune to layout shifts
667
+ // (e.g., scrollbars appearing/disappearing during drag)
668
+ dragStartClientXRef.current = clientX;
669
+ dragStartWidthRef.current = (_paneRef$current$getB = (_paneRef$current = paneRef.current) === null || _paneRef$current === void 0 ? void 0 : _paneRef$current.getBoundingClientRect().width) !== null && _paneRef$current$getB !== void 0 ? _paneRef$current$getB : currentWidthRef.current;
670
+ // Cache max width - won't change during drag
671
+ dragMaxWidthRef.current = getMaxPaneWidth();
672
+ },
673
+ onDrag: (value, isKeyboard) => {
674
+ // Use cached max width for pointer drag, fresh value for keyboard (less frequent)
675
+ const maxWidth = isKeyboard ? getMaxPaneWidth() : dragMaxWidthRef.current;
676
+ if (isKeyboard) {
677
+ // Keyboard: value is a delta (e.g., +3 or -3)
678
+ const delta = value;
679
+ const newWidth = Math.max(minPaneWidth, Math.min(maxWidth, currentWidthRef.current + delta));
680
+ if (newWidth !== currentWidthRef.current) {
681
+ var _paneRef$current2;
682
+ currentWidthRef.current = newWidth;
683
+ (_paneRef$current2 = paneRef.current) === null || _paneRef$current2 === void 0 ? void 0 : _paneRef$current2.style.setProperty('--pane-width', `${newWidth}px`);
684
+ updateAriaValues(handleRef.current, {
685
+ current: newWidth,
686
+ max: maxWidth
687
+ });
688
+ }
689
+ } else {
690
+ // Pointer: value is clientX - calculate width using relative delta from drag start
691
+ // This approach is immune to layout shifts during drag
692
+ if (paneRef.current) {
693
+ const deltaX = value - dragStartClientXRef.current;
694
+ // For position='end': cursor moving left (negative delta) increases width
695
+ // For position='start': cursor moving right (positive delta) increases width
696
+ const directedDelta = position === 'end' ? -deltaX : deltaX;
697
+ const newWidth = dragStartWidthRef.current + directedDelta;
698
+ const clampedWidth = Math.max(minPaneWidth, Math.min(maxWidth, newWidth));
699
+
700
+ // Only update if width actually changed
701
+ if (Math.round(clampedWidth) !== Math.round(currentWidthRef.current)) {
702
+ paneRef.current.style.setProperty('--pane-width', `${clampedWidth}px`);
703
+ currentWidthRef.current = clampedWidth;
704
+ updateAriaValues(handleRef.current, {
705
+ current: Math.round(clampedWidth),
706
+ max: maxWidth
707
+ });
708
+ }
709
+ }
710
+ }
711
+ },
712
+ onDragEnd: () => {
713
+ // Sync React state so parent re-renders use the correct width
714
+ saveWidth(currentWidthRef.current);
715
+ },
716
+ onDoubleClick: () => {
717
+ const resetWidth = getDefaultWidth();
718
+ if (paneRef.current) {
719
+ paneRef.current.style.setProperty('--pane-width', `${resetWidth}px`);
720
+ currentWidthRef.current = resetWidth;
721
+ updateAriaValues(handleRef.current, {
722
+ current: resetWidth
723
+ });
724
+ }
725
+ saveWidth(resetWidth);
726
+ }
727
+ }) : null
728
+ })]
729
+ });
517
730
  });
518
- Pane.displayName = "PageLayout.Pane";
519
- const Sidebar = /* @__PURE__ */ React.forwardRef(({ "aria-label": label, "aria-labelledby": labelledBy, position = "start", width = "medium", minWidth = 256, padding = "none", resizable = false, widthStorageKey, divider = "none", sticky = false, responsiveVariant = "default", hidden: responsiveHidden = false, children, id, className, style }, forwardRef) => {
520
- const { columnGap, sidebarRef, sidebarContentWrapperRef } = React.useContext(PageLayoutContext);
521
- const handleRef = React.useRef(null);
522
- const dragStartClientXRef = React.useRef(0);
523
- const dragStartWidthRef = React.useRef(0);
524
- const dragMaxWidthRef = React.useRef(0);
525
- const { currentWidth, currentWidthRef, minPaneWidth, maxPaneWidth, getMaxPaneWidth, saveWidth, getDefaultWidth } = usePaneWidth({
526
- width,
527
- minWidth,
528
- resizable,
529
- widthStorageKey,
530
- paneRef: sidebarRef,
531
- handleRef,
532
- contentWrapperRef: sidebarContentWrapperRef,
533
- constrainToViewport: true
534
- });
535
- useRefObjectAsForwardedRef(forwardRef, sidebarRef);
536
- const hasOverflow = useOverflow(sidebarRef);
537
- const sidebarId = useId$1(id);
538
- const labelProp = {};
539
- if (hasOverflow) {
540
- warning(label === void 0 && labelledBy === void 0, "The <PageLayout.Sidebar> has overflow and `aria-label` or `aria-labelledby` has not been set. Please provide `aria-label` or `aria-labelledby` to <PageLayout.Sidebar> in order to label this region.");
541
- if (labelledBy) labelProp["aria-labelledby"] = labelledBy;
542
- else if (label) labelProp["aria-label"] = label;
543
- }
544
- return /* @__PURE__ */ jsxs("div", {
545
- className: clsx(PageLayout_module_css_default.SidebarWrapper, className),
546
- style: {
547
- "--spacing-column": `var(--spacing-${columnGap})`,
548
- ...style
549
- },
550
- ...getResponsiveAttributes("is-hidden", responsiveHidden),
551
- "data-position": position,
552
- "data-sticky": sticky || void 0,
553
- "data-responsive-variant": responsiveVariant !== "default" ? responsiveVariant : void 0,
554
- children: [
555
- position === "end" && /* @__PURE__ */ jsx(SidebarDivider, {
556
- position,
557
- divider,
558
- resizable,
559
- minPaneWidth,
560
- maxPaneWidth,
561
- currentWidth,
562
- currentWidthRef,
563
- handleRef,
564
- sidebarRef,
565
- dragStartClientXRef,
566
- dragStartWidthRef,
567
- dragMaxWidthRef,
568
- getMaxPaneWidth,
569
- getDefaultWidth,
570
- saveWidth
571
- }),
572
- /* @__PURE__ */ jsx("div", {
573
- ref: sidebarRef,
574
- suppressHydrationWarning: resizable === true && !!widthStorageKey,
575
- ...hasOverflow ? overflowProps : {},
576
- ...labelProp,
577
- ...id && { id: sidebarId },
578
- className: PageLayout_module_css_default.Sidebar,
579
- "data-resizable": resizable || void 0,
580
- style: {
581
- "--spacing": `var(--spacing-${padding})`,
582
- "--pane-min-width": isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
583
- "--pane-max-width": isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--sidebar-max-width-diff))`,
584
- "--pane-width-custom": isCustomWidthOptions(width) ? width.default : void 0,
585
- "--pane-width-size": `var(--pane-width-${isPaneWidth(width) ? width : "custom"})`,
586
- "--pane-width": `${currentWidth}px`
587
- },
588
- children
589
- }),
590
- position === "start" && /* @__PURE__ */ jsx(SidebarDivider, {
591
- position,
592
- divider,
593
- resizable,
594
- minPaneWidth,
595
- maxPaneWidth,
596
- currentWidth,
597
- currentWidthRef,
598
- handleRef,
599
- sidebarRef,
600
- dragStartClientXRef,
601
- dragStartWidthRef,
602
- dragMaxWidthRef,
603
- getMaxPaneWidth,
604
- getDefaultWidth,
605
- saveWidth
606
- })
607
- ]
608
- });
731
+ Pane.displayName = 'PageLayout.Pane';
732
+
733
+ // ----------------------------------------------------------------------------
734
+ // PageLayout.Footer
735
+
736
+ // ----------------------------------------------------------------------------
737
+ // PageLayout.Sidebar
738
+
739
+ const Sidebar = /*#__PURE__*/React.forwardRef(({
740
+ 'aria-label': label,
741
+ 'aria-labelledby': labelledBy,
742
+ position = 'start',
743
+ width = 'medium',
744
+ minWidth = 256,
745
+ padding = 'none',
746
+ resizable = false,
747
+ widthStorageKey,
748
+ divider = 'none',
749
+ sticky = false,
750
+ responsiveVariant = 'default',
751
+ hidden: responsiveHidden = false,
752
+ children,
753
+ id,
754
+ className,
755
+ style
756
+ }, forwardRef) => {
757
+ const {
758
+ columnGap,
759
+ sidebarRef,
760
+ sidebarContentWrapperRef
761
+ } = React.useContext(PageLayoutContext);
762
+
763
+ // Ref to the drag handle for updating ARIA attributes
764
+ const handleRef = React.useRef(null);
765
+
766
+ // Cache drag start values to calculate relative delta during drag
767
+ const dragStartClientXRef = React.useRef(0);
768
+ const dragStartWidthRef = React.useRef(0);
769
+ const dragMaxWidthRef = React.useRef(0);
770
+ const {
771
+ currentWidth,
772
+ currentWidthRef,
773
+ minPaneWidth,
774
+ maxPaneWidth,
775
+ getMaxPaneWidth,
776
+ saveWidth,
777
+ getDefaultWidth
778
+ } = usePaneWidth({
779
+ width,
780
+ minWidth,
781
+ resizable,
782
+ widthStorageKey,
783
+ paneRef: sidebarRef,
784
+ handleRef,
785
+ contentWrapperRef: sidebarContentWrapperRef,
786
+ constrainToViewport: true
787
+ });
788
+ useRefObjectAsForwardedRef(forwardRef, sidebarRef);
789
+ const hasOverflow = useOverflow(sidebarRef);
790
+ const sidebarId = useId(id);
791
+ const labelProp = {};
792
+ if (hasOverflow) {
793
+ process.env.NODE_ENV !== "production" ? warning(label === undefined && labelledBy === undefined, 'The <PageLayout.Sidebar> has overflow and `aria-label` or `aria-labelledby` has not been set. ' + 'Please provide `aria-label` or `aria-labelledby` to <PageLayout.Sidebar> in order to label this ' + 'region.') : void 0;
794
+ if (labelledBy) {
795
+ labelProp['aria-labelledby'] = labelledBy;
796
+ } else if (label) {
797
+ labelProp['aria-label'] = label;
798
+ }
799
+ }
800
+ return /*#__PURE__*/jsxs("div", {
801
+ className: clsx(classes.SidebarWrapper, className),
802
+ style: {
803
+ '--spacing-column': `var(--spacing-${columnGap})`,
804
+ ...style
805
+ },
806
+ ...getResponsiveAttributes('is-hidden', responsiveHidden),
807
+ "data-position": position,
808
+ "data-sticky": sticky || undefined,
809
+ "data-responsive-variant": responsiveVariant !== 'default' ? responsiveVariant : undefined,
810
+ children: [position === 'end' && /*#__PURE__*/jsx(SidebarDivider, {
811
+ position: position,
812
+ divider: divider,
813
+ resizable: resizable,
814
+ minPaneWidth: minPaneWidth,
815
+ maxPaneWidth: maxPaneWidth,
816
+ currentWidth: currentWidth,
817
+ currentWidthRef: currentWidthRef,
818
+ handleRef: handleRef,
819
+ sidebarRef: sidebarRef,
820
+ dragStartClientXRef: dragStartClientXRef,
821
+ dragStartWidthRef: dragStartWidthRef,
822
+ dragMaxWidthRef: dragMaxWidthRef,
823
+ getMaxPaneWidth: getMaxPaneWidth,
824
+ getDefaultWidth: getDefaultWidth,
825
+ saveWidth: saveWidth
826
+ }), /*#__PURE__*/jsx("div", {
827
+ ref: sidebarRef
828
+ // Suppress hydration mismatch for --pane-width when localStorage
829
+ // provides a width that differs from the server-rendered default.
830
+ ,
831
+ suppressHydrationWarning: resizable === true && !!widthStorageKey,
832
+ ...(hasOverflow ? overflowProps : {}),
833
+ ...labelProp,
834
+ ...(id && {
835
+ id: sidebarId
836
+ }),
837
+ className: classes.Sidebar,
838
+ "data-resizable": resizable || undefined,
839
+ style: {
840
+ '--spacing': `var(--spacing-${padding})`,
841
+ '--pane-min-width': isCustomWidthOptions(width) ? width.min : `${minWidth}px`,
842
+ '--pane-max-width': isCustomWidthOptions(width) ? width.max : `calc(100vw - var(--sidebar-max-width-diff))`,
843
+ '--pane-width-custom': isCustomWidthOptions(width) ? width.default : undefined,
844
+ '--pane-width-size': `var(--pane-width-${isPaneWidth(width) ? width : 'custom'})`,
845
+ '--pane-width': `${currentWidth}px`
846
+ },
847
+ children: children
848
+ }), position === 'start' && /*#__PURE__*/jsx(SidebarDivider, {
849
+ position: position,
850
+ divider: divider,
851
+ resizable: resizable,
852
+ minPaneWidth: minPaneWidth,
853
+ maxPaneWidth: maxPaneWidth,
854
+ currentWidth: currentWidth,
855
+ currentWidthRef: currentWidthRef,
856
+ handleRef: handleRef,
857
+ sidebarRef: sidebarRef,
858
+ dragStartClientXRef: dragStartClientXRef,
859
+ dragStartWidthRef: dragStartWidthRef,
860
+ dragMaxWidthRef: dragMaxWidthRef,
861
+ getMaxPaneWidth: getMaxPaneWidth,
862
+ getDefaultWidth: getDefaultWidth,
863
+ saveWidth: saveWidth
864
+ })]
865
+ });
609
866
  });
610
- Sidebar.displayName = "PageLayout.Sidebar";
611
- const Footer = ({ "aria-label": label, "aria-labelledby": labelledBy, padding = "none", divider = "none", dividerWhenNarrow = "inherit", hidden = false, children, className, style }) => {
612
- const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== "inherit" ? {
613
- regular: divider,
614
- narrow: dividerWhenNarrow
615
- } : divider;
616
- const { rowGap } = React.useContext(PageLayoutContext);
617
- return /* @__PURE__ */ jsxs("footer", {
618
- "aria-label": label,
619
- "aria-labelledby": labelledBy,
620
- ...getResponsiveAttributes("hidden", hidden),
621
- className: clsx(PageLayout_module_css_default.FooterWrapper, className),
622
- style: {
623
- "--spacing": `var(--spacing-${rowGap})`,
624
- ...style
625
- },
626
- children: [/* @__PURE__ */ jsx(HorizontalDivider, {
627
- className: PageLayout_module_css_default.FooterHorizontalDivider,
628
- style: { "--spacing": `var(--spacing-${rowGap})` },
629
- variant: dividerProp
630
- }), /* @__PURE__ */ jsx("div", {
631
- className: PageLayout_module_css_default.FooterContent,
632
- style: { "--spacing": `var(--spacing-${padding})` },
633
- children
634
- })]
635
- });
867
+ Sidebar.displayName = 'PageLayout.Sidebar';
868
+
869
+ // ----------------------------------------------------------------------------
870
+ // PageLayout.Footer
871
+
872
+ const Footer = ({
873
+ 'aria-label': label,
874
+ 'aria-labelledby': labelledBy,
875
+ padding = 'none',
876
+ divider = 'none',
877
+ dividerWhenNarrow = 'inherit',
878
+ hidden = false,
879
+ children,
880
+ className,
881
+ style
882
+ }) => {
883
+ // Combine divider and dividerWhenNarrow for backwards compatibility
884
+ const dividerProp = !isResponsiveValue(divider) && dividerWhenNarrow !== 'inherit' ? {
885
+ regular: divider,
886
+ narrow: dividerWhenNarrow
887
+ } : divider;
888
+ const {
889
+ rowGap
890
+ } = React.useContext(PageLayoutContext);
891
+ return /*#__PURE__*/jsxs("footer", {
892
+ "aria-label": label,
893
+ "aria-labelledby": labelledBy,
894
+ ...getResponsiveAttributes('hidden', hidden),
895
+ className: clsx(classes.FooterWrapper, className),
896
+ style: {
897
+ '--spacing': `var(--spacing-${rowGap})`,
898
+ ...style
899
+ },
900
+ children: [/*#__PURE__*/jsx(HorizontalDivider, {
901
+ className: classes.FooterHorizontalDivider,
902
+ style: {
903
+ '--spacing': `var(--spacing-${rowGap})`
904
+ },
905
+ variant: dividerProp
906
+ }), /*#__PURE__*/jsx("div", {
907
+ className: classes.FooterContent,
908
+ style: {
909
+ '--spacing': `var(--spacing-${padding})`
910
+ },
911
+ children: children
912
+ })]
913
+ });
636
914
  };
637
915
  Footer.displayName = "Footer";
638
- Footer.displayName = "PageLayout.Footer";
916
+ Footer.displayName = 'PageLayout.Footer';
917
+
918
+ // ----------------------------------------------------------------------------
919
+ // Export
920
+
639
921
  const PageLayout = Object.assign(Root, {
640
- __SLOT__: Symbol("PageLayout"),
641
- Header,
642
- Content,
643
- Pane,
644
- Sidebar,
645
- Footer
922
+ __SLOT__: Symbol('PageLayout'),
923
+ Header,
924
+ Content,
925
+ Pane: Pane,
926
+ Sidebar: Sidebar,
927
+ Footer
646
928
  });
647
- Header.__SLOT__ = Symbol("PageLayout.Header");
648
- Content.__SLOT__ = Symbol("PageLayout.Content");
649
- Pane.__SLOT__ = Symbol("PageLayout.Pane");
650
- Sidebar.__SLOT__ = Symbol("PageLayout.Sidebar");
651
- Footer.__SLOT__ = Symbol("PageLayout.Footer");
652
- //#endregion
929
+ Header.__SLOT__ = Symbol('PageLayout.Header');
930
+ Content.__SLOT__ = Symbol('PageLayout.Content');
931
+ Pane.__SLOT__ = Symbol('PageLayout.Pane');
932
+ Sidebar.__SLOT__ = Symbol('PageLayout.Sidebar');
933
+ Footer.__SLOT__ = Symbol('PageLayout.Footer');
934
+
653
935
  export { PageLayout };