@regle/core 1.2.3 → 1.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,8 @@
1
- import * as vue from 'vue';
2
- import { Ref, MaybeRef, UnwrapRef, UnwrapNestedRefs, Raw, MaybeRefOrGetter } from 'vue';
1
+ import * as vue1 from "vue";
2
+ import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
3
3
 
4
- type Prettify<T> = T extends infer R ? {
5
- [K in keyof R]: R[K];
6
- } & {} : never;
4
+ //#region src/types/utils/misc.types.d.ts
5
+ type Prettify<T> = T extends infer R ? { [K in keyof R]: R[K] } & {} : never;
7
6
  type Maybe<T = any> = T | null | undefined;
8
7
  type MaybeInput<T = any> = T | null | undefined;
9
8
  type MaybeOutput<T = any> = T | undefined;
@@ -11,45 +10,51 @@ type MaybeReadonly<T> = T | Readonly<T>;
11
10
  type PromiseReturn<T> = T extends Promise<infer U> ? U : T;
12
11
  type MaybeGetter<T, V = any, TAdd extends Record<string, any> = {}> = T | ((value: Ref<V>, index: number) => T & TAdd);
13
12
  type Unwrap<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : UnwrapNestedRefs<T>;
14
- type UnwrapSimple<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : T extends (...args: any[]) => infer U ? U : T;
13
+ type UnwrapSimple<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : T extends ((...args: any[]) => infer U) ? U : T;
15
14
  type ExtractFromGetter<T extends MaybeGetter<any, any, any>> = T extends ((value: Ref<any>, index: number) => infer U extends Record<string, any>) ? U : T;
16
15
  type ExtendOnlyRealRecord<T extends unknown> = NonNullable<T> extends File | Date ? false : NonNullable<T> extends Record<string, any> ? true : false;
17
- type OmitByType<T extends Record<string, any>, U> = {
18
- [K in keyof T as T[K] extends U ? never : K]: T[K];
19
- };
20
- type DeepMaybeRef<T extends Record<string, any>> = {
21
- [K in keyof T]: MaybeRef<T[K]>;
22
- };
23
- type ExcludeByType<T, U> = {
24
- [K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K];
25
- };
16
+ type OmitByType<T extends Record<string, any>, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] };
17
+ type DeepMaybeRef<T extends Record<string, any>> = { [K in keyof T]: MaybeRef<T[K]> };
18
+ type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K] extends U ? never : T[K] };
26
19
  type PrimitiveTypes = string | number | boolean | bigint | Date | File;
27
20
  type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? false : NonNullable<T> extends Record<string, any> ? true : false;
28
21
  type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
29
22
 
23
+ //#endregion
24
+ //#region src/types/utils/Array.types.d.ts
30
25
  type ArrayElement<T> = T extends Array<infer U> ? U : never;
31
26
 
27
+ //#endregion
28
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/primitive.d.ts
32
29
  /**
33
30
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
34
31
 
35
32
  @category Type
36
33
  */
37
- type Primitive =
38
- | null
39
- | undefined
40
- | string
41
- | number
42
- | boolean
43
- | symbol
44
- | bigint;
34
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
45
35
 
36
+ //#endregion
37
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/observable-like.d.ts
46
38
  declare global {
47
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
48
- interface SymbolConstructor {
49
- readonly observable: symbol;
50
- }
39
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
40
+ interface SymbolConstructor {
41
+ readonly observable: symbol;
42
+ }
51
43
  }
52
44
 
45
+ //#endregion
46
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/union-to-intersection.d.ts
47
+ /**
48
+ @remarks
49
+ The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
50
+ As well, some guidance on making an `Observable` to not include `closed` property.
51
+ @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
52
+ @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
53
+ @see https://github.com/benlesh/symbol-observable#making-an-object-observable
54
+
55
+ @category Observable
56
+ */
57
+
53
58
  /**
54
59
  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).
55
60
 
@@ -96,22 +101,23 @@ type Intersection = UnionToIntersection<Union>;
96
101
  @category Type
97
102
  */
98
103
  type UnionToIntersection$1<Union> = (
99
- // `extends unknown` is always going to be the case and is used to convert the
100
- // `Union` into a [distributive conditional
101
- // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
102
- Union extends unknown
103
- // The union type is used as the only argument to a function since the union
104
- // of function arguments is an intersection.
105
- ? (distributedUnion: Union) => void
106
- // This won't happen.
107
- : never
108
- // Infer the `Intersection` type since TypeScript represents the positional
109
- // arguments of unions of functions as an intersection of the union.
104
+ // `extends unknown` is always going to be the case and is used to convert the
105
+ // `Union` into a [distributive conditional
106
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
107
+ Union extends unknown
108
+ // The union type is used as the only argument to a function since the union
109
+ // of function arguments is an intersection.
110
+ ? (distributedUnion: Union) => void
111
+ // This won't happen.
112
+ : never
113
+ // Infer the `Intersection` type since TypeScript represents the positional
114
+ // arguments of unions of functions as an intersection of the union.
110
115
  ) extends ((mergedIntersection: infer Intersection) => void)
111
- // The `& Union` is to allow indexing by the resulting type
112
- ? Intersection & Union
113
- : never;
116
+ // The `& Union` is to allow indexing by the resulting type
117
+ ? Intersection & Union : never;
114
118
 
119
+ //#endregion
120
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/empty-object.d.ts
115
121
  declare const emptyObjectSymbol: unique symbol;
116
122
 
117
123
  /**
@@ -140,7 +146,9 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
140
146
 
141
147
  @category Object
142
148
  */
143
- type EmptyObject = {[emptyObjectSymbol]?: never};
149
+ type EmptyObject = {
150
+ [emptyObjectSymbol]?: never;
151
+ };
144
152
 
145
153
  /**
146
154
  Returns a `boolean` for whether the type is strictly equal to an empty plain object, the `{}` value.
@@ -159,6 +167,8 @@ type Fail = IsEmptyObject<null>; //=> false
159
167
  */
160
168
  type IsEmptyObject<T> = T extends EmptyObject ? true : false;
161
169
 
170
+ //#endregion
171
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/optional-keys-of.d.ts
162
172
  /**
163
173
  Extract all optional keys from the given type.
164
174
 
@@ -192,13 +202,13 @@ const update2: UpdateOperation<User> = {
192
202
 
193
203
  @category Utilities
194
204
  */
195
- type OptionalKeysOf<BaseType extends object> =
196
- BaseType extends unknown // For distributing `BaseType`
197
- ? (keyof {
198
- [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
199
- }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
200
- : never; // Should never happen
205
+ type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
206
+ ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
207
+ : never;
201
208
 
209
+ //#endregion
210
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/required-keys-of.d.ts
211
+ // Should never happen
202
212
  /**
203
213
  Extract all required keys from the given type.
204
214
 
@@ -223,10 +233,12 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
223
233
 
224
234
  @category Utilities
225
235
  */
226
- type RequiredKeysOf<BaseType extends object> =
227
- BaseType extends unknown // For distributing `BaseType`
228
- ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
229
- : never; // Should never happen
236
+ type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
237
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
238
+
239
+ //#endregion
240
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/is-never.d.ts
241
+ // Should never happen
230
242
 
231
243
  /**
232
244
  Returns a boolean for whether the given type is `never`.
@@ -271,6 +283,8 @@ endIfEqual('abc', '123');
271
283
  */
272
284
  type IsNever$1<T> = [T] extends [never] ? true : false;
273
285
 
286
+ //#endregion
287
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/if-never.d.ts
274
288
  /**
275
289
  An if-else-like type that resolves depending on whether the given type is `never`.
276
290
 
@@ -290,10 +304,10 @@ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
290
304
  @category Type Guard
291
305
  @category Utilities
292
306
  */
293
- type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
294
- IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever
295
- );
307
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
296
308
 
309
+ //#endregion
310
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/is-any.d.ts
297
311
  // Can eventually be replaced with the built-in once this library supports
298
312
  // TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
299
313
  type NoInfer<T> = T extends infer U ? U : never;
@@ -328,11 +342,18 @@ const anyA = get(anyObject, 'a');
328
342
  */
329
343
  type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
330
344
 
345
+ //#endregion
346
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/internal/keys.d.ts
331
347
  /**
332
348
  Disallows any of the given keys.
333
349
  */
334
350
  type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
335
351
 
352
+ //#endregion
353
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/simplify.d.ts
354
+ /**
355
+ Utility type to retrieve only literal keys from type.
356
+ */
336
357
  /**
337
358
  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.
338
359
 
@@ -390,8 +411,10 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
390
411
  @see SimplifyDeep
391
412
  @category Object
392
413
  */
393
- type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
414
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
394
415
 
416
+ //#endregion
417
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/omit-index-signature.d.ts
395
418
  /**
396
419
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
397
420
 
@@ -482,12 +505,10 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
482
505
  @see PickIndexSignature
483
506
  @category Object
484
507
  */
485
- type OmitIndexSignature<ObjectType> = {
486
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
487
- ? never
488
- : KeyType]: ObjectType[KeyType];
489
- };
508
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
490
509
 
510
+ //#endregion
511
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/pick-index-signature.d.ts
491
512
  /**
492
513
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
493
514
 
@@ -533,16 +554,12 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
533
554
  @see OmitIndexSignature
534
555
  @category Object
535
556
  */
536
- type PickIndexSignature<ObjectType> = {
537
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
538
- ? KeyType
539
- : never]: ObjectType[KeyType];
540
- };
557
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
541
558
 
559
+ //#endregion
560
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/merge.d.ts
542
561
  // Merges two objects without worrying about index signatures.
543
- type SimpleMerge<Destination, Source> = {
544
- [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
545
- } & Source;
562
+ type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
546
563
 
547
564
  /**
548
565
  Merge two types into a new type. Keys of the second type overrides keys of the first type.
@@ -578,12 +595,10 @@ export type FooBar = Merge<Foo, Bar>;
578
595
 
579
596
  @category Object
580
597
  */
581
- type Merge<Destination, Source> =
582
- Simplify<
583
- SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
584
- & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
585
- >;
598
+ type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
586
599
 
600
+ //#endregion
601
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/if-any.d.ts
587
602
  /**
588
603
  An if-else-like type that resolves depending on whether the given type is `any`.
589
604
 
@@ -603,15 +618,19 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
603
618
  @category Type Guard
604
619
  @category Utilities
605
620
  */
606
- type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
607
- IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny
608
- );
621
+ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
609
622
 
623
+ //#endregion
624
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/internal/type.d.ts
610
625
  /**
611
626
  Matches any primitive, `void`, `Date`, or `RegExp` value.
612
627
  */
613
628
  type BuiltIns = Primitive | void | Date | RegExp;
614
629
 
630
+ /**
631
+ Matches non-recursive types.
632
+ */
633
+
615
634
  /**
616
635
  Test if the given function has multiple call signatures.
617
636
 
@@ -620,14 +639,14 @@ Needed to handle the case of a single call signature with properties.
620
639
  Multiple call signatures cannot currently be supported due to a TypeScript limitation.
621
640
  @see https://github.com/microsoft/TypeScript/issues/29732
622
641
  */
623
- type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
624
- T extends {(...arguments_: infer A): unknown; (...arguments_: infer B): unknown}
625
- ? B extends A
626
- ? A extends B
627
- ? false
628
- : true
629
- : true
630
- : false;
642
+ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
643
+ (...arguments_: infer A): unknown;
644
+ (...arguments_: infer B): unknown;
645
+ } ? B extends A ? A extends B ? false : true : true : false;
646
+
647
+ /**
648
+ Returns a boolean for whether the given `boolean` is not `false`.
649
+ */
631
650
 
632
651
  /**
633
652
  Returns a boolean for whether the given type is a union type.
@@ -646,23 +665,17 @@ type IsUnion$1<T> = InternalIsUnion<T>;
646
665
  /**
647
666
  The actual implementation of `IsUnion`.
648
667
  */
649
- type InternalIsUnion<T, U = T> =
650
- (
651
- // @link https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html
652
- IsNever$1<T> extends true
653
- ? false
654
- : T extends any
655
- ? [U] extends [T]
656
- ? false
657
- : true
658
- : never
659
- ) extends infer Result
660
- // In some cases `Result` will return `false | true` which is `boolean`,
661
- // that means `T` has at least two types and it's a union type,
662
- // so we will return `true` instead of `boolean`.
663
- ? boolean extends Result ? true
664
- : Result
665
- : never; // Should never happen
668
+ type InternalIsUnion<T, U = T> = (
669
+ // @link https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html
670
+ IsNever$1<T> extends true ? false : T extends any ? [U] extends [T] ? false : true : never) extends infer Result
671
+ // In some cases `Result` will return `false | true` which is `boolean`,
672
+ // that means `T` has at least two types and it's a union type,
673
+ // so we will return `true` instead of `boolean`.
674
+ ? boolean extends Result ? true : Result : never;
675
+
676
+ //#endregion
677
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/internal/object.d.ts
678
+ // Should never happen
666
679
 
667
680
  /**
668
681
  Merges user specified options with default options.
@@ -716,24 +729,11 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
716
729
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
717
730
  ```
718
731
  */
719
- type ApplyDefaultOptions<
720
- Options extends object,
721
- Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
722
- SpecifiedOptions extends Options,
723
- > =
724
- IfAny<SpecifiedOptions, Defaults,
725
- IfNever<SpecifiedOptions, Defaults,
726
- Simplify<Merge<Defaults, {
727
- [Key in keyof SpecifiedOptions
728
- as Key extends OptionalKeysOf<Options>
729
- ? Extract<SpecifiedOptions[Key], undefined> extends never
730
- ? Key
731
- : never
732
- : Key
733
- ]: SpecifiedOptions[Key]
734
- }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
735
- >>;
732
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
733
+ >>;
736
734
 
735
+ //#endregion
736
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/require-exactly-one.d.ts
737
737
  /**
738
738
  Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
739
739
 
@@ -763,12 +763,10 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
763
763
 
764
764
  @category Object
765
765
  */
766
- type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
767
- {[Key in KeysType]: (
768
- Required<Pick<ObjectType, Key>> &
769
- Partial<Record<Exclude<KeysType, Key>, never>>
770
- )}[KeysType] & Omit<ObjectType, KeysType>;
766
+ type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
771
767
 
768
+ //#endregion
769
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/require-one-or-none.d.ts
772
770
  /**
773
771
  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.
774
772
 
@@ -799,52 +797,43 @@ const responder3: Responder = {
799
797
 
800
798
  @category Object
801
799
  */
802
- type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = (
803
- | RequireExactlyOne<ObjectType, KeysType>
804
- | RequireNone<KeysType>
805
- ) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
800
+ type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>;
806
801
 
802
+ //#endregion
803
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/partial-deep.d.ts
804
+ // Ignore unspecified keys.
807
805
  /**
808
806
  @see {@link PartialDeep}
809
807
  */
810
808
  type PartialDeepOptions = {
811
- /**
812
- Whether to affect the individual elements of arrays and tuples.
813
-
814
- @default false
815
- */
816
- readonly recurseIntoArrays?: boolean;
817
-
818
- /**
819
- Allows `undefined` values in non-tuple arrays.
820
-
821
- - When set to `true`, elements of non-tuple arrays can be `undefined`.
822
- - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
823
-
824
- @default true
825
-
826
- @example
827
- You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
828
-
829
- ```
830
- import type {PartialDeep} from 'type-fest';
831
-
832
- type Settings = {
833
- languages: string[];
834
- };
835
-
836
- declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
837
-
838
- partialSettings.languages = [undefined]; // Error
839
- partialSettings.languages = []; // Ok
840
- ```
841
- */
842
- readonly allowUndefinedInNonTupleArrays?: boolean;
809
+ /**
810
+ Whether to affect the individual elements of arrays and tuples.
811
+ @default false
812
+ */
813
+ readonly recurseIntoArrays?: boolean;
814
+
815
+ /**
816
+ Allows `undefined` values in non-tuple arrays.
817
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
818
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
819
+ @default true
820
+ @example
821
+ You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
822
+ ```
823
+ import type {PartialDeep} from 'type-fest';
824
+ type Settings = {
825
+ languages: string[];
826
+ };
827
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
828
+ partialSettings.languages = [undefined]; // Error
829
+ partialSettings.languages = []; // Ok
830
+ ```
831
+ */
832
+ readonly allowUndefinedInNonTupleArrays?: boolean;
843
833
  };
844
-
845
834
  type DefaultPartialDeepOptions = {
846
- recurseIntoArrays: false;
847
- allowUndefinedInNonTupleArrays: true;
835
+ recurseIntoArrays: false;
836
+ allowUndefinedInNonTupleArrays: true;
848
837
  };
849
838
 
850
839
  /**
@@ -896,32 +885,14 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
896
885
  @category Set
897
886
  @category Map
898
887
  */
899
- type PartialDeep<T, Options extends PartialDeepOptions = {}> =
900
- _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
901
-
902
- type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown))
903
- ? T
904
- : IsNever$1<keyof T> extends true // For functions with no properties
905
- ? T
906
- : T extends Map<infer KeyType, infer ValueType>
907
- ? PartialMapDeep<KeyType, ValueType, Options>
908
- : T extends Set<infer ItemType>
909
- ? PartialSetDeep<ItemType, Options>
910
- : T extends ReadonlyMap<infer KeyType, infer ValueType>
911
- ? PartialReadonlyMapDeep<KeyType, ValueType, Options>
912
- : T extends ReadonlySet<infer ItemType>
913
- ? PartialReadonlySetDeep<ItemType, Options>
914
- : T extends object
915
- ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
916
- ? Options['recurseIntoArrays'] extends true
917
- ? ItemType[] extends T // Test for arrays (non-tuples) specifically
918
- ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
919
- ? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
920
- : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
921
- : PartialObjectDeep<T, Options> // Tuples behave properly
922
- : T // If they don't opt into array testing, just use the original type
923
- : PartialObjectDeep<T, Options>
924
- : unknown;
888
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
889
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : IsNever$1<keyof T> extends true // For functions with no properties
890
+ ? 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 object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
891
+ ? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
892
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
893
+ ? 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
894
+ : T // If they don't opt into array testing, just use the original type
895
+ : PartialObjectDeep<T, Options> : unknown;
925
896
 
926
897
  /**
927
898
  Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
@@ -946,13 +917,10 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
946
917
  /**
947
918
  Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
948
919
  */
