@zentto/studio 0.5.2 → 0.6.1

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.
@@ -28,6 +28,8 @@ import './fields/zs-field-chart.js';
28
28
  import './fields/zs-field-media.js';
29
29
  import './fields/zs-field-treeview.js';
30
30
  import './fields/zs-field-chips.js';
31
+ import './fields/zs-field-datagrid.js';
32
+ import './fields/zs-field-report.js';
31
33
  let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
32
34
  constructor() {
33
35
  super(...arguments);
@@ -41,105 +43,105 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
41
43
  this.activeSection = 0;
42
44
  this.renderCounter = 0; // force re-renders
43
45
  }
44
- static { this.styles = [studioTokens, fieldBaseStyles, css `
45
- :host {
46
- display: block;
47
- font-family: var(--zs-font-family);
48
- color: var(--zs-text);
49
- }
50
- .zs-renderer { background: var(--zs-bg); border-radius: var(--zs-radius-lg); }
51
- .zs-header {
52
- padding: var(--zs-spacing-md);
53
- border-bottom: 1px solid var(--zs-border);
54
- }
55
- .zs-title {
56
- margin: 0; font-size: var(--zs-font-size-xl); font-weight: 600;
57
- color: var(--zs-text);
58
- }
59
- .zs-description {
60
- margin: 4px 0 0; font-size: var(--zs-font-size); color: var(--zs-text-secondary);
61
- }
62
- .zs-body { padding: var(--zs-spacing-md); }
63
- .zs-section {
64
- margin-bottom: var(--zs-spacing-lg);
65
- }
66
- .zs-section-title {
67
- font-size: var(--zs-font-size-lg); font-weight: 600;
68
- margin: 0 0 var(--zs-spacing-sm) 0; color: var(--zs-text);
69
- padding-bottom: var(--zs-spacing-xs);
70
- border-bottom: 2px solid var(--zs-primary-light);
71
- }
72
- .zs-section-description {
73
- font-size: var(--zs-font-size-sm); color: var(--zs-text-secondary);
74
- margin: 0 0 var(--zs-spacing-sm) 0;
75
- }
76
- .zs-section-grid {
77
- display: grid;
78
- gap: var(--zs-spacing-md);
79
- }
80
- .zs-actions {
81
- display: flex; gap: var(--zs-spacing-sm);
82
- padding: var(--zs-spacing-md);
83
- border-top: 1px solid var(--zs-border);
84
- justify-content: flex-end;
85
- }
86
- .zs-btn {
87
- padding: 8px 20px; border-radius: var(--zs-radius);
88
- font-family: var(--zs-font-family); font-size: var(--zs-font-size);
89
- font-weight: 500; cursor: pointer; border: 1px solid transparent;
90
- transition: all var(--zs-transition);
91
- }
92
- .zs-btn--primary {
93
- background: var(--zs-primary); color: white; border-color: var(--zs-primary);
94
- }
95
- .zs-btn--primary:hover { background: var(--zs-primary-hover); }
96
- .zs-btn--secondary {
97
- background: var(--zs-bg); color: var(--zs-text); border-color: var(--zs-border);
98
- }
99
- .zs-btn--secondary:hover { background: var(--zs-bg-hover); }
100
- .zs-btn--danger {
101
- background: var(--zs-danger); color: white; border-color: var(--zs-danger);
102
- }
103
- .zs-btn--ghost {
104
- background: transparent; color: var(--zs-text-secondary); border-color: transparent;
105
- }
106
- .zs-btn--ghost:hover { color: var(--zs-text); background: var(--zs-bg-hover); }
107
- .zs-btn:disabled { opacity: 0.5; cursor: not-allowed; }
108
- .zs-field-hidden { display: none; }
109
-
110
- /* Tabs */
111
- .zs-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--zs-border); margin-bottom: var(--zs-spacing-md); }
112
- .zs-tab {
113
- padding: 8px 16px; cursor: pointer; border: none; background: none;
114
- font-family: var(--zs-font-family); font-size: var(--zs-font-size);
115
- color: var(--zs-text-secondary); border-bottom: 2px solid transparent;
116
- margin-bottom: -2px; transition: all var(--zs-transition);
117
- }
118
- .zs-tab:hover { color: var(--zs-text); }
119
- .zs-tab--active { color: var(--zs-primary); border-bottom-color: var(--zs-primary); font-weight: 500; }
120
-
121
- /* Wizard */
122
- .zs-wizard-steps {
123
- display: flex; align-items: center; gap: 8px;
124
- margin-bottom: var(--zs-spacing-lg); padding: 0 var(--zs-spacing-md);
125
- }
126
- .zs-wizard-step {
127
- display: flex; align-items: center; gap: 8px;
128
- }
129
- .zs-wizard-circle {
130
- width: 32px; height: 32px; border-radius: 50%;
131
- display: flex; align-items: center; justify-content: center;
132
- font-size: var(--zs-font-size-sm); font-weight: 600;
133
- background: var(--zs-bg-secondary); color: var(--zs-text-secondary);
134
- border: 2px solid var(--zs-border);
135
- }
136
- .zs-wizard-circle--active { background: var(--zs-primary); color: white; border-color: var(--zs-primary); }
137
- .zs-wizard-circle--done { background: var(--zs-success); color: white; border-color: var(--zs-success); }
138
- .zs-wizard-label { font-size: var(--zs-font-size-sm); color: var(--zs-text-secondary); }
139
- .zs-wizard-label--active { color: var(--zs-text); font-weight: 500; }
140
- .zs-wizard-line { flex: 1; height: 2px; background: var(--zs-border); }
141
- .zs-wizard-line--done { background: var(--zs-success); }
142
- .zs-wizard-nav { display: flex; justify-content: space-between; padding: var(--zs-spacing-md); }
46
+ static { this.styles = [studioTokens, fieldBaseStyles, css `
47
+ :host {
48
+ display: block;
49
+ font-family: var(--zs-font-family);
50
+ color: var(--zs-text);
51
+ }
52
+ .zs-renderer { background: var(--zs-bg); border-radius: var(--zs-radius-lg); }
53
+ .zs-header {
54
+ padding: var(--zs-spacing-md);
55
+ border-bottom: 1px solid var(--zs-border);
56
+ }
57
+ .zs-title {
58
+ margin: 0; font-size: var(--zs-font-size-xl); font-weight: 600;
59
+ color: var(--zs-text);
60
+ }
61
+ .zs-description {
62
+ margin: 4px 0 0; font-size: var(--zs-font-size); color: var(--zs-text-secondary);
63
+ }
64
+ .zs-body { padding: var(--zs-spacing-md); }
65
+ .zs-section {
66
+ margin-bottom: var(--zs-spacing-lg);
67
+ }
68
+ .zs-section-title {
69
+ font-size: var(--zs-font-size-lg); font-weight: 600;
70
+ margin: 0 0 var(--zs-spacing-sm) 0; color: var(--zs-text);
71
+ padding-bottom: var(--zs-spacing-xs);
72
+ border-bottom: 2px solid var(--zs-primary-light);
73
+ }
74
+ .zs-section-description {
75
+ font-size: var(--zs-font-size-sm); color: var(--zs-text-secondary);
76
+ margin: 0 0 var(--zs-spacing-sm) 0;
77
+ }
78
+ .zs-section-grid {
79
+ display: grid;
80
+ gap: var(--zs-spacing-md);
81
+ }
82
+ .zs-actions {
83
+ display: flex; gap: var(--zs-spacing-sm);
84
+ padding: var(--zs-spacing-md);
85
+ border-top: 1px solid var(--zs-border);
86
+ justify-content: flex-end;
87
+ }
88
+ .zs-btn {
89
+ padding: 8px 20px; border-radius: var(--zs-radius);
90
+ font-family: var(--zs-font-family); font-size: var(--zs-font-size);
91
+ font-weight: 500; cursor: pointer; border: 1px solid transparent;
92
+ transition: all var(--zs-transition);
93
+ }
94
+ .zs-btn--primary {
95
+ background: var(--zs-primary); color: white; border-color: var(--zs-primary);
96
+ }
97
+ .zs-btn--primary:hover { background: var(--zs-primary-hover); }
98
+ .zs-btn--secondary {
99
+ background: var(--zs-bg); color: var(--zs-text); border-color: var(--zs-border);
100
+ }
101
+ .zs-btn--secondary:hover { background: var(--zs-bg-hover); }
102
+ .zs-btn--danger {
103
+ background: var(--zs-danger); color: white; border-color: var(--zs-danger);
104
+ }
105
+ .zs-btn--ghost {
106
+ background: transparent; color: var(--zs-text-secondary); border-color: transparent;
107
+ }
108
+ .zs-btn--ghost:hover { color: var(--zs-text); background: var(--zs-bg-hover); }
109
+ .zs-btn:disabled { opacity: 0.5; cursor: not-allowed; }
110
+ .zs-field-hidden { display: none; }
111
+
112
+ /* Tabs */
113
+ .zs-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--zs-border); margin-bottom: var(--zs-spacing-md); }
114
+ .zs-tab {
115
+ padding: 8px 16px; cursor: pointer; border: none; background: none;
116
+ font-family: var(--zs-font-family); font-size: var(--zs-font-size);
117
+ color: var(--zs-text-secondary); border-bottom: 2px solid transparent;
118
+ margin-bottom: -2px; transition: all var(--zs-transition);
119
+ }
120
+ .zs-tab:hover { color: var(--zs-text); }
121
+ .zs-tab--active { color: var(--zs-primary); border-bottom-color: var(--zs-primary); font-weight: 500; }
122
+
123
+ /* Wizard */
124
+ .zs-wizard-steps {
125
+ display: flex; align-items: center; gap: 8px;
126
+ margin-bottom: var(--zs-spacing-lg); padding: 0 var(--zs-spacing-md);
127
+ }
128
+ .zs-wizard-step {
129
+ display: flex; align-items: center; gap: 8px;
130
+ }
131
+ .zs-wizard-circle {
132
+ width: 32px; height: 32px; border-radius: 50%;
133
+ display: flex; align-items: center; justify-content: center;
134
+ font-size: var(--zs-font-size-sm); font-weight: 600;
135
+ background: var(--zs-bg-secondary); color: var(--zs-text-secondary);
136
+ border: 2px solid var(--zs-border);
137
+ }
138
+ .zs-wizard-circle--active { background: var(--zs-primary); color: white; border-color: var(--zs-primary); }
139
+ .zs-wizard-circle--done { background: var(--zs-success); color: white; border-color: var(--zs-success); }
140
+ .zs-wizard-label { font-size: var(--zs-font-size-sm); color: var(--zs-text-secondary); }
141
+ .zs-wizard-label--active { color: var(--zs-text); font-weight: 500; }
142
+ .zs-wizard-line { flex: 1; height: 2px; background: var(--zs-border); }
143
+ .zs-wizard-line--done { background: var(--zs-success); }
144
+ .zs-wizard-nav { display: flex; justify-content: space-between; padding: var(--zs-spacing-md); }
143
145
  `]; }
144
146
  // ─── Lifecycle ───────────────────────────────────────────────
145
147
  connectedCallback() {
@@ -273,48 +275,48 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
273
275
  return html `<div class="zs-renderer" style="padding:24px;color:var(--zs-text-muted)">No schema loaded</div>`;
274
276
  }
275
277
  const layoutType = this.schema.layout.type;
276
- return html `
277
- <div class="zs-renderer">
278
- ${this.schema.title ? html `
279
- <div class="zs-header">
280
- <h2 class="zs-title">${this.schema.title}</h2>
281
- ${this.schema.description ? html `<p class="zs-description">${this.schema.description}</p>` : ''}
282
- </div>
283
- ` : ''}
284
-
278
+ return html `
279
+ <div class="zs-renderer">
280
+ ${this.schema.title ? html `
281
+ <div class="zs-header">
282
+ <h2 class="zs-title">${this.schema.title}</h2>
283
+ ${this.schema.description ? html `<p class="zs-description">${this.schema.description}</p>` : ''}
284
+ </div>
285
+ ` : ''}
286
+
285
287
  ${layoutType === 'tabs' ? this.renderTabs() :
286
288
  layoutType === 'wizard' ? this.renderWizard() :
287
- this.renderSections()}
288
-
289
- ${this.renderActions('bottom')}
290
- </div>
289
+ this.renderSections()}
290
+
291
+ ${this.renderActions('bottom')}
292
+ </div>
291
293
  `;
