@elliemae/ds-controlled-form 2.3.0-next.5 → 2.3.0-next.9

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 (101) hide show
  1. package/cjs/controlled-combobox/ComboBox.js +3 -6
  2. package/cjs/controlled-combobox/ComboBoxCTX.js +3 -3
  3. package/cjs/controlled-combobox/ComboboxDataTestids.js +2 -1
  4. package/cjs/controlled-combobox/config/useComboBox.js +15 -70
  5. package/cjs/controlled-combobox/config/useCorrectOptions.js +77 -0
  6. package/cjs/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +46 -0
  7. package/cjs/controlled-combobox/parts/a11y-messages/{MultiAllyMessages.js → SelectedValuesAllyMsg.js} +16 -7
  8. package/cjs/controlled-combobox/parts/a11y-messages/index.js +4 -4
  9. package/cjs/controlled-combobox/parts/container/Container.js +40 -15
  10. package/cjs/controlled-combobox/parts/container/styled.js +9 -6
  11. package/cjs/controlled-combobox/parts/controls/Controls.js +30 -19
  12. package/cjs/controlled-combobox/parts/controls/styled.js +22 -10
  13. package/cjs/controlled-combobox/parts/controls/useOnPillsNavigation.js +51 -0
  14. package/cjs/controlled-combobox/parts/controls-input/ControlsInput.js +9 -9
  15. package/cjs/controlled-combobox/parts/controls-input/useControlsInput.js +14 -8
  16. package/cjs/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
  17. package/cjs/controlled-combobox/parts/dropdown-indicator/styled.js +2 -3
  18. package/cjs/controlled-combobox/parts/header-list/HeaderList.js +6 -6
  19. package/cjs/controlled-combobox/parts/header-list/useHeaderListHandlers.js +4 -4
  20. package/cjs/controlled-combobox/parts/menu-list/MenuList.js +9 -11
  21. package/cjs/controlled-combobox/parts/menu-list/styled.js +1 -1
  22. package/cjs/controlled-combobox/parts/menu-list/useItemRenderer.js +11 -11
  23. package/cjs/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
  24. package/cjs/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +19 -15
  25. package/cjs/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
  26. package/cjs/controlled-combobox/react-desc-prop-types.js +42 -0
  27. package/cjs/controlled-combobox/{index.d.js → sharedTypes.js} +0 -0
  28. package/cjs/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -15
  29. package/cjs/controlled-combobox/utils/listHelper.js +2 -2
  30. package/esm/controlled-combobox/ComboBox.js +4 -7
  31. package/esm/controlled-combobox/ComboBoxCTX.js +4 -4
  32. package/esm/controlled-combobox/ComboboxDataTestids.js +2 -1
  33. package/esm/controlled-combobox/config/useComboBox.js +17 -72
  34. package/esm/controlled-combobox/config/useCorrectOptions.js +73 -0
  35. package/esm/controlled-combobox/parts/a11y-messages/FocusMenuItem.js +38 -0
  36. package/esm/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.js +34 -0
  37. package/esm/controlled-combobox/parts/a11y-messages/index.js +2 -2
  38. package/esm/controlled-combobox/parts/container/Container.js +38 -15
  39. package/esm/controlled-combobox/parts/container/styled.js +9 -6
  40. package/esm/controlled-combobox/parts/controls/Controls.js +31 -20
  41. package/esm/controlled-combobox/parts/controls/styled.js +22 -10
  42. package/esm/controlled-combobox/parts/controls/useOnPillsNavigation.js +47 -0
  43. package/esm/controlled-combobox/parts/controls-input/ControlsInput.js +9 -9
  44. package/esm/controlled-combobox/parts/controls-input/useControlsInput.js +14 -8
  45. package/esm/controlled-combobox/parts/dropdown-indicator/DropdownIndicator.js +6 -3
  46. package/esm/controlled-combobox/parts/dropdown-indicator/styled.js +3 -3
  47. package/esm/controlled-combobox/parts/header-list/HeaderList.js +6 -6
  48. package/esm/controlled-combobox/parts/header-list/useHeaderListHandlers.js +4 -4
  49. package/esm/controlled-combobox/parts/menu-list/MenuList.js +10 -12
  50. package/esm/controlled-combobox/parts/menu-list/styled.js +1 -1
  51. package/esm/controlled-combobox/parts/menu-list/useItemRenderer.js +11 -11
  52. package/esm/controlled-combobox/parts/menu-list/useMenuList.js +11 -13
  53. package/esm/controlled-combobox/parts/multi-selected-values-container/MultiSelectedValuesContainer.js +20 -16
  54. package/esm/controlled-combobox/parts/multi-selected-values-container/useGroupPills.js +5 -5
  55. package/esm/controlled-combobox/{propTypes.js → react-desc-prop-types.js} +16 -6
  56. package/esm/controlled-combobox/{index.d.js → sharedTypes.js} +0 -0
  57. package/esm/controlled-combobox/utils/hooks/useKeyboardNavigation.js +19 -15
  58. package/esm/controlled-combobox/utils/listHelper.js +2 -2
  59. package/package.json +30 -38
  60. package/types/controlled-combobox/ComboBox.d.ts +4 -70
  61. package/types/controlled-combobox/ComboBoxCTX.d.ts +4 -3
  62. package/types/controlled-combobox/ComboboxDataTestids.d.ts +1 -0
  63. package/types/controlled-combobox/config/useComboBox.d.ts +3 -2
  64. package/types/controlled-combobox/config/useCorrectOptions.d.ts +3 -0
  65. package/types/controlled-combobox/parts/a11y-messages/FocusMenuItem.d.ts +3 -0
  66. package/types/controlled-combobox/parts/a11y-messages/SelectedValuesAllyMsg.d.ts +3 -0
  67. package/types/controlled-combobox/parts/a11y-messages/index.d.ts +2 -2
  68. package/types/controlled-combobox/parts/controls/styled.d.ts +10 -2
  69. package/types/controlled-combobox/parts/controls/useOnPillsNavigation.d.ts +4 -0
  70. package/types/controlled-combobox/parts/dropdown-indicator/styled.d.ts +2 -1
  71. package/types/controlled-combobox/react-desc-prop-types.d.ts +53 -0
  72. package/types/controlled-combobox/sharedTypes.d.ts +29 -0
  73. package/types/controlled-combobox/utils/hooks/useKeyboardNavigation.d.ts +1 -1
  74. package/types/controlled-combobox/utils/listHelper.d.ts +7 -7
  75. package/types/controlled-date-time-picker/parts/Pickers/Calendar/Styleds.d.ts +3 -12
  76. package/types/controlled-date-time-picker/parts/Pickers/CalendarWithTimeWheel/Styleds.d.ts +1 -4
  77. package/types/controlled-date-time-picker/parts/Pickers/TimeWheel/Styleds.d.ts +3 -12
  78. package/types/controlled-date-time-picker/parts/Styleds.d.ts +1 -4
  79. package/cjs/controlled-combobox/config/constants.js +0 -14
  80. package/cjs/controlled-combobox/config/useGetPropsWithDefault.js +0 -11
  81. package/cjs/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -28
  82. package/cjs/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -28
  83. package/cjs/controlled-combobox/parts/single-selected-value-container/index.js +0 -9
  84. package/cjs/controlled-combobox/parts/single-selected-value-container/styled.js +0 -15
  85. package/cjs/controlled-combobox/propTypes.js +0 -28
  86. package/esm/controlled-combobox/config/constants.js +0 -10
  87. package/esm/controlled-combobox/config/useGetPropsWithDefault.js +0 -7
  88. package/esm/controlled-combobox/parts/a11y-messages/MultiAllyMessages.js +0 -25
  89. package/esm/controlled-combobox/parts/a11y-messages/SingleAllyMessages.js +0 -20
  90. package/esm/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.js +0 -20
  91. package/esm/controlled-combobox/parts/single-selected-value-container/index.js +0 -1
  92. package/esm/controlled-combobox/parts/single-selected-value-container/styled.js +0 -7
  93. package/types/controlled-combobox/config/constants.d.ts +0 -8
  94. package/types/controlled-combobox/config/useGetPropsWithDefault.d.ts +0 -2
  95. package/types/controlled-combobox/parts/a11y-messages/MultiAllyMessages.d.ts +0 -3
  96. package/types/controlled-combobox/parts/a11y-messages/SingleAllyMessages.d.ts +0 -3
  97. package/types/controlled-combobox/parts/single-selected-value-container/SingleSelectedValueContainer.d.ts +0 -3
  98. package/types/controlled-combobox/parts/single-selected-value-container/index.d.ts +0 -1
  99. package/types/controlled-combobox/parts/single-selected-value-container/styled.d.ts +0 -1
  100. package/types/controlled-combobox/propTypes.d.ts +0 -60
  101. package/types/controlled-combobox/tests/combobox-special-keys.test.d.ts +0 -1
