@pingux/astro 2.140.0-alpha.1 → 2.140.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/lib/api/users.js +22 -0
  2. package/lib/cjs/api/users.d.ts +2 -0
  3. package/lib/cjs/api/users.js +32 -0
  4. package/lib/cjs/components/ComboBoxField/ComboBoxField.stories.js +117 -91
  5. package/lib/cjs/components/DataTable/DataTable.stories.js +114 -67
  6. package/lib/cjs/components/LinkSelectField/LinkSelectField.stories.js +73 -47
  7. package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +141 -119
  8. package/lib/cjs/components/SelectField/SelectField.stories.js +78 -51
  9. package/lib/cjs/mocks/browser.d.ts +1 -0
  10. package/lib/cjs/mocks/browser.js +11 -0
  11. package/lib/cjs/mocks/constants/index.d.ts +3 -0
  12. package/lib/cjs/mocks/constants/index.js +13 -0
  13. package/lib/cjs/mocks/handlers/users.d.ts +1 -0
  14. package/lib/cjs/mocks/handlers/users.js +107 -0
  15. package/lib/cjs/mocks/handlers.d.ts +1 -0
  16. package/lib/cjs/mocks/handlers.js +13 -0
  17. package/lib/cjs/mocks/responses/users.d.ts +14 -0
  18. package/lib/cjs/mocks/responses/users.js +3572 -0
  19. package/lib/cjs/mocks/types/users.d.ts +73 -0
  20. package/lib/cjs/mocks/types/users.js +6 -0
  21. package/lib/cjs/types/dataTable.d.ts +5 -4
  22. package/lib/components/ComboBoxField/ComboBoxField.stories.js +118 -91
  23. package/lib/components/DataTable/DataTable.stories.js +114 -67
  24. package/lib/components/LinkSelectField/LinkSelectField.stories.js +73 -46
  25. package/lib/components/MultivaluesField/MultivaluesField.stories.js +140 -119
  26. package/lib/components/SelectField/SelectField.stories.js +78 -50
  27. package/lib/mocks/browser.js +3 -0
  28. package/lib/mocks/constants/index.js +3 -0
  29. package/lib/mocks/handlers/users.js +97 -0
  30. package/lib/mocks/handlers.js +4 -0
  31. package/lib/mocks/responses/users.js +3564 -0
  32. package/lib/mocks/types/users.js +1 -0
  33. package/package.json +7 -1
@@ -0,0 +1,73 @@
1
+ /// <reference types="react" />
2
+ export interface UserType {
3
+ _links: {
4
+ self: {
5
+ href: string;
6
+ };
7
+ password: {
8
+ href: string;
9
+ };
10
+ 'password.set': {
11
+ href: string;
12
+ };
13
+ 'password.reset': {
14
+ href: string;
15
+ };
16
+ 'password.check': {
17
+ href: string;
18
+ };
19
+ 'password.recover': {
20
+ href: string;
21
+ };
22
+ 'account.sendVerificationCode': {
23
+ href: string;
24
+ };
25
+ linkedAccounts: {
26
+ href: string;
27
+ };
28
+ };
29
+ _embedded: {
30
+ password: {
31
+ environment: {
32
+ id: string;
33
+ };
34
+ user: {
35
+ id: string;
36
+ };
37
+ passwordPolicy: {
38
+ id: string;
39
+ };
40
+ status: string;
41
+ lastChangedAt: string;
42
+ };
43
+ };
44
+ id: string;
45
+ key: string | React.Key;
46
+ environment: {
47
+ id: string;
48
+ };
49
+ account: {
50
+ canAuthenticate: boolean;
51
+ status: string;
52
+ };
53
+ createdAt: string;
54
+ email: string;
55
+ enabled: boolean;
56
+ identityProvider: {
57
+ type: string;
58
+ };
59
+ lifecycle: {
60
+ status: string;
61
+ };
62
+ mfaEnabled: boolean;
63
+ name: {
64
+ given: string;
65
+ family: string;
66
+ };
67
+ population: {
68
+ id: string;
69
+ };
70
+ updatedAt: string;
71
+ username: string;
72
+ verifyStatus: string;
73
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -44,6 +44,10 @@ export interface DataTableVirtualizerProps<T extends object, V> {
44
44
  whiteSpace?: 'normal' | 'initial';
45
45
  };
46
46
  }
