@openviking/react 0.1.7 → 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 (113) hide show
  1. package/README.md +11 -1
  2. package/dist/1~0.js +57 -0
  3. package/dist/3~0.js +171 -5
  4. package/dist/5~0.js +181 -0
  5. package/dist/6~0.js +48 -0
  6. package/dist/components/agent-connect/style.css +4 -2
  7. package/dist/components/api-key-login-form/api-key-login-form.d.ts +2 -0
  8. package/dist/components/api-key-login-form/index.d.ts +3 -0
  9. package/dist/components/api-key-login-form/style.css +438 -0
  10. package/dist/components/api-key-login-form/style.js +0 -0
  11. package/dist/components/api-key-login-form/types.d.ts +7 -0
  12. package/dist/components/api-key-login-form.js +1 -0
  13. package/dist/components/directory-tour/directory-tour-intro.d.ts +3 -0
  14. package/dist/components/directory-tour/index.d.ts +2 -1
  15. package/dist/components/directory-tour/style.css +154 -26
  16. package/dist/components/directory-tour/tour-card.d.ts +14 -0
  17. package/dist/components/directory-tour/types.d.ts +24 -1
  18. package/dist/components/directory-tour/use-tour-anchor.d.ts +1 -0
  19. package/dist/components/directory-tour/use-tour-position.d.ts +4 -1
  20. package/dist/components/directory-tour/use-tour-theme.d.ts +2 -0
  21. package/dist/components/directory-tour.js +52 -1
  22. package/dist/components/email-login-form/email-login-form.d.ts +2 -0
  23. package/dist/components/email-login-form/index.d.ts +3 -0
  24. package/dist/components/email-login-form/style.css +438 -0
  25. package/dist/components/email-login-form/style.js +0 -0
  26. package/dist/components/email-login-form/types.d.ts +11 -0
  27. package/dist/components/email-login-form.js +1 -0
  28. package/dist/components/experience-dashboard/experience-impact.d.ts +3 -1
  29. package/dist/components/experience-dashboard/style.css +4 -2
  30. package/dist/components/file-browser-entries/style.css +12 -6
  31. package/dist/components/file-preview/file-preview-header.d.ts +4 -21
  32. package/dist/components/file-preview/file-preview-toolbar.d.ts +7 -0
  33. package/dist/components/file-preview/locales/en-US.d.ts +9 -0
  34. package/dist/components/file-preview/locales/zh-CN.d.ts +9 -0
  35. package/dist/components/file-preview/style.css +116 -2
  36. package/dist/components/file-preview/types.d.ts +14 -21
  37. package/dist/components/file-tree/style.css +4 -2
  38. package/dist/components/invitation-confirmation/index.d.ts +3 -0
  39. package/dist/components/invitation-confirmation/invitation-confirmation.d.ts +2 -0
  40. package/dist/components/invitation-confirmation/style.css +438 -0
  41. package/dist/components/invitation-confirmation/style.js +0 -0
  42. package/dist/components/invitation-confirmation/types.d.ts +20 -0
  43. package/dist/components/invitation-confirmation.js +1 -0
  44. package/dist/components/login-method-selector/index.d.ts +2 -0
  45. package/dist/components/login-method-selector/login-method-selector.d.ts +2 -0
  46. package/dist/components/login-method-selector/style.css +438 -0
  47. package/dist/components/login-method-selector/style.js +0 -0
  48. package/dist/components/login-method-selector/types.d.ts +14 -0
  49. package/dist/components/login-method-selector.js +1 -0
  50. package/dist/components/password-reset-request-form/index.d.ts +3 -0
  51. package/dist/components/password-reset-request-form/password-reset-request-form.d.ts +2 -0
  52. package/dist/components/password-reset-request-form/style.css +438 -0
  53. package/dist/components/password-reset-request-form/style.js +0 -0
  54. package/dist/components/password-reset-request-form/types.d.ts +13 -0
  55. package/dist/components/password-reset-request-form.js +1 -0
  56. package/dist/components/password-setup-form/index.d.ts +3 -0
  57. package/dist/components/password-setup-form/password-setup-form.d.ts +2 -0
  58. package/dist/components/password-setup-form/style.css +438 -0
  59. package/dist/components/password-setup-form/style.js +0 -0
  60. package/dist/components/password-setup-form/types.d.ts +10 -0
  61. package/dist/components/password-setup-form.js +1 -0
  62. package/dist/components/scope-switcher/style.css +4 -2
  63. package/dist/components/scope-switcher.js +1 -1
  64. package/dist/components/style.css +2966 -58
  65. package/dist/components/tui/style.css +8 -4
  66. package/dist/components/viking-bot/style.css +12 -6
  67. package/dist/components/wiki-dashboard/index.d.ts +1 -1
  68. package/dist/components/wiki-dashboard/style.css +16 -4
  69. package/dist/components/wiki-dashboard/types.d.ts +12 -16
  70. package/dist/components/wiki-dashboard/wiki-action-button.d.ts +2 -9
  71. package/dist/components/wiki-dashboard/wiki-conflict-card.d.ts +3 -10
  72. package/dist/d~0.js +28 -0
  73. package/dist/ep~0.js +281 -133
  74. package/dist/fi~0.js +339 -0
  75. package/dist/fj~0.js +32 -67
  76. package/dist/fl~0.js +3 -2
  77. package/dist/f~0.js +63 -326
  78. package/dist/g~0.js +135 -0
  79. package/dist/icons/index.d.ts +2 -0
  80. package/dist/icons.js +1 -1
  81. package/dist/index.d.ts +12 -0
  82. package/dist/index.js +8 -2
  83. package/dist/k~0.js +44 -4
  84. package/dist/l5~0.js +3813 -0
  85. package/dist/lk~0.js +1 -1
  86. package/dist/l~0.js +54 -3811
  87. package/dist/modules/console/style.css +28 -14
  88. package/dist/modules/file-browser/file-browser-detail-icons.d.ts +0 -6
  89. package/dist/modules/file-browser/file-browser-detail.d.ts +2 -23
  90. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  91. package/dist/modules/file-browser/fs-file-editing.d.ts +4 -0
  92. package/dist/modules/file-browser/fs-preview-images.d.ts +3 -0
  93. package/dist/modules/file-browser/fs-read-file.d.ts +1 -1
  94. package/dist/modules/file-browser/style.css +156 -70
  95. package/dist/modules/file-browser/types.d.ts +2 -0
  96. package/dist/modules/file-browser/use-file-browser-acl.d.ts +1 -0
  97. package/dist/modules/file-browser/wiki-dashboard-pane.d.ts +2 -4
  98. package/dist/modules/file-browser.js +1 -1
  99. package/dist/modules/scope-cascade/style.css +4 -2
  100. package/dist/modules/style.css +192 -88
  101. package/dist/n~0.js +1 -1
  102. package/dist/p0~0.js +27 -0
  103. package/dist/p~0.js +34 -25
  104. package/dist/shared/auth/agreements.d.ts +10 -0
  105. package/dist/shared/auth/fields.d.ts +15 -0
  106. package/dist/shared/auth/form-frame.d.ts +12 -0
  107. package/dist/shared/auth/locales/en-US.d.ts +24 -0
  108. package/dist/shared/auth/locales/zh-CN.d.ts +24 -0
  109. package/dist/shared/auth/types.d.ts +61 -0
  110. package/dist/shared/auth/use-auth-labels.d.ts +3 -0
  111. package/dist/shared/auth/use-form.d.ts +8 -0
  112. package/dist/style.css +3364 -350
  113. package/package.json +32 -2
