@openviking/react 0.1.3 → 0.1.5

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 (209) hide show
  1. package/LICENSE.arco-design +21 -0
  2. package/README.md +27 -15
  3. package/dist/0~0.js +19 -0
  4. package/dist/28~0.js +15 -0
  5. package/dist/2~0.js +2270 -29
  6. package/dist/2~0.js.LICENSE.txt +23 -0
  7. package/dist/3c~0.js +2208 -0
  8. package/dist/3~0.js +1207 -1982
  9. package/dist/4~0.js +18 -0
  10. package/dist/9~0.js +43 -0
  11. package/dist/{1~0.js → ae~0.js} +11 -26
  12. package/dist/ark-message-list-view~0.js +530 -119
  13. package/dist/a~0.js +1300 -14
  14. package/dist/c7~0.js +38 -2
  15. package/dist/ck~0.js +23 -0
  16. package/dist/client/provider.d.ts +15 -9
  17. package/dist/client/types.d.ts +5 -5
  18. package/dist/client.js +2 -1
  19. package/dist/components/agent-connect/agent-connect-code-block.d.ts +14 -0
  20. package/dist/components/agent-connect/agent-connect-copy.d.ts +22 -33
  21. package/dist/components/agent-connect/agent-connect-design.d.ts +1936 -168
  22. package/dist/components/agent-connect/agent-connect-installer.d.ts +1 -0
  23. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +4 -6
  24. package/dist/components/agent-connect/agent-connect-instructions.d.ts +148 -0
  25. package/dist/components/agent-connect/agent-connect-markdown.d.ts +8 -2
  26. package/dist/components/agent-connect/agent-connect-mask.d.ts +10 -0
  27. package/dist/components/agent-connect/agent-connect.d.ts +1 -1
  28. package/dist/components/agent-connect/locales/en-US.d.ts +23 -0
  29. package/dist/components/agent-connect/locales/zh-CN.d.ts +3 -0
  30. package/dist/components/agent-connect/style.css +129 -3
  31. package/dist/components/agent-connect/types.d.ts +7 -4
  32. package/dist/components/agent-connect/use-agent-connect-copy.d.ts +6 -0
  33. package/dist/components/directory-tour/directory-tour.d.ts +3 -0
  34. package/dist/components/directory-tour/index.d.ts +3 -0
  35. package/dist/components/directory-tour/locales/en-US.d.ts +3 -0
  36. package/dist/components/directory-tour/locales/zh-CN.d.ts +3 -0
  37. package/dist/components/directory-tour/steps.d.ts +5 -0
  38. package/dist/components/directory-tour/style.css +237 -0
  39. package/dist/components/directory-tour/style.js +0 -0
  40. package/dist/components/directory-tour/types.d.ts +43 -0
  41. package/dist/components/directory-tour/use-tour-anchor.d.ts +5 -0
  42. package/dist/components/directory-tour/use-tour-position.d.ts +12 -0
  43. package/dist/components/directory-tour.js +40 -0
  44. package/dist/components/file-browser-entries/file-browser-entries.d.ts +5 -5
  45. package/dist/components/file-browser-entries/labels.d.ts +3 -0
  46. package/dist/components/file-browser-entries/locales/en-US.d.ts +6 -0
  47. package/dist/components/file-browser-entries/locales/zh-CN.d.ts +6 -0
  48. package/dist/components/file-browser-entries/style.css +866 -2
  49. package/dist/components/file-browser-entries/types.d.ts +34 -16
  50. package/dist/components/file-preview/file-preview-adapters.d.ts +2 -1
  51. package/dist/components/file-preview/file-preview-body.d.ts +2 -1
  52. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +2 -1
  53. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +2 -1
  54. package/dist/components/file-preview/file-preview-directory.d.ts +2 -1
  55. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +2 -1
  56. package/dist/components/file-preview/file-preview-header.d.ts +6 -2
  57. package/dist/components/file-preview/file-preview-image-frame.d.ts +5 -0
  58. package/dist/components/file-preview/file-preview-labels.d.ts +2 -14
  59. package/dist/components/file-preview/file-preview-level-tabs.d.ts +7 -0
  60. package/dist/components/file-preview/file-preview-markdown-images.d.ts +13 -0
  61. package/dist/components/file-preview/file-preview-panels.d.ts +5 -2
  62. package/dist/components/file-preview/file-preview-viewer.d.ts +2 -1
  63. package/dist/components/file-preview/file-preview.d.ts +0 -1
  64. package/dist/components/file-preview/index.d.ts +2 -1
  65. package/dist/components/file-preview/locales/en-US.d.ts +16 -0
  66. package/dist/components/file-preview/locales/zh-CN.d.ts +16 -0
  67. package/dist/components/file-preview/style.css +160 -2
  68. package/dist/components/file-preview/types.d.ts +34 -10
  69. package/dist/components/file-preview/use-file-preview-levels.d.ts +7 -0
  70. package/dist/components/file-preview/use-file-preview-view-state.d.ts +15 -0
  71. package/dist/components/file-preview.js +1 -1
  72. package/dist/components/file-tree/file-tree-info-labels.d.ts +0 -15
  73. package/dist/components/file-tree/file-tree-labels.d.ts +4 -0
  74. package/dist/components/file-tree/file-tree-row-shared.d.ts +2 -12
  75. package/dist/components/file-tree/file-tree-toolbar.d.ts +11 -0
  76. package/dist/components/file-tree/locales/en-US.d.ts +69 -0
  77. package/dist/components/file-tree/locales/zh-CN.d.ts +69 -0
  78. package/dist/components/file-tree/style.css +143 -15
  79. package/dist/components/file-tree/types.d.ts +38 -10
  80. package/dist/components/file-tree/use-file-tree-actions.d.ts +4 -1
  81. package/dist/components/scope-switcher/labels.d.ts +3 -0
  82. package/dist/components/scope-switcher/locales/en-US.d.ts +8 -0
  83. package/dist/components/scope-switcher/locales/zh-CN.d.ts +8 -0
  84. package/dist/components/scope-switcher/scope-panel.d.ts +1 -1
  85. package/dist/components/scope-switcher/scope-switcher.d.ts +2 -2
  86. package/dist/components/scope-switcher/style.css +14 -2
  87. package/dist/components/scope-switcher/types.d.ts +12 -6
  88. package/dist/components/style.css +10030 -6763
  89. package/dist/components/tui/locales/en-US.d.ts +35 -0
  90. package/dist/components/tui/locales/zh-CN.d.ts +35 -0
  91. package/dist/components/tui/style.css +310 -18
  92. package/dist/components/tui/tui-copy-button.d.ts +1 -1
  93. package/dist/components/tui/tui-empty.d.ts +25 -0
  94. package/dist/components/tui/tui-labels.d.ts +2 -2
  95. package/dist/components/tui/tui.d.ts +1 -1
  96. package/dist/components/tui/types.d.ts +35 -12
  97. package/dist/components/tui.js +1 -1
  98. package/dist/components/viking-bot/ark-adapter.d.ts +2 -0
  99. package/dist/components/viking-bot/ark-message-body.d.ts +1 -7
  100. package/dist/components/viking-bot/ark-message-list-view.d.ts +4 -1
  101. package/dist/components/viking-bot/ark-message-row.d.ts +3 -1
  102. package/dist/components/viking-bot/bot-popover.d.ts +9 -0
  103. package/dist/components/viking-bot/capabilities.d.ts +49 -0
  104. package/dist/components/viking-bot/composer-attachments.d.ts +13 -0
  105. package/dist/components/viking-bot/composer-controls.d.ts +10 -0
  106. package/dist/components/viking-bot/composer-footer.d.ts +17 -0
  107. package/dist/components/viking-bot/composer-references.d.ts +20 -0
  108. package/dist/components/viking-bot/composer-text.d.ts +10 -0
  109. package/dist/components/viking-bot/index.d.ts +3 -1
  110. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +1 -1
  111. package/dist/components/viking-bot/interaction/labels.d.ts +2 -1
  112. package/dist/components/viking-bot/interaction/locales/en-US.d.ts +17 -0
  113. package/dist/components/viking-bot/interaction/locales/zh-CN.d.ts +17 -0
  114. package/dist/components/viking-bot/interaction/types.d.ts +8 -3
  115. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +1 -1
  116. package/dist/components/viking-bot/labels.d.ts +2 -0
  117. package/dist/components/viking-bot/locales/en-US.d.ts +40 -0
  118. package/dist/components/viking-bot/locales/zh-CN.d.ts +40 -0
  119. package/dist/components/viking-bot/markdown-links.d.ts +27 -0
  120. package/dist/components/viking-bot/message-activity.d.ts +7 -0
  121. package/dist/components/viking-bot/message-code-block.d.ts +8 -0
  122. package/dist/components/viking-bot/message-footer.d.ts +8 -0
  123. package/dist/components/viking-bot/message-markdown.d.ts +9 -0
  124. package/dist/components/viking-bot/model.d.ts +37 -3
  125. package/dist/components/viking-bot/quick-input-tracker.d.ts +16 -0
  126. package/dist/components/viking-bot/quick-inputs.d.ts +6 -0
  127. package/dist/components/viking-bot/reference-picker.d.ts +16 -0
  128. package/dist/components/viking-bot/session-actions.d.ts +11 -0
  129. package/dist/components/viking-bot/style.css +1486 -48
  130. package/dist/components/viking-bot/tool-activity.d.ts +9 -0
  131. package/dist/components/viking-bot/tool-result-links.d.ts +6 -0
  132. package/dist/components/viking-bot/types.d.ts +20 -8
  133. package/dist/components/viking-bot/use-quick-input.d.ts +17 -0
  134. package/dist/components/viking-bot/viking-bot.d.ts +1 -6
  135. package/dist/components/viking-bot/welcome.d.ts +8 -0
  136. package/dist/components/viking-bot.js +1 -1
  137. package/dist/c~0.js +550 -69
  138. package/dist/e~0.js +335 -0
  139. package/dist/file-preview-viewer~0.js +90 -8
  140. package/dist/f~0.js +49 -51
  141. package/dist/h~0.js +5 -1
  142. package/dist/icons/console-icons.d.ts +12 -0
  143. package/dist/icons/index.d.ts +2 -0
  144. package/dist/icons/viking-bot-icons.d.ts +6 -0
  145. package/dist/icons.js +1 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.js +2 -1
  148. package/dist/k~0.js +1 -0
  149. package/dist/lg~0.js +155 -0
  150. package/dist/lk~0.js +40 -8
  151. package/dist/l~0.js +170 -181
  152. package/dist/modules/console/command-messages.d.ts +19 -0
  153. package/dist/modules/console/command-parser.d.ts +15 -0
  154. package/dist/modules/console/command-specs.d.ts +15 -0
  155. package/dist/modules/console/commands.d.ts +6 -0
  156. package/dist/modules/console/console-history.d.ts +10 -0
  157. package/dist/modules/console/console-toolbar.d.ts +18 -0
  158. package/dist/modules/console/console.d.ts +1 -3
  159. package/dist/modules/console/controller.d.ts +17 -0
  160. package/dist/modules/console/index.d.ts +2 -0
  161. package/dist/modules/console/labels.d.ts +61 -0
  162. package/dist/modules/console/locales/en-US.d.ts +49 -0
  163. package/dist/modules/console/locales/zh-CN.d.ts +3 -0
  164. package/dist/modules/console/localize-records.d.ts +11 -0
  165. package/dist/modules/console/results.d.ts +2 -0
  166. package/dist/modules/console/style.css +10905 -15
  167. package/dist/modules/console/types.d.ts +59 -80
  168. package/dist/modules/console/use-console.d.ts +3 -0
  169. package/dist/modules/console.js +1 -1
  170. package/dist/modules/file-browser/file-browser-detail.d.ts +2 -1
  171. package/dist/modules/file-browser/file-browser-labels.d.ts +11 -12
  172. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -4
  173. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +7 -5
  174. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  175. package/dist/modules/file-browser/fs-read-directory.d.ts +2 -6
  176. package/dist/modules/file-browser/locales/en-US.d.ts +25 -0
  177. package/dist/modules/file-browser/locales/zh-CN.d.ts +25 -0
  178. package/dist/modules/file-browser/style.css +1695 -126
  179. package/dist/modules/file-browser/types.d.ts +38 -29
  180. package/dist/modules/file-browser/use-file-browser.d.ts +6 -1
  181. package/dist/modules/file-browser/use-fs-preview.d.ts +15 -1
  182. package/dist/modules/scope-cascade/labels.d.ts +6 -0
  183. package/dist/modules/scope-cascade/locales/en-US.d.ts +6 -0
  184. package/dist/modules/scope-cascade/locales/zh-CN.d.ts +3 -0
  185. package/dist/modules/scope-cascade/scope-cascade.d.ts +2 -2
  186. package/dist/modules/scope-cascade/style.css +14 -2
  187. package/dist/modules/scope-cascade/types.d.ts +3 -0
  188. package/dist/modules/style.css +15938 -3455
  189. package/dist/nx~0.js +15 -0
  190. package/dist/n~0.js +240 -83
  191. package/dist/o~0.js +10 -7
  192. package/dist/p~0.js +27 -0
  193. package/dist/rslib-runtime~0.js +42 -0
  194. package/dist/r~0.js +152 -0
  195. package/dist/shared/components/drawer/drawer.d.ts +13 -0
  196. package/dist/shared/components/drawer/index.d.ts +1 -0
  197. package/dist/shared/components/overlay/use-overlay-position.d.ts +2 -2
  198. package/dist/shared/components/tooltip/use-portal-theme.d.ts +3 -0
  199. package/dist/shared/locale-context.d.ts +8 -0
  200. package/dist/shared/locale.d.ts +6 -0
  201. package/dist/style.css +26339 -10577
  202. package/dist/u~0.js +397 -152
  203. package/dist/viking-bot-composer~0.js +436 -77
  204. package/dist/viking-bot-interaction~0.js +13 -11
  205. package/package.json +15 -4
  206. package/dist/30~0.js +0 -1332
  207. package/dist/components/tui/tui-labels-zh.d.ts +0 -2
  208. package/dist/modules/file-browser/tree-info-copy.d.ts +0 -15
  209. package/dist/modules/file-browser/tree-info-copy.zh-CN.d.ts +0 -15
