@octaviaflow/core 3.1.0-beta.115 → 3.1.0-beta.117
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/chunk-23K2RF7Z.js +2694 -0
- package/dist/chunk-23K2RF7Z.js.map +1 -0
- package/dist/chunk-H3FCGN4P.js +6628 -0
- package/dist/chunk-H3FCGN4P.js.map +1 -0
- package/dist/chunk-ISJSOF3Z.js +3646 -0
- package/dist/chunk-ISJSOF3Z.js.map +1 -0
- package/dist/chunk-KSIZ7DLS.js +3582 -0
- package/dist/chunk-KSIZ7DLS.js.map +1 -0
- package/dist/chunk-NAG3EFQ6.js +6789 -0
- package/dist/chunk-NAG3EFQ6.js.map +1 -0
- package/dist/chunk-NMZWNZV7.js +1547 -0
- package/dist/chunk-NMZWNZV7.js.map +1 -0
- package/dist/chunk-QWOH2E3F.js +3189 -0
- package/dist/chunk-QWOH2E3F.js.map +1 -0
- package/dist/chunk-V22HCPVO.js +2856 -0
- package/dist/chunk-V22HCPVO.js.map +1 -0
- package/dist/chunk-VGAUSBP4.js +3181 -0
- package/dist/chunk-VGAUSBP4.js.map +1 -0
- package/dist/chunk-WTIM6E4X.js +3677 -0
- package/dist/chunk-WTIM6E4X.js.map +1 -0
- package/dist/chunk-XUBJHPJT.js +3680 -0
- package/dist/chunk-XUBJHPJT.js.map +1 -0
- package/dist/components/AgentCard/AgentCard.d.ts.map +1 -1
- package/dist/components/AssistantAura/AssistantAura.d.ts +21 -0
- package/dist/components/AssistantAura/AssistantAura.d.ts.map +1 -0
- package/dist/components/AssistantAura/index.d.ts +2 -0
- package/dist/components/AssistantAura/index.d.ts.map +1 -0
- package/dist/components/AssistantConversation/AssistantConversation.d.ts +112 -0
- package/dist/components/AssistantConversation/AssistantConversation.d.ts.map +1 -0
- package/dist/components/AssistantConversation/assistant.fixtures.d.ts +29 -0
- package/dist/components/AssistantConversation/assistant.fixtures.d.ts.map +1 -0
- package/dist/components/AssistantConversation/assistantGlyphs.d.ts +13 -0
- package/dist/components/AssistantConversation/assistantGlyphs.d.ts.map +1 -0
- package/dist/components/AssistantConversation/index.d.ts +2 -0
- package/dist/components/AssistantConversation/index.d.ts.map +1 -0
- package/dist/components/AssistantDock/AssistantDock.d.ts +25 -0
- package/dist/components/AssistantDock/AssistantDock.d.ts.map +1 -0
- package/dist/components/AssistantDock/index.d.ts +2 -0
- package/dist/components/AssistantDock/index.d.ts.map +1 -0
- package/dist/components/AssistantOrb/AssistantOrb.d.ts +14 -0
- package/dist/components/AssistantOrb/AssistantOrb.d.ts.map +1 -0
- package/dist/components/AssistantOrb/explorations/OvaIconConcepts.d.ts +22 -0
- package/dist/components/AssistantOrb/explorations/OvaIconConcepts.d.ts.map +1 -0
- package/dist/components/AssistantOrb/index.d.ts +2 -0
- package/dist/components/AssistantOrb/index.d.ts.map +1 -0
- package/dist/components/AssistantTrigger/AssistantTrigger.d.ts +17 -0
- package/dist/components/AssistantTrigger/AssistantTrigger.d.ts.map +1 -0
- package/dist/components/AssistantTrigger/index.d.ts +2 -0
- package/dist/components/AssistantTrigger/index.d.ts.map +1 -0
- package/dist/components/ChatComposer/ChatComposer.d.ts +8 -0
- package/dist/components/ChatComposer/ChatComposer.d.ts.map +1 -1
- package/dist/components/ChatDocPreview/ChatDocPreview.d.ts +20 -0
- package/dist/components/ChatDocPreview/ChatDocPreview.d.ts.map +1 -0
- package/dist/components/ChatDocPreview/index.d.ts +2 -0
- package/dist/components/ChatDocPreview/index.d.ts.map +1 -0
- package/dist/components/ChatInputRequest/ChatInputRequest.d.ts +68 -0
- package/dist/components/ChatInputRequest/ChatInputRequest.d.ts.map +1 -0
- package/dist/components/ChatInputRequest/index.d.ts +2 -0
- package/dist/components/ChatInputRequest/index.d.ts.map +1 -0
- package/dist/components/ChatLinkPreview/ChatLinkPreview.d.ts +33 -0
- package/dist/components/ChatLinkPreview/ChatLinkPreview.d.ts.map +1 -0
- package/dist/components/ChatLinkPreview/index.d.ts +2 -0
- package/dist/components/ChatLinkPreview/index.d.ts.map +1 -0
- package/dist/components/ChatSources/ChatSources.d.ts +10 -1
- package/dist/components/ChatSources/ChatSources.d.ts.map +1 -1
- package/dist/components/ChatSources/index.d.ts +1 -1
- package/dist/components/ChatSources/index.d.ts.map +1 -1
- package/dist/components/ChatVideoPreview/ChatVideoPreview.d.ts +37 -0
- package/dist/components/ChatVideoPreview/ChatVideoPreview.d.ts.map +1 -0
- package/dist/components/ChatVideoPreview/index.d.ts +2 -0
- package/dist/components/ChatVideoPreview/index.d.ts.map +1 -0
- package/dist/components/TruncatedText/TruncatedText.d.ts +15 -0
- package/dist/components/TruncatedText/TruncatedText.d.ts.map +1 -0
- package/dist/components/TruncatedText/index.d.ts +2 -0
- package/dist/components/TruncatedText/index.d.ts.map +1 -0
- package/dist/index.cjs +7716 -6548
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4742 -5654
- package/dist/index.js.map +1 -1
- package/dist/marketing/components/AssistantWidget/AssistantWidget.d.ts +60 -0
- package/dist/marketing/components/AssistantWidget/AssistantWidget.d.ts.map +1 -0
- package/dist/marketing/index.d.ts +1 -0
- package/dist/marketing/index.d.ts.map +1 -1
- package/dist/marketing.cjs +3710 -1196
- package/dist/marketing.cjs.map +1 -1
- package/dist/marketing.js +738 -482
- package/dist/marketing.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/workflow.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,3189 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$384704861d32dbed$export$bca9d026f8e704eb,
|
|
3
|
+
Button,
|
|
4
|
+
Checkbox,
|
|
5
|
+
Input,
|
|
6
|
+
Slot,
|
|
7
|
+
Spinner,
|
|
8
|
+
Tooltip,
|
|
9
|
+
resolveAccessibleName
|
|
10
|
+
} from "./chunk-V22HCPVO.js";
|
|
11
|
+
import {
|
|
12
|
+
cn
|
|
13
|
+
} from "./chunk-ZAUUGK2Y.js";
|
|
14
|
+
|
|
15
|
+
// src/components/Card/Card.tsx
|
|
16
|
+
import { motion, useReducedMotion } from "framer-motion";
|
|
17
|
+
import {
|
|
18
|
+
forwardRef
|
|
19
|
+
} from "react";
|
|
20
|
+
import { jsx } from "react/jsx-runtime";
|
|
21
|
+
var Card = forwardRef(function Card2({
|
|
22
|
+
variant = "default",
|
|
23
|
+
padding = "md",
|
|
24
|
+
radius = "md",
|
|
25
|
+
hoverable = false,
|
|
26
|
+
disabled = false,
|
|
27
|
+
loading = false,
|
|
28
|
+
asChild = false,
|
|
29
|
+
onClick,
|
|
30
|
+
onKeyDown,
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}, ref) {
|
|
35
|
+
const reducedMotion = useReducedMotion();
|
|
36
|
+
const isInteractive = Boolean(onClick) && !disabled && !loading;
|
|
37
|
+
const handleKeyDown = (e) => {
|
|
38
|
+
onKeyDown?.(e);
|
|
39
|
+
if (e.defaultPrevented) return;
|
|
40
|
+
if (!isInteractive) return;
|
|
41
|
+
if ((e.key === "Enter" || e.key === " ") && !e.repeat) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
onClick?.(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const rootClassName = cn(
|
|
47
|
+
"ods-card",
|
|
48
|
+
`ods-card--${variant}`,
|
|
49
|
+
`ods-card--pad-${padding}`,
|
|
50
|
+
`ods-card--radius-${radius}`,
|
|
51
|
+
(hoverable || isInteractive) && !loading && !disabled && "ods-card--hoverable",
|
|
52
|
+
isInteractive && "ods-card--clickable",
|
|
53
|
+
disabled && "ods-card--disabled",
|
|
54
|
+
loading && "ods-card--loading",
|
|
55
|
+
className
|
|
56
|
+
);
|
|
57
|
+
if (asChild) {
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
Slot,
|
|
60
|
+
{
|
|
61
|
+
...rest,
|
|
62
|
+
ref,
|
|
63
|
+
className: rootClassName,
|
|
64
|
+
onClick: isInteractive ? onClick : void 0,
|
|
65
|
+
onKeyDown: isInteractive ? handleKeyDown : onKeyDown,
|
|
66
|
+
"aria-disabled": disabled || void 0,
|
|
67
|
+
children
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (loading) {
|
|
72
|
+
return /* @__PURE__ */ jsx("div", { ...rest, ref, className: rootClassName, "aria-busy": "true", "aria-label": "Loading", children: /* @__PURE__ */ jsx("div", { className: "ods-card__skeleton", "data-ods-animate": "shimmer" }) });
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
motion.div,
|
|
76
|
+
{
|
|
77
|
+
...rest,
|
|
78
|
+
ref,
|
|
79
|
+
onClick: isInteractive ? onClick : void 0,
|
|
80
|
+
onKeyDown: isInteractive ? handleKeyDown : onKeyDown,
|
|
81
|
+
className: rootClassName,
|
|
82
|
+
whileHover: (hoverable || isInteractive) && !reducedMotion ? { y: -2, transition: { duration: 0.15 } } : void 0,
|
|
83
|
+
whileTap: isInteractive && !reducedMotion ? { scale: 0.99 } : void 0,
|
|
84
|
+
role: isInteractive ? "button" : rest.role,
|
|
85
|
+
tabIndex: isInteractive ? rest.tabIndex ?? 0 : rest.tabIndex,
|
|
86
|
+
"aria-disabled": disabled || void 0,
|
|
87
|
+
children
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
Card.displayName = "Card";
|
|
92
|
+
var CardHeader = forwardRef(function CardHeader2({ className, children, ...rest }, ref) {
|
|
93
|
+
return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__header", className), children });
|
|
94
|
+
});
|
|
95
|
+
CardHeader.displayName = "Card.Header";
|
|
96
|
+
var CardBody = forwardRef(function CardBody2({ className, children, ...rest }, ref) {
|
|
97
|
+
return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__body", className), children });
|
|
98
|
+
});
|
|
99
|
+
CardBody.displayName = "Card.Body";
|
|
100
|
+
var CardFooter = forwardRef(function CardFooter2({ className, children, ...rest }, ref) {
|
|
101
|
+
return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__footer", className), children });
|
|
102
|
+
});
|
|
103
|
+
CardFooter.displayName = "Card.Footer";
|
|
104
|
+
var CardTitle = forwardRef(function CardTitle2({ as: Comp = "h3", className, children, ...rest }, ref) {
|
|
105
|
+
return /* @__PURE__ */ jsx(
|
|
106
|
+
Comp,
|
|
107
|
+
{
|
|
108
|
+
...rest,
|
|
109
|
+
ref,
|
|
110
|
+
className: cn("ods-card__title", className),
|
|
111
|
+
children
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
CardTitle.displayName = "Card.Title";
|
|
116
|
+
var CardDescription = forwardRef(
|
|
117
|
+
function CardDescription2({ className, children, ...rest }, ref) {
|
|
118
|
+
return /* @__PURE__ */ jsx("p", { ...rest, ref, className: cn("ods-card__description", className), children });
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
CardDescription.displayName = "Card.Description";
|
|
122
|
+
Card.Header = CardHeader;
|
|
123
|
+
Card.Body = CardBody;
|
|
124
|
+
Card.Footer = CardFooter;
|
|
125
|
+
Card.Title = CardTitle;
|
|
126
|
+
Card.Description = CardDescription;
|
|
127
|
+
|
|
128
|
+
// src/components/Avatar/Avatar.tsx
|
|
129
|
+
import {
|
|
130
|
+
forwardRef as forwardRef2,
|
|
131
|
+
useCallback,
|
|
132
|
+
useMemo,
|
|
133
|
+
useState
|
|
134
|
+
} from "react";
|
|
135
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
136
|
+
var PALETTE_SIZE = 12;
|
|
137
|
+
function djb2(str) {
|
|
138
|
+
let h = 5381;
|
|
139
|
+
for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i);
|
|
140
|
+
return h >>> 0;
|
|
141
|
+
}
|
|
142
|
+
function paletteIndexFor(seed) {
|
|
143
|
+
return djb2(seed) % PALETTE_SIZE;
|
|
144
|
+
}
|
|
145
|
+
var AVATAR_PALETTE_SIZE = PALETTE_SIZE;
|
|
146
|
+
function avatarPaletteIndex(seed) {
|
|
147
|
+
return paletteIndexFor(seed);
|
|
148
|
+
}
|
|
149
|
+
function normalizeInitials(raw) {
|
|
150
|
+
const trimmed = raw.trim();
|
|
151
|
+
if (!trimmed) return "";
|
|
152
|
+
const tokens = trimmed.split(/\s+/).filter(Boolean);
|
|
153
|
+
if (tokens.length >= 2) {
|
|
154
|
+
return (tokens[0].charAt(0) + tokens[1].charAt(0)).toUpperCase();
|
|
155
|
+
}
|
|
156
|
+
return trimmed.slice(0, 2).toUpperCase();
|
|
157
|
+
}
|
|
158
|
+
var STATUS_DEFAULT_LABEL = {
|
|
159
|
+
online: "Online",
|
|
160
|
+
offline: "Offline",
|
|
161
|
+
busy: "Busy",
|
|
162
|
+
away: "Away"
|
|
163
|
+
};
|
|
164
|
+
var Avatar = forwardRef2(function Avatar2({
|
|
165
|
+
src,
|
|
166
|
+
alt,
|
|
167
|
+
initials,
|
|
168
|
+
icon,
|
|
169
|
+
fallback,
|
|
170
|
+
seed,
|
|
171
|
+
palette,
|
|
172
|
+
size = "md",
|
|
173
|
+
shape = "circle",
|
|
174
|
+
status,
|
|
175
|
+
statusLabel,
|
|
176
|
+
onClick,
|
|
177
|
+
imgLoading = "lazy",
|
|
178
|
+
referrerPolicy,
|
|
179
|
+
className,
|
|
180
|
+
...rest
|
|
181
|
+
}, ref) {
|
|
182
|
+
const [imgFailed, setImgFailed] = useState(false);
|
|
183
|
+
const handleImgError = useCallback(() => setImgFailed(true), []);
|
|
184
|
+
const showImage = Boolean(src) && !imgFailed;
|
|
185
|
+
const normalizedInitials = useMemo(
|
|
186
|
+
() => initials ? normalizeInitials(initials) : "",
|
|
187
|
+
[initials]
|
|
188
|
+
);
|
|
189
|
+
const paletteIdx = useMemo(() => {
|
|
190
|
+
if (palette !== void 0) {
|
|
191
|
+
return (Math.trunc(palette) % PALETTE_SIZE + PALETTE_SIZE) % PALETTE_SIZE;
|
|
192
|
+
}
|
|
193
|
+
const resolved = seed ?? alt ?? initials ?? "?";
|
|
194
|
+
return paletteIndexFor(resolved);
|
|
195
|
+
}, [palette, seed, alt, initials]);
|
|
196
|
+
const baseName = alt || normalizedInitials || "Avatar";
|
|
197
|
+
const announcedStatus = status ? statusLabel ?? STATUS_DEFAULT_LABEL[status] : "";
|
|
198
|
+
const accessibleName = announcedStatus ? `${baseName}, ${announcedStatus}` : baseName;
|
|
199
|
+
const isClickable = Boolean(onClick);
|
|
200
|
+
const handleKeyDown = (e) => {
|
|
201
|
+
if (!isClickable) return;
|
|
202
|
+
if ((e.key === "Enter" || e.key === " ") && !e.repeat) {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
onClick?.();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const rootClassName = cn(
|
|
208
|
+
"ods-avatar",
|
|
209
|
+
`ods-avatar--${size}`,
|
|
210
|
+
`ods-avatar--${shape}`,
|
|
211
|
+
isClickable && "ods-avatar--clickable",
|
|
212
|
+
className
|
|
213
|
+
);
|
|
214
|
+
return /* @__PURE__ */ jsxs(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
...rest,
|
|
218
|
+
ref,
|
|
219
|
+
className: rootClassName,
|
|
220
|
+
role: isClickable ? "button" : "img",
|
|
221
|
+
"aria-label": accessibleName,
|
|
222
|
+
tabIndex: isClickable ? 0 : void 0,
|
|
223
|
+
onClick,
|
|
224
|
+
onKeyDown: isClickable ? handleKeyDown : void 0,
|
|
225
|
+
"data-status": status,
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx2("span", { className: "ods-avatar__inner", "data-palette": paletteIdx, children: showImage ? /* @__PURE__ */ jsx2(
|
|
228
|
+
"img",
|
|
229
|
+
{
|
|
230
|
+
src,
|
|
231
|
+
alt: "",
|
|
232
|
+
className: "ods-avatar__image",
|
|
233
|
+
loading: imgLoading,
|
|
234
|
+
decoding: "async",
|
|
235
|
+
referrerPolicy,
|
|
236
|
+
onError: handleImgError,
|
|
237
|
+
draggable: false
|
|
238
|
+
}
|
|
239
|
+
) : icon ? /* @__PURE__ */ jsx2("span", { className: "ods-avatar__icon", "aria-hidden": "true", children: icon }) : normalizedInitials ? /* @__PURE__ */ jsx2("span", { className: "ods-avatar__initials", "aria-hidden": "true", children: normalizedInitials }) : /* @__PURE__ */ jsx2("span", { className: "ods-avatar__initials", "aria-hidden": "true", children: fallback ?? "?" }) }),
|
|
240
|
+
status && // Decorative — the textual status is folded into the wrapper's
|
|
241
|
+
// aria-label above. `aria-hidden` keeps AT from double-announcing.
|
|
242
|
+
/* @__PURE__ */ jsx2(
|
|
243
|
+
"span",
|
|
244
|
+
{
|
|
245
|
+
className: cn("ods-avatar__status", `ods-avatar__status--${status}`),
|
|
246
|
+
"aria-hidden": "true"
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
Avatar.displayName = "Avatar";
|
|
254
|
+
var AvatarStack = forwardRef2(function AvatarStack2({ children, max, size = "md", renderOverflow, direction = "ltr", className, ...rest }, ref) {
|
|
255
|
+
const arr = Array.isArray(children) ? children : [children];
|
|
256
|
+
const visible = max && arr.length > max ? arr.slice(0, max) : arr;
|
|
257
|
+
const overflow = max && arr.length > max ? arr.length - max : 0;
|
|
258
|
+
return /* @__PURE__ */ jsxs(
|
|
259
|
+
"div",
|
|
260
|
+
{
|
|
261
|
+
...rest,
|
|
262
|
+
ref,
|
|
263
|
+
className: cn("ods-avatar-stack", `ods-avatar-stack--${direction}`, className),
|
|
264
|
+
children: [
|
|
265
|
+
visible,
|
|
266
|
+
overflow > 0 && (renderOverflow ? renderOverflow(overflow) : /* @__PURE__ */ jsx2(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: cn(
|
|
270
|
+
"ods-avatar",
|
|
271
|
+
`ods-avatar--${size}`,
|
|
272
|
+
"ods-avatar--circle",
|
|
273
|
+
"ods-avatar-stack__overflow"
|
|
274
|
+
),
|
|
275
|
+
role: "img",
|
|
276
|
+
"aria-label": `${overflow} more`,
|
|
277
|
+
children: /* @__PURE__ */ jsx2("span", { className: "ods-avatar__inner", children: /* @__PURE__ */ jsxs("span", { className: "ods-avatar__initials", "aria-hidden": "true", children: [
|
|
278
|
+
"+",
|
|
279
|
+
overflow
|
|
280
|
+
] }) })
|
|
281
|
+
}
|
|
282
|
+
))
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
});
|
|
287
|
+
AvatarStack.displayName = "AvatarStack";
|
|
288
|
+
|
|
289
|
+
// src/components/BlogCard/BlogCard.tsx
|
|
290
|
+
import { forwardRef as forwardRef3, useId } from "react";
|
|
291
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
292
|
+
var BlogCard = forwardRef3(function BlogCard2({
|
|
293
|
+
cover,
|
|
294
|
+
coverAspect = "16/9",
|
|
295
|
+
category,
|
|
296
|
+
tags,
|
|
297
|
+
meta,
|
|
298
|
+
readingTime,
|
|
299
|
+
title,
|
|
300
|
+
titleAs = "h3",
|
|
301
|
+
description,
|
|
302
|
+
author,
|
|
303
|
+
footer,
|
|
304
|
+
radius = "md",
|
|
305
|
+
orientation = "vertical",
|
|
306
|
+
href,
|
|
307
|
+
onClick,
|
|
308
|
+
id: providedId,
|
|
309
|
+
className,
|
|
310
|
+
...rest
|
|
311
|
+
}, ref) {
|
|
312
|
+
const reactId = useId();
|
|
313
|
+
const baseId = providedId ?? `ods-blog-card-${reactId}`;
|
|
314
|
+
const titleId = `${baseId}-title`;
|
|
315
|
+
const descId = description ? `${baseId}-desc` : void 0;
|
|
316
|
+
const tagList = tags ?? (category ? [category] : []);
|
|
317
|
+
const body = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
318
|
+
cover && /* @__PURE__ */ jsx3(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
className: cn(
|
|
322
|
+
"ods-blog-card__cover",
|
|
323
|
+
`ods-blog-card__cover--aspect-${coverAspect.replace("/", "-")}`
|
|
324
|
+
),
|
|
325
|
+
"aria-hidden": "true",
|
|
326
|
+
children: cover
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__body", children: [
|
|
330
|
+
(tagList.length > 0 || meta || readingTime) && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__meta", children: [
|
|
331
|
+
tagList.length > 0 && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__tags", children: tagList.map((t, i) => /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__tag", children: t }, i)) }),
|
|
332
|
+
meta && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__date", children: meta }),
|
|
333
|
+
readingTime && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__reading", children: readingTime })
|
|
334
|
+
] }),
|
|
335
|
+
/* @__PURE__ */ jsx3(Card.Title, { as: titleAs, id: titleId, className: "ods-blog-card__title", children: title }),
|
|
336
|
+
description && /* @__PURE__ */ jsx3(Card.Description, { id: descId, className: "ods-blog-card__desc", children: description }),
|
|
337
|
+
(author || footer) && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__footer", children: [
|
|
338
|
+
author && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__author", children: [
|
|
339
|
+
author.avatar && /* @__PURE__ */ jsx3(
|
|
340
|
+
Avatar,
|
|
341
|
+
{
|
|
342
|
+
size: "sm",
|
|
343
|
+
src: author.avatar.src,
|
|
344
|
+
initials: author.avatar.initials,
|
|
345
|
+
seed: author.avatar.seed,
|
|
346
|
+
palette: author.avatar.palette,
|
|
347
|
+
alt: author.avatar.alt ?? (typeof author.name === "string" ? author.name : void 0)
|
|
348
|
+
}
|
|
349
|
+
),
|
|
350
|
+
/* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__author-text", children: [
|
|
351
|
+
/* @__PURE__ */ jsx3("span", { className: "ods-blog-card__author-name", children: author.name }),
|
|
352
|
+
author.byline && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__author-byline", children: author.byline })
|
|
353
|
+
] })
|
|
354
|
+
] }),
|
|
355
|
+
footer && /* @__PURE__ */ jsx3("div", { className: "ods-blog-card__action", children: footer })
|
|
356
|
+
] })
|
|
357
|
+
] })
|
|
358
|
+
] });
|
|
359
|
+
if (href) {
|
|
360
|
+
return /* @__PURE__ */ jsx3(
|
|
361
|
+
Card,
|
|
362
|
+
{
|
|
363
|
+
asChild: true,
|
|
364
|
+
radius,
|
|
365
|
+
padding: "none",
|
|
366
|
+
className: cn(
|
|
367
|
+
"ods-blog-card",
|
|
368
|
+
`ods-blog-card--${orientation}`,
|
|
369
|
+
"ods-blog-card--interactive",
|
|
370
|
+
className
|
|
371
|
+
),
|
|
372
|
+
"aria-labelledby": titleId,
|
|
373
|
+
"aria-describedby": descId,
|
|
374
|
+
children: /* @__PURE__ */ jsx3(
|
|
375
|
+
"a",
|
|
376
|
+
{
|
|
377
|
+
...rest,
|
|
378
|
+
ref,
|
|
379
|
+
href,
|
|
380
|
+
id: baseId,
|
|
381
|
+
onClick,
|
|
382
|
+
children: body
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
return /* @__PURE__ */ jsx3(
|
|
389
|
+
Card,
|
|
390
|
+
{
|
|
391
|
+
...rest,
|
|
392
|
+
ref,
|
|
393
|
+
id: baseId,
|
|
394
|
+
radius,
|
|
395
|
+
padding: "none",
|
|
396
|
+
onClick,
|
|
397
|
+
className: cn(
|
|
398
|
+
"ods-blog-card",
|
|
399
|
+
`ods-blog-card--${orientation}`,
|
|
400
|
+
onClick && "ods-blog-card--interactive",
|
|
401
|
+
className
|
|
402
|
+
),
|
|
403
|
+
"aria-labelledby": titleId,
|
|
404
|
+
"aria-describedby": descId,
|
|
405
|
+
children: body
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
});
|
|
409
|
+
BlogCard.displayName = "BlogCard";
|
|
410
|
+
|
|
411
|
+
// src/components/ChatBubble/ChatBubble.tsx
|
|
412
|
+
import {
|
|
413
|
+
forwardRef as forwardRef4
|
|
414
|
+
} from "react";
|
|
415
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
416
|
+
var STATUS_LABEL = {
|
|
417
|
+
sent: "Sent",
|
|
418
|
+
delivered: "Delivered",
|
|
419
|
+
read: "Read",
|
|
420
|
+
failed: "Failed to send"
|
|
421
|
+
};
|
|
422
|
+
function StatusGlyph({ status }) {
|
|
423
|
+
switch (status) {
|
|
424
|
+
case "sent":
|
|
425
|
+
return /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 10 10", width: "10", height: "10", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
426
|
+
"path",
|
|
427
|
+
{
|
|
428
|
+
d: "M2 5l2 2 4-4",
|
|
429
|
+
stroke: "currentColor",
|
|
430
|
+
strokeWidth: "1.4",
|
|
431
|
+
strokeLinecap: "round",
|
|
432
|
+
strokeLinejoin: "round"
|
|
433
|
+
}
|
|
434
|
+
) });
|
|
435
|
+
case "delivered":
|
|
436
|
+
return /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 12 10", width: "12", height: "10", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
437
|
+
"path",
|
|
438
|
+
{
|
|
439
|
+
d: "M1 5l2 2 3.5-3.5 M5 5l2 2 4-4",
|
|
440
|
+
stroke: "currentColor",
|
|
441
|
+
strokeWidth: "1.4",
|
|
442
|
+
strokeLinecap: "round",
|
|
443
|
+
strokeLinejoin: "round"
|
|
444
|
+
}
|
|
445
|
+
) });
|
|
446
|
+
case "read":
|
|
447
|
+
return /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 12 10", width: "12", height: "10", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
|
|
448
|
+
"path",
|
|
449
|
+
{
|
|
450
|
+
d: "M1 5l2 2 3.5-3.5 M5 5l2 2 4-4",
|
|
451
|
+
stroke: "currentColor",
|
|
452
|
+
strokeWidth: "1.4",
|
|
453
|
+
strokeLinecap: "round",
|
|
454
|
+
strokeLinejoin: "round"
|
|
455
|
+
}
|
|
456
|
+
) });
|
|
457
|
+
case "failed":
|
|
458
|
+
return /* @__PURE__ */ jsxs3("svg", { viewBox: "0 0 10 10", width: "10", height: "10", fill: "none", "aria-hidden": "true", children: [
|
|
459
|
+
/* @__PURE__ */ jsx4("circle", { cx: "5", cy: "5", r: "4", stroke: "currentColor", strokeWidth: "1.4" }),
|
|
460
|
+
/* @__PURE__ */ jsx4("path", { d: "M5 3v3M5 6.8v.2", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
461
|
+
] });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
var ChatBubble = forwardRef4(function ChatBubble2({
|
|
465
|
+
variant = "bot",
|
|
466
|
+
size = "md",
|
|
467
|
+
author,
|
|
468
|
+
timestamp,
|
|
469
|
+
avatar,
|
|
470
|
+
initial,
|
|
471
|
+
hideAvatar = false,
|
|
472
|
+
continuation = false,
|
|
473
|
+
metaPlacement = "bottom",
|
|
474
|
+
isTyping = false,
|
|
475
|
+
status,
|
|
476
|
+
actions,
|
|
477
|
+
attachments,
|
|
478
|
+
asChild = false,
|
|
479
|
+
className,
|
|
480
|
+
children,
|
|
481
|
+
...rest
|
|
482
|
+
}, ref) {
|
|
483
|
+
const isUser = variant === "user";
|
|
484
|
+
const reserveAvatar = hideAvatar || continuation;
|
|
485
|
+
const rootClassName = cn(
|
|
486
|
+
"ods-chat",
|
|
487
|
+
`ods-chat--${variant}`,
|
|
488
|
+
`ods-chat--${size}`,
|
|
489
|
+
isTyping && "ods-chat--typing",
|
|
490
|
+
continuation && "ods-chat--continuation",
|
|
491
|
+
status === "failed" && "ods-chat--failed",
|
|
492
|
+
className
|
|
493
|
+
);
|
|
494
|
+
if (asChild) {
|
|
495
|
+
return /* @__PURE__ */ jsx4(
|
|
496
|
+
Slot,
|
|
497
|
+
{
|
|
498
|
+
...rest,
|
|
499
|
+
ref,
|
|
500
|
+
className: rootClassName,
|
|
501
|
+
children
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
let resolvedAvatar;
|
|
506
|
+
if (avatar !== void 0) {
|
|
507
|
+
resolvedAvatar = avatar;
|
|
508
|
+
} else {
|
|
509
|
+
const resolvedInitial = initial ?? (typeof author === "string" ? author : isUser ? "You" : variant === "system" ? "System" : "AI");
|
|
510
|
+
resolvedAvatar = /* @__PURE__ */ jsx4(
|
|
511
|
+
Avatar,
|
|
512
|
+
{
|
|
513
|
+
initials: resolvedInitial,
|
|
514
|
+
alt: typeof author === "string" ? author : variant,
|
|
515
|
+
seed: typeof author === "string" ? author : variant,
|
|
516
|
+
size: size === "sm" ? "sm" : size === "lg" ? "lg" : "md"
|
|
517
|
+
}
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
const metaEl = author || timestamp || status ? /* @__PURE__ */ jsxs3("div", { className: "ods-chat__meta", children: [
|
|
521
|
+
author && /* @__PURE__ */ jsx4("span", { className: "ods-chat__author", children: author }),
|
|
522
|
+
timestamp && /* @__PURE__ */ jsx4("span", { className: "ods-chat__time", children: timestamp }),
|
|
523
|
+
status && /* @__PURE__ */ jsx4(
|
|
524
|
+
"span",
|
|
525
|
+
{
|
|
526
|
+
className: cn("ods-chat__status", `ods-chat__status--${status}`),
|
|
527
|
+
role: "img",
|
|
528
|
+
"aria-label": STATUS_LABEL[status],
|
|
529
|
+
children: /* @__PURE__ */ jsx4(StatusGlyph, { status })
|
|
530
|
+
}
|
|
531
|
+
)
|
|
532
|
+
] }) : null;
|
|
533
|
+
return /* @__PURE__ */ jsxs3("div", { ...rest, ref, className: rootClassName, children: [
|
|
534
|
+
/* @__PURE__ */ jsx4(
|
|
535
|
+
"div",
|
|
536
|
+
{
|
|
537
|
+
className: cn("ods-chat__avatar-slot", reserveAvatar && "ods-chat__avatar-slot--hidden"),
|
|
538
|
+
"aria-hidden": reserveAvatar || void 0,
|
|
539
|
+
children: resolvedAvatar
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ jsxs3("div", { className: "ods-chat__column", children: [
|
|
543
|
+
metaPlacement === "top" && metaEl,
|
|
544
|
+
/* @__PURE__ */ jsxs3(
|
|
545
|
+
"div",
|
|
546
|
+
{
|
|
547
|
+
className: "ods-chat__bubble",
|
|
548
|
+
role: isTyping ? "status" : void 0,
|
|
549
|
+
"aria-live": isTyping ? "polite" : void 0,
|
|
550
|
+
children: [
|
|
551
|
+
isTyping ? (
|
|
552
|
+
// role="img" gives the dots cluster an accessible name without
|
|
553
|
+
// tripping axe's "aria-label on a non-roleful span" rule. The
|
|
554
|
+
// outer bubble already carries role="status" + aria-live, so
|
|
555
|
+
// AT users hear "Typing" the moment the indicator appears.
|
|
556
|
+
/* @__PURE__ */ jsxs3("span", { className: "ods-chat__typing", role: "img", "aria-label": "Typing", children: [
|
|
557
|
+
/* @__PURE__ */ jsx4("span", { className: "ods-chat__typing-dot" }),
|
|
558
|
+
/* @__PURE__ */ jsx4("span", { className: "ods-chat__typing-dot" }),
|
|
559
|
+
/* @__PURE__ */ jsx4("span", { className: "ods-chat__typing-dot" })
|
|
560
|
+
] })
|
|
561
|
+
) : /* @__PURE__ */ jsx4("div", { className: "ods-chat__body", children }),
|
|
562
|
+
!isTyping && attachments && /* @__PURE__ */ jsx4("div", { className: "ods-chat__attachments", children: attachments })
|
|
563
|
+
]
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
metaPlacement === "bottom" && metaEl,
|
|
567
|
+
actions && /* @__PURE__ */ jsx4("div", { className: "ods-chat__actions", children: actions })
|
|
568
|
+
] })
|
|
569
|
+
] });
|
|
570
|
+
});
|
|
571
|
+
ChatBubble.displayName = "ChatBubble";
|
|
572
|
+
|
|
573
|
+
// src/components/ChatComposer/ChatComposer.tsx
|
|
574
|
+
import {
|
|
575
|
+
forwardRef as forwardRef5,
|
|
576
|
+
useEffect,
|
|
577
|
+
useId as useId2,
|
|
578
|
+
useRef,
|
|
579
|
+
useState as useState2
|
|
580
|
+
} from "react";
|
|
581
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
582
|
+
function SendGlyph() {
|
|
583
|
+
return /* @__PURE__ */ jsx5("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(
|
|
584
|
+
"path",
|
|
585
|
+
{
|
|
586
|
+
d: "M14.5 1.5 7 9M14.5 1.5l-4.6 13-2.9-5.5L1.5 6.1l13-4.6Z",
|
|
587
|
+
stroke: "currentColor",
|
|
588
|
+
strokeWidth: "1.3",
|
|
589
|
+
strokeLinecap: "round",
|
|
590
|
+
strokeLinejoin: "round"
|
|
591
|
+
}
|
|
592
|
+
) });
|
|
593
|
+
}
|
|
594
|
+
function SpinnerGlyph() {
|
|
595
|
+
return /* @__PURE__ */ jsxs4("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: [
|
|
596
|
+
/* @__PURE__ */ jsx5("circle", { cx: "8", cy: "8", r: "6", stroke: "currentColor", strokeOpacity: "0.3", strokeWidth: "2" }),
|
|
597
|
+
/* @__PURE__ */ jsx5("path", { d: "M8 2a6 6 0 0 1 6 6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
|
|
598
|
+
] });
|
|
599
|
+
}
|
|
600
|
+
function StopGlyph() {
|
|
601
|
+
return /* @__PURE__ */ jsx5("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", children: /* @__PURE__ */ jsx5("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1", fill: "currentColor" }) });
|
|
602
|
+
}
|
|
603
|
+
var ChatComposer = forwardRef5(
|
|
604
|
+
function ChatComposer2({
|
|
605
|
+
value,
|
|
606
|
+
defaultValue,
|
|
607
|
+
onChange,
|
|
608
|
+
onSend,
|
|
609
|
+
placeholder = "Write a message\u2026",
|
|
610
|
+
disabled = false,
|
|
611
|
+
sending = false,
|
|
612
|
+
allowEmpty = false,
|
|
613
|
+
size = "md",
|
|
614
|
+
minRows = 1,
|
|
615
|
+
maxRows = 6,
|
|
616
|
+
grow = "up",
|
|
617
|
+
leading,
|
|
618
|
+
trailing,
|
|
619
|
+
onStop,
|
|
620
|
+
stopLabel = "Stop",
|
|
621
|
+
sendIcon,
|
|
622
|
+
sendLabel = "Send message",
|
|
623
|
+
fieldLabel = "Message",
|
|
624
|
+
hint,
|
|
625
|
+
className,
|
|
626
|
+
onKeyDown,
|
|
627
|
+
...rest
|
|
628
|
+
}, forwardedRef) {
|
|
629
|
+
const innerRef = useRef(null);
|
|
630
|
+
const setRef = (node) => {
|
|
631
|
+
innerRef.current = node;
|
|
632
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
633
|
+
else if (forwardedRef)
|
|
634
|
+
forwardedRef.current = node;
|
|
635
|
+
};
|
|
636
|
+
const isControlled = value !== void 0;
|
|
637
|
+
const [internal, setInternal] = useState2(defaultValue ?? "");
|
|
638
|
+
const text = isControlled ? value : internal;
|
|
639
|
+
const baseId = useId2();
|
|
640
|
+
const setText = (next) => {
|
|
641
|
+
if (!isControlled) setInternal(next);
|
|
642
|
+
onChange?.(next);
|
|
643
|
+
};
|
|
644
|
+
useEffect(() => {
|
|
645
|
+
const el = innerRef.current;
|
|
646
|
+
if (!el) return;
|
|
647
|
+
el.style.height = "auto";
|
|
648
|
+
const cs = window.getComputedStyle(el);
|
|
649
|
+
const fontSize = parseFloat(cs.fontSize) || 14;
|
|
650
|
+
const lh = cs.lineHeight === "normal" ? fontSize * 1.4 : cs.lineHeight.endsWith("px") ? parseFloat(cs.lineHeight) : parseFloat(cs.lineHeight) * fontSize;
|
|
651
|
+
const padV = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
|
|
652
|
+
const max = lh * maxRows + padV;
|
|
653
|
+
const next = Math.min(el.scrollHeight, max);
|
|
654
|
+
el.style.height = `${next}px`;
|
|
655
|
+
const overflowing = el.scrollHeight > max;
|
|
656
|
+
el.style.overflowY = overflowing ? "auto" : "hidden";
|
|
657
|
+
if (overflowing) el.scrollTop = el.scrollHeight;
|
|
658
|
+
}, [text, maxRows]);
|
|
659
|
+
const canSend = !disabled && !sending && (allowEmpty || text.trim().length > 0);
|
|
660
|
+
const stoppable = sending && Boolean(onStop);
|
|
661
|
+
const submit = () => {
|
|
662
|
+
if (!canSend) return;
|
|
663
|
+
onSend?.(text);
|
|
664
|
+
if (!isControlled) setInternal("");
|
|
665
|
+
};
|
|
666
|
+
const handleKeyDown = (e) => {
|
|
667
|
+
onKeyDown?.(e);
|
|
668
|
+
if (e.defaultPrevented) return;
|
|
669
|
+
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
670
|
+
e.preventDefault();
|
|
671
|
+
submit();
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
return /* @__PURE__ */ jsxs4(
|
|
675
|
+
"div",
|
|
676
|
+
{
|
|
677
|
+
className: cn(
|
|
678
|
+
"ods-composer",
|
|
679
|
+
`ods-composer--${size}`,
|
|
680
|
+
`ods-composer--grow-${grow}`,
|
|
681
|
+
disabled && "ods-composer--disabled",
|
|
682
|
+
sending && "ods-composer--sending",
|
|
683
|
+
stoppable && "ods-composer--stoppable",
|
|
684
|
+
className
|
|
685
|
+
),
|
|
686
|
+
children: [
|
|
687
|
+
/* @__PURE__ */ jsxs4("div", { className: "ods-composer__row", children: [
|
|
688
|
+
leading && /* @__PURE__ */ jsx5("div", { className: "ods-composer__leading", children: leading }),
|
|
689
|
+
/* @__PURE__ */ jsx5(
|
|
690
|
+
"textarea",
|
|
691
|
+
{
|
|
692
|
+
...rest,
|
|
693
|
+
ref: setRef,
|
|
694
|
+
id: `ods-composer-${baseId}`,
|
|
695
|
+
className: "ods-composer__field",
|
|
696
|
+
rows: minRows,
|
|
697
|
+
value: text,
|
|
698
|
+
placeholder,
|
|
699
|
+
disabled,
|
|
700
|
+
"aria-label": fieldLabel,
|
|
701
|
+
onChange: (e) => setText(e.target.value),
|
|
702
|
+
onKeyDown: handleKeyDown
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ jsxs4("div", { className: "ods-composer__trailing", children: [
|
|
706
|
+
trailing,
|
|
707
|
+
/* @__PURE__ */ jsxs4(
|
|
708
|
+
"button",
|
|
709
|
+
{
|
|
710
|
+
type: "button",
|
|
711
|
+
className: "ods-composer__send",
|
|
712
|
+
"aria-label": stoppable ? stopLabel : sending ? "Sending\u2026" : sendLabel,
|
|
713
|
+
"aria-busy": sending && !stoppable || void 0,
|
|
714
|
+
onClick: stoppable ? onStop : submit,
|
|
715
|
+
disabled: stoppable ? false : !canSend,
|
|
716
|
+
children: [
|
|
717
|
+
/* @__PURE__ */ jsx5("span", { className: "ods-composer__send-icon", children: sendIcon ?? /* @__PURE__ */ jsx5(SendGlyph, {}) }),
|
|
718
|
+
/* @__PURE__ */ jsx5("span", { className: "ods-composer__send-spinner", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(SpinnerGlyph, {}) }),
|
|
719
|
+
/* @__PURE__ */ jsx5("span", { className: "ods-composer__send-stop", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(StopGlyph, {}) })
|
|
720
|
+
]
|
|
721
|
+
}
|
|
722
|
+
)
|
|
723
|
+
] })
|
|
724
|
+
] }),
|
|
725
|
+
hint && /* @__PURE__ */ jsx5("div", { className: "ods-composer__hint", children: hint })
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
ChatComposer.displayName = "ChatComposer";
|
|
732
|
+
|
|
733
|
+
// src/components/ChatLinkPreview/ChatLinkPreview.tsx
|
|
734
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
735
|
+
|
|
736
|
+
// src/components/TruncatedText/TruncatedText.tsx
|
|
737
|
+
import { useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
|
|
738
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
739
|
+
function TruncatedText({ children, className }) {
|
|
740
|
+
const ref = useRef2(null);
|
|
741
|
+
const [cut, setCut] = useState3(false);
|
|
742
|
+
useLayoutEffect(() => {
|
|
743
|
+
const el = ref.current;
|
|
744
|
+
if (!el) return;
|
|
745
|
+
const measure = () => setCut(el.scrollWidth > el.clientWidth);
|
|
746
|
+
measure();
|
|
747
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
748
|
+
const observer = new ResizeObserver(measure);
|
|
749
|
+
observer.observe(el);
|
|
750
|
+
return () => observer.disconnect();
|
|
751
|
+
}, [children]);
|
|
752
|
+
return /* @__PURE__ */ jsx6(Tooltip, { content: children, disabled: !cut, position: "top", children: /* @__PURE__ */ jsx6("span", { ref, className: cn("ods-truncated-text", className), children }) });
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// src/components/ChatLinkPreview/ChatLinkPreview.tsx
|
|
756
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
757
|
+
function hostOf(url) {
|
|
758
|
+
try {
|
|
759
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
760
|
+
} catch {
|
|
761
|
+
return url;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
function linkTargetProps(target) {
|
|
765
|
+
return { target, rel: target === "_blank" ? "noopener noreferrer" : void 0 };
|
|
766
|
+
}
|
|
767
|
+
var ChatLinkPreview = forwardRef6(
|
|
768
|
+
function ChatLinkPreview2({
|
|
769
|
+
url,
|
|
770
|
+
title,
|
|
771
|
+
description,
|
|
772
|
+
siteName,
|
|
773
|
+
image,
|
|
774
|
+
favicon,
|
|
775
|
+
linkTarget = "_blank",
|
|
776
|
+
compact = false,
|
|
777
|
+
className,
|
|
778
|
+
...rest
|
|
779
|
+
}, ref) {
|
|
780
|
+
const host = hostOf(url);
|
|
781
|
+
return /* @__PURE__ */ jsxs5(
|
|
782
|
+
"a",
|
|
783
|
+
{
|
|
784
|
+
...rest,
|
|
785
|
+
ref,
|
|
786
|
+
href: url,
|
|
787
|
+
...linkTargetProps(linkTarget),
|
|
788
|
+
className: cn(
|
|
789
|
+
"ods-chat-link-preview",
|
|
790
|
+
compact && "ods-chat-link-preview--compact",
|
|
791
|
+
className
|
|
792
|
+
),
|
|
793
|
+
children: [
|
|
794
|
+
/* @__PURE__ */ jsxs5("span", { className: "ods-chat-link-preview__body", children: [
|
|
795
|
+
/* @__PURE__ */ jsxs5("span", { className: "ods-chat-link-preview__site", children: [
|
|
796
|
+
favicon && /* @__PURE__ */ jsx7(
|
|
797
|
+
"img",
|
|
798
|
+
{
|
|
799
|
+
className: "ods-chat-link-preview__favicon",
|
|
800
|
+
src: favicon,
|
|
801
|
+
alt: "",
|
|
802
|
+
width: 14,
|
|
803
|
+
height: 14
|
|
804
|
+
}
|
|
805
|
+
),
|
|
806
|
+
/* @__PURE__ */ jsx7("span", { className: "ods-chat-link-preview__site-name", children: siteName ?? host })
|
|
807
|
+
] }),
|
|
808
|
+
/* @__PURE__ */ jsx7(TruncatedText, { className: "ods-chat-link-preview__title", children: title ?? host }),
|
|
809
|
+
description && !compact && /* @__PURE__ */ jsx7("span", { className: "ods-chat-link-preview__description", children: description })
|
|
810
|
+
] }),
|
|
811
|
+
image && /* @__PURE__ */ jsx7(
|
|
812
|
+
"span",
|
|
813
|
+
{
|
|
814
|
+
className: "ods-chat-link-preview__image",
|
|
815
|
+
style: { backgroundImage: `url(${JSON.stringify(image)})` },
|
|
816
|
+
"aria-hidden": "true"
|
|
817
|
+
}
|
|
818
|
+
)
|
|
819
|
+
]
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
);
|
|
824
|
+
ChatLinkPreview.displayName = "ChatLinkPreview";
|
|
825
|
+
|
|
826
|
+
// src/components/ChatDocPreview/ChatDocPreview.tsx
|
|
827
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
828
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
829
|
+
function PageGlyph() {
|
|
830
|
+
return /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: [
|
|
831
|
+
/* @__PURE__ */ jsx8(
|
|
832
|
+
"path",
|
|
833
|
+
{
|
|
834
|
+
d: "M4 2.5h5L13 6.5V13a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1Z",
|
|
835
|
+
stroke: "currentColor",
|
|
836
|
+
strokeWidth: "1.1",
|
|
837
|
+
strokeLinejoin: "round"
|
|
838
|
+
}
|
|
839
|
+
),
|
|
840
|
+
/* @__PURE__ */ jsx8(
|
|
841
|
+
"path",
|
|
842
|
+
{
|
|
843
|
+
d: "M9 2.5V6h3.5M5.5 9h5M5.5 11h3.5",
|
|
844
|
+
stroke: "currentColor",
|
|
845
|
+
strokeWidth: "1.1",
|
|
846
|
+
strokeLinecap: "round"
|
|
847
|
+
}
|
|
848
|
+
)
|
|
849
|
+
] });
|
|
850
|
+
}
|
|
851
|
+
var ChatDocPreview = forwardRef7(
|
|
852
|
+
function ChatDocPreview2({ url, title, path, excerpt, linkTarget = "_blank", className, ...rest }, ref) {
|
|
853
|
+
return /* @__PURE__ */ jsxs6(
|
|
854
|
+
"a",
|
|
855
|
+
{
|
|
856
|
+
...rest,
|
|
857
|
+
ref,
|
|
858
|
+
href: url,
|
|
859
|
+
...linkTargetProps(linkTarget),
|
|
860
|
+
className: cn("ods-chat-doc-preview", className),
|
|
861
|
+
children: [
|
|
862
|
+
/* @__PURE__ */ jsxs6("span", { className: "ods-chat-doc-preview__head", children: [
|
|
863
|
+
/* @__PURE__ */ jsx8("span", { className: "ods-chat-doc-preview__icon", children: /* @__PURE__ */ jsx8(PageGlyph, {}) }),
|
|
864
|
+
/* @__PURE__ */ jsx8(TruncatedText, { className: "ods-chat-doc-preview__title", children: title })
|
|
865
|
+
] }),
|
|
866
|
+
excerpt && /* @__PURE__ */ jsx8("span", { className: "ods-chat-doc-preview__excerpt", children: excerpt }),
|
|
867
|
+
path && path.length > 0 && /* @__PURE__ */ jsx8("span", { className: "ods-chat-doc-preview__path", children: path.map((segment, i) => (
|
|
868
|
+
// Keyed by the path up to here: unique even when a name repeats.
|
|
869
|
+
/* @__PURE__ */ jsx8("span", { className: "ods-chat-doc-preview__segment", children: segment }, path.slice(0, i + 1).join("/"))
|
|
870
|
+
)) })
|
|
871
|
+
]
|
|
872
|
+
}
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
);
|
|
876
|
+
ChatDocPreview.displayName = "ChatDocPreview";
|
|
877
|
+
|
|
878
|
+
// src/components/Radio/RadioGroup.tsx
|
|
879
|
+
import {
|
|
880
|
+
createContext,
|
|
881
|
+
forwardRef as forwardRef8,
|
|
882
|
+
useContext,
|
|
883
|
+
useId as useId3,
|
|
884
|
+
useRef as useRef3
|
|
885
|
+
} from "react";
|
|
886
|
+
import { useRadioGroup } from "react-aria";
|
|
887
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
888
|
+
var RadioGroupContext = createContext(null);
|
|
889
|
+
function useRadioGroupContext() {
|
|
890
|
+
const context = useContext(RadioGroupContext);
|
|
891
|
+
if (!context) {
|
|
892
|
+
throw new Error("Radio must be used within a RadioGroup");
|
|
893
|
+
}
|
|
894
|
+
return context;
|
|
895
|
+
}
|
|
896
|
+
var RadioGroup = forwardRef8(function RadioGroup2({
|
|
897
|
+
value,
|
|
898
|
+
defaultValue,
|
|
899
|
+
onChange,
|
|
900
|
+
label,
|
|
901
|
+
orientation = "vertical",
|
|
902
|
+
disabled = false,
|
|
903
|
+
children,
|
|
904
|
+
className,
|
|
905
|
+
name,
|
|
906
|
+
required,
|
|
907
|
+
id: providedId,
|
|
908
|
+
helperText,
|
|
909
|
+
error,
|
|
910
|
+
"aria-label": ariaLabel,
|
|
911
|
+
"aria-labelledby": ariaLabelledBy,
|
|
912
|
+
"aria-describedby": consumerDescribedBy,
|
|
913
|
+
...rest
|
|
914
|
+
}, ref) {
|
|
915
|
+
const reactId = useId3();
|
|
916
|
+
const baseId = providedId ?? `ods-radio-group-${reactId}`;
|
|
917
|
+
const hintId = error || helperText ? `${baseId}-hint` : void 0;
|
|
918
|
+
const innerRef = useRef3(null);
|
|
919
|
+
const describedBy = [consumerDescribedBy, hintId].filter(Boolean).join(" ") || void 0;
|
|
920
|
+
const ariaProps = {
|
|
921
|
+
// react-aria wants a string label for its `<label>` association,
|
|
922
|
+
// even if our public API also takes ReactNode. Fall back to the
|
|
923
|
+
// explicit aria-label when label isn't a string.
|
|
924
|
+
label: typeof label === "string" ? label : ariaLabel || "radio group",
|
|
925
|
+
value,
|
|
926
|
+
defaultValue,
|
|
927
|
+
onChange,
|
|
928
|
+
isDisabled: disabled,
|
|
929
|
+
isInvalid: !!error,
|
|
930
|
+
isRequired: required,
|
|
931
|
+
orientation,
|
|
932
|
+
name,
|
|
933
|
+
"aria-label": ariaLabel,
|
|
934
|
+
"aria-labelledby": ariaLabelledBy,
|
|
935
|
+
"aria-describedby": describedBy
|
|
936
|
+
};
|
|
937
|
+
const state = $384704861d32dbed$export$bca9d026f8e704eb(ariaProps);
|
|
938
|
+
const { radioGroupProps, labelProps } = useRadioGroup(ariaProps, state);
|
|
939
|
+
const setRef = (node) => {
|
|
940
|
+
innerRef.current = node;
|
|
941
|
+
if (typeof ref === "function") ref(node);
|
|
942
|
+
else if (ref) ref.current = node;
|
|
943
|
+
};
|
|
944
|
+
return /* @__PURE__ */ jsxs7(
|
|
945
|
+
"div",
|
|
946
|
+
{
|
|
947
|
+
...rest,
|
|
948
|
+
...radioGroupProps,
|
|
949
|
+
ref: setRef,
|
|
950
|
+
id: baseId,
|
|
951
|
+
className: cn(
|
|
952
|
+
"ods-radio-group",
|
|
953
|
+
`ods-radio-group--${orientation}`,
|
|
954
|
+
disabled && "ods-radio-group--disabled",
|
|
955
|
+
error && "ods-radio-group--error",
|
|
956
|
+
className
|
|
957
|
+
),
|
|
958
|
+
children: [
|
|
959
|
+
label && /* @__PURE__ */ jsx9("span", { ...labelProps, className: "ods-radio-group__label", children: label }),
|
|
960
|
+
/* @__PURE__ */ jsx9(RadioGroupContext.Provider, { value: state, children: /* @__PURE__ */ jsx9("div", { className: "ods-radio-group__items", children }) }),
|
|
961
|
+
error ? /* @__PURE__ */ jsx9(
|
|
962
|
+
"div",
|
|
963
|
+
{
|
|
964
|
+
id: hintId,
|
|
965
|
+
className: "ods-radio-group__hint ods-radio-group__hint--error",
|
|
966
|
+
role: "alert",
|
|
967
|
+
children: error
|
|
968
|
+
}
|
|
969
|
+
) : helperText ? /* @__PURE__ */ jsx9("div", { id: hintId, className: "ods-radio-group__hint", children: helperText }) : null
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
);
|
|
973
|
+
});
|
|
974
|
+
RadioGroup.displayName = "RadioGroup";
|
|
975
|
+
|
|
976
|
+
// src/components/Radio/Radio.tsx
|
|
977
|
+
import { forwardRef as forwardRef9, useRef as useRef4 } from "react";
|
|
978
|
+
import { useRadio } from "react-aria";
|
|
979
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
980
|
+
var Radio = forwardRef9(function Radio2({ value, label, description, size = "md", disabled = false, className, ...props }, forwardedRef) {
|
|
981
|
+
const state = useRadioGroupContext();
|
|
982
|
+
const innerRef = useRef4(null);
|
|
983
|
+
const setRef = (node) => {
|
|
984
|
+
innerRef.current = node;
|
|
985
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
986
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
987
|
+
};
|
|
988
|
+
const ariaNameProps = resolveAccessibleName({
|
|
989
|
+
label: typeof label === "string" ? label : void 0,
|
|
990
|
+
ariaLabel: props["aria-label"],
|
|
991
|
+
ariaLabelledby: props["aria-labelledby"],
|
|
992
|
+
componentName: "Radio",
|
|
993
|
+
fallbacks: [value]
|
|
994
|
+
});
|
|
995
|
+
const { inputProps } = useRadio(
|
|
996
|
+
{
|
|
997
|
+
value,
|
|
998
|
+
isDisabled: disabled,
|
|
999
|
+
...ariaNameProps
|
|
1000
|
+
},
|
|
1001
|
+
state,
|
|
1002
|
+
innerRef
|
|
1003
|
+
);
|
|
1004
|
+
const isSelected = state.selectedValue === value;
|
|
1005
|
+
const {
|
|
1006
|
+
onClick: _onClick,
|
|
1007
|
+
onKeyDown: _onKeyDown,
|
|
1008
|
+
onKeyUp: _onKeyUp,
|
|
1009
|
+
onFocus: _onFocus,
|
|
1010
|
+
onBlur: _onBlur,
|
|
1011
|
+
...passthroughProps
|
|
1012
|
+
} = props;
|
|
1013
|
+
return /* @__PURE__ */ jsxs8(
|
|
1014
|
+
"label",
|
|
1015
|
+
{
|
|
1016
|
+
className: cn(
|
|
1017
|
+
"ods-radio",
|
|
1018
|
+
`ods-radio--${size}`,
|
|
1019
|
+
isSelected && "ods-radio--selected",
|
|
1020
|
+
disabled && "ods-radio--disabled",
|
|
1021
|
+
description && "ods-radio--with-description",
|
|
1022
|
+
className
|
|
1023
|
+
),
|
|
1024
|
+
children: [
|
|
1025
|
+
/* @__PURE__ */ jsx10(
|
|
1026
|
+
"input",
|
|
1027
|
+
{
|
|
1028
|
+
...passthroughProps,
|
|
1029
|
+
...inputProps,
|
|
1030
|
+
ref: setRef,
|
|
1031
|
+
className: "ods-radio__input"
|
|
1032
|
+
}
|
|
1033
|
+
),
|
|
1034
|
+
/* @__PURE__ */ jsx10("div", { className: "ods-radio__circle", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("div", { className: cn("ods-radio__dot", isSelected && "ods-radio__dot--visible") }) }),
|
|
1035
|
+
(label || description) && /* @__PURE__ */ jsxs8("div", { className: "ods-radio__text", children: [
|
|
1036
|
+
label && /* @__PURE__ */ jsx10("span", { className: "ods-radio__label", children: label }),
|
|
1037
|
+
description && /* @__PURE__ */ jsx10("span", { className: "ods-radio__description", children: description })
|
|
1038
|
+
] })
|
|
1039
|
+
]
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
});
|
|
1043
|
+
Radio.displayName = "Radio";
|
|
1044
|
+
|
|
1045
|
+
// src/components/ChatInputRequest/ChatInputRequest.tsx
|
|
1046
|
+
import {
|
|
1047
|
+
forwardRef as forwardRef10,
|
|
1048
|
+
useId as useId4,
|
|
1049
|
+
useState as useState4
|
|
1050
|
+
} from "react";
|
|
1051
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1052
|
+
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1053
|
+
function optionsOf(field) {
|
|
1054
|
+
return (field.options ?? []).map((o) => typeof o === "string" ? { value: o, label: o } : o);
|
|
1055
|
+
}
|
|
1056
|
+
function emptyValue(field) {
|
|
1057
|
+
if (field.type === "multichoice") return [];
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
function isEmpty(value) {
|
|
1061
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
1062
|
+
return value === null || value === "";
|
|
1063
|
+
}
|
|
1064
|
+
function fieldProblem(field, value) {
|
|
1065
|
+
if (isEmpty(value)) return field.required ? "Required." : null;
|
|
1066
|
+
if (field.type === "email" && typeof value === "string" && !EMAIL.test(value.trim())) {
|
|
1067
|
+
return "Enter an email address, like name@company.com.";
|
|
1068
|
+
}
|
|
1069
|
+
if (field.type === "number" && typeof value === "string" && Number.isNaN(Number(value)))
|
|
1070
|
+
return "Enter a number.";
|
|
1071
|
+
return null;
|
|
1072
|
+
}
|
|
1073
|
+
function problemsOf(fields, values, typed) {
|
|
1074
|
+
return Object.fromEntries(
|
|
1075
|
+
fields.map((f) => {
|
|
1076
|
+
const value = values[f.name] ?? null;
|
|
1077
|
+
return [f.name, typed && isEmpty(value) ? null : fieldProblem(f, value)];
|
|
1078
|
+
})
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
function displayValue(field, value) {
|
|
1082
|
+
if (value === null || isEmpty(value)) return "";
|
|
1083
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
1084
|
+
const labels = new Map(optionsOf(field).map((o) => [o.value, o.label]));
|
|
1085
|
+
if (Array.isArray(value)) return value.map((v) => labels.get(v) ?? v).join(", ");
|
|
1086
|
+
return labels.get(value) ?? value;
|
|
1087
|
+
}
|
|
1088
|
+
function ChoiceField({ field, value, error, disabled, onChange }) {
|
|
1089
|
+
const options = field.type === "boolean" ? [
|
|
1090
|
+
{ value: "yes", label: "Yes" },
|
|
1091
|
+
{ value: "no", label: "No" }
|
|
1092
|
+
] : optionsOf(field);
|
|
1093
|
+
let selected = "";
|
|
1094
|
+
if (field.type === "boolean" && typeof value === "boolean") selected = value ? "yes" : "no";
|
|
1095
|
+
else if (typeof value === "string") selected = value;
|
|
1096
|
+
return /* @__PURE__ */ jsx11(
|
|
1097
|
+
RadioGroup,
|
|
1098
|
+
{
|
|
1099
|
+
label: field.label,
|
|
1100
|
+
value: selected,
|
|
1101
|
+
onChange: (v) => onChange(field.type === "boolean" ? v === "yes" : v),
|
|
1102
|
+
orientation: options.length > 3 ? "vertical" : "horizontal",
|
|
1103
|
+
required: field.required,
|
|
1104
|
+
disabled,
|
|
1105
|
+
helperText: field.helperText,
|
|
1106
|
+
error: error ?? void 0,
|
|
1107
|
+
children: options.map((o) => /* @__PURE__ */ jsx11(Radio, { value: o.value, label: o.label, size: "sm" }, o.value))
|
|
1108
|
+
}
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
function MultiChoiceField({ field, value, error, disabled, onChange }) {
|
|
1112
|
+
const selected = Array.isArray(value) ? value : [];
|
|
1113
|
+
const toggle = (v, on) => onChange(on ? [...selected, v] : selected.filter((s) => s !== v));
|
|
1114
|
+
return /* @__PURE__ */ jsxs9("fieldset", { className: "ods-chat-input-request__group", disabled, children: [
|
|
1115
|
+
/* @__PURE__ */ jsx11("legend", { className: "ods-chat-input-request__legend", children: field.label }),
|
|
1116
|
+
optionsOf(field).map((o) => /* @__PURE__ */ jsx11(
|
|
1117
|
+
Checkbox,
|
|
1118
|
+
{
|
|
1119
|
+
size: "sm",
|
|
1120
|
+
label: o.label,
|
|
1121
|
+
checked: selected.includes(o.value),
|
|
1122
|
+
onChange: (on) => toggle(o.value, on)
|
|
1123
|
+
},
|
|
1124
|
+
o.value
|
|
1125
|
+
)),
|
|
1126
|
+
error && /* @__PURE__ */ jsx11("span", { className: "ods-chat-input-request__error", role: "alert", children: error })
|
|
1127
|
+
] });
|
|
1128
|
+
}
|
|
1129
|
+
function TextField({ field, value, error, disabled, onChange }) {
|
|
1130
|
+
return /* @__PURE__ */ jsx11(
|
|
1131
|
+
Input,
|
|
1132
|
+
{
|
|
1133
|
+
size: "sm",
|
|
1134
|
+
type: field.type === "choice" || field.type === "multichoice" || field.type === "boolean" ? "text" : field.type,
|
|
1135
|
+
label: field.label,
|
|
1136
|
+
value: typeof value === "string" ? value : "",
|
|
1137
|
+
onChange: (e) => onChange(e.target.value),
|
|
1138
|
+
placeholder: field.placeholder,
|
|
1139
|
+
helperText: field.helperText,
|
|
1140
|
+
required: field.required,
|
|
1141
|
+
disabled,
|
|
1142
|
+
error: Boolean(error),
|
|
1143
|
+
errorMessage: error ?? void 0
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
function Field(props) {
|
|
1148
|
+
const { type } = props.field;
|
|
1149
|
+
if (type === "choice" || type === "boolean") return /* @__PURE__ */ jsx11(ChoiceField, { ...props });
|
|
1150
|
+
if (type === "multichoice") return /* @__PURE__ */ jsx11(MultiChoiceField, { ...props });
|
|
1151
|
+
return /* @__PURE__ */ jsx11(TextField, { ...props });
|
|
1152
|
+
}
|
|
1153
|
+
function AnswerSummary({
|
|
1154
|
+
fields,
|
|
1155
|
+
answer
|
|
1156
|
+
}) {
|
|
1157
|
+
if (answer === "skipped") return /* @__PURE__ */ jsx11("p", { className: "ods-chat-input-request__answer", children: "Skipped" });
|
|
1158
|
+
const parts = fields.map((f) => displayValue(f, answer.values[f.name] ?? null)).filter(Boolean);
|
|
1159
|
+
if (answer.text) parts.push(answer.text);
|
|
1160
|
+
return /* @__PURE__ */ jsxs9("p", { className: "ods-chat-input-request__answer", children: [
|
|
1161
|
+
/* @__PURE__ */ jsx11("svg", { viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx11(
|
|
1162
|
+
"path",
|
|
1163
|
+
{
|
|
1164
|
+
d: "M3.5 8.5l3 3 6-7",
|
|
1165
|
+
stroke: "currentColor",
|
|
1166
|
+
strokeWidth: "1.6",
|
|
1167
|
+
strokeLinecap: "round",
|
|
1168
|
+
strokeLinejoin: "round"
|
|
1169
|
+
}
|
|
1170
|
+
) }),
|
|
1171
|
+
/* @__PURE__ */ jsx11("span", { children: parts.length > 0 ? parts.join(" \xB7 ") : "Sent" })
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
var ChatInputRequest = forwardRef10(
|
|
1175
|
+
function ChatInputRequest2({
|
|
1176
|
+
prompt,
|
|
1177
|
+
description,
|
|
1178
|
+
fields,
|
|
1179
|
+
onSubmit,
|
|
1180
|
+
onSkip,
|
|
1181
|
+
answer = null,
|
|
1182
|
+
submitting = false,
|
|
1183
|
+
submitLabel = "Send",
|
|
1184
|
+
skipLabel = "Skip",
|
|
1185
|
+
textPlaceholder = "Or type your answer\u2026",
|
|
1186
|
+
className,
|
|
1187
|
+
...rest
|
|
1188
|
+
}, ref) {
|
|
1189
|
+
const promptId = useId4();
|
|
1190
|
+
const [values, setValues] = useState4(
|
|
1191
|
+
() => Object.fromEntries(fields.map((f) => [f.name, emptyValue(f)]))
|
|
1192
|
+
);
|
|
1193
|
+
const [errors, setErrors] = useState4({});
|
|
1194
|
+
const [text, setText] = useState4("");
|
|
1195
|
+
const [textError, setTextError] = useState4(null);
|
|
1196
|
+
const answered = answer !== null;
|
|
1197
|
+
const locked = answered || submitting;
|
|
1198
|
+
const submit = (e) => {
|
|
1199
|
+
e.preventDefault();
|
|
1200
|
+
if (locked) return;
|
|
1201
|
+
const typed = text.trim();
|
|
1202
|
+
if (fields.length === 0 && !typed) {
|
|
1203
|
+
setTextError("Type an answer.");
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
const found = problemsOf(fields, values, typed);
|
|
1207
|
+
setErrors(found);
|
|
1208
|
+
if (Object.values(found).some(Boolean)) return;
|
|
1209
|
+
onSubmit(values, typed || void 0);
|
|
1210
|
+
};
|
|
1211
|
+
return /* @__PURE__ */ jsxs9(
|
|
1212
|
+
"form",
|
|
1213
|
+
{
|
|
1214
|
+
...rest,
|
|
1215
|
+
ref,
|
|
1216
|
+
noValidate: true,
|
|
1217
|
+
"aria-labelledby": promptId,
|
|
1218
|
+
onSubmit: submit,
|
|
1219
|
+
className: cn(
|
|
1220
|
+
"ods-chat-input-request",
|
|
1221
|
+
answered && "ods-chat-input-request--answered",
|
|
1222
|
+
className
|
|
1223
|
+
),
|
|
1224
|
+
children: [
|
|
1225
|
+
/* @__PURE__ */ jsxs9("div", { className: "ods-chat-input-request__head", children: [
|
|
1226
|
+
/* @__PURE__ */ jsx11("p", { id: promptId, className: "ods-chat-input-request__prompt", children: prompt }),
|
|
1227
|
+
description && !answered && /* @__PURE__ */ jsx11("p", { className: "ods-chat-input-request__description", children: description })
|
|
1228
|
+
] }),
|
|
1229
|
+
answered ? /* @__PURE__ */ jsx11(AnswerSummary, { fields, answer }) : /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
1230
|
+
fields.length > 0 && /* @__PURE__ */ jsx11("div", { className: "ods-chat-input-request__fields", children: fields.map((f) => /* @__PURE__ */ jsx11(
|
|
1231
|
+
Field,
|
|
1232
|
+
{
|
|
1233
|
+
field: f,
|
|
1234
|
+
value: values[f.name] ?? null,
|
|
1235
|
+
error: errors[f.name] ?? null,
|
|
1236
|
+
disabled: locked,
|
|
1237
|
+
onChange: (v) => {
|
|
1238
|
+
setValues((prev) => ({ ...prev, [f.name]: v }));
|
|
1239
|
+
if (errors[f.name]) setErrors((prev) => ({ ...prev, [f.name]: null }));
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
f.name
|
|
1243
|
+
)) }),
|
|
1244
|
+
/* @__PURE__ */ jsx11("div", { className: "ods-chat-input-request__reply", children: /* @__PURE__ */ jsx11(
|
|
1245
|
+
Input,
|
|
1246
|
+
{
|
|
1247
|
+
size: "sm",
|
|
1248
|
+
"aria-label": "Type your answer",
|
|
1249
|
+
className: "ods-chat-input-request__text",
|
|
1250
|
+
value: text,
|
|
1251
|
+
onChange: (e) => {
|
|
1252
|
+
setText(e.target.value);
|
|
1253
|
+
if (textError) setTextError(null);
|
|
1254
|
+
},
|
|
1255
|
+
placeholder: textPlaceholder,
|
|
1256
|
+
disabled: locked,
|
|
1257
|
+
error: Boolean(textError),
|
|
1258
|
+
errorMessage: textError ?? void 0
|
|
1259
|
+
}
|
|
1260
|
+
) }),
|
|
1261
|
+
/* @__PURE__ */ jsxs9("div", { className: "ods-chat-input-request__actions", children: [
|
|
1262
|
+
onSkip && /* @__PURE__ */ jsx11(
|
|
1263
|
+
Button,
|
|
1264
|
+
{
|
|
1265
|
+
type: "button",
|
|
1266
|
+
variant: "ghost",
|
|
1267
|
+
size: "sm",
|
|
1268
|
+
onClick: onSkip,
|
|
1269
|
+
disabled: submitting,
|
|
1270
|
+
children: skipLabel
|
|
1271
|
+
}
|
|
1272
|
+
),
|
|
1273
|
+
/* @__PURE__ */ jsx11(Button, { type: "submit", variant: "primary", size: "sm", loading: submitting, children: submitLabel })
|
|
1274
|
+
] })
|
|
1275
|
+
] })
|
|
1276
|
+
]
|
|
1277
|
+
}
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
);
|
|
1281
|
+
ChatInputRequest.displayName = "ChatInputRequest";
|
|
1282
|
+
|
|
1283
|
+
// src/components/ChatFeedback/ChatFeedback.tsx
|
|
1284
|
+
import { forwardRef as forwardRef11, useState as useState5 } from "react";
|
|
1285
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1286
|
+
function ThumbUp() {
|
|
1287
|
+
return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 16 16", width: "15", height: "15", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx12(
|
|
1288
|
+
"path",
|
|
1289
|
+
{
|
|
1290
|
+
d: "M5 7v6H3a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h2Zm0 0 3-4.5A1.5 1.5 0 0 1 10.4 4l-.6 3h3.1a1.5 1.5 0 0 1 1.47 1.8l-.8 4A1.5 1.5 0 0 1 12.1 14H5",
|
|
1291
|
+
stroke: "currentColor",
|
|
1292
|
+
strokeWidth: "1.2",
|
|
1293
|
+
strokeLinejoin: "round"
|
|
1294
|
+
}
|
|
1295
|
+
) });
|
|
1296
|
+
}
|
|
1297
|
+
function ThumbDown() {
|
|
1298
|
+
return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 16 16", width: "15", height: "15", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx12(
|
|
1299
|
+
"path",
|
|
1300
|
+
{
|
|
1301
|
+
d: "M11 9V3h2a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-2Zm0 0-3 4.5A1.5 1.5 0 0 1 5.6 12l.6-3H3.1A1.5 1.5 0 0 1 1.63 7.2l.8-4A1.5 1.5 0 0 1 3.9 2H11",
|
|
1302
|
+
stroke: "currentColor",
|
|
1303
|
+
strokeWidth: "1.2",
|
|
1304
|
+
strokeLinejoin: "round"
|
|
1305
|
+
}
|
|
1306
|
+
) });
|
|
1307
|
+
}
|
|
1308
|
+
function CopyGlyph() {
|
|
1309
|
+
return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: [
|
|
1310
|
+
/* @__PURE__ */ jsx12("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
1311
|
+
/* @__PURE__ */ jsx12(
|
|
1312
|
+
"path",
|
|
1313
|
+
{
|
|
1314
|
+
d: "M10.5 5.5V4A1.5 1.5 0 0 0 9 2.5H4A1.5 1.5 0 0 0 2.5 4v5A1.5 1.5 0 0 0 4 10.5h1.5",
|
|
1315
|
+
stroke: "currentColor",
|
|
1316
|
+
strokeWidth: "1.2"
|
|
1317
|
+
}
|
|
1318
|
+
)
|
|
1319
|
+
] });
|
|
1320
|
+
}
|
|
1321
|
+
function CheckGlyph() {
|
|
1322
|
+
return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx12(
|
|
1323
|
+
"path",
|
|
1324
|
+
{
|
|
1325
|
+
d: "M3 8.5l3 3 7-7",
|
|
1326
|
+
stroke: "currentColor",
|
|
1327
|
+
strokeWidth: "1.4",
|
|
1328
|
+
strokeLinecap: "round",
|
|
1329
|
+
strokeLinejoin: "round"
|
|
1330
|
+
}
|
|
1331
|
+
) });
|
|
1332
|
+
}
|
|
1333
|
+
function RegenGlyph() {
|
|
1334
|
+
return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx12(
|
|
1335
|
+
"path",
|
|
1336
|
+
{
|
|
1337
|
+
d: "M13 8a5 5 0 1 1-1.5-3.5M13 2v3h-3",
|
|
1338
|
+
stroke: "currentColor",
|
|
1339
|
+
strokeWidth: "1.2",
|
|
1340
|
+
strokeLinecap: "round",
|
|
1341
|
+
strokeLinejoin: "round"
|
|
1342
|
+
}
|
|
1343
|
+
) });
|
|
1344
|
+
}
|
|
1345
|
+
var ChatFeedback = forwardRef11(function ChatFeedback2({
|
|
1346
|
+
rating,
|
|
1347
|
+
defaultRating = null,
|
|
1348
|
+
onRate,
|
|
1349
|
+
onCopy,
|
|
1350
|
+
onRegenerate,
|
|
1351
|
+
children,
|
|
1352
|
+
size = "sm",
|
|
1353
|
+
className,
|
|
1354
|
+
...rest
|
|
1355
|
+
}, ref) {
|
|
1356
|
+
const isControlled = rating !== void 0;
|
|
1357
|
+
const [internal, setInternal] = useState5(defaultRating);
|
|
1358
|
+
const current = isControlled ? rating : internal;
|
|
1359
|
+
const [copied, setCopied] = useState5(false);
|
|
1360
|
+
const rate = (next) => {
|
|
1361
|
+
const resolved = current === next ? null : next;
|
|
1362
|
+
if (!isControlled) setInternal(resolved);
|
|
1363
|
+
onRate?.(resolved);
|
|
1364
|
+
};
|
|
1365
|
+
const copy = () => {
|
|
1366
|
+
onCopy?.();
|
|
1367
|
+
setCopied(true);
|
|
1368
|
+
window.setTimeout(() => setCopied(false), 1600);
|
|
1369
|
+
};
|
|
1370
|
+
const btnSize = size === "md" ? "md" : "sm";
|
|
1371
|
+
return /* @__PURE__ */ jsxs10(
|
|
1372
|
+
"div",
|
|
1373
|
+
{
|
|
1374
|
+
...rest,
|
|
1375
|
+
ref,
|
|
1376
|
+
className: cn("ods-chat-feedback", `ods-chat-feedback--${size}`, className),
|
|
1377
|
+
role: "group",
|
|
1378
|
+
"aria-label": "Message feedback",
|
|
1379
|
+
children: [
|
|
1380
|
+
/* @__PURE__ */ jsx12(
|
|
1381
|
+
Button,
|
|
1382
|
+
{
|
|
1383
|
+
variant: "icon",
|
|
1384
|
+
size: btnSize,
|
|
1385
|
+
"aria-label": "Good response",
|
|
1386
|
+
pressed: current === "up",
|
|
1387
|
+
onClick: () => rate("up"),
|
|
1388
|
+
children: /* @__PURE__ */ jsx12(ThumbUp, {})
|
|
1389
|
+
}
|
|
1390
|
+
),
|
|
1391
|
+
/* @__PURE__ */ jsx12(
|
|
1392
|
+
Button,
|
|
1393
|
+
{
|
|
1394
|
+
variant: "icon",
|
|
1395
|
+
size: btnSize,
|
|
1396
|
+
"aria-label": "Bad response",
|
|
1397
|
+
pressed: current === "down",
|
|
1398
|
+
onClick: () => rate("down"),
|
|
1399
|
+
children: /* @__PURE__ */ jsx12(ThumbDown, {})
|
|
1400
|
+
}
|
|
1401
|
+
),
|
|
1402
|
+
onCopy && /* @__PURE__ */ jsx12(
|
|
1403
|
+
Button,
|
|
1404
|
+
{
|
|
1405
|
+
variant: "icon",
|
|
1406
|
+
size: btnSize,
|
|
1407
|
+
"aria-label": copied ? "Copied" : "Copy",
|
|
1408
|
+
onClick: copy,
|
|
1409
|
+
children: copied ? /* @__PURE__ */ jsx12(CheckGlyph, {}) : /* @__PURE__ */ jsx12(CopyGlyph, {})
|
|
1410
|
+
}
|
|
1411
|
+
),
|
|
1412
|
+
onRegenerate && /* @__PURE__ */ jsx12(
|
|
1413
|
+
Button,
|
|
1414
|
+
{
|
|
1415
|
+
variant: "icon",
|
|
1416
|
+
size: btnSize,
|
|
1417
|
+
"aria-label": "Regenerate response",
|
|
1418
|
+
onClick: onRegenerate,
|
|
1419
|
+
children: /* @__PURE__ */ jsx12(RegenGlyph, {})
|
|
1420
|
+
}
|
|
1421
|
+
),
|
|
1422
|
+
children
|
|
1423
|
+
]
|
|
1424
|
+
}
|
|
1425
|
+
);
|
|
1426
|
+
});
|
|
1427
|
+
ChatFeedback.displayName = "ChatFeedback";
|
|
1428
|
+
|
|
1429
|
+
// src/components/ChatScrollToBottom/ChatScrollToBottom.tsx
|
|
1430
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
1431
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1432
|
+
var ChatScrollToBottom = forwardRef12(
|
|
1433
|
+
function ChatScrollToBottom2({ count, label = "Jump to latest", showLabel, className, ...rest }, ref) {
|
|
1434
|
+
const hasCount = typeof count === "number" && count > 0;
|
|
1435
|
+
const withLabel = showLabel ?? hasCount;
|
|
1436
|
+
const text = hasCount ? `${count} new` : withLabel ? label : null;
|
|
1437
|
+
return /* @__PURE__ */ jsxs11(
|
|
1438
|
+
"button",
|
|
1439
|
+
{
|
|
1440
|
+
...rest,
|
|
1441
|
+
ref,
|
|
1442
|
+
type: "button",
|
|
1443
|
+
className: cn(
|
|
1444
|
+
"ods-chat-scroll-bottom",
|
|
1445
|
+
!withLabel && "ods-chat-scroll-bottom--icon",
|
|
1446
|
+
className
|
|
1447
|
+
),
|
|
1448
|
+
"aria-label": label,
|
|
1449
|
+
children: [
|
|
1450
|
+
/* @__PURE__ */ jsx13("svg", { viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
|
|
1451
|
+
"path",
|
|
1452
|
+
{
|
|
1453
|
+
d: "M8 3v8.5M4.5 8L8 11.5 11.5 8",
|
|
1454
|
+
stroke: "currentColor",
|
|
1455
|
+
strokeWidth: "1.5",
|
|
1456
|
+
strokeLinecap: "round",
|
|
1457
|
+
strokeLinejoin: "round"
|
|
1458
|
+
}
|
|
1459
|
+
) }),
|
|
1460
|
+
text && /* @__PURE__ */ jsx13("span", { className: "ods-chat-scroll-bottom__text", children: text })
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
);
|
|
1466
|
+
ChatScrollToBottom.displayName = "ChatScrollToBottom";
|
|
1467
|
+
|
|
1468
|
+
// src/components/ChatThread/ChatThread.tsx
|
|
1469
|
+
import {
|
|
1470
|
+
Children,
|
|
1471
|
+
forwardRef as forwardRef13,
|
|
1472
|
+
useEffect as useEffect2,
|
|
1473
|
+
useRef as useRef5
|
|
1474
|
+
} from "react";
|
|
1475
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1476
|
+
var STICK_THRESHOLD = 120;
|
|
1477
|
+
var ChatThread = forwardRef13(function ChatThread2({
|
|
1478
|
+
children,
|
|
1479
|
+
emptyState,
|
|
1480
|
+
loading = false,
|
|
1481
|
+
header,
|
|
1482
|
+
footer,
|
|
1483
|
+
stickToBottom = true,
|
|
1484
|
+
gap = "md",
|
|
1485
|
+
className,
|
|
1486
|
+
onScroll,
|
|
1487
|
+
...rest
|
|
1488
|
+
}, forwardedRef) {
|
|
1489
|
+
const innerRef = useRef5(null);
|
|
1490
|
+
const setRef = (node) => {
|
|
1491
|
+
innerRef.current = node;
|
|
1492
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1493
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1494
|
+
};
|
|
1495
|
+
const following = useRef5(true);
|
|
1496
|
+
const handleScroll = (e) => {
|
|
1497
|
+
const el = e.currentTarget;
|
|
1498
|
+
following.current = el.scrollHeight - el.scrollTop - el.clientHeight < STICK_THRESHOLD;
|
|
1499
|
+
onScroll?.(e);
|
|
1500
|
+
};
|
|
1501
|
+
useEffect2(() => {
|
|
1502
|
+
if (!stickToBottom || loading) return;
|
|
1503
|
+
const el = innerRef.current;
|
|
1504
|
+
if (el && following.current) el.scrollTop = el.scrollHeight;
|
|
1505
|
+
});
|
|
1506
|
+
const isEmpty2 = Children.count(children) === 0;
|
|
1507
|
+
const showEmpty = !loading && isEmpty2 && !footer && emptyState != null;
|
|
1508
|
+
return /* @__PURE__ */ jsx14(
|
|
1509
|
+
"div",
|
|
1510
|
+
{
|
|
1511
|
+
...rest,
|
|
1512
|
+
ref: setRef,
|
|
1513
|
+
className: cn("ods-chat-thread", `ods-chat-thread--gap-${gap}`, className),
|
|
1514
|
+
role: "log",
|
|
1515
|
+
"aria-live": "polite",
|
|
1516
|
+
"aria-relevant": "additions",
|
|
1517
|
+
onScroll: handleScroll,
|
|
1518
|
+
children: loading ? /* @__PURE__ */ jsx14("div", { className: "ods-chat-thread__loading", children: /* @__PURE__ */ jsx14(Spinner, { label: "Loading messages" }) }) : showEmpty ? /* @__PURE__ */ jsx14("div", { className: "ods-chat-thread__empty", children: emptyState }) : /* @__PURE__ */ jsxs12("div", { className: "ods-chat-thread__list", children: [
|
|
1519
|
+
header && /* @__PURE__ */ jsx14("div", { className: "ods-chat-thread__header", children: header }),
|
|
1520
|
+
children,
|
|
1521
|
+
footer && /* @__PURE__ */ jsx14("div", { className: "ods-chat-thread__footer", children: footer })
|
|
1522
|
+
] })
|
|
1523
|
+
}
|
|
1524
|
+
);
|
|
1525
|
+
});
|
|
1526
|
+
ChatThread.displayName = "ChatThread";
|
|
1527
|
+
|
|
1528
|
+
// src/components/ChatPanel/ChatPanel.tsx
|
|
1529
|
+
import {
|
|
1530
|
+
forwardRef as forwardRef14,
|
|
1531
|
+
useCallback as useCallback2,
|
|
1532
|
+
useRef as useRef6,
|
|
1533
|
+
useState as useState6
|
|
1534
|
+
} from "react";
|
|
1535
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1536
|
+
var JUMP_THRESHOLD = 200;
|
|
1537
|
+
var ChatPanel = forwardRef14(function ChatPanel2({
|
|
1538
|
+
header,
|
|
1539
|
+
children,
|
|
1540
|
+
emptyState,
|
|
1541
|
+
loading = false,
|
|
1542
|
+
thinking,
|
|
1543
|
+
threadHeader,
|
|
1544
|
+
suggestions,
|
|
1545
|
+
composer,
|
|
1546
|
+
onSend,
|
|
1547
|
+
composerProps,
|
|
1548
|
+
threadProps,
|
|
1549
|
+
showScrollToBottom = true,
|
|
1550
|
+
className,
|
|
1551
|
+
...rest
|
|
1552
|
+
}, ref) {
|
|
1553
|
+
const threadRef = useRef6(null);
|
|
1554
|
+
const [showJump, setShowJump] = useState6(false);
|
|
1555
|
+
const handleScroll = useCallback2(() => {
|
|
1556
|
+
const el = threadRef.current;
|
|
1557
|
+
if (!el) return;
|
|
1558
|
+
setShowJump(el.scrollHeight - el.scrollTop - el.clientHeight > JUMP_THRESHOLD);
|
|
1559
|
+
}, []);
|
|
1560
|
+
const jumpToBottom = useCallback2(() => {
|
|
1561
|
+
const el = threadRef.current;
|
|
1562
|
+
if (el) el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
|
|
1563
|
+
}, []);
|
|
1564
|
+
return /* @__PURE__ */ jsxs13("div", { ...rest, ref, className: cn("ods-chat-panel", className), children: [
|
|
1565
|
+
header && /* @__PURE__ */ jsx15("div", { className: "ods-chat-panel__header", children: header }),
|
|
1566
|
+
/* @__PURE__ */ jsxs13("div", { className: "ods-chat-panel__body", children: [
|
|
1567
|
+
/* @__PURE__ */ jsx15(
|
|
1568
|
+
ChatThread,
|
|
1569
|
+
{
|
|
1570
|
+
...threadProps,
|
|
1571
|
+
ref: threadRef,
|
|
1572
|
+
loading,
|
|
1573
|
+
emptyState,
|
|
1574
|
+
header: threadHeader,
|
|
1575
|
+
footer: thinking,
|
|
1576
|
+
onScroll: handleScroll,
|
|
1577
|
+
children
|
|
1578
|
+
}
|
|
1579
|
+
),
|
|
1580
|
+
showScrollToBottom && showJump && /* @__PURE__ */ jsx15("div", { className: "ods-chat-panel__jump", children: /* @__PURE__ */ jsx15(ChatScrollToBottom, { showLabel: true, onClick: jumpToBottom }) })
|
|
1581
|
+
] }),
|
|
1582
|
+
suggestions && /* @__PURE__ */ jsx15("div", { className: "ods-chat-panel__suggestions", children: suggestions }),
|
|
1583
|
+
(composer || onSend) && /* @__PURE__ */ jsx15("div", { className: "ods-chat-panel__composer", children: composer ?? /* @__PURE__ */ jsx15(ChatComposer, { onSend, ...composerProps }) })
|
|
1584
|
+
] });
|
|
1585
|
+
});
|
|
1586
|
+
ChatPanel.displayName = "ChatPanel";
|
|
1587
|
+
|
|
1588
|
+
// src/components/ChatVideoPreview/ChatVideoPreview.tsx
|
|
1589
|
+
import { forwardRef as forwardRef15, useState as useState7 } from "react";
|
|
1590
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1591
|
+
var PROVIDER_LABEL = {
|
|
1592
|
+
youtube: "YouTube",
|
|
1593
|
+
vimeo: "Vimeo",
|
|
1594
|
+
loom: "Loom",
|
|
1595
|
+
file: "Video"
|
|
1596
|
+
};
|
|
1597
|
+
var ID = /^[\w-]+$/;
|
|
1598
|
+
function youtubeId(u) {
|
|
1599
|
+
const host = u.hostname.replace(/^www\.|^m\./, "");
|
|
1600
|
+
if (host === "youtu.be") return u.pathname.slice(1).split("/")[0] || null;
|
|
1601
|
+
if (host !== "youtube.com" && host !== "youtube-nocookie.com") return null;
|
|
1602
|
+
if (u.pathname === "/watch") return u.searchParams.get("v");
|
|
1603
|
+
const [, kind, id] = u.pathname.split("/");
|
|
1604
|
+
return kind === "embed" || kind === "shorts" || kind === "live" ? id ?? null : null;
|
|
1605
|
+
}
|
|
1606
|
+
function lastSegment(u, prefixes) {
|
|
1607
|
+
const parts = u.pathname.split("/").filter(Boolean);
|
|
1608
|
+
if (parts.length === 0) return null;
|
|
1609
|
+
if (prefixes.length > 0 && !prefixes.includes(parts[0] ?? "")) return null;
|
|
1610
|
+
return parts[parts.length - 1] ?? null;
|
|
1611
|
+
}
|
|
1612
|
+
function videoEmbedOf(url) {
|
|
1613
|
+
let u;
|
|
1614
|
+
try {
|
|
1615
|
+
u = new URL(url);
|
|
1616
|
+
} catch {
|
|
1617
|
+
return null;
|
|
1618
|
+
}
|
|
1619
|
+
if (u.protocol !== "https:" && u.protocol !== "http:") return null;
|
|
1620
|
+
const host = u.hostname.replace(/^www\./, "");
|
|
1621
|
+
const yt = youtubeId(u);
|
|
1622
|
+
if (yt && ID.test(yt))
|
|
1623
|
+
return { provider: "youtube", src: `https://www.youtube-nocookie.com/embed/${yt}?autoplay=1` };
|
|
1624
|
+
if (host === "vimeo.com" || host === "player.vimeo.com") {
|
|
1625
|
+
const id = lastSegment(u, []);
|
|
1626
|
+
if (id && /^\d+$/.test(id))
|
|
1627
|
+
return { provider: "vimeo", src: `https://player.vimeo.com/video/${id}?autoplay=1` };
|
|
1628
|
+
}
|
|
1629
|
+
if (host === "loom.com") {
|
|
1630
|
+
const id = lastSegment(u, ["share", "embed"]);
|
|
1631
|
+
if (id && ID.test(id))
|
|
1632
|
+
return { provider: "loom", src: `https://www.loom.com/embed/${id}?autoplay=1` };
|
|
1633
|
+
}
|
|
1634
|
+
if (/\.(mp4|webm|mov)$/i.test(u.pathname)) return { provider: "file", src: u.toString() };
|
|
1635
|
+
return null;
|
|
1636
|
+
}
|
|
1637
|
+
function PlayGlyph() {
|
|
1638
|
+
return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 24 24", width: "22", height: "22", "aria-hidden": "true", children: /* @__PURE__ */ jsx16("path", { d: "M8 5.5v13l10.5-6.5z", fill: "currentColor" }) });
|
|
1639
|
+
}
|
|
1640
|
+
function seedOf(text) {
|
|
1641
|
+
let h = 2166136261;
|
|
1642
|
+
for (let i = 0; i < text.length; i++) {
|
|
1643
|
+
h ^= text.charCodeAt(i);
|
|
1644
|
+
h = Math.imul(h, 16777619);
|
|
1645
|
+
}
|
|
1646
|
+
return h >>> 0;
|
|
1647
|
+
}
|
|
1648
|
+
function pick(seed, n, min, max) {
|
|
1649
|
+
const v = (seed >>> n * 3) % 1e3;
|
|
1650
|
+
return min + Math.round(v / 999 * (max - min));
|
|
1651
|
+
}
|
|
1652
|
+
function PosterArt({ url, source }) {
|
|
1653
|
+
const seed = seedOf(url);
|
|
1654
|
+
const holes = Array.from({ length: 16 }, (_, i) => i * 20 + 6);
|
|
1655
|
+
const frames = [0, 1, 2].map((i) => ({ x: 24 + i * 94, h: pick(seed, i, 44, 62) }));
|
|
1656
|
+
return /* @__PURE__ */ jsxs14("span", { className: "ods-chat-video-preview__art", "aria-hidden": "true", children: [
|
|
1657
|
+
/* @__PURE__ */ jsxs14(
|
|
1658
|
+
"svg",
|
|
1659
|
+
{
|
|
1660
|
+
viewBox: "0 0 320 180",
|
|
1661
|
+
preserveAspectRatio: "xMidYMid slice",
|
|
1662
|
+
width: "100%",
|
|
1663
|
+
height: "100%",
|
|
1664
|
+
"aria-hidden": "true",
|
|
1665
|
+
children: [
|
|
1666
|
+
/* @__PURE__ */ jsx16("rect", { className: "ods-chat-video-preview__art-strip", x: "0", y: "0", width: "320", height: "16" }),
|
|
1667
|
+
/* @__PURE__ */ jsx16("rect", { className: "ods-chat-video-preview__art-strip", x: "0", y: "164", width: "320", height: "16" }),
|
|
1668
|
+
holes.map((x) => /* @__PURE__ */ jsxs14("g", { children: [
|
|
1669
|
+
/* @__PURE__ */ jsx16("rect", { className: "ods-chat-video-preview__art-hole", x, y: "5", width: "8", height: "6" }),
|
|
1670
|
+
/* @__PURE__ */ jsx16("rect", { className: "ods-chat-video-preview__art-hole", x, y: "169", width: "8", height: "6" })
|
|
1671
|
+
] }, x)),
|
|
1672
|
+
frames.map((f, i) => /* @__PURE__ */ jsx16(
|
|
1673
|
+
"rect",
|
|
1674
|
+
{
|
|
1675
|
+
className: `ods-chat-video-preview__art-frame ods-chat-video-preview__art-frame--${i}`,
|
|
1676
|
+
x: f.x,
|
|
1677
|
+
y: 90 - f.h / 2 - 8,
|
|
1678
|
+
width: "84",
|
|
1679
|
+
height: f.h
|
|
1680
|
+
},
|
|
1681
|
+
f.x
|
|
1682
|
+
)),
|
|
1683
|
+
/* @__PURE__ */ jsx16(
|
|
1684
|
+
"rect",
|
|
1685
|
+
{
|
|
1686
|
+
className: "ods-chat-video-preview__art-line",
|
|
1687
|
+
x: "24",
|
|
1688
|
+
y: "134",
|
|
1689
|
+
width: pick(seed, 3, 120, 220),
|
|
1690
|
+
height: "5"
|
|
1691
|
+
}
|
|
1692
|
+
),
|
|
1693
|
+
/* @__PURE__ */ jsx16(
|
|
1694
|
+
"rect",
|
|
1695
|
+
{
|
|
1696
|
+
className: "ods-chat-video-preview__art-line",
|
|
1697
|
+
x: "24",
|
|
1698
|
+
y: "145",
|
|
1699
|
+
width: pick(seed, 4, 60, 150),
|
|
1700
|
+
height: "5"
|
|
1701
|
+
}
|
|
1702
|
+
)
|
|
1703
|
+
]
|
|
1704
|
+
}
|
|
1705
|
+
),
|
|
1706
|
+
/* @__PURE__ */ jsx16("span", { className: "ods-chat-video-preview__art-label", children: source })
|
|
1707
|
+
] });
|
|
1708
|
+
}
|
|
1709
|
+
function Player({ embed, title }) {
|
|
1710
|
+
if (embed.provider === "file") {
|
|
1711
|
+
return (
|
|
1712
|
+
// biome-ignore lint/a11y/useMediaCaption: captions come with the source file, which the card does not own.
|
|
1713
|
+
/* @__PURE__ */ jsx16(
|
|
1714
|
+
"video",
|
|
1715
|
+
{
|
|
1716
|
+
className: "ods-chat-video-preview__player",
|
|
1717
|
+
src: embed.src,
|
|
1718
|
+
controls: true,
|
|
1719
|
+
autoPlay: true,
|
|
1720
|
+
playsInline: true
|
|
1721
|
+
}
|
|
1722
|
+
)
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
return /* @__PURE__ */ jsx16(
|
|
1726
|
+
"iframe",
|
|
1727
|
+
{
|
|
1728
|
+
className: "ods-chat-video-preview__player",
|
|
1729
|
+
src: embed.src,
|
|
1730
|
+
title,
|
|
1731
|
+
allow: "autoplay; encrypted-media; picture-in-picture; fullscreen",
|
|
1732
|
+
allowFullScreen: true,
|
|
1733
|
+
referrerPolicy: "strict-origin-when-cross-origin"
|
|
1734
|
+
}
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
var ChatVideoPreview = forwardRef15(
|
|
1738
|
+
function ChatVideoPreview2({ url, title, thumbnail, duration, linkTarget = "_blank", className, ...rest }, ref) {
|
|
1739
|
+
const [playing, setPlaying] = useState7(false);
|
|
1740
|
+
const [failedPoster, setFailedPoster] = useState7(null);
|
|
1741
|
+
const embed = videoEmbedOf(url);
|
|
1742
|
+
const label = typeof title === "string" ? title : "video";
|
|
1743
|
+
const source = embed ? PROVIDER_LABEL[embed.provider] : hostOf(url);
|
|
1744
|
+
const showImage = Boolean(thumbnail) && failedPoster !== thumbnail;
|
|
1745
|
+
const poster = /* @__PURE__ */ jsxs14("span", { className: "ods-chat-video-preview__poster", children: [
|
|
1746
|
+
/* @__PURE__ */ jsx16(PosterArt, { url, source }),
|
|
1747
|
+
showImage && /* @__PURE__ */ jsx16(
|
|
1748
|
+
"img",
|
|
1749
|
+
{
|
|
1750
|
+
className: "ods-chat-video-preview__poster-img",
|
|
1751
|
+
src: thumbnail,
|
|
1752
|
+
alt: "",
|
|
1753
|
+
onError: () => setFailedPoster(thumbnail ?? null)
|
|
1754
|
+
}
|
|
1755
|
+
),
|
|
1756
|
+
/* @__PURE__ */ jsx16("span", { className: "ods-chat-video-preview__play", children: /* @__PURE__ */ jsx16(PlayGlyph, {}) }),
|
|
1757
|
+
duration && /* @__PURE__ */ jsx16("span", { className: "ods-chat-video-preview__duration", children: duration })
|
|
1758
|
+
] });
|
|
1759
|
+
let stage;
|
|
1760
|
+
if (embed && playing) {
|
|
1761
|
+
stage = /* @__PURE__ */ jsx16(Player, { embed, title: label });
|
|
1762
|
+
} else if (embed) {
|
|
1763
|
+
stage = /* @__PURE__ */ jsx16(
|
|
1764
|
+
"button",
|
|
1765
|
+
{
|
|
1766
|
+
type: "button",
|
|
1767
|
+
className: "ods-chat-video-preview__stage",
|
|
1768
|
+
onClick: () => setPlaying(true),
|
|
1769
|
+
"aria-label": `Play ${label}`,
|
|
1770
|
+
children: poster
|
|
1771
|
+
}
|
|
1772
|
+
);
|
|
1773
|
+
} else {
|
|
1774
|
+
stage = /* @__PURE__ */ jsx16(
|
|
1775
|
+
"a",
|
|
1776
|
+
{
|
|
1777
|
+
className: "ods-chat-video-preview__stage",
|
|
1778
|
+
href: url,
|
|
1779
|
+
...linkTargetProps(linkTarget),
|
|
1780
|
+
"aria-label": `Open ${label}`,
|
|
1781
|
+
children: poster
|
|
1782
|
+
}
|
|
1783
|
+
);
|
|
1784
|
+
}
|
|
1785
|
+
return /* @__PURE__ */ jsxs14(
|
|
1786
|
+
"div",
|
|
1787
|
+
{
|
|
1788
|
+
...rest,
|
|
1789
|
+
ref,
|
|
1790
|
+
className: cn(
|
|
1791
|
+
"ods-chat-video-preview",
|
|
1792
|
+
playing && "ods-chat-video-preview--playing",
|
|
1793
|
+
className
|
|
1794
|
+
),
|
|
1795
|
+
children: [
|
|
1796
|
+
/* @__PURE__ */ jsx16("div", { className: "ods-chat-video-preview__frame", children: stage }),
|
|
1797
|
+
/* @__PURE__ */ jsxs14("div", { className: "ods-chat-video-preview__meta", children: [
|
|
1798
|
+
/* @__PURE__ */ jsx16(TruncatedText, { className: "ods-chat-video-preview__title", children: title }),
|
|
1799
|
+
/* @__PURE__ */ jsxs14("span", { className: "ods-chat-video-preview__source", children: [
|
|
1800
|
+
source,
|
|
1801
|
+
/* @__PURE__ */ jsx16("a", { className: "ods-chat-video-preview__open", href: url, ...linkTargetProps(linkTarget), children: "Open" })
|
|
1802
|
+
] })
|
|
1803
|
+
] })
|
|
1804
|
+
]
|
|
1805
|
+
}
|
|
1806
|
+
);
|
|
1807
|
+
}
|
|
1808
|
+
);
|
|
1809
|
+
ChatVideoPreview.displayName = "ChatVideoPreview";
|
|
1810
|
+
|
|
1811
|
+
// src/components/ChatSources/ChatSources.tsx
|
|
1812
|
+
import { forwardRef as forwardRef16, useState as useState8 } from "react";
|
|
1813
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1814
|
+
function hostOf2(url) {
|
|
1815
|
+
try {
|
|
1816
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
1817
|
+
} catch {
|
|
1818
|
+
return url;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
var ChatSources = forwardRef16(function ChatSources2({
|
|
1822
|
+
sources,
|
|
1823
|
+
label = "Sources",
|
|
1824
|
+
display = "links",
|
|
1825
|
+
numbered = true,
|
|
1826
|
+
defaultOpen = false,
|
|
1827
|
+
linkTarget = "_blank",
|
|
1828
|
+
className,
|
|
1829
|
+
...rest
|
|
1830
|
+
}, ref) {
|
|
1831
|
+
const [open, setOpen] = useState8(defaultOpen);
|
|
1832
|
+
if (!sources || sources.length === 0) return null;
|
|
1833
|
+
const count = sources.length;
|
|
1834
|
+
const isChips = display === "chips" || display === "plain-chips";
|
|
1835
|
+
return /* @__PURE__ */ jsxs15(
|
|
1836
|
+
"details",
|
|
1837
|
+
{
|
|
1838
|
+
...rest,
|
|
1839
|
+
ref,
|
|
1840
|
+
open,
|
|
1841
|
+
onToggle: (e) => setOpen(e.currentTarget.open),
|
|
1842
|
+
className: cn("ods-chat-sources", `ods-chat-sources--${display}`, className),
|
|
1843
|
+
children: [
|
|
1844
|
+
/* @__PURE__ */ jsxs15("summary", { className: "ods-chat-sources__trigger", children: [
|
|
1845
|
+
/* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__caret", "aria-hidden": "true", children: /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 12 12", width: "11", height: "11", fill: "none", children: /* @__PURE__ */ jsx17(
|
|
1846
|
+
"path",
|
|
1847
|
+
{
|
|
1848
|
+
d: "M4 2.5L8 6l-4 3.5",
|
|
1849
|
+
stroke: "currentColor",
|
|
1850
|
+
strokeWidth: "1.4",
|
|
1851
|
+
strokeLinecap: "round",
|
|
1852
|
+
strokeLinejoin: "round"
|
|
1853
|
+
}
|
|
1854
|
+
) }) }),
|
|
1855
|
+
/* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__trigger-label", children: label }),
|
|
1856
|
+
/* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__count", children: count })
|
|
1857
|
+
] }),
|
|
1858
|
+
/* @__PURE__ */ jsx17("div", { className: cn("ods-chat-sources__panel", isChips && "ods-chat-sources__panel--chips"), children: sources.map((s, i) => {
|
|
1859
|
+
const key = s.id ?? `${i}`;
|
|
1860
|
+
const idx = numbered ? /* @__PURE__ */ jsxs15("span", { className: "ods-chat-sources__index", children: [
|
|
1861
|
+
"[",
|
|
1862
|
+
i + 1,
|
|
1863
|
+
"]"
|
|
1864
|
+
] }) : null;
|
|
1865
|
+
const linkProps = s.url ? {
|
|
1866
|
+
href: s.url,
|
|
1867
|
+
target: linkTarget,
|
|
1868
|
+
rel: linkTarget === "_blank" ? "noopener noreferrer" : void 0
|
|
1869
|
+
} : null;
|
|
1870
|
+
if (isChips) {
|
|
1871
|
+
const chipClass = cn(
|
|
1872
|
+
"ods-chat-sources__chip",
|
|
1873
|
+
s.url && display === "chips" && "ods-chat-sources__chip--link"
|
|
1874
|
+
);
|
|
1875
|
+
return display === "chips" && linkProps ? /* @__PURE__ */ jsx17("a", { className: chipClass, ...linkProps, children: s.title }, key) : /* @__PURE__ */ jsx17("span", { className: chipClass, children: s.title }, key);
|
|
1876
|
+
}
|
|
1877
|
+
if (display === "urls") {
|
|
1878
|
+
const shown = s.url ?? "";
|
|
1879
|
+
return /* @__PURE__ */ jsxs15("a", { className: "ods-chat-sources__url", ...linkProps ?? {}, children: [
|
|
1880
|
+
idx,
|
|
1881
|
+
/* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__url-text", children: shown || s.title })
|
|
1882
|
+
] }, key);
|
|
1883
|
+
}
|
|
1884
|
+
const Row = linkProps ? "a" : "div";
|
|
1885
|
+
return /* @__PURE__ */ jsxs15(
|
|
1886
|
+
Row,
|
|
1887
|
+
{
|
|
1888
|
+
className: cn("ods-chat-sources__row", s.url && "ods-chat-sources__row--link"),
|
|
1889
|
+
...linkProps ?? {},
|
|
1890
|
+
children: [
|
|
1891
|
+
idx,
|
|
1892
|
+
/* @__PURE__ */ jsxs15("span", { className: "ods-chat-sources__body", children: [
|
|
1893
|
+
/* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__title", children: s.title }),
|
|
1894
|
+
s.snippet && /* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__snippet", children: s.snippet })
|
|
1895
|
+
] }),
|
|
1896
|
+
(s.meta ?? (s.url ? hostOf2(s.url) : null)) && /* @__PURE__ */ jsx17("span", { className: "ods-chat-sources__meta", children: s.meta ?? hostOf2(s.url) })
|
|
1897
|
+
]
|
|
1898
|
+
},
|
|
1899
|
+
key
|
|
1900
|
+
);
|
|
1901
|
+
}) })
|
|
1902
|
+
]
|
|
1903
|
+
}
|
|
1904
|
+
);
|
|
1905
|
+
});
|
|
1906
|
+
ChatSources.displayName = "ChatSources";
|
|
1907
|
+
|
|
1908
|
+
// src/components/ChatSuggestions/ChatSuggestions.tsx
|
|
1909
|
+
import { forwardRef as forwardRef17 } from "react";
|
|
1910
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1911
|
+
function normalize(item) {
|
|
1912
|
+
return typeof item === "string" ? { label: item, value: item } : item;
|
|
1913
|
+
}
|
|
1914
|
+
function resolveValue(s) {
|
|
1915
|
+
if (s.value != null) return s.value;
|
|
1916
|
+
return typeof s.label === "string" ? s.label : "";
|
|
1917
|
+
}
|
|
1918
|
+
var ChatSuggestions = forwardRef17(
|
|
1919
|
+
function ChatSuggestions2({ items, onSelect, label, size = "md", layout = "wrap", disabled = false, className, ...rest }, ref) {
|
|
1920
|
+
return /* @__PURE__ */ jsxs16(
|
|
1921
|
+
"div",
|
|
1922
|
+
{
|
|
1923
|
+
...rest,
|
|
1924
|
+
ref,
|
|
1925
|
+
className: cn(
|
|
1926
|
+
"ods-chat-suggestions",
|
|
1927
|
+
`ods-chat-suggestions--${size}`,
|
|
1928
|
+
`ods-chat-suggestions--${layout}`,
|
|
1929
|
+
className
|
|
1930
|
+
),
|
|
1931
|
+
role: "group",
|
|
1932
|
+
"aria-label": typeof label === "string" ? label : "Suggested replies",
|
|
1933
|
+
children: [
|
|
1934
|
+
label && /* @__PURE__ */ jsx18("span", { className: "ods-chat-suggestions__label", children: label }),
|
|
1935
|
+
/* @__PURE__ */ jsx18("div", { className: "ods-chat-suggestions__track", children: items.map((raw, i) => {
|
|
1936
|
+
const s = normalize(raw);
|
|
1937
|
+
const isDisabled = disabled || s.disabled;
|
|
1938
|
+
return /* @__PURE__ */ jsxs16(
|
|
1939
|
+
"button",
|
|
1940
|
+
{
|
|
1941
|
+
type: "button",
|
|
1942
|
+
className: "ods-chat-suggestions__chip",
|
|
1943
|
+
disabled: isDisabled,
|
|
1944
|
+
onClick: () => onSelect?.(resolveValue(s), s),
|
|
1945
|
+
children: [
|
|
1946
|
+
s.icon && /* @__PURE__ */ jsx18("span", { className: "ods-chat-suggestions__chip-icon", children: s.icon }),
|
|
1947
|
+
/* @__PURE__ */ jsx18("span", { className: "ods-chat-suggestions__chip-label", children: s.label })
|
|
1948
|
+
]
|
|
1949
|
+
},
|
|
1950
|
+
s.id ?? `${i}`
|
|
1951
|
+
);
|
|
1952
|
+
}) })
|
|
1953
|
+
]
|
|
1954
|
+
}
|
|
1955
|
+
);
|
|
1956
|
+
}
|
|
1957
|
+
);
|
|
1958
|
+
ChatSuggestions.displayName = "ChatSuggestions";
|
|
1959
|
+
|
|
1960
|
+
// src/components/ChatThinking/ChatThinking.tsx
|
|
1961
|
+
import {
|
|
1962
|
+
forwardRef as forwardRef18,
|
|
1963
|
+
useEffect as useEffect3,
|
|
1964
|
+
useState as useState9
|
|
1965
|
+
} from "react";
|
|
1966
|
+
import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1967
|
+
var ChatThinking = forwardRef18(function ChatThinking2({
|
|
1968
|
+
variant = "dots",
|
|
1969
|
+
label,
|
|
1970
|
+
labels,
|
|
1971
|
+
cycleMs = 2200,
|
|
1972
|
+
size = "md",
|
|
1973
|
+
srLabel = "Assistant is thinking",
|
|
1974
|
+
className,
|
|
1975
|
+
...rest
|
|
1976
|
+
}, ref) {
|
|
1977
|
+
const cycling = Array.isArray(labels) && labels.length > 0;
|
|
1978
|
+
const [idx, setIdx] = useState9(0);
|
|
1979
|
+
useEffect3(() => {
|
|
1980
|
+
if (!cycling || labels.length < 2) return;
|
|
1981
|
+
const id = window.setInterval(() => setIdx((i) => (i + 1) % labels.length), cycleMs);
|
|
1982
|
+
return () => window.clearInterval(id);
|
|
1983
|
+
}, [cycling, labels, cycleMs]);
|
|
1984
|
+
const activeLabel = cycling ? labels[idx % labels.length] : label;
|
|
1985
|
+
const fadeKey = cycling ? idx : void 0;
|
|
1986
|
+
let indicator;
|
|
1987
|
+
switch (variant) {
|
|
1988
|
+
case "wave":
|
|
1989
|
+
indicator = /* @__PURE__ */ jsx19("span", { className: "ods-thinking__wave", children: [0, 1, 2, 3, 4].map((i) => /* @__PURE__ */ jsx19("span", { className: "ods-thinking__wave-dot" }, i)) });
|
|
1990
|
+
break;
|
|
1991
|
+
case "pulse":
|
|
1992
|
+
indicator = /* @__PURE__ */ jsx19("span", { className: "ods-thinking__pulse" });
|
|
1993
|
+
break;
|
|
1994
|
+
case "bars":
|
|
1995
|
+
indicator = /* @__PURE__ */ jsx19("span", { className: "ods-thinking__bars", children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx19("span", { className: "ods-thinking__bar" }, i)) });
|
|
1996
|
+
break;
|
|
1997
|
+
case "shimmer":
|
|
1998
|
+
indicator = /* @__PURE__ */ jsx19("span", { className: "ods-thinking__shimmer", children: activeLabel ?? "Thinking\u2026" }, fadeKey);
|
|
1999
|
+
break;
|
|
2000
|
+
case "cursor":
|
|
2001
|
+
indicator = /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
2002
|
+
/* @__PURE__ */ jsx19("span", { className: "ods-thinking__cursor-label ods-thinking__fade", children: activeLabel ?? "Thinking" }, fadeKey),
|
|
2003
|
+
/* @__PURE__ */ jsx19("span", { className: "ods-thinking__cursor" })
|
|
2004
|
+
] });
|
|
2005
|
+
break;
|
|
2006
|
+
case "dots":
|
|
2007
|
+
default:
|
|
2008
|
+
indicator = /* @__PURE__ */ jsx19("span", { className: "ods-thinking__dots", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx19("span", { className: "ods-thinking__dot" }, i)) });
|
|
2009
|
+
}
|
|
2010
|
+
const labelInline = variant !== "shimmer" && variant !== "cursor";
|
|
2011
|
+
const inlineLabel = cycling ? activeLabel : label;
|
|
2012
|
+
return /* @__PURE__ */ jsxs17(
|
|
2013
|
+
"div",
|
|
2014
|
+
{
|
|
2015
|
+
...rest,
|
|
2016
|
+
ref,
|
|
2017
|
+
role: "status",
|
|
2018
|
+
"aria-live": "polite",
|
|
2019
|
+
className: cn("ods-thinking", `ods-thinking--${variant}`, `ods-thinking--${size}`, className),
|
|
2020
|
+
children: [
|
|
2021
|
+
/* @__PURE__ */ jsx19("span", { className: "ods-thinking__sr", children: srLabel }),
|
|
2022
|
+
/* @__PURE__ */ jsx19("span", { className: "ods-thinking__indicator", "aria-hidden": "true", children: indicator }),
|
|
2023
|
+
labelInline && inlineLabel && /* @__PURE__ */ jsx19("span", { className: "ods-thinking__label ods-thinking__fade", "aria-hidden": "true", children: inlineLabel }, fadeKey)
|
|
2024
|
+
]
|
|
2025
|
+
}
|
|
2026
|
+
);
|
|
2027
|
+
});
|
|
2028
|
+
ChatThinking.displayName = "ChatThinking";
|
|
2029
|
+
|
|
2030
|
+
// src/components/CountUp/CountUp.tsx
|
|
2031
|
+
import {
|
|
2032
|
+
forwardRef as forwardRef19,
|
|
2033
|
+
useEffect as useEffect4,
|
|
2034
|
+
useRef as useRef7,
|
|
2035
|
+
useState as useState10
|
|
2036
|
+
} from "react";
|
|
2037
|
+
import { jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2038
|
+
var easeLinear = (t) => t;
|
|
2039
|
+
var easeOutCubic = (t) => 1 - (1 - t) ** 3;
|
|
2040
|
+
var easeOutQuart = (t) => 1 - (1 - t) ** 4;
|
|
2041
|
+
var easeOutExpo = (t) => t === 1 ? 1 : 1 - 2 ** (-10 * t);
|
|
2042
|
+
var CountUp = forwardRef19(function CountUp2({
|
|
2043
|
+
value,
|
|
2044
|
+
from = 0,
|
|
2045
|
+
duration = 800,
|
|
2046
|
+
easing = easeOutCubic,
|
|
2047
|
+
decimals = 0,
|
|
2048
|
+
formatValue,
|
|
2049
|
+
prefix,
|
|
2050
|
+
suffix,
|
|
2051
|
+
delay = 0,
|
|
2052
|
+
disableAnimation = false,
|
|
2053
|
+
onComplete,
|
|
2054
|
+
className,
|
|
2055
|
+
...rest
|
|
2056
|
+
}, ref) {
|
|
2057
|
+
const [n, setN] = useState10(disableAnimation ? value : from);
|
|
2058
|
+
const lastRendered = useRef7(disableAnimation ? value : from);
|
|
2059
|
+
useEffect4(() => {
|
|
2060
|
+
const reduced = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
2061
|
+
if (disableAnimation || reduced) {
|
|
2062
|
+
setN(value);
|
|
2063
|
+
lastRendered.current = value;
|
|
2064
|
+
onComplete?.();
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
const startValue = lastRendered.current;
|
|
2068
|
+
const delta = value - startValue;
|
|
2069
|
+
if (delta === 0) return;
|
|
2070
|
+
let raf = null;
|
|
2071
|
+
let timeoutId = null;
|
|
2072
|
+
let startTime = null;
|
|
2073
|
+
let cancelled = false;
|
|
2074
|
+
const tick = (ts) => {
|
|
2075
|
+
if (cancelled) return;
|
|
2076
|
+
if (startTime === null) startTime = ts;
|
|
2077
|
+
const t = Math.min(1, (ts - startTime) / Math.max(1, duration));
|
|
2078
|
+
const eased = easing(t);
|
|
2079
|
+
const current = startValue + delta * eased;
|
|
2080
|
+
setN(current);
|
|
2081
|
+
lastRendered.current = current;
|
|
2082
|
+
if (t < 1) {
|
|
2083
|
+
raf = requestAnimationFrame(tick);
|
|
2084
|
+
} else {
|
|
2085
|
+
lastRendered.current = value;
|
|
2086
|
+
setN(value);
|
|
2087
|
+
onComplete?.();
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
const start = () => {
|
|
2091
|
+
raf = requestAnimationFrame(tick);
|
|
2092
|
+
};
|
|
2093
|
+
if (delay > 0) {
|
|
2094
|
+
timeoutId = window.setTimeout(start, delay);
|
|
2095
|
+
} else {
|
|
2096
|
+
start();
|
|
2097
|
+
}
|
|
2098
|
+
return () => {
|
|
2099
|
+
cancelled = true;
|
|
2100
|
+
if (raf !== null) cancelAnimationFrame(raf);
|
|
2101
|
+
if (timeoutId !== null) window.clearTimeout(timeoutId);
|
|
2102
|
+
};
|
|
2103
|
+
}, [value, duration, delay, disableAnimation]);
|
|
2104
|
+
const display = formatValue ? formatValue(n) : n.toFixed(decimals);
|
|
2105
|
+
return /* @__PURE__ */ jsxs18(
|
|
2106
|
+
"span",
|
|
2107
|
+
{
|
|
2108
|
+
...rest,
|
|
2109
|
+
ref,
|
|
2110
|
+
className: cn("ods-count-up", className),
|
|
2111
|
+
"aria-live": "polite",
|
|
2112
|
+
"aria-atomic": "true",
|
|
2113
|
+
children: [
|
|
2114
|
+
prefix,
|
|
2115
|
+
display,
|
|
2116
|
+
suffix
|
|
2117
|
+
]
|
|
2118
|
+
}
|
|
2119
|
+
);
|
|
2120
|
+
});
|
|
2121
|
+
CountUp.displayName = "CountUp";
|
|
2122
|
+
|
|
2123
|
+
// src/hooks/useTextareaCommands.ts
|
|
2124
|
+
import {
|
|
2125
|
+
useCallback as useCallback3,
|
|
2126
|
+
useEffect as useEffect5,
|
|
2127
|
+
useMemo as useMemo2,
|
|
2128
|
+
useRef as useRef8,
|
|
2129
|
+
useState as useState11
|
|
2130
|
+
} from "react";
|
|
2131
|
+
function findOpenTrigger(value, caret, trigger) {
|
|
2132
|
+
let i = caret - 1;
|
|
2133
|
+
while (i >= 0) {
|
|
2134
|
+
const ch = value[i];
|
|
2135
|
+
if (ch === "\n" || ch === " " || ch === " ") return null;
|
|
2136
|
+
if (value.startsWith(trigger, i)) {
|
|
2137
|
+
const before = i === 0 ? "" : value[i - 1];
|
|
2138
|
+
if (i === 0 || before === " " || before === "\n" || before === " ") {
|
|
2139
|
+
return {
|
|
2140
|
+
triggerIndex: i,
|
|
2141
|
+
query: value.slice(i + trigger.length, caret)
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
return null;
|
|
2145
|
+
}
|
|
2146
|
+
i--;
|
|
2147
|
+
}
|
|
2148
|
+
return null;
|
|
2149
|
+
}
|
|
2150
|
+
function getCaretRect(textarea, caret) {
|
|
2151
|
+
if (typeof document === "undefined") return null;
|
|
2152
|
+
const mirror = document.createElement("div");
|
|
2153
|
+
const styles = window.getComputedStyle(textarea);
|
|
2154
|
+
for (const prop of [
|
|
2155
|
+
"boxSizing",
|
|
2156
|
+
"width",
|
|
2157
|
+
"fontFamily",
|
|
2158
|
+
"fontSize",
|
|
2159
|
+
"fontWeight",
|
|
2160
|
+
"fontStyle",
|
|
2161
|
+
"letterSpacing",
|
|
2162
|
+
"lineHeight",
|
|
2163
|
+
"paddingTop",
|
|
2164
|
+
"paddingRight",
|
|
2165
|
+
"paddingBottom",
|
|
2166
|
+
"paddingLeft",
|
|
2167
|
+
"borderTopWidth",
|
|
2168
|
+
"borderRightWidth",
|
|
2169
|
+
"borderBottomWidth",
|
|
2170
|
+
"borderLeftWidth",
|
|
2171
|
+
"textTransform",
|
|
2172
|
+
"wordSpacing",
|
|
2173
|
+
"tabSize",
|
|
2174
|
+
"whiteSpace"
|
|
2175
|
+
]) {
|
|
2176
|
+
mirror.style[prop] = styles[prop];
|
|
2177
|
+
}
|
|
2178
|
+
mirror.style.position = "absolute";
|
|
2179
|
+
mirror.style.visibility = "hidden";
|
|
2180
|
+
mirror.style.overflow = "hidden";
|
|
2181
|
+
mirror.style.top = "0";
|
|
2182
|
+
mirror.style.left = "0";
|
|
2183
|
+
mirror.style.whiteSpace = "pre-wrap";
|
|
2184
|
+
mirror.style.wordWrap = "break-word";
|
|
2185
|
+
mirror.textContent = textarea.value.slice(0, caret);
|
|
2186
|
+
const marker = document.createElement("span");
|
|
2187
|
+
marker.textContent = "\u200B";
|
|
2188
|
+
mirror.appendChild(marker);
|
|
2189
|
+
document.body.appendChild(mirror);
|
|
2190
|
+
const taRect = textarea.getBoundingClientRect();
|
|
2191
|
+
const markerRect = marker.getBoundingClientRect();
|
|
2192
|
+
const mirrorRect = mirror.getBoundingClientRect();
|
|
2193
|
+
const x = taRect.left + (markerRect.left - mirrorRect.left) - textarea.scrollLeft;
|
|
2194
|
+
const y = taRect.top + (markerRect.top - mirrorRect.top) - textarea.scrollTop;
|
|
2195
|
+
const out = new DOMRect(x, y, 0, markerRect.height || 16);
|
|
2196
|
+
document.body.removeChild(mirror);
|
|
2197
|
+
return out;
|
|
2198
|
+
}
|
|
2199
|
+
function useTextareaCommands({
|
|
2200
|
+
textareaRef,
|
|
2201
|
+
value,
|
|
2202
|
+
onChange,
|
|
2203
|
+
commands,
|
|
2204
|
+
trigger = "/",
|
|
2205
|
+
openOnEmptyTrigger = true,
|
|
2206
|
+
maxItems = 8
|
|
2207
|
+
}) {
|
|
2208
|
+
const [isOpen, setIsOpen] = useState11(false);
|
|
2209
|
+
const [query, setQuery] = useState11("");
|
|
2210
|
+
const [activeIndex, setActiveIndex] = useState11(0);
|
|
2211
|
+
const [triggerIndex, setTriggerIndex] = useState11(null);
|
|
2212
|
+
const [caretRect, setCaretRect] = useState11(null);
|
|
2213
|
+
const dismissedAtRef = useRef8(null);
|
|
2214
|
+
const items = useMemo2(() => {
|
|
2215
|
+
const q = query.trim().toLowerCase();
|
|
2216
|
+
if (!q) return commands.slice(0, maxItems);
|
|
2217
|
+
return commands.filter((c) => {
|
|
2218
|
+
const hay = [
|
|
2219
|
+
typeof c.label === "string" ? c.label : "",
|
|
2220
|
+
typeof c.description === "string" ? c.description : "",
|
|
2221
|
+
c.id,
|
|
2222
|
+
...c.keywords ?? []
|
|
2223
|
+
].join(" ").toLowerCase();
|
|
2224
|
+
return hay.includes(q);
|
|
2225
|
+
}).slice(0, maxItems);
|
|
2226
|
+
}, [commands, query, maxItems]);
|
|
2227
|
+
useEffect5(() => {
|
|
2228
|
+
const ta = textareaRef.current;
|
|
2229
|
+
if (!ta) return;
|
|
2230
|
+
const caret = ta.selectionStart ?? 0;
|
|
2231
|
+
const dismissedAt = dismissedAtRef.current;
|
|
2232
|
+
if (dismissedAt && dismissedAt.value === value && dismissedAt.caret === caret) {
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2235
|
+
const found = findOpenTrigger(value, caret, trigger);
|
|
2236
|
+
if (!found) {
|
|
2237
|
+
if (isOpen) setIsOpen(false);
|
|
2238
|
+
setTriggerIndex(null);
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
if (dismissedAt) dismissedAtRef.current = null;
|
|
2242
|
+
if (found.query.length > 0 || openOnEmptyTrigger) {
|
|
2243
|
+
setQuery(found.query);
|
|
2244
|
+
setTriggerIndex(found.triggerIndex);
|
|
2245
|
+
setIsOpen(true);
|
|
2246
|
+
setActiveIndex(0);
|
|
2247
|
+
setCaretRect(getCaretRect(ta, caret));
|
|
2248
|
+
}
|
|
2249
|
+
}, [value, trigger, openOnEmptyTrigger, isOpen, textareaRef]);
|
|
2250
|
+
const commit = useCallback3(
|
|
2251
|
+
(cmd) => {
|
|
2252
|
+
const ta = textareaRef.current;
|
|
2253
|
+
if (!ta || triggerIndex == null) return;
|
|
2254
|
+
const insertText = typeof cmd.insert === "function" ? cmd.insert(query) : cmd.insert;
|
|
2255
|
+
const caret = ta.selectionStart ?? value.length;
|
|
2256
|
+
const before = value.slice(0, triggerIndex);
|
|
2257
|
+
const after = value.slice(caret);
|
|
2258
|
+
const next = `${before}${insertText}${after}`;
|
|
2259
|
+
dismissedAtRef.current = {
|
|
2260
|
+
value,
|
|
2261
|
+
caret
|
|
2262
|
+
};
|
|
2263
|
+
onChange(next);
|
|
2264
|
+
setIsOpen(false);
|
|
2265
|
+
setTriggerIndex(null);
|
|
2266
|
+
requestAnimationFrame(() => {
|
|
2267
|
+
const pos = before.length + insertText.length;
|
|
2268
|
+
ta.focus();
|
|
2269
|
+
ta.setSelectionRange(pos, pos);
|
|
2270
|
+
});
|
|
2271
|
+
},
|
|
2272
|
+
[textareaRef, triggerIndex, query, value, onChange]
|
|
2273
|
+
);
|
|
2274
|
+
const dismiss = useCallback3(() => {
|
|
2275
|
+
const ta = textareaRef.current;
|
|
2276
|
+
dismissedAtRef.current = {
|
|
2277
|
+
value,
|
|
2278
|
+
caret: ta?.selectionStart ?? value.length
|
|
2279
|
+
};
|
|
2280
|
+
setIsOpen(false);
|
|
2281
|
+
setTriggerIndex(null);
|
|
2282
|
+
}, [textareaRef, value]);
|
|
2283
|
+
const onKeyDown = useCallback3(
|
|
2284
|
+
(e) => {
|
|
2285
|
+
if (!isOpen) return false;
|
|
2286
|
+
if (e.key === "ArrowDown") {
|
|
2287
|
+
e.preventDefault();
|
|
2288
|
+
setActiveIndex((i) => Math.min(items.length - 1, i + 1));
|
|
2289
|
+
return true;
|
|
2290
|
+
}
|
|
2291
|
+
if (e.key === "ArrowUp") {
|
|
2292
|
+
e.preventDefault();
|
|
2293
|
+
setActiveIndex((i) => Math.max(0, i - 1));
|
|
2294
|
+
return true;
|
|
2295
|
+
}
|
|
2296
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
2297
|
+
const pick2 = items[activeIndex];
|
|
2298
|
+
if (pick2) {
|
|
2299
|
+
e.preventDefault();
|
|
2300
|
+
commit(pick2);
|
|
2301
|
+
return true;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
if (e.key === "Escape") {
|
|
2305
|
+
e.preventDefault();
|
|
2306
|
+
dismiss();
|
|
2307
|
+
return true;
|
|
2308
|
+
}
|
|
2309
|
+
return false;
|
|
2310
|
+
},
|
|
2311
|
+
[isOpen, items, activeIndex, commit, dismiss]
|
|
2312
|
+
);
|
|
2313
|
+
return {
|
|
2314
|
+
isOpen,
|
|
2315
|
+
query,
|
|
2316
|
+
activeIndex,
|
|
2317
|
+
items,
|
|
2318
|
+
onKeyDown,
|
|
2319
|
+
dismiss,
|
|
2320
|
+
commit,
|
|
2321
|
+
caretRect
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
// src/hooks/useTextareaSelection.ts
|
|
2326
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useState as useState12 } from "react";
|
|
2327
|
+
function getSelectionRect(textarea, start, end) {
|
|
2328
|
+
if (typeof document === "undefined") return null;
|
|
2329
|
+
if (start === end) return null;
|
|
2330
|
+
const mirror = document.createElement("div");
|
|
2331
|
+
const styles = window.getComputedStyle(textarea);
|
|
2332
|
+
for (const prop of [
|
|
2333
|
+
"boxSizing",
|
|
2334
|
+
"width",
|
|
2335
|
+
"fontFamily",
|
|
2336
|
+
"fontSize",
|
|
2337
|
+
"fontWeight",
|
|
2338
|
+
"fontStyle",
|
|
2339
|
+
"letterSpacing",
|
|
2340
|
+
"lineHeight",
|
|
2341
|
+
"paddingTop",
|
|
2342
|
+
"paddingRight",
|
|
2343
|
+
"paddingBottom",
|
|
2344
|
+
"paddingLeft",
|
|
2345
|
+
"borderTopWidth",
|
|
2346
|
+
"borderRightWidth",
|
|
2347
|
+
"borderBottomWidth",
|
|
2348
|
+
"borderLeftWidth",
|
|
2349
|
+
"textTransform",
|
|
2350
|
+
"wordSpacing",
|
|
2351
|
+
"tabSize",
|
|
2352
|
+
"whiteSpace"
|
|
2353
|
+
]) {
|
|
2354
|
+
mirror.style[prop] = styles[prop];
|
|
2355
|
+
}
|
|
2356
|
+
mirror.style.position = "absolute";
|
|
2357
|
+
mirror.style.visibility = "hidden";
|
|
2358
|
+
mirror.style.overflow = "hidden";
|
|
2359
|
+
mirror.style.top = "0";
|
|
2360
|
+
mirror.style.left = "0";
|
|
2361
|
+
mirror.style.whiteSpace = "pre-wrap";
|
|
2362
|
+
mirror.style.wordWrap = "break-word";
|
|
2363
|
+
const pre = document.createTextNode(textarea.value.slice(0, start));
|
|
2364
|
+
const range = document.createElement("span");
|
|
2365
|
+
range.textContent = textarea.value.slice(start, end) || "\u200B";
|
|
2366
|
+
const post = document.createTextNode(textarea.value.slice(end));
|
|
2367
|
+
mirror.appendChild(pre);
|
|
2368
|
+
mirror.appendChild(range);
|
|
2369
|
+
mirror.appendChild(post);
|
|
2370
|
+
document.body.appendChild(mirror);
|
|
2371
|
+
const taRect = textarea.getBoundingClientRect();
|
|
2372
|
+
const rangeRect = range.getBoundingClientRect();
|
|
2373
|
+
const mirrorRect = mirror.getBoundingClientRect();
|
|
2374
|
+
const out = new DOMRect(
|
|
2375
|
+
taRect.left + (rangeRect.left - mirrorRect.left) - textarea.scrollLeft,
|
|
2376
|
+
taRect.top + (rangeRect.top - mirrorRect.top) - textarea.scrollTop,
|
|
2377
|
+
rangeRect.width,
|
|
2378
|
+
rangeRect.height
|
|
2379
|
+
);
|
|
2380
|
+
document.body.removeChild(mirror);
|
|
2381
|
+
return out;
|
|
2382
|
+
}
|
|
2383
|
+
function useTextareaSelection({
|
|
2384
|
+
textareaRef,
|
|
2385
|
+
value,
|
|
2386
|
+
onChange
|
|
2387
|
+
}) {
|
|
2388
|
+
const [start, setStart] = useState12(0);
|
|
2389
|
+
const [end, setEnd] = useState12(0);
|
|
2390
|
+
const [rect, setRect] = useState12(null);
|
|
2391
|
+
useEffect6(() => {
|
|
2392
|
+
if (typeof document === "undefined") return;
|
|
2393
|
+
const handler = () => {
|
|
2394
|
+
const ta = textareaRef.current;
|
|
2395
|
+
if (!ta || document.activeElement !== ta) {
|
|
2396
|
+
setStart(0);
|
|
2397
|
+
setEnd(0);
|
|
2398
|
+
setRect(null);
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
const s = ta.selectionStart ?? 0;
|
|
2402
|
+
const e = ta.selectionEnd ?? 0;
|
|
2403
|
+
setStart(s);
|
|
2404
|
+
setEnd(e);
|
|
2405
|
+
setRect(s !== e ? getSelectionRect(ta, s, e) : null);
|
|
2406
|
+
};
|
|
2407
|
+
document.addEventListener("selectionchange", handler);
|
|
2408
|
+
return () => document.removeEventListener("selectionchange", handler);
|
|
2409
|
+
}, [textareaRef]);
|
|
2410
|
+
const active = start !== end;
|
|
2411
|
+
const text = active ? value.slice(start, end) : "";
|
|
2412
|
+
const writeToClipboard = useCallback4(async (str) => {
|
|
2413
|
+
try {
|
|
2414
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
2415
|
+
await navigator.clipboard.writeText(str);
|
|
2416
|
+
return true;
|
|
2417
|
+
}
|
|
2418
|
+
} catch {
|
|
2419
|
+
}
|
|
2420
|
+
try {
|
|
2421
|
+
const tmp = document.createElement("textarea");
|
|
2422
|
+
tmp.value = str;
|
|
2423
|
+
tmp.style.position = "fixed";
|
|
2424
|
+
tmp.style.left = "-9999px";
|
|
2425
|
+
document.body.appendChild(tmp);
|
|
2426
|
+
tmp.select();
|
|
2427
|
+
const ok = document.execCommand("copy");
|
|
2428
|
+
document.body.removeChild(tmp);
|
|
2429
|
+
return ok;
|
|
2430
|
+
} catch {
|
|
2431
|
+
return false;
|
|
2432
|
+
}
|
|
2433
|
+
}, []);
|
|
2434
|
+
const copy = useCallback4(async () => {
|
|
2435
|
+
if (!active) return false;
|
|
2436
|
+
return writeToClipboard(text);
|
|
2437
|
+
}, [active, text, writeToClipboard]);
|
|
2438
|
+
const replace = useCallback4(
|
|
2439
|
+
(str) => {
|
|
2440
|
+
const ta = textareaRef.current;
|
|
2441
|
+
if (!ta) return;
|
|
2442
|
+
const next = value.slice(0, start) + str + value.slice(end);
|
|
2443
|
+
onChange(next);
|
|
2444
|
+
requestAnimationFrame(() => {
|
|
2445
|
+
ta.focus();
|
|
2446
|
+
const caret = start + str.length;
|
|
2447
|
+
ta.setSelectionRange(caret, caret);
|
|
2448
|
+
});
|
|
2449
|
+
},
|
|
2450
|
+
[textareaRef, value, start, end, onChange]
|
|
2451
|
+
);
|
|
2452
|
+
const cut = useCallback4(async () => {
|
|
2453
|
+
if (!active) return false;
|
|
2454
|
+
const ok = await writeToClipboard(text);
|
|
2455
|
+
if (ok) replace("");
|
|
2456
|
+
return ok;
|
|
2457
|
+
}, [active, text, writeToClipboard, replace]);
|
|
2458
|
+
const wrap = useCallback4(
|
|
2459
|
+
(open, close) => {
|
|
2460
|
+
const ta = textareaRef.current;
|
|
2461
|
+
if (!ta) return;
|
|
2462
|
+
const closing = close ?? open;
|
|
2463
|
+
const before = value.slice(0, start);
|
|
2464
|
+
const sel = value.slice(start, end);
|
|
2465
|
+
const after = value.slice(end);
|
|
2466
|
+
const next = `${before}${open}${sel}${closing}${after}`;
|
|
2467
|
+
onChange(next);
|
|
2468
|
+
requestAnimationFrame(() => {
|
|
2469
|
+
ta.focus();
|
|
2470
|
+
const newStart = start;
|
|
2471
|
+
const newEnd = end + open.length + closing.length;
|
|
2472
|
+
ta.setSelectionRange(newStart, newEnd);
|
|
2473
|
+
});
|
|
2474
|
+
},
|
|
2475
|
+
[textareaRef, value, start, end, onChange]
|
|
2476
|
+
);
|
|
2477
|
+
return {
|
|
2478
|
+
active,
|
|
2479
|
+
text,
|
|
2480
|
+
start,
|
|
2481
|
+
end,
|
|
2482
|
+
rect,
|
|
2483
|
+
copy,
|
|
2484
|
+
cut,
|
|
2485
|
+
wrap,
|
|
2486
|
+
replace
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
// src/hooks/useTextareaTools.tsx
|
|
2491
|
+
import {
|
|
2492
|
+
CodeIcon,
|
|
2493
|
+
HeadingIcon,
|
|
2494
|
+
ListBulletedIcon,
|
|
2495
|
+
ListNumberedIcon,
|
|
2496
|
+
QuotesIcon,
|
|
2497
|
+
RedoIcon,
|
|
2498
|
+
TextBoldIcon,
|
|
2499
|
+
TextItalicIcon,
|
|
2500
|
+
TextLinkIcon,
|
|
2501
|
+
TextStrikethroughIcon,
|
|
2502
|
+
UndoIcon
|
|
2503
|
+
} from "@octaviaflow/icons";
|
|
2504
|
+
import { useCallback as useCallback5, useMemo as useMemo3, useRef as useRef9 } from "react";
|
|
2505
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2506
|
+
function useTextareaTools({
|
|
2507
|
+
textareaRef,
|
|
2508
|
+
value,
|
|
2509
|
+
onChange,
|
|
2510
|
+
tools
|
|
2511
|
+
}) {
|
|
2512
|
+
const valueRef = useRef9(value);
|
|
2513
|
+
valueRef.current = value;
|
|
2514
|
+
const helpers = useMemo3(() => {
|
|
2515
|
+
const getTa = () => textareaRef.current;
|
|
2516
|
+
const getSelection = () => {
|
|
2517
|
+
const ta = getTa();
|
|
2518
|
+
const s = ta?.selectionStart ?? 0;
|
|
2519
|
+
const e = ta?.selectionEnd ?? 0;
|
|
2520
|
+
return {
|
|
2521
|
+
text: valueRef.current.slice(s, e),
|
|
2522
|
+
start: s,
|
|
2523
|
+
end: e,
|
|
2524
|
+
active: s !== e
|
|
2525
|
+
};
|
|
2526
|
+
};
|
|
2527
|
+
const setValue = (next) => onChange(next);
|
|
2528
|
+
const replace = (text) => {
|
|
2529
|
+
const ta = getTa();
|
|
2530
|
+
if (!ta) return;
|
|
2531
|
+
const { start, end } = getSelection();
|
|
2532
|
+
const next = valueRef.current.slice(0, start) + text + valueRef.current.slice(end);
|
|
2533
|
+
onChange(next);
|
|
2534
|
+
requestAnimationFrame(() => {
|
|
2535
|
+
ta.focus();
|
|
2536
|
+
const caret = start + text.length;
|
|
2537
|
+
ta.setSelectionRange(caret, caret);
|
|
2538
|
+
});
|
|
2539
|
+
};
|
|
2540
|
+
const insert = (text) => replace(text);
|
|
2541
|
+
const wrap = (open, close) => {
|
|
2542
|
+
const ta = getTa();
|
|
2543
|
+
if (!ta) return;
|
|
2544
|
+
const closing = close ?? open;
|
|
2545
|
+
const { start, end } = getSelection();
|
|
2546
|
+
const sel = valueRef.current.slice(start, end);
|
|
2547
|
+
const next = valueRef.current.slice(0, start) + open + sel + closing + valueRef.current.slice(end);
|
|
2548
|
+
onChange(next);
|
|
2549
|
+
requestAnimationFrame(() => {
|
|
2550
|
+
ta.focus();
|
|
2551
|
+
if (start === end) {
|
|
2552
|
+
const caret = start + open.length;
|
|
2553
|
+
ta.setSelectionRange(caret, caret);
|
|
2554
|
+
} else {
|
|
2555
|
+
ta.setSelectionRange(start, end + open.length + closing.length);
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
};
|
|
2559
|
+
const prependLines = (prefix) => {
|
|
2560
|
+
const ta = getTa();
|
|
2561
|
+
if (!ta) return;
|
|
2562
|
+
const { start, end } = getSelection();
|
|
2563
|
+
const v = valueRef.current;
|
|
2564
|
+
const lineStart = v.lastIndexOf("\n", start - 1) + 1;
|
|
2565
|
+
const lineEnd = (() => {
|
|
2566
|
+
const idx = v.indexOf("\n", end);
|
|
2567
|
+
return idx === -1 ? v.length : idx;
|
|
2568
|
+
})();
|
|
2569
|
+
const block = v.slice(lineStart, lineEnd);
|
|
2570
|
+
const updated = block.split("\n").map((line) => `${prefix}${line}`).join("\n");
|
|
2571
|
+
const next = v.slice(0, lineStart) + updated + v.slice(lineEnd);
|
|
2572
|
+
onChange(next);
|
|
2573
|
+
requestAnimationFrame(() => {
|
|
2574
|
+
ta.focus();
|
|
2575
|
+
ta.setSelectionRange(lineStart, lineStart + updated.length);
|
|
2576
|
+
});
|
|
2577
|
+
};
|
|
2578
|
+
const undo = () => {
|
|
2579
|
+
try {
|
|
2580
|
+
getTa()?.focus();
|
|
2581
|
+
document.execCommand("undo");
|
|
2582
|
+
} catch {
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
const redo = () => {
|
|
2586
|
+
try {
|
|
2587
|
+
getTa()?.focus();
|
|
2588
|
+
document.execCommand("redo");
|
|
2589
|
+
} catch {
|
|
2590
|
+
}
|
|
2591
|
+
};
|
|
2592
|
+
return {
|
|
2593
|
+
get value() {
|
|
2594
|
+
return valueRef.current;
|
|
2595
|
+
},
|
|
2596
|
+
get selection() {
|
|
2597
|
+
return getSelection();
|
|
2598
|
+
},
|
|
2599
|
+
setValue,
|
|
2600
|
+
replace,
|
|
2601
|
+
insert,
|
|
2602
|
+
wrap,
|
|
2603
|
+
prependLines,
|
|
2604
|
+
undo,
|
|
2605
|
+
redo,
|
|
2606
|
+
getTextarea: getTa
|
|
2607
|
+
};
|
|
2608
|
+
}, [textareaRef, onChange]);
|
|
2609
|
+
const visibleTools = useMemo3(
|
|
2610
|
+
() => tools.filter((t) => t.isVisible ? t.isVisible(helpers) : true),
|
|
2611
|
+
[tools, helpers]
|
|
2612
|
+
);
|
|
2613
|
+
const runTool = useCallback5(
|
|
2614
|
+
async (id) => {
|
|
2615
|
+
const tool = tools.find((t) => t.id === id);
|
|
2616
|
+
if (!tool || tool.kind === "divider") return;
|
|
2617
|
+
await tool.onAction?.(helpers);
|
|
2618
|
+
},
|
|
2619
|
+
[tools, helpers]
|
|
2620
|
+
);
|
|
2621
|
+
return { tools: visibleTools, runTool, helpers };
|
|
2622
|
+
}
|
|
2623
|
+
var wrapTool = (id, open, close, label, icon, title) => ({
|
|
2624
|
+
id,
|
|
2625
|
+
label,
|
|
2626
|
+
icon,
|
|
2627
|
+
title,
|
|
2628
|
+
onAction: (h) => h.wrap(open, close)
|
|
2629
|
+
});
|
|
2630
|
+
var prependLineTool = (id, prefix, label, icon, title) => ({
|
|
2631
|
+
id,
|
|
2632
|
+
label,
|
|
2633
|
+
icon,
|
|
2634
|
+
title,
|
|
2635
|
+
onAction: (h) => h.prependLines(prefix)
|
|
2636
|
+
});
|
|
2637
|
+
var textareaTools = {
|
|
2638
|
+
bold: () => wrapTool("bold", "**", "**", "Bold", /* @__PURE__ */ jsx20(TextBoldIcon, {}), "Bold (\u2318B)"),
|
|
2639
|
+
italic: () => wrapTool("italic", "*", "*", "Italic", /* @__PURE__ */ jsx20(TextItalicIcon, {}), "Italic (\u2318I)"),
|
|
2640
|
+
strikethrough: () => wrapTool("strike", "~~", "~~", "Strikethrough", /* @__PURE__ */ jsx20(TextStrikethroughIcon, {}), "Strikethrough"),
|
|
2641
|
+
code: () => wrapTool("code", "`", "`", "Code", /* @__PURE__ */ jsx20(CodeIcon, {}), "Inline code"),
|
|
2642
|
+
codeBlock: () => ({
|
|
2643
|
+
id: "code-block",
|
|
2644
|
+
label: "Code block",
|
|
2645
|
+
icon: /* @__PURE__ */ jsx20(CodeIcon, {}),
|
|
2646
|
+
title: "Code block",
|
|
2647
|
+
onAction: (h) => h.wrap("```\n", "\n```")
|
|
2648
|
+
}),
|
|
2649
|
+
link: () => ({
|
|
2650
|
+
id: "link",
|
|
2651
|
+
label: "Link",
|
|
2652
|
+
icon: /* @__PURE__ */ jsx20(TextLinkIcon, {}),
|
|
2653
|
+
title: "Insert link",
|
|
2654
|
+
onAction: (h) => {
|
|
2655
|
+
const sel = h.selection;
|
|
2656
|
+
const text = sel.active ? sel.text : "link text";
|
|
2657
|
+
h.replace(`[${text}](https://)`);
|
|
2658
|
+
}
|
|
2659
|
+
}),
|
|
2660
|
+
/** Heading. Defaults to H2. Pass a `level` (1–6) to override. */
|
|
2661
|
+
heading: (level = 2) => prependLineTool(
|
|
2662
|
+
`heading-${level}`,
|
|
2663
|
+
`${"#".repeat(level)} `,
|
|
2664
|
+
`H${level}`,
|
|
2665
|
+
/* @__PURE__ */ jsx20(HeadingIcon, {}),
|
|
2666
|
+
`Heading ${level}`
|
|
2667
|
+
),
|
|
2668
|
+
bulletList: () => prependLineTool("ul", "- ", "Bullet list", /* @__PURE__ */ jsx20(ListBulletedIcon, {}), "Bullet list"),
|
|
2669
|
+
numberedList: () => prependLineTool("ol", "1. ", "Numbered list", /* @__PURE__ */ jsx20(ListNumberedIcon, {}), "Numbered list"),
|
|
2670
|
+
quote: () => prependLineTool("quote", "> ", "Quote", /* @__PURE__ */ jsx20(QuotesIcon, {}), "Quote"),
|
|
2671
|
+
undo: () => ({
|
|
2672
|
+
id: "undo",
|
|
2673
|
+
label: "Undo",
|
|
2674
|
+
icon: /* @__PURE__ */ jsx20(UndoIcon, {}),
|
|
2675
|
+
title: "Undo (\u2318Z)",
|
|
2676
|
+
onAction: (h) => h.undo()
|
|
2677
|
+
}),
|
|
2678
|
+
redo: () => ({
|
|
2679
|
+
id: "redo",
|
|
2680
|
+
label: "Redo",
|
|
2681
|
+
icon: /* @__PURE__ */ jsx20(RedoIcon, {}),
|
|
2682
|
+
title: "Redo (\u2318\u21E7Z)",
|
|
2683
|
+
onAction: (h) => h.redo()
|
|
2684
|
+
}),
|
|
2685
|
+
divider: (id = "divider") => ({
|
|
2686
|
+
id: `${id}-${Math.random().toString(36).slice(2, 8)}`,
|
|
2687
|
+
label: "",
|
|
2688
|
+
kind: "divider"
|
|
2689
|
+
})
|
|
2690
|
+
};
|
|
2691
|
+
|
|
2692
|
+
// src/components/Textarea/Textarea.tsx
|
|
2693
|
+
import { CopyIcon, CutIcon } from "@octaviaflow/icons";
|
|
2694
|
+
import {
|
|
2695
|
+
forwardRef as forwardRef20,
|
|
2696
|
+
useEffect as useEffect7,
|
|
2697
|
+
useId as useId5,
|
|
2698
|
+
useRef as useRef10,
|
|
2699
|
+
useState as useState13
|
|
2700
|
+
} from "react";
|
|
2701
|
+
import { useTextField } from "react-aria";
|
|
2702
|
+
import { createPortal } from "react-dom";
|
|
2703
|
+
import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2704
|
+
var Textarea = forwardRef20(function Textarea2({
|
|
2705
|
+
label,
|
|
2706
|
+
error = false,
|
|
2707
|
+
errorMessage,
|
|
2708
|
+
helperText,
|
|
2709
|
+
resize = "vertical",
|
|
2710
|
+
autoResize = false,
|
|
2711
|
+
minRows,
|
|
2712
|
+
maxRows,
|
|
2713
|
+
maxHeight,
|
|
2714
|
+
maxWidth,
|
|
2715
|
+
minHeight,
|
|
2716
|
+
minWidth,
|
|
2717
|
+
maxLength,
|
|
2718
|
+
size = "md",
|
|
2719
|
+
rows = 3,
|
|
2720
|
+
disabled = false,
|
|
2721
|
+
className,
|
|
2722
|
+
style: consumerStyle,
|
|
2723
|
+
defaultValue,
|
|
2724
|
+
value,
|
|
2725
|
+
onChange,
|
|
2726
|
+
id: providedId,
|
|
2727
|
+
commands,
|
|
2728
|
+
commandTrigger = "/",
|
|
2729
|
+
selectionToolbar = false,
|
|
2730
|
+
selectionActions,
|
|
2731
|
+
tools,
|
|
2732
|
+
toolbarPosition = "top",
|
|
2733
|
+
...props
|
|
2734
|
+
}, forwardedRef) {
|
|
2735
|
+
const innerRef = useRef10(null);
|
|
2736
|
+
const setRef = (node) => {
|
|
2737
|
+
innerRef.current = node;
|
|
2738
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
2739
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
2740
|
+
};
|
|
2741
|
+
const reactId = useId5();
|
|
2742
|
+
const baseId = providedId ?? `ods-textarea-${reactId}`;
|
|
2743
|
+
const hintId = error && errorMessage || helperText ? `${baseId}-hint` : void 0;
|
|
2744
|
+
const [charCount, setCharCount] = useState13(() => String(value ?? defaultValue ?? "").length);
|
|
2745
|
+
const ariaNameProps = resolveAccessibleName({
|
|
2746
|
+
label: typeof label === "string" ? label : void 0,
|
|
2747
|
+
ariaLabel: props["aria-label"],
|
|
2748
|
+
ariaLabelledby: props["aria-labelledby"],
|
|
2749
|
+
componentName: "Textarea"
|
|
2750
|
+
});
|
|
2751
|
+
const { labelProps, inputProps } = useTextField(
|
|
2752
|
+
{
|
|
2753
|
+
label: typeof label === "string" ? label : void 0,
|
|
2754
|
+
...ariaNameProps,
|
|
2755
|
+
isDisabled: disabled,
|
|
2756
|
+
errorMessage: typeof errorMessage === "string" ? errorMessage : void 0,
|
|
2757
|
+
validationState: error ? "invalid" : void 0,
|
|
2758
|
+
inputElementType: "textarea",
|
|
2759
|
+
value,
|
|
2760
|
+
defaultValue
|
|
2761
|
+
},
|
|
2762
|
+
innerRef
|
|
2763
|
+
);
|
|
2764
|
+
const describedBy = [props["aria-describedby"], hintId].filter(Boolean).join(" ") || void 0;
|
|
2765
|
+
const handleChange = (e) => {
|
|
2766
|
+
setCharCount(e.target.value.length);
|
|
2767
|
+
onChange?.(e);
|
|
2768
|
+
};
|
|
2769
|
+
const [liveValue, setLiveValue] = useState13(String(value ?? defaultValue ?? ""));
|
|
2770
|
+
useEffect7(() => {
|
|
2771
|
+
if (value != null) setLiveValue(String(value));
|
|
2772
|
+
}, [value]);
|
|
2773
|
+
const handleChangeWithMirror = (e) => {
|
|
2774
|
+
setLiveValue(e.target.value);
|
|
2775
|
+
handleChange(e);
|
|
2776
|
+
};
|
|
2777
|
+
const setLiveAndCommit = (next) => {
|
|
2778
|
+
setLiveValue(next);
|
|
2779
|
+
if (innerRef.current) innerRef.current.value = next;
|
|
2780
|
+
onChange?.({
|
|
2781
|
+
target: innerRef.current,
|
|
2782
|
+
currentTarget: innerRef.current
|
|
2783
|
+
});
|
|
2784
|
+
setCharCount(next.length);
|
|
2785
|
+
};
|
|
2786
|
+
const cmdPalette = useTextareaCommands({
|
|
2787
|
+
textareaRef: innerRef,
|
|
2788
|
+
value: liveValue,
|
|
2789
|
+
onChange: setLiveAndCommit,
|
|
2790
|
+
commands: commands ?? [],
|
|
2791
|
+
trigger: commandTrigger
|
|
2792
|
+
});
|
|
2793
|
+
const cmdEnabled = (commands?.length ?? 0) > 0;
|
|
2794
|
+
const sel = useTextareaSelection({
|
|
2795
|
+
textareaRef: innerRef,
|
|
2796
|
+
value: liveValue,
|
|
2797
|
+
onChange: setLiveAndCommit
|
|
2798
|
+
});
|
|
2799
|
+
const toolbar = useTextareaTools({
|
|
2800
|
+
textareaRef: innerRef,
|
|
2801
|
+
value: liveValue,
|
|
2802
|
+
onChange: setLiveAndCommit,
|
|
2803
|
+
tools: tools ?? []
|
|
2804
|
+
});
|
|
2805
|
+
const toolbarEnabled = (tools?.length ?? 0) > 0;
|
|
2806
|
+
const handleKeyDownWithCommands = (e) => {
|
|
2807
|
+
if (cmdEnabled) {
|
|
2808
|
+
const consumed = cmdPalette.onKeyDown(e);
|
|
2809
|
+
if (consumed) return;
|
|
2810
|
+
}
|
|
2811
|
+
props.onKeyDown?.(e);
|
|
2812
|
+
};
|
|
2813
|
+
useEffect7(() => {
|
|
2814
|
+
if (!autoResize) return;
|
|
2815
|
+
const el = innerRef.current;
|
|
2816
|
+
if (!el) return;
|
|
2817
|
+
const computed = window.getComputedStyle(el);
|
|
2818
|
+
const fontSize = parseFloat(computed.fontSize) || 16;
|
|
2819
|
+
const lhRaw = computed.lineHeight;
|
|
2820
|
+
const lh = lhRaw === "normal" ? fontSize * 1.2 : lhRaw.endsWith("px") ? parseFloat(lhRaw) : parseFloat(lhRaw) * fontSize;
|
|
2821
|
+
const padding = parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom);
|
|
2822
|
+
const rowCap = maxRows != null && Number.isFinite(maxRows) ? lh * maxRows + padding : Number.POSITIVE_INFINITY;
|
|
2823
|
+
const pixelCap = typeof maxHeight === "number" ? maxHeight : Number.POSITIVE_INFINITY;
|
|
2824
|
+
const effectiveMax = Math.min(rowCap, pixelCap);
|
|
2825
|
+
const rowFloor = lh * (minRows ?? rows) + padding;
|
|
2826
|
+
el.style.height = "auto";
|
|
2827
|
+
const target = Math.max(rowFloor, Math.min(effectiveMax, el.scrollHeight));
|
|
2828
|
+
el.style.height = `${target}px`;
|
|
2829
|
+
el.style.overflowY = el.scrollHeight > effectiveMax ? "auto" : "hidden";
|
|
2830
|
+
}, [autoResize, value, defaultValue, minRows, maxRows, maxHeight, rows]);
|
|
2831
|
+
const resolvedResize = typeof resize === "boolean" ? resize ? "vertical" : "none" : resize;
|
|
2832
|
+
const toCss = (v) => v == null ? void 0 : typeof v === "number" ? `${v}px` : v;
|
|
2833
|
+
const fieldStyle = {
|
|
2834
|
+
maxHeight: toCss(maxHeight),
|
|
2835
|
+
maxWidth: toCss(maxWidth),
|
|
2836
|
+
minHeight: toCss(minHeight),
|
|
2837
|
+
minWidth: toCss(minWidth),
|
|
2838
|
+
resize: resolvedResize
|
|
2839
|
+
};
|
|
2840
|
+
return /* @__PURE__ */ jsxs19(
|
|
2841
|
+
"div",
|
|
2842
|
+
{
|
|
2843
|
+
className: cn(
|
|
2844
|
+
"ods-textarea",
|
|
2845
|
+
`ods-textarea--${size}`,
|
|
2846
|
+
`ods-textarea--resize-${resolvedResize}`,
|
|
2847
|
+
autoResize && "ods-textarea--auto-resize",
|
|
2848
|
+
error && "ods-textarea--error",
|
|
2849
|
+
disabled && "ods-textarea--disabled",
|
|
2850
|
+
className
|
|
2851
|
+
),
|
|
2852
|
+
style: consumerStyle,
|
|
2853
|
+
children: [
|
|
2854
|
+
label && /* @__PURE__ */ jsx21("label", { ...labelProps, htmlFor: baseId, className: "ods-textarea__label", children: label }),
|
|
2855
|
+
toolbarEnabled && toolbarPosition === "top" && /* @__PURE__ */ jsx21(TextareaToolbar, { tools: toolbar.tools, onRun: toolbar.runTool }),
|
|
2856
|
+
/* @__PURE__ */ jsxs19("div", { className: "ods-textarea__wrapper", children: [
|
|
2857
|
+
/* @__PURE__ */ jsx21(
|
|
2858
|
+
"textarea",
|
|
2859
|
+
{
|
|
2860
|
+
...props,
|
|
2861
|
+
...inputProps,
|
|
2862
|
+
ref: setRef,
|
|
2863
|
+
id: baseId,
|
|
2864
|
+
rows: autoResize ? minRows ?? rows : rows,
|
|
2865
|
+
disabled,
|
|
2866
|
+
maxLength,
|
|
2867
|
+
defaultValue,
|
|
2868
|
+
value,
|
|
2869
|
+
onChange: handleChangeWithMirror,
|
|
2870
|
+
onKeyDown: handleKeyDownWithCommands,
|
|
2871
|
+
className: "ods-textarea__field",
|
|
2872
|
+
style: fieldStyle,
|
|
2873
|
+
"aria-invalid": error || void 0,
|
|
2874
|
+
"aria-describedby": describedBy,
|
|
2875
|
+
"aria-autocomplete": cmdEnabled ? "list" : void 0,
|
|
2876
|
+
"aria-expanded": cmdEnabled ? cmdPalette.isOpen : void 0,
|
|
2877
|
+
"aria-controls": cmdEnabled && cmdPalette.isOpen ? `${baseId}-cmd-list` : void 0,
|
|
2878
|
+
"aria-activedescendant": cmdEnabled && cmdPalette.isOpen && cmdPalette.items[cmdPalette.activeIndex] ? `${baseId}-cmd-${cmdPalette.items[cmdPalette.activeIndex].id}` : void 0
|
|
2879
|
+
}
|
|
2880
|
+
),
|
|
2881
|
+
cmdEnabled && cmdPalette.isOpen && cmdPalette.items.length > 0 && typeof document !== "undefined" && createPortal(
|
|
2882
|
+
/* @__PURE__ */ jsx21(
|
|
2883
|
+
"ul",
|
|
2884
|
+
{
|
|
2885
|
+
id: `${baseId}-cmd-list`,
|
|
2886
|
+
role: "listbox",
|
|
2887
|
+
"aria-label": "Inline commands",
|
|
2888
|
+
className: "ods-textarea__cmd-popover",
|
|
2889
|
+
style: {
|
|
2890
|
+
position: "fixed",
|
|
2891
|
+
top: (cmdPalette.caretRect?.bottom ?? 0) + 6,
|
|
2892
|
+
left: cmdPalette.caretRect?.left ?? 0
|
|
2893
|
+
},
|
|
2894
|
+
children: cmdPalette.items.map((c, i) => /* @__PURE__ */ jsxs19(
|
|
2895
|
+
"li",
|
|
2896
|
+
{
|
|
2897
|
+
id: `${baseId}-cmd-${c.id}`,
|
|
2898
|
+
role: "option",
|
|
2899
|
+
"aria-selected": i === cmdPalette.activeIndex,
|
|
2900
|
+
className: cn(
|
|
2901
|
+
"ods-textarea__cmd-item",
|
|
2902
|
+
i === cmdPalette.activeIndex && "ods-textarea__cmd-item--active"
|
|
2903
|
+
),
|
|
2904
|
+
onMouseDown: (e) => {
|
|
2905
|
+
e.preventDefault();
|
|
2906
|
+
cmdPalette.commit(c);
|
|
2907
|
+
},
|
|
2908
|
+
onMouseEnter: () => {
|
|
2909
|
+
},
|
|
2910
|
+
children: [
|
|
2911
|
+
c.icon && /* @__PURE__ */ jsx21("span", { className: "ods-textarea__cmd-icon", children: c.icon }),
|
|
2912
|
+
/* @__PURE__ */ jsxs19("span", { className: "ods-textarea__cmd-text", children: [
|
|
2913
|
+
/* @__PURE__ */ jsx21("span", { className: "ods-textarea__cmd-label", children: c.label }),
|
|
2914
|
+
c.description && /* @__PURE__ */ jsx21("span", { className: "ods-textarea__cmd-desc", children: c.description })
|
|
2915
|
+
] })
|
|
2916
|
+
]
|
|
2917
|
+
},
|
|
2918
|
+
c.id
|
|
2919
|
+
))
|
|
2920
|
+
}
|
|
2921
|
+
),
|
|
2922
|
+
document.body
|
|
2923
|
+
),
|
|
2924
|
+
selectionToolbar && sel.active && sel.rect && typeof document !== "undefined" && createPortal(
|
|
2925
|
+
/* @__PURE__ */ jsxs19(
|
|
2926
|
+
"div",
|
|
2927
|
+
{
|
|
2928
|
+
role: "toolbar",
|
|
2929
|
+
"aria-label": "Selection actions",
|
|
2930
|
+
className: "ods-textarea__sel-toolbar",
|
|
2931
|
+
style: {
|
|
2932
|
+
position: "fixed",
|
|
2933
|
+
top: sel.rect.top - 36,
|
|
2934
|
+
left: sel.rect.left
|
|
2935
|
+
},
|
|
2936
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2937
|
+
children: [
|
|
2938
|
+
/* @__PURE__ */ jsx21(
|
|
2939
|
+
"button",
|
|
2940
|
+
{
|
|
2941
|
+
type: "button",
|
|
2942
|
+
className: "ods-textarea__sel-btn",
|
|
2943
|
+
onClick: () => sel.copy(),
|
|
2944
|
+
"aria-label": "Copy selection",
|
|
2945
|
+
title: "Copy",
|
|
2946
|
+
children: /* @__PURE__ */ jsx21(CopyIcon, { size: "xs" })
|
|
2947
|
+
}
|
|
2948
|
+
),
|
|
2949
|
+
/* @__PURE__ */ jsx21(
|
|
2950
|
+
"button",
|
|
2951
|
+
{
|
|
2952
|
+
type: "button",
|
|
2953
|
+
className: "ods-textarea__sel-btn",
|
|
2954
|
+
onClick: () => sel.cut(),
|
|
2955
|
+
"aria-label": "Cut selection",
|
|
2956
|
+
title: "Cut",
|
|
2957
|
+
children: /* @__PURE__ */ jsx21(CutIcon, { size: "xs" })
|
|
2958
|
+
}
|
|
2959
|
+
),
|
|
2960
|
+
selectionActions?.map((a) => /* @__PURE__ */ jsxs19(
|
|
2961
|
+
"button",
|
|
2962
|
+
{
|
|
2963
|
+
type: "button",
|
|
2964
|
+
className: "ods-textarea__sel-btn",
|
|
2965
|
+
onClick: () => a.onAction(sel.text, {
|
|
2966
|
+
replace: sel.replace,
|
|
2967
|
+
wrap: sel.wrap,
|
|
2968
|
+
copy: sel.copy,
|
|
2969
|
+
cut: sel.cut
|
|
2970
|
+
}),
|
|
2971
|
+
title: typeof a.label === "string" ? a.label : void 0,
|
|
2972
|
+
children: [
|
|
2973
|
+
a.icon,
|
|
2974
|
+
a.label && /* @__PURE__ */ jsx21("span", { className: "ods-textarea__sel-btn-label", children: a.label })
|
|
2975
|
+
]
|
|
2976
|
+
},
|
|
2977
|
+
a.id
|
|
2978
|
+
))
|
|
2979
|
+
]
|
|
2980
|
+
}
|
|
2981
|
+
),
|
|
2982
|
+
document.body
|
|
2983
|
+
),
|
|
2984
|
+
maxLength != null && /* @__PURE__ */ jsxs19(
|
|
2985
|
+
"span",
|
|
2986
|
+
{
|
|
2987
|
+
className: "ods-textarea__count",
|
|
2988
|
+
"aria-live": charCount > maxLength ? "polite" : "off",
|
|
2989
|
+
children: [
|
|
2990
|
+
charCount,
|
|
2991
|
+
"/",
|
|
2992
|
+
maxLength
|
|
2993
|
+
]
|
|
2994
|
+
}
|
|
2995
|
+
)
|
|
2996
|
+
] }),
|
|
2997
|
+
toolbarEnabled && toolbarPosition === "bottom" && /* @__PURE__ */ jsx21(TextareaToolbar, { tools: toolbar.tools, onRun: toolbar.runTool }),
|
|
2998
|
+
error && errorMessage ? /* @__PURE__ */ jsx21("div", { id: hintId, className: "ods-textarea__error-message", role: "alert", children: errorMessage }) : helperText ? /* @__PURE__ */ jsx21("div", { id: hintId, className: "ods-textarea__hint", children: helperText }) : null
|
|
2999
|
+
]
|
|
3000
|
+
}
|
|
3001
|
+
);
|
|
3002
|
+
});
|
|
3003
|
+
Textarea.displayName = "Textarea";
|
|
3004
|
+
function TextareaToolbar({
|
|
3005
|
+
tools,
|
|
3006
|
+
onRun
|
|
3007
|
+
}) {
|
|
3008
|
+
return /* @__PURE__ */ jsx21(
|
|
3009
|
+
"div",
|
|
3010
|
+
{
|
|
3011
|
+
role: "toolbar",
|
|
3012
|
+
"aria-label": "Formatting",
|
|
3013
|
+
className: "ods-textarea__toolbar",
|
|
3014
|
+
onMouseDown: (e) => {
|
|
3015
|
+
if (e.target.closest(".ods-textarea__toolbar-btn")) {
|
|
3016
|
+
e.preventDefault();
|
|
3017
|
+
}
|
|
3018
|
+
},
|
|
3019
|
+
children: tools.map((t) => {
|
|
3020
|
+
if (t.kind === "divider") {
|
|
3021
|
+
return /* @__PURE__ */ jsx21("span", { className: "ods-textarea__toolbar-divider", "aria-hidden": "true" }, t.id);
|
|
3022
|
+
}
|
|
3023
|
+
return /* @__PURE__ */ jsx21(
|
|
3024
|
+
"button",
|
|
3025
|
+
{
|
|
3026
|
+
type: "button",
|
|
3027
|
+
className: "ods-textarea__toolbar-btn",
|
|
3028
|
+
title: t.title ?? (typeof t.label === "string" ? t.label : void 0),
|
|
3029
|
+
"aria-label": typeof t.label === "string" ? t.label : t.id,
|
|
3030
|
+
onClick: () => onRun(t.id),
|
|
3031
|
+
children: t.icon ? /* @__PURE__ */ jsx21("span", { className: "ods-textarea__toolbar-icon", children: t.icon }) : /* @__PURE__ */ jsx21("span", { className: "ods-textarea__toolbar-text", children: t.label })
|
|
3032
|
+
},
|
|
3033
|
+
t.id
|
|
3034
|
+
);
|
|
3035
|
+
})
|
|
3036
|
+
}
|
|
3037
|
+
);
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
// src/components/TestimonialCard/TestimonialCard.tsx
|
|
3041
|
+
import { QuotesIcon as QuotesIcon2, StarFilledIcon, StarIcon } from "@octaviaflow/icons";
|
|
3042
|
+
import { forwardRef as forwardRef21, useId as useId6 } from "react";
|
|
3043
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3044
|
+
function isAuthorObject(v) {
|
|
3045
|
+
return typeof v === "object" && v !== null && !("type" in v) && // exclude React elements
|
|
3046
|
+
"name" in v;
|
|
3047
|
+
}
|
|
3048
|
+
var TestimonialCard = forwardRef21(
|
|
3049
|
+
function TestimonialCard2({
|
|
3050
|
+
quote,
|
|
3051
|
+
author,
|
|
3052
|
+
role: legacyRole,
|
|
3053
|
+
avatar: legacyAvatar,
|
|
3054
|
+
initial: legacyInitial,
|
|
3055
|
+
rating,
|
|
3056
|
+
logo,
|
|
3057
|
+
size = "md",
|
|
3058
|
+
radius = "md",
|
|
3059
|
+
id: providedId,
|
|
3060
|
+
className,
|
|
3061
|
+
...rest
|
|
3062
|
+
}, ref) {
|
|
3063
|
+
const reactId = useId6();
|
|
3064
|
+
const baseId = providedId ?? `ods-testimonial-${reactId}`;
|
|
3065
|
+
const quoteId = `${baseId}-quote`;
|
|
3066
|
+
const authorId = `${baseId}-author`;
|
|
3067
|
+
const resolved = isAuthorObject(author) ? author : {
|
|
3068
|
+
name: author,
|
|
3069
|
+
role: legacyRole,
|
|
3070
|
+
avatar: legacyAvatar ? void 0 : {
|
|
3071
|
+
initials: typeof legacyInitial === "string" ? legacyInitial : typeof author === "string" ? author.charAt(0).toUpperCase() : void 0
|
|
3072
|
+
}
|
|
3073
|
+
};
|
|
3074
|
+
const renderAvatar = () => {
|
|
3075
|
+
if (!isAuthorObject(author) && legacyAvatar) {
|
|
3076
|
+
return /* @__PURE__ */ jsx22(
|
|
3077
|
+
"span",
|
|
3078
|
+
{
|
|
3079
|
+
className: "ods-testimonial__avatar ods-testimonial__avatar--legacy",
|
|
3080
|
+
"aria-hidden": "true",
|
|
3081
|
+
children: legacyAvatar
|
|
3082
|
+
}
|
|
3083
|
+
);
|
|
3084
|
+
}
|
|
3085
|
+
return /* @__PURE__ */ jsx22(
|
|
3086
|
+
Avatar,
|
|
3087
|
+
{
|
|
3088
|
+
size: size === "sm" ? "xs" : size === "lg" ? "md" : "sm",
|
|
3089
|
+
src: resolved.avatar?.src,
|
|
3090
|
+
initials: resolved.avatar?.initials,
|
|
3091
|
+
seed: resolved.avatar?.seed,
|
|
3092
|
+
palette: resolved.avatar?.palette,
|
|
3093
|
+
alt: resolved.avatar?.alt ?? (typeof resolved.name === "string" ? resolved.name : void 0),
|
|
3094
|
+
className: "ods-testimonial__avatar"
|
|
3095
|
+
}
|
|
3096
|
+
);
|
|
3097
|
+
};
|
|
3098
|
+
return /* @__PURE__ */ jsxs20(
|
|
3099
|
+
Card,
|
|
3100
|
+
{
|
|
3101
|
+
...rest,
|
|
3102
|
+
ref,
|
|
3103
|
+
id: baseId,
|
|
3104
|
+
radius,
|
|
3105
|
+
padding: "none",
|
|
3106
|
+
variant: "subtle",
|
|
3107
|
+
className: cn("ods-testimonial", `ods-testimonial--${size}`, className),
|
|
3108
|
+
"aria-labelledby": authorId,
|
|
3109
|
+
"aria-describedby": quoteId,
|
|
3110
|
+
children: [
|
|
3111
|
+
/* @__PURE__ */ jsxs20("div", { className: "ods-testimonial__head", children: [
|
|
3112
|
+
/* @__PURE__ */ jsx22("span", { className: "ods-testimonial__quote", "aria-hidden": "true", children: /* @__PURE__ */ jsx22(QuotesIcon2, { size: "md" }) }),
|
|
3113
|
+
logo && /* @__PURE__ */ jsx22("span", { className: "ods-testimonial__logo", "aria-hidden": "true", children: logo })
|
|
3114
|
+
] }),
|
|
3115
|
+
/* @__PURE__ */ jsx22("blockquote", { id: quoteId, className: "ods-testimonial__text", children: quote }),
|
|
3116
|
+
typeof rating === "number" && /* @__PURE__ */ jsx22(
|
|
3117
|
+
"div",
|
|
3118
|
+
{
|
|
3119
|
+
className: "ods-testimonial__rating",
|
|
3120
|
+
role: "img",
|
|
3121
|
+
"aria-label": `${rating} out of 5 stars`,
|
|
3122
|
+
children: Array.from({ length: 5 }).map(
|
|
3123
|
+
(_, i) => i < Math.round(rating) ? /* @__PURE__ */ jsx22(
|
|
3124
|
+
StarFilledIcon,
|
|
3125
|
+
{
|
|
3126
|
+
size: "xs",
|
|
3127
|
+
className: "ods-testimonial__star ods-testimonial__star--on"
|
|
3128
|
+
},
|
|
3129
|
+
i
|
|
3130
|
+
) : /* @__PURE__ */ jsx22(StarIcon, { size: "xs", className: "ods-testimonial__star" }, i)
|
|
3131
|
+
)
|
|
3132
|
+
}
|
|
3133
|
+
),
|
|
3134
|
+
/* @__PURE__ */ jsxs20("figcaption", { className: "ods-testimonial__author", id: authorId, children: [
|
|
3135
|
+
renderAvatar(),
|
|
3136
|
+
/* @__PURE__ */ jsxs20("span", { className: "ods-testimonial__author-info", children: [
|
|
3137
|
+
/* @__PURE__ */ jsx22("span", { className: "ods-testimonial__author-name", children: resolved.name }),
|
|
3138
|
+
resolved.role && /* @__PURE__ */ jsx22("span", { className: "ods-testimonial__author-role", children: resolved.role })
|
|
3139
|
+
] })
|
|
3140
|
+
] })
|
|
3141
|
+
]
|
|
3142
|
+
}
|
|
3143
|
+
);
|
|
3144
|
+
}
|
|
3145
|
+
);
|
|
3146
|
+
TestimonialCard.displayName = "TestimonialCard";
|
|
3147
|
+
|
|
3148
|
+
export {
|
|
3149
|
+
TruncatedText,
|
|
3150
|
+
Card,
|
|
3151
|
+
CardHeader,
|
|
3152
|
+
CardBody,
|
|
3153
|
+
CardFooter,
|
|
3154
|
+
CardTitle,
|
|
3155
|
+
CardDescription,
|
|
3156
|
+
AVATAR_PALETTE_SIZE,
|
|
3157
|
+
avatarPaletteIndex,
|
|
3158
|
+
Avatar,
|
|
3159
|
+
AvatarStack,
|
|
3160
|
+
BlogCard,
|
|
3161
|
+
ChatBubble,
|
|
3162
|
+
ChatComposer,
|
|
3163
|
+
ChatLinkPreview,
|
|
3164
|
+
ChatDocPreview,
|
|
3165
|
+
RadioGroup,
|
|
3166
|
+
Radio,
|
|
3167
|
+
ChatInputRequest,
|
|
3168
|
+
ChatFeedback,
|
|
3169
|
+
ChatScrollToBottom,
|
|
3170
|
+
ChatThread,
|
|
3171
|
+
ChatPanel,
|
|
3172
|
+
videoEmbedOf,
|
|
3173
|
+
ChatVideoPreview,
|
|
3174
|
+
ChatSources,
|
|
3175
|
+
ChatSuggestions,
|
|
3176
|
+
ChatThinking,
|
|
3177
|
+
easeLinear,
|
|
3178
|
+
easeOutCubic,
|
|
3179
|
+
easeOutQuart,
|
|
3180
|
+
easeOutExpo,
|
|
3181
|
+
CountUp,
|
|
3182
|
+
useTextareaCommands,
|
|
3183
|
+
useTextareaSelection,
|
|
3184
|
+
useTextareaTools,
|
|
3185
|
+
textareaTools,
|
|
3186
|
+
Textarea,
|
|
3187
|
+
TestimonialCard
|
|
3188
|
+
};
|
|
3189
|
+
//# sourceMappingURL=chunk-QWOH2E3F.js.map
|