@openviking/react 0.1.0 → 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 +57 -34
- package/dist/3~0.js +2117 -0
- package/dist/ark-message-list-view~0.js +310 -0
- package/dist/a~0.js +21 -0
- package/dist/c7~0.js +24 -0
- package/dist/client/client.d.ts +12 -0
- package/dist/client/errors.d.ts +30 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/options.d.ts +101 -0
- package/dist/client/provider.d.ts +52 -0
- package/dist/client/types.d.ts +160 -0
- package/dist/client.js +239 -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 +4 -1
- 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/index.d.ts +1 -0
- package/dist/components/agent-connect/style.css +503 -0
- package/dist/components/agent-connect/types.d.ts +29 -0
- package/dist/components/agent-connect.js +1 -0
- package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
- package/dist/components/file-preview/file-preview-body.d.ts +27 -0
- 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 +25 -0
- package/dist/components/file-preview/file-preview-labels.d.ts +16 -0
- 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 +14 -1
- package/dist/components/file-preview/index.d.ts +1 -0
- package/dist/components/file-preview/style.css +4139 -0
- package/dist/components/file-preview/types.d.ts +516 -0
- 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 +32 -0
- package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
- package/dist/components/file-preview.js +1 -0
- package/dist/components/file-tree/file-tree-body.d.ts +18 -0
- package/dist/components/file-tree/file-tree-entry-row.d.ts +12 -0
- package/dist/components/file-tree/file-tree-icons.d.ts +15 -0
- 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 +14 -0
- package/dist/components/file-tree/file-tree-row-context.d.ts +46 -0
- 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 +17 -0
- package/dist/components/file-tree/file-tree.d.ts +15 -1
- package/dist/components/file-tree/index.d.ts +1 -0
- package/dist/components/file-tree/style.css +410 -0
- package/dist/components/file-tree/types.d.ts +589 -0
- package/dist/components/file-tree/use-file-tree-actions.d.ts +17 -0
- package/dist/components/file-tree.js +1 -0
- package/dist/components/scope-switcher/index.d.ts +1 -0
- package/dist/components/scope-switcher/scope-keyboard.d.ts +2 -0
- package/dist/components/scope-switcher/scope-panel.d.ts +11 -0
- package/dist/components/scope-switcher/scope-selector.d.ts +2 -0
- package/dist/components/scope-switcher/scope-switcher.d.ts +6 -1
- package/dist/components/scope-switcher/style.css +452 -0
- package/dist/components/scope-switcher/types.d.ts +489 -0
- package/dist/components/scope-switcher.js +3 -0
- package/dist/components/style.css +14249 -18
- 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/index.d.ts +1 -0
- package/dist/components/tui/style.css +1552 -0
- 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 +11 -1
- package/dist/components/tui/types.d.ts +527 -0
- 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/tui.js +1 -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 +7133 -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 -1
- 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 +356 -0
- 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 +16 -2
- package/dist/index.js +8 -1
- package/dist/k~0.js +1440 -0
- package/dist/lk~0.js +233 -0
- package/dist/l~0.js +44 -0
- package/dist/modules/console/console.d.ts +4 -0
- package/dist/modules/console/index.d.ts +1 -0
- package/dist/modules/console/style.css +111 -0
- package/dist/modules/console/types.d.ts +101 -0
- package/dist/modules/console.js +1 -0
- package/dist/modules/file-browser/file-browser-toolbar-button.d.ts +10 -0
- package/dist/modules/file-browser/file-browser.d.ts +6 -0
- package/dist/modules/file-browser/index.d.ts +1 -0
- package/dist/modules/file-browser/style.css +158 -0
- package/dist/modules/file-browser/types.d.ts +101 -0
- package/dist/modules/file-browser.js +1 -0
- package/dist/modules/scope-cascade/controller.d.ts +6 -0
- package/dist/modules/scope-cascade/index.d.ts +3 -0
- package/dist/modules/scope-cascade/scope-cascade.d.ts +3 -0
- package/dist/modules/scope-cascade/style.css +456 -0
- package/dist/modules/scope-cascade/style.js +0 -0
- package/dist/modules/scope-cascade/types.d.ts +39 -0
- package/dist/modules/scope-cascade/use-scope-cascade.d.ts +5 -0
- package/dist/modules/scope-cascade.js +1 -0
- package/dist/modules/style.css +808 -0
- package/dist/modules/style.js +0 -0
- package/dist/n~0.js +727 -0
- 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 +15138 -18
- package/dist/u~0.js +1601 -0
- 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 +46 -22
- package/dist/components/resource-import/resource-import.d.ts +0 -1
- package/dist/components/resource-import/style.css +0 -2
- package/dist/components/status-badge/status-badge.d.ts +0 -8
- package/dist/components/status-badge/style.css +0 -37
- package/dist/components/status-badge.js +0 -30
- /package/dist/components/{resource-import → viking-bot/interaction}/style.js +0 -0
- /package/dist/{components/status-badge → modules/console}/style.js +0 -0
- /package/dist/{components/resource-import.js → modules/file-browser/style.js} +0 -0
package/dist/n~0.js
ADDED
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import { FolderOpenIcon, FolderIcon, ChevronRightIcon, DocumentIcon } from "./k~0.js";
|
|
4
|
+
function FileTreeFolderIcon({ open }) {
|
|
5
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
6
|
+
className: "ov-file-tree__folder",
|
|
7
|
+
children: [
|
|
8
|
+
/*#__PURE__*/ jsx(FolderIcon, {
|
|
9
|
+
className: "ov-file-tree__folder-layer",
|
|
10
|
+
"data-open": !open
|
|
11
|
+
}),
|
|
12
|
+
/*#__PURE__*/ jsx(FolderOpenIcon, {
|
|
13
|
+
className: "ov-file-tree__folder-layer",
|
|
14
|
+
"data-open": open
|
|
15
|
+
})
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function FileTreeFileIcon() {
|
|
20
|
+
return /*#__PURE__*/ jsx(DocumentIcon, {
|
|
21
|
+
className: "ov-file-tree__file-icon"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function FileTreeChevron({ open }) {
|
|
25
|
+
return /*#__PURE__*/ jsx(ChevronRightIcon, {
|
|
26
|
+
className: "ov-file-tree__chevron",
|
|
27
|
+
"data-expanded": open || void 0,
|
|
28
|
+
width: 12,
|
|
29
|
+
height: 12
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const TOOLTIP_ONLY_KEYS = new Set([
|
|
33
|
+
'profile',
|
|
34
|
+
'preferences',
|
|
35
|
+
'entities',
|
|
36
|
+
'events',
|
|
37
|
+
'identity',
|
|
38
|
+
'soul',
|
|
39
|
+
'cases',
|
|
40
|
+
'trajectories',
|
|
41
|
+
'experiences'
|
|
42
|
+
]);
|
|
43
|
+
const ROOT_KEY_BY_SEGMENT = {
|
|
44
|
+
agent: 'agentRoot',
|
|
45
|
+
agents: 'agentRoot',
|
|
46
|
+
memory: 'memoryRoot',
|
|
47
|
+
memories: 'memoryRoot',
|
|
48
|
+
resource: 'resourceRoot',
|
|
49
|
+
resources: 'resourceRoot',
|
|
50
|
+
session: 'sessionRoot',
|
|
51
|
+
sessions: 'sessionRoot',
|
|
52
|
+
system: 'systemRoot'
|
|
53
|
+
};
|
|
54
|
+
const USER_SCOPE_KEY_BY_SEGMENT = {
|
|
55
|
+
memories: 'memories',
|
|
56
|
+
peers: 'peers',
|
|
57
|
+
privacy: 'privacy',
|
|
58
|
+
resources: 'userResources',
|
|
59
|
+
sessions: 'sessions',
|
|
60
|
+
skills: 'skills'
|
|
61
|
+
};
|
|
62
|
+
const MEMORY_KEY_BY_SEGMENT = {
|
|
63
|
+
'profile.md': 'profile',
|
|
64
|
+
preferences: 'preferences',
|
|
65
|
+
entities: 'entities',
|
|
66
|
+
events: 'events',
|
|
67
|
+
'identity.md': 'identity',
|
|
68
|
+
'soul.md': 'soul',
|
|
69
|
+
cases: 'cases',
|
|
70
|
+
trajectories: 'trajectories',
|
|
71
|
+
experiences: 'experiences'
|
|
72
|
+
};
|
|
73
|
+
const USER_SEGMENTS = new Set([
|
|
74
|
+
'user',
|
|
75
|
+
'users'
|
|
76
|
+
]);
|
|
77
|
+
function splitVikingUri(uri) {
|
|
78
|
+
const withoutScheme = uri.replace(/^viking:\/*/i, '');
|
|
79
|
+
const withoutQuery = withoutScheme.split(/[?#]/)[0] ?? '';
|
|
80
|
+
return withoutQuery.split('/').map((segment)=>segment.trim()).filter(Boolean).map((segment)=>segment.toLowerCase());
|
|
81
|
+
}
|
|
82
|
+
function resolveFileTreeInfoKey(uri) {
|
|
83
|
+
const segments = splitVikingUri(uri);
|
|
84
|
+
const first = segments[0];
|
|
85
|
+
if (!first) return null;
|
|
86
|
+
if (USER_SEGMENTS.has(first)) {
|
|
87
|
+
if (segments.length <= 2) return 'userRoot';
|
|
88
|
+
const third = segments[2];
|
|
89
|
+
if (!third) return null;
|
|
90
|
+
if (3 === segments.length) return USER_SCOPE_KEY_BY_SEGMENT[third] ?? null;
|
|
91
|
+
if ('memories' !== third || 4 !== segments.length) return null;
|
|
92
|
+
const fourth = segments[3];
|
|
93
|
+
return fourth ? MEMORY_KEY_BY_SEGMENT[fourth] ?? null : null;
|
|
94
|
+
}
|
|
95
|
+
if (1 === segments.length) {
|
|
96
|
+
if ('resources' === first) return 'sharedResources';
|
|
97
|
+
return ROOT_KEY_BY_SEGMENT[first] ?? null;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function showsInlineDescription(key) {
|
|
102
|
+
return null !== key && !TOOLTIP_ONLY_KEYS.has(key);
|
|
103
|
+
}
|
|
104
|
+
const DESCRIPTION = {
|
|
105
|
+
userRoot: 'Context data for the current user',
|
|
106
|
+
memories: 'Long-term memory accumulated across sessions',
|
|
107
|
+
peers: 'Context isolated per application or workspace',
|
|
108
|
+
privacy: 'Keys and other sensitive configuration',
|
|
109
|
+
userResources: 'Private knowledge of this user',
|
|
110
|
+
sessions: 'Conversation and task execution records',
|
|
111
|
+
skills: 'Skills and tools available to the agent',
|
|
112
|
+
profile: 'User identity and background',
|
|
113
|
+
preferences: 'Personalized user preferences',
|
|
114
|
+
entities: 'People, projects, organizations and other entities',
|
|
115
|
+
events: 'Key events archived by date',
|
|
116
|
+
identity: 'Agent name and persona',
|
|
117
|
+
soul: 'Agent behaviour guidelines and boundaries',
|
|
118
|
+
cases: 'Interaction cases used to train experience',
|
|
119
|
+
trajectories: 'Reusable task execution trajectories',
|
|
120
|
+
experiences: 'Execution experience distilled automatically',
|
|
121
|
+
sharedResources: 'External resources the agent can reference',
|
|
122
|
+
agentRoot: 'Agent capabilities, tools and experience',
|
|
123
|
+
memoryRoot: 'Long-term memory and accumulated information',
|
|
124
|
+
resourceRoot: 'External knowledge the agent can reference',
|
|
125
|
+
sessionRoot: 'Raw session records of the user',
|
|
126
|
+
systemRoot: 'Built-in system resources'
|
|
127
|
+
};
|
|
128
|
+
const TRIGGER_BEHAVIOR = {
|
|
129
|
+
userRoot: 'Created from the current user identity; no manual setup needed',
|
|
130
|
+
memories: 'Committed sessions, explicit requests to remember, or continuous extraction from sessions',
|
|
131
|
+
peers: 'Created when connecting as a specific peer, isolating memory and material per peer_id',
|
|
132
|
+
userResources: 'Imported material, uploaded to this user’s private resource directory',
|
|
133
|
+
sessions: 'Created when a session calls OpenViking; messages, tool calls and archives are saved continuously',
|
|
134
|
+
skills: 'Created, installed or imported as a personal skill',
|
|
135
|
+
profile: 'A stable, explicit user background or working style appears in conversation',
|
|
136
|
+
preferences: 'The user explicitly states a specific preference, habit or style',
|
|
137
|
+
entities: 'A person, project or organization worth keeping appears in conversation',
|
|
138
|
+
events: 'An important decision, commitment, arrangement, progress or result appears in dialogue',
|
|
139
|
+
identity: 'Initialized on the first memory extraction run; later updated by write operations',
|
|
140
|
+
soul: 'Initialized on the first memory extraction run; later adjusted by write operations',
|
|
141
|
+
cases: 'A session with a clear task and an evaluable execution result is committed',
|
|
142
|
+
trajectories: 'A task containing decisions, tool calls or multi-step execution is committed',
|
|
143
|
+
experiences: 'Distilled from task cases and execution trajectories',
|
|
144
|
+
sharedResources: 'Imported material, uploaded to a shared resource space'
|
|
145
|
+
};
|
|
146
|
+
const DEFAULT_INFO_LABELS = {
|
|
147
|
+
description: DESCRIPTION,
|
|
148
|
+
triggerBehavior: TRIGGER_BEHAVIOR,
|
|
149
|
+
field: {
|
|
150
|
+
description: "Description",
|
|
151
|
+
triggerBehavior: 'Trigger',
|
|
152
|
+
path: 'Path'
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
function resolveInfoCopy(key, hostLabels) {
|
|
156
|
+
const description = hostLabels?.description?.[key] ?? DESCRIPTION[key] ?? void 0;
|
|
157
|
+
const triggerBehavior = hostLabels?.triggerBehavior?.[key] ?? TRIGGER_BEHAVIOR[key] ?? void 0;
|
|
158
|
+
return {
|
|
159
|
+
description: description || void 0,
|
|
160
|
+
triggerBehavior: triggerBehavior || void 0
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const DEFAULT_FIELDS = {
|
|
164
|
+
description: "Description",
|
|
165
|
+
triggerBehavior: 'Trigger',
|
|
166
|
+
path: 'Path'
|
|
167
|
+
};
|
|
168
|
+
function resolveFileTreeInfoCopy(row, infoLabels) {
|
|
169
|
+
const key = resolveFileTreeInfoKey(row.uri);
|
|
170
|
+
const builtIn = key ? resolveInfoCopy(key, infoLabels) : {};
|
|
171
|
+
const description = row.description ?? builtIn.description;
|
|
172
|
+
if (!description && !builtIn.triggerBehavior) return null;
|
|
173
|
+
return {
|
|
174
|
+
title: row.name,
|
|
175
|
+
description,
|
|
176
|
+
triggerBehavior: builtIn.triggerBehavior,
|
|
177
|
+
path: row.uri,
|
|
178
|
+
fields: {
|
|
179
|
+
...DEFAULT_FIELDS,
|
|
180
|
+
...infoLabels?.field
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function FileTreeInfoTooltip({ copy }) {
|
|
185
|
+
const { description, fields, path, title, triggerBehavior } = copy;
|
|
186
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
187
|
+
className: "ov-file-tree__info",
|
|
188
|
+
children: [
|
|
189
|
+
/*#__PURE__*/ jsx("span", {
|
|
190
|
+
className: "ov-file-tree__info-title",
|
|
191
|
+
children: title
|
|
192
|
+
}),
|
|
193
|
+
description ? /*#__PURE__*/ jsxs("span", {
|
|
194
|
+
className: "ov-file-tree__info-row",
|
|
195
|
+
children: [
|
|
196
|
+
/*#__PURE__*/ jsx("span", {
|
|
197
|
+
className: "ov-file-tree__info-label",
|
|
198
|
+
children: fields.description
|
|
199
|
+
}),
|
|
200
|
+
/*#__PURE__*/ jsx("span", {
|
|
201
|
+
className: "ov-file-tree__info-value",
|
|
202
|
+
children: description
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
}) : null,
|
|
206
|
+
triggerBehavior ? /*#__PURE__*/ jsxs("span", {
|
|
207
|
+
className: "ov-file-tree__info-row",
|
|
208
|
+
children: [
|
|
209
|
+
/*#__PURE__*/ jsx("span", {
|
|
210
|
+
className: "ov-file-tree__info-label",
|
|
211
|
+
children: fields.triggerBehavior
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ jsx("span", {
|
|
214
|
+
className: "ov-file-tree__info-value",
|
|
215
|
+
children: triggerBehavior
|
|
216
|
+
})
|
|
217
|
+
]
|
|
218
|
+
}) : null,
|
|
219
|
+
/*#__PURE__*/ jsxs("span", {
|
|
220
|
+
className: "ov-file-tree__info-row",
|
|
221
|
+
children: [
|
|
222
|
+
/*#__PURE__*/ jsx("span", {
|
|
223
|
+
className: "ov-file-tree__info-label",
|
|
224
|
+
children: fields.path
|
|
225
|
+
}),
|
|
226
|
+
/*#__PURE__*/ jsx("span", {
|
|
227
|
+
className: "ov-file-tree__info-path",
|
|
228
|
+
children: path
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function FileTreeTooltipSurface({ row, infoLabels, renderRowTooltip }) {
|
|
236
|
+
if (renderRowTooltip) {
|
|
237
|
+
const custom = renderRowTooltip(row);
|
|
238
|
+
if (null == custom || false === custom) return null;
|
|
239
|
+
return /*#__PURE__*/ jsx("span", {
|
|
240
|
+
role: "tooltip",
|
|
241
|
+
className: "ov-file-tree__tooltip",
|
|
242
|
+
children: custom
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const copy = resolveFileTreeInfoCopy(row, infoLabels);
|
|
246
|
+
if (!copy) return null;
|
|
247
|
+
return /*#__PURE__*/ jsx("span", {
|
|
248
|
+
role: "tooltip",
|
|
249
|
+
className: "ov-file-tree__tooltip",
|
|
250
|
+
children: /*#__PURE__*/ jsx(FileTreeInfoTooltip, {
|
|
251
|
+
copy: copy
|
|
252
|
+
})
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const INDENT = 20;
|
|
256
|
+
const CHEVRON_SIZE = 16;
|
|
257
|
+
function rowStyle(depth) {
|
|
258
|
+
return {
|
|
259
|
+
paddingLeft: 8 + depth * INDENT
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function Guides({ depth }) {
|
|
263
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
264
|
+
children: Array.from({
|
|
265
|
+
length: depth
|
|
266
|
+
}, (_, level)=>/*#__PURE__*/ jsx("span", {
|
|
267
|
+
"aria-hidden": "true",
|
|
268
|
+
className: "ov-file-tree__guide",
|
|
269
|
+
style: {
|
|
270
|
+
left: 8 + level * INDENT + CHEVRON_SIZE / 2
|
|
271
|
+
}
|
|
272
|
+
}, level))
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const FILE_TREE_ROW_ATTRIBUTE = 'data-file-tree-row-id';
|
|
276
|
+
function FileTreeRowView({ row, ctx }) {
|
|
277
|
+
const { text, selectedId, tooltipRowId, getRowAttributes, renderDashboard, renderRowTooltip, renderRowIcon, onSelect, onToggleExpand, onOpenRetentionSettings, onRowKeyDown, onRowEnter, onRowLeave } = ctx;
|
|
278
|
+
const isDirectory = 'directory' === row.type;
|
|
279
|
+
const canExpand = isDirectory && false !== row.hasChildren;
|
|
280
|
+
const isExpanded = Boolean(row.expanded);
|
|
281
|
+
const isSelected = selectedId === row.id;
|
|
282
|
+
const extra = getRowAttributes?.(row) ?? {};
|
|
283
|
+
const { className: extraClassName, style: extraStyle, ...extraAttributes } = extra;
|
|
284
|
+
const dashboard = renderDashboard?.(row) ?? null;
|
|
285
|
+
const infoKey = resolveFileTreeInfoKey(row.uri);
|
|
286
|
+
const description = row.description ?? (infoKey && showsInlineDescription(infoKey) ? resolveInfoCopy(infoKey, ctx.infoLabels).description : void 0);
|
|
287
|
+
const handleClick = (event)=>{
|
|
288
|
+
if (event.target.closest('[data-role="toggle"]')) return;
|
|
289
|
+
if (row.disabled) return;
|
|
290
|
+
onSelect?.(row);
|
|
291
|
+
};
|
|
292
|
+
const handleToggle = (event)=>{
|
|
293
|
+
event.stopPropagation();
|
|
294
|
+
onToggleExpand?.(row);
|
|
295
|
+
};
|
|
296
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
297
|
+
role: "treeitem",
|
|
298
|
+
tabIndex: 0,
|
|
299
|
+
"aria-level": row.depth + 1,
|
|
300
|
+
"aria-selected": isSelected,
|
|
301
|
+
"aria-expanded": canExpand ? isExpanded : void 0,
|
|
302
|
+
"aria-disabled": row.disabled || void 0,
|
|
303
|
+
...extraAttributes,
|
|
304
|
+
[FILE_TREE_ROW_ATTRIBUTE]: row.id,
|
|
305
|
+
className: [
|
|
306
|
+
'ov-file-tree__row',
|
|
307
|
+
extraClassName
|
|
308
|
+
].filter(Boolean).join(' '),
|
|
309
|
+
"data-selected": isSelected || void 0,
|
|
310
|
+
"data-disabled": row.disabled || void 0,
|
|
311
|
+
"data-kind": row.kind,
|
|
312
|
+
style: {
|
|
313
|
+
...rowStyle(row.depth),
|
|
314
|
+
...extraStyle
|
|
315
|
+
},
|
|
316
|
+
onClick: handleClick,
|
|
317
|
+
onKeyDown: (event)=>onRowKeyDown(event, row),
|
|
318
|
+
onMouseEnter: ()=>onRowEnter(row.id),
|
|
319
|
+
onMouseLeave: onRowLeave,
|
|
320
|
+
onFocus: ()=>onRowEnter(row.id),
|
|
321
|
+
onBlur: onRowLeave,
|
|
322
|
+
children: [
|
|
323
|
+
/*#__PURE__*/ jsx(Guides, {
|
|
324
|
+
depth: row.depth
|
|
325
|
+
}),
|
|
326
|
+
canExpand ? /*#__PURE__*/ jsx("button", {
|
|
327
|
+
type: "button",
|
|
328
|
+
"data-role": "toggle",
|
|
329
|
+
className: "ov-file-tree__toggle",
|
|
330
|
+
"aria-label": isExpanded ? text.collapse.replace('{name}', row.name) : text.expand.replace('{name}', row.name),
|
|
331
|
+
tabIndex: -1,
|
|
332
|
+
disabled: !onToggleExpand || row.disabled,
|
|
333
|
+
onClick: handleToggle,
|
|
334
|
+
children: row.busy ? ctx.renderSpinner?.() ?? /*#__PURE__*/ jsx("span", {
|
|
335
|
+
className: "ov-file-tree__spinner"
|
|
336
|
+
}) : /*#__PURE__*/ jsx(FileTreeChevron, {
|
|
337
|
+
open: isExpanded
|
|
338
|
+
})
|
|
339
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
340
|
+
"aria-hidden": "true",
|
|
341
|
+
className: "ov-file-tree__toggle-spacer"
|
|
342
|
+
}),
|
|
343
|
+
/*#__PURE__*/ jsx("span", {
|
|
344
|
+
className: "ov-file-tree__icon-slot",
|
|
345
|
+
children: isDirectory ? /*#__PURE__*/ jsx(FileTreeFolderIcon, {
|
|
346
|
+
open: isExpanded
|
|
347
|
+
}) : renderRowIcon?.(row) ?? /*#__PURE__*/ jsx(FileTreeFileIcon, {})
|
|
348
|
+
}),
|
|
349
|
+
/*#__PURE__*/ jsxs("span", {
|
|
350
|
+
className: "ov-file-tree__label-group",
|
|
351
|
+
children: [
|
|
352
|
+
/*#__PURE__*/ jsx("span", {
|
|
353
|
+
className: "ov-file-tree__label",
|
|
354
|
+
title: row.name,
|
|
355
|
+
children: row.name
|
|
356
|
+
}),
|
|
357
|
+
description ? /*#__PURE__*/ jsx("span", {
|
|
358
|
+
className: "ov-file-tree__description",
|
|
359
|
+
children: description
|
|
360
|
+
}) : null
|
|
361
|
+
]
|
|
362
|
+
}),
|
|
363
|
+
row.busy && !canExpand ? /*#__PURE__*/ jsx("span", {
|
|
364
|
+
className: "ov-file-tree__spinner"
|
|
365
|
+
}) : null,
|
|
366
|
+
row.expiresAt ? /*#__PURE__*/ jsx("span", {
|
|
367
|
+
className: "ov-file-tree__expiry",
|
|
368
|
+
children: onOpenRetentionSettings ? /*#__PURE__*/ jsx("button", {
|
|
369
|
+
type: "button",
|
|
370
|
+
className: "ov-file-tree__expiry-action",
|
|
371
|
+
onClick: (event)=>{
|
|
372
|
+
event.stopPropagation();
|
|
373
|
+
onOpenRetentionSettings(row.uri);
|
|
374
|
+
},
|
|
375
|
+
children: row.expiresAt
|
|
376
|
+
}) : row.expiresAt
|
|
377
|
+
}) : null,
|
|
378
|
+
row.levelLabel ? /*#__PURE__*/ jsx("span", {
|
|
379
|
+
className: "ov-file-tree__level",
|
|
380
|
+
children: row.levelLabel
|
|
381
|
+
}) : null,
|
|
382
|
+
dashboard ? /*#__PURE__*/ jsx("span", {
|
|
383
|
+
className: "ov-file-tree__dashboard",
|
|
384
|
+
children: dashboard
|
|
385
|
+
}) : null,
|
|
386
|
+
tooltipRowId === row.id ? /*#__PURE__*/ jsx(FileTreeTooltipSurface, {
|
|
387
|
+
row: row,
|
|
388
|
+
infoLabels: ctx.infoLabels,
|
|
389
|
+
renderRowTooltip: renderRowTooltip
|
|
390
|
+
}) : null
|
|
391
|
+
]
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function FileTreeStateRow({ row, ctx }) {
|
|
395
|
+
const { text, onLoadMore, onRetry, getRowAttributes, renderSpinner } = ctx;
|
|
396
|
+
const spinner = renderSpinner?.() ?? /*#__PURE__*/ jsx("span", {
|
|
397
|
+
className: "ov-file-tree__spinner"
|
|
398
|
+
});
|
|
399
|
+
const extra = getRowAttributes?.(row) ?? {};
|
|
400
|
+
const { className: extraClassName, style: extraStyle, ...extraAttributes } = extra;
|
|
401
|
+
const shell = (children, busy = false)=>/*#__PURE__*/ jsxs("div", {
|
|
402
|
+
role: "treeitem",
|
|
403
|
+
"aria-level": row.depth + 1,
|
|
404
|
+
"aria-selected": false,
|
|
405
|
+
"aria-busy": busy || void 0,
|
|
406
|
+
...extraAttributes,
|
|
407
|
+
[FILE_TREE_ROW_ATTRIBUTE]: row.id,
|
|
408
|
+
className: [
|
|
409
|
+
'ov-file-tree__state-row',
|
|
410
|
+
extraClassName
|
|
411
|
+
].filter(Boolean).join(' '),
|
|
412
|
+
style: {
|
|
413
|
+
...rowStyle(row.depth),
|
|
414
|
+
...extraStyle
|
|
415
|
+
},
|
|
416
|
+
children: [
|
|
417
|
+
/*#__PURE__*/ jsx(Guides, {
|
|
418
|
+
depth: row.depth
|
|
419
|
+
}),
|
|
420
|
+
children
|
|
421
|
+
]
|
|
422
|
+
});
|
|
423
|
+
switch(row.kind){
|
|
424
|
+
case 'loading':
|
|
425
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
426
|
+
children: [
|
|
427
|
+
/*#__PURE__*/ jsx("span", {
|
|
428
|
+
className: "ov-file-tree__toggle-spacer"
|
|
429
|
+
}),
|
|
430
|
+
spinner,
|
|
431
|
+
/*#__PURE__*/ jsx("span", {
|
|
432
|
+
className: "ov-file-tree__muted",
|
|
433
|
+
children: text.loading
|
|
434
|
+
})
|
|
435
|
+
]
|
|
436
|
+
}), true);
|
|
437
|
+
case 'load-more':
|
|
438
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
439
|
+
children: [
|
|
440
|
+
/*#__PURE__*/ jsx("span", {
|
|
441
|
+
className: "ov-file-tree__toggle-spacer"
|
|
442
|
+
}),
|
|
443
|
+
row.loading ? spinner : null,
|
|
444
|
+
/*#__PURE__*/ jsx("button", {
|
|
445
|
+
type: "button",
|
|
446
|
+
className: "ov-file-tree__action",
|
|
447
|
+
disabled: row.loading || !onLoadMore,
|
|
448
|
+
onClick: ()=>onLoadMore?.(row),
|
|
449
|
+
children: row.loading ? text.loading : text.loadMore
|
|
450
|
+
})
|
|
451
|
+
]
|
|
452
|
+
}), Boolean(row.loading));
|
|
453
|
+
case 'error':
|
|
454
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
455
|
+
children: [
|
|
456
|
+
/*#__PURE__*/ jsx("span", {
|
|
457
|
+
className: "ov-file-tree__toggle-spacer"
|
|
458
|
+
}),
|
|
459
|
+
/*#__PURE__*/ jsx("span", {
|
|
460
|
+
className: "ov-file-tree__muted",
|
|
461
|
+
children: row.message ?? text.error
|
|
462
|
+
}),
|
|
463
|
+
/*#__PURE__*/ jsx("button", {
|
|
464
|
+
type: "button",
|
|
465
|
+
className: "ov-file-tree__action",
|
|
466
|
+
disabled: !onRetry,
|
|
467
|
+
onClick: ()=>onRetry?.(row),
|
|
468
|
+
children: text.retry
|
|
469
|
+
})
|
|
470
|
+
]
|
|
471
|
+
}));
|
|
472
|
+
case 'empty':
|
|
473
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
474
|
+
children: [
|
|
475
|
+
/*#__PURE__*/ jsx("span", {
|
|
476
|
+
className: "ov-file-tree__toggle-spacer"
|
|
477
|
+
}),
|
|
478
|
+
/*#__PURE__*/ jsx("span", {
|
|
479
|
+
className: "ov-file-tree__muted",
|
|
480
|
+
children: text.empty
|
|
481
|
+
})
|
|
482
|
+
]
|
|
483
|
+
}));
|
|
484
|
+
default:
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function isWholeTreeError(rows) {
|
|
489
|
+
if (1 !== rows.length) return false;
|
|
490
|
+
const [row] = rows;
|
|
491
|
+
return row?.kind === 'error' && !row.parentId;
|
|
492
|
+
}
|
|
493
|
+
function FileTreeBody({ rows, isReady, text, loadingFallback, errorFallback, emptyFallback, ctx }) {
|
|
494
|
+
if (!isReady) return /*#__PURE__*/ jsx("div", {
|
|
495
|
+
className: "ov-file-tree__state",
|
|
496
|
+
children: loadingFallback ?? /*#__PURE__*/ jsx("span", {
|
|
497
|
+
className: "ov-file-tree__muted",
|
|
498
|
+
children: text.loading
|
|
499
|
+
})
|
|
500
|
+
});
|
|
501
|
+
if (isWholeTreeError(rows)) {
|
|
502
|
+
const message = rows[0].message ?? text.error;
|
|
503
|
+
return /*#__PURE__*/ jsx("div", {
|
|
504
|
+
className: "ov-file-tree__state",
|
|
505
|
+
children: errorFallback ?? /*#__PURE__*/ jsx("span", {
|
|
506
|
+
className: "ov-file-tree__muted",
|
|
507
|
+
children: message
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
if (0 === rows.length) return /*#__PURE__*/ jsx("div", {
|
|
512
|
+
className: "ov-file-tree__state",
|
|
513
|
+
children: emptyFallback ?? /*#__PURE__*/ jsx("span", {
|
|
514
|
+
className: "ov-file-tree__muted",
|
|
515
|
+
children: text.empty
|
|
516
|
+
})
|
|
517
|
+
});
|
|
518
|
+
return /*#__PURE__*/ jsx("div", {
|
|
519
|
+
role: "group",
|
|
520
|
+
className: "ov-file-tree__rows",
|
|
521
|
+
children: rows.map((row)=>'entry' === row.kind ? /*#__PURE__*/ jsx(FileTreeRowView, {
|
|
522
|
+
row: row,
|
|
523
|
+
ctx: ctx
|
|
524
|
+
}, row.id) : /*#__PURE__*/ jsx(FileTreeStateRow, {
|
|
525
|
+
row: row,
|
|
526
|
+
ctx: ctx
|
|
527
|
+
}, row.id))
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function visibleRows(root) {
|
|
531
|
+
if (!root) return [];
|
|
532
|
+
return Array.from(root.querySelectorAll(`[${FILE_TREE_ROW_ATTRIBUTE}]`));
|
|
533
|
+
}
|
|
534
|
+
function handleRowKeyDown(event, { root, row, onSelect, onToggleExpand }) {
|
|
535
|
+
const isDirectory = 'directory' === row.type;
|
|
536
|
+
const expanded = Boolean(row.expanded);
|
|
537
|
+
const canToggle = isDirectory && !row.disabled;
|
|
538
|
+
switch(event.key){
|
|
539
|
+
case 'ArrowDown':
|
|
540
|
+
case 'ArrowUp':
|
|
541
|
+
{
|
|
542
|
+
event.preventDefault();
|
|
543
|
+
const rows = visibleRows(root);
|
|
544
|
+
const index = rows.indexOf(event.currentTarget);
|
|
545
|
+
if (-1 === index) return;
|
|
546
|
+
rows[index + ('ArrowDown' === event.key ? 1 : -1)]?.focus();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
case 'ArrowRight':
|
|
550
|
+
if (canToggle && !expanded) {
|
|
551
|
+
event.preventDefault();
|
|
552
|
+
onToggleExpand?.(row);
|
|
553
|
+
}
|
|
554
|
+
return;
|
|
555
|
+
case 'ArrowLeft':
|
|
556
|
+
if (canToggle && expanded) {
|
|
557
|
+
event.preventDefault();
|
|
558
|
+
onToggleExpand?.(row);
|
|
559
|
+
}
|
|
560
|
+
return;
|
|
561
|
+
case 'Enter':
|
|
562
|
+
case ' ':
|
|
563
|
+
event.preventDefault();
|
|
564
|
+
if (!row.disabled) onSelect?.(row);
|
|
565
|
+
return;
|
|
566
|
+
default:
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const DEFAULT_DELAY = 400;
|
|
571
|
+
function useRowTooltip(delay = DEFAULT_DELAY) {
|
|
572
|
+
const [tooltipRowId, setTooltipRowId] = useState(null);
|
|
573
|
+
const timerRef = useRef(void 0);
|
|
574
|
+
const clear = useCallback(()=>{
|
|
575
|
+
if (void 0 !== timerRef.current) {
|
|
576
|
+
window.clearTimeout(timerRef.current);
|
|
577
|
+
timerRef.current = void 0;
|
|
578
|
+
}
|
|
579
|
+
}, []);
|
|
580
|
+
useEffect(()=>clear, [
|
|
581
|
+
clear
|
|
582
|
+
]);
|
|
583
|
+
const show = useCallback((rowId)=>{
|
|
584
|
+
clear();
|
|
585
|
+
timerRef.current = window.setTimeout(()=>{
|
|
586
|
+
setTooltipRowId(rowId);
|
|
587
|
+
timerRef.current = void 0;
|
|
588
|
+
}, delay);
|
|
589
|
+
}, [
|
|
590
|
+
clear,
|
|
591
|
+
delay
|
|
592
|
+
]);
|
|
593
|
+
const hide = useCallback(()=>{
|
|
594
|
+
clear();
|
|
595
|
+
setTooltipRowId(null);
|
|
596
|
+
}, [
|
|
597
|
+
clear
|
|
598
|
+
]);
|
|
599
|
+
return {
|
|
600
|
+
tooltipRowId,
|
|
601
|
+
show,
|
|
602
|
+
hide
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function useFileTreeActions(props) {
|
|
606
|
+
const pending = useRef(new Set());
|
|
607
|
+
const { select, toggleExpand, loadMore, retry, openRetentionSettings } = props.operations ?? {};
|
|
608
|
+
async function run(key, execute, notify, value) {
|
|
609
|
+
if (pending.current.has(key)) return;
|
|
610
|
+
pending.current.add(key);
|
|
611
|
+
try {
|
|
612
|
+
await execute(value);
|
|
613
|
+
} catch {
|
|
614
|
+
return;
|
|
615
|
+
} finally{
|
|
616
|
+
pending.current.delete(key);
|
|
617
|
+
}
|
|
618
|
+
notify?.(value);
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
onSelect: select ? (row)=>void run(`select:${row.id}`, select, props.onSelect, row) : void 0,
|
|
622
|
+
onToggleExpand: toggleExpand ? (row)=>void run(`toggle:${row.id}`, toggleExpand, props.onToggleExpand, row) : void 0,
|
|
623
|
+
onLoadMore: loadMore ? (row)=>void run(`load:${row.id}`, loadMore, props.onLoadMore, row) : void 0,
|
|
624
|
+
onRetry: retry ? (row)=>void run(`retry:${row.id}`, retry, props.onRetry, row) : void 0,
|
|
625
|
+
onOpenRetentionSettings: openRetentionSettings ? (uri)=>void run(`retention:${uri}`, openRetentionSettings, props.onOpenRetentionSettings, uri) : void 0
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function FileTreeSpinner({ className, ...rest }) {
|
|
629
|
+
return /*#__PURE__*/ jsx("span", {
|
|
630
|
+
"aria-hidden": "true",
|
|
631
|
+
...rest,
|
|
632
|
+
className: [
|
|
633
|
+
'ov-file-tree__spinner',
|
|
634
|
+
className
|
|
635
|
+
].filter(Boolean).join(' ')
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
const DEFAULT_LABELS = {
|
|
639
|
+
empty: 'No files yet',
|
|
640
|
+
error: 'Failed to load',
|
|
641
|
+
retry: 'Retry',
|
|
642
|
+
loadMore: 'Load more',
|
|
643
|
+
loading: 'Loading…',
|
|
644
|
+
expand: 'Expand {name}',
|
|
645
|
+
collapse: 'Collapse {name}'
|
|
646
|
+
};
|
|
647
|
+
function findRow(root, id) {
|
|
648
|
+
return root?.querySelector(`[${FILE_TREE_ROW_ATTRIBUTE}="${CSS.escape(id)}"]`) ?? null;
|
|
649
|
+
}
|
|
650
|
+
const file_tree_FileTree = /*#__PURE__*/ forwardRef(function({ rows, operations, selectedId, isReady = true, loadingFallback, errorFallback, emptyFallback, slots, labels, getRowAttributes, renderDashboard, renderRowTooltip, renderRowIcon, onSelect, onToggleExpand, onLoadMore, onRetry, onOpenRetentionSettings, className, ...rest }, ref) {
|
|
651
|
+
const rootRef = useRef(null);
|
|
652
|
+
const text = {
|
|
653
|
+
...DEFAULT_LABELS,
|
|
654
|
+
...labels,
|
|
655
|
+
info: labels?.info ?? DEFAULT_LABELS.info
|
|
656
|
+
};
|
|
657
|
+
const tooltip = useRowTooltip();
|
|
658
|
+
const actions = useFileTreeActions({
|
|
659
|
+
operations,
|
|
660
|
+
onSelect,
|
|
661
|
+
onToggleExpand,
|
|
662
|
+
onLoadMore,
|
|
663
|
+
onRetry,
|
|
664
|
+
onOpenRetentionSettings
|
|
665
|
+
});
|
|
666
|
+
useImperativeHandle(ref, ()=>({
|
|
667
|
+
getRowElement: (id)=>findRow(rootRef.current, id),
|
|
668
|
+
scrollToRow: (id, options)=>{
|
|
669
|
+
const element = findRow(rootRef.current, id);
|
|
670
|
+
if (!element) return false;
|
|
671
|
+
element.scrollIntoView({
|
|
672
|
+
block: 'nearest',
|
|
673
|
+
...options
|
|
674
|
+
});
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
}), []);
|
|
678
|
+
const ctx = {
|
|
679
|
+
text,
|
|
680
|
+
infoLabels: labels?.info,
|
|
681
|
+
selectedId,
|
|
682
|
+
tooltipRowId: tooltip.tooltipRowId,
|
|
683
|
+
getRowAttributes,
|
|
684
|
+
renderDashboard,
|
|
685
|
+
renderRowTooltip,
|
|
686
|
+
renderRowIcon,
|
|
687
|
+
renderSpinner: slots?.spinner ? ()=>slots.spinner : void 0,
|
|
688
|
+
...actions,
|
|
689
|
+
onRowKeyDown: (event, row)=>handleRowKeyDown(event, {
|
|
690
|
+
root: rootRef.current,
|
|
691
|
+
row,
|
|
692
|
+
onSelect: actions.onSelect,
|
|
693
|
+
onToggleExpand: actions.onToggleExpand
|
|
694
|
+
}),
|
|
695
|
+
onRowEnter: tooltip.show,
|
|
696
|
+
onRowLeave: tooltip.hide
|
|
697
|
+
};
|
|
698
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
699
|
+
...rest,
|
|
700
|
+
ref: rootRef,
|
|
701
|
+
className: [
|
|
702
|
+
'ov-file-tree',
|
|
703
|
+
className
|
|
704
|
+
].filter(Boolean).join(' '),
|
|
705
|
+
children: [
|
|
706
|
+
slots?.toolbar ? /*#__PURE__*/ jsx("div", {
|
|
707
|
+
className: "ov-file-tree__toolbar",
|
|
708
|
+
children: slots.toolbar
|
|
709
|
+
}) : null,
|
|
710
|
+
/*#__PURE__*/ jsx("div", {
|
|
711
|
+
role: "tree",
|
|
712
|
+
"aria-label": rest['aria-label'],
|
|
713
|
+
className: "ov-file-tree__body",
|
|
714
|
+
children: /*#__PURE__*/ jsx(FileTreeBody, {
|
|
715
|
+
rows: rows,
|
|
716
|
+
isReady: isReady,
|
|
717
|
+
text: text,
|
|
718
|
+
loadingFallback: loadingFallback,
|
|
719
|
+
errorFallback: errorFallback,
|
|
720
|
+
emptyFallback: emptyFallback,
|
|
721
|
+
ctx: ctx
|
|
722
|
+
})
|
|
723
|
+
})
|
|
724
|
+
]
|
|
725
|
+
});
|
|
726
|
+
});
|
|
727
|
+
export { DEFAULT_INFO_LABELS, FILE_TREE_ROW_ATTRIBUTE, FileTreeSpinner, file_tree_FileTree as FileTree, resolveFileTreeInfoKey, resolveInfoCopy, showsInlineDescription, splitVikingUri };
|