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