@pingux/astro 2.112.0-alpha.3 → 2.112.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.
@@ -47,7 +47,9 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
47
47
  onCancel = props.onCancel,
48
48
  onSubmit = props.onSubmit,
49
49
  uploadButtonContainerProps = props.uploadButtonContainerProps,
50
- uploadButtonProps = props.uploadButtonProps;
50
+ uploadButtonProps = props.uploadButtonProps,
51
+ onKeyUpProp = props.onKeyUp,
52
+ onKeyDownProp = props.onKeyDown;
51
53
  var onFileChange = props.onFileChange,
52
54
  propsWithoutOnFileChange = (0, _objectWithoutProperties2["default"])(props, _excluded);
53
55
  var firstUpdate = (0, _react.useRef)(true);
@@ -59,6 +61,10 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
59
61
  _useProgressiveState2 = (0, _slicedToArray2["default"])(_useProgressiveState, 2),
60
62
  value = _useProgressiveState2[0],
61
63
  setValue = _useProgressiveState2[1];
64
+ var countLineBreaks = function countLineBreaks(str) {
65
+ var lineBreaks = str.match(/\r\n|\r|\n/g);
66
+ return lineBreaks ? lineBreaks.length : 0;
67
+ };
62
68
  var handleFileSelect = function handleFileSelect(_event, files) {
63
69
  var arrayWithNewFiles = (0, _from["default"])(files);
64
70
  var filesWithIdAndLink = (0, _map["default"])(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
@@ -90,6 +96,21 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
90
96
  return _file.id !== id;
91
97
  }));
92
98
  };
99
+ var onEnterPress = function onEnterPress(e) {
100
+ if (onSubmit && !isLoading) {
101
+ onSubmit(e, value);
102
+ e.stopPropagation();
103
+ e.preventDefault();
104
+ } else if (onCancel && isLoading) {
105
+ onCancel(e);
106
+ e.stopPropagation();
107
+ }
108
+ };
109
+ var onKeyUp = function onKeyUp(e) {
110
+ if (onKeyUpProp) {
111
+ onKeyUpProp(e, value);
112
+ }
113
+ };
93
114
  var _useField = (0, _hooks.useField)(_objectSpread({
94
115
  onChange: function onChange(e) {
95
116
  setValue(e.target.value);
@@ -99,18 +120,31 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
99
120
  fieldControlInputProps = _useField.fieldControlInputProps,
100
121
  fieldControlWrapperProps = _useField.fieldControlWrapperProps;
101
122
  var inputRef = (0, _hooks.useLocalOrForwardRef)(ref);
123
+ (0, _react.useEffect)(function () {
124
+ if (inputRef.current && value) {
125
+ var lb = countLineBreaks(value);
126
+ inputRef.current.style.height = 'auto';
127
+ inputRef.current.style.height = "calc(".concat((lb + 1) * 24, "px)");
128
+ } else if (value === '') {
129
+ inputRef.current.style.height = 'auto';
130
+ inputRef.current.style.height = '26px';
131
+ }
132
+ }, [value]);
133
+ var onKeyDown = function onKeyDown(e) {
134
+ if (onKeyDownProp) {
135
+ onKeyDownProp(e, value);
136
+ }
137
+ if (!e.shiftKey && e.key === 'Enter') {
138
+ onEnterPress(e);
139
+ }
140
+ };
102
141
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
103
142
  variant: "forms.input.fieldContainer"
104
143
  }, fieldContainerProps), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
105
144
  variant: "forms.input.promptInputWrapper"
106
145
  }, fieldControlWrapperProps), (0, _react2.jsx)(_index.Box, {
107
146
  isRow: true,
108
- gap: "1.5rem",
109
- sx: {
110
- overflowX: 'auto',
111
- overflowY: 'hidden',
112
- whiteSpace: 'nowrap'
113
- }
147
+ variant: "forms.input.promptInputAttachmentWrapper"
114
148
  }, (0, _map["default"])(userFiles).call(userFiles, function (_ref) {
115
149
  var name = _ref.name,
116
150
  fileType = _ref.fileType,
@@ -125,11 +159,11 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
125
159
  }, attachmentProps));
