@pareto-engineering/design-system 2.0.0-alpha.44 → 2.0.0-alpha.47

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 (35) hide show
  1. package/dist/cjs/f/FormInput/FormInput.js +8 -1
  2. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +49 -41
  3. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +72 -15
  4. package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +1 -1
  5. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +91 -21
  6. package/dist/cjs/f/fields/QueryCombobox/styles.scss +52 -39
  7. package/dist/cjs/f/fields/index.js +9 -1
  8. package/dist/es/f/FormInput/FormInput.js +9 -2
  9. package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +53 -43
  10. package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +73 -17
  11. package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +1 -1
  12. package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +91 -22
  13. package/dist/es/f/fields/QueryCombobox/styles.scss +52 -39
  14. package/dist/es/f/fields/index.js +2 -1
  15. package/package.json +3 -2
  16. package/src/__snapshots__/Storyshots.test.js.snap +508 -0
  17. package/src/local.scss +3 -3
  18. package/src/stories/f/FormInput.stories.jsx +115 -0
  19. package/src/stories/f/QueryCombobox.stories.jsx +267 -0
  20. package/src/stories/f/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
  21. package/src/stories/f/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
  22. package/src/stories/utils/generateNodeId.js +12 -0
  23. package/src/stories/utils/testData.js +63 -0
  24. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  25. package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +223 -0
  26. package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +222 -0
  27. package/src/ui/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
  28. package/src/ui/f/fields/QueryCombobox/common/Menu/Menu.jsx +103 -0
  29. package/src/ui/f/fields/QueryCombobox/common/Menu/index.js +2 -0
  30. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +317 -0
  31. package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
  32. package/src/ui/f/fields/QueryCombobox/common/index.js +3 -0
  33. package/src/ui/f/fields/QueryCombobox/index.js +2 -0
  34. package/src/ui/f/fields/QueryCombobox/styles.scss +78 -0
  35. package/src/ui/f/fields/index.js +1 -0
@@ -67,6 +67,13 @@ var FormInput = _ref => {
67
67
  }, otherProps));
68
68
  }
69
69
 
70
+ if (type === 'query-combobox') {
71
+ return /*#__PURE__*/React.createElement(_fields.QueryCombobox, _extends({
72
+ className: newClassName,
73
+ disabled: disabled
74
+ }, otherProps));
75
+ }
76
+
70
77
  if (extraTypes !== null && extraTypes !== void 0 && extraTypes[type]) {
71
78
  var Component = extraTypes[type];
72
79
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -91,7 +98,7 @@ FormInput.propTypes = {
91
98
  /**
92
99
  * The HTML class names for this element
93
100
  */
94
- type: _propTypes.default.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', // to be removed
101
+ type: _propTypes.default.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', // to be removed
95
102
  'extendedTypeInput']),
96
103
 
97
104
  /**
@@ -7,12 +7,12 @@ exports.default = void 0;
7
7
 
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _formik = require("formik");
11
+
10
12
  var _reactRelay = require("react-relay");
11
13
 
12
14
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
15
 
14
- var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
15
-
16
16
  var _common = require("./common");
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -27,17 +27,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
27
 
28
28
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
29
 
30
- var baseClassName = _bem.default.base;
31
- var componentClassName = 'query-combobox';
32
30
  /**
33
31
  * This is the component description.
34
32
  */
