@elliemae/ds-controlled-form 2.4.1-rc.2 → 2.4.1-rc.6
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
|
@@ -1,83 +1,50 @@
|
|
|
1
1
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
-
import { useContext,
|
|
3
|
-
import { DSCircularProgressIndicator } from '@elliemae/ds-circular-progress-indicator';
|
|
4
|
-
import { Grid } from '@elliemae/ds-grid';
|
|
2
|
+
import { useContext, useCallback } from 'react';
|
|
5
3
|
import { StyledListWrapper, StyledVirtualListWrapper, StyledList } from './styled.js';
|
|
6
4
|
import { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';
|
|
7
5
|
import { AutocompleteContext } from '../../AutocompleteCTX.js';
|
|
8
|
-
import { useOnElementResize } from '../../utils/hooks/useOnElementResize.js';
|
|
9
6
|
import { useItemRenderer } from './useItemRenderer.js';
|
|
10
|
-
import {
|
|
11
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
12
8
|
|
|
13
9
|
const MenuList = () => {
|
|
14
|
-
var _inputRef$current2;
|
|
15
|
-
|
|
16
10
|
const {
|
|
17
11
|
props: {
|
|
18
|
-
|
|
19
|
-
menuMaxHeight,
|
|
20
|
-
options,
|
|
21
|
-
isLoading
|
|
12
|
+
options
|
|
22
13
|
},
|
|
23
14
|
referenceElement,
|
|
24
15
|
inputRef,
|
|
25
16
|
listRef,
|
|
26
17
|
showPopover,
|
|
27
|
-
wrapperListRef,
|
|
28
|
-
controlsWrapperRef,
|
|
29
18
|
virtualListHelpers: {
|
|
30
19
|
totalSize
|
|
31
20
|
}
|
|
32
21
|
} = useContext(AutocompleteContext);
|
|
33
22
|
const ItemRenderer = useItemRenderer();
|
|
34
|
-
useMenuList();
|
|
35
|
-
const {
|
|
36
|
-
width
|
|
37
|
-
} = useOnElementResize(controlsWrapperRef);
|
|
38
|
-
const listWidth = useMemo(() => menuMinWidth || "".concat(referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetWidth), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
[menuMinWidth, referenceElement, width]);
|
|
40
23
|
const handleOnFocus = useCallback(() => {
|
|
41
24
|
var _inputRef$current;
|
|
42
25
|
|
|
43
26
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
44
27
|
}, [inputRef]);
|
|
45
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/_jsx(StyledListWrapper, {
|
|
46
29
|
tabIndex: -1,
|
|
47
|
-
ref: wrapperListRef,
|
|
48
30
|
onMouseDown: e => e.preventDefault(),
|
|
49
|
-
minWidth:
|
|
50
|
-
id: "
|
|
51
|
-
role: "listbox"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
minWidth: referenceElement === null || referenceElement === void 0 ? void 0 : referenceElement.offsetWidth,
|
|
32
|
+
id: "autocomplete-listbox",
|
|
33
|
+
role: "listbox"
|
|
34
|
+
}, void 0, options.length > 0 && /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
35
|
+
tabIndex: -1,
|
|
36
|
+
ref: listRef,
|
|
37
|
+
children: /*#__PURE__*/_jsx(StyledList, {
|
|
38
|
+
tabIndex: -1,
|
|
39
|
+
"aria-expanded": showPopover,
|
|
40
|
+
onFocus: handleOnFocus,
|
|
41
|
+
"data-testid": AutocompleteDataTestid.LIST,
|
|
55
42
|
style: {
|
|
56
|
-
|
|
43
|
+
height: totalSize,
|
|
44
|
+
margin: '8px 0px'
|
|
57
45
|
}
|
|
58
|
-
}, void 0,
|
|
59
|
-
|
|
60
|
-
loading: isLoading,
|
|
61
|
-
waiting: false,
|
|
62
|
-
showTooltip: false
|
|
63
|
-
})) : /*#__PURE__*/jsx(Fragment, {
|
|
64
|
-
children: options.length > 0 && /*#__PURE__*/jsx(StyledVirtualListWrapper, {
|
|
65
|
-
tabIndex: -1,
|
|
66
|
-
maxHeight: menuMaxHeight,
|
|
67
|
-
ref: listRef,
|
|
68
|
-
children: /*#__PURE__*/_jsx(StyledList, {
|
|
69
|
-
tabIndex: -1,
|
|
70
|
-
"aria-expanded": showPopover,
|
|
71
|
-
onFocus: handleOnFocus,
|
|
72
|
-
"data-testid": AutocompleteDataTestid.LIST,
|
|
73
|
-
style: {
|
|
74
|
-
height: totalSize,
|
|
75
|
-
margin: '8px 0px'
|
|
76
|
-
}
|
|
77
|
-
}, void 0, ItemRenderer)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
});
|
|
46
|
+
}, void 0, ItemRenderer)
|
|
47
|
+
}));
|
|
81
48
|
};
|
|
82
49
|
|
|
83
50
|
export { MenuList };
|
|
@@ -2,23 +2,22 @@ import styled from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
const StyledListWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
4
4
|
componentId: "sc-qt1kwv-0"
|
|
5
|
-
})(["min-width:", ";"],
|
|
5
|
+
})(["min-width:", ";"], _ref => {
|
|
6
|
+
let {
|
|
7
|
+
minWidth
|
|
8
|
+
} = _ref;
|
|
9
|
+
return minWidth ? "".concat(minWidth, "px") : '100%';
|
|
10
|
+
});
|
|
6
11
|
const StyledList = /*#__PURE__*/styled.ul.withConfig({
|
|
7
12
|
componentId: "sc-qt1kwv-1"
|
|
8
13
|
})(["position:relative;padding:0;"]);
|
|
9
14
|
const StyledVirtualListWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
10
15
|
componentId: "sc-qt1kwv-2"
|
|
11
|
-
})(["overflow-y:auto;
|
|
12
|
-
let {
|
|
13
|
-
withHeader
|
|
14
|
-
} = _ref;
|
|
15
|
-
return withHeader ? '28px' : '';
|
|
16
|
-
}, _ref2 => {
|
|
16
|
+
})(["overflow-y:auto;max-height:", ";"], _ref2 => {
|
|
17
17
|
let {
|
|
18
|
-
maxHeight
|
|
19
|
-
inline
|
|
18
|
+
maxHeight
|
|
20
19
|
} = _ref2;
|
|
21
|
-
return
|
|
20
|
+
return "".concat(!maxHeight ? '400' : maxHeight, "px");
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
export { StyledList, StyledListWrapper, StyledVirtualListWrapper };
|
|
@@ -7,75 +7,69 @@ import 'core-js/modules/esnext.iterator.filter.js';
|
|
|
7
7
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
8
8
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
9
9
|
import { useContext, useCallback, useMemo } from 'react';
|
|
10
|
-
import { SingleMenuItem } from '@elliemae/ds-form';
|
|
10
|
+
import { Section, SingleMenuItem } from '@elliemae/ds-form';
|
|
11
11
|
import { AutocompleteContext } from '../../AutocompleteCTX.js';
|
|
12
|
-
import { isSelected } from '../../utils/listHelper.js';
|
|
13
12
|
import { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';
|
|
14
13
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
15
14
|
|
|
16
15
|
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; }
|
|
17
16
|
|
|
18
17
|
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; }
|
|
19
|
-
|
|
20
18
|
const useItemRenderer = () => {
|
|
21
19
|
const {
|
|
22
20
|
props: {
|
|
23
21
|
options,
|
|
24
|
-
|
|
25
|
-
selectedValues,
|
|
26
|
-
onFilter
|
|
22
|
+
onSelect
|
|
27
23
|
},
|
|
28
24
|
inputRef,
|
|
29
25
|
setShowPopover,
|
|
30
26
|
focusOptionIdx,
|
|
31
27
|
virtualListHelpers
|
|
32
28
|
} = useContext(AutocompleteContext);
|
|
33
|
-
const {
|
|
34
|
-
virtualItems
|
|
35
|
-
} = virtualListHelpers;
|
|
36
29
|
const handleClick = useCallback((option, e) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (inputRef.current) inputRef.current.value = option.label;
|
|
40
|
-
onFilter(option.label);
|
|
41
|
-
onChange(option.label);
|
|
30
|
+
onSelect(option.label, e);
|
|
42
31
|
setShowPopover(false);
|
|
43
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
44
32
|
e.stopPropagation();
|
|
45
33
|
e.preventDefault();
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
}, [onSelect, setShowPopover]);
|
|
35
|
+
return useMemo(() => {
|
|
36
|
+
if (virtualListHelpers) {
|
|
37
|
+
return virtualListHelpers.virtualItems.map(vItem => {
|
|
38
|
+
const option = options[vItem.index];
|
|
39
|
+
const generalProps = {
|
|
40
|
+
wrapperStyles: {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: vItem.start,
|
|
43
|
+
left: 0,
|
|
44
|
+
width: '100%'
|
|
45
|
+
},
|
|
46
|
+
key: "".concat(option.dsId),
|
|
47
|
+
innerRef: vItem.measureRef
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (option.type === 'section') {
|
|
51
|
+
return /*#__PURE__*/jsx(Section, _objectSpread({
|
|
52
|
+
label: option.label
|
|
53
|
+
}, generalProps));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (option.type === 'option') {
|
|
57
|
+
return /*#__PURE__*/jsx(SingleMenuItem, _objectSpread(_objectSpread({}, generalProps), {}, {
|
|
58
|
+
value: option.value,
|
|
59
|
+
label: option.label,
|
|
60
|
+
dataTestid: AutocompleteDataTestid.OPTION,
|
|
61
|
+
disabled: option.disabled,
|
|
62
|
+
onClick: e => handleClick(option, e),
|
|
63
|
+
isActive: option.dsId === focusOptionIdx
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
value: option.value,
|
|
66
|
-
label: option.label,
|
|
67
|
-
dataTestid: AutocompleteDataTestid.OPTION,
|
|
68
|
-
disabled: option.disabled,
|
|
69
|
-
onClick: e => handleClick(option, e),
|
|
70
|
-
onMouseDown: handleOnMouseDown,
|
|
71
|
-
isActive: option.dsId === focusOptionIdx,
|
|
72
|
-
isSelected: isSelected(selectedValues, option)
|
|
73
|
-
}));
|
|
67
|
+
return /*#__PURE__*/jsx(Fragment, {});
|
|
68
|
+
});
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
return ItemRenderer;
|
|
71
|
+
return null;
|
|
72
|
+
}, [options, focusOptionIdx, inputRef, virtualListHelpers]);
|
|
79
73
|
};
|
|
80
74
|
|
|
81
75
|
export { useItemRenderer };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { PropTypes } from '@elliemae/ds-props-helpers';
|
|
2
2
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
function noop() {}
|
|
5
4
|
const propTypes = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
|
|
11
|
-
onChange: PropTypes.func.description('function triggered when an option is selected it will send the options selected').defaultValue('')
|
|
5
|
+
options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired.description('List of options').defaultValue([]),
|
|
6
|
+
filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),
|
|
7
|
+
onSelect: PropTypes.func.isRequired.description('function triggered when an option is selected it will send the options selected').defaultValue(''),
|
|
8
|
+
children: PropTypes.node.isRequired.description('React component to apply autocomplete functionality').defaultValue('')
|
|
12
9
|
};
|
|
13
10
|
|
|
14
|
-
export {
|
|
11
|
+
export { propTypes };
|
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
2
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
3
|
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.some.js';
|
|
6
4
|
|
|
7
5
|
const getSelectableOptions = options => options ? options.filter(option => option.type === 'option' && !option.disabled) : [];
|
|
8
6
|
const getOptions = options => options ? options.filter(option => option.type === 'option') : [];
|
|
9
7
|
const isSelectedValueEmpty = value => Array.isArray(value) ? value.length === 0 : !value;
|
|
10
8
|
const isSelectedValueMultiple = value => Array.isArray(value);
|
|
11
|
-
const isSelected = (value, activeOption) => {
|
|
12
|
-
if (isSelectedValueMultiple(value)) {
|
|
13
|
-
const multiValue = value;
|
|
14
|
-
return multiValue.some(item => (item === null || item === void 0 ? void 0 : item.value) === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.value));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof value === 'string') {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const singleValue = value;
|
|
22
|
-
return (singleValue === null || singleValue === void 0 ? void 0 : singleValue.value) === activeOption.value;
|
|
23
|
-
};
|
|
24
9
|
const findInCircularList = function (list, from, criteria) {
|
|
25
10
|
let step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
26
11
|
|
|
@@ -30,5 +15,12 @@ const findInCircularList = function (list, from, criteria) {
|
|
|
30
15
|
|
|
31
16
|
return from; // return same item
|
|
32
17
|
};
|
|
18
|
+
const getFirstOption = options => {
|
|
19
|
+
for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type)) {
|
|
20
|
+
return options[i].dsId;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return '';
|
|
24
|
+
};
|
|
33
25
|
|
|
34
|
-
export { findInCircularList, getOptions, getSelectableOptions,
|
|
26
|
+
export { findInCircularList, getFirstOption, getOptions, getSelectableOptions, isSelectedValueEmpty, isSelectedValueMultiple };
|
|
@@ -17,6 +17,7 @@ const defaultProps = {
|
|
|
17
17
|
};
|
|
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
|
+
wrapLabel: PropTypes.bool.description('Whether to wrap or truncate label'),
|
|
20
21
|
hasError: PropTypes.bool.description('Whether the checkbox has error or not.'),
|
|
21
22
|
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).description('Checkbox input ref.')
|
|
22
23
|
});
|
package/esm/combobox/ComboBox.js
CHANGED
|
@@ -38,7 +38,7 @@ const useComboBox = props => {
|
|
|
38
38
|
const {
|
|
39
39
|
selectedValues
|
|
40
40
|
} = propsWithDefaults; // ---------------------------------------------------------------------------
|
|
41
|
-
//
|
|
41
|
+
// Options with creatable option + filtered by selected
|
|
42
42
|
// ---------------------------------------------------------------------------
|
|
43
43
|
|
|
44
44
|
const correctOptions = useCorrectOptions(propsWithDefaults, inputValue, showSelectedOptions); // ===========================================================================
|
|
@@ -78,9 +78,15 @@ const useComboBox = props => {
|
|
|
78
78
|
|
|
79
79
|
if (!hasFocus) setFocusOptionIdx(''); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
80
|
}, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!showPopover) {
|
|
83
|
+
setFocusOptionIdx('');
|
|
84
|
+
setShowSelectedOptions(false);
|
|
85
|
+
}
|
|
86
|
+
}, [showPopover]);
|
|
81
87
|
const ctx = useMemo(() => ({
|
|
82
88
|
props: _objectSpread(_objectSpread({}, propsWithDefaults), {}, {
|
|
83
|
-
|
|
89
|
+
filteredOptions: correctOptions
|
|
84
90
|
}),
|
|
85
91
|
virtualListHelpers,
|
|
86
92
|
showPopover,
|
|
@@ -1,66 +1,38 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.find.js';
|
|
6
1
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
8
3
|
import { uid } from 'uid';
|
|
9
4
|
import { MENU_OPTION_TYPES } from '../constants.js';
|
|
5
|
+
import { selectedValuesWithSections } from '../utils/listHelper.js';
|
|
10
6
|
|
|
11
7
|
const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
|
|
12
8
|
const {
|
|
13
|
-
|
|
9
|
+
filteredOptions,
|
|
10
|
+
allOptions,
|
|
14
11
|
selectedValues,
|
|
15
12
|
onCreate
|
|
16
13
|
} = propsWithDefaults;
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
// if filteredOptions is not passed we copy allOptions into the prop as default
|
|
16
|
+
// this is useful when the user wants a combo with out filtering and only pass allOptions as its required
|
|
17
|
+
if (!filteredOptions) return [...allOptions]; // when show selected toggle is on we return the selected value only as filteredOptions prop
|
|
19
18
|
|
|
20
|
-
const multiSelectedValue = selectedValues;
|
|
21
|
-
const items = [];
|
|
22
|
-
options.forEach(option => {
|
|
23
|
-
const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
|
|
24
|
-
|
|
25
|
-
if (isSelectedValue) {
|
|
26
|
-
items.push(option);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (option.type === MENU_OPTION_TYPES.SECTION) {
|
|
30
|
-
var _items;
|
|
31
|
-
|
|
32
|
-
if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === MENU_OPTION_TYPES.SECTION) {
|
|
33
|
-
items[items.length - 1] = option;
|
|
34
|
-
} else {
|
|
35
|
-
items.push(option);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === MENU_OPTION_TYPES.SECTION) {
|
|
41
|
-
items.pop();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return items;
|
|
45
|
-
}, [options, selectedValues]);
|
|
46
|
-
const correctOptions = useMemo(() => {
|
|
47
19
|
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
48
|
-
return selectedValuesWithSections();
|
|
49
|
-
}
|
|
20
|
+
return selectedValuesWithSections(filteredOptions, selectedValues);
|
|
21
|
+
} // whether oncreate is passed we add as first option the creatable action based on input value string
|
|
22
|
+
|
|
50
23
|
|
|
51
|
-
if (onCreate && inputValue &&
|
|
24
|
+
if (onCreate && inputValue && filteredOptions.findIndex(option => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) === -1) {
|
|
52
25
|
const creatableUuid = uid();
|
|
53
26
|
const creatableItem = {
|
|
54
27
|
dsId: "creatable-".concat(creatableUuid),
|
|
55
28
|
label: inputValue,
|
|
56
29
|
type: 'creatable'
|
|
57
30
|
};
|
|
58
|
-
return [creatableItem, ...
|
|
31
|
+
return [creatableItem, ...filteredOptions];
|
|
59
32
|
}
|
|
60
33
|
|
|
61
|
-
return
|
|
62
|
-
}, [
|
|
63
|
-
return correctOptions;
|
|
34
|
+
return filteredOptions;
|
|
35
|
+
}, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);
|
|
64
36
|
};
|
|
65
37
|
|
|
66
38
|
export { useCorrectOptions };
|
package/esm/combobox/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DSComboBox, DSComboBoxWithSchema } from './ComboBox.js';
|
|
1
|
+
export { DSComboBox, DSComboBox as DSComboBoxV3, DSComboBoxWithSchema } from './ComboBox.js';
|
|
@@ -11,13 +11,13 @@ import { isSeparator } from '../sharedTypes.js';
|
|
|
11
11
|
const A11yFocusedOption = () => {
|
|
12
12
|
const {
|
|
13
13
|
props: {
|
|
14
|
-
|
|
14
|
+
filteredOptions
|
|
15
15
|
},
|
|
16
16
|
focusOptionIdx,
|
|
17
17
|
showPopover
|
|
18
18
|
} = useContext(ComboBoxContext);
|
|
19
|
-
const selectabledOptions = getSelectableOptions(
|
|
20
|
-
const focusOption =
|
|
19
|
+
const selectabledOptions = getSelectableOptions(filteredOptions);
|
|
20
|
+
const focusOption = filteredOptions.find(option => !isSeparator(option) && option.dsId === focusOptionIdx);
|
|
21
21
|
const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
|
|
22
22
|
return useMemo(() => {
|
|
23
23
|
if (!isSeparator(focusOption) && showPopover && focusOption) return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
|
|
@@ -26,6 +26,8 @@ const Controls = () => {
|
|
|
26
26
|
selectedOptionsRef,
|
|
27
27
|
setShowPopover,
|
|
28
28
|
hasFocus,
|
|
29
|
+
focusOptionIdx,
|
|
30
|
+
scrollOptionIntoView,
|
|
29
31
|
showPopover,
|
|
30
32
|
controlsWrapperRef
|
|
31
33
|
} = useContext(ComboBoxContext);
|
|
@@ -43,8 +45,8 @@ const Controls = () => {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
(_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
|
|
46
|
-
setShowPopover(true);
|
|
47
|
-
}, [disabled, hasFocus,
|
|
48
|
+
setShowPopover(true); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
}, [disabled, hasFocus, showPopover, inline, innerRef, setShowPopover, focusOptionIdx]); // this callback prevent to toggle the menu when clicking or removing pills
|
|
48
50
|
|
|
49
51
|
const handleOnPillsClick = useCallback(e => {
|
|
50
52
|
if (showPopover || disabled) {
|
|
@@ -12,6 +12,7 @@ const ControlsInput = () => {
|
|
|
12
12
|
const {
|
|
13
13
|
props: {
|
|
14
14
|
autoFocus,
|
|
15
|
+
placeholder,
|
|
15
16
|
disabled,
|
|
16
17
|
innerRef,
|
|
17
18
|
onFilter
|
|
@@ -40,6 +41,7 @@ const ControlsInput = () => {
|
|
|
40
41
|
})), /*#__PURE__*/jsx(StyledInput, {
|
|
41
42
|
"data-testid": ComboboxDataTestid.INPUT,
|
|
42
43
|
autoFocus: autoFocus,
|
|
44
|
+
placeholder: placeholder,
|
|
43
45
|
"aria-controls": "combo-listbox",
|
|
44
46
|
"aria-activedescendant": focusOptionIdx,
|
|
45
47
|
"aria-expanded": showPopover,
|
|
@@ -2,7 +2,7 @@ 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;
|
|
5
|
-
const StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ", ";\n &:focus {\n outline: none;\n }\n ", "\n"])), props => props.theme.colors.neutral[700], _ref => {
|
|
5
|
+
const StyledInput = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ", ";\n &:focus {\n outline: none;\n }\n ", "\n &::placeholder {\n color: transparent;\n }\n"])), props => props.theme.colors.neutral[700], _ref => {
|
|
6
6
|
let {
|
|
7
7
|
withoutCaret
|
|
8
8
|
} = _ref;
|
|
@@ -9,6 +9,7 @@ const useControlsInput = () => {
|
|
|
9
9
|
const {
|
|
10
10
|
props: {
|
|
11
11
|
selectedValues,
|
|
12
|
+
allOptions,
|
|
12
13
|
placeholder,
|
|
13
14
|
onFilter
|
|
14
15
|
},
|
|
@@ -23,19 +24,18 @@ const useControlsInput = () => {
|
|
|
23
24
|
const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;
|
|
24
25
|
const spanReferenceText = inputValue.replace(/\s/g, '\u00a0');
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
var _spanReference$curren
|
|
27
|
+
var _spanReference$curren;
|
|
27
28
|
|
|
28
|
-
setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ?
|
|
29
|
+
setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);
|
|
29
30
|
}, [inputValue]); // if we se an input mask we configure inside here the proper mask
|
|
30
31
|
// or a stardard combobox onchange event
|
|
31
32
|
|
|
32
33
|
const handleOnChange = useMaskedOnChange();
|
|
33
34
|
const handleOnBlur = useCallback(() => {
|
|
34
35
|
setInputValue('');
|
|
35
|
-
if (onFilter) onFilter(
|
|
36
|
-
setHasFocus(false);
|
|
37
|
-
|
|
38
|
-
}, [setInputValue, setShowSelectedOptions, onFilter, setHasFocus]);
|
|
36
|
+
if (onFilter) onFilter(allOptions, inputValue);
|
|
37
|
+
setHasFocus(false); // setShowSelectedOptions(false);
|
|
38
|
+
}, [setInputValue, onFilter, allOptions, inputValue, setHasFocus, setShowSelectedOptions]);
|
|
39
39
|
const handleOnFocus = useCallback(() => {
|
|
40
40
|
setHasFocus(true);
|
|
41
41
|
}, [setHasFocus]);
|