@lehnihon/bit-form 2.2.0 → 2.2.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.
- package/dist/angular/index.cjs +1 -1
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.d.cts +37 -44
- package/dist/angular/index.d.ts +37 -44
- package/dist/angular/index.js +1 -1
- package/dist/angular/index.js.map +1 -1
- package/dist/bus-B1my-s_o.d.ts +16 -0
- package/dist/bus-BI29cKpD.d.cts +16 -0
- package/dist/chunk-2UVV7SU4.js +2 -0
- package/dist/chunk-2UVV7SU4.js.map +1 -0
- package/dist/chunk-676WXU4S.cjs +2 -0
- package/dist/chunk-676WXU4S.cjs.map +1 -0
- package/dist/chunk-7MBRAKBL.js +2 -0
- package/dist/chunk-7MBRAKBL.js.map +1 -0
- package/dist/chunk-AD7T42HJ.js +1 -0
- package/dist/chunk-AD7T42HJ.js.map +1 -0
- package/dist/chunk-C4BYXZGB.cjs +1 -0
- package/dist/chunk-C4BYXZGB.cjs.map +1 -0
- package/dist/chunk-ER2DNS7T.cjs +2 -0
- package/dist/chunk-ER2DNS7T.cjs.map +1 -0
- package/dist/chunk-NWPA4F3B.cjs +2 -0
- package/dist/chunk-NWPA4F3B.cjs.map +1 -0
- package/dist/chunk-O5RRLZR7.js +2 -0
- package/dist/chunk-O5RRLZR7.js.map +1 -0
- package/dist/chunk-TRPMTJ35.js +2 -0
- package/dist/chunk-TRPMTJ35.js.map +1 -0
- package/dist/chunk-VSWCUQAF.cjs +2 -0
- package/dist/chunk-VSWCUQAF.cjs.map +1 -0
- package/dist/cli/index.cjs +3 -3
- package/dist/core/light.cjs +2 -0
- package/dist/core/light.cjs.map +1 -0
- package/dist/core/light.d.cts +29 -0
- package/dist/core/light.d.ts +29 -0
- package/dist/core/light.js +2 -0
- package/dist/core/light.js.map +1 -0
- package/dist/devtools/bridge.cjs +1 -1
- package/dist/devtools/bridge.cjs.map +1 -1
- package/dist/devtools/bridge.js +1 -1
- package/dist/devtools/bridge.js.map +1 -1
- package/dist/devtools/index.cjs +132 -1
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/devtools/index.js +132 -1
- package/dist/devtools/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -52
- package/dist/index.d.ts +19 -52
- package/dist/index.js +1 -1
- package/dist/public-types-Bl94ECPb.d.ts +91 -0
- package/dist/public-types-CLIDR8aC.d.cts +91 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +6 -5
- package/dist/react/index.d.ts +6 -5
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-native/index.cjs +1 -1
- package/dist/react-native/index.cjs.map +1 -1
- package/dist/react-native/index.d.cts +5 -4
- package/dist/react-native/index.d.ts +5 -4
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/resolvers/joi.cjs +1 -1
- package/dist/resolvers/joi.cjs.map +1 -1
- package/dist/resolvers/joi.d.cts +4 -4
- package/dist/resolvers/joi.d.ts +4 -4
- package/dist/resolvers/joi.js +1 -1
- package/dist/resolvers/joi.js.map +1 -1
- package/dist/resolvers/types.cjs +1 -0
- package/dist/resolvers/types.cjs.map +1 -0
- package/dist/resolvers/types.d.cts +16 -0
- package/dist/resolvers/types.d.ts +16 -0
- package/dist/resolvers/types.js +1 -0
- package/dist/resolvers/types.js.map +1 -0
- package/dist/resolvers/yup.cjs +1 -1
- package/dist/resolvers/yup.cjs.map +1 -1
- package/dist/resolvers/yup.d.cts +4 -4
- package/dist/resolvers/yup.d.ts +4 -4
- package/dist/resolvers/yup.js +1 -1
- package/dist/resolvers/yup.js.map +1 -1
- package/dist/resolvers/zod.cjs +1 -1
- package/dist/resolvers/zod.cjs.map +1 -1
- package/dist/resolvers/zod.d.cts +4 -4
- package/dist/resolvers/zod.d.ts +4 -4
- package/dist/resolvers/zod.js +1 -1
- package/dist/resolvers/zod.js.map +1 -1
- package/dist/{bus-70e4jnBj.d.cts → types-DqeN9Kq_.d.cts} +16 -17
- package/dist/{bus-70e4jnBj.d.ts → types-DqeN9Kq_.d.ts} +16 -17
- package/dist/{use-bit-persist-COdNw_fv.d.ts → use-bit-persist-BgFBg8lQ.d.cts} +43 -53
- package/dist/{use-bit-persist-JshPvwwy.d.cts → use-bit-persist-JtinX6Vy.d.ts} +43 -53
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +54 -61
- package/dist/vue/index.d.ts +54 -61
- package/dist/vue/index.js +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +7 -1
- package/dist/chunk-25Q2XJBV.cjs +0 -133
- package/dist/chunk-25Q2XJBV.cjs.map +0 -1
- package/dist/chunk-2HAQ3QEQ.js +0 -133
- package/dist/chunk-2HAQ3QEQ.js.map +0 -1
- package/dist/chunk-HTB6QIUQ.js +0 -2
- package/dist/chunk-HTB6QIUQ.js.map +0 -1
- package/dist/chunk-W22D7QVJ.cjs +0 -2
- package/dist/chunk-W22D7QVJ.cjs.map +0 -1
- package/dist/public-types-BVZ16kgZ.d.ts +0 -74
- package/dist/public-types-r2aP68Gg.d.cts +0 -74
package/dist/resolvers/yup.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema } from 'yup';
|
|
2
|
-
import { i as BitErrors } from '../
|
|
2
|
+
import { i as BitErrors } from '../types-DqeN9Kq_.cjs';
|
|
3
|
+
import '../bus-BI29cKpD.cjs';
|
|
4
|
+
import { BitYupResolverConfig, BitResolverScopeOptions } from './types.cjs';
|
|
3
5
|
|
|
4
|
-
declare const yupResolver: <T extends object>(schema: Schema<
|
|
5
|
-
scopeFields?: string[];
|
|
6
|
-
}) => Promise<BitErrors<T>>;
|
|
6
|
+
declare const yupResolver: <T extends object>(schema: Schema<T>, config?: BitYupResolverConfig) => (values: T, options?: BitResolverScopeOptions) => Promise<BitErrors<T>>;
|
|
7
7
|
|
|
8
8
|
export { yupResolver };
|
package/dist/resolvers/yup.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema } from 'yup';
|
|
2
|
-
import { i as BitErrors } from '../
|
|
2
|
+
import { i as BitErrors } from '../types-DqeN9Kq_.js';
|
|
3
|
+
import '../bus-B1my-s_o.js';
|
|
4
|
+
import { BitYupResolverConfig, BitResolverScopeOptions } from './types.js';
|
|
3
5
|
|
|
4
|
-
declare const yupResolver: <T extends object>(schema: Schema<
|
|
5
|
-
scopeFields?: string[];
|
|
6
|
-
}) => Promise<BitErrors<T>>;
|
|
6
|
+
declare const yupResolver: <T extends object>(schema: Schema<T>, config?: BitYupResolverConfig) => (values: T, options?: BitResolverScopeOptions) => Promise<BitErrors<T>>;
|
|
7
7
|
|
|
8
8
|
export { yupResolver };
|
package/dist/resolvers/yup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as i,b as s,c as l}from"../chunk-7MBRAKBL.js";import{ValidationError as c}from"yup";var u=(a,n)=>async(p,e)=>{let t={};if(e?.scopeFields&&e.scopeFields.length>0)return await Promise.all(e.scopeFields.map(async o=>{try{await a.validateAt(o,p)}catch(r){r instanceof c&&r.path&&s(t,i(r.path),r.message)}})),t;try{return await a.validate(p,{abortEarly:n?.abortEarly??!1,stripUnknown:n?.stripUnknown??!1}),{}}catch(o){if(o instanceof c){for(let r of o.inner??[])r.path&&s(t,i(r.path),r.message);return l(t,e?.scopeFields)}return{}}};export{u as yupResolver};
|
|
2
2
|
//# sourceMappingURL=yup.js.map
|
|
@@ -1 +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<
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/yup.ts"],"sourcesContent":["import { ValidationError, Schema } from \"yup\";\nimport { BitErrors } from \"../core\";\nimport {\n filterErrorsByScope,\n normalizeErrorPath,\n setFirstError,\n} from \"./utils\";\nimport { BitResolverScopeOptions, BitYupResolverConfig } from \"./types\";\n\nexport const yupResolver = <T extends object>(\n schema: Schema<T>,\n config?: BitYupResolverConfig,\n) => {\n return async (\n values: T,\n options?: BitResolverScopeOptions,\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 (error: unknown) {\n if (error instanceof ValidationError && error.path) {\n setFirstError(\n errors,\n normalizeErrorPath(error.path),\n error.message,\n );\n }\n }\n }),\n );\n return errors;\n }\n\n try {\n await schema.validate(values, {\n abortEarly: config?.abortEarly ?? false,\n stripUnknown: config?.stripUnknown ?? false,\n });\n return {};\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n for (const item of error.inner ?? []) {\n if (item.path) {\n setFirstError(errors, normalizeErrorPath(item.path), item.message);\n }\n }\n\n return filterErrorsByScope(errors, options?.scopeFields);\n }\n\n return {};\n }\n };\n};\n"],"mappings":"uDAAA,OAAS,mBAAAA,MAA+B,MASjC,IAAMC,EAAc,CACzBC,EACAC,IAEO,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,MAAML,EAAO,WAAWK,EAAOH,CAAM,CACvC,OAASI,EAAgB,CACnBA,aAAiBC,GAAmBD,EAAM,MAC5CE,EACEJ,EACAK,EAAmBH,EAAM,IAAI,EAC7BA,EAAM,OACR,CAEJ,CACF,CAAC,CACH,EACOF,EAGT,GAAI,CACF,aAAMJ,EAAO,SAASE,EAAQ,CAC5B,WAAYD,GAAQ,YAAc,GAClC,aAAcA,GAAQ,cAAgB,EACxC,CAAC,EACM,CAAC,CACV,OAASK,EAAgB,CACvB,GAAIA,aAAiBC,EAAiB,CACpC,QAAWG,KAAQJ,EAAM,OAAS,CAAC,EAC7BI,EAAK,MACPF,EAAcJ,EAAQK,EAAmBC,EAAK,IAAI,EAAGA,EAAK,OAAO,EAIrE,OAAOC,EAAoBP,EAAQD,GAAS,WAAW,CACzD,CAEA,MAAO,CAAC,CACV,CACF","names":["ValidationError","yupResolver","schema","config","values","options","errors","field","error","ValidationError","setFirstError","normalizeErrorPath","item","filterErrorsByScope"]}
|
package/dist/resolvers/zod.cjs
CHANGED
|
@@ -1,2 +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
|
|
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 _chunkER2DNS7Tcjs = require('../chunk-ER2DNS7T.cjs');var _zod = require('zod');var l=(i,m)=>async(n,c)=>{try{return await i.parseAsync(n),{}}catch(r){let o={};if(r instanceof _zod.ZodError)for(let e of r.issues){let p=e.path.join(".");_chunkER2DNS7Tcjs.b.call(void 0, o,p,e.message)}return _chunkER2DNS7Tcjs.c.call(void 0, o,_optionalChain([c, 'optionalAccess', _ => _.scopeFields]))}};exports.zodResolver = l;
|
|
2
2
|
//# sourceMappingURL=zod.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resolvers/zod.ts"],"names":["zodResolver","schema","values","options","
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/resolvers/zod.cjs","../../src/resolvers/zod.ts"],"names":["zodResolver","schema","_config","values","options","error","errors","ZodError","issue","path","setFirstError","filterErrorsByScope"],"mappings":"AAAA,soBAAgD,0BCAZ,IAKvBA,CAAAA,CAAc,CACzBC,CAAAA,CACAC,CAAAA,CAAAA,EAEO,KAAA,CACLC,CAAAA,CACAC,CAAAA,CAAAA,EAC0B,CAC1B,GAAI,CACF,OAAA,MAAMH,CAAAA,CAAO,UAAA,CAAWE,CAAM,CAAA,CACvB,CAAC,CACV,CAAA,KAAA,CAASE,CAAAA,CAAgB,CACvB,IAAMC,CAAAA,CAAuB,CAAC,CAAA,CAE9B,EAAA,CAAID,EAAAA,WAAiBE,aAAAA,CACnB,GAAA,CAAA,IAAWC,EAAAA,GAASH,CAAAA,CAAM,MAAA,CAAQ,CAChC,IAAMI,CAAAA,CAAOD,CAAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,CAChCE,iCAAAA,CAAcJ,CAAQG,CAAAA,CAAMD,CAAAA,CAAM,OAAO,CAC3C,CAGF,OAAOG,iCAAAA,CAAoBL,iBAAQF,CAAAA,2BAAS,aAAW,CACzD,CACF,CAAA,CAAA,wBAAA","file":"/home/runner/work/bit-form/bit-form/dist/resolvers/zod.cjs","sourcesContent":[null,"import { ZodError, ZodSchema } from \"zod\";\nimport { BitErrors } from \"../core\";\nimport { filterErrorsByScope, setFirstError } from \"./utils\";\nimport { BitResolverScopeOptions, BitZodResolverConfig } from \"./types\";\n\nexport const zodResolver = <T extends object>(\n schema: ZodSchema<T>,\n _config?: BitZodResolverConfig,\n) => {\n return async (\n values: T,\n options?: BitResolverScopeOptions,\n ): Promise<BitErrors<T>> => {\n try {\n await schema.parseAsync(values);\n return {};\n } catch (error: unknown) {\n const errors: BitErrors<T> = {};\n\n if (error instanceof ZodError) {\n for (const issue of error.issues) {\n const path = issue.path.join(\".\");\n setFirstError(errors, path, issue.message);\n }\n }\n\n return filterErrorsByScope(errors, options?.scopeFields);\n }\n };\n};\n"]}
|
package/dist/resolvers/zod.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ZodSchema } from 'zod';
|
|
2
|
-
import { i as BitErrors } from '../
|
|
2
|
+
import { i as BitErrors } from '../types-DqeN9Kq_.cjs';
|
|
3
|
+
import '../bus-BI29cKpD.cjs';
|
|
4
|
+
import { BitZodResolverConfig, BitResolverScopeOptions } from './types.cjs';
|
|
3
5
|
|
|
4
|
-
declare const zodResolver: <T extends object>(schema: ZodSchema<T
|
|
5
|
-
scopeFields?: string[];
|
|
6
|
-
}) => Promise<BitErrors<T>>;
|
|
6
|
+
declare const zodResolver: <T extends object>(schema: ZodSchema<T>, _config?: BitZodResolverConfig) => (values: T, options?: BitResolverScopeOptions) => Promise<BitErrors<T>>;
|
|
7
7
|
|
|
8
8
|
export { zodResolver };
|
package/dist/resolvers/zod.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ZodSchema } from 'zod';
|
|
2
|
-
import { i as BitErrors } from '../
|
|
2
|
+
import { i as BitErrors } from '../types-DqeN9Kq_.js';
|
|
3
|
+
import '../bus-B1my-s_o.js';
|
|
4
|
+
import { BitZodResolverConfig, BitResolverScopeOptions } from './types.js';
|
|
3
5
|
|
|
4
|
-
declare const zodResolver: <T extends object>(schema: ZodSchema<T
|
|
5
|
-
scopeFields?: string[];
|
|
6
|
-
}) => Promise<BitErrors<T>>;
|
|
6
|
+
declare const zodResolver: <T extends object>(schema: ZodSchema<T>, _config?: BitZodResolverConfig) => (values: T, options?: BitResolverScopeOptions) => Promise<BitErrors<T>>;
|
|
7
7
|
|
|
8
8
|
export { zodResolver };
|
package/dist/resolvers/zod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
import{b as s,c as t}from"../chunk-7MBRAKBL.js";import{ZodError as f}from"zod";var l=(i,m)=>async(n,c)=>{try{return await i.parseAsync(n),{}}catch(r){let o={};if(r instanceof f)for(let e of r.issues){let p=e.path.join(".");s(o,p,e.message)}return t(o,c?.scopeFields)}};export{l as zodResolver};
|
|
2
2
|
//# sourceMappingURL=zod.js.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"sources":["../../src/resolvers/zod.ts"],"sourcesContent":["import { ZodError, ZodSchema } from \"zod\";\nimport { BitErrors } from \"../core\";\nimport { filterErrorsByScope, setFirstError } from \"./utils\";\nimport { BitResolverScopeOptions, BitZodResolverConfig } from \"./types\";\n\nexport const zodResolver = <T extends object>(\n schema: ZodSchema<T>,\n _config?: BitZodResolverConfig,\n) => {\n return async (\n values: T,\n options?: BitResolverScopeOptions,\n ): Promise<BitErrors<T>> => {\n try {\n await schema.parseAsync(values);\n return {};\n } catch (error: unknown) {\n const errors: BitErrors<T> = {};\n\n if (error instanceof ZodError) {\n for (const issue of error.issues) {\n const path = issue.path.join(\".\");\n setFirstError(errors, path, issue.message);\n }\n }\n\n return filterErrorsByScope(errors, options?.scopeFields);\n }\n };\n};\n"],"mappings":"gDAAA,OAAS,YAAAA,MAA2B,MAK7B,IAAMC,EAAc,CACzBC,EACAC,IAEO,MACLC,EACAC,IAC0B,CAC1B,GAAI,CACF,aAAMH,EAAO,WAAWE,CAAM,EACvB,CAAC,CACV,OAASE,EAAgB,CACvB,IAAMC,EAAuB,CAAC,EAE9B,GAAID,aAAiBE,EACnB,QAAWC,KAASH,EAAM,OAAQ,CAChC,IAAMI,EAAOD,EAAM,KAAK,KAAK,GAAG,EAChCE,EAAcJ,EAAQG,EAAMD,EAAM,OAAO,CAC3C,CAGF,OAAOG,EAAoBL,EAAQF,GAAS,WAAW,CACzD,CACF","names":["ZodError","zodResolver","schema","_config","values","options","error","errors","ZodError","issue","path","setFirstError","filterErrorsByScope"]}
|
|
@@ -2,6 +2,8 @@ interface BitMask {
|
|
|
2
2
|
format: (value: any) => string;
|
|
3
3
|
parse: (value: string) => any;
|
|
4
4
|
}
|
|
5
|
+
type BitBuiltInMaskName = "brl" | "usd" | "eur" | "gbp" | "jpy" | "percent" | "decimal" | "int" | "integer" | "cpf" | "cnpj" | "cpfCnpj" | "rg" | "cep" | "cnh" | "plate" | "phone" | "landline" | "date" | "time" | "usPhone" | "zipCode" | "dateUS" | "ssn" | "cc" | "cvv" | "dateISO" | "ip" | "ipv6" | "mac" | "color" | "iban";
|
|
6
|
+
type BitMaskName = BitBuiltInMaskName | (string & {});
|
|
5
7
|
interface PatternMaskOptions {
|
|
6
8
|
allowChars?: string;
|
|
7
9
|
customParse?: (value: string) => any;
|
|
@@ -42,6 +44,15 @@ interface BitState<T> {
|
|
|
42
44
|
isSubmitting: boolean;
|
|
43
45
|
isDirty: boolean;
|
|
44
46
|
}
|
|
47
|
+
interface BitFieldState<T extends object = any, TValue = unknown> {
|
|
48
|
+
value: TValue;
|
|
49
|
+
error: string | undefined;
|
|
50
|
+
touched: boolean;
|
|
51
|
+
isHidden: boolean;
|
|
52
|
+
isRequired: boolean;
|
|
53
|
+
isDirty: boolean;
|
|
54
|
+
isValidating: boolean;
|
|
55
|
+
}
|
|
45
56
|
type ValidatorFn<T> = (values: T, options?: {
|
|
46
57
|
scopeFields?: string[];
|
|
47
58
|
}) => Promise<BitErrors<T>> | BitErrors<T>;
|
|
@@ -64,8 +75,8 @@ interface BitFieldDefinition<T extends object = any> {
|
|
|
64
75
|
validation?: BitFieldValidation<T>;
|
|
65
76
|
transform?: BitTransformFn<T>;
|
|
66
77
|
computed?: BitComputedFn<T>;
|
|
67
|
-
/** Mask name (
|
|
68
|
-
mask?: BitMask |
|
|
78
|
+
/** Mask name (built-in or custom registry key) or BitMask instance. */
|
|
79
|
+
mask?: BitMask | BitMaskName;
|
|
69
80
|
/** Scope name (e.g. wizard step). */
|
|
70
81
|
scope?: string;
|
|
71
82
|
}
|
|
@@ -75,7 +86,7 @@ interface DevToolsOptions {
|
|
|
75
86
|
url?: string;
|
|
76
87
|
}
|
|
77
88
|
type BitPluginHookSource = "beforeValidate" | "afterValidate" | "beforeSubmit" | "afterSubmit" | "onFieldChange" | "setup" | "teardown" | "submit";
|
|
78
|
-
type BitFieldChangeOrigin = "setField" | "
|
|
89
|
+
type BitFieldChangeOrigin = "setField" | "rebase" | "replaceValues" | "hydrate" | "array";
|
|
79
90
|
type BitArrayOperation = "push" | "prepend" | "insert" | "remove" | "move" | "swap";
|
|
80
91
|
interface BitFieldChangeMeta {
|
|
81
92
|
origin: BitFieldChangeOrigin;
|
|
@@ -192,6 +203,7 @@ interface BitHistoryConfig {
|
|
|
192
203
|
interface BitConfig<T extends object = any> {
|
|
193
204
|
/** Core */
|
|
194
205
|
name?: string;
|
|
206
|
+
storeId?: string;
|
|
195
207
|
initialValues?: T;
|
|
196
208
|
/** Central field config: conditional, validation, transform, computed, mask, scope. */
|
|
197
209
|
fields?: Record<string, BitFieldDefinition<T>>;
|
|
@@ -230,17 +242,4 @@ type BitPathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ?
|
|
|
230
242
|
type BitArrayPath<T> = BitPath<T> extends infer P ? P extends string ? BitPathValue<T, P> extends readonly any[] ? P : never : never : never;
|
|
231
243
|
type BitArrayItem<A> = A extends readonly (infer U)[] ? U : A extends (infer U)[] ? U : never;
|
|
232
244
|
|
|
233
|
-
type
|
|
234
|
-
interface BitFormGlobal {
|
|
235
|
-
stores: Record<string, any>;
|
|
236
|
-
listeners: Set<BitBusListener>;
|
|
237
|
-
dispatch: (storeId: string, state: any) => void;
|
|
238
|
-
subscribe: (fn: BitBusListener) => () => void;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
declare global {
|
|
242
|
-
var __BIT_FORM__: BitFormGlobal | undefined;
|
|
243
|
-
}
|
|
244
|
-
declare const bitBus: BitFormGlobal;
|
|
245
|
-
|
|
246
|
-
export { type BitTransformFn as A, type BitConfig as B, type CurrencyMaskConfig as C, type DateMaskConfig as D, type BitValidationConfig as E, type DeepPartial as F, type ValidatorFn as G, bitBus as H, type DevToolsOptions as I, type BitPersistResolvedConfig as J, type PatternMaskOptions as P, type ScopeStatus as S, type ValidateScopeResult as V, type BitMask as a, type BitAfterSubmitEvent as b, type BitAfterValidateEvent as c, type BitArrayItem as d, type BitArrayPath as e, type BitBeforeSubmitEvent as f, type BitBeforeValidateEvent as g, type BitComputedFn as h, type BitErrors as i, type BitFieldChangeEvent as j, type BitFieldChangeMeta as k, type BitFieldConditional as l, type BitFieldDefinition as m, type BitFieldValidation as n, type BitHistoryConfig as o, type BitPath as p, type BitPathValue as q, type BitPersistConfig as r, type BitPersistMode as s, type BitPersistStorageAdapter as t, type BitPlugin as u, type BitPluginContext as v, type BitPluginErrorEvent as w, type BitPluginHooks as x, type BitState as y, type BitTouched as z };
|
|
245
|
+
export type { BitPersistConfig as A, BitConfig as B, CurrencyMaskConfig as C, DevToolsOptions as D, BitPersistMode as E, BitPersistStorageAdapter as F, BitPluginContext as G, BitPluginErrorEvent as H, BitPluginHooks as I, BitTouched as J, BitTransformFn as K, BitValidationConfig as L, PatternMaskOptions as P, ScopeStatus as S, ValidatorFn as V, BitMask as a, BitFieldDefinition as b, BitPersistResolvedConfig as c, BitPlugin as d, BitState as e, BitPath as f, BitPathValue as g, DeepPartial as h, BitErrors as i, BitMaskName as j, BitArrayPath as k, BitArrayItem as l, BitFieldState as m, ValidateScopeResult as n, DateMaskConfig as o, BitBuiltInMaskName as p, BitAfterSubmitEvent as q, BitAfterValidateEvent as r, BitBeforeSubmitEvent as s, BitBeforeValidateEvent as t, BitComputedFn as u, BitFieldChangeEvent as v, BitFieldChangeMeta as w, BitFieldConditional as x, BitFieldValidation as y, BitHistoryConfig as z };
|
|
@@ -2,6 +2,8 @@ interface BitMask {
|
|
|
2
2
|
format: (value: any) => string;
|
|
3
3
|
parse: (value: string) => any;
|
|
4
4
|
}
|
|
5
|
+
type BitBuiltInMaskName = "brl" | "usd" | "eur" | "gbp" | "jpy" | "percent" | "decimal" | "int" | "integer" | "cpf" | "cnpj" | "cpfCnpj" | "rg" | "cep" | "cnh" | "plate" | "phone" | "landline" | "date" | "time" | "usPhone" | "zipCode" | "dateUS" | "ssn" | "cc" | "cvv" | "dateISO" | "ip" | "ipv6" | "mac" | "color" | "iban";
|
|
6
|
+
type BitMaskName = BitBuiltInMaskName | (string & {});
|
|
5
7
|
interface PatternMaskOptions {
|
|
6
8
|
allowChars?: string;
|
|
7
9
|
customParse?: (value: string) => any;
|
|
@@ -42,6 +44,15 @@ interface BitState<T> {
|
|
|
42
44
|
isSubmitting: boolean;
|
|
43
45
|
isDirty: boolean;
|
|
44
46
|
}
|
|
47
|
+
interface BitFieldState<T extends object = any, TValue = unknown> {
|
|
48
|
+
value: TValue;
|
|
49
|
+
error: string | undefined;
|
|
50
|
+
touched: boolean;
|
|
51
|
+
isHidden: boolean;
|
|
52
|
+
isRequired: boolean;
|
|
53
|
+
isDirty: boolean;
|
|
54
|
+
isValidating: boolean;
|
|
55
|
+
}
|
|
45
56
|
type ValidatorFn<T> = (values: T, options?: {
|
|
46
57
|
scopeFields?: string[];
|
|
47
58
|
}) => Promise<BitErrors<T>> | BitErrors<T>;
|
|
@@ -64,8 +75,8 @@ interface BitFieldDefinition<T extends object = any> {
|
|
|
64
75
|
validation?: BitFieldValidation<T>;
|
|
65
76
|
transform?: BitTransformFn<T>;
|
|
66
77
|
computed?: BitComputedFn<T>;
|
|
67
|
-
/** Mask name (
|
|
68
|
-
mask?: BitMask |
|
|
78
|
+
/** Mask name (built-in or custom registry key) or BitMask instance. */
|
|
79
|
+
mask?: BitMask | BitMaskName;
|
|
69
80
|
/** Scope name (e.g. wizard step). */
|
|
70
81
|
scope?: string;
|
|
71
82
|
}
|
|
@@ -75,7 +86,7 @@ interface DevToolsOptions {
|
|
|
75
86
|
url?: string;
|
|
76
87
|
}
|
|
77
88
|
type BitPluginHookSource = "beforeValidate" | "afterValidate" | "beforeSubmit" | "afterSubmit" | "onFieldChange" | "setup" | "teardown" | "submit";
|
|
78
|
-
type BitFieldChangeOrigin = "setField" | "
|
|
89
|
+
type BitFieldChangeOrigin = "setField" | "rebase" | "replaceValues" | "hydrate" | "array";
|
|
79
90
|
type BitArrayOperation = "push" | "prepend" | "insert" | "remove" | "move" | "swap";
|
|
80
91
|
interface BitFieldChangeMeta {
|
|
81
92
|
origin: BitFieldChangeOrigin;
|
|
@@ -192,6 +203,7 @@ interface BitHistoryConfig {
|
|
|
192
203
|
interface BitConfig<T extends object = any> {
|
|
193
204
|
/** Core */
|
|
194
205
|
name?: string;
|
|
206
|
+
storeId?: string;
|
|
195
207
|
initialValues?: T;
|
|
196
208
|
/** Central field config: conditional, validation, transform, computed, mask, scope. */
|
|
197
209
|
fields?: Record<string, BitFieldDefinition<T>>;
|
|
@@ -230,17 +242,4 @@ type BitPathValue<T, P extends string> = P extends `${infer K}.${infer Rest}` ?
|
|
|
230
242
|
type BitArrayPath<T> = BitPath<T> extends infer P ? P extends string ? BitPathValue<T, P> extends readonly any[] ? P : never : never : never;
|
|
231
243
|
type BitArrayItem<A> = A extends readonly (infer U)[] ? U : A extends (infer U)[] ? U : never;
|
|
232
244
|
|
|
233
|
-
type
|
|
234
|
-
interface BitFormGlobal {
|
|
235
|
-
stores: Record<string, any>;
|
|
236
|
-
listeners: Set<BitBusListener>;
|
|
237
|
-
dispatch: (storeId: string, state: any) => void;
|
|
238
|
-
subscribe: (fn: BitBusListener) => () => void;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
declare global {
|
|
242
|
-
var __BIT_FORM__: BitFormGlobal | undefined;
|
|
243
|
-
}
|
|
244
|
-
declare const bitBus: BitFormGlobal;
|
|
245
|
-
|
|
246
|
-
export { type BitTransformFn as A, type BitConfig as B, type CurrencyMaskConfig as C, type DateMaskConfig as D, type BitValidationConfig as E, type DeepPartial as F, type ValidatorFn as G, bitBus as H, type DevToolsOptions as I, type BitPersistResolvedConfig as J, type PatternMaskOptions as P, type ScopeStatus as S, type ValidateScopeResult as V, type BitMask as a, type BitAfterSubmitEvent as b, type BitAfterValidateEvent as c, type BitArrayItem as d, type BitArrayPath as e, type BitBeforeSubmitEvent as f, type BitBeforeValidateEvent as g, type BitComputedFn as h, type BitErrors as i, type BitFieldChangeEvent as j, type BitFieldChangeMeta as k, type BitFieldConditional as l, type BitFieldDefinition as m, type BitFieldValidation as n, type BitHistoryConfig as o, type BitPath as p, type BitPathValue as q, type BitPersistConfig as r, type BitPersistMode as s, type BitPersistStorageAdapter as t, type BitPlugin as u, type BitPluginContext as v, type BitPluginErrorEvent as w, type BitPluginHooks as x, type BitState as y, type BitTouched as z };
|
|
245
|
+
export type { BitPersistConfig as A, BitConfig as B, CurrencyMaskConfig as C, DevToolsOptions as D, BitPersistMode as E, BitPersistStorageAdapter as F, BitPluginContext as G, BitPluginErrorEvent as H, BitPluginHooks as I, BitTouched as J, BitTransformFn as K, BitValidationConfig as L, PatternMaskOptions as P, ScopeStatus as S, ValidatorFn as V, BitMask as a, BitFieldDefinition as b, BitPersistResolvedConfig as c, BitPlugin as d, BitState as e, BitPath as f, BitPathValue as g, DeepPartial as h, BitErrors as i, BitMaskName as j, BitArrayPath as k, BitArrayItem as l, BitFieldState as m, ValidateScopeResult as n, DateMaskConfig as o, BitBuiltInMaskName as p, BitAfterSubmitEvent as q, BitAfterValidateEvent as r, BitBeforeSubmitEvent as s, BitBeforeValidateEvent as t, BitComputedFn as u, BitFieldChangeEvent as v, BitFieldChangeMeta as w, BitFieldConditional as x, BitFieldValidation as y, BitHistoryConfig as z };
|
|
@@ -1,52 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { b as
|
|
4
|
-
import
|
|
3
|
+
import { f as BitStoreApi, g as BitStoreHooksApi, b as BitHistoryMetadata, c as BitPersistMetadata, h as BitValidationOptions } from './public-types-CLIDR8aC.cjs';
|
|
4
|
+
import './bus-BI29cKpD.cjs';
|
|
5
|
+
import { f as BitPath, g as BitPathValue, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, J as BitTouched, h as DeepPartial, k as BitArrayPath, l as BitArrayItem } from './types-DqeN9Kq_.cjs';
|
|
5
6
|
|
|
6
7
|
declare const BitFormProvider: ({ store, children, }: {
|
|
7
|
-
store:
|
|
8
|
+
store: BitStoreApi<any>;
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
-
declare const useBitStore: <T extends object>() =>
|
|
11
|
-
|
|
12
|
-
declare function useBitForm<T extends object>(): {
|
|
13
|
-
meta: {
|
|
14
|
-
submitError: Error | null;
|
|
15
|
-
lastResponse: unknown;
|
|
16
|
-
isValid: boolean;
|
|
17
|
-
isDirty: boolean;
|
|
18
|
-
isSubmitting: boolean;
|
|
19
|
-
};
|
|
20
|
-
getValues: () => T;
|
|
21
|
-
getErrors: () => BitErrors<T>;
|
|
22
|
-
getTouched: () => BitTouched<T>;
|
|
23
|
-
getDirtyValues: () => Partial<T>;
|
|
24
|
-
submit: (onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>) => (e?: {
|
|
25
|
-
preventDefault: () => void;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: {
|
|
28
|
-
preventDefault: () => void;
|
|
29
|
-
}) => Promise<void>;
|
|
30
|
-
reset: () => void;
|
|
31
|
-
setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
|
|
32
|
-
blurField: <P extends BitPath<T, "">>(path: P) => void;
|
|
33
|
-
setValues: (values: T) => void;
|
|
34
|
-
setError: (path: string, message: string | undefined) => void;
|
|
35
|
-
setErrors: (errors: BitErrors<T>) => void;
|
|
36
|
-
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
37
|
-
validate: (options?: {
|
|
38
|
-
scope?: string;
|
|
39
|
-
scopeFields?: string[];
|
|
40
|
-
}) => Promise<boolean>;
|
|
41
|
-
mutations: {
|
|
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
|
-
};
|
|
49
|
-
};
|
|
11
|
+
declare const useBitStore: <T extends object>() => BitStoreHooksApi<T>;
|
|
50
12
|
|
|
51
13
|
/**
|
|
52
14
|
* Metadata describing the current state of a form field.
|
|
@@ -120,10 +82,10 @@ interface UseBitUploadResult {
|
|
|
120
82
|
* Provides form history undo/redo capabilities.
|
|
121
83
|
*/
|
|
122
84
|
interface UseBitHistoryResult {
|
|
123
|
-
canUndo:
|
|
124
|
-
canRedo:
|
|
125
|
-
historyIndex:
|
|
126
|
-
historySize:
|
|
85
|
+
canUndo: BitHistoryMetadata["canUndo"];
|
|
86
|
+
canRedo: BitHistoryMetadata["canRedo"];
|
|
87
|
+
historyIndex: BitHistoryMetadata["historyIndex"];
|
|
88
|
+
historySize: BitHistoryMetadata["historySize"];
|
|
127
89
|
undo: () => void;
|
|
128
90
|
redo: () => void;
|
|
129
91
|
}
|
|
@@ -131,12 +93,40 @@ interface UseBitPersistResult {
|
|
|
131
93
|
restore: () => Promise<boolean>;
|
|
132
94
|
save: () => Promise<void>;
|
|
133
95
|
clear: () => Promise<void>;
|
|
134
|
-
meta:
|
|
135
|
-
isSaving: boolean;
|
|
136
|
-
isRestoring: boolean;
|
|
137
|
-
error: Error | null;
|
|
138
|
-
};
|
|
96
|
+
meta: BitPersistMetadata;
|
|
139
97
|
}
|
|
98
|
+
interface UseBitFormMeta {
|
|
99
|
+
isValid: boolean;
|
|
100
|
+
isDirty: boolean;
|
|
101
|
+
isSubmitting: boolean;
|
|
102
|
+
submitError: Error | null;
|
|
103
|
+
lastResponse: unknown;
|
|
104
|
+
}
|
|
105
|
+
interface UseBitFormResult<T extends object = any> {
|
|
106
|
+
meta: UseBitFormMeta;
|
|
107
|
+
getValues: () => T;
|
|
108
|
+
getErrors: () => BitErrors<T>;
|
|
109
|
+
getTouched: () => BitTouched<T>;
|
|
110
|
+
getDirtyValues: () => Partial<T>;
|
|
111
|
+
submit: (onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>) => (e?: {
|
|
112
|
+
preventDefault: () => void;
|
|
113
|
+
}) => Promise<void>;
|
|
114
|
+
onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: {
|
|
115
|
+
preventDefault: () => void;
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
reset: () => void;
|
|
118
|
+
setField: <P extends BitPath<T>>(path: P, value: BitPathValue<T, P>) => void;
|
|
119
|
+
blurField: <P extends BitPath<T>>(path: P) => void;
|
|
120
|
+
replaceValues: (values: T) => void;
|
|
121
|
+
hydrate: (values: DeepPartial<T>) => void;
|
|
122
|
+
rebase: (values: T) => void;
|
|
123
|
+
setError: (path: string, message: string | undefined) => void;
|
|
124
|
+
setErrors: (errors: BitErrors<T>) => void;
|
|
125
|
+
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
126
|
+
validate: (options?: BitValidationOptions) => Promise<boolean>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare function useBitForm<T extends object>(): UseBitFormResult<T>;
|
|
140
130
|
|
|
141
131
|
declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
|
|
142
132
|
append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
@@ -171,4 +161,4 @@ declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm
|
|
|
171
161
|
|
|
172
162
|
declare function useBitPersist(): UseBitPersistResult;
|
|
173
163
|
|
|
174
|
-
export { BitFormProvider as B, type
|
|
164
|
+
export { BitFormProvider as B, type UseBitPersistResult as U, useBitForm as a, useBitPersist as b, useBitScope as c, useBitSteps as d, useBitStore as e, useBitWatch as f, type UseBitFieldResult as g, type UseBitHistoryResult as h, type UseBitUploadResult as i, type UseBitFieldBindProps as j, type UseBitFieldMeta as k, type UseBitStepsResult as l, useBitArray as u };
|
|
@@ -1,52 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { b as
|
|
4
|
-
import
|
|
3
|
+
import { f as BitStoreApi, g as BitStoreHooksApi, b as BitHistoryMetadata, c as BitPersistMetadata, h as BitValidationOptions } from './public-types-Bl94ECPb.js';
|
|
4
|
+
import './bus-B1my-s_o.js';
|
|
5
|
+
import { f as BitPath, g as BitPathValue, S as ScopeStatus, n as ValidateScopeResult, i as BitErrors, J as BitTouched, h as DeepPartial, k as BitArrayPath, l as BitArrayItem } from './types-DqeN9Kq_.js';
|
|
5
6
|
|
|
6
7
|
declare const BitFormProvider: ({ store, children, }: {
|
|
7
|
-
store:
|
|
8
|
+
store: BitStoreApi<any>;
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
}) => react_jsx_runtime.JSX.Element;
|
|
10
|
-
declare const useBitStore: <T extends object>() =>
|
|
11
|
-
|
|
12
|
-
declare function useBitForm<T extends object>(): {
|
|
13
|
-
meta: {
|
|
14
|
-
submitError: Error | null;
|
|
15
|
-
lastResponse: unknown;
|
|
16
|
-
isValid: boolean;
|
|
17
|
-
isDirty: boolean;
|
|
18
|
-
isSubmitting: boolean;
|
|
19
|
-
};
|
|
20
|
-
getValues: () => T;
|
|
21
|
-
getErrors: () => BitErrors<T>;
|
|
22
|
-
getTouched: () => BitTouched<T>;
|
|
23
|
-
getDirtyValues: () => Partial<T>;
|
|
24
|
-
submit: (onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>) => (e?: {
|
|
25
|
-
preventDefault: () => void;
|
|
26
|
-
}) => Promise<void>;
|
|
27
|
-
onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: {
|
|
28
|
-
preventDefault: () => void;
|
|
29
|
-
}) => Promise<void>;
|
|
30
|
-
reset: () => void;
|
|
31
|
-
setField: <P extends BitPath<T, "">>(path: P, value: BitPathValue<T, P>) => void;
|
|
32
|
-
blurField: <P extends BitPath<T, "">>(path: P) => void;
|
|
33
|
-
setValues: (values: T) => void;
|
|
34
|
-
setError: (path: string, message: string | undefined) => void;
|
|
35
|
-
setErrors: (errors: BitErrors<T>) => void;
|
|
36
|
-
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
37
|
-
validate: (options?: {
|
|
38
|
-
scope?: string;
|
|
39
|
-
scopeFields?: string[];
|
|
40
|
-
}) => Promise<boolean>;
|
|
41
|
-
mutations: {
|
|
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
|
-
};
|
|
49
|
-
};
|
|
11
|
+
declare const useBitStore: <T extends object>() => BitStoreHooksApi<T>;
|
|
50
12
|
|
|
51
13
|
/**
|
|
52
14
|
* Metadata describing the current state of a form field.
|
|
@@ -120,10 +82,10 @@ interface UseBitUploadResult {
|
|
|
120
82
|
* Provides form history undo/redo capabilities.
|
|
121
83
|
*/
|
|
122
84
|
interface UseBitHistoryResult {
|
|
123
|
-
canUndo:
|
|
124
|
-
canRedo:
|
|
125
|
-
historyIndex:
|
|
126
|
-
historySize:
|
|
85
|
+
canUndo: BitHistoryMetadata["canUndo"];
|
|
86
|
+
canRedo: BitHistoryMetadata["canRedo"];
|
|
87
|
+
historyIndex: BitHistoryMetadata["historyIndex"];
|
|
88
|
+
historySize: BitHistoryMetadata["historySize"];
|
|
127
89
|
undo: () => void;
|
|
128
90
|
redo: () => void;
|
|
129
91
|
}
|
|
@@ -131,12 +93,40 @@ interface UseBitPersistResult {
|
|
|
131
93
|
restore: () => Promise<boolean>;
|
|
132
94
|
save: () => Promise<void>;
|
|
133
95
|
clear: () => Promise<void>;
|
|
134
|
-
meta:
|
|
135
|
-
isSaving: boolean;
|
|
136
|
-
isRestoring: boolean;
|
|
137
|
-
error: Error | null;
|
|
138
|
-
};
|
|
96
|
+
meta: BitPersistMetadata;
|
|
139
97
|
}
|
|
98
|
+
interface UseBitFormMeta {
|
|
99
|
+
isValid: boolean;
|
|
100
|
+
isDirty: boolean;
|
|
101
|
+
isSubmitting: boolean;
|
|
102
|
+
submitError: Error | null;
|
|
103
|
+
lastResponse: unknown;
|
|
104
|
+
}
|
|
105
|
+
interface UseBitFormResult<T extends object = any> {
|
|
106
|
+
meta: UseBitFormMeta;
|
|
107
|
+
getValues: () => T;
|
|
108
|
+
getErrors: () => BitErrors<T>;
|
|
109
|
+
getTouched: () => BitTouched<T>;
|
|
110
|
+
getDirtyValues: () => Partial<T>;
|
|
111
|
+
submit: (onSuccess: (values: T, dirtyValues?: Partial<T>) => void | Promise<void>) => (e?: {
|
|
112
|
+
preventDefault: () => void;
|
|
113
|
+
}) => Promise<void>;
|
|
114
|
+
onSubmit: (handler: (values: T, dirtyValues?: Partial<T>) => Promise<unknown>) => (e?: {
|
|
115
|
+
preventDefault: () => void;
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
reset: () => void;
|
|
118
|
+
setField: <P extends BitPath<T>>(path: P, value: BitPathValue<T, P>) => void;
|
|
119
|
+
blurField: <P extends BitPath<T>>(path: P) => void;
|
|
120
|
+
replaceValues: (values: T) => void;
|
|
121
|
+
hydrate: (values: DeepPartial<T>) => void;
|
|
122
|
+
rebase: (values: T) => void;
|
|
123
|
+
setError: (path: string, message: string | undefined) => void;
|
|
124
|
+
setErrors: (errors: BitErrors<T>) => void;
|
|
125
|
+
setServerErrors: (serverErrors: Record<string, string[] | string>) => void;
|
|
126
|
+
validate: (options?: BitValidationOptions) => Promise<boolean>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare function useBitForm<T extends object>(): UseBitFormResult<T>;
|
|
140
130
|
|
|
141
131
|
declare function useBitArray<TForm extends object = any, P extends BitArrayPath<TForm> = BitArrayPath<TForm>>(path: P): {
|
|
142
132
|
append: (value: BitArrayItem<BitPathValue<TForm, P>>) => void;
|
|
@@ -171,4 +161,4 @@ declare function useBitWatch<TForm extends object = any, P extends BitPath<TForm
|
|
|
171
161
|
|
|
172
162
|
declare function useBitPersist(): UseBitPersistResult;
|
|
173
163
|
|
|
174
|
-
export { BitFormProvider as B, type
|
|
164
|
+
export { BitFormProvider as B, type UseBitPersistResult as U, useBitForm as a, useBitPersist as b, useBitScope as c, useBitSteps as d, useBitStore as e, useBitWatch as f, type UseBitFieldResult as g, type UseBitHistoryResult as h, type UseBitUploadResult as i, type UseBitFieldBindProps as j, type UseBitFieldMeta as k, type UseBitStepsResult as l, useBitArray as u };
|
package/dist/vue/index.cjs
CHANGED
|
@@ -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
|
|
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 _chunkNWPA4F3Bcjs = require('../chunk-NWPA4F3B.cjs');require('../chunk-C4BYXZGB.cjs');var _chunk676WXU4Scjs = require('../chunk-676WXU4S.cjs');var _vue = require('vue');var q=Symbol("BIT_STORE");function Y(e){_vue.provide.call(void 0, q,_chunk676WXU4Scjs.Y.call(void 0, e))}function c(){let e=_vue.inject.call(void 0, q);if(!e)throw new Error("BitForm Vue hooks devem ser usados sob um provideBitStore");return e}function Q(){let e=c(),t=_vue.shallowRef.call(void 0, {isValid:e.getState().isValid,isSubmitting:e.getState().isSubmitting,isDirty:e.getState().isDirty}),i=_vue.ref.call(void 0, null),r=_vue.ref.call(void 0, null),s=e.subscribeSelector(m=>({isValid:m.isValid,isSubmitting:m.isSubmitting,isDirty:m.isDirty}),m=>{t.value=m});_vue.onUnmounted.call(void 0, s);let n=_chunkNWPA4F3Bcjs.a.call(void 0, e,{clearSubmissionState:()=>{i.value=null,r.value=null},setSubmissionResult:m=>{r.value=m},setSubmissionError:m=>{i.value=m}}),d=_vue.computed.call(void 0, ()=>t.value.isValid),u=_vue.computed.call(void 0, ()=>t.value.isSubmitting),f=_vue.computed.call(void 0, ()=>t.value.isDirty),o=n.onSubmit,a=n.reset;return{meta:{isValid:d,isDirty:f,isSubmitting:u,submitError:i,lastResponse:r},getValues:n.getValues,getErrors:n.getErrors,getTouched:n.getTouched,getDirtyValues:n.getDirtyValues,submit:n.submit,onSubmit:o,reset:a,replaceValues:e.replaceValues.bind(e),hydrate:e.hydrate.bind(e),rebase:e.rebase.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)}}function U(e){let t=c(),i=t.resolveMask(e),r=_chunkNWPA4F3Bcjs.c.call(void 0, t,e,i),s=_vue.shallowRef.call(void 0, t.getFieldState(e)),n=_chunkNWPA4F3Bcjs.b.call(void 0, t,e,g=>{s.value=g});_vue.onUnmounted.call(void 0, ()=>{n(),t.unregisterField&&t.unregisterField(e)});let d=_vue.computed.call(void 0, ()=>s.value.value),u=_vue.computed.call(void 0, ()=>r.displayValue(d.value)),f=_vue.computed.call(void 0, {get:()=>u.value,set:g=>{r.setValue(g)}}),o=_vue.computed.call(void 0, ()=>s.value.error),a=_vue.computed.call(void 0, ()=>s.value.touched?s.value.error:void 0),l=_vue.computed.call(void 0, ()=>s.value.touched),m=_vue.computed.call(void 0, ()=>!!(l.value&&a.value)),b=_vue.computed.call(void 0, ()=>s.value.isValidating),P=_vue.computed.call(void 0, ()=>s.value.isDirty),E=_vue.computed.call(void 0, ()=>s.value.isHidden),T=_vue.computed.call(void 0, ()=>s.value.isRequired),x=_vue.computed.call(void 0, ()=>!!o.value),p=g=>{r.setValue(g)},y=()=>r.setBlur();return{value:d,displayValue:u,modelValue:f,setValue:p,setBlur:y,onInput:g=>{p(g)},onBlur:()=>{y()},meta:{error:a,touched:l,invalid:m,isValidating:b,isDirty:P,isHidden:E,isRequired:T,hasError:x}}}var S=()=>Math.random().toString(36).substring(2,9);function ee(e){let t=c(),r=(()=>{let o=_chunk676WXU4Scjs.f.call(void 0, t.getState().values,e);return Array.isArray(o)?o:[]})(),s=_vue.ref.call(void 0, r),n=_vue.ref.call(void 0, r.map(S)),d=t.subscribePath(e,o=>{let a=Array.isArray(o)?o:[];if(s.value=[...a],a.length!==n.value.length){let l=[...n.value];if(a.length>l.length){let m=a.length-l.length,b=Array.from({length:m},S);n.value=[...l,...b]}else n.value=l.slice(0,a.length)}});_vue.onUnmounted.call(void 0, ()=>{d(),t.unregisterPrefix&&t.unregisterPrefix(`${e}.`)});let u=_vue.computed.call(void 0, ()=>s.value.map((o,a)=>({key:n.value[a]||`temp-${a}`,value:o,index:a}))),f=_vue.computed.call(void 0, ()=>s.value.length);return{fields:u,length:f,append:o=>{n.value.push(S()),t.pushItem(e,o)},prepend:o=>{n.value.unshift(S()),t.prependItem(e,o)},insert:(o,a)=>{n.value.splice(o,0,S()),t.insertItem(e,o,a)},remove:o=>{n.value.splice(o,1),t.removeItem(e,o)},move:(o,a)=>{let l=[...n.value],[m]=l.splice(o,1);l.splice(a,0,m),n.value=l,t.moveItem(e,o,a)},swap:(o,a)=>{let l=[...n.value];[l[o],l[a]]=[l[a],l[o]],n.value=l,t.swapItems(e,o,a)},replace:o=>{n.value=o.map(S),t.setField(e,o)},clear:()=>{n.value=[],t.setField(e,[])}}}function se(){let e=c(),t=_vue.shallowRef.call(void 0, e.getHistoryMetadata()),i=e.subscribe(()=>{t.value=e.getHistoryMetadata()});_vue.onUnmounted.call(void 0, i);let r=()=>e.undo(),s=()=>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:r,redo:s}}function ae(e,t){let i=Object.keys(e),r=Object.keys(t);return i.length!==r.length?!1:i.every(s=>e[s]===t[s])}function ue(e){let t=c(),i=_vue.ref.call(void 0, t.getStepStatus(e)),r;_vue.onMounted.call(void 0, ()=>{r=t.subscribe(()=>{let o=t.getStepStatus(e);(o.hasErrors!==i.value.hasErrors||o.isDirty!==i.value.isDirty||!ae(o.errors,i.value.errors))&&(i.value=o)})}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([r, 'optionalCall', _2 => _2()])});let s=async()=>{let o=await t.validate({scope:e}),a=t.getStepErrors(e);return{valid:o,errors:a}},n=()=>t.getStepErrors(e),d=_vue.computed.call(void 0, ()=>!i.value.hasErrors),u=_vue.computed.call(void 0, ()=>i.value.isDirty),f=_vue.computed.call(void 0, ()=>i.value.errors);return{scopeName:e,status:i,errors:f,validate:s,getErrors:n,isValid:d,isDirty:u}}function de(e,t){let i=Object.keys(e),r=Object.keys(t);return i.length!==r.length?!1:i.every(s=>e[s]===t[s])}function pe(e){let t=c(),i=_vue.ref.call(void 0, 0),r=_vue.computed.call(void 0, ()=>_nullishCoalesce(e[i.value], () => (""))),s=_vue.ref.call(void 0, t.getStepStatus(r.value)),n;_vue.watch.call(void 0, r,p=>{s.value=t.getStepStatus(p)});let d=()=>{let p=r.value,y=t.getStepStatus(p);(y.hasErrors!==s.value.hasErrors||y.isDirty!==s.value.isDirty||!de(y.errors,s.value.errors))&&(s.value=y)};_vue.onMounted.call(void 0, ()=>{n=t.subscribe(d)}),_vue.onUnmounted.call(void 0, ()=>{_optionalChain([n, 'optionalCall', _3 => _3()])});let u=async()=>{let p=r.value,y=await t.validate({scope:p}),h=t.getStepErrors(p);return{valid:y,errors:h}},f=()=>t.getStepErrors(r.value),o=async()=>{let p=r.value,y=t.getScopeFields(p);if(t.hasValidationsInProgress(y))return!1;let h=await t.validate({scope:p});if(h)i.value=Math.min(i.value+1,e.length-1);else{let D=t.getStepErrors(p),g=Object.keys(D);g.length>0&&t.markFieldsTouched(g)}return h},a=()=>{i.value=Math.max(i.value-1,0)},l=p=>{i.value=Math.max(0,Math.min(p-1,e.length-1))},m=_vue.computed.call(void 0, ()=>i.value+1),b=_vue.computed.call(void 0, ()=>i.value===0),P=_vue.computed.call(void 0, ()=>i.value>=e.length-1),E=_vue.computed.call(void 0, ()=>!s.value.hasErrors),T=_vue.computed.call(void 0, ()=>s.value.isDirty),x=_vue.computed.call(void 0, ()=>s.value.errors);return{step:m,stepIndex:i,scope:r,next:o,prev:a,goTo:l,isFirst:b,isLast:P,status:s,errors:x,isValid:E,isDirty:T,validate:u,getErrors:f}}function ge(e){let t=c(),i=_chunk676WXU4Scjs.f.call(void 0, t.getState().values,e),r=_vue.ref.call(void 0, i),s=t.watch(e,n=>{_chunk676WXU4Scjs.e.call(void 0, r.value,n)||(r.value=n)});return _vue.onUnmounted.call(void 0, s),_vue.readonly.call(void 0, r)}function Se(e,t,i){let r=c(),s=U(e),n=null,d=_vue.ref.call(void 0, !1),u=async o=>{if(o){d.value=!0,r.setError(e,void 0);try{let a=await t(o);s.setValue(a.url),n=a.key,r.setError(e,void 0)}catch(a){let l=a instanceof Error?a.message:"Upload failed";r.setError(e,l)}finally{d.value=!1}}},f=async()=>{if(n&&i)try{await i(n)}catch(o){let a=o instanceof Error?o.message:"Delete failed";r.setError(e,a);return}s.setValue(null),n=null,r.setError(e,void 0)};return{value:s.value,setValue:s.setValue,error:_vue.computed.call(void 0, ()=>s.meta.error.value),isValidating:_vue.computed.call(void 0, ()=>!!s.meta.isValidating.value||d.value),upload:u,remove:f}}function be(){let e=c(),t=_vue.ref.call(void 0, !1),i=_vue.ref.call(void 0, !1),r=_vue.ref.call(void 0, null);return{restore:async()=>{i.value=!0,r.value=null;try{return await e.restorePersisted()}catch(u){return r.value=u instanceof Error?u:new Error(String(u)),!1}finally{i.value=!1}},save:async()=>{t.value=!0,r.value=null;try{await e.forceSave()}catch(u){r.value=u instanceof Error?u:new Error(String(u))}finally{t.value=!1}},clear:async()=>{r.value=null;try{await e.clearPersisted()}catch(u){r.value=u instanceof Error?u:new Error(String(u))}},meta:{isSaving:_vue.readonly.call(void 0, t),isRestoring:_vue.readonly.call(void 0, i),error:_vue.readonly.call(void 0, r)}}}exports.provideBitStore = Y; exports.useBitArray = ee; exports.useBitField = U; exports.useBitForm = Q; exports.useBitHistory = se; exports.useBitPersist = be; exports.useBitScope = ue; exports.useBitSteps = pe; exports.useBitStore = c; exports.useBitUpload = Se; exports.useBitWatch = ge;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|