@formhaus/react 0.7.2 → 0.8.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/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface FormActionsProps {
|
|
|
20
20
|
submitAction?: FormAction;
|
|
21
21
|
backAction?: FormAction | false;
|
|
22
22
|
cancelAction?: FormAction;
|
|
23
|
+
skipAction?: FormAction;
|
|
23
24
|
isFirstStep: boolean;
|
|
24
25
|
isLastStep: boolean;
|
|
25
26
|
isMultiStep: boolean;
|
|
@@ -29,10 +30,13 @@ interface FormActionsProps {
|
|
|
29
30
|
showPrimary?: boolean;
|
|
30
31
|
showBack?: boolean;
|
|
31
32
|
backLabel?: string;
|
|
33
|
+
showSkip?: boolean;
|
|
34
|
+
skipLabel?: string;
|
|
32
35
|
onSubmit: () => void;
|
|
33
36
|
onNext: () => void;
|
|
34
37
|
onPrev: () => void;
|
|
35
38
|
onCancel: () => void;
|
|
39
|
+
onSkip?: () => void;
|
|
36
40
|
onPrimary?: () => void;
|
|
37
41
|
}
|
|
38
42
|
interface FormStepProgressProps {
|
|
@@ -64,7 +68,7 @@ declare function FormRenderer({ components, ActionsComponent, ProgressComponent,
|
|
|
64
68
|
|
|
65
69
|
declare function HeadlessFormRenderer(props: FormRendererProps): react_jsx_runtime.JSX.Element;
|
|
66
70
|
|
|
67
|
-
declare function FormActions({ submitAction, backAction, cancelAction, isFirstStep, isLastStep, isMultiStep, loading, showPrimary, values, onSubmit, onNext, onPrev, onCancel, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, onPrimary: onPrimaryProp, }: FormActionsProps): react_jsx_runtime.JSX.Element;
|
|
71
|
+
declare function FormActions({ submitAction, backAction, cancelAction, skipAction, isFirstStep, isLastStep, isMultiStep, loading, showPrimary, values, onSubmit, onNext, onPrev, onCancel, onSkip, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, showSkip: showSkipProp, skipLabel: skipLabelProp, onPrimary: onPrimaryProp, }: FormActionsProps): react_jsx_runtime.JSX.Element;
|
|
68
72
|
|
|
69
73
|
declare function FormStepProgress({ current, total, stepTitle, stepDescription, }: FormStepProgressProps): react_jsx_runtime.JSX.Element;
|
|
70
74
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useMemo}from'react';import {shouldApplyExternalErrors,evaluateCondition,FormEngine}from'@formhaus/core';import {jsx,jsxs}from'react/jsx-runtime';function Ae(e,o,r){return r?true:!e?.disabled||e.disabled.length===0?false:e.disabled.every(n=>evaluateCondition(n,o))}function D({submitAction:e,backAction:o,cancelAction:r,isFirstStep:n,isLastStep:l,isMultiStep:a,loading:p,showPrimary:u=true,values:i={},onSubmit:t,onNext:s,onPrev:d,onCancel:m,primaryLabel:F,showBack:c,backLabel:y,onPrimary:h}){let f=c??(a&&!n&&o!==false),b=y??(typeof o=="object"?o?.label??"Back":"Back"),_=F??(a&&!l?"Continue":e?.label??"Submit"),E=Ae(a&&!l?void 0:e,i,p);function O(){h?h():a&&!l?s():t();}return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[f&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--text",disabled:p,onClick:d,children:b}),r&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--text",disabled:p,onClick:m,children:r.label})]}),u&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:E,"aria-busy":p,onClick:O,children:_})]})}function V({current:e,total:o,stepTitle:r,stepDescription:n}){let l=e/o*100;return jsxs("div",{className:"fh-step-progress",children:[jsx("div",{className:"fh-step-progress__bar",children:jsx("div",{className:"fh-step-progress__fill",style:{width:`${l}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",o]})}),r&&jsx("h3",{className:"fh-step-progress__title",children:r}),n&&jsx("p",{className:"fh-step-progress__description",children:n})]})}function C(e){let o=useCallback(n=>e.subscribe(n),[e]),r=useCallback(()=>e.getSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function R(e){let o=useCallback(n=>e.subscribeStructure(n),[e]),r=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function oe({engine:e,definition:o,loading:r,ActionsComponent:n,onSubmit:l,onNext:a,onPrev:p,onCancel:u}){C(e);let i=e.isLastStep||!e.isMultiStep,t=e.isMultiStep&&!i?typeof e.currentStep?.next=="object"?e.currentStep.next.label??"Continue":"Continue":o.submit?.label??"Submit",s=e.isMultiStep&&!e.isFirstStep&&e.currentStep?.back!==false,d=typeof e.currentStep?.back=="object"?e.currentStep.back.label??"Back":"Back",m=useCallback(async()=>{e.isMultiStep&&!i?await a():l();},[e,i,a,l]);return n?jsx(n,{submitAction:o.submit,backAction:e.currentStep?.back,cancelAction:o.cancel,isFirstStep:e.isFirstStep,isLastStep:i,isMultiStep:e.isMultiStep,loading:r||e.stepValidating||e.submitting,values:e.values,onSubmit:l,onNext:a,onPrev:p,onCancel:u,primaryLabel:t,showPrimary:i||e.currentStep?.next!==false,showBack:s,backLabel:d,onPrimary:m}):null}function te({field:e,value:o,error:r,loading:n,disabled:l,components:a,onChange:p,onCommit:u,onBlur:i,onFocus:t}){let s=a?.[e.type];return s?jsx(s,{field:e,value:o,error:r,loading:n,disabled:l,onChange:p,onCommit:u,onBlur:i,onFocus:t}):jsxs("div",{children:["Unsupported field type: ",e.type]})}var ne=memo(function({engine:o,field:r,options:n,disabled:l,components:a,onChange:p,onCommit:u,onBlur:i,onFocus:t}){let s=useCallback(f=>o.subscribeField(r.key,f),[o,r.key]),d=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(s,d,d);let m=useCallback(f=>p(r.key,f),[r.key,p]),F=useCallback(f=>u(r.key,f),[r.key,u]),c=useCallback(()=>i(r.key),[r.key,i]),y=useCallback(()=>t(r.key),[r.key,t]),h=n?{...r,options:n}:r;return jsx(te,{field:h,value:o.values[r.key],error:o.errors[r.key],loading:o.fieldLoading[r.key],disabled:l,components:a,onChange:m,onCommit:F,onBlur:c,onFocus:y})});function Ke(e,o){return e?.length===o.length&&e.every((r,n)=>r.value===o[n].value&&r.label===o[n].label)}function se(e,o,r){let[n,l]=useState({}),a=useRef(new Map);return useEffect(()=>{if(!r){l(t=>Object.keys(t).length>0?{}:t);return}let p=true,u=[],i=(t,s)=>{p&&l(d=>Ke(d[t],s)?d:{...d,[t]:s});};for(let t of e){if(!t.optionsFrom)continue;let s=r[t.optionsFrom];if(!s)continue;let d=()=>{let m=(a.current.get(t.key)??0)+1;a.current.set(t.key,m);try{let F=s(o.values);if(Array.isArray(F)){i(t.key,F);return}F.then(c=>{a.current.get(t.key)===m&&i(t.key,c);}).catch(()=>{});}catch{}};d();for(let m of new Set(t.optionsDependsOn??[]))u.push(o.subscribeField(m,d));}return ()=>{p=false;for(let t of u)t();}},[o,e,r]),n}var le=memo(function({engine:o,loading:r,components:n,optionsProviders:l,onChange:a,onCommit:p,onBlur:u,onFocus:i}){R(o),C(o);let t=o.visibleFields,s=se(t,o,l);return jsx("div",{className:"fh-form__fields",children:t.map(d=>jsx(ne,{engine:o,field:d,options:s[d.key]??d.options,disabled:r||o.stepValidating||o.submitting,components:n,onChange:a,onCommit:p,onBlur:u,onFocus:i},d.key))})});function ae({engine:e,ProgressComponent:o}){return R(e),!e.isMultiStep||!o?null:jsx(o,{current:e.progress.current,total:e.progress.total,stepTitle:e.currentStep?.title,stepDescription:e.currentStep?.description})}function de({engine:e,actionError:o}){C(e);let r=o?[...e.topLevelErrors,o]:e.topLevelErrors;return r.length===0?null:jsx("div",{className:"fh-form__top-errors",children:r.map((n,l)=>jsx("p",{className:"fh-form__top-error",children:n},l))})}function q(e,o,r){let n=useRef(r);n.current=r;let l=useRef(null),a=useRef(e.id);(l.current===null||a.current!==e.id)&&(l.current=new FormEngine(e,o,{validators:r?.validators,get onStepValidate(){return n.current?.onStepValidate},get onBeforeStepChange(){return n.current?.onBeforeStepChange},get onAfterStepChange(){return n.current?.onAfterStepChange},get onBeforeSubmit(){return n.current?.onBeforeSubmit},get onAfterSubmit(){return n.current?.onAfterSubmit}}),a.current=e.id);let p=l.current;return useEffect(()=>()=>p.cancelPendingActions(),[p]),p}function Qe(e,o,r){let n=q(e,o,r),l=useCallback(p=>n.subscribe(p),[n]),a=useCallback(()=>n.getSnapshot(),[n]);return useSyncExternalStore(l,a,a),n}function me(e,o){let{loading:r,onError:n,onFieldChange:l,onSubmit:a,onAnalyticsEvent:p}=o,[u,i]=useState(null),t=useCallback(async h=>{if(!r){i(null);try{await h();}catch(f){n?n(f):i({engine:e,message:f instanceof Error?f.message:"Form action failed"});}}},[e,r,n]),s=useCallback(()=>t(()=>e.nextStepAsync()),[t,e]),d=useCallback(()=>t(()=>e.prevStepAsync()),[t,e]),m=useCallback((h,f)=>{r||e.stepValidating||e.submitting||(e.setValue(h,f),l?.(h,f,e.values));},[e,r,l]),F=useCallback((h,f)=>{if(r||e.stepValidating||e.submitting)return;let b=e.currentStep,_=e.visibleFields.find(E=>E.key===h);_&&(m(h,f),_.autoAdvance&&e.currentStep?.id===b?.id&&!e.isLastStep&&t(()=>e.nextStepAsync("autoAdvance")));},[e,r,t,m]),c=useCallback(()=>t(async()=>{if(e.definition.submit.disabled?.every(f=>evaluateCondition(f,e.values))&&e.definition.submit.disabled.length>0)return false;let h=await e.submitAsync(async f=>{p?.({type:"form_submitted",fieldCount:Object.keys(f).length}),await a(f);});if(!h)for(let[f,b]of Object.entries(e.errors))p?.({type:"field_error",fieldKey:f,error:b});return h}),[e,t,a,p]),y=u?.engine===e?u.message:null;return {next:s,prev:d,update:m,commit:F,submit:c,actionError:y}}function U(e){let{definition:o,initialValues:r,loading:n=false,components:l,optionsProviders:a,ActionsComponent:p,ProgressComponent:u,onAnalyticsEvent:i}=e,t=useRef(null),s=useRef(false),d=useRef(null),m=useRef(false),F={...e,onAfterStepChange:async g=>{s.current=true,e.onStepChange?.(g.toStepId,g.direction),g.direction==="next"&&(i?.({type:"step_completed",stepId:g.fromStepId}),i?.({type:"step_viewed",stepId:g.toStepId,stepIndex:c.currentStepIndex})),await e.onAfterStepChange?.(g);}},c=q(o,r,F),y=C(c),h=useRef(c.currentStep?.id),f=me(c,e),b=useRef(null);useEffect(()=>{if(!e.errors)return;let g=b.current?.engine===c?b.current.errors:void 0;shouldApplyExternalErrors(c,g,e.errors)&&(b.current={engine:c,errors:e.errors},c.setErrors(e.errors));},[e.errors,c]),useEffect(()=>{if(h.current!==c.currentStep?.id&&(s.current=true),h.current=c.currentStep?.id,c.stepValidating||c.submitting){m.current=true;return}let g=m.current;if(m.current=false,!s.current){let Z=t.current?.ownerDocument;g&&Z?.activeElement===Z?.body&&d.current?.isConnected&&d.current.focus();return}s.current=false,(t.current?.querySelector(".fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)")??t.current)?.focus();},[c,y]);let _=useCallback(g=>{i?.({type:"field_focused",fieldKey:g});},[i]),E=useCallback(g=>{i?.({type:"field_blurred",fieldKey:g,hasValue:c.values[g]!==void 0&&c.values[g]!==""});},[c,i]),O=useCallback(()=>e.onCancel?.(),[e.onCancel]);return jsxs("form",{ref:t,onFocusCapture:g=>{d.current=g.target;},className:"fh-form",tabIndex:-1,"aria-busy":c.stepValidating||c.submitting||n,onSubmit:g=>{g.preventDefault(),c.isLastStep?f.submit():f.next();},children:[jsx(ae,{engine:c,ProgressComponent:u}),jsx(le,{engine:c,loading:n,components:l,optionsProviders:a,onChange:f.update,onCommit:f.commit,onBlur:E,onFocus:_},o.id),jsx(de,{engine:c,actionError:f.actionError}),jsx(oe,{engine:c,definition:o,loading:n,ActionsComponent:p,onSubmit:f.submit,onNext:f.next,onPrev:f.prev,onCancel:O})]})}function k({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 v({error:e,helperText:o,errorId:r,helperId:n}){return e?jsx("p",{id:r,className:"fh-field__error",role:"alert",children:e}):o?jsx("p",{id:n,className:"fh-field__helper",children:o}):null}function he({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-list`,s=`${e.key}-helper`,d=`${e.key}-error`,m=r?d:e.helperText?s:void 0,F=e.options??[];return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsx("input",{id:i,type:"text",list:t,className:"fh-field__input fh-field__input--autocomplete",value:o??"",placeholder:e.placeholder,disabled:l||n,"aria-invalid":!!r,"aria-describedby":m,autoComplete:"off",onChange:c=>a(c.target.value),onBlur:p,onFocus:u}),jsx("datalist",{id:t,children:F.map(c=>jsx("option",{value:c.value,children:c.label},c.value))}),jsx(v,{error:r,helperText:e.helperText,errorId:d,helperId:s})]})}function ye({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0;return jsxs("div",{className:"fh-field fh-field--checkbox",children:[jsxs("div",{className:"fh-field__checkbox-wrapper",children:[jsx("input",{id:i,type:"checkbox",className:"fh-field__checkbox",checked:!!o,disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m=>a(m.target.checked),onBlur:p,onFocus:u}),e.label&&jsx("label",{className:"fh-field__label",htmlFor:i,children:e.label})]}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function be({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0;return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsx("input",{id:i,type:"date",className:"fh-field__input fh-field__input--date",value:String(o??""),disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m=>a(m.target.value),onBlur:p,onFocus:u}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function ve({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0;return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsx("input",{id:i,type:"datetime-local",className:"fh-field__input fh-field__input--datetime",value:String(o??""),disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m=>a(m.target.value),onBlur:p,onFocus:u}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function ge({field:e,error:o,loading:r,disabled:n,onChange:l,onBlur:a,onFocus:p}){let u=e.key,i=`${e.key}-helper`,t=`${e.key}-error`,s=o?t:e.helperText?i:void 0;return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:u}),jsx("input",{id:u,type:"file",className:"fh-field__input fh-field__input--file",accept:e.accept,disabled:n||r,"aria-invalid":!!o,"aria-describedby":s,onChange:d=>{let m=d.target.files;l(m&&m.length>0?m[0]:null);},onBlur:a,onFocus:p}),jsx(v,{error:o,helperText:e.helperText,errorId:t,helperId:i})]})}function Ce({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0,m=e.options??[],F=Array.isArray(o)?o:[];function c(y){let h=F.includes(y)?F.filter(f=>f!==y):[...F,y];a(h);}return jsxs("fieldset",{className:"fh-field fh-field--multiselect","aria-invalid":!!r||void 0,"aria-describedby":d,children:[e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),jsx("div",{className:"fh-field__multiselect-group",children:m.map(y=>{let h=`${i}-${y.value}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{id:h,type:"checkbox",className:"fh-field__checkbox",checked:F.includes(y.value),disabled:l||n,onChange:()=>c(y.value),onBlur:p,onFocus:u}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:h,children:y.label})]},y.value)})}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function Se({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onCommit:p,onBlur:u,onFocus:i}){let t=useRef(false),s=e.autoAdvance&&p,d=e.key,m=`${e.key}-helper`,F=`${e.key}-error`,c=r?F:e.helperText?m:void 0,y=e.options??[];return jsxs("fieldset",{className:"fh-field fh-field--radio","aria-invalid":!!r||void 0,"aria-describedby":c,children:[e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),jsx("div",{className:"fh-field__radio-group",children:y.map(h=>{let f=`${d}-${h.value}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{id:f,type:"radio",className:"fh-field__radio",name:d,value:h.value,checked:String(o)===String(h.value),disabled:l||n,onChange:()=>{(!s||t.current)&&a(h.value);},onKeyDown:b=>{t.current=b.key.startsWith("Arrow"),s&&b.key===" "&&b.preventDefault(),s&&b.key==="Enter"&&(b.preventDefault(),b.repeat||s(h.value));},onKeyUp:b=>{t.current=false,s&&b.key===" "&&(b.preventDefault(),s(h.value));},onPointerDown:()=>{t.current=false;},onClick:b=>{!s||t.current||(b.detail>1?b.preventDefault():s(h.value));},onBlur:u,onFocus:i}),jsx("label",{className:"fh-field__radio-label",htmlFor:f,children:h.label})]},h.value)})}),jsx(v,{error:r,helperText:e.helperText,errorId:F,helperId:m})]})}function xe({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0,m=e.options??[];return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsxs("select",{id:i,className:"fh-field__input fh-field__input--select",value:o??"",disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:F=>a(F.target.value),onBlur:p,onFocus:u,children:[e.placeholder&&jsx("option",{value:"",disabled:true,children:e.placeholder}),m.map(F=>jsx("option",{value:F.value,children:F.label},F.value))]}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function Ee({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0;return jsxs("div",{className:"fh-field fh-field--switch",children:[jsxs("div",{className:"fh-field__switch-wrapper",children:[jsx("input",{id:i,type:"checkbox",role:"switch",className:"fh-field__switch",checked:!!o,disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m=>a(m.target.checked),onBlur:p,onFocus:u}),e.label&&jsx("label",{className:"fh-field__label",htmlFor:i,children:e.label})]}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}function I({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0,m=c=>{let y=c.target.value;a(e.type==="number"&&y!==""?Number(y):y);},F=e.type==="email"?"email":e.type==="phone"?"tel":e.type==="number"?"number":e.type==="password"?"password":"text";return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsx("input",{id:i,type:F,className:"fh-field__input",value:o!=null?String(o):"",placeholder:e.placeholder??e.mask,disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m,onBlur:p,onFocus:u}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}var ar=3;function Ne({field:e,value:o,error:r,loading:n,disabled:l,onChange:a,onBlur:p,onFocus:u}){let i=e.key,t=`${e.key}-helper`,s=`${e.key}-error`,d=r?s:e.helperText?t:void 0;return jsxs("div",{className:"fh-field",children:[jsx(k,{field:e,inputId:i}),jsx("textarea",{id:i,className:"fh-field__input fh-field__input--textarea",value:o??"",placeholder:e.placeholder,rows:e.rows??ar,disabled:l||n,"aria-invalid":!!r,"aria-describedby":d,onChange:m=>a(m.target.value),onBlur:p,onFocus:u}),jsx(v,{error:r,helperText:e.helperText,errorId:s,helperId:t})]})}var dr={text:I,email:I,phone:I,number:I,password:I,select:xe,autocomplete:he,multiselect:Ce,checkbox:ye,radio:Se,switch:Ee,file:ge,date:be,datetime:ve,textarea:Ne};function Te(e){let o={...dr};for(let[r,n]of Object.entries(e??{}))n&&(o[r]=n);return o}function mr({components:e,ActionsComponent:o,ProgressComponent:r,...n}){let l=useMemo(()=>Te(e),[e]);return jsx(U,{...n,components:l,ActionsComponent:o??D,ProgressComponent:r??V})}export{D as FormActions,mr as FormRenderer,V as FormStepProgress,U as HeadlessFormRenderer,Qe as useFormEngine};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {memo,useCallback,useSyncExternalStore,useState,useRef,useEffect,useMemo}from'react';import {shouldApplyExternalErrors,evaluateCondition,FormEngine}from'@formhaus/core';import {jsx,jsxs,Fragment}from'react/jsx-runtime';function T(e,o,r){return r?true:!e?.disabled||e.disabled.length===0?false:e.disabled.every(t=>evaluateCondition(t,o))}function V(e,o){return `fh-form-actions__button fh-form-actions__button--${e&&e.variant||o}`}function H({submitAction:e,backAction:o,cancelAction:r,skipAction:t,isFirstStep:s,isLastStep:l,isMultiStep:i,loading:p,showPrimary:a=true,values:n={},onSubmit:u,onNext:m,onPrev:h,onCancel:C,onSkip:d,primaryLabel:v,showBack:P,backLabel:F,showSkip:_,skipLabel:y,onPrimary:g}){let E=P??(i&&!s&&o!==false),c=F??(o||void 0)?.label??"Back",O=_??(i&&!!t),L=y??t?.label??"Skip",Te=v??(i&&!l?"Continue":e?.label??"Submit"),De=T(i&&!l?void 0:e,n,p),Me=g??(i&&!l?m:u);return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[E&&jsx("button",{type:"button",className:V(o,"secondary"),disabled:p,onClick:h,children:c}),r&&jsx("button",{type:"button",className:V(r,"text"),disabled:p,onClick:C,children:r.label}),O&&jsx("button",{type:"button",className:V(t,"text"),disabled:p,onClick:d,children:L})]}),a&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:De,"aria-busy":p,onClick:()=>Me(),children:Te})]})}function q({current:e,total:o,stepTitle:r,stepDescription:t}){let s=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:`${s}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",o]})}),r&&jsx("h3",{className:"fh-step-progress__title",children:r}),t&&jsx("p",{className:"fh-step-progress__description",children:t})]})}function S(e){let o=useCallback(t=>e.subscribe(t),[e]),r=useCallback(()=>e.getSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function B(e){let o=useCallback(t=>e.subscribeStructure(t),[e]),r=useCallback(()=>e.getStructureSnapshot(),[e]);return useSyncExternalStore(o,r,r)}function re({engine:e,definition:o,loading:r,ActionsComponent:t,onSubmit:s,onNext:l,onPrev:i,onSkip:p,onCancel:a}){S(e);let n=e.currentStep,u=e.isLastStep||!e.isMultiStep,m=e.isMultiStep&&!u?(n?.next||void 0)?.label??"Continue":o.submit?.label??"Submit",h=e.isMultiStep&&!e.isFirstStep&&n?.back!==false,C=(n?.back||void 0)?.label??"Back",d=useCallback(async()=>{e.isMultiStep&&!u?await l():s();},[e,u,l,s]);return t?jsx(t,{submitAction:o.submit,backAction:n?.back,cancelAction:o.cancel,skipAction:n?.skip,isFirstStep:e.isFirstStep,isLastStep:u,isMultiStep:e.isMultiStep,loading:r||e.stepValidating||e.submitting,values:e.values,onSubmit:s,onNext:l,onPrev:i,onCancel:a,onSkip:p,primaryLabel:m,showPrimary:u||n?.next!==false,showBack:h,backLabel:C,showSkip:!!n?.skip&&n.next!==false,onPrimary:d}):null}function te({field:e,value:o,error:r,loading:t,disabled:s,components:l,onChange:i,onCommit:p,onBlur:a,onFocus:n}){let u=l?.[e.type];return u?jsx(u,{field:e,value:o,error:r,loading:t,disabled:s,onChange:i,onCommit:p,onBlur:a,onFocus:n}):jsxs("div",{children:["Unsupported field type: ",e.type]})}var ne=memo(function({engine:o,field:r,options:t,disabled:s,components:l,onChange:i,onCommit:p,onBlur:a,onFocus:n}){let u=useCallback(F=>o.subscribeField(r.key,F),[o,r.key]),m=useCallback(()=>o.getFieldSnapshot(r.key),[o,r.key]);useSyncExternalStore(u,m,m);let h=useCallback(F=>i(r.key,F),[r.key,i]),C=useCallback(F=>p(r.key,F),[r.key,p]),d=useCallback(()=>a(r.key),[r.key,a]),v=useCallback(()=>n(r.key),[r.key,n]),P=t?{...r,options:t}:r;return jsx(te,{field:P,value:o.values[r.key],error:o.errors[r.key],loading:o.fieldLoading[r.key],disabled:s,components:l,onChange:h,onCommit:C,onBlur:d,onFocus:v})});function Je(e,o){return e?.length===o.length&&e.every((r,t)=>r.value===o[t].value&&r.label===o[t].label)}function ie(e,o,r){let[t,s]=useState({}),l=useRef(new Map);return useEffect(()=>{if(!r){s(n=>Object.keys(n).length>0?{}:n);return}let i=true,p=[],a=(n,u)=>{i&&s(m=>Je(m[n],u)?m:{...m,[n]:u});};for(let n of e){if(!n.optionsFrom)continue;let u=r[n.optionsFrom];if(!u)continue;let m=()=>{let h=(l.current.get(n.key)??0)+1;l.current.set(n.key,h);try{let C=u(o.values);if(Array.isArray(C)){a(n.key,C);return}C.then(d=>{l.current.get(n.key)===h&&a(n.key,d);}).catch(()=>{});}catch{}};m();for(let h of new Set(n.optionsDependsOn??[]))p.push(o.subscribeField(h,m));}return ()=>{i=false;for(let n of p)n();}},[o,e,r]),t}var le=memo(function({engine:o,loading:r,components:t,optionsProviders:s,onChange:l,onCommit:i,onBlur:p,onFocus:a}){B(o),S(o);let n=o.visibleFields,u=ie(n,o,s);return jsx("div",{className:"fh-form__fields",children:n.map(m=>jsx(ne,{engine:o,field:m,options:u[m.key]??m.options,disabled:r||o.stepValidating||o.submitting,components:t,onChange:l,onCommit:i,onBlur:p,onFocus:a},m.key))})});function pe({engine:e,ProgressComponent:o}){return B(e),!e.isMultiStep||!o?null:jsx(o,{current:e.progress.current,total:e.progress.total,stepTitle:e.currentStep?.title,stepDescription:e.currentStep?.description})}function me({engine:e,actionError:o}){S(e);let r=o?[...e.topLevelErrors,o]:e.topLevelErrors;return r.length===0?null:jsx("div",{className:"fh-form__top-errors",children:r.map((t,s)=>jsx("p",{className:"fh-form__top-error",children:t},s))})}function U(e,o,r){let t=useRef(r);t.current=r;let s=useRef(null),l=useRef(e.id);(s.current===null||l.current!==e.id)&&(s.current=new FormEngine(e,o,{validators:r?.validators,get onStepValidate(){return t.current?.onStepValidate},get onBeforeStepChange(){return t.current?.onBeforeStepChange},get onAfterStepChange(){return t.current?.onAfterStepChange},get onBeforeSubmit(){return t.current?.onBeforeSubmit},get onAfterSubmit(){return t.current?.onAfterSubmit}}),l.current=e.id);let i=s.current;return useEffect(()=>()=>i.cancelPendingActions(),[i]),i}function je(e,o,r){let t=U(e,o,r);return S(t),t}function de(e,o){let{loading:r,onError:t,onFieldChange:s,onSubmit:l,onAnalyticsEvent:i}=o,[p,a]=useState(null),n=useCallback(async y=>{if(!r){a(null);try{await y();}catch(g){t?t(g):a({engine:e,message:g instanceof Error?g.message:"Form action failed"});}}},[e,r,t]),u=useCallback(()=>n(()=>e.nextStepAsync()),[n,e]),m=useCallback(()=>n(()=>e.prevStepAsync()),[n,e]),h=useCallback((y,g)=>{r||e.stepValidating||e.submitting||(e.setValue(y,g),s?.(y,g,e.values));},[e,r,s]),C=useCallback((y,g)=>{if(r||e.stepValidating||e.submitting)return;let E=e.currentStep,c=e.visibleFields.find(O=>O.key===y);c&&(h(y,g),c.autoAdvance&&e.currentStep?.id===E?.id&&!e.isLastStep&&n(()=>e.nextStepAsync("autoAdvance")));},[e,r,n,h]),d=useCallback(async y=>{i?.({type:"form_submitted",fieldCount:Object.keys(y).length}),await l(y);},[l,i]),v=useCallback(async y=>{let g=await y;if(!g)for(let[E,c]of Object.entries(e.errors))i?.({type:"field_error",fieldKey:E,error:c});return g},[e,i]),P=useCallback(()=>n(async()=>!T(e.definition.submit,e.values)&&v(e.submitAsync(d))),[e,n,d,v]),F=useCallback(()=>n(()=>v(e.skipStepAsync(y=>(i?.({type:"step_skipped",stepId:e.currentStep.id}),d(y))))),[n,e,d,v,i]),_=p?.engine===e?p.message:null;return {next:u,prev:m,skip:F,update:h,commit:C,submit:P,actionError:_}}function z(e){let{definition:o,initialValues:r,loading:t=false,components:s,optionsProviders:l,ActionsComponent:i,ProgressComponent:p,onAnalyticsEvent:a}=e,n=useRef(null),u=useRef(false),m=useRef(null),h=useRef(false),C={...e,onAfterStepChange:async c=>{u.current=true,e.onStepChange?.(c.toStepId,c.direction),c.direction==="next"&&(a?.({type:c.reason==="skip"?"step_skipped":"step_completed",stepId:c.fromStepId}),a?.({type:"step_viewed",stepId:c.toStepId,stepIndex:d.currentStepIndex})),await e.onAfterStepChange?.(c);}},d=U(o,r,C),v=S(d),P=useRef(d.currentStep?.id),F=de(d,e),_=useRef(null);useEffect(()=>{if(!e.errors)return;let c=_.current?.engine===d?_.current.errors:void 0;shouldApplyExternalErrors(d,c,e.errors)&&(_.current={engine:d,errors:e.errors},d.setErrors(e.errors));},[e.errors,d]),useEffect(()=>{if(P.current!==d.currentStep?.id&&(u.current=true),P.current=d.currentStep?.id,d.stepValidating||d.submitting){h.current=true;return}let c=h.current;if(h.current=false,!u.current){let L=n.current?.ownerDocument;c&&L?.activeElement===L?.body&&m.current?.isConnected&&m.current.focus();return}u.current=false,(n.current?.querySelector(".fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)")??n.current)?.focus();},[d,v]);let y=useCallback(c=>{a?.({type:"field_focused",fieldKey:c});},[a]),g=useCallback(c=>{a?.({type:"field_blurred",fieldKey:c,hasValue:d.values[c]!==void 0&&d.values[c]!==""});},[d,a]),E=useCallback(()=>e.onCancel?.(),[e.onCancel]);return jsxs("form",{ref:n,onFocusCapture:c=>{m.current=c.target;},className:"fh-form",tabIndex:-1,"aria-busy":d.stepValidating||d.submitting||t,onSubmit:c=>{c.preventDefault(),d.isLastStep?F.submit():F.next();},children:[jsx(pe,{engine:d,ProgressComponent:p}),jsx(le,{engine:d,loading:t,components:s,optionsProviders:l,onChange:F.update,onCommit:F.commit,onBlur:g,onFocus:y},o.id),jsx(me,{engine:d,actionError:F.actionError}),jsx(re,{engine:d,definition:o,loading:t,ActionsComponent:i,onSubmit:F.submit,onNext:F.next,onPrev:F.prev,onSkip:F.skip,onCancel:E})]})}function ce({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 Fe({field:e,error:o}){return o?jsx("p",{id:`${e.key}-error`,className:"fh-field__error",role:"alert",children:o}):e.helperText?jsx("p",{id:`${e.key}-helper`,className:"fh-field__helper",children:e.helperText}):null}function G(e,o){return o?`${e.key}-error`:e.helperText?`${e.key}-helper`:void 0}function N({disabled:e,loading:o,onBlur:r,onFocus:t}){return {disabled:e||o,onBlur:r,onFocus:t}}function b(e){return {id:e.field.key,...N(e),"aria-invalid":!!e.error,"aria-describedby":G(e.field,e.error)}}function f({field:e,error:o,variant:r,children:t}){let s=r==="radio"||r==="multiselect";return jsxs(s?"fieldset":"div",{className:r?`fh-field fh-field--${r}`:"fh-field","aria-invalid":s&&!!o||void 0,"aria-describedby":s?G(e,o):void 0,children:[s&&e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),r?jsxs("div",{className:`fh-field__${r}-${s?"group":"wrapper"}`,children:[t,!s&&e.label&&jsx("label",{className:"fh-field__label",htmlFor:e.key,children:e.label})]}):jsxs(Fragment,{children:[jsx(ce,{field:e,inputId:e.key}),t]}),jsx(Fe,{field:e,error:o})]})}function he(e){let{field:o,value:r,error:t,onChange:s}=e,l=`${o.key}-list`,i=o.options??[];return jsxs(f,{field:o,error:t,children:[jsx("input",{...b(e),type:"text",list:l,className:"fh-field__input fh-field__input--autocomplete",value:r??"",placeholder:o.placeholder,autoComplete:"off",onChange:p=>s(p.target.value)}),jsx("datalist",{id:l,children:i.map(p=>jsx("option",{value:p.value,children:p.label},p.value))})]})}function be(e){return jsx(f,{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 Ce(e){return jsx(f,{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 Se(e){return jsx(f,{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 Pe(e){let{field:o,error:r,onChange:t}=e;return jsx(f,{field:o,error:r,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;t(l&&l.length>0?l[0]:null);}})})}function _e(e){let{field:o,value:r,error:t,onChange:s}=e,l=o.options??[],i=Array.isArray(r)?r:[];function p(a){let n=i.includes(a)?i.filter(u=>u!==a):[...i,a];s(n);}return jsx(f,{field:o,error:t,variant:"multiselect",children:l.map(a=>{let n=`${o.key}-${a.value}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{...N(e),id:n,type:"checkbox",className:"fh-field__checkbox",checked:i.includes(a.value),onChange:()=>p(a.value)}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:n,children:a.label})]},a.value)})})}function Ee(e){let{field:o,value:r,error:t,onChange:s,onCommit:l}=e,i=useRef(false),p=o.autoAdvance&&l,a=o.options??[];return jsx(f,{field:o,error:t,variant:"radio",children:a.map(n=>{let u=`${o.key}-${n.value}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{...N(e),id:u,type:"radio",className:"fh-field__radio",name:o.key,value:n.value,checked:String(r)===String(n.value),onChange:()=>{(!p||i.current)&&s(n.value);},onKeyDown:m=>{i.current=m.key.startsWith("Arrow"),p&&m.key===" "&&m.preventDefault(),p&&m.key==="Enter"&&(m.preventDefault(),m.repeat||p(n.value));},onKeyUp:m=>{i.current=false,p&&m.key===" "&&(m.preventDefault(),p(n.value));},onPointerDown:()=>{i.current=false;},onClick:m=>{!p||i.current||(m.detail>1?m.preventDefault():p(n.value));}}),jsx("label",{className:"fh-field__radio-label",htmlFor:u,children:n.label})]},n.value)})})}function xe(e){let{field:o,value:r,error:t,onChange:s}=e,l=o.options??[];return jsx(f,{field:o,error:t,children:jsxs("select",{...b(e),className:"fh-field__input fh-field__input--select",value:r??"",onChange:i=>s(i.target.value),children:[o.placeholder&&jsx("option",{value:"",disabled:true,children:o.placeholder}),l.map(i=>jsx("option",{value:i.value,children:i.label},i.value))]})})}function Re(e){return jsx(f,{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 R(e){let{field:o,value:r,error:t,onChange:s}=e,l=p=>{let a=p.target.value;s(o.type==="number"&&a!==""?Number(a):a);},i=o.type==="email"?"email":o.type==="phone"?"tel":o.type==="number"?"number":o.type==="password"?"password":"text";return jsx(f,{field:o,error:t,children:jsx("input",{...b(e),type:i,className:"fh-field__input",value:r!=null?String(r):"",placeholder:o.placeholder??o.mask,onChange:l})})}var uo=3;function Oe(e){let{field:o,value:r,error:t,onChange:s}=e;return jsx(f,{field:o,error:t,children:jsx("textarea",{...b(e),className:"fh-field__input fh-field__input--textarea",value:r??"",placeholder:o.placeholder,rows:o.rows??uo,onChange:l=>s(l.target.value)})})}var co={text:R,email:R,phone:R,number:R,password:R,select:xe,autocomplete:he,multiselect:_e,checkbox:be,radio:Ee,switch:Re,file:Pe,date:Ce,datetime:Se,textarea:Oe};function Le(e){let o={...co};for(let[r,t]of Object.entries(e??{}))t&&(o[r]=t);return o}function Fo({components:e,ActionsComponent:o,ProgressComponent:r,...t}){let s=useMemo(()=>Le(e),[e]);return jsx(z,{...t,components:s,ActionsComponent:o??H,ProgressComponent:r??q})}export{H as FormActions,Fo as FormRenderer,q as FormStepProgress,z as HeadlessFormRenderer,je 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/FormField.tsx","../src/FormFieldController.tsx","../src/hooks/useFieldOptions.ts","../src/FormFieldsController.tsx","../src/FormProgressController.tsx","../src/FormTopLevelErrors.tsx","../src/hooks/useFormEngine.ts","../src/hooks/useRendererActions.ts","../src/HeadlessFormRenderer.tsx","../src/fields/FieldLabel.tsx","../src/fields/FieldMessage.tsx","../src/fields/AutocompleteField.tsx","../src/fields/CheckboxField.tsx","../src/fields/DateField.tsx","../src/fields/DateTimeField.tsx","../src/fields/FileField.tsx","../src/fields/MultiselectField.tsx","../src/fields/RadioField.tsx","../src/fields/SelectField.tsx","../src/fields/SwitchField.tsx","../src/fields/TextField.tsx","../src/fields/TextareaField.tsx","../src/defaultFieldComponents.ts","../src/FormRenderer.tsx"],"names":["isActionDisabled","action","values","loading","c","evaluateCondition","FormActions","submitAction","backAction","cancelAction","isFirstStep","isLastStep","isMultiStep","showPrimary","onSubmit","onNext","onPrev","onCancel","primaryLabelProp","showBackProp","backLabelProp","onPrimaryProp","showBack","backLabel","primaryLabel","primaryDisabled","handlePrimary","jsxs","jsx","FormStepProgress","current","total","stepTitle","stepDescription","percent","useFormSnapshot","engine","subscribe","useCallback","listener","getSnapshot","useSyncExternalStore","useStructureSnapshot","FormActionsController","definition","ActionsComponent","FormField","field","value","error","disabled","components","onChange","onCommit","onBlur","onFocus","Component","FormFieldController","memo","options","handleChange","handleCommit","handleBlur","handleFocus","fieldWithOptions","areOptionsEqual","previous","next","option","index","useFieldOptions","fields","providers","resolved","setResolved","useState","requestVersions","useRef","useEffect","active","unsubscribers","commit","fieldKey","provider","resolve","requestVersion","result","dependency","unsubscribe","FormFieldsController","optionsProviders","resolvedOptions","FormProgressController","ProgressComponent","FormTopLevelErrors","actionError","errors","useFormEngineStore","initialValues","optionsRef","engineRef","definitionIdRef","FormEngine","useFormEngine","useRendererActions","props","onError","onFieldChange","onAnalyticsEvent","failure","setFailure","run","prev","update","key","step","submit","condition","HeadlessFormRenderer","formRef","focusPending","focusReturn","wasBusy","engineOptions","context","version","previousStep","actions","appliedErrors","shouldApplyExternalErrors","restore","document","handleFieldFocus","handleFieldBlur","handleCancel","event","FieldLabel","inputId","FieldMessage","helperText","errorId","helperId","AutocompleteField","listId","describedBy","e","opt","CheckboxField","DateField","DateTimeField","FileField","files","MultiselectField","groupId","selected","handleToggle","optValue","v","optionId","RadioField","arrowSelection","SelectField","SwitchField","TextField","inputType","DEFAULT_ROWS","TextareaField","defaultFieldComponents","withDefaultFields","merged","type","component","FormRenderer","fieldComponents","useMemo"],"mappings":"yNAIA,SAASA,EAAAA,CACPC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACS,CACT,OAAIA,CAAAA,CAAgB,IAAA,CAChB,CAACF,CAAAA,EAAQ,QAAA,EAAYA,CAAAA,CAAO,QAAA,CAAS,SAAW,CAAA,CAAU,KAAA,CACvDA,CAAAA,CAAO,QAAA,CAAS,KAAA,CAAOG,CAAAA,EAAMC,iBAAAA,CAAkBD,CAAAA,CAAGF,CAAM,CAAC,CAClE,CAEO,SAASI,CAAAA,CAAY,CAC1B,YAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,WAAA,C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AAAzH,CAAAA,CACA,gBAAA,CAAAN,CAAAA,CACA,iBAAA,CAAAgD,CAAAA,CACA,GAAGY,CACL,CAAA,CAAsB,CACpB,IAAMoE,CAAAA,CAAkBC,OAAAA,CAAQ,IAAMN,EAAAA,CAAkBrH,CAAU,CAAA,CAAG,CAACA,CAAU,CAAC,CAAA,CAEjF,OACEvB,IAAC0F,CAAAA,CAAA,CACE,GAAGb,CAAAA,CACJ,UAAA,CAAYoE,CAAAA,CACZ,gBAAA,CAAkBhI,CAAAA,EAAoBvC,CAAAA,CACtC,iBAAA,CAAmBuF,CAAAA,EAAqBhE,CAAAA,CAC1C,CAEJ","file":"index.js","sourcesContent":["import { evaluateCondition } from '@formhaus/core';\nimport type { FormAction } from '@formhaus/core';\nimport type { FormActionsProps } from './types';\n\nfunction isActionDisabled(\n action: FormAction | undefined,\n values: Record<string, unknown>,\n loading?: boolean,\n): boolean {\n if (loading) return true;\n if (!action?.disabled || action.disabled.length === 0) return false;\n return action.disabled.every((c) => evaluateCondition(c, values));\n}\n\nexport function FormActions({\n submitAction,\n backAction,\n cancelAction,\n isFirstStep,\n isLastStep,\n isMultiStep,\n loading,\n showPrimary = true,\n values = {},\n onSubmit,\n onNext,\n onPrev,\n onCancel,\n primaryLabel: primaryLabelProp,\n showBack: showBackProp,\n backLabel: backLabelProp,\n onPrimary: onPrimaryProp,\n}: FormActionsProps) {\n const showBack = showBackProp ?? (isMultiStep && !isFirstStep && backAction !== false);\n const backLabel = backLabelProp ?? (typeof backAction === 'object' ? (backAction?.label ?? 'Back') : 'Back');\n const primaryLabel = primaryLabelProp ?? (isMultiStep && !isLastStep ? 'Continue' : (submitAction?.label ?? 'Submit'));\n\n const primaryDisabled = isActionDisabled(\n isMultiStep && !isLastStep ? undefined : submitAction,\n values,\n loading,\n );\n\n function handlePrimary() {\n if (onPrimaryProp) {\n onPrimaryProp();\n } else if (isMultiStep && !isLastStep) {\n onNext();\n } else {\n onSubmit();\n }\n }\n\n return (\n <div className=\"fh-form-actions\">\n <div className=\"fh-form-actions__secondary\">\n {showBack && (\n <button\n type=\"button\"\n className=\"fh-form-actions__button fh-form-actions__button--text\"\n disabled={loading}\n onClick={onPrev}\n >\n {backLabel}\n </button>\n )}\n {cancelAction && (\n <button\n type=\"button\"\n className=\"fh-form-actions__button fh-form-actions__button--text\"\n disabled={loading}\n onClick={onCancel}\n >\n {cancelAction.label}\n </button>\n )}\n </div>\n {showPrimary && <button\n type=\"button\"\n className=\"fh-form-actions__button fh-form-actions__button--primary\"\n disabled={primaryDisabled}\n aria-busy={loading}\n onClick={handlePrimary}\n >\n {primaryLabel}\n </button>}\n </div>\n );\n}\n","import type { FormStepProgressProps } from './types';\n\nexport function FormStepProgress({\n current,\n total,\n stepTitle,\n stepDescription,\n}: FormStepProgressProps) {\n const percent = (current / total) * 100;\n\n return (\n <div className=\"fh-step-progress\">\n <div className=\"fh-step-progress__bar\">\n <div className=\"fh-step-progress__fill\" style={{ width: `${percent}%` }} />\n </div>\n <div className=\"fh-step-progress__info\">\n <span className=\"fh-step-progress__counter\">\n Step {current} of {total}\n </span>\n </div>\n {stepTitle && <h3 className=\"fh-step-progress__title\">{stepTitle}</h3>}\n {stepDescription && <p className=\"fh-step-progress__description\">{stepDescription}</p>}\n </div>\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nexport function useFormSnapshot(engine: FormEngine): number {\n const subscribe = useCallback((listener: () => void) => engine.subscribe(listener), [engine]);\n const getSnapshot = useCallback(() => engine.getSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useStructureSnapshot(engine: FormEngine): number {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeStructure(listener),\n [engine],\n );\n const getSnapshot = useCallback(() => engine.getStructureSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback } from 'react';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormActionsControllerProps {\n engine: FormEngine;\n definition: FormRendererProps['definition'];\n loading: boolean;\n ActionsComponent: FormRendererProps['ActionsComponent'];\n onSubmit: () => void;\n onNext: () => Promise<void>;\n onPrev: () => void;\n onCancel: () => void;\n}\n\nexport function FormActionsController({\n engine,\n definition,\n loading,\n ActionsComponent,\n onSubmit,\n onNext,\n onPrev,\n onCancel,\n}: FormActionsControllerProps) {\n useFormSnapshot(engine);\n const isLastStep = engine.isLastStep || !engine.isMultiStep;\n const primaryLabel = engine.isMultiStep && !isLastStep\n ? (typeof engine.currentStep?.next === 'object' ? engine.currentStep.next.label ?? 'Continue' : 'Continue')\n : (definition.submit?.label ?? 'Submit');\n const showBack = engine.isMultiStep && !engine.isFirstStep && engine.currentStep?.back !== false;\n const backLabel = typeof engine.currentStep?.back === 'object'\n ? (engine.currentStep.back.label ?? 'Back')\n : 'Back';\n const handlePrimary = useCallback(async () => {\n if (engine.isMultiStep && !isLastStep) await onNext();\n else onSubmit();\n }, [engine, isLastStep, onNext, onSubmit]);\n\n if (!ActionsComponent) return null;\n\n return (\n <ActionsComponent\n submitAction={definition.submit}\n backAction={engine.currentStep?.back}\n cancelAction={definition.cancel}\n isFirstStep={engine.isFirstStep}\n isLastStep={isLastStep}\n isMultiStep={engine.isMultiStep}\n loading={loading || engine.stepValidating || engine.submitting}\n values={engine.values}\n onSubmit={onSubmit}\n onNext={onNext}\n onPrev={onPrev}\n onCancel={onCancel}\n primaryLabel={primaryLabel}\n showPrimary={isLastStep || engine.currentStep?.next !== false}\n showBack={showBack}\n backLabel={backLabel}\n onPrimary={handlePrimary}\n />\n );\n}\n","import type { FormField as FormFieldType } from '@formhaus/core';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\ninterface FormFieldProps {\n field: FormFieldType;\n value: unknown;\n error?: string;\n loading?: boolean;\n disabled?: boolean;\n components?: FieldComponentMap;\n onChange: (value: unknown) => void;\n onCommit?: (value: unknown) => void;\n onBlur: () => void;\n onFocus?: () => void;\n}\n\nexport function FormField({\n field,\n value,\n error,\n loading,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldProps) {\n const Component = components?.[field.type];\n\n if (!Component) {\n return <div>Unsupported field type: {field.type}</div>;\n }\n\n return (\n <Component\n field={field}\n value={value}\n error={error}\n loading={loading}\n disabled={disabled}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n );\n}\n","import type { FieldOption, FormEngine, FormField as FormFieldType } from '@formhaus/core';\nimport { memo, useCallback, useSyncExternalStore } from 'react';\nimport { FormField } from './FormField';\nimport type { FieldComponentMap } from './types';\n\ninterface FormFieldControllerProps {\n engine: FormEngine;\n field: FormFieldType;\n options?: FieldOption[];\n disabled?: boolean;\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\nexport const FormFieldController = memo(function FormFieldController({\n engine,\n field,\n options,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldControllerProps) {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeField(field.key, listener),\n [engine, field.key],\n );\n const getSnapshot = useCallback(\n () => engine.getFieldSnapshot(field.key),\n [engine, field.key],\n );\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const handleChange = useCallback(\n (value: unknown) => onChange(field.key, value),\n [field.key, onChange],\n );\n const handleCommit = useCallback((value: unknown) => onCommit(field.key, value), [field.key, onCommit]);\n const handleBlur = useCallback(() => onBlur(field.key), [field.key, onBlur]);\n const handleFocus = useCallback(() => onFocus(field.key), [field.key, onFocus]);\n const fieldWithOptions = options ? { ...field, options } : field;\n\n return (\n <FormField\n field={fieldWithOptions}\n value={engine.values[field.key]}\n error={engine.errors[field.key]}\n loading={engine.fieldLoading[field.key]}\n disabled={disabled}\n components={components}\n onChange={handleChange}\n onCommit={handleCommit}\n onBlur={handleBlur}\n onFocus={handleFocus}\n />\n );\n});\n","import type { FieldOption, FormEngine, FormField } from '@formhaus/core';\nimport { useEffect, useRef, useState } from 'react';\nimport type { OptionsProvider } from '../types';\n\nfunction areOptionsEqual(previous: FieldOption[] | undefined, next: FieldOption[]): boolean {\n return previous?.length === next.length && previous.every((option, index) => (\n option.value === next[index].value && option.label === next[index].label\n ));\n}\n\nexport function useFieldOptions(\n fields: FormField[],\n engine: FormEngine,\n providers?: Record<string, OptionsProvider>,\n): Record<string, FieldOption[]> {\n const [resolved, setResolved] = useState<Record<string, FieldOption[]>>({});\n const requestVersions = useRef<Map<string, number>>(new Map());\n\n useEffect(() => {\n if (!providers) {\n setResolved((previous) => (\n Object.keys(previous).length > 0 ? {} : previous\n ));\n return;\n }\n\n let active = true;\n const unsubscribers: (() => void)[] = [];\n\n const commit = (fieldKey: string, options: FieldOption[]) => {\n if (!active) return;\n setResolved((previous) => {\n if (areOptionsEqual(previous[fieldKey], options)) return previous;\n return { ...previous, [fieldKey]: options };\n });\n };\n\n for (const field of fields) {\n if (!field.optionsFrom) continue;\n\n const provider = providers[field.optionsFrom];\n if (!provider) continue;\n\n const resolve = () => {\n const requestVersion = (requestVersions.current.get(field.key) ?? 0) + 1;\n requestVersions.current.set(field.key, requestVersion);\n\n try {\n const result = provider(engine.values);\n if (Array.isArray(result)) {\n commit(field.key, result);\n return;\n }\n\n result\n .then((options) => {\n if (requestVersions.current.get(field.key) === requestVersion) {\n commit(field.key, options);\n }\n })\n .catch(() => {});\n } catch {\n // Retry when a dependency changes.\n }\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 type { FormEngine } from '@formhaus/core';\nimport { memo } from 'react';\nimport { FormFieldController } from './FormFieldController';\nimport { useFormSnapshot, useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport { useFieldOptions } from './hooks/useFieldOptions';\nimport type { FieldComponentMap, OptionsProvider } from './types';\n\ninterface FormFieldsControllerProps {\n engine: FormEngine;\n loading: boolean;\n components?: FieldComponentMap;\n optionsProviders?: Record<string, OptionsProvider>;\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\nexport const FormFieldsController = memo(function FormFieldsController({\n engine,\n loading,\n components,\n optionsProviders,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldsControllerProps) {\n useStructureSnapshot(engine);\n useFormSnapshot(engine);\n const fields = engine.visibleFields;\n const resolvedOptions = useFieldOptions(fields, engine, optionsProviders);\n\n return (\n <div className=\"fh-form__fields\">\n {fields.map((field) => (\n <FormFieldController\n key={field.key}\n engine={engine}\n field={field}\n options={resolvedOptions[field.key] ?? field.options}\n disabled={loading || engine.stepValidating || engine.submitting}\n components={components}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n ))}\n </div>\n );\n});\n","import type { FormEngine } from '@formhaus/core';\nimport { useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormProgressControllerProps {\n engine: FormEngine;\n ProgressComponent: FormRendererProps['ProgressComponent'];\n}\n\nexport function FormProgressController({\n engine,\n ProgressComponent,\n}: FormProgressControllerProps) {\n useStructureSnapshot(engine);\n if (!engine.isMultiStep || !ProgressComponent) return null;\n\n return (\n <ProgressComponent\n current={engine.progress.current}\n total={engine.progress.total}\n stepTitle={engine.currentStep?.title}\n stepDescription={engine.currentStep?.description}\n />\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\n\nexport function FormTopLevelErrors({ engine, actionError }: { engine: FormEngine; actionError?: string | null }) {\n useFormSnapshot(engine);\n const errors = actionError ? [...engine.topLevelErrors, actionError] : engine.topLevelErrors;\n if (errors.length === 0) return null;\n\n return (\n <div className=\"fh-form__top-errors\">\n {errors.map((error, index) => (\n <p key={index} className=\"fh-form__top-error\">\n {error}\n </p>\n ))}\n </div>\n );\n}\n","import { FormEngine, type FormEngineOptions, type FormDefinition } from '@formhaus/core';\nimport { useCallback, useEffect, useRef, useSyncExternalStore } from 'react';\n\nexport function useFormEngineStore(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const engineRef = useRef<FormEngine | null>(null);\n const definitionIdRef = useRef<string>(definition.id);\n\n if (engineRef.current === null || definitionIdRef.current !== definition.id) {\n engineRef.current = new FormEngine(definition, initialValues, {\n validators: options?.validators,\n get onStepValidate() { return optionsRef.current?.onStepValidate; },\n get onBeforeStepChange() { return optionsRef.current?.onBeforeStepChange; },\n get onAfterStepChange() { return optionsRef.current?.onAfterStepChange; },\n get onBeforeSubmit() { return optionsRef.current?.onBeforeSubmit; },\n get onAfterSubmit() { return optionsRef.current?.onAfterSubmit; },\n });\n definitionIdRef.current = definition.id;\n }\n\n const engine = engineRef.current;\n useEffect(() => () => engine.cancelPendingActions(), [engine]);\n return engine;\n}\n\nexport function useFormEngine(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const engine = useFormEngineStore(definition, initialValues, options);\n\n const subscribe = useCallback((listener: () => void) => engine.subscribe(listener), [engine]);\n const getSnapshot = useCallback(() => engine.getSnapshot(), [engine]);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n return engine;\n}\n","import { evaluateCondition } from '@formhaus/core';\nimport type { FormEngine } from '@formhaus/core';\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 run = useCallback(async (action: () => Promise<boolean>) => {\n if (loading) return;\n setFailure(null);\n try { await action(); }\n catch (error) {\n if (onError) onError(error);\n else setFailure({ engine, message: error instanceof Error ? error.message : 'Form action failed' });\n }\n }, [engine, loading, onError]);\n const next = useCallback(() => run(() => engine.nextStepAsync()), [run, engine]);\n const prev = useCallback(() => run(() => engine.prevStepAsync()), [run, engine]);\n const update = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n engine.setValue(key, value);\n onFieldChange?.(key, value, engine.values);\n }, [engine, loading, onFieldChange]);\n const commit = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n const step = engine.currentStep;\n const field = engine.visibleFields.find((field) => field.key === key);\n if (!field) return;\n update(key, value);\n if (field.autoAdvance && engine.currentStep?.id === step?.id && !engine.isLastStep) void run(() => engine.nextStepAsync('autoAdvance'));\n }, [engine, loading, run, update]);\n const submit = useCallback(() => run(async () => {\n if (engine.definition.submit.disabled?.every((condition) => evaluateCondition(condition, engine.values))\n && engine.definition.submit.disabled.length > 0) return false;\n const result = await engine.submitAsync(async (values) => {\n onAnalyticsEvent?.({ type: 'form_submitted', fieldCount: Object.keys(values).length });\n await onSubmit(values);\n });\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, run, onSubmit, onAnalyticsEvent]);\n const actionError = failure?.engine === engine ? failure.message : null;\n return { next, prev, update, commit, submit, actionError };\n}\n","import { shouldApplyExternalErrors, type FormEngineOptions } from '@formhaus/core';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { FormActionsController } from './FormActionsController';\nimport { FormFieldsController } from './FormFieldsController';\nimport { FormProgressController } from './FormProgressController';\nimport { FormTopLevelErrors } from './FormTopLevelErrors';\nimport { useFormEngineStore } from './hooks/useFormEngine';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport { useRendererActions } from './hooks/useRendererActions';\nimport type { FormRendererProps } from './types';\n\nexport function HeadlessFormRenderer(props: FormRendererProps) {\n const { definition, initialValues, loading = false, components, optionsProviders,\n ActionsComponent, ProgressComponent, onAnalyticsEvent } = props;\n const formRef = useRef<HTMLFormElement>(null);\n const focusPending = useRef(false);\n const focusReturn = useRef<HTMLElement | null>(null);\n const wasBusy = useRef(false);\n const engineOptions: FormEngineOptions = {\n ...props,\n onAfterStepChange: async (context) => {\n focusPending.current = true;\n props.onStepChange?.(context.toStepId, context.direction);\n if (context.direction === 'next') {\n onAnalyticsEvent?.({ type: 'step_completed', stepId: context.fromStepId });\n onAnalyticsEvent?.({ type: 'step_viewed', stepId: context.toStepId, stepIndex: engine.currentStepIndex });\n }\n await props.onAfterStepChange?.(context);\n },\n };\n const engine = useFormEngineStore(definition, initialValues, engineOptions);\n const version = useFormSnapshot(engine);\n const previousStep = useRef(engine.currentStep?.id);\n const actions = useRendererActions(engine, props);\n\n const appliedErrors = useRef<{ engine: typeof engine; errors: Record<string, string> } | null>(null);\n useEffect(() => {\n if (!props.errors) return;\n const previous = appliedErrors.current?.engine === engine ? appliedErrors.current.errors : undefined;\n if (!shouldApplyExternalErrors(engine, previous, props.errors)) return;\n appliedErrors.current = { engine, errors: props.errors };\n engine.setErrors(props.errors);\n }, [props.errors, engine]);\n\n useEffect(() => {\n if (previousStep.current !== engine.currentStep?.id) focusPending.current = true;\n previousStep.current = engine.currentStep?.id;\n if (engine.stepValidating || engine.submitting) {\n wasBusy.current = true;\n return;\n }\n const restore = wasBusy.current;\n wasBusy.current = false;\n if (!focusPending.current) {\n const document = formRef.current?.ownerDocument;\n if (restore && document?.activeElement === document?.body && focusReturn.current?.isConnected) focusReturn.current.focus();\n return;\n }\n focusPending.current = false;\n const target = formRef.current?.querySelector<HTMLElement>(\n '.fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)',\n );\n (target ?? formRef.current)?.focus();\n }, [engine, version]);\n\n const handleFieldFocus = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_focused', fieldKey: key });\n }, [onAnalyticsEvent]);\n const handleFieldBlur = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_blurred', fieldKey: key,\n hasValue: engine.values[key] !== undefined && engine.values[key] !== '' });\n }, [engine, onAnalyticsEvent]);\n const handleCancel = useCallback(() => props.onCancel?.(), [props.onCancel]);\n\n return (\n <form ref={formRef} onFocusCapture={(event) => { focusReturn.current = event.target; }} className=\"fh-form\" tabIndex={-1} aria-busy={engine.stepValidating || engine.submitting || loading}\n onSubmit={(event) => { event.preventDefault(); void (engine.isLastStep ? actions.submit() : actions.next()); }}>\n <FormProgressController engine={engine} ProgressComponent={ProgressComponent} />\n <FormFieldsController key={definition.id} engine={engine} loading={loading} components={components}\n optionsProviders={optionsProviders} onChange={actions.update} onCommit={actions.commit}\n onBlur={handleFieldBlur} onFocus={handleFieldFocus} />\n <FormTopLevelErrors engine={engine} actionError={actions.actionError} />\n <FormActionsController engine={engine} definition={definition} loading={loading}\n ActionsComponent={ActionsComponent} onSubmit={actions.submit} onNext={actions.next}\n onPrev={actions.prev} 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","interface FieldMessageProps {\n error?: string;\n helperText?: string;\n errorId: string;\n helperId: string;\n}\n\nexport function FieldMessage({ error, helperText, errorId, helperId }: FieldMessageProps) {\n if (error) {\n return <p id={errorId} className=\"fh-field__error\" role=\"alert\">{error}</p>;\n }\n if (helperText) {\n return <p id={helperId} className=\"fh-field__helper\">{helperText}</p>;\n }\n return null;\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function AutocompleteField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const listId = `${field.key}-list`;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n const options = field.options ?? [];\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <input\n id={inputId}\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 disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n autoComplete=\"off\"\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n onFocus={onFocus}\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 <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldMessage } from './FieldMessage';\n\nexport function CheckboxField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field fh-field--checkbox\">\n <div className=\"fh-field__checkbox-wrapper\">\n <input\n id={inputId}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={!!value}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.checked)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n {field.label && (\n <label className=\"fh-field__label\" htmlFor={inputId}>\n {field.label}\n </label>\n )}\n </div>\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function DateField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <input\n id={inputId}\n type=\"date\"\n className=\"fh-field__input fh-field__input--date\"\n value={String(value ?? '')}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function DateTimeField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <input\n id={inputId}\n type=\"datetime-local\"\n className=\"fh-field__input fh-field__input--datetime\"\n value={String(value ?? '')}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function FileField({\n field,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <input\n id={inputId}\n type=\"file\"\n className=\"fh-field__input fh-field__input--file\"\n accept={field.accept}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => {\n const files = e.target.files;\n onChange(files && files.length > 0 ? files[0] : null);\n }}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldMessage } from './FieldMessage';\n\nexport function MultiselectField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const groupId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\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 <fieldset\n className=\"fh-field fh-field--multiselect\"\n aria-invalid={!!error || undefined}\n aria-describedby={describedBy}\n >\n {field.label && <legend className=\"fh-field__label\">{field.label}</legend>}\n <div className=\"fh-field__multiselect-group\">\n {options.map((opt) => {\n const optionId = `${groupId}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__multiselect-option\">\n <input\n id={optionId}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={selected.includes(opt.value)}\n disabled={disabled || loading}\n onChange={() => handleToggle(opt.value)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <label className=\"fh-field__multiselect-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </div>\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </fieldset>\n );\n}\n","import { useRef } from 'react';\nimport type { FieldComponentProps } from '../types';\nimport { FieldMessage } from './FieldMessage';\n\nexport function RadioField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const arrowSelection = useRef(false);\n const commit = field.autoAdvance && onCommit;\n const groupId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n const options = field.options ?? [];\n\n return (\n <fieldset\n className=\"fh-field fh-field--radio\"\n aria-invalid={!!error || undefined}\n aria-describedby={describedBy}\n >\n {field.label && <legend className=\"fh-field__label\">{field.label}</legend>}\n <div className=\"fh-field__radio-group\">\n {options.map((opt) => {\n const optionId = `${groupId}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__radio-option\">\n <input\n id={optionId}\n type=\"radio\"\n className=\"fh-field__radio\"\n name={groupId}\n value={opt.value}\n checked={String(value) === String(opt.value)}\n disabled={disabled || loading}\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 onBlur={onBlur}\n onFocus={onFocus}\n />\n <label className=\"fh-field__radio-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </div>\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </fieldset>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function SelectField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n const options = field.options ?? [];\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <select\n id={inputId}\n className=\"fh-field__input fh-field__input--select\"\n value={(value as string) ?? ''}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n onFocus={onFocus}\n >\n {field.placeholder && (\n <option value=\"\" disabled>\n {field.placeholder}\n </option>\n )}\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldMessage } from './FieldMessage';\n\nexport function SwitchField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field fh-field--switch\">\n <div className=\"fh-field__switch-wrapper\">\n <input\n id={inputId}\n type=\"checkbox\"\n role=\"switch\"\n className=\"fh-field__switch\"\n checked={!!value}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.checked)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n {field.label && (\n <label className=\"fh-field__label\" htmlFor={inputId}>\n {field.label}\n </label>\n )}\n </div>\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nexport function TextField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n onChange(field.type === 'number' && v !== '' ? Number(v) : v);\n };\n\n const inputType =\n field.type === 'email'\n ? 'email'\n : field.type === 'phone'\n ? 'tel'\n : field.type === 'number'\n ? 'number'\n : field.type === 'password'\n ? 'password'\n : 'text';\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <input\n id={inputId}\n type={inputType}\n className=\"fh-field__input\"\n value={value != null ? String(value) : ''}\n placeholder={field.placeholder ?? field.mask}\n disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={handleChange}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\n\nconst DEFAULT_ROWS = 3;\n\nexport function TextareaField({\n field,\n value,\n error,\n loading,\n disabled,\n onChange,\n onBlur,\n onFocus,\n}: FieldComponentProps) {\n const inputId = field.key;\n const helperId = `${field.key}-helper`;\n const errorId = `${field.key}-error`;\n const describedBy = error ? errorId : field.helperText ? helperId : undefined;\n\n return (\n <div className=\"fh-field\">\n <FieldLabel field={field} inputId={inputId} />\n <textarea\n id={inputId}\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 disabled={disabled || loading}\n aria-invalid={!!error}\n aria-describedby={describedBy}\n onChange={(e) => onChange(e.target.value)}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n <FieldMessage error={error} helperText={field.helperText} errorId={errorId} helperId={helperId} />\n </div>\n );\n}\n","import type { DefaultFieldType } from '@formhaus/core';\nimport type { ComponentType } from 'react';\nimport { AutocompleteField } from './fields/AutocompleteField';\nimport { CheckboxField } from './fields/CheckboxField';\nimport { DateField } from './fields/DateField';\nimport { DateTimeField } from './fields/DateTimeField';\nimport { FileField } from './fields/FileField';\nimport { MultiselectField } from './fields/MultiselectField';\nimport { RadioField } from './fields/RadioField';\nimport { SelectField } from './fields/SelectField';\nimport { SwitchField } from './fields/SwitchField';\nimport { TextField } from './fields/TextField';\nimport { TextareaField } from './fields/TextareaField';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\nconst defaultFieldComponents: Record<DefaultFieldType, ComponentType<FieldComponentProps>> = {\n text: TextField,\n email: TextField,\n phone: TextField,\n number: TextField,\n password: TextField,\n select: SelectField,\n autocomplete: AutocompleteField,\n multiselect: MultiselectField,\n checkbox: CheckboxField,\n radio: RadioField,\n switch: SwitchField,\n file: FileField,\n date: DateField,\n datetime: DateTimeField,\n textarea: TextareaField,\n};\n\nexport function withDefaultFields(components?: FieldComponentMap): FieldComponentMap {\n const merged: FieldComponentMap = { ...defaultFieldComponents };\n for (const [type, component] of Object.entries(components ?? {})) {\n if (component) merged[type] = component;\n }\n return merged;\n}\n","import { useMemo } from 'react';\nimport { FormActions } from './FormActions';\nimport { FormStepProgress } from './FormStepProgress';\nimport { HeadlessFormRenderer } from './HeadlessFormRenderer';\nimport { withDefaultFields } from './defaultFieldComponents';\nimport type { FormRendererProps } from './types';\n\nexport function FormRenderer({\n components,\n ActionsComponent,\n ProgressComponent,\n ...props\n}: FormRendererProps) {\n const fieldComponents = useMemo(() => withDefaultFields(components), [components]);\n\n return (\n <HeadlessFormRenderer\n {...props}\n components={fieldComponents}\n ActionsComponent={ActionsComponent ?? FormActions}\n ProgressComponent={ProgressComponent ?? FormStepProgress}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/isActionDisabled.ts","../src/FormActions.tsx","../src/FormStepProgress.tsx","../src/hooks/useEngineSnapshot.ts","../src/FormActionsController.tsx","../src/FormField.tsx","../src/FormFieldController.tsx","../src/hooks/useFieldOptions.ts","../src/FormFieldsController.tsx","../src/FormProgressController.tsx","../src/FormTopLevelErrors.tsx","../src/hooks/useFormEngine.ts","../src/hooks/useRendererActions.ts","../src/HeadlessFormRenderer.tsx","../src/fields/FieldLabel.tsx","../src/fields/FieldMessage.tsx","../src/fields/fieldProps.ts","../src/fields/FieldShell.tsx","../src/fields/AutocompleteField.tsx","../src/fields/CheckboxField.tsx","../src/fields/DateField.tsx","../src/fields/DateTimeField.tsx","../src/fields/FileField.tsx","../src/fields/MultiselectField.tsx","../src/fields/RadioField.tsx","../src/fields/SelectField.tsx","../src/fields/SwitchField.tsx","../src/fields/TextField.tsx","../src/fields/TextareaField.tsx","../src/defaultFieldComponents.ts","../src/FormRenderer.tsx"],"names":["isActionDisabled","action","values","loading","c","evaluateCondition","buttonClass","variant","FormActions","submitAction","backAction","cancelAction","skipAction","isFirstStep","isLastStep","isMultiStep","showPrimary","onSubmit","onNext","onPrev","onCancel","onSkip","primaryLabelProp","showBackProp","backLabelProp","showSkipProp","skipLabelProp","onPrimaryProp","showBack","backLabel","showSkip","skipLabel","primaryLabel","primaryDisabled","handlePrimary","jsxs","jsx","FormStepProgress","current","total","stepTitle","stepDescription","percent","useFormSnapshot","engine","subscribe","useCallback","listener","getSnapshot","useSyncExternalStore","useStructureSnapshot","FormActionsController","definition","ActionsComponent","step","FormField","field","value","error","disabled","components","onChange","onCommit","onBlur","onFocus","Component","FormFieldController","memo","options","handleChange","handleCommit","handleBlur","handleFocus","fieldWithOptions","areOptionsEqual","previous","next","option","index","useFieldOptions","fields","providers","resolved","setResolved","useState","requestVersions","useRef","useEffect","active","unsubscribers","commit","fieldKey","provider","resolve","requestVersion","result","dependency","unsubscribe","FormFieldsController","optionsProviders","resolvedOptions","FormProgressController","ProgressComponent","FormTopLevelErrors","actionError","errors","useFormEngineStore","initialValues","optionsRef","engineRef","definitionIdRef","FormEngine","useFormEngine","useRendererActions","props","onError","onFieldChange","onAnalyticsEvent","failure","setFailure","run","prev","update","key","send","report","submit","skip","HeadlessFormRenderer","formRef","focusPending","focusReturn","wasBusy","engineOptions","context","version","previousStep","actions","appliedErrors","shouldApplyExternalErrors","restore","document","handleFieldFocus","handleFieldBlur","handleCancel","event","FieldLabel","inputId","FieldMessage","describedBy","optionProps","inputProps","FieldShell","children","group","Fragment","AutocompleteField","listId","e","opt","CheckboxField","DateField","DateTimeField","FileField","files","MultiselectField","selected","handleToggle","optValue","v","optionId","RadioField","arrowSelection","SelectField","SwitchField","TextField","inputType","DEFAULT_ROWS","TextareaField","defaultFieldComponents","withDefaultFields","merged","type","component","FormRenderer","fieldComponents","useMemo"],"mappings":"kOAGO,SAASA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,EACS,CACT,OAAIA,EAAgB,IAAA,CAChB,CAACF,GAAQ,QAAA,EAAYA,CAAAA,CAAO,QAAA,CAAS,MAAA,GAAW,CAAA,CAAU,KAAA,CACvDA,EAAO,QAAA,CAAS,KAAA,CAAOG,GAAMC,iBAAAA,CAAkBD,CAAAA,CAAGF,CAAM,CAAC,CAClE,CCPA,SAASI,CAAAA,CAAYL,CAAAA,CAAwCM,CAAAA,CAAqD,CAChH,OAAO,CAAA,iDAAA,EAAqDN,CAAAA,EAAUA,CAAAA,CAAO,OAAA,EAAYM,CAAO,EAClG,CAEO,SAASC,EAAY,CAC1B,YAAA,CAAAC,EACA,UAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,UAAA,CAAAC,CAAAA,CACA,YAAAC,CAAAA,CACA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CACP,MAAA,CAAQA,CAAAA,CACR,QAAA,CAAUA,EACV,MAAA,CAAQF,EAAAA,CACR,aAAcjB,EAAAA,CACd,WAAA,CAAaS,GACb,QAAA,CAAUL,EAAAA,CACV,KAAA,CAAOW,EAAAA,CACP,MAAA,CAAQG,EAAAA,CACR,KAAMX,EAAAA,CACN,IAAA,CAAMF,GACN,QAAA,CAAUC,EAAAA,CACV,SAAUgB,EACZ,CAAA,CAEO,SAASE,EAAAA,CAAkBxH,CAAAA,CAAmD,CACnF,IAAMyH,CAAAA,CAA4B,CAAE,GAAGF,EAAuB,CAAA,CAC9D,IAAA,GAAW,CAACG,CAAAA,CAAMC,CAAS,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQ3H,CAAAA,EAAc,EAAE,CAAA,CACzD2H,IAAWF,CAAAA,CAAOC,CAAI,EAAIC,CAAAA,CAAAA,CAEhC,OAAOF,CACT,CChCO,SAASG,EAAAA,CAAa,CAC3B,UAAA,CAAA5H,CAAAA,CACA,gBAAA,CAAAP,EACA,iBAAA,CAAAiD,CAAAA,CACA,GAAGY,CACL,CAAA,CAAsB,CACpB,IAAMuE,CAAAA,CAAkBC,OAAAA,CAAQ,IAAMN,EAAAA,CAAkBxH,CAAU,EAAG,CAACA,CAAU,CAAC,CAAA,CAEjF,OACExB,GAAAA,CAAC4F,EAAA,CACE,GAAGd,CAAAA,CACJ,UAAA,CAAYuE,CAAAA,CACZ,gBAAA,CAAkBpI,GAAoB7C,CAAAA,CACtC,iBAAA,CAAmB8F,CAAAA,EAAqBjE,CAAAA,CAC1C,CAEJ","file":"index.js","sourcesContent":["import { evaluateCondition } from '@formhaus/core';\nimport type { FormAction } from '@formhaus/core';\n\nexport function isActionDisabled(\n action: FormAction | undefined,\n values: Record<string, unknown>,\n loading?: boolean,\n): boolean {\n if (loading) return true;\n if (!action?.disabled || action.disabled.length === 0) return false;\n return action.disabled.every((c) => evaluateCondition(c, values));\n}\n","import type { FormAction } from '@formhaus/core';\nimport { isActionDisabled } from './isActionDisabled';\nimport type { FormActionsProps } from './types';\n\nfunction buttonClass(action: FormAction | false | undefined, variant: NonNullable<FormAction['variant']>): string {\n return `fh-form-actions__button fh-form-actions__button--${(action && action.variant) || variant}`;\n}\n\nexport function FormActions({\n submitAction,\n backAction,\n cancelAction,\n skipAction,\n isFirstStep,\n isLastStep,\n isMultiStep,\n loading,\n showPrimary = true,\n values = {},\n onSubmit,\n onNext,\n onPrev,\n onCancel,\n onSkip,\n primaryLabel: primaryLabelProp,\n showBack: showBackProp,\n backLabel: backLabelProp,\n showSkip: showSkipProp,\n skipLabel: skipLabelProp,\n onPrimary: onPrimaryProp,\n}: FormActionsProps) {\n const showBack = showBackProp ?? (isMultiStep && !isFirstStep && backAction !== false);\n const backLabel = backLabelProp ?? (backAction || undefined)?.label ?? 'Back';\n const showSkip = showSkipProp ?? (isMultiStep && !!skipAction);\n const skipLabel = skipLabelProp ?? skipAction?.label ?? 'Skip';\n const primaryLabel = primaryLabelProp ?? (isMultiStep && !isLastStep ? 'Continue' : (submitAction?.label ?? 'Submit'));\n\n const primaryDisabled = isActionDisabled(\n isMultiStep && !isLastStep ? undefined : submitAction,\n values,\n loading,\n );\n\n const handlePrimary = onPrimaryProp ?? (isMultiStep && !isLastStep ? onNext : onSubmit);\n\n return (\n <div className=\"fh-form-actions\">\n <div className=\"fh-form-actions__secondary\">\n {showBack && (\n <button type=\"button\" className={buttonClass(backAction, 'secondary')} disabled={loading} onClick={onPrev}>\n {backLabel}\n </button>\n )}\n {cancelAction && (\n <button type=\"button\" className={buttonClass(cancelAction, 'text')} disabled={loading} onClick={onCancel}>\n {cancelAction.label}\n </button>\n )}\n {showSkip && (\n <button type=\"button\" className={buttonClass(skipAction, 'text')} disabled={loading} onClick={onSkip}>\n {skipLabel}\n </button>\n )}\n </div>\n {showPrimary && <button\n type=\"button\"\n className=\"fh-form-actions__button fh-form-actions__button--primary\"\n disabled={primaryDisabled}\n aria-busy={loading}\n onClick={() => handlePrimary()}\n >\n {primaryLabel}\n </button>}\n </div>\n );\n}\n","import type { FormStepProgressProps } from './types';\n\nexport function FormStepProgress({\n current,\n total,\n stepTitle,\n stepDescription,\n}: FormStepProgressProps) {\n const percent = (current / total) * 100;\n\n return (\n <div className=\"fh-step-progress\">\n <div className=\"fh-step-progress__bar\">\n <div className=\"fh-step-progress__fill\" style={{ width: `${percent}%` }} />\n </div>\n <div className=\"fh-step-progress__info\">\n <span className=\"fh-step-progress__counter\">\n Step {current} of {total}\n </span>\n </div>\n {stepTitle && <h3 className=\"fh-step-progress__title\">{stepTitle}</h3>}\n {stepDescription && <p className=\"fh-step-progress__description\">{stepDescription}</p>}\n </div>\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useSyncExternalStore } from 'react';\n\nexport function useFormSnapshot(engine: FormEngine): number {\n const subscribe = useCallback((listener: () => void) => engine.subscribe(listener), [engine]);\n const getSnapshot = useCallback(() => engine.getSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useStructureSnapshot(engine: FormEngine): number {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeStructure(listener),\n [engine],\n );\n const getSnapshot = useCallback(() => engine.getStructureSnapshot(), [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback } from 'react';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormActionsControllerProps {\n engine: FormEngine;\n definition: FormRendererProps['definition'];\n loading: boolean;\n ActionsComponent: FormRendererProps['ActionsComponent'];\n onSubmit: () => void;\n onNext: () => Promise<void>;\n onPrev: () => void;\n onSkip: () => void;\n onCancel: () => void;\n}\n\nexport function FormActionsController({\n engine,\n definition,\n loading,\n ActionsComponent,\n onSubmit,\n onNext,\n onPrev,\n onSkip,\n onCancel,\n}: FormActionsControllerProps) {\n useFormSnapshot(engine);\n const step = engine.currentStep;\n const isLastStep = engine.isLastStep || !engine.isMultiStep;\n const primaryLabel = engine.isMultiStep && !isLastStep\n ? ((step?.next || undefined)?.label ?? 'Continue')\n : (definition.submit?.label ?? 'Submit');\n const showBack = engine.isMultiStep && !engine.isFirstStep && step?.back !== false;\n const backLabel = (step?.back || undefined)?.label ?? 'Back';\n const handlePrimary = useCallback(async () => {\n if (engine.isMultiStep && !isLastStep) await onNext();\n else onSubmit();\n }, [engine, isLastStep, onNext, onSubmit]);\n\n if (!ActionsComponent) return null;\n\n return (\n <ActionsComponent\n submitAction={definition.submit}\n backAction={step?.back}\n cancelAction={definition.cancel}\n skipAction={step?.skip}\n isFirstStep={engine.isFirstStep}\n isLastStep={isLastStep}\n isMultiStep={engine.isMultiStep}\n loading={loading || engine.stepValidating || engine.submitting}\n values={engine.values}\n onSubmit={onSubmit}\n onNext={onNext}\n onPrev={onPrev}\n onCancel={onCancel}\n onSkip={onSkip}\n primaryLabel={primaryLabel}\n showPrimary={isLastStep || step?.next !== false}\n showBack={showBack}\n backLabel={backLabel}\n showSkip={!!step?.skip && step.next !== false}\n onPrimary={handlePrimary}\n />\n );\n}\n","import type { FormField as FormFieldType } from '@formhaus/core';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\ninterface FormFieldProps {\n field: FormFieldType;\n value: unknown;\n error?: string;\n loading?: boolean;\n disabled?: boolean;\n components?: FieldComponentMap;\n onChange: (value: unknown) => void;\n onCommit?: (value: unknown) => void;\n onBlur: () => void;\n onFocus?: () => void;\n}\n\nexport function FormField({\n field,\n value,\n error,\n loading,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldProps) {\n const Component = components?.[field.type];\n\n if (!Component) {\n return <div>Unsupported field type: {field.type}</div>;\n }\n\n return (\n <Component\n field={field}\n value={value}\n error={error}\n loading={loading}\n disabled={disabled}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n );\n}\n","import type { FieldOption, FormEngine, FormField as FormFieldType } from '@formhaus/core';\nimport { memo, useCallback, useSyncExternalStore } from 'react';\nimport { FormField } from './FormField';\nimport type { FieldComponentMap } from './types';\n\nexport interface ControllerProps {\n engine: FormEngine;\n components?: FieldComponentMap;\n onChange: (key: string, value: unknown) => void;\n onCommit: (key: string, value: unknown) => void;\n onBlur: (key: string) => void;\n onFocus: (key: string) => void;\n}\n\ninterface FormFieldControllerProps extends ControllerProps {\n field: FormFieldType;\n options?: FieldOption[];\n disabled?: boolean;\n}\n\nexport const FormFieldController = memo(function FormFieldController({\n engine,\n field,\n options,\n disabled,\n components,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldControllerProps) {\n const subscribe = useCallback(\n (listener: () => void) => engine.subscribeField(field.key, listener),\n [engine, field.key],\n );\n const getSnapshot = useCallback(\n () => engine.getFieldSnapshot(field.key),\n [engine, field.key],\n );\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const handleChange = useCallback(\n (value: unknown) => onChange(field.key, value),\n [field.key, onChange],\n );\n const handleCommit = useCallback((value: unknown) => onCommit(field.key, value), [field.key, onCommit]);\n const handleBlur = useCallback(() => onBlur(field.key), [field.key, onBlur]);\n const handleFocus = useCallback(() => onFocus(field.key), [field.key, onFocus]);\n const fieldWithOptions = options ? { ...field, options } : field;\n\n return (\n <FormField\n field={fieldWithOptions}\n value={engine.values[field.key]}\n error={engine.errors[field.key]}\n loading={engine.fieldLoading[field.key]}\n disabled={disabled}\n components={components}\n onChange={handleChange}\n onCommit={handleCommit}\n onBlur={handleBlur}\n onFocus={handleFocus}\n />\n );\n});\n","import type { FieldOption, FormEngine, FormField } from '@formhaus/core';\nimport { useEffect, useRef, useState } from 'react';\nimport type { OptionsProvider } from '../types';\n\nfunction areOptionsEqual(previous: FieldOption[] | undefined, next: FieldOption[]): boolean {\n return previous?.length === next.length && previous.every((option, index) => (\n option.value === next[index].value && option.label === next[index].label\n ));\n}\n\nexport function useFieldOptions(\n fields: FormField[],\n engine: FormEngine,\n providers?: Record<string, OptionsProvider>,\n): Record<string, FieldOption[]> {\n const [resolved, setResolved] = useState<Record<string, FieldOption[]>>({});\n const requestVersions = useRef<Map<string, number>>(new Map());\n\n useEffect(() => {\n if (!providers) {\n setResolved((previous) => (\n Object.keys(previous).length > 0 ? {} : previous\n ));\n return;\n }\n\n let active = true;\n const unsubscribers: (() => void)[] = [];\n\n const commit = (fieldKey: string, options: FieldOption[]) => {\n if (!active) return;\n setResolved((previous) => {\n if (areOptionsEqual(previous[fieldKey], options)) return previous;\n return { ...previous, [fieldKey]: options };\n });\n };\n\n for (const field of fields) {\n if (!field.optionsFrom) continue;\n\n const provider = providers[field.optionsFrom];\n if (!provider) continue;\n\n const resolve = () => {\n const requestVersion = (requestVersions.current.get(field.key) ?? 0) + 1;\n requestVersions.current.set(field.key, requestVersion);\n\n try {\n const result = provider(engine.values);\n if (Array.isArray(result)) {\n commit(field.key, result);\n return;\n }\n\n result\n .then((options) => {\n if (requestVersions.current.get(field.key) === requestVersion) {\n commit(field.key, options);\n }\n })\n .catch(() => {});\n } catch {}\n };\n\n resolve();\n for (const dependency of new Set(field.optionsDependsOn ?? [])) {\n unsubscribers.push(engine.subscribeField(dependency, resolve));\n }\n }\n\n return () => {\n active = false;\n for (const unsubscribe of unsubscribers) unsubscribe();\n };\n }, [engine, fields, providers]);\n\n return resolved;\n}\n","import { memo } from 'react';\nimport { type ControllerProps, FormFieldController } from './FormFieldController';\nimport { useFormSnapshot, useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport { useFieldOptions } from './hooks/useFieldOptions';\nimport type { OptionsProvider } from './types';\n\ninterface FormFieldsControllerProps extends ControllerProps {\n loading: boolean;\n optionsProviders?: Record<string, OptionsProvider>;\n}\n\nexport const FormFieldsController = memo(function FormFieldsController({\n engine,\n loading,\n components,\n optionsProviders,\n onChange,\n onCommit,\n onBlur,\n onFocus,\n}: FormFieldsControllerProps) {\n useStructureSnapshot(engine);\n useFormSnapshot(engine);\n const fields = engine.visibleFields;\n const resolvedOptions = useFieldOptions(fields, engine, optionsProviders);\n\n return (\n <div className=\"fh-form__fields\">\n {fields.map((field) => (\n <FormFieldController\n key={field.key}\n engine={engine}\n field={field}\n options={resolvedOptions[field.key] ?? field.options}\n disabled={loading || engine.stepValidating || engine.submitting}\n components={components}\n onChange={onChange}\n onCommit={onCommit}\n onBlur={onBlur}\n onFocus={onFocus}\n />\n ))}\n </div>\n );\n});\n","import type { FormEngine } from '@formhaus/core';\nimport { useStructureSnapshot } from './hooks/useEngineSnapshot';\nimport type { FormRendererProps } from './types';\n\ninterface FormProgressControllerProps {\n engine: FormEngine;\n ProgressComponent: FormRendererProps['ProgressComponent'];\n}\n\nexport function FormProgressController({\n engine,\n ProgressComponent,\n}: FormProgressControllerProps) {\n useStructureSnapshot(engine);\n if (!engine.isMultiStep || !ProgressComponent) return null;\n\n return (\n <ProgressComponent\n current={engine.progress.current}\n total={engine.progress.total}\n stepTitle={engine.currentStep?.title}\n stepDescription={engine.currentStep?.description}\n />\n );\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\n\nexport function FormTopLevelErrors({ engine, actionError }: { engine: FormEngine; actionError?: string | null }) {\n useFormSnapshot(engine);\n const errors = actionError ? [...engine.topLevelErrors, actionError] : engine.topLevelErrors;\n if (errors.length === 0) return null;\n\n return (\n <div className=\"fh-form__top-errors\">\n {errors.map((error, index) => (\n <p key={index} className=\"fh-form__top-error\">\n {error}\n </p>\n ))}\n </div>\n );\n}\n","import { FormEngine, type FormEngineOptions, type FormDefinition } from '@formhaus/core';\nimport { useEffect, useRef } from 'react';\nimport { useFormSnapshot } from './useEngineSnapshot';\n\nexport function useFormEngineStore(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n const engineRef = useRef<FormEngine | null>(null);\n const definitionIdRef = useRef<string>(definition.id);\n\n if (engineRef.current === null || definitionIdRef.current !== definition.id) {\n engineRef.current = new FormEngine(definition, initialValues, {\n validators: options?.validators,\n get onStepValidate() { return optionsRef.current?.onStepValidate; },\n get onBeforeStepChange() { return optionsRef.current?.onBeforeStepChange; },\n get onAfterStepChange() { return optionsRef.current?.onAfterStepChange; },\n get onBeforeSubmit() { return optionsRef.current?.onBeforeSubmit; },\n get onAfterSubmit() { return optionsRef.current?.onAfterSubmit; },\n });\n definitionIdRef.current = definition.id;\n }\n\n const engine = engineRef.current;\n useEffect(() => () => engine.cancelPendingActions(), [engine]);\n return engine;\n}\n\nexport function useFormEngine(\n definition: FormDefinition,\n initialValues?: Record<string, unknown>,\n options?: FormEngineOptions,\n): FormEngine {\n const engine = useFormEngineStore(definition, initialValues, options);\n useFormSnapshot(engine);\n return engine;\n}\n","import type { FormEngine } from '@formhaus/core';\nimport { useCallback, useState } from 'react';\nimport { isActionDisabled } from '../isActionDisabled';\nimport type { FormRendererProps } from '../types';\n\nexport function useRendererActions(engine: FormEngine, props: FormRendererProps) {\n const { loading, onError, onFieldChange, onSubmit, onAnalyticsEvent } = props;\n const [failure, setFailure] = useState<{ engine: FormEngine; message: string } | null>(null);\n const run = useCallback(async (action: () => Promise<boolean>) => {\n if (loading) return;\n setFailure(null);\n try { await action(); }\n catch (error) {\n if (onError) onError(error);\n else setFailure({ engine, message: error instanceof Error ? error.message : 'Form action failed' });\n }\n }, [engine, loading, onError]);\n const next = useCallback(() => run(() => engine.nextStepAsync()), [run, engine]);\n const prev = useCallback(() => run(() => engine.prevStepAsync()), [run, engine]);\n const update = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n engine.setValue(key, value);\n onFieldChange?.(key, value, engine.values);\n }, [engine, loading, onFieldChange]);\n const commit = useCallback((key: string, value: unknown) => {\n if (loading || engine.stepValidating || engine.submitting) return;\n const step = engine.currentStep;\n const field = engine.visibleFields.find((field) => field.key === key);\n if (!field) return;\n update(key, value);\n if (field.autoAdvance && engine.currentStep?.id === step?.id && !engine.isLastStep) void run(() => engine.nextStepAsync('autoAdvance'));\n }, [engine, loading, run, update]);\n const send = useCallback(async (values: Record<string, unknown>) => {\n onAnalyticsEvent?.({ type: 'form_submitted', fieldCount: Object.keys(values).length });\n await onSubmit(values);\n }, [onSubmit, onAnalyticsEvent]);\n const report = useCallback(async (action: Promise<boolean>) => {\n const result = await action;\n if (!result) {\n for (const [key, error] of Object.entries(engine.errors)) {\n onAnalyticsEvent?.({ type: 'field_error', fieldKey: key, error });\n }\n }\n return result;\n }, [engine, onAnalyticsEvent]);\n const submit = useCallback(() => run(async () => (\n !isActionDisabled(engine.definition.submit, engine.values) && report(engine.submitAsync(send))\n )), [engine, run, send, report]);\n const skip = useCallback(() => run(() => report(engine.skipStepAsync((values) => {\n onAnalyticsEvent?.({ type: 'step_skipped', stepId: engine.currentStep!.id });\n return send(values);\n }))), [run, engine, send, report, onAnalyticsEvent]);\n const actionError = failure?.engine === engine ? failure.message : null;\n return { next, prev, skip, update, commit, submit, actionError };\n}\n","import { shouldApplyExternalErrors, type FormEngineOptions } from '@formhaus/core';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { FormActionsController } from './FormActionsController';\nimport { FormFieldsController } from './FormFieldsController';\nimport { FormProgressController } from './FormProgressController';\nimport { FormTopLevelErrors } from './FormTopLevelErrors';\nimport { useFormEngineStore } from './hooks/useFormEngine';\nimport { useFormSnapshot } from './hooks/useEngineSnapshot';\nimport { useRendererActions } from './hooks/useRendererActions';\nimport type { FormRendererProps } from './types';\n\nexport function HeadlessFormRenderer(props: FormRendererProps) {\n const { definition, initialValues, loading = false, components, optionsProviders,\n ActionsComponent, ProgressComponent, onAnalyticsEvent } = props;\n const formRef = useRef<HTMLFormElement>(null);\n const focusPending = useRef(false);\n const focusReturn = useRef<HTMLElement | null>(null);\n const wasBusy = useRef(false);\n const engineOptions: FormEngineOptions = {\n ...props,\n onAfterStepChange: async (context) => {\n focusPending.current = true;\n props.onStepChange?.(context.toStepId, context.direction);\n if (context.direction === 'next') {\n onAnalyticsEvent?.({ type: context.reason === 'skip' ? 'step_skipped' : 'step_completed', stepId: context.fromStepId });\n onAnalyticsEvent?.({ type: 'step_viewed', stepId: context.toStepId, stepIndex: engine.currentStepIndex });\n }\n await props.onAfterStepChange?.(context);\n },\n };\n const engine = useFormEngineStore(definition, initialValues, engineOptions);\n const version = useFormSnapshot(engine);\n const previousStep = useRef(engine.currentStep?.id);\n const actions = useRendererActions(engine, props);\n\n const appliedErrors = useRef<{ engine: typeof engine; errors: Record<string, string> } | null>(null);\n useEffect(() => {\n if (!props.errors) return;\n const previous = appliedErrors.current?.engine === engine ? appliedErrors.current.errors : undefined;\n if (!shouldApplyExternalErrors(engine, previous, props.errors)) return;\n appliedErrors.current = { engine, errors: props.errors };\n engine.setErrors(props.errors);\n }, [props.errors, engine]);\n\n useEffect(() => {\n if (previousStep.current !== engine.currentStep?.id) focusPending.current = true;\n previousStep.current = engine.currentStep?.id;\n if (engine.stepValidating || engine.submitting) {\n wasBusy.current = true;\n return;\n }\n const restore = wasBusy.current;\n wasBusy.current = false;\n if (!focusPending.current) {\n const document = formRef.current?.ownerDocument;\n if (restore && document?.activeElement === document?.body && focusReturn.current?.isConnected) focusReturn.current.focus();\n return;\n }\n focusPending.current = false;\n const target = formRef.current?.querySelector<HTMLElement>(\n '.fh-form__fields input:not(:disabled), .fh-form__fields select:not(:disabled), .fh-form__fields textarea:not(:disabled), .fh-form__fields button:not(:disabled)',\n );\n (target ?? formRef.current)?.focus();\n }, [engine, version]);\n\n const handleFieldFocus = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_focused', fieldKey: key });\n }, [onAnalyticsEvent]);\n const handleFieldBlur = useCallback((key: string) => {\n onAnalyticsEvent?.({ type: 'field_blurred', fieldKey: key,\n hasValue: engine.values[key] !== undefined && engine.values[key] !== '' });\n }, [engine, onAnalyticsEvent]);\n const handleCancel = useCallback(() => props.onCancel?.(), [props.onCancel]);\n\n return (\n <form ref={formRef} onFocusCapture={(event) => { focusReturn.current = event.target; }} className=\"fh-form\" tabIndex={-1} aria-busy={engine.stepValidating || engine.submitting || loading}\n onSubmit={(event) => { event.preventDefault(); void (engine.isLastStep ? actions.submit() : actions.next()); }}>\n <FormProgressController engine={engine} ProgressComponent={ProgressComponent} />\n <FormFieldsController key={definition.id} engine={engine} loading={loading} components={components}\n optionsProviders={optionsProviders} onChange={actions.update} onCommit={actions.commit}\n onBlur={handleFieldBlur} onFocus={handleFieldFocus} />\n <FormTopLevelErrors engine={engine} actionError={actions.actionError} />\n <FormActionsController engine={engine} definition={definition} loading={loading}\n ActionsComponent={ActionsComponent} onSubmit={actions.submit} onNext={actions.next}\n onPrev={actions.prev} onSkip={actions.skip} onCancel={handleCancel} />\n </form>\n );\n}\n","import type { FormField } from '@formhaus/core';\n\ninterface FieldLabelProps {\n field: FormField;\n inputId: string;\n}\n\nexport function FieldLabel({ field, inputId }: FieldLabelProps) {\n if (!field.label) return null;\n return (\n <label className=\"fh-field__label\" htmlFor={inputId}>\n {field.label}\n {field.validation?.required && (\n <span className=\"fh-field__required\" aria-hidden=\"true\"> *</span>\n )}\n </label>\n );\n}\n","import type { FormField } from '@formhaus/core';\n\ninterface FieldMessageProps {\n field: FormField;\n error?: string;\n}\n\nexport function FieldMessage({ field, error }: FieldMessageProps) {\n if (error) {\n return <p id={`${field.key}-error`} className=\"fh-field__error\" role=\"alert\">{error}</p>;\n }\n if (field.helperText) {\n return <p id={`${field.key}-helper`} className=\"fh-field__helper\">{field.helperText}</p>;\n }\n return null;\n}\n","import type { FormField } from '@formhaus/core';\nimport type { FieldComponentProps } from '../types';\n\nexport function describedBy(field: FormField, error?: string) {\n return error ? `${field.key}-error` : field.helperText ? `${field.key}-helper` : undefined;\n}\n\nexport function optionProps({ disabled, loading, onBlur, onFocus }: FieldComponentProps) {\n return { disabled: disabled || loading, onBlur, onFocus };\n}\n\nexport function inputProps(props: FieldComponentProps) {\n return {\n id: props.field.key,\n ...optionProps(props),\n 'aria-invalid': !!props.error,\n 'aria-describedby': describedBy(props.field, props.error),\n };\n}\n","import type { FormField } from '@formhaus/core';\nimport type { ReactNode } from 'react';\nimport { FieldLabel } from './FieldLabel';\nimport { FieldMessage } from './FieldMessage';\nimport { describedBy } from './fieldProps';\n\ninterface FieldShellProps {\n field: FormField;\n error?: string;\n variant?: 'checkbox' | 'switch' | 'radio' | 'multiselect';\n children: ReactNode;\n}\n\nexport function FieldShell({ field, error, variant, children }: FieldShellProps) {\n const group = variant === 'radio' || variant === 'multiselect';\n const Root = group ? 'fieldset' : 'div';\n\n return (\n <Root\n className={variant ? `fh-field fh-field--${variant}` : 'fh-field'}\n aria-invalid={group ? !!error || undefined : undefined}\n aria-describedby={group ? describedBy(field, error) : undefined}\n >\n {group && field.label && <legend className=\"fh-field__label\">{field.label}</legend>}\n {variant ? (\n <div className={`fh-field__${variant}-${group ? 'group' : 'wrapper'}`}>\n {children}\n {!group && field.label && (\n <label className=\"fh-field__label\" htmlFor={field.key}>\n {field.label}\n </label>\n )}\n </div>\n ) : (\n <>\n <FieldLabel field={field} inputId={field.key} />\n {children}\n </>\n )}\n <FieldMessage field={field} error={error} />\n </Root>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function AutocompleteField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const listId = `${field.key}-list`;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"text\"\n list={listId}\n className=\"fh-field__input fh-field__input--autocomplete\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n autoComplete=\"off\"\n onChange={(e) => onChange(e.target.value)}\n />\n <datalist id={listId}>\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </datalist>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function CheckboxField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error} variant=\"checkbox\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function DateField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"date\"\n className=\"fh-field__input fh-field__input--date\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function DateTimeField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error}>\n <input\n {...inputProps(props)}\n type=\"datetime-local\"\n className=\"fh-field__input fh-field__input--datetime\"\n value={String(props.value ?? '')}\n onChange={(e) => props.onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function FileField(props: FieldComponentProps) {\n const { field, error, onChange } = props;\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type=\"file\"\n className=\"fh-field__input fh-field__input--file\"\n accept={field.accept}\n onChange={(e) => {\n const files = e.target.files;\n onChange(files && files.length > 0 ? files[0] : null);\n }}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { optionProps } from './fieldProps';\n\nexport function MultiselectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n const selected = Array.isArray(value) ? (value as (string | number)[]) : [];\n\n function handleToggle(optValue: string) {\n const next = selected.includes(optValue)\n ? selected.filter((v) => v !== optValue)\n : [...selected, optValue];\n onChange(next);\n }\n\n return (\n <FieldShell field={field} error={error} variant=\"multiselect\">\n {options.map((opt) => {\n const optionId = `${field.key}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__multiselect-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n type=\"checkbox\"\n className=\"fh-field__checkbox\"\n checked={selected.includes(opt.value)}\n onChange={() => handleToggle(opt.value)}\n />\n <label className=\"fh-field__multiselect-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import { useRef } from 'react';\nimport type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { optionProps } from './fieldProps';\n\nexport function RadioField(props: FieldComponentProps) {\n const { field, value, error, onChange, onCommit } = props;\n const arrowSelection = useRef(false);\n const commit = field.autoAdvance && onCommit;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error} variant=\"radio\">\n {options.map((opt) => {\n const optionId = `${field.key}-${opt.value}`;\n return (\n <div key={opt.value} className=\"fh-field__radio-option\">\n <input\n {...optionProps(props)}\n id={optionId}\n type=\"radio\"\n className=\"fh-field__radio\"\n name={field.key}\n value={opt.value}\n checked={String(value) === String(opt.value)}\n onChange={() => { if (!commit || arrowSelection.current) onChange(opt.value); }}\n onKeyDown={(event) => {\n arrowSelection.current = event.key.startsWith('Arrow');\n if (commit && event.key === ' ') event.preventDefault();\n if (commit && event.key === 'Enter') {\n event.preventDefault();\n if (!event.repeat) commit(opt.value);\n }\n }}\n onKeyUp={(event) => {\n arrowSelection.current = false;\n if (commit && event.key === ' ') { event.preventDefault(); commit(opt.value); }\n }}\n onPointerDown={() => { arrowSelection.current = false; }}\n onClick={(event) => {\n if (!commit || arrowSelection.current) return;\n if (event.detail > 1) event.preventDefault();\n else commit(opt.value);\n }}\n />\n <label className=\"fh-field__radio-label\" htmlFor={optionId}>\n {opt.label}\n </label>\n </div>\n );\n })}\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function SelectField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n const options = field.options ?? [];\n\n return (\n <FieldShell field={field} error={error}>\n <select\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--select\"\n value={(value as string) ?? ''}\n onChange={(e) => onChange(e.target.value)}\n >\n {field.placeholder && (\n <option value=\"\" disabled>\n {field.placeholder}\n </option>\n )}\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function SwitchField(props: FieldComponentProps) {\n return (\n <FieldShell field={props.field} error={props.error} variant=\"switch\">\n <input\n {...inputProps(props)}\n type=\"checkbox\"\n role=\"switch\"\n className=\"fh-field__switch\"\n checked={!!props.value}\n onChange={(e) => props.onChange(e.target.checked)}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nexport function TextField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const v = e.target.value;\n onChange(field.type === 'number' && v !== '' ? Number(v) : v);\n };\n\n const inputType =\n field.type === 'email'\n ? 'email'\n : field.type === 'phone'\n ? 'tel'\n : field.type === 'number'\n ? 'number'\n : field.type === 'password'\n ? 'password'\n : 'text';\n\n return (\n <FieldShell field={field} error={error}>\n <input\n {...inputProps(props)}\n type={inputType}\n className=\"fh-field__input\"\n value={value != null ? String(value) : ''}\n placeholder={field.placeholder ?? field.mask}\n onChange={handleChange}\n />\n </FieldShell>\n );\n}\n","import type { FieldComponentProps } from '../types';\nimport { FieldShell } from './FieldShell';\nimport { inputProps } from './fieldProps';\n\nconst DEFAULT_ROWS = 3;\n\nexport function TextareaField(props: FieldComponentProps) {\n const { field, value, error, onChange } = props;\n\n return (\n <FieldShell field={field} error={error}>\n <textarea\n {...inputProps(props)}\n className=\"fh-field__input fh-field__input--textarea\"\n value={(value as string) ?? ''}\n placeholder={field.placeholder}\n rows={field.rows ?? DEFAULT_ROWS}\n onChange={(e) => onChange(e.target.value)}\n />\n </FieldShell>\n );\n}\n","import type { DefaultFieldType } from '@formhaus/core';\nimport type { ComponentType } from 'react';\nimport { AutocompleteField } from './fields/AutocompleteField';\nimport { CheckboxField } from './fields/CheckboxField';\nimport { DateField } from './fields/DateField';\nimport { DateTimeField } from './fields/DateTimeField';\nimport { FileField } from './fields/FileField';\nimport { MultiselectField } from './fields/MultiselectField';\nimport { RadioField } from './fields/RadioField';\nimport { SelectField } from './fields/SelectField';\nimport { SwitchField } from './fields/SwitchField';\nimport { TextField } from './fields/TextField';\nimport { TextareaField } from './fields/TextareaField';\nimport type { FieldComponentMap, FieldComponentProps } from './types';\n\nconst defaultFieldComponents: Record<DefaultFieldType, ComponentType<FieldComponentProps>> = {\n text: TextField,\n email: TextField,\n phone: TextField,\n number: TextField,\n password: TextField,\n select: SelectField,\n autocomplete: AutocompleteField,\n multiselect: MultiselectField,\n checkbox: CheckboxField,\n radio: RadioField,\n switch: SwitchField,\n file: FileField,\n date: DateField,\n datetime: DateTimeField,\n textarea: TextareaField,\n};\n\nexport function withDefaultFields(components?: FieldComponentMap): FieldComponentMap {\n const merged: FieldComponentMap = { ...defaultFieldComponents };\n for (const [type, component] of Object.entries(components ?? {})) {\n if (component) merged[type] = component;\n }\n return merged;\n}\n","import { useMemo } from 'react';\nimport { FormActions } from './FormActions';\nimport { FormStepProgress } from './FormStepProgress';\nimport { HeadlessFormRenderer } from './HeadlessFormRenderer';\nimport { withDefaultFields } from './defaultFieldComponents';\nimport type { FormRendererProps } from './types';\n\nexport function FormRenderer({\n components,\n ActionsComponent,\n ProgressComponent,\n ...props\n}: FormRendererProps) {\n const fieldComponents = useMemo(() => withDefaultFields(components), [components]);\n\n return (\n <HeadlessFormRenderer\n {...props}\n components={fieldComponents}\n ActionsComponent={ActionsComponent ?? FormActions}\n ProgressComponent={ProgressComponent ?? FormStepProgress}\n />\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formhaus/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React components for Formhaus forms. Define a form once in JSON, render with native HTML or your own components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@formhaus/core": "0.
|
|
20
|
+
"@formhaus/core": "0.8.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=18.0.0"
|