@itwin/itwinui-react 3.0.0-dev.1 → 3.0.0-dev.3
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 +25 -0
- package/cjs/core/Alert/Alert.d.ts +47 -28
- package/cjs/core/Alert/Alert.js +73 -21
- package/cjs/core/Avatar/Avatar.js +1 -1
- package/cjs/core/AvatarGroup/AvatarGroup.js +1 -1
- package/cjs/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/cjs/core/ButtonGroup/ButtonGroup.js +1 -4
- package/cjs/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/cjs/core/Carousel/Carousel.d.ts +2 -2
- package/cjs/core/Carousel/Carousel.js +3 -5
- package/cjs/core/Carousel/CarouselDotsList.js +8 -10
- package/cjs/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/cjs/core/Carousel/CarouselNavigation.js +3 -5
- package/cjs/core/Carousel/CarouselSlider.js +10 -15
- package/cjs/core/ColorPicker/ColorBuilder.js +7 -10
- package/cjs/core/ColorPicker/ColorInputPanel.js +12 -15
- package/cjs/core/ColorPicker/ColorPalette.js +4 -6
- package/cjs/core/ColorPicker/ColorPicker.js +3 -3
- package/cjs/core/ComboBox/ComboBox.js +25 -32
- package/cjs/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/cjs/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/cjs/core/ComboBox/ComboBoxInput.js +21 -20
- package/cjs/core/ComboBox/ComboBoxMenu.js +3 -4
- package/cjs/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/cjs/core/ComboBox/helpers.js +4 -5
- package/cjs/core/DatePicker/DatePicker.js +32 -32
- package/cjs/core/Dialog/Dialog.js +11 -4
- package/cjs/core/Dialog/DialogBackdrop.js +1 -1
- package/cjs/core/Dialog/DialogContext.d.ts +11 -0
- package/cjs/core/Dialog/DialogMain.js +16 -22
- package/cjs/core/DropdownMenu/DropdownMenu.js +6 -8
- package/cjs/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/cjs/core/FileUpload/FileEmptyCard.js +1 -1
- package/cjs/core/FileUpload/FileUpload.d.ts +3 -4
- package/cjs/core/FileUpload/FileUpload.js +5 -8
- package/cjs/core/FileUpload/FileUploadCard.js +9 -10
- package/cjs/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/cjs/core/FileUpload/FileUploadTemplate.js +1 -0
- package/cjs/core/InformationPanel/InformationPanel.js +1 -4
- package/cjs/core/LabeledInput/LabeledInput.js +1 -1
- package/cjs/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/cjs/core/Menu/Menu.js +3 -4
- package/cjs/core/Menu/MenuItem.js +8 -11
- package/cjs/core/Modal/Modal.d.ts +8 -9
- package/cjs/core/Modal/Modal.js +7 -17
- package/cjs/core/SearchBox/SearchBox.js +12 -12
- package/cjs/core/Select/Select.js +12 -17
- package/cjs/core/SideNavigation/SideNavigation.js +2 -2
- package/cjs/core/Slider/Slider.js +16 -19
- package/cjs/core/Slider/Thumb.js +1 -1
- package/cjs/core/StatusMessage/StatusMessage.js +1 -1
- package/cjs/core/Stepper/Stepper.js +1 -1
- package/cjs/core/Stepper/StepperStep.js +1 -1
- package/cjs/core/Table/Table.js +15 -15
- package/cjs/core/Table/TablePaginator.js +2 -3
- package/cjs/core/Table/TableRowMemoized.js +38 -45
- package/cjs/core/Table/actionHandlers/expandHandler.js +3 -3
- package/cjs/core/Table/actionHandlers/filterHandler.js +4 -5
- package/cjs/core/Table/actionHandlers/selectHandler.js +6 -6
- package/cjs/core/Table/cells/DefaultCell.js +1 -1
- package/cjs/core/Table/cells/EditableCell.js +6 -12
- package/cjs/core/Table/columns/actionColumn.js +3 -6
- package/cjs/core/Table/columns/expanderColumn.js +3 -3
- package/cjs/core/Table/columns/selectionColumn.js +4 -4
- package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/cjs/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/cjs/core/Table/hooks/useResizeColumns.js +16 -22
- package/cjs/core/Table/hooks/useScrollToRow.js +1 -2
- package/cjs/core/Table/hooks/useStickyColumns.js +3 -5
- package/cjs/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/cjs/core/Tabs/Tabs.js +13 -16
- package/cjs/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/cjs/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/cjs/core/ThemeProvider/ThemeProvider.js +14 -13
- package/cjs/core/Tile/Tile.js +2 -3
- package/cjs/core/TimePicker/TimePicker.js +13 -13
- package/cjs/core/Toast/Toast.d.ts +5 -10
- package/cjs/core/Toast/Toast.js +17 -16
- package/cjs/core/Toast/Toaster.d.ts +24 -26
- package/cjs/core/Toast/Toaster.js +91 -121
- package/cjs/core/Toast/index.d.ts +1 -4
- package/cjs/core/Toast/index.js +3 -6
- package/cjs/core/TransferList/TransferList.js +3 -4
- package/cjs/core/Tree/Tree.js +9 -13
- package/cjs/core/Tree/TreeNode.js +9 -10
- package/cjs/core/index.d.ts +1 -2
- package/cjs/core/index.js +2 -5
- package/cjs/core/utils/color/ColorValue.js +9 -15
- package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/cjs/core/utils/components/FocusTrap.js +4 -4
- package/cjs/core/utils/components/MiddleTextTruncation.js +1 -2
- package/cjs/core/utils/components/Popover.d.ts +1 -1
- package/cjs/core/utils/components/Popover.js +5 -8
- package/cjs/core/utils/components/Resizer.js +7 -6
- package/cjs/core/utils/components/VirtualScroll.js +14 -21
- package/cjs/core/utils/functions/dom.d.ts +0 -8
- package/cjs/core/utils/functions/dom.js +3 -26
- package/cjs/core/utils/functions/polymorphic.d.ts +1 -1
- package/cjs/core/utils/functions/polymorphic.js +1 -1
- package/cjs/core/utils/functions/supports.js +1 -1
- package/cjs/core/utils/hooks/index.d.ts +0 -1
- package/cjs/core/utils/hooks/index.js +0 -1
- package/cjs/core/utils/hooks/useContainerWidth.js +1 -1
- package/cjs/core/utils/hooks/useDragAndDrop.js +8 -10
- package/cjs/core/utils/hooks/useEventListener.js +1 -1
- package/cjs/core/utils/hooks/useGlobals.d.ts +9 -2
- package/cjs/core/utils/hooks/useGlobals.js +6 -4
- package/cjs/core/utils/hooks/useId.js +1 -2
- package/cjs/core/utils/hooks/useIntersection.js +2 -3
- package/cjs/core/utils/hooks/useMediaQuery.js +6 -8
- package/cjs/core/utils/hooks/useOverflow.js +1 -2
- package/cjs/core/utils/hooks/useResizeObserver.js +3 -4
- package/cjs/styles.js +1 -4
- package/esm/core/Alert/Alert.d.ts +47 -28
- package/esm/core/Alert/Alert.js +74 -22
- package/esm/core/Avatar/Avatar.js +1 -1
- package/esm/core/AvatarGroup/AvatarGroup.js +1 -1
- package/esm/core/Breadcrumbs/Breadcrumbs.js +2 -3
- package/esm/core/ButtonGroup/ButtonGroup.js +1 -4
- package/esm/core/Buttons/DropdownButton/DropdownButton.js +3 -5
- package/esm/core/Carousel/Carousel.d.ts +2 -2
- package/esm/core/Carousel/Carousel.js +3 -5
- package/esm/core/Carousel/CarouselDotsList.js +8 -10
- package/esm/core/Carousel/CarouselNavigation.d.ts +2 -2
- package/esm/core/Carousel/CarouselNavigation.js +3 -5
- package/esm/core/Carousel/CarouselSlider.js +10 -15
- package/esm/core/ColorPicker/ColorBuilder.js +7 -10
- package/esm/core/ColorPicker/ColorInputPanel.js +12 -15
- package/esm/core/ColorPicker/ColorPalette.js +4 -6
- package/esm/core/ColorPicker/ColorPicker.js +3 -3
- package/esm/core/ComboBox/ComboBox.js +25 -32
- package/esm/core/ComboBox/ComboBoxDropdown.js +1 -2
- package/esm/core/ComboBox/ComboBoxEndIcon.js +1 -1
- package/esm/core/ComboBox/ComboBoxInput.js +21 -20
- package/esm/core/ComboBox/ComboBoxMenu.js +3 -4
- package/esm/core/ComboBox/ComboBoxMenuItem.js +2 -2
- package/esm/core/ComboBox/helpers.js +4 -5
- package/esm/core/DatePicker/DatePicker.js +32 -32
- package/esm/core/Dialog/Dialog.js +12 -5
- package/esm/core/Dialog/DialogBackdrop.js +1 -1
- package/esm/core/Dialog/DialogContext.d.ts +11 -0
- package/esm/core/Dialog/DialogMain.js +16 -22
- package/esm/core/DropdownMenu/DropdownMenu.js +6 -8
- package/esm/core/ExpandableBlock/ExpandableBlock.js +2 -2
- package/esm/core/FileUpload/FileEmptyCard.js +1 -1
- package/esm/core/FileUpload/FileUpload.d.ts +3 -4
- package/esm/core/FileUpload/FileUpload.js +5 -8
- package/esm/core/FileUpload/FileUploadCard.js +9 -10
- package/esm/core/FileUpload/FileUploadTemplate.d.ts +1 -0
- package/esm/core/FileUpload/FileUploadTemplate.js +1 -0
- package/esm/core/InformationPanel/InformationPanel.js +1 -4
- package/esm/core/LabeledInput/LabeledInput.js +1 -1
- package/esm/core/LabeledTextarea/LabeledTextarea.js +1 -1
- package/esm/core/Menu/Menu.js +3 -4
- package/esm/core/Menu/MenuItem.js +8 -11
- package/esm/core/Modal/Modal.d.ts +8 -9
- package/esm/core/Modal/Modal.js +3 -10
- package/esm/core/SearchBox/SearchBox.js +12 -12
- package/esm/core/Select/Select.js +12 -17
- package/esm/core/SideNavigation/SideNavigation.js +2 -2
- package/esm/core/Slider/Slider.js +16 -19
- package/esm/core/Slider/Thumb.js +1 -1
- package/esm/core/StatusMessage/StatusMessage.js +1 -1
- package/esm/core/Stepper/Stepper.js +1 -1
- package/esm/core/Stepper/StepperStep.js +1 -1
- package/esm/core/Table/Table.js +15 -15
- package/esm/core/Table/TablePaginator.js +2 -3
- package/esm/core/Table/TableRowMemoized.js +38 -45
- package/esm/core/Table/actionHandlers/expandHandler.js +3 -3
- package/esm/core/Table/actionHandlers/filterHandler.js +4 -5
- package/esm/core/Table/actionHandlers/selectHandler.js +6 -6
- package/esm/core/Table/cells/DefaultCell.js +1 -1
- package/esm/core/Table/cells/EditableCell.js +6 -12
- package/esm/core/Table/columns/actionColumn.js +3 -6
- package/esm/core/Table/columns/expanderColumn.js +3 -3
- package/esm/core/Table/columns/selectionColumn.js +4 -4
- package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +2 -4
- package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +2 -3
- package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +2 -3
- package/esm/core/Table/filters/TextFilter/TextFilter.js +1 -2
- package/esm/core/Table/hooks/useResizeColumns.js +16 -22
- package/esm/core/Table/hooks/useScrollToRow.js +1 -2
- package/esm/core/Table/hooks/useStickyColumns.js +3 -5
- package/esm/core/Table/hooks/useSubRowFiltering.js +2 -4
- package/esm/core/Tabs/Tabs.js +13 -16
- package/esm/core/ThemeProvider/ThemeContext.d.ts +1 -1
- package/esm/core/ThemeProvider/ThemeProvider.d.ts +2 -3
- package/esm/core/ThemeProvider/ThemeProvider.js +15 -14
- package/esm/core/Tile/Tile.js +2 -3
- package/esm/core/TimePicker/TimePicker.js +13 -13
- package/esm/core/Toast/Toast.d.ts +5 -10
- package/esm/core/Toast/Toast.js +18 -17
- package/esm/core/Toast/Toaster.d.ts +24 -26
- package/esm/core/Toast/Toaster.js +85 -121
- package/esm/core/Toast/index.d.ts +1 -4
- package/esm/core/Toast/index.js +1 -3
- package/esm/core/TransferList/TransferList.js +3 -4
- package/esm/core/Tree/Tree.js +9 -13
- package/esm/core/Tree/TreeNode.js +9 -10
- package/esm/core/index.d.ts +1 -2
- package/esm/core/index.js +1 -1
- package/esm/core/utils/color/ColorValue.js +9 -15
- package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +2 -3
- package/esm/core/utils/components/FocusTrap.js +4 -4
- package/esm/core/utils/components/MiddleTextTruncation.js +1 -2
- package/esm/core/utils/components/Popover.d.ts +1 -1
- package/esm/core/utils/components/Popover.js +5 -8
- package/esm/core/utils/components/Resizer.js +7 -6
- package/esm/core/utils/components/VirtualScroll.js +14 -21
- package/esm/core/utils/functions/dom.d.ts +0 -8
- package/esm/core/utils/functions/dom.js +2 -21
- package/esm/core/utils/functions/polymorphic.d.ts +1 -1
- package/esm/core/utils/functions/polymorphic.js +1 -1
- package/esm/core/utils/functions/supports.js +1 -1
- package/esm/core/utils/hooks/index.d.ts +0 -1
- package/esm/core/utils/hooks/index.js +0 -1
- package/esm/core/utils/hooks/useContainerWidth.js +1 -1
- package/esm/core/utils/hooks/useDragAndDrop.js +8 -10
- package/esm/core/utils/hooks/useEventListener.js +1 -1
- package/esm/core/utils/hooks/useGlobals.d.ts +9 -2
- package/esm/core/utils/hooks/useGlobals.js +6 -4
- package/esm/core/utils/hooks/useId.js +1 -2
- package/esm/core/utils/hooks/useIntersection.js +2 -3
- package/esm/core/utils/hooks/useMediaQuery.js +6 -8
- package/esm/core/utils/hooks/useOverflow.js +1 -2
- package/esm/core/utils/hooks/useResizeObserver.js +3 -4
- package/esm/styles.js +1 -4
- package/package.json +2 -2
- package/styles.css +19 -20
- package/cjs/core/Toast/ToastWrapper.d.ts +0 -10
- package/cjs/core/Toast/ToastWrapper.js +0 -49
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/cjs/core/utils/hooks/useIsThemeAlreadySet.js +0 -54
- package/esm/core/Toast/ToastWrapper.d.ts +0 -10
- package/esm/core/Toast/ToastWrapper.js +0 -20
- package/esm/core/utils/hooks/useIsThemeAlreadySet.d.ts +0 -7
- package/esm/core/utils/hooks/useIsThemeAlreadySet.js +0 -27
|
@@ -47,7 +47,6 @@ const ColorPickerContext_js_1 = require("./ColorPickerContext.js");
|
|
|
47
47
|
* </ColorPicker>
|
|
48
48
|
*/
|
|
49
49
|
exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
50
|
-
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
51
50
|
const { defaultColorFormat, allowedColorFormats = ['hsl', 'rgb', 'hex'], className, ...rest } = props;
|
|
52
51
|
const inputsContainerRef = React.useRef(null);
|
|
53
52
|
const { activeColor, applyHsvColorChange, hsvColor, showAlpha } = (0, ColorPickerContext_js_1.useColorPickerContext)();
|
|
@@ -58,14 +57,13 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
58
57
|
// need to use state since input may have parsing error
|
|
59
58
|
const [input, setInput] = React.useState(['', '', '', '']);
|
|
60
59
|
React.useEffect(() => {
|
|
61
|
-
var _a, _b;
|
|
62
60
|
if (currentFormat === 'hsl') {
|
|
63
61
|
const hsl = activeColor.toHslColor();
|
|
64
62
|
setInput([
|
|
65
63
|
index_js_3.ColorValue.getFormattedColorNumber(hsvColor.h),
|
|
66
64
|
index_js_3.ColorValue.getFormattedColorNumber(hsl.s),
|
|
67
65
|
index_js_3.ColorValue.getFormattedColorNumber(hsl.l),
|
|
68
|
-
index_js_3.ColorValue.getFormattedColorNumber(
|
|
66
|
+
index_js_3.ColorValue.getFormattedColorNumber(hsl.a ?? activeColor.getAlpha() / 255, 2),
|
|
69
67
|
]);
|
|
70
68
|
}
|
|
71
69
|
else if (currentFormat === 'rgb') {
|
|
@@ -74,7 +72,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
74
72
|
rgb.r.toString(),
|
|
75
73
|
rgb.g.toString(),
|
|
76
74
|
rgb.b.toString(),
|
|
77
|
-
index_js_3.ColorValue.getFormattedColorNumber(
|
|
75
|
+
index_js_3.ColorValue.getFormattedColorNumber(rgb.a ?? activeColor.getAlpha() / 255, 2),
|
|
78
76
|
]);
|
|
79
77
|
}
|
|
80
78
|
else {
|
|
@@ -84,9 +82,8 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
84
82
|
}, [activeColor, hsvColor.h, currentFormat, showAlpha]);
|
|
85
83
|
const [validHexInput, setValidHexInput] = React.useState(true);
|
|
86
84
|
const swapColorFormat = React.useCallback(() => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
allowedColorFormats.length]) !== null && _a !== void 0 ? _a : allowedColorFormats[0];
|
|
85
|
+
const newFormat = allowedColorFormats[(allowedColorFormats.indexOf(currentFormat) + 1) %
|
|
86
|
+
allowedColorFormats.length] ?? allowedColorFormats[0];
|
|
90
87
|
setCurrentFormat(newFormat);
|
|
91
88
|
}, [currentFormat, allowedColorFormats]);
|
|
92
89
|
const isFocusInside = (focused) => !!(focused &&
|
|
@@ -167,7 +164,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
167
164
|
React.createElement(index_js_3.InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 360
|
|
168
165
|
? 'negative'
|
|
169
166
|
: undefined },
|
|
170
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '359', step: '.1', placeholder: 'H', value:
|
|
167
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '359', step: '.1', placeholder: 'H', value: input[0] ?? '', onChange: (event) => {
|
|
171
168
|
setInput([event.target.value, input[1], input[2], input[3]]);
|
|
172
169
|
}, onKeyDown: (event) => {
|
|
173
170
|
if (event.key === 'Enter') {
|
|
@@ -183,7 +180,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
183
180
|
React.createElement(index_js_3.InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 100
|
|
184
181
|
? 'negative'
|
|
185
182
|
: undefined },
|
|
186
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'S', value:
|
|
183
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'S', value: input[1] ?? '', onChange: (event) => {
|
|
187
184
|
setInput([input[0], event.target.value, input[2], input[3]]);
|
|
188
185
|
}, onKeyDown: (event) => {
|
|
189
186
|
if (event.key === 'Enter') {
|
|
@@ -199,7 +196,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
199
196
|
React.createElement(index_js_3.InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 100
|
|
200
197
|
? 'negative'
|
|
201
198
|
: undefined },
|
|
202
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'L', value:
|
|
199
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'L', value: input[2] ?? '', onChange: (event) => {
|
|
203
200
|
setInput([input[0], input[1], event.target.value, input[3]]);
|
|
204
201
|
}, onKeyDown: (event) => {
|
|
205
202
|
if (event.key === 'Enter') {
|
|
@@ -215,7 +212,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
215
212
|
showAlpha && (React.createElement(index_js_3.InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
|
|
216
213
|
? 'negative'
|
|
217
214
|
: undefined },
|
|
218
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value:
|
|
215
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: input[3] ?? '', onChange: (event) => {
|
|
219
216
|
setInput([input[0], input[1], input[2], event.target.value]);
|
|
220
217
|
}, onKeyDown: (event) => {
|
|
221
218
|
if (event.key === 'Enter') {
|
|
@@ -232,7 +229,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
232
229
|
React.createElement(index_js_3.InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 255
|
|
233
230
|
? 'negative'
|
|
234
231
|
: undefined },
|
|
235
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value:
|
|
232
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value: input[0] ?? '', onChange: (event) => {
|
|
236
233
|
setInput([event.target.value, input[1], input[2], input[3]]);
|
|
237
234
|
}, onKeyDown: (event) => {
|
|
238
235
|
if (event.key === 'Enter') {
|
|
@@ -248,7 +245,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
248
245
|
React.createElement(index_js_3.InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 255
|
|
249
246
|
? 'negative'
|
|
250
247
|
: undefined },
|
|
251
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value:
|
|
248
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value: input[1] ?? '', onChange: (event) => {
|
|
252
249
|
setInput([input[0], event.target.value, input[2], input[3]]);
|
|
253
250
|
}, onKeyDown: (event) => {
|
|
254
251
|
if (event.key === 'Enter') {
|
|
@@ -264,7 +261,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
264
261
|
React.createElement(index_js_3.InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 255
|
|
265
262
|
? 'negative'
|
|
266
263
|
: undefined },
|
|
267
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value:
|
|
264
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value: input[2] ?? '', onChange: (event) => {
|
|
268
265
|
setInput([input[0], input[1], event.target.value, input[3]]);
|
|
269
266
|
}, onKeyDown: (event) => {
|
|
270
267
|
if (event.key === 'Enter') {
|
|
@@ -280,7 +277,7 @@ exports.ColorInputPanel = React.forwardRef((props, ref) => {
|
|
|
280
277
|
showAlpha && (React.createElement(index_js_3.InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
|
|
281
278
|
? 'negative'
|
|
282
279
|
: undefined },
|
|
283
|
-
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value:
|
|
280
|
+
React.createElement(index_js_2.Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: input[3] ?? '', onChange: (event) => {
|
|
284
281
|
setInput([input[0], input[1], input[2], event.target.value]);
|
|
285
282
|
}, onKeyDown: (event) => {
|
|
286
283
|
if (event.key === 'Enter') {
|
|
@@ -54,9 +54,8 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
|
|
|
54
54
|
const [focusedIndex, setFocusedIndex] = React.useState();
|
|
55
55
|
// callback ref to set tabindex=0 on first child if none of the swatches are tabbable
|
|
56
56
|
const setDefaultTabIndex = (el) => {
|
|
57
|
-
var _a;
|
|
58
57
|
if (el && !el.querySelector('[tabindex="0"]')) {
|
|
59
|
-
|
|
58
|
+
el.firstElementChild?.setAttribute('tabindex', '0');
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
61
|
const paletteRef = React.useRef(null);
|
|
@@ -70,7 +69,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
|
|
|
70
69
|
if (!swatches.length) {
|
|
71
70
|
return;
|
|
72
71
|
}
|
|
73
|
-
const currentIndex = swatches.findIndex((swatch) =>
|
|
72
|
+
const currentIndex = swatches.findIndex((swatch) => swatch === paletteRef.current?.ownerDocument.activeElement);
|
|
74
73
|
if (currentIndex < 0) {
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
@@ -112,10 +111,9 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
|
|
|
112
111
|
};
|
|
113
112
|
// call focus() when focusedIndex changes
|
|
114
113
|
React.useEffect(() => {
|
|
115
|
-
var _a;
|
|
116
114
|
if (focusedIndex != null) {
|
|
117
115
|
const swatches = (0, index_js_1.getFocusableElements)(paletteRef.current);
|
|
118
|
-
|
|
116
|
+
swatches[focusedIndex]?.focus();
|
|
119
117
|
}
|
|
120
118
|
}, [focusedIndex]);
|
|
121
119
|
return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-color-palette-wrapper', className), ref: ref, ...rest },
|
|
@@ -127,7 +125,7 @@ exports.ColorPalette = React.forwardRef((props, ref) => {
|
|
|
127
125
|
const color = (0, ColorPicker_js_1.getColorValue)(_color);
|
|
128
126
|
return (React.createElement(ColorSwatch_js_1.ColorSwatch, { key: index, color: color, onClick: (event) => {
|
|
129
127
|
event.preventDefault();
|
|
130
|
-
onChangeComplete
|
|
128
|
+
onChangeComplete?.(color);
|
|
131
129
|
setActiveColor(color);
|
|
132
130
|
}, isActive: color.equals(activeColor) }));
|
|
133
131
|
}))));
|
|
@@ -84,13 +84,13 @@ exports.ColorPicker = React.forwardRef((props, forwardedRef) => {
|
|
|
84
84
|
const applyHsvColorChange = React.useCallback((newColor, selectionChanged, newColorValue) => {
|
|
85
85
|
// save the HSV values
|
|
86
86
|
setHsvColor(newColor);
|
|
87
|
-
const newActiveColor = newColorValue
|
|
87
|
+
const newActiveColor = newColorValue ?? index_js_1.ColorValue.create(newColor);
|
|
88
88
|
// Only update selected color when dragging is done
|
|
89
89
|
if (selectionChanged) {
|
|
90
|
-
onChangeComplete
|
|
90
|
+
onChangeComplete?.(newActiveColor);
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
onChange
|
|
93
|
+
onChange?.(newActiveColor);
|
|
94
94
|
}
|
|
95
95
|
activeColorTbgr.current = newActiveColor.toTbgr();
|
|
96
96
|
// this converts it to store in tbgr
|
|
@@ -53,8 +53,7 @@ const isSingleOnChange = (onChange, multiple) => {
|
|
|
53
53
|
};
|
|
54
54
|
/** Returns either `option.id` or derives a stable id using `idPrefix` and `option.label` (without whitespace) */
|
|
55
55
|
const getOptionId = (option, idPrefix) => {
|
|
56
|
-
|
|
57
|
-
return (_a = option.id) !== null && _a !== void 0 ? _a : `${idPrefix}-option-${option.label.replace(/\s/g, '-')}`;
|
|
56
|
+
return option.id ?? `${idPrefix}-option-${option.label.replace(/\s/g, '-')}`;
|
|
58
57
|
};
|
|
59
58
|
/**
|
|
60
59
|
* ComboBox component that allows typing a value to filter the options in dropdown list.
|
|
@@ -70,13 +69,11 @@ const getOptionId = (option, idPrefix) => {
|
|
|
70
69
|
* />
|
|
71
70
|
*/
|
|
72
71
|
const ComboBox = (props) => {
|
|
73
|
-
var _a, _b;
|
|
74
72
|
const { options, value: valueProp, onChange, filterFunction, inputProps, dropdownMenuProps, emptyStateMessage = 'No options found', itemRenderer, enableVirtualization = false, multiple = false, onShow, onHide, ...rest } = props;
|
|
75
73
|
// Generate a stateful random id if not specified
|
|
76
|
-
const [id] = React.useState(() =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
74
|
+
const [id] = React.useState(() => props.id ??
|
|
75
|
+
(inputProps?.id && `${inputProps.id}-cb`) ??
|
|
76
|
+
`iui-cb-${(0, index_js_3.getRandomValue)(10)}`);
|
|
80
77
|
// Refs get set in subcomponents
|
|
81
78
|
const inputRef = React.useRef(null);
|
|
82
79
|
const menuRef = React.useRef(null);
|
|
@@ -102,7 +99,7 @@ const ComboBox = (props) => {
|
|
|
102
99
|
const getSelectedIndexes = React.useCallback(() => {
|
|
103
100
|
if (isMultipleEnabled(valueProp, multiple)) {
|
|
104
101
|
const indexArray = [];
|
|
105
|
-
valueProp
|
|
102
|
+
valueProp?.forEach((value) => {
|
|
106
103
|
const indexToAdd = options.findIndex((option) => option.value === value);
|
|
107
104
|
if (indexToAdd > -1) {
|
|
108
105
|
indexArray.push(indexToAdd);
|
|
@@ -121,10 +118,9 @@ const ComboBox = (props) => {
|
|
|
121
118
|
focusedIndex: -1,
|
|
122
119
|
});
|
|
123
120
|
(0, index_js_3.useIsomorphicLayoutEffect)(() => {
|
|
124
|
-
var _a, _b;
|
|
125
121
|
// When the dropdown opens
|
|
126
122
|
if (isOpen) {
|
|
127
|
-
|
|
123
|
+
inputRef.current?.focus(); // Focus the input
|
|
128
124
|
// Reset the filtered list (does not reset when multiple enabled)
|
|
129
125
|
if (!multiple) {
|
|
130
126
|
setFilteredOptions(optionsRef.current);
|
|
@@ -138,7 +134,7 @@ const ComboBox = (props) => {
|
|
|
138
134
|
// Reset the input value if not multiple
|
|
139
135
|
if (!isMultipleEnabled(selected, multiple)) {
|
|
140
136
|
setInputValue(selected != undefined && selected >= 0
|
|
141
|
-
?
|
|
137
|
+
? optionsRef.current[selected]?.label
|
|
142
138
|
: '');
|
|
143
139
|
}
|
|
144
140
|
}
|
|
@@ -153,9 +149,9 @@ const ComboBox = (props) => {
|
|
|
153
149
|
// Update filtered options to the latest value options according to input value
|
|
154
150
|
const [filteredOptions, setFilteredOptions] = React.useState(options);
|
|
155
151
|
React.useEffect(() => {
|
|
156
|
-
var _a;
|
|
157
152
|
if (inputValue) {
|
|
158
|
-
setFilteredOptions(
|
|
153
|
+
setFilteredOptions(filterFunction?.(options, inputValue) ??
|
|
154
|
+
options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase())));
|
|
159
155
|
}
|
|
160
156
|
else {
|
|
161
157
|
setFilteredOptions(options);
|
|
@@ -165,18 +161,18 @@ const ComboBox = (props) => {
|
|
|
165
161
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
162
|
}, [options]);
|
|
167
163
|
// Filter options based on input value
|
|
168
|
-
const [inputValue, setInputValue] = React.useState(
|
|
164
|
+
const [inputValue, setInputValue] = React.useState(inputProps?.value?.toString() ?? '');
|
|
169
165
|
const [liveRegionSelection, setLiveRegionSelection] = React.useState('');
|
|
170
166
|
const handleOnInput = React.useCallback((event) => {
|
|
171
|
-
var _a, _b;
|
|
172
167
|
const { value } = event.currentTarget;
|
|
173
168
|
setInputValue(value);
|
|
174
169
|
dispatch({ type: 'open' }); // reopen when typing
|
|
175
|
-
setFilteredOptions(
|
|
170
|
+
setFilteredOptions(filterFunction?.(optionsRef.current, value) ??
|
|
171
|
+
optionsRef.current.filter((option) => option.label.toLowerCase().includes(value.toLowerCase())));
|
|
176
172
|
if (focusedIndex != -1) {
|
|
177
173
|
dispatch({ type: 'focus', value: -1 });
|
|
178
174
|
}
|
|
179
|
-
|
|
175
|
+
inputProps?.onChange?.(event);
|
|
180
176
|
}, [filterFunction, focusedIndex, inputProps, optionsRef]);
|
|
181
177
|
// When the value prop changes, update the selected index/indices
|
|
182
178
|
React.useEffect(() => {
|
|
@@ -225,23 +221,21 @@ const ComboBox = (props) => {
|
|
|
225
221
|
}, [selected]);
|
|
226
222
|
// Calls user defined onChange
|
|
227
223
|
const onChangeHandler = React.useCallback((__originalIndex, actionType, newArray) => {
|
|
228
|
-
var _a, _b, _c, _d;
|
|
229
224
|
if (isSingleOnChange(onChangeProp.current, multiple)) {
|
|
230
|
-
|
|
225
|
+
onChangeProp.current?.(optionsRef.current[__originalIndex]?.value);
|
|
231
226
|
}
|
|
232
227
|
else {
|
|
233
228
|
actionType &&
|
|
234
229
|
newArray &&
|
|
235
|
-
|
|
236
|
-
value:
|
|
230
|
+
onChangeProp.current?.(newArray?.map((item) => optionsRef.current[item]?.value), {
|
|
231
|
+
value: optionsRef.current[__originalIndex]?.value,
|
|
237
232
|
type: actionType,
|
|
238
|
-
})
|
|
233
|
+
});
|
|
239
234
|
}
|
|
240
235
|
}, [multiple, onChangeProp, optionsRef]);
|
|
241
236
|
const onClickHandler = React.useCallback((__originalIndex) => {
|
|
242
|
-
|
|
243
|
-
(
|
|
244
|
-
if ((_b = optionsRef.current[__originalIndex]) === null || _b === void 0 ? void 0 : _b.disabled) {
|
|
237
|
+
inputRef.current?.focus({ preventScroll: true }); // return focus to input
|
|
238
|
+
if (optionsRef.current[__originalIndex]?.disabled) {
|
|
245
239
|
return;
|
|
246
240
|
}
|
|
247
241
|
if (isMultipleEnabled(selected, multiple)) {
|
|
@@ -253,7 +247,7 @@ const ComboBox = (props) => {
|
|
|
253
247
|
onChangeHandler(__originalIndex, actionType, newArray);
|
|
254
248
|
// update live region
|
|
255
249
|
setLiveRegionSelection(newArray
|
|
256
|
-
.map((item) =>
|
|
250
|
+
.map((item) => optionsRef.current[item]?.label)
|
|
257
251
|
.filter(Boolean)
|
|
258
252
|
.join(', '));
|
|
259
253
|
}
|
|
@@ -274,7 +268,7 @@ const ComboBox = (props) => {
|
|
|
274
268
|
const optionId = getOptionId(option, id);
|
|
275
269
|
const { __originalIndex } = optionsExtraInfoRef.current[optionId];
|
|
276
270
|
const { icon, startIcon: startIconProp, ...restOptions } = option;
|
|
277
|
-
const startIcon = startIconProp
|
|
271
|
+
const startIcon = startIconProp ?? icon;
|
|
278
272
|
const customItem = itemRenderer
|
|
279
273
|
? itemRenderer(option, {
|
|
280
274
|
isFocused: focusedIndex === __originalIndex,
|
|
@@ -285,9 +279,8 @@ const ComboBox = (props) => {
|
|
|
285
279
|
: null;
|
|
286
280
|
return customItem ? (React.cloneElement(customItem, {
|
|
287
281
|
onClick: (e) => {
|
|
288
|
-
var _a, _b;
|
|
289
282
|
onClickHandler(__originalIndex);
|
|
290
|
-
|
|
283
|
+
customItem.props.onClick?.(e);
|
|
291
284
|
},
|
|
292
285
|
// ComboBox.MenuItem handles scrollIntoView, data-iui-index and focused through context
|
|
293
286
|
// but we still need to pass them here for backwards compatibility with MenuItem
|
|
@@ -296,7 +289,7 @@ const ComboBox = (props) => {
|
|
|
296
289
|
'data-iui-filtered-index': filteredIndex,
|
|
297
290
|
ref: (0, index_js_3.mergeRefs)(customItem.props.ref, (el) => {
|
|
298
291
|
if (!enableVirtualization && focusedIndex === __originalIndex) {
|
|
299
|
-
el
|
|
292
|
+
el?.scrollIntoView({ block: 'nearest' });
|
|
300
293
|
}
|
|
301
294
|
}),
|
|
302
295
|
})) : (React.createElement(ComboBoxMenuItem_js_1.ComboBoxMenuItem, { key: optionId, id: optionId, startIcon: startIcon, ...restOptions, isSelected: isMenuItemSelected(__originalIndex), onClick: () => {
|
|
@@ -326,7 +319,7 @@ const ComboBox = (props) => {
|
|
|
326
319
|
getMenuItem,
|
|
327
320
|
multiple,
|
|
328
321
|
} },
|
|
329
|
-
React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { disabled: inputProps
|
|
322
|
+
React.createElement(ComboBoxInputContainer_js_1.ComboBoxInputContainer, { disabled: inputProps?.disabled, ...rest },
|
|
330
323
|
React.createElement(React.Fragment, null,
|
|
331
324
|
React.createElement(ComboBoxInput_js_1.ComboBoxInput, { value: inputValue, ...inputProps, onChange: handleOnInput, selectTags: isMultipleEnabled(selected, multiple)
|
|
332
325
|
? selected.map((index) => {
|
|
@@ -334,7 +327,7 @@ const ComboBox = (props) => {
|
|
|
334
327
|
return (React.createElement(SelectTag_js_1.default, { key: item.label, label: item.label }));
|
|
335
328
|
})
|
|
336
329
|
: undefined })),
|
|
337
|
-
React.createElement(ComboBoxEndIcon_js_1.ComboBoxEndIcon, { disabled: inputProps
|
|
330
|
+
React.createElement(ComboBoxEndIcon_js_1.ComboBoxEndIcon, { disabled: inputProps?.disabled, isOpen: isOpen }),
|
|
338
331
|
multiple ? (React.createElement(index_js_3.AutoclearingHiddenLiveRegion, { text: liveRegionSelection })) : null),
|
|
339
332
|
React.createElement(ComboBoxDropdown_js_1.ComboBoxDropdown, { ...dropdownMenuProps, onShow: onShow, onHide: onHide },
|
|
340
333
|
React.createElement(ComboBoxMenu_js_1.ComboBoxMenu, null, filteredOptions.length > 0 && !enableVirtualization
|
|
@@ -43,8 +43,7 @@ exports.ComboBoxDropdown = React.forwardRef((props, forwardedRef) => {
|
|
|
43
43
|
}
|
|
44
44
|
}, [dispatch, props.visible]);
|
|
45
45
|
return (React.createElement(index_js_1.Popover, { placement: 'bottom-start', visible: isOpen, onClickOutside: React.useCallback((_, { target }) => {
|
|
46
|
-
|
|
47
|
-
if (!((_a = toggleButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(target))) {
|
|
46
|
+
if (!toggleButtonRef.current?.contains(target)) {
|
|
48
47
|
dispatch({ type: 'close' });
|
|
49
48
|
}
|
|
50
49
|
}, [dispatch, toggleButtonRef]), animation: 'shift-away', duration: 200, reference: inputRef, ref: forwardedRef, content: children, ...rest }));
|
|
@@ -46,6 +46,6 @@ exports.ComboBoxEndIcon = React.forwardRef((props, forwardedRef) => {
|
|
|
46
46
|
'iui-open': isOpen,
|
|
47
47
|
}, className), onClick: (0, index_js_1.mergeEventHandlers)(onClickProp, () => {
|
|
48
48
|
dispatch({ type: isOpen ? 'close' : 'open' });
|
|
49
|
-
}), ...rest }, children
|
|
49
|
+
}), ...rest }, children ?? React.createElement(index_js_1.SvgCaretDownSmall, { "aria-hidden": true })));
|
|
50
50
|
});
|
|
51
51
|
exports.ComboBoxEndIcon.displayName = 'ComboBoxEndIcon';
|
|
@@ -39,18 +39,16 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
39
39
|
const dispatch = (0, index_js_2.useSafeContext)(helpers_js_1.ComboBoxActionContext);
|
|
40
40
|
const { inputRef, menuRef, optionsExtraInfoRef } = (0, index_js_2.useSafeContext)(helpers_js_1.ComboBoxRefsContext);
|
|
41
41
|
const refs = (0, index_js_2.useMergedRefs)(inputRef, forwardedRef);
|
|
42
|
-
const focusedIndexRef = React.useRef(focusedIndex
|
|
42
|
+
const focusedIndexRef = React.useRef(focusedIndex ?? -1);
|
|
43
43
|
React.useEffect(() => {
|
|
44
|
-
focusedIndexRef.current = focusedIndex
|
|
44
|
+
focusedIndexRef.current = focusedIndex ?? -1;
|
|
45
45
|
}, [focusedIndex]);
|
|
46
46
|
const getIdFromIndex = (index) => {
|
|
47
|
-
|
|
48
|
-
return ((_c = (_b = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-iui-index="${index}"]`)) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '');
|
|
47
|
+
return (menuRef.current?.querySelector(`[data-iui-index="${index}"]`)?.id ?? '');
|
|
49
48
|
};
|
|
50
49
|
const handleKeyDown = React.useCallback((event) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const length = (_a = Object.keys(optionsExtraInfoRef.current).length) !== null && _a !== void 0 ? _a : 0;
|
|
50
|
+
onKeyDownProp?.(event);
|
|
51
|
+
const length = Object.keys(optionsExtraInfoRef.current).length ?? 0;
|
|
54
52
|
if (event.altKey) {
|
|
55
53
|
return;
|
|
56
54
|
}
|
|
@@ -64,22 +62,23 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
66
64
|
if (focusedIndexRef.current === -1) {
|
|
67
|
-
const currentElement =
|
|
65
|
+
const currentElement = menuRef.current?.querySelector('[data-iui-index]');
|
|
68
66
|
return dispatch({
|
|
69
67
|
type: 'focus',
|
|
70
|
-
value: Number(
|
|
68
|
+
value: Number(currentElement?.getAttribute('data-iui-index') ?? 0),
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
// If virtualization is enabled, dont let round scrolling
|
|
74
72
|
if (enableVirtualization &&
|
|
75
|
-
!
|
|
73
|
+
!menuRef.current?.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)?.nextElementSibling) {
|
|
76
74
|
return;
|
|
77
75
|
}
|
|
78
76
|
let nextIndex = focusedIndexRef.current;
|
|
79
77
|
do {
|
|
80
|
-
const currentElement =
|
|
81
|
-
const nextElement =
|
|
82
|
-
|
|
78
|
+
const currentElement = menuRef.current?.querySelector(`[data-iui-index="${nextIndex}"]`);
|
|
79
|
+
const nextElement = currentElement?.nextElementSibling ??
|
|
80
|
+
menuRef.current?.querySelector('[data-iui-index]');
|
|
81
|
+
nextIndex = Number(nextElement?.getAttribute('data-iui-index'));
|
|
83
82
|
if (nextElement) {
|
|
84
83
|
return dispatch({ type: 'focus', value: nextIndex });
|
|
85
84
|
}
|
|
@@ -96,20 +95,22 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
96
95
|
}
|
|
97
96
|
// If virtualization is enabled, dont let round scrolling
|
|
98
97
|
if (enableVirtualization &&
|
|
99
|
-
!
|
|
98
|
+
!menuRef.current?.querySelector(`[data-iui-index="${focusedIndexRef.current}"]`)?.previousElementSibling) {
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
101
|
if (focusedIndexRef.current === -1) {
|
|
103
102
|
return dispatch({
|
|
104
103
|
type: 'focus',
|
|
105
|
-
value:
|
|
104
|
+
value: Object.values(optionsExtraInfoRef.current)?.[length - 1]
|
|
105
|
+
.__originalIndex ?? -1,
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
let prevIndex = focusedIndexRef.current;
|
|
109
109
|
do {
|
|
110
|
-
const currentElement =
|
|
111
|
-
const prevElement =
|
|
112
|
-
|
|
110
|
+
const currentElement = menuRef.current?.querySelector(`[data-iui-index="${prevIndex}"]`);
|
|
111
|
+
const prevElement = currentElement?.previousElementSibling ??
|
|
112
|
+
menuRef.current?.querySelector('[data-iui-index]:last-of-type');
|
|
113
|
+
prevIndex = Number(prevElement?.getAttribute('data-iui-index'));
|
|
113
114
|
if (prevElement) {
|
|
114
115
|
return dispatch({ type: 'focus', value: prevIndex });
|
|
115
116
|
}
|
|
@@ -120,7 +121,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
120
121
|
event.preventDefault();
|
|
121
122
|
if (isOpen) {
|
|
122
123
|
if (focusedIndexRef.current > -1) {
|
|
123
|
-
onClickHandler
|
|
124
|
+
onClickHandler?.(focusedIndexRef.current);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
@@ -148,7 +149,7 @@ exports.ComboBoxInput = React.forwardRef((props, forwardedRef) => {
|
|
|
148
149
|
]);
|
|
149
150
|
const handleFocus = React.useCallback((event) => {
|
|
150
151
|
dispatch({ type: 'open' });
|
|
151
|
-
onFocusProp
|
|
152
|
+
onFocusProp?.(event);
|
|
152
153
|
}, [dispatch, onFocusProp]);
|
|
153
154
|
const handleClick = React.useCallback(() => {
|
|
154
155
|
if (!isOpen) {
|
|
@@ -37,7 +37,7 @@ const index_js_1 = require("../Menu/index.js");
|
|
|
37
37
|
const index_js_2 = require("../Surface/index.js");
|
|
38
38
|
const index_js_3 = require("../utils/index.js");
|
|
39
39
|
const helpers_js_1 = require("./helpers.js");
|
|
40
|
-
const isOverflowOverlaySupported = () =>
|
|
40
|
+
const isOverflowOverlaySupported = () => (0, index_js_3.getWindow)()?.CSS?.supports?.('overflow: overlay');
|
|
41
41
|
const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style, ...rest }, forwardedRef) => {
|
|
42
42
|
const { minWidth, id, filteredOptions, getMenuItem, focusedIndex } = (0, index_js_3.useSafeContext)(helpers_js_1.ComboBoxStateContext);
|
|
43
43
|
const { menuRef } = (0, index_js_3.useSafeContext)(helpers_js_1.ComboBoxRefsContext);
|
|
@@ -46,12 +46,11 @@ const VirtualizedComboBoxMenu = React.forwardRef(({ children, className, style,
|
|
|
46
46
|
: children, // Here is expected empty state content
|
|
47
47
|
[filteredOptions, getMenuItem, children]);
|
|
48
48
|
const focusedVisibleIndex = React.useMemo(() => {
|
|
49
|
-
|
|
50
|
-
const currentElement = (_a = menuRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-iui-index="${focusedIndex}"]`);
|
|
49
|
+
const currentElement = menuRef.current?.querySelector(`[data-iui-index="${focusedIndex}"]`);
|
|
51
50
|
if (!currentElement) {
|
|
52
51
|
return focusedIndex;
|
|
53
52
|
}
|
|
54
|
-
return Number(
|
|
53
|
+
return Number(currentElement.getAttribute('data-iui-filtered-index') ?? focusedIndex);
|
|
55
54
|
}, [focusedIndex, menuRef]);
|
|
56
55
|
const { outerProps, innerProps, visibleChildren } = (0, index_js_3.useVirtualization)({
|
|
57
56
|
// 'Fool' VirtualScroll by passing length 1
|
|
@@ -37,11 +37,11 @@ exports.ComboBoxMenuItem = React.memo(React.forwardRef((props, forwardedRef) =>
|
|
|
37
37
|
const { focusedIndex, enableVirtualization } = (0, index_js_1.useSafeContext)(helpers_js_1.ComboBoxStateContext);
|
|
38
38
|
const focusRef = (el) => {
|
|
39
39
|
if (!enableVirtualization && focusedIndex === index) {
|
|
40
|
-
el
|
|
40
|
+
el?.scrollIntoView({ block: 'nearest' });
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
const refs = (0, index_js_1.useMergedRefs)(forwardedRef, focusRef);
|
|
44
|
-
return (React.createElement(ListItem_js_1.ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, focused: focusedIndex === index, ref: refs, onClick: () => onClick
|
|
44
|
+
return (React.createElement(ListItem_js_1.ListItem, { actionable: true, size: size, active: isSelected, disabled: disabled, focused: focusedIndex === index, ref: refs, onClick: () => onClick?.(value), role: role, tabIndex: role === 'presentation' ? undefined : -1, "aria-selected": isSelected, "aria-disabled": disabled, "data-iui-index": index, ...rest },
|
|
45
45
|
startIcon && (React.createElement(ListItem_js_1.ListItem.Icon, { as: 'span', "aria-hidden": true }, startIcon)),
|
|
46
46
|
React.createElement(ListItem_js_1.ListItem.Content, null,
|
|
47
47
|
children,
|
|
@@ -30,7 +30,6 @@ exports.ComboBoxActionContext = exports.ComboBoxStateContext = exports.ComboBoxR
|
|
|
30
30
|
*--------------------------------------------------------------------------------------------*/
|
|
31
31
|
const React = __importStar(require("react"));
|
|
32
32
|
const comboBoxReducer = (state, action) => {
|
|
33
|
-
var _a, _b, _c, _d, _e;
|
|
34
33
|
switch (action.type) {
|
|
35
34
|
case 'open': {
|
|
36
35
|
return { ...state, isOpen: true };
|
|
@@ -44,8 +43,8 @@ const comboBoxReducer = (state, action) => {
|
|
|
44
43
|
}
|
|
45
44
|
return {
|
|
46
45
|
...state,
|
|
47
|
-
selected:
|
|
48
|
-
focusedIndex:
|
|
46
|
+
selected: action.value ?? state.selected,
|
|
47
|
+
focusedIndex: action.value ?? state.focusedIndex,
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
case 'multiselect': {
|
|
@@ -58,12 +57,12 @@ const comboBoxReducer = (state, action) => {
|
|
|
58
57
|
if (Array.isArray(state.selected)) {
|
|
59
58
|
return {
|
|
60
59
|
...state,
|
|
61
|
-
focusedIndex:
|
|
60
|
+
focusedIndex: action.value ?? -1,
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
63
|
return {
|
|
65
64
|
...state,
|
|
66
|
-
focusedIndex:
|
|
65
|
+
focusedIndex: action.value ?? state.selected ?? -1,
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
default: {
|