Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function FieldsBuilder({ form, fields }: FieldsBuilderProps) {
const cms = useCMS()
return (
{fields.map((field: Field) => {
if (field.component === null) return null
const plugin = cms.plugins
.findOrCreateMap('field')
.find(field.component as string)
let type: string | undefined
if (plugin && plugin.type) {
type = plugin.type
}
const parse = getProp('parse', field, plugin)
const validate = getProp('validate', field, plugin)
export function useCMS(): TinaCMS {
return useBaseCMS() as TinaCMS
}
export function useGlobalForm(
options: FormOptions,
watch: Partial = {}
): [FormShape, Form | undefined] {
const [values, form] = useForm(options, watch)
const GlobalForm = useMemo(() => {
if (!form) return
return new GlobalFormPlugin(form)
}, [form])
usePlugins(GlobalForm)
return [values, form]
}
export function useGlobalForm(
options: FormOptions,
watch: Partial = {}
): [FormShape, Form | undefined] {
const [values, form] = useForm(options, watch)
const GlobalForm = useMemo(() => {
if (!form) return
return new GlobalFormPlugin(form)
}, [form])
usePlugins(GlobalForm)
return [values, form]
}