package/dist/ep~0.js CHANGED
@@ -1,30 +1,40 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useRef, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { useLocale } from "./28~0.js";
5
4
  import { resolveLocale } from "./nx~0.js";
6
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
+ }
7
10
  function useTourAnchor(target, locateTarget, timeout, attempt) {
8
11
  const [state, setState] = useState({
9
12
  anchor: null,
13
+ elements: [],
10
14
  failed: false
11
15
  });
12
16
  useEffect(()=>{
13
17
  const controller = new AbortController();
14
18
  setState({
15
19
  anchor: null,
20
+ elements: [],
16
21
  failed: false
17
22
  });
18
23
  const timer = window.setTimeout(()=>{
19
24
  controller.abort();
20
25
  setState({
21
26
  anchor: null,
27
+ elements: [],
22
28
  failed: true
23
29
  });
24
30
  }, timeout);
25
- Promise.resolve().then(()=>locateTarget?.(target, controller.signal) ?? null).then((anchor)=>{
31
+ Promise.resolve().then(()=>locateTarget?.(target, controller.signal) ?? null).then((target)=>{
26
32
  if (controller.signal.aborted) return;
27
33
  window.clearTimeout(timer);
34
+ const elements = target ? isAnchorGroup(target) ? target : [
35
+ target
36
+ ] : [];
37
+ const anchor = elements[0];
28
38
  if (anchor?.isConnected) {
29
39
  anchor.scrollIntoView({
30
40
  block: 'nearest',
@@ -32,10 +42,12 @@ function useTourAnchor(target, locateTarget, timeout, attempt) {
32
42
  });
33
43
  setState({
34
44
  anchor,
45
+ elements,
35
46
  failed: false
36
47
  });
37
48
  } else setState({
38
49
  anchor: null,
50
+ elements: [],
39
51
  failed: true
40
52
  });
41
53
  }, ()=>{
@@ -43,6 +55,7 @@ function useTourAnchor(target, locateTarget, timeout, attempt) {
43
55
  window.clearTimeout(timer);
44
56
  setState({
45
57
  anchor: null,
58
+ elements: [],
46
59
  failed: true
47
60
  });
48
61
  });
@@ -58,27 +71,39 @@ function useTourAnchor(target, locateTarget, timeout, attempt) {
58
71
  ]);
59
72
  return state;
60
73
  }
61
- function useTourPosition(anchor, surface, placement) {
74
+ function useTourPosition(anchor, surface, placement, elements) {
62
75
  const [position, setPosition] = useState();
63
76
  useEffect(()=>{
64
77
  if (!surface) return;
65
- surface.showPopover?.();
78
+ const frameElement = surface.parentElement;
79
+ frameElement?.showPopover?.();
66
80
  const update = ()=>{
67
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;
68
90
  const box = surface.getBoundingClientRect();
69
- const width = window.innerWidth;
70
- const height = window.innerHeight;
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;
71
96
  const margin = 8;
72
- let left = (width - box.width) / 2;
73
- let top = (height - box.height) / 2;
97
+ let left = x + (width - box.width) / 2;
98
+ let top = y + (height - box.height) / 2;
74
99
  const missing = Boolean(anchor && !anchor.isConnected);
75
100
  let visible = !anchor || missing;
76
101
  if (anchor && a && !missing) {
77
102
  let clip = {
78
- left: 0,
79
- top: 0,
80
- right: width,
81
- bottom: height
103
+ left: x,
104
+ top: y,
105
+ right: x + width,
106
+ bottom: y + height
82
107
  };
83
108
  for(let parent = anchor.parentElement; parent; parent = parent.parentElement){
84
109
  const css = window.getComputedStyle(parent);
@@ -94,33 +119,44 @@ function useTourPosition(anchor, surface, placement) {
94
119
  bottom: Math.min(clip.bottom, rect.bottom)
95
120
  };
96
121
  }
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;
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
+ };
98
130
  const right = a.right + 6;
99
131
  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;
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;
101
133
  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
134
  }
108
135
  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,
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,
115
145
  visible,
116
146
  missing
117
147
  };
118
148
  setPosition((old)=>old && Object.keys(next).every((key)=>old[key] === next[key]) ? old : next);
119
149
  };
120
- update();
150
+ let frame = 0;
151
+ const track = ()=>{
152
+ update();
153
+ frame = window.requestAnimationFrame(track);
154
+ };
155
+ track();
121
156
  const resize = new ResizeObserver(update);
122
157
  resize.observe(surface);
123
158
  for(let node = anchor; node; node = node.parentElement)resize.observe(node);
159
+ for (const element of elements)resize.observe(element);
124
160
  const mutation = new MutationObserver(update);
125
161
  mutation.observe(document.body, {
126
162
  childList: true,
@@ -131,21 +167,82 @@ function useTourPosition(anchor, surface, placement) {
131
167
  window.visualViewport?.addEventListener('resize', update);
132
168
  window.visualViewport?.addEventListener('scroll', update);
133
169
  return ()=>{
170
+ window.cancelAnimationFrame(frame);
134
171
  resize.disconnect();
135
172
  mutation.disconnect();
136
173
  window.removeEventListener('scroll', update, true);
137
174
  window.removeEventListener('resize', update);
138
175
  window.visualViewport?.removeEventListener('resize', update);
139
176
  window.visualViewport?.removeEventListener('scroll', update);
140
- if (surface.isConnected) surface.hidePopover?.();
177
+ if (frameElement?.isConnected) frameElement.hidePopover?.();
141
178
  };
142
179
  }, [
143
180
  anchor,
144
181
  surface,
145
- placement
182
+ placement,
183
+ elements
146
184
  ]);
147
185
  return position;
148
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
+ }
149
246
  const messages = {
150
247
  close: 'Close guide',
151
248
  next: 'Next',
@@ -168,8 +265,105 @@ const zh_CN_messages = {
168
265
  progress: (current, total)=>`${current}/${total}`
169
266
  };
170
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
+ }
171
363
  function DirectoryTour(props) {
172
- if (!props.open || 0 === props.steps.length) return null;
364
+ const [portalRoot, setPortalRoot] = useState(null);
365
+ useEffect(()=>setPortalRoot(document.body), []);
366
+ if (!portalRoot || !props.open || 0 === props.steps.length) return null;
173
367
  return /*#__PURE__*/ jsx(TourSession, {
174
368
  ...props
175
369
  });
@@ -199,34 +393,31 @@ function TourSession(props) {
199
393
  advance: advance
200
394
  }, step.id);
201
395
  }
202
- function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 10000, placement = 'right', onClose, labels, locale: localeProp, className, style }) {
396
+ function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 10000, placement = 'right', onClose, labels, locale: localeProp, className, style, renderContent }) {
203
397
  const locale = useLocale(localeProp);
204
- const text = resolveLocale({
205
- 'en-US': en_US,
206
- 'zh-CN': zh_CN
207
- }, locale, labels);
208
398
  const [attempt, retry] = useState(0);
209
399
  const [surface, setSurface] = useState(null);
210
- const { anchor, failed } = useTourAnchor(step.target, locateTarget, locateTimeout, attempt);
211
- const position = useTourPosition(anchor, surface, placement);
400
+ const { anchor, elements, failed } = useTourAnchor(step.target, locateTarget, locateTimeout, attempt);
401
+ const position = useTourPosition(anchor, surface, placement, elements);
402
+ useTourTheme(anchor, surface);
212
403
  const titleId = useId();
213
404
  const bodyId = useId();
214
405
  useEffect(()=>{
215
406
  const close = (event)=>{
216
- if ('Escape' === event.key) {
407
+ if ('Escape' === event.key && !event.defaultPrevented && onClose) {
217
408
  event.preventDefault();
218
409
  onClose?.();
219
410
  }
220
411
  };
221
- document.addEventListener('keydown', close);
222
- return ()=>document.removeEventListener('keydown', close);
412
+ window.addEventListener('keydown', close);
413
+ return ()=>window.removeEventListener('keydown', close);
223
414
  }, [
224
415
  onClose
225
416
  ]);
226
417
  useEffect(()=>{
227
418
  const previous = document.activeElement;
228
419
  return ()=>{
229
- if (previous instanceof HTMLElement && previous.isConnected) previous.focus({
420
+ if (previous?.isConnected) previous.focus?.({
230
421
  preventScroll: true
231
422
  });
232
423
  };
@@ -240,106 +431,63 @@ function TourStep({ step, index, advance, steps, locateTarget, locateTimeout = 1
240
431
  surface,
241
432
  visible
242
433
  ]);
243
- if ("u" < typeof document) return null;
244
434
  const unavailable = failed || position?.missing;
245
435
  const locating = !anchor && !failed;
246
- return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs("div", {
247
- ref: setSurface,
436
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
437
+ className: "ov-directory-tour-host",
248
438
  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
439
  style: {
260
- ...style,
440
+ width: position?.maxWidth,
441
+ height: position?.layoutHeight,
442
+ '--ov-ui-directory-tour-viewport-height': position ? `${position.maxHeight}px` : void 0,
261
443
  top: position?.top ?? 0,
262
444
  left: position?.left ?? 0,
263
445
  visibility: position?.visible ? 'visible' : 'hidden'
264
446
  },
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
- ]
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
+ })
343
491
  }), document.body);
344
492
  }
345
- export { DirectoryTour };
493
+ export { DirectoryTour, en_US, zh_CN };