949
- type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
950
- (ObjectType extends (...arguments_: any) => unknown
951
- ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
952
- : {}) & ({
953
- [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
954
- });
920
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = (ObjectType extends ((...arguments_: any) => unknown) ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> : {}) & ({ [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> });
955
921
 
922
+ //#endregion
923
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/required-deep.d.ts
956
924
  type ExcludeUndefined<T> = Exclude<T, undefined>;
957
925
 
958
926
  /**
@@ -996,40 +964,15 @@ Note that types containing overloaded functions are not made deeply required due
996
964
  @category Set
997
965
  @category Map
998
966
  */
999
- type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns
1000
- ? E
1001
- : E extends Map<infer KeyType, infer ValueType>
1002
- ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>>
1003
- : E extends Set<infer ItemType>
1004
- ? Set<RequiredDeep<ItemType>>
1005
- : E extends ReadonlyMap<infer KeyType, infer ValueType>
1006
- ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>>
1007
- : E extends ReadonlySet<infer ItemType>
1008
- ? ReadonlySet<RequiredDeep<ItemType>>
1009
- : E extends WeakMap<infer KeyType, infer ValueType>
1010
- ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>>
1011
- : E extends WeakSet<infer ItemType>
1012
- ? WeakSet<RequiredDeep<ItemType>>
1013
- : E extends Promise<infer ValueType>
1014
- ? Promise<RequiredDeep<ValueType>>
1015
- : E extends (...arguments_: any[]) => unknown
1016
- ? {} extends RequiredObjectDeep<E>
1017
- ? E
1018
- : HasMultipleCallSignatures<E> extends true
1019
- ? E
1020
- : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E>
1021
- : E extends object
1022
- ? E extends Array<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
1023
- ? ItemType[] extends E // Test for arrays (non-tuples) specifically
1024
- ? Array<RequiredDeep<ItemType>> // Recreate relevant array type to prevent eager evaluation of circular reference
1025
- : RequiredObjectDeep<E> // Tuples behave properly
1026
- : RequiredObjectDeep<E>
1027
- : unknown;
1028
-
1029
- type RequiredObjectDeep<ObjectType extends object> = {
1030
- [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]>
1031
- };
967
+ type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns ? E : E extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : E extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : E extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : E extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : E extends ((...arguments_: any[]) => unknown) ? {} extends RequiredObjectDeep<E> ? E : HasMultipleCallSignatures<E> extends true ? E : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E> : E extends object ? E extends Array<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
968
+ ? ItemType[] extends E // Test for arrays (non-tuples) specifically
969
+ ? Array<RequiredDeep<ItemType>> // Recreate relevant array type to prevent eager evaluation of circular reference
970
+ : RequiredObjectDeep<E> // Tuples behave properly
971
+ : RequiredObjectDeep<E> : unknown;
972
+ type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
1032
973
 
974
+ //#endregion
975
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/union-to-tuple.d.ts
1033
976
  /**
1034
977
  Returns the last element of a union type.
1035
978
 
@@ -1039,10 +982,7 @@ type Last = LastOfUnion<1 | 2 | 3>;
1039
982
  //=> 3
1040
983
  ```
1041
984
  */
1042
- type LastOfUnion<T> =
1043
- UnionToIntersection$1<T extends any ? () => T : never> extends () => (infer R)
1044
- ? R
1045
- : never;
985
+ type LastOfUnion<T> = UnionToIntersection$1<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
1046
986
 
1047
987
  /**
1048
988
  Convert a union type into an unordered tuple type of its elements.
@@ -1079,11 +1019,10 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
1079
1019
 
1080
1020
  @category Array
1081
1021
  */
1082
- type UnionToTuple$1<T, L = LastOfUnion<T>> =
1083
- IsNever$1<T> extends false
1084
- ? [...UnionToTuple$1<Exclude<T, L>>, L]
1085
- : [];
1022
+ type UnionToTuple$1<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple$1<Exclude<T, L>>, L] : [];
1086
1023
 
1024
+ //#endregion
1025
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/is-null.d.ts
1087
1026
  /**
1088
1027
  Returns a boolean for whether the given type is `null`.
1089
1028
 
@@ -1105,6 +1044,8 @@ type Example2 = NonNullFallback<number, string>;
1105
1044
  */
1106
1045
  type IsNull<T> = [T] extends [null] ? true : false;
1107
1046
 
1047
+ //#endregion
1048
+ //#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/is-unknown.d.ts
1108
1049
  /**
1109
1050
  Returns a boolean for whether the given type is `unknown`.
1110
1051
 
@@ -1148,158 +1089,155 @@ store.execute((state, payload) => ({value: state.value + payload}), someExternal
1148
1089
 
1149
1090
  @category Utilities
1150
1091
  */
1151
- type IsUnknown$1<T> = (
1152
- unknown extends T // `T` can be `unknown` or `any`
1153
- ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
1154
- ? true
1155
- : false
1156
- : false
1157
- );
1092
+ type IsUnknown$1<T> = (unknown extends T // `T` can be `unknown` or `any`
1093
+ ? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
1094
+ ? true : false : false);
1158
1095
 
1096
+ //#endregion
1097
+ //#region src/types/core/modifiers.types.d.ts
1159
1098
  interface RegleBehaviourOptions {
1160
- /**
1161
- * Only display error when calling `r$.$validate()`
1162
- * @default false
1163
- */
1164
- lazy?: boolean | undefined;
1165
- /**
1166
- * Automatically set the dirty set without the need of `$value` or `$touch`.
1167
- * @default true
1168
- *
1169
- */
1170
- autoDirty?: boolean | undefined;
1171
- /**
1172
- * Only update error status when calling `$validate`.
1173
- * Will not display errors as you type
1174
- * @default false
1175
- *
1176
- * @default true if rewardEarly is true
1177
- *
1178
- */
1179
- silent?: boolean | undefined;
1180
- /**
1181
- * The fields will turn valid when they are, but not invalid unless calling `r$.$validate()`
1182
- * @default false
1183
- */
1184
- rewardEarly?: boolean | undefined;
1185
- /**
1186
- * Define whether the external errors should be cleared when updating a field
1187
- *
1188
- * Default to `false` if `$silent` is set to `true`
1189
-
1190
- * @default true
1191
- *
1192
- *
1193
- */
1194
- clearExternalErrorsOnChange?: boolean | undefined;
1099
+ /**
1100
+ * Only display error when calling `r$.$validate()`
1101
+ * @default false
1102
+ */
1103
+ lazy?: boolean | undefined;
1104
+ /**
1105
+ * Automatically set the dirty set without the need of `$value` or `$touch`.
1106
+ * @default true
1107
+ *
1108
+ */
1109
+ autoDirty?: boolean | undefined;
1110
+ /**
1111
+ * Only update error status when calling `$validate`.
1112
+ * Will not display errors as you type
1113
+ * @default false
1114
+ *
1115
+ * @default true if rewardEarly is true
1116
+ *
1117
+ */
1118
+ silent?: boolean | undefined;
1119
+ /**
1120
+ * The fields will turn valid when they are, but not invalid unless calling `r$.$validate()`
1121
+ * @default false
1122
+ */
1123
+ rewardEarly?: boolean | undefined;
1124
+ /**
1125
+ * Define whether the external errors should be cleared when updating a field
1126
+ *
1127
+ * Default to `false` if `$silent` is set to `true`
1128
+ * @default true
1129
+ *
1130
+ *
1131
+ */
1132
+ clearExternalErrorsOnChange?: boolean | undefined;
1195
1133
  }
1196
1134
  interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
1197
- externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState>>>;
1198
- validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
1135
+ externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState>>>;
1136
+ validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
1199
1137
  }
1200
1138
  type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
1201
1139
  interface RegleValidationGroupOutput {
1202
- $invalid: boolean;
1203
- $error: boolean;
1204
- $pending: boolean;
1205
- $dirty: boolean;
1206
- $correct: boolean;
1207
- $errors: string[];
1208
- $silentErrors: string[];
1140
+ $invalid: boolean;
1141
+ $error: boolean;
1142
+ $pending: boolean;
1143
+ $dirty: boolean;
1144
+ $correct: boolean;
1145
+ $errors: string[];
1146
+ $silentErrors: string[];
1209
1147
  }
1210
1148
  type FieldRegleBehaviourOptions = AddDollarToOptions<RegleBehaviourOptions> & {
1211
- /**
1212
- * Let you declare the number of milliseconds the rule needs to wait before executing. Useful for async or heavy computations.
1213
- */
1214
- $debounce?: number;
1149
+ /**
1150
+ * Let you declare the number of milliseconds the rule needs to wait before executing. Useful for async or heavy computations.
1151
+ */
1152
+ $debounce?: number;
1215
1153
  };
1216
1154
  type CollectionRegleBehaviourOptions = FieldRegleBehaviourOptions & {
1217
- /**
1218
- * Allow deep compare of array children to compute the `$edited` property
1219
- *
1220
- * Disabled by default for performance
1221
- *
1222
- * @default false
1223
- * */
1224
- $deepCompare?: boolean;
1155
+ /**
1156
+ * Allow deep compare of array children to compute the `$edited` property
1157
+ *
1158
+ * Disabled by default for performance
1159
+ *
1160
+ * @default false
1161
+ * */
1162
+ $deepCompare?: boolean;
1225
1163
  };
1226
1164
  type ResolvedRegleBehaviourOptions = DeepMaybeRef<RequiredDeep<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<Record<string, any>, Record<string, any>, Record<string, any[]>>;
1227
1165
  type ShortcutCommonFn<T extends Record<string, any>> = {
1228
- [x: string]: (element: OmitByType<T, Function>) => unknown;
1166
+ [x: string]: (element: OmitByType<T, Function>) => unknown;
1229
1167
  };
1230
1168
  type RegleShortcutDefinition<TCustomRules extends Record<string, any> = {}> = {
1231
- /**
1232
- * Allow you to customize the properties for every field
1233
- */
1234
- fields?: ShortcutCommonFn<RegleFieldStatus<any, Partial<TCustomRules> & Partial<DefaultValidators>>>;
1235
- /**
1236
- * Allow you to customize the properties for every parent of a nested object
1237
- */
1238
- nested?: ShortcutCommonFn<RegleStatus<Record<string, any>, ReglePartialRuleTree<any, Partial<TCustomRules> & Partial<DefaultValidators>>>>;
1239
- /**
1240
- * Allow you to customize the properties for every parent of a collection
1241
- */
1242
- collections?: ShortcutCommonFn<RegleCollectionStatus<any[], Partial<TCustomRules> & Partial<DefaultValidators>>>;
1243
- };
1244
- type AddDollarToOptions<T extends Record<string, any>> = {
1245
- [K in keyof T as `$${string & K}`]: T[K];
1246
- };
1247
-
1169
+ /**
1170
+ * Allow you to customize the properties for every field
1171
+ */
1172
+ fields?: ShortcutCommonFn<RegleFieldStatus<any, Partial<TCustomRules> & Partial<DefaultValidators>>>;
1173
+ /**
1174
+ * Allow you to customize the properties for every parent of a nested object
1175
+ */
1176
+ nested?: ShortcutCommonFn<RegleStatus<Record<string, any>, ReglePartialRuleTree<any, Partial<TCustomRules> & Partial<DefaultValidators>>>>;
1177
+ /**
1178
+ * Allow you to customize the properties for every parent of a collection
1179
+ */
1180
+ collections?: ShortcutCommonFn<RegleCollectionStatus<any[], Partial<TCustomRules> & Partial<DefaultValidators>>>;
1181
+ };
1182
+ type AddDollarToOptions<T extends Record<string, any>> = { [K in keyof T as `$${string & K}`]: T[K] };
1183
+
1184
+ //#endregion
1185
+ //#region src/types/core/useRegle.types.d.ts
1248
1186
  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> = {}> = {
1249
- /**
1250
- * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
1251
- *
1252
- * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
1253
- */
1254
- r$: Raw<RegleRoot<TState, TRules, TValidationGroups, TShortcuts>>;
1187
+ /**
1188
+ * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
1189
+ *
1190
+ * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
1191
+ */
1192
+ r$: Raw<RegleRoot<TState, TRules, TValidationGroups, TShortcuts>>;
1255
1193
  } & TAdditionalReturnProperties;
1256
1194
  type RegleSingleField<TState extends Maybe<PrimitiveTypes> = any, TRules extends RegleRuleDecl<NonNullable<TState>> = EmptyObject, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
1257
- /**
1258
- * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
1259
- *
1260
- * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
1261
- */
1262
- r$: Raw<RegleFieldStatus<TState, TRules, TShortcuts>>;
1195
+ /**
1196
+ * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display information.
1197
+ *
1198
+ * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
1199
+ */
1200
+ r$: Raw<RegleFieldStatus<TState, TRules, TShortcuts>>;
1263
1201
  } & TAdditionalReturnProperties;
1264
- type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? {
1265
- [K in keyof T]: InferDeepReactiveState<T[K]>;
1266
- } : never;
1202
+ type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? { [K in keyof T]: InferDeepReactiveState<T[K]> } : never;
1267
1203
  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>;
1268
1204
 
1205
+ //#endregion
1206
+ //#region src/types/core/reset.types.d.ts
1269
1207
  type ResetOptions<TState extends unknown> = RequireOneOrNone<{
1270
- /**
1271
- * Reset validation status and reset form state to its initial state
1272
- *
1273
- * ⚠️ This doesn't work if the state is a `reactive` object.
1274
- */
1275
- toInitialState?: boolean;
1276
- /**
1277
- * Reset validation status and reset form state to the given state
1278
- * Also set the new state as the initial state.
1279
- */
1280
- toState?: TState | (() => TState);
1281
- /**
1282
- * Clears the $externalErrors state back to an empty object.
1283
- */
1284
- clearExternalErrors?: boolean;
1208
+ /**
1209
+ * Reset validation status and reset form state to its initial state
1210
+ *
1211
+ * ⚠️ This doesn't work if the state is a `reactive` object.
1212
+ */
1213
+ toInitialState?: boolean;
1214
+ /**
1215
+ * Reset validation status and reset form state to the given state
1216
+ * Also set the new state as the initial state.
1217
+ */
1218
+ toState?: TState | (() => TState);
1219
+ /**
1220
+ * Clears the $externalErrors state back to an empty object.
1221
+ */
1222
+ clearExternalErrors?: boolean;
1285
1223
  }, 'toInitialState' | 'toState'>;
1286
1224
 
1225
+ //#endregion
1226
+ //#region src/types/core/scopedRegle.types.d.ts
1287
1227
  type ScopedInstancesRecord = Record<string, Record<string, SuperCompatibleRegleRoot>> & {
1288
- '~~global': Record<string, SuperCompatibleRegleRoot>;
1228
+ '~~global': Record<string, SuperCompatibleRegleRoot>;
1289
1229
  };
1290
1230
  type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
1291
1231
 
1292
- type PartialFormState<TState extends Record<string, any>> = [unknown] extends [TState] ? {} : Prettify<{
1293
- [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? never : TState[K] extends Array<any> ? never : K]?: MaybeOutput<TState[K]>;
1294
- } & {
1295
- [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]>;
1296
- }>;
1232
+ //#endregion
1233
+ //#region src/types/core/results.types.d.ts
1234
+ 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]> }>;
1297
1235
  type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules extends ReglePartialRuleTree<any>> = {
1298
- valid: false;
1299
- data: IsUnknown$1<Data> extends true ? unknown : 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>;
1236
+ valid: false;
1237
+ data: IsUnknown$1<Data> extends true ? unknown : 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>;
1300
1238
  } | {
1301
- valid: true;
1302
- data: IsUnknown$1<Data> extends true ? unknown : 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>;
1239
+ valid: true;
1240
+ data: IsUnknown$1<Data> extends true ? unknown : 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>;
1303
1241
  };
1304
1242
  /**
1305
1243
  * Infer safe output from any `r$` instance
@@ -1310,33 +1248,38 @@ type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules exte
1310
1248
  */
1311
1249
  type InferSafeOutput<TRegle extends MaybeRef<RegleRoot<{}, any, any, any>> | MaybeRef<RegleFieldStatus<any, any, any>>> = UnwrapRef<TRegle> extends Raw<RegleRoot<infer TState extends Record<string, any>, infer TRules, any, any>> ? DeepSafeFormState<JoinDiscriminatedUnions<TState>, TRules> : UnwrapRef<TRegle> extends RegleFieldStatus<infer TState, infer TRules> ? SafeFieldProperty<TState, TRules> : never;
1312
1250
  type $InternalRegleResult = {
1313
- valid: boolean;
1314
- data: any;
1251
+ valid: boolean;
1252
+ data: any;
1315
1253
  };
1316
- type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<Record<string, any>, CustomRulesDeclarationTree> | undefined> = [unknown] extends [TState] ? {} : TRules extends undefined ? TState : TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree> ? Prettify<{
1317
- [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]>;
1318
- } & {
1319
- [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]>>;
1320
- }> : TState;
1254
+ type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<Record<string, any>, CustomRulesDeclarationTree> | 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;
1321
1255
  type FieldHaveRequiredRule<TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends RegleRuleDecl<any, any> ? [unknown] extends TRule['required'] ? NonNullable<TRule['literal']> extends RegleRuleDefinition<any, any[], any, any, any, any> ? true : false : NonNullable<TRule['required']> extends TRule['required'] ? TRule['required'] extends RegleRuleDefinition<any, infer Params, any, any, any, any> ? Params extends never[] ? true : false : false : false : false;
1322
- type ObjectHaveAtLeastOneRequiredField<TState extends Record<string, any>, TRule extends ReglePartialRuleTree<TState, any>> = TState extends Maybe<TState> ? {
1323
- [K in keyof NonNullable<TState>]-?: IsPropertyOutputRequired<NonNullable<TState>[K], TRule[K]>;
1324
- }[keyof TState] extends false ? false : true : true;
1256
+ 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;
1325
1257
  type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends RegleCollectionRuleDecl<TState>> = TState extends Maybe<TState> ? FieldHaveRequiredRule<Omit<TRule, '$each'> extends RegleRuleDecl ? Omit<TRule, '$each'> : {}> | ObjectHaveAtLeastOneRequiredField<ArrayElement<NonNullable<TState>>, ExtractFromGetter<TRule['$each']> extends undefined ? {} : NonNullable<ExtractFromGetter<TRule['$each']>>> extends false ? false : true : true;
1326
1258
  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 RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends true ? TState : MaybeOutput<TState> : TState : TState;
1327
- type IsPropertyOutputRequired<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = [
1328
- unknown
1329
- ] 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 RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends false ? false : true : false : false;
1259
+ 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 RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends false ? false : true : false : false;
1330
1260
  type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
1331
1261
 
1262
+ //#endregion
1263
+ //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.d.ts
1332
1264
  /**
1333
1265
  * Negates a boolean type.
1334
1266
  */
1335
1267
  type Not<T extends boolean> = T extends true ? false : true;
1268
+ /**
1269
+ * Returns `true` if at least one of the types in the
1270
+ * {@linkcode Types} array is `true`, otherwise returns `false`.
1271
+ */
1272
+
1336
1273
  /**
1337
1274
  * Checks if all the boolean types in the {@linkcode Types} array are `true`.
1338
1275
  */
1339
1276
  type And<Types extends boolean[]> = Types[number] extends true ? true : false;
1277
+ /**
1278
+ * Represents an equality type that returns {@linkcode Right} if
1279
+ * {@linkcode Left} is `true`,
1280
+ * otherwise returns the negation of {@linkcode Right}.
1281
+ */
1282
+
1340
1283
  /**
1341
1284
  * @internal
1342
1285
  */
@@ -1357,6 +1300,10 @@ type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
1357
1300
  * Determines if the given type is `unknown`.
1358
1301
  */
1359
1302
  type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
1303
+ /**
1304
+ * Determines if a type is either `never` or `any`.
1305
+ */
1306
+
1360
1307
  /**
1361
1308
  * Subjective "useful" keys from a type. For objects it's just `keyof` but for
1362
1309
  * tuples/arrays it's the number keys.
@@ -1370,15 +1317,11 @@ type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
1370
1317
  * UsefulKeys<string[]> // number
1371
1318
  * ```
1372
1319
  */