126
160
  })), (0, _react2.jsx)(_index.Box, {
127
161
  isRow: true,
128
- alignItems: "center",
129
- justifyContent: "center",
130
- flexGrow: "1"
162
+ variant: "forms.input.promptInputRow"
131
163
  }, (0, _react2.jsx)(_index.Box, {
132
- mr: "md"
164
+ mr: "1.5rem",
165
+ mb: "auto",
166
+ ml: ".75rem"
133
167
  }, (0, _react2.jsx)(_index.FileInputField, (0, _extends2["default"])({
134
168
  onFileSelect: handleFileSelect,
135
169
  onRemove: handleFileRemove,
@@ -147,18 +181,26 @@ var PromptInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
147
181
  p: '0px'
148
182
  },
149
183
  "aria-label": "add attachment"
150
- }, fileInputButtonProps))), (0, _react2.jsx)(_index.Input, (0, _extends2["default"])({
184
+ }, fileInputButtonProps))), (0, _react2.jsx)(_index.TextArea, (0, _extends2["default"])({
151
185
  ref: inputRef,
152
186
  variant: "forms.input.promptInput",
153
187
  "data-testid": "prompt-input"
154
- }, fieldControlInputProps)), (0, _react2.jsx)(_PromptUploadButton["default"], (0, _extends2["default"])({
188
+ }, fieldControlInputProps, {
189
+ onKeyUp: onKeyUp,
190
+ onKeyDown: onKeyDown
191
+ })), (0, _react2.jsx)(_index.Box, {
192
+ sx: {
193
+ mx: '.75rem',
194
+ mb: 'auto'
195
+ }
196
+ }, (0, _react2.jsx)(_PromptUploadButton["default"], (0, _extends2["default"])({
155
197
  isLoading: isLoading,
156
198
  value: value,
157
199
  onSubmit: onSubmit,
158
200
  onCancel: onCancel
159
201
  }, uploadButtonProps, {
160
202
  uploadButtonContainerProps: uploadButtonContainerProps
161
- })))));
203
+ }))))));
162
204
  });
163
205
  PromptInput.defaultProps = {
164
206
  controlProps: {
@@ -22,11 +22,13 @@ var _universalComponentTest = require("../../../utils/testUtils/universalCompone
22
22
  var _Attachment = require("../Attachment/Attachment");
23
23
  var _PromptInput = _interopRequireDefault(require("./PromptInput"));
24
24
  var _react2 = require("@emotion/react");
25
- 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; }
25
+ 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; }
26
26
  var onSubmitCallback = jest.fn();
27
27
  var onCancelCallback = jest.fn();
28
28
  var onChangeCallback = jest.fn();
29
29
  var onFileChangeCallback = jest.fn();
30
+ var onKeyDownCallback = jest.fn();
31
+ var onKeyUpCallback = jest.fn();
30
32
  var originalValue = _url["default"].createObjectURL;
31
33
  var testFileURL = 'test-file-url';
32
34
  var testFileName = 'chucknorris.png';
@@ -71,7 +73,7 @@ test('default PromptInput', function () {
71
73
  var field = _testWrapper.screen.getByTestId(testId);
72
74
  var control = _testWrapper.screen.getByLabelText(testLabel);
73
75
  expect(field).toBeInstanceOf(HTMLDivElement);
74
- expect(control).toBeInstanceOf(HTMLInputElement);
76
+ expect(control).toBeInstanceOf(HTMLTextAreaElement);
75
77
  expect(field).toBeInTheDocument();
76
78
  expect(control).toBeInTheDocument();
77
79
  });
@@ -117,7 +119,16 @@ test('onSubmit prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["defau
117
119
  case 7:
118
120
  _userEvent["default"].click(_testWrapper.screen.getByTestId(buttonTestId));
119
121
  expect(onSubmitCallback).toHaveBeenCalledTimes(1);
120
- case 9:
122
+
123
+ // Type a value and press enter
124
+ _context2.next = 11;
125
+ return _userEvent["default"].type(control, testValue);
126
+ case 11:
127
+ _context2.next = 13;
128
+ return _userEvent["default"].type(control, '{enter}');
129
+ case 13:
130
+ expect(onSubmitCallback).toHaveBeenCalledTimes(2);
131
+ case 14:
121
132
  case "end":
122
133
  return _context2.stop();
123
134
  }
@@ -141,16 +152,63 @@ test('onCancel prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["defau
141
152
  case 4:
142
153
  _userEvent["default"].click(_testWrapper.screen.getByTestId(buttonTestId));
143
154
  expect(onCancelCallback).toHaveBeenCalledTimes(1);
144
- case 6:
155
+
156
+ // Press enter
157
+ _context3.next = 8;
158
+ return _userEvent["default"].type(control, testValue);
159
+ case 8:
160
+ _context3.next = 10;
161
+ return _userEvent["default"].type(control, '{enter}');
162
+ case 10:
163
+ expect(onCancelCallback).toHaveBeenCalledTimes(2);
164
+ case 11:
145
165
  case "end":
146
166
  return _context3.stop();
147
167
  }
148
168
  }, _callee3);
149
169
  })));
