@elliemae/ds-controlled-form 2.4.1-rc.4 → 2.4.1-rc.5

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 (157) 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 +8 -3
  34. package/cjs/mask-hook/hooks/index.js +7 -3
  35. package/cjs/mask-hook/hooks/useNumberMask.js +5 -0
  36. package/cjs/mask-hook/hooks/usePhoneMask.js +5 -0
  37. package/cjs/mask-hook/hooks/useSSNMask.js +5 -0
  38. package/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +10 -5
  39. package/cjs/mask-hook/index.js +7 -3
  40. package/esm/autocomplete/Autocomplete.js +2 -3
  41. package/esm/autocomplete/AutocompleteCTX.js +3 -14
  42. package/esm/autocomplete/AutocompleteDataTestids.js +1 -7
  43. package/esm/autocomplete/config/useAutocomplete.js +27 -14
  44. package/esm/autocomplete/parts/container/Container.js +38 -23
  45. package/esm/autocomplete/parts/container/styled.js +2 -5
  46. package/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +8 -24
  47. package/esm/autocomplete/parts/menu-list/MenuList.js +19 -52
  48. package/esm/autocomplete/parts/menu-list/styled.js +9 -10
  49. package/esm/autocomplete/parts/menu-list/useItemRenderer.js +39 -45
  50. package/esm/autocomplete/react-desc-prop-types.js +5 -8
  51. package/esm/autocomplete/utils/listHelper.js +8 -16
  52. package/esm/checkbox/react-desc-prop-types.js +1 -0
  53. package/esm/combobox/ComboBox.js +1 -1
  54. package/esm/combobox/config/useComboBox.js +8 -2
  55. package/esm/combobox/config/useCorrectOptions.js +15 -43
  56. package/esm/combobox/index.js +1 -1
  57. package/esm/combobox/parts/A11yFocusedOption.js +3 -3
  58. package/esm/combobox/parts/controls/Controls.js +4 -2
  59. package/esm/combobox/parts/controls-input/ControlsInput.js +2 -0
  60. package/esm/combobox/parts/controls-input/styled.js +1 -1
  61. package/esm/combobox/parts/controls-input/useControlsInput.js +6 -6
  62. package/esm/combobox/parts/controls-input/useKeyboardNavigation.js +30 -26
  63. package/esm/combobox/parts/controls-input/useMaskedOnChange.js +7 -5
  64. package/esm/combobox/parts/dropdown-indicator/DropdownIndicator.js +2 -2
  65. package/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
  66. package/esm/combobox/parts/menu-list/MenuList.js +13 -7
  67. package/esm/combobox/parts/menu-list/styled.js +16 -5
  68. package/esm/combobox/parts/menu-list/useItemRenderer.js +8 -8
  69. package/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +6 -6
  70. package/esm/combobox/react-desc-prop-types.js +2 -1
  71. package/esm/combobox/utils/listHelper.js +38 -12
  72. package/esm/index.js +5 -5
  73. package/esm/mask-hook/hooks/index.js +4 -4
  74. package/esm/mask-hook/hooks/useNumberMask.js +5 -1
  75. package/esm/mask-hook/hooks/usePhoneMask.js +5 -1
  76. package/esm/mask-hook/hooks/useSSNMask.js +5 -1
  77. package/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +9 -5
  78. package/esm/mask-hook/index.js +4 -4
  79. package/package.json +24 -80
  80. package/types/autocomplete/Autocomplete.d.ts +4 -61
  81. package/types/autocomplete/AutocompleteCTX.d.ts +4 -3
  82. package/types/autocomplete/AutocompleteDataTestids.d.ts +1 -7
  83. package/types/autocomplete/config/useAutocomplete.d.ts +3 -2
  84. package/types/autocomplete/parts/container/Container.d.ts +1 -2
  85. package/types/autocomplete/parts/container/styled.d.ts +0 -1
  86. package/types/autocomplete/parts/{controls → container}/useKeyboardNavigation.d.ts +0 -0
  87. package/types/autocomplete/parts/menu-list/MenuList.d.ts +1 -2
  88. package/types/autocomplete/parts/menu-list/styled.d.ts +1 -4
  89. package/types/autocomplete/parts/menu-list/useItemRenderer.d.ts +2 -3
  90. package/types/autocomplete/react-desc-prop-types.d.ts +8 -18
  91. package/types/autocomplete/sharedTypes.d.ts +1 -3
  92. package/types/autocomplete/tests/general.test.d.ts +1 -0
  93. package/types/autocomplete/tests/utils.d.ts +5 -0
  94. package/types/autocomplete/utils/listHelper.d.ts +2 -2
  95. package/types/checkbox/ControlledCheckbox.d.ts +1 -1
  96. package/types/checkbox/react-desc-prop-types.d.ts +366 -1
  97. package/types/combobox/ComboBox.d.ts +2 -2
  98. package/types/combobox/parts/dropdown-indicator/DropdownIndicator.d.ts +1 -0
  99. package/types/combobox/react-desc-prop-types.d.ts +381 -3
  100. package/types/combobox/utils/listHelper.d.ts +4 -1
  101. package/types/large-text-input/DSControlledLargeTextInput.d.ts +1 -1
  102. package/types/large-text-input/react-desc-prop-types.d.ts +422 -1
  103. package/types/mask-hook/hooks/index.d.ts +1 -1
  104. package/types/mask-hook/hooks/useNumberMask.d.ts +2 -1
  105. package/types/mask-hook/hooks/usePhoneMask.d.ts +2 -1
  106. package/types/mask-hook/hooks/useSSNMask.d.ts +2 -1
  107. package/types/mask-hook/hooks/useZipCodeMask.d.ts +4 -0
  108. package/types/text-input/DSInputText.d.ts +1 -1
  109. package/types/text-input/config/useInputText.d.ts +110 -110
  110. package/cjs/autocomplete/config/constants.js +0 -14
  111. package/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -11
  112. package/cjs/autocomplete/index.d.js +0 -2
  113. package/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -33
  114. package/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -28
  115. package/cjs/autocomplete/parts/a11y-messages/index.js +0 -11
  116. package/cjs/autocomplete/parts/a11y-messages/styled.js +0 -15
  117. package/cjs/autocomplete/parts/controls/Controls.js +0 -63
  118. package/cjs/autocomplete/parts/controls/index.js +0 -9
  119. package/cjs/autocomplete/parts/controls/styled.js +0 -44
  120. package/cjs/autocomplete/parts/controls/useControlsInput.js +0 -44
  121. package/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -28
  122. package/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -69
  123. package/cjs/autocomplete/propTypes.js +0 -25
  124. package/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -97
  125. package/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -37
  126. package/esm/autocomplete/config/constants.js +0 -10
  127. package/esm/autocomplete/config/useGetPropsWithDefault.js +0 -7
  128. package/esm/autocomplete/index.d.js +0 -1
  129. package/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -25
  130. package/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -20
  131. package/esm/autocomplete/parts/a11y-messages/index.js +0 -2
  132. package/esm/autocomplete/parts/a11y-messages/styled.js +0 -7
  133. package/esm/autocomplete/parts/controls/Controls.js +0 -55
  134. package/esm/autocomplete/parts/controls/index.js +0 -1
  135. package/esm/autocomplete/parts/controls/styled.js +0 -32
  136. package/esm/autocomplete/parts/controls/useControlsInput.js +0 -40
  137. package/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -24
  138. package/esm/autocomplete/parts/menu-list/useMenuList.js +0 -65
  139. package/esm/autocomplete/propTypes.js +0 -21
  140. package/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -93
  141. package/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -33
  142. package/types/autocomplete/config/constants.d.ts +0 -8
  143. package/types/autocomplete/config/useGetPropsWithDefault.d.ts +0 -2
  144. package/types/autocomplete/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
  145. package/types/autocomplete/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
  146. package/types/autocomplete/parts/a11y-messages/index.d.ts +0 -2
  147. package/types/autocomplete/parts/a11y-messages/styled.d.ts +0 -1
  148. package/types/autocomplete/parts/controls/Controls.d.ts +0 -3
  149. package/types/autocomplete/parts/controls/index.d.ts +0 -1
  150. package/types/autocomplete/parts/controls/styled.d.ts +0 -8
  151. package/types/autocomplete/parts/controls/useControlsInput.d.ts +0 -9
  152. package/types/autocomplete/parts/controls/useMaskedOnChange.d.ts +0 -2
  153. package/types/autocomplete/parts/menu-list/useMenuList.d.ts +0 -2
  154. package/types/autocomplete/propTypes.d.ts +0 -51
  155. package/types/autocomplete/utils/hooks/useKeyboardNavigation.d.ts +0 -4
  156. package/types/autocomplete/utils/hooks/useOnElementResize.d.ts +0 -3
  157. package/types/mask-hook/hooks/useZipCode.d.ts +0 -3
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var AutocompleteCTX = require('../../AutocompleteCTX.js');
7
-
8
- const useMaskedOnChange = () => {
9
- const {
10
- props: {
11
- useMask,
12
- onChange
13
- },
14
- setShowPopover
15
- } = React.useContext(AutocompleteCTX.AutocompleteContext); // default onchange when no mask provided
16
-
17
- const handleOnChange = React.useCallback(e => {
18
- setShowPopover(true);
19
- onChange(e.target.value);
20
- }, [onChange, setShowPopover]);
21
- const onChangeMask = useMask({
22
- valueSetter: setInputValue,
23
- onChange: handleOnChange
24
- });
25
- return (onChangeMask === null || onChangeMask === void 0 ? void 0 : onChangeMask.onChange) || handleOnChange;
26
- };
27
-
28
- exports.useMaskedOnChange = useMaskedOnChange;
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var AutocompleteCTX = require('../../AutocompleteCTX.js');
7
-
8
- const useMenuList = () => {
9
- var _inputRef$current3;
10
-
11
- const {
12
- props: {
13
- selectedValues,
14
- onMenuOpen,
15
- options
16
- },
17
- inputRef,
18
- setCurrentOption,
19
- scrollOptionIntoView,
20
- setShowPopover,
21
- showPopover
22
- } = React.useContext(AutocompleteCTX.AutocompleteContext);
23
- React.useEffect(() => {
24
- var _inputRef$current;
25
-
26
- if (options.length === 0 || ((_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) === '') {
27
- setShowPopover(false);
28
- }
29
- }, [options, inputRef, setShowPopover]);
30
- React.useEffect(() => {
31
- const getFirstOption = () => {
32
- for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type)) {
33
- setCurrentOption(options[i].dsId);
34
- break;
35
- }
36
- };
37
-
38
- if (showPopover) {
39
- var _inputRef$current2;
40
-
41
- onMenuOpen();
42
-
43
- if (((_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.value) !== '') {
44
- getFirstOption();
45
- } else if (Array.isArray(selectedValues)) {
46
- const multiSelectedValues = selectedValues;
47
-
48
- if (multiSelectedValues.length > 0) {
49
- setCurrentOption(multiSelectedValues[multiSelectedValues.length - 1].dsId);
50
- scrollOptionIntoView(multiSelectedValues[multiSelectedValues.length - 1].dsId);
51
- } else {
52
- getFirstOption();
53
- }
54
- } else {
55
- const singleSelectedValue = selectedValues;
56
-
57
- if (singleSelectedValue) {
58
- setCurrentOption(selectedValues.dsId);
59
- scrollOptionIntoView(selectedValues.dsId);
60
- } else {
61
- getFirstOption();
62
- }
63
- }
64
- } // eslint-disable-next-line react-hooks/exhaustive-deps
65
-
66
- }, [showPopover, (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value]);
67
- };
68
-
69
- exports.useMenuList = useMenuList;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactDesc = require('react-desc');
6
-
7
- const propTypes = {
8
- placeholder: reactDesc.PropTypes.string.description('input s placeholder value').defaultValue(''),
9
- options: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.array, reactDesc.PropTypes.object]).description('List of options').defaultValue([]),
10
- selectedValues: reactDesc.PropTypes.oneOfType([reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.object), reactDesc.PropTypes.object, reactDesc.PropTypes.string]).description('Array of option or single option selected'),
11
- autoFocus: reactDesc.PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),
12
- hasError: reactDesc.PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),
13
- onChange: reactDesc.PropTypes.func.description('function triggered when an option is selected it will send the options selected').defaultValue(''),
14
- onSelectAll: reactDesc.PropTypes.func.description('function triggered when ALL button is selected from the header menu list').defaultValue(''),
15
- onFilter: reactDesc.PropTypes.func.description('function triggered when user type in the autocomplete input').defaultValue(''),
16
- onCreate: reactDesc.PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(''),
17
- onClearAll: reactDesc.PropTypes.func.description('function triggered when user select CLEAR button from the header menu list').defaultValue(''),
18
- onMenuOpen: reactDesc.PropTypes.func.description('function triggered when user open the menu list').defaultValue(''),
19
- inputMinWidth: reactDesc.PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),
20
- menuMinWidth: reactDesc.PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),
21
- menuMaxHeight: reactDesc.PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),
22
- withToggle: reactDesc.PropTypes.bool.description('POC purpose this prop will not remain').defaultValue('false')
23
- };
24
-
25
- exports.propTypes = propTypes;
@@ -1,97 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.find.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.find.js');
8
- var React = require('react');
9
- var AutocompleteCTX = require('../../AutocompleteCTX.js');
10
- var listHelper = require('../listHelper.js');
11
-
12
- const isOptionFocuseable = opt => !['section', 'separator'].includes(opt.type);
13
-
14
- const useKeyboardNavigation = () => {
15
- const {
16
- props: {
17
- onKeyDown,
18
- onChange,
19
- options,
20
- onFilter
21
- },
22
- setShowPopover,
23
- showPopover,
24
- focusOptionIdx,
25
- inputRef,
26
- setCurrentOption,
27
- scrollOptionIntoView
28
- } = React.useContext(AutocompleteCTX.AutocompleteContext);
29
- const currentItemIndex = options.findIndex(opt => opt.dsId === focusOptionIdx);
30
- const currentItem = options.find(item => item.dsId === focusOptionIdx);
31
- const selectOption = React.useCallback(() => {
32
- if (inputRef.current) inputRef.current.value = currentItem.label;
33
- if (onFilter) onFilter(currentItem.label);
34
- onChange(currentItem.label);
35
- setShowPopover(false);
36
- }, [currentItem, setShowPopover, onFilter, inputRef, onChange]);
37
- const onInputKeyDown = React.useCallback(e => {
38
- const targetElement = e.target; // =============================================================================
39
- // CUSTOM KEYS
40
- // =============================================================================
41
-
42
- onKeyDown(e, currentItem); // =============================================================================
43
- // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER
44
- // =============================================================================
45
-
46
- if (e.keyCode === 32 && targetElement.value === '' || e.key === 'Enter') {
47
- if (showPopover) {
48
- e.preventDefault();
49
- selectOption();
50
- }
51
- } // =============================================================================
52
- // ARROWS UP AND DOWN
53
- // =============================================================================
54
-
55
-
56
- if (e.key === 'ArrowDown') {
57
- e.preventDefault();
58
-
59
- if (showPopover) {
60
- const nextItemIndex = listHelper.findInCircularList(options, currentItemIndex, isOptionFocuseable);
61
- setCurrentOption(options[nextItemIndex].dsId);
62
- scrollOptionIntoView(options[nextItemIndex].dsId);
63
- } else {
64
- setShowPopover(true);
65
- }
66
- }
67
-
68
- if (e.key === 'ArrowUp') {
69
- e.preventDefault();
70
-
71
- if (showPopover) {
72
- const nextItemIndex = listHelper.findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);
73
- setCurrentOption(options[nextItemIndex].dsId);
74
- scrollOptionIntoView(options[nextItemIndex].dsId);
75
- } else {
76
- setShowPopover(true);
77
- setTimeout(() => {
78
- const nextItemIndex = listHelper.findInCircularList(options, 0, isOptionFocuseable, -1);
79
- setCurrentOption(options[nextItemIndex].dsId);
80
- scrollOptionIntoView(options[nextItemIndex].dsId);
81
- });
82
- }
83
- } // =============================================================================
84
- // ESCAPE
85
- // =============================================================================
86
-
87
-
88
- if (e.key === 'Escape') {
89
- setShowPopover(false);
90
- }
91
- }, [scrollOptionIntoView, currentItemIndex, options, currentItem, showPopover, onKeyDown, setCurrentOption, setShowPopover, selectOption]);
92
- return {
93
- onInputKeyDown
94
- };
95
- };
96
-
97
- exports.useKeyboardNavigation = useKeyboardNavigation;
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/web.dom-collections.iterator.js');
6
- var React = require('react');
7
-
8
- // Taken and modified from https://stackoverflow.com/a/60218754
9
-
10
- const useOnElementResize = targetRef => {
11
- var _targetRef$current, _targetRef$current2;
12
-
13
- const [width, setWidth] = React.useState(targetRef.current ? (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth : 0);
14
- const [height, setHeight] = React.useState(targetRef.current ? (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetWidth : 0);
15
- const observer = React.useRef(null);
16
- React.useEffect(() => {
17
- function outputsize() {
18
- if (targetRef.current) {
19
- setWidth(targetRef.current.offsetWidth);
20
- setHeight(targetRef.current.offsetHeight);
21
- }
22
- }
23
-
24
- observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
25
- return () => {
26
- var _observer$current;
27
-
28
- (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
29
- };
30
- }, [targetRef]);
31
- return React.useMemo(() => ({
32
- width,
33
- height
34
- }), [width, height]);
35
- };
36
-
37
- exports.useOnElementResize = useOnElementResize;
@@ -1,10 +0,0 @@
1
- const DATA_TESTID = {
2
- COMBOBOX_MENU_LIST: 'autocomplete-menu-list',
3
- COMBOBOX_CLEAR_BTN: 'autocomplete-clear-btn',
4
- COMBOBOX_ALL_BTN: 'autocomplete-all-btn',
5
- COMBOBOX_DROPDOWN_BTN: 'autocomplete-dropdown-btn',
6
- COMBOBOX_OPTION: 'autocomplete-option',
7
- COMBOBOX: 'autocomplete'
8
- };
9
-
10
- export { DATA_TESTID };
@@ -1,7 +0,0 @@
1
- import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
2
- import { defaultProps } from '../AutocompleteCTX.js';
3
-
4
- // we have to merge the "default" nested default values with what the user gives us...
5
- const useGetAutocompleteWithDefaultsProps = props => useMemoMergePropsWithDefault(props, defaultProps);
6
-
7
- export { useGetAutocompleteWithDefaultsProps };
@@ -1 +0,0 @@
1
-
@@ -1,25 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'core-js/modules/esnext.async-iterator.map.js';
3
- import 'core-js/modules/esnext.iterator.map.js';
4
- import { useContext } from 'react';
5
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
6
- import { getSelectableOptions } from '../../utils/listHelper.js';
7
- import { StyledA11ySelectedValues } from './styled.js';
8
-
9
- const MultiAllyMessages = () => {
10
- const {
11
- props: {
12
- options,
13
- selectedValues
14
- }
15
- } = useContext(AutocompleteContext);
16
- const selectableOptions = getSelectableOptions(options);
17
- const multipleSelectedValues = selectedValues;
18
- return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
19
- "aria-live": "polite",
20
- "aria-atomic": "false",
21
- "aria-relevant": "additions text"
22
- }, void 0, "Options selected: ".concat(multipleSelectedValues.map(item => item.label).join(', '), ". ").concat(multipleSelectedValues.length, " of ").concat(selectableOptions.length));
23
- };
24
-
25
- export { MultiAllyMessages };
@@ -1,20 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import { useContext } from 'react';
3
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
4
- import { StyledA11ySelectedValues } from './styled.js';
5
-
6
- const SingleAllyMessages = () => {
7
- const {
8
- props: {
9
- selectedValues
10
- }
11
- } = useContext(AutocompleteContext);
12
- const singleSelectedValue = selectedValues;
13
- return /*#__PURE__*/_jsx(StyledA11ySelectedValues, {
14
- "aria-live": "polite",
15
- "aria-atomic": "false",
16
- "aria-relevant": "additions text"
17
- }, void 0, "Option selected: ".concat(singleSelectedValue.label, "."));
18
- };
19
-
20
- export { SingleAllyMessages };
@@ -1,2 +0,0 @@
1
- export { MultiAllyMessages } from './MultiAllyMessages.js';
2
- export { SingleAllyMessages } from './SingleAllyMessages.js';
@@ -1,7 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- const StyledA11ySelectedValues = /*#__PURE__*/styled.span.withConfig({
4
- componentId: "sc-cm1aqq-0"
5
- })(["width:1px;height:1px;position:absolute;clip:rect(1px,1px,1px,1px);"]);
6
-
7
- export { StyledA11ySelectedValues };
@@ -1,55 +0,0 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import { useContext } from 'react';
3
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
4
- import { useKeyboardNavigation } from '../../utils/hooks/useKeyboardNavigation.js';
5
- import { useControlsInput } from './useControlsInput.js';
6
- import { StyledControlsWrapper, StyledInputWrapper, StyledInput } from './styled.js';
7
- import { jsx } from 'react/jsx-runtime';
8
-
9
- const Controls = () => {
10
- const {
11
- props: {
12
- autoFocus,
13
- hasError,
14
- placeholder,
15
- inputMinWidth
16
- },
17
- inputRef,
18
- showPopover,
19
- focusOptionIdx,
20
- controlsWrapperRef
21
- } = useContext(AutocompleteContext);
22
- const {
23
- onInputKeyDown
24
- } = useKeyboardNavigation();
25
- const {
26
- handleOnBlur,
27
- handleOnInputMouseDown,
28
- handleOnChange
29
- } = useControlsInput();
30
- return /*#__PURE__*/jsx(StyledControlsWrapper, {
31
- ref: controlsWrapperRef,
32
- cols: ['minmax(20px, auto)'],
33
- minWidth: inputMinWidth,
34
- hasError: hasError,
35
- children: /*#__PURE__*/_jsx(StyledInputWrapper, {}, void 0, /*#__PURE__*/jsx(StyledInput, {
36
- autoFocus: autoFocus,
37
- "aria-labelledby": "combo-label",
38
- "aria-controls": "combo-listbox",
39
- "aria-owns": "combo-listbox",
40
- "aria-activedescendant": focusOptionIdx,
41
- "aria-expanded": showPopover,
42
- "aria-haspopup": "listbox",
43
- placeholder: placeholder,
44
- role: "combobox",
45
- ref: inputRef,
46
- type: "text",
47
- onKeyDown: onInputKeyDown,
48
- onChange: handleOnChange,
49
- onBlur: handleOnBlur,
50
- onClick: handleOnInputMouseDown
51
- }))
52
- });
53
- };
54
-
55
- export { Controls };
@@ -1 +0,0 @@
1
- export { Controls } from './Controls.js';
@@ -1,32 +0,0 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
- import styled from 'styled-components';
3
- import { css } from '@elliemae/ds-system';
4
- import { Grid } from '@elliemae/ds-grid';
5
-
6
- var _templateObject, _templateObject2;
7
- const normalBorder = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n"])), props => props.hasError ? props.theme.colors.danger[900] : props.theme.colors.neutral[400]);
8
- const focusBorder = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 2px solid ", ";\n"])), _ref => {
9
- let {
10
- theme
11
- } = _ref;
12
- return theme.colors.brand[700];
13
- });
14
- const StyledControlsWrapper = /*#__PURE__*/styled(Grid).withConfig({
15
- componentId: "sc-vp36gr-0"
16
- })(["background:transparent;position:relative;border-radius:2px;min-width:", ";align-items:center;align-content:center;height:28px;padding-left:8px;::after{display:block;content:' ';position:absolute;top:0;left:0;right:0;bottom:0;border-radius:2px;", " pointer-events:none;z-index:7;}:focus-within{::after{", "}}"], _ref2 => {
17
- let {
18
- minWidth
19
- } = _ref2;
20
- return "".concat(minWidth, "px");
21
- }, normalBorder, focusBorder);
22
- const StyledInput = /*#__PURE__*/styled.input.withConfig({
23
- componentId: "sc-vp36gr-1"
24
- })(["::placeholder{font-style:italic;color:", ";}font-size:13px;line-height:13px;border:none;padding:0;outline:none;width:100%;color:", ";&:focus{outline:none;}"], props => props.theme.colors.neutral[500], props => props.theme.colors.neutral[700]);
25
- const StyledInputPlaceHolder = /*#__PURE__*/styled.div.withConfig({
26
- componentId: "sc-vp36gr-2"
27
- })(["font-style:italic;color:", ";position:absolute;display:flex;align-items:center;width:100%;user-select:none;height:28px;"], props => props.theme.colors.neutral[500]);
28
- const StyledInputWrapper = /*#__PURE__*/styled.div.withConfig({
29
- componentId: "sc-vp36gr-3"
30
- })(["position:relative;flex:1;margin-right:5px;display:flex;align-items:center;"]);
31
-
32
- export { StyledControlsWrapper, StyledInput, StyledInputPlaceHolder, StyledInputWrapper };
@@ -1,40 +0,0 @@
1
- import { useContext, useCallback, useMemo } from 'react';
2
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
3
-
4
- const useControlsInput = () => {
5
- const {
6
- props: {
7
- selectedValues,
8
- onChange,
9
- placeholder,
10
- onFilter
11
- },
12
- setShowPopover,
13
- inputRef
14
- } = useContext(AutocompleteContext);
15
- const handleOnChange = useCallback(e => {
16
- const target = e.target;
17
- onChange(target.value);
18
- setShowPopover(true);
19
- onFilter(target.value);
20
- }, [onFilter, onChange, setShowPopover]);
21
- const handleOnBlur = useCallback(() => {
22
- setShowPopover(false);
23
- }, [setShowPopover]);
24
- const handleOnInputMouseDown = useCallback(e => {
25
- e.stopPropagation();
26
- }, []);
27
- const showPlaceholder = useMemo(() => {
28
- var _inputRef$current;
29
-
30
- return !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.value) && selectedValues === '' ? placeholder : null;
31
- }, [placeholder, inputRef, selectedValues]);
32
- return useMemo(() => ({
33
- handleOnBlur,
34
- handleOnChange,
35
- handleOnInputMouseDown,
36
- showPlaceholder
37
- }), [handleOnBlur, handleOnInputMouseDown, handleOnChange, showPlaceholder]);
38
- };
39
-
40
- export { useControlsInput };
@@ -1,24 +0,0 @@
1
- import { useContext, useCallback } from 'react';
2
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
3
-
4
- const useMaskedOnChange = () => {
5
- const {
6
- props: {
7
- useMask,
8
- onChange
9
- },
10
- setShowPopover
11
- } = useContext(AutocompleteContext); // default onchange when no mask provided
12
-
13
- const handleOnChange = useCallback(e => {
14
- setShowPopover(true);
15
- onChange(e.target.value);
16
- }, [onChange, setShowPopover]);
17
- const onChangeMask = useMask({
18
- valueSetter: setInputValue,
19
- onChange: handleOnChange
20
- });
21
- return (onChangeMask === null || onChangeMask === void 0 ? void 0 : onChangeMask.onChange) || handleOnChange;
22
- };
23
-
24
- export { useMaskedOnChange };
@@ -1,65 +0,0 @@
1
- import { useContext, useEffect } from 'react';
2
- import { AutocompleteContext } from '../../AutocompleteCTX.js';
3
-
4
- const useMenuList = () => {
5
- var _inputRef$current3;
6
-
7
- const {
8
- props: {
9
- selectedValues,
10
- onMenuOpen,
11
- options
12
- },
13
- inputRef,
14
- setCurrentOption,
15
- scrollOptionIntoView,
16
- setShowPopover,
17
- showPopover
18
- } = useContext(AutocompleteContext);
19
- useEffect(() => {
20
- var _inputRef$current;
21
-
22
- if (options.length === 0 || ((_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) === '') {
23
- setShowPopover(false);
24
- }
25
- }, [options, inputRef, setShowPopover]);
26
- useEffect(() => {
27
- const getFirstOption = () => {
28
- for (let i = 0; i < options.length; i += 1) if (!['section', 'separator'].includes(options[i].type)) {
29
- setCurrentOption(options[i].dsId);
30
- break;
31
- }
32
- };
33
-
34
- if (showPopover) {
35
- var _inputRef$current2;
36
-
37
- onMenuOpen();
38
-
39
- if (((_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.value) !== '') {
40
- getFirstOption();
41
- } else if (Array.isArray(selectedValues)) {
42
- const multiSelectedValues = selectedValues;
43
-
44
- if (multiSelectedValues.length > 0) {
45
- setCurrentOption(multiSelectedValues[multiSelectedValues.length - 1].dsId);
46
- scrollOptionIntoView(multiSelectedValues[multiSelectedValues.length - 1].dsId);
47
- } else {
48
- getFirstOption();
49
- }
50
- } else {
51
- const singleSelectedValue = selectedValues;
52
-
53
- if (singleSelectedValue) {
54
- setCurrentOption(selectedValues.dsId);
55
- scrollOptionIntoView(selectedValues.dsId);
56
- } else {
57
- getFirstOption();
58
- }
59
- }
60
- } // eslint-disable-next-line react-hooks/exhaustive-deps
61
-
62
- }, [showPopover, (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value]);
63
- };
64
-
65
- export { useMenuList };
@@ -1,21 +0,0 @@
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, PropTypes.string]).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 autocomplete 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 };