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