@elliemae/ds-form 2.0.0-rc.1 → 2.0.0-rc.13

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 (173) hide show
  1. package/cjs/ComboBox/v1/DSComboBox.js +18 -22
  2. package/cjs/ComboBox/v1/withSelectStringValueConverter.js +3 -4
  3. package/cjs/ComboBox/v3/ComboBox.js +1 -2
  4. package/cjs/ComboBox/v3/ComboBoxCTX.js +22 -15
  5. package/cjs/ComboBox/v3/ComboboxDataTestids.js +3 -1
  6. package/cjs/ComboBox/v3/config/useComboBox.js +65 -21
  7. package/cjs/ComboBox/v3/parts/container/Container.js +28 -18
  8. package/cjs/ComboBox/v3/parts/controls/Controls.js +3 -1
  9. package/cjs/ComboBox/v3/parts/controls/styled.js +30 -8
  10. package/cjs/ComboBox/v3/parts/controls-input/ControlsInput.js +5 -3
  11. package/cjs/ComboBox/v3/parts/controls-input/styled.js +1 -1
  12. package/cjs/ComboBox/v3/parts/controls-input/useControlsInput.js +19 -21
  13. package/cjs/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +0 -3
  14. package/cjs/ComboBox/v3/parts/dropdown-indicator/styled.js +1 -1
  15. package/cjs/ComboBox/v3/parts/header-list/HeaderList.js +61 -37
  16. package/cjs/ComboBox/v3/parts/header-list/styled.js +31 -8
  17. package/cjs/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +73 -0
  18. package/cjs/ComboBox/v3/parts/menu-list/MenuList.js +32 -18
  19. package/cjs/ComboBox/v3/parts/menu-list/styled.js +17 -2
  20. package/cjs/ComboBox/v3/parts/menu-list/useItemRenderer.js +105 -0
  21. package/cjs/ComboBox/v3/parts/menu-list/useMenuList.js +42 -85
  22. package/cjs/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +26 -35
  23. package/cjs/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +10 -6
  24. package/cjs/ComboBox/v3/propTypes.js +15 -11
  25. package/cjs/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +28 -30
  26. package/cjs/ComboBox/v3/utils/hooks/useOnElementResize.js +4 -4
  27. package/cjs/FloatingLabelInput/FloatingLabelInputImpl.js +4 -7
  28. package/cjs/FormItem/ValidationFieldWrapper.js +2 -3
  29. package/cjs/Input/InputAddonWrapper.js +2 -3
  30. package/cjs/Input/InputImpl.js +16 -18
  31. package/cjs/InputGroup/AddonWrapper.js +4 -6
  32. package/cjs/InputMask/DSInputMaskDeprecated.js +10 -12
  33. package/cjs/MenuItem/components/MenuItem/index.js +1 -1
  34. package/cjs/MenuItem/components/MultiMenuItem/MultiMenuItem.js +1 -0
  35. package/cjs/MenuItem/components/Section/index.js +1 -1
  36. package/cjs/MenuItem/components/Section/styled.js +1 -1
  37. package/cjs/MenuItem/components/Separator/styled.js +2 -2
  38. package/cjs/MenuItem/components/SingleMenuItem/SingleMenuItem.js +6 -6
  39. package/cjs/MenuItem/components/SubmenuItem/index.js +1 -1
  40. package/cjs/MenuItem/components/styled.js +12 -4
  41. package/cjs/SearchBox/withSearchable.js +3 -5
  42. package/cjs/Toggle/DSToggleImpl.js +28 -28
  43. package/esm/ComboBox/v1/DSComboBox.js +17 -21
  44. package/esm/ComboBox/v1/withSelectStringValueConverter.js +3 -4
  45. package/esm/ComboBox/v3/ComboBox.js +1 -2
  46. package/esm/ComboBox/v3/ComboBoxCTX.js +17 -10
  47. package/esm/ComboBox/v3/ComboboxDataTestids.js +3 -1
  48. package/esm/ComboBox/v3/config/useComboBox.js +62 -22
  49. package/esm/ComboBox/v3/parts/container/Container.js +29 -19
  50. package/esm/ComboBox/v3/parts/controls/Controls.js +3 -1
  51. package/esm/ComboBox/v3/parts/controls/styled.js +30 -9
  52. package/esm/ComboBox/v3/parts/controls-input/ControlsInput.js +5 -3
  53. package/esm/ComboBox/v3/parts/controls-input/styled.js +1 -1
  54. package/esm/ComboBox/v3/parts/controls-input/useControlsInput.js +20 -22
  55. package/esm/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +0 -3
  56. package/esm/ComboBox/v3/parts/dropdown-indicator/styled.js +1 -1
  57. package/esm/ComboBox/v3/parts/header-list/HeaderList.js +63 -39
  58. package/esm/ComboBox/v3/parts/header-list/styled.js +28 -8
  59. package/esm/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +69 -0
  60. package/esm/ComboBox/v3/parts/menu-list/MenuList.js +35 -21
  61. package/esm/ComboBox/v3/parts/menu-list/styled.js +17 -3
  62. package/esm/ComboBox/v3/parts/menu-list/useItemRenderer.js +97 -0
  63. package/esm/ComboBox/v3/parts/menu-list/useMenuList.js +43 -82
  64. package/esm/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +26 -35
  65. package/esm/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +10 -6
  66. package/esm/ComboBox/v3/propTypes.js +15 -11
  67. package/esm/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +28 -30
  68. package/esm/ComboBox/v3/utils/hooks/useOnElementResize.js +4 -4
  69. package/esm/FloatingLabelInput/FloatingLabelInputImpl.js +4 -7
  70. package/esm/FormItem/ValidationFieldWrapper.js +2 -3
  71. package/esm/Input/InputAddonWrapper.js +2 -3
  72. package/esm/Input/InputImpl.js +15 -17
  73. package/esm/InputGroup/AddonWrapper.js +5 -7
  74. package/esm/InputMask/DSInputMaskDeprecated.js +10 -12
  75. package/esm/MenuItem/components/MenuItem/index.js +1 -1
  76. package/esm/MenuItem/components/MultiMenuItem/MultiMenuItem.js +1 -0
  77. package/esm/MenuItem/components/Section/index.js +1 -1
  78. package/esm/MenuItem/components/Section/styled.js +1 -1
  79. package/esm/MenuItem/components/Separator/styled.js +2 -2
  80. package/esm/MenuItem/components/SingleMenuItem/SingleMenuItem.js +6 -6
  81. package/esm/MenuItem/components/SubmenuItem/index.js +1 -1
  82. package/esm/MenuItem/components/styled.js +13 -6
  83. package/esm/SearchBox/withSearchable.js +2 -4
  84. package/esm/Toggle/DSToggleImpl.js +28 -28
  85. package/package.json +40 -27
  86. package/types/Checkbox/DSCheckbox.d.ts +78 -13
  87. package/types/Checkbox/elements/CheckMark.d.ts +1 -1
  88. package/types/Checkbox/props.d.ts +58 -12
  89. package/types/CheckboxGroup/DSCheckboxGroup.d.ts +51 -7
  90. package/types/CheckboxGroup/props.d.ts +37 -6
  91. package/types/ComboBox/v2/Combobox.d.ts +56 -1
  92. package/types/ComboBox/v3/ComboBox.d.ts +54 -12
  93. package/types/ComboBox/v3/ComboboxDataTestids.d.ts +2 -0
  94. package/types/ComboBox/v3/parts/a11y-messages/styled.d.ts +1 -1
  95. package/types/ComboBox/v3/parts/container/styled.d.ts +3 -3
  96. package/types/ComboBox/v3/parts/controls/styled.d.ts +5 -5
  97. package/types/ComboBox/v3/parts/controls-input/styled.d.ts +4 -4
  98. package/types/ComboBox/v3/parts/controls-input/useControlsInput.d.ts +3 -3
  99. package/types/ComboBox/v3/parts/dropdown-indicator/styled.d.ts +1 -60
  100. package/types/ComboBox/v3/parts/empty-state/styled.d.ts +2 -2
  101. package/types/ComboBox/v3/parts/header-list/styled.d.ts +7 -93
  102. package/types/ComboBox/v3/parts/header-list/useHeaderListHandlers.d.ts +12 -0
  103. package/types/ComboBox/v3/parts/menu-list/styled.d.ts +9 -3
  104. package/types/ComboBox/v3/parts/menu-list/useItemRenderer.d.ts +2 -0
  105. package/types/ComboBox/v3/parts/menu-list/useMenuList.d.ts +1 -1
  106. package/types/ComboBox/v3/parts/multi-selected-values-container/styled.d.ts +3 -3
  107. package/types/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.d.ts +1 -2
  108. package/types/ComboBox/v3/parts/single-selected-value-container/styled.d.ts +1 -1
  109. package/types/ComboBox/v3/propTypes.d.ts +49 -11
  110. package/types/ComboBox/v3/tests/combobox-special-keys.test.d.ts +1 -0
  111. package/types/ComboBox/v3/tests/utils.d.ts +5 -0
  112. package/types/ComboBox/v3/utils/hooks/useKeyboardNavigation.d.ts +4 -1
  113. package/types/ComboBox/v3/utils/listHelper.d.ts +1 -1
  114. package/types/DateInput/DSDateInput.d.ts +97 -16
  115. package/types/DateInput/props.d.ts +97 -16
  116. package/types/DateInputV2/components/DSDateInput.d.ts +72 -5
  117. package/types/DateInputV2/components/props.d.ts +61 -10
  118. package/types/DateInputV2/components/styled.d.ts +4 -4
  119. package/types/FloatingLabelInput/DSFloatingLabelInput.d.ts +118 -20
  120. package/types/FormItem/DSFormItemLayout.d.ts +390 -60
  121. package/types/FormItem/Error/DSError.d.ts +21 -3
  122. package/types/FormItem/Suffix/Suffix.d.ts +3 -3
  123. package/types/FormItem/defaultProps.d.ts +118 -20
  124. package/types/FormItem/props.d.ts +229 -39
  125. package/types/InputGroup/DSInputGroup.d.ts +56 -8
  126. package/types/InputGroup/props.d.ts +43 -7
  127. package/types/InputMask/DSInputMask.d.ts +172 -30
  128. package/types/InputMask/mask_types/DateInputMask.d.ts +34 -33
  129. package/types/InputMask/mask_types/DateTimeInputMask.d.ts +34 -33
  130. package/types/InputMask/mask_types/DictionaryInputMask.d.ts +37 -36
  131. package/types/InputMask/mask_types/NumberInputMask.d.ts +46 -45
  132. package/types/InputMask/mask_types/PhoneInputMask.d.ts +34 -33
  133. package/types/InputMask/mask_types/PhoneInternationalInputMask.d.ts +34 -33
  134. package/types/InputMask/mask_types/SsnInputMask.d.ts +34 -33
  135. package/types/InputMask/mask_types/UsZipCodeInputMask.d.ts +34 -33
  136. package/types/InputMask/mask_types/ZipCodeSearchInputMask.d.ts +34 -33
  137. package/types/InputMask/props.d.ts +172 -30
  138. package/types/InputProtected/DSInputProtected.d.ts +56 -7
  139. package/types/InputProtected/props.d.ts +43 -8
  140. package/types/LargeInputText/DSLargeInputText.d.ts +163 -27
  141. package/types/LargeInputText/props.d.ts +163 -27
  142. package/types/MenuItem/components/MenuItem/index.d.ts +12 -3
  143. package/types/MenuItem/components/MenuItem/styled.d.ts +1 -1
  144. package/types/MenuItem/components/MultiMenuItem/MultiMenuItem.d.ts +12 -3
  145. package/types/MenuItem/components/MultiMenuItem/styled.d.ts +1 -1
  146. package/types/MenuItem/components/Section/index.d.ts +4 -1
  147. package/types/MenuItem/components/Section/props.d.ts +4 -1
  148. package/types/MenuItem/components/Section/styled.d.ts +2 -2
  149. package/types/MenuItem/components/Separator/styled.d.ts +2 -2
  150. package/types/MenuItem/components/SingleMenuItem/SingleMenuItem.d.ts +7 -2
  151. package/types/MenuItem/components/SubmenuItem/index.d.ts +12 -3
  152. package/types/MenuItem/components/SubmenuItem/styled.d.ts +2 -2
  153. package/types/MenuItem/components/styled.d.ts +3 -3
  154. package/types/MenuItem/props.d.ts +7 -2
  155. package/types/Radio/Circle.d.ts +1 -1
  156. package/types/Radio/DSRadio.d.ts +79 -13
  157. package/types/RadioGroup/DSRadioGroup.d.ts +51 -7
  158. package/types/RadioGroup/props.d.ts +37 -6
  159. package/types/SearchBox/DSSearchBox.d.ts +146 -21
  160. package/types/SearchBox/NavSearchBox.d.ts +18 -3
  161. package/types/SearchBox/SButton.d.ts +13 -2
  162. package/types/SearchBox/props.d.ts +133 -22
  163. package/types/SearchBox/styled.d.ts +1 -49
  164. package/types/TextBox/DSTextBox.d.ts +146 -21
  165. package/types/TimeInput/DSTimeInput.d.ts +83 -12
  166. package/types/TimeInput/utils.d.ts +1 -1
  167. package/types/Toggle/DSToggle.d.ts +84 -12
  168. package/cjs/ComboBox/v3/utils/hooks/useOnWindowResize.js +0 -31
  169. package/cjs/MenuItem/components/SingleMenuItem/styled.js +0 -19
  170. package/esm/ComboBox/v3/utils/hooks/useOnWindowResize.js +0 -27
  171. package/esm/MenuItem/components/SingleMenuItem/styled.js +0 -10
  172. package/types/ComboBox/v3/utils/hooks/useOnWindowResize.d.ts +0 -5
  173. package/types/MenuItem/components/SingleMenuItem/styled.d.ts +0 -2
