@pingux/astro 2.32.0-alpha.11 → 2.32.0-alpha.12
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/ImageUploadField/ImageUploadField.test.js +14 -47
- package/lib/cjs/components/TreeView/TreeView.js +11 -99
- package/lib/cjs/components/TreeView/TreeView.stories.js +10 -23
- package/lib/cjs/components/TreeView/TreeView.styles.js +2 -22
- package/lib/cjs/components/TreeView/TreeView.test.js +11 -91
- package/lib/cjs/components/TreeView/TreeViewItem.js +14 -112
- package/lib/cjs/components/TreeView/TreeViewRow.js +5 -20
- package/lib/cjs/components/TreeView/TreeViewSection.js +16 -164
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.js +6 -9
- package/lib/cjs/hooks/useModalState/useModalState.js +9 -0
- package/lib/cjs/utils/testUtils/testWrapper.js +2 -3
- package/lib/components/ImageUploadField/ImageUploadField.test.js +14 -47
- package/lib/components/TreeView/TreeView.js +12 -100
- package/lib/components/TreeView/TreeView.stories.js +10 -23
- package/lib/components/TreeView/TreeView.styles.js +2 -22
- package/lib/components/TreeView/TreeView.test.js +12 -92
- package/lib/components/TreeView/TreeViewItem.js +14 -111
- package/lib/components/TreeView/TreeViewRow.js +5 -20
- package/lib/components/TreeView/TreeViewSection.js +16 -161
- package/lib/hooks/useImageUploadState/useImageUploadState.js +6 -9
- package/lib/hooks/useModalState/useModalState.js +10 -0
- package/lib/utils/testUtils/testWrapper.js +2 -3
- package/package.json +1 -1
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.js +0 -200
- package/lib/cjs/components/TreeView/TreeViewKeyboardDelegate.test.js +0 -511
- package/lib/cjs/components/TreeView/TreeViewWrapper.js +0 -40
- package/lib/cjs/hooks/useImageUploadState/index.d.ts +0 -1
- package/lib/cjs/hooks/useImageUploadState/useImageUploadState.d.ts +0 -28
- package/lib/cjs/hooks/useModalState/index.d.ts +0 -1
- package/lib/cjs/hooks/useModalState/useModalState.d.ts +0 -21
- package/lib/cjs/hooks/useModalState/useModalState.test.d.ts +0 -1
- package/lib/cjs/utils/testUtils/setupTests.d.ts +0 -4
- package/lib/cjs/utils/testUtils/testAxe.d.ts +0 -2
- package/lib/cjs/utils/testUtils/testTheme.d.ts +0 -21
- package/lib/cjs/utils/testUtils/testWrapper.d.ts +0 -5
- package/lib/components/TreeView/TreeViewKeyboardDelegate.js +0 -176
- package/lib/components/TreeView/TreeViewKeyboardDelegate.test.js +0 -496
- package/lib/components/TreeView/TreeViewWrapper.js +0 -31
@@ -1,7 +1,7 @@
|
|
1
1
|
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
2
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
3
3
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
4
|
-
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 _context9; _forEachInstanceProperty(_context9 = ["next", "throw", "return"]).call(_context9, 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 _context10; 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(_context10 = this.tryEntries).call(_context10, 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; }
|
4
|
+
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 _context8; _forEachInstanceProperty(_context8 = ["next", "throw", "return"]).call(_context8, 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 _context9; 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(_context9 = this.tryEntries).call(_context9, 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; }
|
5
5
|
import _URL from "@babel/runtime-corejs3/core-js-stable/url";
|
6
6
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
7
7
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
@@ -336,43 +336,10 @@ test('loader size can be changed via the prop', function () {
|
|
336
336
|
'font-size': "".concat(testLoaderSize, "px")
|
337
337
|
});
|
338
338
|
});
|
339
|
-
test('should show the menu if label clicked when preview image exists', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
340
|
-
var
|
339
|
+
test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
340
|
+
var customUploadProp, customRemoveProp, imagePreview;
|
341
341
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
342
342
|
while (1) switch (_context6.prev = _context6.next) {
|
343
|
-
case 0:
|
344
|
-
getComponent();
|
345
|
-
imageUploadButton = screen.getByTestId(testButtonId);
|
346
|
-
userEvent.click(imageUploadButton);
|
347
|
-
fireEvent.change(screen.getByTestId('image-upload-input'), {
|
348
|
-
target: {
|
349
|
-
files: [file]
|
350
|
-
}
|
351
|
-
});
|
352
|
-
_context6.next = 6;
|
353
|
-
return screen.findByTestId(imageUploadImagePreview);
|
354
|
-
case 6:
|
355
|
-
imagePreview = _context6.sent;
|
356
|
-
expect(imagePreview).toBeInTheDocument();
|
357
|
-
expect(imagePreview).toHaveAttribute('src');
|
358
|
-
|
359
|
-
// Click on the image preview button
|
360
|
-
imageUploadLabel = screen.getByText(testLabel);
|
361
|
-
fireEvent.click(imageUploadLabel);
|
362
|
-
expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-expanded', 'true');
|
363
|
-
expect(screen.getByRole('menu')).toBeInTheDocument();
|
364
|
-
expect(screen.getByText('Upload New Image')).toBeInTheDocument();
|
365
|
-
expect(screen.getByText('Remove Image')).toBeInTheDocument();
|
366
|
-
case 15:
|
367
|
-
case "end":
|
368
|
-
return _context6.stop();
|
369
|
-
}
|
370
|
-
}, _callee6);
|
371
|
-
})));
|
372
|
-
test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
373
|
-
var customUploadProp, customRemoveProp, imagePreview;
|
374
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
375
|
-
while (1) switch (_context7.prev = _context7.next) {
|
376
343
|
case 0:
|
377
344
|
customUploadProp = 'Custom Upload';
|
378
345
|
customRemoveProp = 'Custom Remove';
|
@@ -385,10 +352,10 @@ test('should show the menu if label clicked when preview image exists with custo
|
|
385
352
|
files: [file]
|
386
353
|
}
|
387
354
|
});
|
388
|
-
|
355
|
+
_context6.next = 6;
|
389
356
|
return screen.findByTestId(imageUploadImagePreview);
|
390
357
|
case 6:
|
391
|
-
imagePreview =
|
358
|
+
imagePreview = _context6.sent;
|
392
359
|
expect(imagePreview).toBeInTheDocument();
|
393
360
|
expect(imagePreview).toHaveAttribute('src');
|
394
361
|
|
@@ -398,9 +365,9 @@ test('should show the menu if label clicked when preview image exists with custo
|
|
398
365
|
expect(screen.getByText(customRemoveProp)).toBeInTheDocument();
|
399
366
|
case 12:
|
400
367
|
case "end":
|
401
|
-
return
|
368
|
+
return _context6.stop();
|
402
369
|
}
|
403
|
-
},
|
370
|
+
}, _callee6);
|
404
371
|
})));
|
405
372
|
test('should render node element if passed as default image', function () {
|
406
373
|
getComponent({
|
@@ -412,10 +379,10 @@ test('should render node element if passed as default image', function () {
|
|
412
379
|
expect(img).toBeInstanceOf(HTMLImageElement);
|
413
380
|
expect(img).toBeInTheDocument();
|
414
381
|
});
|
415
|
-
test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
382
|
+
test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
416
383
|
var imagePreview;
|
417
|
-
return _regeneratorRuntime().wrap(function
|
418
|
-
while (1) switch (
|
384
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
385
|
+
while (1) switch (_context7.prev = _context7.next) {
|
419
386
|
case 0:
|
420
387
|
getComponent({
|
421
388
|
popoverMenuProps: {
|
@@ -427,10 +394,10 @@ test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator( /*#_
|
|
427
394
|
files: [file]
|
428
395
|
}
|
429
396
|
});
|
430
|
-
|
397
|
+
_context7.next = 4;
|
431
398
|
return screen.findByTestId(imageUploadImagePreview);
|
432
399
|
case 4:
|
433
|
-
imagePreview =
|
400
|
+
imagePreview = _context7.sent;
|
434
401
|
expect(imagePreview).toBeInTheDocument();
|
435
402
|
expect(imagePreview).toHaveAttribute('src');
|
436
403
|
|
@@ -441,7 +408,7 @@ test('should implement popover menu props', /*#__PURE__*/_asyncToGenerator( /*#_
|
|
441
408
|
expect(screen.getByRole('presentation')).toHaveAttribute('data-popover-placement', 'right');
|
442
409
|
case 11:
|
443
410
|
case "end":
|
444
|
-
return
|
411
|
+
return _context7.stop();
|
445
412
|
}
|
446
|
-
},
|
413
|
+
}, _callee7);
|
447
414
|
})));
|
@@ -8,14 +8,13 @@ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/obje
|
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
12
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
|
-
var _excluded = ["tree", "disabledKeys", "onExpandedChange"
|
12
|
+
var _excluded = ["tree", "disabledKeys", "onExpandedChange"];
|
14
13
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
15
14
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
16
15
|
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
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
18
|
-
import React, { forwardRef, useImperativeHandle, useMemo, useRef
|
17
|
+
import React, { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
|
19
18
|
import { useTreeState } from 'react-stately';
|
20
19
|
import { useCollator } from '@react-aria/i18n';
|
21
20
|
import { useListBox } from '@react-aria/listbox';
|
@@ -24,7 +23,6 @@ import PropTypes from 'prop-types';
|
|
24
23
|
import { TreeViewContext } from '../../context/TreeViewContext';
|
25
24
|
import { Box, TreeViewItem, TreeViewSection } from '../../index';
|
26
25
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
27
|
-
import TreeViewWrapper from './TreeViewWrapper';
|
28
26
|
|
29
27
|
// split out and exported for ease of use across components
|
30
28
|
// and to facilitate easier testing (eliminates redundant conditional renders)
|
@@ -48,23 +46,11 @@ export function useTreeViewLayout(state) {
|
|
48
46
|
return layout;
|
49
47
|
}
|
50
48
|
var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
51
|
-
var
|
49
|
+
var _context;
|
52
50
|
var tree = props.tree,
|
53
51
|
disabledKeys = props.disabledKeys,
|
54
52
|
onExpandedChange = props.onExpandedChange,
|
55
|
-
onKeyDown = props.onKeyDown,
|
56
|
-
_props$pageLength = props.pageLength,
|
57
|
-
pageLength = _props$pageLength === void 0 ? 5 : _props$pageLength,
|
58
53
|
others = _objectWithoutProperties(props, _excluded);
|
59
|
-
|
60
|
-
// we are tracking the last focused item.
|
61
|
-
// this enables us to have focus jump back to the item, after focus
|
62
|
-
// leaves the tree, and then returns.
|
63
|
-
var _useState = useState(tree === null || tree === void 0 || (_tree$items$ = tree.items[0]) === null || _tree$items$ === void 0 ? void 0 : _tree$items$.key),
|
64
|
-
_useState2 = _slicedToArray(_useState, 2),
|
65
|
-
lastFocusedItem = _useState2[0],
|
66
|
-
setLastFocusedItem = _useState2[1];
|
67
|
-
var level = 0;
|
68
54
|
var treeViewRef = useRef();
|
69
55
|
var selectedKeys = tree.selectedKeys;
|
70
56
|
|
@@ -79,66 +65,7 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
79
65
|
selectionMode: 'single',
|
80
66
|
disallowEmptySelection: true
|
81
67
|
}, others));
|
82
|
-
var
|
83
|
-
var returnArray = [];
|
84
|
-
var checkItemNesting = function checkItemNesting(item) {
|
85
|
-
var _item$value, _item$items;
|
86
|
-
if (((_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.items) === null || _item$value === void 0 ? void 0 : _item$value.length) > 0) {
|
87
|
-
return {
|
88
|
-
isTopLevel: true,
|
89
|
-
hasChildren: true
|
90
|
-
};
|
91
|
-
}
|
92
|
-
if (((_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.length) > 0) {
|
93
|
-
return {
|
94
|
-
isTopLevel: false,
|
95
|
-
hasChildren: true
|
96
|
-
};
|
97
|
-
}
|
98
|
-
return {
|
99
|
-
isTopLevel: false,
|
100
|
-
hasChildren: false
|
101
|
-
};
|
102
|
-
};
|
103
|
-
var checkSection = function checkSection(isRendered, hasItems) {
|
104
|
-
return isRendered && hasItems;
|
105
|
-
};
|
106
|
-
var loop = function loop(data) {
|
107
|
-
for (var i = 0; i < data.length; i += 1) {
|
108
|
-
var obj = {
|
109
|
-
key: data[i].key
|
110
|
-
};
|
111
|
-
returnArray.push(obj);
|
112
|
-
var _checkItemNesting = checkItemNesting(data[i]),
|
113
|
-
hasChildren = _checkItemNesting.hasChildren,
|
114
|
-
isTopLevel = _checkItemNesting.isTopLevel;
|
115
|
-
if (checkSection(state.expandedKeys.has(data[i].key), hasChildren) === true) {
|
116
|
-
if (isTopLevel) {
|
117
|
-
var _data$i$value;
|
118
|
-
loop((_data$i$value = data[i].value) === null || _data$i$value === void 0 ? void 0 : _data$i$value.items);
|
119
|
-
} else {
|
120
|
-
loop(data[i].items);
|
121
|
-
}
|
122
|
-
}
|
123
|
-
}
|
124
|
-
};
|
125
|
-
loop(_data);
|
126
|
-
return returnArray;
|
127
|
-
};
|
128
|
-
|
129
|
-
// list of value pairs of keys and refs
|
130
|
-
// does not need to be in order, because they are values pairs
|
131
|
-
var _useState3 = useState([]),
|
132
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
133
|
-
refArray = _useState4[0],
|
134
|
-
setRefs = _useState4[1];
|
135
|
-
|
136
|
-
// creates a flattened list of keys for up/down keyboard use
|
137
|
-
// this DOES need to be in the same order as the HTML appears in the DOM.
|
138
|
-
// we are essentially turning all rendered items into a flat list, for up/down
|
139
|
-
var flatKeyArray = useMemo(function () {
|
140
|
-
return flattenNestedData(props.items);
|
141
|
-
}, [state.expandedKeys]);
|
68
|
+
var level = 0;
|
142
69
|
var ariaLabel = props['aria-label'];
|
143
70
|
var listBoxOptions = {
|
144
71
|
disabledKeys: disabledKeys,
|
@@ -152,13 +79,7 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
152
79
|
return ___EmotionJSX(TreeViewContext.Provider, {
|
153
80
|
value: {
|
154
81
|
state: state,
|
155
|
-
tree: tree
|
156
|
-
refArray: refArray,
|
157
|
-
setRefs: setRefs,
|
158
|
-
flatKeyArray: flatKeyArray,
|
159
|
-
pageLength: pageLength,
|
160
|
-
setLastFocusedItem: setLastFocusedItem,
|
161
|
-
lastFocusedItem: lastFocusedItem
|
82
|
+
tree: tree
|
162
83
|
}
|
163
84
|
}, ___EmotionJSX(Box, _extends({
|
164
85
|
as: "ul"
|
@@ -167,17 +88,14 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
167
88
|
"aria-label": ariaLabel,
|
168
89
|
role: "treegrid",
|
169
90
|
sx: {
|
170
|
-
overflow: 'hidden'
|
171
|
-
p: '5px',
|
172
|
-
border: 'none !important'
|
91
|
+
overflow: 'hidden'
|
173
92
|
}
|
174
|
-
}, others),
|
93
|
+
}, others), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item, index) {
|
175
94
|
return SectionOrItemRender(item.props.items.length > 0, ___EmotionJSX(TreeViewSection, {
|
176
95
|
item: item,
|
177
96
|
items: item.props.items,
|
178
97
|
title: item.props.title,
|
179
98
|
key: item.props.title,
|
180
|
-
onKeyDown: onKeyDown,
|
181
99
|
level: level + 1,
|
182
100
|
setSize: state.collection.size,
|
183
101
|
position: index
|
@@ -185,19 +103,17 @@ var TreeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
185
103
|
item: item,
|
186
104
|
title: item.value.value.title,
|
187
105
|
key: item.value.value.title,
|
188
|
-
onKeyDown: onKeyDown,
|
189
106
|
level: level + 1,
|
190
|
-
|
191
|
-
|
107
|
+
position: index,
|
108
|
+
setSize: state.collection.size
|
192
109
|
}));
|
193
|
-
})))
|
110
|
+
})));
|
194
111
|
});
|
195
112
|
TreeView.propTypes = {
|
196
113
|
/** data object prop that is required to make the tree function
|
197
114
|
this is returned from the useTreeData hook in React-Aria */
|
198
115
|
tree: PropTypes.shape({
|
199
|
-
selectedKeys: isIterableProp
|
200
|
-
items: isIterableProp
|
116
|
+
selectedKeys: isIterableProp
|
201
117
|
}).isRequired,
|
202
118
|
/** The currently disabled keys in the collection. */
|
203
119
|
disabledKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
@@ -206,10 +122,6 @@ TreeView.propTypes = {
|
|
206
122
|
/** The list of TreeView items. */
|
207
123
|
items: isIterableProp,
|
208
124
|
/** String that describes the treeview when using a screen reader. */
|
209
|
-
'aria-label': PropTypes.string
|
210
|
-
/** Handler that is called when a key is pressed. */
|
211
|
-
onKeyDown: PropTypes.func,
|
212
|
-
/** Number of items to move the focus when page up or page down is pressed */
|
213
|
-
pageLength: PropTypes.number
|
125
|
+
'aria-label': PropTypes.string
|
214
126
|
};
|
215
127
|
export default TreeView;
|
@@ -20,50 +20,36 @@ export default {
|
|
20
20
|
};
|
21
21
|
var data = [{
|
22
22
|
title: 'Policies',
|
23
|
-
key: 'Policies',
|
24
23
|
items: [{
|
25
24
|
title: 'Registration',
|
26
|
-
key: 'Registration',
|
27
25
|
items: [{
|
28
|
-
title: 'Registration A'
|
29
|
-
key: 'Registration A'
|
26
|
+
title: 'Registration A'
|
30
27
|
}, {
|
31
28
|
title: 'Registration B',
|
32
|
-
key: 'Registration B',
|
33
29
|
items: [{
|
34
|
-
title: 'Registration B1'
|
35
|
-
key: 'Registration B1'
|
30
|
+
title: 'Registration B1'
|
36
31
|
}, {
|
37
|
-
title: 'Registration B2'
|
38
|
-
key: 'Registration B2'
|
32
|
+
title: 'Registration B2'
|
39
33
|
}]
|
40
34
|
}, {
|
41
|
-
title: 'Registration C'
|
42
|
-
key: 'Registration C'
|
35
|
+
title: 'Registration C'
|
43
36
|
}, {
|
44
|
-
title: 'Registration D'
|
45
|
-
key: 'Registration D'
|
37
|
+
title: 'Registration D'
|
46
38
|
}]
|
47
39
|
}, {
|
48
40
|
title: 'Authentication',
|
49
|
-
key: 'Authentication',
|
50
41
|
items: [{
|
51
|
-
title: 'Authentication A'
|
52
|
-
key: 'Authentication A'
|
42
|
+
title: 'Authentication A'
|
53
43
|
}, {
|
54
|
-
title: 'Authentication B'
|
55
|
-
key: 'Authentication B'
|
44
|
+
title: 'Authentication B'
|
56
45
|
}]
|
57
46
|
}]
|
58
47
|
}, {
|
59
48
|
title: 'Other',
|
60
|
-
key: 'Other',
|
61
49
|
items: [{
|
62
|
-
title: 'Other A'
|
63
|
-
key: 'Other A'
|
50
|
+
title: 'Other A'
|
64
51
|
}]
|
65
52
|
}, {
|
66
|
-
key: 'Single Item',
|
67
53
|
title: 'Single Item'
|
68
54
|
}];
|
69
55
|
export var Default = function Default(args) {
|
@@ -79,7 +65,8 @@ export var Default = function Default(args) {
|
|
79
65
|
return ___EmotionJSX(TreeView, _extends({}, args, {
|
80
66
|
items: tree.items,
|
81
67
|
tree: tree,
|
82
|
-
"aria-label": "Example Tree"
|
68
|
+
"aria-label": "Example Tree",
|
69
|
+
disabledKeys: ['Single Item']
|
83
70
|
}), function (section) {
|
84
71
|
var _section$value;
|
85
72
|
return ___EmotionJSX(Item, {
|
@@ -3,7 +3,7 @@ var treeRow = {
|
|
3
3
|
cursor: 'pointer',
|
4
4
|
height: '31px',
|
5
5
|
outline: 'none',
|
6
|
-
'&.is-selected, &.is-hovered': {
|
6
|
+
'&.is-selected, &.is-hovered, &.is-focused': {
|
7
7
|
backgroundColor: 'active',
|
8
8
|
'& span': {
|
9
9
|
color: 'white'
|
@@ -17,28 +17,8 @@ var treeRow = {
|
|
17
17
|
},
|
18
18
|
'&.is-expanded': {
|
19
19
|
marginBottom: 'xs'
|
20
|
-
},
|
21
|
-
'& :focus': {
|
22
|
-
border: 'none'
|
23
20
|
}
|
24
21
|
};
|
25
|
-
var wrapper = {
|
26
|
-
'&.is-focused': {
|
27
|
-
boxSizing: 'unset',
|
28
|
-
outline: '1px solid',
|
29
|
-
outlineColor: 'focus',
|
30
|
-
outlineOffset: '2px'
|
31
|
-
},
|
32
|
-
width: '100%',
|
33
|
-
':not(:last-child)': {
|
34
|
-
mb: 'sm'
|
35
|
-
},
|
36
|
-
':focus': {
|
37
|
-
border: 'none'
|
38
|
-
},
|
39
|
-
outline: 'none'
|
40
|
-
};
|
41
22
|
export default {
|
42
|
-
treeRow: treeRow
|
43
|
-
wrapper: wrapper
|
23
|
+
treeRow: treeRow
|
44
24
|
};
|
@@ -1,13 +1,9 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import { useTreeData } from 'react-stately';
|
4
|
-
import userEvent from '@testing-library/user-event';
|
5
|
-
import PropTypes from 'prop-types';
|
6
4
|
import { Item } from '../../index';
|
7
|
-
import { render, screen } from '../../utils/testUtils/testWrapper';
|
5
|
+
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
8
6
|
import { SectionOrItemRender } from './TreeView';
|
9
|
-
import { refArray } from './TreeViewKeyboardDelegate.test';
|
10
|
-
import { addRefToArrayHelper, removeRefFromArrayHelper } from './TreeViewSection';
|
11
7
|
import TreeView from '.';
|
12
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
9
|
var testId = 'test-TreeView';
|
@@ -44,12 +40,9 @@ var data = [{
|
|
44
40
|
}, {
|
45
41
|
title: 'Single Item'
|
46
42
|
}];
|
47
|
-
var singleData = [{
|
48
|
-
title: 'Single Item'
|
49
|
-
}];
|
50
43
|
var TreeViewComponent = function TreeViewComponent(props) {
|
51
44
|
var tree = useTreeData({
|
52
|
-
initialItems:
|
45
|
+
initialItems: data,
|
53
46
|
getKey: function getKey(item) {
|
54
47
|
return item.title;
|
55
48
|
},
|
@@ -69,9 +62,6 @@ var TreeViewComponent = function TreeViewComponent(props) {
|
|
69
62
|
});
|
70
63
|
});
|
71
64
|
};
|
72
|
-
TreeViewComponent.propTypes = {
|
73
|
-
data: PropTypes.arrayOf(PropTypes.shape({}))
|
74
|
-
};
|
75
65
|
var offsetWidth;
|
76
66
|
var offsetHeight;
|
77
67
|
var scrollHeight;
|
@@ -105,20 +95,16 @@ test('TreeView component does load', function () {
|
|
105
95
|
expect(element).toBeInTheDocument();
|
106
96
|
});
|
107
97
|
test('Can select an Item using the mouse', function () {
|
108
|
-
render(___EmotionJSX(TreeViewComponent,
|
109
|
-
data: data
|
110
|
-
}));
|
98
|
+
render(___EmotionJSX(TreeViewComponent, null));
|
111
99
|
var element = screen.queryByRole('treegrid');
|
112
100
|
expect(element).toBeInTheDocument();
|
113
101
|
var peopleElement = screen.queryByText('Single Item');
|
114
102
|
expect(peopleElement).not.toHaveClass('is-selected');
|
115
|
-
|
103
|
+
fireEvent.click(peopleElement);
|
116
104
|
expect(peopleElement).toHaveClass('is-selected');
|
117
105
|
});
|
118
106
|
test('Renders both Sections and Items', function () {
|
119
|
-
render(___EmotionJSX(TreeViewComponent,
|
120
|
-
data: data
|
121
|
-
}));
|
107
|
+
render(___EmotionJSX(TreeViewComponent, null));
|
122
108
|
var peopleElement = screen.getByText('Single Item');
|
123
109
|
expect(peopleElement).toBeInTheDocument();
|
124
110
|
var plantElement = screen.getByText('Other');
|
@@ -127,9 +113,7 @@ test('Renders both Sections and Items', function () {
|
|
127
113
|
expect(allListItems).toHaveLength(3);
|
128
114
|
});
|
129
115
|
test('Can expand an Item using the mouse', function () {
|
130
|
-
render(___EmotionJSX(TreeViewComponent,
|
131
|
-
data: data
|
132
|
-
}));
|
116
|
+
render(___EmotionJSX(TreeViewComponent, null));
|
133
117
|
|
134
118
|
// The children of collapsed sections will not
|
135
119
|
// be rendered by default.
|
@@ -138,91 +122,47 @@ test('Can expand an Item using the mouse', function () {
|
|
138
122
|
// Clicking the dropdown icon, renders the children
|
139
123
|
// of the collapsed section.
|
140
124
|
var buttons = screen.queryAllByRole('button');
|
141
|
-
|
125
|
+
fireEvent.click(buttons[0]);
|
142
126
|
expect(screen.queryByText(data[0].items[0].title)).toBeInTheDocument();
|
143
127
|
});
|
144
128
|
test('onExpandedChange change prop calls when used', function () {
|
145
129
|
var onPress = jest.fn();
|
146
130
|
render(___EmotionJSX(TreeViewComponent, {
|
147
|
-
data: data,
|
148
131
|
onExpandedChange: onPress
|
149
132
|
}));
|
150
133
|
expect(onPress).not.toHaveBeenCalled();
|
151
134
|
var buttons = screen.queryAllByRole('button');
|
152
|
-
|
135
|
+
fireEvent.click(buttons[0]);
|
153
136
|
expect(onPress).toHaveBeenCalled();
|
154
137
|
});
|
155
138
|
test('disabledKeys prop disables items in the tree -- rendering them unclickable', function () {
|
156
139
|
render(___EmotionJSX(TreeViewComponent, {
|
157
|
-
data: data,
|
158
140
|
disabledKeys: ['Single Item']
|
159
141
|
}));
|
160
142
|
var listItems = screen.queryAllByRole('treeitem');
|
161
143
|
var thisItem = listItems[2];
|
162
144
|
expect(thisItem).not.toHaveClass('is-selected');
|
163
145
|
expect(thisItem).toHaveAttribute('aria-disabled', 'true');
|
164
|
-
|
146
|
+
fireEvent.mouseDown(thisItem);
|
147
|
+
fireEvent.mouseUp(thisItem);
|
165
148
|
expect(thisItem).not.toHaveClass('is-selected');
|
166
149
|
expect(thisItem).toHaveAttribute('aria-selected', 'false');
|
167
150
|
});
|
168
151
|
test('displays correct aria attributes', function () {
|
169
|
-
render(___EmotionJSX(TreeViewComponent,
|
170
|
-
data: data
|
171
|
-
}));
|
152
|
+
render(___EmotionJSX(TreeViewComponent, null));
|
172
153
|
var listItems = screen.getAllByRole('treeitem');
|
173
154
|
var lastTreeItem = listItems[2];
|
174
155
|
expect(lastTreeItem).toHaveAttribute('aria-level', '1');
|
175
156
|
expect(lastTreeItem).toHaveAttribute('aria-posinset', '3');
|
176
157
|
expect(lastTreeItem).toHaveAttribute('aria-setsize', '3');
|
177
158
|
var buttons = screen.queryAllByRole('button');
|
178
|
-
|
159
|
+
fireEvent.click(buttons[1]);
|
179
160
|
var expandedItems = screen.getAllByRole('treeitem');
|
180
161
|
var nestedItem = expandedItems[2];
|
181
162
|
expect(nestedItem).toHaveAttribute('aria-level', '2');
|
182
163
|
expect(nestedItem).toHaveAttribute('aria-posinset', '1');
|
183
164
|
expect(nestedItem).toHaveAttribute('aria-setsize', '1');
|
184
165
|
});
|
185
|
-
test('onKeyDown calls passed in prop call back function', function () {
|
186
|
-
var callback = jest.fn();
|
187
|
-
render(___EmotionJSX(TreeViewComponent, {
|
188
|
-
data: data,
|
189
|
-
onKeyDown: callback
|
190
|
-
}));
|
191
|
-
var listItems = screen.queryAllByRole('treeitem');
|
192
|
-
var thisItem = listItems[0];
|
193
|
-
userEvent.type(thisItem, '{arrowleft}');
|
194
|
-
expect(callback).toHaveBeenCalled();
|
195
|
-
});
|
196
|
-
test('onKeyDown calls passed in prop call back function', function () {
|
197
|
-
var callback = jest.fn();
|
198
|
-
render(___EmotionJSX(TreeViewComponent, {
|
199
|
-
data: data,
|
200
|
-
onKeyDown: callback
|
201
|
-
}));
|
202
|
-
var listItems = screen.queryAllByRole('treeitem');
|
203
|
-
var thisItem = listItems[2];
|
204
|
-
userEvent.type(thisItem, '{arrowleft}');
|
205
|
-
expect(callback).toHaveBeenCalled();
|
206
|
-
});
|
207
|
-
test('onKeyDown does not call passed in prop call back function', function () {
|
208
|
-
var callback = jest.fn();
|
209
|
-
render(___EmotionJSX(TreeViewComponent, {
|
210
|
-
data: data
|
211
|
-
}));
|
212
|
-
var listItems = screen.queryAllByRole('treeitem');
|
213
|
-
var thisItem = listItems[2];
|
214
|
-
userEvent.type(thisItem, '{arrowleft}');
|
215
|
-
expect(callback).not.toHaveBeenCalled();
|
216
|
-
});
|
217
|
-
test('items still render if there is only one provided', function () {
|
218
|
-
var callback = jest.fn();
|
219
|
-
render(___EmotionJSX(TreeViewComponent, {
|
220
|
-
data: singleData,
|
221
|
-
onKeyDown: callback
|
222
|
-
}));
|
223
|
-
var listItem = screen.queryByText('Single Item');
|
224
|
-
expect(listItem).toBeInTheDocument();
|
225
|
-
});
|
226
166
|
var firstJSX = ___EmotionJSX("p", null, "first");
|
227
167
|
var secondJSX = ___EmotionJSX("p", null, "second");
|
228
168
|
test('Section or Item Render renders first item if condition is true', function () {
|
@@ -236,24 +176,4 @@ test('Section or Item Render renders second item if condition is false', functio
|
|
236
176
|
var thisItem = screen.getByText('second');
|
237
177
|
expect(thisItem).toBeInTheDocument();
|
238
178
|
expect(screen.queryByText('first')).not.toBeInTheDocument();
|
239
|
-
});
|
240
|
-
test('Handler function removes ref from array', function () {
|
241
|
-
var newArray = removeRefFromArrayHelper(refArray, 'test');
|
242
|
-
expect(newArray).toHaveLength(2);
|
243
|
-
});
|
244
|
-
test('Handler function does not remove ref from array', function () {
|
245
|
-
var newArray = removeRefFromArrayHelper(refArray, 'anothertest');
|
246
|
-
expect(newArray).toHaveLength(3);
|
247
|
-
});
|
248
|
-
test('Handler function does add ref to array', function () {
|
249
|
-
var newArray = addRefToArrayHelper(refArray, 'yetanothertest', {
|
250
|
-
current: 'currentlystilltesting'
|
251
|
-
});
|
252
|
-
expect(newArray).toHaveLength(4);
|
253
|
-
});
|
254
|
-
test('Handler function does not add ref to array', function () {
|
255
|
-
var newArray = addRefToArrayHelper(refArray, 'test', {
|
256
|
-
current: 'currentlystilltesting'
|
257
|
-
});
|
258
|
-
expect(newArray).toHaveLength(3);
|
259
179
|
});
|