@openviking/react 0.1.5 → 0.1.6

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 (101) hide show
  1. package/README.md +13 -11
  2. package/dist/37~0.js +27 -0
  3. package/dist/3c~0.js +14 -8
  4. package/dist/3~0.js +1 -1
  5. package/dist/a~0.js +2 -2
  6. package/dist/ck~0.js +4 -0
  7. package/dist/client/paths.d.ts +4 -0
  8. package/dist/components/agent-connect/style.css +48 -4
  9. package/dist/components/directory-tour/style.css +46 -2
  10. package/dist/components/experience-dashboard/dashboard-tabs.d.ts +11 -0
  11. package/dist/components/experience-dashboard/experience-dashboard.d.ts +2 -0
  12. package/dist/components/experience-dashboard/experience-impact.d.ts +11 -0
  13. package/dist/components/experience-dashboard/experience-list.d.ts +9 -0
  14. package/dist/components/experience-dashboard/experience-pagination.d.ts +8 -0
  15. package/dist/components/experience-dashboard/experience-tests.d.ts +6 -0
  16. package/dist/components/experience-dashboard/experience-trajectories.d.ts +6 -0
  17. package/dist/components/experience-dashboard/index.d.ts +2 -0
  18. package/dist/components/experience-dashboard/labels.d.ts +2 -0
  19. package/dist/components/experience-dashboard/style.css +699 -0
  20. package/dist/components/experience-dashboard/style.js +0 -0
  21. package/dist/components/experience-dashboard/types.d.ts +106 -0
  22. package/dist/components/experience-dashboard.js +1 -0
  23. package/dist/components/file-browser-entries/style.css +144 -12
  24. package/dist/components/file-preview/style.css +48 -4
  25. package/dist/components/file-tree/style.css +63 -4
  26. package/dist/components/scope-switcher/style.css +48 -4
  27. package/dist/components/scope-switcher.js +1 -1
  28. package/dist/components/style.css +2168 -84
  29. package/dist/components/tui/style.css +122 -36
  30. package/dist/components/viking-bot/style.css +159 -12
  31. package/dist/components/wiki-dashboard/index.d.ts +2 -0
  32. package/dist/components/wiki-dashboard/labels.d.ts +2 -0
  33. package/dist/components/wiki-dashboard/style.css +741 -0
  34. package/dist/components/wiki-dashboard/style.js +0 -0
  35. package/dist/components/wiki-dashboard/types.d.ts +92 -0
  36. package/dist/components/wiki-dashboard/wiki-action-button.d.ts +9 -0
  37. package/dist/components/wiki-dashboard/wiki-conflict-card.d.ts +15 -0
  38. package/dist/components/wiki-dashboard/wiki-dashboard.d.ts +2 -0
  39. package/dist/components/wiki-dashboard/wiki-file-icon.d.ts +3 -0
  40. package/dist/components/wiki-dashboard/wiki-severity-filter.d.ts +8 -0
  41. package/dist/components/wiki-dashboard.js +1 -0
  42. package/dist/c~0.js +1 -1
  43. package/dist/fi~0.js +354 -0
  44. package/dist/fj~0.js +503 -0
  45. package/dist/f~0.js +661 -315
  46. package/dist/icons/index.d.ts +28 -0
  47. package/dist/icons.js +1 -1
  48. package/dist/index.d.ts +4 -0
  49. package/dist/index.js +3 -1
  50. package/dist/k~0.js +277 -1
  51. package/dist/lk~0.js +52 -13
  52. package/dist/l~0.js +1021 -118
  53. package/dist/modules/console/index.d.ts +1 -2
  54. package/dist/modules/console/style.css +377 -56
  55. package/dist/modules/console.js +1 -1
  56. package/dist/modules/file-browser/dashboard-data.d.ts +9 -0
  57. package/dist/modules/file-browser/dashboard-indicator.d.ts +8 -0
  58. package/dist/modules/file-browser/dashboard-labels.d.ts +9 -0
  59. package/dist/modules/file-browser/dashboard-model.d.ts +14 -0
  60. package/dist/modules/file-browser/dashboard-resource.d.ts +12 -0
  61. package/dist/modules/file-browser/experience-dashboard-pane.d.ts +8 -0
  62. package/dist/modules/file-browser/experience-data.d.ts +31 -0
  63. package/dist/modules/file-browser/file-browser-labels.d.ts +1 -1
  64. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +3 -2
  65. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  66. package/dist/modules/file-browser/fs-directories.d.ts +8 -0
  67. package/dist/modules/file-browser/fs-lines.d.ts +36 -0
  68. package/dist/modules/file-browser/fs-memory-fields.d.ts +65 -0
  69. package/dist/modules/file-browser/fs-model.d.ts +12 -2
  70. package/dist/modules/file-browser/fs-read-file.d.ts +14 -0
  71. package/dist/modules/file-browser/fs-selection.d.ts +4 -0
  72. package/dist/modules/file-browser/index.d.ts +2 -2
  73. package/dist/modules/file-browser/style.css +1768 -24
  74. package/dist/modules/file-browser/types.d.ts +62 -0
  75. package/dist/modules/file-browser/use-browser-dashboards.d.ts +31 -0
  76. package/dist/modules/file-browser/use-dashboard-query.d.ts +9 -0
  77. package/dist/modules/file-browser/use-experience-dashboard.d.ts +27 -0
  78. package/dist/modules/file-browser/use-file-browser.d.ts +2 -45
  79. package/dist/modules/file-browser/use-fs-tree.d.ts +2 -0
  80. package/dist/modules/file-browser/use-wiki-dashboard.d.ts +17 -0
  81. package/dist/modules/file-browser/wiki-conflicts.d.ts +12 -0
  82. package/dist/modules/file-browser/wiki-dashboard-pane.d.ts +14 -0
  83. package/dist/modules/file-browser.js +1 -1
  84. package/dist/modules/scope-cascade/controller.d.ts +2 -2
  85. package/dist/modules/scope-cascade/index.d.ts +1 -2
  86. package/dist/modules/scope-cascade/scope-cascade.d.ts +1 -1
  87. package/dist/modules/scope-cascade/style.css +48 -4
  88. package/dist/modules/scope-cascade/types.d.ts +8 -3
  89. package/dist/modules/scope-cascade/use-scope-cascade.d.ts +2 -2
  90. package/dist/modules/scope-cascade.js +1 -1
  91. package/dist/modules/style.css +2344 -191
  92. package/dist/n~0.js +13 -129
  93. package/dist/rt~0.js +152 -0
  94. package/dist/r~0.js +17 -38
  95. package/dist/shared/components/popover/popover.d.ts +1 -1
  96. package/dist/shared/components/popover/types.d.ts +7 -1
  97. package/dist/shared/dashboard/dashboard-state.d.ts +12 -0
  98. package/dist/static/image/dashboard-background.png +0 -0
  99. package/dist/style.css +8897 -4616
  100. package/dist/viking-bot-composer~0.js +1 -1
  101. package/package.json +12 -2
