@elliemae/ds-form 2.1.0-rc.7 → 2.2.0-alpha.1

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 (152) hide show
  1. package/cjs/ComboBox/index.js +3 -0
  2. package/cjs/ComboBox/v3/ComboBox.js +33 -0
  3. package/cjs/ComboBox/v3/ComboBoxCTX.js +55 -0
  4. package/cjs/ComboBox/v3/ComboboxDataTestids.js +17 -0
  5. package/cjs/ComboBox/v3/config/constants.js +14 -0
  6. package/cjs/ComboBox/v3/config/useComboBox.js +122 -0
  7. package/cjs/ComboBox/v3/config/useGetPropsWithDefault.js +11 -0
  8. package/cjs/ComboBox/v3/index.d.js +2 -0
  9. package/cjs/ComboBox/v3/index.js +10 -0
  10. package/cjs/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js +33 -0
  11. package/cjs/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js +28 -0
  12. package/cjs/ComboBox/v3/parts/a11y-messages/index.js +11 -0
  13. package/cjs/ComboBox/v3/parts/a11y-messages/styled.js +15 -0
  14. package/cjs/ComboBox/v3/parts/container/Container.js +67 -0
  15. package/cjs/ComboBox/v3/parts/container/index.js +9 -0
  16. package/cjs/ComboBox/v3/parts/container/styled.js +23 -0
  17. package/cjs/ComboBox/v3/parts/controls/Controls.js +71 -0
  18. package/cjs/ComboBox/v3/parts/controls/index.js +9 -0
  19. package/cjs/ComboBox/v3/parts/controls/styled.js +65 -0
  20. package/cjs/ComboBox/v3/parts/controls-input/ControlsInput.js +67 -0
  21. package/cjs/ComboBox/v3/parts/controls-input/styled.js +27 -0
  22. package/cjs/ComboBox/v3/parts/controls-input/useControlsInput.js +77 -0
  23. package/cjs/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +33 -0
  24. package/cjs/ComboBox/v3/parts/dropdown-indicator/index.js +2 -0
  25. package/cjs/ComboBox/v3/parts/dropdown-indicator/styled.js +17 -0
  26. package/cjs/ComboBox/v3/parts/empty-state/index.js +27 -0
  27. package/cjs/ComboBox/v3/parts/empty-state/styled.js +19 -0
  28. package/cjs/ComboBox/v3/parts/header-list/HeaderList.js +113 -0
  29. package/cjs/ComboBox/v3/parts/header-list/index.js +9 -0
  30. package/cjs/ComboBox/v3/parts/header-list/styled.js +58 -0
  31. package/cjs/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +73 -0
  32. package/cjs/ComboBox/v3/parts/menu-list/MenuList.js +81 -0
  33. package/cjs/ComboBox/v3/parts/menu-list/index.js +9 -0
  34. package/cjs/ComboBox/v3/parts/menu-list/styled.js +33 -0
  35. package/cjs/ComboBox/v3/parts/menu-list/useItemRenderer.js +105 -0
  36. package/cjs/ComboBox/v3/parts/menu-list/useMenuList.js +61 -0
  37. package/cjs/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +63 -0
  38. package/cjs/ComboBox/v3/parts/multi-selected-values-container/index.js +9 -0
  39. package/cjs/ComboBox/v3/parts/multi-selected-values-container/styled.js +23 -0
  40. package/cjs/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +71 -0
  41. package/cjs/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js +28 -0
  42. package/cjs/ComboBox/v3/parts/single-selected-value-container/index.js +9 -0
  43. package/cjs/ComboBox/v3/parts/single-selected-value-container/styled.js +15 -0
  44. package/cjs/ComboBox/v3/propTypes.js +25 -0
  45. package/cjs/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +152 -0
  46. package/cjs/ComboBox/v3/utils/hooks/useOnElementResize.js +37 -0
  47. package/cjs/ComboBox/v3/utils/listHelper.js +39 -0
  48. package/cjs/ComboBoxFreeSolo/ComboBoxFreeSolo.js +1 -0
  49. package/cjs/index.js +2 -0
  50. package/esm/ComboBox/index.js +1 -0
  51. package/esm/ComboBox/v3/ComboBox.js +24 -0
  52. package/esm/ComboBox/v3/ComboBoxCTX.js +49 -0
  53. package/esm/ComboBox/v3/ComboboxDataTestids.js +13 -0
  54. package/esm/ComboBox/v3/config/constants.js +10 -0
  55. package/esm/ComboBox/v3/config/useComboBox.js +114 -0
  56. package/esm/ComboBox/v3/config/useGetPropsWithDefault.js +7 -0
  57. package/esm/ComboBox/v3/index.d.js +1 -0
  58. package/esm/ComboBox/v3/index.js +1 -0
  59. package/esm/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js +25 -0
  60. package/esm/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js +20 -0
  61. package/esm/ComboBox/v3/parts/a11y-messages/index.js +2 -0
  62. package/esm/ComboBox/v3/parts/a11y-messages/styled.js +7 -0
  63. package/esm/ComboBox/v3/parts/container/Container.js +59 -0
  64. package/esm/ComboBox/v3/parts/container/index.js +1 -0
  65. package/esm/ComboBox/v3/parts/container/styled.js +13 -0
  66. package/esm/ComboBox/v3/parts/controls/Controls.js +63 -0
  67. package/esm/ComboBox/v3/parts/controls/index.js +1 -0
  68. package/esm/ComboBox/v3/parts/controls/styled.js +52 -0
  69. package/esm/ComboBox/v3/parts/controls-input/ControlsInput.js +59 -0
  70. package/esm/ComboBox/v3/parts/controls-input/styled.js +16 -0
  71. package/esm/ComboBox/v3/parts/controls-input/useControlsInput.js +73 -0
  72. package/esm/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js +26 -0
  73. package/esm/ComboBox/v3/parts/dropdown-indicator/index.js +1 -0
  74. package/esm/ComboBox/v3/parts/dropdown-indicator/styled.js +8 -0
  75. package/esm/ComboBox/v3/parts/empty-state/index.js +19 -0
  76. package/esm/ComboBox/v3/parts/empty-state/styled.js +10 -0
  77. package/esm/ComboBox/v3/parts/header-list/HeaderList.js +105 -0
  78. package/esm/ComboBox/v3/parts/header-list/index.js +1 -0
  79. package/esm/ComboBox/v3/parts/header-list/styled.js +41 -0
  80. package/esm/ComboBox/v3/parts/header-list/useHeaderListHandlers.js +69 -0
  81. package/esm/ComboBox/v3/parts/menu-list/MenuList.js +73 -0
  82. package/esm/ComboBox/v3/parts/menu-list/index.js +1 -0
  83. package/esm/ComboBox/v3/parts/menu-list/styled.js +23 -0
  84. package/esm/ComboBox/v3/parts/menu-list/useItemRenderer.js +97 -0
  85. package/esm/ComboBox/v3/parts/menu-list/useMenuList.js +57 -0
  86. package/esm/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +54 -0
  87. package/esm/ComboBox/v3/parts/multi-selected-values-container/index.js +1 -0
  88. package/esm/ComboBox/v3/parts/multi-selected-values-container/styled.js +13 -0
  89. package/esm/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js +67 -0
  90. package/esm/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js +20 -0
  91. package/esm/ComboBox/v3/parts/single-selected-value-container/index.js +1 -0
  92. package/esm/ComboBox/v3/parts/single-selected-value-container/styled.js +7 -0
  93. package/esm/ComboBox/v3/propTypes.js +21 -0
  94. package/esm/ComboBox/v3/utils/hooks/useKeyboardNavigation.js +148 -0
  95. package/esm/ComboBox/v3/utils/hooks/useOnElementResize.js +33 -0
  96. package/esm/ComboBox/v3/utils/listHelper.js +30 -0
  97. package/esm/ComboBoxFreeSolo/ComboBoxFreeSolo.js +1 -0
  98. package/esm/index.js +1 -0
  99. package/package.json +207 -23
  100. package/types/ComboBox/index.d.ts +1 -0
  101. package/types/ComboBox/v3/ComboBox.d.ts +62 -0
  102. package/types/ComboBox/v3/ComboBoxCTX.d.ts +6 -0
  103. package/types/ComboBox/v3/ComboboxDataTestids.d.ts +11 -0
  104. package/types/ComboBox/v3/config/constants.d.ts +8 -0
  105. package/types/ComboBox/v3/config/useComboBox.d.ts +2 -0
  106. package/types/ComboBox/v3/config/useGetPropsWithDefault.d.ts +2 -0
  107. package/types/ComboBox/v3/index.d.ts +1 -0
  108. package/types/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.d.ts +3 -0
  109. package/types/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.d.ts +3 -0
  110. package/types/ComboBox/v3/parts/a11y-messages/index.d.ts +2 -0
  111. package/types/ComboBox/v3/parts/a11y-messages/styled.d.ts +1 -0
  112. package/types/ComboBox/v3/parts/container/Container.d.ts +3 -0
  113. package/types/ComboBox/v3/parts/container/index.d.ts +1 -0
  114. package/types/ComboBox/v3/parts/container/styled.d.ts +3 -0
  115. package/types/ComboBox/v3/parts/controls/Controls.d.ts +3 -0
  116. package/types/ComboBox/v3/parts/controls/index.d.ts +1 -0
  117. package/types/ComboBox/v3/parts/controls/styled.d.ts +7 -0
  118. package/types/ComboBox/v3/parts/controls-input/ControlsInput.d.ts +3 -0
  119. package/types/ComboBox/v3/parts/controls-input/styled.d.ts +4 -0
  120. package/types/ComboBox/v3/parts/controls-input/useControlsInput.d.ts +12 -0
  121. package/types/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.d.ts +3 -0
  122. package/types/ComboBox/v3/parts/dropdown-indicator/index.d.ts +0 -0
  123. package/types/ComboBox/v3/parts/dropdown-indicator/styled.d.ts +1 -0
  124. package/types/ComboBox/v3/parts/empty-state/index.d.ts +3 -0
  125. package/types/ComboBox/v3/parts/empty-state/styled.d.ts +2 -0
  126. package/types/ComboBox/v3/parts/header-list/HeaderList.d.ts +3 -0
  127. package/types/ComboBox/v3/parts/header-list/index.d.ts +1 -0
  128. package/types/ComboBox/v3/parts/header-list/styled.d.ts +7 -0
  129. package/types/ComboBox/v3/parts/header-list/useHeaderListHandlers.d.ts +12 -0
  130. package/types/ComboBox/v3/parts/menu-list/MenuList.d.ts +3 -0
  131. package/types/ComboBox/v3/parts/menu-list/index.d.ts +1 -0
  132. package/types/ComboBox/v3/parts/menu-list/styled.d.ts +10 -0
  133. package/types/ComboBox/v3/parts/menu-list/useItemRenderer.d.ts +2 -0
  134. package/types/ComboBox/v3/parts/menu-list/useMenuList.d.ts +2 -0
  135. package/types/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.d.ts +3 -0
  136. package/types/ComboBox/v3/parts/multi-selected-values-container/index.d.ts +1 -0
  137. package/types/ComboBox/v3/parts/multi-selected-values-container/styled.d.ts +3 -0
  138. package/types/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.d.ts +2 -0
  139. package/types/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.d.ts +3 -0
  140. package/types/ComboBox/v3/parts/single-selected-value-container/index.d.ts +1 -0
  141. package/types/ComboBox/v3/parts/single-selected-value-container/styled.d.ts +1 -0
  142. package/types/ComboBox/v3/propTypes.d.ts +51 -0
  143. package/types/ComboBox/v3/tests/combobox-general.test.d.ts +1 -0
  144. package/types/ComboBox/v3/tests/combobox-multi-select.test.d.ts +1 -0
  145. package/types/ComboBox/v3/tests/combobox-single-select.test.d.ts +1 -0
  146. package/types/ComboBox/v3/tests/combobox-special-keys.test.d.ts +1 -0
  147. package/types/ComboBox/v3/tests/utils.d.ts +22 -0
  148. package/types/ComboBox/v3/utils/hooks/useKeyboardNavigation.d.ts +4 -0
  149. package/types/ComboBox/v3/utils/hooks/useOnElementResize.d.ts +3 -0
  150. package/types/ComboBox/v3/utils/listHelper.d.ts +7 -0
  151. package/types/MenuItem/components/SubmenuItem/styled.d.ts +1 -1
  152. package/types/MenuItem/components/styled.d.ts +3 -3
