@pingux/astro 2.107.0-alpha.2 → 2.107.0-alpha.4

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.
Files changed (49) hide show
  1. package/lib/cjs/components/AIComponents/Attachment/Attachment.d.ts +5 -0
  2. package/lib/cjs/components/AIComponents/Attachment/Attachment.js +107 -0
  3. package/lib/cjs/components/AIComponents/Attachment/Attachment.styles.d.ts +22 -0
  4. package/lib/cjs/components/AIComponents/Attachment/Attachment.styles.js +31 -0
  5. package/lib/cjs/components/AIComponents/Attachment/index.d.ts +1 -0
  6. package/lib/cjs/components/AIComponents/Attachment/index.js +14 -0
  7. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.d.ts +4 -0
  8. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.js +147 -0
  9. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.stories.d.ts +10 -0
  10. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.stories.js +74 -0
  11. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.test.d.ts +1 -0
  12. package/lib/cjs/components/AIComponents/PromptInput/PromptInput.test.js +225 -0
  13. package/lib/cjs/components/AIComponents/PromptInput/PromptUploadButton.d.ts +4 -0
  14. package/lib/cjs/components/AIComponents/PromptInput/PromptUploadButton.js +45 -0
  15. package/lib/cjs/components/AIComponents/PromptInput/index.d.ts +1 -0
  16. package/lib/cjs/components/AIComponents/PromptInput/index.js +14 -0
  17. package/lib/cjs/components/FileInputField/FileInputField.js +34 -22
  18. package/lib/cjs/components/FileInputField/FileInputField.test.js +9 -0
  19. package/lib/cjs/components/FileInputField/FileSelectIcon.d.ts +10 -0
  20. package/lib/cjs/components/FileInputField/FileSelectIcon.js +39 -0
  21. package/lib/cjs/index.d.ts +2 -0
  22. package/lib/cjs/index.js +16 -0
  23. package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +1 -1
  24. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +79 -0
  25. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +58 -0
  26. package/lib/cjs/styles/themes/next-gen/variants/button.js +34 -1
  27. package/lib/cjs/styles/themes/next-gen/variants/input.js +19 -0
  28. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +21 -0
  29. package/lib/cjs/styles/themes/next-gen/variants/variants.js +2 -0
  30. package/lib/cjs/types/promptInput.d.ts +42 -0
  31. package/lib/cjs/types/promptInput.js +6 -0
  32. package/lib/components/AIComponents/Attachment/Attachment.js +98 -0
  33. package/lib/components/AIComponents/Attachment/Attachment.styles.js +23 -0
  34. package/lib/components/AIComponents/Attachment/index.js +1 -0
  35. package/lib/components/AIComponents/PromptInput/PromptInput.js +133 -0
  36. package/lib/components/AIComponents/PromptInput/PromptInput.stories.js +61 -0
  37. package/lib/components/AIComponents/PromptInput/PromptInput.test.js +218 -0
  38. package/lib/components/AIComponents/PromptInput/PromptUploadButton.js +36 -0
  39. package/lib/components/AIComponents/PromptInput/index.js +1 -0
  40. package/lib/components/FileInputField/FileInputField.js +34 -22
  41. package/lib/components/FileInputField/FileInputField.test.js +9 -0
  42. package/lib/components/FileInputField/FileSelectIcon.js +30 -0
  43. package/lib/index.js +2 -0
  44. package/lib/styles/themes/next-gen/convertedComponentList.js +1 -1
  45. package/lib/styles/themes/next-gen/variants/button.js +34 -1
  46. package/lib/styles/themes/next-gen/variants/input.js +19 -0
  47. package/lib/styles/themes/next-gen/variants/variants.js +2 -0
  48. package/lib/types/promptInput.js +1 -0
  49. package/package.json +13 -13
@@ -914,6 +914,64 @@ declare const _default: {
914
914
  fill: string;
915
915
  };
916
916
  };
