@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.
- package/CHANGELOG.md +10 -6
- package/dist/ActionBar/ActionBar.js +502 -705
- package/dist/ActionBar/ActionBar.module.css.js +10 -5
- package/dist/ActionBar/index.js +8 -8
- package/dist/ActionList/ActionList.module.css.js +31 -5
- package/dist/ActionList/ActionListContainerContext.js +4 -5
- package/dist/ActionList/Description.js +117 -133
- package/dist/ActionList/Divider.js +31 -38
- package/dist/ActionList/Group.js +292 -349
- package/dist/ActionList/Group.module.css.js +10 -5
- package/dist/ActionList/Heading.js +88 -106
- package/dist/ActionList/Heading.module.css.js +5 -5
- package/dist/ActionList/Item.js +668 -811
- package/dist/ActionList/LinkItem.js +36 -56
- package/dist/ActionList/List.js +168 -210
- package/dist/ActionList/Selection.js +83 -112
- package/dist/ActionList/TrailingAction.js +97 -112
- package/dist/ActionList/Visuals.js +143 -191
- package/dist/ActionList/index.js +33 -33
- package/dist/ActionList/shared.js +5 -9
- package/dist/ActionMenu/ActionMenu.js +223 -310
- package/dist/ActionMenu/ActionMenu.module.css.js +5 -5
- package/dist/AnchoredOverlay/AnchoredOverlay.d.ts.map +1 -1
- package/dist/AnchoredOverlay/AnchoredOverlay.js +206 -298
- package/dist/AnchoredOverlay/AnchoredOverlay.module.css.js +9 -5
- package/dist/Autocomplete/Autocomplete.js +125 -141
- package/dist/Autocomplete/AutocompleteContext.js +18 -20
- package/dist/Autocomplete/AutocompleteInput.js +108 -146
- package/dist/Autocomplete/AutocompleteMenu.js +201 -238
- package/dist/Autocomplete/AutocompleteMenu.module.css.js +8 -5
- package/dist/Autocomplete/AutocompleteOverlay.js +54 -79
- package/dist/Autocomplete/AutocompleteOverlay.module.css.js +5 -5
- package/dist/Avatar/Avatar.js +106 -133
- package/dist/Avatar/Avatar.module.css.js +5 -5
- package/dist/AvatarStack/AvatarStack.js +102 -143
- package/dist/AvatarStack/AvatarStack.module.css.js +9 -5
- package/dist/Banner/Banner.js +133 -186
- package/dist/Banner/Banner.module.css.js +14 -5
- package/dist/Banner/index.js +7 -7
- package/dist/BaseStyles.js +74 -91
- package/dist/BaseStyles.module.css.js +5 -5
- package/dist/Blankslate/Blankslate.js +266 -328
- package/dist/Blankslate/Blankslate.module.css.js +12 -5
- package/dist/Blankslate/BlankslateContext.js +7 -9
- package/dist/Blankslate/index.js +9 -9
- package/dist/BranchName/BranchName.js +49 -59
- package/dist/BranchName/BranchName.module.css.js +5 -5
- package/dist/Breadcrumbs/Breadcrumbs.js +371 -431
- package/dist/Breadcrumbs/Breadcrumbs.module.css.js +15 -5
- package/dist/Button/Button.js +15 -18
- package/dist/Button/ButtonBase.js +76 -139
- package/dist/Button/ButtonBase.module.css.js +16 -5
- package/dist/Button/IconButton.js +42 -74
- package/dist/Button/LinkButton.js +13 -17
- package/dist/ButtonGroup/ButtonGroup.js +80 -97
- package/dist/ButtonGroup/ButtonGroup.module.css.js +5 -5
- package/dist/Card/Card.js +401 -491
- package/dist/Card/Card.module.css.js +18 -5
- package/dist/Card/index.js +9 -9
- package/dist/Checkbox/Checkbox.js +52 -71
- package/dist/Checkbox/Checkbox.module.css.js +9 -5
- package/dist/Checkbox/shared.module.css.js +5 -5
- package/dist/CheckboxGroup/CheckboxGroup.js +111 -132
- package/dist/CheckboxGroup/CheckboxGroupContext.js +4 -4
- package/dist/CircleBadge/CircleBadge.js +77 -90
- package/dist/CircleBadge/CircleBadge.module.css.js +8 -5
- package/dist/ConfirmationDialog/ConfirmationDialog.js +68 -92
- package/dist/CounterLabel/CounterLabel.js +83 -99
- package/dist/CounterLabel/CounterLabel.module.css.js +5 -5
- package/dist/DataTable/DataTable.js +100 -140
- package/dist/DataTable/ErrorDialog.js +33 -45
- package/dist/DataTable/Pagination.js +464 -592
- package/dist/DataTable/Pagination.module.css.js +13 -5
- package/dist/DataTable/Table.js +527 -710
- package/dist/DataTable/Table.module.css.js +26 -5
- package/dist/DataTable/column.js +10 -11
- package/dist/DataTable/index.js +22 -20
- package/dist/DataTable/sorting.js +65 -103
- package/dist/DataTable/useTable.js +207 -290
- package/dist/Details/Details.js +100 -126
- package/dist/Details/Details.module.css.js +5 -5
- package/dist/Dialog/Dialog.js +259 -351
- package/dist/Dialog/Dialog.module.css.js +22 -5
- package/dist/FeatureFlags/DefaultFeatureFlags.js +7 -7
- package/dist/FeatureFlags/FeatureFlagContext.js +5 -5
- package/dist/FeatureFlags/FeatureFlagScope.js +36 -44
- package/dist/FeatureFlags/FeatureFlags.js +29 -37
- package/dist/FeatureFlags/useFeatureFlag.js +17 -19
- package/dist/FilteredActionList/FilteredActionList.js +454 -579
- package/dist/FilteredActionList/FilteredActionList.module.css.js +15 -5
- package/dist/FilteredActionList/FilteredActionListLoaders.js +119 -150
- package/dist/FilteredActionList/FilteredActionListLoaders.module.css.js +9 -5
- package/dist/FilteredActionList/useAnnouncements.js +167 -180
- package/dist/Flash/Flash.js +57 -69
- package/dist/Flash/Flash.module.css.js +5 -5
- package/dist/FormControl/FormControl.js +211 -227
- package/dist/FormControl/FormControl.module.css.js +11 -5
- package/dist/FormControl/FormControlCaption.js +37 -49
- package/dist/FormControl/FormControlCaption.module.css.js +5 -5
- package/dist/FormControl/FormControlLabel.js +95 -115
- package/dist/FormControl/FormControlLeadingVisual.js +29 -37
- package/dist/FormControl/FormControlLeadingVisual.module.css.js +5 -5
- package/dist/FormControl/_FormControlContext.js +41 -48
- package/dist/FormControl/_FormControlValidation.js +29 -39
- package/dist/Header/Header.js +138 -165
- package/dist/Header/Header.module.css.js +9 -5
- package/dist/Heading/Heading.js +26 -37
- package/dist/Heading/Heading.module.css.js +5 -5
- package/dist/Hidden/Hidden.js +54 -77
- package/dist/Hidden/Hidden.module.css.js +5 -5
- package/dist/InlineMessage/InlineMessage.js +88 -116
- package/dist/InlineMessage/InlineMessage.module.css.js +8 -5
- package/dist/KeybindingHint/KeybindingHint.js +70 -88
- package/dist/KeybindingHint/KeybindingHint.module.css.js +5 -5
- package/dist/KeybindingHint/components/Chord.js +81 -93
- package/dist/KeybindingHint/components/Chord.module.css.js +11 -5
- package/dist/KeybindingHint/components/Key.js +49 -66
- package/dist/KeybindingHint/components/Sequence.js +12 -24
- package/dist/KeybindingHint/key-names.js +99 -114
- package/dist/Label/Label.js +56 -66
- package/dist/Label/Label.module.css.js +5 -5
- package/dist/Label/index.js +5 -5
- package/dist/LabelGroup/LabelGroup.js +260 -344
- package/dist/LabelGroup/LabelGroup.module.css.js +12 -5
- package/dist/Link/Link.js +31 -47
- package/dist/Link/Link.module.css.js +5 -5
- package/dist/NavList/NavList.js +424 -614
- package/dist/NavList/NavList.module.css.js +5 -5
- package/dist/Octicon/Octicon.js +35 -37
- package/dist/Overlay/Overlay.js +264 -318
- package/dist/Overlay/Overlay.module.css.js +8 -5
- package/dist/PageHeader/PageHeader.js +579 -823
- package/dist/PageHeader/PageHeader.module.css.js +21 -5
- package/dist/PageLayout/PageLayout.js +631 -913
- package/dist/PageLayout/PageLayout.module.css.js +31 -5
- package/dist/PageLayout/paneUtils.js +15 -29
- package/dist/PageLayout/usePaneWidth.js +334 -437
- package/dist/Pagehead/Pagehead.js +10 -14
- package/dist/Pagehead/Pagehead.module.css.js +5 -5
- package/dist/Pagination/Pagination.js +84 -114
- package/dist/Pagination/Pagination.module.css.js +9 -5
- package/dist/Pagination/index.js +5 -5
- package/dist/Pagination/model.js +118 -194
- package/dist/Popover/Popover.js +126 -151
- package/dist/Popover/Popover.module.css.js +8 -5
- package/dist/Portal/Portal.js +65 -85
- package/dist/Portal/index.js +5 -6
- package/dist/ProgressBar/ProgressBar.js +210 -255
- package/dist/ProgressBar/ProgressBar.module.css.js +9 -5
- package/dist/ProgressBar/index.js +6 -8
- package/dist/Radio/Radio.js +97 -115
- package/dist/Radio/Radio.module.css.js +5 -5
- package/dist/RadioGroup/RadioGroup.js +99 -118
- package/dist/RelativeTime/RelativeTime.js +64 -76
- package/dist/ScrollableRegion/ScrollableRegion.js +67 -79
- package/dist/ScrollableRegion/ScrollableRegion.module.css.js +5 -5
- package/dist/SegmentedControl/SegmentedControl.js +238 -287
- package/dist/SegmentedControl/SegmentedControl.module.css.js +15 -5
- package/dist/SegmentedControl/SegmentedControlButton.js +156 -187
- package/dist/SegmentedControl/SegmentedControlIconButton.js +133 -161
- package/dist/Select/Select.js +185 -234
- package/dist/Select/Select.module.css.js +10 -5
- package/dist/SelectPanel/SelectPanel.js +620 -828
- package/dist/SelectPanel/SelectPanel.module.css.js +27 -5
- package/dist/SelectPanel/SelectPanelMessage.js +37 -39
- package/dist/SideNav.js +24 -47
- package/dist/SideNav.module.css.js +12 -5
- package/dist/Skeleton/SkeletonBox.js +94 -111
- package/dist/Skeleton/SkeletonBox.module.css.js +8 -5
- package/dist/SkeletonAvatar/SkeletonAvatar.js +95 -120
- package/dist/SkeletonAvatar/SkeletonAvatar.module.css.js +5 -5
- package/dist/SkeletonText/SkeletonText.js +114 -137
- package/dist/SkeletonText/SkeletonText.module.css.js +8 -5
- package/dist/Spinner/Spinner.js +183 -211
- package/dist/Spinner/Spinner.module.css.js +9 -5
- package/dist/SplitPageLayout/SplitPageLayout.js +215 -276
- package/dist/Stack/Stack.js +207 -255
- package/dist/Stack/Stack.module.css.js +8 -5
- package/dist/Stack/index.js +4 -6
- package/dist/StateLabel/StateLabel.js +110 -123
- package/dist/StateLabel/StateLabel.module.css.js +8 -5
- package/dist/SubNav/SubNav.js +159 -197
- package/dist/SubNav/SubNav.module.css.js +11 -5
- package/dist/TabNav/TabNav.js +167 -199
- package/dist/TabNav/TabNav.module.css.js +10 -5
- package/dist/Text/Text.js +56 -67
- package/dist/Text/Text.module.css.js +5 -5
- package/dist/TextInput/TextInput.js +195 -228
- package/dist/TextInput/TextInput.module.css.js +8 -5
- package/dist/TextInputWithTokens/TextInputWithTokens.js +567 -673
- package/dist/TextInputWithTokens/TextInputWithTokens.module.css.js +14 -5
- package/dist/Textarea/TextArea.module.css.js +9 -5
- package/dist/Textarea/Textarea.js +264 -294
- package/dist/ThemeProvider.js +199 -257
- package/dist/Timeline/Timeline.js +204 -247
- package/dist/Timeline/Timeline.module.css.js +12 -5
- package/dist/ToggleSwitch/ToggleSwitch.js +403 -471
- package/dist/ToggleSwitch/ToggleSwitch.module.css.js +16 -5
- package/dist/Token/IssueLabelToken.js +256 -297
- package/dist/Token/IssueLabelToken.module.css.js +8 -5
- package/dist/Token/Token.js +232 -280
- package/dist/Token/Token.module.css.js +9 -5
- package/dist/Token/TokenBase.js +99 -126
- package/dist/Token/TokenBase.module.css.js +5 -5
- package/dist/Token/_RemoveTokenButton.js +27 -48
- package/dist/Token/_RemoveTokenButton.module.css.js +5 -5
- package/dist/Token/_TokenTextContainer.js +54 -65
- package/dist/Token/_TokenTextContainer.module.css.js +5 -5
- package/dist/Tooltip/Tooltip.js +49 -56
- package/dist/Tooltip/Tooltip.module.css.js +20 -5
- package/dist/TooltipV2/Tooltip.js +222 -305
- package/dist/TooltipV2/Tooltip.module.css.js +11 -5
- package/dist/TopicTag/TopicTag.js +46 -55
- package/dist/TopicTag/TopicTag.module.css.js +5 -5
- package/dist/TopicTag/TopicTagGroup.js +40 -48
- package/dist/TopicTag/TopicTagGroup.module.css.js +5 -5
- package/dist/TopicTag/index.js +5 -7
- package/dist/TreeView/TreeView.js +1082 -1414
- package/dist/TreeView/TreeView.module.css.js +24 -5
- package/dist/TreeView/shared.js +10 -9
- package/dist/TreeView/useRovingTabIndex.js +129 -203
- package/dist/TreeView/useTreeItemCache.js +64 -79
- package/dist/TreeView/useTypeahead.js +90 -112
- package/dist/Truncate/Truncate.js +21 -33
- package/dist/Truncate/Truncate.module.css.js +5 -5
- package/dist/UnderlineNav/UnderlineNav.js +278 -375
- package/dist/UnderlineNav/UnderlineNav.module.css.js +8 -5
- package/dist/UnderlineNav/UnderlineNavContext.js +8 -8
- package/dist/UnderlineNav/UnderlineNavItem.js +56 -72
- package/dist/UnderlineNav/UnderlineNavItem.module.css.js +5 -5
- package/dist/UnderlineNav/index.js +5 -7
- package/dist/UnderlineNav/styles.js +11 -15
- package/dist/VisuallyHidden/VisuallyHidden.js +51 -49
- package/dist/VisuallyHidden/VisuallyHidden.module.css.js +5 -5
- package/dist/_VisuallyHidden.js +50 -62
- 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 +43 -50
- package/dist/deprecated/ActionList/Header.js +69 -81
- package/dist/deprecated/ActionList/Header.module.css.js +5 -5
- package/dist/deprecated/ActionList/Item.js +308 -352
- package/dist/deprecated/ActionList/Item.module.css.js +18 -5
- package/dist/deprecated/ActionList/List.js +157 -196
- package/dist/deprecated/ActionList/List.module.css.js +5 -5
- package/dist/deprecated/ActionList/index.js +14 -14
- package/dist/deprecated/ActionMenu.js +159 -190
- package/dist/deprecated/DialogV1/Dialog.js +166 -200
- package/dist/deprecated/DialogV1/Dialog.module.css.js +11 -5
- package/dist/deprecated/FilteredSearch/FilteredSearch.js +43 -51
- package/dist/deprecated/FilteredSearch/FilteredSearch.module.css.js +5 -5
- package/dist/deprecated/UnderlineNav/UnderlineNav.js +132 -160
- package/dist/deprecated/UnderlineNav/UnderlineNav.module.css.js +14 -5
- package/dist/deprecated/index.js +20 -9
- package/dist/experimental/IssueLabel/IssueLabel.js +134 -158
- package/dist/experimental/IssueLabel/IssueLabel.module.css.js +5 -5
- package/dist/experimental/SelectPanel2/SelectPanel.js +419 -567
- package/dist/experimental/SelectPanel2/SelectPanel.module.css.js +32 -5
- package/dist/experimental/Tabs/Tabs.js +234 -297
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +165 -215
- package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +5 -5
- package/dist/experimental/index.js +44 -33
- package/dist/hooks/useAnchoredPosition.d.ts +0 -6
- package/dist/hooks/useAnchoredPosition.d.ts.map +1 -1
- package/dist/hooks/useAnchoredPosition.js +123 -130
- package/dist/hooks/useControllableState.js +34 -59
- package/dist/hooks/useDetails.js +84 -99
- package/dist/hooks/useDialog.js +140 -178
- package/dist/hooks/useFocusTrap.js +57 -71
- package/dist/hooks/useFocusZone.js +32 -38
- package/dist/hooks/useId.js +14 -16
- package/dist/hooks/useIsMacOS.js +21 -26
- package/dist/hooks/useMedia.js +54 -68
- package/dist/hooks/useMenuInitialFocus.js +65 -62
- package/dist/hooks/useMenuKeyboardNavigation.js +129 -126
- package/dist/hooks/useMergedRefs.js +63 -78
- package/dist/hooks/useMnemonics.js +77 -107
- package/dist/hooks/useOnEscapePress.js +45 -56
- package/dist/hooks/useOnOutsideClick.js +32 -63
- package/dist/hooks/useOpenAndCloseFocus.js +40 -43
- package/dist/hooks/useOverflow.js +32 -36
- package/dist/hooks/useOverlay.js +56 -75
- package/dist/hooks/useProvidedRefOrCreate.js +24 -24
- package/dist/hooks/useProvidedStateOrCreate.js +33 -39
- package/dist/hooks/useRefObjectAsForwardedRef.js +30 -32
- package/dist/hooks/useRenderForcingRef.js +42 -46
- package/dist/hooks/useResizeObserver.js +32 -43
- package/dist/hooks/useResponsiveValue.js +37 -57
- package/dist/hooks/useSafeTimeout.js +26 -29
- package/dist/hooks/useScrollFlash.js +16 -23
- package/dist/hooks/useSlots.js +102 -136
- package/dist/hooks/useSyncedState.js +31 -37
- package/dist/index.js +88 -85
- package/dist/internal/components/ButtonReset.js +45 -50
- package/dist/internal/components/ButtonReset.module.css.js +5 -5
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.js +79 -105
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.module.css.js +12 -5
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.js +16 -21
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupContext.js +4 -4
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.js +26 -35
- package/dist/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupValidation.js +14 -19
- package/dist/internal/components/ConditionalWrapper.js +41 -51
- package/dist/internal/components/InputLabel.js +92 -113
- package/dist/internal/components/InputLabel.module.css.js +8 -5
- package/dist/internal/components/InputValidation.js +67 -87
- package/dist/internal/components/InputValidation.module.css.js +9 -5
- package/dist/internal/components/TextInputInnerAction.js +134 -173
- package/dist/internal/components/TextInputInnerAction.module.css.js +9 -5
- package/dist/internal/components/TextInputInnerVisualSlot.js +89 -110
- package/dist/internal/components/TextInputInnerVisualSlot.module.css.js +11 -5
- package/dist/internal/components/TextInputWrapper.js +187 -230
- package/dist/internal/components/TextInputWrapper.module.css.js +8 -5
- package/dist/internal/components/UnderlineTabbedInterface.js +191 -238
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +11 -5
- package/dist/internal/components/UnstyledTextInput.js +40 -47
- package/dist/internal/components/UnstyledTextInput.module.css.js +5 -5
- package/dist/internal/components/ValidationAnimationContainer.js +55 -66
- package/dist/internal/components/ValidationAnimationContainer.module.css.js +8 -5
- package/dist/internal/hooks/useEffectCallback.js +35 -38
- package/dist/internal/hooks/useEffectOnce.js +23 -25
- package/dist/internal/utils/getResponsiveAttributes.js +23 -26
- package/dist/internal/utils/hasInteractiveNodes.js +34 -46
- package/dist/legacy-theme/ts/color-schemes.js +4250 -4732
- package/dist/live-region/Announce.js +144 -183
- package/dist/live-region/AriaAlert.js +20 -22
- package/dist/live-region/AriaStatus.js +20 -22
- package/dist/next/index.js +3 -1
- package/dist/test-helpers.js +40 -62
- package/dist/theme.js +83 -47
- package/dist/utils/character-counter.js +45 -63
- package/dist/utils/create-component.js +15 -16
- package/dist/utils/descendant-registry.js +182 -218
- package/dist/utils/environment.js +7 -7
- package/dist/utils/getBreakpointDeclarations.js +9 -10
- package/dist/utils/invariant.js +17 -23
- package/dist/utils/is-slot.js +10 -11
- package/dist/utils/isNumeric.js +3 -3
- package/dist/utils/modern-polymorphic.js +12 -20
- package/dist/utils/scroll.js +8 -11
- package/dist/utils/theme.js +5 -10
- package/dist/utils/useIsomorphicLayoutEffect.js +4 -9
- package/dist/utils/warning.js +14 -21
- package/generated/components.json +9 -9
- package/package.json +5 -10
|
@@ -1,591 +1,443 @@
|
|
|
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
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
const SelectPanelContext =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { useProvidedRefOrCreate } from "../../hooks/useProvidedRefOrCreate.js";
|
|
2
|
+
import { useAnchoredPosition } from "../../hooks/useAnchoredPosition.js";
|
|
3
|
+
import { useId as useId$1 } from "../../hooks/useId.js";
|
|
4
|
+
import Spinner from "../../Spinner/Spinner.js";
|
|
5
|
+
import { AriaStatus } from "../../live-region/AriaStatus.js";
|
|
6
|
+
import { invariant } from "../../utils/invariant.js";
|
|
7
|
+
import { IconButton } from "../../Button/IconButton.js";
|
|
8
|
+
import { ButtonComponent } from "../../Button/Button.js";
|
|
9
|
+
import { useResponsiveValue } from "../../hooks/useResponsiveValue.js";
|
|
10
|
+
import { isSlot } from "../../utils/is-slot.js";
|
|
11
|
+
import { useSlots } from "../../hooks/useSlots.js";
|
|
12
|
+
import { ActionListContainerContext } from "../../ActionList/ActionListContainerContext.js";
|
|
13
|
+
import Heading from "../../Heading/Heading.js";
|
|
14
|
+
import Link from "../../Link/Link.js";
|
|
15
|
+
import { BaseOverlay, heightMap } from "../../Overlay/Overlay.js";
|
|
16
|
+
import TextInput_default from "../../TextInput/TextInput.js";
|
|
17
|
+
import { useFormControlForwardedProps } from "../../FormControl/_FormControlContext.js";
|
|
18
|
+
import Checkbox from "../../Checkbox/Checkbox.js";
|
|
19
|
+
import Octicon from "../../Octicon/Octicon.js";
|
|
20
|
+
import { InputLabel } from "../../internal/components/InputLabel.js";
|
|
21
|
+
import SelectPanel_module_css_default from "./SelectPanel.module.css.js";
|
|
22
|
+
import { clsx } from "clsx";
|
|
23
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
import React, { useEffect, useState } from "react";
|
|
25
|
+
import { AlertIcon, ArrowLeftIcon, FilterRemoveIcon, SearchIcon, XCircleFillIcon, XIcon } from "@primer/octicons-react";
|
|
26
|
+
//#region src/experimental/SelectPanel2/SelectPanel.tsx
|
|
27
|
+
const SelectPanelContext = /* @__PURE__ */ React.createContext({
|
|
28
|
+
title: "",
|
|
29
|
+
description: void 0,
|
|
30
|
+
panelId: "",
|
|
31
|
+
onCancel: () => {},
|
|
32
|
+
onClearSelection: void 0,
|
|
33
|
+
searchQuery: "",
|
|
34
|
+
setSearchQuery: () => {},
|
|
35
|
+
selectionVariant: "multiple",
|
|
36
|
+
moveFocusToList: () => {}
|
|
37
37
|
});
|
|
38
38
|
const responsiveButtonSizes = {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
narrow: "medium",
|
|
40
|
+
regular: "small"
|
|
41
41
|
};
|
|
42
|
-
const Panel = ({
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
maxHeightValue = '100vh';
|
|
202
|
-
}
|
|
203
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
204
|
-
children: [Anchor, /*#__PURE__*/jsx(BaseOverlay, {
|
|
205
|
-
as: "dialog",
|
|
206
|
-
ref: dialogRef,
|
|
207
|
-
"aria-labelledby": `${panelId}--title`,
|
|
208
|
-
"aria-describedby": description ? `${panelId}--description` : undefined,
|
|
209
|
-
width: width,
|
|
210
|
-
height: "fit-content",
|
|
211
|
-
maxHeight: maxHeight,
|
|
212
|
-
"data-variant": currentVariant,
|
|
213
|
-
style: {
|
|
214
|
-
'--max-height': maxHeightValue,
|
|
215
|
-
'--position-top': `${(_position$top = position === null || position === void 0 ? void 0 : position.top) !== null && _position$top !== void 0 ? _position$top : 0}px`,
|
|
216
|
-
'--position-left': `${(_position$left = position === null || position === void 0 ? void 0 : position.left) !== null && _position$left !== void 0 ? _position$left : 0}px`,
|
|
217
|
-
visibility: internalOpen ? 'visible' : 'hidden',
|
|
218
|
-
display: 'flex'
|
|
219
|
-
},
|
|
220
|
-
className: clsx(classes.Overlay, className),
|
|
221
|
-
...props,
|
|
222
|
-
onClick: event => {
|
|
223
|
-
if (event.target === event.currentTarget) onClickOutside();
|
|
224
|
-
},
|
|
225
|
-
children: internalOpen && /*#__PURE__*/jsx(Fragment, {
|
|
226
|
-
children: /*#__PURE__*/jsx(SelectPanelContext.Provider, {
|
|
227
|
-
value: {
|
|
228
|
-
panelId,
|
|
229
|
-
title,
|
|
230
|
-
description,
|
|
231
|
-
onCancel: onInternalCancel,
|
|
232
|
-
onClearSelection: propsOnClearSelection ? onInternalClearSelection : undefined,
|
|
233
|
-
searchQuery,
|
|
234
|
-
setSearchQuery,
|
|
235
|
-
selectionVariant,
|
|
236
|
-
moveFocusToList
|
|
237
|
-
},
|
|
238
|
-
children: /*#__PURE__*/jsxs("form", {
|
|
239
|
-
method: "dialog",
|
|
240
|
-
onSubmit: onInternalSubmit,
|
|
241
|
-
className: classes.Form,
|
|
242
|
-
children: [(_slots$header = slots.header) !== null && _slots$header !== void 0 ? _slots$header :
|
|
243
|
-
/*#__PURE__*/
|
|
244
|
-
/* render default header as fallback */
|
|
245
|
-
jsx(SelectPanelHeader, {}), /*#__PURE__*/jsx("div", {
|
|
246
|
-
className: classes.Container,
|
|
247
|
-
children: /*#__PURE__*/jsx(ActionListContainerContext.Provider, {
|
|
248
|
-
value: {
|
|
249
|
-
container: 'SelectPanel',
|
|
250
|
-
listRole: 'listbox',
|
|
251
|
-
selectionAttribute: 'aria-selected',
|
|
252
|
-
selectionVariant: selectionVariant === 'instant' ? 'single' : selectionVariant,
|
|
253
|
-
afterSelect: internalAfterSelect,
|
|
254
|
-
listLabelledBy: `${panelId}--title`,
|
|
255
|
-
enableFocusZone: true // Arrow keys navigation for list items
|
|
256
|
-
},
|
|
257
|
-
children: childrenInBody
|
|
258
|
-
})
|
|
259
|
-
}), slots.footer]
|
|
260
|
-
})
|
|
261
|
-
})
|
|
262
|
-
})
|
|
263
|
-
})]
|
|
264
|
-
});
|
|
42
|
+
const Panel = ({ title, description, variant: propsVariant, selectionVariant = "multiple", id, defaultOpen = false, open: propsOpen, anchorRef: providedAnchorRef, anchoredPositionSettings, onCancel: propsOnCancel, onClearSelection: propsOnClearSelection, onSubmit: propsOnSubmit, width = "medium", maxHeight = "large", className, ...props }) => {
|
|
43
|
+
var _position$top, _position$left, _slots$header;
|
|
44
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
45
|
+
const currentVariant = useResponsiveValue(Object.assign({
|
|
46
|
+
regular: "anchored",
|
|
47
|
+
narrow: "full-screen"
|
|
48
|
+
}, typeof propsVariant === "string" ? { regular: propsVariant } : propsVariant), "anchored");
|
|
49
|
+
if (propsOpen !== void 0 && internalOpen !== propsOpen) setInternalOpen(propsOpen);
|
|
50
|
+
let Anchor;
|
|
51
|
+
const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
|
|
52
|
+
const onAnchorClick = () => {
|
|
53
|
+
if (!internalOpen) setInternalOpen(true);
|
|
54
|
+
else onInternalCancel();
|
|
55
|
+
};
|
|
56
|
+
const contents = React.Children.map(props.children, (child) => {
|
|
57
|
+
if (/* @__PURE__ */ React.isValidElement(child) && (child.type === SelectPanelButton || isSlot(child, SelectPanelButton))) {
|
|
58
|
+
Anchor = /* @__PURE__ */ React.cloneElement(child, {
|
|
59
|
+
ref: anchorRef,
|
|
60
|
+
onClick: child.props.onClick || onAnchorClick,
|
|
61
|
+
"aria-haspopup": true,
|
|
62
|
+
"aria-expanded": internalOpen
|
|
63
|
+
});
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return child;
|
|
67
|
+
});
|
|
68
|
+
const onInternalClose = React.useCallback(() => {
|
|
69
|
+
if (internalOpen === false) return;
|
|
70
|
+
if (propsOpen === void 0) setInternalOpen(false);
|
|
71
|
+
}, [internalOpen, propsOpen]);
|
|
72
|
+
const onInternalCancel = React.useCallback(() => {
|
|
73
|
+
onInternalClose();
|
|
74
|
+
if (typeof propsOnCancel === "function") propsOnCancel();
|
|
75
|
+
}, [onInternalClose, propsOnCancel]);
|
|
76
|
+
const onInternalSubmit = (event) => {
|
|
77
|
+
event === null || event === void 0 || event.preventDefault();
|
|
78
|
+
onInternalClose();
|
|
79
|
+
if (typeof propsOnSubmit === "function") propsOnSubmit(event);
|
|
80
|
+
};
|
|
81
|
+
const onInternalClearSelection = () => {
|
|
82
|
+
if (typeof propsOnClearSelection === "function") propsOnClearSelection();
|
|
83
|
+
};
|
|
84
|
+
const internalAfterSelect = (event) => {
|
|
85
|
+
if (selectionVariant === "instant") onInternalSubmit();
|
|
86
|
+
if (event.type === "keypress") {
|
|
87
|
+
if (event.key === "Enter") onInternalSubmit();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const [searchQuery, setSearchQuery] = React.useState("");
|
|
91
|
+
const panelId = useId$1(id);
|
|
92
|
+
const [slots, childrenInBody] = useSlots(contents, {
|
|
93
|
+
header: SelectPanelHeader,
|
|
94
|
+
footer: SelectPanelFooter
|
|
95
|
+
});
|
|
96
|
+
const moveFocusToList = () => {
|
|
97
|
+
var _dialogRef$current;
|
|
98
|
+
const firstListElement = (_dialogRef$current = dialogRef.current) === null || _dialogRef$current === void 0 ? void 0 : _dialogRef$current.querySelector("ul[role=listbox] li:not([role=none])");
|
|
99
|
+
firstListElement === null || firstListElement === void 0 || firstListElement.focus();
|
|
100
|
+
};
|
|
101
|
+
const dialogRef = React.useRef(null);
|
|
102
|
+
React.useEffect(() => {
|
|
103
|
+
var _dialogRef$current2, _dialogRef$current3;
|
|
104
|
+
if (internalOpen) (_dialogRef$current2 = dialogRef.current) === null || _dialogRef$current2 === void 0 || _dialogRef$current2.showModal();
|
|
105
|
+
else if ((_dialogRef$current3 = dialogRef.current) !== null && _dialogRef$current3 !== void 0 && _dialogRef$current3.open) dialogRef.current.close();
|
|
106
|
+
}, [internalOpen]);
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
const dialogEl = dialogRef.current;
|
|
109
|
+
dialogEl === null || dialogEl === void 0 || dialogEl.addEventListener("close", onInternalClose);
|
|
110
|
+
return () => dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.removeEventListener("close", onInternalClose);
|
|
111
|
+
}, [onInternalClose]);
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
const dialogEl = dialogRef.current;
|
|
114
|
+
const handler = (event) => {
|
|
115
|
+
if (event.key === "Escape") onInternalCancel();
|
|
116
|
+
};
|
|
117
|
+
dialogEl === null || dialogEl === void 0 || dialogEl.addEventListener("keydown", handler);
|
|
118
|
+
return () => dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.removeEventListener("keydown", handler);
|
|
119
|
+
}, [onInternalCancel]);
|
|
120
|
+
React.useEffect(function initialFocus() {
|
|
121
|
+
if (internalOpen) {
|
|
122
|
+
const searchInput = document.querySelector("dialog[open] input");
|
|
123
|
+
if (searchInput) searchInput.focus();
|
|
124
|
+
else moveFocusToList();
|
|
125
|
+
}
|
|
126
|
+
}, [internalOpen]);
|
|
127
|
+
const { position } = useAnchoredPosition({
|
|
128
|
+
anchorElementRef: anchorRef,
|
|
129
|
+
floatingElementRef: dialogRef,
|
|
130
|
+
side: "outside-bottom",
|
|
131
|
+
align: "start",
|
|
132
|
+
...anchoredPositionSettings
|
|
133
|
+
}, [
|
|
134
|
+
internalOpen,
|
|
135
|
+
anchorRef.current,
|
|
136
|
+
dialogRef.current
|
|
137
|
+
]);
|
|
138
|
+
const onClickOutside = onInternalCancel;
|
|
139
|
+
let maxHeightValue = heightMap[maxHeight];
|
|
140
|
+
if (currentVariant === "bottom-sheet") maxHeightValue = "calc(100vh - 64px)";
|
|
141
|
+
else if (currentVariant === "full-screen") maxHeightValue = "100vh";
|
|
142
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [Anchor, /* @__PURE__ */ jsx(BaseOverlay, {
|
|
143
|
+
as: "dialog",
|
|
144
|
+
ref: dialogRef,
|
|
145
|
+
"aria-labelledby": `${panelId}--title`,
|
|
146
|
+
"aria-describedby": description ? `${panelId}--description` : void 0,
|
|
147
|
+
width,
|
|
148
|
+
height: "fit-content",
|
|
149
|
+
maxHeight,
|
|
150
|
+
"data-variant": currentVariant,
|
|
151
|
+
style: {
|
|
152
|
+
"--max-height": maxHeightValue,
|
|
153
|
+
"--position-top": `${(_position$top = position === null || position === void 0 ? void 0 : position.top) !== null && _position$top !== void 0 ? _position$top : 0}px`,
|
|
154
|
+
"--position-left": `${(_position$left = position === null || position === void 0 ? void 0 : position.left) !== null && _position$left !== void 0 ? _position$left : 0}px`,
|
|
155
|
+
visibility: internalOpen ? "visible" : "hidden",
|
|
156
|
+
display: "flex"
|
|
157
|
+
},
|
|
158
|
+
className: clsx(SelectPanel_module_css_default.Overlay, className),
|
|
159
|
+
...props,
|
|
160
|
+
onClick: (event) => {
|
|
161
|
+
if (event.target === event.currentTarget) onClickOutside();
|
|
162
|
+
},
|
|
163
|
+
children: internalOpen && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(SelectPanelContext.Provider, {
|
|
164
|
+
value: {
|
|
165
|
+
panelId,
|
|
166
|
+
title,
|
|
167
|
+
description,
|
|
168
|
+
onCancel: onInternalCancel,
|
|
169
|
+
onClearSelection: propsOnClearSelection ? onInternalClearSelection : void 0,
|
|
170
|
+
searchQuery,
|
|
171
|
+
setSearchQuery,
|
|
172
|
+
selectionVariant,
|
|
173
|
+
moveFocusToList
|
|
174
|
+
},
|
|
175
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
176
|
+
method: "dialog",
|
|
177
|
+
onSubmit: onInternalSubmit,
|
|
178
|
+
className: SelectPanel_module_css_default.Form,
|
|
179
|
+
children: [
|
|
180
|
+
(_slots$header = slots.header) !== null && _slots$header !== void 0 ? _slots$header : /* @__PURE__ */ jsx(SelectPanelHeader, {}),
|
|
181
|
+
/* @__PURE__ */ jsx("div", {
|
|
182
|
+
className: SelectPanel_module_css_default.Container,
|
|
183
|
+
children: /* @__PURE__ */ jsx(ActionListContainerContext.Provider, {
|
|
184
|
+
value: {
|
|
185
|
+
container: "SelectPanel",
|
|
186
|
+
listRole: "listbox",
|
|
187
|
+
selectionAttribute: "aria-selected",
|
|
188
|
+
selectionVariant: selectionVariant === "instant" ? "single" : selectionVariant,
|
|
189
|
+
afterSelect: internalAfterSelect,
|
|
190
|
+
listLabelledBy: `${panelId}--title`,
|
|
191
|
+
enableFocusZone: true
|
|
192
|
+
},
|
|
193
|
+
children: childrenInBody
|
|
194
|
+
})
|
|
195
|
+
}),
|
|
196
|
+
slots.footer
|
|
197
|
+
]
|
|
198
|
+
})
|
|
199
|
+
}) })
|
|
200
|
+
})] });
|
|
265
201
|
};
|
|
266
|
-
const SelectPanelButton =
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
...inputProps
|
|
283
|
-
});
|
|
284
|
-
} else {
|
|
285
|
-
return /*#__PURE__*/jsx(ButtonComponent, {
|
|
286
|
-
ref: anchorRef,
|
|
287
|
-
...props
|
|
288
|
-
});
|
|
289
|
-
}
|
|
202
|
+
const SelectPanelButton = /* @__PURE__ */ React.forwardRef((props, anchorRef) => {
|
|
203
|
+
const inputProps = useFormControlForwardedProps(props);
|
|
204
|
+
const [labelText, setLabelText] = useState("");
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
const label = document.querySelector(`[for='${inputProps.id}']`);
|
|
207
|
+
if (label !== null && label !== void 0 && label.textContent) setLabelText(label.textContent);
|
|
208
|
+
}, [inputProps.id]);
|
|
209
|
+
if (labelText) return /* @__PURE__ */ jsx(ButtonComponent, {
|
|
210
|
+
ref: anchorRef,
|
|
211
|
+
"aria-label": `${anchorRef.current.textContent}, ${labelText}`,
|
|
212
|
+
...inputProps
|
|
213
|
+
});
|
|
214
|
+
else return /* @__PURE__ */ jsx(ButtonComponent, {
|
|
215
|
+
ref: anchorRef,
|
|
216
|
+
...props
|
|
217
|
+
});
|
|
290
218
|
});
|
|
291
|
-
SelectPanelButton.__SLOT__ = Symbol(
|
|
292
|
-
const SelectPanelHeader = ({
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
onClick: onClearSelection
|
|
345
|
-
}) : null, /*#__PURE__*/jsx(IconButton, {
|
|
346
|
-
type: "button",
|
|
347
|
-
variant: "invisible",
|
|
348
|
-
icon: XIcon,
|
|
349
|
-
"aria-label": "Close",
|
|
350
|
-
onClick: () => onCancel()
|
|
351
|
-
})]
|
|
352
|
-
})]
|
|
353
|
-
}), slots.searchInput, childrenWithoutSlots]
|
|
354
|
-
});
|
|
219
|
+
SelectPanelButton.__SLOT__ = Symbol("SelectPanel.Button");
|
|
220
|
+
const SelectPanelHeader = ({ children, onBack, className, ...props }) => {
|
|
221
|
+
const [slots, childrenWithoutSlots] = useSlots(children, { searchInput: SelectPanelSearchInput });
|
|
222
|
+
const { title, description, panelId, onCancel, onClearSelection } = React.useContext(SelectPanelContext);
|
|
223
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
224
|
+
className: clsx(SelectPanel_module_css_default.Header, className),
|
|
225
|
+
...props,
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: SelectPanel_module_css_default.HeaderContent,
|
|
229
|
+
"data-description": description ? true : void 0,
|
|
230
|
+
"data-search-input": slots.searchInput ? true : void 0,
|
|
231
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
232
|
+
className: SelectPanel_module_css_default.FlexBox,
|
|
233
|
+
children: [onBack ? /* @__PURE__ */ jsx(IconButton, {
|
|
234
|
+
type: "button",
|
|
235
|
+
variant: "invisible",
|
|
236
|
+
icon: ArrowLeftIcon,
|
|
237
|
+
"aria-label": "Back",
|
|
238
|
+
onClick: () => onBack()
|
|
239
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
240
|
+
className: SelectPanel_module_css_default.TitleWrapper,
|
|
241
|
+
"data-description": description ? true : void 0,
|
|
242
|
+
"data-on-back": onBack ? true : void 0,
|
|
243
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
244
|
+
as: "h1",
|
|
245
|
+
id: `${panelId}--title`,
|
|
246
|
+
className: SelectPanel_module_css_default.Title,
|
|
247
|
+
children: title
|
|
248
|
+
}), description ? /* @__PURE__ */ jsx("span", {
|
|
249
|
+
id: `${panelId}--description`,
|
|
250
|
+
className: SelectPanel_module_css_default.Description,
|
|
251
|
+
children: description
|
|
252
|
+
}) : null]
|
|
253
|
+
})]
|
|
254
|
+
}), /* @__PURE__ */ jsxs("div", { children: [onClearSelection ? /* @__PURE__ */ jsx(IconButton, {
|
|
255
|
+
type: "button",
|
|
256
|
+
variant: "invisible",
|
|
257
|
+
icon: FilterRemoveIcon,
|
|
258
|
+
"aria-label": "Clear selection",
|
|
259
|
+
onClick: onClearSelection
|
|
260
|
+
}) : null, /* @__PURE__ */ jsx(IconButton, {
|
|
261
|
+
type: "button",
|
|
262
|
+
variant: "invisible",
|
|
263
|
+
icon: XIcon,
|
|
264
|
+
"aria-label": "Close",
|
|
265
|
+
onClick: () => onCancel()
|
|
266
|
+
})] })]
|
|
267
|
+
}),
|
|
268
|
+
slots.searchInput,
|
|
269
|
+
childrenWithoutSlots
|
|
270
|
+
]
|
|
271
|
+
});
|
|
355
272
|
};
|
|
356
273
|
SelectPanelHeader.displayName = "SelectPanelHeader";
|
|
357
|
-
SelectPanelHeader.__SLOT__ = Symbol(
|
|
358
|
-
const SelectPanelSearchInput = ({
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
// @ts-ignore TODO this is a hacky solution to clear
|
|
396
|
-
propsOnChange({
|
|
397
|
-
target: inputRef.current,
|
|
398
|
-
currentTarget: inputRef.current
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}),
|
|
403
|
-
className: clsx(classes.TextInput, className),
|
|
404
|
-
onChange: internalOnChange,
|
|
405
|
-
onKeyDown: internalKeyDown,
|
|
406
|
-
...props
|
|
407
|
-
});
|
|
274
|
+
SelectPanelHeader.__SLOT__ = Symbol("SelectPanel.Header");
|
|
275
|
+
const SelectPanelSearchInput = ({ onChange: propsOnChange, onKeyDown: propsOnKeyDown, className, ...props }) => {
|
|
276
|
+
const inputRef = /* @__PURE__ */ React.createRef();
|
|
277
|
+
const { setSearchQuery, moveFocusToList } = React.useContext(SelectPanelContext);
|
|
278
|
+
const internalOnChange = (event) => {
|
|
279
|
+
if (typeof propsOnChange === "function") propsOnChange(event);
|
|
280
|
+
else setSearchQuery(event.target.value);
|
|
281
|
+
};
|
|
282
|
+
const internalKeyDown = (event) => {
|
|
283
|
+
if (event.key === "ArrowDown") {
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
moveFocusToList();
|
|
286
|
+
}
|
|
287
|
+
if (typeof propsOnKeyDown === "function") propsOnKeyDown(event);
|
|
288
|
+
};
|
|
289
|
+
return /* @__PURE__ */ jsx(TextInput_default, {
|
|
290
|
+
ref: inputRef,
|
|
291
|
+
block: true,
|
|
292
|
+
leadingVisual: SearchIcon,
|
|
293
|
+
placeholder: "Search",
|
|
294
|
+
trailingAction: /* @__PURE__ */ jsx(TextInput_default.Action, {
|
|
295
|
+
icon: XCircleFillIcon,
|
|
296
|
+
"aria-label": "Clear",
|
|
297
|
+
tooltipDirection: "w",
|
|
298
|
+
className: SelectPanel_module_css_default.ClearAction,
|
|
299
|
+
onClick: () => {
|
|
300
|
+
if (inputRef.current) inputRef.current.value = "";
|
|
301
|
+
if (typeof propsOnChange === "function") propsOnChange({
|
|
302
|
+
target: inputRef.current,
|
|
303
|
+
currentTarget: inputRef.current
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}),
|
|
307
|
+
className: clsx(SelectPanel_module_css_default.TextInput, className),
|
|
308
|
+
onChange: internalOnChange,
|
|
309
|
+
onKeyDown: internalKeyDown,
|
|
310
|
+
...props
|
|
311
|
+
});
|
|
408
312
|
};
|
|
409
313
|
SelectPanelSearchInput.displayName = "SelectPanelSearchInput";
|
|
410
|
-
SelectPanelSearchInput.__SLOT__ = Symbol(
|
|
411
|
-
const FooterContext =
|
|
412
|
-
const SelectPanelFooter = ({
|
|
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
|
-
}), /*#__PURE__*/jsx(ButtonComponent, {
|
|
443
|
-
type: "submit",
|
|
444
|
-
size: buttonSize,
|
|
445
|
-
variant: "primary",
|
|
446
|
-
children: "Save"
|
|
447
|
-
})]
|
|
448
|
-
})]
|
|
449
|
-
})
|
|
450
|
-
});
|
|
314
|
+
SelectPanelSearchInput.__SLOT__ = Symbol("SelectPanel.SearchInput");
|
|
315
|
+
const FooterContext = /* @__PURE__ */ React.createContext(false);
|
|
316
|
+
const SelectPanelFooter = ({ ...props }) => {
|
|
317
|
+
const { onCancel, selectionVariant } = React.useContext(SelectPanelContext);
|
|
318
|
+
const hidePrimaryActions = selectionVariant === "instant";
|
|
319
|
+
const buttonSize = useResponsiveValue(responsiveButtonSizes, "small");
|
|
320
|
+
if (hidePrimaryActions && !props.children) return null;
|
|
321
|
+
return /* @__PURE__ */ jsx(FooterContext.Provider, {
|
|
322
|
+
value: true,
|
|
323
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
324
|
+
className: SelectPanel_module_css_default.Footer,
|
|
325
|
+
"data-hide-primary-actions": hidePrimaryActions || void 0,
|
|
326
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
327
|
+
className: SelectPanel_module_css_default.FooterContent,
|
|
328
|
+
"data-hide-primary-actions": hidePrimaryActions || void 0,
|
|
329
|
+
children: props.children
|
|
330
|
+
}), hidePrimaryActions ? null : /* @__PURE__ */ jsxs("div", {
|
|
331
|
+
className: SelectPanel_module_css_default.FooterActions,
|
|
332
|
+
children: [/* @__PURE__ */ jsx(ButtonComponent, {
|
|
333
|
+
type: "button",
|
|
334
|
+
size: buttonSize,
|
|
335
|
+
onClick: () => onCancel(),
|
|
336
|
+
children: "Cancel"
|
|
337
|
+
}), /* @__PURE__ */ jsx(ButtonComponent, {
|
|
338
|
+
type: "submit",
|
|
339
|
+
size: buttonSize,
|
|
340
|
+
variant: "primary",
|
|
341
|
+
children: "Save"
|
|
342
|
+
})]
|
|
343
|
+
})]
|
|
344
|
+
})
|
|
345
|
+
});
|
|
451
346
|
};
|
|
452
347
|
SelectPanelFooter.displayName = "SelectPanelFooter";
|
|
453
|
-
SelectPanelFooter.__SLOT__ = Symbol(
|
|
454
|
-
const SecondaryButton = props => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
});
|
|
348
|
+
SelectPanelFooter.__SLOT__ = Symbol("SelectPanel.Footer");
|
|
349
|
+
const SecondaryButton = (props) => {
|
|
350
|
+
return /* @__PURE__ */ jsx(ButtonComponent, {
|
|
351
|
+
type: "button",
|
|
352
|
+
size: useResponsiveValue(responsiveButtonSizes, "small"),
|
|
353
|
+
block: true,
|
|
354
|
+
...props
|
|
355
|
+
});
|
|
462
356
|
};
|
|
463
357
|
SecondaryButton.displayName = "SecondaryButton";
|
|
464
|
-
const SecondaryLink = ({
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
size: size,
|
|
475
|
-
variant: "invisible",
|
|
476
|
-
block: true,
|
|
477
|
-
...props,
|
|
478
|
-
className: clsx(classes.SmallText, className),
|
|
479
|
-
children: props.children
|
|
480
|
-
})
|
|
481
|
-
);
|
|
358
|
+
const SecondaryLink = ({ className, ...props }) => {
|
|
359
|
+
return /* @__PURE__ */ jsx(ButtonComponent, {
|
|
360
|
+
as: Link,
|
|
361
|
+
size: useResponsiveValue(responsiveButtonSizes, "small"),
|
|
362
|
+
variant: "invisible",
|
|
363
|
+
block: true,
|
|
364
|
+
...props,
|
|
365
|
+
className: clsx(SelectPanel_module_css_default.SmallText, className),
|
|
366
|
+
children: props.children
|
|
367
|
+
});
|
|
482
368
|
};
|
|
483
369
|
SecondaryLink.displayName = "SecondaryLink";
|
|
484
|
-
const SecondaryCheckbox = ({
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
id: checkboxId,
|
|
501
|
-
className: clsx(classes.Checkbox, className),
|
|
502
|
-
...props
|
|
503
|
-
}), /*#__PURE__*/jsx(InputLabel, {
|
|
504
|
-
htmlFor: checkboxId,
|
|
505
|
-
className: classes.SmallText,
|
|
506
|
-
children: children
|
|
507
|
-
})]
|
|
508
|
-
});
|
|
370
|
+
const SecondaryCheckbox = ({ id, children, className, ...props }) => {
|
|
371
|
+
const checkboxId = useId$1(id);
|
|
372
|
+
const { selectionVariant } = React.useContext(SelectPanelContext);
|
|
373
|
+
!(selectionVariant !== "instant") && invariant(false, "Sorry! SelectPanel.SecondaryAction with variant=\"checkbox\" is not allowed inside selectionVariant=\"instant\"");
|
|
374
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
375
|
+
className: SelectPanel_module_css_default.SecondaryCheckbox,
|
|
376
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
377
|
+
id: checkboxId,
|
|
378
|
+
className: clsx(SelectPanel_module_css_default.Checkbox, className),
|
|
379
|
+
...props
|
|
380
|
+
}), /* @__PURE__ */ jsx(InputLabel, {
|
|
381
|
+
htmlFor: checkboxId,
|
|
382
|
+
className: SelectPanel_module_css_default.SmallText,
|
|
383
|
+
children
|
|
384
|
+
})]
|
|
385
|
+
});
|
|
509
386
|
};
|
|
510
387
|
SecondaryCheckbox.displayName = "SecondaryCheckbox";
|
|
511
|
-
const SelectPanelSecondaryAction = ({
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
!insideFooter ? process.env.NODE_ENV !== "production" ? invariant(false, 'SelectPanel.SecondaryAction is only allowed inside SelectPanel.Footer') : invariant(false) : void 0;
|
|
517
|
-
|
|
518
|
-
// @ts-ignore TODO
|
|
519
|
-
if (variant === 'button') return /*#__PURE__*/jsx(SecondaryButton, {
|
|
520
|
-
...props
|
|
521
|
-
});
|
|
522
|
-
// @ts-ignore TODO
|
|
523
|
-
else if (variant === 'link') return /*#__PURE__*/jsx(SecondaryLink, {
|
|
524
|
-
...props
|
|
525
|
-
});
|
|
526
|
-
// @ts-ignore TODO
|
|
527
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
528
|
-
else if (variant === 'checkbox') return /*#__PURE__*/jsx(SecondaryCheckbox, {
|
|
529
|
-
...props
|
|
530
|
-
});
|
|
388
|
+
const SelectPanelSecondaryAction = ({ variant, ...props }) => {
|
|
389
|
+
!React.useContext(FooterContext) && invariant(false, "SelectPanel.SecondaryAction is only allowed inside SelectPanel.Footer");
|
|
390
|
+
if (variant === "button") return /* @__PURE__ */ jsx(SecondaryButton, { ...props });
|
|
391
|
+
else if (variant === "link") return /* @__PURE__ */ jsx(SecondaryLink, { ...props });
|
|
392
|
+
else if (variant === "checkbox") return /* @__PURE__ */ jsx(SecondaryCheckbox, { ...props });
|
|
531
393
|
};
|
|
532
|
-
const SelectPanelLoading = ({
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
})]
|
|
545
|
-
});
|
|
394
|
+
const SelectPanelLoading = ({ children = "Fetching items..." }) => {
|
|
395
|
+
return /* @__PURE__ */ jsxs(AriaStatus, {
|
|
396
|
+
announceOnShow: true,
|
|
397
|
+
className: SelectPanel_module_css_default.SelectPanelLoading,
|
|
398
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
399
|
+
size: "medium",
|
|
400
|
+
srText: null
|
|
401
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
402
|
+
className: SelectPanel_module_css_default.LoadingText,
|
|
403
|
+
children
|
|
404
|
+
})]
|
|
405
|
+
});
|
|
546
406
|
};
|
|
547
407
|
SelectPanelLoading.displayName = "SelectPanelLoading";
|
|
548
|
-
const SelectPanelMessage = ({
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
"data-variant": variant,
|
|
573
|
-
children: [/*#__PURE__*/jsx(AlertIcon, {
|
|
574
|
-
size: 16
|
|
575
|
-
}), /*#__PURE__*/jsx("div", {
|
|
576
|
-
children: children
|
|
577
|
-
})]
|
|
578
|
-
});
|
|
579
|
-
}
|
|
408
|
+
const SelectPanelMessage = ({ variant = "warning", size = variant === "empty" ? "full" : "inline", title, children }) => {
|
|
409
|
+
const MessageWrapper = variant === "empty" ? "div" : AriaStatus;
|
|
410
|
+
if (size === "full") return /* @__PURE__ */ jsxs(MessageWrapper, {
|
|
411
|
+
className: SelectPanel_module_css_default.MessageFull,
|
|
412
|
+
children: [
|
|
413
|
+
variant !== "empty" ? /* @__PURE__ */ jsx(Octicon, {
|
|
414
|
+
icon: AlertIcon,
|
|
415
|
+
className: clsx(SelectPanel_module_css_default.Octicon, variant === "error" ? SelectPanel_module_css_default.Error : void 0, variant === "warning" ? SelectPanel_module_css_default.Warning : void 0)
|
|
416
|
+
}) : null,
|
|
417
|
+
/* @__PURE__ */ jsx("span", {
|
|
418
|
+
className: SelectPanel_module_css_default.MessageTitle,
|
|
419
|
+
children: title
|
|
420
|
+
}),
|
|
421
|
+
/* @__PURE__ */ jsx("span", {
|
|
422
|
+
className: SelectPanel_module_css_default.MessageContent,
|
|
423
|
+
children
|
|
424
|
+
})
|
|
425
|
+
]
|
|
426
|
+
});
|
|
427
|
+
else return /* @__PURE__ */ jsxs(MessageWrapper, {
|
|
428
|
+
className: SelectPanel_module_css_default.MessageInline,
|
|
429
|
+
"data-variant": variant,
|
|
430
|
+
children: [/* @__PURE__ */ jsx(AlertIcon, { size: 16 }), /* @__PURE__ */ jsx("div", { children })]
|
|
431
|
+
});
|
|
580
432
|
};
|
|
581
433
|
const SelectPanel = Object.assign(Panel, {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
434
|
+
Button: SelectPanelButton,
|
|
435
|
+
Header: SelectPanelHeader,
|
|
436
|
+
SearchInput: SelectPanelSearchInput,
|
|
437
|
+
Footer: SelectPanelFooter,
|
|
438
|
+
Loading: SelectPanelLoading,
|
|
439
|
+
Message: SelectPanelMessage,
|
|
440
|
+
SecondaryAction: SelectPanelSecondaryAction
|
|
589
441
|
});
|
|
590
|
-
|
|
442
|
+
//#endregion
|
|
591
443
|
export { SelectPanel };
|