@regle/core 1.9.8 → 1.10.0
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/regle-core.d.ts +200 -1392
- package/dist/regle-core.js +105 -13
- package/dist/regle-core.min.js +1 -1
- package/package.json +6 -6
package/dist/regle-core.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as vue0 from "vue";
|
|
2
2
|
import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
3
|
+
import { EmptyObject, IsAny, IsEmptyObject, IsUnion, IsUnknown, Merge, Or, PartialDeep, RequireOneOrNone, RequiredDeep, UnionToIntersection, UnionToTuple } from "type-fest";
|
|
4
|
+
import { IsUnion as IsUnion$1 } from "expect-type";
|
|
3
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
6
|
|
|
5
7
|
//#region src/types/utils/misc.types.d.ts
|
|
@@ -10,1179 +12,22 @@ type MaybeOutput<T = any> = T | undefined;
|
|
|
10
12
|
type MaybeReadonly<T> = T | Readonly<T>;
|
|
11
13
|
type NonUndefined<T> = Exclude<T, undefined>;
|
|
12
14
|
type PromiseReturn<T> = T extends Promise<infer U> ? U : T;
|
|
13
|
-
type MaybeGetter<T, V = any, TAdd extends Record<string, any> = {}> = T | ((value: Ref<V>, index: number) => T & TAdd);
|
|
15
|
+
type MaybeGetter<T, V$1 = any, TAdd extends Record<string, any> = {}> = T | ((value: Ref<V$1>, index: number) => T & TAdd);
|
|
14
16
|
type Unwrap<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
15
17
|
type UnwrapSimple<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : T extends ((...args: any[]) => infer U) ? U : T;
|
|
16
18
|
type ExtractFromGetter<T extends MaybeGetter<any, any, any>> = T extends ((value: Ref<any>, index: number) => infer U extends Record<string, any>) ? U : T;
|
|
17
19
|
type ExtendOnlyRealRecord<T extends unknown> = NonNullable<T> extends File | Date ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
18
|
-
type OmitByType<T extends Record<string, any>, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] };
|
|
20
|
+
type OmitByType<T extends Record<string, any>, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T[K] };
|
|
19
21
|
type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]: MaybeRef<T[K]> };
|
|
20
|
-
type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K] };
|
|
22
|
+
type ExcludeByType<T, U$1> = { [K in keyof T as T[K] extends U$1 ? never : K]: T[K] extends U$1 ? never : T[K] };
|
|
21
23
|
type PrimitiveTypes = string | number | boolean | bigint | Date | File;
|
|
22
24
|
type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
23
|
-
type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
25
|
+
type NoInferLegacy<A$1 extends any> = [A$1][A$1 extends any ? 0 : never];
|
|
24
26
|
//#endregion
|
|
25
27
|
//#region src/types/utils/Array.types.d.ts
|
|
26
28
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
27
29
|
type NonEmptyTuple<T> = [T, ...T[]] | T[];
|
|
28
30
|
//#endregion
|
|
29
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/primitive.d.ts
|
|
30
|
-
/**
|
|
31
|
-
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
32
|
-
|
|
33
|
-
@category Type
|
|
34
|
-
*/
|
|
35
|
-
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
38
|
-
/**
|
|
39
|
-
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
40
|
-
|
|
41
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
42
|
-
|
|
43
|
-
@example
|
|
44
|
-
```
|
|
45
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
46
|
-
|
|
47
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
48
|
-
|
|
49
|
-
type Intersection = UnionToIntersection<Union>;
|
|
50
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
A more applicable example which could make its way into your library code follows.
|
|
54
|
-
|
|
55
|
-
@example
|
|
56
|
-
```
|
|
57
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
58
|
-
|
|
59
|
-
class CommandOne {
|
|
60
|
-
commands: {
|
|
61
|
-
a1: () => undefined,
|
|
62
|
-
b1: () => undefined,
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
class CommandTwo {
|
|
67
|
-
commands: {
|
|
68
|
-
a2: (argA: string) => undefined,
|
|
69
|
-
b2: (argB: string) => undefined,
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
74
|
-
type Union = typeof union;
|
|
75
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
76
|
-
|
|
77
|
-
type Intersection = UnionToIntersection<Union>;
|
|
78
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
@category Type
|
|
82
|
-
*/
|
|
83
|
-
type UnionToIntersection<Union> = (
|
|
84
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
85
|
-
// `Union` into a [distributive conditional
|
|
86
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
87
|
-
Union extends unknown
|
|
88
|
-
// The union type is used as the only argument to a function since the union
|
|
89
|
-
// of function arguments is an intersection.
|
|
90
|
-
? (distributedUnion: Union) => void
|
|
91
|
-
// This won't happen.
|
|
92
|
-
: never
|
|
93
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
94
|
-
// arguments of unions of functions as an intersection of the union.
|
|
95
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
96
|
-
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
97
|
-
? Intersection & Union : never;
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/empty-object.d.ts
|
|
100
|
-
declare const emptyObjectSymbol: unique symbol;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
Represents a strictly empty plain object, the `{}` value.
|
|
104
|
-
|
|
105
|
-
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
|
|
106
|
-
|
|
107
|
-
@example
|
|
108
|
-
```
|
|
109
|
-
import type {EmptyObject} from 'type-fest';
|
|
110
|
-
|
|
111
|
-
// The following illustrates the problem with `{}`.
|
|
112
|
-
const foo1: {} = {}; // Pass
|
|
113
|
-
const foo2: {} = []; // Pass
|
|
114
|
-
const foo3: {} = 42; // Pass
|
|
115
|
-
const foo4: {} = {a: 1}; // Pass
|
|
116
|
-
|
|
117
|
-
// With `EmptyObject` only the first case is valid.
|
|
118
|
-
const bar1: EmptyObject = {}; // Pass
|
|
119
|
-
const bar2: EmptyObject = 42; // Fail
|
|
120
|
-
const bar3: EmptyObject = []; // Fail
|
|
121
|
-
const bar4: EmptyObject = {a: 1}; // Fail
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
|
|
125
|
-
|
|
126
|
-
@category Object
|
|
127
|
-
*/
|
|
128
|
-
type EmptyObject = {
|
|
129
|
-
[emptyObjectSymbol]?: never;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
Returns a `boolean` for whether the type is strictly equal to an empty plain object, the `{}` value.
|
|
133
|
-
|
|
134
|
-
@example
|
|
135
|
-
```
|
|
136
|
-
import type {IsEmptyObject} from 'type-fest';
|
|
137
|
-
|
|
138
|
-
type Pass = IsEmptyObject<{}>; //=> true
|
|
139
|
-
type Fail = IsEmptyObject<[]>; //=> false
|
|
140
|
-
type Fail = IsEmptyObject<null>; //=> false
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
@see EmptyObject
|
|
144
|
-
@category Object
|
|
145
|
-
*/
|
|
146
|
-
type IsEmptyObject<T> = T extends EmptyObject ? true : false;
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-any.d.ts
|
|
149
|
-
/**
|
|
150
|
-
Returns a boolean for whether the given type is `any`.
|
|
151
|
-
|
|
152
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
153
|
-
|
|
154
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
155
|
-
|
|
156
|
-
@example
|
|
157
|
-
```
|
|
158
|
-
import type {IsAny} from 'type-fest';
|
|
159
|
-
|
|
160
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
161
|
-
const anyObject: any = {a: 1, b: 2};
|
|
162
|
-
|
|
163
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
164
|
-
return obj[key];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const typedA = get(typedObject, 'a');
|
|
168
|
-
//=> 1
|
|
169
|
-
|
|
170
|
-
const anyA = get(anyObject, 'a');
|
|
171
|
-
//=> any
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
@category Type Guard
|
|
175
|
-
@category Utilities
|
|
176
|
-
*/
|
|
177
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
180
|
-
/**
|
|
181
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
182
|
-
|
|
183
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
184
|
-
|
|
185
|
-
@example
|
|
186
|
-
```
|
|
187
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
188
|
-
|
|
189
|
-
interface User {
|
|
190
|
-
name: string;
|
|
191
|
-
surname: string;
|
|
192
|
-
|
|
193
|
-
luckyNumber?: number;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
interface Admin {
|
|
197
|
-
name: string;
|
|
198
|
-
surname?: string;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
202
|
-
//=> true
|
|
203
|
-
|
|
204
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
205
|
-
//=> false
|
|
206
|
-
|
|
207
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
208
|
-
//=> boolean
|
|
209
|
-
|
|
210
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
211
|
-
//=> false
|
|
212
|
-
|
|
213
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
214
|
-
//=> boolean
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
@category Type Guard
|
|
218
|
-
@category Utilities
|
|
219
|
-
*/
|
|
220
|
-
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
223
|
-
/**
|
|
224
|
-
Extract all optional keys from the given type.
|
|
225
|
-
|
|
226
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
227
|
-
|
|
228
|
-
@example
|
|
229
|
-
```
|
|
230
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
231
|
-
|
|
232
|
-
interface User {
|
|
233
|
-
name: string;
|
|
234
|
-
surname: string;
|
|
235
|
-
|
|
236
|
-
luckyNumber?: number;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
240
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
241
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const update1: UpdateOperation<User> = {
|
|
245
|
-
name: 'Alice'
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const update2: UpdateOperation<User> = {
|
|
249
|
-
name: 'Bob',
|
|
250
|
-
luckyNumber: REMOVE_FIELD
|
|
251
|
-
};
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
@category Utilities
|
|
255
|
-
*/
|
|
256
|
-
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
257
|
-
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
258
|
-
: never;
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
261
|
-
/**
|
|
262
|
-
Extract all required keys from the given type.
|
|
263
|
-
|
|
264
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
265
|
-
|
|
266
|
-
@example
|
|
267
|
-
```
|
|
268
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
269
|
-
|
|
270
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
271
|
-
|
|
272
|
-
interface User {
|
|
273
|
-
name: string;
|
|
274
|
-
surname: string;
|
|
275
|
-
|
|
276
|
-
luckyNumber?: number;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
280
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
@category Utilities
|
|
284
|
-
*/
|
|
285
|
-
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
286
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-never.d.ts
|
|
289
|
-
/**
|
|
290
|
-
Returns a boolean for whether the given type is `never`.
|
|
291
|
-
|
|
292
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
293
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
294
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
295
|
-
|
|
296
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
297
|
-
|
|
298
|
-
@example
|
|
299
|
-
```
|
|
300
|
-
import type {IsNever, And} from 'type-fest';
|
|
301
|
-
|
|
302
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
303
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
304
|
-
And<
|
|
305
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
306
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
307
|
-
>;
|
|
308
|
-
|
|
309
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
310
|
-
AreStringsEqual<I, O> extends true
|
|
311
|
-
? never
|
|
312
|
-
: void;
|
|
313
|
-
|
|
314
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
315
|
-
if (input === output) {
|
|
316
|
-
process.exit(0);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
endIfEqual('abc', 'abc');
|
|
321
|
-
//=> never
|
|
322
|
-
|
|
323
|
-
endIfEqual('abc', '123');
|
|
324
|
-
//=> void
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
@category Type Guard
|
|
328
|
-
@category Utilities
|
|
329
|
-
*/
|
|
330
|
-
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/if.d.ts
|
|
333
|
-
/**
|
|
334
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
335
|
-
|
|
336
|
-
Use-cases:
|
|
337
|
-
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
338
|
-
|
|
339
|
-
Note:
|
|
340
|
-
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
341
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
342
|
-
|
|
343
|
-
@example
|
|
344
|
-
```
|
|
345
|
-
import {If} from 'type-fest';
|
|
346
|
-
|
|
347
|
-
type A = If<true, 'yes', 'no'>;
|
|
348
|
-
//=> 'yes'
|
|
349
|
-
|
|
350
|
-
type B = If<false, 'yes', 'no'>;
|
|
351
|
-
//=> 'no'
|
|
352
|
-
|
|
353
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
354
|
-
//=> 'yes' | 'no'
|
|
355
|
-
|
|
356
|
-
type D = If<any, 'yes', 'no'>;
|
|
357
|
-
//=> 'yes' | 'no'
|
|
358
|
-
|
|
359
|
-
type E = If<never, 'yes', 'no'>;
|
|
360
|
-
//=> 'no'
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
@example
|
|
364
|
-
```
|
|
365
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
366
|
-
|
|
367
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
368
|
-
//=> 'not any'
|
|
369
|
-
|
|
370
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
371
|
-
//=> 'is never'
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
@example
|
|
375
|
-
```
|
|
376
|
-
import {If, IsEqual} from 'type-fest';
|
|
377
|
-
|
|
378
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
379
|
-
|
|
380
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
381
|
-
//=> 'equal'
|
|
382
|
-
|
|
383
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
384
|
-
//=> 'not equal'
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
@category Type Guard
|
|
388
|
-
@category Utilities
|
|
389
|
-
*/
|
|
390
|
-
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever$1<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/type.d.ts
|
|
393
|
-
/**
|
|
394
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
395
|
-
*/
|
|
396
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
397
|
-
/**
|
|
398
|
-
Test if the given function has multiple call signatures.
|
|
399
|
-
|
|
400
|
-
Needed to handle the case of a single call signature with properties.
|
|
401
|
-
|
|
402
|
-
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
403
|
-
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
404
|
-
*/
|
|
405
|
-
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
406
|
-
(...arguments_: infer A): unknown;
|
|
407
|
-
(...arguments_: infer B): unknown;
|
|
408
|
-
} ? B extends A ? A extends B ? false : true : true : false;
|
|
409
|
-
/**
|
|
410
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
411
|
-
|
|
412
|
-
@example
|
|
413
|
-
```
|
|
414
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
415
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
416
|
-
//=> 'VALID'
|
|
417
|
-
|
|
418
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
419
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
420
|
-
//=> 'IS_ANY'
|
|
421
|
-
|
|
422
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
423
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
424
|
-
//=> 'IS_NEVER'
|
|
425
|
-
```
|
|
426
|
-
*/
|
|
427
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever$1<T>, IfNever, IfNotAnyOrNever>>;
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-null.d.ts
|
|
430
|
-
/**
|
|
431
|
-
Returns a boolean for whether the given type is `null`.
|
|
432
|
-
|
|
433
|
-
@example
|
|
434
|
-
```
|
|
435
|
-
import type {IsNull} from 'type-fest';
|
|
436
|
-
|
|
437
|
-
type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
|
|
438
|
-
|
|
439
|
-
type Example1 = NonNullFallback<null, string>;
|
|
440
|
-
//=> string
|
|
441
|
-
|
|
442
|
-
type Example2 = NonNullFallback<number, string>;
|
|
443
|
-
//=? number
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
@category Type Guard
|
|
447
|
-
@category Utilities
|
|
448
|
-
*/
|
|
449
|
-
type IsNull<T> = [T] extends [null] ? true : false;
|
|
450
|
-
//#endregion
|
|
451
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
452
|
-
/**
|
|
453
|
-
Returns a boolean for whether the given type is `unknown`.
|
|
454
|
-
|
|
455
|
-
@link https://github.com/dsherret/conditional-type-checks/pull/16
|
|
456
|
-
|
|
457
|
-
Useful in type utilities, such as when dealing with unknown data from API calls.
|
|
458
|
-
|
|
459
|
-
@example
|
|
460
|
-
```
|
|
461
|
-
import type {IsUnknown} from 'type-fest';
|
|
462
|
-
|
|
463
|
-
// https://github.com/pajecawav/tiny-global-store/blob/master/src/index.ts
|
|
464
|
-
type Action<TState, TPayload = void> =
|
|
465
|
-
IsUnknown<TPayload> extends true
|
|
466
|
-
? (state: TState) => TState,
|
|
467
|
-
: (state: TState, payload: TPayload) => TState;
|
|
468
|
-
|
|
469
|
-
class Store<TState> {
|
|
470
|
-
constructor(private state: TState) {}
|
|
471
|
-
|
|
472
|
-
execute<TPayload = void>(action: Action<TState, TPayload>, payload?: TPayload): TState {
|
|
473
|
-
this.state = action(this.state, payload);
|
|
474
|
-
return this.state;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// ... other methods
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const store = new Store({value: 1});
|
|
481
|
-
declare const someExternalData: unknown;
|
|
482
|
-
|
|
483
|
-
store.execute(state => ({value: state.value + 1}));
|
|
484
|
-
//=> `TPayload` is `void`
|
|
485
|
-
|
|
486
|
-
store.execute((state, payload) => ({value: state.value + payload}), 5);
|
|
487
|
-
//=> `TPayload` is `5`
|
|
488
|
-
|
|
489
|
-
store.execute((state, payload) => ({value: state.value + payload}), someExternalData);
|
|
490
|
-
//=> Errors: `action` is `(state: TState) => TState`
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
@category Utilities
|
|
494
|
-
*/
|
|
495
|
-
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
496
|
-
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
497
|
-
? true : false : false);
|
|
498
|
-
//#endregion
|
|
499
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
500
|
-
/**
|
|
501
|
-
Disallows any of the given keys.
|
|
502
|
-
*/
|
|
503
|
-
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
504
|
-
//#endregion
|
|
505
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/simplify.d.ts
|
|
506
|
-
/**
|
|
507
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
508
|
-
|
|
509
|
-
@example
|
|
510
|
-
```
|
|
511
|
-
import type {Simplify} from 'type-fest';
|
|
512
|
-
|
|
513
|
-
type PositionProps = {
|
|
514
|
-
top: number;
|
|
515
|
-
left: number;
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
type SizeProps = {
|
|
519
|
-
width: number;
|
|
520
|
-
height: number;
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
524
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
528
|
-
|
|
529
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
530
|
-
|
|
531
|
-
@example
|
|
532
|
-
```
|
|
533
|
-
import type {Simplify} from 'type-fest';
|
|
534
|
-
|
|
535
|
-
interface SomeInterface {
|
|
536
|
-
foo: number;
|
|
537
|
-
bar?: string;
|
|
538
|
-
baz: number | undefined;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
type SomeType = {
|
|
542
|
-
foo: number;
|
|
543
|
-
bar?: string;
|
|
544
|
-
baz: number | undefined;
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
548
|
-
const someType: SomeType = literal;
|
|
549
|
-
const someInterface: SomeInterface = literal;
|
|
550
|
-
|
|
551
|
-
function fn(object: Record<string, unknown>): void {}
|
|
552
|
-
|
|
553
|
-
fn(literal); // Good: literal object type is sealed
|
|
554
|
-
fn(someType); // Good: type is sealed
|
|
555
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
556
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
560
|
-
@see SimplifyDeep
|
|
561
|
-
@category Object
|
|
562
|
-
*/
|
|
563
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
564
|
-
//#endregion
|
|
565
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
566
|
-
/**
|
|
567
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
568
|
-
|
|
569
|
-
This is the counterpart of `PickIndexSignature`.
|
|
570
|
-
|
|
571
|
-
Use-cases:
|
|
572
|
-
- Remove overly permissive signatures from third-party types.
|
|
573
|
-
|
|
574
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
575
|
-
|
|
576
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
577
|
-
|
|
578
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
579
|
-
|
|
580
|
-
```
|
|
581
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
582
|
-
|
|
583
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
584
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
588
|
-
|
|
589
|
-
```
|
|
590
|
-
type Indexed = {} extends Record<string, unknown>
|
|
591
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
592
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
593
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
594
|
-
|
|
595
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
596
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
597
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
598
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
599
|
-
```
|
|
600
|
-
|
|
601
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
602
|
-
|
|
603
|
-
```
|
|
604
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
605
|
-
|
|
606
|
-
type OmitIndexSignature<ObjectType> = {
|
|
607
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
608
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
609
|
-
};
|
|
610
|
-
```
|
|
611
|
-
|
|
612
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
613
|
-
|
|
614
|
-
```
|
|
615
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
616
|
-
|
|
617
|
-
type OmitIndexSignature<ObjectType> = {
|
|
618
|
-
[KeyType in keyof ObjectType
|
|
619
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
620
|
-
as {} extends Record<KeyType, unknown>
|
|
621
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
622
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
623
|
-
]: ObjectType[KeyType];
|
|
624
|
-
};
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
628
|
-
|
|
629
|
-
@example
|
|
630
|
-
```
|
|
631
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
632
|
-
|
|
633
|
-
interface Example {
|
|
634
|
-
// These index signatures will be removed.
|
|
635
|
-
[x: string]: any
|
|
636
|
-
[x: number]: any
|
|
637
|
-
[x: symbol]: any
|
|
638
|
-
[x: `head-${string}`]: string
|
|
639
|
-
[x: `${string}-tail`]: string
|
|
640
|
-
[x: `head-${string}-tail`]: string
|
|
641
|
-
[x: `${bigint}`]: string
|
|
642
|
-
[x: `embedded-${number}`]: string
|
|
643
|
-
|
|
644
|
-
// These explicitly defined keys will remain.
|
|
645
|
-
foo: 'bar';
|
|
646
|
-
qux?: 'baz';
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
650
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
@see PickIndexSignature
|
|
654
|
-
@category Object
|
|
655
|
-
*/
|
|
656
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
657
|
-
//#endregion
|
|
658
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
659
|
-
/**
|
|
660
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
661
|
-
|
|
662
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
663
|
-
|
|
664
|
-
@example
|
|
665
|
-
```
|
|
666
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
667
|
-
|
|
668
|
-
declare const symbolKey: unique symbol;
|
|
669
|
-
|
|
670
|
-
type Example = {
|
|
671
|
-
// These index signatures will remain.
|
|
672
|
-
[x: string]: unknown;
|
|
673
|
-
[x: number]: unknown;
|
|
674
|
-
[x: symbol]: unknown;
|
|
675
|
-
[x: `head-${string}`]: string;
|
|
676
|
-
[x: `${string}-tail`]: string;
|
|
677
|
-
[x: `head-${string}-tail`]: string;
|
|
678
|
-
[x: `${bigint}`]: string;
|
|
679
|
-
[x: `embedded-${number}`]: string;
|
|
680
|
-
|
|
681
|
-
// These explicitly defined keys will be removed.
|
|
682
|
-
['kebab-case-key']: string;
|
|
683
|
-
[symbolKey]: string;
|
|
684
|
-
foo: 'bar';
|
|
685
|
-
qux?: 'baz';
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
689
|
-
// {
|
|
690
|
-
// [x: string]: unknown;
|
|
691
|
-
// [x: number]: unknown;
|
|
692
|
-
// [x: symbol]: unknown;
|
|
693
|
-
// [x: `head-${string}`]: string;
|
|
694
|
-
// [x: `${string}-tail`]: string;
|
|
695
|
-
// [x: `head-${string}-tail`]: string;
|
|
696
|
-
// [x: `${bigint}`]: string;
|
|
697
|
-
// [x: `embedded-${number}`]: string;
|
|
698
|
-
// }
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
@see OmitIndexSignature
|
|
702
|
-
@category Object
|
|
703
|
-
*/
|
|
704
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
705
|
-
//#endregion
|
|
706
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/merge.d.ts
|
|
707
|
-
// Merges two objects without worrying about index signatures.
|
|
708
|
-
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
712
|
-
|
|
713
|
-
@example
|
|
714
|
-
```
|
|
715
|
-
import type {Merge} from 'type-fest';
|
|
716
|
-
|
|
717
|
-
interface Foo {
|
|
718
|
-
[x: string]: unknown;
|
|
719
|
-
[x: number]: unknown;
|
|
720
|
-
foo: string;
|
|
721
|
-
bar: symbol;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
type Bar = {
|
|
725
|
-
[x: number]: number;
|
|
726
|
-
[x: symbol]: unknown;
|
|
727
|
-
bar: Date;
|
|
728
|
-
baz: boolean;
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
732
|
-
// => {
|
|
733
|
-
// [x: string]: unknown;
|
|
734
|
-
// [x: number]: number;
|
|
735
|
-
// [x: symbol]: unknown;
|
|
736
|
-
// foo: string;
|
|
737
|
-
// bar: Date;
|
|
738
|
-
// baz: boolean;
|
|
739
|
-
// }
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
@category Object
|
|
743
|
-
*/
|
|
744
|
-
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
745
|
-
//#endregion
|
|
746
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/object.d.ts
|
|
747
|
-
/**
|
|
748
|
-
Merges user specified options with default options.
|
|
749
|
-
|
|
750
|
-
@example
|
|
751
|
-
```
|
|
752
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
753
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
754
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
755
|
-
|
|
756
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
757
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
@example
|
|
761
|
-
```
|
|
762
|
-
// Complains if default values are not provided for optional options
|
|
763
|
-
|
|
764
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
765
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
766
|
-
type SpecifiedOptions = {};
|
|
767
|
-
|
|
768
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
769
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
770
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
@example
|
|
774
|
-
```
|
|
775
|
-
// Complains if an option's default type does not conform to the expected type
|
|
776
|
-
|
|
777
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
778
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
779
|
-
type SpecifiedOptions = {};
|
|
780
|
-
|
|
781
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
782
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
783
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
784
|
-
```
|
|
785
|
-
|
|
786
|
-
@example
|
|
787
|
-
```
|
|
788
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
789
|
-
|
|
790
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
791
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
792
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
793
|
-
|
|
794
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
795
|
-
// ~~~~~~~~~~~~~~~~
|
|
796
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
797
|
-
```
|
|
798
|
-
*/
|
|
799
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever$1<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
800
|
-
//#endregion
|
|
801
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/or.d.ts
|
|
802
|
-
/**
|
|
803
|
-
Returns a boolean for whether either of two given types are true.
|
|
804
|
-
|
|
805
|
-
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
806
|
-
|
|
807
|
-
@example
|
|
808
|
-
```
|
|
809
|
-
import type {Or} from 'type-fest';
|
|
810
|
-
|
|
811
|
-
type TT = Or<true, false>;
|
|
812
|
-
//=> true
|
|
813
|
-
|
|
814
|
-
type TF = Or<true, false>;
|
|
815
|
-
//=> true
|
|
816
|
-
|
|
817
|
-
type FT = Or<false, true>;
|
|
818
|
-
//=> true
|
|
819
|
-
|
|
820
|
-
type FF = Or<false, false>;
|
|
821
|
-
//=> false
|
|
822
|
-
```
|
|
823
|
-
|
|
824
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
825
|
-
For example, `And<false, boolean>` expands to `And<false, true> | And<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
826
|
-
@example
|
|
827
|
-
```
|
|
828
|
-
import type {And} from 'type-fest';
|
|
829
|
-
|
|
830
|
-
type A = Or<false, boolean>;
|
|
831
|
-
//=> boolean
|
|
832
|
-
|
|
833
|
-
type B = Or<boolean, false>;
|
|
834
|
-
//=> boolean
|
|
835
|
-
|
|
836
|
-
type C = Or<true, boolean>;
|
|
837
|
-
//=> true
|
|
838
|
-
|
|
839
|
-
type D = Or<boolean, true>;
|
|
840
|
-
//=> true
|
|
841
|
-
|
|
842
|
-
type E = Or<boolean, boolean>;
|
|
843
|
-
//=> boolean
|
|
844
|
-
```
|
|
845
|
-
|
|
846
|
-
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
847
|
-
|
|
848
|
-
@example
|
|
849
|
-
```
|
|
850
|
-
import type {Or} from 'type-fest';
|
|
851
|
-
|
|
852
|
-
type A = Or<true, never>;
|
|
853
|
-
//=> true
|
|
854
|
-
|
|
855
|
-
type B = Or<never, true>;
|
|
856
|
-
//=> true
|
|
857
|
-
|
|
858
|
-
type C = Or<false, never>;
|
|
859
|
-
//=> false
|
|
860
|
-
|
|
861
|
-
type D = Or<never, false>;
|
|
862
|
-
//=> false
|
|
863
|
-
|
|
864
|
-
type E = Or<boolean, never>;
|
|
865
|
-
//=> boolean
|
|
866
|
-
|
|
867
|
-
type F = Or<never, boolean>;
|
|
868
|
-
//=> boolean
|
|
869
|
-
|
|
870
|
-
type G = Or<never, never>;
|
|
871
|
-
//=> false
|
|
872
|
-
```
|
|
873
|
-
|
|
874
|
-
@see {@link And}
|
|
875
|
-
*/
|
|
876
|
-
type Or<A extends boolean, B extends boolean> = _Or<If<IsNever$1<A>, false, A>, If<IsNever$1<B>, false, B>>;
|
|
877
|
-
// `never` is treated as `false`
|
|
878
|
-
|
|
879
|
-
type _Or<A extends boolean, B extends boolean> = A extends true ? true : B extends true ? true : false;
|
|
880
|
-
//#endregion
|
|
881
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
882
|
-
/**
|
|
883
|
-
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
884
|
-
|
|
885
|
-
Use-cases:
|
|
886
|
-
- Creating interfaces for components that only need one of the keys to display properly.
|
|
887
|
-
- Declaring generic keys in a single place for a single use-case that gets narrowed down via `RequireExactlyOne`.
|
|
888
|
-
|
|
889
|
-
The caveat with `RequireExactlyOne` is that TypeScript doesn't always know at compile time every key that will exist at runtime. Therefore `RequireExactlyOne` can't do anything to prevent extra keys it doesn't know about.
|
|
890
|
-
|
|
891
|
-
@example
|
|
892
|
-
```
|
|
893
|
-
import type {RequireExactlyOne} from 'type-fest';
|
|
894
|
-
|
|
895
|
-
type Responder = {
|
|
896
|
-
text: () => string;
|
|
897
|
-
json: () => string;
|
|
898
|
-
secure: boolean;
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
902
|
-
// Adding a `text` key here would cause a compile error.
|
|
903
|
-
|
|
904
|
-
json: () => '{"message": "ok"}',
|
|
905
|
-
secure: true
|
|
906
|
-
};
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
@category Object
|
|
910
|
-
*/
|
|
911
|
-
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever$1<KeysType>, never, _RequireExactlyOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
912
|
-
type _RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
915
|
-
/**
|
|
916
|
-
Create a type that requires exactly one of the given keys and disallows more, or none of the given keys. The remaining keys are kept as is.
|
|
917
|
-
|
|
918
|
-
@example
|
|
919
|
-
```
|
|
920
|
-
import type {RequireOneOrNone} from 'type-fest';
|
|
921
|
-
|
|
922
|
-
type Responder = RequireOneOrNone<{
|
|
923
|
-
text: () => string;
|
|
924
|
-
json: () => string;
|
|
925
|
-
secure: boolean;
|
|
926
|
-
}, 'text' | 'json'>;
|
|
927
|
-
|
|
928
|
-
const responder1: Responder = {
|
|
929
|
-
secure: true
|
|
930
|
-
};
|
|
931
|
-
|
|
932
|
-
const responder2: Responder = {
|
|
933
|
-
text: () => '{"message": "hi"}',
|
|
934
|
-
secure: true
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
const responder3: Responder = {
|
|
938
|
-
json: () => '{"message": "ok"}',
|
|
939
|
-
secure: true
|
|
940
|
-
};
|
|
941
|
-
```
|
|
942
|
-
|
|
943
|
-
@category Object
|
|
944
|
-
*/
|
|
945
|
-
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever$1<KeysType>, ObjectType, _RequireOneOrNone<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
946
|
-
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
947
|
-
//#endregion
|
|
948
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-union.d.ts
|
|
949
|
-
/**
|
|
950
|
-
Returns a boolean for whether the given type is a union.
|
|
951
|
-
|
|
952
|
-
@example
|
|
953
|
-
```
|
|
954
|
-
import type {IsUnion} from 'type-fest';
|
|
955
|
-
|
|
956
|
-
type A = IsUnion<string | number>;
|
|
957
|
-
//=> true
|
|
958
|
-
|
|
959
|
-
type B = IsUnion<string>;
|
|
960
|
-
//=> false
|
|
961
|
-
```
|
|
962
|
-
*/
|
|
963
|
-
type IsUnion$1<T> = InternalIsUnion<T>;
|
|
964
|
-
/**
|
|
965
|
-
The actual implementation of `IsUnion`.
|
|
966
|
-
*/
|
|
967
|
-
type InternalIsUnion<T, U = T> = (IsNever$1<T> extends true ? false : T extends any ? [U] extends [T] ? false : true : never) extends infer Result
|
|
968
|
-
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
969
|
-
// that means `T` has at least two types and it's a union type,
|
|
970
|
-
// so we will return `true` instead of `boolean`.
|
|
971
|
-
? boolean extends Result ? true : Result : never; // Should never happen
|
|
972
|
-
//#endregion
|
|
973
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
974
|
-
/**
|
|
975
|
-
@see {@link PartialDeep}
|
|
976
|
-
*/
|
|
977
|
-
type PartialDeepOptions = {
|
|
978
|
-
/**
|
|
979
|
-
Whether to affect the individual elements of arrays and tuples.
|
|
980
|
-
@default false
|
|
981
|
-
*/
|
|
982
|
-
readonly recurseIntoArrays?: boolean;
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
Allows `undefined` values in non-tuple arrays.
|
|
986
|
-
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
987
|
-
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
988
|
-
@default false
|
|
989
|
-
@example
|
|
990
|
-
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
991
|
-
```
|
|
992
|
-
import type {PartialDeep} from 'type-fest';
|
|
993
|
-
type Settings = {
|
|
994
|
-
languages: string[];
|
|
995
|
-
};
|
|
996
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
997
|
-
partialSettings.languages = [undefined]; // OK
|
|
998
|
-
```
|
|
999
|
-
*/
|
|
1000
|
-
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
1001
|
-
};
|
|
1002
|
-
type DefaultPartialDeepOptions = {
|
|
1003
|
-
recurseIntoArrays: false;
|
|
1004
|
-
allowUndefinedInNonTupleArrays: false;
|
|
1005
|
-
};
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
Create a type from another type with all keys and nested keys set to optional.
|
|
1009
|
-
|
|
1010
|
-
Use-cases:
|
|
1011
|
-
- Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
|
|
1012
|
-
- Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
|
|
1013
|
-
|
|
1014
|
-
@example
|
|
1015
|
-
```
|
|
1016
|
-
import type {PartialDeep} from 'type-fest';
|
|
1017
|
-
|
|
1018
|
-
let settings = {
|
|
1019
|
-
textEditor: {
|
|
1020
|
-
fontSize: 14,
|
|
1021
|
-
fontColor: '#000000',
|
|
1022
|
-
fontWeight: 400,
|
|
1023
|
-
},
|
|
1024
|
-
autocomplete: false,
|
|
1025
|
-
autosave: true,
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
|
-
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
1029
|
-
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
1030
|
-
);
|
|
1031
|
-
|
|
1032
|
-
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
1033
|
-
```
|
|
1034
|
-
|
|
1035
|
-
By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
|
|
1036
|
-
|
|
1037
|
-
```
|
|
1038
|
-
import type {PartialDeep} from 'type-fest';
|
|
1039
|
-
|
|
1040
|
-
type Shape = {
|
|
1041
|
-
dimensions: [number, number];
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
1045
|
-
dimensions: [], // OK
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
partialShape.dimensions = [15]; // OK
|
|
1049
|
-
```
|
|
1050
|
-
|
|
1051
|
-
@see {@link PartialDeepOptions}
|
|
1052
|
-
|
|
1053
|
-
@category Object
|
|
1054
|
-
@category Array
|
|
1055
|
-
@category Set
|
|
1056
|
-
@category Map
|
|
1057
|
-
*/
|
|
1058
|
-
type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
1059
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever$1<keyof T> extends true ? T // For functions with no properties
|
|
1060
|
-
: HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
1061
|
-
? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
1062
|
-
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
1063
|
-
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
|
|
1064
|
-
: T // If they don't opt into array testing, just use the original type
|
|
1065
|
-
: PartialObjectDeep<T, Options> : unknown;
|
|
1066
|
-
|
|
1067
|
-
/**
|
|
1068
|
-
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
|
|
1069
|
-
*/
|
|
1070
|
-
type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1073
|
-
Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
|
|
1074
|
-
*/
|
|
1075
|
-
type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
|
|
1079
|
-
*/
|
|
1080
|
-
type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
|
|
1084
|
-
*/
|
|
1085
|
-
type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
1089
|
-
*/
|
|
1090
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
|
|
1091
|
-
//#endregion
|
|
1092
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-deep.d.ts
|
|
1093
|
-
/**
|
|
1094
|
-
Create a type from another type with all keys and nested keys set to required.
|
|
1095
|
-
|
|
1096
|
-
Use-cases:
|
|
1097
|
-
- Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified.
|
|
1098
|
-
- Modeling the resulting type after a deep merge with a set of defaults.
|
|
1099
|
-
|
|
1100
|
-
@example
|
|
1101
|
-
```
|
|
1102
|
-
import type {RequiredDeep} from 'type-fest';
|
|
1103
|
-
|
|
1104
|
-
type Settings = {
|
|
1105
|
-
textEditor?: {
|
|
1106
|
-
fontSize?: number;
|
|
1107
|
-
fontColor?: string;
|
|
1108
|
-
fontWeight?: number | undefined;
|
|
1109
|
-
};
|
|
1110
|
-
autocomplete?: boolean;
|
|
1111
|
-
autosave?: boolean | undefined;
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
|
-
type RequiredSettings = RequiredDeep<Settings>;
|
|
1115
|
-
//=> {
|
|
1116
|
-
// textEditor: {
|
|
1117
|
-
// fontSize: number;
|
|
1118
|
-
// fontColor: string;
|
|
1119
|
-
// fontWeight: number | undefined;
|
|
1120
|
-
// };
|
|
1121
|
-
// autocomplete: boolean;
|
|
1122
|
-
// autosave: boolean | undefined;
|
|
1123
|
-
// }
|
|
1124
|
-
```
|
|
1125
|
-
|
|
1126
|
-
Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
|
|
1127
|
-
|
|
1128
|
-
@category Utilities
|
|
1129
|
-
@category Object
|
|
1130
|
-
@category Array
|
|
1131
|
-
@category Set
|
|
1132
|
-
@category Map
|
|
1133
|
-
*/
|
|
1134
|
-
type RequiredDeep<T> = T extends BuiltIns ? T : T extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : T extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : T extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : T extends ((...arguments_: any[]) => unknown) ? IsNever$1<keyof T> extends true ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & RequiredObjectDeep<T> : T extends object ? RequiredObjectDeep<T> : unknown;
|
|
1135
|
-
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
1138
|
-
/**
|
|
1139
|
-
Returns the last element of a union type.
|
|
1140
|
-
|
|
1141
|
-
@example
|
|
1142
|
-
```
|
|
1143
|
-
type Last = LastOfUnion<1 | 2 | 3>;
|
|
1144
|
-
//=> 3
|
|
1145
|
-
```
|
|
1146
|
-
*/
|
|
1147
|
-
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
Convert a union type into an unordered tuple type of its elements.
|
|
1151
|
-
|
|
1152
|
-
"Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
|
|
1153
|
-
|
|
1154
|
-
This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
|
|
1155
|
-
|
|
1156
|
-
@example
|
|
1157
|
-
```
|
|
1158
|
-
import type {UnionToTuple} from 'type-fest';
|
|
1159
|
-
|
|
1160
|
-
type Numbers = 1 | 2 | 3;
|
|
1161
|
-
type NumbersTuple = UnionToTuple<Numbers>;
|
|
1162
|
-
//=> [1, 2, 3]
|
|
1163
|
-
```
|
|
1164
|
-
|
|
1165
|
-
@example
|
|
1166
|
-
```
|
|
1167
|
-
import type {UnionToTuple} from 'type-fest';
|
|
1168
|
-
|
|
1169
|
-
const pets = {
|
|
1170
|
-
dog: '🐶',
|
|
1171
|
-
cat: '🐱',
|
|
1172
|
-
snake: '🐍',
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
type Pet = keyof typeof pets;
|
|
1176
|
-
//=> 'dog' | 'cat' | 'snake'
|
|
1177
|
-
|
|
1178
|
-
const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
1179
|
-
//=> ['dog', 'cat', 'snake']
|
|
1180
|
-
```
|
|
1181
|
-
|
|
1182
|
-
@category Array
|
|
1183
|
-
*/
|
|
1184
|
-
type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
|
|
1185
|
-
//#endregion
|
|
1186
31
|
//#region src/types/core/modifiers.types.d.ts
|
|
1187
32
|
interface RegleBehaviourOptions {
|
|
1188
33
|
/**
|
|
@@ -1220,9 +65,9 @@ interface RegleBehaviourOptions {
|
|
|
1220
65
|
*/
|
|
1221
66
|
clearExternalErrorsOnChange?: boolean | undefined;
|
|
1222
67
|
}
|
|
1223
|
-
interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
|
|
1224
|
-
externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState>> | Record<string, string[]>>;
|
|
1225
|
-
validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
|
|
68
|
+
interface LocalRegleBehaviourOptions<TState$1 extends Record<string, any>, TRules$1 extends ReglePartialRuleTree<TState$1, CustomRulesDeclarationTree>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
|
|
69
|
+
externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState$1>> | Record<string, string[]>>;
|
|
70
|
+
validationGroups?: (fields: RegleStatus<TState$1, TRules$1>['$fields']) => TValidationGroups;
|
|
1226
71
|
}
|
|
1227
72
|
type RegleValidationGroupEntry = RegleFieldStatus<any, any> | undefined;
|
|
1228
73
|
interface RegleValidationGroupOutput {
|
|
@@ -1281,13 +126,13 @@ type AddDollarToOptions<T extends Record<string, any>> = { [K in keyof T as `$${
|
|
|
1281
126
|
* @template TAdditionalReturnProperties - Additional properties to extend the return type
|
|
1282
127
|
*
|
|
1283
128
|
*/
|
|
1284
|
-
type Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree> = EmptyObject, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
129
|
+
type Regle<TState$1 extends Record<string, any> = EmptyObject, TRules$1 extends ReglePartialRuleTree<TState$1, CustomRulesDeclarationTree> = EmptyObject, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
1285
130
|
/**
|
|
1286
131
|
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
|
|
1287
132
|
*
|
|
1288
133
|
* To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
|
|
1289
134
|
*/
|
|
1290
|
-
r$: Raw<RegleRoot<TState, TRules, TValidationGroups, TShortcuts>>;
|
|
135
|
+
r$: Raw<RegleRoot<TState$1, TRules$1, TValidationGroups, TShortcuts>>;
|
|
1291
136
|
} & TAdditionalReturnProperties;
|
|
1292
137
|
/**
|
|
1293
138
|
* The type for a single field validation instance.
|
|
@@ -1297,19 +142,19 @@ type Regle<TState extends Record<string, any> = EmptyObject, TRules extends Regl
|
|
|
1297
142
|
* @template TShortcuts - Custom shortcut definitions for common validation patterns
|
|
1298
143
|
* @template TAdditionalReturnProperties - Additional properties to extend the return type
|
|
1299
144
|
*/
|
|
1300
|
-
type RegleSingleField<TState extends Maybe<PrimitiveTypes> = any, TRules extends RegleRuleDecl<NonNullable<TState>> = EmptyObject, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
145
|
+
type RegleSingleField<TState$1 extends Maybe<PrimitiveTypes> = any, TRules$1 extends RegleRuleDecl<NonNullable<TState$1>> = EmptyObject, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
1301
146
|
/**
|
|
1302
147
|
* r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
|
|
1303
148
|
*
|
|
1304
149
|
* To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
|
|
1305
150
|
*/
|
|
1306
|
-
r$: Raw<RegleFieldStatus<TState, TRules, TShortcuts>>;
|
|
151
|
+
r$: Raw<RegleFieldStatus<TState$1, TRules$1, TShortcuts>>;
|
|
1307
152
|
} & TAdditionalReturnProperties;
|
|
1308
153
|
type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? { [K in keyof T]: InferDeepReactiveState<T[K]> } : never;
|
|
1309
|
-
type InferDeepReactiveState<TState> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? DeepReactiveState<U[]> : NonNullable<TState> extends Date | File ? MaybeRef<TState> : NonNullable<TState> extends Record<string, any> ? DeepReactiveState<TState> : MaybeRef<TState>;
|
|
154
|
+
type InferDeepReactiveState<TState$1> = NonNullable<TState$1> extends Array<infer U extends Record<string, any>> ? DeepReactiveState<U[]> : NonNullable<TState$1> extends Date | File ? MaybeRef<TState$1> : NonNullable<TState$1> extends Record<string, any> ? DeepReactiveState<TState$1> : MaybeRef<TState$1>;
|
|
1310
155
|
//#endregion
|
|
1311
156
|
//#region src/types/core/reset.types.d.ts
|
|
1312
|
-
type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
157
|
+
type ResetOptions<TState$1 extends unknown> = RequireOneOrNone<{
|
|
1313
158
|
/**
|
|
1314
159
|
* Reset validation status and reset form state to its initial state.
|
|
1315
160
|
*
|
|
@@ -1330,7 +175,7 @@ type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
|
1330
175
|
* Reset validation status and reset form state to the given state
|
|
1331
176
|
* Also set the new state as the initial state.
|
|
1332
177
|
*/
|
|
1333
|
-
toState?: TState | (() => TState);
|
|
178
|
+
toState?: TState$1 | (() => TState$1);
|
|
1334
179
|
/**
|
|
1335
180
|
* Clears the $externalErrors state back to an empty object.
|
|
1336
181
|
*
|
|
@@ -1353,15 +198,15 @@ type ScopedInstancesRecord = Record<string, Record<string, SuperCompatibleRegleR
|
|
|
1353
198
|
type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
|
|
1354
199
|
//#endregion
|
|
1355
200
|
//#region src/types/core/results.types.d.ts
|
|
1356
|
-
type PartialFormState<TState extends Record<string, any>> = [unknown] extends [TState] ? {} : Prettify<{ [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? never : TState[K] extends Array<any> ? never : K]?: MaybeOutput<TState[K]> } & { [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? K : TState[K] extends Array<any> ? K : never]: NonNullable<TState[K]> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : PartialFormState<TState[K]> }>;
|
|
1357
|
-
type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = {
|
|
201
|
+
type PartialFormState<TState$1 extends Record<string, any>> = [unknown] extends [TState$1] ? {} : Prettify<{ [K in keyof TState$1 as ExtendOnlyRealRecord<TState$1[K]> extends true ? never : TState$1[K] extends Array<any> ? never : K]?: MaybeOutput<TState$1[K]> } & { [K in keyof TState$1 as ExtendOnlyRealRecord<TState$1[K]> extends true ? K : TState$1[K] extends Array<any> ? K : never]: NonNullable<TState$1[K]> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : PartialFormState<TState$1[K]> }>;
|
|
202
|
+
type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules$1 extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = {
|
|
1358
203
|
valid: false;
|
|
1359
204
|
data: IsUnknown<Data> extends true ? unknown : IsAny<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? NonNullable<Data> extends Date | File ? MaybeOutput<Data> : NonNullable<Data> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : NonNullable<Data> extends Record<string, any> ? PartialFormState<NonNullable<Data>> : MaybeOutput<Data> : unknown;
|
|
1360
205
|
} | {
|
|
1361
206
|
valid: true;
|
|
1362
|
-
data: IsUnknown<Data> extends true ? unknown : IsAny<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? Data extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, TRules>[] : Data extends Date | File ? SafeFieldProperty<Data, TRules> : Data extends Record<string, any> ? DeepSafeFormState<Data, TRules> : SafeFieldProperty<Data, TRules> : unknown;
|
|
207
|
+
data: IsUnknown<Data> extends true ? unknown : IsAny<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? Data extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, TRules$1>[] : Data extends Date | File ? SafeFieldProperty<Data, TRules$1> : Data extends Record<string, any> ? DeepSafeFormState<Data, TRules$1> : SafeFieldProperty<Data, TRules$1> : unknown;
|
|
1363
208
|
};
|
|
1364
|
-
type RegleNestedResult<Data extends Record<string, any> | unknown, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & ({
|
|
209
|
+
type RegleNestedResult<Data extends Record<string, any> | unknown, TRules$1 extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules$1> & ({
|
|
1365
210
|
valid: false;
|
|
1366
211
|
issues: RegleIssuesTree<Data>;
|
|
1367
212
|
errors: RegleErrorTree<Data>;
|
|
@@ -1370,7 +215,7 @@ type RegleNestedResult<Data extends Record<string, any> | unknown, TRules extend
|
|
|
1370
215
|
issues: EmptyObject;
|
|
1371
216
|
errors: EmptyObject;
|
|
1372
217
|
});
|
|
1373
|
-
type RegleCollectionResult<Data extends any[], TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & ({
|
|
218
|
+
type RegleCollectionResult<Data extends any[], TRules$1 extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules$1> & ({
|
|
1374
219
|
valid: false;
|
|
1375
220
|
issues: RegleCollectionErrors<Data, true>;
|
|
1376
221
|
errors: RegleCollectionErrors<Data>;
|
|
@@ -1379,8 +224,8 @@ type RegleCollectionResult<Data extends any[], TRules extends ReglePartialRuleTr
|
|
|
1379
224
|
issues: EmptyObject;
|
|
1380
225
|
errors: EmptyObject;
|
|
1381
226
|
});
|
|
1382
|
-
type RegleFieldResult<Data extends any, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & {
|
|
1383
|
-
issues: RegleFieldIssue<TRules>[];
|
|
227
|
+
type RegleFieldResult<Data extends any, TRules$1 extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules$1> & {
|
|
228
|
+
issues: RegleFieldIssue<TRules$1>[];
|
|
1384
229
|
errors: string[];
|
|
1385
230
|
};
|
|
1386
231
|
/**
|
|
@@ -1397,51 +242,13 @@ type $InternalRegleResult = {
|
|
|
1397
242
|
errors: $InternalRegleErrorTree | $InternalRegleCollectionErrors | string[];
|
|
1398
243
|
issues: $InternalRegleIssuesTree | $InternalRegleCollectionIssues | RegleFieldIssue[];
|
|
1399
244
|
};
|
|
1400
|
-
type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<Record<string, any>, CustomRulesDeclarationTree> | RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState] ? {} : TRules extends undefined ? TState : TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree> ? Prettify<{ [K in keyof TState as IsPropertyOutputRequired<TState[K], TRules[K]> extends false ? K : never]?: SafeProperty<TState[K], TRules[K]> extends MaybeInput<infer M> ? MaybeOutput<M> : SafeProperty<TState[K], TRules[K]> } & { [K in keyof TState as IsPropertyOutputRequired<TState[K], TRules[K]> extends false ? never : K]-?: unknown extends SafeProperty<TState[K], TRules[K]> ? unknown : NonNullable<SafeProperty<TState[K], TRules[K]>> }> : TState;
|
|
245
|
+
type DeepSafeFormState<TState$1 extends Record<string, any>, TRules$1 extends ReglePartialRuleTree<Record<string, any>, CustomRulesDeclarationTree> | RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState$1] ? {} : TRules$1 extends undefined ? TState$1 : TRules$1 extends ReglePartialRuleTree<TState$1, CustomRulesDeclarationTree> ? Prettify<{ [K in keyof TState$1 as IsPropertyOutputRequired<TState$1[K], TRules$1[K]> extends false ? K : never]?: SafeProperty<TState$1[K], TRules$1[K]> extends MaybeInput<infer M> ? MaybeOutput<M> : SafeProperty<TState$1[K], TRules$1[K]> } & { [K in keyof TState$1 as IsPropertyOutputRequired<TState$1[K], TRules$1[K]> extends false ? never : K]-?: unknown extends SafeProperty<TState$1[K], TRules$1[K]> ? unknown : NonNullable<SafeProperty<TState$1[K], TRules$1[K]>> }> : TState$1;
|
|
1401
246
|
type FieldHaveRequiredRule<TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends MaybeRef<RegleRuleDecl<any, any>> ? [unknown] extends UnwrapRef<TRule>['required'] ? NonNullable<UnwrapRef<TRule>['literal']> extends RegleRuleDefinition<any, any[], any, any, any, any> ? true : false : NonNullable<UnwrapRef<TRule>['required']> extends UnwrapRef<TRule>['required'] ? UnwrapRef<TRule>['required'] extends RegleRuleDefinition<any, infer Params, any, any, any, any> ? Params extends never[] ? true : false : false : false : false;
|
|
1402
|
-
type ObjectHaveAtLeastOneRequiredField<TState extends Record<string, any>, TRule extends ReglePartialRuleTree<TState, any>> = TState extends Maybe<TState> ? { [K in keyof NonNullable<TState>]-?: IsPropertyOutputRequired<NonNullable<TState>[K], TRule[K]> }[keyof TState] extends false ? false : true : true;
|
|
1403
|
-
type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends RegleCollectionRuleDecl<TState>> = TState extends Maybe<TState> ? FieldHaveRequiredRule<Omit<TRule, '$each'> extends MaybeRef<RegleRuleDecl> ? Omit<UnwrapRef<TRule>, '$each'> : {}> | ObjectHaveAtLeastOneRequiredField<ArrayElement<NonNullable<TState>>, ExtractFromGetter<TRule['$each']> extends undefined ? {} : NonNullable<ExtractFromGetter<TRule['$each']>>> extends false ? false : true : true;
|
|
1404
|
-
type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = unknown extends TState ? unknown : TRule extends RegleCollectionRuleDecl<any, any> ? TState extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, ExtractFromGetter<TRule['$each']>>[] : TState : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState> extends true ? DeepSafeFormState<NonNullable<TState> extends Record<string, any> ? JoinDiscriminatedUnions<NonNullable<TState>> : {}, TRule> : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends true ? TState : MaybeOutput<TState> : TState : TState;
|
|
1405
|
-
type IsPropertyOutputRequired<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState] ? unknown : NonNullable<TState> extends Array<any> ? TRule extends RegleCollectionRuleDecl<any, any> ? ArrayHaveAtLeastOneRequiredField<NonNullable<TState>, TRule> extends false ? false : true : false : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState> extends true ? ObjectHaveAtLeastOneRequiredField<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, TRule> extends false ? false : true : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends false ? false : true : false : false;
|
|
1406
|
-
type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
|
|
1407
|
-
//#endregion
|
|
1408
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/utils.d.ts
|
|
1409
|
-
/**
|
|
1410
|
-
* Negates a boolean type.
|
|
1411
|
-
*/
|
|
1412
|
-
type Not<T extends boolean> = T extends true ? false : true;
|
|
1413
|
-
/**
|
|
1414
|
-
* Checks if the given type is `never`.
|
|
1415
|
-
*/
|
|
1416
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
1417
|
-
/**
|
|
1418
|
-
* Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
|
|
1419
|
-
* 1. If either type is `never`, the result is `true` iff the other type is also `never`.
|
|
1420
|
-
* 2. Types are wrapped in a 1-tuple so that union types are not distributed - instead we consider `string | number` to _not_ extend `number`. If we used `Left extends Right` directly you would get `Extends<string | number, number>` => `false | true` => `boolean`.
|
|
1421
|
-
*/
|
|
1422
|
-
type Extends<Left, Right> = IsNever<Left> extends true ? IsNever<Right> : [Left] extends [Right] ? true : false;
|
|
1423
|
-
/**
|
|
1424
|
-
* Convert a union to an intersection.
|
|
1425
|
-
* `A | B | C` -\> `A & B & C`
|
|
1426
|
-
*/
|
|
1427
|
-
type UnionToIntersection$1<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1428
|
-
/**
|
|
1429
|
-
* Get the last element of a union.
|
|
1430
|
-
* First, converts to a union of `() => T` functions,
|
|
1431
|
-
* then uses {@linkcode UnionToIntersection} to get the last one.
|
|
1432
|
-
*/
|
|
1433
|
-
type LastOf<Union> = UnionToIntersection$1<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1434
|
-
/**
|
|
1435
|
-
* Intermediate type for {@linkcode UnionToTuple} which pushes the
|
|
1436
|
-
* "last" union member to the end of a tuple, and recursively prepends
|
|
1437
|
-
* the remainder of the union.
|
|
1438
|
-
*/
|
|
1439
|
-
type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever<Union> extends true ? [] : [...TuplifyUnion<Exclude<Union, LastElement>>, LastElement];
|
|
1440
|
-
/**
|
|
1441
|
-
* Convert a union like `1 | 2 | 3` to a tuple like `[1, 2, 3]`.
|
|
1442
|
-
*/
|
|
1443
|
-
type UnionToTuple$1<Union> = TuplifyUnion<Union>;
|
|
1444
|
-
type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
247
|
+
type ObjectHaveAtLeastOneRequiredField<TState$1 extends Record<string, any>, TRule extends ReglePartialRuleTree<TState$1, any>> = TState$1 extends Maybe<TState$1> ? { [K in keyof NonNullable<TState$1>]-?: IsPropertyOutputRequired<NonNullable<TState$1>[K], TRule[K]> }[keyof TState$1] extends false ? false : true : true;
|
|
248
|
+
type ArrayHaveAtLeastOneRequiredField<TState$1 extends Maybe<any[]>, TRule extends RegleCollectionRuleDecl<TState$1>> = TState$1 extends Maybe<TState$1> ? FieldHaveRequiredRule<Omit<TRule, '$each'> extends MaybeRef<RegleRuleDecl> ? Omit<UnwrapRef<TRule>, '$each'> : {}> | ObjectHaveAtLeastOneRequiredField<ArrayElement<NonNullable<TState$1>>, ExtractFromGetter<TRule['$each']> extends undefined ? {} : NonNullable<ExtractFromGetter<TRule['$each']>>> extends false ? false : true : true;
|
|
249
|
+
type SafeProperty<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined> = unknown extends TState$1 ? unknown : TRule extends RegleCollectionRuleDecl<any, any> ? TState$1 extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, ExtractFromGetter<TRule['$each']>>[] : TState$1 : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState$1> extends true ? DeepSafeFormState<NonNullable<TState$1> extends Record<string, any> ? JoinDiscriminatedUnions<NonNullable<TState$1>> : {}, TRule> : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends true ? TState$1 : MaybeOutput<TState$1> : TState$1 : TState$1;
|
|
250
|
+
type IsPropertyOutputRequired<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState$1] ? unknown : NonNullable<TState$1> extends Array<any> ? TRule extends RegleCollectionRuleDecl<any, any> ? ArrayHaveAtLeastOneRequiredField<NonNullable<TState$1>, TRule> extends false ? false : true : false : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState$1> extends true ? ObjectHaveAtLeastOneRequiredField<NonNullable<TState$1> extends Record<string, any> ? NonNullable<TState$1> : {}, TRule> extends false ? false : true : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends false ? false : true : false : false;
|
|
251
|
+
type SafeFieldProperty<TState$1, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState$1> : MaybeOutput<TState$1>;
|
|
1445
252
|
//#endregion
|
|
1446
253
|
//#region src/types/core/variants.types.d.ts
|
|
1447
254
|
type NarrowVariant<TRoot extends {
|
|
@@ -1449,30 +256,30 @@ type NarrowVariant<TRoot extends {
|
|
|
1449
256
|
$fields: {
|
|
1450
257
|
[x: string]: unknown;
|
|
1451
258
|
};
|
|
1452
|
-
}, TKey extends keyof TRoot, TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
259
|
+
}, TKey$1 extends keyof TRoot, TValue$1 extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey$1], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
1453
260
|
$value: infer V;
|
|
1454
|
-
} ? V : unknown)> = Extract<TRoot, { [K in TKey]: RegleFieldStatus<TValue, any, any> | RegleFieldStatus<MaybeInput<TValue>, any, any> }> & {
|
|
1455
|
-
$fields: Extract<TRoot['$fields'], { [K in TKey]: RegleFieldStatus<TValue, any, any> | RegleFieldStatus<MaybeInput<TValue>, any, any> }>;
|
|
1456
|
-
};
|
|
1457
|
-
type MaybeVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleStatus<TState, TRules, TShortcuts>, '$fields'> & {
|
|
1458
|
-
$fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
|
|
1459
|
-
} & (HasNamedKeys<TState> extends true ? ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>] : {}) : RegleStatus<TState, TRules, TShortcuts>;
|
|
1460
|
-
type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? TKey : never : never : TKey]-?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } & { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? never : TKey : TKey : never]?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } : {} };
|
|
1461
|
-
type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
|
|
1462
|
-
type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> = unknown extends T[TKey] ? {
|
|
1463
|
-
[x: string]: { [K in TKey]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
261
|
+
} ? V : unknown)> = Extract<TRoot, { [K in TKey$1]: RegleFieldStatus<TValue$1, any, any> | RegleFieldStatus<MaybeInput<TValue$1>, any, any> }> & {
|
|
262
|
+
$fields: Extract<TRoot['$fields'], { [K in TKey$1]: RegleFieldStatus<TValue$1, any, any> | RegleFieldStatus<MaybeInput<TValue$1>, any, any> }>;
|
|
263
|
+
};
|
|
264
|
+
type MaybeVariantStatus<TState$1 extends Record<string, any> | undefined = Record<string, any>, TRules$1 extends ReglePartialRuleTree<NonNullable<TState$1>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion$1<NonNullable<TState$1>> extends true ? Omit<RegleStatus<TState$1, TRules$1, TShortcuts>, '$fields'> & {
|
|
265
|
+
$fields: ProcessChildrenFields<TState$1, TRules$1, TShortcuts>[keyof ProcessChildrenFields<TState$1, TRules$1, TShortcuts>];
|
|
266
|
+
} & (HasNamedKeys<TState$1> extends true ? ProcessChildrenFields<TState$1, TRules$1, TShortcuts>[keyof ProcessChildrenFields<TState$1, TRules$1, TShortcuts>] : {}) : RegleStatus<TState$1, TRules$1, TShortcuts>;
|
|
267
|
+
type ProcessChildrenFields<TState$1 extends Record<string, any> | undefined, TRules$1 extends ReglePartialRuleTree<NonNullable<TState$1>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState$1>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState$1>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState$1>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState$1>[TIndexInt] : never, UnionToTuple<TRules$1>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState$1 ? TState$1[TKey] extends NonNullable<TState$1[TKey]> ? TKey : never : never : TKey]-?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState$1>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState$1>[TIndexInt] : never, UnionToTuple<TRules$1>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState$1>[TIndexInt]>, TKey, TShortcuts> } & { [TKey in keyof UnionToTuple<TState$1>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState$1>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState$1>[TIndexInt] : never, UnionToTuple<TRules$1>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject> extends true ? TKey extends keyof TState$1 ? TState$1[TKey] extends NonNullable<TState$1[TKey]> ? never : TKey : TKey : never]?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState$1>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState$1>[TIndexInt] : never, UnionToTuple<TRules$1>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple<TState$1>[TIndexInt]>, TKey, TShortcuts> } : {} };
|
|
268
|
+
type FindCorrespondingVariant<TState$1 extends Record<string, any>, TRules$1 extends any[]> = TRules$1 extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState$1> ? [F] : FindCorrespondingVariant<TState$1, R> : [];
|
|
269
|
+
type PossibleLiteralTypes<T extends Record<string, any>, TKey$1 extends keyof T> = unknown extends T[TKey$1] ? {
|
|
270
|
+
[x: string]: { [K in TKey$1]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
1464
271
|
literal?: RegleRuleDefinition<any, [literal: any], false, boolean, any, string | number>;
|
|
1465
272
|
} };
|
|
1466
|
-
} : { [TVal in NonNullable<T[TKey]>]: { [K in TKey]-?: Omit<RegleRuleDecl<TVal, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
273
|
+
} : { [TVal in NonNullable<T[TKey$1]>]: { [K in TKey$1]-?: Omit<RegleRuleDecl<TVal, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
1467
274
|
literal?: RegleRuleDefinition<MaybeInput<TVal>, [literal: TVal], false, boolean, MaybeInput<TVal>, string | number>;
|
|
1468
275
|
} } };
|
|
1469
|
-
type RequiredForm<T extends Record<string, any>, TKey extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey> & PossibleLiteralTypes<T, TKey>[keyof PossibleLiteralTypes<T, TKey>];
|
|
1470
|
-
type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [RequiredForm<T, TKey>, ...RequiredForm<T, TKey>[]];
|
|
276
|
+
type RequiredForm<T extends Record<string, any>, TKey$1 extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey$1> & PossibleLiteralTypes<T, TKey$1>[keyof PossibleLiteralTypes<T, TKey$1>];
|
|
277
|
+
type VariantTuple<T extends Record<string, any>, TKey$1 extends keyof T> = [RequiredForm<T, TKey$1>, ...RequiredForm<T, TKey$1>[]];
|
|
1471
278
|
//#endregion
|
|
1472
279
|
//#region src/core/useRegle/useRegle.d.ts
|
|
1473
|
-
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends DeepExact<TRules, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations>>>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends MaybeInput<PrimitiveTypes> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? (TRules extends Record<string, any> ? TRules : {}) : {}, TValidationGroups> & TAdditionalOptions;
|
|
280
|
+
type useRegleFnOptions<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations>>>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState$1 extends MaybeInput<PrimitiveTypes> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}>, TState$1 extends Record<string, any> ? (TRules$1 extends Record<string, any> ? TRules$1 : {}) : {}, TValidationGroups> & TAdditionalOptions;
|
|
1474
281
|
interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
1475
|
-
<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends DeepExact<TRules, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<MaybeRef<TState> | DeepReactiveState<TState>>, rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>])]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleField<NonNullable<TState>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules extends Record<string, any> ? TRules : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
|
|
282
|
+
<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>>(...params: [state: Maybe<MaybeRef<TState$1> | DeepReactiveState<TState$1>>, rulesFactory: TState$1 extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : TState$1 extends Record<string, any> ? MaybeRef<TRules$1> | ((...args: any[]) => TRules$1) : {}, ...(HaveAnyRequiredProps<useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<TState$1, TRules$1, TAdditionalOptions, TValidationGroups>])]): NonNullable<TState$1> extends PrimitiveTypes ? RegleSingleField<NonNullable<TState$1>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}, TRules$1 extends Record<string, any> ? TRules$1 : {}, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
|
|
1476
283
|
__config?: {
|
|
1477
284
|
rules?: () => CustomRulesDeclarationTree;
|
|
1478
285
|
modifiers?: RegleBehaviourOptions;
|
|
@@ -1502,7 +309,7 @@ declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutD
|
|
|
1502
309
|
//#endregion
|
|
1503
310
|
//#region src/core/useRegle/inferRules.d.ts
|
|
1504
311
|
interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
1505
|
-
<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends DeepExact<TRules, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>>(state: MaybeRef<TState> | DeepReactiveState<TState>, rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? TDecl : TState extends Record<string, any> ? TRules : {}): NonNullable<TState> extends PrimitiveTypes ? TDecl : TRules;
|
|
312
|
+
<TState$1 extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules$1 extends DeepExact<TRules$1, ReglePartialRuleTree<Unwrap<TState$1 extends Record<string, any> ? TState$1 : {}>, Partial<AllRulesDeclarations> & TCustomRules>>, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>>(state: MaybeRef<TState$1> | DeepReactiveState<TState$1>, rulesFactory: TState$1 extends MaybeInput<PrimitiveTypes> ? TDecl : TState$1 extends Record<string, any> ? TRules$1 : {}): NonNullable<TState$1> extends PrimitiveTypes ? TDecl : TRules$1;
|
|
1506
313
|
}
|
|
1507
314
|
/**
|
|
1508
315
|
* Rule type helper to provide autocomplete and typecheck to your form rules or part of your form rules
|
|
@@ -1554,9 +361,9 @@ declare function flatErrors(errors: $InternalRegleErrors, options?: {
|
|
|
1554
361
|
}): string[];
|
|
1555
362
|
//#endregion
|
|
1556
363
|
//#region src/core/useRegle/useRules.d.ts
|
|
1557
|
-
type useRulesFnOptions<TRules extends RegleUnknownRulesTree | RegleRuleDecl, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState = InferInput<TRules>> = Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? (TRules extends Record<string, any> ? TRules : {}) : {}, TValidationGroups>;
|
|
364
|
+
type useRulesFnOptions<TRules$1 extends RegleUnknownRulesTree | RegleRuleDecl, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState$1 = InferInput<TRules$1>> = Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}>, TState$1 extends Record<string, any> ? (TRules$1 extends Record<string, any> ? TRules$1 : {}) : {}, TValidationGroups>;
|
|
1558
365
|
interface useRulesFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never> {
|
|
1559
|
-
<TRules extends RegleUnknownRulesTree | RegleRuleDecl, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState extends Record<string, any> = InferInput<TRules>>(rulesFactory: TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {}, options?: useRulesFnOptions<TRules, TValidationGroups, TState>): NonNullable<TState> extends PrimitiveTypes ? Raw<RegleFieldStatus<NonNullable<TState>, TDecl, TShortcuts>> & StandardSchemaV1<TState> : Raw<RegleRoot<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules extends Record<string, any> ? TRules : {}, TValidationGroups, TShortcuts>> & StandardSchemaV1<TState>;
|
|
366
|
+
<TRules$1 extends RegleUnknownRulesTree | RegleRuleDecl, TDecl extends RegleRuleDecl<NonNullable<TState$1>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TState$1 extends Record<string, any> = InferInput<TRules$1>>(rulesFactory: TState$1 extends Record<string, any> ? MaybeRef<TRules$1> | ((...args: any[]) => TRules$1) : {}, options?: useRulesFnOptions<TRules$1, TValidationGroups, TState$1>): NonNullable<TState$1> extends PrimitiveTypes ? Raw<RegleFieldStatus<NonNullable<TState$1>, TDecl, TShortcuts>> & StandardSchemaV1<TState$1> : Raw<RegleRoot<TState$1 extends Record<string, any> ? Unwrap<TState$1> : {}, TRules$1 extends Record<string, any> ? TRules$1 : {}, TValidationGroups, TShortcuts>> & StandardSchemaV1<TState$1>;
|
|
1560
367
|
__config?: {
|
|
1561
368
|
rules?: () => CustomRulesDeclarationTree;
|
|
1562
369
|
modifiers?: RegleBehaviourOptions;
|
|
@@ -1598,16 +405,16 @@ type InferRegleShortcuts<T extends useRegleFn<any, any>> = T extends useRegleFn<
|
|
|
1598
405
|
/**
|
|
1599
406
|
* Extract a set rules and setting them as required
|
|
1600
407
|
*/
|
|
1601
|
-
type RegleEnforceRequiredRules<TRules extends keyof DefaultValidators> = Omit<Partial<DefaultValidatorsTree>, TRules> & { [K in TRules]-?: UnwrapRuleWithParams<DefaultValidators[K]> };
|
|
408
|
+
type RegleEnforceRequiredRules<TRules$1 extends keyof DefaultValidators> = Omit<Partial<DefaultValidatorsTree>, TRules$1> & { [K in TRules$1]-?: UnwrapRuleWithParams<DefaultValidators[K]> };
|
|
1602
409
|
/**
|
|
1603
410
|
* Extract a set of custom rules from a global configuration and setting them as required
|
|
1604
411
|
|
|
1605
412
|
*/
|
|
1606
|
-
type RegleEnforceCustomRequiredRules<T extends useRegleFn<any, any>, TRules extends keyof InferRegleRules<T>> = Omit<Partial<DefaultValidatorsTree>, TRules> & { [K in TRules]-?: T extends useRegleFn<any, any> ? K extends keyof InferRegleRules<T> ? NonNullable<UnwrapRuleWithParams<InferRegleRules<T>[K]>> : never : K extends keyof T ? NonNullable<T[K]> : never };
|
|
413
|
+
type RegleEnforceCustomRequiredRules<T extends useRegleFn<any, any>, TRules$1 extends keyof InferRegleRules<T>> = Omit<Partial<DefaultValidatorsTree>, TRules$1> & { [K in TRules$1]-?: T extends useRegleFn<any, any> ? K extends keyof InferRegleRules<T> ? NonNullable<UnwrapRuleWithParams<InferRegleRules<T>[K]>> : never : K extends keyof T ? NonNullable<T[K]> : never };
|
|
1607
414
|
/**
|
|
1608
415
|
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1609
416
|
*/
|
|
1610
|
-
type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState extends unknown = any, TRules extends keyof InferRegleRules<T> = never> = RegleFieldStatus<TState, [TRules] extends [never] ? Partial<InferRegleRules<T>> : RegleEnforceCustomRequiredRules<T, TRules>, InferRegleShortcuts<T>>;
|
|
417
|
+
type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState$1 extends unknown = any, TRules$1 extends keyof InferRegleRules<T> = never> = RegleFieldStatus<TState$1, [TRules$1] extends [never] ? Partial<InferRegleRules<T>> : RegleEnforceCustomRequiredRules<T, TRules$1>, InferRegleShortcuts<T>>;
|
|
1611
418
|
//#endregion
|
|
1612
419
|
//#region src/types/utils/mismatch.types.d.ts
|
|
1613
420
|
/**
|
|
@@ -1625,7 +432,7 @@ type TypeError<Msg> = {
|
|
|
1625
432
|
type Coerce<T> = `${T & string}`;
|
|
1626
433
|
//#endregion
|
|
1627
434
|
//#region src/types/utils/object.types.d.ts
|
|
1628
|
-
type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
|
|
435
|
+
type RemoveCommonKey<T extends readonly any[], K$1 extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K$1>>, ...RemoveCommonKey<R, K$1>] : [];
|
|
1629
436
|
/**
|
|
1630
437
|
* Restore the optional properties (with ?) of a generated mapped object type
|
|
1631
438
|
*/
|
|
@@ -1638,7 +445,7 @@ type HaveAnyRequiredProps<TObject extends Record<string, any>> = [TObject] exten
|
|
|
1638
445
|
/**
|
|
1639
446
|
* Get item value from object, otherwise fallback to undefined. Avoid TS to not be able to infer keys not present on all unions
|
|
1640
447
|
*/
|
|
1641
|
-
type GetMaybeObjectValue<O extends Record<string, any>, K extends string> = K extends keyof O ? O[K] : undefined;
|
|
448
|
+
type GetMaybeObjectValue<O extends Record<string, any>, K$1 extends string> = K$1 extends keyof O ? O[K$1] : undefined;
|
|
1642
449
|
/**
|
|
1643
450
|
* Combine all union values to be able to get even the normally "never" values, act as an intersection type
|
|
1644
451
|
*/
|
|
@@ -1663,19 +470,19 @@ type EnumLike = {
|
|
|
1663
470
|
type enumType<T extends Record<string, unknown>> = T[keyof T];
|
|
1664
471
|
type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
1665
472
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1666
|
-
type HasNamedKeys<T> = IsUnion<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
|
|
473
|
+
type HasNamedKeys<T> = IsUnion$1<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
|
|
1667
474
|
type ProcessHasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
|
|
1668
475
|
//#endregion
|
|
1669
476
|
//#region src/types/utils/infer.types.d.ts
|
|
1670
|
-
type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>) | MaybeRef<StandardSchemaV1<any>>, TMarkMaybe extends boolean = true> = TRules extends MaybeRef<StandardSchemaV1<infer State>> ? State : IsUnion
|
|
477
|
+
type InferInput<TRules$1 extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>) | MaybeRef<StandardSchemaV1<any>>, TMarkMaybe extends boolean = true> = TRules$1 extends MaybeRef<StandardSchemaV1<infer State>> ? State : IsUnion<UnwrapSimple<TRules$1>> extends true ? InferTupleUnionInput<UnionToTuple<UnwrapSimple<TRules$1>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? K : never]?: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> } & { [K in keyof UnwrapSimple<TRules$1> as UnwrapSimple<TRules$1>[K] extends MaybeRef<RegleRuleDecl<any, any>> ? never : K]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules$1>]: ProcessInputChildren<UnwrapSimple<TRules$1>[K], TMarkMaybe> }>;
|
|
1671
478
|
type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
|
|
1672
479
|
$each: RegleCollectionEachRules<any, any>;
|
|
1673
480
|
} ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any, any> ? InferInput<ExtractFromGetter<TRule['$each']>, TMarkMaybe>[] : any[] : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? [ExtractTypeFromRules<UnwrapRef<TRule>>] extends [never] ? unknown : ExtractTypeFromRules<UnwrapRef<TRule>> : TRule extends ReglePartialRuleTree<any, any> ? InferInput<TRule, TMarkMaybe> : string;
|
|
1674
|
-
type ExtractTypeFromRules<TRules extends RegleRuleDecl<any, any>> = FilterRulesWithInput<TRules> extends {
|
|
481
|
+
type ExtractTypeFromRules<TRules$1 extends RegleRuleDecl<any, any>> = FilterRulesWithInput<TRules$1> extends {
|
|
1675
482
|
type: infer Input;
|
|
1676
|
-
} ? Input : [FilterRulesWithSingleType<TRules>[keyof FilterRulesWithSingleType<TRules>]] extends [never] ? FilterRulesWithInput<TRules>[keyof FilterRulesWithInput<TRules>] : FilterRulesWithSingleType<TRules>[keyof FilterRulesWithSingleType<TRules>];
|
|
1677
|
-
type FilterRulesWithInput<TRules extends RegleRuleDecl<any, any>> = { [K in keyof TRules as TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : K : never]: TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? Input : unknown };
|
|
1678
|
-
type FilterRulesWithSingleType<TRules extends RegleRuleDecl<any, any>> = { [K in keyof TRules as TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion
|
|
483
|
+
} ? Input : [FilterRulesWithSingleType<TRules$1>[keyof FilterRulesWithSingleType<TRules$1>]] extends [never] ? FilterRulesWithInput<TRules$1>[keyof FilterRulesWithInput<TRules$1>] : FilterRulesWithSingleType<TRules$1>[keyof FilterRulesWithSingleType<TRules$1>];
|
|
484
|
+
type FilterRulesWithInput<TRules$1 extends RegleRuleDecl<any, any>> = { [K in keyof TRules$1 as TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : K : never]: TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? Input : unknown };
|
|
485
|
+
type FilterRulesWithSingleType<TRules$1 extends RegleRuleDecl<any, any>> = { [K in keyof TRules$1 as TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion<NonNullable<Input>> extends true ? never : K : never]: TRules$1[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? IsUnion<NonNullable<Input>> extends true ? unknown : Input : unknown };
|
|
1679
486
|
type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
|
|
1680
487
|
//#endregion
|
|
1681
488
|
//#region src/types/rules/rule.params.types.d.ts
|
|
@@ -1685,23 +492,23 @@ type CreateFn<T extends any[]> = (...args: T) => any;
|
|
|
1685
492
|
*
|
|
1686
493
|
* [foo: string, bar?: number] => [foo: MaybeRef<string> | (() => string), bar?: MaybeRef<number | undefined> | (() => number) | undefined]
|
|
1687
494
|
*/
|
|
1688
|
-
type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>> }) => any : never>;
|
|
1689
|
-
type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K] }) => any : never>;
|
|
495
|
+
type RegleUniversalParams<T extends any[] = [], F$1 = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F$1 extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>> }) => any : never>;
|
|
496
|
+
type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F$1 = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F$1 extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K] }) => any : never>;
|
|
1690
497
|
//#endregion
|
|
1691
498
|
//#region src/types/rules/rule.internal.types.d.ts
|
|
1692
499
|
/**
|
|
1693
500
|
* Internal definition of the rule, this can be used to reset or patch the rule
|
|
1694
501
|
*/
|
|
1695
|
-
type RegleInternalRuleDefs<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> = Raw<{
|
|
1696
|
-
_validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
1697
|
-
_message: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
|
|
1698
|
-
_active?: boolean | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => boolean);
|
|
1699
|
-
_tooltip?: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
|
|
502
|
+
type RegleInternalRuleDefs<TValue$1 extends any = any, TParams$1 extends any[] = [], TAsync$1 extends boolean = false, TMetadata$1 extends RegleRuleMetadataDefinition = boolean> = Raw<{
|
|
503
|
+
_validator: (value: Maybe<TValue$1>, ...args: TParams$1) => TAsync$1 extends false ? TMetadata$1 : Promise<TMetadata$1>;
|
|
504
|
+
_message: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue$1>) => string | string[]);
|
|
505
|
+
_active?: boolean | ((metadata: PossibleRegleRuleMetadataConsumer<TValue$1>) => boolean);
|
|
506
|
+
_tooltip?: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue$1>) => string | string[]);
|
|
1700
507
|
_type?: string;
|
|
1701
508
|
_message_patched: boolean;
|
|
1702
509
|
_tooltip_patched: boolean;
|
|
1703
|
-
_params?: RegleUniversalParams<TParams>;
|
|
1704
|
-
_async: TAsync;
|
|
510
|
+
_params?: RegleUniversalParams<TParams$1>;
|
|
511
|
+
_async: TAsync$1;
|
|
1705
512
|
readonly _brand: symbol;
|
|
1706
513
|
}>;
|
|
1707
514
|
declare const InternalRuleType: {
|
|
@@ -1715,25 +522,25 @@ type IsLiteral<T> = string extends T ? false : true;
|
|
|
1715
522
|
/**
|
|
1716
523
|
* Returned typed of rules created with `createRule`
|
|
1717
524
|
* */
|
|
1718
|
-
interface RegleRuleDefinition<TValue extends unknown = unknown, TParams extends any[] = [], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, _TInput = unknown, TFilteredValue extends any = (TValue extends Date & File & infer M ? M : TValue)> extends RegleInternalRuleDefs<TFilteredValue, TParams, TAsync, TMetaData> {
|
|
1719
|
-
validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
|
|
525
|
+
interface RegleRuleDefinition<TValue$1 extends unknown = unknown, TParams$1 extends any[] = [], TAsync$1 extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, _TInput = unknown, TFilteredValue extends any = (TValue$1 extends Date & File & infer M ? M : TValue$1)> extends RegleInternalRuleDefs<TFilteredValue, TParams$1, TAsync$1, TMetaData> {
|
|
526
|
+
validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams$1, TAsync$1 extends false ? TMetaData : Promise<TMetaData>>;
|
|
1720
527
|
message: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
|
|
1721
528
|
active: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => boolean;
|
|
1722
529
|
tooltip: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
|
|
1723
530
|
type?: string;
|
|
1724
|
-
_value?: IsLiteral<TValue> extends true ? TValue : any;
|
|
1725
|
-
exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
|
|
531
|
+
_value?: IsLiteral<TValue$1> extends true ? TValue$1 : any;
|
|
532
|
+
exec: (value: Maybe<TFilteredValue>) => TAsync$1 extends false ? TMetaData : Promise<TMetaData>;
|
|
1726
533
|
}
|
|
1727
534
|
/**
|
|
1728
535
|
* Rules with params created with `createRules` are callable while being customizable
|
|
1729
536
|
*/
|
|
1730
|
-
type RegleRuleWithParamsDefinition<TValue extends unknown = unknown, TParams extends any[] = never, TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean, TInput = unknown, TFilteredValue extends any = (TValue extends Date & File & infer M ? M : TValue)> = RegleRuleCore<TFilteredValue, TParams, TAsync, TMetadata> & RegleInternalRuleDefs<TFilteredValue, TParams, TAsync, TMetadata> & {
|
|
1731
|
-
(...params: RegleUniversalParams<TParams>): RegleRuleDefinition<TFilteredValue, TParams, TAsync, TMetadata, TInput>;
|
|
1732
|
-
} & (TParams extends [param?: any, ...any[]] ? {
|
|
1733
|
-
exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
537
|
+
type RegleRuleWithParamsDefinition<TValue$1 extends unknown = unknown, TParams$1 extends any[] = never, TAsync$1 extends boolean = false, TMetadata$1 extends RegleRuleMetadataDefinition = boolean, TInput = unknown, TFilteredValue extends any = (TValue$1 extends Date & File & infer M ? M : TValue$1)> = RegleRuleCore<TFilteredValue, TParams$1, TAsync$1, TMetadata$1> & RegleInternalRuleDefs<TFilteredValue, TParams$1, TAsync$1, TMetadata$1> & {
|
|
538
|
+
(...params: RegleUniversalParams<TParams$1>): RegleRuleDefinition<TFilteredValue, TParams$1, TAsync$1, TMetadata$1, TInput>;
|
|
539
|
+
} & (TParams$1 extends [param?: any, ...any[]] ? {
|
|
540
|
+
exec: (value: Maybe<TFilteredValue>) => TAsync$1 extends false ? TMetadata$1 : Promise<TMetadata$1>;
|
|
1734
541
|
} : {});
|
|
1735
|
-
type RegleRuleWithParamsDefinitionInput<TValue extends any = any, TParams extends any[] = never, TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean, TFilteredValue extends any = (TValue extends Date & File & infer M ? M : TValue)> = RegleRuleCore<TFilteredValue, TParams, TAsync, TMetadata> & RegleInternalRuleDefs<TFilteredValue, TParams, TAsync, TMetadata> & (TParams extends [param?: any, ...any[]] ? {
|
|
1736
|
-
exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
542
|
+
type RegleRuleWithParamsDefinitionInput<TValue$1 extends any = any, TParams$1 extends any[] = never, TAsync$1 extends boolean = false, TMetadata$1 extends RegleRuleMetadataDefinition = boolean, TFilteredValue extends any = (TValue$1 extends Date & File & infer M ? M : TValue$1)> = RegleRuleCore<TFilteredValue, TParams$1, TAsync$1, TMetadata$1> & RegleInternalRuleDefs<TFilteredValue, TParams$1, TAsync$1, TMetadata$1> & (TParams$1 extends [param?: any, ...any[]] ? {
|
|
543
|
+
exec: (value: Maybe<TFilteredValue>) => TAsync$1 extends false ? TMetadata$1 : Promise<TMetadata$1>;
|
|
1737
544
|
} : {});
|
|
1738
545
|
type RegleRuleMetadataExtended = {
|
|
1739
546
|
$valid: boolean;
|
|
@@ -1754,24 +561,24 @@ type DefaultMetadataProperties = DefaultMetadataPropertiesCommon & {
|
|
|
1754
561
|
/**
|
|
1755
562
|
* Will be used to consume metadata on related helpers and rule status
|
|
1756
563
|
*/
|
|
1757
|
-
type RegleRuleMetadataConsumer<TValue extends any, TParams extends [...any[]] = never, TMetadata extends RegleRuleMetadataDefinition = boolean> = {
|
|
1758
|
-
$value: Maybe<TValue>;
|
|
1759
|
-
} & DefaultMetadataProperties & (TParams extends never ? {} : {
|
|
1760
|
-
$params: [...TParams];
|
|
1761
|
-
}) & (Exclude<TMetadata, boolean> extends RegleRuleMetadataExtended ? TMetadata extends boolean ? Partial<Omit<Exclude<TMetadata, boolean>, '$valid'>> : Omit<Exclude<TMetadata, boolean>, '$valid'> : {});
|
|
564
|
+
type RegleRuleMetadataConsumer<TValue$1 extends any, TParams$1 extends [...any[]] = never, TMetadata$1 extends RegleRuleMetadataDefinition = boolean> = {
|
|
565
|
+
$value: Maybe<TValue$1>;
|
|
566
|
+
} & DefaultMetadataProperties & (TParams$1 extends never ? {} : {
|
|
567
|
+
$params: [...TParams$1];
|
|
568
|
+
}) & (Exclude<TMetadata$1, boolean> extends RegleRuleMetadataExtended ? TMetadata$1 extends boolean ? Partial<Omit<Exclude<TMetadata$1, boolean>, '$valid'>> : Omit<Exclude<TMetadata$1, boolean>, '$valid'> : {});
|
|
1762
569
|
/**
|
|
1763
570
|
* Will be used to consume metadata on related helpers and rule status
|
|
1764
571
|
*/
|
|
1765
|
-
type PossibleRegleRuleMetadataConsumer<TValue> = {
|
|
1766
|
-
$value: Maybe<TValue>;
|
|
572
|
+
type PossibleRegleRuleMetadataConsumer<TValue$1> = {
|
|
573
|
+
$value: Maybe<TValue$1>;
|
|
1767
574
|
} & DefaultMetadataProperties & {
|
|
1768
575
|
$params?: [...any[]];
|
|
1769
576
|
};
|
|
1770
577
|
/**
|
|
1771
578
|
* Generic types for a created RegleRule
|
|
1772
579
|
*/
|
|
1773
|
-
type RegleRuleRaw<TValue extends any = any, TParams extends [...any[]] = [...any[]], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = boolean> = RegleRuleDefinition<TValue, TParams, TAsync, TMetaData> | RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetaData>;
|
|
1774
|
-
type RegleRuleRawInput<TValue extends any = any, TParams extends [...any[]] = [...any[]], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = boolean> = Omit<RegleRuleDefinition<TValue, TParams, TAsync, TMetaData> | RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetaData>, 'message' | 'tooltip' | 'active'> & {
|
|
580
|
+
type RegleRuleRaw<TValue$1 extends any = any, TParams$1 extends [...any[]] = [...any[]], TAsync$1 extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = boolean> = RegleRuleDefinition<TValue$1, TParams$1, TAsync$1, TMetaData> | RegleRuleWithParamsDefinition<TValue$1, TParams$1, TAsync$1, TMetaData>;
|
|
581
|
+
type RegleRuleRawInput<TValue$1 extends any = any, TParams$1 extends [...any[]] = [...any[]], TAsync$1 extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = boolean> = Omit<RegleRuleDefinition<TValue$1, TParams$1, TAsync$1, TMetaData> | RegleRuleWithParamsDefinition<TValue$1, TParams$1, TAsync$1, TMetaData>, 'message' | 'tooltip' | 'active'> & {
|
|
1775
582
|
message: any;
|
|
1776
583
|
active?: any;
|
|
1777
584
|
tooltip?: any;
|
|
@@ -1781,44 +588,44 @@ type RegleRuleRawInput<TValue extends any = any, TParams extends [...any[]] = [.
|
|
|
1781
588
|
* For a rule with params it will return a function
|
|
1782
589
|
* Otherwise it will return the rule definition
|
|
1783
590
|
*/
|
|
1784
|
-
type InferRegleRule<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetaData extends RegleRuleMetadataDefinition = boolean> = [TParams] extends [[]] ? RegleRuleDefinition<TValue, TParams, TAsync, TMetaData> : RegleRuleWithParamsDefinition<TValue, TParams, TAsync, TMetaData>;
|
|
1785
|
-
type RegleRuleDefinitionProcessor<TValue extends any = any, TParams extends any[] = [], TReturn = any> = (value: Maybe<TValue>, ...params: TParams) => TReturn;
|
|
1786
|
-
type RegleRuleDefinitionWithMetadataProcessor<TValue extends any, TMetadata extends RegleRuleMetadataConsumer<TValue, any[]>, TReturn = any> = ((metadata: TMetadata) => TReturn) | TReturn;
|
|
1787
|
-
type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions> & {
|
|
1788
|
-
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
591
|
+
type InferRegleRule<TValue$1 extends any = any, TParams$1 extends any[] = [], TAsync$1 extends boolean = false, TMetaData extends RegleRuleMetadataDefinition = boolean> = [TParams$1] extends [[]] ? RegleRuleDefinition<TValue$1, TParams$1, TAsync$1, TMetaData> : RegleRuleWithParamsDefinition<TValue$1, TParams$1, TAsync$1, TMetaData>;
|
|
592
|
+
type RegleRuleDefinitionProcessor<TValue$1 extends any = any, TParams$1 extends any[] = [], TReturn = any> = (value: Maybe<TValue$1>, ...params: TParams$1) => TReturn;
|
|
593
|
+
type RegleRuleDefinitionWithMetadataProcessor<TValue$1 extends any, TMetadata$1 extends RegleRuleMetadataConsumer<TValue$1, any[]>, TReturn = any> = ((metadata: TMetadata$1) => TReturn) | TReturn;
|
|
594
|
+
type RegleCollectionRuleDefinition<TValue$1 = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue$1>, TCustomRules, CollectionRegleBehaviourOptions> & {
|
|
595
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue$1>>, TCustomRules>, ArrayElement<TValue$1>>;
|
|
1789
596
|
}) | ({
|
|
1790
|
-
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
597
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue$1>>, TCustomRules>, ArrayElement<TValue$1>>;
|
|
1791
598
|
} & CollectionRegleBehaviourOptions);
|
|
1792
599
|
//#endregion
|
|
1793
600
|
//#region src/types/rules/rule.init.types.d.ts
|
|
1794
|
-
type RegleInitPropertyGetter<TValue, TReturn, TParams extends [...any[]], TMetadata extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue, TParams, TMetadata>) => TReturn);
|
|
601
|
+
type RegleInitPropertyGetter<TValue$1, TReturn, TParams$1 extends [...any[]], TMetadata$1 extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue$1, TParams$1, TMetadata$1>) => TReturn);
|
|
1795
602
|
/**
|
|
1796
603
|
* @argument
|
|
1797
604
|
* createRule arguments options
|
|
1798
605
|
*/
|
|
1799
|
-
interface RegleRuleInit<TValue extends any, TParams extends [...any[]] = [], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean, TMetadata extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TAsync extends boolean = (TReturn extends Promise<any> ? true : false)> {
|
|
1800
|
-
validator: (value: Maybe<TValue>, ...args: TParams) => TReturn;
|
|
1801
|
-
message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
1802
|
-
active?: RegleInitPropertyGetter<TValue, boolean, TParams, TMetadata>;
|
|
1803
|
-
tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
606
|
+
interface RegleRuleInit<TValue$1 extends any, TParams$1 extends [...any[]] = [], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean, TMetadata$1 extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, TAsync$1 extends boolean = (TReturn extends Promise<any> ? true : false)> {
|
|
607
|
+
validator: (value: Maybe<TValue$1>, ...args: TParams$1) => TReturn;
|
|
608
|
+
message: RegleInitPropertyGetter<TValue$1, string | string[], TParams$1, TMetadata$1>;
|
|
609
|
+
active?: RegleInitPropertyGetter<TValue$1, boolean, TParams$1, TMetadata$1>;
|
|
610
|
+
tooltip?: RegleInitPropertyGetter<TValue$1, string | string[], TParams$1, TMetadata$1>;
|
|
1804
611
|
type?: string;
|
|
1805
|
-
async?: TAsync;
|
|
612
|
+
async?: TAsync$1;
|
|
1806
613
|
}
|
|
1807
614
|
/**
|
|
1808
615
|
* @argument
|
|
1809
616
|
* Rule core
|
|
1810
617
|
*/
|
|
1811
|
-
interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> {
|
|
1812
|
-
validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
|
|
1813
|
-
message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
1814
|
-
active?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
1815
|
-
tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
|
|
618
|
+
interface RegleRuleCore<TValue$1 extends any, TParams$1 extends any[] = [], TAsync$1 extends boolean = false, TMetadata$1 extends RegleRuleMetadataDefinition = boolean> {
|
|
619
|
+
validator: (value: Maybe<TValue$1>, ...args: TParams$1) => TAsync$1 extends false ? TMetadata$1 : Promise<TMetadata$1>;
|
|
620
|
+
message: RegleInitPropertyGetter<TValue$1, string | string[], TParams$1, TMetadata$1>;
|
|
621
|
+
active?: RegleInitPropertyGetter<TValue$1, string | string[], TParams$1, TMetadata$1>;
|
|
622
|
+
tooltip?: RegleInitPropertyGetter<TValue$1, string | string[], TParams$1, TMetadata$1>;
|
|
1816
623
|
type?: string;
|
|
1817
624
|
async?: boolean;
|
|
1818
625
|
}
|
|
1819
|
-
type RegleRuleTypeReturn<TValue, TParams extends [...any[]]> = {
|
|
1820
|
-
value: TValue;
|
|
1821
|
-
params: [...TParams];
|
|
626
|
+
type RegleRuleTypeReturn<TValue$1, TParams$1 extends [...any[]]> = {
|
|
627
|
+
value: TValue$1;
|
|
628
|
+
params: [...TParams$1];
|
|
1822
629
|
};
|
|
1823
630
|
//#endregion
|
|
1824
631
|
//#region src/core/defaultValidators.d.ts
|
|
@@ -1911,7 +718,7 @@ type RegleUnknownRulesTree = {
|
|
|
1911
718
|
/**
|
|
1912
719
|
* @public
|
|
1913
720
|
*/
|
|
1914
|
-
type RegleComputedRules<TForm extends MaybeRef<Record<string, any>> | DeepReactiveState<Record<string, any>>, TCustomRules extends Partial<AllRulesDeclarations> | Regle<any, any> = Partial<AllRulesDeclarations>, TState = Unwrap<TForm>, TCustom = (TCustomRules extends Regle<any, infer R> ? R extends ReglePartialRuleTree<any, infer C> ? C : Partial<AllRulesDeclarations> : TCustomRules)> = { [TKey in keyof JoinDiscriminatedUnions<TState>]?: RegleFormPropertyType<JoinDiscriminatedUnions<TState>[TKey], TCustom extends Partial<AllRulesDeclarations> ? TCustom : {}> };
|
|
721
|
+
type RegleComputedRules<TForm extends MaybeRef<Record<string, any>> | DeepReactiveState<Record<string, any>>, TCustomRules extends Partial<AllRulesDeclarations> | Regle<any, any> = Partial<AllRulesDeclarations>, TState$1 = Unwrap<TForm>, TCustom = (TCustomRules extends Regle<any, infer R> ? R extends ReglePartialRuleTree<any, infer C> ? C : Partial<AllRulesDeclarations> : TCustomRules)> = { [TKey in keyof JoinDiscriminatedUnions<TState$1>]?: RegleFormPropertyType<JoinDiscriminatedUnions<TState$1>[TKey], TCustom extends Partial<AllRulesDeclarations> ? TCustom : {}> };
|
|
1915
722
|
/**
|
|
1916
723
|
* @internal
|
|
1917
724
|
* @reference {@link ReglePartialRuleTree}
|
|
@@ -1922,7 +729,7 @@ type $InternalReglePartialRuleTree = {
|
|
|
1922
729
|
/**
|
|
1923
730
|
* @public
|
|
1924
731
|
*/
|
|
1925
|
-
type RegleFormPropertyType<TValue = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = [NonNullable<TValue>] extends [never] ? MaybeRef<RegleRuleDecl<TValue, TCustomRules>> : NonNullable<TValue> extends Array<any> ? RegleCollectionRuleDecl<TValue, TCustomRules> : NonNullable<TValue> extends Date ? MaybeRef<RegleRuleDecl<NonNullable<TValue>, TCustomRules>> : NonNullable<TValue> extends File ? MaybeRef<RegleRuleDecl<NonNullable<TValue>, TCustomRules>> : NonNullable<TValue> extends Ref<infer V> ? RegleFormPropertyType<V, TCustomRules> : NonNullable<TValue> extends Record<string, any> ? ReglePartialRuleTree<NonNullable<TValue>, TCustomRules> : MaybeRef<RegleRuleDecl<NonNullable<TValue>, TCustomRules>>;
|
|
732
|
+
type RegleFormPropertyType<TValue$1 = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = [NonNullable<TValue$1>] extends [never] ? MaybeRef<RegleRuleDecl<TValue$1, TCustomRules>> : NonNullable<TValue$1> extends Array<any> ? RegleCollectionRuleDecl<TValue$1, TCustomRules> : NonNullable<TValue$1> extends Date ? MaybeRef<RegleRuleDecl<NonNullable<TValue$1>, TCustomRules>> : NonNullable<TValue$1> extends File ? MaybeRef<RegleRuleDecl<NonNullable<TValue$1>, TCustomRules>> : NonNullable<TValue$1> extends Ref<infer V> ? RegleFormPropertyType<V, TCustomRules> : NonNullable<TValue$1> extends Record<string, any> ? ReglePartialRuleTree<NonNullable<TValue$1>, TCustomRules> : MaybeRef<RegleRuleDecl<NonNullable<TValue$1>, TCustomRules>>;
|
|
1926
733
|
/**
|
|
1927
734
|
* @internal
|
|
1928
735
|
* @reference {@link RegleFormPropertyType}
|
|
@@ -1932,7 +739,7 @@ type $InternalFormPropertyTypes = MaybeRef<$InternalRegleRuleDecl> | $InternalRe
|
|
|
1932
739
|
* @public
|
|
1933
740
|
* Rule tree for a form property
|
|
1934
741
|
*/
|
|
1935
|
-
type RegleRuleDecl<TValue extends any = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>, TOptions extends Record<string, unknown> = FieldRegleBehaviourOptions> = TOptions & { [TKey in keyof TCustomRules]?: NonNullable<TCustomRules[TKey]> extends RegleRuleWithParamsDefinition<any, infer TParams> ? RegleRuleDefinition<TValue, [...TParams, ...args: [...any[]]], boolean> : NonNullable<TCustomRules[TKey]> extends RegleRuleDefinition<any, any[], any, any> ? FormRuleDeclaration<TValue, any[]> : FormRuleDeclaration<TValue, any[]> | TOptions[keyof TOptions] };
|
|
742
|
+
type RegleRuleDecl<TValue$1 extends any = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>, TOptions extends Record<string, unknown> = FieldRegleBehaviourOptions> = TOptions & { [TKey in keyof TCustomRules]?: NonNullable<TCustomRules[TKey]> extends RegleRuleWithParamsDefinition<any, infer TParams> ? RegleRuleDefinition<TValue$1, [...TParams, ...args: [...any[]]], boolean> : NonNullable<TCustomRules[TKey]> extends RegleRuleDefinition<any, any[], any, any> ? FormRuleDeclaration<TValue$1, any[]> : FormRuleDeclaration<TValue$1, any[]> | TOptions[keyof TOptions] };
|
|
1936
743
|
/**
|
|
1937
744
|
* @internal
|
|
1938
745
|
* @reference {@link RegleRuleDecl}
|
|
@@ -1947,13 +754,13 @@ type RegleCollectionRuleDeclKeyProperty = {
|
|
|
1947
754
|
/**
|
|
1948
755
|
* @public
|
|
1949
756
|
*/
|
|
1950
|
-
type RegleCollectionRuleDecl<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = ({
|
|
1951
|
-
$each?: RegleCollectionEachRules<TValue, TCustomRules>;
|
|
1952
|
-
} & RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions>) | ({
|
|
1953
|
-
$each?: RegleCollectionEachRules<TValue, TCustomRules>;
|
|
757
|
+
type RegleCollectionRuleDecl<TValue$1 = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = ({
|
|
758
|
+
$each?: RegleCollectionEachRules<TValue$1, TCustomRules>;
|
|
759
|
+
} & RegleRuleDecl<NonNullable<TValue$1>, TCustomRules, CollectionRegleBehaviourOptions>) | ({
|
|
760
|
+
$each?: RegleCollectionEachRules<TValue$1, TCustomRules>;
|
|
1954
761
|
} & CollectionRegleBehaviourOptions);
|
|
1955
762
|
/** @public */
|
|
1956
|
-
type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>, RegleCollectionRuleDeclKeyProperty>;
|
|
763
|
+
type RegleCollectionEachRules<TValue$1 = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue$1>>, TCustomRules>, ArrayElement<TValue$1>, RegleCollectionRuleDeclKeyProperty>;
|
|
1957
764
|
/**
|
|
1958
765
|
* @internal
|
|
1959
766
|
* @reference {@link RegleCollectionRuleDecl}
|
|
@@ -1964,49 +771,49 @@ type $InternalRegleCollectionRuleDecl = $InternalRegleRuleDecl & {
|
|
|
1964
771
|
/**
|
|
1965
772
|
* @public
|
|
1966
773
|
*/
|
|
1967
|
-
type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean> = (value: Maybe<TValue>, ...args: UnwrapRegleUniversalParams<TParams>) => TReturn;
|
|
774
|
+
type InlineRuleDeclaration<TValue$1 extends any = any, TParams$1 extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean> = (value: Maybe<TValue$1>, ...args: UnwrapRegleUniversalParams<TParams$1>) => TReturn;
|
|
1968
775
|
/**
|
|
1969
776
|
* @public
|
|
1970
777
|
* Regroup inline and registered rules
|
|
1971
778
|
* */
|
|
1972
|
-
type FormRuleDeclaration<TValue extends any = unknown, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = boolean> = InlineRuleDeclaration<TValue, TParams, TReturn> | RegleRuleDefinition<TValue, TParams, TAsync, TMetadata> | RegleRuleWithParamsDefinitionInput<TValue, [param?: any], TAsync, TMetadata> | RegleRuleWithParamsDefinitionInput<TValue, [param?: any, ...any[]], TAsync, TMetadata>;
|
|
779
|
+
type FormRuleDeclaration<TValue$1 extends any = unknown, TParams$1 extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata$1 extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync$1 extends boolean = boolean> = InlineRuleDeclaration<TValue$1, TParams$1, TReturn> | RegleRuleDefinition<TValue$1, TParams$1, TAsync$1, TMetadata$1> | RegleRuleWithParamsDefinitionInput<TValue$1, [param?: any], TAsync$1, TMetadata$1> | RegleRuleWithParamsDefinitionInput<TValue$1, [param?: any, ...any[]], TAsync$1, TMetadata$1>;
|
|
1973
780
|
//#endregion
|
|
1974
781
|
//#region src/types/rules/rule.status.types.d.ts
|
|
1975
782
|
/**
|
|
1976
783
|
* @public
|
|
1977
784
|
*/
|
|
1978
|
-
type RegleRoot<TState extends Record<string, unknown> = {}, TRules extends ReglePartialRuleTree<TState> = Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never, TShortcuts extends RegleShortcutDefinition = {}> = MaybeVariantStatus<TState, TRules, TShortcuts> & ([TValidationGroups] extends [never] ? {} : {
|
|
785
|
+
type RegleRoot<TState$1 extends Record<string, unknown> = {}, TRules$1 extends ReglePartialRuleTree<TState$1> = Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never, TShortcuts extends RegleShortcutDefinition = {}> = MaybeVariantStatus<TState$1, TRules$1, TShortcuts> & ([TValidationGroups] extends [never] ? {} : {
|
|
1979
786
|
/**
|
|
1980
787
|
* Collection of validation groups used declared with the `validationGroups` modifier
|
|
1981
788
|
*/
|
|
1982
789
|
$groups: { readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput };
|
|
1983
790
|
});
|
|
1984
|
-
type ProcessNestedFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}, TIsFields extends boolean = false> = Or<HasNamedKeys<TState>, TIsFields> extends true ? { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules[TKey]> extends true ? TKey : never : never : TKey]: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } & { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules[TKey]> extends true ? never : TKey : TKey : never]-?: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } : {};
|
|
791
|
+
type ProcessNestedFields<TState$1 extends Record<string, any> | undefined, TRules$1 extends ReglePartialRuleTree<NonNullable<TState$1>>, TShortcuts extends RegleShortcutDefinition = {}, TIsFields extends boolean = false> = Or<HasNamedKeys<TState$1>, TIsFields> extends true ? { readonly [TKey in keyof TState$1 as TRules$1[TKey] extends NonNullable<TRules$1[TKey]> ? NonNullable<TRules$1[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules$1[TKey]> extends true ? TKey : never : never : TKey]: IsUnion$1<NonNullable<TRules$1[TKey]>> extends true ? ExtendOnlyRealRecord<TState$1[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState$1>[TKey], NonNullable<TRules$1[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules$1[TKey]>, NonNullable<TState$1>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules$1[TKey]>, NonNullable<TState$1>, TKey, TShortcuts> } & { readonly [TKey in keyof TState$1 as TRules$1[TKey] extends NonNullable<TRules$1[TKey]> ? NonNullable<TRules$1[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules$1[TKey]> extends true ? never : TKey : TKey : never]-?: IsUnion$1<NonNullable<TRules$1[TKey]>> extends true ? ExtendOnlyRealRecord<TState$1[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState$1>[TKey], NonNullable<TRules$1[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules$1[TKey]>, NonNullable<TState$1>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules$1[TKey]>, NonNullable<TState$1>, TKey, TShortcuts> } : {};
|
|
1985
792
|
/**
|
|
1986
793
|
* @public
|
|
1987
794
|
*/
|
|
1988
|
-
type RegleStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = RegleCommonStatus<TState> & {
|
|
795
|
+
type RegleStatus<TState$1 extends Record<string, any> | undefined = Record<string, any>, TRules$1 extends ReglePartialRuleTree<NonNullable<TState$1>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = RegleCommonStatus<TState$1> & {
|
|
1989
796
|
/** Represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form. */
|
|
1990
|
-
readonly $fields: ProcessNestedFields<TState, TRules, TShortcuts, true>;
|
|
797
|
+
readonly $fields: ProcessNestedFields<TState$1, TRules$1, TShortcuts, true>;
|
|
1991
798
|
/**
|
|
1992
799
|
* Collection of all the issues, collected for all children properties and nested forms.
|
|
1993
800
|
*
|
|
1994
801
|
* Only contains issues from properties where $dirty equals true.
|
|
1995
802
|
*/
|
|
1996
|
-
readonly $issues: RegleIssuesTree<TState>;
|
|
803
|
+
readonly $issues: RegleIssuesTree<TState$1>;
|
|
1997
804
|
/**
|
|
1998
805
|
* Collection of all the error messages, collected for all children properties and nested forms.
|
|
1999
806
|
*
|
|
2000
807
|
* Only contains errors from properties where $dirty equals true.
|
|
2001
808
|
* */
|
|
2002
|
-
readonly $errors: RegleErrorTree<TState>;
|
|
809
|
+
readonly $errors: RegleErrorTree<TState$1>;
|
|
2003
810
|
/** Collection of all the error messages, collected for all children properties. */
|
|
2004
|
-
readonly $silentErrors: RegleErrorTree<TState>;
|
|
811
|
+
readonly $silentErrors: RegleErrorTree<TState$1>;
|
|
2005
812
|
/** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
2006
|
-
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
|
|
813
|
+
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState$1>;
|
|
2007
814
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2008
|
-
$validate: (forceValues?: JoinDiscriminatedUnions<TState> extends EmptyObject ? any : HasNamedKeys<JoinDiscriminatedUnions<TState>> extends true ? IsUnknown<JoinDiscriminatedUnions<TState>> extends true ? any : JoinDiscriminatedUnions<TState> : any) => Promise<RegleNestedResult<JoinDiscriminatedUnions<TState>, TRules>>;
|
|
2009
|
-
} & ProcessNestedFields<TState, TRules, TShortcuts> & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
|
|
815
|
+
$validate: (forceValues?: JoinDiscriminatedUnions<TState$1> extends EmptyObject ? any : HasNamedKeys<JoinDiscriminatedUnions<TState$1>> extends true ? IsUnknown<JoinDiscriminatedUnions<TState$1>> extends true ? any : JoinDiscriminatedUnions<TState$1> : any) => Promise<RegleNestedResult<JoinDiscriminatedUnions<TState$1>, TRules$1>>;
|
|
816
|
+
} & ProcessNestedFields<TState$1, TRules$1, TShortcuts> & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
|
|
2010
817
|
/**
|
|
2011
818
|
* @internal
|
|
2012
819
|
* @reference {@link RegleStatus}
|
|
@@ -2024,19 +831,19 @@ interface $InternalRegleStatus extends $InternalRegleCommonStatus {
|
|
|
2024
831
|
/**
|
|
2025
832
|
* @public
|
|
2026
833
|
*/
|
|
2027
|
-
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialRuleTree<any>, TState extends Record<PropertyKey, any> = any, TKey extends PropertyKey = string, TShortcuts extends RegleShortcutDefinition = {}> = HasNamedKeys<TState> extends true ? [TState[TKey]] extends [undefined | null] ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : NonNullable<TState[TKey]> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TRule extends RegleCollectionRuleDefinition<any, any> ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any> ? RegleCollectionStatus<TState[TKey], ExtractFromGetter<TRule['$each']>, TRule, TShortcuts> : RegleFieldStatus<TState[TKey], TRule, TShortcuts> : RegleCollectionStatus<TState[TKey], {}, TRule, TShortcuts> : RegleFieldStatus<TState[TKey], TRule, TShortcuts> : TRule extends ReglePartialRuleTree<any> ? NonNullable<TState[TKey]> extends Array<any> ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : NonNullable<TState[TKey]> extends Date | File ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : unknown extends TState[TKey] ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : NonNullable<TState[TKey]> extends Record<PropertyKey, any> ? MaybeVariantStatus<TState[TKey], TRule, TShortcuts> : RegleFieldStatus<TState[TKey], TRule, TShortcuts> : NonNullable<TState[TKey]> extends Date | File ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : unknown extends TState[TKey] ? RegleFieldStatus<TState[TKey], TRule, TShortcuts> : NonNullable<TState[TKey]> extends Record<PropertyKey, any> ? MaybeVariantStatus<TState[TKey], ReglePartialRuleTree<TState[TKey]>, TShortcuts> : RegleFieldStatus<TState[TKey], TRule, TShortcuts> : RegleCommonStatus<unknown>;
|
|
834
|
+
type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl | ReglePartialRuleTree<any>, TState$1 extends Record<PropertyKey, any> = any, TKey$1 extends PropertyKey = string, TShortcuts extends RegleShortcutDefinition = {}> = HasNamedKeys<TState$1> extends true ? [TState$1[TKey$1]] extends [undefined | null] ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : NonNullable<TState$1[TKey$1]> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TRule extends RegleCollectionRuleDefinition<any, any> ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any> ? RegleCollectionStatus<TState$1[TKey$1], ExtractFromGetter<TRule['$each']>, TRule, TShortcuts> : RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : RegleCollectionStatus<TState$1[TKey$1], {}, TRule, TShortcuts> : RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : TRule extends ReglePartialRuleTree<any> ? NonNullable<TState$1[TKey$1]> extends Array<any> ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : NonNullable<TState$1[TKey$1]> extends Date | File ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : unknown extends TState$1[TKey$1] ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : NonNullable<TState$1[TKey$1]> extends Record<PropertyKey, any> ? MaybeVariantStatus<TState$1[TKey$1], TRule, TShortcuts> : RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : NonNullable<TState$1[TKey$1]> extends Date | File ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : unknown extends TState$1[TKey$1] ? RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : NonNullable<TState$1[TKey$1]> extends Record<PropertyKey, any> ? MaybeVariantStatus<TState$1[TKey$1], ReglePartialRuleTree<TState$1[TKey$1]>, TShortcuts> : RegleFieldStatus<TState$1[TKey$1], TRule, TShortcuts> : RegleCommonStatus<unknown>;
|
|
2028
835
|
/**
|
|
2029
836
|
* @internal
|
|
2030
837
|
* @reference {@link InferRegleStatusType}
|
|
2031
838
|
*/
|
|
2032
839
|
type $InternalRegleStatusType = $InternalRegleCollectionStatus | $InternalRegleStatus | $InternalRegleFieldStatus;
|
|
2033
|
-
type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = EmptyObject> = {
|
|
840
|
+
type RegleFieldIssue<TRules$1 extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = EmptyObject> = {
|
|
2034
841
|
readonly $property: string;
|
|
2035
842
|
readonly $type?: string;
|
|
2036
843
|
readonly $message: string;
|
|
2037
|
-
} & (IsEmptyObject<TRules> extends true ? {
|
|
844
|
+
} & (IsEmptyObject<TRules$1> extends true ? {
|
|
2038
845
|
readonly $rule: string;
|
|
2039
|
-
} : { [K in keyof ComputeFieldRules<any, TRules>]: ComputeFieldRules<any, TRules>[K] extends {
|
|
846
|
+
} : { [K in keyof ComputeFieldRules<any, TRules$1>]: ComputeFieldRules<any, TRules$1>[K] extends {
|
|
2040
847
|
$metadata: infer TMetadata;
|
|
2041
848
|
} ? K extends string ? {
|
|
2042
849
|
readonly $rule: K;
|
|
@@ -2046,18 +853,18 @@ type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesD
|
|
|
2046
853
|
readonly $rule: string;
|
|
2047
854
|
} : {
|
|
2048
855
|
readonly $rule: string;
|
|
2049
|
-
} }[keyof ComputeFieldRules<any, TRules>]);
|
|
2050
|
-
type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject<TRules> extends true ? {
|
|
2051
|
-
readonly [x: string]: RegleRuleStatus<TState, any[], any>;
|
|
2052
|
-
} : { readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState, TRules[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : boolean> };
|
|
856
|
+
} }[keyof ComputeFieldRules<any, TRules$1>]);
|
|
857
|
+
type ComputeFieldRules<TState$1 extends any, TRules$1 extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject<TRules$1> extends true ? {
|
|
858
|
+
readonly [x: string]: RegleRuleStatus<TState$1, any[], any>;
|
|
859
|
+
} : { readonly [TRuleKey in keyof Omit<TRules$1, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState$1, TRules$1[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules$1[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules$1[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : boolean> };
|
|
2053
860
|
/**
|
|
2054
861
|
* @public
|
|
2055
862
|
*/
|
|
2056
|
-
type RegleFieldStatus<TState extends any = any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = never> = Omit<RegleCommonStatus<TState>, '$value' | '$silentValue'> & {
|
|
863
|
+
type RegleFieldStatus<TState$1 extends any = any, TRules$1 extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = never> = Omit<RegleCommonStatus<TState$1>, '$value' | '$silentValue'> & {
|
|
2057
864
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
2058
|
-
$value: MaybeOutput<UnwrapNestedRefs<TState>>;
|
|
865
|
+
$value: MaybeOutput<UnwrapNestedRefs<TState$1>>;
|
|
2059
866
|
/** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
2060
|
-
$silentValue: MaybeOutput<UnwrapNestedRefs<TState>>;
|
|
867
|
+
$silentValue: MaybeOutput<UnwrapNestedRefs<TState$1>>;
|
|
2061
868
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2062
869
|
*
|
|
2063
870
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -2067,11 +874,11 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2067
874
|
/**
|
|
2068
875
|
* Collect all metadata of validators, Only contains metadata from properties where $dirty equals true.
|
|
2069
876
|
*/
|
|
2070
|
-
readonly $issues: RegleFieldIssue<TRules>[];
|
|
877
|
+
readonly $issues: RegleFieldIssue<TRules$1>[];
|
|
2071
878
|
/**
|
|
2072
879
|
* Collect all metadata of validators, including the error message.
|
|
2073
880
|
*/
|
|
2074
|
-
readonly $silentIssues: RegleFieldIssue<TRules>[];
|
|
881
|
+
readonly $silentIssues: RegleFieldIssue<TRules$1>[];
|
|
2075
882
|
/** Stores external errors of the current field */
|
|
2076
883
|
readonly $externalErrors: string[];
|
|
2077
884
|
/** Stores active tooltips messages of the current field */
|
|
@@ -2079,11 +886,11 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2079
886
|
/** Represents the inactive status. Is true when this state have empty rules */
|
|
2080
887
|
readonly $inactive: boolean;
|
|
2081
888
|
/** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
2082
|
-
$extractDirtyFields: (filterNullishValues?: boolean) => MaybeOutput<TState>;
|
|
889
|
+
$extractDirtyFields: (filterNullishValues?: boolean) => MaybeOutput<TState$1>;
|
|
2083
890
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2084
|
-
$validate: (forceValues?: IsUnknown<TState> extends true ? any : TState) => Promise<RegleFieldResult<TState, TRules>>;
|
|
891
|
+
$validate: (forceValues?: IsUnknown<TState$1> extends true ? any : TState$1) => Promise<RegleFieldResult<TState$1, TRules$1>>;
|
|
2085
892
|
/** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
|
|
2086
|
-
readonly $rules: ComputeFieldRules<TState, TRules>;
|
|
893
|
+
readonly $rules: ComputeFieldRules<TState$1, TRules$1>;
|
|
2087
894
|
} & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
|
|
2088
895
|
/**
|
|
2089
896
|
* @internal
|
|
@@ -2106,7 +913,7 @@ interface $InternalRegleFieldStatus extends $InternalRegleCommonStatus {
|
|
|
2106
913
|
/**
|
|
2107
914
|
* @public
|
|
2108
915
|
*/
|
|
2109
|
-
interface RegleCommonStatus<TValue = any> extends StandardSchemaV1<TValue> {
|
|
916
|
+
interface RegleCommonStatus<TValue$1 = any> extends StandardSchemaV1<TValue$1> {
|
|
2110
917
|
/** Indicates whether the field is invalid. It becomes true if any associated rules return false. */
|
|
2111
918
|
readonly $invalid: boolean;
|
|
2112
919
|
/**
|
|
@@ -2142,20 +949,20 @@ interface RegleCommonStatus<TValue = any> extends StandardSchemaV1<TValue> {
|
|
|
2142
949
|
/** Id used to track collections items */
|
|
2143
950
|
$id?: string;
|
|
2144
951
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
2145
|
-
$value: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
|
|
952
|
+
$value: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue$1>>;
|
|
2146
953
|
/**
|
|
2147
954
|
* This value reflect the current initial value of the field.
|
|
2148
955
|
* The initial value is different than the original value as the initial value can be mutated when using `$reset`.
|
|
2149
956
|
*/
|
|
2150
|
-
readonly $initialValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
|
|
957
|
+
readonly $initialValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue$1>>;
|
|
2151
958
|
/**
|
|
2152
959
|
* This value reflect the original value of the field at original call. This can't be mutated
|
|
2153
960
|
*/
|
|
2154
|
-
readonly $originalValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
|
|
961
|
+
readonly $originalValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue$1>>;
|
|
2155
962
|
/**
|
|
2156
963
|
* `$value` variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction.
|
|
2157
964
|
* */
|
|
2158
|
-
$silentValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
|
|
965
|
+
$silentValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue$1>>;
|
|
2159
966
|
/** Marks the field and all nested properties as $dirty. */
|
|
2160
967
|
$touch(): void;
|
|
2161
968
|
/**
|
|
@@ -2164,7 +971,7 @@ interface RegleCommonStatus<TValue = any> extends StandardSchemaV1<TValue> {
|
|
|
2164
971
|
* Rerun rules if `$lazy` is false
|
|
2165
972
|
*/
|
|
2166
973
|
$reset(): void;
|
|
2167
|
-
$reset(options?: ResetOptions<TValue>): void;
|
|
974
|
+
$reset(options?: ResetOptions<TValue$1>): void;
|
|
2168
975
|
/** Clears the $externalErrors state back to an empty object. */
|
|
2169
976
|
$clearExternalErrors(): void;
|
|
2170
977
|
}
|
|
@@ -2173,11 +980,12 @@ interface $InternalRegleCommonStatus extends Omit<RegleCommonStatus, '$touch' |
|
|
|
2173
980
|
$unwatch(): void;
|
|
2174
981
|
$watch(): void;
|
|
2175
982
|
$reset(options?: ResetOptions<any>, fromParent?: boolean): void;
|
|
983
|
+
$abort(): void;
|
|
2176
984
|
}
|
|
2177
985
|
/**
|
|
2178
986
|
* @public
|
|
2179
987
|
*/
|
|
2180
|
-
type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata extends RegleRuleMetadataDefinition = boolean> = {
|
|
988
|
+
type RegleRuleStatus<TValue$1 = any, TParams$1 extends any[] = any[], TMetadata$1 extends RegleRuleMetadataDefinition = boolean> = {
|
|
2181
989
|
/** The name of the rule type. */
|
|
2182
990
|
readonly $type: string;
|
|
2183
991
|
/** Returns the computed error message or messages for the current rule. */
|
|
@@ -2193,17 +1001,17 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
2193
1001
|
/** Returns the current path of the rule (used internally for tracking) */
|
|
2194
1002
|
readonly $path: string;
|
|
2195
1003
|
/** Contains the metadata returned by the validator function. */
|
|
2196
|
-
readonly $metadata: TMetadata extends boolean ? TMetadata : Omit<TMetadata, '$valid'>;
|
|
1004
|
+
readonly $metadata: TMetadata$1 extends boolean ? TMetadata$1 : Omit<TMetadata$1, '$valid'>;
|
|
2197
1005
|
/** Run the rule validator and compute its properties like $message and $active */
|
|
2198
1006
|
$parse(): Promise<boolean>;
|
|
2199
1007
|
/** Reset the $valid, $metadata and $pending states */
|
|
2200
1008
|
$reset(): void;
|
|
2201
1009
|
/** Returns the original rule validator function. */
|
|
2202
|
-
$validator: ((value: IsUnknown<TValue> extends true ? any : MaybeInput<TValue>, ...args: any[]) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>) & ((value: IsUnknown<TValue> extends true ? any : TValue, ...args: [TParams] extends [never[]] ? [] : [unknown[]] extends [TParams] ? any[] : TParams) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>);
|
|
2203
|
-
} & ([TParams] extends [never[]] ? {} : [unknown[]] extends [TParams] ? {
|
|
1010
|
+
$validator: ((value: IsUnknown<TValue$1> extends true ? any : MaybeInput<TValue$1>, ...args: any[]) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>) & ((value: IsUnknown<TValue$1> extends true ? any : TValue$1, ...args: [TParams$1] extends [never[]] ? [] : [unknown[]] extends [TParams$1] ? any[] : TParams$1) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>);
|
|
1011
|
+
} & ([TParams$1] extends [never[]] ? {} : [unknown[]] extends [TParams$1] ? {
|
|
2204
1012
|
readonly $params?: any[];
|
|
2205
1013
|
} : {
|
|
2206
|
-
readonly $params: [...TParams];
|
|
1014
|
+
readonly $params: [...TParams$1];
|
|
2207
1015
|
});
|
|
2208
1016
|
/**
|
|
2209
1017
|
* @internal
|
|
@@ -2237,31 +1045,31 @@ interface $InternalRegleRuleStatus {
|
|
|
2237
1045
|
/**
|
|
2238
1046
|
* @public
|
|
2239
1047
|
*/
|
|
2240
|
-
type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement<TState>> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$value'> & {
|
|
1048
|
+
type RegleCollectionStatus<TState$1 extends any[] = any[], TRules$1 extends ReglePartialRuleTree<ArrayElement<TState$1>> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState$1>, '$value'> & {
|
|
2241
1049
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
2242
|
-
$value: MaybeOutput<TState>;
|
|
1050
|
+
$value: MaybeOutput<TState$1>;
|
|
2243
1051
|
/** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
2244
|
-
$silentValue: MaybeOutput<TState>;
|
|
1052
|
+
$silentValue: MaybeOutput<TState$1>;
|
|
2245
1053
|
/** Collection of status of every item in your collection. Each item will be a field you can access, or map on it to display your elements. */
|
|
2246
|
-
readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number, TShortcuts>>;
|
|
1054
|
+
readonly $each: Array<InferRegleStatusType<NonNullable<TRules$1>, NonNullable<TState$1>, number, TShortcuts>>;
|
|
2247
1055
|
/** Represents the status of the collection itself. You can have validation rules on the array like minLength, this field represents the isolated status of the collection. */
|
|
2248
|
-
readonly $self: RegleFieldStatus<TState, TFieldRule, TShortcuts>;
|
|
1056
|
+
readonly $self: RegleFieldStatus<TState$1, TFieldRule, TShortcuts>;
|
|
2249
1057
|
/**
|
|
2250
1058
|
* Collection of all the issues, collected for all children properties and nested forms.
|
|
2251
1059
|
*
|
|
2252
1060
|
* Only contains issues from properties where $dirty equals true.
|
|
2253
1061
|
*/
|
|
2254
|
-
readonly $issues: RegleCollectionErrors<TState, true>;
|
|
1062
|
+
readonly $issues: RegleCollectionErrors<TState$1, true>;
|
|
2255
1063
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2256
1064
|
*
|
|
2257
1065
|
* Only contains errors from properties where $dirty equals true. */
|
|
2258
|
-
readonly $errors: RegleCollectionErrors<TState>;
|
|
1066
|
+
readonly $errors: RegleCollectionErrors<TState$1>;
|
|
2259
1067
|
/** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
2260
|
-
readonly $silentErrors: RegleCollectionErrors<TState>;
|
|
1068
|
+
readonly $silentErrors: RegleCollectionErrors<TState$1>;
|
|
2261
1069
|
/** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
2262
|
-
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
|
|
1070
|
+
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState$1>;
|
|
2263
1071
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2264
|
-
$validate: (value?: JoinDiscriminatedUnions<TState>) => Promise<RegleCollectionResult<TState, JoinDiscriminatedUnions<TRules>>>;
|
|
1072
|
+
$validate: (value?: JoinDiscriminatedUnions<TState$1>) => Promise<RegleCollectionResult<TState$1, JoinDiscriminatedUnions<TRules$1>>>;
|
|
2265
1073
|
} & ([TShortcuts['collections']] extends [never] ? {} : { [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]> });
|
|
2266
1074
|
/**
|
|
2267
1075
|
* @internal
|
|
@@ -2279,19 +1087,19 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2279
1087
|
}
|
|
2280
1088
|
//#endregion
|
|
2281
1089
|
//#region src/types/rules/rule.errors.types.d.ts
|
|
2282
|
-
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>, TIssue extends boolean = false> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, TIssue> };
|
|
2283
|
-
type RegleIssuesTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, true> };
|
|
2284
|
-
type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
|
|
2285
|
-
type RegleExternalSchemaErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true, true> };
|
|
1090
|
+
type RegleErrorTree<TState$1 = MaybeRef<Record<string, any> | any[]>, TIssue extends boolean = false> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], false, TIssue> };
|
|
1091
|
+
type RegleIssuesTree<TState$1 = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], false, true> };
|
|
1092
|
+
type RegleExternalErrorTree<TState$1 = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], true> };
|
|
1093
|
+
type RegleExternalSchemaErrorTree<TState$1 = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState$1>>[K], true, true> };
|
|
2286
1094
|
type ErrorMessageOrIssue<TIssue extends boolean> = TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2287
|
-
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = HasNamedKeys<TState> extends true ? IsAny<TState> extends true ? any : NonNullable<TState> extends Array<infer U> ? U extends Record<string, any> ? TExternal extends false ? ExtendOnlyRealRecord<U> extends true ? RegleCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : RegleExternalCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : NonNullable<TState> extends Date | File ? ErrorMessageOrIssue<TIssue> : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState, TIssue> : RegleExternalErrorTree<TState> : ErrorMessageOrIssue<TIssue> : any;
|
|
2288
|
-
type RegleCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
1095
|
+
type RegleValidationErrors<TState$1 extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = HasNamedKeys<TState$1> extends true ? IsAny<TState$1> extends true ? any : NonNullable<TState$1> extends Array<infer U> ? U extends Record<string, any> ? TExternal extends false ? ExtendOnlyRealRecord<U> extends true ? RegleCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : RegleExternalCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : NonNullable<TState$1> extends Date | File ? ErrorMessageOrIssue<TIssue> : NonNullable<TState$1> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState$1, TIssue> : RegleExternalErrorTree<TState$1> : ErrorMessageOrIssue<TIssue> : any;
|
|
1096
|
+
type RegleCollectionErrors<TState$1 extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2289
1097
|
readonly $self: TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2290
|
-
readonly $each: RegleValidationErrors<TState, false, TIssue>[];
|
|
1098
|
+
readonly $each: RegleValidationErrors<TState$1, false, TIssue>[];
|
|
2291
1099
|
};
|
|
2292
|
-
type RegleExternalCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
1100
|
+
type RegleExternalCollectionErrors<TState$1 extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2293
1101
|
readonly $self?: TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2294
|
-
readonly $each?: RegleValidationErrors<TState, true, TIssue>[];
|
|
1102
|
+
readonly $each?: RegleValidationErrors<TState$1, true, TIssue>[];
|
|
2295
1103
|
};
|
|
2296
1104
|
/** @internal */
|
|
2297
1105
|
type $InternalRegleCollectionErrors = {
|
|
@@ -2396,14 +1204,14 @@ type SuperCompatibleRegleCollectionIssues = $InternalRegleCollectionIssues;
|
|
|
2396
1204
|
*
|
|
2397
1205
|
* Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
|
|
2398
1206
|
*/
|
|
2399
|
-
declare function createRule<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(definition: RegleRuleInit<TValue, TParams, TReturn, TMetadata, TAsync>): InferRegleRule<TValue, TParams, TAsync, TMetadata>;
|
|
1207
|
+
declare function createRule<TValue$1 extends any, TParams$1 extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata$1 extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync$1 extends boolean = (TReturn extends Promise<any> ? true : false)>(definition: RegleRuleInit<TValue$1, TParams$1, TReturn, TMetadata$1, TAsync$1>): InferRegleRule<TValue$1, TParams$1, TAsync$1, TMetadata$1>;
|
|
2400
1208
|
//#endregion
|
|
2401
1209
|
//#region src/core/createRule/unwrapRuleParameters.d.ts
|
|
2402
1210
|
/**
|
|
2403
1211
|
* Returns a clean list of parameters
|
|
2404
1212
|
* Removing Ref and executing function to return the unwrapped value
|
|
2405
1213
|
*/
|
|
2406
|
-
declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
|
|
1214
|
+
declare function unwrapRuleParameters<TParams$1 extends any[]>(params: MaybeRefOrGetter[]): TParams$1;
|
|
2407
1215
|
//#endregion
|
|
2408
1216
|
//#region src/core/defineRegleConfig.d.ts
|
|
2409
1217
|
/**
|
|
@@ -2453,13 +1261,13 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDecl
|
|
|
2453
1261
|
};
|
|
2454
1262
|
//#endregion
|
|
2455
1263
|
//#region src/core/mergeRegles.d.ts
|
|
2456
|
-
type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue = { [K in keyof TRegles]: TRegles[K]['$value'] }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
|
|
1264
|
+
type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue$1 = { [K in keyof TRegles]: TRegles[K]['$value'] }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
|
|
2457
1265
|
/** Map of merged Regle instances and their properties */
|
|
2458
1266
|
readonly $instances: { [K in keyof TRegles]: TRegles[K] };
|
|
2459
1267
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
2460
|
-
$value: TValue;
|
|
1268
|
+
$value: TValue$1;
|
|
2461
1269
|
/** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
2462
|
-
$silentValue: TValue;
|
|
1270
|
+
$silentValue: TValue$1;
|
|
2463
1271
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2464
1272
|
*
|
|
2465
1273
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -2469,15 +1277,15 @@ type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TVal
|
|
|
2469
1277
|
readonly $issues: { [K in keyof TRegles]: TRegles[K]['$issues'] };
|
|
2470
1278
|
readonly $silentIssues: { [K in keyof TRegles]: TRegles[K]['$silentIssues'] };
|
|
2471
1279
|
/** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
|
|
2472
|
-
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TValue>;
|
|
1280
|
+
$extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TValue$1>;
|
|
2473
1281
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2474
1282
|
$validate: (forceValues?: TRegles['$value']) => Promise<MergedReglesResult<TRegles>>;
|
|
2475
1283
|
};
|
|
2476
|
-
type MergedScopedRegles<TValue extends Record<string, unknown>[] = Record<string, unknown>[]> = Omit<MergedRegles<Record<string, SuperCompatibleRegleRoot>, TValue>, '$instances' | '$errors' | '$silentErrors' | '$value' | '$silentValue' | '$validate'> & {
|
|
1284
|
+
type MergedScopedRegles<TValue$1 extends Record<string, unknown>[] = Record<string, unknown>[]> = Omit<MergedRegles<Record<string, SuperCompatibleRegleRoot>, TValue$1>, '$instances' | '$errors' | '$silentErrors' | '$value' | '$silentValue' | '$validate'> & {
|
|
2477
1285
|
/** Array of scoped Regles instances */
|
|
2478
1286
|
readonly $instances: SuperCompatibleRegleRoot[];
|
|
2479
1287
|
/** Collection of all registered Regles instances values */
|
|
2480
|
-
readonly $value: TValue;
|
|
1288
|
+
readonly $value: TValue$1;
|
|
2481
1289
|
/** Collection of all registered Regles instances errors */
|
|
2482
1290
|
readonly $errors: RegleValidationErrors<Record<string, unknown>>[];
|
|
2483
1291
|
/** Collection of all registered Regles instances silent errors */
|
|
@@ -2487,9 +1295,9 @@ type MergedScopedRegles<TValue extends Record<string, unknown>[] = Record<string
|
|
|
2487
1295
|
/** Collection of all registered Regles instances silent issues */
|
|
2488
1296
|
readonly $silentIssues: RegleValidationErrors<Record<string, unknown>, false, true>[];
|
|
2489
1297
|
/** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
|
|
2490
|
-
$validate: (forceValues?: TValue) => Promise<{
|
|
1298
|
+
$validate: (forceValues?: TValue$1) => Promise<{
|
|
2491
1299
|
valid: boolean;
|
|
2492
|
-
data: TValue;
|
|
1300
|
+
data: TValue$1;
|
|
2493
1301
|
errors: RegleValidationErrors<Record<string, unknown>>[];
|
|
2494
1302
|
issues: RegleValidationErrors<Record<string, unknown>>[];
|
|
2495
1303
|
}>;
|
|
@@ -2512,10 +1320,10 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
|
|
|
2512
1320
|
declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
|
|
2513
1321
|
//#endregion
|
|
2514
1322
|
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2515
|
-
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2516
|
-
r$: MergedRegles<{ [K in keyof TValue]: RegleRoot<TValue[K]> & SuperCompatibleRegleRoot }>;
|
|
2517
|
-
} : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2518
|
-
r$: MergedScopedRegles<TValue>;
|
|
1323
|
+
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue$1 extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
1324
|
+
r$: MergedRegles<{ [K in keyof TValue$1]: RegleRoot<TValue$1[K]> & SuperCompatibleRegleRoot }>;
|
|
1325
|
+
} : <TValue$1 extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
1326
|
+
r$: MergedScopedRegles<TValue$1>;
|
|
2519
1327
|
};
|
|
2520
1328
|
//#endregion
|
|
2521
1329
|
//#region src/core/createScopedUseRegle/useScopedRegle.d.ts
|
|
@@ -2552,8 +1360,8 @@ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any>
|
|
|
2552
1360
|
useScopedRegle: TReturnedRegle;
|
|
2553
1361
|
useCollectScope: useCollectScopeFn<TAsRecord>;
|
|
2554
1362
|
};
|
|
2555
|
-
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue0.MaybeRefOrGetter<string>) => {
|
|
2556
|
-
r$: MergedScopedRegles<TValue>;
|
|
1363
|
+
declare const useCollectScope: <TValue$1 extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue0.MaybeRefOrGetter<string>) => {
|
|
1364
|
+
r$: MergedScopedRegles<TValue$1>;
|
|
2557
1365
|
}, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
|
|
2558
1366
|
dispose: () => void;
|
|
2559
1367
|
register: () => void;
|
|
@@ -2597,9 +1405,9 @@ declare function narrowVariant<TRoot extends {
|
|
|
2597
1405
|
$fields: {
|
|
2598
1406
|
[x: string]: unknown;
|
|
2599
1407
|
};
|
|
2600
|
-
}, const TKey extends keyof TRoot, const TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
1408
|
+
}, const TKey$1 extends keyof TRoot, const TValue$1 extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey$1], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
2601
1409
|
$value: infer V;
|
|
2602
|
-
} ? V : unknown)>(root: TRoot, discriminantKey: TKey, discriminantValue: TValue): root is NarrowVariant<TRoot, TKey, TValue>;
|
|
1410
|
+
} ? V : unknown)>(root: TRoot, discriminantKey: TKey$1, discriminantValue: TValue$1): root is NarrowVariant<TRoot, TKey$1, TValue$1>;
|
|
2603
1411
|
/**
|
|
2604
1412
|
* Narrow a nested variant root to a reactive reference
|
|
2605
1413
|
*
|
|
@@ -2609,17 +1417,17 @@ declare function narrowVariant<TRoot extends {
|
|
|
2609
1417
|
* </script>
|
|
2610
1418
|
* ```
|
|
2611
1419
|
*/
|
|
2612
|
-
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey extends keyof TRoot['$fields'], const TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
1420
|
+
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey$1 extends keyof TRoot['$fields'], const TValue$1 extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey$1], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
2613
1421
|
$value: infer V;
|
|
2614
|
-
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue, options: {
|
|
1422
|
+
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey$1, discriminantValue: TValue$1, options: {
|
|
2615
1423
|
/**
|
|
2616
1424
|
* Assert that the variant is always defined, use with caution
|
|
2617
1425
|
*/
|
|
2618
1426
|
unsafeAssertion: true;
|
|
2619
|
-
}): Ref<NarrowVariant<TRoot, TKey, TValue>>;
|
|
2620
|
-
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey extends keyof TRoot['$fields'], const TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
1427
|
+
}): Ref<NarrowVariant<TRoot, TKey$1, TValue$1>>;
|
|
1428
|
+
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey$1 extends keyof TRoot['$fields'], const TValue$1 extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey$1], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
2621
1429
|
$value: infer V;
|
|
2622
|
-
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<NarrowVariant<TRoot, TKey, TValue> | undefined>;
|
|
1430
|
+
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey$1, discriminantValue: TValue$1): Ref<NarrowVariant<TRoot, TKey$1, TValue$1> | undefined>;
|
|
2623
1431
|
//#endregion
|
|
2624
1432
|
//#region src/core/refineRules.d.ts
|
|
2625
1433
|
/**
|
|
@@ -2631,7 +1439,7 @@ declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKe
|
|
|
2631
1439
|
* const rules = {...} satisfies RegleUnknownRulesTree
|
|
2632
1440
|
* ```
|
|
2633
1441
|
*/
|
|
2634
|
-
declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules): TRules;
|
|
1442
|
+
declare function defineRules<TRules$1 extends RegleUnknownRulesTree>(rules: TRules$1): TRules$1;
|
|
2635
1443
|
/**
|
|
2636
1444
|
* Refine a raw rules object to set rules that depends on the state values.
|
|
2637
1445
|
*
|
|
@@ -2647,6 +1455,6 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
|
|
|
2647
1455
|
* })
|
|
2648
1456
|
* ```
|
|
2649
1457
|
*/
|
|
2650
|
-
declare function refineRules<TRules extends RegleUnknownRulesTree, TRefinement extends ReglePartialRuleTree<InferInput<TRules>> & RegleUnknownRulesTree>(rules: TRules, refinement: (state: Ref<InferInput<TRules>>) => TRefinement): (state: Ref<InferInput<TRules>>) => Merge<TRules, TRefinement>;
|
|
1458
|
+
declare function refineRules<TRules$1 extends RegleUnknownRulesTree, TRefinement extends ReglePartialRuleTree<InferInput<TRules$1>> & RegleUnknownRulesTree>(rules: TRules$1, refinement: (state: Ref<InferInput<TRules$1>>) => TRefinement): (state: Ref<InferInput<TRules$1>>) => Merge<TRules$1, TRefinement>;
|
|
2651
1459
|
//#endregion
|
|
2652
1460
|
export { type $InternalRegleStatus, type AllRulesDeclarations, type ArrayElement, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type DeepMaybeRef, type DeepReactiveState, type DefaultValidatorsTree, type FormRuleDeclaration, type HasNamedKeys, type HaveAnyRequiredProps, type InferInput, type InferRegleRoot, type InferRegleRule, type InferRegleRules, type InferRegleShortcuts, type InferRegleStatusType, type InferSafeOutput, type InlineRuleDeclaration, InternalRuleType, type JoinDiscriminatedUnions, type LocalRegleBehaviourOptions, type Maybe, type MaybeInput, type MaybeOutput, type MaybeReadonly, type MaybeVariantStatus, type MergedRegles, type MergedScopedRegles, type NarrowVariant, type NoInferLegacy, type NonEmptyTuple, type PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleCustomFieldStatus, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleExternalSchemaErrorTree, type RegleFieldIssue, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, type RegleIssuesTree, type ReglePartialRuleTree, type RegleResult, type RegleRoot, type RegleRuleCore, type RegleRuleDecl, type RegleRuleDefinition, type RegleRuleDefinitionProcessor, type RegleRuleDefinitionWithMetadataProcessor, type RegleRuleInit, type RegleRuleMetadataConsumer, type RegleRuleMetadataDefinition, type RegleRuleMetadataExtended, type RegleRuleRaw, type RegleRuleStatus, type RegleRuleTypeReturn, type RegleRuleWithParamsDefinition, type RegleShortcutDefinition, type RegleSingleField, type RegleStatus, type RegleUniversalParams, type RegleUnknownRulesTree, type RegleValidationErrors, type RegleValidationGroupEntry, type RegleValidationGroupOutput, type RegleRuleTree as RegleValidationTree, type ResolvedRegleBehaviourOptions, type ScopedInstancesRecord, type ScopedInstancesRecordLike, type SuperCompatibleRegle, type SuperCompatibleRegleCollectionErrors, type SuperCompatibleRegleCollectionStatus, type SuperCompatibleRegleFieldStatus, type SuperCompatibleRegleResult, type SuperCompatibleRegleRoot, type SuperCompatibleRegleRuleStatus, type SuperCompatibleRegleStatus, type Unwrap, type UnwrapRegleUniversalParams, type UnwrapRuleWithParams, type UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, type inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, type useCollectScopeFn, useRegle, type useRegleFn, useRootStorage, useRules, type useRulesFn, useScopedRegle, variantToRef };
|