@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.
Files changed (199) hide show
  1. package/cjs/autocomplete/Autocomplete.js +4 -5
  2. package/cjs/autocomplete/AutocompleteCTX.js +3 -14
  3. package/cjs/autocomplete/AutocompleteDataTestids.js +1 -7
  4. package/cjs/autocomplete/config/useAutocomplete.js +23 -10
  5. package/cjs/autocomplete/parts/container/Container.js +36 -20
  6. package/cjs/autocomplete/parts/container/styled.js +1 -5
  7. package/cjs/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
  8. package/cjs/autocomplete/parts/menu-list/MenuList.js +17 -50
  9. package/cjs/autocomplete/parts/menu-list/styled.js +9 -10
  10. package/cjs/autocomplete/parts/menu-list/useItemRenderer.js +38 -44
  11. package/cjs/autocomplete/react-desc-prop-types.js +4 -8
  12. package/cjs/autocomplete/utils/listHelper.js +8 -16
  13. package/cjs/checkbox/react-desc-prop-types.js +1 -0
  14. package/cjs/combobox/ComboBox.js +1 -0
  15. package/cjs/combobox/config/useComboBox.js +8 -2
  16. package/cjs/combobox/config/useCorrectOptions.js +14 -42
  17. package/cjs/combobox/index.js +1 -0
  18. package/cjs/combobox/parts/A11yFocusedOption.js +3 -3
  19. package/cjs/combobox/parts/controls/Controls.js +4 -2
  20. package/cjs/combobox/parts/controls-input/ControlsInput.js +2 -0
  21. package/cjs/combobox/parts/controls-input/styled.js +1 -1
  22. package/cjs/combobox/parts/controls-input/useControlsInput.js +6 -6
  23. package/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
  24. package/cjs/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
  25. package/cjs/combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -4
  26. package/cjs/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
  27. package/cjs/combobox/parts/menu-list/MenuList.js +13 -7
  28. package/cjs/combobox/parts/menu-list/styled.js +16 -5
  29. package/cjs/combobox/parts/menu-list/useItemRenderer.js +8 -8
  30. package/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
  31. package/cjs/combobox/react-desc-prop-types.js +2 -1
  32. package/cjs/combobox/utils/listHelper.js +40 -11
  33. package/cjs/index.js +20 -3
  34. package/cjs/large-text-input/DSControlledLargeTextInput.js +83 -0
  35. package/cjs/large-text-input/exported-related/data-test-ids.js +11 -0
  36. package/cjs/large-text-input/exported-related/index.js +12 -0
  37. package/cjs/large-text-input/exported-related/theming.js +13 -0
  38. package/cjs/large-text-input/index.js +15 -0
  39. package/cjs/large-text-input/react-desc-prop-types.js +45 -0
  40. package/cjs/large-text-input/styles.js +40 -0
  41. package/cjs/mask-hook/hooks/index.js +11 -3
  42. package/cjs/mask-hook/hooks/useNumberMask.js +7 -0
  43. package/cjs/mask-hook/hooks/usePhoneMask.js +7 -0
  44. package/cjs/mask-hook/hooks/useRegExpMask.js +122 -0
  45. package/cjs/mask-hook/hooks/useSSNMask.js +7 -0
  46. package/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +12 -5
  47. package/cjs/mask-hook/index.js +11 -3
  48. package/cjs/mask-hook/react-desc-prop-types.js +9 -0
  49. package/cjs/mask-hook/utils/addSpecialCharacters.js +3 -4
  50. package/cjs/mask-hook/utils/flatStringArray.js +18 -0
  51. package/cjs/mask-hook/utils/index.js +2 -0
  52. package/esm/autocomplete/Autocomplete.js +2 -3
  53. package/esm/autocomplete/AutocompleteCTX.js +3 -14
  54. package/esm/autocomplete/AutocompleteDataTestids.js +1 -7
  55. package/esm/autocomplete/config/useAutocomplete.js +27 -14
  56. package/esm/autocomplete/parts/container/Container.js +38 -23
  57. package/esm/autocomplete/parts/container/styled.js +2 -5
  58. package/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
  59. package/esm/autocomplete/parts/menu-list/MenuList.js +19 -52
  60. package/esm/autocomplete/parts/menu-list/styled.js +9 -10
  61. package/esm/autocomplete/parts/menu-list/useItemRenderer.js +39 -45
  62. package/esm/autocomplete/react-desc-prop-types.js +5 -8
  63. package/esm/autocomplete/utils/listHelper.js +8 -16
  64. package/esm/checkbox/react-desc-prop-types.js +1 -0
  65. package/esm/combobox/ComboBox.js +1 -1
  66. package/esm/combobox/config/useComboBox.js +8 -2
  67. package/esm/combobox/config/useCorrectOptions.js +15 -43
  68. package/esm/combobox/index.js +1 -1
  69. package/esm/combobox/parts/A11yFocusedOption.js +3 -3
  70. package/esm/combobox/parts/controls/Controls.js +4 -2
  71. package/esm/combobox/parts/controls-input/ControlsInput.js +2 -0
  72. package/esm/combobox/parts/controls-input/styled.js +1 -1
  73. package/esm/combobox/parts/controls-input/useControlsInput.js +6 -6
  74. package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
  75. package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
  76. package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  77. package/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
  78. package/esm/combobox/parts/menu-list/MenuList.js +13 -7
  79. package/esm/combobox/parts/menu-list/styled.js +16 -5
  80. package/esm/combobox/parts/menu-list/useItemRenderer.js +8 -8
  81. package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
  82. package/esm/combobox/react-desc-prop-types.js +2 -1
  83. package/esm/combobox/utils/listHelper.js +38 -12
  84. package/esm/index.js +9 -5
  85. package/esm/large-text-input/DSControlledLargeTextInput.js +72 -0
  86. package/esm/large-text-input/exported-related/data-test-ids.js +7 -0
  87. package/esm/large-text-input/exported-related/index.js +2 -0
  88. package/esm/large-text-input/exported-related/theming.js +8 -0
  89. package/esm/large-text-input/index.js +3 -0
  90. package/esm/large-text-input/react-desc-prop-types.js +36 -0
  91. package/esm/large-text-input/styles.js +30 -0
  92. package/esm/mask-hook/hooks/index.js +5 -4
  93. package/esm/mask-hook/hooks/useNumberMask.js +7 -1
  94. package/esm/mask-hook/hooks/usePhoneMask.js +7 -1
  95. package/esm/mask-hook/hooks/useRegExpMask.js +116 -0
  96. package/esm/mask-hook/hooks/useSSNMask.js +7 -1
  97. package/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +11 -5
  98. package/esm/mask-hook/index.js +5 -4
  99. package/esm/mask-hook/react-desc-prop-types.js +8 -1
  100. package/esm/mask-hook/utils/addSpecialCharacters.js +3 -4
  101. package/esm/mask-hook/utils/flatStringArray.js +14 -0
  102. package/esm/mask-hook/utils/index.js +1 -0
  103. package/package.json +60 -88
  104. package/types/autocomplete/Autocomplete.d.ts +4 -61
  105. package/types/autocomplete/AutocompleteCTX.d.ts +4 -3
  106. package/types/autocomplete/AutocompleteDataTestids.d.ts +1 -7
  107. package/types/autocomplete/config/useAutocomplete.d.ts +3 -2
  108. package/types/autocomplete/parts/container/Container.d.ts +1 -2
  109. package/types/autocomplete/parts/container/styled.d.ts +0 -1
  110. package/types/autocomplete/parts/{controls → container}/useKeyboardNavigation.d.ts +0 -0
  111. package/types/autocomplete/parts/menu-list/MenuList.d.ts +1 -2
  112. package/types/autocomplete/parts/menu-list/styled.d.ts +1 -4
  113. package/types/autocomplete/parts/menu-list/useItemRenderer.d.ts +2 -3
  114. package/types/autocomplete/react-desc-prop-types.d.ts +8 -18
  115. package/types/autocomplete/sharedTypes.d.ts +1 -3
  116. package/types/autocomplete/tests/general.test.d.ts +1 -0
  117. package/types/autocomplete/tests/utils.d.ts +5 -0
  118. package/types/autocomplete/utils/listHelper.d.ts +2 -2
  119. package/types/checkbox/ControlledCheckbox.d.ts +1 -1
  120. package/types/checkbox/react-desc-prop-types.d.ts +366 -1
  121. package/types/combobox/ComboBox.d.ts +2 -2
  122. package/types/combobox/parts/dropdown-indicator/DropdownIndicator.d.ts +1 -0
  123. package/types/combobox/react-desc-prop-types.d.ts +381 -3
  124. package/types/combobox/utils/listHelper.d.ts +4 -1
  125. package/types/index.d.ts +1 -0
  126. package/types/large-text-input/DSControlledLargeTextInput.d.ts +5 -0
  127. package/types/large-text-input/exported-related/data-test-ids.d.ts +5 -0
  128. package/types/large-text-input/exported-related/index.d.ts +2 -0
  129. package/types/large-text-input/exported-related/theming.d.ts +6 -0
  130. package/types/large-text-input/index.d.ts +2 -0
  131. package/types/large-text-input/react-desc-prop-types.d.ts +447 -0
  132. package/types/large-text-input/styles.d.ts +3 -0
  133. package/types/large-text-input/tests/DSControlledLargeTextInput.test.d.ts +1 -0
  134. package/types/mask-hook/hooks/index.d.ts +2 -1
  135. package/types/mask-hook/hooks/useNumberMask.d.ts +2 -1
  136. package/types/mask-hook/hooks/usePhoneMask.d.ts +2 -1
  137. package/types/mask-hook/hooks/useRegExpMask.d.ts +4 -0
  138. package/types/mask-hook/hooks/useSSNMask.d.ts +2 -1
  139. package/types/mask-hook/hooks/useZipCodeMask.d.ts +4 -0
  140. package/types/mask-hook/react-desc-prop-types.d.ts +6 -1
  141. package/types/mask-hook/tests/useRegExpMask.test.d.ts +1 -0
  142. package/types/mask-hook/utils/flatStringArray.d.ts +1 -0
  143. package/types/mask-hook/utils/index.d.ts +1 -0
  144. package/types/text-input/DSInputText.d.ts +1 -1
  145. package/types/text-input/config/useInputText.d.ts +110 -110
  146. package/cjs/autocomplete/config/constants.js +0 -14
  147. package/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -11
  148. package/cjs/autocomplete/index.d.js +0 -2
  149. package/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -33
  150. package/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -28
  151. package/cjs/autocomplete/parts/a11y-messages/index.js +0 -11
  152. package/cjs/autocomplete/parts/a11y-messages/styled.js +0 -15
  153. package/cjs/autocomplete/parts/controls/Controls.js +0 -63
  154. package/cjs/autocomplete/parts/controls/index.js +0 -9
  155. package/cjs/autocomplete/parts/controls/styled.js +0 -44
  156. package/cjs/autocomplete/parts/controls/useControlsInput.js +0 -44
  157. package/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -28
  158. package/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -69
  159. package/cjs/autocomplete/propTypes.js +0 -25
  160. package/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -97
  161. package/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -37
  162. package/cjs/text-input/exported-related/name.js +0 -7
  163. package/cjs/text-input/exported-related/slots.js +0 -11
  164. package/esm/autocomplete/config/constants.js +0 -10
  165. package/esm/autocomplete/config/useGetPropsWithDefault.js +0 -7
  166. package/esm/autocomplete/index.d.js +0 -1
  167. package/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -25
  168. package/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -20
  169. package/esm/autocomplete/parts/a11y-messages/index.js +0 -2
  170. package/esm/autocomplete/parts/a11y-messages/styled.js +0 -7
  171. package/esm/autocomplete/parts/controls/Controls.js +0 -55
  172. package/esm/autocomplete/parts/controls/index.js +0 -1
  173. package/esm/autocomplete/parts/controls/styled.js +0 -32
  174. package/esm/autocomplete/parts/controls/useControlsInput.js +0 -40
  175. package/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -24
  176. package/esm/autocomplete/parts/menu-list/useMenuList.js +0 -65
  177. package/esm/autocomplete/propTypes.js +0 -21
  178. package/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -93
  179. package/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -33
  180. package/esm/text-input/exported-related/name.js +0 -3
  181. package/esm/text-input/exported-related/slots.js +0 -7
  182. package/types/autocomplete/config/constants.d.ts +0 -8
  183. package/types/autocomplete/config/useGetPropsWithDefault.d.ts +0 -2
  184. package/types/autocomplete/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
  185. package/types/autocomplete/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
  186. package/types/autocomplete/parts/a11y-messages/index.d.ts +0 -2
  187. package/types/autocomplete/parts/a11y-messages/styled.d.ts +0 -1
  188. package/types/autocomplete/parts/controls/Controls.d.ts +0 -3
  189. package/types/autocomplete/parts/controls/index.d.ts +0 -1
  190. package/types/autocomplete/parts/controls/styled.d.ts +0 -8
  191. package/types/autocomplete/parts/controls/useControlsInput.d.ts +0 -9
  192. package/types/autocomplete/parts/controls/useMaskedOnChange.d.ts +0 -2
  193. package/types/autocomplete/parts/menu-list/useMenuList.d.ts +0 -2
  194. package/types/autocomplete/propTypes.d.ts +0 -51
  195. package/types/autocomplete/utils/hooks/useKeyboardNavigation.d.ts +0 -4
  196. package/types/autocomplete/utils/hooks/useOnElementResize.d.ts +0 -3
  197. package/types/mask-hook/hooks/useZipCode.d.ts +0 -3
  198. package/types/text-input/exported-related/name.d.ts +0 -1
  199. 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, useMemo, useCallback } from 'react';
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 { useMenuList } from './useMenuList.js';
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
- menuMinWidth,
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__*/jsx(StyledListWrapper, {
28
+ return /*#__PURE__*/_jsx(StyledListWrapper, {
46
29
  tabIndex: -1,
47
- ref: wrapperListRef,
48
30
  onMouseDown: e => e.preventDefault(),
49
- minWidth: listWidth,
50
- id: "combo-listbox",
51
- role: "listbox",
52
- children: isLoading && ((_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.value) !== '' ? /*#__PURE__*/_jsx(Grid, {
53
- justifyContent: "center",
54
- alignItems: "center",
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
- padding: 20
43
+ height: totalSize,
44
+ margin: '8px 0px'
57
45
  }
58
- }, void 0, /*#__PURE__*/_jsx(DSCircularProgressIndicator, {
59
- size: "l",
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:", ";"], props => props.inline ? '100%' : "".concat(props.minWidth, "px"));
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;margin-top:", ";max-height:", ";"], _ref => {
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 inline ? '' : "".concat(!maxHeight ? '400' : maxHeight, "px");
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
- onChange,
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
- var _inputRef$current;
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
- }, [onFilter, onChange, setShowPopover, inputRef]);
47
- const handleOnMouseDown = useCallback(e => {
48
- e.preventDefault();
49
- }, []);
50
- const ItemRenderer = useMemo(() => virtualItems.map(vItem => {
51
- const option = options[vItem.index];
52
- const generalProps = {
53
- wrapperStyles: {
54
- position: 'absolute',
55
- top: vItem.start,
56
- left: 0,
57
- width: '100%'
58
- },
59
- key: "".concat(option.dsId),
60
- innerRef: vItem.measureRef
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
- if (option.type === 'option') {
64
- return /*#__PURE__*/jsx(SingleMenuItem, _objectSpread(_objectSpread({}, generalProps), {}, {
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 /*#__PURE__*/jsx(Fragment, {});
77
- }), [options, focusOptionIdx, selectedValues, inputRef, virtualItems]);
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
- placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),
7
- options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),
8
- value: PropTypes.oneOfType([PropTypes.string]).description('Array of option or single option selected'),
9
- autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
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 { noop, propTypes };
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, isSelected, isSelectedValueEmpty, isSelectedValueMultiple };
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
  });
@@ -18,4 +18,4 @@ const DSComboBox = props => {
18
18
  const DSComboBoxWithSchema = describe(DSComboBox);
19
19
  DSComboBoxWithSchema.propTypes = ComboboxPropTypes;
20
20
 
21
- export { DSComboBox, DSComboBoxWithSchema };
21
+ export { DSComboBox, DSComboBox as DSComboBoxV3, DSComboBoxWithSchema };
@@ -38,7 +38,7 @@ const useComboBox = props => {
38
38
  const {
39
39
  selectedValues
40
40
  } = propsWithDefaults; // ---------------------------------------------------------------------------
41
- // Menu Options with/out selected filter and creatable functionality
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
- options: correctOptions
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 { useCallback, useMemo } from 'react';
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
- options,
9
+ filteredOptions,
10
+ allOptions,
14
11
  selectedValues,
15
12
  onCreate
16
13
  } = propsWithDefaults;
17
- const selectedValuesWithSections = useCallback(() => {
18
- var _items2;
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 && options.findIndex(option => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) === -1) {
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, ...options];
31
+ return [creatableItem, ...filteredOptions];
59
32
  }
60
33
 
61
- return options;
62
- }, [options, onCreate, inputValue, selectedValuesWithSections, selectedValues, showSelectedOptions]);
63
- return correctOptions;
34
+ return filteredOptions;
35
+ }, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);
64
36
  };
65
37
 
66
38
  export { useCorrectOptions };
@@ -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
- options
14
+ filteredOptions
15
15
  },
16
16
  focusOptionIdx,
17
17
  showPopover
18
18
  } = useContext(ComboBoxContext);
19
- const selectabledOptions = getSelectableOptions(options);
20
- const focusOption = options.find(option => !isSeparator(option) && option.dsId === focusOptionIdx);
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, setShowPopover, showPopover, innerRef, inline]); // this callback prevent to toggle the menu when clicking or removing pills
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, _spanReference$curren2;
27
+ var _spanReference$curren;
27
28
 
28
- setWidth((_spanReference$curren = spanReference.current) !== null && _spanReference$curren !== void 0 && _spanReference$curren.offsetWidth ? ((_spanReference$curren2 = spanReference.current) === null || _spanReference$curren2 === void 0 ? void 0 : _spanReference$curren2.offsetWidth) + 2 : 1);
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
- setShowSelectedOptions(false);
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]);