@uipath/apollo-react 6.1.0 → 6.2.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/dist/canvas/components/JsonTree/DecorationChip.cjs +81 -0
- package/dist/canvas/components/JsonTree/DecorationChip.d.ts +5 -0
- package/dist/canvas/components/JsonTree/DecorationChip.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/DecorationChip.js +47 -0
- package/dist/canvas/components/JsonTree/EditorChrome.cjs +93 -0
- package/dist/canvas/components/JsonTree/EditorChrome.d.ts +18 -0
- package/dist/canvas/components/JsonTree/EditorChrome.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/EditorChrome.js +56 -0
- package/dist/canvas/components/JsonTree/JsonContainerEditor.cjs +104 -0
- package/dist/canvas/components/JsonTree/JsonContainerEditor.d.ts +10 -0
- package/dist/canvas/components/JsonTree/JsonContainerEditor.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonContainerEditor.js +70 -0
- package/dist/canvas/components/JsonTree/JsonLeafValueEditor.cjs +98 -0
- package/dist/canvas/components/JsonTree/JsonLeafValueEditor.d.ts +9 -0
- package/dist/canvas/components/JsonTree/JsonLeafValueEditor.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonLeafValueEditor.js +64 -0
- package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.cjs +86 -0
- package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.d.ts +9 -0
- package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonMultilineLeafEditor.js +52 -0
- package/dist/canvas/components/JsonTree/JsonTree.cjs +165 -0
- package/dist/canvas/components/JsonTree/JsonTree.d.ts +23 -0
- package/dist/canvas/components/JsonTree/JsonTree.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonTree.js +131 -0
- package/dist/canvas/components/JsonTree/JsonTree.types.cjs +18 -0
- package/dist/canvas/components/JsonTree/JsonTree.types.d.ts +110 -0
- package/dist/canvas/components/JsonTree/JsonTree.types.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonTree.types.js +0 -0
- package/dist/canvas/components/JsonTree/JsonTreeRow.cjs +358 -0
- package/dist/canvas/components/JsonTree/JsonTreeRow.d.ts +35 -0
- package/dist/canvas/components/JsonTree/JsonTreeRow.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonTreeRow.js +321 -0
- package/dist/canvas/components/JsonTree/JsonTreeToolbar.cjs +224 -0
- package/dist/canvas/components/JsonTree/JsonTreeToolbar.d.ts +17 -0
- package/dist/canvas/components/JsonTree/JsonTreeToolbar.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonTreeToolbar.js +190 -0
- package/dist/canvas/components/JsonTree/JsonTypeBadge.cjs +70 -0
- package/dist/canvas/components/JsonTree/JsonTypeBadge.d.ts +10 -0
- package/dist/canvas/components/JsonTree/JsonTypeBadge.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/JsonTypeBadge.js +36 -0
- package/dist/canvas/components/JsonTree/NodeKey.cjs +86 -0
- package/dist/canvas/components/JsonTree/NodeKey.d.ts +10 -0
- package/dist/canvas/components/JsonTree/NodeKey.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/NodeKey.js +52 -0
- package/dist/canvas/components/JsonTree/RowActions.cjs +114 -0
- package/dist/canvas/components/JsonTree/RowActions.d.ts +8 -0
- package/dist/canvas/components/JsonTree/RowActions.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/RowActions.js +80 -0
- package/dist/canvas/components/JsonTree/ScalarValueCell.cjs +132 -0
- package/dist/canvas/components/JsonTree/ScalarValueCell.d.ts +12 -0
- package/dist/canvas/components/JsonTree/ScalarValueCell.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/ScalarValueCell.js +95 -0
- package/dist/canvas/components/JsonTree/buildJsonTree.cjs +321 -0
- package/dist/canvas/components/JsonTree/buildJsonTree.d.ts +37 -0
- package/dist/canvas/components/JsonTree/buildJsonTree.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/buildJsonTree.js +254 -0
- package/dist/canvas/components/JsonTree/clipboard.cjs +63 -0
- package/dist/canvas/components/JsonTree/clipboard.d.ts +2 -0
- package/dist/canvas/components/JsonTree/clipboard.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/clipboard.js +29 -0
- package/dist/canvas/components/JsonTree/index.cjs +114 -0
- package/dist/canvas/components/JsonTree/index.d.ts +10 -0
- package/dist/canvas/components/JsonTree/index.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/index.js +9 -0
- package/dist/canvas/components/JsonTree/leafEditTypes.cjs +74 -0
- package/dist/canvas/components/JsonTree/leafEditTypes.d.ts +6 -0
- package/dist/canvas/components/JsonTree/leafEditTypes.d.ts.map +1 -0
- package/dist/canvas/components/JsonTree/leafEditTypes.js +34 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.cjs +254 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.d.ts +3 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.d.ts.map +1 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.js +220 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.types.cjs +18 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts +38 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.types.d.ts.map +1 -0
- package/dist/canvas/components/NodeIOView/NodeIOView.types.js +0 -0
- package/dist/canvas/components/NodeIOView/PanelTitleBar.cjs +78 -0
- package/dist/canvas/components/NodeIOView/PanelTitleBar.d.ts +10 -0
- package/dist/canvas/components/NodeIOView/PanelTitleBar.d.ts.map +1 -0
- package/dist/canvas/components/NodeIOView/PanelTitleBar.js +44 -0
- package/dist/canvas/components/NodeIOView/index.cjs +72 -0
- package/dist/canvas/components/NodeIOView/index.d.ts +4 -0
- package/dist/canvas/components/NodeIOView/index.d.ts.map +1 -0
- package/dist/canvas/components/NodeIOView/index.js +3 -0
- package/dist/canvas/components/index.cjs +62 -48
- package/dist/canvas/components/index.d.ts +4 -2
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +4 -2
- package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.cjs +184 -0
- package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.d.ts +18 -0
- package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.d.ts.map +1 -0
- package/dist/canvas/controls/NodeOutputModeSelect/NodeOutputModeSelect.js +144 -0
- package/dist/canvas/controls/NodeOutputModeSelect/index.cjs +42 -0
- package/dist/canvas/controls/NodeOutputModeSelect/index.d.ts +2 -0
- package/dist/canvas/controls/NodeOutputModeSelect/index.d.ts.map +1 -0
- package/dist/canvas/controls/NodeOutputModeSelect/index.js +2 -0
- package/dist/canvas/controls/index.cjs +14 -4
- package/dist/canvas/controls/index.d.ts +1 -0
- package/dist/canvas/controls/index.d.ts.map +1 -1
- package/dist/canvas/controls/index.js +2 -1
- package/dist/canvas/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/i18n/useSafeLingui.cjs +21 -4
- package/dist/i18n/useSafeLingui.d.ts.map +1 -1
- package/dist/i18n/useSafeLingui.js +21 -4
- package/package.json +4 -3
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { ChevronDown, CircleCheck, Copy, Pencil, WrapText } from "lucide-react";
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
import { useSafeLingui } from "../../../i18n/index.js";
|
|
6
|
+
import { formatLeafValue, isArrayItemTemplateRoot } from "./buildJsonTree.js";
|
|
7
|
+
import { DecorationChip } from "./DecorationChip.js";
|
|
8
|
+
import { JsonContainerEditor } from "./JsonContainerEditor.js";
|
|
9
|
+
import { JsonMultilineLeafEditor } from "./JsonMultilineLeafEditor.js";
|
|
10
|
+
import { JsonTypeBadge } from "./JsonTypeBadge.js";
|
|
11
|
+
import { NodeKey } from "./NodeKey.js";
|
|
12
|
+
import { RowActions } from "./RowActions.js";
|
|
13
|
+
import { ScalarValueCell, valueColorClass } from "./ScalarValueCell.js";
|
|
14
|
+
const ROW_CLASS = 'group flex min-h-7 cursor-default items-center gap-1.5 py-1 pr-1 transition hover:bg-surface-overlay';
|
|
15
|
+
const CUSTOM_CELL_CLASS = 'flex min-w-0 flex-1 items-center overflow-hidden';
|
|
16
|
+
function rowIndent(depth, extra = 0) {
|
|
17
|
+
return {
|
|
18
|
+
paddingLeft: `${6 + 12 * depth + extra}px`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const KEY_ALIGN_OFFSET = 44;
|
|
22
|
+
const JsonTreeRowContext = /*#__PURE__*/ createContext(null);
|
|
23
|
+
const JsonTreeRowContextProvider = JsonTreeRowContext.Provider;
|
|
24
|
+
function useJsonTreeRowContext() {
|
|
25
|
+
const ctx = useContext(JsonTreeRowContext);
|
|
26
|
+
if (!ctx) throw new Error('JsonTreeRow must be rendered inside a JsonTreeRowContext provider');
|
|
27
|
+
return ctx;
|
|
28
|
+
}
|
|
29
|
+
function JsonTreeRow({ node, depth }) {
|
|
30
|
+
const { _ } = useSafeLingui();
|
|
31
|
+
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();
|
|
32
|
+
const buildDefaultActions = (node, flags)=>{
|
|
33
|
+
const actions = [];
|
|
34
|
+
if (flags.wrappable) actions.push({
|
|
35
|
+
id: 'wrap',
|
|
36
|
+
icon: /*#__PURE__*/ jsx(WrapText, {}),
|
|
37
|
+
active: flags.wrapped,
|
|
38
|
+
tooltip: flags.wrapped ? _({
|
|
39
|
+
id: 'canvas.json_value_panel.unwrap_value',
|
|
40
|
+
message: 'Unwrap value'
|
|
41
|
+
}) : _({
|
|
42
|
+
id: 'canvas.json_value_panel.wrap_value',
|
|
43
|
+
message: 'Wrap value'
|
|
44
|
+
}),
|
|
45
|
+
label: flags.wrapped ? _({
|
|
46
|
+
id: 'canvas.json_value_panel.unwrap_value_of',
|
|
47
|
+
message: 'Unwrap value of {key}',
|
|
48
|
+
values: {
|
|
49
|
+
key: node.key
|
|
50
|
+
}
|
|
51
|
+
}) : _({
|
|
52
|
+
id: 'canvas.json_value_panel.wrap_value_of',
|
|
53
|
+
message: 'Wrap value of {key}',
|
|
54
|
+
values: {
|
|
55
|
+
key: node.key
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
onSelect: ()=>toggleWrapped(node)
|
|
59
|
+
});
|
|
60
|
+
if (flags.isContainer && canEdit && !node.isArrayItemTemplate) actions.push({
|
|
61
|
+
id: 'edit-json',
|
|
62
|
+
icon: /*#__PURE__*/ jsx(Pencil, {}),
|
|
63
|
+
tooltip: _({
|
|
64
|
+
id: 'canvas.json_value_panel.edit_as_json',
|
|
65
|
+
message: 'Edit as JSON'
|
|
66
|
+
}),
|
|
67
|
+
label: _({
|
|
68
|
+
id: 'canvas.json_value_panel.edit_key_as_json',
|
|
69
|
+
message: 'Edit {key} as JSON',
|
|
70
|
+
values: {
|
|
71
|
+
key: node.key
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
onSelect: ()=>setJsonEditingPath(node.path)
|
|
75
|
+
});
|
|
76
|
+
if (flags.canCopyValue) actions.push({
|
|
77
|
+
id: 'copy-value',
|
|
78
|
+
icon: flags.copiedValue ? /*#__PURE__*/ jsx(CircleCheck, {
|
|
79
|
+
className: "text-brand"
|
|
80
|
+
}) : /*#__PURE__*/ jsx(Copy, {}),
|
|
81
|
+
tooltip: _({
|
|
82
|
+
id: 'canvas.json_value_panel.copy_value',
|
|
83
|
+
message: 'Copy value'
|
|
84
|
+
}),
|
|
85
|
+
label: _({
|
|
86
|
+
id: 'canvas.json_value_panel.copy_value_of',
|
|
87
|
+
message: 'Copy value of {key}',
|
|
88
|
+
values: {
|
|
89
|
+
key: node.key
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
onSelect: ()=>copyValue(node)
|
|
93
|
+
});
|
|
94
|
+
return actions;
|
|
95
|
+
};
|
|
96
|
+
const isContainer = void 0 !== node.children;
|
|
97
|
+
const isTemplate = !!node.isArrayItemTemplate;
|
|
98
|
+
const isTemplateItem = isArrayItemTemplateRoot(node);
|
|
99
|
+
const childCount = node.children?.filter((c)=>!isArrayItemTemplateRoot(c)).length ?? 0;
|
|
100
|
+
const decoration = decorateNode?.(node);
|
|
101
|
+
const customCell = renderValue?.(node, {
|
|
102
|
+
readOnly,
|
|
103
|
+
commit: (value)=>commitEdit(node, value),
|
|
104
|
+
clear: ()=>commitEdit(node, void 0)
|
|
105
|
+
});
|
|
106
|
+
const canCopyValue = void 0 !== node.value;
|
|
107
|
+
const wrappable = !isContainer && null == customCell && void 0 !== node.value && 'boolean' !== node.type && !node.schema?.enum?.length;
|
|
108
|
+
const wrapped = wrappable && !!wrappedPaths[node.path];
|
|
109
|
+
const copiedValue = copied?.path === node.path && 'value' === copied.kind;
|
|
110
|
+
let builtDefaults;
|
|
111
|
+
const getDefaultActions = ()=>{
|
|
112
|
+
builtDefaults ??= buildDefaultActions(node, {
|
|
113
|
+
isContainer,
|
|
114
|
+
wrappable,
|
|
115
|
+
wrapped,
|
|
116
|
+
canCopyValue,
|
|
117
|
+
copiedValue
|
|
118
|
+
});
|
|
119
|
+
return builtDefaults;
|
|
120
|
+
};
|
|
121
|
+
const actions = nodeActions?.(node, {
|
|
122
|
+
readOnly,
|
|
123
|
+
get defaultActions () {
|
|
124
|
+
return getDefaultActions();
|
|
125
|
+
},
|
|
126
|
+
commit: (value)=>commitEdit(node, value),
|
|
127
|
+
clear: ()=>commitEdit(node, void 0)
|
|
128
|
+
}) ?? getDefaultActions();
|
|
129
|
+
const rowClickable = isContainer && !!onToggleCollapsed;
|
|
130
|
+
const handleRowClick = (event)=>{
|
|
131
|
+
if (event.target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return;
|
|
132
|
+
onToggleCollapsed?.(node.path);
|
|
133
|
+
};
|
|
134
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
135
|
+
children: [
|
|
136
|
+
/*#__PURE__*/ jsxs(RowWrapper, {
|
|
137
|
+
node: node,
|
|
138
|
+
className: cn(ROW_CLASS, rowClickable && 'cursor-pointer'),
|
|
139
|
+
style: rowIndent(depth),
|
|
140
|
+
onClick: rowClickable ? handleRowClick : void 0,
|
|
141
|
+
children: [
|
|
142
|
+
isContainer ? /*#__PURE__*/ jsx("button", {
|
|
143
|
+
type: "button",
|
|
144
|
+
onClick: ()=>onToggleCollapsed?.(node.path),
|
|
145
|
+
"aria-label": collapsed[node.path] ? _({
|
|
146
|
+
id: 'canvas.json_value_panel.expand_key',
|
|
147
|
+
message: 'Expand {key}',
|
|
148
|
+
values: {
|
|
149
|
+
key: node.key
|
|
150
|
+
}
|
|
151
|
+
}) : _({
|
|
152
|
+
id: 'canvas.json_value_panel.collapse_key',
|
|
153
|
+
message: 'Collapse {key}',
|
|
154
|
+
values: {
|
|
155
|
+
key: node.key
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
"aria-expanded": !collapsed[node.path],
|
|
159
|
+
className: "grid size-2.5 shrink-0 cursor-pointer place-items-center text-foreground-subtle transition hover:text-foreground",
|
|
160
|
+
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
161
|
+
size: 10,
|
|
162
|
+
className: cn('transition-transform duration-100', collapsed[node.path] && '-rotate-90')
|
|
163
|
+
})
|
|
164
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
165
|
+
className: "size-2.5 shrink-0"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ jsx(JsonTypeBadge, {
|
|
168
|
+
type: node.type,
|
|
169
|
+
icon: decoration?.badge?.icon ?? deriveTypeIcon?.(node),
|
|
170
|
+
className: decoration?.badge?.className
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsx(NodeKey, {
|
|
173
|
+
node: node,
|
|
174
|
+
label: isTemplateItem ? templateItemLabel : decoration?.label,
|
|
175
|
+
displayPath: pathForCopy?.(node.path) ?? node.path,
|
|
176
|
+
onCopyPath: copyPath,
|
|
177
|
+
className: isTemplateItem ? 'font-normal italic text-foreground-subtle' : void 0
|
|
178
|
+
}),
|
|
179
|
+
copied?.path === node.path && 'path' === copied.kind && /*#__PURE__*/ jsx(CircleCheck, {
|
|
180
|
+
size: 11,
|
|
181
|
+
className: "shrink-0 text-brand",
|
|
182
|
+
role: "img",
|
|
183
|
+
"aria-label": _({
|
|
184
|
+
id: 'canvas.json_value_panel.path_copied',
|
|
185
|
+
message: 'Path copied'
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
decoration?.sublabel && /*#__PURE__*/ jsx("span", {
|
|
189
|
+
className: "min-w-0 truncate font-mono text-[10px] text-foreground-subtle leading-4",
|
|
190
|
+
children: decoration.sublabel
|
|
191
|
+
}),
|
|
192
|
+
node.required && /*#__PURE__*/ jsxs("span", {
|
|
193
|
+
className: "shrink-0 text-[10px] text-error",
|
|
194
|
+
children: [
|
|
195
|
+
/*#__PURE__*/ jsx("span", {
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
children: "*"
|
|
198
|
+
}),
|
|
199
|
+
/*#__PURE__*/ jsx("span", {
|
|
200
|
+
className: "sr-only",
|
|
201
|
+
children: _({
|
|
202
|
+
id: 'canvas.json_value_panel.required_marker',
|
|
203
|
+
message: 'required'
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
}),
|
|
208
|
+
isContainer ? /*#__PURE__*/ jsxs(Fragment, {
|
|
209
|
+
children: [
|
|
210
|
+
!decoration?.hideCount && /*#__PURE__*/ jsx("span", {
|
|
211
|
+
className: "shrink-0 whitespace-nowrap font-mono italic text-[10px] text-foreground-subtle",
|
|
212
|
+
children: 'array' === node.type ? _({
|
|
213
|
+
id: 'canvas.json_value_panel.item_count',
|
|
214
|
+
message: '{count, plural, one {# item} other {# items}}',
|
|
215
|
+
values: {
|
|
216
|
+
count: childCount
|
|
217
|
+
}
|
|
218
|
+
}) : _({
|
|
219
|
+
id: 'canvas.json_value_panel.key_count',
|
|
220
|
+
message: '{count, plural, one {# key} other {# keys}}',
|
|
221
|
+
values: {
|
|
222
|
+
count: childCount
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
}),
|
|
226
|
+
null != customCell && /*#__PURE__*/ jsx("span", {
|
|
227
|
+
className: CUSTOM_CELL_CLASS,
|
|
228
|
+
children: customCell
|
|
229
|
+
}),
|
|
230
|
+
/*#__PURE__*/ jsx(DecorationChip, {
|
|
231
|
+
decoration: decoration
|
|
232
|
+
}),
|
|
233
|
+
/*#__PURE__*/ jsx(RowActions, {
|
|
234
|
+
node: node,
|
|
235
|
+
actions: actions,
|
|
236
|
+
maxInline: maxInlineActions
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
240
|
+
children: [
|
|
241
|
+
!wrapped && (null != customCell ? /*#__PURE__*/ jsx("span", {
|
|
242
|
+
className: CUSTOM_CELL_CLASS,
|
|
243
|
+
children: customCell
|
|
244
|
+
}) : !(readOnly && void 0 === node.value || isTemplate) && /*#__PURE__*/ jsxs(Fragment, {
|
|
245
|
+
children: [
|
|
246
|
+
/*#__PURE__*/ jsx("span", {
|
|
247
|
+
className: "shrink-0 font-mono text-xs text-foreground-subtle",
|
|
248
|
+
children: "="
|
|
249
|
+
}),
|
|
250
|
+
/*#__PURE__*/ jsx(ScalarValueCell, {
|
|
251
|
+
node: node,
|
|
252
|
+
readOnly: readOnly,
|
|
253
|
+
editing: editingPath === node.path,
|
|
254
|
+
onStartEdit: (n)=>setEditingPath(n.path),
|
|
255
|
+
onStopEdit: ()=>setEditingPath(null),
|
|
256
|
+
onEdit: canEdit ? commitEdit : void 0
|
|
257
|
+
})
|
|
258
|
+
]
|
|
259
|
+
})),
|
|
260
|
+
editingPath !== node.path && /*#__PURE__*/ jsxs(Fragment, {
|
|
261
|
+
children: [
|
|
262
|
+
/*#__PURE__*/ jsx(DecorationChip, {
|
|
263
|
+
decoration: decoration
|
|
264
|
+
}),
|
|
265
|
+
/*#__PURE__*/ jsx(RowActions, {
|
|
266
|
+
node: node,
|
|
267
|
+
actions: actions,
|
|
268
|
+
maxInline: maxInlineActions
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
})
|
|
274
|
+
]
|
|
275
|
+
}),
|
|
276
|
+
wrapped && /*#__PURE__*/ jsx("div", {
|
|
277
|
+
className: "pb-1.5 pr-3.5",
|
|
278
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
279
|
+
children: editingPath === node.path && canEdit ? /*#__PURE__*/ jsx(JsonMultilineLeafEditor, {
|
|
280
|
+
node: node,
|
|
281
|
+
onCommit: (value)=>{
|
|
282
|
+
setEditingPath(null);
|
|
283
|
+
commitEdit(node, value);
|
|
284
|
+
},
|
|
285
|
+
onCancel: ()=>setEditingPath(null)
|
|
286
|
+
}) : /*#__PURE__*/ jsx("button", {
|
|
287
|
+
type: "button",
|
|
288
|
+
disabled: !canEdit,
|
|
289
|
+
onClick: ()=>setEditingPath(node.path),
|
|
290
|
+
"aria-label": _({
|
|
291
|
+
id: 'canvas.json_value_panel.edit_value_of',
|
|
292
|
+
message: 'Edit value of {key}',
|
|
293
|
+
values: {
|
|
294
|
+
key: node.key
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
title: canEdit ? _({
|
|
298
|
+
id: 'canvas.json_value_panel.edit_hint',
|
|
299
|
+
message: 'Click to edit'
|
|
300
|
+
}) : void 0,
|
|
301
|
+
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)),
|
|
302
|
+
children: 'string' == typeof node.value ? node.value : formatLeafValue(node.type, node.value)
|
|
303
|
+
})
|
|
304
|
+
}),
|
|
305
|
+
isContainer && jsonEditingPath === node.path && /*#__PURE__*/ jsx("div", {
|
|
306
|
+
className: "py-1.5 pr-3.5",
|
|
307
|
+
style: rowIndent(depth, KEY_ALIGN_OFFSET),
|
|
308
|
+
children: /*#__PURE__*/ jsx(JsonContainerEditor, {
|
|
309
|
+
node: node,
|
|
310
|
+
onCommit: (value)=>{
|
|
311
|
+
setJsonEditingPath(null);
|
|
312
|
+
commitEdit(node, value);
|
|
313
|
+
},
|
|
314
|
+
onCancel: ()=>setJsonEditingPath(null),
|
|
315
|
+
renderCodeEditor: renderCodeEditor
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
export { JsonTreeRow, JsonTreeRowContextProvider };
|
|
@@ -0,0 +1,224 @@
|
|
|
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
|
+
JsonTreeToolbar: ()=>JsonTreeToolbar
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
31
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
|
|
34
|
+
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
|
|
35
|
+
const ALL_FILTER_VALUE = '__all__';
|
|
36
|
+
function JsonTreeToolbar({ query, onQueryChange, searchPlaceholder, filters, activeFilterId = null, onFilterChange, allCollapsed = false, onToggleAll, leading, controlsHidden = false, className }) {
|
|
37
|
+
const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
|
|
38
|
+
const [searchOpen, setSearchOpen] = (0, external_react_namespaceObject.useState)(false);
|
|
39
|
+
const activeFilter = filters?.find((f)=>f.id === activeFilterId);
|
|
40
|
+
const resolvedSearchPlaceholder = searchPlaceholder ?? _({
|
|
41
|
+
id: 'canvas.json_value_panel.search_fields',
|
|
42
|
+
message: 'Search fields and values...'
|
|
43
|
+
});
|
|
44
|
+
const filterLabel = activeFilter ? _({
|
|
45
|
+
id: 'canvas.json_value_panel.filter_active',
|
|
46
|
+
message: 'Filter: {label}',
|
|
47
|
+
values: {
|
|
48
|
+
label: activeFilter.label
|
|
49
|
+
}
|
|
50
|
+
}) : _({
|
|
51
|
+
id: 'canvas.json_value_panel.filter',
|
|
52
|
+
message: 'Filter'
|
|
53
|
+
});
|
|
54
|
+
const searchActionLabel = _({
|
|
55
|
+
id: 'canvas.json_value_panel.search_fields_action',
|
|
56
|
+
message: 'Search fields and values'
|
|
57
|
+
});
|
|
58
|
+
const toggleAllLabel = allCollapsed ? _({
|
|
59
|
+
id: 'canvas.json_value_panel.expand_all',
|
|
60
|
+
message: 'Expand all'
|
|
61
|
+
}) : _({
|
|
62
|
+
id: 'canvas.json_value_panel.collapse_all',
|
|
63
|
+
message: 'Collapse all'
|
|
64
|
+
});
|
|
65
|
+
const closeSearch = ()=>{
|
|
66
|
+
onQueryChange('');
|
|
67
|
+
setSearchOpen(false);
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
70
|
+
className: (0, apollo_wind_namespaceObject.cn)('flex items-center gap-1.5', className),
|
|
71
|
+
children: [
|
|
72
|
+
leading,
|
|
73
|
+
!controlsHidden && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
74
|
+
children: [
|
|
75
|
+
searchOpen ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
76
|
+
className: "relative flex min-w-0 flex-1 items-center overflow-hidden",
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Search, {
|
|
79
|
+
size: 13,
|
|
80
|
+
className: "pointer-events-none absolute left-2 text-foreground-subtle"
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Input, {
|
|
83
|
+
autoFocus: true,
|
|
84
|
+
type: "text",
|
|
85
|
+
variant: "ghost",
|
|
86
|
+
size: "xs",
|
|
87
|
+
value: query,
|
|
88
|
+
onChange: (e)=>onQueryChange(e.target.value),
|
|
89
|
+
onKeyDown: (e)=>{
|
|
90
|
+
if ('Escape' === e.key) closeSearch();
|
|
91
|
+
},
|
|
92
|
+
"aria-label": resolvedSearchPlaceholder,
|
|
93
|
+
placeholder: resolvedSearchPlaceholder,
|
|
94
|
+
style: {
|
|
95
|
+
paddingLeft: '1.75rem',
|
|
96
|
+
paddingRight: '1.5rem'
|
|
97
|
+
},
|
|
98
|
+
className: "h-6 w-full text-foreground placeholder:text-foreground-subtle focus-visible:ring-0"
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
101
|
+
type: "button",
|
|
102
|
+
onClick: closeSearch,
|
|
103
|
+
"aria-label": _({
|
|
104
|
+
id: 'canvas.json_value_panel.clear_search',
|
|
105
|
+
message: 'Clear search'
|
|
106
|
+
}),
|
|
107
|
+
className: "absolute right-1.5 grid size-4 place-items-center text-foreground-subtle transition hover:text-foreground",
|
|
108
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
109
|
+
size: 12
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
116
|
+
className: "flex-1"
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
119
|
+
content: searchActionLabel,
|
|
120
|
+
placement: "top",
|
|
121
|
+
delay: true,
|
|
122
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Button, {
|
|
123
|
+
variant: "ghost",
|
|
124
|
+
size: "3xs",
|
|
125
|
+
icon: true,
|
|
126
|
+
onClick: ()=>setSearchOpen(true),
|
|
127
|
+
"aria-label": searchActionLabel,
|
|
128
|
+
className: "rounded text-foreground-subtle hover:bg-surface-overlay hover:text-foreground",
|
|
129
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Search, {
|
|
130
|
+
size: 14
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}),
|
|
136
|
+
!!filters?.length && onFilterChange && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.DropdownMenu, {
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
139
|
+
content: filterLabel,
|
|
140
|
+
placement: "top",
|
|
141
|
+
delay: true,
|
|
142
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuTrigger, {
|
|
143
|
+
asChild: true,
|
|
144
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
|
|
145
|
+
variant: "ghost",
|
|
146
|
+
size: "3xs",
|
|
147
|
+
icon: true,
|
|
148
|
+
"aria-label": filterLabel,
|
|
149
|
+
className: "relative rounded text-foreground-subtle hover:bg-surface-overlay hover:text-foreground",
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Filter, {
|
|
152
|
+
size: 14
|
|
153
|
+
}),
|
|
154
|
+
activeFilter && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
155
|
+
className: "absolute right-0.5 top-0.5 size-1.5 rounded-full bg-primary ring-1 ring-surface"
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
}),
|
|
161
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuContent, {
|
|
162
|
+
align: "end",
|
|
163
|
+
className: "w-52",
|
|
164
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.DropdownMenuRadioGroup, {
|
|
165
|
+
value: activeFilterId ?? ALL_FILTER_VALUE,
|
|
166
|
+
onValueChange: (value)=>onFilterChange(value === ALL_FILTER_VALUE ? null : value),
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.DropdownMenuRadioItem, {
|
|
169
|
+
value: ALL_FILTER_VALUE,
|
|
170
|
+
className: "text-[11px] [&>span:first-child]:text-foreground-accent",
|
|
171
|
+
children: _({
|
|
172
|
+
id: 'canvas.json_value_panel.filter_all',
|
|
173
|
+
message: 'All'
|
|
174
|
+
})
|
|
175
|
+
}),
|
|
176
|
+
filters.map((filter)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.DropdownMenuRadioItem, {
|
|
177
|
+
value: filter.id,
|
|
178
|
+
className: "text-[11px] [&>span:first-child]:text-foreground-accent",
|
|
179
|
+
children: [
|
|
180
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
181
|
+
className: "flex-1 truncate",
|
|
182
|
+
children: filter.label
|
|
183
|
+
}),
|
|
184
|
+
void 0 !== filter.count && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
185
|
+
className: "ml-3 rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[10px] font-medium leading-none text-foreground-muted",
|
|
186
|
+
children: filter.count
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}, filter.id))
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
}),
|
|
195
|
+
onToggleAll && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
196
|
+
content: toggleAllLabel,
|
|
197
|
+
placement: "top",
|
|
198
|
+
delay: true,
|
|
199
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.Button, {
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
size: "3xs",
|
|
202
|
+
icon: true,
|
|
203
|
+
onClick: onToggleAll,
|
|
204
|
+
"aria-label": toggleAllLabel,
|
|
205
|
+
className: "rounded text-foreground-subtle hover:bg-surface-overlay hover:text-foreground",
|
|
206
|
+
children: allCollapsed ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronsUpDown, {
|
|
207
|
+
size: 14
|
|
208
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronsDownUp, {
|
|
209
|
+
size: 14
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
exports.JsonTreeToolbar = __webpack_exports__.JsonTreeToolbar;
|
|
219
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
220
|
+
"JsonTreeToolbar"
|
|
221
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
222
|
+
Object.defineProperty(exports, '__esModule', {
|
|
223
|
+
value: true
|
|
224
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { JsonTreeFilterOption } from './JsonTree.types';
|
|
3
|
+
export interface JsonTreeToolbarProps {
|
|
4
|
+
query: string;
|
|
5
|
+
onQueryChange: (query: string) => void;
|
|
6
|
+
searchPlaceholder?: string;
|
|
7
|
+
filters?: JsonTreeFilterOption[];
|
|
8
|
+
activeFilterId?: string | null;
|
|
9
|
+
onFilterChange?: (id: string | null) => void;
|
|
10
|
+
allCollapsed?: boolean;
|
|
11
|
+
onToggleAll?: () => void;
|
|
12
|
+
leading?: ReactNode;
|
|
13
|
+
controlsHidden?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function JsonTreeToolbar({ query, onQueryChange, searchPlaceholder, filters, activeFilterId, onFilterChange, allCollapsed, onToggleAll, leading, controlsHidden, className, }: JsonTreeToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=JsonTreeToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonTreeToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/JsonTreeToolbar.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAGjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,oBAAoB;IAEnC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAEjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAMzB,OAAO,CAAC,EAAE,SAAS,CAAC;IAKpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,cAAqB,EACrB,cAAc,EACd,YAAoB,EACpB,WAAW,EACX,OAAO,EACP,cAAsB,EACtB,SAAS,GACV,EAAE,oBAAoB,2CA4KtB"}
|