@designa8/vibedesign-linear-internal-v1-b737 0.1.0 → 0.2.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/README.md +1 -1
- package/dist/index.cjs +2249 -1878
- package/dist/index.js +2297 -1926
- package/dist/styles.css +49 -0
- package/package.json +6 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +498 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +109 -0
- package/src/atoms/Button/Button.tsx +19 -5
- package/src/index.ts +1 -0
package/dist/styles.css
CHANGED
|
@@ -477,12 +477,18 @@
|
|
|
477
477
|
.-mr-xs {
|
|
478
478
|
margin-right: calc(var(--spacing-xs) * -1);
|
|
479
479
|
}
|
|
480
|
+
.mr-xs {
|
|
481
|
+
margin-right: var(--spacing-xs);
|
|
482
|
+
}
|
|
480
483
|
.-mb-px {
|
|
481
484
|
margin-bottom: -1px;
|
|
482
485
|
}
|
|
483
486
|
.mb-lg {
|
|
484
487
|
margin-bottom: var(--spacing-lg);
|
|
485
488
|
}
|
|
489
|
+
.mb-md {
|
|
490
|
+
margin-bottom: var(--spacing-md);
|
|
491
|
+
}
|
|
486
492
|
.mb-sm {
|
|
487
493
|
margin-bottom: var(--spacing-sm);
|
|
488
494
|
}
|
|
@@ -678,6 +684,9 @@
|
|
|
678
684
|
.h-full {
|
|
679
685
|
height: 100%;
|
|
680
686
|
}
|
|
687
|
+
.h-lg {
|
|
688
|
+
height: var(--spacing-lg);
|
|
689
|
+
}
|
|
681
690
|
.h-px {
|
|
682
691
|
height: 1px;
|
|
683
692
|
}
|
|
@@ -750,6 +759,9 @@
|
|
|
750
759
|
.w-2\.5 {
|
|
751
760
|
width: calc(var(--spacing) * 2.5);
|
|
752
761
|
}
|
|
762
|
+
.w-2\/3 {
|
|
763
|
+
width: calc(2 / 3 * 100%);
|
|
764
|
+
}
|
|
753
765
|
.w-2\/5 {
|
|
754
766
|
width: calc(2 / 5 * 100%);
|
|
755
767
|
}
|
|
@@ -810,6 +822,9 @@
|
|
|
810
822
|
.w-full {
|
|
811
823
|
width: 100%;
|
|
812
824
|
}
|
|
825
|
+
.w-lg {
|
|
826
|
+
width: var(--spacing-lg);
|
|
827
|
+
}
|
|
813
828
|
.w-md {
|
|
814
829
|
width: var(--spacing-md);
|
|
815
830
|
}
|
|
@@ -877,6 +892,9 @@
|
|
|
877
892
|
--tw-border-spacing-y: var(--spacing-xs);
|
|
878
893
|
border-spacing: var(--tw-border-spacing-x) var(--tw-border-spacing-y);
|
|
879
894
|
}
|
|
895
|
+
.origin-bottom {
|
|
896
|
+
transform-origin: bottom;
|
|
897
|
+
}
|
|
880
898
|
.origin-top {
|
|
881
899
|
transform-origin: top;
|
|
882
900
|
}
|
|
@@ -1909,6 +1927,13 @@
|
|
|
1909
1927
|
}
|
|
1910
1928
|
}
|
|
1911
1929
|
}
|
|
1930
|
+
.group-hover\:border-hairline-strong {
|
|
1931
|
+
&:is(:where(.group):hover *) {
|
|
1932
|
+
@media (hover: hover) {
|
|
1933
|
+
border-color: var(--color-hairline-strong);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1912
1937
|
.group-hover\:border-muted-soft {
|
|
1913
1938
|
&:is(:where(.group):hover *) {
|
|
1914
1939
|
@media (hover: hover) {
|
|
@@ -1916,6 +1941,20 @@
|
|
|
1916
1941
|
}
|
|
1917
1942
|
}
|
|
1918
1943
|
}
|
|
1944
|
+
.group-hover\:border-primary {
|
|
1945
|
+
&:is(:where(.group):hover *) {
|
|
1946
|
+
@media (hover: hover) {
|
|
1947
|
+
border-color: var(--color-primary);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
.group-hover\:text-primary {
|
|
1952
|
+
&:is(:where(.group):hover *) {
|
|
1953
|
+
@media (hover: hover) {
|
|
1954
|
+
color: var(--color-primary);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1919
1958
|
.group-hover\:decoration-current {
|
|
1920
1959
|
&:is(:where(.group):hover *) {
|
|
1921
1960
|
@media (hover: hover) {
|
|
@@ -2432,6 +2471,11 @@
|
|
|
2432
2471
|
background-color: var(--color-surface-soft);
|
|
2433
2472
|
}
|
|
2434
2473
|
}
|
|
2474
|
+
.disabled\:bg-transparent {
|
|
2475
|
+
&:disabled {
|
|
2476
|
+
background-color: transparent;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2435
2479
|
.disabled\:text-muted {
|
|
2436
2480
|
&:disabled {
|
|
2437
2481
|
color: var(--color-muted);
|
|
@@ -2472,6 +2516,11 @@
|
|
|
2472
2516
|
}
|
|
2473
2517
|
}
|
|
2474
2518
|
}
|
|
2519
|
+
.aria-checked\:bg-primary-soft {
|
|
2520
|
+
&[aria-checked="true"] {
|
|
2521
|
+
background-color: var(--color-primary-soft);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2475
2524
|
.aria-expanded\:border-primary {
|
|
2476
2525
|
&[aria-expanded="true"] {
|
|
2477
2526
|
border-color: var(--color-primary);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designa8/vibedesign-linear-internal-v1-b737",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Complete design system \"My Project linear-internal-v1\" generated by Atoms Design.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
"kind": "Molecule",
|
|
55
55
|
"description": null
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
"name": "AgentQuestionCard",
|
|
59
|
+
"kind": "Organism",
|
|
60
|
+
"description": null
|
|
61
|
+
},
|
|
57
62
|
{
|
|
58
63
|
"name": "Alert",
|
|
59
64
|
"kind": "Molecule",
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
import { IconButton } from "../IconButton";
|
|
5
|
+
import { Image } from "../Image";
|
|
6
|
+
import { Input } from "../Input";
|
|
7
|
+
import { Modal } from "../Modal";
|
|
8
|
+
|
|
9
|
+
export interface AgentQuestionOption {
|
|
10
|
+
id: string;
|
|
11
|
+
/** Overrides the auto A, B, C… letter shown in the option badge. */
|
|
12
|
+
letter?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AgentQuestionAnswer {
|
|
17
|
+
questionId: string;
|
|
18
|
+
optionId: string;
|
|
19
|
+
/** Present only when the free-text row was the chosen answer. */
|
|
20
|
+
text?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AgentQuestionCardProps
|
|
24
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSubmit"> {
|
|
25
|
+
questionId: string;
|
|
26
|
+
question: string;
|
|
27
|
+
/** Shown before the question text, e.g. 1. */
|
|
28
|
+
questionNumber?: number;
|
|
29
|
+
options: AgentQuestionOption[];
|
|
30
|
+
/** Optional reference thumbnail; clicking it opens a large preview dialog. */
|
|
31
|
+
imageSrc?: string;
|
|
32
|
+
imageAlt?: string;
|
|
33
|
+
/** Label of the trailing free-text row. Pass `null` to remove the row. */
|
|
34
|
+
freeTextLabel?: string | null;
|
|
35
|
+
freeTextPlaceholder?: string;
|
|
36
|
+
/** Eyebrow label in the header. */
|
|
37
|
+
label?: string;
|
|
38
|
+
/** Muted hint beside the send action. */
|
|
39
|
+
hint?: string;
|
|
40
|
+
sendLabel?: string;
|
|
41
|
+
selectedOptionId?: string | null;
|
|
42
|
+
defaultSelectedOptionId?: string | null;
|
|
43
|
+
freeTextValue?: string;
|
|
44
|
+
defaultFreeTextValue?: string;
|
|
45
|
+
onAnswerChange?: (answer: { optionId: string | null; text: string }) => void;
|
|
46
|
+
onSubmit?: (answer: AgentQuestionAnswer) => void;
|
|
47
|
+
/** Called when the card collapses (close button or Escape). */
|
|
48
|
+
onClose?: () => void;
|
|
49
|
+
/** Called when the restore bar reopens the card. */
|
|
50
|
+
onReopen?: () => void;
|
|
51
|
+
collapsed?: boolean;
|
|
52
|
+
defaultCollapsed?: boolean;
|
|
53
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
54
|
+
submitting?: boolean;
|
|
55
|
+
/** Error line under the options; also marks the free-text row when it is chosen. */
|
|
56
|
+
errorMessage?: string;
|
|
57
|
+
/** Queue size shown in the restore bar. */
|
|
58
|
+
waitingCount?: number;
|
|
59
|
+
reopenLabel?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Option id used when the free-text row is the selected answer. */
|
|
63
|
+
export const AGENT_QUESTION_FREE_TEXT_ID = "__other_free_text__";
|
|
64
|
+
|
|
65
|
+
const cn = (...parts: Array<string | false | null | undefined>) =>
|
|
66
|
+
parts.filter(Boolean).join(" ");
|
|
67
|
+
|
|
68
|
+
const letterFor = (option: AgentQuestionOption, index: number): string =>
|
|
69
|
+
option.letter ?? String.fromCharCode(65 + (index % 26));
|
|
70
|
+
|
|
71
|
+
const letterBadge = (selected: boolean): string =>
|
|
72
|
+
cn(
|
|
73
|
+
"flex h-lg w-lg shrink-0 items-center justify-center rounded-xs border text-caption transition-colors duration-150 ease-out",
|
|
74
|
+
selected
|
|
75
|
+
? "border-primary bg-primary text-on-primary"
|
|
76
|
+
: "border-hairline-strong bg-canvas text-muted group-hover:border-primary group-hover:text-primary",
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const PANEL =
|
|
80
|
+
"min-h-0 overflow-hidden transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:opacity-0";
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The card that replaces the chat prompt while an agent waits on a choice.
|
|
84
|
+
* Options are a radiogroup (arrow keys move and select), the trailing row turns
|
|
85
|
+
* into an inline text field, and closing folds the card into a slim restore bar.
|
|
86
|
+
*/
|
|
87
|
+
export const AgentQuestionCard = React.forwardRef<
|
|
88
|
+
HTMLDivElement,
|
|
89
|
+
AgentQuestionCardProps
|
|
90
|
+
>(
|
|
91
|
+
(
|
|
92
|
+
{
|
|
93
|
+
questionId,
|
|
94
|
+
question,
|
|
95
|
+
questionNumber,
|
|
96
|
+
options,
|
|
97
|
+
imageSrc,
|
|
98
|
+
imageAlt = "Reference image",
|
|
99
|
+
freeTextLabel = "Other…",
|
|
100
|
+
freeTextPlaceholder = "Type your answer",
|
|
101
|
+
label = "Questions",
|
|
102
|
+
hint = "Pick an option or write your own",
|
|
103
|
+
sendLabel = "Send",
|
|
104
|
+
selectedOptionId: selectedProp,
|
|
105
|
+
defaultSelectedOptionId = null,
|
|
106
|
+
freeTextValue: freeTextProp,
|
|
107
|
+
defaultFreeTextValue = "",
|
|
108
|
+
onAnswerChange,
|
|
109
|
+
onSubmit,
|
|
110
|
+
onClose,
|
|
111
|
+
onReopen,
|
|
112
|
+
collapsed: collapsedProp,
|
|
113
|
+
defaultCollapsed = false,
|
|
114
|
+
onCollapsedChange,
|
|
115
|
+
submitting = false,
|
|
116
|
+
errorMessage,
|
|
117
|
+
waitingCount = 1,
|
|
118
|
+
reopenLabel = "Answer",
|
|
119
|
+
className,
|
|
120
|
+
onKeyDown,
|
|
121
|
+
...rest
|
|
122
|
+
},
|
|
123
|
+
ref,
|
|
124
|
+
) => {
|
|
125
|
+
const reactId = React.useId();
|
|
126
|
+
const questionTextId = `aqc-question-${reactId}`;
|
|
127
|
+
const hintId = `aqc-hint-${reactId}`;
|
|
128
|
+
const freeTextInputId = `aqc-free-text-${reactId}`;
|
|
129
|
+
|
|
130
|
+
const [internalSelection, setInternalSelection] =
|
|
131
|
+
React.useState<string | null>(defaultSelectedOptionId);
|
|
132
|
+
const selected =
|
|
133
|
+
selectedProp !== undefined ? selectedProp ?? null : internalSelection;
|
|
134
|
+
|
|
135
|
+
const [internalText, setInternalText] = React.useState(defaultFreeTextValue);
|
|
136
|
+
const text = freeTextProp !== undefined ? freeTextProp : internalText;
|
|
137
|
+
|
|
138
|
+
const [imageOpen, setImageOpen] = React.useState(false);
|
|
139
|
+
|
|
140
|
+
const [internalCollapsed, setInternalCollapsed] =
|
|
141
|
+
React.useState(defaultCollapsed);
|
|
142
|
+
const collapsed =
|
|
143
|
+
collapsedProp !== undefined ? collapsedProp : internalCollapsed;
|
|
144
|
+
|
|
145
|
+
const setSelection = (next: string | null) => {
|
|
146
|
+
if (selectedProp === undefined) setInternalSelection(next);
|
|
147
|
+
onAnswerChange?.({ optionId: next, text });
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const setText = (next: string) => {
|
|
151
|
+
if (freeTextProp === undefined) setInternalText(next);
|
|
152
|
+
onAnswerChange?.({ optionId: selected, text: next });
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const collapse = (next: boolean) => {
|
|
156
|
+
if (collapsedProp === undefined) setInternalCollapsed(next);
|
|
157
|
+
onCollapsedChange?.(next);
|
|
158
|
+
if (next) onClose?.();
|
|
159
|
+
else onReopen?.();
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const hasFreeText = freeTextLabel !== null;
|
|
163
|
+
const freeTextSelected =
|
|
164
|
+
hasFreeText && selected === AGENT_QUESTION_FREE_TEXT_ID;
|
|
165
|
+
const canSend =
|
|
166
|
+
!submitting &&
|
|
167
|
+
selected !== null &&
|
|
168
|
+
(!freeTextSelected || text.trim().length > 0);
|
|
169
|
+
|
|
170
|
+
const optionIds = [
|
|
171
|
+
...options.map((option) => option.id),
|
|
172
|
+
...(hasFreeText ? [AGENT_QUESTION_FREE_TEXT_ID] : []),
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
const handleSubmit = () => {
|
|
176
|
+
if (!canSend || selected === null) return;
|
|
177
|
+
onSubmit?.({
|
|
178
|
+
questionId,
|
|
179
|
+
optionId: selected,
|
|
180
|
+
text: freeTextSelected ? text.trim() : undefined,
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const rowRefs = React.useRef<Array<HTMLButtonElement | null>>([]);
|
|
185
|
+
|
|
186
|
+
const moveTo = (index: number) => {
|
|
187
|
+
const count = optionIds.length;
|
|
188
|
+
if (count === 0) return;
|
|
189
|
+
const wrapped = ((index % count) + count) % count;
|
|
190
|
+
rowRefs.current[wrapped]?.focus();
|
|
191
|
+
setSelection(optionIds[wrapped]);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const radioKeys =
|
|
195
|
+
(index: number) => (event: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
196
|
+
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
moveTo(index + 1);
|
|
199
|
+
} else if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
moveTo(index - 1);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
206
|
+
onKeyDown?.(event);
|
|
207
|
+
if (event.key !== "Escape" || imageOpen || collapsed) return;
|
|
208
|
+
event.stopPropagation();
|
|
209
|
+
collapse(true);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const cardState = collapsed ? "closed" : "open";
|
|
213
|
+
const freeTextLetter = letterFor(
|
|
214
|
+
{ id: AGENT_QUESTION_FREE_TEXT_ID, label: "" },
|
|
215
|
+
options.length,
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const card = (
|
|
219
|
+
<div
|
|
220
|
+
role="group"
|
|
221
|
+
aria-labelledby={questionTextId}
|
|
222
|
+
aria-describedby={hintId}
|
|
223
|
+
aria-busy={submitting || undefined}
|
|
224
|
+
className="w-full rounded-xl border border-hairline bg-surface p-lg shadow-card"
|
|
225
|
+
>
|
|
226
|
+
<div className="mb-md flex items-center gap-sm">
|
|
227
|
+
<Icon name="message-circle" size={16} className="shrink-0 text-muted" />
|
|
228
|
+
<span className="min-w-0 flex-1 truncate text-body-sm text-muted">
|
|
229
|
+
{label}
|
|
230
|
+
</span>
|
|
231
|
+
<IconButton
|
|
232
|
+
icon="x"
|
|
233
|
+
variant="ghost"
|
|
234
|
+
size="md"
|
|
235
|
+
aria-label="Close question"
|
|
236
|
+
disabled={submitting}
|
|
237
|
+
onClick={() => collapse(true)}
|
|
238
|
+
className="text-muted-soft"
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div className="mb-md flex items-baseline gap-sm">
|
|
243
|
+
{questionNumber !== undefined && (
|
|
244
|
+
<span className="shrink-0 text-body-md text-muted">
|
|
245
|
+
{questionNumber}.
|
|
246
|
+
</span>
|
|
247
|
+
)}
|
|
248
|
+
<span id={questionTextId} className="min-w-0 flex-1 text-body-md text-ink">
|
|
249
|
+
{question}
|
|
250
|
+
</span>
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
{imageSrc && (
|
|
254
|
+
<div className="mb-md">
|
|
255
|
+
<Button
|
|
256
|
+
variant="media"
|
|
257
|
+
fullWidth
|
|
258
|
+
aria-haspopup="dialog"
|
|
259
|
+
aria-label={`View ${imageAlt}`}
|
|
260
|
+
onClick={() => setImageOpen(true)}
|
|
261
|
+
className="group block"
|
|
262
|
+
>
|
|
263
|
+
<div className="mx-auto w-2/3">
|
|
264
|
+
<Image
|
|
265
|
+
src={imageSrc}
|
|
266
|
+
alt={imageAlt}
|
|
267
|
+
ratio="wide"
|
|
268
|
+
fit="contain"
|
|
269
|
+
frameClassName="transition-colors duration-150 ease-out group-hover:border-hairline-strong"
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
272
|
+
</Button>
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
|
|
276
|
+
<div
|
|
277
|
+
role="radiogroup"
|
|
278
|
+
aria-labelledby={questionTextId}
|
|
279
|
+
className="flex flex-col gap-xs"
|
|
280
|
+
>
|
|
281
|
+
{options.map((option, index) => {
|
|
282
|
+
const isSelected = selected === option.id;
|
|
283
|
+
return (
|
|
284
|
+
<Button
|
|
285
|
+
key={option.id}
|
|
286
|
+
ref={(node) => {
|
|
287
|
+
rowRefs.current[index] = node;
|
|
288
|
+
}}
|
|
289
|
+
variant="item"
|
|
290
|
+
size="md"
|
|
291
|
+
fullWidth
|
|
292
|
+
role="radio"
|
|
293
|
+
aria-checked={isSelected}
|
|
294
|
+
aria-label={option.label}
|
|
295
|
+
disabled={submitting}
|
|
296
|
+
leadingIcon={
|
|
297
|
+
<span aria-hidden="true" className={letterBadge(isSelected)}>
|
|
298
|
+
{letterFor(option, index)}
|
|
299
|
+
</span>
|
|
300
|
+
}
|
|
301
|
+
trailingIcon={
|
|
302
|
+
isSelected ? (
|
|
303
|
+
<Icon name="check" size={14} className="text-primary" />
|
|
304
|
+
) : undefined
|
|
305
|
+
}
|
|
306
|
+
onClick={() => setSelection(option.id)}
|
|
307
|
+
onKeyDown={radioKeys(index)}
|
|
308
|
+
className="group"
|
|
309
|
+
>
|
|
310
|
+
{option.label}
|
|
311
|
+
</Button>
|
|
312
|
+
);
|
|
313
|
+
})}
|
|
314
|
+
|
|
315
|
+
{hasFreeText && (
|
|
316
|
+
<div
|
|
317
|
+
className={cn(
|
|
318
|
+
"flex w-full items-center gap-sm rounded-md border px-xs transition-colors duration-150 ease-out",
|
|
319
|
+
errorMessage && freeTextSelected
|
|
320
|
+
? "border-semantic-error"
|
|
321
|
+
: freeTextSelected
|
|
322
|
+
? "border-transparent bg-primary-soft"
|
|
323
|
+
: "border-transparent",
|
|
324
|
+
)}
|
|
325
|
+
>
|
|
326
|
+
{freeTextSelected ? (
|
|
327
|
+
<Button
|
|
328
|
+
ref={(node) => {
|
|
329
|
+
rowRefs.current[options.length] = node;
|
|
330
|
+
}}
|
|
331
|
+
variant="item"
|
|
332
|
+
size="md"
|
|
333
|
+
iconOnly
|
|
334
|
+
role="radio"
|
|
335
|
+
aria-checked
|
|
336
|
+
aria-label={freeTextLabel ?? undefined}
|
|
337
|
+
disabled={submitting}
|
|
338
|
+
onClick={() => {
|
|
339
|
+
requestAnimationFrame(() =>
|
|
340
|
+
document.getElementById(freeTextInputId)?.focus(),
|
|
341
|
+
);
|
|
342
|
+
}}
|
|
343
|
+
onKeyDown={radioKeys(options.length)}
|
|
344
|
+
className="group"
|
|
345
|
+
>
|
|
346
|
+
<span aria-hidden="true" className={letterBadge(true)}>
|
|
347
|
+
{freeTextLetter}
|
|
348
|
+
</span>
|
|
349
|
+
</Button>
|
|
350
|
+
) : (
|
|
351
|
+
<Button
|
|
352
|
+
ref={(node) => {
|
|
353
|
+
rowRefs.current[options.length] = node;
|
|
354
|
+
}}
|
|
355
|
+
variant="item"
|
|
356
|
+
size="md"
|
|
357
|
+
fullWidth
|
|
358
|
+
role="radio"
|
|
359
|
+
aria-checked={false}
|
|
360
|
+
aria-label={freeTextLabel ?? undefined}
|
|
361
|
+
disabled={submitting}
|
|
362
|
+
leadingIcon={
|
|
363
|
+
<span aria-hidden="true" className={letterBadge(false)}>
|
|
364
|
+
{freeTextLetter}
|
|
365
|
+
</span>
|
|
366
|
+
}
|
|
367
|
+
onClick={() => {
|
|
368
|
+
setSelection(AGENT_QUESTION_FREE_TEXT_ID);
|
|
369
|
+
requestAnimationFrame(() =>
|
|
370
|
+
document.getElementById(freeTextInputId)?.focus(),
|
|
371
|
+
);
|
|
372
|
+
}}
|
|
373
|
+
onKeyDown={radioKeys(options.length)}
|
|
374
|
+
className="group text-muted"
|
|
375
|
+
>
|
|
376
|
+
{freeTextLabel}
|
|
377
|
+
</Button>
|
|
378
|
+
)}
|
|
379
|
+
|
|
380
|
+
{freeTextSelected && (
|
|
381
|
+
<>
|
|
382
|
+
<div className="min-w-0 flex-1">
|
|
383
|
+
<Input
|
|
384
|
+
id={freeTextInputId}
|
|
385
|
+
chrome="none"
|
|
386
|
+
value={text}
|
|
387
|
+
onChange={(event) => setText(event.target.value)}
|
|
388
|
+
onKeyDown={(event) => {
|
|
389
|
+
if (event.key === "Enter") {
|
|
390
|
+
event.preventDefault();
|
|
391
|
+
handleSubmit();
|
|
392
|
+
}
|
|
393
|
+
}}
|
|
394
|
+
placeholder={freeTextPlaceholder}
|
|
395
|
+
aria-label="Your answer"
|
|
396
|
+
disabled={submitting}
|
|
397
|
+
/>
|
|
398
|
+
</div>
|
|
399
|
+
<Icon name="check" size={14} className="mr-xs shrink-0 text-primary" />
|
|
400
|
+
</>
|
|
401
|
+
)}
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
<div role="status" aria-live="polite">
|
|
407
|
+
{errorMessage && (
|
|
408
|
+
<p className="mt-xs text-caption text-semantic-error">{errorMessage}</p>
|
|
409
|
+
)}
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<div className="mt-md flex items-center justify-between gap-md border-t border-hairline-soft pt-md">
|
|
413
|
+
<span id={hintId} className="min-w-0 flex-1 text-caption text-muted">
|
|
414
|
+
{hint}
|
|
415
|
+
</span>
|
|
416
|
+
<Button
|
|
417
|
+
variant="primary"
|
|
418
|
+
size="lg"
|
|
419
|
+
disabled={!canSend}
|
|
420
|
+
loading={submitting}
|
|
421
|
+
loadingText="Sending…"
|
|
422
|
+
onClick={handleSubmit}
|
|
423
|
+
trailingIcon={<Icon name="arrow-up" size={16} />}
|
|
424
|
+
>
|
|
425
|
+
{sendLabel}
|
|
426
|
+
</Button>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
return (
|
|
432
|
+
<div
|
|
433
|
+
ref={ref}
|
|
434
|
+
data-state={cardState}
|
|
435
|
+
className={cn("w-full", className)}
|
|
436
|
+
onKeyDown={handleKeyDown}
|
|
437
|
+
{...rest}
|
|
438
|
+
>
|
|
439
|
+
<div
|
|
440
|
+
className={cn(
|
|
441
|
+
"grid overflow-hidden transition-[grid-template-rows] duration-200 ease-out",
|
|
442
|
+
collapsed ? "grid-rows-[0fr]" : "grid-rows-[1fr]",
|
|
443
|
+
)}
|
|
444
|
+
>
|
|
445
|
+
<div
|
|
446
|
+
data-state={cardState}
|
|
447
|
+
className={cn(PANEL, "origin-bottom data-[state=closed]:-translate-y-2")}
|
|
448
|
+
>
|
|
449
|
+
{card}
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
|
|
453
|
+
<div
|
|
454
|
+
className={cn(
|
|
455
|
+
"grid overflow-hidden transition-[grid-template-rows] duration-200 ease-out",
|
|
456
|
+
collapsed ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
|
457
|
+
)}
|
|
458
|
+
>
|
|
459
|
+
<div
|
|
460
|
+
data-state={collapsed ? "open" : "closed"}
|
|
461
|
+
className={cn(PANEL, "origin-bottom data-[state=closed]:translate-y-2")}
|
|
462
|
+
>
|
|
463
|
+
<div className="flex w-full items-center gap-md rounded-xl border border-hairline bg-surface px-md py-sm shadow-card">
|
|
464
|
+
<span className="flex h-lg w-lg shrink-0 items-center justify-center rounded-full bg-primary text-on-primary">
|
|
465
|
+
<Icon name="message-circle" size={14} />
|
|
466
|
+
</span>
|
|
467
|
+
<span className="min-w-0 flex-1 truncate text-body-sm text-ink">
|
|
468
|
+
{waitingCount === 1
|
|
469
|
+
? "1 question waiting"
|
|
470
|
+
: `${waitingCount} questions waiting`}
|
|
471
|
+
</span>
|
|
472
|
+
<Button
|
|
473
|
+
variant="ghost"
|
|
474
|
+
size="sm"
|
|
475
|
+
onClick={() => collapse(false)}
|
|
476
|
+
className="text-primary"
|
|
477
|
+
>
|
|
478
|
+
{reopenLabel}
|
|
479
|
+
</Button>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
|
|
484
|
+
{imageSrc && (
|
|
485
|
+
<Modal
|
|
486
|
+
open={imageOpen}
|
|
487
|
+
onOpenChange={setImageOpen}
|
|
488
|
+
title="Reference image"
|
|
489
|
+
size="lg"
|
|
490
|
+
>
|
|
491
|
+
<Image src={imageSrc} alt={imageAlt} ratio="wide" fit="contain" />
|
|
492
|
+
</Modal>
|
|
493
|
+
)}
|
|
494
|
+
</div>
|
|
495
|
+
);
|
|
496
|
+
},
|
|
497
|
+
);
|
|
498
|
+
AgentQuestionCard.displayName = "AgentQuestionCard";
|