@lehnihon/bit-form 2.1.0 → 2.1.2

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 (65) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.cjs.map +1 -1
  3. package/dist/angular/index.d.cts +72 -46
  4. package/dist/angular/index.d.ts +72 -46
  5. package/dist/angular/index.js +1 -1
  6. package/dist/angular/index.js.map +1 -1
  7. package/dist/bus-vCbulIYH.d.cts +141 -0
  8. package/dist/bus-vCbulIYH.d.ts +141 -0
  9. package/dist/chunk-2QNUW6ZN.cjs +133 -0
  10. package/dist/chunk-2QNUW6ZN.cjs.map +1 -0
  11. package/dist/chunk-F6LJWWEW.js +2 -0
  12. package/dist/chunk-F6LJWWEW.js.map +1 -0
  13. package/dist/chunk-LPRLSFPT.cjs +2 -0
  14. package/dist/chunk-LPRLSFPT.cjs.map +1 -0
  15. package/dist/chunk-N6IA7HQL.js +133 -0
  16. package/dist/chunk-N6IA7HQL.js.map +1 -0
  17. package/dist/devtools/bridge.cjs +1 -1
  18. package/dist/devtools/bridge.js +1 -1
  19. package/dist/devtools/index.cjs +1 -1
  20. package/dist/devtools/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +5 -24
  23. package/dist/index.d.ts +5 -24
  24. package/dist/index.js +1 -1
  25. package/dist/public-types-ChP5j3xc.d.ts +69 -0
  26. package/dist/public-types-Nv__uZTR.d.cts +69 -0
  27. package/dist/react/index.cjs +1 -1
  28. package/dist/react/index.cjs.map +1 -1
  29. package/dist/react/index.d.cts +7 -47
  30. package/dist/react/index.d.ts +7 -47
  31. package/dist/react/index.js +1 -1
  32. package/dist/react/index.js.map +1 -1
  33. package/dist/react-native/index.cjs +1 -1
  34. package/dist/react-native/index.cjs.map +1 -1
  35. package/dist/react-native/index.d.cts +16 -5
  36. package/dist/react-native/index.d.ts +16 -5
  37. package/dist/react-native/index.js +1 -1
  38. package/dist/react-native/index.js.map +1 -1
  39. package/dist/resolvers/joi.d.cts +1 -1
  40. package/dist/resolvers/joi.d.ts +1 -1
  41. package/dist/resolvers/yup.d.cts +1 -1
  42. package/dist/resolvers/yup.d.ts +1 -1
  43. package/dist/resolvers/zod.d.cts +1 -1
  44. package/dist/resolvers/zod.d.ts +1 -1
  45. package/dist/{use-bit-watch-iCGj-kYp.d.ts → use-bit-watch-BRekIj2W.d.cts} +92 -28
  46. package/dist/{use-bit-watch-BLCTa7d4.d.cts → use-bit-watch-hA0AqCkC.d.ts} +92 -28
  47. package/dist/vue/index.cjs +1 -1
  48. package/dist/vue/index.cjs.map +1 -1
  49. package/dist/vue/index.d.cts +66 -46
  50. package/dist/vue/index.d.ts +66 -46
  51. package/dist/vue/index.js +1 -1
  52. package/dist/vue/index.js.map +1 -1
  53. package/package.json +7 -2
  54. package/dist/bus-uG4EmM-Z.d.cts +0 -295
  55. package/dist/bus-uG4EmM-Z.d.ts +0 -295
  56. package/dist/chunk-ET36BANJ.js +0 -2
  57. package/dist/chunk-ET36BANJ.js.map +0 -1
  58. package/dist/chunk-NDFMZWBP.js +0 -133
  59. package/dist/chunk-NDFMZWBP.js.map +0 -1
  60. package/dist/chunk-PCVPCFPX.cjs +0 -2
  61. package/dist/chunk-PCVPCFPX.cjs.map +0 -1
  62. package/dist/chunk-VFLQH47Q.cjs +0 -133
  63. package/dist/chunk-VFLQH47Q.cjs.map +0 -1
  64. package/dist/index-1fP1eJH8.d.ts +0 -211
  65. package/dist/index-9vxGUNPP.d.cts +0 -211
@@ -1,10 +1,13 @@
1
- export { B as BitFormProvider, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-BLCTa7d4.cjs';
2
- import { b as BitPath, c as BitPathValue, k as BitFieldDefinition, l as BitFieldOptions } from '../bus-uG4EmM-Z.cjs';
3
- export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-uG4EmM-Z.cjs';
1
+ export { B as BitFormProvider, u as useBitArray, f as useBitForm, g as useBitScope, h as useBitSteps, i as useBitStore, j as useBitWatch } from '../use-bit-watch-BRekIj2W.cjs';
2
+ import { j as BitPath, k as BitPathValue } from '../bus-vCbulIYH.cjs';
3
+ export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-vCbulIYH.cjs';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
- import '../index-9vxGUNPP.cjs';
6
+ import '../public-types-Nv__uZTR.cjs';
7
7
 
8
+ /**
9
+ * Metadata describing the current state of a form field (React Native).
10
+ */
8
11
  interface UseBitFieldNativeMeta {
9
12
  error: string | undefined;
10
13
  touched: boolean;
@@ -15,11 +18,18 @@ interface UseBitFieldNativeMeta {
15
18
  isRequired: boolean;
16
19
  hasError: boolean;
17
20
  }
21
+ /**
22
+ * Props that can be spread onto a React Native input component.
23
+ */
18
24
  interface UseBitFieldNativeBindProps {
19
25
  value: string;
20
26
  onChangeText: (value: string) => void;
21
27
  onBlur: () => void;
22
28
  }
29
+ /**
30
+ * Result from useBitField hook in React Native.
31
+ * Provides field state, value, handlers, and metadata for native mobile development.
32
+ */
23
33
  interface UseBitFieldNativeResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
24
34
  field: {
25
35
  value: BitPathValue<TForm, P>;
@@ -32,6 +42,7 @@ interface UseBitFieldNativeResult<TForm extends object = any, P extends BitPath<
32
42
  meta: UseBitFieldNativeMeta;
33
43
  props: UseBitFieldNativeBindProps;
34
44
  }
35
- declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P, configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions, maybeOptions?: BitFieldOptions): UseBitFieldNativeResult<TForm, P>;
45
+
46
+ declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): UseBitFieldNativeResult<TForm, P>;
36
47
 
37
48
  export { type UseBitFieldNativeBindProps, type UseBitFieldNativeMeta, type UseBitFieldNativeResult, useBitField };
@@ -1,10 +1,13 @@
1
- export { B as BitFormProvider, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-iCGj-kYp.js';
2
- import { b as BitPath, c as BitPathValue, k as BitFieldDefinition, l as BitFieldOptions } from '../bus-uG4EmM-Z.js';
3
- export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-uG4EmM-Z.js';
1
+ export { B as BitFormProvider, u as useBitArray, f as useBitForm, g as useBitScope, h as useBitSteps, i as useBitStore, j as useBitWatch } from '../use-bit-watch-hA0AqCkC.js';
2
+ import { j as BitPath, k as BitPathValue } from '../bus-vCbulIYH.js';
3
+ export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-vCbulIYH.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
6
- import '../index-1fP1eJH8.js';
6
+ import '../public-types-ChP5j3xc.js';
7
7
 
8
+ /**
9
+ * Metadata describing the current state of a form field (React Native).
10
+ */
8
11
  interface UseBitFieldNativeMeta {
9
12
  error: string | undefined;
10
13
  touched: boolean;
@@ -15,11 +18,18 @@ interface UseBitFieldNativeMeta {
15
18
  isRequired: boolean;
16
19
  hasError: boolean;
17
20
  }
21
+ /**
22
+ * Props that can be spread onto a React Native input component.
23
+ */
18
24
  interface UseBitFieldNativeBindProps {
19
25
  value: string;
20
26
  onChangeText: (value: string) => void;
21
27
  onBlur: () => void;
22
28
  }
29
+ /**
30
+ * Result from useBitField hook in React Native.
31
+ * Provides field state, value, handlers, and metadata for native mobile development.
32
+ */
23
33
  interface UseBitFieldNativeResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
24
34
  field: {
25
35
  value: BitPathValue<TForm, P>;
@@ -32,6 +42,7 @@ interface UseBitFieldNativeResult<TForm extends object = any, P extends BitPath<
32
42
  meta: UseBitFieldNativeMeta;
33
43
  props: UseBitFieldNativeBindProps;
34
44
  }
35
- declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P, configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions, maybeOptions?: BitFieldOptions): UseBitFieldNativeResult<TForm, P>;
45
+
46
+ declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): UseBitFieldNativeResult<TForm, P>;
36
47
 
