@elliemae/ds-controlled-form 2.4.2-rc.9 → 2.4.3-rc.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/cjs/autocomplete/config/useAutocomplete.js +0 -1
- package/cjs/autocomplete/parts/A11yFocusedOption.js +46 -0
- package/cjs/autocomplete/parts/container/Container.js +36 -24
- package/cjs/autocomplete/parts/container/styled.js +2 -2
- package/cjs/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/cjs/autocomplete/parts/menu-list/MenuList.js +6 -6
- package/cjs/autocomplete/parts/menu-list/styled.js +2 -2
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/cjs/autocomplete/parts/styled.js +2 -0
- package/cjs/autocomplete/utils/listHelper.js +1 -1
- package/cjs/checkbox/ControlledCheckbox.js +9 -4
- package/cjs/checkbox/config/useValidateProps.js +6 -3
- package/cjs/checkbox/react-desc-prop-types.js +2 -1
- package/cjs/checkbox/styles.js +93 -32
- package/cjs/checkbox/utils/styleHelpers.js +20 -2
- package/cjs/combobox/ComboBoxCTX.js +6 -3
- package/cjs/combobox/config/useComboBox.js +16 -6
- package/cjs/combobox/config/useCorrectOptions.js +1 -2
- package/cjs/combobox/parts/A11yFocusedOption.js +14 -6
- package/cjs/combobox/parts/A11ySelectedValues.js +2 -4
- package/cjs/combobox/parts/DropdownIndicator.js +15 -7
- package/cjs/combobox/parts/container/Container.js +11 -14
- package/cjs/combobox/parts/container/styled.js +11 -10
- package/cjs/combobox/parts/controls/Controls.js +19 -27
- package/cjs/combobox/parts/controls/styled.js +54 -22
- package/cjs/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/cjs/combobox/parts/controls-input/styled.js +41 -11
- package/cjs/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +19 -28
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/cjs/combobox/parts/header-list/HeaderList.js +1 -1
- package/cjs/combobox/parts/header-list/styled.js +39 -10
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/cjs/combobox/parts/menu-list/MenuList.js +8 -6
- package/cjs/combobox/parts/menu-list/styled.js +38 -20
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +18 -17
- package/cjs/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/cjs/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/cjs/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/cjs/combobox/parts/styled.js +6 -7
- package/cjs/combobox/react-desc-prop-types.js +3 -2
- package/cjs/combobox/sharedTypes.js +2 -2
- package/cjs/combobox/utils/listHelper.js +14 -9
- package/cjs/date-range-picker/config/useRangePickerLogic.js +4 -8
- package/cjs/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/cjs/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/cjs/date-time-picker/config/useChangeHandlers.js +3 -3
- package/cjs/date-time-picker/config/useControlledDateTimePicker.js +1 -1
- package/cjs/date-time-picker/config/useFocusTracker.js +1 -1
- package/cjs/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/cjs/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/cjs/date-time-picker/config/useGetReferences.js +1 -1
- package/cjs/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/cjs/date-time-picker/config/useValidateProps.js +42 -11
- package/cjs/date-time-picker/parts/ClearButton/ClearButton.js +1 -3
- package/cjs/date-time-picker/parts/DateInputs/DDInput.js +3 -7
- package/cjs/date-time-picker/parts/DateInputs/MMInput.js +3 -7
- package/cjs/date-time-picker/parts/DateInputs/YYYYInput.js +3 -7
- package/cjs/date-time-picker/parts/DateInputs/useDateInputs.js +13 -23
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +6 -14
- package/cjs/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/Day.js +8 -10
- package/cjs/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -15
- package/cjs/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +1 -2
- package/cjs/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +0 -1
- package/cjs/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +3 -5
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +3 -5
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +5 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +6 -8
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +5 -7
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -15
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +2 -5
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/cjs/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +2 -5
- package/cjs/date-time-picker/parts/Styleds.js +12 -6
- package/cjs/date-time-picker/parts/TimeInputs/HHInput.js +2 -4
- package/cjs/date-time-picker/parts/TimeInputs/MeridiemInput.js +3 -8
- package/cjs/date-time-picker/parts/TimeInputs/MinutesInput.js +3 -7
- package/cjs/date-time-picker/parts/TimeInputs/useTimeInputs.js +14 -26
- package/cjs/date-time-picker/utils/dateHelpers.js +17 -34
- package/cjs/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/cjs/date-time-picker/utils/stringHelpers.js +5 -11
- package/cjs/input-group/InputGroup.js +8 -7
- package/cjs/input-group/exported-related/data-test-ids.js +12 -0
- package/cjs/input-group/exported-related/index.js +12 -0
- package/cjs/input-group/exported-related/theming.js +13 -0
- package/cjs/input-group/styled.js +90 -23
- package/cjs/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/cjs/large-text-input/styles.js +27 -13
- package/cjs/mask-hook/hooks/useNumberMask.js +1 -5
- package/cjs/mask-hook/hooks/usePhoneMask.js +1 -4
- package/cjs/mask-hook/hooks/useRegExpMask.js +4 -7
- package/cjs/mask-hook/hooks/useSSNMask.js +1 -4
- package/cjs/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/cjs/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/cjs/mask-hook/utils/flatStringArray.js +0 -1
- package/cjs/text-input/config/useInputText.js +0 -1
- package/cjs/text-input/styled/borders.js +18 -11
- package/cjs/text-input/styled/components.js +49 -10
- package/cjs/toggle/ControlledToggle.js +2 -3
- package/cjs/toggle/styles.js +7 -5
- package/esm/autocomplete/config/useAutocomplete.js +0 -1
- package/esm/autocomplete/parts/A11yFocusedOption.js +36 -0
- package/esm/autocomplete/parts/container/Container.js +39 -27
- package/esm/autocomplete/parts/container/styled.js +2 -2
- package/esm/autocomplete/parts/container/useKeyboardNavigation.js +2 -2
- package/esm/autocomplete/parts/menu-list/MenuList.js +7 -7
- package/esm/autocomplete/parts/menu-list/styled.js +2 -2
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +1 -1
- package/esm/autocomplete/parts/styled.js +1 -0
- package/esm/autocomplete/utils/listHelper.js +1 -1
- package/esm/checkbox/ControlledCheckbox.js +10 -5
- package/esm/checkbox/config/useValidateProps.js +6 -3
- package/esm/checkbox/react-desc-prop-types.js +2 -1
- package/esm/checkbox/styles.js +93 -29
- package/esm/checkbox/utils/styleHelpers.js +20 -2
- package/esm/combobox/ComboBoxCTX.js +6 -3
- package/esm/combobox/config/useComboBox.js +16 -6
- package/esm/combobox/config/useCorrectOptions.js +1 -2
- package/esm/combobox/parts/A11yFocusedOption.js +15 -7
- package/esm/combobox/parts/A11ySelectedValues.js +2 -4
- package/esm/combobox/parts/DropdownIndicator.js +15 -6
- package/esm/combobox/parts/container/Container.js +11 -14
- package/esm/combobox/parts/container/styled.js +11 -6
- package/esm/combobox/parts/controls/Controls.js +19 -27
- package/esm/combobox/parts/controls/styled.js +54 -18
- package/esm/combobox/parts/controls/useOnPillsNavigation.js +7 -15
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -2
- package/esm/combobox/parts/controls-input/styled.js +41 -7
- package/esm/combobox/parts/controls-input/useControlsInput.js +4 -7
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +20 -29
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -7
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/HeaderList.js +1 -1
- package/esm/combobox/parts/header-list/styled.js +40 -7
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +7 -14
- package/esm/combobox/parts/menu-list/MenuList.js +8 -6
- package/esm/combobox/parts/menu-list/styled.js +38 -17
- package/esm/combobox/parts/menu-list/useItemRenderer.js +20 -19
- package/esm/combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +1 -1
- package/esm/combobox/parts/multi-selected-values-container/RemovableSelectedValuePill.js +1 -3
- package/esm/combobox/parts/multi-selected-values-container/useGroupPills.js +1 -2
- package/esm/combobox/parts/styled.js +6 -3
- package/esm/combobox/react-desc-prop-types.js +3 -2
- package/esm/combobox/sharedTypes.js +2 -2
- package/esm/combobox/utils/listHelper.js +14 -10
- package/esm/date-range-picker/config/useRangePickerLogic.js +3 -7
- package/esm/date-range-picker/parts/ControlledDateRangeCalendar.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeFromDate.js +0 -2
- package/esm/date-range-picker/parts/ControlledDateRangeToDate.js +0 -2
- package/esm/date-time-picker/config/useChangeHandlers.js +3 -3
- package/esm/date-time-picker/config/useControlledDateTimePicker.js +1 -1
- package/esm/date-time-picker/config/useFocusTracker.js +1 -1
- package/esm/date-time-picker/config/useGetDestructuredValues.js +6 -6
- package/esm/date-time-picker/config/useGetPropsBasedOnType.js +1 -1
- package/esm/date-time-picker/config/useGetReferences.js +1 -1
- package/esm/date-time-picker/config/useRelevantValueFromProps.js +1 -1
- package/esm/date-time-picker/config/useValidateProps.js +42 -11
- package/esm/date-time-picker/parts/ClearButton/ClearButton.js +1 -3
- package/esm/date-time-picker/parts/DateInputs/DDInput.js +3 -7
- package/esm/date-time-picker/parts/DateInputs/MMInput.js +3 -7
- package/esm/date-time-picker/parts/DateInputs/YYYYInput.js +3 -7
- package/esm/date-time-picker/parts/DateInputs/useDateInputs.js +13 -23
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarDaysList.js +4 -4
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarHead.js +6 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/CalendarIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/Day.js +8 -10
- package/esm/date-time-picker/parts/Pickers/Calendar/Styleds.js +44 -14
- package/esm/date-time-picker/parts/Pickers/Calendar/useConfigCalendarCTX.js +0 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.js +2 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/useFocusLogic.js +0 -1
- package/esm/date-time-picker/parts/Pickers/Calendar/usePopperTriggerLogic.js +3 -5
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/CalendarWithTimeWheelIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/CalendarWithTimeWheel/useConfigCalendarWithTimeWheelCTX.js +3 -5
- package/esm/date-time-picker/parts/Pickers/TimeWheel/HoursList.js +5 -7
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MeridiemList.js +6 -8
- package/esm/date-time-picker/parts/Pickers/TimeWheel/MinutesList.js +5 -7
- package/esm/date-time-picker/parts/Pickers/TimeWheel/SecondsList.js +2 -2
- package/esm/date-time-picker/parts/Pickers/TimeWheel/Styleds.js +47 -14
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelContent.js +2 -5
- package/esm/date-time-picker/parts/Pickers/TimeWheel/TimeWheelIconTrigger.js +1 -1
- package/esm/date-time-picker/parts/Pickers/TimeWheel/useCurrentDisplayedWheelsLogic.js +3 -3
- package/esm/date-time-picker/parts/Pickers/TimeWheel/usePopperTriggerLogic.js +2 -5
- package/esm/date-time-picker/parts/Styleds.js +12 -6
- package/esm/date-time-picker/parts/TimeInputs/HHInput.js +2 -4
- package/esm/date-time-picker/parts/TimeInputs/MeridiemInput.js +3 -8
- package/esm/date-time-picker/parts/TimeInputs/MinutesInput.js +3 -7
- package/esm/date-time-picker/parts/TimeInputs/useTimeInputs.js +14 -26
- package/esm/date-time-picker/utils/dateHelpers.js +17 -34
- package/esm/date-time-picker/utils/hooks/useOnClickOutside.js +1 -3
- package/esm/date-time-picker/utils/stringHelpers.js +5 -11
- package/esm/input-group/InputGroup.js +5 -4
- package/esm/input-group/exported-related/data-test-ids.js +8 -0
- package/esm/input-group/exported-related/index.js +2 -0
- package/esm/input-group/exported-related/theming.js +8 -0
- package/esm/input-group/styled.js +89 -18
- package/esm/large-text-input/DSControlledLargeTextInput.js +1 -1
- package/esm/large-text-input/styles.js +27 -9
- package/esm/mask-hook/hooks/useNumberMask.js +1 -5
- package/esm/mask-hook/hooks/usePhoneMask.js +1 -4
- package/esm/mask-hook/hooks/useRegExpMask.js +4 -7
- package/esm/mask-hook/hooks/useSSNMask.js +1 -4
- package/esm/mask-hook/hooks/useZipCodeMask.js +1 -4
- package/esm/mask-hook/utils/addSpecialCharacters.js +0 -1
- package/esm/mask-hook/utils/flatStringArray.js +0 -1
- package/esm/text-input/config/useInputText.js +0 -1
- package/esm/text-input/styled/borders.js +18 -7
- package/esm/text-input/styled/components.js +49 -6
- package/esm/toggle/ControlledToggle.js +0 -1
- package/esm/toggle/styles.js +7 -5
- package/package.json +35 -15
- package/types/autocomplete/parts/A11yFocusedOption.d.ts +5 -0
- package/types/autocomplete/parts/container/styled.d.ts +1 -1
- package/types/autocomplete/parts/styled.d.ts +0 -0
- package/types/autocomplete/utils/listHelper.d.ts +5 -5
- package/types/checkbox/react-desc-prop-types.d.ts +2 -1
- package/types/checkbox/styles.d.ts +1 -0
- package/types/combobox/parts/menu-list/styled.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +8 -6
- package/types/combobox/sharedTypes.d.ts +3 -2
- package/types/combobox/utils/listHelper.d.ts +1 -0
- package/types/input-group/exported-related/data-test-ids.d.ts +6 -0
- package/types/input-group/exported-related/index.d.ts +2 -0
- package/types/input-group/exported-related/theming.d.ts +6 -0
- package/types/input-group/styled.d.ts +4 -7
- package/types/text-input/config/useInputText.d.ts +4 -4
|
@@ -2,19 +2,21 @@ import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
|
2
2
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
4
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
5
|
-
import React, { useContext, useEffect, useCallback } from 'react';
|
|
5
|
+
import React, { useContext, useEffect, useCallback, useMemo } from 'react';
|
|
6
6
|
import { DSPopperJS } from '@elliemae/ds-popperjs';
|
|
7
7
|
import { AutocompleteContext } from '../../AutocompleteCTX.js';
|
|
8
|
-
import {
|
|
8
|
+
import { StyledContainer, StyledPopperWrapper } from './styled.js';
|
|
9
9
|
import { MenuList } from '../menu-list/MenuList.js';
|
|
10
10
|
import { useKeyboardNavigation } from './useKeyboardNavigation.js';
|
|
11
11
|
import { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';
|
|
12
|
-
import {
|
|
12
|
+
import { A11yFocusedOption } from '../A11yFocusedOption.js';
|
|
13
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
14
|
|
|
14
|
-
var _StyledPopperWrapper;
|
|
15
|
+
var _A11yFocusedOption, _StyledPopperWrapper;
|
|
15
16
|
const Container = () => {
|
|
16
17
|
const {
|
|
17
18
|
props: {
|
|
19
|
+
id,
|
|
18
20
|
startPlacementPreference,
|
|
19
21
|
children,
|
|
20
22
|
filter,
|
|
@@ -23,6 +25,7 @@ const Container = () => {
|
|
|
23
25
|
showPopover,
|
|
24
26
|
setReferenceElement,
|
|
25
27
|
setShowPopover,
|
|
28
|
+
focusOptionIdx,
|
|
26
29
|
referenceElement
|
|
27
30
|
} = useContext(AutocompleteContext);
|
|
28
31
|
useEffect(() => {
|
|
@@ -38,32 +41,41 @@ const Container = () => {
|
|
|
38
41
|
const handleCloseMenu = useCallback(() => {
|
|
39
42
|
setShowPopover(false);
|
|
40
43
|
}, [setShowPopover]);
|
|
41
|
-
const input = React.Children.only(children);
|
|
42
44
|
const {
|
|
43
45
|
onInputKeyDown
|
|
44
46
|
} = useKeyboardNavigation();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
const input = React.Children.only(children);
|
|
48
|
+
const childrenWithProps = /*#__PURE__*/React.isValidElement(input) ? /*#__PURE__*/React.cloneElement(input, {
|
|
49
|
+
'aria-activedescendant': focusOptionIdx
|
|
50
|
+
}) : input;
|
|
51
|
+
const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);
|
|
52
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
53
|
+
children: [_A11yFocusedOption || (_A11yFocusedOption = /*#__PURE__*/_jsx(A11yFocusedOption, {})), /*#__PURE__*/jsxs(StyledContainer, {
|
|
54
|
+
id: id,
|
|
55
|
+
ref: setReferenceElement,
|
|
56
|
+
role: "combobox",
|
|
57
|
+
"aria-autocomplete": "list",
|
|
58
|
+
"aria-controls": "autocomplete-listbox",
|
|
59
|
+
"aria-expanded": showPopover,
|
|
60
|
+
"aria-haspopup": "listbox",
|
|
61
|
+
"aria-owns": idList,
|
|
62
|
+
onKeyDown: onInputKeyDown,
|
|
63
|
+
"data-testid": AutocompleteDataTestid.CONTAINER,
|
|
64
|
+
children: [childrenWithProps, filter && /*#__PURE__*/_jsx(DSPopperJS, {
|
|
65
|
+
customOffset: [0, 5],
|
|
66
|
+
closeContextMenu: handleCloseMenu,
|
|
67
|
+
referenceElement: referenceElement,
|
|
68
|
+
showPopover: showPopover,
|
|
69
|
+
startPlacementPreference: startPlacementPreference,
|
|
70
|
+
placementOrderPreference: placementOrderPreference,
|
|
71
|
+
withoutPortal: true,
|
|
72
|
+
withoutArrow: true,
|
|
73
|
+
withoutAnimation: true,
|
|
74
|
+
zIndex: 10
|
|
75
|
+
}, void 0, _StyledPopperWrapper || (_StyledPopperWrapper = /*#__PURE__*/_jsx(StyledPopperWrapper, {
|
|
76
|
+
tabIndex: -1
|
|
77
|
+
}, void 0, /*#__PURE__*/_jsx(MenuList, {}))))]
|
|
78
|
+
})]
|
|
67
79
|
});
|
|
68
80
|
};
|
|
69
81
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const StyledContainer = /*#__PURE__*/styled.div.withConfig({
|
|
4
4
|
componentId: "sc-xupfk9-0"
|
|
5
5
|
})(["width:100%;height:28px;position:relative;"]);
|
|
6
6
|
const StyledPopperWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
7
7
|
componentId: "sc-xupfk9-1"
|
|
8
8
|
})(["background:#fff;overflow:auto;position:relative;"]);
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { StyledContainer, StyledPopperWrapper };
|
|
@@ -31,7 +31,7 @@ const useKeyboardNavigation = () => {
|
|
|
31
31
|
|
|
32
32
|
if (e.key === 'Enter' && showPopover) {
|
|
33
33
|
e.preventDefault();
|
|
34
|
-
onSelect(currentItem
|
|
34
|
+
onSelect(currentItem?.label, e);
|
|
35
35
|
setShowPopover(false);
|
|
36
36
|
} // =============================================================================
|
|
37
37
|
// ARROWS UP AND DOWN
|
|
@@ -64,7 +64,7 @@ const useKeyboardNavigation = () => {
|
|
|
64
64
|
if (e.key === 'Escape') {
|
|
65
65
|
setShowPopover(false);
|
|
66
66
|
}
|
|
67
|
-
}, [currentItem
|
|
67
|
+
}, [currentItem?.label, currentItemIndex, onSelect, options, scrollOptionIntoView, setCurrentOption, setShowPopover, showPopover]);
|
|
68
68
|
return {
|
|
69
69
|
onInputKeyDown
|
|
70
70
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import { useContext, useCallback } from 'react';
|
|
2
|
+
import { useContext, useCallback, useMemo } from 'react';
|
|
3
3
|
import { StyledListWrapper, StyledVirtualListWrapper, StyledList } from './styled.js';
|
|
4
4
|
import { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';
|
|
5
5
|
import { AutocompleteContext } from '../../AutocompleteCTX.js';
|
|
@@ -9,7 +9,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
9
9
|
const MenuList = () => {
|
|
10
10
|
const {
|
|
11
11
|
props: {
|
|
12
|
-
options
|
|
12
|
+
options,
|
|
13
|
+
id
|
|
13
14
|
},
|
|
14
15
|
referenceElement,
|
|
15
16
|
inputRef,
|
|
@@ -21,15 +22,14 @@ const MenuList = () => {
|
|
|
21
22
|
} = useContext(AutocompleteContext);
|
|
22
23
|
const ItemRenderer = useItemRenderer();
|
|
23
24
|
const handleOnFocus = useCallback(() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
25
|
+
inputRef.current?.focus();
|
|
27
26
|
}, [inputRef]);
|
|
27
|
+
const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);
|
|
28
28
|
return /*#__PURE__*/_jsx(StyledListWrapper, {
|
|
29
29
|
tabIndex: -1,
|
|
30
30
|
onMouseDown: e => e.preventDefault(),
|
|
31
|
-
minWidth: referenceElement
|
|
32
|
-
id:
|
|
31
|
+
minWidth: referenceElement?.offsetWidth,
|
|
32
|
+
id: idList,
|
|
33
33
|
role: "listbox"
|
|
34
34
|
}, void 0, options.length > 0 && /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
35
35
|
tabIndex: -1,
|
|
@@ -6,7 +6,7 @@ const StyledListWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
|
6
6
|
let {
|
|
7
7
|
minWidth
|
|
8
8
|
} = _ref;
|
|
9
|
-
return minWidth ?
|
|
9
|
+
return minWidth ? `${minWidth}px` : '100%';
|
|
10
10
|
});
|
|
11
11
|
const StyledList = /*#__PURE__*/styled.ul.withConfig({
|
|
12
12
|
componentId: "sc-qt1kwv-1"
|
|
@@ -17,7 +17,7 @@ const StyledVirtualListWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
|
17
17
|
let {
|
|
18
18
|
maxHeight
|
|
19
19
|
} = _ref2;
|
|
20
|
-
return
|
|
20
|
+
return `${!maxHeight ? '400' : maxHeight}px`;
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
export { StyledList, StyledListWrapper, StyledVirtualListWrapper };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -9,7 +9,7 @@ const isSelectedValueMultiple = value => Array.isArray(value);
|
|
|
9
9
|
const findInCircularList = function (list, from, criteria) {
|
|
10
10
|
let step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
11
11
|
|
|
12
|
-
for (let i = (from + step + list.length) % list.length; i !== from; i = (i + step + list.length) % list.length) {
|
|
12
|
+
for (let i = (from + step + list.length) % list.length; i !== from && from > -1; i = (i + step + list.length) % list.length) {
|
|
13
13
|
if (criteria(list[i])) return i;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
9
9
|
import { useRef, useCallback } from 'react';
|
|
10
10
|
import { describe, useMemoMergePropsWithDefault, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';
|
|
11
11
|
import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
|
|
12
|
-
import { StyledContainer, StyledCheckBox, StyledInputMixed, StyledInput, StyledLabel } from './styles.js';
|
|
12
|
+
import { StyledContainer, StyledCheckBox, StyledInputMixed, StyledInput, StyledLabel, StyledWrapLabel } from './styles.js';
|
|
13
13
|
import { propTypes, defaultProps } from './react-desc-prop-types.js';
|
|
14
14
|
import { setMultipleRefs } from './utils/setMultipleRefs.js';
|
|
15
15
|
import { useValidateProps } from './config/useValidateProps.js';
|
|
@@ -76,7 +76,7 @@ const DSControlledCheckbox = props => {
|
|
|
76
76
|
"aria-controls": ariaControls || legacyAriaControls,
|
|
77
77
|
disabled: disabled,
|
|
78
78
|
readOnly: readOnly,
|
|
79
|
-
onClick: onChange,
|
|
79
|
+
onClick: !disabled && onChange,
|
|
80
80
|
"aria-checked": checked
|
|
81
81
|
}, restGlobals), {}, {
|
|
82
82
|
tabIndex: 0
|
|
@@ -91,15 +91,20 @@ const DSControlledCheckbox = props => {
|
|
|
91
91
|
disabled: disabled,
|
|
92
92
|
readOnly: readOnly,
|
|
93
93
|
onChange: onChange
|
|
94
|
-
}, restGlobals))), label && /*#__PURE__*/
|
|
94
|
+
}, restGlobals))), label && /*#__PURE__*/jsx(StyledLabel, _objectSpread(_objectSpread({
|
|
95
95
|
htmlFor: id,
|
|
96
96
|
disabled: disabled,
|
|
97
97
|
readOnly: readOnly,
|
|
98
98
|
checked: checked,
|
|
99
|
+
disabled: disabled,
|
|
99
100
|
"data-testid": "ds-checkbox-label",
|
|
100
101
|
wrapLabel: wrapLabel
|
|
101
|
-
},
|
|
102
|
-
|
|
102
|
+
}, !disabled && (ariaControls || legacyAriaControls) ? {
|
|
103
|
+
onClick: onChange
|
|
104
|
+
} : {}), {}, {
|
|
105
|
+
children: wrapLabel ? /*#__PURE__*/_jsx(StyledWrapLabel, {}, void 0, label) : /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
|
|
106
|
+
value: label
|
|
107
|
+
})
|
|
103
108
|
}))]
|
|
104
109
|
}));
|
|
105
110
|
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import 'core-js/modules/es.error.cause.js';
|
|
1
2
|
import { useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
2
3
|
|
|
3
4
|
const throwError = message => {
|
|
4
|
-
throw new Error(
|
|
5
|
+
throw new Error(`DSControlledCheckbox:: ${message}
|
|
6
|
+
`);
|
|
5
7
|
};
|
|
6
8
|
|
|
7
9
|
const useValidateProps = (props, propTypes) => {
|
|
8
10
|
useValidateTypescriptPropTypes(props, propTypes);
|
|
9
11
|
|
|
10
12
|
if (typeof props.label === 'undefined' && typeof props['aria-label'] === 'undefined') {
|
|
11
|
-
throwError(
|
|
13
|
+
throwError(`Please provide a label or ariaLabel property to use this component.`);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
if (props.checked === 'mixed' && typeof props['aria-controls'] === 'undefined') {
|
|
15
|
-
throwError(
|
|
17
|
+
throwError(`Please provide an ariaControls property to use a checkbox mixed state.
|
|
18
|
+
This property must be a string containing all the ids that this mixed checkbox is controlling.`);
|
|
16
19
|
}
|
|
17
20
|
};
|
|
18
21
|
|
|
@@ -18,7 +18,8 @@ const defaultProps = {
|
|
|
18
18
|
const propTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
19
19
|
label: PropTypes.string.description('Checkbox Label property. This label is also going to be used as an aria-label for screen readers.'),
|
|
20
20
|
hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),
|
|
21
|
-
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.')
|
|
21
|
+
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.'),
|
|
22
|
+
wrapLabel: PropTypes.bool.description('Whether to wrap or truncate the label')
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
export { defaultProps, propTypes };
|
package/esm/checkbox/styles.js
CHANGED
|
@@ -1,41 +1,51 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
1
|
import { styled, css } from '@elliemae/ds-system';
|
|
3
2
|
import { handleBackgroundColor, handleCheckmark } from './utils/styleHelpers.js';
|
|
4
3
|
import { DSCheckboxName, DSCheckboxSlots } from './exported-related/theming.js';
|
|
5
4
|
|
|
6
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
7
5
|
const StyledContainer = styled('div', {
|
|
8
6
|
name: DSCheckboxName,
|
|
9
7
|
slot: DSCheckboxSlots.CONTAINER
|
|
10
|
-
})
|
|
8
|
+
})`
|
|
9
|
+
display: inline-grid;
|
|
10
|
+
grid-template-rows: min-content;
|
|
11
|
+
grid-template-columns: ${_ref => {
|
|
11
12
|
let {
|
|
12
13
|
theme
|
|
13
14
|
} = _ref;
|
|
14
15
|
return theme.space.xs;
|
|
15
|
-
}
|
|
16
|
-
|
|
16
|
+
}} auto;
|
|
17
|
+
align-items: center;
|
|
18
|
+
`;
|
|
19
|
+
const StyledCheckBox = styled('span')`
|
|
20
|
+
width: ${_ref2 => {
|
|
17
21
|
let {
|
|
18
22
|
theme
|
|
19
23
|
} = _ref2;
|
|
20
24
|
return theme.space.xs;
|
|
21
|
-
}
|
|
25
|
+
}};
|
|
26
|
+
height: ${_ref3 => {
|
|
22
27
|
let {
|
|
23
28
|
theme
|
|
24
29
|
} = _ref3;
|
|
25
30
|
return theme.space.xs;
|
|
26
|
-
}
|
|
31
|
+
}};
|
|
32
|
+
border: 1px solid ${_ref4 => {
|
|
27
33
|
let {
|
|
28
34
|
theme,
|
|
29
35
|
hasError
|
|
30
36
|
} = _ref4;
|
|
31
37
|
return hasError ? theme.colors.danger[900] : theme.colors.neutral[400];
|
|
32
|
-
}
|
|
38
|
+
}};
|
|
39
|
+
border-radius: 2px;
|
|
40
|
+
position: relative;
|
|
41
|
+
background: ${_ref5 => {
|
|
33
42
|
let {
|
|
34
43
|
theme,
|
|
35
44
|
disabled
|
|
36
45
|
} = _ref5;
|
|
37
46
|
return handleBackgroundColor(theme, disabled);
|
|
38
|
-
}
|
|
47
|
+
}};
|
|
48
|
+
${_ref6 => {
|
|
39
49
|
let {
|
|
40
50
|
theme,
|
|
41
51
|
checked,
|
|
@@ -44,14 +54,18 @@ const StyledCheckBox = styled('span')(_templateObject2 || (_templateObject2 = _t
|
|
|
44
54
|
hasError
|
|
45
55
|
} = _ref6;
|
|
46
56
|
return handleCheckmark(theme, checked, disabled, readOnly, hasError);
|
|
47
|
-
}
|
|
57
|
+
}}
|
|
58
|
+
&:focus-within {
|
|
59
|
+
${_ref7 => {
|
|
48
60
|
let {
|
|
49
61
|
theme,
|
|
50
62
|
hasError,
|
|
51
63
|
disabled
|
|
52
64
|
} = _ref7;
|
|
53
|
-
return !disabled && !hasError ?
|
|
54
|
-
}
|
|
65
|
+
return !disabled && !hasError ? `border: 1px solid ${theme.colors.brand[700]}; outline : 1px solid ${theme.colors.brand[700]} ` : undefined;
|
|
66
|
+
}};
|
|
67
|
+
&:hover {
|
|
68
|
+
${_ref8 => {
|
|
55
69
|
let {
|
|
56
70
|
theme,
|
|
57
71
|
checked,
|
|
@@ -60,48 +74,98 @@ const StyledCheckBox = styled('span')(_templateObject2 || (_templateObject2 = _t
|
|
|
60
74
|
hasError
|
|
61
75
|
} = _ref8;
|
|
62
76
|
return handleCheckmark(theme, checked, disabled, readOnly, hasError, true);
|
|
63
|
-
}
|
|
77
|
+
}}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
&:hover {
|
|
81
|
+
background: ${_ref9 => {
|
|
64
82
|
let {
|
|
65
83
|
theme,
|
|
66
84
|
checked,
|
|
67
85
|
disabled
|
|
68
86
|
} = _ref9;
|
|
69
87
|
return !disabled && (checked === 'mixed' || checked) ? theme.colors.brand[200] : undefined;
|
|
70
|
-
}
|
|
88
|
+
}};
|
|
89
|
+
${_ref10 => {
|
|
71
90
|
let {
|
|
72
91
|
theme,
|
|
73
92
|
hasError,
|
|
74
93
|
disabled,
|
|
75
94
|
readOnly
|
|
76
95
|
} = _ref10;
|
|
77
|
-
return !hasError && !disabled && !readOnly ?
|
|
78
|
-
}
|
|
79
|
-
|
|
96
|
+
return !hasError && !disabled && !readOnly ? ` border: 1px solid ${theme.colors.brand[600]}` : undefined;
|
|
97
|
+
}};
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
const checkboxStyles = css`
|
|
101
|
+
&:hover {
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
}
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 100%;
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
opacity: 0;
|
|
110
|
+
`;
|
|
80
111
|
const StyledInput = styled('input', {
|
|
81
112
|
name: DSCheckboxName,
|
|
82
113
|
slot: DSCheckboxSlots.INPUT
|
|
83
|
-
})
|
|
114
|
+
})`
|
|
115
|
+
${checkboxStyles}
|
|
116
|
+
&:disabled {
|
|
117
|
+
cursor: not-allowed;
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
84
120
|
const StyledInputMixed = styled('div', {
|
|
85
121
|
name: DSCheckboxName,
|
|
86
122
|
slot: DSCheckboxSlots.INPUT
|
|
87
|
-
})
|
|
123
|
+
})`
|
|
124
|
+
${checkboxStyles}
|
|
125
|
+
${_ref11 => {
|
|
126
|
+
let {
|
|
127
|
+
disabled
|
|
128
|
+
} = _ref11;
|
|
129
|
+
return disabled ? `&:hover {
|
|
130
|
+
cursor: not-allowed;
|
|
131
|
+
}` : '';
|
|
132
|
+
}}
|
|
133
|
+
`;
|
|
88
134
|
const StyledLabel = styled('label', {
|
|
89
135
|
name: DSCheckboxName,
|
|
90
136
|
slot: DSCheckboxSlots.LABEL
|
|
91
|
-
})
|
|
137
|
+
})`
|
|
138
|
+
${_ref12 => {
|
|
92
139
|
let {
|
|
93
140
|
wrapLabel,
|
|
94
141
|
theme
|
|
95
|
-
} =
|
|
96
|
-
return wrapLabel ? 'padding: 8px' :
|
|
97
|
-
}
|
|
142
|
+
} = _ref12;
|
|
143
|
+
return wrapLabel ? 'padding: 8px 0px 8px 8px;' : `padding-left: ${theme.space.xxs}`;
|
|
144
|
+
}};
|
|
145
|
+
|
|
146
|
+
color: ${_ref13 => {
|
|
98
147
|
let {
|
|
99
148
|
theme,
|
|
100
149
|
disabled,
|
|
101
|
-
readOnly
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
150
|
+
readOnly
|
|
151
|
+
} = _ref13;
|
|
152
|
+
return disabled || readOnly ? theme.colors.neutral[500] : theme.colors.neutral[800];
|
|
153
|
+
}};
|
|
154
|
+
font-size: 13px;
|
|
155
|
+
line-height: 13px;
|
|
156
|
+
display: inherit;
|
|
157
|
+
|
|
158
|
+
${_ref14 => {
|
|
159
|
+
let {
|
|
160
|
+
disabled
|
|
161
|
+
} = _ref14;
|
|
162
|
+
return disabled ? `&:hover {
|
|
163
|
+
cursor: not-allowed;
|
|
164
|
+
}` : `&:hover {
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
}`;
|
|
167
|
+
}}
|
|
168
|
+
`;
|
|
169
|
+
const StyledWrapLabel = styled('span')``;
|
|
106
170
|
|
|
107
|
-
export { StyledCheckBox, StyledContainer, StyledInput, StyledInputMixed, StyledLabel };
|
|
171
|
+
export { StyledCheckBox, StyledContainer, StyledInput, StyledInputMixed, StyledLabel, StyledWrapLabel };
|
|
@@ -22,11 +22,29 @@ const handleCheckmark = function (theme, checked, disabled, readOnly, hasError)
|
|
|
22
22
|
let isHovering = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
23
23
|
|
|
24
24
|
if (checked === 'mixed') {
|
|
25
|
-
return
|
|
25
|
+
return `&:before {
|
|
26
|
+
position: absolute;
|
|
27
|
+
content: '';
|
|
28
|
+
top: 6px;
|
|
29
|
+
left: 3px;
|
|
30
|
+
background: ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};
|
|
31
|
+
width: ${theme.space.xxs};
|
|
32
|
+
height: 2px;
|
|
33
|
+
}`;
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
if (checked) {
|
|
29
|
-
return
|
|
37
|
+
return `&:before {
|
|
38
|
+
position: absolute;
|
|
39
|
+
content: '';
|
|
40
|
+
top: 3px;
|
|
41
|
+
left: 2px;
|
|
42
|
+
border-left: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};
|
|
43
|
+
border-bottom: 2px solid ${handleCheckMarkColor(theme, checked, isHovering, disabled, readOnly, hasError)};
|
|
44
|
+
height: 5px;
|
|
45
|
+
width: 10px;
|
|
46
|
+
transform: rotate(-45deg);
|
|
47
|
+
}`;
|
|
30
48
|
}
|
|
31
49
|
|
|
32
50
|
return '';
|
|
@@ -12,12 +12,14 @@ const defaultProps = {
|
|
|
12
12
|
useMask: noop,
|
|
13
13
|
innerRef: /*#__PURE__*/createRef(),
|
|
14
14
|
startPlacementPreference: 'bottom-start',
|
|
15
|
-
placementOrderPreference: ['bottom-start', 'bottom-end']
|
|
15
|
+
placementOrderPreference: ['bottom-start', 'bottom-end'],
|
|
16
|
+
noOptionsMessage: 'No Matches Found',
|
|
17
|
+
filteredOptions: [] // override in useCombobox to avoid ref duplications when more than one cb is used
|
|
16
18
|
|
|
17
19
|
};
|
|
18
20
|
const defaultContext = {
|
|
19
21
|
props: defaultProps,
|
|
20
|
-
|
|
22
|
+
menuState: false,
|
|
21
23
|
hasFocus: false,
|
|
22
24
|
referenceElement: null,
|
|
23
25
|
inputValue: '',
|
|
@@ -36,7 +38,8 @@ const defaultContext = {
|
|
|
36
38
|
setInputValue: noop,
|
|
37
39
|
setReferenceElement: noop,
|
|
38
40
|
setFocusOptionIdx: noop,
|
|
39
|
-
setShowSelectedOptions: noop
|
|
41
|
+
setShowSelectedOptions: noop,
|
|
42
|
+
setMenuState: noop
|
|
40
43
|
};
|
|
41
44
|
/** Context for cross component communication */
|
|
42
45
|
|
|
@@ -4,8 +4,7 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import '
|
|
8
|
-
import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
|
|
7
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
9
8
|
import { useVirtual } from 'react-virtual';
|
|
10
9
|
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
11
10
|
import { defaultProps } from '../ComboBoxCTX.js';
|
|
@@ -36,8 +35,18 @@ const useComboBox = props => {
|
|
|
36
35
|
const toggleSelectionButtonRef = useRef(null);
|
|
37
36
|
const pillGroupRef = useRef(null);
|
|
38
37
|
const {
|
|
39
|
-
selectedValues
|
|
40
|
-
|
|
38
|
+
selectedValues,
|
|
39
|
+
isMenuOpen,
|
|
40
|
+
onMenuChange
|
|
41
|
+
} = propsWithDefaults;
|
|
42
|
+
const menuState = useMemo(() => {
|
|
43
|
+
if (isMenuOpen !== undefined) return isMenuOpen;
|
|
44
|
+
return showPopover;
|
|
45
|
+
}, [showPopover, isMenuOpen]);
|
|
46
|
+
const setMenuState = useCallback((newState, reason, e) => {
|
|
47
|
+
if (onMenuChange !== undefined) onMenuChange(newState, reason, e);
|
|
48
|
+
setShowPopover(newState);
|
|
49
|
+
}, [onMenuChange]); // ---------------------------------------------------------------------------
|
|
41
50
|
// Options with creatable option + filtered by selected
|
|
42
51
|
// ---------------------------------------------------------------------------
|
|
43
52
|
|
|
@@ -91,7 +100,7 @@ const useComboBox = props => {
|
|
|
91
100
|
filteredOptions: correctOptions
|
|
92
101
|
}),
|
|
93
102
|
virtualListHelpers,
|
|
94
|
-
|
|
103
|
+
menuState,
|
|
95
104
|
referenceElement,
|
|
96
105
|
listRef,
|
|
97
106
|
focusOptionIdx,
|
|
@@ -100,6 +109,7 @@ const useComboBox = props => {
|
|
|
100
109
|
selectAllCheckboxRef,
|
|
101
110
|
inputValue,
|
|
102
111
|
setInputValue,
|
|
112
|
+
setMenuState,
|
|
103
113
|
hasFocus,
|
|
104
114
|
toggleSelectionButtonRef,
|
|
105
115
|
pillGroupRef,
|
|
@@ -111,7 +121,7 @@ const useComboBox = props => {
|
|
|
111
121
|
scrollOptionIntoView,
|
|
112
122
|
setReferenceElement,
|
|
113
123
|
setShowPopover
|
|
114
|
-
}), [scrollOptionIntoView, correctOptions, hasFocus, propsWithDefaults, virtualListHelpers, inputValue, focusOptionIdx, wrapperListRef, showSelectedOptions,
|
|
124
|
+
}), [scrollOptionIntoView, setMenuState, correctOptions, hasFocus, propsWithDefaults, virtualListHelpers, inputValue, focusOptionIdx, wrapperListRef, showSelectedOptions, menuState, pillGroupRef, referenceElement, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, listRef]);
|
|
115
125
|
return ctx;
|
|
116
126
|
};
|
|
117
127
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
import { uid } from 'uid';
|
|
4
3
|
import { MENU_OPTION_TYPES } from '../constants.js';
|
|
@@ -24,7 +23,7 @@ const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) =
|
|
|
24
23
|
if (onCreate && inputValue && filteredOptions.findIndex(option => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) === -1) {
|
|
25
24
|
const creatableUuid = uid();
|
|
26
25
|
const creatableItem = {
|
|
27
|
-
dsId:
|
|
26
|
+
dsId: `creatable-${creatableUuid}`,
|
|
28
27
|
label: inputValue,
|
|
29
28
|
type: 'creatable'
|
|
30
29
|
};
|