35
-
36
33
  var QueryCombobox = _ref => {
37
34
  var {
38
35
  id,
39
- className: userClassName,
40
36
  style,
37
+ className,
41
38
  query,
42
39
  multiple,
43
40
  name,
@@ -50,33 +47,46 @@ var QueryCombobox = _ref => {
50
47
  searchVariable,
51
48
  extraVariables,
52
49
  optionsKeyMap,
53
- setValue,
54
- setError,
55
- error // ...otherProps
50
+ minLength,
51
+ transformSearch // ...otherProps
56
52
 
57
53
  } = _ref;
58
54
  (0, React.useLayoutEffect)(() => {
59
55
  Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
60
56
  }, []);
57
+ var [, meta, helpers] = (0, _formik.useField)(name);
58
+ var {
59
+ setValue,
60
+ setError
61
+ } = helpers;
62
+ var {
63
+ error,
64
+ value
65
+ } = meta;
61
66
  var environment = (0, _reactRelay.useRelayEnvironment)();
62
67
  var [isFetching, setIsFetching] = (0, React.useState)(false);
63
68
  var [options, setOptions] = (0, React.useState)([]);
64
69
 
65
- var fetchOptions = inputValue => {
70
+ var getOptions = inputValue => {
66
71
  if (isFetching) return;
67
- (0, _reactRelay.fetchQuery)(environment, query, _objectSpread({
72
+ var variables = {
68
73
  [searchVariable]: inputValue
69
- }, extraVariables)).subscribe({
74
+ };
75
+
76
+ if (extraVariables) {
77
+ variables = _objectSpread(_objectSpread({}, variables), extraVariables);
78
+ }
79
+
80
+ (0, _reactRelay.fetchQuery)(environment, query, variables).subscribe({
70
81
  start: () => {
71
82
  setIsFetching(true);
72
83
  },
73
84
  complete: () => {
74
85
  setIsFetching(false);
75
86
  },
76
- error: theError => {
77
- console.log(theError);
87
+ error: fetchError => {
78
88
  setIsFetching(false);
79
- if (setError) setError(theError);
89
+ if (setError) setError(fetchError.message);
80
90
  },
81
91
  next: data => {
82
92
  setOptions(data[graphQlNode].edges.map(_ref2 => {
@@ -93,23 +103,26 @@ var QueryCombobox = _ref => {
93
103
  };
94
104
 
95
105
  var comboboxProps = {
106
+ id,
107
+ style,
96
108
  options,
97
- fetchOptions,
109
+ getOptions,
98
110
  debounceMs,
99
111
  disabled,
100
112
  name,
101
113
  label,
102
114
  description,
103
115
  setValue,
104
- error
116
+ error,
117
+ value,
118
+ color,
119
+ isFetching,
120
+ className,
121
+ minLength,
122
+ transformSearch
105
123
  };
106
- var Component = multiple ? _common.MultipleCombobox : _common.Combobox;
107
- return /*#__PURE__*/React.createElement("div", {
108
- id: id,
109
- className: [baseClassName, componentClassName, userClassName, "y-".concat(color)].filter(e => e).join(' '),
110
- style: style // {...otherProps}
111
-
112
- }, /*#__PURE__*/React.createElement(Component, comboboxProps));
124
+ var Input = multiple ? _common.MultipleCombobox : _common.Combobox;
125
+ return /*#__PURE__*/React.createElement(Input, comboboxProps);
113
126
  };
114
127
 
115
128
  QueryCombobox.propTypes = {
@@ -138,11 +151,6 @@ QueryCombobox.propTypes = {
138
151
  */
139
152
  label: _propTypes.default.string,
140
153
 
141
- /**
142
- * The input field validator function
143
- */
144
- validate: _propTypes.default.func,
145
-
146
154
  /**
147
155
  * The custom select input description
148
156
  */
@@ -180,7 +188,7 @@ QueryCombobox.propTypes = {
180
188
  optionsKeyMap: _propTypes.default.shape({
181
189
  value: _propTypes.default.string.isRequired,
182
190
  label: _propTypes.default.string.isRequired
183
- }).isRequired,
191
+ }),
184
192
 
185
193
  /**
186
194
  * Whether to allow multiple items selection
@@ -198,25 +206,25 @@ QueryCombobox.propTypes = {
198
206
  searchVariable: _propTypes.default.string,
199
207
 
200
208
  /**
201
- * The function to be called when the value changes
202
- */
203
- setValue: _propTypes.default.func.isRequired,
204
-
205
- /**
206
- * The function to be called with an error when the it occurs
209
+ * The minimum length of the search input to start fetching the options
207
210
  */
208
- setError: _propTypes.default.func,
211
+ minLength: _propTypes.default.number,
209
212
 
210
213
  /**
211
- * The error object
214
+ * The function to transform the search input
212
215
  */
213
- error: _propTypes.default.objectOf(_propTypes.default.string)
216
+ transformSearch: _propTypes.default.func
214
217
  };
215
218
  QueryCombobox.defaultProps = {
216
- extraVariables: {},
219
+ optionsKeyMap: {
220
+ value: 'id',
221
+ label: 'name'
222
+ },
217
223
  multiple: false,
218
224
  color: 'background2',
219
- searchVariable: 'search'
225
+ searchVariable: 'search',
226
+ transformSearch: search => search,
227
+ minLength: 2
220
228
  };
221
229
  var _default = QueryCombobox;
222
230
  exports.default = _default;
@@ -15,6 +15,8 @@ var _bem = _interopRequireDefault(require("@pareto-engineering/bem"));
15
15
 
16
16
  var _ = require("../../../..");
17
17
 
18
+ var _a = require("../../../../../a");
19
+
18
20
  var _Menu = require("../Menu");
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -39,14 +41,20 @@ var Combobox = _ref => {
39
41
  label,
40
42
  name,
41
43
  options: items,
42
- fetchOptions,
44
+ getOptions,
43
45
  setValue,
44
46
  error,
45
- description // ...otherProps
47
+ description,
48
+ value,
49
+ color,
50
+ minLength,
51
+ isFetching,
52
+ transformSearch // ...otherProps
46
53
 
47
54
  } = _ref;
48
55
  var {
49
56
  isOpen,
57
+ selectItem,
50
58
  selectedItem,
51
59
  getLabelProps,
52
60
  getMenuProps,
@@ -56,34 +64,55 @@ var Combobox = _ref => {
56
64
  getItemProps
57
65
  } = (0, _downshift.useCombobox)({
58
66
  items,
67
+ initialSelectedItem: value,
59
68
  itemToString: item => item ? item.label : '',
60
69
  onInputValueChange: _ref2 => {
61
70
  var {
62
71
  inputValue
63
72
  } = _ref2;
64
- fetchOptions(inputValue);
73
+ var transformedInput = transformSearch(inputValue);
74
+
75
+ if (transformedInput.length > minLength) {
76
+ getOptions(transformedInput);
77
+ }
65
78
  }
66
- });
79
+ }); // If the user has selected an item, we'll set the value of the field
80
+ // or if the combobox state has a selected item, we'll set the value to the formik state
81
+
67
82
  (0, React.useEffect)(() => {
68
83
  if (selectedItem) {
69
- setValue(selectedItem.value);
84
+ setValue(selectedItem);
85
+ }
86
+ }, [selectedItem]); // If the formik state has a value, we'll set the selected item to the combobox state
87
+
88
+ (0, React.useEffect)(() => {
89
+ if ((value === null || value === void 0 ? void 0 : value.value) !== (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value)) {
90
+ selectItem(value);
70
91
  }
71
- }, [selectedItem]);
92
+ }, [value]);
93
+ var parentRef = (0, React.useRef)(null);
72
94
  return /*#__PURE__*/React.createElement("div", {
73
95
  id: id,
74
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
75
- style: style
96
+ className: [baseClassName, componentClassName, userClassName, "y-".concat(color)].filter(e => e).join(' '),
97
+ style: style,
98
+ ref: parentRef
76
99
  }, /*#__PURE__*/React.createElement(_.FormLabel, _extends({}, getLabelProps(), {
77
- className: "input-label",
78
100
  name: name
79
- }), label), /*#__PURE__*/React.createElement("div", getComboboxProps(), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
101
+ }), label), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
102
+ className: "input-wrapper"
103
+ }), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(), {
80
104
  className: "input"
81
- }))), /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
105
+ })), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
106
+ className: "x-main2"
107
+ })), /*#__PURE__*/React.createElement(_a.Popover, {
108
+ isOpen: isOpen,
109
+ parentRef: parentRef
110
+ }, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
82
111
  isOpen: isOpen,
83
112
  getItemProps: getItemProps,
84
113
  highlightedIndex: highlightedIndex,
85
114
  items: items
86
- }, getMenuProps())), (description || error) && /*#__PURE__*/React.createElement(_.FormDescription, {
115
+ }, getMenuProps()))), (description || error) && /*#__PURE__*/React.createElement(_.FormDescription, {
87
116
  isError: !!error
88
117
  }, error || description));
