@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.180",
3
+ "version": "0.2.182",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
@@ -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 (they output complete HTML)
44
- return node.value.replace(/<\/wm-button>/g, '');
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
- * Transforms to semantic HTML with Design System button classes.
318
- * Settings object: { title, link, icon, variant, size, iconPosition, openInNewTab }
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
- link = '#',
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 variantClass = `btn-${variantMap[variant] || variant}`;
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
- // Build content based on icon position
366
- let content = '';
351
+ let content;
367
352
  if (icon && iconPosition === 'right') {
368
353
  content = `${this.escapeHtml(title)}${iconHtml ? ' ' + iconHtml : ''}`;
369
- } else if (icon && iconPosition === 'left') {
354
+ } else if (icon) {
370
355
  content = `${iconHtml ? iconHtml + ' ' : ''}${this.escapeHtml(title)}`;
371
356
  } else {
372
357
  content = this.escapeHtml(title);