@openviking/react 0.1.6 → 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.
Files changed (94) hide show
  1. package/README.md +2 -0
  2. package/dist/2~0.js +6 -5
  3. package/dist/3c~0.js +10 -4
  4. package/dist/3~0.js +18 -8
  5. package/dist/ae~0.js +8 -1
  6. package/dist/ark-message-list-view~0.js +9 -4
  7. package/dist/a~0.js +12 -6
  8. package/dist/c7r~0.js +50 -0
  9. package/dist/ck~0.js +3 -0
  10. package/dist/client/paths.d.ts +6 -0
  11. package/dist/client/provider.d.ts +6 -1
  12. package/dist/components/agent-connect/style.css +222 -35
  13. package/dist/components/directory-tour/style.css +221 -21
  14. package/dist/components/directory-tour.js +1 -1
  15. package/dist/components/experience-dashboard/style.css +227 -12
  16. package/dist/components/experience-dashboard.js +1 -1
  17. package/dist/components/file-browser-entries/style.css +325 -80
  18. package/dist/components/file-preview/style.css +221 -76
  19. package/dist/components/file-tree/file-tree-toolbar.d.ts +3 -3
  20. package/dist/components/file-tree/locales/en-US.d.ts +3 -0
  21. package/dist/components/file-tree/locales/zh-CN.d.ts +3 -0
  22. package/dist/components/file-tree/style.css +311 -86
  23. package/dist/components/file-tree/types.d.ts +13 -4
  24. package/dist/components/scope-switcher/style.css +366 -37
  25. package/dist/components/scope-switcher.js +1 -1
  26. package/dist/components/style.css +3329 -640
  27. package/dist/components/tui/style.css +267 -35
  28. package/dist/components/viking-bot/interaction/style.css +143 -22
  29. package/dist/components/viking-bot/style.css +945 -295
  30. package/dist/components/wiki-dashboard/style.css +227 -12
  31. package/dist/c~0.js +16 -8
  32. package/dist/ep~0.js +345 -0
  33. package/dist/e~0.js +33 -328
  34. package/dist/fj~0.js +8 -4
  35. package/dist/fl~0.js +709 -0
  36. package/dist/f~0.js +302 -663
  37. package/dist/index.js +3 -3
  38. package/dist/lk~0.js +6 -3
  39. package/dist/l~0.js +1874 -437
  40. package/dist/modules/console/style.css +1471 -351
  41. package/dist/modules/file-browser/acl/acl-add-principal.d.ts +12 -0
  42. package/dist/modules/file-browser/acl/acl-candidate.d.ts +8 -0
  43. package/dist/modules/file-browser/acl/acl-client.d.ts +13 -0
  44. package/dist/modules/file-browser/acl/acl-confirmation.d.ts +6 -0
  45. package/dist/modules/file-browser/acl/acl-entry.d.ts +13 -0
  46. package/dist/modules/file-browser/acl/acl-labels.d.ts +47 -0
  47. package/dist/modules/file-browser/acl/acl-menu.d.ts +10 -0
  48. package/dist/modules/file-browser/acl/acl-modal.d.ts +17 -0
  49. package/dist/modules/file-browser/acl/acl-model.d.ts +17 -0
  50. package/dist/modules/file-browser/acl/acl-principal-tabs.d.ts +6 -0
  51. package/dist/modules/file-browser/acl/acl-tag.d.ts +7 -0
  52. package/dist/modules/file-browser/acl/locales/en-US.d.ts +44 -0
  53. package/dist/modules/file-browser/acl/locales/zh-CN.d.ts +44 -0
  54. package/dist/modules/file-browser/acl/use-acl-principals.d.ts +17 -0
  55. package/dist/modules/file-browser/acl/use-acl-report.d.ts +27 -0
  56. package/dist/modules/file-browser/acl-types.d.ts +86 -0
  57. package/dist/modules/file-browser/dashboard-model.d.ts +3 -0
  58. package/dist/modules/file-browser/file-browser-detail.d.ts +4 -1
  59. package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
  60. package/dist/modules/file-browser/file-browser-search.d.ts +20 -0
  61. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -10
  62. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +2 -6
  63. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  64. package/dist/modules/file-browser/fs-directories.d.ts +1 -0
  65. package/dist/modules/file-browser/fs-model.d.ts +3 -1
  66. package/dist/modules/file-browser/index.d.ts +1 -0
  67. package/dist/modules/file-browser/locales/en-US.d.ts +5 -0
  68. package/dist/modules/file-browser/locales/zh-CN.d.ts +5 -0
  69. package/dist/modules/file-browser/style.css +2409 -603
  70. package/dist/modules/file-browser/types.d.ts +20 -20
  71. package/dist/modules/file-browser/use-file-browser-acl.d.ts +15 -0
  72. package/dist/modules/file-browser/use-file-browser.d.ts +5 -7
  73. package/dist/modules/file-browser/use-fs-tree.d.ts +1 -0
  74. package/dist/modules/scope-cascade/style.css +535 -37
  75. package/dist/modules/style.css +12227 -8757
  76. package/dist/n~0.js +60 -36
  77. package/dist/rt~0.js +107 -4
  78. package/dist/r~0.js +1 -1
  79. package/dist/shared/components/button/button.d.ts +20 -0
  80. package/dist/shared/components/input/input.d.ts +17 -0
  81. package/dist/shared/components/modal/locales/en-US.d.ts +4 -0
  82. package/dist/shared/components/modal/locales/zh-CN.d.ts +4 -0
  83. package/dist/shared/components/modal/modal.d.ts +2 -0
  84. package/dist/shared/components/modal/types.d.ts +18 -0
  85. package/dist/shared/components/overlay/lock-body-scroll.d.ts +1 -0
  86. package/dist/style.css +7776 -1571
  87. package/dist/s~0.js +16 -0
  88. package/dist/u~0.js +15 -6
  89. package/dist/viking-bot-composer~0.js +29 -11
  90. package/dist/viking-bot-interaction~0.js +2 -1
  91. package/package.json +3 -2
  92. package/dist/fi~0.js +0 -354
  93. package/dist/modules/file-browser/fs-selection.d.ts +0 -4
  94. package/dist/o~0.js +0 -106
