@uipath/apollo-wind 2.69.0 → 2.71.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.
Files changed (91) hide show
  1. package/dist/components/custom/demo-composer.cjs +80 -0
  2. package/dist/components/custom/demo-composer.d.ts +11 -0
  3. package/dist/components/custom/demo-composer.js +46 -0
  4. package/dist/components/custom/panel-flow.cjs +2 -2
  5. package/dist/components/custom/panel-flow.js +2 -2
  6. package/dist/components/forms/field-control.cjs +3 -2
  7. package/dist/components/forms/field-control.js +3 -2
  8. package/dist/components/forms/validation-converter.cjs +14 -5
  9. package/dist/components/forms/validation-converter.js +14 -5
  10. package/dist/components/ui/chat-composer.cjs +429 -0
  11. package/dist/components/ui/chat-composer.d.ts +157 -0
  12. package/dist/components/ui/chat-composer.js +359 -0
  13. package/dist/components/ui/chat-hero.cjs +244 -0
  14. package/dist/components/ui/chat-hero.d.ts +51 -0
  15. package/dist/components/ui/chat-hero.js +189 -0
  16. package/dist/components/ui/citation.cjs +188 -0
  17. package/dist/components/ui/citation.d.ts +42 -0
  18. package/dist/components/ui/citation.js +148 -0
  19. package/dist/components/ui/date-picker.cjs +6 -5
  20. package/dist/components/ui/date-picker.js +7 -6
  21. package/dist/components/ui/datetime-picker.cjs +7 -10
  22. package/dist/components/ui/datetime-picker.js +8 -11
  23. package/dist/components/ui/dropzone-overlay.cjs +142 -0
  24. package/dist/components/ui/dropzone-overlay.d.ts +27 -0
  25. package/dist/components/ui/dropzone-overlay.js +105 -0
  26. package/dist/components/ui/file-upload.cjs +5 -29
  27. package/dist/components/ui/file-upload.js +2 -26
  28. package/dist/components/ui/file-validation.cjs +91 -0
  29. package/dist/components/ui/file-validation.d.ts +24 -0
  30. package/dist/components/ui/file-validation.js +51 -0
  31. package/dist/components/ui/hover-card.cjs +15 -8
  32. package/dist/components/ui/hover-card.d.ts +4 -1
  33. package/dist/components/ui/hover-card.js +16 -9
  34. package/dist/components/ui/index.cjs +304 -216
  35. package/dist/components/ui/index.d.ts +8 -0
  36. package/dist/components/ui/index.js +8 -0
  37. package/dist/components/ui/input-group.cjs +1 -1
  38. package/dist/components/ui/input-group.d.ts +2 -1
  39. package/dist/components/ui/input-group.js +1 -1
  40. package/dist/components/ui/message-actions.cjs +302 -0
  41. package/dist/components/ui/message-actions.d.ts +102 -0
  42. package/dist/components/ui/message-actions.js +241 -0
  43. package/dist/components/ui/message.cjs +1 -1
  44. package/dist/components/ui/message.d.ts +2 -0
  45. package/dist/components/ui/message.js +1 -1
  46. package/dist/components/ui/prompt-suggestions.cjs +133 -0
  47. package/dist/components/ui/prompt-suggestions.d.ts +52 -0
  48. package/dist/components/ui/prompt-suggestions.js +90 -0
  49. package/dist/components/ui/quick-form-field/components/field-header.cjs +9 -4
  50. package/dist/components/ui/quick-form-field/components/field-header.d.ts +4 -1
  51. package/dist/components/ui/quick-form-field/components/field-header.js +9 -4
  52. package/dist/components/ui/quick-form-field/components/lock-toggle-button.cjs +2 -2
  53. package/dist/components/ui/quick-form-field/components/lock-toggle-button.d.ts +5 -4
  54. package/dist/components/ui/quick-form-field/components/lock-toggle-button.js +2 -2
  55. package/dist/components/ui/quick-form-field/index.d.ts +1 -1
  56. package/dist/components/ui/quick-form-field/quick-form-field.cjs +158 -222
  57. package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -4
  58. package/dist/components/ui/quick-form-field/quick-form-field.js +159 -223
  59. package/dist/components/ui/quick-form-field/types.cjs +2 -2
  60. package/dist/components/ui/quick-form-field/types.d.ts +39 -32
  61. package/dist/components/ui/quick-form-field/types.js +2 -2
  62. package/dist/components/ui/quick-form-field/utils.cjs +5 -59
  63. package/dist/components/ui/quick-form-field/utils.d.ts +2 -24
  64. package/dist/components/ui/quick-form-field/utils.js +3 -48
  65. package/dist/components/ui/sources.cjs +175 -0
  66. package/dist/components/ui/sources.d.ts +44 -0
  67. package/dist/components/ui/sources.js +132 -0
  68. package/dist/index.cjs +156 -7
  69. package/dist/index.d.ts +17 -1
  70. package/dist/index.js +9 -1
  71. package/dist/lib/date-value.cjs +46 -0
  72. package/dist/lib/date-value.d.ts +8 -0
  73. package/dist/lib/date-value.js +12 -0
  74. package/dist/lib/index.cjs +8 -1
  75. package/dist/lib/index.d.ts +1 -0
  76. package/dist/lib/index.js +2 -1
  77. package/dist/lib/url.cjs +54 -0
  78. package/dist/lib/url.d.ts +8 -0
  79. package/dist/lib/url.js +17 -0
  80. package/dist/styles.css +239 -78
  81. package/dist/tailwind.utilities.css +15 -0
  82. package/package.json +1 -1
  83. package/dist/components/custom/chat-composer.cjs +0 -134
  84. package/dist/components/custom/chat-composer.d.ts +0 -14
  85. package/dist/components/custom/chat-composer.js +0 -100
  86. package/dist/components/custom/chat-first-experience.cjs +0 -87
  87. package/dist/components/custom/chat-first-experience.d.ts +0 -24
  88. package/dist/components/custom/chat-first-experience.js +0 -53
  89. package/dist/components/custom/chat-prompt-suggestions.cjs +0 -49
  90. package/dist/components/custom/chat-prompt-suggestions.d.ts +0 -18
  91. package/dist/components/custom/chat-prompt-suggestions.js +0 -15
