@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,219 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../../../lib/index.js";
|
|
5
|
+
import { flattenJsonTree } from "./buildJsonTree.js";
|
|
6
|
+
import { copyTextToClipboard } from "./clipboard.js";
|
|
7
|
+
import { JsonTreeRow, JsonTreeRowContextProvider, ROW_MIN_HEIGHT_PX } from "./JsonTreeRow.js";
|
|
8
|
+
import { JsonTreeTooltipProvider } from "./JsonTreeTooltip.js";
|
|
9
|
+
import { JsonTreeViewProvider, useJsonTreeViewStrings } from "./strings.js";
|
|
10
|
+
const useIsomorphicLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
|
|
11
|
+
const VIRTUAL_OVERSCAN = 10;
|
|
12
|
+
function scrollMarginOf(element, scrollElement) {
|
|
13
|
+
return Math.round(element.getBoundingClientRect().top - scrollElement.getBoundingClientRect().top + scrollElement.scrollTop);
|
|
14
|
+
}
|
|
15
|
+
function VirtualRows({ rows, container, scrollElement, pinnedPaths }) {
|
|
16
|
+
const [scrollMargin, setScrollMargin] = useState(0);
|
|
17
|
+
const getItemKey = useCallback((index)=>rows[index]?.node.path ?? index, [
|
|
18
|
+
rows
|
|
19
|
+
]);
|
|
20
|
+
const virtualizer = useVirtualizer({
|
|
21
|
+
count: rows.length,
|
|
22
|
+
getScrollElement: ()=>scrollElement ?? container,
|
|
23
|
+
estimateSize: ()=>ROW_MIN_HEIGHT_PX,
|
|
24
|
+
getItemKey,
|
|
25
|
+
overscan: VIRTUAL_OVERSCAN,
|
|
26
|
+
scrollMargin
|
|
27
|
+
});
|
|
28
|
+
useIsomorphicLayoutEffect(()=>{
|
|
29
|
+
if (!container || !scrollElement) {
|
|
30
|
+
if (0 !== scrollMargin) setScrollMargin(0);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (virtualizer.isScrolling) return;
|
|
34
|
+
const next = scrollMarginOf(container, scrollElement);
|
|
35
|
+
if (next !== scrollMargin) setScrollMargin(next);
|
|
36
|
+
});
|
|
37
|
+
const isPinning = pinnedPaths.length > 0;
|
|
38
|
+
const indexByPath = useMemo(()=>{
|
|
39
|
+
if (!isPinning) return;
|
|
40
|
+
const byPath = new Map();
|
|
41
|
+
for (const [index, row] of rows.entries())byPath.set(row.node.path, index);
|
|
42
|
+
return byPath;
|
|
43
|
+
}, [
|
|
44
|
+
isPinning,
|
|
45
|
+
rows
|
|
46
|
+
]);
|
|
47
|
+
const items = virtualizer.getVirtualItems();
|
|
48
|
+
const firstWindowed = items[0]?.index ?? -1;
|
|
49
|
+
const lastWindowed = items[items.length - 1]?.index ?? -2;
|
|
50
|
+
const pinnedItems = [];
|
|
51
|
+
if (indexByPath) for (const path of pinnedPaths){
|
|
52
|
+
const index = indexByPath.get(path);
|
|
53
|
+
if (void 0 === index || index >= firstWindowed && index <= lastWindowed) continue;
|
|
54
|
+
const measurement = virtualizer.measurementsCache[index];
|
|
55
|
+
if (measurement) pinnedItems.push(measurement);
|
|
56
|
+
}
|
|
57
|
+
const rendered = 0 === pinnedItems.length ? items : [
|
|
58
|
+
...pinnedItems.filter((item)=>item.index < firstWindowed),
|
|
59
|
+
...items,
|
|
60
|
+
...pinnedItems.filter((item)=>item.index > lastWindowed)
|
|
61
|
+
];
|
|
62
|
+
return /*#__PURE__*/ jsx("div", {
|
|
63
|
+
className: "relative",
|
|
64
|
+
style: {
|
|
65
|
+
height: virtualizer.getTotalSize()
|
|
66
|
+
},
|
|
67
|
+
children: rendered.map((item)=>{
|
|
68
|
+
const row = rows[item.index];
|
|
69
|
+
if (!row) return null;
|
|
70
|
+
return /*#__PURE__*/ jsx("div", {
|
|
71
|
+
"data-index": item.index,
|
|
72
|
+
ref: virtualizer.measureElement,
|
|
73
|
+
className: "absolute top-0 left-0 w-full",
|
|
74
|
+
style: {
|
|
75
|
+
transform: `translateY(${item.start - virtualizer.options.scrollMargin}px)`
|
|
76
|
+
},
|
|
77
|
+
children: /*#__PURE__*/ jsx(JsonTreeRow, {
|
|
78
|
+
node: row.node,
|
|
79
|
+
depth: row.depth
|
|
80
|
+
})
|
|
81
|
+
}, item.key);
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function valueAsText(node) {
|
|
86
|
+
if ('string' == typeof node.value) return node.value;
|
|
87
|
+
if (void 0 === node.value) return 'null';
|
|
88
|
+
return JSON.stringify(node.value, null, 2);
|
|
89
|
+
}
|
|
90
|
+
const DefaultRowWrapper = ({ className, style, onClick, children })=>/*#__PURE__*/ jsx("div", {
|
|
91
|
+
className: className,
|
|
92
|
+
style: style,
|
|
93
|
+
onClick: onClick,
|
|
94
|
+
children: children
|
|
95
|
+
});
|
|
96
|
+
function JsonTreeView({ strings, tooltipContentClassName, ...props }) {
|
|
97
|
+
return /*#__PURE__*/ jsx(JsonTreeViewProvider, {
|
|
98
|
+
strings: strings,
|
|
99
|
+
tooltipContentClassName: tooltipContentClassName,
|
|
100
|
+
children: /*#__PURE__*/ jsx(JsonTreeViewContent, {
|
|
101
|
+
...props
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function JsonTreeViewContent({ nodes, collapsed = {}, onToggleCollapsed, query, filterPredicate, readOnly = false, onEdit, rowWrapper, decorateNode, deriveTypeIcon, renderValue, nodeActions, maxInlineActions = 3, renderCodeEditor, pathForCopy, onCopy, virtualized = false, scrollElement, emptyMessage, className }) {
|
|
106
|
+
const strings = useJsonTreeViewStrings();
|
|
107
|
+
const [container, setContainer] = useState(null);
|
|
108
|
+
const usesAncestorScroller = virtualized && !!scrollElement;
|
|
109
|
+
const RowWrapper = rowWrapper ?? DefaultRowWrapper;
|
|
110
|
+
const [editingPath, setEditingPath] = useState(null);
|
|
111
|
+
const [jsonEditingPath, setJsonEditingPath] = useState(null);
|
|
112
|
+
const [wrappedPaths, setWrappedPaths] = useState({});
|
|
113
|
+
const pinnedPaths = useMemo(()=>[
|
|
114
|
+
...new Set([
|
|
115
|
+
editingPath,
|
|
116
|
+
jsonEditingPath
|
|
117
|
+
].filter((path)=>null !== path))
|
|
118
|
+
], [
|
|
119
|
+
editingPath,
|
|
120
|
+
jsonEditingPath
|
|
121
|
+
]);
|
|
122
|
+
const [copied, setCopied] = useState(null);
|
|
123
|
+
const copyTimerRef = useRef(null);
|
|
124
|
+
useEffect(()=>()=>{
|
|
125
|
+
if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
|
|
126
|
+
}, []);
|
|
127
|
+
const copy = (node, kind, text)=>{
|
|
128
|
+
copyTextToClipboard(text).then((ok)=>{
|
|
129
|
+
if (!ok) return;
|
|
130
|
+
setCopied({
|
|
131
|
+
path: node.path,
|
|
132
|
+
kind
|
|
133
|
+
});
|
|
134
|
+
if (copyTimerRef.current) clearTimeout(copyTimerRef.current);
|
|
135
|
+
copyTimerRef.current = setTimeout(()=>setCopied(null), 1500);
|
|
136
|
+
onCopy?.({
|
|
137
|
+
kind,
|
|
138
|
+
path: node.path,
|
|
139
|
+
text
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const copyPath = (node)=>copy(node, 'path', pathForCopy?.(node.path) ?? node.path);
|
|
144
|
+
const copyValue = (node)=>copy(node, 'value', valueAsText(node));
|
|
145
|
+
const toggleWrapped = (node)=>{
|
|
146
|
+
setWrappedPaths((prev)=>({
|
|
147
|
+
...prev,
|
|
148
|
+
[node.path]: !prev[node.path]
|
|
149
|
+
}));
|
|
150
|
+
if (editingPath === node.path) setEditingPath(null);
|
|
151
|
+
};
|
|
152
|
+
const commitEdit = (node, value)=>onEdit?.(node, value);
|
|
153
|
+
const canEdit = !readOnly && !!onEdit;
|
|
154
|
+
const rows = useMemo(()=>flattenJsonTree(nodes, {
|
|
155
|
+
collapsed,
|
|
156
|
+
query,
|
|
157
|
+
filterPredicate,
|
|
158
|
+
displayTexts: decorateNode
|
|
159
|
+
}), [
|
|
160
|
+
nodes,
|
|
161
|
+
collapsed,
|
|
162
|
+
query,
|
|
163
|
+
filterPredicate,
|
|
164
|
+
decorateNode
|
|
165
|
+
]);
|
|
166
|
+
const templateItemLabel = strings.arrayItem;
|
|
167
|
+
const filtering = !!query?.trim() || !!filterPredicate;
|
|
168
|
+
const resolvedEmptyMessage = filtering ? strings.emptySearch : emptyMessage ?? strings.emptyDefault;
|
|
169
|
+
const rowContext = {
|
|
170
|
+
collapsed,
|
|
171
|
+
onToggleCollapsed,
|
|
172
|
+
readOnly,
|
|
173
|
+
decorateNode,
|
|
174
|
+
deriveTypeIcon,
|
|
175
|
+
renderValue,
|
|
176
|
+
nodeActions,
|
|
177
|
+
maxInlineActions,
|
|
178
|
+
renderCodeEditor,
|
|
179
|
+
pathForCopy,
|
|
180
|
+
canEdit,
|
|
181
|
+
RowWrapper,
|
|
182
|
+
templateItemLabel,
|
|
183
|
+
editingPath,
|
|
184
|
+
jsonEditingPath,
|
|
185
|
+
wrappedPaths,
|
|
186
|
+
copied,
|
|
187
|
+
setEditingPath,
|
|
188
|
+
setJsonEditingPath,
|
|
189
|
+
copyPath,
|
|
190
|
+
copyValue,
|
|
191
|
+
toggleWrapped,
|
|
192
|
+
commitEdit
|
|
193
|
+
};
|
|
194
|
+
return /*#__PURE__*/ jsx(JsonTreeTooltipProvider, {
|
|
195
|
+
children: /*#__PURE__*/ jsx(JsonTreeRowContextProvider, {
|
|
196
|
+
value: rowContext,
|
|
197
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
198
|
+
ref: setContainer,
|
|
199
|
+
className: cn(usesAncestorScroller ? 'overflow-x-clip' : 'h-full overflow-y-auto overflow-x-hidden', virtualized && !usesAncestorScroller && 'max-h-screen', virtualized && '[overflow-anchor:none]', className),
|
|
200
|
+
children: [
|
|
201
|
+
virtualized ? /*#__PURE__*/ jsx(VirtualRows, {
|
|
202
|
+
rows: rows,
|
|
203
|
+
container: container,
|
|
204
|
+
scrollElement: scrollElement,
|
|
205
|
+
pinnedPaths: pinnedPaths
|
|
206
|
+
}) : rows.map(({ node, depth })=>/*#__PURE__*/ jsx(JsonTreeRow, {
|
|
207
|
+
node: node,
|
|
208
|
+
depth: depth
|
|
209
|
+
}, node.path)),
|
|
210
|
+
0 === rows.length && /*#__PURE__*/ jsx("span", {
|
|
211
|
+
className: "p-4 text-center text-xs text-foreground-subtle",
|
|
212
|
+
children: resolvedEmptyMessage
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export { JsonTreeView };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import type { ComponentType, CSSProperties, MouseEvent, ReactNode } from 'react';
|
|
2
|
+
/** Any JSON-serializable value. */
|
|
3
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
|
|
4
|
+
/** A JSON object (string keys, JSON values). */
|
|
5
|
+
export interface JsonObject {
|
|
6
|
+
[key: string]: JsonValue;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A JSON container: object or array. The value tree renders fields of a
|
|
10
|
+
* container, so its root value must be one of these (a scalar root has no
|
|
11
|
+
* fields to show).
|
|
12
|
+
*/
|
|
13
|
+
export type JsonContainer = JsonObject | JsonValue[];
|
|
14
|
+
/** JSON Schema `type` keyword values supported by the value tree. */
|
|
15
|
+
export type JsonSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
16
|
+
/**
|
|
17
|
+
* The subset of JSON Schema the value tree understands. Unknown keywords are
|
|
18
|
+
* ignored, so a full draft schema can be passed as-is.
|
|
19
|
+
*/
|
|
20
|
+
export interface JsonSchema {
|
|
21
|
+
type?: JsonSchemaTypeName | JsonSchemaTypeName[];
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Semantic format marker (e.g. `file`). Useful for custom value rendering. */
|
|
25
|
+
format?: string;
|
|
26
|
+
enum?: Array<string | number | boolean | null>;
|
|
27
|
+
default?: JsonValue;
|
|
28
|
+
properties?: Record<string, JsonSchema>;
|
|
29
|
+
required?: string[];
|
|
30
|
+
items?: JsonSchema;
|
|
31
|
+
additionalProperties?: boolean | JsonSchema;
|
|
32
|
+
}
|
|
33
|
+
/** Effective display type of a tree node (JSON value types). */
|
|
34
|
+
export type JsonTreeNodeType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
|
|
35
|
+
/** One step into a JSON value: an object key or an array index. */
|
|
36
|
+
export type PathSegment = string | number;
|
|
37
|
+
/** A node of the merged schema + value tree. */
|
|
38
|
+
export interface JsonTreeNode {
|
|
39
|
+
/** Display key (object key or array index as text). */
|
|
40
|
+
key: string;
|
|
41
|
+
/** Expression path, e.g. `httpRequest1.responseBody.items[0].id`. */
|
|
42
|
+
path: string;
|
|
43
|
+
/** Path as raw segments, usable with `setValueAtPath`/`getValueAtPath`. */
|
|
44
|
+
segments: PathSegment[];
|
|
45
|
+
/** Effective type: from the value when present, else from the schema. */
|
|
46
|
+
type: JsonTreeNodeType;
|
|
47
|
+
/**
|
|
48
|
+
* The value at this node. Undefined when the schema declares this node but
|
|
49
|
+
* the value does not set it (rendered as "unset").
|
|
50
|
+
*/
|
|
51
|
+
value?: JsonValue;
|
|
52
|
+
/** The schema node describing this position, when one exists. */
|
|
53
|
+
schema?: JsonSchema;
|
|
54
|
+
/** True when the schema lists this key in the parent's `required`. */
|
|
55
|
+
required?: boolean;
|
|
56
|
+
/** Present on object/array nodes (may be empty). */
|
|
57
|
+
children?: JsonTreeNode[];
|
|
58
|
+
/**
|
|
59
|
+
* True when this node belongs to a synthesized, read-only preview of an
|
|
60
|
+
* array's `items` schema. When an array has no real items, the tree surfaces
|
|
61
|
+
* the expected item shape by building one preview item from `items`; the flag
|
|
62
|
+
* is set on that item and every node beneath it. The preview is illustrative,
|
|
63
|
+
* so these nodes are not editable and the preview item is left out of the
|
|
64
|
+
* parent array's item count.
|
|
65
|
+
*/
|
|
66
|
+
isArrayItemTemplate?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** A consumer-provided row filter, offered in the toolbar's filter dropdown. */
|
|
69
|
+
export interface JsonTreeFilterOption {
|
|
70
|
+
id: string;
|
|
71
|
+
/** Label shown in the dropdown and on the trigger when active. */
|
|
72
|
+
label: string;
|
|
73
|
+
/**
|
|
74
|
+
* Rows are kept when the node (or any descendant) matches; a node that
|
|
75
|
+
* matches directly shows its whole subtree.
|
|
76
|
+
*/
|
|
77
|
+
predicate: (node: JsonTreeNode) => boolean;
|
|
78
|
+
/** Optional count shown next to the label. */
|
|
79
|
+
count?: number;
|
|
80
|
+
}
|
|
81
|
+
/** Visual tone for decoration chips. */
|
|
82
|
+
export type NodeDecorationTone = 'neutral' | 'info' | 'warning' | 'error';
|
|
83
|
+
/**
|
|
84
|
+
* Derives a custom type-badge icon for a node (e.g. a paperclip for
|
|
85
|
+
* `format: 'file'` schemas). Return undefined to keep the default type icon.
|
|
86
|
+
*/
|
|
87
|
+
export type DeriveTypeIcon = (node: JsonTreeNode) => ReactNode;
|
|
88
|
+
/** Chip annotation next to a node's key. Provide a label, an icon, or both. */
|
|
89
|
+
export interface NodeDecorationChip {
|
|
90
|
+
/** Pill text. Omit for a bare icon-only annotation. */
|
|
91
|
+
label?: string;
|
|
92
|
+
/** Icon rendered before the label (or alone when there is no label). */
|
|
93
|
+
icon?: ReactNode;
|
|
94
|
+
/** Tooltip shown on hover. */
|
|
95
|
+
tooltip?: string;
|
|
96
|
+
tone?: NodeDecorationTone;
|
|
97
|
+
}
|
|
98
|
+
/** Overrides for the row's type badge (the leading icon-in-a-box). */
|
|
99
|
+
export interface NodeDecorationBadge {
|
|
100
|
+
/** Replaces the type icon (wins over `deriveTypeIcon`). */
|
|
101
|
+
icon?: ReactNode;
|
|
102
|
+
/**
|
|
103
|
+
* Color classes for the badge chrome (border/bg/text), replacing the
|
|
104
|
+
* neutral default, e.g. `'border-info/30 bg-info/10 text-info'`.
|
|
105
|
+
*/
|
|
106
|
+
className?: string;
|
|
107
|
+
}
|
|
108
|
+
/** Consumer-provided visual annotation for a tree node. */
|
|
109
|
+
export interface NodeDecoration {
|
|
110
|
+
/**
|
|
111
|
+
* Display label rendered in place of the raw key. The raw key still drives
|
|
112
|
+
* paths, copying, and edits; search matches both.
|
|
113
|
+
*/
|
|
114
|
+
label?: string;
|
|
115
|
+
/** Small muted text after the key label (e.g. an identifier). */
|
|
116
|
+
sublabel?: string;
|
|
117
|
+
/** Replaces the type badge's icon and/or color. */
|
|
118
|
+
badge?: NodeDecorationBadge;
|
|
119
|
+
/** Small pill rendered next to the key (e.g. "mocked"). */
|
|
120
|
+
chip?: NodeDecorationChip;
|
|
121
|
+
/**
|
|
122
|
+
* Hides the built-in keys/items count on a container row.
|
|
123
|
+
*/
|
|
124
|
+
hideCount?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** Context passed to a custom value cell renderer. */
|
|
127
|
+
export interface RenderValueContext {
|
|
128
|
+
readOnly: boolean;
|
|
129
|
+
/** Commits a new value for the node (routed through `onValueChange`). */
|
|
130
|
+
commit: (value: JsonValue) => void;
|
|
131
|
+
/**
|
|
132
|
+
* Removes the value at the node's path (the key is deleted from its parent
|
|
133
|
+
* container). Routed through `onValueChange` with a `JsonTreeChange` whose
|
|
134
|
+
* `value` is undefined. Schema-declared nodes render as "unset" afterwards.
|
|
135
|
+
*/
|
|
136
|
+
clear: () => void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Custom value cell renderer. Return a ReactNode to replace the default value
|
|
140
|
+
* cell for that node (for containers it renders next to the key); return
|
|
141
|
+
* undefined to keep the default rendering.
|
|
142
|
+
*/
|
|
143
|
+
export type RenderValueCell = (node: JsonTreeNode, ctx: RenderValueContext) => ReactNode;
|
|
144
|
+
/**
|
|
145
|
+
* A trailing row action rendered in a node's action group (the icon buttons
|
|
146
|
+
* revealed on row hover). Built-ins use the ids `wrap` | `edit-json` |
|
|
147
|
+
* `copy-value`; consumer actions supply their own stable id.
|
|
148
|
+
*/
|
|
149
|
+
export interface NodeAction {
|
|
150
|
+
/** Stable identifier (also the React key). */
|
|
151
|
+
id: string;
|
|
152
|
+
/** Icon element (e.g. a lucide icon). The tree sizes it — no explicit size needed. */
|
|
153
|
+
icon: ReactNode;
|
|
154
|
+
/** Accessible name (aria-label). Also the hover tooltip unless `tooltip` is set. */
|
|
155
|
+
label: string;
|
|
156
|
+
/** Hover tooltip text; defaults to `label`. */
|
|
157
|
+
tooltip?: string;
|
|
158
|
+
/** Invoked when the action is triggered, with the row's node. */
|
|
159
|
+
onSelect: (node: JsonTreeNode) => void;
|
|
160
|
+
/** Renders in an active/highlighted state (e.g. wrap while a row is wrapped). */
|
|
161
|
+
active?: boolean;
|
|
162
|
+
/** Disables the control. */
|
|
163
|
+
disabled?: boolean;
|
|
164
|
+
/** Color tone; `error` tints a destructive action. Defaults to neutral. */
|
|
165
|
+
tone?: NodeDecorationTone;
|
|
166
|
+
}
|
|
167
|
+
/** Context passed to `nodeActions`, mirroring the value-cell edit context. */
|
|
168
|
+
export interface NodeActionContext {
|
|
169
|
+
readOnly: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* The actions the tree would render by default for this node (wrap,
|
|
172
|
+
* edit-as-JSON, copy-value), in display order. Spread these to keep the
|
|
173
|
+
* built-ins while adding or reordering your own.
|
|
174
|
+
*/
|
|
175
|
+
defaultActions: NodeAction[];
|
|
176
|
+
/** Commits a new value for the node (routed through `onEdit`/`onValueChange`). */
|
|
177
|
+
commit: (value: JsonValue) => void;
|
|
178
|
+
/** Removes the node's value (the key is deleted from its parent container). */
|
|
179
|
+
clear: () => void;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Customizes the trailing row actions per node. Return a new list (typically
|
|
183
|
+
* composed with `ctx.defaultActions`), an empty array to show no actions for
|
|
184
|
+
* that node, or `undefined` to keep the defaults. The tree owns the rendering,
|
|
185
|
+
* the hover reveal, the overflow menu, and a11y.
|
|
186
|
+
*/
|
|
187
|
+
export type NodeActionsResolver = (node: JsonTreeNode, ctx: NodeActionContext) => NodeAction[] | undefined;
|
|
188
|
+
/** Payload for copy events. */
|
|
189
|
+
export interface CopyEvent {
|
|
190
|
+
/** What was copied: the node's path or its value. */
|
|
191
|
+
kind: 'path' | 'value';
|
|
192
|
+
path: string;
|
|
193
|
+
/** The text placed on the clipboard. */
|
|
194
|
+
text: string;
|
|
195
|
+
}
|
|
196
|
+
/** Details about a single value edit. */
|
|
197
|
+
export interface JsonTreeChange {
|
|
198
|
+
path: string;
|
|
199
|
+
segments: PathSegment[];
|
|
200
|
+
/** The newly committed value at `path`. Undefined when the value was removed. */
|
|
201
|
+
value?: JsonValue;
|
|
202
|
+
/** The previous value at `path` (undefined when it did not exist). */
|
|
203
|
+
previous?: JsonValue;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Props passed to a custom row container. The wrapper IS the row element:
|
|
207
|
+
* render a single container applying `className`/`style` and `children`
|
|
208
|
+
* verbatim, plus whatever behavior you attach (e.g. dnd-kit drag listeners).
|
|
209
|
+
*/
|
|
210
|
+
export interface JsonTreeRowWrapperProps {
|
|
211
|
+
node: JsonTreeNode;
|
|
212
|
+
className?: string;
|
|
213
|
+
style?: CSSProperties;
|
|
214
|
+
/**
|
|
215
|
+
* Row click handler (used to expand/collapse containers by clicking the row).
|
|
216
|
+
* Custom wrappers should forward it to their root element so the behavior
|
|
217
|
+
* survives; the handler already ignores clicks on interactive descendants.
|
|
218
|
+
*/
|
|
219
|
+
onClick?: (event: MouseEvent) => void;
|
|
220
|
+
children: ReactNode;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Custom row container component (e.g. to make rows drag sources).
|
|
224
|
+
*
|
|
225
|
+
* Must be a stable component reference (module scope or memoized), not an
|
|
226
|
+
* inline arrow: a new identity on each render is a new component type to
|
|
227
|
+
* React, which remounts every row and drops in-progress editor DOM state.
|
|
228
|
+
*/
|
|
229
|
+
export type JsonTreeRowWrapper = ComponentType<JsonTreeRowWrapperProps>;
|
|
230
|
+
/** Props handed to a consumer-supplied code editor for object/array values. */
|
|
231
|
+
export interface JsonCodeEditorRenderProps {
|
|
232
|
+
/** Current editor text (controlled). */
|
|
233
|
+
value: string;
|
|
234
|
+
/** Called with the new text on every keystroke. */
|
|
235
|
+
onChange: (value: string) => void;
|
|
236
|
+
/** Commit the value (bind to Ctrl/Cmd+Enter). */
|
|
237
|
+
onApply: () => void;
|
|
238
|
+
/** Discard the edit (bind to Escape). */
|
|
239
|
+
onCancel: () => void;
|
|
240
|
+
/** True when `value` does not parse as JSON. */
|
|
241
|
+
invalid: boolean;
|
|
242
|
+
/** Editor content language (currently always JSON). */
|
|
243
|
+
language: 'json';
|
|
244
|
+
/** Whether the editor should take focus on mount. */
|
|
245
|
+
autoFocus: boolean;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Renders the text surface for editing an object/array value as code. Omit to
|
|
249
|
+
* fall back to a plain textarea. The surrounding chrome — the parse-error
|
|
250
|
+
* message and the Apply/Cancel actions — is supplied by the tree, so the
|
|
251
|
+
* editor only needs to render the input and wire the callbacks.
|
|
252
|
+
*/
|
|
253
|
+
export type RenderCodeEditor = (props: JsonCodeEditorRenderProps) => ReactNode;
|
|
File without changes
|