@uipath/apollo-wind 2.78.0 → 2.79.1
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/ui/index.cjs +32 -32
- package/dist/components/ui/input.cjs +1 -1
- package/dist/components/ui/input.d.ts +2 -1
- package/dist/components/ui/input.js +1 -1
- 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/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 +16 -13
- package/package.json +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "../../../lib/index.js";
|
|
3
|
-
import { RequiredIndicator } from "../label.js";
|
|
4
2
|
import { ChevronDown, CircleCheck, Copy, Pencil, WrapText } from "lucide-react";
|
|
5
3
|
import { createContext, useContext } from "react";
|
|
6
|
-
import {
|
|
4
|
+
import { RequiredIndicator } from "../label.js";
|
|
5
|
+
import { cn } from "../../../lib/index.js";
|
|
7
6
|
import { formatLeafValue, isArrayItemTemplateRoot, isPathCollapsed } from "./buildJsonTree.js";
|
|
8
7
|
import { DecorationChip } from "./DecorationChip.js";
|
|
9
8
|
import { JsonContainerEditor } from "./JsonContainerEditor.js";
|
|
@@ -12,15 +11,30 @@ import { JsonTypeBadge } from "./JsonTypeBadge.js";
|
|
|
12
11
|
import { NodeKey } from "./NodeKey.js";
|
|
13
12
|
import { RowActions } from "./RowActions.js";
|
|
14
13
|
import { ScalarValueCell, valueColorClass } from "./ScalarValueCell.js";
|
|
14
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
15
|
+
import { isParentRow } from "./treeGrid.js";
|
|
15
16
|
const ROW_CLASS = 'group flex min-h-7 cursor-default items-center gap-2 py-1 pr-1 transition hover:bg-surface-overlay';
|
|
16
17
|
const ROW_MIN_HEIGHT_PX = 28;
|
|
17
18
|
const VALUE_CELL_CLASS = 'flex min-w-8 flex-1 items-center';
|
|
19
|
+
const NAME_CELL_CLASS = 'flex min-w-0 max-w-1/2 items-center gap-2';
|
|
20
|
+
const FOCUS_RING_CLASS = 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring';
|
|
21
|
+
const ROW_ELEMENT_CLASS = `group/row ${FOCUS_RING_CLASS}`;
|
|
18
22
|
function rowIndent(depth, extra = 0) {
|
|
19
23
|
return {
|
|
20
24
|
paddingLeft: `${8 + 16 * depth + extra}px`
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
const KEY_ALIGN_OFFSET = 44;
|
|
28
|
+
function GridCell({ cell, editing = false, className, ...props }) {
|
|
29
|
+
return /*#__PURE__*/ jsx("div", {
|
|
30
|
+
role: "gridcell",
|
|
31
|
+
"data-cell": cell,
|
|
32
|
+
tabIndex: -1,
|
|
33
|
+
"data-json-tree-editor": editing ? '' : void 0,
|
|
34
|
+
className: cn(FOCUS_RING_CLASS, className),
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
24
38
|
const JsonTreeRowContext = /*#__PURE__*/ createContext(null);
|
|
25
39
|
const JsonTreeRowContextProvider = JsonTreeRowContext.Provider;
|
|
26
40
|
function useJsonTreeRowContext() {
|
|
@@ -28,9 +42,11 @@ function useJsonTreeRowContext() {
|
|
|
28
42
|
if (!ctx) throw new Error('JsonTreeRow must be rendered inside a JsonTreeRowContext provider');
|
|
29
43
|
return ctx;
|
|
30
44
|
}
|
|
31
|
-
function JsonTreeRow({
|
|
45
|
+
function JsonTreeRow({ row, index }) {
|
|
46
|
+
const { node, depth } = row;
|
|
32
47
|
const strings = useJsonTreeViewStrings();
|
|
33
|
-
const { collapsed, onToggleCollapsed, readOnly, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions, renderCodeEditor, pathForCopy, canEdit, RowWrapper, templateItemLabel, editingPath, jsonEditingPath, wrappedPaths, copied, setEditingPath, setJsonEditingPath, copyPath, copyValue, toggleWrapped, commitEdit } = useJsonTreeRowContext();
|
|
48
|
+
const { collapsed, onToggleCollapsed, readOnly, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions, renderCodeEditor, pathForCopy, canEdit, RowWrapper, templateItemLabel, editingPath, jsonEditingPath, wrappedPaths, copied, activePath, setEditingPath, setJsonEditingPath, copyPath, copyValue, toggleWrapped, commitEdit } = useJsonTreeRowContext();
|
|
49
|
+
const isTabStop = activePath === node.path;
|
|
34
50
|
const buildDefaultActions = (node, flags)=>{
|
|
35
51
|
const actions = [];
|
|
36
52
|
if (flags.wrappable) actions.push({
|
|
@@ -97,7 +113,20 @@ function JsonTreeRow({ node, depth }) {
|
|
|
97
113
|
if (event.target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return;
|
|
98
114
|
onToggleCollapsed?.(node.path);
|
|
99
115
|
};
|
|
116
|
+
const collapsedHere = isContainer && isPathCollapsed(collapsed, node.path);
|
|
117
|
+
const editingInline = editingPath === node.path && !wrapped;
|
|
118
|
+
const showsValue = !isContainer && !wrapped && !decoration?.hideValue && (null != customCell || !(readOnly && void 0 === node.value || isTemplate));
|
|
119
|
+
const editingDetail = wrapped && editingPath === node.path && canEdit || isContainer && jsonEditingPath === node.path;
|
|
100
120
|
return /*#__PURE__*/ jsxs("div", {
|
|
121
|
+
role: "row",
|
|
122
|
+
"data-path": node.path,
|
|
123
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
124
|
+
"aria-level": depth + 1,
|
|
125
|
+
"aria-posinset": row.posInSet,
|
|
126
|
+
"aria-setsize": row.setSize,
|
|
127
|
+
"aria-rowindex": index + 1,
|
|
128
|
+
"aria-expanded": isParentRow(row) ? !collapsedHere : void 0,
|
|
129
|
+
className: ROW_ELEMENT_CLASS,
|
|
101
130
|
children: [
|
|
102
131
|
/*#__PURE__*/ jsxs(RowWrapper, {
|
|
103
132
|
node: node,
|
|
@@ -105,48 +134,56 @@ function JsonTreeRow({ node, depth }) {
|
|
|
105
134
|
style: rowIndent(depth),
|
|
106
135
|
onClick: rowClickable ? handleRowClick : void 0,
|
|
107
136
|
children: [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
/*#__PURE__*/ jsxs(GridCell, {
|
|
138
|
+
cell: "name",
|
|
139
|
+
className: NAME_CELL_CLASS,
|
|
140
|
+
children: [
|
|
141
|
+
isContainer ? /*#__PURE__*/ jsx("button", {
|
|
142
|
+
type: "button",
|
|
143
|
+
tabIndex: -1,
|
|
144
|
+
"data-json-tree-skip": "",
|
|
145
|
+
onClick: ()=>onToggleCollapsed?.(node.path),
|
|
146
|
+
disabled: !onToggleCollapsed,
|
|
147
|
+
"aria-label": collapsedHere ? strings.expandKey(node.key) : strings.collapseKey(node.key),
|
|
148
|
+
className: "grid size-2.5 shrink-0 cursor-pointer place-items-center text-foreground-subtle transition hover:text-foreground disabled:cursor-default disabled:hover:text-foreground-subtle",
|
|
149
|
+
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
150
|
+
size: 10,
|
|
151
|
+
className: cn('transition-transform duration-100', collapsedHere && '-rotate-90')
|
|
152
|
+
})
|
|
153
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
154
|
+
className: "size-2.5 shrink-0"
|
|
155
|
+
}),
|
|
156
|
+
/*#__PURE__*/ jsx(JsonTypeBadge, {
|
|
157
|
+
type: node.type,
|
|
158
|
+
icon: decoration?.badge?.icon ?? deriveTypeIcon?.(node),
|
|
159
|
+
className: decoration?.badge?.className,
|
|
160
|
+
reference: decoration?.badge?.reference
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ jsx(NodeKey, {
|
|
163
|
+
node: node,
|
|
164
|
+
label: isTemplateItem ? templateItemLabel : decoration?.label,
|
|
165
|
+
displayPath: pathForCopy?.(node.path, node.segments) ?? node.path,
|
|
166
|
+
onCopyPath: copyPath,
|
|
167
|
+
className: isTemplateItem ? 'font-normal italic text-foreground-subtle' : void 0
|
|
168
|
+
}),
|
|
169
|
+
copied?.path === node.path && 'path' === copied.kind && /*#__PURE__*/ jsx(CircleCheck, {
|
|
170
|
+
size: 11,
|
|
171
|
+
className: "shrink-0 text-brand",
|
|
172
|
+
"aria-hidden": true
|
|
173
|
+
}),
|
|
174
|
+
decoration?.sublabel && /*#__PURE__*/ jsx("span", {
|
|
175
|
+
className: cn('min-w-0 truncate font-mono text-[10px] text-foreground-subtle leading-4', decoration.sublabelOnHover && 'hidden group-hover:block group-focus-within/row:block'),
|
|
176
|
+
children: decoration.sublabel
|
|
177
|
+
}),
|
|
178
|
+
node.required && /*#__PURE__*/ jsx(RequiredIndicator, {
|
|
179
|
+
className: "ml-0 shrink-0 text-[10px] text-foreground",
|
|
180
|
+
srLabel: strings.requiredMarker
|
|
181
|
+
})
|
|
182
|
+
]
|
|
148
183
|
}),
|
|
149
|
-
isContainer ? /*#__PURE__*/ jsxs(
|
|
184
|
+
isContainer ? /*#__PURE__*/ jsxs(GridCell, {
|
|
185
|
+
cell: "value",
|
|
186
|
+
className: cn('flex min-w-0 items-center gap-2', null != customCell && 'flex-1'),
|
|
150
187
|
children: [
|
|
151
188
|
!decoration?.hideCount && /*#__PURE__*/ jsx("span", {
|
|
152
189
|
className: "shrink-0 whitespace-nowrap font-mono italic text-[10px] text-foreground-subtle",
|
|
@@ -158,56 +195,52 @@ function JsonTreeRow({ node, depth }) {
|
|
|
158
195
|
}),
|
|
159
196
|
/*#__PURE__*/ jsx(DecorationChip, {
|
|
160
197
|
decoration: decoration
|
|
161
|
-
}),
|
|
162
|
-
/*#__PURE__*/ jsx(RowActions, {
|
|
163
|
-
node: node,
|
|
164
|
-
actions: actions,
|
|
165
|
-
maxInline: maxInlineActions,
|
|
166
|
-
meta: decoration?.meta
|
|
167
198
|
})
|
|
168
199
|
]
|
|
169
|
-
}) : /*#__PURE__*/ jsxs(
|
|
200
|
+
}) : /*#__PURE__*/ jsxs(GridCell, {
|
|
201
|
+
cell: "value",
|
|
202
|
+
editing: editingInline,
|
|
203
|
+
className: cn('flex flex-1 items-center gap-2', showsValue ? 'min-w-8' : 'min-w-0', showsValue && null == customCell && 'shrink-3'),
|
|
170
204
|
children: [
|
|
171
|
-
|
|
172
|
-
className: VALUE_CELL_CLASS,
|
|
173
|
-
children: customCell
|
|
174
|
-
}) : !(readOnly && void 0 === node.value || isTemplate) && /*#__PURE__*/ jsxs(Fragment, {
|
|
205
|
+
showsValue && (null != customCell ? customCell : /*#__PURE__*/ jsxs(Fragment, {
|
|
175
206
|
children: [
|
|
176
207
|
/*#__PURE__*/ jsx("span", {
|
|
177
208
|
className: "shrink-0 font-mono text-xs text-foreground-subtle",
|
|
178
209
|
children: "="
|
|
179
210
|
}),
|
|
180
|
-
/*#__PURE__*/ jsx(
|
|
181
|
-
className: cn(VALUE_CELL_CLASS, 'shrink-3'),
|
|
182
|
-
children: /*#__PURE__*/ jsx(ScalarValueCell, {
|
|
183
|
-
node: node,
|
|
184
|
-
readOnly: readOnly,
|
|
185
|
-
editing: editingPath === node.path,
|
|
186
|
-
onStartEdit: (n)=>setEditingPath(n.path),
|
|
187
|
-
onStopEdit: ()=>setEditingPath(null),
|
|
188
|
-
onEdit: canEdit ? commitEdit : void 0
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
]
|
|
192
|
-
})),
|
|
193
|
-
editingPath !== node.path && /*#__PURE__*/ jsxs(Fragment, {
|
|
194
|
-
children: [
|
|
195
|
-
/*#__PURE__*/ jsx(DecorationChip, {
|
|
196
|
-
decoration: decoration
|
|
197
|
-
}),
|
|
198
|
-
/*#__PURE__*/ jsx(RowActions, {
|
|
211
|
+
/*#__PURE__*/ jsx(ScalarValueCell, {
|
|
199
212
|
node: node,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
readOnly: readOnly,
|
|
214
|
+
editing: editingPath === node.path,
|
|
215
|
+
onStartEdit: (n)=>setEditingPath(n.path),
|
|
216
|
+
onStopEdit: ()=>setEditingPath(null),
|
|
217
|
+
onEdit: canEdit ? commitEdit : void 0
|
|
203
218
|
})
|
|
204
219
|
]
|
|
220
|
+
})),
|
|
221
|
+
editingPath !== node.path && decoration?.chip && /*#__PURE__*/ jsx("span", {
|
|
222
|
+
className: "ml-auto flex min-w-0 items-center",
|
|
223
|
+
children: /*#__PURE__*/ jsx(DecorationChip, {
|
|
224
|
+
decoration: decoration
|
|
225
|
+
})
|
|
205
226
|
})
|
|
206
227
|
]
|
|
228
|
+
}),
|
|
229
|
+
/*#__PURE__*/ jsx(GridCell, {
|
|
230
|
+
cell: "actions",
|
|
231
|
+
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
232
|
+
children: (isContainer || editingPath !== node.path) && /*#__PURE__*/ jsx(RowActions, {
|
|
233
|
+
node: node,
|
|
234
|
+
actions: actions,
|
|
235
|
+
maxInline: maxInlineActions,
|
|
236
|
+
meta: decoration?.meta
|
|
237
|
+
})
|
|
207
238
|
})
|
|
208
239
|
]
|
|
209
240
|
}),
|
|
210
|
-
wrapped && /*#__PURE__*/ jsx(
|
|
241
|
+
wrapped && /*#__PURE__*/ jsx(GridCell, {
|
|
242
|
+
cell: "detail",
|
|
243
|
+
editing: editingDetail,
|
|
211
244
|
className: "pb-1.5 pr-3.5",
|
|
212
245
|
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
213
246
|
children: editingPath === node.path && canEdit ? /*#__PURE__*/ jsx(JsonMultilineLeafEditor, {
|
|
@@ -229,7 +262,9 @@ function JsonTreeRow({ node, depth }) {
|
|
|
229
262
|
})
|
|
230
263
|
})
|
|
231
264
|
}),
|
|
232
|
-
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ jsx(
|
|
265
|
+
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ jsx(GridCell, {
|
|
266
|
+
cell: "detail",
|
|
267
|
+
editing: true,
|
|
233
268
|
className: "py-1.5 pr-3.5",
|
|
234
269
|
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
235
270
|
children: /*#__PURE__*/ jsx(JsonContainerEditor, {
|
|
@@ -28,13 +28,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
31
|
-
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
32
31
|
const external_JsonTreeTooltip_cjs_namespaceObject = require("./JsonTreeTooltip.cjs");
|
|
32
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
33
33
|
function NodeKey({ node, label, displayPath, onCopyPath, className }) {
|
|
34
34
|
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
35
35
|
const text = label ?? node.key;
|
|
36
36
|
const copyPathText = displayPath ?? node.path;
|
|
37
|
-
const keyClass = (0, index_cjs_namespaceObject.cn)('min-w-4
|
|
37
|
+
const keyClass = (0, index_cjs_namespaceObject.cn)('min-w-4 truncate text-xs text-foreground', null != label ? 'font-medium' : 'font-mono', void 0 === node.value && 'text-foreground-muted', className);
|
|
38
38
|
if (!onCopyPath) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
39
39
|
className: keyClass,
|
|
40
40
|
children: text
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../../lib/index.js";
|
|
3
|
-
import { useJsonTreeViewStrings } from "./strings.js";
|
|
4
3
|
import { JsonTreeTooltip } from "./JsonTreeTooltip.js";
|
|
4
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
5
5
|
function NodeKey({ node, label, displayPath, onCopyPath, className }) {
|
|
6
6
|
const strings = useJsonTreeViewStrings();
|
|
7
7
|
const text = label ?? node.key;
|
|
8
8
|
const copyPathText = displayPath ?? node.path;
|
|
9
|
-
const keyClass = cn('min-w-4
|
|
9
|
+
const keyClass = cn('min-w-4 truncate text-xs text-foreground', null != label ? 'font-medium' : 'font-mono', void 0 === node.value && 'text-foreground-muted', className);
|
|
10
10
|
if (!onCopyPath) return /*#__PURE__*/ jsx("span", {
|
|
11
11
|
className: keyClass,
|
|
12
12
|
children: text
|
|
@@ -27,14 +27,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
RowActions: ()=>RowActions
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
-
const external_button_cjs_namespaceObject = require("../button.cjs");
|
|
31
|
-
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
32
|
-
const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
|
|
33
30
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
34
31
|
const external_react_namespaceObject = require("react");
|
|
35
|
-
const
|
|
32
|
+
const external_button_cjs_namespaceObject = require("../button.cjs");
|
|
33
|
+
const external_dropdown_menu_cjs_namespaceObject = require("../dropdown-menu.cjs");
|
|
34
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
36
35
|
const external_JsonTreeTooltip_cjs_namespaceObject = require("./JsonTreeTooltip.cjs");
|
|
37
|
-
const
|
|
36
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
37
|
+
const ACTION_BUTTON_CLASS = 'shrink-0 rounded text-foreground-subtle opacity-0 hover:text-foreground hover:bg-surface-raised group-hover:opacity-100 group-focus-within/row:opacity-100';
|
|
38
38
|
const ACTION_TONE_CLASS = {
|
|
39
39
|
neutral: '',
|
|
40
40
|
info: 'text-info hover:text-info',
|
|
@@ -65,7 +65,7 @@ function RowActions({ node, actions, maxInline, meta }) {
|
|
|
65
65
|
})
|
|
66
66
|
}, action.id);
|
|
67
67
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
68
|
-
className: "
|
|
68
|
+
className: "flex shrink-0 items-center gap-0.5",
|
|
69
69
|
children: [
|
|
70
70
|
inline.filter((action)=>'start' === action.placement).map(renderInline),
|
|
71
71
|
null != meta && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button } from "../button.js";
|
|
3
|
-
import { cn } from "../../../lib/index.js";
|
|
4
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu.js";
|
|
5
2
|
import { MoreHorizontal } from "lucide-react";
|
|
6
3
|
import { useState } from "react";
|
|
7
|
-
import {
|
|
4
|
+
import { Button } from "../button.js";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu.js";
|
|
6
|
+
import { cn } from "../../../lib/index.js";
|
|
8
7
|
import { JsonTreeTooltip } from "./JsonTreeTooltip.js";
|
|
9
|
-
|
|
8
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
9
|
+
const ACTION_BUTTON_CLASS = 'shrink-0 rounded text-foreground-subtle opacity-0 hover:text-foreground hover:bg-surface-raised group-hover:opacity-100 group-focus-within/row:opacity-100';
|
|
10
10
|
const ACTION_TONE_CLASS = {
|
|
11
11
|
neutral: '',
|
|
12
12
|
info: 'text-info hover:text-info',
|
|
@@ -37,7 +37,7 @@ function RowActions({ node, actions, maxInline, meta }) {
|
|
|
37
37
|
})
|
|
38
38
|
}, action.id);
|
|
39
39
|
return /*#__PURE__*/ jsxs("span", {
|
|
40
|
-
className: "
|
|
40
|
+
className: "flex shrink-0 items-center gap-0.5",
|
|
41
41
|
children: [
|
|
42
42
|
inline.filter((action)=>'start' === action.placement).map(renderInline),
|
|
43
43
|
null != meta && /*#__PURE__*/ jsx("span", {
|
|
@@ -246,12 +246,31 @@ function flattenJsonTree(nodes, options = {}, depth = 0) {
|
|
|
246
246
|
if (filterPredicate && !selfPredicateMatch && !predicateMatches?.below.has(node)) continue;
|
|
247
247
|
rows.push({
|
|
248
248
|
node,
|
|
249
|
-
depth: nodeDepth
|
|
249
|
+
depth: nodeDepth,
|
|
250
|
+
posInSet: 0,
|
|
251
|
+
setSize: 0
|
|
250
252
|
});
|
|
251
253
|
if (node.children && !isPathCollapsed(collapsed, node.path)) pushChildren(node.children, nodeDepth + 1, selfQueryMatch ? '' : query, selfPredicateMatch ? void 0 : filterPredicate);
|
|
252
254
|
}
|
|
255
|
+
numberSiblingSets(rows, depth);
|
|
253
256
|
return rows;
|
|
254
257
|
}
|
|
258
|
+
function numberSiblingSets(rows, baseDepth) {
|
|
259
|
+
const openSets = [];
|
|
260
|
+
const close = (set)=>{
|
|
261
|
+
for (const [position, row] of set.entries()){
|
|
262
|
+
row.posInSet = position + 1;
|
|
263
|
+
row.setSize = set.length;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
for (const row of rows){
|
|
267
|
+
const level = row.depth - baseDepth;
|
|
268
|
+
for (const set of openSets.splice(level + 1))close(set);
|
|
269
|
+
openSets[level] ??= [];
|
|
270
|
+
openSets[level].push(row);
|
|
271
|
+
}
|
|
272
|
+
for (const set of openSets)close(set);
|
|
273
|
+
}
|
|
255
274
|
function collectContainerPaths(nodes, depth = 0) {
|
|
256
275
|
const paths = [];
|
|
257
276
|
const stack = [];
|
|
@@ -37,6 +37,10 @@ export declare function isArrayItemTemplateRoot(node: JsonTreeNode): boolean;
|
|
|
37
37
|
export interface FlatJsonTreeRow {
|
|
38
38
|
node: JsonTreeNode;
|
|
39
39
|
depth: number;
|
|
40
|
+
/** 1-based position among the visible siblings (`aria-posinset`). */
|
|
41
|
+
posInSet: number;
|
|
42
|
+
/** Number of visible siblings, this row included (`aria-setsize`). */
|
|
43
|
+
setSize: number;
|
|
40
44
|
}
|
|
41
45
|
/** Consumer display texts for a node, so search can match them alongside the raw key. */
|
|
42
46
|
export type NodeDisplayTexts = (node: JsonTreeNode) => {
|
|
@@ -206,12 +206,31 @@ function flattenJsonTree(nodes, options = {}, depth = 0) {
|
|
|
206
206
|
if (filterPredicate && !selfPredicateMatch && !predicateMatches?.below.has(node)) continue;
|
|
207
207
|
rows.push({
|
|
208
208
|
node,
|
|
209
|
-
depth: nodeDepth
|
|
209
|
+
depth: nodeDepth,
|
|
210
|
+
posInSet: 0,
|
|
211
|
+
setSize: 0
|
|
210
212
|
});
|
|
211
213
|
if (node.children && !isPathCollapsed(collapsed, node.path)) pushChildren(node.children, nodeDepth + 1, selfQueryMatch ? '' : query, selfPredicateMatch ? void 0 : filterPredicate);
|
|
212
214
|
}
|
|
215
|
+
numberSiblingSets(rows, depth);
|
|
213
216
|
return rows;
|
|
214
217
|
}
|
|
218
|
+
function numberSiblingSets(rows, baseDepth) {
|
|
219
|
+
const openSets = [];
|
|
220
|
+
const close = (set)=>{
|
|
221
|
+
for (const [position, row] of set.entries()){
|
|
222
|
+
row.posInSet = position + 1;
|
|
223
|
+
row.setSize = set.length;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
for (const row of rows){
|
|
227
|
+
const level = row.depth - baseDepth;
|
|
228
|
+
for (const set of openSets.splice(level + 1))close(set);
|
|
229
|
+
openSets[level] ??= [];
|
|
230
|
+
openSets[level].push(row);
|
|
231
|
+
}
|
|
232
|
+
for (const set of openSets)close(set);
|
|
233
|
+
}
|
|
215
234
|
function collectContainerPaths(nodes, depth = 0) {
|
|
216
235
|
const paths = [];
|
|
217
236
|
const stack = [];
|
|
@@ -33,6 +33,7 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
33
33
|
const external_react_namespaceObject = require("react");
|
|
34
34
|
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
35
35
|
const DEFAULT_JSON_TREE_VIEW_STRINGS = {
|
|
36
|
+
treeLabel: 'JSON fields',
|
|
36
37
|
arrayItem: 'item',
|
|
37
38
|
emptySearch: 'No fields match your search.',
|
|
38
39
|
emptyDefault: 'No fields to display.',
|
|
@@ -43,6 +44,7 @@ const DEFAULT_JSON_TREE_VIEW_STRINGS = {
|
|
|
43
44
|
requiredMarker: 'required',
|
|
44
45
|
referenceType: (typeLabel)=>`${typeLabel} · reference`,
|
|
45
46
|
pathCopied: 'Path copied',
|
|
47
|
+
valueCopied: 'Value copied',
|
|
46
48
|
copyPathHint: 'Click to copy this path',
|
|
47
49
|
copyPathFor: (path)=>`Copy path for ${path}`,
|
|
48
50
|
wrapValue: 'Wrap value',
|
|
@@ -6,6 +6,12 @@ import { type ReactNode } from 'react';
|
|
|
6
6
|
* `DEFAULT_JSON_TREE_VIEW_STRINGS`.
|
|
7
7
|
*/
|
|
8
8
|
export interface JsonTreeViewStrings {
|
|
9
|
+
/**
|
|
10
|
+
* Accessible name of the tree grid when the host passes no `aria-label` or
|
|
11
|
+
* `aria-labelledby`. Optional so catalogs written before it was added still
|
|
12
|
+
* type-check; falls back to the English default.
|
|
13
|
+
*/
|
|
14
|
+
treeLabel?: string;
|
|
9
15
|
/** Label for the synthesized array-item preview row. */
|
|
10
16
|
arrayItem: string;
|
|
11
17
|
emptySearch: string;
|
|
@@ -22,7 +28,13 @@ export interface JsonTreeViewStrings {
|
|
|
22
28
|
* back to the English default.
|
|
23
29
|
*/
|
|
24
30
|
referenceType?: (typeLabel: string) => string;
|
|
31
|
+
/** Announced to screen readers after a path is copied. */
|
|
25
32
|
pathCopied: string;
|
|
33
|
+
/**
|
|
34
|
+
* Announced to screen readers after a value is copied. Optional so catalogs
|
|
35
|
+
* written before it was added still type-check; falls back to the English default.
|
|
36
|
+
*/
|
|
37
|
+
valueCopied?: string;
|
|
26
38
|
copyPathHint: string;
|
|
27
39
|
copyPathFor: (path: string) => string;
|
|
28
40
|
wrapValue: string;
|
|
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
3
|
import { cn } from "../../../lib/index.js";
|
|
4
4
|
const DEFAULT_JSON_TREE_VIEW_STRINGS = {
|
|
5
|
+
treeLabel: 'JSON fields',
|
|
5
6
|
arrayItem: 'item',
|
|
6
7
|
emptySearch: 'No fields match your search.',
|
|
7
8
|
emptyDefault: 'No fields to display.',
|
|
@@ -12,6 +13,7 @@ const DEFAULT_JSON_TREE_VIEW_STRINGS = {
|
|
|
12
13
|
requiredMarker: 'required',
|
|
13
14
|
referenceType: (typeLabel)=>`${typeLabel} · reference`,
|
|
14
15
|
pathCopied: 'Path copied',
|
|
16
|
+
valueCopied: 'Value copied',
|
|
15
17
|
copyPathHint: 'Click to copy this path',
|
|
16
18
|
copyPathFor: (path)=>`Copy path for ${path}`,
|
|
17
19
|
wrapValue: 'Wrap value',
|