@entur/dropdown 2.1.1 → 2.2.2
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.
- package/CHANGELOG.md +27 -0
- package/dist/DownshiftProvider.d.ts +1 -0
- package/dist/SearchableDropdown.d.ts +1 -0
- package/dist/dropdown.cjs.development.js +969 -143
- package/dist/dropdown.cjs.development.js.map +1 -1
- package/dist/dropdown.cjs.production.min.js +1 -1
- package/dist/dropdown.cjs.production.min.js.map +1 -1
- package/dist/dropdown.esm.js +907 -83
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +9 -0
- package/package.json +14 -14
|
@@ -2,20 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var utils = require('@entur/utils');
|
|
8
6
|
var React = require('react');
|
|
9
|
-
var React__default = _interopDefault(React);
|
|
10
7
|
var Downshift = require('downshift');
|
|
11
|
-
var
|
|
12
|
-
var classNames = _interopDefault(require('classnames'));
|
|
8
|
+
var classNames = require('classnames');
|
|
13
9
|
var form = require('@entur/form');
|
|
14
10
|
var icons = require('@entur/icons');
|
|
15
11
|
var a11y = require('@entur/a11y');
|
|
16
12
|
var loader = require('@entur/loader');
|
|
17
13
|
var tokens = require('@entur/tokens');
|
|
18
14
|
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
18
|
+
var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
19
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
20
|
+
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
22
|
+
try {
|
|
23
|
+
var info = gen[key](arg);
|
|
24
|
+
var value = info.value;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
reject(error);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (info.done) {
|
|
31
|
+
resolve(value);
|
|
32
|
+
} else {
|
|
33
|
+
Promise.resolve(value).then(_next, _throw);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _asyncToGenerator(fn) {
|
|
38
|
+
return function () {
|
|
39
|
+
var self = this,
|
|
40
|
+
args = arguments;
|
|
41
|
+
return new Promise(function (resolve, reject) {
|
|
42
|
+
var gen = fn.apply(self, args);
|
|
43
|
+
|
|
44
|
+
function _next(value) {
|
|
45
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _throw(err) {
|
|
49
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_next(undefined);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
19
57
|
function _extends() {
|
|
20
58
|
_extends = Object.assign || function (target) {
|
|
21
59
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -49,7 +87,8 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
49
87
|
return target;
|
|
50
88
|
}
|
|
51
89
|
|
|
52
|
-
var
|
|
90
|
+
var _excluded$8 = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
|
|
91
|
+
var DownshiftContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
53
92
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
54
93
|
var children = _ref.children,
|
|
55
94
|
_ref$onChange = _ref.onChange,
|
|
@@ -64,10 +103,12 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
64
103
|
highlightFirstItemOnOpen = _ref$highlightFirstIt === void 0 ? false : _ref$highlightFirstIt,
|
|
65
104
|
className = _ref.className,
|
|
66
105
|
style = _ref.style,
|
|
67
|
-
|
|
106
|
+
_ref$searchable = _ref.searchable,
|
|
107
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
108
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
68
109
|
|
|
69
110
|
var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
|
|
70
|
-
if (changes.type === Downshift__default.stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
111
|
+
if (changes.type === Downshift__default["default"].stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
71
112
|
return;
|
|
72
113
|
}
|
|
73
114
|
|
|
@@ -79,36 +120,53 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
79
120
|
};
|
|
80
121
|
|
|
81
122
|
var stateReducer = function stateReducer(_, changes) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
123
|
+
var highlightFirstOnOpen = highlightFirstItemOnOpen && 'isOpen' in changes && changes.isOpen;
|
|
124
|
+
var highlightFirstItemIndex = highlightFirstOnOpen ? {
|
|
125
|
+
highlightedIndex: 0
|
|
126
|
+
} : {};
|
|
127
|
+
|
|
128
|
+
if (searchable) {
|
|
129
|
+
var type = changes.type;
|
|
130
|
+
|
|
131
|
+
switch (type) {
|
|
132
|
+
case '__autocomplete_change_input__':
|
|
133
|
+
return _extends({}, changes, highlightFirstItemIndex);
|
|
134
|
+
|
|
135
|
+
case '__autocomplete_click_item__':
|
|
136
|
+
case '__autocomplete_keydown_enter__':
|
|
137
|
+
case '__autocomplete_blur_input__':
|
|
138
|
+
case '__autocomplete_mouseup__':
|
|
139
|
+
return _extends({}, changes, {
|
|
140
|
+
// if we had an item highlighted in the previous state.
|
|
141
|
+
// we will reset input field value to blank
|
|
142
|
+
inputValue: ''
|
|
143
|
+
}, highlightFirstItemIndex);
|
|
144
|
+
|
|
145
|
+
default:
|
|
146
|
+
return _extends({}, changes, highlightFirstItemIndex);
|
|
89
147
|
}
|
|
148
|
+
} else {
|
|
149
|
+
return _extends({}, changes, highlightFirstItemIndex);
|
|
90
150
|
}
|
|
91
|
-
|
|
92
|
-
return changes;
|
|
93
151
|
};
|
|
94
152
|
|
|
95
|
-
return React__default.createElement(Downshift__default,
|
|
153
|
+
return React__default["default"].createElement(Downshift__default["default"], _extends({
|
|
96
154
|
itemToString: function itemToString(item) {
|
|
97
155
|
return item ? item.label : '';
|
|
98
156
|
},
|
|
99
157
|
onStateChange: handleStateChange,
|
|
100
158
|
stateReducer: stateReducer
|
|
101
159
|
}, rest), function (args) {
|
|
102
|
-
return React__default.createElement("div", {
|
|
103
|
-
className:
|
|
160
|
+
return React__default["default"].createElement("div", {
|
|
161
|
+
className: classNames__default["default"]('eds-input-group', className),
|
|
104
162
|
style: style
|
|
105
|
-
}, React__default.createElement(DownshiftContext.Provider, {
|
|
163
|
+
}, React__default["default"].createElement(DownshiftContext.Provider, {
|
|
106
164
|
value: args
|
|
107
165
|
}, children));
|
|
108
166
|
});
|
|
109
167
|
};
|
|
110
168
|
var useDownshift = function useDownshift() {
|
|
111
|
-
var context = React__default.useContext(DownshiftContext);
|
|
169
|
+
var context = React__default["default"].useContext(DownshiftContext);
|
|
112
170
|
|
|
113
171
|
if (!context) {
|
|
114
172
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
@@ -117,9 +175,10 @@ var useDownshift = function useDownshift() {
|
|
|
117
175
|
return context;
|
|
118
176
|
};
|
|
119
177
|
|
|
178
|
+
var _excluded$7 = ["items"];
|
|
120
179
|
var DropdownList = function DropdownList(_ref) {
|
|
121
180
|
var items = _ref.items,
|
|
122
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
181
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
123
182
|
|
|
124
183
|
var _useDownshift = useDownshift(),
|
|
125
184
|
highlightedIndex = _useDownshift.highlightedIndex,
|
|
@@ -128,14 +187,14 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
128
187
|
getItemProps = _useDownshift.getItemProps,
|
|
129
188
|
getMenuProps = _useDownshift.getMenuProps;
|
|
130
189
|
|
|
131
|
-
return React__default.createElement("ul",
|
|
132
|
-
className:
|
|
190
|
+
return React__default["default"].createElement("ul", _extends({
|
|
191
|
+
className: classNames__default["default"]('eds-dropdown-list', {
|
|
133
192
|
'eds-dropdown-list--open': isOpen
|
|
134
193
|
})
|
|
135
194
|
}, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
|
|
136
195
|
return (// eslint-disable-next-line react/jsx-key
|
|
137
|
-
React__default.createElement("li",
|
|
138
|
-
className:
|
|
196
|
+
React__default["default"].createElement("li", _extends({
|
|
197
|
+
className: classNames__default["default"]('eds-dropdown-list__item', {
|
|
139
198
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
140
199
|
'eds-dropdown-list__item--selected': selectedItem === item
|
|
141
200
|
})
|
|
@@ -143,42 +202,44 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
143
202
|
key: "" + index + item.value,
|
|
144
203
|
item: item,
|
|
145
204
|
index: index
|
|
146
|
-
})), React__default.createElement("span", null, item.label), item.icons && React__default.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
147
|
-
return React__default.createElement(Icon, {
|
|
205
|
+
})), React__default["default"].createElement("span", null, item.label), item.icons && React__default["default"].createElement("span", null, item.icons.map(function (Icon, index) {
|
|
206
|
+
return React__default["default"].createElement(Icon, {
|
|
148
207
|
key: index,
|
|
149
208
|
inline: true,
|
|
150
209
|
className: "eds-dropdown-list__item-icon"
|
|
151
210
|
});
|
|
152
|
-
})), selectedItem === item && React__default.createElement(icons.CheckIcon, null))
|
|
211
|
+
})), selectedItem === item && React__default["default"].createElement(icons.CheckIcon, null))
|
|
153
212
|
);
|
|
154
213
|
}) : null);
|
|
155
214
|
};
|
|
156
215
|
|
|
157
|
-
var DropdownToggleButton = function DropdownToggleButton() {
|
|
216
|
+
var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
158
217
|
var _useDownshift = useDownshift(),
|
|
159
218
|
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
160
219
|
isOpen = _useDownshift.isOpen;
|
|
161
220
|
|
|
162
|
-
return React__default.createElement("button",
|
|
163
|
-
className:
|
|
221
|
+
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
222
|
+
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
164
223
|
'eds-dropdown__toggle-button--open': isOpen
|
|
165
224
|
})
|
|
166
225
|
}), {
|
|
167
226
|
tabIndex: "-1",
|
|
168
227
|
type: "button"
|
|
169
|
-
}), React__default.createElement(icons.DownArrowIcon, null));
|
|
228
|
+
}), React__default["default"].createElement(icons.DownArrowIcon, null));
|
|
170
229
|
};
|
|
171
230
|
|
|
231
|
+
var _excluded$6 = ["className", "children"];
|
|
172
232
|
var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
173
233
|
var className = _ref.className,
|
|
174
234
|
children = _ref.children,
|
|
175
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
235
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
176
236
|
|
|
177
|
-
return React__default.createElement("div",
|
|
178
|
-
className:
|
|
179
|
-
}, rest), React__default.createElement(loader.LoadingDots, null), React__default.createElement(a11y.VisuallyHidden, null, children));
|
|
237
|
+
return React__default["default"].createElement("div", _extends({
|
|
238
|
+
className: classNames__default["default"]('eds-inline-spinner', className)
|
|
239
|
+
}, rest), React__default["default"].createElement(loader.LoadingDots, null), React__default["default"].createElement(a11y.VisuallyHidden, null, children));
|
|
180
240
|
};
|
|
181
241
|
|
|
242
|
+
var _excluded$5 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
|
|
182
243
|
var BaseDropdown = function BaseDropdown(_ref) {
|
|
183
244
|
var children = _ref.children,
|
|
184
245
|
className = _ref.className,
|
|
@@ -194,16 +255,16 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
194
255
|
_ref$isFilled = _ref.isFilled,
|
|
195
256
|
isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
|
|
196
257
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
197
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
258
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
198
259
|
|
|
199
260
|
var _useDownshift = useDownshift(),
|
|
200
261
|
getLabelProps = _useDownshift.getLabelProps;
|
|
201
262
|
|
|
202
|
-
return React__default.createElement("div", {
|
|
263
|
+
return React__default["default"].createElement("div", {
|
|
203
264
|
className: "eds-dropdown-wrapper",
|
|
204
265
|
style: style
|
|
205
|
-
}, React__default.createElement(form.BaseFormControl,
|
|
206
|
-
append: React__default.createElement(Appendix, {
|
|
266
|
+
}, React__default["default"].createElement(form.BaseFormControl, _extends({
|
|
267
|
+
append: React__default["default"].createElement(Appendix$1, {
|
|
207
268
|
clearable: clearable,
|
|
208
269
|
loading: loading,
|
|
209
270
|
loadingText: loadingText,
|
|
@@ -214,7 +275,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
214
275
|
isFilled: isFilled,
|
|
215
276
|
labelProps: getLabelProps(),
|
|
216
277
|
disableLabelAnimation: disableLabelAnimation
|
|
217
|
-
}, rest), children), React__default.createElement(DropdownList,
|
|
278
|
+
}, rest), children), React__default["default"].createElement(DropdownList, _extends({
|
|
218
279
|
items: items,
|
|
219
280
|
style: _extends({
|
|
220
281
|
position: 'absolute',
|
|
@@ -223,42 +284,43 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
223
284
|
}, rest)));
|
|
224
285
|
};
|
|
225
286
|
|
|
226
|
-
var ClearButton = function ClearButton(_ref2) {
|
|
287
|
+
var ClearButton$1 = function ClearButton(_ref2) {
|
|
227
288
|
var props = _extends({}, _ref2);
|
|
228
289
|
|
|
229
290
|
var _useDownshift2 = useDownshift(),
|
|
230
291
|
clearSelection = _useDownshift2.clearSelection,
|
|
231
292
|
selectedItem = _useDownshift2.selectedItem;
|
|
232
293
|
|
|
233
|
-
return React__default.createElement(React__default.Fragment, null, selectedItem && React__default.createElement("button",
|
|
294
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, selectedItem && React__default["default"].createElement("button", _extends({
|
|
234
295
|
className: "eds-dropdown__clear-button",
|
|
235
296
|
type: "button",
|
|
236
297
|
tabIndex: -1,
|
|
237
298
|
onClick: function onClick() {
|
|
238
299
|
return clearSelection();
|
|
239
300
|
}
|
|
240
|
-
}, props), React__default.createElement(icons.CloseSmallIcon, null)), selectedItem && React__default.createElement("div", {
|
|
301
|
+
}, props), React__default["default"].createElement(icons.CloseSmallIcon, null)), selectedItem && React__default["default"].createElement("div", {
|
|
241
302
|
className: "eds-dropdown__divider"
|
|
242
303
|
}));
|
|
243
304
|
};
|
|
244
305
|
|
|
245
|
-
var Appendix = function Appendix(_ref3) {
|
|
306
|
+
var Appendix$1 = function Appendix(_ref3) {
|
|
246
307
|
var clearable = _ref3.clearable,
|
|
247
308
|
loading = _ref3.loading,
|
|
248
309
|
loadingText = _ref3.loadingText,
|
|
249
310
|
readOnly = _ref3.readOnly;
|
|
250
311
|
|
|
251
312
|
if (loading) {
|
|
252
|
-
return React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
313
|
+
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
253
314
|
}
|
|
254
315
|
|
|
255
316
|
if (readOnly) {
|
|
256
317
|
return null;
|
|
257
318
|
}
|
|
258
319
|
|
|
259
|
-
return clearable ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ClearButton, null), " ", React__default.createElement(DropdownToggleButton, null)) : React__default.createElement(DropdownToggleButton, null);
|
|
320
|
+
return clearable ? React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(ClearButton$1, null), " ", React__default["default"].createElement(DropdownToggleButton$1, null)) : React__default["default"].createElement(DropdownToggleButton$1, null);
|
|
260
321
|
};
|
|
261
322
|
|
|
323
|
+
var _excluded$4 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
262
324
|
var RegularDropdown = function RegularDropdown(_ref) {
|
|
263
325
|
var disabled = _ref.disabled,
|
|
264
326
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -275,7 +337,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
275
337
|
loadingText = _ref.loadingText,
|
|
276
338
|
className = _ref.className,
|
|
277
339
|
clearable = _ref.clearable,
|
|
278
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
340
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
279
341
|
|
|
280
342
|
var _useDownshift = useDownshift(),
|
|
281
343
|
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
@@ -286,7 +348,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
286
348
|
highlightedIndex = _useDownshift.highlightedIndex,
|
|
287
349
|
setHighlightedIndex = _useDownshift.setHighlightedIndex;
|
|
288
350
|
|
|
289
|
-
return React__default.createElement(BaseDropdown,
|
|
351
|
+
return React__default["default"].createElement(BaseDropdown, _extends({
|
|
290
352
|
disabled: disabled,
|
|
291
353
|
listStyle: listStyle,
|
|
292
354
|
items: items,
|
|
@@ -297,7 +359,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
297
359
|
loadingText: loadingText,
|
|
298
360
|
className: className,
|
|
299
361
|
clearable: clearable
|
|
300
|
-
}, rest), React__default.createElement("button",
|
|
362
|
+
}, rest), React__default["default"].createElement("button", _extends({}, getToggleButtonProps(_extends({
|
|
301
363
|
className: 'eds-form-control eds-dropdown__selected-item',
|
|
302
364
|
style: {
|
|
303
365
|
textAlign: 'left'
|
|
@@ -320,7 +382,7 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
320
382
|
return firstCharacter === keyDownValue;
|
|
321
383
|
});
|
|
322
384
|
var nextHighlightItem = matchedItems.find(function (item) {
|
|
323
|
-
return item.index > (highlightedIndex
|
|
385
|
+
return item.index > (highlightedIndex != null ? highlightedIndex : 0);
|
|
324
386
|
});
|
|
325
387
|
|
|
326
388
|
if (nextHighlightItem) {
|
|
@@ -338,6 +400,8 @@ var RegularDropdown = function RegularDropdown(_ref) {
|
|
|
338
400
|
}, rest))), selectedItem ? selectedItem.label : placeholder));
|
|
339
401
|
};
|
|
340
402
|
|
|
403
|
+
var _excluded$3 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
404
|
+
|
|
341
405
|
function LowerCaseFilterTest(item, input) {
|
|
342
406
|
if (!input) {
|
|
343
407
|
return true;
|
|
@@ -370,7 +434,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
370
434
|
} : _ref$itemFilter,
|
|
371
435
|
label = _ref.label,
|
|
372
436
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
373
|
-
|
|
437
|
+
placeholder = _ref.placeholder,
|
|
438
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
374
439
|
|
|
375
440
|
var _useDownshift = useDownshift(),
|
|
376
441
|
getInputProps = _useDownshift.getInputProps,
|
|
@@ -380,12 +445,12 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
380
445
|
openMenu = _useDownshift.openMenu,
|
|
381
446
|
selectedItem = _useDownshift.selectedItem;
|
|
382
447
|
|
|
383
|
-
var filteredItems = React__default.useMemo(function () {
|
|
448
|
+
var filteredItems = React__default["default"].useMemo(function () {
|
|
384
449
|
return items.filter(function (item) {
|
|
385
450
|
return itemFilter(item, inputValue);
|
|
386
451
|
});
|
|
387
452
|
}, [inputValue, items, itemFilter]);
|
|
388
|
-
return React__default.createElement(BaseDropdown, {
|
|
453
|
+
return React__default["default"].createElement(BaseDropdown, {
|
|
389
454
|
items: filteredItems,
|
|
390
455
|
disabled: disabled,
|
|
391
456
|
readOnly: readOnly,
|
|
@@ -398,7 +463,9 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
398
463
|
label: label,
|
|
399
464
|
isFilled: selectedItem ? true : false,
|
|
400
465
|
disableLabelAnimation: disableLabelAnimation
|
|
401
|
-
}, React__default.createElement("
|
|
466
|
+
}, selectedItem && !inputValue && React__default["default"].createElement("span", {
|
|
467
|
+
className: "eds-dropdown__searchable-selected-item"
|
|
468
|
+
}, selectedItem.label), React__default["default"].createElement("input", _extends({}, getInputProps(_extends({
|
|
402
469
|
disabled: disabled,
|
|
403
470
|
readOnly: readOnly,
|
|
404
471
|
className: 'eds-form-control eds-dropdown__input',
|
|
@@ -411,7 +478,8 @@ var SearchableDropdown = function SearchableDropdown(_ref) {
|
|
|
411
478
|
if (openOnFocus) {
|
|
412
479
|
!isOpen && openMenu();
|
|
413
480
|
}
|
|
414
|
-
}
|
|
481
|
+
},
|
|
482
|
+
placeholder: selectedItem ? undefined : placeholder
|
|
415
483
|
}, rest)))));
|
|
416
484
|
};
|
|
417
485
|
|
|
@@ -421,18 +489,747 @@ var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
|
421
489
|
variant = _ref.variant,
|
|
422
490
|
className = _ref.className,
|
|
423
491
|
style = _ref.style;
|
|
424
|
-
return React__default.createElement(form.VariantProvider, {
|
|
492
|
+
return React__default["default"].createElement(form.VariantProvider, {
|
|
425
493
|
variant: variant
|
|
426
|
-
}, React__default.createElement("div", {
|
|
494
|
+
}, React__default["default"].createElement("div", {
|
|
427
495
|
className: className,
|
|
428
496
|
style: style
|
|
429
|
-
}, children, feedback && variant && React__default.createElement(form.FeedbackText, {
|
|
497
|
+
}, children, feedback && variant && React__default["default"].createElement(form.FeedbackText, {
|
|
430
498
|
variant: variant
|
|
431
499
|
}, feedback)));
|
|
432
500
|
};
|
|
433
501
|
|
|
502
|
+
var runtime = {exports: {}};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
506
|
+
*
|
|
507
|
+
* This source code is licensed under the MIT license found in the
|
|
508
|
+
* LICENSE file in the root directory of this source tree.
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
(function (module) {
|
|
512
|
+
var runtime = /*#__PURE__*/function (exports) {
|
|
513
|
+
|
|
514
|
+
var Op = Object.prototype;
|
|
515
|
+
var hasOwn = Op.hasOwnProperty;
|
|
516
|
+
var undefined$1; // More compressible than void 0.
|
|
517
|
+
|
|
518
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
519
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
520
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
521
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
522
|
+
|
|
523
|
+
function define(obj, key, value) {
|
|
524
|
+
Object.defineProperty(obj, key, {
|
|
525
|
+
value: value,
|
|
526
|
+
enumerable: true,
|
|
527
|
+
configurable: true,
|
|
528
|
+
writable: true
|
|
529
|
+
});
|
|
530
|
+
return obj[key];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
try {
|
|
534
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
535
|
+
define({}, "");
|
|
536
|
+
} catch (err) {
|
|
537
|
+
define = function define(obj, key, value) {
|
|
538
|
+
return obj[key] = value;
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
543
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
544
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
545
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
546
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
547
|
+
// .throw, and .return methods.
|
|
548
|
+
|
|
549
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
550
|
+
return generator;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
554
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
555
|
+
// have been (and was previously) designed to take a closure to be
|
|
556
|
+
// invoked without arguments, but in all the cases we care about we
|
|
557
|
+
// already have an existing method we want to call, so there's no need
|
|
558
|
+
// to create a new function object. We can even get away with assuming
|
|
559
|
+
// the method takes exactly one argument, since that happens to be true
|
|
560
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
561
|
+
// only additional allocation required is the completion record, which
|
|
562
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
563
|
+
|
|
564
|
+
function tryCatch(fn, obj, arg) {
|
|
565
|
+
try {
|
|
566
|
+
return {
|
|
567
|
+
type: "normal",
|
|
568
|
+
arg: fn.call(obj, arg)
|
|
569
|
+
};
|
|
570
|
+
} catch (err) {
|
|
571
|
+
return {
|
|
572
|
+
type: "throw",
|
|
573
|
+
arg: err
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
579
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
580
|
+
var GenStateExecuting = "executing";
|
|
581
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
582
|
+
// breaking out of the dispatch switch statement.
|
|
583
|
+
|
|
584
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
585
|
+
// .constructor.prototype properties for functions that return Generator
|
|
586
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
587
|
+
// minifier not to mangle the names of these two functions.
|
|
588
|
+
|
|
589
|
+
function Generator() {}
|
|
590
|
+
|
|
591
|
+
function GeneratorFunction() {}
|
|
592
|
+
|
|
593
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
594
|
+
// don't natively support it.
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
var IteratorPrototype = {};
|
|
598
|
+
|
|
599
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
600
|
+
return this;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
var getProto = Object.getPrototypeOf;
|
|
604
|
+
var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
|
|
605
|
+
|
|
606
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
607
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
608
|
+
// of the polyfill.
|
|
609
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
|
|
613
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
614
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
615
|
+
GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
616
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
617
|
+
|
|
618
|
+
function defineIteratorMethods(prototype) {
|
|
619
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
620
|
+
define(prototype, method, function (arg) {
|
|
621
|
+
return this._invoke(method, arg);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
627
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
628
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
629
|
+
// do is to check its .name property.
|
|
630
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
exports.mark = function (genFun) {
|
|
634
|
+
if (Object.setPrototypeOf) {
|
|
635
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
636
|
+
} else {
|
|
637
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
638
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
genFun.prototype = Object.create(Gp);
|
|
642
|
+
return genFun;
|
|
643
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
644
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
645
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
646
|
+
// meant to be awaited.
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
exports.awrap = function (arg) {
|
|
650
|
+
return {
|
|
651
|
+
__await: arg
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
656
|
+
function invoke(method, arg, resolve, reject) {
|
|
657
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
658
|
+
|
|
659
|
+
if (record.type === "throw") {
|
|
660
|
+
reject(record.arg);
|
|
661
|
+
} else {
|
|
662
|
+
var result = record.arg;
|
|
663
|
+
var value = result.value;
|
|
664
|
+
|
|
665
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
666
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
667
|
+
invoke("next", value, resolve, reject);
|
|
668
|
+
}, function (err) {
|
|
669
|
+
invoke("throw", err, resolve, reject);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
674
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
675
|
+
// the .value of the Promise<{value,done}> result for the
|
|
676
|
+
// current iteration.
|
|
677
|
+
result.value = unwrapped;
|
|
678
|
+
resolve(result);
|
|
679
|
+
}, function (error) {
|
|
680
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
681
|
+
// into the async generator function so it can be handled there.
|
|
682
|
+
return invoke("throw", error, resolve, reject);
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
var previousPromise;
|
|
688
|
+
|
|
689
|
+
function enqueue(method, arg) {
|
|
690
|
+
function callInvokeWithMethodAndArg() {
|
|
691
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
692
|
+
invoke(method, arg, resolve, reject);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
697
|
+
// all previous Promises have been resolved before calling invoke,
|
|
698
|
+
// so that results are always delivered in the correct order. If
|
|
699
|
+
// enqueue has not been called before, then it is important to
|
|
700
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
701
|
+
// so that the async generator function has the opportunity to do
|
|
702
|
+
// any necessary setup in a predictable way. This predictability
|
|
703
|
+
// is why the Promise constructor synchronously invokes its
|
|
704
|
+
// executor callback, and why async functions synchronously
|
|
705
|
+
// execute code before the first await. Since we implement simple
|
|
706
|
+
// async functions in terms of async generators, it is especially
|
|
707
|
+
// important to get this right, even though it requires care.
|
|
708
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
709
|
+
// invocations of the iterator.
|
|
710
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
711
|
+
} // Define the unified helper method that is used to implement .next,
|
|
712
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
this._invoke = enqueue;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
719
|
+
|
|
720
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
721
|
+
return this;
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
725
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
726
|
+
// the final result produced by the iterator.
|
|
727
|
+
|
|
728
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
729
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
730
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
731
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
732
|
+
: iter.next().then(function (result) {
|
|
733
|
+
return result.done ? result.value : iter.next();
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
738
|
+
var state = GenStateSuspendedStart;
|
|
739
|
+
return function invoke(method, arg) {
|
|
740
|
+
if (state === GenStateExecuting) {
|
|
741
|
+
throw new Error("Generator is already running");
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (state === GenStateCompleted) {
|
|
745
|
+
if (method === "throw") {
|
|
746
|
+
throw arg;
|
|
747
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
748
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
return doneResult();
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
context.method = method;
|
|
755
|
+
context.arg = arg;
|
|
756
|
+
|
|
757
|
+
while (true) {
|
|
758
|
+
var delegate = context.delegate;
|
|
759
|
+
|
|
760
|
+
if (delegate) {
|
|
761
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
762
|
+
|
|
763
|
+
if (delegateResult) {
|
|
764
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
765
|
+
return delegateResult;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (context.method === "next") {
|
|
770
|
+
// Setting context._sent for legacy support of Babel's
|
|
771
|
+
// function.sent implementation.
|
|
772
|
+
context.sent = context._sent = context.arg;
|
|
773
|
+
} else if (context.method === "throw") {
|
|
774
|
+
if (state === GenStateSuspendedStart) {
|
|
775
|
+
state = GenStateCompleted;
|
|
776
|
+
throw context.arg;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
context.dispatchException(context.arg);
|
|
780
|
+
} else if (context.method === "return") {
|
|
781
|
+
context.abrupt("return", context.arg);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
state = GenStateExecuting;
|
|
785
|
+
var record = tryCatch(innerFn, self, context);
|
|
786
|
+
|
|
787
|
+
if (record.type === "normal") {
|
|
788
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
789
|
+
// GenStateExecuting and loop back for another invocation.
|
|
790
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
791
|
+
|
|
792
|
+
if (record.arg === ContinueSentinel) {
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return {
|
|
797
|
+
value: record.arg,
|
|
798
|
+
done: context.done
|
|
799
|
+
};
|
|
800
|
+
} else if (record.type === "throw") {
|
|
801
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
802
|
+
// context.dispatchException(context.arg) call above.
|
|
803
|
+
|
|
804
|
+
context.method = "throw";
|
|
805
|
+
context.arg = record.arg;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
810
|
+
// result, either by returning a { value, done } result from the
|
|
811
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
812
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
816
|
+
var method = delegate.iterator[context.method];
|
|
817
|
+
|
|
818
|
+
if (method === undefined$1) {
|
|
819
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
820
|
+
// method always terminates the yield* loop.
|
|
821
|
+
context.delegate = null;
|
|
822
|
+
|
|
823
|
+
if (context.method === "throw") {
|
|
824
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
825
|
+
if (delegate.iterator["return"]) {
|
|
826
|
+
// If the delegate iterator has a return method, give it a
|
|
827
|
+
// chance to clean up.
|
|
828
|
+
context.method = "return";
|
|
829
|
+
context.arg = undefined$1;
|
|
830
|
+
maybeInvokeDelegate(delegate, context);
|
|
831
|
+
|
|
832
|
+
if (context.method === "throw") {
|
|
833
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
834
|
+
// "return" to "throw", let that override the TypeError below.
|
|
835
|
+
return ContinueSentinel;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
context.method = "throw";
|
|
840
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return ContinueSentinel;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
847
|
+
|
|
848
|
+
if (record.type === "throw") {
|
|
849
|
+
context.method = "throw";
|
|
850
|
+
context.arg = record.arg;
|
|
851
|
+
context.delegate = null;
|
|
852
|
+
return ContinueSentinel;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
var info = record.arg;
|
|
856
|
+
|
|
857
|
+
if (!info) {
|
|
858
|
+
context.method = "throw";
|
|
859
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
860
|
+
context.delegate = null;
|
|
861
|
+
return ContinueSentinel;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (info.done) {
|
|
865
|
+
// Assign the result of the finished delegate to the temporary
|
|
866
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
867
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
868
|
+
|
|
869
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
870
|
+
// exception, let the outer generator proceed normally. If
|
|
871
|
+
// context.method was "next", forget context.arg since it has been
|
|
872
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
873
|
+
// "return", allow the original .return call to continue in the
|
|
874
|
+
// outer generator.
|
|
875
|
+
|
|
876
|
+
if (context.method !== "return") {
|
|
877
|
+
context.method = "next";
|
|
878
|
+
context.arg = undefined$1;
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
// Re-yield the result returned by the delegate method.
|
|
882
|
+
return info;
|
|
883
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
884
|
+
// the outer generator.
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
context.delegate = null;
|
|
888
|
+
return ContinueSentinel;
|
|
889
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
890
|
+
// unified ._invoke helper method.
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
defineIteratorMethods(Gp);
|
|
894
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
895
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
896
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
897
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
898
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
899
|
+
|
|
900
|
+
Gp[iteratorSymbol] = function () {
|
|
901
|
+
return this;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
Gp.toString = function () {
|
|
905
|
+
return "[object Generator]";
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
function pushTryEntry(locs) {
|
|
909
|
+
var entry = {
|
|
910
|
+
tryLoc: locs[0]
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
if (1 in locs) {
|
|
914
|
+
entry.catchLoc = locs[1];
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
if (2 in locs) {
|
|
918
|
+
entry.finallyLoc = locs[2];
|
|
919
|
+
entry.afterLoc = locs[3];
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
this.tryEntries.push(entry);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function resetTryEntry(entry) {
|
|
926
|
+
var record = entry.completion || {};
|
|
927
|
+
record.type = "normal";
|
|
928
|
+
delete record.arg;
|
|
929
|
+
entry.completion = record;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
function Context(tryLocsList) {
|
|
933
|
+
// The root entry object (effectively a try statement without a catch
|
|
934
|
+
// or a finally block) gives us a place to store values thrown from
|
|
935
|
+
// locations where there is no enclosing try statement.
|
|
936
|
+
this.tryEntries = [{
|
|
937
|
+
tryLoc: "root"
|
|
938
|
+
}];
|
|
939
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
940
|
+
this.reset(true);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
exports.keys = function (object) {
|
|
944
|
+
var keys = [];
|
|
945
|
+
|
|
946
|
+
for (var key in object) {
|
|
947
|
+
keys.push(key);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
951
|
+
// things simple and return the next function itself.
|
|
952
|
+
|
|
953
|
+
return function next() {
|
|
954
|
+
while (keys.length) {
|
|
955
|
+
var key = keys.pop();
|
|
956
|
+
|
|
957
|
+
if (key in object) {
|
|
958
|
+
next.value = key;
|
|
959
|
+
next.done = false;
|
|
960
|
+
return next;
|
|
961
|
+
}
|
|
962
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
963
|
+
// and .done properties off the next function object itself. This
|
|
964
|
+
// also ensures that the minifier will not anonymize the function.
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
next.done = true;
|
|
968
|
+
return next;
|
|
969
|
+
};
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
function values(iterable) {
|
|
973
|
+
if (iterable) {
|
|
974
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
975
|
+
|
|
976
|
+
if (iteratorMethod) {
|
|
977
|
+
return iteratorMethod.call(iterable);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
if (typeof iterable.next === "function") {
|
|
981
|
+
return iterable;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
if (!isNaN(iterable.length)) {
|
|
985
|
+
var i = -1,
|
|
986
|
+
next = function next() {
|
|
987
|
+
while (++i < iterable.length) {
|
|
988
|
+
if (hasOwn.call(iterable, i)) {
|
|
989
|
+
next.value = iterable[i];
|
|
990
|
+
next.done = false;
|
|
991
|
+
return next;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
next.value = undefined$1;
|
|
996
|
+
next.done = true;
|
|
997
|
+
return next;
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
return next.next = next;
|
|
1001
|
+
}
|
|
1002
|
+
} // Return an iterator with no values.
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
next: doneResult
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
exports.values = values;
|
|
1011
|
+
|
|
1012
|
+
function doneResult() {
|
|
1013
|
+
return {
|
|
1014
|
+
value: undefined$1,
|
|
1015
|
+
done: true
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
Context.prototype = {
|
|
1020
|
+
constructor: Context,
|
|
1021
|
+
reset: function reset(skipTempReset) {
|
|
1022
|
+
this.prev = 0;
|
|
1023
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1024
|
+
// function.sent implementation.
|
|
1025
|
+
|
|
1026
|
+
this.sent = this._sent = undefined$1;
|
|
1027
|
+
this.done = false;
|
|
1028
|
+
this.delegate = null;
|
|
1029
|
+
this.method = "next";
|
|
1030
|
+
this.arg = undefined$1;
|
|
1031
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
1032
|
+
|
|
1033
|
+
if (!skipTempReset) {
|
|
1034
|
+
for (var name in this) {
|
|
1035
|
+
// Not sure about the optimal order of these conditions:
|
|
1036
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
1037
|
+
this[name] = undefined$1;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
stop: function stop() {
|
|
1043
|
+
this.done = true;
|
|
1044
|
+
var rootEntry = this.tryEntries[0];
|
|
1045
|
+
var rootRecord = rootEntry.completion;
|
|
1046
|
+
|
|
1047
|
+
if (rootRecord.type === "throw") {
|
|
1048
|
+
throw rootRecord.arg;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
return this.rval;
|
|
1052
|
+
},
|
|
1053
|
+
dispatchException: function dispatchException(exception) {
|
|
1054
|
+
if (this.done) {
|
|
1055
|
+
throw exception;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
var context = this;
|
|
1059
|
+
|
|
1060
|
+
function handle(loc, caught) {
|
|
1061
|
+
record.type = "throw";
|
|
1062
|
+
record.arg = exception;
|
|
1063
|
+
context.next = loc;
|
|
1064
|
+
|
|
1065
|
+
if (caught) {
|
|
1066
|
+
// If the dispatched exception was caught by a catch block,
|
|
1067
|
+
// then let that catch block handle the exception normally.
|
|
1068
|
+
context.method = "next";
|
|
1069
|
+
context.arg = undefined$1;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return !!caught;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1076
|
+
var entry = this.tryEntries[i];
|
|
1077
|
+
var record = entry.completion;
|
|
1078
|
+
|
|
1079
|
+
if (entry.tryLoc === "root") {
|
|
1080
|
+
// Exception thrown outside of any try block that could handle
|
|
1081
|
+
// it, so set the completion value of the entire function to
|
|
1082
|
+
// throw the exception.
|
|
1083
|
+
return handle("end");
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
if (entry.tryLoc <= this.prev) {
|
|
1087
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1088
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1089
|
+
|
|
1090
|
+
if (hasCatch && hasFinally) {
|
|
1091
|
+
if (this.prev < entry.catchLoc) {
|
|
1092
|
+
return handle(entry.catchLoc, true);
|
|
1093
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
1094
|
+
return handle(entry.finallyLoc);
|
|
1095
|
+
}
|
|
1096
|
+
} else if (hasCatch) {
|
|
1097
|
+
if (this.prev < entry.catchLoc) {
|
|
1098
|
+
return handle(entry.catchLoc, true);
|
|
1099
|
+
}
|
|
1100
|
+
} else if (hasFinally) {
|
|
1101
|
+
if (this.prev < entry.finallyLoc) {
|
|
1102
|
+
return handle(entry.finallyLoc);
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
throw new Error("try statement without catch or finally");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
},
|
|
1110
|
+
abrupt: function abrupt(type, arg) {
|
|
1111
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1112
|
+
var entry = this.tryEntries[i];
|
|
1113
|
+
|
|
1114
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1115
|
+
var finallyEntry = entry;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1121
|
+
// Ignore the finally entry if control is not jumping to a
|
|
1122
|
+
// location outside the try/catch block.
|
|
1123
|
+
finallyEntry = null;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1127
|
+
record.type = type;
|
|
1128
|
+
record.arg = arg;
|
|
1129
|
+
|
|
1130
|
+
if (finallyEntry) {
|
|
1131
|
+
this.method = "next";
|
|
1132
|
+
this.next = finallyEntry.finallyLoc;
|
|
1133
|
+
return ContinueSentinel;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return this.complete(record);
|
|
1137
|
+
},
|
|
1138
|
+
complete: function complete(record, afterLoc) {
|
|
1139
|
+
if (record.type === "throw") {
|
|
1140
|
+
throw record.arg;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
if (record.type === "break" || record.type === "continue") {
|
|
1144
|
+
this.next = record.arg;
|
|
1145
|
+
} else if (record.type === "return") {
|
|
1146
|
+
this.rval = this.arg = record.arg;
|
|
1147
|
+
this.method = "return";
|
|
1148
|
+
this.next = "end";
|
|
1149
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
1150
|
+
this.next = afterLoc;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
return ContinueSentinel;
|
|
1154
|
+
},
|
|
1155
|
+
finish: function finish(finallyLoc) {
|
|
1156
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1157
|
+
var entry = this.tryEntries[i];
|
|
1158
|
+
|
|
1159
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
1160
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
1161
|
+
resetTryEntry(entry);
|
|
1162
|
+
return ContinueSentinel;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
"catch": function _catch(tryLoc) {
|
|
1167
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1168
|
+
var entry = this.tryEntries[i];
|
|
1169
|
+
|
|
1170
|
+
if (entry.tryLoc === tryLoc) {
|
|
1171
|
+
var record = entry.completion;
|
|
1172
|
+
|
|
1173
|
+
if (record.type === "throw") {
|
|
1174
|
+
var thrown = record.arg;
|
|
1175
|
+
resetTryEntry(entry);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
return thrown;
|
|
1179
|
+
}
|
|
1180
|
+
} // The context.catch method must only be called with a location
|
|
1181
|
+
// argument that corresponds to a known catch block.
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
throw new Error("illegal catch attempt");
|
|
1185
|
+
},
|
|
1186
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1187
|
+
this.delegate = {
|
|
1188
|
+
iterator: values(iterable),
|
|
1189
|
+
resultName: resultName,
|
|
1190
|
+
nextLoc: nextLoc
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
if (this.method === "next") {
|
|
1194
|
+
// Deliberately forget the last sent value so that we don't
|
|
1195
|
+
// accidentally pass it on to the delegate.
|
|
1196
|
+
this.arg = undefined$1;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
return ContinueSentinel;
|
|
1200
|
+
}
|
|
1201
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1202
|
+
// or not, return the runtime object so that we can declare the variable
|
|
1203
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1204
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1205
|
+
|
|
1206
|
+
return exports;
|
|
1207
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1208
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1209
|
+
// object. Either way, the resulting object will be used to initialize
|
|
1210
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
1211
|
+
module.exports );
|
|
1212
|
+
|
|
1213
|
+
try {
|
|
1214
|
+
regeneratorRuntime = runtime;
|
|
1215
|
+
} catch (accidentalStrictMode) {
|
|
1216
|
+
// This module should not be running in strict mode, so the above
|
|
1217
|
+
// assignment should always work unless something is misconfigured. Just
|
|
1218
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1219
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
1220
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
1221
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
1222
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
1223
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1224
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
1225
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1226
|
+
}
|
|
1227
|
+
})(runtime);
|
|
1228
|
+
|
|
1229
|
+
var _regeneratorRuntime = runtime.exports;
|
|
1230
|
+
|
|
434
1231
|
var useNormalizedItems = function useNormalizedItems(items) {
|
|
435
|
-
return React__default.useMemo(function () {
|
|
1232
|
+
return React__default["default"].useMemo(function () {
|
|
436
1233
|
return items.map(function (item) {
|
|
437
1234
|
if (typeof item == 'string') {
|
|
438
1235
|
return {
|
|
@@ -453,8 +1250,8 @@ var useNormalizedItems = function useNormalizedItems(items) {
|
|
|
453
1250
|
};
|
|
454
1251
|
|
|
455
1252
|
var useIsMounted = function useIsMounted() {
|
|
456
|
-
var isMountedRef = React__default.useRef(true);
|
|
457
|
-
React__default.useEffect(function () {
|
|
1253
|
+
var isMountedRef = React__default["default"].useRef(true);
|
|
1254
|
+
React__default["default"].useEffect(function () {
|
|
458
1255
|
return function () {
|
|
459
1256
|
isMountedRef.current = false;
|
|
460
1257
|
};
|
|
@@ -490,13 +1287,13 @@ debounceTimeout) {
|
|
|
490
1287
|
var isItemsFunction = typeof itemsOrItemsResolver === 'function'; // Here, we normalize the itemsResolver argument to an async function, so we
|
|
491
1288
|
// can use it without thinking about the differences later
|
|
492
1289
|
|
|
493
|
-
var itemsResolver = React__default.useMemo(function () {
|
|
1290
|
+
var itemsResolver = React__default["default"].useMemo(function () {
|
|
494
1291
|
return isItemsFunction ? itemsOrItemsResolver : function () {
|
|
495
1292
|
return Promise.resolve(itemsOrItemsResolver);
|
|
496
1293
|
};
|
|
497
1294
|
}, [itemsOrItemsResolver, isItemsFunction]);
|
|
498
1295
|
|
|
499
|
-
var _React$useReducer = React__default.useReducer(reducer, {
|
|
1296
|
+
var _React$useReducer = React__default["default"].useReducer(reducer, {
|
|
500
1297
|
items: isItemsFunction ? [] : itemsOrItemsResolver,
|
|
501
1298
|
loading: false
|
|
502
1299
|
}),
|
|
@@ -511,29 +1308,51 @@ debounceTimeout) {
|
|
|
511
1308
|
var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
|
|
512
1309
|
// the input value changes
|
|
513
1310
|
|
|
514
|
-
var fetchItems = React__default.useCallback(function (
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
1311
|
+
var fetchItems = React__default["default"].useCallback( /*#__PURE__*/function () {
|
|
1312
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
|
|
1313
|
+
var resolvedItems;
|
|
1314
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1315
|
+
while (1) {
|
|
1316
|
+
switch (_context.prev = _context.next) {
|
|
1317
|
+
case 0:
|
|
1318
|
+
if (isMounted) {
|
|
1319
|
+
_context.next = 2;
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
return _context.abrupt("return");
|
|
1324
|
+
|
|
1325
|
+
case 2:
|
|
1326
|
+
dispatch({
|
|
1327
|
+
type: 'request results'
|
|
1328
|
+
});
|
|
1329
|
+
_context.next = 5;
|
|
1330
|
+
return itemsResolver(inputValue);
|
|
1331
|
+
|
|
1332
|
+
case 5:
|
|
1333
|
+
resolvedItems = _context.sent;
|
|
1334
|
+
|
|
1335
|
+
if (isMounted) {
|
|
1336
|
+
dispatch({
|
|
1337
|
+
type: 'received results',
|
|
1338
|
+
payload: resolvedItems
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
case 7:
|
|
1343
|
+
case "end":
|
|
1344
|
+
return _context.stop();
|
|
1345
|
+
}
|
|
529
1346
|
}
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
1347
|
+
}, _callee);
|
|
1348
|
+
}));
|
|
1349
|
+
|
|
1350
|
+
return function (_x) {
|
|
1351
|
+
return _ref.apply(this, arguments);
|
|
1352
|
+
};
|
|
1353
|
+
}(), [itemsResolver, isMounted]);
|
|
535
1354
|
var normalizedItems = useNormalizedItems(items);
|
|
536
|
-
React__default.useEffect(function () {
|
|
1355
|
+
React__default["default"].useEffect(function () {
|
|
537
1356
|
// Let's fetch the list initially if it's specified
|
|
538
1357
|
if (isItemsFunction) {
|
|
539
1358
|
fetchItems('');
|
|
@@ -546,6 +1365,7 @@ debounceTimeout) {
|
|
|
546
1365
|
};
|
|
547
1366
|
};
|
|
548
1367
|
|
|
1368
|
+
var _excluded$2 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
549
1369
|
var Dropdown = function Dropdown(_ref) {
|
|
550
1370
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
551
1371
|
debounceTimeout = _ref.debounceTimeout,
|
|
@@ -573,7 +1393,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
573
1393
|
listStyle = _ref.listStyle,
|
|
574
1394
|
itemFilter = _ref.itemFilter,
|
|
575
1395
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
576
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1396
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
577
1397
|
|
|
578
1398
|
var _useResolvedItems = useResolvedItems(items, debounceTimeout),
|
|
579
1399
|
normalizedItems = _useResolvedItems.items,
|
|
@@ -592,18 +1412,19 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
592
1412
|
name: rest.name,
|
|
593
1413
|
'data-cy': rest['data-cy']
|
|
594
1414
|
};
|
|
595
|
-
return React__default.createElement(DownshiftProvider,
|
|
1415
|
+
return React__default["default"].createElement(DownshiftProvider, _extends({
|
|
596
1416
|
selectedItem: selectedItem,
|
|
597
1417
|
onInputValueChange: fetchItems,
|
|
598
1418
|
onChange: onChange,
|
|
599
1419
|
value: value,
|
|
600
1420
|
highlightFirstItemOnOpen: highlightFirstItemOnOpen,
|
|
601
1421
|
className: className,
|
|
602
|
-
style: style
|
|
603
|
-
|
|
1422
|
+
style: style,
|
|
1423
|
+
searchable: searchable
|
|
1424
|
+
}, rest), React__default["default"].createElement(DropdownInputGroup, {
|
|
604
1425
|
feedback: feedback,
|
|
605
1426
|
variant: variant
|
|
606
|
-
}, React__default.createElement(RenderedDropdown,
|
|
1427
|
+
}, React__default["default"].createElement(RenderedDropdown, _extends({
|
|
607
1428
|
label: label,
|
|
608
1429
|
items: normalizedItems,
|
|
609
1430
|
loading: loading,
|
|
@@ -620,6 +1441,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
620
1441
|
}, searchAbleProps))));
|
|
621
1442
|
};
|
|
622
1443
|
|
|
1444
|
+
var _excluded$1 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
623
1445
|
var NativeDropdown = function NativeDropdown(_ref) {
|
|
624
1446
|
var className = _ref.className,
|
|
625
1447
|
_ref$disabled = _ref.disabled,
|
|
@@ -634,24 +1456,24 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
634
1456
|
variant = _ref.variant,
|
|
635
1457
|
feedback = _ref.feedback,
|
|
636
1458
|
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
637
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1459
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
638
1460
|
|
|
639
1461
|
var _useResolvedItems = useResolvedItems(items),
|
|
640
1462
|
normalizedItems = _useResolvedItems.items,
|
|
641
1463
|
loading = _useResolvedItems.loading;
|
|
642
1464
|
|
|
643
|
-
var rightSideIcon = React__default.createElement(icons.DownArrowIcon, {
|
|
1465
|
+
var rightSideIcon = React__default["default"].createElement(icons.DownArrowIcon, {
|
|
644
1466
|
inline: true
|
|
645
1467
|
});
|
|
646
1468
|
|
|
647
1469
|
if (disabled || readOnly) {
|
|
648
1470
|
rightSideIcon = null;
|
|
649
1471
|
} else if (loading) {
|
|
650
|
-
rightSideIcon = React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
1472
|
+
rightSideIcon = React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
651
1473
|
}
|
|
652
1474
|
|
|
653
1475
|
var nativeDropdownId = utils.useRandomId('eds-native-dropdown');
|
|
654
|
-
return React__default.createElement(form.BaseFormControl, {
|
|
1476
|
+
return React__default["default"].createElement(form.BaseFormControl, {
|
|
655
1477
|
disabled: disabled,
|
|
656
1478
|
readOnly: readOnly,
|
|
657
1479
|
prepend: prepend,
|
|
@@ -664,22 +1486,23 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
664
1486
|
labelId: nativeDropdownId,
|
|
665
1487
|
disableLabelAnimation: disableLabelAnimation,
|
|
666
1488
|
isFilled: true
|
|
667
|
-
}, React__default.createElement("select",
|
|
1489
|
+
}, React__default["default"].createElement("select", _extends({
|
|
668
1490
|
"aria-invalid": variant === 'error',
|
|
669
1491
|
className: "eds-form-control eds-dropdown",
|
|
670
1492
|
disabled: disabled || readOnly
|
|
671
1493
|
}, rest), normalizedItems.map(function (item) {
|
|
672
|
-
return React__default.createElement("option", {
|
|
1494
|
+
return React__default["default"].createElement("option", {
|
|
673
1495
|
key: item.value,
|
|
674
1496
|
value: item.value
|
|
675
1497
|
}, item.label);
|
|
676
1498
|
})));
|
|
677
1499
|
};
|
|
678
1500
|
|
|
679
|
-
var
|
|
1501
|
+
var _excluded = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1502
|
+
var MultiSelectContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
680
1503
|
|
|
681
1504
|
var useMultiSelectContext = function useMultiSelectContext() {
|
|
682
|
-
var context = React__default.useContext(MultiSelectContext);
|
|
1505
|
+
var context = React__default["default"].useContext(MultiSelectContext);
|
|
683
1506
|
|
|
684
1507
|
if (!context) {
|
|
685
1508
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
@@ -737,7 +1560,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
737
1560
|
_ref$initialSelectedI = _ref.initialSelectedItems,
|
|
738
1561
|
initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
|
|
739
1562
|
debounceTimeout = _ref.debounceTimeout,
|
|
740
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
1563
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
741
1564
|
|
|
742
1565
|
var _useResolvedItems = useResolvedItems(input, debounceTimeout),
|
|
743
1566
|
items = _useResolvedItems.items;
|
|
@@ -746,10 +1569,16 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
746
1569
|
selectedItems = _useState[0],
|
|
747
1570
|
setSelectedItems = _useState[1];
|
|
748
1571
|
|
|
749
|
-
var reset = React__default.useCallback(function () {
|
|
1572
|
+
var reset = React__default["default"].useCallback(function () {
|
|
750
1573
|
setSelectedItems([]);
|
|
751
1574
|
}, []);
|
|
752
1575
|
|
|
1576
|
+
function isSelected(selectedCheckboxItem) {
|
|
1577
|
+
return selectedItems.some(function (selected) {
|
|
1578
|
+
return selected.value === selectedCheckboxItem.value;
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
|
|
753
1582
|
var _useSelect = Downshift.useSelect(_extends({
|
|
754
1583
|
items: items,
|
|
755
1584
|
stateReducer: stateReducer,
|
|
@@ -761,22 +1590,19 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
761
1590
|
return;
|
|
762
1591
|
}
|
|
763
1592
|
|
|
764
|
-
var
|
|
1593
|
+
var itemIsFound = isSelected(selectedItem);
|
|
765
1594
|
|
|
766
|
-
if (
|
|
767
|
-
var slicedItemList =
|
|
1595
|
+
if (itemIsFound) {
|
|
1596
|
+
var slicedItemList = selectedItems.filter(function (item) {
|
|
1597
|
+
return item.value !== selectedItem.value;
|
|
1598
|
+
});
|
|
768
1599
|
setSelectedItems(slicedItemList);
|
|
769
1600
|
onChange(slicedItemList);
|
|
770
|
-
} else
|
|
771
|
-
var _slicedItemList = [].concat(selectedItems
|
|
1601
|
+
} else {
|
|
1602
|
+
var _slicedItemList = [].concat(selectedItems, [selectedItem]);
|
|
772
1603
|
|
|
773
1604
|
setSelectedItems(_slicedItemList);
|
|
774
1605
|
onChange(_slicedItemList);
|
|
775
|
-
} else {
|
|
776
|
-
var _slicedItemList2 = [].concat(selectedItems, [selectedItem]);
|
|
777
|
-
|
|
778
|
-
setSelectedItems(_slicedItemList2);
|
|
779
|
-
onChange(_slicedItemList2);
|
|
780
1606
|
}
|
|
781
1607
|
}
|
|
782
1608
|
}, rest)),
|
|
@@ -790,7 +1616,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
790
1616
|
|
|
791
1617
|
var buttonText = selectedItems.length ? itemsSelectedLabel(selectedItems) : '';
|
|
792
1618
|
var multiSelectId = utils.useRandomId('eds-multiselect');
|
|
793
|
-
return React__default.createElement(MultiSelectContext.Provider, {
|
|
1619
|
+
return React__default["default"].createElement(MultiSelectContext.Provider, {
|
|
794
1620
|
value: {
|
|
795
1621
|
isOpen: isOpen,
|
|
796
1622
|
reset: reset,
|
|
@@ -798,10 +1624,10 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
798
1624
|
openMenu: openMenu,
|
|
799
1625
|
openOnFocus: openOnFocus
|
|
800
1626
|
}
|
|
801
|
-
}, React__default.createElement("div", {
|
|
802
|
-
className:
|
|
1627
|
+
}, React__default["default"].createElement("div", {
|
|
1628
|
+
className: classNames__default["default"]('eds-multiselect', 'eds-dropdown-wrapper', className),
|
|
803
1629
|
style: style
|
|
804
|
-
}, React__default.createElement(form.BaseFormControl, {
|
|
1630
|
+
}, React__default["default"].createElement(form.BaseFormControl, {
|
|
805
1631
|
label: label,
|
|
806
1632
|
labelId: multiSelectId,
|
|
807
1633
|
labelProps: getLabelProps(),
|
|
@@ -810,20 +1636,20 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
810
1636
|
isFilled: selectedItems.length > 0 || isOpen,
|
|
811
1637
|
disabled: disabled,
|
|
812
1638
|
readOnly: readOnly,
|
|
813
|
-
append: React__default.createElement(Appendix
|
|
1639
|
+
append: React__default["default"].createElement(Appendix, {
|
|
814
1640
|
hasSelected: clearable && selectedItems.length > 0,
|
|
815
1641
|
loading: loading,
|
|
816
1642
|
loadingText: loadingText,
|
|
817
1643
|
readOnly: readOnly
|
|
818
1644
|
})
|
|
819
|
-
}, React__default.createElement("button",
|
|
1645
|
+
}, React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
820
1646
|
style: {
|
|
821
1647
|
textAlign: 'left'
|
|
822
1648
|
},
|
|
823
1649
|
type: 'button',
|
|
824
1650
|
className: 'eds-form-control eds-multiselect__button'
|
|
825
|
-
})), buttonText)), React__default.createElement("ul",
|
|
826
|
-
className:
|
|
1651
|
+
})), buttonText)), React__default["default"].createElement("ul", _extends({
|
|
1652
|
+
className: classNames__default["default"]('eds-dropdown-list', {
|
|
827
1653
|
'eds-dropdown-list--open': isOpen
|
|
828
1654
|
})
|
|
829
1655
|
}, getMenuProps({
|
|
@@ -832,12 +1658,12 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
832
1658
|
top: tokens.space.extraLarge3 + tokens.space.extraSmall + "px"
|
|
833
1659
|
}, listStyle)
|
|
834
1660
|
})), isOpen && items.map(function (item, index) {
|
|
835
|
-
return React__default.createElement("li",
|
|
836
|
-
className:
|
|
1661
|
+
return React__default["default"].createElement("li", _extends({
|
|
1662
|
+
className: classNames__default["default"]('eds-dropdown-list__item', {
|
|
837
1663
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
838
|
-
'eds-dropdown-list__item--selected':
|
|
1664
|
+
'eds-dropdown-list__item--selected': isSelected(item)
|
|
839
1665
|
}),
|
|
840
|
-
key: "" + item + index
|
|
1666
|
+
key: "" + item.value + index
|
|
841
1667
|
}, getItemProps({
|
|
842
1668
|
item: item,
|
|
843
1669
|
index: index
|
|
@@ -845,18 +1671,18 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
845
1671
|
style: {
|
|
846
1672
|
display: 'flex'
|
|
847
1673
|
}
|
|
848
|
-
}), React__default.createElement("span", {
|
|
1674
|
+
}), React__default["default"].createElement("span", {
|
|
849
1675
|
style: {
|
|
850
1676
|
display: 'flex'
|
|
851
1677
|
}
|
|
852
|
-
}, React__default.createElement("span", {
|
|
853
|
-
className:
|
|
854
|
-
'eds-multiselect-checkbox--checked':
|
|
1678
|
+
}, React__default["default"].createElement("span", {
|
|
1679
|
+
className: classNames__default["default"]('eds-multiselect-checkbox', {
|
|
1680
|
+
'eds-multiselect-checkbox--checked': isSelected(item)
|
|
855
1681
|
})
|
|
856
|
-
}, React__default.createElement(CheckboxIcon, null)), React__default.createElement("span", {
|
|
1682
|
+
}, React__default["default"].createElement(CheckboxIcon, null)), React__default["default"].createElement("span", {
|
|
857
1683
|
className: "eds-multiselect__item-label"
|
|
858
|
-
}, item.label)), item.icons && React__default.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
859
|
-
return React__default.createElement(Icon, {
|
|
1684
|
+
}, item.label)), item.icons && React__default["default"].createElement("span", null, item.icons.map(function (Icon, index) {
|
|
1685
|
+
return React__default["default"].createElement(Icon, {
|
|
860
1686
|
key: index,
|
|
861
1687
|
inline: true,
|
|
862
1688
|
className: "eds-dropdown-list__item-icon"
|
|
@@ -865,50 +1691,50 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
865
1691
|
}))));
|
|
866
1692
|
};
|
|
867
1693
|
|
|
868
|
-
var ClearButton
|
|
1694
|
+
var ClearButton = function ClearButton(_ref3) {
|
|
869
1695
|
var props = _extends({}, _ref3);
|
|
870
1696
|
|
|
871
1697
|
var _useMultiSelectContex = useMultiSelectContext(),
|
|
872
1698
|
reset = _useMultiSelectContex.reset;
|
|
873
1699
|
|
|
874
|
-
return React__default.createElement(React__default.Fragment, null, React__default.createElement("button",
|
|
1700
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("button", _extends({
|
|
875
1701
|
className: "eds-dropdown__clear-button",
|
|
876
1702
|
type: "button",
|
|
877
1703
|
tabIndex: -1,
|
|
878
1704
|
onClick: function onClick() {
|
|
879
1705
|
return reset();
|
|
880
1706
|
}
|
|
881
|
-
}, props), React__default.createElement(icons.CloseIcon, null)), React__default.createElement("div", {
|
|
1707
|
+
}, props), React__default["default"].createElement(icons.CloseIcon, null)), React__default["default"].createElement("div", {
|
|
882
1708
|
className: "eds-dropdown__divider"
|
|
883
1709
|
}));
|
|
884
1710
|
};
|
|
885
1711
|
|
|
886
|
-
var Appendix
|
|
1712
|
+
var Appendix = function Appendix(_ref4) {
|
|
887
1713
|
var loading = _ref4.loading,
|
|
888
1714
|
loadingText = _ref4.loadingText,
|
|
889
1715
|
readOnly = _ref4.readOnly,
|
|
890
1716
|
hasSelected = _ref4.hasSelected;
|
|
891
1717
|
|
|
892
1718
|
if (loading) {
|
|
893
|
-
return React__default.createElement(DropdownLoadingDots, null, loadingText);
|
|
1719
|
+
return React__default["default"].createElement(DropdownLoadingDots, null, loadingText);
|
|
894
1720
|
}
|
|
895
1721
|
|
|
896
1722
|
if (readOnly) {
|
|
897
1723
|
return null;
|
|
898
1724
|
}
|
|
899
1725
|
|
|
900
|
-
return hasSelected ? React__default.createElement(React__default.Fragment, null, React__default.createElement(ClearButton
|
|
1726
|
+
return hasSelected ? React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(ClearButton, null), React__default["default"].createElement(DropdownToggleButton, null)) : React__default["default"].createElement(DropdownToggleButton, null);
|
|
901
1727
|
};
|
|
902
1728
|
|
|
903
|
-
var DropdownToggleButton
|
|
1729
|
+
var DropdownToggleButton = function DropdownToggleButton() {
|
|
904
1730
|
var _useMultiSelectContex2 = useMultiSelectContext(),
|
|
905
1731
|
getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
|
|
906
1732
|
isOpen = _useMultiSelectContex2.isOpen,
|
|
907
1733
|
openMenu = _useMultiSelectContex2.openMenu,
|
|
908
1734
|
openOnFocus = _useMultiSelectContex2.openOnFocus;
|
|
909
1735
|
|
|
910
|
-
return React__default.createElement("button",
|
|
911
|
-
className:
|
|
1736
|
+
return React__default["default"].createElement("button", _extends({}, getToggleButtonProps({
|
|
1737
|
+
className: classNames__default["default"]('eds-dropdown__toggle-button', {
|
|
912
1738
|
'eds-dropdown__toggle-button--open': isOpen
|
|
913
1739
|
}),
|
|
914
1740
|
onFocus: function onFocus() {
|
|
@@ -918,16 +1744,16 @@ var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
|
918
1744
|
}
|
|
919
1745
|
}), {
|
|
920
1746
|
type: "button"
|
|
921
|
-
}), React__default.createElement(icons.DownArrowIcon, null));
|
|
1747
|
+
}), React__default["default"].createElement(icons.DownArrowIcon, null));
|
|
922
1748
|
};
|
|
923
1749
|
|
|
924
1750
|
var CheckboxIcon = function CheckboxIcon() {
|
|
925
|
-
return React__default.createElement("svg", {
|
|
1751
|
+
return React__default["default"].createElement("svg", {
|
|
926
1752
|
className: "eds-checkbox-icon",
|
|
927
1753
|
width: "11px",
|
|
928
1754
|
height: "9px",
|
|
929
1755
|
viewBox: "6 11 37 33"
|
|
930
|
-
}, React__default.createElement("path", {
|
|
1756
|
+
}, React__default["default"].createElement("path", {
|
|
931
1757
|
className: "eds-checkbox-icon__path",
|
|
932
1758
|
d: "M14.1 27.2l7.1 7.2 14.6-14.8",
|
|
933
1759
|
fill: "none"
|