@openviking/react 0.1.0 → 0.1.2

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 (193) hide show
  1. package/README.md +57 -34
  2. package/dist/3~0.js +2117 -0
  3. package/dist/ark-message-list-view~0.js +310 -0
  4. package/dist/a~0.js +21 -0
  5. package/dist/c7~0.js +24 -0
  6. package/dist/client/client.d.ts +12 -0
  7. package/dist/client/errors.d.ts +30 -0
  8. package/dist/client/index.d.ts +4 -0
  9. package/dist/client/options.d.ts +101 -0
  10. package/dist/client/provider.d.ts +52 -0
  11. package/dist/client/types.d.ts +160 -0
  12. package/dist/client.js +239 -0
  13. package/dist/components/agent-connect/agent-connect-copy.d.ts +34 -0
  14. package/dist/components/agent-connect/agent-connect-design.d.ts +1781 -0
  15. package/dist/components/agent-connect/agent-connect-detail.d.ts +13 -0
  16. package/dist/components/agent-connect/agent-connect-installer.d.ts +3 -0
  17. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +14 -0
  18. package/dist/components/agent-connect/agent-connect-instructions.d.ts +145 -0
  19. package/dist/components/agent-connect/agent-connect-markdown.d.ts +3 -0
  20. package/dist/components/agent-connect/agent-connect.d.ts +4 -1
  21. package/dist/components/agent-connect/content-en.d.ts +137 -0
  22. package/dist/components/agent-connect/content-zh.d.ts +137 -0
  23. package/dist/components/agent-connect/index.d.ts +1 -0
  24. package/dist/components/agent-connect/style.css +503 -0
  25. package/dist/components/agent-connect/types.d.ts +29 -0
  26. package/dist/components/agent-connect.js +1 -0
  27. package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
  28. package/dist/components/file-preview/file-preview-body.d.ts +27 -0
  29. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +16 -0
  30. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +21 -0
  31. package/dist/components/file-preview/file-preview-copy-path.d.ts +12 -0
  32. package/dist/components/file-preview/file-preview-editor.d.ts +22 -0
  33. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +26 -0
  34. package/dist/components/file-preview/file-preview-header.d.ts +25 -0
  35. package/dist/components/file-preview/file-preview-labels.d.ts +16 -0
  36. package/dist/components/file-preview/file-preview-lazy-viewer.d.ts +3 -0
  37. package/dist/components/file-preview/file-preview-path.d.ts +30 -0
  38. package/dist/components/file-preview/file-preview-source.d.ts +24 -0
  39. package/dist/components/file-preview/file-preview-state.d.ts +28 -0
  40. package/dist/components/file-preview/file-preview-tab-row.d.ts +16 -0
  41. package/dist/components/file-preview/file-preview-viewer.d.ts +31 -0
  42. package/dist/components/file-preview/file-preview.d.ts +14 -1
  43. package/dist/components/file-preview/index.d.ts +1 -0
  44. package/dist/components/file-preview/style.css +4139 -0
  45. package/dist/components/file-preview/types.d.ts +516 -0
  46. package/dist/components/file-preview/use-file-preview-actions-context.d.ts +23 -0
  47. package/dist/components/file-preview/use-file-preview-actions.d.ts +19 -0
  48. package/dist/components/file-preview/use-file-preview-editing.d.ts +32 -0
  49. package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
  50. package/dist/components/file-preview.js +1 -0
  51. package/dist/components/file-tree/file-tree-body.d.ts +18 -0
  52. package/dist/components/file-tree/file-tree-entry-row.d.ts +12 -0
  53. package/dist/components/file-tree/file-tree-icons.d.ts +15 -0
  54. package/dist/components/file-tree/file-tree-info-labels.d.ts +21 -0
  55. package/dist/components/file-tree/file-tree-info-tooltip.d.ts +43 -0
  56. package/dist/components/file-tree/file-tree-info.d.ts +29 -0
  57. package/dist/components/file-tree/file-tree-keyboard.d.ts +14 -0
  58. package/dist/components/file-tree/file-tree-row-context.d.ts +46 -0
  59. package/dist/components/file-tree/file-tree-row-shared.d.ts +11 -0
  60. package/dist/components/file-tree/file-tree-spinner.d.ts +10 -0
  61. package/dist/components/file-tree/file-tree-state-row.d.ts +7 -0
  62. package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +22 -0
  63. package/dist/components/file-tree/file-tree-tooltip.d.ts +17 -0
  64. package/dist/components/file-tree/file-tree.d.ts +15 -1
  65. package/dist/components/file-tree/index.d.ts +1 -0
  66. package/dist/components/file-tree/style.css +410 -0
  67. package/dist/components/file-tree/types.d.ts +589 -0
  68. package/dist/components/file-tree/use-file-tree-actions.d.ts +17 -0
  69. package/dist/components/file-tree.js +1 -0
  70. package/dist/components/scope-switcher/index.d.ts +1 -0
  71. package/dist/components/scope-switcher/scope-keyboard.d.ts +2 -0
  72. package/dist/components/scope-switcher/scope-panel.d.ts +11 -0
  73. package/dist/components/scope-switcher/scope-selector.d.ts +2 -0
  74. package/dist/components/scope-switcher/scope-switcher.d.ts +6 -1
  75. package/dist/components/scope-switcher/style.css +452 -0
  76. package/dist/components/scope-switcher/types.d.ts +489 -0
  77. package/dist/components/scope-switcher.js +3 -0
  78. package/dist/components/style.css +14249 -18
  79. package/dist/components/tui/command-catalog.d.ts +58 -0
  80. package/dist/components/tui/command-completion.d.ts +19 -0
  81. package/dist/components/tui/command-definitions.d.ts +10 -0
  82. package/dist/components/tui/command-input.d.ts +16 -0
  83. package/dist/components/tui/index.d.ts +1 -0
  84. package/dist/components/tui/style.css +1552 -0
  85. package/dist/components/tui/tui-assist.d.ts +15 -0
  86. package/dist/components/tui/tui-code-block.d.ts +8 -0
  87. package/dist/components/tui/tui-command-help.d.ts +9 -0
  88. package/dist/components/tui/tui-command-text.d.ts +6 -0
  89. package/dist/components/tui/tui-composer.d.ts +24 -0
  90. package/dist/components/tui/tui-copy-button.d.ts +9 -0
  91. package/dist/components/tui/tui-input-mirror.d.ts +14 -0
  92. package/dist/components/tui/tui-labels-zh.d.ts +2 -0
  93. package/dist/components/tui/tui-labels.d.ts +5 -0
  94. package/dist/components/tui/tui-markdown-renderers.d.ts +10 -0
  95. package/dist/components/tui/tui-markdown.d.ts +6 -0
  96. package/dist/components/tui/tui-param-hint.d.ts +7 -0
  97. package/dist/components/tui/tui-record-time.d.ts +11 -0
  98. package/dist/components/tui/tui-record.d.ts +13 -0
  99. package/dist/components/tui/tui-resource-preview.d.ts +10 -0
  100. package/dist/components/tui/tui-resource-tree.d.ts +10 -0
  101. package/dist/components/tui/tui-result-header.d.ts +7 -0
  102. package/dist/components/tui/tui-result-text.d.ts +5 -0
  103. package/dist/components/tui/tui-search-list.d.ts +8 -0
  104. package/dist/components/tui/tui-skeleton.d.ts +6 -0
  105. package/dist/components/tui/tui-status-card.d.ts +7 -0
  106. package/dist/components/tui/tui-text.d.ts +10 -0
  107. package/dist/components/tui/tui-uri-text.d.ts +19 -0
  108. package/dist/components/tui/tui-write-result.d.ts +7 -0
  109. package/dist/components/tui/tui.d.ts +11 -1
  110. package/dist/components/tui/types.d.ts +527 -0
  111. package/dist/components/tui/use-tui-assist-position.d.ts +3 -0
  112. package/dist/components/tui/use-tui-completion.d.ts +14 -0
  113. package/dist/components/tui/use-tui-composer-keyboard.d.ts +25 -0
  114. package/dist/components/tui.js +1 -0
  115. package/dist/components/viking-bot/ark-adapter.d.ts +45 -0
  116. package/dist/components/viking-bot/ark-message-body.d.ts +16 -0
  117. package/dist/components/viking-bot/ark-message-list-view.d.ts +7 -0
  118. package/dist/components/viking-bot/ark-message-row.d.ts +19 -0
  119. package/dist/components/viking-bot/index.d.ts +10 -0
  120. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +10 -0
  121. package/dist/components/viking-bot/interaction/index.d.ts +4 -0
  122. package/dist/components/viking-bot/interaction/labels.d.ts +7 -0
  123. package/dist/components/viking-bot/interaction/lazy-interaction.d.ts +3 -0
  124. package/dist/components/viking-bot/interaction/schedule-input.d.ts +13 -0
  125. package/dist/components/viking-bot/interaction/style.css +189 -0
  126. package/dist/components/viking-bot/interaction/types.d.ts +188 -0
  127. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +9 -0
  128. package/dist/components/viking-bot/interaction.js +2 -0
  129. package/dist/components/viking-bot/labels.d.ts +2 -0
  130. package/dist/components/viking-bot/lazy-composer.d.ts +3 -0
  131. package/dist/components/viking-bot/message-groups.d.ts +12 -0
  132. package/dist/components/viking-bot/model.d.ts +252 -0
  133. package/dist/components/viking-bot/render-part.d.ts +12 -0
  134. package/dist/components/viking-bot/style.css +7133 -0
  135. package/dist/components/viking-bot/types.d.ts +140 -0
  136. package/dist/components/viking-bot/viking-bot-composer.d.ts +6 -0
  137. package/dist/components/viking-bot/viking-bot-message-list.d.ts +3 -0
  138. package/dist/components/viking-bot/viking-bot.d.ts +16 -1
  139. package/dist/components/viking-bot.js +4 -0
  140. package/dist/c~0.js +201 -0
  141. package/dist/file-preview-viewer~0.js +191 -0
  142. package/dist/f~0.js +356 -0
  143. package/dist/g~0.js +1207 -0
  144. package/dist/h~0.js +58 -0
  145. package/dist/icons/file-type-icon.d.ts +31 -0
  146. package/dist/icons/index.d.ts +33 -23
  147. package/dist/icons/nextjs-icon.d.ts +19 -0
  148. package/dist/icons.js +1 -25
  149. package/dist/index.d.ts +16 -2
  150. package/dist/index.js +8 -1
  151. package/dist/k~0.js +1440 -0
  152. package/dist/lk~0.js +233 -0
  153. package/dist/l~0.js +44 -0
  154. package/dist/modules/console/console.d.ts +4 -0
  155. package/dist/modules/console/index.d.ts +1 -0
  156. package/dist/modules/console/style.css +111 -0
  157. package/dist/modules/console/types.d.ts +101 -0
  158. package/dist/modules/console.js +1 -0
  159. package/dist/modules/file-browser/file-browser-toolbar-button.d.ts +10 -0
  160. package/dist/modules/file-browser/file-browser.d.ts +6 -0
  161. package/dist/modules/file-browser/index.d.ts +1 -0
  162. package/dist/modules/file-browser/style.css +158 -0
  163. package/dist/modules/file-browser/types.d.ts +101 -0
  164. package/dist/modules/file-browser.js +1 -0
  165. package/dist/modules/scope-cascade/controller.d.ts +6 -0
  166. package/dist/modules/scope-cascade/index.d.ts +3 -0
  167. package/dist/modules/scope-cascade/scope-cascade.d.ts +3 -0
  168. package/dist/modules/scope-cascade/style.css +456 -0
  169. package/dist/modules/scope-cascade/style.js +0 -0
  170. package/dist/modules/scope-cascade/types.d.ts +39 -0
  171. package/dist/modules/scope-cascade/use-scope-cascade.d.ts +5 -0
  172. package/dist/modules/scope-cascade.js +1 -0
  173. package/dist/modules/style.css +808 -0
  174. package/dist/modules/style.js +0 -0
  175. package/dist/n~0.js +727 -0
  176. package/dist/shared/components/tooltip/index.d.ts +1 -0
  177. package/dist/shared/components/tooltip/tooltip.d.ts +25 -0
  178. package/dist/shared/components/tooltip/types.d.ts +42 -0
  179. package/dist/shared/components/tooltip/use-tooltip-position.d.ts +38 -0
  180. package/dist/style.css +15138 -18
  181. package/dist/u~0.js +1601 -0
  182. package/dist/viking-bot-composer~0.js +164 -0
  183. package/dist/viking-bot-interaction~0.js +284 -0
  184. package/dist/w~0.js +19 -0
  185. package/package.json +46 -22
  186. package/dist/components/resource-import/resource-import.d.ts +0 -1
  187. package/dist/components/resource-import/style.css +0 -2
  188. package/dist/components/status-badge/status-badge.d.ts +0 -8
  189. package/dist/components/status-badge/style.css +0 -37
  190. package/dist/components/status-badge.js +0 -30
  191. /package/dist/components/{resource-import → viking-bot/interaction}/style.js +0 -0
  192. /package/dist/{components/status-badge → modules/console}/style.js +0 -0
  193. /package/dist/{components/resource-import.js → modules/file-browser/style.js} +0 -0
