@elliemae/ds-controlled-form 2.3.0-next.5 → 2.3.0-next.9
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/controlled-combobox/ComboBox.js +3 -6
- package/cjs/controlled-combobox/ComboBoxCTX.js +3 -3
- package/cjs/controlled-combobox/ComboboxDataTestids.js +2 -1
- package/cjs/controlled-combobox/config/useComboBox.js +15 -70
- package/cjs/controlled-combobox/config/useCorrectOptions.js +77 -0
- package/cjs/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +46 -0
- package/cjs/controlled-combobox/parts/a11y-messages/{MultiAllyMessages.js → SelectedValuesAllyMsg.js} +16 -7
- package/cjs/controlled-combobox/parts/a11y-messages/index.js +4 -4
- package/cjs/controlled-combobox/parts/container/Container.js +40 -15
- package/cjs/controlled-combobox/parts/container/styled.js +9 -6
- package/cjs/controlled-combobox/parts/controls/Controls.js +30 -19
- package/cjs/controlled-combobox/parts/controls/styled.js +22 -10
- package/cjs/controlled-combobox/parts/controls/useOnPillsNavigation.js +51 -0
- package/cjs/controlled-combobox/parts/controls-input/ControlsInput.js +9 -9
- package/cjs/controlled-combobox/parts/controls-input/useControlsInput.js +14 -8
- package/cjs/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
- package/cjs/controlled-combobox/parts/dropdown-indicator/styled.js +2 -3
- package/cjs/controlled-combobox/parts/header-list/HeaderList.js +6 -6
- package/cjs/controlled-combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/cjs/controlled-combobox/parts/menu-list/MenuList.js +9 -11
- package/cjs/controlled-combobox/parts/menu-list/styled.js +1 -1
- package/cjs/controlled-combobox/parts/menu-list/useItemRenderer.js +11 -11
- package/cjs/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
- package/cjs/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +19 -15
- package/cjs/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
- package/cjs/controlled-combobox/react-desc-prop-types.js +42 -0
- package/cjs/controlled-combobox/{index.d.js → sharedTypes.js} +0 -0
- package/cjs/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -15
- package/cjs/controlled-combobox/utils/listHelper.js +2 -2
- package/esm/controlled-combobox/ComboBox.js +4 -7
- package/esm/controlled-combobox/ComboBoxCTX.js +4 -4
- package/esm/controlled-combobox/ComboboxDataTestids.js +2 -1
- package/esm/controlled-combobox/config/useComboBox.js +17 -72
- package/esm/controlled-combobox/config/useCorrectOptions.js +73 -0
- package/esm/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +38 -0
- package/esm/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.js +34 -0
- package/esm/controlled-combobox/parts/a11y-messages/index.js +2 -2
- package/esm/controlled-combobox/parts/container/Container.js +38 -15
- package/esm/controlled-combobox/parts/container/styled.js +9 -6
- package/esm/controlled-combobox/parts/controls/Controls.js +31 -20
- package/esm/controlled-combobox/parts/controls/styled.js +22 -10
- package/esm/controlled-combobox/parts/controls/useOnPillsNavigation.js +47 -0
- package/esm/controlled-combobox/parts/controls-input/ControlsInput.js +9 -9
- package/esm/controlled-combobox/parts/controls-input/useControlsInput.js +14 -8
- package/esm/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
- package/esm/controlled-combobox/parts/dropdown-indicator/styled.js +3 -3
- package/esm/controlled-combobox/parts/header-list/HeaderList.js +6 -6
- package/esm/controlled-combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/esm/controlled-combobox/parts/menu-list/MenuList.js +10 -12
- package/esm/controlled-combobox/parts/menu-list/styled.js +1 -1
- package/esm/controlled-combobox/parts/menu-list/useItemRenderer.js +11 -11
- package/esm/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
- package/esm/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +20 -16
- package/esm/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
- package/esm/controlled-combobox/{propTypes.js → react-desc-prop-types.js} +16 -6
- package/esm/controlled-combobox/{index.d.js → sharedTypes.js} +0 -0
- package/esm/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -15
- package/esm/controlled-combobox/utils/listHelper.js +2 -2
- package/package.json +30 -38
- package/types/controlled-combobox/ComboBox.d.ts +4 -70
- package/types/controlled-combobox/ComboBoxCTX.d.ts +4 -3
- package/types/controlled-combobox/ComboboxDataTestids.d.ts +1 -0
- package/types/controlled-combobox/config/useComboBox.d.ts +3 -2
- package/types/controlled-combobox/config/useCorrectOptions.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/FocusMenuItem.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.d.ts +3 -0
- package/types/controlled-combobox/parts/a11y-messages/index.d.ts +2 -2
- package/types/controlled-combobox/parts/controls/styled.d.ts +10 -2
- package/types/controlled-combobox/parts/controls/useOnPillsNavigation.d.ts +4 -0
- package/types/controlled-combobox/parts/dropdown-indicator/styled.d.ts +2 -1
- package/types/controlled-combobox/react-desc-prop-types.d.ts +53 -0
- package/types/controlled-combobox/sharedTypes.d.ts +29 -0
- package/types/controlled-combobox/utils/hooks/useKeyboardNavigation.d.ts +1 -1
- package/types/controlled-combobox/utils/listHelper.d.ts +7 -7
- package/types/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.d.ts +3 -12
- package/types/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.d.ts +1 -4
- package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.d.ts +3 -12
- package/types/controlled-date-time-picker/parts/Styleds.d.ts +1 -4
- package/cjs/controlled-combobox/config/constants.js +0 -14
- package/cjs/controlled-combobox/config/useGetPropsWithDefault.js +0 -11
- package/cjs/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -28
- package/cjs/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -28
- package/cjs/controlled-combobox/parts/single-selected-value-container/index.js +0 -9
- package/cjs/controlled-combobox/parts/single-selected-value-container/styled.js +0 -15
- package/cjs/controlled-combobox/propTypes.js +0 -28
- package/esm/controlled-combobox/config/constants.js +0 -10
- package/esm/controlled-combobox/config/useGetPropsWithDefault.js +0 -7
- package/esm/controlled-combobox/parts/a11y-messages/MultiAllyMessages.js +0 -25
- package/esm/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -20
- package/esm/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -20
- package/esm/controlled-combobox/parts/single-selected-value-container/index.js +0 -1
- package/esm/controlled-combobox/parts/single-selected-value-container/styled.js +0 -7
- package/types/controlled-combobox/config/constants.d.ts +0 -8
- package/types/controlled-combobox/config/useGetPropsWithDefault.d.ts +0 -2
- package/types/controlled-combobox/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
- package/types/controlled-combobox/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
- package/types/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.d.ts +0 -3
- package/types/controlled-combobox/parts/single-selected-value-container/index.d.ts +0 -1
- package/types/controlled-combobox/parts/single-selected-value-container/styled.d.ts +0 -1
- package/types/controlled-combobox/propTypes.d.ts +0 -60
- package/types/controlled-combobox/tests/combobox-special-keys.test.d.ts +0 -1
|
@@ -6,43 +6,47 @@ import Grid from '@elliemae/ds-grid';
|
|
|
6
6
|
import { DSPillGroupV2, DSPillV2 } from '@elliemae/ds-pills';
|
|
7
7
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
8
8
|
import { useGroupPills } from './useGroupPills.js';
|
|
9
|
-
import {
|
|
10
|
-
import '
|
|
11
|
-
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
|
-
|
|
13
|
-
var _MultiAllyMessages;
|
|
9
|
+
import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
|
|
10
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
14
11
|
|
|
15
12
|
const MultiSelectedValuesContainer = () => {
|
|
16
|
-
var _inputRef$current;
|
|
17
|
-
|
|
18
13
|
const {
|
|
19
14
|
props: {
|
|
20
|
-
selectedValues
|
|
15
|
+
selectedValues,
|
|
16
|
+
onChange,
|
|
17
|
+
innerRef
|
|
21
18
|
},
|
|
22
|
-
inputRef,
|
|
23
19
|
pillGroupRef
|
|
24
20
|
} = useContext(ComboBoxContext);
|
|
25
21
|
const multiSelectedValue = selectedValues;
|
|
26
|
-
const
|
|
27
|
-
const correctPillsToShow = pillsToShow || 1;
|
|
22
|
+
const correctPillsToShow = useGroupPills() || 1;
|
|
28
23
|
const pills = useMemo(() => /*#__PURE__*/_jsx(Grid, {
|
|
29
24
|
style: {
|
|
30
25
|
width: 'max-content'
|
|
31
|
-
}
|
|
26
|
+
},
|
|
27
|
+
onClick: e => e.stopPropagation(),
|
|
28
|
+
"data-testid": ComboboxDataTestid.SELECTED_VALUES
|
|
32
29
|
}, void 0, /*#__PURE__*/_jsx(DSPillGroupV2, {
|
|
33
30
|
innerRef: pillGroupRef
|
|
34
31
|
}, void 0, multiSelectedValue.length > 0 && multiSelectedValue.slice(0, correctPillsToShow).map(option => /*#__PURE__*/_jsx(DSPillV2, {
|
|
35
32
|
size: "s",
|
|
36
33
|
label: option.label,
|
|
37
|
-
type: "
|
|
34
|
+
type: "removable",
|
|
35
|
+
tabIndex: -1,
|
|
36
|
+
onRemove: () => {
|
|
37
|
+
var _innerRef$current;
|
|
38
|
+
|
|
39
|
+
onChange(option);
|
|
40
|
+
(_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.focus();
|
|
41
|
+
}
|
|
38
42
|
}, option.value)), multiSelectedValue.length > 0 && correctPillsToShow !== multiSelectedValue.length && /*#__PURE__*/_jsx(DSPillV2, {
|
|
39
43
|
size: "s",
|
|
40
44
|
labelTruncated: false,
|
|
41
45
|
label: "+".concat(multiSelectedValue.length - correctPillsToShow),
|
|
42
46
|
type: "value"
|
|
43
|
-
}, "grouped"))), [pillGroupRef, multiSelectedValue, correctPillsToShow]);
|
|
44
|
-
return /*#__PURE__*/
|
|
45
|
-
children:
|
|
47
|
+
}, "grouped"))), [pillGroupRef, innerRef, onChange, multiSelectedValue, correctPillsToShow]);
|
|
48
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
49
|
+
children: pills
|
|
46
50
|
});
|
|
47
51
|
};
|
|
48
52
|
|
|
@@ -17,9 +17,9 @@ const getGroupedPillWidth = remainingPills => {
|
|
|
17
17
|
const useGroupPills = () => {
|
|
18
18
|
const {
|
|
19
19
|
props: {
|
|
20
|
-
selectedValues
|
|
20
|
+
selectedValues,
|
|
21
|
+
innerRef
|
|
21
22
|
},
|
|
22
|
-
inputRef,
|
|
23
23
|
selectedOptionsRef,
|
|
24
24
|
controlsWrapperRef,
|
|
25
25
|
pillGroupRef
|
|
@@ -31,7 +31,7 @@ const useGroupPills = () => {
|
|
|
31
31
|
} = useOnElementResize(controlsWrapperRef);
|
|
32
32
|
const {
|
|
33
33
|
width: widthInput
|
|
34
|
-
} = useOnElementResize(
|
|
34
|
+
} = useOnElementResize(innerRef || null);
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (multiSelectedValues.length !== pillsToShow) {
|
|
37
37
|
setPillsToShow(multiSelectedValues.length);
|
|
@@ -44,7 +44,7 @@ const useGroupPills = () => {
|
|
|
44
44
|
let lastPillFit = -1;
|
|
45
45
|
let currentWidth = 0;
|
|
46
46
|
const referenceWidth = selectedOptionsRef.current.offsetWidth;
|
|
47
|
-
const pills = [...selectedOptionsRef.current.querySelectorAll('.ds-pill-wrapper-
|
|
47
|
+
const pills = [...selectedOptionsRef.current.querySelectorAll('.ds-pill-wrapper-removable')];
|
|
48
48
|
const pillsWidth = pills.map(pill => pill === null || pill === void 0 ? void 0 : pill.offsetWidth);
|
|
49
49
|
pillsWidth.forEach((pillWidth, idx) => {
|
|
50
50
|
currentWidth += pillWidth;
|
|
@@ -64,7 +64,7 @@ const useGroupPills = () => {
|
|
|
64
64
|
|
|
65
65
|
if (pillGroupRef.current) pillGroupRef.current.style.width = 'fit-content';
|
|
66
66
|
}
|
|
67
|
-
}, [selectedOptionsRef,
|
|
67
|
+
}, [selectedOptionsRef, innerRef, multiSelectedValues, pillsToShow, pillGroupRef, width, widthInput]);
|
|
68
68
|
return pillsToShow;
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import
|
|
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 _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
const ComboboxPropTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
4
13
|
placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),
|
|
5
14
|
options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),
|
|
6
15
|
selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description('Array of option or single option selected'),
|
|
16
|
+
disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),
|
|
7
17
|
autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
|
|
8
18
|
hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
|
|
9
19
|
onChange: PropTypes.func.description('function triggered when an option is selected it will send the options selected').defaultValue(''),
|
|
@@ -16,9 +26,9 @@ const propTypes = {
|
|
|
16
26
|
inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),
|
|
17
27
|
menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),
|
|
18
28
|
menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),
|
|
19
|
-
withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false'),
|
|
20
29
|
withoutPortal: PropTypes.bool.description('Whether the combobox menu is rendered in a portal or not').defaultValue(false),
|
|
21
|
-
zIndex: PropTypes.number.description('The z-index of the combobox menu').defaultValue(10)
|
|
22
|
-
|
|
30
|
+
zIndex: PropTypes.number.description('The z-index of the combobox menu').defaultValue(10),
|
|
31
|
+
innerRef: PropTypes.object.description('ref to the component s container')
|
|
32
|
+
});
|
|
23
33
|
|
|
24
|
-
export {
|
|
34
|
+
export { ComboboxPropTypes };
|
|
File without changes
|
|
@@ -5,7 +5,7 @@ import { useContext, useCallback } from 'react';
|
|
|
5
5
|
import { ComboBoxContext } from '../../ComboBoxCTX.js';
|
|
6
6
|
import { findInCircularList } from '../listHelper.js';
|
|
7
7
|
|
|
8
|
-
const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type);
|
|
8
|
+
const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type) && !opt.disabled;
|
|
9
9
|
|
|
10
10
|
const useKeyboardNavigation = () => {
|
|
11
11
|
const {
|
|
@@ -19,13 +19,13 @@ const useKeyboardNavigation = () => {
|
|
|
19
19
|
options,
|
|
20
20
|
selectedValues,
|
|
21
21
|
onFilter,
|
|
22
|
-
withoutPortal
|
|
22
|
+
withoutPortal,
|
|
23
|
+
innerRef
|
|
23
24
|
},
|
|
24
25
|
setShowPopover,
|
|
25
26
|
showPopover,
|
|
26
27
|
setShowSelectedValue,
|
|
27
28
|
focusOptionIdx,
|
|
28
|
-
inputRef,
|
|
29
29
|
setCurrentOption,
|
|
30
30
|
scrollOptionIntoView,
|
|
31
31
|
selectAllCheckboxRef,
|
|
@@ -36,16 +36,17 @@ const useKeyboardNavigation = () => {
|
|
|
36
36
|
const currentItem = options.find(item => item.dsId === focusOptionIdx);
|
|
37
37
|
const selectOption = useCallback(() => {
|
|
38
38
|
if (multiple) {
|
|
39
|
-
if (
|
|
39
|
+
if (innerRef.current) onFilter(innerRef.current.value);
|
|
40
40
|
} else {
|
|
41
41
|
onFilter('');
|
|
42
|
-
if (
|
|
42
|
+
if (innerRef.current) innerRef.current.value = '';
|
|
43
43
|
setShowSelectedValue(true);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const selectedOption = options.find(item => item.dsId === focusOptionIdx);
|
|
47
|
+
onChange(selectedOption);
|
|
48
|
+
if (!selectedOption.disabled && !multiple) setShowPopover(false);
|
|
49
|
+
}, [multiple, options, focusOptionIdx, setShowPopover, onFilter, innerRef, setShowSelectedValue, onChange]);
|
|
49
50
|
const onInputKeyDown = useCallback(e => {
|
|
50
51
|
const targetElement = e.target; // =============================================================================
|
|
51
52
|
// CUSTOM KEYS
|
|
@@ -58,7 +59,7 @@ const useKeyboardNavigation = () => {
|
|
|
58
59
|
if (e.key === 'Enter' && (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) === 'creatable') {
|
|
59
60
|
onCreate(targetElement.value);
|
|
60
61
|
onFilter('');
|
|
61
|
-
if (
|
|
62
|
+
if (innerRef.current) innerRef.current.value = '';
|
|
62
63
|
return;
|
|
63
64
|
} // =============================================================================
|
|
64
65
|
// Enter and space on selection
|
|
@@ -67,6 +68,7 @@ const useKeyboardNavigation = () => {
|
|
|
67
68
|
|
|
68
69
|
if (e.key === 'Enter' || e.keyCode === 32 && e.altKey) {
|
|
69
70
|
e.preventDefault();
|
|
71
|
+
e.stopPropagation();
|
|
70
72
|
|
|
71
73
|
if (!showPopover && !inline) {
|
|
72
74
|
setShowPopover(true);
|
|
@@ -88,6 +90,7 @@ const useKeyboardNavigation = () => {
|
|
|
88
90
|
|
|
89
91
|
if (e.key === 'ArrowDown') {
|
|
90
92
|
e.preventDefault();
|
|
93
|
+
e.stopPropagation();
|
|
91
94
|
|
|
92
95
|
if (showPopover || inline) {
|
|
93
96
|
const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);
|
|
@@ -100,6 +103,7 @@ const useKeyboardNavigation = () => {
|
|
|
100
103
|
|
|
101
104
|
if (e.key === 'ArrowUp') {
|
|
102
105
|
e.preventDefault();
|
|
106
|
+
e.stopPropagation();
|
|
103
107
|
|
|
104
108
|
if (showPopover || inline) {
|
|
105
109
|
const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);
|
|
@@ -119,13 +123,13 @@ const useKeyboardNavigation = () => {
|
|
|
119
123
|
|
|
120
124
|
|
|
121
125
|
if (e.key === 'Escape') {
|
|
122
|
-
var
|
|
126
|
+
var _innerRef$current;
|
|
123
127
|
|
|
124
128
|
if (onCancel) onCancel();
|
|
125
129
|
|
|
126
|
-
if (
|
|
130
|
+
if (innerRef.current && ((_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.value) !== '') {
|
|
127
131
|
onFilter('');
|
|
128
|
-
|
|
132
|
+
innerRef.current.value = '';
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
if (!inline) setShowPopover(false);
|
|
@@ -154,10 +158,10 @@ const useKeyboardNavigation = () => {
|
|
|
154
158
|
e.preventDefault();
|
|
155
159
|
element.focus();
|
|
156
160
|
}
|
|
157
|
-
}
|
|
161
|
+
} // if (e.key === 'Tab' && multiple) {
|
|
162
|
+
// }
|
|
158
163
|
|
|
159
|
-
|
|
160
|
-
}, [currentItemIndex, options, currentItem, inputRef, multiple, showPopover, selectedValues, inline, scrollOptionIntoView, onKeyDown, onSelectAll, onChange, onCreate, onFilter, setCurrentOption, setShowPopover, setShowSelectedValue, selectOption, onCancel, selectAllCheckboxRef, toggleSelectionButtonRef, withoutPortal]);
|
|
164
|
+
}, [currentItemIndex, options, currentItem, innerRef, multiple, showPopover, selectedValues, inline, scrollOptionIntoView, onKeyDown, onSelectAll, onChange, onCreate, onFilter, setCurrentOption, setShowPopover, setShowSelectedValue, selectOption, onCancel, selectAllCheckboxRef, toggleSelectionButtonRef, withoutPortal]);
|
|
161
165
|
return {
|
|
162
166
|
onInputKeyDown
|
|
163
167
|
};
|
|
@@ -4,8 +4,8 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
4
4
|
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
5
5
|
import 'core-js/modules/esnext.iterator.some.js';
|
|
6
6
|
|
|
7
|
-
const getSelectableOptions = options => options
|
|
8
|
-
const getOptions = options => options
|
|
7
|
+
const getSelectableOptions = options => options.filter(option => option.type === 'option' && !option.disabled);
|
|
8
|
+
const getOptions = options => options.filter(option => option.type === 'option');
|
|
9
9
|
const isSelectedValueEmpty = value => Array.isArray(value) ? value.length === 0 : !value;
|
|
10
10
|
const isSelectedValueMultiple = value => Array.isArray(value);
|
|
11
11
|
const isSelected = (value, activeOption) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-controlled-form",
|
|
3
|
-
"version": "2.3.0-next.
|
|
3
|
+
"version": "2.3.0-next.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Controlled Form Controllers",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -419,21 +419,13 @@
|
|
|
419
419
|
"import": "./esm/controlled-combobox/tests/utils.js",
|
|
420
420
|
"require": "./cjs/controlled-combobox/tests/utils.js"
|
|
421
421
|
},
|
|
422
|
-
"./controlled-combobox/
|
|
423
|
-
"import": "./esm/controlled-combobox/
|
|
424
|
-
"require": "./cjs/controlled-combobox/
|
|
422
|
+
"./controlled-combobox/sharedTypes": {
|
|
423
|
+
"import": "./esm/controlled-combobox/sharedTypes.js",
|
|
424
|
+
"require": "./cjs/controlled-combobox/sharedTypes.js"
|
|
425
425
|
},
|
|
426
|
-
"./controlled-combobox/
|
|
427
|
-
"import": "./esm/controlled-combobox/
|
|
428
|
-
"require": "./cjs/controlled-combobox/
|
|
429
|
-
},
|
|
430
|
-
"./controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer": {
|
|
431
|
-
"import": "./esm/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js",
|
|
432
|
-
"require": "./cjs/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js"
|
|
433
|
-
},
|
|
434
|
-
"./controlled-combobox/parts/single-selected-value-container": {
|
|
435
|
-
"import": "./esm/controlled-combobox/parts/single-selected-value-container/index.js",
|
|
436
|
-
"require": "./cjs/controlled-combobox/parts/single-selected-value-container/index.js"
|
|
426
|
+
"./controlled-combobox/react-desc-prop-types": {
|
|
427
|
+
"import": "./esm/controlled-combobox/react-desc-prop-types.js",
|
|
428
|
+
"require": "./cjs/controlled-combobox/react-desc-prop-types.js"
|
|
437
429
|
},
|
|
438
430
|
"./controlled-combobox/parts/multi-selected-values-container/useGroupPills": {
|
|
439
431
|
"import": "./esm/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js",
|
|
@@ -507,6 +499,10 @@
|
|
|
507
499
|
"import": "./esm/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js",
|
|
508
500
|
"require": "./cjs/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js"
|
|
509
501
|
},
|
|
502
|
+
"./controlled-combobox/parts/controls/useOnPillsNavigation": {
|
|
503
|
+
"import": "./esm/controlled-combobox/parts/controls/useOnPillsNavigation.js",
|
|
504
|
+
"require": "./cjs/controlled-combobox/parts/controls/useOnPillsNavigation.js"
|
|
505
|
+
},
|
|
510
506
|
"./controlled-combobox/parts/controls/styled": {
|
|
511
507
|
"import": "./esm/controlled-combobox/parts/controls/styled.js",
|
|
512
508
|
"require": "./cjs/controlled-combobox/parts/controls/styled.js"
|
|
@@ -547,34 +543,30 @@
|
|
|
547
543
|
"import": "./esm/controlled-combobox/parts/a11y-messages/styled.js",
|
|
548
544
|
"require": "./cjs/controlled-combobox/parts/a11y-messages/styled.js"
|
|
549
545
|
},
|
|
550
|
-
"./controlled-combobox/parts/a11y-messages/
|
|
551
|
-
"import": "./esm/controlled-combobox/parts/a11y-messages/
|
|
552
|
-
"require": "./cjs/controlled-combobox/parts/a11y-messages/
|
|
553
|
-
},
|
|
554
|
-
"./controlled-combobox/parts/a11y-messages/MultiAllyMessages": {
|
|
555
|
-
"import": "./esm/controlled-combobox/parts/a11y-messages/MultiAllyMessages.js",
|
|
556
|
-
"require": "./cjs/controlled-combobox/parts/a11y-messages/MultiAllyMessages.js"
|
|
546
|
+
"./controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg": {
|
|
547
|
+
"import": "./esm/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.js",
|
|
548
|
+
"require": "./cjs/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.js"
|
|
557
549
|
},
|
|
558
550
|
"./controlled-combobox/parts/a11y-messages": {
|
|
559
551
|
"import": "./esm/controlled-combobox/parts/a11y-messages/index.js",
|
|
560
552
|
"require": "./cjs/controlled-combobox/parts/a11y-messages/index.js"
|
|
561
553
|
},
|
|
554
|
+
"./controlled-combobox/parts/a11y-messages/FocusMenuItem": {
|
|
555
|
+
"import": "./esm/controlled-combobox/parts/a11y-messages/FocusMenuItem.js",
|
|
556
|
+
"require": "./cjs/controlled-combobox/parts/a11y-messages/FocusMenuItem.js"
|
|
557
|
+
},
|
|
562
558
|
"./controlled-combobox": {
|
|
563
559
|
"import": "./esm/controlled-combobox/index.js",
|
|
564
560
|
"require": "./cjs/controlled-combobox/index.js"
|
|
565
561
|
},
|
|
566
|
-
"./controlled-combobox/config/
|
|
567
|
-
"import": "./esm/controlled-combobox/config/
|
|
568
|
-
"require": "./cjs/controlled-combobox/config/
|
|
562
|
+
"./controlled-combobox/config/useCorrectOptions": {
|
|
563
|
+
"import": "./esm/controlled-combobox/config/useCorrectOptions.js",
|
|
564
|
+
"require": "./cjs/controlled-combobox/config/useCorrectOptions.js"
|
|
569
565
|
},
|
|
570
566
|
"./controlled-combobox/config/useComboBox": {
|
|
571
567
|
"import": "./esm/controlled-combobox/config/useComboBox.js",
|
|
572
568
|
"require": "./cjs/controlled-combobox/config/useComboBox.js"
|
|
573
569
|
},
|
|
574
|
-
"./controlled-combobox/config/constants": {
|
|
575
|
-
"import": "./esm/controlled-combobox/config/constants.js",
|
|
576
|
-
"require": "./cjs/controlled-combobox/config/constants.js"
|
|
577
|
-
},
|
|
578
570
|
"./controlled-combobox/ComboboxDataTestids": {
|
|
579
571
|
"import": "./esm/controlled-combobox/ComboboxDataTestids.js",
|
|
580
572
|
"require": "./cjs/controlled-combobox/ComboboxDataTestids.js"
|
|
@@ -744,15 +736,15 @@
|
|
|
744
736
|
"build": "node ../../scripts/build/build.js"
|
|
745
737
|
},
|
|
746
738
|
"dependencies": {
|
|
747
|
-
"@elliemae/ds-button": "2.3.0-next.
|
|
748
|
-
"@elliemae/ds-form-layout-blocks": "2.3.0-next.
|
|
749
|
-
"@elliemae/ds-grid": "2.3.0-next.
|
|
750
|
-
"@elliemae/ds-icon": "2.3.0-next.
|
|
751
|
-
"@elliemae/ds-icons": "2.3.0-next.
|
|
752
|
-
"@elliemae/ds-props-helpers": "2.3.0-next.
|
|
753
|
-
"@elliemae/ds-system": "2.3.0-next.
|
|
754
|
-
"@elliemae/ds-tooltip": "2.3.0-next.
|
|
755
|
-
"@elliemae/ds-truncated-tooltip-text": "2.3.0-next.
|
|
739
|
+
"@elliemae/ds-button": "2.3.0-next.9",
|
|
740
|
+
"@elliemae/ds-form-layout-blocks": "2.3.0-next.9",
|
|
741
|
+
"@elliemae/ds-grid": "2.3.0-next.9",
|
|
742
|
+
"@elliemae/ds-icon": "2.3.0-next.9",
|
|
743
|
+
"@elliemae/ds-icons": "2.3.0-next.9",
|
|
744
|
+
"@elliemae/ds-props-helpers": "2.3.0-next.9",
|
|
745
|
+
"@elliemae/ds-system": "2.3.0-next.9",
|
|
746
|
+
"@elliemae/ds-tooltip": "2.3.0-next.9",
|
|
747
|
+
"@elliemae/ds-truncated-tooltip-text": "2.3.0-next.9",
|
|
756
748
|
"prop-types": "~15.7.2",
|
|
757
749
|
"react-desc": "~4.1.3",
|
|
758
750
|
"react-popper": "~2.2.5",
|
|
@@ -1,71 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const
|
|
5
|
-
(props: ComboBoxPropsT): JSX.Element;
|
|
6
|
-
propTypes: {
|
|
7
|
-
placeholder: {
|
|
8
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
9
|
-
};
|
|
10
|
-
options: {
|
|
11
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
12
|
-
};
|
|
13
|
-
selectedValues: {
|
|
14
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
15
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
16
|
-
};
|
|
17
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
18
|
-
};
|
|
19
|
-
autoFocus: {
|
|
20
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
21
|
-
};
|
|
22
|
-
hasError: {
|
|
23
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
24
|
-
};
|
|
25
|
-
onChange: {
|
|
26
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
27
|
-
};
|
|
28
|
-
onSelectAll: {
|
|
29
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
30
|
-
};
|
|
31
|
-
onFilter: {
|
|
32
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
33
|
-
};
|
|
34
|
-
onCreate: {
|
|
35
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
36
|
-
};
|
|
37
|
-
onClearAll: {
|
|
38
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
39
|
-
};
|
|
40
|
-
onCancel: {
|
|
41
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
42
|
-
};
|
|
43
|
-
onMenuOpen: {
|
|
44
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
45
|
-
};
|
|
46
|
-
inputMinWidth: {
|
|
47
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
48
|
-
};
|
|
49
|
-
menuMinWidth: {
|
|
50
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
51
|
-
};
|
|
52
|
-
menuMaxHeight: {
|
|
53
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
54
|
-
};
|
|
55
|
-
withToggle: {
|
|
56
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
57
|
-
};
|
|
58
|
-
withoutPortal: {
|
|
59
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
60
|
-
};
|
|
61
|
-
zIndex: {
|
|
62
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
declare const DSComboBoxWithSchema: {
|
|
67
|
-
(props?: unknown): JSX.Element;
|
|
68
|
-
propTypes: unknown;
|
|
69
|
-
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
70
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DSComboboxT } from './react-desc-prop-types';
|
|
3
|
+
declare const DSComboBox: React.ComponentType<DSComboboxT.Props>;
|
|
4
|
+
declare const DSComboBoxWithSchema: any;
|
|
71
5
|
export { DSComboBox, DSComboBoxWithSchema };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { DSComboboxT } from './react-desc-prop-types';
|
|
3
|
+
import { DSComboboxInternalsT } from './sharedTypes';
|
|
4
|
+
export declare const defaultProps: DSComboboxT.Props;
|
|
4
5
|
/** Context for cross component communication */
|
|
5
|
-
export declare const ComboBoxContext: import("react").Context<ComboBoxContextT>;
|
|
6
|
+
export declare const ComboBoxContext: import("react").Context<DSComboboxInternalsT.ComboBoxContextT>;
|
|
6
7
|
export default ComboBoxContext;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { DSComboboxT } from '../react-desc-prop-types';
|
|
2
|
+
import { DSComboboxInternalsT } from '../sharedTypes';
|
|
3
|
+
export declare const useComboBox: (props: Partial<DSComboboxT.Props>) => DSComboboxInternalsT.ComboBoxContextT;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { SelectedValuesAllyMsg } from './SelectedValuesAllyMsg';
|
|
2
|
+
export { FocusMenuItem } from './FocusMenuItem';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
interface StyledControlsWrapperT {
|
|
3
|
+
hasError?: boolean;
|
|
4
|
+
inline?: boolean;
|
|
5
|
+
hasFocus?: boolean;
|
|
6
|
+
minWidth: number;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const StyledControlsWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, StyledControlsWrapperT, never>;
|
|
3
10
|
export declare const StyledSelection: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
-
export declare const StyledHeaderActionsWrapper: import("styled-components").StyledComponent<"
|
|
11
|
+
export declare const StyledHeaderActionsWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elliemae/ds-grid/types/types").GridPropsT & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
5
12
|
export declare const StyleDropdownIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
13
|
export declare const StyleHeaderActionsSeparator: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
14
|
+
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledDropDownButton: import("styled-components").StyledComponent<import("react").ComponentType<import("@elliemae/ds-button/types/v2/propTypes").DSButtonT.Props>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare namespace DSComboboxT {
|
|
3
|
+
interface CommonItemOptions {
|
|
4
|
+
dsId: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
render?: React.ComponentType<unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface ItemSeparatorOptions extends CommonItemOptions {
|
|
9
|
+
type: 'separator';
|
|
10
|
+
}
|
|
11
|
+
interface ItemSectionOptions extends CommonItemOptions {
|
|
12
|
+
type: 'section';
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
interface ItemOption extends CommonItemOptions {
|
|
16
|
+
value: unknown;
|
|
17
|
+
label: string;
|
|
18
|
+
type: 'option';
|
|
19
|
+
}
|
|
20
|
+
interface ItemCreatableOption extends CommonItemOptions {
|
|
21
|
+
label: string;
|
|
22
|
+
type: 'creatable';
|
|
23
|
+
}
|
|
24
|
+
type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions | ItemCreatableOption;
|
|
25
|
+
type SelectedOptionsT = ItemOption[] | ItemOption | null;
|
|
26
|
+
interface Props {
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
options: OptionTypes[];
|
|
29
|
+
selectedValues: SelectedOptionsT;
|
|
30
|
+
hasError?: boolean;
|
|
31
|
+
inline?: boolean;
|
|
32
|
+
autoFocus?: boolean;
|
|
33
|
+
innerRef: React.RefObject<HTMLInputElement>;
|
|
34
|
+
startPlacementPreference: string;
|
|
35
|
+
placementOrderPreference: string[];
|
|
36
|
+
withoutPortal?: boolean;
|
|
37
|
+
zIndex?: number;
|
|
38
|
+
inputMinWidth?: number;
|
|
39
|
+
menuMinWidth?: number;
|
|
40
|
+
menuMaxHeight?: number;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>, value: ItemOption | undefined) => void;
|
|
43
|
+
onChange: (value: ItemOption | null) => void;
|
|
44
|
+
onBlur: () => void;
|
|
45
|
+
onSelectAll: () => void;
|
|
46
|
+
onClearAll: () => void;
|
|
47
|
+
onFilter: (value: string) => void;
|
|
48
|
+
onCreate: (label: string) => void;
|
|
49
|
+
onMenuOpen?: () => void;
|
|
50
|
+
onCancel?: () => void;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export declare const ComboboxPropTypes: any;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { useVirtual } from 'react-virtual';
|
|
3
|
+
import { DSComboboxT } from './react-desc-prop-types';
|
|
4
|
+
export declare namespace DSComboboxInternalsT {
|
|
5
|
+
interface ComboBoxContextT {
|
|
6
|
+
props: DSComboboxT.Props;
|
|
7
|
+
virtualListHelpers?: ReturnType<typeof useVirtual>;
|
|
8
|
+
showPopover: boolean;
|
|
9
|
+
setShowPopover: React.Dispatch<React.SetStateAction<boolean>>;
|
|
10
|
+
referenceElement: HTMLElement | null;
|
|
11
|
+
setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
|
12
|
+
hasFocus: boolean;
|
|
13
|
+
pillGroupRef: React.RefObject<HTMLDivElement>;
|
|
14
|
+
scrollOptionIntoView: (dsId: string) => void;
|
|
15
|
+
setHasFocus: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
+
listRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
wrapperListRef: React.RefObject<HTMLDivElement>;
|
|
18
|
+
selectedOptionsRef: React.RefObject<HTMLDivElement>;
|
|
19
|
+
controlsWrapperRef: React.RefObject<HTMLDivElement>;
|
|
20
|
+
selectAllCheckboxRef: React.RefObject<HTMLInputElement>;
|
|
21
|
+
toggleSelectionButtonRef: React.RefObject<HTMLButtonElement>;
|
|
22
|
+
showSelectedValue: boolean;
|
|
23
|
+
setShowSelectedValue: React.Dispatch<React.SetStateAction<boolean>>;
|
|
24
|
+
focusOptionIdx: string;
|
|
25
|
+
setCurrentOption: React.Dispatch<React.SetStateAction<string>>;
|
|
26
|
+
showSelectedOptions: boolean;
|
|
27
|
+
setShowSelectedOptions: React.Dispatch<React.SetStateAction<boolean>>;
|
|
28
|
+
}
|
|
29
|
+
}
|