1373
- type UsefulKeys<T> = T extends any[] ? {
1374
- [K in keyof T]: K;
1375
- }[number] : keyof T;
1320
+ type UsefulKeys<T> = T extends any[] ? { [K in keyof T]: K }[number] : keyof T;
1376
1321
  /**
1377
1322
  * Extracts the keys from a type that are required (not optional).
1378
1323
  */
1379
- type RequiredKeys<T> = Extract<{
1380
- [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
1381
- }[keyof T], keyof T>;
1324
+ type RequiredKeys<T> = Extract<{ [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T], keyof T>;
1382
1325
  /**
1383
1326
  * Gets the keys of an object type that are optional.
1384
1327
  */
@@ -1386,13 +1329,7 @@ type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
1386
1329
  /**
1387
1330
  * Extracts the keys from a type that are not `readonly`.
1388
1331
  */
1389
- type ReadonlyKeys<T> = Extract<{
1390
- [K in keyof T]-?: ReadonlyEquivalent<{
1391
- [_K in K]: T[K];
1392
- }, {
1393
- -readonly [_K in K]: T[K];
1394
- }> extends true ? never : K;
1395
- }[keyof T], keyof T>;
1332
+ type ReadonlyKeys<T> = Extract<{ [K in keyof T]-?: ReadonlyEquivalent<{ [_K in K]: T[K] }, { -readonly [_K in K]: T[K] }> extends true ? never : K }[keyof T], keyof T>;
1396
1333
  /**
1397
1334
  * Determines if two types, are equivalent in a `readonly` manner.
1398
1335
  *
@@ -1405,13 +1342,18 @@ type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (
1405
1342
  * 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`.
1406
1343
  */
1407
1344
  type Extends<Left, Right> = IsNever<Left> extends true ? IsNever<Right> : [Left] extends [Right] ? true : false;
1345
+ /**
1346
+ * Checks if the {@linkcode Left} type extends the {@linkcode Right} type,
1347
+ * excluding `any` or `never`.
1348
+ */
1349
+
1408
1350
  /**
1409
1351
  * Checks if two types are strictly equal using
1410
1352
  * the TypeScript internal identical-to operator.
1411
1353
  *
1412
1354
  * @see {@link https://github.com/microsoft/TypeScript/issues/55188#issuecomment-1656328122 | much history}
1413
1355
  */
1414
- type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends <T>() => T extends (R & T) | T ? true : false ? IsNever<L> extends IsNever<R> ? true : false : false;
1356
+ type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends (<T>() => T extends (R & T) | T ? true : false) ? IsNever<L> extends IsNever<R> ? true : false : false;
1415
1357
  /**
1416
1358
  * Checks that {@linkcode Left} and {@linkcode Right} extend each other.
1417
1359
  * Not quite the same as an equality check since `any` can make it resolve
@@ -1419,17 +1361,21 @@ type StrictEqualUsingTSInternalIdenticalToOperator<L, R> = (<T>() => T extends (
1419
1361
  * {@linkcode Right} are known to avoid `any`.
1420
1362
  */
1421
1363
  type MutuallyExtends<Left, Right> = And<[Extends<Left, Right>, Extends<Right, Left>]>;
1364
+ /**
1365
+ * @internal
1366
+ */
1367
+
1422
1368
  /**
1423
1369
  * Convert a union to an intersection.
1424
1370
  * `A | B | C` -\> `A & B & C`
1425
1371
  */
1426
- type UnionToIntersection<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection : never;
1372
+ type UnionToIntersection<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
1427
1373
  /**
1428
1374
  * Get the last element of a union.
1429
1375
  * First, converts to a union of `() => T` functions,
1430
1376
  * then uses {@linkcode UnionToIntersection} to get the last one.
1431
1377
  */
1432
- type LastOf<Union> = UnionToIntersection<Union extends any ? () => Union : never> extends () => infer R ? R : never;
1378
+ type LastOf<Union> = UnionToIntersection<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
1433
1379
  /**
1434
1380
  * Intermediate type for {@linkcode UnionToTuple} which pushes the
1435
1381
  * "last" union member to the end of a tuple, and recursively prepends
@@ -1442,6 +1388,19 @@ type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever<Union> extends t
1442
1388
  type UnionToTuple<Union> = TuplifyUnion<Union>;
1443
1389
  type IsUnion<T> = Not<Extends<UnionToTuple<T>['length'], 1>>;
1444
1390
 
1391
+ //#endregion
1392
+ //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.d.ts
1393
+ /**
1394
+ * A recursive version of `Pick` that selects properties from the left type that are present in the right type.
1395
+ * The "leaf" types from `Left` are used - only the keys of `Right` are considered.
1396
+ *
1397
+ * @example
1398
+ * ```ts
1399
+ * const user = {email: 'a@b.com', name: 'John Doe', address: {street: '123 2nd St', city: 'New York', zip: '10001', state: 'NY', country: 'USA'}}
1400
+ *
1401
+ * type Result = DeepPickMatchingProps<typeof user, {name: unknown; address: {city: unknown}}> // {name: string, address: {city: string}}
1402
+ * ```
1403
+ */
1445
1404
  /**
1446
1405
  * The simple(ish) way to get overload info from a function
1447
1406
  * {@linkcode FunctionType}. Recent versions of TypeScript will match any
@@ -1453,16 +1412,16 @@ type IsUnion<T> = Not<Extends<UnionToTuple<T>['length'], 1>>;
1453
1412
  * ten separate matches.
1454
1413
  */
1455
1414
  type TSPost53OverloadsInfoUnion<FunctionType> = FunctionType extends {
1456
- (...args: infer A1): infer R1;
1457
- (...args: infer A2): infer R2;
1458
- (...args: infer A3): infer R3;
1459
- (...args: infer A4): infer R4;
1460
- (...args: infer A5): infer R5;
1461
- (...args: infer A6): infer R6;
1462
- (...args: infer A7): infer R7;
1463
- (...args: infer A8): infer R8;
1464
- (...args: infer A9): infer R9;
1465
- (...args: infer A10): infer R10;
1415
+ (...args: infer A1): infer R1;
1416
+ (...args: infer A2): infer R2;
1417
+ (...args: infer A3): infer R3;
1418
+ (...args: infer A4): infer R4;
1419
+ (...args: infer A5): infer R5;
1420
+ (...args: infer A6): infer R6;
1421
+ (...args: infer A7): infer R7;
1422
+ (...args: infer A8): infer R8;
1423
+ (...args: infer A9): infer R9;
1424
+ (...args: infer A10): infer R10;
1466
1425
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) | ((...p: A10) => R10) : never;
1467
1426
  /**
1468
1427
  * A function with `unknown` parameters and return type.
@@ -1503,69 +1462,69 @@ type TSPre53OverloadsInfoUnion<FunctionType> = Tuplify<DecreasingOverloadsInfoUn
1503
1462
  * then 9, then 8, etc., to get a union of the overload variants.
1504
1463
  */
1505
1464
  type DecreasingOverloadsInfoUnion<F> = F extends {
1506
- (...args: infer A1): infer R1;
1507
- (...args: infer A2): infer R2;
1508
- (...args: infer A3): infer R3;
1509
- (...args: infer A4): infer R4;
1510
- (...args: infer A5): infer R5;
1511
- (...args: infer A6): infer R6;
1512
- (...args: infer A7): infer R7;
1513
- (...args: infer A8): infer R8;
1514
- (...args: infer A9): infer R9;
1515
- (...args: infer A10): infer R10;
1465
+ (...args: infer A1): infer R1;
1466
+ (...args: infer A2): infer R2;
1467
+ (...args: infer A3): infer R3;
1468
+ (...args: infer A4): infer R4;
1469
+ (...args: infer A5): infer R5;
1470
+ (...args: infer A6): infer R6;
1471
+ (...args: infer A7): infer R7;
1472
+ (...args: infer A8): infer R8;
1473
+ (...args: infer A9): infer R9;
1474
+ (...args: infer A10): infer R10;
1516
1475
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) | ((...p: A10) => R10) : F extends {
1517
- (...args: infer A1): infer R1;
1518
- (...args: infer A2): infer R2;
1519
- (...args: infer A3): infer R3;
1520
- (...args: infer A4): infer R4;
1521
- (...args: infer A5): infer R5;
1522
- (...args: infer A6): infer R6;
1523
- (...args: infer A7): infer R7;
1524
- (...args: infer A8): infer R8;
1525
- (...args: infer A9): infer R9;
1476
+ (...args: infer A1): infer R1;
1477
+ (...args: infer A2): infer R2;
1478
+ (...args: infer A3): infer R3;
1479
+ (...args: infer A4): infer R4;
1480
+ (...args: infer A5): infer R5;
1481
+ (...args: infer A6): infer R6;
1482
+ (...args: infer A7): infer R7;
1483
+ (...args: infer A8): infer R8;
1484
+ (...args: infer A9): infer R9;
1526
1485
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) | ((...p: A9) => R9) : F extends {
1527
- (...args: infer A1): infer R1;
1528
- (...args: infer A2): infer R2;
1529
- (...args: infer A3): infer R3;
1530
- (...args: infer A4): infer R4;
1531
- (...args: infer A5): infer R5;
1532
- (...args: infer A6): infer R6;
1533
- (...args: infer A7): infer R7;
1534
- (...args: infer A8): infer R8;
1486
+ (...args: infer A1): infer R1;
1487
+ (...args: infer A2): infer R2;
1488
+ (...args: infer A3): infer R3;
1489
+ (...args: infer A4): infer R4;
1490
+ (...args: infer A5): infer R5;
1491
+ (...args: infer A6): infer R6;
1492
+ (...args: infer A7): infer R7;
1493
+ (...args: infer A8): infer R8;
1535
1494
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) | ((...p: A8) => R8) : F extends {
1536
- (...args: infer A1): infer R1;
1537
- (...args: infer A2): infer R2;
1538
- (...args: infer A3): infer R3;
1539
- (...args: infer A4): infer R4;
1540
- (...args: infer A5): infer R5;
1541
- (...args: infer A6): infer R6;
1542
- (...args: infer A7): infer R7;
1495
+ (...args: infer A1): infer R1;
1496
+ (...args: infer A2): infer R2;
1497
+ (...args: infer A3): infer R3;
1498
+ (...args: infer A4): infer R4;
1499
+ (...args: infer A5): infer R5;
1500
+ (...args: infer A6): infer R6;
1501
+ (...args: infer A7): infer R7;
1543
1502
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) | ((...p: A7) => R7) : F extends {
1544
- (...args: infer A1): infer R1;
1545
- (...args: infer A2): infer R2;
1546
- (...args: infer A3): infer R3;
1547
- (...args: infer A4): infer R4;
1548
- (...args: infer A5): infer R5;
1549
- (...args: infer A6): infer R6;
1503
+ (...args: infer A1): infer R1;
1504
+ (...args: infer A2): infer R2;
1505
+ (...args: infer A3): infer R3;
1506
+ (...args: infer A4): infer R4;
1507
+ (...args: infer A5): infer R5;
1508
+ (...args: infer A6): infer R6;
1550
1509
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) | ((...p: A6) => R6) : F extends {
1551
- (...args: infer A1): infer R1;
1552
- (...args: infer A2): infer R2;
1553
- (...args: infer A3): infer R3;
1554
- (...args: infer A4): infer R4;
1555
- (...args: infer A5): infer R5;
1510
+ (...args: infer A1): infer R1;
1511
+ (...args: infer A2): infer R2;
1512
+ (...args: infer A3): infer R3;
1513
+ (...args: infer A4): infer R4;
1514
+ (...args: infer A5): infer R5;
1556
1515
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) | ((...p: A5) => R5) : F extends {
1557
- (...args: infer A1): infer R1;
1558
- (...args: infer A2): infer R2;
1559
- (...args: infer A3): infer R3;
1560
- (...args: infer A4): infer R4;
1516
+ (...args: infer A1): infer R1;
1517
+ (...args: infer A2): infer R2;
1518
+ (...args: infer A3): infer R3;
1519
+ (...args: infer A4): infer R4;
1561
1520
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) | ((...p: A4) => R4) : F extends {
1562
- (...args: infer A1): infer R1;
1563
- (...args: infer A2): infer R2;
1564
- (...args: infer A3): infer R3;
1521
+ (...args: infer A1): infer R1;
1522
+ (...args: infer A2): infer R2;
1523
+ (...args: infer A3): infer R3;
1565
1524
  } ? ((...p: A1) => R1) | ((...p: A2) => R2) | ((...p: A3) => R3) : F extends {
1566
- (...args: infer A1): infer R1;
1567
- (...args: infer A2): infer R2;
1568
- } ? ((...p: A1) => R1) | ((...p: A2) => R2) : F extends (...args: infer A1) => infer R1 ? ((...p: A1) => R1) : never;
1525
+ (...args: infer A1): infer R1;
1526
+ (...args: infer A2): infer R2;
1527
+ } ? ((...p: A1) => R1) | ((...p: A2) => R2) : F extends ((...args: infer A1) => infer R1) ? ((...p: A1) => R1) : never;
1569
1528
  /**
1570
1529
  * Get a union of overload variants for a function {@linkcode FunctionType}.
1571
1530
  * Does a check for whether we can do the one-shot
@@ -1573,6 +1532,10 @@ type DecreasingOverloadsInfoUnion<F> = F extends {
1573
1532
  * falls back to the more complicated utility.
1574
1533
  */
1575
1534
  type OverloadsInfoUnion<FunctionType> = IsNever<TSPost53OverloadsInfoUnion<(a: 1) => 2>> extends true ? TSPre53OverloadsInfoUnion<FunctionType> : TSPost53OverloadsInfoUnion<FunctionType>;
1535
+ /**
1536
+ * Allows inferring any function using the `infer` keyword.
1537
+ */
1538
+
1576
1539
  /**
1577
1540
  * The simple(ish) way to get overload info from a constructor
1578
1541
  * {@linkcode ConstructorType}. Recent versions of TypeScript will match any
@@ -1584,16 +1547,16 @@ type OverloadsInfoUnion<FunctionType> = IsNever<TSPost53OverloadsInfoUnion<(a: 1
1584
1547
  * we'll need to painstakingly do ten separate matches.
1585
1548
  */
1586
1549
  type TSPost53ConstructorOverloadsInfoUnion<ConstructorType> = ConstructorType extends {
1587
- new (...args: infer A1): infer R1;
1588
- new (...args: infer A2): infer R2;
1589
- new (...args: infer A3): infer R3;
1590
- new (...args: infer A4): infer R4;
1591
- new (...args: infer A5): infer R5;
1592
- new (...args: infer A6): infer R6;
1593
- new (...args: infer A7): infer R7;
1594
- new (...args: infer A8): infer R8;
1595
- new (...args: infer A9): infer R9;
1596
- new (...args: infer A10): infer R10;
1550
+ new (...args: infer A1): infer R1;
1551
+ new (...args: infer A2): infer R2;
1552
+ new (...args: infer A3): infer R3;
1553
+ new (...args: infer A4): infer R4;
1554
+ new (...args: infer A5): infer R5;
1555
+ new (...args: infer A6): infer R6;
1556
+ new (...args: infer A7): infer R7;
1557
+ new (...args: infer A8): infer R8;
1558
+ new (...args: infer A9): infer R9;
1559
+ new (...args: infer A10): infer R10;
1597
1560
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) | (new (...p: A10) => R10) : never;
1598
1561
  /**
1599
1562
  * A constructor function with `unknown` parameters and return type.
@@ -1620,69 +1583,69 @@ type TSPre53ConstructorOverloadsInfoUnion<ConstructorType> = Tuplify<DecreasingC
1620
1583
  * then 9, then 8, etc., to get a union of the overload variants.
1621
1584
  */
1622
1585
  type DecreasingConstructorOverloadsInfoUnion<ConstructorType> = ConstructorType extends {
1623
- new (...args: infer A1): infer R1;
1624
- new (...args: infer A2): infer R2;
1625
- new (...args: infer A3): infer R3;
1626
- new (...args: infer A4): infer R4;
1627
- new (...args: infer A5): infer R5;
1628
- new (...args: infer A6): infer R6;
1629
- new (...args: infer A7): infer R7;
1630
- new (...args: infer A8): infer R8;
1631
- new (...args: infer A9): infer R9;
1632
- new (...args: infer A10): infer R10;
1586
+ new (...args: infer A1): infer R1;
1587
+ new (...args: infer A2): infer R2;
1588
+ new (...args: infer A3): infer R3;
1589
+ new (...args: infer A4): infer R4;
1590
+ new (...args: infer A5): infer R5;
1591
+ new (...args: infer A6): infer R6;
1592
+ new (...args: infer A7): infer R7;
1593
+ new (...args: infer A8): infer R8;
1594
+ new (...args: infer A9): infer R9;
1595
+ new (...args: infer A10): infer R10;
1633
1596
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) | (new (...p: A10) => R10) : ConstructorType extends {
1634
- new (...args: infer A1): infer R1;
1635
- new (...args: infer A2): infer R2;
1636
- new (...args: infer A3): infer R3;
1637
- new (...args: infer A4): infer R4;
1638
- new (...args: infer A5): infer R5;
1639
- new (...args: infer A6): infer R6;
1640
- new (...args: infer A7): infer R7;
1641
- new (...args: infer A8): infer R8;
1642
- new (...args: infer A9): infer R9;
1597
+ new (...args: infer A1): infer R1;
1598
+ new (...args: infer A2): infer R2;
1599
+ new (...args: infer A3): infer R3;
1600
+ new (...args: infer A4): infer R4;
1601
+ new (...args: infer A5): infer R5;
1602
+ new (...args: infer A6): infer R6;
1603
+ new (...args: infer A7): infer R7;
1604
+ new (...args: infer A8): infer R8;
1605
+ new (...args: infer A9): infer R9;
1643
1606
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) | (new (...p: A9) => R9) : ConstructorType extends {
1644
- new (...args: infer A1): infer R1;
1645
- new (...args: infer A2): infer R2;
1646
- new (...args: infer A3): infer R3;
1647
- new (...args: infer A4): infer R4;
1648
- new (...args: infer A5): infer R5;
1649
- new (...args: infer A6): infer R6;
1650
- new (...args: infer A7): infer R7;
1651
- new (...args: infer A8): infer R8;
1607
+ new (...args: infer A1): infer R1;
1608
+ new (...args: infer A2): infer R2;
1609
+ new (...args: infer A3): infer R3;
1610
+ new (...args: infer A4): infer R4;
1611
+ new (...args: infer A5): infer R5;
1612
+ new (...args: infer A6): infer R6;
1613
+ new (...args: infer A7): infer R7;
1614
+ new (...args: infer A8): infer R8;
1652
1615
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) | (new (...p: A8) => R8) : ConstructorType extends {
1653
- new (...args: infer A1): infer R1;
1654
- new (...args: infer A2): infer R2;
1655
- new (...args: infer A3): infer R3;
1656
- new (...args: infer A4): infer R4;
1657
- new (...args: infer A5): infer R5;
1658
- new (...args: infer A6): infer R6;
1659
- new (...args: infer A7): infer R7;
1616
+ new (...args: infer A1): infer R1;
1617
+ new (...args: infer A2): infer R2;
1618
+ new (...args: infer A3): infer R3;
1619
+ new (...args: infer A4): infer R4;
1620
+ new (...args: infer A5): infer R5;
1621
+ new (...args: infer A6): infer R6;
1622
+ new (...args: infer A7): infer R7;
1660
1623
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) | (new (...p: A7) => R7) : ConstructorType extends {
1661
- new (...args: infer A1): infer R1;
1662
- new (...args: infer A2): infer R2;
1663
- new (...args: infer A3): infer R3;
1664
- new (...args: infer A4): infer R4;
1665
- new (...args: infer A5): infer R5;
1666
- new (...args: infer A6): infer R6;
1624
+ new (...args: infer A1): infer R1;
1625
+ new (...args: infer A2): infer R2;
1626
+ new (...args: infer A3): infer R3;
1627
+ new (...args: infer A4): infer R4;
1628
+ new (...args: infer A5): infer R5;
1629
+ new (...args: infer A6): infer R6;
1667
1630
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) | (new (...p: A6) => R6) : ConstructorType extends {
1668
- new (...args: infer A1): infer R1;
1669
- new (...args: infer A2): infer R2;
1670
- new (...args: infer A3): infer R3;
1671
- new (...args: infer A4): infer R4;
1672
- new (...args: infer A5): infer R5;
1631
+ new (...args: infer A1): infer R1;
1632
+ new (...args: infer A2): infer R2;
1633
+ new (...args: infer A3): infer R3;
1634
+ new (...args: infer A4): infer R4;
1635
+ new (...args: infer A5): infer R5;
1673
1636
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) | (new (...p: A5) => R5) : ConstructorType extends {
1674
- new (...args: infer A1): infer R1;
1675
- new (...args: infer A2): infer R2;
1676
- new (...args: infer A3): infer R3;
1677
- new (...args: infer A4): infer R4;
1637
+ new (...args: infer A1): infer R1;
1638
+ new (...args: infer A2): infer R2;
1639
+ new (...args: infer A3): infer R3;
1640
+ new (...args: infer A4): infer R4;
1678
1641
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) | (new (...p: A4) => R4) : ConstructorType extends {
1679
- new (...args: infer A1): infer R1;
1680
- new (...args: infer A2): infer R2;
1681
- new (...args: infer A3): infer R3;
1642
+ new (...args: infer A1): infer R1;
1643
+ new (...args: infer A2): infer R2;
1644
+ new (...args: infer A3): infer R3;
1682
1645
  } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) | (new (...p: A3) => R3) : ConstructorType extends {
1683
- new (...args: infer A1): infer R1;
1684
- new (...args: infer A2): infer R2;
1685
- } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) : ConstructorType extends new (...args: infer A1) => infer R1 ? (new (...p: A1) => R1) : never;
1646
+ new (...args: infer A1): infer R1;
1647
+ new (...args: infer A2): infer R2;
1648
+ } ? (new (...p: A1) => R1) | (new (...p: A2) => R2) : ConstructorType extends (new (...args: infer A1) => infer R1) ? (new (...p: A1) => R1) : never;
1686
1649
  /**
1687
1650
  * Get a union of overload variants for a constructor
1688
1651
  * {@linkcode ConstructorType}. Does a check for whether we can do the
@@ -1704,6 +1667,8 @@ type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<
1704
1667
  */
