@webmate-studio/builder 0.2.180 → 0.2.181

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.181",
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,11 +317,9 @@ 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
+ * Outputs a <wm-button> Custom Element with serialized settings.
321
+ * In Preview: Web Component (wm-button.js) renders it live.
322
+ * In Build: html-static-builder resolves it to static <a> HTML.
322
323
  */
323
324
  evalWmButton(node, ctx) {
324
325
  // Resolve the settings prop
@@ -337,42 +338,9 @@ class TemplateEvaluator {
337
338
  return '<!-- wm-button: no settings -->';
338
339
  }
339
340
 
340
- const {
341
- title = '',
342
- link = '#',
343
- icon = '',
344
- variant = 'filled',
345
- size = 'md',
346
- iconPosition = 'left',
347
- openInNewTab = false
348
- } = settings;
349
-
350
- // Map size names
351
- 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
- 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"' : '';
360
- const href = typeof link === 'object' ? (link.path || link.url || '#') : (link || '#');
361
-
362
- // Build icon HTML
363
- const iconHtml = icon ? `<iconify-icon icon="${this.escapeAttr(icon)}"></iconify-icon>` : '';
364
-
365
- // Build content based on icon position
366
- let content = '';
367
- if (icon && iconPosition === 'right') {
368
- content = `${this.escapeHtml(title)}${iconHtml ? ' ' + iconHtml : ''}`;
369
- } else if (icon && iconPosition === 'left') {
370
- content = `${iconHtml ? iconHtml + ' ' : ''}${this.escapeHtml(title)}`;
371
- } else {
372
- content = this.escapeHtml(title);
373
- }
374
-
375
- return `<a href="${this.escapeAttr(href)}" class="${classes}"${target}>${content}</a>`;
341
+ // Serialize settings as JSON attribute for the Web Component
342
+ const json = JSON.stringify(settings).replace(/'/g, '&apos;');
343
+ return `<wm-button settings='${json}'></wm-button>`;
376
344
  }
377
345
 
378
346
  // ========================================