@pingux/astro 2.111.0-alpha.2 → 2.111.0-alpha.3
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/AIComponents/Attachment/Attachment.d.ts +6 -1
- package/lib/cjs/components/AIComponents/Attachment/Attachment.js +4 -2
- package/lib/cjs/components/AIComponents/PromptInput/PromptInput.js +34 -12
- package/lib/cjs/components/AIComponents/PromptInput/PromptInput.stories.js +3 -5
- package/lib/cjs/components/AIComponents/PromptInput/PromptInput.test.js +131 -127
- package/lib/cjs/components/AIComponents/PromptInput/PromptUploadButton.js +17 -6
- package/lib/cjs/hooks/useField/useField.d.ts +8 -2
- package/lib/cjs/hooks/useField/useField.js +4 -3
- package/lib/cjs/hooks/useField/useField.test.js +4 -4
- package/lib/cjs/hooks/useSelectField/useSelectField.d.ts +1 -0
- package/lib/cjs/types/promptInput.d.ts +8 -9
- package/lib/cjs/types/textField.d.ts +1 -1
- package/lib/components/AIComponents/Attachment/Attachment.js +4 -2
- package/lib/components/AIComponents/PromptInput/PromptInput.js +34 -11
- package/lib/components/AIComponents/PromptInput/PromptInput.stories.js +3 -5
- package/lib/components/AIComponents/PromptInput/PromptInput.test.js +134 -126
- package/lib/components/AIComponents/PromptInput/PromptUploadButton.js +18 -6
- package/lib/hooks/useField/useField.js +10 -9
- package/lib/hooks/useField/useField.test.js +4 -4
- package/package.json +1 -1
@@ -1,8 +1,3 @@
|
|
1
|
-
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
2
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
3
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
4
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, 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 _context8; 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(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
5
|
-
import _URL from "@babel/runtime-corejs3/core-js-stable/url";
|
6
1
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
7
2
|
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
8
3
|
import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
|
@@ -12,54 +7,51 @@ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object
|
|
12
7
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
13
8
|
import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
|
14
9
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
15
|
-
import
|
10
|
+
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
11
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
12
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
13
|
+
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 _context6; _forEachInstanceProperty(_context6 = ["next", "throw", "return"]).call(_context6, 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 _context7; 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(_context7 = this.tryEntries).call(_context7, 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; }
|
14
|
+
import _URL from "@babel/runtime-corejs3/core-js-stable/url";
|
15
|
+
import React from 'react';
|
16
16
|
import GlobeIcon from '@pingux/mdi-react/GlobeIcon';
|
17
|
-
import
|
18
|
-
import {
|
17
|
+
import userEvent from '@testing-library/user-event';
|
18
|
+
import { render, screen } from '../../../utils/testUtils/testWrapper';
|
19
|
+
import { universalComponentTests } from '../../../utils/testUtils/universalComponentTest';
|
19
20
|
import { getFileExtension } from '../Attachment/Attachment';
|
20
21
|
import PromptInput from './PromptInput';
|
21
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
23
|
+
var onSubmitCallback = jest.fn();
|
24
|
+
var onCancelCallback = jest.fn();
|
25
|
+
var onChangeCallback = jest.fn();
|
26
|
+
var onFileChangeCallback = jest.fn();
|
27
|
+
var originalValue = _URL.createObjectURL;
|
22
28
|
var testFileURL = 'test-file-url';
|
23
29
|
var testFileName = 'chucknorris.png';
|
24
30
|
var testFile = new File(['(⌐□_□)'], testFileName, {
|
25
31
|
type: 'image/png'
|
26
32
|
});
|
27
|
-
var
|
28
|
-
var
|
29
|
-
var
|
30
|
-
var
|
31
|
-
var
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
themeOverrides: [NextGenTheme]
|
38
|
-
}, ___EmotionJSX(PromptInput, {
|
39
|
-
placeholder: "Enter a prompt here",
|
40
|
-
onChange: function onChange(e) {
|
41
|
-
setValue(e.target.value);
|
42
|
-
onChangeCallback(e);
|
43
|
-
},
|
44
|
-
onSubmit: onSubmitCallback,
|
45
|
-
onCancel: onCancelCallback,
|
46
|
-
onFileChange: onFileChangeCallback,
|
47
|
-
value: value,
|
48
|
-
"data-testid": "testid",
|
49
|
-
label: "chat prompt",
|
50
|
-
isLoading: props.isLoading,
|
51
|
-
attachmentProps: {
|
52
|
-
icon: props.attachmentIcon,
|
53
|
-
iconWrapperProps: {
|
54
|
-
'data-testid': 'icon-wrapper'
|
55
|
-
}
|
56
|
-
},
|
57
|
-
uploadButtonProps: {
|
58
|
-
'data-testid': 'upload button'
|
59
|
-
}
|
60
|
-
}));
|
33
|
+
var buttonTestId = 'upload button';
|
34
|
+
var testId = 'test-id';
|
35
|
+
var testId2 = 'test-id-2';
|
36
|
+
var testLabel = 'Test Label';
|
37
|
+
var testValue = 'test value';
|
38
|
+
var defaultProps = {
|
39
|
+
'data-testid': testId,
|
40
|
+
controlProps: {
|
41
|
+
'aria-label': testLabel
|
42
|
+
}
|
61
43
|
};
|
62
|
-
var
|
44
|
+
var getComponent = function getComponent() {
|
45
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
46
|
+
return render(___EmotionJSX(PromptInput, _extends({}, defaultProps, props)));
|
47
|
+
};
|
48
|
+
|
49
|
+
// Needs to be added to each components test file
|
50
|
+
universalComponentTests({
|
51
|
+
renderComponent: function renderComponent(props) {
|
52
|
+
return ___EmotionJSX(PromptInput, _extends({}, defaultProps, props));
|
53
|
+
}
|
54
|
+
});
|
63
55
|
beforeAll(function () {
|
64
56
|
_URL.createObjectURL = jest.fn(function () {
|
65
57
|
return testFileURL;
|
@@ -71,144 +63,160 @@ afterAll(function () {
|
|
71
63
|
afterEach(function () {
|
72
64
|
jest.resetAllMocks();
|
73
65
|
});
|
74
|
-
test('
|
75
|
-
|
66
|
+
test('default PromptInput', function () {
|
67
|
+
getComponent();
|
68
|
+
var field = screen.getByTestId(testId);
|
69
|
+
var control = screen.getByLabelText(testLabel);
|
70
|
+
expect(field).toBeInstanceOf(HTMLDivElement);
|
71
|
+
expect(control).toBeInstanceOf(HTMLInputElement);
|
72
|
+
expect(field).toBeInTheDocument();
|
73
|
+
expect(control).toBeInTheDocument();
|
74
|
+
});
|
75
|
+
test('onChange and value props work correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
76
|
+
var control;
|
76
77
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
77
78
|
while (1) switch (_context.prev = _context.next) {
|
78
79
|
case 0:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
getComponent({
|
81
|
+
onChange: onChangeCallback
|
82
|
+
});
|
83
|
+
control = screen.getByLabelText(testLabel);
|
84
|
+
_context.next = 4;
|
85
|
+
return userEvent.type(control, testValue);
|
86
|
+
case 4:
|
87
|
+
expect(control).toHaveValue(testValue);
|
88
|
+
expect(onChangeCallback).toHaveBeenCalledTimes(testValue.length);
|
89
|
+
case 6:
|
83
90
|
case "end":
|
84
91
|
return _context.stop();
|
85
92
|
}
|
86
93
|
}, _callee);
|
87
94
|
})));
|
88
|
-
test('
|
89
|
-
var
|
95
|
+
test('onSubmit prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
96
|
+
var control;
|
90
97
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
91
98
|
while (1) switch (_context2.prev = _context2.next) {
|
92
99
|
case 0:
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
target: {
|
98
|
-
value: testValue
|
100
|
+
getComponent({
|
101
|
+
onSubmit: onSubmitCallback,
|
102
|
+
uploadButtonProps: {
|
103
|
+
'data-testid': buttonTestId
|
99
104
|
}
|
100
105
|
});
|
101
|
-
|
102
|
-
|
103
|
-
|
106
|
+
control = screen.getByLabelText(testLabel); // Try to click before entering a value
|
107
|
+
userEvent.click(screen.getByTestId(buttonTestId));
|
108
|
+
expect(screen.getByTestId(buttonTestId)).toBeDisabled();
|
109
|
+
expect(onSubmitCallback).toHaveBeenCalledTimes(0);
|
110
|
+
|
111
|
+
// Enter a value and click
|
112
|
+
_context2.next = 7;
|
113
|
+
return userEvent.type(control, testValue);
|
114
|
+
case 7:
|
115
|
+
userEvent.click(screen.getByTestId(buttonTestId));
|
116
|
+
expect(onSubmitCallback).toHaveBeenCalledTimes(1);
|
117
|
+
case 9:
|
104
118
|
case "end":
|
105
119
|
return _context2.stop();
|
106
120
|
}
|
107
121
|
}, _callee2);
|
108
122
|
})));
|
109
|
-
test('
|
110
|
-
var
|
123
|
+
test('onCancel prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
124
|
+
var control;
|
111
125
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
112
126
|
while (1) switch (_context3.prev = _context3.next) {
|
113
127
|
case 0:
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
target: {
|
120
|
-
value: testValue
|
128
|
+
getComponent({
|
129
|
+
isLoading: true,
|
130
|
+
onCancel: onCancelCallback,
|
131
|
+
uploadButtonProps: {
|
132
|
+
'data-testid': buttonTestId
|
121
133
|
}
|
122
134
|
});
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
case
|
135
|
+
control = screen.getByLabelText(testLabel); // Click the button
|
136
|
+
_context3.next = 4;
|
137
|
+
return userEvent.type(control, testValue);
|
138
|
+
case 4:
|
139
|
+
userEvent.click(screen.getByTestId(buttonTestId));
|
140
|
+
expect(onCancelCallback).toHaveBeenCalledTimes(1);
|
141
|
+
case 6:
|
127
142
|
case "end":
|
128
143
|
return _context3.stop();
|
129
144
|
}
|
130
145
|
}, _callee3);
|
131
146
|
})));
|
132
|
-
test('
|
133
|
-
var
|
147
|
+
test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
148
|
+
var fileInput, removeButton;
|
134
149
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
135
150
|
while (1) switch (_context4.prev = _context4.next) {
|
136
151
|
case 0:
|
137
|
-
|
138
|
-
isLoading: true
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
152
|
+
getComponent({
|
153
|
+
isLoading: true,
|
154
|
+
onCancel: onCancelCallback,
|
155
|
+
onFileChange: onFileChangeCallback,
|
156
|
+
uploadButtonProps: {
|
157
|
+
'data-testid': buttonTestId
|
158
|
+
},
|
159
|
+
attachmentProps: {
|
160
|
+
icon: GlobeIcon,
|
161
|
+
iconWrapperProps: {
|
162
|
+
'data-testid': testId2
|
163
|
+
}
|
146
164
|
}
|
147
165
|
});
|
148
|
-
fireEvent.mouseDown(button);
|
149
|
-
fireEvent.mouseUp(button);
|
150
|
-
expect(onCancelCallback).toHaveBeenCalledTimes(1);
|
151
|
-
case 8:
|
152
|
-
case "end":
|
153
|
-
return _context4.stop();
|
154
|
-
}
|
155
|
-
}, _callee4);
|
156
|
-
})));
|
157
|
-
test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
158
|
-
var fileInput, removeButton;
|
159
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
160
|
-
while (1) switch (_context5.prev = _context5.next) {
|
161
|
-
case 0:
|
162
|
-
render(___EmotionJSX(PromptInputStory, {
|
163
|
-
attachmentIcon: GlobeIcon
|
164
|
-
}));
|
165
166
|
fileInput = screen.getAllByLabelText('add attachment')[0];
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
}
|
170
|
-
});
|
167
|
+
_context4.next = 4;
|
168
|
+
return userEvent.upload(fileInput, testFile);
|
169
|
+
case 4:
|
171
170
|
expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
|
172
171
|
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
173
|
-
expect(screen.getByTestId(
|
172
|
+
expect(screen.getByTestId(testId2)).toBeInTheDocument();
|
174
173
|
removeButton = screen.getByTestId('remove-attachment');
|
175
|
-
|
176
|
-
fireEvent.mouseUp(removeButton);
|
174
|
+
userEvent.click(removeButton);
|
177
175
|
expect(onFileChangeCallback).toHaveBeenCalledTimes(2);
|
178
176
|
expect(screen.queryByText(testFileName)).not.toBeInTheDocument();
|
179
|
-
expect(screen.queryByTestId(
|
177
|
+
expect(screen.queryByTestId(testId2)).not.toBeInTheDocument();
|
180
178
|
case 12:
|
181
179
|
case "end":
|
182
|
-
return
|
180
|
+
return _context4.stop();
|
183
181
|
}
|
184
|
-
},
|
182
|
+
}, _callee4);
|
185
183
|
})));
|
186
|
-
test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
184
|
+
test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
187
185
|
var fileInput, removeButton;
|
188
|
-
return _regeneratorRuntime().wrap(function
|
189
|
-
while (1) switch (
|
186
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
187
|
+
while (1) switch (_context5.prev = _context5.next) {
|
190
188
|
case 0:
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
189
|
+
getComponent({
|
190
|
+
isLoading: true,
|
191
|
+
onCancel: onCancelCallback,
|
192
|
+
onFileChange: onFileChangeCallback,
|
193
|
+
uploadButtonProps: {
|
194
|
+
'data-testid': buttonTestId
|
195
|
+
},
|
196
|
+
attachmentProps: {
|
197
|
+
icon: GlobeIcon,
|
198
|
+
iconWrapperProps: {
|
199
|
+
'data-testid': testId2
|
200
|
+
}
|
196
201
|
}
|
197
202
|
});
|
203
|
+
fileInput = screen.getAllByLabelText('add attachment')[0];
|
204
|
+
_context5.next = 4;
|
205
|
+
return userEvent.upload(fileInput, testFile);
|
206
|
+
case 4:
|
198
207
|
expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
|
199
208
|
expect(screen.getByText(testFileName)).toBeInTheDocument();
|
200
|
-
expect(screen.getByTestId(
|
209
|
+
expect(screen.getByTestId(testId2)).toBeInTheDocument();
|
201
210
|
removeButton = screen.getByTestId('remove-attachment');
|
202
|
-
|
203
|
-
fireEvent.mouseUp(removeButton);
|
211
|
+
userEvent.click(removeButton);
|
204
212
|
expect(onFileChangeCallback).toHaveBeenCalledTimes(2);
|
205
213
|
expect(screen.queryByText(testFileName)).not.toBeInTheDocument();
|
206
|
-
expect(screen.queryByTestId(
|
214
|
+
expect(screen.queryByTestId(testId2)).not.toBeInTheDocument();
|
207
215
|
case 12:
|
208
216
|
case "end":
|
209
|
-
return
|
217
|
+
return _context5.stop();
|
210
218
|
}
|
211
|
-
},
|
219
|
+
}, _callee5);
|
212
220
|
})));
|
213
221
|
test('regex expression', function () {
|
214
222
|
var string = 'alongiflename.txt';
|
@@ -1,6 +1,17 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
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";
|
1
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
2
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
12
|
var _excluded = ["isLoading", "onCancel", "onSubmit", "value", "uploadButtonContainerProps"];
|
13
|
+
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; }
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
15
|
import React from 'react';
|
5
16
|
import ArrowUpIcon from '@pingux/mdi-react/ArrowUpIcon';
|
6
17
|
import StopIcon from '@pingux/mdi-react/StopIcon';
|
@@ -17,18 +28,19 @@ var PromptUploadButton = function PromptUploadButton(props) {
|
|
17
28
|
if (isLoading && onCancel) {
|
18
29
|
onCancel(e);
|
19
30
|
} else if (onSubmit) {
|
20
|
-
onSubmit(e);
|
31
|
+
onSubmit(e, value);
|
21
32
|
}
|
22
33
|
};
|
23
34
|
return ___EmotionJSX(Box, uploadButtonContainerProps, ___EmotionJSX(IconButton, _extends({
|
24
35
|
"aria-label": "upload chat",
|
25
|
-
isDisabled: !isLoading && value.length === 0,
|
36
|
+
isDisabled: !isLoading && (typeof value === 'undefined' || (value === null || value === void 0 ? void 0 : value.length) === 0),
|
26
37
|
variant: "inverted",
|
27
|
-
sx: {
|
28
|
-
size: '24px'
|
29
|
-
},
|
30
38
|
onPress: onPress
|
31
|
-
}, others
|
39
|
+
}, others, {
|
40
|
+
sx: _objectSpread({
|
41
|
+
size: '24px'
|
42
|
+
}, others === null || others === void 0 ? void 0 : others.sx)
|
43
|
+
}), ___EmotionJSX(Icon, {
|
32
44
|
size: "xs",
|
33
45
|
icon: isLoading ? StopIcon : ArrowUpIcon
|
34
46
|
})));
|
@@ -1,3 +1,10 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
+
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "className", "containerProps", "controlProps", "defaultValue", "hasAutoFocus", "hasNoStatusIndicator", "hintText", "id", "isDefaultSelected", "isDisabled", "isIndeterminate", "isReadOnly", "isRequired", "isRestrictiveMultivalues", "label", "labelMode", "labelProps", "maxLength", "name", "onBlur", "onChange", "onFocus", "placeholder", "role", "spellCheck", "status", "statusClasses", "type", "value", "wrapperProps"];
|
5
|
+
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; }
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
|
+
import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
|
1
8
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
9
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
10
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
@@ -6,12 +13,6 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
6
13
|
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
14
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
15
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
11
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
-
var _excluded = ["autocomplete", "autoComplete", "autoCorrect", "className", "containerProps", "controlProps", "defaultValue", "hasAutoFocus", "hasNoStatusIndicator", "hintText", "id", "isDefaultSelected", "isDisabled", "isIndeterminate", "isReadOnly", "isRequired", "isRestrictiveMultivalues", "label", "labelMode", "labelProps", "maxLength", "name", "onBlur", "onChange", "onFocus", "placeholder", "role", "spellCheck", "status", "statusClasses", "type", "value", "wrapperProps"];
|
13
|
-
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; }
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
16
|
import { useEffect, useState } from 'react';
|
16
17
|
import { mergeProps, useFocusRing, useLabel } from 'react-aria';
|
17
18
|
import { useFocusWithin } from '@react-aria/interactions';
|
@@ -88,9 +89,9 @@ var useField = function useField(props) {
|
|
88
89
|
|
89
90
|
// Capture value changes so we can apply the has-value class to the container
|
90
91
|
var fieldOnChange = function fieldOnChange(e) {
|
91
|
-
var
|
92
|
-
var
|
93
|
-
if (!!eventValue ||
|
92
|
+
var eventValue = e.currentTarget.value;
|
93
|
+
var isZero = !_Number$isNaN(Number(eventValue)) && Number(eventValue) === 0;
|
94
|
+
if (!!eventValue || !!placeholder || isZero || !!placeholder || placeholder === 0) {
|
94
95
|
setHasValue(true);
|
95
96
|
} else {
|
96
97
|
setHasValue(false);
|
@@ -170,7 +170,7 @@ test('should return isFloatLabelActive class for container', function () {
|
|
170
170
|
// Does not have the class if the value is invalid
|
171
171
|
act(function () {
|
172
172
|
return result.current.fieldControlInputProps.onChange({
|
173
|
-
|
173
|
+
currentTarget: {
|
174
174
|
value: undefined
|
175
175
|
}
|
176
176
|
});
|
@@ -237,7 +237,7 @@ test('should return hasValue class for container when onChange updates internal
|
|
237
237
|
// 0 should be a valid value
|
238
238
|
act(function () {
|
239
239
|
return result.current.fieldControlInputProps.onChange({
|
240
|
-
|
240
|
+
currentTarget: {
|
241
241
|
value: 0
|
242
242
|
}
|
243
243
|
});
|
@@ -248,7 +248,7 @@ test('should return hasValue class for container when onChange updates internal
|
|
248
248
|
// undefined is not a valid value
|
249
249
|
act(function () {
|
250
250
|
return result.current.fieldControlInputProps.onChange({
|
251
|
-
|
251
|
+
currentTarget: {
|
252
252
|
value: undefined
|
253
253
|
}
|
254
254
|
});
|
@@ -259,7 +259,7 @@ test('should return hasValue class for container when onChange updates internal
|
|
259
259
|
// a non-empty string is a valid value
|
260
260
|
act(function () {
|
261
261
|
return result.current.fieldControlInputProps.onChange({
|
262
|
-
|
262
|
+
currentTarget: {
|
263
263
|
value: 'a'
|
264
264
|
}
|
265
265
|
});
|