37
48
  export { type UseBitFieldNativeBindProps, type UseBitFieldNativeMeta, type UseBitFieldNativeResult, useBitField };
@@ -1,2 +1,2 @@
1
- import{a as N,b as U,c as D,d as c,e as C,f as M,g as R,h as j}from"../chunk-ET36BANJ.js";import"../chunk-NDFMZWBP.js";import{useMemo as v,useCallback as f}from"react";function x(o){if(!o||typeof o!="object")return!1;let t=Object.keys(o);return t.length===1&&t[0]==="mask"}function E(o,t,s){let P=s!==void 0?t:x(t)?void 0:t,B=s!==void 0?s:x(t)?t:void 0,{fieldState:a,setValue:n,setBlur:d,store:r}=c(o,P),i=v(()=>{let e=B?.mask??r.config.fields?.[o]?.mask;if(e)return typeof e=="string"?r.config.masks[e]:e},[B?.mask,r.config.masks,r.config.fields,o]),m=v(()=>{let e=a.value;return e==null||e===""?"":i?i.format(e):String(e)},[a.value,i]),F=f(e=>{if(!i){n(e);return}n(i.parse(String(e??"")))},[i,n]),g=f(e=>{if(!i){n(e);return}n(i.parse(String(e??"")))},[i,n]),{isHidden:h,isRequired:y,value:T,error:l,touched:u,isDirty:V,isValidating:b}=a,k=!!(u&&l),S=u?l:void 0,p=f(()=>{d()},[d]);return{field:{value:T,displayValue:m,setValue:g,setBlur:d,onChangeText:F,onBlur:p},meta:{error:S,touched:u,invalid:k,isValidating:b,isDirty:V,isHidden:h,isRequired:y,hasError:!!l},props:{value:m,onChangeText:F,onBlur:p}}}export{N as BitFormProvider,C as useBitArray,E as useBitField,D as useBitForm,M as useBitScope,R as useBitSteps,U as useBitStore,j as useBitWatch};
1
+ import{a as S,b as T,c as V,d as B,e as N,f as U,g as M,h as R}from"../chunk-F6LJWWEW.js";import"../chunk-N6IA7HQL.js";import{useMemo as f,useCallback as u}from"react";function k(i){let{fieldState:o,setValue:r,setBlur:s,store:a}=B(i),t=f(()=>a.resolveMask(i),[a.config.masks,a.config.fields,i]),d=f(()=>{let e=o.value;return e==null||e===""?"":t?t.format(e):String(e)},[o.value,t]),m=u(e=>{if(!t){r(e);return}r(t.parse(String(e??"")))},[t,r]),c=u(e=>{if(!t){r(e);return}r(t.parse(String(e??"")))},[t,r]),{isHidden:F,isRequired:v,value:P,error:n,touched:l,isDirty:x,isValidating:y}=o,g=!!(l&&n),h=l?n:void 0,p=u(()=>{s()},[s]);return{field:{value:P,displayValue:d,setValue:c,setBlur:s,onChangeText:m,onBlur:p},meta:{error:h,touched:l,invalid:g,isValidating:y,isDirty:x,isHidden:F,isRequired:v,hasError:!!n},props:{value:d,onChangeText:m,onBlur:p}}}export{S as BitFormProvider,N as useBitArray,k as useBitField,V as useBitForm,U as useBitScope,M as useBitSteps,T as useBitStore,R as useBitWatch};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react-native/use-bit-field.ts"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { useBitFieldBase } from \"../react/use-bit-field-base\";\nimport {\n BitFieldDefinition,\n BitFieldOptions,\n BitPath,\n BitPathValue,\n} from \"../core\";\n\nexport interface UseBitFieldNativeMeta {\n error: string | undefined;\n touched: boolean;\n invalid: boolean;\n isValidating: boolean;\n isDirty: boolean;\n isHidden: boolean;\n isRequired: boolean;\n hasError: boolean;\n}\n\nexport interface UseBitFieldNativeBindProps {\n value: string;\n onChangeText: (value: string) => void;\n onBlur: () => void;\n}\n\nexport interface UseBitFieldNativeResult<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n> {\n field: {\n value: BitPathValue<TForm, P>;\n displayValue: string;\n setValue: (val: any) => void;\n setBlur: () => void;\n onChangeText: (text: string) => void;\n onBlur: () => void;\n };\n meta: UseBitFieldNativeMeta;\n props: UseBitFieldNativeBindProps;\n}\n\nfunction isMaskOnlyOptions(\n value: BitFieldDefinition<any> | BitFieldOptions | undefined,\n): value is BitFieldOptions {\n if (!value || typeof value !== \"object\") return false;\n const keys = Object.keys(value);\n return keys.length === 1 && keys[0] === \"mask\";\n}\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(\n path: P,\n configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions,\n maybeOptions?: BitFieldOptions,\n): UseBitFieldNativeResult<TForm, P> {\n const config =\n maybeOptions !== undefined\n ? (configOrOptions as BitFieldDefinition<TForm> | undefined)\n : isMaskOnlyOptions(configOrOptions)\n ? undefined\n : (configOrOptions as BitFieldDefinition<TForm> | undefined);\n\n const options =\n maybeOptions !== undefined\n ? maybeOptions\n : isMaskOnlyOptions(configOrOptions)\n ? configOrOptions\n : undefined;\n\n const {\n fieldState,\n setValue: rawSetValue,\n setBlur,\n store,\n } = useBitFieldBase<BitPathValue<TForm, P>, TForm, P>(path, config);\n\n const resolvedMask = useMemo(() => {\n const maskOption =\n options?.mask ?? store.config.fields?.[path as string]?.mask;\n if (!maskOption) return undefined;\n return typeof maskOption === \"string\"\n ? store.config.masks![maskOption]\n : maskOption;\n }, [options?.mask, store.config.masks, store.config.fields, path]);\n\n const displayValue = useMemo(() => {\n const val = fieldState.value;\n if (val === undefined || val === null || val === \"\") return \"\";\n\n return resolvedMask ? resolvedMask.format(val) : String(val);\n }, [fieldState.value, resolvedMask]);\n\n const handleChange = useCallback(\n (text: string) => {\n if (!resolvedMask) {\n rawSetValue(text as any);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(text ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const setValue = useCallback(\n (val: any) => {\n if (!resolvedMask) {\n rawSetValue(val);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(val ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const { isHidden, isRequired, value, error, touched, isDirty, isValidating } =\n fieldState;\n const invalid = !!(touched && error);\n const visibleError = touched ? error : undefined;\n\n const onBlur = useCallback(() => {\n setBlur();\n }, [setBlur]);\n\n return {\n field: {\n value: value as BitPathValue<TForm, P>,\n displayValue,\n setValue,\n setBlur,\n onChangeText: handleChange,\n onBlur,\n },\n meta: {\n error: visibleError,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError: !!error,\n },\n props: {\n value: displayValue,\n onChangeText: handleChange,\n onBlur,\n },\n };\n}\n"],"mappings":"uHAAA,OAAS,WAAAA,EAAS,eAAAC,MAAmB,QA0CrC,SAASC,EACPC,EAC0B,CAC1B,GAAI,CAACA,GAAS,OAAOA,GAAU,SAAU,MAAO,GAChD,IAAMC,EAAO,OAAO,KAAKD,CAAK,EAC9B,OAAOC,EAAK,SAAW,GAAKA,EAAK,CAAC,IAAM,MAC1C,CAEO,SAASC,EAIdC,EACAC,EACAC,EACmC,CACnC,IAAMC,EACJD,IAAiB,OACZD,EACDL,EAAkBK,CAAe,EAC/B,OACCA,EAEHG,EACJF,IAAiB,OACbA,EACAN,EAAkBK,CAAe,EAC/BA,EACA,OAEF,CACJ,WAAAI,EACA,SAAUC,EACV,QAAAC,EACA,MAAAC,CACF,EAAIC,EAAkDT,EAAMG,CAAM,EAE5DO,EAAeC,EAAQ,IAAM,CACjC,IAAMC,EACJR,GAAS,MAAQI,EAAM,OAAO,SAASR,CAAc,GAAG,KAC1D,GAAKY,EACL,OAAO,OAAOA,GAAe,SACzBJ,EAAM,OAAO,MAAOI,CAAU,EAC9BA,CACN,EAAG,CAACR,GAAS,KAAMI,EAAM,OAAO,MAAOA,EAAM,OAAO,OAAQR,CAAI,CAAC,EAE3Da,EAAeF,EAAQ,IAAM,CACjC,IAAMG,EAAMT,EAAW,MACvB,OAAyBS,GAAQ,MAAQA,IAAQ,GAAW,GAErDJ,EAAeA,EAAa,OAAOI,CAAG,EAAI,OAAOA,CAAG,CAC7D,EAAG,CAACT,EAAW,MAAOK,CAAY,CAAC,EAE7BK,EAAeC,EAClBC,GAAiB,CAChB,GAAI,CAACP,EAAc,CACjBJ,EAAYW,CAAW,EACvB,MACF,CAEAX,EAAYI,EAAa,MAAM,OAAOO,GAAQ,EAAE,CAAC,CAAQ,CAC3D,EACA,CAACP,EAAcJ,CAAW,CAC5B,EAEMY,EAAWF,EACdF,GAAa,CACZ,GAAI,CAACJ,EAAc,CACjBJ,EAAYQ,CAAG,EACf,MACF,CAEAR,EAAYI,EAAa,MAAM,OAAOI,GAAO,EAAE,CAAC,CAAQ,CAC1D,EACA,CAACJ,EAAcJ,CAAW,CAC5B,EAEM,CAAE,SAAAa,EAAU,WAAAC,EAAY,MAAAvB,EAAO,MAAAwB,EAAO,QAAAC,EAAS,QAAAC,EAAS,aAAAC,CAAa,EACzEnB,EACIoB,EAAU,CAAC,EAAEH,GAAWD,GACxBK,EAAeJ,EAAUD,EAAQ,OAEjCM,EAASX,EAAY,IAAM,CAC/BT,EAAQ,CACV,EAAG,CAACA,CAAO,CAAC,EAEZ,MAAO,CACL,MAAO,CACL,MAAOV,EACP,aAAAgB,EACA,SAAAK,EACA,QAAAX,EACA,aAAcQ,EACd,OAAAY,CACF,EACA,KAAM,CACJ,MAAOD,EACP,QAAAJ,EACA,QAAAG,EACA,aAAAD,EACA,QAAAD,EACA,SAAAJ,EACA,WAAAC,EACA,SAAU,CAAC,CAACC,CACd,EACA,MAAO,CACL,MAAOR,EACP,aAAcE,EACd,OAAAY,CACF,CACF,CACF","names":["useMemo","useCallback","isMaskOnlyOptions","value","keys","useBitField","path","configOrOptions","maybeOptions","config","options","fieldState","rawSetValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","maskOption","displayValue","val","handleChange","useCallback","text","setValue","isHidden","isRequired","error","touched","isDirty","isValidating","invalid","visibleError","onBlur"]}
1
+ {"version":3,"sources":["../../src/react-native/use-bit-field.ts"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { useBitFieldBase } from \"../react/use-bit-field-base\";\nimport { BitPath, BitPathValue } from \"../core\";\nimport type {\n UseBitFieldNativeMeta,\n UseBitFieldNativeBindProps,\n UseBitFieldNativeResult,\n} from \"./types\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): UseBitFieldNativeResult<TForm, P> {\n const {\n fieldState,\n setValue: rawSetValue,\n setBlur,\n store,\n } = useBitFieldBase<BitPathValue<TForm, P>, TForm, P>(path);\n\n const resolvedMask = useMemo(() => {\n return store.resolveMask(path as string);\n }, [store.config.masks, store.config.fields, path]);\n\n const displayValue = useMemo(() => {\n const val = fieldState.value;\n if (val === undefined || val === null || val === \"\") return \"\";\n\n return resolvedMask ? resolvedMask.format(val) : String(val);\n }, [fieldState.value, resolvedMask]);\n\n const handleChange = useCallback(\n (text: string) => {\n if (!resolvedMask) {\n rawSetValue(text as any);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(text ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const setValue = useCallback(\n (val: any) => {\n if (!resolvedMask) {\n rawSetValue(val);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(val ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const { isHidden, isRequired, value, error, touched, isDirty, isValidating } =\n fieldState;\n const invalid = !!(touched && error);\n const visibleError = touched ? error : undefined;\n\n const onBlur = useCallback(() => {\n setBlur();\n }, [setBlur]);\n\n return {\n field: {\n value: value as BitPathValue<TForm, P>,\n displayValue,\n setValue,\n setBlur,\n onChangeText: handleChange,\n onBlur,\n },\n meta: {\n error: visibleError,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n hasError: !!error,\n },\n props: {\n value: displayValue,\n onChangeText: handleChange,\n onBlur,\n },\n };\n}\n"],"mappings":"uHAAA,OAAS,WAAAA,EAAS,eAAAC,MAAmB,QAS9B,SAASC,EAGdC,EAA4C,CAC5C,GAAM,CACJ,WAAAC,EACA,SAAUC,EACV,QAAAC,EACA,MAAAC,CACF,EAAIC,EAAkDL,CAAI,EAEpDM,EAAeC,EAAQ,IACpBH,EAAM,YAAYJ,CAAc,EACtC,CAACI,EAAM,OAAO,MAAOA,EAAM,OAAO,OAAQJ,CAAI,CAAC,EAE5CQ,EAAeD,EAAQ,IAAM,CACjC,IAAME,EAAMR,EAAW,MACvB,OAAyBQ,GAAQ,MAAQA,IAAQ,GAAW,GAErDH,EAAeA,EAAa,OAAOG,CAAG,EAAI,OAAOA,CAAG,CAC7D,EAAG,CAACR,EAAW,MAAOK,CAAY,CAAC,EAE7BI,EAAeC,EAClBC,GAAiB,CAChB,GAAI,CAACN,EAAc,CACjBJ,EAAYU,CAAW,EACvB,MACF,CAEAV,EAAYI,EAAa,MAAM,OAAOM,GAAQ,EAAE,CAAC,CAAQ,CAC3D,EACA,CAACN,EAAcJ,CAAW,CAC5B,EAEMW,EAAWF,EACdF,GAAa,CACZ,GAAI,CAACH,EAAc,CACjBJ,EAAYO,CAAG,EACf,MACF,CAEAP,EAAYI,EAAa,MAAM,OAAOG,GAAO,EAAE,CAAC,CAAQ,CAC1D,EACA,CAACH,EAAcJ,CAAW,CAC5B,EAEM,CAAE,SAAAY,EAAU,WAAAC,EAAY,MAAAC,EAAO,MAAAC,EAAO,QAAAC,EAAS,QAAAC,EAAS,aAAAC,CAAa,EACzEnB,EACIoB,EAAU,CAAC,EAAEH,GAAWD,GACxBK,EAAeJ,EAAUD,EAAQ,OAEjCM,EAASZ,EAAY,IAAM,CAC/BR,EAAQ,CACV,EAAG,CAACA,CAAO,CAAC,EAEZ,MAAO,CACL,MAAO,CACL,MAAOa,EACP,aAAAR,EACA,SAAAK,EACA,QAAAV,EACA,aAAcO,EACd,OAAAa,CACF,EACA,KAAM,CACJ,MAAOD,EACP,QAAAJ,EACA,QAAAG,EACA,aAAAD,EACA,QAAAD,EACA,SAAAL,EACA,WAAAC,EACA,SAAU,CAAC,CAACE,CACd,EACA,MAAO,CACL,MAAOT,EACP,aAAcE,EACd,OAAAa,CACF,CACF,CACF","names":["useMemo","useCallback","useBitField","path","fieldState","rawSetValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","displayValue","val","handleChange","useCallback","text","setValue","isHidden","isRequired","value","error","touched","isDirty","isValidating","invalid","visibleError","onBlur"]}
@@ -1,5 +1,5 @@
1
1
  import { ObjectSchema } from 'joi';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.cjs';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.cjs';
