@pingux/astro 2.52.0 → 2.53.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/CopyText/CopyButton.d.ts +4 -0
- package/lib/cjs/components/CopyText/CopyButton.js +6 -7
- package/lib/cjs/components/CopyText/CopyText.d.ts +4 -0
- package/lib/cjs/components/CopyText/CopyText.js +15 -28
- package/lib/cjs/components/CopyText/CopyText.stories.d.ts +7 -0
- package/lib/cjs/components/CopyText/CopyText.stories.js +1 -1
- package/lib/cjs/components/CopyText/CopyText.styles.d.ts +57 -0
- package/lib/cjs/components/CopyText/CopyText.test.d.ts +1 -0
- package/lib/cjs/components/CopyText/CopyText.test.js +81 -79
- package/lib/cjs/components/CopyText/index.d.ts +1 -0
- package/lib/cjs/components/IconButton/IconButton.styles.d.ts +20 -1
- package/lib/cjs/types/copyText.d.ts +25 -0
- package/lib/cjs/types/copyText.js +6 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +37 -26
- package/lib/components/CopyText/CopyButton.js +6 -7
- package/lib/components/CopyText/CopyText.js +15 -28
- package/lib/components/CopyText/CopyText.stories.js +1 -1
- package/lib/components/CopyText/CopyText.test.js +74 -73
- package/lib/types/copyText.js +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +1 -1
@@ -5,7 +5,6 @@ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-sta
|
|
5
5
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
6
|
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
7
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
8
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
10
9
|
import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
|
11
10
|
import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
|
@@ -17,22 +16,22 @@ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
17
16
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
18
17
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
19
18
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
20
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context19; _forEachInstanceProperty(_context19 = ["next", "throw", "return"]).call(_context19, 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 _context20; 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(_context20 = this.tryEntries).call(_context20, 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; }
|
19
|
+
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 _context17; _forEachInstanceProperty(_context17 = ["next", "throw", "return"]).call(_context17, 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 _context18; 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(_context18 = this.tryEntries).call(_context18, 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; }
|
20
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
21
21
|
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; }
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context15, _context16; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context15 = ownKeys(Object(source), !0)).call(_context15, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context16 = ownKeys(Object(source))).call(_context16, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
23
23
|
import React from 'react';
|
24
|
+
import { waitFor } from '@testing-library/react';
|
24
25
|
import userEvent from '@testing-library/user-event';
|
25
26
|
import { Link, Text } from '../..';
|
26
27
|
import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '../../utils/testUtils/testWrapper';
|
27
28
|
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
28
|
-
import CopyText from '
|
29
|
+
import CopyText from './CopyText';
|
29
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
30
31
|
var testId = 'test-copy-text';
|
31
32
|
var originalClipboard = _objectSpread({}, global.navigator.clipboard);
|
32
|
-
var originalExecCommand = global.document.execCommand;
|
33
33
|
var originalGetSelection = window.getSelection;
|
34
|
-
var defaultTest = function defaultTest() {
|
35
|
-
var getComponent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
34
|
+
var defaultTest = function defaultTest(getComponent) {
|
36
35
|
getComponent();
|
37
36
|
var container = screen.getByTestId(testId);
|
38
37
|
expect(container).toBeInstanceOf(HTMLDivElement);
|
@@ -43,17 +42,27 @@ describe('CopyText', function () {
|
|
43
42
|
var mockClipboard = {
|
44
43
|
writeText: jest.fn()
|
45
44
|
};
|
46
|
-
|
45
|
+
_Object$defineProperty(window, 'navigator', {
|
46
|
+
value: {
|
47
|
+
clipboard: mockClipboard
|
48
|
+
},
|
49
|
+
configurable: true
|
50
|
+
});
|
47
51
|
global.document.execCommand = jest.fn();
|
48
|
-
|
52
|
+
jest.spyOn(document, 'execCommand').mockReturnValue(true);
|
49
53
|
var mockGetSelection = jest.fn();
|
50
54
|
mockGetSelection.mockReturnValue('');
|
51
55
|
window.getSelection = mockGetSelection;
|
52
56
|
});
|
53
57
|
afterEach(function () {
|
54
58
|
jest.resetAllMocks();
|
55
|
-
|
56
|
-
|
59
|
+
_Object$defineProperty(window, 'navigator', {
|
60
|
+
value: {
|
61
|
+
clipboard: originalClipboard
|
62
|
+
},
|
63
|
+
configurable: true
|
64
|
+
});
|
65
|
+
jest.spyOn(document, 'execCommand').mockReturnValue(true);
|
57
66
|
window.getSelection = originalGetSelection;
|
58
67
|
});
|
59
68
|
describe('Text mode', function () {
|
@@ -66,7 +75,7 @@ describe('CopyText', function () {
|
|
66
75
|
return render(___EmotionJSX(CopyText, _extends({}, defaultProps, props), ___EmotionJSX(Text, null, textValue)));
|
67
76
|
};
|
68
77
|
|
69
|
-
// Needs to be added to each
|
78
|
+
// Needs to be added to each component's test file
|
70
79
|
universalComponentTests({
|
71
80
|
renderComponent: function renderComponent(props) {
|
72
81
|
return ___EmotionJSX(CopyText, _extends({}, defaultProps, props), ___EmotionJSX(Text, null, textValue));
|
@@ -183,7 +192,10 @@ describe('CopyText', function () {
|
|
183
192
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
184
193
|
while (1) switch (_context8.prev = _context8.next) {
|
185
194
|
case 0:
|
186
|
-
|
195
|
+
_Object$defineProperty(window.navigator, 'clipboard', {
|
196
|
+
value: undefined,
|
197
|
+
writable: true
|
198
|
+
});
|
187
199
|
getComponent();
|
188
200
|
button = screen.getByLabelText('copy to clipboard');
|
189
201
|
_context8.next = 5;
|
@@ -212,11 +224,14 @@ describe('CopyText', function () {
|
|
212
224
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
213
225
|
while (1) switch (_context10.prev = _context10.next) {
|
214
226
|
case 0:
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
227
|
+
_Object$defineProperty(window.navigator, 'clipboard', {
|
228
|
+
value: undefined,
|
229
|
+
writable: true
|
230
|
+
});
|
231
|
+
jest.spyOn(document, 'execCommand').mockReturnValue(false);
|
232
|
+
jest.spyOn(console, 'error').mockImplementation(function () {
|
233
|
+
return false;
|
234
|
+
}); // eslint-disable-line no-console
|
220
235
|
|
221
236
|
getComponent();
|
222
237
|
spy = jest.spyOn(console, 'error');
|
@@ -244,63 +259,46 @@ describe('CopyText', function () {
|
|
244
259
|
}
|
245
260
|
}, _callee10);
|
246
261
|
})));
|
247
|
-
test('after button click, the tooltip renders with the text "Copied!"', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
262
|
+
test('after button click, the tooltip renders with the text "Copied!"', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
248
263
|
var button;
|
249
|
-
return _regeneratorRuntime().wrap(function
|
250
|
-
while (1) switch (
|
264
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
265
|
+
while (1) switch (_context11.prev = _context11.next) {
|
251
266
|
case 0:
|
252
267
|
getComponent();
|
253
268
|
button = screen.getByLabelText('copy to clipboard');
|
254
|
-
|
255
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
256
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
257
|
-
while (1) switch (_context11.prev = _context11.next) {
|
258
|
-
case 0:
|
259
|
-
return _context11.abrupt("return", userEvent.click(button));
|
260
|
-
case 1:
|
261
|
-
case "end":
|
262
|
-
return _context11.stop();
|
263
|
-
}
|
264
|
-
}, _callee11);
|
265
|
-
})));
|
266
|
-
case 4:
|
269
|
+
fireEvent.click(button);
|
267
270
|
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
268
|
-
|
271
|
+
_context11.next = 6;
|
272
|
+
return waitFor(function () {
|
273
|
+
expect(screen.queryByRole('tooltip')).toHaveTextContent('Copied!');
|
274
|
+
});
|
269
275
|
case 6:
|
270
276
|
case "end":
|
271
|
-
return
|
277
|
+
return _context11.stop();
|
272
278
|
}
|
273
|
-
},
|
279
|
+
}, _callee11);
|
274
280
|
})));
|
275
|
-
test('tooltip renders with the text "Copied!" hides after delay', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
281
|
+
test('tooltip renders with the text "Copied!" hides after delay', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
276
282
|
var button;
|
277
|
-
return _regeneratorRuntime().wrap(function
|
278
|
-
while (1) switch (
|
283
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
284
|
+
while (1) switch (_context12.prev = _context12.next) {
|
279
285
|
case 0:
|
280
286
|
getComponent();
|
281
287
|
button = screen.getByLabelText('copy to clipboard');
|
282
|
-
|
283
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
284
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
285
|
-
while (1) switch (_context13.prev = _context13.next) {
|
286
|
-
case 0:
|
287
|
-
return _context13.abrupt("return", userEvent.click(button));
|
288
|
-
case 1:
|
289
|
-
case "end":
|
290
|
-
return _context13.stop();
|
291
|
-
}
|
292
|
-
}, _callee13);
|
293
|
-
})));
|
294
|
-
case 4:
|
288
|
+
fireEvent.click(button);
|
295
289
|
expect(screen.queryByRole('tooltip')).toBeInTheDocument();
|
296
|
-
|
297
|
-
|
290
|
+
_context12.next = 6;
|
291
|
+
return waitFor(function () {
|
292
|
+
expect(screen.queryByRole('tooltip')).toHaveTextContent('Copied!');
|
293
|
+
});
|
294
|
+
case 6:
|
295
|
+
_context12.next = 8;
|
298
296
|
return waitForElementToBeRemoved(screen.queryByRole('tooltip'));
|
299
297
|
case 8:
|
300
298
|
case "end":
|
301
|
-
return
|
299
|
+
return _context12.stop();
|
302
300
|
}
|
303
|
-
},
|
301
|
+
}, _callee12);
|
304
302
|
})));
|
305
303
|
});
|
306
304
|
describe('Link mode', function () {
|
@@ -316,7 +314,7 @@ describe('CopyText', function () {
|
|
316
314
|
}, linkValue)));
|
317
315
|
};
|
318
316
|
|
319
|
-
// Needs to be added to each
|
317
|
+
// Needs to be added to each component's test file
|
320
318
|
universalComponentTests({
|
321
319
|
renderComponent: function renderComponent(props) {
|
322
320
|
return ___EmotionJSX(CopyText, _extends({}, defaultProps, props), ___EmotionJSX(Link, {
|
@@ -347,33 +345,36 @@ describe('CopyText', function () {
|
|
347
345
|
expect(copyBtn).toHaveFocus();
|
348
346
|
expect(copyBtn).toHaveClass('is-focused');
|
349
347
|
});
|
350
|
-
test('click on copy button copies data to the clipboard', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
348
|
+
test('click on copy button copies data to the clipboard', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
351
349
|
var button;
|
352
|
-
return _regeneratorRuntime().wrap(function
|
353
|
-
while (1) switch (
|
350
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
351
|
+
while (1) switch (_context14.prev = _context14.next) {
|
354
352
|
case 0:
|
355
353
|
getComponent();
|
356
354
|
button = screen.getByLabelText('copy to clipboard');
|
357
|
-
|
358
|
-
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
359
|
-
return _regeneratorRuntime().wrap(function
|
360
|
-
while (1) switch (
|
355
|
+
_context14.next = 4;
|
356
|
+
return act( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
357
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
358
|
+
while (1) switch (_context13.prev = _context13.next) {
|
361
359
|
case 0:
|
362
|
-
return
|
360
|
+
return _context13.abrupt("return", userEvent.click(button));
|
363
361
|
case 1:
|
364
362
|
case "end":
|
365
|
-
return
|
363
|
+
return _context13.stop();
|
366
364
|
}
|
367
|
-
},
|
365
|
+
}, _callee13);
|
368
366
|
})));
|
369
367
|
case 4:
|
370
|
-
|
371
|
-
|
372
|
-
|
368
|
+
// If navigator.clipboard is available and in secure context
|
369
|
+
if (navigator.clipboard) {
|
370
|
+
expect(navigator.clipboard.writeText).toBeCalledTimes(1);
|
371
|
+
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(linkValue);
|
372
|
+
}
|
373
|
+
case 5:
|
373
374
|
case "end":
|
374
|
-
return
|
375
|
+
return _context14.stop();
|
375
376
|
}
|
376
|
-
},
|
377
|
+
}, _callee14);
|
377
378
|
})));
|
378
379
|
});
|
379
380
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/lib/types/index.js
CHANGED