@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.
- package/CHANGELOG.md +5 -1
- package/dist/ActionBar/ActionBar.js +705 -502
- package/dist/ActionBar/ActionBar.module.css.js +5 -10
- package/dist/ActionBar/index.js +8 -8
- package/dist/ActionList/{ActionList-53389912.css → ActionList-09f5c4a8.css} +2 -2
- package/dist/ActionList/ActionList-09f5c4a8.css.map +1 -0
- package/dist/ActionList/ActionList.module.css.js +5 -31
- package/dist/ActionList/ActionListContainerContext.js +5 -4
- package/dist/ActionList/Description.js +133 -117
- package/dist/ActionList/Divider.js +38 -31
- package/dist/ActionList/Group.js +349 -292
- package/dist/ActionList/Group.module.css.js +5 -10
- package/dist/ActionList/Heading.js +106 -88
- package/dist/ActionList/Heading.module.css.js +5 -5
- package/dist/ActionList/Item.js +811 -668
- package/dist/ActionList/LinkItem.js +56 -36
- package/dist/ActionList/List.js +210 -168
- package/dist/ActionList/Selection.d.ts +2 -3
- package/dist/ActionList/Selection.d.ts.map +1 -1
- package/dist/ActionList/Selection.js +112 -83
- package/dist/ActionList/TrailingAction.js +112 -97
- package/dist/ActionList/Visuals.js +191 -143
- package/dist/ActionList/index.d.ts +7 -0
- package/dist/ActionList/index.d.ts.map +1 -1
- package/dist/ActionList/index.js +38 -33
- package/dist/ActionList/shared.js +9 -5
- package/dist/ActionMenu/ActionMenu.js +310 -223
- package/dist/ActionMenu/ActionMenu.module.css.js +5 -5
- package/dist/AnchoredOverlay/AnchoredOverlay.js +280 -206
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +5 -9
- package/dist/Autocomplete/Autocomplete.js +141 -125
- package/dist/Autocomplete/AutocompleteContext.js +20 -18
- package/dist/Autocomplete/AutocompleteInput.js +146 -108
- package/dist/Autocomplete/AutocompleteMenu.js +238 -201
- package/dist/Autocomplete/AutocompleteMenu.module.css.js +5 -8
- package/dist/Autocomplete/AutocompleteOverlay.js +79 -54
- package/dist/Autocomplete/AutocompleteOverlay.module.css.js +5 -5
- package/dist/Avatar/Avatar.js +133 -106
- package/dist/Avatar/Avatar.module.css.js +5 -5
- package/dist/AvatarStack/AvatarStack.js +143 -102
- package/dist/AvatarStack/AvatarStack.module.css.js +5 -9
- package/dist/Banner/Banner.js +186 -133
- package/dist/Banner/Banner.module.css.js +5 -14
- package/dist/Banner/index.js +7 -7
- package/dist/BaseStyles.js +91 -74
- package/dist/BaseStyles.module.css.js +5 -5
- package/dist/Blankslate/Blankslate.js +328 -266
- package/dist/Blankslate/Blankslate.module.css.js +5 -12
- package/dist/Blankslate/BlankslateContext.js +9 -7
- package/dist/Blankslate/index.js +9 -9
- package/dist/BranchName/BranchName.js +59 -49
- package/dist/BranchName/BranchName.module.css.js +5 -5
- package/dist/Breadcrumbs/Breadcrumbs.js +431 -371
- package/dist/Breadcrumbs/Breadcrumbs.module.css.js +5 -15
- package/dist/Button/Button.js +18 -15
- package/dist/Button/ButtonBase.js +139 -76
- package/dist/Button/ButtonBase.module.css.js +5 -16
- package/dist/Button/IconButton.js +74 -42
- package/dist/Button/LinkButton.js +17 -13
- package/dist/ButtonGroup/ButtonGroup.js +97 -80
- package/dist/ButtonGroup/ButtonGroup.module.css.js +5 -5
- package/dist/Card/Card.js +491 -401
- package/dist/Card/Card.module.css.js +5 -18
- package/dist/Card/index.js +9 -9
- package/dist/Checkbox/Checkbox.js +71 -52
- package/dist/Checkbox/Checkbox.module.css.js +5 -9
- package/dist/Checkbox/shared.module.css.js +5 -5
- package/dist/CheckboxGroup/CheckboxGroup.js +132 -111
- package/dist/CheckboxGroup/CheckboxGroupContext.js +4 -4
- package/dist/CircleBadge/CircleBadge.js +90 -77
- package/dist/CircleBadge/CircleBadge.module.css.js +5 -8
- package/dist/ConfirmationDialog/ConfirmationDialog.js +92 -68
- package/dist/CounterLabel/CounterLabel.js +99 -83
- package/dist/CounterLabel/CounterLabel.module.css.js +5 -5
- package/dist/DataTable/DataTable.js +140 -100
- package/dist/DataTable/ErrorDialog.js +45 -33
- package/dist/DataTable/Pagination.js +592 -464
- package/dist/DataTable/Pagination.module.css.js +5 -13
- package/dist/DataTable/Table.js +710 -527
- package/dist/DataTable/Table.module.css.js +5 -26
- package/dist/DataTable/column.js +11 -10
- package/dist/DataTable/index.js +20 -22
- package/dist/DataTable/sorting.js +103 -65
- package/dist/DataTable/useTable.js +290 -207
- package/dist/Details/Details.js +126 -100
- package/dist/Details/Details.module.css.js +5 -5
- package/dist/Dialog/Dialog.js +351 -259
- package/dist/Dialog/Dialog.module.css.js +5 -22
- package/dist/FeatureFlags/DefaultFeatureFlags.js +7 -7
- package/dist/FeatureFlags/FeatureFlagContext.js +5 -5
- package/dist/FeatureFlags/FeatureFlagScope.js +44 -36
- package/dist/FeatureFlags/FeatureFlags.js +37 -29
- package/dist/FeatureFlags/useFeatureFlag.js +19 -17
- package/dist/FilteredActionList/FilteredActionList.d.ts.map +1 -1
- package/dist/FilteredActionList/FilteredActionList.js +559 -454
- package/dist/FilteredActionList/FilteredActionList.module.css.js +5 -15
- package/dist/FilteredActionList/FilteredActionListInput.d.ts +15 -0
- package/dist/FilteredActionList/FilteredActionListInput.d.ts.map +1 -0
- package/dist/FilteredActionList/FilteredActionListInput.js +119 -0
- package/dist/FilteredActionList/FilteredActionListLoaders.js +150 -119
- package/dist/FilteredActionList/FilteredActionListLoaders.module.css.js +5 -9
- package/dist/FilteredActionList/index.d.ts +9 -1
- package/dist/FilteredActionList/index.d.ts.map +1 -1
- package/dist/FilteredActionList/index.js +11 -0
- package/dist/FilteredActionList/useAnnouncements.js +180 -167
- package/dist/Flash/Flash.js +69 -57
- package/dist/Flash/Flash.module.css.js +5 -5
- package/dist/FormControl/FormControl.js +227 -211
- package/dist/FormControl/FormControl.module.css.js +5 -11
- package/dist/FormControl/FormControlCaption.js +49 -37
- package/dist/FormControl/FormControlCaption.module.css.js +5 -5
- package/dist/FormControl/FormControlLabel.js +115 -95
- package/dist/FormControl/FormControlLeadingVisual.js +37 -29
- package/dist/FormControl/FormControlLeadingVisual.module.css.js +5 -5
- package/dist/FormControl/_FormControlContext.js +48 -41
- package/dist/FormControl/_FormControlValidation.js +39 -29
- package/dist/Header/Header.js +165 -138
- package/dist/Header/Header.module.css.js +5 -9
- package/dist/Heading/Heading.js +37 -26
- package/dist/Heading/Heading.module.css.js +5 -5
- package/dist/Hidden/Hidden.js +77 -54
- package/dist/Hidden/Hidden.module.css.js +5 -5
- package/dist/InlineMessage/InlineMessage.js +116 -88
- package/dist/InlineMessage/InlineMessage.module.css.js +5 -8
- package/dist/KeybindingHint/KeybindingHint.js +88 -70
- package/dist/KeybindingHint/KeybindingHint.module.css.js +5 -5
- package/dist/KeybindingHint/components/Chord.js +93 -81
- package/dist/KeybindingHint/components/Chord.module.css.js +5 -11
- package/dist/KeybindingHint/components/Key.js +66 -49
- package/dist/KeybindingHint/components/Sequence.js +24 -12
- package/dist/KeybindingHint/key-names.js +114 -99
- package/dist/Label/Label.js +66 -56
- package/dist/Label/Label.module.css.js +5 -5
- package/dist/Label/index.js +5 -5
- package/dist/LabelGroup/LabelGroup.js +344 -260
- package/dist/LabelGroup/LabelGroup.module.css.js +5 -12
- package/dist/Link/Link.js +47 -31
- package/dist/Link/Link.module.css.js +5 -5
- package/dist/NavList/NavList.js +614 -424
- package/dist/NavList/NavList.module.css.js +5 -5
- package/dist/Octicon/Octicon.js +37 -35
- package/dist/Overlay/Overlay.js +318 -264
- package/dist/Overlay/Overlay.module.css.js +5 -8
- package/dist/PageHeader/PageHeader.js +823 -579
- package/dist/PageHeader/PageHeader.module.css.js +5 -21
- package/dist/PageLayout/PageLayout.js +913 -631
- package/dist/PageLayout/PageLayout.module.css.js +5 -31
- package/dist/PageLayout/paneUtils.js +29 -15
- package/dist/PageLayout/usePaneWidth.js +437 -334
- package/dist/Pagehead/Pagehead.js +14 -10
- package/dist/Pagehead/Pagehead.module.css.js +5 -5
- package/dist/Pagination/Pagination.js +114 -84
- package/dist/Pagination/Pagination.module.css.js +5 -9
- package/dist/Pagination/index.js +5 -5
- package/dist/Pagination/model.js +194 -118
- package/dist/Popover/Popover.js +151 -126
- package/dist/Popover/Popover.module.css.js +5 -8
- package/dist/Portal/Portal.js +85 -65
- package/dist/Portal/index.js +6 -5
- package/dist/ProgressBar/ProgressBar.js +255 -210
- package/dist/ProgressBar/ProgressBar.module.css.js +5 -9
- package/dist/ProgressBar/index.js +8 -6
- package/dist/Radio/Radio.js +115 -97
- package/dist/Radio/Radio.module.css.js +5 -5
- package/dist/RadioGroup/RadioGroup.js +118 -99
- package/dist/RelativeTime/RelativeTime.js +76 -64
- package/dist/ScrollableRegion/ScrollableRegion.js +79 -67
- package/dist/ScrollableRegion/ScrollableRegion.module.css.js +5 -5
- package/dist/SegmentedControl/SegmentedControl.js +287 -238
- package/dist/SegmentedControl/SegmentedControl.module.css.js +5 -15
- package/dist/SegmentedControl/SegmentedControlButton.js +187 -156
- package/dist/SegmentedControl/SegmentedControlIconButton.js +161 -133
- package/dist/Select/Select.js +234 -185
- package/dist/Select/Select.module.css.js +5 -10
- package/dist/SelectPanel/SelectPanel.d.ts +1 -0
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +829 -620
- package/dist/SelectPanel/SelectPanel.module.css.js +5 -27
- package/dist/SelectPanel/SelectPanelMessage.js +39 -37
- package/dist/SelectPanel/index.d.ts +1 -0
- package/dist/SelectPanel/index.d.ts.map +1 -1
- package/dist/SideNav.js +47 -24
- package/dist/SideNav.module.css.js +5 -12
- package/dist/Skeleton/SkeletonBox.js +111 -94
- package/dist/Skeleton/SkeletonBox.module.css.js +5 -8
- package/dist/SkeletonAvatar/SkeletonAvatar.js +120 -95
- package/dist/SkeletonAvatar/SkeletonAvatar.module.css.js +5 -5
- package/dist/SkeletonText/SkeletonText.js +137 -114
- package/dist/SkeletonText/SkeletonText.module.css.js +5 -8
- package/dist/Spinner/Spinner.js +211 -183
- package/dist/Spinner/Spinner.module.css.js +5 -9
- package/dist/SplitPageLayout/SplitPageLayout.js +276 -215
- package/dist/Stack/Stack.js +255 -207
- package/dist/Stack/Stack.module.css.js +5 -8
- package/dist/Stack/index.js +6 -4
- package/dist/StateLabel/StateLabel.js +123 -110
- package/dist/StateLabel/StateLabel.module.css.js +5 -8
- package/dist/SubNav/SubNav.js +197 -159
- package/dist/SubNav/SubNav.module.css.js +5 -11
- package/dist/TabNav/TabNav.js +199 -167
- package/dist/TabNav/TabNav.module.css.js +5 -10
- package/dist/Text/Text.js +67 -56
- package/dist/Text/Text.module.css.js +5 -5
- package/dist/TextInput/TextInput.js +228 -195
- package/dist/TextInput/TextInput.module.css.js +5 -8
- package/dist/TextInputWithTokens/TextInputWithTokens.js +673 -567
- package/dist/TextInputWithTokens/TextInputWithTokens.module.css.js +5 -14
- package/dist/Textarea/TextArea.module.css.js +5 -9
- package/dist/Textarea/Textarea.js +294 -264
- package/dist/ThemeProvider.js +257 -199
- package/dist/Timeline/Timeline.js +247 -204
- package/dist/Timeline/Timeline.module.css.js +5 -12
- package/dist/ToggleSwitch/ToggleSwitch.js +471 -403
- package/dist/ToggleSwitch/ToggleSwitch.module.css.js +5 -16
- package/dist/Token/IssueLabelToken.js +297 -256
- package/dist/Token/IssueLabelToken.module.css.js +5 -8
- package/dist/Token/Token.js +280 -232
- package/dist/Token/Token.module.css.js +5 -9
- package/dist/Token/TokenBase.js +126 -99
- package/dist/Token/TokenBase.module.css.js +5 -5
- package/dist/Token/_RemoveTokenButton.js +48 -27
- package/dist/Token/_RemoveTokenButton.module.css.js +5 -5
- package/dist/Token/_TokenTextContainer.js +65 -54
- package/dist/Token/_TokenTextContainer.module.css.js +5 -5
- package/dist/Tooltip/Tooltip.js +56 -49
- package/dist/Tooltip/Tooltip.module.css.js +5 -20
- package/dist/TooltipV2/Tooltip.js +305 -222
- package/dist/TooltipV2/Tooltip.module.css.js +5 -11
- package/dist/TopicTag/TopicTag.js +55 -46
- package/dist/TopicTag/TopicTag.module.css.js +5 -5
- package/dist/TopicTag/TopicTagGroup.js +48 -40
- package/dist/TopicTag/TopicTagGroup.module.css.js +5 -5
- package/dist/TopicTag/index.js +7 -5
- package/dist/TreeView/TreeView.js +1414 -1082
- package/dist/TreeView/TreeView.module.css.js +5 -24
- package/dist/TreeView/shared.js +9 -10
- package/dist/TreeView/useRovingTabIndex.js +203 -129
- package/dist/TreeView/useTreeItemCache.js +79 -64
- package/dist/TreeView/useTypeahead.js +112 -90
- package/dist/Truncate/Truncate.js +33 -21
- package/dist/Truncate/Truncate.module.css.js +5 -5
- package/dist/UnderlineNav/UnderlineNav.js +375 -278
- package/dist/UnderlineNav/UnderlineNav.module.css.js +5 -8
- package/dist/UnderlineNav/UnderlineNavContext.js +8 -8
- package/dist/UnderlineNav/UnderlineNavItem.js +72 -56
- package/dist/UnderlineNav/UnderlineNavItem.module.css.js +5 -5
- package/dist/UnderlineNav/index.js +7 -5
- package/dist/UnderlineNav/styles.js +15 -11
- package/dist/VisuallyHidden/VisuallyHidden.js +49 -51
- package/dist/VisuallyHidden/VisuallyHidden.module.css.js +5 -5
- package/dist/_VisuallyHidden.js +62 -50
- package/dist/_VisuallyHidden.module.css.js +5 -5
- package/dist/deprecated/ActionList/Divider.js +23 -23
- package/dist/deprecated/ActionList/Divider.module.css.js +5 -5
- package/dist/deprecated/ActionList/Group.js +50 -43
- package/dist/deprecated/ActionList/Header.js +81 -69
- package/dist/deprecated/ActionList/Header.module.css.js +5 -5
- package/dist/deprecated/ActionList/Item.js +352 -308
- package/dist/deprecated/ActionList/Item.module.css.js +5 -18
- package/dist/deprecated/ActionList/List.js +196 -157
- package/dist/deprecated/ActionList/List.module.css.js +5 -5
- package/dist/deprecated/ActionList/index.js +14 -14
- package/dist/deprecated/ActionMenu.js +190 -159
- package/dist/deprecated/DialogV1/Dialog.js +200 -166
- package/dist/deprecated/DialogV1/Dialog.module.css.js +5 -11
- package/dist/deprecated/FilteredSearch/FilteredSearch.js +51 -43
- package/dist/deprecated/FilteredSearch/FilteredSearch.module.css.js +5 -5
- package/dist/deprecated/UnderlineNav/UnderlineNav.js +160 -132
- package/dist/deprecated/UnderlineNav/UnderlineNav.module.css.js +5 -14
- package/dist/deprecated/index.js +9 -20
- package/dist/experimental/IssueLabel/IssueLabel.js +158 -134
- package/dist/experimental/IssueLabel/IssueLabel.module.css.js +5 -5
- package/dist/experimental/SelectPanel2/SelectPanel.js +567 -419
- package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +5 -32
- package/dist/experimental/Tabs/Tabs.js +297 -234
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +215 -165
- package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +5 -5
- package/dist/experimental/index.d.ts +2 -2
- package/dist/experimental/index.d.ts.map +1 -1
- package/dist/experimental/index.js +34 -44
- package/dist/hooks/useAnchoredPosition.js +144 -123
- package/dist/hooks/useControllableState.js +59 -34
- package/dist/hooks/useDetails.js +99 -84
- package/dist/hooks/useDialog.js +178 -140
- package/dist/hooks/useFocusTrap.js +71 -57
- package/dist/hooks/useFocusZone.js +38 -32
- package/dist/hooks/useId.js +16 -14
- package/dist/hooks/useIsMacOS.js +26 -21
- package/dist/hooks/useMedia.js +68 -54
- package/dist/hooks/useMenuInitialFocus.js +62 -65
- package/dist/hooks/useMenuKeyboardNavigation.js +126 -129
- package/dist/hooks/useMergedRefs.js +78 -63
- package/dist/hooks/useMnemonics.js +107 -77
- package/dist/hooks/useOnEscapePress.js +56 -45
- package/dist/hooks/useOnOutsideClick.js +63 -32
- package/dist/hooks/useOpenAndCloseFocus.js +43 -40
- package/dist/hooks/useOverflow.js +36 -32
- package/dist/hooks/useOverlay.js +75 -56
- package/dist/hooks/useProvidedRefOrCreate.js +24 -24
- package/dist/hooks/useProvidedStateOrCreate.js +39 -33
- package/dist/hooks/useRefObjectAsForwardedRef.js +32 -30
- package/dist/hooks/useRenderForcingRef.js +46 -42
- package/dist/hooks/useResizeObserver.js +43 -32
- package/dist/hooks/useResponsiveValue.js +57 -37
- package/dist/hooks/useSafeTimeout.js +29 -26
- package/dist/hooks/useScrollFlash.js +23 -16
- package/dist/hooks/useSlots.js +136 -102
- package/dist/hooks/useSyncedState.js +37 -31
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -88
- package/dist/internal/components/ButtonReset.js +50 -45
- package/dist/internal/components/ButtonReset.module.css.js +5 -5
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +105 -79
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.module.css.js +5 -12
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.js +21 -16
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupContext.js +4 -4
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.js +35 -26
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation.js +19 -14
- package/dist/internal/components/ConditionalWrapper.js +51 -41
- package/dist/internal/components/InputLabel.js +113 -92
- package/dist/internal/components/InputLabel.module.css.js +5 -8
- package/dist/internal/components/InputValidation.js +87 -67
- package/dist/internal/components/InputValidation.module.css.js +5 -9
- package/dist/internal/components/TextInputInnerAction.js +173 -134
- package/dist/internal/components/TextInputInnerAction.module.css.js +5 -9
- package/dist/internal/components/TextInputInnerVisualSlot.js +110 -89
- package/dist/internal/components/TextInputInnerVisualSlot.module.css.js +5 -11
- package/dist/internal/components/TextInputWrapper.js +230 -187
- package/dist/internal/components/TextInputWrapper.module.css.js +5 -8
- package/dist/internal/components/UnderlineTabbedInterface.js +238 -191
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +5 -11
- package/dist/internal/components/UnstyledTextInput.js +47 -40
- package/dist/internal/components/UnstyledTextInput.module.css.js +5 -5
- package/dist/internal/components/ValidationAnimationContainer.js +66 -55
- package/dist/internal/components/ValidationAnimationContainer.module.css.js +5 -8
- package/dist/internal/hooks/useEffectCallback.js +38 -35
- package/dist/internal/hooks/useEffectOnce.js +25 -23
- package/dist/internal/utils/getResponsiveAttributes.js +26 -23
- package/dist/internal/utils/hasInteractiveNodes.js +46 -34
- package/dist/legacy-theme/ts/color-schemes.js +4732 -4250
- package/dist/live-region/Announce.js +183 -144
- package/dist/live-region/AriaAlert.js +22 -20
- package/dist/live-region/AriaStatus.js +22 -20
- package/dist/next/index.js +1 -3
- package/dist/test-helpers.js +62 -40
- package/dist/theme.js +47 -83
- package/dist/utils/character-counter.js +63 -45
- package/dist/utils/create-component.js +16 -15
- package/dist/utils/descendant-registry.js +218 -182
- package/dist/utils/environment.js +7 -7
- package/dist/utils/getBreakpointDeclarations.js +10 -9
- package/dist/utils/invariant.js +23 -17
- package/dist/utils/is-slot.js +11 -10
- package/dist/utils/isNumeric.js +3 -3
- package/dist/utils/modern-polymorphic.js +20 -12
- package/dist/utils/scroll.js +11 -8
- package/dist/utils/theme.js +10 -5
- package/dist/utils/useIsomorphicLayoutEffect.js +9 -4
- package/dist/utils/warning.js +21 -14
- package/package.json +10 -5
- package/dist/ActionList/ActionList-53389912.css.map +0 -1
|
@@ -1,653 +1,935 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
const isArrowKey =
|
|
16
|
-
const isShrinkKey =
|
|
17
|
-
const PageLayoutContext =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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 =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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 =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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 =
|
|
104
|
-
const VerticalDivider =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 =
|
|
114
|
-
const SidebarDivider =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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 =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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 =
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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 =
|
|
502
|
+
Content.displayName = 'PageLayout.Content';
|
|
503
|
+
|
|
504
|
+
// ----------------------------------------------------------------------------
|
|
505
|
+
// PageLayout.Pane
|
|
506
|
+
|
|
369
507
|
const overflowProps = {
|
|
370
|
-
|
|
371
|
-
|
|
508
|
+
tabIndex: 0,
|
|
509
|
+
role: 'region'
|
|
372
510
|
};
|
|
373
|
-
const Pane =
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
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 =
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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 =
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
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 =
|
|
916
|
+
Footer.displayName = 'PageLayout.Footer';
|
|
917
|
+
|
|
918
|
+
// ----------------------------------------------------------------------------
|
|
919
|
+
// Export
|
|
920
|
+
|
|
639
921
|
const PageLayout = Object.assign(Root, {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
922
|
+
__SLOT__: Symbol('PageLayout'),
|
|
923
|
+
Header,
|
|
924
|
+
Content,
|
|
925
|
+
Pane: Pane,
|
|
926
|
+
Sidebar: Sidebar,
|
|
927
|
+
Footer
|
|
646
928
|
});
|
|
647
|
-
Header.__SLOT__ = Symbol(
|
|
648
|
-
Content.__SLOT__ = Symbol(
|
|
649
|
-
Pane.__SLOT__ = Symbol(
|
|
650
|
-
Sidebar.__SLOT__ = Symbol(
|
|
651
|
-
Footer.__SLOT__ = Symbol(
|
|
652
|
-
|
|
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 };
|