xmlui 0.7.29 → 0.7.31

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 (44) hide show
  1. package/dist/{apiInterceptorWorker-BXh2BMZL.mjs → apiInterceptorWorker-CaRsvFsP.mjs} +1 -1
  2. package/dist/{grammar.tmLanguage-JAlHWPqw.mjs → grammar.tmLanguage-CiYpNgdH.mjs} +3 -17
  3. package/dist/{index-B3eDGXIR.mjs → index-C2wZyJh9.mjs} +19785 -26255
  4. package/dist/index.css +1 -1
  5. package/dist/lint-Fx8P7hBr.mjs +5645 -0
  6. package/dist/scripts/bin/build-lib.js +8 -5
  7. package/dist/scripts/bin/start.js +1 -0
  8. package/dist/scripts/src/components/ComponentProvider.js +1 -16
  9. package/dist/scripts/src/components/DatePicker/DatePicker.js +31 -2
  10. package/dist/scripts/src/components/DatePicker/DatePickerNative.js +3 -34
  11. package/dist/scripts/src/components/FlowLayout/FlowLayout.js +0 -1
  12. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +444 -315
  13. package/dist/scripts/src/components/IconProvider.js +2 -4
  14. package/dist/scripts/src/components/List/List.js +6 -0
  15. package/dist/scripts/src/components/List/ListNative.js +7 -6
  16. package/dist/scripts/src/components/Markdown/MarkdownNative.js +84 -85
  17. package/dist/scripts/src/components/{ThemeChanger → ToneChangerButton}/ToneChangerButton.js +0 -1
  18. package/dist/scripts/src/components-core/ComponentDecorator.js +45 -67
  19. package/dist/scripts/src/components-core/InspectorContext.js +15 -5
  20. package/dist/scripts/src/components-core/descriptorHelper.js +16 -3
  21. package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +1 -1
  22. package/dist/scripts/src/components-core/theming/layout-resolver.js +40 -9
  23. package/dist/scripts/src/components-core/utils/extractParam.js +66 -0
  24. package/dist/scripts/src/parsers/style-parser/StyleParser.js +15 -603
  25. package/dist/scripts/src/syntax/grammar.tmLanguage.json +4 -17
  26. package/dist/style.css +1 -1
  27. package/dist/xmlui-metadata.mjs +5179 -5314
  28. package/dist/xmlui-metadata.umd.js +11 -88
  29. package/dist/xmlui-parser.d.ts +1488 -0
  30. package/dist/xmlui-parser.mjs +407 -0
  31. package/dist/xmlui-standalone.umd.js +150 -227
  32. package/dist/xmlui.d.ts +1 -1
  33. package/dist/xmlui.mjs +1 -1
  34. package/package.json +12 -3
  35. package/dist/scripts/src/components/Icon/MoonIcon.js +0 -10
  36. package/dist/scripts/src/components/Icon/SunIcon.js +0 -10
  37. package/dist/scripts/src/components/IconInfoCard/IconInfoCard.js +0 -40
  38. package/dist/scripts/src/components/PageHeader/PageHeader.js +0 -36
  39. package/dist/scripts/src/components/TableHeader/TableHeader.js +0 -34
  40. package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +0 -115
  41. package/dist/scripts/src/components/Toolbar/Toolbar.js +0 -32
  42. package/dist/scripts/src/components/ToolbarButton/ToolbarButton.js +0 -38
  43. package/dist/scripts/src/components/TrendLabel/TrendLabel.js +0 -37
  44. package/dist/scripts/src/parsers/style-parser/style-compiler.js +0 -562
