@uipath/apollo-wind 2.79.0 → 2.79.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/dist/components/forms/metadata-form.cjs +3 -2
- package/dist/components/forms/metadata-form.js +3 -2
- package/dist/components/ui/field-actions/ai-assist-action.cjs +7 -5
- package/dist/components/ui/field-actions/ai-assist-action.js +7 -5
- package/dist/components/ui/field-actions/collapse.cjs +7 -7
- package/dist/components/ui/field-actions/collapse.d.ts +6 -3
- package/dist/components/ui/field-actions/collapse.js +3 -3
- package/dist/components/ui/field-actions/insert-variable-action.cjs +7 -7
- package/dist/components/ui/field-actions/insert-variable-action.js +8 -8
- package/dist/components/ui/index.cjs +34 -34
- package/dist/components/ui/json-tree-view/EditorChrome.cjs +5 -2
- package/dist/components/ui/json-tree-view/EditorChrome.js +5 -2
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +6 -3
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +6 -3
- package/dist/components/ui/json-tree-view/JsonTree.cjs +66 -38
- package/dist/components/ui/json-tree-view/JsonTree.d.ts +6 -1
- package/dist/components/ui/json-tree-view/JsonTree.js +66 -38
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +6 -1
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +116 -81
- package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +16 -8
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +116 -81
- package/dist/components/ui/json-tree-view/NodeKey.cjs +2 -2
- package/dist/components/ui/json-tree-view/NodeKey.js +2 -2
- package/dist/components/ui/json-tree-view/RowActions.cjs +6 -6
- package/dist/components/ui/json-tree-view/RowActions.js +6 -6
- package/dist/components/ui/json-tree-view/buildJsonTree.cjs +20 -1
- package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +4 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.js +20 -1
- package/dist/components/ui/json-tree-view/strings.cjs +2 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +12 -0
- package/dist/components/ui/json-tree-view/strings.js +2 -0
- package/dist/components/ui/json-tree-view/treeGrid.cjs +306 -0
- package/dist/components/ui/json-tree-view/treeGrid.d.ts +36 -0
- package/dist/components/ui/json-tree-view/treeGrid.js +269 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +14 -14
- package/dist/components/ui/quick-form-field/components/field-header.js +15 -15
- package/dist/components/ui/tool-call.cjs +2 -2
- package/dist/components/ui/tool-call.js +2 -2
- package/dist/lib/clipboard.cjs +4 -0
- package/dist/lib/clipboard.js +4 -0
- package/dist/lib/use-ancestor-density.cjs +2 -2
- package/dist/lib/use-ancestor-density.js +2 -2
- package/dist/lib/use-isomorphic-layout-effect.cjs +37 -0
- package/dist/lib/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/lib/use-isomorphic-layout-effect.js +3 -0
- package/dist/styles.css +18 -26
- package/dist/tailwind.css +2 -1
- package/package.json +1 -1
|
@@ -31,16 +31,17 @@ const react_virtual_namespaceObject = require("@tanstack/react-virtual");
|
|
|
31
31
|
const external_react_namespaceObject = require("react");
|
|
32
32
|
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
33
33
|
const clipboard_cjs_namespaceObject = require("../../../lib/clipboard.cjs");
|
|
34
|
+
const use_isomorphic_layout_effect_cjs_namespaceObject = require("../../../lib/use-isomorphic-layout-effect.cjs");
|
|
34
35
|
const external_buildJsonTree_cjs_namespaceObject = require("./buildJsonTree.cjs");
|
|
35
36
|
const external_JsonTreeRow_cjs_namespaceObject = require("./JsonTreeRow.cjs");
|
|
36
37
|
const external_JsonTreeTooltip_cjs_namespaceObject = require("./JsonTreeTooltip.cjs");
|
|
37
38
|
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
38
|
-
const
|
|
39
|
+
const external_treeGrid_cjs_namespaceObject = require("./treeGrid.cjs");
|
|
39
40
|
const VIRTUAL_OVERSCAN = 10;
|
|
40
41
|
function scrollMarginOf(element, scrollElement) {
|
|
41
42
|
return Math.round(element.getBoundingClientRect().top - scrollElement.getBoundingClientRect().top + scrollElement.scrollTop);
|
|
42
43
|
}
|
|
43
|
-
function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
44
|
+
function VirtualRows({ rows, indexByPath, container, scrollElement, pinnedPaths, gridProps }) {
|
|
44
45
|
const [scrollMargin, setScrollMargin] = (0, external_react_namespaceObject.useState)(0);
|
|
45
46
|
const getItemKey = (0, external_react_namespaceObject.useCallback)((index)=>rows[index]?.node.path ?? index, [
|
|
46
47
|
rows
|
|
@@ -53,7 +54,7 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
53
54
|
overscan: VIRTUAL_OVERSCAN,
|
|
54
55
|
scrollMargin
|
|
55
56
|
});
|
|
56
|
-
useIsomorphicLayoutEffect(()=>{
|
|
57
|
+
(0, use_isomorphic_layout_effect_cjs_namespaceObject.useIsomorphicLayoutEffect)(()=>{
|
|
57
58
|
if (!container || !scrollElement) {
|
|
58
59
|
if (0 !== scrollMargin) setScrollMargin(0);
|
|
59
60
|
return;
|
|
@@ -62,21 +63,11 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
62
63
|
const next = scrollMarginOf(container, scrollElement);
|
|
63
64
|
if (next !== scrollMargin) setScrollMargin(next);
|
|
64
65
|
});
|
|
65
|
-
const isPinning = pinnedPaths.length > 0;
|
|
66
|
-
const indexByPath = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
67
|
-
if (!isPinning) return;
|
|
68
|
-
const byPath = new Map();
|
|
69
|
-
for (const [index, row] of rows.entries())byPath.set(row.node.path, index);
|
|
70
|
-
return byPath;
|
|
71
|
-
}, [
|
|
72
|
-
isPinning,
|
|
73
|
-
rows
|
|
74
|
-
]);
|
|
75
66
|
const items = virtualizer.getVirtualItems();
|
|
76
67
|
const firstWindowed = items[0]?.index ?? -1;
|
|
77
68
|
const lastWindowed = items[items.length - 1]?.index ?? -2;
|
|
78
69
|
const pinnedItems = [];
|
|
79
|
-
|
|
70
|
+
for (const path of pinnedPaths){
|
|
80
71
|
const index = indexByPath.get(path);
|
|
81
72
|
if (void 0 === index || index >= firstWindowed && index <= lastWindowed) continue;
|
|
82
73
|
const measurement = virtualizer.measurementsCache[index];
|
|
@@ -88,6 +79,7 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
88
79
|
...pinnedItems.filter((item)=>item.index > lastWindowed)
|
|
89
80
|
];
|
|
90
81
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
82
|
+
...gridProps,
|
|
91
83
|
className: "relative",
|
|
92
84
|
style: {
|
|
93
85
|
height: virtualizer.getTotalSize()
|
|
@@ -103,8 +95,8 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
103
95
|
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
104
96
|
},
|
|
105
97
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeRow_cjs_namespaceObject.JsonTreeRow, {
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
row: row,
|
|
99
|
+
index: item.index
|
|
108
100
|
})
|
|
109
101
|
}, item.key);
|
|
110
102
|
})
|
|
@@ -130,7 +122,7 @@ function JsonTreeView({ strings, tooltipContentClassName, ...props }) {
|
|
|
130
122
|
})
|
|
131
123
|
});
|
|
132
124
|
}
|
|
133
|
-
function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, virtualized = false, scrollElement, emptyMessage, className }) {
|
|
125
|
+
function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, virtualized = false, scrollElement, emptyMessage, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className }) {
|
|
134
126
|
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
135
127
|
const [container, setContainer] = (0, external_react_namespaceObject.useState)(null);
|
|
136
128
|
const usesAncestorScroller = virtualized && !!scrollElement;
|
|
@@ -138,15 +130,6 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
138
130
|
const [editingPath, setEditingPath] = (0, external_react_namespaceObject.useState)(null);
|
|
139
131
|
const [jsonEditingPath, setJsonEditingPath] = (0, external_react_namespaceObject.useState)(null);
|
|
140
132
|
const [wrappedPaths, setWrappedPaths] = (0, external_react_namespaceObject.useState)({});
|
|
141
|
-
const pinnedPaths = (0, external_react_namespaceObject.useMemo)(()=>[
|
|
142
|
-
...new Set([
|
|
143
|
-
editingPath,
|
|
144
|
-
jsonEditingPath
|
|
145
|
-
].filter((path)=>null !== path))
|
|
146
|
-
], [
|
|
147
|
-
editingPath,
|
|
148
|
-
jsonEditingPath
|
|
149
|
-
]);
|
|
150
133
|
const [copied, setCopied] = (0, external_react_namespaceObject.useState)(null);
|
|
151
134
|
const copyTimerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
152
135
|
(0, external_react_namespaceObject.useEffect)(()=>()=>{
|
|
@@ -155,10 +138,11 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
155
138
|
const copy = (node, kind, text)=>{
|
|
156
139
|
(0, clipboard_cjs_namespaceObject.copyTextToClipboard)(text).then((ok)=>{
|
|
157
140
|
if (!ok) return;
|
|
158
|
-
setCopied({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
setCopied((prev)=>({
|
|
142
|
+
path: node.path,
|
|
143
|
+
kind,
|
|
144
|
+
id: (prev?.id ?? 0) + 1
|
|
145
|
+
}));
|
|
162
146
|
if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
|
|
163
147
|
copyTimerRef.current = setTimeout(()=>setCopied(null), 1500);
|
|
164
148
|
onCopy?.({
|
|
@@ -191,6 +175,37 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
191
175
|
filterPredicate,
|
|
192
176
|
decorateNode
|
|
193
177
|
]);
|
|
178
|
+
const indexByPath = (0, external_react_namespaceObject.useMemo)(()=>new Map(rows.map((row, index)=>[
|
|
179
|
+
row.node.path,
|
|
180
|
+
index
|
|
181
|
+
])), [
|
|
182
|
+
rows
|
|
183
|
+
]);
|
|
184
|
+
const { activePath, gridHandlers, trackEditor } = (0, external_treeGrid_cjs_namespaceObject.useTreeGrid)({
|
|
185
|
+
rows,
|
|
186
|
+
indexByPath,
|
|
187
|
+
collapsed,
|
|
188
|
+
toggle: onToggleCollapsed
|
|
189
|
+
});
|
|
190
|
+
const pinnedPaths = (0, external_react_namespaceObject.useMemo)(()=>[
|
|
191
|
+
...new Set([
|
|
192
|
+
editingPath,
|
|
193
|
+
jsonEditingPath,
|
|
194
|
+
activePath
|
|
195
|
+
].filter((path)=>null !== path))
|
|
196
|
+
], [
|
|
197
|
+
editingPath,
|
|
198
|
+
jsonEditingPath,
|
|
199
|
+
activePath
|
|
200
|
+
]);
|
|
201
|
+
const gridProps = {
|
|
202
|
+
...gridHandlers,
|
|
203
|
+
role: 'treegrid',
|
|
204
|
+
'aria-label': ariaLabelledBy ? void 0 : ariaLabel ?? strings.treeLabel,
|
|
205
|
+
'aria-labelledby': ariaLabelledBy,
|
|
206
|
+
'aria-readonly': !canEdit || void 0,
|
|
207
|
+
'aria-rowcount': rows.length
|
|
208
|
+
};
|
|
194
209
|
const templateItemLabel = strings.arrayItem;
|
|
195
210
|
const filtering = !!query?.trim() || !!filterPredicate;
|
|
196
211
|
const resolvedEmptyMessage = filtering ? strings.emptySearch : emptyMessage ?? strings.emptyDefault;
|
|
@@ -212,8 +227,9 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
212
227
|
jsonEditingPath,
|
|
213
228
|
wrappedPaths,
|
|
214
229
|
copied,
|
|
215
|
-
|
|
216
|
-
|
|
230
|
+
activePath,
|
|
231
|
+
setEditingPath: trackEditor('leaf', setEditingPath),
|
|
232
|
+
setJsonEditingPath: trackEditor('json', setJsonEditingPath),
|
|
217
233
|
copyPath,
|
|
218
234
|
copyValue,
|
|
219
235
|
toggleWrapped,
|
|
@@ -226,15 +242,27 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
226
242
|
ref: setContainer,
|
|
227
243
|
className: (0, index_cjs_namespaceObject.cn)(usesAncestorScroller ? 'overflow-x-clip' : 'h-full overflow-y-auto overflow-x-hidden', virtualized && !usesAncestorScroller && 'max-h-screen', virtualized && '[overflow-anchor:none]', className),
|
|
228
244
|
children: [
|
|
229
|
-
|
|
245
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
246
|
+
role: "status",
|
|
247
|
+
className: "sr-only",
|
|
248
|
+
children: copied && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
249
|
+
children: 'path' === copied.kind ? strings.pathCopied : strings.valueCopied
|
|
250
|
+
}, copied.id)
|
|
251
|
+
}),
|
|
252
|
+
rows.length > 0 && (virtualized ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(VirtualRows, {
|
|
230
253
|
rows: rows,
|
|
254
|
+
indexByPath: indexByPath,
|
|
231
255
|
container: container,
|
|
232
256
|
scrollElement: scrollElement,
|
|
233
|
-
pinnedPaths: pinnedPaths
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
pinnedPaths: pinnedPaths,
|
|
258
|
+
gridProps: gridProps
|
|
259
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
260
|
+
...gridProps,
|
|
261
|
+
children: rows.map((row, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTreeRow_cjs_namespaceObject.JsonTreeRow, {
|
|
262
|
+
row: row,
|
|
263
|
+
index: index
|
|
264
|
+
}, row.node.path))
|
|
265
|
+
})),
|
|
238
266
|
0 === rows.length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
239
267
|
className: "p-4 text-center text-xs text-foreground-subtle",
|
|
240
268
|
children: resolvedEmptyMessage
|
|
@@ -51,7 +51,8 @@ export interface JsonTreeViewProps {
|
|
|
51
51
|
* for values with thousands of fields. Rows are measured, so wrapped values
|
|
52
52
|
* and inline editors keep their height. The tree scrolls inside its own box,
|
|
53
53
|
* capped at the viewport height, unless `scrollElement` names the scroller.
|
|
54
|
-
*
|
|
54
|
+
* Also keeps arrow-key navigation quick in large trees, since each focus move
|
|
55
|
+
* re-renders the mounted rows. Off by default.
|
|
55
56
|
*/
|
|
56
57
|
virtualized?: boolean;
|
|
57
58
|
/**
|
|
@@ -70,6 +71,10 @@ export interface JsonTreeViewProps {
|
|
|
70
71
|
strings?: Partial<JsonTreeViewStrings>;
|
|
71
72
|
/** Extra classes for every tooltip panel (e.g. a z-index above a host's overlays). */
|
|
72
73
|
tooltipContentClassName?: string;
|
|
74
|
+
/** Accessible name of the tree grid. Defaults to the `treeLabel` string. */
|
|
75
|
+
'aria-label'?: string;
|
|
76
|
+
/** Id of a visible heading naming the tree grid; takes precedence over `aria-label`. */
|
|
77
|
+
'aria-labelledby'?: string;
|
|
73
78
|
className?: string;
|
|
74
79
|
}
|
|
75
80
|
/**
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3
|
-
import { useCallback, useEffect,
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "../../../lib/index.js";
|
|
5
5
|
import { copyTextToClipboard } from "../../../lib/clipboard.js";
|
|
6
|
+
import { useIsomorphicLayoutEffect } from "../../../lib/use-isomorphic-layout-effect.js";
|
|
6
7
|
import { flattenJsonTree } from "./buildJsonTree.js";
|
|
7
8
|
import { JsonTreeRow, JsonTreeRowContextProvider, ROW_MIN_HEIGHT_PX } from "./JsonTreeRow.js";
|
|
8
9
|
import { JsonTreeTooltipProvider } from "./JsonTreeTooltip.js";
|
|
9
10
|
import { JsonTreeViewProvider, useJsonTreeViewStrings } from "./strings.js";
|
|
10
|
-
|
|
11
|
+
import { useTreeGrid } from "./treeGrid.js";
|
|
11
12
|
const VIRTUAL_OVERSCAN = 10;
|
|
12
13
|
function scrollMarginOf(element, scrollElement) {
|
|
13
14
|
return Math.round(element.getBoundingClientRect().top - scrollElement.getBoundingClientRect().top + scrollElement.scrollTop);
|
|
14
15
|
}
|
|
15
|
-
function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
16
|
+
function VirtualRows({ rows, indexByPath, container, scrollElement, pinnedPaths, gridProps }) {
|
|
16
17
|
const [scrollMargin, setScrollMargin] = useState(0);
|
|
17
18
|
const getItemKey = useCallback((index)=>rows[index]?.node.path ?? index, [
|
|
18
19
|
rows
|
|
@@ -34,21 +35,11 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
34
35
|
const next = scrollMarginOf(container, scrollElement);
|
|
35
36
|
if (next !== scrollMargin) setScrollMargin(next);
|
|
36
37
|
});
|
|
37
|
-
const isPinning = pinnedPaths.length > 0;
|
|
38
|
-
const indexByPath = useMemo(()=>{
|
|
39
|
-
if (!isPinning) return;
|
|
40
|
-
const byPath = new Map();
|
|
41
|
-
for (const [index, row] of rows.entries())byPath.set(row.node.path, index);
|
|
42
|
-
return byPath;
|
|
43
|
-
}, [
|
|
44
|
-
isPinning,
|
|
45
|
-
rows
|
|
46
|
-
]);
|
|
47
38
|
const items = virtualizer.getVirtualItems();
|
|
48
39
|
const firstWindowed = items[0]?.index ?? -1;
|
|
49
40
|
const lastWindowed = items[items.length - 1]?.index ?? -2;
|
|
50
41
|
const pinnedItems = [];
|
|
51
|
-
|
|
42
|
+
for (const path of pinnedPaths){
|
|
52
43
|
const index = indexByPath.get(path);
|
|
53
44
|
if (void 0 === index || index >= firstWindowed && index <= lastWindowed) continue;
|
|
54
45
|
const measurement = virtualizer.measurementsCache[index];
|
|
@@ -60,6 +51,7 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
60
51
|
...pinnedItems.filter((item)=>item.index > lastWindowed)
|
|
61
52
|
];
|
|
62
53
|
return /*#__PURE__*/ jsx("div", {
|
|
54
|
+
...gridProps,
|
|
63
55
|
className: "relative",
|
|
64
56
|
style: {
|
|
65
57
|
height: virtualizer.getTotalSize()
|
|
@@ -75,8 +67,8 @@ function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
|
75
67
|
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
76
68
|
},
|
|
77
69
|
children: /*#__PURE__*/ jsx(JsonTreeRow, {
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
row: row,
|
|
71
|
+
index: item.index
|
|
80
72
|
})
|
|
81
73
|
}, item.key);
|
|
82
74
|
})
|
|
@@ -102,7 +94,7 @@ function JsonTreeView({ strings, tooltipContentClassName, ...props }) {
|
|
|
102
94
|
})
|
|
103
95
|
});
|
|
104
96
|
}
|
|
105
|
-
function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, virtualized = false, scrollElement, emptyMessage, className }) {
|
|
97
|
+
function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, virtualized = false, scrollElement, emptyMessage, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className }) {
|
|
106
98
|
const strings = useJsonTreeViewStrings();
|
|
107
99
|
const [container, setContainer] = useState(null);
|
|
108
100
|
const usesAncestorScroller = virtualized && !!scrollElement;
|
|
@@ -110,15 +102,6 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
110
102
|
const [editingPath, setEditingPath] = useState(null);
|
|
111
103
|
const [jsonEditingPath, setJsonEditingPath] = useState(null);
|
|
112
104
|
const [wrappedPaths, setWrappedPaths] = useState({});
|
|
113
|
-
const pinnedPaths = useMemo(()=>[
|
|
114
|
-
...new Set([
|
|
115
|
-
editingPath,
|
|
116
|
-
jsonEditingPath
|
|
117
|
-
].filter((path)=>null !== path))
|
|
118
|
-
], [
|
|
119
|
-
editingPath,
|
|
120
|
-
jsonEditingPath
|
|
121
|
-
]);
|
|
122
105
|
const [copied, setCopied] = useState(null);
|
|
123
106
|
const copyTimerRef = useRef(null);
|
|
124
107
|
useEffect(()=>()=>{
|
|
@@ -127,10 +110,11 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
127
110
|
const copy = (node, kind, text)=>{
|
|
128
111
|
copyTextToClipboard(text).then((ok)=>{
|
|
129
112
|
if (!ok) return;
|
|
130
|
-
setCopied({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
113
|
+
setCopied((prev)=>({
|
|
114
|
+
path: node.path,
|
|
115
|
+
kind,
|
|
116
|
+
id: (prev?.id ?? 0) + 1
|
|
117
|
+
}));
|
|
134
118
|
if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
|
|
135
119
|
copyTimerRef.current = setTimeout(()=>setCopied(null), 1500);
|
|
136
120
|
onCopy?.({
|
|
@@ -163,6 +147,37 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
163
147
|
filterPredicate,
|
|
164
148
|
decorateNode
|
|
165
149
|
]);
|
|
150
|
+
const indexByPath = useMemo(()=>new Map(rows.map((row, index)=>[
|
|
151
|
+
row.node.path,
|
|
152
|
+
index
|
|
153
|
+
])), [
|
|
154
|
+
rows
|
|
155
|
+
]);
|
|
156
|
+
const { activePath, gridHandlers, trackEditor } = useTreeGrid({
|
|
157
|
+
rows,
|
|
158
|
+
indexByPath,
|
|
159
|
+
collapsed,
|
|
160
|
+
toggle: onToggleCollapsed
|
|
161
|
+
});
|
|
162
|
+
const pinnedPaths = useMemo(()=>[
|
|
163
|
+
...new Set([
|
|
164
|
+
editingPath,
|
|
165
|
+
jsonEditingPath,
|
|
166
|
+
activePath
|
|
167
|
+
].filter((path)=>null !== path))
|
|
168
|
+
], [
|
|
169
|
+
editingPath,
|
|
170
|
+
jsonEditingPath,
|
|
171
|
+
activePath
|
|
172
|
+
]);
|
|
173
|
+
const gridProps = {
|
|
174
|
+
...gridHandlers,
|
|
175
|
+
role: 'treegrid',
|
|
176
|
+
'aria-label': ariaLabelledBy ? void 0 : ariaLabel ?? strings.treeLabel,
|
|
177
|
+
'aria-labelledby': ariaLabelledBy,
|
|
178
|
+
'aria-readonly': !canEdit || void 0,
|
|
179
|
+
'aria-rowcount': rows.length
|
|
180
|
+
};
|
|
166
181
|
const templateItemLabel = strings.arrayItem;
|
|
167
182
|
const filtering = !!query?.trim() || !!filterPredicate;
|
|
168
183
|
const resolvedEmptyMessage = filtering ? strings.emptySearch : emptyMessage ?? strings.emptyDefault;
|
|
@@ -184,8 +199,9 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
184
199
|
jsonEditingPath,
|
|
185
200
|
wrappedPaths,
|
|
186
201
|
copied,
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
activePath,
|
|
203
|
+
setEditingPath: trackEditor('leaf', setEditingPath),
|
|
204
|
+
setJsonEditingPath: trackEditor('json', setJsonEditingPath),
|
|
189
205
|
copyPath,
|
|
190
206
|
copyValue,
|
|
191
207
|
toggleWrapped,
|
|
@@ -198,15 +214,27 @@ function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query,
|
|
|
198
214
|
ref: setContainer,
|
|
199
215
|
className: cn(usesAncestorScroller ? 'overflow-x-clip' : 'h-full overflow-y-auto overflow-x-hidden', virtualized && !usesAncestorScroller && 'max-h-screen', virtualized && '[overflow-anchor:none]', className),
|
|
200
216
|
children: [
|
|
201
|
-
|
|
217
|
+
/*#__PURE__*/ jsx("span", {
|
|
218
|
+
role: "status",
|
|
219
|
+
className: "sr-only",
|
|
220
|
+
children: copied && /*#__PURE__*/ jsx("span", {
|
|
221
|
+
children: 'path' === copied.kind ? strings.pathCopied : strings.valueCopied
|
|
222
|
+
}, copied.id)
|
|
223
|
+
}),
|
|
224
|
+
rows.length > 0 && (virtualized ? /*#__PURE__*/ jsx(VirtualRows, {
|
|
202
225
|
rows: rows,
|
|
226
|
+
indexByPath: indexByPath,
|
|
203
227
|
container: container,
|
|
204
228
|
scrollElement: scrollElement,
|
|
205
|
-
pinnedPaths: pinnedPaths
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
229
|
+
pinnedPaths: pinnedPaths,
|
|
230
|
+
gridProps: gridProps
|
|
231
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
232
|
+
...gridProps,
|
|
233
|
+
children: rows.map((row, index)=>/*#__PURE__*/ jsx(JsonTreeRow, {
|
|
234
|
+
row: row,
|
|
235
|
+
index: index
|
|
236
|
+
}, row.node.path))
|
|
237
|
+
})),
|
|
210
238
|
0 === rows.length && /*#__PURE__*/ jsx("span", {
|
|
211
239
|
className: "p-4 text-center text-xs text-foreground-subtle",
|
|
212
240
|
children: resolvedEmptyMessage
|
|
@@ -248,9 +248,14 @@ export interface JsonTreeChange {
|
|
|
248
248
|
previous?: JsonValue;
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
|
-
* Props passed to a custom row container. The wrapper
|
|
251
|
+
* Props passed to a custom row container. The wrapper is the row's visual line:
|
|
252
252
|
* render a single container applying `className`/`style` and `children`
|
|
253
253
|
* verbatim, plus whatever behavior you attach (e.g. dnd-kit drag listeners).
|
|
254
|
+
*
|
|
255
|
+
* It renders inside the tree grid's `row` element, which owns the row's role
|
|
256
|
+
* and keyboard focus, so don't give the wrapper a role or tabindex. dnd-kit's
|
|
257
|
+
* `attributes` add both (`role="button"`, `tabIndex={0}`); spread only its
|
|
258
|
+
* `listeners`.
|
|
254
259
|
*/
|
|
255
260
|
export interface JsonTreeRowWrapperProps {
|
|
256
261
|
node: JsonTreeNode;
|