@primer/react 0.0.0-20260427204434 → 0.0.0-20260428150519

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 (344) hide show
  1. package/CHANGELOG.md +10 -6
  2. package/dist/ActionBar/ActionBar.js +502 -705
  3. package/dist/ActionBar/ActionBar.module.css.js +10 -5
  4. package/dist/ActionBar/index.js +8 -8
  5. package/dist/ActionList/ActionList.module.css.js +31 -5
  6. package/dist/ActionList/ActionListContainerContext.js +4 -5
  7. package/dist/ActionList/Description.js +117 -133
  8. package/dist/ActionList/Divider.js +31 -38
  9. package/dist/ActionList/Group.js +292 -349
  10. package/dist/ActionList/Group.module.css.js +10 -5
  11. package/dist/ActionList/Heading.js +88 -106
  12. package/dist/ActionList/Heading.module.css.js +5 -5
  13. package/dist/ActionList/Item.js +668 -811
  14. package/dist/ActionList/LinkItem.js +36 -56
  15. package/dist/ActionList/List.js +168 -210
  16. package/dist/ActionList/Selection.js +83 -112
  17. package/dist/ActionList/TrailingAction.js +97 -112
  18. package/dist/ActionList/Visuals.js +143 -191
  19. package/dist/ActionList/index.js +33 -33
  20. package/dist/ActionList/shared.js +5 -9
  21. package/dist/ActionMenu/ActionMenu.js +223 -310
  22. package/dist/ActionMenu/ActionMenu.module.css.js +5 -5
  23. package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
  24. package/dist/AnchoredOverlay/AnchoredOverlay.js +206 -298
  25. package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +9 -5
  26. package/dist/Autocomplete/Autocomplete.js +125 -141
  27. package/dist/Autocomplete/AutocompleteContext.js +18 -20
  28. package/dist/Autocomplete/AutocompleteInput.js +108 -146
  29. package/dist/Autocomplete/AutocompleteMenu.js +201 -238
  30. package/dist/Autocomplete/AutocompleteMenu.module.css.js +8 -5
  31. package/dist/Autocomplete/AutocompleteOverlay.js +54 -79
  32. package/dist/Autocomplete/AutocompleteOverlay.module.css.js +5 -5
  33. package/dist/Avatar/Avatar.js +106 -133
  34. package/dist/Avatar/Avatar.module.css.js +5 -5
  35. package/dist/AvatarStack/AvatarStack.js +102 -143
  36. package/dist/AvatarStack/AvatarStack.module.css.js +9 -5
  37. package/dist/Banner/Banner.js +133 -186
  38. package/dist/Banner/Banner.module.css.js +14 -5
  39. package/dist/Banner/index.js +7 -7
  40. package/dist/BaseStyles.js +74 -91
  41. package/dist/BaseStyles.module.css.js +5 -5
  42. package/dist/Blankslate/Blankslate.js +266 -328
  43. package/dist/Blankslate/Blankslate.module.css.js +12 -5
  44. package/dist/Blankslate/BlankslateContext.js +7 -9
  45. package/dist/Blankslate/index.js +9 -9
  46. package/dist/BranchName/BranchName.js +49 -59
  47. package/dist/BranchName/BranchName.module.css.js +5 -5
  48. package/dist/Breadcrumbs/Breadcrumbs.js +371 -431
  49. package/dist/Breadcrumbs/Breadcrumbs.module.css.js +15 -5
  50. package/dist/Button/Button.js +15 -18
  51. package/dist/Button/ButtonBase.js +76 -139
  52. package/dist/Button/ButtonBase.module.css.js +16 -5
  53. package/dist/Button/IconButton.js +42 -74
  54. package/dist/Button/LinkButton.js +13 -17
  55. package/dist/ButtonGroup/ButtonGroup.js +80 -97
  56. package/dist/ButtonGroup/ButtonGroup.module.css.js +5 -5
  57. package/dist/Card/Card.js +401 -491
  58. package/dist/Card/Card.module.css.js +18 -5
  59. package/dist/Card/index.js +9 -9
  60. package/dist/Checkbox/Checkbox.js +52 -71
  61. package/dist/Checkbox/Checkbox.module.css.js +9 -5
  62. package/dist/Checkbox/shared.module.css.js +5 -5
  63. package/dist/CheckboxGroup/CheckboxGroup.js +111 -132
  64. package/dist/CheckboxGroup/CheckboxGroupContext.js +4 -4
  65. package/dist/CircleBadge/CircleBadge.js +77 -90
  66. package/dist/CircleBadge/CircleBadge.module.css.js +8 -5
  67. package/dist/ConfirmationDialog/ConfirmationDialog.js +68 -92
  68. package/dist/CounterLabel/CounterLabel.js +83 -99
  69. package/dist/CounterLabel/CounterLabel.module.css.js +5 -5
  70. package/dist/DataTable/DataTable.js +100 -140
  71. package/dist/DataTable/ErrorDialog.js +33 -45
  72. package/dist/DataTable/Pagination.js +464 -592
  73. package/dist/DataTable/Pagination.module.css.js +13 -5
  74. package/dist/DataTable/Table.js +527 -710
  75. package/dist/DataTable/Table.module.css.js +26 -5
  76. package/dist/DataTable/column.js +10 -11
  77. package/dist/DataTable/index.js +22 -20
  78. package/dist/DataTable/sorting.js +65 -103
  79. package/dist/DataTable/useTable.js +207 -290
  80. package/dist/Details/Details.js +100 -126
  81. package/dist/Details/Details.module.css.js +5 -5
  82. package/dist/Dialog/Dialog.js +259 -351
  83. package/dist/Dialog/Dialog.module.css.js +22 -5
  84. package/dist/FeatureFlags/DefaultFeatureFlags.js +7 -7
  85. package/dist/FeatureFlags/FeatureFlagContext.js +5 -5
  86. package/dist/FeatureFlags/FeatureFlagScope.js +36 -44
  87. package/dist/FeatureFlags/FeatureFlags.js +29 -37
  88. package/dist/FeatureFlags/useFeatureFlag.js +17 -19
  89. package/dist/FilteredActionList/FilteredActionList.js +454 -579
  90. package/dist/FilteredActionList/FilteredActionList.module.css.js +15 -5
  91. package/dist/FilteredActionList/FilteredActionListLoaders.js +119 -150
  92. package/dist/FilteredActionList/FilteredActionListLoaders.module.css.js +9 -5
  93. package/dist/FilteredActionList/useAnnouncements.js +167 -180
  94. package/dist/Flash/Flash.js +57 -69
  95. package/dist/Flash/Flash.module.css.js +5 -5
  96. package/dist/FormControl/FormControl.js +211 -227
  97. package/dist/FormControl/FormControl.module.css.js +11 -5
  98. package/dist/FormControl/FormControlCaption.js +37 -49
  99. package/dist/FormControl/FormControlCaption.module.css.js +5 -5
  100. package/dist/FormControl/FormControlLabel.js +95 -115
  101. package/dist/FormControl/FormControlLeadingVisual.js +29 -37
  102. package/dist/FormControl/FormControlLeadingVisual.module.css.js +5 -5
  103. package/dist/FormControl/_FormControlContext.js +41 -48
  104. package/dist/FormControl/_FormControlValidation.js +29 -39
  105. package/dist/Header/Header.js +138 -165
  106. package/dist/Header/Header.module.css.js +9 -5
  107. package/dist/Heading/Heading.js +26 -37
  108. package/dist/Heading/Heading.module.css.js +5 -5
  109. package/dist/Hidden/Hidden.js +54 -77
  110. package/dist/Hidden/Hidden.module.css.js +5 -5
  111. package/dist/InlineMessage/InlineMessage.js +88 -116
  112. package/dist/InlineMessage/InlineMessage.module.css.js +8 -5
  113. package/dist/KeybindingHint/KeybindingHint.js +70 -88
  114. package/dist/KeybindingHint/KeybindingHint.module.css.js +5 -5
  115. package/dist/KeybindingHint/components/Chord.js +81 -93
  116. package/dist/KeybindingHint/components/Chord.module.css.js +11 -5
  117. package/dist/KeybindingHint/components/Key.js +49 -66
  118. package/dist/KeybindingHint/components/Sequence.js +12 -24
  119. package/dist/KeybindingHint/key-names.js +99 -114
  120. package/dist/Label/Label.js +56 -66
  121. package/dist/Label/Label.module.css.js +5 -5
  122. package/dist/Label/index.js +5 -5
  123. package/dist/LabelGroup/LabelGroup.js +260 -344
  124. package/dist/LabelGroup/LabelGroup.module.css.js +12 -5
  125. package/dist/Link/Link.js +31 -47
  126. package/dist/Link/Link.module.css.js +5 -5
  127. package/dist/NavList/NavList.js +424 -614
  128. package/dist/NavList/NavList.module.css.js +5 -5
  129. package/dist/Octicon/Octicon.js +35 -37
  130. package/dist/Overlay/Overlay.js +264 -318
  131. package/dist/Overlay/Overlay.module.css.js +8 -5
  132. package/dist/PageHeader/PageHeader.js +579 -823
  133. package/dist/PageHeader/PageHeader.module.css.js +21 -5
  134. package/dist/PageLayout/PageLayout.js +631 -913
  135. package/dist/PageLayout/PageLayout.module.css.js +31 -5
  136. package/dist/PageLayout/paneUtils.js +15 -29
  137. package/dist/PageLayout/usePaneWidth.js +334 -437
  138. package/dist/Pagehead/Pagehead.js +10 -14
  139. package/dist/Pagehead/Pagehead.module.css.js +5 -5
  140. package/dist/Pagination/Pagination.js +84 -114
  141. package/dist/Pagination/Pagination.module.css.js +9 -5
  142. package/dist/Pagination/index.js +5 -5
  143. package/dist/Pagination/model.js +118 -194
  144. package/dist/Popover/Popover.js +126 -151
  145. package/dist/Popover/Popover.module.css.js +8 -5
  146. package/dist/Portal/Portal.js +65 -85
  147. package/dist/Portal/index.js +5 -6
  148. package/dist/ProgressBar/ProgressBar.js +210 -255
  149. package/dist/ProgressBar/ProgressBar.module.css.js +9 -5
  150. package/dist/ProgressBar/index.js +6 -8
  151. package/dist/Radio/Radio.js +97 -115
  152. package/dist/Radio/Radio.module.css.js +5 -5
  153. package/dist/RadioGroup/RadioGroup.js +99 -118
  154. package/dist/RelativeTime/RelativeTime.js +64 -76
  155. package/dist/ScrollableRegion/ScrollableRegion.js +67 -79
  156. package/dist/ScrollableRegion/ScrollableRegion.module.css.js +5 -5
  157. package/dist/SegmentedControl/SegmentedControl.js +238 -287
  158. package/dist/SegmentedControl/SegmentedControl.module.css.js +15 -5
  159. package/dist/SegmentedControl/SegmentedControlButton.js +156 -187
  160. package/dist/SegmentedControl/SegmentedControlIconButton.js +133 -161
  161. package/dist/Select/Select.js +185 -234
  162. package/dist/Select/Select.module.css.js +10 -5
  163. package/dist/SelectPanel/SelectPanel.js +620 -828
  164. package/dist/SelectPanel/SelectPanel.module.css.js +27 -5
  165. package/dist/SelectPanel/SelectPanelMessage.js +37 -39
  166. package/dist/SideNav.js +24 -47
  167. package/dist/SideNav.module.css.js +12 -5
  168. package/dist/Skeleton/SkeletonBox.js +94 -111
  169. package/dist/Skeleton/SkeletonBox.module.css.js +8 -5
  170. package/dist/SkeletonAvatar/SkeletonAvatar.js +95 -120
  171. package/dist/SkeletonAvatar/SkeletonAvatar.module.css.js +5 -5
  172. package/dist/SkeletonText/SkeletonText.js +114 -137
  173. package/dist/SkeletonText/SkeletonText.module.css.js +8 -5
  174. package/dist/Spinner/Spinner.js +183 -211
  175. package/dist/Spinner/Spinner.module.css.js +9 -5
  176. package/dist/SplitPageLayout/SplitPageLayout.js +215 -276
  177. package/dist/Stack/Stack.js +207 -255
  178. package/dist/Stack/Stack.module.css.js +8 -5
  179. package/dist/Stack/index.js +4 -6
  180. package/dist/StateLabel/StateLabel.js +110 -123
  181. package/dist/StateLabel/StateLabel.module.css.js +8 -5
  182. package/dist/SubNav/SubNav.js +159 -197
  183. package/dist/SubNav/SubNav.module.css.js +11 -5
  184. package/dist/TabNav/TabNav.js +167 -199
  185. package/dist/TabNav/TabNav.module.css.js +10 -5
  186. package/dist/Text/Text.js +56 -67
  187. package/dist/Text/Text.module.css.js +5 -5
  188. package/dist/TextInput/TextInput.js +195 -228
  189. package/dist/TextInput/TextInput.module.css.js +8 -5
  190. package/dist/TextInputWithTokens/TextInputWithTokens.js +567 -673
  191. package/dist/TextInputWithTokens/TextInputWithTokens.module.css.js +14 -5
  192. package/dist/Textarea/TextArea.module.css.js +9 -5
  193. package/dist/Textarea/Textarea.js +264 -294
  194. package/dist/ThemeProvider.js +199 -257
  195. package/dist/Timeline/Timeline.js +204 -247
  196. package/dist/Timeline/Timeline.module.css.js +12 -5
  197. package/dist/ToggleSwitch/ToggleSwitch.js +403 -471
  198. package/dist/ToggleSwitch/ToggleSwitch.module.css.js +16 -5
  199. package/dist/Token/IssueLabelToken.js +256 -297
  200. package/dist/Token/IssueLabelToken.module.css.js +8 -5
  201. package/dist/Token/Token.js +232 -280
  202. package/dist/Token/Token.module.css.js +9 -5
  203. package/dist/Token/TokenBase.js +99 -126
  204. package/dist/Token/TokenBase.module.css.js +5 -5
  205. package/dist/Token/_RemoveTokenButton.js +27 -48
  206. package/dist/Token/_RemoveTokenButton.module.css.js +5 -5
  207. package/dist/Token/_TokenTextContainer.js +54 -65
  208. package/dist/Token/_TokenTextContainer.module.css.js +5 -5
  209. package/dist/Tooltip/Tooltip.js +49 -56
  210. package/dist/Tooltip/Tooltip.module.css.js +20 -5
  211. package/dist/TooltipV2/Tooltip.js +222 -305
  212. package/dist/TooltipV2/Tooltip.module.css.js +11 -5
  213. package/dist/TopicTag/TopicTag.js +46 -55
  214. package/dist/TopicTag/TopicTag.module.css.js +5 -5
  215. package/dist/TopicTag/TopicTagGroup.js +40 -48
  216. package/dist/TopicTag/TopicTagGroup.module.css.js +5 -5
  217. package/dist/TopicTag/index.js +5 -7
  218. package/dist/TreeView/TreeView.js +1082 -1414
  219. package/dist/TreeView/TreeView.module.css.js +24 -5
  220. package/dist/TreeView/shared.js +10 -9
  221. package/dist/TreeView/useRovingTabIndex.js +129 -203
  222. package/dist/TreeView/useTreeItemCache.js +64 -79
  223. package/dist/TreeView/useTypeahead.js +90 -112
  224. package/dist/Truncate/Truncate.js +21 -33
  225. package/dist/Truncate/Truncate.module.css.js +5 -5
  226. package/dist/UnderlineNav/UnderlineNav.js +278 -375
  227. package/dist/UnderlineNav/UnderlineNav.module.css.js +8 -5
  228. package/dist/UnderlineNav/UnderlineNavContext.js +8 -8
  229. package/dist/UnderlineNav/UnderlineNavItem.js +56 -72
  230. package/dist/UnderlineNav/UnderlineNavItem.module.css.js +5 -5
  231. package/dist/UnderlineNav/index.js +5 -7
  232. package/dist/UnderlineNav/styles.js +11 -15
  233. package/dist/VisuallyHidden/VisuallyHidden.js +51 -49
  234. package/dist/VisuallyHidden/VisuallyHidden.module.css.js +5 -5
  235. package/dist/_VisuallyHidden.js +50 -62
  236. package/dist/_VisuallyHidden.module.css.js +5 -5
  237. package/dist/deprecated/ActionList/Divider.js +23 -23
  238. package/dist/deprecated/ActionList/Divider.module.css.js +5 -5
  239. package/dist/deprecated/ActionList/Group.js +43 -50
  240. package/dist/deprecated/ActionList/Header.js +69 -81
  241. package/dist/deprecated/ActionList/Header.module.css.js +5 -5
  242. package/dist/deprecated/ActionList/Item.js +308 -352
  243. package/dist/deprecated/ActionList/Item.module.css.js +18 -5
  244. package/dist/deprecated/ActionList/List.js +157 -196
  245. package/dist/deprecated/ActionList/List.module.css.js +5 -5
  246. package/dist/deprecated/ActionList/index.js +14 -14
  247. package/dist/deprecated/ActionMenu.js +159 -190
  248. package/dist/deprecated/DialogV1/Dialog.js +166 -200
  249. package/dist/deprecated/DialogV1/Dialog.module.css.js +11 -5
  250. package/dist/deprecated/FilteredSearch/FilteredSearch.js +43 -51
  251. package/dist/deprecated/FilteredSearch/FilteredSearch.module.css.js +5 -5
  252. package/dist/deprecated/UnderlineNav/UnderlineNav.js +132 -160
  253. package/dist/deprecated/UnderlineNav/UnderlineNav.module.css.js +14 -5
  254. package/dist/deprecated/index.js +20 -9
  255. package/dist/experimental/IssueLabel/IssueLabel.js +134 -158
  256. package/dist/experimental/IssueLabel/IssueLabel.module.css.js +5 -5
  257. package/dist/experimental/SelectPanel2/SelectPanel.js +419 -567
  258. package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +32 -5
  259. package/dist/experimental/Tabs/Tabs.js +234 -297
  260. package/dist/experimental/UnderlinePanels/UnderlinePanels.js +165 -215
  261. package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +5 -5
  262. package/dist/experimental/index.js +44 -33
  263. package/dist/hooks/useAnchoredPosition.d.ts +0 -6
  264. package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
  265. package/dist/hooks/useAnchoredPosition.js +123 -130
  266. package/dist/hooks/useControllableState.js +34 -59
  267. package/dist/hooks/useDetails.js +84 -99
  268. package/dist/hooks/useDialog.js +140 -178
  269. package/dist/hooks/useFocusTrap.js +57 -71
  270. package/dist/hooks/useFocusZone.js +32 -38
  271. package/dist/hooks/useId.js +14 -16
  272. package/dist/hooks/useIsMacOS.js +21 -26
  273. package/dist/hooks/useMedia.js +54 -68
  274. package/dist/hooks/useMenuInitialFocus.js +65 -62
  275. package/dist/hooks/useMenuKeyboardNavigation.js +129 -126
  276. package/dist/hooks/useMergedRefs.js +63 -78
  277. package/dist/hooks/useMnemonics.js +77 -107
  278. package/dist/hooks/useOnEscapePress.js +45 -56
  279. package/dist/hooks/useOnOutsideClick.js +32 -63
  280. package/dist/hooks/useOpenAndCloseFocus.js +40 -43
  281. package/dist/hooks/useOverflow.js +32 -36
  282. package/dist/hooks/useOverlay.js +56 -75
  283. package/dist/hooks/useProvidedRefOrCreate.js +24 -24
  284. package/dist/hooks/useProvidedStateOrCreate.js +33 -39
  285. package/dist/hooks/useRefObjectAsForwardedRef.js +30 -32
  286. package/dist/hooks/useRenderForcingRef.js +42 -46
  287. package/dist/hooks/useResizeObserver.js +32 -43
  288. package/dist/hooks/useResponsiveValue.js +37 -57
  289. package/dist/hooks/useSafeTimeout.js +26 -29
  290. package/dist/hooks/useScrollFlash.js +16 -23
  291. package/dist/hooks/useSlots.js +102 -136
  292. package/dist/hooks/useSyncedState.js +31 -37
  293. package/dist/index.js +88 -85
  294. package/dist/internal/components/ButtonReset.js +45 -50
  295. package/dist/internal/components/ButtonReset.module.css.js +5 -5
  296. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +79 -105
  297. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.module.css.js +12 -5
  298. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.js +16 -21
  299. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupContext.js +4 -4
  300. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.js +26 -35
  301. package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation.js +14 -19
  302. package/dist/internal/components/ConditionalWrapper.js +41 -51
  303. package/dist/internal/components/InputLabel.js +92 -113
  304. package/dist/internal/components/InputLabel.module.css.js +8 -5
  305. package/dist/internal/components/InputValidation.js +67 -87
  306. package/dist/internal/components/InputValidation.module.css.js +9 -5
  307. package/dist/internal/components/TextInputInnerAction.js +134 -173
  308. package/dist/internal/components/TextInputInnerAction.module.css.js +9 -5
  309. package/dist/internal/components/TextInputInnerVisualSlot.js +89 -110
  310. package/dist/internal/components/TextInputInnerVisualSlot.module.css.js +11 -5
  311. package/dist/internal/components/TextInputWrapper.js +187 -230
  312. package/dist/internal/components/TextInputWrapper.module.css.js +8 -5
  313. package/dist/internal/components/UnderlineTabbedInterface.js +191 -238
  314. package/dist/internal/components/UnderlineTabbedInterface.module.css.js +11 -5
  315. package/dist/internal/components/UnstyledTextInput.js +40 -47
  316. package/dist/internal/components/UnstyledTextInput.module.css.js +5 -5
  317. package/dist/internal/components/ValidationAnimationContainer.js +55 -66
  318. package/dist/internal/components/ValidationAnimationContainer.module.css.js +8 -5
  319. package/dist/internal/hooks/useEffectCallback.js +35 -38
  320. package/dist/internal/hooks/useEffectOnce.js +23 -25
  321. package/dist/internal/utils/getResponsiveAttributes.js +23 -26
  322. package/dist/internal/utils/hasInteractiveNodes.js +34 -46
  323. package/dist/legacy-theme/ts/color-schemes.js +4250 -4732
  324. package/dist/live-region/Announce.js +144 -183
  325. package/dist/live-region/AriaAlert.js +20 -22
  326. package/dist/live-region/AriaStatus.js +20 -22
  327. package/dist/next/index.js +3 -1
  328. package/dist/test-helpers.js +40 -62
  329. package/dist/theme.js +83 -47
  330. package/dist/utils/character-counter.js +45 -63
  331. package/dist/utils/create-component.js +15 -16
  332. package/dist/utils/descendant-registry.js +182 -218
  333. package/dist/utils/environment.js +7 -7
  334. package/dist/utils/getBreakpointDeclarations.js +9 -10
  335. package/dist/utils/invariant.js +17 -23
  336. package/dist/utils/is-slot.js +10 -11
  337. package/dist/utils/isNumeric.js +3 -3
  338. package/dist/utils/modern-polymorphic.js +12 -20
  339. package/dist/utils/scroll.js +8 -11
  340. package/dist/utils/theme.js +5 -10
  341. package/dist/utils/useIsomorphicLayoutEffect.js +4 -9
  342. package/dist/utils/warning.js +14 -21
  343. package/generated/components.json +9 -9
  344. package/package.json +5 -10
