@entur/dropdown 4.0.0-beta.2 → 4.0.0
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/LICENSE.md +0 -71
- package/README.md +2 -2
- package/dist/BaseDropdown.d.ts +1 -1
- package/dist/DownshiftProvider.d.ts +1 -1
- package/dist/Dropdown.d.ts +3 -3
- package/dist/DropdownInputGroup.d.ts +1 -1
- package/dist/DropdownList.d.ts +1 -1
- package/dist/DropdownLoadingDots.d.ts +1 -1
- package/dist/MultiSelect.d.ts +2 -2
- package/dist/NativeDropdown.d.ts +1 -1
- package/dist/RegularDropdown.d.ts +1 -1
- package/dist/SearchableDropdown.d.ts +1 -1
- package/dist/beta/DropdownList.d.ts +17 -0
- package/dist/beta/SearchableDropdown.d.ts +8 -3
- package/dist/dropdown.cjs.development.js +664 -1175
- 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 +664 -1175
- package/dist/dropdown.esm.js.map +1 -1
- package/dist/styles.css +116 -156
- package/dist/useNormalizedItems.d.ts +2 -2
- package/dist/useResolvedItems.d.ts +3 -3
- package/package.json +13 -12
- package/CHANGELOG.md +0 -592
package/dist/dropdown.esm.js
CHANGED
|
@@ -7,7 +7,309 @@ import { CheckIcon, DownArrowIcon, CloseSmallIcon, CloseIcon } from '@entur/icon
|
|
|
7
7
|
import { VisuallyHidden } from '@entur/a11y';
|
|
8
8
|
import { LoadingDots } from '@entur/loader';
|
|
9
9
|
import { space } from '@entur/tokens';
|
|
10
|
+
import { IconButton } from '@entur/button';
|
|
10
11
|
|
|
12
|
+
function _regeneratorRuntime() {
|
|
13
|
+
_regeneratorRuntime = function () {
|
|
14
|
+
return exports;
|
|
15
|
+
};
|
|
16
|
+
var exports = {},
|
|
17
|
+
Op = Object.prototype,
|
|
18
|
+
hasOwn = Op.hasOwnProperty,
|
|
19
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
20
|
+
obj[key] = desc.value;
|
|
21
|
+
},
|
|
22
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
23
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
24
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
25
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
26
|
+
function define(obj, key, value) {
|
|
27
|
+
return Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: !0,
|
|
30
|
+
configurable: !0,
|
|
31
|
+
writable: !0
|
|
32
|
+
}), obj[key];
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
define({}, "");
|
|
36
|
+
} catch (err) {
|
|
37
|
+
define = function (obj, key, value) {
|
|
38
|
+
return obj[key] = value;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
42
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
43
|
+
generator = Object.create(protoGenerator.prototype),
|
|
44
|
+
context = new Context(tryLocsList || []);
|
|
45
|
+
return defineProperty(generator, "_invoke", {
|
|
46
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
47
|
+
}), generator;
|
|
48
|
+
}
|
|
49
|
+
function tryCatch(fn, obj, arg) {
|
|
50
|
+
try {
|
|
51
|
+
return {
|
|
52
|
+
type: "normal",
|
|
53
|
+
arg: fn.call(obj, arg)
|
|
54
|
+
};
|
|
55
|
+
} catch (err) {
|
|
56
|
+
return {
|
|
57
|
+
type: "throw",
|
|
58
|
+
arg: err
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.wrap = wrap;
|
|
63
|
+
var ContinueSentinel = {};
|
|
64
|
+
function Generator() {}
|
|
65
|
+
function GeneratorFunction() {}
|
|
66
|
+
function GeneratorFunctionPrototype() {}
|
|
67
|
+
var IteratorPrototype = {};
|
|
68
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
69
|
+
return this;
|
|
70
|
+
});
|
|
71
|
+
var getProto = Object.getPrototypeOf,
|
|
72
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
73
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
74
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
75
|
+
function defineIteratorMethods(prototype) {
|
|
76
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
77
|
+
define(prototype, method, function (arg) {
|
|
78
|
+
return this._invoke(method, arg);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
83
|
+
function invoke(method, arg, resolve, reject) {
|
|
84
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
85
|
+
if ("throw" !== record.type) {
|
|
86
|
+
var result = record.arg,
|
|
87
|
+
value = result.value;
|
|
88
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
89
|
+
invoke("next", value, resolve, reject);
|
|
90
|
+
}, function (err) {
|
|
91
|
+
invoke("throw", err, resolve, reject);
|
|
92
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
93
|
+
result.value = unwrapped, resolve(result);
|
|
94
|
+
}, function (error) {
|
|
95
|
+
return invoke("throw", error, resolve, reject);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
reject(record.arg);
|
|
99
|
+
}
|
|
100
|
+
var previousPromise;
|
|
101
|
+
defineProperty(this, "_invoke", {
|
|
102
|
+
value: function (method, arg) {
|
|
103
|
+
function callInvokeWithMethodAndArg() {
|
|
104
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
105
|
+
invoke(method, arg, resolve, reject);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
113
|
+
var state = "suspendedStart";
|
|
114
|
+
return function (method, arg) {
|
|
115
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
116
|
+
if ("completed" === state) {
|
|
117
|
+
if ("throw" === method) throw arg;
|
|
118
|
+
return doneResult();
|
|
119
|
+
}
|
|
120
|
+
for (context.method = method, context.arg = arg;;) {
|
|
121
|
+
var delegate = context.delegate;
|
|
122
|
+
if (delegate) {
|
|
123
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
124
|
+
if (delegateResult) {
|
|
125
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
126
|
+
return delegateResult;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
130
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
131
|
+
context.dispatchException(context.arg);
|
|
132
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
133
|
+
state = "executing";
|
|
134
|
+
var record = tryCatch(innerFn, self, context);
|
|
135
|
+
if ("normal" === record.type) {
|
|
136
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
137
|
+
return {
|
|
138
|
+
value: record.arg,
|
|
139
|
+
done: context.done
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
147
|
+
var methodName = context.method,
|
|
148
|
+
method = delegate.iterator[methodName];
|
|
149
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
150
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
151
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
152
|
+
var info = record.arg;
|
|
153
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
154
|
+
}
|
|
155
|
+
function pushTryEntry(locs) {
|
|
156
|
+
var entry = {
|
|
157
|
+
tryLoc: locs[0]
|
|
158
|
+
};
|
|
159
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
160
|
+
}
|
|
161
|
+
function resetTryEntry(entry) {
|
|
162
|
+
var record = entry.completion || {};
|
|
163
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
164
|
+
}
|
|
165
|
+
function Context(tryLocsList) {
|
|
166
|
+
this.tryEntries = [{
|
|
167
|
+
tryLoc: "root"
|
|
168
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
169
|
+
}
|
|
170
|
+
function values(iterable) {
|
|
171
|
+
if (iterable) {
|
|
172
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
173
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
174
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
175
|
+
if (!isNaN(iterable.length)) {
|
|
176
|
+
var i = -1,
|
|
177
|
+
next = function next() {
|
|
178
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
179
|
+
return next.value = undefined, next.done = !0, next;
|
|
180
|
+
};
|
|
181
|
+
return next.next = next;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
next: doneResult
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function doneResult() {
|
|
189
|
+
return {
|
|
190
|
+
value: undefined,
|
|
191
|
+
done: !0
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
195
|
+
value: GeneratorFunctionPrototype,
|
|
196
|
+
configurable: !0
|
|
197
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
198
|
+
value: GeneratorFunction,
|
|
199
|
+
configurable: !0
|
|
200
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
201
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
202
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
203
|
+
}, exports.mark = function (genFun) {
|
|
204
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
205
|
+
}, exports.awrap = function (arg) {
|
|
206
|
+
return {
|
|
207
|
+
__await: arg
|
|
208
|
+
};
|
|
209
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
210
|
+
return this;
|
|
211
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
212
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
213
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
214
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
215
|
+
return result.done ? result.value : iter.next();
|
|
216
|
+
});
|
|
217
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
218
|
+
return this;
|
|
219
|
+
}), define(Gp, "toString", function () {
|
|
220
|
+
return "[object Generator]";
|
|
221
|
+
}), exports.keys = function (val) {
|
|
222
|
+
var object = Object(val),
|
|
223
|
+
keys = [];
|
|
224
|
+
for (var key in object) keys.push(key);
|
|
225
|
+
return keys.reverse(), function next() {
|
|
226
|
+
for (; keys.length;) {
|
|
227
|
+
var key = keys.pop();
|
|
228
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
229
|
+
}
|
|
230
|
+
return next.done = !0, next;
|
|
231
|
+
};
|
|
232
|
+
}, exports.values = values, Context.prototype = {
|
|
233
|
+
constructor: Context,
|
|
234
|
+
reset: function (skipTempReset) {
|
|
235
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
236
|
+
},
|
|
237
|
+
stop: function () {
|
|
238
|
+
this.done = !0;
|
|
239
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
240
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
241
|
+
return this.rval;
|
|
242
|
+
},
|
|
243
|
+
dispatchException: function (exception) {
|
|
244
|
+
if (this.done) throw exception;
|
|
245
|
+
var context = this;
|
|
246
|
+
function handle(loc, caught) {
|
|
247
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
248
|
+
}
|
|
249
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
250
|
+
var entry = this.tryEntries[i],
|
|
251
|
+
record = entry.completion;
|
|
252
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
253
|
+
if (entry.tryLoc <= this.prev) {
|
|
254
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
255
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
256
|
+
if (hasCatch && hasFinally) {
|
|
257
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
258
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
259
|
+
} else if (hasCatch) {
|
|
260
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
261
|
+
} else {
|
|
262
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
263
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
abrupt: function (type, arg) {
|
|
269
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
270
|
+
var entry = this.tryEntries[i];
|
|
271
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
272
|
+
var finallyEntry = entry;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
277
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
278
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
279
|
+
},
|
|
280
|
+
complete: function (record, afterLoc) {
|
|
281
|
+
if ("throw" === record.type) throw record.arg;
|
|
282
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
283
|
+
},
|
|
284
|
+
finish: function (finallyLoc) {
|
|
285
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
286
|
+
var entry = this.tryEntries[i];
|
|
287
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
catch: function (tryLoc) {
|
|
291
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
292
|
+
var entry = this.tryEntries[i];
|
|
293
|
+
if (entry.tryLoc === tryLoc) {
|
|
294
|
+
var record = entry.completion;
|
|
295
|
+
if ("throw" === record.type) {
|
|
296
|
+
var thrown = record.arg;
|
|
297
|
+
resetTryEntry(entry);
|
|
298
|
+
}
|
|
299
|
+
return thrown;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
throw new Error("illegal catch attempt");
|
|
303
|
+
},
|
|
304
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
305
|
+
return this.delegate = {
|
|
306
|
+
iterator: values(iterable),
|
|
307
|
+
resultName: resultName,
|
|
308
|
+
nextLoc: nextLoc
|
|
309
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
310
|
+
}
|
|
311
|
+
}, exports;
|
|
312
|
+
}
|
|
11
313
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
12
314
|
try {
|
|
13
315
|
var info = gen[key](arg);
|
|
@@ -16,112 +318,97 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
16
318
|
reject(error);
|
|
17
319
|
return;
|
|
18
320
|
}
|
|
19
|
-
|
|
20
321
|
if (info.done) {
|
|
21
322
|
resolve(value);
|
|
22
323
|
} else {
|
|
23
324
|
Promise.resolve(value).then(_next, _throw);
|
|
24
325
|
}
|
|
25
326
|
}
|
|
26
|
-
|
|
27
327
|
function _asyncToGenerator(fn) {
|
|
28
328
|
return function () {
|
|
29
329
|
var self = this,
|
|
30
|
-
|
|
330
|
+
args = arguments;
|
|
31
331
|
return new Promise(function (resolve, reject) {
|
|
32
332
|
var gen = fn.apply(self, args);
|
|
33
|
-
|
|
34
333
|
function _next(value) {
|
|
35
334
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
335
|
}
|
|
37
|
-
|
|
38
336
|
function _throw(err) {
|
|
39
337
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
338
|
}
|
|
41
|
-
|
|
42
339
|
_next(undefined);
|
|
43
340
|
});
|
|
44
341
|
};
|
|
45
342
|
}
|
|
46
|
-
|
|
47
343
|
function _extends() {
|
|
48
|
-
_extends = Object.assign
|
|
344
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
49
345
|
for (var i = 1; i < arguments.length; i++) {
|
|
50
346
|
var source = arguments[i];
|
|
51
|
-
|
|
52
347
|
for (var key in source) {
|
|
53
348
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
54
349
|
target[key] = source[key];
|
|
55
350
|
}
|
|
56
351
|
}
|
|
57
352
|
}
|
|
58
|
-
|
|
59
353
|
return target;
|
|
60
354
|
};
|
|
61
|
-
|
|
62
355
|
return _extends.apply(this, arguments);
|
|
63
356
|
}
|
|
64
|
-
|
|
357
|
+
function _objectDestructuringEmpty(obj) {
|
|
358
|
+
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
359
|
+
}
|
|
65
360
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
66
361
|
if (source == null) return {};
|
|
67
362
|
var target = {};
|
|
68
363
|
var sourceKeys = Object.keys(source);
|
|
69
364
|
var key, i;
|
|
70
|
-
|
|
71
365
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
72
366
|
key = sourceKeys[i];
|
|
73
367
|
if (excluded.indexOf(key) >= 0) continue;
|
|
74
368
|
target[key] = source[key];
|
|
75
369
|
}
|
|
76
|
-
|
|
77
370
|
return target;
|
|
78
371
|
}
|
|
79
372
|
|
|
80
|
-
var _excluded$
|
|
373
|
+
var _excluded$a = ["children", "onChange", "onInputValueChange", "highlightFirstItemOnOpen", "className", "style", "searchable"];
|
|
81
374
|
var DownshiftContext = /*#__PURE__*/React.createContext(null);
|
|
82
375
|
var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
83
376
|
var children = _ref.children,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
377
|
+
_ref$onChange = _ref.onChange,
|
|
378
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
379
|
+
return undefined;
|
|
380
|
+
} : _ref$onChange,
|
|
381
|
+
_ref$onInputValueChan = _ref.onInputValueChange,
|
|
382
|
+
onInputValueChange = _ref$onInputValueChan === void 0 ? function () {
|
|
383
|
+
return undefined;
|
|
384
|
+
} : _ref$onInputValueChan,
|
|
385
|
+
_ref$highlightFirstIt = _ref.highlightFirstItemOnOpen,
|
|
386
|
+
highlightFirstItemOnOpen = _ref$highlightFirstIt === void 0 ? false : _ref$highlightFirstIt,
|
|
387
|
+
className = _ref.className,
|
|
388
|
+
style = _ref.style,
|
|
389
|
+
_ref$searchable = _ref.searchable,
|
|
390
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
391
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
100
392
|
var handleStateChange = function handleStateChange(changes, stateAndHelpers) {
|
|
101
393
|
if (changes.type === Downshift.stateChangeTypes.controlledPropUpdatedSelectedItem) {
|
|
102
394
|
return;
|
|
103
395
|
}
|
|
104
|
-
|
|
105
396
|
if ('selectedItem' in changes) {
|
|
106
397
|
onChange(changes.selectedItem, stateAndHelpers);
|
|
107
398
|
} else if ('inputValue' in changes) {
|
|
108
399
|
onInputValueChange(changes.inputValue);
|
|
109
400
|
}
|
|
110
401
|
};
|
|
111
|
-
|
|
112
402
|
var stateReducer = function stateReducer(_, changes) {
|
|
113
403
|
var highlightFirstOnOpen = highlightFirstItemOnOpen && 'isOpen' in changes && changes.isOpen;
|
|
114
404
|
var highlightFirstItemIndex = highlightFirstOnOpen ? {
|
|
115
405
|
highlightedIndex: 0
|
|
116
406
|
} : {};
|
|
117
|
-
|
|
118
407
|
if (searchable) {
|
|
119
408
|
var type = changes.type;
|
|
120
|
-
|
|
121
409
|
switch (type) {
|
|
122
410
|
case '__autocomplete_change_input__':
|
|
123
411
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
124
|
-
|
|
125
412
|
case '__autocomplete_click_item__':
|
|
126
413
|
case '__autocomplete_keydown_enter__':
|
|
127
414
|
case '__autocomplete_blur_input__':
|
|
@@ -131,7 +418,6 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
131
418
|
// we will reset input field value to blank
|
|
132
419
|
inputValue: ''
|
|
133
420
|
}, highlightFirstItemIndex);
|
|
134
|
-
|
|
135
421
|
default:
|
|
136
422
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
137
423
|
}
|
|
@@ -139,7 +425,6 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
139
425
|
return _extends({}, changes, highlightFirstItemIndex);
|
|
140
426
|
}
|
|
141
427
|
};
|
|
142
|
-
|
|
143
428
|
return React.createElement(Downshift, _extends({
|
|
144
429
|
itemToString: function itemToString(item) {
|
|
145
430
|
return item ? item.label : '';
|
|
@@ -157,32 +442,29 @@ var DownshiftProvider = function DownshiftProvider(_ref) {
|
|
|
157
442
|
};
|
|
158
443
|
var useDownshift = function useDownshift() {
|
|
159
444
|
var context = React.useContext(DownshiftContext);
|
|
160
|
-
|
|
161
445
|
if (!context) {
|
|
162
446
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
163
447
|
}
|
|
164
|
-
|
|
165
448
|
return context;
|
|
166
449
|
};
|
|
167
450
|
|
|
168
|
-
var _excluded$
|
|
169
|
-
var DropdownList = function DropdownList(_ref) {
|
|
451
|
+
var _excluded$9 = ["items"];
|
|
452
|
+
var DropdownList$1 = function DropdownList(_ref) {
|
|
170
453
|
var items = _ref.items,
|
|
171
|
-
|
|
172
|
-
|
|
454
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
173
455
|
var _useDownshift = useDownshift(),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
456
|
+
highlightedIndex = _useDownshift.highlightedIndex,
|
|
457
|
+
isOpen = _useDownshift.isOpen,
|
|
458
|
+
selectedItem = _useDownshift.selectedItem,
|
|
459
|
+
getItemProps = _useDownshift.getItemProps,
|
|
460
|
+
getMenuProps = _useDownshift.getMenuProps;
|
|
180
461
|
return React.createElement("ul", _extends({
|
|
181
462
|
className: classNames('eds-dropdown-list', {
|
|
182
463
|
'eds-dropdown-list--open': isOpen
|
|
183
464
|
})
|
|
184
465
|
}, getMenuProps(), rest), isOpen ? items.map(function (item, index) {
|
|
185
|
-
return (
|
|
466
|
+
return (
|
|
467
|
+
// eslint-disable-next-line react/jsx-key
|
|
186
468
|
React.createElement("li", _extends({
|
|
187
469
|
className: classNames('eds-dropdown-list__item', {
|
|
188
470
|
'eds-dropdown-list__item--highlighted': highlightedIndex === index,
|
|
@@ -205,9 +487,8 @@ var DropdownList = function DropdownList(_ref) {
|
|
|
205
487
|
|
|
206
488
|
var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
207
489
|
var _useDownshift = useDownshift(),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
490
|
+
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
491
|
+
isOpen = _useDownshift.isOpen;
|
|
211
492
|
return React.createElement("button", _extends({}, getToggleButtonProps({
|
|
212
493
|
className: classNames('eds-dropdown__toggle-button', {
|
|
213
494
|
'eds-dropdown__toggle-button--open': isOpen
|
|
@@ -218,38 +499,35 @@ var DropdownToggleButton$1 = function DropdownToggleButton() {
|
|
|
218
499
|
}), React.createElement(DownArrowIcon, null));
|
|
219
500
|
};
|
|
220
501
|
|
|
221
|
-
var _excluded$
|
|
502
|
+
var _excluded$8 = ["className", "children"];
|
|
222
503
|
var DropdownLoadingDots = function DropdownLoadingDots(_ref) {
|
|
223
504
|
var className = _ref.className,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
505
|
+
children = _ref.children,
|
|
506
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
227
507
|
return React.createElement("div", _extends({
|
|
228
508
|
className: classNames('eds-inline-spinner', className)
|
|
229
509
|
}, rest), React.createElement(LoadingDots, null), React.createElement(VisuallyHidden, null, children));
|
|
230
510
|
};
|
|
231
511
|
|
|
232
|
-
var _excluded$
|
|
512
|
+
var _excluded$7 = ["children", "className", "items", "loading", "loadingText", "placeholder", "style", "listStyle", "clearable", "label", "isFilled", "disableLabelAnimation"];
|
|
233
513
|
var BaseDropdown = function BaseDropdown(_ref) {
|
|
234
514
|
var children = _ref.children,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
515
|
+
className = _ref.className,
|
|
516
|
+
items = _ref.items,
|
|
517
|
+
_ref$loading = _ref.loading,
|
|
518
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
519
|
+
_ref$loadingText = _ref.loadingText,
|
|
520
|
+
loadingText = _ref$loadingText === void 0 ? 'Loading...' : _ref$loadingText,
|
|
521
|
+
style = _ref.style,
|
|
522
|
+
listStyle = _ref.listStyle,
|
|
523
|
+
clearable = _ref.clearable,
|
|
524
|
+
label = _ref.label,
|
|
525
|
+
_ref$isFilled = _ref.isFilled,
|
|
526
|
+
isFilled = _ref$isFilled === void 0 ? false : _ref$isFilled,
|
|
527
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
528
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
250
529
|
var _useDownshift = useDownshift(),
|
|
251
|
-
|
|
252
|
-
|
|
530
|
+
getLabelProps = _useDownshift.getLabelProps;
|
|
253
531
|
return React.createElement("div", {
|
|
254
532
|
className: "eds-dropdown-wrapper",
|
|
255
533
|
style: style
|
|
@@ -265,7 +543,7 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
265
543
|
isFilled: isFilled,
|
|
266
544
|
labelProps: getLabelProps(),
|
|
267
545
|
disableLabelAnimation: disableLabelAnimation
|
|
268
|
-
}, rest), children), React.createElement(DropdownList, _extends({
|
|
546
|
+
}, rest), children), React.createElement(DropdownList$1, _extends({
|
|
269
547
|
items: items,
|
|
270
548
|
style: _extends({
|
|
271
549
|
position: 'absolute',
|
|
@@ -273,14 +551,11 @@ var BaseDropdown = function BaseDropdown(_ref) {
|
|
|
273
551
|
}, listStyle)
|
|
274
552
|
}, rest)));
|
|
275
553
|
};
|
|
276
|
-
|
|
277
554
|
var ClearButton$1 = function ClearButton(_ref2) {
|
|
278
|
-
var props = _extends({}, _ref2);
|
|
279
|
-
|
|
555
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref2), _ref2));
|
|
280
556
|
var _useDownshift2 = useDownshift(),
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
557
|
+
clearSelection = _useDownshift2.clearSelection,
|
|
558
|
+
selectedItem = _useDownshift2.selectedItem;
|
|
284
559
|
return React.createElement(React.Fragment, null, selectedItem && React.createElement("button", _extends({
|
|
285
560
|
className: "eds-dropdown__clear-button",
|
|
286
561
|
type: "button",
|
|
@@ -292,52 +567,46 @@ var ClearButton$1 = function ClearButton(_ref2) {
|
|
|
292
567
|
className: "eds-dropdown__divider"
|
|
293
568
|
}));
|
|
294
569
|
};
|
|
295
|
-
|
|
296
570
|
var Appendix$2 = function Appendix(_ref3) {
|
|
297
571
|
var clearable = _ref3.clearable,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
572
|
+
loading = _ref3.loading,
|
|
573
|
+
loadingText = _ref3.loadingText,
|
|
574
|
+
readOnly = _ref3.readOnly;
|
|
302
575
|
if (loading) {
|
|
303
576
|
return React.createElement(DropdownLoadingDots, null, loadingText);
|
|
304
577
|
}
|
|
305
|
-
|
|
306
578
|
if (readOnly) {
|
|
307
579
|
return null;
|
|
308
580
|
}
|
|
309
|
-
|
|
310
581
|
return clearable ? React.createElement(React.Fragment, null, React.createElement(ClearButton$1, null), " ", React.createElement(DropdownToggleButton$1, null)) : React.createElement(DropdownToggleButton$1, null);
|
|
311
582
|
};
|
|
312
583
|
|
|
313
|
-
var _excluded$
|
|
584
|
+
var _excluded$6 = ["disabled", "placeholder", "selectOnTab", "openOnFocus", "listStyle", "items", "label", "disableLabelAnimation", "loading", "loadingText", "className", "clearable"];
|
|
314
585
|
var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
315
586
|
var disabled = _ref.disabled,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
587
|
+
_ref$placeholder = _ref.placeholder,
|
|
588
|
+
placeholder = _ref$placeholder === void 0 ? 'Vennligst velg' : _ref$placeholder,
|
|
589
|
+
_ref$selectOnTab = _ref.selectOnTab,
|
|
590
|
+
selectOnTab = _ref$selectOnTab === void 0 ? false : _ref$selectOnTab,
|
|
591
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
592
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
593
|
+
listStyle = _ref.listStyle,
|
|
594
|
+
items = _ref.items,
|
|
595
|
+
label = _ref.label,
|
|
596
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
597
|
+
loading = _ref.loading,
|
|
598
|
+
loadingText = _ref.loadingText,
|
|
599
|
+
className = _ref.className,
|
|
600
|
+
clearable = _ref.clearable,
|
|
601
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
332
602
|
var _useDownshift = useDownshift(),
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
603
|
+
getToggleButtonProps = _useDownshift.getToggleButtonProps,
|
|
604
|
+
selectedItem = _useDownshift.selectedItem,
|
|
605
|
+
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
606
|
+
openMenu = _useDownshift.openMenu,
|
|
607
|
+
isOpen = _useDownshift.isOpen,
|
|
608
|
+
highlightedIndex = _useDownshift.highlightedIndex,
|
|
609
|
+
setHighlightedIndex = _useDownshift.setHighlightedIndex;
|
|
341
610
|
return React.createElement(BaseDropdown, _extends({
|
|
342
611
|
disabled: disabled,
|
|
343
612
|
listStyle: listStyle,
|
|
@@ -360,7 +629,6 @@ var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
360
629
|
if (selectOnTab && e.key === 'Tab') {
|
|
361
630
|
selectHighlightedItem();
|
|
362
631
|
}
|
|
363
|
-
|
|
364
632
|
if (isOpen) {
|
|
365
633
|
var keyDownValue = e.key;
|
|
366
634
|
var matchedItems = items.map(function (item, index) {
|
|
@@ -374,7 +642,6 @@ var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
374
642
|
var nextHighlightItem = matchedItems.find(function (item) {
|
|
375
643
|
return item.index > (highlightedIndex != null ? highlightedIndex : 0);
|
|
376
644
|
});
|
|
377
|
-
|
|
378
645
|
if (nextHighlightItem) {
|
|
379
646
|
setHighlightedIndex(nextHighlightItem.index);
|
|
380
647
|
} else if (matchedItems.length > 0) {
|
|
@@ -392,56 +659,50 @@ var RegularDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
392
659
|
}), selectedItem ? selectedItem.label : placeholder));
|
|
393
660
|
});
|
|
394
661
|
|
|
395
|
-
var _excluded$
|
|
396
|
-
|
|
662
|
+
var _excluded$5 = ["disabled", "className", "items", "loading", "loadingText", "readOnly", "prepend", "selectOnTab", "openOnFocus", "listStyle", "clearable", "itemFilter", "label", "disableLabelAnimation", "placeholder"];
|
|
397
663
|
function LowerCaseFilterTest(item, input) {
|
|
398
664
|
if (!input) {
|
|
399
665
|
return true;
|
|
400
666
|
}
|
|
401
|
-
|
|
402
667
|
var sanitizeEscapeCharacters = input.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
403
668
|
var inputRegex = new RegExp(sanitizeEscapeCharacters, 'i');
|
|
404
669
|
return inputRegex.test(item.label);
|
|
405
670
|
}
|
|
406
|
-
|
|
407
671
|
var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
408
672
|
var _ref$disabled = _ref.disabled,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
673
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
674
|
+
className = _ref.className,
|
|
675
|
+
items = _ref.items,
|
|
676
|
+
loading = _ref.loading,
|
|
677
|
+
loadingText = _ref.loadingText,
|
|
678
|
+
_ref$readOnly = _ref.readOnly,
|
|
679
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
680
|
+
prepend = _ref.prepend,
|
|
681
|
+
_ref$selectOnTab = _ref.selectOnTab,
|
|
682
|
+
selectOnTab = _ref$selectOnTab === void 0 ? false : _ref$selectOnTab,
|
|
683
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
684
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
685
|
+
listStyle = _ref.listStyle,
|
|
686
|
+
clearable = _ref.clearable,
|
|
687
|
+
_ref$itemFilter = _ref.itemFilter,
|
|
688
|
+
itemFilter = _ref$itemFilter === void 0 ? function (item, inputValue) {
|
|
689
|
+
return LowerCaseFilterTest(item, inputValue);
|
|
690
|
+
} : _ref$itemFilter,
|
|
691
|
+
label = _ref.label,
|
|
692
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
693
|
+
placeholder = _ref.placeholder,
|
|
694
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
432
695
|
var _useDownshift = useDownshift(),
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
696
|
+
getInputProps = _useDownshift.getInputProps,
|
|
697
|
+
inputValue = _useDownshift.inputValue,
|
|
698
|
+
selectHighlightedItem = _useDownshift.selectHighlightedItem,
|
|
699
|
+
isOpen = _useDownshift.isOpen,
|
|
700
|
+
openMenu = _useDownshift.openMenu,
|
|
701
|
+
closeMenu = _useDownshift.closeMenu,
|
|
702
|
+
selectedItem = _useDownshift.selectedItem;
|
|
441
703
|
var _useState = useState(false),
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
704
|
+
hideSelectedItem = _useState[0],
|
|
705
|
+
setHideSelectedItem = _useState[1];
|
|
445
706
|
var inputRef = useRef(null);
|
|
446
707
|
var filteredItems = React.useMemo(function () {
|
|
447
708
|
return items.filter(function (item) {
|
|
@@ -467,7 +728,6 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
467
728
|
className: "eds-dropdown__searchable-selected-item",
|
|
468
729
|
onClick: function onClick() {
|
|
469
730
|
var _inputRef$current;
|
|
470
|
-
|
|
471
731
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
472
732
|
}
|
|
473
733
|
}, selectedItem.label)), React.createElement("input", _extends({}, getInputProps(_extends({
|
|
@@ -493,10 +753,10 @@ var SearchableDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
493
753
|
|
|
494
754
|
var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
495
755
|
var children = _ref.children,
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
756
|
+
feedback = _ref.feedback,
|
|
757
|
+
variant = _ref.variant,
|
|
758
|
+
className = _ref.className,
|
|
759
|
+
style = _ref.style;
|
|
500
760
|
return React.createElement(VariantProvider, {
|
|
501
761
|
variant: variant
|
|
502
762
|
}, React.createElement("div", {
|
|
@@ -507,735 +767,6 @@ var DropdownInputGroup = function DropdownInputGroup(_ref) {
|
|
|
507
767
|
}, feedback)));
|
|
508
768
|
};
|
|
509
769
|
|
|
510
|
-
var runtime = {exports: {}};
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
514
|
-
*
|
|
515
|
-
* This source code is licensed under the MIT license found in the
|
|
516
|
-
* LICENSE file in the root directory of this source tree.
|
|
517
|
-
*/
|
|
518
|
-
|
|
519
|
-
(function (module) {
|
|
520
|
-
var runtime = /*#__PURE__*/function (exports) {
|
|
521
|
-
|
|
522
|
-
var Op = Object.prototype;
|
|
523
|
-
var hasOwn = Op.hasOwnProperty;
|
|
524
|
-
var undefined$1; // More compressible than void 0.
|
|
525
|
-
|
|
526
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
527
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
528
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
529
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
530
|
-
|
|
531
|
-
function define(obj, key, value) {
|
|
532
|
-
Object.defineProperty(obj, key, {
|
|
533
|
-
value: value,
|
|
534
|
-
enumerable: true,
|
|
535
|
-
configurable: true,
|
|
536
|
-
writable: true
|
|
537
|
-
});
|
|
538
|
-
return obj[key];
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
try {
|
|
542
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
543
|
-
define({}, "");
|
|
544
|
-
} catch (err) {
|
|
545
|
-
define = function define(obj, key, value) {
|
|
546
|
-
return obj[key] = value;
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
551
|
-
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
552
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
553
|
-
var generator = Object.create(protoGenerator.prototype);
|
|
554
|
-
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
555
|
-
// .throw, and .return methods.
|
|
556
|
-
|
|
557
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
558
|
-
return generator;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
562
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
563
|
-
// have been (and was previously) designed to take a closure to be
|
|
564
|
-
// invoked without arguments, but in all the cases we care about we
|
|
565
|
-
// already have an existing method we want to call, so there's no need
|
|
566
|
-
// to create a new function object. We can even get away with assuming
|
|
567
|
-
// the method takes exactly one argument, since that happens to be true
|
|
568
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
569
|
-
// only additional allocation required is the completion record, which
|
|
570
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
571
|
-
|
|
572
|
-
function tryCatch(fn, obj, arg) {
|
|
573
|
-
try {
|
|
574
|
-
return {
|
|
575
|
-
type: "normal",
|
|
576
|
-
arg: fn.call(obj, arg)
|
|
577
|
-
};
|
|
578
|
-
} catch (err) {
|
|
579
|
-
return {
|
|
580
|
-
type: "throw",
|
|
581
|
-
arg: err
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
var GenStateSuspendedStart = "suspendedStart";
|
|
587
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
588
|
-
var GenStateExecuting = "executing";
|
|
589
|
-
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
590
|
-
// breaking out of the dispatch switch statement.
|
|
591
|
-
|
|
592
|
-
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
593
|
-
// .constructor.prototype properties for functions that return Generator
|
|
594
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
595
|
-
// minifier not to mangle the names of these two functions.
|
|
596
|
-
|
|
597
|
-
function Generator() {}
|
|
598
|
-
|
|
599
|
-
function GeneratorFunction() {}
|
|
600
|
-
|
|
601
|
-
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
602
|
-
// don't natively support it.
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
var IteratorPrototype = {};
|
|
606
|
-
|
|
607
|
-
IteratorPrototype[iteratorSymbol] = function () {
|
|
608
|
-
return this;
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
var getProto = Object.getPrototypeOf;
|
|
612
|
-
var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
|
|
613
|
-
|
|
614
|
-
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
615
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
616
|
-
// of the polyfill.
|
|
617
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
|
|
621
|
-
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
622
|
-
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
623
|
-
GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
624
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
625
|
-
|
|
626
|
-
function defineIteratorMethods(prototype) {
|
|
627
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
628
|
-
define(prototype, method, function (arg) {
|
|
629
|
-
return this._invoke(method, arg);
|
|
630
|
-
});
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
exports.isGeneratorFunction = function (genFun) {
|
|
635
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
636
|
-
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
637
|
-
// do is to check its .name property.
|
|
638
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
639
|
-
};
|
|
640
|
-
|
|
641
|
-
exports.mark = function (genFun) {
|
|
642
|
-
if (Object.setPrototypeOf) {
|
|
643
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
644
|
-
} else {
|
|
645
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
646
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
genFun.prototype = Object.create(Gp);
|
|
650
|
-
return genFun;
|
|
651
|
-
}; // Within the body of any async function, `await x` is transformed to
|
|
652
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
653
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
654
|
-
// meant to be awaited.
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
exports.awrap = function (arg) {
|
|
658
|
-
return {
|
|
659
|
-
__await: arg
|
|
660
|
-
};
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
664
|
-
function invoke(method, arg, resolve, reject) {
|
|
665
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
666
|
-
|
|
667
|
-
if (record.type === "throw") {
|
|
668
|
-
reject(record.arg);
|
|
669
|
-
} else {
|
|
670
|
-
var result = record.arg;
|
|
671
|
-
var value = result.value;
|
|
672
|
-
|
|
673
|
-
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
674
|
-
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
675
|
-
invoke("next", value, resolve, reject);
|
|
676
|
-
}, function (err) {
|
|
677
|
-
invoke("throw", err, resolve, reject);
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
682
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
683
|
-
// the .value of the Promise<{value,done}> result for the
|
|
684
|
-
// current iteration.
|
|
685
|
-
result.value = unwrapped;
|
|
686
|
-
resolve(result);
|
|
687
|
-
}, function (error) {
|
|
688
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
689
|
-
// into the async generator function so it can be handled there.
|
|
690
|
-
return invoke("throw", error, resolve, reject);
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
var previousPromise;
|
|
696
|
-
|
|
697
|
-
function enqueue(method, arg) {
|
|
698
|
-
function callInvokeWithMethodAndArg() {
|
|
699
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
700
|
-
invoke(method, arg, resolve, reject);
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
705
|
-
// all previous Promises have been resolved before calling invoke,
|
|
706
|
-
// so that results are always delivered in the correct order. If
|
|
707
|
-
// enqueue has not been called before, then it is important to
|
|
708
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
709
|
-
// so that the async generator function has the opportunity to do
|
|
710
|
-
// any necessary setup in a predictable way. This predictability
|
|
711
|
-
// is why the Promise constructor synchronously invokes its
|
|
712
|
-
// executor callback, and why async functions synchronously
|
|
713
|
-
// execute code before the first await. Since we implement simple
|
|
714
|
-
// async functions in terms of async generators, it is especially
|
|
715
|
-
// important to get this right, even though it requires care.
|
|
716
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
717
|
-
// invocations of the iterator.
|
|
718
|
-
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
719
|
-
} // Define the unified helper method that is used to implement .next,
|
|
720
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
this._invoke = enqueue;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
727
|
-
|
|
728
|
-
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
729
|
-
return this;
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
733
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
734
|
-
// the final result produced by the iterator.
|
|
735
|
-
|
|
736
|
-
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
737
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
738
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
739
|
-
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
740
|
-
: iter.next().then(function (result) {
|
|
741
|
-
return result.done ? result.value : iter.next();
|
|
742
|
-
});
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
746
|
-
var state = GenStateSuspendedStart;
|
|
747
|
-
return function invoke(method, arg) {
|
|
748
|
-
if (state === GenStateExecuting) {
|
|
749
|
-
throw new Error("Generator is already running");
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (state === GenStateCompleted) {
|
|
753
|
-
if (method === "throw") {
|
|
754
|
-
throw arg;
|
|
755
|
-
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
756
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return doneResult();
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
context.method = method;
|
|
763
|
-
context.arg = arg;
|
|
764
|
-
|
|
765
|
-
while (true) {
|
|
766
|
-
var delegate = context.delegate;
|
|
767
|
-
|
|
768
|
-
if (delegate) {
|
|
769
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
770
|
-
|
|
771
|
-
if (delegateResult) {
|
|
772
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
773
|
-
return delegateResult;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
if (context.method === "next") {
|
|
778
|
-
// Setting context._sent for legacy support of Babel's
|
|
779
|
-
// function.sent implementation.
|
|
780
|
-
context.sent = context._sent = context.arg;
|
|
781
|
-
} else if (context.method === "throw") {
|
|
782
|
-
if (state === GenStateSuspendedStart) {
|
|
783
|
-
state = GenStateCompleted;
|
|
784
|
-
throw context.arg;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
context.dispatchException(context.arg);
|
|
788
|
-
} else if (context.method === "return") {
|
|
789
|
-
context.abrupt("return", context.arg);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
state = GenStateExecuting;
|
|
793
|
-
var record = tryCatch(innerFn, self, context);
|
|
794
|
-
|
|
795
|
-
if (record.type === "normal") {
|
|
796
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
797
|
-
// GenStateExecuting and loop back for another invocation.
|
|
798
|
-
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
799
|
-
|
|
800
|
-
if (record.arg === ContinueSentinel) {
|
|
801
|
-
continue;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
return {
|
|
805
|
-
value: record.arg,
|
|
806
|
-
done: context.done
|
|
807
|
-
};
|
|
808
|
-
} else if (record.type === "throw") {
|
|
809
|
-
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
810
|
-
// context.dispatchException(context.arg) call above.
|
|
811
|
-
|
|
812
|
-
context.method = "throw";
|
|
813
|
-
context.arg = record.arg;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
818
|
-
// result, either by returning a { value, done } result from the
|
|
819
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
820
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
824
|
-
var method = delegate.iterator[context.method];
|
|
825
|
-
|
|
826
|
-
if (method === undefined$1) {
|
|
827
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
828
|
-
// method always terminates the yield* loop.
|
|
829
|
-
context.delegate = null;
|
|
830
|
-
|
|
831
|
-
if (context.method === "throw") {
|
|
832
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
833
|
-
if (delegate.iterator["return"]) {
|
|
834
|
-
// If the delegate iterator has a return method, give it a
|
|
835
|
-
// chance to clean up.
|
|
836
|
-
context.method = "return";
|
|
837
|
-
context.arg = undefined$1;
|
|
838
|
-
maybeInvokeDelegate(delegate, context);
|
|
839
|
-
|
|
840
|
-
if (context.method === "throw") {
|
|
841
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
842
|
-
// "return" to "throw", let that override the TypeError below.
|
|
843
|
-
return ContinueSentinel;
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
context.method = "throw";
|
|
848
|
-
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
return ContinueSentinel;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
855
|
-
|
|
856
|
-
if (record.type === "throw") {
|
|
857
|
-
context.method = "throw";
|
|
858
|
-
context.arg = record.arg;
|
|
859
|
-
context.delegate = null;
|
|
860
|
-
return ContinueSentinel;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
var info = record.arg;
|
|
864
|
-
|
|
865
|
-
if (!info) {
|
|
866
|
-
context.method = "throw";
|
|
867
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
868
|
-
context.delegate = null;
|
|
869
|
-
return ContinueSentinel;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
if (info.done) {
|
|
873
|
-
// Assign the result of the finished delegate to the temporary
|
|
874
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
875
|
-
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
876
|
-
|
|
877
|
-
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
878
|
-
// exception, let the outer generator proceed normally. If
|
|
879
|
-
// context.method was "next", forget context.arg since it has been
|
|
880
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
881
|
-
// "return", allow the original .return call to continue in the
|
|
882
|
-
// outer generator.
|
|
883
|
-
|
|
884
|
-
if (context.method !== "return") {
|
|
885
|
-
context.method = "next";
|
|
886
|
-
context.arg = undefined$1;
|
|
887
|
-
}
|
|
888
|
-
} else {
|
|
889
|
-
// Re-yield the result returned by the delegate method.
|
|
890
|
-
return info;
|
|
891
|
-
} // The delegate iterator is finished, so forget it and continue with
|
|
892
|
-
// the outer generator.
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
context.delegate = null;
|
|
896
|
-
return ContinueSentinel;
|
|
897
|
-
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
898
|
-
// unified ._invoke helper method.
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
defineIteratorMethods(Gp);
|
|
902
|
-
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
903
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
904
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
905
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
906
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
907
|
-
|
|
908
|
-
Gp[iteratorSymbol] = function () {
|
|
909
|
-
return this;
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
Gp.toString = function () {
|
|
913
|
-
return "[object Generator]";
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
function pushTryEntry(locs) {
|
|
917
|
-
var entry = {
|
|
918
|
-
tryLoc: locs[0]
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
if (1 in locs) {
|
|
922
|
-
entry.catchLoc = locs[1];
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
if (2 in locs) {
|
|
926
|
-
entry.finallyLoc = locs[2];
|
|
927
|
-
entry.afterLoc = locs[3];
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
this.tryEntries.push(entry);
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
function resetTryEntry(entry) {
|
|
934
|
-
var record = entry.completion || {};
|
|
935
|
-
record.type = "normal";
|
|
936
|
-
delete record.arg;
|
|
937
|
-
entry.completion = record;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
function Context(tryLocsList) {
|
|
941
|
-
// The root entry object (effectively a try statement without a catch
|
|
942
|
-
// or a finally block) gives us a place to store values thrown from
|
|
943
|
-
// locations where there is no enclosing try statement.
|
|
944
|
-
this.tryEntries = [{
|
|
945
|
-
tryLoc: "root"
|
|
946
|
-
}];
|
|
947
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
948
|
-
this.reset(true);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
exports.keys = function (object) {
|
|
952
|
-
var keys = [];
|
|
953
|
-
|
|
954
|
-
for (var key in object) {
|
|
955
|
-
keys.push(key);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
959
|
-
// things simple and return the next function itself.
|
|
960
|
-
|
|
961
|
-
return function next() {
|
|
962
|
-
while (keys.length) {
|
|
963
|
-
var key = keys.pop();
|
|
964
|
-
|
|
965
|
-
if (key in object) {
|
|
966
|
-
next.value = key;
|
|
967
|
-
next.done = false;
|
|
968
|
-
return next;
|
|
969
|
-
}
|
|
970
|
-
} // To avoid creating an additional object, we just hang the .value
|
|
971
|
-
// and .done properties off the next function object itself. This
|
|
972
|
-
// also ensures that the minifier will not anonymize the function.
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
next.done = true;
|
|
976
|
-
return next;
|
|
977
|
-
};
|
|
978
|
-
};
|
|
979
|
-
|
|
980
|
-
function values(iterable) {
|
|
981
|
-
if (iterable) {
|
|
982
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
983
|
-
|
|
984
|
-
if (iteratorMethod) {
|
|
985
|
-
return iteratorMethod.call(iterable);
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
if (typeof iterable.next === "function") {
|
|
989
|
-
return iterable;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
if (!isNaN(iterable.length)) {
|
|
993
|
-
var i = -1,
|
|
994
|
-
next = function next() {
|
|
995
|
-
while (++i < iterable.length) {
|
|
996
|
-
if (hasOwn.call(iterable, i)) {
|
|
997
|
-
next.value = iterable[i];
|
|
998
|
-
next.done = false;
|
|
999
|
-
return next;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
next.value = undefined$1;
|
|
1004
|
-
next.done = true;
|
|
1005
|
-
return next;
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
return next.next = next;
|
|
1009
|
-
}
|
|
1010
|
-
} // Return an iterator with no values.
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
return {
|
|
1014
|
-
next: doneResult
|
|
1015
|
-
};
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
exports.values = values;
|
|
1019
|
-
|
|
1020
|
-
function doneResult() {
|
|
1021
|
-
return {
|
|
1022
|
-
value: undefined$1,
|
|
1023
|
-
done: true
|
|
1024
|
-
};
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
Context.prototype = {
|
|
1028
|
-
constructor: Context,
|
|
1029
|
-
reset: function reset(skipTempReset) {
|
|
1030
|
-
this.prev = 0;
|
|
1031
|
-
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
1032
|
-
// function.sent implementation.
|
|
1033
|
-
|
|
1034
|
-
this.sent = this._sent = undefined$1;
|
|
1035
|
-
this.done = false;
|
|
1036
|
-
this.delegate = null;
|
|
1037
|
-
this.method = "next";
|
|
1038
|
-
this.arg = undefined$1;
|
|
1039
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
1040
|
-
|
|
1041
|
-
if (!skipTempReset) {
|
|
1042
|
-
for (var name in this) {
|
|
1043
|
-
// Not sure about the optimal order of these conditions:
|
|
1044
|
-
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
1045
|
-
this[name] = undefined$1;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
},
|
|
1050
|
-
stop: function stop() {
|
|
1051
|
-
this.done = true;
|
|
1052
|
-
var rootEntry = this.tryEntries[0];
|
|
1053
|
-
var rootRecord = rootEntry.completion;
|
|
1054
|
-
|
|
1055
|
-
if (rootRecord.type === "throw") {
|
|
1056
|
-
throw rootRecord.arg;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
return this.rval;
|
|
1060
|
-
},
|
|
1061
|
-
dispatchException: function dispatchException(exception) {
|
|
1062
|
-
if (this.done) {
|
|
1063
|
-
throw exception;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
var context = this;
|
|
1067
|
-
|
|
1068
|
-
function handle(loc, caught) {
|
|
1069
|
-
record.type = "throw";
|
|
1070
|
-
record.arg = exception;
|
|
1071
|
-
context.next = loc;
|
|
1072
|
-
|
|
1073
|
-
if (caught) {
|
|
1074
|
-
// If the dispatched exception was caught by a catch block,
|
|
1075
|
-
// then let that catch block handle the exception normally.
|
|
1076
|
-
context.method = "next";
|
|
1077
|
-
context.arg = undefined$1;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
return !!caught;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1084
|
-
var entry = this.tryEntries[i];
|
|
1085
|
-
var record = entry.completion;
|
|
1086
|
-
|
|
1087
|
-
if (entry.tryLoc === "root") {
|
|
1088
|
-
// Exception thrown outside of any try block that could handle
|
|
1089
|
-
// it, so set the completion value of the entire function to
|
|
1090
|
-
// throw the exception.
|
|
1091
|
-
return handle("end");
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
if (entry.tryLoc <= this.prev) {
|
|
1095
|
-
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
1096
|
-
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1097
|
-
|
|
1098
|
-
if (hasCatch && hasFinally) {
|
|
1099
|
-
if (this.prev < entry.catchLoc) {
|
|
1100
|
-
return handle(entry.catchLoc, true);
|
|
1101
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
1102
|
-
return handle(entry.finallyLoc);
|
|
1103
|
-
}
|
|
1104
|
-
} else if (hasCatch) {
|
|
1105
|
-
if (this.prev < entry.catchLoc) {
|
|
1106
|
-
return handle(entry.catchLoc, true);
|
|
1107
|
-
}
|
|
1108
|
-
} else if (hasFinally) {
|
|
1109
|
-
if (this.prev < entry.finallyLoc) {
|
|
1110
|
-
return handle(entry.finallyLoc);
|
|
1111
|
-
}
|
|
1112
|
-
} else {
|
|
1113
|
-
throw new Error("try statement without catch or finally");
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
},
|
|
1118
|
-
abrupt: function abrupt(type, arg) {
|
|
1119
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1120
|
-
var entry = this.tryEntries[i];
|
|
1121
|
-
|
|
1122
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1123
|
-
var finallyEntry = entry;
|
|
1124
|
-
break;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
1129
|
-
// Ignore the finally entry if control is not jumping to a
|
|
1130
|
-
// location outside the try/catch block.
|
|
1131
|
-
finallyEntry = null;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1135
|
-
record.type = type;
|
|
1136
|
-
record.arg = arg;
|
|
1137
|
-
|
|
1138
|
-
if (finallyEntry) {
|
|
1139
|
-
this.method = "next";
|
|
1140
|
-
this.next = finallyEntry.finallyLoc;
|
|
1141
|
-
return ContinueSentinel;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
return this.complete(record);
|
|
1145
|
-
},
|
|
1146
|
-
complete: function complete(record, afterLoc) {
|
|
1147
|
-
if (record.type === "throw") {
|
|
1148
|
-
throw record.arg;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
if (record.type === "break" || record.type === "continue") {
|
|
1152
|
-
this.next = record.arg;
|
|
1153
|
-
} else if (record.type === "return") {
|
|
1154
|
-
this.rval = this.arg = record.arg;
|
|
1155
|
-
this.method = "return";
|
|
1156
|
-
this.next = "end";
|
|
1157
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
1158
|
-
this.next = afterLoc;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
return ContinueSentinel;
|
|
1162
|
-
},
|
|
1163
|
-
finish: function finish(finallyLoc) {
|
|
1164
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1165
|
-
var entry = this.tryEntries[i];
|
|
1166
|
-
|
|
1167
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
1168
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
1169
|
-
resetTryEntry(entry);
|
|
1170
|
-
return ContinueSentinel;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
"catch": function _catch(tryLoc) {
|
|
1175
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1176
|
-
var entry = this.tryEntries[i];
|
|
1177
|
-
|
|
1178
|
-
if (entry.tryLoc === tryLoc) {
|
|
1179
|
-
var record = entry.completion;
|
|
1180
|
-
|
|
1181
|
-
if (record.type === "throw") {
|
|
1182
|
-
var thrown = record.arg;
|
|
1183
|
-
resetTryEntry(entry);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
return thrown;
|
|
1187
|
-
}
|
|
1188
|
-
} // The context.catch method must only be called with a location
|
|
1189
|
-
// argument that corresponds to a known catch block.
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
throw new Error("illegal catch attempt");
|
|
1193
|
-
},
|
|
1194
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1195
|
-
this.delegate = {
|
|
1196
|
-
iterator: values(iterable),
|
|
1197
|
-
resultName: resultName,
|
|
1198
|
-
nextLoc: nextLoc
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
if (this.method === "next") {
|
|
1202
|
-
// Deliberately forget the last sent value so that we don't
|
|
1203
|
-
// accidentally pass it on to the delegate.
|
|
1204
|
-
this.arg = undefined$1;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
return ContinueSentinel;
|
|
1208
|
-
}
|
|
1209
|
-
}; // Regardless of whether this script is executing as a CommonJS module
|
|
1210
|
-
// or not, return the runtime object so that we can declare the variable
|
|
1211
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1212
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1213
|
-
|
|
1214
|
-
return exports;
|
|
1215
|
-
}( // If this script is executing as a CommonJS module, use module.exports
|
|
1216
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1217
|
-
// object. Either way, the resulting object will be used to initialize
|
|
1218
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
1219
|
-
module.exports );
|
|
1220
|
-
|
|
1221
|
-
try {
|
|
1222
|
-
regeneratorRuntime = runtime;
|
|
1223
|
-
} catch (accidentalStrictMode) {
|
|
1224
|
-
// This module should not be running in strict mode, so the above
|
|
1225
|
-
// assignment should always work unless something is misconfigured. Just
|
|
1226
|
-
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
1227
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
1228
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
1229
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
1230
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
1231
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1232
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
1233
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1234
|
-
}
|
|
1235
|
-
})(runtime);
|
|
1236
|
-
|
|
1237
|
-
var _regeneratorRuntime = runtime.exports;
|
|
1238
|
-
|
|
1239
770
|
var useNormalizedItems = function useNormalizedItems(items) {
|
|
1240
771
|
return React.useMemo(function () {
|
|
1241
772
|
return items.map(function (item) {
|
|
@@ -1245,13 +776,11 @@ var useNormalizedItems = function useNormalizedItems(items) {
|
|
|
1245
776
|
label: item
|
|
1246
777
|
};
|
|
1247
778
|
}
|
|
1248
|
-
|
|
1249
779
|
if (!('value' in item)) {
|
|
1250
780
|
return _extends({}, item, {
|
|
1251
781
|
value: item.label
|
|
1252
782
|
});
|
|
1253
783
|
}
|
|
1254
|
-
|
|
1255
784
|
return item;
|
|
1256
785
|
});
|
|
1257
786
|
}, [items]);
|
|
@@ -1266,7 +795,6 @@ var useIsMounted = function useIsMounted() {
|
|
|
1266
795
|
}, []);
|
|
1267
796
|
return isMountedRef.current;
|
|
1268
797
|
};
|
|
1269
|
-
|
|
1270
798
|
var reducer = function reducer(_state, action) {
|
|
1271
799
|
switch (action.type) {
|
|
1272
800
|
case 'request results':
|
|
@@ -1274,7 +802,6 @@ var reducer = function reducer(_state, action) {
|
|
|
1274
802
|
items: [],
|
|
1275
803
|
loading: true
|
|
1276
804
|
};
|
|
1277
|
-
|
|
1278
805
|
case 'received results':
|
|
1279
806
|
return {
|
|
1280
807
|
items: action.payload,
|
|
@@ -1282,44 +809,38 @@ var reducer = function reducer(_state, action) {
|
|
|
1282
809
|
};
|
|
1283
810
|
}
|
|
1284
811
|
};
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
/** The list of items, or an async function that resolves the list of items */
|
|
1288
|
-
itemsOrItemsResolver,
|
|
1289
|
-
/** The time to wait after the input changes to the fetchItems method is called */
|
|
812
|
+
var useResolvedItems = function useResolvedItems( /** The list of items, or an async function that resolves the list of items */
|
|
813
|
+
itemsOrItemsResolver, /** The time to wait after the input changes to the fetchItems method is called */
|
|
1290
814
|
debounceTimeout) {
|
|
1291
815
|
if (debounceTimeout === void 0) {
|
|
1292
816
|
debounceTimeout = 250;
|
|
1293
817
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
818
|
+
var isItemsFunction = typeof itemsOrItemsResolver === 'function';
|
|
819
|
+
// Here, we normalize the itemsResolver argument to an async function, so we
|
|
1296
820
|
// can use it without thinking about the differences later
|
|
1297
|
-
|
|
1298
821
|
var itemsResolver = React.useMemo(function () {
|
|
1299
822
|
return isItemsFunction ? itemsOrItemsResolver : function () {
|
|
1300
823
|
return Promise.resolve(itemsOrItemsResolver);
|
|
1301
824
|
};
|
|
1302
825
|
}, [itemsOrItemsResolver, isItemsFunction]);
|
|
1303
|
-
|
|
1304
826
|
var _React$useReducer = React.useReducer(reducer, {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
827
|
+
items: isItemsFunction ? [] : itemsOrItemsResolver,
|
|
828
|
+
loading: false
|
|
829
|
+
}),
|
|
830
|
+
_React$useReducer$ = _React$useReducer[0],
|
|
831
|
+
items = _React$useReducer$.items,
|
|
832
|
+
loading = _React$useReducer$.loading,
|
|
833
|
+
dispatch = _React$useReducer[1];
|
|
834
|
+
// This is a way to check whether or not the dropdown is still in the
|
|
1312
835
|
// document. We use it below to make sure we're not updating the state of
|
|
1313
836
|
// an unmounted component.
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
var isMounted = useIsMounted(); // Next, let's create the fetching function. This should be called whenever
|
|
837
|
+
var isMounted = useIsMounted();
|
|
838
|
+
// Next, let's create the fetching function. This should be called whenever
|
|
1317
839
|
// the input value changes
|
|
1318
|
-
|
|
1319
840
|
var fetchItems = React.useCallback( /*#__PURE__*/function () {
|
|
1320
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(inputValue) {
|
|
841
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputValue) {
|
|
1321
842
|
var resolvedItems;
|
|
1322
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
843
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1323
844
|
while (1) {
|
|
1324
845
|
switch (_context.prev = _context.next) {
|
|
1325
846
|
case 0:
|
|
@@ -1327,26 +848,21 @@ debounceTimeout) {
|
|
|
1327
848
|
_context.next = 2;
|
|
1328
849
|
break;
|
|
1329
850
|
}
|
|
1330
|
-
|
|
1331
851
|
return _context.abrupt("return");
|
|
1332
|
-
|
|
1333
852
|
case 2:
|
|
1334
853
|
dispatch({
|
|
1335
854
|
type: 'request results'
|
|
1336
855
|
});
|
|
1337
856
|
_context.next = 5;
|
|
1338
857
|
return itemsResolver(inputValue);
|
|
1339
|
-
|
|
1340
858
|
case 5:
|
|
1341
859
|
resolvedItems = _context.sent;
|
|
1342
|
-
|
|
1343
860
|
if (isMounted) {
|
|
1344
861
|
dispatch({
|
|
1345
862
|
type: 'received results',
|
|
1346
863
|
payload: resolvedItems
|
|
1347
864
|
});
|
|
1348
865
|
}
|
|
1349
|
-
|
|
1350
866
|
case 7:
|
|
1351
867
|
case "end":
|
|
1352
868
|
return _context.stop();
|
|
@@ -1354,7 +870,6 @@ debounceTimeout) {
|
|
|
1354
870
|
}
|
|
1355
871
|
}, _callee);
|
|
1356
872
|
}));
|
|
1357
|
-
|
|
1358
873
|
return function (_x) {
|
|
1359
874
|
return _ref.apply(this, arguments);
|
|
1360
875
|
};
|
|
@@ -1373,41 +888,39 @@ debounceTimeout) {
|
|
|
1373
888
|
};
|
|
1374
889
|
};
|
|
1375
890
|
|
|
1376
|
-
var _excluded$
|
|
891
|
+
var _excluded$4 = ["highlightFirstItemOnOpen", "debounceTimeout", "disabled", "feedback", "items", "label", "loadingText", "onChange", "placeholder", "prepend", "readOnly", "searchable", "selectOnTab", "openOnFocus", "variant", "value", "clearable", "className", "style", "listStyle", "itemFilter", "disableLabelAnimation"];
|
|
1377
892
|
var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
1378
893
|
var highlightFirstItemOnOpen = _ref.highlightFirstItemOnOpen,
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
894
|
+
debounceTimeout = _ref.debounceTimeout,
|
|
895
|
+
disabled = _ref.disabled,
|
|
896
|
+
feedback = _ref.feedback,
|
|
897
|
+
items = _ref.items,
|
|
898
|
+
label = _ref.label,
|
|
899
|
+
loadingText = _ref.loadingText,
|
|
900
|
+
_ref$onChange = _ref.onChange,
|
|
901
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
902
|
+
return undefined;
|
|
903
|
+
} : _ref$onChange,
|
|
904
|
+
placeholder = _ref.placeholder,
|
|
905
|
+
prepend = _ref.prepend,
|
|
906
|
+
readOnly = _ref.readOnly,
|
|
907
|
+
searchable = _ref.searchable,
|
|
908
|
+
selectOnTab = _ref.selectOnTab,
|
|
909
|
+
openOnFocus = _ref.openOnFocus,
|
|
910
|
+
variant = _ref.variant,
|
|
911
|
+
value = _ref.value,
|
|
912
|
+
_ref$clearable = _ref.clearable,
|
|
913
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
914
|
+
className = _ref.className,
|
|
915
|
+
style = _ref.style,
|
|
916
|
+
listStyle = _ref.listStyle,
|
|
917
|
+
itemFilter = _ref.itemFilter,
|
|
918
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
919
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
1406
920
|
var _useResolvedItems = useResolvedItems(items, debounceTimeout),
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
921
|
+
normalizedItems = _useResolvedItems.items,
|
|
922
|
+
loading = _useResolvedItems.loading,
|
|
923
|
+
fetchItems = _useResolvedItems.fetchItems;
|
|
1411
924
|
var selectedItem = value === undefined ? undefined : normalizedItems.find(function (item) {
|
|
1412
925
|
return value === item.value;
|
|
1413
926
|
}) || null;
|
|
@@ -1450,37 +963,33 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
1450
963
|
}, searchAbleProps))));
|
|
1451
964
|
});
|
|
1452
965
|
|
|
1453
|
-
var _excluded$
|
|
966
|
+
var _excluded$3 = ["className", "disabled", "readOnly", "items", "loadingText", "prepend", "style", "label", "variant", "feedback", "disableLabelAnimation"];
|
|
1454
967
|
var NativeDropdown = function NativeDropdown(_ref) {
|
|
1455
968
|
var className = _ref.className,
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
969
|
+
_ref$disabled = _ref.disabled,
|
|
970
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
971
|
+
_ref$readOnly = _ref.readOnly,
|
|
972
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
973
|
+
items = _ref.items,
|
|
974
|
+
loadingText = _ref.loadingText,
|
|
975
|
+
prepend = _ref.prepend,
|
|
976
|
+
style = _ref.style,
|
|
977
|
+
label = _ref.label,
|
|
978
|
+
variant = _ref.variant,
|
|
979
|
+
feedback = _ref.feedback,
|
|
980
|
+
disableLabelAnimation = _ref.disableLabelAnimation,
|
|
981
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
1470
982
|
var _useResolvedItems = useResolvedItems(items),
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
983
|
+
normalizedItems = _useResolvedItems.items,
|
|
984
|
+
loading = _useResolvedItems.loading;
|
|
1474
985
|
var rightSideIcon = React.createElement(DownArrowIcon, {
|
|
1475
986
|
inline: true
|
|
1476
987
|
});
|
|
1477
|
-
|
|
1478
988
|
if (disabled || readOnly) {
|
|
1479
989
|
rightSideIcon = null;
|
|
1480
990
|
} else if (loading) {
|
|
1481
991
|
rightSideIcon = React.createElement(DropdownLoadingDots, null, loadingText);
|
|
1482
992
|
}
|
|
1483
|
-
|
|
1484
993
|
var nativeDropdownId = useRandomId('eds-native-dropdown');
|
|
1485
994
|
return React.createElement(BaseFormControl, {
|
|
1486
995
|
disabled: disabled,
|
|
@@ -1507,24 +1016,20 @@ var NativeDropdown = function NativeDropdown(_ref) {
|
|
|
1507
1016
|
})));
|
|
1508
1017
|
};
|
|
1509
1018
|
|
|
1510
|
-
var _excluded$
|
|
1019
|
+
var _excluded$2 = ["items", "itemsSelectedLabel", "label", "feedback", "variant", "disabled", "readOnly", "onChange", "className", "clearable", "loading", "loadingText", "openOnFocus", "style", "listStyle", "initialSelectedItems", "debounceTimeout"];
|
|
1511
1020
|
var MultiSelectContext = /*#__PURE__*/React.createContext(null);
|
|
1512
|
-
|
|
1513
1021
|
var useMultiSelectContext = function useMultiSelectContext() {
|
|
1514
1022
|
var context = React.useContext(MultiSelectContext);
|
|
1515
|
-
|
|
1516
1023
|
if (!context) {
|
|
1517
1024
|
throw new Error('You need to wrap your component in a DownshiftProvider');
|
|
1518
1025
|
}
|
|
1519
|
-
|
|
1520
1026
|
return context;
|
|
1521
1027
|
};
|
|
1522
|
-
|
|
1523
|
-
|
|
1028
|
+
function stateReducer(state,
|
|
1029
|
+
//StateChangeOptions<NormalizedDropdownItemType>,
|
|
1524
1030
|
actionAndChanges) {
|
|
1525
1031
|
var changes = actionAndChanges.changes,
|
|
1526
|
-
|
|
1527
|
-
|
|
1032
|
+
type = actionAndChanges.type;
|
|
1528
1033
|
switch (type) {
|
|
1529
1034
|
case useSelect.stateChangeTypes.MenuKeyDownEnter:
|
|
1530
1035
|
case useSelect.stateChangeTypes.MenuKeyDownSpaceButton:
|
|
@@ -1533,96 +1038,84 @@ actionAndChanges) {
|
|
|
1533
1038
|
isOpen: true,
|
|
1534
1039
|
highlightedIndex: state.highlightedIndex
|
|
1535
1040
|
});
|
|
1536
|
-
|
|
1537
1041
|
default:
|
|
1538
1042
|
return changes;
|
|
1539
1043
|
}
|
|
1540
1044
|
}
|
|
1541
|
-
|
|
1542
1045
|
var MultiSelect = function MultiSelect(_ref) {
|
|
1543
1046
|
var input = _ref.items,
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1047
|
+
_ref$itemsSelectedLab = _ref.itemsSelectedLabel,
|
|
1048
|
+
itemsSelectedLabel = _ref$itemsSelectedLab === void 0 ? function (items) {
|
|
1049
|
+
return SelectedItemsLabel(items);
|
|
1050
|
+
} : _ref$itemsSelectedLab,
|
|
1051
|
+
label = _ref.label,
|
|
1052
|
+
feedback = _ref.feedback,
|
|
1053
|
+
variant = _ref.variant,
|
|
1054
|
+
disabled = _ref.disabled,
|
|
1055
|
+
_ref$readOnly = _ref.readOnly,
|
|
1056
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
1057
|
+
_ref$onChange = _ref.onChange,
|
|
1058
|
+
onChange = _ref$onChange === void 0 ? function () {
|
|
1059
|
+
return undefined;
|
|
1060
|
+
} : _ref$onChange,
|
|
1061
|
+
className = _ref.className,
|
|
1062
|
+
_ref$clearable = _ref.clearable,
|
|
1063
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1064
|
+
_ref$loading = _ref.loading,
|
|
1065
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
1066
|
+
_ref$loadingText = _ref.loadingText,
|
|
1067
|
+
loadingText = _ref$loadingText === void 0 ? '' : _ref$loadingText,
|
|
1068
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
1069
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
1070
|
+
style = _ref.style,
|
|
1071
|
+
listStyle = _ref.listStyle,
|
|
1072
|
+
_ref$initialSelectedI = _ref.initialSelectedItems,
|
|
1073
|
+
initialSelectedItems = _ref$initialSelectedI === void 0 ? [] : _ref$initialSelectedI,
|
|
1074
|
+
debounceTimeout = _ref.debounceTimeout,
|
|
1075
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1574
1076
|
var _useResolvedItems = useResolvedItems(input, debounceTimeout),
|
|
1575
|
-
|
|
1576
|
-
|
|
1077
|
+
items = _useResolvedItems.items;
|
|
1577
1078
|
var _useState = useState(initialSelectedItems),
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1079
|
+
selectedItems = _useState[0],
|
|
1080
|
+
setSelectedItems = _useState[1];
|
|
1581
1081
|
var reset = React.useCallback(function () {
|
|
1582
1082
|
setSelectedItems([]);
|
|
1583
1083
|
}, []);
|
|
1584
|
-
|
|
1585
1084
|
function isSelected(selectedCheckboxItem) {
|
|
1586
1085
|
return selectedItems.some(function (selected) {
|
|
1587
1086
|
return selected.value === selectedCheckboxItem.value;
|
|
1588
1087
|
});
|
|
1589
1088
|
}
|
|
1590
|
-
|
|
1591
1089
|
var _useSelect = useSelect(_extends({
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
setSelectedItems(_slicedItemList);
|
|
1614
|
-
onChange(_slicedItemList);
|
|
1090
|
+
items: items,
|
|
1091
|
+
stateReducer: stateReducer,
|
|
1092
|
+
selectedItem: null,
|
|
1093
|
+
onSelectedItemChange: function onSelectedItemChange(_ref2) {
|
|
1094
|
+
var selectedItem = _ref2.selectedItem;
|
|
1095
|
+
if (!selectedItem) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
var itemIsFound = isSelected(selectedItem);
|
|
1099
|
+
if (itemIsFound) {
|
|
1100
|
+
var slicedItemList = selectedItems.filter(function (item) {
|
|
1101
|
+
return item.value !== selectedItem.value;
|
|
1102
|
+
});
|
|
1103
|
+
setSelectedItems(slicedItemList);
|
|
1104
|
+
onChange(slicedItemList);
|
|
1105
|
+
} else {
|
|
1106
|
+
var _slicedItemList = [].concat(selectedItems, [selectedItem]);
|
|
1107
|
+
setSelectedItems(_slicedItemList);
|
|
1108
|
+
onChange(_slicedItemList);
|
|
1109
|
+
}
|
|
1615
1110
|
}
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
openMenu = _useSelect.openMenu;
|
|
1625
|
-
|
|
1111
|
+
}, rest)),
|
|
1112
|
+
isOpen = _useSelect.isOpen,
|
|
1113
|
+
getToggleButtonProps = _useSelect.getToggleButtonProps,
|
|
1114
|
+
getLabelProps = _useSelect.getLabelProps,
|
|
1115
|
+
getMenuProps = _useSelect.getMenuProps,
|
|
1116
|
+
highlightedIndex = _useSelect.highlightedIndex,
|
|
1117
|
+
getItemProps = _useSelect.getItemProps,
|
|
1118
|
+
openMenu = _useSelect.openMenu;
|
|
1626
1119
|
var buttonText = selectedItems.length ? itemsSelectedLabel(selectedItems) : '';
|
|
1627
1120
|
var multiSelectId = useRandomId('eds-multiselect');
|
|
1628
1121
|
return React.createElement(MultiSelectContext.Provider, {
|
|
@@ -1699,13 +1192,10 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
1699
1192
|
})));
|
|
1700
1193
|
}))));
|
|
1701
1194
|
};
|
|
1702
|
-
|
|
1703
1195
|
var ClearButton = function ClearButton(_ref3) {
|
|
1704
|
-
var props = _extends({}, _ref3);
|
|
1705
|
-
|
|
1196
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref3), _ref3));
|
|
1706
1197
|
var _useMultiSelectContex = useMultiSelectContext(),
|
|
1707
|
-
|
|
1708
|
-
|
|
1198
|
+
reset = _useMultiSelectContex.reset;
|
|
1709
1199
|
return React.createElement(React.Fragment, null, React.createElement("button", _extends({
|
|
1710
1200
|
className: "eds-dropdown__clear-button",
|
|
1711
1201
|
type: "button",
|
|
@@ -1717,31 +1207,25 @@ var ClearButton = function ClearButton(_ref3) {
|
|
|
1717
1207
|
className: "eds-dropdown__divider"
|
|
1718
1208
|
}));
|
|
1719
1209
|
};
|
|
1720
|
-
|
|
1721
1210
|
var Appendix$1 = function Appendix(_ref4) {
|
|
1722
1211
|
var loading = _ref4.loading,
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1212
|
+
loadingText = _ref4.loadingText,
|
|
1213
|
+
readOnly = _ref4.readOnly,
|
|
1214
|
+
hasSelected = _ref4.hasSelected;
|
|
1727
1215
|
if (loading) {
|
|
1728
1216
|
return React.createElement(DropdownLoadingDots, null, loadingText);
|
|
1729
1217
|
}
|
|
1730
|
-
|
|
1731
1218
|
if (readOnly) {
|
|
1732
1219
|
return null;
|
|
1733
1220
|
}
|
|
1734
|
-
|
|
1735
1221
|
return hasSelected ? React.createElement(React.Fragment, null, React.createElement(ClearButton, null), React.createElement(DropdownToggleButton, null)) : React.createElement(DropdownToggleButton, null);
|
|
1736
1222
|
};
|
|
1737
|
-
|
|
1738
1223
|
var DropdownToggleButton = function DropdownToggleButton() {
|
|
1739
1224
|
var _useMultiSelectContex2 = useMultiSelectContext(),
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1225
|
+
getToggleButtonProps = _useMultiSelectContex2.getToggleButtonProps,
|
|
1226
|
+
isOpen = _useMultiSelectContex2.isOpen,
|
|
1227
|
+
openMenu = _useMultiSelectContex2.openMenu,
|
|
1228
|
+
openOnFocus = _useMultiSelectContex2.openOnFocus;
|
|
1745
1229
|
return React.createElement("button", _extends({}, getToggleButtonProps({
|
|
1746
1230
|
className: classNames('eds-dropdown__toggle-button', {
|
|
1747
1231
|
'eds-dropdown__toggle-button--open': isOpen
|
|
@@ -1755,7 +1239,6 @@ var DropdownToggleButton = function DropdownToggleButton() {
|
|
|
1755
1239
|
type: "button"
|
|
1756
1240
|
}), React.createElement(DownArrowIcon, null));
|
|
1757
1241
|
};
|
|
1758
|
-
|
|
1759
1242
|
var CheckboxIcon = function CheckboxIcon() {
|
|
1760
1243
|
return React.createElement("svg", {
|
|
1761
1244
|
className: "eds-checkbox-icon",
|
|
@@ -1768,60 +1251,91 @@ var CheckboxIcon = function CheckboxIcon() {
|
|
|
1768
1251
|
fill: "none"
|
|
1769
1252
|
}));
|
|
1770
1253
|
};
|
|
1771
|
-
|
|
1772
1254
|
function SelectedItemsLabel(items) {
|
|
1773
1255
|
return items.length < 3 ? items.map(function (item) {
|
|
1774
1256
|
return item.label;
|
|
1775
1257
|
}).toString() : items.length + " elementer valgt";
|
|
1776
1258
|
}
|
|
1777
1259
|
|
|
1778
|
-
var _excluded = ["
|
|
1260
|
+
var _excluded$1 = ["selectedItem", "isOpen", "getMenuProps", "getItemProps", "filteredItems", "highlightedIndex", "listStyle"];
|
|
1261
|
+
var DropdownList = function DropdownList(_ref) {
|
|
1262
|
+
var selectedItem = _ref.selectedItem,
|
|
1263
|
+
isOpen = _ref.isOpen,
|
|
1264
|
+
getMenuProps = _ref.getMenuProps,
|
|
1265
|
+
getItemProps = _ref.getItemProps,
|
|
1266
|
+
filteredItems = _ref.filteredItems,
|
|
1267
|
+
highlightedIndex = _ref.highlightedIndex,
|
|
1268
|
+
listStyle = _ref.listStyle,
|
|
1269
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1270
|
+
return React.createElement("ul", _extends({
|
|
1271
|
+
className: classNames('eds-searchable-dropdown__list', {
|
|
1272
|
+
'eds-searchable-dropdown__list--open': isOpen
|
|
1273
|
+
})
|
|
1274
|
+
}, getMenuProps(), {
|
|
1275
|
+
style: _extends({}, rest.style, listStyle)
|
|
1276
|
+
}), isOpen ? filteredItems.map(function (item, index) {
|
|
1277
|
+
return (
|
|
1278
|
+
// eslint-disable-next-line react/jsx-key
|
|
1279
|
+
React.createElement("li", _extends({
|
|
1280
|
+
className: classNames('eds-searchable-dropdown__list__item', {
|
|
1281
|
+
'eds-searchable-dropdown__list__item--highlighted': highlightedIndex === index,
|
|
1282
|
+
'eds-searchable-dropdown__list__item--selected': (selectedItem == null ? void 0 : selectedItem.value) === item.value
|
|
1283
|
+
})
|
|
1284
|
+
}, getItemProps({
|
|
1285
|
+
key: "" + index + item.value,
|
|
1286
|
+
item: item,
|
|
1287
|
+
index: index
|
|
1288
|
+
})), React.createElement("span", null, item.label), item.icons && React.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
1289
|
+
return React.createElement(Icon, {
|
|
1290
|
+
key: index,
|
|
1291
|
+
inline: true,
|
|
1292
|
+
className: "eds-searchable-dropdown__list__item-icon"
|
|
1293
|
+
});
|
|
1294
|
+
})), (selectedItem == null ? void 0 : selectedItem.value) === item.value && React.createElement(CheckIcon, null))
|
|
1295
|
+
);
|
|
1296
|
+
}) : null);
|
|
1297
|
+
};
|
|
1779
1298
|
|
|
1299
|
+
var _excluded = ["items", "selectedItem", "onChange", "label", "placeholder", "clearable", "openOnFocus", "readonly", "feedback", "variant", "className", "listStyle"];
|
|
1780
1300
|
function lowerCaseFilterTest(item, input) {
|
|
1781
1301
|
if (!input) {
|
|
1782
1302
|
return true;
|
|
1783
1303
|
}
|
|
1784
|
-
|
|
1785
1304
|
var sanitizeEscapeCharacters = input.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
1786
1305
|
var inputRegex = new RegExp(sanitizeEscapeCharacters, 'i');
|
|
1787
1306
|
return inputRegex.test(item.label);
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1307
|
+
}
|
|
1308
|
+
// TODO Husk å @deprecate searchable-prop-en til Dropdown når denne komponenten skal ha official release
|
|
1309
|
+
// TODO Husk å generelt legge inn støtte for typeof value === string
|
|
1791
1310
|
var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
1792
1311
|
var _selectedItem$label;
|
|
1793
|
-
|
|
1794
1312
|
var items = _ref.items,
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1313
|
+
value = _ref.selectedItem,
|
|
1314
|
+
onChange = _ref.onChange,
|
|
1315
|
+
label = _ref.label,
|
|
1316
|
+
placeholder = _ref.placeholder,
|
|
1317
|
+
_ref$clearable = _ref.clearable,
|
|
1318
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
1319
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
1320
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
1321
|
+
_ref$readonly = _ref.readonly,
|
|
1322
|
+
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
1323
|
+
feedback = _ref.feedback,
|
|
1324
|
+
_ref$variant = _ref.variant,
|
|
1325
|
+
variant = _ref$variant === void 0 ? 'info' : _ref$variant,
|
|
1326
|
+
className = _ref.className,
|
|
1327
|
+
listStyle = _ref.listStyle,
|
|
1328
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1812
1329
|
var _React$useState = React.useState(items),
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1330
|
+
filteredItems = _React$useState[0],
|
|
1331
|
+
setFilteredItems = _React$useState[1];
|
|
1816
1332
|
var _useState = useState(false),
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1333
|
+
hideSelectedItem = _useState[0],
|
|
1334
|
+
setHideSelectedItem = _useState[1];
|
|
1820
1335
|
var inputRef = useRef(null);
|
|
1821
1336
|
var stateReducer = React.useCallback(function (_, actionAndChanges) {
|
|
1822
1337
|
var type = actionAndChanges.type,
|
|
1823
|
-
|
|
1824
|
-
|
|
1338
|
+
changes = actionAndChanges.changes;
|
|
1825
1339
|
switch (type) {
|
|
1826
1340
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
1827
1341
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
@@ -1830,44 +1344,40 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1830
1344
|
return _extends({}, changes, changes.selectedItem && {
|
|
1831
1345
|
inputValue: ''
|
|
1832
1346
|
});
|
|
1833
|
-
|
|
1834
1347
|
default:
|
|
1835
1348
|
return changes;
|
|
1836
1349
|
}
|
|
1837
1350
|
}, []);
|
|
1838
|
-
|
|
1839
1351
|
var _useCombobox = useCombobox(_extends({
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1352
|
+
onInputValueChange: function onInputValueChange(_ref2) {
|
|
1353
|
+
var inputValue = _ref2.inputValue;
|
|
1354
|
+
setFilteredItems(items.filter(function (item) {
|
|
1355
|
+
return lowerCaseFilterTest(item, inputValue);
|
|
1356
|
+
}));
|
|
1357
|
+
},
|
|
1358
|
+
items: filteredItems,
|
|
1359
|
+
itemToString: function itemToString(item) {
|
|
1360
|
+
if (item) return item.value;
|
|
1361
|
+
return '';
|
|
1362
|
+
},
|
|
1363
|
+
stateReducer: stateReducer,
|
|
1364
|
+
selectedItem: value,
|
|
1365
|
+
onSelectedItemChange: function onSelectedItemChange(_ref3) {
|
|
1366
|
+
var newSelectedItem = _ref3.selectedItem;
|
|
1367
|
+
return onChange(newSelectedItem != null ? newSelectedItem : null);
|
|
1368
|
+
}
|
|
1369
|
+
}, rest)),
|
|
1370
|
+
isOpen = _useCombobox.isOpen,
|
|
1371
|
+
getToggleButtonProps = _useCombobox.getToggleButtonProps,
|
|
1372
|
+
getLabelProps = _useCombobox.getLabelProps,
|
|
1373
|
+
getMenuProps = _useCombobox.getMenuProps,
|
|
1374
|
+
getInputProps = _useCombobox.getInputProps,
|
|
1375
|
+
getComboboxProps = _useCombobox.getComboboxProps,
|
|
1376
|
+
highlightedIndex = _useCombobox.highlightedIndex,
|
|
1377
|
+
getItemProps = _useCombobox.getItemProps,
|
|
1378
|
+
selectedItem = _useCombobox.selectedItem,
|
|
1379
|
+
openMenu = _useCombobox.openMenu,
|
|
1380
|
+
inputValue = _useCombobox.inputValue;
|
|
1871
1381
|
return React.createElement("div", {
|
|
1872
1382
|
className: "eds-searchable-dropdown__wrapper"
|
|
1873
1383
|
}, React.createElement(BaseFormControl, _extends({
|
|
@@ -1894,7 +1404,6 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1894
1404
|
className: "eds-searchable-dropdown__selected-item",
|
|
1895
1405
|
onClick: function onClick() {
|
|
1896
1406
|
var _inputRef$current;
|
|
1897
|
-
|
|
1898
1407
|
return (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
|
|
1899
1408
|
}
|
|
1900
1409
|
}, selectedItem.label)), React.createElement("input", _extends({
|
|
@@ -1909,42 +1418,23 @@ var SearchableDropdownBeta = function SearchableDropdownBeta(_ref) {
|
|
|
1909
1418
|
setHideSelectedItem(false);
|
|
1910
1419
|
},
|
|
1911
1420
|
ref: inputRef
|
|
1912
|
-
})))), React.createElement(
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
className: classNames('eds-searchable-dropdown__list__item', {
|
|
1922
|
-
'eds-searchable-dropdown__list__item--highlighted': highlightedIndex === index,
|
|
1923
|
-
'eds-searchable-dropdown__list__item--selected': (selectedItem == null ? void 0 : selectedItem.value) === item.value
|
|
1924
|
-
})
|
|
1925
|
-
}, getItemProps({
|
|
1926
|
-
key: "" + index + item.value,
|
|
1927
|
-
item: item,
|
|
1928
|
-
index: index
|
|
1929
|
-
})), React.createElement("span", null, item.label), item.icons && React.createElement("span", null, item.icons.map(function (Icon, index) {
|
|
1930
|
-
return React.createElement(Icon, {
|
|
1931
|
-
key: index,
|
|
1932
|
-
inline: true,
|
|
1933
|
-
className: "eds-searchable-dropdown__list__item-icon"
|
|
1934
|
-
});
|
|
1935
|
-
})), (selectedItem == null ? void 0 : selectedItem.value) === item.value && React.createElement(CheckIcon, null))
|
|
1936
|
-
);
|
|
1937
|
-
}) : null));
|
|
1421
|
+
})))), React.createElement(DropdownList, {
|
|
1422
|
+
selectedItem: selectedItem,
|
|
1423
|
+
isOpen: isOpen,
|
|
1424
|
+
filteredItems: filteredItems,
|
|
1425
|
+
highlightedIndex: highlightedIndex,
|
|
1426
|
+
listStyle: listStyle,
|
|
1427
|
+
getMenuProps: getMenuProps,
|
|
1428
|
+
getItemProps: getItemProps
|
|
1429
|
+
}));
|
|
1938
1430
|
};
|
|
1939
|
-
|
|
1940
1431
|
var Appendix = function Appendix(_ref4) {
|
|
1941
1432
|
var clearable = _ref4.clearable,
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1433
|
+
readOnly = _ref4.readOnly,
|
|
1434
|
+
getToggleButtonProps = _ref4.getToggleButtonProps,
|
|
1435
|
+
selectedItem = _ref4.selectedItem,
|
|
1436
|
+
isOpen = _ref4.isOpen,
|
|
1437
|
+
onChange = _ref4.onChange;
|
|
1948
1438
|
// TODO implement loading / async
|
|
1949
1439
|
// if (loading) {
|
|
1950
1440
|
// return <DropdownLoadingDots>{loadingText}</DropdownLoadingDots>;
|
|
@@ -1952,13 +1442,12 @@ var Appendix = function Appendix(_ref4) {
|
|
|
1952
1442
|
if (readOnly) {
|
|
1953
1443
|
return null;
|
|
1954
1444
|
}
|
|
1955
|
-
|
|
1956
1445
|
return React.createElement("div", {
|
|
1957
1446
|
style: {
|
|
1958
1447
|
display: 'flex',
|
|
1959
1448
|
alignItems: 'center'
|
|
1960
1449
|
}
|
|
1961
|
-
}, clearable && selectedItem && React.createElement(React.Fragment, null, React.createElement(
|
|
1450
|
+
}, clearable && selectedItem && React.createElement(React.Fragment, null, React.createElement(IconButton, {
|
|
1962
1451
|
className: "eds-searchable-dropdown-appendix__clear-button",
|
|
1963
1452
|
type: "button",
|
|
1964
1453
|
tabIndex: -1,
|
|
@@ -1967,12 +1456,12 @@ var Appendix = function Appendix(_ref4) {
|
|
|
1967
1456
|
}
|
|
1968
1457
|
}, React.createElement(CloseSmallIcon, null)), React.createElement("div", {
|
|
1969
1458
|
className: "eds-searchable-dropdown-appendix__divider"
|
|
1970
|
-
})), React.createElement(
|
|
1459
|
+
})), React.createElement(IconButton, _extends({}, getToggleButtonProps({
|
|
1971
1460
|
className: classNames('eds-searchable-dropdown-appendix__toggle-button', {
|
|
1972
1461
|
'eds-searchable-dropdown-appendix__toggle-button--open': isOpen
|
|
1973
1462
|
})
|
|
1974
1463
|
}), {
|
|
1975
|
-
tabIndex:
|
|
1464
|
+
tabIndex: -1,
|
|
1976
1465
|
type: "button"
|
|
1977
1466
|
}), React.createElement(DownArrowIcon, null)));
|
|
1978
1467
|
};
|