@formhaus/react 0.2.1 → 0.3.1

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.
Files changed (61) hide show
  1. package/dist/index.d.ts +68 -6
  2. package/dist/index.js +1 -5
  3. package/package.json +21 -11
  4. package/dist/FormActions.d.ts +0 -3
  5. package/dist/FormActions.d.ts.map +0 -1
  6. package/dist/FormActions.js +0 -19
  7. package/dist/FormActions.js.map +0 -1
  8. package/dist/FormField.d.ts +0 -15
  9. package/dist/FormField.d.ts.map +0 -1
  10. package/dist/FormField.js +0 -32
  11. package/dist/FormField.js.map +0 -1
  12. package/dist/FormRenderer.d.ts +0 -3
  13. package/dist/FormRenderer.d.ts.map +0 -1
  14. package/dist/FormRenderer.js +0 -67
  15. package/dist/FormRenderer.js.map +0 -1
  16. package/dist/FormStepProgress.d.ts +0 -3
  17. package/dist/FormStepProgress.d.ts.map +0 -1
  18. package/dist/FormStepProgress.js +0 -6
  19. package/dist/FormStepProgress.js.map +0 -1
  20. package/dist/fields/CheckboxField.d.ts +0 -3
  21. package/dist/fields/CheckboxField.d.ts.map +0 -1
  22. package/dist/fields/CheckboxField.js +0 -9
  23. package/dist/fields/CheckboxField.js.map +0 -1
  24. package/dist/fields/DateField.d.ts +0 -3
  25. package/dist/fields/DateField.d.ts.map +0 -1
  26. package/dist/fields/DateField.js +0 -9
  27. package/dist/fields/DateField.js.map +0 -1
  28. package/dist/fields/FileField.d.ts +0 -3
  29. package/dist/fields/FileField.d.ts.map +0 -1
  30. package/dist/fields/FileField.js +0 -12
  31. package/dist/fields/FileField.js.map +0 -1
  32. package/dist/fields/RadioField.d.ts +0 -3
  33. package/dist/fields/RadioField.d.ts.map +0 -1
  34. package/dist/fields/RadioField.js +0 -13
  35. package/dist/fields/RadioField.js.map +0 -1
  36. package/dist/fields/SelectField.d.ts +0 -3
  37. package/dist/fields/SelectField.d.ts.map +0 -1
  38. package/dist/fields/SelectField.js +0 -10
  39. package/dist/fields/SelectField.js.map +0 -1
  40. package/dist/fields/SwitchField.d.ts +0 -3
  41. package/dist/fields/SwitchField.d.ts.map +0 -1
  42. package/dist/fields/SwitchField.js +0 -9
  43. package/dist/fields/SwitchField.js.map +0 -1
  44. package/dist/fields/TextField.d.ts +0 -3
  45. package/dist/fields/TextField.d.ts.map +0 -1
  46. package/dist/fields/TextField.js +0 -22
  47. package/dist/fields/TextField.js.map +0 -1
  48. package/dist/fields/TextareaField.d.ts +0 -3
  49. package/dist/fields/TextareaField.d.ts.map +0 -1
  50. package/dist/fields/TextareaField.js +0 -9
  51. package/dist/fields/TextareaField.js.map +0 -1
  52. package/dist/hooks/useFormEngine.d.ts +0 -3
  53. package/dist/hooks/useFormEngine.d.ts.map +0 -1
  54. package/dist/hooks/useFormEngine.js +0 -13
  55. package/dist/hooks/useFormEngine.js.map +0 -1
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/types.d.ts +0 -51
  59. package/dist/types.d.ts.map +0 -1
  60. package/dist/types.js +0 -2
  61. package/dist/types.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,6 +1,68 @@