292
294
  }
293
295
  renderSections() {
294
296
  if (!this.schema || !this.model)
295
297
  return nothing;
296
- return html `
297
- <div class="zs-body">
298
- ${this.schema.sections.map(section => this.renderSection(section))}
299
- </div>
298
+ return html `
299
+ <div class="zs-body">
300
+ ${this.schema.sections.map(section => this.renderSection(section))}
301
+ </div>
300
302
  `;
301
303
  }
302
304
  renderTabs() {
303
305
  if (!this.schema || !this.model)
304
306
  return nothing;
305
307
  const sections = this.schema.sections;
306
- return html `
307
- <div class="zs-tabs">
308
- ${sections.map((s, i) => html `
309
- <button
310
- class="zs-tab ${i === this.activeSection ? 'zs-tab--active' : ''}"
311
- @click="${() => { this.activeSection = i; }}"
312
- >${s.title ?? `Tab ${i + 1}`}</button>
313
- `)}
314
- </div>
315
- <div class="zs-body">
316
- ${this.renderSection(sections[this.activeSection])}
317
- </div>
308
+ return html `
309
+ <div class="zs-tabs">
310
+ ${sections.map((s, i) => html `
311
+ <button
312
+ class="zs-tab ${i === this.activeSection ? 'zs-tab--active' : ''}"
313
+ @click="${() => { this.activeSection = i; }}"
314
+ >${s.title ?? `Tab ${i + 1}`}</button>
315
+ `)}
316
+ </div>
317
+ <div class="zs-body">
318
+ ${this.renderSection(sections[this.activeSection])}
319
+ </div>
318
320
  `;
319
321
  }
