@openviking/react 0.1.1 → 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.
- package/README.md +18 -15
- package/dist/3~0.js +2113 -4
- package/dist/ark-message-list-view~0.js +310 -0
- package/dist/c7~0.js +24 -0
- package/dist/components/agent-connect/agent-connect-copy.d.ts +34 -0
- package/dist/components/agent-connect/agent-connect-design.d.ts +1781 -0
- package/dist/components/agent-connect/agent-connect-detail.d.ts +13 -0
- package/dist/components/agent-connect/agent-connect-installer.d.ts +3 -0
- package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +14 -0
- package/dist/components/agent-connect/agent-connect-instructions.d.ts +145 -0
- package/dist/components/agent-connect/agent-connect-markdown.d.ts +3 -0
- package/dist/components/agent-connect/agent-connect.d.ts +3 -3
- package/dist/components/agent-connect/content-en.d.ts +137 -0
- package/dist/components/agent-connect/content-zh.d.ts +137 -0
- package/dist/components/agent-connect/style.css +495 -6
- package/dist/components/agent-connect/types.d.ts +20 -166
- package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
- package/dist/components/file-preview/file-preview-body.d.ts +24 -12
- package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +16 -0
- package/dist/components/file-preview/file-preview-breadcrumb.d.ts +21 -0
- package/dist/components/file-preview/file-preview-copy-path.d.ts +12 -0
- package/dist/components/file-preview/file-preview-editor.d.ts +22 -0
- package/dist/components/file-preview/file-preview-handle-adapters.d.ts +26 -0
- package/dist/components/file-preview/file-preview-header.d.ts +23 -14
- package/dist/components/file-preview/file-preview-labels.d.ts +15 -4
- package/dist/components/file-preview/file-preview-lazy-viewer.d.ts +3 -0
- package/dist/components/file-preview/file-preview-path.d.ts +30 -0
- package/dist/components/file-preview/file-preview-source.d.ts +24 -0
- package/dist/components/file-preview/file-preview-state.d.ts +28 -0
- package/dist/components/file-preview/file-preview-tab-row.d.ts +16 -0
- package/dist/components/file-preview/file-preview-viewer.d.ts +31 -0
- package/dist/components/file-preview/file-preview.d.ts +8 -11
- package/dist/components/file-preview/style.css +3984 -128
- package/dist/components/file-preview/types.d.ts +250 -169
- package/dist/components/file-preview/use-file-preview-actions-context.d.ts +23 -0
- package/dist/components/file-preview/use-file-preview-actions.d.ts +19 -0
- package/dist/components/file-preview/use-file-preview-editing.d.ts +21 -2
- package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
- package/dist/components/file-preview.js +1 -442
- package/dist/components/file-tree/file-tree-body.d.ts +8 -4
- package/dist/components/file-tree/file-tree-entry-row.d.ts +9 -3
- package/dist/components/file-tree/file-tree-icons.d.ts +12 -5
- package/dist/components/file-tree/file-tree-info-labels.d.ts +21 -0
- package/dist/components/file-tree/file-tree-info-tooltip.d.ts +43 -0
- package/dist/components/file-tree/file-tree-info.d.ts +29 -0
- package/dist/components/file-tree/file-tree-keyboard.d.ts +8 -4
- package/dist/components/file-tree/file-tree-row-context.d.ts +31 -9
- package/dist/components/file-tree/file-tree-row-shared.d.ts +11 -0
- package/dist/components/file-tree/file-tree-spinner.d.ts +10 -0
- package/dist/components/file-tree/file-tree-state-row.d.ts +7 -0
- package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +22 -0
- package/dist/components/file-tree/file-tree-tooltip.d.ts +9 -3
- package/dist/components/file-tree/file-tree.d.ts +12 -1
- package/dist/components/file-tree/style.css +225 -57
- package/dist/components/file-tree/types.d.ts +183 -0
- package/dist/components/file-tree/use-file-tree-actions.d.ts +7 -0
- package/dist/components/file-tree.js +1 -1
- package/dist/components/scope-switcher/scope-panel.d.ts +9 -3
- package/dist/components/scope-switcher/scope-selector.d.ts +1 -1
- package/dist/components/scope-switcher/scope-switcher.d.ts +1 -1
- package/dist/components/scope-switcher/style.css +282 -76
- package/dist/components/scope-switcher/types.d.ts +230 -108
- package/dist/components/style.css +13845 -372
- package/dist/components/tui/command-catalog.d.ts +58 -0
- package/dist/components/tui/command-completion.d.ts +19 -0
- package/dist/components/tui/command-definitions.d.ts +10 -0
- package/dist/components/tui/command-input.d.ts +16 -0
- package/dist/components/tui/style.css +1543 -5
- package/dist/components/tui/tui-assist.d.ts +15 -0
- package/dist/components/tui/tui-code-block.d.ts +8 -0
- package/dist/components/tui/tui-command-help.d.ts +9 -0
- package/dist/components/tui/tui-command-text.d.ts +6 -0
- package/dist/components/tui/tui-composer.d.ts +24 -0
- package/dist/components/tui/tui-copy-button.d.ts +9 -0
- package/dist/components/tui/tui-input-mirror.d.ts +14 -0
- package/dist/components/tui/tui-labels-zh.d.ts +2 -0
- package/dist/components/tui/tui-labels.d.ts +5 -0
- package/dist/components/tui/tui-markdown-renderers.d.ts +10 -0
- package/dist/components/tui/tui-markdown.d.ts +6 -0
- package/dist/components/tui/tui-param-hint.d.ts +7 -0
- package/dist/components/tui/tui-record-time.d.ts +11 -0
- package/dist/components/tui/tui-record.d.ts +13 -0
- package/dist/components/tui/tui-resource-preview.d.ts +10 -0
- package/dist/components/tui/tui-resource-tree.d.ts +10 -0
- package/dist/components/tui/tui-result-header.d.ts +7 -0
- package/dist/components/tui/tui-result-text.d.ts +5 -0
- package/dist/components/tui/tui-search-list.d.ts +8 -0
- package/dist/components/tui/tui-skeleton.d.ts +6 -0
- package/dist/components/tui/tui-status-card.d.ts +7 -0
- package/dist/components/tui/tui-text.d.ts +10 -0
- package/dist/components/tui/tui-uri-text.d.ts +19 -0
- package/dist/components/tui/tui-write-result.d.ts +7 -0
- package/dist/components/tui/tui.d.ts +10 -2
- package/dist/components/tui/types.d.ts +57 -15
- package/dist/components/tui/use-tui-assist-position.d.ts +3 -0
- package/dist/components/tui/use-tui-completion.d.ts +14 -0
- package/dist/components/tui/use-tui-composer-keyboard.d.ts +25 -0
- package/dist/components/viking-bot/ark-adapter.d.ts +45 -0
- package/dist/components/viking-bot/ark-message-body.d.ts +16 -0
- package/dist/components/viking-bot/ark-message-list-view.d.ts +7 -0
- package/dist/components/viking-bot/ark-message-row.d.ts +19 -0
- package/dist/components/viking-bot/index.d.ts +10 -0
- package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +10 -0
- package/dist/components/viking-bot/interaction/index.d.ts +4 -0
- package/dist/components/viking-bot/interaction/labels.d.ts +7 -0
- package/dist/components/viking-bot/interaction/lazy-interaction.d.ts +3 -0
- package/dist/components/viking-bot/interaction/schedule-input.d.ts +13 -0
- package/dist/components/viking-bot/interaction/style.css +189 -0
- package/dist/components/viking-bot/interaction/types.d.ts +188 -0
- package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +9 -0
- package/dist/components/viking-bot/interaction.js +2 -0
- package/dist/components/viking-bot/labels.d.ts +2 -0
- package/dist/components/viking-bot/lazy-composer.d.ts +3 -0
- package/dist/components/viking-bot/message-groups.d.ts +12 -0
- package/dist/components/viking-bot/model.d.ts +252 -0
- package/dist/components/viking-bot/render-part.d.ts +12 -0
- package/dist/components/viking-bot/style.css +7135 -0
- package/dist/components/viking-bot/style.js +0 -0
- package/dist/components/viking-bot/types.d.ts +140 -0
- package/dist/components/viking-bot/viking-bot-composer.d.ts +6 -0
- package/dist/components/viking-bot/viking-bot-message-list.d.ts +3 -0
- package/dist/components/viking-bot/viking-bot.d.ts +16 -0
- package/dist/components/viking-bot.js +4 -0
- package/dist/c~0.js +201 -0
- package/dist/file-preview-viewer~0.js +191 -0
- package/dist/f~0.js +149 -77
- package/dist/g~0.js +1207 -0
- package/dist/h~0.js +58 -0
- package/dist/icons/file-type-icon.d.ts +31 -0
- package/dist/icons/index.d.ts +33 -23
- package/dist/icons/nextjs-icon.d.ts +19 -0
- package/dist/icons.js +1 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/k~0.js +1440 -0
- package/dist/lk~0.js +25 -12
- package/dist/modules/console/style.css +83 -1
- package/dist/modules/file-browser/style.css +89 -6
- package/dist/modules/scope-cascade/style.css +282 -76
- package/dist/modules/style.css +533 -110
- package/dist/n~0.js +434 -206
- package/dist/shared/components/tooltip/index.d.ts +1 -0
- package/dist/shared/components/tooltip/tooltip.d.ts +25 -0
- package/dist/shared/components/tooltip/types.d.ts +42 -0
- package/dist/shared/components/tooltip/use-tooltip-position.d.ts +38 -0
- package/dist/style.css +14451 -474
- package/dist/u~0.js +1597 -4
- package/dist/viking-bot-composer~0.js +164 -0
- package/dist/viking-bot-interaction~0.js +284 -0
- package/dist/w~0.js +19 -0
- package/package.json +18 -10
- package/dist/components/file-preview/file-preview-icons.d.ts +0 -2
- package/dist/components/file-preview/file-preview-operations.d.ts +0 -1
- package/dist/components/file-tree/file-tree-dom.d.ts +0 -4
- package/dist/components/file-tree/file-tree-labels.d.ts +0 -5
- package/dist/components/file-tree/file-tree-rows.d.ts +0 -12
- package/dist/i~0.js +0 -21
- package/dist/modules/task-center/columns.d.ts +0 -129
- package/dist/modules/task-center/index.d.ts +0 -1
- package/dist/modules/task-center/style.css +0 -29
- package/dist/modules/task-center/task-center.d.ts +0 -4
- package/dist/modules/task-center/types.d.ts +0 -168
- package/dist/modules/task-center.js +0 -1
- /package/dist/{modules/task-center → components/viking-bot/interaction}/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.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,6 +50,15 @@
|
|
|
50
50
|
"import": "./dist/components/agent-connect.js"
|
|
51
51
|
},
|
|
52
52
|
"./components/agent-connect/style.css": "./dist/components/agent-connect/style.css",
|
|
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"
|
|
61
|
+
},
|
|
53
62
|
"./style.css": "./dist/style.css",
|
|
54
63
|
"./components/style.css": "./dist/components/style.css",
|
|
55
64
|
"./modules/file-browser": {
|
|
@@ -62,11 +71,6 @@
|
|
|
62
71
|
"import": "./dist/modules/console.js"
|
|
63
72
|
},
|
|
64
73
|
"./modules/console/style.css": "./dist/modules/console/style.css",
|
|
65
|
-
"./modules/task-center": {
|
|
66
|
-
"types": "./dist/modules/task-center/index.d.ts",
|
|
67
|
-
"import": "./dist/modules/task-center.js"
|
|
68
|
-
},
|
|
69
|
-
"./modules/task-center/style.css": "./dist/modules/task-center/style.css",
|
|
70
74
|
"./modules/style.css": "./dist/modules/style.css",
|
|
71
75
|
"./package.json": "./package.json",
|
|
72
76
|
"./icons": {
|
|
@@ -88,18 +92,22 @@
|
|
|
88
92
|
"build": "rslib build"
|
|
89
93
|
},
|
|
90
94
|
"peerDependencies": {
|
|
95
|
+
"@ark-design/ui": ">=0.0.0-beta.7",
|
|
91
96
|
"react": "^18.2.0 || ^19.0.0",
|
|
92
|
-
"react-dom": "^18.2.0 || ^19.0.0"
|
|
93
|
-
"@ark-design/ui": "^0.0.0-beta.5"
|
|
97
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
94
98
|
},
|
|
95
99
|
"devDependencies": {
|
|
100
|
+
"@ark-design/ui": "0.0.0-beta.7",
|
|
96
101
|
"@rsbuild/plugin-react": "^2.1.1",
|
|
97
|
-
"@rslib/core": "^1.0.5"
|
|
98
|
-
"@ark-design/ui": "0.0.0-beta.5"
|
|
102
|
+
"@rslib/core": "^1.0.5"
|
|
99
103
|
},
|
|
100
104
|
"peerDependenciesMeta": {
|
|
101
105
|
"@ark-design/ui": {
|
|
102
106
|
"optional": true
|
|
103
107
|
}
|
|
108
|
+
},
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"react-markdown": "^10.1.0",
|
|
111
|
+
"remark-gfm": "^4.0.1"
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function performPreviewOperation(execute: (() => Promise<void>) | undefined, notify: (() => void) | undefined): Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type FileTreeRowContext } from './file-tree-row-context.js';
|
|
2
|
-
import { type FileTreeRow } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* 整树级失败:只有一个错误行且没有归属父节点。
|
|
5
|
-
* Whole-tree failure: a single error row that belongs to no parent.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isWholeTreeError(rows: readonly FileTreeRow[]): boolean;
|
|
8
|
-
/** 按行类型分派渲染,条目行与状态行分别处理。 */
|
|
9
|
-
export declare function FileTreeRowView({ row, ctx, }: {
|
|
10
|
-
row: FileTreeRow;
|
|
11
|
-
ctx: FileTreeRowContext;
|
|
12
|
-
}): import("react").JSX.Element;
|
package/dist/i~0.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
function TaskCenter({ className, style, labels }) {
|
|
3
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
4
|
-
className: [
|
|
5
|
-
'ov-module-placeholder',
|
|
6
|
-
className
|
|
7
|
-
].filter(Boolean).join(' '),
|
|
8
|
-
style: style,
|
|
9
|
-
children: [
|
|
10
|
-
/*#__PURE__*/ jsx("p", {
|
|
11
|
-
className: "ov-module-placeholder__title",
|
|
12
|
-
children: labels?.title ?? 'Task center'
|
|
13
|
-
}),
|
|
14
|
-
/*#__PURE__*/ jsx("p", {
|
|
15
|
-
className: "ov-module-placeholder__description",
|
|
16
|
-
children: labels?.description ?? 'Placeholder. Functionality is not available yet.'
|
|
17
|
-
})
|
|
18
|
-
]
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export { TaskCenter };
|