@@ -1,562 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compileLayout = compileLayout;
4
- const lodash_es_1 = require("lodash-es");
5
- const constants_1 = require("../../components-core/constants");
6
- const StyleParser_1 = require("./StyleParser");
7
- const defaultCompResult = {
8
- cssProps: {},
9
- nonCssProps: {},
10
- };
11
- // Compile style properties into an object that can be directly used as the "style" attribute of elements
12
- function compileLayout(layoutProps = constants_1.EMPTY_OBJECT, themeVars, layoutContext) {
13
- var _a, _b, _c, _d, _e, _f;
14
- const result = {
15
- cssProps: {},
16
- nonCssProps: {},
17
- };
18
- const css = result.cssProps;
19
- // --- Compile alignment
20
- const horizontalAlignment = compileAlignment("horizontalAlignment", layoutProps);
21
- if (horizontalAlignment) {
22
- result.nonCssProps.horizontalAlignment = horizontalAlignment;
23
- }
24
- const verticalAlignment = compileAlignment("verticalAlignment", layoutProps);
25
- if (verticalAlignment) {
26
- result.nonCssProps.verticalAlignment = verticalAlignment;
27
- }
28
- const orientation = compileOrientation("orientation", layoutProps);
29
- if (orientation) {
30
- result.nonCssProps.orientation = orientation;
31
- }
32
- // --- Compile dimensions
33
- if (!!getOrientation(layoutContext)) {
34
- // --- In a container, we always use "flex-shrink: 0"
35
- css.flexShrink = 0;
36
- }
37
- const widthResult = compileSize("width", layoutProps);
38
- if (widthResult.value)
39
- css.width = widthResult.value;
40
- if (isHorizontalAndStartSize(widthResult, layoutContext)) {
41
- // --- In a horizontal container, we use "flex" when width is in start-size
42
- css.flex = widthResult.ratio;
43
- css.flexShrink = 1; //if it's star sizing, we allow shrinking
44
- }
45
- const minWidthResult = compileSize("minWidth", layoutProps);
46
- if (minWidthResult.value)
47
- css.minWidth = minWidthResult.value;
48
- const maxWidthResult = compileSize("maxWidth", layoutProps);
49
- if (maxWidthResult.value)
50
- css.maxWidth = maxWidthResult.value;
51
- const heightResult = compileSize("height", layoutProps);
52
- if (heightResult.value)
53
- css.height = heightResult.value;
54
- if (isVerticalAndStarSize(heightResult, layoutContext)) {
55
- // --- In a vertical container, we use "flex" when height is in star-size
56
- css.flex = heightResult.ratio;
57
- css.flexShrink = 1;
58
- }
59
- const minHeightResult = compileSize("minHeight", layoutProps);
60
- if (minHeightResult.value)
61
- css.minHeight = minHeightResult.value;
62
- const maxHeightResult = compileSize("maxHeight", layoutProps);
63
- if (maxHeightResult.value)
64
- css.maxHeight = maxHeightResult.value;
65
- // --- Compile positions
66
- const top = compileSize("top", layoutProps);
67
- if (top.value)
68
- css.top = top.value;
69
- const right = compileSize("right", layoutProps);
70
- if (right.value)
71
- css.right = right.value;
72
- const bottom = compileSize("bottom", layoutProps);
73
- if (bottom.value)
74
- css.bottom = bottom.value;
75
- const left = compileSize("left", layoutProps);
76
- if (left.value)
77
- css.left = left.value;
78
- // --- Compile gap
79
- const gap = compileSize("gap", layoutProps);
80
- if (gap.value)
81
- css.gap = gap.value;
82
- // --- Compile border
83
- const border = compileBorder("border", layoutProps);
84
- if (border)
85
- css.border = border;
86
- const borderTop = compileBorder("borderTop", layoutProps);
87
- if (borderTop)
88
- css.borderTop = borderTop;
89
- const borderRight = compileBorder("borderRight", layoutProps);
90
- if (borderRight)
91
- css.borderRight = borderRight;
92
- const borderBottom = compileBorder("borderBottom", layoutProps);
93
- if (borderBottom)
94
- css.borderBottom = borderBottom;
95
- const borderLeft = compileBorder("borderLeft", layoutProps);
96
- if (borderLeft)
97
- css.borderLeft = borderLeft;
98
- const borderColor = compileColor("borderColor", layoutProps);
99
- if (borderColor)
100
- css.borderColor = borderColor;
101
- const borderStyle = compileBorderStyle("borderStyle", layoutProps);
102
- if (borderStyle)
103
- css.borderStyle = borderStyle;
104
- const borderThickness = compileSize("borderThickness", layoutProps);
105
- if (borderThickness.value)
106
- css.borderWidth = borderThickness.value;
107
- // --- Compile radius
108
- const radius = compileRadius("radius", layoutProps);
109
- if (radius)
110
- css.borderRadius = radius;
111
- const radiusTopLeft = compileRadius("radiusTopLeft", layoutProps);
112
- if (radiusTopLeft)
113
- css.borderTopLeftRadius = radiusTopLeft;
114
- const radiusTopRight = compileRadius("radiusTopRight", layoutProps);
115
- if (radiusTopRight)
116
- css.borderTopRightRadius = radiusTopRight;
117
- const radiusBottomLeft = compileRadius("radiusBottomLeft", layoutProps);
118
- if (radiusBottomLeft)
119
- css.borderBottomLeftRadius = radiusBottomLeft;
120
- const radiusBottomRight = compileRadius("radiusBottomRight", layoutProps);
121
- if (radiusBottomRight)
122
- css.borderBottomRightRadius = radiusBottomRight;
123
- // --- Compile padding
124
- const padding = compileSize("padding", layoutProps);
125
- if (padding.value)
126
- css.padding = padding.value;
127
- const horizontalPadding = compileSize("horizontalPadding", layoutProps);
128
- const verticalPadding = compileSize("verticalPadding", layoutProps);
129
- const paddingLeft = mergeSizes(compileSize("paddingLeft", layoutProps), horizontalPadding);
130
- if (paddingLeft.value)
131
- css.paddingLeft = paddingLeft.value;
132
- const paddingRight = mergeSizes(compileSize("paddingRight", layoutProps), horizontalPadding);
133
- if (paddingRight.value)
134
- css.paddingRight = paddingRight.value;
135
- const paddingTop = mergeSizes(compileSize("paddingTop", layoutProps), verticalPadding);
136
- if (paddingTop.value)
137
- css.paddingTop = paddingTop.value;
138
- const paddingBottom = mergeSizes(compileSize("paddingBottom", layoutProps), verticalPadding);
139
- if (paddingBottom.value)
140
- css.paddingBottom = paddingBottom.value;
141
- // --- Compile margin
142
- const margin = compileMargin("margin", layoutProps);
143
- if (margin)
144
- css.margin = margin;
145
- const horizontalMargin = compileMargin("horizontalMargin", layoutProps);
146
- const verticalMargin = compileMargin("verticalMargin", layoutProps);
147
- const marginLeft = (_a = compileMargin("marginLeft", layoutProps)) !== null && _a !== void 0 ? _a : horizontalMargin;
148
- if (marginLeft)
149
- css.marginLeft = marginLeft;
150
- const marginRight = (_b = compileMargin("marginRight", layoutProps)) !== null && _b !== void 0 ? _b : horizontalMargin;
151
- if (marginRight)
152
- css.marginRight = marginRight;
153
- const marginTop = (_c = compileMargin("marginTop", layoutProps)) !== null && _c !== void 0 ? _c : verticalMargin;
154
- if (marginTop)
155
- css.marginTop = marginTop;
156
- const marginBottom = (_d = compileMargin("marginBottom", layoutProps)) !== null && _d !== void 0 ? _d : verticalMargin;
157
- if (marginBottom)
158
- css.marginBottom = marginBottom;
159
- // --- Compile other
160
- const backgroundColor = compileColor("backgroundColor", layoutProps);
161
- if (backgroundColor)
162
- css.backgroundColor = backgroundColor;
163
- const background = compileBackground("background", layoutProps);
164
- if (background)
165
- css.background = background;
166
- const boxShadow = compileShadow("shadow", layoutProps);
167
- if (boxShadow)
168
- css.boxShadow = boxShadow;
169
- const direction = compileDirection("direction", layoutProps);
170
- if (direction)
171
- css.direction = direction;
172
- const overflowX = compileScrolling("horizontalOverflow", layoutProps);
173
- if (overflowX)
174
- css.overflowX = overflowX;
175
- const overflowY = compileScrolling("verticalOverflow", layoutProps);
176
- if (overflowY)
177
- css.overflowY = overflowY;
178
- const zIndex = compileZIndex("zIndex", layoutProps);
179
- if (zIndex)
180
- css.zIndex = zIndex;
181
- const opacity = compileOpacity("opacity", layoutProps);
182
- if (opacity)
183
- css.opacity = opacity;
184
- const zoom = compileZoom("zoom", layoutProps);
185
- if (zoom)
186
- css.zoom = zoom;
187
- // --- Compile typography
188
- const color = compileColor("color", layoutProps);
189
- if (color)
190
- css.color = color;
191
- const fontFamily = compileFontFamily("fontFamily", layoutProps);
192
- if (fontFamily)
193
- css.fontFamily = fontFamily;
194
- const fontSize = compileSize("fontSize", layoutProps);
195
- if (fontSize.value)
196
- css.fontSize = fontSize.value;
197
- const fontWeight = compileFontWeight("fontWeight", layoutProps);
198
- if (fontWeight)
199
- css.fontWeight = fontWeight;
200
- const fontStyle = compileItalic("italic", layoutProps);
201
- if (fontStyle)
202
- css.fontStyle = fontStyle;
203
- const textDecoration = compileTextDecoration("textDecoration", layoutProps);
204
- if (textDecoration)
205
- css.textDecoration = textDecoration;
206
- const userSelect = compileUserSelect("userSelect", layoutProps);
207
- if (userSelect)
208
- css.userSelect = userSelect;
209
- const letterSpacing = compileSize("letterSpacing", layoutProps);
210
- if (letterSpacing.value)
211
- css.letterSpacing = letterSpacing.value;
212
- const textTransform = compileTextTransform("textTransform", layoutProps);
213
- if (textTransform)
214
- css.textTransform = textTransform;
215
- const lineHeight = compileLineHeight("lineHeight", layoutProps);
216
- if (lineHeight)
217
- css.lineHeight = lineHeight;
218
- const textAlign = compileTextAlign("textAlign", layoutProps);
219
- if (textAlign)
220
- css.textAlign = textAlign;
221
- const textAlignLast = compileTextAlign("textAlignLast", layoutProps);
222
- if (textAlignLast)
223
- css.textAlignLast = textAlignLast;
224
- const textWrap = (_e = layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.textWrap) === null || _e === void 0 ? void 0 : _e.toString();
225
- if (textWrap)
226
- css.textWrap = textWrap;
227
- const whiteSpace = (_f = layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps.whiteSpace) === null || _f === void 0 ? void 0 : _f.toString();
228
- if (whiteSpace) {
229
- css.whiteSpace = whiteSpace;
230
- }
231
- // --- Compile content rendering
232
- const wrapContent = compileWrapContent("wrapContent", layoutProps);
233
- if (wrapContent)
234
- css.flexWrap = wrapContent;
235
- const canShrink = compileCanShrink("canShrink", layoutProps);
236
- if (canShrink)
237
- css.flexShrink = canShrink;
238
- // --- Other
239
- const cursor = compileCursor("cursor", layoutProps);
240
- if (cursor)
241
- css.cursor = cursor;
242
- // --- Done
243
- //if we didn't set any props, return a referentially stable result
244
- if ((0, lodash_es_1.isEmpty)(result.cssProps) && (0, lodash_es_1.isEmpty)(result.nonCssProps) && (0, lodash_es_1.isEmpty)(result.issues)) {
245
- return defaultCompResult;
246
- }
247
- return result;
248
- function mergeSizes(size, defSize) {
249
- return size.value ? size : defSize;
250
- }
251
- function getThemeVar(themeVar) {
252
- return themeVars === null || themeVars === void 0 ? void 0 : themeVars[themeVar.id.substring(1)];
253
- }
254
- function isCssVarResolved(themeVar) {
255
- const varValue = getThemeVar(themeVar);
256
- if (varValue === undefined || varValue === "") {
257
- return false;
258
- }
259
- return true;
260
- }
261
- function compile(propName, layoutProps, parseFn, convertFn) {
262
- var _a, _b, _c, _d;
263
- const defValue = compileSingleProperty();
264
- if (((_a = layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.mediaSize) === null || _a === void 0 ? void 0 : _a.sizeIndex) !== undefined) {
265
- const sizeIndex = (_b = layoutContext.mediaSize) === null || _b === void 0 ? void 0 : _b.sizeIndex;
266
- const xsValue = compileSingleProperty("xs");
267
- const smValue = compileSingleProperty("sm");
268
- const mdValue = compileSingleProperty("md");
269
- const lgValue = compileSingleProperty("lg");
270
- const xlValue = compileSingleProperty("xl");
271
- const xxlValue = compileSingleProperty("xxl");
272
- let mergedValue;
273
- switch (sizeIndex) {
274
- case 0: // xs
275
- mergedValue = (_c = xsValue !== null && xsValue !== void 0 ? xsValue : smValue) !== null && _c !== void 0 ? _c : mdValue;
276
- break;
277
- case 1: // sm
278
- mergedValue = smValue !== null && smValue !== void 0 ? smValue : mdValue;
279
- break;
280
- case 2: // md
281
- mergedValue = mdValue;
282
- break;
283
- case 3: // lg
284
- mergedValue = lgValue;
285
- break;
286
- case 4: // xl
287
- mergedValue = xlValue !== null && xlValue !== void 0 ? xlValue : lgValue;
288
- break;
289
- case 5: // xxl
290
- mergedValue = (_d = xxlValue !== null && xxlValue !== void 0 ? xxlValue : xlValue) !== null && _d !== void 0 ? _d : lgValue;
291
- break;
292
- }
293
- return mergedValue !== null && mergedValue !== void 0 ? mergedValue : defValue;
294
- }
295
- return defValue;
296
- function compileSingleProperty(sizeSpec) {
297
- var _a, _b, _c;
298
- const source = (_a = layoutProps === null || layoutProps === void 0 ? void 0 : layoutProps[propName + (sizeSpec ? `-${sizeSpec}` : "")]) === null || _a === void 0 ? void 0 : _a.toString();
299
- if (!source)
300
- return undefined;
301
- const parser = new StyleParser_1.StyleParser(source);
302
- try {
303
- const node = parseFn(parser);
304
- if (!node)
305
- return source;
306
- if (!parser.testCompleted()) {
307
- (_b = result.issues) !== null && _b !== void 0 ? _b : (result.issues = {});
308
- result.issues[propName] = `Unexpected tail after the ${propName}`;
309
- return source;
310
- }
311
- if (node.themeId) {
312
- return (0, StyleParser_1.toCssVar)(node.themeId);
313
- }
314
- return convertFn(node);
315
- }
316
- catch (err) {
317
- (_c = result.issues) !== null && _c !== void 0 ? _c : (result.issues = {});
318
- result.issues[propName] = err === null || err === void 0 ? void 0 : err.toString();
319
- return source;
320
- }
321
- }
322
- }
323
- // --- Compiles an alignment definition into a CSS size property
324
- function compileAlignment(propName, layoutProps) {
325
- return compile(propName, layoutProps, (p) => p.parseAlignment(), (n) => n.value);
326
- }
327
- // --- Compiles an alignment definition into a CSS size property
328
- function compileTextAlign(propName, layoutProps) {
329
- return compile(propName, layoutProps, (p) => p.parseTextAlign(), (n) => n.value);
330
- }
331
- // --- Compiles a user select definition into a CSS size property
332
- function compileUserSelect(propName, layoutProps) {
333
- return compile(propName, layoutProps, (p) => p.parseUserSelect(), (n) => n.value);
334
- }
335
- // --- Compiles a text transform definition into a CSS size property
336
- function compileTextTransform(propName, layoutProps) {
337
- return compile(propName, layoutProps, (p) => p.parseTextTransform(), (n) => n.value);
338
- }
339
- function compileOrientation(propName, layoutProps) {
340
- return compile(propName, layoutProps, (p) => p.parseOrientation(), (n) => n.value);
341
- }
342
- // --- Compiles a size definition into a CSS size property
343
- function compileLineHeight(propName, layoutProps) {
344
- return compile(propName, layoutProps, (p) => p.parseLineHeight(), (n) => `${n.value}${n.unit}`);
345
- }
346
- // --- Compiles an opacity definition into a CSS opacity property
347
- function compileOpacity(propName, layoutProps) {
348
- return compile(propName, layoutProps, (p) => p.parseOpacity(), (n) => `${n.value}${n.unit}`);
349
- }
350
- // --- Compiles an opacity definition into a CSS opacity property
351
- function compileZoom(propName, layoutProps) {
352
- return compile(propName, layoutProps, (p) => p.parseZoom(), (n) => { var _a; return `${n.value}${(_a = n.unit) !== null && _a !== void 0 ? _a : ""}`; });
353
- }
354
- // --- Compiles a size definition into a CSS size property
355
- function compileSize(propName, layoutProps) {
356
- let isStarSize = false;
357
- let ratio;
358
- let value = compile(propName, layoutProps, (p) => {
359
- var _a;
360
- const sizeNode = p.parseSize();
361
- isStarSize = (sizeNode === null || sizeNode === void 0 ? void 0 : sizeNode.unit) === "*";
362
- if (isStarSize) {
363
- ratio = (_a = sizeNode === null || sizeNode === void 0 ? void 0 : sizeNode.value) !== null && _a !== void 0 ? _a : 1;
364
- }
365
- return sizeNode;
366
- }, (n) => { var _a; return (_a = n.extSize) !== null && _a !== void 0 ? _a : `${n.value}${n.unit}`; });
367
- return {
368
- value: value ? replaceThemeVar(value) : undefined,
369
- ratio,
370
- isStarSize,
371
- };
372
- }
373
- // --- Compiles a size definition into a CSS size property
374
- function compileMargin(propName, layoutProps) {
375
- return compile(propName, layoutProps, (p) => p.parseMargin(), (n) => { var _a; return (_a = n.extSize) !== null && _a !== void 0 ? _a : `${n.value}${n.unit}`; });
376
- }
377
- // --- Compiles a zIndex definition into a CSS zIndex property
378
- function compileZIndex(propName, layoutProps) {
379
- return compile(propName, layoutProps, (p) => p.parseZIndex(), (n) => n.value.toString());
380
- }
381
- function compileScrolling(propName, layoutProps) {
382
- return compile(propName, layoutProps, (p) => p.parseScrolling(), (n) => n.value);
383
- }
384
- function compileDirection(propName, layoutProps) {
385
- return compile(propName, layoutProps, (p) => p.parseDirection(), (n) => n.value);
386
- }
387
- function compileCursor(propName, layoutProps) {
388
- return compile(propName, layoutProps, (p) => p.parseCursor(), (n) => n.value);
389
- }
390
- function compileFontWeight(propName, layoutProps) {
391
- return compile(propName, layoutProps, (p) => p.parseFontWeight(), (n) => { var _a; return (_a = n.value) === null || _a === void 0 ? void 0 : _a.toString(); });
392
- }
393
- function compileFontFamily(propName, layoutProps) {
394
- return compile(propName, layoutProps, (p) => p.parseFontFamily(), (n) => n.value);
395
- }
396
- function compileColor(propName, layoutProps) {
397
- return compile(propName, layoutProps, (p) => p.parseColor(), (n) => n.value !== undefined
398
- ? typeof n.value === "number"
399
- ? `#${n.value.toString(16).padStart(8, "0")}`
400
- : n.value
401
- : undefined);
402
- }
403
- function compileBackground(propName, layoutProps) {
404
- return compile(propName, layoutProps, (p) => p.parseColor(), (n) => n.value !== undefined
405
- ? typeof n.value === "number"
406
- ? `#${n.value.toString(16).padStart(8, "0")}`
407
- : n.value
408
- : undefined);
409
- }
410
- function hasOnlyUnresolvedVars(...themeIds) {
411
- let definedThemeIds = themeIds.filter((id) => id !== undefined);
412
- if (!definedThemeIds.length) {
413
- return false;
414
- }
415
- for (let i = 0; i < definedThemeIds.length; i++) {
416
- const themeId = definedThemeIds[i];
417
- if (isCssVarResolved(themeId)) {
418
- return false;
419
- }
420
- if (themeId.defaultValue) {
421
- const hasStringDefaultValue = themeId.defaultValue.find((value) => typeof value === "string") !== undefined;
422
- if (hasStringDefaultValue) {
423
- return false;
424
- }
425
- const themeVarDefaultValues = themeId.defaultValue.filter((value) => typeof value !== "string");
426
- if (!hasOnlyUnresolvedVars(...themeVarDefaultValues)) {
427
- return false;
428
- }
429
- }
430
- }
431
- return true;
432
- }
433
- function compileBorder(propName, layoutProps) {
434
- return compile(propName, layoutProps, (p) => p.parseBorder(), (n) => {
435
- var _a, _b, _c;
436
- if (hasOnlyUnresolvedVars(n.themeId1, n.themeId2, n.themeId3)) {
437
- return undefined;
438
- }
439
- return ((`${n.themeId1 ? (0, StyleParser_1.toCssVar)(n.themeId1) : ""} ` +
440
- `${n.themeId2 ? (0, StyleParser_1.toCssVar)(n.themeId2) : ""} ` +
441
- `${n.themeId3 ? (0, StyleParser_1.toCssVar)(n.themeId3) : ""}`).trim() +
442
- " " +
443
- `${(_a = n.widthValue) !== null && _a !== void 0 ? _a : ""}${(_b = n.widthUnit) !== null && _b !== void 0 ? _b : ""}` +
444
- `${n.widthValue && n.styleValue ? " " : ""}` +
445
- `${(_c = n.styleValue) !== null && _c !== void 0 ? _c : ""}` +
446
- `${(n.widthValue || n.styleValue) && n.color ? " " : ""}` +
447
- `${n.color !== undefined
448
- ? typeof n.color === "number"
449
- ? `#${n.color.toString(16).padStart(8, "0")}`
450
- : n.color
451
- : ""}`).trim();
452
- });
453
- }
454
- function compileBorderStyle(propName, layoutProps) {
455
- return compile(propName, layoutProps, (p) => p.parseBorderStyle(), (n) => n.value);
456
- }
457
- function compileTextDecoration(propName, layoutProps) {
458
- return compile(propName, layoutProps, (p) => p.parseTextDecoration(), (n) => {
459
- var _a, _b, _c;
460
- if (n.none) {
461
- return "none";
462
- }
463
- if (hasOnlyUnresolvedVars(n.themeId1, n.themeId2, n.themeId3)) {
464
- return undefined;
465
- }
466
- return ((`${n.themeId1 ? (0, StyleParser_1.toCssVar)(n.themeId1) : ""} ` +
467
- `${n.themeId2 ? (0, StyleParser_1.toCssVar)(n.themeId2) : ""} ` +
468
- `${n.themeId3 ? (0, StyleParser_1.toCssVar)(n.themeId3) : ""}`).trim() +
469
- " " +
470
- `${(_a = n.line) !== null && _a !== void 0 ? _a : ""}` +
471
- `${n.line && n.style ? " " : ""}` +
472
- `${(_b = n.style) !== null && _b !== void 0 ? _b : ""}` +
473
- `${(n.line || n.style) && n.color ? " " : ""}` +
474
- `${(_c = n.color) !== null && _c !== void 0 ? _c : ""}`).trim();
475
- });
476
- }
477
- function compileRadius(propName, layoutProps) {
478
- return compile(propName, layoutProps, (p) => p.parseRadius(), (n) => {
479
- var _a, _b, _c, _d;
480
- if (hasOnlyUnresolvedVars(n.themeId1, n.themeId2)) {
481
- return undefined;
482
- }
483
- const theme1 = `${n.themeId1 ? (0, StyleParser_1.toCssVar)(n.themeId1) : ""}`;
484
- const value1 = `${(_a = n.value1) !== null && _a !== void 0 ? _a : ""}${(_b = n.unit1) !== null && _b !== void 0 ? _b : ""}`;
485
- const theme2 = `${n.themeId2 ? (0, StyleParser_1.toCssVar)(n.themeId2) : ""}`;
486
- const value2 = `${(_c = n.value2) !== null && _c !== void 0 ? _c : ""}${(_d = n.unit2) !== null && _d !== void 0 ? _d : ""}`;
487
- let part = `${theme1}${value1}`;
488
- let part2 = `${theme2}${value2}`;
489
- part += part2 ? " / " + part2 : "";
490
- return part.trim();
491
- });
492
- }
493
- function compileShadow(propName, layoutProps) {
494
- return compile(propName, layoutProps, (p) => p.parseShadow(), (n) => {
495
- var _a;
496
- let css = "";
497
- for (const sg of (_a = n.segments) !== null && _a !== void 0 ? _a : []) {
498
- if (css) {
499
- css += ", ";
500
- }
501
- css += sg.inset ? "inset " : "";
502
- css += `${sg.offsetXValue}${sg.offsetXUnit} ${sg.offsetYValue}${sg.offsetYUnit}`;
503
- if (sg.blurRadiusValue !== undefined) {
504
- css += ` ${sg.blurRadiusValue}${sg.blurRadiusUnit}`;
505
- }
506
- if (sg.spreadRadiusValue !== undefined) {
507
- css += ` ${sg.spreadRadiusValue}${sg.spreadRadiusUnit}`;
508
- }
509
- if (sg.color !== undefined) {
510
- css += ` ${sg.color}`;
511
- }
512
- }
513
- return css;
514
- });
515
- }
516
- // --- Compiles a Boolean definition into a CSS font-style size property
517
- function compileItalic(propName, layoutProps) {
518
- return compile(propName, layoutProps, (p) => p.parseBoolean(), (n) => (n.value ? "italic" : "normal"));
519
- }
520
- // --- Compiles a Boolean definition into a CSS flex-wrap property
521
- function compileWrapContent(propName, layoutProps) {
522
- return compile(propName, layoutProps, (p) => p.parseBoolean(), (n) => (n.value ? "wrap" : "nowrap"));
523
- }
524
- // --- Compiles a Boolean definition into a CSS flex-shrink property
525
- function compileCanShrink(propName, layoutProps) {
526
- return compile(propName, layoutProps, (p) => p.parseBoolean(), (n) => (n.value ? "1" : "0"));
527
- }
528
- function isHorizontalAndStartSize(size, layoutContext) {
529
- if (!size.value)
530
- return false;
531
- const orientation = getOrientation(layoutContext);
532
- return orientation === "horizontal" && size.isStarSize;
533
- }
534
- function isVerticalAndStarSize(size, layoutContext) {
535
- if (!size.value)
536
- return false;
537
- const orientation = getOrientation(layoutContext);
538
- return orientation === "vertical" && size.isStarSize;
539
- }
540
- function getOrientation(layoutContext) {
541
- if (!layoutContext)
542
- return;
543
- let orientation = (layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.type) === "Stack" && (layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.orientation);
544
- return orientation === null || orientation === void 0 ? void 0 : orientation.toString();
545
- }
546
- function replaceThemeVar(input) {
547
- const regex = /\$([a-zA-Z0-9_-]+)/gi;
548
- let matches = input.matchAll(regex);
549
- // --- We go from 1, because result[1] is the whole stuff
550
- if (matches) {
551
- let ret = input;
552
- for (let match of matches) {
553
- const varName = match[0];
554
- if (varName) {
555
- ret = ret.replace(match[0], (0, StyleParser_1.toCssVar)(varName));
556
- }
557
- }
558
- return ret;
559
- }
560
- return input;
561
- }
562
- }