320
322
  renderWizard() {
@@ -322,31 +324,31 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
322
324
  return nothing;
323
325
  const sections = this.schema.sections;
324
326
  const total = sections.length;
325
- return html `
326
- <div class="zs-wizard-steps">
327
- ${sections.map((s, i) => html `
328
- ${i > 0 ? html `<div class="zs-wizard-line ${i <= this.activeSection ? 'zs-wizard-line--done' : ''}"></div>` : ''}
329
- <div class="zs-wizard-step">
330
- <div class="zs-wizard-circle ${i === this.activeSection ? 'zs-wizard-circle--active' : i < this.activeSection ? 'zs-wizard-circle--done' : ''}">
331
- ${i < this.activeSection ? '✓' : i + 1}
332
- </div>
333
- <span class="zs-wizard-label ${i === this.activeSection ? 'zs-wizard-label--active' : ''}">${s.title ?? `Paso ${i + 1}`}</span>
334
- </div>
335
- `)}
336
- </div>
337
- <div class="zs-body">
338
- ${this.renderSection(sections[this.activeSection])}
339
- </div>
340
- <div class="zs-wizard-nav">
341
- <button
342
- class="zs-btn zs-btn--secondary"
343
- ?disabled="${this.activeSection === 0}"
344
- @click="${() => { this.activeSection = Math.max(0, this.activeSection - 1); }}"
345
- >Anterior</button>
327
+ return html `
328
+ <div class="zs-wizard-steps">
329
+ ${sections.map((s, i) => html `
330
+ ${i > 0 ? html `<div class="zs-wizard-line ${i <= this.activeSection ? 'zs-wizard-line--done' : ''}"></div>` : ''}
331
+ <div class="zs-wizard-step">
332
+ <div class="zs-wizard-circle ${i === this.activeSection ? 'zs-wizard-circle--active' : i < this.activeSection ? 'zs-wizard-circle--done' : ''}">
333
+ ${i < this.activeSection ? '✓' : i + 1}
334
+ </div>
335
+ <span class="zs-wizard-label ${i === this.activeSection ? 'zs-wizard-label--active' : ''}">${s.title ?? `Paso ${i + 1}`}</span>
336
+ </div>
337
+ `)}
338
+ </div>
339
+ <div class="zs-body">
340
+ ${this.renderSection(sections[this.activeSection])}
341
+ </div>
342
+ <div class="zs-wizard-nav">
343
+ <button
344
+ class="zs-btn zs-btn--secondary"
345
+ ?disabled="${this.activeSection === 0}"
346
+ @click="${() => { this.activeSection = Math.max(0, this.activeSection - 1); }}"
347
+ >Anterior</button>
346
348
  ${this.activeSection < total - 1
347
349
  ? html `<button class="zs-btn zs-btn--primary" @click="${() => { this.activeSection = Math.min(total - 1, this.activeSection + 1); }}">Siguiente</button>`
348
- : html `<button class="zs-btn zs-btn--primary" @click="${() => this.handleAction('__wizard_finish__')}">Finalizar</button>`}
349
- </div>
350
+ : html `<button class="zs-btn zs-btn--primary" @click="${() => this.handleAction('__wizard_finish__')}">Finalizar</button>`}
351
+ </div>
350
352
  `;
351
353
  }
352
354
  renderSection(section) {
@@ -361,14 +363,14 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
361
363
  }
362
364
  const columns = section.columns ?? this.schema?.layout.columns ?? 1;
363
365
  const gap = this.schema?.layout.gap ?? 16;
364
- return html `
365
- <div class="zs-section">
366
- ${section.title ? html `<h3 class="zs-section-title">${section.title}</h3>` : ''}
367
- ${section.description ? html `<p class="zs-section-description">${section.description}</p>` : ''}
368
- <div class="zs-section-grid" style="grid-template-columns: repeat(${columns}, 1fr); gap: ${gap}px;">
369
- ${section.fields.map(field => this.renderField(field))}
370
- </div>
371
- </div>
366
+ return html `
367
+ <div class="zs-section">
368
+ ${section.title ? html `<h3 class="zs-section-title">${section.title}</h3>` : ''}
369
+ ${section.description ? html `<p class="zs-section-description">${section.description}</p>` : ''}
370
+ <div class="zs-section-grid" style="grid-template-columns: repeat(${columns}, 1fr); gap: ${gap}px;">
371
+ ${section.fields.map(field => this.renderField(field))}
372
+ </div>
373
+ </div>
372
374
  `;
