@openviking/react 0.1.5 → 0.1.7
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 +15 -11
- package/dist/2~0.js +6 -5
- package/dist/37~0.js +27 -0
- package/dist/3c~0.js +24 -12
- package/dist/3~0.js +19 -9
- package/dist/ae~0.js +8 -1
- package/dist/ark-message-list-view~0.js +9 -4
- package/dist/a~0.js +13 -7
- package/dist/c7r~0.js +50 -0
- package/dist/ck~0.js +7 -0
- package/dist/client/paths.d.ts +10 -0
- package/dist/client/provider.d.ts +6 -1
- package/dist/components/agent-connect/style.css +268 -37
- package/dist/components/directory-tour/style.css +265 -21
- package/dist/components/directory-tour.js +1 -1
- package/dist/components/experience-dashboard/dashboard-tabs.d.ts +11 -0
- package/dist/components/experience-dashboard/experience-dashboard.d.ts +2 -0
- package/dist/components/experience-dashboard/experience-impact.d.ts +11 -0
- package/dist/components/experience-dashboard/experience-list.d.ts +9 -0
- package/dist/components/experience-dashboard/experience-pagination.d.ts +8 -0
- package/dist/components/experience-dashboard/experience-tests.d.ts +6 -0
- package/dist/components/experience-dashboard/experience-trajectories.d.ts +6 -0
- package/dist/components/experience-dashboard/index.d.ts +2 -0
- package/dist/components/experience-dashboard/labels.d.ts +2 -0
- package/dist/components/experience-dashboard/style.css +914 -0
- package/dist/components/experience-dashboard/style.js +0 -0
- package/dist/components/experience-dashboard/types.d.ts +106 -0
- package/dist/components/experience-dashboard.js +1 -0
- package/dist/components/file-browser-entries/style.css +463 -86
- package/dist/components/file-preview/style.css +267 -78
- package/dist/components/file-tree/file-tree-toolbar.d.ts +3 -3
- package/dist/components/file-tree/locales/en-US.d.ts +3 -0
- package/dist/components/file-tree/locales/zh-CN.d.ts +3 -0
- package/dist/components/file-tree/style.css +372 -88
- package/dist/components/file-tree/types.d.ts +13 -4
- package/dist/components/scope-switcher/style.css +412 -39
- package/dist/components/style.css +9326 -4553
- package/dist/components/tui/style.css +385 -67
- package/dist/components/viking-bot/interaction/style.css +143 -22
- package/dist/components/viking-bot/style.css +1075 -278
- package/dist/components/wiki-dashboard/index.d.ts +2 -0
- package/dist/components/wiki-dashboard/labels.d.ts +2 -0
- package/dist/components/wiki-dashboard/style.css +956 -0
- package/dist/components/wiki-dashboard/style.js +0 -0
- package/dist/components/wiki-dashboard/types.d.ts +92 -0
- package/dist/components/wiki-dashboard/wiki-action-button.d.ts +9 -0
- package/dist/components/wiki-dashboard/wiki-conflict-card.d.ts +15 -0
- package/dist/components/wiki-dashboard/wiki-dashboard.d.ts +2 -0
- package/dist/components/wiki-dashboard/wiki-file-icon.d.ts +3 -0
- package/dist/components/wiki-dashboard/wiki-severity-filter.d.ts +8 -0
- package/dist/components/wiki-dashboard.js +1 -0
- package/dist/c~0.js +16 -8
- package/dist/ep~0.js +345 -0
- package/dist/e~0.js +33 -328
- package/dist/fj~0.js +507 -0
- package/dist/fl~0.js +709 -0
- package/dist/f~0.js +12 -27
- package/dist/icons/index.d.ts +28 -0
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -1
- package/dist/k~0.js +277 -1
- package/dist/lk~0.js +56 -14
- package/dist/l~0.js +2786 -446
- package/dist/modules/console/index.d.ts +1 -2
- package/dist/modules/console/style.css +1787 -346
- package/dist/modules/console.js +1 -1
- package/dist/modules/file-browser/acl/acl-add-principal.d.ts +12 -0
- package/dist/modules/file-browser/acl/acl-candidate.d.ts +8 -0
- package/dist/modules/file-browser/acl/acl-client.d.ts +13 -0
- package/dist/modules/file-browser/acl/acl-confirmation.d.ts +6 -0
- package/dist/modules/file-browser/acl/acl-entry.d.ts +13 -0
- package/dist/modules/file-browser/acl/acl-labels.d.ts +47 -0
- package/dist/modules/file-browser/acl/acl-menu.d.ts +10 -0
- package/dist/modules/file-browser/acl/acl-modal.d.ts +17 -0
- package/dist/modules/file-browser/acl/acl-model.d.ts +17 -0
- package/dist/modules/file-browser/acl/acl-principal-tabs.d.ts +6 -0
- package/dist/modules/file-browser/acl/acl-tag.d.ts +7 -0
- package/dist/modules/file-browser/acl/locales/en-US.d.ts +44 -0
- package/dist/modules/file-browser/acl/locales/zh-CN.d.ts +44 -0
- package/dist/modules/file-browser/acl/use-acl-principals.d.ts +17 -0
- package/dist/modules/file-browser/acl/use-acl-report.d.ts +27 -0
- package/dist/modules/file-browser/acl-types.d.ts +86 -0
- package/dist/modules/file-browser/dashboard-data.d.ts +9 -0
- package/dist/modules/file-browser/dashboard-indicator.d.ts +8 -0
- package/dist/modules/file-browser/dashboard-labels.d.ts +9 -0
- package/dist/modules/file-browser/dashboard-model.d.ts +17 -0
- package/dist/modules/file-browser/dashboard-resource.d.ts +12 -0
- package/dist/modules/file-browser/experience-dashboard-pane.d.ts +8 -0
- package/dist/modules/file-browser/experience-data.d.ts +31 -0
- package/dist/modules/file-browser/file-browser-detail.d.ts +4 -1
- package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
- package/dist/modules/file-browser/file-browser-search.d.ts +20 -0
- package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -10
- package/dist/modules/file-browser/file-browser-tree-pane.d.ts +4 -7
- package/dist/modules/file-browser/file-browser.d.ts +1 -1
- package/dist/modules/file-browser/fs-directories.d.ts +9 -0
- package/dist/modules/file-browser/fs-lines.d.ts +36 -0
- package/dist/modules/file-browser/fs-memory-fields.d.ts +65 -0
- package/dist/modules/file-browser/fs-model.d.ts +15 -3
- package/dist/modules/file-browser/fs-read-file.d.ts +14 -0
- package/dist/modules/file-browser/index.d.ts +3 -2
- package/dist/modules/file-browser/locales/en-US.d.ts +5 -0
- package/dist/modules/file-browser/locales/zh-CN.d.ts +5 -0
- package/dist/modules/file-browser/style.css +4033 -483
- package/dist/modules/file-browser/types.d.ts +82 -20
- package/dist/modules/file-browser/use-browser-dashboards.d.ts +31 -0
- package/dist/modules/file-browser/use-dashboard-query.d.ts +9 -0
- package/dist/modules/file-browser/use-experience-dashboard.d.ts +27 -0
- package/dist/modules/file-browser/use-file-browser-acl.d.ts +15 -0
- package/dist/modules/file-browser/use-file-browser.d.ts +6 -51
- package/dist/modules/file-browser/use-fs-tree.d.ts +3 -0
- package/dist/modules/file-browser/use-wiki-dashboard.d.ts +17 -0
- package/dist/modules/file-browser/wiki-conflicts.d.ts +12 -0
- package/dist/modules/file-browser/wiki-dashboard-pane.d.ts +14 -0
- package/dist/modules/file-browser.js +1 -1
- package/dist/modules/scope-cascade/controller.d.ts +2 -2
- package/dist/modules/scope-cascade/index.d.ts +1 -2
- package/dist/modules/scope-cascade/scope-cascade.d.ts +1 -1
- package/dist/modules/scope-cascade/style.css +581 -39
- package/dist/modules/scope-cascade/types.d.ts +8 -3
- package/dist/modules/scope-cascade/use-scope-cascade.d.ts +2 -2
- package/dist/modules/scope-cascade.js +1 -1
- package/dist/modules/style.css +13589 -7966
- package/dist/n~0.js +73 -165
- package/dist/rt~0.js +255 -0
- package/dist/r~0.js +18 -39
- package/dist/shared/components/button/button.d.ts +20 -0
- package/dist/shared/components/input/input.d.ts +17 -0
- package/dist/shared/components/modal/locales/en-US.d.ts +4 -0
- package/dist/shared/components/modal/locales/zh-CN.d.ts +4 -0
- package/dist/shared/components/modal/modal.d.ts +2 -0
- package/dist/shared/components/modal/types.d.ts +18 -0
- package/dist/shared/components/overlay/lock-body-scroll.d.ts +1 -0
- package/dist/shared/components/popover/popover.d.ts +1 -1
- package/dist/shared/components/popover/types.d.ts +7 -1
- package/dist/shared/dashboard/dashboard-state.d.ts +12 -0
- package/dist/static/image/dashboard-background.png +0 -0
- package/dist/style.css +16088 -5602
- package/dist/s~0.js +16 -0
- package/dist/u~0.js +15 -6
- package/dist/viking-bot-composer~0.js +30 -12
- package/dist/viking-bot-interaction~0.js +2 -1
- package/package.json +14 -3
- package/dist/o~0.js +0 -106
package/dist/fl~0.js
ADDED
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { mergeLabels } from "./nx~0.js";
|
|
4
|
+
import { FileInputIcon, ScanSearchIcon, ActivityIcon } from "./k~0.js";
|
|
5
|
+
import { DashboardState } from "./37~0.js";
|
|
6
|
+
import { button_Button } from "./e~0.js";
|
|
7
|
+
import { useLocale } from "./28~0.js";
|
|
8
|
+
function DashboardTabs({ tabs, active, label, onChange, children }) {
|
|
9
|
+
const id = useId();
|
|
10
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
11
|
+
children: [
|
|
12
|
+
/*#__PURE__*/ jsx("div", {
|
|
13
|
+
className: "ov-dashboard-tabs",
|
|
14
|
+
role: "tablist",
|
|
15
|
+
tabIndex: -1,
|
|
16
|
+
"aria-label": label,
|
|
17
|
+
onKeyDown: (event)=>{
|
|
18
|
+
const delta = 'ArrowRight' === event.key ? 1 : 'ArrowLeft' === event.key ? -1 : 0;
|
|
19
|
+
if (!delta && 'Home' !== event.key && 'End' !== event.key) return;
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
const index = 'Home' === event.key ? 0 : 'End' === event.key ? tabs.length - 1 : (tabs.findIndex((tab)=>tab.key === active) + delta + tabs.length) % tabs.length;
|
|
22
|
+
onChange(tabs[index].key);
|
|
23
|
+
const buttons = event.currentTarget.querySelectorAll('[role="tab"]');
|
|
24
|
+
buttons[index]?.focus();
|
|
25
|
+
},
|
|
26
|
+
children: tabs.map((tab)=>/*#__PURE__*/ jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
id: `${id}-${tab.key}`,
|
|
29
|
+
role: "tab",
|
|
30
|
+
"aria-selected": active === tab.key,
|
|
31
|
+
"aria-controls": `${id}-panel`,
|
|
32
|
+
tabIndex: active === tab.key ? 0 : -1,
|
|
33
|
+
onClick: ()=>onChange(tab.key),
|
|
34
|
+
children: tab.title
|
|
35
|
+
}, tab.key))
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ jsx("div", {
|
|
38
|
+
role: "tabpanel",
|
|
39
|
+
id: `${id}-panel`,
|
|
40
|
+
"aria-labelledby": `${id}-${active}`,
|
|
41
|
+
className: "ov-dashboard-tabpanel",
|
|
42
|
+
children: children
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const en = {
|
|
48
|
+
latest: 'Latest experience',
|
|
49
|
+
sourceCount: 'Generated from {count} trajectories',
|
|
50
|
+
sourceUri: 'Source Trajectory URI',
|
|
51
|
+
task: 'Task',
|
|
52
|
+
copy: 'Copy',
|
|
53
|
+
copied: 'Copied',
|
|
54
|
+
copyFailed: 'Copy failed',
|
|
55
|
+
title: 'Agent experiences',
|
|
56
|
+
allExperiences: 'All experiences',
|
|
57
|
+
index: 'No.',
|
|
58
|
+
impact: 'Application impact',
|
|
59
|
+
source: 'Source trace',
|
|
60
|
+
test: 'Test',
|
|
61
|
+
application: 'Experience application data',
|
|
62
|
+
notice: 'AI-generated data may contain errors',
|
|
63
|
+
injection: 'Context injections',
|
|
64
|
+
recall: 'Retrieval recalls',
|
|
65
|
+
listRecall: 'Experience recalls',
|
|
66
|
+
rate: 'Injection rate',
|
|
67
|
+
outcomes: 'Outcome distribution',
|
|
68
|
+
trajectories: 'Application trajectories',
|
|
69
|
+
empty: 'No experiences',
|
|
70
|
+
emptySource: 'No source records',
|
|
71
|
+
emptyTests: 'No test materials',
|
|
72
|
+
emptyOutcomes: 'No distribution data',
|
|
73
|
+
loading: 'Loading…',
|
|
74
|
+
failed: 'Could not load data',
|
|
75
|
+
retry: 'Retry',
|
|
76
|
+
previous: 'Previous',
|
|
77
|
+
next: 'Next',
|
|
78
|
+
all: 'All time',
|
|
79
|
+
week: 'Last 7 days',
|
|
80
|
+
month: 'Last 30 days',
|
|
81
|
+
range: 'Statistics period',
|
|
82
|
+
updated: 'Updated',
|
|
83
|
+
name: 'Experience',
|
|
84
|
+
success: 'Task success',
|
|
85
|
+
partial: 'Partial success',
|
|
86
|
+
unfinished: 'Unfinished',
|
|
87
|
+
failure: 'Failure',
|
|
88
|
+
unknown: 'Unknown',
|
|
89
|
+
unsupportedMetric: 'Metric not provided',
|
|
90
|
+
open: 'Open'
|
|
91
|
+
};
|
|
92
|
+
const zh = {
|
|
93
|
+
latest: '最新经验',
|
|
94
|
+
sourceCount: '由 {count} 条轨迹生成',
|
|
95
|
+
sourceUri: '来源 Trajectory URI',
|
|
96
|
+
task: '任务描述',
|
|
97
|
+
copy: '复制',
|
|
98
|
+
copied: '已复制',
|
|
99
|
+
copyFailed: '复制失败',
|
|
100
|
+
title: 'Agent 经验',
|
|
101
|
+
allExperiences: '全部经验',
|
|
102
|
+
index: '序号',
|
|
103
|
+
impact: '应用效果',
|
|
104
|
+
source: '来源追溯',
|
|
105
|
+
test: '测试',
|
|
106
|
+
application: '经验应用数据',
|
|
107
|
+
notice: '数据由 AI 生成,可能有误',
|
|
108
|
+
injection: '注入上下文次数',
|
|
109
|
+
recall: '检索召回次数',
|
|
110
|
+
listRecall: '经验召回次数',
|
|
111
|
+
rate: '注入率',
|
|
112
|
+
outcomes: '任务结果分布',
|
|
113
|
+
trajectories: '应用轨迹记录',
|
|
114
|
+
empty: '暂无经验',
|
|
115
|
+
emptySource: '暂无来源记录',
|
|
116
|
+
emptyTests: '暂无测试材料',
|
|
117
|
+
emptyOutcomes: '暂无可用分布数据',
|
|
118
|
+
loading: '加载中…',
|
|
119
|
+
failed: '数据加载失败',
|
|
120
|
+
retry: '重试',
|
|
121
|
+
previous: '上一页',
|
|
122
|
+
next: '下一页',
|
|
123
|
+
all: '全部时间',
|
|
124
|
+
week: '最近 7 天',
|
|
125
|
+
month: '最近 30 天',
|
|
126
|
+
range: '选择统计时间范围',
|
|
127
|
+
updated: '更新于',
|
|
128
|
+
name: '经验文件',
|
|
129
|
+
success: '任务成功',
|
|
130
|
+
partial: '部分成功',
|
|
131
|
+
unfinished: '未完成',
|
|
132
|
+
failure: '失败',
|
|
133
|
+
unknown: '未知',
|
|
134
|
+
unsupportedMetric: '未提供此指标',
|
|
135
|
+
open: '打开'
|
|
136
|
+
};
|
|
137
|
+
const experienceLabels = (locale, labels)=>mergeLabels('zh-CN' === locale ? zh : en, labels);
|
|
138
|
+
function updatedAt(value, locale) {
|
|
139
|
+
const time = Date.parse(value);
|
|
140
|
+
if (!Number.isFinite(time)) return value;
|
|
141
|
+
const seconds = (time - Date.now()) / 1000;
|
|
142
|
+
const absolute = Math.abs(seconds);
|
|
143
|
+
if (absolute >= 604800) return new Intl.DateTimeFormat(locale).format(time);
|
|
144
|
+
const [unit, size] = absolute < 3600 ? [
|
|
145
|
+
'minute',
|
|
146
|
+
60
|
|
147
|
+
] : absolute < 86400 ? [
|
|
148
|
+
'hour',
|
|
149
|
+
3600
|
|
150
|
+
] : [
|
|
151
|
+
'day',
|
|
152
|
+
86400
|
|
153
|
+
];
|
|
154
|
+
return new Intl.RelativeTimeFormat(locale, {
|
|
155
|
+
numeric: 'always'
|
|
156
|
+
}).format(Math.round(seconds / size), unit);
|
|
157
|
+
}
|
|
158
|
+
function ExperienceList({ items, total, startIndex = 0, locale = 'en-US', labels: t, onOpenUri }) {
|
|
159
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ jsxs("h2", {
|
|
162
|
+
className: "ov-experience-dashboard__list-title",
|
|
163
|
+
children: [
|
|
164
|
+
t.allExperiences,
|
|
165
|
+
void 0 === total ? '' : ` · ${total}`
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ jsx("div", {
|
|
169
|
+
className: "ov-experience-dashboard__table-scroll",
|
|
170
|
+
tabIndex: 0,
|
|
171
|
+
role: "region",
|
|
172
|
+
"aria-label": t.title,
|
|
173
|
+
children: /*#__PURE__*/ jsxs("table", {
|
|
174
|
+
className: "ov-experience-dashboard__table",
|
|
175
|
+
children: [
|
|
176
|
+
/*#__PURE__*/ jsx("caption", {
|
|
177
|
+
children: t.title
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ jsx("thead", {
|
|
180
|
+
children: /*#__PURE__*/ jsxs("tr", {
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ jsx("th", {
|
|
183
|
+
scope: "col",
|
|
184
|
+
children: t.index
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ jsx("th", {
|
|
187
|
+
scope: "col",
|
|
188
|
+
children: t.name
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsx("th", {
|
|
191
|
+
scope: "col",
|
|
192
|
+
children: t.injection
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ jsx("th", {
|
|
195
|
+
scope: "col",
|
|
196
|
+
children: t.listRecall
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
})
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ jsx("tbody", {
|
|
202
|
+
children: items.map((item, index)=>/*#__PURE__*/ jsxs("tr", {
|
|
203
|
+
children: [
|
|
204
|
+
/*#__PURE__*/ jsxs("td", {
|
|
205
|
+
children: [
|
|
206
|
+
"# ",
|
|
207
|
+
startIndex + index + 1
|
|
208
|
+
]
|
|
209
|
+
}),
|
|
210
|
+
/*#__PURE__*/ jsxs("th", {
|
|
211
|
+
scope: "row",
|
|
212
|
+
children: [
|
|
213
|
+
/*#__PURE__*/ jsx("button", {
|
|
214
|
+
type: "button",
|
|
215
|
+
disabled: !onOpenUri,
|
|
216
|
+
onClick: ()=>onOpenUri?.(item.uri),
|
|
217
|
+
children: item.name
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ jsxs("span", {
|
|
220
|
+
children: [
|
|
221
|
+
/*#__PURE__*/ jsx("code", {
|
|
222
|
+
title: item.uri,
|
|
223
|
+
children: item.uri
|
|
224
|
+
}),
|
|
225
|
+
item.modTime ? /*#__PURE__*/ jsxs("time", {
|
|
226
|
+
dateTime: item.modTime,
|
|
227
|
+
title: item.modTime,
|
|
228
|
+
children: [
|
|
229
|
+
"\xb7 ",
|
|
230
|
+
t.updated,
|
|
231
|
+
" ",
|
|
232
|
+
updatedAt(item.modTime, locale)
|
|
233
|
+
]
|
|
234
|
+
}) : null
|
|
235
|
+
]
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
}),
|
|
239
|
+
/*#__PURE__*/ jsx("td", {
|
|
240
|
+
children: item.injectionCount ?? '—'
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ jsx("td", {
|
|
243
|
+
children: item.recallCount ?? '—'
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
}, item.uri))
|
|
247
|
+
})
|
|
248
|
+
]
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
]
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function ExperienceTrajectories({ items, onOpenUri, source = false }) {
|
|
255
|
+
return /*#__PURE__*/ jsx("ul", {
|
|
256
|
+
className: `ov-experience-dashboard__timeline${source ? ' ov-experience-dashboard__timeline--source' : ''}`,
|
|
257
|
+
children: items.map((item)=>/*#__PURE__*/ jsxs("li", {
|
|
258
|
+
children: [
|
|
259
|
+
item.created_at ? /*#__PURE__*/ jsx("time", {
|
|
260
|
+
dateTime: item.created_at,
|
|
261
|
+
children: item.created_at
|
|
262
|
+
}) : null,
|
|
263
|
+
/*#__PURE__*/ jsx("button", {
|
|
264
|
+
type: "button",
|
|
265
|
+
disabled: !onOpenUri,
|
|
266
|
+
onClick: ()=>onOpenUri?.(item.uri),
|
|
267
|
+
children: item.name
|
|
268
|
+
}),
|
|
269
|
+
/*#__PURE__*/ jsx("code", {
|
|
270
|
+
children: item.uri
|
|
271
|
+
}),
|
|
272
|
+
item.description ? /*#__PURE__*/ jsx("p", {
|
|
273
|
+
children: item.description
|
|
274
|
+
}) : null
|
|
275
|
+
]
|
|
276
|
+
}, item.uri))
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
const ORDER = [
|
|
280
|
+
'success',
|
|
281
|
+
'partial',
|
|
282
|
+
'unfinished',
|
|
283
|
+
'failure',
|
|
284
|
+
'unknown'
|
|
285
|
+
];
|
|
286
|
+
function ExperienceImpact({ data, labels: t, days, onDaysChange, outcomesState, trajectoriesState, onOpenUri }) {
|
|
287
|
+
const total = data.outcomes?.reduce((sum, item)=>sum + item.count, 0) ?? 0;
|
|
288
|
+
const metrics = [
|
|
289
|
+
{
|
|
290
|
+
label: t.injection,
|
|
291
|
+
value: data.effect?.injectionCount,
|
|
292
|
+
icon: /*#__PURE__*/ jsx(FileInputIcon, {
|
|
293
|
+
width: 14,
|
|
294
|
+
height: 14
|
|
295
|
+
})
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
label: t.recall,
|
|
299
|
+
value: data.effect?.recallCount,
|
|
300
|
+
icon: /*#__PURE__*/ jsx(ScanSearchIcon, {
|
|
301
|
+
width: 14,
|
|
302
|
+
height: 14
|
|
303
|
+
})
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
label: t.rate,
|
|
307
|
+
value: data.effect ? new Intl.NumberFormat('en-US', {
|
|
308
|
+
style: 'percent',
|
|
309
|
+
maximumFractionDigits: 1
|
|
310
|
+
}).format(data.effect.injectionRate) : void 0,
|
|
311
|
+
icon: /*#__PURE__*/ jsx(ActivityIcon, {
|
|
312
|
+
width: 14,
|
|
313
|
+
height: 14
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
];
|
|
317
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
318
|
+
className: "ov-experience-dashboard__impact",
|
|
319
|
+
children: [
|
|
320
|
+
/*#__PURE__*/ jsxs("div", {
|
|
321
|
+
className: "ov-experience-dashboard__heading",
|
|
322
|
+
children: [
|
|
323
|
+
/*#__PURE__*/ jsxs("div", {
|
|
324
|
+
children: [
|
|
325
|
+
/*#__PURE__*/ jsx("h2", {
|
|
326
|
+
children: t.application
|
|
327
|
+
}),
|
|
328
|
+
/*#__PURE__*/ jsx("span", {
|
|
329
|
+
children: t.notice
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
}),
|
|
333
|
+
/*#__PURE__*/ jsxs("select", {
|
|
334
|
+
"aria-label": t.range,
|
|
335
|
+
value: days,
|
|
336
|
+
onChange: (event)=>onDaysChange(Number(event.target.value)),
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ jsx("option", {
|
|
339
|
+
value: 7,
|
|
340
|
+
children: t.week
|
|
341
|
+
}),
|
|
342
|
+
/*#__PURE__*/ jsx("option", {
|
|
343
|
+
value: 30,
|
|
344
|
+
children: t.month
|
|
345
|
+
}),
|
|
346
|
+
/*#__PURE__*/ jsx("option", {
|
|
347
|
+
value: 0,
|
|
348
|
+
children: t.all
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
]
|
|
353
|
+
}),
|
|
354
|
+
/*#__PURE__*/ jsx("dl", {
|
|
355
|
+
className: "ov-experience-dashboard__metrics",
|
|
356
|
+
children: metrics.map((metric)=>/*#__PURE__*/ jsxs("div", {
|
|
357
|
+
title: void 0 === metric.value ? t.unsupportedMetric : void 0,
|
|
358
|
+
children: [
|
|
359
|
+
metric.icon,
|
|
360
|
+
/*#__PURE__*/ jsx("dd", {
|
|
361
|
+
children: metric.value ?? '—'
|
|
362
|
+
}),
|
|
363
|
+
/*#__PURE__*/ jsx("dt", {
|
|
364
|
+
children: metric.label
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
}, metric.label))
|
|
368
|
+
}),
|
|
369
|
+
/*#__PURE__*/ jsx("section", {
|
|
370
|
+
className: "ov-experience-dashboard__distribution",
|
|
371
|
+
"aria-label": t.outcomes,
|
|
372
|
+
children: data.outcomes?.length ? ORDER.map((outcome)=>{
|
|
373
|
+
const count = data.outcomes?.find((item)=>item.outcome === outcome)?.count ?? 0;
|
|
374
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
375
|
+
className: "ov-experience-dashboard__outcome",
|
|
376
|
+
children: [
|
|
377
|
+
/*#__PURE__*/ jsxs("div", {
|
|
378
|
+
children: [
|
|
379
|
+
/*#__PURE__*/ jsx("span", {
|
|
380
|
+
children: t[outcome]
|
|
381
|
+
}),
|
|
382
|
+
/*#__PURE__*/ jsx("strong", {
|
|
383
|
+
children: count
|
|
384
|
+
})
|
|
385
|
+
]
|
|
386
|
+
}),
|
|
387
|
+
/*#__PURE__*/ jsx("div", {
|
|
388
|
+
className: "ov-experience-dashboard__outcome-track",
|
|
389
|
+
"aria-hidden": "true",
|
|
390
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
391
|
+
style: {
|
|
392
|
+
width: `${total > 0 ? Math.max(count / total * 100, count ? 2 : 0) : 0}%`
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
]
|
|
397
|
+
}, outcome);
|
|
398
|
+
}) : /*#__PURE__*/ jsx(DashboardState, {
|
|
399
|
+
state: outcomesState,
|
|
400
|
+
empty: t.emptyOutcomes,
|
|
401
|
+
loading: t.loading,
|
|
402
|
+
failed: t.failed,
|
|
403
|
+
retry: t.retry
|
|
404
|
+
})
|
|
405
|
+
}),
|
|
406
|
+
/*#__PURE__*/ jsxs("section", {
|
|
407
|
+
className: "ov-experience-dashboard__trajectories",
|
|
408
|
+
children: [
|
|
409
|
+
/*#__PURE__*/ jsxs("h3", {
|
|
410
|
+
children: [
|
|
411
|
+
t.trajectories,
|
|
412
|
+
void 0 === data.trajectoryTotal ? '' : ` · ${data.trajectoryTotal}`
|
|
413
|
+
]
|
|
414
|
+
}),
|
|
415
|
+
data.trajectories?.length ? /*#__PURE__*/ jsx(ExperienceTrajectories, {
|
|
416
|
+
items: data.trajectories,
|
|
417
|
+
onOpenUri: onOpenUri
|
|
418
|
+
}) : /*#__PURE__*/ jsx(DashboardState, {
|
|
419
|
+
state: trajectoriesState,
|
|
420
|
+
empty: t.empty,
|
|
421
|
+
loading: t.loading,
|
|
422
|
+
failed: t.failed,
|
|
423
|
+
retry: t.retry
|
|
424
|
+
})
|
|
425
|
+
]
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
function CopyButton({ value, labels: t }) {
|
|
431
|
+
const [result, setResult] = useState();
|
|
432
|
+
const state = result?.value === value ? result.state : void 0;
|
|
433
|
+
const copy = async ()=>{
|
|
434
|
+
setResult({
|
|
435
|
+
value,
|
|
436
|
+
state: 'pending'
|
|
437
|
+
});
|
|
438
|
+
try {
|
|
439
|
+
await navigator.clipboard.writeText(value);
|
|
440
|
+
setResult({
|
|
441
|
+
value,
|
|
442
|
+
state: 'copied'
|
|
443
|
+
});
|
|
444
|
+
} catch {
|
|
445
|
+
setResult({
|
|
446
|
+
value,
|
|
447
|
+
state: 'failed'
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
return /*#__PURE__*/ jsx(button_Button, {
|
|
452
|
+
size: "small",
|
|
453
|
+
type: "default",
|
|
454
|
+
htmlType: "button",
|
|
455
|
+
disabled: !value || 'pending' === state,
|
|
456
|
+
"aria-live": "polite",
|
|
457
|
+
onClick: ()=>void copy(),
|
|
458
|
+
children: 'copied' === state ? t.copied : 'failed' === state ? t.copyFailed : t.copy
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
function ExperienceTests({ items, labels: t, onOpenUri }) {
|
|
462
|
+
return /*#__PURE__*/ jsx("div", {
|
|
463
|
+
className: "ov-experience-dashboard__tests",
|
|
464
|
+
children: items.map((item)=>/*#__PURE__*/ jsxs("article", {
|
|
465
|
+
children: [
|
|
466
|
+
/*#__PURE__*/ jsxs("header", {
|
|
467
|
+
children: [
|
|
468
|
+
/*#__PURE__*/ jsxs("div", {
|
|
469
|
+
className: "ov-experience-dashboard__test-heading",
|
|
470
|
+
children: [
|
|
471
|
+
/*#__PURE__*/ jsx("strong", {
|
|
472
|
+
children: item.title
|
|
473
|
+
}),
|
|
474
|
+
/*#__PURE__*/ jsxs("div", {
|
|
475
|
+
className: "ov-experience-dashboard__test-meta",
|
|
476
|
+
children: [
|
|
477
|
+
/*#__PURE__*/ jsx("span", {
|
|
478
|
+
children: t.sourceUri
|
|
479
|
+
}),
|
|
480
|
+
/*#__PURE__*/ jsx("code", {
|
|
481
|
+
title: item.uri,
|
|
482
|
+
children: item.uri ?? '—'
|
|
483
|
+
}),
|
|
484
|
+
item.uri ? /*#__PURE__*/ jsxs(Fragment, {
|
|
485
|
+
children: [
|
|
486
|
+
/*#__PURE__*/ jsx(CopyButton, {
|
|
487
|
+
value: item.uri,
|
|
488
|
+
labels: t
|
|
489
|
+
}),
|
|
490
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
491
|
+
size: "small",
|
|
492
|
+
type: "default",
|
|
493
|
+
htmlType: "button",
|
|
494
|
+
disabled: !onOpenUri,
|
|
495
|
+
onClick: ()=>item.uri && onOpenUri?.(item.uri),
|
|
496
|
+
children: t.open
|
|
497
|
+
})
|
|
498
|
+
]
|
|
499
|
+
}) : null
|
|
500
|
+
]
|
|
501
|
+
}),
|
|
502
|
+
item.taskQuery ? /*#__PURE__*/ jsxs("div", {
|
|
503
|
+
className: "ov-experience-dashboard__test-meta",
|
|
504
|
+
children: [
|
|
505
|
+
/*#__PURE__*/ jsx("span", {
|
|
506
|
+
children: t.task
|
|
507
|
+
}),
|
|
508
|
+
/*#__PURE__*/ jsx("p", {
|
|
509
|
+
children: item.taskQuery
|
|
510
|
+
})
|
|
511
|
+
]
|
|
512
|
+
}) : null
|
|
513
|
+
]
|
|
514
|
+
}),
|
|
515
|
+
/*#__PURE__*/ jsx(CopyButton, {
|
|
516
|
+
value: item.content,
|
|
517
|
+
labels: t
|
|
518
|
+
})
|
|
519
|
+
]
|
|
520
|
+
}),
|
|
521
|
+
/*#__PURE__*/ jsx("div", {
|
|
522
|
+
className: "ov-experience-dashboard__test-content",
|
|
523
|
+
children: item.content.split('\n').map((line, index)=>{
|
|
524
|
+
const role = line.match(/^(User|Assistant):(.*)$/);
|
|
525
|
+
return /*#__PURE__*/ jsx("div", {
|
|
526
|
+
children: role ? /*#__PURE__*/ jsxs(Fragment, {
|
|
527
|
+
children: [
|
|
528
|
+
/*#__PURE__*/ jsxs("strong", {
|
|
529
|
+
children: [
|
|
530
|
+
role[1],
|
|
531
|
+
":"
|
|
532
|
+
]
|
|
533
|
+
}),
|
|
534
|
+
role[2]
|
|
535
|
+
]
|
|
536
|
+
}) : line.startsWith('# ') ? /*#__PURE__*/ jsx("strong", {
|
|
537
|
+
children: line
|
|
538
|
+
}) : line || '\u00a0'
|
|
539
|
+
}, index);
|
|
540
|
+
})
|
|
541
|
+
})
|
|
542
|
+
]
|
|
543
|
+
}, item.id))
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
function ExperiencePagination({ page, hasMore, loading, labels: t, onPageChange }) {
|
|
547
|
+
if (!page && !hasMore) return null;
|
|
548
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
549
|
+
className: "ov-experience-dashboard__pagination",
|
|
550
|
+
children: [
|
|
551
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
552
|
+
size: "small",
|
|
553
|
+
type: "default",
|
|
554
|
+
htmlType: "button",
|
|
555
|
+
disabled: !page || loading || !onPageChange,
|
|
556
|
+
onClick: ()=>onPageChange?.(page - 1),
|
|
557
|
+
children: t.previous
|
|
558
|
+
}),
|
|
559
|
+
/*#__PURE__*/ jsx("span", {
|
|
560
|
+
children: page + 1
|
|
561
|
+
}),
|
|
562
|
+
/*#__PURE__*/ jsx(button_Button, {
|
|
563
|
+
size: "small",
|
|
564
|
+
type: "default",
|
|
565
|
+
htmlType: "button",
|
|
566
|
+
disabled: !hasMore || loading || !onPageChange,
|
|
567
|
+
onClick: ()=>onPageChange?.(page + 1),
|
|
568
|
+
children: t.next
|
|
569
|
+
})
|
|
570
|
+
]
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
function ExperienceDashboard(props) {
|
|
574
|
+
return /*#__PURE__*/ jsx(ExperienceDashboardContent, {
|
|
575
|
+
...props
|
|
576
|
+
}, props.uri);
|
|
577
|
+
}
|
|
578
|
+
function ExperienceDashboardContent({ uri, data = {}, kind, tab: controlledTab, days: controlledDays, page = 0, hasMore = false, startIndex = 0, states = {}, onTabChange, onDaysChange, onPageChange, locale: localeProp, onOpenUri, labels, className, ...rest }) {
|
|
579
|
+
const locale = useLocale(localeProp);
|
|
580
|
+
const [localTab, setLocalTab] = useState('impact');
|
|
581
|
+
const [localDays, setLocalDays] = useState(7);
|
|
582
|
+
const selectedTab = controlledTab ?? localTab;
|
|
583
|
+
const missingTest = void 0 === data.testMaterials;
|
|
584
|
+
const tab = 'test' === selectedTab && missingTest ? 'impact' : selectedTab;
|
|
585
|
+
if ('test' === localTab && missingTest) setLocalTab('impact');
|
|
586
|
+
const days = controlledDays ?? localDays;
|
|
587
|
+
const setTab = (value)=>{
|
|
588
|
+
setLocalTab(value);
|
|
589
|
+
onTabChange?.(value);
|
|
590
|
+
};
|
|
591
|
+
const setDays = (value)=>{
|
|
592
|
+
setLocalDays(value);
|
|
593
|
+
onDaysChange?.(value);
|
|
594
|
+
};
|
|
595
|
+
const t = experienceLabels(locale, labels);
|
|
596
|
+
const directory = 'directory' === kind;
|
|
597
|
+
const result = data;
|
|
598
|
+
const tabs = [
|
|
599
|
+
{
|
|
600
|
+
key: 'impact',
|
|
601
|
+
title: t.impact
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
key: 'source',
|
|
605
|
+
title: t.source
|
|
606
|
+
},
|
|
607
|
+
...void 0 === result.testMaterials ? [] : [
|
|
608
|
+
{
|
|
609
|
+
key: 'test',
|
|
610
|
+
title: t.test
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
];
|
|
614
|
+
const activeState = directory ? states.list : 'source' === tab ? states.sources : states.trajectories;
|
|
615
|
+
const pagination = /*#__PURE__*/ jsx(ExperiencePagination, {
|
|
616
|
+
page: page,
|
|
617
|
+
hasMore: hasMore,
|
|
618
|
+
loading: activeState?.loading,
|
|
619
|
+
labels: t,
|
|
620
|
+
onPageChange: onPageChange
|
|
621
|
+
});
|
|
622
|
+
return /*#__PURE__*/ jsx("div", {
|
|
623
|
+
...rest,
|
|
624
|
+
"data-resource-uri": uri,
|
|
625
|
+
className: [
|
|
626
|
+
'ov-experience-dashboard',
|
|
627
|
+
className
|
|
628
|
+
].filter(Boolean).join(' '),
|
|
629
|
+
children: directory ? /*#__PURE__*/ jsxs("div", {
|
|
630
|
+
className: "ov-experience-dashboard__body",
|
|
631
|
+
children: [
|
|
632
|
+
result.experiences?.length ? /*#__PURE__*/ jsx(ExperienceList, {
|
|
633
|
+
items: result.experiences,
|
|
634
|
+
total: result.total,
|
|
635
|
+
locale: locale,
|
|
636
|
+
startIndex: startIndex,
|
|
637
|
+
labels: t,
|
|
638
|
+
onOpenUri: onOpenUri
|
|
639
|
+
}) : /*#__PURE__*/ jsx(DashboardState, {
|
|
640
|
+
state: states.list,
|
|
641
|
+
empty: t.empty,
|
|
642
|
+
loading: t.loading,
|
|
643
|
+
failed: t.failed,
|
|
644
|
+
retry: t.retry
|
|
645
|
+
}),
|
|
646
|
+
pagination
|
|
647
|
+
]
|
|
648
|
+
}) : /*#__PURE__*/ jsx(DashboardTabs, {
|
|
649
|
+
tabs: tabs,
|
|
650
|
+
active: tab,
|
|
651
|
+
label: t.title,
|
|
652
|
+
onChange: setTab,
|
|
653
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
654
|
+
className: "ov-experience-dashboard__body",
|
|
655
|
+
children: 'impact' === tab ? /*#__PURE__*/ jsxs(Fragment, {
|
|
656
|
+
children: [
|
|
657
|
+
/*#__PURE__*/ jsx(ExperienceImpact, {
|
|
658
|
+
data: result,
|
|
659
|
+
labels: t,
|
|
660
|
+
days: days,
|
|
661
|
+
onDaysChange: setDays,
|
|
662
|
+
outcomesState: states.outcomes ?? {},
|
|
663
|
+
trajectoriesState: states.trajectories ?? {},
|
|
664
|
+
onOpenUri: onOpenUri
|
|
665
|
+
}),
|
|
666
|
+
pagination
|
|
667
|
+
]
|
|
668
|
+
}) : 'source' === tab ? result.sources?.length ? /*#__PURE__*/ jsxs("details", {
|
|
669
|
+
open: true,
|
|
670
|
+
className: "ov-experience-dashboard__source-group",
|
|
671
|
+
children: [
|
|
672
|
+
/*#__PURE__*/ jsxs("summary", {
|
|
673
|
+
children: [
|
|
674
|
+
/*#__PURE__*/ jsx("strong", {
|
|
675
|
+
children: t.latest
|
|
676
|
+
}),
|
|
677
|
+
/*#__PURE__*/ jsx("span", {
|
|
678
|
+
children: t.sourceCount.replace('{count}', String(result.sources.length))
|
|
679
|
+
})
|
|
680
|
+
]
|
|
681
|
+
}),
|
|
682
|
+
/*#__PURE__*/ jsx(ExperienceTrajectories, {
|
|
683
|
+
items: result.sources,
|
|
684
|
+
source: true,
|
|
685
|
+
onOpenUri: onOpenUri
|
|
686
|
+
})
|
|
687
|
+
]
|
|
688
|
+
}) : /*#__PURE__*/ jsx(DashboardState, {
|
|
689
|
+
state: states.sources,
|
|
690
|
+
empty: t.emptySource,
|
|
691
|
+
loading: t.loading,
|
|
692
|
+
failed: t.failed,
|
|
693
|
+
retry: t.retry
|
|
694
|
+
}) : result.testMaterials?.length ? /*#__PURE__*/ jsx(ExperienceTests, {
|
|
695
|
+
items: result.testMaterials,
|
|
696
|
+
labels: t,
|
|
697
|
+
onOpenUri: onOpenUri
|
|
698
|
+
}) : /*#__PURE__*/ jsx(DashboardState, {
|
|
699
|
+
state: states.tests,
|
|
700
|
+
empty: t.emptyTests,
|
|
701
|
+
loading: t.loading,
|
|
702
|
+
failed: t.failed,
|
|
703
|
+
retry: t.retry
|
|
704
|
+
})
|
|
705
|
+
})
|
|
706
|
+
})
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
export { ExperienceDashboard };
|