@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
|
@@ -29,11 +29,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
ROW_MIN_HEIGHT_PX: ()=>ROW_MIN_HEIGHT_PX
|
|
30
30
|
});
|
|
31
31
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
-
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
33
|
-
const external_label_cjs_namespaceObject = require("../label.cjs");
|
|
34
32
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
35
33
|
const external_react_namespaceObject = require("react");
|
|
36
|
-
const
|
|
34
|
+
const external_label_cjs_namespaceObject = require("../label.cjs");
|
|
35
|
+
const index_cjs_namespaceObject = require("../../../lib/index.cjs");
|
|
37
36
|
const external_buildJsonTree_cjs_namespaceObject = require("./buildJsonTree.cjs");
|
|
38
37
|
const external_DecorationChip_cjs_namespaceObject = require("./DecorationChip.cjs");
|
|
39
38
|
const external_JsonContainerEditor_cjs_namespaceObject = require("./JsonContainerEditor.cjs");
|
|
@@ -42,15 +41,30 @@ const external_JsonTypeBadge_cjs_namespaceObject = require("./JsonTypeBadge.cjs"
|
|
|
42
41
|
const external_NodeKey_cjs_namespaceObject = require("./NodeKey.cjs");
|
|
43
42
|
const external_RowActions_cjs_namespaceObject = require("./RowActions.cjs");
|
|
44
43
|
const external_ScalarValueCell_cjs_namespaceObject = require("./ScalarValueCell.cjs");
|
|
44
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
45
|
+
const external_treeGrid_cjs_namespaceObject = require("./treeGrid.cjs");
|
|
45
46
|
const ROW_CLASS = 'group flex min-h-7 cursor-default items-center gap-2 py-1 pr-1 transition hover:bg-surface-overlay';
|
|
46
47
|
const ROW_MIN_HEIGHT_PX = 28;
|
|
47
48
|
const VALUE_CELL_CLASS = 'flex min-w-8 flex-1 items-center';
|
|
49
|
+
const NAME_CELL_CLASS = 'flex min-w-0 max-w-1/2 items-center gap-2';
|
|
50
|
+
const FOCUS_RING_CLASS = 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring';
|
|
51
|
+
const ROW_ELEMENT_CLASS = `group/row ${FOCUS_RING_CLASS}`;
|
|
48
52
|
function rowIndent(depth, extra = 0) {
|
|
49
53
|
return {
|
|
50
54
|
paddingLeft: `${8 + 16 * depth + extra}px`
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
57
|
const KEY_ALIGN_OFFSET = 44;
|
|
58
|
+
function GridCell({ cell, editing = false, className, ...props }) {
|
|
59
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
60
|
+
role: "gridcell",
|
|
61
|
+
"data-cell": cell,
|
|
62
|
+
tabIndex: -1,
|
|
63
|
+
"data-json-tree-editor": editing ? '' : void 0,
|
|
64
|
+
className: (0, index_cjs_namespaceObject.cn)(FOCUS_RING_CLASS, className),
|
|
65
|
+
...props
|
|
66
|
+
});
|
|
67
|
+
}
|
|
54
68
|
const JsonTreeRowContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
|
|
55
69
|
const JsonTreeRowContextProvider = JsonTreeRowContext.Provider;
|
|
56
70
|
function useJsonTreeRowContext() {
|
|
@@ -58,9 +72,11 @@ function useJsonTreeRowContext() {
|
|
|
58
72
|
if (!ctx) throw new Error('JsonTreeRow must be rendered inside a JsonTreeRowContext provider');
|
|
59
73
|
return ctx;
|
|
60
74
|
}
|
|
61
|
-
function JsonTreeRow({
|
|
75
|
+
function JsonTreeRow({ row, index }) {
|
|
76
|
+
const { node, depth } = row;
|
|
62
77
|
const strings = (0, external_strings_cjs_namespaceObject.useJsonTreeViewStrings)();
|
|
63
|
-
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();
|
|
78
|
+
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();
|
|
79
|
+
const isTabStop = activePath === node.path;
|
|
64
80
|
const buildDefaultActions = (node, flags)=>{
|
|
65
81
|
const actions = [];
|
|
66
82
|
if (flags.wrappable) actions.push({
|
|
@@ -127,7 +143,20 @@ function JsonTreeRow({ node, depth }) {
|
|
|
127
143
|
if (event.target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return;
|
|
128
144
|
onToggleCollapsed?.(node.path);
|
|
129
145
|
};
|
|
146
|
+
const collapsedHere = isContainer && (0, external_buildJsonTree_cjs_namespaceObject.isPathCollapsed)(collapsed, node.path);
|
|
147
|
+
const editingInline = editingPath === node.path && !wrapped;
|
|
148
|
+
const showsValue = !isContainer && !wrapped && !decoration?.hideValue && (null != customCell || !(readOnly && void 0 === node.value || isTemplate));
|
|
149
|
+
const editingDetail = wrapped && editingPath === node.path && canEdit || isContainer && jsonEditingPath === node.path;
|
|
130
150
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
151
|
+
role: "row",
|
|
152
|
+
"data-path": node.path,
|
|
153
|
+
tabIndex: isTabStop ? 0 : -1,
|
|
154
|
+
"aria-level": depth + 1,
|
|
155
|
+
"aria-posinset": row.posInSet,
|
|
156
|
+
"aria-setsize": row.setSize,
|
|
157
|
+
"aria-rowindex": index + 1,
|
|
158
|
+
"aria-expanded": (0, external_treeGrid_cjs_namespaceObject.isParentRow)(row) ? !collapsedHere : void 0,
|
|
159
|
+
className: ROW_ELEMENT_CLASS,
|
|
131
160
|
children: [
|
|
132
161
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(RowWrapper, {
|
|
133
162
|
node: node,
|
|
@@ -135,48 +164,56 @@ function JsonTreeRow({ node, depth }) {
|
|
|
135
164
|
style: rowIndent(depth),
|
|
136
165
|
onClick: rowClickable ? handleRowClick : void 0,
|
|
137
166
|
children: [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(GridCell, {
|
|
168
|
+
cell: "name",
|
|
169
|
+
className: NAME_CELL_CLASS,
|
|
170
|
+
children: [
|
|
171
|
+
isContainer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
172
|
+
type: "button",
|
|
173
|
+
tabIndex: -1,
|
|
174
|
+
"data-json-tree-skip": "",
|
|
175
|
+
onClick: ()=>onToggleCollapsed?.(node.path),
|
|
176
|
+
disabled: !onToggleCollapsed,
|
|
177
|
+
"aria-label": collapsedHere ? strings.expandKey(node.key) : strings.collapseKey(node.key),
|
|
178
|
+
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",
|
|
179
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
|
|
180
|
+
size: 10,
|
|
181
|
+
className: (0, index_cjs_namespaceObject.cn)('transition-transform duration-100', collapsedHere && '-rotate-90')
|
|
182
|
+
})
|
|
183
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
184
|
+
className: "size-2.5 shrink-0"
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTypeBadge_cjs_namespaceObject.JsonTypeBadge, {
|
|
187
|
+
type: node.type,
|
|
188
|
+
icon: decoration?.badge?.icon ?? deriveTypeIcon?.(node),
|
|
189
|
+
className: decoration?.badge?.className,
|
|
190
|
+
reference: decoration?.badge?.reference
|
|
191
|
+
}),
|
|
192
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodeKey_cjs_namespaceObject.NodeKey, {
|
|
193
|
+
node: node,
|
|
194
|
+
label: isTemplateItem ? templateItemLabel : decoration?.label,
|
|
195
|
+
displayPath: pathForCopy?.(node.path, node.segments) ?? node.path,
|
|
196
|
+
onCopyPath: copyPath,
|
|
197
|
+
className: isTemplateItem ? 'font-normal italic text-foreground-subtle' : void 0
|
|
198
|
+
}),
|
|
199
|
+
copied?.path === node.path && 'path' === copied.kind && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleCheck, {
|
|
200
|
+
size: 11,
|
|
201
|
+
className: "shrink-0 text-brand",
|
|
202
|
+
"aria-hidden": true
|
|
203
|
+
}),
|
|
204
|
+
decoration?.sublabel && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
205
|
+
className: (0, index_cjs_namespaceObject.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'),
|
|
206
|
+
children: decoration.sublabel
|
|
207
|
+
}),
|
|
208
|
+
node.required && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.RequiredIndicator, {
|
|
209
|
+
className: "ml-0 shrink-0 text-[10px] text-foreground",
|
|
210
|
+
srLabel: strings.requiredMarker
|
|
211
|
+
})
|
|
212
|
+
]
|
|
178
213
|
}),
|
|
179
|
-
isContainer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(
|
|
214
|
+
isContainer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(GridCell, {
|
|
215
|
+
cell: "value",
|
|
216
|
+
className: (0, index_cjs_namespaceObject.cn)('flex min-w-0 items-center gap-2', null != customCell && 'flex-1'),
|
|
180
217
|
children: [
|
|
181
218
|
!decoration?.hideCount && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
182
219
|
className: "shrink-0 whitespace-nowrap font-mono italic text-[10px] text-foreground-subtle",
|
|
@@ -188,56 +225,52 @@ function JsonTreeRow({ node, depth }) {
|
|
|
188
225
|
}),
|
|
189
226
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecorationChip_cjs_namespaceObject.DecorationChip, {
|
|
190
227
|
decoration: decoration
|
|
191
|
-
}),
|
|
192
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_RowActions_cjs_namespaceObject.RowActions, {
|
|
193
|
-
node: node,
|
|
194
|
-
actions: actions,
|
|
195
|
-
maxInline: maxInlineActions,
|
|
196
|
-
meta: decoration?.meta
|
|
197
228
|
})
|
|
198
229
|
]
|
|
199
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(
|
|
230
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(GridCell, {
|
|
231
|
+
cell: "value",
|
|
232
|
+
editing: editingInline,
|
|
233
|
+
className: (0, index_cjs_namespaceObject.cn)('flex flex-1 items-center gap-2', showsValue ? 'min-w-8' : 'min-w-0', showsValue && null == customCell && 'shrink-3'),
|
|
200
234
|
children: [
|
|
201
|
-
|
|
202
|
-
className: VALUE_CELL_CLASS,
|
|
203
|
-
children: customCell
|
|
204
|
-
}) : !(readOnly && void 0 === node.value || isTemplate) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
235
|
+
showsValue && (null != customCell ? customCell : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
205
236
|
children: [
|
|
206
237
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
207
238
|
className: "shrink-0 font-mono text-xs text-foreground-subtle",
|
|
208
239
|
children: "="
|
|
209
240
|
}),
|
|
210
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
211
|
-
className: (0, index_cjs_namespaceObject.cn)(VALUE_CELL_CLASS, 'shrink-3'),
|
|
212
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ScalarValueCell_cjs_namespaceObject.ScalarValueCell, {
|
|
213
|
-
node: node,
|
|
214
|
-
readOnly: readOnly,
|
|
215
|
-
editing: editingPath === node.path,
|
|
216
|
-
onStartEdit: (n)=>setEditingPath(n.path),
|
|
217
|
-
onStopEdit: ()=>setEditingPath(null),
|
|
218
|
-
onEdit: canEdit ? commitEdit : void 0
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
]
|
|
222
|
-
})),
|
|
223
|
-
editingPath !== node.path && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
224
|
-
children: [
|
|
225
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecorationChip_cjs_namespaceObject.DecorationChip, {
|
|
226
|
-
decoration: decoration
|
|
227
|
-
}),
|
|
228
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_RowActions_cjs_namespaceObject.RowActions, {
|
|
241
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ScalarValueCell_cjs_namespaceObject.ScalarValueCell, {
|
|
229
242
|
node: node,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
readOnly: readOnly,
|
|
244
|
+
editing: editingPath === node.path,
|
|
245
|
+
onStartEdit: (n)=>setEditingPath(n.path),
|
|
246
|
+
onStopEdit: ()=>setEditingPath(null),
|
|
247
|
+
onEdit: canEdit ? commitEdit : void 0
|
|
233
248
|
})
|
|
234
249
|
]
|
|
250
|
+
})),
|
|
251
|
+
editingPath !== node.path && decoration?.chip && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
252
|
+
className: "ml-auto flex min-w-0 items-center",
|
|
253
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecorationChip_cjs_namespaceObject.DecorationChip, {
|
|
254
|
+
decoration: decoration
|
|
255
|
+
})
|
|
235
256
|
})
|
|
236
257
|
]
|
|
258
|
+
}),
|
|
259
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GridCell, {
|
|
260
|
+
cell: "actions",
|
|
261
|
+
className: "ml-auto flex shrink-0 items-center gap-2",
|
|
262
|
+
children: (isContainer || editingPath !== node.path) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_RowActions_cjs_namespaceObject.RowActions, {
|
|
263
|
+
node: node,
|
|
264
|
+
actions: actions,
|
|
265
|
+
maxInline: maxInlineActions,
|
|
266
|
+
meta: decoration?.meta
|
|
267
|
+
})
|
|
237
268
|
})
|
|
238
269
|
]
|
|
239
270
|
}),
|
|
240
|
-
wrapped && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
271
|
+
wrapped && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GridCell, {
|
|
272
|
+
cell: "detail",
|
|
273
|
+
editing: editingDetail,
|
|
241
274
|
className: "pb-1.5 pr-3.5",
|
|
242
275
|
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
243
276
|
children: editingPath === node.path && canEdit ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonMultilineLeafEditor_cjs_namespaceObject.JsonMultilineLeafEditor, {
|
|
@@ -259,7 +292,9 @@ function JsonTreeRow({ node, depth }) {
|
|
|
259
292
|
})
|
|
260
293
|
})
|
|
261
294
|
}),
|
|
262
|
-
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
295
|
+
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(GridCell, {
|
|
296
|
+
cell: "detail",
|
|
297
|
+
editing: true,
|
|
263
298
|
className: "py-1.5 pr-3.5",
|
|
264
299
|
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
265
300
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonContainerEditor_cjs_namespaceObject.JsonContainerEditor, {
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { type FlatJsonTreeRow } from './buildJsonTree';
|
|
1
2
|
import type { CopyEvent, DeriveTypeIcon, JsonTreeNode, JsonTreeRowWrapper, JsonValue, NodeActionsResolver, NodeDecoration, PathForCopy, RenderCodeEditor, RenderValueCell } from './JsonTree.types';
|
|
2
3
|
/** `min-h-7` above (1.75rem) in px at the default root size: the virtualizer's estimate
|
|
3
4
|
* until each row is measured, so a different root size costs accuracy but not correctness. */
|
|
4
5
|
export declare const ROW_MIN_HEIGHT_PX = 28;
|
|
6
|
+
/** The last copy, for the inline confirmation and the tree's announcement. */
|
|
7
|
+
export interface JsonTreeCopyState {
|
|
8
|
+
path: string;
|
|
9
|
+
kind: CopyEvent['kind'];
|
|
10
|
+
/** Re-keys the announcement, so copying twice in a row is heard twice. */
|
|
11
|
+
id: number;
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
* Shared, node-invariant context every row needs: the tree config, the mutable
|
|
7
15
|
* edit/copy state, and the handlers that mutate it. Held once by `JsonTreeView` so
|
|
8
|
-
* each `JsonTreeRow` only takes its own `
|
|
16
|
+
* each `JsonTreeRow` only takes its own `row` and `index`.
|
|
9
17
|
*/
|
|
10
18
|
export interface JsonTreeRowContextValue {
|
|
11
19
|
collapsed: Record<string, boolean>;
|
|
@@ -26,10 +34,10 @@ export interface JsonTreeRowContextValue {
|
|
|
26
34
|
editingPath: string | null;
|
|
27
35
|
jsonEditingPath: string | null;
|
|
28
36
|
wrappedPaths: Record<string, boolean>;
|
|
29
|
-
copied:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
copied: JsonTreeCopyState | null;
|
|
38
|
+
/** The row holding the tree's single Tab stop. */
|
|
39
|
+
activePath: string | null;
|
|
40
|
+
/** Opening and closing an editor through these also moves focus into and back out of it. */
|
|
33
41
|
setEditingPath: (path: string | null) => void;
|
|
34
42
|
setJsonEditingPath: (path: string | null) => void;
|
|
35
43
|
copyPath: (node: JsonTreeNode) => void;
|
|
@@ -44,7 +52,7 @@ export declare const JsonTreeRowContextProvider: import("react").Provider<JsonTr
|
|
|
44
52
|
* plus the expanded wrapped-scalar and edit-as-JSON surfaces below it. All
|
|
45
53
|
* shared state and handlers come from `JsonTreeRowContext`.
|
|
46
54
|
*/
|
|
47
|
-
export declare function JsonTreeRow({
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
export declare function JsonTreeRow({ row, index }: {
|
|
56
|
+
row: FlatJsonTreeRow;
|
|
57
|
+
index: number;
|
|
50
58
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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
|