@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
|
@@ -14,7 +14,6 @@ import hsvToHex from './utils/hsvToHex.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 Saturation(_ref) {
|
|
19
18
|
let {
|
|
20
19
|
hsv,
|
|
@@ -24,7 +23,7 @@ function Saturation(_ref) {
|
|
|
24
23
|
} = _ref;
|
|
25
24
|
const gridRef = useRef(null);
|
|
26
25
|
const loopRef = useRef(null);
|
|
27
|
-
const saturationId =
|
|
26
|
+
const saturationId = `${containerId}-saturation`;
|
|
28
27
|
const {
|
|
29
28
|
translate
|
|
30
29
|
} = useTranslation();
|
|
@@ -48,91 +47,71 @@ function Saturation(_ref) {
|
|
|
48
47
|
onSaturationChange(newSaturation, newValue);
|
|
49
48
|
});
|
|
50
49
|
const handleMouseDown = useMouseDrag(handleChange);
|
|
51
|
-
|
|
52
50
|
function handleKeyDown(e) {
|
|
53
51
|
switch (e.key) {
|
|
54
52
|
case 'ArrowUp':
|
|
55
53
|
e.preventDefault(); // prevent page scroll
|
|
56
|
-
|
|
57
54
|
setIsKeyboardUser(true);
|
|
58
55
|
onSaturationChange(hsv.s, Math.min(hsv.v + 0.01, 1));
|
|
59
56
|
break;
|
|
60
|
-
|
|
61
57
|
case 'ArrowDown':
|
|
62
58
|
e.preventDefault(); // prevent page scroll
|
|
63
|
-
|
|
64
59
|
setIsKeyboardUser(true);
|
|
65
60
|
onSaturationChange(hsv.s, Math.max(hsv.v - 0.01, 0));
|
|
66
61
|
break;
|
|
67
|
-
|
|
68
62
|
case 'ArrowLeft':
|
|
69
63
|
e.preventDefault(); // prevent page scroll
|
|
70
|
-
|
|
71
64
|
setIsKeyboardUser(true);
|
|
72
65
|
onSaturationChange(Math.max(hsv.s - 0.01, 0), hsv.v);
|
|
73
66
|
break;
|
|
74
|
-
|
|
75
67
|
case 'ArrowRight':
|
|
76
68
|
e.preventDefault(); // prevent page scroll
|
|
77
|
-
|
|
78
69
|
setIsKeyboardUser(true);
|
|
79
70
|
onSaturationChange(Math.min(hsv.s + 0.01, 1), hsv.v);
|
|
80
71
|
break;
|
|
81
|
-
|
|
82
72
|
case 'Home':
|
|
83
73
|
e.preventDefault(); // prevent page scroll
|
|
84
|
-
|
|
85
74
|
setIsKeyboardUser(true);
|
|
86
75
|
onSaturationChange(0, hsv.v);
|
|
87
76
|
break;
|
|
88
|
-
|
|
89
77
|
case 'End':
|
|
90
78
|
e.preventDefault(); // prevent page scroll
|
|
91
|
-
|
|
92
79
|
setIsKeyboardUser(true);
|
|
93
80
|
onSaturationChange(1, hsv.v);
|
|
94
81
|
break;
|
|
95
|
-
|
|
96
82
|
case 'PageUp':
|
|
97
83
|
e.preventDefault(); // prevent page scroll
|
|
98
|
-
|
|
99
84
|
setIsKeyboardUser(true);
|
|
100
85
|
onSaturationChange(hsv.s, 1);
|
|
101
86
|
break;
|
|
102
|
-
|
|
103
87
|
case 'PageDown':
|
|
104
88
|
e.preventDefault(); // prevent page scroll
|
|
105
|
-
|
|
106
89
|
setIsKeyboardUser(true);
|
|
107
90
|
onSaturationChange(hsv.s, 0);
|
|
108
91
|
break;
|
|
109
|
-
|
|
110
92
|
default:
|
|
111
93
|
break;
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
|
-
|
|
115
96
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
116
97
|
className: styles.saturationGrid,
|
|
117
98
|
style: {
|
|
118
|
-
backgroundColor:
|
|
99
|
+
backgroundColor: `${hsvToHex({
|
|
119
100
|
h: hsv.h,
|
|
120
101
|
s: 1,
|
|
121
102
|
v: 1
|
|
122
|
-
})
|
|
103
|
+
})}`
|
|
123
104
|
},
|
|
124
105
|
onMouseDown: e => {
|
|
125
|
-
var _loopRef$current;
|
|
126
|
-
|
|
127
106
|
// prevent text highlighting while dragging
|
|
128
107
|
e.preventDefault();
|
|
129
|
-
|
|
108
|
+
loopRef.current?.focus();
|
|
130
109
|
handleMouseDown(e);
|
|
131
110
|
},
|
|
132
111
|
"data-testid": getSubDataTestId(dataTestId, 'saturation-grid'),
|
|
133
112
|
ref: gridRef
|
|
134
113
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
135
|
-
id:
|
|
114
|
+
id: `${saturationId}-saturation-desc`,
|
|
136
115
|
className: styles.hidden
|
|
137
116
|
}, saturationAriaDesc), /*#__PURE__*/React__default.createElement("div", {
|
|
138
117
|
"aria-live": loopRef.current === document.activeElement ? 'assertive' : 'off',
|
|
@@ -143,13 +122,13 @@ function Saturation(_ref) {
|
|
|
143
122
|
}, valueAriaLive), /*#__PURE__*/React__default.createElement("div", {
|
|
144
123
|
className: styles.saturationLoop,
|
|
145
124
|
style: {
|
|
146
|
-
left:
|
|
147
|
-
bottom:
|
|
125
|
+
left: `calc(${hsv.s * 100}% - ${hsv.s * 12}px)`,
|
|
126
|
+
bottom: `calc(${hsv.v * 100}% - ${hsv.v * 12}px)`
|
|
148
127
|
},
|
|
149
128
|
onKeyDown: handleKeyDown,
|
|
150
129
|
tabIndex: 0,
|
|
151
130
|
"aria-label": saturationAriaLabel,
|
|
152
|
-
"aria-describedby":
|
|
131
|
+
"aria-describedby": `${saturationId}-saturation-desc`,
|
|
153
132
|
ref: loopRef,
|
|
154
133
|
"data-testid": getSubDataTestId(dataTestId, 'saturation-thumb')
|
|
155
134
|
}));
|
|
@@ -2,49 +2,39 @@
|
|
|
2
2
|
function calculateTargetId(focusedId, paletteLength, direction) {
|
|
3
3
|
const rowLength = 9;
|
|
4
4
|
const rowCount = Math.ceil(paletteLength / rowLength);
|
|
5
|
-
|
|
6
5
|
switch (direction) {
|
|
7
6
|
case 'up':
|
|
8
7
|
// move focus up 1 row
|
|
9
8
|
if (focusedId - rowLength >= 0) {
|
|
10
9
|
return focusedId - rowLength;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
}
|
|
11
|
+
// loop focus to bottom row
|
|
14
12
|
if ((rowCount - 1) * rowLength + focusedId < paletteLength) {
|
|
15
13
|
return (rowCount - 1) * rowLength + focusedId;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
}
|
|
15
|
+
// incomplete row exception: loop focus to second row from bottom
|
|
19
16
|
return (rowCount - 2) * rowLength + focusedId;
|
|
20
|
-
|
|
21
17
|
case 'down':
|
|
22
18
|
// move focus down 1 row
|
|
23
19
|
if (focusedId + rowLength < paletteLength) {
|
|
24
20
|
return focusedId + rowLength;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
}
|
|
22
|
+
// loop focus to top row
|
|
28
23
|
return focusedId % rowLength;
|
|
29
|
-
|
|
30
24
|
case 'left':
|
|
31
25
|
// first item in row is focused: loop focus to end of row, or last item if row is incomplete
|
|
32
26
|
if ((focusedId - 1) % rowLength === rowLength - 1 || focusedId - 1 < 0) {
|
|
33
27
|
return Math.min(focusedId + (rowLength - 1), paletteLength - 1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
}
|
|
29
|
+
// move focus left 1
|
|
37
30
|
return focusedId - 1;
|
|
38
|
-
|
|
39
31
|
case 'right':
|
|
40
32
|
// move focus right 1
|
|
41
33
|
if (focusedId + 1 < paletteLength && (focusedId + 1) % rowLength !== 0) {
|
|
42
34
|
return focusedId + 1;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
}
|
|
36
|
+
// last item in row is focused: loop focus to first item in row
|
|
46
37
|
return (Math.ceil((focusedId + 1) / rowLength) - 1) * rowLength;
|
|
47
|
-
|
|
48
38
|
default:
|
|
49
39
|
return 0;
|
|
50
40
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
function getMousePosition(e, containerRef) {
|
|
2
2
|
const container = containerRef.current.getBoundingClientRect();
|
|
3
3
|
const containerWidth = container.width;
|
|
4
|
-
const containerHeight = container.height;
|
|
5
|
-
|
|
4
|
+
const containerHeight = container.height;
|
|
5
|
+
// mouse positions
|
|
6
6
|
const mouseXPosition = e.clientX;
|
|
7
|
-
const mouseYPosition = e.clientY;
|
|
7
|
+
const mouseYPosition = e.clientY;
|
|
8
8
|
|
|
9
|
+
// distance between mouse position and edge of container
|
|
9
10
|
const left = mouseXPosition - container.left;
|
|
10
11
|
const bottom = container.bottom - mouseYPosition;
|
|
11
12
|
return {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import hexToRgb from './hexToRgb.js';
|
|
2
2
|
|
|
3
3
|
// formula from https://www.rapidtables.com/convert/color/rgb-to-hsv.html
|
|
4
|
-
|
|
5
4
|
function hexToHsv(hex) {
|
|
6
5
|
const {
|
|
7
6
|
r,
|
|
@@ -20,20 +19,16 @@ function hexToHsv(hex) {
|
|
|
20
19
|
case rDecimal:
|
|
21
20
|
h = ((gDecimal - bDecimal) / d + (gDecimal < bDecimal ? 6 : 0)) * 60;
|
|
22
21
|
break;
|
|
23
|
-
|
|
24
22
|
case gDecimal:
|
|
25
23
|
h = ((bDecimal - rDecimal) / d + 2) * 60;
|
|
26
24
|
break;
|
|
27
|
-
|
|
28
25
|
case bDecimal:
|
|
29
26
|
h = ((rDecimal - gDecimal) / d + 4) * 60;
|
|
30
27
|
break;
|
|
31
|
-
|
|
32
28
|
default:
|
|
33
29
|
throw new Error('There was a problem with ColorPicker: broken hexToHsv conversion. Please reach out to the CFE team.');
|
|
34
30
|
break;
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
h = Math.min(Math.round(h), 359);
|
|
38
33
|
}
|
|
39
34
|
let s;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import hexToRgb from './hexToRgb.js';
|
|
2
2
|
|
|
3
3
|
function hexToRgbaString(color) {
|
|
4
|
-
var _color$alpha;
|
|
5
|
-
|
|
6
4
|
const rgb = hexToRgb(color.hex);
|
|
7
|
-
const alpha =
|
|
8
|
-
return
|
|
5
|
+
const alpha = color.alpha ?? 100;
|
|
6
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha / 100})`;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export { hexToRgbaString as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import rgbToHex from './rgbToHex.js';
|
|
2
2
|
|
|
3
3
|
// formula from https://www.rapidtables.com/convert/color/hsv-to-rgb.html
|
|
4
|
-
|
|
5
4
|
function hsvToHex(hsv) {
|
|
6
5
|
const {
|
|
7
6
|
h,
|
|
@@ -16,7 +15,6 @@ function hsvToHex(hsv) {
|
|
|
16
15
|
const secondary = Math.round((x + m) * 255);
|
|
17
16
|
const tertiary = Math.round(m * 255);
|
|
18
17
|
let rgb;
|
|
19
|
-
|
|
20
18
|
if (section === 0) {
|
|
21
19
|
rgb = {
|
|
22
20
|
r: primary,
|
|
@@ -54,7 +52,6 @@ function hsvToHex(hsv) {
|
|
|
54
52
|
b: secondary
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
|
-
|
|
58
55
|
return rgbToHex(rgb);
|
|
59
56
|
}
|
|
60
57
|
|
|
@@ -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 `#${rStr}${gStr}${bStr}`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { rgbToHex as default };
|
|
@@ -1,48 +1,41 @@
|
|
|
1
1
|
function validateHex(currentColor, newHex, isAlphaEnabled) {
|
|
2
|
-
var _currentColor$alpha;
|
|
3
|
-
|
|
4
2
|
// set current alpha to hex format
|
|
5
|
-
const alpha = Math.round((
|
|
3
|
+
const alpha = Math.round((currentColor.alpha ?? 100) / 100 * 255).toString(16).toUpperCase().padStart(2, '0');
|
|
6
4
|
let newAlpha = isAlphaEnabled ? alpha : '';
|
|
7
5
|
let validatedHex;
|
|
8
6
|
const hexLength = isAlphaEnabled ? 8 : 6;
|
|
9
|
-
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
7
|
+
const hexRegex = /^[a-fA-F0-9]+$/;
|
|
10
8
|
|
|
11
|
-
if
|
|
9
|
+
// if newHex contains invalid characters or is empty string, revert to previous color
|
|
10
|
+
if (!hexRegex.test(newHex.slice(0, hexLength))) return `${currentColor.hex.substring(1)}${newAlpha}`;
|
|
12
11
|
|
|
12
|
+
// match validation pattern based on string length
|
|
13
13
|
switch (newHex.length) {
|
|
14
14
|
case 1:
|
|
15
|
-
validatedHex =
|
|
15
|
+
validatedHex = `${newHex.repeat(6)}${newAlpha}`;
|
|
16
16
|
break;
|
|
17
|
-
|
|
18
17
|
case 2:
|
|
19
|
-
validatedHex =
|
|
18
|
+
validatedHex = `${newHex.repeat(3)}${newAlpha}`;
|
|
20
19
|
break;
|
|
21
|
-
|
|
22
20
|
case 3:
|
|
23
|
-
validatedHex =
|
|
21
|
+
validatedHex = `${newHex[0].repeat(2)}${newHex[1].repeat(2)}${newHex[2].repeat(2)}${newAlpha}`;
|
|
24
22
|
break;
|
|
25
|
-
|
|
26
23
|
case 4:
|
|
27
24
|
case 5:
|
|
28
25
|
newAlpha = isAlphaEnabled ? newHex[3].repeat(2) : '';
|
|
29
|
-
validatedHex =
|
|
26
|
+
validatedHex = `${newHex[0].repeat(2)}${newHex[1].repeat(2)}${newHex[2].repeat(2)}${newAlpha}`;
|
|
30
27
|
break;
|
|
31
|
-
|
|
32
28
|
case 6:
|
|
33
|
-
validatedHex =
|
|
29
|
+
validatedHex = `${newHex}${newAlpha}`;
|
|
34
30
|
break;
|
|
35
|
-
|
|
36
31
|
case 7:
|
|
37
|
-
validatedHex =
|
|
32
|
+
validatedHex = `${newHex.substring(0, 6)}${newAlpha}`;
|
|
38
33
|
break;
|
|
39
|
-
|
|
40
34
|
default:
|
|
41
35
|
newAlpha = isAlphaEnabled ? newHex.substring(6, 8) : '';
|
|
42
|
-
validatedHex =
|
|
36
|
+
validatedHex = `${newHex.substring(0, 6)}${newAlpha}`;
|
|
43
37
|
break;
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
return validatedHex.toUpperCase();
|
|
47
40
|
}
|
|
48
41
|
|