fix preview inputs and markup preview

This commit is contained in:
2026-03-27 21:34:51 -07:00
parent 66f1bca046
commit 63bdc70456
13 changed files with 501 additions and 316 deletions

View File

@@ -0,0 +1,26 @@
import { DATA_TYPES } from './constants.js';
export function getDefaultWidgetValue(spec) {
const [type, opts] = Array.isArray(spec) ? spec : [spec, {}];
if (DATA_TYPES.has(type)) return undefined;
if (type === 'BUTTON') return undefined;
if (Array.isArray(type)) {
if (typeof opts?.default === 'string' && type.includes(opts.default)) {
return opts.default;
}
return type[0];
}
return opts?.default ?? '';
}
export function buildDefaultWidgetValues(definition) {
const widgetValues = {};
const required = definition?.input?.required || {};
for (const [name, spec] of Object.entries(required)) {
const value = getDefaultWidgetValue(spec);
if (value !== undefined) {
widgetValues[name] = value;
}
}
return widgetValues;
}