@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.
- package/dist/components/custom/demo-composer.cjs +80 -0
- package/dist/components/custom/demo-composer.d.ts +11 -0
- package/dist/components/custom/demo-composer.js +46 -0
- package/dist/components/custom/panel-flow.cjs +2 -2
- package/dist/components/custom/panel-flow.js +2 -2
- package/dist/components/forms/field-control.cjs +3 -2
- package/dist/components/forms/field-control.js +3 -2
- package/dist/components/forms/validation-converter.cjs +14 -5
- package/dist/components/forms/validation-converter.js +14 -5
- package/dist/components/ui/chat-composer.cjs +429 -0
- package/dist/components/ui/chat-composer.d.ts +157 -0
- package/dist/components/ui/chat-composer.js +359 -0
- package/dist/components/ui/chat-hero.cjs +244 -0
- package/dist/components/ui/chat-hero.d.ts +51 -0
- package/dist/components/ui/chat-hero.js +189 -0
- package/dist/components/ui/citation.cjs +188 -0
- package/dist/components/ui/citation.d.ts +42 -0
- package/dist/components/ui/citation.js +148 -0
- package/dist/components/ui/date-picker.cjs +6 -5
- package/dist/components/ui/date-picker.js +7 -6
- package/dist/components/ui/datetime-picker.cjs +7 -10
- package/dist/components/ui/datetime-picker.js +8 -11
- package/dist/components/ui/dropzone-overlay.cjs +142 -0
- package/dist/components/ui/dropzone-overlay.d.ts +27 -0
- package/dist/components/ui/dropzone-overlay.js +105 -0
- package/dist/components/ui/file-upload.cjs +5 -29
- package/dist/components/ui/file-upload.js +2 -26
- package/dist/components/ui/file-validation.cjs +91 -0
- package/dist/components/ui/file-validation.d.ts +24 -0
- package/dist/components/ui/file-validation.js +51 -0
- package/dist/components/ui/hover-card.cjs +15 -8
- package/dist/components/ui/hover-card.d.ts +4 -1
- package/dist/components/ui/hover-card.js +16 -9
- package/dist/components/ui/index.cjs +304 -216
- package/dist/components/ui/index.d.ts +8 -0
- package/dist/components/ui/index.js +8 -0
- package/dist/components/ui/input-group.cjs +1 -1
- package/dist/components/ui/input-group.d.ts +2 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/message-actions.cjs +302 -0
- package/dist/components/ui/message-actions.d.ts +102 -0
- package/dist/components/ui/message-actions.js +241 -0
- package/dist/components/ui/message.cjs +1 -1
- package/dist/components/ui/message.d.ts +2 -0
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/prompt-suggestions.cjs +133 -0
- package/dist/components/ui/prompt-suggestions.d.ts +52 -0
- package/dist/components/ui/prompt-suggestions.js +90 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +9 -4
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +4 -1
- package/dist/components/ui/quick-form-field/components/field-header.js +9 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.cjs +2 -2
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.d.ts +5 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.js +2 -2
- package/dist/components/ui/quick-form-field/index.d.ts +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +158 -222
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -4
- package/dist/components/ui/quick-form-field/quick-form-field.js +159 -223
- package/dist/components/ui/quick-form-field/types.cjs +2 -2
- package/dist/components/ui/quick-form-field/types.d.ts +39 -32
- package/dist/components/ui/quick-form-field/types.js +2 -2
- package/dist/components/ui/quick-form-field/utils.cjs +5 -59
- package/dist/components/ui/quick-form-field/utils.d.ts +2 -24
- package/dist/components/ui/quick-form-field/utils.js +3 -48
- package/dist/components/ui/sources.cjs +175 -0
- package/dist/components/ui/sources.d.ts +44 -0
- package/dist/components/ui/sources.js +132 -0
- package/dist/index.cjs +156 -7
- package/dist/index.d.ts +17 -1
- package/dist/index.js +9 -1
- package/dist/lib/date-value.cjs +46 -0
- package/dist/lib/date-value.d.ts +8 -0
- package/dist/lib/date-value.js +12 -0
- package/dist/lib/index.cjs +8 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -1
- package/dist/lib/url.cjs +54 -0
- package/dist/lib/url.d.ts +8 -0
- package/dist/lib/url.js +17 -0
- package/dist/styles.css +239 -78
- package/dist/tailwind.utilities.css +15 -0
- package/package.json +1 -1
- package/dist/components/custom/chat-composer.cjs +0 -134
- package/dist/components/custom/chat-composer.d.ts +0 -14
- package/dist/components/custom/chat-composer.js +0 -100
- package/dist/components/custom/chat-first-experience.cjs +0 -87
- package/dist/components/custom/chat-first-experience.d.ts +0 -24
- package/dist/components/custom/chat-first-experience.js +0 -53
- package/dist/components/custom/chat-prompt-suggestions.cjs +0 -49
- package/dist/components/custom/chat-prompt-suggestions.d.ts +0 -18
- package/dist/components/custom/chat-prompt-suggestions.js +0 -15
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { ArrowUp, CircleAlert, FileText, Paperclip, Square, TriangleAlert, X } from "lucide-react";
|
|
5
|
+
import { createContext, forwardRef, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "../../lib/index.js";
|
|
7
|
+
import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle } from "./attachment.js";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { validateFiles } from "./file-validation.js";
|
|
10
|
+
import { InputGroup, InputGroupBody, InputGroupButton, InputGroupRow, InputGroupTextarea } from "./input-group.js";
|
|
11
|
+
const DEFAULT_CHAT_COMPOSER_STRINGS = {
|
|
12
|
+
label: 'Message',
|
|
13
|
+
placeholder: 'Ask anything',
|
|
14
|
+
send: 'Send message',
|
|
15
|
+
stop: 'Stop generating',
|
|
16
|
+
attach: 'Attach files',
|
|
17
|
+
removeAttachment: (name)=>`Remove ${name}`,
|
|
18
|
+
dismissError: 'Dismiss'
|
|
19
|
+
};
|
|
20
|
+
const ChatComposerContext = /*#__PURE__*/ createContext(null);
|
|
21
|
+
function useChatComposerInternal() {
|
|
22
|
+
const context = useContext(ChatComposerContext);
|
|
23
|
+
if (!context) throw new Error('ChatComposer parts must be rendered inside <ChatComposer>.');
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
function useChatComposer() {
|
|
27
|
+
return useChatComposerInternal();
|
|
28
|
+
}
|
|
29
|
+
const chatComposerVariants = cva('flex w-full min-w-0 flex-col', {
|
|
30
|
+
variants: {
|
|
31
|
+
density: {
|
|
32
|
+
comfortable: 'gap-2',
|
|
33
|
+
compact: 'gap-1.5'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
density: 'comfortable'
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const NO_ATTACHMENTS = [];
|
|
41
|
+
const ChatComposer = /*#__PURE__*/ forwardRef(({ className, children, value: valueProp, defaultValue, onValueChange, onSubmit, status = 'idle', onStop, disabled = false, submitDisabled = false, density, attachments = NO_ATTACHMENTS, onRemoveAttachment, strings, ...props }, ref)=>{
|
|
42
|
+
const resolvedDensity = density ?? 'comfortable';
|
|
43
|
+
const controlled = void 0 !== valueProp;
|
|
44
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? '');
|
|
45
|
+
const value = controlled ? valueProp : uncontrolledValue;
|
|
46
|
+
const fileInputRef = useRef(null);
|
|
47
|
+
const onFilesRef = useRef(void 0);
|
|
48
|
+
const attachmentsBusy = attachments.some(({ state })=>'uploading' === state || 'processing' === state);
|
|
49
|
+
const canSubmit = !disabled && !submitDisabled && !attachmentsBusy && 'idle' === status && ('' !== value.trim() || attachments.length > 0);
|
|
50
|
+
const setValue = useCallback((next)=>{
|
|
51
|
+
if (!controlled) setUncontrolledValue(next);
|
|
52
|
+
onValueChange?.(next);
|
|
53
|
+
}, [
|
|
54
|
+
controlled,
|
|
55
|
+
onValueChange
|
|
56
|
+
]);
|
|
57
|
+
const submit = useCallback(()=>{
|
|
58
|
+
if (!canSubmit) return;
|
|
59
|
+
onSubmit?.(value, {
|
|
60
|
+
attachments
|
|
61
|
+
});
|
|
62
|
+
if (!controlled) setValue('');
|
|
63
|
+
}, [
|
|
64
|
+
canSubmit,
|
|
65
|
+
onSubmit,
|
|
66
|
+
value,
|
|
67
|
+
attachments,
|
|
68
|
+
controlled,
|
|
69
|
+
setValue
|
|
70
|
+
]);
|
|
71
|
+
const openFilePicker = useCallback(({ accept, multiple = true, onFiles })=>{
|
|
72
|
+
const input = fileInputRef.current;
|
|
73
|
+
if (!input) return;
|
|
74
|
+
input.accept = accept ?? '';
|
|
75
|
+
input.multiple = multiple;
|
|
76
|
+
onFilesRef.current = onFiles;
|
|
77
|
+
input.click();
|
|
78
|
+
}, []);
|
|
79
|
+
const text = useMemo(()=>({
|
|
80
|
+
...DEFAULT_CHAT_COMPOSER_STRINGS,
|
|
81
|
+
...strings
|
|
82
|
+
}), [
|
|
83
|
+
strings
|
|
84
|
+
]);
|
|
85
|
+
const context = useMemo(()=>({
|
|
86
|
+
value,
|
|
87
|
+
setValue,
|
|
88
|
+
status,
|
|
89
|
+
density: resolvedDensity,
|
|
90
|
+
disabled,
|
|
91
|
+
strings: text,
|
|
92
|
+
attachments,
|
|
93
|
+
onRemoveAttachment,
|
|
94
|
+
onStop,
|
|
95
|
+
canSubmit,
|
|
96
|
+
submit,
|
|
97
|
+
openFilePicker
|
|
98
|
+
}), [
|
|
99
|
+
value,
|
|
100
|
+
setValue,
|
|
101
|
+
status,
|
|
102
|
+
resolvedDensity,
|
|
103
|
+
disabled,
|
|
104
|
+
text,
|
|
105
|
+
attachments,
|
|
106
|
+
onRemoveAttachment,
|
|
107
|
+
onStop,
|
|
108
|
+
canSubmit,
|
|
109
|
+
submit,
|
|
110
|
+
openFilePicker
|
|
111
|
+
]);
|
|
112
|
+
return /*#__PURE__*/ jsx(ChatComposerContext.Provider, {
|
|
113
|
+
value: context,
|
|
114
|
+
children: /*#__PURE__*/ jsxs("form", {
|
|
115
|
+
ref: ref,
|
|
116
|
+
"data-slot": "chat-composer",
|
|
117
|
+
"data-status": status,
|
|
118
|
+
"data-density": resolvedDensity,
|
|
119
|
+
"data-disabled": disabled ? '' : void 0,
|
|
120
|
+
className: cn(chatComposerVariants({
|
|
121
|
+
density: resolvedDensity
|
|
122
|
+
}), className),
|
|
123
|
+
onSubmit: (event)=>{
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
submit();
|
|
126
|
+
},
|
|
127
|
+
...props,
|
|
128
|
+
children: [
|
|
129
|
+
children,
|
|
130
|
+
/*#__PURE__*/ jsx("input", {
|
|
131
|
+
ref: fileInputRef,
|
|
132
|
+
type: "file",
|
|
133
|
+
hidden: true,
|
|
134
|
+
tabIndex: -1,
|
|
135
|
+
"data-slot": "chat-composer-file-input",
|
|
136
|
+
disabled: disabled,
|
|
137
|
+
onChange: (event)=>{
|
|
138
|
+
const files = Array.from(event.target.files ?? []);
|
|
139
|
+
event.target.value = '';
|
|
140
|
+
if (files.length > 0) onFilesRef.current?.(files);
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
ChatComposer.displayName = 'ChatComposer';
|
|
148
|
+
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';
|
|
149
|
+
const ChatComposerInputGroup = /*#__PURE__*/ forwardRef(({ className, disabled, invalid, error, ...props }, ref)=>{
|
|
150
|
+
const composer = useChatComposer();
|
|
151
|
+
return /*#__PURE__*/ jsx(InputGroup, {
|
|
152
|
+
ref: ref,
|
|
153
|
+
layout: "block",
|
|
154
|
+
disabled: disabled || composer.disabled,
|
|
155
|
+
invalid: invalid,
|
|
156
|
+
error: error,
|
|
157
|
+
className: 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),
|
|
158
|
+
...props
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
ChatComposerInputGroup.displayName = 'ChatComposerInputGroup';
|
|
162
|
+
const ChatComposerTextarea = /*#__PURE__*/ forwardRef(({ className, minRows, maxRows = 6, placeholder, disabled, onChange, onKeyDown, 'aria-label': ariaLabel, ...props }, ref)=>{
|
|
163
|
+
const composer = useChatComposer();
|
|
164
|
+
const rows = minRows ?? ('compact' === composer.density ? 1 : 2);
|
|
165
|
+
return /*#__PURE__*/ jsx(InputGroupRow, {
|
|
166
|
+
className: 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'),
|
|
167
|
+
children: /*#__PURE__*/ jsx(InputGroupTextarea, {
|
|
168
|
+
ref: ref,
|
|
169
|
+
rows: rows,
|
|
170
|
+
minRows: rows,
|
|
171
|
+
maxRows: maxRows,
|
|
172
|
+
"aria-label": ariaLabel ?? composer.strings.label,
|
|
173
|
+
placeholder: placeholder ?? composer.strings.placeholder,
|
|
174
|
+
disabled: disabled || composer.disabled,
|
|
175
|
+
value: composer.value,
|
|
176
|
+
onChange: (event)=>{
|
|
177
|
+
onChange?.(event);
|
|
178
|
+
composer.setValue(event.target.value);
|
|
179
|
+
},
|
|
180
|
+
onKeyDown: (event)=>{
|
|
181
|
+
onKeyDown?.(event);
|
|
182
|
+
if (event.defaultPrevented || 'Enter' !== event.key || event.shiftKey) return;
|
|
183
|
+
if (event.nativeEvent.isComposing || 229 === event.keyCode) return;
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
composer.submit();
|
|
186
|
+
},
|
|
187
|
+
className: className,
|
|
188
|
+
...props
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
ChatComposerTextarea.displayName = 'ChatComposerTextarea';
|
|
193
|
+
const ChatComposerToolbar = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
194
|
+
const { density } = useChatComposer();
|
|
195
|
+
return /*#__PURE__*/ jsx(InputGroupBody, {
|
|
196
|
+
ref: ref,
|
|
197
|
+
"data-slot": "chat-composer-toolbar",
|
|
198
|
+
className: cn('flex min-w-0 items-center gap-1', 'compact' === density ? 'px-1.5 py-1' : 'px-2 py-1.5', className),
|
|
199
|
+
...props
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
ChatComposerToolbar.displayName = 'ChatComposerToolbar';
|
|
203
|
+
const ChatComposerAttachButton = /*#__PURE__*/ forwardRef(({ accept, maxSize, maxFiles, multiple = true, onFiles, onClick, children, disabled, ...props }, ref)=>{
|
|
204
|
+
const composer = useChatComposerInternal();
|
|
205
|
+
const openPicker = ()=>{
|
|
206
|
+
const remaining = void 0 === maxFiles ? void 0 : Math.max(0, maxFiles - composer.attachments.length);
|
|
207
|
+
composer.openFilePicker({
|
|
208
|
+
accept: Array.isArray(accept) ? accept.join(',') : accept,
|
|
209
|
+
multiple,
|
|
210
|
+
onFiles: (files)=>{
|
|
211
|
+
const { accepted, rejected } = validateFiles(files, {
|
|
212
|
+
accept,
|
|
213
|
+
maxSize,
|
|
214
|
+
maxFiles: remaining
|
|
215
|
+
});
|
|
216
|
+
onFiles?.(accepted, rejected);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
return /*#__PURE__*/ jsx(InputGroupButton, {
|
|
221
|
+
ref: ref,
|
|
222
|
+
"data-slot": "chat-composer-attach",
|
|
223
|
+
icon: true,
|
|
224
|
+
size: 'compact' === composer.density ? '3xs' : '2xs',
|
|
225
|
+
"aria-label": composer.strings.attach,
|
|
226
|
+
disabled: disabled || composer.disabled,
|
|
227
|
+
onClick: (event)=>{
|
|
228
|
+
onClick?.(event);
|
|
229
|
+
if (!event.defaultPrevented) openPicker();
|
|
230
|
+
},
|
|
231
|
+
...props,
|
|
232
|
+
children: children ?? /*#__PURE__*/ jsx(Paperclip, {})
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
ChatComposerAttachButton.displayName = 'ChatComposerAttachButton';
|
|
236
|
+
const ChatComposerSubmit = /*#__PURE__*/ forwardRef(({ className, onClick, children, disabled, ...props }, ref)=>{
|
|
237
|
+
const composer = useChatComposer();
|
|
238
|
+
const stoppable = 'streaming' === composer.status && void 0 !== composer.onStop;
|
|
239
|
+
return /*#__PURE__*/ jsx(InputGroupButton, {
|
|
240
|
+
ref: ref,
|
|
241
|
+
"data-slot": "chat-composer-submit",
|
|
242
|
+
"data-status": composer.status,
|
|
243
|
+
type: stoppable ? 'button' : 'submit',
|
|
244
|
+
variant: stoppable ? 'ghost' : 'default',
|
|
245
|
+
icon: true,
|
|
246
|
+
size: 'compact' === composer.density ? '3xs' : '2xs',
|
|
247
|
+
"aria-label": stoppable ? composer.strings.stop : composer.strings.send,
|
|
248
|
+
disabled: disabled || composer.disabled || !stoppable && !composer.canSubmit,
|
|
249
|
+
onClick: (event)=>{
|
|
250
|
+
onClick?.(event);
|
|
251
|
+
if (stoppable && !event.defaultPrevented) composer.onStop?.();
|
|
252
|
+
},
|
|
253
|
+
className: cn('ml-auto', className),
|
|
254
|
+
...props,
|
|
255
|
+
children: children ?? (stoppable ? /*#__PURE__*/ jsx(Square, {
|
|
256
|
+
className: "fill-current"
|
|
257
|
+
}) : /*#__PURE__*/ jsx(ArrowUp, {}))
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
ChatComposerSubmit.displayName = 'ChatComposerSubmit';
|
|
261
|
+
const ChatComposerAttachments = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
262
|
+
const { attachments, onRemoveAttachment, strings, disabled, density } = useChatComposer();
|
|
263
|
+
if (0 === attachments.length) return null;
|
|
264
|
+
return /*#__PURE__*/ jsx(AttachmentGroup, {
|
|
265
|
+
ref: ref,
|
|
266
|
+
"data-slot": "chat-composer-attachments",
|
|
267
|
+
className: cn('compact' === density ? 'px-2 pt-1.5' : 'px-2.5 pt-2.5', className),
|
|
268
|
+
...props,
|
|
269
|
+
children: attachments.map((attachment)=>{
|
|
270
|
+
const state = attachment.state ?? 'done';
|
|
271
|
+
return /*#__PURE__*/ jsxs(Attachment, {
|
|
272
|
+
size: 'compact' === density ? 'xs' : 'sm',
|
|
273
|
+
state: state,
|
|
274
|
+
"aria-busy": 'uploading' === state || 'processing' === state || void 0,
|
|
275
|
+
children: [
|
|
276
|
+
/*#__PURE__*/ jsx(AttachmentMedia, {
|
|
277
|
+
variant: attachment.previewUrl ? 'image' : 'icon',
|
|
278
|
+
children: attachment.previewUrl ? /*#__PURE__*/ jsx("img", {
|
|
279
|
+
src: attachment.previewUrl,
|
|
280
|
+
alt: ""
|
|
281
|
+
}) : attachment.icon ?? ('error' === state ? /*#__PURE__*/ jsx(CircleAlert, {}) : /*#__PURE__*/ jsx(FileText, {}))
|
|
282
|
+
}),
|
|
283
|
+
/*#__PURE__*/ jsxs(AttachmentContent, {
|
|
284
|
+
children: [
|
|
285
|
+
/*#__PURE__*/ jsx(AttachmentTitle, {
|
|
286
|
+
children: attachment.name
|
|
287
|
+
}),
|
|
288
|
+
attachment.description && /*#__PURE__*/ jsx(AttachmentDescription, {
|
|
289
|
+
children: attachment.description
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
}),
|
|
293
|
+
onRemoveAttachment && /*#__PURE__*/ jsx(AttachmentActions, {
|
|
294
|
+
children: /*#__PURE__*/ jsx(AttachmentAction, {
|
|
295
|
+
"aria-label": strings.removeAttachment(attachment.name),
|
|
296
|
+
disabled: disabled,
|
|
297
|
+
onClick: ()=>onRemoveAttachment(attachment),
|
|
298
|
+
children: /*#__PURE__*/ jsx(X, {})
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
}, attachment.id);
|
|
303
|
+
})
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
ChatComposerAttachments.displayName = 'ChatComposerAttachments';
|
|
307
|
+
const chatComposerErrorVariants = 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", {
|
|
308
|
+
variants: {
|
|
309
|
+
variant: {
|
|
310
|
+
error: 'border-error/50 bg-error-background/25 [&>svg]:text-error',
|
|
311
|
+
warning: 'border-warning/50 bg-warning-background/25 [&>svg]:text-warning'
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
defaultVariants: {
|
|
315
|
+
variant: 'error'
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
const ChatComposerError = /*#__PURE__*/ forwardRef(({ className, variant, onDismiss, children, ...props }, ref)=>{
|
|
319
|
+
const { strings } = useChatComposer();
|
|
320
|
+
const resolved = variant ?? 'error';
|
|
321
|
+
const Icon = 'warning' === resolved ? TriangleAlert : CircleAlert;
|
|
322
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
323
|
+
ref: ref,
|
|
324
|
+
role: "alert",
|
|
325
|
+
"data-slot": "chat-composer-error",
|
|
326
|
+
"data-variant": resolved,
|
|
327
|
+
className: cn(chatComposerErrorVariants({
|
|
328
|
+
variant: resolved
|
|
329
|
+
}), className),
|
|
330
|
+
...props,
|
|
331
|
+
children: [
|
|
332
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
333
|
+
"aria-hidden": "true"
|
|
334
|
+
}),
|
|
335
|
+
/*#__PURE__*/ jsx("div", {
|
|
336
|
+
className: "min-w-0 flex-1",
|
|
337
|
+
children: children
|
|
338
|
+
}),
|
|
339
|
+
onDismiss && /*#__PURE__*/ jsx(Button, {
|
|
340
|
+
variant: "ghost",
|
|
341
|
+
size: "4xs",
|
|
342
|
+
icon: true,
|
|
343
|
+
"aria-label": strings.dismissError,
|
|
344
|
+
className: "-my-0.5 shrink-0",
|
|
345
|
+
onClick: onDismiss,
|
|
346
|
+
children: /*#__PURE__*/ jsx(X, {})
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
ChatComposerError.displayName = 'ChatComposerError';
|
|
352
|
+
const ChatComposerFooter = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("p", {
|
|
353
|
+
ref: ref,
|
|
354
|
+
"data-slot": "chat-composer-footer",
|
|
355
|
+
className: cn('px-1 text-center text-xs text-muted-foreground', className),
|
|
356
|
+
...props
|
|
357
|
+
}));
|
|
358
|
+
ChatComposerFooter.displayName = 'ChatComposerFooter';
|
|
359
|
+
export { ChatComposer, ChatComposerAttachButton, ChatComposerAttachments, ChatComposerError, ChatComposerFooter, ChatComposerInputGroup, ChatComposerSubmit, ChatComposerTextarea, ChatComposerToolbar, DEFAULT_CHAT_COMPOSER_STRINGS, chatComposerErrorVariants, chatComposerVariants, useChatComposer };
|
|
@@ -0,0 +1,244 @@
|
|
|
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
|
+
ChatHeroHeader: ()=>ChatHeroHeader,
|
|
29
|
+
chatHeroTitleVariants: ()=>chatHeroTitleVariants,
|
|
30
|
+
ChatHeroLogo: ()=>ChatHeroLogo,
|
|
31
|
+
ChatHeroDescription: ()=>ChatHeroDescription,
|
|
32
|
+
ChatHero: ()=>ChatHero,
|
|
33
|
+
ChatHeroTitle: ()=>ChatHeroTitle,
|
|
34
|
+
chatHeroVariants: ()=>chatHeroVariants,
|
|
35
|
+
chatHeroDescriptionVariants: ()=>chatHeroDescriptionVariants
|
|
36
|
+
});
|
|
37
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
38
|
+
const react_slot_namespaceObject = require("@radix-ui/react-slot");
|
|
39
|
+
const external_class_variance_authority_namespaceObject = require("class-variance-authority");
|
|
40
|
+
const external_react_namespaceObject = require("react");
|
|
41
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
42
|
+
const ChatHeroContext = /*#__PURE__*/ external_react_namespaceObject.createContext({
|
|
43
|
+
layout: 'centered',
|
|
44
|
+
density: 'comfortable'
|
|
45
|
+
});
|
|
46
|
+
const chatHeroVariants = (0, external_class_variance_authority_namespaceObject.cva)('flex w-full min-w-0 flex-1 flex-col', {
|
|
47
|
+
variants: {
|
|
48
|
+
layout: {
|
|
49
|
+
centered: 'mx-auto max-w-[800px] items-center justify-center',
|
|
50
|
+
docked: 'justify-end gap-6 text-start'
|
|
51
|
+
},
|
|
52
|
+
density: {
|
|
53
|
+
comfortable: '',
|
|
54
|
+
compact: ''
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
compoundVariants: [
|
|
58
|
+
{
|
|
59
|
+
layout: 'centered',
|
|
60
|
+
density: 'comfortable',
|
|
61
|
+
className: 'gap-8'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
layout: 'centered',
|
|
65
|
+
density: 'compact',
|
|
66
|
+
className: 'gap-6'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
layout: 'centered',
|
|
71
|
+
density: 'comfortable'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const ChatHero = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, layout, density, ...props }, ref)=>{
|
|
75
|
+
const context = external_react_namespaceObject.useMemo(()=>({
|
|
76
|
+
layout: layout ?? 'centered',
|
|
77
|
+
density: density ?? 'comfortable'
|
|
78
|
+
}), [
|
|
79
|
+
layout,
|
|
80
|
+
density
|
|
81
|
+
]);
|
|
82
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ChatHeroContext.Provider, {
|
|
83
|
+
value: context,
|
|
84
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
85
|
+
ref: ref,
|
|
86
|
+
"data-slot": "chat-hero",
|
|
87
|
+
"data-layout": context.layout,
|
|
88
|
+
"data-density": context.density,
|
|
89
|
+
className: (0, index_cjs_namespaceObject.cn)(chatHeroVariants({
|
|
90
|
+
layout: context.layout,
|
|
91
|
+
density: context.density
|
|
92
|
+
}), className),
|
|
93
|
+
...props
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
ChatHero.displayName = 'ChatHero';
|
|
98
|
+
const ChatHeroHeader = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>{
|
|
99
|
+
const { layout } = external_react_namespaceObject.useContext(ChatHeroContext);
|
|
100
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
101
|
+
ref: ref,
|
|
102
|
+
"data-slot": "chat-hero-header",
|
|
103
|
+
className: (0, index_cjs_namespaceObject.cn)('flex w-full min-w-0 flex-col empty:hidden', 'centered' === layout ? 'items-center gap-1 text-center' : 'items-start gap-2 text-start', className),
|
|
104
|
+
...props
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
ChatHeroHeader.displayName = 'ChatHeroHeader';
|
|
108
|
+
const ChatHeroLogo = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
109
|
+
ref: ref,
|
|
110
|
+
"data-slot": "chat-hero-logo",
|
|
111
|
+
className: (0, index_cjs_namespaceObject.cn)('mb-3 flex shrink-0 items-center justify-center', className),
|
|
112
|
+
...props
|
|
113
|
+
}));
|
|
114
|
+
ChatHeroLogo.displayName = 'ChatHeroLogo';
|
|
115
|
+
function isEmptyContent(children) {
|
|
116
|
+
return null == children || false === children || '' === children;
|
|
117
|
+
}
|
|
118
|
+
function isEmptyTitle(children, asChild) {
|
|
119
|
+
if (isEmptyContent(children)) return true;
|
|
120
|
+
if (!asChild || !/*#__PURE__*/ external_react_namespaceObject.isValidElement(children)) return false;
|
|
121
|
+
return isEmptyContent(children.props.children);
|
|
122
|
+
}
|
|
123
|
+
const chatHeroTitleVariants = (0, external_class_variance_authority_namespaceObject.cva)('min-w-0 text-foreground', {
|
|
124
|
+
variants: {
|
|
125
|
+
layout: {
|
|
126
|
+
centered: 'font-bold tracking-tight',
|
|
127
|
+
docked: 'font-semibold tracking-tight'
|
|
128
|
+
},
|
|
129
|
+
density: {
|
|
130
|
+
comfortable: '',
|
|
131
|
+
compact: ''
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
compoundVariants: [
|
|
135
|
+
{
|
|
136
|
+
layout: 'centered',
|
|
137
|
+
density: 'comfortable',
|
|
138
|
+
className: 'text-4xl leading-10'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
layout: 'centered',
|
|
142
|
+
density: 'compact',
|
|
143
|
+
className: 'text-2xl leading-8'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
layout: 'docked',
|
|
147
|
+
className: 'text-xl leading-6'
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
defaultVariants: {
|
|
151
|
+
layout: 'centered',
|
|
152
|
+
density: 'comfortable'
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
const ChatHeroTitle = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, asChild = false, children, ...props }, ref)=>{
|
|
156
|
+
const { layout, density } = external_react_namespaceObject.useContext(ChatHeroContext);
|
|
157
|
+
if (isEmptyTitle(children, asChild)) return null;
|
|
158
|
+
const Comp = asChild ? react_slot_namespaceObject.Slot : 'h2';
|
|
159
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Comp, {
|
|
160
|
+
ref: ref,
|
|
161
|
+
"data-slot": "chat-hero-title",
|
|
162
|
+
className: (0, index_cjs_namespaceObject.cn)(chatHeroTitleVariants({
|
|
163
|
+
layout,
|
|
164
|
+
density
|
|
165
|
+
}), className),
|
|
166
|
+
...props,
|
|
167
|
+
children: children
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
ChatHeroTitle.displayName = 'ChatHeroTitle';
|
|
171
|
+
const chatHeroDescriptionVariants = (0, external_class_variance_authority_namespaceObject.cva)('min-w-0 text-muted-foreground', {
|
|
172
|
+
variants: {
|
|
173
|
+
layout: {
|
|
174
|
+
centered: '',
|
|
175
|
+
docked: ''
|
|
176
|
+
},
|
|
177
|
+
density: {
|
|
178
|
+
comfortable: '',
|
|
179
|
+
compact: ''
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
compoundVariants: [
|
|
183
|
+
{
|
|
184
|
+
layout: 'centered',
|
|
185
|
+
density: 'comfortable',
|
|
186
|
+
className: 'text-base'
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
layout: 'centered',
|
|
190
|
+
density: 'compact',
|
|
191
|
+
className: 'text-sm'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
layout: 'docked',
|
|
195
|
+
density: 'comfortable',
|
|
196
|
+
className: 'text-sm leading-5'
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
layout: 'docked',
|
|
200
|
+
density: 'compact',
|
|
201
|
+
className: 'text-xs leading-4'
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
defaultVariants: {
|
|
205
|
+
layout: 'centered',
|
|
206
|
+
density: 'comfortable'
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
const ChatHeroDescription = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, children, ...props }, ref)=>{
|
|
210
|
+
const { layout, density } = external_react_namespaceObject.useContext(ChatHeroContext);
|
|
211
|
+
if (isEmptyContent(children)) return null;
|
|
212
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
213
|
+
ref: ref,
|
|
214
|
+
"data-slot": "chat-hero-description",
|
|
215
|
+
className: (0, index_cjs_namespaceObject.cn)(chatHeroDescriptionVariants({
|
|
216
|
+
layout,
|
|
217
|
+
density
|
|
218
|
+
}), className),
|
|
219
|
+
...props,
|
|
220
|
+
children: children
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
ChatHeroDescription.displayName = "ChatHeroDescription";
|
|
224
|
+
exports.ChatHero = __webpack_exports__.ChatHero;
|
|
225
|
+
exports.ChatHeroDescription = __webpack_exports__.ChatHeroDescription;
|
|
226
|
+
exports.ChatHeroHeader = __webpack_exports__.ChatHeroHeader;
|
|
227
|
+
exports.ChatHeroLogo = __webpack_exports__.ChatHeroLogo;
|
|
228
|
+
exports.ChatHeroTitle = __webpack_exports__.ChatHeroTitle;
|
|
229
|
+
exports.chatHeroDescriptionVariants = __webpack_exports__.chatHeroDescriptionVariants;
|
|
230
|
+
exports.chatHeroTitleVariants = __webpack_exports__.chatHeroTitleVariants;
|
|
231
|
+
exports.chatHeroVariants = __webpack_exports__.chatHeroVariants;
|
|
232
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
233
|
+
"ChatHero",
|
|
234
|
+
"ChatHeroDescription",
|
|
235
|
+
"ChatHeroHeader",
|
|
236
|
+
"ChatHeroLogo",
|
|
237
|
+
"ChatHeroTitle",
|
|
238
|
+
"chatHeroDescriptionVariants",
|
|
239
|
+
"chatHeroTitleVariants",
|
|
240
|
+
"chatHeroVariants"
|
|
241
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
242
|
+
Object.defineProperty(exports, '__esModule', {
|
|
243
|
+
value: true
|
|
244
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The first-run state of a chat, before any message. `centered` is the home screen: greeting,
|
|
4
|
+
* composer and suggestions in a centered column. `docked` sits at the bottom of the message area,
|
|
5
|
+
* start-aligned, while the composer stays in the footer.
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <ChatHero layout="centered">
|
|
9
|
+
* <ChatHeroHeader>
|
|
10
|
+
* <ChatHeroTitle>Hello David</ChatHeroTitle>
|
|
11
|
+
* <ChatHeroDescription>What should we work on today?</ChatHeroDescription>
|
|
12
|
+
* </ChatHeroHeader>
|
|
13
|
+
* <ChatComposer onSubmit={send}>...</ChatComposer>
|
|
14
|
+
* <PromptSuggestions suggestions={suggestions} onSelect={pick} />
|
|
15
|
+
* </ChatHero>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type ChatHeroLayout = 'centered' | 'docked';
|
|
19
|
+
export type ChatHeroDensity = 'comfortable' | 'compact';
|
|
20
|
+
declare const chatHeroVariants: (props?: ({
|
|
21
|
+
layout?: "centered" | "docked" | null | undefined;
|
|
22
|
+
density?: "compact" | "comfortable" | null | undefined;
|
|
23
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
24
|
+
export interface ChatHeroProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
layout?: ChatHeroLayout;
|
|
26
|
+
density?: ChatHeroDensity;
|
|
27
|
+
}
|
|
28
|
+
/** Fills its flex parent, so the parent decides the height that `centered` centers within. */
|
|
29
|
+
declare const ChatHero: React.ForwardRefExoticComponent<ChatHeroProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
/** Holds the logo, title and description. Hidden when all of them render nothing. */
|
|
31
|
+
declare const ChatHeroHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
declare const ChatHeroLogo: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
33
|
+
declare const chatHeroTitleVariants: (props?: ({
|
|
34
|
+
layout?: "centered" | "docked" | null | undefined;
|
|
35
|
+
density?: "compact" | "comfortable" | null | undefined;
|
|
36
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
37
|
+
export interface ChatHeroTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
38
|
+
/**
|
|
39
|
+
* Renders the child element instead of an `h2`, such as an `h1` on a page of its own. Put
|
|
40
|
+
* class overrides on `ChatHeroTitle`, not the child: Slot joins the two without resolving
|
|
41
|
+
* conflicts.
|
|
42
|
+
*/
|
|
43
|
+
asChild?: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare const ChatHeroTitle: React.ForwardRefExoticComponent<ChatHeroTitleProps & React.RefAttributes<HTMLHeadingElement>>;
|
|
46
|
+
declare const chatHeroDescriptionVariants: (props?: ({
|
|
47
|
+
layout?: "centered" | "docked" | null | undefined;
|
|
48
|
+
density?: "compact" | "comfortable" | null | undefined;
|
|
49
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
50
|
+
declare const ChatHeroDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
51
|
+
export { ChatHero, ChatHeroDescription, ChatHeroHeader, ChatHeroLogo, ChatHeroTitle, chatHeroDescriptionVariants, chatHeroTitleVariants, chatHeroVariants, };
|