@qualtrics/ui-react 2.20.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -33
- package/dist/__shared/cjs/{index-90d4069b.js → index-025620bf.js} +718 -673
- package/dist/__shared/cjs/{index-579c4690.js → index-41a013d2.js} +4 -4
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +4 -4
- package/dist/components/Accordion/AccordionPanel.js +3 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button2.js +2 -2
- package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox.js +11 -11
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/Alpha.js +12 -16
- package/dist/components/ColorPicker/ColorPicker.js +15 -9
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +9 -4
- package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +8 -6
- package/dist/components/ColorPicker/Hue.js +3 -9
- package/dist/components/ColorPicker/Palette.js +13 -9
- package/dist/components/ColorPicker/Saturation.js +9 -17
- package/dist/components/ColorPicker/utils/hexToRgbaString.js +3 -2
- package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
- package/dist/components/ColorPicker/utils/validateHex.js +10 -9
- package/dist/components/Combobox/Combobox.js +54 -31
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxHeader.js +1 -1
- package/dist/components/Combobox/ComboboxIcon.js +3 -2
- package/dist/components/Combobox/ComboboxInput.js +4 -4
- package/dist/components/Combobox/ComboboxList.js +2 -2
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +5 -2
- package/dist/components/Dropdown/Dropdown.js +14 -14
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +23 -19
- package/dist/components/Dropdown/DropdownList.js +4 -4
- package/dist/components/Dropdown/DropdownOption.js +5 -7
- package/dist/components/Dropdown/DropdownSearch.js +12 -9
- package/dist/components/FilePicker/FilePicker.js +13 -13
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField.js +2 -2
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FormField/FormFieldContext.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/Icon.js +2 -2
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput.js +12 -9
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/Input/InputField.js +2 -2
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner.js +1 -1
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/ConditionSet.js +5 -5
- package/dist/components/LogicEditor/LogicEditor.js +1 -1
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/LogicEditor/utils.js +2 -1
- package/dist/components/Modal/Modal.js +14 -13
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +41 -30
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -2
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +19 -15
- package/dist/components/NewMenu/parts/MenuItem.js +1 -1
- package/dist/components/NumberStepper/NumberStepper.js +7 -6
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/NumberStepper/NumberStepperDecrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperIncrement.js +1 -1
- package/dist/components/NumberStepper/NumberStepperInput.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination.js +1 -1
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +5 -5
- package/dist/components/Pagination/PaginationPageInput.js +11 -9
- package/dist/components/Pagination/PaginationPreviousButton.js +5 -5
- package/dist/components/Popover/Popover.js +9 -7
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +4 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +4 -4
- package/dist/components/Radio/Radio.js +12 -11
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput.js +4 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav.js +2 -1
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/SidebarNav/SidebarNavLink.js +1 -1
- package/dist/components/Slider/RangeSlider.js +2 -2
- package/dist/components/Slider/Slider.js +1 -1
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Slider/SliderButton.js +1 -1
- package/dist/components/Switch/Switch.js +11 -11
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tab.js +3 -3
- package/dist/components/Tabs/TabList.js +6 -5
- package/dist/components/Tabs/TabPanel.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +15 -7
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/UIProvider/UIProvider.js +2 -2
- package/dist/components/deprecated_ColorPicker/Alpha.js +4 -4
- package/dist/components/deprecated_ColorPicker/Color.js +6 -6
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -2
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_ColorPicker/HexInput.js +1 -1
- package/dist/components/deprecated_ColorPicker/Hue.js +3 -3
- package/dist/components/deprecated_ColorPicker/Saturation.js +5 -5
- package/dist/components/deprecated_ColorPicker/Swatch.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +2 -2
- package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +8 -8
- package/dist/components/deprecated_Tabs/Tabs.js +11 -7
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/components/deprecated_Toolbar/ToolbarPanel.js +3 -3
- package/dist/components/deprecated_Toolbar/ToolbarPanels.js +4 -29
- package/dist/components/deprecated_Toolbar/ToolbarTab.js +8 -8
- package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -3
- package/dist/hooks/useBreakpoints/useBreakpoints.js +1 -1
- package/dist/hooks/useClickOutside/useClickOutside.js +2 -1
- package/dist/hooks/useControllableState/useControllableState.js +2 -1
- package/dist/hooks/useEventListener/useEventListener.js +4 -1
- package/dist/hooks/useId/useId.js +1 -1
- package/dist/hooks/useOverlay/useOverlay.js +11 -6
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useResponsiveValue/useResponsiveValue.js +2 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +4 -2
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/createIconComponent.js +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.es.js +1 -7
- package/dist/index.js +4 -7
- package/dist/next/AdvancedTable/AdvancedTable.js +86 -87
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCell.js +6 -4
- package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +18 -10
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +7 -6
- package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +5 -4
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -1
- package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +3 -2
- package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +6 -5
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInputIconButton.js +1 -1
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxFlyout.js +2 -2
- package/dist/next/Combobox/ComboboxGroup.js +1 -1
- package/dist/next/Combobox/ComboboxInput.js +2 -2
- package/dist/next/Combobox/ComboboxOption.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +12 -8
- package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +1 -1
- package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +3 -2
- package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +2 -1
- package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +2 -1
- package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +1 -1
- package/dist/next/Drawer/Drawer.js +7 -4
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input.js +2 -2
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu.js +11 -5
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuItem.js +19 -11
- package/dist/next/Menu/MenuPane.js +70 -40
- package/dist/next/Menu/MenuSearch.js +16 -71
- package/dist/next/Menu/SubMenu.js +63 -46
- package/dist/next/Menu/constants.js +5 -1
- package/dist/next/Menu/useMutationObserver.js +17 -0
- package/dist/next/Menu/usePaneSearch.js +109 -7
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +7 -6
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +8 -2
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimeDropdown.js +4 -4
- package/dist/next/TimePicker/TimeInput.js +2 -2
- package/dist/next/TimePicker/TimePicker.js +4 -4
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/TimePicker/TimePickerIcon.js +2 -1
- package/dist/next/TimePicker/utils.js +10 -9
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +2 -1
- package/dist/next/index.js +601 -432
- package/dist/utils/Flyout/Flyout.js +1 -1
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/Popper/Popper.js +9 -5
- package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +2 -1
- package/dist/utils/Translation/useTranslation.js +4 -5
- package/dist/utils/filterChildren/filterChildren.js +2 -1
- package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -1
- package/dist/utils/mergeRefs/mergeRefs.js +1 -1
- package/dist/utils/wrapEvent/wrapEvent.js +2 -2
- package/icons/package.json +1 -0
- package/next/package.json +2 -1
- package/package.json +4 -4
- package/dist/utils/keyboardUser/index.js +0 -1
- package/dist/utils/keyboardUser/keyboardUser.js +0 -30
|
@@ -23,7 +23,7 @@ function RGBInput(_ref) {
|
|
|
23
23
|
containerId,
|
|
24
24
|
dataTestId
|
|
25
25
|
} = _ref;
|
|
26
|
-
const inputId =
|
|
26
|
+
const inputId = "".concat(containerId, "-").concat(label, "-input");
|
|
27
27
|
const [internalValue, setInternalValue] = useState(externalValue);
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
setInternalValue(externalValue);
|
|
@@ -41,13 +41,14 @@ function RGBInput(_ref) {
|
|
|
41
41
|
onChange: e => setInternalValue(parseInt(e.target.value, 10) || 0),
|
|
42
42
|
onBlur: onBlur,
|
|
43
43
|
"aria-label": ariaLabel,
|
|
44
|
-
"data-testid": getSubDataTestId(dataTestId,
|
|
44
|
+
"data-testid": getSubDataTestId(dataTestId, "".concat(label, "-channel"))
|
|
45
45
|
}), /*#__PURE__*/React__default.createElement(Label, {
|
|
46
46
|
htmlFor: inputId,
|
|
47
47
|
className: styles.inputLabel
|
|
48
48
|
}, label));
|
|
49
49
|
}
|
|
50
50
|
const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
51
|
+
var _color$alpha;
|
|
51
52
|
let {
|
|
52
53
|
color,
|
|
53
54
|
onHexBlur,
|
|
@@ -56,8 +57,8 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
56
57
|
containerId,
|
|
57
58
|
dataTestId
|
|
58
59
|
} = _ref2;
|
|
59
|
-
const hexInputId =
|
|
60
|
-
const alphaInputId =
|
|
60
|
+
const hexInputId = "".concat(containerId, "-hex-input");
|
|
61
|
+
const alphaInputId = "".concat(containerId, "-alpha-input");
|
|
61
62
|
const {
|
|
62
63
|
translate
|
|
63
64
|
} = useTranslation();
|
|
@@ -81,9 +82,10 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
81
82
|
onHexBlur(validatedHex);
|
|
82
83
|
setInternalHex(validatedHex);
|
|
83
84
|
}
|
|
84
|
-
const [internalAlpha, setInternalAlpha] = useState(color.alpha
|
|
85
|
+
const [internalAlpha, setInternalAlpha] = useState((_color$alpha = color.alpha) !== null && _color$alpha !== void 0 ? _color$alpha : 100);
|
|
85
86
|
useEffect(() => {
|
|
86
|
-
|
|
87
|
+
var _color$alpha2;
|
|
88
|
+
setInternalAlpha((_color$alpha2 = color.alpha) !== null && _color$alpha2 !== void 0 ? _color$alpha2 : 100);
|
|
87
89
|
}, [color.alpha, isAlphaEnabled]);
|
|
88
90
|
function handleAlphaBlur(e) {
|
|
89
91
|
const newAlpha = Math.min(Math.max(parseInt(e.target.value, 10) || 0, 0), 100);
|
|
@@ -10,7 +10,6 @@ import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
|
10
10
|
import useEventCallback from '../../hooks/useEventCallback/useEventCallback.js';
|
|
11
11
|
import getMousePosition from './utils/getMousePosition.js';
|
|
12
12
|
import useMouseDrag from '../../hooks/useMouseDrag/useMouseDrag.js';
|
|
13
|
-
import { setIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
14
13
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
15
14
|
|
|
16
15
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
@@ -45,33 +44,27 @@ function Hue(_ref) {
|
|
|
45
44
|
case 'ArrowUp':
|
|
46
45
|
case 'ArrowRight':
|
|
47
46
|
e.preventDefault(); // prevent page scroll
|
|
48
|
-
setIsKeyboardUser(true);
|
|
49
47
|
onHueChange(Math.min(hue + 3, 359));
|
|
50
48
|
break;
|
|
51
49
|
case 'ArrowDown':
|
|
52
50
|
case 'ArrowLeft':
|
|
53
51
|
e.preventDefault(); // prevent page scroll
|
|
54
|
-
setIsKeyboardUser(true);
|
|
55
52
|
onHueChange(Math.max(hue - 3, 0));
|
|
56
53
|
break;
|
|
57
54
|
case 'End':
|
|
58
55
|
e.preventDefault(); // prevent page scroll
|
|
59
|
-
setIsKeyboardUser(true);
|
|
60
56
|
onHueChange(359);
|
|
61
57
|
break;
|
|
62
58
|
case 'Home':
|
|
63
59
|
e.preventDefault(); // prevent page scroll
|
|
64
|
-
setIsKeyboardUser(true);
|
|
65
60
|
onHueChange(0);
|
|
66
61
|
break;
|
|
67
62
|
case 'PageUp':
|
|
68
63
|
e.preventDefault(); // prevent page scroll
|
|
69
|
-
setIsKeyboardUser(true);
|
|
70
64
|
onHueChange(Math.min(hue + 30, 359));
|
|
71
65
|
break;
|
|
72
66
|
case 'PageDown':
|
|
73
67
|
e.preventDefault(); // prevent page scroll
|
|
74
|
-
setIsKeyboardUser(true);
|
|
75
68
|
onHueChange(Math.max(hue - 30, 0));
|
|
76
69
|
break;
|
|
77
70
|
default:
|
|
@@ -83,9 +76,10 @@ function Hue(_ref) {
|
|
|
83
76
|
[styles.alphaEnabled]: isAlphaEnabled
|
|
84
77
|
}),
|
|
85
78
|
onMouseDown: e => {
|
|
79
|
+
var _thumbRef$current;
|
|
86
80
|
// prevent text highlighting while dragging
|
|
87
81
|
e.preventDefault();
|
|
88
|
-
thumbRef.current
|
|
82
|
+
(_thumbRef$current = thumbRef.current) === null || _thumbRef$current === void 0 ? void 0 : _thumbRef$current.focus();
|
|
89
83
|
handleMouseDown(e);
|
|
90
84
|
},
|
|
91
85
|
"data-testid": getSubDataTestId(dataTestId, 'hue-rail'),
|
|
@@ -96,7 +90,7 @@ function Hue(_ref) {
|
|
|
96
90
|
[styles.alphaEnabled]: isAlphaEnabled
|
|
97
91
|
}),
|
|
98
92
|
style: {
|
|
99
|
-
left:
|
|
93
|
+
left: "calc(".concat(hue / 359 * 100, "% - 4px)")
|
|
100
94
|
},
|
|
101
95
|
onKeyDown: handleKeyDown,
|
|
102
96
|
"aria-label": hueAriaLabel,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React__default, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
import styles from './ColorPicker2.js';
|
|
3
4
|
import './utils/index.js';
|
|
4
5
|
import '../../utils/index.js';
|
|
5
6
|
import '../../utils/getSubDataTestId/index.js';
|
|
6
7
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
7
8
|
import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
8
|
-
import { setIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
9
9
|
import calculateTargetId from './utils/calculateTargetId.js';
|
|
10
10
|
|
|
11
11
|
const Swatch = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
12
|
+
var _color$name;
|
|
12
13
|
let {
|
|
13
14
|
color,
|
|
14
15
|
onColorSwatchClick,
|
|
@@ -28,14 +29,14 @@ const Swatch = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
28
29
|
type: "button",
|
|
29
30
|
className: styles.swatch,
|
|
30
31
|
style: {
|
|
31
|
-
backgroundColor:
|
|
32
|
+
backgroundColor: "".concat(color.hex)
|
|
32
33
|
},
|
|
33
34
|
onClick: handleClick,
|
|
34
35
|
tabIndex: cellIndex === focusedSwatchIndex ? 0 : -1,
|
|
35
|
-
"aria-label":
|
|
36
|
+
"aria-label": "".concat((_color$name = color.name) !== null && _color$name !== void 0 ? _color$name : '', " ").concat(color.hex),
|
|
36
37
|
"aria-describedby": ariaDescribedBy,
|
|
37
38
|
ref: ref,
|
|
38
|
-
"data-testid": getSubDataTestId(dataTestId,
|
|
39
|
+
"data-testid": getSubDataTestId(dataTestId, "".concat(color.hex.substring(1), "-swatch"))
|
|
39
40
|
}));
|
|
40
41
|
});
|
|
41
42
|
function Palette(_ref2) {
|
|
@@ -43,7 +44,8 @@ function Palette(_ref2) {
|
|
|
43
44
|
onColorSwatchClick,
|
|
44
45
|
palette,
|
|
45
46
|
containerId,
|
|
46
|
-
dataTestId
|
|
47
|
+
dataTestId,
|
|
48
|
+
removeUpperMargin
|
|
47
49
|
} = _ref2;
|
|
48
50
|
const [focusedSwatchIndex, setFocusedSwatchIndex] = useState(0);
|
|
49
51
|
const {
|
|
@@ -51,7 +53,7 @@ function Palette(_ref2) {
|
|
|
51
53
|
} = useTranslation();
|
|
52
54
|
const paletteAriaLabel = translate('palette');
|
|
53
55
|
const swatchAriaDesc = translate('selectColor');
|
|
54
|
-
const swatchDescriptionId =
|
|
56
|
+
const swatchDescriptionId = "".concat(containerId, "-swatch-desc");
|
|
55
57
|
const swatchRefs = useRef({});
|
|
56
58
|
|
|
57
59
|
// split palette into rows for grid aria role semantics
|
|
@@ -66,10 +68,10 @@ function Palette(_ref2) {
|
|
|
66
68
|
}, [palette]);
|
|
67
69
|
function updateFocusedSwatchIndex(e, direction) {
|
|
68
70
|
e.preventDefault(); // prevents scroll
|
|
69
|
-
setIsKeyboardUser(true);
|
|
70
71
|
setFocusedSwatchIndex(prevFocusedSwatchIndex => {
|
|
72
|
+
var _swatchRefs$current, _swatchRefs$current$t;
|
|
71
73
|
const targetId = calculateTargetId(prevFocusedSwatchIndex, palette.length, direction);
|
|
72
|
-
swatchRefs.current
|
|
74
|
+
(_swatchRefs$current = swatchRefs.current) === null || _swatchRefs$current === void 0 ? void 0 : (_swatchRefs$current$t = _swatchRefs$current[targetId]) === null || _swatchRefs$current$t === void 0 ? void 0 : _swatchRefs$current$t.focus();
|
|
73
75
|
return targetId;
|
|
74
76
|
});
|
|
75
77
|
}
|
|
@@ -99,7 +101,9 @@ function Palette(_ref2) {
|
|
|
99
101
|
React__default.createElement("div", {
|
|
100
102
|
role: "grid",
|
|
101
103
|
"aria-label": paletteAriaLabel,
|
|
102
|
-
className: styles.palette,
|
|
104
|
+
className: classNames(styles.palette, {
|
|
105
|
+
[styles.removeUpperMargin]: removeUpperMargin
|
|
106
|
+
}),
|
|
103
107
|
onKeyDown: handleKeyDown,
|
|
104
108
|
"data-testid": getSubDataTestId(dataTestId, 'palette')
|
|
105
109
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -9,7 +9,6 @@ import useTranslation from '../../utils/Translation/useTranslation.js';
|
|
|
9
9
|
import useEventCallback from '../../hooks/useEventCallback/useEventCallback.js';
|
|
10
10
|
import getMousePosition from './utils/getMousePosition.js';
|
|
11
11
|
import useMouseDrag from '../../hooks/useMouseDrag/useMouseDrag.js';
|
|
12
|
-
import { setIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
13
12
|
import hsvToHex from './utils/hsvToHex.js';
|
|
14
13
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
15
14
|
|
|
@@ -23,7 +22,7 @@ function Saturation(_ref) {
|
|
|
23
22
|
} = _ref;
|
|
24
23
|
const gridRef = useRef(null);
|
|
25
24
|
const loopRef = useRef(null);
|
|
26
|
-
const saturationId =
|
|
25
|
+
const saturationId = "".concat(containerId, "-saturation");
|
|
27
26
|
const {
|
|
28
27
|
translate
|
|
29
28
|
} = useTranslation();
|
|
@@ -51,42 +50,34 @@ function Saturation(_ref) {
|
|
|
51
50
|
switch (e.key) {
|
|
52
51
|
case 'ArrowUp':
|
|
53
52
|
e.preventDefault(); // prevent page scroll
|
|
54
|
-
setIsKeyboardUser(true);
|
|
55
53
|
onSaturationChange(hsv.s, Math.min(hsv.v + 0.01, 1));
|
|
56
54
|
break;
|
|
57
55
|
case 'ArrowDown':
|
|
58
56
|
e.preventDefault(); // prevent page scroll
|
|
59
|
-
setIsKeyboardUser(true);
|
|
60
57
|
onSaturationChange(hsv.s, Math.max(hsv.v - 0.01, 0));
|
|
61
58
|
break;
|
|
62
59
|
case 'ArrowLeft':
|
|
63
60
|
e.preventDefault(); // prevent page scroll
|
|
64
|
-
setIsKeyboardUser(true);
|
|
65
61
|
onSaturationChange(Math.max(hsv.s - 0.01, 0), hsv.v);
|
|
66
62
|
break;
|
|
67
63
|
case 'ArrowRight':
|
|
68
64
|
e.preventDefault(); // prevent page scroll
|
|
69
|
-
setIsKeyboardUser(true);
|
|
70
65
|
onSaturationChange(Math.min(hsv.s + 0.01, 1), hsv.v);
|
|
71
66
|
break;
|
|
72
67
|
case 'Home':
|
|
73
68
|
e.preventDefault(); // prevent page scroll
|
|
74
|
-
setIsKeyboardUser(true);
|
|
75
69
|
onSaturationChange(0, hsv.v);
|
|
76
70
|
break;
|
|
77
71
|
case 'End':
|
|
78
72
|
e.preventDefault(); // prevent page scroll
|
|
79
|
-
setIsKeyboardUser(true);
|
|
80
73
|
onSaturationChange(1, hsv.v);
|
|
81
74
|
break;
|
|
82
75
|
case 'PageUp':
|
|
83
76
|
e.preventDefault(); // prevent page scroll
|
|
84
|
-
setIsKeyboardUser(true);
|
|
85
77
|
onSaturationChange(hsv.s, 1);
|
|
86
78
|
break;
|
|
87
79
|
case 'PageDown':
|
|
88
80
|
e.preventDefault(); // prevent page scroll
|
|
89
|
-
setIsKeyboardUser(true);
|
|
90
81
|
onSaturationChange(hsv.s, 0);
|
|
91
82
|
break;
|
|
92
83
|
default:
|
|
@@ -96,22 +87,23 @@ function Saturation(_ref) {
|
|
|
96
87
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
97
88
|
className: styles.saturationGrid,
|
|
98
89
|
style: {
|
|
99
|
-
backgroundColor:
|
|
90
|
+
backgroundColor: "".concat(hsvToHex({
|
|
100
91
|
h: hsv.h,
|
|
101
92
|
s: 1,
|
|
102
93
|
v: 1
|
|
103
|
-
})
|
|
94
|
+
}))
|
|
104
95
|
},
|
|
105
96
|
onMouseDown: e => {
|
|
97
|
+
var _loopRef$current;
|
|
106
98
|
// prevent text highlighting while dragging
|
|
107
99
|
e.preventDefault();
|
|
108
|
-
loopRef.current
|
|
100
|
+
(_loopRef$current = loopRef.current) === null || _loopRef$current === void 0 ? void 0 : _loopRef$current.focus();
|
|
109
101
|
handleMouseDown(e);
|
|
110
102
|
},
|
|
111
103
|
"data-testid": getSubDataTestId(dataTestId, 'saturation-grid'),
|
|
112
104
|
ref: gridRef
|
|
113
105
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
114
|
-
id:
|
|
106
|
+
id: "".concat(saturationId, "-saturation-desc"),
|
|
115
107
|
className: styles.hidden
|
|
116
108
|
}, saturationAriaDesc), /*#__PURE__*/React__default.createElement("div", {
|
|
117
109
|
"aria-live": loopRef.current === document.activeElement ? 'assertive' : 'off',
|
|
@@ -122,13 +114,13 @@ function Saturation(_ref) {
|
|
|
122
114
|
}, valueAriaLive), /*#__PURE__*/React__default.createElement("div", {
|
|
123
115
|
className: styles.saturationLoop,
|
|
124
116
|
style: {
|
|
125
|
-
left:
|
|
126
|
-
bottom:
|
|
117
|
+
left: "calc(".concat(hsv.s * 100, "% - ").concat(hsv.s * 12, "px)"),
|
|
118
|
+
bottom: "calc(".concat(hsv.v * 100, "% - ").concat(hsv.v * 12, "px)")
|
|
127
119
|
},
|
|
128
120
|
onKeyDown: handleKeyDown,
|
|
129
121
|
tabIndex: 0,
|
|
130
122
|
"aria-label": saturationAriaLabel,
|
|
131
|
-
"aria-describedby":
|
|
123
|
+
"aria-describedby": "".concat(saturationId, "-saturation-desc"),
|
|
132
124
|
ref: loopRef,
|
|
133
125
|
"data-testid": getSubDataTestId(dataTestId, 'saturation-thumb')
|
|
134
126
|
}));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import hexToRgb from './hexToRgb.js';
|
|
2
2
|
|
|
3
3
|
function hexToRgbaString(color) {
|
|
4
|
+
var _color$alpha;
|
|
4
5
|
const rgb = hexToRgb(color.hex);
|
|
5
|
-
const alpha = color.alpha
|
|
6
|
-
return
|
|
6
|
+
const alpha = (_color$alpha = color.alpha) !== null && _color$alpha !== void 0 ? _color$alpha : 100;
|
|
7
|
+
return "rgba(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(alpha / 100, ")");
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export { hexToRgbaString as default };
|
|
@@ -7,7 +7,7 @@ function rgbToHex(_ref) {
|
|
|
7
7
|
const rStr = r.toString(16).padStart(2, '0');
|
|
8
8
|
const gStr = g.toString(16).padStart(2, '0');
|
|
9
9
|
const bStr = b.toString(16).padStart(2, '0');
|
|
10
|
-
return
|
|
10
|
+
return "#".concat(rStr).concat(gStr).concat(bStr);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { rgbToHex as default };
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
function validateHex(currentColor, newHex, isAlphaEnabled) {
|
|
2
|
+
var _currentColor$alpha;
|
|
2
3
|
// set current alpha to hex format
|
|
3
|
-
const alpha = Math.round((currentColor.alpha
|
|
4
|
+
const alpha = Math.round(((_currentColor$alpha = currentColor.alpha) !== null && _currentColor$alpha !== void 0 ? _currentColor$alpha : 100) / 100 * 255).toString(16).toUpperCase().padStart(2, '0');
|
|
4
5
|
let newAlpha = isAlphaEnabled ? alpha : '';
|
|
5
6
|
let validatedHex;
|
|
6
7
|
const hexLength = isAlphaEnabled ? 8 : 6;
|
|
7
8
|
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
8
9
|
|
|
9
10
|
// if newHex contains invalid characters or is empty string, revert to previous color
|
|
10
|
-
if (!hexRegex.test(newHex.slice(0, hexLength))) return
|
|
11
|
+
if (!hexRegex.test(newHex.slice(0, hexLength))) return "".concat(currentColor.hex.substring(1)).concat(newAlpha);
|
|
11
12
|
|
|
12
13
|
// match validation pattern based on string length
|
|
13
14
|
switch (newHex.length) {
|
|
14
15
|
case 1:
|
|
15
|
-
validatedHex =
|
|
16
|
+
validatedHex = "".concat(newHex.repeat(6)).concat(newAlpha);
|
|
16
17
|
break;
|
|
17
18
|
case 2:
|
|
18
|
-
validatedHex =
|
|
19
|
+
validatedHex = "".concat(newHex.repeat(3)).concat(newAlpha);
|
|
19
20
|
break;
|
|
20
21
|
case 3:
|
|
21
|
-
validatedHex =
|
|
22
|
+
validatedHex = "".concat(newHex[0].repeat(2)).concat(newHex[1].repeat(2)).concat(newHex[2].repeat(2)).concat(newAlpha);
|
|
22
23
|
break;
|
|
23
24
|
case 4:
|
|
24
25
|
case 5:
|
|
25
26
|
newAlpha = isAlphaEnabled ? newHex[3].repeat(2) : '';
|
|
26
|
-
validatedHex =
|
|
27
|
+
validatedHex = "".concat(newHex[0].repeat(2)).concat(newHex[1].repeat(2)).concat(newHex[2].repeat(2)).concat(newAlpha);
|
|
27
28
|
break;
|
|
28
29
|
case 6:
|
|
29
|
-
validatedHex =
|
|
30
|
+
validatedHex = "".concat(newHex).concat(newAlpha);
|
|
30
31
|
break;
|
|
31
32
|
case 7:
|
|
32
|
-
validatedHex =
|
|
33
|
+
validatedHex = "".concat(newHex.substring(0, 6)).concat(newAlpha);
|
|
33
34
|
break;
|
|
34
35
|
default:
|
|
35
36
|
newAlpha = isAlphaEnabled ? newHex.substring(6, 8) : '';
|
|
36
|
-
validatedHex =
|
|
37
|
+
validatedHex = "".concat(newHex.substring(0, 6)).concat(newAlpha);
|
|
37
38
|
break;
|
|
38
39
|
}
|
|
39
40
|
return validatedHex.toUpperCase();
|
|
@@ -2,6 +2,7 @@ import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
|
2
2
|
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
3
|
import React__default, { forwardRef, useMemo, useRef, useState, useCallback, useEffect, cloneElement } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
+
import { useFocusVisible } from '@react-aria/interactions';
|
|
5
6
|
import styles from './Combobox2.js';
|
|
6
7
|
import ComboboxInput from './ComboboxInput.js';
|
|
7
8
|
import ComboboxList from './ComboboxList.js';
|
|
@@ -18,8 +19,14 @@ import useControllableState from '../../hooks/useControllableState/useControllab
|
|
|
18
19
|
import useClickOutside from '../../hooks/useClickOutside/useClickOutside.js';
|
|
19
20
|
import wrapEvent from '../../utils/wrapEvent/wrapEvent.js';
|
|
20
21
|
|
|
21
|
-
const getOptionLabel = option =>
|
|
22
|
-
|
|
22
|
+
const getOptionLabel = option => {
|
|
23
|
+
var _option$props;
|
|
24
|
+
return option === null || option === void 0 ? void 0 : (_option$props = option.props) === null || _option$props === void 0 ? void 0 : _option$props.label;
|
|
25
|
+
};
|
|
26
|
+
const getOptionValue = option => {
|
|
27
|
+
var _option$props2;
|
|
28
|
+
return option === null || option === void 0 ? void 0 : (_option$props2 = option.props) === null || _option$props2 === void 0 ? void 0 : _option$props2.value;
|
|
29
|
+
};
|
|
23
30
|
const doesOptionMatchFilter = (option, header, inputValue) => {
|
|
24
31
|
var _context, _context2;
|
|
25
32
|
const label = getOptionLabel(option);
|
|
@@ -57,26 +64,34 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
57
64
|
} = useTranslation();
|
|
58
65
|
const isOptionSelectedOnKeyboardHighlight = unstable_isOptionSelectedOnKeyboardHighlight;
|
|
59
66
|
const isFilteringDisabled = isOptionSelectedOnKeyboardHighlight || externalIsFilteringDisabled;
|
|
67
|
+
const {
|
|
68
|
+
isFocusVisible
|
|
69
|
+
} = useFocusVisible({
|
|
70
|
+
isTextInput: true
|
|
71
|
+
});
|
|
60
72
|
let comboboxInput = /*#__PURE__*/React__default.createElement(ComboboxInput, null);
|
|
61
73
|
let comboboxList = /*#__PURE__*/React__default.createElement(ComboboxList, null);
|
|
62
74
|
|
|
63
75
|
// Gets the <ComboboxInput> and <ComboboxList> components from the children
|
|
64
76
|
React__default.Children.forEach(children, child => {
|
|
65
77
|
if ( /*#__PURE__*/React__default.isValidElement(child)) {
|
|
66
|
-
if (child
|
|
78
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === ComboboxInput) {
|
|
67
79
|
comboboxInput = child;
|
|
68
|
-
} else if (child
|
|
80
|
+
} else if ((child === null || child === void 0 ? void 0 : child.type) === ComboboxList) {
|
|
69
81
|
comboboxList = child;
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
});
|
|
73
85
|
const listContainerId = useId(comboboxList.props.id);
|
|
74
|
-
const noMatchesFoundContainerId =
|
|
86
|
+
const noMatchesFoundContainerId = "".concat(listContainerId, "-no-matches-found");
|
|
75
87
|
|
|
76
88
|
// Extracts all ComboboxOptions
|
|
77
|
-
const [, [allOptions]] = useMemo(() =>
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
const [, [allOptions]] = useMemo(() => {
|
|
90
|
+
var _comboboxList, _comboboxList$props;
|
|
91
|
+
return filterChildren((_comboboxList = comboboxList) === null || _comboboxList === void 0 ? void 0 : (_comboboxList$props = _comboboxList.props) === null || _comboboxList$props === void 0 ? void 0 : _comboboxList$props.children, [{
|
|
92
|
+
matcher: child => (child === null || child === void 0 ? void 0 : child.type) === ComboboxOption
|
|
93
|
+
}]);
|
|
94
|
+
}, [comboboxList]);
|
|
80
95
|
const {
|
|
81
96
|
defaultValue: defaultInputValue,
|
|
82
97
|
onChange: onInputChange,
|
|
@@ -87,7 +102,6 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
102
|
const inputRef = useRef(null);
|
|
88
103
|
const iconRef = useRef(null);
|
|
89
104
|
const [isFlyoutOpen, setIsFlyoutOpen] = useControllableState(false, onIsOpenChange, externalIsOpen);
|
|
90
|
-
const [isKeyboardUser, setIsKeyboardUser] = useState(false);
|
|
91
105
|
|
|
92
106
|
// Highlighted index is only used when isOptionSelectedOnKeyboardHighlight is set to false
|
|
93
107
|
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
@@ -100,7 +114,7 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
100
114
|
const [selectedOptionLabel, setSelectedOptionLabel] = useState(() => getLabelForValue(selectedOptionValue) || externalInputValue || defaultInputValue || '');
|
|
101
115
|
const [inputValue, setInputValue] = useControllableState(selectedOptionLabel,
|
|
102
116
|
// `e &&` prevents `ComboboxInput` from calling consumer-passed `onChange` for consumer-controlled `Combobox` value updates.
|
|
103
|
-
(_, e) => e && onInputChange
|
|
117
|
+
(_, e) => e && (onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(e)), externalInputValue);
|
|
104
118
|
|
|
105
119
|
// listen for updates from controlled value
|
|
106
120
|
useEffect(() => {
|
|
@@ -128,6 +142,7 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
128
142
|
|
|
129
143
|
// Gets the filtered options based on the current input value (only if isFilteringDisabled is false)
|
|
130
144
|
const [listChildrenFilteredOptions, [, filteredOptions]] = useMemo(() => {
|
|
145
|
+
var _comboboxList2, _comboboxList2$props;
|
|
131
146
|
let currentHeaderTitle;
|
|
132
147
|
const handleSelect = option => {
|
|
133
148
|
const newOptionValue = getOptionValue(option);
|
|
@@ -139,15 +154,16 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
139
154
|
}
|
|
140
155
|
});
|
|
141
156
|
};
|
|
142
|
-
return filterChildren(comboboxList
|
|
157
|
+
return filterChildren((_comboboxList2 = comboboxList) === null || _comboboxList2 === void 0 ? void 0 : (_comboboxList2$props = _comboboxList2.props) === null || _comboboxList2$props === void 0 ? void 0 : _comboboxList2$props.children, [
|
|
143
158
|
/*
|
|
144
159
|
* For each header, adds a key value pair to the headerCounts object where the key is the header title and the value is 0.
|
|
145
160
|
* The value will be updated in the matcher/modifier below this matcher/modifier.
|
|
146
161
|
*/
|
|
147
162
|
{
|
|
148
|
-
matcher: child => child
|
|
163
|
+
matcher: child => (child === null || child === void 0 ? void 0 : child.type) === ComboboxHeader,
|
|
149
164
|
modifier: child => {
|
|
150
|
-
|
|
165
|
+
var _props;
|
|
166
|
+
currentHeaderTitle = (_props = child.props) === null || _props === void 0 ? void 0 : _props.title;
|
|
151
167
|
headerCounts[currentHeaderTitle] = 0;
|
|
152
168
|
return child;
|
|
153
169
|
}
|
|
@@ -157,16 +173,18 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
157
173
|
* Otherwise, returns null.
|
|
158
174
|
*/
|
|
159
175
|
{
|
|
160
|
-
matcher: child => child
|
|
176
|
+
matcher: child => (child === null || child === void 0 ? void 0 : child.type) === ComboboxOption,
|
|
161
177
|
modifier: (child, index) => {
|
|
162
178
|
if (inputValue === selectedOptionLabel || isFilteringDisabled || doesOptionMatchFilter(child, currentHeaderTitle, inputValue)) {
|
|
179
|
+
var _props$id;
|
|
163
180
|
headerCounts[currentHeaderTitle] += 1;
|
|
164
181
|
return /*#__PURE__*/cloneElement(child, {
|
|
165
182
|
onSelect: e => {
|
|
166
|
-
|
|
183
|
+
var _props2, _props2$onSelect;
|
|
184
|
+
child === null || child === void 0 ? void 0 : (_props2 = child.props) === null || _props2 === void 0 ? void 0 : (_props2$onSelect = _props2.onSelect) === null || _props2$onSelect === void 0 ? void 0 : _props2$onSelect.call(_props2, e);
|
|
167
185
|
|
|
168
186
|
// Prevents form submission
|
|
169
|
-
if (e
|
|
187
|
+
if ((e === null || e === void 0 ? void 0 : e.key) === 'Enter') {
|
|
170
188
|
e.preventDefault();
|
|
171
189
|
}
|
|
172
190
|
if (!e.key) {
|
|
@@ -178,18 +196,16 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
178
196
|
if (!isOptionSelectedOnKeyboardHighlight) {
|
|
179
197
|
setHighlightedIndex(index);
|
|
180
198
|
}
|
|
181
|
-
setIsKeyboardUser(false);
|
|
182
199
|
}),
|
|
183
200
|
onMouseLeave: wrapEvent(child.props.onMouseLeave, () => {
|
|
184
201
|
if (!isOptionSelectedOnKeyboardHighlight) {
|
|
185
202
|
setHighlightedIndex(-1);
|
|
186
203
|
}
|
|
187
|
-
setIsKeyboardUser(false);
|
|
188
204
|
}),
|
|
189
205
|
isHighlightedOnHover: isOptionSelectedOnKeyboardHighlight,
|
|
190
206
|
isHighlighted: isOptionSelectedOnKeyboardHighlight ? false : index === highlightedIndex,
|
|
191
207
|
isSelected: isOptionSelectedOnKeyboardHighlight ? index === selectedIndex : selectedOptionValue === getOptionValue(child),
|
|
192
|
-
id: child.props.id
|
|
208
|
+
id: (_props$id = child.props.id) !== null && _props$id !== void 0 ? _props$id : "".concat(listContainerId, "-option-").concat(index),
|
|
193
209
|
ref: node => {
|
|
194
210
|
optionRefs.current[Number(index)] = node;
|
|
195
211
|
}
|
|
@@ -203,16 +219,19 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
203
219
|
|
|
204
220
|
// Gets all filtered options, as well as headers that have at least one filtered option
|
|
205
221
|
const [listChildrenFilteredOptionsAndHeaders] = useMemo(() => filterChildren(listChildrenFilteredOptions, [{
|
|
206
|
-
matcher: child => child
|
|
222
|
+
matcher: child => (child === null || child === void 0 ? void 0 : child.type) === ComboboxOption
|
|
207
223
|
}, {
|
|
208
|
-
matcher: child => child
|
|
209
|
-
modifier: child =>
|
|
224
|
+
matcher: child => (child === null || child === void 0 ? void 0 : child.type) === ComboboxHeader,
|
|
225
|
+
modifier: child => {
|
|
226
|
+
var _props3;
|
|
227
|
+
return headerCounts[(_props3 = child.props) === null || _props3 === void 0 ? void 0 : _props3.title] ? child : null;
|
|
228
|
+
}
|
|
210
229
|
}]), [headerCounts, listChildrenFilteredOptions]);
|
|
211
230
|
const keyboardHighlightOrSelectOption = (index, e) => {
|
|
212
|
-
setIsKeyboardUser(true);
|
|
213
231
|
if (isOptionSelectedOnKeyboardHighlight) {
|
|
232
|
+
var _filteredOptions$inde, _filteredOptions$inde2, _filteredOptions$inde3;
|
|
214
233
|
setSelectedIndex(index);
|
|
215
|
-
filteredOptions[index]
|
|
234
|
+
(_filteredOptions$inde = filteredOptions[index]) === null || _filteredOptions$inde === void 0 ? void 0 : (_filteredOptions$inde2 = _filteredOptions$inde.props) === null || _filteredOptions$inde2 === void 0 ? void 0 : (_filteredOptions$inde3 = _filteredOptions$inde2.onSelect) === null || _filteredOptions$inde3 === void 0 ? void 0 : _filteredOptions$inde3.call(_filteredOptions$inde2, e);
|
|
216
235
|
} else {
|
|
217
236
|
setHighlightedIndex(index);
|
|
218
237
|
}
|
|
@@ -270,7 +289,8 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
270
289
|
case 'Enter':
|
|
271
290
|
if (isFlyoutOpen) {
|
|
272
291
|
if (!isOptionSelectedOnKeyboardHighlight && filteredOptions.length > 0 && filteredOptions[highlightedIndex] !== undefined) {
|
|
273
|
-
|
|
292
|
+
var _filteredOptions$high, _filteredOptions$high2, _filteredOptions$high3;
|
|
293
|
+
(_filteredOptions$high = filteredOptions[highlightedIndex]) === null || _filteredOptions$high === void 0 ? void 0 : (_filteredOptions$high2 = _filteredOptions$high.props) === null || _filteredOptions$high2 === void 0 ? void 0 : (_filteredOptions$high3 = _filteredOptions$high2.onSelect) === null || _filteredOptions$high3 === void 0 ? void 0 : _filteredOptions$high3.call(_filteredOptions$high2, e);
|
|
274
294
|
}
|
|
275
295
|
}
|
|
276
296
|
setIsFlyoutOpen(false);
|
|
@@ -331,11 +351,12 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
331
351
|
useEffect(() => {
|
|
332
352
|
const currentIndex = isOptionSelectedOnKeyboardHighlight ? selectedIndex : highlightedIndex;
|
|
333
353
|
const optionRef = optionRefs.current[currentIndex];
|
|
334
|
-
if (
|
|
354
|
+
if (isFocusVisible && isFlyoutOpen && optionRef && listRef !== null && listRef !== void 0 && listRef.current) {
|
|
355
|
+
var _listRef$current, _listRef$current2;
|
|
335
356
|
if (currentIndex === 0) {
|
|
336
357
|
// Scrolls the first header into view if one exists
|
|
337
358
|
listRef.current.scrollTop = 0;
|
|
338
|
-
} else if (listRef.current
|
|
359
|
+
} else if (((_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollHeight) > ((_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.clientHeight)) {
|
|
339
360
|
const scrollBottom = listRef.current.clientHeight + listRef.current.scrollTop;
|
|
340
361
|
const elementBottom = optionRef.offsetTop + optionRef.offsetHeight;
|
|
341
362
|
if (elementBottom > scrollBottom) {
|
|
@@ -345,7 +366,7 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
345
366
|
}
|
|
346
367
|
}
|
|
347
368
|
}
|
|
348
|
-
}, [
|
|
369
|
+
}, [isFocusVisible, highlightedIndex, selectedIndex, isOptionSelectedOnKeyboardHighlight, isFlyoutOpen]);
|
|
349
370
|
|
|
350
371
|
// Updates the selected option label and selected option index based on the new selected option value
|
|
351
372
|
useEffect(() => {
|
|
@@ -375,16 +396,18 @@ const Combobox = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
375
396
|
const activeDescendantId = useMemo(() => {
|
|
376
397
|
if (isAriaExpanded) {
|
|
377
398
|
if (unstable_isLoading) {
|
|
378
|
-
return
|
|
399
|
+
return "".concat(listContainerId, "-loading-spinner");
|
|
379
400
|
}
|
|
380
401
|
if (filteredOptions.length === 0) {
|
|
381
402
|
return undefined;
|
|
382
403
|
}
|
|
383
404
|
if (selectedIndex !== -1) {
|
|
384
|
-
|
|
405
|
+
var _filteredOptions$sele;
|
|
406
|
+
return (_filteredOptions$sele = filteredOptions[selectedIndex]) === null || _filteredOptions$sele === void 0 ? void 0 : _filteredOptions$sele.props.id;
|
|
385
407
|
}
|
|
386
408
|
if (highlightedIndex !== -1) {
|
|
387
|
-
|
|
409
|
+
var _filteredOptions$high4;
|
|
410
|
+
return (_filteredOptions$high4 = filteredOptions[highlightedIndex]) === null || _filteredOptions$high4 === void 0 ? void 0 : _filteredOptions$high4.props.id;
|
|
388
411
|
}
|
|
389
412
|
}
|
|
390
413
|
return undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".
|
|
4
|
-
var styles = {"combobox":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._qt655{position:relative;display:inline-block}._6yCG2{padding-right:36px}._6yCG2._-yWRC{box-shadow:none!important;border:1px solid #898989!important}._A8C-V{margin-top:4px}._2sk--{position:absolute;right:4px;bottom:4px;height:28px;width:28px;border-radius:4px;fill:#515559;cursor:pointer}._2sk--:hover{background-color:rgba(50,54,58,.08)}._2sk--:active{background-color:rgba(50,54,58,.11)}._2sk--._jl2QZ{transform:rotate(-180deg)}._2sk--._L83pp{opacity:.4}._B-nk4{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._L83pp{cursor:not-allowed}._L83pp:hover{background-color:transparent}";
|
|
4
|
+
var styles = {"combobox":"_qt655","comboboxInput":"_6yCG2","ignoreFocusStyle":"_-yWRC","labelledInput":"_A8C-V","comboboxIcon":"_2sk--","open":"_jl2QZ","disabled":"_L83pp","comboboxEmpty":"_B-nk4"};
|
|
5
|
+
var stylesheet="._qt655{position:relative;display:inline-block}._6yCG2{padding-right:36px}._6yCG2._-yWRC{box-shadow:none!important;border:1px solid #898989!important}._A8C-V{margin-top:4px}._2sk--{position:absolute;right:4px;bottom:4px;height:28px;width:28px;border-radius:4px;fill:#515559;cursor:pointer}._2sk--:hover{background-color:rgba(50,54,58,.08)}._2sk--:active{background-color:rgba(50,54,58,.11)}._2sk--._jl2QZ{transform:rotate(-180deg)}._2sk--._L83pp{opacity:.4}._B-nk4{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._L83pp{cursor:not-allowed}._L83pp:hover{background-color:transparent}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -13,7 +13,7 @@ const ComboboxHeader = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
13
13
|
} = _ref;
|
|
14
14
|
return /*#__PURE__*/React__default.createElement(FlyoutHeader, _extends({}, rest, {
|
|
15
15
|
title: title,
|
|
16
|
-
onMouseDown: wrapEvent(onMouseDown, e => e
|
|
16
|
+
onMouseDown: wrapEvent(onMouseDown, e => e === null || e === void 0 ? void 0 : e.preventDefault()),
|
|
17
17
|
ref: ref
|
|
18
18
|
}), children);
|
|
19
19
|
});
|
|
@@ -34,10 +34,11 @@ const ComboboxIcon = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
34
34
|
if (inputRef.current === document.activeElement) {
|
|
35
35
|
setIsOpen(!isOpen);
|
|
36
36
|
} else {
|
|
37
|
-
|
|
37
|
+
var _inputRef$current;
|
|
38
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
38
39
|
}
|
|
39
40
|
}) : undefined,
|
|
40
|
-
onMouseDown: wrapEvent(onMouseDown, e => e
|
|
41
|
+
onMouseDown: wrapEvent(onMouseDown, e => e === null || e === void 0 ? void 0 : e.preventDefault()),
|
|
41
42
|
ref: mergeRefs(ref, iconRef),
|
|
42
43
|
"aria-hidden": "true"
|
|
43
44
|
}));
|