@octaviaflow/core 3.1.0-beta.75 → 3.1.0-beta.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/chunk-CVU6QDOL.js +1696 -0
  2. package/dist/chunk-CVU6QDOL.js.map +1 -0
  3. package/dist/chunk-PZIWTCI6.js +1690 -0
  4. package/dist/chunk-PZIWTCI6.js.map +1 -0
  5. package/dist/chunk-REEBXURQ.js +1646 -0
  6. package/dist/chunk-REEBXURQ.js.map +1 -0
  7. package/dist/components/Avatar/Avatar.d.ts +17 -3
  8. package/dist/components/Avatar/Avatar.d.ts.map +1 -1
  9. package/dist/components/Avatar/index.d.ts +1 -1
  10. package/dist/components/Avatar/index.d.ts.map +1 -1
  11. package/dist/components/BlogCard/BlogCard.d.ts +1 -1
  12. package/dist/components/BlogCard/BlogCard.d.ts.map +1 -1
  13. package/dist/components/KanbanCard/KanbanCard.d.ts +1 -1
  14. package/dist/components/KanbanCard/KanbanCard.d.ts.map +1 -1
  15. package/dist/components/MembersSettings/MembersSettings.d.ts.map +1 -1
  16. package/dist/components/OrganizationSettings/OrganizationSettings.d.ts.map +1 -1
  17. package/dist/components/SettingsLayout/SettingsLayout.d.ts +1 -1
  18. package/dist/components/SettingsLayout/SettingsLayout.d.ts.map +1 -1
  19. package/dist/components/TemplateCard/TemplateCard.d.ts +1 -1
  20. package/dist/components/TemplateCard/TemplateCard.d.ts.map +1 -1
  21. package/dist/components/TestimonialCard/TestimonialCard.d.ts +1 -1
  22. package/dist/components/TestimonialCard/TestimonialCard.d.ts.map +1 -1
  23. package/dist/components/UserCard/UserCard.d.ts +1 -1
  24. package/dist/components/UserCard/UserCard.d.ts.map +1 -1
  25. package/dist/index.cjs +1477 -1482
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1137 -1119
  30. package/dist/index.js.map +1 -1
  31. package/dist/marketing.cjs +228 -260
  32. package/dist/marketing.cjs.map +1 -1
  33. package/dist/marketing.js +1 -1
  34. package/dist/styles.css +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1,1696 @@