package/dist/ep~0.js ADDED
@@ -0,0 +1,345 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { useLocale } from "./28~0.js";
5
+ import { resolveLocale } from "./nx~0.js";
6
+ import { button_Button } from "./e~0.js";
7
+ function useTourAnchor(target, locateTarget, timeout, attempt) {
8
+ const [state, setState] = useState({
9
+ anchor: null,
10
+ failed: false
11
+ });
12
+ useEffect(()=>{
13
+ const controller = new AbortController();
14
+ setState({
15
+ anchor: null,
16
+ failed: false
17
+ });
18
+ const timer = window.setTimeout(()=>{
19
+ controller.abort();
20
+ setState({
21
+ anchor: null,
22
+ failed: true
23
+ });
24
+ }, timeout);
25
+ Promise.resolve().then(()=>locateTarget?.(target, controller.signal) ?? null).then((anchor)=>{
26
+ if (controller.signal.aborted) return;
27
+ window.clearTimeout(timer);
28
+ if (anchor?.isConnected) {
29
+ anchor.scrollIntoView({
30
+ block: 'nearest',
31
+ inline: 'nearest'
32
+ });
33
+ setState({
34
+ anchor,
35
+ failed: false
36
+ });
37
+ } else setState({
38
+ anchor: null,
39
+ failed: true
40
+ });
41
+ }, ()=>{
42
+ if (controller.signal.aborted) return;
43
+ window.clearTimeout(timer);
44
+ setState({
45
+ anchor: null,
46
+ failed: true
47
+ });
48
+ });
49
+ return ()=>{
50
+ controller.abort();
51
+ window.clearTimeout(timer);
52
+ };
53
+ }, [
54
+ target,
55
+ locateTarget,
56
+ timeout,
57
+ attempt
58
+ ]);
59
+ return state;
60
+ }
61
+ function useTourPosition(anchor, surface, placement) {
62
+ const [position, setPosition] = useState();
63
+ useEffect(()=>{
64
+ if (!surface) return;
65
+ surface.showPopover?.();
66
+ const update = ()=>{
67
+ const a = anchor?.getBoundingClientRect();
68
+ const box = surface.getBoundingClientRect();
69
+ const width = window.innerWidth;
70
+ const height = window.innerHeight;
71
+ const margin = 8;
72
+ let left = (width - box.width) / 2;
73
+ let top = (height - box.height) / 2;
74
+ const missing = Boolean(anchor && !anchor.isConnected);
75
+ let visible = !anchor || missing;
76
+ if (anchor && a && !missing) {
77
+ let clip = {
78
+ left: 0,
79
+ top: 0,
80
+ right: width,
81
+ bottom: height
82
+ };
83
+ for(let parent = anchor.parentElement; parent; parent = parent.parentElement){
84
+ const css = window.getComputedStyle(parent);
85
+ const rect = parent.getBoundingClientRect();
86
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowX)) clip = {
87
+ ...clip,
88
+ left: Math.max(clip.left, rect.left),
89
+ right: Math.min(clip.right, rect.right)
90
+ };
91
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowY)) clip = {
92
+ ...clip,
93
+ top: Math.max(clip.top, rect.top),
94
+ bottom: Math.min(clip.bottom, rect.bottom)
95
+ };
96
+ }
97
+ visible = anchor.isConnected && a.width > 0 && a.height > 0 && a.top < clip.bottom && a.bottom > clip.top && a.left < clip.right && a.right > clip.left;
98
+ const right = a.right + 6;
99
+ const leftSide = a.left - box.width - 6;
100
+ left = 'right' === placement ? right + box.width <= width - margin || leftSide < margin ? right : leftSide : leftSide >= margin || right + box.width > width - margin ? leftSide : right;
101
+ top = a.top - 16;
102
+ const css = window.getComputedStyle(anchor);
103
+ for(let i = 0; i < css.length; i++){
104
+ const name = css[i];
105
+ if (name?.startsWith('--ov-ui-')) surface.style.setProperty(name, css.getPropertyValue(name));
106
+ }
107
+ }
108
+ const next = {
109
+ left: Math.max(margin, Math.min(left, width - box.width - margin)),
110
+ top: Math.max(margin, Math.min(top, height - box.height - margin)),
111
+ targetTop: a?.top ?? 0,
112
+ targetLeft: a?.left ?? 0,
113
+ targetWidth: a?.width ?? 0,
114
+ targetHeight: a?.height ?? 0,
115
+ visible,
116
+ missing
117
+ };
118
+ setPosition((old)=>old && Object.keys(next).every((key)=>old[key] === next[key]) ? old : next);
119
+ };
120
+ update();
121
+ const resize = new ResizeObserver(update);
122
+ resize.observe(surface);
123
+ for(let node = anchor; node; node = node.parentElement)resize.observe(node);
124
+ const mutation = new MutationObserver(update);
125
+ mutation.observe(document.body, {
126
+ childList: true,
127
+ subtree: true
128
+ });
129
+ window.addEventListener('scroll', update, true);
130
+ window.addEventListener('resize', update);
131
+ window.visualViewport?.addEventListener('resize', update);
132
+ window.visualViewport?.addEventListener('scroll', update);
133
+ return ()=>{
134
+ resize.disconnect();
135
+ mutation.disconnect();
136
+ window.removeEventListener('scroll', update, true);
137
+ window.removeEventListener('resize', update);
138
+ window.visualViewport?.removeEventListener('resize', update);
139
+ window.visualViewport?.removeEventListener('scroll', update);
140
+ if (surface.isConnected) surface.hidePopover?.();
141
+ };
142
+ }, [
143
+ anchor,
144
+ surface,
145
+ placement
146
+ ]);
147
+ return position;
148
+ }
149
+ const messages = {
150
+ close: 'Close guide',
151
+ next: 'Next',
152
+ done: 'Got it',
153
+ locating: 'Locating directory…',
154
+ unavailable: 'This directory is unavailable. Retry or skip this step.',
155
+ retry: 'Retry',
156
+ skip: 'Skip',
157
+ progress: (current, total)=>`${current}/${total}`
158
+ };
159
+ const en_US = messages;
160
+ const zh_CN_messages = {
161
+ close: '关闭引导',
162
+ next: '下一步',
163
+ done: '知道了',
164
+ locating: '正在定位目录…',
165
+ unavailable: '此目录暂不可用,请重试或跳过这一步。',
166
+ retry: '重试',
167
+ skip: '跳过',
168
+ progress: (current, total)=>`${current}/${total}`
169
+ };
170
+ const zh_CN = zh_CN_messages;
171
+ function DirectoryTour(props) {
172
+ if (!props.open || 0 === props.steps.length) return null;
173
+ return /*#__PURE__*/ jsx(TourSession, {
174
+ ...props
175
+ });
176
+ }
177
+ function TourSession(props) {
178
+ const [index, setIndex] = useState(props.defaultStep ?? 0);
179
+ const skipped = useRef(new Set());
180
+ const current = props.currentStep ?? index;
181
+ const step = props.steps[current];
182
+ if (!step) return null;
183
+ const advance = (skip)=>{
184
+ if (skip) skipped.current.add(step.id);
185
+ if (current === props.steps.length - 1) props.onComplete?.({
186
+ skippedStepIds: [
187
+ ...skipped.current
188
+ ]
189
+ });
190
+ else {
191
+ if (void 0 === props.currentStep) setIndex(current + 1);
192
+ props.onStepChange?.(current + 1);
193
+ }
194
+ };
195
+ return /*#__PURE__*/ jsx(TourStep, {
196
+ ...props,
197
+ step: step,
198
+ index: current,
199
+ advance: advance
200
+ }, step.id);
201
+ }
202
+ function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 10000, placement = 'right', onClose, labels, locale: localeProp, className, style }) {
203
+ const locale = useLocale(localeProp);
204
+ const text = resolveLocale({
205
+ 'en-US': en_US,
206
+ 'zh-CN': zh_CN
207
+ }, locale, labels);
208
+ const [attempt, retry] = useState(0);
209
+ const [surface, setSurface] = useState(null);
210
+ const { anchor, failed } = useTourAnchor(step.target, locateTarget, locateTimeout, attempt);
211
+ const position = useTourPosition(anchor, surface, placement);
212
+ const titleId = useId();
213
+ const bodyId = useId();
214
+ useEffect(()=>{
215
+ const close = (event)=>{
216
+ if ('Escape' === event.key) {
217
+ event.preventDefault();
218
+ onClose?.();
219
+ }
220
+ };
221
+ document.addEventListener('keydown', close);
222
+ return ()=>document.removeEventListener('keydown', close);
223
+ }, [
224
+ onClose
225
+ ]);
226
+ useEffect(()=>{
227
+ const previous = document.activeElement;
228
+ return ()=>{
229
+ if (previous instanceof HTMLElement && previous.isConnected) previous.focus({
230
+ preventScroll: true
231
+ });
232
+ };
233
+ }, []);
234
+ const visible = position?.visible;
235
+ useEffect(()=>{
236
+ if (surface && visible) surface.focus({
237
+ preventScroll: true
238
+ });
239
+ }, [
240
+ surface,
241
+ visible
242
+ ]);
243
+ if ("u" < typeof document) return null;
244
+ const unavailable = failed || position?.missing;
245
+ const locating = !anchor && !failed;
246
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs("div", {
247
+ ref: setSurface,
248
+ popover: "manual",
249
+ role: "dialog",
250
+ "aria-modal": "false",
251
+ "aria-labelledby": titleId,
252
+ "aria-describedby": bodyId,
253
+ "aria-busy": locating,
254
+ tabIndex: -1,
255
+ className: [
256
+ 'ov-directory-tour',
257
+ className
258
+ ].filter(Boolean).join(' '),
259
+ style: {
260
+ ...style,
261
+ top: position?.top ?? 0,
262
+ left: position?.left ?? 0,
263
+ visibility: position?.visible ? 'visible' : 'hidden'
264
+ },
265
+ children: [
266
+ anchor && !unavailable && position?.visible && /*#__PURE__*/ jsx("div", {
267
+ className: "ov-directory-tour__highlight",
268
+ "aria-hidden": "true",
269
+ style: {
270
+ top: position.targetTop,
271
+ left: position.targetLeft,
272
+ width: position.targetWidth,
273
+ height: position.targetHeight
274
+ }
275
+ }),
276
+ /*#__PURE__*/ jsxs("div", {
277
+ className: "ov-directory-tour__card",
278
+ children: [
279
+ onClose && /*#__PURE__*/ jsx(button_Button, {
280
+ size: "mini",
281
+ type: "text",
282
+ iconOnly: true,
283
+ className: "ov-directory-tour__close",
284
+ htmlType: "button",
285
+ "aria-label": text.close,
286
+ onClick: onClose,
287
+ children: "\xd7"
288
+ }),
289
+ !locating && !unavailable && step.illustration && /*#__PURE__*/ jsx("div", {
290
+ className: "ov-directory-tour__illustration",
291
+ children: step.illustration
292
+ }),
293
+ /*#__PURE__*/ jsx("h2", {
294
+ id: titleId,
295
+ className: "ov-directory-tour__title",
296
+ children: step.title
297
+ }),
298
+ /*#__PURE__*/ jsx("div", {
299
+ id: bodyId,
300
+ className: "ov-directory-tour__description",
301
+ role: unavailable ? 'alert' : void 0,
302
+ children: unavailable ? text.unavailable : locating ? text.locating : step.description
303
+ }),
304
+ /*#__PURE__*/ jsxs("footer", {
305
+ className: "ov-directory-tour__actions",
306
+ children: [
307
+ /*#__PURE__*/ jsx("span", {
308
+ className: "ov-directory-tour__progress",
309
+ "aria-live": "polite",
310
+ children: text.progress(index + 1, steps.length)
311
+ }),
312
+ unavailable ? /*#__PURE__*/ jsxs(Fragment, {
313
+ children: [
314
+ /*#__PURE__*/ jsx(button_Button, {
315
+ size: "small",
316
+ type: "default",
317
+ htmlType: "button",
318
+ onClick: ()=>retry((value)=>value + 1),
319
+ children: text.retry
320
+ }),
321
+ /*#__PURE__*/ jsx(button_Button, {
322
+ size: "small",
323
+ type: "default",
324
+ htmlType: "button",
325
+ onClick: ()=>advance(true),
326
+ children: text.skip
327
+ })
328
+ ]
329
+ }) : /*#__PURE__*/ jsx(button_Button, {
330
+ size: "small",
331
+ type: "primary",
332
+ htmlType: "button",
333
+ className: "ov-directory-tour__primary",
334
+ disabled: locating,
335
+ onClick: ()=>advance(false),
336
+ children: step.nextLabel ?? (index === steps.length - 1 ? text.done : text.next)
337
+ })
338
+ ]
339
+ })
340
+ ]
341
+ })
342
+ ]
343
+ }), document.body);
344
+ }
345
+ export { DirectoryTour };