1705
1668
  type NumOverloads<FunctionType> = UnionToTuple<OverloadsInfoUnion<FunctionType>>['length'];
1706
1669
 
1670
+ //#endregion
1671
+ //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.d.ts
1707
1672
  /**
1708
1673
  * Represents a deeply branded type.
1709
1674
  *
@@ -1721,117 +1686,92 @@ type NumOverloads<FunctionType> = UnionToTuple<OverloadsInfoUnion<FunctionType>>
1721
1686
  * better to use {@linkcode StrictEqualUsingTSInternalIdenticalToOperator}.
1722
1687
  */
1723
1688
  type DeepBrand<T> = IsNever<T> extends true ? {
1724
- type: 'never';
1689
+ type: 'never';
1725
1690
  } : IsAny<T> extends true ? {
1726
- type: 'any';
1691
+ type: 'any';
1727
1692
  } : IsUnknown<T> extends true ? {
1728
- type: 'unknown';
1693
+ type: 'unknown';
1729
1694
  } : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
1730
- type: 'primitive';
1731
- value: T;
1732
- } : T extends new (...args: any[]) => any ? {
1733
- type: 'constructor';
1734
- params: ConstructorOverloadParameters<T>;
1735
- instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>;
1736
- } : T extends (...args: infer P) => infer R ? NumOverloads<T> extends 1 ? {
1737
- type: 'function';
1738
- params: DeepBrand<P>;
1739
- return: DeepBrand<R>;
1740
- this: DeepBrand<ThisParameterType<T>>;
1741
- props: DeepBrand<Omit<T, keyof Function>>;
1695
+ type: 'primitive';
1696
+ value: T;
1697
+ } : T extends (new (...args: any[]) => any) ? {
1698
+ type: 'constructor';
1699
+ params: ConstructorOverloadParameters<T>;
1700
+ instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>;
1701
+ } : T extends ((...args: infer P) => infer R) ? NumOverloads<T> extends 1 ? {
1702
+ type: 'function';
1703
+ params: DeepBrand<P>;
1704
+ return: DeepBrand<R>;
1705
+ this: DeepBrand<ThisParameterType<T>>;
1706
+ props: DeepBrand<Omit<T, keyof Function>>;
1742
1707
  } : UnionToTuple<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
1743
- type: 'overloads';
1744
- overloads: {
1745
- [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]>;
1746
- };
1708
+ type: 'overloads';
1709
+ overloads: { [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]> };
1747
1710
  } : never : T extends any[] ? {
1748
- type: 'array';
1749
- items: {
1750
- [K in keyof T]: T[K];
1751
- };
1711
+ type: 'array';
1712
+ items: { [K in keyof T]: T[K] };
1752
1713
  } : {
1753
- type: 'object';
1754
- properties: {
1755
- [K in keyof T]: DeepBrand<T[K]>;
1756
- };
1757
- readonly: ReadonlyKeys<T>;
1758
- required: RequiredKeys<T>;
1759
- optional: OptionalKeys<T>;
1760
- constructorParams: DeepBrand<ConstructorOverloadParameters<T>>;
1714
+ type: 'object';
1715
+ properties: { [K in keyof T]: DeepBrand<T[K]> };
1716
+ readonly: ReadonlyKeys<T>;
1717
+ required: RequiredKeys<T>;
1718
+ optional: OptionalKeys<T>;
1719
+ constructorParams: DeepBrand<ConstructorOverloadParameters<T>>;
1761
1720
  };
1762
1721
  /**
1763
1722
  * Checks if two types are strictly equal using branding.
1764
1723
  */
1765
1724
  type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
1766
1725
 
1726
+ //#endregion
1727
+ //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.d.ts
1767
1728
  /**
1768
1729
  * Determines the printable type representation for a given type.
1769
1730
  */
1770
- type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : bigint extends T ? 'bigint' : T extends bigint ? `literal bigint: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends (...args: any[]) => any ? 'function' : '...';
1731
+ type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : bigint extends T ? 'bigint' : T extends bigint ? `literal bigint: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends ((...args: any[]) => any) ? 'function' : '...';
1771
1732
  /**
1772
1733
  * Helper for showing end-user a hint why their type assertion is failing.
1773
1734
  * This swaps "leaf" types with a literal message about what the actual and
1774
1735
  * expected types are. Needs to check for `Not<IsAny<Actual>>` because
1775
1736
  * otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
1776
1737
  */
1777
- type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, Not<IsAny<Actual>>]> extends true ? And<[Extends<any[], Actual>, Extends<any[], Expected>]> extends true ? Array<MismatchInfo<Extract<Actual, any[]>[number], Extract<Expected, any[]>[number]>> : {
1778
- [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never>;
1779
- } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `Expected: ${PrintType<Expected>}, Actual: ${PrintType<Exclude<Actual, Expected>>}`;
1738
+ type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, Not<IsAny<Actual>>]> extends true ? And<[Extends<any[], Actual>, Extends<any[], Expected>]> extends true ? Array<MismatchInfo<Extract<Actual, any[]>[number], Extract<Expected, any[]>[number]>> : { [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never> } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `Expected: ${PrintType<Expected>}, Actual: ${PrintType<Exclude<Actual, Expected>>}`;
1780
1739
 
1740
+ //#endregion
1741
+ //#region src/types/core/variants.types.d.ts
1742
+ /**
1743
+ * @internal
1744
+ */
1781
1745
  type NarrowVariant<TRoot extends {
1782
- [x: string]: unknown;
1783
- }, TKey extends keyof TRoot, TValue extends LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
1784
- $value: infer V;
1785
- } ? V : unknown> = Extract<TRoot, {
1786
- [K in TKey]: RegleFieldStatus<TValue, any, any>;
1787
- }>;
1746
+ [x: string]: unknown;
1747
+ }, TKey extends keyof TRoot, TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
1748
+ $value: infer V;
1749
+ } ? V : unknown)> = Extract<TRoot, { [K in TKey]: RegleFieldStatus<TValue, any, any> }>;
1788
1750
  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'> & {
1789
- $fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
1751
+ $fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
1790
1752
  } : RegleStatus<TState, TRules, TShortcuts>;
1791
- type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = {
1792
- [TIndex in keyof TupleToPlainObj<UnionToTuple$1<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? {
1793
- [TKey in keyof UnionToTuple$1<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<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$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple$1<TState>[TIndexInt]>, TKey, TShortcuts>;
1794
- } & {
1795
- [TKey in keyof UnionToTuple$1<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<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$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple$1<TState>[TIndexInt]>, TKey, TShortcuts>;
1796
- } : {};
1797
- };
1798
- type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [
1799
- infer F,
1800
- ...infer R
1801
- ] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
1753
+ type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple$1<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple$1<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<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$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple$1<TState>[TIndexInt]>, TKey, TShortcuts> } & { [TKey in keyof UnionToTuple$1<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<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$1<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple$1<TState>[TIndexInt] : never, UnionToTuple$1<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject : EmptyObject, NonNullable<UnionToTuple$1<TState>[TIndexInt]>, TKey, TShortcuts> } : {} };
1754
+ type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
1802
1755
  type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> = unknown extends T[TKey] ? {
1803
- [x: string]: {
1804
- [K in TKey]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
1805
- literal?: RegleRuleDefinition<any, [literal: any], false, boolean, any, string | number>;
1806
- };
1807
- };
1808
- } : {
1809
- [TVal in NonNullable<T[TKey]>]: {
1810
- [K in TKey]-?: Omit<RegleRuleDecl<TVal, Partial<AllRulesDeclarations>>, 'literal'> & {
1811
- literal?: RegleRuleDefinition<MaybeInput<TVal>, [
1812
- literal: TVal
1813
- ], false, boolean, MaybeInput<TVal>, string | number>;
1814
- };
1815
- };
1816
- };
1756
+ [x: string]: { [K in TKey]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
1757
+ literal?: RegleRuleDefinition<any, [literal: any], false, boolean, any, string | number>;
1758
+ } };
1759
+ } : { [TVal in NonNullable<T[TKey]>]: { [K in TKey]-?: Omit<RegleRuleDecl<TVal, Partial<AllRulesDeclarations>>, 'literal'> & {
1760
+ literal?: RegleRuleDefinition<MaybeInput<TVal>, [literal: TVal], false, boolean, MaybeInput<TVal>, string | number>;
1761
+ } } };
1817
1762
  type RequiredForm<T extends Record<string, any>, TKey extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey> & PossibleLiteralTypes<T, TKey>[keyof PossibleLiteralTypes<T, TKey>];
1818
- type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [
1819
- RequiredForm<T, TKey>,
1820
- ...RequiredForm<T, TKey>[]
1821
- ];
1763
+ type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [RequiredForm<T, TKey>, ...RequiredForm<T, TKey>[]];
1822
1764
 
1765
+ //#endregion
1766
+ //#region src/core/useRegle/useRegle.d.ts
1823
1767
  type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends 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 : {}, TValidationGroups> & TAdditionalOptions;
1824
1768
  interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
1825
- <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TValid = isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<RegleRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>, NoInferLegacy<TRules>>>(...params: [
1826
- state: Maybe<MaybeRef<TState> | DeepReactiveState<TState>>,
1827
- rulesFactory: TState extends MaybeInput<PrimitiveTypes> ? MaybeRefOrGetter<TDecl> : TState extends Record<string, any> ? MaybeRef<TRules> | ((...args: any[]) => TRules) : {},
1828
- ...(HaveAnyRequiredProps<useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>> extends true ? [options: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>] : [options?: useRegleFnOptions<TState, TRules, TAdditionalOptions, TValidationGroups>])
1829
- ]): NonNullable<TState> extends PrimitiveTypes ? RegleSingleField<NonNullable<TState>, TDecl, TShortcuts, TAdditionalReturnProperties> : Regle<TState extends Record<string, any> ? Unwrap<TState> : {}, TRules, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
1830
- __config?: {
1831
- rules?: () => CustomRulesDeclarationTree;
1832
- modifiers?: RegleBehaviourOptions;
1833
- shortcuts?: TShortcuts;
1834
- };
1769
+ <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>, TValid = (isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<RegleRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules>, NoInferLegacy<TRules>>)>(...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, TValidationGroups, TShortcuts, TAdditionalReturnProperties>;
1770
+ __config?: {
1771
+ rules?: () => CustomRulesDeclarationTree;
1772
+ modifiers?: RegleBehaviourOptions;
1773
+ shortcuts?: TShortcuts;
1774
+ };
1835
1775
  }
1836
1776
  /**
1837
1777
  * useRegle serves as the foundation for validation logic.
@@ -1854,8 +1794,10 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
1854
1794
  */
1855
1795
  declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutDefinition<any>, {}, {}>;
1856
1796
 
1797
+ //#endregion
1798
+ //#region src/core/useRegle/inferRules.d.ts
1857
1799
  interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
1858
- <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValid = isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<NoInferLegacy<TRules>, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? 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;
1800
+ <TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations> & TCustomRules> & TValid, TDecl extends RegleRuleDecl<NonNullable<TState>, Partial<AllRulesDeclarations> & TCustomRules>, TValid = (isDeepExact<NoInferLegacy<TRules>, Unwrap<TState extends Record<string, any> ? TState : {}>> extends true ? {} : MismatchInfo<NoInferLegacy<TRules>, ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? 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;
1859
1801
  }
1860
1802
  /**
1861
1803
  * Rule type helper to provide autocomplete and typecheck to your form rules or part of your form rules
@@ -1866,49 +1808,65 @@ interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
1866
1808
  */
1867
1809
  declare const inferRules: inferRulesFn<Partial<AllRulesDeclarations>>;
1868
1810
 