89
118
  };
@@ -125,7 +154,7 @@ Combobox.propTypes = {
125
154
  /**
126
155
  * The function to fetch the options from the backend
127
156
  */
128
- fetchOptions: _propTypes.default.func,
157
+ getOptions: _propTypes.default.func,
129
158
 
130
159
  /**
131
160
  * The function to set the value of the custom select input
@@ -140,9 +169,37 @@ Combobox.propTypes = {
140
169
  /**
141
170
  * The error object
142
171
  */
143
- error: _propTypes.default.objectOf(_propTypes.default.string)
172
+ error: _propTypes.default.objectOf(_propTypes.default.string),
173
+
174
+ /**
175
+ * The value of the custom select input
176
+ */
177
+ value: _propTypes.default.shape({
178
+ value: _propTypes.default.string,
179
+ label: _propTypes.default.string
180
+ }),
181
+
182
+ /**
183
+ * The base color of the combobox custom select input
184
+ */
185
+ color: _propTypes.default.string,
186
+
187
+ /**
188
+ * Whether the query getting the combobox options is inFlight
189
+ */
190
+ isFetching: _propTypes.default.bool.isRequired,
191
+
192
+ /**
193
+ * The minimum length of the search input to start fetching the options
194
+ */
195
+ minLength: _propTypes.default.number,
196
+
197
+ /**
198
+ * The function to transform the search input
199
+ */
200
+ transformSearch: _propTypes.default.func
144
201
  };