150
- test('should add and remove a file attachment', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
151
- var fileInput, removeButton;
170
+ test('onKeyDown prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
171
+ var control;
152
172
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
153
173
  while (1) switch (_context4.prev = _context4.next) {
174
+ case 0:
175
+ getComponent({
176
+ onKeyDown: onKeyDownCallback
177
+ });
178
+ control = _testWrapper.screen.getByLabelText(testLabel);
179
+ _context4.next = 4;
180
+ return _userEvent["default"].type(control, '{enter}');
181
+ case 4:
182
+ expect(onKeyDownCallback).toHaveBeenCalled();
183
+ case 5:
184
+ case "end":
185
+ return _context4.stop();
186
+ }
187
+ }, _callee4);
188
+ })));
189
+ test('onKeyUp prop works correctly', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
190
+ var control;
191
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
192
+ while (1) switch (_context5.prev = _context5.next) {
193
+ case 0:
194
+ getComponent({
195
+ onKeyUp: onKeyUpCallback
196
+ });
197
+ control = _testWrapper.screen.getByLabelText(testLabel);
198
+ _context5.next = 4;
199
+ return _userEvent["default"].type(control, '{enter}');
200
+ case 4:
201
+ expect(onKeyUpCallback).toHaveBeenCalled();
202
+ case 5:
203
+ case "end":
204
+ return _context5.stop();
205
+ }
206
+ }, _callee5);
207
+ })));
208
+ test('should add and remove a file attachment', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
209
+ var fileInput, removeButton;
210
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
211
+ while (1) switch (_context6.prev = _context6.next) {
154
212
  case 0:
155
213
  getComponent({
156
214
  isLoading: true,
@@ -167,7 +225,7 @@ test('should add and remove a file attachment', /*#__PURE__*/(0, _asyncToGenerat
167
225
  }
168
226
  });
169
227
  fileInput = _testWrapper.screen.getAllByLabelText('add attachment')[0];
170
- _context4.next = 4;
228
+ _context6.next = 4;
171
229
  return _userEvent["default"].upload(fileInput, testFile);
172
230
  case 4:
173
231
  expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
@@ -180,14 +238,14 @@ test('should add and remove a file attachment', /*#__PURE__*/(0, _asyncToGenerat
180
238
  expect(_testWrapper.screen.queryByTestId(testId2)).not.toBeInTheDocument();
181
239
  case 12:
182
240
  case "end":
183
- return _context4.stop();
241
+ return _context6.stop();
184
242
  }
185
- }, _callee4);
243
+ }, _callee6);
186
244
  })));
187
- test('should use default icon if no icon is provided', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
245
+ test('should use default icon if no icon is provided', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
188
246
  var fileInput, removeButton;
189
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
190
- while (1) switch (_context5.prev = _context5.next) {
247
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
248
+ while (1) switch (_context7.prev = _context7.next) {
191
249
  case 0:
192
250
  getComponent({
193
251
  isLoading: true,
@@ -204,7 +262,7 @@ test('should use default icon if no icon is provided', /*#__PURE__*/(0, _asyncTo
204
262
  }
205
263
  });
206
264
  fileInput = _testWrapper.screen.getAllByLabelText('add attachment')[0];
207
- _context5.next = 4;
265
+ _context7.next = 4;
208
266
  return _userEvent["default"].upload(fileInput, testFile);
209
267
  case 4:
210
268
  expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
@@ -217,9 +275,9 @@ test('should use default icon if no icon is provided', /*#__PURE__*/(0, _asyncTo
217
275
  expect(_testWrapper.screen.queryByTestId(testId2)).not.toBeInTheDocument();
218
276
  case 12:
219
277
  case "end":
220
- return _context5.stop();
278
+ return _context7.stop();
221
279
  }
222
- }, _callee5);
280
+ }, _callee7);
223
281
  })));
