@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,443 +1,591 @@
|
|
|
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 React, { useState, useEffect } from 'react';
|
|
2
|
+
import { AlertIcon, SearchIcon, XCircleFillIcon, ArrowLeftIcon, FilterRemoveIcon, XIcon } from '@primer/octicons-react';
|
|
3
|
+
import { ActionListContainerContext } from '../../ActionList/ActionListContainerContext.js';
|
|
4
|
+
import { useSlots } from '../../hooks/useSlots.js';
|
|
5
|
+
import { BaseOverlay, heightMap } from '../../Overlay/Overlay.js';
|
|
6
|
+
import { InputLabel } from '../../internal/components/InputLabel.js';
|
|
7
|
+
import { invariant } from '../../utils/invariant.js';
|
|
8
|
+
import { useResponsiveValue } from '../../hooks/useResponsiveValue.js';
|
|
9
|
+
import { clsx } from 'clsx';
|
|
10
|
+
import classes from './SelectPanel.module.css.js';
|
|
11
|
+
import { isSlot } from '../../utils/is-slot.js';
|
|
12
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
13
|
+
import { useProvidedRefOrCreate } from '../../hooks/useProvidedRefOrCreate.js';
|
|
14
|
+
import { useId } from '../../hooks/useId.js';
|
|
15
|
+
import { useAnchoredPosition } from '../../hooks/useAnchoredPosition.js';
|
|
16
|
+
import { AriaStatus } from '../../live-region/AriaStatus.js';
|
|
17
|
+
import Octicon from '../../Octicon/Octicon.js';
|
|
18
|
+
import Spinner from '../../Spinner/Spinner.js';
|
|
19
|
+
import { ButtonComponent } from '../../Button/Button.js';
|
|
20
|
+
import TextInput from '../../TextInput/TextInput.js';
|
|
21
|
+
import { IconButton } from '../../Button/IconButton.js';
|
|
22
|
+
import Heading from '../../Heading/Heading.js';
|
|
23
|
+
import { useFormControlForwardedProps } from '../../FormControl/_FormControlContext.js';
|
|
24
|
+
import Link from '../../Link/Link.js';
|
|
25
|
+
import Checkbox from '../../Checkbox/Checkbox.js';
|
|
26
|
+
|
|
27
|
+
const SelectPanelContext = /*#__PURE__*/React.createContext({
|
|
28
|
+
title: '',
|
|
29
|
+
description: undefined,
|
|
30
|
+
panelId: '',
|
|
31
|
+
onCancel: () => {},
|
|
32
|
+
onClearSelection: undefined,
|
|
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
|
-
|
|
42
|
+
const Panel = ({
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
variant: propsVariant,
|
|
46
|
+
selectionVariant = 'multiple',
|
|
47
|
+
id,
|
|
48
|
+
defaultOpen = false,
|
|
49
|
+
open: propsOpen,
|
|
50
|
+
anchorRef: providedAnchorRef,
|
|
51
|
+
anchoredPositionSettings,
|
|
52
|
+
onCancel: propsOnCancel,
|
|
53
|
+
onClearSelection: propsOnClearSelection,
|
|
54
|
+
onSubmit: propsOnSubmit,
|
|
55
|
+
width = 'medium',
|
|
56
|
+
maxHeight = 'large',
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}) => {
|
|
60
|
+
var _position$top, _position$left, _slots$header;
|
|
61
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
|
|
62
|
+
const responsiveVariants = Object.assign({
|
|
63
|
+
regular: 'anchored',
|
|
64
|
+
narrow: 'full-screen'
|
|
65
|
+
},
|
|
66
|
+
// defaults
|
|
67
|
+
typeof propsVariant === 'string' ? {
|
|
68
|
+
regular: propsVariant
|
|
69
|
+
} : propsVariant);
|
|
70
|
+
const currentVariant = useResponsiveValue(responsiveVariants, 'anchored');
|
|
71
|
+
|
|
72
|
+
// sync open state with props
|
|
73
|
+
if (propsOpen !== undefined && internalOpen !== propsOpen) setInternalOpen(propsOpen);
|
|
74
|
+
|
|
75
|
+
// TODO: replace this hack with clone element?
|
|
76
|
+
|
|
77
|
+
// 🚨 Hack for good API!
|
|
78
|
+
// we strip out Anchor from children and wire it up to Dialog
|
|
79
|
+
// with additional props for accessibility
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
let Anchor;
|
|
82
|
+
const anchorRef = useProvidedRefOrCreate(providedAnchorRef);
|
|
83
|
+
const onAnchorClick = () => {
|
|
84
|
+
if (!internalOpen) setInternalOpen(true);else onInternalCancel();
|
|
85
|
+
};
|
|
86
|
+
const contents = React.Children.map(props.children, child => {
|
|
87
|
+
if (/*#__PURE__*/React.isValidElement(child) && (child.type === SelectPanelButton || isSlot(child, SelectPanelButton))) {
|
|
88
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
89
|
+
Anchor = /*#__PURE__*/React.cloneElement(child, {
|
|
90
|
+
// @ts-ignore TODO
|
|
91
|
+
ref: anchorRef,
|
|
92
|
+
onClick: child.props.onClick || onAnchorClick,
|
|
93
|
+
'aria-haspopup': true,
|
|
94
|
+
'aria-expanded': internalOpen
|
|
95
|
+
});
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return child;
|
|
99
|
+
});
|
|
100
|
+
const onInternalClose = React.useCallback(() => {
|
|
101
|
+
if (internalOpen === false) return; // nothing to do here
|
|
102
|
+
if (propsOpen === undefined) setInternalOpen(false);
|
|
103
|
+
}, [internalOpen, propsOpen]);
|
|
104
|
+
const onInternalCancel = React.useCallback(() => {
|
|
105
|
+
onInternalClose();
|
|
106
|
+
if (typeof propsOnCancel === 'function') propsOnCancel();
|
|
107
|
+
}, [onInternalClose, propsOnCancel]);
|
|
108
|
+
const onInternalSubmit = event => {
|
|
109
|
+
event === null || event === void 0 ? void 0 : event.preventDefault(); // there is no event with selectionVariant=instant
|
|
110
|
+
onInternalClose();
|
|
111
|
+
if (typeof propsOnSubmit === 'function') propsOnSubmit(event);
|
|
112
|
+
};
|
|
113
|
+
const onInternalClearSelection = () => {
|
|
114
|
+
if (typeof propsOnClearSelection === 'function') propsOnClearSelection();
|
|
115
|
+
};
|
|
116
|
+
const internalAfterSelect = event => {
|
|
117
|
+
if (selectionVariant === 'instant') onInternalSubmit();
|
|
118
|
+
if (event.type === 'keypress') {
|
|
119
|
+
if (event.key === 'Enter') onInternalSubmit();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/* Search/Filter */
|
|
124
|
+
const [searchQuery, setSearchQuery] = React.useState('');
|
|
125
|
+
|
|
126
|
+
/* Panel plumbing */
|
|
127
|
+
const panelId = useId(id);
|
|
128
|
+
const [slots, childrenInBody] = useSlots(contents, {
|
|
129
|
+
header: SelectPanelHeader,
|
|
130
|
+
footer: SelectPanelFooter
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// used in SelectPanel.SearchInput
|
|
134
|
+
const moveFocusToList = () => {
|
|
135
|
+
var _dialogRef$current;
|
|
136
|
+
const selector = 'ul[role=listbox] li:not([role=none])';
|
|
137
|
+
// being specific about roles because there can be another ul (tabs in header) and an ActionList.Group (li[role=none])
|
|
138
|
+
const firstListElement = (_dialogRef$current = dialogRef.current) === null || _dialogRef$current === void 0 ? void 0 : _dialogRef$current.querySelector(selector);
|
|
139
|
+
firstListElement === null || firstListElement === void 0 ? void 0 : firstListElement.focus();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/* Dialog */
|
|
143
|
+
const dialogRef = React.useRef(null);
|
|
144
|
+
|
|
145
|
+
// sync dialog open state (imperative) with internal component state
|
|
146
|
+
React.useEffect(() => {
|
|
147
|
+
var _dialogRef$current2, _dialogRef$current3;
|
|
148
|
+
if (internalOpen) (_dialogRef$current2 = dialogRef.current) === null || _dialogRef$current2 === void 0 ? void 0 : _dialogRef$current2.showModal();else if ((_dialogRef$current3 = dialogRef.current) !== null && _dialogRef$current3 !== void 0 && _dialogRef$current3.open) dialogRef.current.close();
|
|
149
|
+
}, [internalOpen]);
|
|
150
|
+
|
|
151
|
+
// dialog handles Esc automatically, so we have to sync internal state
|
|
152
|
+
// but it doesn't call onCancel, so have another effect for that!
|
|
153
|
+
React.useEffect(() => {
|
|
154
|
+
const dialogEl = dialogRef.current;
|
|
155
|
+
dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.addEventListener('close', onInternalClose);
|
|
156
|
+
return () => dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.removeEventListener('close', onInternalClose);
|
|
157
|
+
}, [onInternalClose]);
|
|
158
|
+
|
|
159
|
+
// Esc handler
|
|
160
|
+
React.useEffect(() => {
|
|
161
|
+
const dialogEl = dialogRef.current;
|
|
162
|
+
const handler = event => {
|
|
163
|
+
if (event.key === 'Escape') onInternalCancel();
|
|
164
|
+
};
|
|
165
|
+
dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.addEventListener('keydown', handler);
|
|
166
|
+
return () => dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.removeEventListener('keydown', handler);
|
|
167
|
+
}, [onInternalCancel]);
|
|
168
|
+
|
|
169
|
+
// Autofocus hack: React doesn't support autoFocus for dialog: https://github.com/facebook/react/issues/23301
|
|
170
|
+
// tl;dr: react takes over autofocus instead of letting the browser handle it,
|
|
171
|
+
// but not for dialogs, so we have to do it
|
|
172
|
+
React.useEffect(function initialFocus() {
|
|
173
|
+
if (internalOpen) {
|
|
174
|
+
const searchInput = document.querySelector('dialog[open] input');
|
|
175
|
+
if (searchInput) searchInput.focus();else moveFocusToList();
|
|
176
|
+
}
|
|
177
|
+
}, [internalOpen]);
|
|
178
|
+
|
|
179
|
+
/* Anchored */
|
|
180
|
+
const {
|
|
181
|
+
position
|
|
182
|
+
} = useAnchoredPosition({
|
|
183
|
+
anchorElementRef: anchorRef,
|
|
184
|
+
floatingElementRef: dialogRef,
|
|
185
|
+
side: 'outside-bottom',
|
|
186
|
+
align: 'start',
|
|
187
|
+
...anchoredPositionSettings
|
|
188
|
+
},
|
|
189
|
+
// eslint-disable-next-line react-hooks/refs
|
|
190
|
+
[internalOpen, anchorRef.current, dialogRef.current]);
|
|
191
|
+
|
|
192
|
+
/*
|
|
193
|
+
We want to cancel and close the panel when user clicks outside.
|
|
194
|
+
See decision log: https://github.com/github/primer/discussions/2614#discussioncomment-8544561
|
|
195
|
+
*/
|
|
196
|
+
const onClickOutside = onInternalCancel;
|
|
197
|
+
let maxHeightValue = heightMap[maxHeight];
|
|
198
|
+
if (currentVariant === 'bottom-sheet') {
|
|
199
|
+
maxHeightValue = 'calc(100vh - 64px)';
|
|
200
|
+
} else if (currentVariant === 'full-screen') {
|
|
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
|
+
});
|
|
201
265
|
};
|
|
202
|
-
const SelectPanelButton =
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
266
|
+
const SelectPanelButton = /*#__PURE__*/React.forwardRef((props, anchorRef) => {
|
|
267
|
+
const inputProps = useFormControlForwardedProps(props);
|
|
268
|
+
const [labelText, setLabelText] = useState('');
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
const label = document.querySelector(`[for='${inputProps.id}']`);
|
|
271
|
+
if (label !== null && label !== void 0 && label.textContent) {
|
|
272
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
273
|
+
setLabelText(label.textContent);
|
|
274
|
+
}
|
|
275
|
+
}, [inputProps.id]);
|
|
276
|
+
if (labelText) {
|
|
277
|
+
return /*#__PURE__*/jsx(ButtonComponent, {
|
|
278
|
+
ref: anchorRef
|
|
279
|
+
// eslint-disable-next-line react-hooks/refs
|
|
280
|
+
,
|
|
281
|
+
"aria-label": `${anchorRef.current.textContent}, ${labelText}`,
|
|
282
|
+
...inputProps
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
return /*#__PURE__*/jsx(ButtonComponent, {
|
|
286
|
+
ref: anchorRef,
|
|
287
|
+
...props
|
|
288
|
+
});
|
|
289
|
+
}
|
|
218
290
|
});
|
|
219
|
-
SelectPanelButton.__SLOT__ = Symbol(
|
|
220
|
-
const SelectPanelHeader = ({
|
|
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
|
-
|
|
291
|
+
SelectPanelButton.__SLOT__ = Symbol('SelectPanel.Button');
|
|
292
|
+
const SelectPanelHeader = ({
|
|
293
|
+
children,
|
|
294
|
+
onBack,
|
|
295
|
+
className,
|
|
296
|
+
...props
|
|
297
|
+
}) => {
|
|
298
|
+
const [slots, childrenWithoutSlots] = useSlots(children, {
|
|
299
|
+
searchInput: SelectPanelSearchInput
|
|
300
|
+
});
|
|
301
|
+
const {
|
|
302
|
+
title,
|
|
303
|
+
description,
|
|
304
|
+
panelId,
|
|
305
|
+
onCancel,
|
|
306
|
+
onClearSelection
|
|
307
|
+
} = React.useContext(SelectPanelContext);
|
|
308
|
+
return /*#__PURE__*/jsxs("div", {
|
|
309
|
+
className: clsx(classes.Header, className),
|
|
310
|
+
...props,
|
|
311
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
312
|
+
className: classes.HeaderContent,
|
|
313
|
+
"data-description": description ? true : undefined,
|
|
314
|
+
"data-search-input": slots.searchInput ? true : undefined,
|
|
315
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
316
|
+
className: classes.FlexBox,
|
|
317
|
+
children: [onBack ? /*#__PURE__*/jsx(IconButton, {
|
|
318
|
+
type: "button",
|
|
319
|
+
variant: "invisible",
|
|
320
|
+
icon: ArrowLeftIcon,
|
|
321
|
+
"aria-label": "Back",
|
|
322
|
+
onClick: () => onBack()
|
|
323
|
+
}) : null, /*#__PURE__*/jsxs("div", {
|
|
324
|
+
className: classes.TitleWrapper,
|
|
325
|
+
"data-description": description ? true : undefined,
|
|
326
|
+
"data-on-back": onBack ? true : undefined,
|
|
327
|
+
children: [/*#__PURE__*/jsx(Heading, {
|
|
328
|
+
as: "h1",
|
|
329
|
+
id: `${panelId}--title`,
|
|
330
|
+
className: classes.Title,
|
|
331
|
+
children: title
|
|
332
|
+
}), description ? /*#__PURE__*/jsx("span", {
|
|
333
|
+
id: `${panelId}--description`,
|
|
334
|
+
className: classes.Description,
|
|
335
|
+
children: description
|
|
336
|
+
}) : null]
|
|
337
|
+
})]
|
|
338
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
339
|
+
children: [onClearSelection ? /*#__PURE__*/jsx(IconButton, {
|
|
340
|
+
type: "button",
|
|
341
|
+
variant: "invisible",
|
|
342
|
+
icon: FilterRemoveIcon,
|
|
343
|
+
"aria-label": "Clear selection",
|
|
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
|
+
});
|
|
272
355
|
};
|
|
273
356
|
SelectPanelHeader.displayName = "SelectPanelHeader";
|
|
274
|
-
SelectPanelHeader.__SLOT__ = Symbol(
|
|
275
|
-
const SelectPanelSearchInput = ({
|
|
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
|
-
|
|
357
|
+
SelectPanelHeader.__SLOT__ = Symbol('SelectPanel.Header');
|
|
358
|
+
const SelectPanelSearchInput = ({
|
|
359
|
+
onChange: propsOnChange,
|
|
360
|
+
onKeyDown: propsOnKeyDown,
|
|
361
|
+
className,
|
|
362
|
+
...props
|
|
363
|
+
}) => {
|
|
364
|
+
// TODO: use forwardedRef
|
|
365
|
+
const inputRef = /*#__PURE__*/React.createRef();
|
|
366
|
+
const {
|
|
367
|
+
setSearchQuery,
|
|
368
|
+
moveFocusToList
|
|
369
|
+
} = React.useContext(SelectPanelContext);
|
|
370
|
+
const internalOnChange = event => {
|
|
371
|
+
// If props.onChange is given, the application controls search,
|
|
372
|
+
// otherwise the component does
|
|
373
|
+
if (typeof propsOnChange === 'function') propsOnChange(event);else setSearchQuery(event.target.value);
|
|
374
|
+
};
|
|
375
|
+
const internalKeyDown = event => {
|
|
376
|
+
if (event.key === 'ArrowDown') {
|
|
377
|
+
event.preventDefault(); // prevent scroll
|
|
378
|
+
moveFocusToList();
|
|
379
|
+
}
|
|
380
|
+
if (typeof propsOnKeyDown === 'function') propsOnKeyDown(event);
|
|
381
|
+
};
|
|
382
|
+
return /*#__PURE__*/jsx(TextInput, {
|
|
383
|
+
ref: inputRef,
|
|
384
|
+
block: true,
|
|
385
|
+
leadingVisual: SearchIcon,
|
|
386
|
+
placeholder: "Search",
|
|
387
|
+
trailingAction: /*#__PURE__*/jsx(TextInput.Action, {
|
|
388
|
+
icon: XCircleFillIcon,
|
|
389
|
+
"aria-label": "Clear",
|
|
390
|
+
tooltipDirection: "w",
|
|
391
|
+
className: classes.ClearAction,
|
|
392
|
+
onClick: () => {
|
|
393
|
+
if (inputRef.current) inputRef.current.value = '';
|
|
394
|
+
if (typeof propsOnChange === 'function') {
|
|
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
|
+
});
|
|
312
408
|
};
|
|
313
409
|
SelectPanelSearchInput.displayName = "SelectPanelSearchInput";
|
|
314
|
-
SelectPanelSearchInput.__SLOT__ = Symbol(
|
|
315
|
-
const FooterContext =
|
|
316
|
-
const SelectPanelFooter = ({
|
|
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
|
-
|
|
345
|
-
|
|
410
|
+
SelectPanelSearchInput.__SLOT__ = Symbol('SelectPanel.SearchInput');
|
|
411
|
+
const FooterContext = /*#__PURE__*/React.createContext(false);
|
|
412
|
+
const SelectPanelFooter = ({
|
|
413
|
+
...props
|
|
414
|
+
}) => {
|
|
415
|
+
const {
|
|
416
|
+
onCancel,
|
|
417
|
+
selectionVariant
|
|
418
|
+
} = React.useContext(SelectPanelContext);
|
|
419
|
+
const hidePrimaryActions = selectionVariant === 'instant';
|
|
420
|
+
const buttonSize = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
421
|
+
if (hidePrimaryActions && !props.children) {
|
|
422
|
+
// nothing to render
|
|
423
|
+
// todo: we can inform them the developer footer will render nothing
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
return /*#__PURE__*/jsx(FooterContext.Provider, {
|
|
427
|
+
value: true,
|
|
428
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
429
|
+
className: classes.Footer,
|
|
430
|
+
"data-hide-primary-actions": hidePrimaryActions || undefined,
|
|
431
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
432
|
+
className: classes.FooterContent,
|
|
433
|
+
"data-hide-primary-actions": hidePrimaryActions || undefined,
|
|
434
|
+
children: props.children
|
|
435
|
+
}), hidePrimaryActions ? null : /*#__PURE__*/jsxs("div", {
|
|
436
|
+
className: classes.FooterActions,
|
|
437
|
+
children: [/*#__PURE__*/jsx(ButtonComponent, {
|
|
438
|
+
type: "button",
|
|
439
|
+
size: buttonSize,
|
|
440
|
+
onClick: () => onCancel(),
|
|
441
|
+
children: "Cancel"
|
|
442
|
+
}), /*#__PURE__*/jsx(ButtonComponent, {
|
|
443
|
+
type: "submit",
|
|
444
|
+
size: buttonSize,
|
|
445
|
+
variant: "primary",
|
|
446
|
+
children: "Save"
|
|
447
|
+
})]
|
|
448
|
+
})]
|
|
449
|
+
})
|
|
450
|
+
});
|
|
346
451
|
};
|
|
347
452
|
SelectPanelFooter.displayName = "SelectPanelFooter";
|
|
348
|
-
SelectPanelFooter.__SLOT__ = Symbol(
|
|
349
|
-
const SecondaryButton =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
453
|
+
SelectPanelFooter.__SLOT__ = Symbol('SelectPanel.Footer');
|
|
454
|
+
const SecondaryButton = props => {
|
|
455
|
+
const size = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
456
|
+
return /*#__PURE__*/jsx(ButtonComponent, {
|
|
457
|
+
type: "button",
|
|
458
|
+
size: size,
|
|
459
|
+
block: true,
|
|
460
|
+
...props
|
|
461
|
+
});
|
|
356
462
|
};
|
|
357
463
|
SecondaryButton.displayName = "SecondaryButton";
|
|
358
|
-
const SecondaryLink = ({
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
464
|
+
const SecondaryLink = ({
|
|
465
|
+
className,
|
|
466
|
+
...props
|
|
467
|
+
}) => {
|
|
468
|
+
const size = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
469
|
+
return (
|
|
470
|
+
/*#__PURE__*/
|
|
471
|
+
// @ts-ignore TODO: is as prop is not recognised by button?
|
|
472
|
+
jsx(ButtonComponent, {
|
|
473
|
+
as: Link,
|
|
474
|
+
size: size,
|
|
475
|
+
variant: "invisible",
|
|
476
|
+
block: true,
|
|
477
|
+
...props,
|
|
478
|
+
className: clsx(classes.SmallText, className),
|
|
479
|
+
children: props.children
|
|
480
|
+
})
|
|
481
|
+
);
|
|
368
482
|
};
|
|
369
483
|
SecondaryLink.displayName = "SecondaryLink";
|
|
370
|
-
const SecondaryCheckbox = ({
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
484
|
+
const SecondaryCheckbox = ({
|
|
485
|
+
id,
|
|
486
|
+
children,
|
|
487
|
+
className,
|
|
488
|
+
...props
|
|
489
|
+
}) => {
|
|
490
|
+
const checkboxId = useId(id);
|
|
491
|
+
const {
|
|
492
|
+
selectionVariant
|
|
493
|
+
} = React.useContext(SelectPanelContext);
|
|
494
|
+
|
|
495
|
+
// Checkbox should not be used with instant selection
|
|
496
|
+
!(selectionVariant !== 'instant') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Sorry! SelectPanel.SecondaryAction with variant="checkbox" is not allowed inside selectionVariant="instant"') : invariant(false) : void 0;
|
|
497
|
+
return /*#__PURE__*/jsxs("div", {
|
|
498
|
+
className: classes.SecondaryCheckbox,
|
|
499
|
+
children: [/*#__PURE__*/jsx(Checkbox, {
|
|
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
|
+
});
|
|
386
509
|
};
|
|
387
510
|
SecondaryCheckbox.displayName = "SecondaryCheckbox";
|
|
388
|
-
const SelectPanelSecondaryAction = ({
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
511
|
+
const SelectPanelSecondaryAction = ({
|
|
512
|
+
variant,
|
|
513
|
+
...props
|
|
514
|
+
}) => {
|
|
515
|
+
const insideFooter = React.useContext(FooterContext);
|
|
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
|
+
});
|
|
393
531
|
};
|
|
394
|
-
const SelectPanelLoading = ({
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
532
|
+
const SelectPanelLoading = ({
|
|
533
|
+
children = 'Fetching items...'
|
|
534
|
+
}) => {
|
|
535
|
+
return /*#__PURE__*/jsxs(AriaStatus, {
|
|
536
|
+
announceOnShow: true,
|
|
537
|
+
className: classes.SelectPanelLoading,
|
|
538
|
+
children: [/*#__PURE__*/jsx(Spinner, {
|
|
539
|
+
size: "medium",
|
|
540
|
+
srText: null
|
|
541
|
+
}), /*#__PURE__*/jsx("span", {
|
|
542
|
+
className: classes.LoadingText,
|
|
543
|
+
children: children
|
|
544
|
+
})]
|
|
545
|
+
});
|
|
406
546
|
};
|
|
407
547
|
SelectPanelLoading.displayName = "SelectPanelLoading";
|
|
408
|
-
const SelectPanelMessage = ({
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
548
|
+
const SelectPanelMessage = ({
|
|
549
|
+
variant = 'warning',
|
|
550
|
+
size = variant === 'empty' ? 'full' : 'inline',
|
|
551
|
+
title,
|
|
552
|
+
children
|
|
553
|
+
}) => {
|
|
554
|
+
const MessageWrapper = variant === 'empty' ? 'div' : AriaStatus;
|
|
555
|
+
if (size === 'full') {
|
|
556
|
+
return /*#__PURE__*/jsxs(MessageWrapper, {
|
|
557
|
+
className: classes.MessageFull,
|
|
558
|
+
children: [variant !== 'empty' ? /*#__PURE__*/jsx(Octicon, {
|
|
559
|
+
icon: AlertIcon,
|
|
560
|
+
className: clsx(classes.Octicon, variant === 'error' ? classes.Error : undefined, variant === 'warning' ? classes.Warning : undefined)
|
|
561
|
+
}) : null, /*#__PURE__*/jsx("span", {
|
|
562
|
+
className: classes.MessageTitle,
|
|
563
|
+
children: title
|
|
564
|
+
}), /*#__PURE__*/jsx("span", {
|
|
565
|
+
className: classes.MessageContent,
|
|
566
|
+
children: children
|
|
567
|
+
})]
|
|
568
|
+
});
|
|
569
|
+
} else {
|
|
570
|
+
return /*#__PURE__*/jsxs(MessageWrapper, {
|
|
571
|
+
className: classes.MessageInline,
|
|
572
|
+
"data-variant": variant,
|
|
573
|
+
children: [/*#__PURE__*/jsx(AlertIcon, {
|
|
574
|
+
size: 16
|
|
575
|
+
}), /*#__PURE__*/jsx("div", {
|
|
576
|
+
children: children
|
|
577
|
+
})]
|
|
578
|
+
});
|
|
579
|
+
}
|
|
432
580
|
};
|
|
433
581
|
const SelectPanel = Object.assign(Panel, {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
582
|
+
Button: SelectPanelButton,
|
|
583
|
+
Header: SelectPanelHeader,
|
|
584
|
+
SearchInput: SelectPanelSearchInput,
|
|
585
|
+
Footer: SelectPanelFooter,
|
|
586
|
+
Loading: SelectPanelLoading,
|
|
587
|
+
Message: SelectPanelMessage,
|
|
588
|
+
SecondaryAction: SelectPanelSecondaryAction
|
|
441
589
|
});
|
|
442
|
-
|
|
590
|
+
|
|
443
591
|
export { SelectPanel };
|