@procore/core-react 12.42.0 → 12.44.0
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 +61 -1
- package/dist/AnchorNavigation/AnchorNavigation.js +11 -5
- package/dist/AnchorNavigation/AnchorNavigation.js.map +1 -1
- package/dist/AnchorNavigation/AnchorNavigation.styles.d.ts +1 -0
- package/dist/AnchorNavigation/AnchorNavigation.styles.js +7 -3
- package/dist/AnchorNavigation/AnchorNavigation.styles.js.map +1 -1
- package/dist/AnchorNavigation/AnchorNavigation.types.d.ts +7 -1
- package/dist/AnchorNavigation/AnchorNavigation.types.js.map +1 -1
- package/dist/AnchorNavigation/AnchorNavigationProvider.js +11 -0
- package/dist/AnchorNavigation/AnchorNavigationProvider.js.map +1 -1
- package/dist/Avatar/Avatar.styles.js +5 -5
- package/dist/AvatarStack/AvatarStack.styles.d.ts +74 -74
- package/dist/AvatarStack/AvatarStack.styles.js +7 -7
- package/dist/Badge/Badge.styles.js +2 -2
- package/dist/BadgePill/BadgePill.styles.js +4 -4
- package/dist/Banner/Banner.styles.js +10 -10
- package/dist/Box/Box.styles.js +1 -1
- package/dist/Breadcrumbs/Breadcrumbs.styles.js +4 -4
- package/dist/Button/Button.styles.js +5 -5
- package/dist/Button/Button.types.d.ts +1 -4
- package/dist/Button/Button.types.js.map +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.js.map +1 -1
- package/dist/Calendar/Calendar.styles.js +9 -9
- package/dist/Card/Card.styles.js +1 -1
- package/dist/Checkbox/Checkbox.js +1 -0
- package/dist/Checkbox/Checkbox.js.map +1 -1
- package/dist/Checkbox/Checkbox.styles.js +6 -6
- package/dist/ContactItem/ContactItem.styles.js +5 -5
- package/dist/Content/Content.styles.js +2 -2
- package/dist/DateInput/DateInput.js +9 -0
- package/dist/DateInput/DateInput.js.map +1 -1
- package/dist/DateInput/DateInput.styles.js +6 -6
- package/dist/DetailPage/DetailPage.styles.js +7 -7
- package/dist/Dropdown/Dropdown.styles.js +3 -3
- package/dist/DropdownFlyout/DropdownFlyout.styles.js +4 -4
- package/dist/Dropzone/Dropzone.js +1 -1
- package/dist/Dropzone/Dropzone.styles.js +9 -9
- package/dist/EmptyState/EmptyState.styles.js +6 -6
- package/dist/Field/Field.styles.js +3 -3
- package/dist/FileList/FileList.styles.js +3 -3
- package/dist/FileSelect/FileExplorer/FileExplorer.styles.js +9 -9
- package/dist/FileSelect/FileExplorer/FileExplorerSidebar.styles.js +3 -3
- package/dist/FileSelect/FileSelect.styles.js +2 -2
- package/dist/FileSelect/FileSelectDropzone/FileSelectDropzone.styles.js +3 -3
- package/dist/FileSelect/FileTokenList/FileTokenList.styles.js +2 -2
- package/dist/FileSelect/GridSource/GridSource.styles.js +6 -6
- package/dist/FileSelect/LocalSource/LocalSource.styles.js +4 -4
- package/dist/FileSelect/SourceItem/SourceItem.styles.js +3 -3
- package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.d.ts +1 -1
- package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.js +6 -6
- package/dist/FileSelect/TreeSource/TreeSource.styles.js +1 -1
- package/dist/FileToken/FileToken.styles.js +6 -6
- package/dist/FileToken/FileTokenInner.js +1 -3
- package/dist/FileToken/FileTokenInner.js.map +1 -1
- package/dist/FilterToken/FilterToken.styles.js +5 -5
- package/dist/FlexList/FlexList.styles.js +1 -1
- package/dist/Form/Form.styles.js +13 -13
- package/dist/Form/StyledFormikForm.styles.d.ts +2 -2
- package/dist/Form/StyledFormikForm.styles.js +2 -2
- package/dist/GhostPlaceholder/GhostPlaceholder.styles.js +2 -2
- package/dist/Grid/Grid.styles.js +2 -2
- package/dist/GroupSelect/GroupSelect.styles.js +1 -1
- package/dist/Input/Input.styles.js +1 -1
- package/dist/Link/Link.styles.js +1 -1
- package/dist/ListPage/ListPage.styles.js +8 -8
- package/dist/Loader/Loader.styles.js +2 -2
- package/dist/MenuImperative/MenuImperative.styles.js +11 -11
- package/dist/Modal/Modal.js +8 -2
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/Modal/Modal.styles.js +13 -13
- package/dist/MultiSelect/MultiSelect.js +7 -5
- package/dist/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/MultiSelect/MultiSelect.styles.js +8 -8
- package/dist/NextMenu/NextMenu.styles.js +3 -3
- package/dist/Notation/Notation.js +1 -1
- package/dist/NumberInput/NumberInput.styles.js +7 -7
- package/dist/Overlay/OverlayArrow.styles.js +1 -1
- package/dist/OverlayTrigger/a11yPresets.d.ts +6 -6
- package/dist/PageLayout/PageLayout.styles.d.ts +1 -1
- package/dist/PageLayout/PageLayout.styles.js +16 -16
- package/dist/PageTemplate/PageFooterTemplate/PageFooterTemplate.styles.js +1 -1
- package/dist/PageTemplate/PageHeaderTemplate/PageHeaderTemplate.styles.js +3 -3
- package/dist/PageTemplate/PagePaneTemplate/PagePaneTemplate.styles.js +2 -2
- package/dist/PageTemplate/PageTemplate/PageTemplate.styles.js +3 -3
- package/dist/Pagination/Pagination.styles.js +5 -5
- package/dist/Panel/Panel.styles.js +11 -11
- package/dist/Pill/Pill.styles.js +3 -3
- package/dist/PillSelect/PillSelect.styles.js +4 -4
- package/dist/Popover/Popover.styles.js +2 -2
- package/dist/Portal/Portal.styles.js +1 -1
- package/dist/ProgressBar/ProgressBar.styles.js +2 -2
- package/dist/RadioButton/RadioButton.styles.js +3 -3
- package/dist/Required/Required.styles.js +3 -3
- package/dist/Search/Search.styles.js +5 -5
- package/dist/Section/Section.styles.js +7 -7
- package/dist/SegmentedController/SegmentedController.styles.js +4 -4
- package/dist/Select/Select.js +3 -2
- package/dist/Select/Select.js.map +1 -1
- package/dist/Select/Select.styles.js +8 -8
- package/dist/Semantic/Semantic.styles.d.ts +74 -74
- package/dist/Semantic/Semantic.styles.js +9 -9
- package/dist/Slider/Slider.styles.js +5 -5
- package/dist/Spinner/Spinner.js +3 -1
- package/dist/Spinner/Spinner.js.map +1 -1
- package/dist/Spinner/Spinner.styles.js +7 -7
- package/dist/SplitViewCard/SplitViewCard.styles.js +8 -8
- package/dist/SuperSelect/SuperSelect.components.js +42 -22
- package/dist/SuperSelect/SuperSelect.components.js.map +1 -1
- package/dist/SuperSelect/SuperSelect.presets.styles.js +1 -1
- package/dist/SuperSelect/SuperSelect.styles.d.ts +4 -2
- package/dist/SuperSelect/SuperSelect.styles.js +49 -42
- package/dist/SuperSelect/SuperSelect.styles.js.map +1 -1
- package/dist/SuperSelect/SuperSelect.types.d.ts +3 -4
- package/dist/SuperSelect/SuperSelect.types.js.map +1 -1
- package/dist/SuperSelect/presets/filterPreset.js +7 -2
- package/dist/SuperSelect/presets/filterPreset.js.map +1 -1
- package/dist/SuperSelect/useSuperSelect.d.ts +1 -1
- package/dist/SuperSelect/useSuperSelect.js +115 -88
- package/dist/SuperSelect/useSuperSelect.js.map +1 -1
- package/dist/Switch/Switch.styles.js +4 -4
- package/dist/Table/Table.js +2 -2
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/Table.styles.d.ts +1 -8
- package/dist/Table/Table.styles.js +74 -81
- package/dist/Table/Table.styles.js.map +1 -1
- package/dist/TableShelf/TableShelf.styles.js +5 -5
- package/dist/Tabs/Tabs.js +1 -1
- package/dist/Tabs/Tabs.js.map +1 -1
- package/dist/Tabs/Tabs.styles.js +15 -15
- package/dist/Tearsheet/Tearsheet.styles.js +5 -5
- package/dist/TextArea/TextArea.styles.js +1 -1
- package/dist/TextEditorOutput/TextEditorOutput.styles.js +1 -1
- package/dist/Thumbnail/Thumbnail.hooks.d.ts +58 -58
- package/dist/Thumbnail/Thumbnail.styles.js +17 -17
- package/dist/ThumbnailGrid/ThumbnailGrid.styles.d.ts +1 -1
- package/dist/ThumbnailGrid/ThumbnailGrid.styles.js +7 -7
- package/dist/TieredSelect/TieredSelect.styles.d.ts +1 -1
- package/dist/TieredSelect/TieredSelect.styles.js +9 -9
- package/dist/Tile/Tile.styles.js +8 -8
- package/dist/Title/Title.styles.js +7 -7
- package/dist/Toast/Toast.styles.js +3 -3
- package/dist/ToggleButton/ToggleButton.styles.js +1 -1
- package/dist/Token/Token.js +1 -1
- package/dist/Token/Token.js.map +1 -1
- package/dist/Token/Token.styles.js +3 -3
- package/dist/ToolHeader/ToolHeader.styles.js +6 -6
- package/dist/ToolLandingPage/ToolLandingPage.styles.js +3 -3
- package/dist/ToolLandingPageTemplate/ToolLandingPageTemplate.d.ts +1 -1
- package/dist/Tooltip/Tooltip.styles.js +3 -3
- package/dist/Tree/Tree.js +1 -1
- package/dist/Tree/Tree.styles.js +10 -10
- package/dist/Typeahead/Typeahead.js +7 -3
- package/dist/Typeahead/Typeahead.js.map +1 -1
- package/dist/Typeahead/Typeahead.styles.js +3 -3
- package/dist/Typography/Typography.styles.js +1 -1
- package/dist/Typography/Typography.table.story.js +2 -2
- package/dist/Typography/Typography.types.d.ts +1 -0
- package/dist/Typography/Typography.types.js.map +1 -1
- package/dist/_hooks/I18n.d.ts +14 -0
- package/dist/_locales/en.json +7 -0
- package/dist/_locales/pseudo.json +7 -0
- package/dist/_storyHelpers_/components/Deprecation.styles.js +1 -1
- package/dist/_storyHelpers_/components/StoryGrid.js +3 -3
- package/dist/_typedoc/AnchorNavigation/AnchorNavigation.types.json +13 -3
- package/dist/_typedoc/Avatar/Avatar.types.json +20 -20
- package/dist/_typedoc/AvatarStack/AvatarStack.types.json +25 -25
- package/dist/_typedoc/Badge/Badge.types.json +6 -6
- package/dist/_typedoc/Banner/Banner.types.json +15 -15
- package/dist/_typedoc/Box/Box.types.json +72 -72
- package/dist/_typedoc/Breadcrumbs/Breadcrumbs.types.json +10 -10
- package/dist/_typedoc/Button/Button.types.json +17 -17
- package/dist/_typedoc/Calendar/Calendar.types.json +80 -80
- package/dist/_typedoc/Card/Card.types.json +6 -6
- package/dist/_typedoc/Checkbox/Checkbox.types.json +8 -8
- package/dist/_typedoc/ContactItem/ContactItem.types.json +9 -9
- package/dist/_typedoc/DateInput/DateInput.types.json +35 -35
- package/dist/_typedoc/DateSelect/DateSelect.types.json +13 -13
- package/dist/_typedoc/DetailPage/DetailPage.types.json +5 -5
- package/dist/_typedoc/Dropdown/Dropdown.types.json +39 -39
- package/dist/_typedoc/DropdownFlyout/DropdownFlyout.types.json +31 -31
- package/dist/_typedoc/Dropzone/Dropzone.types.json +44 -44
- package/dist/_typedoc/EmptyState/EmptyState.types.json +16 -16
- package/dist/_typedoc/FileList/FileList.types.json +9 -9
- package/dist/_typedoc/FileSelect/FileSelect.types.json +27 -27
- package/dist/_typedoc/FileSelect/GridSource/GridSource.types.json +20 -20
- package/dist/_typedoc/FileSelect/LocalSource/LocalSource.types.json +14 -14
- package/dist/_typedoc/FileSelect/TreeSource/TreeSource.types.json +9 -9
- package/dist/_typedoc/Flex/Flex.types.json +27 -27
- package/dist/_typedoc/FlexList/FlexList.types.json +30 -30
- package/dist/_typedoc/Form/Form.types.json +832 -832
- package/dist/_typedoc/GhostPlaceholder/GhostPlaceholder.types.json +12 -12
- package/dist/_typedoc/Grid/Grid.types.json +8 -8
- package/dist/_typedoc/GroupSelect/GroupSelect.types.json +54 -54
- package/dist/_typedoc/Input/Input.types.json +2 -2
- package/dist/_typedoc/Link/Link.types.json +1 -1
- package/dist/_typedoc/ListPage/ListPage.types.json +13 -13
- package/dist/_typedoc/Menu/Menu.types.json +62 -62
- package/dist/_typedoc/MenuImperative/MenuImperative.types.json +84 -84
- package/dist/_typedoc/Modal/Modal.types.json +48 -48
- package/dist/_typedoc/MultiSelect/MultiSelect.types.json +33 -33
- package/dist/_typedoc/NextTile/NextTile.types.json +32 -32
- package/dist/_typedoc/Notation/Notation.types.json +4 -4
- package/dist/_typedoc/NumberInput/NumberInput.types.json +54 -54
- package/dist/_typedoc/OverlayTrigger/OverlayTrigger.types.json +33 -33
- package/dist/_typedoc/PageLayout/PageLayout.types.json +28 -28
- package/dist/_typedoc/Pagination/Pagination.types.json +7 -7
- package/dist/_typedoc/Panel/Panel.types.json +27 -27
- package/dist/_typedoc/Pill/Pill.types.json +2 -2
- package/dist/_typedoc/PillSelect/PillSelect.types.json +49 -49
- package/dist/_typedoc/Popover/Popover.types.json +15 -15
- package/dist/_typedoc/ProgressBar/ProgressBar.types.json +7 -7
- package/dist/_typedoc/RadioButton/RadioButton.types.json +6 -6
- package/dist/_typedoc/Required/Required.types.json +5 -5
- package/dist/_typedoc/Search/Search.types.json +18 -18
- package/dist/_typedoc/Section/Section.types.json +15 -15
- package/dist/_typedoc/SegmentedController/SegmentedController.types.json +21 -21
- package/dist/_typedoc/Select/Select.types.json +69 -69
- package/dist/_typedoc/SettingsPage/SettingsPage.types.json +10 -10
- package/dist/_typedoc/Slider/Slider.types.json +6 -6
- package/dist/_typedoc/Spinner/Spinner.types.json +9 -9
- package/dist/_typedoc/SplitViewCard/SplitViewCard.types.json +14 -14
- package/dist/_typedoc/Table/Table.types.json +102 -102
- package/dist/_typedoc/Tabs/Tabs.types.json +21 -21
- package/dist/_typedoc/Tearsheet/Tearsheet.types.json +17 -17
- package/dist/_typedoc/TextArea/TextArea.types.json +3 -3
- package/dist/_typedoc/TextEditor/TextEditor.types.json +11 -11
- package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +4 -4
- package/dist/_typedoc/Thumbnail/Thumbnail.types.json +19 -19
- package/dist/_typedoc/TieredDropdown/TieredDropdown.types.json +43 -43
- package/dist/_typedoc/TieredSelect/TieredSelect.types.json +29 -29
- package/dist/_typedoc/Tile/Tile.types.json +8 -8
- package/dist/_typedoc/Title/Title.types.json +3 -3
- package/dist/_typedoc/Toast/Toast.types.json +4 -4
- package/dist/_typedoc/ToggleButton/ToggleButton.types.json +4 -4
- package/dist/_typedoc/Token/Token.types.json +7 -7
- package/dist/_typedoc/ToolHeader/ToolHeader.types.json +10 -10
- package/dist/_typedoc/ToolLandingPage/ToolLandingPage.types.json +10 -10
- package/dist/_typedoc/Tooltip/Tooltip.types.json +15 -15
- package/dist/_typedoc/Tree/Tree.types.json +90 -90
- package/dist/_typedoc/Typeahead/Typeahead.types.json +2 -2
- package/dist/_typedoc/Typography/Typography.types.json +12 -11
- package/dist/_typedoc/_utils/types.json +3 -3
- package/package.json +2 -2
|
@@ -65,48 +65,17 @@ function useTokenNavigation(context) {
|
|
|
65
65
|
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
66
66
|
_ref$value = _ref.value,
|
|
67
67
|
value = _ref$value === void 0 ? [] : _ref$value,
|
|
68
|
-
|
|
69
|
-
activeIndex = _ref$activeIndex === void 0 ? null : _ref$activeIndex,
|
|
70
|
-
_ref$onNavigate = _ref.onNavigate,
|
|
71
|
-
onNavigate = _ref$onNavigate === void 0 ? noop : _ref$onNavigate,
|
|
72
|
-
_ref$onChange = _ref.onChange,
|
|
73
|
-
onChange = _ref$onChange === void 0 ? noop : _ref$onChange;
|
|
68
|
+
tokenRemoveRefs = _ref.tokenRemoveRefs;
|
|
74
69
|
return {
|
|
75
70
|
reference: {
|
|
76
71
|
onKeyDown: function onKeyDown(e) {
|
|
77
|
-
if (!enabled || !Array.isArray(value)) {
|
|
72
|
+
if (!enabled || !Array.isArray(value) || value.length === 0) {
|
|
78
73
|
return;
|
|
79
74
|
}
|
|
80
75
|
if (e.key === 'ArrowLeft') {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onNavigate(value.length - 1);
|
|
85
|
-
}
|
|
86
|
-
} else if (e.key === 'ArrowRight') {
|
|
87
|
-
if (activeIndex !== null) {
|
|
88
|
-
if (activeIndex === value.length - 1) {
|
|
89
|
-
onNavigate(null);
|
|
90
|
-
} else {
|
|
91
|
-
onNavigate(activeIndex + 1);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} else if (e.key === 'Backspace') {
|
|
95
|
-
if (!e.repeat) {
|
|
96
|
-
if (activeIndex !== null) {
|
|
97
|
-
var nextVal = value.filter(function (_, i) {
|
|
98
|
-
return i !== activeIndex;
|
|
99
|
-
});
|
|
100
|
-
onChange(nextVal);
|
|
101
|
-
if (activeIndex >= nextVal.length) {
|
|
102
|
-
onNavigate(null);
|
|
103
|
-
}
|
|
104
|
-
} else if (value.length > 0) {
|
|
105
|
-
onChange(value.filter(function (_, i) {
|
|
106
|
-
return i !== value.length - 1;
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
76
|
+
var _tokenRemoveRefs$curr;
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
tokenRemoveRefs === null || tokenRemoveRefs === void 0 ? void 0 : (_tokenRemoveRefs$curr = tokenRemoveRefs.current[value.length - 1]) === null || _tokenRemoveRefs$curr === void 0 ? void 0 : _tokenRemoveRefs$curr.focus();
|
|
110
79
|
}
|
|
111
80
|
}
|
|
112
81
|
}
|
|
@@ -195,7 +164,8 @@ export function useSuperSelect(_ref3) {
|
|
|
195
164
|
value_ = _ref3.value,
|
|
196
165
|
_ref3$overlayMatchesT = _ref3.overlayMatchesTriggerWidth,
|
|
197
166
|
overlayMatchesTriggerWidth = _ref3$overlayMatchesT === void 0 ? true : _ref3$overlayMatchesT,
|
|
198
|
-
ariaLabel = _ref3['aria-label']
|
|
167
|
+
ariaLabel = _ref3['aria-label'],
|
|
168
|
+
ariaLabelledBy = _ref3['aria-labelledby'];
|
|
199
169
|
React.useEffect(function () {
|
|
200
170
|
if (!draggable) {
|
|
201
171
|
return;
|
|
@@ -386,7 +356,8 @@ export function useSuperSelect(_ref3) {
|
|
|
386
356
|
var searchRef = React.useRef(null);
|
|
387
357
|
var overlayId = useId(); // TODO use React 18 useId
|
|
388
358
|
var listId = useId(); // TODO use React 18 useId
|
|
389
|
-
|
|
359
|
+
var selectedValueId = useId();
|
|
360
|
+
var tokenListId = useId();
|
|
390
361
|
var _React$useState5 = React.useState(false),
|
|
391
362
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
392
363
|
open = _React$useState6[0],
|
|
@@ -426,10 +397,7 @@ export function useSuperSelect(_ref3) {
|
|
|
426
397
|
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
427
398
|
activeMenuIndex = _React$useState20[0],
|
|
428
399
|
setActiveMenuIndex = _React$useState20[1];
|
|
429
|
-
var
|
|
430
|
-
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
431
|
-
activeTokenIndex = _React$useState22[0],
|
|
432
|
-
setActiveTokenIndex = _React$useState22[1];
|
|
400
|
+
var tokenRemoveRefs = React.useRef([]);
|
|
433
401
|
var components = _objectSpread(_objectSpread({}, defaultComponents), customComponents || {});
|
|
434
402
|
|
|
435
403
|
// TODO #memogetters: consider having getOption... getter functions memoized by consumers
|
|
@@ -573,10 +541,10 @@ export function useSuperSelect(_ref3) {
|
|
|
573
541
|
}
|
|
574
542
|
return [selectAllOption].concat(_toConsumableArray(options));
|
|
575
543
|
}, [selectAllEnabled, multiple, selectAllOption, options]);
|
|
576
|
-
var _React$
|
|
577
|
-
_React$
|
|
578
|
-
draggableOptions = _React$
|
|
579
|
-
setDraggableOptions = _React$
|
|
544
|
+
var _React$useState21 = React.useState([]),
|
|
545
|
+
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
546
|
+
draggableOptions = _React$useState22[0],
|
|
547
|
+
setDraggableOptions = _React$useState22[1];
|
|
580
548
|
React.useEffect(function () {
|
|
581
549
|
if (!draggable) {
|
|
582
550
|
return;
|
|
@@ -846,9 +814,15 @@ export function useSuperSelect(_ref3) {
|
|
|
846
814
|
}, [open]);
|
|
847
815
|
var floating = useFloating({
|
|
848
816
|
open: open,
|
|
849
|
-
onOpenChange: function onOpenChange(
|
|
850
|
-
setOpen(
|
|
851
|
-
_onOpenChange(
|
|
817
|
+
onOpenChange: function onOpenChange(nextOpen) {
|
|
818
|
+
setOpen(nextOpen);
|
|
819
|
+
_onOpenChange(nextOpen);
|
|
820
|
+
if (!nextOpen && multiple) {
|
|
821
|
+
requestAnimationFrame(function () {
|
|
822
|
+
var _searchRef$current;
|
|
823
|
+
(_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.focus();
|
|
824
|
+
});
|
|
825
|
+
}
|
|
852
826
|
},
|
|
853
827
|
whileElementsMounted: function whileElementsMounted() {
|
|
854
828
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -884,6 +858,21 @@ export function useSuperSelect(_ref3) {
|
|
|
884
858
|
});
|
|
885
859
|
var _useZIndexContext = useZIndexContext(),
|
|
886
860
|
zIndex = _useZIndexContext.value;
|
|
861
|
+
var activeDescendantId = React.useMemo(function () {
|
|
862
|
+
if (activeMenuIndex === null) return undefined;
|
|
863
|
+
var baseOptions = selectAllEnabled && multiple ? allOptionsWithSelectAll : options;
|
|
864
|
+
var option = baseOptions[activeMenuIndex];
|
|
865
|
+
if (!option) return undefined;
|
|
866
|
+
if (getOptionIsOptSelectAll(option)) return "item-".concat(selectAllOption.id);
|
|
867
|
+
return "item-".concat(getOptionValue(option));
|
|
868
|
+
}, [activeMenuIndex, selectAllEnabled, multiple, allOptionsWithSelectAll, options, selectAllOption]);
|
|
869
|
+
function getAriaLabelProps() {
|
|
870
|
+
return _objectSpread(_objectSpread({}, ariaLabel && {
|
|
871
|
+
'aria-label': ariaLabel
|
|
872
|
+
}), ariaLabelledBy && {
|
|
873
|
+
'aria-labelledby': ariaLabelledBy
|
|
874
|
+
});
|
|
875
|
+
}
|
|
887
876
|
var _useInteractions = useInteractions([useClick(floating.context, {
|
|
888
877
|
enabled: !disabled,
|
|
889
878
|
keyboardHandlers: false
|
|
@@ -903,14 +892,8 @@ export function useSuperSelect(_ref3) {
|
|
|
903
892
|
selectedIndex: selectedIndex,
|
|
904
893
|
virtual: true
|
|
905
894
|
}), useTokenNavigation(floating.context, {
|
|
906
|
-
activeIndex: activeTokenIndex,
|
|
907
895
|
enabled: !disabled && multiple && searchValue === '',
|
|
908
|
-
|
|
909
|
-
onNavigate: function onNavigate(i) {
|
|
910
|
-
return setActiveTokenIndex(function () {
|
|
911
|
-
return i;
|
|
912
|
-
});
|
|
913
|
-
},
|
|
896
|
+
tokenRemoveRefs: tokenRemoveRefs,
|
|
914
897
|
value: value
|
|
915
898
|
}), useKeyboardSelection(floating.context, {
|
|
916
899
|
enabled: !disabled,
|
|
@@ -925,18 +908,20 @@ export function useSuperSelect(_ref3) {
|
|
|
925
908
|
$multiple: multiple,
|
|
926
909
|
$open: open,
|
|
927
910
|
$placeholder: !selectedLabel,
|
|
928
|
-
'aria-
|
|
911
|
+
'aria-activedescendant': multiple ? undefined : activeDescendantId
|
|
912
|
+
}, !multiple && _objectSpread(_objectSpread({
|
|
913
|
+
'aria-controls': open ? overlayId : undefined,
|
|
914
|
+
'aria-describedby': selectedValueId,
|
|
929
915
|
'aria-expanded': open,
|
|
930
916
|
'aria-haspopup': 'listbox'
|
|
931
|
-
},
|
|
932
|
-
'
|
|
933
|
-
|
|
917
|
+
}, getAriaLabelProps()), {}, {
|
|
918
|
+
role: 'button',
|
|
919
|
+
tabIndex: disabled ? -1 : tabIndex
|
|
920
|
+
})), {}, {
|
|
934
921
|
onKeyDown: function onKeyDown() {
|
|
935
922
|
setPointer(false);
|
|
936
923
|
},
|
|
937
|
-
|
|
938
|
-
search: search,
|
|
939
|
-
tabIndex: disabled ? -1 : tabIndex
|
|
924
|
+
search: search
|
|
940
925
|
}),
|
|
941
926
|
// TODO fix type
|
|
942
927
|
floating: {
|
|
@@ -963,15 +948,23 @@ export function useSuperSelect(_ref3) {
|
|
|
963
948
|
getItemProps = _useInteractions.getItemProps;
|
|
964
949
|
function getLabelProps() {
|
|
965
950
|
return {
|
|
966
|
-
$hoverable: false
|
|
951
|
+
$hoverable: false,
|
|
952
|
+
id: selectedValueId
|
|
967
953
|
};
|
|
968
954
|
}
|
|
969
955
|
function getMultiInputProps() {
|
|
970
|
-
|
|
956
|
+
var showPlaceholder = isEmpty();
|
|
957
|
+
return _objectSpread(_objectSpread({
|
|
958
|
+
'aria-activedescendant': activeDescendantId,
|
|
959
|
+
'aria-controls': open ? overlayId : undefined,
|
|
960
|
+
'aria-expanded': open,
|
|
961
|
+
'aria-haspopup': 'listbox'
|
|
962
|
+
}, getAriaLabelProps()), {}, {
|
|
963
|
+
role: 'combobox',
|
|
971
964
|
ref: searchRef,
|
|
972
|
-
|
|
965
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
966
|
+
placeholder: showPlaceholder ? placeholder : '',
|
|
973
967
|
disabled: disabled,
|
|
974
|
-
'aria-controls': listId,
|
|
975
968
|
onKeyDown: function onKeyDown(e) {
|
|
976
969
|
if (e.key === 'Tab') {
|
|
977
970
|
if (open) {
|
|
@@ -981,25 +974,59 @@ export function useSuperSelect(_ref3) {
|
|
|
981
974
|
(_floating$refs$floati = floating.refs.floating.current) === null || _floating$refs$floati === void 0 ? void 0 : _floating$refs$floati.focus();
|
|
982
975
|
}
|
|
983
976
|
}
|
|
984
|
-
},
|
|
985
|
-
onChange: function onChange(e) {
|
|
986
|
-
setSearchValue(e.currentTarget.value);
|
|
987
|
-
setActiveTokenIndex(null);
|
|
988
|
-
},
|
|
989
|
-
style: {
|
|
990
|
-
opacity: activeTokenIndex === null ? 1 : 0
|
|
991
977
|
}
|
|
992
|
-
};
|
|
978
|
+
});
|
|
993
979
|
}
|
|
994
980
|
function getMultiValueProps(index) {
|
|
981
|
+
function removeToken() {
|
|
982
|
+
if (!isMultiple(multiple, value)) return;
|
|
983
|
+
var nextVal = value.filter(function (_, i) {
|
|
984
|
+
return i !== index;
|
|
985
|
+
});
|
|
986
|
+
setValue(nextVal);
|
|
987
|
+
requestAnimationFrame(function () {
|
|
988
|
+
if (nextVal.length === 0) {
|
|
989
|
+
var _searchRef$current2;
|
|
990
|
+
(_searchRef$current2 = searchRef.current) === null || _searchRef$current2 === void 0 ? void 0 : _searchRef$current2.focus();
|
|
991
|
+
} else if (index >= nextVal.length) {
|
|
992
|
+
var _tokenRemoveRefs$curr2;
|
|
993
|
+
(_tokenRemoveRefs$curr2 = tokenRemoveRefs.current[nextVal.length - 1]) === null || _tokenRemoveRefs$curr2 === void 0 ? void 0 : _tokenRemoveRefs$curr2.focus();
|
|
994
|
+
} else {
|
|
995
|
+
var _tokenRemoveRefs$curr3;
|
|
996
|
+
(_tokenRemoveRefs$curr3 = tokenRemoveRefs.current[index]) === null || _tokenRemoveRefs$curr3 === void 0 ? void 0 : _tokenRemoveRefs$curr3.focus();
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
}
|
|
995
1000
|
return {
|
|
1001
|
+
ref: function ref(el) {
|
|
1002
|
+
tokenRemoveRefs.current[index] = el;
|
|
1003
|
+
},
|
|
996
1004
|
onClick: function onClick(e) {
|
|
997
|
-
// prevent the menu from closing
|
|
998
1005
|
e.stopPropagation();
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1006
|
+
removeToken();
|
|
1007
|
+
},
|
|
1008
|
+
onKeyDown: function onKeyDown(e) {
|
|
1009
|
+
if (e.key === 'Enter' || e.key === 'Backspace' || e.key === 'Delete') {
|
|
1010
|
+
e.preventDefault();
|
|
1011
|
+
e.stopPropagation();
|
|
1012
|
+
removeToken();
|
|
1013
|
+
} else if (e.key === 'ArrowLeft') {
|
|
1014
|
+
e.preventDefault();
|
|
1015
|
+
e.stopPropagation();
|
|
1016
|
+
if (index > 0) {
|
|
1017
|
+
var _tokenRemoveRefs$curr4;
|
|
1018
|
+
(_tokenRemoveRefs$curr4 = tokenRemoveRefs.current[index - 1]) === null || _tokenRemoveRefs$curr4 === void 0 ? void 0 : _tokenRemoveRefs$curr4.focus();
|
|
1019
|
+
}
|
|
1020
|
+
} else if (e.key === 'ArrowRight') {
|
|
1021
|
+
e.preventDefault();
|
|
1022
|
+
e.stopPropagation();
|
|
1023
|
+
if (isMultiple(multiple, value) && index < value.length - 1) {
|
|
1024
|
+
var _tokenRemoveRefs$curr5;
|
|
1025
|
+
(_tokenRemoveRefs$curr5 = tokenRemoveRefs.current[index + 1]) === null || _tokenRemoveRefs$curr5 === void 0 ? void 0 : _tokenRemoveRefs$curr5.focus();
|
|
1026
|
+
} else {
|
|
1027
|
+
var _searchRef$current3;
|
|
1028
|
+
(_searchRef$current3 = searchRef.current) === null || _searchRef$current3 === void 0 ? void 0 : _searchRef$current3.focus();
|
|
1029
|
+
}
|
|
1003
1030
|
}
|
|
1004
1031
|
}
|
|
1005
1032
|
};
|
|
@@ -1014,12 +1041,15 @@ export function useSuperSelect(_ref3) {
|
|
|
1014
1041
|
}
|
|
1015
1042
|
function getSearchProps() {
|
|
1016
1043
|
return {
|
|
1044
|
+
'aria-activedescendant': activeDescendantId,
|
|
1017
1045
|
'aria-controls': listId,
|
|
1046
|
+
'aria-expanded': open,
|
|
1047
|
+
'aria-haspopup': 'listbox',
|
|
1018
1048
|
onChange: function onChange(value) {
|
|
1019
1049
|
setSearchValue(value);
|
|
1020
|
-
setActiveTokenIndex(null);
|
|
1021
1050
|
},
|
|
1022
|
-
placeholder: i18n.t('core.select.search')
|
|
1051
|
+
placeholder: i18n.t('core.select.search'),
|
|
1052
|
+
role: 'combobox'
|
|
1023
1053
|
};
|
|
1024
1054
|
}
|
|
1025
1055
|
function getHeaderProps() {
|
|
@@ -1049,10 +1079,10 @@ export function useSuperSelect(_ref3) {
|
|
|
1049
1079
|
return {
|
|
1050
1080
|
'aria-hidden': true,
|
|
1051
1081
|
'aria-label': i18n.t('core.select.clear'),
|
|
1082
|
+
tabIndex: -1,
|
|
1052
1083
|
onClick: function onClick(e) {
|
|
1053
1084
|
// prevent the menu from closing
|
|
1054
1085
|
e.stopPropagation();
|
|
1055
|
-
setActiveTokenIndex(null);
|
|
1056
1086
|
setValue(multiple ? [] : null);
|
|
1057
1087
|
setOpen(true);
|
|
1058
1088
|
}
|
|
@@ -1074,7 +1104,7 @@ export function useSuperSelect(_ref3) {
|
|
|
1074
1104
|
};
|
|
1075
1105
|
return {
|
|
1076
1106
|
role: 'listbox',
|
|
1077
|
-
id:
|
|
1107
|
+
id: listId,
|
|
1078
1108
|
data: draggable ? queriedDraggableOptions : options,
|
|
1079
1109
|
components: {
|
|
1080
1110
|
Item: components === null || components === void 0 ? void 0 : components.Item // TODO fix type
|
|
@@ -1135,9 +1165,6 @@ export function useSuperSelect(_ref3) {
|
|
|
1135
1165
|
setSearchValue(function () {
|
|
1136
1166
|
return '';
|
|
1137
1167
|
});
|
|
1138
|
-
setActiveTokenIndex(function () {
|
|
1139
|
-
return null;
|
|
1140
|
-
});
|
|
1141
1168
|
}
|
|
1142
1169
|
}, [open]);
|
|
1143
1170
|
|
|
@@ -1210,12 +1237,12 @@ export function useSuperSelect(_ref3) {
|
|
|
1210
1237
|
components: components,
|
|
1211
1238
|
state: {
|
|
1212
1239
|
activeMenuIndex: activeMenuIndex,
|
|
1213
|
-
activeTokenIndex: activeTokenIndex,
|
|
1214
1240
|
isEmpty: isEmpty,
|
|
1215
1241
|
isSelectAllActive: isSelectAllActive,
|
|
1216
1242
|
listContainerHeight: listContainerHeight,
|
|
1217
1243
|
listId: listId,
|
|
1218
1244
|
maxHeight: maxHeight,
|
|
1245
|
+
tokenListId: tokenListId,
|
|
1219
1246
|
onDragEnd: onDragEnd,
|
|
1220
1247
|
onSelect: onSelect,
|
|
1221
1248
|
onSelectAll: onSelectAll,
|