224
282
  test('regex expression', function () {
225
283
  var string = 'alongiflename.txt';
@@ -40,7 +40,7 @@ var PromptUploadButton = function PromptUploadButton(props) {
40
40
  };
41
41
  return (0, _react2.jsx)(_index.Box, uploadButtonContainerProps, (0, _react2.jsx)(_index.IconButton, (0, _extends2["default"])({
42
42
  "aria-label": "upload chat",
43
- isDisabled: !isLoading && (typeof value === 'undefined' || (value === null || value === void 0 ? void 0 : value.length) === 0),
43
+ isDisabled: !isLoading && (typeof value === 'undefined' || value.length === 0),
44
44
  variant: "inverted",
45
45
  onPress: onPress
46
46
  }, others, {
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
5
+ var _react = _interopRequireDefault(require("react"));
6
+ var _react2 = require("@testing-library/react");
7
+ var _PromptUploadButton = _interopRequireDefault(require("./PromptUploadButton"));
8
+ var _react3 = require("@emotion/react");
9
+ var defaultProps = {
10
+ isLoading: false,
11
+ onCancel: jest.fn(),
12
+ onSubmit: jest.fn(),
13
+ value: '',
14
+ uploadButtonContainerProps: {}
15
+ };
16
+ var getComponent = function getComponent() {
17
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
+ return (0, _react2.render)((0, _react3.jsx)(_PromptUploadButton["default"], (0, _extends2["default"])({}, defaultProps, props)));
19
+ };
20
+ test('PromptUploadButton is disabled when value is empty and isLoading is false', function () {
21
+ getComponent();
22
+ var button = _react2.screen.getByRole('button', {
23
+ name: /upload chat/i
24
+ });
25
+ expect(button).toBeDisabled();
26
+ });
27
+ test('PromptUploadButton is enabled when value is not empty and isLoading is false', function () {
28
+ getComponent({
29
+ value: 'test value'
30
+ });
31
+ var button = _react2.screen.getByRole('button', {
32
+ name: /upload chat/i
33
+ });
34
+ expect(button).not.toHaveClass('is-disabled');
35
+ });
36
+ test('PromptUploadButton is enabled when isLoading is true', function () {
37
+ getComponent({
38
+ isLoading: true
39
+ });
40
+ var button = _react2.screen.getByRole('button', {
41
+ name: /upload chat/i
42
+ });
43
+ expect(button).not.toHaveClass('is-disabled');
44
+ });
45
+ test('PromptUploadButton calls onSubmit when clicked and isLoading is false', function () {
46
+ var onSubmit = jest.fn();
47
+ getComponent({
48
+ value: 'test value',
49
+ onSubmit: onSubmit
50
+ });
51
+ var button = _react2.screen.getByRole('button', {
52
+ name: /upload chat/i
53
+ });
54
+ _react2.fireEvent.click(button);
55
+ expect(onSubmit).toHaveBeenCalled();
56
+ });
57
+ test('PromptUploadButton calls onCancel when clicked and isLoading is true', function () {
58
+ var onCancel = jest.fn();
59
+ getComponent({
60
+ isLoading: true,
61
+ onCancel: onCancel
62
+ });
63
+ var button = _react2.screen.getByRole('button', {
64
+ name: /upload chat/i
65
+ });
66
+ _react2.fireEvent.click(button);
67
+ expect(onCancel).toHaveBeenCalled();
68
+ });
@@ -35,14 +35,20 @@ var input = {
35
35
  '&.is-focused': _objectSpread({}, defaultFocus),
36
36
  borderRadius: '4px',
37
37
  fontWeight: 1,
38
- height: '50px',
39
38
  '&::placeholder': _text.text.placeholder
40
39
  };
41
40
  exports.input = input;
42
41
  input.promptInput = _objectSpread(_objectSpread({}, input), {}, {
42
+ position: 'absolute',
43
43
  pl: '0px',
44
44
  border: 'none',
45
45
  outline: 'none !important',
46
+ overflowY: 'hidden',
47
+ resize: 'none',
48
+ lineHeight: '24px',
49
+ minHeight: '26px',
50
+ height: '26px',
51
+ p: '0px',
46
52
  '&.is-focused': {
47
53
  border: 'none !important',
48
54
  outline: 'none !important'
@@ -121,8 +127,8 @@ input.fieldControlWrapper = _objectSpread({}, fieldControlWrapper);
121
127
  input.promptInputWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper), {}, {
122
128
  border: '1px solid',
123
129
  borderColor: 'border.input',
124
- px: '.75rem',
125
130
  borderRadius: '4px',
131
+ minHeight: '50px',
126
132
  '&.is-focused': {
127
133
  boxShadow: '0 1px 1px rgba(0,0,0,.075), 0 0 0 .0625rem blue'
128
134
  }
@@ -158,4 +164,20 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper),
158
164
  });
159
165
  input.numberField = _objectSpread(_objectSpread({}, input), {}, {
160
166
  pr: '28px'
161
- });
167
+ });
168
+ input.promptInputRow = {
169
+ alignItems: 'center',
170
+ position: 'relative',
171
+ justifyContent: 'center',
172
+ flexGrow: '1',
173
+ overflowX: 'hidden',
174
+ overflowY: 'auto',
175
+ py: '12px'
176
+ };
177
+ input.promptInputAttachmentWrapper = {
178
+ gap: '1.5rem',
179
+ overflowX: 'auto',
180
+ overflowY: 'hidden',
181
+ whiteSpace: 'nowrap',
182
+ px: '.75rem'
183
+ };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import type { PressEvent } from '@react-types/shared';
2
3
  import { IconTypeExtended } from './icon';
3
4
  import { IconButtonProps } from './iconButton';
@@ -15,6 +16,8 @@ export interface PromptProps {
15
16
  isFullScreen?: boolean;
16
17
  }
17
18
  export interface PromptInputProps extends TextFieldProps, PromptProps {
19
+ onKeyUp?: (e: React.KeyboardEvent, value?: string) => void;
20
+ onKeyDown?: (e: React.KeyboardEvent, value?: string) => void;
18
21
  }
19
22
  export interface AttachmentProps {
20
23
  title: string;
@@ -20,7 +20,7 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
20
20
  import React, { forwardRef, useEffect, useRef, useState } from 'react';
21
21
  import { v4 as uuid } from 'uuid';
22
22
  import { useField, useLocalOrForwardRef, useProgressiveState } from '../../../hooks';
23
- import { Box, FileInputField, Input } from '../../../index';
23
+ import { Box, FileInputField, TextArea } from '../../../index';
24
24
  import statuses from '../../../utils/devUtils/constants/statuses';
25
25
  import Attachment, { getFileExtension } from '../Attachment/Attachment';
26
26
  import PromptUploadButton from './PromptUploadButton';
@@ -35,7 +35,9 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
35
35
  onCancel = props.onCancel,
36
36
  onSubmit = props.onSubmit,
37
37
  uploadButtonContainerProps = props.uploadButtonContainerProps,
38
- uploadButtonProps = props.uploadButtonProps;
38
+ uploadButtonProps = props.uploadButtonProps,
39
+ onKeyUpProp = props.onKeyUp,
40
+ onKeyDownProp = props.onKeyDown;
39
41
  var onFileChange = props.onFileChange,
40
42
  propsWithoutOnFileChange = _objectWithoutProperties(props, _excluded);
41
43
  var firstUpdate = useRef(true);
@@ -47,6 +49,10 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
47
49
  _useProgressiveState2 = _slicedToArray(_useProgressiveState, 2),
48
50
  value = _useProgressiveState2[0],
49
51
  setValue = _useProgressiveState2[1];
52
+ var countLineBreaks = function countLineBreaks(str) {
53
+ var lineBreaks = str.match(/\r\n|\r|\n/g);
54
+ return lineBreaks ? lineBreaks.length : 0;
55
+ };
50
56
  var handleFileSelect = function handleFileSelect(_event, files) {
51
57
  var arrayWithNewFiles = _Array$from(files);
52
58
  var filesWithIdAndLink = _mapInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
@@ -78,6 +84,21 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
78
84
  return _file.id !== id;
79
85
  }));
80
86
  };
87
+ var onEnterPress = function onEnterPress(e) {
88
+ if (onSubmit && !isLoading) {
89
+ onSubmit(e, value);
90
+ e.stopPropagation();
91
+ e.preventDefault();
92
+ } else if (onCancel && isLoading) {
93
+ onCancel(e);
94
+ e.stopPropagation();
95
+ }
96
+ };
97
+ var onKeyUp = function onKeyUp(e) {
98
+ if (onKeyUpProp) {
99
+ onKeyUpProp(e, value);
100
+ }
101
+ };
81
102
  var _useField = useField(_objectSpread({
82
103
  onChange: function onChange(e) {
83
104
  setValue(e.target.value);
@@ -87,18 +108,31 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
87
108
  fieldControlInputProps = _useField.fieldControlInputProps,
88
109
  fieldControlWrapperProps = _useField.fieldControlWrapperProps;
89
110
  var inputRef = useLocalOrForwardRef(ref);
111
+ useEffect(function () {
112
+ if (inputRef.current && value) {
113
+ var lb = countLineBreaks(value);
114
+ inputRef.current.style.height = 'auto';
115
+ inputRef.current.style.height = "calc(".concat((lb + 1) * 24, "px)");
116
+ } else if (value === '') {
117
+ inputRef.current.style.height = 'auto';
118
+ inputRef.current.style.height = '26px';
119
+ }
120
+ }, [value]);
121
+ var onKeyDown = function onKeyDown(e) {
122
+ if (onKeyDownProp) {
123
+ onKeyDownProp(e, value);
124
+ }
125
+ if (!e.shiftKey && e.key === 'Enter') {
126
+ onEnterPress(e);
127
+ }
128
+ };
90
129
  return ___EmotionJSX(Box, _extends({
91
130
  variant: "forms.input.fieldContainer"
92
131
  }, fieldContainerProps), ___EmotionJSX(Box, _extends({
93
132
  variant: "forms.input.promptInputWrapper"
94
133
  }, fieldControlWrapperProps), ___EmotionJSX(Box, {
95
134
  isRow: true,
96
- gap: "1.5rem",
97
- sx: {
98
- overflowX: 'auto',
99
- overflowY: 'hidden',
100
- whiteSpace: 'nowrap'
101
- }
135
+ variant: "forms.input.promptInputAttachmentWrapper"
102
136
  }, _mapInstanceProperty(userFiles).call(userFiles, function (_ref) {
103
137
  var name = _ref.name,
104
138
  fileType = _ref.fileType,
@@ -113,11 +147,11 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
113
147
  }, attachmentProps));
114
148
  })), ___EmotionJSX(Box, {
115
149
  isRow: true,
116
- alignItems: "center",
117
- justifyContent: "center",
118
- flexGrow: "1"
150
+ variant: "forms.input.promptInputRow"
119
151
  }, ___EmotionJSX(Box, {
120
- mr: "md"
152
+ mr: "1.5rem",
153
+ mb: "auto",
154
+ ml: ".75rem"
121
155
  }, ___EmotionJSX(FileInputField, _extends({
122
156
  onFileSelect: handleFileSelect,
123
157
  onRemove: handleFileRemove,
@@ -135,18 +169,26 @@ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
135
169
  p: '0px'
136
170
  },
137
171
  "aria-label": "add attachment"
138
- }, fileInputButtonProps))), ___EmotionJSX(Input, _extends({
172
+ }, fileInputButtonProps))), ___EmotionJSX(TextArea, _extends({
139
173
  ref: inputRef,
140
174
  variant: "forms.input.promptInput",
141
175
  "data-testid": "prompt-input"
142
- }, fieldControlInputProps)), ___EmotionJSX(PromptUploadButton, _extends({
176
+ }, fieldControlInputProps, {
177
+ onKeyUp: onKeyUp,
178
+ onKeyDown: onKeyDown
179
+ })), ___EmotionJSX(Box, {
180
+ sx: {
181
+ mx: '.75rem',
182
+ mb: 'auto'
183
+ }
184
+ }, ___EmotionJSX(PromptUploadButton, _extends({
143
185
  isLoading: isLoading,
144
186
  value: value,
145
187
  onSubmit: onSubmit,
146
188
  onCancel: onCancel
147
189
  }, uploadButtonProps, {
148
190
  uploadButtonContainerProps: uploadButtonContainerProps
149
- })))));
191
+ }))))));
150
192
  });
