@openviking/react 0.1.6 → 0.1.8-beta.10.1.g8e5299efeb0a

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 (172) hide show
  1. package/README.md +13 -1
  2. package/dist/1~0.js +57 -0
  3. package/dist/2~0.js +6 -5
  4. package/dist/3c~0.js +10 -4
  5. package/dist/3~0.js +189 -13
  6. package/dist/5~0.js +181 -0
  7. package/dist/6~0.js +48 -0
  8. package/dist/ae~0.js +8 -1
  9. package/dist/ark-message-list-view~0.js +9 -4
  10. package/dist/a~0.js +12 -6
  11. package/dist/c7r~0.js +50 -0
  12. package/dist/ck~0.js +3 -0
  13. package/dist/client/paths.d.ts +6 -0
  14. package/dist/client/provider.d.ts +6 -1
  15. package/dist/components/agent-connect/style.css +224 -35
  16. package/dist/components/api-key-login-form/api-key-login-form.d.ts +2 -0
  17. package/dist/components/api-key-login-form/index.d.ts +3 -0
  18. package/dist/components/api-key-login-form/style.css +438 -0
  19. package/dist/components/api-key-login-form/style.js +0 -0
  20. package/dist/components/api-key-login-form/types.d.ts +7 -0
  21. package/dist/components/api-key-login-form.js +1 -0
  22. package/dist/components/directory-tour/directory-tour-intro.d.ts +3 -0
  23. package/dist/components/directory-tour/index.d.ts +2 -1
  24. package/dist/components/directory-tour/style.css +367 -39
  25. package/dist/components/directory-tour/tour-card.d.ts +14 -0
  26. package/dist/components/directory-tour/types.d.ts +24 -1
  27. package/dist/components/directory-tour/use-tour-anchor.d.ts +1 -0
  28. package/dist/components/directory-tour/use-tour-position.d.ts +4 -1
  29. package/dist/components/directory-tour/use-tour-theme.d.ts +2 -0
  30. package/dist/components/directory-tour.js +53 -2
  31. package/dist/components/email-login-form/email-login-form.d.ts +2 -0
  32. package/dist/components/email-login-form/index.d.ts +3 -0
  33. package/dist/components/email-login-form/style.css +438 -0
  34. package/dist/components/email-login-form/style.js +0 -0
  35. package/dist/components/email-login-form/types.d.ts +11 -0
  36. package/dist/components/email-login-form.js +1 -0
  37. package/dist/components/experience-dashboard/experience-impact.d.ts +3 -1
  38. package/dist/components/experience-dashboard/style.css +229 -12
  39. package/dist/components/experience-dashboard.js +1 -1
  40. package/dist/components/file-browser-entries/style.css +331 -80
  41. package/dist/components/file-preview/file-preview-header.d.ts +4 -21
  42. package/dist/components/file-preview/file-preview-toolbar.d.ts +7 -0
  43. package/dist/components/file-preview/locales/en-US.d.ts +9 -0
  44. package/dist/components/file-preview/locales/zh-CN.d.ts +9 -0
  45. package/dist/components/file-preview/style.css +335 -76
  46. package/dist/components/file-preview/types.d.ts +14 -21
  47. package/dist/components/file-tree/file-tree-toolbar.d.ts +3 -3
  48. package/dist/components/file-tree/locales/en-US.d.ts +3 -0
  49. package/dist/components/file-tree/locales/zh-CN.d.ts +3 -0
  50. package/dist/components/file-tree/style.css +313 -86
  51. package/dist/components/file-tree/types.d.ts +13 -4
  52. package/dist/components/invitation-confirmation/index.d.ts +3 -0
  53. package/dist/components/invitation-confirmation/invitation-confirmation.d.ts +2 -0
  54. package/dist/components/invitation-confirmation/style.css +438 -0
  55. package/dist/components/invitation-confirmation/style.js +0 -0
  56. package/dist/components/invitation-confirmation/types.d.ts +20 -0
  57. package/dist/components/invitation-confirmation.js +1 -0
  58. package/dist/components/login-method-selector/index.d.ts +2 -0
  59. package/dist/components/login-method-selector/login-method-selector.d.ts +2 -0
  60. package/dist/components/login-method-selector/style.css +438 -0
  61. package/dist/components/login-method-selector/style.js +0 -0
  62. package/dist/components/login-method-selector/types.d.ts +14 -0
  63. package/dist/components/login-method-selector.js +1 -0
  64. package/dist/components/password-reset-request-form/index.d.ts +3 -0
  65. package/dist/components/password-reset-request-form/password-reset-request-form.d.ts +2 -0
  66. package/dist/components/password-reset-request-form/style.css +438 -0
  67. package/dist/components/password-reset-request-form/style.js +0 -0
  68. package/dist/components/password-reset-request-form/types.d.ts +13 -0
  69. package/dist/components/password-reset-request-form.js +1 -0
  70. package/dist/components/password-setup-form/index.d.ts +3 -0
  71. package/dist/components/password-setup-form/password-setup-form.d.ts +2 -0
  72. package/dist/components/password-setup-form/style.css +438 -0
  73. package/dist/components/password-setup-form/style.js +0 -0
  74. package/dist/components/password-setup-form/types.d.ts +10 -0
  75. package/dist/components/password-setup-form.js +1 -0
  76. package/dist/components/scope-switcher/style.css +368 -37
  77. package/dist/components/style.css +13071 -7474
  78. package/dist/components/tui/style.css +271 -35
  79. package/dist/components/viking-bot/interaction/style.css +143 -22
  80. package/dist/components/viking-bot/style.css +951 -295
  81. package/dist/components/wiki-dashboard/index.d.ts +1 -1
  82. package/dist/components/wiki-dashboard/style.css +241 -14
  83. package/dist/components/wiki-dashboard/types.d.ts +12 -16
  84. package/dist/components/wiki-dashboard/wiki-action-button.d.ts +2 -9
  85. package/dist/components/wiki-dashboard/wiki-conflict-card.d.ts +3 -10
  86. package/dist/c~0.js +16 -8
  87. package/dist/d~0.js +28 -0
  88. package/dist/ep~0.js +493 -0
  89. package/dist/e~0.js +33 -328
  90. package/dist/fi~0.js +13 -28
  91. package/dist/fj~0.js +38 -69
  92. package/dist/fl~0.js +710 -0
  93. package/dist/f~0.js +61 -685
  94. package/dist/g~0.js +135 -0
  95. package/dist/icons/index.d.ts +2 -0
  96. package/dist/icons.js +1 -1
  97. package/dist/index.d.ts +12 -0
  98. package/dist/index.js +9 -3
  99. package/dist/k~0.js +44 -4
  100. package/dist/l5~0.js +3813 -0
  101. package/dist/lk~0.js +5 -2
  102. package/dist/l~0.js +49 -2369
  103. package/dist/modules/console/style.css +1485 -351
  104. package/dist/modules/file-browser/acl/acl-add-principal.d.ts +12 -0
  105. package/dist/modules/file-browser/acl/acl-candidate.d.ts +8 -0
  106. package/dist/modules/file-browser/acl/acl-client.d.ts +13 -0
  107. package/dist/modules/file-browser/acl/acl-confirmation.d.ts +6 -0
  108. package/dist/modules/file-browser/acl/acl-entry.d.ts +13 -0
  109. package/dist/modules/file-browser/acl/acl-labels.d.ts +47 -0
  110. package/dist/modules/file-browser/acl/acl-menu.d.ts +10 -0
  111. package/dist/modules/file-browser/acl/acl-modal.d.ts +17 -0
  112. package/dist/modules/file-browser/acl/acl-model.d.ts +17 -0
  113. package/dist/modules/file-browser/acl/acl-principal-tabs.d.ts +6 -0
  114. package/dist/modules/file-browser/acl/acl-tag.d.ts +7 -0
  115. package/dist/modules/file-browser/acl/locales/en-US.d.ts +44 -0
  116. package/dist/modules/file-browser/acl/locales/zh-CN.d.ts +44 -0
  117. package/dist/modules/file-browser/acl/use-acl-principals.d.ts +17 -0
  118. package/dist/modules/file-browser/acl/use-acl-report.d.ts +27 -0
  119. package/dist/modules/file-browser/acl-types.d.ts +86 -0
  120. package/dist/modules/file-browser/dashboard-model.d.ts +3 -0
  121. package/dist/modules/file-browser/file-browser-detail-icons.d.ts +0 -6
  122. package/dist/modules/file-browser/file-browser-detail.d.ts +5 -23
  123. package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
  124. package/dist/modules/file-browser/file-browser-search.d.ts +20 -0
  125. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -10
  126. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +2 -6
  127. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  128. package/dist/modules/file-browser/fs-directories.d.ts +1 -0
  129. package/dist/modules/file-browser/fs-file-editing.d.ts +4 -0
  130. package/dist/modules/file-browser/fs-model.d.ts +3 -1
  131. package/dist/modules/file-browser/fs-preview-images.d.ts +3 -0
  132. package/dist/modules/file-browser/fs-read-file.d.ts +1 -1
  133. package/dist/modules/file-browser/index.d.ts +1 -0
  134. package/dist/modules/file-browser/locales/en-US.d.ts +5 -0
  135. package/dist/modules/file-browser/locales/zh-CN.d.ts +5 -0
  136. package/dist/modules/file-browser/style.css +2595 -703
  137. package/dist/modules/file-browser/types.d.ts +22 -20
  138. package/dist/modules/file-browser/use-file-browser-acl.d.ts +16 -0
  139. package/dist/modules/file-browser/use-file-browser.d.ts +5 -7
  140. package/dist/modules/file-browser/use-fs-tree.d.ts +1 -0
  141. package/dist/modules/file-browser/wiki-dashboard-pane.d.ts +2 -4
  142. package/dist/modules/file-browser.js +1 -1
  143. package/dist/modules/scope-cascade/style.css +537 -37
  144. package/dist/modules/style.css +12429 -8855
  145. package/dist/n~0.js +61 -37
  146. package/dist/p0~0.js +27 -0
  147. package/dist/p~0.js +34 -25
  148. package/dist/rt~0.js +107 -4
  149. package/dist/r~0.js +1 -1
  150. package/dist/shared/auth/agreements.d.ts +10 -0
  151. package/dist/shared/auth/fields.d.ts +15 -0
  152. package/dist/shared/auth/form-frame.d.ts +12 -0
  153. package/dist/shared/auth/locales/en-US.d.ts +24 -0
  154. package/dist/shared/auth/locales/zh-CN.d.ts +24 -0
  155. package/dist/shared/auth/types.d.ts +61 -0
  156. package/dist/shared/auth/use-auth-labels.d.ts +3 -0
  157. package/dist/shared/auth/use-form.d.ts +8 -0
  158. package/dist/shared/components/button/button.d.ts +20 -0
  159. package/dist/shared/components/input/input.d.ts +17 -0
  160. package/dist/shared/components/modal/locales/en-US.d.ts +4 -0
  161. package/dist/shared/components/modal/locales/zh-CN.d.ts +4 -0
  162. package/dist/shared/components/modal/modal.d.ts +2 -0
  163. package/dist/shared/components/modal/types.d.ts +18 -0
  164. package/dist/shared/components/overlay/lock-body-scroll.d.ts +1 -0
  165. package/dist/style.css +15477 -6258
  166. package/dist/s~0.js +16 -0
  167. package/dist/u~0.js +15 -6
  168. package/dist/viking-bot-composer~0.js +29 -11
  169. package/dist/viking-bot-interaction~0.js +2 -1
  170. package/package.json +34 -3
  171. package/dist/modules/file-browser/fs-selection.d.ts +0 -4
  172. package/dist/o~0.js +0 -106
