UNPKG

@tsed/schema-formio

Version:

Transform Ts.ED Schema & JsonSchema to a valid Formio schema

18 lines (17 loc) 672 B
import { nameOf, StoreSet, useDecorators } from "@tsed/core"; import { Name } from "@tsed/schema"; import { kebabCase } from "change-case"; import { FormsContainer } from "../registries/FormsContainer.js"; import { Label } from "./label.js"; /** * Expose the model as Formio Form. * @param form */ export function Form(form = {}) { return useDecorators((target) => { const name = form.name || nameOf(target); const machineName = kebabCase(name); FormsContainer.set(name, target); FormsContainer.set(machineName, target); }, form.name && Name(form.name), form.label && Label(form.label), form && StoreSet("formio:form", form)); }