@@ -0,0 +1,97 @@
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import 'core-js/modules/esnext.async-iterator.map.js';
3
+ import 'core-js/modules/esnext.iterator.map.js';
4
+ import 'core-js/modules/esnext.async-iterator.filter.js';
5
+ import 'core-js/modules/esnext.iterator.constructor.js';
6
+ import 'core-js/modules/esnext.iterator.filter.js';
7
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
8
+ import 'core-js/modules/esnext.iterator.for-each.js';
9
+ import { useContext, useCallback, useMemo } from 'react';
10
+ import { Section, Separator, MultiMenuItem, SingleMenuItem } from '@elliemae/ds-form';
11
+ import { ComboBoxContext } from '../../ComboBoxCTX.js';
12
+ import { isSelected } from '../../utils/listHelper.js';
13
+ import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
14
+ import { jsx, Fragment } from 'react/jsx-runtime';
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ const useItemRenderer = () => {
21
+ const {
22
+ props: {
23
+ options,
24
+ onChange,
25
+ selectedValues,
26
+ onFilter
27
+ },
28
+ inputRef,
29
+ setShowPopover,
30
+ focusOptionIdx,
31
+ virtualListHelpers
32
+ } = useContext(ComboBoxContext);
33
+ const {
34
+ virtualItems
35
+ } = virtualListHelpers;
36
+ const multiple = Array.isArray(selectedValues);
37
+ const CBItem = multiple ? MultiMenuItem : SingleMenuItem;
38
+ const handleClick = useCallback((option, e) => {
39
+ var _inputRef$current;
40
+
41
+ if (!multiple) {
42
+ setShowPopover(false);
43
+ if (inputRef.current) inputRef.current.value = '';
44
+ } else if (inputRef.current) {
45
+ onFilter(inputRef.current.value);
46
+ }
47
+
48
+ onChange(option);
49
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
50
+ e.stopPropagation();
51
+ e.preventDefault();
52
+ }, [onFilter, onChange, setShowPopover, multiple, inputRef]);
53
+ const handleOnMouseDown = useCallback(e => {
54
+ e.preventDefault();
55
+ }, []);
56
+ const ItemRenderer = useMemo(() => virtualItems.map(vItem => {
57
+ const option = options[vItem.index];
58
+ const generalProps = {
59
+ wrapperStyles: {
60
+ position: 'absolute',
61
+ top: vItem.start,
62
+ left: 0,
63
+ width: '100%'
64
+ },
65
+ key: "".concat(option.dsId),
66
+ innerRef: vItem.measureRef
67
+ };
68
+
69
+ if (option.type === 'section') {
70
+ return /*#__PURE__*/jsx(Section, _objectSpread({
71
+ label: option.label
72
+ }, generalProps));
73
+ }
74
+
75
+ if (option.type === 'separator') {
76
+ return /*#__PURE__*/jsx(Separator, _objectSpread({}, generalProps));
77
+ }
78
+
79
+ if (option.type === 'option') {
80
+ return /*#__PURE__*/jsx(CBItem, _objectSpread(_objectSpread({}, generalProps), {}, {
81
+ value: option.value,
82
+ label: option.label,
83
+ dataTestid: ComboboxDataTestid.OPTION,
84
+ disabled: option.disabled,
85
+ onClick: e => handleClick(option, e),
86
+ onMouseDown: handleOnMouseDown,
87
+ isActive: option.dsId === focusOptionIdx,
88
+ isSelected: isSelected(selectedValues, option)
89
+ }));
90
+ }
91
+
92
+ return /*#__PURE__*/jsx(Fragment, {});
93
+ }), [options, focusOptionIdx, selectedValues, inputRef, virtualItems]);
94
+ return ItemRenderer;
95
+ };
96
+
97
+ export { useItemRenderer };
@@ -1,96 +1,57 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import 'core-js/modules/esnext.async-iterator.map.js';
3
- import 'core-js/modules/esnext.iterator.map.js';
4
- import 'core-js/modules/esnext.async-iterator.filter.js';
5
- import 'core-js/modules/esnext.iterator.constructor.js';
6
- import 'core-js/modules/esnext.iterator.filter.js';
7
- import 'core-js/modules/esnext.async-iterator.for-each.js';
8
- import 'core-js/modules/esnext.iterator.for-each.js';
9
- import { useContext, useCallback, useMemo } from 'react';
10
- import { Section, Separator, MultiMenuItem, SingleMenuItem } from '@elliemae/ds-form';
1
+ import { useContext, useEffect } from 'react';
11
2
  import { ComboBoxContext } from '../../ComboBoxCTX.js';
