@qualtrics/ui-react 2.19.0 → 2.20.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 +45 -0
- package/dist/__shared/cjs/{index-bf07471d.js → index-579c4690.js} +10 -7
- package/dist/__shared/cjs/{index-4e4cc354.js → index-90d4069b.js} +999 -1875
- package/dist/components/Accordion/Accordion.js +1 -5
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +8 -10
- package/dist/components/Accordion/AccordionPanel.js +3 -3
- package/dist/components/BreakpointSwitch/Breakpoint.js +0 -2
- package/dist/components/BreakpointSwitch/BreakpointSwitch.js +0 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/Button/Button2.js +2 -7
- package/dist/components/ButtonGroup/ButtonGroup.js +1 -2
- 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/VisualCheckbox.js +1 -1
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/Alpha.js +9 -30
- package/dist/components/ColorPicker/ColorPicker.js +33 -42
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +2 -1
- package/dist/components/ColorPicker/ColorPickerFlyoutInputs.js +20 -23
- package/dist/components/ColorPicker/Hue.js +2 -19
- package/dist/components/ColorPicker/Palette.js +7 -27
- package/dist/components/ColorPicker/Saturation.js +8 -29
- package/dist/components/ColorPicker/utils/calculateTargetId.js +10 -20
- package/dist/components/ColorPicker/utils/getMousePosition.js +4 -3
- package/dist/components/ColorPicker/utils/hexToHsv.js +0 -5
- package/dist/components/ColorPicker/utils/hexToRgbaString.js +2 -4
- package/dist/components/ColorPicker/utils/hsvToHex.js +0 -3
- package/dist/components/ColorPicker/utils/rgbToHex.js +1 -1
- package/dist/components/ColorPicker/utils/validateHex.js +12 -19
- package/dist/components/Combobox/Combobox.js +57 -127
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxHeader.js +1 -1
- package/dist/components/Combobox/ComboboxIcon.js +2 -4
- package/dist/components/Combobox/ComboboxInput.js +4 -5
- package/dist/components/Combobox/ComboboxList.js +2 -2
- package/dist/components/ConfigPane/ConfigPane.js +0 -7
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/ChildIndexContext/index.js +0 -1
- package/dist/components/Dropdown/ChildIndexContext/reach-descendants.js +34 -30
- package/dist/components/Dropdown/Dropdown.js +17 -68
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +23 -33
- package/dist/components/Dropdown/DropdownHeader.js +2 -1
- package/dist/components/Dropdown/DropdownList.js +8 -7
- package/dist/components/Dropdown/DropdownOption.js +3 -10
- package/dist/components/Dropdown/DropdownSearch.js +6 -24
- package/dist/components/FilePicker/FilePicker.js +15 -26
- 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 -6
- package/dist/components/FormField/ReadOnlyText.js +2 -1
- package/dist/components/FullScreenTakeover/FullScreenTakeover.js +5 -11
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/Icon.js +3 -6
- package/dist/components/Icon/IconTypes.js +1 -0
- package/dist/components/IconButton/IconButton.js +1 -6
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput.js +16 -33
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input.js +3 -2
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/Input/InputField.js +2 -5
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/InputGroup/InputGroupProvider.js +0 -2
- 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/ConditionContainer.js +0 -2
- package/dist/components/LogicEditor/ConditionSet.js +8 -25
- package/dist/components/LogicEditor/Controls.js +2 -2
- package/dist/components/LogicEditor/LogicEditor.js +3 -12
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/LogicEditor/utils.js +9 -34
- package/dist/components/Modal/Modal.js +22 -35
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +43 -108
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +2 -3
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +20 -32
- package/dist/components/NewMenu/parts/MenuItem.js +2 -3
- package/dist/components/NewMenu/parts/MenuSearchBox.js +2 -1
- package/dist/components/NumberStepper/NumberStepper.js +29 -44
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/NumberStepper/NumberStepperDecrement.js +6 -5
- package/dist/components/NumberStepper/NumberStepperIncrement.js +6 -5
- package/dist/components/NumberStepper/NumberStepperInput.js +10 -12
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination.js +10 -6
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +8 -8
- package/dist/components/Pagination/PaginationPageInput.js +17 -22
- package/dist/components/Pagination/PaginationPreviousButton.js +8 -8
- package/dist/components/Popover/Popover.js +9 -18
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +3 -5
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/QuickSearch/QuickSearchInput.js +6 -23
- package/dist/components/Radio/Radio.js +11 -13
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput.js +5 -11
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/ExpandCollapseButton.js +0 -2
- package/dist/components/SidebarNav/SidebarNav.js +5 -4
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/SidebarNav/SidebarNavLink.js +1 -4
- package/dist/components/Slider/RangeSlider.js +8 -22
- package/dist/components/Slider/Slider.js +7 -26
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Slider/SliderButton.js +7 -9
- 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/TabContextProvider.js +1 -1
- package/dist/components/Tabs/TabList.js +9 -17
- package/dist/components/Tabs/TabPanel.js +3 -3
- package/dist/components/Tabs/TabPanels.js +0 -2
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +13 -42
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/UIProvider/PortalTargetContext.js +0 -1
- package/dist/components/UIProvider/UIProvider.js +2 -2
- package/dist/components/deprecated_ColorPicker/Alpha.js +4 -11
- package/dist/components/deprecated_ColorPicker/Color.js +9 -66
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +2 -8
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_ColorPicker/HexInput.js +1 -7
- package/dist/components/deprecated_ColorPicker/Hue.js +3 -10
- package/dist/components/deprecated_ColorPicker/Saturation.js +7 -14
- package/dist/components/deprecated_ColorPicker/Swatch.js +2 -6
- package/dist/components/deprecated_ColorPicker/useMouseDrag.js +0 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper.js +14 -20
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepperDecrement.js +7 -6
- package/dist/components/deprecated_NumberStepper/NumberStepperIncrement.js +7 -6
- package/dist/components/deprecated_NumberStepper/NumberStepperInput.js +16 -17
- package/dist/components/deprecated_Tabs/Tabs.js +9 -25
- 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 +3 -17
- package/dist/components/deprecated_Toolbar/ToolbarTab.js +10 -26
- package/dist/components/deprecated_Toolbar/ToolbarTabs.js +6 -18
- package/dist/hooks/useBreakpoints/useBreakpoints.js +3 -4
- package/dist/hooks/useClickOutside/useClickOutside.js +2 -7
- package/dist/hooks/useClickOutsidePortals/useClickOutsidePortals.js +3 -6
- package/dist/hooks/useControllableState/useControllableState.js +5 -10
- package/dist/hooks/useDidUpdate/useDidUpdate.js +2 -4
- package/dist/hooks/useEventCallback/useEventCallback.js +2 -1
- package/dist/hooks/useEventListener/useEventListener.js +1 -4
- package/dist/hooks/useFocusSequence/useFocusSequence.js +10 -17
- package/dist/hooks/useId/useId.js +1 -2
- package/dist/hooks/useIsFocused/useIsFocused.js +0 -1
- package/dist/hooks/useIsHovered/useIsHovered.js +0 -1
- package/dist/hooks/useIsTruncated/useIsTruncated.js +4 -3
- package/dist/hooks/useLatest/useLatest.js +0 -1
- package/dist/hooks/useMounted/useMounted.js +0 -1
- package/dist/hooks/useMouseDrag/useMouseDrag.js +0 -4
- package/dist/hooks/useOverlay/useOverlay.js +4 -10
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/usePrevious/usePrevious.js +0 -1
- package/dist/hooks/useResponsiveValue/useResponsiveValue.js +1 -4
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +11 -16
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/components/HeadsetIcon.js +6 -0
- package/dist/icons/components/PauseCircleIcon.js +1 -1
- package/dist/icons/createIconComponent.js +2 -3
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.es.js +1 -0
- package/dist/icons/index.js +2 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.es.js +4 -3
- package/dist/index.js +6 -5
- package/dist/next/AdvancedTable/AdvancedTable.js +82 -188
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTableCell.js +4 -14
- package/dist/next/AdvancedTable/AdvancedTableCheckbox.js +0 -1
- package/dist/next/AdvancedTable/AdvancedTableColumnHeader.js +11 -41
- package/dist/next/AdvancedTable/AdvancedTableColumnHeaderMenu.js +8 -14
- package/dist/next/AdvancedTable/AdvancedTableDragPreview.js +4 -6
- package/dist/next/AdvancedTable/AdvancedTablePagination.js +1 -4
- package/dist/next/AdvancedTable/AdvancedTableRowExpandButton.js +0 -1
- package/dist/next/AdvancedTable/AdvancedTableTypes.js +1 -3
- package/dist/next/AdvancedTable/useAdvancedTableDragAndDrop.js +8 -13
- package/dist/next/AdvancedTable/useComputedWidth.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput.js +5 -20
- 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 +3 -3
- package/dist/next/Combobox/ComboboxGroup.js +1 -1
- package/dist/next/Combobox/ComboboxInput.js +7 -20
- package/dist/next/Combobox/ComboboxOption.js +5 -6
- package/dist/next/Combobox/hooks/useComboboxFilteredGroup/useComboboxFilteredGroup.js +4 -5
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +37 -54
- package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +4 -5
- package/dist/next/Combobox/hooks/useComboboxValue/useComboboxValue.js +5 -3
- package/dist/next/Combobox/hooks/useListboxFlyoutDimensions/useListboxFlyoutDimensions.js +10 -10
- package/dist/next/Combobox/hooks/useSelectedOptionScroll/useSelectedOptionScroll.js +1 -6
- package/dist/next/Combobox/hooks/useShouldRenderGroupHeader/useShouldRenderGroupHeader.js +6 -6
- package/dist/next/Combobox/utils/nodeRegistration/nodeRegistration.js +4 -6
- package/dist/next/Drawer/Drawer.js +5 -16
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor.js +7 -5
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Input/Input.js +5 -8
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu.js +10 -23
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +13 -6
- package/dist/next/Menu/MenuContext.js +0 -2
- package/dist/next/Menu/MenuItem.js +11 -15
- package/dist/next/Menu/MenuPane.js +11 -25
- package/dist/next/Menu/MenuSearch.js +15 -22
- package/dist/next/Menu/SubMenu.js +10 -27
- package/dist/next/Menu/usePaneSearch.js +2 -1
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +12 -19
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +6 -12
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/Stack/Stack.js +0 -3
- package/dist/next/TimePicker/TimeDropdown.js +4 -5
- package/dist/next/TimePicker/TimeInput.js +4 -5
- package/dist/next/TimePicker/TimePicker.js +12 -30
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/TimePicker/TimePickerIcon.js +1 -3
- package/dist/next/TimePicker/utils.js +12 -52
- package/dist/next/ToggleButton/ToggleButton.js +0 -5
- package/dist/next/ToggleButton/ToggleButtonGroup.js +2 -1
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +5 -4
- package/dist/next/index.js +389 -754
- package/dist/utils/Flyout/Flyout.js +4 -5
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/Popper/Popper.js +18 -25
- package/dist/utils/Portal/Portal.js +2 -1
- package/dist/utils/TextOverflowTooltip/TextOverflowTooltip.js +4 -4
- package/dist/utils/Translation/Translate.js +0 -4
- package/dist/utils/Translation/TranslationProvider.js +0 -1
- package/dist/utils/Translation/containsComponentOrElement.js +1 -5
- package/dist/utils/Translation/insertPlaceholders.js +0 -1
- package/dist/utils/Translation/useTranslation.js +7 -14
- package/dist/utils/concatIds/concatIds.js +0 -1
- package/dist/utils/constants.js +2 -2
- package/dist/utils/createContextUtilities/createContextUtilities.js +0 -4
- package/dist/utils/filterChildren/filterChildren.js +8 -17
- package/dist/utils/getSubDataTestId/getSubDataTestId.js +1 -2
- package/dist/utils/keyboardUser/keyboardUser.js +0 -1
- package/dist/utils/mediaQueryManager/mediaQueryManager.js +1 -12
- package/dist/utils/mergeRefs/mergeRefs.js +1 -2
- package/dist/utils/wrapAround/wrapAround.js +1 -2
- package/dist/utils/wrapEvent/wrapEvent.js +2 -4
- package/icons/package.json +2 -1
- package/next/package.json +5 -1
- package/package.json +9 -4
|
@@ -28,8 +28,6 @@ import CaretDownIcon from '../../icons/components/CaretDownIcon.js';
|
|
|
28
28
|
import Input from '../Input/Input.js';
|
|
29
29
|
|
|
30
30
|
function ColorPicker(_ref) {
|
|
31
|
-
var _color$name;
|
|
32
|
-
|
|
33
31
|
let {
|
|
34
32
|
color: externalColor,
|
|
35
33
|
onChange,
|
|
@@ -46,18 +44,16 @@ function ColorPicker(_ref) {
|
|
|
46
44
|
'data-testid': dataTestId
|
|
47
45
|
} = _ref;
|
|
48
46
|
const containerId = useId(id);
|
|
49
|
-
const flyoutId =
|
|
47
|
+
const flyoutId = `${containerId}-flyout`;
|
|
50
48
|
const [color, setColor] = useControllableState(externalColor, onChange, externalColor);
|
|
51
49
|
const [isOpen, setIsOpen] = useState(false);
|
|
52
50
|
const [hsv, setHsv] = useState(hexToHsv(color.hex));
|
|
53
51
|
const [inputHex, setInputHex] = useState(color.hex);
|
|
54
52
|
const [triggerHexUpdate, setTriggerHexUpdate] = useState(0);
|
|
55
53
|
useEffect(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const alpha = isAlphaEnabled ? Math.round(((_color$alpha = color.alpha) !== null && _color$alpha !== void 0 ? _color$alpha : 100) / 100 * 255).toString(16).padStart(2, '0') : '';
|
|
54
|
+
const alpha = isAlphaEnabled ? Math.round((color.alpha ?? 100) / 100 * 255).toString(16).padStart(2, '0') : '';
|
|
59
55
|
const hex = color.hex.substring(1);
|
|
60
|
-
setInputHex(
|
|
56
|
+
setInputHex(`${hex}${alpha}`);
|
|
61
57
|
}, [color, isAlphaEnabled]);
|
|
62
58
|
const anchorRef = useRef(null);
|
|
63
59
|
const popperRef = useRef(null);
|
|
@@ -66,24 +62,25 @@ function ColorPicker(_ref) {
|
|
|
66
62
|
translate
|
|
67
63
|
} = useTranslation();
|
|
68
64
|
const anchorAriaDescription = translate('colorPickerAnchorDesc', {
|
|
69
|
-
colorName:
|
|
65
|
+
colorName: color.name ?? '',
|
|
70
66
|
colorHex: color.hex
|
|
71
67
|
});
|
|
72
|
-
const inputAriaLabel = translate('hex');
|
|
68
|
+
const inputAriaLabel = translate('hex');
|
|
73
69
|
|
|
70
|
+
// Update hsv whenever color.hex changes
|
|
74
71
|
useEffect(() => {
|
|
75
72
|
setHsv(prevHsv => {
|
|
76
73
|
if (hsvToHex(prevHsv) === color.hex) {
|
|
77
74
|
return prevHsv;
|
|
78
75
|
}
|
|
79
|
-
|
|
80
76
|
return hexToHsv(color.hex);
|
|
81
77
|
});
|
|
82
|
-
}, [color.hex]);
|
|
78
|
+
}, [color.hex]);
|
|
79
|
+
|
|
80
|
+
// Update color.hex whenever hsv changes
|
|
83
81
|
// Due to rounding errors between hex and hsv values, this conversion
|
|
84
82
|
// should only happen when the Saturation or Hue sliders are
|
|
85
83
|
// explicitly moved by users
|
|
86
|
-
|
|
87
84
|
useDidUpdate(() => {
|
|
88
85
|
setColor(_ref2 => {
|
|
89
86
|
let {
|
|
@@ -92,7 +89,6 @@ function ColorPicker(_ref) {
|
|
|
92
89
|
...rest
|
|
93
90
|
} = _ref2;
|
|
94
91
|
let newColor;
|
|
95
|
-
|
|
96
92
|
if (JSON.stringify(hsv) === JSON.stringify(hexToHsv(hex)) && name) {
|
|
97
93
|
newColor = {
|
|
98
94
|
name,
|
|
@@ -100,31 +96,31 @@ function ColorPicker(_ref) {
|
|
|
100
96
|
...rest
|
|
101
97
|
};
|
|
102
98
|
} else {
|
|
103
|
-
newColor = {
|
|
99
|
+
newColor = {
|
|
100
|
+
...rest,
|
|
104
101
|
hex: hsvToHex(hsv)
|
|
105
102
|
};
|
|
106
103
|
}
|
|
107
|
-
|
|
108
104
|
return newColor;
|
|
109
|
-
});
|
|
105
|
+
});
|
|
106
|
+
// hsv intentionally removed from dependency array to prevent
|
|
110
107
|
// looping side effects from rounding errors between hex and hsv
|
|
111
|
-
}, [triggerHexUpdate]);
|
|
108
|
+
}, [triggerHexUpdate]);
|
|
112
109
|
|
|
110
|
+
// filter # from hex inputs
|
|
113
111
|
function handleInputHexChange(e) {
|
|
114
112
|
const newInputHex = e.target.value.replace('#', '');
|
|
115
113
|
setInputHex(newInputHex);
|
|
116
114
|
}
|
|
117
|
-
|
|
118
115
|
function handleInputBlur(e) {
|
|
119
|
-
const validatedHex = validateHex(color, e.target.value, isAlphaEnabled);
|
|
120
|
-
|
|
116
|
+
const validatedHex = validateHex(color, e.target.value, isAlphaEnabled);
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
121
118
|
setColor(_ref3 => {
|
|
122
119
|
let {
|
|
123
120
|
name,
|
|
124
121
|
...rest
|
|
125
122
|
} = _ref3;
|
|
126
|
-
const hex =
|
|
127
|
-
|
|
123
|
+
const hex = `#${validatedHex.substring(0, 6)}`;
|
|
128
124
|
if (isAlphaEnabled) {
|
|
129
125
|
const alpha = Math.round(parseInt(validatedHex.substring(6, 8), 16) / 255 * 100);
|
|
130
126
|
return {
|
|
@@ -132,13 +128,12 @@ function ColorPicker(_ref) {
|
|
|
132
128
|
alpha
|
|
133
129
|
};
|
|
134
130
|
}
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
return {
|
|
132
|
+
...rest,
|
|
137
133
|
hex
|
|
138
134
|
};
|
|
139
135
|
});
|
|
140
136
|
}
|
|
141
|
-
|
|
142
137
|
function handleHexBlur(hex) {
|
|
143
138
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
139
|
setColor(_ref4 => {
|
|
@@ -146,39 +141,39 @@ function ColorPicker(_ref) {
|
|
|
146
141
|
name,
|
|
147
142
|
...rest
|
|
148
143
|
} = _ref4;
|
|
149
|
-
const newColor = {
|
|
150
|
-
|
|
144
|
+
const newColor = {
|
|
145
|
+
...rest,
|
|
146
|
+
hex: `#${hex}`
|
|
151
147
|
};
|
|
152
148
|
return newColor;
|
|
153
149
|
});
|
|
154
150
|
}
|
|
155
|
-
|
|
156
151
|
function handleAnchorClick() {
|
|
157
152
|
setIsOpen(prevIsOpen => !prevIsOpen);
|
|
158
153
|
}
|
|
159
|
-
|
|
160
154
|
function handleHueChange(newHue) {
|
|
161
155
|
setHsv(prevHsv => {
|
|
162
|
-
const newHsv = {
|
|
156
|
+
const newHsv = {
|
|
157
|
+
...prevHsv,
|
|
163
158
|
h: Math.round(newHue)
|
|
164
159
|
};
|
|
165
160
|
setTriggerHexUpdate(v => (v + 1) % Number.MAX_SAFE_INTEGER);
|
|
166
161
|
return newHsv;
|
|
167
162
|
});
|
|
168
163
|
}
|
|
169
|
-
|
|
170
164
|
function handleAlphaChange(alpha) {
|
|
171
165
|
setColor(prevColor => {
|
|
172
|
-
const newColor = {
|
|
166
|
+
const newColor = {
|
|
167
|
+
...prevColor,
|
|
173
168
|
alpha: Math.round(alpha)
|
|
174
169
|
};
|
|
175
170
|
return newColor;
|
|
176
171
|
});
|
|
177
172
|
}
|
|
178
|
-
|
|
179
173
|
function handleSaturationChange(newSaturation, newValue) {
|
|
180
174
|
setHsv(prevHsv => {
|
|
181
|
-
const newHsv = {
|
|
175
|
+
const newHsv = {
|
|
176
|
+
...prevHsv,
|
|
182
177
|
s: newSaturation,
|
|
183
178
|
v: newValue
|
|
184
179
|
};
|
|
@@ -186,7 +181,6 @@ function ColorPicker(_ref) {
|
|
|
186
181
|
return newHsv;
|
|
187
182
|
});
|
|
188
183
|
}
|
|
189
|
-
|
|
190
184
|
function handleColorSwatchClick(swatchColor) {
|
|
191
185
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
192
186
|
setColor(_ref5 => {
|
|
@@ -194,27 +188,24 @@ function ColorPicker(_ref) {
|
|
|
194
188
|
name,
|
|
195
189
|
...rest
|
|
196
190
|
} = _ref5;
|
|
197
|
-
const newColor = {
|
|
191
|
+
const newColor = {
|
|
192
|
+
...rest,
|
|
198
193
|
...swatchColor
|
|
199
194
|
};
|
|
200
195
|
return newColor;
|
|
201
196
|
});
|
|
202
197
|
}
|
|
203
|
-
|
|
204
198
|
function handleFlyoutKeyDown(e) {
|
|
205
199
|
switch (e.key) {
|
|
206
200
|
case 'Escape':
|
|
207
201
|
e.preventDefault(); // prevent browser exiting full screen
|
|
208
|
-
|
|
209
202
|
e.stopPropagation();
|
|
210
203
|
setIsOpen(false);
|
|
211
204
|
break;
|
|
212
|
-
|
|
213
205
|
default:
|
|
214
206
|
break;
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
|
-
|
|
218
209
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
219
210
|
className: styles.colorPicker,
|
|
220
211
|
id: containerId,
|
|
@@ -253,11 +244,11 @@ function ColorPicker(_ref) {
|
|
|
253
244
|
onClick: handleAnchorClick,
|
|
254
245
|
"aria-label": ariaLabel,
|
|
255
246
|
"aria-labelledby": ariaLabelledBy,
|
|
256
|
-
"aria-describedby":
|
|
247
|
+
"aria-describedby": `${anchorAriaDescription} ${ariaDescribedBy}`,
|
|
257
248
|
"aria-expanded": isOpen,
|
|
258
249
|
"aria-controls": isOpen ? flyoutId : undefined,
|
|
259
250
|
"aria-haspopup": "dialog",
|
|
260
|
-
ref: mergeRefs(anchorRef, externalButtonRef
|
|
251
|
+
ref: mergeRefs(anchorRef, externalButtonRef ?? null),
|
|
261
252
|
"data-testid": getSubDataTestId(dataTestId, 'anchor-button')
|
|
262
253
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
263
254
|
className: classNames(styles.colorPickerButtonPreview, {
|
|
@@ -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 = {"colorPicker":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._lc-eC{display:flex;line-height:1.15}._lc-eC ._nguXi{display:flex;align-items:center;background-color:#fafafa;border:0;border-radius:4px 0 0 4px;padding:0;cursor:pointer;outline:none}._lc-eC ._nguXi:hover:not(._wKiEc){background-color:#f5f5f5}._lc-eC ._nguXi._wKiEc{cursor:not-allowed;fill:rgba(81,85,89,.4)}._lc-eC ._nguXi:active:not(._wKiEc){background-color:#eee}._lc-eC ._EXASZ{width:18px;height:36px;border-radius:4px 0 0 4px;border:1px solid #898989;border-right-width:0}._lc-eC ._EXASZ._wKiEc{border-color:#d9d9d9}._lc-eC ._7Tfnu{position:relative;background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:18px 18px;background-position:0 0,9px 0,9px -9px,0 9px}._lc-eC ._75xyK{width:18px;height:36px;border:1px solid #898989;border-width:1px 0}._lc-eC ._75xyK._wKiEc{border-color:#d9d9d9}._lc-eC ._nMNV-{height:36px;border:1px solid #898989;border-width:1px 0}._lc-eC ._nMNV-._wKiEc{border-color:#d9d9d9}._lc-eC ._hH9Yf{border-radius:0 4px 4px 0;width:115px;padding-left:21px}._lc-eC ._tY32j{position:absolute;top:10px;left:13px;font-size:14px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._lc-eC ._tY32j._7-8FD{color:#9d9fa1}body.keyboard-user ._nguXi:active:focus,body.keyboard-user ._nguXi:focus{background:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;z-index:10}._VC7Gv{width:264px;padding:8px;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1);line-height:1.15}._VC7Gv ._MqjB8{position:relative;width:246px;height:150px;border-radius:4px;border:1px solid rgba(0,0,0,.43);background:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,transparent);background-origin:border-box}._VC7Gv ._5VEqm{position:absolute;width:12px;height:12px;border-radius:50%;border:1px solid #fff;box-shadow:inset 0 0 0 1px rgba(0,0,0,.5);outline:none;cursor:pointer}._VC7Gv ._4lkLY{display:flex;justify-content:space-between;margin:12px 0}._VC7Gv ._QYZGh{display:flex}._VC7Gv ._YwhXI{width:19px;height:38px;border-radius:2px 0 0 2px;border:1px solid rgba(0,0,0,.43);border-right-width:0}._VC7Gv ._joCG4{width:19px;height:38px;border-radius:0 2px 2px 0;border:1px solid rgba(0,0,0,.43);border-left-width:0}._VC7Gv ._iGv0L{background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:19px 19px;background-position:0 0,9.5px 0,9.5px -9.5px,0 9.5px;border-radius:0 2px 2px 0}._VC7Gv ._-wiaX{width:202px;height:38px;padding:0 3px;border-radius:1px;border:1px solid rgba(0,0,0,.43);background:linear-gradient(90deg,red,red 2%,#ff0 18%,#0f0 34%,#0ff 50%,#00f 66%,#f0f 82%,red 98%,red)}._VC7Gv ._-wiaX._lLjSG{height:16px;margin-bottom:6px}._VC7Gv ._pncFM{position:relative;background-color:#fff;border:1px solid rgba(0,0,0,.25);border-radius:1px;background-clip:padding-box;width:8px;height:38px;outline:none;cursor:pointer;top:-1px}._VC7Gv ._pncFM._lLjSG{height:16px}._VC7Gv ._g0Lb8{position:relative;background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:16px 16px;background-position:0 0,8px 0,8px -8px,0 8px;border-radius:1px}._VC7Gv ._KYwy5{width:202px;height:16px;padding:0 3px;border-radius:1px;border:1px solid rgba(0,0,0,.43);background-origin:border-box!important}._VC7Gv ._kdDO0{position:relative;background-color:#fff;border:1px solid rgba(0,0,0,.25);border-radius:1px;background-clip:padding-box;width:8px;height:16px;outline:none;cursor:pointer;top:-1px}._VC7Gv ._AbFWw{display:flex;justify-content:space-between}._VC7Gv ._DQUHe{display:flex;flex-direction:column;align-items:center}._VC7Gv ._DQUHe._mGge-{margin-left:4px}._VC7Gv ._lFPlo{position:absolute;top:3px;left:5px;font-size:14px;line-height:20px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._VC7Gv ._YToKi{padding:3px 4px 3px 13px!important;width:78px}._VC7Gv ._g50u2{text-align:right;padding:3px 4px 3px 0!important;width:34px}._VC7Gv ._dsoWa{text-align:right;padding:3px 16px 3px 0!important;width:46px}._VC7Gv ._FI2h6{position:absolute;top:3px;right:4px;font-size:14px;line-height:20px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._VC7Gv ._H9MOu{line-height:22px}._VC7Gv ._mXbkl{display:flex}._VC7Gv ._IcBhn{display:flex;flex-wrap:wrap;margin:9px -3px -3px}._VC7Gv ._S-XX0{width:22px;height:22px;margin:3px;border-radius:4px;border:1px solid rgba(0,0,0,.43);outline:none;cursor:pointer}._6AUvh{position:relative}._WDvkj{display:none}._TgaYP{border:0;clip:rect(0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;width:1px;position:absolute}body.keyboard-user ._5VEqm:focus{box-shadow:inset 0 0 0 1px rgba(0,0,0,.5),0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fff}body.keyboard-user ._kdDO0:focus,body.keyboard-user ._pncFM:focus,body.keyboard-user ._S-XX0:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4
|
+
var styles = {"colorPicker":"_lc-eC","colorPickerButton":"_nguXi","disabledButton":"_wKiEc","colorPickerButtonPreview":"_EXASZ","alphaBackground":"_7Tfnu","colorPickerButtonAlphaPreview":"_75xyK","caretIcon":"_nMNV-","colorPickerInput":"_hH9Yf","colorPickerInputDecoration":"_tY32j","disabledDecoration":"_7-8FD","colorPickerFlyout":"_VC7Gv","saturationGrid":"_MqjB8","saturationLoop":"_5VEqm","sliderGroup":"_4lkLY","sliderPreviewContainer":"_QYZGh","sliderPreview":"_YwhXI","sliderPreviewAlpha":"_joCG4","sliderPreviewAlphaBackground":"_iGv0L","hueSliderRail":"_-wiaX","alphaEnabled":"_lLjSG","hueSliderThumb":"_pncFM","alphaSliderRailBackground":"_g0Lb8","alphaSliderRail":"_KYwy5","alphaSliderThumb":"_kdDO0","hexInputGroup":"_AbFWw","hexInputContainer":"_DQUHe","rgbInputContainer":"_mGge-","hexInputDecoration":"_lFPlo","hexInput":"_YToKi","rgbInput":"_g50u2","alphaInput":"_dsoWa","alphaInputDecoration":"_FI2h6","inputLabel":"_H9MOu","rgbContainer":"_mXbkl","palette":"_IcBhn","swatch":"_S-XX0","relativePositionContainer":"_6AUvh","hidden":"_WDvkj","hiddenLiveRegion":"_TgaYP"};
|
|
5
|
+
var stylesheet="._lc-eC{display:flex;line-height:1.15}._lc-eC ._nguXi{display:flex;align-items:center;background-color:#fafafa;border:0;border-radius:4px 0 0 4px;padding:0;cursor:pointer;outline:none}._lc-eC ._nguXi:hover:not(._wKiEc){background-color:#f5f5f5}._lc-eC ._nguXi._wKiEc{cursor:not-allowed;fill:rgba(81,85,89,.4)}._lc-eC ._nguXi:active:not(._wKiEc){background-color:#eee}._lc-eC ._EXASZ{width:18px;height:36px;border-radius:4px 0 0 4px;border:1px solid #898989;border-right-width:0}._lc-eC ._EXASZ._wKiEc{border-color:#d9d9d9}._lc-eC ._7Tfnu{position:relative;background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:18px 18px;background-position:0 0,9px 0,9px -9px,0 9px}._lc-eC ._75xyK{width:18px;height:36px;border:1px solid #898989;border-width:1px 0}._lc-eC ._75xyK._wKiEc{border-color:#d9d9d9}._lc-eC ._nMNV-{height:36px;border:1px solid #898989;border-width:1px 0}._lc-eC ._nMNV-._wKiEc{border-color:#d9d9d9}._lc-eC ._hH9Yf{border-radius:0 4px 4px 0;width:115px;padding-left:21px}._lc-eC ._tY32j{position:absolute;top:10px;left:13px;font-size:14px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._lc-eC ._tY32j._7-8FD{color:#9d9fa1}body.keyboard-user ._nguXi:active:focus,body.keyboard-user ._nguXi:focus{background:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;z-index:10}._VC7Gv{width:264px;padding:8px;background-color:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1);line-height:1.15}._VC7Gv ._MqjB8{position:relative;width:246px;height:150px;border-radius:4px;border:1px solid rgba(0,0,0,.43);background:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,transparent);background-origin:border-box}._VC7Gv ._5VEqm{position:absolute;width:12px;height:12px;border-radius:50%;border:1px solid #fff;box-shadow:inset 0 0 0 1px rgba(0,0,0,.5);outline:none;cursor:pointer}._VC7Gv ._4lkLY{display:flex;justify-content:space-between;margin:12px 0}._VC7Gv ._QYZGh{display:flex}._VC7Gv ._YwhXI{width:19px;height:38px;border-radius:2px 0 0 2px;border:1px solid rgba(0,0,0,.43);border-right-width:0}._VC7Gv ._joCG4{width:19px;height:38px;border-radius:0 2px 2px 0;border:1px solid rgba(0,0,0,.43);border-left-width:0}._VC7Gv ._iGv0L{background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:19px 19px;background-position:0 0,9.5px 0,9.5px -9.5px,0 9.5px;border-radius:0 2px 2px 0}._VC7Gv ._-wiaX{width:202px;height:38px;padding:0 3px;border-radius:1px;border:1px solid rgba(0,0,0,.43);background:linear-gradient(90deg,red,red 2%,#ff0 18%,#0f0 34%,#0ff 50%,#00f 66%,#f0f 82%,red 98%,red)}._VC7Gv ._-wiaX._lLjSG{height:16px;margin-bottom:6px}._VC7Gv ._pncFM{position:relative;background-color:#fff;border:1px solid rgba(0,0,0,.25);border-radius:1px;background-clip:padding-box;width:8px;height:38px;outline:none;cursor:pointer;top:-1px}._VC7Gv ._pncFM._lLjSG{height:16px}._VC7Gv ._g0Lb8{position:relative;background-image:linear-gradient(45deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(135deg,rgba(0,0,0,.1) 25%,transparent 0),linear-gradient(45deg,transparent 75%,rgba(0,0,0,.1) 0),linear-gradient(135deg,transparent 75%,rgba(0,0,0,.1) 0);background-color:#fff;background-size:16px 16px;background-position:0 0,8px 0,8px -8px,0 8px;border-radius:1px}._VC7Gv ._KYwy5{width:202px;height:16px;padding:0 3px;border-radius:1px;border:1px solid rgba(0,0,0,.43);background-origin:border-box!important}._VC7Gv ._kdDO0{position:relative;background-color:#fff;border:1px solid rgba(0,0,0,.25);border-radius:1px;background-clip:padding-box;width:8px;height:16px;outline:none;cursor:pointer;top:-1px}._VC7Gv ._AbFWw{display:flex;justify-content:space-between}._VC7Gv ._DQUHe{display:flex;flex-direction:column;align-items:center}._VC7Gv ._DQUHe._mGge-{margin-left:4px}._VC7Gv ._lFPlo{position:absolute;top:3px;left:5px;font-size:14px;line-height:20px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._VC7Gv ._YToKi{padding:3px 4px 3px 13px!important;width:78px}._VC7Gv ._g50u2{text-align:right;padding:3px 4px 3px 0!important;width:34px}._VC7Gv ._dsoWa{text-align:right;padding:3px 16px 3px 0!important;width:46px}._VC7Gv ._FI2h6{position:absolute;top:3px;right:4px;font-size:14px;line-height:20px;color:#32363a;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none}._VC7Gv ._H9MOu{line-height:22px}._VC7Gv ._mXbkl{display:flex}._VC7Gv ._IcBhn{display:flex;flex-wrap:wrap;margin:9px -3px -3px}._VC7Gv ._S-XX0{width:22px;height:22px;margin:3px;border-radius:4px;border:1px solid rgba(0,0,0,.43);outline:none;cursor:pointer}._6AUvh{position:relative}._WDvkj{display:none}._TgaYP{border:0;clip:rect(0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;width:1px;position:absolute}body.keyboard-user ._5VEqm:focus{box-shadow:inset 0 0 0 1px rgba(0,0,0,.5),0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fff}body.keyboard-user ._kdDO0:focus,body.keyboard-user ._pncFM:focus,body.keyboard-user ._S-XX0:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -41,7 +41,8 @@ const ColorPickerFlyout = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
41
41
|
"aria-label": flyoutAriaLabel,
|
|
42
42
|
className: classNames(className, styles.colorPickerFlyout),
|
|
43
43
|
ref: ref,
|
|
44
|
-
style: {
|
|
44
|
+
style: {
|
|
45
|
+
...style,
|
|
45
46
|
zIndex
|
|
46
47
|
},
|
|
47
48
|
"data-testid": getSubDataTestId(dataTestId, 'flyout')
|
|
@@ -23,7 +23,7 @@ function RGBInput(_ref) {
|
|
|
23
23
|
containerId,
|
|
24
24
|
dataTestId
|
|
25
25
|
} = _ref;
|
|
26
|
-
const inputId =
|
|
26
|
+
const inputId = `${containerId}-${label}-input`;
|
|
27
27
|
const [internalValue, setInternalValue] = useState(externalValue);
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
setInternalValue(externalValue);
|
|
@@ -41,16 +41,13 @@ 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, `${label}-channel`)
|
|
45
45
|
}), /*#__PURE__*/React__default.createElement(Label, {
|
|
46
46
|
htmlFor: inputId,
|
|
47
47
|
className: styles.inputLabel
|
|
48
48
|
}, label));
|
|
49
49
|
}
|
|
50
|
-
|
|
51
50
|
const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
52
|
-
var _color$alpha;
|
|
53
|
-
|
|
54
51
|
let {
|
|
55
52
|
color,
|
|
56
53
|
onHexBlur,
|
|
@@ -59,8 +56,8 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
59
56
|
containerId,
|
|
60
57
|
dataTestId
|
|
61
58
|
} = _ref2;
|
|
62
|
-
const hexInputId =
|
|
63
|
-
const alphaInputId =
|
|
59
|
+
const hexInputId = `${containerId}-hex-input`;
|
|
60
|
+
const alphaInputId = `${containerId}-alpha-input`;
|
|
64
61
|
const {
|
|
65
62
|
translate
|
|
66
63
|
} = useTranslation();
|
|
@@ -72,37 +69,31 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
72
69
|
const [internalHex, setInternalHex] = useState(color.hex);
|
|
73
70
|
useEffect(() => {
|
|
74
71
|
setInternalHex(color.hex.substring(1));
|
|
75
|
-
}, [color.hex]);
|
|
72
|
+
}, [color.hex]);
|
|
76
73
|
|
|
74
|
+
// filter # from hex input
|
|
77
75
|
function handleHexInputChange(e) {
|
|
78
76
|
const newInternalHex = e.target.value.replace('#', '');
|
|
79
77
|
setInternalHex(newInternalHex);
|
|
80
78
|
}
|
|
81
|
-
|
|
82
79
|
function handleBlur(e) {
|
|
83
80
|
const validatedHex = validateHex(color, e.target.value, false);
|
|
84
81
|
onHexBlur(validatedHex);
|
|
85
82
|
setInternalHex(validatedHex);
|
|
86
83
|
}
|
|
87
|
-
|
|
88
|
-
const [internalAlpha, setInternalAlpha] = useState((_color$alpha = color.alpha) !== null && _color$alpha !== void 0 ? _color$alpha : 100);
|
|
84
|
+
const [internalAlpha, setInternalAlpha] = useState(color.alpha ?? 100);
|
|
89
85
|
useEffect(() => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setInternalAlpha((_color$alpha2 = color.alpha) !== null && _color$alpha2 !== void 0 ? _color$alpha2 : 100);
|
|
86
|
+
setInternalAlpha(color.alpha ?? 100);
|
|
93
87
|
}, [color.alpha, isAlphaEnabled]);
|
|
94
|
-
|
|
95
88
|
function handleAlphaBlur(e) {
|
|
96
89
|
const newAlpha = Math.min(Math.max(parseInt(e.target.value, 10) || 0, 0), 100);
|
|
97
90
|
onAlphaBlur(newAlpha);
|
|
98
91
|
setInternalAlpha(newAlpha);
|
|
99
92
|
}
|
|
100
|
-
|
|
101
93
|
function handleInternalAlphaChange(e) {
|
|
102
94
|
const newAlpha = e.target.value || '0';
|
|
103
95
|
setInternalAlpha(parseInt(newAlpha, 10));
|
|
104
96
|
}
|
|
105
|
-
|
|
106
97
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
107
98
|
className: styles.hexInputGroup
|
|
108
99
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -126,13 +117,15 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
126
117
|
className: styles.inputLabel
|
|
127
118
|
}, "Hex")), /*#__PURE__*/React__default.createElement("div", {
|
|
128
119
|
className: styles.rgbContainer
|
|
129
|
-
}, /*#__PURE__*/React__default.createElement(RGBInput
|
|
120
|
+
}, /*#__PURE__*/React__default.createElement(RGBInput
|
|
121
|
+
// if hex is incomplete, fill color channel value with 0
|
|
130
122
|
, {
|
|
131
123
|
value: parseInt(color.hex.substring(1, 3), 16) || 0,
|
|
132
124
|
onBlur: e => {
|
|
133
125
|
const r = Math.max(Math.min(parseInt(e.target.value, 10) || 0, 255), 0).toString(16);
|
|
134
126
|
const rgb = hexToRgb(color.hex);
|
|
135
|
-
onHexBlur(
|
|
127
|
+
onHexBlur(
|
|
128
|
+
// if hex is incomplete, fill missing color channels with 0
|
|
136
129
|
rgbToHex({
|
|
137
130
|
r,
|
|
138
131
|
g: rgb.g ? rgb.g : 0,
|
|
@@ -143,13 +136,15 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
143
136
|
"aria-label": redInputAriaLabel,
|
|
144
137
|
containerId: containerId,
|
|
145
138
|
dataTestId: dataTestId
|
|
146
|
-
}), /*#__PURE__*/React__default.createElement(RGBInput
|
|
139
|
+
}), /*#__PURE__*/React__default.createElement(RGBInput
|
|
140
|
+
// if hex is incomplete, fill color channel value with 0
|
|
147
141
|
, {
|
|
148
142
|
value: parseInt(color.hex.substring(3, 5), 16) || 0,
|
|
149
143
|
onBlur: e => {
|
|
150
144
|
const g = Math.max(Math.min(parseInt(e.target.value, 10) || 0, 255), 0).toString(16);
|
|
151
145
|
const rgb = hexToRgb(color.hex);
|
|
152
|
-
onHexBlur(
|
|
146
|
+
onHexBlur(
|
|
147
|
+
// if hex is incomplete, fill missing color channels with 0
|
|
153
148
|
rgbToHex({
|
|
154
149
|
r: rgb.r ? rgb.r : 0,
|
|
155
150
|
g,
|
|
@@ -160,13 +155,15 @@ const ColorPickerFlyoutInputs = function HexInputGroup(_ref2) {
|
|
|
160
155
|
"aria-label": greenInputAriaLabel,
|
|
161
156
|
containerId: containerId,
|
|
162
157
|
dataTestId: dataTestId
|
|
163
|
-
}), /*#__PURE__*/React__default.createElement(RGBInput
|
|
158
|
+
}), /*#__PURE__*/React__default.createElement(RGBInput
|
|
159
|
+
// if hex is incomplete, fill color channel value with 0
|
|
164
160
|
, {
|
|
165
161
|
value: parseInt(color.hex.substring(5, 7), 16) || 0,
|
|
166
162
|
onBlur: e => {
|
|
167
163
|
const b = Math.max(Math.min(parseInt(e.target.value, 10) || 0, 255), 0).toString(16);
|
|
168
164
|
const rgb = hexToRgb(color.hex);
|
|
169
|
-
onHexBlur(
|
|
165
|
+
onHexBlur(
|
|
166
|
+
// if hex is incomplete, fill missing color channels with 0
|
|
170
167
|
rgbToHex({
|
|
171
168
|
r: rgb.r ? rgb.r : 0,
|
|
172
169
|
g: rgb.g ? rgb.g : 0,
|
|
@@ -14,7 +14,6 @@ import { setIsKeyboardUser } from '../../utils/keyboardUser/keyboardUser.js';
|
|
|
14
14
|
import getSubDataTestId from '../../utils/getSubDataTestId/getSubDataTestId.js';
|
|
15
15
|
|
|
16
16
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
17
|
-
|
|
18
17
|
function Hue(_ref) {
|
|
19
18
|
let {
|
|
20
19
|
hue,
|
|
@@ -41,68 +40,52 @@ function Hue(_ref) {
|
|
|
41
40
|
onHueChange(newHue);
|
|
42
41
|
});
|
|
43
42
|
const handleMouseDown = useMouseDrag(handleChange);
|
|
44
|
-
|
|
45
43
|
function handleKeyDown(e) {
|
|
46
44
|
switch (e.key) {
|
|
47
45
|
case 'ArrowUp':
|
|
48
46
|
case 'ArrowRight':
|
|
49
47
|
e.preventDefault(); // prevent page scroll
|
|
50
|
-
|
|
51
48
|
setIsKeyboardUser(true);
|
|
52
49
|
onHueChange(Math.min(hue + 3, 359));
|
|
53
50
|
break;
|
|
54
|
-
|
|
55
51
|
case 'ArrowDown':
|
|
56
52
|
case 'ArrowLeft':
|
|
57
53
|
e.preventDefault(); // prevent page scroll
|
|
58
|
-
|
|
59
54
|
setIsKeyboardUser(true);
|
|
60
55
|
onHueChange(Math.max(hue - 3, 0));
|
|
61
56
|
break;
|
|
62
|
-
|
|
63
57
|
case 'End':
|
|
64
58
|
e.preventDefault(); // prevent page scroll
|
|
65
|
-
|
|
66
59
|
setIsKeyboardUser(true);
|
|
67
60
|
onHueChange(359);
|
|
68
61
|
break;
|
|
69
|
-
|
|
70
62
|
case 'Home':
|
|
71
63
|
e.preventDefault(); // prevent page scroll
|
|
72
|
-
|
|
73
64
|
setIsKeyboardUser(true);
|
|
74
65
|
onHueChange(0);
|
|
75
66
|
break;
|
|
76
|
-
|
|
77
67
|
case 'PageUp':
|
|
78
68
|
e.preventDefault(); // prevent page scroll
|
|
79
|
-
|
|
80
69
|
setIsKeyboardUser(true);
|
|
81
70
|
onHueChange(Math.min(hue + 30, 359));
|
|
82
71
|
break;
|
|
83
|
-
|
|
84
72
|
case 'PageDown':
|
|
85
73
|
e.preventDefault(); // prevent page scroll
|
|
86
|
-
|
|
87
74
|
setIsKeyboardUser(true);
|
|
88
75
|
onHueChange(Math.max(hue - 30, 0));
|
|
89
76
|
break;
|
|
90
|
-
|
|
91
77
|
default:
|
|
92
78
|
break;
|
|
93
79
|
}
|
|
94
80
|
}
|
|
95
|
-
|
|
96
81
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
97
82
|
className: classNames(styles.hueSliderRail, {
|
|
98
83
|
[styles.alphaEnabled]: isAlphaEnabled
|
|
99
84
|
}),
|
|
100
85
|
onMouseDown: e => {
|
|
101
|
-
var _thumbRef$current;
|
|
102
|
-
|
|
103
86
|
// prevent text highlighting while dragging
|
|
104
87
|
e.preventDefault();
|
|
105
|
-
|
|
88
|
+
thumbRef.current?.focus();
|
|
106
89
|
handleMouseDown(e);
|
|
107
90
|
},
|
|
108
91
|
"data-testid": getSubDataTestId(dataTestId, 'hue-rail'),
|
|
@@ -113,7 +96,7 @@ function Hue(_ref) {
|
|
|
113
96
|
[styles.alphaEnabled]: isAlphaEnabled
|
|
114
97
|
}),
|
|
115
98
|
style: {
|
|
116
|
-
left:
|
|
99
|
+
left: `calc(${hue / 359 * 100}% - 4px)`
|
|
117
100
|
},
|
|
118
101
|
onKeyDown: handleKeyDown,
|
|
119
102
|
"aria-label": hueAriaLabel,
|
|
@@ -9,8 +9,6 @@ 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;
|
|
13
|
-
|
|
14
12
|
let {
|
|
15
13
|
color,
|
|
16
14
|
onColorSwatchClick,
|
|
@@ -20,29 +18,26 @@ const Swatch = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
20
18
|
'aria-describedby': ariaDescribedBy,
|
|
21
19
|
dataTestId
|
|
22
20
|
} = _ref;
|
|
23
|
-
|
|
24
21
|
function handleClick() {
|
|
25
22
|
setFocusedSwatchIndex(cellIndex);
|
|
26
23
|
onColorSwatchClick(color);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
30
26
|
role: "gridcell"
|
|
31
27
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
32
28
|
type: "button",
|
|
33
29
|
className: styles.swatch,
|
|
34
30
|
style: {
|
|
35
|
-
backgroundColor:
|
|
31
|
+
backgroundColor: `${color.hex}`
|
|
36
32
|
},
|
|
37
33
|
onClick: handleClick,
|
|
38
34
|
tabIndex: cellIndex === focusedSwatchIndex ? 0 : -1,
|
|
39
|
-
"aria-label":
|
|
35
|
+
"aria-label": `${color.name ?? ''} ${color.hex}`,
|
|
40
36
|
"aria-describedby": ariaDescribedBy,
|
|
41
37
|
ref: ref,
|
|
42
|
-
"data-testid": getSubDataTestId(dataTestId,
|
|
38
|
+
"data-testid": getSubDataTestId(dataTestId, `${color.hex.substring(1)}-swatch`)
|
|
43
39
|
}));
|
|
44
40
|
});
|
|
45
|
-
|
|
46
41
|
function Palette(_ref2) {
|
|
47
42
|
let {
|
|
48
43
|
onColorSwatchClick,
|
|
@@ -56,64 +51,50 @@ function Palette(_ref2) {
|
|
|
56
51
|
} = useTranslation();
|
|
57
52
|
const paletteAriaLabel = translate('palette');
|
|
58
53
|
const swatchAriaDesc = translate('selectColor');
|
|
59
|
-
const swatchDescriptionId =
|
|
60
|
-
const swatchRefs = useRef({});
|
|
54
|
+
const swatchDescriptionId = `${containerId}-swatch-desc`;
|
|
55
|
+
const swatchRefs = useRef({});
|
|
61
56
|
|
|
57
|
+
// split palette into rows for grid aria role semantics
|
|
62
58
|
const [paletteRows, setPaletteRows] = useState([]);
|
|
63
59
|
const rowLength = 9;
|
|
64
60
|
const maxRows = 4;
|
|
65
61
|
useEffect(() => {
|
|
66
62
|
const paletteRowCount = Math.min(Math.ceil(palette.length / rowLength), maxRows);
|
|
67
63
|
const newPaletteRows = [];
|
|
68
|
-
|
|
69
64
|
for (let i = 0; i < paletteRowCount; i += 1) newPaletteRows.push(palette.slice(i * rowLength, (i + 1) * rowLength));
|
|
70
|
-
|
|
71
65
|
setPaletteRows(newPaletteRows);
|
|
72
66
|
}, [palette]);
|
|
73
|
-
|
|
74
67
|
function updateFocusedSwatchIndex(e, direction) {
|
|
75
68
|
e.preventDefault(); // prevents scroll
|
|
76
|
-
|
|
77
69
|
setIsKeyboardUser(true);
|
|
78
70
|
setFocusedSwatchIndex(prevFocusedSwatchIndex => {
|
|
79
|
-
var _swatchRefs$current, _swatchRefs$current$t;
|
|
80
|
-
|
|
81
71
|
const targetId = calculateTargetId(prevFocusedSwatchIndex, palette.length, direction);
|
|
82
|
-
|
|
72
|
+
swatchRefs.current?.[targetId]?.focus();
|
|
83
73
|
return targetId;
|
|
84
74
|
});
|
|
85
75
|
}
|
|
86
|
-
|
|
87
76
|
function handleKeyDown(e) {
|
|
88
77
|
switch (e.key) {
|
|
89
78
|
case 'ArrowUp':
|
|
90
79
|
updateFocusedSwatchIndex(e, 'up');
|
|
91
80
|
break;
|
|
92
|
-
|
|
93
81
|
case 'ArrowDown':
|
|
94
82
|
updateFocusedSwatchIndex(e, 'down');
|
|
95
83
|
break;
|
|
96
|
-
|
|
97
84
|
case 'ArrowLeft':
|
|
98
85
|
updateFocusedSwatchIndex(e, 'left');
|
|
99
86
|
break;
|
|
100
|
-
|
|
101
87
|
case 'ArrowRight':
|
|
102
88
|
updateFocusedSwatchIndex(e, 'right');
|
|
103
89
|
break;
|
|
104
|
-
|
|
105
90
|
default:
|
|
106
91
|
break;
|
|
107
92
|
}
|
|
108
93
|
}
|
|
109
|
-
|
|
110
94
|
return (
|
|
111
95
|
/*#__PURE__*/
|
|
112
|
-
|
|
113
96
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
114
|
-
|
|
115
97
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
116
|
-
|
|
117
98
|
/* eslint-disable jsx-a11y/interactive-supports-focus */
|
|
118
99
|
React__default.createElement("div", {
|
|
119
100
|
role: "grid",
|
|
@@ -126,7 +107,6 @@ function Palette(_ref2) {
|
|
|
126
107
|
className: styles.hidden
|
|
127
108
|
}, swatchAriaDesc), paletteRows.map((row, rowIndex) =>
|
|
128
109
|
/*#__PURE__*/
|
|
129
|
-
|
|
130
110
|
/* eslint-disable react/no-array-index-key */
|
|
131
111
|
React__default.createElement("div", {
|
|
132
112
|
role: "row",
|