xmlui 0.9.78 → 0.9.80
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/lib/{index-j0JcJZMC.mjs → index-DO8H2Odv.mjs} +19070 -14106
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-Co9BqeUA.mjs → initMock-CYAkCVnp.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +11 -9
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{collectedComponentMetadata-tSxX8HKm.mjs → collectedComponentMetadata-uE4L7cM3.mjs} +23626 -18671
- package/dist/metadata/{initMock-B7VL6XTr.mjs → initMock-CqvnqrIU.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +135 -123
- package/dist/scripts/bin/build.js +6 -1
- package/dist/scripts/bin/index.js +4 -4
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/ComponentProvider.js +6 -2
- package/dist/scripts/src/components/EmojiSelector/DefaultProps.js +9 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +2 -1
- package/dist/scripts/src/components/EmojiSelector/EmojiSelectorNative.js +5 -8
- package/dist/scripts/src/components/FormItem/FormItem.js +21 -2
- package/dist/scripts/src/components/FormItem/FormItemNative.js +2 -2
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -3
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +7 -6
- package/dist/scripts/src/components/NumberBox/NumberBox.js +6 -1
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +1 -0
- package/dist/scripts/src/components/TableEditor/TableEditor.js +2 -132
- package/dist/scripts/src/components/TableEditor/TableEditorNative.js +133 -5
- package/dist/scripts/src/components-core/ComponentViewer.js +66 -0
- package/dist/scripts/src/components-core/InspectorContext.js +0 -15
- package/dist/scripts/src/components-core/abstractions/standalone.js +2 -0
- package/dist/scripts/src/components-core/devtools/InspectorDialog.js +135 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +5 -2
- package/dist/scripts/src/language-server/services/common/metadata-utils.js +157 -0
- package/dist/scripts/src/parsers/xmlui-parser/index.js +29 -0
- package/dist/scripts/src/parsers/xmlui-parser/lint.js +165 -0
- package/dist/scripts/src/parsers/xmlui-parser/xmlui-serializer.js +582 -0
- package/dist/scripts/src/parsers/xmlui-parser/xmlui-tree.js +2 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +11 -9
- package/dist/standalone/xmlui-standalone.umd.js +277 -265
- package/package.json +1 -1
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlUiHelper = void 0;
|
|
4
|
+
const transform_1 = require("./transform");
|
|
5
|
+
const attrBreakRegex = /[\r\n<>'"&]/;
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for XMLUI serialization and parsing
|
|
8
|
+
*/
|
|
9
|
+
class XmlUiHelper {
|
|
10
|
+
/**
|
|
11
|
+
* Serialize the specified XML fragment into a string
|
|
12
|
+
* @param xml XML fragment to serialize
|
|
13
|
+
* @param options Formatting options to use
|
|
14
|
+
*/
|
|
15
|
+
serialize(xml, options) {
|
|
16
|
+
const fragment = Array.isArray(xml) ? xml : [xml];
|
|
17
|
+
return serializeFragment(fragment, 0);
|
|
18
|
+
function serializeFragment(nodes, depth) {
|
|
19
|
+
return nodes
|
|
20
|
+
.map((n) => serializeNode(n, depth))
|
|
21
|
+
.join((options === null || options === void 0 ? void 0 : options.prettify) ? "\n" + getIndent(depth) : "");
|
|
22
|
+
}
|
|
23
|
+
function serializeNode(node, depth) {
|
|
24
|
+
switch (node.type) {
|
|
25
|
+
case "XmlUiComment":
|
|
26
|
+
return serializeXmlComment(node, depth);
|
|
27
|
+
case "XmlUiElement":
|
|
28
|
+
return serializeXmlElement(node, depth);
|
|
29
|
+
default:
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function getIndent(depth) {
|
|
34
|
+
var _a;
|
|
35
|
+
return (options === null || options === void 0 ? void 0 : options.prettify) ? "".padEnd(((_a = options === null || options === void 0 ? void 0 : options.indents) !== null && _a !== void 0 ? _a : 2) * depth, " ") : "";
|
|
36
|
+
}
|
|
37
|
+
function serializeXmlComment(node, depth) {
|
|
38
|
+
return `${getIndent(depth)}<!--${node.text}-->`;
|
|
39
|
+
}
|
|
40
|
+
function serializeXmlElement(node, depth) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
42
|
+
let elementStr = `${getIndent(depth)}<${nodeName()}`;
|
|
43
|
+
const hasAttrs = ((_b = (_a = node.attributes) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
44
|
+
const hasChildren = ((_d = (_c = node.childNodes) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0;
|
|
45
|
+
if (node.text || hasAttrs || hasChildren) {
|
|
46
|
+
// --- Indicate that the node has not yet been broken into multiple lines
|
|
47
|
+
if (hasAttrs) {
|
|
48
|
+
// --- Render attributes
|
|
49
|
+
const attrTexts = node.attributes.map((a) => serializeXmlAttribute(a));
|
|
50
|
+
if (!(options === null || options === void 0 ? void 0 : options.prettify)) {
|
|
51
|
+
elementStr += " " + attrTexts.join(" ");
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// --- Check line overflow
|
|
55
|
+
const nodeLength = elementStr.length +
|
|
56
|
+
1 + // --- Space after
|
|
57
|
+
attrTexts.join(" ").length + // --- Attributes total length
|
|
58
|
+
(hasChildren ? 1 : ((_e = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _e !== void 0 ? _e : false) ? 3 : 2); // --- Closing token length
|
|
59
|
+
if (nodeLength > ((_f = options === null || options === void 0 ? void 0 : options.lineLength) !== null && _f !== void 0 ? _f : 80)) {
|
|
60
|
+
// --- Too long, break attributes into new lines
|
|
61
|
+
attrTexts.forEach((text) => {
|
|
62
|
+
elementStr += "\n" + getIndent(depth + 1) + text;
|
|
63
|
+
});
|
|
64
|
+
if ((_g = options === null || options === void 0 ? void 0 : options.breakClosingTag) !== null && _g !== void 0 ? _g : false) {
|
|
65
|
+
elementStr += "\n" + getIndent(depth);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// --- Attributes fit into the line
|
|
70
|
+
elementStr += " " + attrTexts.join(" ");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (node.text || hasChildren) {
|
|
75
|
+
// --- Close the opening tag
|
|
76
|
+
elementStr += ">";
|
|
77
|
+
// --- Render the text
|
|
78
|
+
if (node.text) {
|
|
79
|
+
const textContents = node.preserveSpaces
|
|
80
|
+
? serializeQuotedText(node.text)
|
|
81
|
+
: serializeText(node.text);
|
|
82
|
+
if ((options === null || options === void 0 ? void 0 : options.prettify) &&
|
|
83
|
+
elementStr.length + textContents.length + node.name.length + 3 >
|
|
84
|
+
((_h = options === null || options === void 0 ? void 0 : options.lineLength) !== null && _h !== void 0 ? _h : 80)) {
|
|
85
|
+
// --- break text
|
|
86
|
+
elementStr += "\n" + getIndent(depth + 1) + textContents + "\n";
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
elementStr += textContents;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// --- Render child nodes
|
|
93
|
+
if (hasChildren) {
|
|
94
|
+
const childrenTexts = node.childNodes.map((c) => serializeNode(c, depth + 1));
|
|
95
|
+
if (!(options === null || options === void 0 ? void 0 : options.prettify)) {
|
|
96
|
+
elementStr += childrenTexts.join("");
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
childrenTexts.forEach((text) => {
|
|
100
|
+
elementStr += "\n" + text;
|
|
101
|
+
});
|
|
102
|
+
elementStr += "\n";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// --- Render the closing tag
|
|
106
|
+
elementStr += `${getIndent(depth)}</${node.name}>`;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
elementStr += (((_j = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _j !== void 0 ? _j : false) ? " " : "") + "/>";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
elementStr += (((_k = options === null || options === void 0 ? void 0 : options.useSpaceBeforeClose) !== null && _k !== void 0 ? _k : false) ? " " : "") + "/>";
|
|
114
|
+
if (node.text === "") {
|
|
115
|
+
elementStr += `""</${nodeName()}>`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return elementStr;
|
|
119
|
+
function nodeName() {
|
|
120
|
+
return node.namespace ? `${node.namespace}:${node.name}` : node.name;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function serializeXmlAttribute(node) {
|
|
124
|
+
var _a;
|
|
125
|
+
// --- Handle valueless attributes
|
|
126
|
+
if (node.value === undefined || node.value === null) {
|
|
127
|
+
return `${nodeName()}`;
|
|
128
|
+
}
|
|
129
|
+
// --- Use quotes when required so
|
|
130
|
+
if (node.preserveSpaces) {
|
|
131
|
+
return `${nodeName()}=${serializeQuotedText(node.value)}`;
|
|
132
|
+
}
|
|
133
|
+
// --- Do the rest
|
|
134
|
+
const value = (_a = node.value) !== null && _a !== void 0 ? _a : "";
|
|
135
|
+
return `${nodeName()}=${serializeQuotedText(value)}`;
|
|
136
|
+
function nodeName() {
|
|
137
|
+
return node.namespace ? `${node.namespace}:${node.name}` : node.name;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function serializeText(text) {
|
|
141
|
+
return (options === null || options === void 0 ? void 0 : options.useQuotes) || attrBreakRegex.test(text) ? serializeQuotedText(text) : text;
|
|
142
|
+
}
|
|
143
|
+
function serializeQuotedText(text) {
|
|
144
|
+
const containsQuote = text.indexOf("'") >= 0;
|
|
145
|
+
const containsDQuote = text.indexOf('"') >= 0;
|
|
146
|
+
if ((!containsQuote && !containsDQuote) || (containsQuote && !containsDQuote)) {
|
|
147
|
+
return `"${text.replaceAll("`", "\\`")}"`;
|
|
148
|
+
}
|
|
149
|
+
if (containsDQuote && !containsQuote) {
|
|
150
|
+
return `'${text.replaceAll("`", "\\`")}'`;
|
|
151
|
+
}
|
|
152
|
+
return `\`${text.replaceAll("`", "\\`")}\``;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Transform the specified component definition into an XMLUI node
|
|
157
|
+
* @param def Component definitions
|
|
158
|
+
* @param options Transformation options
|
|
159
|
+
*/
|
|
160
|
+
transformComponentDefinition(def, options) {
|
|
161
|
+
return def.type
|
|
162
|
+
? this.transformSimpleComponentDefinition(def, options)
|
|
163
|
+
: this.transformCompoundComponentDefinition(def, options);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Transform the specified object into an XMLUI nodes
|
|
167
|
+
* @param def Object definition
|
|
168
|
+
* @param options Transformation options
|
|
169
|
+
*/
|
|
170
|
+
transformObject(def, options) {
|
|
171
|
+
var _a;
|
|
172
|
+
const transformed = this.transformValue("Object", "", def, options);
|
|
173
|
+
if (!transformed) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return (_a = transformed.childNodes) !== null && _a !== void 0 ? _a : [];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Transforms the specified simple component definition into an XMLUI node
|
|
180
|
+
* @param def Component definition
|
|
181
|
+
* @param options Transformation options
|
|
182
|
+
*/
|
|
183
|
+
transformSimpleComponentDefinition(def, options) {
|
|
184
|
+
const componentNode = {
|
|
185
|
+
type: "XmlUiElement",
|
|
186
|
+
name: def.type,
|
|
187
|
+
};
|
|
188
|
+
// --- Fundamental props
|
|
189
|
+
if (def.uid !== undefined) {
|
|
190
|
+
this.addProperty(componentNode, "id", def.uid, options);
|
|
191
|
+
}
|
|
192
|
+
if (def.testId !== undefined) {
|
|
193
|
+
this.addProperty(componentNode, "testId", def.testId, options);
|
|
194
|
+
}
|
|
195
|
+
if (def.when !== undefined) {
|
|
196
|
+
this.addProperty(componentNode, "when", def.when, options);
|
|
197
|
+
}
|
|
198
|
+
// --- Process vars
|
|
199
|
+
if (def.vars) {
|
|
200
|
+
Object.keys(def.vars).forEach((key) => {
|
|
201
|
+
var _a;
|
|
202
|
+
const varElement = this.transformValue("var", key, def.vars[key], options);
|
|
203
|
+
if (varElement === null)
|
|
204
|
+
return;
|
|
205
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
206
|
+
componentNode.childNodes.push(varElement);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// --- Process properties
|
|
210
|
+
if (def.props) {
|
|
211
|
+
Object.keys(def.props).forEach((key) => {
|
|
212
|
+
var _a, _b, _c;
|
|
213
|
+
// --- Special serialization for component-aware props
|
|
214
|
+
const propValue = def.props[key];
|
|
215
|
+
if (key.endsWith("Template") && propValue.type) {
|
|
216
|
+
// --- Consider this property holds a component
|
|
217
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
218
|
+
const propWrapper = {
|
|
219
|
+
type: "XmlUiElement",
|
|
220
|
+
name: "property",
|
|
221
|
+
attributes: [
|
|
222
|
+
{
|
|
223
|
+
type: "XmlUiAttribute",
|
|
224
|
+
name: "name",
|
|
225
|
+
value: key,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
this.addComponentElement(propWrapper, propValue);
|
|
230
|
+
componentNode.childNodes.push(propWrapper);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// --- Undefined is not serialized
|
|
234
|
+
if (propValue === undefined) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// --- Handle null property value
|
|
238
|
+
if (propValue === null) {
|
|
239
|
+
const nullPropElement = {
|
|
240
|
+
type: "XmlUiElement",
|
|
241
|
+
name: "property",
|
|
242
|
+
attributes: [
|
|
243
|
+
{
|
|
244
|
+
type: "XmlUiAttribute",
|
|
245
|
+
name: "name",
|
|
246
|
+
value: key,
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
(_b = componentNode.childNodes) !== null && _b !== void 0 ? _b : (componentNode.childNodes = []);
|
|
251
|
+
componentNode.childNodes.push(nullPropElement);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
// --- Extract prop if asked so, or if those are special, like "id", "when", or "testIs"
|
|
255
|
+
if (key === "id" || key === "when" || key === "testId" || (options === null || options === void 0 ? void 0 : options.extractProps)) {
|
|
256
|
+
const idPropElement = {
|
|
257
|
+
type: "XmlUiElement",
|
|
258
|
+
name: "property",
|
|
259
|
+
};
|
|
260
|
+
this.addProperty(idPropElement, key, propValue, options);
|
|
261
|
+
(_c = componentNode.childNodes) !== null && _c !== void 0 ? _c : (componentNode.childNodes = []);
|
|
262
|
+
componentNode.childNodes.push(idPropElement);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// --- Add property as the best according to the value
|
|
266
|
+
this.addProperty(componentNode, key, propValue, options);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// --- Process events
|
|
271
|
+
if (def.events) {
|
|
272
|
+
Object.keys(def.events).forEach((key) => {
|
|
273
|
+
var _a;
|
|
274
|
+
const eventElement = this.transformValue("event", key, def.events[key], options);
|
|
275
|
+
if (eventElement === null)
|
|
276
|
+
return;
|
|
277
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
278
|
+
componentNode.childNodes.push(eventElement);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
// --- Process loaders
|
|
282
|
+
if (def.loaders) {
|
|
283
|
+
this.addComponentList(componentNode, "loaders", def.loaders);
|
|
284
|
+
}
|
|
285
|
+
// --- Process APIs
|
|
286
|
+
if (def.api) {
|
|
287
|
+
Object.keys(def.api).forEach((key) => {
|
|
288
|
+
var _a;
|
|
289
|
+
const apiElement = this.transformValue("api", key, def.api[key], options);
|
|
290
|
+
if (apiElement === null)
|
|
291
|
+
return;
|
|
292
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
293
|
+
componentNode.childNodes.push(apiElement);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
// --- Process uses
|
|
297
|
+
if (def.uses) {
|
|
298
|
+
this.addList(componentNode, "uses", "", def.uses, options);
|
|
299
|
+
}
|
|
300
|
+
// --- Process children
|
|
301
|
+
if (def.children) {
|
|
302
|
+
if (typeof def.children === "string") {
|
|
303
|
+
this.addProperty(componentNode, "children", def.children, options);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
def.children.forEach((ch) => {
|
|
307
|
+
this.addComponentElement(componentNode, ch);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// --- Done
|
|
312
|
+
return componentNode;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Transforms the specified simple component definition into an Xml node
|
|
316
|
+
* @param def Compound component definition
|
|
317
|
+
* @param options Transformation options
|
|
318
|
+
*/
|
|
319
|
+
transformCompoundComponentDefinition(def, options) {
|
|
320
|
+
if (typeof def === "string") {
|
|
321
|
+
return {
|
|
322
|
+
type: "XmlUiElement",
|
|
323
|
+
name: def,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const nested = this.transformSimpleComponentDefinition(def.component, options);
|
|
327
|
+
const componentNode = {
|
|
328
|
+
type: "XmlUiElement",
|
|
329
|
+
name: transform_1.COMPOUND_COMP_ID,
|
|
330
|
+
attributes: [
|
|
331
|
+
{
|
|
332
|
+
type: "XmlUiAttribute",
|
|
333
|
+
name: "name",
|
|
334
|
+
value: def.name,
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
childNodes: Array.isArray(nested) ? [...nested] : [nested],
|
|
338
|
+
};
|
|
339
|
+
// --- Transform APIs
|
|
340
|
+
if (def.api) {
|
|
341
|
+
Object.keys(def.api).forEach((key) => {
|
|
342
|
+
var _a;
|
|
343
|
+
const apiElement = this.transformValue("api", key, def.api[key], options);
|
|
344
|
+
if (apiElement === null)
|
|
345
|
+
return;
|
|
346
|
+
(_a = componentNode.childNodes) !== null && _a !== void 0 ? _a : (componentNode.childNodes = []);
|
|
347
|
+
componentNode.childNodes.push(apiElement);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
// --- Done
|
|
351
|
+
return componentNode;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Transforms a value into an XMLUI element
|
|
355
|
+
* @param nodeName Name of the value node
|
|
356
|
+
* @param name Optional (property) name
|
|
357
|
+
* @param value Value to transform
|
|
358
|
+
* @param options Transformation options
|
|
359
|
+
*/
|
|
360
|
+
transformValue(nodeName, name, value, options) {
|
|
361
|
+
var _a, _b, _c;
|
|
362
|
+
// --- Do not transform undefined elements
|
|
363
|
+
if (value === undefined)
|
|
364
|
+
return null;
|
|
365
|
+
// --- Prepare the node with the value
|
|
366
|
+
const valueNode = {
|
|
367
|
+
type: "XmlUiElement",
|
|
368
|
+
name: nodeName,
|
|
369
|
+
};
|
|
370
|
+
if (name) {
|
|
371
|
+
valueNode.attributes = [
|
|
372
|
+
{
|
|
373
|
+
type: "XmlUiAttribute",
|
|
374
|
+
name: "name",
|
|
375
|
+
value: name,
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
}
|
|
379
|
+
// --- Extend the node according to the specified value
|
|
380
|
+
// --- Null value: we're done
|
|
381
|
+
if (value === null) {
|
|
382
|
+
return valueNode;
|
|
383
|
+
}
|
|
384
|
+
// --- Simple value: use text or value attribute
|
|
385
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
386
|
+
const strValue = typeof value === "string" ? value.toString() : `{${value.toString()}}`;
|
|
387
|
+
const preserveSpaces = attrBreakRegex.test(strValue) || strValue.trim().length != strValue.length;
|
|
388
|
+
if (options === null || options === void 0 ? void 0 : options.preferTextToValue) {
|
|
389
|
+
valueNode.text = strValue;
|
|
390
|
+
valueNode.preserveSpaces = preserveSpaces;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
(_a = valueNode.attributes) !== null && _a !== void 0 ? _a : (valueNode.attributes = []);
|
|
394
|
+
valueNode.attributes.push({
|
|
395
|
+
type: "XmlUiAttribute",
|
|
396
|
+
name: "value",
|
|
397
|
+
value: strValue,
|
|
398
|
+
preserveSpaces,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
return valueNode;
|
|
402
|
+
}
|
|
403
|
+
// --- Array value
|
|
404
|
+
if (Array.isArray(value)) {
|
|
405
|
+
if (value.length === 0) {
|
|
406
|
+
// --- Empty array
|
|
407
|
+
(_b = valueNode.attributes) !== null && _b !== void 0 ? _b : (valueNode.attributes = []);
|
|
408
|
+
valueNode.attributes.push({
|
|
409
|
+
type: "XmlUiAttribute",
|
|
410
|
+
name: "value",
|
|
411
|
+
value: "{[]}",
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
value.forEach((item) => {
|
|
416
|
+
var _a;
|
|
417
|
+
const itemElement = this.transformValue("item", undefined, item, options);
|
|
418
|
+
if (!itemElement)
|
|
419
|
+
return;
|
|
420
|
+
(_a = valueNode.childNodes) !== null && _a !== void 0 ? _a : (valueNode.childNodes = []);
|
|
421
|
+
valueNode.childNodes.push(itemElement);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
else if (typeof value === "object") {
|
|
426
|
+
const keys = Object.keys(value);
|
|
427
|
+
if (keys.length === 0) {
|
|
428
|
+
// --- Empty object
|
|
429
|
+
(_c = valueNode.attributes) !== null && _c !== void 0 ? _c : (valueNode.attributes = []);
|
|
430
|
+
valueNode.attributes.push({
|
|
431
|
+
type: "XmlUiAttribute",
|
|
432
|
+
name: "value",
|
|
433
|
+
value: "{{}}",
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
keys.forEach((key) => {
|
|
438
|
+
var _a;
|
|
439
|
+
const fieldElement = this.transformValue("field", key, value[key], options);
|
|
440
|
+
if (!fieldElement)
|
|
441
|
+
return;
|
|
442
|
+
(_a = valueNode.childNodes) !== null && _a !== void 0 ? _a : (valueNode.childNodes = []);
|
|
443
|
+
valueNode.childNodes.push(fieldElement);
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
throw new Error(`Cannot serialize '${typeof value}' value`);
|
|
449
|
+
}
|
|
450
|
+
return valueNode;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Transforms the specified simple component definition into an Xml node
|
|
454
|
+
* @param name Element name
|
|
455
|
+
* @param value Value to transform
|
|
456
|
+
* @param options Transformation options
|
|
457
|
+
*/
|
|
458
|
+
transformObjectValue(name, value, options) {
|
|
459
|
+
const componentNode = {
|
|
460
|
+
type: "XmlUiElement",
|
|
461
|
+
name: name,
|
|
462
|
+
};
|
|
463
|
+
if (value) {
|
|
464
|
+
Object.keys(value).forEach((key) => this.addProperty(componentNode, key, value[key], options));
|
|
465
|
+
}
|
|
466
|
+
return componentNode;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Add a property to the specified XMLUI element
|
|
470
|
+
* @param element XML element
|
|
471
|
+
* @param name Element name
|
|
472
|
+
* @param value Element value
|
|
473
|
+
* @param options Transformation options
|
|
474
|
+
*/
|
|
475
|
+
addProperty(element, name, value, options) {
|
|
476
|
+
var _a, _b, _c;
|
|
477
|
+
switch (typeof value) {
|
|
478
|
+
// --- We do not serialize undefined property values
|
|
479
|
+
case "undefined":
|
|
480
|
+
break;
|
|
481
|
+
case "string":
|
|
482
|
+
(_a = element.attributes) !== null && _a !== void 0 ? _a : (element.attributes = []);
|
|
483
|
+
element.attributes.push({
|
|
484
|
+
type: "XmlUiAttribute",
|
|
485
|
+
name,
|
|
486
|
+
value: value === null || value === void 0 ? void 0 : value.toString(),
|
|
487
|
+
preserveQuotes: (_b = options === null || options === void 0 ? void 0 : options.removeQuotes) !== null && _b !== void 0 ? _b : false,
|
|
488
|
+
preserveSpaces: attrBreakRegex.test(value.toString()),
|
|
489
|
+
});
|
|
490
|
+
break;
|
|
491
|
+
case "boolean":
|
|
492
|
+
case "number":
|
|
493
|
+
case "object":
|
|
494
|
+
const objElement = this.transformValue("property", name, value, options);
|
|
495
|
+
if (objElement) {
|
|
496
|
+
(_c = element.childNodes) !== null && _c !== void 0 ? _c : (element.childNodes = []);
|
|
497
|
+
element.childNodes.push(objElement);
|
|
498
|
+
}
|
|
499
|
+
break;
|
|
500
|
+
default:
|
|
501
|
+
throw new Error(`'${typeof value}' transformation is not implemented yet`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
addComponentElement(element, component) {
|
|
505
|
+
var _a;
|
|
506
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
507
|
+
const childDef = this.transformComponentDefinition(component);
|
|
508
|
+
if (Array.isArray(childDef)) {
|
|
509
|
+
element.childNodes.push(...childDef);
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
element.childNodes.push(childDef);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Adds a list to the specified XML element
|
|
517
|
+
* @param element XML element
|
|
518
|
+
* @param name Name of the list (child in `element`)
|
|
519
|
+
* @param prefix Prefix to use for the list
|
|
520
|
+
* @param list List with items
|
|
521
|
+
* @param options Transformation options
|
|
522
|
+
*/
|
|
523
|
+
addList(element, name, prefix, list, options) {
|
|
524
|
+
var _a;
|
|
525
|
+
const nodeName = `${prefix ? prefix + "." : ""}${name}`;
|
|
526
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
527
|
+
list.forEach((item) => {
|
|
528
|
+
if (typeof item === "string") {
|
|
529
|
+
// --- Special case, the item can be the text of an XML element
|
|
530
|
+
element.childNodes.push({
|
|
531
|
+
type: "XmlUiElement",
|
|
532
|
+
name: nodeName,
|
|
533
|
+
text: item,
|
|
534
|
+
preserveSpaces: attrBreakRegex.test(item) || item !== item.trim() || item === "",
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
else if (item === null) {
|
|
538
|
+
element.childNodes.push({
|
|
539
|
+
type: "XmlUiElement",
|
|
540
|
+
name: nodeName,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
const transformed = this.transformObjectValue(nodeName, item, options);
|
|
545
|
+
if (Array.isArray(transformed)) {
|
|
546
|
+
element.childNodes.push(...transformed);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
element.childNodes.push(transformed);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Adds a component list to the specified element
|
|
556
|
+
* @param element XML element
|
|
557
|
+
* @param name Name to use for the wrapper element
|
|
558
|
+
* @param list List with component items
|
|
559
|
+
* @private
|
|
560
|
+
*/
|
|
561
|
+
addComponentList(element, name, list) {
|
|
562
|
+
var _a;
|
|
563
|
+
const children = [];
|
|
564
|
+
list.forEach((item) => {
|
|
565
|
+
const fragment = this.transformSimpleComponentDefinition(item);
|
|
566
|
+
if (Array.isArray(fragment)) {
|
|
567
|
+
children.push(...fragment);
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
children.push(fragment);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
const listElement = {
|
|
574
|
+
type: "XmlUiElement",
|
|
575
|
+
name,
|
|
576
|
+
childNodes: children,
|
|
577
|
+
};
|
|
578
|
+
(_a = element.childNodes) !== null && _a !== void 0 ? _a : (element.childNodes = []);
|
|
579
|
+
element.childNodes.push(listElement);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
exports.XmlUiHelper = XmlUiHelper;
|
|
@@ -67,13 +67,7 @@ declare type ApiInterceptorDefinition = {
|
|
|
67
67
|
useWorker?: boolean;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
declare function ApiInterceptorProvider({ interceptor, children, parentInterceptorContext, waitForApiInterceptor, }:
|
|
71
|
-
interceptor?: ApiInterceptorDefinition;
|
|
72
|
-
children: ReactNode;
|
|
73
|
-
apiWorker?: SetupWorker;
|
|
74
|
-
parentInterceptorContext?: IApiInterceptorContext;
|
|
75
|
-
waitForApiInterceptor?: boolean;
|
|
76
|
-
}): JSX_2.Element;
|
|
70
|
+
declare function ApiInterceptorProvider({ interceptor, children, parentInterceptorContext, waitForApiInterceptor, }: Props_4): JSX_2.Element;
|
|
77
71
|
|
|
78
72
|
declare type AppContextObject = {
|
|
79
73
|
[x: string]: unknown;
|
|
@@ -1061,6 +1055,14 @@ declare type Props_3 = {
|
|
|
1061
1055
|
distributeEvenly?: boolean;
|
|
1062
1056
|
};
|
|
1063
1057
|
|
|
1058
|
+
declare type Props_4 = {
|
|
1059
|
+
interceptor?: ApiInterceptorDefinition;
|
|
1060
|
+
children: ReactNode;
|
|
1061
|
+
parentInterceptorContext?: IApiInterceptorContext;
|
|
1062
|
+
waitForApiInterceptor?: boolean;
|
|
1063
|
+
useHashBasedRouting?: boolean;
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1064
1066
|
/**
|
|
1065
1067
|
* TextBox component that supports text input with various configurations.
|
|
1066
1068
|
* Features:
|
|
@@ -1069,7 +1071,7 @@ declare type Props_3 = {
|
|
|
1069
1071
|
* - Start/end adornments (icons and text)
|
|
1070
1072
|
* - Password visibility toggle option
|
|
1071
1073
|
*/
|
|
1072
|
-
declare type
|
|
1074
|
+
declare type Props_5 = {
|
|
1073
1075
|
id?: string;
|
|
1074
1076
|
type?: "text" | "password" | "search";
|
|
1075
1077
|
value?: string;
|
|
@@ -1617,7 +1619,7 @@ declare interface TemplateLiteralExpression extends ExpressionBase {
|
|
|
1617
1619
|
|
|
1618
1620
|
declare const Text_2: default_2.ForwardRefExoticComponent<Omit<TextProps, "ref"> & default_2.RefAttributes<unknown>>;
|
|
1619
1621
|
|
|
1620
|
-
declare const TextBox: default_2.ForwardRefExoticComponent<
|
|
1622
|
+
declare const TextBox: default_2.ForwardRefExoticComponent<Props_5 & default_2.RefAttributes<HTMLDivElement>>;
|
|
1621
1623
|
|
|
1622
1624
|
declare type TextProps = {
|
|
1623
1625
|
uid?: string;
|