1
+ import {
2
+ Slot,
3
+ resolveAccessibleName
4
+ } from "./chunk-CRDYAV5R.js";
5
+ import {
6
+ cn
7
+ } from "./chunk-ZAUUGK2Y.js";
8
+
9
+ // src/components/Card/Card.tsx
10
+ import { motion, useReducedMotion } from "framer-motion";
11
+ import {
12
+ forwardRef
13
+ } from "react";
14
+ import { jsx } from "react/jsx-runtime";
15
+ var Card = forwardRef(function Card2({
16
+ variant = "default",
17
+ padding = "md",
18
+ radius = "md",
19
+ hoverable = false,
20
+ disabled = false,
21
+ loading = false,
22
+ asChild = false,
23
+ onClick,
24
+ onKeyDown,
25
+ className,
26
+ children,
27
+ ...rest
28
+ }, ref) {
29
+ const reducedMotion = useReducedMotion();
30
+ const isInteractive = Boolean(onClick) && !disabled && !loading;
31
+ const handleKeyDown = (e) => {
32
+ onKeyDown?.(e);
33
+ if (e.defaultPrevented) return;
34
+ if (!isInteractive) return;
35
+ if ((e.key === "Enter" || e.key === " ") && !e.repeat) {
36
+ e.preventDefault();
37
+ onClick?.(e);
38
+ }
39
+ };
40
+ const rootClassName = cn(
41
+ "ods-card",
42
+ `ods-card--${variant}`,
43
+ `ods-card--pad-${padding}`,
44
+ `ods-card--radius-${radius}`,
45
+ (hoverable || isInteractive) && !loading && !disabled && "ods-card--hoverable",
46
+ isInteractive && "ods-card--clickable",
47
+ disabled && "ods-card--disabled",
48
+ loading && "ods-card--loading",
49
+ className
50
+ );
51
+ if (asChild) {
52
+ return /* @__PURE__ */ jsx(
53
+ Slot,
54
+ {
55
+ ...rest,
56
+ ref,
57
+ className: rootClassName,
58
+ onClick: isInteractive ? onClick : void 0,
59
+ onKeyDown: isInteractive ? handleKeyDown : onKeyDown,
60
+ "aria-disabled": disabled || void 0,
61
+ children
62
+ }
63
+ );
64
+ }
65
+ if (loading) {
66
+ return /* @__PURE__ */ jsx(
67
+ "div",
68
+ {
69
+ ...rest,
70
+ ref,
71
+ className: rootClassName,
72
+ "aria-busy": "true",
73
+ "aria-label": "Loading",
74
+ children: /* @__PURE__ */ jsx("div", { className: "ods-card__skeleton", "data-ods-animate": "shimmer" })
75
+ }
76
+ );
77
+ }
78
+ return /* @__PURE__ */ jsx(
79
+ motion.div,
80
+ {
81
+ ...rest,
82
+ ref,
83
+ onClick: isInteractive ? onClick : void 0,
84
+ onKeyDown: isInteractive ? handleKeyDown : onKeyDown,
85
+ className: rootClassName,
86
+ whileHover: (hoverable || isInteractive) && !reducedMotion ? { y: -2, transition: { duration: 0.15 } } : void 0,
87
+ whileTap: isInteractive && !reducedMotion ? { scale: 0.99 } : void 0,
88
+ role: isInteractive ? "button" : rest.role,
89
+ tabIndex: isInteractive ? rest.tabIndex ?? 0 : rest.tabIndex,
90
+ "aria-disabled": disabled || void 0,
91
+ children
92
+ }
93
+ );
94
+ });
95
+ Card.displayName = "Card";
96
+ var CardHeader = forwardRef(
97
+ function CardHeader2({ className, children, ...rest }, ref) {
98
+ return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__header", className), children });
99
+ }
100
+ );
101
+ CardHeader.displayName = "Card.Header";
102
+ var CardBody = forwardRef(
103
+ function CardBody2({ className, children, ...rest }, ref) {
104
+ return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__body", className), children });
105
+ }
106
+ );
107
+ CardBody.displayName = "Card.Body";
108
+ var CardFooter = forwardRef(
109
+ function CardFooter2({ className, children, ...rest }, ref) {
110
+ return /* @__PURE__ */ jsx("div", { ...rest, ref, className: cn("ods-card__footer", className), children });
111
+ }
112
+ );
113
+ CardFooter.displayName = "Card.Footer";
114
+ var CardTitle = forwardRef(
115
+ function CardTitle2({ as: Comp = "h3", className, children, ...rest }, ref) {
116
+ return /* @__PURE__ */ jsx(
117
+ Comp,
118
+ {
119
+ ...rest,
120
+ ref,
121
+ className: cn("ods-card__title", className),
122
+ children
123
+ }
124
+ );
125
+ }
126
+ );
127
+ CardTitle.displayName = "Card.Title";
128
+ var CardDescription = forwardRef(function CardDescription2({ className, children, ...rest }, ref) {
129
+ return /* @__PURE__ */ jsx("p", { ...rest, ref, className: cn("ods-card__description", className), children });
130
+ });
131
+ CardDescription.displayName = "Card.Description";
132
+ Card.Header = CardHeader;
133
+ Card.Body = CardBody;
134
+ Card.Footer = CardFooter;
135
+ Card.Title = CardTitle;
136
+ Card.Description = CardDescription;
137
+
138
+ // src/components/Avatar/Avatar.tsx
139
+ import {
140
+ forwardRef as forwardRef2,
141
+ useCallback,
142
+ useMemo,
143
+ useState
144
+ } from "react";
145
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
146
+ var PALETTE_SIZE = 12;
147
+ function djb2(str) {
148
+ let h = 5381;
149
+ for (let i = 0; i < str.length; i++) h = (h << 5) + h + str.charCodeAt(i);
150
+ return h >>> 0;
151
+ }
152
+ function paletteIndexFor(seed) {
153
+ return djb2(seed) % PALETTE_SIZE;
154
+ }
155
+ var AVATAR_PALETTE_SIZE = PALETTE_SIZE;
156
+ function avatarPaletteIndex(seed) {
157
+ return paletteIndexFor(seed);
158
+ }
159
+ function normalizeInitials(raw) {
160
+ const trimmed = raw.trim();
161
+ if (!trimmed) return "";
162
+ const tokens = trimmed.split(/\s+/).filter(Boolean);
163
+ if (tokens.length >= 2) {
164
+ return (tokens[0].charAt(0) + tokens[1].charAt(0)).toUpperCase();
165
+ }
166
+ return trimmed.slice(0, 2).toUpperCase();
167
+ }
168
+ var STATUS_DEFAULT_LABEL = {
169
+ online: "Online",
170
+ offline: "Offline",
171
+ busy: "Busy",
172
+ away: "Away"
173
+ };
174
+ var Avatar = forwardRef2(function Avatar2({
175
+ src,
176
+ alt,
177
+ initials,
178
+ icon,
179
+ fallback,
180
+ seed,
181
+ palette,
182
+ size = "md",
183
+ shape = "circle",
184
+ status,
185
+ statusLabel,
186
+ onClick,
187
+ imgLoading = "lazy",
188
+ referrerPolicy,
189
+ className,
190
+ ...rest
191
+ }, ref) {
192
+ const [imgFailed, setImgFailed] = useState(false);
193
+ const handleImgError = useCallback(() => setImgFailed(true), []);
194
+ const showImage = Boolean(src) && !imgFailed;
195
+ const normalizedInitials = useMemo(
196
+ () => initials ? normalizeInitials(initials) : "",
197
+ [initials]
198
+ );
199
+ const paletteIdx = useMemo(() => {
200
+ if (palette !== void 0) {
201
+ return (Math.trunc(palette) % PALETTE_SIZE + PALETTE_SIZE) % PALETTE_SIZE;
202
+ }
203
+ const resolved = seed ?? alt ?? initials ?? "?";
204
+ return paletteIndexFor(resolved);
205
+ }, [palette, seed, alt, initials]);
206
+ const baseName = alt || normalizedInitials || "Avatar";
207
+ const announcedStatus = status ? statusLabel ?? STATUS_DEFAULT_LABEL[status] : "";
208
+ const accessibleName = announcedStatus ? `${baseName}, ${announcedStatus}` : baseName;
209
+ const isClickable = Boolean(onClick);
210
+ const handleKeyDown = (e) => {
211
+ if (!isClickable) return;
212
+ if ((e.key === "Enter" || e.key === " ") && !e.repeat) {
213
+ e.preventDefault();
214
+ onClick?.();
215
+ }
216
+ };
217
+ const rootClassName = cn(
218
+ "ods-avatar",
219
+ `ods-avatar--${size}`,
220
+ `ods-avatar--${shape}`,
221
+ isClickable && "ods-avatar--clickable",
222
+ className
223
+ );
224
+ return /* @__PURE__ */ jsxs(
225
+ "div",
226
+ {
227
+ ...rest,
228
+ ref,
229
+ className: rootClassName,
230
+ role: isClickable ? "button" : "img",
231
+ "aria-label": accessibleName,
232
+ tabIndex: isClickable ? 0 : void 0,
233
+ onClick,
234
+ onKeyDown: isClickable ? handleKeyDown : void 0,
235
+ "data-status": status,
236
+ children: [
237
+ /* @__PURE__ */ jsx2("span", { className: "ods-avatar__inner", "data-palette": paletteIdx, children: showImage ? /* @__PURE__ */ jsx2(
238
+ "img",
239
+ {
240
+ src,
241
+ alt: "",
242
+ className: "ods-avatar__image",
243
+ loading: imgLoading,
244
+ decoding: "async",
245
+ referrerPolicy,
246
+ onError: handleImgError,
247
+ draggable: false
248
+ }
249
+ ) : 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 ?? "?" }) }),
250
+ status && // Decorative — the textual status is folded into the wrapper's
251
+ // aria-label above. `aria-hidden` keeps AT from double-announcing.
252
+ /* @__PURE__ */ jsx2(
253
+ "span",
254
+ {
255
+ className: cn("ods-avatar__status", `ods-avatar__status--${status}`),
256
+ "aria-hidden": "true"
257
+ }
258
+ )
259
+ ]
260
+ }
261
+ );
262
+ });
263
+ Avatar.displayName = "Avatar";
264
+ var AvatarStack = forwardRef2(
265
+ function AvatarStack2({
266
+ children,
267
+ max,
268
+ size = "md",
269
+ renderOverflow,
270
+ direction = "ltr",
271
+ className,
272
+ ...rest
273
+ }, ref) {
274
+ const arr = Array.isArray(children) ? children : [children];
275
+ const visible = max && arr.length > max ? arr.slice(0, max) : arr;
276
+ const overflow = max && arr.length > max ? arr.length - max : 0;
277
+ return /* @__PURE__ */ jsxs(
278
+ "div",
279
+ {
280
+ ...rest,
281
+ ref,
282
+ className: cn(
283
+ "ods-avatar-stack",
284
+ `ods-avatar-stack--${direction}`,
285
+ className
286
+ ),
287
+ children: [
288
+ visible,
289
+ overflow > 0 && (renderOverflow ? renderOverflow(overflow) : /* @__PURE__ */ jsx2(
290
+ "div",
291
+ {
292
+ className: cn(
293
+ "ods-avatar",
294
+ `ods-avatar--${size}`,
295
+ "ods-avatar--circle",
296
+ "ods-avatar-stack__overflow"
297
+ ),
298
+ role: "img",
299
+ "aria-label": `${overflow} more`,
300
+ children: /* @__PURE__ */ jsx2("span", { className: "ods-avatar__inner", children: /* @__PURE__ */ jsxs("span", { className: "ods-avatar__initials", "aria-hidden": "true", children: [
301
+ "+",
302
+ overflow
303
+ ] }) })
304
+ }
305
+ ))
306
+ ]
307
+ }
308
+ );
309
+ }
310
+ );
311
+ AvatarStack.displayName = "AvatarStack";
312
+
313
+ // src/components/BlogCard/BlogCard.tsx
314
+ import {
315
+ forwardRef as forwardRef3,
316
+ useId
317
+ } from "react";
318
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
319
+ var BlogCard = forwardRef3(
320
+ function BlogCard2({
321
+ cover,
322
+ coverAspect = "16/9",
323
+ category,
324
+ tags,
325
+ meta,
326
+ readingTime,
327
+ title,
328
+ titleAs = "h3",
329
+ description,
330
+ author,
331
+ footer,
332
+ radius = "md",
333
+ orientation = "vertical",
334
+ href,
335
+ onClick,
336
+ id: providedId,
337
+ className,
338
+ ...rest
339
+ }, ref) {
340
+ const reactId = useId();
341
+ const baseId = providedId ?? `ods-blog-card-${reactId}`;
342
+ const titleId = `${baseId}-title`;
343
+ const descId = description ? `${baseId}-desc` : void 0;
344
+ const tagList = tags ?? (category ? [category] : []);
345
+ const body = /* @__PURE__ */ jsxs2(Fragment, { children: [
346
+ cover && /* @__PURE__ */ jsx3(
347
+ "div",
348
+ {
349
+ className: cn(
350
+ "ods-blog-card__cover",
351
+ `ods-blog-card__cover--aspect-${coverAspect.replace("/", "-")}`
352
+ ),
353
+ "aria-hidden": "true",
354
+ children: cover
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__body", children: [
358
+ (tagList.length > 0 || meta || readingTime) && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__meta", children: [
359
+ 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)) }),
360
+ meta && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__date", children: meta }),
361
+ readingTime && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__reading", children: readingTime })
362
+ ] }),
363
+ /* @__PURE__ */ jsx3(
364
+ Card.Title,
365
+ {
366
+ as: titleAs,
367
+ id: titleId,
368
+ className: "ods-blog-card__title",
369
+ children: title
370
+ }
371
+ ),
372
+ description && /* @__PURE__ */ jsx3(
373
+ Card.Description,
374
+ {
375
+ id: descId,
376
+ className: "ods-blog-card__desc",
377
+ children: description
378
+ }
379
+ ),
380
+ (author || footer) && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__footer", children: [
381
+ author && /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__author", children: [
382
+ author.avatar && /* @__PURE__ */ jsx3(
383
+ Avatar,
384
+ {
385
+ size: "sm",
386
+ src: author.avatar.src,
387
+ initials: author.avatar.initials,
388
+ seed: author.avatar.seed,
389
+ palette: author.avatar.palette,
390
+ alt: author.avatar.alt ?? (typeof author.name === "string" ? author.name : void 0)
391
+ }
392
+ ),
393
+ /* @__PURE__ */ jsxs2("div", { className: "ods-blog-card__author-text", children: [
394
+ /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__author-name", children: author.name }),
395
+ author.byline && /* @__PURE__ */ jsx3("span", { className: "ods-blog-card__author-byline", children: author.byline })
396
+ ] })
397
+ ] }),
398
+ footer && /* @__PURE__ */ jsx3("div", { className: "ods-blog-card__action", children: footer })
399
+ ] })
400
+ ] })
401
+ ] });
402
+ if (href) {
403
+ return /* @__PURE__ */ jsx3(
404
+ Card,
405
+ {
406
+ asChild: true,
407
+ radius,
408
+ padding: "none",
409
+ className: cn(
410
+ "ods-blog-card",
411
+ `ods-blog-card--${orientation}`,
412
+ "ods-blog-card--interactive",
413
+ className
414
+ ),
415
+ "aria-labelledby": titleId,
416
+ "aria-describedby": descId,
417
+ children: /* @__PURE__ */ jsx3(
418
+ "a",
419
+ {
420
+ ...rest,
421
+ ref,
422
+ href,
423
+ id: baseId,
424
+ onClick,
425
+ children: body
426
+ }
427
+ )
428
+ }
429
+ );
430
+ }
431
+ return /* @__PURE__ */ jsx3(
432
+ Card,
433
+ {
434
+ ...rest,
435
+ ref,
436
+ id: baseId,
437
+ radius,
438
+ padding: "none",
439
+ onClick,
440
+ className: cn(
441
+ "ods-blog-card",
442
+ `ods-blog-card--${orientation}`,
443
+ onClick && "ods-blog-card--interactive",
444
+ className
445
+ ),
446
+ "aria-labelledby": titleId,
447
+ "aria-describedby": descId,
448
+ children: body
449
+ }
450
+ );
451
+ }
452
+ );
453
+ BlogCard.displayName = "BlogCard";
454
+
455
+ // src/hooks/useTextareaCommands.ts
456
+ import {
457
+ useCallback as useCallback2,
458
+ useEffect,
459
+ useMemo as useMemo2,
460
+ useRef,
461
+ useState as useState2
462
+ } from "react";
463
+ function findOpenTrigger(value, caret, trigger) {
464
+ let i = caret - 1;
465
+ while (i >= 0) {
466
+ const ch = value[i];
467
+ if (ch === "\n" || ch === " " || ch === " ") return null;
468
+ if (value.startsWith(trigger, i)) {
469
+ const before = i === 0 ? "" : value[i - 1];
470
+ if (i === 0 || before === " " || before === "\n" || before === " ") {
471
+ return {
472
+ triggerIndex: i,
473
+ query: value.slice(i + trigger.length, caret)
474
+ };
475
+ }
476
+ return null;
477
+ }
478
+ i--;
479
+ }
480
+ return null;
481
+ }
482
+ function getCaretRect(textarea, caret) {
483
+ if (typeof document === "undefined") return null;
484
+ const mirror = document.createElement("div");
485
+ const styles = window.getComputedStyle(textarea);
486
+ for (const prop of [
487
+ "boxSizing",
488
+ "width",
489
+ "fontFamily",
490
+ "fontSize",
491
+ "fontWeight",
492
+ "fontStyle",
493
+ "letterSpacing",
494
+ "lineHeight",
495
+ "paddingTop",
496
+ "paddingRight",
497
+ "paddingBottom",
498
+ "paddingLeft",
499
+ "borderTopWidth",
500
+ "borderRightWidth",
501
+ "borderBottomWidth",
502
+ "borderLeftWidth",
503
+ "textTransform",
504
+ "wordSpacing",
505
+ "tabSize",
506
+ "whiteSpace"
507
+ ]) {
508
+ mirror.style[prop] = styles[prop];
509
+ }
510
+ mirror.style.position = "absolute";
511
+ mirror.style.visibility = "hidden";
512
+ mirror.style.overflow = "hidden";
513
+ mirror.style.top = "0";
514
+ mirror.style.left = "0";
515
+ mirror.style.whiteSpace = "pre-wrap";
516
+ mirror.style.wordWrap = "break-word";
517
+ mirror.textContent = textarea.value.slice(0, caret);
518
+ const marker = document.createElement("span");
519
+ marker.textContent = "\u200B";
520
+ mirror.appendChild(marker);
521
+ document.body.appendChild(mirror);
522
+ const taRect = textarea.getBoundingClientRect();
523
+ const markerRect = marker.getBoundingClientRect();
524
+ const mirrorRect = mirror.getBoundingClientRect();
525
+ const x = taRect.left + (markerRect.left - mirrorRect.left) - textarea.scrollLeft;
526
+ const y = taRect.top + (markerRect.top - mirrorRect.top) - textarea.scrollTop;
527
+ const out = new DOMRect(x, y, 0, markerRect.height || 16);
528
+ document.body.removeChild(mirror);
529
+ return out;
530
+ }
531
+ function useTextareaCommands({
532
+ textareaRef,
533
+ value,
534
+ onChange,
535
+ commands,
536
+ trigger = "/",
537
+ openOnEmptyTrigger = true,
538
+ maxItems = 8
539
+ }) {
540
+ const [isOpen, setIsOpen] = useState2(false);
541
+ const [query, setQuery] = useState2("");
542
+ const [activeIndex, setActiveIndex] = useState2(0);
543
+ const [triggerIndex, setTriggerIndex] = useState2(null);
544
+ const [caretRect, setCaretRect] = useState2(null);
545
+ const dismissedAtRef = useRef(
546
+ null
547
+ );
548
+ const items = useMemo2(() => {
549
+ const q = query.trim().toLowerCase();
550
+ if (!q) return commands.slice(0, maxItems);
551
+ return commands.filter((c) => {
552
+ const hay = [
553
+ typeof c.label === "string" ? c.label : "",
554
+ typeof c.description === "string" ? c.description : "",
555
+ c.id,
556
+ ...c.keywords ?? []
557
+ ].join(" ").toLowerCase();
558
+ return hay.includes(q);
559
+ }).slice(0, maxItems);
560
+ }, [commands, query, maxItems]);
561
+ useEffect(() => {
562
+ const ta = textareaRef.current;
563
+ if (!ta) return;
564
+ const caret = ta.selectionStart ?? 0;
565
+ const dismissedAt = dismissedAtRef.current;
566
+ if (dismissedAt && dismissedAt.value === value && dismissedAt.caret === caret) {
567
+ return;
568
+ }
569
+ const found = findOpenTrigger(value, caret, trigger);
570
+ if (!found) {
571
+ if (isOpen) setIsOpen(false);
572
+ setTriggerIndex(null);
573
+ return;
574
+ }
575
+ if (dismissedAt) dismissedAtRef.current = null;
576
+ if (found.query.length > 0 || openOnEmptyTrigger) {
577
+ setQuery(found.query);
578
+ setTriggerIndex(found.triggerIndex);
579
+ setIsOpen(true);
580
+ setActiveIndex(0);
581
+ setCaretRect(getCaretRect(ta, caret));
582
+ }
583
+ }, [value, trigger, openOnEmptyTrigger, isOpen, textareaRef]);
584
+ const commit = useCallback2(
585
+ (cmd) => {
586
+ const ta = textareaRef.current;
587
+ if (!ta || triggerIndex == null) return;
588
+ const insertText = typeof cmd.insert === "function" ? cmd.insert(query) : cmd.insert;
589
+ const caret = ta.selectionStart ?? value.length;
590
+ const before = value.slice(0, triggerIndex);
591
+ const after = value.slice(caret);
592
+ const next = `${before}${insertText}${after}`;
593
+ dismissedAtRef.current = {
594
+ value,
595
+ caret
596
+ };
597
+ onChange(next);
598
+ setIsOpen(false);
599
+ setTriggerIndex(null);
600
+ requestAnimationFrame(() => {
601
+ const pos = before.length + insertText.length;
602
+ ta.focus();
603
+ ta.setSelectionRange(pos, pos);
604
+ });
605
+ },
606
+ [textareaRef, triggerIndex, query, value, onChange]
607
+ );
608
+ const dismiss = useCallback2(() => {
609
+ const ta = textareaRef.current;
610
+ dismissedAtRef.current = {
611
+ value,
612
+ caret: ta?.selectionStart ?? value.length
613
+ };
614
+ setIsOpen(false);
615
+ setTriggerIndex(null);
616
+ }, [textareaRef, value]);
617
+ const onKeyDown = useCallback2(
618
+ (e) => {
619
+ if (!isOpen) return false;
620
+ if (e.key === "ArrowDown") {
621
+ e.preventDefault();
622
+ setActiveIndex((i) => Math.min(items.length - 1, i + 1));
623
+ return true;
624
+ }
625
+ if (e.key === "ArrowUp") {
626
+ e.preventDefault();
627
+ setActiveIndex((i) => Math.max(0, i - 1));
628
+ return true;
629
+ }
630
+ if (e.key === "Enter" || e.key === "Tab") {
631
+ const pick = items[activeIndex];
632
+ if (pick) {
633
+ e.preventDefault();
634
+ commit(pick);
635
+ return true;
636
+ }
637
+ }
638
+ if (e.key === "Escape") {
639
+ e.preventDefault();
640
+ dismiss();
641
+ return true;
642
+ }
643
+ return false;
644
+ },
645
+ [isOpen, items, activeIndex, commit, dismiss]
646
+ );
647
+ return {
648
+ isOpen,
649
+ query,
650
+ activeIndex,
651
+ items,
652
+ onKeyDown,
653
+ dismiss,
654
+ commit,
655
+ caretRect
656
+ };
657
+ }
658
+
659
+ // src/hooks/useTextareaSelection.ts
660
+ import { useCallback as useCallback3, useEffect as useEffect2, useState as useState3 } from "react";
661
+ function getSelectionRect(textarea, start, end) {
662
+ if (typeof document === "undefined") return null;
663
+ if (start === end) return null;
664
+ const mirror = document.createElement("div");
665
+ const styles = window.getComputedStyle(textarea);
666
+ for (const prop of [
667
+ "boxSizing",
668
+ "width",
669
+ "fontFamily",
670
+ "fontSize",
671
+ "fontWeight",
672
+ "fontStyle",
673
+ "letterSpacing",
674
+ "lineHeight",
675
+ "paddingTop",
676
+ "paddingRight",
677
+ "paddingBottom",
678
+ "paddingLeft",
679
+ "borderTopWidth",
680
+ "borderRightWidth",
681
+ "borderBottomWidth",
682
+ "borderLeftWidth",
683
+ "textTransform",
684
+ "wordSpacing",
685
+ "tabSize",
686
+ "whiteSpace"
687
+ ]) {
688
+ mirror.style[prop] = styles[prop];
689
+ }
690
+ mirror.style.position = "absolute";
691
+ mirror.style.visibility = "hidden";
692
+ mirror.style.overflow = "hidden";
693
+ mirror.style.top = "0";
694
+ mirror.style.left = "0";
695
+ mirror.style.whiteSpace = "pre-wrap";
696
+ mirror.style.wordWrap = "break-word";
697
+ const pre = document.createTextNode(textarea.value.slice(0, start));
698
+ const range = document.createElement("span");
699
+ range.textContent = textarea.value.slice(start, end) || "\u200B";
700
+ const post = document.createTextNode(textarea.value.slice(end));
701
+ mirror.appendChild(pre);
702
+ mirror.appendChild(range);
703
+ mirror.appendChild(post);
704
+ document.body.appendChild(mirror);
705
+ const taRect = textarea.getBoundingClientRect();
706
+ const rangeRect = range.getBoundingClientRect();
707
+ const mirrorRect = mirror.getBoundingClientRect();
708
+ const out = new DOMRect(
709
+ taRect.left + (rangeRect.left - mirrorRect.left) - textarea.scrollLeft,
710
+ taRect.top + (rangeRect.top - mirrorRect.top) - textarea.scrollTop,
711
+ rangeRect.width,
712
+ rangeRect.height
713
+ );
714
+ document.body.removeChild(mirror);
715
+ return out;
716
+ }
717
+ function useTextareaSelection({
718
+ textareaRef,
719
+ value,
720
+ onChange
721
+ }) {
722
+ const [start, setStart] = useState3(0);
723
+ const [end, setEnd] = useState3(0);
724
+ const [rect, setRect] = useState3(null);
725
+ useEffect2(() => {
726
+ if (typeof document === "undefined") return;
727
+ const handler = () => {
728
+ const ta = textareaRef.current;
729
+ if (!ta || document.activeElement !== ta) {
730
+ setStart(0);
731
+ setEnd(0);
732
+ setRect(null);
733
+ return;
734
+ }
735
+ const s = ta.selectionStart ?? 0;
736
+ const e = ta.selectionEnd ?? 0;
737
+ setStart(s);
738
+ setEnd(e);
739
+ setRect(s !== e ? getSelectionRect(ta, s, e) : null);
740
+ };
741
+ document.addEventListener("selectionchange", handler);
742
+ return () => document.removeEventListener("selectionchange", handler);
743
+ }, [textareaRef]);
744
+ const active = start !== end;
745
+ const text = active ? value.slice(start, end) : "";
746
+ const writeToClipboard = useCallback3(
747
+ async (str) => {
748
+ try {
749
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
750
+ await navigator.clipboard.writeText(str);
751
+ return true;
752
+ }
753
+ } catch {
754
+ }
755
+ try {
756
+ const tmp = document.createElement("textarea");
757
+ tmp.value = str;
758
+ tmp.style.position = "fixed";
759
+ tmp.style.left = "-9999px";
760
+ document.body.appendChild(tmp);
761
+ tmp.select();
762
+ const ok = document.execCommand("copy");
763
+ document.body.removeChild(tmp);
764
+ return ok;
765
+ } catch {
766
+ return false;
767
+ }
768
+ },
769
+ []
770
+ );
771
+ const copy = useCallback3(async () => {
772
+ if (!active) return false;
773
+ return writeToClipboard(text);
774
+ }, [active, text, writeToClipboard]);
775
+ const replace = useCallback3(
776
+ (str) => {
777
+ const ta = textareaRef.current;
778
+ if (!ta) return;
779
+ const next = value.slice(0, start) + str + value.slice(end);
780
+ onChange(next);
781
+ requestAnimationFrame(() => {
782
+ ta.focus();
783
+ const caret = start + str.length;
784
+ ta.setSelectionRange(caret, caret);
785
+ });
786
+ },
787
+ [textareaRef, value, start, end, onChange]
788
+ );
789
+ const cut = useCallback3(async () => {
790
+ if (!active) return false;
791
+ const ok = await writeToClipboard(text);
792
+ if (ok) replace("");
793
+ return ok;
794
+ }, [active, text, writeToClipboard, replace]);
795
+ const wrap = useCallback3(
796
+ (open, close) => {
797
+ const ta = textareaRef.current;
798
+ if (!ta) return;
799
+ const closing = close ?? open;
800
+ const before = value.slice(0, start);
801
+ const sel = value.slice(start, end);
802
+ const after = value.slice(end);
803
+ const next = `${before}${open}${sel}${closing}${after}`;
804
+ onChange(next);
805
+ requestAnimationFrame(() => {
806
+ ta.focus();
807
+ const newStart = start;
808
+ const newEnd = end + open.length + closing.length;
809
+ ta.setSelectionRange(newStart, newEnd);
810
+ });
811
+ },
812
+ [textareaRef, value, start, end, onChange]
813
+ );
814
+ return {
815
+ active,
816
+ text,
817
+ start,
818
+ end,
819
+ rect,
820
+ copy,
821
+ cut,
822
+ wrap,
823
+ replace
824
+ };
825
+ }
826
+
827
+ // src/hooks/useTextareaTools.tsx
828
+ import {
829
+ CodeIcon,
830
+ HeadingIcon,
831
+ ListBulletedIcon,
832
+ ListNumberedIcon,
833
+ QuotesIcon,
834
+ RedoIcon,
835
+ TextBoldIcon,
836
+ TextItalicIcon,
837
+ TextLinkIcon,
838
+ TextStrikethroughIcon,
839
+ UndoIcon
840
+ } from "@octaviaflow/icons";
841
+ import { useCallback as useCallback4, useMemo as useMemo3, useRef as useRef2 } from "react";
842
+ import { jsx as jsx4 } from "react/jsx-runtime";
843
+ function useTextareaTools({
844
+ textareaRef,
845
+ value,
846
+ onChange,
847
+ tools
848
+ }) {
849
+ const valueRef = useRef2(value);
850
+ valueRef.current = value;
851
+ const helpers = useMemo3(() => {
852
+ const getTa = () => textareaRef.current;
853
+ const getSelection = () => {
854
+ const ta = getTa();
855
+ const s = ta?.selectionStart ?? 0;
856
+ const e = ta?.selectionEnd ?? 0;
857
+ return {
858
+ text: valueRef.current.slice(s, e),
859
+ start: s,
860
+ end: e,
861
+ active: s !== e
862
+ };
863
+ };
864
+ const setValue = (next) => onChange(next);
865
+ const replace = (text) => {
866
+ const ta = getTa();
867
+ if (!ta) return;
868
+ const { start, end } = getSelection();
869
+ const next = valueRef.current.slice(0, start) + text + valueRef.current.slice(end);
870
+ onChange(next);
871
+ requestAnimationFrame(() => {
872
+ ta.focus();
873
+ const caret = start + text.length;
874
+ ta.setSelectionRange(caret, caret);
875
+ });
876
+ };
877
+ const insert = (text) => replace(text);
878
+ const wrap = (open, close) => {
879
+ const ta = getTa();
880
+ if (!ta) return;
881
+ const closing = close ?? open;
882
+ const { start, end } = getSelection();
883
+ const sel = valueRef.current.slice(start, end);
884
+ const next = valueRef.current.slice(0, start) + open + sel + closing + valueRef.current.slice(end);
885
+ onChange(next);
886
+ requestAnimationFrame(() => {
887
+ ta.focus();
888
+ if (start === end) {
889
+ const caret = start + open.length;
890
+ ta.setSelectionRange(caret, caret);
891
+ } else {
892
+ ta.setSelectionRange(start, end + open.length + closing.length);
893
+ }
894
+ });
895
+ };
896
+ const prependLines = (prefix) => {
897
+ const ta = getTa();
898
+ if (!ta) return;
899
+ const { start, end } = getSelection();
900
+ const v = valueRef.current;
901
+ const lineStart = v.lastIndexOf("\n", start - 1) + 1;
902
+ const lineEnd = (() => {
903
+ const idx = v.indexOf("\n", end);
904
+ return idx === -1 ? v.length : idx;
905
+ })();
906
+ const block = v.slice(lineStart, lineEnd);
907
+ const updated = block.split("\n").map((line) => `${prefix}${line}`).join("\n");
908
+ const next = v.slice(0, lineStart) + updated + v.slice(lineEnd);
909
+ onChange(next);
910
+ requestAnimationFrame(() => {
911
+ ta.focus();
912
+ ta.setSelectionRange(
913
+ lineStart,
914
+ lineStart + updated.length
915
+ );
916
+ });
917
+ };
918
+ const undo = () => {
919
+ try {
920
+ getTa()?.focus();
921
+ document.execCommand("undo");
922
+ } catch {
923
+ }
924
+ };
925
+ const redo = () => {
926
+ try {
927
+ getTa()?.focus();
928
+ document.execCommand("redo");
929
+ } catch {
930
+ }
931
+ };
932
+ return {
933
+ get value() {
934
+ return valueRef.current;
935
+ },
936
+ get selection() {
937
+ return getSelection();
938
+ },
939
+ setValue,
940
+ replace,
941
+ insert,
942
+ wrap,
943
+ prependLines,
944
+ undo,
945
+ redo,
946
+ getTextarea: getTa
947
+ };
948
+ }, [textareaRef, onChange]);
949
+ const visibleTools = useMemo3(
950
+ () => tools.filter((t) => t.isVisible ? t.isVisible(helpers) : true),
951
+ [tools, helpers]
952
+ );
953
+ const runTool = useCallback4(
954
+ async (id) => {
955
+ const tool = tools.find((t) => t.id === id);
956
+ if (!tool || tool.kind === "divider") return;
957
+ await tool.onAction?.(helpers);
958
+ },
959
+ [tools, helpers]
960
+ );
961
+ return { tools: visibleTools, runTool, helpers };
962
+ }
963
+ var wrapTool = (id, open, close, label, icon, title) => ({
964
+ id,
965
+ label,
966
+ icon,
967
+ title,
968
+ onAction: (h) => h.wrap(open, close)
969
+ });
970
+ var prependLineTool = (id, prefix, label, icon, title) => ({
971
+ id,
972
+ label,
973
+ icon,
974
+ title,
975
+ onAction: (h) => h.prependLines(prefix)
976
+ });
977
+ var textareaTools = {
978
+ bold: () => wrapTool("bold", "**", "**", "Bold", /* @__PURE__ */ jsx4(TextBoldIcon, {}), "Bold (\u2318B)"),
979
+ italic: () => wrapTool("italic", "*", "*", "Italic", /* @__PURE__ */ jsx4(TextItalicIcon, {}), "Italic (\u2318I)"),
980
+ strikethrough: () => wrapTool(
981
+ "strike",
982
+ "~~",
983
+ "~~",
984
+ "Strikethrough",
985
+ /* @__PURE__ */ jsx4(TextStrikethroughIcon, {}),
986
+ "Strikethrough"
987
+ ),
988
+ code: () => wrapTool("code", "`", "`", "Code", /* @__PURE__ */ jsx4(CodeIcon, {}), "Inline code"),
989
+ codeBlock: () => ({
990
+ id: "code-block",
991
+ label: "Code block",
992
+ icon: /* @__PURE__ */ jsx4(CodeIcon, {}),
993
+ title: "Code block",
994
+ onAction: (h) => h.wrap("```\n", "\n```")
995
+ }),
996
+ link: () => ({
997
+ id: "link",
998
+ label: "Link",
999
+ icon: /* @__PURE__ */ jsx4(TextLinkIcon, {}),
1000
+ title: "Insert link",
1001
+ onAction: (h) => {
1002
+ const sel = h.selection;
1003
+ const text = sel.active ? sel.text : "link text";
1004
+ h.replace(`[${text}](https://)`);
1005
+ }
1006
+ }),
1007
+ /** Heading. Defaults to H2. Pass a `level` (1–6) to override. */
1008
+ heading: (level = 2) => prependLineTool(
1009
+ `heading-${level}`,
1010
+ `${"#".repeat(level)} `,
1011
+ `H${level}`,
1012
+ /* @__PURE__ */ jsx4(HeadingIcon, {}),
1013
+ `Heading ${level}`
1014
+ ),
1015
+ bulletList: () => prependLineTool(
1016
+ "ul",
1017
+ "- ",
1018
+ "Bullet list",
1019
+ /* @__PURE__ */ jsx4(ListBulletedIcon, {}),
1020
+ "Bullet list"
1021
+ ),
1022
+ numberedList: () => prependLineTool(
1023
+ "ol",
1024
+ "1. ",
1025
+ "Numbered list",
1026
+ /* @__PURE__ */ jsx4(ListNumberedIcon, {}),
1027
+ "Numbered list"
1028
+ ),
1029
+ quote: () => prependLineTool(
1030
+ "quote",
1031
+ "> ",
1032
+ "Quote",
1033
+ /* @__PURE__ */ jsx4(QuotesIcon, {}),
1034
+ "Quote"
1035
+ ),
1036
+ undo: () => ({
1037
+ id: "undo",
1038
+ label: "Undo",
1039
+ icon: /* @__PURE__ */ jsx4(UndoIcon, {}),
1040
+ title: "Undo (\u2318Z)",
1041
+ onAction: (h) => h.undo()
1042
+ }),
1043
+ redo: () => ({
1044
+ id: "redo",
1045
+ label: "Redo",
1046
+ icon: /* @__PURE__ */ jsx4(RedoIcon, {}),
1047
+ title: "Redo (\u2318\u21E7Z)",
1048
+ onAction: (h) => h.redo()
1049
+ }),
1050
+ divider: (id = "divider") => ({
1051
+ id: `${id}-${Math.random().toString(36).slice(2, 8)}`,
1052
+ label: "",
1053
+ kind: "divider"
1054
+ })
1055
+ };
1056
+
1057
+ // src/components/Textarea/Textarea.tsx
1058
+ import {
1059
+ forwardRef as forwardRef4,
1060
+ useEffect as useEffect3,
1061
+ useId as useId2,
1062
+ useRef as useRef3,
1063
+ useState as useState4
1064
+ } from "react";
1065
+ import { useTextField } from "react-aria";
1066
+ import { createPortal } from "react-dom";
1067
+ import { CopyIcon, CutIcon } from "@octaviaflow/icons";
1068
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1069
+ var Textarea = forwardRef4(
1070
+ function Textarea2({
1071
+ label,
1072
+ error = false,
1073
+ errorMessage,
1074
+ helperText,
1075
+ resize = "vertical",
1076
+ autoResize = false,
1077
+ minRows,
1078
+ maxRows,
1079
+ maxHeight,
1080
+ maxWidth,
1081
+ minHeight,
1082
+ minWidth,
1083
+ maxLength,
1084
+ size = "md",
1085
+ rows = 3,
1086
+ disabled = false,
1087
+ className,
1088
+ style: consumerStyle,
1089
+ defaultValue,
1090
+ value,
1091
+ onChange,
1092
+ id: providedId,
1093
+ commands,
1094
+ commandTrigger = "/",
1095
+ selectionToolbar = false,
1096
+ selectionActions,
1097
+ tools,
1098
+ toolbarPosition = "top",
1099
+ ...props
1100
+ }, forwardedRef) {
1101
+ const innerRef = useRef3(null);
1102
+ const setRef = (node) => {
1103
+ innerRef.current = node;
1104
+ if (typeof forwardedRef === "function") forwardedRef(node);
1105
+ else if (forwardedRef)
1106
+ forwardedRef.current = node;
1107
+ };
1108
+ const reactId = useId2();
1109
+ const baseId = providedId ?? `ods-textarea-${reactId}`;
1110
+ const hintId = error && errorMessage || helperText ? `${baseId}-hint` : void 0;
1111
+ const [charCount, setCharCount] = useState4(
1112
+ () => String(value ?? defaultValue ?? "").length
1113
+ );
1114
+ const ariaNameProps = resolveAccessibleName({
1115
+ label: typeof label === "string" ? label : void 0,
1116
+ ariaLabel: props["aria-label"],
1117
+ ariaLabelledby: props["aria-labelledby"],
1118
+ componentName: "Textarea"
1119
+ });
1120
+ const { labelProps, inputProps } = useTextField(
1121
+ {
1122
+ label: typeof label === "string" ? label : void 0,
1123
+ ...ariaNameProps,
1124
+ isDisabled: disabled,
1125
+ errorMessage: typeof errorMessage === "string" ? errorMessage : void 0,
1126
+ validationState: error ? "invalid" : void 0,
1127
+ inputElementType: "textarea",
1128
+ value,
1129
+ defaultValue
1130
+ },
1131
+ innerRef
1132
+ );
1133
+ const describedBy = [
1134
+ props["aria-describedby"],
1135
+ hintId
1136
+ ].filter(Boolean).join(" ") || void 0;
1137
+ const handleChange = (e) => {
1138
+ setCharCount(e.target.value.length);
1139
+ onChange?.(e);
1140
+ };
1141
+ const [liveValue, setLiveValue] = useState4(
1142
+ String(value ?? defaultValue ?? "")
1143
+ );
1144
+ useEffect3(() => {
1145
+ if (value != null) setLiveValue(String(value));
1146
+ }, [value]);
1147
+ const handleChangeWithMirror = (e) => {
1148
+ setLiveValue(e.target.value);
1149
+ handleChange(e);
1150
+ };
1151
+ const setLiveAndCommit = (next) => {
1152
+ setLiveValue(next);
1153
+ if (innerRef.current) innerRef.current.value = next;
1154
+ onChange?.({
1155
+ target: innerRef.current,
1156
+ currentTarget: innerRef.current
1157
+ });
1158
+ setCharCount(next.length);
1159
+ };
1160
+ const cmdPalette = useTextareaCommands({
1161
+ textareaRef: innerRef,
1162
+ value: liveValue,
1163
+ onChange: setLiveAndCommit,
1164
+ commands: commands ?? [],
1165
+ trigger: commandTrigger
1166
+ });
1167
+ const cmdEnabled = (commands?.length ?? 0) > 0;
1168
+ const sel = useTextareaSelection({
1169
+ textareaRef: innerRef,
1170
+ value: liveValue,
1171
+ onChange: setLiveAndCommit
1172
+ });
1173
+ const toolbar = useTextareaTools({
1174
+ textareaRef: innerRef,
1175
+ value: liveValue,
1176
+ onChange: setLiveAndCommit,
1177
+ tools: tools ?? []
1178
+ });
1179
+ const toolbarEnabled = (tools?.length ?? 0) > 0;
1180
+ const handleKeyDownWithCommands = (e) => {
1181
+ if (cmdEnabled) {
1182
+ const consumed = cmdPalette.onKeyDown(e);
1183
+ if (consumed) return;
1184
+ }
1185
+ props.onKeyDown?.(e);
1186
+ };
1187
+ useEffect3(() => {
1188
+ if (!autoResize) return;
1189
+ const el = innerRef.current;
1190
+ if (!el) return;
1191
+ const computed = window.getComputedStyle(el);
1192
+ const fontSize = parseFloat(computed.fontSize) || 16;
1193
+ const lhRaw = computed.lineHeight;
1194
+ const lh = lhRaw === "normal" ? fontSize * 1.2 : lhRaw.endsWith("px") ? parseFloat(lhRaw) : parseFloat(lhRaw) * fontSize;
1195
+ const padding = parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom);
1196
+ const rowCap = maxRows != null && Number.isFinite(maxRows) ? lh * maxRows + padding : Number.POSITIVE_INFINITY;
1197
+ const pixelCap = typeof maxHeight === "number" ? maxHeight : Number.POSITIVE_INFINITY;
1198
+ const effectiveMax = Math.min(rowCap, pixelCap);
1199
+ const rowFloor = lh * (minRows ?? rows) + padding;
1200
+ el.style.height = "auto";
1201
+ const target = Math.max(
1202
+ rowFloor,
1203
+ Math.min(effectiveMax, el.scrollHeight)
1204
+ );
1205
+ el.style.height = `${target}px`;
1206
+ el.style.overflowY = el.scrollHeight > effectiveMax ? "auto" : "hidden";
1207
+ }, [autoResize, value, defaultValue, minRows, maxRows, maxHeight, rows]);
1208
+ const resolvedResize = typeof resize === "boolean" ? resize ? "vertical" : "none" : resize;
1209
+ const toCss = (v) => v == null ? void 0 : typeof v === "number" ? `${v}px` : v;
1210
+ const fieldStyle = {
1211
+ maxHeight: toCss(maxHeight),
1212
+ maxWidth: toCss(maxWidth),
1213
+ minHeight: toCss(minHeight),
1214
+ minWidth: toCss(minWidth),
1215
+ resize: resolvedResize
1216
+ };
1217
+ return /* @__PURE__ */ jsxs3(
1218
+ "div",
1219
+ {
1220
+ className: cn(
1221
+ "ods-textarea",
1222
+ `ods-textarea--${size}`,
1223
+ `ods-textarea--resize-${resolvedResize}`,
1224
+ autoResize && "ods-textarea--auto-resize",
1225
+ error && "ods-textarea--error",
1226
+ disabled && "ods-textarea--disabled",
1227
+ className
1228
+ ),
1229
+ style: consumerStyle,
1230
+ children: [
1231
+ label && /* @__PURE__ */ jsx5(
1232
+ "label",
1233
+ {
1234
+ ...labelProps,
1235
+ htmlFor: baseId,
1236
+ className: "ods-textarea__label",
1237
+ children: label
1238
+ }
1239
+ ),
1240
+ toolbarEnabled && toolbarPosition === "top" && /* @__PURE__ */ jsx5(
1241
+ TextareaToolbar,
1242
+ {
1243
+ tools: toolbar.tools,
1244
+ onRun: toolbar.runTool
1245
+ }
1246
+ ),
1247
+ /* @__PURE__ */ jsxs3("div", { className: "ods-textarea__wrapper", children: [
1248
+ /* @__PURE__ */ jsx5(
1249
+ "textarea",
1250
+ {
1251
+ ...props,
1252
+ ...inputProps,
1253
+ ref: setRef,
1254
+ id: baseId,
1255
+ rows: autoResize ? minRows ?? rows : rows,
1256
+ disabled,
1257
+ maxLength,
1258
+ defaultValue,
1259
+ value,
1260
+ onChange: handleChangeWithMirror,
1261
+ onKeyDown: handleKeyDownWithCommands,
1262
+ className: "ods-textarea__field",
1263
+ style: fieldStyle,
1264
+ "aria-invalid": error || void 0,
1265
+ "aria-describedby": describedBy,
1266
+ "aria-autocomplete": cmdEnabled ? "list" : void 0,
1267
+ "aria-expanded": cmdEnabled ? cmdPalette.isOpen : void 0,
1268
+ "aria-controls": cmdEnabled && cmdPalette.isOpen ? `${baseId}-cmd-list` : void 0,
1269
+ "aria-activedescendant": cmdEnabled && cmdPalette.isOpen && cmdPalette.items[cmdPalette.activeIndex] ? `${baseId}-cmd-${cmdPalette.items[cmdPalette.activeIndex].id}` : void 0
1270
+ }
1271
+ ),
1272
+ cmdEnabled && cmdPalette.isOpen && cmdPalette.items.length > 0 && typeof document !== "undefined" && createPortal(
1273
+ /* @__PURE__ */ jsx5(
1274
+ "ul",
1275
+ {
1276
+ id: `${baseId}-cmd-list`,
1277
+ role: "listbox",
1278
+ "aria-label": "Inline commands",
1279
+ className: "ods-textarea__cmd-popover",
1280
+ style: {
1281
+ position: "fixed",
1282
+ top: (cmdPalette.caretRect?.bottom ?? 0) + 6,
1283
+ left: cmdPalette.caretRect?.left ?? 0
1284
+ },
1285
+ children: cmdPalette.items.map((c, i) => /* @__PURE__ */ jsxs3(
1286
+ "li",
1287
+ {
1288
+ id: `${baseId}-cmd-${c.id}`,
1289
+ role: "option",
1290
+ "aria-selected": i === cmdPalette.activeIndex,
1291
+ className: cn(
1292
+ "ods-textarea__cmd-item",
1293
+ i === cmdPalette.activeIndex && "ods-textarea__cmd-item--active"
1294
+ ),
1295
+ onMouseDown: (e) => {
1296
+ e.preventDefault();
1297
+ cmdPalette.commit(c);
1298
+ },
1299
+ onMouseEnter: () => {
1300
+ },
1301
+ children: [
1302
+ c.icon && /* @__PURE__ */ jsx5("span", { className: "ods-textarea__cmd-icon", children: c.icon }),
1303
+ /* @__PURE__ */ jsxs3("span", { className: "ods-textarea__cmd-text", children: [
1304
+ /* @__PURE__ */ jsx5("span", { className: "ods-textarea__cmd-label", children: c.label }),
1305
+ c.description && /* @__PURE__ */ jsx5("span", { className: "ods-textarea__cmd-desc", children: c.description })
1306
+ ] })
1307
+ ]
1308
+ },
1309
+ c.id
1310
+ ))
1311
+ }
1312
+ ),
1313
+ document.body
1314
+ ),
1315
+ selectionToolbar && sel.active && sel.rect && typeof document !== "undefined" && createPortal(
1316
+ /* @__PURE__ */ jsxs3(
1317
+ "div",
1318
+ {
1319
+ role: "toolbar",
1320
+ "aria-label": "Selection actions",
1321
+ className: "ods-textarea__sel-toolbar",
1322
+ style: {
1323
+ position: "fixed",
1324
+ top: sel.rect.top - 36,
1325
+ left: sel.rect.left
1326
+ },
1327
+ onMouseDown: (e) => e.preventDefault(),
1328
+ children: [
1329
+ /* @__PURE__ */ jsx5(
1330
+ "button",
1331
+ {
1332
+ type: "button",
1333
+ className: "ods-textarea__sel-btn",
1334
+ onClick: () => sel.copy(),
1335
+ "aria-label": "Copy selection",
1336
+ title: "Copy",
1337
+ children: /* @__PURE__ */ jsx5(CopyIcon, { size: "xs" })
1338
+ }
1339
+ ),
1340
+ /* @__PURE__ */ jsx5(
1341
+ "button",
1342
+ {
1343
+ type: "button",
1344
+ className: "ods-textarea__sel-btn",
1345
+ onClick: () => sel.cut(),
1346
+ "aria-label": "Cut selection",
1347
+ title: "Cut",
1348
+ children: /* @__PURE__ */ jsx5(CutIcon, { size: "xs" })
1349
+ }
1350
+ ),
1351
+ selectionActions?.map((a) => /* @__PURE__ */ jsxs3(
1352
+ "button",
1353
+ {
1354
+ type: "button",
1355
+ className: "ods-textarea__sel-btn",
1356
+ onClick: () => a.onAction(sel.text, {
1357
+ replace: sel.replace,
1358
+ wrap: sel.wrap,
1359
+ copy: sel.copy,
1360
+ cut: sel.cut
1361
+ }),
1362
+ title: typeof a.label === "string" ? a.label : void 0,
1363
+ children: [
1364
+ a.icon,
1365
+ a.label && /* @__PURE__ */ jsx5("span", { className: "ods-textarea__sel-btn-label", children: a.label })
1366
+ ]
1367
+ },
1368
+ a.id
1369
+ ))
1370
+ ]
1371
+ }
1372
+ ),
1373
+ document.body
1374
+ ),
1375
+ maxLength != null && /* @__PURE__ */ jsxs3(
1376
+ "span",
1377
+ {
1378
+ className: "ods-textarea__count",
1379
+ "aria-live": charCount > maxLength ? "polite" : "off",
1380
+ children: [
1381
+ charCount,
1382
+ "/",
1383
+ maxLength
1384
+ ]
1385
+ }
1386
+ )
1387
+ ] }),
1388
+ toolbarEnabled && toolbarPosition === "bottom" && /* @__PURE__ */ jsx5(
1389
+ TextareaToolbar,
1390
+ {
1391
+ tools: toolbar.tools,
1392
+ onRun: toolbar.runTool
1393
+ }
1394
+ ),
1395
+ error && errorMessage ? /* @__PURE__ */ jsx5(
1396
+ "div",
1397
+ {
1398
+ id: hintId,
1399
+ className: "ods-textarea__error-message",
1400
+ role: "alert",
1401
+ children: errorMessage
1402
+ }
1403
+ ) : helperText ? /* @__PURE__ */ jsx5("div", { id: hintId, className: "ods-textarea__hint", children: helperText }) : null
1404
+ ]
1405
+ }
1406
+ );
1407
+ }
1408
+ );
1409
+ Textarea.displayName = "Textarea";
1410
+ function TextareaToolbar({
1411
+ tools,
1412
+ onRun
1413
+ }) {
1414
+ return /* @__PURE__ */ jsx5(
1415
+ "div",
1416
+ {
1417
+ role: "toolbar",
1418
+ "aria-label": "Formatting",
1419
+ className: "ods-textarea__toolbar",
1420
+ onMouseDown: (e) => {
1421
+ if (e.target.closest(".ods-textarea__toolbar-btn")) {
1422
+ e.preventDefault();
1423
+ }
1424
+ },
1425
+ children: tools.map((t) => {
1426
+ if (t.kind === "divider") {
1427
+ return /* @__PURE__ */ jsx5(
1428
+ "span",
1429
+ {
1430
+ className: "ods-textarea__toolbar-divider",
1431
+ "aria-hidden": "true"
1432
+ },
1433
+ t.id
1434
+ );
1435
+ }
1436
+ return /* @__PURE__ */ jsx5(
1437
+ "button",
1438
+ {
1439
+ type: "button",
1440
+ className: "ods-textarea__toolbar-btn",
1441
+ title: t.title ?? (typeof t.label === "string" ? t.label : void 0),
1442
+ "aria-label": typeof t.label === "string" ? t.label : t.id,
1443
+ onClick: () => onRun(t.id),
1444
+ children: t.icon ? /* @__PURE__ */ jsx5("span", { className: "ods-textarea__toolbar-icon", children: t.icon }) : /* @__PURE__ */ jsx5("span", { className: "ods-textarea__toolbar-text", children: t.label })
1445
+ },
1446
+ t.id
1447
+ );
1448
+ })
1449
+ }
1450
+ );
1451
+ }
1452
+
1453
+ // src/components/CountUp/CountUp.tsx
1454
+ import {
1455
+ forwardRef as forwardRef5,
1456
+ useEffect as useEffect4,
1457
+ useRef as useRef4,
1458
+ useState as useState5
1459
+ } from "react";
1460
+ import { jsxs as jsxs4 } from "react/jsx-runtime";
1461
+ var easeLinear = (t) => t;
1462
+ var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
1463
+ var easeOutQuart = (t) => 1 - Math.pow(1 - t, 4);
1464
+ var easeOutExpo = (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
1465
+ var CountUp = forwardRef5(
1466
+ function CountUp2({
1467
+ value,
1468
+ from = 0,
1469
+ duration = 800,
1470
+ easing = easeOutCubic,
1471
+ decimals = 0,
1472
+ formatValue,
1473
+ prefix,
1474
+ suffix,
1475
+ delay = 0,
1476
+ disableAnimation = false,
1477
+ onComplete,
1478
+ className,
1479
+ ...rest
1480
+ }, ref) {
1481
+ const [n, setN] = useState5(disableAnimation ? value : from);
1482
+ const lastRendered = useRef4(disableAnimation ? value : from);
1483
+ useEffect4(() => {
1484
+ const reduced = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
1485
+ if (disableAnimation || reduced) {
1486
+ setN(value);
1487
+ lastRendered.current = value;
1488
+ onComplete?.();
1489
+ return;
1490
+ }
1491
+ const startValue = lastRendered.current;
1492
+ const delta = value - startValue;
1493
+ if (delta === 0) return;
1494
+ let raf = null;
1495
+ let timeoutId = null;
1496
+ let startTime = null;
1497
+ let cancelled = false;
1498
+ const tick = (ts) => {
1499
+ if (cancelled) return;
1500
+ if (startTime === null) startTime = ts;
1501
+ const t = Math.min(1, (ts - startTime) / Math.max(1, duration));
1502
+ const eased = easing(t);
1503
+ const current = startValue + delta * eased;
1504
+ setN(current);
1505
+ lastRendered.current = current;
1506
+ if (t < 1) {
1507
+ raf = requestAnimationFrame(tick);
1508
+ } else {
1509
+ lastRendered.current = value;
1510
+ setN(value);
1511
+ onComplete?.();
1512
+ }
1513
+ };
1514
+ const start = () => {
1515
+ raf = requestAnimationFrame(tick);
1516
+ };
1517
+ if (delay > 0) {
1518
+ timeoutId = window.setTimeout(start, delay);
1519
+ } else {
1520
+ start();
1521
+ }
1522
+ return () => {
1523
+ cancelled = true;
1524
+ if (raf !== null) cancelAnimationFrame(raf);
1525
+ if (timeoutId !== null) window.clearTimeout(timeoutId);
1526
+ };
1527
+ }, [value, duration, delay, disableAnimation]);
1528
+ const display = formatValue ? formatValue(n) : n.toFixed(decimals);
1529
+ return /* @__PURE__ */ jsxs4(
1530
+ "span",
1531
+ {
1532
+ ...rest,
1533
+ ref,
1534
+ className: cn("ods-count-up", className),
1535
+ "aria-live": "polite",
1536
+ "aria-atomic": "true",
1537
+ children: [
1538
+ prefix,
1539
+ display,
1540
+ suffix
1541
+ ]
1542
+ }
1543
+ );
1544
+ }
1545
+ );
1546
+ CountUp.displayName = "CountUp";
1547
+
1548
+ // src/components/TestimonialCard/TestimonialCard.tsx
1549
+ import {
1550
+ QuotesIcon as QuotesIcon2,
1551
+ StarFilledIcon,
1552
+ StarIcon
1553
+ } from "@octaviaflow/icons";
1554
+ import {
1555
+ forwardRef as forwardRef6,
1556
+ useId as useId3
1557
+ } from "react";
1558
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1559
+ function isAuthorObject(v) {
1560
+ return typeof v === "object" && v !== null && !("type" in v) && // exclude React elements
1561
+ "name" in v;
1562
+ }
1563
+ var TestimonialCard = forwardRef6(function TestimonialCard2({
1564
+ quote,
1565
+ author,
1566
+ role: legacyRole,
1567
+ avatar: legacyAvatar,
1568
+ initial: legacyInitial,
1569
+ rating,
1570
+ logo,
1571
+ size = "md",
1572
+ radius = "md",
1573
+ id: providedId,
1574
+ className,
1575
+ ...rest
1576
+ }, ref) {
1577
+ const reactId = useId3();
1578
+ const baseId = providedId ?? `ods-testimonial-${reactId}`;
1579
+ const quoteId = `${baseId}-quote`;
1580
+ const authorId = `${baseId}-author`;
1581
+ const resolved = isAuthorObject(author) ? author : {
1582
+ name: author,
1583
+ role: legacyRole,
1584
+ avatar: legacyAvatar ? void 0 : {
1585
+ initials: typeof legacyInitial === "string" ? legacyInitial : typeof author === "string" ? author.charAt(0).toUpperCase() : void 0
1586
+ }
1587
+ };
1588
+ const renderAvatar = () => {
1589
+ if (!isAuthorObject(author) && legacyAvatar) {
1590
+ return /* @__PURE__ */ jsx6(
1591
+ "span",
1592
+ {
1593
+ className: "ods-testimonial__avatar ods-testimonial__avatar--legacy",
1594
+ "aria-hidden": "true",
1595
+ children: legacyAvatar
1596
+ }
1597
+ );
1598
+ }
1599
+ return /* @__PURE__ */ jsx6(
1600
+ Avatar,
1601
+ {
1602
+ size: size === "sm" ? "xs" : size === "lg" ? "md" : "sm",
1603
+ src: resolved.avatar?.src,
1604
+ initials: resolved.avatar?.initials,
1605
+ seed: resolved.avatar?.seed,
1606
+ palette: resolved.avatar?.palette,
1607
+ alt: resolved.avatar?.alt ?? (typeof resolved.name === "string" ? resolved.name : void 0),
1608
+ className: "ods-testimonial__avatar"
1609
+ }
1610
+ );
1611
+ };
1612
+ return /* @__PURE__ */ jsxs5(
1613
+ Card,
1614
+ {
1615
+ ...rest,
1616
+ ref,
1617
+ id: baseId,
1618
+ radius,
1619
+ padding: "none",
1620
+ variant: "subtle",
1621
+ className: cn(
1622
+ "ods-testimonial",
1623
+ `ods-testimonial--${size}`,
1624
+ className
1625
+ ),
1626
+ "aria-labelledby": authorId,
1627
+ "aria-describedby": quoteId,
1628
+ children: [
1629
+ /* @__PURE__ */ jsxs5("div", { className: "ods-testimonial__head", children: [
1630
+ /* @__PURE__ */ jsx6("span", { className: "ods-testimonial__quote", "aria-hidden": "true", children: /* @__PURE__ */ jsx6(QuotesIcon2, { size: "md" }) }),
1631
+ logo && /* @__PURE__ */ jsx6("span", { className: "ods-testimonial__logo", "aria-hidden": "true", children: logo })
1632
+ ] }),
1633
+ /* @__PURE__ */ jsx6("blockquote", { id: quoteId, className: "ods-testimonial__text", children: quote }),
1634
+ typeof rating === "number" && /* @__PURE__ */ jsx6(
1635
+ "div",
1636
+ {
1637
+ className: "ods-testimonial__rating",
1638
+ role: "img",
1639
+ "aria-label": `${rating} out of 5 stars`,
1640
+ children: Array.from({ length: 5 }).map(
1641
+ (_, i) => i < Math.round(rating) ? /* @__PURE__ */ jsx6(
1642
+ StarFilledIcon,
1643
+ {
1644
+ size: "xs",
1645
+ className: "ods-testimonial__star ods-testimonial__star--on"
1646
+ },
1647
+ i
1648
+ ) : /* @__PURE__ */ jsx6(
1649
+ StarIcon,
1650
+ {
1651
+ size: "xs",
1652
+ className: "ods-testimonial__star"
1653
+ },
1654
+ i
1655
+ )
1656
+ )
1657
+ }
1658
+ ),
1659
+ /* @__PURE__ */ jsxs5("figcaption", { className: "ods-testimonial__author", id: authorId, children: [
1660
+ renderAvatar(),
1661
+ /* @__PURE__ */ jsxs5("span", { className: "ods-testimonial__author-info", children: [
1662
+ /* @__PURE__ */ jsx6("span", { className: "ods-testimonial__author-name", children: resolved.name }),
1663
+ resolved.role && /* @__PURE__ */ jsx6("span", { className: "ods-testimonial__author-role", children: resolved.role })
1664
+ ] })
1665
+ ] })
1666
+ ]
1667
+ }
1668
+ );
1669
+ });
1670
+ TestimonialCard.displayName = "TestimonialCard";
1671
+
1672
+ export {
1673
+ Card,
1674
+ CardHeader,
1675
+ CardBody,
1676
+ CardFooter,
1677
+ CardTitle,
1678
+ CardDescription,
1679
+ AVATAR_PALETTE_SIZE,
1680
+ avatarPaletteIndex,
1681
+ Avatar,
1682
+ AvatarStack,
1683
+ BlogCard,
1684
+ useTextareaCommands,
1685
+ useTextareaSelection,
1686
+ useTextareaTools,
1687
+ textareaTools,
1688
+ Textarea,
1689
+ easeLinear,
1690
+ easeOutCubic,
1691
+ easeOutQuart,
1692
+ easeOutExpo,
1693
+ CountUp,
1694
+ TestimonialCard
1695
+ };
1696
+ //# sourceMappingURL=chunk-CVU6QDOL.js.map