@formhaus/react 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cloud.d.ts +12 -7
- package/dist/cloud.js +1 -1
- package/dist/cloud.js.map +1 -1
- package/dist/index.d.ts +51 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Unmapped field types fall back to native HTML.
|
|
|
70
70
|
|
|
71
71
|
`FormRenderer` imports the built-in native fields, so they stay in your bundle even when you replace them. If you map every field type you use, import `HeadlessFormRenderer` instead. It takes the same props as `FormRenderer`. It does not import the built-in fields, actions or step progress, so they stay out of your bundle.
|
|
72
72
|
|
|
73
|
-
`HeadlessFormRenderer` has no fallbacks. An unmapped field type renders an "Unsupported field type" placeholder. Pass `
|
|
73
|
+
`HeadlessFormRenderer` has no fallbacks. An unmapped field type renders an "Unsupported field type" placeholder. Pass `actionsComponent` and `progressComponent` too, or the form renders no buttons and no progress bar.
|
|
74
74
|
|
|
75
75
|
## Dynamic options
|
|
76
76
|
|
package/dist/cloud.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CloudSubmission } from '@formhaus/core/cloud';
|
|
2
|
+
import { PublishedForm, DraftStore, CloudSubmission } from '@formhaus/core/cloud';
|
|
3
3
|
export { CloudError, CloudSubmission } from '@formhaus/core/cloud';
|
|
4
4
|
import { ComponentType, ReactNode } from 'react';
|
|
5
5
|
import * as _formhaus_core from '@formhaus/core';
|
|
6
|
-
import { FormEngineOptions, FormDefinition, ValidatorFn, StepValidateFn, FieldType, FieldOption, FormAction, FormAnalyticsEvent } from '@formhaus/core';
|
|
6
|
+
import { FormEngineOptions, FormDefinition, SubmitFn, ValidatorFn, StepValidateFn, FieldType, FieldOption, FormAction, FormAnalyticsEvent } from '@formhaus/core';
|
|
7
7
|
|
|
8
8
|
type OptionsProvider = (values: Record<string, unknown>) => FieldOption[] | Promise<FieldOption[]>;
|
|
9
9
|
interface FieldComponentProps {
|
|
10
|
+
id?: string;
|
|
10
11
|
field: _formhaus_core.FormField;
|
|
11
12
|
value: unknown;
|
|
12
13
|
error?: string;
|
|
@@ -41,19 +42,20 @@ interface FormActionsProps {
|
|
|
41
42
|
onSkip?: () => void;
|
|
42
43
|
onPrimary?: () => void;
|
|
43
44
|
}
|
|
45
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
44
46
|
interface FormStepProgressProps {
|
|
45
47
|
current: number;
|
|
46
48
|
total: number;
|
|
47
49
|
stepTitle?: string;
|
|
48
50
|
stepDescription?: string;
|
|
51
|
+
headingLevel?: HeadingLevel;
|
|
49
52
|
}
|
|
50
53
|
interface FormRendererProps extends FormEngineOptions {
|
|
51
54
|
onError?: (error: unknown) => void;
|
|
52
55
|
definition: FormDefinition;
|
|
53
56
|
initialValues?: Record<string, unknown>;
|
|
54
|
-
onSubmit:
|
|
57
|
+
onSubmit: SubmitFn;
|
|
55
58
|
onCancel?: () => void;
|
|
56
|
-
onStepChange?: (stepId: string, direction: 'next' | 'back') => void;
|
|
57
59
|
onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
|
|
58
60
|
validators?: Record<string, ValidatorFn>;
|
|
59
61
|
onStepValidate?: StepValidateFn;
|
|
@@ -61,19 +63,22 @@ interface FormRendererProps extends FormEngineOptions {
|
|
|
61
63
|
loading?: boolean;
|
|
62
64
|
components?: FieldComponentMap;
|
|
63
65
|
optionsProviders?: Record<string, OptionsProvider>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
actionsComponent?: ComponentType<FormActionsProps>;
|
|
67
|
+
progressComponent?: ComponentType<FormStepProgressProps>;
|
|
68
|
+
headingLevel?: HeadingLevel;
|
|
66
69
|
onAnalyticsEvent?: (event: FormAnalyticsEvent) => void;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
interface FormhausFormProps extends Omit<FormRendererProps, 'definition' | 'onSubmit' | 'errors'> {
|
|
70
73
|
id: string;
|
|
71
74
|
apiBase?: string;
|
|
75
|
+
initialForm?: PublishedForm;
|
|
76
|
+
draftStore?: DraftStore;
|
|
72
77
|
onSuccess?: (submission: CloudSubmission) => void;
|
|
73
78
|
fallback?: ReactNode;
|
|
74
79
|
success?: ReactNode;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
declare function FormhausForm({ id, apiBase, onSuccess, onError, fallback, success, initialValues, ...rendererProps }: FormhausFormProps): react_jsx_runtime.JSX.Element;
|
|
82
|
+
declare function FormhausForm({ id, apiBase, initialForm, draftStore, onSuccess, onError, fallback, success, initialValues, onFieldChange, ...rendererProps }: FormhausFormProps): react_jsx_runtime.JSX.Element;
|
|
78
83
|
|
|
79
84
|
export { FormhausForm, type FormhausFormProps };
|
package/dist/cloud.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use client';import {FormRenderer}from'@formhaus/react';import {
|
|
1
|
+
'use client';import {FormRenderer}from'@formhaus/react';import {CloudError}from'@formhaus/core/cloud';export{CloudError}from'@formhaus/core/cloud';import {focusProblem,cloudStateFor,createCloudController}from'@formhaus/core/internal';import {useRef,useCallback,useEffect,createElement,useState}from'react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';var H={retry:"Try again",reload:"Reload page"};function k({notice:r,noticeRef:l,onAction:e}){return r?jsxs("div",{ref:l,tabIndex:-1,className:`fh-form__notice fh-form__notice--${r.tone}`,children:[jsx("p",{children:r.message}),r.details.length>0&&jsx("ul",{children:r.details.map(n=>jsx("li",{children:n},n))}),r.action&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--secondary",onClick:()=>e(r.action),children:H[r.action]})]}):null}function R({id:r,apiBase:l,initialForm:e,draftStore:n,extraBody:h,onSuccess:b,onError:y}){let[c,C]=useState(()=>cloudStateFor(e)),i=useRef(null),s=useRef({onSuccess:b,onError:y,extraBody:h,initialForm:e,draftStore:n});s.current={onSuccess:b,onError:y,extraBody:h,initialForm:e,draftStore:n},useEffect(()=>{let{initialForm:t,draftStore:f}=s.current;C(cloudStateFor(t));let u=createCloudController({id:r,apiBase:l,initialForm:t,draftStore:f,extraBody:()=>s.current.extraBody()},{onChange:C,onSuccess:d=>s.current.onSuccess?.(d),onError:d=>s.current.onError?.(d)});return i.current=u,u.start(),()=>u.dispose()},[r,l]);let _=useCallback((t,f)=>i.current.submit(t,f),[]),E=useCallback(()=>i.current.start(),[]),o=useCallback(()=>i.current.again(),[]),m=useCallback(t=>i.current?.saveDraft(t),[]);return {...c,submit:_,retry:E,again:o,saveDraft:m}}var Y={position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)"};function $(){}function z({id:r,apiBase:l,initialForm:e,draftStore:n,onSuccess:h,onError:b,fallback:y,success:c,initialValues:C,onFieldChange:i,...s}){let _=useRef(null),E=useCallback(()=>({_fh_hp:_.current?.value??""}),[]),o=R({id:r,apiBase:l,initialForm:e,draftStore:n,extraBody:E,onSuccess:h,onError:b}),m=useRef(null),t=useRef(null),f=useCallback(p=>{p==="reload"?window.location.reload():m.current?.querySelector("form")?.requestSubmit();},[]),{redirectUrl:u,successMessage:d,allowAnother:P}=o.settings;return useEffect(()=>{if(o.attempt===0)return;let p=requestAnimationFrame(()=>focusProblem(m.current,t.current));return ()=>cancelAnimationFrame(p)},[o.attempt]),useEffect(()=>{o.done&&u&&!c&&window.location.assign(u);},[o.done,u,c]),o.loadError?jsxs(Fragment,{children:[jsx("p",{role:"alert",className:"fh-form__error",children:o.loadError.message}),o.loadError instanceof CloudError&&o.loadError.retryable&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--secondary",onClick:o.retry,children:"Try again"})]}):o.definition?o.done?jsxs(Fragment,{children:[c??jsx("p",{role:"status",className:"fh-form__success",children:d??"Thank you. Your response was submitted."}),P&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--secondary",onClick:o.again,children:"Submit another response"})]}):jsxs("div",{ref:m,className:"fh-cloud",children:[jsx("input",{ref:_,name:"_fh_hp",tabIndex:-1,autoComplete:"off","aria-hidden":"true",style:Y,defaultValue:""}),jsx(k,{notice:o.notice,noticeRef:t,onAction:f}),createElement(FormRenderer,{...s,key:o.revision,definition:o.definition,initialValues:o.initialValues??C,errors:o.errors,onSubmit:o.submit,onError:$,onFieldChange:(p,L,N)=>{o.saveDraft(N),i?.(p,L,N);}})]}):jsx("div",{className:"fh-form","aria-busy":"true",children:y})}export{z as FormhausForm};//# sourceMappingURL=cloud.js.map
|
|
2
2
|
//# sourceMappingURL=cloud.js.map
|
package/dist/cloud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cloud/CloudNotice.tsx","../src/cloud/useCloudForm.ts","../src/cloud/FormhausForm.tsx"],"names":["LABELS","CloudNotice","notice","noticeRef","onAction","jsxs","jsx","detail","useCloudForm","id","apiBase","onSuccess","onError","state","setState","useState","initialCloudState","controller","useRef","callbacks","useEffect","current","createCloudController","submission","error","submit","useCallback","values","skippedSteps","handled","FormhausForm","fallback","success","initialValues","rendererProps","cloud","root","act","action","frame","focusProblem","Fragment","createElement","FormRenderer"],"mappings":"0SAGA,IAAMA,CAAAA,CAAS,CAAE,KAAA,CAAO,YAAa,MAAA,CAAQ,aAAc,EAEpD,SAASC,CAAAA,CAAY,CAAE,MAAA,CAAAC,CAAAA,CAAQ,SAAA,CAAAC,CAAAA,CAAW,QAAA,CAAAC,CAAS,EAIvD,CACD,OAAKF,CAAAA,CAEHG,IAAAA,CAAC,KAAA,CAAA,CAAI,GAAA,CAAKF,EAAW,QAAA,CAAU,EAAA,CAAI,SAAA,CAAW,CAAA,iCAAA,EAAoCD,CAAAA,CAAO,IAAI,GAC3F,QAAA,CAAA,CAAAI,GAAAA,CAAC,KAAG,QAAA,CAAAJ,CAAAA,CAAO,QAAQ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ud';\nimport type { Ref } from 'react';\n\nconst LABELS = { retry: 'Try again', reload: 'Reload page' };\n\nexport function CloudNotice({ notice, noticeRef, onAction }: {\n notice: Notice | null;\n noticeRef: Ref<HTMLDivElement>;\n onAction: (action: Exclude<CloudAction, null>) => void;\n}) {\n if (!notice) return null;\n return (\n <div ref={noticeRef} tabIndex={-1} className={`fh-form__notice fh-form__notice--${notice.tone}`}>\n <p>{notice.message}</p>\n {notice.details.length > 0 && <ul>{notice.details.map((detail) => <li key={detail}>{detail}</li>)}</ul>}\n {notice.action && (\n <button type=\"button\" className=\"fh-form-actions__button fh-form-actions__button--secondary\" onClick={() => onAction(notice.action!)}>\n {LABELS[notice.action]}\n </button>\n )}\n </div>\n );\n}\n","import { createCloudController, initialCloudState, type CloudSubmission } from '@formhaus/core/cloud';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\ninterface CloudFormOptions {\n id: string;\n apiBase?: string;\n onSuccess?: (submission: CloudSubmission) => void;\n onError?: (error: unknown) => void;\n}\n\nexport function useCloudForm({ id, apiBase, onSuccess, onError }: CloudFormOptions) {\n const [state, setState] = useState(initialCloudState);\n const controller = useRef<ReturnType<typeof createCloudController> | null>(null);\n const callbacks = useRef({ onSuccess, onError });\n callbacks.current = { onSuccess, onError };\n\n useEffect(() => {\n setState(initialCloudState);\n const current = createCloudController({ id, apiBase }, {\n onChange: setState,\n onSuccess: (submission) => callbacks.current.onSuccess?.(submission),\n onError: (error) => callbacks.current.onError?.(error),\n });\n controller.current = current;\n current.start();\n return () => current.dispose();\n }, [id, apiBase]);\n\n const submit = useCallback((values: Record<string, unknown>, skippedSteps?: string[]) => (\n controller.current!.submit(values, skippedSteps)\n ), []);\n\n return { ...state, submit };\n}\n","import { FormRenderer } from '@formhaus/react';\nimport { focusProblem, type CloudAction } from '@formhaus/core/cloud';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { CloudNotice } from './CloudNotice';\nimport type { FormhausFormProps } from './types';\nimport { useCloudForm } from './useCloudForm';\n\nfunction handled() {}\n\nexport function FormhausForm({ id, apiBase, onSuccess, onError, fallback, success, initialValues, ...rendererProps }: FormhausFormProps) {\n const cloud = useCloudForm({ id, apiBase, onSuccess, onError });\n const root = useRef<HTMLDivElement>(null);\n const notice = useRef<HTMLDivElement>(null);\n const act = useCallback((action: Exclude<CloudAction, null>) => {\n if (action === 'reload') window.location.reload();\n else root.current?.querySelector('form')?.requestSubmit();\n }, []);\n\n useEffect(() => {\n if (cloud.attempt === 0) return;\n const frame = requestAnimationFrame(() => focusProblem(root.current, notice.current));\n return () => cancelAnimationFrame(frame);\n }, [cloud.attempt]);\n\n if (cloud.loadError) return <p role=\"alert\" className=\"fh-form__error\">{cloud.loadError.message}</p>;\n if (!cloud.definition) return <div className=\"fh-form\" aria-busy=\"true\">{fallback}</div>;\n if (cloud.done) return <>{success ?? <p role=\"status\" className=\"fh-form__success\">Thank you. Your response was submitted.</p>}</>;\n return (\n <div ref={root} className=\"fh-cloud\">\n <CloudNotice notice={cloud.notice} noticeRef={notice} onAction={act} />\n <FormRenderer\n {...rendererProps}\n key={cloud.revision}\n definition={cloud.definition}\n initialValues={cloud.initialValues ?? initialValues}\n errors={cloud.errors}\n onSubmit={cloud.submit}\n onError={handled}\n />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/cloud/CloudNotice.tsx","../src/cloud/useCloudForm.ts","../src/cloud/FormhausForm.tsx"],"names":["LABELS","CloudNotice","notice","noticeRef","onAction","jsxs","jsx","detail","useCloudForm","id","apiBase","initialForm","draftStore","extraBody","onSuccess","onError","state","setState","useState","cloudStateFor","controller","useRef","callbacks","useEffect","form","store","current","createCloudController","submission","error","submit","useCallback","values","skippedSteps","retry","again","saveDraft","HIDDEN","handled","FormhausForm","fallback","success","initialValues","onFieldChange","rendererProps","trap","cloud","root","act","action","redirectUrl","successMessage","allowAnother","frame","focusProblem","Fragment","CloudError","createElement","FormRenderer","key","value"],"mappings":"uVAGA,IAAMA,CAAAA,CAAS,CAAE,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AAAA,CAAM,SAAA,CAAUd,CAAM,CAAA,CAAGW,CAAAA,GAAgBgB,CAAAA,CAAKC,CAAAA,CAAO5B,CAAM,EAAG,CAAA,CACzG,CAAA,CAAA,CACF,CAAA,CArB4B1B,IAAC,KAAA,CAAA,CAAI,SAAA,CAAU,SAAA,CAAU,WAAA,CAAU,OAAQ,QAAA,CAAAkC,CAAAA,CAAS,CAuBpF","file":"cloud.js","sourcesContent":["import type { CloudAction, CloudNotice as Notice } from '@formhaus/core/cloud';\nimport type { Ref } from 'react';\n\nconst LABELS = { retry: 'Try again', reload: 'Reload page' };\n\nexport function CloudNotice({ notice, noticeRef, onAction }: {\n notice: Notice | null;\n noticeRef: Ref<HTMLDivElement>;\n onAction: (action: Exclude<CloudAction, null>) => void;\n}) {\n if (!notice) return null;\n return (\n <div ref={noticeRef} tabIndex={-1} className={`fh-form__notice fh-form__notice--${notice.tone}`}>\n <p>{notice.message}</p>\n {notice.details.length > 0 && <ul>{notice.details.map((detail) => <li key={detail}>{detail}</li>)}</ul>}\n {notice.action && (\n <button type=\"button\" className=\"fh-form-actions__button fh-form-actions__button--secondary\" onClick={() => onAction(notice.action!)}>\n {LABELS[notice.action]}\n </button>\n )}\n </div>\n );\n}\n","import type { CloudSubmission, DraftStore, PublishedForm } from '@formhaus/core/cloud';\nimport { cloudStateFor, createCloudController } from '@formhaus/core/internal';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\ninterface CloudFormOptions {\n id: string;\n apiBase?: string;\n initialForm?: PublishedForm;\n draftStore?: DraftStore;\n extraBody: () => Record<string, unknown>;\n onSuccess?: (submission: CloudSubmission) => void;\n onError?: (error: unknown) => void;\n}\n\nexport function useCloudForm({ id, apiBase, initialForm, draftStore, extraBody, onSuccess, onError }: CloudFormOptions) {\n const [state, setState] = useState(() => cloudStateFor(initialForm));\n const controller = useRef<ReturnType<typeof createCloudController> | null>(null);\n const callbacks = useRef({ onSuccess, onError, extraBody, initialForm, draftStore });\n callbacks.current = { onSuccess, onError, extraBody, initialForm, draftStore };\n\n useEffect(() => {\n const { initialForm: form, draftStore: store } = callbacks.current;\n setState(cloudStateFor(form));\n const current = createCloudController({ id, apiBase, initialForm: form, draftStore: store, extraBody: () => callbacks.current.extraBody() }, {\n onChange: setState,\n onSuccess: (submission) => callbacks.current.onSuccess?.(submission),\n onError: (error) => callbacks.current.onError?.(error),\n });\n controller.current = current;\n current.start();\n return () => current.dispose();\n }, [id, apiBase]);\n\n const submit = useCallback((values: Record<string, unknown>, skippedSteps?: string[]) => (\n controller.current!.submit(values, skippedSteps)\n ), []);\n const retry = useCallback(() => controller.current!.start(), []);\n const again = useCallback(() => controller.current!.again(), []);\n const saveDraft = useCallback((values: Record<string, unknown>) => controller.current?.saveDraft(values), []);\n\n return { ...state, submit, retry, again, saveDraft };\n}\n","import { FormRenderer } from '@formhaus/react';\nimport { CloudError, type CloudAction } from '@formhaus/core/cloud';\nimport { focusProblem } from '@formhaus/core/internal';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { CloudNotice } from './CloudNotice';\nimport type { FormhausFormProps } from './types';\nimport { useCloudForm } from './useCloudForm';\n\nconst HIDDEN = { position: 'absolute', width: '1px', height: '1px', overflow: 'hidden', clip: 'rect(0 0 0 0)', clipPath: 'inset(50%)' } as const;\n\nfunction handled() {}\n\nexport function FormhausForm({ id, apiBase, initialForm, draftStore, onSuccess, onError, fallback, success, initialValues, onFieldChange, ...rendererProps }: FormhausFormProps) {\n const trap = useRef<HTMLInputElement>(null);\n const extraBody = useCallback(() => ({ _fh_hp: trap.current?.value ?? '' }), []);\n const cloud = useCloudForm({ id, apiBase, initialForm, draftStore, extraBody, onSuccess, onError });\n const root = useRef<HTMLDivElement>(null);\n const notice = useRef<HTMLDivElement>(null);\n const act = useCallback((action: Exclude<CloudAction, null>) => {\n if (action === 'reload') window.location.reload();\n else root.current?.querySelector('form')?.requestSubmit();\n }, []);\n const { redirectUrl, successMessage, allowAnother } = cloud.settings;\n\n useEffect(() => {\n if (cloud.attempt === 0) return;\n const frame = requestAnimationFrame(() => focusProblem(root.current, notice.current));\n return () => cancelAnimationFrame(frame);\n }, [cloud.attempt]);\n\n useEffect(() => {\n if (cloud.done && redirectUrl && !success) window.location.assign(redirectUrl);\n }, [cloud.done, redirectUrl, success]);\n\n if (cloud.loadError) return (\n <>\n <p role=\"alert\" className=\"fh-form__error\">{cloud.loadError.message}</p>\n {cloud.loadError instanceof CloudError && cloud.loadError.retryable && (\n <button type=\"button\" className=\"fh-form-actions__button fh-form-actions__button--secondary\" onClick={cloud.retry}>Try again</button>\n )}\n </>\n );\n if (!cloud.definition) return <div className=\"fh-form\" aria-busy=\"true\">{fallback}</div>;\n if (cloud.done) return (\n <>\n {success ?? <p role=\"status\" className=\"fh-form__success\">{successMessage ?? 'Thank you. Your response was submitted.'}</p>}\n {allowAnother && <button type=\"button\" className=\"fh-form-actions__button fh-form-actions__button--secondary\" onClick={cloud.again}>Submit another response</button>}\n </>\n );\n return (\n <div ref={root} className=\"fh-cloud\">\n <input ref={trap} name=\"_fh_hp\" tabIndex={-1} autoComplete=\"off\" aria-hidden=\"true\" style={HIDDEN} defaultValue=\"\" />\n <CloudNotice notice={cloud.notice} noticeRef={notice} onAction={act} />\n <FormRenderer\n {...rendererProps}\n key={cloud.revision}\n definition={cloud.definition}\n initialValues={cloud.initialValues ?? initialValues}\n errors={cloud.errors}\n onSubmit={cloud.submit}\n onError={handled}\n onFieldChange={(key, value, values) => { cloud.saveDraft(values); onFieldChange?.(key, value, values); }}\n />\n </div>\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _formhaus_core from '@formhaus/core';
|
|
3
|
-
import { FieldType, FormAction, FormEngineOptions, FormDefinition, ValidatorFn, StepValidateFn, FieldOption, FormAnalyticsEvent, FormEngine } from '@formhaus/core';
|
|
3
|
+
import { FieldType, FormAction, FormEngineOptions, FormDefinition, SubmitFn, ValidatorFn, StepValidateFn, FieldOption, FormAnalyticsEvent, FormField, DefaultFieldType, FormEngine } from '@formhaus/core';
|
|
4
4
|
import { ComponentType } from 'react';
|
|
5
5
|
|
|
6
6
|
type OptionsProvider = (values: Record<string, unknown>) => FieldOption[] | Promise<FieldOption[]>;
|
|
7
7
|
interface FieldComponentProps {
|
|
8
|
+
id?: string;
|
|
8
9
|
field: _formhaus_core.FormField;
|
|
9
10
|
value: unknown;
|
|
10
11
|
error?: string;
|
|
@@ -39,19 +40,20 @@ interface FormActionsProps {
|
|
|
39
40
|
onSkip?: () => void;
|
|
40
41
|
onPrimary?: () => void;
|
|
41
42
|
}
|
|
43
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
42
44
|
interface FormStepProgressProps {
|
|
43
45
|
current: number;
|
|
44
46
|
total: number;
|
|
45
47
|
stepTitle?: string;
|
|
46
48
|
stepDescription?: string;
|
|
49
|
+
headingLevel?: HeadingLevel;
|
|
47
50
|
}
|
|
48
51
|
interface FormRendererProps extends FormEngineOptions {
|
|
49
52
|
onError?: (error: unknown) => void;
|
|
50
53
|
definition: FormDefinition;
|
|
51
54
|
initialValues?: Record<string, unknown>;
|
|
52
|
-
onSubmit:
|
|
55
|
+
onSubmit: SubmitFn;
|
|
53
56
|
onCancel?: () => void;
|
|
54
|
-
onStepChange?: (stepId: string, direction: 'next' | 'back') => void;
|
|
55
57
|
onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
|
|
56
58
|
validators?: Record<string, ValidatorFn>;
|
|
57
59
|
onStepValidate?: StepValidateFn;
|
|
@@ -59,19 +61,60 @@ interface FormRendererProps extends FormEngineOptions {
|
|
|
59
61
|
loading?: boolean;
|
|
60
62
|
components?: FieldComponentMap;
|
|
61
63
|
optionsProviders?: Record<string, OptionsProvider>;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
actionsComponent?: ComponentType<FormActionsProps>;
|
|
65
|
+
progressComponent?: ComponentType<FormStepProgressProps>;
|
|
66
|
+
headingLevel?: HeadingLevel;
|
|
64
67
|
onAnalyticsEvent?: (event: FormAnalyticsEvent) => void;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
declare function FormRenderer({ components,
|
|
70
|
+
declare function FormRenderer({ components, actionsComponent, progressComponent, ...props }: FormRendererProps): react_jsx_runtime.JSX.Element;
|
|
68
71
|
|
|
69
72
|
declare function HeadlessFormRenderer(props: FormRendererProps): react_jsx_runtime.JSX.Element;
|
|
70
73
|
|
|
71
74
|
declare function FormActions({ submitAction, backAction, cancelAction, skipAction, isFirstStep, isLastStep, isMultiStep, loading, showPrimary, values, onSubmit, onNext, onPrev, onCancel, onSkip, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, showSkip: showSkipProp, skipLabel: skipLabelProp, onPrimary: onPrimaryProp, }: FormActionsProps): react_jsx_runtime.JSX.Element;
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
interface FieldResolverProps {
|
|
77
|
+
id?: string;
|
|
78
|
+
field: FormField;
|
|
79
|
+
value: unknown;
|
|
80
|
+
error?: string;
|
|
81
|
+
loading?: boolean;
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
components?: FieldComponentMap;
|
|
84
|
+
onChange: (value: unknown) => void;
|
|
85
|
+
onCommit?: (value: unknown) => void;
|
|
86
|
+
onBlur?: () => void;
|
|
87
|
+
onFocus?: () => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare function FormhausField({ components, id, ...props }: FieldResolverProps): react_jsx_runtime.JSX.Element;
|
|
91
|
+
|
|
92
|
+
declare const defaultFieldComponents: Record<DefaultFieldType, ComponentType<FieldComponentProps>>;
|
|
93
|
+
|
|
94
|
+
declare function AutocompleteField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
95
|
+
|
|
96
|
+
declare function CheckboxField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
97
|
+
|
|
98
|
+
declare function DateField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
99
|
+
|
|
100
|
+
declare function DateTimeField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
101
|
+
|
|
102
|
+
declare function FileField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
103
|
+
|
|
104
|
+
declare function MultiselectField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
105
|
+
|
|
106
|
+
declare function RadioField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare function SelectField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
109
|
+
|
|
110
|
+
declare function SwitchField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare function TextareaField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
113
|
+
|
|
114
|
+
declare function TextField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
declare function FormStepProgress({ current, total, stepTitle, stepDescription, headingLevel, }: FormStepProgressProps): react_jsx_runtime.JSX.Element;
|
|
74
117
|
|
|
75
118
|
declare function useFormEngine(definition: FormDefinition, initialValues?: Record<string, unknown>, options?: FormEngineOptions): FormEngine;
|
|
76
119
|
|
|
77
|
-
export { type FieldComponentMap, type FieldComponentProps, FormActions, type FormActionsProps, FormRenderer, type FormRendererProps, FormStepProgress, type FormStepProgressProps, HeadlessFormRenderer, type OptionsProvider, useFormEngine };
|
|
120
|
+
export { AutocompleteField, CheckboxField, DateField, DateTimeField, type FieldComponentMap, type FieldComponentProps, FileField, FormActions, type FormActionsProps, FormRenderer, type FormRendererProps, FormStepProgress, type FormStepProgressProps, FormhausField, type FieldResolverProps as FormhausFieldProps, type HeadingLevel, HeadlessFormRenderer, MultiselectField, type OptionsProvider, RadioField, SelectField, SwitchField, TextField, TextareaField, defaultFieldComponents, useFormEngine };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useMemo}from'react';import {shouldApplyExternalErrors,evaluateCondition,FormEngine}from'@formhaus/core';import {jsx,jsxs}from'react/jsx-runtime';function D(e,o,r){return r?true:!e?.disabled||e.disabled.length===0?false:e.disabled.every(t=>evaluateCondition(t,o))}function V(e,o){return `fh-form-actions__button fh-form-actions__button--${e&&e.variant||o}`}function H({submitAction:e,backAction:o,cancelAction:r,skipAction:t,isFirstStep:l,isLastStep:s,isMultiStep:i,loading:p,showPrimary:a=true,values:n={},onSubmit:u,onNext:m,onPrev:y,onCancel:C,onSkip:d,primaryLabel:v,showBack:P,backLabel:F,showSkip:_,skipLabel:b,onPrimary:h}){let E=P??(i&&!l&&o!==false),c=F??(o||void 0)?.label??"Back",L=_??(i&&!!t),T=b??t?.label??"Skip",Oe=v??(i&&!s?"Continue":e?.label??"Submit"),Le=D(i&&!s?void 0:e,n,p),Te=h??(i&&!s?m:u);return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[E&&jsx("button",{type:"button",className:V(o,"secondary"),disabled:p,onClick:y,children:c}),r&&jsx("button",{type:"button",className:V(r,"text"),disabled:p,onClick:C,children:r.label}),L&&jsx("button",{type:"button",className:V(t,"text"),disabled:p,onClick:d,children:T})]}),a&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:Le,"aria-busy":p,onClick:()=>Te(),children:Oe})]})}function q({current:e,total:o,stepTitle:r,stepDescription:t}){let l=e/o*100;return jsxs("div",{className:"fh-step-progress",children:[jsx("div",{className:"fh-step-progress__bar",children:jsx("div",{className:"fh-step-progress__fill",style:{width:`${l}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",o]})}),r&&jsx("h3",{className:"fh-step-progress__title",children:r}),t&&jsx("p",{className:"fh-step-progress__description",children:t})]})}function S(e){let o=useCallback(t=>e.subscribe(t),[e]),r=useCallback(()=>e.getSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function I(e){let o=useCallback(t=>e.subscribeStructure(t),[e]),r=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function oe({engine:e,definition:o,loading:r,ActionsComponent:t,onSubmit:l,onNext:s,onPrev:i,onSkip:p,onCancel:a}){S(e);let n=e.currentStep,u=e.isLastStep||!e.isMultiStep,m=e.isMultiStep&&!u?(n?.next||void 0)?.label??"Continue":o.submit?.label??"Submit",y=e.isMultiStep&&!e.isFirstStep&&n?.back!==false,C=(n?.back||void 0)?.label??"Back",d=useCallback(async()=>{e.isMultiStep&&!u?await s():l();},[e,u,s,l]);return t?jsx(t,{submitAction:o.submit,backAction:n?.back,cancelAction:o.cancel,skipAction:n?.skip,isFirstStep:e.isFirstStep,isLastStep:u,isMultiStep:e.isMultiStep,loading:r||e.stepValidating||e.submitting,values:e.values,onSubmit:l,onNext:s,onPrev:i,onCancel:a,onSkip:p,primaryLabel:m,showPrimary:u||n?.next!==false,showBack:y,backLabel:C,showSkip:!!n?.skip&&n.next!==false,onPrimary:d}):null}function re({field:e,value:o,error:r,loading:t,disabled:l,components:s,onChange:i,onCommit:p,onBlur:a,onFocus:n}){let u=s?.[e.type];return u?jsx(u,{field:e,value:o,error:r,loading:t,disabled:l,onChange:i,onCommit:p,onBlur:a,onFocus:n}):jsxs("div",{children:["Unsupported field type: ",e.type]})}var te=memo(function({engine:o,field:r,options:t,disabled:l,components:s,onChange:i,onCommit:p,onBlur:a,onFocus:n}){let u=useCallback(F=>o.subscribeField(r.key,F),[o,r.key]),m=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(u,m,m);let y=useCallback(F=>i(r.key,F),[r.key,i]),C=useCallback(F=>p(r.key,F),[r.key,p]),d=useCallback(()=>a(r.key),[r.key,a]),v=useCallback(()=>n(r.key),[r.key,n]),P=t?{...r,options:t}:r;return jsx(re,{field:P,value:o.values[r.key],error:o.errors[r.key],loading:o.fieldLoading[r.key],disabled:l,components:s,onChange:y,onCommit:C,onBlur:d,onFocus:v})});function ze(e,o){return e?.length===o.length&&e.every((r,t)=>r.value===o[t].value&&r.label===o[t].label)}function ne(e,o,r){let[t,l]=useState({}),s=useRef(new Map);return useEffect(()=>{if(!r){l(n=>Object.keys(n).length>0?{}:n);return}let i=true,p=[],a=(n,u)=>{i&&l(m=>ze(m[n],u)?m:{...m,[n]:u});};for(let n of e){if(!n.optionsFrom)continue;let u=r[n.optionsFrom];if(!u)continue;let m=()=>{let y=(s.current.get(n.key)??0)+1;s.current.set(n.key,y);try{let C=u(o.values);if(Array.isArray(C)){a(n.key,C);return}C.then(d=>{s.current.get(n.key)===y&&a(n.key,d);}).catch(()=>{});}catch{}};m();for(let y of new Set(n.optionsDependsOn??[]))p.push(o.subscribeField(y,m));}return ()=>{i=false;for(let n of p)n();}},[o,e,r]),t}var le=memo(function({engine:o,loading:r,components:t,optionsProviders:l,onChange:s,onCommit:i,onBlur:p,onFocus:a}){I(o),S(o);let n=o.visibleFields,u=ne(n,o,l);return jsx("div",{className:"fh-form__fields",children:n.map(m=>jsx(te,{engine:o,field:m,options:u[m.key]??m.options,disabled:r||o.stepValidating||o.submitting,components:t,onChange:s,onCommit:i,onBlur:p,onFocus:a},m.key))})});function se({engine:e,ProgressComponent:o}){return I(e),!e.isMultiStep||!o?null:jsx(o,{current:e.progress.current,total:e.progress.total,stepTitle:e.currentStep?.title,stepDescription:e.currentStep?.description})}function ae({engine:e,actionError:o}){S(e);let r=o?[...e.topLevelErrors,o]:e.topLevelErrors;return r.length===0?null:jsx("div",{className:"fh-form__top-errors",children:r.map((t,l)=>jsx("p",{className:"fh-form__top-error",children:t},l))})}function U(e,o,r){let t=useRef(r);t.current=r;let l=useRef(null),s=useRef(e.id);(l.current===null||s.current!==e.id)&&(l.current=new FormEngine(e,o,{validators:r?.validators,get onStepValidate(){return t.current?.onStepValidate},get onBeforeStepChange(){return t.current?.onBeforeStepChange},get onAfterStepChange(){return t.current?.onAfterStepChange},get onBeforeSubmit(){return t.current?.onBeforeSubmit},get onAfterSubmit(){return t.current?.onAfterSubmit}}),s.current=e.id);let i=l.current;return useEffect(()=>()=>i.cancelPendingActions(),[i]),i}function Ye(e,o,r){let t=U(e,o,r);return S(t),t}function me(e,o){let{loading:r,onError:t,onFieldChange:l,onSubmit:s,onAnalyticsEvent:i}=o,[p,a]=useState(null),n=useCallback(async b=>{if(!r){a(null);try{await b();}catch(h){t?t(h):a({engine:e,message:h instanceof Error?h.message:"Form action failed"});}}},[e,r,t]),u=useCallback(()=>n(()=>e.nextStepAsync()),[n,e]),m=useCallback(()=>n(()=>e.prevStepAsync()),[n,e]),y=useCallback((b,h)=>{r||e.stepValidating||e.submitting||(e.setValue(b,h),l?.(b,h,e.values));},[e,r,l]),C=useCallback((b,h)=>{if(r||e.stepValidating||e.submitting)return;let E=e.currentStep,c=e.visibleFields.find(L=>L.key===b);c&&(y(b,h),c.autoAdvance&&e.currentStep?.id===E?.id&&!e.isLastStep&&n(()=>e.nextStepAsync("autoAdvance")));},[e,r,n,y]),d=useCallback(async(b,h)=>{i?.({type:"form_submitted",fieldCount:Object.keys(b).length}),await s(b,h);},[s,i]),v=useCallback(async b=>{let h=await b;if(!h)for(let[E,c]of Object.entries(e.errors))i?.({type:"field_error",fieldKey:E,error:c});return h},[e,i]),P=useCallback(()=>n(async()=>!D(e.definition.submit,e.values)&&v(e.submitAsync(d))),[e,n,d,v]),F=useCallback(()=>n(()=>v(e.skipStepAsync((b,h)=>(i?.({type:"step_skipped",stepId:e.currentStep.id}),d(b,h))))),[n,e,d,v,i]),_=p?.engine===e?p.message:null;return {next:u,prev:m,skip:F,update:y,commit:C,submit:P,actionError:_}}function z(e){let{definition:o,initialValues:r,loading:t=false,components:l,optionsProviders:s,ActionsComponent:i,ProgressComponent:p,onAnalyticsEvent:a}=e,n=useRef(null),u=useRef(false),m=useRef(null),y=useRef(false),C={...e,onAfterStepChange:async c=>{u.current=true,e.onStepChange?.(c.toStepId,c.direction),c.direction==="next"&&(a?.({type:c.reason==="skip"?"step_skipped":"step_completed",stepId:c.fromStepId}),a?.({type:"step_viewed",stepId:c.toStepId,stepIndex:d.currentStepIndex})),await e.onAfterStepChange?.(c);}},d=U(o,r,C),v=S(d),P=useRef(d.currentStep?.id),F=me(d,e),_=useRef(null);useEffect(()=>{if(!e.errors)return;let c=_.current?.engine===d?_.current.errors:void 0;shouldApplyExternalErrors(d,c,e.errors)&&(_.current={engine:d,errors:e.errors},d.setErrors(e.errors));},[e.errors,d]),useEffect(()=>{if(P.current!==d.currentStep?.id&&(u.current=true),P.current=d.currentStep?.id,d.stepValidating||d.submitting){y.current=true;return}let c=y.current;if(y.current=false,!u.current){let T=n.current?.ownerDocument;c&&T?.activeElement===T?.body&&m.current?.isConnected&&m.current.focus();return}u.current=false,(n.current?.querySelector(".fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)")??n.current)?.focus();},[d,v]);let b=useCallback(c=>{a?.({type:"field_focused",fieldKey:c});},[a]),h=useCallback(c=>{a?.({type:"field_blurred",fieldKey:c,hasValue:d.values[c]!==void 0&&d.values[c]!==""});},[d,a]),E=useCallback(()=>e.onCancel?.(),[e.onCancel]);return jsxs("form",{ref:n,onFocusCapture:c=>{m.current=c.target;},className:"fh-form",tabIndex:-1,"aria-busy":d.stepValidating||d.submitting||t,onSubmit:c=>{c.preventDefault(),d.isLastStep?F.submit():F.next();},children:[jsx(se,{engine:d,ProgressComponent:p}),jsx(le,{engine:d,loading:t,components:l,optionsProviders:s,onChange:F.update,onCommit:F.commit,onBlur:h,onFocus:b},o.id),jsx(ae,{engine:d,actionError:F.actionError}),jsx(oe,{engine:d,definition:o,loading:t,ActionsComponent:i,onSubmit:F.submit,onNext:F.next,onPrev:F.prev,onSkip:F.skip,onCancel:E})]})}function ue({field:e,inputId:o}){return e.label?jsxs("label",{className:"fh-field__label",htmlFor:o,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}):null}function G(e,o){return [e.helperText&&`${e.key}-helper`,o&&`${e.key}-error`].filter(Boolean).join(" ")||void 0}function N({disabled:e,loading:o,onBlur:r,onFocus:t}){return {disabled:e||o,onBlur:r,onFocus:t}}function g(e){return {id:e.field.key,...N(e),"aria-invalid":!!e.error,"aria-describedby":G(e.field,e.error)}}function f({field:e,error:o,variant:r,children:t}){let l=r==="radio"||r==="multiselect",s=r&&!l,i=l?"fieldset":"div",p=`fh-field__${r}-${l?"group":"wrapper"}`,a=e.helperText&&jsx("p",{id:`${e.key}-helper`,className:"fh-field__helper",children:e.helperText});return jsxs(i,{className:r?`fh-field fh-field--${r}`:"fh-field","aria-invalid":l&&!!o||void 0,"aria-describedby":l?G(e,o):void 0,children:[l&&e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),!r&&jsx(ue,{field:e,inputId:e.key}),!s&&a,r?jsxs("div",{className:l&&e.layout==="inline"?`${p} ${p}--inline`:p,children:[t,s&&e.label&&jsx("label",{className:"fh-field__label",htmlFor:e.key,children:e.label})]}):t,s&&a,o&&jsx("p",{id:`${e.key}-error`,className:"fh-field__error",role:"alert",children:o})]})}function fe(e){let{field:o,value:r,error:t,onChange:l}=e,s=`${o.key}-list`,i=o.options??[];return jsxs(f,{field:o,error:t,children:[jsx("input",{...g(e),type:"text",list:s,className:"fh-field__input fh-field__input--autocomplete",value:r??"",placeholder:o.placeholder,autoComplete:"off",onChange:p=>l(p.target.value)}),jsx("datalist",{id:s,children:i.map(p=>jsx("option",{value:p.value,children:p.label},p.value))})]})}function he(e){return jsx(f,{field:e.field,error:e.error,variant:"checkbox",children:jsx("input",{...g(e),type:"checkbox",className:"fh-field__checkbox",checked:!!e.value,onChange:o=>e.onChange(o.target.checked)})})}function be(e){return jsx(f,{field:e.field,error:e.error,children:jsx("input",{...g(e),type:"date",className:"fh-field__input fh-field__input--date",value:String(e.value??""),onChange:o=>e.onChange(o.target.value)})})}function Ce(e){return jsx(f,{field:e.field,error:e.error,children:jsx("input",{...g(e),type:"datetime-local",className:"fh-field__input fh-field__input--datetime",value:String(e.value??""),onChange:o=>e.onChange(o.target.value)})})}function Se(e){let{field:o,error:r,onChange:t}=e;return jsx(f,{field:o,error:r,children:jsx("input",{...g(e),type:"file",className:"fh-field__input fh-field__input--file",accept:o.accept,onChange:l=>{let s=l.target.files;t(s&&s.length>0?s[0]:null);}})})}function ke(e){let{field:o,value:r,error:t,onChange:l}=e,s=o.options??[],i=Array.isArray(r)?r:[];function p(a){let n=i.includes(a)?i.filter(u=>u!==a):[...i,a];l(n);}return jsx(f,{field:o,error:t,variant:"multiselect",children:s.map(a=>{let n=`${o.key}-${a.value}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{...N(e),id:n,type:"checkbox",className:"fh-field__checkbox",checked:i.includes(a.value),onChange:()=>p(a.value)}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:n,children:a.label})]},a.value)})})}function Pe(e){let{field:o,value:r,error:t,onChange:l,onCommit:s}=e,i=useRef(false),p=o.autoAdvance&&s,a=o.options??[];return jsx(f,{field:o,error:t,variant:"radio",children:a.map(n=>{let u=`${o.key}-${n.value}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{...N(e),id:u,type:"radio",className:"fh-field__radio",name:o.key,value:n.value,checked:String(r)===String(n.value),onChange:()=>{(!p||i.current)&&l(n.value);},onKeyDown:m=>{i.current=m.key.startsWith("Arrow"),p&&m.key===" "&&m.preventDefault(),p&&m.key==="Enter"&&(m.preventDefault(),m.repeat||p(n.value));},onKeyUp:m=>{i.current=false,p&&m.key===" "&&(m.preventDefault(),p(n.value));},onPointerDown:()=>{i.current=false;},onClick:m=>{!p||i.current||(m.detail>1?m.preventDefault():p(n.value));}}),jsx("label",{className:"fh-field__radio-label",htmlFor:u,children:n.label})]},n.value)})})}function _e(e){let{field:o,value:r,error:t,onChange:l}=e,s=o.options??[];return jsx(f,{field:o,error:t,children:jsxs("select",{...g(e),className:"fh-field__input fh-field__input--select",value:r??"",onChange:i=>l(i.target.value),children:[o.placeholder&&jsx("option",{value:"",disabled:true,children:o.placeholder}),s.map(i=>jsx("option",{value:i.value,children:i.label},i.value))]})})}function xe(e){return jsx(f,{field:e.field,error:e.error,variant:"switch",children:jsx("input",{...g(e),type:"checkbox",role:"switch",className:"fh-field__switch",checked:!!e.value,onChange:o=>e.onChange(o.target.checked)})})}function A(e){let{field:o,value:r,error:t,onChange:l}=e,s=p=>{let a=p.target.value;l(o.type==="number"&&a!==""?Number(a):a);},i=o.type==="email"?"email":o.type==="phone"?"tel":o.type==="number"?"number":o.type==="password"?"password":"text";return jsx(f,{field:o,error:t,children:jsx("input",{...g(e),type:i,className:"fh-field__input",value:r!=null?String(r):"",placeholder:o.placeholder??o.mask,onChange:s})})}var po=3;function Re(e){let{field:o,value:r,error:t,onChange:l}=e;return jsx(f,{field:o,error:t,children:jsx("textarea",{...g(e),className:"fh-field__input fh-field__input--textarea",value:r??"",placeholder:o.placeholder,rows:o.rows??po,onChange:s=>l(s.target.value)})})}var ao={text:A,email:A,phone:A,number:A,password:A,select:_e,autocomplete:fe,multiselect:ke,checkbox:he,radio:Pe,switch:xe,file:Se,date:be,datetime:Ce,textarea:Re};function Ne(e){let o={...ao};for(let[r,t]of Object.entries(e??{}))t&&(o[r]=t);return o}function uo({components:e,ActionsComponent:o,ProgressComponent:r,...t}){let l=useMemo(()=>Ne(e),[e]);return jsx(z,{...t,components:l,ActionsComponent:o??H,ProgressComponent:r??q})}export{H as FormActions,uo as FormRenderer,q as FormStepProgress,z as HeadlessFormRenderer,Ye as useFormEngine};//# sourceMappingURL=index.js.map
|
|
1
|
+
'use client';import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useId,useMemo}from'react';import {evaluateCondition,FormEngine}from'@formhaus/core';import {jsx,jsxs}from'react/jsx-runtime';import {fieldDomId,shouldApplyExternalErrors,autoAdvance}from'@formhaus/core/internal';function $(e,o,t){return t?true:!e?.disabled||e.disabled.length===0?false:e.disabled.every(r=>evaluateCondition(r,o))}function z(e,o){return `fh-form-actions__button fh-form-actions__button--${e&&e.variant||o}`}function G({submitAction:e,backAction:o,cancelAction:t,skipAction:r,isFirstStep:s,isLastStep:l,isMultiStep:i,loading:a,showPrimary:d=true,values:n={},onSubmit:u,onNext:p,onPrev:m,onCancel:C,onSkip:S,primaryLabel:w,showBack:c,backLabel:_,showSkip:P,skipLabel:v,onPrimary:I}){let y=c??(i&&!s&&o!==false),g=_??(o||void 0)?.label??"Back",k=P??(i&&!!r),R=v??r?.label??"Skip",F=w??(i&&!l?"Continue":e?.label??"Submit"),M=$(i&&!l?void 0:e,n,a),fe=I??(i&&!l?p:u);return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[y&&jsx("button",{type:"button",className:z(o,"secondary"),disabled:a,onClick:m,children:g}),t&&jsx("button",{type:"button",className:z(t,"text"),disabled:a,onClick:C,children:t.label}),k&&jsx("button",{type:"button",className:z(r,"text"),disabled:a,onClick:S,children:R})]}),d&&jsx("button",{type:"submit",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:M,"aria-busy":a,onClick:B=>{B.preventDefault(),fe();},children:F})]})}function J({current:e,total:o,stepTitle:t,stepDescription:r,headingLevel:s=2}){let l=`h${s}`,i=e/o*100;return jsxs("div",{className:"fh-step-progress",children:[jsx("div",{className:"fh-step-progress__bar",children:jsx("div",{className:"fh-step-progress__fill",style:{width:`${i}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",o]})}),t&&jsx(l,{className:"fh-step-progress__title",children:t}),r&&jsx("p",{className:"fh-step-progress__description",children:r})]})}function x(e){let o=useCallback(r=>e.subscribe(r),[e]),t=useCallback(()=>e.getSnapshot(),[e]);return useSyncExternalStore(o,t,t)}function H(e){let o=useCallback(r=>e.subscribeStructure(r),[e]),t=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,t,t)}function be({engine:e,definition:o,loading:t,ActionsComponent:r,onSubmit:s,onNext:l,onPrev:i,onSkip:a,onCancel:d}){x(e);let n=e.currentStep,u=e.isLastStep||!e.isMultiStep,p=e.isMultiStep&&!u?(n?.next||void 0)?.label??"Continue":o.submit?.label??"Submit",m=e.isMultiStep&&!e.isFirstStep&&n?.back!==false,C=(n?.back||void 0)?.label??"Back",S=useCallback(async()=>{e.isMultiStep&&!u?await l():s();},[e,u,l,s]);return r?jsx(r,{submitAction:o.submit,backAction:n?.back,cancelAction:o.cancel,skipAction:n?.skip,isFirstStep:e.isFirstStep,isLastStep:u,isMultiStep:e.isMultiStep,loading:t||e.stepValidating||e.submitting,values:e.getSubmitValues(),onSubmit:s,onNext:l,onPrev:i,onCancel:d,onSkip:a,primaryLabel:p,showPrimary:u||n?.next!==false,showBack:m,backLabel:C,showSkip:!!n?.skip&&n.next!==false,onPrimary:S}):null}var Ue=()=>{};function K({id:e,field:o,value:t,error:r,loading:s,disabled:l,components:i,onChange:a,onCommit:d,onBlur:n,onFocus:u}){let p=i?.[o.type];return p?jsx(p,{id:e,field:o,value:t,error:r,loading:s,disabled:l,onChange:a,onCommit:d,onBlur:n??Ue,onFocus:u}):jsxs("div",{children:["Unsupported field type: ",o.type]})}var ge=memo(function({engine:o,formId:t,field:r,options:s,disabled:l,components:i,onChange:a,onCommit:d,onBlur:n,onFocus:u}){let p=useCallback(P=>o.subscribeField(r.key,P),[o,r.key]),m=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(p,m,m);let C=useCallback(P=>a(r.key,P),[r.key,a]),S=useCallback(P=>d(r.key,P),[r.key,d]),w=useCallback(()=>n(r.key),[r.key,n]),c=useCallback(()=>u(r.key),[r.key,u]),_=s?{...r,options:s}:r;return jsx(K,{id:fieldDomId(t,r.key),field:_,value:o.values[r.key],error:o.errors[r.key],loading:o.fieldLoading[r.key],disabled:l,components:i,onChange:C,onCommit:S,onBlur:w,onFocus:c})});function oo(e,o){return e?.length===o.length&&e.every((t,r)=>t.value===o[r].value&&t.label===o[r].label)}function ve(e,o,t){let[r,s]=useState({}),l=useRef(new Map);return useEffect(()=>{if(!t){s(n=>Object.keys(n).length>0?{}:n);return}let i=true,a=[],d=(n,u)=>{i&&s(p=>oo(p[n],u)?p:{...p,[n]:u});};for(let n of e){if(!n.optionsFrom)continue;let u=t[n.optionsFrom];if(!u)continue;let p=()=>{let m=(l.current.get(n.key)??0)+1;l.current.set(n.key,m);try{let C=u(o.values);if(Array.isArray(C)){d(n.key,C);return}C.then(S=>{l.current.get(n.key)===m&&d(n.key,S);}).catch(()=>{});}catch{}};p();for(let m of new Set(n.optionsDependsOn??[]))a.push(o.subscribeField(m,p));}return ()=>{i=false;for(let n of a)n();}},[o,e,t]),r}var Se=memo(function({engine:o,formId:t,loading:r,components:s,optionsProviders:l,onChange:i,onCommit:a,onBlur:d,onFocus:n}){H(o),x(o);let u=o.visibleFields,p=ve(u,o,l);return jsx("div",{className:"fh-form__fields",children:u.map(m=>jsx(ge,{engine:o,formId:t,field:m,options:p[m.key]??m.options,disabled:r||o.stepValidating||o.submitting,components:s,onChange:i,onCommit:a,onBlur:d,onFocus:n},m.key))})});function ke({engine:e,ProgressComponent:o,headingLevel:t}){return H(e),!e.isMultiStep||!o?null:jsx(o,{current:e.progress.current,total:e.progress.total,stepTitle:e.currentStep?.title,stepDescription:e.currentStep?.description,headingLevel:t})}function _e({engine:e,actionError:o}){x(e);let t=o?[...e.topLevelErrors,o]:e.topLevelErrors;return t.length===0?null:jsx("div",{className:"fh-form__top-errors",children:t.map((r,s)=>jsx("p",{className:"fh-form__top-error",children:r},s))})}function X(e,o,t){let r=useRef(t);r.current=t;let s=useRef(null),l=useRef(e);(s.current===null||l.current!==e)&&(s.current=new FormEngine(e,o,{validators:t?.validators,get onStepValidate(){return r.current?.onStepValidate},get onBeforeStepChange(){return r.current?.onBeforeStepChange},get onAfterStepChange(){return r.current?.onAfterStepChange},get onBeforeSubmit(){return r.current?.onBeforeSubmit},get onAfterSubmit(){return r.current?.onAfterSubmit},onWarning:t?.onWarning}),l.current=e);let i=s.current;return useEffect(()=>()=>i.cancelPendingActions(),[i]),i}function lo(e,o,t){let r=X(e,o,t);return x(r),r}function Ee(e,o){let{loading:t,onError:r,onFieldChange:s,onSubmit:l,onAnalyticsEvent:i}=o,[a,d]=useState(null),[n,u]=useState(0),p=useCallback(async y=>{if(t)return;d(null);let g=e.errors;try{!await y()&&e.errors!==g&&Object.keys(e.errors).length>0&&u(k=>k+1);}catch(k){r?r(k):d({engine:e,message:k instanceof Error?k.message:"Form action failed"});}},[e,t,r]),m=useCallback(()=>p(()=>e.next()),[p,e]),C=useCallback(()=>p(()=>e.back()),[p,e]),S=useCallback((y,g)=>{t||e.stepValidating||e.submitting||(e.setValue(y,g),s?.(y,g,e.values));},[e,t,s]),w=useCallback((y,g)=>{if(t||e.stepValidating||e.submitting)return;let k=e.currentStep,R=e.visibleFields.find(F=>F.key===y);R&&(S(y,g),R.autoAdvance&&e.currentStep?.id===k?.id&&!e.isLastStep&&p(()=>autoAdvance(e)));},[e,t,p,S]),c=useCallback(async(y,g)=>{i?.({type:"form_submitted",fieldCount:Object.keys(y).length}),await l(y,g);},[l,i]),_=useCallback(async y=>{let g=await y;if(!g)for(let[k,R]of Object.entries(e.errors))i?.({type:"field_error",fieldKey:k,error:R});return g},[e,i]),P=useCallback(()=>p(async()=>!$(e.definition.submit,e.getSubmitValues())&&_(e.submit(c))),[e,p,c,_]),v=useCallback(()=>p(()=>_(e.skip((y,g)=>(i?.({type:"step_skipped",stepId:e.currentStep.id}),c(y,g))))),[p,e,c,_,i]),I=a?.engine===e?a.message:null;return {next:m,prev:C,skip:v,update:S,commit:w,submit:P,actionError:I,invalidAttempts:n}}var po=0,we=new WeakMap;function uo(e){let o=we.get(e);return o===void 0&&we.set(e,o=po++),o}var Ne="input:not(:disabled), select:not(:disabled), textarea:not(:disabled), button:not(:disabled)";function Ae(e){return e?.matches(Ne)?e:e?.querySelector(Ne)}function Z(e){let{definition:o,initialValues:t,loading:r=false,components:s,optionsProviders:l,actionsComponent:i,progressComponent:a,headingLevel:d=2,onAnalyticsEvent:n}=e,u=useId(),p=useRef(null),m=useRef(false),C=useRef(null),S=useRef(false),w={...e,onAfterStepChange:async F=>{m.current=true,F.reason!=="back"&&(n?.({type:F.reason==="skip"?"step_skipped":"step_completed",stepId:F.fromStepId}),n?.({type:"step_viewed",stepId:F.toStepId,stepIndex:c.currentStepIndex})),await e.onAfterStepChange?.(F);}},c=X(o,t,w),_=x(c),P=useRef(c.currentStep?.id),v=Ee(c,e),I=useRef(0),y=useRef(null);useEffect(()=>{if(!e.errors)return;let F=y.current?.engine===c?y.current.errors:void 0;shouldApplyExternalErrors(c,F,e.errors)&&(y.current={engine:c,errors:e.errors},c.setErrors(e.errors));},[e.errors,c]),useEffect(()=>{if((P.current!==c.currentStep?.id||I.current!==v.invalidAttempts)&&(m.current=true),P.current=c.currentStep?.id,I.current=v.invalidAttempts,c.stepValidating||c.submitting){S.current=true;return}let F=S.current;if(S.current=false,!m.current){let B=p.current?.ownerDocument;F&&B?.activeElement===B?.body&&C.current?.isConnected&&C.current.focus();return}m.current=false;let M=p.current?.querySelector(".fh-form__fields");(Ae(M?.querySelector('[aria-invalid="true"]'))??Ae(M)??p.current)?.focus();},[c,_,v.invalidAttempts]);let g=useCallback(F=>{n?.({type:"field_focused",fieldKey:F});},[n]),k=useCallback(F=>{n?.({type:"field_blurred",fieldKey:F,hasValue:c.values[F]!==void 0&&c.values[F]!==""});},[c,n]),R=useCallback(()=>e.onCancel?.(),[e.onCancel]);return jsxs("form",{ref:p,onFocusCapture:F=>{C.current=F.target;},className:"fh-form",tabIndex:-1,"aria-busy":c.stepValidating||c.submitting||r,onSubmit:F=>{F.preventDefault(),c.isLastStep?v.submit():v.next();},children:[jsx(ke,{engine:c,ProgressComponent:a,headingLevel:d}),jsx(Se,{engine:c,formId:u,loading:r,components:s,optionsProviders:l,onChange:v.update,onCommit:v.commit,onBlur:k,onFocus:g},uo(c)),jsx(_e,{engine:c,actionError:v.actionError}),jsx(be,{engine:c,definition:o,loading:r,ActionsComponent:i,onSubmit:v.submit,onNext:v.next,onPrev:v.prev,onSkip:v.skip,onCancel:R})]})}function Ie({field:e,inputId:o}){return e.label?jsxs("label",{className:"fh-field__label",htmlFor:o,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}):null}function f(e){return e.id??fieldDomId(void 0,e.field.key)}function j(e,o,t){return [e.helperText&&`${o}-helper`,t&&`${o}-error`].filter(Boolean).join(" ")||void 0}function D({disabled:e,loading:o,onBlur:t,onFocus:r}){return {disabled:e||o,onBlur:t,onFocus:r}}function b(e){let o=f(e);return {id:o,name:e.field.key,...D(e),"aria-invalid":!!e.error,"aria-required":!!e.field.validation?.required||void 0,"aria-describedby":j(e.field,o,e.error)}}function h({id:e,field:o,error:t,variant:r,children:s}){let l=r==="radio"||r==="multiselect",i=r&&!l,a=l?"fieldset":"div",d=`fh-field__${r}-${l?"group":"wrapper"}`,n=o.helperText&&jsx("p",{id:`${e}-helper`,className:"fh-field__helper",children:o.helperText});return jsxs(a,{className:r?`fh-field fh-field--${r}`:"fh-field","aria-invalid":l&&!!t||void 0,"aria-describedby":l?j(o,e,t):void 0,children:[l&&o.label&&jsx("legend",{className:"fh-field__label",children:o.label}),!r&&jsx(Ie,{field:o,inputId:e}),!i&&n,r?jsxs("div",{className:l&&o.layout==="inline"?`${d} ${d}--inline`:d,children:[s,i&&o.label&&jsx("label",{className:"fh-field__label",htmlFor:e,children:o.label})]}):s,i&&n,t&&jsx("p",{id:`${e}-error`,className:"fh-field__error",role:"alert",children:t})]})}function oe(e){let{field:o,value:t,error:r,onChange:s}=e,l=`${f(e)}-list`,i=o.options??[];return jsxs(h,{id:f(e),field:o,error:r,children:[jsx("input",{...b(e),type:"text",list:l,className:"fh-field__input fh-field__input--autocomplete",value:t??"",placeholder:o.placeholder,autoComplete:"off",onChange:a=>s(a.target.value)}),jsx("datalist",{id:l,children:i.map(a=>jsx("option",{value:a.value,children:a.label},a.value))})]})}function re(e){return jsx(h,{id:f(e),field:e.field,error:e.error,variant:"checkbox",children:jsx("input",{...b(e),type:"checkbox",className:"fh-field__checkbox",checked:!!e.value,onChange:o=>e.onChange(o.target.checked)})})}function te(e){return jsx(h,{id:f(e),field:e.field,error:e.error,children:jsx("input",{...b(e),type:"date",className:"fh-field__input fh-field__input--date",value:String(e.value??""),onChange:o=>e.onChange(o.target.value)})})}function ne(e){return jsx(h,{id:f(e),field:e.field,error:e.error,children:jsx("input",{...b(e),type:"datetime-local",className:"fh-field__input fh-field__input--datetime",value:String(e.value??""),onChange:o=>e.onChange(o.target.value)})})}function ie(e){let{field:o,error:t,onChange:r}=e;return jsx(h,{id:f(e),field:o,error:t,children:jsx("input",{...b(e),type:"file",className:"fh-field__input fh-field__input--file",accept:o.accept,onChange:s=>{let l=s.target.files;r(l&&l.length>0?l[0]:null);}})})}function se(e){let{field:o,value:t,error:r,onChange:s}=e,l=o.options??[],i=Array.isArray(t)?t:[];function a(d){let n=i.includes(d)?i.filter(u=>u!==d):[...i,d];s(n);}return jsx(h,{id:f(e),field:o,error:r,variant:"multiselect",children:l.map((d,n)=>{let u=`${f(e)}-${n}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{...D(e),id:u,name:o.key,type:"checkbox",className:"fh-field__checkbox",checked:i.includes(d.value),onChange:()=>a(d.value)}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:u,children:d.label})]},d.value)})})}function me(e){let{field:o,value:t,error:r,onChange:s,onCommit:l}=e,i=useRef(false),a=o.autoAdvance&&l,d=o.options??[];return jsx(h,{id:f(e),field:o,error:r,variant:"radio",children:d.map((n,u)=>{let p=`${f(e)}-${u}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{...D(e),id:p,type:"radio",className:"fh-field__radio",name:o.key,value:n.value,checked:String(t)===String(n.value),onChange:()=>{(!a||i.current)&&s(n.value);},onKeyDown:m=>{i.current=m.key.startsWith("Arrow"),a&&m.key===" "&&m.preventDefault(),a&&m.key==="Enter"&&(m.preventDefault(),m.repeat||a(n.value));},onKeyUp:m=>{i.current=false,a&&m.key===" "&&(m.preventDefault(),a(n.value));},onPointerDown:()=>{i.current=false;},onClick:m=>{!a||i.current||(m.detail>1?m.preventDefault():a(n.value));}}),jsx("label",{className:"fh-field__radio-label",htmlFor:p,children:n.label})]},n.value)})})}function de(e){let{field:o,value:t,error:r,onChange:s}=e,l=o.options??[];return jsx(h,{id:f(e),field:o,error:r,children:jsxs("select",{...b(e),className:"fh-field__input fh-field__input--select",value:t??"",onChange:i=>s(i.target.value),children:[o.placeholder&&jsx("option",{value:"",disabled:true,children:o.placeholder}),l.map(i=>jsx("option",{value:i.value,children:i.label},i.value))]})})}function ue(e){return jsx(h,{id:f(e),field:e.field,error:e.error,variant:"switch",children:jsx("input",{...b(e),type:"checkbox",role:"switch",className:"fh-field__switch",checked:!!e.value,onChange:o=>e.onChange(o.target.checked)})})}function A(e){let{field:o,value:t,error:r,onChange:s}=e,l=o.type==="number",[i,a]=useState(""),d=p=>{let m=p.target.value;a(m),s(l&&m!==""?Number(m):m);},n=l&&i&&Object.is(Number(i),t)?i:String(t??""),u=o.type==="email"?"email":o.type==="phone"?"tel":l?"number":o.type==="password"?"password":"text";return jsx(h,{id:f(e),field:o,error:r,children:jsx("input",{...b(e),type:u,className:"fh-field__input",value:n,placeholder:o.placeholder??o.mask,inputMode:o.inputMode,onChange:d})})}var ko=3;function ce(e){let{field:o,value:t,error:r,onChange:s}=e;return jsx(h,{id:f(e),field:o,error:r,children:jsx("textarea",{...b(e),className:"fh-field__input fh-field__input--textarea",value:t??"",placeholder:o.placeholder,rows:o.rows??ko,onChange:l=>s(l.target.value)})})}var qe={text:A,email:A,phone:A,number:A,password:A,select:de,autocomplete:oe,multiselect:se,checkbox:re,radio:me,switch:ue,file:ie,date:te,datetime:ne,textarea:ce};function U(e){let o={...qe};for(let[t,r]of Object.entries(e??{}))r&&(o[t]=r);return o}function _o({components:e,actionsComponent:o,progressComponent:t,...r}){let s=useMemo(()=>U(e),[e]);return jsx(Z,{...r,components:s,actionsComponent:o??G,progressComponent:t??J})}function No({components:e,id:o,...t}){let r=useId(),s=useMemo(()=>U(e),[e]);return jsx(K,{...t,id:o??fieldDomId(r,t.field.key),components:s})}export{oe as AutocompleteField,re as CheckboxField,te as DateField,ne as DateTimeField,ie as FileField,G as FormActions,_o as FormRenderer,J as FormStepProgress,No as FormhausField,Z as HeadlessFormRenderer,se as MultiselectField,me as RadioField,de as SelectField,ue as SwitchField,A as TextField,ce as TextareaField,qe as defaultFieldComponents,lo as useFormEngine};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/isActionDisabled.ts","../src/FormActions.tsx","../src/FormStepProgress.tsx","../src/hooks/useEngineSnapshot.ts","../src/FormActionsController.tsx","../src/FormField.tsx","../src/FormFieldController.tsx","../src/hooks/useFieldOptions.ts","../src/FormFieldsController.tsx","../src/FormProgressController.tsx","../src/FormTopLevelErrors.tsx","../src/hooks/useFormEngine.ts","../src/hooks/useRendererActions.ts","../src/HeadlessFormRenderer.tsx","../src/fields/FieldLabel.tsx","../src/fields/fieldProps.ts","../src/fields/FieldShell.tsx","../src/fields/AutocompleteField.tsx","../src/fields/CheckboxField.tsx","../src/fields/DateField.tsx","../src/fields/DateTimeField.tsx","../src/fields/FileField.tsx","../src/fields/MultiselectField.tsx","../src/fields/RadioField.tsx","../src/fields/SelectField.tsx","../src/fields/SwitchField.tsx","../src/fields/TextField.tsx","../src/fields/TextareaField.tsx","../src/defaultFieldComponents.ts","../src/FormRenderer.tsx"],"names":["isActionDisabled","action","values","loading","c","evaluateCondition","buttonClass","variant","FormActions","submitAction","backAction","cancelAction","skipAction","isFirstStep","isLastStep","isMultiStep","showPrimary","onSubmit","onNext","onPrev","onCancel","onSkip","primaryLabelProp","showBackProp","backLabelProp","showSkipProp","skipLabelProp","onPrimaryProp","showBack","backLabel","showSkip","skipLabel","primaryLabel","primaryDisabled","handlePrimary","jsxs","jsx","FormStepProgress","current","total","stepTitle","stepDescription","percent","useFormSnapshot","engine","subscribe","useCallback","listener","getSnapshot","useSyncExternalStore","useStructureSnapshot","FormActionsController","definition","ActionsComponent","step","FormField","field","value","error","disabled","components","onChange","onCommit","onBlur","onFocus","Component","FormFieldController","memo","options","handleChange","handleCommit","handleBlur","handleFocus","fieldWithOptions","areOptionsEqual","previous","next","option","index","useFieldOptions","fields","providers","resolved","setResolved","useState","requestVersions","useRef","useEffect","active","unsubscribers","commit","fieldKey","provider","resolve","requestVersion","result","dependency","unsubscribe","FormFieldsController","optionsProviders","resolvedOptions","FormProgressController","ProgressComponent","FormTopLevelErrors","actionError","errors","useFormEngineStore","initialValues","optionsRef","engineRef","definitionIdRef","FormEngine","useFormEngine","useRendererActions","props","onError","onFieldChange","onAnalyticsEvent","failure","setFailure","run","prev","update","key","send","skippedSteps","report","submit","skip","HeadlessFormRenderer","formRef","focusPending","focusReturn","wasBusy","engineOptions","context","version","previousStep","actions","appliedErrors","shouldApplyExternalErrors","restore","document","handleFieldFocus","handleFieldBlur","handleCancel","event","FieldLabel","inputId","describedBy","optionProps","inputProps","FieldShell","children","group","inline","Root","container","helper","AutocompleteField","listId","e","opt","CheckboxField","DateField","DateTimeField","FileField","files","MultiselectField","selected","handleToggle","optValue","v","optionId","RadioField","arrowSelection","SelectField","SwitchField","TextField","inputType","DEFAULT_ROWS","TextareaField","defaultFieldComponents","withDefaultFields","merged","type","component","FormRenderer","fieldComponents","useMemo"],"mappings":"yNAGO,SAASA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,EACS,CACT,OAAIA,EAAgB,IAAA,CAChB,CAACF,GAAQ,QAAA,EAAYA,CAAAA,CAAO,QAAA,CAAS,MAAA,GAAW,CAAA,CAAU,KA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IAAA,GAAW,CAACG,CAAAA,CAAMC,CAAS,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQ9H,CAAAA,EAAc,EAAE,CAAA,CACzD8H,IAAWF,CAAAA,CAAOC,CAAI,EAAIC,CAAAA,CAAAA,CAEhC,OAAOF,CACT,CChCO,SAASG,EAAAA,CAAa,CAC3B,UAAA,CAAA/H,CAAAA,CACA,gBAAA,CAAAP,EACA,iBAAA,CAAAiD,CAAAA,CACA,GAAGY,CACL,CAAA,CAAsB,CACpB,IAAM0E,CAAAA,CAAkBC,OAAAA,CAAQ,IAAMN,EAAAA,CAAkB3H,CAAU,EAAG,CAACA,CAAU,CAAC,CAAA,CAEjF,OACExB,GAAAA,CAAC6F,EAAA,CACE,GAAGf,CAAAA,CACJ,UAAA,CAAY0E,CAAAA,CACZ,gBAAA,CAAkBvI,GAAoB7C,CAAAA,CACtC,iBAAA,CAAmB8F,CAAAA,EAAqBjE,CAAAA,CAC1C,CAEJ","file":"index.js","sourcesContent":["import { evaluateCondition } from '@formhaus/core';\nimport type { FormAction } from '@formhaus/core';\n\nexport function isActionDisabled(\n action: FormAction | undefined,\n values: Record<string, unknown>,\n loading?: boolean,\n): boolean {\n if (loading) return true;\n if (!action?.disabled || action.disabled.length === 0) return false;\n return action.disabled.every((c) => evaluateCondition(c, values));\n}\n","import type { FormAction } from '@formhaus/core';\nimport { isActionDisabled } from './isActionDisabled';\nimport type { FormActionsProps } from './types';\n\nfunction buttonClass(action: FormAction | false | undefined, variant: NonNullable<FormAction['variant']>): string {\n return `fh-form-actions__button fh-form-actions__button--${(action && action.variant) || variant}`;\n}\n\nexport function FormActions({\n submitAction,\n backAction,\n cancelAction,\n skipAction,\n isFirstStep,\n isLastStep,\n isMultiStep,\n loading,\n showPrimary = true,\n values = {},\n onSubmit,\n onNext,\n onPrev,\n onCancel,\n onSkip,\n primaryLabel: primaryLabelProp,\n showBack: showBackProp,\n backLabel: backLabelProp,\n showSkip: showSkipProp,\n skipLabel: skipLabelProp,\n onPrimary: onPrimaryProp,\n}: FormActionsProps) {\n const showBack = showBackProp ?? (isMultiStep && !isFirstStep && backAction !== false);\n const backLabel = backLabelProp ?? (backAction || undefined)?.label ?? 'Back';\n const showSkip = showSkipProp ?? (isMultiStep && !!skipAction);\n const skipLabel = skipLabelProp ?? skipAction?.label ?? 'Skip';\n const primaryLabel = primaryLabelProp ?? (isMultiStep && !isLastStep ? 'Continue' : (submitAction?.label ?? 'Submit'));\n\n const primaryDisabled = isActionDisabled(\n isMultiStep && !isLastStep ? undefined : submitAction,\n values,\n loading,\n );\n\n const handlePrimary = onPrimaryProp ?? (isMultiStep && !isLastStep ? onNext : onSubmit);\n\n return (\n <div className=\"fh-form-actions\">\n <div className=\"fh-form-actions__secondary\">\n {showBack && (\n <button type=\"button\" className={buttonClass(backAction, 'secondary')} disabled={loading} onClick={onPrev}>\n {backLabel}\n </button>\n )}\n {cancelAction && (\n <button type=\"button\" className={buttonClass(cancelAction, 'text')} disabled={loading} onClick={onCancel}>\n {cancelAction.label}\n </button>\n )}\n {showSkip && (\n <button type=\"button\" className={buttonClass(skipAction, 'text')} disabled={loading} onClick={onSkip}>\n {skipLabel}\n </button>\n )}\n </div>\n {showPrimary && <button\n type=\"button\"\n className=\"fh-form-actions__button fh-form-actions__button--primary\"\n disabled={primaryDisabled}\n aria-busy={loading}\n onClick={() => handlePrimary()}\n >\n {primaryLabel}\n </button>}\n </div>\n );\n}\n","import type { FormStepProgressProps } from './types';\n\nexport function FormStepProgress({\n current,\n total,\n stepTitle,\n stepDescription,\n}: FormStepProgressProps) {\n const percent = (current / total) * 100;\n\n return (\n <div className=\"fh-step-progress\">\n <div className=\"fh-step-progress__bar\">\n <div className=\"fh-step-progress__fill\" style={{ width: `${percent}%` }} />\n </div>\n <div className=\"fh-step-progress__info\">\n <span className=\"fh-step-progress__counter\">\n Step {current} of {total}\n </span>\n </div>\n {stepTitle && <h3 className=\"fh-step-progress__title\">{stepTitle}</h3>}\n {stepDescription && <p className=\"fh-step-progress__description\">{stepDescription}</p>}\n </div>\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nexport function useFormSnapshot(engine: FormEngine): number {\n const subscribe = useCallback((listener: () => void) => engine.subscribe(listener), [engine]);\n const getSnapshot = useCallback(() => engine.getSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useStructureSnapshot(engine: FormEngine): number {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeStructure(listener),\n [engine],\n );\n const getSnapshot = useCallback(() => engine.getStructureSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback } from 'react';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormActionsControllerProps {\n engine: FormEngine;\n definition: FormRendererProps['definition'];\n loading: boolean;\n ActionsComponent: FormRendererProps['ActionsComponent'];\n onSubmit: () => void;\n onNext: () => Promise<void>;\n onPrev: () => void;\n onSkip: () => void;\n onCancel: () => void;\n}\n\nexport function FormActionsController({\n engine,\n definition,\n loading,\n ActionsComponent,\n onSubmit,\n onNext,\n onPrev,\n onSkip,\n onCancel,\n}: FormActionsControllerProps) {\n useFormSnapshot(engine);\n const step = engine.currentStep;\n const isLastStep = engine.isLastStep || !engine.isMultiStep;\n const primaryLabel = engine.isMultiStep && !isLastStep\n ? ((step?.next || undefined)?.label ?? 'Continue')\n : (definition.submit?.label ?? 'Submit');\n const showBack = engine.isMultiStep && !engine.isFirstStep && step?.back !== false;\n const backLabel = (step?.back || undefined)?.label ?? 'Back';\n const handlePrimary = useCallback(async () => {\n if (engine.isMultiStep && !isLastStep) await onNext();\n else onSubmit();\n }, [engine, isLastStep, onNext, onSubmit]);\n\n if (!ActionsComponent) return null;\n\n return (\n <ActionsComponent\n submitAction={definition.submit}\n backAction={step?.back}\n cancelAction={definition.cancel}\n skipAction={step?.skip}\n isFirstStep={engine.isFirstStep}\n isLastStep={isLastStep}\n isMultiStep={engine.isMultiStep}\n loading={loading || engine.stepValidating || engine.submitting}\n values={engine.values}\n onSubmit={onSubmit}\n onNext={onNext}\n onPrev={onPrev}\n onCancel={onCancel}\n onSkip={onSkip}\n primaryLabel={primaryLabel}\n showPrimary={isLastStep || step?.next !== false}\n showBack={showBack}\n backLabel={backLabel}\n showSkip={!!step?.skip && step.next !== false}\n onPrimary={handlePrimary}\n />\n );\n}\n","import type { FormField as FormFieldType } from '@formhaus/core';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\ninterface FormFieldProps {\n field: FormFieldType;\n value: unknown;\n error?: string;\n loading?: boolean;\n disabled?: boolean;\n components?: FieldComponentMap;\n onChange: (value: unknown) => void;\n onCommit?: (value: unknown) => void;\n onBlur: () => void;\n onFocus?: () => void;\n}\n\nexport function FormField({\n field,\n value,\n error,\n loading,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldProps) {\n const Component = components?.[field.type];\n\n if (!Component) {\n return <div>Unsupported field type: {field.type}</div>;\n }\n\n return (\n <Component\n field={field}\n value={value}\n error={error}\n loading={loading}\n disabled={disabled}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n );\n}\n","import type { FieldOption, FormEngine, FormField as FormFieldType } from '@formhaus/core';\nimport { memo, useCallback, useSyncExternalStore } from 'react';\nimport { FormField } from './FormField';\nimport type { FieldComponentMap } from './types';\n\nexport interface ControllerProps {\n engine: FormEngine;\n components?: FieldComponentMap;\n onChange: (key: string, value: unknown) => void;\n onCommit: (key: string, value: unknown) => void;\n onBlur: (key: string) => void;\n onFocus: (key: string) => void;\n}\n\ninterface FormFieldControllerProps extends ControllerProps {\n field: FormFieldType;\n options?: FieldOption[];\n disabled?: boolean;\n}\n\nexport const FormFieldController = memo(function FormFieldController({\n engine,\n field,\n options,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldControllerProps) {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeField(field.key, listener),\n [engine, field.key],\n );\n const getSnapshot = useCallback(\n () => engine.getFieldSnapshot(field.key),\n [engine, field.key],\n );\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const handleChange = useCallback(\n (value: unknown) => onChange(field.key, value),\n [field.key, onChange],\n );\n const handleCommit = useCallback((value: unknown) => onCommit(field.key, value), [field.key, onCommit]);\n const handleBlur = useCallback(() => onBlur(field.key), [field.key, onBlur]);\n const handleFocus = useCallback(() => onFocus(field.key), [field.key, onFocus]);\n const fieldWithOptions = options ? { ...field, options } : field;\n\n return (\n <FormField\n field={fieldWithOptions}\n value={engine.values[field.key]}\n error={engine.errors[field.key]}\n loading={engine.fieldLoading[field.key]}\n disabled={disabled}\n components={components}\n onChange={handleChange}\n onCommit={handleCommit}\n onBlur={handleBlur}\n onFocus={handleFocus}\n />\n );\n});\n","import type { FieldOption, FormEngine, FormField } from '@formhaus/core';\nimport { useEffect, useRef, useState } from 'react';\nimport type { OptionsProvider } from '../types';\n\nfunction areOptionsEqual(previous: FieldOption[] | undefined, next: FieldOption[]): boolean {\n return previous?.length === next.length && previous.every((option, index) => (\n option.value === next[index].value && option.label === next[index].label\n ));\n}\n\nexport function useFieldOptions(\n fields: FormField[],\n engine: FormEngine,\n providers?: Record<string, OptionsProvider>,\n): Record<string, FieldOption[]> {\n const [resolved, setResolved] = useState<Record<string, FieldOption[]>>({});\n const requestVersions = useRef<Map<string, number>>(new Map());\n\n useEffect(() => {\n if (!providers) {\n setResolved((previous) => (\n Object.keys(previous).length > 0 ? {} : previous\n ));\n return;\n }\n\n let active = true;\n const unsubscribers: (() => void)[] = [];\n\n const commit = (fieldKey: string, options: FieldOption[]) => {\n if (!active) return;\n setResolved((previous) => {\n if (areOptionsEqual(previous[fieldKey], options)) return previous;\n return { ...previous, [fieldKey]: options };\n });\n };\n\n for (const field of fields) {\n if (!field.optionsFrom) continue;\n\n const provider = providers[field.optionsFrom];\n if (!provider) continue;\n\n const resolve = () => {\n const requestVersion = (requestVersions.current.get(field.key) ?? 0) + 1;\n requestVersions.current.set(field.key, requestVersion);\n\n try {\n const result = provider(engine.values);\n if (Array.isArray(result)) {\n commit(field.key, result);\n return;\n }\n\n result\n .then((options) => {\n if (requestVersions.current.get(field.key) === requestVersion) {\n commit(field.key, options);\n }\n })\n .catch(() => {});\n } catch {}\n };\n\n resolve();\n for (const dependency of new Set(field.optionsDependsOn ?? [])) {\n unsubscribers.push(engine.subscribeField(dependency, resolve));\n }\n }\n\n return () => {\n active = false;\n for (const unsubscribe of unsubscribers) unsubscribe();\n };\n }, [engine, fields, providers]);\n\n return resolved;\n}\n","import { memo } from 'react';\nimport { type ControllerProps, FormFieldController } from './FormFieldController';\nimport { useFormSnapshot, useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport { useFieldOptions } from './hooks/useFieldOptions';\nimport type { OptionsProvider } from './types';\n\ninterface FormFieldsControllerProps extends ControllerProps {\n loading: boolean;\n optionsProviders?: Record<string, OptionsProvider>;\n}\n\nexport const FormFieldsController = memo(function FormFieldsController({\n engine,\n loading,\n components,\n optionsProviders,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldsControllerProps) {\n useStructureSnapshot(engine);\n useFormSnapshot(engine);\n const fields = engine.visibleFields;\n const resolvedOptions = useFieldOptions(fields, engine, optionsProviders);\n\n return (\n <div className=\"fh-form__fields\">\n {fields.map((field) => (\n <FormFieldController\n key={field.key}\n engine={engine}\n field={field}\n options={resolvedOptions[field.key] ?? field.options}\n disabled={loading || engine.stepValidating || engine.submitting}\n components={components}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n ))}\n </div>\n );\n});\n","import type { FormEngine } from '@formhaus/core';\nimport { useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormProgressControllerProps {\n engine: FormEngine;\n ProgressComponent: FormRendererProps['ProgressComponent'];\n}\n\nexport function FormProgressController({\n engine,\n ProgressComponent,\n}: FormProgressControllerProps) {\n useStructureSnapshot(engine);\n if (!engine.isMultiStep || !ProgressComponent) return null;\n\n return (\n <ProgressComponent\n current={engine.progress.current}\n total={engine.progress.total}\n stepTitle={engine.currentStep?.title}\n stepDescription={engine.currentStep?.description}\n />\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\n\nexport function FormTopLevelErrors({ engine, actionError }: { engine: FormEngine; actionError?: string | null }) {\n useFormSnapshot(engine);\n const errors = actionError ? [...engine.topLevelErrors, actionError] : engine.topLevelErrors;\n if (errors.length === 0) return null;\n\n return (\n <div className=\"fh-form__top-errors\">\n {errors.map((error, index) => (\n <p key={index} className=\"fh-form__top-error\">\n {error}\n </p>\n ))}\n </div>\n );\n}\n","import { FormEngine, type FormEngineOptions, type FormDefinition } from '@formhaus/core';\nimport { useEffect, useRef } from 'react';\nimport { useFormSnapshot } from './useEngineSnapshot';\n\nexport function useFormEngineStore(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const engineRef = useRef<FormEngine | null>(null);\n const definitionIdRef = useRef<string>(definition.id);\n\n if (engineRef.current === null || definitionIdRef.current !== definition.id) {\n engineRef.current = new FormEngine(definition, initialValues, {\n validators: options?.validators,\n get onStepValidate() { return optionsRef.current?.onStepValidate; },\n get onBeforeStepChange() { return optionsRef.current?.onBeforeStepChange; },\n get onAfterStepChange() { return optionsRef.current?.onAfterStepChange; },\n get onBeforeSubmit() { return optionsRef.current?.onBeforeSubmit; },\n get onAfterSubmit() { return optionsRef.current?.onAfterSubmit; },\n });\n definitionIdRef.current = definition.id;\n }\n\n const engine = engineRef.current;\n useEffect(() => () => engine.cancelPendingActions(), [engine]);\n return engine;\n}\n\nexport function useFormEngine(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const engine = useFormEngineStore(definition, initialValues, options);\n useFormSnapshot(engine);\n return engine;\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useState } from 'react';\nimport { isActionDisabled } from '../isActionDisabled';\nimport type { FormRendererProps } from '../types';\n\nexport function useRendererActions(engine: FormEngine, props: FormRendererProps) {\n const { loading, onError, onFieldChange, onSubmit, onAnalyticsEvent } = props;\n const [failure, setFailure] = useState<{ engine: FormEngine; message: string } | null>(null);\n const run = useCallback(async (action: () => Promise<boolean>) => {\n if (loading) return;\n setFailure(null);\n try { await action(); }\n catch (error) {\n if (onError) onError(error);\n else setFailure({ engine, message: error instanceof Error ? error.message : 'Form action failed' });\n }\n }, [engine, loading, onError]);\n const next = useCallback(() => run(() => engine.nextStepAsync()), [run, engine]);\n const prev = useCallback(() => run(() => engine.prevStepAsync()), [run, engine]);\n const update = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n engine.setValue(key, value);\n onFieldChange?.(key, value, engine.values);\n }, [engine, loading, onFieldChange]);\n const commit = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n const step = engine.currentStep;\n const field = engine.visibleFields.find((field) => field.key === key);\n if (!field) return;\n update(key, value);\n if (field.autoAdvance && engine.currentStep?.id === step?.id && !engine.isLastStep) void run(() => engine.nextStepAsync('autoAdvance'));\n }, [engine, loading, run, update]);\n const send = useCallback(async (values: Record<string, unknown>, skippedSteps?: string[]) => {\n onAnalyticsEvent?.({ type: 'form_submitted', fieldCount: Object.keys(values).length });\n await onSubmit(values, skippedSteps);\n }, [onSubmit, onAnalyticsEvent]);\n const report = useCallback(async (action: Promise<boolean>) => {\n const result = await action;\n if (!result) {\n for (const [key, error] of Object.entries(engine.errors)) {\n onAnalyticsEvent?.({ type: 'field_error', fieldKey: key, error });\n }\n }\n return result;\n }, [engine, onAnalyticsEvent]);\n const submit = useCallback(() => run(async () => (\n !isActionDisabled(engine.definition.submit, engine.values) && report(engine.submitAsync(send))\n )), [engine, run, send, report]);\n const skip = useCallback(() => run(() => report(engine.skipStepAsync((values, skippedSteps) => {\n onAnalyticsEvent?.({ type: 'step_skipped', stepId: engine.currentStep!.id });\n return send(values, skippedSteps);\n }))), [run, engine, send, report, onAnalyticsEvent]);\n const actionError = failure?.engine === engine ? failure.message : null;\n return { next, prev, skip, update, commit, submit, actionError };\n}\n","import { shouldApplyExternalErrors, type FormEngineOptions } from '@formhaus/core';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { FormActionsController } from './FormActionsController';\nimport { FormFieldsController } from './FormFieldsController';\nimport { FormProgressController } from './FormProgressController';\nimport { FormTopLevelErrors } from './FormTopLevelErrors';\nimport { useFormEngineStore } from './hooks/useFormEngine';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport { useRendererActions } from './hooks/useRendererActions';\nimport type { FormRendererProps } from './types';\n\nexport function HeadlessFormRenderer(props: FormRendererProps) {\n const { definition, initialValues, loading = false, components, optionsProviders,\n ActionsComponent, ProgressComponent, onAnalyticsEvent } = props;\n const formRef = useRef<HTMLFormElement>(null);\n const focusPending = useRef(false);\n const focusReturn = useRef<HTMLElement | null>(null);\n const wasBusy = useRef(false);\n const engineOptions: FormEngineOptions = {\n ...props,\n onAfterStepChange: async (context) => {\n focusPending.current = true;\n props.onStepChange?.(context.toStepId, context.direction);\n if (context.direction === 'next') {\n onAnalyticsEvent?.({ type: context.reason === 'skip' ? 'step_skipped' : 'step_completed', stepId: context.fromStepId });\n onAnalyticsEvent?.({ type: 'step_viewed', stepId: context.toStepId, stepIndex: engine.currentStepIndex });\n }\n await props.onAfterStepChange?.(context);\n },\n };\n const engine = useFormEngineStore(definition, initialValues, engineOptions);\n const version = useFormSnapshot(engine);\n const previousStep = useRef(engine.currentStep?.id);\n const actions = useRendererActions(engine, props);\n\n const appliedErrors = useRef<{ engine: typeof engine; errors: Record<string, string> } | null>(null);\n useEffect(() => {\n if (!props.errors) return;\n const previous = appliedErrors.current?.engine === engine ? appliedErrors.current.errors : undefined;\n if (!shouldApplyExternalErrors(engine, previous, props.errors)) return;\n appliedErrors.current = { engine, errors: props.errors };\n engine.setErrors(props.errors);\n }, [props.errors, engine]);\n\n useEffect(() => {\n if (previousStep.current !== engine.currentStep?.id) focusPending.current = true;\n previousStep.current = engine.currentStep?.id;\n if (engine.stepValidating || engine.submitting) {\n wasBusy.current = true;\n return;\n }\n const restore = wasBusy.current;\n wasBusy.current = false;\n if (!focusPending.current) {\n const document = formRef.current?.ownerDocument;\n if (restore && document?.activeElement === document?.body && focusReturn.current?.isConnected) focusReturn.current.focus();\n return;\n }\n focusPending.current = false;\n const target = formRef.current?.querySelector<HTMLElement>(\n '.fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)',\n );\n (target ?? formRef.current)?.focus();\n }, [engine, version]);\n\n const handleFieldFocus = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_focused', fieldKey: key });\n }, [onAnalyticsEvent]);\n const handleFieldBlur = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_blurred', fieldKey: key,\n hasValue: engine.values[key] !== undefined && engine.values[key] !== '' });\n }, [engine, onAnalyticsEvent]);\n const handleCancel = useCallback(() => props.onCancel?.(), [props.onCancel]);\n\n return (\n <form ref={formRef} onFocusCapture={(event) => { focusReturn.current = event.target; }} className=\"fh-form\" tabIndex={-1} aria-busy={engine.stepValidating || engine.submitting || loading}\n onSubmit={(event) => { event.preventDefault(); void (engine.isLastStep ? actions.submit() : actions.next()); }}>\n <FormProgressController engine={engine} ProgressComponent={ProgressComponent} />\n <FormFieldsController key={definition.id} engine={engine} loading={loading} components={components}\n optionsProviders={optionsProviders} onChange={actions.update} onCommit={actions.commit}\n onBlur={handleFieldBlur} onFocus={handleFieldFocus} />\n <FormTopLevelErrors engine={engine} actionError={actions.actionError} />\n <FormActionsController engine={engine} definition={definition} loading={loading}\n ActionsComponent={ActionsComponent} onSubmit={actions.submit} onNext={actions.next}\n onPrev={actions.prev} onSkip={actions.skip} onCancel={handleCancel} />\n </form>\n );\n}\n","import type { FormField } from '@formhaus/core';\n\ninterface FieldLabelProps {\n field: FormField;\n inputId: string;\n}\n\nexport function FieldLabel({ field, inputId }: FieldLabelProps) {\n if (!field.label) return null;\n return (\n <label className=\"fh-field__label\" htmlFor={inputId}>\n {field.label}\n {field.validation?.required && (\n <span className=\"fh-field__required\" aria-hidden=\"true\"> *</span>\n )}\n </label>\n );\n}\n","import type { FormField } from '@formhaus/core';\nimport type { FieldComponentProps } from '../types';\n\nexport function describedBy(field: FormField, error?: string) {\n return [field.helperText && `${field.key}-helper`, error && `${field.key}-error`].filter(Boolean).join(' ') || undefined;\n}\n\nexport function optionProps({ disabled, loading, onBlur, onFocus }: FieldComponentProps) {\n return { disabled: disabled || loading, onBlur, onFocus };\n}\n\nexport function inputProps(props: FieldComponentProps) {\n return {\n id: props.field.key,\n ...optionProps(props),\n 'aria-invalid': !!props.error,\n 'aria-describedby': describedBy(props.field, props.error),\n };\n}\n","import type { FormField } from '@formhaus/core';\nimport type { ReactNode } from 'react';\nimport { FieldLabel } from './FieldLabel';\nimport { describedBy } from './fieldProps';\n\ninterface FieldShellProps {\n field: FormField;\n error?: string;\n variant?: 'checkbox' | 'switch' | 'radio' | 'multiselect';\n children: ReactNode;\n}\n\nexport function FieldShell({ field, error, variant, children }: FieldShellProps) {\n const group = variant === 'radio' || variant === 'multiselect';\n const inline = variant && !group;\n const Root = group ? 'fieldset' : 'div';\n const container = `fh-field__${variant}-${group ? 'group' : 'wrapper'}`;\n const helper = field.helperText && <p id={`${field.key}-helper`} className=\"fh-field__helper\">{field.helperText}</p>;\n\n return (\n <Root\n className={variant ? `fh-field fh-field--${variant}` : 'fh-field'}\n aria-invalid={group ? !!error || undefined : undefined}\n aria-describedby={group ? describedBy(field, error) : undefined}\n >\n {group && field.label && <legend className=\"fh-field__label\">{field.label}</legend>}\n {!variant && <FieldLabel field={field} inputId={field.key} />}\n {!inline && helper}\n {variant ? (\n <div className={group && field.layout === 'inline' ? `${container} ${container}--inline` : container}>\n {children}\n {inline && field.label && (\n <label className=\"fh-field__label\" htmlFor={field.key}>\n {field.label}\n </label>\n )}\n </div>\n ) : children}\n {inline && helper}\n {error && <p id={`${field.key}-error`} className=\"fh-field__error\" role=\"alert\">{error}</p>}\n </Root>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function AutocompleteField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const listId = `${field.key}-list`;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"text\"\n list={listId}\n className=\"fh-field__input fh-field__input--autocomplete\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n autoComplete=\"off\"\n onChange={(e) => onChange(e.target.value)}\n />\n <datalist id={listId}>\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </datalist>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function CheckboxField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error} variant=\"checkbox\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function DateField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"date\"\n className=\"fh-field__input fh-field__input--date\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function DateTimeField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"datetime-local\"\n className=\"fh-field__input fh-field__input--datetime\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function FileField(props: FieldComponentProps) {\n const { field, error, onChange } = props;\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"file\"\n className=\"fh-field__input fh-field__input--file\"\n accept={field.accept}\n onChange={(e) => {\n const files = e.target.files;\n onChange(files && files.length > 0 ? files[0] : null);\n }}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { optionProps } from './fieldProps';\n\nexport function MultiselectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n const selected = Array.isArray(value) ? (value as (string | number)[]) : [];\n\n function handleToggle(optValue: string) {\n const next = selected.includes(optValue)\n ? selected.filter((v) => v !== optValue)\n : [...selected, optValue];\n onChange(next);\n }\n\n return (\n <FieldShell field={field} error={error} variant=\"multiselect\">\n {options.map((opt) => {\n const optionId = `${field.key}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__multiselect-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={selected.includes(opt.value)}\n onChange={() => handleToggle(opt.value)}\n />\n <label className=\"fh-field__multiselect-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import { useRef } from 'react';\nimport type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { optionProps } from './fieldProps';\n\nexport function RadioField(props: FieldComponentProps) {\n const { field, value, error, onChange, onCommit } = props;\n const arrowSelection = useRef(false);\n const commit = field.autoAdvance && onCommit;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error} variant=\"radio\">\n {options.map((opt) => {\n const optionId = `${field.key}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__radio-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n type=\"radio\"\n className=\"fh-field__radio\"\n name={field.key}\n value={opt.value}\n checked={String(value) === String(opt.value)}\n onChange={() => { if (!commit || arrowSelection.current) onChange(opt.value); }}\n onKeyDown={(event) => {\n arrowSelection.current = event.key.startsWith('Arrow');\n if (commit && event.key === ' ') event.preventDefault();\n if (commit && event.key === 'Enter') {\n event.preventDefault();\n if (!event.repeat) commit(opt.value);\n }\n }}\n onKeyUp={(event) => {\n arrowSelection.current = false;\n if (commit && event.key === ' ') { event.preventDefault(); commit(opt.value); }\n }}\n onPointerDown={() => { arrowSelection.current = false; }}\n onClick={(event) => {\n if (!commit || arrowSelection.current) return;\n if (event.detail > 1) event.preventDefault();\n else commit(opt.value);\n }}\n />\n <label className=\"fh-field__radio-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function SelectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error}>\n <select\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--select\"\n value={(value as string) ?? ''}\n onChange={(e) => onChange(e.target.value)}\n >\n {field.placeholder && (\n <option value=\"\" disabled>\n {field.placeholder}\n </option>\n )}\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function SwitchField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error} variant=\"switch\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n role=\"switch\"\n className=\"fh-field__switch\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function TextField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n onChange(field.type === 'number' && v !== '' ? Number(v) : v);\n };\n\n const inputType =\n field.type === 'email'\n ? 'email'\n : field.type === 'phone'\n ? 'tel'\n : field.type === 'number'\n ? 'number'\n : field.type === 'password'\n ? 'password'\n : 'text';\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type={inputType}\n className=\"fh-field__input\"\n value={value != null ? String(value) : ''}\n placeholder={field.placeholder ?? field.mask}\n onChange={handleChange}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nconst DEFAULT_ROWS = 3;\n\nexport function TextareaField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n\n return (\n <FieldShell field={field} error={error}>\n <textarea\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--textarea\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n rows={field.rows ?? DEFAULT_ROWS}\n onChange={(e) => onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { DefaultFieldType } from '@formhaus/core';\nimport type { ComponentType } from 'react';\nimport { AutocompleteField } from './fields/AutocompleteField';\nimport { CheckboxField } from './fields/CheckboxField';\nimport { DateField } from './fields/DateField';\nimport { DateTimeField } from './fields/DateTimeField';\nimport { FileField } from './fields/FileField';\nimport { MultiselectField } from './fields/MultiselectField';\nimport { RadioField } from './fields/RadioField';\nimport { SelectField } from './fields/SelectField';\nimport { SwitchField } from './fields/SwitchField';\nimport { TextField } from './fields/TextField';\nimport { TextareaField } from './fields/TextareaField';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\nconst defaultFieldComponents: Record<DefaultFieldType, ComponentType<FieldComponentProps>> = {\n text: TextField,\n email: TextField,\n phone: TextField,\n number: TextField,\n password: TextField,\n select: SelectField,\n autocomplete: AutocompleteField,\n multiselect: MultiselectField,\n checkbox: CheckboxField,\n radio: RadioField,\n switch: SwitchField,\n file: FileField,\n date: DateField,\n datetime: DateTimeField,\n textarea: TextareaField,\n};\n\nexport function withDefaultFields(components?: FieldComponentMap): FieldComponentMap {\n const merged: FieldComponentMap = { ...defaultFieldComponents };\n for (const [type, component] of Object.entries(components ?? {})) {\n if (component) merged[type] = component;\n }\n return merged;\n}\n","import { useMemo } from 'react';\nimport { FormActions } from './FormActions';\nimport { FormStepProgress } from './FormStepProgress';\nimport { HeadlessFormRenderer } from './HeadlessFormRenderer';\nimport { withDefaultFields } from './defaultFieldComponents';\nimport type { FormRendererProps } from './types';\n\nexport function FormRenderer({\n components,\n ActionsComponent,\n ProgressComponent,\n ...props\n}: FormRendererProps) {\n const fieldComponents = useMemo(() => withDefaultFields(components), [components]);\n\n return (\n <HeadlessFormRenderer\n {...props}\n components={fieldComponents}\n ActionsComponent={ActionsComponent ?? FormActions}\n ProgressComponent={ProgressComponent ?? FormStepProgress}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/isActionDisabled.ts","../src/FormActions.tsx","../src/FormStepProgress.tsx","../src/hooks/useEngineSnapshot.ts","../src/FormActionsController.tsx","../src/FieldResolver.tsx","../src/FormFieldController.tsx","../src/hooks/useFieldOptions.ts","../src/FormFieldsController.tsx","../src/FormProgressController.tsx","../src/FormTopLevelErrors.tsx","../src/hooks/useFormEngine.ts","../src/hooks/useRendererActions.ts","../src/HeadlessFormRenderer.tsx","../src/fields/FieldLabel.tsx","../src/fields/fieldProps.ts","../src/fields/FieldShell.tsx","../src/fields/AutocompleteField.tsx","../src/fields/CheckboxField.tsx","../src/fields/DateField.tsx","../src/fields/DateTimeField.tsx","../src/fields/FileField.tsx","../src/fields/MultiselectField.tsx","../src/fields/RadioField.tsx","../src/fields/SelectField.tsx","../src/fields/SwitchField.tsx","../src/fields/TextField.tsx","../src/fields/TextareaField.tsx","../src/defaultFieldComponents.ts","../src/FormRenderer.tsx","../src/FormhausField.tsx"],"names":["isActionDisabled","action","values","loading","c","evaluateCondition","buttonClass","variant","FormActions","submitAction","backAction","cancelAction","skipAction","isFirstStep","isLastStep","isMultiStep","showPrimary","onSubmit","onNext","onPrev","onCancel","onSkip","primaryLabelProp","showBackProp","backLabelProp","showSkipProp","skipLabelProp","onPrimaryProp","showBack","backLabel","showSkip","skipLabel","primaryLabel","primaryDisabled","handlePrimary","jsxs","jsx","event","FormStepProgress","current","total","stepTitle","stepDescription","headingLevel","Heading","percent","useFormSnapshot","engine","subscribe","useCallback","listener","getSnapshot","useSyncExternalStore","useStructureSnapshot","FormActionsController","definition","ActionsComponent","step","noop","FieldResolver","id","field","value","error","disabled","components","onChange","onCommit","onBlur","onFocus","Component","FormFieldController","memo","formId","options","handleChange","handleCommit","handleBlur","handleFocus","fieldWithOptions","fieldDomId","areOptionsEqual","previous","next","option","index","useFieldOptions","fields","providers","resolved","setResolved","useState","requestVersions","useRef","useEffect","active","unsubscribers","commit","fieldKey","provider","resolve","requestVersion","result","dependency","unsubscribe","FormFieldsController","optionsProviders","resolvedOptions","FormProgressController","ProgressComponent","FormTopLevelErrors","actionError","errors","useFormEngineStore","initialValues","optionsRef","engineRef","definitionRef","FormEngine","useFormEngine","useRendererActions","props","onError","onFieldChange","onAnalyticsEvent","failure","setFailure","invalidAttempts","setInvalidAttempts","run","count","prev","update","key","autoAdvance","send","skippedSteps","report","submit","skip","nextKey","engineKeys","engineKey","CONTROLS","firstControl","root","HeadlessFormRenderer","actionsComponent","progressComponent","useId","formRef","focusPending","focusReturn","wasBusy","engineOptions","context","version","previousStep","actions","handledInvalid","appliedErrors","shouldApplyExternalErrors","restore","document","handleFieldFocus","handleFieldBlur","handleCancel","FieldLabel","inputId","fieldId","describedBy","optionProps","inputProps","FieldShell","children","group","inline","Root","container","helper","AutocompleteField","listId","e","opt","CheckboxField","DateField","DateTimeField","FileField","files","MultiselectField","selected","handleToggle","optValue","v","optionId","RadioField","arrowSelection","SelectField","SwitchField","TextField","isNumber","draft","setDraft","text","inputType","DEFAULT_ROWS","TextareaField","defaultFieldComponents","withDefaultFields","merged","type","component","FormRenderer","fieldComponents","useMemo","FormhausField","fallback"],"mappings":"4RAGO,SAASA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACS,CACT,OAAIA,CAAAA,CAAgB,IAAA,CAChB,CAACF,CAAAA,EAAQ,QAAA,EAAYA,CAAAA,CAAO,QAAA,CAAS,MAAA,GAAW,CAAA,CAAU,KAAA,CACvDA,CAAAA,CAAO,QAAA,CAAS,KAAA,CAAOG,GAAMC,iBAAAA,CAAkBD,CAAAA,CAAGF,CAAM,CAAC,CAClE,CCPA,SAASI,EAAYL,CAAAA,CAAwCM,CAAAA,CAAqD,CAChH,OAAO,CAAA,iDAAA,EAAqDN,CAAAA,EAAUA,CAAAA,CAAO,OAAA,EAAYM,CAAO,CAAA,CAClG,CAEO,SAASC,CAAAA,CAAY,CAC1B,aAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,EACA,WAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,QAAAZ,CAAAA,CACA,WAAA,CAAAa,CAAAA,CAAc,IAAA,CACd,MAAA,CAAAd,CAAAA,CAAS,EAAC,CACV,QAAA,CAAAe,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,SAAAC,CAAAA,CACA,MAAA,CAAAC,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AW,CAACG,CAAAA,CAAMC,CAAS,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQlJ,CAAAA,EAAc,EAAE,CAAA,CACzDkJ,CAAAA,GAAWF,CAAAA,CAAOC,CAAI,CAAA,CAAIC,GAEhC,OAAOF,CACT,CChCO,SAASG,EAAAA,CAAa,CAC3B,UAAA,CAAAnJ,CAAAA,CACA,gBAAA,CAAAkF,CAAAA,CACA,iBAAA,CAAAC,EACA,GAAG3B,CACL,CAAA,CAAsB,CACpB,IAAM4F,CAAAA,CAAkBC,QAAQ,IAAMN,CAAAA,CAAkB/I,CAAU,CAAA,CAAG,CAACA,CAAU,CAAC,CAAA,CAEjF,OACE7B,GAAAA,CAAC8G,CAAAA,CAAA,CACE,GAAGzB,CAAAA,CACJ,UAAA,CAAY4F,CAAAA,CACZ,gBAAA,CAAkBlE,CAAAA,EAAoB3I,CAAAA,CACtC,iBAAA,CAAmB4I,CAAAA,EAAqB9G,EAC1C,CAEJ,CClBO,SAASiL,EAAAA,CAAc,CAAE,UAAA,CAAAtJ,CAAAA,CAAY,EAAA,CAAAL,CAAAA,CAAI,GAAG6D,CAAM,CAAA,CAAuB,CAC9E,IAAM+F,CAAAA,CAAWnE,OAAM,CACjBgE,CAAAA,CAAkBC,OAAAA,CAAQ,IAAMN,CAAAA,CAAkB/I,CAAU,CAAA,CAAG,CAACA,CAAU,CAAC,CAAA,CACjF,OAAO7B,GAAAA,CAACuB,CAAAA,CAAA,CAAe,GAAG8D,CAAAA,CAAO,EAAA,CAAI7D,CAAAA,EAAMoB,UAAAA,CAAWwI,CAAAA,CAAU/F,CAAAA,CAAM,KAAA,CAAM,GAAG,CAAA,CAAG,UAAA,CAAY4F,CAAAA,CAAiB,CACjH","file":"index.js","sourcesContent":["import { evaluateCondition } from '@formhaus/core';\nimport type { FormAction } from '@formhaus/core';\n\nexport function isActionDisabled(\n action: FormAction | undefined,\n values: Record<string, unknown>,\n loading?: boolean,\n): boolean {\n if (loading) return true;\n if (!action?.disabled || action.disabled.length === 0) return false;\n return action.disabled.every((c) => evaluateCondition(c, values));\n}\n","import type { FormAction } from '@formhaus/core';\nimport { isActionDisabled } from './isActionDisabled';\nimport type { FormActionsProps } from './types';\n\nfunction buttonClass(action: FormAction | false | undefined, variant: NonNullable<FormAction['variant']>): string {\n return `fh-form-actions__button fh-form-actions__button--${(action && action.variant) || variant}`;\n}\n\nexport function FormActions({\n submitAction,\n backAction,\n cancelAction,\n skipAction,\n isFirstStep,\n isLastStep,\n isMultiStep,\n loading,\n showPrimary = true,\n values = {},\n onSubmit,\n onNext,\n onPrev,\n onCancel,\n onSkip,\n primaryLabel: primaryLabelProp,\n showBack: showBackProp,\n backLabel: backLabelProp,\n showSkip: showSkipProp,\n skipLabel: skipLabelProp,\n onPrimary: onPrimaryProp,\n}: FormActionsProps) {\n const showBack = showBackProp ?? (isMultiStep && !isFirstStep && backAction !== false);\n const backLabel = backLabelProp ?? (backAction || undefined)?.label ?? 'Back';\n const showSkip = showSkipProp ?? (isMultiStep && !!skipAction);\n const skipLabel = skipLabelProp ?? skipAction?.label ?? 'Skip';\n const primaryLabel = primaryLabelProp ?? (isMultiStep && !isLastStep ? 'Continue' : (submitAction?.label ?? 'Submit'));\n\n const primaryDisabled = isActionDisabled(\n isMultiStep && !isLastStep ? undefined : submitAction,\n values,\n loading,\n );\n\n const handlePrimary = onPrimaryProp ?? (isMultiStep && !isLastStep ? onNext : onSubmit);\n\n return (\n <div className=\"fh-form-actions\">\n <div className=\"fh-form-actions__secondary\">\n {showBack && (\n <button type=\"button\" className={buttonClass(backAction, 'secondary')} disabled={loading} onClick={onPrev}>\n {backLabel}\n </button>\n )}\n {cancelAction && (\n <button type=\"button\" className={buttonClass(cancelAction, 'text')} disabled={loading} onClick={onCancel}>\n {cancelAction.label}\n </button>\n )}\n {showSkip && (\n <button type=\"button\" className={buttonClass(skipAction, 'text')} disabled={loading} onClick={onSkip}>\n {skipLabel}\n </button>\n )}\n </div>\n {showPrimary && <button\n type=\"submit\"\n className=\"fh-form-actions__button fh-form-actions__button--primary\"\n disabled={primaryDisabled}\n aria-busy={loading}\n onClick={(event) => {\n event.preventDefault();\n handlePrimary();\n }}\n >\n {primaryLabel}\n </button>}\n </div>\n );\n}\n","import type { FormStepProgressProps } from './types';\n\nexport function FormStepProgress({\n current,\n total,\n stepTitle,\n stepDescription,\n headingLevel = 2,\n}: FormStepProgressProps) {\n const Heading = `h${headingLevel}` as const;\n const percent = (current / total) * 100;\n\n return (\n <div className=\"fh-step-progress\">\n <div className=\"fh-step-progress__bar\">\n <div className=\"fh-step-progress__fill\" style={{ width: `${percent}%` }} />\n </div>\n <div className=\"fh-step-progress__info\">\n <span className=\"fh-step-progress__counter\">\n Step {current} of {total}\n </span>\n </div>\n {stepTitle && <Heading className=\"fh-step-progress__title\">{stepTitle}</Heading>}\n {stepDescription && <p className=\"fh-step-progress__description\">{stepDescription}</p>}\n </div>\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nexport function useFormSnapshot(engine: FormEngine): number {\n const subscribe = useCallback((listener: () => void) => engine.subscribe(listener), [engine]);\n const getSnapshot = useCallback(() => engine.getSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useStructureSnapshot(engine: FormEngine): number {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeStructure(listener),\n [engine],\n );\n const getSnapshot = useCallback(() => engine.getStructureSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback } from 'react';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormActionsControllerProps {\n engine: FormEngine;\n definition: FormRendererProps['definition'];\n loading: boolean;\n ActionsComponent: FormRendererProps['actionsComponent'];\n onSubmit: () => void;\n onNext: () => Promise<void>;\n onPrev: () => void;\n onSkip: () => void;\n onCancel: () => void;\n}\n\nexport function FormActionsController({\n engine,\n definition,\n loading,\n ActionsComponent,\n onSubmit,\n onNext,\n onPrev,\n onSkip,\n onCancel,\n}: FormActionsControllerProps) {\n useFormSnapshot(engine);\n const step = engine.currentStep;\n const isLastStep = engine.isLastStep || !engine.isMultiStep;\n const primaryLabel = engine.isMultiStep && !isLastStep\n ? ((step?.next || undefined)?.label ?? 'Continue')\n : (definition.submit?.label ?? 'Submit');\n const showBack = engine.isMultiStep && !engine.isFirstStep && step?.back !== false;\n const backLabel = (step?.back || undefined)?.label ?? 'Back';\n const handlePrimary = useCallback(async () => {\n if (engine.isMultiStep && !isLastStep) await onNext();\n else onSubmit();\n }, [engine, isLastStep, onNext, onSubmit]);\n\n if (!ActionsComponent) return null;\n\n return (\n <ActionsComponent\n submitAction={definition.submit}\n backAction={step?.back}\n cancelAction={definition.cancel}\n skipAction={step?.skip}\n isFirstStep={engine.isFirstStep}\n isLastStep={isLastStep}\n isMultiStep={engine.isMultiStep}\n loading={loading || engine.stepValidating || engine.submitting}\n values={engine.getSubmitValues()}\n onSubmit={onSubmit}\n onNext={onNext}\n onPrev={onPrev}\n onCancel={onCancel}\n onSkip={onSkip}\n primaryLabel={primaryLabel}\n showPrimary={isLastStep || step?.next !== false}\n showBack={showBack}\n backLabel={backLabel}\n showSkip={!!step?.skip && step.next !== false}\n onPrimary={handlePrimary}\n />\n );\n}\n","import type { FormField as FormFieldType } from '@formhaus/core';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\nconst noop = () => {};\n\nexport interface FieldResolverProps {\n id?: string;\n field: FormFieldType;\n value: unknown;\n error?: string;\n loading?: boolean;\n disabled?: boolean;\n components?: FieldComponentMap;\n onChange: (value: unknown) => void;\n onCommit?: (value: unknown) => void;\n onBlur?: () => void;\n onFocus?: () => void;\n}\n\nexport function FieldResolver({\n id,\n field,\n value,\n error,\n loading,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FieldResolverProps) {\n const Component = components?.[field.type];\n\n if (!Component) {\n return <div>Unsupported field type: {field.type}</div>;\n }\n\n return (\n <Component\n id={id}\n field={field}\n value={value}\n error={error}\n loading={loading}\n disabled={disabled}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur ?? noop}\n onFocus={onFocus}\n />\n );\n}\n","import { fieldDomId } from '@formhaus/core/internal';\nimport type { FieldOption, FormEngine, FormField as FormFieldType } from '@formhaus/core';\nimport { memo, useCallback, useSyncExternalStore } from 'react';\nimport { FieldResolver } from './FieldResolver';\nimport type { FieldComponentMap } from './types';\n\nexport interface ControllerProps {\n engine: FormEngine;\n formId: string;\n components?: FieldComponentMap;\n onChange: (key: string, value: unknown) => void;\n onCommit: (key: string, value: unknown) => void;\n onBlur: (key: string) => void;\n onFocus: (key: string) => void;\n}\n\ninterface FormFieldControllerProps extends ControllerProps {\n field: FormFieldType;\n options?: FieldOption[];\n disabled?: boolean;\n}\n\nexport const FormFieldController = memo(function FormFieldController({\n engine,\n formId,\n field,\n options,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldControllerProps) {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeField(field.key, listener),\n [engine, field.key],\n );\n const getSnapshot = useCallback(\n () => engine.getFieldSnapshot(field.key),\n [engine, field.key],\n );\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const handleChange = useCallback(\n (value: unknown) => onChange(field.key, value),\n [field.key, onChange],\n );\n const handleCommit = useCallback((value: unknown) => onCommit(field.key, value), [field.key, onCommit]);\n const handleBlur = useCallback(() => onBlur(field.key), [field.key, onBlur]);\n const handleFocus = useCallback(() => onFocus(field.key), [field.key, onFocus]);\n const fieldWithOptions = options ? { ...field, options } : field;\n\n return (\n <FieldResolver\n id={fieldDomId(formId, field.key)}\n field={fieldWithOptions}\n value={engine.values[field.key]}\n error={engine.errors[field.key]}\n loading={engine.fieldLoading[field.key]}\n disabled={disabled}\n components={components}\n onChange={handleChange}\n onCommit={handleCommit}\n onBlur={handleBlur}\n onFocus={handleFocus}\n />\n );\n});\n","import type { FieldOption, FormEngine, FormField } from '@formhaus/core';\nimport { useEffect, useRef, useState } from 'react';\nimport type { OptionsProvider } from '../types';\n\nfunction areOptionsEqual(previous: FieldOption[] | undefined, next: FieldOption[]): boolean {\n return previous?.length === next.length && previous.every((option, index) => (\n option.value === next[index].value && option.label === next[index].label\n ));\n}\n\nexport function useFieldOptions(\n fields: FormField[],\n engine: FormEngine,\n providers?: Record<string, OptionsProvider>,\n): Record<string, FieldOption[]> {\n const [resolved, setResolved] = useState<Record<string, FieldOption[]>>({});\n const requestVersions = useRef<Map<string, number>>(new Map());\n\n useEffect(() => {\n if (!providers) {\n setResolved((previous) => (\n Object.keys(previous).length > 0 ? {} : previous\n ));\n return;\n }\n\n let active = true;\n const unsubscribers: (() => void)[] = [];\n\n const commit = (fieldKey: string, options: FieldOption[]) => {\n if (!active) return;\n setResolved((previous) => {\n if (areOptionsEqual(previous[fieldKey], options)) return previous;\n return { ...previous, [fieldKey]: options };\n });\n };\n\n for (const field of fields) {\n if (!field.optionsFrom) continue;\n\n const provider = providers[field.optionsFrom];\n if (!provider) continue;\n\n const resolve = () => {\n const requestVersion = (requestVersions.current.get(field.key) ?? 0) + 1;\n requestVersions.current.set(field.key, requestVersion);\n\n try {\n const result = provider(engine.values);\n if (Array.isArray(result)) {\n commit(field.key, result);\n return;\n }\n\n result\n .then((options) => {\n if (requestVersions.current.get(field.key) === requestVersion) {\n commit(field.key, options);\n }\n })\n .catch(() => {});\n } catch {}\n };\n\n resolve();\n for (const dependency of new Set(field.optionsDependsOn ?? [])) {\n unsubscribers.push(engine.subscribeField(dependency, resolve));\n }\n }\n\n return () => {\n active = false;\n for (const unsubscribe of unsubscribers) unsubscribe();\n };\n }, [engine, fields, providers]);\n\n return resolved;\n}\n","import { memo } from 'react';\nimport { type ControllerProps, FormFieldController } from './FormFieldController';\nimport { useFormSnapshot, useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport { useFieldOptions } from './hooks/useFieldOptions';\nimport type { OptionsProvider } from './types';\n\ninterface FormFieldsControllerProps extends ControllerProps {\n loading: boolean;\n optionsProviders?: Record<string, OptionsProvider>;\n}\n\nexport const FormFieldsController = memo(function FormFieldsController({\n engine,\n formId,\n loading,\n components,\n optionsProviders,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldsControllerProps) {\n useStructureSnapshot(engine);\n useFormSnapshot(engine);\n const fields = engine.visibleFields;\n const resolvedOptions = useFieldOptions(fields, engine, optionsProviders);\n\n return (\n <div className=\"fh-form__fields\">\n {fields.map((field) => (\n <FormFieldController\n key={field.key}\n engine={engine}\n formId={formId}\n field={field}\n options={resolvedOptions[field.key] ?? field.options}\n disabled={loading || engine.stepValidating || engine.submitting}\n components={components}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n ))}\n </div>\n );\n});\n","import type { FormEngine } from '@formhaus/core';\nimport { useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormProgressControllerProps {\n engine: FormEngine;\n ProgressComponent: FormRendererProps['progressComponent'];\n headingLevel: FormRendererProps['headingLevel'];\n}\n\nexport function FormProgressController({\n engine,\n ProgressComponent,\n headingLevel,\n}: FormProgressControllerProps) {\n useStructureSnapshot(engine);\n if (!engine.isMultiStep || !ProgressComponent) return null;\n\n return (\n <ProgressComponent\n current={engine.progress.current}\n total={engine.progress.total}\n stepTitle={engine.currentStep?.title}\n stepDescription={engine.currentStep?.description}\n headingLevel={headingLevel}\n />\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\n\nexport function FormTopLevelErrors({ engine, actionError }: { engine: FormEngine; actionError?: string | null }) {\n useFormSnapshot(engine);\n const errors = actionError ? [...engine.topLevelErrors, actionError] : engine.topLevelErrors;\n if (errors.length === 0) return null;\n\n return (\n <div className=\"fh-form__top-errors\">\n {errors.map((error, index) => (\n <p key={index} className=\"fh-form__top-error\">\n {error}\n </p>\n ))}\n </div>\n );\n}\n","import { FormEngine, type FormEngineOptions, type FormDefinition } from '@formhaus/core';\nimport { useEffect, useRef } from 'react';\nimport { useFormSnapshot } from './useEngineSnapshot';\n\nexport function useFormEngineStore(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const engineRef = useRef<FormEngine | null>(null);\n const definitionRef = useRef(definition);\n\n if (engineRef.current === null || definitionRef.current !== definition) {\n engineRef.current = new FormEngine(definition, initialValues, {\n validators: options?.validators,\n get onStepValidate() { return optionsRef.current?.onStepValidate; },\n get onBeforeStepChange() { return optionsRef.current?.onBeforeStepChange; },\n get onAfterStepChange() { return optionsRef.current?.onAfterStepChange; },\n get onBeforeSubmit() { return optionsRef.current?.onBeforeSubmit; },\n get onAfterSubmit() { return optionsRef.current?.onAfterSubmit; },\n onWarning: options?.onWarning,\n });\n definitionRef.current = definition;\n }\n\n const engine = engineRef.current;\n useEffect(() => () => engine.cancelPendingActions(), [engine]);\n return engine;\n}\n\nexport function useFormEngine(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const engine = useFormEngineStore(definition, initialValues, options);\n useFormSnapshot(engine);\n return engine;\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { autoAdvance } from '@formhaus/core/internal';\nimport { useCallback, useState } from 'react';\nimport { isActionDisabled } from '../isActionDisabled';\nimport type { FormRendererProps } from '../types';\n\nexport function useRendererActions(engine: FormEngine, props: FormRendererProps) {\n const { loading, onError, onFieldChange, onSubmit, onAnalyticsEvent } = props;\n const [failure, setFailure] = useState<{ engine: FormEngine; message: string } | null>(null);\n const [invalidAttempts, setInvalidAttempts] = useState(0);\n const run = useCallback(async (action: () => Promise<boolean>) => {\n if (loading) return;\n setFailure(null);\n const errors = engine.errors;\n try { if (!(await action()) && engine.errors !== errors && Object.keys(engine.errors).length > 0) setInvalidAttempts((count) => count + 1); }\n catch (error) {\n if (onError) onError(error);\n else setFailure({ engine, message: error instanceof Error ? error.message : 'Form action failed' });\n }\n }, [engine, loading, onError]);\n const next = useCallback(() => run(() => engine.next()), [run, engine]);\n const prev = useCallback(() => run(() => engine.back()), [run, engine]);\n const update = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n engine.setValue(key, value);\n onFieldChange?.(key, value, engine.values);\n }, [engine, loading, onFieldChange]);\n const commit = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n const step = engine.currentStep;\n const field = engine.visibleFields.find((field) => field.key === key);\n if (!field) return;\n update(key, value);\n if (field.autoAdvance && engine.currentStep?.id === step?.id && !engine.isLastStep) void run(() => autoAdvance(engine));\n }, [engine, loading, run, update]);\n const send = useCallback(async (values: Record<string, unknown>, skippedSteps: string[]) => {\n onAnalyticsEvent?.({ type: 'form_submitted', fieldCount: Object.keys(values).length });\n await onSubmit(values, skippedSteps);\n }, [onSubmit, onAnalyticsEvent]);\n const report = useCallback(async (action: Promise<boolean>) => {\n const result = await action;\n if (!result) {\n for (const [key, error] of Object.entries(engine.errors)) {\n onAnalyticsEvent?.({ type: 'field_error', fieldKey: key, error });\n }\n }\n return result;\n }, [engine, onAnalyticsEvent]);\n const submit = useCallback(() => run(async () => (\n !isActionDisabled(engine.definition.submit, engine.getSubmitValues()) && report(engine.submit(send))\n )), [engine, run, send, report]);\n const skip = useCallback(() => run(() => report(engine.skip((values, skippedSteps) => {\n onAnalyticsEvent?.({ type: 'step_skipped', stepId: engine.currentStep!.id });\n return send(values, skippedSteps);\n }))), [run, engine, send, report, onAnalyticsEvent]);\n const actionError = failure?.engine === engine ? failure.message : null;\n return { next, prev, skip, update, commit, submit, actionError, invalidAttempts };\n}\n","import type { FormEngineOptions } from '@formhaus/core';\nimport { shouldApplyExternalErrors } from '@formhaus/core/internal';\nimport { useCallback, useEffect, useId, useRef } from 'react';\nimport { FormActionsController } from './FormActionsController';\nimport { FormFieldsController } from './FormFieldsController';\nimport { FormProgressController } from './FormProgressController';\nimport { FormTopLevelErrors } from './FormTopLevelErrors';\nimport { useFormEngineStore } from './hooks/useFormEngine';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport { useRendererActions } from './hooks/useRendererActions';\nimport type { FormRendererProps } from './types';\n\nlet nextKey = 0;\nconst engineKeys = new WeakMap<object, number>();\n\nfunction engineKey(engine: object): number {\n let key = engineKeys.get(engine);\n if (key === undefined) engineKeys.set(engine, key = nextKey++);\n return key;\n}\n\nconst CONTROLS = 'input:not(:disabled), select:not(:disabled), textarea:not(:disabled), button:not(:disabled)';\n\nfunction firstControl(root: Element | null | undefined) {\n return root?.matches(CONTROLS) ? root : root?.querySelector(CONTROLS);\n}\n\nexport function HeadlessFormRenderer(props: FormRendererProps) {\n const { definition, initialValues, loading = false, components, optionsProviders,\n actionsComponent, progressComponent, headingLevel = 2, onAnalyticsEvent } = props;\n const formId = useId();\n const formRef = useRef<HTMLFormElement>(null);\n const focusPending = useRef(false);\n const focusReturn = useRef<HTMLElement | null>(null);\n const wasBusy = useRef(false);\n const engineOptions: FormEngineOptions = {\n ...props,\n onAfterStepChange: async (context) => {\n focusPending.current = true;\n if (context.reason !== 'back') {\n onAnalyticsEvent?.({ type: context.reason === 'skip' ? 'step_skipped' : 'step_completed', stepId: context.fromStepId });\n onAnalyticsEvent?.({ type: 'step_viewed', stepId: context.toStepId, stepIndex: engine.currentStepIndex });\n }\n await props.onAfterStepChange?.(context);\n },\n };\n const engine = useFormEngineStore(definition, initialValues, engineOptions);\n const version = useFormSnapshot(engine);\n const previousStep = useRef(engine.currentStep?.id);\n const actions = useRendererActions(engine, props);\n const handledInvalid = useRef(0);\n\n const appliedErrors = useRef<{ engine: typeof engine; errors: Record<string, string> } | null>(null);\n useEffect(() => {\n if (!props.errors) return;\n const previous = appliedErrors.current?.engine === engine ? appliedErrors.current.errors : undefined;\n if (!shouldApplyExternalErrors(engine, previous, props.errors)) return;\n appliedErrors.current = { engine, errors: props.errors };\n engine.setErrors(props.errors);\n }, [props.errors, engine]);\n\n useEffect(() => {\n if (previousStep.current !== engine.currentStep?.id || handledInvalid.current !== actions.invalidAttempts) focusPending.current = true;\n previousStep.current = engine.currentStep?.id;\n handledInvalid.current = actions.invalidAttempts;\n if (engine.stepValidating || engine.submitting) {\n wasBusy.current = true;\n return;\n }\n const restore = wasBusy.current;\n wasBusy.current = false;\n if (!focusPending.current) {\n const document = formRef.current?.ownerDocument;\n if (restore && document?.activeElement === document?.body && focusReturn.current?.isConnected) focusReturn.current.focus();\n return;\n }\n focusPending.current = false;\n const fields = formRef.current?.querySelector('.fh-form__fields');\n const target = firstControl(fields?.querySelector('[aria-invalid=\"true\"]')) ?? firstControl(fields);\n ((target as HTMLElement | null | undefined) ?? formRef.current)?.focus();\n }, [engine, version, actions.invalidAttempts]);\n\n const handleFieldFocus = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_focused', fieldKey: key });\n }, [onAnalyticsEvent]);\n const handleFieldBlur = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_blurred', fieldKey: key,\n hasValue: engine.values[key] !== undefined && engine.values[key] !== '' });\n }, [engine, onAnalyticsEvent]);\n const handleCancel = useCallback(() => props.onCancel?.(), [props.onCancel]);\n\n return (\n <form ref={formRef} onFocusCapture={(event) => { focusReturn.current = event.target; }} className=\"fh-form\" tabIndex={-1} aria-busy={engine.stepValidating || engine.submitting || loading}\n onSubmit={(event) => { event.preventDefault(); void (engine.isLastStep ? actions.submit() : actions.next()); }}>\n <FormProgressController engine={engine} ProgressComponent={progressComponent} headingLevel={headingLevel} />\n <FormFieldsController key={engineKey(engine)} engine={engine} formId={formId} loading={loading} components={components}\n optionsProviders={optionsProviders} onChange={actions.update} onCommit={actions.commit}\n onBlur={handleFieldBlur} onFocus={handleFieldFocus} />\n <FormTopLevelErrors engine={engine} actionError={actions.actionError} />\n <FormActionsController engine={engine} definition={definition} loading={loading}\n ActionsComponent={actionsComponent} onSubmit={actions.submit} onNext={actions.next}\n onPrev={actions.prev} onSkip={actions.skip} onCancel={handleCancel} />\n </form>\n );\n}\n","import type { FormField } from '@formhaus/core';\n\ninterface FieldLabelProps {\n field: FormField;\n inputId: string;\n}\n\nexport function FieldLabel({ field, inputId }: FieldLabelProps) {\n if (!field.label) return null;\n return (\n <label className=\"fh-field__label\" htmlFor={inputId}>\n {field.label}\n {field.validation?.required && (\n <span className=\"fh-field__required\" aria-hidden=\"true\"> *</span>\n )}\n </label>\n );\n}\n","import { fieldDomId } from '@formhaus/core/internal';\nimport type { FormField } from '@formhaus/core';\nimport type { FieldComponentProps } from '../types';\n\nexport function fieldId(props: Pick<FieldComponentProps, 'id' | 'field'>): string {\n return props.id ?? fieldDomId(undefined, props.field.key);\n}\n\nexport function describedBy(field: FormField, id: string, error?: string) {\n return [field.helperText && `${id}-helper`, error && `${id}-error`].filter(Boolean).join(' ') || undefined;\n}\n\nexport function optionProps({ disabled, loading, onBlur, onFocus }: FieldComponentProps) {\n return { disabled: disabled || loading, onBlur, onFocus };\n}\n\nexport function inputProps(props: FieldComponentProps) {\n const id = fieldId(props);\n return {\n id,\n name: props.field.key,\n ...optionProps(props),\n 'aria-invalid': !!props.error,\n 'aria-required': !!props.field.validation?.required || undefined,\n 'aria-describedby': describedBy(props.field, id, props.error),\n };\n}\n","import type { FormField } from '@formhaus/core';\nimport type { ReactNode } from 'react';\nimport { FieldLabel } from './FieldLabel';\nimport { describedBy } from './fieldProps';\n\ninterface FieldShellProps {\n id: string;\n field: FormField;\n error?: string;\n variant?: 'checkbox' | 'switch' | 'radio' | 'multiselect';\n children: ReactNode;\n}\n\nexport function FieldShell({ id, field, error, variant, children }: FieldShellProps) {\n const group = variant === 'radio' || variant === 'multiselect';\n const inline = variant && !group;\n const Root = group ? 'fieldset' : 'div';\n const container = `fh-field__${variant}-${group ? 'group' : 'wrapper'}`;\n const helper = field.helperText && <p id={`${id}-helper`} className=\"fh-field__helper\">{field.helperText}</p>;\n\n return (\n <Root\n className={variant ? `fh-field fh-field--${variant}` : 'fh-field'}\n aria-invalid={group ? !!error || undefined : undefined}\n aria-describedby={group ? describedBy(field, id, error) : undefined}\n >\n {group && field.label && <legend className=\"fh-field__label\">{field.label}</legend>}\n {!variant && <FieldLabel field={field} inputId={id} />}\n {!inline && helper}\n {variant ? (\n <div className={group && field.layout === 'inline' ? `${container} ${container}--inline` : container}>\n {children}\n {inline && field.label && (\n <label className=\"fh-field__label\" htmlFor={id}>\n {field.label}\n </label>\n )}\n </div>\n ) : children}\n {inline && helper}\n {error && <p id={`${id}-error`} className=\"fh-field__error\" role=\"alert\">{error}</p>}\n </Root>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function AutocompleteField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const listId = `${fieldId(props)}-list`;\n const options = field.options ?? [];\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"text\"\n list={listId}\n className=\"fh-field__input fh-field__input--autocomplete\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n autoComplete=\"off\"\n onChange={(e) => onChange(e.target.value)}\n />\n <datalist id={listId}>\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </datalist>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function CheckboxField(props: FieldComponentProps) {\n return (\n <FieldShell id={fieldId(props)} field={props.field} error={props.error} variant=\"checkbox\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function DateField(props: FieldComponentProps) {\n return (\n <FieldShell id={fieldId(props)} field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"date\"\n className=\"fh-field__input fh-field__input--date\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function DateTimeField(props: FieldComponentProps) {\n return (\n <FieldShell id={fieldId(props)} field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"datetime-local\"\n className=\"fh-field__input fh-field__input--datetime\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function FileField(props: FieldComponentProps) {\n const { field, error, onChange } = props;\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"file\"\n className=\"fh-field__input fh-field__input--file\"\n accept={field.accept}\n onChange={(e) => {\n const files = e.target.files;\n onChange(files && files.length > 0 ? files[0] : null);\n }}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, optionProps } from './fieldProps';\n\nexport function MultiselectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n const selected = Array.isArray(value) ? (value as (string | number)[]) : [];\n\n function handleToggle(optValue: string) {\n const next = selected.includes(optValue)\n ? selected.filter((v) => v !== optValue)\n : [...selected, optValue];\n onChange(next);\n }\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error} variant=\"multiselect\">\n {options.map((opt, index) => {\n const optionId = `${fieldId(props)}-${index}`;\n return (\n <div key={opt.value} className=\"fh-field__multiselect-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n name={field.key}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={selected.includes(opt.value)}\n onChange={() => handleToggle(opt.value)}\n />\n <label className=\"fh-field__multiselect-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import { useRef } from 'react';\nimport type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, optionProps } from './fieldProps';\n\nexport function RadioField(props: FieldComponentProps) {\n const { field, value, error, onChange, onCommit } = props;\n const arrowSelection = useRef(false);\n const commit = field.autoAdvance && onCommit;\n const options = field.options ?? [];\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error} variant=\"radio\">\n {options.map((opt, index) => {\n const optionId = `${fieldId(props)}-${index}`;\n return (\n <div key={opt.value} className=\"fh-field__radio-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n type=\"radio\"\n className=\"fh-field__radio\"\n name={field.key}\n value={opt.value}\n checked={String(value) === String(opt.value)}\n onChange={() => { if (!commit || arrowSelection.current) onChange(opt.value); }}\n onKeyDown={(event) => {\n arrowSelection.current = event.key.startsWith('Arrow');\n if (commit && event.key === ' ') event.preventDefault();\n if (commit && event.key === 'Enter') {\n event.preventDefault();\n if (!event.repeat) commit(opt.value);\n }\n }}\n onKeyUp={(event) => {\n arrowSelection.current = false;\n if (commit && event.key === ' ') { event.preventDefault(); commit(opt.value); }\n }}\n onPointerDown={() => { arrowSelection.current = false; }}\n onClick={(event) => {\n if (!commit || arrowSelection.current) return;\n if (event.detail > 1) event.preventDefault();\n else commit(opt.value);\n }}\n />\n <label className=\"fh-field__radio-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function SelectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error}>\n <select\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--select\"\n value={(value as string) ?? ''}\n onChange={(e) => onChange(e.target.value)}\n >\n {field.placeholder && (\n <option value=\"\" disabled>\n {field.placeholder}\n </option>\n )}\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function SwitchField(props: FieldComponentProps) {\n return (\n <FieldShell id={fieldId(props)} field={props.field} error={props.error} variant=\"switch\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n role=\"switch\"\n className=\"fh-field__switch\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import { useState } from 'react';\nimport type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nexport function TextField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const isNumber = field.type === 'number';\n const [draft, setDraft] = useState('');\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n setDraft(v);\n onChange(isNumber && v !== '' ? Number(v) : v);\n };\n\n const text = isNumber && draft && Object.is(Number(draft), value) ? draft : String(value ?? '');\n\n const inputType =\n field.type === 'email'\n ? 'email'\n : field.type === 'phone'\n ? 'tel'\n : isNumber\n ? 'number'\n : field.type === 'password'\n ? 'password'\n : 'text';\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error}>\n <input\n {...inputProps(props)}\n type={inputType}\n className=\"fh-field__input\"\n value={text}\n placeholder={field.placeholder ?? field.mask}\n inputMode={field.inputMode}\n onChange={handleChange}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { fieldId, inputProps } from './fieldProps';\n\nconst DEFAULT_ROWS = 3;\n\nexport function TextareaField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n\n return (\n <FieldShell id={fieldId(props)} field={field} error={error}>\n <textarea\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--textarea\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n rows={field.rows ?? DEFAULT_ROWS}\n onChange={(e) => onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { DefaultFieldType } from '@formhaus/core';\nimport type { ComponentType } from 'react';\nimport { AutocompleteField } from './fields/AutocompleteField';\nimport { CheckboxField } from './fields/CheckboxField';\nimport { DateField } from './fields/DateField';\nimport { DateTimeField } from './fields/DateTimeField';\nimport { FileField } from './fields/FileField';\nimport { MultiselectField } from './fields/MultiselectField';\nimport { RadioField } from './fields/RadioField';\nimport { SelectField } from './fields/SelectField';\nimport { SwitchField } from './fields/SwitchField';\nimport { TextField } from './fields/TextField';\nimport { TextareaField } from './fields/TextareaField';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\nexport const defaultFieldComponents: Record<DefaultFieldType, ComponentType<FieldComponentProps>> = {\n text: TextField,\n email: TextField,\n phone: TextField,\n number: TextField,\n password: TextField,\n select: SelectField,\n autocomplete: AutocompleteField,\n multiselect: MultiselectField,\n checkbox: CheckboxField,\n radio: RadioField,\n switch: SwitchField,\n file: FileField,\n date: DateField,\n datetime: DateTimeField,\n textarea: TextareaField,\n};\n\nexport function withDefaultFields(components?: FieldComponentMap): FieldComponentMap {\n const merged: FieldComponentMap = { ...defaultFieldComponents };\n for (const [type, component] of Object.entries(components ?? {})) {\n if (component) merged[type] = component;\n }\n return merged;\n}\n","import { useMemo } from 'react';\nimport { FormActions } from './FormActions';\nimport { FormStepProgress } from './FormStepProgress';\nimport { HeadlessFormRenderer } from './HeadlessFormRenderer';\nimport { withDefaultFields } from './defaultFieldComponents';\nimport type { FormRendererProps } from './types';\n\nexport function FormRenderer({\n components,\n actionsComponent,\n progressComponent,\n ...props\n}: FormRendererProps) {\n const fieldComponents = useMemo(() => withDefaultFields(components), [components]);\n\n return (\n <HeadlessFormRenderer\n {...props}\n components={fieldComponents}\n actionsComponent={actionsComponent ?? FormActions}\n progressComponent={progressComponent ?? FormStepProgress}\n />\n );\n}\n","import { fieldDomId } from '@formhaus/core/internal';\nimport { useId, useMemo } from 'react';\nimport { withDefaultFields } from './defaultFieldComponents';\nimport { FieldResolver, type FieldResolverProps } from './FieldResolver';\n\nexport function FormhausField({ components, id, ...props }: FieldResolverProps) {\n const fallback = useId();\n const fieldComponents = useMemo(() => withDefaultFields(components), [components]);\n return <FieldResolver {...props} id={id ?? fieldDomId(fallback, props.field.key)} components={fieldComponents} />;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formhaus/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Render multi-step, conditional and branching forms in React from a JSON form definition. Native inputs or your own components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=20"
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
@@ -20,11 +20,9 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@formhaus/core": "0.10.0"
|
|
25
|
-
},
|
|
26
23
|
"peerDependencies": {
|
|
27
|
-
"
|
|
24
|
+
"@formhaus/core": "^0.11.0",
|
|
25
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
28
26
|
},
|
|
29
27
|
"devDependencies": {
|
|
30
28
|
"@testing-library/react": "^16.3.2",
|
|
@@ -35,7 +33,8 @@
|
|
|
35
33
|
"react-dom": "^19.2.4",
|
|
36
34
|
"tsup": "^8.5.1",
|
|
37
35
|
"typescript": "^5.7.3",
|
|
38
|
-
"vitest": "^4.1.3"
|
|
36
|
+
"vitest": "^4.1.3",
|
|
37
|
+
"@formhaus/core": "0.11.0"
|
|
39
38
|
},
|
|
40
39
|
"license": "MIT",
|
|
41
40
|
"homepage": "https://formhaus.dev",
|