@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.
Files changed (162) hide show
  1. package/README.md +13 -0
  2. package/dist/components/forms/field-actions.cjs +181 -0
  3. package/dist/components/forms/field-actions.d.ts +131 -0
  4. package/dist/components/forms/field-actions.js +129 -0
  5. package/dist/components/forms/field-control.cjs +415 -0
  6. package/dist/components/forms/field-control.d.ts +52 -0
  7. package/dist/components/forms/field-control.js +372 -0
  8. package/dist/components/forms/field-renderer.cjs +77 -420
  9. package/dist/components/forms/field-renderer.d.ts +2 -3
  10. package/dist/components/forms/field-renderer.js +78 -421
  11. package/dist/components/forms/form-designer.cjs +7 -1
  12. package/dist/components/forms/form-designer.js +7 -1
  13. package/dist/components/forms/form-schema.d.ts +121 -2
  14. package/dist/components/forms/form-strings.cjs +67 -0
  15. package/dist/components/forms/form-strings.d.ts +30 -0
  16. package/dist/components/forms/form-strings.js +30 -0
  17. package/dist/components/forms/index.cjs +53 -9
  18. package/dist/components/forms/index.d.ts +6 -1
  19. package/dist/components/forms/index.js +6 -1
  20. package/dist/components/forms/literal-value-context.cjs +37 -0
  21. package/dist/components/forms/literal-value-context.d.ts +5 -0
  22. package/dist/components/forms/literal-value-context.js +3 -0
  23. package/dist/components/forms/metadata-form.cjs +100 -21
  24. package/dist/components/forms/metadata-form.d.ts +5 -0
  25. package/dist/components/forms/metadata-form.js +101 -22
  26. package/dist/components/forms/mode-aware-field.cjs +589 -0
  27. package/dist/components/forms/mode-aware-field.d.ts +15 -0
  28. package/dist/components/forms/mode-aware-field.js +555 -0
  29. package/dist/components/forms/opaque-value.cjs +44 -0
  30. package/dist/components/forms/opaque-value.d.ts +7 -0
  31. package/dist/components/forms/opaque-value.js +7 -0
  32. package/dist/components/forms/rules-engine.cjs +13 -0
  33. package/dist/components/forms/rules-engine.js +13 -0
  34. package/dist/components/forms/schema-serializer.cjs +8 -0
  35. package/dist/components/forms/schema-serializer.js +8 -0
  36. package/dist/components/forms/string-list-field.cjs +36 -18
  37. package/dist/components/forms/string-list-field.d.ts +6 -0
  38. package/dist/components/forms/string-list-field.js +35 -20
  39. package/dist/components/forms/validation-converter.cjs +32 -2
  40. package/dist/components/forms/validation-converter.d.ts +17 -1
  41. package/dist/components/forms/validation-converter.js +30 -3
  42. package/dist/components/forms/value-modes.cjs +253 -0
  43. package/dist/components/forms/value-modes.d.ts +236 -0
  44. package/dist/components/forms/value-modes.js +180 -0
  45. package/dist/components/ui/accordion.cjs +1 -0
  46. package/dist/components/ui/accordion.js +1 -0
  47. package/dist/components/ui/avatar.d.ts +1 -1
  48. package/dist/components/ui/badge.d.ts +1 -1
  49. package/dist/components/ui/boolean-radio-group.cjs +114 -0
  50. package/dist/components/ui/boolean-radio-group.d.ts +24 -0
  51. package/dist/components/ui/boolean-radio-group.js +77 -0
  52. package/dist/components/ui/button.d.ts +2 -2
  53. package/dist/components/ui/command.d.ts +7 -7
  54. package/dist/components/ui/dialog.cjs +1 -0
  55. package/dist/components/ui/dialog.js +1 -0
  56. package/dist/components/ui/drawer.cjs +1 -1
  57. package/dist/components/ui/drawer.js +1 -1
  58. package/dist/components/ui/field-addons/field-menu.cjs +1 -0
  59. package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
  60. package/dist/components/ui/field-addons/field-menu.js +1 -0
  61. package/dist/components/ui/field-addons/index.cjs +4 -0
  62. package/dist/components/ui/field-addons/index.d.ts +1 -0
  63. package/dist/components/ui/field-addons/index.js +2 -1
  64. package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
  65. package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
  66. package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
  67. package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
  68. package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
  69. package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
  70. package/dist/components/ui/form-field.cjs +2 -1
  71. package/dist/components/ui/form-field.d.ts +2 -0
  72. package/dist/components/ui/form-field.js +2 -1
  73. package/dist/components/ui/index.cjs +235 -191
  74. package/dist/components/ui/index.d.ts +4 -0
  75. package/dist/components/ui/index.js +4 -0
  76. package/dist/components/ui/input-group.cjs +6 -3
  77. package/dist/components/ui/input-group.d.ts +6 -5
  78. package/dist/components/ui/input-group.js +6 -3
  79. package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
  80. package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
  81. package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
  82. package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
  83. package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
  84. package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
  85. package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
  86. package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
  87. package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
  88. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
  89. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
  90. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
  91. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
  92. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
  93. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
  94. package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
  95. package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
  96. package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
  97. package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
  98. package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
  99. package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
  100. package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
  101. package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
  102. package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
  103. package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
  104. package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
  105. package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
  106. package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
  107. package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
  108. package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
  109. package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
  110. package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
  111. package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
  112. package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
  113. package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
  114. package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
  115. package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
  116. package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
  117. package/dist/components/ui/json-tree-view/RowActions.js +86 -0
  118. package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
  119. package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
  120. package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
  121. package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
  122. package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
  123. package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
  124. package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
  125. package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
  126. package/dist/components/ui/json-tree-view/clipboard.js +29 -0
  127. package/dist/components/ui/json-tree-view/index.cjs +175 -0
  128. package/dist/components/ui/json-tree-view/index.d.ts +10 -0
  129. package/dist/components/ui/json-tree-view/index.js +11 -0
  130. package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
  131. package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
  132. package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
  133. package/dist/components/ui/json-tree-view/strings.cjs +122 -0
  134. package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
  135. package/dist/components/ui/json-tree-view/strings.js +79 -0
  136. package/dist/components/ui/prompt-value-control.cjs +70 -0
  137. package/dist/components/ui/prompt-value-control.d.ts +28 -0
  138. package/dist/components/ui/prompt-value-control.js +36 -0
  139. package/dist/components/ui/sheet.cjs +2 -2
  140. package/dist/components/ui/sheet.d.ts +1 -1
  141. package/dist/components/ui/sheet.js +2 -2
  142. package/dist/components/ui/spinner.d.ts +1 -1
  143. package/dist/components/ui/switch.d.ts +2 -2
  144. package/dist/components/ui/textarea.cjs +1 -1
  145. package/dist/components/ui/textarea.js +1 -1
  146. package/dist/components/ui/toggle-group.d.ts +2 -2
  147. package/dist/components/ui/toggle.d.ts +2 -2
  148. package/dist/components/ui/variable-value-control.cjs +98 -0
  149. package/dist/components/ui/variable-value-control.d.ts +35 -0
  150. package/dist/components/ui/variable-value-control.js +64 -0
  151. package/dist/index.cjs +145 -16
  152. package/dist/index.d.ts +21 -3
  153. package/dist/index.js +11 -2
  154. package/dist/lib/index.cjs +4 -1
  155. package/dist/lib/index.d.ts +1 -1
  156. package/dist/lib/index.js +2 -2
  157. package/dist/lib/utils.cjs +21 -1
  158. package/dist/lib/utils.d.ts +8 -0
  159. package/dist/lib/utils.js +18 -1
  160. package/dist/styles.css +278 -0
  161. package/dist/tailwind.css +72 -0
  162. package/package.json +1 -1