@@ -1,935 +1,653 @@
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
- }
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 }
33
25
  });
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
- });
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
+ });
87
77
  };
88
78
  Root.displayName = "Root";
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
- });
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
+ });
105
89
  });
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
- });
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
+ });
129
102
  });
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
- });
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
+ });
145
112
  });
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
- });
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
+ });
236
175
  });
237
176
  /**
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
- });
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
+ });
414
320
  });
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
- });
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
+ });
461
346
  };
462
347
  Header.displayName = "Header";
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
- });
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
+ });
500
366
  };
501
367
  Content.displayName = "Content";
502
- Content.displayName = 'PageLayout.Content';
503
-
504
- // ----------------------------------------------------------------------------
505
- // PageLayout.Pane
506
-
368
+ Content.displayName = "PageLayout.Content";
507
369
  const overflowProps = {
508
- tabIndex: 0,
509
- role: 'region'
370
+ tabIndex: 0,
371
+ role: "region"
510
372
  };
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
- });
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
+ });
730
517
  });
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
- });
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
+ });
866
609
  });
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
- });
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
+ });
914
636
  };
915
637
  Footer.displayName = "Footer";
916
- Footer.displayName = 'PageLayout.Footer';
917
-
918
- // ----------------------------------------------------------------------------
919
- // Export
920
-
638
+ Footer.displayName = "PageLayout.Footer";
921
639
  const PageLayout = Object.assign(Root, {
922
- __SLOT__: Symbol('PageLayout'),
923
- Header,
924
- Content,
925
- Pane: Pane,
926
- Sidebar: Sidebar,
927
- Footer
640
+ __SLOT__: Symbol("PageLayout"),
641
+ Header,
642
+ Content,
643
+ Pane,
644
+ Sidebar,
645
+ Footer
928
646
  });
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
-
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
935
653
  export { PageLayout };