@@ -1,39 +1,400 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Sender } from "@ark-design/ui/sender";
3
- import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from "react";
4
- import { DEFAULT_LABELS } from "./c~0.js";
5
- const HARD_BREAK = 'hardBreak';
6
- const TEXT = 'text';
7
- const toPlainText = (content)=>content.map((item)=>{
8
- if (item.type === HARD_BREAK) return '\n';
9
- return item.type === TEXT ? item.text ?? '' : '';
10
- }).join('').trim();
11
- const toRichText = (text)=>text ? [
3
+ import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
4
+ import { Tooltip } from "./r~0.js";
5
+ import { VikingBotIcon } from "./lg~0.js";
6
+ import { resolveVikingBotLabels, BotPopover, useQuickInput, QuickInputs } from "./c~0.js";
7
+ import { usePortalTheme } from "./9~0.js";
8
+ import { FileTree as file_tree_FileTree } from "./n~0.js";
9
+ import { useLocale } from "./28~0.js";
10
+ const SvgSend = (props)=>/*#__PURE__*/ jsx("svg", {
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ fill: "none",
13
+ preserveAspectRatio: "none",
14
+ viewBox: "0 0 9 10.333",
15
+ ...props,
16
+ children: /*#__PURE__*/ jsx("path", {
17
+ fill: "currentColor",
18
+ d: "M4 9.833V1.707L.853 4.854a.5.5 0 1 1-.707-.707l4-4 .038-.035a.5.5 0 0 1 .67.035l4 4a.5.5 0 1 1-.708.707L5 1.707v8.126a.5.5 0 1 1-1 0"
19
+ })
20
+ });
21
+ const sendreact = SvgSend;
22
+ const SvgAttach = (props)=>/*#__PURE__*/ jsx("svg", {
23
+ xmlns: "http://www.w3.org/2000/svg",
24
+ fill: "none",
25
+ preserveAspectRatio: "none",
26
+ viewBox: "0 0 10.208 10.208",
27
+ ...props,
28
+ children: /*#__PURE__*/ jsx("path", {
29
+ fill: "currentColor",
30
+ d: "M4.667 9.77V5.543H.437a.438.438 0 0 1 0-.875h4.23V.437a.437.437 0 1 1 .875 0v4.23H9.77a.437.437 0 1 1 0 .875H5.54V9.77a.437.437 0 1 1-.874 0"
31
+ })
32
+ });
33
+ const attachreact = SvgAttach;
34
+ function VikingBotSubmit({ onSend, onStop, sending, tip, className, label, ...props }) {
35
+ return /*#__PURE__*/ jsx(Tooltip, {
36
+ content: tip ?? label,
37
+ children: /*#__PURE__*/ jsx("button", {
38
+ ...props,
39
+ type: "button",
40
+ className: [
41
+ 'ov-viking-bot__submit',
42
+ className
43
+ ].filter(Boolean).join(' '),
44
+ "aria-label": label,
45
+ onClick: (event)=>void (sending ? onStop : onSend)?.(event.nativeEvent),
46
+ children: sending ? /*#__PURE__*/ jsx("span", {
47
+ className: "ov-viking-bot__stop-icon",
48
+ "aria-hidden": "true"
49
+ }) : /*#__PURE__*/ jsx(sendreact, {
50
+ "aria-hidden": "true",
51
+ focusable: "false"
52
+ })
53
+ })
54
+ });
55
+ }
56
+ function VikingBotAttach({ label, ...props }) {
57
+ return /*#__PURE__*/ jsx(Tooltip, {
58
+ content: label,
59
+ children: /*#__PURE__*/ jsx("button", {
60
+ ...props,
61
+ type: "button",
62
+ className: "ov-viking-bot__attach",
63
+ "aria-label": label,
64
+ children: /*#__PURE__*/ jsx(attachreact, {
65
+ "aria-hidden": "true",
66
+ focusable: "false"
67
+ })
68
+ })
69
+ });
70
+ }
71
+ function ComposerFileButton({ accept, disabled, label, onFiles }) {
72
+ const input = useRef(null);
73
+ return /*#__PURE__*/ jsxs(Fragment, {
74
+ children: [
75
+ /*#__PURE__*/ jsx("input", {
76
+ ref: input,
77
+ type: "file",
78
+ accept: accept,
79
+ multiple: true,
80
+ hidden: true,
81
+ onChange: (event)=>{
82
+ onFiles([
83
+ ...event.target.files ?? []
84
+ ]);
85
+ event.target.value = '';
86
+ }
87
+ }),
88
+ /*#__PURE__*/ jsx(VikingBotAttach, {
89
+ label: label,
90
+ disabled: disabled,
91
+ onClick: ()=>input.current?.click()
92
+ })
93
+ ]
94
+ });
95
+ }
96
+ function ComposerAttachments({ items, onRemove, disabled, labels }) {
97
+ if (!items.length) return null;
98
+ return /*#__PURE__*/ jsx("ul", {
99
+ className: "ov-viking-bot__attachments",
100
+ children: items.map((item)=>/*#__PURE__*/ jsxs("li", {
101
+ children: [
102
+ /*#__PURE__*/ jsx("span", {
103
+ children: item.name
104
+ }),
105
+ 'error' === item.status ? /*#__PURE__*/ jsx("span", {
106
+ className: "ov-viking-bot__attachment-status",
107
+ children: item.errorMessage ?? labels.toolError
108
+ }) : null,
109
+ onRemove ? /*#__PURE__*/ jsx("button", {
110
+ type: "button",
111
+ "aria-label": `${labels.removeAttachment}: ${item.name}`,
112
+ disabled: disabled,
113
+ onClick: ()=>onRemove(item),
114
+ children: /*#__PURE__*/ jsx(VikingBotIcon, {
115
+ name: "remove",
116
+ width: 12,
117
+ height: 12
118
+ })
119
+ }) : null
120
+ ]
121
+ }, item.key))
122
+ });
123
+ }
124
+ function ReferencePicker({ config, locale, query: externalQuery, editor, onSelect, labels: overrides }) {
125
+ const labels = resolveVikingBotLabels(locale, overrides);
126
+ const [search, setSearch] = useState('');
127
+ const [active, setActive] = useState(0);
128
+ const [surface, setSurface] = useState(null);
129
+ const anchor = useMemo(()=>({
130
+ current: editor?.view.dom ?? null
131
+ }), [
132
+ editor
133
+ ]);
134
+ usePortalTheme(!!editor, anchor, surface);
135
+ const query = externalQuery ?? search;
136
+ const { onQueryChange } = config;
137
+ const id = useId();
138
+ const rows = query && !config.onQueryChange ? config.rows.filter((row)=>'entry' === row.kind && `${row.name} ${row.uri}`.toLowerCase().includes(query.toLowerCase())) : config.rows;
139
+ const entries = rows.filter((row)=>'entry' === row.kind && !row.disabled);
140
+ const activeEntry = entries[Math.min(active, entries.length - 1)];
141
+ useEffect(()=>{
142
+ onQueryChange?.(query);
143
+ }, [
144
+ query,
145
+ onQueryChange
146
+ ]);
147
+ useEffect(()=>{
148
+ if (!editor) return;
149
+ const keydown = (event)=>{
150
+ if (event.isComposing) return;
151
+ if ('Enter' === event.key) {
152
+ event.preventDefault();
153
+ event.stopImmediatePropagation();
154
+ if (activeEntry && !config.isLoading && !config.error) onSelect(activeEntry);
155
+ return;
156
+ }
157
+ if (config.isLoading || config.error) return;
158
+ if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
159
+ event.preventDefault();
160
+ event.stopImmediatePropagation();
161
+ setActive((index)=>entries.length ? (index + ('ArrowDown' === event.key ? 1 : -1) + entries.length) % entries.length : 0);
162
+ } else if (('ArrowRight' === event.key || 'ArrowLeft' === event.key) && activeEntry?.type === 'directory') {
163
+ event.preventDefault();
164
+ event.stopImmediatePropagation();
165
+ config.onExpand?.(activeEntry.uri);
166
+ }
167
+ };
168
+ editor.view.dom.addEventListener('keydown', keydown, true);
169
+ return ()=>editor.view.dom.removeEventListener('keydown', keydown, true);
170
+ }, [
171
+ editor,
172
+ activeEntry,
173
+ entries.length,
174
+ onSelect,
175
+ config
176
+ ]);
177
+ return /*#__PURE__*/ jsxs("div", {
178
+ ref: setSurface,
179
+ className: `ov-viking-bot__reference-picker${editor ? ' ov-viking-bot__reference-picker--mention' : ''}`,
180
+ children: [
181
+ editor ? null : /*#__PURE__*/ jsxs("label", {
182
+ htmlFor: id,
183
+ children: [
184
+ labels.searchReferences,
185
+ /*#__PURE__*/ jsx("input", {
186
+ id: id,
187
+ type: "search",
188
+ value: search,
189
+ onChange: (event)=>{
190
+ setSearch(event.target.value);
191
+ setActive(0);
192
+ }
193
+ })
194
+ ]
195
+ }),
196
+ config.error ? /*#__PURE__*/ jsx("p", {
197
+ role: "alert",
198
+ children: config.error
199
+ }) : /*#__PURE__*/ jsx(file_tree_FileTree, {
200
+ locale: locale,
201
+ "aria-label": labels.reference,
202
+ rows: rows,
203
+ isReady: !config.isLoading,
204
+ selectedId: editor ? activeEntry?.id : void 0,
205
+ operations: {
206
+ select: ()=>Promise.resolve(),
207
+ toggleExpand: ()=>Promise.resolve()
208
+ },
209
+ onSelect: onSelect,
210
+ onToggleExpand: (row)=>config.onExpand?.(row.uri),
211
+ renderRowTooltip: ()=>null,
212
+ getRowAttributes: ()=>editor ? {
213
+ onMouseDown: (event)=>event.preventDefault()
214
+ } : {},
215
+ loadingFallback: /*#__PURE__*/ jsx("p", {
216
+ role: "status",
217
+ children: labels.loading
218
+ }),
219
+ emptyFallback: /*#__PURE__*/ jsx("p", {
220
+ role: "status",
221
+ children: labels.emptyReferences
222
+ }),
223
+ labels: {
224
+ expand: labels.expandReference,
225
+ collapse: labels.collapseReference
226
+ }
227
+ })
228
+ ]
229
+ });
230
+ }
231
+ function selectReference(config, item) {
232
+ if (!config.selected.some((entry)=>entry.uri === item.uri)) config.onChange([
233
+ ...config.selected,
12
234
  {
13
- type: TEXT,
14
- text
235
+ uri: item.uri,
236
+ name: item.name,
237
+ type: item.type
15
238
  }
16
- ] : [];
17
- const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(function({ value, className, attachments = [], disabled, disabledReason, isSending, variant = 'default', accept, maxAttachments = 10, actions, onValueChange, onFilesAdded, onAttachmentRemove, onSend, onCancel, labels: overrides }, ref) {
18
- const labels = {
19
- ...DEFAULT_LABELS,
20
- ...overrides
239
+ ]);
240
+ }
241
+ function composerMention(config, disabled, labels, locale) {
242
+ if (!config) return;
243
+ return {
244
+ option: [],
245
+ shouldShow: ({ editor })=>!disabled && editor.isFocused,
246
+ onSelect: (item, { editor, range })=>{
247
+ const reference = config.rows.find((row)=>'entry' === row.kind && row.uri === item.value);
248
+ if (disabled || !reference || 'entry' !== reference.kind || reference.disabled) return;
249
+ selectReference(config, reference);
250
+ editor.chain().focus().deleteRange(range).run();
251
+ },
252
+ render: ({ query, command, editor })=>disabled ? null : /*#__PURE__*/ jsx(ReferencePicker, {
253
+ locale: locale,
254
+ config: config,
255
+ editor: editor,
256
+ query: query,
257
+ labels: labels,
258
+ onSelect: (item)=>command({
259
+ tagType: 'file',
260
+ label: item.name,
261
+ value: item.uri
262
+ })
263
+ })
21
264
  };
265
+ }
266
+ function ReferenceButton({ locale, config, disabled, labels, senderRef }) {
267
+ return /*#__PURE__*/ jsx(BotPopover, {
268
+ label: labels.reference,
269
+ placement: "top",
270
+ trigger: (props)=>/*#__PURE__*/ jsx(Tooltip, {
271
+ content: labels.reference,
272
+ disabled: true === props['aria-expanded'],
273
+ children: /*#__PURE__*/ jsx("button", {
274
+ ...props,
275
+ className: "ov-viking-bot__attach",
276
+ type: "button",
277
+ "aria-label": labels.reference,
278
+ disabled: disabled,
279
+ children: "@"
280
+ })
281
+ }),
282
+ children: (close)=>/*#__PURE__*/ jsx(ReferencePicker, {
283
+ locale: locale,
284
+ config: config,
285
+ labels: labels,
286
+ onSelect: (item)=>{
287
+ if (disabled) return;
288
+ selectReference(config, item);
289
+ close();
290
+ senderRef.current?.getEditor()?.commands.focus();
291
+ }
292
+ })
293
+ }, disabled ? 'disabled' : 'enabled');
294
+ }
295
+ function ReferenceTags({ config, labels, disabled }) {
296
+ if (!config?.selected.length) return null;
297
+ return /*#__PURE__*/ jsx("ul", {
298
+ className: "ov-viking-bot__reference-tags",
299
+ children: config.selected.map((item)=>/*#__PURE__*/ jsxs("li", {
300
+ children: [
301
+ /*#__PURE__*/ jsx(Tooltip, {
302
+ content: item.uri,
303
+ children: /*#__PURE__*/ jsx("span", {
304
+ children: item.name
305
+ })
306
+ }),
307
+ /*#__PURE__*/ jsx("button", {
308
+ type: "button",
309
+ disabled: disabled,
310
+ "aria-label": `${labels.removeReference}: ${item.name}`,
311
+ onClick: ()=>config.onChange(config.selected.filter((entry)=>entry.uri !== item.uri)),
312
+ children: /*#__PURE__*/ jsx(VikingBotIcon, {
313
+ name: "remove",
314
+ width: 12,
315
+ height: 12
316
+ })
317
+ })
318
+ ]
319
+ }, item.uri))
320
+ });
321
+ }
322
+ function ComposerFooter({ locale, references, senderRef, labels, disabled, filesDisabled, accept, onFiles, actions, submit }) {
323
+ return /*#__PURE__*/ jsxs("div", {
324
+ className: "ov-viking-bot__composer-actions",
325
+ children: [
326
+ /*#__PURE__*/ jsxs("div", {
327
+ className: "ov-viking-bot__composer-tools",
328
+ children: [
329
+ onFiles ? /*#__PURE__*/ jsx(ComposerFileButton, {
330
+ label: labels.attach,
331
+ accept: accept,
332
+ disabled: filesDisabled,
333
+ onFiles: onFiles
334
+ }) : null,
335
+ references ? /*#__PURE__*/ jsx(ReferenceButton, {
336
+ locale: locale,
337
+ config: references,
338
+ labels: labels,
339
+ senderRef: senderRef,
340
+ disabled: disabled
341
+ }) : null,
342
+ actions
343
+ ]
344
+ }),
345
+ submit
346
+ ]
347
+ });
348
+ }
349
+ const toPlainText = (content)=>content.map((item)=>'hardBreak' === item.type ? '\n' : 'text' === item.type ? item.text ?? '' : '').join('');
350
+ function toRichText(text) {
351
+ const content = [];
352
+ text.split('\n').forEach((line, index)=>{
353
+ if (index) content.push({
354
+ type: 'hardBreak'
355
+ });
356
+ if (line) content.push({
357
+ type: 'text',
358
+ text: line
359
+ });
360
+ });
361
+ return content;
362
+ }
363
+ function writeComposerText(sender, text, writing) {
364
+ const previous = writing.current;
365
+ writing.current = true;
366
+ try {
367
+ sender?.setValue(toRichText(text));
368
+ } finally{
369
+ writing.current = previous;
370
+ }
371
+ }
372
+ function composerCaret(sender) {
373
+ const editor = sender?.getEditor();
374
+ if (!editor?.state.selection.empty) return;
375
+ const { doc, selection } = editor.state;
376
+ return doc.textBetween(0, selection.from, '\n', '\n').length;
377
+ }
378
+ const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(function({ value, locale: localeProp, className, attachments = [], disabled, disabledReason, isSending, variant = 'default', accept, maxAttachments = 10, actions, quickInputs, onQuickInputSelect, references, onValueChange, onFilesAdded, onAttachmentRemove, onSend, onCancel, labels: overrides }, ref) {
379
+ const locale = useLocale(localeProp);
380
+ const labels = resolveVikingBotLabels(locale, overrides);
22
381
  const senderRef = useRef(null);
23
- const fileRef = useRef(null);
382
+ const writing = useRef(false);
24
383
  const readOnly = !onValueChange;
384
+ const locked = Boolean(disabled || readOnly || isSending);
25
385
  const remaining = Math.max(0, maxAttachments - attachments.length);
26
386
  const limitReached = 0 === remaining;
27
387
  const setText = useCallback((text)=>{
28
- senderRef.current?.setValue(toRichText(text));
388
+ writeComposerText(senderRef.current, text, writing);
29
389
  onValueChange?.(text);
30
390
  }, [
31
391
  onValueChange
32
392
  ]);
393
+ const shortcuts = useQuickInput(value, setText, onQuickInputSelect);
33
394
  useEffect(()=>{
34
395
  const current = toPlainText(senderRef.current?.getValue() ?? []);
35
396
  if (current === value) return;
36
- senderRef.current?.setValue(toRichText(value));
397
+ writeComposerText(senderRef.current, value, writing);
37
398
  }, [
38
399
  value
39
400
  ]);
@@ -56,10 +417,13 @@ const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(funct
56
417
  }));
57
418
  const submit = ()=>{
58
419
  if (!onSend || disabled || isSending) return;
59
- const text = toPlainText(senderRef.current?.getValue() ?? toRichText(value));
420
+ const text = toPlainText(senderRef.current?.getValue() ?? toRichText(value)).trim();
60
421
  onSend({
61
422
  text,
62
- attachments
423
+ attachments,
424
+ ...references ? {
425
+ references: references.selected
426
+ } : {}
63
427
  });
64
428
  };
65
429
  const interceptDrop = Boolean(onFilesAdded);
@@ -89,73 +453,68 @@ const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(funct
89
453
  role: "status",
90
454
  children: disabledReason
91
455
  }) : null,
92
- attachments.length > 0 ? /*#__PURE__*/ jsx("ul", {
93
- className: "ov-viking-bot__attachments",
94
- children: attachments.map((attachment)=>/*#__PURE__*/ jsxs("li", {
95
- children: [
96
- /*#__PURE__*/ jsx("span", {
97
- children: attachment.name
98
- }),
99
- 'error' === attachment.status ? /*#__PURE__*/ jsx("span", {
100
- className: "ov-viking-bot__attachment-status",
101
- children: attachment.errorMessage ?? labels.toolError
102
- }) : null,
103
- onAttachmentRemove ? /*#__PURE__*/ jsx("button", {
104
- type: "button",
105
- "aria-label": labels.removeAttachment,
106
- disabled: disabled,
107
- onClick: ()=>onAttachmentRemove(attachment),
108
- children: "\xd7"
109
- }) : null
110
- ]
111
- }, attachment.key))
112
- }) : null,
456
+ /*#__PURE__*/ jsx(QuickInputs, {
457
+ items: quickInputs,
458
+ disabled: disabled || readOnly || isSending,
459
+ onSelect: (item)=>{
460
+ shortcuts.select(item);
461
+ senderRef.current?.getEditor()?.commands.focus('end');
462
+ }
463
+ }),
113
464
  /*#__PURE__*/ jsx(Sender, {
114
465
  ref: senderRef,
115
466
  className: "ov-viking-bot__sender",
116
467
  defaultContent: toRichText(value),
117
468
  sending: isSending,
118
- sendDisabled: disabled || readOnly,
469
+ sendDisabled: disabled || readOnly || !isSending && !onSend,
119
470
  onContentChange: (content)=>{
120
- if (!readOnly) onValueChange?.(toPlainText(content));
121
- },
122
- onSend: ()=>{
123
- submit();
471
+ if (readOnly || writing.current) return;
472
+ const next = toPlainText(content);
473
+ shortcuts.tracker.edit(next, composerCaret(senderRef.current));
474
+ onValueChange?.(next);
124
475
  },
476
+ onSend: submit,
125
477
  onStop: ()=>onCancel?.(),
478
+ renderHeader: ()=>/*#__PURE__*/ jsxs(Fragment, {
479
+ children: [
480
+ /*#__PURE__*/ jsx(ReferenceTags, {
481
+ config: references,
482
+ labels: labels,
483
+ disabled: disabled || isSending
484
+ }),
485
+ /*#__PURE__*/ jsx(ComposerAttachments, {
486
+ items: attachments,
487
+ onRemove: onAttachmentRemove,
488
+ labels: labels,
489
+ disabled: disabled || isSending
490
+ })
491
+ ]
492
+ }),
493
+ renderSubmit: (props)=>isSending && !onCancel ? null : /*#__PURE__*/ jsx(VikingBotSubmit, {
494
+ ...props,
495
+ label: isSending ? labels.stop : labels.send
496
+ }),
126
497
  richTextAreaProps: {
498
+ mentionConfig: composerMention(references, locked, labels, locale),
127
499
  placeholder: labels.placeholder,
128
- disabled
500
+ disabled,
501
+ minRows: 1,
502
+ maxRows: 6,
503
+ style: {
504
+ minHeight: 44
505
+ }
129
506
  },
130
- renderFooter: ({ components })=>/*#__PURE__*/ jsxs("div", {
131
- className: "ov-viking-bot__composer-actions",
132
- children: [
133
- components.sendBtnComponent,
134
- onFilesAdded ? /*#__PURE__*/ jsxs(Fragment, {
135
- children: [
136
- /*#__PURE__*/ jsx("input", {
137
- ref: fileRef,
138
- type: "file",
139
- accept: accept,
140
- multiple: true,
141
- hidden: true,
142
- onChange: (event)=>{
143
- reportFiles([
144
- ...event.target.files ?? []
145
- ]);
146
- event.target.value = '';
147
- }
148
- }),
149
- /*#__PURE__*/ jsx("button", {
150
- type: "button",
151
- disabled: disabled || limitReached,
152
- onClick: ()=>fileRef.current?.click(),
153
- children: labels.attach
154
- })
155
- ]
156
- }) : null,
157
- actions
158
- ]
507
+ renderFooter: ({ components })=>/*#__PURE__*/ jsx(ComposerFooter, {
508
+ locale: locale,
509
+ references: references,
510
+ senderRef: senderRef,
511
+ labels: labels,
512
+ disabled: locked,
513
+ filesDisabled: Boolean(disabled || limitReached || isSending),
514
+ accept: accept,
515
+ onFiles: onFilesAdded ? reportFiles : void 0,
516
+ actions: actions,
517
+ submit: components.sendBtnComponent
159
518
  })
160
519
  })
161
520
  ]
@@ -1,8 +1,9 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { AskHuman } from "@ark-design/ui/ask-human";
3
3
  import { useState } from "react";
4
- import { DEFAULT_INTERACTION_LABELS } from "./c7~0.js";
5
- const toFields = (request)=>{
4
+ import { useLocale } from "./28~0.js";
5
+ import { resolveInteractionLabels } from "./c7~0.js";
6
+ const toFields = (request, other)=>{
6
7
  if ('choice' === request.kind) return [
7
8
  {
8
9
  type: 'single-select',
@@ -12,7 +13,9 @@ const toFields = (request)=>{
12
13
  label: option.label,
13
14
  description: option.description
14
15
  })),
15
- allowCustomInput: request.allowCustomInput
16
+ allowCustomInput: request.allowCustomInput ? {
17
+ placeholder: 'object' == typeof request.allowCustomInput ? request.allowCustomInput.placeholder ?? other : other
18
+ } : false
16
19
  }
17
20
  ];
18
21
  if ('repair' === request.kind) return [
@@ -177,7 +180,7 @@ function ScheduleInput({ request, labels, disabled, onChange }) {
177
180
  ]
178
181
  });
179
182
  }