@@ -0,0 +1,324 @@
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
+ appendPathSegment: ()=>appendPathSegment,
28
+ buildJsonTree: ()=>buildJsonTree,
29
+ collectContainerPaths: ()=>collectContainerPaths,
30
+ flattenJsonTree: ()=>flattenJsonTree,
31
+ formatLeafValue: ()=>formatLeafValue,
32
+ getValueAtPath: ()=>getValueAtPath,
33
+ inferValueType: ()=>inferValueType,
34
+ isArrayItemTemplateRoot: ()=>isArrayItemTemplateRoot,
35
+ isJsonObject: ()=>isJsonObject,
36
+ removeValueAtPath: ()=>removeValueAtPath,
37
+ schemaDisplayType: ()=>schemaDisplayType,
38
+ setValueAtPath: ()=>setValueAtPath
39
+ });
40
+ const IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
41
+ function hasOwn(object, key) {
42
+ return Object.prototype.hasOwnProperty.call(object, key);
43
+ }
44
+ function isJsonObject(value) {
45
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
46
+ }
47
+ function appendPathSegment(path, segment) {
48
+ if ('number' == typeof segment) return `${path}[${segment}]`;
49
+ if (IDENTIFIER_RE.test(segment)) return path ? `${path}.${segment}` : segment;
50
+ return `${path}[${JSON.stringify(segment)}]`;
51
+ }
52
+ function inferValueType(value) {
53
+ if (null === value) return 'null';
54
+ if (Array.isArray(value)) return 'array';
55
+ switch(typeof value){
56
+ case 'string':
57
+ return 'string';
58
+ case 'number':
59
+ return 'number';
60
+ case 'boolean':
61
+ return 'boolean';
62
+ default:
63
+ return 'object';
64
+ }
65
+ }
66
+ function declaredTypes(schema) {
67
+ if (!schema?.type) return;
68
+ return Array.isArray(schema.type) ? schema.type : [
69
+ schema.type
70
+ ];
71
+ }
72
+ function schemaDisplayType(schema) {
73
+ const types = declaredTypes(schema);
74
+ const first = types?.find((t)=>'null' !== t) ?? types?.[0];
75
+ if (first) return 'integer' === first ? 'number' : first;
76
+ if (schema?.properties) return 'object';
77
+ if (schema?.items) return 'array';
78
+ const enumSample = schema?.enum?.find((v)=>null !== v);
79
+ if (void 0 !== enumSample) return inferValueType(enumSample);
80
+ return 'null';
81
+ }
82
+ function buildNode(input) {
83
+ const type = input.hasValue ? inferValueType(input.value) : schemaDisplayType(input.schema);
84
+ const node = {
85
+ key: input.key,
86
+ path: input.path,
87
+ segments: input.segments,
88
+ type,
89
+ required: input.required,
90
+ schema: input.schema
91
+ };
92
+ if (input.hasValue) node.value = input.value;
93
+ if (input.isTemplate) node.isArrayItemTemplate = true;
94
+ if ('object' === type) node.children = buildObjectChildren(input.hasValue ? input.value : void 0, input.schema, input.segments, input.path, input.isTemplate);
95
+ else if ('array' === type) node.children = buildArrayChildren(input.schema, input.value, input.hasValue, input.segments, input.path, input.isTemplate);
96
+ return node;
97
+ }
98
+ function buildArrayChildren(schema, value, hasValue, segments, path, isTemplate) {
99
+ const items = hasValue && Array.isArray(value) ? value : [];
100
+ if (items.length > 0) return items.map((item, index)=>buildNode({
101
+ key: String(index),
102
+ segments: [
103
+ ...segments,
104
+ index
105
+ ],
106
+ path: appendPathSegment(path, index),
107
+ schema: schema?.items,
108
+ value: item,
109
+ hasValue: true,
110
+ isTemplate
111
+ }));
112
+ if (schema?.items) return [
113
+ buildNode({
114
+ key: '0',
115
+ segments: [
116
+ ...segments,
117
+ 0
118
+ ],
119
+ path: appendPathSegment(path, 0),
120
+ schema: schema.items,
121
+ hasValue: false,
122
+ isTemplate: true
123
+ })
124
+ ];
125
+ return [];
126
+ }
127
+ function buildObjectChildren(value, schema, segments, path, isTemplate) {
128
+ const properties = schema?.properties ?? {};
129
+ const required = new Set(schema?.required ?? []);
130
+ const additional = 'object' == typeof schema?.additionalProperties ? schema.additionalProperties : void 0;
131
+ const children = [];
132
+ for (const [key, childSchema] of Object.entries(properties)){
133
+ const hasValue = void 0 !== value && hasOwn(value, key);
134
+ children.push(buildNode({
135
+ key,
136
+ segments: [
137
+ ...segments,
138
+ key
139
+ ],
140
+ path: appendPathSegment(path, key),
141
+ schema: childSchema,
142
+ value: hasValue ? value?.[key] : void 0,
143
+ hasValue,
144
+ required: required.has(key),
145
+ isTemplate
146
+ }));
147
+ }
148
+ if (void 0 !== value) {
149
+ for (const [key, childValue] of Object.entries(value))if (!hasOwn(properties, key)) children.push(buildNode({
150
+ key,
151
+ segments: [
152
+ ...segments,
153
+ key
154
+ ],
155
+ path: appendPathSegment(path, key),
156
+ schema: additional,
157
+ value: childValue,
158
+ hasValue: true
159
+ }));
160
+ }
161
+ return children;
162
+ }
163
+ function buildJsonTree(options) {
164
+ const { schema, value, basePath = '' } = options;
165
+ const rootIsArray = void 0 !== value ? Array.isArray(value) : !!schema && 'array' === schemaDisplayType(schema);
166
+ if (rootIsArray) return buildArrayChildren(schema, value, void 0 !== value, [], basePath);
167
+ return buildObjectChildren(isJsonObject(value) ? value : void 0, schema, [], basePath);
168
+ }
169
+ function isArrayItemTemplateRoot(node) {
170
+ return !!node.isArrayItemTemplate && 'number' == typeof node.segments[node.segments.length - 1];
171
+ }
172
+ function nodeSelfMatchesQuery(node, query, displayTexts) {
173
+ if (node.key.toLowerCase().includes(query)) return true;
174
+ const display = displayTexts?.(node);
175
+ if (display?.label?.toLowerCase().includes(query)) return true;
176
+ if (display?.sublabel?.toLowerCase().includes(query)) return true;
177
+ return void 0 !== node.value && null !== node.value && 'object' != typeof node.value && String(node.value).toLowerCase().includes(query);
178
+ }
179
+ function nodeMatchesQuery(node, query, displayTexts) {
180
+ if (nodeSelfMatchesQuery(node, query, displayTexts)) return true;
181
+ return node.children?.some((c)=>nodeMatchesQuery(c, query, displayTexts)) ?? false;
182
+ }
183
+ function nodeOrDescendantMatches(node, predicate) {
184
+ if (predicate(node)) return true;
185
+ return node.children?.some((c)=>nodeOrDescendantMatches(c, predicate)) ?? false;
186
+ }
187
+ function flattenJsonTree(nodes, options = {}, depth = 0) {
188
+ const { collapsed = {}, filterPredicate } = options;
189
+ const query = options.query?.trim().toLowerCase() ?? '';
190
+ const rows = [];
191
+ for (const node of nodes){
192
+ const selfQueryMatch = !!query && nodeSelfMatchesQuery(node, query, options.displayTexts);
193
+ if (query && !selfQueryMatch && !(node.children?.some((c)=>nodeMatchesQuery(c, query, options.displayTexts)) ?? false)) continue;
194
+ const selfPredicateMatch = !!filterPredicate && filterPredicate(node);
195
+ if (!filterPredicate || selfPredicateMatch || (node.children?.some((c)=>nodeOrDescendantMatches(c, filterPredicate)) ?? false)) {
196
+ rows.push({
197
+ node,
198
+ depth
199
+ });
200
+ if (node.children && !collapsed[node.path]) {
201
+ const childOptions = selfQueryMatch || selfPredicateMatch ? {
202
+ ...options,
203
+ query: selfQueryMatch ? '' : options.query,
204
+ filterPredicate: selfPredicateMatch ? void 0 : filterPredicate
205
+ } : options;
206
+ for (const row of flattenJsonTree(node.children, childOptions, depth + 1))rows.push(row);
207
+ }
208
+ }
209
+ }
210
+ return rows;
211
+ }
212
+ function collectContainerPaths(nodes, depth = 0) {
213
+ const paths = [];
214
+ for (const node of nodes)if (node.children) {
215
+ paths.push({
216
+ path: node.path,
217
+ depth
218
+ });
219
+ for (const child of collectContainerPaths(node.children, depth + 1))paths.push(child);
220
+ }
221
+ return paths;
222
+ }
223
+ function getValueAtPath(root, segments) {
224
+ let current = root;
225
+ for (const segment of segments)if ('number' == typeof segment) {
226
+ if (!Array.isArray(current)) return;
227
+ current = current[segment];
228
+ } else {
229
+ if (!isJsonObject(current) || !hasOwn(current, segment)) return;
230
+ current = current[segment];
231
+ }
232
+ return current;
233
+ }
234
+ function setValueAtPath(root, segments, value) {
235
+ const [head, ...rest] = segments;
236
+ if (void 0 === head) return value;
237
+ if ('number' == typeof head) {
238
+ const array = Array.isArray(root) ? [
239
+ ...root
240
+ ] : [];
241
+ array[head] = setValueAtPath(array[head], rest, value);
242
+ return array;
243
+ }
244
+ const object = isJsonObject(root) ? {
245
+ ...root
246
+ } : {};
247
+ const previous = hasOwn(object, head) ? object[head] : void 0;
248
+ Object.defineProperty(object, head, {
249
+ value: setValueAtPath(previous, rest, value),
250
+ enumerable: true,
251
+ configurable: true,
252
+ writable: true
253
+ });
254
+ return object;
255
+ }
256
+ function removeValueAtPath(root, segments) {
257
+ const [head, ...rest] = segments;
258
+ if (void 0 === head) return;
259
+ if ('number' == typeof head) {
260
+ if (!Array.isArray(root) || head >= root.length) return root;
261
+ if (0 === rest.length) {
262
+ const array = [
263
+ ...root
264
+ ];
265
+ array.splice(head, 1);
266
+ return array;
267
+ }
268
+ const child = removeValueAtPath(root[head], rest);
269
+ if (child === root[head]) return root;
270
+ const array = [
271
+ ...root
272
+ ];
273
+ array[head] = child;
274
+ return array;
275
+ }
276
+ if (!isJsonObject(root) || !hasOwn(root, head)) return root;
277
+ if (0 === rest.length) {
278
+ const object = {
279
+ ...root
280
+ };
281
+ delete object[head];
282
+ return object;
283
+ }
284
+ const child = removeValueAtPath(root[head], rest);
285
+ if (child === root[head]) return root;
286
+ return {
287
+ ...root,
288
+ [head]: child
289
+ };
290
+ }
291
+ function formatLeafValue(type, value, options) {
292
+ if (null == value) return 'null';
293
+ if ('string' === type) return options?.preserveStringWhitespace ? `"${value}"` : JSON.stringify(value);
294
+ return String(value);
295
+ }
296
+ exports.appendPathSegment = __webpack_exports__.appendPathSegment;
297
+ exports.buildJsonTree = __webpack_exports__.buildJsonTree;
298
+ exports.collectContainerPaths = __webpack_exports__.collectContainerPaths;
299
+ exports.flattenJsonTree = __webpack_exports__.flattenJsonTree;
300
+ exports.formatLeafValue = __webpack_exports__.formatLeafValue;
301
+ exports.getValueAtPath = __webpack_exports__.getValueAtPath;
302
+ exports.inferValueType = __webpack_exports__.inferValueType;
303
+ exports.isArrayItemTemplateRoot = __webpack_exports__.isArrayItemTemplateRoot;
304
+ exports.isJsonObject = __webpack_exports__.isJsonObject;
305
+ exports.removeValueAtPath = __webpack_exports__.removeValueAtPath;
306
+ exports.schemaDisplayType = __webpack_exports__.schemaDisplayType;
307
+ exports.setValueAtPath = __webpack_exports__.setValueAtPath;
308
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
309
+ "appendPathSegment",
310
+ "buildJsonTree",
311
+ "collectContainerPaths",
312
+ "flattenJsonTree",
313
+ "formatLeafValue",
314
+ "getValueAtPath",
315
+ "inferValueType",
316
+ "isArrayItemTemplateRoot",
317
+ "isJsonObject",
318
+ "removeValueAtPath",
319
+ "schemaDisplayType",
320
+ "setValueAtPath"
321
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
322
+ Object.defineProperty(exports, '__esModule', {
323
+ value: true
324
+ });
@@ -0,0 +1,75 @@
1
+ import type { JsonContainer, JsonObject, JsonSchema, JsonTreeNode, JsonTreeNodeType, JsonValue, PathSegment } from './JsonTree.types';
2
+ export declare function isJsonObject(value: JsonValue | undefined): value is JsonObject;
3
+ /** Appends a segment to an expression path (`a.b`, `a["x-y"]`, `a[0]`). */
4
+ export declare function appendPathSegment(path: string, segment: PathSegment): string;
5
+ export declare function inferValueType(value: JsonValue): JsonTreeNodeType;
6
+ /** The type a schema-only (unset) node should display as. */
7
+ export declare function schemaDisplayType(schema: JsonSchema | undefined): JsonTreeNodeType;
8
+ export interface BuildJsonTreeOptions {
9
+ schema?: JsonSchema;
10
+ /** Root value to render. Must be an object or array (fields of a container). */
11
+ value?: JsonContainer;
12
+ /** Prefix prepended to every path (e.g. a node id). Default: none. */
13
+ basePath?: string;
14
+ }
15
+ /**
16
+ * Merges a JSON Schema with a JSON value into a tree.
17
+ *
18
+ * Returns the children of the root: schema-declared entries first (rendered
19
+ * even when the value omits them, as "unset"), then value entries the schema
20
+ * does not declare. Without a schema the tree is value-driven.
21
+ */
22
+ export declare function buildJsonTree(options: BuildJsonTreeOptions): JsonTreeNode[];
23
+ /**
24
+ * True for the synthesized array-item preview node itself (the "item" row), as
25
+ * opposed to its descendant fields. Only array elements carry a numeric final
26
+ * segment, and a preview subtree has no real elements, so a numeric tail marks
27
+ * the preview item at any nesting depth. Used to label the row and to keep it
28
+ * out of the parent array's item count.
29
+ */
30
+ export declare function isArrayItemTemplateRoot(node: JsonTreeNode): boolean;
31
+ export interface FlatJsonTreeRow {
32
+ node: JsonTreeNode;
33
+ depth: number;
34
+ }
35
+ /** Consumer display texts for a node, so search can match them alongside the raw key. */
36
+ export type NodeDisplayTexts = (node: JsonTreeNode) => {
37
+ label?: string;
38
+ sublabel?: string;
39
+ } | undefined;
40
+ export interface FlattenOptions {
41
+ collapsed?: Record<string, boolean>;
42
+ query?: string;
43
+ /**
44
+ * Rows are kept when the node (or any descendant) matches; a node that
45
+ * matches directly shows its whole subtree.
46
+ */
47
+ filterPredicate?: (node: JsonTreeNode) => boolean;
48
+ /** Lets search also match consumer display labels (e.g. decoration labels). */
49
+ displayTexts?: NodeDisplayTexts;
50
+ }
51
+ /** Flattens the tree to visible rows, honoring collapse state, search, and filter. */
52
+ export declare function flattenJsonTree(nodes: JsonTreeNode[], options?: FlattenOptions, depth?: number): FlatJsonTreeRow[];
53
+ export interface ContainerPath {
54
+ path: string;
55
+ depth: number;
56
+ }
57
+ /** All container (object/array) paths in the tree, with their depth. */
58
+ export declare function collectContainerPaths(nodes: JsonTreeNode[], depth?: number): ContainerPath[];
59
+ export declare function getValueAtPath(root: JsonValue | undefined, segments: PathSegment[]): JsonValue | undefined;
60
+ /**
61
+ * Returns a copy of `root` with `value` set at `segments`, creating missing
62
+ * containers along the way (arrays for numeric segments, objects otherwise).
63
+ * This is how edits on schema-declared but absent branches extend the value.
64
+ */
65
+ export declare function setValueAtPath(root: JsonValue | undefined, segments: PathSegment[], value: JsonValue): JsonValue;
66
+ /**
67
+ * Returns a copy of `root` with the entry at `segments` removed (object keys
68
+ * are deleted, array items spliced out). Removing the root itself (`segments`
69
+ * empty) returns undefined. Paths that don't resolve return `root` unchanged.
70
+ */
71
+ export declare function removeValueAtPath(root: JsonValue | undefined, segments: PathSegment[]): JsonValue | undefined;
72
+ /** Formats a leaf value for display (`"text"`, `42`, `true`, `null`). */
73
+ export declare function formatLeafValue(type: JsonTreeNodeType, value: JsonValue | undefined, options?: {
74
+ preserveStringWhitespace?: boolean;
75
+ }): string;
@@ -0,0 +1,257 @@
1
+ const IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
2
+ function hasOwn(object, key) {
3
+ return Object.prototype.hasOwnProperty.call(object, key);
4
+ }
5
+ function isJsonObject(value) {
6
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
7
+ }
8
+ function appendPathSegment(path, segment) {
9
+ if ('number' == typeof segment) return `${path}[${segment}]`;
10
+ if (IDENTIFIER_RE.test(segment)) return path ? `${path}.${segment}` : segment;
11
+ return `${path}[${JSON.stringify(segment)}]`;
12
+ }
13
+ function inferValueType(value) {
14
+ if (null === value) return 'null';
15
+ if (Array.isArray(value)) return 'array';
16
+ switch(typeof value){
17
+ case 'string':
18
+ return 'string';
19
+ case 'number':
20
+ return 'number';
21
+ case 'boolean':
22
+ return 'boolean';
23
+ default:
24
+ return 'object';
25
+ }
26
+ }
27
+ function declaredTypes(schema) {
28
+ if (!schema?.type) return;
29
+ return Array.isArray(schema.type) ? schema.type : [
30
+ schema.type
31
+ ];
32
+ }
33
+ function schemaDisplayType(schema) {
34
+ const types = declaredTypes(schema);
35
+ const first = types?.find((t)=>'null' !== t) ?? types?.[0];
36
+ if (first) return 'integer' === first ? 'number' : first;
37
+ if (schema?.properties) return 'object';
38
+ if (schema?.items) return 'array';
39
+ const enumSample = schema?.enum?.find((v)=>null !== v);
40
+ if (void 0 !== enumSample) return inferValueType(enumSample);
41
+ return 'null';
42
+ }
43
+ function buildNode(input) {
44
+ const type = input.hasValue ? inferValueType(input.value) : schemaDisplayType(input.schema);
45
+ const node = {
46
+ key: input.key,
47
+ path: input.path,
48
+ segments: input.segments,
49
+ type,
50
+ required: input.required,
51
+ schema: input.schema
52
+ };
53
+ if (input.hasValue) node.value = input.value;
54
+ if (input.isTemplate) node.isArrayItemTemplate = true;
55
+ if ('object' === type) node.children = buildObjectChildren(input.hasValue ? input.value : void 0, input.schema, input.segments, input.path, input.isTemplate);
56
+ else if ('array' === type) node.children = buildArrayChildren(input.schema, input.value, input.hasValue, input.segments, input.path, input.isTemplate);
57
+ return node;
58
+ }
59
+ function buildArrayChildren(schema, value, hasValue, segments, path, isTemplate) {
60
+ const items = hasValue && Array.isArray(value) ? value : [];
61
+ if (items.length > 0) return items.map((item, index)=>buildNode({
62
+ key: String(index),
63
+ segments: [
64
+ ...segments,
65
+ index
66
+ ],
67
+ path: appendPathSegment(path, index),
68
+ schema: schema?.items,
69
+ value: item,
70
+ hasValue: true,
71
+ isTemplate
72
+ }));
73
+ if (schema?.items) return [
74
+ buildNode({
75
+ key: '0',
76
+ segments: [
77
+ ...segments,
78
+ 0
79
+ ],
80
+ path: appendPathSegment(path, 0),
81
+ schema: schema.items,
82
+ hasValue: false,
83
+ isTemplate: true
84
+ })
85
+ ];
86
+ return [];
87
+ }
88
+ function buildObjectChildren(value, schema, segments, path, isTemplate) {
89
+ const properties = schema?.properties ?? {};
90
+ const required = new Set(schema?.required ?? []);
91
+ const additional = 'object' == typeof schema?.additionalProperties ? schema.additionalProperties : void 0;
92
+ const children = [];
93
+ for (const [key, childSchema] of Object.entries(properties)){
94
+ const hasValue = void 0 !== value && hasOwn(value, key);
95
+ children.push(buildNode({
96
+ key,
97
+ segments: [
98
+ ...segments,
99
+ key
100
+ ],
101
+ path: appendPathSegment(path, key),
102
+ schema: childSchema,
103
+ value: hasValue ? value?.[key] : void 0,
104
+ hasValue,
105
+ required: required.has(key),
106
+ isTemplate
107
+ }));
108
+ }
109
+ if (void 0 !== value) {
110
+ for (const [key, childValue] of Object.entries(value))if (!hasOwn(properties, key)) children.push(buildNode({
111
+ key,
112
+ segments: [
113
+ ...segments,
114
+ key
115
+ ],
116
+ path: appendPathSegment(path, key),
117
+ schema: additional,
118
+ value: childValue,
119
+ hasValue: true
120
+ }));
121
+ }
122
+ return children;
123
+ }
124
+ function buildJsonTree(options) {
125
+ const { schema, value, basePath = '' } = options;
126
+ const rootIsArray = void 0 !== value ? Array.isArray(value) : !!schema && 'array' === schemaDisplayType(schema);
127
+ if (rootIsArray) return buildArrayChildren(schema, value, void 0 !== value, [], basePath);
128
+ return buildObjectChildren(isJsonObject(value) ? value : void 0, schema, [], basePath);
129
+ }
130
+ function isArrayItemTemplateRoot(node) {
131
+ return !!node.isArrayItemTemplate && 'number' == typeof node.segments[node.segments.length - 1];
132
+ }
133
+ function nodeSelfMatchesQuery(node, query, displayTexts) {
134
+ if (node.key.toLowerCase().includes(query)) return true;
135
+ const display = displayTexts?.(node);
136
+ if (display?.label?.toLowerCase().includes(query)) return true;
137
+ if (display?.sublabel?.toLowerCase().includes(query)) return true;
138
+ return void 0 !== node.value && null !== node.value && 'object' != typeof node.value && String(node.value).toLowerCase().includes(query);
139
+ }
140
+ function nodeMatchesQuery(node, query, displayTexts) {
141
+ if (nodeSelfMatchesQuery(node, query, displayTexts)) return true;
142
+ return node.children?.some((c)=>nodeMatchesQuery(c, query, displayTexts)) ?? false;
143
+ }
144
+ function nodeOrDescendantMatches(node, predicate) {
145
+ if (predicate(node)) return true;
146
+ return node.children?.some((c)=>nodeOrDescendantMatches(c, predicate)) ?? false;
147
+ }
148
+ function flattenJsonTree(nodes, options = {}, depth = 0) {
149
+ const { collapsed = {}, filterPredicate } = options;
150
+ const query = options.query?.trim().toLowerCase() ?? '';
151
+ const rows = [];
152
+ for (const node of nodes){
153
+ const selfQueryMatch = !!query && nodeSelfMatchesQuery(node, query, options.displayTexts);
154
+ if (query && !selfQueryMatch && !(node.children?.some((c)=>nodeMatchesQuery(c, query, options.displayTexts)) ?? false)) continue;
155
+ const selfPredicateMatch = !!filterPredicate && filterPredicate(node);
156
+ if (!filterPredicate || selfPredicateMatch || (node.children?.some((c)=>nodeOrDescendantMatches(c, filterPredicate)) ?? false)) {
157
+ rows.push({
158
+ node,
159
+ depth
160
+ });
161
+ if (node.children && !collapsed[node.path]) {
162
+ const childOptions = selfQueryMatch || selfPredicateMatch ? {
163
+ ...options,
164
+ query: selfQueryMatch ? '' : options.query,
165
+ filterPredicate: selfPredicateMatch ? void 0 : filterPredicate
166
+ } : options;
167
+ for (const row of flattenJsonTree(node.children, childOptions, depth + 1))rows.push(row);
168
+ }
169
+ }
170
+ }
171
+ return rows;
172
+ }
173
+ function collectContainerPaths(nodes, depth = 0) {
174
+ const paths = [];
175
+ for (const node of nodes)if (node.children) {
176
+ paths.push({
177
+ path: node.path,
178
+ depth
179
+ });
180
+ for (const child of collectContainerPaths(node.children, depth + 1))paths.push(child);
181
+ }
182
+ return paths;
183
+ }
184
+ function getValueAtPath(root, segments) {
185
+ let current = root;
186
+ for (const segment of segments)if ('number' == typeof segment) {
187
+ if (!Array.isArray(current)) return;
188
+ current = current[segment];
189
+ } else {
190
+ if (!isJsonObject(current) || !hasOwn(current, segment)) return;
191
+ current = current[segment];
192
+ }
193
+ return current;
194
+ }
195
+ function setValueAtPath(root, segments, value) {
196
+ const [head, ...rest] = segments;
197
+ if (void 0 === head) return value;
198
+ if ('number' == typeof head) {
199
+ const array = Array.isArray(root) ? [
200
+ ...root
201
+ ] : [];
202
+ array[head] = setValueAtPath(array[head], rest, value);
203
+ return array;
204
+ }
205
+ const object = isJsonObject(root) ? {
206
+ ...root
207
+ } : {};
208
+ const previous = hasOwn(object, head) ? object[head] : void 0;
209
+ Object.defineProperty(object, head, {
210
+ value: setValueAtPath(previous, rest, value),
211
+ enumerable: true,
212
+ configurable: true,
213
+ writable: true
214
+ });
215
+ return object;
216
+ }
217
+ function removeValueAtPath(root, segments) {
218
+ const [head, ...rest] = segments;
219
+ if (void 0 === head) return;
220
+ if ('number' == typeof head) {
221
+ if (!Array.isArray(root) || head >= root.length) return root;
222
+ if (0 === rest.length) {
223
+ const array = [
224
+ ...root
225
+ ];
226
+ array.splice(head, 1);
227
+ return array;
228
+ }
229
+ const child = removeValueAtPath(root[head], rest);
230
+ if (child === root[head]) return root;
231
+ const array = [
232
+ ...root
233
+ ];
234
+ array[head] = child;
235
+ return array;
236
+ }
237
+ if (!isJsonObject(root) || !hasOwn(root, head)) return root;
238
+ if (0 === rest.length) {
239
+ const object = {
240
+ ...root
241
+ };
242
+ delete object[head];
243
+ return object;
244
+ }
245
+ const child = removeValueAtPath(root[head], rest);
246
+ if (child === root[head]) return root;
247
+ return {
248
+ ...root,
249
+ [head]: child
250
+ };
251
+ }
252
+ function formatLeafValue(type, value, options) {
253
+ if (null == value) return 'null';
254
+ if ('string' === type) return options?.preserveStringWhitespace ? `"${value}"` : JSON.stringify(value);
255
+ return String(value);
256
+ }
257
+ export { appendPathSegment, buildJsonTree, collectContainerPaths, flattenJsonTree, formatLeafValue, getValueAtPath, inferValueType, isArrayItemTemplateRoot, isJsonObject, removeValueAtPath, schemaDisplayType, setValueAtPath };