@@ -4,12 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
6
  require('react');
7
- var reactDesc = require('react-desc');
8
7
  var dsPropsHelpers = require('@elliemae/ds-props-helpers');
9
8
  var useComboBox = require('./config/useComboBox.js');
10
9
  var Container = require('./parts/container/Container.js');
11
- var propTypes = require('./propTypes.js');
12
10
  var ComboBoxCTX = require('./ComboBoxCTX.js');
11
+ var reactDescPropTypes = require('./react-desc-prop-types.js');
13
12
 
14
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
14
 
@@ -18,16 +17,14 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
18
17
  var _Container;
19
18
 
20
19
  const DSComboBox = props => {
21
- const propsWithDefault = dsPropsHelpers.useMemoMergePropsWithDefault(props, ComboBoxCTX.defaultProps);
22
- dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefault, propTypes.propTypes);
23
20
  const ctx = useComboBox.useComboBox(props);
24
21
  return /*#__PURE__*/_jsx__default["default"](ComboBoxCTX.ComboBoxContext.Provider, {
25
22
  value: ctx
26
23
  }, void 0, _Container || (_Container = /*#__PURE__*/_jsx__default["default"](Container.Container, {})));
27
24
  };
28
25
 
29
- const DSComboBoxWithSchema = reactDesc.describe(DSComboBox);
30
- DSComboBoxWithSchema.propTypes = propTypes.propTypes;
26
+ const DSComboBoxWithSchema = dsPropsHelpers.describe(DSComboBox);
27
+ DSComboBoxWithSchema.propTypes = reactDescPropTypes.ComboboxPropTypes;
31
28
 