145
- Combobox.defaultProps = {// someProp:false
202
+ Combobox.defaultProps = {// someProp: false
146
203
  };
147
204
  var _default = Combobox;
148
205
  exports.default = _default;
@@ -55,7 +55,7 @@ var Menu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
55
55
  item,
56
56
  index
57
57
  }), {
58
- className: "item ".concat(highlightedIndex === index ? _bem.default.modifierActive : '')
58
+ className: ['item', highlightedIndex === index && _bem.default.modifierActive].filter(Boolean).join(' ')
59
59
  }), /*#__PURE__*/React.createElement("p", null, item.label))));
60
60
  });
61
61
  Menu.propTypes = {
@@ -15,6 +15,8 @@ var _downshift = require("downshift");
15
15
 
16
16
  var _b = require("../../../../../b");
17
17
 
18
+ var _a = require("../../../../../a");
19
+
18
20
  var _ = require("../../../..");
19
21
 
20
22
  var _Menu = require("../Menu");
@@ -35,10 +37,19 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
35
37
 
36
38
  var baseClassName = _bem.default.base;
37
39
  var componentClassName = 'multiple-combobox';
40
+ /**
41
+ * @param {Array[Object]} first - first array to check if it has an item not in the second array.
42
+ * @param {Array[Object]} second - second array to check against the first array.
43
+ *
44
+ * @returns {Boolean} - true if the first array has an item not in the second array.
45
+ */
46
+
47
+ var testIfArraysAreUnique = (first, second) => first.filter(objInFirstArray => !second.some(objInSecondArray => objInFirstArray.value === objInSecondArray.value)).length > 0;
38
48
  /**
39
49
  * This is the component description.
40
50
  */
41
51
 
52
+
42
53
  var MultipleCombobox = _ref => {
43
54
  var {
44
55
  id,
@@ -47,22 +58,34 @@ var MultipleCombobox = _ref => {
47
58
  label,
48
59
  name,
49
60
  options: items,
50
- fetchOptions,
61
+ getOptions,
51
62
  setValue,
52
63
  error,
53
- description // ...otherProps
64
+ description,
65
+ value,
66
+ color,
67
+ isFetching,
68
+ minLength,
69
+ transformSearch // ...otherProps
54
70
 
55
71
  } = _ref;
56
- var [inputValue, setInputValue] = (0, React.useState)('');
72
+ var [searchInputValue, setSearchInputValue] = (0, React.useState)('');
57
73
  var {
58
74
  getSelectedItemProps,
59
75
  getDropdownProps,
60
76
  addSelectedItem,
61
77
  removeSelectedItem,
78
+ setSelectedItems,
62
79
  selectedItems
63
- } = (0, _downshift.useMultipleSelection)();
80
+ } = (0, _downshift.useMultipleSelection)({
81
+ initialSelectedItems: value || []
82
+ });
83
+ /**
84
+ * @returns {Boolean} - Unique items from the options array so that the combobox
85
+ * shows only the options that are not yet selected.
86
+ */
64
87
 
65
- var getFilteredItems = () => items.filter(item => selectedItems.findIndex(e => e.label === item.label) < 0 && item.label.toLowerCase().startsWith(inputValue.toLowerCase()));
88
+ var getFilteredItems = () => items.filter(item => selectedItems.findIndex(e => e.label === item.label) < 0);
66
89
 
67
90
  var {
68
91
  isOpen,
@@ -73,7 +96,7 @@ var MultipleCombobox = _ref => {
73
96
  highlightedIndex,
74
97
  getItemProps
75
98
  } = (0, _downshift.useCombobox)({
76
- inputValue,
99
+ searchInputValue,
77
100
  defaultHighlightedIndex: 0,
78
101
  // after selection, highlight the first item.
79
102
  selectedItem: null,
@@ -101,22 +124,29 @@ var MultipleCombobox = _ref => {
101
124
  },
102
125
  onStateChange: _ref2 => {
103
126
  var {
104
- inputValue: newInputValue,
127
+ inputValue: newSearchInputValue,
105
128
  type,
106
129
  selectedItem
107
130
  } = _ref2;
108
131
 
109
132
  switch (type) {
110
133
  case _downshift.useCombobox.stateChangeTypes.InputChange:
111
- fetchOptions(newInputValue);
112
- setInputValue(newInputValue);
113
- break;
134
+ {
135
+ var transformedInput = transformSearch(newSearchInputValue);
136
+
137
+ if (transformedInput.length > minLength) {
138
+ getOptions(transformedInput);
139
+ }
140
+
141
+ setSearchInputValue(newSearchInputValue);
142
+ break;
143
+ }
114
144
 
115
145
  case _downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
116
146
  case _downshift.useCombobox.stateChangeTypes.ItemClick:
117
147
  case _downshift.useCombobox.stateChangeTypes.InputBlur:
118
148
  if (selectedItem) {
119
- setInputValue('');
149
+ setSearchInputValue('');
120
150
  addSelectedItem(selectedItem);
121
151
  }
122
152
 
@@ -128,16 +158,21 @@ var MultipleCombobox = _ref => {
128
158
  }
129
159
  });
130
160
  (0, React.useEffect)(() => {
131
- if (selectedItems.length > 0) {
132
- setValue(selectedItems.map(e => e.value));
161
+ if ((selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) > 0) {
162
+ setValue(selectedItems);
133
163
  }
134
164
  }, [selectedItems]);
165
+ (0, React.useEffect)(() => {
166
+ if ((value === null || value === void 0 ? void 0 : value.length) > 0 && (testIfArraysAreUnique(value, selectedItems) || testIfArraysAreUnique(selectedItems, value))) {
167
+ setSelectedItems(value);
168
+ }
169
+ }, [value]);
170
+ var parentRef = (0, React.useRef)(null);
135
171
  return /*#__PURE__*/React.createElement("div", {
136
172
  id: id,
137
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
173
+ className: [baseClassName, componentClassName, userClassName, "y-".concat(color)].filter(e => e).join(' '),
138
174
  style: style
139
175
  }, /*#__PURE__*/React.createElement(_.FormLabel, _extends({}, getLabelProps(), {
140
- className: "input-label",
141
176
  name: name
142
177
  }), label), /*#__PURE__*/React.createElement("div", {
143
178
  className: "selected-items"
@@ -155,16 +190,23 @@ var MultipleCombobox = _ref => {
155
190
  isCompact: true,
156
191
  isSimple: true,
157
192
  color: "main2"
158
- }, "X")))), /*#__PURE__*/React.createElement("div", getComboboxProps(), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
193
+ }, "X")))), /*#__PURE__*/React.createElement("div", _extends({}, getComboboxProps(), {
194
+ className: "input-wrapper"
195
+ }), /*#__PURE__*/React.createElement("input", _extends({}, getInputProps(getDropdownProps({
159
196
  preventKeyAction: isOpen
160
197
  })), {
161
198
  className: "input"
162
- }))), /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
199
+ })), isFetching && /*#__PURE__*/React.createElement(_a.LoadingCircle, {
200
+ className: "x-main2"
201
+ })), /*#__PURE__*/React.createElement(_a.Popover, {
202
+ isOpen: isOpen,
203
+ parentRef: parentRef
204
+ }, /*#__PURE__*/React.createElement(_Menu.Menu, _extends({
163
205
  isOpen: isOpen,
164
206
  getItemProps: getItemProps,
165
207
  highlightedIndex: highlightedIndex,
166
208
  items: getFilteredItems()
167
- }, getMenuProps())), (description || error) && /*#__PURE__*/React.createElement(_.FormDescription, {
209
+ }, getMenuProps()))), (description || error) && /*#__PURE__*/React.createElement(_.FormDescription, {
168
210
  isError: !!error
169
211
  }, error || description));