12
- import { isSelected } from '../../utils/listHelper.js';
13
- import { ComboboxDataTestid } from '../../ComboboxDataTestids.js';
14
- import { jsx, Fragment } from 'react/jsx-runtime';
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
3
 
20
4
  const useMenuList = () => {
5
+ var _inputRef$current;
6
+
21
7
  const {
22
8
  props: {
23
- options,
24
- onChange,
9
+ inline,
25
10
  selectedValues,
26
- onFilter
11
+ onMenuOpen,
12
+ options
27
13
  },
28
14
  inputRef,
29
- setShowPopover,
30
- focusOptionIdx,
31
- virtualListHelpers: {
32
- virtualItems
33
- }
15
+ setCurrentOption,
16
+ scrollOptionIntoView,
17
+ hasFocus,
18
+ showPopover
34
19
  } = useContext(ComboBoxContext);
35
- const multiple = Array.isArray(selectedValues);
36
- const CBItem = multiple ? MultiMenuItem : SingleMenuItem;
37
- const handleClick = useCallback((option, e) => {
38
- if (!multiple) {
39
- setShowPopover(false);
40
- inputRef.current.value = '';
41
- } else {
42
- onFilter(inputRef.current.value);
43
- }
44
-
45
- onChange(option);
46
- inputRef.current.focus();
47
- e.stopPropagation();
48
- e.preventDefault();
49
- }, [onFilter, onChange, setShowPopover, multiple, inputRef]);
50
- const handleOnMouseDown = useCallback(e => {
51
- e.preventDefault();
52
- }, []);
53
- const ItemRenderer = useMemo(() => virtualItems.map(vItem => {
54
- const option = options[vItem.index];
55
- const generalProps = {
56
- wrapperStyles: {
57
- position: 'absolute',
58
- top: vItem.start,
59
- left: 0,
60
- width: '100%'
61
- },
62
- key: "".concat(option.dsId),
63
- innerRef: vItem.measureRef
20
+ useEffect(() => {
21
+ const getFirstOption = () => {
22
+ for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type)) {
23
+ setCurrentOption(options[i].dsId);
24
+ break;
25
+ }
64
26
  };
65
27
 
66
- if (option.type === 'section') {
67
- return /*#__PURE__*/jsx(Section, _objectSpread({
68
- label: option.label
69
- }, generalProps));
70
- }
71
-
72
- if (option.type === 'separator') {
73
- return /*#__PURE__*/jsx(Separator, _objectSpread({}, generalProps));
74
- }
75
-
76
- if (option.type === 'option') {
77
- return /*#__PURE__*/jsx(CBItem, _objectSpread(_objectSpread({}, generalProps), {}, {
78
- value: option.value,
79
- label: option.label,
80
- dataTestid: ComboboxDataTestid.OPTION,
81
- disabled: option.disabled,
82
- onClick: e => handleClick(option, e),
83
- onMouseDown: handleOnMouseDown,
84
- isActive: option.dsId === focusOptionIdx,
85
- isSelected: isSelected(selectedValues, option)
86
- }));
87
- }
88
-
89
- return /*#__PURE__*/jsx(Fragment, {});
90
- }), [options, focusOptionIdx, selectedValues, inputRef, virtualItems]);
91
- return useMemo(() => ({
92
- ItemRenderer
93
- }), [ItemRenderer]);
28
+ if (showPopover || inline) {
29
+ onMenuOpen();
30
+
31
+ if (inputRef.current.value !== '') {
32
+ getFirstOption();
33
+ } else if (Array.isArray(selectedValues)) {
34
+ const multiSelectedValues = selectedValues;
35
+
36
+ if (multiSelectedValues.length > 0) {
37
+ setCurrentOption(multiSelectedValues[multiSelectedValues.length - 1].dsId);
38
+ scrollOptionIntoView(multiSelectedValues[multiSelectedValues.length - 1].dsId);
39
+ } else {
40
+ getFirstOption();
41
+ }
42
+ } else {
43
+ const singleSelectedValue = selectedValues;
44
+
45
+ if (singleSelectedValue) {
46
+ setCurrentOption(selectedValues.dsId);
47
+ scrollOptionIntoView(selectedValues.dsId);
48
+ } else {
49
+ getFirstOption();
50
+ }
51
+ }
52
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
53
+
54
+ }, [showPopover, inline, hasFocus, (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value]);
94
55
  };
95
56
 
96
57
  export { useMenuList };
@@ -1,7 +1,7 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import 'core-js/modules/esnext.async-iterator.map.js';
3
3
  import 'core-js/modules/esnext.iterator.map.js';
4
- import { useContext, useRef, useMemo } from 'react';
4
+ import { useContext, useMemo } from 'react';
5
5
  import Grid from '@elliemae/ds-grid';
6
6
  import { DSPillGroupV2, DSPillV2 } from '@elliemae/ds-pills';
7
7
  import { ComboBoxContext } from '../../ComboBoxCTX.js';
@@ -13,50 +13,41 @@ import { jsxs, Fragment } from 'react/jsx-runtime';
13
13
  var _MultiAllyMessages;
14
14
 
15
15
  const MultiSelectedValuesContainer = () => {
16
+ var _inputRef$current2;
17
+
16
18
  const {
17
19
  props: {
18
- onChange,
19
20
  selectedValues
20
21
  },
21
- inputRef
22
+ inputRef,
23
+ pillGroupRef
22
24
  } = useContext(ComboBoxContext);
23
- const pillGroupRef = useRef(null);
24
25
  const multiSelectedValue = selectedValues;
25
- const pillsToShow = useGroupPills(pillGroupRef);
26
+ const pillsToShow = useGroupPills();
26
27
  const correctPillsToShow = pillsToShow || 1;
28
+ const pills = useMemo(() => /*#__PURE__*/_jsx(Grid, {
29
+ style: {
30
+ width: 'max-content'
31
+ }
32
+ }, void 0, /*#__PURE__*/_jsx(DSPillGroupV2, {
33
+ innerRef: pillGroupRef
34
+ }, void 0, multiSelectedValue.length > 0 && multiSelectedValue.slice(0, correctPillsToShow).map(option => {
35
+ var _inputRef$current;
27
36
 
28
- const handleClick = e => {
29
- // prevent toggle drowpdown on pills remove
30
- e.stopPropagation();
31
- };
32
-
33
- const pills = useMemo(() => {
34
- const handleRemove = option => {
35
- onChange(option);
36
- inputRef.current.focus();
37
- };
38
-
39
- return /*#__PURE__*/_jsx(Grid, {
40
- onClick: handleClick,
41
- style: {
42
- width: 'max-content'
43
- }
44
- }, void 0, /*#__PURE__*/_jsx(DSPillGroupV2, {
45
- innerRef: pillGroupRef
46
- }, void 0, multiSelectedValue.length > 0 && multiSelectedValue.slice(0, correctPillsToShow).map(option => /*#__PURE__*/_jsx(DSPillV2, {
47
- labelTruncated: inputRef.current.value === '' || correctPillsToShow !== pillsToShow,
37
+ return /*#__PURE__*/_jsx(DSPillV2, {
38
+ size: "s",
39
+ labelTruncated: ((_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) === '' || correctPillsToShow !== pillsToShow,
48
40
  label: option.label,
49
- type: "removable",
50
- onRemove: () => handleRemove(option)
51
- }, option.value)), multiSelectedValue.length > 0 && correctPillsToShow !== multiSelectedValue.length && /*#__PURE__*/_jsx(DSPillV2, {
52
- labelTruncated: false,
53
- label: "+".concat(multiSelectedValue.length - correctPillsToShow),
54
- type: "value",
55
- tooltipValue: multiSelectedValue.slice(correctPillsToShow).map(val => val.label).join(', ')
56
- }, "grouped")));
57
- }, [pillsToShow, onChange, inputRef, multiSelectedValue, correctPillsToShow]);
41
+ type: "value"
42
+ }, option.value);
43
+ }), multiSelectedValue.length > 0 && correctPillsToShow !== multiSelectedValue.length && /*#__PURE__*/_jsx(DSPillV2, {
44
+ size: "s",
45
+ labelTruncated: false,
46
+ label: "+".concat(multiSelectedValue.length - correctPillsToShow),
47
+ type: "value"
48
+ }, "grouped"))), [pillsToShow, pillGroupRef, inputRef, multiSelectedValue, correctPillsToShow]);
58
49
  return /*#__PURE__*/jsxs(Fragment, {
59
- children: [multiSelectedValue.length > 0 && !inputRef.current.value && (_MultiAllyMessages || (_MultiAllyMessages = /*#__PURE__*/_jsx(MultiAllyMessages, {}))), pills]
50
+ children: [multiSelectedValue.length > 0 && !((_inputRef$current2 = inputRef.current) !== null && _inputRef$current2 !== void 0 && _inputRef$current2.value) && (_MultiAllyMessages || (_MultiAllyMessages = /*#__PURE__*/_jsx(MultiAllyMessages, {}))), pills]
60
51
  });
61
52
  };
62
53
 
@@ -14,13 +14,14 @@ const getGroupedPillWidth = remainingPills => {
14
14
  return 8 * (digits - 1) + 31;
15
15
  };
16
16
 
17
- const useGroupPills = pillGroupRef => {
17
+ const useGroupPills = () => {
18
18
  const {
19
19
  props: {
20
20
  selectedValues
21
21
  },
22
22
  selectedOptionsRef,
23
- controlsWrapperRef
23
+ controlsWrapperRef,
24
+ pillGroupRef
24
25
  } = useContext(ComboBoxContext);
25
26
  const multiSelectedValues = selectedValues;
26
27
  const [pillsToShow, setPillsToShow] = useState(multiSelectedValues.length);
@@ -39,7 +40,7 @@ const useGroupPills = pillGroupRef => {
39
40
  let lastPillFit = -1;
40
41
  let currentWidth = 0;
41
42
  const referenceWidth = selectedOptionsRef.current.offsetWidth;
42
- const pills = [...selectedOptionsRef.current.querySelectorAll('.ds-pill-wrapper-removable')];
43
+ const pills = [...selectedOptionsRef.current.querySelectorAll('.ds-pill-wrapper-value')];
43
44
  const pillsWidth = pills.map(pill => pill === null || pill === void 0 ? void 0 : pill.offsetWidth);
44
45
  pillsWidth.forEach((pillWidth, idx) => {
45
46
  currentWidth += pillWidth;
@@ -48,10 +49,13 @@ const useGroupPills = pillGroupRef => {
48
49
  lastPillFit = idx;
49
50
  }
50
51
  });
51
- const nextPillsToShow = lastPillFit + 1;
52
52
 
53
- if (nextPillsToShow !== pillsToShow) {
54
- setPillsToShow(nextPillsToShow);
53
+ if (!(multiSelectedValues.length > 0 && pillsToShow !== multiSelectedValues.length)) {
54
+ const nextPillsToShow = lastPillFit + 1;
55
+
56
+ if (nextPillsToShow !== pillsToShow) {
57
+ setPillsToShow(nextPillsToShow);
58
+ }
55
59
  }
56
60
 
57
61
  pillGroupRef.current.style.width = 'fit-content';
@@ -1,17 +1,21 @@
1
1
  import { PropTypes } from 'react-desc';
2
2
 
3
3
  const propTypes = {
4
- placeholder: PropTypes.string.description('').defaultValue(''),
5
- options: PropTypes.array.description('').defaultValue([]),
6
- selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description(''),
7
- autoFocus: PropTypes.bool.description('').defaultValue('false'),
8
- hasError: PropTypes.bool.description('').defaultValue('false'),
9
- onChange: PropTypes.func.description('').defaultValue(''),
10
- onSelectAll: PropTypes.func.description('').defaultValue(''),
11
- onFilter: PropTypes.func.description('').defaultValue(''),
12
- onCreate: PropTypes.func.description('').defaultValue(''),
13
- onClear: PropTypes.func.description('').defaultValue(''),
14
- onClearAll: PropTypes.func.description('').defaultValue('')
4
+ placeholder: PropTypes.string.description('input s placeholder value').defaultValue(''),
5
+ options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).description('List of options').defaultValue([]),
6
+ selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).description('Array of option or single option selected'),
7
+ autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
8
+ hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
9
+ onChange: PropTypes.func.description('function triggered when an option is selected it will send the options selected').defaultValue(''),
10
+ onSelectAll: PropTypes.func.description('function triggered when ALL button is selected from the header menu list').defaultValue(''),
11
+ onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),
12
+ onCreate: PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(''),
13
+ onClearAll: PropTypes.func.description('function triggered when user select CLEAR button from the header menu list').defaultValue(''),
14
+ onMenuOpen: PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),
15
+ inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),
16
+ menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),
17
+ menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),
18
+ withToggle: PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false')
15
19
  };
