@pingux/astro 2.98.0-alpha.1 → 2.98.0
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/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/types/listBox.d.ts +3 -1
- package/lib/components/ListBox/ListBox.js +17 -2
- 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/package.json +1 -1
@@ -28,13 +28,15 @@ var _listbox = require("@react-aria/listbox");
|
|
28
28
|
var _listboxLayout = require("listbox-layout");
|
29
29
|
var _listboxVirtualizer = require("listbox-virtualizer");
|
30
30
|
var _hooks = require("../../hooks");
|
31
|
+
var _useLoadPrev = _interopRequireDefault(require("../../hooks/useLoadPrev"));
|
32
|
+
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
31
33
|
var _Box = _interopRequireDefault(require("../Box"));
|
32
34
|
var _Loader = _interopRequireDefault(require("../Loader"));
|
33
35
|
var _index = require("./index");
|
34
36
|
var _ListBoxContext = require("./ListBoxContext");
|
35
37
|
var _ListBoxSection = _interopRequireDefault(require("./ListBoxSection"));
|
36
38
|
var _react2 = require("@emotion/react");
|
37
|
-
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"];
|
39
|
+
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"];
|
38
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
39
41
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
40
42
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -81,7 +83,9 @@ var ListBox = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
81
83
|
items = props.items,
|
82
84
|
keyboardDelegate = props.keyboardDelegate,
|
83
85
|
label = props.label,
|
86
|
+
loadingState = props.loadingState,
|
84
87
|
onLoadMore = props.onLoadMore,
|
88
|
+
onLoadPrev = props.onLoadPrev,
|
85
89
|
onScroll = props.onScroll,
|
86
90
|
onSelectionChange = props.onSelectionChange,
|
87
91
|
renderEmptyState = props.renderEmptyState,
|
@@ -153,11 +157,22 @@ var ListBox = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
153
157
|
parent: parent
|
154
158
|
});
|
155
159
|
};
|
160
|
+
var memoedLoadMoreProps = (0, _react.useMemo)(function () {
|
161
|
+
return {
|
162
|
+
isLoading: isLoading,
|
163
|
+
onLoadPrev: onLoadPrev,
|
164
|
+
items: items
|
165
|
+
};
|
166
|
+
}, [isLoading, onLoadPrev, items]);
|
167
|
+
(0, _useLoadPrev["default"])(memoedLoadMoreProps, listBoxRef);
|
156
168
|
return (0, _react2.jsx)(_ListBoxContext.ListBoxContext.Provider, {
|
157
169
|
value: state
|
158
170
|
}, (0, _react2.jsx)(_Box["default"], {
|
159
171
|
variant: "listBox.container"
|
160
|
-
},
|
172
|
+
}, loadingState === _loadingStates["default"].LOADING_MORE_PREPEND && (0, _react2.jsx)(_Loader["default"], {
|
173
|
+
variant: "loader.withinListbox",
|
174
|
+
"aria-label": "Loading more..."
|
175
|
+
}), (0, _react2.jsx)(_listboxVirtualizer.Virtualizer, (0, _extends2["default"])({}, (0, _reactAria.mergeProps)(listBoxProps, others), {
|
161
176
|
autoFocus: hasAutoFocus,
|
162
177
|
style: {
|
163
178
|
outline: 'none'
|
@@ -39,6 +39,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
39
39
|
var _ = require("../..");
|
40
40
|
var _MultivaluesContext = require("../../context/MultivaluesContext");
|
41
41
|
var _hooks = require("../../hooks");
|
42
|
+
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
42
43
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
43
44
|
var _isIterable = require("../../utils/devUtils/props/isIterable");
|
44
45
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
@@ -46,7 +47,7 @@ var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
46
47
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
47
48
|
var _ListBox = _interopRequireDefault(require("../ListBox"));
|
48
49
|
var _react2 = require("@emotion/react");
|
49
|
-
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "readOnlyKeys", "selectedKeys", "scrollBoxProps", "status"];
|
50
|
+
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "loadingState", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onLoadMore", "onLoadPrev", "onOpenChange", "onSelectionChange", "placeholder", "readOnlyKeys", "selectedKeys", "scrollBoxProps", "status"];
|
50
51
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
51
52
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
52
53
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -68,12 +69,15 @@ var DefaultMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (prop
|
|
68
69
|
isRequired = props.isRequired,
|
69
70
|
initialItems = props.items,
|
70
71
|
label = props.label,
|
72
|
+
loadingState = props.loadingState,
|
71
73
|
mode = props.mode,
|
72
74
|
_onBlur = props.onBlur,
|
73
75
|
_onFocus = props.onFocus,
|
74
76
|
onInputChange = props.onInputChange,
|
75
77
|
onKeyDown = props.onKeyDown,
|
76
78
|
_onKeyUp = props.onKeyUp,
|
79
|
+
onLoadMore = props.onLoadMore,
|
80
|
+
onLoadPrev = props.onLoadPrev,
|
77
81
|
onOpenChange = props.onOpenChange,
|
78
82
|
onSelectionChange = props.onSelectionChange,
|
79
83
|
placeholder = props.placeholder,
|
@@ -105,6 +109,11 @@ var DefaultMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (prop
|
|
105
109
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
106
110
|
activeDescendant = _useState10[0],
|
107
111
|
setActiveDescendant = _useState10[1];
|
112
|
+
(0, _react.useEffect)(function () {
|
113
|
+
if (mode !== 'non-restrictive') {
|
114
|
+
setItems(initialItems);
|
115
|
+
}
|
116
|
+
}, [initialItems]);
|
108
117
|
var toggleItems = function toggleItems(keys) {
|
109
118
|
setItems((0, _filter["default"])(initialItems).call(initialItems, function (item) {
|
110
119
|
var _context;
|
@@ -412,6 +421,10 @@ var DefaultMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (prop
|
|
412
421
|
hasVirtualFocus: true,
|
413
422
|
hasNoEmptySelection: true,
|
414
423
|
state: state,
|
424
|
+
onLoadMore: onLoadMore,
|
425
|
+
onLoadPrev: onLoadPrev,
|
426
|
+
loadingState: loadingState,
|
427
|
+
isLoading: loadingState === _loadingStates["default"].LOADING_MORE,
|
415
428
|
"aria-label": "List of options"
|
416
429
|
})), (0, _react2.jsx)(_reactAria.DismissButton, {
|
417
430
|
onDismiss: close
|
@@ -9,18 +9,32 @@ var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/in
|
|
9
9
|
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
10
10
|
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
11
11
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
12
|
+
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
13
|
+
var _Object$create = require("@babel/runtime-corejs3/core-js-stable/object/create");
|
14
|
+
var _Object$getPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
|
15
|
+
var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
|
16
|
+
var _Promise2 = require("@babel/runtime-corejs3/core-js-stable/promise");
|
17
|
+
var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
|
18
|
+
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
12
19
|
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
13
20
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
14
21
|
_Object$defineProperty(exports, "__esModule", {
|
15
22
|
value: true
|
16
23
|
});
|
17
|
-
exports["default"] = exports.Uncontrolled = exports.ReadOnlyValues = exports.ReadOnlyField = exports.IconSlotsInBadge = exports.Error = exports.DisabledKeys = exports.Default = exports.CustomValues = exports.CustomSize = exports.Controlled = exports.CondensedWithSection = exports.Condensed = void 0;
|
24
|
+
exports["default"] = exports.Uncontrolled = exports.ReadOnlyValues = exports.ReadOnlyField = exports.OnLoadPrev = exports.IconSlotsInBadge = exports.Error = exports.DisabledKeys = exports.Default = exports.CustomValues = exports.CustomSize = exports.Controlled = exports.CondensedWithSection = exports.Condensed = void 0;
|
25
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
26
|
+
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
27
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
28
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
29
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
30
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
18
31
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
19
32
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
20
33
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
21
34
|
var _react = _interopRequireWildcard(require("react"));
|
22
35
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
23
36
|
var _index = require("../../index");
|
37
|
+
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
24
38
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
25
39
|
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
26
40
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
@@ -28,8 +42,9 @@ var _MultivaluesField = _interopRequireDefault(require("./MultivaluesField.mdx")
|
|
28
42
|
var _react2 = require("@emotion/react");
|
29
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
30
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
45
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _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 = _Promise2); 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; }
|
31
46
|
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; }
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
47
|
+
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) { (0, _defineProperty2["default"])(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; }
|
33
48
|
var _default = {
|
34
49
|
title: 'Form/MultivaluesField',
|
35
50
|
component: _index.MultivaluesField,
|
@@ -419,7 +434,7 @@ var Controlled = function Controlled(args) {
|
|
419
434
|
}));
|
420
435
|
};
|
421
436
|
exports.Controlled = Controlled;
|
422
|
-
var
|
437
|
+
var _Error = function Error(args) {
|
423
438
|
var _useState9 = (0, _react.useState)(false),
|
424
439
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
425
440
|
isOpen = _useState10[0],
|
@@ -445,7 +460,7 @@ var Error = function Error(args) {
|
|
445
460
|
}, item.name);
|
446
461
|
}));
|
447
462
|
};
|
448
|
-
exports.Error =
|
463
|
+
exports.Error = _Error;
|
449
464
|
var ReadOnlyField = function ReadOnlyField(args) {
|
450
465
|
var _useState11 = (0, _react.useState)(false),
|
451
466
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
@@ -674,4 +689,131 @@ var CondensedWithSection = function CondensedWithSection(args) {
|
|
674
689
|
});
|
675
690
|
}));
|
676
691
|
};
|
677
|
-
exports.CondensedWithSection = CondensedWithSection;
|
692
|
+
exports.CondensedWithSection = CondensedWithSection;
|
693
|
+
var OnLoadPrev = function OnLoadPrev() {
|
694
|
+
var _context, _context2;
|
695
|
+
var initialItems = (0, _map["default"])(_context = (0, _fill["default"])(_context2 = new Array(10)).call(_context2, {
|
696
|
+
key: 'string',
|
697
|
+
name: 'string'
|
698
|
+
})).call(_context, function (_, index) {
|
699
|
+
return {
|
700
|
+
name: "name: ".concat(index),
|
701
|
+
key: "name: ".concat(index),
|
702
|
+
id: index
|
703
|
+
};
|
704
|
+
});
|
705
|
+
var _useState27 = (0, _react.useState)(0),
|
706
|
+
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
707
|
+
minNum = _useState28[0],
|
708
|
+
setMinNum = _useState28[1];
|
709
|
+
var _useState29 = (0, _react.useState)(10),
|
710
|
+
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
711
|
+
maxNum = _useState30[0],
|
712
|
+
setMaxNum = _useState30[1];
|
713
|
+
var _useState31 = (0, _react.useState)(initialItems),
|
714
|
+
_useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
|
715
|
+
listItems = _useState32[0],
|
716
|
+
setListItems = _useState32[1];
|
717
|
+
var _useState33 = (0, _react.useState)(false),
|
718
|
+
_useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
|
719
|
+
isOpen = _useState34[0],
|
720
|
+
setIsOpen = _useState34[1];
|
721
|
+
var _useState35 = (0, _react.useState)(_loadingStates["default"].IDLE),
|
722
|
+
_useState36 = (0, _slicedToArray2["default"])(_useState35, 2),
|
723
|
+
loadingState = _useState36[0],
|
724
|
+
setLoadingState = _useState36[1];
|
725
|
+
var onOpenChange = function onOpenChange() {
|
726
|
+
setIsOpen(true);
|
727
|
+
};
|
728
|
+
var onLoadMore = /*#__PURE__*/function () {
|
729
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
730
|
+
var _context3, _context4, _context5;
|
731
|
+
var newItems;
|
732
|
+
return _regeneratorRuntime().wrap(function _callee$(_context6) {
|
733
|
+
while (1) switch (_context6.prev = _context6.next) {
|
734
|
+
case 0:
|
735
|
+
setLoadingState(_loadingStates["default"].LOADING_MORE);
|
736
|
+
_context6.next = 3;
|
737
|
+
return new _promise["default"](function (resolve) {
|
738
|
+
return (0, _setTimeout2["default"])(resolve, 3000);
|
739
|
+
});
|
740
|
+
case 3:
|
741
|
+
newItems = (0, _map["default"])(_context3 = (0, _fill["default"])(_context4 = new Array(10)).call(_context4, {
|
742
|
+
key: 'string',
|
743
|
+
name: 'string'
|
744
|
+
})).call(_context3, function (_, index) {
|
745
|
+
return {
|
746
|
+
name: "name: ".concat(maxNum + index),
|
747
|
+
key: "name: ".concat(maxNum + index),
|
748
|
+
id: maxNum + index
|
749
|
+
};
|
750
|
+
});
|
751
|
+
setMaxNum(maxNum + 10);
|
752
|
+
setListItems((0, _concat["default"])(_context5 = []).call(_context5, listItems, newItems));
|
753
|
+
setLoadingState(_loadingStates["default"].IDLE);
|
754
|
+
case 7:
|
755
|
+
case "end":
|
756
|
+
return _context6.stop();
|
757
|
+
}
|
758
|
+
}, _callee);
|
759
|
+
}));
|
760
|
+
return function onLoadMore() {
|
761
|
+
return _ref.apply(this, arguments);
|
762
|
+
};
|
763
|
+
}();
|
764
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
765
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
766
|
+
var _context7, _context8, _context9;
|
767
|
+
var newItems;
|
768
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context10) {
|
769
|
+
while (1) switch (_context10.prev = _context10.next) {
|
770
|
+
case 0:
|
771
|
+
setLoadingState(_loadingStates["default"].LOADING_MORE_PREPEND);
|
772
|
+
_context10.next = 3;
|
773
|
+
return new _promise["default"](function (resolve) {
|
774
|
+
return (0, _setTimeout2["default"])(resolve, 3000);
|
775
|
+
});
|
776
|
+
case 3:
|
777
|
+
newItems = (0, _map["default"])(_context7 = (0, _fill["default"])(_context8 = new Array(10)).call(_context8, {
|
778
|
+
key: 'string',
|
779
|
+
name: 'string'
|
780
|
+
})).call(_context7, function (_, index) {
|
781
|
+
return {
|
782
|
+
name: "name: ".concat(minNum - (index + 1)),
|
783
|
+
key: "name: ".concat(minNum - (index + 1)),
|
784
|
+
id: minNum - (index + 1)
|
785
|
+
};
|
786
|
+
});
|
787
|
+
setMinNum(minNum - 10);
|
788
|
+
setListItems((0, _concat["default"])(_context9 = []).call(_context9, newItems, listItems));
|
789
|
+
setLoadingState(_loadingStates["default"].IDLE);
|
790
|
+
case 7:
|
791
|
+
case "end":
|
792
|
+
return _context10.stop();
|
793
|
+
}
|
794
|
+
}, _callee2);
|
795
|
+
}));
|
796
|
+
return function onLoadPrev() {
|
797
|
+
return _ref2.apply(this, arguments);
|
798
|
+
};
|
799
|
+
}();
|
800
|
+
return (0, _react2.jsx)(_index.OverlayProvider
|
801
|
+
// note: spacing for demo purpose only so that the select list renders in the correct place
|
802
|
+
, {
|
803
|
+
style: setOverlayStyle('bottom', isOpen, '50%', '50%', '20%')
|
804
|
+
}, (0, _react2.jsx)(_index.MultivaluesField, {
|
805
|
+
items: listItems,
|
806
|
+
onOpenChange: onOpenChange,
|
807
|
+
onLoadMore: onLoadMore,
|
808
|
+
onLoadPrev: onLoadPrev,
|
809
|
+
loadingState: loadingState,
|
810
|
+
label: "On Load More & Prev"
|
811
|
+
}, function (item) {
|
812
|
+
return (0, _react2.jsx)(_index.Item, {
|
813
|
+
key: item.key,
|
814
|
+
"data-id": item.name,
|
815
|
+
"aria-label": item.name
|
816
|
+
}, item.name);
|
817
|
+
}));
|
818
|
+
};
|
819
|
+
exports.OnLoadPrev = OnLoadPrev;
|
@@ -10,19 +10,26 @@ var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/obje
|
|
10
10
|
var _Promise = require("@babel/runtime-corejs3/core-js-stable/promise");
|
11
11
|
var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
|
12
12
|
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
13
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
14
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
13
15
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
16
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
17
|
+
var _fill = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/fill"));
|
14
18
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
15
19
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
16
20
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
21
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
17
22
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
18
|
-
var _react =
|
23
|
+
var _react = _interopRequireWildcard(require("react"));
|
19
24
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
20
25
|
var _index = require("../../index");
|
21
26
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
22
27
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
23
28
|
var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
|
24
29
|
var _react2 = require("@emotion/react");
|
25
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context3; _forEachInstanceProperty2(_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" }], _forEachInstanceProperty2(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, _forEachInstanceProperty2(_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; }
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
31
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
32
|
+
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; _forEachInstanceProperty2(_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" }], _forEachInstanceProperty2(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, _forEachInstanceProperty2(_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; }
|
26
33
|
var items = [{
|
27
34
|
id: 1,
|
28
35
|
name: 'Aardvark',
|
@@ -63,6 +70,8 @@ var defaultSectionProps = {
|
|
63
70
|
items: withSection,
|
64
71
|
label: 'Field Label'
|
65
72
|
};
|
73
|
+
var onLoadMoreFunc = jest.fn();
|
74
|
+
var onLoadPrevFunc = jest.fn();
|
66
75
|
var getComponent = function getComponent() {
|
67
76
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
68
77
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
@@ -108,6 +117,68 @@ var getSectionsComponent = function getSectionsComponent() {
|
|
108
117
|
});
|
109
118
|
})));
|
110
119
|
};
|
120
|
+
var ComponentOnPrevLoad = function ComponentOnPrevLoad() {
|
121
|
+
var _context, _context2;
|
122
|
+
var initialItems = (0, _map["default"])(_context = (0, _fill["default"])(_context2 = new Array(10)).call(_context2, {
|
123
|
+
key: 'string',
|
124
|
+
name: 'string'
|
125
|
+
})).call(_context, function (_item, index) {
|
126
|
+
return {
|
127
|
+
name: "name: ".concat(index),
|
128
|
+
key: "name: ".concat(index),
|
129
|
+
id: index
|
130
|
+
};
|
131
|
+
});
|
132
|
+
// eslint-disable-next-line no-unused-vars
|
133
|
+
var _useState = (0, _react.useState)(initialItems),
|
134
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
135
|
+
listItems = _useState2[0],
|
136
|
+
setListItems = _useState2[1];
|
137
|
+
var onLoadMore = /*#__PURE__*/function () {
|
138
|
+
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
139
|
+
return _regeneratorRuntime().wrap(function _callee$(_context3) {
|
140
|
+
while (1) switch (_context3.prev = _context3.next) {
|
141
|
+
case 0:
|
142
|
+
onLoadMoreFunc();
|
143
|
+
case 1:
|
144
|
+
case "end":
|
145
|
+
return _context3.stop();
|
146
|
+
}
|
147
|
+
}, _callee);
|
148
|
+
}));
|
149
|
+
return function onLoadMore() {
|
150
|
+
return _ref4.apply(this, arguments);
|
151
|
+
};
|
152
|
+
}();
|
153
|
+
var onLoadPrev = /*#__PURE__*/function () {
|
154
|
+
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
155
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context4) {
|
156
|
+
while (1) switch (_context4.prev = _context4.next) {
|
157
|
+
case 0:
|
158
|
+
onLoadPrevFunc();
|
159
|
+
case 1:
|
160
|
+
case "end":
|
161
|
+
return _context4.stop();
|
162
|
+
}
|
163
|
+
}, _callee2);
|
164
|
+
}));
|
165
|
+
return function onLoadPrev() {
|
166
|
+
return _ref5.apply(this, arguments);
|
167
|
+
};
|
168
|
+
}();
|
169
|
+
return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.MultivaluesField, {
|
170
|
+
items: listItems,
|
171
|
+
label: "Field Label",
|
172
|
+
onLoadMore: onLoadMore,
|
173
|
+
onLoadPrev: onLoadPrev
|
174
|
+
}, function (item) {
|
175
|
+
return (0, _react2.jsx)(_index.Item, {
|
176
|
+
key: item.key,
|
177
|
+
"data-id": item.name,
|
178
|
+
"aria-label": item.name
|
179
|
+
}, item.name);
|
180
|
+
}));
|
181
|
+
};
|
111
182
|
beforeAll(function () {
|
112
183
|
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function () {
|
113
184
|
return 1000;
|
@@ -267,10 +338,10 @@ test('no badges are rendered, if nothing is selected', function () {
|
|
267
338
|
});
|
268
339
|
expect(_testWrapper.screen.queryByRole('presentation')).not.toBeInTheDocument(0);
|
269
340
|
});
|
270
|
-
test('after clicking an option, and then typing a custom input, the listbox remains open and filters the options', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
341
|
+
test('after clicking an option, and then typing a custom input, the listbox remains open and filters the options', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
271
342
|
var input, options, firstOption, value, listbox, filteredOptions;
|
272
|
-
return _regeneratorRuntime().wrap(function
|
273
|
-
while (1) switch (
|
343
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context5) {
|
344
|
+
while (1) switch (_context5.prev = _context5.next) {
|
274
345
|
case 0:
|
275
346
|
getComponent({
|
276
347
|
mode: 'non-restrictive'
|
@@ -284,11 +355,11 @@ test('after clicking an option, and then typing a custom input, the listbox rema
|
|
284
355
|
firstOption.click();
|
285
356
|
});
|
286
357
|
expect(firstOption).not.toBeInTheDocument();
|
287
|
-
|
358
|
+
_context5.next = 10;
|
288
359
|
return _userEvent["default"].clear(input);
|
289
360
|
case 10:
|
290
361
|
value = 'ka';
|
291
|
-
|
362
|
+
_context5.next = 13;
|
292
363
|
return _userEvent["default"].type(input, value);
|
293
364
|
case 13:
|
294
365
|
listbox = _testWrapper.screen.queryByRole('listbox');
|
@@ -297,9 +368,9 @@ test('after clicking an option, and then typing a custom input, the listbox rema
|
|
297
368
|
expect(filteredOptions.length).toBe(1);
|
298
369
|
case 17:
|
299
370
|
case "end":
|
300
|
-
return
|
371
|
+
return _context5.stop();
|
301
372
|
}
|
302
|
-
},
|
373
|
+
}, _callee3);
|
303
374
|
})));
|
304
375
|
test('clicking on delete button deletes selection, and re-adds option to list', function () {
|
305
376
|
getComponent();
|
@@ -401,10 +472,10 @@ test('in non-restrictive mode, a badge gets added if there is only one matching
|
|
401
472
|
expect(badgeContainer).toHaveAttribute('role', 'presentation');
|
402
473
|
expect(firstOption).not.toBeInTheDocument();
|
403
474
|
});
|
404
|
-
test('dropdown with options reappears after entering a custom input', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
475
|
+
test('dropdown with options reappears after entering a custom input', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
405
476
|
var input, value1, value2, listbox, options2;
|
406
|
-
return _regeneratorRuntime().wrap(function
|
407
|
-
while (1) switch (
|
477
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context6) {
|
478
|
+
while (1) switch (_context6.prev = _context6.next) {
|
408
479
|
case 0:
|
409
480
|
getComponent({
|
410
481
|
mode: 'non-restrictive'
|
@@ -414,10 +485,10 @@ test('dropdown with options reappears after entering a custom input', /*#__PURE_
|
|
414
485
|
_userEvent["default"].type(input, value1);
|
415
486
|
expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
|
416
487
|
value2 = '';
|
417
|
-
|
488
|
+
_context6.next = 8;
|
418
489
|
return _userEvent["default"].clear(input);
|
419
490
|
case 8:
|
420
|
-
|
491
|
+
_context6.next = 10;
|
421
492
|
return _userEvent["default"].type(input, value2);
|
422
493
|
case 10:
|
423
494
|
listbox = _testWrapper.screen.getByRole('listbox');
|
@@ -425,9 +496,9 @@ test('dropdown with options reappears after entering a custom input', /*#__PURE_
|
|
425
496
|
expect(options2.length).toBe(items.length);
|
426
497
|
case 13:
|
427
498
|
case "end":
|
428
|
-
return
|
499
|
+
return _context6.stop();
|
429
500
|
}
|
430
|
-
},
|
501
|
+
}, _callee4);
|
431
502
|
})));
|
432
503
|
test('changing the input value and hitting enter by default do nothing', function () {
|
433
504
|
getComponent();
|
@@ -1032,6 +1103,23 @@ test('should render the separators', function () {
|
|
1032
1103
|
}
|
1033
1104
|
});
|
1034
1105
|
});
|
1106
|
+
test('escape focus delegate calls correct functions if anything else is pressed', function () {
|
1107
|
+
(0, _testWrapper.render)((0, _react2.jsx)(ComponentOnPrevLoad, null));
|
1108
|
+
_userEvent["default"].tab();
|
1109
|
+
var listBox = _testWrapper.screen.getAllByRole('listbox');
|
1110
|
+
_testWrapper.fireEvent.scroll(listBox[0], {
|
1111
|
+
target: {
|
1112
|
+
scrollY: 450
|
1113
|
+
}
|
1114
|
+
});
|
1115
|
+
expect(onLoadMoreFunc).toHaveBeenCalled();
|
1116
|
+
_testWrapper.fireEvent.scroll(listBox[0], {
|
1117
|
+
target: {
|
1118
|
+
scrollY: 0
|
1119
|
+
}
|
1120
|
+
});
|
1121
|
+
expect(onLoadPrevFunc).toHaveBeenCalled();
|
1122
|
+
});
|
1035
1123
|
|
1036
1124
|
// Needs to be added to each components test file
|
1037
1125
|
(0, _universalComponentTest.universalComponentTests)({
|
@@ -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;
|
@@ -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'
|
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
9
9
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
10
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onOpenChange", "onSelectionChange", "placeholder", "readOnlyKeys", "selectedKeys", "scrollBoxProps", "status"];
|
12
|
+
var _excluded = ["defaultSelectedKeys", "direction", "disabledKeys", "containerProps", "hasAutoFocus", "hasNoStatusIndicator", "helperText", "inputProps", "isDisabled", "isNotFlippable", "isReadOnly", "isRequired", "items", "label", "loadingState", "mode", "onBlur", "onFocus", "onInputChange", "onKeyDown", "onKeyUp", "onLoadMore", "onLoadPrev", "onOpenChange", "onSelectionChange", "placeholder", "readOnlyKeys", "selectedKeys", "scrollBoxProps", "status"];
|
13
13
|
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; }
|
14
14
|
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; }
|
15
15
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
@@ -32,6 +32,7 @@ import PropTypes from 'prop-types';
|
|
32
32
|
import { Badge, Box, Icon, IconButton, PopoverContainer, ScrollBox, Text, TextField } from '../..';
|
33
33
|
import { MultivaluesContext } from '../../context/MultivaluesContext';
|
34
34
|
import { usePropWarning } from '../../hooks';
|
35
|
+
import loadingStates from '../../utils/devUtils/constants/loadingStates';
|
35
36
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
36
37
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
37
38
|
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
@@ -56,12 +57,15 @@ var DefaultMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
56
57
|
isRequired = props.isRequired,
|
57
58
|
initialItems = props.items,
|
58
59
|
label = props.label,
|
60
|
+
loadingState = props.loadingState,
|
59
61
|
mode = props.mode,
|
60
62
|
_onBlur = props.onBlur,
|
61
63
|
_onFocus = props.onFocus,
|
62
64
|
onInputChange = props.onInputChange,
|
63
65
|
onKeyDown = props.onKeyDown,
|
64
66
|
_onKeyUp = props.onKeyUp,
|
67
|
+
onLoadMore = props.onLoadMore,
|
68
|
+
onLoadPrev = props.onLoadPrev,
|
65
69
|
onOpenChange = props.onOpenChange,
|
66
70
|
onSelectionChange = props.onSelectionChange,
|
67
71
|
placeholder = props.placeholder,
|
@@ -93,6 +97,11 @@ var DefaultMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
93
97
|
_useState10 = _slicedToArray(_useState9, 2),
|
94
98
|
activeDescendant = _useState10[0],
|
95
99
|
setActiveDescendant = _useState10[1];
|
100
|
+
useEffect(function () {
|
101
|
+
if (mode !== 'non-restrictive') {
|
102
|
+
setItems(initialItems);
|
103
|
+
}
|
104
|
+
}, [initialItems]);
|
96
105
|
var toggleItems = function toggleItems(keys) {
|
97
106
|
setItems(_filterInstanceProperty(initialItems).call(initialItems, function (item) {
|
98
107
|
var _context;
|
@@ -400,6 +409,10 @@ var DefaultMultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
400
409
|
hasVirtualFocus: true,
|
401
410
|
hasNoEmptySelection: true,
|
402
411
|
state: state,
|
412
|
+
onLoadMore: onLoadMore,
|
413
|
+
onLoadPrev: onLoadPrev,
|
414
|
+
loadingState: loadingState,
|
415
|
+
isLoading: loadingState === loadingStates.LOADING_MORE,
|
403
416
|
"aria-label": "List of options"
|
404
417
|
})), ___EmotionJSX(DismissButton, {
|
405
418
|
onDismiss: close
|
@@ -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({
|