@pingux/astro 2.42.0-alpha.0 → 2.42.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/TreeView/TreeView.js +5 -10
- package/lib/cjs/components/TreeView/TreeView.stories.js +3 -169
- package/lib/cjs/components/TreeView/TreeView.test.js +9 -130
- package/lib/cjs/components/TreeView/TreeViewRow.js +3 -5
- package/lib/cjs/components/TreeView/TreeViewSection.js +3 -32
- package/lib/components/TreeView/TreeView.js +5 -10
- package/lib/components/TreeView/TreeView.stories.js +1 -161
- package/lib/components/TreeView/TreeView.test.js +9 -130
- package/lib/components/TreeView/TreeViewRow.js +3 -5
- package/lib/components/TreeView/TreeViewSection.js +5 -34
- package/package.json +1 -1
@@ -43,7 +43,7 @@ var _TreeViewWrapper = _interopRequireDefault(require("./TreeViewWrapper"));
|
|
43
43
|
var _react2 = require("@emotion/react");
|
44
44
|
var _excluded = ["value"],
|
45
45
|
_excluded2 = ["value"],
|
46
|
-
_excluded3 = ["tree", "disabledKeys", "onExpandedChange", "
|
46
|
+
_excluded3 = ["tree", "disabledKeys", "onExpandedChange", "onDragStart", "onDrop", "onKeyDown", "pageLength"]; // split out and exported for ease of use across components
|
47
47
|
// and to facilitate easier testing (eliminates redundant conditional renders)
|
48
48
|
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); }
|
49
49
|
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; }
|
@@ -122,7 +122,6 @@ var TreeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
122
122
|
var tree = props.tree,
|
123
123
|
disabledKeys = props.disabledKeys,
|
124
124
|
onExpandedChange = props.onExpandedChange,
|
125
|
-
loadingNodes = props.loadingNodes,
|
126
125
|
onDragStartProp = props.onDragStart,
|
127
126
|
onDropProp = props.onDrop,
|
128
127
|
onKeyDown = props.onKeyDown,
|
@@ -162,14 +161,14 @@ var TreeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
162
161
|
var flattenNestedData = function flattenNestedData(_data) {
|
163
162
|
var returnArray = [];
|
164
163
|
var checkItemNesting = function checkItemNesting(item) {
|
165
|
-
var _item$value, _item$
|
166
|
-
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
|
164
|
+
var _item$value, _item$children;
|
165
|
+
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) {
|
167
166
|
return {
|
168
167
|
isTopLevel: true,
|
169
168
|
hasChildren: true
|
170
169
|
};
|
171
170
|
}
|
172
|
-
if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0
|
171
|
+
if (((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) {
|
173
172
|
return {
|
174
173
|
isTopLevel: false,
|
175
174
|
hasChildren: true
|
@@ -367,13 +366,11 @@ var TreeView = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
367
366
|
border: 'none !important'
|
368
367
|
}
|
369
368
|
}, others), (0, _react2.jsx)(_TreeViewWrapper["default"], null, (0, _map["default"])(_context5 = (0, _from["default"])(state.collection)).call(_context5, function (item, index) {
|
370
|
-
return SectionOrItemRender(item.
|
369
|
+
return SectionOrItemRender(item.value.children.length > 0, (0, _react2.jsx)(_index.TreeViewSection, {
|
371
370
|
item: item,
|
372
371
|
items: item.value.children,
|
373
372
|
title: item.props.title,
|
374
373
|
key: item.props.title,
|
375
|
-
hasChildren: item.props.hasChildren,
|
376
|
-
loadingNodes: loadingNodes,
|
377
374
|
onKeyDown: onKeyDown,
|
378
375
|
level: level + 1,
|
379
376
|
setSize: state.collection.size,
|
@@ -408,8 +405,6 @@ TreeView.propTypes = {
|
|
408
405
|
items: _isIterable.isIterableProp,
|
409
406
|
/** String that describes the treeview when using a screen reader. */
|
410
407
|
'aria-label': _propTypes["default"].string,
|
411
|
-
/** Determines whether the loading indicator is shown for the expanded node. */
|
412
|
-
loadingNodes: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
|
413
408
|
/** Handler that is called when a key is pressed. */
|
414
409
|
onKeyDown: _propTypes["default"].func,
|
415
410
|
/** Callback that is called when the dragging action starts. */
|
@@ -1,40 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
|
-
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
6
|
-
var _Object$create = require("@babel/runtime-corejs3/core-js-stable/object/create");
|
7
|
-
var _Object$getPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
|
8
|
-
var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
9
|
-
var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
|
10
|
-
var _Promise2 = require("@babel/runtime-corejs3/core-js-stable/promise");
|
11
|
-
var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
|
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");
|
15
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
16
5
|
_Object$defineProperty(exports, "__esModule", {
|
17
6
|
value: true
|
18
7
|
});
|
19
|
-
exports["default"] = exports.Default =
|
20
|
-
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
21
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
22
|
-
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
23
|
-
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
24
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
25
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
26
|
-
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
27
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
28
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
8
|
+
exports["default"] = exports.Default = void 0;
|
29
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
30
|
-
var _react =
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
31
11
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
32
12
|
var _index = require("../../index");
|
33
13
|
var _TreeView = _interopRequireDefault(require("./TreeView.mdx"));
|
34
14
|
var _react2 = require("@emotion/react");
|
35
|
-
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); }
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
|
-
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; _forEachInstanceProperty2(_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" }], _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 = _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 _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, _forEachInstanceProperty2(_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; }
|
38
15
|
var _default = {
|
39
16
|
title: 'Experimental/TreeView',
|
40
17
|
component: _index.TreeView,
|
@@ -98,24 +75,6 @@ var data = [{
|
|
98
75
|
key: 'Single Item',
|
99
76
|
title: 'Single Item'
|
100
77
|
}];
|
101
|
-
var initialAsyncItems = [{
|
102
|
-
title: 'Item1',
|
103
|
-
items: []
|
104
|
-
}, {
|
105
|
-
title: 'Item2',
|
106
|
-
items: []
|
107
|
-
}, {
|
108
|
-
title: 'Item3'
|
109
|
-
}, {
|
110
|
-
title: 'Item4',
|
111
|
-
items: []
|
112
|
-
}, {
|
113
|
-
title: 'Item5',
|
114
|
-
items: []
|
115
|
-
}, {
|
116
|
-
title: 'Item6',
|
117
|
-
items: []
|
118
|
-
}];
|
119
78
|
var Default = function Default(args) {
|
120
79
|
var tree = (0, _index.useTreeData)({
|
121
80
|
initialItems: data,
|
@@ -140,129 +99,4 @@ var Default = function Default(args) {
|
|
140
99
|
});
|
141
100
|
});
|
142
101
|
};
|
143
|
-
exports.Default = Default;
|
144
|
-
var AsyncLoading = function AsyncLoading(args) {
|
145
|
-
var _useState = (0, _react.useState)(new _set["default"]([])),
|
146
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
147
|
-
expandedKeys = _useState2[0],
|
148
|
-
setExpandedKeys = _useState2[1];
|
149
|
-
var _useState3 = (0, _react.useState)(1),
|
150
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
151
|
-
childNode = _useState4[0],
|
152
|
-
setChildNode = _useState4[1];
|
153
|
-
var _useState5 = (0, _react.useState)([]),
|
154
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
155
|
-
loadingNodes = _useState6[0],
|
156
|
-
setLoadingNodes = _useState6[1];
|
157
|
-
var getMockData = /*#__PURE__*/function () {
|
158
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
159
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
160
|
-
while (1) switch (_context.prev = _context.next) {
|
161
|
-
case 0:
|
162
|
-
setChildNode(childNode + 1);
|
163
|
-
|
164
|
-
// emulate loading state
|
165
|
-
_context.next = 3;
|
166
|
-
return new _promise["default"](function (resolve) {
|
167
|
-
return (0, _setTimeout2["default"])(resolve, childNode ? 2000 : 3000);
|
168
|
-
});
|
169
|
-
case 3:
|
170
|
-
return _context.abrupt("return", [{
|
171
|
-
title: "Child Node ".concat(childNode),
|
172
|
-
items: []
|
173
|
-
}, {
|
174
|
-
title: "Single Node ".concat(childNode)
|
175
|
-
}]);
|
176
|
-
case 4:
|
177
|
-
case "end":
|
178
|
-
return _context.stop();
|
179
|
-
}
|
180
|
-
}, _callee);
|
181
|
-
}));
|
182
|
-
return function getMockData() {
|
183
|
-
return _ref.apply(this, arguments);
|
184
|
-
};
|
185
|
-
}();
|
186
|
-
var tree = (0, _index.useTreeData)({
|
187
|
-
initialItems: initialAsyncItems,
|
188
|
-
getKey: function getKey(item) {
|
189
|
-
return item.title;
|
190
|
-
},
|
191
|
-
getChildren: function getChildren(item) {
|
192
|
-
return item.items;
|
193
|
-
}
|
194
|
-
});
|
195
|
-
var handleExpand = /*#__PURE__*/function () {
|
196
|
-
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(node) {
|
197
|
-
var _tree$getItem, expandedNode, _context2, list;
|
198
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
199
|
-
while (1) switch (_context3.prev = _context3.next) {
|
200
|
-
case 0:
|
201
|
-
if (!(expandedKeys.size < 0 || expandedKeys.size < node.size)) {
|
202
|
-
_context3.next = 11;
|
203
|
-
break;
|
204
|
-
}
|
205
|
-
expandedNode = (0, _from["default"])(node).pop();
|
206
|
-
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)) {
|
207
|
-
_context3.next = 9;
|
208
|
-
break;
|
209
|
-
}
|
210
|
-
setLoadingNodes((0, _concat["default"])(_context2 = []).call(_context2, loadingNodes, [{
|
211
|
-
node: expandedNode,
|
212
|
-
loadingState: true
|
213
|
-
}]));
|
214
|
-
_context3.next = 6;
|
215
|
-
return getMockData();
|
216
|
-
case 6:
|
217
|
-
list = _context3.sent;
|
218
|
-
(0, _forEach["default"])(list).call(list, function (item) {
|
219
|
-
tree.insert(expandedNode, 1, item);
|
220
|
-
});
|
221
|
-
setExpandedKeys(node);
|
222
|
-
case 9:
|
223
|
-
_context3.next = 12;
|
224
|
-
break;
|
225
|
-
case 11:
|
226
|
-
if (expandedKeys.size > node.size) {
|
227
|
-
setExpandedKeys(node);
|
228
|
-
}
|
229
|
-
case 12:
|
230
|
-
case "end":
|
231
|
-
return _context3.stop();
|
232
|
-
}
|
233
|
-
}, _callee2);
|
234
|
-
}));
|
235
|
-
return function handleExpand(_x) {
|
236
|
-
return _ref2.apply(this, arguments);
|
237
|
-
};
|
238
|
-
}();
|
239
|
-
(0, _react.useEffect)(function () {
|
240
|
-
(0, _forEach["default"])(loadingNodes).call(loadingNodes, function (item, index) {
|
241
|
-
var _tree$getItem2;
|
242
|
-
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;
|
243
|
-
if (isFulfilled) {
|
244
|
-
var _context4;
|
245
|
-
var tempArray = (0, _concat["default"])(_context4 = []).call(_context4, loadingNodes);
|
246
|
-
(0, _splice["default"])(tempArray).call(tempArray, index, 1, {
|
247
|
-
node: item.node,
|
248
|
-
loadingState: false
|
249
|
-
});
|
250
|
-
setLoadingNodes(tempArray);
|
251
|
-
}
|
252
|
-
});
|
253
|
-
}, [expandedKeys]);
|
254
|
-
return (0, _react2.jsx)(_index.TreeView, (0, _extends2["default"])({}, args, {
|
255
|
-
items: tree.items,
|
256
|
-
tree: tree,
|
257
|
-
onExpandedChange: handleExpand,
|
258
|
-
loadingNodes: loadingNodes
|
259
|
-
}), function (section) {
|
260
|
-
return (0, _react2.jsx)(_index.Item, {
|
261
|
-
key: section.key,
|
262
|
-
items: section.children,
|
263
|
-
title: section.value.title,
|
264
|
-
hasChildren: section.value.items && true
|
265
|
-
});
|
266
|
-
});
|
267
|
-
};
|
268
|
-
exports.AsyncLoading = AsyncLoading;
|
102
|
+
exports.Default = Default;
|
@@ -40,8 +40,8 @@ var _context; // Needs to be added to each components test file
|
|
40
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); }
|
41
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; }
|
42
42
|
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; }
|
43
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
44
|
-
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; }
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
44
|
+
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; }
|
45
45
|
var testId = 'test-TreeView';
|
46
46
|
var defaultProps = {
|
47
47
|
'data-testid': testId,
|
@@ -158,46 +158,6 @@ var TreeViewComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref
|
|
158
158
|
});
|
159
159
|
});
|
160
160
|
});
|
161
|
-
var asyncData = [{
|
162
|
-
title: 'Item1',
|
163
|
-
items: []
|
164
|
-
}, {
|
165
|
-
title: 'Item2',
|
166
|
-
items: []
|
167
|
-
}, {
|
168
|
-
title: 'Item3'
|
169
|
-
}, {
|
170
|
-
title: 'Item4',
|
171
|
-
items: []
|
172
|
-
}];
|
173
|
-
var AsyncTreeViewComponent = function AsyncTreeViewComponent(props) {
|
174
|
-
var tree = (0, _reactStately.useTreeData)({
|
175
|
-
initialItems: asyncData,
|
176
|
-
getKey: function getKey(item) {
|
177
|
-
return item.title;
|
178
|
-
},
|
179
|
-
getChildren: function getChildren(item) {
|
180
|
-
return item.items;
|
181
|
-
}
|
182
|
-
});
|
183
|
-
var loadingNodes = [];
|
184
|
-
return (0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, props, {
|
185
|
-
items: tree.items,
|
186
|
-
tree: tree,
|
187
|
-
isLoading: loadingNodes,
|
188
|
-
"aria-label": "Example Tree"
|
189
|
-
}), function (section) {
|
190
|
-
return (0, _react2.jsx)(_index.Item, {
|
191
|
-
key: section.key,
|
192
|
-
items: section.children,
|
193
|
-
title: section.key,
|
194
|
-
hasChildren: section.value.items && true,
|
195
|
-
customProp: {
|
196
|
-
testp: 1
|
197
|
-
}
|
198
|
-
});
|
199
|
-
});
|
200
|
-
};
|
201
161
|
TreeViewComponent.propTypes = {
|
202
162
|
data: _propTypes["default"].arrayOf(_propTypes["default"].shape({}))
|
203
163
|
};
|
@@ -353,87 +313,6 @@ test('disabledKeys prop disables items in the tree -- rendering them unclickable
|
|
353
313
|
expect(thisItem).not.toHaveClass('is-selected');
|
354
314
|
expect(thisItem).toHaveAttribute('aria-selected', 'false');
|
355
315
|
});
|
356
|
-
describe('loadingState', function () {
|
357
|
-
test('should not render loader if tree item is not expanded', function () {
|
358
|
-
(0, _testWrapper.render)((0, _react2.jsx)(AsyncTreeViewComponent, {
|
359
|
-
loadingNodes: [{
|
360
|
-
node: 'Item2',
|
361
|
-
loadingState: true
|
362
|
-
}]
|
363
|
-
}));
|
364
|
-
expect(_testWrapper.screen.queryByRole('alert')).not.toBeInTheDocument();
|
365
|
-
});
|
366
|
-
test('should render loader if tree item is expanded', function () {
|
367
|
-
(0, _testWrapper.render)((0, _react2.jsx)(AsyncTreeViewComponent, {
|
368
|
-
loadingNodes: [{
|
369
|
-
node: 'Item1',
|
370
|
-
loadingState: true
|
371
|
-
}]
|
372
|
-
}));
|
373
|
-
var buttons = _testWrapper.screen.queryAllByRole('button');
|
374
|
-
_userEvent["default"].click(buttons[0]);
|
375
|
-
var listItems = _testWrapper.screen.getAllByRole('row');
|
376
|
-
var thisItem = listItems[0];
|
377
|
-
var loader = (0, _testWrapper.within)(thisItem).getByRole('alert');
|
378
|
-
expect(loader).toBeInTheDocument();
|
379
|
-
});
|
380
|
-
test('should hide loader after children are added to the tree item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
381
|
-
var buttons;
|
382
|
-
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
383
|
-
while (1) switch (_context2.prev = _context2.next) {
|
384
|
-
case 0:
|
385
|
-
(0, _testWrapper.render)((0, _react2.jsx)(AsyncTreeViewComponent, {
|
386
|
-
loadingNodes: [{
|
387
|
-
node: 'Item1',
|
388
|
-
loadingState: true
|
389
|
-
}]
|
390
|
-
}));
|
391
|
-
buttons = _testWrapper.screen.queryAllByRole('button');
|
392
|
-
_testWrapper.fireEvent.click(buttons[0]);
|
393
|
-
(0, _testWrapper.render)((0, _react2.jsx)(AsyncTreeViewComponent, {
|
394
|
-
loadingNodes: [{
|
395
|
-
node: 'Item1',
|
396
|
-
loadingState: false
|
397
|
-
}]
|
398
|
-
}));
|
399
|
-
_testWrapper.fireEvent.click(buttons[0]);
|
400
|
-
expect(_testWrapper.screen.queryByRole('alert')).not.toBeInTheDocument();
|
401
|
-
case 6:
|
402
|
-
case "end":
|
403
|
-
return _context2.stop();
|
404
|
-
}
|
405
|
-
}, _callee);
|
406
|
-
})));
|
407
|
-
test('should add loader to item without children and not other expanded items', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
408
|
-
var buttons, loader;
|
409
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
410
|
-
while (1) switch (_context3.prev = _context3.next) {
|
411
|
-
case 0:
|
412
|
-
(0, _testWrapper.render)((0, _react2.jsx)(AsyncTreeViewComponent, {
|
413
|
-
loadingNodes: [{
|
414
|
-
node: 'Item1',
|
415
|
-
loadingState: true
|
416
|
-
}, {
|
417
|
-
node: 'Item2',
|
418
|
-
loadingState: true
|
419
|
-
}, {
|
420
|
-
node: 'Item4',
|
421
|
-
loadingState: false
|
422
|
-
}]
|
423
|
-
}));
|
424
|
-
buttons = _testWrapper.screen.queryAllByRole('button');
|
425
|
-
_userEvent["default"].click(buttons[0]);
|
426
|
-
_userEvent["default"].click(buttons[1]);
|
427
|
-
_userEvent["default"].click(buttons[2]);
|
428
|
-
loader = _testWrapper.screen.getAllByRole('alert');
|
429
|
-
expect(loader).toHaveLength(2);
|
430
|
-
case 7:
|
431
|
-
case "end":
|
432
|
-
return _context3.stop();
|
433
|
-
}
|
434
|
-
}, _callee2);
|
435
|
-
})));
|
436
|
-
});
|
437
316
|
test('displays correct aria attributes', function () {
|
438
317
|
(0, _testWrapper.render)((0, _react2.jsx)(TreeViewComponent, {
|
439
318
|
data: data
|
@@ -497,10 +376,10 @@ test('onKeyDown does not call passed in prop call back function', function () {
|
|
497
376
|
_userEvent["default"].type(thisItem, '{arrowleft}');
|
498
377
|
expect(callback).not.toHaveBeenCalled();
|
499
378
|
});
|
500
|
-
test('onDragStart calls passed in prop call back function', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function
|
379
|
+
test('onDragStart calls passed in prop call back function', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
501
380
|
var callback, secondCallback, listItems, element, target, dataTransfer;
|
502
|
-
return _regeneratorRuntime().wrap(function
|
503
|
-
while (1) switch (
|
381
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
382
|
+
while (1) switch (_context2.prev = _context2.next) {
|
504
383
|
case 0:
|
505
384
|
callback = jest.fn();
|
506
385
|
secondCallback = jest.fn();
|
@@ -539,7 +418,7 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/(0, _as
|
|
539
418
|
clientY: 51
|
540
419
|
}));
|
541
420
|
expect(target).toHaveAttribute('data-droptarget', 'true');
|
542
|
-
|
421
|
+
_context2.next = 17;
|
543
422
|
return (0, _testWrapper.fireEvent)(target, new _dndMocks.DragEvent('drop', {
|
544
423
|
dataTransfer: dataTransfer,
|
545
424
|
clientX: 51,
|
@@ -549,7 +428,7 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/(0, _as
|
|
549
428
|
(0, _testWrapper.act)(function () {
|
550
429
|
return jest.runAllTimers();
|
551
430
|
});
|
552
|
-
|
431
|
+
_context2.next = 20;
|
553
432
|
return (0, _testWrapper.fireEvent)(element, new _dndMocks.DragEvent('dragend', {
|
554
433
|
dataTransfer: dataTransfer,
|
555
434
|
clientX: 51,
|
@@ -565,9 +444,9 @@ test('onDragStart calls passed in prop call back function', /*#__PURE__*/(0, _as
|
|
565
444
|
});
|
566
445
|
case 23:
|
567
446
|
case "end":
|
568
|
-
return
|
447
|
+
return _context2.stop();
|
569
448
|
}
|
570
|
-
},
|
449
|
+
}, _callee);
|
571
450
|
})));
|
572
451
|
test('items still render if there is only one provided', function () {
|
573
452
|
var callback = jest.fn();
|
@@ -37,7 +37,7 @@ var _hooks = require("../../hooks");
|
|
37
37
|
var _index = require("../../index");
|
38
38
|
var _TreeViewSection = require("./TreeViewSection");
|
39
39
|
var _react2 = require("@emotion/react");
|
40
|
-
var _excluded = ["title", "mainIcon", "lastIcon", "item", "items", "isExpanded", "
|
40
|
+
var _excluded = ["title", "mainIcon", "lastIcon", "item", "items", "isExpanded", "isDragging", "onKeyDown"];
|
41
41
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
42
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
43
43
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -51,7 +51,6 @@ var TreeViewRow = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
51
51
|
item = props.item,
|
52
52
|
items = props.items,
|
53
53
|
isExpanded = props.isExpanded,
|
54
|
-
hasChildren = props.hasChildren,
|
55
54
|
isDragging = props.isDragging,
|
56
55
|
_onKeyDown = props.onKeyDown,
|
57
56
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
@@ -193,7 +192,7 @@ var TreeViewRow = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
193
192
|
onKeyDown: function onKeyDown(e) {
|
194
193
|
_onKeyDown(e);
|
195
194
|
}
|
196
|
-
}), (
|
195
|
+
}), (items === null || items === void 0 ? void 0 : items.length) > 0 && (0, _react2.jsx)(_index.IconButtonToggle, {
|
197
196
|
onToggle: pressIcon,
|
198
197
|
isToggled: isExpanded,
|
199
198
|
defaultIcon: _MenuRightIcon["default"],
|
@@ -246,8 +245,7 @@ TreeViewRow.propTypes = {
|
|
246
245
|
key: _propTypes["default"].string
|
247
246
|
}),
|
248
247
|
mainIcon: _propTypes["default"].elementType,
|
249
|
-
lastIcon: _propTypes["default"].elementType
|
250
|
-
hasChildren: _propTypes["default"].bool
|
248
|
+
lastIcon: _propTypes["default"].elementType
|
251
249
|
};
|
252
250
|
var _default = TreeViewRow;
|
253
251
|
exports["default"] = _default;
|