adaptform 2.0.2 → 2.0.3
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/Form-DOdrOtbT.d.cts +213 -0
- package/dist/Form-DOdrOtbT.d.ts +213 -0
- package/dist/index.cjs +0 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -229
- package/dist/index.d.ts +3 -229
- package/dist/index.mjs +1 -58
- package/dist/index.mjs.map +1 -1
- package/dist/luxon.cjs +122 -0
- package/dist/luxon.cjs.map +1 -0
- package/dist/luxon.d.cts +26 -0
- package/dist/luxon.d.ts +26 -0
- package/dist/luxon.mjs +120 -0
- package/dist/luxon.mjs.map +1 -0
- package/package.json +19 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,59 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
init?(field: Field<T>): void;
|
|
4
|
-
toRawValue?(value: any, field: Field<T>): any;
|
|
5
|
-
toValueClear?(value: any, field: Field<T>): any;
|
|
6
|
-
}
|
|
7
|
-
declare abstract class BasePlugin<T = any> implements FieldPlugin<T> {
|
|
8
|
-
pluginOptions: PluginOptions;
|
|
9
|
-
constructor(pluginOptions?: PluginOptions);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare class ArrayField<T = any> {
|
|
13
|
-
protected factory: (value?: T) => Field<T>;
|
|
14
|
-
protected options: ArrayFieldOptions;
|
|
15
|
-
protected _items: Field<T>[];
|
|
16
|
-
protected _errors: string[];
|
|
17
|
-
isTouched: boolean;
|
|
18
|
-
constructor(factory: (value?: T) => Field<T>, options?: ArrayFieldOptions, initial?: T[]);
|
|
19
|
-
set itemsValue(items: T[]);
|
|
20
|
-
get itemsValue(): T[];
|
|
21
|
-
get items(): Field<T>[];
|
|
22
|
-
add(value?: T, force_check?: boolean): Field<T>;
|
|
23
|
-
remove(index: number): void;
|
|
24
|
-
clear(): void;
|
|
25
|
-
private isRequired;
|
|
26
|
-
checkValid(form?: Form): boolean;
|
|
27
|
-
checkAndSetValid(form?: Form): boolean;
|
|
28
|
-
get isValid(): boolean;
|
|
29
|
-
get error(): string;
|
|
30
|
-
set error(message: string | null);
|
|
31
|
-
get errors(): string[];
|
|
32
|
-
reset(): void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare class ArrayFormField<T extends Form = Form> {
|
|
36
|
-
private FormConstructor;
|
|
37
|
-
private options;
|
|
38
|
-
private _forms;
|
|
39
|
-
private _errors;
|
|
40
|
-
isTouched: boolean;
|
|
41
|
-
constructor(FormConstructor: new () => T, options?: ArrayFormFieldOptions, initial?: any[]);
|
|
42
|
-
set forms(forms: any[]);
|
|
43
|
-
get forms(): Form[];
|
|
44
|
-
get formsFieldsValue(): any[];
|
|
45
|
-
add(data?: any, force_check?: boolean): T;
|
|
46
|
-
remove(index: number): void;
|
|
47
|
-
clear(): void;
|
|
48
|
-
reset(): void;
|
|
49
|
-
private isRequired;
|
|
50
|
-
checkValid(form?: Form): boolean;
|
|
51
|
-
checkAndSetValid(form?: Form): boolean;
|
|
52
|
-
get isValid(): boolean;
|
|
53
|
-
get errors(): string[];
|
|
54
|
-
get error(): string;
|
|
55
|
-
set error(message: string | null);
|
|
56
|
-
}
|
|
1
|
+
import { B as BasePlugin, M as MaskPluginOptions, P as PluginOptions, F as Field, a as FieldType, S as StringOptions, N as NumberOptions, D as DecimalOptions, b as BooleanOptions, c as DateOptions } from './Form-DOdrOtbT.js';
|
|
2
|
+
export { o as ArrayField, A as ArrayFieldOptions, p as ArrayFormField, n as ArrayFormFieldOptions, l as FieldOptions, q as FieldPlugin, d as Form, j as messagesArrayFieldOptions, k as messagesArrayFormFieldOptions, g as messagesBooleanOptions, h as messagesDateOptions, i as messagesDecimalOptions, f as messagesNumberOptions, m as messagesOptions, e as messagesStringOptions } from './Form-DOdrOtbT.js';
|
|
57
3
|
|
|
58
4
|
declare class MaskPlugin extends BasePlugin {
|
|
59
5
|
private config;
|
|
@@ -67,173 +13,6 @@ declare class MaskPlugin extends BasePlugin {
|
|
|
67
13
|
private removeMask;
|
|
68
14
|
}
|
|
69
15
|
|
|
70
|
-
interface messagesOptions {
|
|
71
|
-
isRequired?: string;
|
|
72
|
-
validate?: string;
|
|
73
|
-
type?: string;
|
|
74
|
-
invalid?: string;
|
|
75
|
-
}
|
|
76
|
-
interface messagesStringOptions extends messagesOptions {
|
|
77
|
-
minLength?: string;
|
|
78
|
-
maxLength?: string;
|
|
79
|
-
pattern?: string;
|
|
80
|
-
}
|
|
81
|
-
interface messagesNumberOptions extends messagesOptions {
|
|
82
|
-
gt?: string;
|
|
83
|
-
ge?: string;
|
|
84
|
-
lt?: string;
|
|
85
|
-
le?: string;
|
|
86
|
-
}
|
|
87
|
-
interface messagesBooleanOptions extends messagesOptions {
|
|
88
|
-
mustBeTrue?: string;
|
|
89
|
-
mustBeFalse?: string;
|
|
90
|
-
}
|
|
91
|
-
interface messagesDateOptions extends messagesOptions {
|
|
92
|
-
minDate?: string;
|
|
93
|
-
maxDate?: string;
|
|
94
|
-
}
|
|
95
|
-
interface messagesDateLuxonOptions extends messagesOptions {
|
|
96
|
-
minDate?: string;
|
|
97
|
-
maxDate?: string;
|
|
98
|
-
}
|
|
99
|
-
interface messagesDecimalOptions extends messagesOptions {
|
|
100
|
-
gt?: string;
|
|
101
|
-
ge?: string;
|
|
102
|
-
lt?: string;
|
|
103
|
-
le?: string;
|
|
104
|
-
decimalPlaces?: string;
|
|
105
|
-
maxDigits?: string;
|
|
106
|
-
}
|
|
107
|
-
interface messagesArrayFieldOptions extends messagesOptions {
|
|
108
|
-
minItems?: string;
|
|
109
|
-
maxItems?: string;
|
|
110
|
-
}
|
|
111
|
-
interface messagesArrayFormFieldOptions extends messagesOptions {
|
|
112
|
-
minForms?: string;
|
|
113
|
-
maxForms?: string;
|
|
114
|
-
}
|
|
115
|
-
interface FieldOptions {
|
|
116
|
-
isRequired?: boolean | ((form?: any) => boolean);
|
|
117
|
-
messages?: messagesOptions;
|
|
118
|
-
validate?: (value: any, form?: any) => boolean | string;
|
|
119
|
-
plugins?: FieldPlugin[];
|
|
120
|
-
}
|
|
121
|
-
interface StringOptions extends FieldOptions {
|
|
122
|
-
minLength?: number;
|
|
123
|
-
maxLength?: number;
|
|
124
|
-
pattern?: RegExp;
|
|
125
|
-
messages?: messagesStringOptions;
|
|
126
|
-
}
|
|
127
|
-
interface NumberOptions extends FieldOptions {
|
|
128
|
-
gt?: number;
|
|
129
|
-
ge?: number;
|
|
130
|
-
lt?: number;
|
|
131
|
-
le?: number;
|
|
132
|
-
messages?: messagesNumberOptions;
|
|
133
|
-
}
|
|
134
|
-
interface BooleanOptions extends FieldOptions {
|
|
135
|
-
mustBeTrue?: boolean;
|
|
136
|
-
mustBeFalse?: boolean;
|
|
137
|
-
messages?: messagesBooleanOptions;
|
|
138
|
-
}
|
|
139
|
-
interface DateOptions extends FieldOptions {
|
|
140
|
-
minDate?: Date;
|
|
141
|
-
maxDate?: Date;
|
|
142
|
-
isDatetime?: boolean;
|
|
143
|
-
messages?: messagesDateOptions;
|
|
144
|
-
}
|
|
145
|
-
interface DateLuxonOptions extends FieldOptions {
|
|
146
|
-
minDate?: any;
|
|
147
|
-
maxDate?: any;
|
|
148
|
-
inputFormat?: string;
|
|
149
|
-
outputFormat?: string;
|
|
150
|
-
isDatetime?: boolean;
|
|
151
|
-
messages?: messagesDateLuxonOptions;
|
|
152
|
-
}
|
|
153
|
-
interface DecimalOptions extends FieldOptions {
|
|
154
|
-
gt?: number;
|
|
155
|
-
ge?: number;
|
|
156
|
-
lt?: number;
|
|
157
|
-
le?: number;
|
|
158
|
-
decimalPlaces?: number;
|
|
159
|
-
maxDigits?: number;
|
|
160
|
-
messages?: messagesDecimalOptions;
|
|
161
|
-
}
|
|
162
|
-
interface ArrayFieldOptions {
|
|
163
|
-
isRequired?: boolean | ((form?: any) => boolean);
|
|
164
|
-
messages?: messagesArrayFieldOptions;
|
|
165
|
-
validate?: (value: any[], form?: any) => boolean | string;
|
|
166
|
-
minItems?: number;
|
|
167
|
-
maxItems?: number;
|
|
168
|
-
}
|
|
169
|
-
interface ArrayFormFieldOptions {
|
|
170
|
-
isRequired?: boolean | ((form?: any) => boolean);
|
|
171
|
-
messages?: messagesArrayFormFieldOptions;
|
|
172
|
-
validate?: (value: any[], form?: any) => boolean | string;
|
|
173
|
-
minForms?: number;
|
|
174
|
-
maxForms?: number;
|
|
175
|
-
}
|
|
176
|
-
interface PluginOptions {
|
|
177
|
-
priority?: number;
|
|
178
|
-
}
|
|
179
|
-
interface MaskPluginOptions {
|
|
180
|
-
maskFormat: string;
|
|
181
|
-
maskPlaceholder: string;
|
|
182
|
-
digitPattern: RegExp;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
declare abstract class FieldType<T, O extends FieldOptions = FieldOptions> {
|
|
186
|
-
options: O;
|
|
187
|
-
constructor(options: O);
|
|
188
|
-
abstract cast(rawValue: any): T | null;
|
|
189
|
-
abstract validate(value: T, form?: Form): string[];
|
|
190
|
-
abstract getTypeName(): string;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
type FieldTypeConstructor<T, O extends FieldOptions = FieldOptions> = new (options: O) => FieldType<T, O>;
|
|
194
|
-
declare class Field<T = any, O extends FieldOptions = FieldOptions> {
|
|
195
|
-
protected _rawValue: any;
|
|
196
|
-
protected _valueClear: T | null;
|
|
197
|
-
protected filed_type: FieldType<T, O>;
|
|
198
|
-
protected defaultValue: T | null;
|
|
199
|
-
protected _errors: string[];
|
|
200
|
-
isValid: boolean | null;
|
|
201
|
-
isTouched: boolean;
|
|
202
|
-
constructor(TypeConstructor: FieldTypeConstructor<T, O>, defaultValue?: T | null, options?: O | null);
|
|
203
|
-
protected get plugins(): FieldPlugin<any>[];
|
|
204
|
-
get options(): O;
|
|
205
|
-
set options(options: O);
|
|
206
|
-
get rawValue(): T | null;
|
|
207
|
-
set rawValue(input: any);
|
|
208
|
-
get errors(): string[];
|
|
209
|
-
get error(): string;
|
|
210
|
-
set error(message: string | null);
|
|
211
|
-
get valueClear(): any;
|
|
212
|
-
private isRequired;
|
|
213
|
-
checkValid(form?: Form): boolean;
|
|
214
|
-
checkAndSetValid(form?: Form): boolean;
|
|
215
|
-
get isEmpty(): boolean;
|
|
216
|
-
reset(): void;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
declare abstract class Form {
|
|
220
|
-
private _globalErrors;
|
|
221
|
-
protected get _fields(): Record<string, Field<any> | ArrayField<any> | ArrayFormField<any>>;
|
|
222
|
-
checkValid(form?: this): boolean;
|
|
223
|
-
get fieldsValue(): Record<string, any>;
|
|
224
|
-
set fields(data: Record<string, any>);
|
|
225
|
-
get allErrors(): Record<string, string[]>;
|
|
226
|
-
get globalErrors(): Record<string, string>;
|
|
227
|
-
set errors(errors: Record<string, string>);
|
|
228
|
-
setGlobalError(key: string, message: string): void;
|
|
229
|
-
clearGlobalErrors(): void;
|
|
230
|
-
reset(): void;
|
|
231
|
-
get isTouched(): boolean;
|
|
232
|
-
get isValid(): boolean;
|
|
233
|
-
toFormData(): FormData;
|
|
234
|
-
toJSON(): Record<string, any>;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
16
|
declare class StringType extends FieldType<string, StringOptions> {
|
|
238
17
|
cast(rawValue: any): string | null;
|
|
239
18
|
validate(value: string): string[];
|
|
@@ -271,9 +50,4 @@ declare class DateType extends FieldType<Date, DateOptions> {
|
|
|
271
50
|
private toDateOnly;
|
|
272
51
|
}
|
|
273
52
|
|
|
274
|
-
|
|
275
|
-
declare function initLuxon(): Promise<any>;
|
|
276
|
-
declare function isLuxonAvailable(): boolean;
|
|
277
|
-
declare function resetLuxon(): void;
|
|
278
|
-
|
|
279
|
-
export { ArrayField, type ArrayFieldOptions, ArrayFormField, type ArrayFormFieldOptions, BasePlugin, type BooleanOptions, BooleanType, type DateLuxonOptions, type DateOptions, DateType, type DecimalOptions, DecimalType, Field, type FieldOptions, type FieldPlugin, FieldType, Form, MaskPlugin, type MaskPluginOptions, type NumberOptions, NumberType, type PluginOptions, type StringOptions, StringType, getDateTimeConstructor, initLuxon, isLuxonAvailable, type messagesArrayFieldOptions, type messagesArrayFormFieldOptions, type messagesBooleanOptions, type messagesDateLuxonOptions, type messagesDateOptions, type messagesDecimalOptions, type messagesNumberOptions, type messagesOptions, type messagesStringOptions, resetLuxon };
|
|
53
|
+
export { BasePlugin, BooleanOptions, BooleanType, DateOptions, DateType, DecimalOptions, DecimalType, Field, FieldType, MaskPlugin, MaskPluginOptions, NumberOptions, NumberType, PluginOptions, StringOptions, StringType };
|
package/dist/index.mjs
CHANGED
|
@@ -1010,63 +1010,6 @@ var DateType = class extends FieldType {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
1012
|
|
|
1013
|
-
|
|
1014
|
-
var DateTimeConstructor = null;
|
|
1015
|
-
var isLoading = false;
|
|
1016
|
-
var loadError = null;
|
|
1017
|
-
var loadPromise = null;
|
|
1018
|
-
function getDateTimeConstructor() {
|
|
1019
|
-
if (DateTimeConstructor) {
|
|
1020
|
-
return DateTimeConstructor;
|
|
1021
|
-
}
|
|
1022
|
-
if (loadError) {
|
|
1023
|
-
throw loadError;
|
|
1024
|
-
}
|
|
1025
|
-
if (isLoading) {
|
|
1026
|
-
throw new Error(
|
|
1027
|
-
"Luxon is still loading. Please await initLuxon() first."
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
throw new Error(
|
|
1031
|
-
"Luxon is not initialized. Install: npm install luxon"
|
|
1032
|
-
);
|
|
1033
|
-
}
|
|
1034
|
-
function initLuxon() {
|
|
1035
|
-
if (DateTimeConstructor) {
|
|
1036
|
-
return Promise.resolve(DateTimeConstructor);
|
|
1037
|
-
}
|
|
1038
|
-
if (loadPromise) {
|
|
1039
|
-
return loadPromise;
|
|
1040
|
-
}
|
|
1041
|
-
isLoading = true;
|
|
1042
|
-
loadPromise = (async () => {
|
|
1043
|
-
try {
|
|
1044
|
-
const luxon = await import('luxon');
|
|
1045
|
-
DateTimeConstructor = luxon.DateTime;
|
|
1046
|
-
return DateTimeConstructor;
|
|
1047
|
-
} catch (error) {
|
|
1048
|
-
loadError = new Error(
|
|
1049
|
-
'DateLuxonType requires the "luxon" package to be installed.\nInstall: npm install luxon'
|
|
1050
|
-
);
|
|
1051
|
-
throw loadError;
|
|
1052
|
-
} finally {
|
|
1053
|
-
isLoading = false;
|
|
1054
|
-
}
|
|
1055
|
-
})();
|
|
1056
|
-
return loadPromise;
|
|
1057
|
-
}
|
|
1058
|
-
function isLuxonAvailable() {
|
|
1059
|
-
return DateTimeConstructor !== null;
|
|
1060
|
-
}
|
|
1061
|
-
function resetLuxon() {
|
|
1062
|
-
DateTimeConstructor = null;
|
|
1063
|
-
isLoading = false;
|
|
1064
|
-
loadError = null;
|
|
1065
|
-
loadPromise = null;
|
|
1066
|
-
}
|
|
1067
|
-
initLuxon().catch(() => {
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
export { ArrayField, ArrayFormField, BasePlugin, BooleanType, DateType, DecimalType, Field, FieldType, Form, MaskPlugin, NumberType, StringType, getDateTimeConstructor, initLuxon, isLuxonAvailable, resetLuxon };
|
|
1013
|
+
export { ArrayField, ArrayFormField, BasePlugin, BooleanType, DateType, DecimalType, Field, FieldType, Form, MaskPlugin, NumberType, StringType };
|
|
1071
1014
|
//# sourceMappingURL=index.mjs.map
|
|
1072
1015
|
//# sourceMappingURL=index.mjs.map
|