151
193
  PromptInput.defaultProps = {
152
194
  controlProps: {
@@ -10,7 +10,7 @@ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instan
10
10
  import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
11
11
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
12
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; }
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 _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; }
14
14
  import _URL from "@babel/runtime-corejs3/core-js-stable/url";
15
15
  import React from 'react';
16
16
  import GlobeIcon from '@pingux/mdi-react/GlobeIcon';
@@ -24,6 +24,8 @@ var onSubmitCallback = jest.fn();
24
24
  var onCancelCallback = jest.fn();
25
25
  var onChangeCallback = jest.fn();
26
26
  var onFileChangeCallback = jest.fn();
27
+ var onKeyDownCallback = jest.fn();
28
+ var onKeyUpCallback = jest.fn();
27
29
  var originalValue = _URL.createObjectURL;
28
30
  var testFileURL = 'test-file-url';
29
31
  var testFileName = 'chucknorris.png';
@@ -68,7 +70,7 @@ test('default PromptInput', function () {
68
70
  var field = screen.getByTestId(testId);
69
71
  var control = screen.getByLabelText(testLabel);
70
72
  expect(field).toBeInstanceOf(HTMLDivElement);
71
- expect(control).toBeInstanceOf(HTMLInputElement);
73
+ expect(control).toBeInstanceOf(HTMLTextAreaElement);
72
74
  expect(field).toBeInTheDocument();
73
75
  expect(control).toBeInTheDocument();
74
76
  });