170
212
  };
@@ -206,7 +248,7 @@ MultipleCombobox.propTypes = {
206
248
  /**
207
249
  * The function to fetch the options from the backend
208
250
  */
209
- fetchOptions: _propTypes.default.func,
251
+ getOptions: _propTypes.default.func,
210
252
 
211
253
  /**
212
254
  * The function to set the value of the custom select input
@@ -221,9 +263,37 @@ MultipleCombobox.propTypes = {
221
263
  /**
222
264
  * The error object
223
265
  */
224
- error: _propTypes.default.objectOf(_propTypes.default.string)
266
+ error: _propTypes.default.objectOf(_propTypes.default.string),
267
+
268
+ /**
269
+ * The value of the custom select input
270
+ */
271
+ value: _propTypes.default.arrayOf(_propTypes.default.shape({
272
+ value: _propTypes.default.string,
273
+ label: _propTypes.default.string
274
+ })),
275
+
276
+ /**
277
+ * The base color of the custom select input
278
+ */
279
+ color: _propTypes.default.string,
280
+
281
+ /**
282
+ * Whether the query getting the combobox options is inFlight
283
+ */
284
+ isFetching: _propTypes.default.bool.isRequired,
285
+
286
+ /**
287
+ * The minimum length of the search input to start fetching the options
288
+ */
289
+ minLength: _propTypes.default.number,
290
+
291
+ /**
292
+ * The function to transform the search input
293
+ */
294
+ transformSearch: _propTypes.default.func
225
295
  };
