@formhaus/react 0.11.3 → 0.12.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/dist/cloud.d.ts CHANGED
@@ -3,7 +3,7 @@ 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, SubmitFn, ValidatorFn, StepValidateFn, FieldType, FieldOption, FormAction, FormAnalyticsEvent } from '@formhaus/core';
6
+ import { FormEngineOptions, FormDefinition, SubmitHandler, 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 {
@@ -44,23 +44,31 @@ interface FormActionsProps {
44
44
  onPrimary?: () => void;
45
45
  }
46
46
  type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
47
+ interface FormStepStatus {
48
+ id: string;
49
+ title?: string;
50
+ errorCount: number;
51
+ }
47
52
  interface FormStepProgressProps {
48
53
  current: number;
49
54
  total: number;
50
55
  stepTitle?: string;
51
56
  stepDescription?: string;
52
57
  headingLevel?: HeadingLevel;
58
+ steps?: FormStepStatus[];
53
59
  }
54
60
  interface FormRendererProps extends FormEngineOptions {
55
61
  onError?: (error: unknown) => void;
56
62
  definition: FormDefinition;
57
63
  initialValues?: Record<string, unknown>;
58
- onSubmit: SubmitFn;
64
+ onSubmit: SubmitHandler;
59
65
  onCancel?: () => void;
60
66
  onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
61
67
  validators?: Record<string, ValidatorFn>;
62
68
  onStepValidate?: StepValidateFn;
63
69
  errors?: Record<string, string>;
70
+ errorSummary?: boolean;
71
+ stepErrorMarks?: boolean;
64
72
  loading?: boolean;
65
73
  components?: FieldComponentMap;
66
74
  optionsProviders?: Record<string, OptionsProvider>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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, SubmitFn, ValidatorFn, StepValidateFn, FieldOption, FormAnalyticsEvent, FormField, DefaultFieldType, FormEngine } from '@formhaus/core';
3
+ import { FieldType, FormAction, FormEngineOptions, FormDefinition, SubmitHandler, 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[]>;
@@ -42,23 +42,31 @@ interface FormActionsProps {
42
42
  onPrimary?: () => void;
43
43
  }
44
44
  type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
45
+ interface FormStepStatus {
46
+ id: string;
47
+ title?: string;
48
+ errorCount: number;
49
+ }
45
50
  interface FormStepProgressProps {
46
51
  current: number;
47
52
  total: number;
48
53
  stepTitle?: string;
49
54
  stepDescription?: string;
50
55
  headingLevel?: HeadingLevel;
56
+ steps?: FormStepStatus[];
51
57
  }
52
58
  interface FormRendererProps extends FormEngineOptions {
53
59
  onError?: (error: unknown) => void;
54
60
  definition: FormDefinition;
55
61
  initialValues?: Record<string, unknown>;
56
- onSubmit: SubmitFn;
62
+ onSubmit: SubmitHandler;
57
63
  onCancel?: () => void;
58
64
  onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
59
65
  validators?: Record<string, ValidatorFn>;
60
66
  onStepValidate?: StepValidateFn;
61
67
  errors?: Record<string, string>;
68
+ errorSummary?: boolean;
69
+ stepErrorMarks?: boolean;
62
70
  loading?: boolean;
63
71
  components?: FieldComponentMap;
64
72
  optionsProviders?: Record<string, OptionsProvider>;
@@ -114,8 +122,8 @@ declare function TextareaField(props: FieldComponentProps): react_jsx_runtime.JS
114
122
 
115
123
  declare function TextField(props: FieldComponentProps): react_jsx_runtime.JSX.Element;
116
124
 
117
- declare function FormStepProgress({ current, total, stepTitle, stepDescription, headingLevel, }: FormStepProgressProps): react_jsx_runtime.JSX.Element;
125
+ declare function FormStepProgress({ current, total, stepTitle, stepDescription, headingLevel, steps, }: FormStepProgressProps): react_jsx_runtime.JSX.Element;
118
126
 
119
127
  declare function useFormEngine(definition: FormDefinition, initialValues?: Record<string, unknown>, options?: FormEngineOptions): FormEngine;
120
128
 
121
- 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 };
129
+ export { AutocompleteField, CheckboxField, DateField, DateTimeField, type FieldComponentMap, type FieldComponentProps, FileField, FormActions, type FormActionsProps, FormRenderer, type FormRendererProps, FormStepProgress, type FormStepProgressProps, type FormStepStatus, 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
- 'use client';import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useId,useMemo}from'react';import {isActionDisabled,FormEngine}from'@formhaus/core';import {jsx,jsxs}from'react/jsx-runtime';import {fieldDomId,shouldApplyExternalErrors,autoAdvance}from'@formhaus/core/internal';function U(e,o){return `fh-form-actions__button fh-form-actions__button--${e&&e.variant||o}`}function z({submitAction:e,nextAction:o,backAction:t,cancelAction:r,skipAction:s,isFirstStep:l,isLastStep:i,isMultiStep:a,loading:p,showPrimary:n=true,values:u={},onSubmit:d,onNext:m,onPrev:C,onCancel:S,onSkip:w,primaryLabel:c,showBack:_,backLabel:P,showSkip:v,skipLabel:I,onPrimary:y}){let g=_??(a&&!l&&t!==false),k=P??(t||void 0)?.label??"Back",R=v??(a&&!!s),F=I??s?.label??"Skip",M=c??(a&&!i?"Continue":e?.label??"Submit"),ce=!!p||isActionDisabled(a&&!i?o:e,u),B=y??(a&&!i?m:d);return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[g&&jsx("button",{type:"button",className:U(t,"secondary"),disabled:p,onClick:C,children:k}),r&&jsx("button",{type:"button",className:U(r,"text"),disabled:p,onClick:S,children:r.label}),R&&jsx("button",{type:"button",className:U(s,"text"),disabled:p,onClick:w,children:F})]}),n&&jsx("button",{type:"submit",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:ce,"aria-busy":p,onClick:He=>{He.preventDefault(),B();},children:M})]})}function G({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 q(e){let o=useCallback(r=>e.subscribeStructure(r),[e]),t=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,t,t)}function ye({engine:e,definition:o,loading:t,ActionsComponent:r,onSubmit:s,onNext:l,onPrev:i,onSkip:a,onCancel:p}){x(e);let n=e.currentStep,u=e.isLastStep||!e.isMultiStep,d=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,nextAction:n?.next,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:p,onSkip:a,primaryLabel:d,showPrimary:u||n?.next!==false,showBack:m,backLabel:C,showSkip:!!n?.skip&&n.next!==false,onPrimary:S}):null}var ze=()=>{};function H({id:e,field:o,value:t,error:r,loading:s,disabled:l,components:i,onChange:a,onCommit:p,onBlur:n,onFocus:u}){let d=i?.[o.type];return d?jsx(d,{id:e,field:o,value:t,error:r,loading:s,disabled:l,onChange:a,onCommit:p,onBlur:n??ze,onFocus:u}):jsxs("div",{children:["Unsupported field type: ",o.type]})}var be=memo(function({engine:o,formId:t,field:r,options:s,disabled:l,components:i,onChange:a,onCommit:p,onBlur:n,onFocus:u}){let d=useCallback(P=>o.subscribeField(r.key,P),[o,r.key]),m=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(d,m,m);let C=useCallback(P=>a(r.key,P),[r.key,a]),S=useCallback(P=>p(r.key,P),[r.key,p]),w=useCallback(()=>n(r.key),[r.key,n]),c=useCallback(()=>u(r.key),[r.key,u]),_=s?{...r,options:s}:r;return jsx(H,{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 ro(e,o){return e?.length===o.length&&e.every((t,r)=>t.value===o[r].value&&t.label===o[r].label)}function ge(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=[],p=(n,u)=>{i&&s(d=>ro(d[n],u)?d:{...d,[n]:u});};for(let n of e){if(!n.optionsFrom)continue;let u=t[n.optionsFrom];if(!u)continue;let d=()=>{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)){p(n.key,C);return}C.then(S=>{l.current.get(n.key)===m&&p(n.key,S);}).catch(()=>{});}catch{}};d();for(let m of new Set(n.optionsDependsOn??[]))a.push(o.subscribeField(m,d));}return ()=>{i=false;for(let n of a)n();}},[o,e,t]),r}var Ce=memo(function({engine:o,formId:t,loading:r,components:s,optionsProviders:l,onChange:i,onCommit:a,onBlur:p,onFocus:n}){q(o),x(o);let u=o.visibleFields,d=ge(u,o,l);return jsx("div",{className:"fh-form__fields",children:u.map(m=>jsx(be,{engine:o,formId:t,field:m,options:d[m.key]??m.options,disabled:r||o.stepValidating||o.submitting,components:s,onChange:i,onCommit:a,onBlur:p,onFocus:n},m.key))})});function Se({engine:e,ProgressComponent:o,headingLevel:t}){return q(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 Pe({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 Q(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 so(e,o,t){let r=Q(e,o,t);return x(r),r}function Ee(e,o){let{loading:t,onError:r,onFieldChange:s,onSubmit:l,onAnalyticsEvent:i}=o,[a,p]=useState(null),[n,u]=useState(0),d=useCallback(async y=>{if(t)return;p(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):p({engine:e,message:k instanceof Error?k.message:"Form action failed"});}},[e,t,r]),m=useCallback(()=>d(async()=>!isActionDisabled(e.isLastStep?void 0:e.currentStep?.next,e.getSubmitValues())&&e.next()),[d,e]),C=useCallback(()=>d(()=>e.back()),[d,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&&d(()=>autoAdvance(e)));},[e,t,d,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(()=>d(async()=>!isActionDisabled(e.definition.submit,e.getSubmitValues())&&_(e.submit(c))),[e,d,c,_]),v=useCallback(()=>d(()=>_(e.skip((y,g)=>(i?.({type:"step_skipped",stepId:e.currentStep.id}),c(y,g))))),[d,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 uo=0,we=new WeakMap;function co(e){let o=we.get(e);return o===void 0&&we.set(e,o=uo++),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 Y(e){let{definition:o,initialValues:t,loading:r=false,components:s,optionsProviders:l,actionsComponent:i,progressComponent:a,headingLevel:p=2,onAnalyticsEvent:n}=e,u=useId(),d=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=Q(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=d.current?.ownerDocument;F&&B?.activeElement===B?.body&&C.current?.isConnected&&C.current.focus();return}m.current=false;let M=d.current?.querySelector(".fh-form__fields");(Ae(M?.querySelector('[aria-invalid="true"]'))??Ae(M)??d.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:d,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(Se,{engine:c,ProgressComponent:a,headingLevel:p}),jsx(Ce,{engine:c,formId:u,loading:r,components:s,optionsProviders:l,onChange:v.update,onCommit:v.commit,onBlur:k,onFocus:g},co(c)),jsx(Pe,{engine:c,actionError:v.actionError}),jsx(ye,{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 Z(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":Z(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",p=`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?Z(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"?`${p} ${p}--inline`:p,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 ee(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 oe(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 re(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 te(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 ne(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 le(e){let{field:o,value:t,error:r,onChange:s}=e,l=o.options??[],i=Array.isArray(t)?t:[];function a(p){let n=i.includes(p)?i.filter(u=>u!==p):[...i,p];s(n);}return jsx(h,{id:f(e),field:o,error:r,variant:"multiselect",children:l.map((p,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(p.value),onChange:()=>a(p.value)}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:u,children:p.label})]},p.value)})})}function ae(e){let{field:o,value:t,error:r,onChange:s,onCommit:l}=e,i=useRef(false),a=o.autoAdvance&&l,p=o.options??[];return jsx(h,{id:f(e),field:o,error:r,variant:"radio",children:p.map((n,u)=>{let d=`${f(e)}-${u}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{...D(e),id:d,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:d,children:n.label})]},n.value)})})}function pe(e){let{field:o,value:t,error:r,onChange:s}=e,l=o.options??[],i=t??"";return jsx(h,{id:f(e),field:o,error:r,children:jsxs("select",{...b(e),className:"fh-field__input fh-field__input--select",value:i,onChange:a=>s(a.target.value),children:[(o.placeholder||i==="")&&jsx("option",{value:"",disabled:true,hidden:!o.placeholder,children:o.placeholder}),l.map(a=>jsx("option",{value:a.value,children:a.label},a.value))]})})}function de(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(""),p=d=>{let m=d.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:p})})}var Po=3;function ue(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??Po,onChange:l=>s(l.target.value)})})}var qe={text:A,email:A,phone:A,number:A,password:A,select:pe,autocomplete:ee,multiselect:le,checkbox:oe,radio:ae,switch:de,file:ne,date:re,datetime:te,textarea:ue};function W(e){let o={...qe};for(let[t,r]of Object.entries(e??{}))r&&(o[t]=r);return o}function xo({components:e,actionsComponent:o,progressComponent:t,...r}){let s=useMemo(()=>W(e),[e]);return jsx(Y,{...r,components:s,actionsComponent:o??z,progressComponent:t??G})}function Ao({components:e,id:o,...t}){let r=useId(),s=useMemo(()=>W(e),[e]);return jsx(H,{...t,id:o??fieldDomId(r,t.field.key),components:s})}export{ee as AutocompleteField,oe as CheckboxField,re as DateField,te as DateTimeField,ne as FileField,z as FormActions,xo as FormRenderer,G as FormStepProgress,Ao as FormhausField,Y as HeadlessFormRenderer,le as MultiselectField,ae as RadioField,pe as SelectField,de as SwitchField,A as TextField,ue as TextareaField,qe as defaultFieldComponents,so as useFormEngine};//# sourceMappingURL=index.js.map
1
+ 'use client';import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useId,useMemo}from'react';import {isActionDisabled,FormEngine}from'@formhaus/core';import {jsx,jsxs}from'react/jsx-runtime';import {fieldDomId,shouldApplyExternalErrors,autoAdvance}from'@formhaus/core/internal';function J(e,o){return `fh-form-actions__button fh-form-actions__button--${e&&e.variant||o}`}function Q({submitAction:e,nextAction:o,backAction:t,cancelAction:r,skipAction:s,isFirstStep:n,isLastStep:l,isMultiStep:a,loading:m,showPrimary:i=true,values:d={},onSubmit:u,onNext:p,onPrev:v,onCancel:S,onSkip:E,primaryLabel:x,showBack:c,backLabel:_,showSkip:D,skipLabel:C,onPrimary:y}){let b=c??(a&&!n&&t!==false),P=_??(t||void 0)?.label??"Back",w=D??(a&&!!s),T=C??s?.label??"Skip",z=x??(a&&!l?"Continue":e?.label??"Submit"),F=!!m||isActionDisabled(a&&!l?o:e,d),M=y??(a&&!l?p:u);return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[b&&jsx("button",{type:"button",className:J(t,"secondary"),disabled:m,onClick:v,children:P}),r&&jsx("button",{type:"button",className:J(r,"text"),disabled:m,onClick:S,children:r.label}),w&&jsx("button",{type:"button",className:J(s,"text"),disabled:m,onClick:E,children:T})]}),i&&jsx("button",{type:"submit",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:F,"aria-busy":m,onClick:L=>{L.preventDefault(),M();},children:z})]})}function Y({current:e,total:o,stepTitle:t,stepDescription:r,headingLevel:s=2,steps:n}){let l=`h${s}`,a=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:`${a}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",o]})}),n&&jsx("ol",{className:"fh-step-progress__steps",children:n.map((m,i)=>{let d=m.title||`Step ${i+1}`;return jsxs("li",{className:`fh-step-progress__step${m.errorCount?" fh-step-progress__step--invalid":""}`,"aria-current":i+1===e?"step":void 0,children:[i+1===e?jsx("strong",{children:d}):d,m.errorCount>0&&` \xB7 ${m.errorCount} ${m.errorCount===1?"error":"errors"}`]},m.id)})}),t&&jsx(l,{className:"fh-step-progress__title",children:t}),r&&jsx("p",{className:"fh-step-progress__description",children:r})]})}function k(e){let o=useCallback(r=>e.subscribe(r),[e]),t=useCallback(()=>e.getSnapshot(),[e]);return useSyncExternalStore(o,t,t)}function Ce(e){let o=useCallback(r=>e.subscribeStructure(r),[e]),t=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,t,t)}function Se({engine:e,definition:o,loading:t,ActionsComponent:r,onSubmit:s,onNext:n,onPrev:l,onSkip:a,onCancel:m}){k(e);let i=e.currentStep,d=e.isLastStep||!e.isMultiStep,u=e.isMultiStep&&!d?(i?.next||void 0)?.label??"Continue":o.submit?.label??"Submit",p=e.isMultiStep&&!e.isFirstStep&&i?.back!==false,v=(i?.back||void 0)?.label??"Back",S=useCallback(async()=>{e.isMultiStep&&!d?await n():s();},[e,d,n,s]);return r?jsx(r,{submitAction:o.submit,nextAction:i?.next,backAction:i?.back,cancelAction:o.cancel,skipAction:i?.skip,isFirstStep:e.isFirstStep,isLastStep:d,isMultiStep:e.isMultiStep,loading:t||e.stepValidating||e.submitting,values:e.getSubmitValues(),onSubmit:s,onNext:n,onPrev:l,onCancel:m,onSkip:a,primaryLabel:u,showPrimary:d||i?.next!==false,showBack:p,backLabel:v,showSkip:!!i?.skip&&i.next!==false,onPrimary:S}):null}function Pe({engine:e,formId:o,onSelect:t}){k(e);let s=(e.isMultiStep?e.visibleSteps.flatMap(n=>n.fields):e.visibleFields).filter(n=>e.errors[n.key]!==void 0);return s.length===0?null:jsxs("div",{className:"fh-error-summary",role:"alert",children:[jsx("strong",{className:"fh-error-summary__title",children:"Check these answers"}),jsx("ul",{className:"fh-error-summary__list",children:s.map(n=>jsx("li",{children:jsxs("a",{className:"fh-error-summary__link",href:`#${fieldDomId(o,n.key)}`,onClick:l=>{l.preventDefault(),t(n.key);},children:[n.label,": ",e.errors[n.key]]})},n.key))})]})}var je=()=>{};function K({id:e,field:o,value:t,error:r,loading:s,disabled:n,components:l,onChange:a,onCommit:m,onBlur:i,onFocus:d}){let u=l?.[o.type];return u?jsx(u,{id:e,field:o,value:t,error:r,loading:s,disabled:n,onChange:a,onCommit:m,onBlur:i??je,onFocus:d}):jsxs("div",{children:["Unsupported field type: ",o.type]})}var _e=memo(function({engine:o,formId:t,field:r,options:s,disabled:n,components:l,onChange:a,onCommit:m,onBlur:i,onFocus:d}){let u=useCallback(_=>o.subscribeField(r.key,_),[o,r.key]),p=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(u,p,p);let v=useCallback(_=>a(r.key,_),[r.key,a]),S=useCallback(_=>m(r.key,_),[r.key,m]),E=useCallback(()=>i(r.key),[r.key,i]),x=useCallback(()=>d(r.key),[r.key,d]),c=s?{...r,options:s}:r;return jsx(K,{id:fieldDomId(t,r.key),field:c,value:o.values[r.key],error:o.errors[r.key],loading:o.fieldLoading[r.key],disabled:n,components:l,onChange:v,onCommit:S,onBlur:E,onFocus:x})});function mo(e,o){return e?.length===o.length&&e.every((t,r)=>t.value===o[r].value&&t.label===o[r].label)}function xe(e,o,t){let[r,s]=useState({}),n=useRef(new Map);return useEffect(()=>{if(!t){s(i=>Object.keys(i).length>0?{}:i);return}let l=true,a=[],m=(i,d)=>{l&&s(u=>mo(u[i],d)?u:{...u,[i]:d});};for(let i of e){if(!i.optionsFrom)continue;let d=t[i.optionsFrom];if(!d)continue;let u=()=>{let p=(n.current.get(i.key)??0)+1;n.current.set(i.key,p);try{let v=d(o.values);if(Array.isArray(v)){m(i.key,v);return}v.then(S=>{n.current.get(i.key)===p&&m(i.key,S);}).catch(()=>{});}catch{}};u();for(let p of new Set(i.optionsDependsOn??[]))a.push(o.subscribeField(p,u));}return ()=>{l=false;for(let i of a)i();}},[o,e,t]),r}var Re=memo(function({engine:o,formId:t,loading:r,components:s,optionsProviders:n,onChange:l,onCommit:a,onBlur:m,onFocus:i}){Ce(o),k(o);let d=o.visibleFields,u=xe(d,o,n);return jsx("div",{className:"fh-form__fields",children:d.map(p=>jsx(_e,{engine:o,formId:t,field:p,options:u[p.key]??p.options,disabled:r||o.stepValidating||o.submitting,components:s,onChange:l,onCommit:a,onBlur:m,onFocus:i},p.key))})});function we({engine:e,ProgressComponent:o,headingLevel:t,marks:r}){if(k(e),!e.isMultiStep||!o)return null;let s=r?e.stepErrors:{};return jsx(o,{current:e.progress.current,total:e.progress.total,stepTitle:e.currentStep?.title,stepDescription:e.currentStep?.description,headingLevel:t,steps:r?e.visibleSteps.map(({id:n,title:l})=>({id:n,title:l,errorCount:s[n]?.length??0})):void 0})}function Ae({engine:e,actionError:o}){k(e);let t=o?[...e.topLevelErrors,o]:e.topLevelErrors;return t.length===0?null:jsx("div",{className:"fh-form__top-errors",role:"alert",children:t.map((r,s)=>jsx("p",{className:"fh-form__top-error",children:r},s))})}function ee(e,o,t){let r=useRef(t);r.current=t;let s=useRef(null),n=useRef(e);(s.current===null||n.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}),n.current=e);let l=s.current;return useEffect(()=>()=>l.cancelPendingActions(),[l]),l}function Fo(e,o,t){let r=ee(e,o,t);return k(r),r}function Le(e,o){let{loading:t,onError:r,onFieldChange:s,onSubmit:n,onAnalyticsEvent:l}=o,[a,m]=useState(null),[i,d]=useState(0),u=useCallback(async y=>{if(t)return;m(null);let b=e.errors;try{!await y()&&e.errors!==b&&Object.keys(e.errors).length>0&&d(P=>P+1);}catch(P){r?r(P):m({engine:e,message:P instanceof Error?P.message:"Form action failed"});}},[e,t,r]),p=useCallback(()=>u(async()=>!isActionDisabled(e.isLastStep?void 0:e.currentStep?.next,e.getSubmitValues())&&e.next()),[u,e]),v=useCallback(()=>u(()=>e.back()),[u,e]),S=useCallback((y,b)=>{t||e.stepValidating||e.submitting||(e.setValue(y,b),s?.(y,b,e.values));},[e,t,s]),E=useCallback((y,b)=>{if(t||e.stepValidating||e.submitting)return;let P=e.currentStep,w=e.visibleFields.find(T=>T.key===y);w&&(S(y,b),w.autoAdvance&&e.currentStep?.id===P?.id&&!e.isLastStep&&u(()=>autoAdvance(e)));},[e,t,u,S]),x=useCallback(async(y,b)=>(l?.({type:"form_submitted",fieldCount:Object.keys(y).length}),n(y,b)),[n,l]),c=useCallback(async y=>{let b=await y;if(!b)for(let[P,w]of Object.entries(e.errors))l?.({type:"field_error",fieldKey:P,error:w});return b},[e,l]),_=useCallback(()=>u(async()=>!isActionDisabled(e.definition.submit,e.getSubmitValues())&&c(e.submit(x))),[e,u,x,c]),D=useCallback(()=>u(()=>c(e.skip((y,b)=>(l?.({type:"step_skipped",stepId:e.currentStep.id}),x(y,b))))),[u,e,x,c,l]),C=a?.engine===e?a.message:null;return {next:p,prev:v,skip:D,update:S,commit:E,submit:_,actionError:C,invalidAttempts:i}}var vo=0,Te=new WeakMap;function Co(e){let o=Te.get(e);return o===void 0&&Te.set(e,o=vo++),o}var Me="input:not(:disabled), select:not(:disabled), textarea:not(:disabled), button:not(:disabled)";function $e(e){return e?.matches(Me)?e:e?.querySelector(Me)}function oe(e){let{definition:o,initialValues:t,loading:r=false,components:s,optionsProviders:n,actionsComponent:l,progressComponent:a,headingLevel:m=2,onAnalyticsEvent:i}=e,d=useId(),u=useRef(null),p=useRef(false),v=useRef(null),S=useRef(null),E=useRef(false),x={...e,onAfterStepChange:async F=>{p.current=true,F.reason!=="back"&&(i?.({type:F.reason==="skip"?"step_skipped":"step_completed",stepId:F.fromStepId}),i?.({type:"step_viewed",stepId:F.toStepId,stepIndex:c.currentStepIndex})),await e.onAfterStepChange?.(F);}},c=ee(o,t,x),_=k(c),D=useRef(c.currentStep?.id),C=Le(c,e),y=useRef(0),b=useRef(null);useEffect(()=>{if(!e.errors)return;let F=b.current?.engine===c?b.current.errors:void 0;shouldApplyExternalErrors(c,F,e.errors)&&(b.current={engine:c,errors:e.errors},c.setErrors(e.errors));},[e.errors,c]),useEffect(()=>{if((D.current!==c.currentStep?.id||y.current!==C.invalidAttempts)&&(p.current=true),D.current=c.currentStep?.id,y.current=C.invalidAttempts,c.stepValidating||c.submitting){E.current=true;return}let F=E.current;if(E.current=false,!p.current){let be=u.current?.ownerDocument;F&&be?.activeElement===be?.body&&S.current?.isConnected&&S.current.focus();return}p.current=false;let M=u.current?.querySelector(".fh-form__fields"),L=v.current&&fieldDomId(d,v.current);v.current=null;let G=L?M?.querySelector(`[id="${L}"], [id="${L}-error"]`):null;if(L&&!G)return;let ye=G?.closest(".fh-field")??G??M?.querySelector('[aria-invalid="true"]');(ye?.querySelector("input:checked:not(:disabled)")??$e(ye)??$e(M)??u.current)?.focus();},[c,_,C.invalidAttempts]);let P=useCallback(F=>{i?.({type:"field_focused",fieldKey:F});},[i]),w=useCallback(F=>{i?.({type:"field_blurred",fieldKey:F,hasValue:c.values[F]!==void 0&&c.values[F]!==""});},[c,i]),T=useCallback(()=>e.onCancel?.(),[e.onCancel]),z=useCallback(F=>{v.current=F,p.current=true,c.goToStepWithField(F);},[c]);return jsxs("form",{ref:u,onFocusCapture:F=>{S.current=F.target;},className:"fh-form",tabIndex:-1,"aria-busy":c.stepValidating||c.submitting||r,onSubmit:F=>{F.preventDefault(),c.isLastStep?C.submit():C.next();},children:[jsx(we,{engine:c,ProgressComponent:a,headingLevel:m,marks:e.stepErrorMarks}),e.errorSummary&&jsx(Pe,{engine:c,formId:d,onSelect:z}),jsx(Re,{engine:c,formId:d,loading:r,components:s,optionsProviders:n,onChange:C.update,onCommit:C.commit,onBlur:w,onFocus:P},Co(c)),jsx(Ae,{engine:c,actionError:C.actionError}),jsx(Se,{engine:c,definition:o,loading:r,ActionsComponent:l,onSubmit:C.submit,onNext:C.next,onPrev:C.prev,onSkip:C.skip,onCancel:T})]})}function Be({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 re(e,o,t){return [e.helperText&&`${o}-helper`,t&&`${o}-error`].filter(Boolean).join(" ")||void 0}function B({disabled:e,loading:o,onBlur:t,onFocus:r}){return {disabled:e||o,onBlur:t,onFocus:r}}function g(e){let o=f(e);return {id:o,name:e.field.key,...B(e),"aria-invalid":!!e.error,"aria-required":!!e.field.validation?.required||void 0,"aria-describedby":re(e.field,o,e.error)}}function h({id:e,field:o,error:t,variant:r,children:s}){let n=r==="radio"||r==="multiselect",l=r&&!n,a=n?"fieldset":"div",m=`fh-field__${r}-${n?"group":"wrapper"}`,i=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":n&&!!t||void 0,"aria-describedby":n?re(o,e,t):void 0,children:[n&&o.label&&jsx("legend",{className:"fh-field__label",children:o.label}),!r&&jsx(Be,{field:o,inputId:e}),!l&&i,r?jsxs("div",{className:n&&o.layout==="inline"?`${m} ${m}--inline`:m,children:[s,l&&o.label&&jsx("label",{className:"fh-field__label",htmlFor:e,children:o.label})]}):s,l&&i,t&&jsx("p",{id:`${e}-error`,className:"fh-field__error",role:"alert",children:t})]})}function ne(e){let{field:o,value:t,error:r,onChange:s}=e,n=`${f(e)}-list`,l=o.options??[];return jsxs(h,{id:f(e),field:o,error:r,children:[jsx("input",{...g(e),type:"text",list:n,className:"fh-field__input fh-field__input--autocomplete",value:t??"",placeholder:o.placeholder,autoComplete:"off",onChange:a=>s(a.target.value)}),jsx("datalist",{id:n,children:l.map(a=>jsx("option",{value:a.value,children:a.label},a.value))})]})}function ie(e){return jsx(h,{id:f(e),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 le(e){return jsx(h,{id:f(e),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 se(e){return jsx(h,{id:f(e),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 ae(e){let{field:o,error:t,onChange:r}=e;return jsx(h,{id:f(e),field:o,error:t,children:jsx("input",{...g(e),type:"file",className:"fh-field__input fh-field__input--file",accept:o.accept,onChange:s=>{let n=s.target.files;r(n&&n.length>0?n[0]:null);}})})}function pe(e){let{field:o,value:t,error:r,onChange:s}=e,n=o.options??[],l=Array.isArray(t)?t:[];function a(m){let i=l.includes(m)?l.filter(d=>d!==m):[...l,m];s(i);}return jsx(h,{id:f(e),field:o,error:r,variant:"multiselect",children:n.map((m,i)=>{let d=`${f(e)}-${i}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{...B(e),id:d,name:o.key,type:"checkbox",className:"fh-field__checkbox",checked:l.includes(m.value),onChange:()=>a(m.value)}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:d,children:m.label})]},m.value)})})}function ue(e){let{field:o,value:t,error:r,onChange:s,onCommit:n}=e,l=useRef(false),a=o.autoAdvance&&n,m=o.options??[];return jsx(h,{id:f(e),field:o,error:r,variant:"radio",children:m.map((i,d)=>{let u=`${f(e)}-${d}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{...B(e),id:u,type:"radio",className:"fh-field__radio",name:o.key,value:i.value,checked:String(t)===String(i.value),onChange:()=>{(!a||l.current)&&s(i.value);},onKeyDown:p=>{l.current=p.key.startsWith("Arrow"),a&&p.key===" "&&p.preventDefault(),a&&p.key==="Enter"&&(p.preventDefault(),p.repeat||a(i.value));},onKeyUp:p=>{l.current=false,a&&p.key===" "&&(p.preventDefault(),a(i.value));},onPointerDown:()=>{l.current=false;},onClick:p=>{!a||l.current||(p.detail>1?p.preventDefault():a(i.value));}}),jsx("label",{className:"fh-field__radio-label",htmlFor:u,children:i.label})]},i.value)})})}function fe(e){let{field:o,value:t,error:r,onChange:s}=e,n=o.options??[],l=t??"";return jsx(h,{id:f(e),field:o,error:r,children:jsxs("select",{...g(e),className:"fh-field__input fh-field__input--select",value:l,onChange:a=>s(a.target.value),children:[(o.placeholder||l==="")&&jsx("option",{value:"",disabled:true,hidden:!o.placeholder,children:o.placeholder}),n.map(a=>jsx("option",{value:a.value,children:a.label},a.value))]})})}function Fe(e){return jsx(h,{id:f(e),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 I(e){let{field:o,value:t,error:r,onChange:s}=e,n=o.type==="number",[l,a]=useState(""),m=u=>{let p=u.target.value;a(p),s(n&&p!==""?Number(p):p);},i=n&&l&&Object.is(Number(l),t)?l:String(t??""),d=o.type==="email"?"email":o.type==="phone"?"tel":n?"number":o.type==="password"?"password":"text";return jsx(h,{id:f(e),field:o,error:r,children:jsx("input",{...g(e),type:d,className:"fh-field__input",value:i,placeholder:o.placeholder??o.mask,inputMode:o.inputMode,onChange:m})})}var Io=3;function he(e){let{field:o,value:t,error:r,onChange:s}=e;return jsx(h,{id:f(e),field:o,error:r,children:jsx("textarea",{...g(e),className:"fh-field__input fh-field__input--textarea",value:t??"",placeholder:o.placeholder,rows:o.rows??Io,onChange:n=>s(n.target.value)})})}var Je={text:I,email:I,phone:I,number:I,password:I,select:fe,autocomplete:ne,multiselect:pe,checkbox:ie,radio:ue,switch:Fe,file:ae,date:le,datetime:se,textarea:he};function U(e){let o={...Je};for(let[t,r]of Object.entries(e??{}))r&&(o[t]=r);return o}function Lo({components:e,actionsComponent:o,progressComponent:t,...r}){let s=useMemo(()=>U(e),[e]);return jsx(oe,{...r,components:s,actionsComponent:o??Q,progressComponent:t??Y})}function Bo({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{ne as AutocompleteField,ie as CheckboxField,le as DateField,se as DateTimeField,ae as FileField,Q as FormActions,Lo as FormRenderer,Y as FormStepProgress,Bo as FormhausField,oe as HeadlessFormRenderer,pe as MultiselectField,ue as RadioField,fe as SelectField,Fe as SwitchField,I as TextField,he as TextareaField,Je as defaultFieldComponents,Fo 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/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":["buttonClass","action","variant","FormActions","submitAction","nextAction","backAction","cancelAction","skipAction","isFirstStep","isLastStep","isMultiStep","loading","showPrimary","values","onSubmit","onNext","onPrev","onCancel","onSkip","primaryLabelProp","showBackProp","backLabelProp","showSkipProp","skipLabelProp","onPrimaryProp","showBack","backLabel","showSkip","skipLabel","primaryLabel","primaryDisabled","isActionDisabled","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":"2RAGA,SAASA,CAAAA,CAAYC,CAAAA,CAAwCC,CAAAA,CAAqD,CAChH,OAAO,CAAA,iDAAA,EAAqDD,CAAAA,EAAUA,CAAAA,CAAO,OAAA,EAAYC,CAAO,CAAA,CAClG,CAEO,SAASC,EAAY,CAC1B,YAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,EACA,YAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,WAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CAAc,IAAA,CACd,MAAA,CAAAC,CAAAA,CAAS,EAAC,CACV,QAAA,CAAAC,CAAAA,CACA,OAAAC,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CAAAA,CACA,MAAA,CAAAC,EACA,YAAA,CAAcC,CAAAA,CACd,QAAA,CAAUC,CAAAA,CACV,SAAA,CAAWC,CAAAA,CACX,SAAUC,CAAAA,CACV,SAAA,CAAWC,CAAAA,CACX,SAAA,CAAWC,CACb,CAAA,CAAqB,CACnB,IAAMC,CAAAA,CAAWL,CAAAA,GAAiBV,CAAAA,EAAe,CAACF,CAAAA,EAAeH,CAAAA,GAAe,OAC1EqB,CAAAA,CAAYL,CAAAA,EAAAA,CAAkBhB,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AGF,EAAuB,CAAA,CAC9D,IAAA,GAAW,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,EAAoB/I,CAAAA,CACtC,iBAAA,CAAmBgJ,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 { isActionDisabled, type FormAction } from '@formhaus/core';\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 nextAction,\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 = !!loading || isActionDisabled(isMultiStep && !isLastStep ? nextAction : submitAction, values);\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 nextAction={step?.next}\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 { isActionDisabled, type FormEngine } from '@formhaus/core';\nimport { autoAdvance } from '@formhaus/core/internal';\nimport { useCallback, useState } from 'react';\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(async () => (\n !isActionDisabled(engine.isLastStep ? undefined : engine.currentStep?.next, engine.getSubmitValues()) && engine.next()\n )), [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 const current = (value as string) ?? '';\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={current}\n onChange={(e) => onChange(e.target.value)}\n >\n {(field.placeholder || current === '') && (\n <option value=\"\" disabled hidden={!field.placeholder}>\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"]}
1
+ {"version":3,"sources":["../src/FormActions.tsx","../src/FormStepProgress.tsx","../src/hooks/useEngineSnapshot.ts","../src/FormActionsController.tsx","../src/FormErrorSummary.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":["buttonClass","action","variant","FormActions","submitAction","nextAction","backAction","cancelAction","skipAction","isFirstStep","isLastStep","isMultiStep","loading","showPrimary","values","onSubmit","onNext","onPrev","onCancel","onSkip","primaryLabelProp","showBackProp","backLabelProp","showSkipProp","skipLabelProp","onPrimaryProp","showBack","backLabel","showSkip","skipLabel","primaryLabel","primaryDisabled","isActionDisabled","handlePrimary","jsxs","jsx","event","FormStepProgress","current","total","stepTitle","stepDescription","headingLevel","steps","Heading","percent","step","index","label","useFormSnapshot","engine","subscribe","useCallback","listener","getSnapshot","useSyncExternalStore","useStructureSnapshot","FormActionsController","definition","ActionsComponent","FormErrorSummary","formId","onSelect","invalid","field","fieldDomId","noop","FieldResolver","id","value","error","disabled","components","onChange","onCommit","onBlur","onFocus","Component","FormFieldController","memo","options","handleChange","handleCommit","handleBlur","handleFocus","fieldWithOptions","areOptionsEqual","previous","next","option","useFieldOptions","fields","providers","resolved","setResolved","useState","requestVersions","useRef","useEffect","active","unsubscribers","commit","fieldKey","provider","resolve","requestVersion","result","dependency","unsubscribe","FormFieldsController","optionsProviders","resolvedOptions","FormProgressController","ProgressComponent","marks","errors","title","FormTopLevelErrors","actionError","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","focusKey","focusReturn","wasBusy","engineOptions","context","version","previousStep","actions","handledInvalid","appliedErrors","shouldApplyExternalErrors","restore","document","chosen","handleFieldFocus","handleFieldBlur","handleCancel","showField","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":"2RAGA,SAASA,CAAAA,CAAYC,CAAAA,CAAwCC,CAAAA,CAAqD,CAChH,OAAO,CAAA,iDAAA,EAAqDD,CAAAA,EAAUA,CAAAA,CAAO,OAAA,EAAYC,CAAO,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CAAU,CAAC,CAAA,CAEjF,OACErC,GAAAA,CAACqH,EAAAA,CAAA,CACE,GAAGzB,CAAAA,CACJ,UAAA,CAAY+F,CAAAA,CACZ,gBAAA,CAAkBrE,GAAoBtJ,CAAAA,CACtC,iBAAA,CAAmBuJ,CAAAA,EAAqBrH,CAAAA,CAC1C,CAEJ,CClBO,SAAS2L,EAAAA,CAAc,CAAE,UAAA,CAAAxJ,CAAAA,CAAY,EAAA,CAAAJ,CAAAA,CAAI,GAAG2D,CAAM,CAAA,CAAuB,CAC9E,IAAMkG,CAAAA,CAAWtE,KAAAA,EAAM,CACjBmE,CAAAA,CAAkBC,OAAAA,CAAQ,IAAMN,CAAAA,CAAkBjJ,CAAU,CAAA,CAAG,CAACA,CAAU,CAAC,CAAA,CACjF,OAAOrC,GAAAA,CAACgC,CAAAA,CAAA,CAAe,GAAG4D,CAAAA,CAAO,EAAA,CAAI3D,CAAAA,EAAMH,UAAAA,CAAWgK,CAAAA,CAAUlG,CAAAA,CAAM,KAAA,CAAM,GAAG,CAAA,CAAG,UAAA,CAAY+F,CAAAA,CAAiB,CACjH","file":"index.js","sourcesContent":["import { isActionDisabled, type FormAction } from '@formhaus/core';\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 nextAction,\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 = !!loading || isActionDisabled(isMultiStep && !isLastStep ? nextAction : submitAction, values);\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 steps,\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 {steps && (\n <ol className=\"fh-step-progress__steps\">\n {steps.map((step, index) => {\n const label = step.title || `Step ${index + 1}`;\n return (\n <li key={step.id} className={`fh-step-progress__step${step.errorCount ? ' fh-step-progress__step--invalid' : ''}`}\n aria-current={index + 1 === current ? 'step' : undefined}>\n {index + 1 === current ? <strong>{label}</strong> : label}\n {step.errorCount > 0 && ` · ${step.errorCount} ${step.errorCount === 1 ? 'error' : 'errors'}`}\n </li>\n );\n })}\n </ol>\n )}\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 nextAction={step?.next}\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 { FormEngine } from '@formhaus/core';\nimport { fieldDomId } from '@formhaus/core/internal';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\n\ninterface FormErrorSummaryProps {\n engine: FormEngine;\n formId: string;\n onSelect: (key: string) => void;\n}\n\nexport function FormErrorSummary({ engine, formId, onSelect }: FormErrorSummaryProps) {\n useFormSnapshot(engine);\n const fields = engine.isMultiStep ? engine.visibleSteps.flatMap((step) => step.fields) : engine.visibleFields;\n const invalid = fields.filter((field) => engine.errors[field.key] !== undefined);\n if (invalid.length === 0) return null;\n\n return (\n <div className=\"fh-error-summary\" role=\"alert\">\n <strong className=\"fh-error-summary__title\">Check these answers</strong>\n <ul className=\"fh-error-summary__list\">\n {invalid.map((field) => (\n <li key={field.key}>\n <a className=\"fh-error-summary__link\" href={`#${fieldDomId(formId, field.key)}`}\n onClick={(event) => { event.preventDefault(); onSelect(field.key); }}>\n {field.label}: {engine.errors[field.key]}\n </a>\n </li>\n ))}\n </ul>\n </div>\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 { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormProgressControllerProps {\n engine: FormEngine;\n ProgressComponent: FormRendererProps['progressComponent'];\n headingLevel: FormRendererProps['headingLevel'];\n marks?: boolean;\n}\n\nexport function FormProgressController({\n engine,\n ProgressComponent,\n headingLevel,\n marks,\n}: FormProgressControllerProps) {\n useFormSnapshot(engine);\n if (!engine.isMultiStep || !ProgressComponent) return null;\n const errors = marks ? engine.stepErrors : {};\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 steps={marks ? engine.visibleSteps.map(({ id, title }) => ({ id, title, errorCount: errors[id]?.length ?? 0 })) : undefined}\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\" role=\"alert\">\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 { isActionDisabled, type FormEngine } from '@formhaus/core';\nimport { autoAdvance } from '@formhaus/core/internal';\nimport { useCallback, useState } from 'react';\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(async () => (\n !isActionDisabled(engine.isLastStep ? undefined : engine.currentStep?.next, engine.getSubmitValues()) && engine.next()\n )), [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 return 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 { fieldDomId, shouldApplyExternalErrors } from '@formhaus/core/internal';\nimport { useCallback, useEffect, useId, useRef } from 'react';\nimport { FormActionsController } from './FormActionsController';\nimport { FormErrorSummary } from './FormErrorSummary';\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 focusKey = useRef<string | null>(null);\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 id = focusKey.current && fieldDomId(formId, focusKey.current);\n focusKey.current = null;\n const chosen = id ? fields?.querySelector(`[id=\"${id}\"], [id=\"${id}-error\"]`) : null;\n if (id && !chosen) return;\n const field = chosen?.closest('.fh-field') ?? chosen ?? fields?.querySelector('[aria-invalid=\"true\"]');\n const target = field?.querySelector('input:checked:not(:disabled)') ?? firstControl(field) ?? 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 const showField = useCallback((key: string) => {\n focusKey.current = key;\n focusPending.current = true;\n engine.goToStepWithField(key);\n }, [engine]);\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} marks={props.stepErrorMarks} />\n {props.errorSummary && <FormErrorSummary engine={engine} formId={formId} onSelect={showField} />}\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 const current = (value as string) ?? '';\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={current}\n onChange={(e) => onChange(e.target.value)}\n >\n {(field.placeholder || current === '') && (\n <option value=\"\" disabled hidden={!field.placeholder}>\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,6 +1,6 @@
1
1
  {
2
2
  "name": "@formhaus/react",
3
- "version": "0.11.3",
3
+ "version": "0.12.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,
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@formhaus/core": "^0.11.3",
24
+ "@formhaus/core": "^0.12.0",
25
25
  "react": "^18.0.0 || ^19.0.0"
26
26
  },
27
27
  "devDependencies": {
@@ -34,7 +34,7 @@
34
34
  "tsup": "^8.5.1",
35
35
  "typescript": "^5.7.3",
36
36
  "vitest": "^4.1.3",
37
- "@formhaus/core": "0.11.3"
37
+ "@formhaus/core": "0.12.0"
38
38
  },
39
39
  "license": "MIT",
40
40
  "homepage": "https://formhaus.dev",