16
20
 
17
21
  export { propTypes };
@@ -11,6 +11,8 @@ const useKeyboardNavigation = () => {
11
11
  const {
12
12
  props: {
13
13
  inline,
14
+ onSelectAll,
15
+ onKeyDown,
14
16
  onChange,
15
17
  onCreate,
16
18
  options,
@@ -28,9 +30,10 @@ const useKeyboardNavigation = () => {
28
30
  const multiple = Array.isArray(selectedValues);
29
31
  const selectableOptions = getOptions(options);
30
32
  const currentItemIndex = options.findIndex(opt => opt.dsId === focusOptionIdx);
33
+ const currentItem = options.find(item => item.dsId === focusOptionIdx);
31
34
  const selectOption = useCallback(() => {
32
35
  if (multiple) {
33
- onFilter(inputRef.current.value);
36
+ if (inputRef.current) onFilter(inputRef.current.value);
34
37
  } else {
35
38
  onFilter('');
36
39
  if (inputRef.current) inputRef.current.value = '';
@@ -42,9 +45,13 @@ const useKeyboardNavigation = () => {
42
45
  }, [multiple, options, focusOptionIdx, setShowPopover, showPopover, onFilter, inputRef, setShowSelectedValue, onChange]);
43
46
  const onInputKeyDown = useCallback(e => {
44
47
  const targetElement = e.target; // =============================================================================
45
- // ENTER KEY TO CREATE ELEMENTS
48
+ // CUSTOM KEYS
46
49
  // =============================================================================
47
50
 
51
+ onKeyDown(e, currentItem); // =============================================================================
52
+ // ENTER KEY TO CREATE ELEMENTS
53
+ // ====================================================== =================
54
+
48
55
  if (e.key === 'Enter' && onCreate && !selectableOptions.length) {
49
56
  onCreate(targetElement.value);
50
57
  onFilter('');
@@ -58,7 +65,7 @@ const useKeyboardNavigation = () => {
58
65
  if (e.keyCode === 32 && targetElement.value === '' || e.key === 'Enter') {
59
66
  e.preventDefault();
60
67
 
61
- if (!showPopover) {
68
+ if (!showPopover && !inline) {
62
69
  setShowPopover(true);
63
70
  } else {
64
71
  selectOption();
@@ -70,14 +77,19 @@ const useKeyboardNavigation = () => {
70
77
 
71
78
  if (e.key === 'Enter' && e.ctrlKey && multiple) {
72
79
  setShowPopover(false);
80
+ }
81
+
82
+ if (e.key === 'a' && e.ctrlKey && multiple) {
83
+ onSelectAll();
73
84
  } // =============================================================================
74
85
  // ARROWS UP AND DOWN
75
86
  // =============================================================================
76
87
 
77
88
 
78
89
  if (e.key === 'ArrowDown') {
90
+ e.preventDefault();
91
+
79
92
  if (showPopover || inline) {
80
- e.preventDefault();
81
93
  const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);
82
94
  setCurrentOption(options[nextItemIndex].dsId);
83
95
  scrollOptionIntoView(options[nextItemIndex].dsId);
@@ -87,8 +99,9 @@ const useKeyboardNavigation = () => {
87
99
  }
88
100
 
89
101
  if (e.key === 'ArrowUp') {
102
+ e.preventDefault();
103
+
90
104
  if (showPopover || inline) {
91
- e.preventDefault();
92
105
  const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);
93
106
  setCurrentOption(options[nextItemIndex].dsId);
94
107
  scrollOptionIntoView(options[nextItemIndex].dsId);
@@ -98,7 +111,7 @@ const useKeyboardNavigation = () => {
98
111
  const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);
99
112
  setCurrentOption(options[nextItemIndex].dsId);
100
113
  scrollOptionIntoView(options[nextItemIndex].dsId);
101
- }, 1);
114
+ });
102
115
  }
103
116
  } // =============================================================================
104
117
  // ESCAPE
@@ -106,7 +119,9 @@ const useKeyboardNavigation = () => {
106
119
 
107
120
 
108
121
  if (e.key === 'Escape' && !inline) {
109
- setShowPopover(false);
122
+ setShowPopover(false); // TODO confirm funcionality
123
+ // onFilter('');
124
+ // inputRef.current.value = '';
110
125
  } // =============================================================================
111
126
  // BACKSPACE
112
127
  // =============================================================================
@@ -114,37 +129,20 @@ const useKeyboardNavigation = () => {
114
129
 
115
130
  if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {
116
131
  if (multiple && !targetElement.value) {
117
- const multiSelectedValues = selectedValues;
118
- if (multiSelectedValues.length > 0) onChange(multiSelectedValues[multiSelectedValues.length - 1]);
132
+ if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);
119
133
  } else {
120
134
  onChange(null);
121
135
  }
122
136
 
123
137
  onFilter('');
124
138
  setShowSelectedValue(true);
125
- } // =============================================================================
126
- // SHIFT + TAB ON SINGLE SELECT: SELECT AND RETURN TO INPUT
127
- // =============================================================================
128
-
129
-
130
- if (e.key === 'Tab' && e.shiftKey && !multiple && showPopover) {
131
- selectOption();
132
- e.preventDefault();
133
- } // =============================================================================
134
- // TAB + SINGLE SELECT
135
- // =============================================================================
136
-
137
-
138
- if (e.key === 'Tab' && showPopover && !multiple) {
139
- selectOption();
140
- setShowPopover(false);
141
139
  }
142
140
 
143
- if (e.key === 'Tab' && inline) {
144
- e.preventDefault();
145
- }
146
- }, [scrollOptionIntoView, currentItemIndex, options, selectableOptions, inputRef, multiple, showPopover, selectedValues, inline, onChange, onCreate, onFilter, setCurrentOption, setShowPopover, setShowSelectedValue, selectOption]);
147
- return onInputKeyDown;
141
+ if (e.key === 'Tab' && inline) ;
142
+ }, [scrollOptionIntoView, currentItemIndex, options, currentItem, selectableOptions, inputRef, multiple, showPopover, selectedValues, inline, onKeyDown, onSelectAll, onChange, onCreate, onFilter, setCurrentOption, setShowPopover, setShowSelectedValue, selectOption]);
143
+ return {
144
+ onInputKeyDown
145
+ };
148
146
  };
149
147
 
150
148
  export { useKeyboardNavigation };
@@ -11,10 +11,10 @@ const useOnElementResize = targetRef => {
11
11
  const observer = useRef(null);
12
12
  useEffect(() => {
13
13
  function outputsize() {
14
- var _targetRef$current3, _targetRef$current4;
15
-
16
- setWidth((_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth);
17
- setHeight((_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight);
14
+ if (targetRef.current) {
15
+ setWidth(targetRef.current.offsetWidth);
16
+ setHeight(targetRef.current.offsetHeight);
17
+ }
18
18
  }
19
19
 
20
20
  observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
@@ -44,11 +44,8 @@ const shouldUpdateSvgPath = (_ref2, prevSizes) => {
44
44
  class FloatingLabelInputImpl extends Component {
45
45
  constructor(props) {
46
46
  super(props);
47
-
48
- _defineProperty(this, "resizeObserver", new ResizeObserver(() => this.updatePath()));
49
-
50
- _defineProperty(this, "prevSizes", {});
51
-
47
+ this.resizeObserver = new ResizeObserver(() => this.updatePath());
48
+ this.prevSizes = {};
52
49
  this.wrapperRef = /*#__PURE__*/React.createRef();
53
50
  this.outlinePathRef = /*#__PURE__*/React.createRef();
54
51
  this.outlineIdleRef = /*#__PURE__*/React.createRef();
@@ -188,8 +185,8 @@ class FloatingLabelInputImpl extends Component {
188
185
 
189
186
  }
190
187
 
191
- _defineProperty(FloatingLabelInputImpl, "defaultProps", {
188
+ FloatingLabelInputImpl.defaultProps = {
192
189
  onChange: () => null
193
- });
190
+ };
194
191
 
195
192
  export { FloatingLabelInputImpl as default };
@@ -105,8 +105,7 @@ class ValidationFieldWrapper extends Component {
105
105
  }
106
106
 
107
107
  }
108
-
109
- _defineProperty(ValidationFieldWrapper, "defaultProps", {
108
+ ValidationFieldWrapper.defaultProps = {
110
109
  validateOnBlur: false,
111
110
  validateOnChange: false,
112
111
  name: '',
@@ -115,6 +114,6 @@ _defineProperty(ValidationFieldWrapper, "defaultProps", {
115
114
  validate: () => null,
116
115
  onChange: () => null,
117
116
  onBlur: () => null
118
- });
117
+ };
119
118
 
120
119
  export { ValidationFieldWrapper as default };
@@ -105,11 +105,10 @@ class InputAddonWrapper extends Component {
105
105
  }
106
106
 
107
107
  }
108
-
109
- _defineProperty(InputAddonWrapper, "defaultProps", {
108
+ InputAddonWrapper.defaultProps = {
110
109
  rightComponents: [],
111
110
  leftComponents: [],
112
111
  containerProps: {}
113
- });
112
+ };
114
113
 
115
114
  export { InputAddonWrapper as default };