xmlui 0.10.10 → 0.10.11
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/{metadata/apiInterceptorWorker-Bb5-fQup.mjs → lib/apiInterceptorWorker-DPgtUtdA.mjs} +5870 -3195
- package/dist/lib/index-BuIblMfO.mjs +50034 -0
- package/dist/lib/index.css +1 -1
- package/dist/lib/initMock-CV-9AUzP.mjs +843 -0
- package/dist/lib/language-server-web-worker.mjs +8 -7
- package/dist/lib/language-server.mjs +6 -6
- package/dist/lib/{metadata-utils-gIOZMGG7.mjs → metadata-utils-DzONZF-e.mjs} +159 -114
- package/dist/lib/scss/components-core/theming/_themes.scss +6 -7
- package/dist/lib/{server-common-BfCSNpXG.mjs → server-common-Dsyp3-Ro.mjs} +14497 -10458
- package/dist/lib/syntax-monaco.mjs +14 -11
- package/dist/lib/syntax-textmate.d.ts +2 -2
- package/dist/lib/syntax-textmate.mjs +128 -109
- package/dist/lib/transform-CBz7TQJh.mjs +7375 -0
- package/dist/lib/xmlui-parser.mjs +49 -49
- package/dist/lib/xmlui-serializer-Bf9bdvlV.mjs +667 -0
- package/dist/lib/xmlui.d.ts +3 -2
- package/dist/lib/xmlui.mjs +43 -43
- package/dist/{lib/apiInterceptorWorker-DH8wqOVq.mjs → metadata/apiInterceptorWorker-BmKP8bnq.mjs} +5432 -3502
- package/dist/metadata/collectedComponentMetadata-Cdi6AFD3.mjs +55851 -0
- package/dist/metadata/initMock-B7OlSKKb.mjs +843 -0
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +3 -3
- package/dist/metadata/xmlui-metadata.umd.js +207 -419
- package/dist/scripts/package.json +3 -1
- package/dist/scripts/src/components/APICall/APICall.js +4 -4
- package/dist/scripts/src/components/Accordion/Accordion.js +1 -1
- package/dist/scripts/src/components/Animation/AnimationNative.js +259 -0
- package/dist/scripts/src/components/App/App.js +10 -0
- package/dist/scripts/src/components/App/AppNative.js +23 -2
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +5 -4
- package/dist/scripts/src/components/Button/Button.js +1 -1
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.js +92 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChartNative.js +127 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +85 -81
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.js +92 -0
- package/dist/scripts/src/components/Charts/RadarChart/RadarChartNative.js +125 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +2 -1
- package/dist/scripts/src/components/ComponentProvider.js +4 -0
- package/dist/scripts/src/components/DataSource/DataSource.js +124 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/scripts/src/components/Footer/Footer.js +1 -1
- package/dist/scripts/src/components/FormItem/FormItem.js +1 -1
- package/dist/scripts/src/components/Heading/Heading.js +83 -28
- package/dist/scripts/src/components/Heading/HeadingNative.js +10 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1 -1
- package/dist/scripts/src/components/Image/ImageNative.js +13 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +1 -1
- package/dist/scripts/src/components/Option/Option.js +2 -2
- package/dist/scripts/src/components/Option/OptionNative.js +12 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +7 -3
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +20 -5
- package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +2 -1
- package/dist/scripts/src/components/Select/Select.js +1 -1
- package/dist/scripts/src/components/Select/SelectNative.js +1 -1
- package/dist/scripts/src/components/Switch/Switch.js +2 -1
- package/dist/scripts/src/components/Table/Table.js +1 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -1
- package/dist/scripts/src/components/Text/Text.js +32 -14
- package/dist/scripts/src/components/Text/TextNative.js +17 -5
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
- package/dist/scripts/src/components/Toggle/Toggle.js +2 -2
- package/dist/scripts/src/components/abstractions.js +2 -1
- package/dist/scripts/src/components/collectedComponentMetadata.js +316 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +3 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +823 -0
- package/dist/scripts/src/components-core/markup-check.js +279 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +36 -16
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +4 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +4 -1
- package/dist/scripts/src/components-core/theming/themes/root.js +30 -17
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +14 -7
- package/dist/scripts/src/components-core/xmlui-parser.js +60 -43
- package/dist/scripts/src/index.js +120 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +15 -4
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -2
- package/dist/standalone/xmlui-standalone.umd.js +319 -823
- package/package.json +3 -1
- package/src/syntax/textMate/xmlui.tmLanguage.json +2 -2
- package/dist/lib/index-C71PAj7E.mjs +0 -38677
- package/dist/lib/initMock-Bvbl2Pa3.mjs +0 -571
- package/dist/lib/transform-SMWeyMoq.mjs +0 -5391
- package/dist/lib/xmlui-serializer-a0O0jFY-.mjs +0 -497
- package/dist/metadata/collectedComponentMetadata-Dn91__HO.mjs +0 -43087
- package/dist/metadata/initMock-ghNfStAu.mjs +0 -571
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
import { v as A, t as j } from "./transform-SMWeyMoq.mjs";
|
|
2
|
-
const k = "xmlui", P = "xmlui.xs", D = "xs";
|
|
3
|
-
var V = /* @__PURE__ */ ((l) => (l[l.Skip = 0] = "Skip", l[l.Warning = 1] = "Warning", l[l.Error = 2] = "Error", l))(V || {}), w = /* @__PURE__ */ ((l) => (l[l.UnrecognisedProp = 0] = "UnrecognisedProp", l))(w || {});
|
|
4
|
-
function L(l) {
|
|
5
|
-
if (!l)
|
|
6
|
-
return 1;
|
|
7
|
-
switch (l.toLowerCase()) {
|
|
8
|
-
case "warning":
|
|
9
|
-
return 1;
|
|
10
|
-
case "error":
|
|
11
|
-
return 2;
|
|
12
|
-
case "skip":
|
|
13
|
-
return 0;
|
|
14
|
-
default:
|
|
15
|
-
return console.warn(
|
|
16
|
-
`Invalid lint severity option '${l}'. Must be one of: 'warning', 'error', 'skip'. Defaulting to 'warning'.`
|
|
17
|
-
), 1;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function z({
|
|
21
|
-
appDef: l,
|
|
22
|
-
metadataProvider: e
|
|
23
|
-
}) {
|
|
24
|
-
const t = {
|
|
25
|
-
componentName: "Main",
|
|
26
|
-
lints: C({
|
|
27
|
-
component: l.entryPoint,
|
|
28
|
-
metadataProvider: e
|
|
29
|
-
})
|
|
30
|
-
}, r = (l.components ?? []).map((n) => ({ lints: C({
|
|
31
|
-
component: n,
|
|
32
|
-
metadataProvider: e
|
|
33
|
-
}), componentName: n.name }));
|
|
34
|
-
return [t, ...r].filter((n) => n.lints.length > 0);
|
|
35
|
-
}
|
|
36
|
-
function T(l) {
|
|
37
|
-
console.group(`Validation on '${l.componentName}':`), l.lints.forEach(({ message: e }) => {
|
|
38
|
-
console.warn(e);
|
|
39
|
-
}), console.groupEnd();
|
|
40
|
-
}
|
|
41
|
-
function I(l) {
|
|
42
|
-
function e() {
|
|
43
|
-
const t = l.map((n, s) => ({
|
|
44
|
-
type: "VStack",
|
|
45
|
-
props: { gap: "0px" },
|
|
46
|
-
children: [
|
|
47
|
-
{
|
|
48
|
-
type: "VStack",
|
|
49
|
-
props: { backgroundColor: "lightgrey", padding: "10px" },
|
|
50
|
-
children: [
|
|
51
|
-
{
|
|
52
|
-
type: "H2",
|
|
53
|
-
props: {
|
|
54
|
-
value: `#${s + 1}: In component '${n.componentName}':`,
|
|
55
|
-
color: "$color-info"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: "VStack",
|
|
60
|
-
children: n.lints.map(({ message: a }, u) => ({
|
|
61
|
-
type: "Text",
|
|
62
|
-
props: { value: `${s + 1}.${u + 1}: ${a}`, fontWeight: "bold" }
|
|
63
|
-
}))
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}));
|
|
69
|
-
return {
|
|
70
|
-
type: "VStack",
|
|
71
|
-
props: { padding: "$padding-normal", gap: 0 },
|
|
72
|
-
children: [
|
|
73
|
-
{
|
|
74
|
-
type: "H1",
|
|
75
|
-
props: {
|
|
76
|
-
value: "Errors found while checking Xmlui markup",
|
|
77
|
-
padding: "$padding-normal",
|
|
78
|
-
backgroundColor: "$color-error",
|
|
79
|
-
color: "white"
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: "VStack",
|
|
84
|
-
props: {
|
|
85
|
-
gap: "$gap-tight",
|
|
86
|
-
padding: "$padding-normal"
|
|
87
|
-
},
|
|
88
|
-
children: t
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
return e();
|
|
94
|
-
}
|
|
95
|
-
function C({
|
|
96
|
-
component: l,
|
|
97
|
-
metadataProvider: e
|
|
98
|
-
}) {
|
|
99
|
-
return "component" in l ? g(l.component, e, []) : g(l, e, []);
|
|
100
|
-
}
|
|
101
|
-
function g(l, e, t) {
|
|
102
|
-
const r = l.type.startsWith(A) ? l.type.slice(A.length + 1) : l.type, n = e.getComponent(r);
|
|
103
|
-
if (n !== null && !n.allowArbitraryProps && x(l, n, t), !l.children)
|
|
104
|
-
return t;
|
|
105
|
-
for (const s of l.children)
|
|
106
|
-
g(s, e, t);
|
|
107
|
-
return t;
|
|
108
|
-
}
|
|
109
|
-
function x(l, e, t) {
|
|
110
|
-
const r = Object.keys(l.props ?? {}).filter(
|
|
111
|
-
(a) => !e.getAttr(a)
|
|
112
|
-
), n = Object.keys(l.events ?? {}).filter(
|
|
113
|
-
(a) => !e.getEvent(a)
|
|
114
|
-
), s = Object.keys(l.api ?? {}).filter(
|
|
115
|
-
(a) => !e.getApi(a)
|
|
116
|
-
);
|
|
117
|
-
r.push(...n), r.push(...s);
|
|
118
|
-
for (const a of r)
|
|
119
|
-
t.push(S(l, a));
|
|
120
|
-
}
|
|
121
|
-
function S(l, e) {
|
|
122
|
-
return {
|
|
123
|
-
message: `Unrecognised property '${e}' on component '${l.type}'.`,
|
|
124
|
-
kind: 0
|
|
125
|
-
/* UnrecognisedProp */
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
const y = /[\r\n<>'"&]/;
|
|
129
|
-
class M {
|
|
130
|
-
/**
|
|
131
|
-
* Serialize the specified XML fragment into a string
|
|
132
|
-
* @param xml XML fragment to serialize
|
|
133
|
-
* @param options Formatting options to use
|
|
134
|
-
*/
|
|
135
|
-
serialize(e, t) {
|
|
136
|
-
const r = Array.isArray(e) ? e : [e];
|
|
137
|
-
return n(r, 0);
|
|
138
|
-
function n(i, o) {
|
|
139
|
-
return i.map((c) => s(c, o)).join(t != null && t.prettify ? `
|
|
140
|
-
` + a(o) : "");
|
|
141
|
-
}
|
|
142
|
-
function s(i, o) {
|
|
143
|
-
switch (i.type) {
|
|
144
|
-
case "XmlUiComment":
|
|
145
|
-
return u(i, o);
|
|
146
|
-
case "XmlUiElement":
|
|
147
|
-
return m(i, o);
|
|
148
|
-
default:
|
|
149
|
-
return "";
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function a(i) {
|
|
153
|
-
return t != null && t.prettify ? "".padEnd(((t == null ? void 0 : t.indents) ?? 2) * i, " ") : "";
|
|
154
|
-
}
|
|
155
|
-
function u(i, o) {
|
|
156
|
-
return `${a(o)}<!--${i.text}-->`;
|
|
157
|
-
}
|
|
158
|
-
function m(i, o) {
|
|
159
|
-
var E, $;
|
|
160
|
-
let c = `${a(o)}<${b()}`;
|
|
161
|
-
const N = (((E = i.attributes) == null ? void 0 : E.length) ?? 0) > 0, p = ((($ = i.childNodes) == null ? void 0 : $.length) ?? 0) > 0;
|
|
162
|
-
if (i.text || N || p) {
|
|
163
|
-
if (N) {
|
|
164
|
-
const h = i.attributes.map((d) => U(d));
|
|
165
|
-
t != null && t.prettify && c.length + 1 + // --- Space after
|
|
166
|
-
h.join(" ").length + // --- Attributes total length
|
|
167
|
-
(p ? 1 : (t == null ? void 0 : t.useSpaceBeforeClose) ?? !1 ? 3 : 2) > ((t == null ? void 0 : t.lineLength) ?? 80) ? (h.forEach((v) => {
|
|
168
|
-
c += `
|
|
169
|
-
` + a(o + 1) + v;
|
|
170
|
-
}), ((t == null ? void 0 : t.breakClosingTag) ?? !1) && (c += `
|
|
171
|
-
` + a(o))) : c += " " + h.join(" ");
|
|
172
|
-
}
|
|
173
|
-
if (i.text || p) {
|
|
174
|
-
if (c += ">", i.text) {
|
|
175
|
-
const h = i.preserveSpaces ? f(i.text) : X(i.text);
|
|
176
|
-
t != null && t.prettify && c.length + h.length + i.name.length + 3 > ((t == null ? void 0 : t.lineLength) ?? 80) ? c += `
|
|
177
|
-
` + a(o + 1) + h + `
|
|
178
|
-
` : c += h;
|
|
179
|
-
}
|
|
180
|
-
if (p) {
|
|
181
|
-
const h = i.childNodes.map((d) => s(d, o + 1));
|
|
182
|
-
t != null && t.prettify ? (h.forEach((d) => {
|
|
183
|
-
c += `
|
|
184
|
-
` + d;
|
|
185
|
-
}), c += `
|
|
186
|
-
`) : c += h.join("");
|
|
187
|
-
}
|
|
188
|
-
c += `${a(o)}</${i.name}>`;
|
|
189
|
-
} else
|
|
190
|
-
c += ((t == null ? void 0 : t.useSpaceBeforeClose) ?? !1 ? " " : "") + "/>";
|
|
191
|
-
} else
|
|
192
|
-
c += ((t == null ? void 0 : t.useSpaceBeforeClose) ?? !1 ? " " : "") + "/>", i.text === "" && (c += `""</${b()}>`);
|
|
193
|
-
return c;
|
|
194
|
-
function b() {
|
|
195
|
-
return i.namespace ? `${i.namespace}:${i.name}` : i.name;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function U(i) {
|
|
199
|
-
if (i.value === void 0 || i.value === null)
|
|
200
|
-
return `${c()}`;
|
|
201
|
-
if (i.preserveSpaces)
|
|
202
|
-
return `${c()}=${f(i.value)}`;
|
|
203
|
-
const o = i.value ?? "";
|
|
204
|
-
return `${c()}=${f(o)}`;
|
|
205
|
-
function c() {
|
|
206
|
-
return i.namespace ? `${i.namespace}:${i.name}` : i.name;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function X(i) {
|
|
210
|
-
return t != null && t.useQuotes || y.test(i) ? f(i) : i;
|
|
211
|
-
}
|
|
212
|
-
function f(i) {
|
|
213
|
-
const o = i.indexOf("'") >= 0, c = i.indexOf('"') >= 0;
|
|
214
|
-
return !o && !c || o && !c ? `"${i.replaceAll("`", "\\`")}"` : c && !o ? `'${i.replaceAll("`", "\\`")}'` : `\`${i.replaceAll("`", "\\`")}\``;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Transform the specified component definition into an XMLUI node
|
|
219
|
-
* @param def Component definitions
|
|
220
|
-
* @param options Transformation options
|
|
221
|
-
*/
|
|
222
|
-
transformComponentDefinition(e, t) {
|
|
223
|
-
return e.type ? this.transformSimpleComponentDefinition(e, t) : this.transformCompoundComponentDefinition(e, t);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Transform the specified object into an XMLUI nodes
|
|
227
|
-
* @param def Object definition
|
|
228
|
-
* @param options Transformation options
|
|
229
|
-
*/
|
|
230
|
-
transformObject(e, t) {
|
|
231
|
-
const r = this.transformValue("Object", "", e, t);
|
|
232
|
-
return r ? r.childNodes ?? [] : null;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Transforms the specified simple component definition into an XMLUI node
|
|
236
|
-
* @param def Component definition
|
|
237
|
-
* @param options Transformation options
|
|
238
|
-
*/
|
|
239
|
-
transformSimpleComponentDefinition(e, t) {
|
|
240
|
-
const r = {
|
|
241
|
-
type: "XmlUiElement",
|
|
242
|
-
name: e.type
|
|
243
|
-
};
|
|
244
|
-
return e.uid !== void 0 && this.addProperty(r, "id", e.uid, t), e.testId !== void 0 && this.addProperty(r, "testId", e.testId, t), e.when !== void 0 && this.addProperty(r, "when", e.when, t), e.vars && Object.keys(e.vars).forEach((n) => {
|
|
245
|
-
const s = this.transformValue("var", n, e.vars[n], t);
|
|
246
|
-
s !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(s));
|
|
247
|
-
}), e.props && Object.keys(e.props).forEach((n) => {
|
|
248
|
-
const s = e.props[n];
|
|
249
|
-
if (n.endsWith("Template") && s.type) {
|
|
250
|
-
r.childNodes ?? (r.childNodes = []);
|
|
251
|
-
const a = {
|
|
252
|
-
type: "XmlUiElement",
|
|
253
|
-
name: "property",
|
|
254
|
-
attributes: [
|
|
255
|
-
{
|
|
256
|
-
type: "XmlUiAttribute",
|
|
257
|
-
name: "name",
|
|
258
|
-
value: n
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
};
|
|
262
|
-
this.addComponentElement(a, s), r.childNodes.push(a);
|
|
263
|
-
} else {
|
|
264
|
-
if (s === void 0)
|
|
265
|
-
return;
|
|
266
|
-
if (s === null) {
|
|
267
|
-
const a = {
|
|
268
|
-
type: "XmlUiElement",
|
|
269
|
-
name: "property",
|
|
270
|
-
attributes: [
|
|
271
|
-
{
|
|
272
|
-
type: "XmlUiAttribute",
|
|
273
|
-
name: "name",
|
|
274
|
-
value: n
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
};
|
|
278
|
-
r.childNodes ?? (r.childNodes = []), r.childNodes.push(a);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (n === "id" || n === "when" || n === "testId" || t != null && t.extractProps) {
|
|
282
|
-
const a = {
|
|
283
|
-
type: "XmlUiElement",
|
|
284
|
-
name: "property"
|
|
285
|
-
};
|
|
286
|
-
this.addProperty(a, n, s, t), r.childNodes ?? (r.childNodes = []), r.childNodes.push(a);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
this.addProperty(r, n, s, t);
|
|
290
|
-
}
|
|
291
|
-
}), e.events && Object.keys(e.events).forEach((n) => {
|
|
292
|
-
const s = this.transformValue("event", n, e.events[n], t);
|
|
293
|
-
s !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(s));
|
|
294
|
-
}), e.loaders && this.addComponentList(r, "loaders", e.loaders), e.api && Object.keys(e.api).forEach((n) => {
|
|
295
|
-
const s = this.transformValue("api", n, e.api[n], t);
|
|
296
|
-
s !== null && (r.childNodes ?? (r.childNodes = []), r.childNodes.push(s));
|
|
297
|
-
}), e.uses && this.addList(r, "uses", "", e.uses, t), e.children && (typeof e.children == "string" ? this.addProperty(r, "children", e.children, t) : e.children.forEach((n) => {
|
|
298
|
-
this.addComponentElement(r, n);
|
|
299
|
-
})), r;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Transforms the specified simple component definition into an Xml node
|
|
303
|
-
* @param def Compound component definition
|
|
304
|
-
* @param options Transformation options
|
|
305
|
-
*/
|
|
306
|
-
transformCompoundComponentDefinition(e, t) {
|
|
307
|
-
if (typeof e == "string")
|
|
308
|
-
return {
|
|
309
|
-
type: "XmlUiElement",
|
|
310
|
-
name: e
|
|
311
|
-
};
|
|
312
|
-
const r = this.transformSimpleComponentDefinition(
|
|
313
|
-
e.component,
|
|
314
|
-
t
|
|
315
|
-
), n = {
|
|
316
|
-
type: "XmlUiElement",
|
|
317
|
-
name: j,
|
|
318
|
-
attributes: [
|
|
319
|
-
{
|
|
320
|
-
type: "XmlUiAttribute",
|
|
321
|
-
name: "name",
|
|
322
|
-
value: e.name
|
|
323
|
-
}
|
|
324
|
-
],
|
|
325
|
-
childNodes: Array.isArray(r) ? [...r] : [r]
|
|
326
|
-
};
|
|
327
|
-
return e.api && Object.keys(e.api).forEach((s) => {
|
|
328
|
-
const a = this.transformValue("api", s, e.api[s], t);
|
|
329
|
-
a !== null && (n.childNodes ?? (n.childNodes = []), n.childNodes.push(a));
|
|
330
|
-
}), n;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Transforms a value into an XMLUI element
|
|
334
|
-
* @param nodeName Name of the value node
|
|
335
|
-
* @param name Optional (property) name
|
|
336
|
-
* @param value Value to transform
|
|
337
|
-
* @param options Transformation options
|
|
338
|
-
*/
|
|
339
|
-
transformValue(e, t, r, n) {
|
|
340
|
-
if (r === void 0) return null;
|
|
341
|
-
const s = {
|
|
342
|
-
type: "XmlUiElement",
|
|
343
|
-
name: e
|
|
344
|
-
};
|
|
345
|
-
if (t && (s.attributes = [
|
|
346
|
-
{
|
|
347
|
-
type: "XmlUiAttribute",
|
|
348
|
-
name: "name",
|
|
349
|
-
value: t
|
|
350
|
-
}
|
|
351
|
-
]), r === null)
|
|
352
|
-
return s;
|
|
353
|
-
if (typeof r == "string" || typeof r == "number" || typeof r == "boolean") {
|
|
354
|
-
const a = typeof r == "string" ? r.toString() : `{${r.toString()}}`, u = y.test(a) || a.trim().length != a.length;
|
|
355
|
-
return n != null && n.preferTextToValue ? (s.text = a, s.preserveSpaces = u) : (s.attributes ?? (s.attributes = []), s.attributes.push({
|
|
356
|
-
type: "XmlUiAttribute",
|
|
357
|
-
name: "value",
|
|
358
|
-
value: a,
|
|
359
|
-
preserveSpaces: u
|
|
360
|
-
})), s;
|
|
361
|
-
}
|
|
362
|
-
if (Array.isArray(r))
|
|
363
|
-
r.length === 0 ? (s.attributes ?? (s.attributes = []), s.attributes.push({
|
|
364
|
-
type: "XmlUiAttribute",
|
|
365
|
-
name: "value",
|
|
366
|
-
value: "{[]}"
|
|
367
|
-
})) : r.forEach((a) => {
|
|
368
|
-
const u = this.transformValue("item", void 0, a, n);
|
|
369
|
-
u && (s.childNodes ?? (s.childNodes = []), s.childNodes.push(u));
|
|
370
|
-
});
|
|
371
|
-
else if (typeof r == "object") {
|
|
372
|
-
const a = Object.keys(r);
|
|
373
|
-
a.length === 0 ? (s.attributes ?? (s.attributes = []), s.attributes.push({
|
|
374
|
-
type: "XmlUiAttribute",
|
|
375
|
-
name: "value",
|
|
376
|
-
value: "{{}}"
|
|
377
|
-
})) : a.forEach((u) => {
|
|
378
|
-
const m = this.transformValue("field", u, r[u], n);
|
|
379
|
-
m && (s.childNodes ?? (s.childNodes = []), s.childNodes.push(m));
|
|
380
|
-
});
|
|
381
|
-
} else
|
|
382
|
-
throw new Error(`Cannot serialize '${typeof r}' value`);
|
|
383
|
-
return s;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Transforms the specified simple component definition into an Xml node
|
|
387
|
-
* @param name Element name
|
|
388
|
-
* @param value Value to transform
|
|
389
|
-
* @param options Transformation options
|
|
390
|
-
*/
|
|
391
|
-
transformObjectValue(e, t, r) {
|
|
392
|
-
const n = {
|
|
393
|
-
type: "XmlUiElement",
|
|
394
|
-
name: e
|
|
395
|
-
};
|
|
396
|
-
return t && Object.keys(t).forEach(
|
|
397
|
-
(s) => this.addProperty(n, s, t[s], r)
|
|
398
|
-
), n;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Add a property to the specified XMLUI element
|
|
402
|
-
* @param element XML element
|
|
403
|
-
* @param name Element name
|
|
404
|
-
* @param value Element value
|
|
405
|
-
* @param options Transformation options
|
|
406
|
-
*/
|
|
407
|
-
addProperty(e, t, r, n) {
|
|
408
|
-
switch (typeof r) {
|
|
409
|
-
case "undefined":
|
|
410
|
-
break;
|
|
411
|
-
case "string":
|
|
412
|
-
e.attributes ?? (e.attributes = []), e.attributes.push({
|
|
413
|
-
type: "XmlUiAttribute",
|
|
414
|
-
name: t,
|
|
415
|
-
value: r == null ? void 0 : r.toString(),
|
|
416
|
-
preserveQuotes: (n == null ? void 0 : n.removeQuotes) ?? !1,
|
|
417
|
-
preserveSpaces: y.test(r.toString())
|
|
418
|
-
});
|
|
419
|
-
break;
|
|
420
|
-
case "boolean":
|
|
421
|
-
case "number":
|
|
422
|
-
case "object":
|
|
423
|
-
const s = this.transformValue("property", t, r, n);
|
|
424
|
-
s && (e.childNodes ?? (e.childNodes = []), e.childNodes.push(s));
|
|
425
|
-
break;
|
|
426
|
-
default:
|
|
427
|
-
throw new Error(`'${typeof r}' transformation is not implemented yet`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
addComponentElement(e, t) {
|
|
431
|
-
e.childNodes ?? (e.childNodes = []);
|
|
432
|
-
const r = this.transformComponentDefinition(t);
|
|
433
|
-
Array.isArray(r) ? e.childNodes.push(...r) : e.childNodes.push(r);
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Adds a list to the specified XML element
|
|
437
|
-
* @param element XML element
|
|
438
|
-
* @param name Name of the list (child in `element`)
|
|
439
|
-
* @param prefix Prefix to use for the list
|
|
440
|
-
* @param list List with items
|
|
441
|
-
* @param options Transformation options
|
|
442
|
-
*/
|
|
443
|
-
addList(e, t, r, n, s) {
|
|
444
|
-
const a = `${r ? r + "." : ""}${t}`;
|
|
445
|
-
e.childNodes ?? (e.childNodes = []), n.forEach((u) => {
|
|
446
|
-
if (typeof u == "string")
|
|
447
|
-
e.childNodes.push({
|
|
448
|
-
type: "XmlUiElement",
|
|
449
|
-
name: a,
|
|
450
|
-
text: u,
|
|
451
|
-
preserveSpaces: y.test(u) || u !== u.trim() || u === ""
|
|
452
|
-
});
|
|
453
|
-
else if (u === null)
|
|
454
|
-
e.childNodes.push({
|
|
455
|
-
type: "XmlUiElement",
|
|
456
|
-
name: a
|
|
457
|
-
});
|
|
458
|
-
else {
|
|
459
|
-
const m = this.transformObjectValue(a, u, s);
|
|
460
|
-
Array.isArray(m) ? e.childNodes.push(...m) : e.childNodes.push(m);
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* Adds a component list to the specified element
|
|
466
|
-
* @param element XML element
|
|
467
|
-
* @param name Name to use for the wrapper element
|
|
468
|
-
* @param list List with component items
|
|
469
|
-
* @private
|
|
470
|
-
*/
|
|
471
|
-
addComponentList(e, t, r) {
|
|
472
|
-
const n = [];
|
|
473
|
-
r.forEach((a) => {
|
|
474
|
-
const u = this.transformSimpleComponentDefinition(a);
|
|
475
|
-
Array.isArray(u) ? n.push(...u) : n.push(u);
|
|
476
|
-
});
|
|
477
|
-
const s = {
|
|
478
|
-
type: "XmlUiElement",
|
|
479
|
-
name: t,
|
|
480
|
-
childNodes: n
|
|
481
|
-
};
|
|
482
|
-
e.childNodes ?? (e.childNodes = []), e.childNodes.push(s);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
export {
|
|
486
|
-
V as L,
|
|
487
|
-
M as X,
|
|
488
|
-
P as a,
|
|
489
|
-
w as b,
|
|
490
|
-
k as c,
|
|
491
|
-
I as d,
|
|
492
|
-
C as e,
|
|
493
|
-
L as g,
|
|
494
|
-
z as l,
|
|
495
|
-
D as m,
|
|
496
|
-
T as p
|
|
497
|
-
};
|