@macrulez/vue-form-schema 0.1.9 → 0.2.1
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 +461 -180
- package/dist/MaskEngine-BEXwX4BK.js +144 -0
- package/dist/MaskEngine-CPr-fSPy.cjs +1 -0
- package/dist/ValidationEngine-BC4U1ef1.js +135 -0
- package/dist/ValidationEngine-Diz-qTFs.cjs +1 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/core/ConditionEvaluator.d.ts.map +1 -1
- package/dist/core/MaskEngine.d.ts.map +1 -1
- package/dist/core/ValidationEngine.d.ts +7 -0
- package/dist/core/ValidationEngine.d.ts.map +1 -1
- package/dist/core/formRegistry.d.ts +33 -0
- package/dist/core/formRegistry.d.ts.map +1 -0
- package/dist/core/inferTypes.d.ts.map +1 -1
- package/dist/core/schemaUtils.d.ts +38 -0
- package/dist/core/schemaUtils.d.ts.map +1 -1
- package/dist/core/serverErrors.d.ts +69 -0
- package/dist/core/serverErrors.d.ts.map +1 -0
- package/dist/core/types.d.ts +12 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/useForm.d.ts +4 -1
- package/dist/core/useForm.d.ts.map +1 -1
- package/dist/core/useMultiStepForm.d.ts.map +1 -1
- package/dist/devtools/index.d.ts +26 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools.cjs +1 -0
- package/dist/devtools.d.ts +6 -0
- package/dist/devtools.js +93 -0
- package/dist/formRegistry-Bv1eaWQ-.js +31 -0
- package/dist/formRegistry-DaDmXyYY.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +393 -368
- package/dist/openapi.cjs +1 -0
- package/dist/openapi.d.ts +202 -0
- package/dist/openapi.js +118 -0
- package/dist/parsers/json.d.ts.map +1 -1
- package/dist/parsers/openapi.d.ts +139 -0
- package/dist/parsers/openapi.d.ts.map +1 -0
- package/dist/parsers/valibot.d.ts +13 -4
- package/dist/parsers/valibot.d.ts.map +1 -1
- package/dist/parsers/yup.d.ts +10 -4
- package/dist/parsers/yup.d.ts.map +1 -1
- package/dist/parsers/zod.d.ts +18 -4
- package/dist/parsers/zod.d.ts.map +1 -1
- package/dist/schemaUtils-Cc7CwGXB.cjs +1 -0
- package/dist/schemaUtils-Cvlsk24U.js +337 -0
- package/dist/style.css +1 -0
- package/dist/ui/naive/index.d.ts +11 -0
- package/dist/ui/naive/index.d.ts.map +1 -0
- package/dist/ui/primevue/index.d.ts +11 -0
- package/dist/ui/primevue/index.d.ts.map +1 -0
- package/dist/ui/shadcn/index.d.ts +11 -0
- package/dist/ui/shadcn/index.d.ts.map +1 -0
- package/dist/ui-naive.cjs +1 -0
- package/dist/ui-naive.d.ts +276 -0
- package/dist/ui-naive.js +667 -0
- package/dist/ui-primevue.cjs +1 -0
- package/dist/ui-primevue.d.ts +276 -0
- package/dist/ui-primevue.js +651 -0
- package/dist/ui-shadcn.cjs +1 -0
- package/dist/ui-shadcn.d.ts +276 -0
- package/dist/ui-shadcn.js +650 -0
- package/dist/ui-tailwind.cjs +1 -1
- package/dist/ui-tailwind.d.ts +153 -274
- package/dist/ui-tailwind.js +180 -161
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +170 -308
- package/dist/ui.js +130 -131
- package/dist/valibot.cjs +1 -1
- package/dist/valibot.d.ts +25 -2
- package/dist/valibot.js +47 -20
- package/dist/yup.cjs +1 -1
- package/dist/yup.d.ts +23 -3
- package/dist/yup.js +16 -15
- package/dist/zod.cjs +1 -1
- package/dist/zod.d.ts +31 -3
- package/dist/zod.js +58 -28
- package/package.json +69 -7
- package/dist/MaskEngine-DAKSNIHQ.cjs +0 -1
- package/dist/MaskEngine-mLoXKd4d.js +0 -251
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
3
|
+
import { ComponentProvideOptions } from 'vue';
|
|
4
|
+
import { ComputedRef } from 'vue';
|
|
5
|
+
import { DefineComponent } from 'vue';
|
|
6
|
+
import { PublicProps } from 'vue';
|
|
7
|
+
import { Ref } from 'vue';
|
|
8
|
+
|
|
9
|
+
declare const __VLS_base: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
10
|
+
submit: () => any;
|
|
11
|
+
}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onSubmit?: (() => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
|
|
15
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
16
|
+
|
|
17
|
+
declare const __VLS_export_10: DefineComponent<__VLS_Props_10, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_10> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
|
|
19
|
+
declare const __VLS_export_2: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
20
|
+
blur: () => any;
|
|
21
|
+
"update:modelValue": (value: string) => any;
|
|
22
|
+
}, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
|
|
23
|
+
onBlur?: (() => any) | undefined;
|
|
24
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
25
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
|
|
27
|
+
declare const __VLS_export_3: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
28
|
+
blur: () => any;
|
|
29
|
+
"update:modelValue": (value: number | null) => any;
|
|
30
|
+
}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{
|
|
31
|
+
onBlur?: (() => any) | undefined;
|
|
32
|
+
"onUpdate:modelValue"?: ((value: number | null) => any) | undefined;
|
|
33
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
34
|
+
|
|
35
|
+
declare const __VLS_export_4: DefineComponent<__VLS_Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
36
|
+
blur: () => any;
|
|
37
|
+
"update:modelValue": (value: string) => any;
|
|
38
|
+
}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{
|
|
39
|
+
onBlur?: (() => any) | undefined;
|
|
40
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
41
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
42
|
+
|
|
43
|
+
declare const __VLS_export_5: DefineComponent<__VLS_Props_5, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
44
|
+
blur: () => any;
|
|
45
|
+
"update:modelValue": (value: unknown) => any;
|
|
46
|
+
}, string, PublicProps, Readonly<__VLS_Props_5> & Readonly<{
|
|
47
|
+
onBlur?: (() => any) | undefined;
|
|
48
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
49
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
50
|
+
|
|
51
|
+
declare const __VLS_export_6: DefineComponent<__VLS_Props_6, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
52
|
+
blur: () => any;
|
|
53
|
+
"update:modelValue": (value: boolean) => any;
|
|
54
|
+
}, string, PublicProps, Readonly<__VLS_Props_6> & Readonly<{
|
|
55
|
+
onBlur?: (() => any) | undefined;
|
|
56
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
57
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
58
|
+
|
|
59
|
+
declare const __VLS_export_7: DefineComponent<__VLS_Props_7, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
60
|
+
blur: () => any;
|
|
61
|
+
"update:modelValue": (value: unknown) => any;
|
|
62
|
+
}, string, PublicProps, Readonly<__VLS_Props_7> & Readonly<{
|
|
63
|
+
onBlur?: (() => any) | undefined;
|
|
64
|
+
"onUpdate:modelValue"?: ((value: unknown) => any) | undefined;
|
|
65
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
66
|
+
|
|
67
|
+
declare const __VLS_export_8: DefineComponent<__VLS_Props_8, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
68
|
+
blur: () => any;
|
|
69
|
+
"update:modelValue": (value: string) => any;
|
|
70
|
+
}, string, PublicProps, Readonly<__VLS_Props_8> & Readonly<{
|
|
71
|
+
onBlur?: (() => any) | undefined;
|
|
72
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
73
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
74
|
+
|
|
75
|
+
declare const __VLS_export_9: DefineComponent<__VLS_Props_9, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
76
|
+
blur: () => any;
|
|
77
|
+
"update:modelValue": (value: File | File[] | null) => any;
|
|
78
|
+
}, string, PublicProps, Readonly<__VLS_Props_9> & Readonly<{
|
|
79
|
+
onBlur?: (() => any) | undefined;
|
|
80
|
+
"onUpdate:modelValue"?: ((value: File | File[] | null) => any) | undefined;
|
|
81
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
82
|
+
|
|
83
|
+
declare type __VLS_Props = {
|
|
84
|
+
form: UseFormReturn;
|
|
85
|
+
components?: Partial<Record<FieldDefinition['type'], Component | string>>;
|
|
86
|
+
submitLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Internal: the field list to render. Used by the `group` case to recurse
|
|
89
|
+
* into `field.fields` instead of re-rendering the whole top-level schema
|
|
90
|
+
* (which would recurse into the same group forever). Defaults to the
|
|
91
|
+
* form's top-level fields — not meant to be passed by consumers.
|
|
92
|
+
*/
|
|
93
|
+
fields?: FieldDefinition[];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
declare type __VLS_Props_10 = {
|
|
97
|
+
field: FieldDefinition;
|
|
98
|
+
form: UseFormReturn;
|
|
99
|
+
components?: Partial<Record<FieldDefinition['type'], Component | string>>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
declare type __VLS_Props_2 = {
|
|
103
|
+
field: FieldDefinition;
|
|
104
|
+
modelValue: string | null;
|
|
105
|
+
error?: string[];
|
|
106
|
+
touched?: boolean;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare type __VLS_Props_3 = {
|
|
110
|
+
field: FieldDefinition;
|
|
111
|
+
modelValue: number | null;
|
|
112
|
+
error?: string[];
|
|
113
|
+
touched?: boolean;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
declare type __VLS_Props_4 = {
|
|
117
|
+
field: FieldDefinition;
|
|
118
|
+
modelValue: string | null;
|
|
119
|
+
error?: string[];
|
|
120
|
+
touched?: boolean;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
declare type __VLS_Props_5 = {
|
|
124
|
+
field: FieldDefinition;
|
|
125
|
+
modelValue: unknown;
|
|
126
|
+
error?: string[];
|
|
127
|
+
touched?: boolean;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
declare type __VLS_Props_6 = {
|
|
131
|
+
field: FieldDefinition;
|
|
132
|
+
modelValue: boolean | null;
|
|
133
|
+
error?: string[];
|
|
134
|
+
touched?: boolean;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
declare type __VLS_Props_7 = {
|
|
138
|
+
field: FieldDefinition;
|
|
139
|
+
modelValue: unknown;
|
|
140
|
+
error?: string[];
|
|
141
|
+
touched?: boolean;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
declare type __VLS_Props_8 = {
|
|
145
|
+
field: FieldDefinition;
|
|
146
|
+
modelValue: string | null;
|
|
147
|
+
error?: string[];
|
|
148
|
+
touched?: boolean;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
declare type __VLS_Props_9 = {
|
|
152
|
+
field: FieldDefinition;
|
|
153
|
+
modelValue: File | File[] | null;
|
|
154
|
+
error?: string[];
|
|
155
|
+
touched?: boolean;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
declare type __VLS_Slots = {} & {
|
|
159
|
+
[K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
|
|
160
|
+
} & {
|
|
161
|
+
submit?: (props: typeof __VLS_29) => any;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
declare type __VLS_WithSlots<T, S> = T & {
|
|
165
|
+
new (): {
|
|
166
|
+
$slots: S;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
declare type AsyncValidatorFn = (value: unknown, values: Record<string, unknown>) => Promise<string | null>;
|
|
171
|
+
|
|
172
|
+
declare interface FieldDefinition {
|
|
173
|
+
type: FieldType;
|
|
174
|
+
/** Dot-path for nested fields, e.g. "address.city" */
|
|
175
|
+
name: string;
|
|
176
|
+
label?: string;
|
|
177
|
+
placeholder?: string;
|
|
178
|
+
defaultValue?: unknown | ((values: Record<string, unknown>) => unknown);
|
|
179
|
+
required?: boolean;
|
|
180
|
+
/** Static or dynamic disabled state */
|
|
181
|
+
disabled?: boolean | ((values: Record<string, unknown>) => boolean);
|
|
182
|
+
/** Static or dynamic visibility; string is evaluated as expression */
|
|
183
|
+
visible?: boolean | string | ((values: Record<string, unknown>) => boolean);
|
|
184
|
+
validators?: ValidatorFn[];
|
|
185
|
+
asyncValidators?: AsyncValidatorFn[];
|
|
186
|
+
mask?: string | MaskConfig;
|
|
187
|
+
/** For select / radio — static list, sync function, or async function */
|
|
188
|
+
options?: FieldOption[] | ((values: Record<string, unknown>) => FieldOption[] | Promise<FieldOption[]>);
|
|
189
|
+
/**
|
|
190
|
+
* Field names whose values trigger re-fetching of async options.
|
|
191
|
+
* Only relevant when `options` is an async function.
|
|
192
|
+
*/
|
|
193
|
+
optionsDeps?: string[];
|
|
194
|
+
/** Internal: set by useForm when async options are loading. Read-only for consumers. */
|
|
195
|
+
optionsLoading?: boolean;
|
|
196
|
+
/** For group and array */
|
|
197
|
+
fields?: FieldDefinition[];
|
|
198
|
+
/**
|
|
199
|
+
* Applied on every setField call before the value is stored.
|
|
200
|
+
* Use for trimming, type coercion, formatting, etc.
|
|
201
|
+
*/
|
|
202
|
+
transform?: (value: unknown, values: Record<string, unknown>) => unknown;
|
|
203
|
+
/**
|
|
204
|
+
* Applied at submit time to produce the final payload value.
|
|
205
|
+
* Runs after all validation passes.
|
|
206
|
+
*/
|
|
207
|
+
parse?: (raw: unknown) => unknown;
|
|
208
|
+
/**
|
|
209
|
+
* Custom Vue component to render this field.
|
|
210
|
+
* Receives FormFieldProps and must emit 'update:modelValue' and 'blur'.
|
|
211
|
+
*/
|
|
212
|
+
component?: Component | string;
|
|
213
|
+
/** Accepted file types, e.g. "image/*,.pdf" — passed to <input accept> */
|
|
214
|
+
accept?: string;
|
|
215
|
+
/** Allow selecting multiple files */
|
|
216
|
+
multiple?: boolean;
|
|
217
|
+
/** Maximum file size in bytes */
|
|
218
|
+
maxSize?: number;
|
|
219
|
+
/** Maximum number of files (only relevant when multiple=true) */
|
|
220
|
+
maxFiles?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare interface FieldOption {
|
|
224
|
+
label: string;
|
|
225
|
+
value: unknown;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare type FieldType = 'text' | 'number' | 'email' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'date' | 'array' | 'group' | 'file';
|
|
229
|
+
|
|
230
|
+
declare interface MaskConfig {
|
|
231
|
+
preset?: MaskPreset;
|
|
232
|
+
/** Custom mask pattern: '#' = digit, 'A' = letter, other chars are literals */
|
|
233
|
+
pattern?: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare type MaskPreset = 'phone-ru' | 'phone-eu' | 'date' | 'inn' | 'iban';
|
|
237
|
+
|
|
238
|
+
export declare const NaiveFormRenderer: typeof __VLS_export;
|
|
239
|
+
|
|
240
|
+
export declare const NuArrayField: typeof __VLS_export_10;
|
|
241
|
+
|
|
242
|
+
export declare const NuCheckboxField: typeof __VLS_export_6;
|
|
243
|
+
|
|
244
|
+
export declare const NuDateField: typeof __VLS_export_8;
|
|
245
|
+
|
|
246
|
+
export declare const NuFileField: typeof __VLS_export_9;
|
|
247
|
+
|
|
248
|
+
export declare const NuNumberField: typeof __VLS_export_3;
|
|
249
|
+
|
|
250
|
+
export declare const NuRadioField: typeof __VLS_export_7;
|
|
251
|
+
|
|
252
|
+
export declare const NuSelectField: typeof __VLS_export_5;
|
|
253
|
+
|
|
254
|
+
export declare const NuTextareaField: typeof __VLS_export_4;
|
|
255
|
+
|
|
256
|
+
export declare const NuTextField: typeof __VLS_export_2;
|
|
257
|
+
|
|
258
|
+
declare interface UseFormReturn<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
259
|
+
fields: ComputedRef<FieldDefinition[]>;
|
|
260
|
+
values: Ref<T>;
|
|
261
|
+
errors: Ref<Record<string, string[]>>;
|
|
262
|
+
touched: Ref<Record<string, boolean>>;
|
|
263
|
+
/** Per-field async options loading state */
|
|
264
|
+
optionsLoading: Ref<Record<string, boolean>>;
|
|
265
|
+
isDirty: ComputedRef<boolean>;
|
|
266
|
+
isValid: ComputedRef<boolean>;
|
|
267
|
+
isSubmitting: Ref<boolean>;
|
|
268
|
+
submit(): Promise<void>;
|
|
269
|
+
reset(values?: Partial<T>): void;
|
|
270
|
+
setField(path: string, value: unknown): void;
|
|
271
|
+
getField(path: string): unknown;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare type ValidatorFn = (value: unknown, values: Record<string, unknown>) => string | null;
|
|
275
|
+
|
|
276
|
+
export { }
|