@webmate-studio/builder 0.2.180 → 0.2.182
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/package.json +1 -1
- package/src/template-evaluator.js +13 -28
package/package.json
CHANGED
|
@@ -40,8 +40,11 @@ class TemplateEvaluator {
|
|
|
40
40
|
case 'Fragment':
|
|
41
41
|
return this.evalFragment(node, ctx);
|
|
42
42
|
case 'Text':
|
|
43
|
-
// Strip closing tags of built-in micro-components (
|
|
44
|
-
|
|
43
|
+
// Strip closing tags of built-in micro-components (only if present)
|
|
44
|
+
if (node.value.includes('</wm-')) {
|
|
45
|
+
return node.value.replace(/<\/wm-button>/g, '');
|
|
46
|
+
}
|
|
47
|
+
return node.value;
|
|
45
48
|
case 'Expression':
|
|
46
49
|
return this.evalExpression(node, ctx);
|
|
47
50
|
case 'HtmlExpression':
|
|
@@ -314,14 +317,10 @@ class TemplateEvaluator {
|
|
|
314
317
|
/**
|
|
315
318
|
* Built-in micro-component: <wm-button settings={button}></wm-button>
|
|
316
319
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* Size mapping: small/sm → btn-sm, medium/md → btn-md, large/lg → btn-lg
|
|
321
|
-
* Variant mapping: primary → btn-filled, filled/tonal/outline/ghost/text/destructive → btn-{variant}
|
|
320
|
+
* Resolves to static <a> HTML with Design System button classes.
|
|
321
|
+
* Works identically in Preview and Build — no Web Component needed.
|
|
322
322
|
*/
|
|
323
323
|
evalWmButton(node, ctx) {
|
|
324
|
-
// Resolve the settings prop
|
|
325
324
|
let settings = null;
|
|
326
325
|
for (const attr of node.attributes) {
|
|
327
326
|
if (attr.name === 'settings') {
|
|
@@ -338,35 +337,21 @@ class TemplateEvaluator {
|
|
|
338
337
|
}
|
|
339
338
|
|
|
340
339
|
const {
|
|
341
|
-
title = '',
|
|
342
|
-
|
|
343
|
-
icon = '',
|
|
344
|
-
variant = 'filled',
|
|
345
|
-
size = 'md',
|
|
346
|
-
iconPosition = 'left',
|
|
347
|
-
openInNewTab = false
|
|
340
|
+
title = '', link = '#', icon = '', variant = 'filled',
|
|
341
|
+
size = 'md', iconPosition = 'left', openInNewTab = false
|
|
348
342
|
} = settings;
|
|
349
343
|
|
|
350
|
-
// Map size names
|
|
351
344
|
const sizeMap = { small: 'sm', medium: 'md', large: 'lg', sm: 'sm', md: 'md', lg: 'lg' };
|
|
352
|
-
const sizeClass = `btn-${sizeMap[size] || 'md'}`;
|
|
353
|
-
|
|
354
|
-
// Map variant names (primary → filled for backward compat)
|
|
355
345
|
const variantMap = { primary: 'filled', secondary: 'tonal' };
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
const classes = ['btn', sizeClass, variantClass].join(' ');
|
|
359
|
-
const target = openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : '';
|
|
346
|
+
const classes = `btn btn-${sizeMap[size] || 'md'} btn-${variantMap[variant] || variant}`;
|
|
360
347
|
const href = typeof link === 'object' ? (link.path || link.url || '#') : (link || '#');
|
|
361
|
-
|
|
362
|
-
// Build icon HTML
|
|
348
|
+
const target = openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : '';
|
|
363
349
|
const iconHtml = icon ? `<iconify-icon icon="${this.escapeAttr(icon)}"></iconify-icon>` : '';
|
|
364
350
|
|
|
365
|
-
|
|
366
|
-
let content = '';
|
|
351
|
+
let content;
|
|
367
352
|
if (icon && iconPosition === 'right') {
|
|
368
353
|
content = `${this.escapeHtml(title)}${iconHtml ? ' ' + iconHtml : ''}`;
|
|
369
|
-
} else if (icon
|
|
354
|
+
} else if (icon) {
|
|
370
355
|
content = `${iconHtml ? iconHtml + ' ' : ''}${this.escapeHtml(title)}`;
|
|
371
356
|
} else {
|
|
372
357
|
content = this.escapeHtml(title);
|