1
- export { FormRenderer } from './FormRenderer';
2
- export { FormActions } from './FormActions';
3
- export { FormStepProgress } from './FormStepProgress';
4
- export { useFormEngine } from './hooks/useFormEngine';
5
- export type { FieldComponentMap, FieldComponentProps, FormRendererProps, FormActionsProps, FormStepProgressProps, } from './types';
6
- //# sourceMappingURL=index.d.ts.map
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _formhaus_core from '@formhaus/core';
3
+ import { FieldType, FormAction, FormDefinition, ValidatorFn, StepValidateFn, FieldOption, FormAnalyticsEvent, FormEngineOptions, FormEngine } from '@formhaus/core';
4
+ import { ComponentType } from 'react';
5
+
6
+ type OptionsProvider = (values: Record<string, unknown>) => FieldOption[] | Promise<FieldOption[]>;
7
+ interface FieldComponentProps {
8
+ field: _formhaus_core.FormField;
9
+ value: unknown;
10
+ error?: string;
11
+ loading?: boolean;
12
+ disabled?: boolean;
13
+ onChange: (value: unknown) => void;
14
+ onBlur: () => void;
15
+ onFocus?: () => void;
16
+ }
17
+ type FieldComponentMap = Partial<Record<FieldType, ComponentType<FieldComponentProps>>>;
18
+ interface FormActionsProps {
19
+ submitAction?: FormAction;
20
+ backAction?: FormAction | false;
21
+ cancelAction?: FormAction;
22
+ isFirstStep: boolean;
23
+ isLastStep: boolean;
24
+ isMultiStep: boolean;
25
+ loading?: boolean;
26
+ values?: Record<string, unknown>;
27
+ primaryLabel?: string;
28
+ showBack?: boolean;
29
+ backLabel?: string;
30
+ onSubmit: () => void;
31
+ onNext: () => void;
32
+ onPrev: () => void;
33
+ onCancel: () => void;
34
+ onPrimary?: () => void;
35
+ }
36
+ interface FormStepProgressProps {
37
+ current: number;
38
+ total: number;
39
+ stepTitle?: string;
40
+ stepDescription?: string;
41
+ }
42
+ interface FormRendererProps {
43
+ definition: FormDefinition;
44
+ initialValues?: Record<string, unknown>;
45
+ onSubmit: (values: Record<string, unknown>) => Promise<void> | void;
46
+ onCancel?: () => void;
47
+ onStepChange?: (stepId: string, direction: 'next' | 'back') => void;
48
+ onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
49
+ validators?: Record<string, ValidatorFn>;
50
+ onStepValidate?: StepValidateFn;
51
+ errors?: Record<string, string>;
52
+ loading?: boolean;
53
+ components?: FieldComponentMap;
54
+ optionsProviders?: Record<string, OptionsProvider>;
55
+ ActionsComponent?: ComponentType<FormActionsProps>;
56
+ ProgressComponent?: ComponentType<FormStepProgressProps>;
57
+ onAnalyticsEvent?: (event: FormAnalyticsEvent) => void;
58
+ }
59
+
60
+ declare function FormRenderer({ definition, initialValues, onSubmit, onCancel, onStepChange, onFieldChange, validators, onStepValidate, errors: externalErrors, loading, components, optionsProviders, ActionsComponent, ProgressComponent, onAnalyticsEvent, }: FormRendererProps): react_jsx_runtime.JSX.Element;
61
+
62
+ declare function FormActions({ submitAction, backAction, cancelAction, isFirstStep, isLastStep, isMultiStep, loading, values, onSubmit, onNext, onPrev, onCancel, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, onPrimary: onPrimaryProp, }: FormActionsProps): react_jsx_runtime.JSX.Element;
63
+
64
+ declare function FormStepProgress({ current, total, stepTitle, stepDescription, }: FormStepProgressProps): react_jsx_runtime.JSX.Element;
65
+
66
+ declare function useFormEngine(definition: FormDefinition, initialValues?: Record<string, unknown>, options?: FormEngineOptions): FormEngine;
67
+
68
+ export { type FieldComponentMap, type FieldComponentProps, FormActions, type FormActionsProps, FormRenderer, type FormRendererProps, FormStepProgress, type FormStepProgressProps, useFormEngine };
package/dist/index.js CHANGED
@@ -1,5 +1 @@
1
- export { FormRenderer } from './FormRenderer';
2
- export { FormActions } from './FormActions';
3
- export { FormStepProgress } from './FormStepProgress';
4
- export { useFormEngine } from './hooks/useFormEngine';
5
- //# sourceMappingURL=index.js.map
1
+ import {useRef,useSyncExternalStore,useEffect,useState}from'react';import {FormEngine,evaluateCondition}from'@formhaus/core';import {jsxs,jsx}from'react/jsx-runtime';function ke(e,r,t){return t?true:!e?.disabled||e.disabled.length===0?false:e.disabled.every(i=>evaluateCondition(i,r))}function A({submitAction:e,backAction:r,cancelAction:t,isFirstStep:i,isLastStep:a,isMultiStep:s,loading:c,values:p={},onSubmit:l,onNext:n,onPrev:d,onCancel:u,primaryLabel:f,showBack:h,backLabel:y,onPrimary:b}){let o=h??(s&&!i&&r!==false),F=y??(typeof r=="object"?r?.label??"Back":"Back"),$=f??(s&&!a?"Continue":e?.label??"Submit"),O=ke(s&&!a?void 0:e,p,c);function E(){b?b():s&&!a?n():l();}return jsxs("div",{className:"fh-form-actions",children:[jsxs("div",{className:"fh-form-actions__secondary",children:[o&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--text",disabled:c,onClick:d,children:F}),t&&jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--text",disabled:c,onClick:u,children:t.label})]}),jsx("button",{type:"button",className:"fh-form-actions__button fh-form-actions__button--primary",disabled:O,"aria-busy":c,onClick:E,children:$})]})}function z({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0;return jsxs("div",{className:"fh-field fh-field--checkbox",children:[jsxs("div",{className:"fh-field__checkbox-wrapper",children:[jsx("input",{id:l,type:"checkbox",className:"fh-field__checkbox",checked:!!r,disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:f=>s(f.target.checked),onBlur:c,onFocus:p}),e.label&&jsx("label",{className:"fh-field__label",htmlFor:l,children:e.label})]}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function J({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0;return jsxs("div",{className:"fh-field",children:[e.label&&jsxs("label",{className:"fh-field__label",htmlFor:l,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}),jsx("input",{id:l,type:"date",className:"fh-field__input fh-field__input--date",value:String(r??""),disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:f=>s(f.target.value),onBlur:c,onFocus:p}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function X({field:e,error:r,loading:t,disabled:i,onChange:a,onBlur:s,onFocus:c}){let p=e.key,l=`${e.key}-helper`,n=`${e.key}-error`,d=r?n:e.helperText?l:void 0;return jsxs("div",{className:"fh-field",children:[e.label&&jsxs("label",{className:"fh-field__label",htmlFor:p,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}),jsx("input",{id:p,type:"file",className:"fh-field__input fh-field__input--file",accept:e.accept,disabled:i||t,"aria-invalid":!!r,"aria-describedby":d,onChange:u=>{let f=u.target.files;a(f&&f.length>0?f[0]:null);},onBlur:s,onFocus:c}),r&&jsx("p",{id:n,className:"fh-field__error",role:"alert",children:r}),!r&&e.helperText&&jsx("p",{id:l,className:"fh-field__helper",children:e.helperText})]})}function Z({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0,f=e.options??[],h=Array.isArray(r)?r:[];function y(b){let o=h.includes(b)?h.filter(F=>F!==b):[...h,b];s(o);}return jsxs("fieldset",{className:"fh-field fh-field--multiselect","aria-invalid":!!t||void 0,"aria-describedby":u,children:[e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),jsx("div",{className:"fh-field__multiselect-group",children:f.map(b=>{let o=`${l}-${b.value}`;return jsxs("div",{className:"fh-field__multiselect-option",children:[jsx("input",{id:o,type:"checkbox",className:"fh-field__checkbox",checked:h.includes(b.value),disabled:a||i,onChange:()=>y(b.value),onBlur:c,onFocus:p}),jsx("label",{className:"fh-field__multiselect-label",htmlFor:o,children:b.label})]},b.value)})}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function ee({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0,f=e.options??[];return jsxs("fieldset",{className:"fh-field fh-field--radio","aria-invalid":!!t||void 0,"aria-describedby":u,children:[e.label&&jsx("legend",{className:"fh-field__label",children:e.label}),jsx("div",{className:"fh-field__radio-group",children:f.map(h=>{let y=`${l}-${h.value}`;return jsxs("div",{className:"fh-field__radio-option",children:[jsx("input",{id:y,type:"radio",className:"fh-field__radio",name:l,value:h.value,checked:String(r)===String(h.value),disabled:a||i,onChange:()=>s(h.value),onBlur:c,onFocus:p}),jsx("label",{className:"fh-field__radio-label",htmlFor:y,children:h.label})]},h.value)})}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function te({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0,f=e.options??[];return jsxs("div",{className:"fh-field",children:[e.label&&jsxs("label",{className:"fh-field__label",htmlFor:l,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}),jsxs("select",{id:l,className:"fh-field__input fh-field__input--select",value:r??"",disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:h=>s(h.target.value),onBlur:c,onFocus:p,children:[e.placeholder&&jsx("option",{value:"",disabled:true,children:e.placeholder}),f.map(h=>jsx("option",{value:h.value,children:h.label},h.value))]}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function re({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0;return jsxs("div",{className:"fh-field fh-field--switch",children:[jsxs("div",{className:"fh-field__switch-wrapper",children:[jsx("input",{id:l,type:"checkbox",role:"switch",className:"fh-field__switch",checked:!!r,disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:f=>s(f.target.checked),onBlur:c,onFocus:p}),e.label&&jsx("label",{className:"fh-field__label",htmlFor:l,children:e.label})]}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function k({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0,f=y=>{let b=y.target.value;s(e.type==="number"?Number(b):b);},h=e.type==="email"?"email":e.type==="phone"?"tel":e.type==="number"?"number":e.type==="password"?"password":"text";return jsxs("div",{className:"fh-field",children:[e.label&&jsxs("label",{className:"fh-field__label",htmlFor:l,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}),jsx("input",{id:l,type:h,className:"fh-field__input",value:r!=null?String(r):"",placeholder:e.placeholder??e.mask,disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:f,onBlur:c,onFocus:p}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}function le({field:e,value:r,error:t,loading:i,disabled:a,onChange:s,onBlur:c,onFocus:p}){let l=e.key,n=`${e.key}-helper`,d=`${e.key}-error`,u=t?d:e.helperText?n:void 0;return jsxs("div",{className:"fh-field",children:[e.label&&jsxs("label",{className:"fh-field__label",htmlFor:l,children:[e.label,e.validation?.required&&jsx("span",{className:"fh-field__required","aria-hidden":"true",children:" *"})]}),jsx("textarea",{id:l,className:"fh-field__input fh-field__input--textarea",value:r??"",placeholder:e.placeholder,rows:e.rows??3,disabled:a||i,"aria-invalid":!!t,"aria-describedby":u,onChange:f=>s(f.target.value),onBlur:c,onFocus:p}),t&&jsx("p",{id:d,className:"fh-field__error",role:"alert",children:t}),!t&&e.helperText&&jsx("p",{id:n,className:"fh-field__helper",children:e.helperText})]})}var Ne={text:k,email:k,phone:k,number:k,password:k,select:te,multiselect:Z,checkbox:z,radio:ee,switch:re,file:X,date:J,textarea:le};function ie({field:e,value:r,error:t,loading:i,disabled:a,components:s,onChange:c,onBlur:p,onFocus:l}){let n=s?.[e.type]??Ne[e.type];return n?jsx(n,{field:e,value:r,error:t,loading:i,disabled:a,onChange:c,onBlur:p,onFocus:l}):jsxs("div",{children:["Unsupported field type: ",e.type]})}function K({current:e,total:r,stepTitle:t,stepDescription:i}){let a=e/r*100;return jsxs("div",{className:"fh-step-progress",children:[jsx("div",{className:"fh-step-progress__bar",children:jsx("div",{className:"fh-step-progress__fill",style:{width:`${a}%`}})}),jsx("div",{className:"fh-step-progress__info",children:jsxs("span",{className:"fh-step-progress__counter",children:["Step ",e," of ",r]})}),t&&jsx("h3",{className:"fh-step-progress__title",children:t}),i&&jsx("p",{className:"fh-step-progress__description",children:i})]})}function pe(e,r,t){let[i,a]=useState({}),s=useRef(new Map);return useEffect(()=>{if(!t)return;let c=false;for(let p of e){if(!p.optionsFrom)continue;let l=t[p.optionsFrom];if(!l)continue;let n=(p.optionsDependsOn??[]).map(u=>r[u]).join("|");if(s.current.get(p.key)===n)continue;s.current.set(p.key,n);let d=l(r);Array.isArray(d)?c||a(u=>({...u,[p.key]:d})):d.then(u=>{c||a(f=>({...f,[p.key]:u}));}).catch(()=>{s.current.delete(p.key);});}return ()=>{c=true;}},[e,r,t]),i}function U(e,r,t){let i=useRef(null),a=useRef(e.id);(i.current===null||a.current!==e.id)&&(i.current=new FormEngine(e,r,t),a.current=e.id);let s=i.current;return useSyncExternalStore(s.subscribe.bind(s),s.getSnapshot.bind(s)),s}function Re({definition:e,initialValues:r,onSubmit:t,onCancel:i,onStepChange:a,onFieldChange:s,validators:c,onStepValidate:p,errors:l,loading:n=false,components:d,optionsProviders:u,ActionsComponent:f,ProgressComponent:h,onAnalyticsEvent:y}){let o=U(e,r,{validators:c,onStepValidate:p}),F=pe(o.visibleFields,o.values,u);useEffect(()=>{l&&o.setErrors(l);},[l,o]);function $(m,_){o.setValue(m,_),s?.(m,_,o.values);}function O(m){y?.({type:"field_focused",fieldKey:m});}function E(m){y?.({type:"field_blurred",fieldKey:m,hasValue:o.values[m]!==void 0&&o.values[m]!==""});}function D(m){m.preventDefault();let _=o.validate();for(let[Fe,ve]of Object.entries(_))y?.({type:"field_error",fieldKey:Fe,error:ve});if(Object.keys(_).length>0)return;let S=o.getSubmitValues();y?.({type:"form_submitted",fieldCount:Object.keys(S).length}),t(S);}async function V(){let m=o.currentStep;await o.nextStepAsync()&&(m&&y?.({type:"step_completed",stepId:m.id}),o.currentStep&&(a?.(o.currentStep.id,"next"),y?.({type:"step_viewed",stepId:o.currentStep.id,stepIndex:o.currentStepIndex})));}function ce(){o.prevStep(),o.currentStep&&a?.(o.currentStep.id,"back");}function me(){i?.();}let ue=h??K,fe=f??A,L=o.isLastStep||!o.isMultiStep,he=o.isMultiStep&&!L?o.currentStep?.next?.label??"Continue":e.submit?.label??"Submit",be=o.isMultiStep&&!o.isFirstStep&&o.currentStep?.back!==false,ye=typeof o.currentStep?.back=="object"?o.currentStep.back.label??"Back":"Back";async function _e(){o.isMultiStep&&!L?await V():D({preventDefault:()=>{}});}return jsxs("form",{className:"fh-form",onSubmit:D,children:[o.isMultiStep&&jsx(ue,{current:o.progress.current,total:o.progress.total,stepTitle:o.currentStep?.title,stepDescription:o.currentStep?.description}),jsx("div",{className:"fh-form__fields",children:o.visibleFields.map(m=>{let _=F[m.key]?{...m,options:F[m.key]}:m;return jsx(ie,{field:_,value:o.values[m.key],error:o.errors[m.key],loading:o.fieldLoading[m.key],disabled:n,components:d,onChange:S=>$(m.key,S),onBlur:()=>E(m.key),onFocus:()=>O(m.key)},m.key)})}),o.topLevelErrors.length>0&&jsx("div",{className:"fh-form__top-errors",children:o.topLevelErrors.map(m=>jsx("p",{className:"fh-form__top-error",children:m},m))}),jsx(fe,{submitAction:e.submit,backAction:o.currentStep?.back,cancelAction:e.cancel,isFirstStep:o.isFirstStep,isLastStep:L,isMultiStep:o.isMultiStep,loading:n||o.stepValidating,values:o.values,onSubmit:()=>D({preventDefault:()=>{}}),onNext:V,onPrev:ce,onCancel:me,primaryLabel:he,showBack:be,backLabel:ye,onPrimary:_e})]})}export{A as FormActions,Re as FormRenderer,K as FormStepProgress,U as useFormEngine};
package/package.json CHANGED
@@ -1,39 +1,49 @@
1
1
  {
2
2
  "name": "@formhaus/react",
3
- "version": "0.2.1",
4
- "description": "React components for formhaus JSON-schema-driven forms",
3
+ "version": "0.3.1",
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
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
6
+ "sideEffects": false,
7
+ "engines": {
8
+ "node": ">=18"
9
+ },
9
10
  "exports": {
10
11
  ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
13
14
  }
14
15
  },
15
16
  "files": [
16
17
  "dist"
17
18
  ],
18
19
  "dependencies": {
19
- "@formhaus/core": "0.1.0"
20
+ "@formhaus/core": "0.3.1"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "react": ">=18.0.0"
23
24
  },
24
25
  "devDependencies": {
26
+ "@testing-library/react": "^16.3.2",
25
27
  "@types/react": "^19.2.14",
28
+ "@types/react-dom": "^19.2.3",
29
+ "jsdom": "^29.0.2",
26
30
  "react": "^19.2.4",
27
- "typescript": "^5.7.3"
31
+ "react-dom": "^19.2.4",
32
+ "tsup": "^8.5.1",
33
+ "typescript": "^5.7.3",
34
+ "vitest": "^4.1.3"
28
35
  },
29
36
  "license": "MIT",
30
37
  "repository": {
31
38
  "type": "git",
32
- "url": "https://github.com/ignsm/formhaus.git",
39
+ "url": "git+https://github.com/ignsm/formhaus.git",
33
40
  "directory": "packages/react"
34
41
  },
35
42
  "scripts": {
36
- "build": "tsc",
43
+ "build": "tsup",
44
+ "test": "vitest run",
45
+ "test:watch": "vitest",
46
+ "test:resolve": "node --input-type=module -e \"import('./dist/index.js').then(m => { if (!m.FormRenderer) process.exit(1); console.log('ESM resolve OK'); })\"",
37
47
  "clean": "rm -rf dist"
38
48
  }
39
49
  }
@@ -1,3 +0,0 @@
1
- import type { FormActionsProps } from './types';
2
- export declare function FormActions({ submitAction, backAction, cancelAction, isFirstStep, isLastStep, isMultiStep, loading, onSubmit, onNext, onPrev, onCancel, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, onPrimary: onPrimaryProp, }: FormActionsProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=FormActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormActions.d.ts","sourceRoot":"","sources":["../src/FormActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,wBAAgB,WAAW,CAAC,EAC1B,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,GACzB,EAAE,gBAAgB,2CAkDlB"}
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function FormActions({ submitAction, backAction, cancelAction, isFirstStep, isLastStep, isMultiStep, loading, onSubmit, onNext, onPrev, onCancel, primaryLabel: primaryLabelProp, showBack: showBackProp, backLabel: backLabelProp, onPrimary: onPrimaryProp, }) {
3
- const showBack = showBackProp ?? (isMultiStep && !isFirstStep && backAction !== false);
4
- const backLabel = backLabelProp ?? (typeof backAction === 'object' ? (backAction?.label ?? 'Back') : 'Back');
5
- const primaryLabel = primaryLabelProp ?? (isMultiStep && !isLastStep ? 'Continue' : (submitAction?.label ?? 'Submit'));
6
- function handlePrimary() {
7
- if (onPrimaryProp) {
8
- onPrimaryProp();
9
- }
10
- else if (isMultiStep && !isLastStep) {
11
- onNext();
12
- }
13
- else {
14
- onSubmit();
15
- }
16
- }
17
- return (_jsxs("div", { className: "fh-form-actions", children: [_jsxs("div", { className: "fh-form-actions__secondary", children: [showBack && (_jsx("button", { type: "button", className: "fh-form-actions__btn fh-form-actions__btn--text", disabled: loading, onClick: onPrev, children: backLabel })), cancelAction && (_jsx("button", { type: "button", className: "fh-form-actions__btn fh-form-actions__btn--text", disabled: loading, onClick: onCancel, children: cancelAction.label }))] }), _jsx("button", { type: "button", className: "fh-form-actions__btn fh-form-actions__btn--primary", disabled: loading, "aria-busy": loading, onClick: handlePrimary, children: primaryLabel })] }));
18
- }
19
- //# sourceMappingURL=FormActions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormActions.js","sourceRoot":"","sources":["../src/FormActions.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,WAAW,CAAC,EAC1B,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,GACP;IACjB,MAAM,QAAQ,GAAG,YAAY,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,IAAI,UAAU,KAAK,KAAK,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,aAAa,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7G,MAAM,YAAY,GAAG,gBAAgB,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC;IAEvH,SAAS,aAAa;QACpB,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,EAAE,CAAC;QAClB,CAAC;aAAM,IAAI,WAAW,IAAI,CAAC,UAAU,EAAE,CAAC;YACtC,MAAM,EAAE,CAAC;QACX,CAAC;aAAM,CAAC;YACN,QAAQ,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAED,OAAO,CACL,eAAK,SAAS,EAAC,iBAAiB,aAC9B,eAAK,SAAS,EAAC,4BAA4B,aACxC,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iDAAiD,EAC3D,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,MAAM,YAEd,SAAS,GACH,CACV,EACA,YAAY,IAAI,CACf,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iDAAiD,EAC3D,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,QAAQ,YAEhB,YAAY,CAAC,KAAK,GACZ,CACV,IACG,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,oDAAoD,EAC9D,QAAQ,EAAE,OAAO,eACN,OAAO,EAClB,OAAO,EAAE,aAAa,YAErB,YAAY,GACN,IACL,CACP,CAAC;AACJ,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { FormField as FormFieldType } from '@formhaus/core';
2
- import type { FieldComponentMap } from './types';
3
- interface FormFieldProps {
4
- field: FormFieldType;
5
- value: unknown;
6
- error?: string;
7
- loading?: boolean;
8
- disabled?: boolean;
9
- components?: FieldComponentMap;
10
- onChange: (value: unknown) => void;
11
- onBlur: () => void;
12
- }
13
- export declare function FormField({ field, value, error, loading, disabled, components, onChange, onBlur, }: FormFieldProps): import("react/jsx-runtime").JSX.Element;
14
- export {};
15
- //# sourceMappingURL=FormField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../src/FormField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,SAAS,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAU5E,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,SAAS,CAAC;AAkBtE,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,GACP,EAAE,cAAc,2CAkBhB"}
package/dist/FormField.js DELETED
@@ -1,32 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { CheckboxField } from './fields/CheckboxField';
3
- import { DateField } from './fields/DateField';
4
- import { FileField } from './fields/FileField';
5
- import { RadioField } from './fields/RadioField';
6
- import { SelectField } from './fields/SelectField';
7
- import { SwitchField } from './fields/SwitchField';
8
- import { TextField } from './fields/TextField';
9
- import { TextareaField } from './fields/TextareaField';
10
- const defaultComponents = {
11
- text: TextField,
12
- email: TextField,
13
- phone: TextField,
14
- number: TextField,
15
- password: TextField,
16
- select: SelectField,
17
- multiselect: SelectField,
18
- checkbox: CheckboxField,
19
- radio: RadioField,
20
- switch: SwitchField,
21
- file: FileField,
22
- date: DateField,
23
- textarea: TextareaField,
24
- };
25
- export function FormField({ field, value, error, loading, disabled, components, onChange, onBlur, }) {
26
- const Component = components?.[field.type] ?? defaultComponents[field.type];
27
- if (!Component) {
28
- return _jsxs("div", { children: ["Unsupported field type: ", field.type] });
29
- }
30
- return (_jsx(Component, { field: field, value: value, error: error, loading: loading, disabled: disabled, onChange: onChange, onBlur: onBlur }));
31
- }
32
- //# sourceMappingURL=FormField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../src/FormField.tsx"],"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AAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FormRendererProps } from './types';
2
- export declare function FormRenderer({ schema, initialValues, onSubmit, onCancel, onStepChange, onFieldChange, validators, errors: externalErrors, loading, components, ActionsComponent, ProgressComponent, }: FormRendererProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=FormRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../src/FormRenderer.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,EAAE,cAAc,EACtB,OAAe,EACf,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,EAAE,iBAAiB,2CA2HnB"}
@@ -1,67 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect } from 'react';
3
- import { FormActions } from './FormActions';
4
- import { FormField } from './FormField';
5
- import { FormStepProgress } from './FormStepProgress';
6
- import { useFormEngine } from './hooks/useFormEngine';
7
- export function FormRenderer({ schema, initialValues, onSubmit, onCancel, onStepChange, onFieldChange, validators, errors: externalErrors, loading = false, components, ActionsComponent, ProgressComponent, }) {
8
- const engineOptions = { validators };
9
- const engine = useFormEngine(schema, initialValues, engineOptions);
10
- // Sync external errors
11
- useEffect(() => {
12
- if (externalErrors) {
13
- engine.setErrors(externalErrors);
14
- }
15
- }, [externalErrors, engine]);
16
- function handleFieldUpdate(key, value) {
17
- engine.setValue(key, value);
18
- onFieldChange?.(key, value, engine.values);
19
- }
20
- function handleFieldBlur(_key) {
21
- // Intentionally no validation on blur.
22
- // Validation runs only on Submit / Continue click.
23
- }
24
- function handleSubmit(e) {
25
- e.preventDefault();
26
- const allErrors = engine.validate();
27
- if (Object.keys(allErrors).length > 0)
28
- return;
29
- const submitValues = engine.getSubmitValues();
30
- onSubmit(submitValues);
31
- }
32
- function handleNext() {
33
- const success = engine.nextStep();
34
- if (success && engine.currentStep) {
35
- onStepChange?.(engine.currentStep.id, 'next');
36
- }
37
- }
38
- function handlePrev() {
39
- engine.prevStep();
40
- if (engine.currentStep) {
41
- onStepChange?.(engine.currentStep.id, 'back');
42
- }
43
- }
44
- function handleCancel() {
45
- onCancel?.();
46
- }
47
- const ProgressComp = ProgressComponent ?? FormStepProgress;
48
- const ActionsComp = ActionsComponent ?? FormActions;
49
- const effectiveIsLastStep = engine.isLastStep || !engine.isMultiStep;
50
- const computedPrimaryLabel = engine.isMultiStep && !effectiveIsLastStep
51
- ? (engine.currentStep?.next?.label ?? 'Continue')
52
- : (schema.submit?.label ?? 'Submit');
53
- const computedShowBack = engine.isMultiStep && !engine.isFirstStep && engine.currentStep?.back !== false;
54
- const computedBackLabel = typeof engine.currentStep?.back === 'object'
55
- ? (engine.currentStep.back.label ?? 'Back')
56
- : 'Back';
57
- function handlePrimary() {
58
- if (engine.isMultiStep && !effectiveIsLastStep) {
59
- handleNext();
60
- }
61
- else {
62
- handleSubmit({ preventDefault: () => { } });
63
- }
64
- }
65
- return (_jsxs("form", { className: "fh-form", onSubmit: handleSubmit, children: [engine.isMultiStep && (_jsx(ProgressComp, { current: engine.progress.current, total: engine.progress.total, stepTitle: engine.currentStep?.title, stepDescription: engine.currentStep?.description })), _jsx("div", { className: "fh-form__fields", children: engine.visibleFields.map((field) => (_jsx(FormField, { field: field, value: engine.values[field.key], error: engine.errors[field.key], loading: engine.fieldLoading[field.key], disabled: loading, components: components, onChange: (v) => handleFieldUpdate(field.key, v), onBlur: () => handleFieldBlur(field.key) }, field.key))) }), engine.topLevelErrors.length > 0 && (_jsx("div", { className: "fh-form__top-errors", children: engine.topLevelErrors.map((error) => (_jsx("p", { className: "fh-form__top-error", children: error }, error))) })), _jsx(ActionsComp, { submitAction: schema.submit, backAction: engine.currentStep?.back, cancelAction: schema.cancel, isFirstStep: engine.isFirstStep, isLastStep: effectiveIsLastStep, isMultiStep: engine.isMultiStep, loading: loading, onSubmit: () => handleSubmit({ preventDefault: () => { } }), onNext: handleNext, onPrev: handlePrev, onCancel: handleCancel, primaryLabel: computedPrimaryLabel, showBack: computedShowBack, backLabel: computedBackLabel, onPrimary: handlePrimary })] }));
66
- }
67
- //# sourceMappingURL=FormRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormRenderer.js","sourceRoot":"","sources":["../src/FormRenderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,MAAM,UAAU,YAAY,CAAC,EAC3B,MAAM,EACN,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,EAAE,cAAc,EACtB,OAAO,GAAG,KAAK,EACf,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GACC;IAClB,MAAM,aAAa,GAAsB,EAAE,UAAU,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAEnE,uBAAuB;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAE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B,EAC1B,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,aAAa,GACxB,IACG,CACR,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FormStepProgressProps } from './types';
2
- export declare function FormStepProgress({ current, total, stepTitle, stepDescription, }: FormStepProgressProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=FormStepProgress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormStepProgress.d.ts","sourceRoot":"","sources":["../src/FormStepProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,KAAK,EACL,SAAS,EACT,eAAe,GAChB,EAAE,qBAAqB,2CAiBvB"}
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function FormStepProgress({ current, total, stepTitle, stepDescription, }) {
3
- const percent = (current / total) * 100;
4
- 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: `${percent}%` } }) }), _jsx("div", { className: "fh-step-progress__info", children: _jsxs("span", { className: "fh-step-progress__counter", children: ["Step ", current, " of ", total] }) }), stepTitle && _jsx("h3", { className: "fh-step-progress__title", children: stepTitle }), stepDescription && _jsx("p", { className: "fh-step-progress__description", children: stepDescription })] }));
5
- }
6
- //# sourceMappingURL=FormStepProgress.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormStepProgress.js","sourceRoot":"","sources":["../src/FormStepProgress.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,KAAK,EACL,SAAS,EACT,eAAe,GACO;IACtB,MAAM,OAAO,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC;IAExC,OAAO,CACL,eAAK,SAAS,EAAC,kBAAkB,aAC/B,cAAK,SAAS,EAAC,uBAAuB,YACpC,cAAK,SAAS,EAAC,wBAAwB,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,GAAG,EAAE,GAAI,GACvE,EACN,cAAK,SAAS,EAAC,wBAAwB,YACrC,gBAAM,SAAS,EAAC,2BAA2B,sBACnC,OAAO,UAAM,KAAK,IACnB,GACH,EACL,SAAS,IAAI,aAAI,SAAS,EAAC,yBAAyB,YAAE,SAAS,GAAM,EACrE,eAAe,IAAI,YAAG,SAAS,EAAC,+BAA+B,YAAE,eAAe,GAAK,IAClF,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function CheckboxField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=CheckboxField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../src/fields/CheckboxField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAkCrB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function CheckboxField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- return (_jsxs("div", { className: "fh-field fh-field--checkbox", children: [_jsxs("label", { className: "fh-field__checkbox-label", htmlFor: inputId, children: [_jsx("input", { id: inputId, type: "checkbox", className: "fh-field__checkbox", checked: !!value, disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => onChange(e.target.checked), onBlur: onBlur }), _jsx("span", { className: "fh-field__checkbox-text", children: field.label })] }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
8
- }
9
- //# sourceMappingURL=CheckboxField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CheckboxField.js","sourceRoot":"","sources":["../../src/fields/CheckboxField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,OAAO,CACL,eAAK,SAAS,EAAC,6BAA6B,aAC1C,iBAAO,SAAS,EAAC,0BAA0B,EAAC,OAAO,EAAE,OAAO,aAC1D,gBACE,EAAE,EAAE,OAAO,EACX,IAAI,EAAC,UAAU,EACf,SAAS,EAAC,oBAAoB,EAC9B,OAAO,EAAE,CAAC,CAAC,KAAK,EAChB,QAAQ,EAAE,QAAQ,IAAI,OAAO,kBACf,CAAC,CAAC,KAAK,sBACH,WAAW,EAC7B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAC3C,MAAM,EAAE,MAAM,GACd,EACF,eAAM,SAAS,EAAC,yBAAyB,YAAE,KAAK,CAAC,KAAK,GAAQ,IACxD,EACP,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function DateField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=DateField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/fields/DateField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAqCrB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function DateField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- return (_jsxs("div", { className: "fh-field", children: [field.label && (_jsxs("label", { className: "fh-field__label", htmlFor: inputId, children: [field.label, field.validation?.required && _jsx("span", { className: "fh-field__required", "aria-hidden": "true", children: " *" })] })), _jsx("input", { id: inputId, type: "date", className: "fh-field__input fh-field__input--date", value: String(value ?? ''), disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => onChange(e.target.value), onBlur: onBlur }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
8
- }
9
- //# sourceMappingURL=DateField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../src/fields/DateField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,aACtB,KAAK,CAAC,KAAK,IAAI,CACd,iBAAO,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,OAAO,aAChD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,UAAU,EAAE,QAAQ,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,mBAAU,IAC1F,CACT,EACD,gBACE,EAAE,EAAE,OAAO,EACX,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,uCAAuC,EACjD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,EAC1B,QAAQ,EAAE,QAAQ,IAAI,OAAO,kBACf,CAAC,CAAC,KAAK,sBACH,WAAW,EAC7B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,MAAM,EAAE,MAAM,GACd,EACD,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function FileField({ field, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=FileField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileField.d.ts","sourceRoot":"","sources":["../../src/fields/FileField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAwCrB"}
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function FileField({ field, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- return (_jsxs("div", { className: "fh-field", children: [field.label && (_jsxs("label", { className: "fh-field__label", htmlFor: inputId, children: [field.label, field.validation?.required && _jsx("span", { className: "fh-field__required", "aria-hidden": "true", children: " *" })] })), _jsx("input", { id: inputId, type: "file", className: "fh-field__input fh-field__input--file", accept: field.accept, disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => {
8
- const files = e.target.files;
9
- onChange(files && files.length > 0 ? files[0] : null);
10
- }, onBlur: onBlur }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
11
- }
12
- //# sourceMappingURL=FileField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileField.js","sourceRoot":"","sources":["../../src/fields/FileField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,aACtB,KAAK,CAAC,KAAK,IAAI,CACd,iBAAO,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,OAAO,aAChD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,UAAU,EAAE,QAAQ,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,mBAAU,IAC1F,CACT,EACD,gBACE,EAAE,EAAE,OAAO,EACX,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,uCAAuC,EACjD,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,QAAQ,IAAI,OAAO,kBACf,CAAC,CAAC,KAAK,sBACH,WAAW,EAC7B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC7B,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACxD,CAAC,EACD,MAAM,EAAE,MAAM,GACd,EACD,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function RadioField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=RadioField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RadioField.d.ts","sourceRoot":"","sources":["../../src/fields/RadioField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAiDrB"}
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function RadioField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const groupId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- const options = field.options ?? [];
8
- return (_jsxs("div", { className: "fh-field fh-field--radio", children: [_jsxs("fieldset", { className: "fh-field__fieldset", "aria-invalid": !!error, "aria-describedby": describedBy, children: [field.label && _jsx("legend", { className: "fh-field__legend", children: field.label }), _jsx("div", { className: "fh-field__radio-group", children: options.map((opt) => {
9
- const optionId = `${groupId}-${opt.value}`;
10
- return (_jsxs("label", { className: "fh-field__radio-label", htmlFor: optionId, children: [_jsx("input", { id: optionId, type: "radio", className: "fh-field__radio", name: groupId, value: opt.value, checked: value === opt.value, disabled: disabled || loading, onChange: () => onChange(opt.value), onBlur: onBlur }), _jsx("span", { className: "fh-field__radio-text", children: opt.label })] }, opt.value));
11
- }) })] }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
12
- }
13
- //# sourceMappingURL=RadioField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RadioField.js","sourceRoot":"","sources":["../../src/fields/RadioField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IAEpC,OAAO,CACL,eAAK,SAAS,EAAC,0BAA0B,aACvC,oBACE,SAAS,EAAC,oBAAoB,kBAChB,CAAC,CAAC,KAAK,sBACH,WAAW,aAE5B,KAAK,CAAC,KAAK,IAAI,iBAAQ,SAAS,EAAC,kBAAkB,YAAE,KAAK,CAAC,KAAK,GAAU,EAC3E,cAAK,SAAS,EAAC,uBAAuB,YACnC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;4BACnB,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;4BAC3C,OAAO,CACL,iBAAuB,SAAS,EAAC,uBAAuB,EAAC,OAAO,EAAE,QAAQ,aACxE,gBACE,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,iBAAiB,EAC3B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,GAAG,CAAC,KAAK,EAChB,OAAO,EAAE,KAAK,KAAK,GAAG,CAAC,KAAK,EAC5B,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAC7B,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EACnC,MAAM,EAAE,MAAM,GACd,EACF,eAAM,SAAS,EAAC,sBAAsB,YAAE,GAAG,CAAC,KAAK,GAAQ,KAZ/C,GAAG,CAAC,KAAK,CAab,CACT,CAAC;wBACJ,CAAC,CAAC,GACE,IACG,EACV,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function SelectField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=SelectField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../src/fields/SelectField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAgDrB"}
@@ -1,10 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function SelectField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- const options = field.options ?? [];
8
- return (_jsxs("div", { className: "fh-field", children: [field.label && (_jsxs("label", { className: "fh-field__label", htmlFor: inputId, children: [field.label, field.validation?.required && _jsx("span", { className: "fh-field__required", "aria-hidden": "true", children: " *" })] })), _jsxs("select", { id: inputId, className: "fh-field__input fh-field__input--select", value: value ?? '', disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => onChange(e.target.value), onBlur: onBlur, children: [field.placeholder && (_jsx("option", { value: "", disabled: true, children: field.placeholder })), options.map((opt) => (_jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
9
- }
10
- //# sourceMappingURL=SelectField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectField.js","sourceRoot":"","sources":["../../src/fields/SelectField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,G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EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function SwitchField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=SwitchField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SwitchField.d.ts","sourceRoot":"","sources":["../../src/fields/SwitchField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAmCrB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function SwitchField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- return (_jsxs("div", { className: "fh-field fh-field--switch", children: [_jsxs("label", { className: "fh-field__switch-label", htmlFor: inputId, children: [_jsx("input", { id: inputId, type: "checkbox", role: "switch", className: "fh-field__switch", checked: !!value, disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => onChange(e.target.checked), onBlur: onBlur }), _jsx("span", { className: "fh-field__switch-text", children: field.label })] }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
8
- }
9
- //# sourceMappingURL=SwitchField.js.map
@@ -1 +0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AE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function TextField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=TextField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../src/fields/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAsDrB"}
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function TextField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- const handleChange = (e) => {
8
- const v = e.target.value;
9
- onChange(field.type === 'number' ? Number(v) : v);
10
- };
11
- const inputType = field.type === 'email'
12
- ? 'email'
13
- : field.type === 'phone'
14
- ? 'tel'
15
- : field.type === 'number'
16
- ? 'number'
17
- : field.type === 'password'
18
- ? 'password'
19
- : 'text';
20
- return (_jsxs("div", { className: "fh-field", children: [field.label && (_jsxs("label", { className: "fh-field__label", htmlFor: inputId, children: [field.label, field.validation?.required && _jsx("span", { className: "fh-field__required", "aria-hidden": "true", children: " *" })] })), _jsx("input", { id: inputId, type: inputType, className: "fh-field__input", value: value != null ? String(value) : '', placeholder: field.placeholder, disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: handleChange, onBlur: onBlur }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
21
- }
22
- //# sourceMappingURL=TextField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/fields/TextField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACzB,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,MAAM,SAAS,GACb,KAAK,CAAC,IAAI,KAAK,OAAO;QACpB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO;YACtB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;gBACvB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;oBACzB,CAAC,CAAC,UAAU;oBACZ,CAAC,CAAC,MAAM,CAAC;IAEnB,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,aACtB,KAAK,CAAC,KAAK,IAAI,CACd,iBAAO,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,OAAO,aAChD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,UAAU,EAAE,QAAQ,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,mBAAU,IAC1F,CACT,EACD,gBACE,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,SAAS,EACf,SAAS,EAAC,iBAAiB,EAC3B,KAAK,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EACzC,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,QAAQ,IAAI,OAAO,kBACf,CAAC,CAAC,KAAK,sBACH,WAAW,EAC7B,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,GACd,EACD,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { FieldComponentProps } from '../types';
2
- export declare function TextareaField({ field, value, error, loading, disabled, onChange, onBlur, }: FieldComponentProps): import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=TextareaField.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextareaField.d.ts","sourceRoot":"","sources":["../../src/fields/TextareaField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,2CAsCrB"}
@@ -1,9 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function TextareaField({ field, value, error, loading, disabled, onChange, onBlur, }) {
3
- const inputId = field.key;
4
- const helperId = `${field.key}-helper`;
5
- const errorId = `${field.key}-error`;
6
- const describedBy = error ? errorId : field.helperText ? helperId : undefined;
7
- return (_jsxs("div", { className: "fh-field", children: [field.label && (_jsxs("label", { className: "fh-field__label", htmlFor: inputId, children: [field.label, field.validation?.required && _jsx("span", { className: "fh-field__required", "aria-hidden": "true", children: " *" })] })), _jsx("textarea", { id: inputId, className: "fh-field__input fh-field__input--textarea", value: value ?? '', placeholder: field.placeholder, rows: field.rows ?? 3, disabled: disabled || loading, "aria-invalid": !!error, "aria-describedby": describedBy, onChange: (e) => onChange(e.target.value), onBlur: onBlur }), error && (_jsx("p", { id: errorId, className: "fh-field__error", role: "alert", children: error })), !error && field.helperText && (_jsx("p", { id: helperId, className: "fh-field__helper", children: field.helperText }))] }));
8
- }
9
- //# sourceMappingURL=TextareaField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextareaField.js","sourceRoot":"","sources":["../../src/fields/TextareaField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,GACc;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,GAAG,QAAQ,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,OAAO,CACL,eAAK,SAAS,EAAC,UAAU,aACtB,KAAK,CAAC,KAAK,IAAI,CACd,iBAAO,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,OAAO,aAChD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,UAAU,EAAE,QAAQ,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,mBAAU,IAC1F,CACT,EACD,mBACE,EAAE,EAAE,OAAO,EACX,SAAS,EAAC,2CAA2C,EACrD,KAAK,EAAG,KAAgB,IAAI,EAAE,EAC9B,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,EACrB,QAAQ,EAAE,QAAQ,IAAI,OAAO,kBACf,CAAC,CAAC,KAAK,sBACH,WAAW,EAC7B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,MAAM,EAAE,MAAM,GACd,EACD,KAAK,IAAI,CACR,YAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,IAAI,EAAC,OAAO,YACrD,KAAK,GACJ,CACL,EACA,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,CAC7B,YAAG,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,kBAAkB,YAC1C,KAAK,CAAC,UAAU,GACf,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FormEngine, type FormEngineOptions, type FormSchema } from '@formhaus/core';
2
- export declare function useFormEngine(schema: FormSchema, initialValues?: Record<string, unknown>, options?: FormEngineOptions): FormEngine;
3
- //# sourceMappingURL=useFormEngine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFormEngine.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGrF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,UAAU,CAWZ"}
@@ -1,13 +0,0 @@
1
- import { FormEngine } from '@formhaus/core';
2
- import { useRef, useSyncExternalStore } from 'react';
3
- export function useFormEngine(schema, initialValues, options) {
4
- const engineRef = useRef(null);
5
- if (engineRef.current === null) {
6
- engineRef.current = new FormEngine(schema, initialValues, options);
7
- }
8
- const engine = engineRef.current;
9
- // Subscribe to engine changes via useSyncExternalStore
10
- useSyncExternalStore(engine.subscribe.bind(engine), engine.getSnapshot.bind(engine));
11
- return engine;
12
- }
13
- //# sourceMappingURL=useFormEngine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFormEngine.js","sourceRoot":"","sources":["../../src/hooks/useFormEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAErD,MAAM,UAAU,aAAa,CAC3B,MAAkB,EAClB,aAAuC,EACvC,OAA2B;IAE3B,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC/B,SAAS,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;IAEjC,uDAAuD;IACvD,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAErF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,51 +0,0 @@
1
- import type { FieldType, FormAction, FormAnalyticsEvent, FormSchema, ValidatorFn } from '@formhaus/core';
2
- import type { ComponentType } from 'react';
3
- export interface FieldComponentProps {
4
- field: import('@formhaus/core').FormField;
5
- value: unknown;
6
- error?: string;
7
- loading?: boolean;
8
- disabled?: boolean;
9
- onChange: (value: unknown) => void;
10
- onBlur: () => void;
11
- }
12
- export type FieldComponentMap = Partial<Record<FieldType, ComponentType<FieldComponentProps>>>;
13
- export interface FormActionsProps {
14
- submitAction?: FormAction;
15
- backAction?: FormAction | false;
16
- cancelAction?: FormAction;
17
- isFirstStep: boolean;
18
- isLastStep: boolean;
19
- isMultiStep: boolean;
20
- loading?: boolean;
21
- primaryLabel?: string;
22
- showBack?: boolean;
23
- backLabel?: string;
24
- onSubmit: () => void;
25
- onNext: () => void;
26
- onPrev: () => void;
27
- onCancel: () => void;
28
- onPrimary?: () => void;
29
- }
30
- export interface FormStepProgressProps {
31
- current: number;
32
- total: number;
33
- stepTitle?: string;
34
- stepDescription?: string;
35
- }
36
- export interface FormRendererProps {
37
- schema: FormSchema;
38
- initialValues?: Record<string, unknown>;
39
- onSubmit: (values: Record<string, unknown>) => Promise<void> | void;
40
- onCancel?: () => void;
41
- onStepChange?: (stepId: string, direction: 'next' | 'back') => void;
42
- onFieldChange?: (key: string, value: unknown, allValues: Record<string, unknown>) => void;
43
- validators?: Record<string, ValidatorFn>;
44
- errors?: Record<string, string>;
45
- loading?: boolean;
46
- components?: FieldComponentMap;
47
- ActionsComponent?: ComponentType<FormActionsProps>;
48
- ProgressComponent?: ComponentType<FormStepProgressProps>;
49
- onAnalyticsEvent?: (event: FormAnalyticsEvent) => void;
50
- }
51
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,gBAAgB,EAAE,SAAS,CAAC;IAC1C,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAA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AC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAC1F,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,gBAAgB,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACnD,iBAAiB,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACzD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACxD"}
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}