@@ -0,0 +1,67 @@
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
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.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.constructor.js';
6
+ import 'core-js/modules/esnext.iterator.for-each.js';
7
+ import { useContext, useState, useEffect, useLayoutEffect } from 'react';
8
+ import { useOnElementResize } from '../../utils/hooks/useOnElementResize.js';
9
+ import { ComboBoxContext } from '../../ComboBoxCTX.js';
10
+
11
+ const getGroupedPillWidth = remainingPills => {
12
+ if (remainingPills === 0) return 0;
13
+ const digits = remainingPills.toString().length;
14
+ return 8 * (digits - 1) + 31;
15
+ };
16
+
17
+ const useGroupPills = () => {
18
+ const {
19
+ props: {
20
+ selectedValues
21
+ },
22
+ selectedOptionsRef,
23
+ controlsWrapperRef,
24
+ pillGroupRef
25
+ } = useContext(ComboBoxContext);
26
+ const multiSelectedValues = selectedValues;
27
+ const [pillsToShow, setPillsToShow] = useState(multiSelectedValues.length);
28
+ const {
29
+ width
30
+ } = useOnElementResize(controlsWrapperRef);
31
+ useEffect(() => {
32
+ if (multiSelectedValues.length !== pillsToShow) {
33
+ setPillsToShow(multiSelectedValues.length);
34
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
35
+
36
+ }, [multiSelectedValues.length, width]);
37
+ useLayoutEffect(() => {
38
+ if (selectedOptionsRef.current) {
39
+ pillGroupRef.current.style.width = 'max-content';
40
+ let lastPillFit = -1;
41
+ let currentWidth = 0;
42
+ const referenceWidth = selectedOptionsRef.current.offsetWidth;
43
+ const pills = [...selectedOptionsRef.current.querySelectorAll('.ds-pill-wrapper-value')];
44
+ const pillsWidth = pills.map(pill => pill === null || pill === void 0 ? void 0 : pill.offsetWidth);
45
+ pillsWidth.forEach((pillWidth, idx) => {
46
+ currentWidth += pillWidth;
47
+
48
+ if (currentWidth + getGroupedPillWidth(multiSelectedValues.length - idx - 1) <= referenceWidth) {
49
+ lastPillFit = idx;
50
+ }
51
+ });
52
+
53
+ if (!(multiSelectedValues.length > 0 && pillsToShow !== multiSelectedValues.length)) {
54
+ const nextPillsToShow = lastPillFit + 1;
55
+
56
+ if (nextPillsToShow !== pillsToShow) {
57
+ setPillsToShow(nextPillsToShow);
58
+ }
59
+ }
60
+
61
+ pillGroupRef.current.style.width = 'fit-content';
62
+ }
63
+ }, [selectedOptionsRef, multiSelectedValues, pillsToShow, pillGroupRef, width]);
64
+ return pillsToShow;
65
+ };
66
+
67
+ export { useGroupPills };
@@ -0,0 +1,20 @@
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext } from 'react';
3
+ import { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';
4
+ import { ComboBoxContext } from '../../ComboBoxCTX.js';
5
+ import { StyledSingleSelectedValue } from './styled.js';
6
+
7
+ const SingleSelectedValueContainer = () => {
8
+ const {
9
+ props: {
10
+ selectedValues
11
+ },
12
+ showSelectedValue
13
+ } = useContext(ComboBoxContext);
14
+ const singleSelectedValue = selectedValues;
15
+ return /*#__PURE__*/_jsx(StyledSingleSelectedValue, {}, void 0, showSelectedValue ? /*#__PURE__*/_jsx(SimpleTruncatedTooltipText, {
16
+ value: singleSelectedValue === null || singleSelectedValue === void 0 ? void 0 : singleSelectedValue.label
17
+ }) : null);
18
+ };
19
+
20
+ export { SingleSelectedValueContainer };
@@ -0,0 +1 @@
1
+ export { SingleSelectedValueContainer } from './SingleSelectedValueContainer.js';
@@ -0,0 +1,7 @@
1
+ import styled from 'styled-components';
2
+
3
+ const StyledSingleSelectedValue = /*#__PURE__*/styled.div.withConfig({
4
+ componentId: "sc-ui9n59-0"
5
+ })(["width:100%;display:flex;align-items:center;"]);
6
+
7
+ export { StyledSingleSelectedValue };
@@ -0,0 +1,21 @@
1
+ import { PropTypes } from 'react-desc';
2
+
3
+ const propTypes = {
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')
19
+ };
20
+
21
+ export { propTypes };
@@ -0,0 +1,148 @@
1
+ import 'core-js/modules/esnext.async-iterator.find.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.find.js';
4
+ import { useContext, useCallback } from 'react';
5
+ import { ComboBoxContext } from '../../ComboBoxCTX.js';
6
+ import { getOptions, findInCircularList } from '../listHelper.js';
7
+
8
+ const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type);
9
+
10
+ const useKeyboardNavigation = () => {
11
+ const {
12
+ props: {
13
+ inline,
14
+ onSelectAll,
15
+ onKeyDown,
16
+ onChange,
17
+ onCreate,
18
+ options,
19
+ selectedValues,
20
+ onFilter
21
+ },
22
+ setShowPopover,
23
+ showPopover,
24
+ setShowSelectedValue,
25
+ focusOptionIdx,
26
+ inputRef,
27
+ setCurrentOption,
28
+ scrollOptionIntoView
29
+ } = useContext(ComboBoxContext);
30
+ const multiple = Array.isArray(selectedValues);
31
+ const selectableOptions = getOptions(options);
32
+ const currentItemIndex = options.findIndex(opt => opt.dsId === focusOptionIdx);
33
+ const currentItem = options.find(item => item.dsId === focusOptionIdx);
34
+ const selectOption = useCallback(() => {
35
+ if (multiple) {
36
+ if (inputRef.current) onFilter(inputRef.current.value);
37
+ } else {
38
+ onFilter('');
39
+ if (inputRef.current) inputRef.current.value = '';
40
+ setShowSelectedValue(true);
41
+ }
42
+
43
+ onChange(options.find(item => item.dsId === focusOptionIdx));
44
+ setShowPopover(multiple ? true : !showPopover);
45
+ }, [multiple, options, focusOptionIdx, setShowPopover, showPopover, onFilter, inputRef, setShowSelectedValue, onChange]);
46
+ const onInputKeyDown = useCallback(e => {
47
+ const targetElement = e.target; // =============================================================================
48
+ // CUSTOM KEYS
49
+ // =============================================================================
50
+
51
+ onKeyDown(e, currentItem); // =============================================================================
52
+ // ENTER KEY TO CREATE ELEMENTS
53
+ // ====================================================== =================
54
+
55
+ if (e.key === 'Enter' && onCreate && !selectableOptions.length) {
56
+ onCreate(targetElement.value);
57
+ onFilter('');
58
+ if (inputRef.current) inputRef.current.value = '';
59
+ return;
60
+ } // =============================================================================
61
+ // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER
62
+ // =============================================================================
63
+
64
+
65
+ if (e.keyCode === 32 && targetElement.value === '' || e.key === 'Enter') {
66
+ e.preventDefault();
67
+
68
+ if (!showPopover && !inline) {
69
+ setShowPopover(true);
70
+ } else {
71
+ selectOption();
72
+ }
73
+ } // =============================================================================
74
+ // CTRL + ENTER + MULTIPLE: SELECT AND CLOSE MENU
75
+ // =============================================================================
76
+
77
+
78
+ if (e.key === 'Enter' && e.ctrlKey && multiple) {
79
+ setShowPopover(false);
80
+ }
81
+
82
+ if (e.key === 'a' && e.ctrlKey && multiple) {
83
+ onSelectAll();
84
+ } // =============================================================================
85
+ // ARROWS UP AND DOWN
86
+ // =============================================================================
87
+
88
+
89
+ if (e.key === 'ArrowDown') {
90
+ e.preventDefault();
91
+
92
+ if (showPopover || inline) {
93
+ const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);
94
+ setCurrentOption(options[nextItemIndex].dsId);
95
+ scrollOptionIntoView(options[nextItemIndex].dsId);
96
+ } else {
97
+ setShowPopover(true);
98
+ }
99
+ }
100
+
101
+ if (e.key === 'ArrowUp') {
102
+ e.preventDefault();
103
+
104
+ if (showPopover || inline) {
105
+ const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);
106
+ setCurrentOption(options[nextItemIndex].dsId);
107
+ scrollOptionIntoView(options[nextItemIndex].dsId);
108
+ } else {
109
+ setShowPopover(true);
110
+ setTimeout(() => {
111
+ const nextItemIndex = findInCircularList(options, 0, isOptionFocuseable, -1);
112
+ setCurrentOption(options[nextItemIndex].dsId);
113
+ scrollOptionIntoView(options[nextItemIndex].dsId);
114
+ });
115
+ }
116
+ } // =============================================================================
117
+ // ESCAPE
118
+ // =============================================================================
119
+
120
+
121
+ if (e.key === 'Escape' && !inline) {
122
+ setShowPopover(false); // TODO confirm funcionality
123
+ // onFilter('');
124
+ // inputRef.current.value = '';
125
+ } // =============================================================================
126
+ // BACKSPACE
127
+ // =============================================================================
128
+
129
+
130
+ if (e.key === 'Backspace' && targetElement.value.length <= 0 && !inline) {
131
+ if (multiple && !targetElement.value) {
132
+ if (selectedValues.length > 0) onChange(selectedValues[selectedValues.length - 1]);
133
+ } else {
134
+ onChange(null);
135
+ }
136
+
137
+ onFilter('');
138
+ setShowSelectedValue(true);
139
+ }
140
+
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
+ };
146
+ };
147
+
148
+ export { useKeyboardNavigation };
@@ -0,0 +1,33 @@
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import { useState, useRef, useEffect, useMemo } from 'react';
3
+
4
+ // Taken and modified from https://stackoverflow.com/a/60218754
5
+
6
+ const useOnElementResize = targetRef => {
7
+ var _targetRef$current, _targetRef$current2;
8
+
9
+ const [width, setWidth] = useState(targetRef.current ? (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth : 0);
10
+ const [height, setHeight] = useState(targetRef.current ? (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetWidth : 0);
11
+ const observer = useRef(null);
12
+ useEffect(() => {
13
+ function outputsize() {
14
+ if (targetRef.current) {
15
+ setWidth(targetRef.current.offsetWidth);
16
+ setHeight(targetRef.current.offsetHeight);
17
+ }
18
+ }
19
+
20
+ observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
21
+ return () => {
22
+ var _observer$current;
23
+
24
+ (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
25
+ };
26
+ }, [targetRef]);
27
+ return useMemo(() => ({
28
+ width,
29
+ height
30
+ }), [width, height]);
31
+ };
32
+
33
+ export { useOnElementResize };
@@ -0,0 +1,30 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.some.js';
5
+ import 'core-js/modules/esnext.iterator.some.js';
6
+
7
+ const getSelectableOptions = options => options ? options.filter(option => option.type === 'option' && !option.disabled) : [];
8
+ const getOptions = options => options ? options.filter(option => option.type === 'option') : [];
9
+ const isSelectedValueEmpty = value => Array.isArray(value) ? value.length === 0 : !value;
10
+ 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
+ const singleValue = value;
18
+ return (singleValue === null || singleValue === void 0 ? void 0 : singleValue.value) === activeOption.value;
19
+ };
20
+ const findInCircularList = function (list, from, criteria) {
21
+ let step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
22
+
23
+ for (let i = (from + step + list.length) % list.length; i !== from; i = (i + step + list.length) % list.length) {
24
+ if (criteria(list[i])) return i;
25
+ }
26
+
27
+ return from; // return same item
28
+ };
29
+
30
+ export { findInCircularList, getOptions, getSelectableOptions, isSelected, isSelectedValueEmpty, isSelectedValueMultiple };
@@ -9,6 +9,7 @@ import 'react';
9
9
  import { noop } from 'lodash';
10
10
  import '../ComboBox/v1/DSComboBox.js';
11
11
  import { DSComboBox2 } from '../ComboBox/v2/Combobox.js';
12
+ import '../ComboBox/v3/ComboBox.js';
12
13
  import { MultiValueLabel } from './components/MultiValueLabel.js';
13
14
  import { MultiValueRemove } from './components/MultiValueRemove.js';
14
15
  import { SingleValue } from './components/SingleValue.js';
package/esm/index.js CHANGED
@@ -2,6 +2,7 @@ export { CheckboxWithSchema, DSCheckbox } from './Checkbox/DSCheckbox.js';
2
2
  export { DSCheckboxGroup, DSCheckboxGroupWithSchema } from './CheckboxGroup/DSCheckboxGroup.js';
3
3
  import './ComboBox/v1/DSComboBox.js';
4
4
  export { ComboBoxWithSchema, DSComboBox2 as DSComboBox, DSComboBox2 } from './ComboBox/v2/Combobox.js';
5
+ export { DSComboBoxWithSchema } from './ComboBox/v3/ComboBox.js';
5
6
  export { default as ComboBoxFreeSolo } from './ComboBoxFreeSolo/ComboBoxFreeSolo.js';
6
7
  export { default as DSDateInput, DSDateInputWithSchema } from './DateInput/DSDateInput.js';
7
8
  export { DateInputs as DateInputsV2Impl } from './DateInputV2/components/DateInputs.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-form",
3
- "version": "2.1.0-rc.7",
3
+ "version": "2.2.0-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Form",
6
6
  "module": "./esm/index.js",
@@ -511,6 +511,190 @@
511
511
  "import": "./esm/ComboBoxFreeSolo/ComboBoxFreeSolo.js",
512
512
  "require": "./cjs/ComboBoxFreeSolo/ComboBoxFreeSolo.js"
513
513
  },
514
+ "./ComboBox/v3/utils/listHelper": {
515
+ "import": "./esm/ComboBox/v3/utils/listHelper.js",
516
+ "require": "./cjs/ComboBox/v3/utils/listHelper.js"
517
+ },
518
+ "./ComboBox/v3/utils/hooks/useOnElementResize": {
519
+ "import": "./esm/ComboBox/v3/utils/hooks/useOnElementResize.js",
520
+ "require": "./cjs/ComboBox/v3/utils/hooks/useOnElementResize.js"
521
+ },
522
+ "./ComboBox/v3/utils/hooks/useKeyboardNavigation": {
523
+ "import": "./esm/ComboBox/v3/utils/hooks/useKeyboardNavigation.js",
524
+ "require": "./cjs/ComboBox/v3/utils/hooks/useKeyboardNavigation.js"
525
+ },
526
+ "./ComboBox/v3/tests/utils": {
527
+ "import": "./esm/ComboBox/v3/tests/utils.js",
528
+ "require": "./cjs/ComboBox/v3/tests/utils.js"
529
+ },
530
+ "./ComboBox/v3/propTypes": {
531
+ "import": "./esm/ComboBox/v3/propTypes.js",
532
+ "require": "./cjs/ComboBox/v3/propTypes.js"
533
+ },
534
+ "./ComboBox/v3/parts/single-selected-value-container/styled": {
535
+ "import": "./esm/ComboBox/v3/parts/single-selected-value-container/styled.js",
536
+ "require": "./cjs/ComboBox/v3/parts/single-selected-value-container/styled.js"
537
+ },
538
+ "./ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer": {
539
+ "import": "./esm/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js",
540
+ "require": "./cjs/ComboBox/v3/parts/single-selected-value-container/SingleSelectedValueContainer.js"
541
+ },
542
+ "./ComboBox/v3/parts/single-selected-value-container": {
543
+ "import": "./esm/ComboBox/v3/parts/single-selected-value-container/index.js",
544
+ "require": "./cjs/ComboBox/v3/parts/single-selected-value-container/index.js"
545
+ },
546
+ "./ComboBox/v3/parts/multi-selected-values-container/useGroupPills": {
547
+ "import": "./esm/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js",
548
+ "require": "./cjs/ComboBox/v3/parts/multi-selected-values-container/useGroupPills.js"
549
+ },
550
+ "./ComboBox/v3/parts/multi-selected-values-container/styled": {
551
+ "import": "./esm/ComboBox/v3/parts/multi-selected-values-container/styled.js",
552
+ "require": "./cjs/ComboBox/v3/parts/multi-selected-values-container/styled.js"
553
+ },
554
+ "./ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer": {
555
+ "import": "./esm/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js",
556
+ "require": "./cjs/ComboBox/v3/parts/multi-selected-values-container/MultiSelectedValuesContainer.js"
557
+ },
558
+ "./ComboBox/v3/parts/multi-selected-values-container": {
559
+ "import": "./esm/ComboBox/v3/parts/multi-selected-values-container/index.js",
560
+ "require": "./cjs/ComboBox/v3/parts/multi-selected-values-container/index.js"
561
+ },
562
+ "./ComboBox/v3/parts/menu-list/useMenuList": {
563
+ "import": "./esm/ComboBox/v3/parts/menu-list/useMenuList.js",
564
+ "require": "./cjs/ComboBox/v3/parts/menu-list/useMenuList.js"
565
+ },
566
+ "./ComboBox/v3/parts/menu-list/useItemRenderer": {
567
+ "import": "./esm/ComboBox/v3/parts/menu-list/useItemRenderer.js",
568
+ "require": "./cjs/ComboBox/v3/parts/menu-list/useItemRenderer.js"
569
+ },
570
+ "./ComboBox/v3/parts/menu-list/styled": {
571
+ "import": "./esm/ComboBox/v3/parts/menu-list/styled.js",
572
+ "require": "./cjs/ComboBox/v3/parts/menu-list/styled.js"
573
+ },
574
+ "./ComboBox/v3/parts/menu-list/MenuList": {
575
+ "import": "./esm/ComboBox/v3/parts/menu-list/MenuList.js",
576
+ "require": "./cjs/ComboBox/v3/parts/menu-list/MenuList.js"
577
+ },
578
+ "./ComboBox/v3/parts/menu-list": {
579
+ "import": "./esm/ComboBox/v3/parts/menu-list/index.js",
580
+ "require": "./cjs/ComboBox/v3/parts/menu-list/index.js"
581
+ },
582
+ "./ComboBox/v3/parts/header-list/useHeaderListHandlers": {
583
+ "import": "./esm/ComboBox/v3/parts/header-list/useHeaderListHandlers.js",
584
+ "require": "./cjs/ComboBox/v3/parts/header-list/useHeaderListHandlers.js"
585
+ },
586
+ "./ComboBox/v3/parts/header-list/styled": {
587
+ "import": "./esm/ComboBox/v3/parts/header-list/styled.js",
588
+ "require": "./cjs/ComboBox/v3/parts/header-list/styled.js"
589
+ },
590
+ "./ComboBox/v3/parts/header-list": {
591
+ "import": "./esm/ComboBox/v3/parts/header-list/index.js",
592
+ "require": "./cjs/ComboBox/v3/parts/header-list/index.js"
593
+ },
594
+ "./ComboBox/v3/parts/header-list/HeaderList": {
595
+ "import": "./esm/ComboBox/v3/parts/header-list/HeaderList.js",
596
+ "require": "./cjs/ComboBox/v3/parts/header-list/HeaderList.js"
597
+ },
598
+ "./ComboBox/v3/parts/empty-state/styled": {
599
+ "import": "./esm/ComboBox/v3/parts/empty-state/styled.js",
600
+ "require": "./cjs/ComboBox/v3/parts/empty-state/styled.js"
601
+ },
602
+ "./ComboBox/v3/parts/empty-state": {
603
+ "import": "./esm/ComboBox/v3/parts/empty-state/index.js",
604
+ "require": "./cjs/ComboBox/v3/parts/empty-state/index.js"
605
+ },
606
+ "./ComboBox/v3/parts/dropdown-indicator/styled": {
607
+ "import": "./esm/ComboBox/v3/parts/dropdown-indicator/styled.js",
608
+ "require": "./cjs/ComboBox/v3/parts/dropdown-indicator/styled.js"
609
+ },
610
+ "./ComboBox/v3/parts/dropdown-indicator": {
611
+ "import": "./esm/ComboBox/v3/parts/dropdown-indicator/index.js",
612
+ "require": "./cjs/ComboBox/v3/parts/dropdown-indicator/index.js"
613
+ },
614
+ "./ComboBox/v3/parts/dropdown-indicator/DropdownIndicator": {
615
+ "import": "./esm/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js",
616
+ "require": "./cjs/ComboBox/v3/parts/dropdown-indicator/DropdownIndicator.js"
617
+ },
618
+ "./ComboBox/v3/parts/controls/styled": {
619
+ "import": "./esm/ComboBox/v3/parts/controls/styled.js",
620
+ "require": "./cjs/ComboBox/v3/parts/controls/styled.js"
621
+ },
622
+ "./ComboBox/v3/parts/controls": {
623
+ "import": "./esm/ComboBox/v3/parts/controls/index.js",
624
+ "require": "./cjs/ComboBox/v3/parts/controls/index.js"
625
+ },
626
+ "./ComboBox/v3/parts/controls/Controls": {
627
+ "import": "./esm/ComboBox/v3/parts/controls/Controls.js",
628
+ "require": "./cjs/ComboBox/v3/parts/controls/Controls.js"
629
+ },
630
+ "./ComboBox/v3/parts/controls-input/useControlsInput": {
631
+ "import": "./esm/ComboBox/v3/parts/controls-input/useControlsInput.js",
632
+ "require": "./cjs/ComboBox/v3/parts/controls-input/useControlsInput.js"
633
+ },
634
+ "./ComboBox/v3/parts/controls-input/styled": {
635
+ "import": "./esm/ComboBox/v3/parts/controls-input/styled.js",
636
+ "require": "./cjs/ComboBox/v3/parts/controls-input/styled.js"
637
+ },
638
+ "./ComboBox/v3/parts/controls-input/ControlsInput": {
639
+ "import": "./esm/ComboBox/v3/parts/controls-input/ControlsInput.js",
640
+ "require": "./cjs/ComboBox/v3/parts/controls-input/ControlsInput.js"
641
+ },
642
+ "./ComboBox/v3/parts/container/styled": {
643
+ "import": "./esm/ComboBox/v3/parts/container/styled.js",
644
+ "require": "./cjs/ComboBox/v3/parts/container/styled.js"
645
+ },
646
+ "./ComboBox/v3/parts/container": {
647
+ "import": "./esm/ComboBox/v3/parts/container/index.js",
648
+ "require": "./cjs/ComboBox/v3/parts/container/index.js"
649
+ },
650
+ "./ComboBox/v3/parts/container/Container": {
651
+ "import": "./esm/ComboBox/v3/parts/container/Container.js",
652
+ "require": "./cjs/ComboBox/v3/parts/container/Container.js"
653
+ },
654
+ "./ComboBox/v3/parts/a11y-messages/styled": {
655
+ "import": "./esm/ComboBox/v3/parts/a11y-messages/styled.js",
656
+ "require": "./cjs/ComboBox/v3/parts/a11y-messages/styled.js"
657
+ },
658
+ "./ComboBox/v3/parts/a11y-messages/SingleAllyMessages": {
659
+ "import": "./esm/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js",
660
+ "require": "./cjs/ComboBox/v3/parts/a11y-messages/SingleAllyMessages.js"
661
+ },
662
+ "./ComboBox/v3/parts/a11y-messages/MultiAllyMessages": {
663
+ "import": "./esm/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js",
664
+ "require": "./cjs/ComboBox/v3/parts/a11y-messages/MultiAllyMessages.js"
665
+ },
666
+ "./ComboBox/v3/parts/a11y-messages": {
667
+ "import": "./esm/ComboBox/v3/parts/a11y-messages/index.js",
668
+ "require": "./cjs/ComboBox/v3/parts/a11y-messages/index.js"
669
+ },
670
+ "./ComboBox/v3": {
671
+ "import": "./esm/ComboBox/v3/index.js",
672
+ "require": "./cjs/ComboBox/v3/index.js"
673
+ },
674
+ "./ComboBox/v3/config/useGetPropsWithDefault": {
675
+ "import": "./esm/ComboBox/v3/config/useGetPropsWithDefault.js",
676
+ "require": "./cjs/ComboBox/v3/config/useGetPropsWithDefault.js"
677
+ },
678
+ "./ComboBox/v3/config/useComboBox": {
679
+ "import": "./esm/ComboBox/v3/config/useComboBox.js",
680
+ "require": "./cjs/ComboBox/v3/config/useComboBox.js"
681
+ },
682
+ "./ComboBox/v3/config/constants": {
683
+ "import": "./esm/ComboBox/v3/config/constants.js",
684
+ "require": "./cjs/ComboBox/v3/config/constants.js"
685
+ },
686
+ "./ComboBox/v3/ComboboxDataTestids": {
687
+ "import": "./esm/ComboBox/v3/ComboboxDataTestids.js",
688
+ "require": "./cjs/ComboBox/v3/ComboboxDataTestids.js"
689
+ },
690
+ "./ComboBox/v3/ComboBoxCTX": {
691
+ "import": "./esm/ComboBox/v3/ComboBoxCTX.js",
692
+ "require": "./cjs/ComboBox/v3/ComboBoxCTX.js"
693
+ },
694
+ "./ComboBox/v3/ComboBox": {
695
+ "import": "./esm/ComboBox/v3/ComboBox.js",
696
+ "require": "./cjs/ComboBox/v3/ComboBox.js"
697
+ },
514
698
  "./ComboBox/v2/mockOptions": {
515
699
  "import": "./esm/ComboBox/v2/mockOptions.js",
516
700
  "require": "./cjs/ComboBox/v2/mockOptions.js"
@@ -748,28 +932,28 @@
748
932
  "build": "node ../../scripts/build/build.js"
749
933
  },
750
934
  "dependencies": {
751
- "@elliemae/ds-button": "2.1.0-rc.7",
752
- "@elliemae/ds-circular-progress-indicator": "2.1.0-rc.7",
753
- "@elliemae/ds-classnames": "2.1.0-rc.7",
754
- "@elliemae/ds-controlled-form": "2.1.0-rc.7",
755
- "@elliemae/ds-dropdownmenu": "2.1.0-rc.7",
756
- "@elliemae/ds-form": "2.1.0-rc.7",
757
- "@elliemae/ds-grid": "2.1.0-rc.7",
758
- "@elliemae/ds-icon": "2.1.0-rc.7",
759
- "@elliemae/ds-icons": "2.1.0-rc.7",
760
- "@elliemae/ds-menu": "2.1.0-rc.7",
761
- "@elliemae/ds-overlay": "2.1.0-rc.7",
762
- "@elliemae/ds-pills": "2.1.0-rc.7",
763
- "@elliemae/ds-popper": "2.1.0-rc.7",
764
- "@elliemae/ds-popperjs": "2.1.0-rc.7",
765
- "@elliemae/ds-props-helpers": "2.1.0-rc.7",
766
- "@elliemae/ds-separator": "2.1.0-rc.7",
767
- "@elliemae/ds-shared": "2.1.0-rc.7",
768
- "@elliemae/ds-system": "2.1.0-rc.7",
769
- "@elliemae/ds-text-wrapper": "2.1.0-rc.7",
770
- "@elliemae/ds-tooltip": "2.1.0-rc.7",
771
- "@elliemae/ds-truncated-tooltip-text": "2.1.0-rc.7",
772
- "@elliemae/ds-utilities": "2.1.0-rc.7",
935
+ "@elliemae/ds-button": "2.2.0-alpha.1",
936
+ "@elliemae/ds-circular-progress-indicator": "2.2.0-alpha.1",
937
+ "@elliemae/ds-classnames": "2.2.0-alpha.1",
938
+ "@elliemae/ds-controlled-form": "2.2.0-alpha.1",
939
+ "@elliemae/ds-dropdownmenu": "2.2.0-alpha.1",
940
+ "@elliemae/ds-form": "2.2.0-alpha.1",
941
+ "@elliemae/ds-grid": "2.2.0-alpha.1",
942
+ "@elliemae/ds-icon": "2.2.0-alpha.1",
943
+ "@elliemae/ds-icons": "2.2.0-alpha.1",
944
+ "@elliemae/ds-menu": "2.2.0-alpha.1",
945
+ "@elliemae/ds-overlay": "2.2.0-alpha.1",
946
+ "@elliemae/ds-pills": "2.2.0-alpha.1",
947
+ "@elliemae/ds-popper": "2.2.0-alpha.1",
948
+ "@elliemae/ds-popperjs": "2.2.0-alpha.1",
949
+ "@elliemae/ds-props-helpers": "2.2.0-alpha.1",
950
+ "@elliemae/ds-separator": "2.2.0-alpha.1",
951
+ "@elliemae/ds-shared": "2.2.0-alpha.1",
952
+ "@elliemae/ds-system": "2.2.0-alpha.1",
953
+ "@elliemae/ds-text-wrapper": "2.2.0-alpha.1",
954
+ "@elliemae/ds-tooltip": "2.2.0-alpha.1",
955
+ "@elliemae/ds-truncated-tooltip-text": "2.2.0-alpha.1",
956
+ "@elliemae/ds-utilities": "2.2.0-alpha.1",
773
957
  "memoize-one": "~5.1.1",
774
958
  "moment": "~2.29.1",
775
959
  "prop-types": "~15.7.2",
@@ -1,3 +1,4 @@
1
1
  export * from './v1/DSComboBox';
2
2
  export * from './v2';
3
3
  export { default } from './v2';
4
+ export * from './v3';