47
+ export type SortDescriptor = {
48
+ column?: string;
49
+ direction?: 'ascending' | 'descending';
50
+ };
47
51
  export interface DataTableProps {
48
52
  onSelectedKeyChange?: () => void;
49
53
  selectedKeys?: Key[];
@@ -60,10 +64,7 @@ export interface DataTableProps {
60
64
  onLoadMore?: () => void;
61
65
  onSortChange?: () => void;
62
66
  loadingState?: loadingState;
63
- sortDescriptor?: {
64
- column?: string;
65
- direction?: 'ascending' | 'descending';
66
- };
67
+ sortDescriptor?: SortDescriptor;
67
68
  width?: string | number;
68
69
  children: ReactNode;
69
70
  scale?: 'large' | 'medium' | 'xl';
@@ -9,28 +9,28 @@ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
9
9
  import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
10
10
  import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
11
11
  import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
12
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
12
13
  import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
13
14
  import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
14
15
  import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
15
- import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
16
16
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
17
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
17
18
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
18
19
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
19
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; 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; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; 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); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context6; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context6 = this.tryEntries).call(_context6, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; 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; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
20
- import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
21
- import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
22
20
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
23
21
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
24
22
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
25
23
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
24
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; 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; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; 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); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context6; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context6 = this.tryEntries).call(_context6, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; 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; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
26
25
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
28
- import React, { useState } from 'react';
29
- import { useAsyncList } from 'react-stately';
27
+ import React, { useCallback, useEffect, useState } from 'react';
30
28
  import { useFilter } from '@react-aria/i18n';
31
29
  import { action } from '@storybook/addon-actions';
32
30
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
31
+ import { getAllUsers } from '../../api/users';
33
32
  import { ComboBoxField, Item, OverlayProvider, Section } from '../../index';
33
+ import { LIMIT } from '../../mocks/constants';
34
34
  import loadingStates from '../../utils/devUtils/constants/loadingStates';
35
35
  import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
36
36
  import ComboBoxFieldReadme from './ComboBoxField.mdx';
@@ -230,70 +230,97 @@ export var WithSections = function WithSections(args) {
230
230
  }));
231
231
  };
