@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/n~0.js
CHANGED
|
@@ -1,106 +1,304 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
className: "ov-file-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
strokeWidth: "1.5"
|
|
18
|
-
})
|
|
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
|
+
]
|
|
19
17
|
});
|
|
20
18
|
}
|
|
21
|
-
function
|
|
22
|
-
return /*#__PURE__*/ jsx(
|
|
23
|
-
|
|
24
|
-
className: "ov-file-tree__icon",
|
|
25
|
-
viewBox: "0 0 16 16",
|
|
26
|
-
width: "14",
|
|
27
|
-
height: "14",
|
|
28
|
-
children: /*#__PURE__*/ jsx("path", {
|
|
29
|
-
d: open ? 'M1.5 13V4.5A1 1 0 0 1 2.5 3.5h3l1.2 1.5h5.8a1 1 0 0 1 1 1V7M1.5 13l1.6-5h11.4l-1.6 5H1.5Z' : 'M1.5 12.5v-9a1 1 0 0 1 1-1h3l1.2 1.5h6.8a1 1 0 0 1 1 1v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1Z',
|
|
30
|
-
fill: "none",
|
|
31
|
-
stroke: "currentColor",
|
|
32
|
-
strokeLinejoin: "round",
|
|
33
|
-
strokeWidth: "1.2"
|
|
34
|
-
})
|
|
19
|
+
function FileTreeFileIcon() {
|
|
20
|
+
return /*#__PURE__*/ jsx(DocumentIcon, {
|
|
21
|
+
className: "ov-file-tree__file-icon"
|
|
35
22
|
});
|
|
36
23
|
}
|
|
37
|
-
function
|
|
38
|
-
return /*#__PURE__*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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",
|
|
44
188
|
children: [
|
|
45
|
-
/*#__PURE__*/ jsx("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
stroke: "currentColor",
|
|
49
|
-
strokeLinejoin: "round",
|
|
50
|
-
strokeWidth: "1.2"
|
|
189
|
+
/*#__PURE__*/ jsx("span", {
|
|
190
|
+
className: "ov-file-tree__info-title",
|
|
191
|
+
children: title
|
|
51
192
|
}),
|
|
52
|
-
/*#__PURE__*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
]
|
|
57
231
|
})
|
|
58
232
|
]
|
|
59
233
|
});
|
|
60
234
|
}
|
|
61
|
-
function
|
|
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;
|
|
62
247
|
return /*#__PURE__*/ jsx("span", {
|
|
63
|
-
|
|
64
|
-
className: "ov-file-
|
|
248
|
+
role: "tooltip",
|
|
249
|
+
className: "ov-file-tree__tooltip",
|
|
250
|
+
children: /*#__PURE__*/ jsx(FileTreeInfoTooltip, {
|
|
251
|
+
copy: copy
|
|
252
|
+
})
|
|
65
253
|
});
|
|
66
254
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
retry: 'Retry',
|
|
71
|
-
loadMore: 'Load more',
|
|
72
|
-
loading: 'Loading…',
|
|
73
|
-
expand: 'Expand {name}',
|
|
74
|
-
collapse: 'Collapse {name}'
|
|
75
|
-
};
|
|
76
|
-
function fillName(template, name) {
|
|
77
|
-
return template.replace('{name}', name);
|
|
78
|
-
}
|
|
79
|
-
function rowIndent(row) {
|
|
255
|
+
const INDENT = 20;
|
|
256
|
+
const CHEVRON_SIZE = 16;
|
|
257
|
+
function rowStyle(depth) {
|
|
80
258
|
return {
|
|
81
|
-
paddingLeft:
|
|
259
|
+
paddingLeft: 8 + depth * INDENT
|
|
82
260
|
};
|
|
83
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
|
+
}
|
|
84
275
|
const FILE_TREE_ROW_ATTRIBUTE = 'data-file-tree-row-id';
|
|
85
|
-
function
|
|
86
|
-
const { text, selectedId, tooltipRowId, getRowAttributes, renderDashboard, renderRowTooltip, onSelect, onToggleExpand, onOpenRetentionSettings, onRowKeyDown, onRowEnter, onRowLeave } = ctx;
|
|
276
|
+
function FileTreeRowView({ row, ctx }) {
|
|
277
|
+
const { text, selectedId, tooltipRowId, getRowAttributes, renderDashboard, renderRowTooltip, renderRowIcon, onSelect, onToggleExpand, onOpenRetentionSettings, onRowKeyDown, onRowEnter, onRowLeave } = ctx;
|
|
87
278
|
const isDirectory = 'directory' === row.type;
|
|
88
279
|
const canExpand = isDirectory && false !== row.hasChildren;
|
|
280
|
+
const isExpanded = Boolean(row.expanded);
|
|
89
281
|
const isSelected = selectedId === row.id;
|
|
90
|
-
const
|
|
282
|
+
const extra = getRowAttributes?.(row) ?? {};
|
|
283
|
+
const { className: extraClassName, style: extraStyle, ...extraAttributes } = extra;
|
|
91
284
|
const dashboard = renderDashboard?.(row) ?? null;
|
|
92
|
-
const
|
|
93
|
-
const
|
|
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)=>{
|
|
94
288
|
if (event.target.closest('[data-role="toggle"]')) return;
|
|
95
289
|
if (row.disabled) return;
|
|
96
290
|
onSelect?.(row);
|
|
97
291
|
};
|
|
292
|
+
const handleToggle = (event)=>{
|
|
293
|
+
event.stopPropagation();
|
|
294
|
+
onToggleExpand?.(row);
|
|
295
|
+
};
|
|
98
296
|
return /*#__PURE__*/ jsxs("div", {
|
|
99
297
|
role: "treeitem",
|
|
100
298
|
tabIndex: 0,
|
|
101
299
|
"aria-level": row.depth + 1,
|
|
102
300
|
"aria-selected": isSelected,
|
|
103
|
-
"aria-expanded": canExpand ?
|
|
301
|
+
"aria-expanded": canExpand ? isExpanded : void 0,
|
|
104
302
|
"aria-disabled": row.disabled || void 0,
|
|
105
303
|
...extraAttributes,
|
|
106
304
|
[FILE_TREE_ROW_ATTRIBUTE]: row.id,
|
|
@@ -112,29 +310,31 @@ function FileTreeEntryRowView({ row, ctx }) {
|
|
|
112
310
|
"data-disabled": row.disabled || void 0,
|
|
113
311
|
"data-kind": row.kind,
|
|
114
312
|
style: {
|
|
115
|
-
...
|
|
313
|
+
...rowStyle(row.depth),
|
|
116
314
|
...extraStyle
|
|
117
315
|
},
|
|
118
|
-
onClick:
|
|
316
|
+
onClick: handleClick,
|
|
119
317
|
onKeyDown: (event)=>onRowKeyDown(event, row),
|
|
120
318
|
onMouseEnter: ()=>onRowEnter(row.id),
|
|
121
319
|
onMouseLeave: onRowLeave,
|
|
122
320
|
onFocus: ()=>onRowEnter(row.id),
|
|
123
321
|
onBlur: onRowLeave,
|
|
124
322
|
children: [
|
|
323
|
+
/*#__PURE__*/ jsx(Guides, {
|
|
324
|
+
depth: row.depth
|
|
325
|
+
}),
|
|
125
326
|
canExpand ? /*#__PURE__*/ jsx("button", {
|
|
126
327
|
type: "button",
|
|
127
328
|
"data-role": "toggle",
|
|
128
329
|
className: "ov-file-tree__toggle",
|
|
129
|
-
"aria-label":
|
|
330
|
+
"aria-label": isExpanded ? text.collapse.replace('{name}', row.name) : text.expand.replace('{name}', row.name),
|
|
130
331
|
tabIndex: -1,
|
|
131
|
-
disabled: !onToggleExpand || row.disabled
|
|
132
|
-
onClick:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
expanded: Boolean(row.expanded)
|
|
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
|
|
138
338
|
})
|
|
139
339
|
}) : /*#__PURE__*/ jsx("span", {
|
|
140
340
|
"aria-hidden": "true",
|
|
@@ -142,9 +342,9 @@ function FileTreeEntryRowView({ row, ctx }) {
|
|
|
142
342
|
}),
|
|
143
343
|
/*#__PURE__*/ jsx("span", {
|
|
144
344
|
className: "ov-file-tree__icon-slot",
|
|
145
|
-
children: isDirectory ? /*#__PURE__*/ jsx(
|
|
146
|
-
open:
|
|
147
|
-
}) : /*#__PURE__*/ jsx(
|
|
345
|
+
children: isDirectory ? /*#__PURE__*/ jsx(FileTreeFolderIcon, {
|
|
346
|
+
open: isExpanded
|
|
347
|
+
}) : renderRowIcon?.(row) ?? /*#__PURE__*/ jsx(FileTreeFileIcon, {})
|
|
148
348
|
}),
|
|
149
349
|
/*#__PURE__*/ jsxs("span", {
|
|
150
350
|
className: "ov-file-tree__label-group",
|
|
@@ -154,16 +354,17 @@ function FileTreeEntryRowView({ row, ctx }) {
|
|
|
154
354
|
title: row.name,
|
|
155
355
|
children: row.name
|
|
156
356
|
}),
|
|
157
|
-
|
|
357
|
+
description ? /*#__PURE__*/ jsx("span", {
|
|
158
358
|
className: "ov-file-tree__description",
|
|
159
|
-
children:
|
|
359
|
+
children: description
|
|
160
360
|
}) : null
|
|
161
361
|
]
|
|
162
362
|
}),
|
|
163
|
-
row.busy ? /*#__PURE__*/ jsx(
|
|
363
|
+
row.busy && !canExpand ? /*#__PURE__*/ jsx("span", {
|
|
364
|
+
className: "ov-file-tree__spinner"
|
|
365
|
+
}) : null,
|
|
164
366
|
row.expiresAt ? /*#__PURE__*/ jsx("span", {
|
|
165
367
|
className: "ov-file-tree__expiry",
|
|
166
|
-
title: row.expiresAt,
|
|
167
368
|
children: onOpenRetentionSettings ? /*#__PURE__*/ jsx("button", {
|
|
168
369
|
type: "button",
|
|
169
370
|
className: "ov-file-tree__expiry-action",
|
|
@@ -182,116 +383,112 @@ function FileTreeEntryRowView({ row, ctx }) {
|
|
|
182
383
|
className: "ov-file-tree__dashboard",
|
|
183
384
|
children: dashboard
|
|
184
385
|
}) : null,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
386
|
+
tooltipRowId === row.id ? /*#__PURE__*/ jsx(FileTreeTooltipSurface, {
|
|
387
|
+
row: row,
|
|
388
|
+
infoLabels: ctx.infoLabels,
|
|
389
|
+
renderRowTooltip: renderRowTooltip
|
|
189
390
|
}) : null
|
|
190
391
|
]
|
|
191
392
|
});
|
|
192
393
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
function StateRow({ row, ctx, attributes, tone, children }) {
|
|
199
|
-
const { className: extraClassName, style: extraStyle, ...extraAttributes } = ctx.getRowAttributes?.(row) ?? {};
|
|
200
|
-
return /*#__PURE__*/ jsx("div", {
|
|
201
|
-
role: "treeitem",
|
|
202
|
-
"aria-level": row.depth + 1,
|
|
203
|
-
"aria-selected": false,
|
|
204
|
-
...attributes,
|
|
205
|
-
...extraAttributes,
|
|
206
|
-
[FILE_TREE_ROW_ATTRIBUTE]: row.id,
|
|
207
|
-
className: [
|
|
208
|
-
'ov-file-tree__child-row',
|
|
209
|
-
extraClassName
|
|
210
|
-
].filter(Boolean).join(' '),
|
|
211
|
-
"data-tone": tone,
|
|
212
|
-
style: {
|
|
213
|
-
...rowIndent(row),
|
|
214
|
-
...extraStyle
|
|
215
|
-
},
|
|
216
|
-
children: children
|
|
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"
|
|
217
398
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const
|
|
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
|
+
});
|
|
221
423
|
switch(row.kind){
|
|
222
424
|
case 'loading':
|
|
223
|
-
return /*#__PURE__*/ jsxs(
|
|
224
|
-
row: row,
|
|
225
|
-
ctx: ctx,
|
|
226
|
-
attributes: {
|
|
227
|
-
'aria-busy': true
|
|
228
|
-
},
|
|
425
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
229
426
|
children: [
|
|
230
427
|
/*#__PURE__*/ jsx("span", {
|
|
231
428
|
className: "ov-file-tree__toggle-spacer"
|
|
232
429
|
}),
|
|
233
|
-
|
|
430
|
+
spinner,
|
|
234
431
|
/*#__PURE__*/ jsx("span", {
|
|
235
432
|
className: "ov-file-tree__muted",
|
|
236
433
|
children: text.loading
|
|
237
434
|
})
|
|
238
435
|
]
|
|
239
|
-
});
|
|
436
|
+
}), true);
|
|
240
437
|
case 'load-more':
|
|
241
|
-
return /*#__PURE__*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
row.loading
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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));
|
|
255
453
|
case 'error':
|
|
256
|
-
return /*#__PURE__*/ jsxs(
|
|
257
|
-
row: row,
|
|
258
|
-
ctx: ctx,
|
|
259
|
-
tone: "error",
|
|
454
|
+
return shell(/*#__PURE__*/ jsxs(Fragment, {
|
|
260
455
|
children: [
|
|
456
|
+
/*#__PURE__*/ jsx("span", {
|
|
457
|
+
className: "ov-file-tree__toggle-spacer"
|
|
458
|
+
}),
|
|
261
459
|
/*#__PURE__*/ jsx("span", {
|
|
262
460
|
className: "ov-file-tree__muted",
|
|
263
461
|
children: row.message ?? text.error
|
|
264
462
|
}),
|
|
265
463
|
/*#__PURE__*/ jsx("button", {
|
|
266
464
|
type: "button",
|
|
267
|
-
className: "ov-file-
|
|
465
|
+
className: "ov-file-tree__action",
|
|
268
466
|
disabled: !onRetry,
|
|
269
467
|
onClick: ()=>onRetry?.(row),
|
|
270
468
|
children: text.retry
|
|
271
469
|
})
|
|
272
470
|
]
|
|
273
|
-
});
|
|
471
|
+
}));
|
|
274
472
|
case 'empty':
|
|
275
|
-
return /*#__PURE__*/
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
+
}));
|
|
283
484
|
default:
|
|
284
|
-
return
|
|
285
|
-
row: row,
|
|
286
|
-
ctx: ctx
|
|
287
|
-
});
|
|
485
|
+
return null;
|
|
288
486
|
}
|
|
289
487
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
});
|
|
488
|
+
function isWholeTreeError(rows) {
|
|
489
|
+
if (1 !== rows.length) return false;
|
|
490
|
+
const [row] = rows;
|
|
491
|
+
return row?.kind === 'error' && !row.parentId;
|
|
295
492
|
}
|
|
296
493
|
function FileTreeBody({ rows, isReady, text, loadingFallback, errorFallback, emptyFallback, ctx }) {
|
|
297
494
|
if (!isReady) return /*#__PURE__*/ jsx("div", {
|
|
@@ -321,79 +518,84 @@ function FileTreeBody({ rows, isReady, text, loadingFallback, errorFallback, emp
|
|
|
321
518
|
return /*#__PURE__*/ jsx("div", {
|
|
322
519
|
role: "group",
|
|
323
520
|
className: "ov-file-tree__rows",
|
|
324
|
-
children: rows.map((row)
|
|
521
|
+
children: rows.map((row)=>'entry' === row.kind ? /*#__PURE__*/ jsx(FileTreeRowView, {
|
|
522
|
+
row: row,
|
|
523
|
+
ctx: ctx
|
|
524
|
+
}, row.id) : /*#__PURE__*/ jsx(FileTreeStateRow, {
|
|
325
525
|
row: row,
|
|
326
526
|
ctx: ctx
|
|
327
527
|
}, row.id))
|
|
328
528
|
});
|
|
329
529
|
}
|
|
330
|
-
function
|
|
530
|
+
function visibleRows(root) {
|
|
331
531
|
if (!root) return [];
|
|
332
532
|
return Array.from(root.querySelectorAll(`[${FILE_TREE_ROW_ATTRIBUTE}]`));
|
|
333
533
|
}
|
|
334
|
-
function findRowElement(root, id) {
|
|
335
|
-
if (!root) return null;
|
|
336
|
-
return root.querySelector(`[${FILE_TREE_ROW_ATTRIBUTE}="${CSS.escape(id)}"]`);
|
|
337
|
-
}
|
|
338
|
-
function moveFocus(current, root, delta) {
|
|
339
|
-
const elements = queryRowElements(root);
|
|
340
|
-
const index = elements.indexOf(current);
|
|
341
|
-
if (-1 === index) return;
|
|
342
|
-
elements[index + delta]?.focus();
|
|
343
|
-
}
|
|
344
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;
|
|
345
538
|
switch(event.key){
|
|
346
539
|
case 'ArrowDown':
|
|
347
|
-
event.preventDefault();
|
|
348
|
-
moveFocus(event.currentTarget, root, 1);
|
|
349
|
-
break;
|
|
350
540
|
case 'ArrowUp':
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
+
}
|
|
354
549
|
case 'ArrowRight':
|
|
355
|
-
if (
|
|
550
|
+
if (canToggle && !expanded) {
|
|
356
551
|
event.preventDefault();
|
|
357
552
|
onToggleExpand?.(row);
|
|
358
553
|
}
|
|
359
|
-
|
|
554
|
+
return;
|
|
360
555
|
case 'ArrowLeft':
|
|
361
|
-
if (
|
|
556
|
+
if (canToggle && expanded) {
|
|
362
557
|
event.preventDefault();
|
|
363
558
|
onToggleExpand?.(row);
|
|
364
559
|
}
|
|
365
|
-
|
|
560
|
+
return;
|
|
366
561
|
case 'Enter':
|
|
367
562
|
case ' ':
|
|
368
563
|
event.preventDefault();
|
|
369
564
|
if (!row.disabled) onSelect?.(row);
|
|
370
|
-
|
|
565
|
+
return;
|
|
371
566
|
default:
|
|
372
|
-
|
|
567
|
+
return;
|
|
373
568
|
}
|
|
374
569
|
}
|
|
375
|
-
|
|
570
|
+
const DEFAULT_DELAY = 400;
|
|
571
|
+
function useRowTooltip(delay = DEFAULT_DELAY) {
|
|
376
572
|
const [tooltipRowId, setTooltipRowId] = useState(null);
|
|
377
573
|
const timerRef = useRef(void 0);
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
+
]);
|
|
381
583
|
const show = useCallback((rowId)=>{
|
|
382
|
-
|
|
584
|
+
clear();
|
|
383
585
|
timerRef.current = window.setTimeout(()=>{
|
|
384
586
|
setTooltipRowId(rowId);
|
|
385
587
|
timerRef.current = void 0;
|
|
386
588
|
}, delay);
|
|
387
589
|
}, [
|
|
590
|
+
clear,
|
|
388
591
|
delay
|
|
389
592
|
]);
|
|
390
593
|
const hide = useCallback(()=>{
|
|
391
|
-
|
|
392
|
-
window.clearTimeout(timerRef.current);
|
|
393
|
-
timerRef.current = void 0;
|
|
394
|
-
}
|
|
594
|
+
clear();
|
|
395
595
|
setTooltipRowId(null);
|
|
396
|
-
}, [
|
|
596
|
+
}, [
|
|
597
|
+
clear
|
|
598
|
+
]);
|
|
397
599
|
return {
|
|
398
600
|
tooltipRowId,
|
|
399
601
|
show,
|
|
@@ -423,11 +625,34 @@ function useFileTreeActions(props) {
|
|
|
423
625
|
onOpenRetentionSettings: openRetentionSettings ? (uri)=>void run(`retention:${uri}`, openRetentionSettings, props.onOpenRetentionSettings, uri) : void 0
|
|
424
626
|
};
|
|
425
627
|
}
|
|
426
|
-
|
|
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) {
|
|
427
651
|
const rootRef = useRef(null);
|
|
428
652
|
const text = {
|
|
429
653
|
...DEFAULT_LABELS,
|
|
430
|
-
...labels
|
|
654
|
+
...labels,
|
|
655
|
+
info: labels?.info ?? DEFAULT_LABELS.info
|
|
431
656
|
};
|
|
432
657
|
const tooltip = useRowTooltip();
|
|
433
658
|
const actions = useFileTreeActions({
|
|
@@ -439,9 +664,9 @@ const file_tree_FileTree = /*#__PURE__*/ forwardRef(function({ rows, operations,
|
|
|
439
664
|
onOpenRetentionSettings
|
|
440
665
|
});
|
|
441
666
|
useImperativeHandle(ref, ()=>({
|
|
442
|
-
getRowElement: (id)=>
|
|
667
|
+
getRowElement: (id)=>findRow(rootRef.current, id),
|
|
443
668
|
scrollToRow: (id, options)=>{
|
|
444
|
-
const element =
|
|
669
|
+
const element = findRow(rootRef.current, id);
|
|
445
670
|
if (!element) return false;
|
|
446
671
|
element.scrollIntoView({
|
|
447
672
|
block: 'nearest',
|
|
@@ -450,13 +675,16 @@ const file_tree_FileTree = /*#__PURE__*/ forwardRef(function({ rows, operations,
|
|
|
450
675
|
return true;
|
|
451
676
|
}
|
|
452
677
|
}), []);
|
|
453
|
-
const
|
|
678
|
+
const ctx = {
|
|
454
679
|
text,
|
|
680
|
+
infoLabels: labels?.info,
|
|
455
681
|
selectedId,
|
|
456
682
|
tooltipRowId: tooltip.tooltipRowId,
|
|
457
683
|
getRowAttributes,
|
|
458
684
|
renderDashboard,
|
|
459
685
|
renderRowTooltip,
|
|
686
|
+
renderRowIcon,
|
|
687
|
+
renderSpinner: slots?.spinner ? ()=>slots.spinner : void 0,
|
|
460
688
|
...actions,
|
|
461
689
|
onRowKeyDown: (event, row)=>handleRowKeyDown(event, {
|
|
462
690
|
root: rootRef.current,
|
|
@@ -490,10 +718,10 @@ const file_tree_FileTree = /*#__PURE__*/ forwardRef(function({ rows, operations,
|
|
|
490
718
|
loadingFallback: loadingFallback,
|
|
491
719
|
errorFallback: errorFallback,
|
|
492
720
|
emptyFallback: emptyFallback,
|
|
493
|
-
ctx:
|
|
721
|
+
ctx: ctx
|
|
494
722
|
})
|
|
495
723
|
})
|
|
496
724
|
]
|
|
497
725
|
});
|
|
498
726
|
});
|
|
499
|
-
export { FILE_TREE_ROW_ATTRIBUTE, file_tree_FileTree as FileTree };
|
|
727
|
+
export { DEFAULT_INFO_LABELS, FILE_TREE_ROW_ATTRIBUTE, FileTreeSpinner, file_tree_FileTree as FileTree, resolveFileTreeInfoKey, resolveInfoCopy, showsInlineDescription, splitVikingUri };
|