@arc-ui/components 12.0.0-beta.22 → 12.0.0-beta.23
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/lib/Alert/Alert.cjs +22 -21
- package/lib/Alert/Alert.mjs +22 -21
- package/lib/Alert/styles.css +1 -1
- package/lib/Align/styles.css +1 -1
- package/lib/AppButton/styles.css +1 -1
- package/lib/Avatar/styles.css +1 -1
- package/lib/AvatarGroup/styles.css +1 -1
- package/lib/Badge/styles.css +1 -1
- package/lib/Banner/Banner.cjs +1 -1
- package/lib/Banner/Banner.mjs +1 -1
- package/lib/Box/styles.css +1 -1
- package/lib/BrandLogo/styles.css +1 -1
- package/lib/Breadcrumbs/Breadcrumbs.cjs +12 -3
- package/lib/Breadcrumbs/Breadcrumbs.mjs +12 -3
- package/lib/Breadcrumbs/styles.css +1 -1
- package/lib/Button/styles.css +1 -1
- package/lib/ButtonGroup/styles.css +1 -1
- package/lib/ButtonV2/styles.css +1 -1
- package/lib/Calendar/Calendar.cjs +2 -2
- package/lib/Calendar/Calendar.mjs +2 -2
- package/lib/Calendar/styles.css +1 -1
- package/lib/CardFooter/styles.css +1 -1
- package/lib/CardHeading/styles.css +1 -1
- package/lib/Carousel/Carousel.cjs +11 -5
- package/lib/Carousel/Carousel.mjs +8 -2
- package/lib/Carousel/styles.css +1 -1
- package/lib/Checkbox/Checkbox.cjs +85 -11
- package/lib/Checkbox/Checkbox.mjs +87 -9
- package/lib/Checkbox/styles.css +1 -1
- package/lib/Columns/styles.css +1 -1
- package/lib/ComboBox/ComboBox.cjs +276 -11
- package/lib/ComboBox/ComboBox.mjs +279 -10
- package/lib/ComboBox/styles.css +1 -1
- package/lib/ContentSwitcher/ContentSwitcher.cjs +5 -6
- package/lib/ContentSwitcher/ContentSwitcher.mjs +5 -6
- package/lib/ContentSwitcher/styles.css +1 -1
- package/lib/ContentSwitcherDropdown/styles.css +1 -1
- package/lib/DatePicker/DatePicker.cjs +351 -38
- package/lib/DatePicker/DatePicker.mjs +329 -17
- package/lib/DatePicker/styles.css +1 -1
- package/lib/Disclosure/styles.css +1 -1
- package/lib/DisclosureMini/styles.css +1 -1
- package/lib/Download/styles.css +1 -1
- package/lib/Drawer/styles.css +1 -1
- package/lib/Elevation/styles.css +1 -1
- package/lib/Filter/styles.css +1 -1
- package/lib/FormControl/styles.css +1 -1
- package/lib/GhostedHeroBanner/styles.css +1 -1
- package/lib/GradientPageBackground/GradientPageBackground.cjs +55 -43
- package/lib/GradientPageBackground/GradientPageBackground.mjs +55 -43
- package/lib/GradientPageBackground/styles.css +1 -1
- package/lib/Grid/styles.css +1 -1
- package/lib/Group/styles.css +1 -1
- package/lib/Heading/styles.css +1 -1
- package/lib/HeroBanner/HeroBanner.cjs +1 -1
- package/lib/HeroBanner/HeroBanner.mjs +1 -1
- package/lib/HeroBanner/styles.css +1 -1
- package/lib/HeroButton/HeroButton.cjs +77 -9
- package/lib/HeroButton/HeroButton.mjs +80 -8
- package/lib/HeroButton/styles.css +1 -1
- package/lib/Hidden/styles.css +1 -1
- package/lib/HorizontalCard/styles.css +1 -1
- package/lib/Icon/styles.css +1 -1
- package/lib/Image/styles.css +1 -1
- package/lib/ImpactCard/ImpactCard.cjs +3 -3
- package/lib/ImpactCard/ImpactCard.mjs +3 -3
- package/lib/ImpactCard/styles.css +1 -1
- package/lib/InformationCard/InformationCard.cjs +6 -6
- package/lib/InformationCard/InformationCard.mjs +6 -6
- package/lib/InformationCard/styles.css +1 -1
- package/lib/Link/Link.cjs +1 -1
- package/lib/Link/Link.mjs +1 -1
- package/lib/Link/styles.css +1 -1
- package/lib/Markup/styles.css +1 -1
- package/lib/MediaCard/MediaCard.cjs +53 -14
- package/lib/MediaCard/MediaCard.mjs +55 -12
- package/lib/MediaCard/styles.css +1 -1
- package/lib/Menu/Menu.cjs +1327 -25
- package/lib/Menu/Menu.mjs +1292 -9
- package/lib/Menu/styles.css +1 -1
- package/lib/Modal/styles.css +1 -1
- package/lib/NavigationHeader/NavigationHeader.cjs +743 -16
- package/lib/NavigationHeader/NavigationHeader.mjs +734 -7
- package/lib/NavigationHeader/styles.css +1 -1
- package/lib/Pagination/styles.css +1 -1
- package/lib/PaginationSimple/styles.css +1 -1
- package/lib/Popover/styles.css +1 -1
- package/lib/Poster/styles.css +1 -1
- package/lib/ProgressBar/styles.css +1 -1
- package/lib/ProgressStepper/styles.css +1 -1
- package/lib/ProgressStepperOverflow/ProgressStepperOverflow.cjs +138 -7
- package/lib/ProgressStepperOverflow/ProgressStepperOverflow.mjs +140 -5
- package/lib/ProgressStepperOverflow/styles.css +1 -1
- package/lib/RadioCardGroup/RadioCardGroup.cjs +48 -7
- package/lib/RadioCardGroup/RadioCardGroup.mjs +48 -8
- package/lib/RadioCardGroup/styles.css +1 -1
- package/lib/RadioGroup/RadioGroup.cjs +50 -8
- package/lib/RadioGroup/RadioGroup.mjs +49 -8
- package/lib/RadioGroup/styles.css +1 -1
- package/lib/Rule/styles.css +1 -1
- package/lib/ScrollToTop/styles.css +1 -1
- package/lib/Section/Section.cjs +1 -1
- package/lib/Section/Section.mjs +1 -1
- package/lib/Section/styles.css +1 -1
- package/lib/Select/styles.css +1 -1
- package/lib/SiteFooter/SiteFooter.cjs +1 -1
- package/lib/SiteFooter/SiteFooter.mjs +1 -1
- package/lib/SiteFooter/styles.css +1 -1
- package/lib/SiteFooterV2/SiteFooterV2.cjs +6 -5
- package/lib/SiteFooterV2/SiteFooterV2.mjs +6 -5
- package/lib/SiteFooterV2/styles.css +1 -1
- package/lib/SiteHeaderV2/SiteHeaderV2.cjs +440 -15
- package/lib/SiteHeaderV2/SiteHeaderV2.mjs +435 -11
- package/lib/SiteHeaderV2/styles.css +1 -1
- package/lib/Skeleton/styles.css +1 -1
- package/lib/SkipLink/styles.css +1 -1
- package/lib/Spinner/styles.css +1 -1
- package/lib/Surface/styles.css +1 -1
- package/lib/Switch/styles.css +1 -1
- package/lib/TabbedBanner/TabbedBanner.cjs +4 -5
- package/lib/TabbedBanner/TabbedBanner.mjs +4 -5
- package/lib/TabbedBanner/styles.css +1 -1
- package/lib/Tabs/Tabs.mjs +1 -1
- package/lib/Tabs/styles.css +1 -1
- package/lib/Tag/Tag.cjs +9 -9
- package/lib/Tag/Tag.mjs +9 -9
- package/lib/Tag/styles.css +1 -1
- package/lib/TemplateBanner/TemplateBanner.cjs +1 -1
- package/lib/TemplateBanner/TemplateBanner.mjs +1 -1
- package/lib/TemplateBanner/styles.css +1 -1
- package/lib/Text/styles.css +1 -1
- package/lib/TextArea/TextArea.cjs +2 -53
- package/lib/TextArea/TextArea.mjs +2 -53
- package/lib/TextArea/styles.css +1 -1
- package/lib/TextInput/styles.css +1 -1
- package/lib/Theme/Theme.cjs +1 -1
- package/lib/Theme/Theme.mjs +1 -1
- package/lib/Theme/styles.css +1 -1
- package/lib/ThemeIcon/styles.css +1 -1
- package/lib/ThumbnailSignpost/styles.css +1 -1
- package/lib/Toast/styles.css +1 -1
- package/lib/Tooltip/styles.css +1 -1
- package/lib/Truncate/styles.css +1 -1
- package/lib/TypographyCard/TypographyCard.cjs +3 -3
- package/lib/TypographyCard/TypographyCard.mjs +3 -3
- package/lib/TypographyCard/styles.css +1 -1
- package/lib/UniversalHeader/styles.css +1 -1
- package/lib/VerticalSpace/styles.css +1 -1
- package/lib/VideoPlayer/styles.css +1 -1
- package/lib/Visible/styles.css +1 -1
- package/lib/VisuallyHidden/styles.css +1 -1
- package/lib/_shared/cjs/{Calendar-B-va25n2.cjs → Calendar-Bfdgf5q1.cjs} +1 -1
- package/lib/_shared/cjs/{ContentSwitcherList-bCEzIPN2.cjs → ContentSwitcherList-pcYtuT6L.cjs} +8 -0
- package/lib/_shared/cjs/{Link-7xUgVf1I.cjs → Link-C3OSQIIk.cjs} +3 -1
- package/lib/_shared/cjs/{Section-wUVdzmGA.cjs → Section-Bz2fwj8Z.cjs} +2 -2
- package/lib/_shared/cjs/{TemplateBanner-CImrJ9ON.cjs → TemplateBanner-COymAI91.cjs} +2 -2
- package/lib/_shared/cjs/{arc-breakpoints-DWUgmeLA.cjs → arc-breakpoints-CS8JVk5T.cjs} +1 -1
- package/lib/_shared/cjs/{index.es-DlNskPlN.cjs → index.es-fkulh7qu.cjs} +1 -1
- package/lib/_shared/esm/{Calendar-Bd2_eT1Y.mjs → Calendar-Drh_NJ9I.mjs} +1 -1
- package/lib/_shared/esm/{ContentSwitcherList-bCQz0qkU.mjs → ContentSwitcherList-DwHfU3no.mjs} +10 -3
- package/lib/_shared/esm/{Link-Biyg9qBH.mjs → Link-DxjGH_7f.mjs} +3 -1
- package/lib/_shared/esm/{Section-DDygQ5Az.mjs → Section-7InCvzfh.mjs} +2 -2
- package/lib/_shared/esm/{TemplateBanner-DeHjliNP.mjs → TemplateBanner-Dkgzu3A5.mjs} +2 -2
- package/lib/_shared/esm/{arc-breakpoints-D5hR5m3t.mjs → arc-breakpoints-D7Ie4kBt.mjs} +1 -1
- package/lib/_shared/esm/{index-BDWwJ5x2.mjs → index-BWkI4Dwz.mjs} +1 -1
- package/lib/_shared/esm/{index.es-C3WqfFKH.mjs → index.es-CtRkzfKP.mjs} +2 -2
- package/lib/index.cjs +300 -283
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +28 -3
- package/lib/index.d.mts +28 -3
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +301 -284
- package/lib/index.mjs.map +1 -1
- package/lib/styles.css +10 -10
- package/package.json +8 -8
- package/lib/_shared/cjs/BreadcrumbsLink-CDmk3Y3m.cjs +0 -18
- package/lib/_shared/cjs/Checkbox-DfZMjO1Y.cjs +0 -88
- package/lib/_shared/cjs/ComboBox-BGUhlqx1.cjs +0 -281
- package/lib/_shared/cjs/ContentSwitcherTab-B387Qs3I.cjs +0 -14
- package/lib/_shared/cjs/DatePicker-Dt4faA_N.cjs +0 -334
- package/lib/_shared/cjs/HeroButton-CrzkTUwP.cjs +0 -82
- package/lib/_shared/cjs/MediaCard-BEZFbiYO.cjs +0 -57
- package/lib/_shared/cjs/MenuItemMultiLevelContent-vLr6hSBm.cjs +0 -1328
- package/lib/_shared/cjs/ProgressStepperOverflow-BAGZNC26.cjs +0 -142
- package/lib/_shared/cjs/RadioCardGroupInput-CeUM3yPS.cjs +0 -53
- package/lib/_shared/cjs/RadioGroupInput-w2qkfsnG.cjs +0 -54
- package/lib/_shared/cjs/SiteHeaderV2NavItemWithSubNav-CagFKPEa.cjs +0 -445
- package/lib/_shared/cjs/kebabCase-D5yA6u-V.cjs +0 -743
- package/lib/_shared/cjs/keynames-Cx13-hWr.cjs +0 -8
- package/lib/_shared/esm/BreadcrumbsLink-BxTurGNa.mjs +0 -16
- package/lib/_shared/esm/Checkbox-CwOHzlQF.mjs +0 -86
- package/lib/_shared/esm/ComboBox-CRlJjeev.mjs +0 -279
- package/lib/_shared/esm/ContentSwitcherTab-CfC3PGeZ.mjs +0 -12
- package/lib/_shared/esm/DatePicker-DT4OEzxP.mjs +0 -324
- package/lib/_shared/esm/HeroButton-jdjjV_Gf.mjs +0 -80
- package/lib/_shared/esm/MediaCard-DqMaNWsE.mjs +0 -55
- package/lib/_shared/esm/MenuItemMultiLevelContent-JTOHqpzg.mjs +0 -1296
- package/lib/_shared/esm/ProgressStepperOverflow-fPkLltVO.mjs +0 -140
- package/lib/_shared/esm/RadioCardGroupInput-D7W28geB.mjs +0 -50
- package/lib/_shared/esm/RadioGroupInput-zAWSV29m.mjs +0 -50
- package/lib/_shared/esm/SiteHeaderV2NavItemWithSubNav-CxGwdV6u.mjs +0 -439
- package/lib/_shared/esm/kebabCase-CCEMRBfd.mjs +0 -737
- package/lib/_shared/esm/keynames-B5whqsjh.mjs +0 -8
|
@@ -1,29 +1,294 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('
|
|
6
|
-
require('
|
|
7
|
-
require('../_shared/cjs/index-
|
|
4
|
+
var filterAttrs = require('../_shared/cjs/filter-attrs-eK6E_34o.cjs');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var index$2 = require('../_shared/cjs/index-CaO6cOF0.cjs');
|
|
7
|
+
var index$1 = require('../_shared/cjs/index-CTlXMLug.cjs');
|
|
8
|
+
var FormControl = require('../_shared/cjs/FormControl-BPnKQrCm.cjs');
|
|
9
|
+
var index = require('../_shared/cjs/index-DXNM3D1d.cjs');
|
|
10
|
+
var Box = require('../_shared/cjs/Box-COPXU1Jf.cjs');
|
|
11
|
+
var Icon = require('../_shared/cjs/Icon-CzhyKqMd.cjs');
|
|
12
|
+
var ThemeIcon = require('../_shared/cjs/ThemeIcon-BoxbjTaQ.cjs');
|
|
8
13
|
require('../_shared/cjs/Combination-B-rSVLfT.cjs');
|
|
9
|
-
require('../_shared/cjs/index-DXNM3D1d.cjs');
|
|
10
14
|
require('react/jsx-runtime');
|
|
11
15
|
require('react-dom');
|
|
12
16
|
require('../_shared/cjs/index-Bt7hfZBc.cjs');
|
|
13
17
|
require('../_shared/cjs/index-B11wQrRa.cjs');
|
|
14
18
|
require('../_shared/cjs/index-Dv1xvB_E.cjs');
|
|
15
|
-
require('../_shared/cjs/index-CTlXMLug.cjs');
|
|
16
|
-
require('../_shared/cjs/FormControl-BPnKQrCm.cjs');
|
|
17
19
|
require('../_shared/cjs/Surface-BFx1yNsq.cjs');
|
|
18
20
|
require('../_shared/cjs/index-DR8Rkav9.cjs');
|
|
19
21
|
require('../_shared/cjs/DisclosureMini-CtvDxVaG.cjs');
|
|
20
22
|
require('../_shared/cjs/Text-Cr5nmYmx.cjs');
|
|
21
23
|
require('../_shared/cjs/suffix-modifier-DLUGR-yG.cjs');
|
|
22
|
-
require('../_shared/cjs/ThemeIcon-BoxbjTaQ.cjs');
|
|
23
24
|
require('../_shared/cjs/VisuallyHidden-B4XCvPYP.cjs');
|
|
24
|
-
require('../_shared/cjs/Box-COPXU1Jf.cjs');
|
|
25
|
-
require('../_shared/cjs/Icon-CzhyKqMd.cjs');
|
|
26
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Do not edit directly
|
|
28
|
+
* Generated file
|
|
29
|
+
*/
|
|
27
30
|
|
|
31
|
+
const BtIconChevronDown2Px =
|
|
32
|
+
"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3e%3cpath fill='currentColor' d='M15.993 23.914 2.294 10.207a1 1 0 1 1 1.414-1.414l12.285 12.293L28.292 8.793a1 1 0 1 1 1.414 1.414Z'/%3e%3c/svg%3e";
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
var filterOptions = function (options, value) {
|
|
35
|
+
return options.filter(function (option) {
|
|
36
|
+
return value ? option.toLowerCase().includes(value.toLowerCase()) : true;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var getSelectedOptions = function (option, selectedOptions) {
|
|
40
|
+
return selectedOptions.indexOf(option) !== -1
|
|
41
|
+
? selectedOptions.filter(function (selectedOption) { return selectedOption !== option; })
|
|
42
|
+
: filterAttrs.__spreadArray(filterAttrs.__spreadArray([], selectedOptions, true), [option], false);
|
|
43
|
+
};
|
|
44
|
+
var findOptionIndex = function (options, searchOption) {
|
|
45
|
+
return options.findIndex(function (option) { return option === searchOption; });
|
|
46
|
+
};
|
|
47
|
+
var isSelected = function (option, selectedOptions) {
|
|
48
|
+
return selectedOptions.some(function (selectedOption) { return option === selectedOption; });
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var reducer = function (initialOptions) {
|
|
52
|
+
return function (state, action) {
|
|
53
|
+
switch (action.type) {
|
|
54
|
+
case "OPEN": {
|
|
55
|
+
var isMultiSelectable = action.payload.isMultiSelectable;
|
|
56
|
+
var selectedOptions = state.selectedOptions, options = state.options;
|
|
57
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
58
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
59
|
+
: 0 });
|
|
60
|
+
}
|
|
61
|
+
case "CLOSE": {
|
|
62
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: false, highlightedOptionIndex: 0 });
|
|
63
|
+
}
|
|
64
|
+
case "INPUT_CHANGE": {
|
|
65
|
+
var _a = action.payload, value = _a.value, isAutocomplete = _a.isAutocomplete;
|
|
66
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { value: value, options: isAutocomplete
|
|
67
|
+
? filterOptions(initialOptions, value)
|
|
68
|
+
: state.options, highlightedOptionIndex: 0, isExpanded: true });
|
|
69
|
+
}
|
|
70
|
+
case "SINGLE_SELECT": {
|
|
71
|
+
var _b = action.payload, selectedOption = _b.option, isAutocomplete = _b.isAutocomplete;
|
|
72
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: false, options: isAutocomplete
|
|
73
|
+
? filterOptions(initialOptions, selectedOption)
|
|
74
|
+
: state.options, value: selectedOption });
|
|
75
|
+
}
|
|
76
|
+
case "MULTI_SELECT": {
|
|
77
|
+
var selectedOption = action.payload.option;
|
|
78
|
+
var selectedOptions = state.selectedOptions, options = state.options;
|
|
79
|
+
var newSelectedOptions = getSelectedOptions(selectedOption, selectedOptions);
|
|
80
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { value: "", options: initialOptions, highlightedOptionIndex: findOptionIndex(options, selectedOption), selectedOptions: newSelectedOptions });
|
|
81
|
+
}
|
|
82
|
+
case "MULTI_SELECT_REMOVE": {
|
|
83
|
+
var option_1 = action.payload.option;
|
|
84
|
+
var selectedOptions = state.selectedOptions;
|
|
85
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { selectedOptions: selectedOptions.filter(function (selectedOption) { return option_1 !== selectedOption; }) });
|
|
86
|
+
}
|
|
87
|
+
case "KEYDOWN": {
|
|
88
|
+
var _c = action.payload, key = _c.key, isAutocomplete = _c.isAutocomplete, isMultiSelectable = _c.isMultiSelectable;
|
|
89
|
+
var isExpanded = state.isExpanded, highlightedOptionIndex = state.highlightedOptionIndex, options = state.options, selectedOptions = state.selectedOptions;
|
|
90
|
+
if (key === "Escape" && isExpanded) {
|
|
91
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: false, highlightedOptionIndex: 0 });
|
|
92
|
+
}
|
|
93
|
+
if (key === "ArrowDown" && isExpanded) {
|
|
94
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { highlightedOptionIndex: highlightedOptionIndex === options.length - 1
|
|
95
|
+
? 0
|
|
96
|
+
: highlightedOptionIndex + 1 });
|
|
97
|
+
}
|
|
98
|
+
if (key === "ArrowUp" && isExpanded) {
|
|
99
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { highlightedOptionIndex: highlightedOptionIndex === 0
|
|
100
|
+
? options.length - 1
|
|
101
|
+
: highlightedOptionIndex - 1 });
|
|
102
|
+
}
|
|
103
|
+
if (key === "ArrowDown" && !isExpanded) {
|
|
104
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
105
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
106
|
+
: 0 });
|
|
107
|
+
}
|
|
108
|
+
if (key === "ArrowUp" && !isExpanded) {
|
|
109
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
110
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
111
|
+
: options.length - 1 });
|
|
112
|
+
}
|
|
113
|
+
if (key === "Enter" && isExpanded) {
|
|
114
|
+
if (isMultiSelectable) {
|
|
115
|
+
var newSelectedOptionIds = getSelectedOptions(options[highlightedOptionIndex], selectedOptions);
|
|
116
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { value: "", options: initialOptions, selectedOptions: newSelectedOptionIds });
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return filterAttrs.__assign(filterAttrs.__assign({}, state), { isExpanded: false, options: isAutocomplete
|
|
120
|
+
? filterOptions(initialOptions, options[highlightedOptionIndex])
|
|
121
|
+
: options, value: options[highlightedOptionIndex] });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return state;
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
return state;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var ComboBox = React.forwardRef(function (_a, ref) {
|
|
133
|
+
var name = _a.name, onBlur = _a.onBlur, onFocus = _a.onFocus, label = _a.label, helper = _a.helper, id = _a.id, initialOptions = _a.options, hideLabel = _a.hideLabel, isFluid = _a.isFluid, errorMessage = _a.errorMessage, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, listBoxAriaLabel = _a.listBoxAriaLabel, _b = _a.defaultValue, defaultValue = _b === void 0 ? "" : _b, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, _d = _a.isMultiSelectable, isMultiSelectable = _d === void 0 ? false : _d, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, _f = _a.isRequired, isRequired = _f === void 0 ? false : _f, _g = _a.isAutocomplete, isAutocomplete = _g === void 0 ? false : _g, props = filterAttrs.__rest(_a, ["name", "onBlur", "onFocus", "label", "helper", "id", "options", "hideLabel", "isFluid", "errorMessage", "disclosureTitle", "disclosureText", "onClickDisclosure", "listBoxAriaLabel", "defaultValue", "labelSize", "isMultiSelectable", "isDisabled", "isRequired", "isAutocomplete"]);
|
|
134
|
+
var listBoxId = React.useId();
|
|
135
|
+
var listItemRefs = React.useRef([]);
|
|
136
|
+
var containerRef = React.useRef(null);
|
|
137
|
+
var inputRef = React.useRef(null);
|
|
138
|
+
var _h = index.useThemeElement(), themeElement = _h[0], setThemeElement = _h[1];
|
|
139
|
+
var _j = React.useReducer(reducer(initialOptions), {
|
|
140
|
+
isExpanded: false,
|
|
141
|
+
value: defaultValue,
|
|
142
|
+
options: initialOptions,
|
|
143
|
+
highlightedOptionIndex: 0,
|
|
144
|
+
selectedOptions: [],
|
|
145
|
+
}), _k = _j[0], isExpanded = _k.isExpanded, value = _k.value, options = _k.options, highlightedOptionIndex = _k.highlightedOptionIndex, selectedOptions = _k.selectedOptions, dispatch = _j[1];
|
|
146
|
+
var ariaDescribedby = FormControl.useAriaDescribedby({
|
|
147
|
+
errorMessage: errorMessage,
|
|
148
|
+
id: id,
|
|
149
|
+
helper: helper,
|
|
150
|
+
disclosureText: disclosureText,
|
|
151
|
+
}).ariaDescribedby;
|
|
152
|
+
var getTextInputRef = function (elementRef) {
|
|
153
|
+
inputRef.current = elementRef;
|
|
154
|
+
if (ref && typeof ref === "object") {
|
|
155
|
+
ref.current = elementRef;
|
|
156
|
+
}
|
|
157
|
+
if (ref && typeof ref === "function") {
|
|
158
|
+
ref(elementRef);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var setScrollPosition = function (listEl) {
|
|
162
|
+
var listItemEl = listItemRefs.current[highlightedOptionIndex];
|
|
163
|
+
if (listItemEl && listEl) {
|
|
164
|
+
var selectedOptionIsBelowOverFlow = listItemEl.offsetTop + listItemEl.offsetHeight >
|
|
165
|
+
listEl.offsetHeight + listEl.scrollTop;
|
|
166
|
+
var selectedOptionIsAboveOverFlow = listItemEl.offsetTop < listEl.scrollTop;
|
|
167
|
+
if (selectedOptionIsBelowOverFlow) {
|
|
168
|
+
listEl.scrollTop =
|
|
169
|
+
listItemEl.offsetTop +
|
|
170
|
+
listItemEl.offsetHeight -
|
|
171
|
+
listEl.offsetHeight;
|
|
172
|
+
}
|
|
173
|
+
if (selectedOptionIsAboveOverFlow) {
|
|
174
|
+
listEl.scrollTop = listItemEl.offsetTop;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
var onItemClick = function (itemOption) {
|
|
179
|
+
return function (e) {
|
|
180
|
+
var _a;
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
if (isMultiSelectable) {
|
|
183
|
+
dispatch({
|
|
184
|
+
type: "MULTI_SELECT",
|
|
185
|
+
payload: {
|
|
186
|
+
option: itemOption,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
dispatch({
|
|
192
|
+
type: "SINGLE_SELECT",
|
|
193
|
+
payload: {
|
|
194
|
+
isAutocomplete: isAutocomplete,
|
|
195
|
+
option: itemOption,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
var onInputChange = function (e) {
|
|
203
|
+
dispatch({
|
|
204
|
+
type: "INPUT_CHANGE",
|
|
205
|
+
payload: {
|
|
206
|
+
isAutocomplete: isAutocomplete,
|
|
207
|
+
value: e.target.value,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
var onInputClick = function () {
|
|
212
|
+
isAutocomplete &&
|
|
213
|
+
dispatch({
|
|
214
|
+
type: "OPEN",
|
|
215
|
+
payload: {
|
|
216
|
+
isMultiSelectable: isMultiSelectable,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
var onInteractOutside = function (e) {
|
|
221
|
+
if (containerRef.current &&
|
|
222
|
+
!containerRef.current.contains(e.currentTarget)) {
|
|
223
|
+
dispatch({
|
|
224
|
+
type: "CLOSE",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var onInputKeyDown = function (e) {
|
|
229
|
+
dispatch({
|
|
230
|
+
type: "KEYDOWN",
|
|
231
|
+
payload: {
|
|
232
|
+
key: e.key,
|
|
233
|
+
isAutocomplete: isAutocomplete,
|
|
234
|
+
isMultiSelectable: isMultiSelectable,
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
var onMultiSelectRemove = function (option) { return function (e) {
|
|
239
|
+
var _a;
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
e.stopPropagation();
|
|
242
|
+
dispatch({
|
|
243
|
+
type: "MULTI_SELECT_REMOVE",
|
|
244
|
+
payload: {
|
|
245
|
+
option: option,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
249
|
+
}; };
|
|
250
|
+
var onOpenAutoFocus = function (e) {
|
|
251
|
+
var _a;
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
254
|
+
};
|
|
255
|
+
return (React.createElement("div", { ref: setThemeElement, className: index$1.classNames("arc-ComboBox", {
|
|
256
|
+
"arc-ComboBox--constrained": !isFluid,
|
|
257
|
+
}) },
|
|
258
|
+
React.createElement("div", { ref: containerRef },
|
|
259
|
+
React.createElement(index$2.Root2, { open: isExpanded },
|
|
260
|
+
React.createElement(FormControl.FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, isDisabled: isDisabled, label: label, hideLabel: hideLabel, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", disclosureTitle: disclosureTitle, disclosureText: disclosureText, onClickDisclosure: onClickDisclosure },
|
|
261
|
+
React.createElement("div", { onClick: onInputClick, className: index$1.classNames("arc-ComboBox-container", {
|
|
262
|
+
"arc-ComboBox-container--cursor": isAutocomplete,
|
|
263
|
+
}) },
|
|
264
|
+
React.createElement("div", { className: index$1.classNames("arc-ComboBox-inputWrapper", {
|
|
265
|
+
"arc-ComboBox-inputWrapper--multiSelect": isMultiSelectable,
|
|
266
|
+
}) },
|
|
267
|
+
selectedOptions.length > 0 &&
|
|
268
|
+
selectedOptions.map(function (option, i) { return (React.createElement("div", { className: "arc-ComboBox-tag", key: "".concat(listBoxId, "-selectedOption-").concat(i) },
|
|
269
|
+
React.createElement("span", null, option),
|
|
270
|
+
React.createElement("button", { className: "arc-ComboBox-tagButton", "aria-label": "".concat(option, ", press space or enter to remove"), onClick: onMultiSelectRemove(option) },
|
|
271
|
+
React.createElement(ThemeIcon.ThemeIcon, { icon: "tagRemove", color: "brand", size: 20 })))); }),
|
|
272
|
+
React.createElement("input", filterAttrs.__assign({ className: "arc-ComboBox-input", ref: getTextInputRef, "aria-describedby": ariaDescribedby, "aria-invalid": errorMessage ? "true" : "false", type: "text", role: "combobox", autoComplete: "off", "aria-autocomplete": "list", "aria-controls": listBoxId, "aria-expanded": isExpanded, "aria-activedescendant": highlightedOptionIndex
|
|
273
|
+
? "".concat(listBoxId, "-").concat(highlightedOptionIndex)
|
|
274
|
+
: undefined, id: id, name: name, onFocus: onFocus, onBlur: onBlur, onChange: onInputChange, onKeyDown: onInputKeyDown, disabled: isDisabled, required: isRequired, value: value }, filterAttrs.filterAttrs(props)))),
|
|
275
|
+
isAutocomplete && (React.createElement("div", { className: index$1.classNames("arc-ComboBox-inputIcon", {
|
|
276
|
+
"arc-ComboBox-inputIcon--expanded": isExpanded,
|
|
277
|
+
}) },
|
|
278
|
+
React.createElement(Icon.Icon, { icon: BtIconChevronDown2Px, size: 24 }))))),
|
|
279
|
+
React.createElement(index$2.Anchor2, null),
|
|
280
|
+
React.createElement(index$2.Portal, { container: themeElement },
|
|
281
|
+
React.createElement(index$2.Content2, { align: "start", sideOffset: 5, onInteractOutside: onInteractOutside, onOpenAutoFocus: onOpenAutoFocus },
|
|
282
|
+
React.createElement("div", { className: "arc-ComboBox-listboxContainer" },
|
|
283
|
+
React.createElement(Box.Box, { elevationLevel: "1" },
|
|
284
|
+
React.createElement("ul", { ref: setScrollPosition, id: listBoxId, className: "arc-ComboBox-list", role: "listbox", "aria-label": listBoxAriaLabel, "aria-multiselectable": isMultiSelectable }, options.length ? (options.map(function (option, i) { return (React.createElement("li", { id: "".concat(listBoxId, "-").concat(i), ref: function (el) { return (listItemRefs.current[i] = el); }, key: option, className: index$1.classNames("arc-ComboBox-listItem", {
|
|
285
|
+
"arc-ComboBox-listItem--highlighted": i === highlightedOptionIndex,
|
|
286
|
+
}), onMouseDown: onItemClick(option), role: "option", "aria-selected": isSelected(option, selectedOptions) },
|
|
287
|
+
React.createElement("div", { className: "arc-ComboBox-listItemText" }, option),
|
|
288
|
+
React.createElement("div", { className: index$1.classNames("arc-ComboBox-listItemIcon", {
|
|
289
|
+
"arc-ComboBox-listItemIcon--visible": isSelected(option, selectedOptions),
|
|
290
|
+
}) },
|
|
291
|
+
React.createElement(ThemeIcon.ThemeIcon, { size: 20, icon: "selectIndicator" })))); })) : (React.createElement("li", { className: "arc-ComboBox-listItem", role: "option", "aria-selected": false, "aria-disabled": true }, "No matches found")))))))))));
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
exports.ComboBox = ComboBox;
|
|
@@ -1,23 +1,292 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
5
|
-
import '../_shared/esm/index-
|
|
2
|
+
import { b as __spreadArray, a as __assign, _ as __rest, f as filterAttrs } from '../_shared/esm/filter-attrs-B6CM-NUr.mjs';
|
|
3
|
+
import React__default, { forwardRef, useId, useRef, useReducer } from 'react';
|
|
4
|
+
import { R as Root2, A as Anchor2, P as Portal, C as Content2 } from '../_shared/esm/index-CxrL7jIX.mjs';
|
|
5
|
+
import { c as classNames } from '../_shared/esm/index-5C0-U8cc.mjs';
|
|
6
|
+
import { u as useAriaDescribedby, F as FormControl } from '../_shared/esm/FormControl-CWyrVi1u.mjs';
|
|
7
|
+
import { e as useThemeElement } from '../_shared/esm/index-Bz2JQq34.mjs';
|
|
8
|
+
import { B as Box } from '../_shared/esm/Box-BYm_GTct.mjs';
|
|
9
|
+
import { I as Icon } from '../_shared/esm/Icon-CcPOJcQm.mjs';
|
|
10
|
+
import { T as ThemeIcon } from '../_shared/esm/ThemeIcon-CN_Ed5b1.mjs';
|
|
6
11
|
import '../_shared/esm/Combination-BpO6XTeS.mjs';
|
|
7
|
-
import '../_shared/esm/index-Bz2JQq34.mjs';
|
|
8
12
|
import 'react/jsx-runtime';
|
|
9
13
|
import 'react-dom';
|
|
10
14
|
import '../_shared/esm/index-DLovItWo.mjs';
|
|
11
15
|
import '../_shared/esm/index-CWHcEz3_.mjs';
|
|
12
16
|
import '../_shared/esm/index-DXTwueLZ.mjs';
|
|
13
|
-
import '../_shared/esm/index-5C0-U8cc.mjs';
|
|
14
|
-
import '../_shared/esm/FormControl-CWyrVi1u.mjs';
|
|
15
17
|
import '../_shared/esm/Surface-Colbp3Zx.mjs';
|
|
16
18
|
import '../_shared/esm/index-Spae4j7j.mjs';
|
|
17
19
|
import '../_shared/esm/DisclosureMini-B9LzsQC2.mjs';
|
|
18
20
|
import '../_shared/esm/Text-CBlnm5CT.mjs';
|
|
19
21
|
import '../_shared/esm/suffix-modifier-B_pO0UkF.mjs';
|
|
20
|
-
import '../_shared/esm/ThemeIcon-CN_Ed5b1.mjs';
|
|
21
22
|
import '../_shared/esm/VisuallyHidden-DqAgoqJo.mjs';
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Do not edit directly
|
|
26
|
+
* Generated file
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const BtIconChevronDown2Px =
|
|
30
|
+
"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3e%3cpath fill='currentColor' d='M15.993 23.914 2.294 10.207a1 1 0 1 1 1.414-1.414l12.285 12.293L28.292 8.793a1 1 0 1 1 1.414 1.414Z'/%3e%3c/svg%3e";
|
|
31
|
+
|
|
32
|
+
var filterOptions = function (options, value) {
|
|
33
|
+
return options.filter(function (option) {
|
|
34
|
+
return value ? option.toLowerCase().includes(value.toLowerCase()) : true;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var getSelectedOptions = function (option, selectedOptions) {
|
|
38
|
+
return selectedOptions.indexOf(option) !== -1
|
|
39
|
+
? selectedOptions.filter(function (selectedOption) { return selectedOption !== option; })
|
|
40
|
+
: __spreadArray(__spreadArray([], selectedOptions, true), [option], false);
|
|
41
|
+
};
|
|
42
|
+
var findOptionIndex = function (options, searchOption) {
|
|
43
|
+
return options.findIndex(function (option) { return option === searchOption; });
|
|
44
|
+
};
|
|
45
|
+
var isSelected = function (option, selectedOptions) {
|
|
46
|
+
return selectedOptions.some(function (selectedOption) { return option === selectedOption; });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
var reducer = function (initialOptions) {
|
|
50
|
+
return function (state, action) {
|
|
51
|
+
switch (action.type) {
|
|
52
|
+
case "OPEN": {
|
|
53
|
+
var isMultiSelectable = action.payload.isMultiSelectable;
|
|
54
|
+
var selectedOptions = state.selectedOptions, options = state.options;
|
|
55
|
+
return __assign(__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
56
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
57
|
+
: 0 });
|
|
58
|
+
}
|
|
59
|
+
case "CLOSE": {
|
|
60
|
+
return __assign(__assign({}, state), { isExpanded: false, highlightedOptionIndex: 0 });
|
|
61
|
+
}
|
|
62
|
+
case "INPUT_CHANGE": {
|
|
63
|
+
var _a = action.payload, value = _a.value, isAutocomplete = _a.isAutocomplete;
|
|
64
|
+
return __assign(__assign({}, state), { value: value, options: isAutocomplete
|
|
65
|
+
? filterOptions(initialOptions, value)
|
|
66
|
+
: state.options, highlightedOptionIndex: 0, isExpanded: true });
|
|
67
|
+
}
|
|
68
|
+
case "SINGLE_SELECT": {
|
|
69
|
+
var _b = action.payload, selectedOption = _b.option, isAutocomplete = _b.isAutocomplete;
|
|
70
|
+
return __assign(__assign({}, state), { isExpanded: false, options: isAutocomplete
|
|
71
|
+
? filterOptions(initialOptions, selectedOption)
|
|
72
|
+
: state.options, value: selectedOption });
|
|
73
|
+
}
|
|
74
|
+
case "MULTI_SELECT": {
|
|
75
|
+
var selectedOption = action.payload.option;
|
|
76
|
+
var selectedOptions = state.selectedOptions, options = state.options;
|
|
77
|
+
var newSelectedOptions = getSelectedOptions(selectedOption, selectedOptions);
|
|
78
|
+
return __assign(__assign({}, state), { value: "", options: initialOptions, highlightedOptionIndex: findOptionIndex(options, selectedOption), selectedOptions: newSelectedOptions });
|
|
79
|
+
}
|
|
80
|
+
case "MULTI_SELECT_REMOVE": {
|
|
81
|
+
var option_1 = action.payload.option;
|
|
82
|
+
var selectedOptions = state.selectedOptions;
|
|
83
|
+
return __assign(__assign({}, state), { selectedOptions: selectedOptions.filter(function (selectedOption) { return option_1 !== selectedOption; }) });
|
|
84
|
+
}
|
|
85
|
+
case "KEYDOWN": {
|
|
86
|
+
var _c = action.payload, key = _c.key, isAutocomplete = _c.isAutocomplete, isMultiSelectable = _c.isMultiSelectable;
|
|
87
|
+
var isExpanded = state.isExpanded, highlightedOptionIndex = state.highlightedOptionIndex, options = state.options, selectedOptions = state.selectedOptions;
|
|
88
|
+
if (key === "Escape" && isExpanded) {
|
|
89
|
+
return __assign(__assign({}, state), { isExpanded: false, highlightedOptionIndex: 0 });
|
|
90
|
+
}
|
|
91
|
+
if (key === "ArrowDown" && isExpanded) {
|
|
92
|
+
return __assign(__assign({}, state), { highlightedOptionIndex: highlightedOptionIndex === options.length - 1
|
|
93
|
+
? 0
|
|
94
|
+
: highlightedOptionIndex + 1 });
|
|
95
|
+
}
|
|
96
|
+
if (key === "ArrowUp" && isExpanded) {
|
|
97
|
+
return __assign(__assign({}, state), { highlightedOptionIndex: highlightedOptionIndex === 0
|
|
98
|
+
? options.length - 1
|
|
99
|
+
: highlightedOptionIndex - 1 });
|
|
100
|
+
}
|
|
101
|
+
if (key === "ArrowDown" && !isExpanded) {
|
|
102
|
+
return __assign(__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
103
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
104
|
+
: 0 });
|
|
105
|
+
}
|
|
106
|
+
if (key === "ArrowUp" && !isExpanded) {
|
|
107
|
+
return __assign(__assign({}, state), { isExpanded: true, highlightedOptionIndex: isMultiSelectable && selectedOptions.length
|
|
108
|
+
? findOptionIndex(options, selectedOptions[selectedOptions.length - 1])
|
|
109
|
+
: options.length - 1 });
|
|
110
|
+
}
|
|
111
|
+
if (key === "Enter" && isExpanded) {
|
|
112
|
+
if (isMultiSelectable) {
|
|
113
|
+
var newSelectedOptionIds = getSelectedOptions(options[highlightedOptionIndex], selectedOptions);
|
|
114
|
+
return __assign(__assign({}, state), { value: "", options: initialOptions, selectedOptions: newSelectedOptionIds });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return __assign(__assign({}, state), { isExpanded: false, options: isAutocomplete
|
|
118
|
+
? filterOptions(initialOptions, options[highlightedOptionIndex])
|
|
119
|
+
: options, value: options[highlightedOptionIndex] });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return state;
|
|
123
|
+
}
|
|
124
|
+
default:
|
|
125
|
+
return state;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var ComboBox = forwardRef(function (_a, ref) {
|
|
131
|
+
var name = _a.name, onBlur = _a.onBlur, onFocus = _a.onFocus, label = _a.label, helper = _a.helper, id = _a.id, initialOptions = _a.options, hideLabel = _a.hideLabel, isFluid = _a.isFluid, errorMessage = _a.errorMessage, disclosureTitle = _a.disclosureTitle, disclosureText = _a.disclosureText, onClickDisclosure = _a.onClickDisclosure, listBoxAriaLabel = _a.listBoxAriaLabel, _b = _a.defaultValue, defaultValue = _b === void 0 ? "" : _b, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, _d = _a.isMultiSelectable, isMultiSelectable = _d === void 0 ? false : _d, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, _f = _a.isRequired, isRequired = _f === void 0 ? false : _f, _g = _a.isAutocomplete, isAutocomplete = _g === void 0 ? false : _g, props = __rest(_a, ["name", "onBlur", "onFocus", "label", "helper", "id", "options", "hideLabel", "isFluid", "errorMessage", "disclosureTitle", "disclosureText", "onClickDisclosure", "listBoxAriaLabel", "defaultValue", "labelSize", "isMultiSelectable", "isDisabled", "isRequired", "isAutocomplete"]);
|
|
132
|
+
var listBoxId = useId();
|
|
133
|
+
var listItemRefs = useRef([]);
|
|
134
|
+
var containerRef = useRef(null);
|
|
135
|
+
var inputRef = useRef(null);
|
|
136
|
+
var _h = useThemeElement(), themeElement = _h[0], setThemeElement = _h[1];
|
|
137
|
+
var _j = useReducer(reducer(initialOptions), {
|
|
138
|
+
isExpanded: false,
|
|
139
|
+
value: defaultValue,
|
|
140
|
+
options: initialOptions,
|
|
141
|
+
highlightedOptionIndex: 0,
|
|
142
|
+
selectedOptions: [],
|
|
143
|
+
}), _k = _j[0], isExpanded = _k.isExpanded, value = _k.value, options = _k.options, highlightedOptionIndex = _k.highlightedOptionIndex, selectedOptions = _k.selectedOptions, dispatch = _j[1];
|
|
144
|
+
var ariaDescribedby = useAriaDescribedby({
|
|
145
|
+
errorMessage: errorMessage,
|
|
146
|
+
id: id,
|
|
147
|
+
helper: helper,
|
|
148
|
+
disclosureText: disclosureText,
|
|
149
|
+
}).ariaDescribedby;
|
|
150
|
+
var getTextInputRef = function (elementRef) {
|
|
151
|
+
inputRef.current = elementRef;
|
|
152
|
+
if (ref && typeof ref === "object") {
|
|
153
|
+
ref.current = elementRef;
|
|
154
|
+
}
|
|
155
|
+
if (ref && typeof ref === "function") {
|
|
156
|
+
ref(elementRef);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var setScrollPosition = function (listEl) {
|
|
160
|
+
var listItemEl = listItemRefs.current[highlightedOptionIndex];
|
|
161
|
+
if (listItemEl && listEl) {
|
|
162
|
+
var selectedOptionIsBelowOverFlow = listItemEl.offsetTop + listItemEl.offsetHeight >
|
|
163
|
+
listEl.offsetHeight + listEl.scrollTop;
|
|
164
|
+
var selectedOptionIsAboveOverFlow = listItemEl.offsetTop < listEl.scrollTop;
|
|
165
|
+
if (selectedOptionIsBelowOverFlow) {
|
|
166
|
+
listEl.scrollTop =
|
|
167
|
+
listItemEl.offsetTop +
|
|
168
|
+
listItemEl.offsetHeight -
|
|
169
|
+
listEl.offsetHeight;
|
|
170
|
+
}
|
|
171
|
+
if (selectedOptionIsAboveOverFlow) {
|
|
172
|
+
listEl.scrollTop = listItemEl.offsetTop;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var onItemClick = function (itemOption) {
|
|
177
|
+
return function (e) {
|
|
178
|
+
var _a;
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
if (isMultiSelectable) {
|
|
181
|
+
dispatch({
|
|
182
|
+
type: "MULTI_SELECT",
|
|
183
|
+
payload: {
|
|
184
|
+
option: itemOption,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
dispatch({
|
|
190
|
+
type: "SINGLE_SELECT",
|
|
191
|
+
payload: {
|
|
192
|
+
isAutocomplete: isAutocomplete,
|
|
193
|
+
option: itemOption,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
var onInputChange = function (e) {
|
|
201
|
+
dispatch({
|
|
202
|
+
type: "INPUT_CHANGE",
|
|
203
|
+
payload: {
|
|
204
|
+
isAutocomplete: isAutocomplete,
|
|
205
|
+
value: e.target.value,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
var onInputClick = function () {
|
|
210
|
+
isAutocomplete &&
|
|
211
|
+
dispatch({
|
|
212
|
+
type: "OPEN",
|
|
213
|
+
payload: {
|
|
214
|
+
isMultiSelectable: isMultiSelectable,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
var onInteractOutside = function (e) {
|
|
219
|
+
if (containerRef.current &&
|
|
220
|
+
!containerRef.current.contains(e.currentTarget)) {
|
|
221
|
+
dispatch({
|
|
222
|
+
type: "CLOSE",
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var onInputKeyDown = function (e) {
|
|
227
|
+
dispatch({
|
|
228
|
+
type: "KEYDOWN",
|
|
229
|
+
payload: {
|
|
230
|
+
key: e.key,
|
|
231
|
+
isAutocomplete: isAutocomplete,
|
|
232
|
+
isMultiSelectable: isMultiSelectable,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
var onMultiSelectRemove = function (option) { return function (e) {
|
|
237
|
+
var _a;
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
e.stopPropagation();
|
|
240
|
+
dispatch({
|
|
241
|
+
type: "MULTI_SELECT_REMOVE",
|
|
242
|
+
payload: {
|
|
243
|
+
option: option,
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
247
|
+
}; };
|
|
248
|
+
var onOpenAutoFocus = function (e) {
|
|
249
|
+
var _a;
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
252
|
+
};
|
|
253
|
+
return (React__default.createElement("div", { ref: setThemeElement, className: classNames("arc-ComboBox", {
|
|
254
|
+
"arc-ComboBox--constrained": !isFluid,
|
|
255
|
+
}) },
|
|
256
|
+
React__default.createElement("div", { ref: containerRef },
|
|
257
|
+
React__default.createElement(Root2, { open: isExpanded },
|
|
258
|
+
React__default.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, isDisabled: isDisabled, label: label, hideLabel: hideLabel, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional", disclosureTitle: disclosureTitle, disclosureText: disclosureText, onClickDisclosure: onClickDisclosure },
|
|
259
|
+
React__default.createElement("div", { onClick: onInputClick, className: classNames("arc-ComboBox-container", {
|
|
260
|
+
"arc-ComboBox-container--cursor": isAutocomplete,
|
|
261
|
+
}) },
|
|
262
|
+
React__default.createElement("div", { className: classNames("arc-ComboBox-inputWrapper", {
|
|
263
|
+
"arc-ComboBox-inputWrapper--multiSelect": isMultiSelectable,
|
|
264
|
+
}) },
|
|
265
|
+
selectedOptions.length > 0 &&
|
|
266
|
+
selectedOptions.map(function (option, i) { return (React__default.createElement("div", { className: "arc-ComboBox-tag", key: "".concat(listBoxId, "-selectedOption-").concat(i) },
|
|
267
|
+
React__default.createElement("span", null, option),
|
|
268
|
+
React__default.createElement("button", { className: "arc-ComboBox-tagButton", "aria-label": "".concat(option, ", press space or enter to remove"), onClick: onMultiSelectRemove(option) },
|
|
269
|
+
React__default.createElement(ThemeIcon, { icon: "tagRemove", color: "brand", size: 20 })))); }),
|
|
270
|
+
React__default.createElement("input", __assign({ className: "arc-ComboBox-input", ref: getTextInputRef, "aria-describedby": ariaDescribedby, "aria-invalid": errorMessage ? "true" : "false", type: "text", role: "combobox", autoComplete: "off", "aria-autocomplete": "list", "aria-controls": listBoxId, "aria-expanded": isExpanded, "aria-activedescendant": highlightedOptionIndex
|
|
271
|
+
? "".concat(listBoxId, "-").concat(highlightedOptionIndex)
|
|
272
|
+
: undefined, id: id, name: name, onFocus: onFocus, onBlur: onBlur, onChange: onInputChange, onKeyDown: onInputKeyDown, disabled: isDisabled, required: isRequired, value: value }, filterAttrs(props)))),
|
|
273
|
+
isAutocomplete && (React__default.createElement("div", { className: classNames("arc-ComboBox-inputIcon", {
|
|
274
|
+
"arc-ComboBox-inputIcon--expanded": isExpanded,
|
|
275
|
+
}) },
|
|
276
|
+
React__default.createElement(Icon, { icon: BtIconChevronDown2Px, size: 24 }))))),
|
|
277
|
+
React__default.createElement(Anchor2, null),
|
|
278
|
+
React__default.createElement(Portal, { container: themeElement },
|
|
279
|
+
React__default.createElement(Content2, { align: "start", sideOffset: 5, onInteractOutside: onInteractOutside, onOpenAutoFocus: onOpenAutoFocus },
|
|
280
|
+
React__default.createElement("div", { className: "arc-ComboBox-listboxContainer" },
|
|
281
|
+
React__default.createElement(Box, { elevationLevel: "1" },
|
|
282
|
+
React__default.createElement("ul", { ref: setScrollPosition, id: listBoxId, className: "arc-ComboBox-list", role: "listbox", "aria-label": listBoxAriaLabel, "aria-multiselectable": isMultiSelectable }, options.length ? (options.map(function (option, i) { return (React__default.createElement("li", { id: "".concat(listBoxId, "-").concat(i), ref: function (el) { return (listItemRefs.current[i] = el); }, key: option, className: classNames("arc-ComboBox-listItem", {
|
|
283
|
+
"arc-ComboBox-listItem--highlighted": i === highlightedOptionIndex,
|
|
284
|
+
}), onMouseDown: onItemClick(option), role: "option", "aria-selected": isSelected(option, selectedOptions) },
|
|
285
|
+
React__default.createElement("div", { className: "arc-ComboBox-listItemText" }, option),
|
|
286
|
+
React__default.createElement("div", { className: classNames("arc-ComboBox-listItemIcon", {
|
|
287
|
+
"arc-ComboBox-listItemIcon--visible": isSelected(option, selectedOptions),
|
|
288
|
+
}) },
|
|
289
|
+
React__default.createElement(ThemeIcon, { size: 20, icon: "selectIndicator" })))); })) : (React__default.createElement("li", { className: "arc-ComboBox-listItem", role: "option", "aria-selected": false, "aria-disabled": true }, "No matches found")))))))))));
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
export { ComboBox };
|
package/lib/ComboBox/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.arc-v12-0-0-beta-
|
|
1
|
+
.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listboxContainer{animation:listbox-slide-in 0.2s ease-out;transform-origin:var(--radix-popover-content-transform-origin)}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-list{border:none;list-style:none;margin:0;max-height:400px;overflow-y:auto;padding:0}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container{background-color:var(--textinput-colors-light-bg-default);border:var(--textinput-border-weight-s) solid var(--textinput-colors-light-border-default);border-radius:var(--textinput-border-radius-s);color:var(--textinput-colors-light-text-default);display:flex;margin-top:var(--textinput-gap-m);overflow:hidden}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;flex:1 1 auto;font:var(--sem-type-body-reg-m);height:var(--textinput-size-m);margin-bottom:0;padding:0 0 0 calc(var(--textinput-padding-m) - var(--textinput-border-weight-s))}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container--cursor,.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container--cursor .arc-ComboBox-input{cursor:pointer}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-inputWrapper{display:flex;flex:1 1 auto}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-input:focus{border:none;cursor:auto;outline:0}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container[\:has\(\:focus-visible\,\%20\:active\)]{box-shadow:0 0 0 var(--focus-border-weight-s) var(--focus-colors-light-border-subtle);outline:var(--focus-border-weight-s) solid transparent}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container[\:has\(\:focus-visible\,\:active\)]{box-shadow:0 0 0 var(--focus-border-weight-s) var(--focus-colors-light-border-subtle);outline:var(--focus-border-weight-s) solid transparent}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-container:has(:focus-visible,:active){box-shadow:0 0 0 var(--focus-border-weight-s) var(--focus-colors-light-border-subtle);outline:var(--focus-border-weight-s) solid transparent}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-inputIcon{align-items:center;display:flex;flex:0 0 auto;height:44px;justify-content:center;pointer-events:none;transition:0.2s ease-out transform;width:44px}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-inputIcon--expanded{transform:rotate(180deg)}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItem{align-items:center;cursor:pointer;display:flex;height:40px;line-height:1;padding:0 var(--sem-space-padding-60)}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItem--highlighted,.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItem:hover{background-color:var(--sem-color-bg-primary-light-minimal)}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-inputWrapper--multiSelect{flex-wrap:wrap}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItemText{flex:1 1 auto}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItemIcon{flex:0 1 auto;opacity:0;transition:0.2s ease-out opacity}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-listItemIcon--visible{opacity:1}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-tag{align-items:center;background:none;border-radius:var(--tag-border-radius-s);cursor:auto;display:flex;font:var(--sem-type-interface-semi-xs);height:24px;margin:8px 4px;outline:var(--tag-border-weight-s) solid var(--tag-colors-light-border-default-alt);padding:0 12px;white-space:nowrap}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-tagButton{background:none;border:none;cursor:pointer;margin:0 0 0 12px;outline:none;padding:0}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-tag[\:has\(\:focus-visible\)]{outline:2px solid var(--focus-colors-light-border-subtle)}.arc-v12-0-0-beta-23 .arc .arc-ComboBox-tag:has(:focus-visible){outline:2px solid var(--focus-colors-light-border-subtle)}@keyframes listbox-slide-in{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}
|