@arbidocs/blocks 0.4.122 → 0.4.124

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 (123) hide show
  1. package/dist/{StreamedArtifactEditor-IZWYNFMM.cjs → StreamedArtifactEditor-DNBDUNP2.cjs} +5 -5
  2. package/dist/{StreamedArtifactEditor-IZWYNFMM.cjs.map → StreamedArtifactEditor-DNBDUNP2.cjs.map} +1 -1
  3. package/dist/{StreamedArtifactEditor-HTNPG4NB.js → StreamedArtifactEditor-WDHPTWX7.js} +3 -3
  4. package/dist/{StreamedArtifactEditor-HTNPG4NB.js.map → StreamedArtifactEditor-WDHPTWX7.js.map} +1 -1
  5. package/dist/agents/index.cjs +390 -326
  6. package/dist/agents/index.js +9 -9
  7. package/dist/agents/tasks/ConversationListView.d.ts +2 -1
  8. package/dist/agents/tasks/ConversationTurnSpeaker.d.ts +3 -1
  9. package/dist/agents/tasks/TaskFlow.d.ts +17 -0
  10. package/dist/agents/tasks/ThreadLauncher.d.ts +51 -0
  11. package/dist/agents/tasks/ThreadStatusLine.d.ts +33 -0
  12. package/dist/agents/tasks/WorkflowRunStatus.d.ts +32 -0
  13. package/dist/agents/tasks/WorkflowThreadStrip.d.ts +29 -3
  14. package/dist/agents/tasks/compact-thread-activity.d.ts +5 -2
  15. package/dist/agents/tasks/index.d.ts +3 -0
  16. package/dist/agents/workflows/StepBarFrame.d.ts +18 -17
  17. package/dist/agents/workflows/StepChip.d.ts +37 -0
  18. package/dist/agents/workflows/StepDocuments.d.ts +64 -0
  19. package/dist/agents/workflows/WorkflowStepBar.d.ts +1 -2
  20. package/dist/agents/workflows/index.d.ts +2 -0
  21. package/dist/agents/workflows/stepKinds.d.ts +24 -0
  22. package/dist/artifacts/VersionTimeline.d.ts +7 -0
  23. package/dist/artifacts/index.cjs +21 -21
  24. package/dist/artifacts/index.js +1 -1
  25. package/dist/chat/ChatPage.d.ts +1 -1
  26. package/dist/chat/DraftingDocChip.d.ts +22 -0
  27. package/dist/chat/WorkflowStepChip.d.ts +23 -5
  28. package/dist/chat/chat-page-types.d.ts +18 -2
  29. package/dist/chat/flashMessage.d.ts +6 -0
  30. package/dist/chat/index.cjs +144 -131
  31. package/dist/chat/index.d.ts +2 -0
  32. package/dist/chat/index.js +4 -3
  33. package/dist/{chunk-SHASZLGD.js → chunk-3AV7HP6G.js} +3 -3
  34. package/dist/{chunk-SHASZLGD.js.map → chunk-3AV7HP6G.js.map} +1 -1
  35. package/dist/{chunk-UDK553WP.cjs → chunk-4VCKYR4D.cjs} +4 -4
  36. package/dist/{chunk-UDK553WP.cjs.map → chunk-4VCKYR4D.cjs.map} +1 -1
  37. package/dist/chunk-7HAM7Y5U.js +907 -0
  38. package/dist/chunk-7HAM7Y5U.js.map +1 -0
  39. package/dist/{chunk-TCNYKDYE.js → chunk-CXLVI3SB.js} +73 -40
  40. package/dist/chunk-CXLVI3SB.js.map +1 -0
  41. package/dist/{chunk-N7ARMX3O.cjs → chunk-D7WCGOD4.cjs} +3 -3
  42. package/dist/{chunk-N7ARMX3O.cjs.map → chunk-D7WCGOD4.cjs.map} +1 -1
  43. package/dist/{chunk-ZP4IFW2E.js → chunk-EJSJ27HV.js} +733 -185
  44. package/dist/chunk-EJSJ27HV.js.map +1 -0
  45. package/dist/{chunk-AY32GGKU.js → chunk-ERNMU6RV.js} +132 -752
  46. package/dist/chunk-ERNMU6RV.js.map +1 -0
  47. package/dist/{chunk-XFZ7HNPG.js → chunk-ETN5EZI4.js} +3 -3
  48. package/dist/{chunk-XFZ7HNPG.js.map → chunk-ETN5EZI4.js.map} +1 -1
  49. package/dist/{chunk-Z2NSU7D5.cjs → chunk-FL5TEBTM.cjs} +770 -216
  50. package/dist/chunk-FL5TEBTM.cjs.map +1 -0
  51. package/dist/chunk-HM23LXUP.cjs +976 -0
  52. package/dist/chunk-HM23LXUP.cjs.map +1 -0
  53. package/dist/{chunk-WN64RF46.js → chunk-HQH35JWC.js} +3 -3
  54. package/dist/{chunk-WN64RF46.js.map → chunk-HQH35JWC.js.map} +1 -1
  55. package/dist/{chunk-XSUOEJB3.cjs → chunk-MRURIBBB.cjs} +163 -837
  56. package/dist/chunk-MRURIBBB.cjs.map +1 -0
  57. package/dist/{chunk-65HZ36MY.js → chunk-OTDGTBAS.js} +20 -3
  58. package/dist/chunk-OTDGTBAS.js.map +1 -0
  59. package/dist/{chunk-CK4C3IQR.cjs → chunk-VMZXFYHK.cjs} +47 -6
  60. package/dist/chunk-VMZXFYHK.cjs.map +1 -0
  61. package/dist/{chunk-SVJQWLOF.cjs → chunk-W4GXDARU.cjs} +20 -3
  62. package/dist/chunk-W4GXDARU.cjs.map +1 -0
  63. package/dist/{chunk-US5ASM4G.cjs → chunk-WEUCLOBB.cjs} +5 -5
  64. package/dist/{chunk-US5ASM4G.cjs.map → chunk-WEUCLOBB.cjs.map} +1 -1
  65. package/dist/{chunk-S2KVJYBD.cjs → chunk-WV4IDVDQ.cjs} +76 -43
  66. package/dist/chunk-WV4IDVDQ.cjs.map +1 -0
  67. package/dist/{chunk-2FUJXMGO.js → chunk-Y4X3RBFI.js} +44 -6
  68. package/dist/{chunk-CK4C3IQR.cjs.map → chunk-Y4X3RBFI.js.map} +1 -1
  69. package/dist/collaboration/index.cjs +1 -1
  70. package/dist/collaboration/index.js +1 -1
  71. package/dist/connect/docx.cjs +4 -4
  72. package/dist/connect/docx.js +3 -3
  73. package/dist/connect/index.cjs +68 -51
  74. package/dist/connect/index.cjs.map +1 -1
  75. package/dist/connect/index.js +37 -20
  76. package/dist/connect/index.js.map +1 -1
  77. package/dist/connection/WorkflowRunThread.d.ts +4 -4
  78. package/dist/connection/ai.d.ts +2 -0
  79. package/dist/facts/index.cjs +1 -1
  80. package/dist/facts/index.js +1 -1
  81. package/dist/files/index.cjs +3 -3
  82. package/dist/files/index.js +3 -3
  83. package/dist/index.cjs +728 -652
  84. package/dist/index.js +16 -16
  85. package/dist/settings/index.cjs +1 -1
  86. package/dist/settings/index.js +1 -1
  87. package/dist/shell/index.cjs +10 -10
  88. package/dist/shell/index.js +2 -2
  89. package/dist/site/index.cjs +5 -5
  90. package/dist/site/index.js +1 -1
  91. package/dist/studio/index.cjs +6 -5
  92. package/dist/studio/index.cjs.map +1 -1
  93. package/dist/studio/index.js +5 -4
  94. package/dist/studio/index.js.map +1 -1
  95. package/dist/workflow-canvas/WorkflowCanvas.d.ts +0 -9
  96. package/dist/workflow-canvas/edit.d.ts +2 -11
  97. package/dist/workflow-canvas/index.cjs +63 -87
  98. package/dist/workflow-canvas/index.cjs.map +1 -1
  99. package/dist/workflow-canvas/index.js +14 -38
  100. package/dist/workflow-canvas/index.js.map +1 -1
  101. package/node_modules/@arbidocs/coedit/dist/commands.cjs +25 -13
  102. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  103. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +3 -1
  104. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +3 -1
  105. package/node_modules/@arbidocs/coedit/dist/commands.js +25 -14
  106. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  107. package/node_modules/@arbidocs/coedit/package.json +1 -1
  108. package/package.json +4 -4
  109. package/src/blocks.css +168 -0
  110. package/src/workflow-canvas/canvas.css +2 -40
  111. package/dist/chunk-2FUJXMGO.js.map +0 -1
  112. package/dist/chunk-65HZ36MY.js.map +0 -1
  113. package/dist/chunk-AY32GGKU.js.map +0 -1
  114. package/dist/chunk-B4SRYJLM.cjs +0 -107
  115. package/dist/chunk-B4SRYJLM.cjs.map +0 -1
  116. package/dist/chunk-HOXKR26S.js +0 -103
  117. package/dist/chunk-HOXKR26S.js.map +0 -1
  118. package/dist/chunk-S2KVJYBD.cjs.map +0 -1
  119. package/dist/chunk-SVJQWLOF.cjs.map +0 -1
  120. package/dist/chunk-TCNYKDYE.js.map +0 -1
  121. package/dist/chunk-XSUOEJB3.cjs.map +0 -1
  122. package/dist/chunk-Z2NSU7D5.cjs.map +0 -1
  123. package/dist/chunk-ZP4IFW2E.js.map +0 -1