373
375
  }
374
376
  renderField(field) {
@@ -403,10 +405,10 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
403
405
  const gridStyle = fullWidth ? 'grid-column: 1 / -1' : colSpan > 1 ? `grid-column: span ${colSpan}` : '';
404
406
  // Render based on tag name
405
407
  const tag = getFieldTag(field.type);
406
- return html `
407
- <div style="${gridStyle}" @field-change="${this.handleFieldChange}">
408
- ${this.renderFieldByTag(tag, field, value, errors, disabled, readOnly, required, mergedProps)}
409
- </div>
408
+ return html `
409
+ <div style="${gridStyle}" @field-change="${this.handleFieldChange}">
410
+ ${this.renderFieldByTag(tag, field, value, errors, disabled, readOnly, required, mergedProps)}
411
+ </div>
410
412
  `;
411
413
  }
412
414
  renderFieldByTag(tag, field, value, errors, disabled, readOnly, required, props) {
@@ -419,165 +421,178 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
419
421
  };
420
422
  switch (tag) {
421
423
  case 'zs-field-text':
422
- return html `<zs-field-text
423
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
424
- .value="${value != null ? String(value) : ''}"
425
- .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
426
- .inputType="${props.inputType ?? 'text'}"
427
- .multiline="${field.type === 'textarea'}"
428
- .errors="${baseAttrs.errors}"
429
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
424
+ return html `<zs-field-text
425
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
426
+ .value="${value != null ? String(value) : ''}"
427
+ .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
428
+ .inputType="${props.inputType ?? 'text'}"
429
+ .multiline="${field.type === 'textarea'}"
430
+ .errors="${baseAttrs.errors}"
431
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
430
432
  ></zs-field-text>`;
431
433
  case 'zs-field-number':
432
- return html `<zs-field-number
433
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
434
- .value="${value != null ? Number(value) : null}"
435
- .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
436
- .isCurrency="${!!props.isCurrency}" .isPercentage="${!!props.isPercentage}"
437
- .currencySymbol="${props.currencySymbol ?? '$'}"
438
- .mode="${props.mode ?? 'input'}"
439
- .min="${props.min ?? 0}" .max="${props.max ?? 100}"
440
- .step="${props.step ?? 1}"
441
- .maxRating="${props.maxRating ?? 5}"
442
- .errors="${baseAttrs.errors}"
443
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
434
+ return html `<zs-field-number
435
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
436
+ .value="${value != null ? Number(value) : null}"
437
+ .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
438
+ .isCurrency="${!!props.isCurrency}" .isPercentage="${!!props.isPercentage}"
439
+ .currencySymbol="${props.currencySymbol ?? '$'}"
440
+ .mode="${props.mode ?? 'input'}"
441
+ .min="${props.min ?? 0}" .max="${props.max ?? 100}"
442
+ .step="${props.step ?? 1}"
443
+ .maxRating="${props.maxRating ?? 5}"
444
+ .errors="${baseAttrs.errors}"
445
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
444
446
  ></zs-field-number>`;
445
447
  case 'zs-field-select':
446
- return html `<zs-field-select
447
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
448
- .value="${value ?? ''}"
449
- .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
450
- .options="${props.options ?? []}"
451
- .multiple="${!!props.multiple}"
452
- .mode="${props.mode ?? 'select'}"
453
- .errors="${baseAttrs.errors}"
454
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
448
+ return html `<zs-field-select
449
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
450
+ .value="${value ?? ''}"
451
+ .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
452
+ .options="${props.options ?? []}"
453
+ .multiple="${!!props.multiple}"
454
+ .mode="${props.mode ?? 'select'}"
455
+ .errors="${baseAttrs.errors}"
456
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
455
457
  ></zs-field-select>`;
456
458
  case 'zs-field-date':
457
- return html `<zs-field-date
458
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
459
- .value="${value != null ? String(value) : ''}"
460
- .helpText="${baseAttrs.helpText}"
461
- .mode="${props.mode ?? 'date'}"
462
- .min="${props.min ?? ''}" .max="${props.max ?? ''}"
463
- .errors="${baseAttrs.errors}"
464
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
459
+ return html `<zs-field-date
460
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
461
+ .value="${value != null ? String(value) : ''}"
462
+ .helpText="${baseAttrs.helpText}"
463
+ .mode="${props.mode ?? 'date'}"
464
+ .min="${props.min ?? ''}" .max="${props.max ?? ''}"
465
+ .errors="${baseAttrs.errors}"
466
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
465
467
  ></zs-field-date>`;
466
468
  case 'zs-field-checkbox':
467
- return html `<zs-field-checkbox
468
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
469
- .value="${value ?? false}"
470
- .helpText="${baseAttrs.helpText}"
471
- .mode="${props.mode ?? 'checkbox'}"
472
- .options="${props.options ?? []}"
473
- .horizontal="${!!props.horizontal}"
474
- .errors="${baseAttrs.errors}"
475
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
469
+ return html `<zs-field-checkbox
470
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
471
+ .value="${value ?? false}"
472
+ .helpText="${baseAttrs.helpText}"
473
+ .mode="${props.mode ?? 'checkbox'}"
474
+ .options="${props.options ?? []}"
475
+ .horizontal="${!!props.horizontal}"
476
+ .errors="${baseAttrs.errors}"
477
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
476
478
  ></zs-field-checkbox>`;
477
479
  case 'zs-field-switch':
478
- return html `<zs-field-switch
479
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
480
- .value="${!!value}"
481
- .helpText="${baseAttrs.helpText}"
482
- .errors="${baseAttrs.errors}"
483
- ?disabled="${baseAttrs.disabled}"
480
+ return html `<zs-field-switch
481
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
482
+ .value="${!!value}"
483
+ .helpText="${baseAttrs.helpText}"
484
+ .errors="${baseAttrs.errors}"
485
+ ?disabled="${baseAttrs.disabled}"
484
486
  ></zs-field-switch>`;
485
487
  case 'zs-field-file':
486
- return html `<zs-field-file
487
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
488
- .helpText="${baseAttrs.helpText}"
489
- .accept="${props.accept ?? ''}"
490
- .multiple="${!!props.multiple}"
491
- .errors="${baseAttrs.errors}"
492
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
488
+ return html `<zs-field-file
489
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
490
+ .helpText="${baseAttrs.helpText}"
491
+ .accept="${props.accept ?? ''}"
492
+ .multiple="${!!props.multiple}"
493
+ .errors="${baseAttrs.errors}"
494
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
493
495
  ></zs-field-file>`;
494
496
  case 'zs-field-lookup':
495
- return html `<zs-field-lookup
496
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
497
- .value="${value ?? ''}" .displayValue="${props.displayValue ?? ''}"
498
- .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
499
- .options="${props.lookupOptions ?? []}"
500
- .minChars="${props.minChars ?? 2}"
501
- .debounceMs="${props.debounceMs ?? 300}"
502
- .errors="${baseAttrs.errors}"
503
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
497
+ return html `<zs-field-lookup
498
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
499
+ .value="${value ?? ''}" .displayValue="${props.displayValue ?? ''}"
500
+ .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
501
+ .options="${props.lookupOptions ?? []}"
502
+ .minChars="${props.minChars ?? 2}"
503
+ .debounceMs="${props.debounceMs ?? 300}"
504
+ .errors="${baseAttrs.errors}"
505
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
504
506
  ></zs-field-lookup>`;
505
507
  case 'zs-field-separator':
506
- return html `<zs-field-separator
507
- .variant="${props.variant ?? 'thin'}"
508
+ return html `<zs-field-separator
509
+ .variant="${props.variant ?? 'thin'}"
508
510
  ></zs-field-separator>`;
509
511
  case 'zs-field-heading':
510
- return html `<zs-field-heading
511
- .label="${baseAttrs.label}" .helpText="${baseAttrs.helpText}"
512
- .level="${props.level ?? 'h2'}"
512
+ return html `<zs-field-heading
513
+ .label="${baseAttrs.label}" .helpText="${baseAttrs.helpText}"
514
+ .level="${props.level ?? 'h2'}"
513
515
  ></zs-field-heading>`;
514
516
  case 'zs-field-html':
515
- return html `<zs-field-html
516
- .content="${props.content ?? String(value ?? '')}"
517
+ return html `<zs-field-html
518
+ .content="${props.content ?? String(value ?? '')}"
517
519
  ></zs-field-html>`;
518
520
  case 'zs-field-signature':
519
- return html `<zs-field-signature
520
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
521
- .value="${value != null ? String(value) : ''}"
522
- .helpText="${baseAttrs.helpText}"
523
- .penWidth="${props.penWidth ?? 2}"
524
- .penColor="${props.penColor ?? '#000000'}"
525
- .errors="${baseAttrs.errors}"
526
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
521
+ return html `<zs-field-signature
522
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
523
+ .value="${value != null ? String(value) : ''}"
524
+ .helpText="${baseAttrs.helpText}"
525
+ .penWidth="${props.penWidth ?? 2}"
526
+ .penColor="${props.penColor ?? '#000000'}"
527
+ .errors="${baseAttrs.errors}"
528
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
527
529
  ></zs-field-signature>`;
528
530
  case 'zs-field-address':
529
- return html `<zs-field-address
530
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
531
- .value="${value ?? {}}" .helpText="${baseAttrs.helpText}"
532
- .errors="${baseAttrs.errors}"
533
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
531
+ return html `<zs-field-address
532
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
533
+ .value="${value ?? {}}" .helpText="${baseAttrs.helpText}"
534
+ .errors="${baseAttrs.errors}"
535
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}" ?readOnly="${baseAttrs.readOnly}"
534
536
  ></zs-field-address>`;
535
537
  case 'zs-field-chart':
536
- return html `<zs-field-chart
537
- .label="${baseAttrs.label}"
538
- .chartType="${props.chartType ?? 'bar'}"
539
- .data="${props.chartData ?? []}"
540
- .width="${props.width ?? 400}"
541
- .height="${props.height ?? 250}"
538
+ return html `<zs-field-chart
539
+ .label="${baseAttrs.label}"
540
+ .chartType="${props.chartType ?? 'bar'}"
541
+ .data="${props.chartData ?? []}"
542
+ .width="${props.width ?? 400}"
543
+ .height="${props.height ?? 250}"
542
544
  ></zs-field-chart>`;
543
545
  case 'zs-field-media':
544
- return html `<zs-field-media
545
- .label="${baseAttrs.label}"
546
- .src="${value != null ? String(value) : props.src ?? ''}"
547
- .mediaType="${props.mediaType ?? 'image'}"
548
- .alt="${props.alt ?? ''}"
546
+ return html `<zs-field-media
547
+ .label="${baseAttrs.label}"
548
+ .src="${value != null ? String(value) : props.src ?? ''}"
549
+ .mediaType="${props.mediaType ?? 'image'}"
550
+ .alt="${props.alt ?? ''}"
549
551
  ></zs-field-media>`;
550
552
  case 'zs-field-treeview':
551
- return html `<zs-field-treeview
552
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
553
- .value="${Array.isArray(value) ? value : (value ? [value] : [])}"
554
- .helpText="${baseAttrs.helpText}"
555
- .nodes="${props.nodes ?? []}"
556
- .multiSelect="${!!props.multiSelect}"
557
- .showCheckboxes="${!!props.showCheckboxes}"
558
- .searchable="${!!props.searchable}"
559
- .errors="${baseAttrs.errors}"
560
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
553
+ return html `<zs-field-treeview
554
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
555
+ .value="${Array.isArray(value) ? value : (value ? [value] : [])}"
556
+ .helpText="${baseAttrs.helpText}"
557
+ .nodes="${props.nodes ?? []}"
558
+ .multiSelect="${!!props.multiSelect}"
559
+ .showCheckboxes="${!!props.showCheckboxes}"
560
+ .searchable="${!!props.searchable}"
561
+ .errors="${baseAttrs.errors}"
562
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
561
563
  ></zs-field-treeview>`;
562
564
  case 'zs-field-chips':
563
- return html `<zs-field-chips
564
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
565
- .value="${Array.isArray(value) ? value : []}"
566
- .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
567
- .options="${props.options ?? []}"
568
- .allowCustom="${props.allowCustom !== false}"
569
- .maxChips="${props.maxChips ?? 0}"
570
- .colorMode="${props.colorMode ?? 'default'}"
571
- .errors="${baseAttrs.errors}"
572
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
565
+ return html `<zs-field-chips
566
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
567
+ .value="${Array.isArray(value) ? value : []}"
568
+ .placeholder="${baseAttrs.placeholder}" .helpText="${baseAttrs.helpText}"
569
+ .options="${props.options ?? []}"
570
+ .allowCustom="${props.allowCustom !== false}"
571
+ .maxChips="${props.maxChips ?? 0}"
572
+ .colorMode="${props.colorMode ?? 'default'}"
573
+ .errors="${baseAttrs.errors}"
574
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
573
575
  ></zs-field-chips>`;
576
+ case 'zs-field-datagrid':
577
+ return html `<zs-field-datagrid
578
+ .config="${field}"
579
+ .rows="${Array.isArray(value) ? value : props.rows ?? []}"
580
+ .theme="${this.themeMode}"
581
+ ></zs-field-datagrid>`;
582
+ case 'zs-field-report':
583
+ return html `<zs-field-report
584
+ .config="${field}"
585
+ .template="${props.template ?? null}"
586
+ .data="${value ?? props.data ?? null}"
587
+ .theme="${this.themeMode}"
588
+ ></zs-field-report>`;
574
589
  default:
575
- return html `<zs-field-text
576
- .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
577
- .value="${value != null ? String(value) : ''}"
578
- .placeholder="${baseAttrs.placeholder}"
579
- .errors="${baseAttrs.errors}"
580
- ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
590
+ return html `<zs-field-text
591
+ .fieldId="${baseAttrs.fieldId}" .label="${baseAttrs.label}"
592
+ .value="${value != null ? String(value) : ''}"
593
+ .placeholder="${baseAttrs.placeholder}"
594
+ .errors="${baseAttrs.errors}"
595
+ ?required="${baseAttrs.required}" ?disabled="${baseAttrs.disabled}"
581
596
  ></zs-field-text>`;
582
597
  }
583
598
  }
@@ -588,20 +603,20 @@ let ZenttoStudioRenderer = class ZenttoStudioRenderer extends LitElement {
588
603
  if (actions.length === 0)
589
604
  return nothing;
590
605
  const ctx = this.buildContext();
591
- return html `
592
- <div class="zs-actions">
606
+ return html `
607
+ <div class="zs-actions">
593
608
  ${actions.map(action => {
594
609
  const enabled = isActionEnabled(action, ctx);
595
610
  const variant = action.variant ?? 'secondary';
596
- return html `
597
- <button
598
- class="zs-btn zs-btn--${variant}"
599
- ?disabled="${!enabled}"
600
- @click="${() => this.handleAction(action.id)}"
601
- >${action.label}</button>
611
+ return html `
612
+ <button
613
+ class="zs-btn zs-btn--${variant}"
614
+ ?disabled="${!enabled}"
615
+ @click="${() => this.handleAction(action.id)}"
616
+ >${action.label}</button>
602
617
  `;
603
- })}
604
- </div>
618
+ })}
619
+ </div>
605
620
  `;
606
621
  }
607
622
  };