@@ -0,0 +1,164 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
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 ? [
12
+ {
13
+ type: TEXT,
14
+ text
15
+ }
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
21
+ };
22
+ const senderRef = useRef(null);
23
+ const fileRef = useRef(null);
24
+ const readOnly = !onValueChange;
25
+ const remaining = Math.max(0, maxAttachments - attachments.length);
26
+ const limitReached = 0 === remaining;
27
+ const setText = useCallback((text)=>{
28
+ senderRef.current?.setValue(toRichText(text));
29
+ onValueChange?.(text);
30
+ }, [
31
+ onValueChange
32
+ ]);
33
+ useEffect(()=>{
34
+ const current = toPlainText(senderRef.current?.getValue() ?? []);
35
+ if (current === value) return;
36
+ senderRef.current?.setValue(toRichText(value));
37
+ }, [
38
+ value
39
+ ]);
40
+ const reportFiles = useCallback((files)=>{
41
+ if (!onFilesAdded || 0 === files.length || limitReached) return;
42
+ const accepted = files.slice(0, remaining);
43
+ if (accepted.length) onFilesAdded(accepted);
44
+ }, [
45
+ limitReached,
46
+ onFilesAdded,
47
+ remaining
48
+ ]);
49
+ useImperativeHandle(ref, ()=>({
50
+ setText,
51
+ appendText: (text)=>setText(`${value}${text}`),
52
+ addFiles: (files)=>reportFiles(files),
53
+ isAttachmentLimitReached: ()=>limitReached,
54
+ clear: ()=>setText(''),
55
+ focus: ()=>senderRef.current?.getEditor()?.commands.focus('end')
56
+ }));
57
+ const submit = ()=>{
58
+ if (!onSend || disabled || isSending) return;
59
+ const text = toPlainText(senderRef.current?.getValue() ?? toRichText(value));
60
+ onSend({
61
+ text,
62
+ attachments
63
+ });
64
+ };
65
+ const interceptDrop = Boolean(onFilesAdded);
66
+ const acceptDrop = interceptDrop && !disabled && !limitReached;
67
+ return /*#__PURE__*/ jsxs("div", {
68
+ className: [
69
+ 'ov-viking-bot__composer',
70
+ `ov-viking-bot__composer--${variant}`,
71
+ className
72
+ ].filter(Boolean).join(' '),
73
+ onDragOver: (event)=>{
74
+ if (!interceptDrop) return;
75
+ event.preventDefault();
76
+ event.dataTransfer.dropEffect = acceptDrop ? 'copy' : 'none';
77
+ },
78
+ onDrop: (event)=>{
79
+ if (!interceptDrop) return;
80
+ event.preventDefault();
81
+ if (!acceptDrop) return;
82
+ reportFiles([
83
+ ...event.dataTransfer.files ?? []
84
+ ]);
85
+ },
86
+ children: [
87
+ disabled && disabledReason ? /*#__PURE__*/ jsx("p", {
88
+ className: "ov-viking-bot__composer-hint",
89
+ role: "status",
90
+ children: disabledReason
91
+ }) : 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,
113
+ /*#__PURE__*/ jsx(Sender, {
114
+ ref: senderRef,
115
+ className: "ov-viking-bot__sender",
116
+ defaultContent: toRichText(value),
117
+ sending: isSending,
118
+ sendDisabled: disabled || readOnly,
119
+ onContentChange: (content)=>{
120
+ if (!readOnly) onValueChange?.(toPlainText(content));
121
+ },
122
+ onSend: ()=>{
123
+ submit();
124
+ },
125
+ onStop: ()=>onCancel?.(),
126
+ richTextAreaProps: {
127
+ placeholder: labels.placeholder,
128
+ disabled
129
+ },
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
+ ]
159
+ })
160
+ })
161
+ ]
162
+ });
163
+ });
164
+ export { viking_bot_composer_VikingBotComposerView as VikingBotComposerView };
@@ -0,0 +1,284 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { AskHuman } from "@ark-design/ui/ask-human";
3
+ import { useState } from "react";
4
+ import { DEFAULT_INTERACTION_LABELS } from "./c7~0.js";
5
+ const toFields = (request)=>{
6
+ if ('choice' === request.kind) return [
7
+ {
8
+ type: 'single-select',
9
+ field: 'value',
10
+ options: request.options.map((option)=>({
11
+ value: option.value,
12
+ label: option.label,
13
+ description: option.description
14
+ })),
15
+ allowCustomInput: request.allowCustomInput
16
+ }
17
+ ];
18
+ if ('repair' === request.kind) return [
19
+ {
20
+ type: 'single-select',
21
+ field: 'value',
22
+ formItemProps: request.initialValue ? {
23
+ initialValue: {
24
+ type: 'option',
25
+ value: request.initialValue
26
+ }
27
+ } : void 0,
28
+ options: request.options.map((option)=>({
29
+ value: option.id,
30
+ label: option.label,
31
+ description: option.description
32
+ }))
33
+ }
34
+ ];
35
+ return [
36
+ {
37
+ type: `viking-bot-${request.kind}`,
38
+ field: 'value',
39
+ extra: {
40
+ request
41
+ }
42
+ }
43
+ ];
44
+ };
45
+ const toAnswer = (request, value)=>{
46
+ const raw = value.value;
47
+ if ('choice' === request.kind || 'repair' === request.kind) {
48
+ const selected = raw;
49
+ return {
50
+ kind: request.kind,
51
+ value: selected?.type === 'custom' ? selected.customText ?? '' : selected?.value ?? ''
52
+ };
53
+ }
54
+ if ('text' === request.kind) return {
55
+ kind: 'text',
56
+ value: 'string' == typeof raw ? raw : ''
57
+ };
58
+ if ('schedule' === request.kind) return {
59
+ kind: 'schedule',
60
+ value: raw
61
+ };
62
+ return {
63
+ kind: 'custom',
64
+ value: raw
65
+ };
66
+ };
67
+ const toDefaultValue = (request)=>{
68
+ if ('choice' === request.kind) return;
69
+ if ('repair' === request.kind) return request.initialValue ? {
70
+ value: {
71
+ type: 'option',
72
+ value: request.initialValue
73
+ }
74
+ } : void 0;
75
+ if ('text' === request.kind) return {
76
+ value: request.initialValue ?? ''
77
+ };
78
+ if ('schedule' === request.kind) return {
79
+ value: request.initialValue
80
+ };
81
+ };
82
+ const isValidAnswer = (request, value)=>{
83
+ const raw = value.value;
84
+ if ('choice' === request.kind) {
85
+ if (!raw || 'object' != typeof raw) return false;
86
+ const selected = raw;
87
+ if ('custom' === selected.type) return Boolean(selected.customText?.trim());
88
+ return request.options.some((option)=>option.value === selected.value);
89
+ }
90
+ if ('repair' === request.kind) {
91
+ const selected = raw;
92
+ if (!selected || 'object' != typeof selected) return false;
93
+ return request.options.some((option)=>option.id === selected.value);
94
+ }
95
+ return true;
96
+ };
97
+ const DEFAULT_TIME = '09:00';
98
+ function ScheduleInput({ request, labels, disabled, onChange }) {
99
+ const [value, setValue] = useState(request.initialValue);
100
+ const time = 'none' === value.mode ? DEFAULT_TIME : value.time;
101
+ const weekday = 'weekly' === value.mode ? value.weekday : 1;
102
+ const update = (next)=>{
103
+ setValue(next);
104
+ onChange(next);
105
+ };
106
+ return /*#__PURE__*/ jsxs("div", {
107
+ className: "ov-viking-bot__schedule",
108
+ children: [
109
+ /*#__PURE__*/ jsxs("select", {
110
+ className: "ov-viking-bot__interaction-input",
111
+ value: value.mode,
112
+ disabled: disabled,
113
+ "aria-label": labels.scheduleWeekly,
114
+ onChange: (event)=>{
115
+ const mode = event.target.value;
116
+ if ('none' === mode) update({
117
+ mode: 'none'
118
+ });
119
+ else 'daily' === mode ? update({
120
+ mode: 'daily',
121
+ time
122
+ }) : update({
123
+ mode: 'weekly',
124
+ time,
125
+ weekday
126
+ });
127
+ },
128
+ children: [
129
+ /*#__PURE__*/ jsx("option", {
130
+ value: "none",
131
+ children: labels.scheduleNone
132
+ }),
133
+ /*#__PURE__*/ jsx("option", {
134
+ value: "daily",
135
+ children: labels.scheduleDaily
136
+ }),
137
+ /*#__PURE__*/ jsx("option", {
138
+ value: "weekly",
139
+ children: labels.scheduleWeekly
140
+ })
141
+ ]
142
+ }),
143
+ 'none' !== value.mode ? /*#__PURE__*/ jsx("input", {
144
+ type: "time",
145
+ className: "ov-viking-bot__interaction-input",
146
+ value: time,
147
+ disabled: disabled,
148
+ "aria-label": labels.scheduleTime,
149
+ onChange: (event)=>update('weekly' === value.mode ? {
150
+ mode: 'weekly',
151
+ time: event.target.value,
152
+ weekday
153
+ } : {
154
+ mode: 'daily',
155
+ time: event.target.value
156
+ })
157
+ }) : null,
158
+ 'weekly' === value.mode ? /*#__PURE__*/ jsx("select", {
159
+ className: "ov-viking-bot__interaction-input",
160
+ value: weekday,
161
+ disabled: disabled,
162
+ "aria-label": labels.scheduleWeekday,
163
+ onChange: (event)=>update({
164
+ mode: 'weekly',
165
+ time,
166
+ weekday: Number(event.target.value)
167
+ }),
168
+ children: labels.weekdays.map((name, index)=>/*#__PURE__*/ jsx("option", {
169
+ value: index + 1,
170
+ children: name
171
+ }, name))
172
+ }) : null,
173
+ request.timezone ? /*#__PURE__*/ jsx("small", {
174
+ className: "ov-viking-bot__interaction-hint",
175
+ children: request.timezone
176
+ }) : null
177
+ ]
178
+ });
179
+ }
180
+ const TextInput = ({ request, disabled, onChange })=>/*#__PURE__*/ jsxs(Fragment, {
181
+ children: [
182
+ request.description ? /*#__PURE__*/ jsx("p", {
183
+ children: request.description
184
+ }) : null,
185
+ /*#__PURE__*/ jsx("textarea", {
186
+ className: "ov-viking-bot__interaction-input",
187
+ defaultValue: request.initialValue,
188
+ disabled: disabled,
189
+ "aria-label": "answer",
190
+ onChange: (event)=>onChange(event.target.value)
191
+ })
192
+ ]
193
+ });
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
+ };
199
+ const blocked = Boolean(disabled || submitting);
200
+ const formKey = requestKey ?? `${request.kind}:${index}`;
201
+ const rootClass = [
202
+ 'ov-viking-bot__interaction',
203
+ className
204
+ ].filter(Boolean).join(' ');
205
+ if ('custom' === request.kind) return /*#__PURE__*/ jsxs("section", {
206
+ className: rootClass,
207
+ "aria-label": labels.title,
208
+ "aria-busy": submitting || void 0,
209
+ children: [
210
+ error ? /*#__PURE__*/ jsx("p", {
211
+ className: "ov-viking-bot__interaction-error",
212
+ role: "alert",
213
+ children: error
214
+ }) : null,
215
+ request.render({
216
+ disabled: blocked,
217
+ submitting,
218
+ submit: (value)=>void onSubmit?.({
219
+ kind: 'custom',
220
+ value
221
+ }),
222
+ cancel: ()=>onCancel?.()
223
+ })
224
+ ]
225
+ });
226
+ const steps = [
227
+ {
228
+ key: request.kind,
229
+ title: request.question,
230
+ fields: toFields(request),
231
+ extra: {
232
+ index,
233
+ total
234
+ }
235
+ }
236
+ ];
237
+ return /*#__PURE__*/ jsxs("section", {
238
+ className: rootClass,
239
+ "aria-label": labels.title,
240
+ "aria-busy": submitting || void 0,
241
+ children: [
242
+ total > 1 ? /*#__PURE__*/ jsx("p", {
243
+ className: "ov-viking-bot__interaction-progress",
244
+ children: labels.progress(index, total)
245
+ }) : null,
246
+ error ? /*#__PURE__*/ jsx("p", {
247
+ className: "ov-viking-bot__interaction-error",
248
+ role: "alert",
249
+ children: error
250
+ }) : null,
251
+ /*#__PURE__*/ jsx(AskHuman, {
252
+ steps: steps,
253
+ current: 0,
254
+ defaultValue: toDefaultValue(request),
255
+ showSkip: Boolean(onCancel),
256
+ skipText: labels.cancel,
257
+ submitText: labels.submit,
258
+ onSkip: ()=>{
259
+ if (blocked) return;
260
+ onCancel?.();
261
+ },
262
+ onSubmit: async (value)=>{
263
+ if (blocked) return;
264
+ if (!isValidAnswer(request, value)) return;
265
+ await onSubmit?.(toAnswer(request, value));
266
+ },
267
+ customRenderFields: {
268
+ 'viking-bot-text': ({ field, onChange })=>/*#__PURE__*/ jsx(TextInput, {
269
+ request: field.extra?.request,
270
+ disabled: blocked,
271
+ onChange: onChange
272
+ }),
273
+ 'viking-bot-schedule': ({ field, onChange })=>/*#__PURE__*/ jsx(ScheduleInput, {
274
+ request: field.extra?.request,
275
+ labels: labels,
276
+ disabled: blocked,
277
+ onChange: onChange
278
+ })
279
+ }
280
+ }, formKey)
281
+ ]
282
+ });
283
+ }
284
+ export { VikingBotInteractionView };
package/dist/w~0.js ADDED
@@ -0,0 +1,19 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Suspense, lazy } from "react";
3
+ const View = /*#__PURE__*/ lazy(async ()=>{
4
+ const { VikingBotInteractionView } = await import("./viking-bot-interaction~0.js");
5
+ return {
6
+ default: VikingBotInteractionView
7
+ };
8
+ });
9
+ function VikingBotInteraction(props) {
10
+ return /*#__PURE__*/ jsx(Suspense, {
11
+ fallback: /*#__PURE__*/ jsx("section", {
12
+ className: "ov-viking-bot__interaction ov-viking-bot__interaction--loading"
13
+ }),
14
+ children: /*#__PURE__*/ jsx(View, {
15
+ ...props
16
+ })
17
+ });
18
+ }
19
+ export { VikingBotInteraction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/react",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,65 +25,89 @@
25
25
  "types": "./dist/index.d.ts",
26
26
  "import": "./dist/index.js"
27
27
  },