226
- MultipleCombobox.defaultProps = {// someProp:false
296
+ MultipleCombobox.defaultProps = {// someProp: false
227
297
  };
228
298
  var _default = MultipleCombobox;
229
299
  exports.default = _default;
@@ -5,61 +5,74 @@
5
5
  $default-input-padding: .75em .75em .55em;
6
6
  $default-padding: 1em;
7
7
  $default-margin: 1em;
8
+ $default-loading-circle-displacement: 1em;
8
9
 
9
- .#{bem.$base}.query-combobox {
10
- .input {
11
- background: var(--light-y);
12
- border: var(--theme-border-style) var(--dark-y);
13
- color: var(--on-y);
14
- padding: $default-input-padding;
15
- width: 100%;
10
+ .#{bem.$base}.combobox,
11
+ .#{bem.$base}.multiple-combobox {
12
+ position: relative;
16
13
 
17
- &::placeholder {
18
- color: var(--metadata);
19
- }
14
+ .#{bem.$base}.label {
15
+ margin-bottom: $default-margin
16
+ }
20
17
 
21
- &:not(:disabled):hover {
22
- border: var(--theme-border-style) var(--light-background4);
23
- }
18
+ .#{bem.$base}.popover {
19
+ width: 100%;
24
20
 
25
- &:disabled {
26
- background-color: var(--dark-y);
27
- }
21
+ >.menu {
22
+ list-style: none;
23
+ margin: 0;
24
+ outline: 0;
25
+ padding: 0;
28
26
 
29
- &:focus {
30
- background: var(--light-background4);
27
+ >.item {
28
+ padding: $default-padding / 2;
29
+
30
+ &.#{bem.$modifier-active} {
31
+ background-color: var(--background2);
32
+ }
33
+ }
31
34
  }
32
35
  }
33
36
 
34
- .menu {
35
- list-style: none;
36
- margin: 0;
37
- outline: 0;
38
- padding: 0;
37
+ >.input-wrapper {
38
+ position: relative;
39
39
 
40
- /* stylelint-disable selector-max-universal -- Allow */
41
- >* {
42
- padding-block: $default-padding / 2;
40
+ >.#{bem.$base}.loading-circle {
41
+ position: absolute;
42
+ top: $default-loading-circle-displacement;
43
+ right: $default-loading-circle-displacement;
43
44
  }
44
45
 
45
- /* stylelint-enable selector-max-universal */
46
- >.item {
47
- &.#{bem.$modifier-active} {
48
- background-color: var(--background2);
46
+ >.input {
47
+ background: var(--light-y);
48
+ border: var(--theme-border-style) var(--dark-y);
49
+ color: var(--on-y);
50
+ padding: $default-input-padding;
51
+ width: 100%;
52
+
53
+ &::placeholder {
54
+ color: var(--metadata);
49
55
  }
50
- }
51
- }
52
56
 
53
- .multiple-combobox {
54
- .selected-items {
55
- display: flex;
57
+ &:not(:disabled):hover {
58
+ border: var(--theme-border-style) var(--light-background4);
59
+ }
56
60
 
57
- /* stylelint-disable selector-max-universal -- Allow */
58
- >*:not(:first-child) {
59
- margin-left: $default-margin;
61
+ &:disabled {
62
+ background-color: var(--dark-y);
60
63
  }
61
64
 
62
- /* stylelint-enable selector-max-universal */
65
+ &:focus {
66
+ background: var(--light-background4);
67
+ }
63
68
  }
64
69
  }
70
+ }
71
+
72
+
73
+ .#{bem.$base}.multiple-combobox {
74
+ >.selected-items {
75
+ display: flex;
76
+ gap: var(--default-gap);
77
+ }
65
78
  }