@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 @@
|
|
|
1
|
+
{"version":3,"file":"buildJsonTree.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/buildJsonTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,UAAU,EAEV,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAI1B,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,KAAK,IAAI,UAAU,CAE9E;AAGD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAI5E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,gBAAgB,CAajE;AAQD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,gBAAgB,CASlF;AAuJD,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,YAAY,EAAE,CAc3E;AASD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAEnE;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,MAAM,gBAAgB,GAAG,CAC7B,IAAI,EAAE,YAAY,KACf;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC;AAoCvD,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IAElD,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAGD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,GAAE,cAAmB,EAC5B,KAAK,SAAI,GACR,eAAe,EAAE,CAsCnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,KAAK,SAAI,GAAG,aAAa,EAAE,CASvF;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,GAAG,SAAS,EAC3B,QAAQ,EAAE,WAAW,EAAE,GACtB,SAAS,GAAG,SAAS,CAcvB;AAOD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,GAAG,SAAS,EAC3B,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,SAAS,GACf,SAAS,CAoBX;AAOD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,GAAG,SAAS,EAC3B,QAAQ,EAAE,WAAW,EAAE,GACtB,SAAS,GAAG,SAAS,CAyBvB;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAI5F"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
const IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
2
|
+
function isJsonObject(value) {
|
|
3
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function appendPathSegment(path, segment) {
|
|
6
|
+
if ('number' == typeof segment) return `${path}[${segment}]`;
|
|
7
|
+
if (IDENTIFIER_RE.test(segment)) return path ? `${path}.${segment}` : segment;
|
|
8
|
+
return `${path}[${JSON.stringify(segment)}]`;
|
|
9
|
+
}
|
|
10
|
+
function inferValueType(value) {
|
|
11
|
+
if (null === value) return 'null';
|
|
12
|
+
if (Array.isArray(value)) return 'array';
|
|
13
|
+
switch(typeof value){
|
|
14
|
+
case 'string':
|
|
15
|
+
return 'string';
|
|
16
|
+
case 'number':
|
|
17
|
+
return 'number';
|
|
18
|
+
case 'boolean':
|
|
19
|
+
return 'boolean';
|
|
20
|
+
default:
|
|
21
|
+
return 'object';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function declaredTypes(schema) {
|
|
25
|
+
if (!schema?.type) return;
|
|
26
|
+
return Array.isArray(schema.type) ? schema.type : [
|
|
27
|
+
schema.type
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function schemaDisplayType(schema) {
|
|
31
|
+
const types = declaredTypes(schema);
|
|
32
|
+
const first = types?.find((t)=>'null' !== t) ?? types?.[0];
|
|
33
|
+
if (first) return 'integer' === first ? 'number' : first;
|
|
34
|
+
if (schema?.properties) return 'object';
|
|
35
|
+
if (schema?.items) return 'array';
|
|
36
|
+
const enumSample = schema?.enum?.find((v)=>null !== v);
|
|
37
|
+
if (void 0 !== enumSample) return inferValueType(enumSample);
|
|
38
|
+
return 'null';
|
|
39
|
+
}
|
|
40
|
+
function buildNode(input) {
|
|
41
|
+
const type = input.hasValue ? inferValueType(input.value) : schemaDisplayType(input.schema);
|
|
42
|
+
const node = {
|
|
43
|
+
key: input.key,
|
|
44
|
+
path: input.path,
|
|
45
|
+
segments: input.segments,
|
|
46
|
+
type,
|
|
47
|
+
required: input.required,
|
|
48
|
+
schema: input.schema
|
|
49
|
+
};
|
|
50
|
+
if (input.hasValue) node.value = input.value;
|
|
51
|
+
if (input.isTemplate) node.isArrayItemTemplate = true;
|
|
52
|
+
if ('object' === type) node.children = buildObjectChildren(input.hasValue ? input.value : void 0, input.schema, input.segments, input.path, input.isTemplate);
|
|
53
|
+
else if ('array' === type) node.children = buildArrayChildren(input.schema, input.value, input.hasValue, input.segments, input.path, input.isTemplate);
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
function buildArrayChildren(schema, value, hasValue, segments, path, isTemplate) {
|
|
57
|
+
const items = hasValue && Array.isArray(value) ? value : [];
|
|
58
|
+
if (items.length > 0) return items.map((item, index)=>buildNode({
|
|
59
|
+
key: String(index),
|
|
60
|
+
segments: [
|
|
61
|
+
...segments,
|
|
62
|
+
index
|
|
63
|
+
],
|
|
64
|
+
path: appendPathSegment(path, index),
|
|
65
|
+
schema: schema?.items,
|
|
66
|
+
value: item,
|
|
67
|
+
hasValue: true,
|
|
68
|
+
isTemplate
|
|
69
|
+
}));
|
|
70
|
+
if (schema?.items) return [
|
|
71
|
+
buildNode({
|
|
72
|
+
key: '0',
|
|
73
|
+
segments: [
|
|
74
|
+
...segments,
|
|
75
|
+
0
|
|
76
|
+
],
|
|
77
|
+
path: appendPathSegment(path, 0),
|
|
78
|
+
schema: schema.items,
|
|
79
|
+
hasValue: false,
|
|
80
|
+
isTemplate: true
|
|
81
|
+
})
|
|
82
|
+
];
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
function buildObjectChildren(value, schema, segments, path, isTemplate) {
|
|
86
|
+
const properties = schema?.properties ?? {};
|
|
87
|
+
const required = new Set(schema?.required ?? []);
|
|
88
|
+
const additional = 'object' == typeof schema?.additionalProperties ? schema.additionalProperties : void 0;
|
|
89
|
+
const children = [];
|
|
90
|
+
for (const [key, childSchema] of Object.entries(properties)){
|
|
91
|
+
const hasValue = void 0 !== value && Object.hasOwn(value, key);
|
|
92
|
+
children.push(buildNode({
|
|
93
|
+
key,
|
|
94
|
+
segments: [
|
|
95
|
+
...segments,
|
|
96
|
+
key
|
|
97
|
+
],
|
|
98
|
+
path: appendPathSegment(path, key),
|
|
99
|
+
schema: childSchema,
|
|
100
|
+
value: hasValue ? value?.[key] : void 0,
|
|
101
|
+
hasValue,
|
|
102
|
+
required: required.has(key),
|
|
103
|
+
isTemplate
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
if (void 0 !== value) {
|
|
107
|
+
for (const [key, childValue] of Object.entries(value))if (!Object.hasOwn(properties, key)) children.push(buildNode({
|
|
108
|
+
key,
|
|
109
|
+
segments: [
|
|
110
|
+
...segments,
|
|
111
|
+
key
|
|
112
|
+
],
|
|
113
|
+
path: appendPathSegment(path, key),
|
|
114
|
+
schema: additional,
|
|
115
|
+
value: childValue,
|
|
116
|
+
hasValue: true
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
return children;
|
|
120
|
+
}
|
|
121
|
+
function buildJsonTree(options) {
|
|
122
|
+
const { schema, value, basePath = '' } = options;
|
|
123
|
+
const rootIsArray = void 0 !== value ? Array.isArray(value) : !!schema && 'array' === schemaDisplayType(schema);
|
|
124
|
+
if (rootIsArray) return buildArrayChildren(schema, value, void 0 !== value, [], basePath);
|
|
125
|
+
return buildObjectChildren(isJsonObject(value) ? value : void 0, schema, [], basePath);
|
|
126
|
+
}
|
|
127
|
+
function isArrayItemTemplateRoot(node) {
|
|
128
|
+
return !!node.isArrayItemTemplate && 'number' == typeof node.segments[node.segments.length - 1];
|
|
129
|
+
}
|
|
130
|
+
function nodeSelfMatchesQuery(node, query, displayTexts) {
|
|
131
|
+
if (node.key.toLowerCase().includes(query)) return true;
|
|
132
|
+
const display = displayTexts?.(node);
|
|
133
|
+
if (display?.label?.toLowerCase().includes(query)) return true;
|
|
134
|
+
if (display?.sublabel?.toLowerCase().includes(query)) return true;
|
|
135
|
+
return void 0 !== node.value && null !== node.value && 'object' != typeof node.value && String(node.value).toLowerCase().includes(query);
|
|
136
|
+
}
|
|
137
|
+
function nodeMatchesQuery(node, query, displayTexts) {
|
|
138
|
+
if (nodeSelfMatchesQuery(node, query, displayTexts)) return true;
|
|
139
|
+
return node.children?.some((c)=>nodeMatchesQuery(c, query, displayTexts)) ?? false;
|
|
140
|
+
}
|
|
141
|
+
function nodeOrDescendantMatches(node, predicate) {
|
|
142
|
+
if (predicate(node)) return true;
|
|
143
|
+
return node.children?.some((c)=>nodeOrDescendantMatches(c, predicate)) ?? false;
|
|
144
|
+
}
|
|
145
|
+
function flattenJsonTree(nodes, options = {}, depth = 0) {
|
|
146
|
+
const { collapsed = {}, filterPredicate } = options;
|
|
147
|
+
const query = options.query?.trim().toLowerCase() ?? '';
|
|
148
|
+
const rows = [];
|
|
149
|
+
for (const node of nodes){
|
|
150
|
+
const selfQueryMatch = !!query && nodeSelfMatchesQuery(node, query, options.displayTexts);
|
|
151
|
+
if (query && !selfQueryMatch && !(node.children?.some((c)=>nodeMatchesQuery(c, query, options.displayTexts)) ?? false)) continue;
|
|
152
|
+
const selfPredicateMatch = !!filterPredicate && filterPredicate(node);
|
|
153
|
+
if (!filterPredicate || selfPredicateMatch || (node.children?.some((c)=>nodeOrDescendantMatches(c, filterPredicate)) ?? false)) {
|
|
154
|
+
rows.push({
|
|
155
|
+
node,
|
|
156
|
+
depth
|
|
157
|
+
});
|
|
158
|
+
if (node.children && !collapsed[node.path]) {
|
|
159
|
+
const childOptions = selfQueryMatch || selfPredicateMatch ? {
|
|
160
|
+
...options,
|
|
161
|
+
query: selfQueryMatch ? '' : options.query,
|
|
162
|
+
filterPredicate: selfPredicateMatch ? void 0 : filterPredicate
|
|
163
|
+
} : options;
|
|
164
|
+
rows.push(...flattenJsonTree(node.children, childOptions, depth + 1));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return rows;
|
|
169
|
+
}
|
|
170
|
+
function collectContainerPaths(nodes, depth = 0) {
|
|
171
|
+
const paths = [];
|
|
172
|
+
for (const node of nodes)if (node.children) {
|
|
173
|
+
paths.push({
|
|
174
|
+
path: node.path,
|
|
175
|
+
depth
|
|
176
|
+
});
|
|
177
|
+
paths.push(...collectContainerPaths(node.children, depth + 1));
|
|
178
|
+
}
|
|
179
|
+
return paths;
|
|
180
|
+
}
|
|
181
|
+
function getValueAtPath(root, segments) {
|
|
182
|
+
let current = root;
|
|
183
|
+
for (const segment of segments)if ('number' == typeof segment) {
|
|
184
|
+
if (!Array.isArray(current)) return;
|
|
185
|
+
current = current[segment];
|
|
186
|
+
} else {
|
|
187
|
+
if (!isJsonObject(current) || !Object.hasOwn(current, segment)) return;
|
|
188
|
+
current = current[segment];
|
|
189
|
+
}
|
|
190
|
+
return current;
|
|
191
|
+
}
|
|
192
|
+
function setValueAtPath(root, segments, value) {
|
|
193
|
+
const [head, ...rest] = segments;
|
|
194
|
+
if (void 0 === head) return value;
|
|
195
|
+
if ('number' == typeof head) {
|
|
196
|
+
const array = Array.isArray(root) ? [
|
|
197
|
+
...root
|
|
198
|
+
] : [];
|
|
199
|
+
array[head] = setValueAtPath(array[head], rest, value);
|
|
200
|
+
return array;
|
|
201
|
+
}
|
|
202
|
+
const object = isJsonObject(root) ? {
|
|
203
|
+
...root
|
|
204
|
+
} : {};
|
|
205
|
+
const previous = Object.hasOwn(object, head) ? object[head] : void 0;
|
|
206
|
+
Object.defineProperty(object, head, {
|
|
207
|
+
value: setValueAtPath(previous, rest, value),
|
|
208
|
+
enumerable: true,
|
|
209
|
+
configurable: true,
|
|
210
|
+
writable: true
|
|
211
|
+
});
|
|
212
|
+
return object;
|
|
213
|
+
}
|
|
214
|
+
function removeValueAtPath(root, segments) {
|
|
215
|
+
const [head, ...rest] = segments;
|
|
216
|
+
if (void 0 === head) return;
|
|
217
|
+
if ('number' == typeof head) {
|
|
218
|
+
if (!Array.isArray(root) || head >= root.length) return root;
|
|
219
|
+
if (0 === rest.length) {
|
|
220
|
+
const array = [
|
|
221
|
+
...root
|
|
222
|
+
];
|
|
223
|
+
array.splice(head, 1);
|
|
224
|
+
return array;
|
|
225
|
+
}
|
|
226
|
+
const child = removeValueAtPath(root[head], rest);
|
|
227
|
+
if (child === root[head]) return root;
|
|
228
|
+
const array = [
|
|
229
|
+
...root
|
|
230
|
+
];
|
|
231
|
+
array[head] = child;
|
|
232
|
+
return array;
|
|
233
|
+
}
|
|
234
|
+
if (!isJsonObject(root) || !Object.hasOwn(root, head)) return root;
|
|
235
|
+
if (0 === rest.length) {
|
|
236
|
+
const object = {
|
|
237
|
+
...root
|
|
238
|
+
};
|
|
239
|
+
delete object[head];
|
|
240
|
+
return object;
|
|
241
|
+
}
|
|
242
|
+
const child = removeValueAtPath(root[head], rest);
|
|
243
|
+
if (child === root[head]) return root;
|
|
244
|
+
return {
|
|
245
|
+
...root,
|
|
246
|
+
[head]: child
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function formatLeafValue(type, value) {
|
|
250
|
+
if (null == value) return 'null';
|
|
251
|
+
if ('string' === type) return JSON.stringify(value);
|
|
252
|
+
return String(value);
|
|
253
|
+
}
|
|
254
|
+
export { appendPathSegment, buildJsonTree, collectContainerPaths, flattenJsonTree, formatLeafValue, getValueAtPath, inferValueType, isArrayItemTemplateRoot, isJsonObject, removeValueAtPath, schemaDisplayType, setValueAtPath };
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
copyTextToClipboard: ()=>copyTextToClipboard
|
|
28
|
+
});
|
|
29
|
+
async function copyTextToClipboard(text) {
|
|
30
|
+
if ("u" > typeof navigator && navigator.clipboard) try {
|
|
31
|
+
await navigator.clipboard.writeText(text);
|
|
32
|
+
return true;
|
|
33
|
+
} catch {}
|
|
34
|
+
if ("u" < typeof document) return false;
|
|
35
|
+
const textarea = document.createElement('textarea');
|
|
36
|
+
textarea.value = text;
|
|
37
|
+
textarea.setAttribute('readonly', '');
|
|
38
|
+
textarea.style.position = 'fixed';
|
|
39
|
+
textarea.style.opacity = '0';
|
|
40
|
+
document.body.appendChild(textarea);
|
|
41
|
+
const selection = document.getSelection();
|
|
42
|
+
const previousRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
|
|
43
|
+
textarea.select();
|
|
44
|
+
let copied = false;
|
|
45
|
+
try {
|
|
46
|
+
copied = document.execCommand('copy');
|
|
47
|
+
} catch {
|
|
48
|
+
copied = false;
|
|
49
|
+
}
|
|
50
|
+
textarea.remove();
|
|
51
|
+
if (previousRange && selection) {
|
|
52
|
+
selection.removeAllRanges();
|
|
53
|
+
selection.addRange(previousRange);
|
|
54
|
+
}
|
|
55
|
+
return copied;
|
|
56
|
+
}
|
|
57
|
+
exports.copyTextToClipboard = __webpack_exports__.copyTextToClipboard;
|
|
58
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
59
|
+
"copyTextToClipboard"
|
|
60
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
61
|
+
Object.defineProperty(exports, '__esModule', {
|
|
62
|
+
value: true
|
|
63
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/clipboard.ts"],"names":[],"mappings":"AAKA,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BxE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
async function copyTextToClipboard(text) {
|
|
2
|
+
if ("u" > typeof navigator && navigator.clipboard) try {
|
|
3
|
+
await navigator.clipboard.writeText(text);
|
|
4
|
+
return true;
|
|
5
|
+
} catch {}
|
|
6
|
+
if ("u" < typeof document) return false;
|
|
7
|
+
const textarea = document.createElement('textarea');
|
|
8
|
+
textarea.value = text;
|
|
9
|
+
textarea.setAttribute('readonly', '');
|
|
10
|
+
textarea.style.position = 'fixed';
|
|
11
|
+
textarea.style.opacity = '0';
|
|
12
|
+
document.body.appendChild(textarea);
|
|
13
|
+
const selection = document.getSelection();
|
|
14
|
+
const previousRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
|
|
15
|
+
textarea.select();
|
|
16
|
+
let copied = false;
|
|
17
|
+
try {
|
|
18
|
+
copied = document.execCommand('copy');
|
|
19
|
+
} catch {
|
|
20
|
+
copied = false;
|
|
21
|
+
}
|
|
22
|
+
textarea.remove();
|
|
23
|
+
if (previousRange && selection) {
|
|
24
|
+
selection.removeAllRanges();
|
|
25
|
+
selection.addRange(previousRange);
|
|
26
|
+
}
|
|
27
|
+
return copied;
|
|
28
|
+
}
|
|
29
|
+
export { copyTextToClipboard };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./JsonContainerEditor" (module) {
|
|
4
|
+
module.exports = require("./JsonContainerEditor.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./JsonLeafValueEditor" (module) {
|
|
7
|
+
module.exports = require("./JsonLeafValueEditor.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./JsonMultilineLeafEditor" (module) {
|
|
10
|
+
module.exports = require("./JsonMultilineLeafEditor.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./JsonTree?811b" (module) {
|
|
13
|
+
module.exports = require("./JsonTree.cjs");
|
|
14
|
+
},
|
|
15
|
+
"./JsonTree.types" (module) {
|
|
16
|
+
module.exports = require("./JsonTree.types.cjs");
|
|
17
|
+
},
|
|
18
|
+
"./JsonTreeToolbar" (module) {
|
|
19
|
+
module.exports = require("./JsonTreeToolbar.cjs");
|
|
20
|
+
},
|
|
21
|
+
"./JsonTypeBadge" (module) {
|
|
22
|
+
module.exports = require("./JsonTypeBadge.cjs");
|
|
23
|
+
},
|
|
24
|
+
"./buildJsonTree" (module) {
|
|
25
|
+
module.exports = require("./buildJsonTree.cjs");
|
|
26
|
+
},
|
|
27
|
+
"./clipboard" (module) {
|
|
28
|
+
module.exports = require("./clipboard.cjs");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var __webpack_module_cache__ = {};
|
|
32
|
+
function __webpack_require__(moduleId) {
|
|
33
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
34
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
35
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
36
|
+
exports: {}
|
|
37
|
+
};
|
|
38
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
39
|
+
return module.exports;
|
|
40
|
+
}
|
|
41
|
+
(()=>{
|
|
42
|
+
__webpack_require__.n = (module)=>{
|
|
43
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
44
|
+
__webpack_require__.d(getter, {
|
|
45
|
+
a: getter
|
|
46
|
+
});
|
|
47
|
+
return getter;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
(()=>{
|
|
51
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
52
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: definition[key]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
(()=>{
|
|
59
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
60
|
+
})();
|
|
61
|
+
(()=>{
|
|
62
|
+
__webpack_require__.r = (exports1)=>{
|
|
63
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
64
|
+
value: 'Module'
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
})();
|
|
71
|
+
var __webpack_exports__ = {};
|
|
72
|
+
(()=>{
|
|
73
|
+
__webpack_require__.r(__webpack_exports__);
|
|
74
|
+
var _buildJsonTree__rspack_import_0 = __webpack_require__("./buildJsonTree");
|
|
75
|
+
var __rspack_reexport = {};
|
|
76
|
+
for(const __rspack_import_key in _buildJsonTree__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_buildJsonTree__rspack_import_0[__rspack_import_key];
|
|
77
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
78
|
+
var _clipboard__rspack_import_1 = __webpack_require__("./clipboard");
|
|
79
|
+
var __rspack_reexport = {};
|
|
80
|
+
for(const __rspack_import_key in _clipboard__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_clipboard__rspack_import_1[__rspack_import_key];
|
|
81
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
82
|
+
var _JsonContainerEditor__rspack_import_2 = __webpack_require__("./JsonContainerEditor");
|
|
83
|
+
var __rspack_reexport = {};
|
|
84
|
+
for(const __rspack_import_key in _JsonContainerEditor__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonContainerEditor__rspack_import_2[__rspack_import_key];
|
|
85
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
86
|
+
var _JsonLeafValueEditor__rspack_import_3 = __webpack_require__("./JsonLeafValueEditor");
|
|
87
|
+
var __rspack_reexport = {};
|
|
88
|
+
for(const __rspack_import_key in _JsonLeafValueEditor__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonLeafValueEditor__rspack_import_3[__rspack_import_key];
|
|
89
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
90
|
+
var _JsonMultilineLeafEditor__rspack_import_4 = __webpack_require__("./JsonMultilineLeafEditor");
|
|
91
|
+
var __rspack_reexport = {};
|
|
92
|
+
for(const __rspack_import_key in _JsonMultilineLeafEditor__rspack_import_4)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonMultilineLeafEditor__rspack_import_4[__rspack_import_key];
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
94
|
+
var _JsonTree__rspack_import_5 = __webpack_require__("./JsonTree?811b");
|
|
95
|
+
var __rspack_reexport = {};
|
|
96
|
+
for(const __rspack_import_key in _JsonTree__rspack_import_5)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonTree__rspack_import_5[__rspack_import_key];
|
|
97
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
98
|
+
var _JsonTree_types__rspack_import_6 = __webpack_require__("./JsonTree.types");
|
|
99
|
+
var __rspack_reexport = {};
|
|
100
|
+
for(const __rspack_import_key in _JsonTree_types__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonTree_types__rspack_import_6[__rspack_import_key];
|
|
101
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
102
|
+
var _JsonTreeToolbar__rspack_import_7 = __webpack_require__("./JsonTreeToolbar");
|
|
103
|
+
var __rspack_reexport = {};
|
|
104
|
+
for(const __rspack_import_key in _JsonTreeToolbar__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonTreeToolbar__rspack_import_7[__rspack_import_key];
|
|
105
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
106
|
+
var _JsonTypeBadge__rspack_import_8 = __webpack_require__("./JsonTypeBadge");
|
|
107
|
+
var __rspack_reexport = {};
|
|
108
|
+
for(const __rspack_import_key in _JsonTypeBadge__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_JsonTypeBadge__rspack_import_8[__rspack_import_key];
|
|
109
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
110
|
+
})();
|
|
111
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
112
|
+
Object.defineProperty(exports, '__esModule', {
|
|
113
|
+
value: true
|
|
114
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './buildJsonTree';
|
|
2
|
+
export * from './clipboard';
|
|
3
|
+
export * from './JsonContainerEditor';
|
|
4
|
+
export * from './JsonLeafValueEditor';
|
|
5
|
+
export * from './JsonMultilineLeafEditor';
|
|
6
|
+
export * from './JsonTree';
|
|
7
|
+
export * from './JsonTree.types';
|
|
8
|
+
export * from './JsonTreeToolbar';
|
|
9
|
+
export * from './JsonTypeBadge';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./buildJsonTree.js";
|
|
2
|
+
export * from "./clipboard.js";
|
|
3
|
+
export * from "./JsonContainerEditor.js";
|
|
4
|
+
export * from "./JsonLeafValueEditor.js";
|
|
5
|
+
export * from "./JsonMultilineLeafEditor.js";
|
|
6
|
+
export * from "./JsonTree.js";
|
|
7
|
+
export * from "./JsonTree.types.js";
|
|
8
|
+
export * from "./JsonTreeToolbar.js";
|
|
9
|
+
export * from "./JsonTypeBadge.js";
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
isNumericEdit: ()=>isNumericEdit,
|
|
28
|
+
parseLeafValue: ()=>parseLeafValue,
|
|
29
|
+
resolveLeafEditType: ()=>resolveLeafEditType
|
|
30
|
+
});
|
|
31
|
+
function isNumericEdit(editType) {
|
|
32
|
+
return 'number' === editType || 'integer' === editType;
|
|
33
|
+
}
|
|
34
|
+
function resolveLeafEditType(type, schema) {
|
|
35
|
+
const declared = schema?.type === void 0 ? [] : [
|
|
36
|
+
schema.type
|
|
37
|
+
].flat();
|
|
38
|
+
const scalars = declared.filter((t)=>'string' === t || 'number' === t || 'integer' === t);
|
|
39
|
+
if (1 === scalars.length) {
|
|
40
|
+
const only = scalars[0];
|
|
41
|
+
return 'string' === only ? 'string' : 'integer' === only ? 'integer' : 'number';
|
|
42
|
+
}
|
|
43
|
+
if ('string' === type) return 'string';
|
|
44
|
+
if ('number' === type) return 'number';
|
|
45
|
+
return 'auto';
|
|
46
|
+
}
|
|
47
|
+
function parseLeafValue(raw, editType) {
|
|
48
|
+
if ('string' === editType) return raw;
|
|
49
|
+
if (isNumericEdit(editType)) {
|
|
50
|
+
if ('' === raw.trim()) return;
|
|
51
|
+
const parsed = Number(raw);
|
|
52
|
+
if (!Number.isFinite(parsed)) return;
|
|
53
|
+
if ('integer' === editType && !Number.isInteger(parsed)) return;
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
const trimmed = raw.trim();
|
|
57
|
+
if ('' === trimmed) return null;
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(trimmed);
|
|
60
|
+
} catch {
|
|
61
|
+
return raw;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.isNumericEdit = __webpack_exports__.isNumericEdit;
|
|
65
|
+
exports.parseLeafValue = __webpack_exports__.parseLeafValue;
|
|
66
|
+
exports.resolveLeafEditType = __webpack_exports__.resolveLeafEditType;
|
|
67
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
68
|
+
"isNumericEdit",
|
|
69
|
+
"parseLeafValue",
|
|
70
|
+
"resolveLeafEditType"
|
|
71
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
72
|
+
Object.defineProperty(exports, '__esModule', {
|
|
73
|
+
value: true
|
|
74
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JsonSchema, JsonTreeNodeType, JsonValue } from './JsonTree.types';
|
|
2
|
+
export type LeafEditType = 'string' | 'number' | 'integer' | 'auto';
|
|
3
|
+
export declare function isNumericEdit(editType: LeafEditType): boolean;
|
|
4
|
+
export declare function resolveLeafEditType(type: JsonTreeNodeType, schema: JsonSchema | undefined): LeafEditType;
|
|
5
|
+
export declare function parseLeafValue(raw: string, editType: LeafEditType): JsonValue | undefined;
|
|
6
|
+
//# sourceMappingURL=leafEditTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leafEditTypes.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/JsonTree/leafEditTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAGpE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAE7D;AAQD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,UAAU,GAAG,SAAS,GAC7B,YAAY,CAUd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAmBzF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function isNumericEdit(editType) {
|
|
2
|
+
return 'number' === editType || 'integer' === editType;
|
|
3
|
+
}
|
|
4
|
+
function resolveLeafEditType(type, schema) {
|
|
5
|
+
const declared = schema?.type === void 0 ? [] : [
|
|
6
|
+
schema.type
|
|
7
|
+
].flat();
|
|
8
|
+
const scalars = declared.filter((t)=>'string' === t || 'number' === t || 'integer' === t);
|
|
9
|
+
if (1 === scalars.length) {
|
|
10
|
+
const only = scalars[0];
|
|
11
|
+
return 'string' === only ? 'string' : 'integer' === only ? 'integer' : 'number';
|
|
12
|
+
}
|
|
13
|
+
if ('string' === type) return 'string';
|
|
14
|
+
if ('number' === type) return 'number';
|
|
15
|
+
return 'auto';
|
|
16
|
+
}
|
|
17
|
+
function parseLeafValue(raw, editType) {
|
|
18
|
+
if ('string' === editType) return raw;
|
|
19
|
+
if (isNumericEdit(editType)) {
|
|
20
|
+
if ('' === raw.trim()) return;
|
|
21
|
+
const parsed = Number(raw);
|
|
22
|
+
if (!Number.isFinite(parsed)) return;
|
|
23
|
+
if ('integer' === editType && !Number.isInteger(parsed)) return;
|
|
24
|
+
return parsed;
|
|
25
|
+
}
|
|
26
|
+
const trimmed = raw.trim();
|
|
27
|
+
if ('' === trimmed) return null;
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(trimmed);
|
|
30
|
+
} catch {
|
|
31
|
+
return raw;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export { isNumericEdit, parseLeafValue, resolveLeafEditType };
|