28
- "./components/status-badge": {
29
- "types": "./dist/components/status-badge/status-badge.d.ts",
30
- "import": "./dist/components/status-badge.js"
31
- },
32
- "./components/status-badge/style.css": "./dist/components/status-badge/style.css",
33
28
  "./components/file-tree": {
34
- "types": "./dist/components/file-tree/file-tree.d.ts",
29
+ "types": "./dist/components/file-tree/index.d.ts",
35
30
  "import": "./dist/components/file-tree.js"
36
31
  },
37
32
  "./components/file-tree/style.css": "./dist/components/file-tree/style.css",
38
33
  "./components/file-preview": {
39
- "types": "./dist/components/file-preview/file-preview.d.ts",
34
+ "types": "./dist/components/file-preview/index.d.ts",
40
35
  "import": "./dist/components/file-preview.js"
41
36
  },
42
37
  "./components/file-preview/style.css": "./dist/components/file-preview/style.css",
43
38
  "./components/tui": {
44
- "types": "./dist/components/tui/tui.d.ts",
39
+ "types": "./dist/components/tui/index.d.ts",
45
40
  "import": "./dist/components/tui.js"
46
41
  },
47
42
  "./components/tui/style.css": "./dist/components/tui/style.css",
48
- "./components/viking-bot": {
49
- "types": "./dist/components/viking-bot/viking-bot.d.ts",
50
- "import": "./dist/components/viking-bot.js"
51
- },
52
- "./components/viking-bot/style.css": "./dist/components/viking-bot/style.css",
53
43
  "./components/scope-switcher": {
54
- "types": "./dist/components/scope-switcher/scope-switcher.d.ts",
44
+ "types": "./dist/components/scope-switcher/index.d.ts",
55
45
  "import": "./dist/components/scope-switcher.js"
56
46
  },