@@ -114,7 +116,16 @@ test('onSubmit prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE_
114
116
  case 7:
115
117
  userEvent.click(screen.getByTestId(buttonTestId));
116
118
  expect(onSubmitCallback).toHaveBeenCalledTimes(1);
117
- case 9:
119
+
120
+ // Type a value and press enter
121
+ _context2.next = 11;
122
+ return userEvent.type(control, testValue);
123
+ case 11:
124
+ _context2.next = 13;
125
+ return userEvent.type(control, '{enter}');
126
+ case 13:
127
+ expect(onSubmitCallback).toHaveBeenCalledTimes(2);
128
+ case 14:
118
129
  case "end":
119
130
  return _context2.stop();
120
131
  }
@@ -138,16 +149,63 @@ test('onCancel prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE_
138
149
  case 4:
139
150
  userEvent.click(screen.getByTestId(buttonTestId));
140
151
  expect(onCancelCallback).toHaveBeenCalledTimes(1);
141
- case 6:
152
+
153
+ // Press enter
154
+ _context3.next = 8;
155
+ return userEvent.type(control, testValue);
156
+ case 8:
157
+ _context3.next = 10;
158
+ return userEvent.type(control, '{enter}');
159
+ case 10:
160
+ expect(onCancelCallback).toHaveBeenCalledTimes(2);
161
+ case 11:
142
162
  case "end":
143
163
  return _context3.stop();
144
164
  }
