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