57
47
  "./components/scope-switcher/style.css": "./dist/components/scope-switcher/style.css",
58
48
  "./components/agent-connect": {
59
- "types": "./dist/components/agent-connect/agent-connect.d.ts",
49
+ "types": "./dist/components/agent-connect/index.d.ts",
60
50
  "import": "./dist/components/agent-connect.js"
61
51
  },
62
52
  "./components/agent-connect/style.css": "./dist/components/agent-connect/style.css",
63
- "./components/resource-import": {
64
- "types": "./dist/components/resource-import/resource-import.d.ts",
65
- "import": "./dist/components/resource-import.js"
53
+ "./components/viking-bot": {
54
+ "types": "./dist/components/viking-bot/index.d.ts",
55
+ "import": "./dist/components/viking-bot.js"
56
+ },
57
+ "./components/viking-bot/style.css": "./dist/components/viking-bot/style.css",
58
+ "./components/viking-bot/interaction": {
59
+ "types": "./dist/components/viking-bot/interaction/index.d.ts",
60
+ "import": "./dist/components/viking-bot/interaction.js"
66
61
  },
67
- "./components/resource-import/style.css": "./dist/components/resource-import/style.css",
68
62
  "./style.css": "./dist/style.css",
69
63
  "./components/style.css": "./dist/components/style.css",
64
+ "./modules/file-browser": {
65
+ "types": "./dist/modules/file-browser/index.d.ts",
66
+ "import": "./dist/modules/file-browser.js"
67
+ },
68
+ "./modules/file-browser/style.css": "./dist/modules/file-browser/style.css",
69
+ "./modules/console": {
70
+ "types": "./dist/modules/console/index.d.ts",
71
+ "import": "./dist/modules/console.js"
72
+ },
73
+ "./modules/console/style.css": "./dist/modules/console/style.css",
74
+ "./modules/style.css": "./dist/modules/style.css",
70
75
  "./package.json": "./package.json",
71
76
  "./icons": {
72
77
  "types": "./dist/icons/index.d.ts",
73
78
  "import": "./dist/icons.js"
74
- }
79
+ },
80
+ "./client": {
81
+ "types": "./dist/client/index.d.ts",
82
+ "import": "./dist/client.js"
83
+ },
84
+ "./modules/scope-cascade": {
85
+ "types": "./dist/modules/scope-cascade/index.d.ts",
86
+ "import": "./dist/modules/scope-cascade.js"
87
+ },
88
+ "./modules/scope-cascade/style.css": "./dist/modules/scope-cascade/style.css"
75
89
  },