145
165
  }, _callee3);
146
166
  })));
147
- test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
148
- var fileInput, removeButton;
167
+ test('onKeyDown prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
168
+ var control;
149
169
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
150
170
  while (1) switch (_context4.prev = _context4.next) {
171
+ case 0:
172
+ getComponent({
173
+ onKeyDown: onKeyDownCallback
174
+ });
175
+ control = screen.getByLabelText(testLabel);
176
+ _context4.next = 4;
177
+ return userEvent.type(control, '{enter}');
178
+ case 4:
179
+ expect(onKeyDownCallback).toHaveBeenCalled();
180
+ case 5:
181
+ case "end":
182
+ return _context4.stop();
183
+ }
184
+ }, _callee4);
185
+ })));
186
+ test('onKeyUp prop works correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
187
+ var control;
188
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
189
+ while (1) switch (_context5.prev = _context5.next) {
190
+ case 0:
191
+ getComponent({
192
+ onKeyUp: onKeyUpCallback
193
+ });
194
+ control = screen.getByLabelText(testLabel);
195
+ _context5.next = 4;
196
+ return userEvent.type(control, '{enter}');
197
+ case 4:
198
+ expect(onKeyUpCallback).toHaveBeenCalled();
199
+ case 5:
200
+ case "end":
201
+ return _context5.stop();
202
+ }
203
+ }, _callee5);
204
+ })));
205
+ test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
206
+ var fileInput, removeButton;
207
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
208
+ while (1) switch (_context6.prev = _context6.next) {
151
209
  case 0:
152
210
  getComponent({
153
211
  isLoading: true,
@@ -164,7 +222,7 @@ test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator(
164
222
  }
165
223
  });
166
224
  fileInput = screen.getAllByLabelText('add attachment')[0];
167
- _context4.next = 4;
225
+ _context6.next = 4;
168
226
  return userEvent.upload(fileInput, testFile);
169
227
  case 4:
170
228
  expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
@@ -177,14 +235,14 @@ test('should add and remove a file attachment', /*#__PURE__*/_asyncToGenerator(
177
235
  expect(screen.queryByTestId(testId2)).not.toBeInTheDocument();
178
236
  case 12:
179
237
  case "end":
180
- return _context4.stop();
238
+ return _context6.stop();
181
239
  }
182
- }, _callee4);
240
+ }, _callee6);
183
241
  })));
184
- test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
242
+ test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
185
243
  var fileInput, removeButton;
186
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
187
- while (1) switch (_context5.prev = _context5.next) {
244
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
245
+ while (1) switch (_context7.prev = _context7.next) {
188
246
  case 0:
189
247
  getComponent({
190
248
  isLoading: true,
@@ -201,7 +259,7 @@ test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGene
201
259
  }
202
260
  });
203
261
  fileInput = screen.getAllByLabelText('add attachment')[0];
204
- _context5.next = 4;
262
+ _context7.next = 4;
205
263
  return userEvent.upload(fileInput, testFile);
206
264
  case 4:
207
265
  expect(onFileChangeCallback).toHaveBeenCalledTimes(1);
@@ -214,9 +272,9 @@ test('should use default icon if no icon is provided', /*#__PURE__*/_asyncToGene
214
272
  expect(screen.queryByTestId(testId2)).not.toBeInTheDocument();
215
273
  case 12:
216
274
  case "end":
217
- return _context5.stop();
275
+ return _context7.stop();
218
276
  }
219
- }, _callee5);
277
+ }, _callee7);
220
278
  })));
