@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
@@ -5,7 +5,7 @@ import { VirtualizerItemOptions } from '@react-aria/virtualizer';
|
|
5
5
|
import { ReusableView } from '@react-stately/virtualizer';
|
6
6
|
import type { CollectionChildren, FocusStrategy } from '@react-types/shared';
|
7
7
|
import { BoxProps } from './box';
|
8
|
-
import { StyleProps } from './shared';
|
8
|
+
import { loadingState, StyleProps } from './shared';
|
9
9
|
export interface ComboBoxStateType extends ComboBoxState<object> {
|
10
10
|
focusStrategy: FocusStrategy;
|
11
11
|
}
|
@@ -24,7 +24,9 @@ export interface ListBoxProps extends AriaListBoxOptions<object> {
|
|
24
24
|
isLoading?: boolean;
|
25
25
|
isFocusedOnHover?: boolean;
|
26
26
|
isSelectedOnPressUp?: boolean;
|
27
|
+
loadingState?: loadingState;
|
27
28
|
onLoadMore?: () => void;
|
29
|
+
onLoadPrev?: () => void;
|
28
30
|
onScroll?: () => void;
|
29
31
|
state: ListBoxStateType;
|
30
32
|
renderEmptyState?: React.ReactNode;
|
@@ -12,6 +12,7 @@ export interface ListViewProps extends Omit<TreeProps<ExampleItemProps>, 'select
|
|
12
12
|
selectionMode?: SelectionOptions;
|
13
13
|
onFocus?: (event: any) => void;
|
14
14
|
onLoadMore?: () => void;
|
15
|
+
onLoadPrev?: () => void;
|
15
16
|
'aria-label'?: string;
|
16
17
|
containerProps?: object;
|
17
18
|
sx?: ThemeUICSSObject;
|
@@ -8,7 +8,7 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
8
8
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
11
|
-
var _excluded = ["defaultSelectedKeys", "disabledKeys", "hasAutoFocus", "hasFocusWrap", "hasNoEmptySelection", "hasVirtualFocus", "id", "isCondensed", "isLoading", "isFocusedOnHover", "isSelectedOnPressUp", "isVirtualized", "items", "keyboardDelegate", "label", "onLoadMore", "onScroll", "onSelectionChange", "renderEmptyState", "selectedKeys", "selectionMode", "state", "aria-label", "aria-labelledby", "aria-describedby", "aria-details"];
|
11
|
+
var _excluded = ["defaultSelectedKeys", "disabledKeys", "hasAutoFocus", "hasFocusWrap", "hasNoEmptySelection", "hasVirtualFocus", "id", "isCondensed", "isLoading", "isFocusedOnHover", "isSelectedOnPressUp", "isVirtualized", "items", "keyboardDelegate", "label", "loadingState", "onLoadMore", "onLoadPrev", "onScroll", "onSelectionChange", "renderEmptyState", "selectedKeys", "selectionMode", "state", "aria-label", "aria-labelledby", "aria-describedby", "aria-details"];
|
12
12
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
13
13
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
14
14
|
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; }
|
@@ -20,6 +20,8 @@ import { useListBox } from '@react-aria/listbox';
|
|
20
20
|
import { ListLayout } from 'listbox-layout';
|
21
21
|
import { Virtualizer, VirtualizerItem } from 'listbox-virtualizer';
|
22
22
|
import { useLocalOrForwardRef } from '../../hooks';
|
23
|
+
import useLoadPrev from '../../hooks/useLoadPrev';
|
24
|
+
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
23
25
|
import Box from '../Box';
|
24
26
|
import Loader from '../Loader';
|
25
27
|
import { Option } from './index';
|
@@ -67,7 +69,9 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
69
|
items = props.items,
|
68
70
|
keyboardDelegate = props.keyboardDelegate,
|
69
71
|
label = props.label,
|
72
|
+
loadingState = props.loadingState,
|
70
73
|
onLoadMore = props.onLoadMore,
|
74
|
+
onLoadPrev = props.onLoadPrev,
|
71
75
|
onScroll = props.onScroll,
|
72
76
|
onSelectionChange = props.onSelectionChange,
|
73
77
|
renderEmptyState = props.renderEmptyState,
|
@@ -139,11 +143,22 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
139
143
|
parent: parent
|
140
144
|
});
|
141
145
|
};
|
146
|
+
var memoedLoadMoreProps = useMemo(function () {
|
147
|
+
return {
|
148
|
+
isLoading: isLoading,
|
149
|
+
onLoadPrev: onLoadPrev,
|
150
|
+
items: items
|
151
|
+
};
|
152
|
+
}, [isLoading, onLoadPrev, items]);
|
153
|
+
useLoadPrev(memoedLoadMoreProps, listBoxRef);
|
142
154
|
return ___EmotionJSX(ListBoxContext.Provider, {
|
143
155
|
value: state
|
144
156
|
}, ___EmotionJSX(Box, {
|
145
157
|
variant: "listBox.container"
|
146
|
-
},
|
158
|
+
}, loadingState === loadingStates.LOADING_MORE_PREPEND && ___EmotionJSX(Loader, {
|
159
|
+
variant: "loader.withinListbox",
|
160
|
+
"aria-label": "Loading more..."
|
161
|
+
}), ___EmotionJSX(Virtualizer, _extends({}, mergeProps(listBoxProps, others), {
|
147
162
|
autoFocus: hasAutoFocus,
|
148
163
|
style: {
|
149
164
|
outline: 'none'
|
@@ -10,7 +10,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
11
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
12
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
|
-
var _excluded = ["containerProps", "disabledKeys", "isHoverable", "loadingState", "onLoadMore", "onSelectionChange", "onExpandedChange", "expandedKeys", "selectedKeys", "selectionMode", "selectionStyle", "items", "onFocus"];
|
13
|
+
var _excluded = ["containerProps", "disabledKeys", "isHoverable", "loadingState", "onLoadMore", "onLoadPrev", "onSelectionChange", "onExpandedChange", "expandedKeys", "selectedKeys", "selectionMode", "selectionStyle", "items", "onFocus"];
|
14
14
|
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; }
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
16
16
|
import React, { forwardRef, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
@@ -19,6 +19,7 @@ import { useTreeState } from 'react-stately';
|
|
19
19
|
import { useCollator } from '@react-aria/i18n';
|
20
20
|
import { Virtualizer, VirtualizerItem } from '@react-aria/virtualizer';
|
21
21
|
import { ListLayout } from '@react-stately/layout';
|
22
|
+
import useLoadPrev from '../../hooks/useLoadPrev';
|
22
23
|
import { Box } from '../../index';
|
23
24
|
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
24
25
|
import Loader from '../Loader';
|
@@ -57,6 +58,7 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
58
|
isHoverable = _props$isHoverable === void 0 ? true : _props$isHoverable,
|
58
59
|
loadingState = props.loadingState,
|
59
60
|
onLoadMore = props.onLoadMore,
|
61
|
+
onLoadPrev = props.onLoadPrev,
|
60
62
|
onSelectionChange = props.onSelectionChange,
|
61
63
|
onExpandedChange = props.onExpandedChange,
|
62
64
|
expandedKeys = props.expandedKeys,
|
@@ -123,13 +125,24 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
123
125
|
var resetHoverState = function resetHoverState() {
|
124
126
|
state.hover.setHoveredItem(null);
|
125
127
|
};
|
128
|
+
var memoedLoadMoreProps = useMemo(function () {
|
129
|
+
return {
|
130
|
+
isLoading: isLoading,
|
131
|
+
onLoadPrev: onLoadPrev,
|
132
|
+
items: items
|
133
|
+
};
|
134
|
+
}, [isLoading, onLoadPrev, items]);
|
135
|
+
useLoadPrev(memoedLoadMoreProps, listViewRef);
|
126
136
|
return ___EmotionJSX(ListViewContext.Provider, {
|
127
137
|
value: {
|
128
138
|
state: state
|
129
139
|
}
|
130
140
|
}, ___EmotionJSX(Box, _extends({
|
131
141
|
variant: "listView.container"
|
132
|
-
}, containerProps),
|
142
|
+
}, containerProps), loadingState === loadingStates.LOADING_MORE_PREPEND && ___EmotionJSX(Loader, {
|
143
|
+
variant: "loader.withinListView",
|
144
|
+
"aria-label": "Loading more..."
|
145
|
+
}), ___EmotionJSX(Virtualizer, _extends({}, items ? gridProps : {
|
133
146
|
role: 'presentation'
|
134
147
|
}, {
|
135
148
|
onLoadMore: onLoadMore,
|
@@ -19,7 +19,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
19
19
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
20
20
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
21
21
|
var _excluded = ["string", "secondString"];
|
22
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context6; _forEachInstanceProperty(_context6 = ["next", "throw", "return"]).call(_context6, 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 _context7; 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(_context7 = this.tryEntries).call(_context7, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
22
|
+
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 _context16; _forEachInstanceProperty(_context16 = ["next", "throw", "return"]).call(_context16, 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 _context17; 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(_context17 = this.tryEntries).call(_context17, 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; }
|
23
23
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
24
24
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
25
25
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
@@ -27,8 +27,10 @@ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
27
27
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
28
28
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
29
29
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
30
|
+
import _fillInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/fill";
|
31
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
30
32
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
31
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
33
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context14, _context15; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context14 = ownKeys(Object(source), !0)).call(_context14, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context15 = ownKeys(Object(source))).call(_context15, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
32
34
|
import React, { useRef, useState } from 'react';
|
33
35
|
import { Item, useAsyncList } from 'react-stately';
|
34
36
|
import FormSelectIcon from '@pingux/mdi-react/FormSelectIcon';
|
@@ -37,6 +39,7 @@ import { action } from '@storybook/addon-actions';
|
|
37
39
|
import isChromatic from 'chromatic/isChromatic';
|
38
40
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
39
41
|
import { Badge, Box, Button, HelpHint, Icon, IconButton, ListView, ListViewItem, ListViewItemChart, ListViewItemMenu, ListViewItemSwitchField, Text, TextField } from '../..';
|
42
|
+
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
40
43
|
import { chartData } from '../ListViewItem/controls/chart/chartData';
|
41
44
|
import ListViewReadme from './ListView.mdx';
|
42
45
|
import { listViewArgTypes } from './listViewAttributes';
|
@@ -883,4 +886,124 @@ export var WithCharts = function WithCharts(_ref9) {
|
|
883
886
|
ariaLabel: item.name
|
884
887
|
}), ___EmotionJSX(Controls, null)));
|
885
888
|
});
|
889
|
+
};
|
890
|
+
export var OnLoadPrev = function OnLoadPrev() {
|
891
|
+
var _context4, _context5;
|
892
|
+
var initialItems = _mapInstanceProperty(_context4 = _fillInstanceProperty(_context5 = new Array(10)).call(_context5, {
|
893
|
+
key: 'string',
|
894
|
+
name: 'string'
|
895
|
+
})).call(_context4, function (_, index) {
|
896
|
+
return {
|
897
|
+
name: "name: ".concat(index),
|
898
|
+
key: "name: ".concat(index),
|
899
|
+
id: index
|
900
|
+
};
|
901
|
+
});
|
902
|
+
var _useState3 = useState(0),
|
903
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
904
|
+
minNum = _useState4[0],
|
905
|
+
setMinNum = _useState4[1];
|
906
|
+
var _useState5 = useState(10),
|
907
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
908
|
+
maxNum = _useState6[0],
|
909
|
+
setMaxNum = _useState6[1];
|
910
|
+
var _useState7 = useState(initialItems),
|
911
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
912
|
+
listItems = _useState8[0],
|
913
|
+
setListItems = _useState8[1];
|
914
|
+
var _useState9 = useState(loadingStates.IDLE),
|
915
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
916
|
+
loadingState = _useState10[0],
|
917
|
+
setLoadingState = _useState10[1];
|
918
|
+
var onLoadMore = /*#__PURE__*/function () {
|
919
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
920
|
+
var _context6, _context7, _context8;
|
921
|
+
var newItems;
|
922
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context9) {
|
923
|
+
while (1) switch (_context9.prev = _context9.next) {
|
924
|
+
case 0:
|
925
|
+
setLoadingState(loadingStates.LOADING_MORE);
|
926
|
+
_context9.next = 3;
|
927
|
+
return new _Promise(function (resolve) {
|
928
|
+
return _setTimeout(resolve, 3000);
|
929
|
+
});
|
930
|
+
case 3:
|
931
|
+
newItems = _mapInstanceProperty(_context6 = _fillInstanceProperty(_context7 = new Array(10)).call(_context7, {
|
932
|
+
key: 'string',
|
933
|
+
name: 'string'
|
934
|
+
})).call(_context6, function (_, index) {
|
935
|
+
return {
|
936
|
+
name: "name: ".concat(maxNum + index),
|
937
|
+
key: "name: ".concat(maxNum + index),
|
938
|
+
id: maxNum + index
|
939
|
+
};
|
940
|
+
});
|
941
|
+
setMaxNum(maxNum + 10);
|
942
|
+
setListItems(_concatInstanceProperty(_context8 = []).call(_context8, listItems, newItems));
|
943
|
+
setLoadingState(loadingStates.IDLE);
|
944
|
+
case 7:
|
945
|
+
case "end":
|
946
|
+
return _context9.stop();
|
947
|
+
}
|
948
|
+
}, _callee4);
|
949
|
+
}));
|
950
|
+
return function onLoadMore() {
|
951
|
+
return _ref10.apply(this, arguments);
|
952
|
+
};
|
953
|
+
}();
|
954
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
955
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
956
|
+
var _context10, _context11, _context12;
|
957
|
+
var newItems;
|
958
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context13) {
|
959
|
+
while (1) switch (_context13.prev = _context13.next) {
|
960
|
+
case 0:
|
961
|
+
setLoadingState(loadingStates.LOADING_MORE_PREPEND);
|
962
|
+
_context13.next = 3;
|
963
|
+
return new _Promise(function (resolve) {
|
964
|
+
return _setTimeout(resolve, 3000);
|
965
|
+
});
|
966
|
+
case 3:
|
967
|
+
newItems = _mapInstanceProperty(_context10 = _fillInstanceProperty(_context11 = new Array(10)).call(_context11, {
|
968
|
+
key: 'string',
|
969
|
+
name: 'string'
|
970
|
+
})).call(_context10, function (_, index) {
|
971
|
+
return {
|
972
|
+
name: "name: ".concat(minNum - (index + 1)),
|
973
|
+
key: "name: ".concat(minNum - (index + 1)),
|
974
|
+
id: minNum - (index + 1)
|
975
|
+
};
|
976
|
+
});
|
977
|
+
setMinNum(minNum - 10);
|
978
|
+
setListItems(_concatInstanceProperty(_context12 = []).call(_context12, newItems, listItems));
|
979
|
+
setLoadingState(loadingStates.IDLE);
|
980
|
+
case 7:
|
981
|
+
case "end":
|
982
|
+
return _context13.stop();
|
983
|
+
}
|
984
|
+
}, _callee5);
|
985
|
+
}));
|
986
|
+
return function onLoadPrev() {
|
987
|
+
return _ref11.apply(this, arguments);
|
988
|
+
};
|
989
|
+
}();
|
990
|
+
return ___EmotionJSX(Box, {
|
991
|
+
sx: {
|
992
|
+
height: '400px'
|
993
|
+
}
|
994
|
+
}, ___EmotionJSX(ListView, _extends({}, actions, {
|
995
|
+
items: listItems,
|
996
|
+
loadingState: loadingState,
|
997
|
+
onLoadMore: onLoadMore,
|
998
|
+
onLoadPrev: onLoadPrev
|
999
|
+
}), function (item) {
|
1000
|
+
return ___EmotionJSX(Item, {
|
1001
|
+
key: item.name
|
1002
|
+
}, ___EmotionJSX(ListViewItem, {
|
1003
|
+
data: {
|
1004
|
+
text: item.name,
|
1005
|
+
icon: FormSelectIcon
|
1006
|
+
}
|
1007
|
+
}, ___EmotionJSX(Controls, null)));
|
1008
|
+
}));
|
886
1009
|
};
|