917
+ deleteAttachment: {
918
+ backgroundColor: string;
919
+ border: string;
920
+ borderColor: string;
921
+ size: string;
922
+ p: string;
923
+ cursor: string;
924
+ transition: string;
925
+ outline: string;
926
+ borderRadius: string;
927
+ path: {
928
+ fill: string;
929
+ };
930
+ '&.is-focused': {
931
+ outline: string;
932
+ outlineColor: string;
933
+ outlineOffset: string;
934
+ };
935
+ '&.is-hovered': {
936
+ backgroundColor: string;
937
+ path: {
938
+ fill: string;
939
+ };
940
+ };
941
+ '&.is-pressed': {
942
+ backgroundColor: string;
943
+ borderColor: string;
944
+ path: {
945
+ fill: string;
946
+ };
947
+ };
948
+ };
949
+ inverted: {
950
+ cursor: string;
951
+ transition: string;
952
+ outline: string;
953
+ path: {
954
+ fill: string;
955
+ };
956
+ '&.is-focused': {
957
+ outline: string;
958
+ outlineColor: string;
959
+ outlineOffset: string;
960
+ };
961
+ '&.is-pressed': {
962
+ backgroundColor: string;
963
+ borderColor: string;
964
+ };
965
+ '&.is-hovered': {
966
+ border: string;
967
+ boxShadow: string;
968
+ borderColor: string;
969
+ backgroundColor: string;
970
+ };
971
+ '&.is-disabled': {
972
+ backgroundColor: string;
973
+ };
974
+ };
917
975
  };
918
976
  modalCloseButton: {
919
977
  position: string;
@@ -1847,6 +1905,27 @@ declare const _default: {
1847
1905
  };
1848
1906
  };
1849
1907
  variants: {
1908
+ attachment: {
1909
+ container: {
1910
+ backgroundColor: string;
1911
+ mt: string;
1912
+ borderRadius: string;
1913
+ border: string;
1914
+ borderColor: string;
1915
+ position: string;
1916
+ maxWidth: string;
1917
+ minWidth: string;
1918
+ '&.is-full-screen': {
1919
+ maxWidth: string;
1920
+ minWidth: string;
1921
+ };
1922
+ };
1923
+ iconWrapper: {
1924
+ position: string;
1925
+ top: string;
1926
+ right: string;
1927
+ };
1928
+ };
1850
1929
  navBar: {
1851
1930
  container: {
1852
1931
  width: string;
@@ -681,6 +681,64 @@ declare const buttons: {
681
681
  fill: string;
682
682
  };
683
683
  };
684
+ deleteAttachment: {
685
+ backgroundColor: string;
686
+ border: string;
687
+ borderColor: string;
688
+ size: string;
689
+ p: string;
690
+ cursor: string;
691
+ transition: string;
692
+ outline: string;
693
+ borderRadius: string;
694
+ path: {
695
+ fill: string;
696
+ };
697
+ '&.is-focused': {
698
+ outline: string;
699
+ outlineColor: string;
700
+ outlineOffset: string;
701
+ };
702
+ '&.is-hovered': {
703
+ backgroundColor: string;
704
+ path: {
705
+ fill: string;
706
+ };
707
+ };
708
+ '&.is-pressed': {
709
+ backgroundColor: string;
710
+ borderColor: string;
711
+ path: {
712
+ fill: string;
713
+ };
714
+ };
715
+ };
716
+ inverted: {
717
+ cursor: string;
718
+ transition: string;
719
+ outline: string;
720
+ path: {
721
+ fill: string;
722
+ };
723
+ '&.is-focused': {
724
+ outline: string;
725
+ outlineColor: string;
726
+ outlineOffset: string;
727
+ };
728
+ '&.is-pressed': {
729
+ backgroundColor: string;
730
+ borderColor: string;
731
+ };
732
+ '&.is-hovered': {
733
+ border: string;
734
+ boxShadow: string;
735
+ borderColor: string;
736
+ backgroundColor: string;
737
+ };
738
+ '&.is-disabled': {
739
+ backgroundColor: string;
740
+ };
741
+ };
684
742
  };
685
743
  modalCloseButton: {
686
744
  position: string;
@@ -294,7 +294,40 @@ var iconButtons = {
294
294
  outlineOffset: '1px'
295
295
  })
296
296
  }),