1869
- declare function useRootStorage({ initialState, options, scopeRules, state, customRules, shortcuts, schemaErrors, schemaMode, onValidate, }: {
1870
- scopeRules: Ref<$InternalReglePartialRuleTree>;
1871
- state: Ref<Record<string, any> | PrimitiveTypes>;
1872
- options: ResolvedRegleBehaviourOptions;
1873
- initialState: Ref<Record<string, any> | PrimitiveTypes>;
1874
- customRules?: () => CustomRulesDeclarationTree;
1875
- shortcuts: RegleShortcutDefinition | undefined;
1876
- schemaErrors?: Ref<any | undefined>;
1877
- schemaMode?: boolean;
1878
- onValidate?: () => Promise<$InternalRegleResult>;
1811
+ //#endregion
1812
+ //#region src/core/useRegle/root/useRootStorage.d.ts
1813
+ declare function useRootStorage({
1814
+ initialState,
1815
+ options,
1816
+ scopeRules,
1817
+ state,
1818
+ customRules,
1819
+ shortcuts,
1820
+ schemaErrors,
1821
+ schemaMode,
1822
+ onValidate
1823
+ }: {
1824
+ scopeRules: Ref<$InternalReglePartialRuleTree>;
1825
+ state: Ref<Record<string, any> | PrimitiveTypes>;
1826
+ options: ResolvedRegleBehaviourOptions;
1827
+ initialState: Ref<Record<string, any> | PrimitiveTypes>;
1828
+ customRules?: () => CustomRulesDeclarationTree;
1829
+ shortcuts: RegleShortcutDefinition | undefined;
1830
+ schemaErrors?: Ref<any | undefined>;
1831
+ schemaMode?: boolean;
1832
+ onValidate?: () => Promise<$InternalRegleResult>;
1879
1833
  }): {
1880
- regle: $InternalRegleStatusType | undefined;
1834
+ regle: $InternalRegleStatusType | undefined;
1881
1835
  };
1882
1836
 
1837
+ //#endregion
1838
+ //#region src/core/useRegle/useErrors.d.ts
1883
1839
  /**
1884
1840
  * Converts a nested $errors object to a flat array of string errors
1885
1841
  *
1886
1842
  * Can also flatten to an array containing the path of each error with the options.includePath
1887
1843
  */
1888
1844
  declare function flatErrors(errors: $InternalRegleErrors, options: {
1889
- includePath: true;
1845
+ includePath: true;
1890
1846
  }): {
1891
- error: string;
1892
- path: string;
1847
+ error: string;
1848
+ path: string;
1893
1849
  }[];
1894
1850
  declare function flatErrors(errors: $InternalRegleErrors, options?: {
1895
- includePath?: false;
1851
+ includePath?: false;
1896
1852
  }): string[];
1897
1853
 
1898
- type InferRegleRoot<T extends (...args: any[]) => SuperCompatibleRegle> = T extends (...args: any[]) => infer U ? U extends SuperCompatibleRegle ? U['r$'] : never : never;
1854
+ //#endregion
1855
+ //#region src/types/utils/props.types.d.ts
1856
+ type InferRegleRoot<T extends (...args: any[]) => SuperCompatibleRegle> = T extends ((...args: any[]) => infer U) ? U extends SuperCompatibleRegle ? U['r$'] : never : never;
1899
1857
  type InferRegleRules<T extends useRegleFn<any, any>> = T extends useRegleFn<infer U, any> ? UnwrapRuleTree<Partial<U> & Partial<DefaultValidators>> : {};
1900
1858
  type InferRegleShortcuts<T extends useRegleFn<any, any>> = T extends useRegleFn<any, infer U> ? U : {};
1901
- type RegleEnforceRequiredRules<TRules extends keyof DefaultValidators> = Omit<Partial<DefaultValidatorsTree>, TRules> & {
1902
- [K in TRules]-?: UnwrapRuleWithParams<DefaultValidators[K]>;
1903
- };
1904
- type RegleEnforceCustomRequiredRules<T extends Partial<AllRulesDeclarations> | useRegleFn<any, any>, TRules extends T extends useRegleFn<any, any> ? keyof InferRegleRules<T> : keyof T> = Omit<Partial<DefaultValidatorsTree>, TRules> & {
1905
- [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;
1906
- };
1859
+ type RegleEnforceRequiredRules<TRules extends keyof DefaultValidators> = Omit<Partial<DefaultValidatorsTree>, TRules> & { [K in TRules]-?: UnwrapRuleWithParams<DefaultValidators[K]> };
1860
+ type RegleEnforceCustomRequiredRules<T extends Partial<AllRulesDeclarations> | useRegleFn<any, any>, TRules extends (T extends useRegleFn<any, any> ? keyof InferRegleRules<T> : keyof 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 };
1907
1861
 
1862
+ //#endregion
1863
+ //#region src/types/utils/object.types.d.ts
1908
1864
  type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
1909
- type MergePropsIntoRequiredBooleans<TObject extends Record<string, any>> = {
1910
- [K in keyof TObject]-?: TObject[K] extends NonNullable<TObject[K]> ? true : false;
1911
- }[keyof TObject];
1865
+ /**
1866
+ * Restore the optional properties (with ?) of a generated mapped object type
1867
+ */
1868
+
1869
+ type MergePropsIntoRequiredBooleans<TObject extends Record<string, any>> = { [K in keyof TObject]-?: TObject[K] extends NonNullable<TObject[K]> ? true : false }[keyof TObject];
1912
1870
  /**
1913
1871
  * Ensure that if at least one prop is required, the "prop" object will be required too
1914
1872
  */
@@ -1920,17 +1878,7 @@ type GetMaybeObjectValue<O extends Record<string, any>, K extends string> = K ex
1920
1878
  /**
1921
1879
  * Combine all union values to be able to get even the normally "never" values, act as an intersection type
1922
1880
  */
1923
- type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [
1924
- infer F extends Record<string, any>,
1925
- ...infer R
1926
- ] ? [
1927
- {
1928
- [K in TKeys as GetMaybeObjectValue<F, K> extends NonNullable<GetMaybeObjectValue<F, K>> ? never : K]?: GetMaybeObjectValue<F, K>;
1929
- } & {
1930
- [K in TKeys as GetMaybeObjectValue<F, K> extends NonNullable<GetMaybeObjectValue<F, K>> ? K : never]: GetMaybeObjectValue<F, K>;
1931
- },
1932
- ...RetrieveUnionUnknownValues<R, TKeys>
1933
- ] : [];
1881
+ type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [infer F extends Record<string, any>, ...infer R] ? [{ [K in TKeys as GetMaybeObjectValue<F, K> extends NonNullable<GetMaybeObjectValue<F, K>> ? never : K]?: GetMaybeObjectValue<F, K> } & { [K in TKeys as GetMaybeObjectValue<F, K> extends NonNullable<GetMaybeObjectValue<F, K>> ? K : never]: GetMaybeObjectValue<F, K> }, ...RetrieveUnionUnknownValues<R, TKeys>] : [];
1934
1882
  /**
1935
1883
  * Get all possible keys from a union, even the ones present only on one union
1936
1884
  */
@@ -1945,106 +1893,102 @@ type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTupl
1945
1893
  type JoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection$1<RemoveCommonKey<UnionToTuple$1<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>[number]>> & Pick<NormalizeUnion<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>> : TUnion;
1946
1894
  type LazyJoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection$1<RemoveCommonKey<UnionToTuple$1<TUnion>, keyof NonNullable<TUnion>>[number]>> & Pick<NonNullable<TUnion>, keyof NonNullable<TUnion>>> : TUnion;
1947
1895
  type EnumLike = {
1948
- [k: string]: string | number;
1949
- [nu: number]: string;
1896
+ [k: string]: string | number;
1897
+ [nu: number]: string;
1950
1898
  };
1951
1899
  type enumType<T extends Record<string, unknown>> = T[keyof T];
1952
1900
  type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
1953
- type TupleToPlainObj<T> = {
1954
- [I in keyof T & `${number}`]: T[I];
1955
- };
1901
+ type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
1956
1902
 
1957
- type isDeepExact<TRules, TTree> = {
1958
- [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never>;
1959
- }[keyof TRules] extends true ? true : false;
1903
+ //#endregion
1904
+ //#region src/types/utils/mismatch.types.d.ts
1905
+ type isDeepExact<TRules, TTree> = { [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never> }[keyof TRules] extends true ? true : false;
1960
1906
  type CheckDeepExact<TRules, TTree> = [TTree] extends [never] ? false : TRules extends RegleCollectionRuleDecl ? TTree extends Array<any> ? isDeepExact<NonNullable<TRules['$each']>, JoinDiscriminatedUnions<NonNullable<ArrayElement<TTree>>>> : TRules extends RegleRuleDecl ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<TRules, TTree> : false : TRules extends RegleRuleDecl ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<TRules, TTree> : false;
1961
1907
 
1962
- type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>), TMarkMaybe extends boolean = true> = IsUnion$1<UnwrapSimple<TRules>> extends true ? InferTupleUnionInput<UnionToTuple$1<UnwrapSimple<TRules>>>[number] : TMarkMaybe extends true ? Prettify<{
1963
- [K in keyof UnwrapSimple<TRules>]?: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe>;
1964
- }> : Prettify<{
1965
- [K in keyof UnwrapSimple<TRules>]: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe>;
1966
- }>;
1908
+ //#endregion
1909
+ //#region src/types/utils/infer.types.d.ts
1910
+ type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>), TMarkMaybe extends boolean = true> = IsUnion$1<UnwrapSimple<TRules>> extends true ? InferTupleUnionInput<UnionToTuple$1<UnwrapSimple<TRules>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules>]?: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules>]: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }>;
1967
1911
  type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
1968
- $each: RegleCollectionEachRules<any, any>;
1912
+ $each: RegleCollectionEachRules<any, any>;
1969
1913
  } ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any, any> ? InferInput<ExtractFromGetter<TRule['$each']>, TMarkMaybe>[] : any[] : TRule extends RegleRuleDecl<any, any> ? [ExtractTypeFromRules<TRule>] extends [never] ? unknown : ExtractTypeFromRules<TRule> : TRule extends ReglePartialRuleTree<any, any> ? InferInput<TRule, TMarkMaybe> : string;
1970
1914
  type ExtractTypeFromRules<TRules extends RegleRuleDecl<any, any>> = FilterRulesWithInput<TRules> extends {
1971
- type: infer Input;
1915
+ type: infer Input;
1972
1916
  } ? Input : [FilterRulesWithSingleType<TRules>[keyof FilterRulesWithSingleType<TRules>]] extends [never] ? FilterRulesWithInput<TRules>[keyof FilterRulesWithInput<TRules>] : FilterRulesWithSingleType<TRules>[keyof FilterRulesWithSingleType<TRules>];
1973
- type FilterRulesWithInput<TRules extends RegleRuleDecl<any, any>> = {
1974
- [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;
1975
- };
1976
- type FilterRulesWithSingleType<TRules extends RegleRuleDecl<any, any>> = {
1977
- [K in keyof TRules as TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion$1<NonNullable<Input>> extends true ? never : K : never]: TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? IsUnion$1<NonNullable<Input>> extends true ? unknown : Input : unknown;
1978
- };
1917
+ 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 };
1918
+ 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$1<NonNullable<Input>> extends true ? never : K : never]: TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? IsUnion$1<NonNullable<Input>> extends true ? unknown : Input : unknown };
1979
1919
  type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
1980
1920
 
1921
+ //#endregion
1922
+ //#region src/types/rules/rule.params.types.d.ts
1981
1923
  type CreateFn<T extends any[]> = (...args: T) => any;
1982
1924
  /**
1983
1925
  * Transform normal parameters tuple declaration to a rich tuple declaration
1984
1926
  *
1985
1927
  * [foo: string, bar?: number] => [foo: MaybeRef<string> | (() => string), bar?: MaybeRef<number | undefined> | (() => number) | undefined]
1986
1928
  */
1987
- type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
1988
- [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>>;
1989
- }) => any : never>;
1990
- type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends (...args: infer Args) => any ? (...args: {
1991
- [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K];
1992
- }) => any : never>;
1929
+ 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>;
1930
+ 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>;
1993
1931
 
1932
+ //#endregion
1933
+ //#region src/types/rules/rule.internal.types.d.ts
1994
1934
  /**
1995
1935
  * Internal definition of the rule, this can be used to reset or patch the rule
1996
1936
  */
1997
1937
  type RegleInternalRuleDefs<TValue extends any = any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> = Raw<{
1998
- _validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
1999
- _message: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
2000
- _active?: boolean | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => boolean);
2001
- _tooltip?: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
2002
- _type?: string;
2003
- _message_patched: boolean;
2004
- _tooltip_patched: boolean;
2005
- _params?: RegleUniversalParams<TParams>;
2006
- _async: TAsync;
2007
- readonly _brand: symbol;
1938
+ _validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
1939
+ _message: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
1940
+ _active?: boolean | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => boolean);
1941
+ _tooltip?: string | string[] | ((metadata: PossibleRegleRuleMetadataConsumer<TValue>) => string | string[]);
1942
+ _type?: string;
1943
+ _message_patched: boolean;
1944
+ _tooltip_patched: boolean;
1945
+ _params?: RegleUniversalParams<TParams>;
1946
+ _async: TAsync;
1947
+ readonly _brand: symbol;
2008
1948
  }>;
2009
1949
  declare const InternalRuleType: {
2010
- readonly Inline: "__inline";
2011
- readonly Async: "__async";
1950
+ readonly Inline: "__inline";
1951
+ readonly Async: "__async";
2012
1952
  };
2013
1953
  type InternalRuleType = enumType<typeof InternalRuleType>;
2014
1954
 
1955
+ //#endregion
1956
+ //#region src/types/rules/rule.definition.type.d.ts
2015
1957
  type IsLiteral<T> = string extends T ? false : true;
2016
1958
  /**
2017
1959
  * Returned typed of rules created with `createRule`
2018
1960
  * */
2019
- 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> {
2020
- validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
2021
- message: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
2022
- active: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => boolean;
2023
- tooltip: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
2024
- type?: string;
2025
- _value?: IsLiteral<TValue> extends true ? TValue : any;
2026
- exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
1961
+ 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> {
1962
+ validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
1963
+ message: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
1964
+ active: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => boolean;
1965
+ tooltip: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
1966
+ type?: string;
1967
+ _value?: IsLiteral<TValue> extends true ? TValue : any;
1968
+ exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
2027
1969
  }
1970
+ /**
1971
+ * @internal
1972
+ * */
1973
+
2028
1974
  /**
2029
1975
  * Rules with params created with `createRules` are callable while being customizable
2030
1976
  */
2031
- 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> & {
2032
- (...params: RegleUniversalParams<TParams>): RegleRuleDefinition<TFilteredValue, TParams, TAsync, TMetadata, TInput>;
1977
+ 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> & {
1978
+ (...params: RegleUniversalParams<TParams>): RegleRuleDefinition<TFilteredValue, TParams, TAsync, TMetadata, TInput>;
2033
1979
  } & (TParams extends [param?: any, ...any[]] ? {
2034
- exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
1980
+ exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
2035
1981
  } : {});
2036
- 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[]] ? {
2037
- exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
1982
+ 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[]] ? {
1983
+ exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetadata : Promise<TMetadata>;
2038
1984
  } : {});
2039
1985
  type RegleRuleMetadataExtended = {
2040
- $valid: boolean;
2041
- [x: string]: any;
1986
+ $valid: boolean;
1987
+ [x: string]: any;
2042
1988
  };
2043
1989
  type UnwrapRuleTree<T extends {
2044
- [x: string]: RegleRuleRawInput<any, any[], any, any> | undefined;
2045
- }> = {
2046
- [K in keyof T]: UnwrapRuleWithParams<T[K]>;
2047
- };
1990
+ [x: string]: RegleRuleRawInput<any, any[], any, any> | undefined;
1991
+ }> = { [K in keyof T]: UnwrapRuleWithParams<T[K]> };
2048
1992
  type UnwrapRuleWithParams<T extends RegleRuleRawInput<any, any[], any, any> | undefined> = T extends RegleRuleWithParamsDefinition<infer TValue, infer TParams, infer TAsync, infer TMetadata> ? RegleRuleDefinition<TValue, TParams, TAsync, TMetadata> : T;
2049
1993
  /**
2050
1994
  * Define a rule Metadata definition
@@ -2052,32 +1996,36 @@ type UnwrapRuleWithParams<T extends RegleRuleRawInput<any, any[], any, any> | un
2052
1996
  type RegleRuleMetadataDefinition = RegleRuleMetadataExtended | boolean;
2053
1997
  type DefaultMetadataPropertiesCommon = Pick<ExcludeByType<RegleCommonStatus, Function>, '$invalid' | '$dirty' | '$pending' | '$correct' | '$error'>;
2054
1998
  type DefaultMetadataProperties = DefaultMetadataPropertiesCommon & {
2055
- $rule: Pick<$InternalRegleRuleStatus, '$valid' | '$pending'>;
1999
+ $rule: Pick<$InternalRegleRuleStatus, '$valid' | '$pending'>;
2056
2000
  };
2057
2001
  /**
2058
2002
  * Will be used to consume metadata on related helpers and rule status
2059
2003
  */
2060
2004
  type RegleRuleMetadataConsumer<TValue extends any, TParams extends [...any[]] = never, TMetadata extends RegleRuleMetadataDefinition = boolean> = {
2061
- $value: Maybe<TValue>;
2005
+ $value: Maybe<TValue>;
2062
2006
  } & DefaultMetadataProperties & (TParams extends never ? {} : {
2063
- $params: [...TParams];
2007
+ $params: [...TParams];
2064
2008
  }) & (Exclude<TMetadata, boolean> extends RegleRuleMetadataExtended ? TMetadata extends boolean ? Partial<Omit<Exclude<TMetadata, boolean>, '$valid'>> : Omit<Exclude<TMetadata, boolean>, '$valid'> : {});
2065
2009
  /**
2066
2010
  * Will be used to consume metadata on related helpers and rule status
2067
2011
  */
2068
2012
  type PossibleRegleRuleMetadataConsumer<TValue> = {
2069
- $value: Maybe<TValue>;
2013
+ $value: Maybe<TValue>;
2070
2014
  } & DefaultMetadataProperties & {
2071
- $params?: [...any[]];
2015
+ $params?: [...any[]];
2072
2016
  };
2017
+ /**
2018
+ * @internal
2019
+ */
2020
+
2073
2021
  /**
2074
2022
  * Generic types for a created RegleRule
2075
2023
  */
2076
2024
  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>;
2077
2025
  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'> & {
2078
- message: any;
2079
- active?: any;
2080
- tooltip?: any;
2026
+ message: any;
2027
+ active?: any;
2028
+ tooltip?: any;
2081
2029
  };
2082
2030
  /**
2083
2031
  * Process the type of created rule with `createRule`.
@@ -2088,160 +2036,147 @@ type InferRegleRule<TValue extends any = any, TParams extends any[] = [], TAsync
2088
2036
  type RegleRuleDefinitionProcessor<TValue extends any = any, TParams extends any[] = [], TReturn = any> = (value: Maybe<TValue>, ...params: TParams) => TReturn;
2089
2037
  type RegleRuleDefinitionWithMetadataProcessor<TValue extends any, TMetadata extends RegleRuleMetadataConsumer<TValue, any[]>, TReturn = any> = ((metadata: TMetadata) => TReturn) | TReturn;
2090
2038
  type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions> & {
2091
- $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
2039
+ $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
2092
2040
  }) | ({
2093
- $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
2041
+ $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
2094
2042
  } & CollectionRegleBehaviourOptions);
2095
2043
 
2044
+ //#endregion
2045
+ //#region src/types/rules/rule.init.types.d.ts
2096
2046
  type RegleInitPropertyGetter<TValue, TReturn, TParams extends [...any[]], TMetadata extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue, TParams, TMetadata>) => TReturn);
2097
2047
  /**
2098
2048
  * @argument
2099
2049
  * createRule arguments options
2100
2050
  */
2101
- 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> {
2102
- validator: (value: Maybe<TValue>, ...args: TParams) => TReturn;
2103
- message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2104
- active?: RegleInitPropertyGetter<TValue, boolean, TParams, TMetadata>;
2105
- tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2106
- type?: string;
2107
- async?: TAsync;
2051
+ 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)> {
2052
+ validator: (value: Maybe<TValue>, ...args: TParams) => TReturn;
2053
+ message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2054
+ active?: RegleInitPropertyGetter<TValue, boolean, TParams, TMetadata>;
2055
+ tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2056
+ type?: string;
2057
+ async?: TAsync;
2108
2058
  }
2109
2059
  /**
2110
2060
  * @argument
2111
2061
  * Rule core
2112
2062
  */
2113
2063
  interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync extends boolean = false, TMetadata extends RegleRuleMetadataDefinition = boolean> {
2114
- validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
2115
- message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2116
- active?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2117
- tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2118
- type?: string;
2064
+ validator: (value: Maybe<TValue>, ...args: TParams) => TAsync extends false ? TMetadata : Promise<TMetadata>;
2065
+ message: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2066
+ active?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2067
+ tooltip?: RegleInitPropertyGetter<TValue, string | string[], TParams, TMetadata>;
2068
+ type?: string;
2119
2069
  }
2070
+ /**
2071
+ * @internal
2072
+ * createRule arguments options
2073
+ */
2074
+
2120
2075
  type RegleRuleTypeReturn<TValue, TParams extends [...any[]]> = {
2121
- value: TValue;
2122
- params: [...TParams];
2076
+ value: TValue;
2077
+ params: [...TParams];
2123
2078
  };
2124
2079
 
2080
+ //#endregion
2081
+ //#region src/core/defaultValidators.d.ts
2125
2082
  interface CommonComparisonOptions {
2126
- /**
2127
- * Change the behaviour of the rule to check only if the value is equal in addition to be strictly superior or inferior
2128
- * @default true
2129
- */
2130
- allowEqual?: boolean;
2083
+ /**
2084
+ * Change the behaviour of the rule to check only if the value is equal in addition to be strictly superior or inferior
2085
+ * @default true
2086
+ */
2087
+ allowEqual?: boolean;
2131
2088
  }
2132
2089
  interface CommonAlphaOptions {
2133
- /**
2134
- * Allow symbols in alphabetical-like rules (like "_")
2135
- * @default true
2136
- */
2137
- allowSymbols?: boolean;
2090
+ /**
2091
+ * Allow symbols in alphabetical-like rules (like "_")
2092
+ * @default true
2093
+ */
2094
+ allowSymbols?: boolean;
2138
2095
  }
