@dynamicforms/vue-forms 0.5.1 → 0.6.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/dist/dynamicforms-vue-forms.js +753 -606
- package/dist/dynamicforms-vue-forms.js.map +1 -1
- package/dist/dynamicforms-vue-forms.umd.cjs +2 -2
- package/dist/dynamicforms-vue-forms.umd.cjs.map +1 -1
- package/dist/index.d.cts +663 -0
- package/dist/index.d.ts +163 -93
- package/package.json +24 -8
- package/readme.md +145 -43
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentOptionsMixin } from 'vue';
|
|
2
2
|
import { ComponentProvideOptions } from 'vue';
|
|
3
|
-
import { ComputedRef } from 'vue';
|
|
4
3
|
import { DefineComponent } from 'vue';
|
|
5
4
|
import { PublicProps } from 'vue';
|
|
6
5
|
import { Ref } from 'vue';
|
|
@@ -9,9 +8,7 @@ export declare class AbortEventHandlingException extends Error {
|
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export declare class Action<T extends ActionValue = ActionValue> extends Field<T> {
|
|
12
|
-
constructor(guard?: symbol);
|
|
13
11
|
protected init(params?: Partial<IFieldConstructorParams<T>>): void;
|
|
14
|
-
static create<T extends ActionValue = ActionValue>(params?: Partial<IFieldConstructorParams<T>>): Action<T>;
|
|
15
12
|
get icon(): string | undefined;
|
|
16
13
|
set icon(newValue: string | undefined);
|
|
17
14
|
get label(): string | undefined;
|
|
@@ -19,17 +16,16 @@ export declare class Action<T extends ActionValue = ActionValue> extends Field<T
|
|
|
19
16
|
execute(params: any): void;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
declare type ActionExecutor = (field:
|
|
19
|
+
declare type ActionExecutor = (field: FieldBase, supr: FieldActionExecute, ...params: any[]) => any;
|
|
23
20
|
|
|
24
21
|
export declare class ActionsMap extends Map<symbol, FieldActionExecute> {
|
|
25
22
|
private readonly eagerActions;
|
|
26
23
|
private readonly registeredActions;
|
|
27
24
|
register(action: FieldActionBase): void;
|
|
28
|
-
trigger<T extends FieldActionBase>(ActionClass: {
|
|
29
|
-
new (...args: any[]): T;
|
|
25
|
+
trigger<T extends FieldActionBase>(ActionClass: (abstract new (...args: any[]) => T) & {
|
|
30
26
|
classIdentifier: symbol;
|
|
31
|
-
}, field:
|
|
32
|
-
triggerEager(field:
|
|
27
|
+
}, field: FieldBase, ...params: any[]): any;
|
|
28
|
+
triggerEager(field: FieldBase, ...params: any[]): any;
|
|
33
29
|
clone(): ActionsMap;
|
|
34
30
|
cloneWithoutValidators(): ActionsMap;
|
|
35
31
|
}
|
|
@@ -54,7 +50,7 @@ declare class CompareTo<T = any> extends Validator {
|
|
|
54
50
|
private otherField;
|
|
55
51
|
private isValidComparison;
|
|
56
52
|
private unregistered;
|
|
57
|
-
constructor(otherField:
|
|
53
|
+
constructor(otherField: FieldBase, isValidComparison: (myValue: T, otherValue: T) => boolean, message: RenderContentRef);
|
|
58
54
|
unregister(): void;
|
|
59
55
|
}
|
|
60
56
|
|
|
@@ -62,7 +58,7 @@ export declare class ConditionalEnabledAction extends ConditionalStatementAction
|
|
|
62
58
|
constructor(statement: Statement);
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
declare type ConditionalExecutorFn = (field:
|
|
61
|
+
declare type ConditionalExecutorFn = (field: FieldBase, currentResult: boolean, previousResult: boolean | undefined) => void;
|
|
66
62
|
|
|
67
63
|
export declare class ConditionalStatementAction extends ValueChangedAction {
|
|
68
64
|
private lastResult;
|
|
@@ -70,7 +66,7 @@ export declare class ConditionalStatementAction extends ValueChangedAction {
|
|
|
70
66
|
constructor(statement: Statement, executorFn: ConditionalExecutorFn);
|
|
71
67
|
static get classIdentifier(): symbol;
|
|
72
68
|
get eager(): boolean;
|
|
73
|
-
boundToField(field:
|
|
69
|
+
boundToField(field: FieldBase): void;
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
export declare class ConditionalValueAction<T> extends ConditionalStatementAction {
|
|
@@ -97,67 +93,80 @@ export declare namespace DisplayMode {
|
|
|
97
93
|
export function isDefined(mode: number | string): boolean;
|
|
98
94
|
}
|
|
99
95
|
|
|
100
|
-
export declare const EmptyField: Field<
|
|
96
|
+
export declare const EmptyField: Field<string>;
|
|
101
97
|
|
|
102
98
|
export declare class EnabledChangedAction extends FieldActionBase {
|
|
103
|
-
constructor(executorFn: (field:
|
|
99
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => void);
|
|
104
100
|
static get classIdentifier(): symbol;
|
|
105
|
-
execute(field:
|
|
101
|
+
execute(field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): void;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
104
|
export declare class EnabledChangingAction extends FieldActionBase {
|
|
109
|
-
constructor(executorFn: (field:
|
|
105
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => boolean);
|
|
110
106
|
static get classIdentifier(): symbol;
|
|
111
|
-
execute(field:
|
|
107
|
+
execute(field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): boolean;
|
|
112
108
|
}
|
|
113
109
|
|
|
114
110
|
export declare class ExecuteAction extends FieldActionBase {
|
|
115
|
-
constructor(executorFn: (field:
|
|
111
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, params: any) => any);
|
|
116
112
|
static get classIdentifier(): symbol;
|
|
117
|
-
execute(field:
|
|
113
|
+
execute(field: FieldBase, supr: FieldActionExecute, params: any): any;
|
|
118
114
|
}
|
|
119
115
|
|
|
120
|
-
export declare class Field<T = any> extends FieldBase {
|
|
116
|
+
export declare class Field<T = any> extends FieldBase<T> {
|
|
121
117
|
protected _value: T;
|
|
122
118
|
protected _touched: boolean;
|
|
123
|
-
constructor(
|
|
124
|
-
protected init(params?: Partial<IFieldConstructorParams<T>>): void;
|
|
119
|
+
constructor(params?: Partial<IFieldConstructorParams<T>>);
|
|
125
120
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
121
|
+
* Applies the constructor parameters. It is a hook so that a subclass needing different parameter handling
|
|
122
|
+
* overrides one method instead of redeclaring the constructor - Action does exactly that.
|
|
123
|
+
*
|
|
124
|
+
* It is called from this constructor, so it runs before a subclass's own class field initializers, which
|
|
125
|
+
* only run once super() returns. An override must therefore work off its parameters alone: members the
|
|
126
|
+
* subclass initializes read as undefined inside it, and anything it writes to such a member is overwritten
|
|
127
|
+
* the moment the initializer runs.
|
|
129
128
|
*/
|
|
130
|
-
|
|
129
|
+
protected init(params?: Partial<IFieldConstructorParams<T>>): void;
|
|
131
130
|
get value(): T;
|
|
132
131
|
set value(newValue: T);
|
|
133
132
|
get touched(): boolean;
|
|
134
133
|
set touched(touched: boolean);
|
|
135
|
-
clone(overrides?: Partial<
|
|
134
|
+
clone(overrides?: Partial<IFieldConstructorParams<T>>): this;
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
export declare abstract class FieldActionBase
|
|
137
|
+
export declare abstract class FieldActionBase {
|
|
139
138
|
static get classIdentifier(): symbol;
|
|
140
139
|
get classIdentifier(): symbol;
|
|
141
140
|
private readonly executorFn;
|
|
142
141
|
constructor(executorFn: ActionExecutor);
|
|
143
|
-
execute(field:
|
|
142
|
+
execute(field: FieldBase, supr: FieldActionExecute, ...params: any[]): any;
|
|
144
143
|
get eager(): boolean;
|
|
145
|
-
boundToField(field:
|
|
144
|
+
boundToField(field: FieldBase): void;
|
|
146
145
|
unregister(): void;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
export declare type FieldActionExecute<T = any> = (field:
|
|
148
|
+
export declare type FieldActionExecute<T = any> = (field: FieldBase<T>, ...params: any[]) => any;
|
|
150
149
|
|
|
151
|
-
export declare abstract class FieldBase<T = any>
|
|
150
|
+
export declare abstract class FieldBase<T = any> {
|
|
151
|
+
/**
|
|
152
|
+
* A field is a Vue reactive proxy from construction onwards: the base constructor returns the proxy, and a
|
|
153
|
+
* derived class's `this` is whatever super() returned, so every subclass constructor, field initializer and
|
|
154
|
+
* method sees the proxy. Consequence: plain `field.property = value` is tracked, with no wrapper in between.
|
|
155
|
+
*/
|
|
156
|
+
constructor();
|
|
152
157
|
abstract get value(): T;
|
|
153
158
|
abstract set value(newValue: T);
|
|
154
159
|
abstract get touched(): boolean;
|
|
155
160
|
abstract set touched(touched: boolean);
|
|
156
|
-
|
|
157
|
-
abstract clone(overrides?: Partial<IField<T>>): IField<T>;
|
|
161
|
+
abstract clone(overrides?: Partial<IFieldConstructorParams<T>>): FieldBase<T>;
|
|
158
162
|
originalValue: T;
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
private validatingCount;
|
|
164
|
+
/** true while at least one asynchronous validator is still running for this field */
|
|
165
|
+
get validating(): boolean;
|
|
166
|
+
/** announces the start of one asynchronous validation run; validators pair it with endValidating */
|
|
167
|
+
beginValidating(): void;
|
|
168
|
+
/** announces the end of one asynchronous validation run */
|
|
169
|
+
endValidating(): void;
|
|
161
170
|
protected _valid: boolean;
|
|
162
171
|
errors: ValidationError[];
|
|
163
172
|
parent?: Group;
|
|
@@ -169,17 +178,51 @@ export declare abstract class FieldBase<T = any> implements IField<T> {
|
|
|
169
178
|
private _enabled;
|
|
170
179
|
get enabled(): boolean;
|
|
171
180
|
set enabled(newValue: boolean);
|
|
181
|
+
/**
|
|
182
|
+
* While true, validate() on this field does nothing at all: it neither recomputes _valid nor emits
|
|
183
|
+
* ValidChangedAction, and nothing climbs to the parent. A container that walks its members one by one - assigning
|
|
184
|
+
* them a value, or revalidating them - sets it for the duration of the walk, so a member's upward climb cannot
|
|
185
|
+
* announce the verdict of a half-applied value or of a half-revalidated set, and clears it in a finally block
|
|
186
|
+
* followed by its own validate(). That call recomputes over the finished state and emits the net transition, so
|
|
187
|
+
* the deferral cannot swallow a real change.
|
|
188
|
+
*/
|
|
189
|
+
protected suppressValidation: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* While true, a validity change is still recomputed and still announced on this field, but it is not passed up to
|
|
192
|
+
* the parent: the climb is only remembered and carried out by flushParentValidityClimb(). A setter that notifies
|
|
193
|
+
* the parent of the new value itself holds it over the notifying region, so the parent forms its verdict once,
|
|
194
|
+
* over the finished value, instead of once over the value being replaced and once over the value replacing it.
|
|
195
|
+
*/
|
|
196
|
+
protected suppressParentValidityClimb: boolean;
|
|
197
|
+
private parentValidityClimbPending;
|
|
198
|
+
/** Carries out the climb that a validity change made while suppressParentValidityClimb was held, if there was one. */
|
|
199
|
+
protected flushParentValidityClimb(): void;
|
|
172
200
|
validate(revalidate?: boolean): void;
|
|
173
201
|
get valid(): boolean;
|
|
174
202
|
get fullValue(): any;
|
|
175
203
|
get isChanged(): boolean;
|
|
176
|
-
|
|
177
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Registers the actions a constructor received in its parameters: registration without the eager trigger,
|
|
206
|
+
* because a constructor ends with a single this.actions.triggerEager(...) over the finished value, and an
|
|
207
|
+
* eager action registered here would otherwise also run once per registration, over a half-built field.
|
|
208
|
+
*/
|
|
209
|
+
protected registerInitialActions(actions: FieldActionBase[]): void;
|
|
210
|
+
registerAction(action: FieldActionBase): this;
|
|
211
|
+
triggerAction<T2 extends FieldActionBase>(actionClass: (abstract new (...args: any[]) => T2) & {
|
|
212
|
+
classIdentifier: symbol;
|
|
213
|
+
}, ...params: any[]): any;
|
|
214
|
+
private _validationEpoch;
|
|
215
|
+
/**
|
|
216
|
+
* Generation counter of the validators attached to this field. A Validator reads it when a run starts and drops
|
|
217
|
+
* a result whose epoch no longer matches, so a validation still in flight when clearValidators() is called
|
|
218
|
+
* cannot push an error onto a field that no longer has the validator that produced it.
|
|
219
|
+
*/
|
|
220
|
+
get validationEpoch(): number;
|
|
178
221
|
clearValidators(): void;
|
|
179
222
|
}
|
|
180
223
|
|
|
181
|
-
declare type FieldsToValues<T extends GenericFieldsInterface> = {
|
|
182
|
-
[K in keyof T]: T[K]
|
|
224
|
+
export declare type FieldsToValues<T extends GenericFieldsInterface> = {
|
|
225
|
+
[K in keyof T]: T[K]['value'];
|
|
183
226
|
};
|
|
184
227
|
|
|
185
228
|
declare namespace Form {
|
|
@@ -210,16 +253,18 @@ declare namespace Form {
|
|
|
210
253
|
Field,
|
|
211
254
|
NullableField,
|
|
212
255
|
EmptyField,
|
|
213
|
-
IField,
|
|
214
256
|
IFieldConstructorActionsList,
|
|
215
257
|
IFieldConstructorParams,
|
|
216
258
|
AbortEventHandlingException,
|
|
217
259
|
FieldActionExecute,
|
|
218
|
-
IFieldAction,
|
|
219
260
|
FieldBase,
|
|
220
261
|
GenericFieldsInterface,
|
|
262
|
+
FieldsToValues,
|
|
263
|
+
GroupValue,
|
|
264
|
+
GroupValueInput,
|
|
221
265
|
Group,
|
|
222
266
|
NullableGroup,
|
|
267
|
+
ListValue,
|
|
223
268
|
List,
|
|
224
269
|
NullableList,
|
|
225
270
|
Validators,
|
|
@@ -253,61 +298,63 @@ declare interface FormsConfig {
|
|
|
253
298
|
useMarkdownInValidators: boolean;
|
|
254
299
|
}
|
|
255
300
|
|
|
256
|
-
export declare type GenericFieldsInterface = Record<string,
|
|
301
|
+
export declare type GenericFieldsInterface = Record<string, FieldBase>;
|
|
257
302
|
|
|
258
|
-
export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {
|
|
303
|
+
export declare class Group<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase<GroupValue<T>> {
|
|
259
304
|
private readonly _fields;
|
|
260
305
|
private _value;
|
|
261
|
-
readonly reactiveValue: ComputedRef<FieldsToValues<T> | null>;
|
|
262
306
|
private suppressNotifyValueChanged;
|
|
263
|
-
constructor(fields: T, params?: Partial<IFieldConstructorParams
|
|
307
|
+
constructor(fields: T, params?: Partial<IFieldConstructorParams<GroupValueInput<T>>>);
|
|
264
308
|
private addField;
|
|
265
309
|
private static isValidFields;
|
|
266
310
|
static createFromFormData(data: Record<string, any> | null): Group;
|
|
267
311
|
field<K extends keyof T>(fieldName: K): T[K] | null;
|
|
268
312
|
get fields(): T;
|
|
269
|
-
get value():
|
|
270
|
-
|
|
313
|
+
get value(): GroupValue<T>;
|
|
314
|
+
/**
|
|
315
|
+
* Writes the members that the given value carries, without letting any single member announce the state in
|
|
316
|
+
* between: the group's own value notification and its own validation are both held back for the duration, so
|
|
317
|
+
* neither a ValueChangedAction nor a ValidChangedAction reports a verdict over a half-applied value. The
|
|
318
|
+
* caller decides what to announce once the whole value is in place. Both flags are restored to what they were,
|
|
319
|
+
* so a caller that is itself holding the group back stays in charge.
|
|
320
|
+
*/
|
|
321
|
+
private assignMembers;
|
|
322
|
+
set value(newValue: GroupValueInput<T>);
|
|
271
323
|
get touched(): boolean;
|
|
272
324
|
set touched(touched: boolean);
|
|
273
325
|
get fullValue(): Record<string, any>;
|
|
274
326
|
notifyValueChanged(): void;
|
|
275
327
|
get valid(): boolean;
|
|
276
328
|
validate(revalidate?: boolean): void;
|
|
277
|
-
clone(overrides?: Partial<
|
|
329
|
+
clone(overrides?: Partial<IFieldConstructorParams<GroupValueInput<T>>>): Group<T>;
|
|
278
330
|
}
|
|
279
331
|
|
|
280
|
-
|
|
332
|
+
/** what Group.value reads back: the full field map, or null when no field serializes */
|
|
333
|
+
export declare type GroupValue<T extends GenericFieldsInterface> = FieldsToValues<T> | null;
|
|
334
|
+
|
|
335
|
+
/** what Group.value and the Group constructor accept: keys left out are simply not assigned */
|
|
336
|
+
export declare type GroupValueInput<T extends GenericFieldsInterface> = Partial<FieldsToValues<T>> | null;
|
|
337
|
+
|
|
338
|
+
export declare interface IFieldConstructorActionsList {
|
|
339
|
+
actions?: FieldActionBase[];
|
|
340
|
+
validators?: FieldActionBase[];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Parameters accepted by field constructors and by clone overrides.
|
|
345
|
+
*
|
|
346
|
+
* Only writable members are listed. valid, validating, fullValue and isChanged are getter-only, so assigning
|
|
347
|
+
* them throws a TypeError. parent and fieldName are set by the container: until a Group or List installs them
|
|
348
|
+
* as non-configurable accessors, assigning them is silently accepted, which is why the type rejects them.
|
|
349
|
+
*/
|
|
350
|
+
export declare type IFieldConstructorParams<T = any> = {
|
|
281
351
|
value: T;
|
|
282
|
-
reactiveValue: ComputedRef<T>;
|
|
283
|
-
fullValue: T;
|
|
284
352
|
originalValue: T;
|
|
285
|
-
valid: boolean;
|
|
286
|
-
validating: boolean;
|
|
287
|
-
errors: ValidationError[];
|
|
288
353
|
enabled: boolean;
|
|
289
354
|
visibility: DisplayMode;
|
|
290
355
|
touched: boolean;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
clone(overrides?: Partial<IField<T>>): IField<T>;
|
|
294
|
-
registerAction(action: IFieldAction<T>): this;
|
|
295
|
-
triggerAction<T2 extends IFieldAction<T>>(actionClass: abstract new (...args: any[]) => T2, ...params: any[]): any;
|
|
296
|
-
validate(revalidate?: boolean): void;
|
|
297
|
-
clearValidators(): void;
|
|
298
|
-
isChanged: boolean;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export declare interface IFieldAction<T = any> {
|
|
302
|
-
execute(field: IField<T>, supr: FieldActionExecute<T>, ...params: any[]): any;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export declare interface IFieldConstructorActionsList<T = any> {
|
|
306
|
-
actions?: IFieldAction<T>[];
|
|
307
|
-
validators?: IFieldAction<T>[];
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export declare type IFieldConstructorParams<T = any> = IField<T> & IFieldConstructorActionsList<T>;
|
|
356
|
+
errors: ValidationError[];
|
|
357
|
+
} & IFieldConstructorActionsList;
|
|
311
358
|
|
|
312
359
|
declare class InAllowedValues<T = any> extends Validator {
|
|
313
360
|
constructor(allowedValues: T[], message?: RenderContentRef);
|
|
@@ -326,18 +373,23 @@ declare class LengthInRange<T = any> extends Validator {
|
|
|
326
373
|
constructor(minLength: number, maxLength: number, message?: RenderContentRef);
|
|
327
374
|
}
|
|
328
375
|
|
|
329
|
-
export declare class List<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase {
|
|
376
|
+
export declare class List<T extends GenericFieldsInterface = GenericFieldsInterface> extends FieldBase<ListValue> {
|
|
330
377
|
private _value;
|
|
331
378
|
private _itemTemplate?;
|
|
332
379
|
private _previousValue;
|
|
333
|
-
constructor(itemTemplate?: Group<T>, params?: Partial<IFieldConstructorParams
|
|
380
|
+
constructor(itemTemplate?: Group<T>, params?: Partial<IFieldConstructorParams<ListValue>>);
|
|
334
381
|
private processSetValueItem;
|
|
382
|
+
/**
|
|
383
|
+
* Builds the item that fills a gap left by an insert beyond the end of the list: a copy of the item template with
|
|
384
|
+
* the template's own values, or an empty group when the list has no template.
|
|
385
|
+
*/
|
|
386
|
+
private createPaddingItem;
|
|
335
387
|
private setValueInternal;
|
|
336
|
-
get value():
|
|
388
|
+
get value(): ListValue;
|
|
337
389
|
set value(newValue: Record<string, any>[]);
|
|
338
390
|
get touched(): boolean;
|
|
339
391
|
set touched(touched: boolean);
|
|
340
|
-
clone(overrides?: Partial<
|
|
392
|
+
clone(overrides?: Partial<IFieldConstructorParams<ListValue>>): List<T>;
|
|
341
393
|
notifyValueChanged(): void;
|
|
342
394
|
get valid(): boolean;
|
|
343
395
|
validate(revalidate?: boolean): void;
|
|
@@ -350,17 +402,20 @@ export declare class List<T extends GenericFieldsInterface = GenericFieldsInterf
|
|
|
350
402
|
}
|
|
351
403
|
|
|
352
404
|
export declare class ListItemAddedAction extends FieldActionBase {
|
|
353
|
-
constructor(executorFn: (field:
|
|
405
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, item: any, index: number) => void);
|
|
354
406
|
static get classIdentifier(): symbol;
|
|
355
|
-
execute(field:
|
|
407
|
+
execute(field: FieldBase, supr: FieldActionExecute, item: any, index: number): void;
|
|
356
408
|
}
|
|
357
409
|
|
|
358
410
|
export declare class ListItemRemovedAction extends FieldActionBase {
|
|
359
|
-
constructor(executorFn: (field:
|
|
411
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, item: any, index: number) => void);
|
|
360
412
|
static get classIdentifier(): symbol;
|
|
361
|
-
execute(field:
|
|
413
|
+
execute(field: FieldBase, supr: FieldActionExecute, item: any, index: number): void;
|
|
362
414
|
}
|
|
363
415
|
|
|
416
|
+
/** what List.value reads back: one plain object per item, or null when the list is empty */
|
|
417
|
+
export declare type ListValue = Record<string, any>[] | null;
|
|
418
|
+
|
|
364
419
|
declare class MaxLength<T = any> extends Validator {
|
|
365
420
|
constructor(maxLength: number, message?: RenderContentRef);
|
|
366
421
|
}
|
|
@@ -396,7 +451,7 @@ export declare type NullableGroup = Group | null;
|
|
|
396
451
|
|
|
397
452
|
export declare type NullableList = List | null;
|
|
398
453
|
|
|
399
|
-
export declare type OperandType = any | Statement |
|
|
454
|
+
export declare type OperandType = any | Statement | FieldBase;
|
|
400
455
|
|
|
401
456
|
/**
|
|
402
457
|
* Operators provides us a functionality for backend to send us complex condition upon which we send
|
|
@@ -482,7 +537,7 @@ export declare class Statement {
|
|
|
482
537
|
* Recursively collects all fields used in this statement and its nested statements
|
|
483
538
|
* @returns A set of all fields used in this statement
|
|
484
539
|
*/
|
|
485
|
-
collectFields(): Set<
|
|
540
|
+
collectFields(): Set<FieldBase>;
|
|
486
541
|
}
|
|
487
542
|
|
|
488
543
|
/**
|
|
@@ -523,7 +578,7 @@ export declare class ValidationErrorText extends ValidationError {
|
|
|
523
578
|
get extraClasses(): ClassTypes;
|
|
524
579
|
}
|
|
525
580
|
|
|
526
|
-
export declare type ValidationFunction<T = any> = (newValue: T, oldValue: T, field:
|
|
581
|
+
export declare type ValidationFunction<T = any> = (newValue: T, oldValue: T, field: FieldBase<T>) => ValidationFunctionResult | Promise<ValidationFunctionResult>;
|
|
527
582
|
|
|
528
583
|
export declare type ValidationFunctionResult = ValidationError[] | null;
|
|
529
584
|
|
|
@@ -533,11 +588,26 @@ export declare type ValidationFunctionResult = ValidationError[] | null;
|
|
|
533
588
|
*/
|
|
534
589
|
export declare class Validator<T = any> extends ValueChangedAction {
|
|
535
590
|
private readonly source;
|
|
591
|
+
/**
|
|
592
|
+
* Sequence number of the newest run of this validator, per field. Every execution takes the next number, and a
|
|
593
|
+
* result is applied only while its number is still the newest one, so a slow run cannot overwrite the verdict of
|
|
594
|
+
* a faster one that started after it. The key is the field because one validator instance may be registered on
|
|
595
|
+
* several fields, each with a sequence of its own.
|
|
596
|
+
*/
|
|
597
|
+
private readonly runs;
|
|
536
598
|
/**
|
|
537
599
|
* Creates a new validator
|
|
538
600
|
* @param validationFn Function that validates the field value and returns errors or null
|
|
539
601
|
*/
|
|
540
602
|
constructor(validationFn: ValidationFunction<T>);
|
|
603
|
+
/**
|
|
604
|
+
* Returns the error instance this validator owns and may later withdraw: the argument itself when it carries no
|
|
605
|
+
* ownership stamp or already carries this validator's, a copy of it when it belongs to another validator. The
|
|
606
|
+
* stamp is not configurable, so an instance one validator owns can never be reassigned to another; the copy is
|
|
607
|
+
* what makes an error instance shareable between validators, and it keeps the prototype and every own property,
|
|
608
|
+
* including the non-enumerable ones, so it renders exactly like the instance it was made from.
|
|
609
|
+
*/
|
|
610
|
+
private claim;
|
|
541
611
|
static get classIdentifier(): symbol;
|
|
542
612
|
get eager(): boolean;
|
|
543
613
|
protected replacePlaceholdersFunction(text: RenderContentRef, replace: Record<string, any>): RenderContentRef;
|
|
@@ -563,15 +633,15 @@ export declare namespace Validators {
|
|
|
563
633
|
}
|
|
564
634
|
|
|
565
635
|
export declare class ValidChangedAction extends FieldActionBase {
|
|
566
|
-
constructor(executorFn: (field:
|
|
636
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean) => void);
|
|
567
637
|
static get classIdentifier(): symbol;
|
|
568
|
-
execute(field:
|
|
638
|
+
execute(field: FieldBase, supr: FieldActionExecute, newValue: boolean, oldValue: boolean): void;
|
|
569
639
|
}
|
|
570
640
|
|
|
571
641
|
export declare class ValueChangedAction<T = any> extends FieldActionBase {
|
|
572
|
-
constructor(executorFn: (field:
|
|
642
|
+
constructor(executorFn: (field: FieldBase<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T) => void);
|
|
573
643
|
static get classIdentifier(): symbol;
|
|
574
|
-
execute(field:
|
|
644
|
+
execute(field: FieldBase<T>, supr: FieldActionExecute<T>, newValue: T, oldValue: T): void;
|
|
575
645
|
}
|
|
576
646
|
|
|
577
647
|
declare class ValueInRange<T = any> extends Validator {
|
|
@@ -579,15 +649,15 @@ declare class ValueInRange<T = any> extends Validator {
|
|
|
579
649
|
}
|
|
580
650
|
|
|
581
651
|
export declare class VisibilityChangedAction extends FieldActionBase {
|
|
582
|
-
constructor(executorFn: (field:
|
|
652
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode) => void);
|
|
583
653
|
static get classIdentifier(): symbol;
|
|
584
|
-
execute(field:
|
|
654
|
+
execute(field: FieldBase, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode): void;
|
|
585
655
|
}
|
|
586
656
|
|
|
587
657
|
export declare class VisibilityChangingAction extends FieldActionBase {
|
|
588
|
-
constructor(executorFn: (field:
|
|
658
|
+
constructor(executorFn: (field: FieldBase, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode) => DisplayMode);
|
|
589
659
|
static get classIdentifier(): symbol;
|
|
590
|
-
execute(field:
|
|
660
|
+
execute(field: FieldBase, supr: FieldActionExecute, newValue: DisplayMode, oldValue: DisplayMode): DisplayMode;
|
|
591
661
|
}
|
|
592
662
|
|
|
593
663
|
export { }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamicforms/vue-forms",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A lightweight Vue.js library for form state management with built-in validation, conditional logic, nested structures, and a rich event system. UI-agnostic and TypeScript-first.",
|
|
7
7
|
"author": "Jure Erznožnik",
|
|
@@ -12,17 +12,27 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/dynamicforms-vue-forms.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/dynamicforms-vue-forms.umd.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"./style.css": "./dist/dynamicforms-vue-forms.css",
|
|
25
|
+
"./package.json": "./package.json"
|
|
18
26
|
},
|
|
19
27
|
"workspaces": [
|
|
20
28
|
"docs"
|
|
21
29
|
],
|
|
22
30
|
"scripts": {
|
|
23
|
-
"build": "vite build",
|
|
31
|
+
"build": "vite build && node -e \"require('fs').copyFileSync('dist/index.d.ts', 'dist/index.d.cts')\"",
|
|
32
|
+
"prepack": "npm run build",
|
|
24
33
|
"test": "vitest run --coverage",
|
|
25
34
|
"lint": "eslint src --fix && vue-tsc --noEmit",
|
|
35
|
+
"lint:ci": "eslint src && vue-tsc --noEmit",
|
|
26
36
|
"docs:dev": "npm run docs:dev -w docs",
|
|
27
37
|
"docs:build": "npm run docs:build -w docs",
|
|
28
38
|
"docs:preview": "npm run docs:preview -w docs"
|
|
@@ -43,13 +53,19 @@
|
|
|
43
53
|
"homepage": "https://docs.velis.si/dynamicforms/vue-forms",
|
|
44
54
|
"repository": {
|
|
45
55
|
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/
|
|
56
|
+
"url": "git+https://github.com/dynamicforms/vue-forms.git"
|
|
47
57
|
},
|
|
48
58
|
"bugs": {
|
|
49
|
-
"url": "https://github.com/
|
|
59
|
+
"url": "https://github.com/dynamicforms/vue-forms/issues"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"lodash": "^4.17.21",
|
|
66
|
+
"lodash-es": "^4.17.21"
|
|
50
67
|
},
|
|
51
68
|
"peerDependencies": {
|
|
52
|
-
"lodash-es": "^4.17.12",
|
|
53
69
|
"vue": "^3.4"
|
|
54
70
|
},
|
|
55
71
|
"devDependencies": {
|