297
- copyButton: _codeView.copyButton
297
+ copyButton: _codeView.copyButton,
298
+ deleteAttachment: _objectSpread(_objectSpread({}, baseIconButton), {}, {
299
+ backgroundColor: 'white',
300
+ border: '1px solid',
301
+ borderColor: 'gray-300',
302
+ size: '24px',
303
+ p: '4px'
304
+ }),
305
+ inverted: {
306
+ cursor: 'pointer',
307
+ transition: 'color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out',
308
+ outline: 'none',
309
+ path: {
310
+ fill: 'white'
311
+ },
312
+ '&.is-focused': {
313
+ outline: '2px solid',
314
+ outlineColor: 'primary',
315
+ outlineOffset: '3px'
316
+ },
317
+ '&.is-pressed': {
318
+ backgroundColor: _chromaJs["default"].mix(primaryBlue, 'black', 0.125, 'rgb').hex(),
319
+ borderColor: _chromaJs["default"].mix(primaryBlue, 'black', 0.125, 'rgb').hex()
320
+ },
321
+ '&.is-hovered': {
322
+ border: 'none !important',
323
+ boxShadow: 'none !important',
324
+ borderColor: 'none !important',
325
+ backgroundColor: _chromaJs["default"].mix(primaryBlue, 'black', 0.075, 'rgb').hex()
326
+ },
327
+ '&.is-disabled': {
328
+ backgroundColor: 'gray-300'
329
+ }
330
+ }
298
331
  };