package/dist/ep~0.js ADDED
@@ -0,0 +1,493 @@
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 { resolveLocale } from "./nx~0.js";
5
+ import { button_Button } from "./e~0.js";
6
+ import { useLocale } from "./28~0.js";
7
+ function isAnchorGroup(target) {
8
+ return Array.isArray(target);
9
+ }
10
+ function useTourAnchor(target, locateTarget, timeout, attempt) {
11
+ const [state, setState] = useState({
12
+ anchor: null,
13
+ elements: [],
14
+ failed: false
15
+ });
16
+ useEffect(()=>{
17
+ const controller = new AbortController();
18
+ setState({
19
+ anchor: null,
20
+ elements: [],
21
+ failed: false
22
+ });
23
+ const timer = window.setTimeout(()=>{
24
+ controller.abort();
25
+ setState({
26
+ anchor: null,
27
+ elements: [],
28
+ failed: true
29
+ });
30
+ }, timeout);
31
+ Promise.resolve().then(()=>locateTarget?.(target, controller.signal) ?? null).then((target)=>{
32
+ if (controller.signal.aborted) return;
33
+ window.clearTimeout(timer);
34
+ const elements = target ? isAnchorGroup(target) ? target : [
35
+ target
36
+ ] : [];
37
+ const anchor = elements[0];
38
+ if (anchor?.isConnected) {
39
+ anchor.scrollIntoView({
40
+ block: 'nearest',
41
+ inline: 'nearest'
42
+ });
43
+ setState({
44
+ anchor,
45
+ elements,
46
+ failed: false
47
+ });
48
+ } else setState({
49
+ anchor: null,
50
+ elements: [],
51
+ failed: true
52
+ });
53
+ }, ()=>{
54
+ if (controller.signal.aborted) return;
55
+ window.clearTimeout(timer);
56
+ setState({
57
+ anchor: null,
58
+ elements: [],
59
+ failed: true
60
+ });
61
+ });
62
+ return ()=>{
63
+ controller.abort();
64
+ window.clearTimeout(timer);
65
+ };
66
+ }, [
67
+ target,
68
+ locateTarget,
69
+ timeout,
70
+ attempt
71
+ ]);
72
+ return state;
73
+ }
74
+ function useTourPosition(anchor, surface, placement, elements) {
75
+ const [position, setPosition] = useState();
76
+ useEffect(()=>{
77
+ if (!surface) return;
78
+ const frameElement = surface.parentElement;
79
+ frameElement?.showPopover?.();
80
+ const update = ()=>{
81
+ const a = anchor?.getBoundingClientRect();
82
+ const bounds = elements.filter((node)=>node.isConnected).map((node)=>node.getBoundingClientRect());
83
+ const group = bounds.length ? {
84
+ top: Math.min(...bounds.map((r)=>r.top)),
85
+ left: Math.min(...bounds.map((r)=>r.left)),
86
+ right: Math.max(...bounds.map((r)=>r.right)),
87
+ bottom: Math.max(...bounds.map((r)=>r.bottom))
88
+ } : a;
89
+ let highlight = group;
90
+ const box = surface.getBoundingClientRect();
91
+ const viewport = window.visualViewport;
92
+ const width = viewport?.width ?? window.innerWidth;
93
+ const height = viewport?.height ?? window.innerHeight;
94
+ const x = viewport?.offsetLeft ?? 0;
95
+ const y = viewport?.offsetTop ?? 0;
96
+ const margin = 8;
97
+ let left = x + (width - box.width) / 2;
98
+ let top = y + (height - box.height) / 2;
99
+ const missing = Boolean(anchor && !anchor.isConnected);
100
+ let visible = !anchor || missing;
101
+ if (anchor && a && !missing) {
102
+ let clip = {
103
+ left: x,
104
+ top: y,
105
+ right: x + width,
106
+ bottom: y + height
107
+ };
108
+ for(let parent = anchor.parentElement; parent; parent = parent.parentElement){
109
+ const css = window.getComputedStyle(parent);
110
+ const rect = parent.getBoundingClientRect();
111
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowX)) clip = {
112
+ ...clip,
113
+ left: Math.max(clip.left, rect.left),
114
+ right: Math.min(clip.right, rect.right)
115
+ };
116
+ if (/(auto|scroll|hidden|clip)/.test(css.overflowY)) clip = {
117
+ ...clip,
118
+ top: Math.max(clip.top, rect.top),
119
+ bottom: Math.min(clip.bottom, rect.bottom)
120
+ };
121
+ }
122
+ const target = group ?? a;
123
+ visible = target.right > target.left && target.bottom > target.top && target.top < clip.bottom && target.bottom > clip.top && target.left < clip.right && target.right > clip.left;
124
+ if (group) highlight = {
125
+ top: Math.max(group.top, clip.top),
126
+ left: Math.max(group.left, clip.left),
127
+ right: Math.min(group.right, clip.right),
128
+ bottom: Math.min(group.bottom, clip.bottom)
129
+ };
130
+ const right = a.right + 6;
131
+ const leftSide = a.left - box.width - 6;
132
+ left = 'right' === placement ? right + box.width <= x + width - margin || leftSide < x + margin ? right : leftSide : leftSide >= x + margin || right + box.width > x + width - margin ? leftSide : right;
133
+ top = a.top - 16;
134
+ }
135
+ const next = {
136
+ left: Math.max(x + margin, Math.min(left, x + width - box.width - margin)),
137
+ top: Math.max(y + margin, Math.min(top, y + height - box.height - margin)),
138
+ maxWidth: Math.max(0, width - 2 * margin),
139
+ maxHeight: Math.max(0, height - 2 * margin),
140
+ layoutHeight: window.innerHeight,
141
+ targetTop: highlight?.top ?? 0,
142
+ targetLeft: highlight?.left ?? 0,
143
+ targetWidth: highlight ? Math.max(0, highlight.right - highlight.left) : 0,
144
+ targetHeight: highlight ? Math.max(0, highlight.bottom - highlight.top) : 0,
145
+ visible,
146
+ missing
147
+ };
148
+ setPosition((old)=>old && Object.keys(next).every((key)=>old[key] === next[key]) ? old : next);
149
+ };
150
+ let frame = 0;
151
+ const track = ()=>{
152
+ update();
153
+ frame = window.requestAnimationFrame(track);
154
+ };
155
+ track();
156
+ const resize = new ResizeObserver(update);
157
+ resize.observe(surface);
158
+ for(let node = anchor; node; node = node.parentElement)resize.observe(node);
159
+ for (const element of elements)resize.observe(element);
160
+ const mutation = new MutationObserver(update);
161
+ mutation.observe(document.body, {
162
+ childList: true,
163
+ subtree: true
164
+ });
165
+ window.addEventListener('scroll', update, true);
166
+ window.addEventListener('resize', update);
167
+ window.visualViewport?.addEventListener('resize', update);
168
+ window.visualViewport?.addEventListener('scroll', update);
169
+ return ()=>{
170
+ window.cancelAnimationFrame(frame);
171
+ resize.disconnect();
172
+ mutation.disconnect();
173
+ window.removeEventListener('scroll', update, true);
174
+ window.removeEventListener('resize', update);
175
+ window.visualViewport?.removeEventListener('resize', update);
176
+ window.visualViewport?.removeEventListener('scroll', update);
177
+ if (frameElement?.isConnected) frameElement.hidePopover?.();
178
+ };
179
+ }, [
180
+ anchor,
181
+ surface,
182
+ placement,
183
+ elements
184
+ ]);
185
+ return position;
186
+ }
187
+ function useTourTheme(anchor, surface) {
188
+ useEffect(()=>{
189
+ const host = surface?.parentElement;
190
+ if (!anchor || !host) return;
191
+ const copied = new Set();
192
+ const update = ()=>{
193
+ const css = window.getComputedStyle(anchor);
194
+ const next = new Set();
195
+ for(let index = 0; index < css.length; index++){
196
+ const name = css[index];
197
+ if (name?.startsWith('--ov-ui-')) {
198
+ next.add(name);
199
+ host.style.setProperty(name, css.getPropertyValue(name));
200
+ }
201
+ }
202
+ for (const name of copied)if (!next.has(name)) host.style.removeProperty(name);
203
+ copied.clear();
204
+ for (const name of next)copied.add(name);
205
+ };
206
+ let ancestors = [];
207
+ const observeAncestry = ()=>{
208
+ const next = [];
209
+ for(let node = anchor; node; node = node.parentElement)next.push(node);
210
+ if (next.length === ancestors.length && next.every((node, index)=>node === ancestors[index])) return false;
211
+ ancestors = next;
212
+ observer.disconnect();
213
+ for (const node of ancestors)observer.observe(node, {
214
+ attributes: true,
215
+ attributeFilter: [
216
+ 'class',
217
+ 'style',
218
+ 'data-theme'
219
+ ],
220
+ childList: true
221
+ });
222
+ observer.observe(anchor.ownerDocument, {
223
+ childList: true,
224
+ subtree: !anchor.isConnected
225
+ });
226
+ return true;
227
+ };
228
+ const observer = new MutationObserver((records)=>{
229
+ if (observeAncestry() || records.some(({ type })=>'attributes' === type)) update();
230
+ });
231
+ observeAncestry();
232
+ update();
233
+ window.addEventListener('resize', update);
234
+ window.visualViewport?.addEventListener('resize', update);
235
+ return ()=>{
236
+ window.removeEventListener('resize', update);
237
+ window.visualViewport?.removeEventListener('resize', update);
238
+ observer.disconnect();
239
+ for (const name of copied)host.style.removeProperty(name);
240
+ };
241
+ }, [
242
+ anchor,
243
+ surface
244
+ ]);
245
+ }
246
+ const messages = {
247
+ close: 'Close guide',
248
+ next: 'Next',
249
+ done: 'Got it',
250
+ locating: 'Locating directory…',
251
+ unavailable: 'This directory is unavailable. Retry or skip this step.',
252
+ retry: 'Retry',
253
+ skip: 'Skip',
254
+ progress: (current, total)=>`${current}/${total}`
255
+ };
256
+ const en_US = messages;
257
+ const zh_CN_messages = {
258
+ close: '关闭引导',
259
+ next: '下一步',
260
+ done: '知道了',
261
+ locating: '正在定位目录…',
262
+ unavailable: '此目录暂不可用,请重试或跳过这一步。',
263
+ retry: '重试',
264
+ skip: '跳过',
265
+ progress: (current, total)=>`${current}/${total}`
266
+ };
267
+ const zh_CN = zh_CN_messages;
268
+ function TourCard({ step, index, total, locale, labels, onClose, renderContent, titleId, bodyId, locating, unavailable, retry, advance }) {
269
+ const text = resolveLocale({
270
+ 'en-US': en_US,
271
+ 'zh-CN': zh_CN
272
+ }, locale, labels);
273
+ const custom = renderContent && !locating && !unavailable;
274
+ return /*#__PURE__*/ jsxs("div", {
275
+ className: custom ? 'ov-directory-tour__card ov-directory-tour__card--custom' : 'ov-directory-tour__card',
276
+ children: [
277
+ !custom && onClose && /*#__PURE__*/ jsx(button_Button, {
278
+ size: "mini",
279
+ type: "text",
280
+ iconOnly: true,
281
+ className: "ov-directory-tour__close",
282
+ htmlType: "button",
283
+ "aria-label": text.close,
284
+ onClick: onClose,
285
+ children: "\xd7"
286
+ }),
287
+ custom ? /*#__PURE__*/ jsxs(Fragment, {
288
+ children: [
289
+ /*#__PURE__*/ jsx("h2", {
290
+ id: titleId,
291
+ className: "ov-directory-tour__sr-only",
292
+ children: step.title
293
+ }),
294
+ /*#__PURE__*/ jsx("div", {
295
+ id: bodyId,
296
+ children: renderContent({
297
+ step,
298
+ index,
299
+ total,
300
+ complete: ()=>advance(false),
301
+ close: ()=>onClose?.()
302
+ })
303
+ })
304
+ ]
305
+ }) : /*#__PURE__*/ jsxs(Fragment, {
306
+ children: [
307
+ !locating && !unavailable && step.illustration && /*#__PURE__*/ jsx("div", {
308
+ className: "ov-directory-tour__illustration",
309
+ children: step.illustration
310
+ }),
311
+ /*#__PURE__*/ jsx("h2", {
312
+ id: titleId,
313
+ className: "ov-directory-tour__title",
314
+ children: step.title
315
+ }),
316
+ /*#__PURE__*/ jsx("div", {
317
+ id: bodyId,
318
+ className: "ov-directory-tour__description",
319
+ role: unavailable ? 'alert' : void 0,
320
+ children: unavailable ? text.unavailable : locating ? text.locating : step.description
321
+ }),
322
+ /*#__PURE__*/ jsxs("footer", {
323
+ className: "ov-directory-tour__actions",
324
+ children: [
325
+ total > 1 && /*#__PURE__*/ jsx("span", {
326
+ className: "ov-directory-tour__progress",
327
+ "aria-live": "polite",
328
+ children: text.progress(index + 1, total)
329
+ }),
330
+ unavailable ? /*#__PURE__*/ jsxs(Fragment, {
331
+ children: [
332
+ /*#__PURE__*/ jsx(button_Button, {
333
+ size: "small",
334
+ type: "default",
335
+ htmlType: "button",
336
+ onClick: retry,
337
+ children: text.retry
338
+ }),
339
+ /*#__PURE__*/ jsx(button_Button, {
340
+ size: "small",
341
+ type: "default",
342
+ htmlType: "button",
343
+ onClick: ()=>advance(true),
344
+ children: text.skip
345
+ })
346
+ ]
347
+ }) : /*#__PURE__*/ jsx(button_Button, {
348
+ size: "small",
349
+ type: "primary",
350
+ htmlType: "button",
351
+ className: "ov-directory-tour__primary",
352
+ disabled: locating,
353
+ onClick: ()=>advance(false),
354
+ children: step.nextLabel ?? (index === total - 1 ? text.done : text.next)
355
+ })
356
+ ]
357
+ })
358
+ ]
359
+ })
360
+ ]
361
+ });
362
+ }
363
+ function DirectoryTour(props) {
364
+ const [portalRoot, setPortalRoot] = useState(null);
365
+ useEffect(()=>setPortalRoot(document.body), []);
366
+ if (!portalRoot || !props.open || 0 === props.steps.length) return null;
367
+ return /*#__PURE__*/ jsx(TourSession, {
368
+ ...props
369
+ });
370
+ }
371
+ function TourSession(props) {
372
+ const [index, setIndex] = useState(props.defaultStep ?? 0);
373
+ const skipped = useRef(new Set());
374
+ const current = props.currentStep ?? index;
375
+ const step = props.steps[current];
376
+ if (!step) return null;
377
+ const advance = (skip)=>{
378
+ if (skip) skipped.current.add(step.id);
379
+ if (current === props.steps.length - 1) props.onComplete?.({
380
+ skippedStepIds: [
381
+ ...skipped.current
382
+ ]
383
+ });
384
+ else {
385
+ if (void 0 === props.currentStep) setIndex(current + 1);
386
+ props.onStepChange?.(current + 1);
387
+ }
388
+ };
389
+ return /*#__PURE__*/ jsx(TourStep, {
390
+ ...props,
391
+ step: step,
392
+ index: current,
393
+ advance: advance
394
+ }, step.id);
395
+ }
396
+ function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 10000, placement = 'right', onClose, labels, locale: localeProp, className, style, renderContent }) {
397
+ const locale = useLocale(localeProp);
398
+ const [attempt, retry] = useState(0);
399
+ const [surface, setSurface] = useState(null);
400
+ const { anchor, elements, failed } = useTourAnchor(step.target, locateTarget, locateTimeout, attempt);
401
+ const position = useTourPosition(anchor, surface, placement, elements);
402
+ useTourTheme(anchor, surface);
403
+ const titleId = useId();
404
+ const bodyId = useId();
405
+ useEffect(()=>{
406
+ const close = (event)=>{
407
+ if ('Escape' === event.key && !event.defaultPrevented && onClose) {
408
+ event.preventDefault();
409
+ onClose?.();
410
+ }
411
+ };
412
+ window.addEventListener('keydown', close);
413
+ return ()=>window.removeEventListener('keydown', close);
414
+ }, [
415
+ onClose
416
+ ]);
417
+ useEffect(()=>{
418
+ const previous = document.activeElement;
419
+ return ()=>{
420
+ if (previous?.isConnected) previous.focus?.({
421
+ preventScroll: true
422
+ });
423
+ };
424
+ }, []);
425
+ const visible = position?.visible;
426
+ useEffect(()=>{
427
+ if (surface && visible) surface.focus({
428
+ preventScroll: true
429
+ });
430
+ }, [
431
+ surface,
432
+ visible
433
+ ]);
434
+ const unavailable = failed || position?.missing;
435
+ const locating = !anchor && !failed;
436
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
437
+ className: "ov-directory-tour-host",
438
+ popover: "manual",
439
+ style: {
440
+ width: position?.maxWidth,
441
+ height: position?.layoutHeight,
442
+ '--ov-ui-directory-tour-viewport-height': position ? `${position.maxHeight}px` : void 0,
443
+ top: position?.top ?? 0,
444
+ left: position?.left ?? 0,
445
+ visibility: position?.visible ? 'visible' : 'hidden'
446
+ },
447
+ children: /*#__PURE__*/ jsxs("div", {
448
+ ref: setSurface,
449
+ role: "dialog",
450
+ "aria-modal": "false",
451
+ "aria-labelledby": titleId,
452
+ "aria-describedby": bodyId,
453
+ "aria-busy": locating,
454
+ tabIndex: -1,
455
+ className: [
456
+ 'ov-directory-tour',
457
+ className
458
+ ].filter(Boolean).join(' '),
459
+ style: {
460
+ width: step.cardWidth,
461
+ ...style
462
+ },
463
+ children: [
464
+ anchor && !unavailable && position?.visible && /*#__PURE__*/ jsx("div", {
465
+ className: elements.length > 1 ? 'ov-directory-tour__highlight ov-directory-tour__highlight--group' : 'ov-directory-tour__highlight',
466
+ "aria-hidden": "true",
467
+ style: {
468
+ top: position.targetTop,
469
+ left: position.targetLeft,
470
+ width: position.targetWidth,
471
+ height: position.targetHeight
472
+ }
473
+ }),
474
+ /*#__PURE__*/ jsx(TourCard, {
475
+ step: step,
476
+ index: index,
477
+ total: steps.length,
478
+ locale: locale,
479
+ labels: labels,
480
+ titleId: titleId,
481
+ bodyId: bodyId,
482
+ locating: locating,
483
+ unavailable: Boolean(unavailable),
484
+ onClose: onClose,
485
+ retry: ()=>retry((value)=>value + 1),
486
+ advance: advance,
487
+ renderContent: renderContent
488
+ })
489
+ ]
490
+ })
491
+ }), document.body);
492
+ }
493
+ export { DirectoryTour, en_US, zh_CN };