2139
2096
  type DefaultValidators = {
2140
- alpha: RegleRuleWithParamsDefinition<string, [options?: CommonAlphaOptions | undefined]>;
2141
- alphaNum: RegleRuleWithParamsDefinition<string | number, [options?: CommonAlphaOptions | undefined]>;
2142
- between: RegleRuleWithParamsDefinition<number, [min: Maybe<number>, max: Maybe<number>]>;
2143
- boolean: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2144
- checked: RegleRuleDefinition<boolean, [], false, boolean, boolean>;
2145
- contains: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2146
- date: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<Date>, unknown>;
2147
- dateAfter: RegleRuleWithParamsDefinition<string | Date, [
2148
- after: Maybe<string | Date>,
2149
- options?: CommonComparisonOptions
2150
- ], false, true | {
2151
- $valid: false;
2152
- error: 'date-not-after';
2153
- } | {
2154
- $valid: false;
2155
- error: 'value-or-parameter-not-a-date';
2156
- }>;
2157
- dateBefore: RegleRuleWithParamsDefinition<string | Date, [
2158
- before: Maybe<string | Date>,
2159
- options?: CommonComparisonOptions
2160
- ], false, true | {
2161
- $valid: false;
2162
- error: 'date-not-before';
2163
- } | {
2164
- $valid: false;
2165
- error: 'value-or-parameter-not-a-date';
2166
- }>;
2167
- dateBetween: RegleRuleWithParamsDefinition<string | Date, [
2168
- before: Maybe<string | Date>,
2169
- after: Maybe<string | Date>,
2170
- options?: CommonComparisonOptions
2171
- ], false, boolean>;
2172
- decimal: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2173
- email: RegleRuleDefinition<string, [], false, boolean, string>;
2174
- endsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2175
- exactLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
2176
- count: number
2177
- ], false, boolean>;
2178
- exactValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean>;
2179
- hexadecimal: RegleRuleDefinition<string, [], false, boolean, string>;
2180
- integer: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2181
- ipv4Address: RegleRuleDefinition<string, [], false, boolean, string>;
2182
- literal: RegleRuleDefinition<string | number, [literal: string | number], false, boolean, string | number>;
2183
- macAddress: RegleRuleWithParamsDefinition<string, [separator?: string | undefined], false, boolean>;
2184
- maxLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
2185
- count: number,
2186
- options?: CommonComparisonOptions
2187
- ], false, boolean>;
2188
- maxValue: RegleRuleWithParamsDefinition<number, [count: number, options?: CommonComparisonOptions], false, boolean>;
2189
- minLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [
2190
- count: number,
2191
- options?: CommonComparisonOptions
2192
- ], false, boolean>;
2193
- minValue: RegleRuleWithParamsDefinition<number, [count: number, options?: CommonComparisonOptions], false, boolean>;
2194
- nativeEnum: RegleRuleDefinition<string | number, [enumLike: EnumLike], false, boolean, string | number>;
2195
- number: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2196
- numeric: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2197
- oneOf: RegleRuleDefinition<string | number, [options: (string | number)[]], false, boolean, string | number>;
2198
- regex: RegleRuleWithParamsDefinition<string, [regexp: RegExp], false, boolean>;
2199
- required: RegleRuleDefinition<unknown, []>;
2200
- sameAs: RegleRuleWithParamsDefinition<unknown, [target: unknown, otherName?: string], false, boolean>;
2201
- string: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2202
- type: RegleRuleDefinition<unknown, [], false, boolean, unknown, unknown>;
2203
- startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2204
- url: RegleRuleDefinition<string, [], false, boolean, string>;
2205
- };
2206
-
2097
+ alpha: RegleRuleWithParamsDefinition<string, [options?: CommonAlphaOptions | undefined]>;
2098
+ alphaNum: RegleRuleWithParamsDefinition<string | number, [options?: CommonAlphaOptions | undefined]>;
2099
+ between: RegleRuleWithParamsDefinition<number, [min: Maybe<number>, max: Maybe<number>]>;
2100
+ boolean: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2101
+ checked: RegleRuleDefinition<boolean, [], false, boolean, boolean>;
2102
+ contains: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2103
+ date: RegleRuleDefinition<unknown, [], false, boolean, MaybeInput<Date>, unknown>;
2104
+ dateAfter: RegleRuleWithParamsDefinition<string | Date, [after: Maybe<string | Date>, options?: CommonComparisonOptions], false, true | {
2105
+ $valid: false;
2106
+ error: 'date-not-after';
2107
+ } | {
2108
+ $valid: false;
2109
+ error: 'value-or-parameter-not-a-date';
2110
+ }>;
2111
+ dateBefore: RegleRuleWithParamsDefinition<string | Date, [before: Maybe<string | Date>, options?: CommonComparisonOptions], false, true | {
2112
+ $valid: false;
2113
+ error: 'date-not-before';
2114
+ } | {
2115
+ $valid: false;
2116
+ error: 'value-or-parameter-not-a-date';
2117
+ }>;
2118
+ dateBetween: RegleRuleWithParamsDefinition<string | Date, [before: Maybe<string | Date>, after: Maybe<string | Date>, options?: CommonComparisonOptions], false, boolean>;
2119
+ decimal: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2120
+ email: RegleRuleDefinition<string, [], false, boolean, string>;
2121
+ endsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2122
+ exactLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number], false, boolean>;
2123
+ exactValue: RegleRuleWithParamsDefinition<number, [count: number], false, boolean>;
2124
+ hexadecimal: RegleRuleDefinition<string, [], false, boolean, string>;
2125
+ integer: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2126
+ ipv4Address: RegleRuleDefinition<string, [], false, boolean, string>;
2127
+ literal: RegleRuleDefinition<string | number, [literal: string | number], false, boolean, string | number>;
2128
+ macAddress: RegleRuleWithParamsDefinition<string, [separator?: string | undefined], false, boolean>;
2129
+ maxLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number, options?: CommonComparisonOptions], false, boolean>;
2130
+ maxValue: RegleRuleWithParamsDefinition<number, [count: number, options?: CommonComparisonOptions], false, boolean>;
2131
+ minLength: RegleRuleWithParamsDefinition<string | any[] | Record<PropertyKey, any>, [count: number, options?: CommonComparisonOptions], false, boolean>;
2132
+ minValue: RegleRuleWithParamsDefinition<number, [count: number, options?: CommonComparisonOptions], false, boolean>;
2133
+ nativeEnum: RegleRuleDefinition<string | number, [enumLike: EnumLike], false, boolean, string | number>;
2134
+ number: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2135
+ numeric: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
2136
+ oneOf: RegleRuleDefinition<string | number, [options: (string | number)[]], false, boolean, string | number>;
2137
+ regex: RegleRuleWithParamsDefinition<string, [regexp: RegExp], false, boolean>;
2138
+ required: RegleRuleDefinition<unknown, []>;
2139
+ sameAs: RegleRuleWithParamsDefinition<unknown, [target: unknown, otherName?: string], false, boolean>;
2140
+ string: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
2141
+ type: RegleRuleDefinition<unknown, [], false, boolean, unknown, unknown>;
2142
+ startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
2143
+ url: RegleRuleDefinition<string, [], false, boolean, string>;
2144
+ };
2145
+
2146
+ //#endregion
2147
+ //#region src/types/rules/rule.custom.types.d.ts
2207
2148
  type CustomRulesDeclarationTree = {
2208
- [x: string]: RegleRuleRawInput<any, any[], boolean, any> | undefined;
2209
- };
2210
- type DefaultValidatorsTree = {
2211
- [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined;
2149
+ [x: string]: RegleRuleRawInput<any, any[], boolean, any> | undefined;
2212
2150
  };
2151
+ type DefaultValidatorsTree = { [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined };
2213
2152
  type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
2214
2153
 
2154
+ //#endregion
2155
+ //#region src/types/rules/rule.declaration.types.d.ts
2215
2156
  /**
2216
2157
  * @public
2217
2158
  */
2218
- type ReglePartialRuleTree<TForm extends Record<string, any> = Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = {
2219
- [TKey in keyof TForm]?: RegleFormPropertyType<TForm[TKey], TCustomRules>;
2220
- };
2159
+ type ReglePartialRuleTree<TForm extends Record<string, any> = Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = { [TKey in keyof TForm]?: RegleFormPropertyType<TForm[TKey], TCustomRules> };
2221
2160
  /**
2222
2161
  * @public
2223
2162
  */
2224
- type RegleRuleTree<TForm extends Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = {
2225
- [TKey in keyof TForm]: RegleFormPropertyType<TForm[TKey], TCustomRules>;
2226
- };
2163
+ type RegleRuleTree<TForm extends Record<string, any>, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = { [TKey in keyof TForm]: RegleFormPropertyType<TForm[TKey], TCustomRules> };
2227
2164
  /**
2228
2165
  * @public
2229
2166
  */
2230
2167
  type RegleUnknownRulesTree = {
2231
- [x: string]: RegleRuleDecl | RegleCollectionRuleDecl | RegleUnknownRulesTree;
2168
+ [x: string]: RegleRuleDecl | RegleCollectionRuleDecl | RegleUnknownRulesTree;
2232
2169
  };
2233
2170
  /**
2234
2171
  * @public
2235
2172
  */
2236
- 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> = {
2237
- [TKey in keyof JoinDiscriminatedUnions<TState>]?: RegleFormPropertyType<JoinDiscriminatedUnions<TState>[TKey], TCustom extends Partial<AllRulesDeclarations> ? TCustom : {}>;
2238
- };
2173
+ 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 : {}> };
2239
2174
  /**
2240
2175
  * @internal
2241
2176
  * @reference {@link ReglePartialRuleTree}
2242
2177
  */
2243
2178
  type $InternalReglePartialRuleTree = {
2244
- [x: string]: $InternalFormPropertyTypes;
2179
+ [x: string]: $InternalFormPropertyTypes;
2245
2180
  };
2246
2181
  /**
2247
2182
  * @public
@@ -2256,9 +2191,7 @@ type $InternalFormPropertyTypes = $InternalRegleRuleDecl | $InternalRegleCollect
2256
2191
  * @public
2257
2192
  * Rule tree for a form property
2258
2193
  */
2259
- type RegleRuleDecl<TValue extends any = any, TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>, TOptions extends Record<string, unknown> = FieldRegleBehaviourOptions> = TOptions & {
2260
- [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];
2261
- };
2194
+ 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] };
2262
2195
  /**
2263
2196
  * @internal
2264
2197
  * @reference {@link RegleRuleDecl}
@@ -2268,15 +2201,15 @@ type $InternalRegleRuleDecl = FieldRegleBehaviourOptions & CollectionRegleBehavi
2268
2201
  * @public
2269
2202
  */
2270
2203
  type RegleCollectionRuleDeclKeyProperty = {
2271
- $key?: PropertyKey;
2204
+ $key?: PropertyKey;
2272
2205
  };
2273
2206
  /**
2274
2207
  * @public
2275
2208
  */
2276
2209
  type RegleCollectionRuleDecl<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = ({
2277
- $each?: RegleCollectionEachRules<TValue, TCustomRules>;
2210
+ $each?: RegleCollectionEachRules<TValue, TCustomRules>;
2278
2211
  } & RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions>) | ({
2279
- $each?: RegleCollectionEachRules<TValue, TCustomRules>;
2212
+ $each?: RegleCollectionEachRules<TValue, TCustomRules>;
2280
2213
  } & CollectionRegleBehaviourOptions);
2281
2214
  /** @public */
2282
2215
  type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>, RegleCollectionRuleDeclKeyProperty>;
@@ -2285,93 +2218,89 @@ type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRu
2285
2218
  * @reference {@link RegleCollectionRuleDecl}
2286
2219
  */
2287
2220
  type $InternalRegleCollectionRuleDecl = $InternalRegleRuleDecl & {
2288
- $each?: MaybeGetter<$InternalFormPropertyTypes & RegleCollectionRuleDeclKeyProperty, any>;
2221
+ $each?: MaybeGetter<$InternalFormPropertyTypes & RegleCollectionRuleDeclKeyProperty, any>;
2289
2222
  };
2290
2223
  /**
2291
2224
  * @public
2292
2225
  */
2293
2226
  type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean> = (value: Maybe<TValue>, ...args: UnwrapRegleUniversalParams<TParams>) => TReturn;
2227
+ /**
2228
+ * @internal
2229
+ */
2230
+
2294
2231
  /**
2295
2232
  * @public
2296
2233
  * Regroup inline and registered rules
2297
2234
  * */
2298
- 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>;
2235
+ 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>;
2299
2236
 
2300
- type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = {
2301
- readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false>;
2302
- };
2303
- type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = {
2304
- readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true>;
2305
- };
2237
+ //#endregion
2238
+ //#region src/types/rules/rule.errors.types.d.ts
2239
+ type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false> };
2240
+ type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
2306
2241
  type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TExternal extends false ? RegleCollectionErrors<U> : RegleExternalCollectionErrors<U> : string[] : NonNullable<TState> extends Date | File ? string[] : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState> : RegleExternalErrorTree<TState> : string[];
2307
2242
  type RegleCollectionErrors<TState extends Record<string, any>> = {
2308
- readonly $self: string[];
2309
- readonly $each: RegleValidationErrors<TState, false>[];
2243
+ readonly $self: string[];
2244
+ readonly $each: RegleValidationErrors<TState, false>[];
2310
2245
  };
2311
2246
  type RegleExternalCollectionErrors<TState extends Record<string, any>> = {
2312
- readonly $self?: string[];
2313
- readonly $each?: RegleValidationErrors<TState, true>[];
2247
+ readonly $self?: string[];
2248
+ readonly $each?: RegleValidationErrors<TState, true>[];
2314
2249
  };
2315
2250
  /** @internal */
2316
2251
  type $InternalRegleCollectionErrors = {
2317
- readonly $self?: string[];
2318
- readonly $each?: $InternalRegleErrors[];
2252
+ readonly $self?: string[];
2253
+ readonly $each?: $InternalRegleErrors[];
2319
2254
  };
2320
2255
  type $InternalRegleErrorTree = {
2321
- [x: string]: $InternalRegleErrors;
2256
+ [x: string]: $InternalRegleErrors;
2322
2257
  };
2323
2258
  /**
2324
2259
  * @internal
2325
2260
  */
2326
2261
  type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
2327
2262
 
2263
+ //#endregion
2264
+ //#region src/types/rules/rule.status.types.d.ts
2328
2265
  /**
2329
2266
  * @public
2330
2267
  */
2331
2268
  type RegleRoot<TState extends Record<string, any> = {}, TRules extends ReglePartialRuleTree<TState> = Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = never, TShortcuts extends RegleShortcutDefinition = {}> = MaybeVariantStatus<TState, TRules, TShortcuts> & ([TValidationGroups] extends [never] ? {} : {
2332
- /**
2333
- * Collection of validation groups used declared with the `validationGroups` modifier
2334
- */
2335
- $groups: {
2336
- readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput;
2337
- };
2269
+ /**
2270
+ * Collection of validation groups used declared with the `validationGroups` modifier
2271
+ */
2272
+ $groups: { readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput };
2338
2273
  });
2339
2274
  /**
2340
2275
  * @public
2341
2276
  */
2342
2277
  type RegleStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = RegleCommonStatus<TState> & {
2343
- /** 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. */
2344
- readonly $fields: {
2345
- readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends 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>;
2346
- } & {
2347
- readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends 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>;
2348
- };
2349
- /**
2350
- * Collection of all the error messages, collected for all children properties and nested forms.
2351
- *
2352
- * Only contains errors from properties where $dirty equals true. */
2353
- readonly $errors: RegleErrorTree<TState>;
2354
- /** Collection of all the error messages, collected for all children properties. */
2355
- readonly $silentErrors: RegleErrorTree<TState>;
2356
- /** 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). */
2357
- $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
2358
- /** 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). */
2359
- $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, TRules>>;
2360
- } & ([TShortcuts['nested']] extends [never] ? {} : {
2361
- [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]>;
2362
- });
2278
+ /** 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. */
2279
+ readonly $fields: { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends 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 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> };
2280
+ /**
2281
+ * Collection of all the error messages, collected for all children properties and nested forms.
2282
+ *
2283
+ * Only contains errors from properties where $dirty equals true. */
2284
+ readonly $errors: RegleErrorTree<TState>;
2285
+ /** Collection of all the error messages, collected for all children properties. */
2286
+ readonly $silentErrors: RegleErrorTree<TState>;
2287
+ /** 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). */
2288
+ $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
2289
+ /** 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). */
2290
+ $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, TRules>>;
2291
+ } & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
2363
2292
  /**
2364
2293
  * @internal
2365
2294
  * @reference {@link RegleStatus}
2366
2295
  */
2367
2296
  interface $InternalRegleStatus extends $InternalRegleCommonStatus {
2368
- $fields: {
2369
- [x: string]: $InternalRegleStatusType;
2370
- };
2371
- readonly $errors: Record<string, $InternalRegleErrors>;
2372
- readonly $silentErrors: Record<string, $InternalRegleErrors>;
2373
- $extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
2374
- $validate: () => Promise<$InternalRegleResult>;
2297
+ $fields: {
2298
+ [x: string]: $InternalRegleStatusType;
2299
+ };
2300
+ readonly $errors: Record<string, $InternalRegleErrors>;
2301
+ readonly $silentErrors: Record<string, $InternalRegleErrors>;
2302
+ $extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
2303
+ $validate: () => Promise<$InternalRegleResult>;
2375
2304
  }
2376
2305
  /**
2377
2306
  * @public
@@ -2386,254 +2315,252 @@ type $InternalRegleStatusType = $InternalRegleCollectionStatus | $InternalRegleS
2386
2315
  * @public
2387
2316
  */