76
90
  "scripts": {
77
- "check": "tsc --noEmit && tsc --noEmit -p tsconfig.config.json",
78
91
  "dev": "rslib build --watch",
79
92
  "build": "rslib build"
80
93
  },
81
94
  "peerDependencies": {
95
+ "@ark-design/ui": ">=0.0.0-beta.7",
82
96
  "react": "^18.2.0 || ^19.0.0",
83
97
  "react-dom": "^18.2.0 || ^19.0.0"
84
98
  },
85
99
  "devDependencies": {
100
+ "@ark-design/ui": "0.0.0-beta.7",
86
101
  "@rsbuild/plugin-react": "^2.1.1",
87
102
  "@rslib/core": "^1.0.5"
103
+ },
104
+ "peerDependenciesMeta": {
105
+ "@ark-design/ui": {
106
+ "optional": true
107
+ }
108
+ },
109
+ "dependencies": {
110
+ "react-markdown": "^10.1.0",
111
+ "remark-gfm": "^4.0.1"
88
112
  }
89
113
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { HTMLAttributes } from 'react';
2
- export type StatusBadgeStatus = 'ready' | 'processing' | 'error';
3
- export interface StatusBadgeProps extends HTMLAttributes<HTMLSpanElement> {
4
- /** The state to display. Text accompanies the color indicator. */
5
- status: StatusBadgeStatus;
6
- }
7
- /** Displays a status with a color indicator and an optional custom label. */
8
- export declare function StatusBadge({ status, children, className, ...props }: StatusBadgeProps): import("react").JSX.Element;
@@ -1,37 +0,0 @@
1
- .badge-up7fab {
2
- box-sizing: border-box;
3
- border-radius: var(--ov-ui-radius, 6px);
4
- white-space: nowrap;
5
- border: 1px solid;
6
- align-items: center;
7
- gap: .5em;
8
- padding: .3em .7em;
9
- font-family: inherit;
10
- font-size: .875rem;
11
- font-weight: 500;
12
- line-height: 1.5;
13
- display: inline-flex;
14
- }
15
-
16
- .badge-up7fab[data-status="ready"] {
17
- color: var(--ov-ui-status-ready, #187347);
18
- }
19
-
20
- .badge-up7fab[data-status="processing"] {
21
- color: var(--ov-ui-status-processing, #2563c5);
22
- }
23
-
24
- .badge-up7fab[data-status="error"] {
25
- color: var(--ov-ui-status-error, #c43838);
26
- }
27
-
28
- .indicator-EU2f1X {
29
- background: currentColor;
30
- border-radius: 50%;
31
- flex: none;
32
- width: .45em;
33
- height: .45em;
34
- }
35
-
36
-
37
-
@@ -1,30 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- const status_badge_module = {
3
- badge: "badge-up7fab",
4
- indicator: "indicator-EU2f1X"
5
- };
6
- const labels = {
7
- ready: 'Ready',
8
- processing: 'Processing',
9
- error: 'Error'
10
- };
11
- function StatusBadge({ status, children, className, ...props }) {
12
- return /*#__PURE__*/ jsxs("span", {
13
- ...props,
14
- className: [
15
- status_badge_module.badge,
16
- className
17
- ].filter(Boolean).join(' '),
18
- "data-status": status,
19
- children: [
20
- /*#__PURE__*/ jsx("span", {
21
- className: status_badge_module.indicator,
22
- "aria-hidden": "true"
23
- }),
24
- /*#__PURE__*/ jsx("span", {
25
- children: children ?? labels[status]
26
- })
27
- ]
28
- });
29
- }
30
- export { StatusBadge };