299
332
  var buttons = {
300
333
  neutral: neutral,
@@ -28,6 +28,7 @@ var readOnlyandDisabledStyles = {
28
28
  };
29
29
  var input = {
30
30
  fontSize: 'md',
31
+ fontFamily: 'standard',
31
32
  p: '0.75rem',
32
33
  backgroundColor: 'background.base',
33
34
  borderColor: 'border.input',
@@ -38,6 +39,15 @@ var input = {
38
39
  '&::placeholder': _text.text.placeholder
39
40
  };
40
41
  exports.input = input;
42
+ input.promptInput = _objectSpread(_objectSpread({}, input), {}, {
43
+ pl: '0px',
44
+ border: 'none',
45
+ outline: 'none !important',
46
+ '&.is-focused': {
47
+ border: 'none !important',
48
+ outline: 'none !important'
49
+ }
50
+ });
41
51
  input.search = _objectSpread(_objectSpread({}, input), {}, {
42
52
  '&.is-disabled': _objectSpread(_objectSpread({}, readOnlyandDisabledStyles), {}, {
43
53
  '> input': _objectSpread({}, readOnlyandDisabledStyles)
@@ -108,6 +118,15 @@ var fieldControlWrapper = {
108
118
  };
109
119
  exports.fieldControlWrapper = fieldControlWrapper;
110
120
  input.fieldControlWrapper = _objectSpread({}, fieldControlWrapper);
121
+ input.promptInputWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper), {}, {
122
+ border: '1px solid',
123
+ borderColor: 'border.input',
124
+ px: '.75rem',
125
+ borderRadius: '4px',
126
+ '&.is-focused': {
127
+ boxShadow: '0 1px 1px rgba(0,0,0,.075), 0 0 0 .0625rem blue'
128
+ }
129
+ });
111
130
  input.multivaluesWrapper = _objectSpread(_objectSpread({}, fieldControlWrapper), {}, {
112
131
  borderColor: 'border.input',
113
132
  borderStyle: 'solid',
@@ -207,6 +207,27 @@ export declare const badges: {
207
207
  };
208
208
  };
209
209
  declare const _default: {
210
+ attachment: {
211
+ container: {
212
+ backgroundColor: string;
213
+ mt: string;
214
+ borderRadius: string;
215
+ border: string;
216
+ borderColor: string;
217
+ position: string;
218
+ maxWidth: string;
219
+ minWidth: string;
220
+ '&.is-full-screen': {
221
+ maxWidth: string;
222
+ minWidth: string;
223
+ };
224
+ };
225
+ iconWrapper: {
226
+ position: string;
227
+ top: string;
228
+ right: string;
229
+ };
230
+ };
210
231
  navBar: {
211
232
  container: {
212
233
  width: string;
@@ -14,6 +14,7 @@ _Object$defineProperty(exports, "__esModule", {
14
14
  });
15
15
  exports["default"] = exports.badges = exports.badgeDeleteButton = void 0;
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
17
+ var _Attachment = _interopRequireDefault(require("../../../../components/AIComponents/Attachment/Attachment.styles"));
17
18
  var _codeView = _interopRequireDefault(require("../codeView/codeView"));
18
19
  var _avatar = require("./avatar");
19
20
  var _button = _interopRequireDefault(require("./button"));
@@ -310,6 +311,7 @@ var overlayPanel = {
310
311
  }
311
312
  };
312
313
  var _default = {
314
+ attachment: _Attachment["default"],
313
315
  navBar: _navbar.navBar,
314
316
  fieldHelperText: fieldHelperText,
315
317
  message: _messages.message,
@@ -0,0 +1,42 @@
1
+ import type { PressEvent } from '@react-types/shared';
2
+ import { IconTypeExtended } from './icon';
3
+ import { TextFieldProps } from './textField';
4
+ export interface PromptInputProps extends TextFieldProps {
5
+ attachmentProps?: object;
6
+ value: string;
7
+ onFileChange?: (files: FileProps[]) => void;
8
+ onCancel?: (event: PressEvent) => void;
9
+ onSubmit?: (event: PressEvent) => void;
10
+ isLoading?: boolean;
11
+ uploadButtonContainerProps?: object;
12
+ uploadButtonProps?: object;
13
+ fileInputButtonProps?: object;
14
+ isFullScreen?: boolean;
15
+ }
16
+ export interface AttachmentProps {
17
+ title: string;
18
+ isFullScreen?: boolean;
19
+ fileType: string;
20
+ removeFile: (id: string) => void;
21
+ id: string;
22
+ className?: string;
23
+ containerProps?: object;
24
+ iconWrapperProps?: object;
25
+ deleteButtonProps?: object;
26
+ icon?: IconTypeExtended;
27
+ }
28
+ export interface FileProps {
29
+ id: string;
30
+ name: string;
31
+ downloadLink: string;
32
+ fileType: string;
33
+ status: string;
34
+ fileObj: object;
35
+ }
36
+ export interface PromptUploadButtonProps {
37
+ uploadButtonContainerProps?: object;
38
+ value: string;
39
+ isLoading?: boolean;
40
+ onSubmit?: (event: PressEvent) => void;
41
+ onCancel?: (event: PressEvent) => void;
42
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -0,0 +1,98 @@
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";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ 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; }
12
+ 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; }
13
+ import React from 'react';
14
+ import CloseIcon from '@pingux/mdi-react/CloseIcon';
15
+ import PaperOutlineIcon from '@pingux/mdi-react/PaperOutlineIcon';
16
+ import { useStatusClasses } from '../../../hooks';
17
+ import { Box, Icon, IconButton, IconWrapper, Text } from '../../../index';
18
+ import { jsx as ___EmotionJSX } from "@emotion/react";
19
+ export var getFileExtension = function getFileExtension(fullString) {
20
+ var fileExtensionPattern = /\.([0-9a-z]+)(?:[?#]|$)/i;
21
+ var ext = fullString.match(fileExtensionPattern);
22
+ if (ext) {
23
+ return ext[1];
24
+ }
25
+ return 'unknown file type';
26
+ };
27
+ var Attachment = function Attachment(props) {
28
+ var title = props.title,
29
+ fileType = props.fileType,
30
+ removeFile = props.removeFile,
31
+ isFullScreen = props.isFullScreen,
32
+ className = props.className,
33
+ id = props.id,
34
+ containerProps = props.containerProps,
35
+ iconWrapperProps = props.iconWrapperProps,
36
+ _props$icon = props.icon,
37
+ icon = _props$icon === void 0 ? PaperOutlineIcon : _props$icon,
38
+ deleteButtonProps = props.deleteButtonProps;
39
+ var _useStatusClasses = useStatusClasses(className, {
40
+ isFullScreen: isFullScreen
41
+ }),
42
+ classNames = _useStatusClasses.classNames;
43
+ return ___EmotionJSX(Box, _extends({
44
+ variant: "attachment.container",
45
+ className: classNames
46
+ }, containerProps), ___EmotionJSX(Box, {
47
+ isRow: true,
48
+ alignItems: "center",
49
+ px: "lg",
50
+ py: "md"
51
+ }, ___EmotionJSX(IconWrapper, {
52
+ isCircle: true,
53
+ title: {
54
+ name: 'File Icon'
55
+ },
56
+ icon: icon,
57
+ color: "red",
58
+ size: "sm",
59
+ wrapperProps: _objectSpread({
60
+ size: '36px',
61
+ minHeight: '36px',
62
+ minWidth: '36px',
63
+ p: '9px'
64
+ }, iconWrapperProps)
65
+ }), ___EmotionJSX(Box, {
66
+ sx: {
67
+ ml: 'md'
68
+ }
69
+ }, ___EmotionJSX(Text, {
70
+ as: "h5",
71
+ sx: {
72
+ fontWeight: 2,
73
+ textOverflow: 'ellipsis',
74
+ whiteSpace: 'nowrap',
75
+ overflow: 'hidden'
76
+ }
77
+ }, title), ___EmotionJSX(Text, {
78
+ sx: {
79
+ textOverflow: 'ellipsis'
80
+ },
81
+ variant: "small"
82
+ }, fileType.toLocaleUpperCase()))), ___EmotionJSX(Box, {
83
+ variant: "attachment.iconWrapper"
84
+ }, ___EmotionJSX(IconButton, _extends({
85
+ "aria-label": "remove attachment",
86
+ "data-testid": "remove-attachment",
87
+ onPress: function onPress() {
88
+ return removeFile(id);
89
+ },
90
+ variant: "deleteAttachment"
91
+ }, deleteButtonProps), ___EmotionJSX(Icon, {
92
+ title: {
93
+ name: 'Remove Attachment Icon'
94
+ },
95
+ icon: CloseIcon
96
+ }))));
97
+ };
98
+ export default Attachment;
@@ -0,0 +1,23 @@
1
+ var container = {
2
+ backgroundColor: 'light',
3
+ mt: '12px',
4
+ borderRadius: '16px',
5
+ border: '1px solid',
6
+ borderColor: 'gray-200',
7
+ position: 'relative',
8
+ maxWidth: '15rem',
9
+ minWidth: '15rem',
10
+ '&.is-full-screen': {
11
+ maxWidth: '20rem',
12
+ minWidth: '20rem'
13
+ }
14
+ };
15
+ var iconWrapper = {
16
+ position: 'absolute',
17
+ top: '-8px',
18
+ right: '-8px'
19
+ };
20
+ export default {
21
+ container: container,
22
+ iconWrapper: iconWrapper
23
+ };
@@ -0,0 +1 @@
1
+ export { default } from './Attachment';
@@ -0,0 +1,133 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["attachmentProps", "onFileChange", "isFullScreen", "isLoading", "fileInputButtonProps", "value", "onCancel", "onSubmit", "uploadButtonContainerProps", "uploadButtonProps"];
5
+ import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
+ import _URL from "@babel/runtime-corejs3/core-js-stable/url";
8
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
9
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
10
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
11
+ import { v4 as uuid } from 'uuid';
12
+ import { useField, useLocalOrForwardRef } from '../../../hooks';
13
+ import { Box, FileInputField, Input } from '../../../index';
14
+ import statuses from '../../../utils/devUtils/constants/statuses';
15
+ import Attachment, { getFileExtension } from '../Attachment/Attachment';
16
+ import PromptUploadButton from './PromptUploadButton';
17
+ import { jsx as ___EmotionJSX } from "@emotion/react";
18
+ var PromptInput = /*#__PURE__*/forwardRef(function (props, ref) {
19
+ var attachmentProps = props.attachmentProps,
20
+ onFileChange = props.onFileChange,
21
+ isFullScreen = props.isFullScreen,
22
+ isLoading = props.isLoading,
23
+ fileInputButtonProps = props.fileInputButtonProps,
24
+ value = props.value,
25
+ onCancel = props.onCancel,
26
+ onSubmit = props.onSubmit,
27
+ uploadButtonContainerProps = props.uploadButtonContainerProps,
28
+ uploadButtonProps = props.uploadButtonProps,
29
+ others = _objectWithoutProperties(props, _excluded);
30
+ var firstUpdate = useRef(true);
31
+ var _useState = useState([]),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ userFiles = _useState2[0],
34
+ setUserFiles = _useState2[1];
35
+ var handleFileSelect = function handleFileSelect(event, files) {
36
+ var arrayWithNewFiles = _Array$from(files);
37
+ var filesWithIdAndLink = _mapInstanceProperty(arrayWithNewFiles).call(arrayWithNewFiles, function (newFile) {
38
+ return {
39
+ fileObj: newFile,
40
+ name: newFile.name,
41
+ id: uuid(),
42
+ downloadLink: _URL.createObjectURL(newFile),
43
+ status: statuses.DEFAULT,
44
+ fileType: getFileExtension(newFile.name)
45
+ };
46
+ });
47
+ setUserFiles(function (prevFiles) {
48
+ var _context;
49
+ return _concatInstanceProperty(_context = []).call(_context, prevFiles, filesWithIdAndLink);
50
+ });
51
+ };
52
+ useEffect(function () {
53
+ if (firstUpdate.current) {
54
+ firstUpdate.current = false;
55
+ return;
56
+ }
57
+ if (onFileChange) {
58
+ onFileChange(userFiles);
59
+ }
60
+ }, [userFiles, onFileChange]);
61
+ var handleFileRemove = function handleFileRemove(id) {
62
+ setUserFiles(_filterInstanceProperty(userFiles).call(userFiles, function (_file) {
63
+ return _file.id !== id;
64
+ }));
65
+ };
66
+ var _useField = useField(others),
67
+ fieldContainerProps = _useField.fieldContainerProps,
68
+ fieldControlInputProps = _useField.fieldControlInputProps,
69
+ fieldControlWrapperProps = _useField.fieldControlWrapperProps;
70
+ var inputRef = useLocalOrForwardRef(ref);
71
+ return ___EmotionJSX(Box, _extends({
72
+ variant: "forms.input.fieldContainer"
73
+ }, fieldContainerProps), ___EmotionJSX(Box, _extends({
74
+ variant: "forms.input.promptInputWrapper"
75
+ }, fieldControlWrapperProps), ___EmotionJSX(Box, {
76
+ isRow: true,
77
+ gap: "1.5rem",
78
+ sx: {
79
+ overflowX: 'auto',
80
+ overflowY: 'hidden',
81
+ whiteSpace: 'nowrap'
82
+ }
83
+ }, _mapInstanceProperty(userFiles).call(userFiles, function (_ref) {
84
+ var name = _ref.name,
85
+ fileType = _ref.fileType,
86
+ id = _ref.id;
87
+ return ___EmotionJSX(Attachment, _extends({
88
+ key: id,
89
+ title: name,
90
+ fileType: fileType,
91
+ removeFile: handleFileRemove,
92
+ id: id,
93
+ isFullScreen: isFullScreen
94
+ }, attachmentProps));
95
+ })), ___EmotionJSX(Box, {
96
+ isRow: true,
97
+ alignItems: "center",
98
+ justifyContent: "center",
99
+ flexGrow: "1"
100
+ }, ___EmotionJSX(Box, {
101
+ mr: "md"
102
+ }, ___EmotionJSX(FileInputField, _extends({
103
+ onFileSelect: handleFileSelect,
104
+ onRemove: handleFileRemove,
105
+ fileList: [],
106
+ isIconButton: true,
107
+ buttonProps: {
108
+ sx: {
109
+ size: '24px',
110
+ padding: '0px'
111
+ }
112
+ },
113
+ sx: {
114
+ width: 'fit-content',
115
+ border: 'none',
116
+ p: '0px'
117
+ },
118
+ "aria-label": "add attachment"
119
+ }, fileInputButtonProps))), ___EmotionJSX(Input, _extends({
120
+ ref: inputRef
121
+ }, fieldControlInputProps, {
122
+ variant: "forms.input.promptInput",
123
+ "data-testid": "prompt-input"
124
+ })), ___EmotionJSX(PromptUploadButton, _extends({
125
+ isLoading: isLoading,
126
+ value: value,
127
+ onSubmit: onSubmit,
128
+ onCancel: onCancel
129
+ }, uploadButtonProps, {
130
+ uploadButtonContainerProps: uploadButtonContainerProps
131
+ })))));
132
+ });
133
+ export default PromptInput;
@@ -0,0 +1,61 @@
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";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
12
+ 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; }
13
+ 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; }
14
+ import React, { useState } from 'react';
15
+ import { AstroProvider, Box, NextGenTheme } from '../../..';
16
+ import { booleanArg } from '../../../utils/docUtils/docArgTypes';
17
+ import PromptInput from './PromptInput';
18
+ import { jsx as ___EmotionJSX } from "@emotion/react";
19
+ export default {
20
+ title: 'Ai Components/Prompt Input',
21
+ component: PromptInput,
22
+ argTypes: {
23
+ isLoading: _objectSpread({}, booleanArg)
24
+ }
25
+ };
26
+ export var Default = function Default(args) {
27
+ var _useState = useState(''),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ value = _useState2[0],
30
+ setValue = _useState2[1];
31
+ var _useState3 = useState([]),
32
+ _useState4 = _slicedToArray(_useState3, 2),
33
+ attachments = _useState4[0],
34
+ setAttachments = _useState4[1];
35
+ var onFileChange = function onFileChange(files) {
36
+ console.log(files);
37
+ setAttachments(files);
38
+ };
39
+ var onCancel = function onCancel(event) {
40
+ console.log(event);
41
+ };
42
+ var onSubmit = function onSubmit(event) {
43
+ console.log(event);
44
+ console.log(attachments);
45
+ };
46
+ return ___EmotionJSX(AstroProvider, {
47
+ themeOverrides: [NextGenTheme]
48
+ }, ___EmotionJSX(Box, {
49
+ maxWidth: "768px"
50
+ }, ___EmotionJSX(PromptInput, _extends({}, args, {
51
+ placeholder: "Enter a prompt here",
52
+ onChange: function onChange(e) {
53
+ return setValue(e.target.value);
54
+ },
55
+ value: value,
56
+ "aria-label": "test",
57
+ onFileChange: onFileChange,
58
+ onSubmit: onSubmit,
59
+ onCancel: onCancel
60
+ }))));
61
+ };