2388
2317
  type RegleFieldStatus<TState extends any = any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = never> = Omit<RegleCommonStatus<TState>, '$value' | '$silentValue'> & {
2389
- /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2390
- $value: MaybeOutput<UnwrapNestedRefs<TState>>;
2391
- /** $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. */
2392
- $silentValue: MaybeOutput<UnwrapNestedRefs<TState>>;
2393
- /** Collection of all the error messages, collected for all children properties and nested forms.
2394
- *
2395
- * Only contains errors from properties where $dirty equals true. */
2396
- readonly $errors: string[];
2397
- /** Collection of all the error messages, collected for all children properties and nested forms. */
2398
- readonly $silentErrors: string[];
2399
- /** Stores external errors of the current field */
2400
- readonly $externalErrors: string[];
2401
- /** Stores active tooltips messages of the current field */
2402
- readonly $tooltips: string[];
2403
- /** Represents the inactive status. Is true when this state have empty rules */
2404
- readonly $inactive: boolean;
2405
- /** 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). */
2406
- $extractDirtyFields: (filterNullishValues?: boolean) => MaybeOutput<TState>;
2407
- /** 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). */
2408
- $validate: () => Promise<RegleResult<TState, TRules>>;
2409
- /** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
2410
- readonly $rules: IsEmptyObject<TRules> extends true ? {
2411
- readonly [x: string]: RegleRuleStatus<TState, any[], any>;
2412
- } : {
2413
- 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 : any>;
2414
- };
2415
- } & ([TShortcuts['fields']] extends [never] ? {} : {
2416
- [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]>;
2417
- });
2318
+ /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2319
+ $value: MaybeOutput<UnwrapNestedRefs<TState>>;
2320
+ /** $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. */
2321
+ $silentValue: MaybeOutput<UnwrapNestedRefs<TState>>;
2322
+ /** Collection of all the error messages, collected for all children properties and nested forms.
2323
+ *
2324
+ * Only contains errors from properties where $dirty equals true. */
2325
+ readonly $errors: string[];
2326
+ /** Collection of all the error messages, collected for all children properties and nested forms. */
2327
+ readonly $silentErrors: string[];
2328
+ /** Stores external errors of the current field */
2329
+ readonly $externalErrors: string[];
2330
+ /** Stores active tooltips messages of the current field */
2331
+ readonly $tooltips: string[];
2332
+ /** Represents the inactive status. Is true when this state have empty rules */
2333
+ readonly $inactive: boolean;
2334
+ /** 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). */
2335
+ $extractDirtyFields: (filterNullishValues?: boolean) => MaybeOutput<TState>;
2336
+ /** 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). */
2337
+ $validate: () => Promise<RegleResult<TState, TRules>>;
2338
+ /** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
2339
+ readonly $rules: IsEmptyObject<TRules> extends true ? {
2340
+ readonly [x: string]: RegleRuleStatus<TState, any[], any>;
2341
+ } : { 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 : any> };
2342
+ } & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
2418
2343
  /**
2419
2344
  * @internal
2420
2345
  * @reference {@link RegleFieldStatus}
2421
2346
  */
2422
2347
  interface $InternalRegleFieldStatus extends $InternalRegleCommonStatus {
2423
- $value: any;
2424
- $silentValue: any;
2425
- readonly $rules: Record<string, $InternalRegleRuleStatus>;
2426
- readonly $externalErrors?: string[];
2427
- readonly $errors: string[];
2428
- readonly $tooltips: string[];
2429
- readonly $inactive: boolean;
2430
- readonly $silentErrors: string[];
2431
- $extractDirtyFields: (filterNullishValues?: boolean) => any;
2432
- $validate: () => Promise<$InternalRegleResult>;
2348
+ $value: any;
2349
+ $silentValue: any;
2350
+ readonly $rules: Record<string, $InternalRegleRuleStatus>;
2351
+ readonly $externalErrors?: string[];
2352
+ readonly $errors: string[];
2353
+ readonly $tooltips: string[];
2354
+ readonly $inactive: boolean;
2355
+ readonly $silentErrors: string[];
2356
+ $extractDirtyFields: (filterNullishValues?: boolean) => any;
2357
+ $validate: () => Promise<$InternalRegleResult>;
2433
2358
  }
2434
2359
  /**
2435
2360
  * @public
2436
2361
  */
2437
2362
  interface RegleCommonStatus<TValue = any> {
2438
- /** Indicates whether the field is invalid. It becomes true if any associated rules return false. */
2439
- readonly $invalid: boolean;
2440
- /**
2441
- * This is not the opposite of `$invalid`. Correct is meant to display UI validation report.
2442
- *
2443
- * This will be `true` only if:
2444
- * - The field have at least one active rule
2445
- * - Is dirty and not empty
2446
- * - Passes validation
2447
- */
2448
- readonly $correct: boolean;
2449
- /** Indicates whether a field has been validated or interacted with by the user at least once. It's typically used to determine if a message should be displayed to the user. You can change this flag manually using the $touch and $reset methods. The $dirty flag is considered true if the current model has been touched or if all its children are dirty.*/
2450
- readonly $dirty: boolean;
2451
- /** Similar to $dirty, with one exception. The $anyDirty flag is considered true if given model was touched or any of its children are $anyDirty which means at least one descendant is $dirty. */
2452
- readonly $anyDirty: boolean;
2453
- /** Indicates whether a field has been touched and if the value is different than the initial one.
2454
- * On nested elements and collections, it's true only if all its children are also `$edited`.
2455
- * Use `$anyEdited` to check for any edited children
2456
- */
2457
- readonly $edited: boolean;
2458
- /** Similar to $edited, with one exception. The $anyEdited flag is considered true if given model was edited or any of its children are $anyEdited which means at least one descendant is $edited. */
2459
- readonly $anyEdited: boolean;
2460
- /** Indicates if any async rule for the field is currently running. Always false for synchronous rules. */
2461
- readonly $pending: boolean;
2462
- /** Convenience flag to easily decide if a message should be displayed. Equivalent to $dirty && !$pending && $invalid. */
2463
- readonly $error: boolean;
2464
- /** Indicates whether the field is ready for submission. Equivalent to !$invalid && !$pending. */
2465
- readonly $ready: boolean;
2466
- /** Return the current key name of the field. */
2467
- readonly $name: string;
2468
- /** Id used to track collections items */
2469
- $id?: string;
2470
- /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2471
- $value: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
2472
- /** $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. */
2473
- $silentValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
2474
- /** Marks the field and all nested properties as $dirty. */
2475
- $touch(): void;
2476
- /**
2477
- * Reset the validation status to a pristine state while keeping the current form state.
2478
- * Resets the `$dirty` state on all nested properties of a form.
2479
- * Rerun rules if `$lazy` is false
2480
- */
2481
- $reset(): void;
2482
- $reset(options?: ResetOptions<TValue>): void;
2483
- /** Clears the $externalErrors state back to an empty object. */
2484
- $clearExternalErrors(): void;
2363
+ /** Indicates whether the field is invalid. It becomes true if any associated rules return false. */
2364
+ readonly $invalid: boolean;
2365
+ /**
2366
+ * This is not the opposite of `$invalid`. Correct is meant to display UI validation report.
2367
+ *
2368
+ * This will be `true` only if:
2369
+ * - The field have at least one active rule
2370
+ * - Is dirty and not empty
2371
+ * - Passes validation
2372
+ */
2373
+ readonly $correct: boolean;
2374
+ /** Indicates whether a field has been validated or interacted with by the user at least once. It's typically used to determine if a message should be displayed to the user. You can change this flag manually using the $touch and $reset methods. The $dirty flag is considered true if the current model has been touched or if all its children are dirty.*/
2375
+ readonly $dirty: boolean;
2376
+ /** Similar to $dirty, with one exception. The $anyDirty flag is considered true if given model was touched or any of its children are $anyDirty which means at least one descendant is $dirty. */
2377
+ readonly $anyDirty: boolean;
2378
+ /** Indicates whether a field has been touched and if the value is different than the initial one.
2379
+ * On nested elements and collections, it's true only if all its children are also `$edited`.
2380
+ * Use `$anyEdited` to check for any edited children
2381
+ */
2382
+ readonly $edited: boolean;
2383
+ /** Similar to $edited, with one exception. The $anyEdited flag is considered true if given model was edited or any of its children are $anyEdited which means at least one descendant is $edited. */
2384
+ readonly $anyEdited: boolean;
2385
+ /** Indicates if any async rule for the field is currently running. Always false for synchronous rules. */
2386
+ readonly $pending: boolean;
2387
+ /** Convenience flag to easily decide if a message should be displayed. Equivalent to $dirty && !$pending && $invalid. */
2388
+ readonly $error: boolean;
2389
+ /** Indicates whether the field is ready for submission. Equivalent to !$invalid && !$pending. */
2390
+ readonly $ready: boolean;
2391
+ /** Return the current key name of the field. */
2392
+ readonly $name: string;
2393
+ /** Id used to track collections items */
2394
+ $id?: string;
2395
+ /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2396
+ $value: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
2397
+ /** $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. */
2398
+ $silentValue: JoinDiscriminatedUnions<UnwrapNestedRefs<TValue>>;
2399
+ /** Marks the field and all nested properties as $dirty. */
2400
+ $touch(): void;
2401
+ /**
2402
+ * Reset the validation status to a pristine state while keeping the current form state.
2403
+ * Resets the `$dirty` state on all nested properties of a form.
2404
+ * Rerun rules if `$lazy` is false
2405
+ */
2406
+ $reset(): void;
2407
+ $reset(options?: ResetOptions<TValue>): void;
2408
+ /** Clears the $externalErrors state back to an empty object. */
2409
+ $clearExternalErrors(): void;
2485
2410
  }
2486
2411
  interface $InternalRegleCommonStatus extends Omit<RegleCommonStatus, '$touch' | '$reset'> {
2487
- $touch(runCommit?: boolean, withConditions?: boolean): void;
2488
- $unwatch(): void;
2489
- $watch(): void;
2490
- $reset(options?: ResetOptions<any>, fromParent?: boolean): void;
2412
+ $touch(runCommit?: boolean, withConditions?: boolean): void;
2413
+ $unwatch(): void;
2414
+ $watch(): void;
2415
+ $reset(options?: ResetOptions<any>, fromParent?: boolean): void;
2491
2416
  }
2492
2417
  /**
2493
2418
  * @public
2494
2419
  */
2495
2420
  type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata extends RegleRuleMetadataDefinition = boolean> = {
2496
- /** The name of the rule type. */
2497
- readonly $type: string;
2498
- /** Returns the computed error message or messages for the current rule. */
2499
- readonly $message: string | string[];
2500
- /** Stores the current rule tooltip or tooltips */
2501
- readonly $tooltip: string | string[];
2502
- /** Indicates whether or not the rule is enabled (for rules like requiredIf) */
2503
- readonly $active: boolean;
2504
- /** Indicates the state of validation for this validator. */
2505
- readonly $valid: boolean;
2506
- /** If the rule is async, indicates if it's currently pending. Always false if it's synchronous. */
2507
- readonly $pending: boolean;
2508
- /** Returns the current path of the rule (used internally for tracking) */
2509
- readonly $path: string;
2510
- /** Contains the metadata returned by the validator function. */
2511
- readonly $metadata: TMetadata extends boolean ? TMetadata : Omit<TMetadata, '$valid'>;
2512
- /** Run the rule validator and compute its properties like $message and $active */
2513
- $parse(): Promise<boolean>;
2514
- /** Reset the $valid, $metadata and $pending states */
2515
- $reset(): void;
2516
- /** Returns the original rule validator function. */
2517
- $validator: ((value: IsUnknown$1<TValue> extends true ? any : MaybeInput<TValue>, ...args: any[]) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>) & ((value: IsUnknown$1<TValue> extends true ? any : TValue, ...args: [TParams] extends [never[]] ? [] : [unknown[]] extends [TParams] ? any[] : TParams) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>);
2421
+ /** The name of the rule type. */
2422
+ readonly $type: string;
2423
+ /** Returns the computed error message or messages for the current rule. */
2424
+ readonly $message: string | string[];
2425
+ /** Stores the current rule tooltip or tooltips */
2426
+ readonly $tooltip: string | string[];
2427
+ /** Indicates whether or not the rule is enabled (for rules like requiredIf) */
2428
+ readonly $active: boolean;
2429
+ /** Indicates the state of validation for this validator. */
2430
+ readonly $valid: boolean;
2431
+ /** If the rule is async, indicates if it's currently pending. Always false if it's synchronous. */
2432
+ readonly $pending: boolean;
2433
+ /** Returns the current path of the rule (used internally for tracking) */
2434
+ readonly $path: string;
2435
+ /** Contains the metadata returned by the validator function. */
2436
+ readonly $metadata: TMetadata extends boolean ? TMetadata : Omit<TMetadata, '$valid'>;
2437
+ /** Run the rule validator and compute its properties like $message and $active */
2438
+ $parse(): Promise<boolean>;
2439
+ /** Reset the $valid, $metadata and $pending states */
2440
+ $reset(): void;
2441
+ /** Returns the original rule validator function. */
2442
+ $validator: ((value: IsUnknown$1<TValue> extends true ? any : MaybeInput<TValue>, ...args: any[]) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>) & ((value: IsUnknown$1<TValue> extends true ? any : TValue, ...args: [TParams] extends [never[]] ? [] : [unknown[]] extends [TParams] ? any[] : TParams) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>);
2518
2443
  } & ([TParams] extends [never[]] ? {} : [unknown[]] extends [TParams] ? {
2519
- readonly $params?: any[];
2444
+ readonly $params?: any[];
2520
2445
  } : {
2521
- readonly $params: [...TParams];
2446
+ readonly $params: [...TParams];
2522
2447
  });
2523
2448
  /**
2524
2449
  * @internal
2525
2450
  * @reference {@link RegleRuleStatus}
2526
2451
  */
2527
2452
  interface $InternalRegleRuleStatus {
2528
- $type: string;
2529
- $message: string | string[];
2530
- $tooltip: string | string[];
2531
- $active: boolean;
2532
- $valid: boolean;
2533
- $pending: boolean;
2534
- $path: string;
2535
- $externalErrors?: string[];
2536
- $params?: any[];
2537
- $metadata: any;
2538
- $haveAsync: boolean;
2539
- $validating: boolean;
2540
- $fieldDirty: boolean;
2541
- $fieldInvalid: boolean;
2542
- $fieldPending: boolean;
2543
- $fieldCorrect: boolean;
2544
- $fieldError: boolean;
2545
- $maybePending: boolean;
2546
- $validator(value: any, ...args: any[]): RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>;
2547
- $parse(): Promise<boolean>;
2548
- $reset(): void;
2549
- $unwatch(): void;
2550
- $watch(): void;
2453
+ $type: string;
2454
+ $message: string | string[];
2455
+ $tooltip: string | string[];
2456
+ $active: boolean;
2457
+ $valid: boolean;
2458
+ $pending: boolean;
2459
+ $path: string;
2460
+ $externalErrors?: string[];
2461
+ $params?: any[];
2462
+ $metadata: any;
2463
+ $haveAsync: boolean;
2464
+ $validating: boolean;
2465
+ $fieldDirty: boolean;
2466
+ $fieldInvalid: boolean;
2467
+ $fieldPending: boolean;
2468
+ $fieldCorrect: boolean;
2469
+ $fieldError: boolean;
2470
+ $maybePending: boolean;
2471
+ $validator(value: any, ...args: any[]): RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>;
2472
+ $parse(): Promise<boolean>;
2473
+ $reset(): void;
2474
+ $unwatch(): void;
2475
+ $watch(): void;
2551
2476
  }
2552
2477
  /**
2553
2478
  * @public
2554
2479
  */
2555
2480
  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'> & {
2556
- /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2557
- $value: MaybeOutput<TState>;
2558
- /** $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. */
2559
- $silentValue: MaybeOutput<TState>;
2560
- /** 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. */
2561
- readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number, TShortcuts>>;
2562
- /** 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. */
2563
- readonly $self: RegleFieldStatus<TState, TFieldRule, TShortcuts>;
2564
- /** Collection of all the error messages, collected for all children properties and nested forms.
2565
- *
2566
- * Only contains errors from properties where $dirty equals true. */
2567
- readonly $errors: RegleCollectionErrors<TState>;
2568
- /** Collection of all the error messages, collected for all children properties and nested forms. */
2569
- readonly $silentErrors: RegleCollectionErrors<TState>;
2570
- /** 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). */
2571
- $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
2572
- /** 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). */
2573
- $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, JoinDiscriminatedUnions<TRules>>>;
2574
- } & ([TShortcuts['collections']] extends [never] ? {} : {
2575
- [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]>;
2576
- });
2481
+ /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2482
+ $value: MaybeOutput<TState>;
2483
+ /** $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. */
2484
+ $silentValue: MaybeOutput<TState>;
2485
+ /** 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. */
2486
+ readonly $each: Array<InferRegleStatusType<NonNullable<TRules>, NonNullable<TState>, number, TShortcuts>>;
2487
+ /** 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. */
2488
+ readonly $self: RegleFieldStatus<TState, TFieldRule, TShortcuts>;
2489
+ /** Collection of all the error messages, collected for all children properties and nested forms.
2490
+ *
2491
+ * Only contains errors from properties where $dirty equals true. */
2492
+ readonly $errors: RegleCollectionErrors<TState>;
2493
+ /** Collection of all the error messages, collected for all children properties and nested forms. */
2494
+ readonly $silentErrors: RegleCollectionErrors<TState>;
2495
+ /** 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). */
2496
+ $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
2497
+ /** 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). */
2498
+ $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, JoinDiscriminatedUnions<TRules>>>;
2499
+ } & ([TShortcuts['collections']] extends [never] ? {} : { [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]> });
2577
2500
  /**
2578
2501
  * @internal
2579
2502
  * @reference {@link RegleCollectionStatus}
2580
2503
  */
2581
2504
  interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fields' | '$errors' | '$silentErrors'> {
2582
- readonly $self: $InternalRegleFieldStatus;
2583
- readonly $each: Array<$InternalRegleStatusType>;
2584
- readonly $errors: $InternalRegleCollectionErrors;
2585
- readonly $silentErrors: $InternalRegleCollectionErrors;
2586
- readonly $externalErrors?: string[];
2587
- $extractDirtyFields: (filterNullishValues?: boolean) => any[];
2588
- $validate: () => Promise<$InternalRegleResult>;
2505
+ readonly $self: $InternalRegleFieldStatus;
2506
+ readonly $each: Array<$InternalRegleStatusType>;
2507
+ readonly $errors: $InternalRegleCollectionErrors;
2508
+ readonly $silentErrors: $InternalRegleCollectionErrors;
2509
+ readonly $externalErrors?: string[];
2510
+ $extractDirtyFields: (filterNullishValues?: boolean) => any[];
2511
+ $validate: () => Promise<$InternalRegleResult>;
2589
2512
  }
2590
2513
 
2514
+ //#endregion
2515
+ //#region src/types/rules/compatibility.rules.d.ts
2591
2516
  interface SuperCompatibleRegle {
2592
- r$: SuperCompatibleRegleRoot;
2517
+ r$: SuperCompatibleRegleRoot;
2593
2518
  }
2594
2519
  /** Supports both core Regle and schemas Regle for Zod/Valibot */
2595
2520
  type SuperCompatibleRegleRoot = SuperCompatibleRegleStatus & {
2596
- $groups?: {
2597
- [x: string]: RegleValidationGroupOutput;
2598
- };
2599
- $validate: () => Promise<SuperCompatibleRegleResult>;
2521
+ $groups?: {
2522
+ [x: string]: RegleValidationGroupOutput;
2523
+ };
2524
+ $validate: () => Promise<SuperCompatibleRegleResult>;
2600
2525
  };
2601
2526
  type SuperCompatibleRegleResult = $InternalRegleResult;
2602
2527
  interface SuperCompatibleRegleStatus extends SuperCompatibleRegleCommonStatus {
2603
- $fields: {
2604
- [x: string]: unknown;
2605
- };
2606
- readonly $errors: Record<string, RegleValidationErrors<any, false>>;
2607
- readonly $silentErrors: Record<string, RegleValidationErrors<any, false>>;
2608
- $extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
2609
- $validate?: () => Promise<SuperCompatibleRegleResult>;
2528
+ $fields: {
2529
+ [x: string]: unknown;
2530
+ };
2531
+ readonly $errors: Record<string, RegleValidationErrors<any, false>>;
2532
+ readonly $silentErrors: Record<string, RegleValidationErrors<any, false>>;
2533
+ $extractDirtyFields: (filterNullishValues?: boolean) => Record<string, any>;
2534
+ $validate?: () => Promise<SuperCompatibleRegleResult>;
2610
2535
  }
2611
2536
  type SuperCompatibleRegleRuleStatus = Omit<$InternalRegleRuleStatus, '$haveAsync' | '$validating' | '$fieldDirty' | '$fieldInvalid' | '$fieldPending' | '$fieldCorrect' | '$fieldError' | '$unwatch' | '$watch' | '$maybePending'>;
2612
2537
  type SuperCompatibleRegleCommonStatus = Omit<RegleCommonStatus, '$pending'> & {
2613
- $pending?: boolean;
2538
+ $pending?: boolean;
2614
2539
  };
2615
2540
  interface SuperCompatibleRegleFieldStatus extends SuperCompatibleRegleCommonStatus {
2616
- $value: any;
2617
- $silentValue: any;
2618
- readonly $rules: Record<string, SuperCompatibleRegleRuleStatus>;
2619
- readonly $externalErrors?: string[];
2620
- readonly $errors: string[];
2621
- readonly $inactive: boolean;
2622
- readonly $silentErrors: string[];
2623
- $extractDirtyFields: (filterNullishValues?: boolean) => any;
2624
- $validate?: () => Promise<SuperCompatibleRegleResult>;
2541
+ $value: any;
2542
+ $silentValue: any;
2543
+ readonly $rules: Record<string, SuperCompatibleRegleRuleStatus>;
2544
+ readonly $externalErrors?: string[];
2545
+ readonly $errors: string[];
2546
+ readonly $inactive: boolean;
2547
+ readonly $silentErrors: string[];
2548
+ $extractDirtyFields: (filterNullishValues?: boolean) => any;
2549
+ $validate?: () => Promise<SuperCompatibleRegleResult>;
2625
2550
  }
