@pingux/astro 2.98.0-alpha.0 → 2.98.0-alpha.2
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/ListBox/ListBox.js +17 -2
- 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/components/MultivaluesField/DefaultMultivaluesField.js +14 -1
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +147 -5
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +104 -16
- 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/listBox.d.ts +3 -1
- package/lib/cjs/types/listView.d.ts +1 -0
- package/lib/cjs/utils/devUtils/constants/loadingStates.js +2 -1
- package/lib/components/ListBox/ListBox.js +17 -2
- 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/components/MultivaluesField/DefaultMultivaluesField.js +14 -1
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +144 -2
- package/lib/components/MultivaluesField/MultivaluesField.test.js +100 -16
- 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
@@ -6,14 +6,29 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
6
6
|
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
7
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
10
|
+
import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
|
11
|
+
import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
|
12
|
+
import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
|
13
|
+
import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
|
14
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
15
|
+
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
16
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
9
17
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
10
18
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
19
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
20
|
+
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; }
|
21
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
22
|
+
import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
|
23
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
24
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
25
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
12
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; }
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
27
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context11, _context12; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(source), !0)).call(_context11, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context12 = ownKeys(Object(source))).call(_context12, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
14
28
|
import React, { useState } from 'react';
|
15
29
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
16
30
|
import { Box, Icon, Item, MultivaluesField, OverlayProvider, Section } from '../../index';
|
31
|
+
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
17
32
|
import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
|
18
33
|
import { inputFieldAttributeBaseArgTypes } from '../../utils/docUtils/fieldAttributes';
|
19
34
|
import { statusArgTypes } from '../../utils/docUtils/statusProp';
|
@@ -404,7 +419,7 @@ export var Controlled = function Controlled(args) {
|
|
404
419
|
}, item.name);
|
405
420
|
}));
|
406
421
|
};
|
407
|
-
|
422
|
+
var _Error = function Error(args) {
|
408
423
|
var _useState9 = useState(false),
|
409
424
|
_useState10 = _slicedToArray(_useState9, 2),
|
410
425
|
isOpen = _useState10[0],
|
@@ -430,6 +445,7 @@ export var Error = function Error(args) {
|
|
430
445
|
}, item.name);
|
431
446
|
}));
|
432
447
|
};
|
448
|
+
export { _Error as Error };
|
433
449
|
export var ReadOnlyField = function ReadOnlyField(args) {
|
434
450
|
var _useState11 = useState(false),
|
435
451
|
_useState12 = _slicedToArray(_useState11, 2),
|
@@ -650,4 +666,130 @@ export var CondensedWithSection = function CondensedWithSection(args) {
|
|
650
666
|
}, item.name);
|
651
667
|
});
|
652
668
|
}));
|
669
|
+
};
|
670
|
+
export var OnLoadPrev = function OnLoadPrev() {
|
671
|
+
var _context, _context2;
|
672
|
+
var initialItems = _mapInstanceProperty(_context = _fillInstanceProperty(_context2 = new Array(10)).call(_context2, {
|
673
|
+
key: 'string',
|
674
|
+
name: 'string'
|
675
|
+
})).call(_context, function (_, index) {
|
676
|
+
return {
|
677
|
+
name: "name: ".concat(index),
|
678
|
+
key: "name: ".concat(index),
|
679
|
+
id: index
|
680
|
+
};
|
681
|
+
});
|
682
|
+
var _useState27 = useState(0),
|
683
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
684
|
+
minNum = _useState28[0],
|
685
|
+
setMinNum = _useState28[1];
|
686
|
+
var _useState29 = useState(10),
|
687
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
688
|
+
maxNum = _useState30[0],
|
689
|
+
setMaxNum = _useState30[1];
|
690
|
+
var _useState31 = useState(initialItems),
|
691
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
692
|
+
listItems = _useState32[0],
|
693
|
+
setListItems = _useState32[1];
|
694
|
+
var _useState33 = useState(false),
|
695
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
696
|
+
isOpen = _useState34[0],
|
697
|
+
setIsOpen = _useState34[1];
|
698
|
+
var _useState35 = useState(loadingStates.IDLE),
|
699
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
700
|
+
loadingState = _useState36[0],
|
701
|
+
setLoadingState = _useState36[1];
|
702
|
+
var onOpenChange = function onOpenChange() {
|
703
|
+
setIsOpen(true);
|
704
|
+
};
|
705
|
+
var onLoadMore = /*#__PURE__*/function () {
|
706
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
707
|
+
var _context3, _context4, _context5;
|
708
|
+
var newItems;
|
709
|
+
return _regeneratorRuntime().wrap(function _callee$(_context6) {
|
710
|
+
while (1) switch (_context6.prev = _context6.next) {
|
711
|
+
case 0:
|
712
|
+
setLoadingState(loadingStates.LOADING_MORE);
|
713
|
+
_context6.next = 3;
|
714
|
+
return new _Promise(function (resolve) {
|
715
|
+
return _setTimeout(resolve, 3000);
|
716
|
+
});
|
717
|
+
case 3:
|
718
|
+
newItems = _mapInstanceProperty(_context3 = _fillInstanceProperty(_context4 = new Array(10)).call(_context4, {
|
719
|
+
key: 'string',
|
720
|
+
name: 'string'
|
721
|
+
})).call(_context3, function (_, index) {
|
722
|
+
return {
|
723
|
+
name: "name: ".concat(maxNum + index),
|
724
|
+
key: "name: ".concat(maxNum + index),
|
725
|
+
id: maxNum + index
|
726
|
+
};
|
727
|
+
});
|
728
|
+
setMaxNum(maxNum + 10);
|
729
|
+
setListItems(_concatInstanceProperty(_context5 = []).call(_context5, listItems, newItems));
|
730
|
+
setLoadingState(loadingStates.IDLE);
|
731
|
+
case 7:
|
732
|
+
case "end":
|
733
|
+
return _context6.stop();
|
734
|
+
}
|
735
|
+
}, _callee);
|
736
|
+
}));
|
737
|
+
return function onLoadMore() {
|
738
|
+
return _ref.apply(this, arguments);
|
739
|
+
};
|
740
|
+
}();
|
741
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
742
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
743
|
+
var _context7, _context8, _context9;
|
744
|
+
var newItems;
|
745
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context10) {
|
746
|
+
while (1) switch (_context10.prev = _context10.next) {
|
747
|
+
case 0:
|
748
|
+
setLoadingState(loadingStates.LOADING_MORE_PREPEND);
|
749
|
+
_context10.next = 3;
|
750
|
+
return new _Promise(function (resolve) {
|
751
|
+
return _setTimeout(resolve, 3000);
|
752
|
+
});
|
753
|
+
case 3:
|
754
|
+
newItems = _mapInstanceProperty(_context7 = _fillInstanceProperty(_context8 = new Array(10)).call(_context8, {
|
755
|
+
key: 'string',
|
756
|
+
name: 'string'
|
757
|
+
})).call(_context7, function (_, index) {
|
758
|
+
return {
|
759
|
+
name: "name: ".concat(minNum - (index + 1)),
|
760
|
+
key: "name: ".concat(minNum - (index + 1)),
|
761
|
+
id: minNum - (index + 1)
|
762
|
+
};
|
763
|
+
});
|
764
|
+
setMinNum(minNum - 10);
|
765
|
+
setListItems(_concatInstanceProperty(_context9 = []).call(_context9, newItems, listItems));
|
766
|
+
setLoadingState(loadingStates.IDLE);
|
767
|
+
case 7:
|
768
|
+
case "end":
|
769
|
+
return _context10.stop();
|
770
|
+
}
|
771
|
+
}, _callee2);
|
772
|
+
}));
|
773
|
+
return function onLoadPrev() {
|
774
|
+
return _ref2.apply(this, arguments);
|
775
|
+
};
|
776
|
+
}();
|
777
|
+
return ___EmotionJSX(OverlayProvider
|
778
|
+
// note: spacing for demo purpose only so that the select list renders in the correct place
|
779
|
+
, {
|
780
|
+
style: setOverlayStyle('bottom', isOpen, '50%', '50%', '20%')
|
781
|
+
}, ___EmotionJSX(MultivaluesField, {
|
782
|
+
items: listItems,
|
783
|
+
onOpenChange: onOpenChange,
|
784
|
+
onLoadMore: onLoadMore,
|
785
|
+
onLoadPrev: onLoadPrev,
|
786
|
+
loadingState: loadingState,
|
787
|
+
label: "On Load More & Prev"
|
788
|
+
}, function (item) {
|
789
|
+
return ___EmotionJSX(Item, {
|
790
|
+
key: item.key,
|
791
|
+
"data-id": item.name,
|
792
|
+
"aria-label": item.name
|
793
|
+
}, item.name);
|
794
|
+
}));
|
653
795
|
};
|
@@ -8,11 +8,14 @@ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
8
8
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
9
9
|
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
10
10
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
11
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
12
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
13
|
+
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; }
|
14
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
15
|
+
import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
|
12
16
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
13
17
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
14
|
-
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 _context3; _forEachInstanceProperty(_context3 = ["next", "throw", "return"]).call(_context3, 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 _context4; 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(_context4 = this.tryEntries).call(_context4, 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; }
|
15
|
-
import React from 'react';
|
18
|
+
import React, { useState } from 'react';
|
16
19
|
import userEvent from '@testing-library/user-event';
|
17
20
|
import { Item, MultivaluesField, OverlayProvider, Section } from '../../index';
|
18
21
|
import statuses from '../../utils/devUtils/constants/statuses';
|
@@ -59,6 +62,8 @@ var defaultSectionProps = {
|
|
59
62
|
items: withSection,
|
60
63
|
label: 'Field Label'
|
61
64
|
};
|
65
|
+
var onLoadMoreFunc = jest.fn();
|
66
|
+
var onLoadPrevFunc = jest.fn();
|
62
67
|
var getComponent = function getComponent() {
|
63
68
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
64
69
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
@@ -104,6 +109,68 @@ var getSectionsComponent = function getSectionsComponent() {
|
|
104
109
|
});
|
105
110
|
})));
|
106
111
|
};
|
112
|
+
var ComponentOnPrevLoad = function ComponentOnPrevLoad() {
|
113
|
+
var _context, _context2;
|
114
|
+
var initialItems = _mapInstanceProperty(_context = _fillInstanceProperty(_context2 = new Array(10)).call(_context2, {
|
115
|
+
key: 'string',
|
116
|
+
name: 'string'
|
117
|
+
})).call(_context, function (_item, index) {
|
118
|
+
return {
|
119
|
+
name: "name: ".concat(index),
|
120
|
+
key: "name: ".concat(index),
|
121
|
+
id: index
|
122
|
+
};
|
123
|
+
});
|
124
|
+
// eslint-disable-next-line no-unused-vars
|
125
|
+
var _useState = useState(initialItems),
|
126
|
+
_useState2 = _slicedToArray(_useState, 2),
|
127
|
+
listItems = _useState2[0],
|
128
|
+
setListItems = _useState2[1];
|
129
|
+
var onLoadMore = /*#__PURE__*/function () {
|
130
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
131
|
+
return _regeneratorRuntime().wrap(function _callee$(_context3) {
|
132
|
+
while (1) switch (_context3.prev = _context3.next) {
|
133
|
+
case 0:
|
134
|
+
onLoadMoreFunc();
|
135
|
+
case 1:
|
136
|
+
case "end":
|
137
|
+
return _context3.stop();
|
138
|
+
}
|
139
|
+
}, _callee);
|
140
|
+
}));
|
141
|
+
return function onLoadMore() {
|
142
|
+
return _ref4.apply(this, arguments);
|
143
|
+
};
|
144
|
+
}();
|
145
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
146
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
147
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context4) {
|
148
|
+
while (1) switch (_context4.prev = _context4.next) {
|
149
|
+
case 0:
|
150
|
+
onLoadPrevFunc();
|
151
|
+
case 1:
|
152
|
+
case "end":
|
153
|
+
return _context4.stop();
|
154
|
+
}
|
155
|
+
}, _callee2);
|
156
|
+
}));
|
157
|
+
return function onLoadPrev() {
|
158
|
+
return _ref5.apply(this, arguments);
|
159
|
+
};
|
160
|
+
}();
|
161
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(MultivaluesField, {
|
162
|
+
items: listItems,
|
163
|
+
label: "Field Label",
|
164
|
+
onLoadMore: onLoadMore,
|
165
|
+
onLoadPrev: onLoadPrev
|
166
|
+
}, function (item) {
|
167
|
+
return ___EmotionJSX(Item, {
|
168
|
+
key: item.key,
|
169
|
+
"data-id": item.name,
|
170
|
+
"aria-label": item.name
|
171
|
+
}, item.name);
|
172
|
+
}));
|
173
|
+
};
|
107
174
|
beforeAll(function () {
|
108
175
|
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
109
176
|
return 1000;
|
@@ -263,10 +330,10 @@ test('no badges are rendered, if nothing is selected', function () {
|
|
263
330
|
});
|
264
331
|
expect(screen.queryByRole('presentation')).not.toBeInTheDocument(0);
|
265
332
|
});
|
266
|
-
test('after clicking an option, and then typing a custom input, the listbox remains open and filters the options', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
333
|
+
test('after clicking an option, and then typing a custom input, the listbox remains open and filters the options', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
267
334
|
var input, options, firstOption, value, listbox, filteredOptions;
|
268
|
-
return _regeneratorRuntime().wrap(function
|
269
|
-
while (1) switch (
|
335
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context5) {
|
336
|
+
while (1) switch (_context5.prev = _context5.next) {
|
270
337
|
case 0:
|
271
338
|
getComponent({
|
272
339
|
mode: 'non-restrictive'
|
@@ -280,11 +347,11 @@ test('after clicking an option, and then typing a custom input, the listbox rema
|
|
280
347
|
firstOption.click();
|
281
348
|
});
|
282
349
|
expect(firstOption).not.toBeInTheDocument();
|
283
|
-
|
350
|
+
_context5.next = 10;
|
284
351
|
return userEvent.clear(input);
|
285
352
|
case 10:
|
286
353
|
value = 'ka';
|
287
|
-
|
354
|
+
_context5.next = 13;
|
288
355
|
return userEvent.type(input, value);
|
289
356
|
case 13:
|
290
357
|
listbox = screen.queryByRole('listbox');
|
@@ -293,9 +360,9 @@ test('after clicking an option, and then typing a custom input, the listbox rema
|
|
293
360
|
expect(filteredOptions.length).toBe(1);
|
294
361
|
case 17:
|
295
362
|
case "end":
|
296
|
-
return
|
363
|
+
return _context5.stop();
|
297
364
|
}
|
298
|
-
},
|
365
|
+
}, _callee3);
|
299
366
|
})));
|
300
367
|
test('clicking on delete button deletes selection, and re-adds option to list', function () {
|
301
368
|
getComponent();
|
@@ -397,10 +464,10 @@ test('in non-restrictive mode, a badge gets added if there is only one matching
|
|
397
464
|
expect(badgeContainer).toHaveAttribute('role', 'presentation');
|
398
465
|
expect(firstOption).not.toBeInTheDocument();
|
399
466
|
});
|
400
|
-
test('dropdown with options reappears after entering a custom input', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
467
|
+
test('dropdown with options reappears after entering a custom input', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
401
468
|
var input, value1, value2, listbox, options2;
|
402
|
-
return _regeneratorRuntime().wrap(function
|
403
|
-
while (1) switch (
|
469
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context6) {
|
470
|
+
while (1) switch (_context6.prev = _context6.next) {
|
404
471
|
case 0:
|
405
472
|
getComponent({
|
406
473
|
mode: 'non-restrictive'
|
@@ -410,10 +477,10 @@ test('dropdown with options reappears after entering a custom input', /*#__PURE_
|
|
410
477
|
userEvent.type(input, value1);
|
411
478
|
expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
|
412
479
|
value2 = '';
|
413
|
-
|
480
|
+
_context6.next = 8;
|
414
481
|
return userEvent.clear(input);
|
415
482
|
case 8:
|
416
|
-
|
483
|
+
_context6.next = 10;
|
417
484
|
return userEvent.type(input, value2);
|
418
485
|
case 10:
|
419
486
|
listbox = screen.getByRole('listbox');
|
@@ -421,9 +488,9 @@ test('dropdown with options reappears after entering a custom input', /*#__PURE_
|
|
421
488
|
expect(options2.length).toBe(items.length);
|
422
489
|
case 13:
|
423
490
|
case "end":
|
424
|
-
return
|
491
|
+
return _context6.stop();
|
425
492
|
}
|
426
|
-
},
|
493
|
+
}, _callee4);
|
427
494
|
})));
|
428
495
|
test('changing the input value and hitting enter by default do nothing', function () {
|
429
496
|
getComponent();
|
@@ -1028,6 +1095,23 @@ test('should render the separators', function () {
|
|
1028
1095
|
}
|
1029
1096
|
});
|
1030
1097
|
});
|
1098
|
+
test('escape focus delegate calls correct functions if anything else is pressed', function () {
|
1099
|
+
render(___EmotionJSX(ComponentOnPrevLoad, null));
|
1100
|
+
userEvent.tab();
|
1101
|
+
var listBox = screen.getAllByRole('listbox');
|
1102
|
+
fireEvent.scroll(listBox[0], {
|
1103
|
+
target: {
|
1104
|
+
scrollY: 450
|
1105
|
+
}
|
1106
|
+
});
|
1107
|
+
expect(onLoadMoreFunc).toHaveBeenCalled();
|
1108
|
+
fireEvent.scroll(listBox[0], {
|
1109
|
+
target: {
|
1110
|
+
scrollY: 0
|
1111
|
+
}
|
1112
|
+
});
|
1113
|
+
expect(onLoadPrevFunc).toHaveBeenCalled();
|
1114
|
+
});
|
1031
1115
|
|
1032
1116
|
// Needs to be added to each components test file
|
1033
1117
|
universalComponentTests({
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useLoadPrev';
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef } from 'react';
|
2
|
+
import { useEvent } from '@react-aria/utils';
|
3
|
+
var useLoadPrev = function useLoadPrev(props, ref) {
|
4
|
+
var isLoading = props.isLoading,
|
5
|
+
onLoadPrev = props.onLoadPrev,
|
6
|
+
items = props.items;
|
7
|
+
var isLoadingRef = useRef(isLoading);
|
8
|
+
var prevProps = useRef(props);
|
9
|
+
var onScroll = useCallback(function () {
|
10
|
+
if (ref.current && !isLoadingRef.current && onLoadPrev) {
|
11
|
+
var rc = ref.current;
|
12
|
+
var shouldLoadPrev = rc.scrollTop === 0;
|
13
|
+
if (shouldLoadPrev) {
|
14
|
+
isLoadingRef.current = true;
|
15
|
+
onLoadPrev();
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}, [onLoadPrev, ref]);
|
19
|
+
useLayoutEffect(function () {
|
20
|
+
if (props !== prevProps.current) {
|
21
|
+
isLoadingRef.current = isLoading;
|
22
|
+
prevProps.current = props;
|
23
|
+
}
|
24
|
+
}, [isLoading, onLoadPrev, props, ref, items]);
|
25
|
+
useEvent(ref, 'scroll', onScroll);
|
26
|
+
};
|
27
|
+
export default useLoadPrev;
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import React, { useRef } from 'react';
|
2
|
+
import { fireEvent } from '@testing-library/react';
|
3
|
+
import Box from '../../components/Box';
|
4
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
+
import useLoadPrev from './useLoadPrev';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
var onLoadPrev = jest.fn();
|
8
|
+
var TestComponent = function TestComponent(props) {
|
9
|
+
var items = props.items;
|
10
|
+
var ref = useRef(null);
|
11
|
+
useLoadPrev({
|
12
|
+
isLoading: false,
|
13
|
+
onLoadPrev: onLoadPrev,
|
14
|
+
items: items
|
15
|
+
}, ref);
|
16
|
+
return ___EmotionJSX(Box, {
|
17
|
+
sx: {
|
18
|
+
height: '400px',
|
19
|
+
maxHeight: '400px',
|
20
|
+
overflowY: 'scroll'
|
21
|
+
},
|
22
|
+
"data-testid": "outerbox",
|
23
|
+
ref: ref
|
24
|
+
}, "content", ___EmotionJSX(Box, {
|
25
|
+
sx: {
|
26
|
+
height: '800px',
|
27
|
+
minHeight: '800px'
|
28
|
+
},
|
29
|
+
"data-testid": "innerbox"
|
30
|
+
}, "inner content"));
|
31
|
+
};
|
32
|
+
describe('useLoadPrev', function () {
|
33
|
+
it('onLoadPrev is called when scrolling to the top', function () {
|
34
|
+
var _render = render(___EmotionJSX(TestComponent, {
|
35
|
+
items: [1, 2, 3, 4]
|
36
|
+
})),
|
37
|
+
rerender = _render.rerender;
|
38
|
+
var listView = screen.getByTestId('outerbox');
|
39
|
+
fireEvent.scroll(listView, {
|
40
|
+
target: {
|
41
|
+
scrollY: 450
|
42
|
+
}
|
43
|
+
});
|
44
|
+
fireEvent.scroll(listView, {
|
45
|
+
target: {
|
46
|
+
scrollY: 0
|
47
|
+
}
|
48
|
+
});
|
49
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(1);
|
50
|
+
// should not call because props have not changed
|
51
|
+
fireEvent.scroll(listView, {
|
52
|
+
target: {
|
53
|
+
scrollY: 450
|
54
|
+
}
|
55
|
+
});
|
56
|
+
fireEvent.scroll(listView, {
|
57
|
+
target: {
|
58
|
+
scrollY: 0
|
59
|
+
}
|
60
|
+
});
|
61
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(1);
|
62
|
+
// will call becuase props have changed.
|
63
|
+
rerender(___EmotionJSX(TestComponent, {
|
64
|
+
items: [1, 2, 3, 4, 5]
|
65
|
+
}));
|
66
|
+
fireEvent.scroll(listView, {
|
67
|
+
target: {
|
68
|
+
scrollY: 450
|
69
|
+
}
|
70
|
+
});
|
71
|
+
fireEvent.scroll(listView, {
|
72
|
+
target: {
|
73
|
+
scrollY: 0
|
74
|
+
}
|
75
|
+
});
|
76
|
+
expect(onLoadPrev).toHaveBeenCalledTimes(2);
|
77
|
+
});
|
78
|
+
});
|