232
232
  export var AsyncLoading = function AsyncLoading() {
233
- // This example uses `useAsyncList` from "@react-stately/data"
234
- var list = useAsyncList({
235
- load: function load(_ref) {
236
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
237
- var signal, cursor, filterText, res, json;
238
- return _regeneratorRuntime().wrap(function _callee$(_context) {
239
- while (1) switch (_context.prev = _context.next) {
240
- case 0:
241
- signal = _ref.signal, cursor = _ref.cursor, filterText = _ref.filterText;
242
- if (cursor) {
243
- // eslint-disable-next-line
244
- cursor = cursor.replace(/^http:\/\//i, 'https://');
245
- }
246
-
247
- // If no cursor is available, then we're loading the first page,
248
- // filtering the results returned via a query string that
249
- // mirrors the ComboBox input text.
250
- // Otherwise, the cursor is the next URL to load,
251
- // as returned from the previous page.
252
- _context.next = 4;
253
- return fetch(cursor || "https://swapi.py4e.com/api/people/?search=".concat(filterText), {
254
- signal: signal
255
- });
256
- case 4:
257
- res = _context.sent;
258
- _context.next = 7;
259
- return res.json();
260
- case 7:
261
- json = _context.sent;
262
- _context.next = 10;
263
- return new _Promise(function (resolve) {
264
- return _setTimeout(resolve, cursor ? 2000 : 3000);
265
- });
266
- case 10:
267
- return _context.abrupt("return", {
268
- items: json.results,
269
- cursor: json.next
270
- });
271
- case 11:
272
- case "end":
273
- return _context.stop();
274
- }
275
- }, _callee);
276
- }))();
277
- }
278
- });
233
+ var _useState = useState([]),
234
+ _useState2 = _slicedToArray(_useState, 2),
235
+ data = _useState2[0],
236
+ setData = _useState2[1];
237
+ var _useState3 = useState(LIMIT),
238
+ _useState4 = _slicedToArray(_useState3, 2),
239
+ limit = _useState4[0],
240
+ setLimit = _useState4[1];
241
+ var _useState5 = useState(0),
242
+ _useState6 = _slicedToArray(_useState5, 2),
243
+ dataSize = _useState6[0],
244
+ setDataSize = _useState6[1];
245
+ var _useState7 = useState(loadingStates.LOADING),
246
+ _useState8 = _slicedToArray(_useState7, 2),
247
+ loading = _useState8[0],
248
+ setLoading = _useState8[1];
249
+ var _useState9 = useState(''),
250
+ _useState10 = _slicedToArray(_useState9, 2),
251
+ filterText = _useState10[0],
252
+ setFilterText = _useState10[1];
253
+ var fetchData = useCallback( /*#__PURE__*/function () {
254
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(currentLimit, searchText) {
255
+ var response, json;
256
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
257
+ while (1) switch (_context.prev = _context.next) {
258
+ case 0:
259
+ _context.prev = 0;
260
+ _context.next = 3;
261
+ return getAllUsers(currentLimit, searchText);
262
+ case 3:
263
+ response = _context.sent;
264
+ _context.next = 6;
265
+ return response.json();
266
+ case 6:
267
+ json = _context.sent;
268
+ if (response.ok) {
269
+ setData(json.body._embedded.users || []);
270
+ setDataSize(json.body.count);
271
+ } else {
272
+ setData([]);
273
+ }
274
+ setLoading(loadingStates.IDLE);
275
+ _context.next = 15;
276
+ break;
277
+ case 11:
278
+ _context.prev = 11;
279
+ _context.t0 = _context["catch"](0);
280
+ console.error('Fetch error:', _context.t0);
281
+ setLoading(loadingStates.ERROR);
282
+ case 15:
283
+ case "end":
284
+ return _context.stop();
285
+ }
286
+ }, _callee, null, [[0, 11]]);
287
+ }));
288
+ return function (_x, _x2) {
289
+ return _ref.apply(this, arguments);
290
+ };
291
+ }(), []);
292
+ var handleLoadMore = function handleLoadMore() {
293
+ if (loading !== loadingStates.IDLE || limit >= dataSize) return;
294
+ setLoading(loadingStates.LOADING_MORE);
295
+ setLimit(function (prev) {
296
+ return prev + LIMIT;
297
+ });
298
+ };
299
+ var handleSearch = function handleSearch(searchText) {
300
+ setLoading(loadingStates.FILTERING);
301
+ setFilterText(searchText);
302
+ };
303
+ useEffect(function () {
304
+ fetchData(limit, filterText);
305
+ }, [fetchData, limit, filterText]);
279
306
  return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({}, actions, {
280
307
  label: "Example label",
281
- items: list.items,
282
- inputValue: list.filterText,
283
- onInputChange: list.setFilterText,
284
- loadingState: list.loadingState,
285
- onLoadMore: list.loadMore
308
+ items: data,
309
+ inputValue: filterText,
310
+ onInputChange: handleSearch,
311
+ loadingState: loading,
312
+ onLoadMore: handleLoadMore
286
313
  }), function (item) {
287
314
  return ___EmotionJSX(Item, {
288
- key: item.name
289
- }, item.name);
315
+ key: item.name.given
316
+ }, item.name.given);
290
317
  }));
291
318
  };
292
319
  export var ControlledInput = function ControlledInput() {
293
- var _useState = useState(''),
294
- _useState2 = _slicedToArray(_useState, 2),
295
- inputValue = _useState2[0],
296
- setInputValue = _useState2[1];
320
+ var _useState11 = useState(''),
321
+ _useState12 = _slicedToArray(_useState11, 2),
322
+ inputValue = _useState12[0],
323
+ setInputValue = _useState12[1];
297
324
  return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
298
325
  label: "Example label",
299
326
  defaultItems: items
@@ -307,10 +334,10 @@ export var ControlledInput = function ControlledInput() {
307
334
  }));
308
335
  };