221
279
  test('regex expression', function () {
222
280
  var string = 'alongiflename.txt';
@@ -33,7 +33,7 @@ var PromptUploadButton = function PromptUploadButton(props) {
33
33
  };
34
34
  return ___EmotionJSX(Box, uploadButtonContainerProps, ___EmotionJSX(IconButton, _extends({
35
35
  "aria-label": "upload chat",
36
- isDisabled: !isLoading && (typeof value === 'undefined' || (value === null || value === void 0 ? void 0 : value.length) === 0),
36
+ isDisabled: !isLoading && (typeof value === 'undefined' || value.length === 0),
37
37
  variant: "inverted",
38
38
  onPress: onPress
39
39
  }, others, {
@@ -0,0 +1,65 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React from 'react';
3
+ import { fireEvent, render, screen } from '@testing-library/react';
4
+ import PromptUploadButton from './PromptUploadButton';
5
+ import { jsx as ___EmotionJSX } from "@emotion/react";
6
+ var defaultProps = {
7
+ isLoading: false,
8
+ onCancel: jest.fn(),
9
+ onSubmit: jest.fn(),
10
+ value: '',
11
+ uploadButtonContainerProps: {}
12
+ };
13
+ var getComponent = function getComponent() {
14
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
+ return render(___EmotionJSX(PromptUploadButton, _extends({}, defaultProps, props)));
16
+ };
17
+ test('PromptUploadButton is disabled when value is empty and isLoading is false', function () {
18
+ getComponent();
19
+ var button = screen.getByRole('button', {
20
+ name: /upload chat/i
21
+ });
22
+ expect(button).toBeDisabled();
23
+ });
24
+ test('PromptUploadButton is enabled when value is not empty and isLoading is false', function () {
25
+ getComponent({
26
+ value: 'test value'
27
+ });
28
+ var button = screen.getByRole('button', {
29
+ name: /upload chat/i
30
+ });
31
+ expect(button).not.toHaveClass('is-disabled');
32
+ });
33
+ test('PromptUploadButton is enabled when isLoading is true', function () {
34
+ getComponent({
35
+ isLoading: true
36
+ });
37
+ var button = screen.getByRole('button', {
38
+ name: /upload chat/i
39
+ });
40
+ expect(button).not.toHaveClass('is-disabled');
41
+ });
42
+ test('PromptUploadButton calls onSubmit when clicked and isLoading is false', function () {
43
+ var onSubmit = jest.fn();
44
+ getComponent({
45
+ value: 'test value',
46
+ onSubmit: onSubmit
47
+ });
48
+ var button = screen.getByRole('button', {
49
+ name: /upload chat/i
50
+ });
51
+ fireEvent.click(button);
52
+ expect(onSubmit).toHaveBeenCalled();
53
+ });
54
+ test('PromptUploadButton calls onCancel when clicked and isLoading is true', function () {
55
+ var onCancel = jest.fn();
56
+ getComponent({
57
+ isLoading: true,
58
+ onCancel: onCancel
59
+ });
60
+ var button = screen.getByRole('button', {
61
+ name: /upload chat/i
62
+ });
63
+ fireEvent.click(button);
64
+ expect(onCancel).toHaveBeenCalled();
65
+ });
@@ -28,13 +28,19 @@ export var input = {
28
28
  '&.is-focused': _objectSpread({}, defaultFocus),
29
29
  borderRadius: '4px',
30
30
  fontWeight: 1,
31
- height: '50px',
32
31
  '&::placeholder': text.placeholder
33
32
  };
34
33
  input.promptInput = _objectSpread(_objectSpread({}, input), {}, {
34
+ position: 'absolute',
35
35
  pl: '0px',
36
36
  border: 'none',
37
37
  outline: 'none !important',
38
+ overflowY: 'hidden',
39
+ resize: 'none',
40
+ lineHeight: '24px',
41
+ minHeight: '26px',
42
+ height: '26px',
43
+ p: '0px',
38
44
  '&.is-focused': {
39
45
  border: 'none !important',
40
46
  outline: 'none !important'
@@ -112,8 +118,8 @@ input.fieldControlWrapper = _objectSpread({}, fieldControlWrapper);
112
118
  input.promptInputWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper), {}, {
113
119
  border: '1px solid',
114
120
  borderColor: 'border.input',
115
- px: '.75rem',
116
121
  borderRadius: '4px',
122
+ minHeight: '50px',
117
123
  '&.is-focused': {
118
124
  boxShadow: '0 1px 1px rgba(0,0,0,.075), 0 0 0 .0625rem blue'
119
125
  }
@@ -149,4 +155,20 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper),
149
155
  });
150
156
  input.numberField = _objectSpread(_objectSpread({}, input), {}, {
151
157
  pr: '28px'
152
- });
158
+ });
159
+ input.promptInputRow = {
160
+ alignItems: 'center',
161
+ position: 'relative',
162
+ justifyContent: 'center',
163
+ flexGrow: '1',
164
+ overflowX: 'hidden',
165
+ overflowY: 'auto',
166
+ py: '12px'
167
+ };
168
+ input.promptInputAttachmentWrapper = {
169
+ gap: '1.5rem',
170
+ overflowX: 'auto',
171
+ overflowY: 'hidden',
172
+ whiteSpace: 'nowrap',
173
+ px: '.75rem'
174
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.112.0-alpha.3",
3
+ "version": "2.112.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",