3
3
 
4
4
  declare const joiResolver: <T extends object>(schema: ObjectSchema<T>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,5 +1,5 @@
1
1
  import { ObjectSchema } from 'joi';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.js';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.js';
3
3
 
4
4
  declare const joiResolver: <T extends object>(schema: ObjectSchema<T>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,5 +1,5 @@
1
1
  import { Schema } from 'yup';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.cjs';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.cjs';
3
3
 
4
4
  declare const yupResolver: <T extends object>(schema: Schema<any>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,5 +1,5 @@
1
1
  import { Schema } from 'yup';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.js';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.js';
3
3
 
4
4
  declare const yupResolver: <T extends object>(schema: Schema<any>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,5 +1,5 @@
1
1
  import { ZodSchema } from 'zod';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.cjs';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.cjs';
3
3
 
4
4
  declare const zodResolver: <T extends object>(schema: ZodSchema<T>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,5 +1,5 @@
1
1
  import { ZodSchema } from 'zod';
2
- import { d as BitErrors } from '../bus-uG4EmM-Z.js';
2
+ import { e as BitErrors } from '../bus-vCbulIYH.js';
3
3
 
4
4
  declare const zodResolver: <T extends object>(schema: ZodSchema<T>) => (values: T, options?: {
5
5
  scopeFields?: string[];
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { B as BitStore } from './index-1fP1eJH8.js';
4
- import { d as BitErrors, o as BitTouched, b as BitPath, c as BitPathValue, h as BitArrayPath, g as BitArrayItem, S as ScopeStatus, V as ValidateScopeResult } from './bus-uG4EmM-Z.js';
3
+ import { b as BitFrameworkStore } from './public-types-Nv__uZTR.cjs';
4
+ import { e as BitErrors, m as BitTouched, j as BitPath, k as BitPathValue, S as ScopeStatus, V as ValidateScopeResult, c as BitArrayPath, b as BitArrayItem } from './bus-vCbulIYH.cjs';
5
5
 
6
6
  declare const BitFormProvider: ({ store, children, }: {
7
- store: BitStore<any>;
7
+ store: BitFrameworkStore<any>;
8
8
  children: React.ReactNode;
9
9
  }) => react_jsx_runtime.JSX.Element;
10
- declare const useBitStore: <T extends object>() => BitStore<T>;
10
+ declare const useBitStore: <T extends object>() => BitFrameworkStore<T>;
11
11
 
12
12
  declare function useBitForm<T extends object>(): {
13
13
  meta: {
@@ -30,7 +30,7 @@ declare function useBitForm<T extends object>(): {
30
30
  reset: () => void;
31
31
  setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
32
32
  blurField: <P extends BitPath<T, "">>(path: P) => void;
33
- setValues: (newValues: T) => void;
33
+ setValues: (values: T) => void;
34
34
  setError: (path: string, message: string | undefined) => void;
35
35
  setErrors: (errors: BitErrors<T>) => void;
36
36
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -39,15 +39,95 @@ declare function useBitForm<T extends object>(): {
39
39
  scopeFields?: string[];
40
40
  }) => Promise<boolean>;
41
41
  mutations: {
42
- pushItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
43
- removeItem: <P extends BitArrayPath<T>>(path: P, index: number) => void;
44
- prependItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
45
- insertItem: <P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>) => void;
46
- moveItem: <P extends BitArrayPath<T>>(path: P, from: number, to: number) => void;
47
- swapItems: <P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number) => void;
42
+ pushItem: (path: any, value: any) => void;
43
+ removeItem: (path: any, index: number) => void;
44
+ prependItem: (path: any, value: any) => void;
45
+ insertItem: (path: any, index: number, value: any) => void;
46
+ moveItem: (path: any, from: number, to: number) => void;
47
+ swapItems: (path: any, indexA: number, indexB: number) => void;
48
48
  };
49
49
  };
50
50
 
51
+ /**
52
+ * Metadata describing the current state of a form field.
53
+ */
54
+ interface UseBitFieldMeta {
55
+ error: string | undefined;
56
+ touched: boolean;
57
+ invalid: boolean;
58
+ isValidating: boolean;
59
+ isDirty: boolean;
60
+ isHidden: boolean;
61
+ isRequired: boolean;
62
+ hasError: boolean;
63
+ }
64
+ /**
65
+ * Props that can be spread onto a native HTML input element.
66
+ */
67
+ interface UseBitFieldBindProps {
68
+ value: string;
69
+ onChange: (e: any) => void;
70
+ onBlur: () => void;
71
+ }
72
+ /**
73
+ * Result from useBitField hook.
74
+ * Provides field state, value, handlers, and metadata.
75
+ */
76
+ interface UseBitFieldResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
77
+ value: BitPathValue<TForm, P>;
78
+ displayValue: string;
79
+ setValue: (val: any) => void;
80
+ setBlur: () => void;
81
+ onChange: (e: any) => void;
82
+ onBlur: () => void;
83
+ props: UseBitFieldBindProps;
84
+ meta: UseBitFieldMeta;
85
+ }
86
+ /**
87
+ * Result from useBitSteps hook.
88
+ * Provides multi-step form navigation and validation.
89
+ */
90
+ interface UseBitStepsResult {
91
+ step: number;
92
+ stepIndex: number;
93
+ scope: string;
94
+ next: () => Promise<boolean>;
95
+ prev: () => void;
96
+ goTo: (step: number) => void;
97
+ isFirst: boolean;
98
+ isLast: boolean;
99
+ status: ScopeStatus;
100
+ errors: Record<string, string>;
101
+ isValid: boolean;
102
+ isDirty: boolean;
103
+ validate: () => Promise<ValidateScopeResult>;
104
+ getErrors: () => Record<string, string>;
105
+ }
106
+ /**
107
+ * Result from useBitUpload hook.
108
+ * Provides file upload functionality with integrated validation.
109
+ */
110
+ interface UseBitUploadResult {
111
+ value: string | File | null;
112
+ setValue: (value: string | File | null) => void;
113
+ error?: string;
114
+ isValidating: boolean;
115
+ upload: (file: File | null | undefined) => Promise<void>;
116
+ remove: () => Promise<void>;
117
+ }
118
+ /**
119
+ * Result from useBitHistory hook.
120
+ * Provides form history undo/redo capabilities.
121
+ */
122
+ interface UseBitHistoryResult {
123
+ canUndo: boolean;
124
+ canRedo: boolean;
125
+ historyIndex: number;
126
+ historySize: number;
127
+ undo: () => void;
128
+ redo: () => void;
129
+ }
130
+
51
131
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
52
132
  append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
53
133
  prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
@@ -75,24 +155,8 @@ declare function useBitScope(scopeName: string): {
75
155
  isDirty: boolean;
76
156
  };
77
157
 
78
- interface UseBitStepsResult {
79
- step: number;
80
- stepIndex: number;
81
- scope: string;
82
- next: () => Promise<boolean>;
83
- prev: () => void;
84
- goTo: (step: number) => void;
85
- isFirst: boolean;
86
- isLast: boolean;
87
- status: ScopeStatus;
88
- errors: Record<string, string>;
89
- isValid: boolean;
90
- isDirty: boolean;
91
- validate: () => Promise<ValidateScopeResult>;
92
- getErrors: () => Record<string, string>;
93
- }
94
158
  declare function useBitSteps(scopeNames: string[]): UseBitStepsResult;
95
159
 
96
160
  declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): BitPathValue<TForm, P>;
97
161
 
98
- export { BitFormProvider as B, type UseBitStepsResult as U, useBitForm as a, useBitScope as b, useBitSteps as c, useBitStore as d, useBitWatch as e, useBitArray as u };
162
+ export { BitFormProvider as B, type UseBitFieldResult as U, type UseBitHistoryResult as a, type UseBitUploadResult as b, type UseBitFieldBindProps as c, type UseBitFieldMeta as d, type UseBitStepsResult as e, useBitForm as f, useBitScope as g, useBitSteps as h, useBitStore as i, useBitWatch as j, useBitArray as u };
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { B as BitStore } from './index-9vxGUNPP.cjs';
4
- import { d as BitErrors, o as BitTouched, b as BitPath, c as BitPathValue, h as BitArrayPath, g as BitArrayItem, S as ScopeStatus, V as ValidateScopeResult } from './bus-uG4EmM-Z.cjs';
3
+ import { b as BitFrameworkStore } from './public-types-ChP5j3xc.js';
4
+ import { e as BitErrors, m as BitTouched, j as BitPath, k as BitPathValue, S as ScopeStatus, V as ValidateScopeResult, c as BitArrayPath, b as BitArrayItem } from './bus-vCbulIYH.js';
5
5
 
6
6
  declare const BitFormProvider: ({ store, children, }: {
7
- store: BitStore<any>;
7
+ store: BitFrameworkStore<any>;
8
8
  children: React.ReactNode;
9
9
  }) => react_jsx_runtime.JSX.Element;
10
- declare const useBitStore: <T extends object>() => BitStore<T>;
10
+ declare const useBitStore: <T extends object>() => BitFrameworkStore<T>;
11
11
 
12
12
  declare function useBitForm<T extends object>(): {
13
13
  meta: {
@@ -30,7 +30,7 @@ declare function useBitForm<T extends object>(): {
30
30
  reset: () => void;
31
31
  setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
32
32
  blurField: <P extends BitPath<T, "">>(path: P) => void;
33
- setValues: (newValues: T) => void;
33
+ setValues: (values: T) => void;
34
34
  setError: (path: string, message: string | undefined) => void;
35
35
  setErrors: (errors: BitErrors<T>) => void;
36
36
  setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
@@ -39,15 +39,95 @@ declare function useBitForm<T extends object>(): {
39
39
  scopeFields?: string[];
40
40
  }) => Promise<boolean>;
41
41
  mutations: {
42
- pushItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
43
- removeItem: <P extends BitArrayPath<T>>(path: P, index: number) => void;
44
- prependItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
45
- insertItem: <P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>) => void;
46
- moveItem: <P extends BitArrayPath<T>>(path: P, from: number, to: number) => void;
47
- swapItems: <P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number) => void;
42
+ pushItem: (path: any, value: any) => void;
43
+ removeItem: (path: any, index: number) => void;
44
+ prependItem: (path: any, value: any) => void;
45
+ insertItem: (path: any, index: number, value: any) => void;
46
+ moveItem: (path: any, from: number, to: number) => void;
47
+ swapItems: (path: any, indexA: number, indexB: number) => void;
48
48
  };
49
49
  };
50
50
 
51
+ /**
52
+ * Metadata describing the current state of a form field.
53
+ */
54
+ interface UseBitFieldMeta {
55
+ error: string | undefined;
56
+ touched: boolean;
57
+ invalid: boolean;
58
+ isValidating: boolean;
59
+ isDirty: boolean;
60
+ isHidden: boolean;
61
+ isRequired: boolean;
62
+ hasError: boolean;
63
+ }
64
+ /**
65
+ * Props that can be spread onto a native HTML input element.
66
+ */
67
+ interface UseBitFieldBindProps {
68
+ value: string;
69
+ onChange: (e: any) => void;
70
+ onBlur: () => void;
71
+ }
72
+ /**
73
+ * Result from useBitField hook.
74
+ * Provides field state, value, handlers, and metadata.
75
+ */
76
+ interface UseBitFieldResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
77
+ value: BitPathValue<TForm, P>;
78
+ displayValue: string;
79
+ setValue: (val: any) => void;
80
+ setBlur: () => void;
81
+ onChange: (e: any) => void;
82
+ onBlur: () => void;
83
+ props: UseBitFieldBindProps;
84
+ meta: UseBitFieldMeta;
85
+ }
86
+ /**
87
+ * Result from useBitSteps hook.
88
+ * Provides multi-step form navigation and validation.
89
+ */
90
+ interface UseBitStepsResult {
91
+ step: number;
92
+ stepIndex: number;
93
+ scope: string;
94
+ next: () => Promise<boolean>;
95
+ prev: () => void;
96
+ goTo: (step: number) => void;
97
+ isFirst: boolean;
98
+ isLast: boolean;
99
+ status: ScopeStatus;
100
+ errors: Record<string, string>;
101
+ isValid: boolean;
102
+ isDirty: boolean;
103
+ validate: () => Promise<ValidateScopeResult>;
104
+ getErrors: () => Record<string, string>;
105
+ }
106
+ /**
107
+ * Result from useBitUpload hook.
108
+ * Provides file upload functionality with integrated validation.
109
+ */
110
+ interface UseBitUploadResult {
111
+ value: string | File | null;
112
+ setValue: (value: string | File | null) => void;
113
+ error?: string;
114
+ isValidating: boolean;
115
+ upload: (file: File | null | undefined) => Promise<void>;
116
+ remove: () => Promise<void>;
117
+ }
118
+ /**
119
+ * Result from useBitHistory hook.
120
+ * Provides form history undo/redo capabilities.
121
+ */
122
+ interface UseBitHistoryResult {
123
+ canUndo: boolean;
124
+ canRedo: boolean;
125
+ historyIndex: number;
126
+ historySize: number;
127
+ undo: () => void;
128
+ redo: () => void;
129
+ }
130
+
51
131
  declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
52
132
  append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
53
133
  prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
@@ -75,24 +155,8 @@ declare function useBitScope(scopeName: string): {
75
155
  isDirty: boolean;
76
156
  };
77
157
 
78
- interface UseBitStepsResult {
79
- step: number;
80
- stepIndex: number;
81
- scope: string;
82
- next: () => Promise<boolean>;
83
- prev: () => void;
84
- goTo: (step: number) => void;
85
- isFirst: boolean;
86
- isLast: boolean;
87
- status: ScopeStatus;
88
- errors: Record<string, string>;
89
- isValid: boolean;
90
- isDirty: boolean;
91
- validate: () => Promise<ValidateScopeResult>;
92
- getErrors: () => Record<string, string>;
93
- }
94
158
  declare function useBitSteps(scopeNames: string[]): UseBitStepsResult;
95
159
 
96
160
  declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): BitPathValue<TForm, P>;
97
161
 
98
- export { BitFormProvider as B, type UseBitStepsResult as U, useBitForm as a, useBitScope as b, useBitSteps as c, useBitStore as d, useBitWatch as e, useBitArray as u };
162
+ export { BitFormProvider as B, type UseBitFieldResult as U, type UseBitHistoryResult as a, type UseBitUploadResult as b, type UseBitFieldBindProps as c, type UseBitFieldMeta as d, type UseBitStepsResult as e, useBitForm as f, useBitScope as g, useBitSteps as h, useBitStore as i, useBitWatch as j, useBitArray as u };
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkVFLQH47Qcjs = require('../chunk-VFLQH47Q.cjs');var _vue = require('vue');var j=Symbol("BIT_STORE");function _(e){_vue.provide.call(void 0, j,e)}function c(){let e=_vue.inject.call(void 0, j);if(!e)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return e}function Y(){let e=c(),t=_vue.shallowRef.call(void 0, e.getState()),s=_vue.ref.call(void 0, null),o=_vue.ref.call(void 0, null),n=e.subscribe(()=>{t.value={...e.getState()}});_vue.onUnmounted.call(void 0, n);let i=()=>t.value.values,u=()=>t.value.errors,y=()=>t.value.touched,m=()=>e.getDirtyValues(),r=_vue.computed.call(void 0, ()=>t.value.isValid),a=_vue.computed.call(void 0, ()=>t.value.isSubmitting),d=_vue.computed.call(void 0, ()=>t.value.isDirty);return{meta:{isValid:r,isDirty:d,isSubmitting:a,submitError:s,lastResponse:o},getValues:i,getErrors:u,getTouched:y,getDirtyValues:m,submit:S=>b=>(_optionalChain([b, 'optionalAccess', _2 => _2.preventDefault, 'optionalCall', _3 => _3()]),e.submit(S)),onSubmit:S=>b=>(_optionalChain([b, 'optionalAccess', _4 => _4.preventDefault, 'optionalCall', _5 => _5()]),s.value=null,e.submit(async(E,p)=>{try{let l=await S(E,p);o.value=l,s.value=null}catch(l){_chunkVFLQH47Qcjs.h.call(void 0, l)?e.setServerErrors(_chunkVFLQH47Qcjs.i.call(void 0, l)):s.value=l instanceof Error?l:new Error(String(l))}})),reset:()=>{e.reset(),s.value=null,o.value=null},setValues:e.setValues.bind(e),setError:e.setError.bind(e),setErrors:e.setErrors.bind(e),setServerErrors:e.setServerErrors.bind(e),setField:e.setField.bind(e),blurField:e.blurField.bind(e),validate:e.validate.bind(e),mutations:{pushItem:e.pushItem.bind(e),prependItem:e.prependItem.bind(e),removeItem:e.removeItem.bind(e),insertItem:e.insertItem.bind(e),moveItem:e.moveItem.bind(e),swapItems:e.swapItems.bind(e)}}}function P(e,t,s){let o=c();t&&o.registerField(e,t);let n=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _6 => _6.mask]), () => (_optionalChain([o, 'access', _7 => _7.config, 'access', _8 => _8.fields, 'optionalAccess', _9 => _9[e], 'optionalAccess', _10 => _10.mask]))),i=n?typeof n=="string"?_optionalChain([o, 'access', _11 => _11.config, 'access', _12 => _12.masks, 'optionalAccess', _13 => _13[n]]):n:void 0,u=_vue.shallowRef.call(void 0, o.getState()),y=o.subscribe(()=>{u.value=o.getState()});_vue.onUnmounted.call(void 0, ()=>{y(),o.unregisterField&&o.unregisterField(e)});let m=_vue.computed.call(void 0, ()=>_chunkVFLQH47Qcjs.e.call(void 0, u.value.values,e)),r=_vue.computed.call(void 0, ()=>{let v=m.value;return v==null||v===""?"":i?i.format(v):String(v)}),a=_vue.computed.call(void 0, {get:()=>r.value,set:v=>{if(!i){o.setField(e,v);return}o.setField(e,i.parse(String(_nullishCoalesce(v, () => ("")))))}}),d=_vue.computed.call(void 0, ()=>u.value.errors[e]),g=_vue.computed.call(void 0, ()=>u.value.touched[e]?u.value.errors[e]:void 0),h=_vue.computed.call(void 0, ()=>!!u.value.touched[e]),x=_vue.computed.call(void 0, ()=>!!(h.value&&g.value)),S=_vue.computed.call(void 0, ()=>(u.value,o.isFieldValidating(e))),b=_vue.computed.call(void 0, ()=>(u.value,o.isFieldDirty(e))),E=_vue.computed.call(void 0, ()=>(u.value,o.isHidden(e))),p=_vue.computed.call(void 0, ()=>(u.value,o.isRequired(e))),l=_vue.computed.call(void 0, ()=>!!d.value),B=v=>{a.value=v},I=()=>o.blurField(e);return{value:m,displayValue:r,modelValue:a,setValue:B,setBlur:I,onInput:v=>{B(v)},onBlur:()=>{I()},meta:{error:g,touched:h,invalid:x,isValidating:S,isDirty:b,isHidden:E,isRequired:p,hasError:l}}}var R=()=>Math.random().toString(36).substring(2,9);function X(e){let t=c(),s=()=>{let r=_chunkVFLQH47Qcjs.e.call(void 0, t.getState().values,e);return Array.isArray(r)?r:[]},o=s(),n=_vue.ref.call(void 0, o),i=_vue.ref.call(void 0, o.map(R)),u=t.subscribe(()=>{let r=s();if(n.value=[...r],r.length!==i.value.length){let a=[...i.value];if(r.length>a.length){let d=r.length-a.length,g=Array.from({length:d},R);i.value=[...a,...g]}else i.value=a.slice(0,r.length)}});_vue.onUnmounted.call(void 0, ()=>{u(),t.unregisterPrefix&&t.unregisterPrefix(`${e}.`)});let y=_vue.computed.call(void 0, ()=>n.value.map((r,a)=>({key:i.value[a]||`temp-${a}`,value:r,index:a}))),m=_vue.computed.call(void 0, ()=>n.value.length);return{fields:y,length:m,append:r=>{i.value.push(R()),t.pushItem(e,r)},prepend:r=>{i.value.unshift(R()),t.prependItem(e,r)},insert:(r,a)=>{i.value.splice(r,0,R()),t.insertItem(e,r,a)},remove:r=>{i.value.splice(r,1),t.removeItem(e,r)},move:(r,a)=>{let d=[...i.value],[g]=d.splice(r,1);d.splice(a,0,g),i.value=d,t.moveItem(e,r,a)},swap:(r,a)=>{let d=[...i.value];[d[r],d[a]]=[d[a],d[r]],i.value=d,t.swapItems(e,r,a)},replace:r=>{i.value=r.map(R),t.setField(e,r)},clear:()=>{i.value=[],t.setField(e,[])}}}function ee(){let e=c(),t=_vue.shallowRef.call(void 0, e.getHistoryMetadata()),s=e.subscribe(()=>{t.value=e.getHistoryMetadata()});_vue.onUnmounted.call(void 0, s);let o=()=>e.undo(),n=()=>e.redo();return{canUndo:_vue.computed.call(void 0, ()=>t.value.canUndo),canRedo:_vue.computed.call(void 0, ()=>t.value.canRedo),historyIndex:_vue.computed.call(void 0, ()=>t.value.historyIndex),historySize:_vue.computed.call(void 0, ()=>t.value.historySize),undo:o,redo:n}}function se(e,t){let s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(n=>e[n]===t[n])}function ne(e){let t=c(),s=_vue.ref.call(void 0, t.getStepStatus(e)),o;_vue.onMounted.call(void 0, ()=>{o=t.subscribe(()=>{let r=t.getStepStatus(e);(r.hasErrors!==s.value.hasErrors||r.isDirty!==s.value.isDirty||!se(r.errors,s.value.errors))&&(s.value=r)})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([o, 'optionalCall', _14 => _14()])});let n=async()=>{let r=await t.validate({scope:e}),a=t.getStepErrors(e);return{valid:r,errors:a}},i=()=>t.getStepErrors(e),u=_vue.computed.call(void 0, ()=>!s.value.hasErrors),y=_vue.computed.call(void 0, ()=>s.value.isDirty),m=_vue.computed.call(void 0, ()=>s.value.errors);return{scopeName:e,status:s,errors:m,validate:n,getErrors:i,isValid:u,isDirty:y}}function le(e,t){let s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(n=>e[n]===t[n])}function de(e){let t=c(),s=_vue.ref.call(void 0, 0),o=_vue.computed.call(void 0, ()=>_nullishCoalesce(e[s.value], () => (""))),n=_vue.ref.call(void 0, t.getStepStatus(o.value)),i;_vue.watch.call(void 0, o,p=>{n.value=t.getStepStatus(p)});let u=()=>{let p=o.value,l=t.getStepStatus(p);(l.hasErrors!==n.value.hasErrors||l.isDirty!==n.value.isDirty||!le(l.errors,n.value.errors))&&(n.value=l)};_vue.onMounted.call(void 0, ()=>{i=t.subscribe(u)}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([i, 'optionalCall', _15 => _15()])});let y=async()=>{let p=o.value,l=await t.validate({scope:p}),B=t.getStepErrors(p);return{valid:l,errors:B}},m=()=>t.getStepErrors(o.value),r=async()=>{let p=o.value,l=_optionalChain([t, 'access', _16 => _16.getConfig, 'call', _17 => _17(), 'access', _18 => _18.scopes, 'optionalAccess', _19 => _19[p]]);if(t.hasValidationsInProgress(l))return!1;let B=await t.validate({scope:p});if(B)s.value=Math.min(s.value+1,e.length-1);else{let I=t.getStepErrors(p),U=Object.keys(I);U.length>0&&t.markFieldsTouched(U)}return B},a=()=>{s.value=Math.max(s.value-1,0)},d=p=>{s.value=Math.max(0,Math.min(p-1,e.length-1))},g=_vue.computed.call(void 0, ()=>s.value+1),h=_vue.computed.call(void 0, ()=>s.value===0),x=_vue.computed.call(void 0, ()=>s.value>=e.length-1),S=_vue.computed.call(void 0, ()=>!n.value.hasErrors),b=_vue.computed.call(void 0, ()=>n.value.isDirty),E=_vue.computed.call(void 0, ()=>n.value.errors);return{step:g,stepIndex:s,scope:o,next:r,prev:a,goTo:d,isFirst:h,isLast:x,status:n,errors:E,isValid:S,isDirty:b,validate:y,getErrors:m}}function ve(e){let t=c(),s=_chunkVFLQH47Qcjs.e.call(void 0, t.getState().values,e),o=_vue.ref.call(void 0, s),n=t.watch(e,i=>{_chunkVFLQH47Qcjs.d.call(void 0, o.value,i)||(o.value=i)});return _vue.onUnmounted.call(void 0, n),_vue.readonly.call(void 0, o)}function fe(e,t,s){let o=c(),n=P(e),i=null,u=async m=>{if(m){o.beginFieldValidation(e),await o.clearFieldAsyncError(e);try{let r=await t(m);n.setValue(r.url),i=r.key,await o.clearFieldAsyncError(e)}catch(r){let a=r instanceof Error?r.message:"Upload failed";await o.setFieldAsyncError(e,a)}finally{o.endFieldValidation(e)}}},y=async()=>{if(i&&s)try{await s(i)}catch(m){let r=m instanceof Error?m.message:"Delete failed";await o.setFieldAsyncError(e,r);return}n.setValue(null),i=null,await o.clearFieldAsyncError(e)};return{value:n.value,setValue:n.setValue,error:_vue.computed.call(void 0, ()=>n.meta.error.value),isValidating:_vue.computed.call(void 0, ()=>n.meta.isValidating.value||!1),upload:u,remove:y}}exports.provideBitStore = _; exports.useBitArray = X; exports.useBitField = P; exports.useBitForm = Y; exports.useBitHistory = ee; exports.useBitScope = ne; exports.useBitSteps = de; exports.useBitStore = c; exports.useBitUpload = fe; exports.useBitWatch = ve;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk2QNUW6ZNcjs = require('../chunk-2QNUW6ZN.cjs');var _vue = require('vue');var j=Symbol("BIT_STORE");function z(e){_vue.provide.call(void 0, j,e)}function m(){let e=_vue.inject.call(void 0, j);if(!e)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return e}function L(){let e=m(),t=_vue.shallowRef.call(void 0, e.getState()),s=_vue.ref.call(void 0, null),o=_vue.ref.call(void 0, null),n=e.subscribe(()=>{t.value={...e.getState()}});_vue.onUnmounted.call(void 0, n);let i=()=>t.value.values,v=()=>t.value.errors,y=()=>t.value.touched,d=()=>e.getDirtyValues(),r=_vue.computed.call(void 0, ()=>t.value.isValid),a=_vue.computed.call(void 0, ()=>t.value.isSubmitting),u=_vue.computed.call(void 0, ()=>t.value.isDirty);return{meta:{isValid:r,isDirty:u,isSubmitting:a,submitError:s,lastResponse:o},getValues:i,getErrors:v,getTouched:y,getDirtyValues:d,submit:S=>B=>(_optionalChain([B, 'optionalAccess', _2 => _2.preventDefault, 'optionalCall', _3 => _3()]),e.submit(S)),onSubmit:S=>B=>(_optionalChain([B, 'optionalAccess', _4 => _4.preventDefault, 'optionalCall', _5 => _5()]),s.value=null,e.submit(async(F,l)=>{try{let c=await S(F,l);o.value=c,s.value=null}catch(c){_chunk2QNUW6ZNcjs.h.call(void 0, c)?e.setServerErrors(_chunk2QNUW6ZNcjs.i.call(void 0, c)):s.value=c instanceof Error?c:new Error(String(c))}})),reset:()=>{e.reset(),s.value=null,o.value=null},setValues:e.setValues.bind(e),setError:e.setError.bind(e),setErrors:e.setErrors.bind(e),setServerErrors:e.setServerErrors.bind(e),setField:e.setField.bind(e),blurField:e.blurField.bind(e),validate:e.validate.bind(e),mutations:{pushItem:e.pushItem.bind(e),prependItem:e.prependItem.bind(e),removeItem:e.removeItem.bind(e),insertItem:e.insertItem.bind(e),moveItem:e.moveItem.bind(e),swapItems:e.swapItems.bind(e)}}}function R(e){let t=m(),s=t.resolveMask(e),o=_vue.shallowRef.call(void 0, t.getState()),n=t.subscribe(()=>{o.value=t.getState()});_vue.onUnmounted.call(void 0, ()=>{n(),t.unregisterField&&t.unregisterField(e)});let i=_vue.computed.call(void 0, ()=>_chunk2QNUW6ZNcjs.e.call(void 0, o.value.values,e)),v=_vue.computed.call(void 0, ()=>{let p=i.value;return p==null||p===""?"":s?s.format(p):String(p)}),y=_vue.computed.call(void 0, {get:()=>v.value,set:p=>{if(!s){t.setField(e,p);return}t.setField(e,s.parse(String(_nullishCoalesce(p, () => ("")))))}}),d=_vue.computed.call(void 0, ()=>o.value.errors[e]),r=_vue.computed.call(void 0, ()=>o.value.touched[e]?o.value.errors[e]:void 0),a=_vue.computed.call(void 0, ()=>!!o.value.touched[e]),u=_vue.computed.call(void 0, ()=>!!(a.value&&r.value)),g=_vue.computed.call(void 0, ()=>(o.value,t.isFieldValidating(e))),I=_vue.computed.call(void 0, ()=>(o.value,t.isFieldDirty(e))),x=_vue.computed.call(void 0, ()=>(o.value,t.isHidden(e))),S=_vue.computed.call(void 0, ()=>(o.value,t.isRequired(e))),B=_vue.computed.call(void 0, ()=>!!d.value),F=p=>{y.value=p},l=()=>t.blurField(e);return{value:i,displayValue:v,modelValue:y,setValue:F,setBlur:l,onInput:p=>{F(p)},onBlur:()=>{l()},meta:{error:r,touched:a,invalid:u,isValidating:g,isDirty:I,isHidden:x,isRequired:S,hasError:B}}}var h=()=>Math.random().toString(36).substring(2,9);function Q(e){let t=m(),s=()=>{let r=_chunk2QNUW6ZNcjs.e.call(void 0, t.getState().values,e);return Array.isArray(r)?r:[]},o=s(),n=_vue.ref.call(void 0, o),i=_vue.ref.call(void 0, o.map(h)),v=t.subscribe(()=>{let r=s();if(n.value=[...r],r.length!==i.value.length){let a=[...i.value];if(r.length>a.length){let u=r.length-a.length,g=Array.from({length:u},h);i.value=[...a,...g]}else i.value=a.slice(0,r.length)}});_vue.onUnmounted.call(void 0, ()=>{v(),t.unregisterPrefix&&t.unregisterPrefix(`${e}.`)});let y=_vue.computed.call(void 0, ()=>n.value.map((r,a)=>({key:i.value[a]||`temp-${a}`,value:r,index:a}))),d=_vue.computed.call(void 0, ()=>n.value.length);return{fields:y,length:d,append:r=>{i.value.push(h()),t.pushItem(e,r)},prepend:r=>{i.value.unshift(h()),t.prependItem(e,r)},insert:(r,a)=>{i.value.splice(r,0,h()),t.insertItem(e,r,a)},remove:r=>{i.value.splice(r,1),t.removeItem(e,r)},move:(r,a)=>{let u=[...i.value],[g]=u.splice(r,1);u.splice(a,0,g),i.value=u,t.moveItem(e,r,a)},swap:(r,a)=>{let u=[...i.value];[u[r],u[a]]=[u[a],u[r]],i.value=u,t.swapItems(e,r,a)},replace:r=>{i.value=r.map(h),t.setField(e,r)},clear:()=>{i.value=[],t.setField(e,[])}}}function N(){let e=m(),t=_vue.shallowRef.call(void 0, e.getHistoryMetadata()),s=e.subscribe(()=>{t.value=e.getHistoryMetadata()});_vue.onUnmounted.call(void 0, s);let o=()=>e.undo(),n=()=>e.redo();return{canUndo:_vue.computed.call(void 0, ()=>t.value.canUndo),canRedo:_vue.computed.call(void 0, ()=>t.value.canRedo),historyIndex:_vue.computed.call(void 0, ()=>t.value.historyIndex),historySize:_vue.computed.call(void 0, ()=>t.value.historySize),undo:o,redo:n}}function se(e,t){let s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(n=>e[n]===t[n])}function oe(e){let t=m(),s=_vue.ref.call(void 0, t.getStepStatus(e)),o;_vue.onMounted.call(void 0, ()=>{o=t.subscribe(()=>{let r=t.getStepStatus(e);(r.hasErrors!==s.value.hasErrors||r.isDirty!==s.value.isDirty||!se(r.errors,s.value.errors))&&(s.value=r)})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([o, 'optionalCall', _6 => _6()])});let n=async()=>{let r=await t.validate({scope:e}),a=t.getStepErrors(e);return{valid:r,errors:a}},i=()=>t.getStepErrors(e),v=_vue.computed.call(void 0, ()=>!s.value.hasErrors),y=_vue.computed.call(void 0, ()=>s.value.isDirty),d=_vue.computed.call(void 0, ()=>s.value.errors);return{scopeName:e,status:s,errors:d,validate:n,getErrors:i,isValid:v,isDirty:y}}function ue(e,t){let s=Object.keys(e),o=Object.keys(t);return s.length!==o.length?!1:s.every(n=>e[n]===t[n])}function le(e){let t=m(),s=_vue.ref.call(void 0, 0),o=_vue.computed.call(void 0, ()=>_nullishCoalesce(e[s.value], () => (""))),n=_vue.ref.call(void 0, t.getStepStatus(o.value)),i;_vue.watch.call(void 0, o,l=>{n.value=t.getStepStatus(l)});let v=()=>{let l=o.value,c=t.getStepStatus(l);(c.hasErrors!==n.value.hasErrors||c.isDirty!==n.value.isDirty||!ue(c.errors,n.value.errors))&&(n.value=c)};_vue.onMounted.call(void 0, ()=>{i=t.subscribe(v)}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([i, 'optionalCall', _7 => _7()])});let y=async()=>{let l=o.value,c=await t.validate({scope:l}),E=t.getStepErrors(l);return{valid:c,errors:E}},d=()=>t.getStepErrors(o.value),r=async()=>{let l=o.value,c=t.getScopeFields(l);if(t.hasValidationsInProgress(c))return!1;let E=await t.validate({scope:l});if(E)s.value=Math.min(s.value+1,e.length-1);else{let p=t.getStepErrors(l),P=Object.keys(p);P.length>0&&t.markFieldsTouched(P)}return E},a=()=>{s.value=Math.max(s.value-1,0)},u=l=>{s.value=Math.max(0,Math.min(l-1,e.length-1))},g=_vue.computed.call(void 0, ()=>s.value+1),I=_vue.computed.call(void 0, ()=>s.value===0),x=_vue.computed.call(void 0, ()=>s.value>=e.length-1),S=_vue.computed.call(void 0, ()=>!n.value.hasErrors),B=_vue.computed.call(void 0, ()=>n.value.isDirty),F=_vue.computed.call(void 0, ()=>n.value.errors);return{step:g,stepIndex:s,scope:o,next:r,prev:a,goTo:u,isFirst:I,isLast:x,status:n,errors:F,isValid:S,isDirty:B,validate:y,getErrors:d}}function pe(e){let t=m(),s=_chunk2QNUW6ZNcjs.e.call(void 0, t.getState().values,e),o=_vue.ref.call(void 0, s),n=t.watch(e,i=>{_chunk2QNUW6ZNcjs.d.call(void 0, o.value,i)||(o.value=i)});return _vue.onUnmounted.call(void 0, n),_vue.readonly.call(void 0, o)}function ve(e,t,s){let o=m(),n=R(e),i=null,v=async d=>{if(d){o.beginFieldValidation(e),await o.clearFieldAsyncError(e);try{let r=await t(d);n.setValue(r.url),i=r.key,await o.clearFieldAsyncError(e)}catch(r){let a=r instanceof Error?r.message:"Upload failed";await o.setFieldAsyncError(e,a)}finally{o.endFieldValidation(e)}}},y=async()=>{if(i&&s)try{await s(i)}catch(d){let r=d instanceof Error?d.message:"Delete failed";await o.setFieldAsyncError(e,r);return}n.setValue(null),i=null,await o.clearFieldAsyncError(e)};return{value:n.value,setValue:n.setValue,error:_vue.computed.call(void 0, ()=>n.meta.error.value),isValidating:_vue.computed.call(void 0, ()=>n.meta.isValidating.value||!1),upload:v,remove:y}}exports.provideBitStore = z; exports.useBitArray = Q; exports.useBitField = R; exports.useBitForm = L; exports.useBitHistory = N; exports.useBitScope = oe; exports.useBitSteps = le; exports.useBitStore = m; exports.useBitUpload = ve; exports.useBitWatch = pe;
2
2
  //# sourceMappingURL=index.cjs.map