32
29
  exports.DSComboBox = DSComboBox;
33
30
  exports.DSComboBoxWithSchema = DSComboBoxWithSchema;
@@ -18,13 +18,14 @@ const defaultProps = {
18
18
  onClearAll: lodash.noop,
19
19
  onSelectAll: lodash.noop,
20
20
  onCreate: lodash.noop,
21
- withToggle: false,
21
+ onBlur: lodash.noop,
22
22
  withoutPortal: true,
23
23
  zIndex: 10,
24
24
  onChange: lodash.noop,
25
25
  onKeyDown: lodash.noop,
26
26
  onFilter: lodash.noop,
27
- onMenuOpen: lodash.noop
27
+ onMenuOpen: lodash.noop,
28
+ innerRef: /*#__PURE__*/React.createRef()
28
29
  };
29
30
  const defaultContext = {
30
31
  props: defaultProps,
@@ -36,7 +37,6 @@ const defaultContext = {
36
37
  setHasFocus: lodash.noop,
37
38
  pillGroupRef: /*#__PURE__*/React.createRef(),
38
39
  setReferenceElement: lodash.noop,
39
- inputRef: /*#__PURE__*/React.createRef(),
40
40
  listRef: /*#__PURE__*/React.createRef(),
41
41
  wrapperListRef: /*#__PURE__*/React.createRef(),
42
42
  controlsWrapperRef: /*#__PURE__*/React.createRef(),
@@ -11,7 +11,8 @@ const ComboboxDataTestid = {
11
11
  DROPDOWN: 'combobox-dropdown-btn',
12
12
  OPTION: 'combobox-option',
13
13
  SELECT_ALL_CHECKBOX: 'combobox-select-all-checkbox',
14
- SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle'
14
+ SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle',
15
+ ALLY_SELECTED_VALUES: 'combobox-ally-selected-values'
15
16
  };
16
17
 
17
18
  exports.ComboboxDataTestid = ComboboxDataTestid;
@@ -4,18 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
6
  require('core-js/modules/web.dom-collections.iterator.js');
7
- require('core-js/modules/esnext.async-iterator.for-each.js');
8
- require('core-js/modules/esnext.iterator.constructor.js');
9
- require('core-js/modules/esnext.iterator.for-each.js');
10
- require('core-js/modules/esnext.async-iterator.find.js');
11
- require('core-js/modules/esnext.iterator.find.js');
12
7
  require('core-js/modules/esnext.async-iterator.filter.js');
8
+ require('core-js/modules/esnext.iterator.constructor.js');
13
9
  require('core-js/modules/esnext.iterator.filter.js');
10
+ require('core-js/modules/esnext.async-iterator.for-each.js');
11
+ require('core-js/modules/esnext.iterator.for-each.js');
14
12
  var React = require('react');
15
- var lodash = require('lodash');
16
- var uuid = require('uuid');
17
13
  var reactVirtual = require('react-virtual');
18
- var useGetPropsWithDefault = require('./useGetPropsWithDefault.js');
14
+ var dsPropsHelpers = require('@elliemae/ds-props-helpers');
15
+ var ComboBoxCTX = require('../ComboBoxCTX.js');
16
+ var reactDescPropTypes = require('../react-desc-prop-types.js');
17
+ var useCorrectOptions = require('./useCorrectOptions.js');
19
18
 
20
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
20
 
@@ -25,77 +24,25 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
25
24
 
26
25
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
26
  const useComboBox = props => {
27
+ const propsWithDefaults = dsPropsHelpers.useMemoMergePropsWithDefault(props, ComboBoxCTX.defaultProps);
28
+ dsPropsHelpers.useValidateTypescriptPropTypes(propsWithDefaults, reactDescPropTypes.ComboboxPropTypes);
28
29
  const [showPopover, setShowPopover] = React.useState(false);
29
30
  const [referenceElement, setReferenceElement] = React.useState(null);
30
31
  const [showSelectedValue, setShowSelectedValue] = React.useState(false);
31
32
  const [showSelectedOptions, setShowSelectedOptions] = React.useState(false);
32
33
  const [hasFocus, setHasFocus] = React.useState(false);
33
34
  const [focusOptionIdx, setCurrentOption] = React.useState('');
34
- const inputRef = React.useRef(null);
35
35
  const listRef = React.useRef(null);
36
36
  const wrapperListRef = React.useRef(null);
37
37
  const selectedOptionsRef = React.useRef(null);
38
38
  const controlsWrapperRef = React.useRef(null);
39
39
  const selectAllCheckboxRef = React.useRef(null);
40
40
  const toggleSelectionButtonRef = React.useRef(null);
41
- const pillGroupRef = React.useRef(null);
42
- const propsWithDefaults = useGetPropsWithDefault.useGetComboBoxWithDefaultsProps(props);
43
- const {
44
- options,
45
- selectedValues,
46
- onCreate
47
- } = propsWithDefaults; // ---------------------------------------------------------------------------
41
+ const pillGroupRef = React.useRef(null); // ---------------------------------------------------------------------------
48
42
  // Menu Options with/out selected filter
49
43
  // ---------------------------------------------------------------------------
50
44
 
51
- const selectedValuesWithSections = React.useCallback(() => {
52
- var _items2;
53
-
54
- const multiSelectedValue = selectedValues;
55
- const items = [];
56
- options.forEach(option => {
57
- const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
58
-
59
- if (isSelectedValue) {
60
- items.push(option);
61
- }
62
-
63
- if (option.type === 'section') {
64
- var _items;
65
-
66
- if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === 'section') {
67
- items[items.length - 1] = option;
68
- } else {
69
- items.push(option);
70
- }
71
- }
72
- });
73
-
74
- if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === 'section') {
75
- items.pop();
76
- }
77
-
78
- return items;
79
- }, [options, selectedValues]);
80
- const correctOptions = React.useMemo(() => {
81
- if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
82
- return selectedValuesWithSections();
83
- }
84
-
85
- if (onCreate !== lodash.noop && inputRef.current && inputRef.current.value !== '') {
86
- var _inputRef$current;
87
-
88
- const creatableUuid = uuid.v4();
89
- const creatableItem = {
90
- dsId: "creatable-".concat(creatableUuid),
91
- label: (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value,
92
- type: 'creatable'
93
- };
94
- return [creatableItem, ...options];
95
- }
96
-
97
- return options;
98
- }, [options, onCreate, selectedValuesWithSections, selectedValues, showSelectedOptions]); // ===========================================================================
45
+ const correctOptions = useCorrectOptions.useCorrectOptions(propsWithDefaults, showSelectedOptions); // ===========================================================================
99
46
  // Virtualization setup
100
47
  // ===========================================================================
101
48
 
@@ -108,11 +55,10 @@ const useComboBox = props => {
108
55
  // Scroll into view function
109
56
  // ===========================================================================
110
57
 
111
- const scrollOptionIntoView = React.useCallback(function (dsId) {
112
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
58
+ const scrollOptionIntoView = React.useCallback(dsId => {
59
+ virtualListHelpers.scrollToIndex(correctOptions.findIndex(opt => opt.dsId === dsId), {
113
60
  align: 'center'
114
- };
115
- virtualListHelpers.scrollToIndex(correctOptions.findIndex(opt => opt.dsId === dsId), opts);
61
+ });
116
62
  }, [correctOptions, virtualListHelpers]);
117
63
  const ctx = React.useMemo(() => ({
118
64
  props: _objectSpread(_objectSpread({}, propsWithDefaults), {}, {
@@ -121,7 +67,6 @@ const useComboBox = props => {
121
67
  virtualListHelpers,
122
68
  showPopover,
123
69
  referenceElement,
124
- inputRef,
125
70
  showSelectedValue,
126
71
  listRef,
127
72
  focusOptionIdx,
@@ -140,7 +85,7 @@ const useComboBox = props => {
140
85
  setShowSelectedValue,
141
86
  setReferenceElement,
142
87
  setShowPopover
143
- }), [scrollOptionIntoView, correctOptions, propsWithDefaults, virtualListHelpers, focusOptionIdx, showSelectedValue, wrapperListRef, showSelectedOptions, showPopover, pillGroupRef, referenceElement, inputRef, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, hasFocus, listRef]);
88
+ }), [scrollOptionIntoView, correctOptions, propsWithDefaults, virtualListHelpers, focusOptionIdx, showSelectedValue, wrapperListRef, showSelectedOptions, showPopover, pillGroupRef, referenceElement, selectedOptionsRef, controlsWrapperRef, selectAllCheckboxRef, toggleSelectionButtonRef, hasFocus, listRef]);
144
89
  return ctx;
145
90
  };
146
91
 
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('core-js/modules/esnext.async-iterator.for-each.js');
6
+ require('core-js/modules/esnext.iterator.constructor.js');
7
+ require('core-js/modules/esnext.iterator.for-each.js');
8
+ require('core-js/modules/esnext.async-iterator.find.js');
9
+ require('core-js/modules/esnext.iterator.find.js');
10
+ require('core-js/modules/web.dom-collections.iterator.js');
11
+ var React = require('react');
12
+ var uuid = require('uuid');
13
+ var lodash = require('lodash');
14
+
15
+ const useCorrectOptions = (propsWithDefaults, showSelectedOptions) => {
16
+ const {
17
+ options,
18
+ selectedValues,
19
+ onCreate,
20
+ innerRef
21
+ } = propsWithDefaults;
22
+ const selectedValuesWithSections = React.useCallback(() => {
23
+ var _items2;
24
+
25
+ const multiSelectedValue = selectedValues;
26
+ const items = [];
27
+ options.forEach(option => {
28
+ const isSelectedValue = multiSelectedValue.find(item => item.dsId === option.dsId);
29
+
30
+ if (isSelectedValue) {
31
+ items.push(option);
32
+ }
33
+
34
+ if (option.type === 'section') {
35
+ var _items;
36
+
37
+ if (((_items = items[items.length - 1]) === null || _items === void 0 ? void 0 : _items.type) === 'section') {
38
+ items[items.length - 1] = option;
39
+ } else {
40
+ items.push(option);
41
+ }
42
+ }
43
+ });
44
+
45
+ if (((_items2 = items[items.length - 1]) === null || _items2 === void 0 ? void 0 : _items2.type) === 'section') {
46
+ items.pop();
47
+ }
48
+
49
+ return items;
50
+ }, [options, selectedValues]);
51
+ const correctOptions = React.useMemo(() => {
52
+ if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
53
+ return selectedValuesWithSections();
54
+ }
55
+
56
+ if (onCreate !== lodash.noop && innerRef.current && innerRef.current.value !== '' && options.findIndex(option => {
57
+ var _innerRef$current;
58
+
59
+ return option.type === 'option' && option.label === (innerRef === null || innerRef === void 0 ? void 0 : (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.value);
60
+ }) === -1) {
61
+ var _innerRef$current2;
62
+
63
+ const creatableUuid = uuid.v4();
64
+ const creatableItem = {
65
+ dsId: "creatable-".concat(creatableUuid),
66
+ label: (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.value,
67
+ type: 'creatable'
68
+ };
69
+ return [creatableItem, ...options];
70
+ }
71
+
72
+ return options;
73
+ }, [options, onCreate, innerRef, selectedValuesWithSections, selectedValues, showSelectedOptions]);
74
+ return correctOptions;
75
+ };
76
+
77
+ exports.useCorrectOptions = useCorrectOptions;
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _jsx = require('@babel/runtime/helpers/jsx');
6
+ require('core-js/modules/esnext.async-iterator.find.js');
7
+ require('core-js/modules/esnext.iterator.constructor.js');
8
+ require('core-js/modules/esnext.iterator.find.js');
9
+ var React = require('react');
10
+ var ComboBoxCTX = require('../../ComboBoxCTX.js');
11
+ var styled = require('./styled.js');
12
+ var listHelper = require('../../utils/listHelper.js');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+
15
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
+
17
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
18
+
19
+ const FocusMenuItem = () => {
20
+ const {
21
+ props: {
22
+ options
23
+ },
24
+ focusOptionIdx,
25
+ showPopover
26
+ } = React.useContext(ComboBoxCTX.ComboBoxContext);
27
+ const selectabledOptions = listHelper.getSelectableOptions(options);
28
+ const focusOption = options.find(option => option.dsId === focusOptionIdx);
29
+ const focusSelectableOptionIdx = selectabledOptions.findIndex(option => option.dsId === focusOptionIdx);
30
+ const msg = React.useMemo(() => {
31
+ if (showPopover) {
32
+ return /*#__PURE__*/_jsx__default["default"](styled.StyledA11ySelectedValues, {
33
+ "aria-live": "polite",
34
+ "aria-atomic": "false",
35
+ "aria-relevant": "additions text"
36
+ }, void 0, "option ".concat(focusOption === null || focusOption === void 0 ? void 0 : focusOption.label, " focused.").concat(focusSelectableOptionIdx + 1, " of ").concat(selectabledOptions.length, " "));
37
+ }
38
+
39
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {});
40
+ }, [showPopover, focusOption, focusSelectableOptionIdx, selectabledOptions]);
41
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
42
+ children: msg
43
+ });
44
+ };
45
+
46
+ exports.FocusMenuItem = FocusMenuItem;
@@ -7,27 +7,36 @@ require('core-js/modules/esnext.async-iterator.map.js');
7
7
  require('core-js/modules/esnext.iterator.map.js');
8
8
  var React = require('react');
9
9
  var ComboBoxCTX = require('../../ComboBoxCTX.js');
10
- var listHelper = require('../../utils/listHelper.js');
11
10
  var styled = require('./styled.js');
11
+ var ComboboxDataTestids = require('../../ComboboxDataTestids.js');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
15
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
16
16
 
17
- const MultiAllyMessages = () => {
17
+ const SelectedValuesAllyMsg = () => {
18
18
  const {
19
19
  props: {
20
- options,
21
20
  selectedValues
22
21
  }
23
22
  } = React.useContext(ComboBoxCTX.ComboBoxContext);
24
- const selectableOptions = listHelper.getSelectableOptions(options);
25
- const multipleSelectedValues = selectedValues;
23
+ const msg = React.useMemo(() => {
24
+ if (Array.isArray(selectedValues)) {
25
+ return "Options selected: ".concat(selectedValues.map(item => item.label).join(', '));
26
+ }
27
+
28
+ if (selectedValues) {
29
+ return "Option selected: ".concat(selectedValues === null || selectedValues === void 0 ? void 0 : selectedValues.label);
30
+ }
31
+
32
+ return '';
33
+ }, [selectedValues]);
26
34
  return /*#__PURE__*/_jsx__default["default"](styled.StyledA11ySelectedValues, {
35
+ "data-testid": ComboboxDataTestids.ComboboxDataTestid.ALLY_SELECTED_VALUES,
27
36
  "aria-live": "polite",
28
37
  "aria-atomic": "false",
29
38
  "aria-relevant": "additions text"
30
- }, void 0, "Options selected: ".concat(multipleSelectedValues.map(item => item.label).join(', '), ". ").concat(multipleSelectedValues.length, " of ").concat(selectableOptions.length));
39
+ }, void 0, msg);
31
40
  };
