@pingux/astro 2.42.0-alpha.1 → 2.42.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/TreeView/TreeView.js +10 -5
- package/lib/cjs/components/TreeView/TreeView.stories.js +169 -3
- package/lib/cjs/components/TreeView/TreeView.test.js +130 -9
- package/lib/cjs/components/TreeView/TreeViewRow.js +5 -3
- package/lib/cjs/components/TreeView/TreeViewSection.js +32 -3
- package/lib/cjs/recipes/LinkedListView.stories.js +6 -2
- package/lib/cjs/recipes/PanelContent.stories.js +1 -1
- package/lib/components/TreeView/TreeView.js +10 -5
- package/lib/components/TreeView/TreeView.stories.js +161 -1
- package/lib/components/TreeView/TreeView.test.js +130 -9
- package/lib/components/TreeView/TreeViewRow.js +5 -3
- package/lib/components/TreeView/TreeViewSection.js +34 -5
- package/lib/recipes/LinkedListView.stories.js +7 -3
- package/lib/recipes/PanelContent.stories.js +1 -1
- package/package.json +1 -1
@@ -9,13 +9,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
10
10
|
});
|
11
11
|
exports.removeRefFromArrayHelper = exports.onKeyDownSection = exports["default"] = exports.addRefToArrayHelper = void 0;
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
12
13
|
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
13
14
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
15
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
16
|
+
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
15
17
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
16
18
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
17
19
|
var _react = _interopRequireWildcard(require("react"));
|
18
20
|
var _listbox = require("@react-aria/listbox");
|
21
|
+
var _visuallyHidden = require("@react-aria/visually-hidden");
|
19
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
20
23
|
var _TreeViewContext = require("../../context/TreeViewContext");
|
21
24
|
var _index2 = require("../../index");
|
@@ -110,6 +113,8 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
110
113
|
var item = props.item,
|
111
114
|
items = props.items,
|
112
115
|
title = props.title,
|
116
|
+
hasChildren = props.hasChildren,
|
117
|
+
loadingNodes = props.loadingNodes,
|
113
118
|
focusManager = props.focusManager,
|
114
119
|
onKeyDown = props.onKeyDown,
|
115
120
|
level = props.level,
|
@@ -117,6 +122,7 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
117
122
|
setSize = props.setSize;
|
118
123
|
var key = item.key;
|
119
124
|
var treeSectionRef = (0, _react.useRef)();
|
125
|
+
|
120
126
|
/* istanbul ignore next */
|
121
127
|
(0, _react.useImperativeHandle)(ref, function () {
|
122
128
|
return treeSectionRef.current;
|
@@ -136,6 +142,17 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
136
142
|
isDisabled = _useOption.isDisabled;
|
137
143
|
var isExpanded = state.expandedKeys.has(key);
|
138
144
|
var isDragging = dragState.isDragging(item.key);
|
145
|
+
var _useState = (0, _react.useState)(),
|
146
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
147
|
+
loaderState = _useState2[0],
|
148
|
+
setLoaderState = _useState2[1];
|
149
|
+
(0, _react.useEffect)(function () {
|
150
|
+
if (loadingNodes) {
|
151
|
+
(0, _forEach["default"])(loadingNodes).call(loadingNodes, function (loader) {
|
152
|
+
if (loader.node === title) setLoaderState(loader.loadingState);
|
153
|
+
});
|
154
|
+
}
|
155
|
+
}, [loadingNodes, title]);
|
139
156
|
var onKeyDownFunction = function onKeyDownFunction(e) {
|
140
157
|
onKeyDownSection(e, state, key, tree, isSelected, isExpanded, focusManager, flatKeyArray, refArray, pageLength, true);
|
141
158
|
if (onKeyDown) {
|
@@ -166,7 +183,8 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
166
183
|
items: items,
|
167
184
|
isDragging: isDragging,
|
168
185
|
isExpanded: isExpanded,
|
169
|
-
onKeyDown: onKeyDownFunction
|
186
|
+
onKeyDown: onKeyDownFunction,
|
187
|
+
hasChildren: hasChildren
|
170
188
|
}), isExpanded && (0, _react2.jsx)(_index2.Box, {
|
171
189
|
role: "rowgroup",
|
172
190
|
key: "".concat(item.key, " ul"),
|
@@ -176,13 +194,22 @@ var TreeViewSection = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
176
194
|
border: 'none'
|
177
195
|
}
|
178
196
|
}
|
179
|
-
}, (0,
|
197
|
+
}, (0, _react2.jsx)(_visuallyHidden.VisuallyHidden, {
|
198
|
+
"aria-live": "polite"
|
199
|
+
}, loaderState === false && (isExpanded && items.length > 0 ? ' Loading successful' : 'Loading unsuccessful')), loaderState ? (0, _react2.jsx)(_index2.Loader, {
|
200
|
+
color: "active",
|
201
|
+
ml: "31px"
|
202
|
+
}) : (0, _map["default"])(_context3 = (0, _from["default"])(items)).call(_context3, function (_item, _index) {
|
180
203
|
var _item$children;
|
181
|
-
return (0, _TreeView.SectionOrItemRender)(
|
204
|
+
return (0, _TreeView.SectionOrItemRender)(
|
205
|
+
// _item.value.items?.length > 0 || _item.value.items,
|
206
|
+
((_item$children = _item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0 || _item.value.items, (0, _react2.jsx)(TreeViewSection, {
|
182
207
|
item: _item,
|
183
208
|
items: _item.children,
|
184
209
|
title: _item.value.title,
|
185
210
|
key: _item.value.title,
|
211
|
+
hasChildren: _item.value.items && true,
|
212
|
+
loadingNodes: loadingNodes,
|
186
213
|
focusManager: focusManager,
|
187
214
|
level: level + 1,
|
188
215
|
position: _index,
|
@@ -211,6 +238,8 @@ TreeViewSection.propTypes = {
|
|
211
238
|
key: _propTypes["default"].string
|
212
239
|
}),
|
213
240
|
title: _propTypes["default"].string,
|
241
|
+
hasChildren: _propTypes["default"].bool,
|
242
|
+
loadingNodes: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
|
214
243
|
focusManager: _propTypes["default"].shape({}),
|
215
244
|
onKeyDown: _propTypes["default"].func,
|
216
245
|
level: _propTypes["default"].number,
|
@@ -18,6 +18,7 @@ var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
18
18
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
20
20
|
var _DotsVerticalIcon = _interopRequireDefault(require("@pingux/mdi-react/DotsVerticalIcon"));
|
21
|
+
var _uuid = require("uuid");
|
21
22
|
var _useOverlappingMenuHoverState = _interopRequireDefault(require("../hooks/useOverlappingMenuHoverState"));
|
22
23
|
var _index = require("../index");
|
23
24
|
var _react2 = require("@emotion/react");
|
@@ -237,14 +238,17 @@ var Default = function Default(_ref) {
|
|
237
238
|
|
238
239
|
// the vector shield and key icon.
|
239
240
|
var ShieldIcon = function ShieldIcon(props) {
|
241
|
+
var id = (0, _react.useMemo)(function () {
|
242
|
+
return (0, _uuid.v4)();
|
243
|
+
}, []);
|
240
244
|
return (0, _react2.jsx)("svg", (0, _extends2["default"])({
|
241
245
|
width: "19",
|
242
246
|
height: "23",
|
243
247
|
viewBox: "0 0 19 23",
|
244
248
|
xmlns: "http://www.w3.org/2000/svg",
|
245
|
-
"aria-labelledby": "shield-icon-title"
|
249
|
+
"aria-labelledby": "shield-icon-title-".concat(id)
|
246
250
|
}, props), (0, _react2.jsx)("title", {
|
247
|
-
id: "shield-icon-title"
|
251
|
+
id: "shield-icon-title-".concat(id)
|
248
252
|
}, "Shield Icon"), (0, _react2.jsx)("path", {
|
249
253
|
d: "M9.5 7.33342C9.77627 7.33342 10.0412 7.44316 10.2366 7.63851C10.4319 7.83386 10.5417 8.09881 10.5417 8.37508C10.5417 8.65135 10.4319 8.9163 10.2366 9.11165C10.0412 9.307 9.77627 9.41675 9.5 9.41675C9.22373 9.41675 8.95878 9.307 8.76343 9.11165C8.56808 8.9163 8.45833 8.65135 8.45833 8.37508C8.45833 8.09881 8.56808 7.83386 8.76343 7.63851C8.95878 7.44316 9.22373 7.33342 9.5 7.33342ZM18.875 10.4584C18.875 16.2397 14.875 21.6459 9.5 22.9584C4.125 21.6459 0.125 16.2397 0.125 10.4584V4.20842L9.5 0.041748L18.875 4.20842V10.4584ZM9.5 5.25008C8.6712 5.25008 7.87634 5.57932 7.29029 6.16537C6.70424 6.75142 6.375 7.54628 6.375 8.37508C6.375 9.73967 7.23958 10.8959 8.45833 11.323V17.7501H10.5417V15.6667H12.625V13.5834H10.5417V11.323C11.7604 10.8959 12.625 9.73967 12.625 8.37508C12.625 7.54628 12.2958 6.75142 11.7097 6.16537C11.1237 5.57932 10.3288 5.25008 9.5 5.25008Z"
|
250
254
|
}));
|
@@ -26,7 +26,7 @@ var _react2 = require("@emotion/react");
|
|
26
26
|
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); }
|
27
27
|
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; }
|
28
28
|
var _default = {
|
29
|
-
title: '
|
29
|
+
title: 'Recipes/Panel Content',
|
30
30
|
parameters: {
|
31
31
|
docs: {
|
32
32
|
source: {
|
@@ -12,7 +12,7 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
12
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
13
|
var _excluded = ["value"],
|
14
14
|
_excluded2 = ["value"],
|
15
|
-
_excluded3 = ["tree", "disabledKeys", "onExpandedChange", "onDragStart", "onDrop", "onKeyDown", "pageLength"];
|
15
|
+
_excluded3 = ["tree", "disabledKeys", "onExpandedChange", "loadingNodes", "onDragStart", "onDrop", "onKeyDown", "pageLength"];
|
16
16
|
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; }
|
17
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
18
18
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
@@ -108,6 +108,7 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
108
108
|
var tree = props.tree,
|
109
109
|
disabledKeys = props.disabledKeys,
|
110
110
|
onExpandedChange = props.onExpandedChange,
|
111
|
+
loadingNodes = props.loadingNodes,
|
111
112
|
onDragStartProp = props.onDragStart,
|
112
113
|
onDropProp = props.onDrop,
|
113
114
|
onKeyDown = props.onKeyDown,
|
@@ -147,14 +148,14 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
147
148
|
var flattenNestedData = function flattenNestedData(_data) {
|
148
149
|
var returnArray = [];
|
149
150
|
var checkItemNesting = function checkItemNesting(item) {
|
150
|
-
var _item$value, _item$children;
|
151
|
-
if (((_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.children) === null || _item$value === void 0 ? void 0 : _item$value.length) > 0) {
|
151
|
+
var _item$value, _item$props, _item$children, _item$value2;
|
152
|
+
if (((_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.children) === null || _item$value === void 0 ? void 0 : _item$value.length) > 0 || item !== null && item !== void 0 && (_item$props = item.props) !== null && _item$props !== void 0 && _item$props.hasChildren) {
|
152
153
|
return {
|
153
154
|
isTopLevel: true,
|
154
155
|
hasChildren: true
|
155
156
|
};
|
156
157
|
}
|
157
|
-
if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) {
|
158
|
+
if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0 || (_item$value2 = item.value) !== null && _item$value2 !== void 0 && _item$value2.items) {
|
158
159
|
return {
|
159
160
|
isTopLevel: false,
|
160
161
|
hasChildren: true
|
@@ -352,11 +353,13 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
352
353
|
border: 'none !important'
|
353
354
|
}
|
354
355
|
}, others), ___EmotionJSX(TreeViewWrapper, null, _mapInstanceProperty(_context5 = _Array$from(state.collection)).call(_context5, function (item, index) {
|
355
|
-
return SectionOrItemRender(item.value.children.length > 0, ___EmotionJSX(TreeViewSection, {
|
356
|
+
return SectionOrItemRender(item.props.hasChildren || item.value.children.length > 0, ___EmotionJSX(TreeViewSection, {
|
356
357
|
item: item,
|
357
358
|
items: item.value.children,
|
358
359
|
title: item.props.title,
|
359
360
|
key: item.props.title,
|
361
|
+
hasChildren: item.props.hasChildren,
|
362
|
+
loadingNodes: loadingNodes,
|
360
363
|
onKeyDown: onKeyDown,
|
361
364
|
level: level + 1,
|
362
365
|
setSize: state.collection.size,
|
@@ -391,6 +394,8 @@ TreeView.propTypes = {
|
|
391
394
|
items: isIterableProp,
|
392
395
|
/** String that describes the treeview when using a screen reader. */
|
393
396
|
'aria-label': PropTypes.string,
|
397
|
+
/** Determines whether the loading indicator is shown for the expanded node. */
|
398
|
+
loadingNodes: PropTypes.arrayOf(PropTypes.shape({})),
|
394
399
|
/** Handler that is called when a key is pressed. */
|
395
400
|
onKeyDown: PropTypes.func,
|
396
401
|
/** Callback that is called when the dragging action starts. */
|
@@ -1,5 +1,23 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
3
|
+
import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
|
4
|
+
import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
|
5
|
+
import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
|
6
|
+
import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
|
7
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
8
|
+
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
9
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
10
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
1
11
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import React from 'react';
|
12
|
+
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 _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, 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 _context6; 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(_context6 = this.tryEntries).call(_context6, 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; }
|
13
|
+
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
14
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
15
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
16
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
17
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
18
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
19
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
|
20
|
+
import React, { useEffect, useState } from 'react';
|
3
21
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
4
22
|
import { Item, TreeView, useTreeData } from '../../index';
|
5
23
|
import TreeViewReadMe from './TreeView.mdx';
|
@@ -66,6 +84,24 @@ var data = [{
|
|
66
84
|
key: 'Single Item',
|
67
85
|
title: 'Single Item'
|
68
86
|
}];
|
87
|
+
var initialAsyncItems = [{
|
88
|
+
title: 'Item1',
|
89
|
+
items: []
|
90
|
+
}, {
|
91
|
+
title: 'Item2',
|
92
|
+
items: []
|
93
|
+
}, {
|
94
|
+
title: 'Item3'
|
95
|
+
}, {
|
96
|
+
title: 'Item4',
|
97
|
+
items: []
|
98
|
+
}, {
|
99
|
+
title: 'Item5',
|
100
|
+
items: []
|
101
|
+
}, {
|
102
|
+
title: 'Item6',
|
103
|
+
items: []
|
104
|
+
}];
|
69
105
|
export var Default = function Default(args) {
|
70
106
|
var tree = useTreeData({
|
71
107
|
initialItems: data,
|
@@ -89,4 +125,128 @@ export var Default = function Default(args) {
|
|
89
125
|
title: (_section$value = section.value) === null || _section$value === void 0 ? void 0 : _section$value.title
|
90
126
|
});
|
91
127
|
});
|
128
|
+
};
|
129
|
+
export var AsyncLoading = function AsyncLoading(args) {
|
130
|
+
var _useState = useState(new _Set([])),
|
131
|
+
_useState2 = _slicedToArray(_useState, 2),
|
132
|
+
expandedKeys = _useState2[0],
|
133
|
+
setExpandedKeys = _useState2[1];
|
134
|
+
var _useState3 = useState(1),
|
135
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
136
|
+
childNode = _useState4[0],
|
137
|
+
setChildNode = _useState4[1];
|
138
|
+
var _useState5 = useState([]),
|
139
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
140
|
+
loadingNodes = _useState6[0],
|
141
|
+
setLoadingNodes = _useState6[1];
|
142
|
+
var getMockData = /*#__PURE__*/function () {
|
143
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
144
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
145
|
+
while (1) switch (_context.prev = _context.next) {
|
146
|
+
case 0:
|
147
|
+
setChildNode(childNode + 1);
|
148
|
+
|
149
|
+
// emulate loading state
|
150
|
+
_context.next = 3;
|
151
|
+
return new _Promise(function (resolve) {
|
152
|
+
return _setTimeout(resolve, childNode ? 2000 : 3000);
|
153
|
+
});
|
154
|
+
case 3:
|
155
|
+
return _context.abrupt("return", [{
|
156
|
+
title: "Child Node ".concat(childNode),
|
157
|
+
items: []
|
158
|
+
}, {
|
159
|
+
title: "Single Node ".concat(childNode)
|
160
|
+
}]);
|
161
|
+
case 4:
|
162
|
+
case "end":
|
163
|
+
return _context.stop();
|
164
|
+
}
|
165
|
+
}, _callee);
|
166
|
+
}));
|
167
|
+
return function getMockData() {
|
168
|
+
return _ref.apply(this, arguments);
|
169
|
+
};
|
170
|
+
}();
|
171
|
+
var tree = useTreeData({
|
172
|
+
initialItems: initialAsyncItems,
|
173
|
+
getKey: function getKey(item) {
|
174
|
+
return item.title;
|
175
|
+
},
|
176
|
+
getChildren: function getChildren(item) {
|
177
|
+
return item.items;
|
178
|
+
}
|
179
|
+
});
|
180
|
+
var handleExpand = /*#__PURE__*/function () {
|
181
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(node) {
|
182
|
+
var _tree$getItem, expandedNode, _context2, list;
|
183
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
184
|
+
while (1) switch (_context3.prev = _context3.next) {
|
185
|
+
case 0:
|
186
|
+
if (!(expandedKeys.size < 0 || expandedKeys.size < node.size)) {
|
187
|
+
_context3.next = 11;
|
188
|
+
break;
|
189
|
+
}
|
190
|
+
expandedNode = _Array$from(node).pop();
|
191
|
+
if (!(((_tree$getItem = tree.getItem(expandedNode)) === null || _tree$getItem === void 0 || (_tree$getItem = _tree$getItem.children) === null || _tree$getItem === void 0 ? void 0 : _tree$getItem.length) <= 0)) {
|
192
|
+
_context3.next = 9;
|
193
|
+
break;
|
194
|
+
}
|
195
|
+
setLoadingNodes(_concatInstanceProperty(_context2 = []).call(_context2, loadingNodes, [{
|
196
|
+
node: expandedNode,
|
197
|
+
loadingState: true
|
198
|
+
}]));
|
199
|
+
_context3.next = 6;
|
200
|
+
return getMockData();
|
201
|
+
case 6:
|
202
|
+
list = _context3.sent;
|
203
|
+
_forEachInstanceProperty(list).call(list, function (item) {
|
204
|
+
tree.insert(expandedNode, 1, item);
|
205
|
+
});
|
206
|
+
setExpandedKeys(node);
|
207
|
+
case 9:
|
208
|
+
_context3.next = 12;
|
209
|
+
break;
|
210
|
+
case 11:
|
211
|
+
if (expandedKeys.size > node.size) {
|
212
|
+
setExpandedKeys(node);
|
213
|
+
}
|
214
|
+
case 12:
|
215
|
+
case "end":
|
216
|
+
return _context3.stop();
|
217
|
+
}
|
218
|
+
}, _callee2);
|
219
|
+
}));
|
220
|
+
return function handleExpand(_x) {
|
221
|
+
return _ref2.apply(this, arguments);
|
222
|
+
};
|
223
|
+
}();
|
224
|
+
useEffect(function () {
|
225
|
+
_forEachInstanceProperty(loadingNodes).call(loadingNodes, function (item, index) {
|
226
|
+
var _tree$getItem2;
|
227
|
+
var isFulfilled = ((_tree$getItem2 = tree.getItem(item.node)) === null || _tree$getItem2 === void 0 || (_tree$getItem2 = _tree$getItem2.children) === null || _tree$getItem2 === void 0 ? void 0 : _tree$getItem2.length) > 0;
|
228
|
+
if (isFulfilled) {
|
229
|
+
var _context4;
|
230
|
+
var tempArray = _concatInstanceProperty(_context4 = []).call(_context4, loadingNodes);
|
231
|
+
_spliceInstanceProperty(tempArray).call(tempArray, index, 1, {
|
232
|
+
node: item.node,
|
233
|
+
loadingState: false
|
234
|
+
});
|
235
|
+
setLoadingNodes(tempArray);
|
236
|
+
}
|
237
|
+
});
|
238
|
+
}, [expandedKeys]);
|
239
|
+
return ___EmotionJSX(TreeView, _extends({}, args, {
|
240
|
+
items: tree.items,
|
241
|
+
tree: tree,
|
242
|
+
onExpandedChange: handleExpand,
|
243
|
+
loadingNodes: loadingNodes
|
244
|
+
}), function (section) {
|
245
|
+
return ___EmotionJSX(Item, {
|
246
|
+
key: section.key,
|
247
|
+
items: section.children,
|
248
|
+
title: section.value.title,
|
249
|
+
hasChildren: section.value.items && true
|
250
|
+
});
|
251
|
+
});
|
92
252
|
};
|
@@ -4,8 +4,8 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerat
|
|
4
4
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
5
5
|
var _context;
|
6
6
|
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; }
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
8
|
-
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; }
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
+
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 _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, 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 _context6; 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(_context6 = this.tryEntries).call(_context6, 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; }
|
9
9
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
10
10
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
11
11
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
@@ -153,6 +153,46 @@ var TreeViewComponent = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
153
153
|
});
|
154
154
|
});
|
155
155
|
});
|
156
|
+
var asyncData = [{
|
157
|
+
title: 'Item1',
|
158
|
+
items: []
|
159
|
+
}, {
|
160
|
+
title: 'Item2',
|
161
|
+
items: []
|
162
|
+
}, {
|
163
|
+
title: 'Item3'
|
164
|
+
}, {
|
165
|
+
title: 'Item4',
|
166
|
+
items: []
|
167
|
+
}];
|
168
|
+
var AsyncTreeViewComponent = function AsyncTreeViewComponent(props) {
|
169
|
+
var tree = useTreeData({
|
170
|
+
initialItems: asyncData,
|
171
|
+
getKey: function getKey(item) {
|
172
|
+
return item.title;
|
173
|
+
},
|
174
|
+
getChildren: function getChildren(item) {
|
175
|
+
return item.items;
|
176
|
+
}
|
177
|
+
});
|
178
|
+
var loadingNodes = [];
|
179
|
+
return ___EmotionJSX(TreeView, _extends({}, defaultProps, props, {
|
180
|
+
items: tree.items,
|
181
|
+
tree: tree,
|
182
|
+
isLoading: loadingNodes,
|
183
|
+
"aria-label": "Example Tree"
|
184
|
+
}), function (section) {
|
185
|
+
return ___EmotionJSX(Item, {
|
186
|
+
key: section.key,
|
187
|
+
items: section.children,
|
188
|
+
title: section.key,
|
189
|
+
hasChildren: section.value.items && true,
|
190
|
+
customProp: {
|
191
|
+
testp: 1
|
192
|
+
}
|
193
|
+
});
|
194
|
+
});
|
195
|
+
};
|
156
196
|
TreeViewComponent.propTypes = {
|
157
197
|
data: PropTypes.arrayOf(PropTypes.shape({}))
|
158
198
|
};
|
@@ -308,6 +348,87 @@ test('disabledKeys prop disables items in the tree -- rendering them unclickable
|
|
308
348
|
expect(thisItem).not.toHaveClass('is-selected');
|
309
349
|
expect(thisItem).toHaveAttribute('aria-selected', 'false');
|
310
350
|
});
|
351
|
+
describe('loadingState', function () {
|
352
|
+
test('should not render loader if tree item is not expanded', function () {
|
353
|
+
render(___EmotionJSX(AsyncTreeViewComponent, {
|
354
|
+
loadingNodes: [{
|
355
|
+
node: 'Item2',
|
356
|
+
loadingState: true
|
357
|
+
}]
|
358
|
+
}));
|
359
|
+
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
|
360
|
+
});
|
361
|
+
test('should render loader if tree item is expanded', function () {
|
362
|
+
render(___EmotionJSX(AsyncTreeViewComponent, {
|
363
|
+
loadingNodes: [{
|
364
|
+
node: 'Item1',
|
365
|
+
loadingState: true
|
366
|
+
}]
|
367
|
+
}));
|
368
|
+
var buttons = screen.queryAllByRole('button');
|
369
|
+
userEvent.click(buttons[0]);
|
370
|
+
var listItems = screen.getAllByRole('row');
|
371
|
+
var thisItem = listItems[0];
|
372
|
+
var loader = within(thisItem).getByRole('alert');
|
373
|
+
expect(loader).toBeInTheDocument();
|
374
|
+
});
|
375
|
+
test('should hide loader after children are added to the tree item', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
376
|
+
var buttons;
|
377
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
378
|
+
while (1) switch (_context2.prev = _context2.next) {
|
379
|
+
case 0:
|
380
|
+
render(___EmotionJSX(AsyncTreeViewComponent, {
|
381
|
+
loadingNodes: [{
|
382
|
+
node: 'Item1',
|
383
|
+
loadingState: true
|
384
|
+
}]
|
385
|
+
}));
|
386
|
+
buttons = screen.queryAllByRole('button');
|
387
|
+
fireEvent.click(buttons[0]);
|
388
|
+
render(___EmotionJSX(AsyncTreeViewComponent, {
|
389
|
+
loadingNodes: [{
|
390
|
+
node: 'Item1',
|
391
|
+
loadingState: false
|
392
|
+
}]
|
393
|
+
}));
|
394
|
+
fireEvent.click(buttons[0]);
|
395
|
+
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
|
396
|
+
case 6:
|
397
|
+
case "end":
|
398
|
+
return _context2.stop();
|
399
|
+
}
|
400
|
+
}, _callee);
|
401
|
+
})));
|
402
|
+
test('should add loader to item without children and not other expanded items', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
403
|
+
var buttons, loader;
|
404
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
405
|
+
while (1) switch (_context3.prev = _context3.next) {
|
406
|
+
case 0:
|
407
|
+
render(___EmotionJSX(AsyncTreeViewComponent, {
|
408
|
+
loadingNodes: [{
|
409
|
+
node: 'Item1',
|
410
|
+
loadingState: true
|
411
|
+
}, {
|
412
|
+
node: 'Item2',
|
413
|
+
loadingState: true
|
414
|
+
}, {
|
415
|
+
node: 'Item4',
|
416
|
+
loadingState: false
|
417
|
+
}]
|
418
|
+
}));
|
419
|
+
buttons = screen.queryAllByRole('button');
|
420
|
+
userEvent.click(buttons[0]);
|
421
|
+
userEvent.click(buttons[1]);
|
422
|
+
userEvent.click(buttons[2]);
|
423
|
+
loader = screen.getAllByRole('alert');
|
424
|
+
expect(loader).toHaveLength(2);
|
425
|
+
case 7:
|
426
|
+
case "end":
|
427
|
+
return _context3.stop();
|
428
|
+
}
|
429
|
+
}, _callee2);
|
430
|
+
})));
|
431
|
+
});
|
311
432
|
test('displays correct aria attributes', function () {
|
312
433
|
render(___EmotionJSX(TreeViewComponent, {
|
313
434
|
data: data
|
@@ -371,10 +492,10 @@ test('onKeyDown does not call passed in prop call back function', function () {
|
|
371
492
|
userEvent.type(thisItem, '{arrowleft}');
|
372
493
|
expect(callback).not.toHaveBeenCalled();
|
373
494
|
});
|
374
|
-
test('onDragStart calls passed in prop call back function', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
495
|
+
test('onDragStart calls passed in prop call back function', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
375
496
|
var callback, secondCallback, listItems, element, target, dataTransfer;
|
376
|
-
return _regeneratorRuntime().wrap(function
|
377
|
-
while (1) switch (
|
497
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
498
|
+
while (1) switch (_context4.prev = _context4.next) {
|
378
499
|
case 0:
|
379
500
|
callback = jest.fn();
|
380
501
|
secondCallback = jest.fn();
|
@@ -413,7 +534,7 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/_asyncT
|
|
413
534
|
clientY: 51
|
414
535
|
}));
|
415
536
|
expect(target).toHaveAttribute('data-droptarget', 'true');
|
416
|
-
|
537
|
+
_context4.next = 17;
|
417
538
|
return fireEvent(target, new DragEvent('drop', {
|
418
539
|
dataTransfer: dataTransfer,
|
419
540
|
clientX: 51,
|
@@ -423,7 +544,7 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/_asyncT
|
|
423
544
|
act(function () {
|
424
545
|
return jest.runAllTimers();
|
425
546
|
});
|
426
|
-
|
547
|
+
_context4.next = 20;
|
427
548
|
return fireEvent(element, new DragEvent('dragend', {
|
428
549
|
dataTransfer: dataTransfer,
|
429
550
|
clientX: 51,
|
@@ -439,9 +560,9 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/_asyncT
|
|
439
560
|
});
|
440
561
|
case 23:
|
441
562
|
case "end":
|
442
|
-
return
|
563
|
+
return _context4.stop();
|
443
564
|
}
|
444
|
-
},
|
565
|
+
}, _callee3);
|
445
566
|
})));
|
446
567
|
test('items still render if there is only one provided', function () {
|
447
568
|
var callback = jest.fn();
|