@webmate-studio/builder 0.2.181 → 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.181",
3
+ "version": "0.2.182",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
@@ -317,12 +317,10 @@ class TemplateEvaluator {
317
317
  /**
318
318
  * Built-in micro-component: <wm-button settings={button}></wm-button>
319
319
  *
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.
320
+ * Resolves to static <a> HTML with Design System button classes.
321
+ * Works identically in Preview and Build no Web Component needed.
323
322
  */
324
323
  evalWmButton(node, ctx) {
325
- // Resolve the settings prop
326
324
  let settings = null;
327
325
  for (const attr of node.attributes) {
328
326
  if (attr.name === 'settings') {
@@ -338,9 +336,28 @@ class TemplateEvaluator {
338
336
  return '<!-- wm-button: no settings -->';
339
337
  }
340
338
 
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>`;
339
+ const {
340
+ title = '', link = '#', icon = '', variant = 'filled',
341
+ size = 'md', iconPosition = 'left', openInNewTab = false
342
+ } = settings;
343
+
344
+ const sizeMap = { small: 'sm', medium: 'md', large: 'lg', sm: 'sm', md: 'md', lg: 'lg' };
345
+ const variantMap = { primary: 'filled', secondary: 'tonal' };
346
+ const classes = `btn btn-${sizeMap[size] || 'md'} btn-${variantMap[variant] || variant}`;
347
+ const href = typeof link === 'object' ? (link.path || link.url || '#') : (link || '#');
348
+ const target = openInNewTab ? ' target="_blank" rel="noopener noreferrer"' : '';
349
+ const iconHtml = icon ? `<iconify-icon icon="${this.escapeAttr(icon)}"></iconify-icon>` : '';
350
+
351
+ let content;
352
+ if (icon && iconPosition === 'right') {
353
+ content = `${this.escapeHtml(title)}${iconHtml ? ' ' + iconHtml : ''}`;
354
+ } else if (icon) {
355
+ content = `${iconHtml ? iconHtml + ' ' : ''}${this.escapeHtml(title)}`;
356
+ } else {
357
+ content = this.escapeHtml(title);
358
+ }
359
+
360
+ return `<a href="${this.escapeAttr(href)}" class="${classes}"${target}>${content}</a>`;
344
361
  }
345
362
 
346
363
  // ========================================