32
41
 
33
- exports.MultiAllyMessages = MultiAllyMessages;
42
+ exports.SelectedValuesAllyMsg = SelectedValuesAllyMsg;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var MultiAllyMessages = require('./MultiAllyMessages.js');
6
- var SingleAllyMessages = require('./SingleAllyMessages.js');
5
+ var SelectedValuesAllyMsg = require('./SelectedValuesAllyMsg.js');
6
+ var FocusMenuItem = require('./FocusMenuItem.js');
7
7
 
8
8
 
9
9
 
10
- exports.MultiAllyMessages = MultiAllyMessages.MultiAllyMessages;
11
- exports.SingleAllyMessages = SingleAllyMessages.SingleAllyMessages;
10
+ exports.SelectedValuesAllyMsg = SelectedValuesAllyMsg.SelectedValuesAllyMsg;
11
+ exports.FocusMenuItem = FocusMenuItem.FocusMenuItem;
@@ -2,8 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ require('core-js/modules/esnext.async-iterator.filter.js');
6
+ require('core-js/modules/esnext.iterator.constructor.js');
7
+ require('core-js/modules/esnext.iterator.filter.js');
8
+ require('core-js/modules/esnext.async-iterator.for-each.js');
9
+ require('core-js/modules/esnext.iterator.for-each.js');
10
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
5
11
  var _jsx = require('@babel/runtime/helpers/jsx');
