@openviking/react 0.1.1 → 0.1.2
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.
- package/README.md +18 -15
- package/dist/3~0.js +2113 -4
- package/dist/ark-message-list-view~0.js +310 -0
- package/dist/c7~0.js +24 -0
- package/dist/components/agent-connect/agent-connect-copy.d.ts +34 -0
- package/dist/components/agent-connect/agent-connect-design.d.ts +1781 -0
- package/dist/components/agent-connect/agent-connect-detail.d.ts +13 -0
- package/dist/components/agent-connect/agent-connect-installer.d.ts +3 -0
- package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +14 -0
- package/dist/components/agent-connect/agent-connect-instructions.d.ts +145 -0
- package/dist/components/agent-connect/agent-connect-markdown.d.ts +3 -0
- package/dist/components/agent-connect/agent-connect.d.ts +3 -3
- package/dist/components/agent-connect/content-en.d.ts +137 -0
- package/dist/components/agent-connect/content-zh.d.ts +137 -0
- package/dist/components/agent-connect/style.css +495 -6
- package/dist/components/agent-connect/types.d.ts +20 -166
- package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
- package/dist/components/file-preview/file-preview-body.d.ts +24 -12
- package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +16 -0
- package/dist/components/file-preview/file-preview-breadcrumb.d.ts +21 -0
- package/dist/components/file-preview/file-preview-copy-path.d.ts +12 -0
- package/dist/components/file-preview/file-preview-editor.d.ts +22 -0
- package/dist/components/file-preview/file-preview-handle-adapters.d.ts +26 -0
- package/dist/components/file-preview/file-preview-header.d.ts +23 -14
- package/dist/components/file-preview/file-preview-labels.d.ts +15 -4
- package/dist/components/file-preview/file-preview-lazy-viewer.d.ts +3 -0
- package/dist/components/file-preview/file-preview-path.d.ts +30 -0
- package/dist/components/file-preview/file-preview-source.d.ts +24 -0
- package/dist/components/file-preview/file-preview-state.d.ts +28 -0
- package/dist/components/file-preview/file-preview-tab-row.d.ts +16 -0
- package/dist/components/file-preview/file-preview-viewer.d.ts +31 -0
- package/dist/components/file-preview/file-preview.d.ts +8 -11
- package/dist/components/file-preview/style.css +3984 -128
- package/dist/components/file-preview/types.d.ts +250 -169
- package/dist/components/file-preview/use-file-preview-actions-context.d.ts +23 -0
- package/dist/components/file-preview/use-file-preview-actions.d.ts +19 -0
- package/dist/components/file-preview/use-file-preview-editing.d.ts +21 -2
- package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
- package/dist/components/file-preview.js +1 -442
- package/dist/components/file-tree/file-tree-body.d.ts +8 -4
- package/dist/components/file-tree/file-tree-entry-row.d.ts +9 -3
- package/dist/components/file-tree/file-tree-icons.d.ts +12 -5
- package/dist/components/file-tree/file-tree-info-labels.d.ts +21 -0
- package/dist/components/file-tree/file-tree-info-tooltip.d.ts +43 -0
- package/dist/components/file-tree/file-tree-info.d.ts +29 -0
- package/dist/components/file-tree/file-tree-keyboard.d.ts +8 -4
- package/dist/components/file-tree/file-tree-row-context.d.ts +31 -9
- package/dist/components/file-tree/file-tree-row-shared.d.ts +11 -0
- package/dist/components/file-tree/file-tree-spinner.d.ts +10 -0
- package/dist/components/file-tree/file-tree-state-row.d.ts +7 -0
- package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +22 -0
- package/dist/components/file-tree/file-tree-tooltip.d.ts +9 -3
- package/dist/components/file-tree/file-tree.d.ts +12 -1
- package/dist/components/file-tree/style.css +225 -57
- package/dist/components/file-tree/types.d.ts +183 -0
- package/dist/components/file-tree/use-file-tree-actions.d.ts +7 -0
- package/dist/components/file-tree.js +1 -1
- package/dist/components/scope-switcher/scope-panel.d.ts +9 -3
- package/dist/components/scope-switcher/scope-selector.d.ts +1 -1
- package/dist/components/scope-switcher/scope-switcher.d.ts +1 -1
- package/dist/components/scope-switcher/style.css +282 -76
- package/dist/components/scope-switcher/types.d.ts +230 -108
- package/dist/components/style.css +13845 -372
- package/dist/components/tui/command-catalog.d.ts +58 -0
- package/dist/components/tui/command-completion.d.ts +19 -0
- package/dist/components/tui/command-definitions.d.ts +10 -0
- package/dist/components/tui/command-input.d.ts +16 -0
- package/dist/components/tui/style.css +1543 -5
- package/dist/components/tui/tui-assist.d.ts +15 -0
- package/dist/components/tui/tui-code-block.d.ts +8 -0
- package/dist/components/tui/tui-command-help.d.ts +9 -0
- package/dist/components/tui/tui-command-text.d.ts +6 -0
- package/dist/components/tui/tui-composer.d.ts +24 -0
- package/dist/components/tui/tui-copy-button.d.ts +9 -0
- package/dist/components/tui/tui-input-mirror.d.ts +14 -0
- package/dist/components/tui/tui-labels-zh.d.ts +2 -0
- package/dist/components/tui/tui-labels.d.ts +5 -0
- package/dist/components/tui/tui-markdown-renderers.d.ts +10 -0
- package/dist/components/tui/tui-markdown.d.ts +6 -0
- package/dist/components/tui/tui-param-hint.d.ts +7 -0
- package/dist/components/tui/tui-record-time.d.ts +11 -0
- package/dist/components/tui/tui-record.d.ts +13 -0
- package/dist/components/tui/tui-resource-preview.d.ts +10 -0
- package/dist/components/tui/tui-resource-tree.d.ts +10 -0
- package/dist/components/tui/tui-result-header.d.ts +7 -0
- package/dist/components/tui/tui-result-text.d.ts +5 -0
- package/dist/components/tui/tui-search-list.d.ts +8 -0
- package/dist/components/tui/tui-skeleton.d.ts +6 -0
- package/dist/components/tui/tui-status-card.d.ts +7 -0
- package/dist/components/tui/tui-text.d.ts +10 -0
- package/dist/components/tui/tui-uri-text.d.ts +19 -0
- package/dist/components/tui/tui-write-result.d.ts +7 -0
- package/dist/components/tui/tui.d.ts +10 -2
- package/dist/components/tui/types.d.ts +57 -15
- package/dist/components/tui/use-tui-assist-position.d.ts +3 -0
- package/dist/components/tui/use-tui-completion.d.ts +14 -0
- package/dist/components/tui/use-tui-composer-keyboard.d.ts +25 -0
- package/dist/components/viking-bot/ark-adapter.d.ts +45 -0
- package/dist/components/viking-bot/ark-message-body.d.ts +16 -0
- package/dist/components/viking-bot/ark-message-list-view.d.ts +7 -0
- package/dist/components/viking-bot/ark-message-row.d.ts +19 -0
- package/dist/components/viking-bot/index.d.ts +10 -0
- package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +10 -0
- package/dist/components/viking-bot/interaction/index.d.ts +4 -0
- package/dist/components/viking-bot/interaction/labels.d.ts +7 -0
- package/dist/components/viking-bot/interaction/lazy-interaction.d.ts +3 -0
- package/dist/components/viking-bot/interaction/schedule-input.d.ts +13 -0
- package/dist/components/viking-bot/interaction/style.css +189 -0
- package/dist/components/viking-bot/interaction/types.d.ts +188 -0
- package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +9 -0
- package/dist/components/viking-bot/interaction.js +2 -0
- package/dist/components/viking-bot/labels.d.ts +2 -0
- package/dist/components/viking-bot/lazy-composer.d.ts +3 -0
- package/dist/components/viking-bot/message-groups.d.ts +12 -0
- package/dist/components/viking-bot/model.d.ts +252 -0
- package/dist/components/viking-bot/render-part.d.ts +12 -0
- package/dist/components/viking-bot/style.css +7135 -0
- package/dist/components/viking-bot/style.js +0 -0
- package/dist/components/viking-bot/types.d.ts +140 -0
- package/dist/components/viking-bot/viking-bot-composer.d.ts +6 -0
- package/dist/components/viking-bot/viking-bot-message-list.d.ts +3 -0
- package/dist/components/viking-bot/viking-bot.d.ts +16 -0
- package/dist/components/viking-bot.js +4 -0
- package/dist/c~0.js +201 -0
- package/dist/file-preview-viewer~0.js +191 -0
- package/dist/f~0.js +149 -77
- package/dist/g~0.js +1207 -0
- package/dist/h~0.js +58 -0
- package/dist/icons/file-type-icon.d.ts +31 -0
- package/dist/icons/index.d.ts +33 -23
- package/dist/icons/nextjs-icon.d.ts +19 -0
- package/dist/icons.js +1 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/k~0.js +1440 -0
- package/dist/lk~0.js +25 -12
- package/dist/modules/console/style.css +83 -1
- package/dist/modules/file-browser/style.css +89 -6
- package/dist/modules/scope-cascade/style.css +282 -76
- package/dist/modules/style.css +533 -110
- package/dist/n~0.js +434 -206
- package/dist/shared/components/tooltip/index.d.ts +1 -0
- package/dist/shared/components/tooltip/tooltip.d.ts +25 -0
- package/dist/shared/components/tooltip/types.d.ts +42 -0
- package/dist/shared/components/tooltip/use-tooltip-position.d.ts +38 -0
- package/dist/style.css +14451 -474
- package/dist/u~0.js +1597 -4
- package/dist/viking-bot-composer~0.js +164 -0
- package/dist/viking-bot-interaction~0.js +284 -0
- package/dist/w~0.js +19 -0
- package/package.json +18 -10
- package/dist/components/file-preview/file-preview-icons.d.ts +0 -2
- package/dist/components/file-preview/file-preview-operations.d.ts +0 -1
- package/dist/components/file-tree/file-tree-dom.d.ts +0 -4
- package/dist/components/file-tree/file-tree-labels.d.ts +0 -5
- package/dist/components/file-tree/file-tree-rows.d.ts +0 -12
- package/dist/i~0.js +0 -21
- package/dist/modules/task-center/columns.d.ts +0 -129
- package/dist/modules/task-center/index.d.ts +0 -1
- package/dist/modules/task-center/style.css +0 -29
- package/dist/modules/task-center/task-center.d.ts +0 -4
- package/dist/modules/task-center/types.d.ts +0 -168
- package/dist/modules/task-center.js +0 -1
- /package/dist/{modules/task-center → components/viking-bot/interaction}/style.js +0 -0
package/dist/f~0.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
3
|
-
const
|
|
3
|
+
const SvgChevronDown = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: 14,
|
|
6
|
+
height: 14,
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 14 14",
|
|
9
|
+
...props,
|
|
10
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
11
|
+
fill: "currentColor",
|
|
12
|
+
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"
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const chevron_downreact = SvgChevronDown;
|
|
4
16
|
function moveScopeFocus(event) {
|
|
5
17
|
if (![
|
|
6
18
|
'ArrowDown',
|
|
@@ -18,61 +30,118 @@ function moveScopeFocus(event) {
|
|
|
18
30
|
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;
|
|
19
31
|
options[next]?.focus();
|
|
20
32
|
}
|
|
21
|
-
const
|
|
33
|
+
const SvgCheck = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
34
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
35
|
+
width: 16,
|
|
36
|
+
height: 16,
|
|
37
|
+
fill: "none",
|
|
38
|
+
viewBox: "0 0 16 16",
|
|
39
|
+
...props,
|
|
40
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
41
|
+
stroke: "currentColor",
|
|
42
|
+
strokeLinecap: "round",
|
|
43
|
+
strokeLinejoin: "round",
|
|
44
|
+
strokeWidth: 1.2,
|
|
45
|
+
d: "M13.333 4 6 11.333 2.667 8"
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
const checkreact = SvgCheck;
|
|
49
|
+
const SvgSearch = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
50
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
51
|
+
width: 16,
|
|
52
|
+
height: 16,
|
|
53
|
+
fill: "none",
|
|
54
|
+
viewBox: "0 0 16 16",
|
|
55
|
+
...props,
|
|
56
|
+
children: /*#__PURE__*/ jsxs("g", {
|
|
57
|
+
stroke: "currentColor",
|
|
58
|
+
strokeWidth: 1.2,
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ jsx("circle", {
|
|
61
|
+
cx: 7.167,
|
|
62
|
+
cy: 7.167,
|
|
63
|
+
r: 4.667
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx("path", {
|
|
66
|
+
strokeLinecap: "round",
|
|
67
|
+
d: "m10.667 10.667 3 3"
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
const searchreact = SvgSearch;
|
|
22
73
|
function Highlight({ text, keyword }) {
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
74
|
+
const needle = keyword.trim().toLocaleLowerCase();
|
|
75
|
+
if (!needle) return /*#__PURE__*/ jsx(Fragment, {
|
|
25
76
|
children: text
|
|
26
77
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
78
|
+
const haystack = text.toLocaleLowerCase();
|
|
79
|
+
const parts = [];
|
|
80
|
+
let cursor = 0;
|
|
81
|
+
let hit = haystack.indexOf(needle);
|
|
82
|
+
while(hit >= 0){
|
|
83
|
+
if (hit > cursor) parts.push(text.slice(cursor, hit));
|
|
84
|
+
const end = hit + needle.length;
|
|
85
|
+
parts.push(/*#__PURE__*/ jsx("mark", {
|
|
86
|
+
children: text.slice(hit, end)
|
|
87
|
+
}, `${hit}-${end}`));
|
|
88
|
+
cursor = end;
|
|
89
|
+
hit = haystack.indexOf(needle, cursor);
|
|
90
|
+
}
|
|
91
|
+
if (cursor < text.length) parts.push(text.slice(cursor));
|
|
92
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
93
|
+
children: parts
|
|
35
94
|
});
|
|
36
95
|
}
|
|
37
|
-
function ScopePanel({
|
|
96
|
+
function ScopePanel({ label, data, state, slots, actions, onSelect, labels }) {
|
|
38
97
|
const focusPanel = useCallback((node)=>{
|
|
39
98
|
const target = node?.querySelector('input') ?? node?.querySelector('[role="option"][aria-selected="true"]:not([aria-disabled="true"])') ?? node?.querySelector('[role="option"]:not([aria-disabled="true"])');
|
|
40
99
|
(target ?? node)?.focus();
|
|
41
100
|
}, []);
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
101
|
+
const options = data.visibleOptions ?? data.options;
|
|
102
|
+
const keyword = state?.searchKeyword ?? '';
|
|
103
|
+
const hasKeyword = keyword.trim().length > 0;
|
|
104
|
+
const searchVisible = actions?.onSearchKeywordChange && (hasKeyword || Math.max(options.length, data.options.length, data.total ?? 0) > 10);
|
|
105
|
+
const search = searchVisible ? /*#__PURE__*/ jsxs("div", {
|
|
106
|
+
className: "ov-scope-switcher__search-field",
|
|
107
|
+
children: [
|
|
108
|
+
/*#__PURE__*/ jsx(searchreact, {
|
|
109
|
+
className: "ov-scope-switcher__search-icon"
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ jsx("input", {
|
|
112
|
+
type: "search",
|
|
113
|
+
className: "ov-scope-switcher__search",
|
|
114
|
+
value: keyword,
|
|
115
|
+
"aria-label": labels?.searchPlaceholder ?? 'Search',
|
|
116
|
+
placeholder: labels?.searchPlaceholder ?? 'Search',
|
|
117
|
+
onChange: (event)=>actions?.onSearchKeywordChange?.(event.currentTarget.value)
|
|
118
|
+
})
|
|
119
|
+
]
|
|
51
120
|
}) : null;
|
|
52
121
|
let list;
|
|
53
|
-
list =
|
|
122
|
+
list = state?.loading ? /*#__PURE__*/ jsx("div", {
|
|
54
123
|
className: "ov-scope-switcher__state",
|
|
55
124
|
role: "status",
|
|
56
125
|
children: labels?.loading ?? 'Loading…'
|
|
57
|
-
}) :
|
|
126
|
+
}) : state?.error ? /*#__PURE__*/ jsx("div", {
|
|
58
127
|
className: "ov-scope-switcher__state",
|
|
59
128
|
role: "alert",
|
|
60
|
-
children:
|
|
61
|
-
}) :
|
|
129
|
+
children: slots?.errorFallback ?? labels?.error ?? 'Unable to load options'
|
|
130
|
+
}) : options.length ? /*#__PURE__*/ jsx("div", {
|
|
62
131
|
className: "ov-scope-switcher__list",
|
|
63
132
|
role: "listbox",
|
|
64
|
-
"aria-label":
|
|
65
|
-
"aria-busy":
|
|
133
|
+
"aria-label": label,
|
|
134
|
+
"aria-busy": state?.busy,
|
|
66
135
|
onScroll: (event)=>{
|
|
67
136
|
const { scrollTop, scrollHeight, clientHeight } = event.currentTarget;
|
|
68
|
-
|
|
137
|
+
actions?.onScroll?.({
|
|
69
138
|
scrollTop,
|
|
70
139
|
scrollHeight,
|
|
71
140
|
clientHeight
|
|
72
141
|
});
|
|
73
142
|
},
|
|
74
|
-
children:
|
|
75
|
-
const selected = option.id ===
|
|
143
|
+
children: options.map((option)=>{
|
|
144
|
+
const selected = option.id === data.selectedId;
|
|
76
145
|
const content = /*#__PURE__*/ jsxs(Fragment, {
|
|
77
146
|
children: [
|
|
78
147
|
option.icon && /*#__PURE__*/ jsx("span", {
|
|
@@ -97,51 +166,48 @@ function ScopePanel({ level, labels }) {
|
|
|
97
166
|
selected && /*#__PURE__*/ jsx("span", {
|
|
98
167
|
className: "ov-scope-switcher__check",
|
|
99
168
|
"aria-hidden": "true",
|
|
100
|
-
children: /*#__PURE__*/ jsx(
|
|
101
|
-
src: checkinline_namespaceObject,
|
|
102
|
-
alt: "",
|
|
103
|
-
width: 16,
|
|
104
|
-
height: 16
|
|
105
|
-
})
|
|
169
|
+
children: /*#__PURE__*/ jsx(checkreact, {})
|
|
106
170
|
})
|
|
107
171
|
]
|
|
108
172
|
});
|
|
109
173
|
return /*#__PURE__*/ jsx("div", {
|
|
110
|
-
tabIndex: option.disabled ||
|
|
174
|
+
tabIndex: option.disabled || state?.busy ? -1 : 0,
|
|
111
175
|
role: "option",
|
|
112
176
|
"aria-selected": selected,
|
|
113
177
|
className: "ov-scope-switcher__option",
|
|
114
178
|
title: option.label,
|
|
115
|
-
"aria-disabled": option.disabled ||
|
|
179
|
+
"aria-disabled": option.disabled || state?.busy || void 0,
|
|
116
180
|
onClick: (event)=>{
|
|
117
181
|
const target = event.target;
|
|
118
|
-
if (option.disabled ||
|
|
119
|
-
|
|
182
|
+
if (option.disabled || state?.busy || target.closest('button, a, input, select, textarea, [role="button"]')) return;
|
|
183
|
+
onSelect(option);
|
|
120
184
|
},
|
|
121
185
|
onKeyDown: (event)=>{
|
|
122
|
-
if (event.target !== event.currentTarget || option.disabled ||
|
|
186
|
+
if (event.target !== event.currentTarget || option.disabled || state?.busy) return;
|
|
123
187
|
if ('Enter' === event.key || ' ' === event.key) {
|
|
124
188
|
event.preventDefault();
|
|
125
|
-
|
|
189
|
+
onSelect(option);
|
|
126
190
|
}
|
|
127
191
|
},
|
|
128
|
-
children:
|
|
192
|
+
children: slots?.renderOption ? slots?.renderOption(content, option) : content
|
|
129
193
|
}, option.id);
|
|
130
194
|
})
|
|
131
195
|
}, keyword) : /*#__PURE__*/ jsx("div", {
|
|
132
196
|
className: "ov-scope-switcher__state",
|
|
133
197
|
role: "status",
|
|
134
|
-
children:
|
|
198
|
+
children: slots?.emptyFallback ?? (hasKeyword ? labels?.noMatch ?? labels?.empty ?? 'No matches' : labels?.empty ?? 'No options')
|
|
135
199
|
});
|
|
136
200
|
return /*#__PURE__*/ jsx("div", {
|
|
137
201
|
role: "group",
|
|
138
202
|
tabIndex: -1,
|
|
139
203
|
ref: focusPanel,
|
|
204
|
+
className: "ov-scope-switcher__panel-inner",
|
|
140
205
|
onKeyDownCapture: moveScopeFocus,
|
|
141
|
-
children:
|
|
206
|
+
children: slots?.renderPanel ? slots?.renderPanel({
|
|
142
207
|
search,
|
|
143
208
|
list
|
|
144
|
-
}) : /*#__PURE__*/ jsxs(
|
|
209
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
210
|
+
className: "ov-scope-switcher__panel-body",
|
|
145
211
|
children: [
|
|
146
212
|
search,
|
|
147
213
|
list
|
|
@@ -149,14 +215,20 @@ function ScopePanel({ level, labels }) {
|
|
|
149
215
|
})
|
|
150
216
|
});
|
|
151
217
|
}
|
|
152
|
-
function ScopeSelector(
|
|
218
|
+
function ScopeSelector(props) {
|
|
219
|
+
const { identity, trigger: triggerContent, labels } = props;
|
|
220
|
+
const selectable = 'selectable' === props.kind ? props : void 0;
|
|
221
|
+
const data = selectable?.data;
|
|
222
|
+
const state = selectable?.state;
|
|
223
|
+
const actions = selectable?.actions;
|
|
224
|
+
const slots = selectable?.slots;
|
|
153
225
|
const [localVisible, setLocalVisible] = useState(false);
|
|
154
226
|
const root = useRef(null);
|
|
155
227
|
const trigger = useRef(null);
|
|
156
228
|
const restoreSelectionFocus = useRef(false);
|
|
157
229
|
const panelId = useId();
|
|
158
|
-
const open =
|
|
159
|
-
const onVisibleChange =
|
|
230
|
+
const open = void 0 !== selectable && (state?.visible ?? localVisible) && !state?.disabled;
|
|
231
|
+
const onVisibleChange = actions?.onVisibleChange;
|
|
160
232
|
const changeVisible = useCallback((visible)=>{
|
|
161
233
|
setLocalVisible(visible);
|
|
162
234
|
onVisibleChange?.(visible);
|
|
@@ -192,20 +264,23 @@ function ScopeSelector({ level, labels }) {
|
|
|
192
264
|
}, [
|
|
193
265
|
open
|
|
194
266
|
]);
|
|
267
|
+
const selected = data?.options.find((o)=>o.id === data.selectedId);
|
|
268
|
+
const label = triggerContent?.label ?? selected?.label ?? '';
|
|
269
|
+
const icon = triggerContent?.icon ?? selected?.icon;
|
|
195
270
|
const content = /*#__PURE__*/ jsxs(Fragment, {
|
|
196
271
|
children: [
|
|
197
|
-
|
|
272
|
+
icon && /*#__PURE__*/ jsx("span", {
|
|
198
273
|
className: "ov-scope-switcher__icon",
|
|
199
274
|
"aria-hidden": "true",
|
|
200
|
-
children:
|
|
275
|
+
children: icon
|
|
201
276
|
}),
|
|
202
277
|
/*#__PURE__*/ jsx("span", {
|
|
203
278
|
className: "ov-scope-switcher__label",
|
|
204
|
-
children:
|
|
279
|
+
children: label
|
|
205
280
|
}),
|
|
206
|
-
|
|
281
|
+
identity.tag && /*#__PURE__*/ jsx("span", {
|
|
207
282
|
className: "ov-scope-switcher__tag",
|
|
208
|
-
children:
|
|
283
|
+
children: identity.tag
|
|
209
284
|
})
|
|
210
285
|
]
|
|
211
286
|
});
|
|
@@ -217,18 +292,18 @@ function ScopeSelector({ level, labels }) {
|
|
|
217
292
|
if (open && event.relatedTarget instanceof Node && !event.currentTarget.contains(event.relatedTarget)) changeVisible(false);
|
|
218
293
|
},
|
|
219
294
|
children: [
|
|
220
|
-
|
|
295
|
+
void 0 === selectable ? /*#__PURE__*/ jsx("span", {
|
|
221
296
|
className: "ov-scope-switcher__trigger",
|
|
222
|
-
"aria-label":
|
|
223
|
-
title:
|
|
297
|
+
"aria-label": identity.ariaLabel,
|
|
298
|
+
title: label,
|
|
224
299
|
children: content
|
|
225
300
|
}) : /*#__PURE__*/ jsxs("button", {
|
|
226
301
|
ref: trigger,
|
|
227
302
|
type: "button",
|
|
228
303
|
className: "ov-scope-switcher__trigger",
|
|
229
|
-
"aria-label":
|
|
230
|
-
title:
|
|
231
|
-
disabled:
|
|
304
|
+
"aria-label": identity.ariaLabel,
|
|
305
|
+
title: label,
|
|
306
|
+
disabled: state?.disabled,
|
|
232
307
|
"aria-expanded": open,
|
|
233
308
|
"aria-haspopup": "dialog",
|
|
234
309
|
"aria-controls": open ? panelId : void 0,
|
|
@@ -245,28 +320,25 @@ function ScopeSelector({ level, labels }) {
|
|
|
245
320
|
/*#__PURE__*/ jsx("span", {
|
|
246
321
|
className: "ov-scope-switcher__arrow",
|
|
247
322
|
"aria-hidden": "true",
|
|
248
|
-
children: /*#__PURE__*/ jsx(
|
|
249
|
-
src: chevron_downinline_namespaceObject,
|
|
250
|
-
alt: "",
|
|
251
|
-
width: 14,
|
|
252
|
-
height: 14
|
|
253
|
-
})
|
|
323
|
+
children: /*#__PURE__*/ jsx(chevron_downreact, {})
|
|
254
324
|
})
|
|
255
325
|
]
|
|
256
326
|
}),
|
|
257
|
-
open &&
|
|
327
|
+
open && void 0 !== selectable && void 0 !== data && /*#__PURE__*/ jsx("div", {
|
|
258
328
|
id: panelId,
|
|
259
|
-
className:
|
|
329
|
+
className: slots?.renderPanel ? 'ov-scope-switcher__panel ov-scope-switcher__panel--custom' : 'ov-scope-switcher__panel',
|
|
260
330
|
role: "dialog",
|
|
261
|
-
"aria-label":
|
|
331
|
+
"aria-label": identity.ariaLabel ?? label,
|
|
262
332
|
children: /*#__PURE__*/ jsx(ScopePanel, {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
333
|
+
label: identity.ariaLabel ?? label,
|
|
334
|
+
data: data,
|
|
335
|
+
state: state,
|
|
336
|
+
slots: slots,
|
|
337
|
+
actions: actions,
|
|
338
|
+
onSelect: (option)=>{
|
|
339
|
+
restoreSelectionFocus.current = true;
|
|
340
|
+
changeVisible(false);
|
|
341
|
+
actions?.onSelect?.(option);
|
|
270
342
|
},
|
|
271
343
|
labels: labels
|
|
272
344
|
})
|