feat(custom-widgets): complete Custom JSX v2 (#6390)

This commit is contained in:
Thomas authored and GitHub committed 2026-07-22 20:47:19 +02:00
1 parent 60cbd7bb7a
commit 6aceb2fd1f
450 files changed
+39817 -20588

No files matched your search

@@ -0,0 +1,28 @@
import { getCustomWidgetOptionValueIssue } from "./options-schema";
import type { CustomWidgetOption, CustomWidgetOptions } from "./options-schema";
export interface CustomWidgetOptionIssue {
path: string;
message: string;
}
export function getCustomWidgetDefaultOptions(
options: Record<string, Pick<CustomWidgetOption, "default">>,
): Record<string, unknown> {
return Object.fromEntries(Object.entries(options).map(([name, option]) => [name, option.default]));
}
export function validateCustomWidgetOptions(
options: CustomWidgetOptions,
value: Record<string, unknown>,
): CustomWidgetOptionIssue[] {
const issues: CustomWidgetOptionIssue[] = [];
for (const [name, option] of Object.entries(options)) {
const issue = getCustomWidgetOptionValueIssue(option, value[name]);
if (issue) issues.push({ path: `configuration.${name}`, message: issue });
}
for (const name of Object.keys(value)) {
if (!Object.hasOwn(options, name)) issues.push({ path: `configuration.${name}`, message: "Unknown option" });
}
return issues;
}