180
- const TextInput = ({ request, disabled, onChange })=>/*#__PURE__*/ jsxs(Fragment, {
183
+ const TextInput = ({ request, label, disabled, onChange })=>/*#__PURE__*/ jsxs(Fragment, {
181
184
  children: [
182
185
  request.description ? /*#__PURE__*/ jsx("p", {
183
186
  children: request.description
@@ -186,16 +189,14 @@ const TextInput = ({ request, disabled, onChange })=>/*#__PURE__*/ jsxs(Fragment
186
189
  className: "ov-viking-bot__interaction-input",
187
190
  defaultValue: request.initialValue,
188
191
  disabled: disabled,
189
- "aria-label": "answer",
192
+ "aria-label": label,
190
193
  onChange: (event)=>onChange(event.target.value)
191
194
  })
192
195
  ]
193
196
  });
194
- function VikingBotInteractionView({ request, className, requestKey, index = 0, total = 1, disabled, submitting, error, onSubmit, onCancel, labels: overrides }) {
195
- const labels = {
196
- ...DEFAULT_INTERACTION_LABELS,
197
- ...overrides
198
- };
197
+ function VikingBotInteractionView({ request, className, requestKey, index = 0, total = 1, disabled, submitting, error, onSubmit, onCancel, locale: localeProp, labels: overrides }) {
198
+ const locale = useLocale(localeProp);
199
+ const labels = resolveInteractionLabels(locale, overrides);
199
200
  const blocked = Boolean(disabled || submitting);
200
201
  const formKey = requestKey ?? `${request.kind}:${index}`;
201
202
  const rootClass = [
@@ -227,7 +228,7 @@ function VikingBotInteractionView({ request, className, requestKey, index = 0, t
227
228
  {
228
229
  key: request.kind,
229
230
  title: request.question,
230
- fields: toFields(request),
231
+ fields: toFields(request, labels.other),
231
232
  extra: {
232
233
  index,
233
234
  total
@@ -266,6 +267,7 @@ function VikingBotInteractionView({ request, className, requestKey, index = 0, t
266
267
  },
267
268
  customRenderFields: {
268
269
  'viking-bot-text': ({ field, onChange })=>/*#__PURE__*/ jsx(TextInput, {
270
+ label: labels.answer,
269
271
  request: field.extra?.request,
270
272
  disabled: blocked,
271
273
  onChange: onChange