@@ -1,107 +0,0 @@
1
- "use client";
2
- 'use strict';
3
-
4
- var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
5
- var chunkPPCATBOY_cjs = require('./chunk-PPCATBOY.cjs');
6
- var react = require('react');
7
-
8
- function useMentionAutocomplete({
9
- value,
10
- onValueChange,
11
- candidates,
12
- textareaRef
13
- }) {
14
- const [caret, setCaret] = react.useState(null);
15
- const [dismissedAt, setDismissedAt] = react.useState(null);
16
- react.useEffect(() => {
17
- if (dismissedAt !== null && value[dismissedAt] !== "@") setDismissedAt(null);
18
- }, [value, dismissedAt]);
19
- const match = react.useMemo(() => {
20
- if (caret === null) return null;
21
- const query = chunk7UTB4PHM_cjs.findMentionQuery(value, Math.min(caret, value.length));
22
- return query && candidates.some((candidate) => query.query === `${candidate.label} `) ? null : query;
23
- }, [value, caret, candidates]);
24
- const items = react.useMemo(
25
- () => match ? chunk7UTB4PHM_cjs.filterMentionCandidates(candidates, match.query) : [],
26
- [match, candidates]
27
- );
28
- const isOpen = !!match && items.length > 0 && dismissedAt !== match.start;
29
- const readCaret = react.useCallback(() => {
30
- const ta = textareaRef.current;
31
- setCaret(ta ? ta.selectionStart : null);
32
- }, [textareaRef]);
33
- const pick = react.useCallback(
34
- (candidate) => {
35
- if (!match || caret === null) return;
36
- const next = chunk7UTB4PHM_cjs.insertMention(value, match.start, Math.min(caret, value.length), candidate.label);
37
- onValueChange(next.text);
38
- setCaret(next.caret);
39
- setDismissedAt(match.start);
40
- requestAnimationFrame(() => {
41
- const ta = textareaRef.current;
42
- if (!ta) return;
43
- ta.focus();
44
- ta.setSelectionRange(next.caret, next.caret);
45
- });
46
- },
47
- [match, caret, value, onValueChange, textareaRef]
48
- );
49
- const nav = chunk7UTB4PHM_cjs.useListKeyNav({
50
- open: isOpen,
51
- items,
52
- onPick: pick,
53
- onDismiss: () => setDismissedAt(match?.start ?? null),
54
- resetKey: match?.query
55
- });
56
- const handleValueChange = react.useCallback(
57
- (next) => {
58
- onValueChange(next);
59
- const ta = textareaRef.current;
60
- setCaret(ta ? ta.selectionStart : next.length);
61
- if (dismissedAt !== null && (next.length < value.length || next[dismissedAt] !== "@")) {
62
- setDismissedAt(null);
63
- }
64
- },
65
- [onValueChange, textareaRef, dismissedAt, value]
66
- );
67
- return {
68
- isOpen,
69
- items,
70
- nav,
71
- pick,
72
- onValueChange: handleValueChange,
73
- textareaProps: { onSelect: readCaret }
74
- };
75
- }
76
- function useElementSize(ref) {
77
- const [size, setSize] = react.useState({ width: 0, height: 0 });
78
- react.useLayoutEffect(() => {
79
- const el = ref.current;
80
- if (!el) return;
81
- const measure = () => {
82
- const rect = el.getBoundingClientRect();
83
- setSize(
84
- (prev) => prev.width === rect.width && prev.height === rect.height ? prev : { width: rect.width, height: rect.height }
85
- );
86
- };
87
- measure();
88
- window.addEventListener("resize", measure);
89
- const stopObserving = chunkPPCATBOY_cjs.observeResize(el, measure);
90
- return () => {
91
- window.removeEventListener("resize", measure);
92
- stopObserving();
93
- };
94
- }, [ref]);
95
- return size;
96
- }
97
- function rootFontSizePx() {
98
- if (typeof document === "undefined") return 16;
99
- const size = parseFloat(getComputedStyle(document.documentElement).fontSize);
100
- return Number.isFinite(size) && size > 0 ? size : 16;
101
- }
102
-
103
- exports.rootFontSizePx = rootFontSizePx;
104
- exports.useElementSize = useElementSize;
105
- exports.useMentionAutocomplete = useMentionAutocomplete;
106
- //# sourceMappingURL=chunk-B4SRYJLM.cjs.map
107
- //# sourceMappingURL=chunk-B4SRYJLM.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/chat/useMentionAutocomplete.ts","../src/lib/useElementSize.ts"],"names":["useState","useEffect","useMemo","findMentionQuery","filterMentionCandidates","useCallback","insertMention","useListKeyNav","useLayoutEffect","observeResize"],"mappings":";;;;;;AA6CO,SAAS,sBAAA,CAAuB;AAAA,EACrC,KAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA;AAC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AA,CAAc,EAAA,EAAI,OAAO,CAAA;AAC/C,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,OAAO,CAAA;AAC5C,MAAA,aAAA,EAAc;AAAA,IAChB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AACR,EAAA,OAAO,IAAA;AACT;AAGO,SAAS,cAAA,GAAyB;AACvC,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,EAAA;AAC5C,EAAA,MAAM,OAAO,UAAA,CAAW,gBAAA,CAAiB,QAAA,CAAS,eAAe,EAAE,QAAQ,CAAA;AAC3E,EAAA,OAAO,OAAO,QAAA,CAAS,IAAI,CAAA,IAAK,IAAA,GAAO,IAAI,IAAA,GAAO,EAAA;AACpD","file":"chunk-B4SRYJLM.cjs","sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useState,\n type RefObject,\n type SyntheticEvent,\n} from 'react'\nimport { useListKeyNav, type UseListKeyNav } from '../lib/useListKeyNav'\nimport {\n filterMentionCandidates,\n findMentionQuery,\n insertMention,\n type MentionCandidate,\n} from './mentions'\n\nexport interface UseMentionAutocompleteOptions {\n /** The draft. */\n value: string\n /** Writes the draft (the same setter the composer uses). */\n onValueChange: (next: string) => void\n /** Who can be mentioned: workspace members and the assistant. */\n candidates: ReadonlyArray<MentionCandidate>\n /** The composer textarea; read for the caret and refocused after a pick. */\n textareaRef: RefObject<HTMLTextAreaElement | null>\n}\n\nexport interface UseMentionAutocomplete {\n isOpen: boolean\n /** Filtered candidates for the `@query` at the caret. */\n items: MentionCandidate[]\n /** Keyboard navigation; call `nav.handleKeyDown` first in the textarea's `onKeyDown`. */\n nav: UseListKeyNav\n /** Insert a candidate in place of the `@query`. */\n pick: (candidate: MentionCandidate) => void\n /** Wrap the composer's `onValueChange` with this so the caret is tracked as the user types. */\n onValueChange: (next: string) => void\n /** Spread onto the textarea (via `textareaProps`): tracks caret moves (clicks, arrows). */\n textareaProps: { onSelect: (event: SyntheticEvent<HTMLTextAreaElement>) => void }\n}\n\n/**\n * Headless `@mention` autocomplete for a textarea: finds the `@query` at the caret, filters the\n * candidates, and on pick replaces the query with `@<label> `. Pair with {@link MentionMenu}.\n */\nexport function useMentionAutocomplete({\n value,\n onValueChange,\n candidates,\n textareaRef,\n}: UseMentionAutocompleteOptions): UseMentionAutocomplete {\n const [caret, setCaret] = useState<number | null>(null)\n // Escape dismisses the menu for the `@` it was opened at, until the user starts another one.\n const [dismissedAt, setDismissedAt] = useState<number | null>(null)\n\n // The draft can change from outside (cleared on send, restored on error): once the dismissed\n // `@` is gone, re-arm so the next `@` there opens the menu again.\n useEffect(() => {\n if (dismissedAt !== null && value[dismissedAt] !== '@') setDismissedAt(null)\n }, [value, dismissedAt])\n\n const match = useMemo(() => {\n if (caret === null) return null\n const query = findMentionQuery(value, Math.min(caret, value.length))\n // A completed recipient followed by a space is no longer an autocomplete query.\n return query && candidates.some((candidate) => query.query === `${candidate.label} `)\n ? null\n : query\n }, [value, caret, candidates])\n const items = useMemo(\n () => (match ? filterMentionCandidates(candidates, match.query) : []),\n [match, candidates]\n )\n const isOpen = !!match && items.length > 0 && dismissedAt !== match.start\n\n const readCaret = useCallback(() => {\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : null)\n }, [textareaRef])\n\n const pick = useCallback(\n (candidate: MentionCandidate) => {\n if (!match || caret === null) return\n const next = insertMention(value, match.start, Math.min(caret, value.length), candidate.label)\n onValueChange(next.text)\n setCaret(next.caret)\n // The inserted `@<label> ` is complete: keep the menu shut for this `@`.\n setDismissedAt(match.start)\n requestAnimationFrame(() => {\n const ta = textareaRef.current\n if (!ta) return\n ta.focus()\n ta.setSelectionRange(next.caret, next.caret)\n })\n },\n [match, caret, value, onValueChange, textareaRef]\n )\n\n const nav = useListKeyNav({\n open: isOpen,\n items,\n onPick: pick,\n onDismiss: () => setDismissedAt(match?.start ?? null),\n resetKey: match?.query,\n })\n\n const handleValueChange = useCallback(\n (next: string) => {\n onValueChange(next)\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : next.length)\n // Deleting text (or the `@` itself) re-arms the menu: the user is editing that mention.\n if (dismissedAt !== null && (next.length < value.length || next[dismissedAt] !== '@')) {\n setDismissedAt(null)\n }\n },\n [onValueChange, textareaRef, dismissedAt, value]\n )\n\n return {\n isOpen,\n items,\n nav,\n pick,\n onValueChange: handleValueChange,\n textareaProps: { onSelect: readCaret },\n }\n}\n","import { useLayoutEffect, useState, type RefObject } from 'react'\nimport { observeResize } from './observe-resize'\n\nexport interface ElementSize {\n width: number\n height: number\n}\n\n/**\n * The border-box size of an element, kept current with a ResizeObserver. It is measured before\n * the first paint (layout effect), so a layout that depends on it never flashes the wrong mode.\n * Window resize is listened to as well (a no-ResizeObserver engine, jsdom, still re-measures).\n */\nexport function useElementSize<T extends HTMLElement>(ref: RefObject<T | null>): ElementSize {\n const [size, setSize] = useState<ElementSize>({ width: 0, height: 0 })\n useLayoutEffect(() => {\n const el = ref.current\n if (!el) return\n const measure = () => {\n const rect = el.getBoundingClientRect()\n setSize((prev) =>\n prev.width === rect.width && prev.height === rect.height\n ? prev\n : { width: rect.width, height: rect.height }\n )\n }\n measure()\n window.addEventListener('resize', measure)\n const stopObserving = observeResize(el, measure)\n return () => {\n window.removeEventListener('resize', measure)\n stopObserving()\n }\n }, [ref])\n return size\n}\n\n/** The root font size in px (what `rem` means), 16 when it cannot be read. */\nexport function rootFontSizePx(): number {\n if (typeof document === 'undefined') return 16\n const size = parseFloat(getComputedStyle(document.documentElement).fontSize)\n return Number.isFinite(size) && size > 0 ? size : 16\n}\n"]}
@@ -1,103 +0,0 @@
1
- "use client";
2
- import { findMentionQuery, filterMentionCandidates, insertMention, useListKeyNav } from './chunk-AA3PT6KR.js';
3
- import { observeResize } from './chunk-NPLYHR2E.js';
4
- import { useState, useEffect, useMemo, useCallback, useLayoutEffect } from 'react';
5
-
6
- function useMentionAutocomplete({
7
- value,
8
- onValueChange,
9
- candidates,
10
- textareaRef
11
- }) {
12
- const [caret, setCaret] = useState(null);
13
- const [dismissedAt, setDismissedAt] = useState(null);
14
- useEffect(() => {
15
- if (dismissedAt !== null && value[dismissedAt] !== "@") setDismissedAt(null);
16
- }, [value, dismissedAt]);
17
- const match = useMemo(() => {
18
- if (caret === null) return null;
19
- const query = findMentionQuery(value, Math.min(caret, value.length));
20
- return query && candidates.some((candidate) => query.query === `${candidate.label} `) ? null : query;
21
- }, [value, caret, candidates]);
22
- const items = useMemo(
23
- () => match ? filterMentionCandidates(candidates, match.query) : [],
24
- [match, candidates]
25
- );
26
- const isOpen = !!match && items.length > 0 && dismissedAt !== match.start;
27
- const readCaret = useCallback(() => {
28
- const ta = textareaRef.current;
29
- setCaret(ta ? ta.selectionStart : null);
30
- }, [textareaRef]);
31
- const pick = useCallback(
32
- (candidate) => {
33
- if (!match || caret === null) return;
34
- const next = insertMention(value, match.start, Math.min(caret, value.length), candidate.label);
35
- onValueChange(next.text);
36
- setCaret(next.caret);
37
- setDismissedAt(match.start);
38
- requestAnimationFrame(() => {
39
- const ta = textareaRef.current;
40
- if (!ta) return;
41
- ta.focus();
42
- ta.setSelectionRange(next.caret, next.caret);
43
- });
44
- },
45
- [match, caret, value, onValueChange, textareaRef]
46
- );
47
- const nav = useListKeyNav({
48
- open: isOpen,
49
- items,
50
- onPick: pick,
51
- onDismiss: () => setDismissedAt(match?.start ?? null),
52
- resetKey: match?.query
53
- });
54
- const handleValueChange = useCallback(
55
- (next) => {
56
- onValueChange(next);
57
- const ta = textareaRef.current;
58
- setCaret(ta ? ta.selectionStart : next.length);
59
- if (dismissedAt !== null && (next.length < value.length || next[dismissedAt] !== "@")) {
60
- setDismissedAt(null);
61
- }
62
- },
63
- [onValueChange, textareaRef, dismissedAt, value]
64
- );
65
- return {
66
- isOpen,
67
- items,
68
- nav,
69
- pick,
70
- onValueChange: handleValueChange,
71
- textareaProps: { onSelect: readCaret }
72
- };
73
- }
74
- function useElementSize(ref) {
75
- const [size, setSize] = useState({ width: 0, height: 0 });
76
- useLayoutEffect(() => {
77
- const el = ref.current;
78
- if (!el) return;
79
- const measure = () => {
80
- const rect = el.getBoundingClientRect();
81
- setSize(
82
- (prev) => prev.width === rect.width && prev.height === rect.height ? prev : { width: rect.width, height: rect.height }
83
- );
84
- };
85
- measure();
86
- window.addEventListener("resize", measure);
87
- const stopObserving = observeResize(el, measure);
88
- return () => {
89
- window.removeEventListener("resize", measure);
90
- stopObserving();
91
- };
92
- }, [ref]);
93
- return size;
94
- }
95
- function rootFontSizePx() {
96
- if (typeof document === "undefined") return 16;
97
- const size = parseFloat(getComputedStyle(document.documentElement).fontSize);
98
- return Number.isFinite(size) && size > 0 ? size : 16;
99
- }
100
-
101
- export { rootFontSizePx, useElementSize, useMentionAutocomplete };
102
- //# sourceMappingURL=chunk-HOXKR26S.js.map
103
- //# sourceMappingURL=chunk-HOXKR26S.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/chat/useMentionAutocomplete.ts","../src/lib/useElementSize.ts"],"names":["useState"],"mappings":";;;;AA6CO,SAAS,sBAAA,CAAuB;AAAA,EACrC,KAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,EAA0D;AACxD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAwB,IAAI,CAAA;AAEtD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAwB,IAAI,CAAA;AAIlE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,gBAAgB,IAAA,IAAQ,KAAA,CAAM,WAAW,CAAA,KAAM,GAAA,iBAAoB,IAAI,CAAA;AAAA,EAC7E,CAAA,EAAG,CAAC,KAAA,EAAO,WAAW,CAAC,CAAA;AAEvB,EAAA,MAAM,KAAA,GAAQ,QAAQ,MAAM;AAC1B,IAAA,IAAI,KAAA,KAAU,MAAM,OAAO,IAAA;AAC3B,IAAA,MAAM,KAAA,GAAQ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ACpD","file":"chunk-HOXKR26S.js","sourcesContent":["import {\n useCallback,\n useEffect,\n useMemo,\n useState,\n type RefObject,\n type SyntheticEvent,\n} from 'react'\nimport { useListKeyNav, type UseListKeyNav } from '../lib/useListKeyNav'\nimport {\n filterMentionCandidates,\n findMentionQuery,\n insertMention,\n type MentionCandidate,\n} from './mentions'\n\nexport interface UseMentionAutocompleteOptions {\n /** The draft. */\n value: string\n /** Writes the draft (the same setter the composer uses). */\n onValueChange: (next: string) => void\n /** Who can be mentioned: workspace members and the assistant. */\n candidates: ReadonlyArray<MentionCandidate>\n /** The composer textarea; read for the caret and refocused after a pick. */\n textareaRef: RefObject<HTMLTextAreaElement | null>\n}\n\nexport interface UseMentionAutocomplete {\n isOpen: boolean\n /** Filtered candidates for the `@query` at the caret. */\n items: MentionCandidate[]\n /** Keyboard navigation; call `nav.handleKeyDown` first in the textarea's `onKeyDown`. */\n nav: UseListKeyNav\n /** Insert a candidate in place of the `@query`. */\n pick: (candidate: MentionCandidate) => void\n /** Wrap the composer's `onValueChange` with this so the caret is tracked as the user types. */\n onValueChange: (next: string) => void\n /** Spread onto the textarea (via `textareaProps`): tracks caret moves (clicks, arrows). */\n textareaProps: { onSelect: (event: SyntheticEvent<HTMLTextAreaElement>) => void }\n}\n\n/**\n * Headless `@mention` autocomplete for a textarea: finds the `@query` at the caret, filters the\n * candidates, and on pick replaces the query with `@<label> `. Pair with {@link MentionMenu}.\n */\nexport function useMentionAutocomplete({\n value,\n onValueChange,\n candidates,\n textareaRef,\n}: UseMentionAutocompleteOptions): UseMentionAutocomplete {\n const [caret, setCaret] = useState<number | null>(null)\n // Escape dismisses the menu for the `@` it was opened at, until the user starts another one.\n const [dismissedAt, setDismissedAt] = useState<number | null>(null)\n\n // The draft can change from outside (cleared on send, restored on error): once the dismissed\n // `@` is gone, re-arm so the next `@` there opens the menu again.\n useEffect(() => {\n if (dismissedAt !== null && value[dismissedAt] !== '@') setDismissedAt(null)\n }, [value, dismissedAt])\n\n const match = useMemo(() => {\n if (caret === null) return null\n const query = findMentionQuery(value, Math.min(caret, value.length))\n // A completed recipient followed by a space is no longer an autocomplete query.\n return query && candidates.some((candidate) => query.query === `${candidate.label} `)\n ? null\n : query\n }, [value, caret, candidates])\n const items = useMemo(\n () => (match ? filterMentionCandidates(candidates, match.query) : []),\n [match, candidates]\n )\n const isOpen = !!match && items.length > 0 && dismissedAt !== match.start\n\n const readCaret = useCallback(() => {\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : null)\n }, [textareaRef])\n\n const pick = useCallback(\n (candidate: MentionCandidate) => {\n if (!match || caret === null) return\n const next = insertMention(value, match.start, Math.min(caret, value.length), candidate.label)\n onValueChange(next.text)\n setCaret(next.caret)\n // The inserted `@<label> ` is complete: keep the menu shut for this `@`.\n setDismissedAt(match.start)\n requestAnimationFrame(() => {\n const ta = textareaRef.current\n if (!ta) return\n ta.focus()\n ta.setSelectionRange(next.caret, next.caret)\n })\n },\n [match, caret, value, onValueChange, textareaRef]\n )\n\n const nav = useListKeyNav({\n open: isOpen,\n items,\n onPick: pick,\n onDismiss: () => setDismissedAt(match?.start ?? null),\n resetKey: match?.query,\n })\n\n const handleValueChange = useCallback(\n (next: string) => {\n onValueChange(next)\n const ta = textareaRef.current\n setCaret(ta ? ta.selectionStart : next.length)\n // Deleting text (or the `@` itself) re-arms the menu: the user is editing that mention.\n if (dismissedAt !== null && (next.length < value.length || next[dismissedAt] !== '@')) {\n setDismissedAt(null)\n }\n },\n [onValueChange, textareaRef, dismissedAt, value]\n )\n\n return {\n isOpen,\n items,\n nav,\n pick,\n onValueChange: handleValueChange,\n textareaProps: { onSelect: readCaret },\n }\n}\n","import { useLayoutEffect, useState, type RefObject } from 'react'\nimport { observeResize } from './observe-resize'\n\nexport interface ElementSize {\n width: number\n height: number\n}\n\n/**\n * The border-box size of an element, kept current with a ResizeObserver. It is measured before\n * the first paint (layout effect), so a layout that depends on it never flashes the wrong mode.\n * Window resize is listened to as well (a no-ResizeObserver engine, jsdom, still re-measures).\n */\nexport function useElementSize<T extends HTMLElement>(ref: RefObject<T | null>): ElementSize {\n const [size, setSize] = useState<ElementSize>({ width: 0, height: 0 })\n useLayoutEffect(() => {\n const el = ref.current\n if (!el) return\n const measure = () => {\n const rect = el.getBoundingClientRect()\n setSize((prev) =>\n prev.width === rect.width && prev.height === rect.height\n ? prev\n : { width: rect.width, height: rect.height }\n )\n }\n measure()\n window.addEventListener('resize', measure)\n const stopObserving = observeResize(el, measure)\n return () => {\n window.removeEventListener('resize', measure)\n stopObserving()\n }\n }, [ref])\n return size\n}\n\n/** The root font size in px (what `rem` means), 16 when it cannot be read. */\nexport function rootFontSizePx(): number {\n if (typeof document === 'undefined') return 16\n const size = parseFloat(getComputedStyle(document.documentElement).fontSize)\n return Number.isFinite(size) && size > 0 ? size : 16\n}\n"]}