23 lines
1.0 KiB
TypeScript
23 lines
1.0 KiB
TypeScript
'use client'
|
|
import { lazy, Suspense } from 'react'
|
|
|
|
import type { BuilderFormProps } from './BuilderForm.js'
|
|
|
|
/**
|
|
* <BuilderForm> loaded only on a page that renders a form (1.18.0). RenderForm uses this: the catch-all route can
|
|
* render any block, so a static import put the form engine (fields, steps, validation, the Turnstile widget) into
|
|
* the JavaScript of every page. The server still renders the whole form (the HTML is complete without JavaScript,
|
|
* search engines and the first paint see it); the browser fetches the code while it hydrates the rest of the page.
|
|
* It is `BuilderForm` in `@intecion/ipal-kit/client` (same props). The eager component, in every page's bundle:
|
|
* `@intecion/ipal-kit/client/eager` → `<RenderForm Form={BuilderForm}>` (docs/forms.md).
|
|
*/
|
|
const Impl = lazy(() => import('./BuilderForm.js').then((m) => ({ default: m.BuilderForm })))
|
|
|
|
export function LazyBuilderForm(props: BuilderFormProps) {
|
|
return (
|
|
<Suspense fallback={null}>
|
|
<Impl {...props} />
|
|
</Suspense>
|
|
)
|
|
}
|