309
336
  export var ControlledMenu = function ControlledMenu() {
310
- var _useState3 = useState(false),
311
- _useState4 = _slicedToArray(_useState3, 2),
312
- isOpen = _useState4[0],
313
- setIsOpen = _useState4[1];
337
+ var _useState13 = useState(false),
338
+ _useState14 = _slicedToArray(_useState13, 2),
339
+ isOpen = _useState14[0],
340
+ setIsOpen = _useState14[1];
314
341
 
315
342
  // Use menuTrigger="manual" if you don't want open change events to fire on input / focus
316
343
  return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
@@ -326,10 +353,10 @@ export var ControlledMenu = function ControlledMenu() {
326
353
  }));
327
354
  };
328
355
  export var ControlledSelection = function ControlledSelection() {
329
- var _useState5 = useState(''),
330
- _useState6 = _slicedToArray(_useState5, 2),
331
- selectedKey = _useState6[0],
332
- setSelectedKey = _useState6[1];
356
+ var _useState15 = useState(''),
357
+ _useState16 = _slicedToArray(_useState15, 2),
358
+ selectedKey = _useState16[0],
359
+ setSelectedKey = _useState16[1];
333
360
  return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
334
361
  label: "Example label",
335
362
  defaultItems: items
@@ -348,14 +375,14 @@ export var ControlledFiltering = function ControlledFiltering() {
348
375
  sensitivity: 'base'
349
376
  }),
350
377
  startsWith = _startsWithInstanceProperty(_useFilter);
351
- var _useState7 = useState({
378
+ var _useState17 = useState({
352
379
  inputValue: '',
353
380
  selectedKey: '',
354
381
  itemsList: items
355
382
  }),
356
- _useState8 = _slicedToArray(_useState7, 2),
357
- fieldState = _useState8[0],
358
- setFieldState = _useState8[1];
383
+ _useState18 = _slicedToArray(_useState17, 2),
384
+ fieldState = _useState18[0],
385
+ setFieldState = _useState18[1];
359
386
  var onSelectionChange = function onSelectionChange(key) {
360
387
  var selectedItem = _filterInstanceProperty(items).call(items, function (_ref2) {
361
388
  var id = _ref2.id;
@@ -408,10 +435,10 @@ export var ControlledFiltering = function ControlledFiltering() {
408
435
  }));
409
436
  };
410
437
  export var ControlledWithCustomValue = function ControlledWithCustomValue() {
411
- var _useState9 = useState(''),
412
- _useState10 = _slicedToArray(_useState9, 2),
413
- inputValue = _useState10[0],
414
- setInputValue = _useState10[1];
438
+ var _useState19 = useState(''),
439
+ _useState20 = _slicedToArray(_useState19, 2),
440
+ inputValue = _useState20[0],
441
+ setInputValue = _useState20[1];
415
442
  return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ComboBoxField, _extends({
416
443
  label: "Example label",
417
444
  defaultItems: items
@@ -556,18 +583,18 @@ export var CustomDefaultFilter = function CustomDefaultFilter() {
556
583
  }));
557
584
  };
558
585
  export var ControlledWithAddOption = function ControlledWithAddOption() {
559
- var _useState11 = useState(items),
560
- _useState12 = _slicedToArray(_useState11, 2),
561
- options = _useState12[0],
562
- setOptions = _useState12[1];
563
- var _useState13 = useState(''),
564
- _useState14 = _slicedToArray(_useState13, 2),
565
- inputValue = _useState14[0],
566
- setInputValue = _useState14[1];
567
- var _useState15 = useState(''),
568
- _useState16 = _slicedToArray(_useState15, 2),
569
- selectedKey = _useState16[0],
570
- setSelectedKey = _useState16[1];
586
+ var _useState21 = useState(items),
587
+ _useState22 = _slicedToArray(_useState21, 2),
588
+ options = _useState22[0],
589
+ setOptions = _useState22[1];
590
+ var _useState23 = useState(''),
591
+ _useState24 = _slicedToArray(_useState23, 2),
592
+ inputValue = _useState24[0],
593
+ setInputValue = _useState24[1];
594
+ var _useState25 = useState(''),
595
+ _useState26 = _slicedToArray(_useState25, 2),
596
+ selectedKey = _useState26[0],
597
+ setSelectedKey = _useState26[1];
571
598
  var onSelectionChange = function onSelectionChange(key) {
572
599
  // Add new option to options array
573
600
  if (key && !_findInstanceProperty(options).call(options, function (_ref3) {