2626
2551
  interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegleStatus, '$fields' | '$errors' | '$silentErrors'> {
2627
- readonly $self: SuperCompatibleRegleFieldStatus;
2628
- readonly $each: Array<SuperCompatibleRegleStatus | SuperCompatibleRegleFieldStatus>;
2629
- readonly $errors: SuperCompatibleRegleCollectionErrors;
2630
- readonly $silentErrors: SuperCompatibleRegleCollectionErrors;
2631
- readonly $externalErrors?: string[];
2632
- $extractDirtyFields: (filterNullishValues?: boolean) => any[];
2633
- $validate?: () => Promise<SuperCompatibleRegleResult>;
2552
+ readonly $self: SuperCompatibleRegleFieldStatus;
2553
+ readonly $each: Array<SuperCompatibleRegleStatus | SuperCompatibleRegleFieldStatus>;
2554
+ readonly $errors: SuperCompatibleRegleCollectionErrors;
2555
+ readonly $silentErrors: SuperCompatibleRegleCollectionErrors;
2556
+ readonly $externalErrors?: string[];
2557
+ $extractDirtyFields: (filterNullishValues?: boolean) => any[];
2558
+ $validate?: () => Promise<SuperCompatibleRegleResult>;
2634
2559
  }
2635
2560
  type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
2636
2561
 
2562
+ //#endregion
2563
+ //#region src/core/createRule/createRule.d.ts
2637
2564
  /**
2638
2565
  * Create a typed custom rule that can be used like default rules.
2639
2566
  * It can also be declared in the global options
@@ -2665,14 +2592,23 @@ type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
2665
2592
  *
2666
2593
  * Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
2667
2594
  */
2668
- 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>;
2595
+ 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>;
2669
2596
 
2597
+ //#endregion
2598
+ //#region src/core/createRule/unwrapRuleParameters.d.ts
2670
2599
  /**
2671
2600
  * Returns a clean list of parameters
2672
2601
  * Removing Ref and executing function to return the unwrapped value
2673
2602
  */
2674
2603
  declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
2675
2604
 
2605
+ //#endregion
2606
+ //#region src/core/defineRegleConfig.d.ts
2607
+ /**
2608
+ * Returns a clean list of parameters
2609
+ * Removing Ref and executing function to return the unwrapped value
2610
+ */
2611
+
2676
2612
  /**
2677
2613
  * Define a global regle configuration, where you can:
2678
2614
  * - Customize built-in rules messages
@@ -2685,13 +2621,17 @@ declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrG
2685
2621
  * - a `useRegle` composable that can typecheck your custom rules
2686
2622
  * - an `inferRules` helper that can typecheck your custom rules
2687
2623
  */
2688
- declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TCustomRules>, TCustomRules extends Partial<AllRulesDeclarations>>({ rules, modifiers, shortcuts, }: {
2689
- rules?: () => TCustomRules;
2690
- modifiers?: RegleBehaviourOptions;
2691
- shortcuts?: TShortcuts;
2624
+ declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TCustomRules>, TCustomRules extends Partial<AllRulesDeclarations>>({
2625
+ rules,
2626
+ modifiers,
2627
+ shortcuts
2628
+ }: {
2629
+ rules?: () => TCustomRules;
2630
+ modifiers?: RegleBehaviourOptions;
2631
+ shortcuts?: TShortcuts;
2692
2632
  }): {
2693
- useRegle: useRegleFn<TCustomRules, TShortcuts>;
2694
- inferRules: inferRulesFn<TCustomRules>;
2633
+ useRegle: useRegleFn<TCustomRules, TShortcuts>;
2634
+ inferRules: inferRulesFn<TCustomRules>;
2695
2635
  };
2696
2636
  /**
2697
2637
  * Extend an already created custom `useRegle` (as the first parameter)
@@ -2701,121 +2641,119 @@ declare function defineRegleConfig<TShortcuts extends RegleShortcutDefinition<TC
2701
2641
  * - a `useRegle` composable that can typecheck your custom rules
2702
2642
  * - an `inferRules` helper that can typecheck your custom rules
2703
2643
  */
2704
- declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDeclarations>, TRootShortcuts extends RegleShortcutDefinition<{}>, TShortcuts extends RegleShortcutDefinition<Merge<TRootCustomRules, TCustomRules>>, TCustomRules extends Partial<AllRulesDeclarations>>(regle: useRegleFn<TRootCustomRules, TRootShortcuts>, { rules, modifiers, shortcuts, }: {
2705
- rules?: () => TCustomRules;
2706
- modifiers?: RegleBehaviourOptions;
2707
- shortcuts?: TShortcuts;
2644
+ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDeclarations>, TRootShortcuts extends RegleShortcutDefinition<{}>, TShortcuts extends RegleShortcutDefinition<Merge<TRootCustomRules, TCustomRules>>, TCustomRules extends Partial<AllRulesDeclarations>>(regle: useRegleFn<TRootCustomRules, TRootShortcuts>, {
2645
+ rules,
2646
+ modifiers,
2647
+ shortcuts
2648
+ }: {
2649
+ rules?: () => TCustomRules;
2650
+ modifiers?: RegleBehaviourOptions;
2651
+ shortcuts?: TShortcuts;
2708
2652
  }): {
2709
- useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
2710
- inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
2711
- };
2712
-
2713
- type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue = {
2714
- [K in keyof TRegles]: TRegles[K]['$value'];
2715
- }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
2716
- /** Map of merged Regle instances and their properties */
2717
- readonly $instances: {
2718
- [K in keyof TRegles]: TRegles[K];
2719
- };
2720
- /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2721
- $value: TValue;
2722
- /** $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. */
2723
- $silentValue: TValue;
2724
- /** Collection of all the error messages, collected for all children properties and nested forms.
2725
- *
2726
- * Only contains errors from properties where $dirty equals true. */
2727
- readonly $errors: {
2728
- [K in keyof TRegles]: TRegles[K]['$errors'];
2729
- };
2730
- /** Collection of all the error messages, collected for all children properties. */
2731
- readonly $silentErrors: {
2732
- [K in keyof TRegles]: TRegles[K]['$silentErrors'];
2733
- };
2734
- /** 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). */
2735
- $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TValue>;
2736
- /** 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). */
2737
- $validate: () => Promise<MergedReglesResult<TRegles>>;
2653
+ useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
2654
+ inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
2655
+ };
2656
+
2657
+ //#endregion
2658
+ //#region src/core/mergeRegles.d.ts
2659
+ type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue = { [K in keyof TRegles]: TRegles[K]['$value'] }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
2660
+ /** Map of merged Regle instances and their properties */
2661
+ readonly $instances: { [K in keyof TRegles]: TRegles[K] };
2662
+ /** A reference to the original validated model. It can be used to bind your form with v-model.*/
2663
+ $value: TValue;
2664
+ /** $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. */
2665
+ $silentValue: TValue;
2666
+ /** Collection of all the error messages, collected for all children properties and nested forms.
2667
+ *
2668
+ * Only contains errors from properties where $dirty equals true. */
2669
+ readonly $errors: { [K in keyof TRegles]: TRegles[K]['$errors'] };
2670
+ /** Collection of all the error messages, collected for all children properties. */
2671
+ readonly $silentErrors: { [K in keyof TRegles]: TRegles[K]['$silentErrors'] };
2672
+ /** 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). */
2673
+ $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TValue>;
2674
+ /** 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). */
2675
+ $validate: () => Promise<MergedReglesResult<TRegles>>;
2738
2676
  };
2739
2677
  type MergedScopedRegles<TValue extends Record<string, unknown>[] = Record<string, unknown>[]> = Omit<MergedRegles<Record<string, SuperCompatibleRegleRoot>, TValue>, '$instances' | '$errors' | '$silentErrors' | '$value' | '$silentValue' | '$validate'> & {
2740
- /** Array of scoped Regles instances */
2741
- readonly $instances: SuperCompatibleRegleRoot[];
2742
- /** Collection of all registered Regles instances values */
2743
- readonly $value: TValue;
2744
- /** Collection of all registered Regles instances errors */
2745
- readonly $errors: RegleValidationErrors<Record<string, unknown>>[];
2746
- /** Collection of all registered Regles instances silent errors */
2747
- readonly $silentErrors: RegleValidationErrors<Record<string, unknown>>[];
2748
- /** 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). */
2749
- $validate: () => Promise<{
2750
- valid: boolean;
2751
- data: TValue;
2752
- }>;
2678
+ /** Array of scoped Regles instances */
2679
+ readonly $instances: SuperCompatibleRegleRoot[];
2680
+ /** Collection of all registered Regles instances values */
2681
+ readonly $value: TValue;
2682
+ /** Collection of all registered Regles instances errors */
2683
+ readonly $errors: RegleValidationErrors<Record<string, unknown>>[];
2684
+ /** Collection of all registered Regles instances silent errors */
2685
+ readonly $silentErrors: RegleValidationErrors<Record<string, unknown>>[];
2686
+ /** 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). */
2687
+ $validate: () => Promise<{
2688
+ valid: boolean;
2689
+ data: TValue;
2690
+ }>;
2753
2691
  };
2754
2692
  type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>> = {
2693
+ valid: false;
2694
+ data: { [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2755
2695
  valid: false;
2756
- data: {
2757
- [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2758
- valid: false;
2759
- }>['data'];
2760
- };
2696
+ }>['data'] };
2761
2697
  } | {
2698
+ valid: true;
2699
+ data: { [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2762
2700
  valid: true;
2763
- data: {
2764
- [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2765
- valid: true;
2766
- }>['data'];
2767
- };
2701
+ }>['data'] };
2768
2702
  };
2769
2703
  declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
2770
2704
 
2705
+ //#endregion
2706
+ //#region src/core/createScopedUseRegle/useCollectScope.d.ts
2771
2707
  type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
2772
- r$: MergedRegles<{
2773
- [K in keyof TValue]: RegleRoot<TValue[K]>;
2774
- }>;
2708
+ r$: MergedRegles<{ [K in keyof TValue]: RegleRoot<TValue[K]> }>;
2775
2709
  } : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
2776
- r$: MergedScopedRegles<TValue>;
2710
+ r$: MergedScopedRegles<TValue>;
2777
2711
  };
2778
2712
 
2713
+ //#endregion
2714
+ //#region src/core/createScopedUseRegle/useScopedRegle.d.ts
2779
2715
  type UseScopedRegleOptions<TAsRecord extends boolean> = {
2780
- namespace?: MaybeRefOrGetter<string>;
2716
+ namespace?: MaybeRefOrGetter<string>;
2781
2717
  } & (TAsRecord extends true ? {
2782
- scopeKey: string;
2718
+ scopeKey: string;
2783
2719
  } : {});
2784
2720
 
2721
+ //#endregion
2722
+ //#region src/core/createScopedUseRegle/createScopedUseRegle.d.ts
2785
2723
  type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsRecord extends boolean> = {
2786
- /**
2787
- * Inject a global configuration to the exported composables to keep your translations and typings
2788
- */
2789
- customUseRegle?: TCustomRegle;
2790
- /**
2791
- * Store the collected instances externally
2792
- */
2793
- customStore?: Ref<ScopedInstancesRecordLike>;
2794
- /**
2795
- * Set the
2796
- */
2797
- asRecord?: TAsRecord;
2798
- };
2799
- declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any> = useRegleFn<Partial<AllRulesDeclarations>>, TAsRecord extends boolean = false, TReturnedRegle extends useRegleFn<any, any, any, any> = TCustomRegle extends useRegleFn<infer A, infer B> ? useRegleFn<A, B, {
2800
- dispose: () => void;
2801
- register: () => void;
2724
+ /**
2725
+ * Inject a global configuration to the exported composables to keep your translations and typings
2726
+ */
2727
+ customUseRegle?: TCustomRegle;
2728
+ /**
2729
+ * Store the collected instances externally
2730
+ */
2731
+ customStore?: Ref<ScopedInstancesRecordLike>;
2732
+ /**
2733
+ * Set the
2734
+ */
2735
+ asRecord?: TAsRecord;
2736
+ };
2737
+ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any> = useRegleFn<Partial<AllRulesDeclarations>>, TAsRecord extends boolean = false, TReturnedRegle extends useRegleFn<any, any, any, any> = (TCustomRegle extends useRegleFn<infer A, infer B> ? useRegleFn<A, B, {
2738
+ dispose: () => void;
2739
+ register: () => void;
2802
2740
  }, UseScopedRegleOptions<TAsRecord>> : useRegleFn<Partial<AllRulesDeclarations>, any, {
2803
- dispose: () => void;
2804
- register: () => void;
2805
- }, UseScopedRegleOptions<TAsRecord>>>(options?: CreateScopedUseRegleOptions<TCustomRegle, TAsRecord>): {
2806
- useScopedRegle: TReturnedRegle;
2807
- useCollectScope: useCollectScopeFn<TAsRecord>;
2741
+ dispose: () => void;
2742
+ register: () => void;
2743
+ }, UseScopedRegleOptions<TAsRecord>>)>(options?: CreateScopedUseRegleOptions<TCustomRegle, TAsRecord>): {
2744
+ useScopedRegle: TReturnedRegle;
2745
+ useCollectScope: useCollectScopeFn<TAsRecord>;
2808
2746
  };
2809
- declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue.MaybeRefOrGetter<string>) => {
2747
+ declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue1.MaybeRefOrGetter<string>) => {
2810
2748
  r$: MergedScopedRegles<TValue>;
2811
- };
2812
- declare const useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
2749
+ }, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
2813
2750
  dispose: () => void;
2814
2751
  register: () => void;
2815
- }, {
2816
- namespace?: vue.MaybeRefOrGetter<string>;
2817
- }>;
2818
-
2752
+ }, {
2753
+ namespace?: vue1.MaybeRefOrGetter<string>;
2754
+ }>;
2755
+ //#endregion
2756
+ //#region src/core/createVariant.d.ts
2819
2757
  /**
2820
2758
  * Declare variations of state that depends on one value
2821
2759
  *
@@ -2847,12 +2785,10 @@ declare function createVariant<TForm extends Record<string, any>, TDiscriminant
2847
2785
  * ```
2848
2786
  */
2849
2787
  declare function narrowVariant<TRoot extends {
2850
- [x: string]: unknown;
2851
- }, const TKey extends keyof TRoot, const TValue extends LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
2852
- $value: infer V;
2853
- } ? V : unknown>(root: TRoot, discriminantKey: TKey, discriminantValue: TValue): root is Extract<TRoot, {
2854
- [K in TKey]: RegleFieldStatus<TValue, any, any> | RegleFieldStatus<MaybeInput<TValue>, any, any>;
2855
- }>;
2788
+ [x: string]: unknown;
2789
+ }, const TKey extends keyof TRoot, const TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
2790
+ $value: infer V;
2791
+ } ? V : unknown)>(root: TRoot, discriminantKey: TKey, discriminantValue: TValue): root is Extract<TRoot, { [K in TKey]: RegleFieldStatus<TValue, any, any> | RegleFieldStatus<MaybeInput<TValue>, any, any> }>;
2856
2792
  /**
2857
2793
  * Narrow a nested variant root to a reactive reference
2858
2794
  *
@@ -2862,12 +2798,12 @@ declare function narrowVariant<TRoot extends {
2862
2798
  * </script>
2863
2799
  * ```
2864
2800
  */
2865
- 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 {
2866
- $value: infer V;
2867
- } ? V : unknown>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<Extract<TRoot['$fields'], {
2868
- [K in TKey]: RegleFieldStatus<TValue, any, any>;
2869
- }> | undefined>;
2801
+ 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 {
2802
+ $value: infer V;
2803
+ } ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<Extract<TRoot['$fields'], { [K in TKey]: RegleFieldStatus<TValue, any, any> }> | undefined>;
2870
2804
 
2805
+ //#endregion
2806
+ //#region src/core/refineRules.d.ts
2871
2807
  /**
2872
2808
  * Helper method to wrap an raw rules object
2873
2809
  *
@@ -2895,4 +2831,5 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
2895
2831
  */
2896
2832
  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>;
2897
2833
 
2898
- export { type $InternalRegleStatus, type AllRulesDeclarations, type CommonAlphaOptions, type CommonComparisonOptions, type CreateScopedUseRegleOptions, type DeepMaybeRef, type DeepReactiveState, type DefaultValidatorsTree, type FormRuleDeclaration, 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 PrimitiveTypes, type Regle, type RegleBehaviourOptions, type RegleCollectionErrors, type RegleCollectionRuleDecl, type RegleCollectionRuleDefinition, type RegleCollectionStatus, type RegleCommonStatus, type RegleComputedRules, type RegleEnforceCustomRequiredRules, type RegleEnforceRequiredRules, type RegleErrorTree, type RegleExternalCollectionErrors, type RegleExternalErrorTree, type RegleFieldStatus, type RegleFormPropertyType, type RegleInternalRuleDefs, 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, useScopedRegle, variantToRef };
2834
+ //#endregion
2835
+ export { $InternalRegleStatus, AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, CreateScopedUseRegleOptions, DeepMaybeRef, DeepReactiveState, DefaultValidatorsTree, FormRuleDeclaration, HaveAnyRequiredProps, InferInput, InferRegleRoot, InferRegleRule, InferRegleRules, InferRegleShortcuts, InferRegleStatusType, InferSafeOutput, InlineRuleDeclaration, InternalRuleType, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeInput, MaybeOutput, MaybeReadonly, MaybeVariantStatus, MergedRegles, MergedScopedRegles, NarrowVariant, NoInferLegacy, PrimitiveTypes, Regle, RegleBehaviourOptions, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleComputedRules, RegleEnforceCustomRequiredRules, RegleEnforceRequiredRules, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalErrorTree, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialRuleTree, RegleResult, RegleRoot, RegleRuleCore, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleDefinitionWithMetadataProcessor, RegleRuleInit, RegleRuleMetadataConsumer, RegleRuleMetadataDefinition, RegleRuleMetadataExtended, RegleRuleRaw, RegleRuleStatus, RegleRuleTypeReturn, RegleRuleWithParamsDefinition, RegleShortcutDefinition, RegleSingleField, RegleStatus, RegleUniversalParams, RegleUnknownRulesTree, RegleValidationErrors, RegleValidationGroupEntry, RegleValidationGroupOutput, RegleRuleTree as RegleValidationTree, ResolvedRegleBehaviourOptions, ScopedInstancesRecord, ScopedInstancesRecordLike, SuperCompatibleRegle, SuperCompatibleRegleCollectionErrors, SuperCompatibleRegleCollectionStatus, SuperCompatibleRegleFieldStatus, SuperCompatibleRegleResult, SuperCompatibleRegleRoot, SuperCompatibleRegleRuleStatus, SuperCompatibleRegleStatus, Unwrap, UnwrapRegleUniversalParams, UnwrapRuleWithParams, UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, useCollectScopeFn, useRegle, useRegleFn, useRootStorage, useScopedRegle, variantToRef };