File without changes
@@ -0,0 +1,92 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ export interface WikiConflict {
3
+ id: string;
4
+ matchText: string;
5
+ description: string;
6
+ reason: string;
7
+ severity: 'high' | 'medium' | 'low';
8
+ state: 'unfixed' | 'fixed';
9
+ beginTime: number;
10
+ fixTime: number | null;
11
+ fixPlan: string;
12
+ resolutionBasis: string;
13
+ resolutionSource?: 'manual' | 'automatic';
14
+ location: {
15
+ status: 'unique';
16
+ start: number;
17
+ end: number;
18
+ line: number;
19
+ } | {
20
+ status: 'missing' | 'ambiguous';
21
+ };
22
+ }
23
+ export interface WikiDirectoryData {
24
+ files: readonly string[];
25
+ conflictFileCount?: number;
26
+ limited?: boolean;
27
+ }
28
+ export interface WikiFileData {
29
+ conflicts: readonly WikiConflict[];
30
+ /** Document path to display; omitted paths hide the path column. */
31
+ path?: string;
32
+ }
33
+ export type WikiDashboardData = WikiDirectoryData | WikiFileData;
34
+ export interface WikiDashboardLabels {
35
+ title: string;
36
+ pendingLabel: string;
37
+ discuss: string;
38
+ conflicts: string;
39
+ conflictFiles: string;
40
+ pending: string;
41
+ all: string;
42
+ severity: string;
43
+ high: string;
44
+ medium: string;
45
+ low: string;
46
+ fixed: string;
47
+ reason: string;
48
+ file: string;
49
+ empty: string;
50
+ loading: string;
51
+ failed: string;
52
+ retry: string;
53
+ open: string;
54
+ edit: string;
55
+ solution: string;
56
+ occurred: string;
57
+ fixedAt: string;
58
+ evidence: string;
59
+ history: string;
60
+ historyHint: string;
61
+ unavailable: string;
62
+ limited: string;
63
+ }
64
+ interface WikiDashboardCommonProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
65
+ loading?: boolean;
66
+ error?: Error | null;
67
+ locale?: 'en-US' | 'zh-CN';
68
+ onRetry?: () => void;
69
+ labels?: Partial<WikiDashboardLabels>;
70
+ }
71
+ export type WikiDashboardProps = WikiDashboardCommonProps & ({
72
+ kind: 'directory';
73
+ data?: WikiDirectoryData;
74
+ editDisabledReason?: never;
75
+ discussDisabledReason?: never;
76
+ onOpenUri?: (uri: string) => void;
77
+ onOpenDashboard?: (uri: string) => void;
78
+ onEdit?: (uri: string) => void;
79
+ onDiscuss?: never;
80
+ } | {
81
+ kind: 'file';
82
+ data?: WikiFileData;
83
+ /** Explanation shown when editing has no handler. Defaults to labels.unavailable. */
84
+ editDisabledReason?: string;
85
+ /** Explanation shown when discussion has no handler. Defaults to labels.unavailable. */
86
+ discussDisabledReason?: string;
87
+ onOpenUri?: () => void;
88
+ onOpenDashboard?: never;
89
+ onEdit?: (conflict: WikiConflict) => void;
90
+ onDiscuss?: (conflict: WikiConflict) => void;
91
+ });
92
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare function WikiActionButton({ label, hint, onClick, children, ...aria }: {
3
+ label: string;
4
+ hint: string;
5
+ onClick?: () => void;
6
+ children: ReactNode;
7
+ 'aria-expanded'?: boolean;
8
+ 'aria-controls'?: string;
9
+ }): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import type { WikiConflict, WikiDashboardProps, WikiDashboardLabels } from './types.js';
2
+ export declare function WikiConflictCard({ conflict, path, labels: t, editDisabledReason, discussDisabledReason, onOpenUri, onEdit, onDiscuss, }: {
3
+ conflict: WikiConflict;
4
+ path?: string;
5
+ labels: WikiDashboardLabels;
6
+ editDisabledReason?: string;
7
+ discussDisabledReason?: string;
8
+ onOpenUri?: () => void;
9
+ onEdit?: Extract<WikiDashboardProps, {
10
+ kind: 'file';
11
+ }>['onEdit'];
12
+ onDiscuss?: Extract<WikiDashboardProps, {
13
+ kind: 'file';
14
+ }>['onDiscuss'];
15
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { WikiDashboardProps } from './types.js';
2
+ export declare function WikiDashboard(props: WikiDashboardProps): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function WikiFileIcon({ name }: {
2
+ name: string;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import type { WikiConflict, WikiDashboardLabels } from './types.js';
2
+ type Severity = WikiConflict['severity'] | 'all';
3
+ export declare function WikiSeverityFilter({ value, onChange, labels: t, }: {
4
+ value: Severity;
5
+ onChange: (value: Severity) => void;
6
+ labels: WikiDashboardLabels;
7
+ }): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1 @@
1
+ export { WikiDashboard } from "../fj~0.js";
package/dist/c~0.js CHANGED
@@ -4,7 +4,7 @@ import { createPortal } from "react-dom";
4
4
  import { resolveLocale } from "./nx~0.js";
5
5
  import { useOverlayPosition } from "./o~0.js";
6
6
  import { useLocale, LocaleProvider } from "./28~0.js";
7
- import { Tooltip } from "./r~0.js";
7
+ import { Tooltip } from "./rt~0.js";
8
8
  import { VikingBotIcon } from "./lg~0.js";
9
9
  import { VikingBotInteraction } from "./w~0.js";
10
10
  const en_US_messages = {
package/dist/fi~0.js ADDED
@@ -0,0 +1,354 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { resolveLocale } from "./nx~0.js";
4
+ import { checkreact } from "./0~0.js";
5
+ import { searchreact } from "./p~0.js";
6
+ import { useLocale, LocaleProvider } from "./28~0.js";
7
+ const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ width: 14,
10
+ height: 14,
11
+ fill: "none",
12
+ viewBox: "0 0 14 14",
13
+ ...props,
14
+ children: /*#__PURE__*/ jsx("path", {
15
+ fill: "currentColor",
16
+ d: "M9.607 5.232a.437.437 0 1 1 .619.619L7.309 8.768a.437.437 0 0 1-.618 0L3.774 5.85a.437.437 0 1 1 .619-.619L7 7.84z"
17
+ })
18
+ });
19
+ const chevron_downreact = SvgChevronDown;
20
+ const messages = {
21
+ loading: 'Loading…',
22
+ searchPlaceholder: 'Search',
23
+ empty: 'No options',
24
+ noMatch: 'No matches',
25
+ error: 'Unable to load options'
26
+ };
27
+ const en_US = messages;
28
+ const zh_CN_messages = {
29
+ loading: '加载中…',
30
+ searchPlaceholder: '搜索',
31
+ empty: '暂无选项',
32
+ noMatch: '没有匹配项',
33
+ error: '选项加载失败'
34
+ };
35
+ const zh_CN = zh_CN_messages;
36
+ const LOCALES = {
37
+ 'en-US': en_US,
38
+ 'zh-CN': zh_CN
39
+ };
40
+ function resolveScopeLabels(locale = 'en-US', labels) {
41
+ const defaults = resolveLocale(LOCALES, locale, labels);
42
+ return {
43
+ ...defaults,
44
+ noMatch: labels?.noMatch ?? labels?.empty ?? defaults.noMatch
45
+ };
46
+ }
47
+ function moveScopeFocus(event) {
48
+ if (![
49
+ 'ArrowDown',
50
+ 'ArrowUp',
51
+ 'Home',
52
+ 'End'
53
+ ].includes(event.key)) return;
54
+ const target = event.target;
55
+ const isSearch = target.matches('input.ov-scope-switcher__search');
56
+ if (event.defaultPrevented || !target.matches('[role="option"]') && !isSearch || isSearch && !event.key.startsWith('Arrow')) return;
57
+ const options = Array.from(event.currentTarget.querySelectorAll('[role="option"]:not([aria-disabled="true"])'));
58
+ if (!options.length) return;
59
+ event.preventDefault();
60
+ const current = options.indexOf(document.activeElement);
61
+ const next = 'Home' === event.key ? 0 : 'End' === event.key ? options.length - 1 : 'ArrowDown' === event.key ? (current + 1) % options.length : current < 0 ? options.length - 1 : (current - 1 + options.length) % options.length;
62
+ options[next]?.focus();
63
+ }
64
+ function Highlight({ text, keyword }) {
65
+ const needle = keyword.trim().toLocaleLowerCase();
66
+ if (!needle) return /*#__PURE__*/ jsx(Fragment, {
67
+ children: text
68
+ });
69
+ const haystack = text.toLocaleLowerCase();
70
+ const parts = [];
71
+ let cursor = 0;
72
+ let hit = haystack.indexOf(needle);
73
+ while(hit >= 0){
74
+ if (hit > cursor) parts.push(text.slice(cursor, hit));
75
+ const end = hit + needle.length;
76
+ parts.push(/*#__PURE__*/ jsx("mark", {
77
+ children: text.slice(hit, end)
78
+ }, `${hit}-${end}`));
79
+ cursor = end;
80
+ hit = haystack.indexOf(needle, cursor);
81
+ }
82
+ if (cursor < text.length) parts.push(text.slice(cursor));
83
+ return /*#__PURE__*/ jsx(Fragment, {
84
+ children: parts
85
+ });
86
+ }
87
+ function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
88
+ const focusPanel = useCallback((node)=>{
89
+ const target = node?.querySelector('input') ?? node?.querySelector('[role="option"][aria-selected="true"]:not([aria-disabled="true"])') ?? node?.querySelector('[role="option"]:not([aria-disabled="true"])');
90
+ (target ?? node)?.focus();
91
+ }, []);
92
+ const options = data.visibleOptions ?? data.options;
93
+ const keyword = state?.searchKeyword ?? '';
94
+ const hasKeyword = keyword.trim().length > 0;
95
+ const searchVisible = actions?.onSearchKeywordChange && (hasKeyword || Math.max(options.length, data.options.length, data.total ?? 0) > 10);
96
+ const search = searchVisible ? /*#__PURE__*/ jsxs("div", {
97
+ className: "ov-scope-switcher__search-field",
98
+ children: [
99
+ /*#__PURE__*/ jsx(searchreact, {
100
+ className: "ov-scope-switcher__search-icon"
101
+ }),
102
+ /*#__PURE__*/ jsx("input", {
103
+ type: "search",
104
+ className: "ov-scope-switcher__search",
105
+ value: keyword,
106
+ "aria-label": labels.searchPlaceholder,
107
+ placeholder: labels.searchPlaceholder,
108
+ onChange: (event)=>actions?.onSearchKeywordChange?.(event.currentTarget.value)
109
+ })
110
+ ]
111
+ }) : null;
112
+ let list;
113
+ list = state?.loading ? /*#__PURE__*/ jsx("div", {
114
+ className: "ov-scope-switcher__state",
115
+ role: "status",
116
+ children: labels.loading
117
+ }) : state?.error ? /*#__PURE__*/ jsx("div", {
118
+ className: "ov-scope-switcher__state",
119
+ role: "alert",
120
+ children: slots?.errorFallback ?? labels.error
121
+ }) : options.length ? /*#__PURE__*/ jsx("div", {
122
+ className: "ov-scope-switcher__list",
123
+ role: "listbox",
124
+ "aria-label": label,
125
+ "aria-busy": state?.busy,
126
+ onScroll: (event)=>{
127
+ const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
128
+ actions?.onScroll?.({
129
+ scrollTop,
130
+ scrollHeight,
131
+ clientHeight
132
+ });
133
+ },
134
+ children: options.map((option)=>{
135
+ const selected = option.id === data.selectedId;
136
+ const content = /*#__PURE__*/ jsxs(Fragment, {
137
+ children: [
138
+ option.icon && /*#__PURE__*/ jsx("span", {
139
+ className: "ov-scope-switcher__icon",
140
+ "aria-hidden": "true",
141
+ children: option.icon
142
+ }),
143
+ /*#__PURE__*/ jsxs("span", {
144
+ className: "ov-scope-switcher__option-text",
145
+ children: [
146
+ /*#__PURE__*/ jsx("span", {
147
+ children: /*#__PURE__*/ jsx(Highlight, {
148
+ text: option.label,
149
+ keyword: keyword
150
+ })
151
+ }),
152
+ option.description && /*#__PURE__*/ jsx("small", {
153
+ children: option.description
154
+ })
155
+ ]
156
+ }),
157
+ selected && /*#__PURE__*/ jsx("span", {
158
+ className: "ov-scope-switcher__check",
159
+ "aria-hidden": "true",
160
+ children: /*#__PURE__*/ jsx(checkreact, {})
161
+ })
162
+ ]
163
+ });
164
+ return /*#__PURE__*/ jsx("div", {
165
+ tabIndex: option.disabled || state?.busy ? -1 : 0,
166
+ role: "option",
167
+ "aria-selected": selected,
168
+ className: "ov-scope-switcher__option",
169
+ title: option.label,
170
+ "aria-disabled": option.disabled || state?.busy || void 0,
171
+ onClick: (event)=>{
172
+ const target = event.target;
173
+ if (option.disabled || state?.busy || target.closest('button, a, input, select, textarea, [role="button"]')) return;
174
+ onSelect(option);
175
+ },
176
+ onKeyDown: (event)=>{
177
+ if (event.target !== event.currentTarget || option.disabled || state?.busy) return;
178
+ if ('Enter' === event.key || ' ' === event.key) {
179
+ event.preventDefault();
180
+ onSelect(option);
181
+ }
182
+ },
183
+ children: slots?.renderOption ? slots?.renderOption(content, option) : content
184
+ }, option.id);
185
+ })
186
+ }, keyword) : /*#__PURE__*/ jsx("div", {
187
+ className: "ov-scope-switcher__state",
188
+ role: "status",
189
+ children: slots?.emptyFallback ?? (hasKeyword ? labels.noMatch : labels.empty)
190
+ });
191
+ return /*#__PURE__*/ jsx("div", {
192
+ role: "group",
193
+ tabIndex: -1,
194
+ ref: focusPanel,
195
+ className: "ov-scope-switcher__panel-inner",
196
+ onKeyDownCapture: moveScopeFocus,
197
+ children: slots?.renderPanel ? slots?.renderPanel({
198
+ search,
199
+ list
200
+ }) : /*#__PURE__*/ jsxs("div", {
201
+ className: "ov-scope-switcher__panel-body",
202
+ children: [
203
+ search,
204
+ list
205
+ ]
206
+ })
207
+ });
208
+ }
209
+ function ScopeSelector(props) {
210
+ const { identity, trigger: triggerContent } = props;
211
+ const locale = useLocale(props.locale);
212
+ const labels = resolveScopeLabels(locale, props.labels);
213
+ const selectable = 'selectable' === props.kind ? props : void 0;
214
+ const data = selectable?.data;
215
+ const state = selectable?.state;
216
+ const actions = selectable?.actions;
217
+ const slots = selectable?.slots;
218
+ const [localVisible, setLocalVisible] = useState(false);
219
+ const root = useRef(null);
220
+ const trigger = useRef(null);
221
+ const restoreSelectionFocus = useRef(false);
222
+ const panelId = useId();
223
+ const open = void 0 !== selectable && (state?.visible ?? localVisible) && !state?.disabled;
224
+ const onVisibleChange = actions?.onVisibleChange;
225
+ const changeVisible = useCallback((visible)=>{
226
+ setLocalVisible(visible);
227
+ onVisibleChange?.(visible);
228
+ }, [
229
+ onVisibleChange
230
+ ]);
231
+ useEffect(()=>{
232
+ if (!open) return;
233
+ const dismiss = (event)=>{
234
+ if (event.target instanceof Node && !root.current?.contains(event.target)) changeVisible(false);
235
+ };
236
+ const escape = (event)=>{
237
+ if ('Escape' === event.key) {
238
+ event.preventDefault();
239
+ changeVisible(false);
240
+ trigger.current?.focus();
241
+ }
242
+ };
243
+ document.addEventListener('pointerdown', dismiss);
244
+ document.addEventListener('keydown', escape);
245
+ return ()=>{
246
+ document.removeEventListener('pointerdown', dismiss);
247
+ document.removeEventListener('keydown', escape);
248
+ };
249
+ }, [
250
+ open,
251
+ changeVisible
252
+ ]);
253
+ useEffect(()=>{
254
+ if (open || !restoreSelectionFocus.current) return;
255
+ restoreSelectionFocus.current = false;
256
+ if (document.activeElement === document.body || root.current?.contains(document.activeElement)) trigger.current?.focus();
257
+ }, [
258
+ open
259
+ ]);
260
+ const selected = data?.options.find((o)=>o.id === data.selectedId);
261
+ const label = triggerContent?.label ?? selected?.label ?? '';
262
+ const icon = triggerContent?.icon ?? selected?.icon;
263
+ const content = /*#__PURE__*/ jsxs(Fragment, {
264
+ children: [
265
+ icon && /*#__PURE__*/ jsx("span", {
266
+ className: "ov-scope-switcher__icon",
267
+ "aria-hidden": "true",
268
+ children: icon
269
+ }),
270
+ /*#__PURE__*/ jsx("span", {
271
+ className: "ov-scope-switcher__label",
272
+ children: label
273
+ }),
274
+ identity.tag && /*#__PURE__*/ jsx("span", {
275
+ className: "ov-scope-switcher__tag",
276
+ children: identity.tag
277
+ })
278
+ ]
279
+ });
280
+ return /*#__PURE__*/ jsxs("div", {
281
+ ref: root,
282
+ role: "group",
283
+ className: "ov-scope-switcher__level",
284
+ onBlur: (event)=>{
285
+ if (open && event.relatedTarget instanceof Node && !event.currentTarget.contains(event.relatedTarget)) changeVisible(false);
286
+ },
287
+ children: [
288
+ void 0 === selectable ? /*#__PURE__*/ jsx("span", {
289
+ className: "ov-scope-switcher__trigger",
290
+ "aria-label": identity.ariaLabel,
291
+ title: label,
292
+ children: content
293
+ }) : /*#__PURE__*/ jsxs("button", {
294
+ ref: trigger,
295
+ type: "button",
296
+ className: "ov-scope-switcher__trigger",
297
+ "aria-label": identity.ariaLabel,
298
+ title: label,
299
+ disabled: state?.disabled,
300
+ "aria-expanded": open,
301
+ "aria-haspopup": "dialog",
302
+ "aria-controls": open ? panelId : void 0,
303
+ onClick: ()=>changeVisible(!open),
304
+ onKeyDown: (event)=>{
305
+ if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
306
+ event.preventDefault();
307
+ if (open) root.current?.querySelector('[role="option"]:not([aria-disabled="true"])')?.focus();
308
+ else changeVisible(true);
309
+ }
310
+ },
311
+ children: [
312
+ content,
313
+ /*#__PURE__*/ jsx("span", {
314
+ className: "ov-scope-switcher__arrow",
315
+ "aria-hidden": "true",
316
+ children: /*#__PURE__*/ jsx(chevron_downreact, {})
317
+ })
318
+ ]
319
+ }),
320
+ open && void 0 !== selectable && void 0 !== data && /*#__PURE__*/ jsx("div", {
321
+ id: panelId,
322
+ className: slots?.renderPanel ? 'ov-scope-switcher__panel ov-scope-switcher__panel--custom' : 'ov-scope-switcher__panel',
323
+ role: "dialog",
324
+ "aria-label": identity.ariaLabel ?? label,
325
+ children: /*#__PURE__*/ jsx(ScopePanel, {
326
+ label: identity.ariaLabel ?? label,
327
+ data: data,
328
+ state: state,
329
+ slots: slots,
330
+ actions: actions,
331
+ onSelect: (option)=>{
332
+ restoreSelectionFocus.current = true;
333
+ changeVisible(false);
334
+ actions?.onSelect?.(option);
335
+ },
336
+ labels: labels
337
+ })
338
+ })
339
+ ]
340
+ });
341
+ }
342
+ function ScopeSwitcher({ locale: localeProp, children, className = '', ...props }) {
343
+ const locale = useLocale(localeProp);
344
+ return /*#__PURE__*/ jsx(LocaleProvider, {
345
+ locale: locale,
346
+ children: /*#__PURE__*/ jsx("div", {
347
+ lang: locale,
348
+ ...props,
349
+ className: `ov-scope-switcher ${className}`,
350
+ children: children
351
+ })
352
+ });
353
+ }
354
+ export { ScopeSelector, ScopeSwitcher };