@elliemae/ds-controlled-form 2.4.1-rc.3 → 2.4.1-rc.7
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/Autocomplete.js +4 -5
- package/cjs/autocomplete/AutocompleteCTX.js +3 -14
- package/cjs/autocomplete/AutocompleteDataTestids.js +1 -7
- package/cjs/autocomplete/config/useAutocomplete.js +23 -10
- package/cjs/autocomplete/parts/container/Container.js +36 -20
- package/cjs/autocomplete/parts/container/styled.js +1 -5
- package/cjs/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/cjs/autocomplete/parts/menu-list/MenuList.js +17 -50
- package/cjs/autocomplete/parts/menu-list/styled.js +9 -10
- package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +38 -44
- package/cjs/autocomplete/react-desc-prop-types.js +4 -8
- package/cjs/autocomplete/utils/listHelper.js +8 -16
- package/cjs/checkbox/react-desc-prop-types.js +1 -0
- package/cjs/combobox/ComboBox.js +1 -0
- package/cjs/combobox/config/useComboBox.js +8 -2
- package/cjs/combobox/config/useCorrectOptions.js +14 -42
- package/cjs/combobox/index.js +1 -0
- package/cjs/combobox/parts/A11yFocusedOption.js +3 -3
- package/cjs/combobox/parts/controls/Controls.js +4 -2
- package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/cjs/combobox/parts/controls-input/styled.js +1 -1
- package/cjs/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -4
- package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/cjs/combobox/parts/menu-list/MenuList.js +13 -7
- package/cjs/combobox/parts/menu-list/styled.js +16 -5
- package/cjs/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/cjs/combobox/react-desc-prop-types.js +2 -1
- package/cjs/combobox/utils/listHelper.js +40 -11
- package/cjs/index.js +20 -3
- package/cjs/large-text-input/DSControlledLargeTextInput.js +83 -0
- package/cjs/large-text-input/exported-related/data-test-ids.js +11 -0
- package/cjs/large-text-input/exported-related/index.js +12 -0
- package/cjs/large-text-input/exported-related/theming.js +13 -0
- package/cjs/large-text-input/index.js +15 -0
- package/cjs/large-text-input/react-desc-prop-types.js +45 -0
- package/cjs/large-text-input/styles.js +40 -0
- package/cjs/mask-hook/hooks/index.js +11 -3
- package/cjs/mask-hook/hooks/useNumberMask.js +7 -0
- package/cjs/mask-hook/hooks/usePhoneMask.js +7 -0
- package/cjs/mask-hook/hooks/useRegExpMask.js +122 -0
- package/cjs/mask-hook/hooks/useSSNMask.js +7 -0
- package/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +12 -5
- package/cjs/mask-hook/index.js +11 -3
- package/cjs/mask-hook/react-desc-prop-types.js +9 -0
- package/cjs/mask-hook/utils/addSpecialCharacters.js +3 -4
- package/cjs/mask-hook/utils/flatStringArray.js +18 -0
- package/cjs/mask-hook/utils/index.js +2 -0
- package/esm/autocomplete/Autocomplete.js +2 -3
- package/esm/autocomplete/AutocompleteCTX.js +3 -14
- package/esm/autocomplete/AutocompleteDataTestids.js +1 -7
- package/esm/autocomplete/config/useAutocomplete.js +27 -14
- package/esm/autocomplete/parts/container/Container.js +38 -23
- package/esm/autocomplete/parts/container/styled.js +2 -5
- package/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
- package/esm/autocomplete/parts/menu-list/MenuList.js +19 -52
- package/esm/autocomplete/parts/menu-list/styled.js +9 -10
- package/esm/autocomplete/parts/menu-list/useItemRenderer.js +39 -45
- package/esm/autocomplete/react-desc-prop-types.js +5 -8
- package/esm/autocomplete/utils/listHelper.js +8 -16
- package/esm/checkbox/react-desc-prop-types.js +1 -0
- package/esm/combobox/ComboBox.js +1 -1
- package/esm/combobox/config/useComboBox.js +8 -2
- package/esm/combobox/config/useCorrectOptions.js +15 -43
- package/esm/combobox/index.js +1 -1
- package/esm/combobox/parts/A11yFocusedOption.js +3 -3
- package/esm/combobox/parts/controls/Controls.js +4 -2
- package/esm/combobox/parts/controls-input/ControlsInput.js +2 -0
- package/esm/combobox/parts/controls-input/styled.js +1 -1
- package/esm/combobox/parts/controls-input/useControlsInput.js +6 -6
- package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
- package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
- package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
- package/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/esm/combobox/parts/menu-list/MenuList.js +13 -7
- package/esm/combobox/parts/menu-list/styled.js +16 -5
- package/esm/combobox/parts/menu-list/useItemRenderer.js +8 -8
- package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
- package/esm/combobox/react-desc-prop-types.js +2 -1
- package/esm/combobox/utils/listHelper.js +38 -12
- package/esm/index.js +9 -5
- package/esm/large-text-input/DSControlledLargeTextInput.js +72 -0
- package/esm/large-text-input/exported-related/data-test-ids.js +7 -0
- package/esm/large-text-input/exported-related/index.js +2 -0
- package/esm/large-text-input/exported-related/theming.js +8 -0
- package/esm/large-text-input/index.js +3 -0
- package/esm/large-text-input/react-desc-prop-types.js +36 -0
- package/esm/large-text-input/styles.js +30 -0
- package/esm/mask-hook/hooks/index.js +5 -4
- package/esm/mask-hook/hooks/useNumberMask.js +7 -1
- package/esm/mask-hook/hooks/usePhoneMask.js +7 -1
- package/esm/mask-hook/hooks/useRegExpMask.js +116 -0
- package/esm/mask-hook/hooks/useSSNMask.js +7 -1
- package/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +11 -5
- package/esm/mask-hook/index.js +5 -4
- package/esm/mask-hook/react-desc-prop-types.js +8 -1
- package/esm/mask-hook/utils/addSpecialCharacters.js +3 -4
- package/esm/mask-hook/utils/flatStringArray.js +14 -0
- package/esm/mask-hook/utils/index.js +1 -0
- package/package.json +60 -88
- package/types/autocomplete/Autocomplete.d.ts +4 -61
- package/types/autocomplete/AutocompleteCTX.d.ts +4 -3
- package/types/autocomplete/AutocompleteDataTestids.d.ts +1 -7
- package/types/autocomplete/config/useAutocomplete.d.ts +3 -2
- package/types/autocomplete/parts/container/Container.d.ts +1 -2
- package/types/autocomplete/parts/container/styled.d.ts +0 -1
- package/types/autocomplete/parts/{controls → container}/useKeyboardNavigation.d.ts +0 -0
- package/types/autocomplete/parts/menu-list/MenuList.d.ts +1 -2
- package/types/autocomplete/parts/menu-list/styled.d.ts +1 -4
- package/types/autocomplete/parts/menu-list/useItemRenderer.d.ts +2 -3
- package/types/autocomplete/react-desc-prop-types.d.ts +8 -18
- package/types/autocomplete/sharedTypes.d.ts +1 -3
- package/types/autocomplete/tests/general.test.d.ts +1 -0
- package/types/autocomplete/tests/utils.d.ts +5 -0
- package/types/autocomplete/utils/listHelper.d.ts +2 -2
- package/types/checkbox/ControlledCheckbox.d.ts +1 -1
- package/types/checkbox/react-desc-prop-types.d.ts +366 -1
- package/types/combobox/ComboBox.d.ts +2 -2
- package/types/combobox/parts/dropdown-indicator/DropdownIndicator.d.ts +1 -0
- package/types/combobox/react-desc-prop-types.d.ts +381 -3
- package/types/combobox/utils/listHelper.d.ts +4 -1
- package/types/index.d.ts +1 -0
- package/types/large-text-input/DSControlledLargeTextInput.d.ts +5 -0
- package/types/large-text-input/exported-related/data-test-ids.d.ts +5 -0
- package/types/large-text-input/exported-related/index.d.ts +2 -0
- package/types/large-text-input/exported-related/theming.d.ts +6 -0
- package/types/large-text-input/index.d.ts +2 -0
- package/types/large-text-input/react-desc-prop-types.d.ts +447 -0
- package/types/large-text-input/styles.d.ts +3 -0
- package/types/large-text-input/tests/DSControlledLargeTextInput.test.d.ts +1 -0
- package/types/mask-hook/hooks/index.d.ts +2 -1
- package/types/mask-hook/hooks/useNumberMask.d.ts +2 -1
- package/types/mask-hook/hooks/usePhoneMask.d.ts +2 -1
- package/types/mask-hook/hooks/useRegExpMask.d.ts +4 -0
- package/types/mask-hook/hooks/useSSNMask.d.ts +2 -1
- package/types/mask-hook/hooks/useZipCodeMask.d.ts +4 -0
- package/types/mask-hook/react-desc-prop-types.d.ts +6 -1
- package/types/mask-hook/tests/useRegExpMask.test.d.ts +1 -0
- package/types/mask-hook/utils/flatStringArray.d.ts +1 -0
- package/types/mask-hook/utils/index.d.ts +1 -0
- package/types/text-input/DSInputText.d.ts +1 -1
- package/types/text-input/config/useInputText.d.ts +110 -110
- package/cjs/autocomplete/config/constants.js +0 -14
- package/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -11
- package/cjs/autocomplete/index.d.js +0 -2
- package/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -33
- package/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -28
- package/cjs/autocomplete/parts/a11y-messages/index.js +0 -11
- package/cjs/autocomplete/parts/a11y-messages/styled.js +0 -15
- package/cjs/autocomplete/parts/controls/Controls.js +0 -63
- package/cjs/autocomplete/parts/controls/index.js +0 -9
- package/cjs/autocomplete/parts/controls/styled.js +0 -44
- package/cjs/autocomplete/parts/controls/useControlsInput.js +0 -44
- package/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -28
- package/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -69
- package/cjs/autocomplete/propTypes.js +0 -25
- package/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -97
- package/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -37
- package/cjs/text-input/exported-related/name.js +0 -7
- package/cjs/text-input/exported-related/slots.js +0 -11
- package/esm/autocomplete/config/constants.js +0 -10
- package/esm/autocomplete/config/useGetPropsWithDefault.js +0 -7
- package/esm/autocomplete/index.d.js +0 -1
- package/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -25
- package/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -20
- package/esm/autocomplete/parts/a11y-messages/index.js +0 -2
- package/esm/autocomplete/parts/a11y-messages/styled.js +0 -7
- package/esm/autocomplete/parts/controls/Controls.js +0 -55
- package/esm/autocomplete/parts/controls/index.js +0 -1
- package/esm/autocomplete/parts/controls/styled.js +0 -32
- package/esm/autocomplete/parts/controls/useControlsInput.js +0 -40
- package/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -24
- package/esm/autocomplete/parts/menu-list/useMenuList.js +0 -65
- package/esm/autocomplete/propTypes.js +0 -21
- package/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -93
- package/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -33
- package/esm/text-input/exported-related/name.js +0 -3
- package/esm/text-input/exported-related/slots.js +0 -7
- package/types/autocomplete/config/constants.d.ts +0 -8
- package/types/autocomplete/config/useGetPropsWithDefault.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
- package/types/autocomplete/parts/a11y-messages/index.d.ts +0 -2
- package/types/autocomplete/parts/a11y-messages/styled.d.ts +0 -1
- package/types/autocomplete/parts/controls/Controls.d.ts +0 -3
- package/types/autocomplete/parts/controls/index.d.ts +0 -1
- package/types/autocomplete/parts/controls/styled.d.ts +0 -8
- package/types/autocomplete/parts/controls/useControlsInput.d.ts +0 -9
- package/types/autocomplete/parts/controls/useMaskedOnChange.d.ts +0 -2
- package/types/autocomplete/parts/menu-list/useMenuList.d.ts +0 -2
- package/types/autocomplete/propTypes.d.ts +0 -51
- package/types/autocomplete/utils/hooks/useKeyboardNavigation.d.ts +0 -4
- package/types/autocomplete/utils/hooks/useOnElementResize.d.ts +0 -3
- package/types/mask-hook/hooks/useZipCode.d.ts +0 -3
- package/types/text-input/exported-related/name.d.ts +0 -1
- package/types/text-input/exported-related/slots.d.ts +0 -5
|
@@ -13,6 +13,7 @@ const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type) &
|
|
|
13
13
|
const useKeyboardNavigation = () => {
|
|
14
14
|
const {
|
|
15
15
|
props: {
|
|
16
|
+
allOptions,
|
|
16
17
|
onCancel,
|
|
17
18
|
onKeyDown,
|
|
18
19
|
onChange,
|
|
@@ -20,7 +21,7 @@ const useKeyboardNavigation = () => {
|
|
|
20
21
|
onFilter,
|
|
21
22
|
onSelectAll,
|
|
22
23
|
inline,
|
|
23
|
-
|
|
24
|
+
filteredOptions,
|
|
24
25
|
selectedValues,
|
|
25
26
|
withoutPortal
|
|
26
27
|
},
|
|
@@ -35,9 +36,9 @@ const useKeyboardNavigation = () => {
|
|
|
35
36
|
setFocusOptionIdx
|
|
36
37
|
} = useContext(ComboBoxContext);
|
|
37
38
|
const multiple = Array.isArray(selectedValues);
|
|
38
|
-
const selectableOptions = getOptions(
|
|
39
|
-
const currentItemIndex =
|
|
40
|
-
const currentItem =
|
|
39
|
+
const selectableOptions = getOptions(filteredOptions);
|
|
40
|
+
const currentItemIndex = filteredOptions.findIndex(opt => opt.dsId === focusOptionIdx);
|
|
41
|
+
const currentItem = filteredOptions.find(item => item.dsId === focusOptionIdx);
|
|
41
42
|
const onInputKeyDown = useCallback(e => {
|
|
42
43
|
// =============================================================================
|
|
43
44
|
// CUSTOM KEYS
|
|
@@ -55,7 +56,7 @@ const useKeyboardNavigation = () => {
|
|
|
55
56
|
if (onCancel) onCancel();
|
|
56
57
|
|
|
57
58
|
if (inputValue) {
|
|
58
|
-
if (onFilter) onFilter(
|
|
59
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
59
60
|
setInputValue('');
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -66,8 +67,10 @@ const useKeyboardNavigation = () => {
|
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
69
|
-
onCreate(inputValue);
|
|
70
|
-
|
|
70
|
+
onCreate(inputValue); //blank active item to force search last one
|
|
71
|
+
|
|
72
|
+
setFocusOptionIdx('');
|
|
73
|
+
if (onFilter) onFilter(allOptions, '');
|
|
71
74
|
setInputValue('');
|
|
72
75
|
return;
|
|
73
76
|
} // =============================================================================
|
|
@@ -80,10 +83,10 @@ const useKeyboardNavigation = () => {
|
|
|
80
83
|
e.stopPropagation();
|
|
81
84
|
|
|
82
85
|
if (focusOptionIdx !== '' && (showPopover || inline) && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === MENU_OPTION_TYPES.OPTION && !currentItem.disabled) {
|
|
83
|
-
if (onFilter) onFilter('');
|
|
86
|
+
if (onFilter) onFilter(allOptions, '');
|
|
84
87
|
setInputValue('');
|
|
85
88
|
|
|
86
|
-
if (!multiple
|
|
89
|
+
if (!multiple) {
|
|
87
90
|
setShowPopover(false);
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -96,7 +99,7 @@ const useKeyboardNavigation = () => {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {
|
|
99
|
-
onSelectAll(
|
|
102
|
+
onSelectAll(filteredOptions.filter(option => option.type === 'option' && !option.disabled), e);
|
|
100
103
|
} // =============================================================================
|
|
101
104
|
// ARROWS UP AND DOWN: LOGIC TO CALCULATE NEXT OR PREV ITEM TO PSEUDOFOCUS FROM INPUT
|
|
102
105
|
// =============================================================================
|
|
@@ -107,9 +110,9 @@ const useKeyboardNavigation = () => {
|
|
|
107
110
|
e.stopPropagation();
|
|
108
111
|
|
|
109
112
|
if ((showPopover || inline) && selectableOptions.length) {
|
|
110
|
-
const nextItemIndex = findInCircularList(
|
|
111
|
-
setFocusOptionIdx(
|
|
112
|
-
scrollOptionIntoView(
|
|
113
|
+
const nextItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);
|
|
114
|
+
setFocusOptionIdx(filteredOptions[nextItemIndex].dsId);
|
|
115
|
+
scrollOptionIntoView(filteredOptions[nextItemIndex].dsId);
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
|
|
@@ -117,17 +120,17 @@ const useKeyboardNavigation = () => {
|
|
|
117
120
|
e.preventDefault();
|
|
118
121
|
e.stopPropagation();
|
|
119
122
|
if (!selectableOptions.length) return;
|
|
120
|
-
const prevItemIndex = findInCircularList(
|
|
123
|
+
const prevItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
|
|
121
124
|
|
|
122
125
|
if (showPopover || inline) {
|
|
123
|
-
setFocusOptionIdx(
|
|
124
|
-
scrollOptionIntoView(
|
|
126
|
+
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
127
|
+
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
125
128
|
} else {
|
|
126
129
|
setShowPopover(true);
|
|
127
130
|
setTimeout(() => {
|
|
128
|
-
const prevItem = findInCircularList(
|
|
129
|
-
setFocusOptionIdx(
|
|
130
|
-
scrollOptionIntoView(
|
|
131
|
+
const prevItem = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
132
|
+
setFocusOptionIdx(filteredOptions[prevItem].dsId);
|
|
133
|
+
scrollOptionIntoView(filteredOptions[prevItem].dsId);
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
} // =============================================================================
|
|
@@ -135,14 +138,14 @@ const useKeyboardNavigation = () => {
|
|
|
135
138
|
// =============================================================================
|
|
136
139
|
|
|
137
140
|
|
|
138
|
-
if (e.key === 'Backspace' &&
|
|
141
|
+
if (e.key === 'Backspace' && e.currentTarget.value.length <= 0 && !inline) {
|
|
139
142
|
const lastValue = getLastValueSelected(selectedValues);
|
|
140
143
|
|
|
141
|
-
if (!
|
|
144
|
+
if (!e.currentTarget.value && lastValue) {
|
|
142
145
|
onChange(getSuggestedValueOnChange(lastValue, selectedValues), lastValue, e);
|
|
143
146
|
}
|
|
144
147
|
|
|
145
|
-
if (onFilter) onFilter(
|
|
148
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
if (e.key === 'Tab' && !inline && !withoutPortal) {
|
|
@@ -154,12 +157,13 @@ const useKeyboardNavigation = () => {
|
|
|
154
157
|
e.preventDefault();
|
|
155
158
|
element.focus();
|
|
156
159
|
}
|
|
157
|
-
}
|
|
158
|
-
// if (e.key === 'Tab' && multiple) {
|
|
159
|
-
// }
|
|
160
|
+
}
|
|
160
161
|
|
|
162
|
+
if (e.key === 'Tab' && !multiple && showPopover) {
|
|
163
|
+
setShowPopover(false);
|
|
164
|
+
}
|
|
161
165
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
162
|
-
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, focusOptionIdx, showPopover, selectableOptions.length,
|
|
166
|
+
[onKeyDown, currentItem, onCreate, multiple, inputValue, inline, withoutPortal, setShowPopover, onCancel, onFilter, setInputValue, focusOptionIdx, showPopover, selectableOptions.length, filteredOptions, currentItemIndex, setFocusOptionIdx, selectedValues, onChange, selectAllCheckboxRef, toggleSelectionButtonRef]);
|
|
163
167
|
return {
|
|
164
168
|
onInputKeyDown
|
|
165
169
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useContext, useCallback } from 'react';
|
|
2
2
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
3
|
+
import { filterOptions } from '../../utils/listHelper.js';
|
|
3
4
|
|
|
4
5
|
const useMaskedOnChange = () => {
|
|
5
6
|
const {
|
|
6
7
|
props: {
|
|
7
8
|
useMask,
|
|
8
|
-
onFilter
|
|
9
|
+
onFilter,
|
|
10
|
+
allOptions
|
|
9
11
|
},
|
|
10
12
|
setShowPopover,
|
|
11
13
|
setInputValue,
|
|
@@ -17,16 +19,16 @@ const useMaskedOnChange = () => {
|
|
|
17
19
|
setShowPopover(true);
|
|
18
20
|
|
|
19
21
|
if (onFilter) {
|
|
20
|
-
onFilter(e.currentTarget.value);
|
|
22
|
+
onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
21
23
|
setInputValue(e.currentTarget.value);
|
|
22
24
|
}
|
|
23
|
-
}, [onFilter, setInputValue, setShowPopover, setShowSelectedOptions]); // onchange used when mask is provided
|
|
25
|
+
}, [allOptions, onFilter, setInputValue, setShowPopover, setShowSelectedOptions]); // onchange used when mask is provided
|
|
24
26
|
|
|
25
27
|
const handleOnChangeMask = useCallback((_, mask) => {
|
|
26
28
|
setShowSelectedOptions(false);
|
|
27
29
|
setShowPopover(true);
|
|
28
|
-
if (mask && onFilter) onFilter(mask);
|
|
29
|
-
}, [onFilter, setShowPopover, setShowSelectedOptions]);
|
|
30
|
+
if (mask && onFilter) onFilter(filterOptions(mask, allOptions), mask);else if (!mask && onFilter) onFilter(allOptions, '');
|
|
31
|
+
}, [allOptions, onFilter, setShowPopover, setShowSelectedOptions]);
|
|
30
32
|
const onChangeMask = useMask({
|
|
31
33
|
valueSetter: setInputValue,
|
|
32
34
|
onChange: handleOnChangeMask
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import ChevronSmallDown from '@elliemae/ds-icons
|
|
3
|
+
import { ChevronSmallDown } from '@elliemae/ds-icons';
|
|
4
4
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
5
5
|
import { StyledDropDownButton } from './styled.js';
|
|
6
6
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
@@ -27,4 +27,4 @@ const DropdownIndicator = () => {
|
|
|
27
27
|
}, void 0, _ChevronSmallDown || (_ChevronSmallDown = /*#__PURE__*/_jsx(ChevronSmallDown, {})));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export { DropdownIndicator as default };
|
|
30
|
+
export { DropdownIndicator, DropdownIndicator as default };
|
|
@@ -10,7 +10,7 @@ const useHeaderListHandlers = () => {
|
|
|
10
10
|
const {
|
|
11
11
|
props: {
|
|
12
12
|
selectedValues,
|
|
13
|
-
|
|
13
|
+
filteredOptions,
|
|
14
14
|
onSelectAll,
|
|
15
15
|
innerRef
|
|
16
16
|
},
|
|
@@ -19,7 +19,7 @@ const useHeaderListHandlers = () => {
|
|
|
19
19
|
setShowPopover
|
|
20
20
|
} = useContext(ComboBoxContext);
|
|
21
21
|
const multiSelectedValues = selectedValues;
|
|
22
|
-
const selectableOptions = getSelectableOptions(
|
|
22
|
+
const selectableOptions = getSelectableOptions(filteredOptions);
|
|
23
23
|
const getCheckboxStatus = useMemo(() => {
|
|
24
24
|
if (multiSelectedValues.length === selectableOptions.length) {
|
|
25
25
|
return true;
|
|
@@ -40,13 +40,13 @@ const useHeaderListHandlers = () => {
|
|
|
40
40
|
}, []);
|
|
41
41
|
const handleSelectAllCheckboxChange = useCallback(e => {
|
|
42
42
|
if ((!checkboxStatus || checkboxStatus === 'mixed') && onSelectAll) {
|
|
43
|
-
onSelectAll(
|
|
43
|
+
onSelectAll(filteredOptions.filter(option => option.type === 'option' && !option.disabled), e);
|
|
44
44
|
setCheckboxStatus(true);
|
|
45
45
|
} else if (onSelectAll) {
|
|
46
46
|
onSelectAll([], e);
|
|
47
47
|
setCheckboxStatus(false);
|
|
48
48
|
}
|
|
49
|
-
}, [checkboxStatus, onSelectAll,
|
|
49
|
+
}, [checkboxStatus, onSelectAll, filteredOptions]);
|
|
50
50
|
const handleToggleSelectedValuesFilter = useCallback(e => {
|
|
51
51
|
e.preventDefault();
|
|
52
52
|
setShowSelectedOptions(!showSelectedOptions);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
2
|
import { useContext, useCallback, useMemo } from 'react';
|
|
3
|
+
import { useOnElementResize } from '@elliemae/ds-utilities';
|
|
3
4
|
import { StyledListWrapper, StyledVirtualListWrapper, StyledList, StyledNoResultsWrapper } from './styled.js';
|
|
4
5
|
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
5
6
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
@@ -15,18 +16,22 @@ const MenuList = () => {
|
|
|
15
16
|
menuMaxHeight,
|
|
16
17
|
onCreate,
|
|
17
18
|
inline,
|
|
18
|
-
|
|
19
|
+
filteredOptions,
|
|
19
20
|
selectedValues
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
+
controlsWrapperRef,
|
|
22
23
|
listRef,
|
|
23
24
|
inputValue,
|
|
24
25
|
wrapperListRef,
|
|
25
26
|
virtualListHelpers
|
|
26
27
|
} = useContext(ComboBoxContext);
|
|
27
|
-
const multiple = Array.isArray(selectedValues);
|
|
28
|
-
|
|
28
|
+
const multiple = Array.isArray(selectedValues); // removing the header list if we are filtering or is inline cb or we have no options to show
|
|
29
|
+
|
|
30
|
+
const withHeader = !inline && multiple && filteredOptions.length > 0 && !inputValue;
|
|
29
31
|
const ItemRenderer = useItemRenderer();
|
|
32
|
+
const {
|
|
33
|
+
width
|
|
34
|
+
} = useOnElementResize(controlsWrapperRef);
|
|
30
35
|
const preventLoseInputFocus = useCallback(e => {
|
|
31
36
|
e.preventDefault();
|
|
32
37
|
}, []);
|
|
@@ -34,8 +39,9 @@ const MenuList = () => {
|
|
|
34
39
|
ref: wrapperListRef,
|
|
35
40
|
inline: inline,
|
|
36
41
|
onMouseDown: preventLoseInputFocus,
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
width: width,
|
|
43
|
+
minWidth: menuMinWidth,
|
|
44
|
+
children: [withHeader && (_HeaderList || (_HeaderList = /*#__PURE__*/_jsx(HeaderList, {}))), filteredOptions.length > 0 || onCreate ? /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
39
45
|
inline: inline,
|
|
40
46
|
maxHeight: menuMaxHeight,
|
|
41
47
|
ref: listRef,
|
|
@@ -52,7 +58,7 @@ const MenuList = () => {
|
|
|
52
58
|
}) : _StyledNoResultsWrapp || (_StyledNoResultsWrapp = /*#__PURE__*/_jsx(StyledNoResultsWrapper, {
|
|
53
59
|
"aria-live": "polite"
|
|
54
60
|
}, void 0, "No matches found"))]
|
|
55
|
-
}), [wrapperListRef, inline,
|
|
61
|
+
}), [wrapperListRef, inline, preventLoseInputFocus, width, menuMinWidth, withHeader, filteredOptions.length, onCreate, menuMaxHeight, listRef, virtualListHelpers === null || virtualListHelpers === void 0 ? void 0 : virtualListHelpers.totalSize, ItemRenderer]);
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
export { MenuList };
|
|
@@ -2,17 +2,28 @@ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLit
|
|
|
2
2
|
import { styled } from '@elliemae/ds-system';
|
|
3
3
|
|
|
4
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
5
|
-
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n background-color: #ffffff;\n"])),
|
|
5
|
+
const StyledListWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-width: ", ";\n width: ", ";\n background-color: #ffffff;\n"])), _ref => {
|
|
6
|
+
let {
|
|
7
|
+
inline,
|
|
8
|
+
minWidth
|
|
9
|
+
} = _ref;
|
|
10
|
+
return inline ? '100%' : "".concat(minWidth, "px");
|
|
11
|
+
}, _ref2 => {
|
|
12
|
+
let {
|
|
13
|
+
width
|
|
14
|
+
} = _ref2;
|
|
15
|
+
return "".concat(width, "px");
|
|
16
|
+
});
|
|
6
17
|
const StyledList = styled.ul(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0;\n"])));
|
|
7
|
-
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n\n max-height: ", ";\n"])),
|
|
18
|
+
const StyledVirtualListWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow-y: auto;\n margin-top: ", ";\n\n max-height: ", ";\n"])), _ref3 => {
|
|
8
19
|
let {
|
|
9
20
|
withHeader
|
|
10
|
-
} =
|
|
21
|
+
} = _ref3;
|
|
11
22
|
return withHeader ? '28px' : '';
|
|
12
|
-
},
|
|
23
|
+
}, _ref4 => {
|
|
13
24
|
let {
|
|
14
25
|
maxHeight
|
|
15
|
-
} =
|
|
26
|
+
} = _ref4;
|
|
16
27
|
return !maxHeight ? '400px' : "".concat(maxHeight, "px");
|
|
17
28
|
});
|
|
18
29
|
const StyledCreatableLabel = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-weight: bold;\n font-style: italic;\n"])));
|
|
@@ -25,12 +25,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
25
25
|
const useItemRenderer = () => {
|
|
26
26
|
const {
|
|
27
27
|
props: {
|
|
28
|
-
|
|
28
|
+
filteredOptions,
|
|
29
29
|
onCreate,
|
|
30
30
|
onChange,
|
|
31
31
|
selectedValues,
|
|
32
32
|
onFilter,
|
|
33
|
-
|
|
33
|
+
allOptions
|
|
34
34
|
},
|
|
35
35
|
setShowPopover,
|
|
36
36
|
inputValue,
|
|
@@ -45,11 +45,11 @@ const useItemRenderer = () => {
|
|
|
45
45
|
if (inputValue) {
|
|
46
46
|
onCreate(inputValue);
|
|
47
47
|
setInputValue('');
|
|
48
|
-
onFilter(
|
|
48
|
+
onFilter(allOptions, inputValue);
|
|
49
49
|
}
|
|
50
50
|
} else if (option.type === MENU_OPTION_TYPES.OPTION) {
|
|
51
51
|
if (!option.disabled) {
|
|
52
|
-
if (onFilter) onFilter(
|
|
52
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
53
53
|
setInputValue('');
|
|
54
54
|
|
|
55
55
|
if (!multiple) {
|
|
@@ -63,7 +63,7 @@ const useItemRenderer = () => {
|
|
|
63
63
|
|
|
64
64
|
e.stopPropagation();
|
|
65
65
|
e.preventDefault();
|
|
66
|
-
}, [onFilter, selectedValues, onChange, setShowPopover, multiple
|
|
66
|
+
}, [onFilter, selectedValues, onChange, setShowPopover, multiple]); // prevent blur from controls input
|
|
67
67
|
|
|
68
68
|
const handleOnMouseDown = useCallback(e => {
|
|
69
69
|
e.preventDefault();
|
|
@@ -74,7 +74,7 @@ const useItemRenderer = () => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return virtualListHelpers.virtualItems.map(vItem => {
|
|
77
|
-
const option =
|
|
77
|
+
const option = filteredOptions[vItem.index];
|
|
78
78
|
const generalProps = {
|
|
79
79
|
wrapperStyles: {
|
|
80
80
|
position: 'absolute',
|
|
@@ -124,7 +124,7 @@ const useItemRenderer = () => {
|
|
|
124
124
|
height: "16px",
|
|
125
125
|
gutter: "xxs",
|
|
126
126
|
alignItems: "center"
|
|
127
|
-
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx("span", {}, void 0, label));
|
|
127
|
+
}, void 0, _StyledCreatableLabel || (_StyledCreatableLabel = /*#__PURE__*/_jsx(StyledCreatableLabel, {}, void 0, "Add:")), /*#__PURE__*/_jsx("span", {}, void 0, "\"".concat(label, "\"")));
|
|
128
128
|
},
|
|
129
129
|
label: option.label,
|
|
130
130
|
onClick: e => handleClick(option, e)
|
|
@@ -133,7 +133,7 @@ const useItemRenderer = () => {
|
|
|
133
133
|
|
|
134
134
|
return /*#__PURE__*/jsx(Fragment, {});
|
|
135
135
|
});
|
|
136
|
-
}, [
|
|
136
|
+
}, [filteredOptions, focusOptionIdx, selectedValues, virtualListHelpers]);
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
export { useItemRenderer };
|
|
@@ -6,7 +6,7 @@ const useMenuListSetFocusOption = () => {
|
|
|
6
6
|
const {
|
|
7
7
|
props: {
|
|
8
8
|
selectedValues,
|
|
9
|
-
|
|
9
|
+
filteredOptions
|
|
10
10
|
},
|
|
11
11
|
setFocusOptionIdx,
|
|
12
12
|
hasFocus,
|
|
@@ -15,16 +15,16 @@ const useMenuListSetFocusOption = () => {
|
|
|
15
15
|
scrollOptionIntoView
|
|
16
16
|
} = useContext(ComboBoxContext);
|
|
17
17
|
const getFirstOption = useCallback(() => {
|
|
18
|
-
for (let i = 0; i <
|
|
19
|
-
setFocusOptionIdx(
|
|
18
|
+
for (let i = 0; i < filteredOptions.length; i += 1) if (!['section', 'separator'].includes(filteredOptions[i].type) && !filteredOptions[i].disabled) {
|
|
19
|
+
setFocusOptionIdx(filteredOptions[i].dsId);
|
|
20
20
|
break;
|
|
21
21
|
}
|
|
22
|
-
}, [
|
|
22
|
+
}, [filteredOptions, setFocusOptionIdx]);
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
scrollOptionIntoView(focusOptionIdx); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
}, [focusOptionIdx]);
|
|
26
26
|
useEffect(() => {
|
|
27
|
-
if (
|
|
27
|
+
if (filteredOptions.length === 0) {
|
|
28
28
|
setFocusOptionIdx('');
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ const useMenuListSetFocusOption = () => {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (hasFocus) getFirstOption();
|
|
44
|
-
}, [getFirstOption, inputValue, selectedValues, hasFocus, setFocusOptionIdx,
|
|
44
|
+
}, [getFirstOption, inputValue, selectedValues, hasFocus, setFocusOptionIdx, filteredOptions.length]);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export { useMenuListSetFocusOption };
|
|
@@ -12,7 +12,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
12
12
|
function noop() {}
|
|
13
13
|
const ComboboxPropTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
14
14
|
placeholder: PropTypes.string.description("input's placeholder value").defaultValue(''),
|
|
15
|
-
|
|
15
|
+
allOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired.description('List of original options').defaultValue([]),
|
|
16
|
+
filteredOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of filtered options to show in the menu based on the current internal input filter value').defaultValue([]),
|
|
16
17
|
selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).isRequired.description('Array of option or single option selected'),
|
|
17
18
|
disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),
|
|
18
19
|
autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
|
|
@@ -6,6 +6,8 @@ import 'core-js/modules/esnext.iterator.some.js';
|
|
|
6
6
|
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
7
7
|
import 'core-js/modules/esnext.iterator.find.js';
|
|
8
8
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
11
|
import { MENU_OPTION_TYPES } from '../constants.js';
|
|
10
12
|
|
|
11
13
|
const getSelectableOptions = options => options.filter(option => option.type === MENU_OPTION_TYPES.OPTION && !option.disabled);
|
|
@@ -30,15 +32,17 @@ const findInCircularList = function (list, from, criteria) {
|
|
|
30
32
|
|
|
31
33
|
return from; // return same item
|
|
32
34
|
};
|
|
35
|
+
const getLastValueSelected = selectedValues => {
|
|
36
|
+
if (Array.isArray(selectedValues)) {
|
|
37
|
+
return selectedValues[selectedValues.length - 1];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return selectedValues;
|
|
41
|
+
};
|
|
33
42
|
const getFirstOption = (options, selectedValues, inputValue) => {
|
|
34
43
|
if (!inputValue) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (selectedValues !== null && selectedValues !== void 0 && selectedValues.dsId) {
|
|
40
|
-
return selectedValues.dsId;
|
|
41
|
-
}
|
|
44
|
+
const lastValue = getLastValueSelected(selectedValues);
|
|
45
|
+
if (lastValue) return lastValue.dsId;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type) && !options[i].disabled) {
|
|
@@ -64,12 +68,34 @@ const getSuggestedValueOnChange = (selectedOption, selectedValues) => {
|
|
|
64
68
|
|
|
65
69
|
return selectedOption;
|
|
66
70
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
const filterOptions = (inputValue, options) => options.filter(option => option.type === MENU_OPTION_TYPES.OPTION && option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
72
|
+
const selectedValuesWithSections = (optionsToParse, multiSelectedValue) => {
|
|
73
|
+
var _items2;
|
|
74
|
+
|
|
75
|
+
const items = [];
|
|
76
|
+
if (optionsToParse) optionsToParse.forEach(option => {
|
|
77
|
+
// const isSelectedValue = multiSelectedValue.find((item) => item?.dsId === option.dsId);
|
|
78
|
+
if (option.type === MENU_OPTION_TYPES.OPTION && isSelected(multiSelectedValue, option)) {
|
|
79
|
+
items.push(option);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (option.type === MENU_OPTION_TYPES.SECTION) {
|
|
83
|
+
var _items;
|
|
84
|
+
|
|
85
|
+
if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === MENU_OPTION_TYPES.SECTION) {
|
|
86
|
+
items[items.length - 1] = option;
|
|
87
|
+
} else {
|
|
88
|
+
items.push(option);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === MENU_OPTION_TYPES.SECTION) {
|
|
94
|
+
items.pop();
|
|
70
95
|
}
|
|
71
96
|
|
|
72
|
-
return
|
|
97
|
+
return items;
|
|
73
98
|
};
|
|
99
|
+
const getFilteredOptionsSelected = (filteredOption, selectedValues) => filteredOption.filter(option => option.type === MENU_OPTION_TYPES.OPTION && isSelected(selectedValues, option));
|
|
74
100
|
|
|
75
|
-
export { findInCircularList, getFirstOption, getLastValueSelected, getOptions, getSelectableOptions, getSuggestedValueOnChange, isSelected, isSelectedValueEmpty, isSelectedValueMultiple };
|
|
101
|
+
export { filterOptions, findInCircularList, getFilteredOptionsSelected, getFirstOption, getLastValueSelected, getOptions, getSelectableOptions, getSuggestedValueOnChange, isSelected, isSelectedValueEmpty, isSelectedValueMultiple, selectedValuesWithSections };
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DSAutocomplete, DSAutocompleteWithSchema } from './autocomplete/Autocomplete.js';
|
|
2
2
|
export { DSControlledCheckbox, DSControlledCheckboxWithSchema } from './checkbox/ControlledCheckbox.js';
|
|
3
|
-
export { DSComboBox, DSComboBoxWithSchema } from './combobox/ComboBox.js';
|
|
3
|
+
export { DSComboBox, DSComboBox as DSComboBoxV3, DSComboBoxWithSchema } from './combobox/ComboBox.js';
|
|
4
4
|
export { DSControlledDateRangePicker, DSControlledDateRangePickerWithSchema } from './date-range-picker/ControlledDateRangePicker.js';
|
|
5
5
|
export { ControlledDateRangePickerDatatestid } from './date-range-picker/ControlledDateRangePickerDatatestid.js';
|
|
6
6
|
export { CONTROLLED_DATE_RANGE_PICKER_TYPES } from './date-range-picker/ControlledDateRangePickerTypes.js';
|
|
@@ -11,11 +11,15 @@ export { deconstructValuesFromDateString, prependStringWithPlaceHolders } from '
|
|
|
11
11
|
export { getValidationDateTimeStringMetaInfo } from './date-time-picker/utils/dateTimeHelpers.js';
|
|
12
12
|
export { getDateStringFromDay, getDateValuesFromDate, getDayFromDateString, getValidationDateStringMetaInfo } from './date-time-picker/utils/dateHelpers.js';
|
|
13
13
|
export { getValidationTimeStringMetaInfo } from './date-time-picker/utils/timeHelpers.js';
|
|
14
|
-
export { UsePhoneMaskWithSchema, usePhoneMask } from './mask-hook/hooks/usePhoneMask.js';
|
|
15
|
-
export { UseNumberMaskWithSchema, useNumberMask } from './mask-hook/hooks/useNumberMask.js';
|
|
16
|
-
export { UseSSNMaskWithSchema, useSSNMask } from './mask-hook/hooks/useSSNMask.js';
|
|
17
|
-
export {
|
|
14
|
+
export { UsePhoneMaskWithSchema, getPhoneMaskedValue, usePhoneMask } from './mask-hook/hooks/usePhoneMask.js';
|
|
15
|
+
export { UseNumberMaskWithSchema, getNumberMaskedValue, useNumberMask } from './mask-hook/hooks/useNumberMask.js';
|
|
16
|
+
export { UseSSNMaskWithSchema, getSSNMaskedValue, useSSNMask } from './mask-hook/hooks/useSSNMask.js';
|
|
17
|
+
export { UseRegExpMaskWithSchema, isRegExp, useRegExpMask } from './mask-hook/hooks/useRegExpMask.js';
|
|
18
|
+
export { UseZipCodeMaskWithSchema, getUseZipMaskedValue, useZipCodeMask } from './mask-hook/hooks/useZipCodeMask.js';
|
|
18
19
|
export { DSInputText, DSInputTextWithSchema } from './text-input/DSInputText.js';
|
|
19
20
|
export { DSInputTextDataTestIds } from './text-input/exported-related/data-test-ids.js';
|
|
20
21
|
export { DSInputTextName, DSInputTextSlots } from './text-input/exported-related/theming.js';
|
|
21
22
|
export { DSControlledToggle, DSControlledToggleWithSchema } from './toggle/ControlledToggle.js';
|
|
23
|
+
export { DSControlledLargeTextInput, DSControlledLargeTextInputWithSchema } from './large-text-input/DSControlledLargeTextInput.js';
|
|
24
|
+
export { DSControlledLargetTextInputDatatestids } from './large-text-input/exported-related/data-test-ids.js';
|
|
25
|
+
export { DSControlledLargeTextInputName, DSControlledLargeTextInputSlots } from './large-text-input/exported-related/theming.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
+
import { useCallback } from 'react';
|
|
10
|
+
import { describe, useValidateTypescriptPropTypes, useMemoMergePropsWithDefault, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';
|
|
11
|
+
import { propTypes, defaultProps } from './react-desc-prop-types.js';
|
|
12
|
+
import { StyledContainer, StyledTextArea, StyledCharCounter } from './styles.js';
|
|
13
|
+
import { DSControlledLargetTextInputDatatestids } from './exported-related/data-test-ids.js';
|
|
14
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
const _excluded = ["maxLength", "value", "onChange", "innerRef", "resizable", "name", "id", "withoutCharacterCounter", "hasError"],
|
|
17
|
+
_excluded2 = ["className"];
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
|
|
23
|
+
const DSControlledLargeTextInput = props => {
|
|
24
|
+
useValidateTypescriptPropTypes(props, propTypes);
|
|
25
|
+
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
maxLength,
|
|
29
|
+
value,
|
|
30
|
+
onChange,
|
|
31
|
+
innerRef,
|
|
32
|
+
resizable,
|
|
33
|
+
name,
|
|
34
|
+
id,
|
|
35
|
+
withoutCharacterCounter,
|
|
36
|
+
hasError
|
|
37
|
+
} = propsWithDefault,
|
|
38
|
+
otherProps = _objectWithoutProperties(propsWithDefault, _excluded);
|
|
39
|
+
|
|
40
|
+
const _useGetGlobalAttribut = useGetGlobalAttributes(otherProps),
|
|
41
|
+
{
|
|
42
|
+
className
|
|
43
|
+
} = _useGetGlobalAttribut,
|
|
44
|
+
globalAttributes = _objectWithoutProperties(_useGetGlobalAttribut, _excluded2);
|
|
45
|
+
|
|
46
|
+
const xstyledProps = useGetXstyledProps(otherProps);
|
|
47
|
+
const handleOnChange = useCallback(e => onChange(e.target.value, e), [onChange]);
|
|
48
|
+
return /*#__PURE__*/jsxs(StyledContainer, _objectSpread(_objectSpread({
|
|
49
|
+
className: className,
|
|
50
|
+
"data-testid": DSControlledLargetTextInputDatatestids.CONTAINER
|
|
51
|
+
}, xstyledProps), {}, {
|
|
52
|
+
children: [/*#__PURE__*/jsx(StyledTextArea, _objectSpread({
|
|
53
|
+
ref: innerRef,
|
|
54
|
+
maxLength: maxLength,
|
|
55
|
+
"aria-multiline": true,
|
|
56
|
+
value: value,
|
|
57
|
+
onChange: handleOnChange,
|
|
58
|
+
resizable: resizable,
|
|
59
|
+
name: name,
|
|
60
|
+
id: id,
|
|
61
|
+
"data-testid": DSControlledLargetTextInputDatatestids.INPUT,
|
|
62
|
+
hasError: hasError
|
|
63
|
+
}, globalAttributes)), maxLength && !withoutCharacterCounter && /*#__PURE__*/_jsx(StyledCharCounter, {
|
|
64
|
+
"data-testid": DSControlledLargetTextInputDatatestids.CHAR_COUNTER
|
|
65
|
+
}, void 0, "".concat(value.length, "/").concat(maxLength))]
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const DSControlledLargeTextInputWithSchema = describe(DSControlledLargeTextInput);
|
|
70
|
+
DSControlledLargeTextInputWithSchema.propTypes = propTypes;
|
|
71
|
+
|
|
72
|
+
export { DSControlledLargeTextInput, DSControlledLargeTextInputWithSchema };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const DSControlledLargetTextInputDatatestids = {
|
|
2
|
+
CONTAINER: 'ds-controlled-large-text-input-container',
|
|
3
|
+
CHAR_COUNTER: 'ds-controlled-large-text-input-char-counter',
|
|
4
|
+
INPUT: 'ds-controlled-large-text-input'
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { DSControlledLargetTextInputDatatestids };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const DSControlledLargeTextInputName = 'ds-controlled-large-text-input';
|
|
2
|
+
const DSControlledLargeTextInputSlots = {
|
|
3
|
+
CONTAINER: 'root',
|
|
4
|
+
INPUT: 'input',
|
|
5
|
+
CHAR_COUNTER: 'char-counter'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { DSControlledLargeTextInputName, DSControlledLargeTextInputSlots };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DSControlledLargeTextInput, DSControlledLargeTextInputWithSchema } from './DSControlledLargeTextInput.js';
|
|
2
|
+
export { DSControlledLargetTextInputDatatestids } from './exported-related/data-test-ids.js';
|
|
3
|
+
export { DSControlledLargeTextInputName, DSControlledLargeTextInputSlots } from './exported-related/theming.js';
|