@lehnihon/bit-form 1.0.6 → 1.0.8
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/README.md +42 -1
- package/dist/angular/index.cjs +1 -1
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.d.cts +44 -41
- package/dist/angular/index.d.ts +44 -41
- package/dist/angular/index.js +1 -1
- package/dist/angular/index.js.map +1 -1
- package/dist/{bus-DAwKIiMY.d.cts → bus-BtKUu_9m.d.cts} +42 -7
- package/dist/{bus-DAwKIiMY.d.ts → bus-BtKUu_9m.d.ts} +42 -7
- package/dist/chunk-4SZ2BOTW.js +2 -0
- package/dist/chunk-4SZ2BOTW.js.map +1 -0
- package/dist/chunk-IUDMKNON.cjs +2 -0
- package/dist/chunk-IUDMKNON.cjs.map +1 -0
- package/dist/chunk-MVDS4KAD.js +133 -0
- package/dist/chunk-MVDS4KAD.js.map +1 -0
- package/dist/chunk-QB7MQ6ZB.cjs +133 -0
- package/dist/{chunk-6VDQSKUN.cjs.map → chunk-QB7MQ6ZB.cjs.map} +1 -1
- package/dist/cli/index.cjs +404 -4
- package/dist/devtools/bridge.cjs +1 -1
- package/dist/devtools/bridge.js +1 -1
- package/dist/devtools/index.cjs +1 -1
- package/dist/devtools/index.js +1 -1
- package/dist/{index-BD_l3aH5.d.cts → index-C4HaSh5W.d.ts} +102 -15
- package/dist/{index-CPKnWBVv.d.ts → index-CH9ZdEkZ.d.cts} +102 -15
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +23 -22
- package/dist/react/index.d.ts +23 -22
- 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 +24 -14
- package/dist/react-native/index.d.ts +24 -14
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/resolvers/joi.d.cts +1 -1
- package/dist/resolvers/joi.d.ts +1 -1
- package/dist/resolvers/yup.d.cts +1 -1
- package/dist/resolvers/yup.d.ts +1 -1
- package/dist/resolvers/zod.d.cts +1 -1
- package/dist/resolvers/zod.d.ts +1 -1
- package/dist/{use-bit-watch-CoCFwS-F.d.ts → use-bit-watch-Bdwj9l_g.d.ts} +32 -27
- package/dist/{use-bit-watch-BSWy9rG7.d.cts → use-bit-watch-ClvBxm6Z.d.cts} +32 -27
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +48 -42
- package/dist/vue/index.d.ts +48 -42
- package/dist/vue/index.js +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6VDQSKUN.cjs +0 -133
- package/dist/chunk-KA4FAGIX.js +0 -133
- package/dist/chunk-KA4FAGIX.js.map +0 -1
- package/dist/chunk-UFYHEI6S.js +0 -2
- package/dist/chunk-UFYHEI6S.js.map +0 -1
- package/dist/chunk-Z6ITPS2B.cjs +0 -2
- package/dist/chunk-Z6ITPS2B.cjs.map +0 -1
package/dist/devtools/bridge.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQB7MQ6ZBcjs = require('../chunk-QB7MQ6ZB.cjs');exports.setupRemoteBridge = _chunkQB7MQ6ZBcjs.T;
|
|
2
2
|
//# sourceMappingURL=bridge.cjs.map
|
package/dist/devtools/bridge.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{T as a}from"../chunk-
|
|
1
|
+
import{T as a}from"../chunk-MVDS4KAD.js";export{a as setupRemoteBridge};
|
|
2
2
|
//# sourceMappingURL=bridge.js.map
|
package/dist/devtools/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQB7MQ6ZBcjs = require('../chunk-QB7MQ6ZB.cjs');exports.initDevTools = _chunkQB7MQ6ZBcjs.U;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/devtools/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{U as a}from"../chunk-
|
|
1
|
+
import{U as a}from"../chunk-MVDS4KAD.js";export{a as initDevTools};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as BitStoreAdapter, t as BitResolvedConfig, u as BitLifecycleAdapter,
|
|
1
|
+
import { s as BitStoreAdapter, t as BitResolvedConfig, u as BitLifecycleAdapter, m as BitState, v as BitDependencyManager, e as BitErrors, w as BitValidationAdapter, x as BitValidationManager, y as BitDirtyManager, z as BitHistoryManager, d as BitConfig, g as BitFieldDefinition, k as BitPath, l as BitPathValue, B as BitMask, b as BitArrayPath, a as BitArrayItem } from './bus-BtKUu_9m.js';
|
|
2
2
|
|
|
3
3
|
declare class BitArrayManager<T extends object = any> {
|
|
4
4
|
private store;
|
|
@@ -37,32 +37,126 @@ declare class BitDevtoolsManager<T extends object> {
|
|
|
37
37
|
destroy(): void;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* BitScopeManager
|
|
42
|
+
*
|
|
43
|
+
* Manages multi-step forms and scope-based validation.
|
|
44
|
+
* Scopes are groups of fields that can be validated and tracked independently,
|
|
45
|
+
* useful for wizard-style forms or multi-section forms.
|
|
46
|
+
*/
|
|
47
|
+
declare class BitScopeManager<T extends object = any> {
|
|
48
|
+
private getState;
|
|
49
|
+
private getConfig;
|
|
50
|
+
constructor(getState: () => BitState<T>, getConfig: () => BitResolvedConfig<T>);
|
|
51
|
+
/**
|
|
52
|
+
* Get validation status of a scope (step).
|
|
53
|
+
* Returns whether the scope has errors, is dirty, and the error details.
|
|
54
|
+
*/
|
|
55
|
+
getStepStatus(scopeName: string): {
|
|
56
|
+
hasErrors: boolean;
|
|
57
|
+
isDirty: boolean;
|
|
58
|
+
errors: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Get all errors for fields in a specific scope.
|
|
62
|
+
*/
|
|
63
|
+
getStepErrors(scopeName: string): Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* BitFieldQueryManager
|
|
68
|
+
*
|
|
69
|
+
* Provides query methods for field state without mutating.
|
|
70
|
+
* All methods are read-only and delegate to appropriate managers.
|
|
71
|
+
*/
|
|
72
|
+
declare class BitFieldQueryManager<T extends object = any> {
|
|
73
|
+
private depsMg;
|
|
74
|
+
private getState;
|
|
75
|
+
private getConfig;
|
|
76
|
+
constructor(depsMg: BitDependencyManager<T>, getState: () => BitState<T>, getConfig: () => BitResolvedConfig<T>);
|
|
77
|
+
/**
|
|
78
|
+
* Check if a field is hidden based on conditional logic.
|
|
79
|
+
*/
|
|
80
|
+
isHidden<P extends string>(path: P): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Check if a field is required based on conditional logic.
|
|
83
|
+
*/
|
|
84
|
+
isRequired<P extends string>(path: P): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a field has been modified from its initial value.
|
|
87
|
+
*/
|
|
88
|
+
isFieldDirty(path: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a field is currently validating (async validation in progress).
|
|
91
|
+
*/
|
|
92
|
+
isFieldValidating(path: string): boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* BitErrorManager
|
|
97
|
+
*
|
|
98
|
+
* Manages error state for fields.
|
|
99
|
+
* Handles setting individual errors, batch errors, and server errors.
|
|
100
|
+
*/
|
|
101
|
+
declare class BitErrorManager<T extends object = any> {
|
|
102
|
+
private getState;
|
|
103
|
+
private internalUpdateState;
|
|
104
|
+
constructor(getState: () => BitState<T>, internalUpdateState: (partial: Partial<BitState<T>>) => void);
|
|
105
|
+
/**
|
|
106
|
+
* Set or clear error for a single field.
|
|
107
|
+
* Pass undefined to clear the error.
|
|
108
|
+
*/
|
|
109
|
+
setError(path: string, message: string | undefined): void;
|
|
110
|
+
/**
|
|
111
|
+
* Set multiple field errors at once (merge behavior).
|
|
112
|
+
*/
|
|
113
|
+
setErrors(errors: BitErrors<T>): void;
|
|
114
|
+
/**
|
|
115
|
+
* Set errors from server response (converts arrays to first element).
|
|
116
|
+
* Useful for handling 422 validation error responses.
|
|
117
|
+
*/
|
|
118
|
+
setServerErrors(serverErrors: Record<string, string[] | string>): void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* BitStore
|
|
123
|
+
*
|
|
124
|
+
* The core orchestrator of form state management.
|
|
125
|
+
*
|
|
126
|
+
* This store coordinates multiple managers to provide comprehensive form handling:
|
|
127
|
+
* - Core managers handle essential state and validation
|
|
128
|
+
* - Feature managers provide optional enhancements (history, arrays, scopes)
|
|
129
|
+
* - Query/mutation managers organize domain-specific operations
|
|
130
|
+
*/
|
|
40
131
|
declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, BitValidationAdapter<T>, BitLifecycleAdapter<T> {
|
|
41
132
|
private state;
|
|
42
133
|
private listeners;
|
|
43
134
|
config: BitResolvedConfig<T>;
|
|
135
|
+
storeId: string;
|
|
44
136
|
depsMg: BitDependencyManager<T>;
|
|
45
|
-
historyMg: BitHistoryManager<T>;
|
|
46
137
|
validatorMg: BitValidationManager<T>;
|
|
47
138
|
computedMg: BitComputedManager<T>;
|
|
139
|
+
dirtyMg: BitDirtyManager<T>;
|
|
48
140
|
lifecycleMg: BitLifecycleManager<T>;
|
|
141
|
+
historyMg: BitHistoryManager<T>;
|
|
49
142
|
arraysMg: BitArrayManager<T>;
|
|
143
|
+
scopeMg: BitScopeManager<T>;
|
|
50
144
|
devtoolsMg: BitDevtoolsManager<T>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** Paths from config.fields — never unregistered when components unmount */
|
|
54
|
-
private configFields;
|
|
145
|
+
queryMg: BitFieldQueryManager<T>;
|
|
146
|
+
errorMg: BitErrorManager<T>;
|
|
55
147
|
constructor(config?: BitConfig<T>);
|
|
56
148
|
getConfig(): BitResolvedConfig<T>;
|
|
57
149
|
getState(): BitState<T>;
|
|
58
150
|
get isValid(): boolean;
|
|
59
151
|
get isSubmitting(): boolean;
|
|
60
152
|
get isDirty(): boolean;
|
|
153
|
+
registerField(path: string, config: BitFieldDefinition<T>): void;
|
|
61
154
|
unregisterField<P extends BitPath<T>>(path: P): void;
|
|
62
155
|
unregisterPrefix(prefix: string): void;
|
|
63
|
-
registerField(path: string, config: BitFieldDefinition<T>): void;
|
|
64
156
|
isHidden<P extends BitPath<T>>(path: P): boolean;
|
|
65
157
|
isRequired<P extends BitPath<T>>(path: P): boolean;
|
|
158
|
+
isFieldDirty(path: string): boolean;
|
|
159
|
+
isFieldValidating(path: string): boolean;
|
|
66
160
|
subscribe(listener: () => void): () => void;
|
|
67
161
|
watch<P extends BitPath<T>>(path: P, callback: (value: BitPathValue<T, P>) => void): () => void;
|
|
68
162
|
setField<P extends BitPath<T>>(path: P, value: BitPathValue<T, P>): void;
|
|
@@ -73,6 +167,7 @@ declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, Bi
|
|
|
73
167
|
setErrors(errors: BitErrors<T>): void;
|
|
74
168
|
setServerErrors(serverErrors: Record<string, string[] | string>): void;
|
|
75
169
|
reset(): void;
|
|
170
|
+
submit(onSuccess: (values: T) => void | Promise<void>): Promise<void>;
|
|
76
171
|
registerMask(name: string, mask: BitMask): void;
|
|
77
172
|
pushItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
|
|
78
173
|
prependItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
|
|
@@ -94,16 +189,8 @@ declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, Bi
|
|
|
94
189
|
errors: Record<string, string>;
|
|
95
190
|
};
|
|
96
191
|
getStepErrors(scopeName: string): Record<string, string>;
|
|
97
|
-
isFieldDirty(path: string): boolean;
|
|
98
|
-
isFieldValidating(path: string): boolean;
|
|
99
|
-
submit(onSuccess: (values: T) => void | Promise<void>): Promise<void>;
|
|
100
192
|
internalUpdateState(partialState: Partial<BitState<T>>): void;
|
|
101
193
|
internalSaveSnapshot(): void;
|
|
102
|
-
/** Updates dirtyPaths for a single path change. Returns new isDirty. */
|
|
103
|
-
updateDirtyForPath(path: string, values: T, initialValues: T): boolean;
|
|
104
|
-
clearDirtyPaths(): void;
|
|
105
|
-
/** Rebuilds dirtyPaths from full values (used for undo/redo/updateAll). */
|
|
106
|
-
rebuildDirtyPaths(values: T, initialValues: T): boolean;
|
|
107
194
|
cleanup(): void;
|
|
108
195
|
private notify;
|
|
109
196
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as BitStoreAdapter, t as BitResolvedConfig, u as BitLifecycleAdapter,
|
|
1
|
+
import { s as BitStoreAdapter, t as BitResolvedConfig, u as BitLifecycleAdapter, m as BitState, v as BitDependencyManager, e as BitErrors, w as BitValidationAdapter, x as BitValidationManager, y as BitDirtyManager, z as BitHistoryManager, d as BitConfig, g as BitFieldDefinition, k as BitPath, l as BitPathValue, B as BitMask, b as BitArrayPath, a as BitArrayItem } from './bus-BtKUu_9m.cjs';
|
|
2
2
|
|
|
3
3
|
declare class BitArrayManager<T extends object = any> {
|
|
4
4
|
private store;
|
|
@@ -37,32 +37,126 @@ declare class BitDevtoolsManager<T extends object> {
|
|
|
37
37
|
destroy(): void;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* BitScopeManager
|
|
42
|
+
*
|
|
43
|
+
* Manages multi-step forms and scope-based validation.
|
|
44
|
+
* Scopes are groups of fields that can be validated and tracked independently,
|
|
45
|
+
* useful for wizard-style forms or multi-section forms.
|
|
46
|
+
*/
|
|
47
|
+
declare class BitScopeManager<T extends object = any> {
|
|
48
|
+
private getState;
|
|
49
|
+
private getConfig;
|
|
50
|
+
constructor(getState: () => BitState<T>, getConfig: () => BitResolvedConfig<T>);
|
|
51
|
+
/**
|
|
52
|
+
* Get validation status of a scope (step).
|
|
53
|
+
* Returns whether the scope has errors, is dirty, and the error details.
|
|
54
|
+
*/
|
|
55
|
+
getStepStatus(scopeName: string): {
|
|
56
|
+
hasErrors: boolean;
|
|
57
|
+
isDirty: boolean;
|
|
58
|
+
errors: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Get all errors for fields in a specific scope.
|
|
62
|
+
*/
|
|
63
|
+
getStepErrors(scopeName: string): Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* BitFieldQueryManager
|
|
68
|
+
*
|
|
69
|
+
* Provides query methods for field state without mutating.
|
|
70
|
+
* All methods are read-only and delegate to appropriate managers.
|
|
71
|
+
*/
|
|
72
|
+
declare class BitFieldQueryManager<T extends object = any> {
|
|
73
|
+
private depsMg;
|
|
74
|
+
private getState;
|
|
75
|
+
private getConfig;
|
|
76
|
+
constructor(depsMg: BitDependencyManager<T>, getState: () => BitState<T>, getConfig: () => BitResolvedConfig<T>);
|
|
77
|
+
/**
|
|
78
|
+
* Check if a field is hidden based on conditional logic.
|
|
79
|
+
*/
|
|
80
|
+
isHidden<P extends string>(path: P): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Check if a field is required based on conditional logic.
|
|
83
|
+
*/
|
|
84
|
+
isRequired<P extends string>(path: P): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a field has been modified from its initial value.
|
|
87
|
+
*/
|
|
88
|
+
isFieldDirty(path: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a field is currently validating (async validation in progress).
|
|
91
|
+
*/
|
|
92
|
+
isFieldValidating(path: string): boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* BitErrorManager
|
|
97
|
+
*
|
|
98
|
+
* Manages error state for fields.
|
|
99
|
+
* Handles setting individual errors, batch errors, and server errors.
|
|
100
|
+
*/
|
|
101
|
+
declare class BitErrorManager<T extends object = any> {
|
|
102
|
+
private getState;
|
|
103
|
+
private internalUpdateState;
|
|
104
|
+
constructor(getState: () => BitState<T>, internalUpdateState: (partial: Partial<BitState<T>>) => void);
|
|
105
|
+
/**
|
|
106
|
+
* Set or clear error for a single field.
|
|
107
|
+
* Pass undefined to clear the error.
|
|
108
|
+
*/
|
|
109
|
+
setError(path: string, message: string | undefined): void;
|
|
110
|
+
/**
|
|
111
|
+
* Set multiple field errors at once (merge behavior).
|
|
112
|
+
*/
|
|
113
|
+
setErrors(errors: BitErrors<T>): void;
|
|
114
|
+
/**
|
|
115
|
+
* Set errors from server response (converts arrays to first element).
|
|
116
|
+
* Useful for handling 422 validation error responses.
|
|
117
|
+
*/
|
|
118
|
+
setServerErrors(serverErrors: Record<string, string[] | string>): void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* BitStore
|
|
123
|
+
*
|
|
124
|
+
* The core orchestrator of form state management.
|
|
125
|
+
*
|
|
126
|
+
* This store coordinates multiple managers to provide comprehensive form handling:
|
|
127
|
+
* - Core managers handle essential state and validation
|
|
128
|
+
* - Feature managers provide optional enhancements (history, arrays, scopes)
|
|
129
|
+
* - Query/mutation managers organize domain-specific operations
|
|
130
|
+
*/
|
|
40
131
|
declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, BitValidationAdapter<T>, BitLifecycleAdapter<T> {
|
|
41
132
|
private state;
|
|
42
133
|
private listeners;
|
|
43
134
|
config: BitResolvedConfig<T>;
|
|
135
|
+
storeId: string;
|
|
44
136
|
depsMg: BitDependencyManager<T>;
|
|
45
|
-
historyMg: BitHistoryManager<T>;
|
|
46
137
|
validatorMg: BitValidationManager<T>;
|
|
47
138
|
computedMg: BitComputedManager<T>;
|
|
139
|
+
dirtyMg: BitDirtyManager<T>;
|
|
48
140
|
lifecycleMg: BitLifecycleManager<T>;
|
|
141
|
+
historyMg: BitHistoryManager<T>;
|
|
49
142
|
arraysMg: BitArrayManager<T>;
|
|
143
|
+
scopeMg: BitScopeManager<T>;
|
|
50
144
|
devtoolsMg: BitDevtoolsManager<T>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** Paths from config.fields — never unregistered when components unmount */
|
|
54
|
-
private configFields;
|
|
145
|
+
queryMg: BitFieldQueryManager<T>;
|
|
146
|
+
errorMg: BitErrorManager<T>;
|
|
55
147
|
constructor(config?: BitConfig<T>);
|
|
56
148
|
getConfig(): BitResolvedConfig<T>;
|
|
57
149
|
getState(): BitState<T>;
|
|
58
150
|
get isValid(): boolean;
|
|
59
151
|
get isSubmitting(): boolean;
|
|
60
152
|
get isDirty(): boolean;
|
|
153
|
+
registerField(path: string, config: BitFieldDefinition<T>): void;
|
|
61
154
|
unregisterField<P extends BitPath<T>>(path: P): void;
|
|
62
155
|
unregisterPrefix(prefix: string): void;
|
|
63
|
-
registerField(path: string, config: BitFieldDefinition<T>): void;
|
|
64
156
|
isHidden<P extends BitPath<T>>(path: P): boolean;
|
|
65
157
|
isRequired<P extends BitPath<T>>(path: P): boolean;
|
|
158
|
+
isFieldDirty(path: string): boolean;
|
|
159
|
+
isFieldValidating(path: string): boolean;
|
|
66
160
|
subscribe(listener: () => void): () => void;
|
|
67
161
|
watch<P extends BitPath<T>>(path: P, callback: (value: BitPathValue<T, P>) => void): () => void;
|
|
68
162
|
setField<P extends BitPath<T>>(path: P, value: BitPathValue<T, P>): void;
|
|
@@ -73,6 +167,7 @@ declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, Bi
|
|
|
73
167
|
setErrors(errors: BitErrors<T>): void;
|
|
74
168
|
setServerErrors(serverErrors: Record<string, string[] | string>): void;
|
|
75
169
|
reset(): void;
|
|
170
|
+
submit(onSuccess: (values: T) => void | Promise<void>): Promise<void>;
|
|
76
171
|
registerMask(name: string, mask: BitMask): void;
|
|
77
172
|
pushItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
|
|
78
173
|
prependItem<P extends BitArrayPath<T>>(path: P, value: BitArrayItem<BitPathValue<T, P>>): void;
|
|
@@ -94,16 +189,8 @@ declare class BitStore<T extends object = any> implements BitStoreAdapter<T>, Bi
|
|
|
94
189
|
errors: Record<string, string>;
|
|
95
190
|
};
|
|
96
191
|
getStepErrors(scopeName: string): Record<string, string>;
|
|
97
|
-
isFieldDirty(path: string): boolean;
|
|
98
|
-
isFieldValidating(path: string): boolean;
|
|
99
|
-
submit(onSuccess: (values: T) => void | Promise<void>): Promise<void>;
|
|
100
192
|
internalUpdateState(partialState: Partial<BitState<T>>): void;
|
|
101
193
|
internalSaveSnapshot(): void;
|
|
102
|
-
/** Updates dirtyPaths for a single path change. Returns new isDirty. */
|
|
103
|
-
updateDirtyForPath(path: string, values: T, initialValues: T): boolean;
|
|
104
|
-
clearDirtyPaths(): void;
|
|
105
|
-
/** Rebuilds dirtyPaths from full values (used for undo/redo/updateAll). */
|
|
106
|
-
rebuildDirtyPaths(values: T, initialValues: T): boolean;
|
|
107
194
|
cleanup(): void;
|
|
108
195
|
private notify;
|
|
109
196
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQB7MQ6ZBcjs = require('./chunk-QB7MQ6ZB.cjs');exports.BitStore = _chunkQB7MQ6ZBcjs.V; exports.bitBus = _chunkQB7MQ6ZBcjs.a; exports.bitMasks = _chunkQB7MQ6ZBcjs.S; exports.cleanPrefixedKeys = _chunkQB7MQ6ZBcjs.g; exports.createCreditCardMask = _chunkQB7MQ6ZBcjs.n; exports.createCurrencyMask = _chunkQB7MQ6ZBcjs.m; exports.createDateMask = _chunkQB7MQ6ZBcjs.o; exports.createPatternMask = _chunkQB7MQ6ZBcjs.l; exports.deepClone = _chunkQB7MQ6ZBcjs.b; exports.deepEqual = _chunkQB7MQ6ZBcjs.d; exports.extractServerErrors = _chunkQB7MQ6ZBcjs.i; exports.getDeepValue = _chunkQB7MQ6ZBcjs.e; exports.isValidationErrorShape = _chunkQB7MQ6ZBcjs.h; exports.maskBRL = _chunkQB7MQ6ZBcjs.p; exports.maskCEP = _chunkQB7MQ6ZBcjs.B; exports.maskCNH = _chunkQB7MQ6ZBcjs.E; exports.maskCNPJ = _chunkQB7MQ6ZBcjs.y; exports.maskCPF = _chunkQB7MQ6ZBcjs.x; exports.maskCVV = _chunkQB7MQ6ZBcjs.L; exports.maskColorHex = _chunkQB7MQ6ZBcjs.O; exports.maskCreditCard = _chunkQB7MQ6ZBcjs.K; exports.maskDate = _chunkQB7MQ6ZBcjs.C; exports.maskDateISO = _chunkQB7MQ6ZBcjs.M; exports.maskDateUS = _chunkQB7MQ6ZBcjs.I; exports.maskDecimal = _chunkQB7MQ6ZBcjs.v; exports.maskEUR = _chunkQB7MQ6ZBcjs.r; exports.maskGBP = _chunkQB7MQ6ZBcjs.s; exports.maskIBAN = _chunkQB7MQ6ZBcjs.R; exports.maskIPv4 = _chunkQB7MQ6ZBcjs.P; exports.maskIPv6 = _chunkQB7MQ6ZBcjs.Q; exports.maskInteger = _chunkQB7MQ6ZBcjs.w; exports.maskJPY = _chunkQB7MQ6ZBcjs.t; exports.maskLandline = _chunkQB7MQ6ZBcjs.A; exports.maskMacAddress = _chunkQB7MQ6ZBcjs.N; exports.maskPercent = _chunkQB7MQ6ZBcjs.u; exports.maskPhone = _chunkQB7MQ6ZBcjs.z; exports.maskRG = _chunkQB7MQ6ZBcjs.F; exports.maskSSN = _chunkQB7MQ6ZBcjs.J; exports.maskTime = _chunkQB7MQ6ZBcjs.D; exports.maskUSD = _chunkQB7MQ6ZBcjs.q; exports.maskUSPhone = _chunkQB7MQ6ZBcjs.G; exports.maskZipCode = _chunkQB7MQ6ZBcjs.H; exports.setDeepValue = _chunkQB7MQ6ZBcjs.f; exports.unmask = _chunkQB7MQ6ZBcjs.j; exports.unmaskCurrency = _chunkQB7MQ6ZBcjs.k; exports.valueEqual = _chunkQB7MQ6ZBcjs.c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { B as BitStore } from './index-
|
|
2
|
-
import { P as PatternMaskOptions, B as BitMask, C as CurrencyMaskConfig, D as DateMaskConfig } from './bus-
|
|
3
|
-
export { a as BitArrayItem, b as BitArrayPath, c as BitComputedFn, d as BitConfig, e as BitErrors, f as BitFieldConditional, g as BitFieldDefinition, h as BitFieldOptions, i as BitFieldValidation, j as BitHistoryConfig, k as BitPath, l as BitPathValue, m as BitState, n as BitTouched, o as BitTransformFn, p as BitValidationConfig, S as ScopeStatus, V as ValidateScopeResult, q as ValidatorFn, r as bitBus } from './bus-
|
|
1
|
+
export { B as BitStore } from './index-CH9ZdEkZ.cjs';
|
|
2
|
+
import { P as PatternMaskOptions, B as BitMask, C as CurrencyMaskConfig, D as DateMaskConfig } from './bus-BtKUu_9m.cjs';
|
|
3
|
+
export { a as BitArrayItem, b as BitArrayPath, c as BitComputedFn, d as BitConfig, e as BitErrors, f as BitFieldConditional, g as BitFieldDefinition, h as BitFieldOptions, i as BitFieldValidation, j as BitHistoryConfig, k as BitPath, l as BitPathValue, m as BitState, n as BitTouched, o as BitTransformFn, p as BitValidationConfig, S as ScopeStatus, V as ValidateScopeResult, q as ValidatorFn, r as bitBus } from './bus-BtKUu_9m.cjs';
|
|
4
4
|
|
|
5
5
|
declare function deepClone<T>(obj: T): T;
|
|
6
6
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { B as BitStore } from './index-
|
|
2
|
-
import { P as PatternMaskOptions, B as BitMask, C as CurrencyMaskConfig, D as DateMaskConfig } from './bus-
|
|
3
|
-
export { a as BitArrayItem, b as BitArrayPath, c as BitComputedFn, d as BitConfig, e as BitErrors, f as BitFieldConditional, g as BitFieldDefinition, h as BitFieldOptions, i as BitFieldValidation, j as BitHistoryConfig, k as BitPath, l as BitPathValue, m as BitState, n as BitTouched, o as BitTransformFn, p as BitValidationConfig, S as ScopeStatus, V as ValidateScopeResult, q as ValidatorFn, r as bitBus } from './bus-
|
|
1
|
+
export { B as BitStore } from './index-C4HaSh5W.js';
|
|
2
|
+
import { P as PatternMaskOptions, B as BitMask, C as CurrencyMaskConfig, D as DateMaskConfig } from './bus-BtKUu_9m.js';
|
|
3
|
+
export { a as BitArrayItem, b as BitArrayPath, c as BitComputedFn, d as BitConfig, e as BitErrors, f as BitFieldConditional, g as BitFieldDefinition, h as BitFieldOptions, i as BitFieldValidation, j as BitHistoryConfig, k as BitPath, l as BitPathValue, m as BitState, n as BitTouched, o as BitTransformFn, p as BitValidationConfig, S as ScopeStatus, V as ValidateScopeResult, q as ValidatorFn, r as bitBus } from './bus-BtKUu_9m.js';
|
|
4
4
|
|
|
5
5
|
declare function deepClone<T>(obj: T): T;
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,V as T,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,V as T,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,u as s,v as u,w as v,x as w,y,z}from"./chunk-MVDS4KAD.js";export{T as BitStore,o as bitBus,S as bitMasks,t as cleanPrefixedKeys,h as createCreditCardMask,g as createCurrencyMask,i as createDateMask,d as createPatternMask,r as deepClone,f as deepEqual,a as extractServerErrors,m as getDeepValue,x as isValidationErrorShape,j as maskBRL,B as maskCEP,E as maskCNH,y as maskCNPJ,w as maskCPF,L as maskCVV,O as maskColorHex,K as maskCreditCard,C as maskDate,M as maskDateISO,I as maskDateUS,u as maskDecimal,l as maskEUR,n as maskGBP,R as maskIBAN,P as maskIPv4,Q as maskIPv6,v as maskInteger,q as maskJPY,A as maskLandline,N as maskMacAddress,s as maskPercent,z as maskPhone,F as maskRG,J as maskSSN,D as maskTime,k as maskUSD,G as maskUSPhone,H as maskZipCode,p as setDeepValue,b as unmask,c as unmaskCurrency,e as valueEqual};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react/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 _chunkIUDMKNONcjs = require('../chunk-IUDMKNON.cjs');require('../chunk-QB7MQ6ZB.cjs');var _react = require('react');function y(i){if(!i||typeof i!="object")return!1;let t=Object.keys(i);return t.length===1&&t[0]==="mask"}function H(i,t,r){let x=r!==void 0?t:y(t)?void 0:t,m=r!==void 0?r:y(t)?t:void 0,{fieldState:s,setValue:a,setBlur:d,store:n}=_chunkIUDMKNONcjs.d.call(void 0, i,x),o=_react.useMemo.call(void 0, ()=>{let e=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _ => _.mask]), () => (_optionalChain([n, 'access', _2 => _2.config, 'access', _3 => _3.fields, 'optionalAccess', _4 => _4[i], 'optionalAccess', _5 => _5.mask])));if(e)return typeof e=="string"?n.config.masks[e]:e},[_optionalChain([m, 'optionalAccess', _6 => _6.mask]),n.config.masks,n.config.fields,i]),p=_react.useMemo.call(void 0, ()=>{let e=s.value;return e==null||e===""?"":o?o.format(e):String(e)},[s.value,o]),l=_react.useCallback.call(void 0, e=>{if(!o){a(e);return}a(o.parse(String(_nullishCoalesce(e, () => ("")))))},[o,a]),{isHidden:g,isRequired:h,value:T,error:u,touched:B,isDirty:b,isValidating:V}=s,k=!!(B&&u),S=B?u:void 0,F=_react.useCallback.call(void 0, e=>{let U=_optionalChain([e, 'optionalAccess', _7 => _7.target])?e.target.value:e;l(U)},[l]),c=_react.useCallback.call(void 0, ()=>{d()},[d]);return{value:T,displayValue:p,setValue:l,setBlur:d,onChange:F,onBlur:c,props:{value:p,onChange:F,onBlur:c},meta:{error:S,touched:B,invalid:k,isDirty:b,isValidating:V,isHidden:g,isRequired:h,hasError:!!u}}}exports.BitFormProvider = _chunkIUDMKNONcjs.a; exports.useBitArray = _chunkIUDMKNONcjs.e; exports.useBitField = H; exports.useBitForm = _chunkIUDMKNONcjs.c; exports.useBitScope = _chunkIUDMKNONcjs.f; exports.useBitSteps = _chunkIUDMKNONcjs.g; exports.useBitStore = _chunkIUDMKNONcjs.b; exports.useBitWatch = _chunkIUDMKNONcjs.h;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/react/index.cjs","../../src/react/use-bit-field.ts"],"names":["useBitField","path","options","fieldState","rawSetValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","maskOption","displayValue","val","setValue","useCallback","isHidden","isRequired","
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/react/index.cjs","../../src/react/use-bit-field.ts"],"names":["isMaskOnlyOptions","value","keys","useBitField","path","configOrOptions","maybeOptions","config","options","fieldState","rawSetValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","maskOption","displayValue","val","setValue","useCallback","isHidden","isRequired","error","touched","isDirty","isValidating","invalid","visibleError","onChange","onBlur"],"mappings":"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","file":"/home/runner/work/bit-form/bit-form/dist/react/index.cjs","sourcesContent":[null,"import { useMemo, useCallback } from \"react\";\nimport { useBitFieldBase } from \"./use-bit-field-base\";\nimport {\n BitFieldDefinition,\n BitFieldOptions,\n BitPath,\n BitPathValue,\n} from \"../core\";\n\nexport interface UseBitFieldMeta {\n error: string | undefined;\n touched: boolean;\n invalid: boolean;\n isValidating: boolean;\n isDirty: boolean;\n isHidden: boolean;\n isRequired: boolean;\n hasError: boolean;\n}\n\nexport interface UseBitFieldBindProps {\n value: string;\n onChange: (e: any) => void;\n onBlur: () => void;\n}\n\nexport interface UseBitFieldResult<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n> {\n // Main handlers and values (flat)\n value: BitPathValue<TForm, P>;\n displayValue: string;\n setValue: (val: any) => void;\n setBlur: () => void;\n onChange: (e: any) => void;\n onBlur: () => void;\n // Props helper for native inputs\n props: UseBitFieldBindProps;\n // Readonly metadata (grouped)\n meta: UseBitFieldMeta;\n}\n\nfunction isMaskOnlyOptions(\n value: BitFieldDefinition<any> | BitFieldOptions | undefined,\n): value is BitFieldOptions {\n if (!value || typeof value !== \"object\") return false;\n const keys = Object.keys(value);\n return keys.length === 1 && keys[0] === \"mask\";\n}\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(\n path: P,\n configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions,\n maybeOptions?: BitFieldOptions,\n): UseBitFieldResult<TForm, P> {\n const config =\n maybeOptions !== undefined\n ? (configOrOptions as BitFieldDefinition<TForm> | undefined)\n : isMaskOnlyOptions(configOrOptions)\n ? undefined\n : (configOrOptions as BitFieldDefinition<TForm> | undefined);\n\n const options =\n maybeOptions !== undefined\n ? maybeOptions\n : isMaskOnlyOptions(configOrOptions)\n ? configOrOptions\n : undefined;\n\n const {\n fieldState,\n setValue: rawSetValue,\n setBlur,\n store,\n } = useBitFieldBase<BitPathValue<TForm, P>, TForm, P>(path, config);\n\n const resolvedMask = useMemo(() => {\n const maskOption =\n options?.mask ?? store.config.fields?.[path as string]?.mask;\n if (!maskOption) return undefined;\n return typeof maskOption === \"string\"\n ? store.config.masks![maskOption]\n : maskOption;\n }, [options?.mask, store.config.masks, store.config.fields, path]);\n\n const displayValue = useMemo(() => {\n const val = fieldState.value;\n if (val === undefined || val === null || val === \"\") return \"\";\n\n return resolvedMask ? resolvedMask.format(val) : String(val);\n }, [fieldState.value, resolvedMask]);\n\n const setValue = useCallback(\n (val: any) => {\n if (!resolvedMask) {\n rawSetValue(val);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(val ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const { isHidden, isRequired, value, error, touched, isDirty, isValidating } =\n fieldState;\n\n const invalid = !!(touched && error);\n const visibleError = touched ? error : undefined;\n\n const onChange = useCallback(\n (e: any) => {\n const val = e?.target ? e.target.value : e;\n setValue(val);\n },\n [setValue],\n );\n\n const onBlur = useCallback(() => {\n setBlur();\n }, [setBlur]);\n\n return {\n // Main handlers and values (flat)\n value: value as BitPathValue<TForm, P>,\n displayValue,\n setValue,\n setBlur,\n onChange,\n onBlur,\n // Props helper\n props: {\n value: displayValue,\n onChange,\n onBlur,\n },\n // Metadata (grouped)\n meta: {\n error: visibleError,\n touched,\n invalid,\n isDirty,\n isValidating,\n isHidden,\n isRequired,\n hasError: !!error,\n },\n };\n}\n"]}
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
export { B as BitFormProvider, U as UseBitStepsResult, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-
|
|
2
|
-
import { k as BitPath,
|
|
3
|
-
export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-
|
|
1
|
+
export { B as BitFormProvider, U as UseBitStepsResult, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-ClvBxm6Z.cjs';
|
|
2
|
+
import { k as BitPath, l as BitPathValue, g as BitFieldDefinition, h as BitFieldOptions } from '../bus-BtKUu_9m.cjs';
|
|
3
|
+
export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-BtKUu_9m.cjs';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
|
-
import '../index-
|
|
6
|
+
import '../index-CH9ZdEkZ.cjs';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
displayValue: string;
|
|
11
|
-
error: any;
|
|
8
|
+
interface UseBitFieldMeta {
|
|
9
|
+
error: string | undefined;
|
|
12
10
|
touched: boolean;
|
|
13
11
|
invalid: boolean;
|
|
14
12
|
isValidating: boolean;
|
|
15
13
|
isDirty: boolean;
|
|
16
14
|
isHidden: boolean;
|
|
17
15
|
isRequired: boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
hasError: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface UseBitFieldBindProps {
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (e: any) => void;
|
|
21
|
+
onBlur: () => void;
|
|
22
|
+
}
|
|
23
|
+
interface UseBitFieldResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
|
|
24
|
+
value: BitPathValue<TForm, P>;
|
|
25
|
+
displayValue: string;
|
|
25
26
|
setValue: (val: any) => void;
|
|
26
27
|
setBlur: () => void;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
onChange: (e: any) => void;
|
|
29
|
+
onBlur: () => void;
|
|
30
|
+
props: UseBitFieldBindProps;
|
|
31
|
+
meta: UseBitFieldMeta;
|
|
32
|
+
}
|
|
33
|
+
declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P, configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions, maybeOptions?: BitFieldOptions): UseBitFieldResult<TForm, P>;
|
|
33
34
|
|
|
34
|
-
export { useBitField };
|
|
35
|
+
export { type UseBitFieldBindProps, type UseBitFieldMeta, type UseBitFieldResult, useBitField };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
export { B as BitFormProvider, U as UseBitStepsResult, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-
|
|
2
|
-
import { k as BitPath,
|
|
3
|
-
export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-
|
|
1
|
+
export { B as BitFormProvider, U as UseBitStepsResult, u as useBitArray, a as useBitForm, b as useBitScope, c as useBitSteps, d as useBitStore, e as useBitWatch } from '../use-bit-watch-Bdwj9l_g.js';
|
|
2
|
+
import { k as BitPath, l as BitPathValue, g as BitFieldDefinition, h as BitFieldOptions } from '../bus-BtKUu_9m.js';
|
|
3
|
+
export { S as ScopeStatus, V as ValidateScopeResult } from '../bus-BtKUu_9m.js';
|
|
4
4
|
import 'react/jsx-runtime';
|
|
5
5
|
import 'react';
|
|
6
|
-
import '../index-
|
|
6
|
+
import '../index-C4HaSh5W.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
displayValue: string;
|
|
11
|
-
error: any;
|
|
8
|
+
interface UseBitFieldMeta {
|
|
9
|
+
error: string | undefined;
|
|
12
10
|
touched: boolean;
|
|
13
11
|
invalid: boolean;
|
|
14
12
|
isValidating: boolean;
|
|
15
13
|
isDirty: boolean;
|
|
16
14
|
isHidden: boolean;
|
|
17
15
|
isRequired: boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
hasError: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface UseBitFieldBindProps {
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (e: any) => void;
|
|
21
|
+
onBlur: () => void;
|
|
22
|
+
}
|
|
23
|
+
interface UseBitFieldResult<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>> {
|
|
24
|
+
value: BitPathValue<TForm, P>;
|
|
25
|
+
displayValue: string;
|
|
25
26
|
setValue: (val: any) => void;
|
|
26
27
|
setBlur: () => void;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
onChange: (e: any) => void;
|
|
29
|
+
onBlur: () => void;
|
|
30
|
+
props: UseBitFieldBindProps;
|
|
31
|
+
meta: UseBitFieldMeta;
|
|
32
|
+
}
|
|
33
|
+
declare function useBitField<TForm extends object = any, P extends BitPath<TForm> = BitPath<TForm>>(path: P, configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions, maybeOptions?: BitFieldOptions): UseBitFieldResult<TForm, P>;
|
|
33
34
|
|
|
34
|
-
export { useBitField };
|
|
35
|
+
export { type UseBitFieldBindProps, type UseBitFieldMeta, type UseBitFieldResult, useBitField };
|
package/dist/react/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as D,b as R,c as M,d as P,e as j,f as C,g as E,h as q}from"../chunk-4SZ2BOTW.js";import"../chunk-MVDS4KAD.js";import{useMemo as v,useCallback as f}from"react";function y(i){if(!i||typeof i!="object")return!1;let t=Object.keys(i);return t.length===1&&t[0]==="mask"}function H(i,t,r){let x=r!==void 0?t:y(t)?void 0:t,m=r!==void 0?r:y(t)?t:void 0,{fieldState:s,setValue:a,setBlur:d,store:n}=P(i,x),o=v(()=>{let e=m?.mask??n.config.fields?.[i]?.mask;if(e)return typeof e=="string"?n.config.masks[e]:e},[m?.mask,n.config.masks,n.config.fields,i]),p=v(()=>{let e=s.value;return e==null||e===""?"":o?o.format(e):String(e)},[s.value,o]),l=f(e=>{if(!o){a(e);return}a(o.parse(String(e??"")))},[o,a]),{isHidden:g,isRequired:h,value:T,error:u,touched:B,isDirty:b,isValidating:V}=s,k=!!(B&&u),S=B?u:void 0,F=f(e=>{let U=e?.target?e.target.value:e;l(U)},[l]),c=f(()=>{d()},[d]);return{value:T,displayValue:p,setValue:l,setBlur:d,onChange:F,onBlur:c,props:{value:p,onChange:F,onBlur:c},meta:{error:S,touched:B,invalid:k,isDirty:b,isValidating:V,isHidden:g,isRequired:h,hasError:!!u}}}export{D as BitFormProvider,j as useBitArray,H as useBitField,M as useBitForm,C as useBitScope,E as useBitSteps,R as useBitStore,q as useBitWatch};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/use-bit-field.ts"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { useBitFieldBase } from \"./use-bit-field-base\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/react/use-bit-field.ts"],"sourcesContent":["import { useMemo, useCallback } from \"react\";\nimport { useBitFieldBase } from \"./use-bit-field-base\";\nimport {\n BitFieldDefinition,\n BitFieldOptions,\n BitPath,\n BitPathValue,\n} from \"../core\";\n\nexport interface UseBitFieldMeta {\n error: string | undefined;\n touched: boolean;\n invalid: boolean;\n isValidating: boolean;\n isDirty: boolean;\n isHidden: boolean;\n isRequired: boolean;\n hasError: boolean;\n}\n\nexport interface UseBitFieldBindProps {\n value: string;\n onChange: (e: any) => void;\n onBlur: () => void;\n}\n\nexport interface UseBitFieldResult<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n> {\n // Main handlers and values (flat)\n value: BitPathValue<TForm, P>;\n displayValue: string;\n setValue: (val: any) => void;\n setBlur: () => void;\n onChange: (e: any) => void;\n onBlur: () => void;\n // Props helper for native inputs\n props: UseBitFieldBindProps;\n // Readonly metadata (grouped)\n meta: UseBitFieldMeta;\n}\n\nfunction isMaskOnlyOptions(\n value: BitFieldDefinition<any> | BitFieldOptions | undefined,\n): value is BitFieldOptions {\n if (!value || typeof value !== \"object\") return false;\n const keys = Object.keys(value);\n return keys.length === 1 && keys[0] === \"mask\";\n}\n\nexport function useBitField<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(\n path: P,\n configOrOptions?: BitFieldDefinition<TForm> | BitFieldOptions,\n maybeOptions?: BitFieldOptions,\n): UseBitFieldResult<TForm, P> {\n const config =\n maybeOptions !== undefined\n ? (configOrOptions as BitFieldDefinition<TForm> | undefined)\n : isMaskOnlyOptions(configOrOptions)\n ? undefined\n : (configOrOptions as BitFieldDefinition<TForm> | undefined);\n\n const options =\n maybeOptions !== undefined\n ? maybeOptions\n : isMaskOnlyOptions(configOrOptions)\n ? configOrOptions\n : undefined;\n\n const {\n fieldState,\n setValue: rawSetValue,\n setBlur,\n store,\n } = useBitFieldBase<BitPathValue<TForm, P>, TForm, P>(path, config);\n\n const resolvedMask = useMemo(() => {\n const maskOption =\n options?.mask ?? store.config.fields?.[path as string]?.mask;\n if (!maskOption) return undefined;\n return typeof maskOption === \"string\"\n ? store.config.masks![maskOption]\n : maskOption;\n }, [options?.mask, store.config.masks, store.config.fields, path]);\n\n const displayValue = useMemo(() => {\n const val = fieldState.value;\n if (val === undefined || val === null || val === \"\") return \"\";\n\n return resolvedMask ? resolvedMask.format(val) : String(val);\n }, [fieldState.value, resolvedMask]);\n\n const setValue = useCallback(\n (val: any) => {\n if (!resolvedMask) {\n rawSetValue(val);\n return;\n }\n\n rawSetValue(resolvedMask.parse(String(val ?? \"\")) as any);\n },\n [resolvedMask, rawSetValue],\n );\n\n const { isHidden, isRequired, value, error, touched, isDirty, isValidating } =\n fieldState;\n\n const invalid = !!(touched && error);\n const visibleError = touched ? error : undefined;\n\n const onChange = useCallback(\n (e: any) => {\n const val = e?.target ? e.target.value : e;\n setValue(val);\n },\n [setValue],\n );\n\n const onBlur = useCallback(() => {\n setBlur();\n }, [setBlur]);\n\n return {\n // Main handlers and values (flat)\n value: value as BitPathValue<TForm, P>,\n displayValue,\n setValue,\n setBlur,\n onChange,\n onBlur,\n // Props helper\n props: {\n value: displayValue,\n onChange,\n onBlur,\n },\n // Metadata (grouped)\n meta: {\n error: visibleError,\n touched,\n invalid,\n isDirty,\n isValidating,\n isHidden,\n isRequired,\n hasError: !!error,\n },\n };\n}\n"],"mappings":"uHAAA,OAAS,WAAAA,EAAS,eAAAC,MAAmB,QA2CrC,SAASC,EACPC,EAC0B,CAC1B,GAAI,CAACA,GAAS,OAAOA,GAAU,SAAU,MAAO,GAChD,IAAMC,EAAO,OAAO,KAAKD,CAAK,EAC9B,OAAOC,EAAK,SAAW,GAAKA,EAAK,CAAC,IAAM,MAC1C,CAEO,SAASC,EAIdC,EACAC,EACAC,EAC6B,CAC7B,IAAMC,EACJD,IAAiB,OACZD,EACDL,EAAkBK,CAAe,EAC/B,OACCA,EAEHG,EACJF,IAAiB,OACbA,EACAN,EAAkBK,CAAe,EAC/BA,EACA,OAEF,CACJ,WAAAI,EACA,SAAUC,EACV,QAAAC,EACA,MAAAC,CACF,EAAIC,EAAkDT,EAAMG,CAAM,EAE5DO,EAAeC,EAAQ,IAAM,CACjC,IAAMC,EACJR,GAAS,MAAQI,EAAM,OAAO,SAASR,CAAc,GAAG,KAC1D,GAAKY,EACL,OAAO,OAAOA,GAAe,SACzBJ,EAAM,OAAO,MAAOI,CAAU,EAC9BA,CACN,EAAG,CAACR,GAAS,KAAMI,EAAM,OAAO,MAAOA,EAAM,OAAO,OAAQR,CAAI,CAAC,EAE3Da,EAAeF,EAAQ,IAAM,CACjC,IAAMG,EAAMT,EAAW,MACvB,OAAyBS,GAAQ,MAAQA,IAAQ,GAAW,GAErDJ,EAAeA,EAAa,OAAOI,CAAG,EAAI,OAAOA,CAAG,CAC7D,EAAG,CAACT,EAAW,MAAOK,CAAY,CAAC,EAE7BK,EAAWC,EACdF,GAAa,CACZ,GAAI,CAACJ,EAAc,CACjBJ,EAAYQ,CAAG,EACf,MACF,CAEAR,EAAYI,EAAa,MAAM,OAAOI,GAAO,EAAE,CAAC,CAAQ,CAC1D,EACA,CAACJ,EAAcJ,CAAW,CAC5B,EAEM,CAAE,SAAAW,EAAU,WAAAC,EAAY,MAAArB,EAAO,MAAAsB,EAAO,QAAAC,EAAS,QAAAC,EAAS,aAAAC,CAAa,EACzEjB,EAEIkB,EAAU,CAAC,EAAEH,GAAWD,GACxBK,EAAeJ,EAAUD,EAAQ,OAEjCM,EAAWT,EACd,GAAW,CACV,IAAMF,EAAM,GAAG,OAAS,EAAE,OAAO,MAAQ,EACzCC,EAASD,CAAG,CACd,EACA,CAACC,CAAQ,CACX,EAEMW,EAASV,EAAY,IAAM,CAC/BT,EAAQ,CACV,EAAG,CAACA,CAAO,CAAC,EAEZ,MAAO,CAEL,MAAOV,EACP,aAAAgB,EACA,SAAAE,EACA,QAAAR,EACA,SAAAkB,EACA,OAAAC,EAEA,MAAO,CACL,MAAOb,EACP,SAAAY,EACA,OAAAC,CACF,EAEA,KAAM,CACJ,MAAOF,EACP,QAAAJ,EACA,QAAAG,EACA,QAAAF,EACA,aAAAC,EACA,SAAAL,EACA,WAAAC,EACA,SAAU,CAAC,CAACC,CACd,CACF,CACF","names":["useMemo","useCallback","isMaskOnlyOptions","value","keys","useBitField","path","configOrOptions","maybeOptions","config","options","fieldState","rawSetValue","setBlur","store","useBitFieldBase","resolvedMask","useMemo","maskOption","displayValue","val","setValue","useCallback","isHidden","isRequired","error","touched","isDirty","isValidating","invalid","visibleError","onChange","onBlur"]}
|