@uipath/apollo-wind 2.60.0 → 2.61.0
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 +13 -0
- package/dist/components/forms/field-actions.cjs +181 -0
- package/dist/components/forms/field-actions.d.ts +131 -0
- package/dist/components/forms/field-actions.js +129 -0
- package/dist/components/forms/field-control.cjs +415 -0
- package/dist/components/forms/field-control.d.ts +52 -0
- package/dist/components/forms/field-control.js +372 -0
- package/dist/components/forms/field-renderer.cjs +77 -420
- package/dist/components/forms/field-renderer.d.ts +2 -3
- package/dist/components/forms/field-renderer.js +78 -421
- package/dist/components/forms/form-designer.cjs +7 -1
- package/dist/components/forms/form-designer.js +7 -1
- package/dist/components/forms/form-schema.d.ts +121 -2
- package/dist/components/forms/form-strings.cjs +67 -0
- package/dist/components/forms/form-strings.d.ts +30 -0
- package/dist/components/forms/form-strings.js +30 -0
- package/dist/components/forms/index.cjs +53 -9
- package/dist/components/forms/index.d.ts +6 -1
- package/dist/components/forms/index.js +6 -1
- package/dist/components/forms/literal-value-context.cjs +37 -0
- package/dist/components/forms/literal-value-context.d.ts +5 -0
- package/dist/components/forms/literal-value-context.js +3 -0
- package/dist/components/forms/metadata-form.cjs +100 -21
- package/dist/components/forms/metadata-form.d.ts +5 -0
- package/dist/components/forms/metadata-form.js +101 -22
- package/dist/components/forms/mode-aware-field.cjs +589 -0
- package/dist/components/forms/mode-aware-field.d.ts +15 -0
- package/dist/components/forms/mode-aware-field.js +555 -0
- package/dist/components/forms/opaque-value.cjs +44 -0
- package/dist/components/forms/opaque-value.d.ts +7 -0
- package/dist/components/forms/opaque-value.js +7 -0
- package/dist/components/forms/rules-engine.cjs +13 -0
- package/dist/components/forms/rules-engine.js +13 -0
- package/dist/components/forms/schema-serializer.cjs +8 -0
- package/dist/components/forms/schema-serializer.js +8 -0
- package/dist/components/forms/string-list-field.cjs +36 -18
- package/dist/components/forms/string-list-field.d.ts +6 -0
- package/dist/components/forms/string-list-field.js +35 -20
- package/dist/components/forms/validation-converter.cjs +32 -2
- package/dist/components/forms/validation-converter.d.ts +17 -1
- package/dist/components/forms/validation-converter.js +30 -3
- package/dist/components/forms/value-modes.cjs +253 -0
- package/dist/components/forms/value-modes.d.ts +236 -0
- package/dist/components/forms/value-modes.js +180 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/boolean-radio-group.cjs +114 -0
- package/dist/components/ui/boolean-radio-group.d.ts +24 -0
- package/dist/components/ui/boolean-radio-group.js +77 -0
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +7 -7
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.cjs +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/field-addons/field-menu.cjs +1 -0
- package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
- package/dist/components/ui/field-addons/field-menu.js +1 -0
- package/dist/components/ui/field-addons/index.cjs +4 -0
- package/dist/components/ui/field-addons/index.d.ts +1 -0
- package/dist/components/ui/field-addons/index.js +2 -1
- package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
- package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
- package/dist/components/ui/form-field.cjs +2 -1
- package/dist/components/ui/form-field.d.ts +2 -0
- package/dist/components/ui/form-field.js +2 -1
- package/dist/components/ui/index.cjs +235 -191
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +4 -0
- package/dist/components/ui/input-group.cjs +6 -3
- package/dist/components/ui/input-group.d.ts +6 -5
- package/dist/components/ui/input-group.js +6 -3
- package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
- package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
- package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
- package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
- package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
- package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
- package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
- package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
- package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
- package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
- package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
- package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
- package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
- package/dist/components/ui/json-tree-view/RowActions.js +86 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
- package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
- package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
- package/dist/components/ui/json-tree-view/clipboard.js +29 -0
- package/dist/components/ui/json-tree-view/index.cjs +175 -0
- package/dist/components/ui/json-tree-view/index.d.ts +10 -0
- package/dist/components/ui/json-tree-view/index.js +11 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
- package/dist/components/ui/json-tree-view/strings.cjs +122 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
- package/dist/components/ui/json-tree-view/strings.js +79 -0
- package/dist/components/ui/prompt-value-control.cjs +70 -0
- package/dist/components/ui/prompt-value-control.d.ts +28 -0
- package/dist/components/ui/prompt-value-control.js +36 -0
- package/dist/components/ui/sheet.cjs +2 -2
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/textarea.cjs +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/components/ui/variable-value-control.cjs +98 -0
- package/dist/components/ui/variable-value-control.d.ts +35 -0
- package/dist/components/ui/variable-value-control.js +64 -0
- package/dist/index.cjs +145 -16
- package/dist/index.d.ts +21 -3
- package/dist/index.js +11 -2
- package/dist/lib/index.cjs +4 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/utils.cjs +21 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +18 -1
- package/dist/styles.css +278 -0
- package/dist/tailwind.css +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
JsonTreeRowContextProvider: ()=>JsonTreeRowContextProvider,
|
|
28
|
+
JsonTreeRow: ()=>JsonTreeRow,
|
|
29
|
+
ROW_MIN_HEIGHT_PX: ()=>ROW_MIN_HEIGHT_PX
|
|
30
|
+
});
|
|
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
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const external_strings_cjs_namespaceObject = require("./strings.cjs");
|
|
37
|
+
const external_buildJsonTree_cjs_namespaceObject = require("./buildJsonTree.cjs");
|
|
38
|
+
const external_DecorationChip_cjs_namespaceObject = require("./DecorationChip.cjs");
|
|
39
|
+
const external_JsonContainerEditor_cjs_namespaceObject = require("./JsonContainerEditor.cjs");
|
|
40
|
+
const external_JsonMultilineLeafEditor_cjs_namespaceObject = require("./JsonMultilineLeafEditor.cjs");
|
|
41
|
+
const external_JsonTypeBadge_cjs_namespaceObject = require("./JsonTypeBadge.cjs");
|
|
42
|
+
const external_NodeKey_cjs_namespaceObject = require("./NodeKey.cjs");
|
|
43
|
+
const external_RowActions_cjs_namespaceObject = require("./RowActions.cjs");
|
|
44
|
+
const external_ScalarValueCell_cjs_namespaceObject = require("./ScalarValueCell.cjs");
|
|
45
|
+
const ROW_CLASS = 'group flex min-h-7 cursor-default items-center gap-1.5 py-1 pr-1 transition hover:bg-surface-overlay';
|
|
46
|
+
const ROW_MIN_HEIGHT_PX = 28;
|
|
47
|
+
const VALUE_CELL_CLASS = 'flex min-w-8 flex-1 items-center';
|
|
48
|
+
function rowIndent(depth, extra = 0) {
|
|
49
|
+
return {
|
|
50
|
+
paddingLeft: `${6 + 12 * depth + extra}px`
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const KEY_ALIGN_OFFSET = 44;
|
|
54
|
+
const JsonTreeRowContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
|
|
55
|
+
const JsonTreeRowContextProvider = JsonTreeRowContext.Provider;
|
|
56
|
+
function useJsonTreeRowContext() {
|
|
57
|
+
const ctx = (0, external_react_namespaceObject.useContext)(JsonTreeRowContext);
|
|
58
|
+
if (!ctx) throw new Error('JsonTreeRow must be rendered inside a JsonTreeRowContext provider');
|
|
59
|
+
return ctx;
|
|
60
|
+
}
|
|
61
|
+
function JsonTreeRow({ node, depth }) {
|
|
62
|
+
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();
|
|
64
|
+
const buildDefaultActions = (node, flags)=>{
|
|
65
|
+
const actions = [];
|
|
66
|
+
if (flags.wrappable) actions.push({
|
|
67
|
+
id: 'wrap',
|
|
68
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.WrapText, {}),
|
|
69
|
+
active: flags.wrapped,
|
|
70
|
+
tooltip: flags.wrapped ? strings.unwrapValue : strings.wrapValue,
|
|
71
|
+
label: flags.wrapped ? strings.unwrapValueOf(node.key) : strings.wrapValueOf(node.key),
|
|
72
|
+
onSelect: ()=>toggleWrapped(node)
|
|
73
|
+
});
|
|
74
|
+
if (flags.isContainer && canEdit && !node.isArrayItemTemplate) actions.push({
|
|
75
|
+
id: 'edit-json',
|
|
76
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Pencil, {}),
|
|
77
|
+
tooltip: strings.editAsJson,
|
|
78
|
+
label: strings.editKeyAsJson(node.key),
|
|
79
|
+
onSelect: ()=>setJsonEditingPath(node.path)
|
|
80
|
+
});
|
|
81
|
+
if (flags.canCopyValue) actions.push({
|
|
82
|
+
id: 'copy-value',
|
|
83
|
+
icon: flags.copiedValue ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleCheck, {
|
|
84
|
+
className: "text-brand"
|
|
85
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Copy, {}),
|
|
86
|
+
tooltip: strings.copyValue,
|
|
87
|
+
label: strings.copyValueOf(node.key),
|
|
88
|
+
onSelect: ()=>copyValue(node)
|
|
89
|
+
});
|
|
90
|
+
return actions;
|
|
91
|
+
};
|
|
92
|
+
const isContainer = void 0 !== node.children;
|
|
93
|
+
const isTemplate = !!node.isArrayItemTemplate;
|
|
94
|
+
const isTemplateItem = (0, external_buildJsonTree_cjs_namespaceObject.isArrayItemTemplateRoot)(node);
|
|
95
|
+
const childCount = node.children?.filter((c)=>!(0, external_buildJsonTree_cjs_namespaceObject.isArrayItemTemplateRoot)(c)).length ?? 0;
|
|
96
|
+
const decoration = decorateNode?.(node);
|
|
97
|
+
const customCell = renderValue?.(node, {
|
|
98
|
+
readOnly,
|
|
99
|
+
commit: (value)=>commitEdit(node, value),
|
|
100
|
+
clear: ()=>commitEdit(node, void 0)
|
|
101
|
+
});
|
|
102
|
+
const canCopyValue = void 0 !== node.value;
|
|
103
|
+
const wrappable = !isContainer && null == customCell && void 0 !== node.value && 'boolean' !== node.type && !node.schema?.enum?.length;
|
|
104
|
+
const wrapped = wrappable && !!wrappedPaths[node.path];
|
|
105
|
+
const copiedValue = copied?.path === node.path && 'value' === copied.kind;
|
|
106
|
+
let builtDefaults;
|
|
107
|
+
const getDefaultActions = ()=>{
|
|
108
|
+
builtDefaults ??= buildDefaultActions(node, {
|
|
109
|
+
isContainer,
|
|
110
|
+
wrappable,
|
|
111
|
+
wrapped,
|
|
112
|
+
canCopyValue,
|
|
113
|
+
copiedValue
|
|
114
|
+
});
|
|
115
|
+
return builtDefaults;
|
|
116
|
+
};
|
|
117
|
+
const actions = nodeActions?.(node, {
|
|
118
|
+
readOnly,
|
|
119
|
+
get defaultActions () {
|
|
120
|
+
return getDefaultActions();
|
|
121
|
+
},
|
|
122
|
+
commit: (value)=>commitEdit(node, value),
|
|
123
|
+
clear: ()=>commitEdit(node, void 0)
|
|
124
|
+
}) ?? getDefaultActions();
|
|
125
|
+
const rowClickable = isContainer && !!onToggleCollapsed;
|
|
126
|
+
const handleRowClick = (event)=>{
|
|
127
|
+
if (event.target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return;
|
|
128
|
+
onToggleCollapsed?.(node.path);
|
|
129
|
+
};
|
|
130
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(RowWrapper, {
|
|
133
|
+
node: node,
|
|
134
|
+
className: (0, index_cjs_namespaceObject.cn)(ROW_CLASS, rowClickable && 'cursor-pointer'),
|
|
135
|
+
style: rowIndent(depth),
|
|
136
|
+
onClick: rowClickable ? handleRowClick : void 0,
|
|
137
|
+
children: [
|
|
138
|
+
isContainer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
139
|
+
type: "button",
|
|
140
|
+
onClick: ()=>onToggleCollapsed?.(node.path),
|
|
141
|
+
"aria-label": collapsed[node.path] ? strings.expandKey(node.key) : strings.collapseKey(node.key),
|
|
142
|
+
"aria-expanded": !collapsed[node.path],
|
|
143
|
+
className: "grid size-2.5 shrink-0 cursor-pointer place-items-center text-foreground-subtle transition hover:text-foreground",
|
|
144
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
|
|
145
|
+
size: 10,
|
|
146
|
+
className: (0, index_cjs_namespaceObject.cn)('transition-transform duration-100', collapsed[node.path] && '-rotate-90')
|
|
147
|
+
})
|
|
148
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
149
|
+
className: "size-2.5 shrink-0"
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonTypeBadge_cjs_namespaceObject.JsonTypeBadge, {
|
|
152
|
+
type: node.type,
|
|
153
|
+
icon: decoration?.badge?.icon ?? deriveTypeIcon?.(node),
|
|
154
|
+
className: decoration?.badge?.className
|
|
155
|
+
}),
|
|
156
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodeKey_cjs_namespaceObject.NodeKey, {
|
|
157
|
+
node: node,
|
|
158
|
+
label: isTemplateItem ? templateItemLabel : decoration?.label,
|
|
159
|
+
displayPath: pathForCopy?.(node.path) ?? node.path,
|
|
160
|
+
onCopyPath: copyPath,
|
|
161
|
+
className: isTemplateItem ? 'font-normal italic text-foreground-subtle' : void 0
|
|
162
|
+
}),
|
|
163
|
+
copied?.path === node.path && 'path' === copied.kind && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CircleCheck, {
|
|
164
|
+
size: 11,
|
|
165
|
+
className: "shrink-0 text-brand",
|
|
166
|
+
role: "img",
|
|
167
|
+
"aria-label": strings.pathCopied
|
|
168
|
+
}),
|
|
169
|
+
decoration?.sublabel && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
170
|
+
className: "min-w-0 truncate font-mono text-[10px] text-foreground-subtle leading-4",
|
|
171
|
+
children: decoration.sublabel
|
|
172
|
+
}),
|
|
173
|
+
node.required && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.RequiredIndicator, {
|
|
174
|
+
className: "ml-0 shrink-0 text-[10px] text-foreground",
|
|
175
|
+
srLabel: strings.requiredMarker
|
|
176
|
+
}),
|
|
177
|
+
isContainer ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
178
|
+
children: [
|
|
179
|
+
!decoration?.hideCount && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
180
|
+
className: "shrink-0 whitespace-nowrap font-mono italic text-[10px] text-foreground-subtle",
|
|
181
|
+
children: 'array' === node.type ? strings.itemCount(childCount) : strings.keyCount(childCount)
|
|
182
|
+
}),
|
|
183
|
+
null != customCell && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
184
|
+
className: VALUE_CELL_CLASS,
|
|
185
|
+
children: customCell
|
|
186
|
+
}),
|
|
187
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecorationChip_cjs_namespaceObject.DecorationChip, {
|
|
188
|
+
decoration: decoration
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_RowActions_cjs_namespaceObject.RowActions, {
|
|
191
|
+
node: node,
|
|
192
|
+
actions: actions,
|
|
193
|
+
maxInline: maxInlineActions
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
197
|
+
children: [
|
|
198
|
+
!wrapped && (null != customCell ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
199
|
+
className: VALUE_CELL_CLASS,
|
|
200
|
+
children: customCell
|
|
201
|
+
}) : !(readOnly && void 0 === node.value || isTemplate) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
202
|
+
children: [
|
|
203
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
204
|
+
className: "shrink-0 font-mono text-xs text-foreground-subtle",
|
|
205
|
+
children: "="
|
|
206
|
+
}),
|
|
207
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
208
|
+
className: (0, index_cjs_namespaceObject.cn)(VALUE_CELL_CLASS, 'shrink-3'),
|
|
209
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ScalarValueCell_cjs_namespaceObject.ScalarValueCell, {
|
|
210
|
+
node: node,
|
|
211
|
+
readOnly: readOnly,
|
|
212
|
+
editing: editingPath === node.path,
|
|
213
|
+
onStartEdit: (n)=>setEditingPath(n.path),
|
|
214
|
+
onStopEdit: ()=>setEditingPath(null),
|
|
215
|
+
onEdit: canEdit ? commitEdit : void 0
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})),
|
|
220
|
+
editingPath !== node.path && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
221
|
+
children: [
|
|
222
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DecorationChip_cjs_namespaceObject.DecorationChip, {
|
|
223
|
+
decoration: decoration
|
|
224
|
+
}),
|
|
225
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_RowActions_cjs_namespaceObject.RowActions, {
|
|
226
|
+
node: node,
|
|
227
|
+
actions: actions,
|
|
228
|
+
maxInline: maxInlineActions
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
}),
|
|
236
|
+
wrapped && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
237
|
+
className: "pb-1.5 pr-3.5",
|
|
238
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
239
|
+
children: editingPath === node.path && canEdit ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonMultilineLeafEditor_cjs_namespaceObject.JsonMultilineLeafEditor, {
|
|
240
|
+
node: node,
|
|
241
|
+
onCommit: (value)=>{
|
|
242
|
+
setEditingPath(null);
|
|
243
|
+
commitEdit(node, value);
|
|
244
|
+
},
|
|
245
|
+
onCancel: ()=>setEditingPath(null)
|
|
246
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
247
|
+
type: "button",
|
|
248
|
+
disabled: !canEdit,
|
|
249
|
+
onClick: ()=>setEditingPath(node.path),
|
|
250
|
+
"aria-label": strings.editValueOf(node.key),
|
|
251
|
+
title: canEdit ? strings.editHint : void 0,
|
|
252
|
+
className: (0, index_cjs_namespaceObject.cn)('w-full whitespace-pre-wrap break-all rounded text-left font-mono text-xs leading-5', canEdit && 'cursor-text', (0, external_ScalarValueCell_cjs_namespaceObject.valueColorClass)(node.type, node.value)),
|
|
253
|
+
children: (0, external_buildJsonTree_cjs_namespaceObject.formatLeafValue)(node.type, node.value, {
|
|
254
|
+
preserveStringWhitespace: true
|
|
255
|
+
})
|
|
256
|
+
})
|
|
257
|
+
}),
|
|
258
|
+
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
259
|
+
className: "py-1.5 pr-3.5",
|
|
260
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
261
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_JsonContainerEditor_cjs_namespaceObject.JsonContainerEditor, {
|
|
262
|
+
node: node,
|
|
263
|
+
onCommit: (value)=>{
|
|
264
|
+
setJsonEditingPath(null);
|
|
265
|
+
commitEdit(node, value);
|
|
266
|
+
},
|
|
267
|
+
onCancel: ()=>setJsonEditingPath(null),
|
|
268
|
+
renderCodeEditor: renderCodeEditor
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
exports.JsonTreeRow = __webpack_exports__.JsonTreeRow;
|
|
275
|
+
exports.JsonTreeRowContextProvider = __webpack_exports__.JsonTreeRowContextProvider;
|
|
276
|
+
exports.ROW_MIN_HEIGHT_PX = __webpack_exports__.ROW_MIN_HEIGHT_PX;
|
|
277
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
278
|
+
"JsonTreeRow",
|
|
279
|
+
"JsonTreeRowContextProvider",
|
|
280
|
+
"ROW_MIN_HEIGHT_PX"
|
|
281
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
282
|
+
Object.defineProperty(exports, '__esModule', {
|
|
283
|
+
value: true
|
|
284
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CopyEvent, DeriveTypeIcon, JsonTreeNode, JsonTreeRowWrapper, JsonValue, NodeActionsResolver, NodeDecoration, RenderCodeEditor, RenderValueCell } from './JsonTree.types';
|
|
2
|
+
/** `min-h-7` above (1.75rem) in px at the default root size: the virtualizer's estimate
|
|
3
|
+
* until each row is measured, so a different root size costs accuracy but not correctness. */
|
|
4
|
+
export declare const ROW_MIN_HEIGHT_PX = 28;
|
|
5
|
+
/**
|
|
6
|
+
* Shared, node-invariant context every row needs: the tree config, the mutable
|
|
7
|
+
* edit/copy state, and the handlers that mutate it. Held once by `JsonTreeView` so
|
|
8
|
+
* each `JsonTreeRow` only takes its own `node`/`depth`.
|
|
9
|
+
*/
|
|
10
|
+
export interface JsonTreeRowContextValue {
|
|
11
|
+
collapsed: Record<string, boolean>;
|
|
12
|
+
onToggleCollapsed?: (path: string) => void;
|
|
13
|
+
readOnly: boolean;
|
|
14
|
+
decorateNode?: (node: JsonTreeNode) => NodeDecoration | undefined;
|
|
15
|
+
deriveTypeIcon?: DeriveTypeIcon;
|
|
16
|
+
renderValue?: RenderValueCell;
|
|
17
|
+
nodeActions?: NodeActionsResolver;
|
|
18
|
+
maxInlineActions: number;
|
|
19
|
+
renderCodeEditor?: RenderCodeEditor;
|
|
20
|
+
pathForCopy?: (path: string) => string;
|
|
21
|
+
/** Editability is row-invariant (props only), so it is resolved once. */
|
|
22
|
+
canEdit: boolean;
|
|
23
|
+
RowWrapper: JsonTreeRowWrapper;
|
|
24
|
+
/** Localized label for the synthesized array-item preview row. */
|
|
25
|
+
templateItemLabel: string;
|
|
26
|
+
editingPath: string | null;
|
|
27
|
+
jsonEditingPath: string | null;
|
|
28
|
+
wrappedPaths: Record<string, boolean>;
|
|
29
|
+
copied: {
|
|
30
|
+
path: string;
|
|
31
|
+
kind: CopyEvent['kind'];
|
|
32
|
+
} | null;
|
|
33
|
+
setEditingPath: (path: string | null) => void;
|
|
34
|
+
setJsonEditingPath: (path: string | null) => void;
|
|
35
|
+
copyPath: (node: JsonTreeNode) => void;
|
|
36
|
+
copyValue: (node: JsonTreeNode) => void;
|
|
37
|
+
toggleWrapped: (node: JsonTreeNode) => void;
|
|
38
|
+
commitEdit: (node: JsonTreeNode, value: JsonValue | undefined) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare const JsonTreeRowContextProvider: import("react").Provider<JsonTreeRowContextValue | null>;
|
|
41
|
+
/**
|
|
42
|
+
* A single flattened tree row: the collapse chevron, type badge, field name,
|
|
43
|
+
* decorations, and either the value cell (leaf) or key/item count (container),
|
|
44
|
+
* plus the expanded wrapped-scalar and edit-as-JSON surfaces below it. All
|
|
45
|
+
* shared state and handlers come from `JsonTreeRowContext`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function JsonTreeRow({ node, depth }: {
|
|
48
|
+
node: JsonTreeNode;
|
|
49
|
+
depth: number;
|
|
50
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/index.js";
|
|
3
|
+
import { RequiredIndicator } from "../label.js";
|
|
4
|
+
import { ChevronDown, CircleCheck, Copy, Pencil, WrapText } from "lucide-react";
|
|
5
|
+
import { createContext, useContext } from "react";
|
|
6
|
+
import { useJsonTreeViewStrings } from "./strings.js";
|
|
7
|
+
import { formatLeafValue, isArrayItemTemplateRoot } from "./buildJsonTree.js";
|
|
8
|
+
import { DecorationChip } from "./DecorationChip.js";
|
|
9
|
+
import { JsonContainerEditor } from "./JsonContainerEditor.js";
|
|
10
|
+
import { JsonMultilineLeafEditor } from "./JsonMultilineLeafEditor.js";
|
|
11
|
+
import { JsonTypeBadge } from "./JsonTypeBadge.js";
|
|
12
|
+
import { NodeKey } from "./NodeKey.js";
|
|
13
|
+
import { RowActions } from "./RowActions.js";
|
|
14
|
+
import { ScalarValueCell, valueColorClass } from "./ScalarValueCell.js";
|
|
15
|
+
const ROW_CLASS = 'group flex min-h-7 cursor-default items-center gap-1.5 py-1 pr-1 transition hover:bg-surface-overlay';
|
|
16
|
+
const ROW_MIN_HEIGHT_PX = 28;
|
|
17
|
+
const VALUE_CELL_CLASS = 'flex min-w-8 flex-1 items-center';
|
|
18
|
+
function rowIndent(depth, extra = 0) {
|
|
19
|
+
return {
|
|
20
|
+
paddingLeft: `${6 + 12 * depth + extra}px`
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const KEY_ALIGN_OFFSET = 44;
|
|
24
|
+
const JsonTreeRowContext = /*#__PURE__*/ createContext(null);
|
|
25
|
+
const JsonTreeRowContextProvider = JsonTreeRowContext.Provider;
|
|
26
|
+
function useJsonTreeRowContext() {
|
|
27
|
+
const ctx = useContext(JsonTreeRowContext);
|
|
28
|
+
if (!ctx) throw new Error('JsonTreeRow must be rendered inside a JsonTreeRowContext provider');
|
|
29
|
+
return ctx;
|
|
30
|
+
}
|
|
31
|
+
function JsonTreeRow({ node, depth }) {
|
|
32
|
+
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();
|
|
34
|
+
const buildDefaultActions = (node, flags)=>{
|
|
35
|
+
const actions = [];
|
|
36
|
+
if (flags.wrappable) actions.push({
|
|
37
|
+
id: 'wrap',
|
|
38
|
+
icon: /*#__PURE__*/ jsx(WrapText, {}),
|
|
39
|
+
active: flags.wrapped,
|
|
40
|
+
tooltip: flags.wrapped ? strings.unwrapValue : strings.wrapValue,
|
|
41
|
+
label: flags.wrapped ? strings.unwrapValueOf(node.key) : strings.wrapValueOf(node.key),
|
|
42
|
+
onSelect: ()=>toggleWrapped(node)
|
|
43
|
+
});
|
|
44
|
+
if (flags.isContainer && canEdit && !node.isArrayItemTemplate) actions.push({
|
|
45
|
+
id: 'edit-json',
|
|
46
|
+
icon: /*#__PURE__*/ jsx(Pencil, {}),
|
|
47
|
+
tooltip: strings.editAsJson,
|
|
48
|
+
label: strings.editKeyAsJson(node.key),
|
|
49
|
+
onSelect: ()=>setJsonEditingPath(node.path)
|
|
50
|
+
});
|
|
51
|
+
if (flags.canCopyValue) actions.push({
|
|
52
|
+
id: 'copy-value',
|
|
53
|
+
icon: flags.copiedValue ? /*#__PURE__*/ jsx(CircleCheck, {
|
|
54
|
+
className: "text-brand"
|
|
55
|
+
}) : /*#__PURE__*/ jsx(Copy, {}),
|
|
56
|
+
tooltip: strings.copyValue,
|
|
57
|
+
label: strings.copyValueOf(node.key),
|
|
58
|
+
onSelect: ()=>copyValue(node)
|
|
59
|
+
});
|
|
60
|
+
return actions;
|
|
61
|
+
};
|
|
62
|
+
const isContainer = void 0 !== node.children;
|
|
63
|
+
const isTemplate = !!node.isArrayItemTemplate;
|
|
64
|
+
const isTemplateItem = isArrayItemTemplateRoot(node);
|
|
65
|
+
const childCount = node.children?.filter((c)=>!isArrayItemTemplateRoot(c)).length ?? 0;
|
|
66
|
+
const decoration = decorateNode?.(node);
|
|
67
|
+
const customCell = renderValue?.(node, {
|
|
68
|
+
readOnly,
|
|
69
|
+
commit: (value)=>commitEdit(node, value),
|
|
70
|
+
clear: ()=>commitEdit(node, void 0)
|
|
71
|
+
});
|
|
72
|
+
const canCopyValue = void 0 !== node.value;
|
|
73
|
+
const wrappable = !isContainer && null == customCell && void 0 !== node.value && 'boolean' !== node.type && !node.schema?.enum?.length;
|
|
74
|
+
const wrapped = wrappable && !!wrappedPaths[node.path];
|
|
75
|
+
const copiedValue = copied?.path === node.path && 'value' === copied.kind;
|
|
76
|
+
let builtDefaults;
|
|
77
|
+
const getDefaultActions = ()=>{
|
|
78
|
+
builtDefaults ??= buildDefaultActions(node, {
|
|
79
|
+
isContainer,
|
|
80
|
+
wrappable,
|
|
81
|
+
wrapped,
|
|
82
|
+
canCopyValue,
|
|
83
|
+
copiedValue
|
|
84
|
+
});
|
|
85
|
+
return builtDefaults;
|
|
86
|
+
};
|
|
87
|
+
const actions = nodeActions?.(node, {
|
|
88
|
+
readOnly,
|
|
89
|
+
get defaultActions () {
|
|
90
|
+
return getDefaultActions();
|
|
91
|
+
},
|
|
92
|
+
commit: (value)=>commitEdit(node, value),
|
|
93
|
+
clear: ()=>commitEdit(node, void 0)
|
|
94
|
+
}) ?? getDefaultActions();
|
|
95
|
+
const rowClickable = isContainer && !!onToggleCollapsed;
|
|
96
|
+
const handleRowClick = (event)=>{
|
|
97
|
+
if (event.target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return;
|
|
98
|
+
onToggleCollapsed?.(node.path);
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ jsxs(RowWrapper, {
|
|
103
|
+
node: node,
|
|
104
|
+
className: cn(ROW_CLASS, rowClickable && 'cursor-pointer'),
|
|
105
|
+
style: rowIndent(depth),
|
|
106
|
+
onClick: rowClickable ? handleRowClick : void 0,
|
|
107
|
+
children: [
|
|
108
|
+
isContainer ? /*#__PURE__*/ jsx("button", {
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: ()=>onToggleCollapsed?.(node.path),
|
|
111
|
+
"aria-label": collapsed[node.path] ? strings.expandKey(node.key) : strings.collapseKey(node.key),
|
|
112
|
+
"aria-expanded": !collapsed[node.path],
|
|
113
|
+
className: "grid size-2.5 shrink-0 cursor-pointer place-items-center text-foreground-subtle transition hover:text-foreground",
|
|
114
|
+
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
115
|
+
size: 10,
|
|
116
|
+
className: cn('transition-transform duration-100', collapsed[node.path] && '-rotate-90')
|
|
117
|
+
})
|
|
118
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
119
|
+
className: "size-2.5 shrink-0"
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsx(JsonTypeBadge, {
|
|
122
|
+
type: node.type,
|
|
123
|
+
icon: decoration?.badge?.icon ?? deriveTypeIcon?.(node),
|
|
124
|
+
className: decoration?.badge?.className
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ jsx(NodeKey, {
|
|
127
|
+
node: node,
|
|
128
|
+
label: isTemplateItem ? templateItemLabel : decoration?.label,
|
|
129
|
+
displayPath: pathForCopy?.(node.path) ?? node.path,
|
|
130
|
+
onCopyPath: copyPath,
|
|
131
|
+
className: isTemplateItem ? 'font-normal italic text-foreground-subtle' : void 0
|
|
132
|
+
}),
|
|
133
|
+
copied?.path === node.path && 'path' === copied.kind && /*#__PURE__*/ jsx(CircleCheck, {
|
|
134
|
+
size: 11,
|
|
135
|
+
className: "shrink-0 text-brand",
|
|
136
|
+
role: "img",
|
|
137
|
+
"aria-label": strings.pathCopied
|
|
138
|
+
}),
|
|
139
|
+
decoration?.sublabel && /*#__PURE__*/ jsx("span", {
|
|
140
|
+
className: "min-w-0 truncate font-mono text-[10px] text-foreground-subtle leading-4",
|
|
141
|
+
children: decoration.sublabel
|
|
142
|
+
}),
|
|
143
|
+
node.required && /*#__PURE__*/ jsx(RequiredIndicator, {
|
|
144
|
+
className: "ml-0 shrink-0 text-[10px] text-foreground",
|
|
145
|
+
srLabel: strings.requiredMarker
|
|
146
|
+
}),
|
|
147
|
+
isContainer ? /*#__PURE__*/ jsxs(Fragment, {
|
|
148
|
+
children: [
|
|
149
|
+
!decoration?.hideCount && /*#__PURE__*/ jsx("span", {
|
|
150
|
+
className: "shrink-0 whitespace-nowrap font-mono italic text-[10px] text-foreground-subtle",
|
|
151
|
+
children: 'array' === node.type ? strings.itemCount(childCount) : strings.keyCount(childCount)
|
|
152
|
+
}),
|
|
153
|
+
null != customCell && /*#__PURE__*/ jsx("span", {
|
|
154
|
+
className: VALUE_CELL_CLASS,
|
|
155
|
+
children: customCell
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ jsx(DecorationChip, {
|
|
158
|
+
decoration: decoration
|
|
159
|
+
}),
|
|
160
|
+
/*#__PURE__*/ jsx(RowActions, {
|
|
161
|
+
node: node,
|
|
162
|
+
actions: actions,
|
|
163
|
+
maxInline: maxInlineActions
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
167
|
+
children: [
|
|
168
|
+
!wrapped && (null != customCell ? /*#__PURE__*/ jsx("span", {
|
|
169
|
+
className: VALUE_CELL_CLASS,
|
|
170
|
+
children: customCell
|
|
171
|
+
}) : !(readOnly && void 0 === node.value || isTemplate) && /*#__PURE__*/ jsxs(Fragment, {
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ jsx("span", {
|
|
174
|
+
className: "shrink-0 font-mono text-xs text-foreground-subtle",
|
|
175
|
+
children: "="
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ jsx("span", {
|
|
178
|
+
className: cn(VALUE_CELL_CLASS, 'shrink-3'),
|
|
179
|
+
children: /*#__PURE__*/ jsx(ScalarValueCell, {
|
|
180
|
+
node: node,
|
|
181
|
+
readOnly: readOnly,
|
|
182
|
+
editing: editingPath === node.path,
|
|
183
|
+
onStartEdit: (n)=>setEditingPath(n.path),
|
|
184
|
+
onStopEdit: ()=>setEditingPath(null),
|
|
185
|
+
onEdit: canEdit ? commitEdit : void 0
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
})),
|
|
190
|
+
editingPath !== node.path && /*#__PURE__*/ jsxs(Fragment, {
|
|
191
|
+
children: [
|
|
192
|
+
/*#__PURE__*/ jsx(DecorationChip, {
|
|
193
|
+
decoration: decoration
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ jsx(RowActions, {
|
|
196
|
+
node: node,
|
|
197
|
+
actions: actions,
|
|
198
|
+
maxInline: maxInlineActions
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
}),
|
|
206
|
+
wrapped && /*#__PURE__*/ jsx("div", {
|
|
207
|
+
className: "pb-1.5 pr-3.5",
|
|
208
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
209
|
+
children: editingPath === node.path && canEdit ? /*#__PURE__*/ jsx(JsonMultilineLeafEditor, {
|
|
210
|
+
node: node,
|
|
211
|
+
onCommit: (value)=>{
|
|
212
|
+
setEditingPath(null);
|
|
213
|
+
commitEdit(node, value);
|
|
214
|
+
},
|
|
215
|
+
onCancel: ()=>setEditingPath(null)
|
|
216
|
+
}) : /*#__PURE__*/ jsx("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
disabled: !canEdit,
|
|
219
|
+
onClick: ()=>setEditingPath(node.path),
|
|
220
|
+
"aria-label": strings.editValueOf(node.key),
|
|
221
|
+
title: canEdit ? strings.editHint : void 0,
|
|
222
|
+
className: cn('w-full whitespace-pre-wrap break-all rounded text-left font-mono text-xs leading-5', canEdit && 'cursor-text', valueColorClass(node.type, node.value)),
|
|
223
|
+
children: formatLeafValue(node.type, node.value, {
|
|
224
|
+
preserveStringWhitespace: true
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
}),
|
|
228
|
+
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ jsx("div", {
|
|
229
|
+
className: "py-1.5 pr-3.5",
|
|
230
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
231
|
+
children: /*#__PURE__*/ jsx(JsonContainerEditor, {
|
|
232
|
+
node: node,
|
|
233
|
+
onCommit: (value)=>{
|
|
234
|
+
setJsonEditingPath(null);
|
|
235
|
+
commitEdit(node, value);
|
|
236
|
+
},
|
|
237
|
+
onCancel: ()=>setJsonEditingPath(null),
|
|
238
|
+
renderCodeEditor: renderCodeEditor
|
|
239
|
+
})
|
|
240
|
+
})
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
export { JsonTreeRow, JsonTreeRowContextProvider, ROW_MIN_HEIGHT_PX };
|