@pingux/astro 2.98.0-alpha.0 → 2.98.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.
- package/lib/cjs/components/ListView/ListView.js +15 -2
- package/lib/cjs/components/ListView/ListView.stories.d.ts +1 -0
- package/lib/cjs/components/ListView/ListView.stories.js +157 -33
- package/lib/cjs/components/ListView/ListView.test.js +171 -77
- package/lib/cjs/hooks/useLoadPrev/index.d.ts +1 -0
- package/lib/cjs/hooks/useLoadPrev/index.js +14 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.d.ts +2 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.js +35 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.test.d.ts +1 -0
- package/lib/cjs/hooks/useLoadPrev/useLoadPrev.test.js +87 -0
- package/lib/cjs/types/listView.d.ts +1 -0
- package/lib/cjs/utils/devUtils/constants/loadingStates.js +2 -1
- package/lib/components/ListView/ListView.js +15 -2
- package/lib/components/ListView/ListView.stories.js +125 -2
- package/lib/components/ListView/ListView.test.js +168 -77
- package/lib/hooks/useLoadPrev/index.js +1 -0
- package/lib/hooks/useLoadPrev/useLoadPrev.js +27 -0
- package/lib/hooks/useLoadPrev/useLoadPrev.test.js +78 -0
- package/lib/utils/devUtils/constants/loadingStates.js +2 -1
- package/package.json +1 -1
@@ -16,12 +16,16 @@ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/ins
|
|
16
16
|
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
17
17
|
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
18
18
|
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
19
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
19
20
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
21
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
22
|
+
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
20
23
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
21
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
22
25
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
26
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
23
27
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
24
|
-
var _react =
|
28
|
+
var _react = _interopRequireWildcard(require("react"));
|
25
29
|
var _reactAria = require("react-aria");
|
26
30
|
var _reactStately = require("react-stately");
|
27
31
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
@@ -34,9 +38,11 @@ var _CheckboxField = _interopRequireDefault(require("../CheckboxField"));
|
|
34
38
|
var _ListView = _interopRequireDefault(require("./ListView"));
|
35
39
|
var _ListViewFocusWrapper = require("./ListViewFocusWrapper");
|
36
40
|
var _react2 = require("@emotion/react");
|
41
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
42
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
43
|
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; }
|
38
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
39
|
-
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 _context13; _forEachInstanceProperty(_context13 = ["next", "throw", "return"]).call(_context13, 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 _context14; 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(_context14 = this.tryEntries).call(_context14, 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; }
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context19, _context20; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context19 = ownKeys(Object(source), !0)).call(_context19, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context20 = ownKeys(Object(source))).call(_context20, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
45
|
+
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 _context17; _forEachInstanceProperty(_context17 = ["next", "throw", "return"]).call(_context17, 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 _context18; 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(_context18 = this.tryEntries).call(_context18, 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; }
|
40
46
|
var items = [{
|
41
47
|
key: 'Aardvark',
|
42
48
|
name: 'Aardvark',
|
@@ -60,6 +66,8 @@ var preventDefault = jest.fn();
|
|
60
66
|
var focusNext = jest.fn();
|
61
67
|
var focusPrevious = jest.fn();
|
62
68
|
var setIsFocusEscaped = jest.fn();
|
69
|
+
var onLoadMoreFunc = jest.fn();
|
70
|
+
var onLoadPrevFunc = jest.fn();
|
63
71
|
var testEvent = {
|
64
72
|
stopPropagation: stopPropagation,
|
65
73
|
preventDefault: preventDefault
|
@@ -152,6 +160,69 @@ var getComponentWithCheckbox = function getComponentWithCheckbox() {
|
|
152
160
|
}));
|
153
161
|
})));
|
154
162
|
};
|
163
|
+
var ComponentOnPrevLoad = function ComponentOnPrevLoad() {
|
164
|
+
var _context, _context2;
|
165
|
+
var initialItems = (0, _map["default"])(_context = (0, _fill["default"])(_context2 = new Array(10)).call(_context2, {
|
166
|
+
key: 'string',
|
167
|
+
name: 'string'
|
168
|
+
})).call(_context, function (_item, index) {
|
169
|
+
return {
|
170
|
+
name: "name: ".concat(index),
|
171
|
+
key: "name: ".concat(index),
|
172
|
+
id: index
|
173
|
+
};
|
174
|
+
});
|
175
|
+
var _useState = (0, _react.useState)(initialItems),
|
176
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
177
|
+
listItems = _useState2[0],
|
178
|
+
setListItems = _useState2[1];
|
179
|
+
var onLoadMore = /*#__PURE__*/function () {
|
180
|
+
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
181
|
+
return _regeneratorRuntime().wrap(function _callee$(_context3) {
|
182
|
+
while (1) switch (_context3.prev = _context3.next) {
|
183
|
+
case 0:
|
184
|
+
onLoadMoreFunc();
|
185
|
+
case 1:
|
186
|
+
case "end":
|
187
|
+
return _context3.stop();
|
188
|
+
}
|
189
|
+
}, _callee);
|
190
|
+
}));
|
191
|
+
return function onLoadMore() {
|
192
|
+
return _ref5.apply(this, arguments);
|
193
|
+
};
|
194
|
+
}();
|
195
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
196
|
+
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
197
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context4) {
|
198
|
+
while (1) switch (_context4.prev = _context4.next) {
|
199
|
+
case 0:
|
200
|
+
onLoadPrevFunc();
|
201
|
+
case 1:
|
202
|
+
case "end":
|
203
|
+
return _context4.stop();
|
204
|
+
}
|
205
|
+
}, _callee2);
|
206
|
+
}));
|
207
|
+
return function onLoadPrev() {
|
208
|
+
return _ref6.apply(this, arguments);
|
209
|
+
};
|
210
|
+
}();
|
211
|
+
return (0, _react2.jsx)(_ListView["default"], (0, _extends2["default"])({}, defaultProps, {
|
212
|
+
items: listItems,
|
213
|
+
onLoadMore: onLoadMore,
|
214
|
+
onLoadPrev: onLoadPrev
|
215
|
+
}), function (item) {
|
216
|
+
return (0, _react2.jsx)(_reactStately.Item, {
|
217
|
+
key: item.key,
|
218
|
+
textValue: item.name,
|
219
|
+
"data-id": item.key
|
220
|
+
}, (0, _react2.jsx)("h1", {
|
221
|
+
key: item.key,
|
222
|
+
"data-testid": item.name
|
223
|
+
}, item.name));
|
224
|
+
});
|
225
|
+
};
|
155
226
|
|
156
227
|
// Needs to be added to each components test file
|
157
228
|
(0, _universalComponentTest.universalComponentTests)({
|
@@ -175,10 +246,10 @@ test('renders listview component', function () {
|
|
175
246
|
var listView = _testWrapper.screen.getByTestId(testId);
|
176
247
|
expect(listView).toBeInTheDocument();
|
177
248
|
});
|
178
|
-
test('navigating the list using the keyboard causes the isSelected and isFocused state to change', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
249
|
+
test('navigating the list using the keyboard causes the isSelected and isFocused state to change', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
179
250
|
var listView, options, updatedOption;
|
180
|
-
return _regeneratorRuntime().wrap(function
|
181
|
-
while (1) switch (
|
251
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context5) {
|
252
|
+
while (1) switch (_context5.prev = _context5.next) {
|
182
253
|
case 0:
|
183
254
|
getComponent();
|
184
255
|
listView = _testWrapper.screen.getByTestId(testId); // Open the list arrow down to the second option,
|
@@ -192,21 +263,21 @@ test('navigating the list using the keyboard causes the isSelected and isFocused
|
|
192
263
|
_userEvent["default"].type(listView, '{enter}', {
|
193
264
|
skipClick: true
|
194
265
|
});
|
195
|
-
|
266
|
+
_context5.next = 9;
|
196
267
|
return _testWrapper.screen.findAllByRole('gridcell');
|
197
268
|
case 9:
|
198
|
-
updatedOption =
|
269
|
+
updatedOption = _context5.sent;
|
199
270
|
expect(updatedOption[1]).toHaveClass('is-selected');
|
200
271
|
case 11:
|
201
272
|
case "end":
|
202
|
-
return
|
273
|
+
return _context5.stop();
|
203
274
|
}
|
204
|
-
},
|
275
|
+
}, _callee3);
|
205
276
|
})));
|
206
|
-
test('navigating to a disabled key will not apply the isFocused class', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
277
|
+
test('navigating to a disabled key will not apply the isFocused class', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
207
278
|
var listView, options;
|
208
|
-
return _regeneratorRuntime().wrap(function
|
209
|
-
while (1) switch (
|
279
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context6) {
|
280
|
+
while (1) switch (_context6.prev = _context6.next) {
|
210
281
|
case 0:
|
211
282
|
getComponent({
|
212
283
|
disabledKeys: ['Kangaroo']
|
@@ -221,14 +292,14 @@ test('navigating to a disabled key will not apply the isFocused class', /*#__PUR
|
|
221
292
|
expect(options[1]).not.toHaveClass('is-focused');
|
222
293
|
case 6:
|
223
294
|
case "end":
|
224
|
-
return
|
295
|
+
return _context6.stop();
|
225
296
|
}
|
226
|
-
},
|
297
|
+
}, _callee4);
|
227
298
|
})));
|
228
|
-
test('navigating to a disabled key will not apply the isFocused class', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
299
|
+
test('navigating to a disabled key will not apply the isFocused class', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
229
300
|
var listView, options;
|
230
|
-
return _regeneratorRuntime().wrap(function
|
231
|
-
while (1) switch (
|
301
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context7) {
|
302
|
+
while (1) switch (_context7.prev = _context7.next) {
|
232
303
|
case 0:
|
233
304
|
getComponent({
|
234
305
|
selectionMode: 'expansion',
|
@@ -244,33 +315,33 @@ test('navigating to a disabled key will not apply the isFocused class', /*#__PUR
|
|
244
315
|
expect(options[1]).not.toHaveClass('is-focused');
|
245
316
|
case 6:
|
246
317
|
case "end":
|
247
|
-
return
|
318
|
+
return _context7.stop();
|
248
319
|
}
|
249
|
-
},
|
320
|
+
}, _callee5);
|
250
321
|
})));
|
251
|
-
test('clicking an item on the list selects the item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
322
|
+
test('clicking an item on the list selects the item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
252
323
|
var options, updatedOption;
|
253
|
-
return _regeneratorRuntime().wrap(function
|
254
|
-
while (1) switch (
|
324
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
325
|
+
while (1) switch (_context8.prev = _context8.next) {
|
255
326
|
case 0:
|
256
327
|
getComponent();
|
257
328
|
options = _testWrapper.screen.getByTestId(items[1].name);
|
258
329
|
_userEvent["default"].click(options);
|
259
|
-
|
330
|
+
_context8.next = 5;
|
260
331
|
return _testWrapper.screen.findAllByRole('gridcell');
|
261
332
|
case 5:
|
262
|
-
updatedOption =
|
333
|
+
updatedOption = _context8.sent;
|
263
334
|
expect(updatedOption[1]).toHaveClass('is-selected');
|
264
335
|
case 7:
|
265
336
|
case "end":
|
266
|
-
return
|
337
|
+
return _context8.stop();
|
267
338
|
}
|
268
|
-
},
|
339
|
+
}, _callee6);
|
269
340
|
})));
|
270
|
-
test('clicking an item fires "onSelectionChange" handler and returns Set with keys of items', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
341
|
+
test('clicking an item fires "onSelectionChange" handler and returns Set with keys of items', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
271
342
|
var expectedResult, onSelectionChange, option1, selectedItems;
|
272
|
-
return _regeneratorRuntime().wrap(function
|
273
|
-
while (1) switch (
|
343
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
344
|
+
while (1) switch (_context9.prev = _context9.next) {
|
274
345
|
case 0:
|
275
346
|
expectedResult = new _set["default"]();
|
276
347
|
expectedResult.add(items[1].key);
|
@@ -285,9 +356,9 @@ test('clicking an item fires "onSelectionChange" handler and returns Set with ke
|
|
285
356
|
expect(_lodash["default"].isEqual(expectedResult, selectedItems)).toBeTruthy();
|
286
357
|
case 9:
|
287
358
|
case "end":
|
288
|
-
return
|
359
|
+
return _context9.stop();
|
289
360
|
}
|
290
|
-
},
|
361
|
+
}, _callee7);
|
291
362
|
})));
|
292
363
|
test('renders loader, if a loader component is passed in, and state is loading', function () {
|
293
364
|
getComponent({
|
@@ -296,6 +367,13 @@ test('renders loader, if a loader component is passed in, and state is loading',
|
|
296
367
|
var loader = _testWrapper.screen.getByRole('alert');
|
297
368
|
expect(loader).toBeInTheDocument();
|
298
369
|
});
|
370
|
+
test('renders top loader, if a loader component is passed in, and state is loading', function () {
|
371
|
+
getComponent({
|
372
|
+
loadingState: _loadingStates["default"].LOADING
|
373
|
+
});
|
374
|
+
var loader = _testWrapper.screen.getByRole('alert');
|
375
|
+
expect(loader).toBeInTheDocument();
|
376
|
+
});
|
299
377
|
test('renders loader, if a loader component is passed in, and state is loading', function () {
|
300
378
|
getComponent({
|
301
379
|
loadingState: _loadingStates["default"].LOADING
|
@@ -332,31 +410,31 @@ test('Item accepts a data-id and the data-id can be found in the DOM', function
|
|
332
410
|
expect(options).toHaveLength(items.length);
|
333
411
|
expect(options[0]).toHaveAttribute('data-id', items[0].name);
|
334
412
|
});
|
335
|
-
test('selectionMode "none" disallows to select item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
413
|
+
test('selectionMode "none" disallows to select item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
336
414
|
var option1, updatedOption;
|
337
|
-
return _regeneratorRuntime().wrap(function
|
338
|
-
while (1) switch (
|
415
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
416
|
+
while (1) switch (_context10.prev = _context10.next) {
|
339
417
|
case 0:
|
340
418
|
getComponent({
|
341
419
|
selectionMode: 'none'
|
342
420
|
});
|
343
421
|
option1 = _testWrapper.screen.getByTestId(items[1].name);
|
344
422
|
_userEvent["default"].click(option1);
|
345
|
-
|
423
|
+
_context10.next = 5;
|
346
424
|
return _testWrapper.screen.findAllByRole('gridcell');
|
347
425
|
case 5:
|
348
|
-
updatedOption =
|
426
|
+
updatedOption = _context10.sent;
|
349
427
|
expect(updatedOption[1]).not.toHaveClass('is-selected');
|
350
428
|
case 7:
|
351
429
|
case "end":
|
352
|
-
return
|
430
|
+
return _context10.stop();
|
353
431
|
}
|
354
|
-
},
|
432
|
+
}, _callee8);
|
355
433
|
})));
|
356
|
-
test('selectionMode "multiple" allows to select more than one item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
434
|
+
test('selectionMode "multiple" allows to select more than one item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
357
435
|
var option1, option2, updatedOption;
|
358
|
-
return _regeneratorRuntime().wrap(function
|
359
|
-
while (1) switch (
|
436
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
437
|
+
while (1) switch (_context11.prev = _context11.next) {
|
360
438
|
case 0:
|
361
439
|
getComponent({
|
362
440
|
selectionMode: 'multiple'
|
@@ -365,22 +443,22 @@ test('selectionMode "multiple" allows to select more than one item', /*#__PURE__
|
|
365
443
|
_userEvent["default"].click(option1);
|
366
444
|
option2 = _testWrapper.screen.getByTestId(items[2].name);
|
367
445
|
_userEvent["default"].click(option2);
|
368
|
-
|
446
|
+
_context11.next = 7;
|
369
447
|
return _testWrapper.screen.findAllByRole('gridcell');
|
370
448
|
case 7:
|
371
|
-
updatedOption =
|
449
|
+
updatedOption = _context11.sent;
|
372
450
|
expect(updatedOption[1]).toHaveClass('is-selected');
|
373
451
|
expect(updatedOption[2]).toHaveClass('is-selected');
|
374
452
|
case 10:
|
375
453
|
case "end":
|
376
|
-
return
|
454
|
+
return _context11.stop();
|
377
455
|
}
|
378
|
-
},
|
456
|
+
}, _callee9);
|
379
457
|
})));
|
380
|
-
test('when user navigates with tab and arrows keys, onFocus is called and the is-focused class is applied', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
458
|
+
test('when user navigates with tab and arrows keys, onFocus is called and the is-focused class is applied', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
381
459
|
var onFocus, listView, options;
|
382
|
-
return _regeneratorRuntime().wrap(function
|
383
|
-
while (1) switch (
|
460
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
461
|
+
while (1) switch (_context12.prev = _context12.next) {
|
384
462
|
case 0:
|
385
463
|
onFocus = jest.fn();
|
386
464
|
getComponent({
|
@@ -397,9 +475,9 @@ test('when user navigates with tab and arrows keys, onFocus is called and the is
|
|
397
475
|
expect(onFocus).toHaveBeenCalled();
|
398
476
|
case 9:
|
399
477
|
case "end":
|
400
|
-
return
|
478
|
+
return _context12.stop();
|
401
479
|
}
|
402
|
-
},
|
480
|
+
}, _callee10);
|
403
481
|
})));
|
404
482
|
test('list view not receive focus when click on checkbox', function () {
|
405
483
|
getComponentWithCheckbox();
|
@@ -427,10 +505,10 @@ test('list view reset hover on item when scroll', function () {
|
|
427
505
|
_userEvent["default"].hover(listItem[1]);
|
428
506
|
expect(listItem[0]).not.toHaveClass('is-hovered');
|
429
507
|
});
|
430
|
-
test('list view expandable reset hover on item when scroll', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
508
|
+
test('list view expandable reset hover on item when scroll', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
431
509
|
var listItem, listRow;
|
432
|
-
return _regeneratorRuntime().wrap(function
|
433
|
-
while (1) switch (
|
510
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
511
|
+
while (1) switch (_context13.prev = _context13.next) {
|
434
512
|
case 0:
|
435
513
|
getComponentExpandable({
|
436
514
|
selectionMode: 'expansion'
|
@@ -444,9 +522,9 @@ test('list view expandable reset hover on item when scroll', /*#__PURE__*/(0, _a
|
|
444
522
|
expect(listItem[0]).not.toHaveClass('is-hovered');
|
445
523
|
case 7:
|
446
524
|
case "end":
|
447
|
-
return
|
525
|
+
return _context13.stop();
|
448
526
|
}
|
449
|
-
},
|
527
|
+
}, _callee11);
|
450
528
|
})));
|
451
529
|
test('list view item should not receive focus when selectionMode is "none"', function () {
|
452
530
|
var onFocus = jest.fn();
|
@@ -469,10 +547,10 @@ test('list view item should receive focus when selectionMode is default or a val
|
|
469
547
|
expect(onFocus).toHaveBeenCalled();
|
470
548
|
expect(options[0]).toHaveClass('is-focused');
|
471
549
|
});
|
472
|
-
test('selectionMode "expanded" cells render expandable list items, and can be expanded, and collapsed', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
550
|
+
test('selectionMode "expanded" cells render expandable list items, and can be expanded, and collapsed', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
473
551
|
var options, updatedOptions, updatedOptions1;
|
474
|
-
return _regeneratorRuntime().wrap(function
|
475
|
-
while (1) switch (
|
552
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
553
|
+
while (1) switch (_context14.prev = _context14.next) {
|
476
554
|
case 0:
|
477
555
|
getComponent({
|
478
556
|
selectionMode: 'expansion'
|
@@ -480,27 +558,27 @@ test('selectionMode "expanded" cells render expandable list items, and can be ex
|
|
480
558
|
options = _testWrapper.screen.getAllByRole('gridcell');
|
481
559
|
expect(options[0]).toHaveAttribute('aria-expanded', 'false');
|
482
560
|
_userEvent["default"].click(options[0]);
|
483
|
-
|
561
|
+
_context14.next = 6;
|
484
562
|
return _testWrapper.screen.findAllByRole('gridcell');
|
485
563
|
case 6:
|
486
|
-
updatedOptions =
|
564
|
+
updatedOptions = _context14.sent;
|
487
565
|
expect(updatedOptions[0]).toHaveAttribute('aria-expanded', 'true');
|
488
566
|
_userEvent["default"].click(options[0]);
|
489
|
-
|
567
|
+
_context14.next = 11;
|
490
568
|
return _testWrapper.screen.findAllByRole('gridcell');
|
491
569
|
case 11:
|
492
|
-
updatedOptions1 =
|
570
|
+
updatedOptions1 = _context14.sent;
|
493
571
|
expect(updatedOptions1[0]).toHaveAttribute('aria-expanded', 'false');
|
494
572
|
case 13:
|
495
573
|
case "end":
|
496
|
-
return
|
574
|
+
return _context14.stop();
|
497
575
|
}
|
498
|
-
},
|
576
|
+
}, _callee12);
|
499
577
|
})));
|
500
|
-
test('should navigate to expandable listitems with keyboard ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
578
|
+
test('should navigate to expandable listitems with keyboard ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
501
579
|
var option, row, focusContainer, button;
|
502
|
-
return _regeneratorRuntime().wrap(function
|
503
|
-
while (1) switch (
|
580
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
581
|
+
while (1) switch (_context15.prev = _context15.next) {
|
504
582
|
case 0:
|
505
583
|
getComponentExpandable({
|
506
584
|
selectionMode: 'expansion'
|
@@ -531,24 +609,24 @@ test('should navigate to expandable listitems with keyboard ', /*#__PURE__*/(0,
|
|
531
609
|
_userEvent["default"].type(focusContainer, '{enter}', {
|
532
610
|
skipClick: true
|
533
611
|
});
|
534
|
-
|
612
|
+
_context15.next = 15;
|
535
613
|
return _testWrapper.screen.findByRole('button');
|
536
614
|
case 15:
|
537
|
-
button =
|
615
|
+
button = _context15.sent;
|
538
616
|
expect(button).toHaveClass('is-focused');
|
539
617
|
_userEvent["default"].type(row, '{esc}', {
|
540
618
|
skipClick: true
|
541
619
|
});
|
542
620
|
case 18:
|
543
621
|
case "end":
|
544
|
-
return
|
622
|
+
return _context15.stop();
|
545
623
|
}
|
546
|
-
},
|
624
|
+
}, _callee13);
|
547
625
|
})));
|
548
|
-
test('should navigate to expandable container ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
626
|
+
test('should navigate to expandable container ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
549
627
|
var option;
|
550
|
-
return _regeneratorRuntime().wrap(function
|
551
|
-
while (1) switch (
|
628
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
629
|
+
while (1) switch (_context16.prev = _context16.next) {
|
552
630
|
case 0:
|
553
631
|
getComponentExpandable({
|
554
632
|
selectionMode: 'expansion'
|
@@ -593,9 +671,9 @@ test('should navigate to expandable container ', /*#__PURE__*/(0, _asyncToGenera
|
|
593
671
|
});
|
594
672
|
case 17:
|
595
673
|
case "end":
|
596
|
-
return
|
674
|
+
return _context16.stop();
|
597
675
|
}
|
598
|
-
},
|
676
|
+
}, _callee14);
|
599
677
|
})));
|
600
678
|
test('escape focus delegate turns on if enter is pressed', function () {
|
601
679
|
(0, _ListViewFocusWrapper.escapeFocusDelegate)(_objectSpread(_objectSpread({}, testEvent), {}, {
|
@@ -640,4 +718,20 @@ test('escape focus delegate calls correct functions if anything else is pressed'
|
|
640
718
|
}), setIsFocusEscaped, focusManager, true);
|
641
719
|
expect(focusNext).not.toHaveBeenCalled();
|
642
720
|
expect(focusPrevious).not.toHaveBeenCalled();
|
721
|
+
});
|
722
|
+
test('escape focus delegate calls correct functions if anything else is pressed', function () {
|
723
|
+
(0, _testWrapper.render)((0, _react2.jsx)(ComponentOnPrevLoad, null));
|
724
|
+
var listView = _testWrapper.screen.getAllByRole('grid');
|
725
|
+
_testWrapper.fireEvent.scroll(listView[0], {
|
726
|
+
target: {
|
727
|
+
scrollY: 450
|
728
|
+
}
|
729
|
+
});
|
730
|
+
expect(onLoadMoreFunc).toHaveBeenCalled();
|
731
|
+
_testWrapper.fireEvent.scroll(listView[0], {
|
732
|
+
target: {
|
733
|
+
scrollY: 0
|
734
|
+
}
|
735
|
+
});
|
736
|
+
expect(onLoadPrevFunc).toHaveBeenCalled();
|
643
737
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useLoadPrev';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
_Object$defineProperty(exports, "default", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function get() {
|
11
|
+
return _useLoadPrev["default"];
|
12
|
+
}
|
13
|
+
});
|
14
|
+
var _useLoadPrev = _interopRequireDefault(require("./useLoadPrev"));
|
@@ -0,0 +1,35 @@
|
|
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
|
+
});
|
7
|
+
exports["default"] = void 0;
|
8
|
+
var _react = require("react");
|
9
|
+
var _utils = require("@react-aria/utils");
|
10
|
+
var useLoadPrev = function useLoadPrev(props, ref) {
|
11
|
+
var isLoading = props.isLoading,
|
12
|
+
onLoadPrev = props.onLoadPrev,
|
13
|
+
items = props.items;
|
14
|
+
var isLoadingRef = (0, _react.useRef)(isLoading);
|
15
|
+
var prevProps = (0, _react.useRef)(props);
|
16
|
+
var onScroll = (0, _react.useCallback)(function () {
|
17
|
+
if (ref.current && !isLoadingRef.current && onLoadPrev) {
|
18
|
+
var rc = ref.current;
|
19
|
+
var shouldLoadPrev = rc.scrollTop === 0;
|
20
|
+
if (shouldLoadPrev) {
|
21
|
+
isLoadingRef.current = true;
|
22
|
+
onLoadPrev();
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}, [onLoadPrev, ref]);
|
26
|
+
(0, _react.useLayoutEffect)(function () {
|
27
|
+
if (props !== prevProps.current) {
|
28
|
+
isLoadingRef.current = isLoading;
|
29
|
+
prevProps.current = props;
|
30
|
+
}
|
31
|
+
}, [isLoading, onLoadPrev, props, ref, items]);
|
32
|
+
(0, _utils.useEvent)(ref, 'scroll', onScroll);
|
33
|
+
};
|
34
|
+
var _default = useLoadPrev;
|
35
|
+
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|