@lehnihon/bit-form 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +150 -0
- package/dist/angular/index.cjs +2 -0
- package/dist/angular/index.cjs.map +1 -0
- package/dist/angular/index.d.cts +115 -0
- package/dist/angular/index.d.ts +115 -0
- package/dist/angular/index.js +2 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/bus-DAwKIiMY.d.cts +233 -0
- package/dist/bus-DAwKIiMY.d.ts +233 -0
- package/dist/chunk-32ZEDTLP.js +2 -0
- package/dist/chunk-32ZEDTLP.js.map +1 -0
- package/dist/chunk-FOPOA6NB.cjs +133 -0
- package/dist/chunk-FOPOA6NB.cjs.map +1 -0
- package/dist/chunk-XIDR3J47.cjs +2 -0
- package/dist/chunk-XIDR3J47.cjs.map +1 -0
- package/dist/chunk-ZI3XHI4I.js +133 -0
- package/dist/chunk-ZI3XHI4I.js.map +1 -0
- package/dist/cli/index.cjs +105 -0
- package/dist/devtools/bridge.cjs +2 -0
- package/dist/devtools/bridge.cjs.map +1 -0
- package/dist/devtools/bridge.d.cts +3 -0
- package/dist/devtools/bridge.d.ts +3 -0
- package/dist/devtools/bridge.js +2 -0
- package/dist/devtools/bridge.js.map +1 -0
- package/dist/devtools/index.cjs +2 -0
- package/dist/devtools/index.cjs.map +1 -0
- package/dist/devtools/index.d.cts +14 -0
- package/dist/devtools/index.d.ts +14 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/index-CmwQH2V1.d.cts +108 -0
- package/dist/index-DRvn8318.d.ts +108 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +119 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +34 -0
- package/dist/react/index.d.ts +34 -0
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react-native/index.cjs +2 -0
- package/dist/react-native/index.cjs.map +1 -0
- package/dist/react-native/index.d.cts +27 -0
- package/dist/react-native/index.d.ts +27 -0
- package/dist/react-native/index.js +2 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/resolvers/joi.cjs +2 -0
- package/dist/resolvers/joi.cjs.map +1 -0
- package/dist/resolvers/joi.d.cts +8 -0
- package/dist/resolvers/joi.d.ts +8 -0
- package/dist/resolvers/joi.js +2 -0
- package/dist/resolvers/joi.js.map +1 -0
- package/dist/resolvers/yup.cjs +2 -0
- package/dist/resolvers/yup.cjs.map +1 -0
- package/dist/resolvers/yup.d.cts +8 -0
- package/dist/resolvers/yup.d.ts +8 -0
- package/dist/resolvers/yup.js +2 -0
- package/dist/resolvers/yup.js.map +1 -0
- package/dist/resolvers/zod.cjs +2 -0
- package/dist/resolvers/zod.cjs.map +1 -0
- package/dist/resolvers/zod.d.cts +8 -0
- package/dist/resolvers/zod.d.ts +8 -0
- package/dist/resolvers/zod.js +2 -0
- package/dist/resolvers/zod.js.map +1 -0
- package/dist/use-bit-watch-BMCwKIYx.d.cts +99 -0
- package/dist/use-bit-watch-BujTdIMc.d.ts +99 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.cts +122 -0
- package/dist/vue/index.d.ts +122 -0
- package/dist/vue/index.js +2 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +160 -0
|
@@ -0,0 +1,27 @@
|
|
|
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-BujTdIMc.js';
|
|
2
|
+
import { k as BitPath, h as BitFieldOptions, l as BitPathValue } from '../bus-DAwKIiMY.js';
|
|
3
|
+
export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-DAwKIiMY.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import '../index-DRvn8318.js';
|
|
7
|
+
|
|
8
|
+
declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P, options?: BitFieldOptions): {
|
|
9
|
+
value: BitPathValue<TForm, P>;
|
|
10
|
+
displayValue: string;
|
|
11
|
+
error: any;
|
|
12
|
+
touched: boolean;
|
|
13
|
+
invalid: boolean;
|
|
14
|
+
isValidating: boolean;
|
|
15
|
+
isDirty: boolean;
|
|
16
|
+
isHidden: boolean;
|
|
17
|
+
isRequired: boolean;
|
|
18
|
+
setValue: (val: BitPathValue<TForm, P>) => void;
|
|
19
|
+
setBlur: () => void;
|
|
20
|
+
props: {
|
|
21
|
+
value: string;
|
|
22
|
+
onChangeText: (text: string) => void;
|
|
23
|
+
onBlur: () => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { useBitField };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as g,b as P,c as x,d as m,e as v,f as y,g as S,h}from"../chunk-32ZEDTLP.js";import"../chunk-ZI3XHI4I.js";import{useMemo as f,useCallback as k}from"react";function V(i,n){let{fieldState:s,setValue:o,setBlur:u,store:t}=m(i),r=f(()=>{let e=n?.mask??t.config.fields?.[i]?.mask;if(e)return typeof e=="string"?t.config.masks[e]:e},[n?.mask,t.config.masks,t.config.fields,i]),l=f(()=>{let e=s.value;return e==null||e===""?"":r?r.format(e):String(e)},[s.value,r]),c=k(e=>{if(!r){o(e);return}o(r.parse(String(e??"")))},[r,o]),{isHidden:B,isRequired:p,value:F,error:d,touched:a}=s;return{value:F,displayValue:l,error:a?d:void 0,touched:a,invalid:!!(a&&d),isValidating:t.isFieldValidating(i),isDirty:t.isFieldDirty(i),isHidden:B,isRequired:p,setValue:o,setBlur:u,props:{value:l,onChangeText:c,onBlur:u}}}export{g as BitFormProvider,v as useBitArray,V as useBitField,x as useBitForm,y as useBitScope,S as useBitSteps,P as useBitStore,h as useBitWatch};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 { BitFieldOptions, BitPath, BitPathValue } from \"../core\";\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P, options?: BitFieldOptions) {\n const { fieldState, setValue, setBlur, store } = useBitFieldBase<\n BitPathValue<TForm, P>,\n TForm,\n P\n >(path);\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 setValue(text as any);\n return;\n }\n\n setValue(resolvedMask.parse(String(text ?? \"\")) as any);\n },\n [resolvedMask, setValue],\n );\n\n const { isHidden, isRequired, value, error, touched } = fieldState;\n\n return {\n value: value as BitPathValue<TForm, P>,\n displayValue,\n error: touched ? error : undefined,\n touched: touched,\n invalid: !!(touched && error),\n isValidating: store.isFieldValidating(path),\n isDirty: store.isFieldDirty(path),\n isHidden,\n isRequired,\n setValue,\n setBlur,\n props: {\n value: displayValue,\n onChangeText: handleChange,\n onBlur: setBlur,\n },\n };\n}\n"],"mappings":"kHAAA,OAAS,WAAAA,EAAS,eAAAC,MAAmB,QAI9B,SAASC,EAGdC,EAASC,EAA2B,CACpC,GAAM,CAAE,WAAAC,EAAY,SAAAC,EAAU,QAAAC,EAAS,MAAAC,CAAM,EAAIC,EAI/CN,CAAI,EAEAO,EAAeC,EAAQ,IAAM,CACjC,IAAMC,EACJR,GAAS,MAAQI,EAAM,OAAO,SAASL,CAAc,GAAG,KAC1D,GAAKS,EACL,OAAO,OAAOA,GAAe,SACzBJ,EAAM,OAAO,MAAOI,CAAU,EAC9BA,CACN,EAAG,CAACR,GAAS,KAAMI,EAAM,OAAO,MAAOA,EAAM,OAAO,OAAQL,CAAI,CAAC,EAE3DU,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,EAASW,CAAW,EACpB,MACF,CAEAX,EAASI,EAAa,MAAM,OAAOO,GAAQ,EAAE,CAAC,CAAQ,CACxD,EACA,CAACP,EAAcJ,CAAQ,CACzB,EAEM,CAAE,SAAAY,EAAU,WAAAC,EAAY,MAAAC,EAAO,MAAAC,EAAO,QAAAC,CAAQ,EAAIjB,EAExD,MAAO,CACL,MAAOe,EACP,aAAAP,EACA,MAAOS,EAAUD,EAAQ,OACzB,QAASC,EACT,QAAS,CAAC,EAAEA,GAAWD,GACvB,aAAcb,EAAM,kBAAkBL,CAAI,EAC1C,QAASK,EAAM,aAAaL,CAAI,EAChC,SAAAe,EACA,WAAAC,EACA,SAAAb,EACA,QAAAC,EACA,MAAO,CACL,MAAOM,EACP,aAAcE,EACd,OAAQR,CACV,CACF,CACF","names":["useMemo","useCallback","useBitField","path","options","fieldState","setValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","maskOption","displayValue","val","handleChange","useCallback","text","isHidden","isRequired","value","error","touched"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 n=i=>async(c,o)=>{let{error:t}=i.validate(c,{abortEarly:!1,allowUnknown:!0});if(!t)return{};let e={};return t.details.forEach(s=>{let r=s.path.join(".");_optionalChain([o, 'optionalAccess', _ => _.scopeFields])?o.scopeFields.includes(r)&&!e[r]&&(e[r]=s.message):r&&!e[r]&&(e[r]=s.message)}),e};exports.joiResolver = n;
|
|
2
|
+
//# sourceMappingURL=joi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/joi.ts"],"names":["joiResolver","schema","values","options","error","errors","detail","path"],"mappings":"AAGO,ilBAAMA,CAAAA,CAAiCC,CAAAA,EACrC,KAAA,CACLC,CAAAA,CACAC,CAAAA,CAAAA,EAC0B,CAE1B,GAAM,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAIH,CAAAA,CAAO,QAAA,CAASC,CAAAA,CAAQ,CACxC,UAAA,CAAY,CAAA,CAAA,CACZ,YAAA,CAAc,CAAA,CAChB,CAAC,CAAA,CAED,EAAA,CAAI,CAACE,CAAAA,CAAO,MAAO,CAAC,CAAA,CAEpB,IAAMC,CAAAA,CAAuB,CAAC,CAAA,CAE9B,OAAAD,CAAAA,CAAM,OAAA,CAAQ,OAAA,CAASE,CAAAA,EAAW,CAChC,IAAMC,CAAAA,CAAOD,CAAAA,CAAO,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,iBAG7BH,CAAAA,2BAAS,aAAA,CACPA,CAAAA,CAAQ,WAAA,CAAY,QAAA,CAASI,CAAI,CAAA,EAAK,CAACF,CAAAA,CAAOE,CAAI,CAAA,EAAA,CACpDF,CAAAA,CAAOE,CAAI,CAAA,CAAID,CAAAA,CAAO,OAAA,CAAA,CAEfC,CAAAA,EAAQ,CAACF,CAAAA,CAAOE,CAAI,CAAA,EAAA,CAC7BF,CAAAA,CAAOE,CAAI,CAAA,CAAID,CAAAA,CAAO,OAAA,CAE1B,CAAC,CAAA,CAEMD,CACT,CAAA,CAAA,wBAAA","file":"/Users/leandrocarol/Projetos/bit-form/dist/resolvers/joi.cjs","sourcesContent":["import { ObjectSchema } from \"joi\";\nimport { BitErrors } from \"../core\";\n\nexport const joiResolver = <T extends object>(schema: ObjectSchema<T>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n // Para validação parcial, o Joi precisa ignorar campos desconhecidos no objeto de valores\n const { error } = schema.validate(values, {\n abortEarly: false,\n allowUnknown: true,\n });\n\n if (!error) return {};\n\n const errors: BitErrors<T> = {};\n\n error.details.forEach((detail) => {\n const path = detail.path.join(\".\");\n\n // Se houver campos alvo, filtramos o erro. Caso contrário, pega tudo.\n if (options?.scopeFields) {\n if (options.scopeFields.includes(path) && !errors[path]) {\n errors[path] = detail.message;\n }\n } else if (path && !errors[path]) {\n errors[path] = detail.message;\n }\n });\n\n return errors;\n };\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ObjectSchema } from 'joi';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.cjs';
|
|
3
|
+
|
|
4
|
+
declare const joiResolver: <T extends object>(schema: ObjectSchema<T>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { joiResolver };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ObjectSchema } from 'joi';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.js';
|
|
3
|
+
|
|
4
|
+
declare const joiResolver: <T extends object>(schema: ObjectSchema<T>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { joiResolver };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n=i=>async(c,o)=>{let{error:t}=i.validate(c,{abortEarly:!1,allowUnknown:!0});if(!t)return{};let e={};return t.details.forEach(s=>{let r=s.path.join(".");o?.scopeFields?o.scopeFields.includes(r)&&!e[r]&&(e[r]=s.message):r&&!e[r]&&(e[r]=s.message)}),e};export{n as joiResolver};
|
|
2
|
+
//# sourceMappingURL=joi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/joi.ts"],"sourcesContent":["import { ObjectSchema } from \"joi\";\nimport { BitErrors } from \"../core\";\n\nexport const joiResolver = <T extends object>(schema: ObjectSchema<T>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n // Para validação parcial, o Joi precisa ignorar campos desconhecidos no objeto de valores\n const { error } = schema.validate(values, {\n abortEarly: false,\n allowUnknown: true,\n });\n\n if (!error) return {};\n\n const errors: BitErrors<T> = {};\n\n error.details.forEach((detail) => {\n const path = detail.path.join(\".\");\n\n // Se houver campos alvo, filtramos o erro. Caso contrário, pega tudo.\n if (options?.scopeFields) {\n if (options.scopeFields.includes(path) && !errors[path]) {\n errors[path] = detail.message;\n }\n } else if (path && !errors[path]) {\n errors[path] = detail.message;\n }\n });\n\n return errors;\n };\n};\n"],"mappings":"AAGO,IAAMA,EAAiCC,GACrC,MACLC,EACAC,IAC0B,CAE1B,GAAM,CAAE,MAAAC,CAAM,EAAIH,EAAO,SAASC,EAAQ,CACxC,WAAY,GACZ,aAAc,EAChB,CAAC,EAED,GAAI,CAACE,EAAO,MAAO,CAAC,EAEpB,IAAMC,EAAuB,CAAC,EAE9B,OAAAD,EAAM,QAAQ,QAASE,GAAW,CAChC,IAAMC,EAAOD,EAAO,KAAK,KAAK,GAAG,EAG7BH,GAAS,YACPA,EAAQ,YAAY,SAASI,CAAI,GAAK,CAACF,EAAOE,CAAI,IACpDF,EAAOE,CAAI,EAAID,EAAO,SAEfC,GAAQ,CAACF,EAAOE,CAAI,IAC7BF,EAAOE,CAAI,EAAID,EAAO,QAE1B,CAAC,EAEMD,CACT","names":["joiResolver","schema","values","options","error","errors","detail","path"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _yup = require('yup');var d=n=>async(o,i)=>{let a={};if(_optionalChain([i, 'optionalAccess', _ => _.scopeFields])&&i.scopeFields.length>0)return await Promise.all(i.scopeFields.map(async e=>{try{await n.validateAt(e,o)}catch(r){if(r.name==="ValidationError"&&r.path){let t=r.path.replace(/\[(\d+)\]/g,".$1");a[t]=r.message}}})),a;try{return await n.validate(o,{abortEarly:!1}),{}}catch(e){return e.name==="ValidationError"||e instanceof _yup.ValidationError?(_optionalChain([e, 'access', _2 => _2.inner, 'optionalAccess', _3 => _3.forEach, 'call', _4 => _4(r=>{if(r.path){let t=r.path.replace(/\[(\d+)\]/g,".$1");a[t]||(a[t]=r.message)}})]),a):{}}};exports.yupResolver = d;
|
|
2
|
+
//# sourceMappingURL=yup.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/yup.ts"],"names":["yupResolver","schema","values","options","errors","field","err","normalizedPath","ValidationError","error"],"mappings":"AAAA,umBAAwC,IAG3BA,CAAAA,CAAiCC,CAAAA,EACrC,K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AAA,CACML,CAAAA,CAAAA,CAEF,CAAC,CACV,CACF,CAAA,CAAA,wBAAA","file":"/Users/leandrocarol/Projetos/bit-form/dist/resolvers/yup.cjs","sourcesContent":["import { ValidationError, Schema } from \"yup\";\nimport { BitErrors } from \"../core\";\n\nexport const yupResolver = <T extends object>(schema: Schema<any>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n const errors: BitErrors<T> = {};\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n await Promise.all(\n options.scopeFields.map(async (field) => {\n try {\n await schema.validateAt(field, values);\n } catch (err: any) {\n if (err.name === \"ValidationError\" && err.path) {\n const normalizedPath = err.path.replace(/\\[(\\d+)\\]/g, \".$1\");\n errors[normalizedPath] = err.message;\n }\n }\n }),\n );\n return errors;\n }\n\n try {\n await schema.validate(values, { abortEarly: false });\n return {};\n } catch (err: any) {\n if (err.name === \"ValidationError\" || err instanceof ValidationError) {\n err.inner?.forEach((error: any) => {\n if (error.path) {\n const normalizedPath = error.path.replace(/\\[(\\d+)\\]/g, \".$1\");\n if (!errors[normalizedPath]) {\n errors[normalizedPath] = error.message;\n }\n }\n });\n return errors;\n }\n return {};\n }\n };\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from 'yup';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.cjs';
|
|
3
|
+
|
|
4
|
+
declare const yupResolver: <T extends object>(schema: Schema<any>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { yupResolver };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from 'yup';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.js';
|
|
3
|
+
|
|
4
|
+
declare const yupResolver: <T extends object>(schema: Schema<any>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { yupResolver };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ValidationError as s}from"yup";var d=n=>async(o,i)=>{let a={};if(i?.scopeFields&&i.scopeFields.length>0)return await Promise.all(i.scopeFields.map(async e=>{try{await n.validateAt(e,o)}catch(r){if(r.name==="ValidationError"&&r.path){let t=r.path.replace(/\[(\d+)\]/g,".$1");a[t]=r.message}}})),a;try{return await n.validate(o,{abortEarly:!1}),{}}catch(e){return e.name==="ValidationError"||e instanceof s?(e.inner?.forEach(r=>{if(r.path){let t=r.path.replace(/\[(\d+)\]/g,".$1");a[t]||(a[t]=r.message)}}),a):{}}};export{d as yupResolver};
|
|
2
|
+
//# sourceMappingURL=yup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import { ValidationError, Schema } from \"yup\";\nimport { BitErrors } from \"../core\";\n\nexport const yupResolver = <T extends object>(schema: Schema<any>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n const errors: BitErrors<T> = {};\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n await Promise.all(\n options.scopeFields.map(async (field) => {\n try {\n await schema.validateAt(field, values);\n } catch (err: any) {\n if (err.name === \"ValidationError\" && err.path) {\n const normalizedPath = err.path.replace(/\\[(\\d+)\\]/g, \".$1\");\n errors[normalizedPath] = err.message;\n }\n }\n }),\n );\n return errors;\n }\n\n try {\n await schema.validate(values, { abortEarly: false });\n return {};\n } catch (err: any) {\n if (err.name === \"ValidationError\" || err instanceof ValidationError) {\n err.inner?.forEach((error: any) => {\n if (error.path) {\n const normalizedPath = error.path.replace(/\\[(\\d+)\\]/g, \".$1\");\n if (!errors[normalizedPath]) {\n errors[normalizedPath] = error.message;\n }\n }\n });\n return errors;\n }\n return {};\n }\n };\n};\n"],"mappings":"AAAA,OAAS,mBAAAA,MAA+B,MAGjC,IAAMC,EAAiCC,GACrC,MACLC,EACAC,IAC0B,CAC1B,IAAMC,EAAuB,CAAC,EAE9B,GAAID,GAAS,aAAeA,EAAQ,YAAY,OAAS,EACvD,aAAM,QAAQ,IACZA,EAAQ,YAAY,IAAI,MAAOE,GAAU,CACvC,GAAI,CACF,MAAMJ,EAAO,WAAWI,EAAOH,CAAM,CACvC,OAASI,EAAU,CACjB,GAAIA,EAAI,OAAS,mBAAqBA,EAAI,KAAM,CAC9C,IAAMC,EAAiBD,EAAI,KAAK,QAAQ,aAAc,KAAK,EAC3DF,EAAOG,CAAc,EAAID,EAAI,OAC/B,CACF,CACF,CAAC,CACH,EACOF,EAGT,GAAI,CACF,aAAMH,EAAO,SAASC,EAAQ,CAAE,WAAY,EAAM,CAAC,EAC5C,CAAC,CACV,OAASI,EAAU,CACjB,OAAIA,EAAI,OAAS,mBAAqBA,aAAeP,GACnDO,EAAI,OAAO,QAASE,GAAe,CACjC,GAAIA,EAAM,KAAM,CACd,IAAMD,EAAiBC,EAAM,KAAK,QAAQ,aAAc,KAAK,EACxDJ,EAAOG,CAAc,IACxBH,EAAOG,CAAc,EAAIC,EAAM,QAEnC,CACF,CAAC,EACMJ,GAEF,CAAC,CACV,CACF","names":["ValidationError","yupResolver","schema","values","options","errors","field","err","normalizedPath","error"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 i=t=>async(c,o)=>{try{let e=t;if(_optionalChain([o, 'optionalAccess', _ => _.scopeFields])&&o.scopeFields.length>0){let r={};o.scopeFields.forEach(s=>r[s]=!0),t.pick&&(e=t.pick(r))}return await e.parseAsync(c),{}}catch(e){let r={};return e.issues&&e.issues.forEach(s=>{let a=s.path.join(".");a&&!r[a]&&(r[a]=s.message)}),r}};exports.zodResolver = i;
|
|
2
|
+
//# sourceMappingURL=zod.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/zod.ts"],"names":["zodResolver","schema","values","options","targetSchema","mask","field","err","errors","issue","path"],"mappings":"AAGO,ilBAAMA,CAAAA,CAAiCC,CAAAA,EACrC,KAAA,CACLC,CAAAA,CACAC,CAAAA,CAAAA,EAC0B,CAC1B,GAAI,CACF,IAAIC,CAAAA,CAAeH,CAAAA,CAEnB,EAAA,iBAAIE,CAAAA,2BAAS,aAAA,EAAeA,CAAAA,CAAQ,WAAA,CAAY,MAAA,CAAS,CAAA,CAAG,CAC1D,IAAME,CAAAA,CAAY,CAAC,CAAA,CACnBF,CAAAA,CAAQ,WAAA,CAAY,OAAA,CAASG,CAAAA,EAAWD,CAAAA,CAAKC,CAAK,CAAA,CAAI,CAAA,CAAK,CAAA,CACtDL,CAAAA,CAAe,IAAA,EAAA,CAClBG,CAAAA,CAAgBH,CAAAA,CAAe,IAAA,CAAKI,CAAI,CAAA,CAE5C,CAEA,OAAA,MAAMD,CAAAA,CAAa,UAAA,CAAWF,CAAM,CAAA,CAC7B,CAAC,CACV,CAAA,KAAA,CAASK,CAAAA,CAAU,CACjB,IAAMC,CAAAA,CAAuB,CAAC,CAAA,CAE9B,OAAID,CAAAA,CAAI,MAAA,EACNA,CAAAA,CAAI,MAAA,CAAO,OAAA,CAASE,CAAAA,EAAe,CACjC,IAAMC,CAAAA,CAAOD,CAAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,CAC5BC,CAAAA,EAAQ,CAACF,CAAAA,CAAOE,CAAI,CAAA,EAAA,CACtBF,CAAAA,CAAOE,CAAI,CAAA,CAAID,CAAAA,CAAM,OAAA,CAEzB,CAAC,CAAA,CAGID,CACT,CACF,CAAA,CAAA,wBAAA","file":"/Users/leandrocarol/Projetos/bit-form/dist/resolvers/zod.cjs","sourcesContent":["import { ZodSchema } from \"zod\";\nimport { BitErrors } from \"../core\";\n\nexport const zodResolver = <T extends object>(schema: ZodSchema<T>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n try {\n let targetSchema = schema;\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n const mask: any = {};\n options.scopeFields.forEach((field) => (mask[field] = true));\n if ((schema as any).pick) {\n targetSchema = (schema as any).pick(mask);\n }\n }\n\n await targetSchema.parseAsync(values);\n return {};\n } catch (err: any) {\n const errors: BitErrors<T> = {};\n\n if (err.issues) {\n err.issues.forEach((issue: any) => {\n const path = issue.path.join(\".\");\n if (path && !errors[path]) {\n errors[path] = issue.message;\n }\n });\n }\n\n return errors;\n }\n };\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZodSchema } from 'zod';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.cjs';
|
|
3
|
+
|
|
4
|
+
declare const zodResolver: <T extends object>(schema: ZodSchema<T>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { zodResolver };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ZodSchema } from 'zod';
|
|
2
|
+
import { e as BitErrors } from '../bus-DAwKIiMY.js';
|
|
3
|
+
|
|
4
|
+
declare const zodResolver: <T extends object>(schema: ZodSchema<T>) => (values: T, options?: {
|
|
5
|
+
scopeFields?: string[];
|
|
6
|
+
}) => Promise<BitErrors<T>>;
|
|
7
|
+
|
|
8
|
+
export { zodResolver };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var i=t=>async(c,o)=>{try{let e=t;if(o?.scopeFields&&o.scopeFields.length>0){let r={};o.scopeFields.forEach(s=>r[s]=!0),t.pick&&(e=t.pick(r))}return await e.parseAsync(c),{}}catch(e){let r={};return e.issues&&e.issues.forEach(s=>{let a=s.path.join(".");a&&!r[a]&&(r[a]=s.message)}),r}};export{i as zodResolver};
|
|
2
|
+
//# sourceMappingURL=zod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import { ZodSchema } from \"zod\";\nimport { BitErrors } from \"../core\";\n\nexport const zodResolver = <T extends object>(schema: ZodSchema<T>) => {\n return async (\n values: T,\n options?: { scopeFields?: string[] },\n ): Promise<BitErrors<T>> => {\n try {\n let targetSchema = schema;\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n const mask: any = {};\n options.scopeFields.forEach((field) => (mask[field] = true));\n if ((schema as any).pick) {\n targetSchema = (schema as any).pick(mask);\n }\n }\n\n await targetSchema.parseAsync(values);\n return {};\n } catch (err: any) {\n const errors: BitErrors<T> = {};\n\n if (err.issues) {\n err.issues.forEach((issue: any) => {\n const path = issue.path.join(\".\");\n if (path && !errors[path]) {\n errors[path] = issue.message;\n }\n });\n }\n\n return errors;\n }\n };\n};\n"],"mappings":"AAGO,IAAMA,EAAiCC,GACrC,MACLC,EACAC,IAC0B,CAC1B,GAAI,CACF,IAAIC,EAAeH,EAEnB,GAAIE,GAAS,aAAeA,EAAQ,YAAY,OAAS,EAAG,CAC1D,IAAME,EAAY,CAAC,EACnBF,EAAQ,YAAY,QAASG,GAAWD,EAAKC,CAAK,EAAI,EAAK,EACtDL,EAAe,OAClBG,EAAgBH,EAAe,KAAKI,CAAI,EAE5C,CAEA,aAAMD,EAAa,WAAWF,CAAM,EAC7B,CAAC,CACV,OAASK,EAAU,CACjB,IAAMC,EAAuB,CAAC,EAE9B,OAAID,EAAI,QACNA,EAAI,OAAO,QAASE,GAAe,CACjC,IAAMC,EAAOD,EAAM,KAAK,KAAK,GAAG,EAC5BC,GAAQ,CAACF,EAAOE,CAAI,IACtBF,EAAOE,CAAI,EAAID,EAAM,QAEzB,CAAC,EAGID,CACT,CACF","names":["zodResolver","schema","values","options","targetSchema","mask","field","err","errors","issue","path"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { B as BitStore } from './index-CmwQH2V1.cjs';
|
|
4
|
+
import { k as BitPath, l as BitPathValue, e as BitErrors, B as BitMask, b as BitArrayPath, a as BitArrayItem, n as BitTouched, S as ScopeStatus, V as ValidateScopeResult } from './bus-DAwKIiMY.cjs';
|
|
5
|
+
|
|
6
|
+
declare const BitFormProvider: ({ store, children, }: {
|
|
7
|
+
store: BitStore<any>;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare const useBitStore: <T extends object>() => BitStore<T>;
|
|
11
|
+
|
|
12
|
+
declare function useBitForm<T extends object>(): {
|
|
13
|
+
reset: () => void;
|
|
14
|
+
store: BitStore<T>;
|
|
15
|
+
setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
|
|
16
|
+
blurField: <P extends BitPath<T, "">>(path: P) => void;
|
|
17
|
+
setValues: (newValues: T) => void;
|
|
18
|
+
setError: (path: string, message: string | undefined) => void;
|
|
19
|
+
setErrors: (errors: BitErrors<T>) => void;
|
|
20
|
+
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
21
|
+
validate: (options?: {
|
|
22
|
+
scope?: string;
|
|
23
|
+
scopeFields?: string[];
|
|
24
|
+
}) => Promise<boolean>;
|
|
25
|
+
registerMask: (name: string, mask: BitMask) => void;
|
|
26
|
+
pushItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
27
|
+
removeItem: <P extends BitArrayPath<T>>(path: P, index: number) => void;
|
|
28
|
+
prependItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
29
|
+
insertItem: <P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
30
|
+
moveItem: <P extends BitArrayPath<T>>(path: P, from: number, to: number) => void;
|
|
31
|
+
swapItems: <P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number) => void;
|
|
32
|
+
undo: () => void;
|
|
33
|
+
redo: () => void;
|
|
34
|
+
getValues: () => T;
|
|
35
|
+
getErrors: () => BitErrors<T>;
|
|
36
|
+
getTouched: () => BitTouched<T>;
|
|
37
|
+
submit: (onSuccess: (values: T) => void | Promise<void>) => (e?: {
|
|
38
|
+
preventDefault: () => void;
|
|
39
|
+
}) => Promise<void>;
|
|
40
|
+
onSubmit: (handler: (values: T) => Promise<unknown>) => (e?: {
|
|
41
|
+
preventDefault: () => void;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
submitError: Error | null;
|
|
44
|
+
lastResponse: unknown;
|
|
45
|
+
isValid: boolean;
|
|
46
|
+
isDirty: boolean;
|
|
47
|
+
isSubmitting: boolean;
|
|
48
|
+
canUndo: boolean;
|
|
49
|
+
canRedo: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
|
|
53
|
+
append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
54
|
+
prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
55
|
+
insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
56
|
+
remove: (index: number) => void;
|
|
57
|
+
move: (from: number, to: number) => void;
|
|
58
|
+
swap: (indexA: number, indexB: number) => void;
|
|
59
|
+
replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
|
|
60
|
+
clear: () => void;
|
|
61
|
+
fields: {
|
|
62
|
+
key: string;
|
|
63
|
+
value: BitArrayItem<BitPathValue<TForm, P>>;
|
|
64
|
+
index: number;
|
|
65
|
+
}[];
|
|
66
|
+
length: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
declare function useBitScope(scopeName: string): {
|
|
70
|
+
scopeName: string;
|
|
71
|
+
status: ScopeStatus;
|
|
72
|
+
errors: Record<string, string>;
|
|
73
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
74
|
+
getErrors: () => Record<string, string>;
|
|
75
|
+
isValid: boolean;
|
|
76
|
+
isDirty: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
interface UseBitStepsResult {
|
|
80
|
+
step: number;
|
|
81
|
+
stepIndex: number;
|
|
82
|
+
scope: string;
|
|
83
|
+
next: () => Promise<boolean>;
|
|
84
|
+
prev: () => void;
|
|
85
|
+
goTo: (step: number) => void;
|
|
86
|
+
isFirst: boolean;
|
|
87
|
+
isLast: boolean;
|
|
88
|
+
status: ScopeStatus;
|
|
89
|
+
errors: Record<string, string>;
|
|
90
|
+
isValid: boolean;
|
|
91
|
+
isDirty: boolean;
|
|
92
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
93
|
+
getErrors: () => Record<string, string>;
|
|
94
|
+
}
|
|
95
|
+
declare function useBitSteps(scopeNames: string[]): UseBitStepsResult;
|
|
96
|
+
|
|
97
|
+
declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): BitPathValue<TForm, P>;
|
|
98
|
+
|
|
99
|
+
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 };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { B as BitStore } from './index-DRvn8318.js';
|
|
4
|
+
import { k as BitPath, l as BitPathValue, e as BitErrors, B as BitMask, b as BitArrayPath, a as BitArrayItem, n as BitTouched, S as ScopeStatus, V as ValidateScopeResult } from './bus-DAwKIiMY.js';
|
|
5
|
+
|
|
6
|
+
declare const BitFormProvider: ({ store, children, }: {
|
|
7
|
+
store: BitStore<any>;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
declare const useBitStore: <T extends object>() => BitStore<T>;
|
|
11
|
+
|
|
12
|
+
declare function useBitForm<T extends object>(): {
|
|
13
|
+
reset: () => void;
|
|
14
|
+
store: BitStore<T>;
|
|
15
|
+
setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
|
|
16
|
+
blurField: <P extends BitPath<T, "">>(path: P) => void;
|
|
17
|
+
setValues: (newValues: T) => void;
|
|
18
|
+
setError: (path: string, message: string | undefined) => void;
|
|
19
|
+
setErrors: (errors: BitErrors<T>) => void;
|
|
20
|
+
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
21
|
+
validate: (options?: {
|
|
22
|
+
scope?: string;
|
|
23
|
+
scopeFields?: string[];
|
|
24
|
+
}) => Promise<boolean>;
|
|
25
|
+
registerMask: (name: string, mask: BitMask) => void;
|
|
26
|
+
pushItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
27
|
+
removeItem: <P extends BitArrayPath<T>>(path: P, index: number) => void;
|
|
28
|
+
prependItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
29
|
+
insertItem: <P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
30
|
+
moveItem: <P extends BitArrayPath<T>>(path: P, from: number, to: number) => void;
|
|
31
|
+
swapItems: <P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number) => void;
|
|
32
|
+
undo: () => void;
|
|
33
|
+
redo: () => void;
|
|
34
|
+
getValues: () => T;
|
|
35
|
+
getErrors: () => BitErrors<T>;
|
|
36
|
+
getTouched: () => BitTouched<T>;
|
|
37
|
+
submit: (onSuccess: (values: T) => void | Promise<void>) => (e?: {
|
|
38
|
+
preventDefault: () => void;
|
|
39
|
+
}) => Promise<void>;
|
|
40
|
+
onSubmit: (handler: (values: T) => Promise<unknown>) => (e?: {
|
|
41
|
+
preventDefault: () => void;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
submitError: Error | null;
|
|
44
|
+
lastResponse: unknown;
|
|
45
|
+
isValid: boolean;
|
|
46
|
+
isDirty: boolean;
|
|
47
|
+
isSubmitting: boolean;
|
|
48
|
+
canUndo: boolean;
|
|
49
|
+
canRedo: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
|
|
53
|
+
append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
54
|
+
prepend: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
55
|
+
insert: (index: number, value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
56
|
+
remove: (index: number) => void;
|
|
57
|
+
move: (from: number, to: number) => void;
|
|
58
|
+
swap: (indexA: number, indexB: number) => void;
|
|
59
|
+
replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
|
|
60
|
+
clear: () => void;
|
|
61
|
+
fields: {
|
|
62
|
+
key: string;
|
|
63
|
+
value: BitArrayItem<BitPathValue<TForm, P>>;
|
|
64
|
+
index: number;
|
|
65
|
+
}[];
|
|
66
|
+
length: number;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
declare function useBitScope(scopeName: string): {
|
|
70
|
+
scopeName: string;
|
|
71
|
+
status: ScopeStatus;
|
|
72
|
+
errors: Record<string, string>;
|
|
73
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
74
|
+
getErrors: () => Record<string, string>;
|
|
75
|
+
isValid: boolean;
|
|
76
|
+
isDirty: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
interface UseBitStepsResult {
|
|
80
|
+
step: number;
|
|
81
|
+
stepIndex: number;
|
|
82
|
+
scope: string;
|
|
83
|
+
next: () => Promise<boolean>;
|
|
84
|
+
prev: () => void;
|
|
85
|
+
goTo: (step: number) => void;
|
|
86
|
+
isFirst: boolean;
|
|
87
|
+
isLast: boolean;
|
|
88
|
+
status: ScopeStatus;
|
|
89
|
+
errors: Record<string, string>;
|
|
90
|
+
isValid: boolean;
|
|
91
|
+
isDirty: boolean;
|
|
92
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
93
|
+
getErrors: () => Record<string, string>;
|
|
94
|
+
}
|
|
95
|
+
declare function useBitSteps(scopeNames: string[]): UseBitStepsResult;
|
|
96
|
+
|
|
97
|
+
declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): BitPathValue<TForm, P>;
|
|
98
|
+
|
|
99
|
+
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 };
|
|
@@ -0,0 +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 _chunkFOPOA6NBcjs = require('../chunk-FOPOA6NB.cjs');var _vue = require('vue');var w=Symbol("BIT_STORE");function C(e){_vue.provide.call(void 0, w,e)}function d(){let e=_vue.inject.call(void 0, w);if(!e)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return e}function K(){let e=d(),t=_vue.shallowRef.call(void 0, e.getState()),o=_vue.ref.call(void 0, null),s=_vue.ref.call(void 0, null),n=e.subscribe(()=>{t.value={...e.getState()}});_vue.onUnmounted.call(void 0, n);let i=()=>t.value.values,m=()=>t.value.errors,f=()=>t.value.touched,g=_vue.computed.call(void 0, ()=>t.value.isValid),r=_vue.computed.call(void 0, ()=>t.value.isSubmitting),u=_vue.computed.call(void 0, ()=>t.value.isDirty),c=_vue.computed.call(void 0, ()=>(t.value,e.canUndo)),p=_vue.computed.call(void 0, ()=>(t.value,e.canRedo));return{store:e,isValid:g,isSubmitting:r,isDirty:u,canUndo:c,canRedo:p,getValues:i,getErrors:m,getTouched:f,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()]),o.value=null,e.submit(async B=>{try{let a=await S(B);s.value=a,o.value=null}catch(a){_chunkFOPOA6NBcjs.h.call(void 0, a)?e.setServerErrors(_chunkFOPOA6NBcjs.i.call(void 0, a)):o.value=a instanceof Error?a:new Error(String(a))}})),submitError:o,lastResponse:s,reset:()=>{e.reset(),o.value=null,s.value=null},validate:e.validate.bind(e),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),registerMask:e.registerMask.bind(e),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),undo:e.undo.bind(e),redo:e.redo.bind(e)}}function W(e,t,o){let s=d();t&&s.registerField(e,t);let n=_nullishCoalesce(_optionalChain([o, 'optionalAccess', _6 => _6.mask]), () => (_optionalChain([s, 'access', _7 => _7.config, 'access', _8 => _8.fields, 'optionalAccess', _9 => _9[e], 'optionalAccess', _10 => _10.mask]))),i=n?typeof n=="string"?_optionalChain([s, 'access', _11 => _11.config, 'access', _12 => _12.masks, 'optionalAccess', _13 => _13[n]]):n:void 0,m=_vue.shallowRef.call(void 0, s.getState()),f=s.subscribe(()=>{m.value=s.getState()});_vue.onUnmounted.call(void 0, ()=>{f(),s.unregisterField&&s.unregisterField(e)});let g=_vue.computed.call(void 0, ()=>_chunkFOPOA6NBcjs.e.call(void 0, m.value.values,e)),r=_vue.computed.call(void 0, ()=>{let l=g.value;return l==null||l===""?"":i?i.format(l):String(l)}),u=_vue.computed.call(void 0, {get:()=>r.value,set:l=>{if(!i){s.setField(e,l);return}s.setField(e,i.parse(String(_nullishCoalesce(l, () => ("")))))}}),c=_vue.computed.call(void 0, ()=>m.value.touched[e]?m.value.errors[e]:void 0),p=_vue.computed.call(void 0, ()=>!!m.value.touched[e]),V=_vue.computed.call(void 0, ()=>!!(p.value&&c.value)),I=_vue.computed.call(void 0, ()=>(m.value,s.isFieldValidating(e))),S=_vue.computed.call(void 0, ()=>(m.value,s.isFieldDirty(e))),b=_vue.computed.call(void 0, ()=>(m.value,s.isHidden(e))),B=_vue.computed.call(void 0, ()=>(m.value,s.isRequired(e))),a=_vue.computed.call(void 0, ()=>({isDirty:S.value,isValidating:I.value,isHidden:b.value,isRequired:B.value,hasError:!!c.value}));return{value:u,displayValue:r,error:c,touched:p,invalid:V,isValidating:I,isDirty:S,isHidden:b,isRequired:B,fieldMeta:a,setBlur:()=>s.blurField(e),setValue:l=>u.value=l}}var F=()=>Math.random().toString(36).substring(2,9);function Y(e){let t=d(),o=()=>{let r=_chunkFOPOA6NBcjs.e.call(void 0, t.getState().values,e);return Array.isArray(r)?r:[]},s=o(),n=_vue.ref.call(void 0, s),i=_vue.ref.call(void 0, s.map(F)),m=t.subscribe(()=>{let r=o();if(n.value=[...r],r.length!==i.value.length){let u=[...i.value];if(r.length>u.length){let c=r.length-u.length,p=Array.from({length:c},F);i.value=[...u,...p]}else i.value=u.slice(0,r.length)}});_vue.onUnmounted.call(void 0, ()=>{m(),t.unregisterPrefix&&t.unregisterPrefix(`${e}.`)});let f=_vue.computed.call(void 0, ()=>n.value.map((r,u)=>({key:i.value[u]||`temp-${u}`,value:r,index:u}))),g=_vue.computed.call(void 0, ()=>n.value.length);return{fields:f,length:g,append:r=>{i.value.push(F()),t.pushItem(e,r)},prepend:r=>{i.value.unshift(F()),t.prependItem(e,r)},insert:(r,u)=>{i.value.splice(r,0,F()),t.insertItem(e,r,u)},remove:r=>{i.value.splice(r,1),t.removeItem(e,r)},move:(r,u)=>{let c=[...i.value],[p]=c.splice(r,1);c.splice(u,0,p),i.value=c,t.moveItem(e,r,u)},swap:(r,u)=>{let c=[...i.value];[c[r],c[u]]=[c[u],c[r]],i.value=c,t.swapItems(e,r,u)},replace:r=>{i.value=r.map(F),t.setField(e,r)},clear:()=>{i.value=[],t.setField(e,[])}}}function Q(e,t){let o=Object.keys(e),s=Object.keys(t);return o.length!==s.length?!1:o.every(n=>e[n]===t[n])}function X(e){let t=d(),o=_vue.ref.call(void 0, t.getStepStatus(e)),s;_vue.onMounted.call(void 0, ()=>{s=t.subscribe(()=>{let r=t.getStepStatus(e);(r.hasErrors!==o.value.hasErrors||r.isDirty!==o.value.isDirty||!Q(r.errors,o.value.errors))&&(o.value=r)})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([s, 'optionalCall', _14 => _14()])});let n=async()=>{let r=await t.validate({scope:e}),u=t.getStepErrors(e);return{valid:r,errors:u}},i=()=>t.getStepErrors(e),m=_vue.computed.call(void 0, ()=>!o.value.hasErrors),f=_vue.computed.call(void 0, ()=>o.value.isDirty),g=_vue.computed.call(void 0, ()=>o.value.errors);return{scopeName:e,status:o,errors:g,validate:n,getErrors:i,isValid:m,isDirty:f}}function te(e,t){let o=Object.keys(e),s=Object.keys(t);return o.length!==s.length?!1:o.every(n=>e[n]===t[n])}function re(e){let t=d(),o=_vue.ref.call(void 0, 0),s=_vue.computed.call(void 0, ()=>_nullishCoalesce(e[o.value], () => (""))),n=_vue.ref.call(void 0, t.getStepStatus(s.value)),i;_vue.watch.call(void 0, s,a=>{n.value=t.getStepStatus(a)});let m=()=>{let a=s.value,l=t.getStepStatus(a);(l.hasErrors!==n.value.hasErrors||l.isDirty!==n.value.isDirty||!te(l.errors,n.value.errors))&&(n.value=l)};_vue.onMounted.call(void 0, ()=>{i=t.subscribe(m)}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([i, 'optionalCall', _15 => _15()])});let f=async()=>{let a=s.value,l=await t.validate({scope:a}),M=t.getStepErrors(a);return{valid:l,errors:M}},g=()=>t.getStepErrors(s.value),r=async()=>{let a=s.value,l=await t.validate({scope:a});return l&&(o.value=Math.min(o.value+1,e.length-1)),l},u=()=>{o.value=Math.max(o.value-1,0)},c=a=>{o.value=Math.max(0,Math.min(a-1,e.length-1))},p=_vue.computed.call(void 0, ()=>o.value+1),V=_vue.computed.call(void 0, ()=>o.value===0),I=_vue.computed.call(void 0, ()=>o.value>=e.length-1),S=_vue.computed.call(void 0, ()=>!n.value.hasErrors),b=_vue.computed.call(void 0, ()=>n.value.isDirty),B=_vue.computed.call(void 0, ()=>n.value.errors);return{step:p,stepIndex:o,scope:s,next:r,prev:u,goTo:c,isFirst:V,isLast:I,status:n,errors:B,isValid:S,isDirty:b,validate:f,getErrors:g}}function ie(e){let t=d(),o=_chunkFOPOA6NBcjs.e.call(void 0, t.getState().values,e),s=_vue.ref.call(void 0, o),n=t.watch(e,i=>{_chunkFOPOA6NBcjs.d.call(void 0, s.value,i)||(s.value=i)});return _vue.onUnmounted.call(void 0, n),_vue.readonly.call(void 0, s)}exports.provideBitStore = C; exports.useBitArray = Y; exports.useBitField = W; exports.useBitForm = K; exports.useBitScope = X; exports.useBitSteps = re; exports.useBitStore = d; exports.useBitWatch = ie;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/leandrocarol/Projetos/bit-form/dist/vue/index.cjs","../../src/vue/context.ts","../../src/vue/use-bit-form.ts","../../src/vue/use-bit-field.ts","../../src/vue/use-bit-array.ts"],"names":["BIT_STORE_KEY","provideBitStore","store","provide","useBitStore","inject","useBitForm","state","shallowRef","submitError","ref","lastResponse","unsubscribe","onUnmounted","getValues","getErrors","getTouched","isValid","computed","isSubmitting","isDirty","canUndo","canRedo","onSuccess","e","handler","values","result","err","isValidationErrorShape","extractServerErrors","useBitField","path","config","options","maskOption","resolvedMask","rawValue","getDeepValue","displayValue","val","value","error","touched","invalid","isValidating","isHidden","isRequired","fieldMeta","generateId","useBitArray","getSnapshot","initialValues","ids","newValues","currentIds","diff","newIds"],"mappings":"AAAA,0uBAA8D,0BCAhB,IAIjCA,CAAAA,CAA6C,MAAA,CAAO,WAAW,CAAA,CAErE,SAASC,CAAAA,CAAgBC,CAAAA,CAAsB,CACpDC,0BAAAA,CAAQH,CAAeE,CAAK,CAC9B,CAEO,SAASE,CAAAA,CAAAA,CAAgC,CAC9C,IAAMF,CAAAA,CAAQG,yBAAAA,CAAoB,CAAA,CAClC,EAAA,CAAI,CAACH,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,2DACF,CAAA,CACF,OAAOA,CACT,CCjBA,SAIgBI,CAAAA,CAAAA,CAA+B,CAC7C,IAAMJ,CAAAA,CAAQE,CAAAA,CAAe,CAAA,CACvBG,CAAAA,CAAQC,6BAAAA,CAAWN,CAAM,QAAA,CAAS,CAAC,CAAA,CACnCO,CAAAA,CAAcC,sBAAAA,IAAsB,CAAA,CACpCC,CAAAA,CAAeD,sBAAAA,IAAiB,CAAA,CAEhCE,CAAAA,CAAcV,CAAAA,CAAM,SAAA,CAAU,CAAA,CAAA,EAAM,CACxCK,CAAAA,CAAM,KAAA,CAAQ,CAAE,GAAGL,CAAAA,CAAM,QAAA,CAAS,CAAE,CACtC,CAAC,CAAA,CAEDW,8BAAAA,CAAuB,CAAA,CAEvB,IAAMC,CAAAA,CAAY,CAAA,CAAA,EAAMP,C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C,CAAAA,CAAW,MAAA,CACrCE,CAAAA,CAAS,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQD,CAAK,CAAA,CAAGP,CAAU,CAAA,CACtDI,CAAAA,CAAI,KAAA,CAAQ,CAAC,GAAGE,CAAAA,CAAY,GAAGE,CAAM,CACvC,CAAA,KACEJ,CAAAA,CAAI,KAAA,CAAQE,CAAAA,CAAW,KAAA,CAAM,CAAA,CAAGD,CAAAA,CAAU,MAAM,CAEpD,CACF,CAAC,CAAA,CAEDzC,8BAAAA,CAAY,CAAA,EAAM,CAChBD,CAAAA,CAAY,CAAA,CACRV,CAAAA,CAAM,gBAAA,EACRA,CAAAA,CAAM,gBAAA,CAAiB,CAAA,EAAA","file":"/Users/leandrocarol/Projetos/bit-form/dist/vue/index.cjs","sourcesContent":[null,"import { inject, provide, InjectionKey } from \"vue\";\nimport { BitStore } from \"../core\";\n\n// Chave única para evitar colisões\nexport const BIT_STORE_KEY: InjectionKey<BitStore<any>> = Symbol(\"BIT_STORE\");\n\nexport function provideBitStore(store: BitStore<any>) {\n provide(BIT_STORE_KEY, store);\n}\n\nexport function useBitStore<T extends object>() {\n const store = inject(BIT_STORE_KEY);\n if (!store)\n throw new Error(\n \"BitForm Vue hooks devem ser usados sob um provideBitStore\",\n );\n return store as BitStore<T>;\n}\n","import { computed, onUnmounted, shallowRef, ref } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { isValidationErrorShape, extractServerErrors } from \"../core/utils\";\n\nexport function useBitForm<T extends object>() {\n const store = useBitStore<T>();\n const state = shallowRef(store.getState());\n const submitError = ref<Error | null>(null);\n const lastResponse = ref<unknown>(null);\n\n const unsubscribe = store.subscribe(() => {\n state.value = { ...store.getState() };\n });\n\n onUnmounted(unsubscribe);\n\n const getValues = () => state.value.values;\n const getErrors = () => state.value.errors;\n const getTouched = () => state.value.touched;\n\n const isValid = computed(() => state.value.isValid);\n const isSubmitting = computed(() => state.value.isSubmitting);\n const isDirty = computed(() => state.value.isDirty);\n\n const canUndo = computed(() => {\n state.value;\n return store.canUndo;\n });\n\n const canRedo = computed(() => {\n state.value;\n return store.canRedo;\n });\n\n const onSubmit = (handler: (values: T) => Promise<unknown>) => {\n return (e?: Event) => {\n e?.preventDefault?.();\n submitError.value = null;\n return store.submit(async (values) => {\n try {\n const result = await handler(values);\n lastResponse.value = result;\n submitError.value = null;\n } catch (err) {\n if (isValidationErrorShape(err)) {\n store.setServerErrors(extractServerErrors(err));\n } else {\n submitError.value =\n err instanceof Error ? err : new Error(String(err));\n }\n }\n });\n };\n };\n\n const reset = () => {\n store.reset();\n submitError.value = null;\n lastResponse.value = null;\n };\n\n return {\n store,\n isValid,\n isSubmitting,\n isDirty,\n canUndo,\n canRedo,\n getValues,\n getErrors,\n getTouched,\n submit: (onSuccess: (values: T) => void | Promise<void>) => {\n return (e?: Event) => {\n e?.preventDefault?.();\n return store.submit(onSuccess);\n };\n },\n onSubmit,\n submitError,\n lastResponse,\n reset,\n validate: store.validate.bind(store),\n setValues: store.setValues.bind(store),\n setError: store.setError.bind(store),\n setErrors: store.setErrors.bind(store),\n setServerErrors: store.setServerErrors.bind(store),\n setField: store.setField.bind(store),\n blurField: store.blurField.bind(store),\n registerMask: store.registerMask.bind(store),\n pushItem: store.pushItem.bind(store),\n prependItem: store.prependItem.bind(store),\n removeItem: store.removeItem.bind(store),\n insertItem: store.insertItem.bind(store),\n moveItem: store.moveItem.bind(store),\n swapItems: store.swapItems.bind(store),\n undo: store.undo.bind(store),\n redo: store.redo.bind(store),\n };\n}\n","import { computed, onUnmounted, shallowRef } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport { BitFieldOptions, BitFieldDefinition, getDeepValue } from \"../core\";\n\nexport function useBitField<TValue = any>(\n path: string,\n config?: BitFieldDefinition<any>,\n options?: BitFieldOptions,\n) {\n const store = useBitStore<any>();\n\n if (config) {\n store.registerField(path as string, config as any);\n }\n\n const maskOption =\n options?.mask ?? store.config.fields?.[path as string]?.mask;\n const resolvedMask = maskOption\n ? typeof maskOption === \"string\"\n ? store.config.masks?.[maskOption]\n : maskOption\n : undefined;\n\n const state = shallowRef(store.getState());\n\n const unsubscribe = store.subscribe(() => {\n state.value = store.getState();\n });\n\n onUnmounted(() => {\n unsubscribe();\n if (store.unregisterField) {\n store.unregisterField(path as string);\n }\n });\n\n const rawValue = computed(\n () => getDeepValue(state.value.values, path as string) as TValue,\n );\n\n const displayValue = computed(() => {\n const val = rawValue.value;\n if (val === undefined || val === null || val === \"\") return \"\";\n\n return resolvedMask ? resolvedMask.format(val as any) : String(val);\n });\n\n const value = computed({\n get: () => displayValue.value,\n set: (val: any) => {\n if (!resolvedMask) {\n store.setField(path, val);\n return;\n }\n\n store.setField(path, resolvedMask.parse(String(val ?? \"\")));\n },\n });\n\n const error = computed(() =>\n state.value.touched[path] ? state.value.errors[path] : undefined,\n );\n const touched = computed(() => !!state.value.touched[path]);\n const invalid = computed(() => !!(touched.value && error.value));\n\n const isValidating = computed(() => {\n state.value;\n return store.isFieldValidating(path);\n });\n\n const isDirty = computed(() => {\n state.value;\n return store.isFieldDirty(path);\n });\n\n const isHidden = computed(() => {\n state.value;\n return store.isHidden(path);\n });\n\n const isRequired = computed(() => {\n state.value;\n return store.isRequired(path);\n });\n\n const fieldMeta = computed(() => ({\n isDirty: isDirty.value,\n isValidating: isValidating.value,\n isHidden: isHidden.value,\n isRequired: isRequired.value,\n hasError: !!error.value,\n }));\n\n return {\n value,\n displayValue,\n error,\n touched,\n invalid,\n isValidating,\n isDirty,\n isHidden,\n isRequired,\n fieldMeta,\n setBlur: () => store.blurField(path),\n setValue: (val: any) => (value.value = val),\n };\n}\n","import { ref, computed, onUnmounted } from \"vue\";\nimport { useBitStore } from \"./context\";\nimport {\n getDeepValue,\n BitArrayPath,\n BitPathValue,\n BitArrayItem,\n BitPath,\n} from \"../core\";\n\nconst generateId = () => Math.random().toString(36).substring(2, 9);\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n\n type Item = BitArrayItem<BitPathValue<TForm, P>>;\n\n const getSnapshot = (): Item[] => {\n const val = getDeepValue(\n store.getState().values,\n path as string,\n ) as BitPathValue<TForm, P> | undefined;\n return Array.isArray(val) ? (val as Item[]) : [];\n };\n\n const initialValues = getSnapshot();\n const values = ref<Item[]>(initialValues);\n const ids = ref<string[]>(initialValues.map(generateId));\n\n const unsubscribe = store.subscribe(() => {\n const newValues = getSnapshot();\n values.value = [...newValues];\n\n if (newValues.length !== ids.value.length) {\n const currentIds = [...ids.value];\n if (newValues.length > currentIds.length) {\n const diff = newValues.length - currentIds.length;\n const newIds = Array.from({ length: diff }, generateId);\n ids.value = [...currentIds, ...newIds];\n } else {\n ids.value = currentIds.slice(0, newValues.length);\n }\n }\n });\n\n onUnmounted(() => {\n unsubscribe();\n if (store.unregisterPrefix) {\n store.unregisterPrefix(`${path as string}.`);\n }\n });\n\n const fields = computed(() =>\n values.value.map((v, i) => ({\n key: ids.value[i] || `temp-${i}`,\n value: v,\n index: i,\n })),\n );\n\n const length = computed(() => values.value.length);\n\n return {\n fields,\n length,\n append: (val: Item) => {\n ids.value.push(generateId());\n store.pushItem(path, val);\n },\n prepend: (val: Item) => {\n ids.value.unshift(generateId());\n store.prependItem(path, val);\n },\n insert: (index: number, val: Item) => {\n ids.value.splice(index, 0, generateId());\n store.insertItem(path, index, val);\n },\n remove: (index: number) => {\n ids.value.splice(index, 1);\n store.removeItem(path, index);\n },\n move: (from: number, to: number) => {\n const currentIds = [...ids.value];\n const [id] = currentIds.splice(from, 1);\n currentIds.splice(to, 0, id);\n ids.value = currentIds;\n store.moveItem(path, from, to);\n },\n swap: (a: number, b: number) => {\n const currentIds = [...ids.value];\n [currentIds[a], currentIds[b]] = [currentIds[b], currentIds[a]];\n ids.value = currentIds;\n store.swapItems(path, a, b);\n },\n replace: (items: Item[]) => {\n ids.value = items.map(generateId);\n store.setField(path as unknown as BitPath<TForm>, items as any);\n },\n clear: () => {\n ids.value = [];\n store.setField(path as unknown as BitPath<TForm>, [] as any);\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { B as BitStore } from '../index-CmwQH2V1.cjs';
|
|
2
|
+
import { e as BitErrors, n as BitTouched, k as BitPath, l as BitPathValue, B as BitMask, b as BitArrayPath, a as BitArrayItem, g as BitFieldDefinition, h as BitFieldOptions, S as ScopeStatus, V as ValidateScopeResult } from '../bus-DAwKIiMY.cjs';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import * as _vue_reactivity from '@vue/reactivity';
|
|
5
|
+
import * as _vue_shared from '@vue/shared';
|
|
6
|
+
|
|
7
|
+
declare function provideBitStore(store: BitStore<any>): void;
|
|
8
|
+
declare function useBitStore<T extends object>(): BitStore<T>;
|
|
9
|
+
|
|
10
|
+
declare function useBitForm<T extends object>(): {
|
|
11
|
+
store: BitStore<T>;
|
|
12
|
+
isValid: vue.ComputedRef<boolean>;
|
|
13
|
+
isSubmitting: vue.ComputedRef<boolean>;
|
|
14
|
+
isDirty: vue.ComputedRef<boolean>;
|
|
15
|
+
canUndo: vue.ComputedRef<boolean>;
|
|
16
|
+
canRedo: vue.ComputedRef<boolean>;
|
|
17
|
+
getValues: () => T;
|
|
18
|
+
getErrors: () => BitErrors<T>;
|
|
19
|
+
getTouched: () => BitTouched<T>;
|
|
20
|
+
submit: (onSuccess: (values: T) => void | Promise<void>) => (e?: Event) => Promise<void>;
|
|
21
|
+
onSubmit: (handler: (values: T) => Promise<unknown>) => (e?: Event) => Promise<void>;
|
|
22
|
+
submitError: vue.Ref<Error | null, Error | null>;
|
|
23
|
+
lastResponse: vue.Ref<unknown, unknown>;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
validate: (options?: {
|
|
26
|
+
scope?: string;
|
|
27
|
+
scopeFields?: string[];
|
|
28
|
+
}) => Promise<boolean>;
|
|
29
|
+
setValues: (newValues: T) => void;
|
|
30
|
+
setError: (path: string, message: string | undefined) => void;
|
|
31
|
+
setErrors: (errors: BitErrors<T>) => void;
|
|
32
|
+
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
33
|
+
setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
|
|
34
|
+
blurField: <P extends BitPath<T, "">>(path: P) => void;
|
|
35
|
+
registerMask: (name: string, mask: BitMask) => void;
|
|
36
|
+
pushItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
37
|
+
prependItem: <P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
38
|
+
removeItem: <P extends BitArrayPath<T>>(path: P, index: number) => void;
|
|
39
|
+
insertItem: <P extends BitArrayPath<T>>(path: P, index: number, value: BitArrayItem<BitPathValue<T, P>>) => void;
|
|
40
|
+
moveItem: <P extends BitArrayPath<T>>(path: P, from: number, to: number) => void;
|
|
41
|
+
swapItems: <P extends BitArrayPath<T>>(path: P, indexA: number, indexB: number) => void;
|
|
42
|
+
undo: () => void;
|
|
43
|
+
redo: () => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare function useBitField<TValue = any>(path: string, config?: BitFieldDefinition<any>, options?: BitFieldOptions): {
|
|
47
|
+
value: vue.WritableComputedRef<string, any>;
|
|
48
|
+
displayValue: vue.ComputedRef<string>;
|
|
49
|
+
error: vue.ComputedRef<string | undefined>;
|
|
50
|
+
touched: vue.ComputedRef<boolean>;
|
|
51
|
+
invalid: vue.ComputedRef<boolean>;
|
|
52
|
+
isValidating: vue.ComputedRef<boolean>;
|
|
53
|
+
isDirty: vue.ComputedRef<boolean>;
|
|
54
|
+
isHidden: vue.ComputedRef<boolean>;
|
|
55
|
+
isRequired: vue.ComputedRef<boolean>;
|
|
56
|
+
fieldMeta: vue.ComputedRef<{
|
|
57
|
+
isDirty: boolean;
|
|
58
|
+
isValidating: boolean;
|
|
59
|
+
isHidden: boolean;
|
|
60
|
+
isRequired: boolean;
|
|
61
|
+
hasError: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
setBlur: () => void;
|
|
64
|
+
setValue: (val: any) => any;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
|
|
68
|
+
fields: vue.ComputedRef<{
|
|
69
|
+
key: string;
|
|
70
|
+
value: _vue_reactivity.UnwrapRefSimple<BitArrayItem<BitPathValue<TForm, P>>>;
|
|
71
|
+
index: number;
|
|
72
|
+
}[]>;
|
|
73
|
+
length: vue.ComputedRef<number>;
|
|
74
|
+
append: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
75
|
+
prepend: (val: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
76
|
+
insert: (index: number, val: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
77
|
+
remove: (index: number) => void;
|
|
78
|
+
move: (from: number, to: number) => void;
|
|
79
|
+
swap: (a: number, b: number) => void;
|
|
80
|
+
replace: (items: BitArrayItem<BitPathValue<TForm, P>>[]) => void;
|
|
81
|
+
clear: () => void;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
declare function useBitScope(scopeName: string): {
|
|
85
|
+
scopeName: string;
|
|
86
|
+
status: vue.Ref<{
|
|
87
|
+
hasErrors: boolean;
|
|
88
|
+
isDirty: boolean;
|
|
89
|
+
errors: Record<string, string>;
|
|
90
|
+
}, ScopeStatus | {
|
|
91
|
+
hasErrors: boolean;
|
|
92
|
+
isDirty: boolean;
|
|
93
|
+
errors: Record<string, string>;
|
|
94
|
+
}>;
|
|
95
|
+
errors: vue.ComputedRef<Record<string, string>>;
|
|
96
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
97
|
+
getErrors: () => Record<string, string>;
|
|
98
|
+
isValid: vue.ComputedRef<boolean>;
|
|
99
|
+
isDirty: vue.ComputedRef<boolean>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
interface UseBitStepsResult {
|
|
103
|
+
step: vue.ComputedRef<number>;
|
|
104
|
+
stepIndex: vue.Ref<number>;
|
|
105
|
+
scope: vue.ComputedRef<string>;
|
|
106
|
+
next: () => Promise<boolean>;
|
|
107
|
+
prev: () => void;
|
|
108
|
+
goTo: (step: number) => void;
|
|
109
|
+
isFirst: vue.ComputedRef<boolean>;
|
|
110
|
+
isLast: vue.ComputedRef<boolean>;
|
|
111
|
+
status: vue.Ref<ScopeStatus>;
|
|
112
|
+
errors: vue.ComputedRef<Record<string, string>>;
|
|
113
|
+
isValid: vue.ComputedRef<boolean>;
|
|
114
|
+
isDirty: vue.ComputedRef<boolean>;
|
|
115
|
+
validate: () => Promise<ValidateScopeResult>;
|
|
116
|
+
getErrors: () => Record<string, string>;
|
|
117
|
+
}
|
|
118
|
+
declare function useBitSteps(scopeNames: string[]): UseBitStepsResult;
|
|
119
|
+
|
|
120
|
+
declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P): vue.DeepReadonly<vue.UnwrapNestedRefs<[BitPathValue<TForm, P>] extends [vue.Ref<any, any>] ? _vue_shared.IfAny<vue.Ref<any, any> & BitPathValue<TForm, P>, vue.Ref<vue.Ref<any, any> & BitPathValue<TForm, P>, vue.Ref<any, any> & BitPathValue<TForm, P>>, vue.Ref<any, any> & BitPathValue<TForm, P>> : vue.Ref<vue.UnwrapRef<BitPathValue<TForm, P>>, BitPathValue<TForm, P> | vue.UnwrapRef<BitPathValue<TForm, P>>>>>;
|
|
121
|
+
|
|
122
|
+
export { ScopeStatus, ValidateScopeResult, provideBitStore, useBitArray, useBitField, useBitForm, useBitScope, useBitSteps, useBitStore, useBitWatch };
|