12
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
13
  var React = require('react');
14
+ var dsPropsHelpers = require('@elliemae/ds-props-helpers');
7
15
  var dsPopperjs = require('@elliemae/ds-popperjs');
8
16
  var ComboBoxCTX = require('../../ComboBoxCTX.js');
9
17
  var styled = require('./styled.js');
@@ -13,42 +21,59 @@ var jsxRuntime = require('react/jsx-runtime');
13
21
 
14
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
23
 
24
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
16
25
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
26
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
17
27
 
18
28
  var _Controls, _MenuList, _MenuList2;
19
29
 
30
+ const _excluded = ["placeholder", "onKeyDown", "onChange"];
31
+
32
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
+
34
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
+
20
36
  const Container = () => {
21
37
  const {
22
- props: {
23
- inline,
24
- startPlacementPreference,
25
- placementOrderPreference,
26
- withoutPortal,
27
- zIndex
28
- },
38
+ props,
29
39
  showPopover,
30
- inputRef,
40
+ innerRef,
31
41
  setReferenceElement,
32
42
  setShowPopover,
33
43
  referenceElement
34
44
  } = React.useContext(ComboBoxCTX.ComboBoxContext);
45
+ const {
46
+ inline,
47
+ disabled,
48
+ startPlacementPreference,
49
+ placementOrderPreference,
50
+ withoutPortal,
51
+ zIndex
52
+ } = props;
35
53
  const handleCloseMenu = React.useCallback(() => {
36
54
  setShowPopover(false);
37
- if (inputRef.current) inputRef.current.blur();
38
- }, [inputRef, setShowPopover]);
55
+ if (innerRef.current) innerRef.current.blur();
56
+ }, [innerRef, setShowPopover]);
39
57
  const handleMouseDown = React.useCallback(e => {
40
58
  e.preventDefault();
41
59
  }, []);