@@ -0,0 +1,429 @@
1
+ "use strict";
2
+ "use client";
3
+ var __webpack_require__ = {};
4
+ (()=>{
5
+ __webpack_require__.d = (exports1, definition)=>{
6
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ get: definition[key]
9
+ });
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.r = (exports1)=>{
17
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
18
+ value: 'Module'
19
+ });
20
+ Object.defineProperty(exports1, '__esModule', {
21
+ value: true
22
+ });
23
+ };
24
+ })();
25
+ var __webpack_exports__ = {};
26
+ __webpack_require__.r(__webpack_exports__);
27
+ __webpack_require__.d(__webpack_exports__, {
28
+ DEFAULT_CHAT_COMPOSER_STRINGS: ()=>DEFAULT_CHAT_COMPOSER_STRINGS,
29
+ ChatComposerToolbar: ()=>ChatComposerToolbar,
30
+ chatComposerErrorVariants: ()=>chatComposerErrorVariants,
31
+ ChatComposerFooter: ()=>ChatComposerFooter,
32
+ ChatComposerAttachments: ()=>ChatComposerAttachments,
33
+ ChatComposerInputGroup: ()=>ChatComposerInputGroup,
34
+ ChatComposer: ()=>ChatComposer,
35
+ ChatComposerTextarea: ()=>ChatComposerTextarea,
36
+ chatComposerVariants: ()=>chatComposerVariants,
37
+ ChatComposerAttachButton: ()=>ChatComposerAttachButton,
38
+ useChatComposer: ()=>useChatComposer,
39
+ ChatComposerError: ()=>ChatComposerError,
40
+ ChatComposerSubmit: ()=>ChatComposerSubmit
41
+ });
42
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
43
+ const external_class_variance_authority_namespaceObject = require("class-variance-authority");
44
+ const external_lucide_react_namespaceObject = require("lucide-react");
45
+ const external_react_namespaceObject = require("react");
46
+ const index_cjs_namespaceObject = require("../../lib/index.cjs");
47
+ const external_attachment_cjs_namespaceObject = require("./attachment.cjs");
48
+ const external_button_cjs_namespaceObject = require("./button.cjs");
49
+ const external_file_validation_cjs_namespaceObject = require("./file-validation.cjs");
50
+ const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
51
+ const DEFAULT_CHAT_COMPOSER_STRINGS = {
52
+ label: 'Message',
53
+ placeholder: 'Ask anything',
54
+ send: 'Send message',
55
+ stop: 'Stop generating',
56
+ attach: 'Attach files',
57
+ removeAttachment: (name)=>`Remove ${name}`,
58
+ dismissError: 'Dismiss'
59
+ };
60
+ const ChatComposerContext = /*#__PURE__*/ external_react_namespaceObject.createContext(null);
61
+ function useChatComposerInternal() {
62
+ const context = external_react_namespaceObject.useContext(ChatComposerContext);
63
+ if (!context) throw new Error('ChatComposer parts must be rendered inside <ChatComposer>.');
64
+ return context;
65
+ }
66
+ function useChatComposer() {
67
+ return useChatComposerInternal();
68
+ }
69
+ const chatComposerVariants = (0, external_class_variance_authority_namespaceObject.cva)('flex w-full min-w-0 flex-col', {
70
+ variants: {
71
+ density: {
72
+ comfortable: 'gap-2',
73
+ compact: 'gap-1.5'
74
+ }
75
+ },
76
+ defaultVariants: {
77
+ density: 'comfortable'
78
+ }
79
+ });
80
+ const NO_ATTACHMENTS = [];
81
+ const ChatComposer = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, children, value: valueProp, defaultValue, onValueChange, onSubmit, status = 'idle', onStop, disabled = false, submitDisabled = false, density, attachments = NO_ATTACHMENTS, onRemoveAttachment, strings, ...props }, ref)=>{
82
+ const resolvedDensity = density ?? 'comfortable';
83
+ const controlled = void 0 !== valueProp;
84
+ const [uncontrolledValue, setUncontrolledValue] = external_react_namespaceObject.useState(defaultValue ?? '');
85
+ const value = controlled ? valueProp : uncontrolledValue;
86
+ const fileInputRef = external_react_namespaceObject.useRef(null);
87
+ const onFilesRef = external_react_namespaceObject.useRef(void 0);
88
+ const attachmentsBusy = attachments.some(({ state })=>'uploading' === state || 'processing' === state);
89
+ const canSubmit = !disabled && !submitDisabled && !attachmentsBusy && 'idle' === status && ('' !== value.trim() || attachments.length > 0);
90
+ const setValue = external_react_namespaceObject.useCallback((next)=>{
91
+ if (!controlled) setUncontrolledValue(next);
92
+ onValueChange?.(next);
93
+ }, [
94
+ controlled,
95
+ onValueChange
96
+ ]);
97
+ const submit = external_react_namespaceObject.useCallback(()=>{
98
+ if (!canSubmit) return;
99
+ onSubmit?.(value, {
100
+ attachments
101
+ });
102
+ if (!controlled) setValue('');
103
+ }, [
104
+ canSubmit,
105
+ onSubmit,
106
+ value,
107
+ attachments,
108
+ controlled,
109
+ setValue
110
+ ]);
111
+ const openFilePicker = external_react_namespaceObject.useCallback(({ accept, multiple = true, onFiles })=>{
112
+ const input = fileInputRef.current;
113
+ if (!input) return;
114
+ input.accept = accept ?? '';
115
+ input.multiple = multiple;
116
+ onFilesRef.current = onFiles;
117
+ input.click();
118
+ }, []);
119
+ const text = external_react_namespaceObject.useMemo(()=>({
120
+ ...DEFAULT_CHAT_COMPOSER_STRINGS,
121
+ ...strings
122
+ }), [
123
+ strings
124
+ ]);
125
+ const context = external_react_namespaceObject.useMemo(()=>({
126
+ value,
127
+ setValue,
128
+ status,
129
+ density: resolvedDensity,
130
+ disabled,
131
+ strings: text,
132
+ attachments,
133
+ onRemoveAttachment,
134
+ onStop,
135
+ canSubmit,
136
+ submit,
137
+ openFilePicker
138
+ }), [
139
+ value,
140
+ setValue,
141
+ status,
142
+ resolvedDensity,
143
+ disabled,
144
+ text,
145
+ attachments,
146
+ onRemoveAttachment,
147
+ onStop,
148
+ canSubmit,
149
+ submit,
150
+ openFilePicker
151
+ ]);
152
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ChatComposerContext.Provider, {
153
+ value: context,
154
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("form", {
155
+ ref: ref,
156
+ "data-slot": "chat-composer",
157
+ "data-status": status,
158
+ "data-density": resolvedDensity,
159
+ "data-disabled": disabled ? '' : void 0,
160
+ className: (0, index_cjs_namespaceObject.cn)(chatComposerVariants({
161
+ density: resolvedDensity
162
+ }), className),
163
+ onSubmit: (event)=>{
164
+ event.preventDefault();
165
+ submit();
166
+ },
167
+ ...props,
168
+ children: [
169
+ children,
170
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
171
+ ref: fileInputRef,
172
+ type: "file",
173
+ hidden: true,
174
+ tabIndex: -1,
175
+ "data-slot": "chat-composer-file-input",
176
+ disabled: disabled,
177
+ onChange: (event)=>{
178
+ const files = Array.from(event.target.files ?? []);
179
+ event.target.value = '';
180
+ if (files.length > 0) onFilesRef.current?.(files);
181
+ }
182
+ })
183
+ ]
184
+ })
185
+ });
186
+ });
187
+ ChatComposer.displayName = 'ChatComposer';
188
+ const FOCUS_RING_CLASS = 'has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error future:has-[[data-slot=input-group-control]:focus-visible]:ring-offset-2 future:has-[[data-slot=input-group-control]:focus-visible]:ring-offset-background';
189
+ const ChatComposerInputGroup = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, disabled, invalid, error, ...props }, ref)=>{
190
+ const composer = useChatComposer();
191
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroup, {
192
+ ref: ref,
193
+ layout: "block",
194
+ disabled: disabled || composer.disabled,
195
+ invalid: invalid,
196
+ error: error,
197
+ className: (0, index_cjs_namespaceObject.cn)(FOCUS_RING_CLASS, invalid || error ? 'has-[[data-slot=input-group-control]:focus-visible]:ring-error' : 'has-[[data-slot=input-group-control]:focus-visible]:ring-ring future:has-[[data-slot=input-group-control]:focus-visible]:ring-primary', className),
198
+ ...props
199
+ });
200
+ });
201
+ ChatComposerInputGroup.displayName = 'ChatComposerInputGroup';
202
+ const ChatComposerTextarea = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, minRows, maxRows = 6, placeholder, disabled, onChange, onKeyDown, 'aria-label': ariaLabel, ...props }, ref)=>{
203
+ const composer = useChatComposer();
204
+ const rows = minRows ?? ('compact' === composer.density ? 1 : 2);
205
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupRow, {
206
+ className: (0, index_cjs_namespaceObject.cn)('has-[[data-slot=input-group-control]:focus-visible]:ring-0 has-[[data-slot=input-group-control]_:focus-visible]:ring-0', 'compact' === composer.density ? 'min-h-0 py-1 future:min-h-0' : 'py-2'),
207
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupTextarea, {
208
+ ref: ref,
209
+ rows: rows,
210
+ minRows: rows,
211
+ maxRows: maxRows,
212
+ "aria-label": ariaLabel ?? composer.strings.label,
213
+ placeholder: placeholder ?? composer.strings.placeholder,
214
+ disabled: disabled || composer.disabled,
215
+ value: composer.value,
216
+ onChange: (event)=>{
217
+ onChange?.(event);
218
+ composer.setValue(event.target.value);
219
+ },
220
+ onKeyDown: (event)=>{
221
+ onKeyDown?.(event);
222
+ if (event.defaultPrevented || 'Enter' !== event.key || event.shiftKey) return;
223
+ if (event.nativeEvent.isComposing || 229 === event.keyCode) return;
224
+ event.preventDefault();
225
+ composer.submit();
226
+ },
227
+ className: className,
228
+ ...props
229
+ })
230
+ });
231
+ });
232
+ ChatComposerTextarea.displayName = 'ChatComposerTextarea';
233
+ const ChatComposerToolbar = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>{
234
+ const { density } = useChatComposer();
235
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupBody, {
236
+ ref: ref,
237
+ "data-slot": "chat-composer-toolbar",
238
+ className: (0, index_cjs_namespaceObject.cn)('flex min-w-0 items-center gap-1', 'compact' === density ? 'px-1.5 py-1' : 'px-2 py-1.5', className),
239
+ ...props
240
+ });
241
+ });
242
+ ChatComposerToolbar.displayName = 'ChatComposerToolbar';
243
+ const ChatComposerAttachButton = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ accept, maxSize, maxFiles, multiple = true, onFiles, onClick, children, disabled, ...props }, ref)=>{
244
+ const composer = useChatComposerInternal();
245
+ const openPicker = ()=>{
246
+ const remaining = void 0 === maxFiles ? void 0 : Math.max(0, maxFiles - composer.attachments.length);
247
+ composer.openFilePicker({
248
+ accept: Array.isArray(accept) ? accept.join(',') : accept,
249
+ multiple,
250
+ onFiles: (files)=>{
251
+ const { accepted, rejected } = (0, external_file_validation_cjs_namespaceObject.validateFiles)(files, {
252
+ accept,
253
+ maxSize,
254
+ maxFiles: remaining
255
+ });
256
+ onFiles?.(accepted, rejected);
257
+ }
258
+ });
259
+ };
260
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupButton, {
261
+ ref: ref,
262
+ "data-slot": "chat-composer-attach",
263
+ icon: true,
264
+ size: 'compact' === composer.density ? '3xs' : '2xs',
265
+ "aria-label": composer.strings.attach,
266
+ disabled: disabled || composer.disabled,
267
+ onClick: (event)=>{
268
+ onClick?.(event);
269
+ if (!event.defaultPrevented) openPicker();
270
+ },
271
+ ...props,
272
+ children: children ?? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Paperclip, {})
273
+ });
274
+ });
275
+ ChatComposerAttachButton.displayName = 'ChatComposerAttachButton';
276
+ const ChatComposerSubmit = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, onClick, children, disabled, ...props }, ref)=>{
277
+ const composer = useChatComposer();
278
+ const stoppable = 'streaming' === composer.status && void 0 !== composer.onStop;
279
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupButton, {
280
+ ref: ref,
281
+ "data-slot": "chat-composer-submit",
282
+ "data-status": composer.status,
283
+ type: stoppable ? 'button' : 'submit',
284
+ variant: stoppable ? 'ghost' : 'default',
285
+ icon: true,
286
+ size: 'compact' === composer.density ? '3xs' : '2xs',
287
+ "aria-label": stoppable ? composer.strings.stop : composer.strings.send,
288
+ disabled: disabled || composer.disabled || !stoppable && !composer.canSubmit,
289
+ onClick: (event)=>{
290
+ onClick?.(event);
291
+ if (stoppable && !event.defaultPrevented) composer.onStop?.();
292
+ },
293
+ className: (0, index_cjs_namespaceObject.cn)('ml-auto', className),
294
+ ...props,
295
+ children: children ?? (stoppable ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Square, {
296
+ className: "fill-current"
297
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowUp, {}))
298
+ });
299
+ });
300
+ ChatComposerSubmit.displayName = 'ChatComposerSubmit';
301
+ const ChatComposerAttachments = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>{
302
+ const { attachments, onRemoveAttachment, strings, disabled, density } = useChatComposer();
303
+ if (0 === attachments.length) return null;
304
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentGroup, {
305
+ ref: ref,
306
+ "data-slot": "chat-composer-attachments",
307
+ className: (0, index_cjs_namespaceObject.cn)('compact' === density ? 'px-2 pt-1.5' : 'px-2.5 pt-2.5', className),
308
+ ...props,
309
+ children: attachments.map((attachment)=>{
310
+ const state = attachment.state ?? 'done';
311
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_attachment_cjs_namespaceObject.Attachment, {
312
+ size: 'compact' === density ? 'xs' : 'sm',
313
+ state: state,
314
+ "aria-busy": 'uploading' === state || 'processing' === state || void 0,
315
+ children: [
316
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentMedia, {
317
+ variant: attachment.previewUrl ? 'image' : 'icon',
318
+ children: attachment.previewUrl ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("img", {
319
+ src: attachment.previewUrl,
320
+ alt: ""
321
+ }) : attachment.icon ?? ('error' === state ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleAlert, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.FileText, {}))
322
+ }),
323
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_attachment_cjs_namespaceObject.AttachmentContent, {
324
+ children: [
325
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentTitle, {
326
+ children: attachment.name
327
+ }),
328
+ attachment.description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentDescription, {
329
+ children: attachment.description
330
+ })
331
+ ]
332
+ }),
333
+ onRemoveAttachment && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentActions, {
334
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_attachment_cjs_namespaceObject.AttachmentAction, {
335
+ "aria-label": strings.removeAttachment(attachment.name),
336
+ disabled: disabled,
337
+ onClick: ()=>onRemoveAttachment(attachment),
338
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {})
339
+ })
340
+ })
341
+ ]
342
+ }, attachment.id);
343
+ })
344
+ });
345
+ });
346
+ ChatComposerAttachments.displayName = 'ChatComposerAttachments';
347
+ const chatComposerErrorVariants = (0, external_class_variance_authority_namespaceObject.cva)("flex items-start gap-2 rounded-lg border px-3 py-2 text-xs leading-4 text-foreground [&>svg:not([class*='size-'])]:mt-px [&>svg:not([class*='size-'])]:size-3.5 [&>svg]:shrink-0", {
348
+ variants: {
349
+ variant: {
350
+ error: 'border-error/50 bg-error-background/25 [&>svg]:text-error',
351
+ warning: 'border-warning/50 bg-warning-background/25 [&>svg]:text-warning'
352
+ }
353
+ },
354
+ defaultVariants: {
355
+ variant: 'error'
356
+ }
357
+ });
358
+ const ChatComposerError = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, variant, onDismiss, children, ...props }, ref)=>{
359
+ const { strings } = useChatComposer();
360
+ const resolved = variant ?? 'error';
361
+ const Icon = 'warning' === resolved ? external_lucide_react_namespaceObject.TriangleAlert : external_lucide_react_namespaceObject.CircleAlert;
362
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
363
+ ref: ref,
364
+ role: "alert",
365
+ "data-slot": "chat-composer-error",
366
+ "data-variant": resolved,
367
+ className: (0, index_cjs_namespaceObject.cn)(chatComposerErrorVariants({
368
+ variant: resolved
369
+ }), className),
370
+ ...props,
371
+ children: [
372
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Icon, {
373
+ "aria-hidden": "true"
374
+ }),
375
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
376
+ className: "min-w-0 flex-1",
377
+ children: children
378
+ }),
379
+ onDismiss && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
380
+ variant: "ghost",
381
+ size: "4xs",
382
+ icon: true,
383
+ "aria-label": strings.dismissError,
384
+ className: "-my-0.5 shrink-0",
385
+ onClick: onDismiss,
386
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {})
387
+ })
388
+ ]
389
+ });
390
+ });
391
+ ChatComposerError.displayName = 'ChatComposerError';
392
+ const ChatComposerFooter = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
393
+ ref: ref,
394
+ "data-slot": "chat-composer-footer",
395
+ className: (0, index_cjs_namespaceObject.cn)('px-1 text-center text-xs text-muted-foreground', className),
396
+ ...props
397
+ }));
398
+ ChatComposerFooter.displayName = 'ChatComposerFooter';
399
+ exports.ChatComposer = __webpack_exports__.ChatComposer;
400
+ exports.ChatComposerAttachButton = __webpack_exports__.ChatComposerAttachButton;
401
+ exports.ChatComposerAttachments = __webpack_exports__.ChatComposerAttachments;
402
+ exports.ChatComposerError = __webpack_exports__.ChatComposerError;
403
+ exports.ChatComposerFooter = __webpack_exports__.ChatComposerFooter;
404
+ exports.ChatComposerInputGroup = __webpack_exports__.ChatComposerInputGroup;
405
+ exports.ChatComposerSubmit = __webpack_exports__.ChatComposerSubmit;
406
+ exports.ChatComposerTextarea = __webpack_exports__.ChatComposerTextarea;
407
+ exports.ChatComposerToolbar = __webpack_exports__.ChatComposerToolbar;
408
+ exports.DEFAULT_CHAT_COMPOSER_STRINGS = __webpack_exports__.DEFAULT_CHAT_COMPOSER_STRINGS;
409
+ exports.chatComposerErrorVariants = __webpack_exports__.chatComposerErrorVariants;
410
+ exports.chatComposerVariants = __webpack_exports__.chatComposerVariants;
411
+ exports.useChatComposer = __webpack_exports__.useChatComposer;
412
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
413
+ "ChatComposer",
414
+ "ChatComposerAttachButton",
415
+ "ChatComposerAttachments",
416
+ "ChatComposerError",
417
+ "ChatComposerFooter",
418
+ "ChatComposerInputGroup",
419
+ "ChatComposerSubmit",
420
+ "ChatComposerTextarea",
421
+ "ChatComposerToolbar",
422
+ "DEFAULT_CHAT_COMPOSER_STRINGS",
423
+ "chatComposerErrorVariants",
424
+ "chatComposerVariants",
425
+ "useChatComposer"
426
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
427
+ Object.defineProperty(exports, '__esModule', {
428
+ value: true
429
+ });
@@ -0,0 +1,157 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ import { type AttachmentState } from './attachment';
4
+ import { type ButtonProps } from './button';
5
+ import { type FileRejection, type FileValidationOptions } from './file-validation';
6
+ import { type InputGroupProps, type InputGroupTextareaProps } from './input-group';
7
+ /**
8
+ * The prompt input of a chat. `ChatComposer` is the form and owns the draft, the status and the
9
+ * attachments; its parts read them from context:
10
+ *
11
+ * ```tsx
12
+ * <ChatComposer onSubmit={send} status={status} onStop={stop}>
13
+ * <ChatComposerError />
14
+ * <ChatComposerInputGroup>
15
+ * <ChatComposerAttachments />
16
+ * <ChatComposerTextarea />
17
+ * <ChatComposerToolbar>
18
+ * <ChatComposerAttachButton onFiles={add} />
19
+ * <ChatComposerSubmit />
20
+ * </ChatComposerToolbar>
21
+ * </ChatComposerInputGroup>
22
+ * <ChatComposerFooter />
23
+ * </ChatComposer>
24
+ * ```
25
+ *
26
+ * Enter sends and Shift+Enter starts a new line. While `status` is `streaming` the submit button
27
+ * becomes a stop button and Enter does not send.
28
+ */
29
+ export interface ChatComposerStrings {
30
+ /** Accessible name of the textarea. */
31
+ label: string;
32
+ placeholder: string;
33
+ send: string;
34
+ stop: string;
35
+ attach: string;
36
+ removeAttachment: (name: string) => string;
37
+ dismissError: string;
38
+ }
39
+ export declare const DEFAULT_CHAT_COMPOSER_STRINGS: ChatComposerStrings;
40
+ export type ChatComposerStatus = 'idle' | 'streaming';
41
+ export type ChatComposerDensity = 'comfortable' | 'compact';
42
+ /** One chip in `ChatComposerAttachments`. The consumer owns the list and its upload states. */
43
+ export interface ChatComposerAttachmentItem {
44
+ id: string;
45
+ name: string;
46
+ /** Second line, such as the size, or the reason an upload failed. */
47
+ description?: React.ReactNode;
48
+ state?: AttachmentState;
49
+ /** Replaces the default file icon. */
50
+ icon?: React.ReactNode;
51
+ /** An image URL shown as a thumbnail instead of the icon. */
52
+ previewUrl?: string;
53
+ }
54
+ export interface ChatComposerSubmitDetails {
55
+ attachments: ChatComposerAttachmentItem[];
56
+ }
57
+ /** What `useChatComposer` gives a custom part. */
58
+ export interface ChatComposerContextValue {
59
+ value: string;
60
+ /** Replaces the draft, through `onValueChange` when controlled. */
61
+ setValue: (value: string) => void;
62
+ status: ChatComposerStatus;
63
+ density: ChatComposerDensity;
64
+ disabled: boolean;
65
+ strings: ChatComposerStrings;
66
+ attachments: ChatComposerAttachmentItem[];
67
+ onRemoveAttachment?: (attachment: ChatComposerAttachmentItem) => void;
68
+ onStop?: () => void;
69
+ canSubmit: boolean;
70
+ /** Sends the draft, if `canSubmit`. */
71
+ submit: () => void;
72
+ }
73
+ /** The enclosing `ChatComposer`'s state and actions, for custom parts. */
74
+ declare function useChatComposer(): ChatComposerContextValue;
75
+ declare const chatComposerVariants: (props?: ({
76
+ density?: "compact" | "comfortable" | null | undefined;
77
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
78
+ export interface ChatComposerProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'defaultValue'>, VariantProps<typeof chatComposerVariants> {
79
+ /** Controls the draft. Clear it yourself in `onSubmit`. */
80
+ value?: string;
81
+ defaultValue?: string;
82
+ /** Called on every edit, and with `''` when an uncontrolled draft clears after sending. */
83
+ onValueChange?: (value: string) => void;
84
+ /** Called with the draft when the user sends. An uncontrolled draft clears itself after. */
85
+ onSubmit?: (value: string, details: ChatComposerSubmitDetails) => void;
86
+ /** `streaming` turns the submit button into a stop button and holds back Enter. */
87
+ status?: ChatComposerStatus;
88
+ /**
89
+ * Called by the stop button while `status` is `streaming`. Without it, there is no stop button.
90
+ */
91
+ onStop?: () => void;
92
+ disabled?: boolean;
93
+ /** Holds back sending, by button and by Enter, while the textarea stays editable. */
94
+ submitDisabled?: boolean;
95
+ /**
96
+ * Files attached to the draft, rendered by `ChatComposerAttachments`. One still uploading or
97
+ * processing holds back sending.
98
+ */
99
+ attachments?: ChatComposerAttachmentItem[];
100
+ /** Adds a remove action to every attachment chip. */
101
+ onRemoveAttachment?: (attachment: ChatComposerAttachmentItem) => void;
102
+ /** Overrides for any subset of the English strings. */
103
+ strings?: Partial<ChatComposerStrings>;
104
+ }
105
+ declare const ChatComposer: React.ForwardRefExoticComponent<ChatComposerProps & React.RefAttributes<HTMLFormElement>>;
106
+ export interface ChatComposerInputGroupProps extends Omit<InputGroupProps, 'layout'> {
107
+ }
108
+ /** The field box: an `InputGroup` in block layout holding attachments, textarea and toolbar. */
109
+ declare const ChatComposerInputGroup: React.ForwardRefExoticComponent<ChatComposerInputGroupProps & React.RefAttributes<HTMLDivElement>>;
110
+ /** The draft lives on `ChatComposer`, so the textarea takes no `value` of its own. */
111
+ export interface ChatComposerTextareaProps extends Omit<InputGroupTextareaProps, 'value' | 'defaultValue'> {
112
+ }
113
+ declare const ChatComposerTextarea: React.ForwardRefExoticComponent<Omit<ChatComposerTextareaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
114
+ export interface ChatComposerToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
115
+ }
116
+ /**
117
+ * The row of actions below the textarea. `ChatComposerSubmit` pushes itself right with `ml-auto`;
118
+ * to group another action with it, such as a mic button, give that action `ml-auto` and the
119
+ * submit button `ml-0`.
120
+ */
121
+ declare const ChatComposerToolbar: React.ForwardRefExoticComponent<ChatComposerToolbarProps & React.RefAttributes<HTMLDivElement>>;
122
+ export interface ChatComposerAttachButtonProps extends Omit<ButtonProps, 'onChange'>, FileValidationOptions {
123
+ /** Allows picking several files at once. Defaults to true. */
124
+ multiple?: boolean;
125
+ /**
126
+ * Called once per pick, with the files that passed the checks and those that did not. `maxFiles`
127
+ * counts the composer's attachments too, so it caps the draft rather than each pick.
128
+ */
129
+ onFiles?: (accepted: File[], rejected: FileRejection[]) => void;
130
+ }
131
+ declare const ChatComposerAttachButton: React.ForwardRefExoticComponent<ChatComposerAttachButtonProps & React.RefAttributes<HTMLButtonElement>>;
132
+ export interface ChatComposerSubmitProps extends ButtonProps {
133
+ }
134
+ /**
135
+ * Sends while idle and stops while streaming. Idle, it is disabled until there is text or an
136
+ * attachment to send, and while an attachment is busy or `submitDisabled` is set. Streaming
137
+ * without an `onStop`, it stays a disabled send button.
138
+ */
139
+ declare const ChatComposerSubmit: React.ForwardRefExoticComponent<ChatComposerSubmitProps & React.RefAttributes<HTMLButtonElement>>;
140
+ export interface ChatComposerAttachmentsProps extends React.HTMLAttributes<HTMLDivElement> {
141
+ }
142
+ /** The draft's attachments as a scrolling row of chips. Renders nothing when there are none. */
143
+ declare const ChatComposerAttachments: React.ForwardRefExoticComponent<ChatComposerAttachmentsProps & React.RefAttributes<HTMLDivElement>>;
144
+ declare const chatComposerErrorVariants: (props?: ({
145
+ variant?: "error" | "warning" | null | undefined;
146
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
147
+ export interface ChatComposerErrorProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof chatComposerErrorVariants> {
148
+ /** Adds a dismiss button. */
149
+ onDismiss?: () => void;
150
+ }
151
+ /** A message about the last send, such as a failed request or a rate limit. */
152
+ declare const ChatComposerError: React.ForwardRefExoticComponent<ChatComposerErrorProps & React.RefAttributes<HTMLDivElement>>;
153
+ export interface ChatComposerFooterProps extends React.HTMLAttributes<HTMLParagraphElement> {
154
+ }
155
+ /** Small muted text below the field, such as an AI disclaimer. */
156
+ declare const ChatComposerFooter: React.ForwardRefExoticComponent<ChatComposerFooterProps & React.RefAttributes<HTMLParagraphElement>>;
157
+ export { ChatComposer, ChatComposerAttachButton, ChatComposerAttachments, ChatComposerError, ChatComposerFooter, ChatComposerInputGroup, ChatComposerSubmit, ChatComposerTextarea, ChatComposerToolbar, chatComposerErrorVariants, chatComposerVariants, useChatComposer, };