@qualtrics/ui-react 2.19.0 → 2.19.1
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 +16 -0
- package/dist/__shared/cjs/{index-4e4cc354.js → index-384184bd.js} +994 -1872
- package/dist/__shared/cjs/{index-bf07471d.js → index-4a5425cc.js} +10 -7
- package/dist/components/Accordion/Accordion.js +1 -5
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Accordion/AccordionHeader.js +4 -8
- 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 +12 -41
- 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 +1 -0
- 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/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.js +376 -748
- 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
|
@@ -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 = {"tablist":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._Z6iSC{display:flex;justify-content:left;border-bottom:1px solid #e5e5e5;height:52px}._Z6iSC._aS-FP ._yqmRl{flex:1 1 0px;max-width:none}._yqmRl{background:inherit;font-family:inherit;font-size:100%;line-height:1.15;margin:0;-webkit-appearance:button;-moz-appearance:button;appearance:button;text-transform:none;text-align:center;color:#6a6d70;height:52px;padding:16px 12px;max-width:200px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border:none;border-bottom:2px solid transparent;border-radius:1px;display:block;outline:none;cursor:pointer}._yqmRl:hover{color:#32363a}._yqmRl._VbFbX{border-bottom-color:#0b6ed0;color:#32363a;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif;font-weight:500}._qF8YD{padding-top:32px}._qF8YD._hnt-l{display:none}body.keyboard-user ._yqmRl:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
|
|
4
|
+
var styles = {"tablist":"_Z6iSC","grow":"_aS-FP","tab":"_yqmRl","selected":"_VbFbX","tabpanel":"_qF8YD","inactive":"_hnt-l"};
|
|
5
|
+
var stylesheet="._Z6iSC{display:flex;justify-content:left;border-bottom:1px solid #e5e5e5;height:52px}._Z6iSC._aS-FP ._yqmRl{flex:1 1 0px;max-width:none}._yqmRl{background:inherit;font-family:inherit;font-size:100%;line-height:1.15;margin:0;-webkit-appearance:button;-moz-appearance:button;appearance:button;text-transform:none;text-align:center;color:#6a6d70;height:52px;padding:16px 12px;max-width:200px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border:none;border-bottom:2px solid transparent;border-radius:1px;display:block;outline:none;cursor:pointer}._yqmRl:hover{color:#32363a}._yqmRl._VbFbX{border-bottom-color:#0b6ed0;color:#32363a;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif;font-weight:500}._qF8YD{padding-top:32px}._qF8YD._hnt-l{display:none}body.keyboard-user ._yqmRl: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 };
|
|
@@ -15,8 +15,6 @@ import Popper from '../../utils/Popper/Popper.js';
|
|
|
15
15
|
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
16
16
|
|
|
17
17
|
const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
18
|
-
var _children$ref;
|
|
19
|
-
|
|
20
18
|
let {
|
|
21
19
|
content,
|
|
22
20
|
unstable_contentKey: contentKey,
|
|
@@ -48,31 +46,19 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
48
46
|
const flyoutOffsetBackplateRef = useRef(null);
|
|
49
47
|
const timer = useRef();
|
|
50
48
|
const flyoutContainerId = useId(id);
|
|
51
|
-
|
|
52
|
-
const getIsAnchorKeyboardFocused = () => {
|
|
53
|
-
var _anchorRef$current;
|
|
54
|
-
|
|
55
|
-
return (showOnDescendantFocus ? (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.contains(document.activeElement) : document.activeElement === anchorRef.current) && getIsKeyboardUser();
|
|
56
|
-
};
|
|
57
|
-
|
|
49
|
+
const getIsAnchorKeyboardFocused = () => (showOnDescendantFocus ? anchorRef.current?.contains(document.activeElement) : document.activeElement === anchorRef.current) && getIsKeyboardUser();
|
|
58
50
|
const addAriaDescribedByToTrigger = triggeringTarget => {
|
|
59
51
|
if (!ariaHidden && triggeringTarget instanceof HTMLElement) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const describedBy = new Set((_triggeringTarget$get = triggeringTarget.getAttribute('aria-describedby')) === null || _triggeringTarget$get === void 0 ? void 0 : _triggeringTarget$get.split(' '));
|
|
52
|
+
const describedBy = new Set(triggeringTarget.getAttribute('aria-describedby')?.split(' '));
|
|
63
53
|
describedBy.add(flyoutContainerId);
|
|
64
54
|
triggeringTarget.setAttribute('aria-describedby', Array.from(describedBy).join(' '));
|
|
65
55
|
setTriggerElements(prev => new Set(prev).add(triggeringTarget));
|
|
66
56
|
}
|
|
67
57
|
};
|
|
68
|
-
|
|
69
58
|
const removeAriaDescribedByFromAllTriggers = () => {
|
|
70
59
|
triggerElements.forEach(triggeringTarget => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const describedBy = new Set((_triggeringTarget$get2 = triggeringTarget.getAttribute('aria-describedby')) === null || _triggeringTarget$get2 === void 0 ? void 0 : _triggeringTarget$get2.split(' '));
|
|
60
|
+
const describedBy = new Set(triggeringTarget.getAttribute('aria-describedby')?.split(' '));
|
|
74
61
|
describedBy.delete(flyoutContainerId);
|
|
75
|
-
|
|
76
62
|
if (describedBy.size > 0) {
|
|
77
63
|
triggeringTarget.setAttribute('aria-describedby', Array.from(describedBy).join(' '));
|
|
78
64
|
} else {
|
|
@@ -81,32 +67,25 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
81
67
|
});
|
|
82
68
|
setTriggerElements(new Set());
|
|
83
69
|
};
|
|
84
|
-
|
|
85
70
|
const triggerShowTooltip = triggeringTarget => {
|
|
86
71
|
const showTooltip = () => {
|
|
87
72
|
setIsInDOM(true); // Renders the flyout before the delay so that screen readers can read out the tooltip content
|
|
88
|
-
|
|
89
73
|
if (triggeringTarget) {
|
|
90
74
|
addAriaDescribedByToTrigger(triggeringTarget);
|
|
91
75
|
}
|
|
92
|
-
|
|
93
76
|
clearTimeout(timer.current);
|
|
94
77
|
timer.current = window.setTimeout(() => setIsVisible(true), delayMs);
|
|
95
78
|
};
|
|
96
|
-
|
|
97
79
|
if (!disabled) {
|
|
98
80
|
if (!show) {
|
|
99
81
|
setShow(true);
|
|
100
|
-
|
|
101
82
|
if (componentIsControlled) {
|
|
102
83
|
return;
|
|
103
84
|
}
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
showTooltip();
|
|
107
87
|
}
|
|
108
88
|
};
|
|
109
|
-
|
|
110
89
|
const triggerHideTooltip = () => {
|
|
111
90
|
const hideTooltip = () => {
|
|
112
91
|
clearTimeout(timer.current);
|
|
@@ -114,18 +93,14 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
114
93
|
removeAriaDescribedByFromAllTriggers();
|
|
115
94
|
setIsInDOM(false);
|
|
116
95
|
};
|
|
117
|
-
|
|
118
96
|
if (show) {
|
|
119
97
|
setShow(false);
|
|
120
|
-
|
|
121
98
|
if (componentIsControlled) {
|
|
122
99
|
return;
|
|
123
100
|
}
|
|
124
101
|
}
|
|
125
|
-
|
|
126
102
|
hideTooltip();
|
|
127
103
|
};
|
|
128
|
-
|
|
129
104
|
useEffect(() => {
|
|
130
105
|
if (externalShow) {
|
|
131
106
|
triggerShowTooltip();
|
|
@@ -133,36 +108,31 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
133
108
|
triggerHideTooltip();
|
|
134
109
|
}
|
|
135
110
|
}, [externalShow]);
|
|
136
|
-
|
|
137
111
|
const handleMouseEnter = event => {
|
|
138
112
|
triggerShowTooltip(event.currentTarget);
|
|
139
113
|
setIsMouseHoveringComponent(true);
|
|
140
114
|
};
|
|
141
|
-
|
|
142
115
|
const handleMouseLeave = event => {
|
|
143
116
|
const isMouseEnteringAnchorOrTooltip = event.relatedTarget === anchorRef.current || event.relatedTarget === flyoutRef.current || event.relatedTarget === flyoutOffsetBackplateRef.current;
|
|
117
|
+
|
|
144
118
|
/*
|
|
145
119
|
* Prevents the tooltip from hiding when at least one of the following conditions are met:
|
|
146
120
|
* A keyboard user exists and the anchor element is focused, but that same user is using a mouse to enter and leave the flyout or anchor, or
|
|
147
121
|
* A user is moving the mouse between the anchor and the flyout
|
|
148
122
|
*/
|
|
149
|
-
|
|
150
123
|
if (!isMouseEnteringAnchorOrTooltip) {
|
|
151
124
|
setIsMouseHoveringComponent(false);
|
|
152
|
-
|
|
153
125
|
if (!getIsAnchorKeyboardFocused()) {
|
|
154
126
|
triggerHideTooltip();
|
|
155
127
|
}
|
|
156
128
|
}
|
|
157
129
|
};
|
|
158
|
-
|
|
159
130
|
const handleFocus = e => {
|
|
160
131
|
// Prevents the tooltip from showing for mouse users when the tooltip's anchor element is programmatically focused
|
|
161
132
|
if (getIsKeyboardUser() && (showOnDescendantFocus || e.target === e.currentTarget)) {
|
|
162
133
|
triggerShowTooltip(e.target);
|
|
163
134
|
}
|
|
164
135
|
};
|
|
165
|
-
|
|
166
136
|
const handleBlur = () => {
|
|
167
137
|
/*
|
|
168
138
|
* Prevents the tooltip from hiding when the cursor is hovering over the anchor or flyout.
|
|
@@ -172,7 +142,6 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
172
142
|
triggerHideTooltip();
|
|
173
143
|
}
|
|
174
144
|
};
|
|
175
|
-
|
|
176
145
|
const handleKeyDown = event => {
|
|
177
146
|
if (event.key === 'Escape') {
|
|
178
147
|
if (isVisible) {
|
|
@@ -182,30 +151,32 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
182
151
|
triggerHideTooltip();
|
|
183
152
|
}
|
|
184
153
|
};
|
|
185
|
-
|
|
186
154
|
useEffect(() => {
|
|
187
155
|
if (disabled) {
|
|
188
156
|
triggerHideTooltip();
|
|
189
157
|
} else if (isMouseHoveringComponent || getIsAnchorKeyboardFocused()) {
|
|
190
158
|
triggerShowTooltip();
|
|
191
159
|
}
|
|
192
|
-
},
|
|
160
|
+
},
|
|
161
|
+
// the hide/show functionality of the tooltip based on hover and focus
|
|
193
162
|
// are handled else where and thus don't need to be included here
|
|
194
163
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
195
164
|
[disabled]);
|
|
196
165
|
useEffect(() => () => {
|
|
197
166
|
clearTimeout(timer.current);
|
|
198
|
-
}, []);
|
|
199
|
-
// handle in capture so that it runs before modal or popover event handlers
|
|
167
|
+
}, []);
|
|
200
168
|
|
|
169
|
+
// Allows the user to press the `Escape` key to close the flyout even if the anchor element is not focused
|
|
170
|
+
// handle in capture so that it runs before modal or popover event handlers
|
|
201
171
|
useEventListener(document, 'keydown', handleKeyDown, {
|
|
202
172
|
isCaptureEvent: true
|
|
203
173
|
});
|
|
204
174
|
useEventListener(anchorRef, 'mouseenter', handleMouseEnter);
|
|
205
175
|
useEventListener(anchorRef, 'mouseleave', handleMouseLeave);
|
|
206
176
|
useEventListener(anchorRef, 'focusin', handleFocus);
|
|
207
|
-
useEventListener(anchorRef, 'focusout', handleBlur);
|
|
177
|
+
useEventListener(anchorRef, 'focusout', handleBlur);
|
|
208
178
|
|
|
179
|
+
// `isInDOM` is added as a dependency because the `flyoutRef` won't be in the DOM until `isInDOM` is `true`
|
|
209
180
|
const commonFlyoutListenerOptions = {
|
|
210
181
|
additionalDependencies: [isInDOM, contentKey]
|
|
211
182
|
};
|
|
@@ -215,7 +186,7 @@ const Tooltip = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
215
186
|
open: isInDOM,
|
|
216
187
|
placement: placement,
|
|
217
188
|
anchor: /*#__PURE__*/React__default.cloneElement(children, {
|
|
218
|
-
ref: mergeRefs(anchorRef,
|
|
189
|
+
ref: mergeRefs(anchorRef, children.ref ?? null)
|
|
219
190
|
}),
|
|
220
191
|
popper: /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
221
192
|
id: flyoutContainerId,
|
|
@@ -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 = {"tooltip":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._l18Tp{position:absolute;z-index:2000;max-width:240px;padding:8px 16px;color:#fff;text-align:center;text-decoration:none;background-color:#222;border-radius:4px;box-shadow:0 3px 4px 0 rgba(0,0,0,.05),0 6px 10px 0 rgba(0,0,0,.05);font-size:14px;opacity:0;pointer-events:none;overflow-wrap:break-word;border:1px solid #898989}._l18Tp._9Gfkz{color:#32363a;background-color:#fff}._52ldN{opacity:1;pointer-events:all}._PTsfg,._PTsfg>div{position:absolute;width:8px;height:8px;background:inherit}._PTsfg{visibility:hidden;z-index:2000}._PTsfg>div{visibility:visible;border:1px solid #898989;transform:rotate(45deg)}[data-popper-placement^=top]>._PTsfg{bottom:-4px}[data-popper-placement^=top]>._PTsfg>div{border-top-color:transparent;border-left-color:transparent}[data-popper-placement^=right]>._PTsfg{left:-5px}[data-popper-placement^=right]>._PTsfg>div{border-top-color:transparent;border-right-color:transparent}[data-popper-placement^=bottom]>._PTsfg{top:-5px}[data-popper-placement^=bottom]>._PTsfg>div{border-bottom-color:transparent;border-right-color:transparent}[data-popper-placement^=left]>._PTsfg{right:-4px}[data-popper-placement^=left]>._PTsfg>div{border-bottom-color:transparent;border-left-color:transparent}._rr6NU{position:absolute}[data-popper-placement^=top]>._rr6NU{bottom:-13px;left:0;width:100%;height:17px}[data-popper-placement^=right]>._rr6NU{top:0;left:-13px;width:17px;height:100%}[data-popper-placement^=bottom]>._rr6NU{top:-13px;left:0;width:100%;height:17px}[data-popper-placement^=left]>._rr6NU{top:0;right:-13px;width:17px;height:100%}";
|
|
4
|
+
var styles = {"tooltip":"_l18Tp","lightTheme":"_9Gfkz","visible":"_52ldN","arrow":"_PTsfg","offsetBackplate":"_rr6NU"};
|
|
5
|
+
var stylesheet="._l18Tp{position:absolute;z-index:2000;max-width:240px;padding:8px 16px;color:#fff;text-align:center;text-decoration:none;background-color:#222;border-radius:4px;box-shadow:0 3px 4px 0 rgba(0,0,0,.05),0 6px 10px 0 rgba(0,0,0,.05);font-size:14px;opacity:0;pointer-events:none;overflow-wrap:break-word;border:1px solid #898989}._l18Tp._9Gfkz{color:#32363a;background-color:#fff}._52ldN{opacity:1;pointer-events:all}._PTsfg,._PTsfg>div{position:absolute;width:8px;height:8px;background:inherit}._PTsfg{visibility:hidden;z-index:2000}._PTsfg>div{visibility:visible;border:1px solid #898989;transform:rotate(45deg)}[data-popper-placement^=top]>._PTsfg{bottom:-4px}[data-popper-placement^=top]>._PTsfg>div{border-top-color:transparent;border-left-color:transparent}[data-popper-placement^=right]>._PTsfg{left:-5px}[data-popper-placement^=right]>._PTsfg>div{border-top-color:transparent;border-right-color:transparent}[data-popper-placement^=bottom]>._PTsfg{top:-5px}[data-popper-placement^=bottom]>._PTsfg>div{border-bottom-color:transparent;border-right-color:transparent}[data-popper-placement^=left]>._PTsfg{right:-4px}[data-popper-placement^=left]>._PTsfg>div{border-bottom-color:transparent;border-left-color:transparent}._rr6NU{position:absolute}[data-popper-placement^=top]>._rr6NU{bottom:-13px;left:0;width:100%;height:17px}[data-popper-placement^=right]>._rr6NU{top:0;left:-13px;width:17px;height:100%}[data-popper-placement^=bottom]>._rr6NU{top:-13px;left:0;width:100%;height:17px}[data-popper-placement^=left]>._rr6NU{top:0;right:-13px;width:17px;height:100%}";
|
|
6
6
|
styleInject(css_248z);
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -10,9 +10,9 @@ const UIProvider = _ref => {
|
|
|
10
10
|
config = {}
|
|
11
11
|
} = _ref;
|
|
12
12
|
return /*#__PURE__*/React__default.createElement(TranslationProvider, {
|
|
13
|
-
localizedText: config
|
|
13
|
+
localizedText: config?.localizedText
|
|
14
14
|
}, /*#__PURE__*/React__default.createElement(PortalTargetProvider, {
|
|
15
|
-
target: portalTarget
|
|
15
|
+
target: portalTarget ?? null
|
|
16
16
|
}, children));
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -12,7 +12,6 @@ const getMouseChange = (e, hsl, initialA, container) => {
|
|
|
12
12
|
const y = isMouseEvent(e) ? e.pageY : e.touches[0].pageY;
|
|
13
13
|
const bottom = container.getBoundingClientRect().bottom + window.pageYOffset - y;
|
|
14
14
|
let a;
|
|
15
|
-
|
|
16
15
|
if (bottom < 0) {
|
|
17
16
|
a = 0;
|
|
18
17
|
} else if (bottom > containerHeight) {
|
|
@@ -20,7 +19,6 @@ const getMouseChange = (e, hsl, initialA, container) => {
|
|
|
20
19
|
} else {
|
|
21
20
|
a = bottom / containerHeight;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
return {
|
|
25
23
|
h: hsl.h,
|
|
26
24
|
s: hsl.s,
|
|
@@ -28,12 +26,10 @@ const getMouseChange = (e, hsl, initialA, container) => {
|
|
|
28
26
|
a
|
|
29
27
|
};
|
|
30
28
|
};
|
|
31
|
-
|
|
32
29
|
const KEY_CHANGES = {
|
|
33
30
|
ArrowUp: 0.02,
|
|
34
31
|
ArrowDown: -0.02
|
|
35
32
|
};
|
|
36
|
-
|
|
37
33
|
const getKeyChange = (e, hsl) => {
|
|
38
34
|
const alphaChange = KEY_CHANGES[e.key];
|
|
39
35
|
const a = Math.max(0, Math.min(1, hsl.a + alphaChange));
|
|
@@ -44,7 +40,6 @@ const getKeyChange = (e, hsl) => {
|
|
|
44
40
|
a
|
|
45
41
|
};
|
|
46
42
|
};
|
|
47
|
-
|
|
48
43
|
const Alpha = function Alpha(_ref) {
|
|
49
44
|
let {
|
|
50
45
|
alpha,
|
|
@@ -56,17 +51,15 @@ const Alpha = function Alpha(_ref) {
|
|
|
56
51
|
const containerRef = React__default.useRef(null);
|
|
57
52
|
const handleChange = useEventCallback(e => {
|
|
58
53
|
const change = getMouseChange(e, hsl, alpha, containerRef.current);
|
|
59
|
-
onChange
|
|
54
|
+
onChange?.(change, e);
|
|
60
55
|
});
|
|
61
56
|
const handleMouseDown = useMouseDrag(handleChange);
|
|
62
|
-
|
|
63
57
|
function handleKeyDown(e) {
|
|
64
58
|
if (Object.keys(KEY_CHANGES).indexOf(e.key) > -1) {
|
|
65
59
|
const change = getKeyChange(e, hsl);
|
|
66
|
-
onChange
|
|
60
|
+
onChange?.(change, e);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
71
64
|
className: classNames(styles.alpha, className)
|
|
72
65
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -79,7 +72,7 @@ const Alpha = function Alpha(_ref) {
|
|
|
79
72
|
onTouchMove: handleChange,
|
|
80
73
|
onTouchStart: handleChange,
|
|
81
74
|
style: {
|
|
82
|
-
background:
|
|
75
|
+
background: `linear-gradient(to top, hsla(${hsl.h}, ${hsl.s * 100}%, ${hsl.l * 100}%, 0) 0%, hsla(${hsl.h}, ${hsl.s * 100}%, ${hsl.l * 100}%, 1) 100%)`
|
|
83
76
|
},
|
|
84
77
|
role: "slider",
|
|
85
78
|
"aria-valuemin": 0,
|
|
@@ -89,7 +82,7 @@ const Alpha = function Alpha(_ref) {
|
|
|
89
82
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
90
83
|
className: styles.alphaSlider,
|
|
91
84
|
style: {
|
|
92
|
-
bottom:
|
|
85
|
+
bottom: `${alpha * 100}%`
|
|
93
86
|
}
|
|
94
87
|
})));
|
|
95
88
|
};
|
|
@@ -1,72 +1,55 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
|
|
3
2
|
/* eslint-disable no-param-reassign,no-nested-ternary,no-bitwise,no-multi-assign,prefer-destructuring */
|
|
3
|
+
|
|
4
4
|
const STRING_PARSERS = [{
|
|
5
5
|
re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
|
|
6
6
|
format: 'hex',
|
|
7
|
-
|
|
8
7
|
parse(execResult) {
|
|
9
8
|
return [parseInt(execResult[1], 16), parseInt(execResult[2], 16), parseInt(execResult[3], 16), 1];
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
}, {
|
|
13
11
|
re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
|
|
14
12
|
format: 'hex',
|
|
15
|
-
|
|
16
13
|
parse(execResult) {
|
|
17
14
|
return [parseInt(execResult[1] + execResult[1], 16), parseInt(execResult[2] + execResult[2], 16), parseInt(execResult[3] + execResult[3], 16), 1];
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
}, {
|
|
21
17
|
re: /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,
|
|
22
18
|
format: 'rgb',
|
|
23
|
-
|
|
24
19
|
parse(execResult) {
|
|
25
20
|
return [execResult[1], execResult[2], execResult[3], 1];
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
}, {
|
|
29
23
|
re: /rgb\(\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*?\)/,
|
|
30
24
|
format: 'rgb',
|
|
31
|
-
|
|
32
25
|
parse(execResult) {
|
|
33
26
|
return [Math.round(2.55 * execResult[1]), Math.round(2.55 * execResult[2]), Math.round(2.55 * execResult[3]), 1];
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
}, {
|
|
37
29
|
re: /rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
|
38
30
|
format: 'rgba',
|
|
39
|
-
|
|
40
31
|
parse(execResult) {
|
|
41
32
|
return [execResult[1], execResult[2], execResult[3], execResult[4]];
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
}, {
|
|
45
35
|
re: /rgba\(\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
|
46
36
|
format: 'rgba',
|
|
47
|
-
|
|
48
37
|
parse(execResult) {
|
|
49
38
|
return [Math.round(2.55 * execResult[1]), Math.round(2.55 * execResult[2]), Math.round(2.55 * execResult[3]), execResult[4]];
|
|
50
39
|
}
|
|
51
|
-
|
|
52
40
|
}, {
|
|
53
41
|
re: /hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*?\)/,
|
|
54
42
|
format: 'hsl',
|
|
55
|
-
|
|
56
43
|
parse(execResult) {
|
|
57
44
|
return [parseInt(execResult[1], 10), execResult[2] / 100, execResult[3] / 100, 1];
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
}, {
|
|
61
47
|
re: /hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
|
62
48
|
format: 'hsla',
|
|
63
|
-
|
|
64
49
|
parse(execResult) {
|
|
65
50
|
return [parseInt(execResult[1], 10), execResult[2] / 100, execResult[3] / 100, parseInt(execResult[4], 10)];
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
}];
|
|
69
|
-
|
|
70
53
|
class Color {
|
|
71
54
|
constructor(val) {
|
|
72
55
|
this.value = {
|
|
@@ -75,7 +58,6 @@ class Color {
|
|
|
75
58
|
b: 0,
|
|
76
59
|
a: 1
|
|
77
60
|
};
|
|
78
|
-
|
|
79
61
|
if (typeof val === 'string') {
|
|
80
62
|
this.setColor(val);
|
|
81
63
|
} else if (typeof val.r === 'number') {
|
|
@@ -87,36 +69,30 @@ class Color {
|
|
|
87
69
|
this.value.h = val.h;
|
|
88
70
|
this.originalFormat = 'hsla';
|
|
89
71
|
} else {
|
|
90
|
-
this.value = {
|
|
72
|
+
this.value = {
|
|
73
|
+
...val
|
|
91
74
|
};
|
|
92
75
|
this.originalFormat = 'hsba';
|
|
93
76
|
}
|
|
94
77
|
}
|
|
95
78
|
}
|
|
96
|
-
|
|
97
79
|
$sanitizeNumber(val) {
|
|
98
80
|
if (typeof val === 'number') {
|
|
99
81
|
return val;
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
if (Number.isNaN(val) || val === null || val === '' || val === undefined) {
|
|
103
84
|
return 1;
|
|
104
85
|
}
|
|
105
|
-
|
|
106
86
|
if (val.toLowerCase !== undefined) {
|
|
107
87
|
return parseFloat(val);
|
|
108
88
|
}
|
|
109
|
-
|
|
110
89
|
return 1;
|
|
111
90
|
}
|
|
112
|
-
|
|
113
91
|
setColor(strVal) {
|
|
114
92
|
strVal = strVal.toLowerCase();
|
|
115
|
-
|
|
116
93
|
if (strVal.charAt(0) !== '#') {
|
|
117
|
-
strVal =
|
|
94
|
+
strVal = `#${strVal}`;
|
|
118
95
|
}
|
|
119
|
-
|
|
120
96
|
this.value = this.stringToHSB(strVal) || {
|
|
121
97
|
h: 0,
|
|
122
98
|
s: 0,
|
|
@@ -124,7 +100,6 @@ class Color {
|
|
|
124
100
|
a: 1
|
|
125
101
|
};
|
|
126
102
|
}
|
|
127
|
-
|
|
128
103
|
stringToHSB(strVal) {
|
|
129
104
|
strVal = strVal.toLowerCase();
|
|
130
105
|
let result;
|
|
@@ -132,7 +107,6 @@ class Color {
|
|
|
132
107
|
const match = parser.re.exec(strVal);
|
|
133
108
|
const values = match && parser.parse(match);
|
|
134
109
|
const format = parser.format || 'rgba';
|
|
135
|
-
|
|
136
110
|
if (values) {
|
|
137
111
|
if (format.match(/hsla?/)) {
|
|
138
112
|
const oldHue = values[0];
|
|
@@ -141,23 +115,19 @@ class Color {
|
|
|
141
115
|
} else {
|
|
142
116
|
result = this.RGBtoHSB(...values);
|
|
143
117
|
}
|
|
144
|
-
|
|
145
118
|
this.originalFormat = format;
|
|
146
119
|
return true;
|
|
147
120
|
}
|
|
148
|
-
|
|
149
121
|
return false;
|
|
150
122
|
});
|
|
151
123
|
return result;
|
|
152
124
|
}
|
|
153
|
-
|
|
154
125
|
toRGB(h, s, b, a) {
|
|
155
126
|
if (!h) {
|
|
156
127
|
h = this.value.h;
|
|
157
128
|
s = this.value.s;
|
|
158
129
|
b = this.value.b;
|
|
159
130
|
}
|
|
160
|
-
|
|
161
131
|
let R;
|
|
162
132
|
let G;
|
|
163
133
|
let B;
|
|
@@ -176,12 +146,10 @@ class Color {
|
|
|
176
146
|
a: a || this.value.a
|
|
177
147
|
};
|
|
178
148
|
}
|
|
179
|
-
|
|
180
149
|
toHex(h, s, b, a) {
|
|
181
150
|
const rgb = this.toRGB(Number(h), Number(s), Number(b), Number(a));
|
|
182
|
-
return
|
|
151
|
+
return `#${(1 << 24 | parseInt(String(rgb.r), 10) << 16 | parseInt(String(rgb.g), 10) << 8 | parseInt(String(rgb.b), 10)).toString(16).substr(1)}`;
|
|
183
152
|
}
|
|
184
|
-
|
|
185
153
|
toHSL(h, s, b, a) {
|
|
186
154
|
h = h || this.value.h;
|
|
187
155
|
s = s || this.value.s;
|
|
@@ -190,19 +158,15 @@ class Color {
|
|
|
190
158
|
const H = h;
|
|
191
159
|
let L = (2 - s) * b;
|
|
192
160
|
let S = s * b;
|
|
193
|
-
|
|
194
161
|
if (L > 0 && L <= 1) {
|
|
195
162
|
S /= L;
|
|
196
163
|
} else {
|
|
197
164
|
S /= 2 - L;
|
|
198
165
|
}
|
|
199
|
-
|
|
200
166
|
L /= 2;
|
|
201
|
-
|
|
202
167
|
if (S > 1) {
|
|
203
168
|
S = 1;
|
|
204
169
|
}
|
|
205
|
-
|
|
206
170
|
return {
|
|
207
171
|
h: Number.isNaN(H) ? 0 : H,
|
|
208
172
|
s: Number.isNaN(S) ? 0 : S,
|
|
@@ -210,7 +174,6 @@ class Color {
|
|
|
210
174
|
a: Number.isNaN(a) ? 0 : a
|
|
211
175
|
};
|
|
212
176
|
}
|
|
213
|
-
|
|
214
177
|
toHSB() {
|
|
215
178
|
return {
|
|
216
179
|
h: this.value.h,
|
|
@@ -219,7 +182,6 @@ class Color {
|
|
|
219
182
|
a: this.value.a
|
|
220
183
|
};
|
|
221
184
|
}
|
|
222
|
-
|
|
223
185
|
RGBtoHSB(r, g, b, a) {
|
|
224
186
|
r /= 255;
|
|
225
187
|
g /= 255;
|
|
@@ -236,44 +198,34 @@ class Color {
|
|
|
236
198
|
a: this.$sanitizeNumber(a)
|
|
237
199
|
};
|
|
238
200
|
}
|
|
239
|
-
|
|
240
201
|
HueToRGB(p, q, h) {
|
|
241
202
|
if (h < 0) {
|
|
242
203
|
h += 1;
|
|
243
204
|
} else if (h > 1) {
|
|
244
205
|
h -= 1;
|
|
245
206
|
}
|
|
246
|
-
|
|
247
207
|
if (h * 6 < 1) {
|
|
248
208
|
return p + (q - p) * h * 6;
|
|
249
209
|
}
|
|
250
|
-
|
|
251
210
|
if (h * 2 < 1) {
|
|
252
211
|
return q;
|
|
253
212
|
}
|
|
254
|
-
|
|
255
213
|
if (h * 3 < 2) {
|
|
256
214
|
return p + (q - p) * (2 / 3 - h) * 6;
|
|
257
215
|
}
|
|
258
|
-
|
|
259
216
|
return p;
|
|
260
217
|
}
|
|
261
|
-
|
|
262
218
|
HSLtoRGB(h, s, l, a) {
|
|
263
219
|
h /= 360;
|
|
264
|
-
|
|
265
220
|
if (s < 0) {
|
|
266
221
|
s = 0;
|
|
267
222
|
}
|
|
268
|
-
|
|
269
223
|
let q;
|
|
270
|
-
|
|
271
224
|
if (l <= 0.5) {
|
|
272
225
|
q = l * (1 + s);
|
|
273
226
|
} else {
|
|
274
227
|
q = l + s - l * s;
|
|
275
228
|
}
|
|
276
|
-
|
|
277
229
|
const p = 2 * l - q;
|
|
278
230
|
const tr = h + 1 / 3;
|
|
279
231
|
const tg = h;
|
|
@@ -283,7 +235,6 @@ class Color {
|
|
|
283
235
|
const b = Math.round(this.HueToRGB(p, q, tb) * 255);
|
|
284
236
|
return [r, g, b, this.$sanitizeNumber(a)];
|
|
285
237
|
}
|
|
286
|
-
|
|
287
238
|
getValue() {
|
|
288
239
|
return {
|
|
289
240
|
hex: this.toHex(),
|
|
@@ -296,37 +247,29 @@ class Color {
|
|
|
296
247
|
rgbaString: this.toString('rgba')
|
|
297
248
|
};
|
|
298
249
|
}
|
|
299
|
-
|
|
300
250
|
toString(format) {
|
|
301
251
|
format = format || this.originalFormat || 'rgba';
|
|
302
252
|
let rgb;
|
|
303
253
|
let hsl;
|
|
304
|
-
|
|
305
254
|
switch (format) {
|
|
306
255
|
case 'rgb':
|
|
307
256
|
rgb = this.toRGB();
|
|
308
|
-
return
|
|
309
|
-
|
|
257
|
+
return `rgb(${rgb.r},${rgb.g},${rgb.b})`;
|
|
310
258
|
case 'rgba':
|
|
311
259
|
rgb = this.toRGB();
|
|
312
|
-
return
|
|
313
|
-
|
|
260
|
+
return `rgba(${rgb.r},${rgb.g},${rgb.b},${rgb.a})`;
|
|
314
261
|
case 'hsl':
|
|
315
262
|
hsl = this.toHSL();
|
|
316
|
-
return
|
|
317
|
-
|
|
263
|
+
return `hsl(${Math.round(hsl.h)},${Math.round(hsl.s * 100)}%,${Math.round(hsl.l * 100)}%)`;
|
|
318
264
|
case 'hsla':
|
|
319
265
|
hsl = this.toHSL();
|
|
320
|
-
return
|
|
321
|
-
|
|
266
|
+
return `hsla(${Math.round(hsl.h)},${Math.round(hsl.s * 100)}%,${Math.round(hsl.l * 100)}%,${hsl.a})`;
|
|
322
267
|
case 'hex':
|
|
323
268
|
return this.toHex();
|
|
324
|
-
|
|
325
269
|
default:
|
|
326
270
|
return '';
|
|
327
271
|
}
|
|
328
272
|
}
|
|
329
|
-
|
|
330
273
|
}
|
|
331
274
|
|
|
332
275
|
export { Color as default };
|
|
@@ -39,20 +39,17 @@ const ColorPicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
39
39
|
...rest
|
|
40
40
|
} = _ref;
|
|
41
41
|
const [show, setShow] = React__default.useState(false);
|
|
42
|
-
const [color, setColor] = React__default.useState(new Color(externalColor
|
|
42
|
+
const [color, setColor] = React__default.useState(new Color(externalColor ?? defaultColor));
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
if (externalColor) setColor(new Color(externalColor));
|
|
45
45
|
}, [externalColor]);
|
|
46
|
-
|
|
47
46
|
function handleChange(rawColor, e) {
|
|
48
47
|
const nextColor = new Color(rawColor);
|
|
49
48
|
setColor(nextColor);
|
|
50
|
-
onChange
|
|
49
|
+
onChange?.(nextColor.getValue(), e);
|
|
51
50
|
}
|
|
52
|
-
|
|
53
51
|
let alpha;
|
|
54
52
|
let width = 136;
|
|
55
|
-
|
|
56
53
|
if (enableAlpha) {
|
|
57
54
|
alpha = /*#__PURE__*/React__default.createElement(Alpha, {
|
|
58
55
|
className: styles.colorPickerAlpha,
|
|
@@ -62,9 +59,7 @@ const ColorPicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
62
59
|
});
|
|
63
60
|
width += 20;
|
|
64
61
|
}
|
|
65
|
-
|
|
66
62
|
let swatchComponent;
|
|
67
|
-
|
|
68
63
|
if (swatches && swatches.length > 0) {
|
|
69
64
|
swatchComponent = /*#__PURE__*/React__default.createElement("div", {
|
|
70
65
|
className: styles.colorPickerSwatches
|
|
@@ -75,7 +70,6 @@ const ColorPicker = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
75
70
|
onClick: handleChange
|
|
76
71
|
})));
|
|
77
72
|
}
|
|
78
|
-
|
|
79
73
|
const anchorRef = useRef(null);
|
|
80
74
|
const popperRef = useRef(null);
|
|
81
75
|
const refs = useMemo(() => [anchorRef, popperRef], []);
|