42
60
  const handleOnClickContainer = React.useCallback(() => {
43
- setShowPopover(!showPopover);
44
- }, [setShowPopover, showPopover]);
61
+ if (!disabled) setShowPopover(!showPopover);
62
+ }, [setShowPopover, disabled, showPopover]);
45
63
  const StyledContainer = inline ? styled.StyledContainerInline : styled.StyledContainerWithPopper;
64
+ const globalAttributes = dsPropsHelpers.useGetGlobalAttributes(props, {
65
+ onClick: handleOnClickContainer
66
+ }); // Removing possible collisionable props
67
+
68
+ const rest = _objectWithoutProperties__default["default"](globalAttributes, _excluded);
69
+
46
70
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
47
- children: [/*#__PURE__*/jsxRuntime.jsxs(StyledContainer, {
71
+ children: [/*#__PURE__*/jsxRuntime.jsxs(StyledContainer, _objectSpread(_objectSpread({
48
72
  ref: setReferenceElement,
49
- onClick: handleOnClickContainer,
73
+ onClick: handleOnClickContainer
74
+ }, rest), {}, {
50
75
  children: [_Controls || (_Controls = /*#__PURE__*/_jsx__default["default"](Controls.Controls, {})), inline ? _MenuList || (_MenuList = /*#__PURE__*/_jsx__default["default"](MenuList.MenuList, {})) : null]
51
- }), !inline ? /*#__PURE__*/_jsx__default["default"](dsPopperjs.DSPopperJS, {
76
+ })), !inline ? /*#__PURE__*/_jsx__default["default"](dsPopperjs.DSPopperJS, {
52
77
  customOffset: [0, 5],
53
78
  closeContextMenu: handleCloseMenu,
54
79
  referenceElement: referenceElement,
@@ -8,15 +8,18 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
- const StyledContainerWithPopper = /*#__PURE__*/styled__default["default"].div.withConfig({
11
+ const StyledGenericContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
12
12
  componentId: "sc-16uoof1-0"
13
- })(["width:100%;height:28px;position:relative;"]);
14
- const StyledContainerInline = /*#__PURE__*/styled__default["default"].div.withConfig({
13
+ })(["position:relative;"]);
14
+ const StyledContainerWithPopper = /*#__PURE__*/styled__default["default"](StyledGenericContainer).withConfig({
15
15
  componentId: "sc-16uoof1-1"
16
- })(["width:100%;position:relative;"]);
17
- const StyledPopperWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
16
+ })(["width:100%;height:28px;"]);
17
+ const StyledContainerInline = /*#__PURE__*/styled__default["default"](StyledGenericContainer).withConfig({
18
18
  componentId: "sc-16uoof1-2"
19
- })(["background:#fff;overflow:auto;position:relative;"]);
19
+ })(["width:100%;"]);
20
+ const StyledPopperWrapper = /*#__PURE__*/styled__default["default"](StyledGenericContainer).withConfig({
21
+ componentId: "sc-16uoof1-3"
22
+ })(["overflow:auto;"]);
20
23
 
21
24
  exports.StyledContainerInline = StyledContainerInline;
22
25
  exports.StyledContainerWithPopper = StyledContainerWithPopper;
@@ -11,23 +11,27 @@ var ComboBoxCTX = require('../../ComboBoxCTX.js');
11
11
  var styled = require('./styled.js');
12
12
  var MultiSelectedValuesContainer = require('../multi-selected-values-container/MultiSelectedValuesContainer.js');
13
13
  var ControlsInput = require('../controls-input/ControlsInput.js');
14
+ var useOnPillsNavigation = require('./useOnPillsNavigation.js');
15
+ var SelectedValuesAllyMsg = require('../a11y-messages/SelectedValuesAllyMsg.js');
16
+ var FocusMenuItem = require('../a11y-messages/FocusMenuItem.js');
14
17
  var jsxRuntime = require('react/jsx-runtime');
15
18
 
16
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
20
 
18
21
  var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
19
22
 
20
- var _MultiSelectedValuesC, _ControlsInput, _StyledHeaderActionsW;
23
+ var _SelectedValuesAllyMs, _FocusMenuItem, _MultiSelectedValuesC, _ControlsInput, _StyleHeaderActionsSe, _DropdownIndicator;
21
24
 
22
25
  const Controls = () => {
23
26
  const {
24
27
  props: {
25
28
  inline,
29
+ disabled,
26
30
  inputMinWidth,
27
31
  hasError,
28
- selectedValues
32
+ selectedValues,
33
+ innerRef
29
34
  },
30
- inputRef,
31
35
  selectedOptionsRef,
32
36
  setShowPopover,
33
37
  showPopover,
@@ -36,17 +40,17 @@ const Controls = () => {
36
40
  } = React.useContext(ComboBoxCTX.ComboBoxContext);
37
41
  const handleOnClick = React.useCallback(() => {
38
42
  if (hasFocus && showPopover && !inline) {
39
- var _inputRef$current;
43
+ var _innerRef$current;
40
44
 
41
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
45
+ (_innerRef$current = innerRef.current) === null || _innerRef$current === void 0 ? void 0 : _innerRef$current.blur();
42
46
  } else if (hasFocus) {
43
47
  setShowPopover(true);
44
48
  } else {
45
- var _inputRef$current2;
49
+ var _innerRef$current2;
46
50
 
47
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
51
+ (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.focus();
48
52
  }
49
- }, [hasFocus, setShowPopover, showPopover, inputRef, inline]);
53
+ }, [hasFocus, setShowPopover, showPopover, innerRef, inline]);
50
54
 
51
55
  const handleOnMouseDown = e => {
52
56
  if (hasFocus || inline) {
@@ -54,28 +58,35 @@ const Controls = () => {
54
58
  }
55
59
  };
56
60
 
61
+ const {
62
+ onKeyDownPills
63
+ } = useOnPillsNavigation.useOnPillsNavigation();
57
64
  const cols = !inline ? ['minmax(0px,max-content)', 'minmax(20px, auto)', '29px'] : ['minmax(0px, auto)'];
58
65
  return /*#__PURE__*/jsxRuntime.jsxs(styled.StyledControlsWrapper, {
59
66
  ref: controlsWrapperRef,
60
67
  cols: cols,
68
+ disabled: disabled,
61
69
  minWidth: inputMinWidth,
62
70
  hasError: hasError,
63
71
  hasFocus: hasFocus,
64
72
  inline: inline,
65
73
  onClick: handleOnClick,
66
74
  onMouseDown: handleOnMouseDown,
67
- children: [!inline && /*#__PURE__*/jsxRuntime.jsx(styled.StyledSelection, {
75
+ onKeyDown: onKeyDownPills,
76
+ children: [!inline && /*#__PURE__*/jsxRuntime.jsxs(styled.StyledSelection, {
68
77
  ref: selectedOptionsRef,
69
- "data-testid": ComboboxDataTestids.ComboboxDataTestid.SELECTED_VALUES,
70
- children: Array.isArray(selectedValues) ? _MultiSelectedValuesC || (_MultiSelectedValuesC = /*#__PURE__*/_jsx__default["default"](MultiSelectedValuesContainer.MultiSelectedValuesContainer, {})) : /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
71
- children: selectedValues && /*#__PURE__*/_jsx__default["default"](dsPills.DSPillV2, {
72
- size: "s",
73
- labelTruncated: true,
74
- label: selectedValues.label,
75
- type: "value"
76
- }, selectedValues.value)
77
- })
78
- }), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx__default["default"](ControlsInput.ControlsInput, {})), !inline && (_StyledHeaderActionsW || (_StyledHeaderActionsW = /*#__PURE__*/_jsx__default["default"](styled.StyledHeaderActionsWrapper, {}, void 0, /*#__PURE__*/_jsx__default["default"](styled.StyleHeaderActionsSeparator, {}), /*#__PURE__*/_jsx__default["default"](DropdownIndicator, {}))))]
78
+ children: [_SelectedValuesAllyMs || (_SelectedValuesAllyMs = /*#__PURE__*/_jsx__default["default"](SelectedValuesAllyMsg.SelectedValuesAllyMsg, {})), _FocusMenuItem || (_FocusMenuItem = /*#__PURE__*/_jsx__default["default"](FocusMenuItem.FocusMenuItem, {})), Array.isArray(selectedValues) ? _MultiSelectedValuesC || (_MultiSelectedValuesC = /*#__PURE__*/_jsx__default["default"](MultiSelectedValuesContainer.MultiSelectedValuesContainer, {})) : /*#__PURE__*/_jsx__default["default"]("div", {
79
+ "data-testid": ComboboxDataTestids.ComboboxDataTestid.SELECTED_VALUES
80
+ }, void 0, selectedValues && /*#__PURE__*/_jsx__default["default"](dsPills.DSPillV2, {
81
+ size: "s",
82
+ labelTruncated: true,
83
+ label: selectedValues.label,
84
+ type: "value"
85
+ }, selectedValues.value))]
86
+ }), _ControlsInput || (_ControlsInput = /*#__PURE__*/_jsx__default["default"](ControlsInput.ControlsInput, {})), !inline && /*#__PURE__*/_jsx__default["default"](styled.StyledHeaderActionsWrapper, {
87
+ justifyContent: "center",
88
+ cols: ['auto', 'auto']
89
+ }, void 0, _StyleHeaderActionsSe || (_StyleHeaderActionsSe = /*#__PURE__*/_jsx__default["default"](styled.StyleHeaderActionsSeparator, {})), _DropdownIndicator || (_DropdownIndicator = /*#__PURE__*/_jsx__default["default"](DropdownIndicator, {})))]
79
90
  });
80
91
  };
81
92