@pingux/astro 2.92.0-alpha.0 → 2.92.0-alpha.1

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.
@@ -22,9 +22,9 @@ import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
22
22
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
23
23
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
24
24
  import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
25
- 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 _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, 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 _context8; 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(_context8 = this.tryEntries).call(_context8, 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; }
25
+ 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 _context8; _forEachInstanceProperty(_context8 = ["next", "throw", "return"]).call(_context8, 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 _context9; 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(_context9 = this.tryEntries).call(_context9, 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
26
  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
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
28
28
  import React, { useEffect, useState } from 'react';
29
29
  import { useAsyncList } from 'react-stately';
30
30
  import { useCollator } from '@react-aria/i18n';
@@ -58,6 +58,36 @@ export default {
58
58
  disable: true
59
59
  }
60
60
  },
61
+ selectedKeys: {
62
+ description: 'The array of keys that is currently selected. (Controlled version).',
63
+ control: {
64
+ disable: true
65
+ }
66
+ },
67
+ disabledKeys: {
68
+ description: 'The array of keys that are unabled to be selected.',
69
+ control: {
70
+ disable: true
71
+ }
72
+ },
73
+ defaultSelectedKeys: {
74
+ description: 'The array of keys that is selected by default. (Uncontrolled version).',
75
+ control: {
76
+ disable: true
77
+ }
78
+ },
79
+ onSelectionChange: {
80
+ description: 'A callback function that fires when the selection changes.',
81
+ control: {
82
+ disable: true
83
+ }
84
+ },
85
+ selectionMode: {
86
+ description: 'Options are "none" and "single". Whether or not the DataTable support selection',
87
+ control: {
88
+ disable: true
89
+ }
90
+ },
61
91
  width: {
62
92
  description: 'Sets the width of the data table.',
63
93
  control: {
@@ -470,6 +500,164 @@ Sortable.parameters = {
470
500
  }
471
501
  }
472
502
  };
503
+ export var Selection = function Selection(args) {
504
+ var columns = [{
505
+ name: 'Country',
506
+ key: 'country'
507
+ }, {
508
+ name: 'Population',
509
+ key: 'population'
510
+ }, {
511
+ name: 'Continent',
512
+ key: 'continent'
513
+ }];
514
+ var rows = [{
515
+ id: 1,
516
+ country: 'USA',
517
+ population: '320,000,000',
518
+ continent: 'North America'
519
+ }, {
520
+ id: 2,
521
+ country: 'Canada',
522
+ population: '37,000,000',
523
+ continent: 'North America'
524
+ }, {
525
+ id: 3,
526
+ country: 'China',
527
+ population: '1,398,000,000',
528
+ continent: 'Asia'
529
+ }, {
530
+ id: 4,
531
+ country: 'France',
532
+ population: '67,000,000',
533
+ continent: 'Europe'
534
+ }, {
535
+ id: 5,
536
+ country: 'Mexico',
537
+ population: '126,000,000',
538
+ continent: 'South America'
539
+ }, {
540
+ id: 6,
541
+ country: 'Ethiopia',
542
+ population: '120,000,000',
543
+ continent: 'Africa'
544
+ }, {
545
+ id: 7,
546
+ country: 'Austria',
547
+ population: '25,000,000',
548
+ continent: 'Oceania'
549
+ }];
550
+ return ___EmotionJSX(DataTable, _extends({}, args, {
551
+ "aria-label": "Dynamic table",
552
+ density: "compact",
553
+ scale: "medium",
554
+ selectionMode: "single",
555
+ disabledKeys: [3],
556
+ defaultSelectedKeys: [1]
557
+ }), ___EmotionJSX(DataTableHeader, {
558
+ columns: columns
559
+ }, function (column) {
560
+ return ___EmotionJSX(DataTableColumn, _extends({}, getCellProps(column.key, 'center'), {
561
+ minWidth: 155
562
+ }), column.name);
563
+ }), ___EmotionJSX(DataTableBody, {
564
+ items: rows
565
+ }, function (item) {
566
+ return ___EmotionJSX(DataTableRow, null, function (columnKey) {
567
+ return ___EmotionJSX(DataTableCell, getCellProps(columnKey, 'left'), item[columnKey]);
568
+ });
569
+ }));
570
+ };
571
+ export var ControlledSelection = function ControlledSelection(args) {
572
+ var _useState3 = useState([2]),
573
+ _useState4 = _slicedToArray(_useState3, 2),
574
+ selectedKeys = _useState4[0],
575
+ setSelectedKeys = _useState4[1];
576
+ var columns = [{
577
+ name: 'Country',
578
+ key: 'country'
579
+ }, {
580
+ name: 'Population',
581
+ key: 'population'
582
+ }, {
583
+ name: 'Continent',
584
+ key: 'continent'
585
+ }];
586
+ var rows = [{
587
+ id: 1,
588
+ country: 'USA',
589
+ population: '320,000,000',
590
+ continent: 'North America'
591
+ }, {
592
+ id: 2,
593
+ country: 'Canada',
594
+ population: '37,000,000',
595
+ continent: 'North America'
596
+ }, {
597
+ id: 3,
598
+ country: 'China',
599
+ population: '1,398,000,000',
600
+ continent: 'Asia'
601
+ }, {
602
+ id: 4,
603
+ country: 'France',
604
+ population: '67,000,000',
605
+ continent: 'Europe'
606
+ }, {
607
+ id: 5,
608
+ country: 'Mexico',
609
+ population: '126,000,000',
610
+ continent: 'South America'
611
+ }, {
612
+ id: 6,
613
+ country: 'Ethiopia',
614
+ population: '120,000,000',
615
+ continent: 'Africa'
616
+ }, {
617
+ id: 7,
618
+ country: 'Austria',
619
+ population: '25,000,000',
620
+ continent: 'Oceania'
621
+ }];
622
+ var list = useAsyncList({
623
+ load: function load() {
624
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
625
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
626
+ while (1) switch (_context4.prev = _context4.next) {
627
+ case 0:
628
+ return _context4.abrupt("return", {
629
+ items: rows
630
+ });
631
+ case 1:
632
+ case "end":
633
+ return _context4.stop();
634
+ }
635
+ }, _callee4);
636
+ }))();
637
+ }
638
+ });
639
+ return ___EmotionJSX(DataTable, _extends({}, args, {
640
+ "aria-label": "Dynamic table",
641
+ density: "compact",
642
+ scale: "medium",
643
+ selectionMode: "single",
644
+ disabledKeys: [3],
645
+ selectedKeys: selectedKeys,
646
+ onSelectionChange: setSelectedKeys
647
+ }), ___EmotionJSX(DataTableHeader, {
648
+ columns: columns
649
+ }, function (column) {
650
+ return ___EmotionJSX(DataTableColumn, _extends({}, getCellProps(column.key, 'center'), {
651
+ minWidth: 155
652
+ }), column.name);
653
+ }), ___EmotionJSX(DataTableBody, {
654
+ items: list.items
655
+ }, function (item) {
656
+ return ___EmotionJSX(DataTableRow, null, function (columnKey) {
657
+ return ___EmotionJSX(DataTableCell, getCellProps(columnKey, 'left'), item[columnKey]);
658
+ });
659
+ }));
660
+ };
473
661
  export var AsyncLoading = function AsyncLoading(args) {
474
662
  /**
475
663
  * isChromatic checks if the code is running in Chromatic environment
@@ -492,40 +680,40 @@ export var AsyncLoading = function AsyncLoading(args) {
492
680
  }];
493
681
  var list = useAsyncList({
494
682
  load: function load(_ref2) {
495
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
683
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
496
684
  var signal, cursor, res, json;
497
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
498
- while (1) switch (_context4.prev = _context4.next) {
685
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
686
+ while (1) switch (_context5.prev = _context5.next) {
499
687
  case 0:
500
688
  signal = _ref2.signal, cursor = _ref2.cursor;
501
689
  if (cursor) {
502
690
  // eslint-disable-next-line no-param-reassign
503
691
  cursor = cursor.replace(/^http:\/\//i, 'https://');
504
692
  }
505
- _context4.next = 4;
693
+ _context5.next = 4;
506
694
  return fetch(cursor || 'https://swapi.py4e.com/api/people/?search=', {
507
695
  signal: signal
508
696
  });
509
697
  case 4:
510
- res = _context4.sent;
511
- _context4.next = 7;
698
+ res = _context5.sent;
699
+ _context5.next = 7;
512
700
  return res.json();
513
701
  case 7:
514
- json = _context4.sent;
515
- _context4.next = 10;
702
+ json = _context5.sent;
703
+ _context5.next = 10;
516
704
  return new _Promise(function (resolve) {
517
705
  return _setTimeout(resolve, cursor ? 2000 : 3000);
518
706
  });
519
707
  case 10:
520
- return _context4.abrupt("return", {
708
+ return _context5.abrupt("return", {
521
709
  items: json.results,
522
710
  cursor: json.next
523
711
  });
524
712
  case 11:
525
713
  case "end":
526
- return _context4.stop();
714
+ return _context5.stop();
527
715
  }
528
- }, _callee4);
716
+ }, _callee5);
529
717
  }))();
530
718
  }
531
719
  });
@@ -61,6 +61,22 @@ var tableRow = {
61
61
  backgroundColor: 'white'
62
62
  }
63
63
  };
64
+ var selectableTableRow = _objectSpread(_objectSpread({}, tableRow), {}, {
65
+ bg: 'accent.99',
66
+ '&.is-selected': {
67
+ bg: 'white'
68
+ },
69
+ '&.is-hovered': {
70
+ bg: 'white',
71
+ cursor: 'pointer'
72
+ },
73
+ '&.is-focused': {
74
+ boxShadow: '0 0 0 1px inset #D033FF'
75
+ },
76
+ '&.is-disabled': {
77
+ opacity: '0.5 !important'
78
+ }
79
+ });
64
80
  var tableHeadWrapper = {
65
81
  borderLeftWidth: '0px',
66
82
  borderLeftStyle: 'solid',
@@ -137,6 +153,7 @@ var tableMenu = {
137
153
  mr: 'md'
138
154
  };
139
155
  export default {
156
+ selectableTableRow: selectableTableRow,
140
157
  tableBody: tableBody,
141
158
  tableHeadWrapper: tableHeadWrapper,
142
159
  tableCenteredWrapper: tableCenteredWrapper,
@@ -16,8 +16,9 @@ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object
16
16
  import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
17
17
  import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
18
18
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
19
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
20
19
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
20
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
21
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
21
22
  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 _context40; _forEachInstanceProperty(_context40 = ["next", "throw", "return"]).call(_context40, 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 _context41; 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(_context41 = this.tryEntries).call(_context41, 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; }
22
23
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
23
24
  import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
@@ -30,10 +31,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
30
31
  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; }
31
32
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context37, _context38; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context37 = ownKeys(Object(source), !0)).call(_context37, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context38 = ownKeys(Object(source))).call(_context38, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
32
33
  /* eslint-disable testing-library/no-node-access */
33
- import React from 'react';
34
+ import React, { useState } from 'react';
34
35
  import { useAsyncList } from 'react-stately';
35
36
  import { useCollator } from '@react-aria/i18n';
36
37
  import { act, act as actDom, act as actHooks, fireEvent, render, renderHook, screen, within } from '@testing-library/react';
38
+ import userEvent from '@testing-library/user-event';
37
39
  import { DataTableBody, DataTableCell, DataTableColumn, DataTableHeader, DataTableRow } from '../../index';
38
40
  import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
39
41
  import DataTable from './DataTable';
@@ -65,25 +67,50 @@ var columns = [{
65
67
  }];
66
68
  var rows = [{
67
69
  id: 2,
70
+ key: 2,
68
71
  country: 'Canada',
69
72
  population: 37000000,
70
73
  continent: 'North America'
71
74
  }, {
72
75
  id: 1,
76
+ key: 1,
73
77
  country: 'USA',
74
78
  population: 320000000,
75
79
  continent: 'North America'
76
80
  }, {
77
81
  id: 3,
82
+ key: 3,
78
83
  country: 'China',
79
84
  population: 1398000000,
80
85
  continent: 'Asia'
81
86
  }, {
82
87
  id: 4,
88
+ key: 4,
83
89
  country: 'France',
84
90
  population: 67000000,
85
91
  continent: 'Europe'
86
92
  }];
93
+ var ControlledDataTable = function ControlledDataTable(props) {
94
+ var _useState = useState([]),
95
+ _useState2 = _slicedToArray(_useState, 2),
96
+ selectedKeys = _useState2[0],
97
+ setSelectedKeys = _useState2[1];
98
+ return ___EmotionJSX(DataTable, _extends({}, props, {
99
+ selectionMode: "single",
100
+ selectedKeys: selectedKeys,
101
+ onSelectionChange: setSelectedKeys
102
+ }), ___EmotionJSX(DataTableHeader, {
103
+ columns: columns
104
+ }, function (column) {
105
+ return ___EmotionJSX(DataTableColumn, null, column.name);
106
+ }), ___EmotionJSX(DataTableBody, {
107
+ items: rows
108
+ }, function (item) {
109
+ return ___EmotionJSX(DataTableRow, null, function (columnKey) {
110
+ return ___EmotionJSX(DataTableCell, null, item[columnKey]);
111
+ });
112
+ }));
113
+ };
87
114
  var getCell = function getCell(view, text) {
88
115
  // Find by text, then go up to the element with the cell role.
89
116
  // eslint-disable-next-line testing-library/prefer-screen-queries
@@ -192,6 +219,14 @@ describe('Static DataTable', function () {
192
219
  expect(cells[6]).toHaveAttribute('aria-colindex', '2');
193
220
  expect(cells[7]).toHaveAttribute('aria-colindex', '3');
194
221
  });
222
+ test('should select with mouse click', function () {
223
+ staticDataTable();
224
+ var thisItem = screen.getAllByRole('row');
225
+ expect(thisItem[2]).not.toHaveClass('is-selected');
226
+ userEvent.click(thisItem[2]);
227
+ var updatedItem = screen.queryAllByRole('row')[2];
228
+ expect(updatedItem).not.toHaveClass('is-selected');
229
+ });
195
230
  test('should move focus to the next cell in a row with ArrowRight', function () {
196
231
  var view = staticDataTable();
197
232
  act(function () {
@@ -227,6 +262,110 @@ describe('Static DataTable', function () {
227
262
  expect(getCell(view, 'Europe')).toHaveFocus();
228
263
  });
229
264
  });
265
+ describe('Selectable DataTable', function () {
266
+ var testId = 'staticTable';
267
+ var testCallback = jest.fn();
268
+ var defaultProps = {
269
+ 'aria-label': 'Default table with static content',
270
+ width: '100%',
271
+ height: '100%',
272
+ 'data-testid': testId,
273
+ selectionMode: 'single',
274
+ defaultSelectedKeys: [1],
275
+ onSelectionChange: testCallback
276
+ };
277
+ var staticDataTable = function staticDataTable(props) {
278
+ return render(___EmotionJSX(DataTable, _extends({}, defaultProps, props), ___EmotionJSX(DataTableHeader, {
279
+ columns: columns
280
+ }, function (column) {
281
+ return ___EmotionJSX(DataTableColumn, null, column.name);
282
+ }), ___EmotionJSX(DataTableBody, {
283
+ items: rows
284
+ }, function (item) {
285
+ return ___EmotionJSX(DataTableRow, null, function (columnKey) {
286
+ return ___EmotionJSX(DataTableCell, null, item[columnKey]);
287
+ });
288
+ })));
289
+ };
290
+ test('should change selection on mouse press', function () {
291
+ staticDataTable({});
292
+ var thisItem = screen.getAllByRole('row');
293
+ expect(thisItem[1]).not.toHaveClass('is-selected');
294
+ userEvent.click(thisItem[1]);
295
+ expect(thisItem[1]).toHaveClass('is-selected');
296
+ expect(thisItem[1]).toHaveClass('is-selectable');
297
+ });
298
+ test('defaultSelectedKeys works', function () {
299
+ staticDataTable({
300
+ defaultSelectedKeys: [2]
301
+ });
302
+ var thisItem = screen.getAllByRole('row');
303
+ expect(thisItem[1]).toHaveClass('is-selected');
304
+ });
305
+ test('disabledKeys', function () {
306
+ staticDataTable({
307
+ disabledKeys: [2]
308
+ });
309
+ var thisItem = screen.getAllByRole('row');
310
+ expect(thisItem[1]).not.toHaveClass('is-selected');
311
+ userEvent.click(thisItem[1]);
312
+ expect(thisItem[1]).not.toHaveClass('is-selected');
313
+ });
314
+ test('onSelectedChange callback works as expected', function () {
315
+ staticDataTable({
316
+ disabledKeys: [2]
317
+ });
318
+ var thisItem = screen.getAllByRole('row');
319
+ expect(thisItem[1]).not.toHaveClass('is-selected');
320
+ userEvent.click(thisItem[1]);
321
+ expect(testCallback).toHaveBeenCalled();
322
+ expect(thisItem[1]).not.toHaveClass('is-selected');
323
+ });
324
+ });
325
+ describe('Controlled Selectable DataTable', function () {
326
+ var testId = 'staticTable';
327
+ var props = {
328
+ 'aria-label': 'Default table with static content',
329
+ width: '100%',
330
+ height: '100%',
331
+ 'data-testid': testId,
332
+ selectionMode: 'single'
333
+ };
334
+ test('should select with mouse click', function () {
335
+ render(___EmotionJSX(ControlledDataTable, props));
336
+ var thisItem = screen.getAllByRole('row');
337
+ expect(thisItem[2]).not.toHaveClass('is-selected');
338
+ userEvent.click(thisItem[2]);
339
+ var updatedItem = screen.queryAllByRole('row')[2];
340
+ expect(updatedItem).toHaveClass('is-selected');
341
+ });
342
+ test('should select with keyboard', function () {
343
+ render(___EmotionJSX(ControlledDataTable, props));
344
+ var thisItem = screen.getAllByRole('row');
345
+ userEvent.tab();
346
+ expect(thisItem[2]).not.toHaveClass('is-selected');
347
+ moveFocus('ArrowDown');
348
+ fireEvent.keyDown(thisItem[2], {
349
+ key: ' '
350
+ });
351
+ var updatedItem = screen.queryAllByRole('row')[2];
352
+ expect(updatedItem).toHaveClass('is-selected');
353
+ });
354
+ test('disabledKeys', function () {
355
+ var theseProps = {
356
+ disabledKeys: [2],
357
+ 'aria-label': 'Default table with static content',
358
+ width: '100%',
359
+ height: '100%',
360
+ 'data-testid': testId
361
+ };
362
+ render(___EmotionJSX(ControlledDataTable, theseProps));
363
+ var thisItem = screen.getAllByRole('row');
364
+ expect(thisItem[1]).not.toHaveClass('is-selected');
365
+ userEvent.click(thisItem[1]);
366
+ expect(thisItem[1]).not.toHaveClass('is-selected');
367
+ });
368
+ });
230
369
  describe('Async DataTable', function () {
231
370
  test('renders a spinner when loading', function () {
232
371
  var testId = 'loadingTable';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.92.0-alpha.0",
3
+ "version": "2.92.0-alpha.1",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",