notform 1.0.7 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,422 +1,2230 @@
1
- import * as vue0 from "vue";
2
- import { ComputedRef, MaybeRefOrGetter, Ref, VNodeChild, useAttrs } from "vue";
3
1
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
- import { PartialDeep, Paths as Paths$1 } from "type-fest";
2
+ import { MaybeRefOrGetter } from "vue";
5
3
 
6
- //#region src/types/shared.d.ts
4
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/primitive.d.ts
7
5
  /**
8
- * Validation execution strategy.
9
- * - `lazy`: Validates on blur or submission.
10
- * - `eager`: Validates on blur, then on every change if an error exists.
11
- */
12
- type ValidationMode = 'lazy' | 'eager';
6
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
7
+
8
+ @category Type
9
+ */
10
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
11
+ //#endregion
12
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-any.d.ts
13
+ /**
14
+ Returns a boolean for whether the given type is `any`.
15
+
16
+ @link https://stackoverflow.com/a/49928360/1490091
17
+
18
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
19
+
20
+ @example
21
+ ```
22
+ import type {IsAny} from 'type-fest';
23
+
24
+ const typedObject = {a: 1, b: 2} as const;
25
+ const anyObject: any = {a: 1, b: 2};
26
+
27
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
28
+ return object[key];
29
+ }
30
+
31
+ const typedA = get(typedObject, 'a');
32
+ //=> 1
33
+
34
+ const anyA = get(anyObject, 'a');
35
+ //=> any
36
+ ```
37
+
38
+ @category Type Guard
39
+ @category Utilities
40
+ */
41
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
42
+ //#endregion
43
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-optional-key-of.d.ts
44
+ /**
45
+ Returns a boolean for whether the given key is an optional key of type.
46
+
47
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
48
+
49
+ @example
50
+ ```
51
+ import type {IsOptionalKeyOf} from 'type-fest';
52
+
53
+ type User = {
54
+ name: string;
55
+ surname: string;
56
+
57
+ luckyNumber?: number;
58
+ };
59
+
60
+ type Admin = {
61
+ name: string;
62
+ surname?: string;
63
+ };
64
+
65
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
66
+ //=> true
67
+
68
+ type T2 = IsOptionalKeyOf<User, 'name'>;
69
+ //=> false
70
+
71
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
72
+ //=> boolean
73
+
74
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
75
+ //=> false
76
+
77
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
78
+ //=> boolean
79
+ ```
80
+
81
+ @category Type Guard
82
+ @category Utilities
83
+ */
84
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
85
+ //#endregion
86
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/optional-keys-of.d.ts
87
+ /**
88
+ Extract all optional keys from the given type.
89
+
90
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
91
+
92
+ @example
93
+ ```
94
+ import type {OptionalKeysOf, Except} from 'type-fest';
95
+
96
+ type User = {
97
+ name: string;
98
+ surname: string;
99
+
100
+ luckyNumber?: number;
101
+ };
102
+
103
+ const REMOVE_FIELD = Symbol('remove field symbol');
104
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
105
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
106
+ };
107
+
108
+ const update1: UpdateOperation<User> = {
109
+ name: 'Alice',
110
+ };
111
+
112
+ const update2: UpdateOperation<User> = {
113
+ name: 'Bob',
114
+ luckyNumber: REMOVE_FIELD,
115
+ };
116
+ ```
117
+
118
+ @category Utilities
119
+ */
120
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
121
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
122
+ : never;
123
+ //#endregion
124
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/required-keys-of.d.ts
125
+ /**
126
+ Extract all required keys from the given type.
127
+
128
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
129
+
130
+ @example
131
+ ```
132
+ import type {RequiredKeysOf} from 'type-fest';
133
+
134
+ declare function createValidation<
135
+ Entity extends object,
136
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
137
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
138
+
139
+ type User = {
140
+ name: string;
141
+ surname: string;
142
+ luckyNumber?: number;
143
+ };
144
+
145
+ const validator1 = createValidation<User>('name', value => value.length < 25);
146
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
147
+
148
+ // @ts-expect-error
149
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
150
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
151
+ ```
152
+
153
+ @category Utilities
154
+ */
155
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
156
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
157
+ //#endregion
158
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-never.d.ts
159
+ /**
160
+ Returns a boolean for whether the given type is `never`.
161
+
162
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
163
+ @link https://stackoverflow.com/a/53984913/10292952
164
+ @link https://www.zhenghao.io/posts/ts-never
165
+
166
+ Useful in type utilities, such as checking if something does not occur.
167
+
168
+ @example
169
+ ```
170
+ import type {IsNever, And} from 'type-fest';
171
+
172
+ type A = IsNever<never>;
173
+ //=> true
174
+
175
+ type B = IsNever<any>;
176
+ //=> false
177
+
178
+ type C = IsNever<unknown>;
179
+ //=> false
180
+
181
+ type D = IsNever<never[]>;
182
+ //=> false
183
+
184
+ type E = IsNever<object>;
185
+ //=> false
186
+
187
+ type F = IsNever<string>;
188
+ //=> false
189
+ ```
190
+
191
+ @example
192
+ ```
193
+ import type {IsNever} from 'type-fest';
194
+
195
+ type IsTrue<T> = T extends true ? true : false;
196
+
197
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
198
+ type A = IsTrue<never>;
199
+ //=> never
200
+
201
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
202
+ type IsTrueFixed<T> =
203
+ IsNever<T> extends true ? false : T extends true ? true : false;
204
+
205
+ type B = IsTrueFixed<never>;
206
+ //=> false
207
+ ```
208
+
209
+ @category Type Guard
210
+ @category Utilities
211
+ */
212
+ type IsNever<T> = [T] extends [never] ? true : false;
213
+ //#endregion
214
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/if.d.ts
215
+ /**
216
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
217
+
218
+ Use-cases:
219
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
220
+
221
+ Note:
222
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
223
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
224
+
225
+ @example
226
+ ```
227
+ import type {If} from 'type-fest';
228
+
229
+ type A = If<true, 'yes', 'no'>;
230
+ //=> 'yes'
231
+
232
+ type B = If<false, 'yes', 'no'>;
233
+ //=> 'no'
234
+
235
+ type C = If<boolean, 'yes', 'no'>;
236
+ //=> 'yes' | 'no'
237
+
238
+ type D = If<any, 'yes', 'no'>;
239
+ //=> 'yes' | 'no'
240
+
241
+ type E = If<never, 'yes', 'no'>;
242
+ //=> 'no'
243
+ ```
244
+
245
+ @example
246
+ ```
247
+ import type {If, IsAny, IsNever} from 'type-fest';
248
+
249
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
250
+ //=> 'not any'
251
+
252
+ type B = If<IsNever<never>, 'is never', 'not never'>;
253
+ //=> 'is never'
254
+ ```
255
+
256
+ @example
257
+ ```
258
+ import type {If, IsEqual} from 'type-fest';
259
+
260
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
261
+
262
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
263
+ //=> 'equal'
264
+
265
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
266
+ //=> 'not equal'
267
+ ```
268
+
269
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
270
+
271
+ @example
272
+ ```
273
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
274
+
275
+ type HundredZeroes = StringRepeat<'0', 100>;
276
+
277
+ // The following implementation is not tail recursive
278
+ type Includes<S extends string, Char extends string> =
279
+ S extends `${infer First}${infer Rest}`
280
+ ? If<IsEqual<First, Char>,
281
+ 'found',
282
+ Includes<Rest, Char>>
283
+ : 'not found';
284
+
285
+ // Hence, instantiations with long strings will fail
286
+ // @ts-expect-error
287
+ type Fails = Includes<HundredZeroes, '1'>;
288
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289
+ // Error: Type instantiation is excessively deep and possibly infinite.
290
+
291
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
292
+ type IncludesWithoutIf<S extends string, Char extends string> =
293
+ S extends `${infer First}${infer Rest}`
294
+ ? IsEqual<First, Char> extends true
295
+ ? 'found'
296
+ : IncludesWithoutIf<Rest, Char>
297
+ : 'not found';
298
+
299
+ // Now, instantiations with long strings will work
300
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
301
+ //=> 'not found'
302
+ ```
303
+
304
+ @category Type Guard
305
+ @category Utilities
306
+ */
307
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
308
+ //#endregion
309
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/unknown-array.d.ts
310
+ /**
311
+ Represents an array with `unknown` value.
312
+
313
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
314
+
315
+ @example
316
+ ```
317
+ import type {UnknownArray} from 'type-fest';
318
+
319
+ type IsArray<T> = T extends UnknownArray ? true : false;
320
+
321
+ type A = IsArray<['foo']>;
322
+ //=> true
323
+
324
+ type B = IsArray<readonly number[]>;
325
+ //=> true
326
+
327
+ type C = IsArray<string>;
328
+ //=> false
329
+ ```
330
+
331
+ @category Type
332
+ @category Array
333
+ */
334
+ type UnknownArray = readonly unknown[];
335
+ //#endregion
336
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/type.d.ts
337
+ /**
338
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
339
+ */
340
+ type BuiltIns = Primitive | void | Date | RegExp;
341
+ /**
342
+ Matches non-recursive types.
343
+ */
344
+ type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown) | Promise<unknown>;
345
+ /**
346
+ Matches maps, sets, or arrays.
347
+ */
348
+ type MapsSetsOrArrays = ReadonlyMap<unknown, unknown> | WeakMap<WeakKey, unknown> | ReadonlySet<unknown> | WeakSet<WeakKey> | UnknownArray;
349
+ /**
350
+ Test if the given function has multiple call signatures.
351
+
352
+ Needed to handle the case of a single call signature with properties.
353
+
354
+ Multiple call signatures cannot currently be supported due to a TypeScript limitation.
355
+ @see https://github.com/microsoft/TypeScript/issues/29732
356
+ */
357
+ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
358
+ (...arguments_: infer A): unknown;
359
+ (...arguments_: infer B): unknown;
360
+ } ? B extends A ? A extends B ? false : true : true : false;
361
+ /**
362
+ Returns a boolean for whether A is false.
363
+
364
+ @example
365
+ ```
366
+ type A = Not<true>;
367
+ //=> false
368
+
369
+ type B = Not<false>;
370
+ //=> true
371
+ ```
372
+ */
373
+ type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
374
+ /**
375
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
376
+
377
+ @example
378
+ ```
379
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
380
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
381
+ //=> 'VALID'
382
+
383
+ // When `T` is `any` => Returns `IfAny` branch
384
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
385
+ //=> 'IS_ANY'
386
+
387
+ // When `T` is `never` => Returns `IfNever` branch
388
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
389
+ //=> 'IS_NEVER'
390
+ ```
391
+
392
+ Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
393
+
394
+ @example
395
+ ```ts
396
+ import type {StringRepeat} from 'type-fest';
397
+
398
+ type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
399
+
400
+ // The following implementation is not tail recursive
401
+ type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
402
+
403
+ // Hence, instantiations with long strings will fail
404
+ // @ts-expect-error
405
+ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
406
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407
+ // Error: Type instantiation is excessively deep and possibly infinite.
408
+
409
+ // To fix this, move the recursion into a helper type
410
+ type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
411
+
412
+ type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
413
+
414
+ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
415
+ //=> ''
416
+ ```
417
+ */
418
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
419
+ /**
420
+ Indicates the value of `exactOptionalPropertyTypes` compiler option.
421
+ */
422
+ type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
423
+ //#endregion
424
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/array.d.ts
425
+ /**
426
+ Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
427
+
428
+ @example
429
+ ```
430
+ type A = CollapseRestElement<[string, string, ...number[]]>;
431
+ //=> [string, string, number]
432
+
433
+ type B = CollapseRestElement<[...string[], number, number]>;
434
+ //=> [string, number, number]
435
+
436
+ type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
437
+ //=> [string, string, number | bigint]
438
+
439
+ type D = CollapseRestElement<[string, number]>;
440
+ //=> [string, number]
441
+ ```
442
+
443
+ Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
444
+
445
+ @example
446
+ ```
447
+ // `exactOptionalPropertyTypes` enabled
448
+ type A = CollapseRestElement<[string?, string?, ...number[]]>;
449
+ //=> [string, string, number]
450
+
451
+ // `exactOptionalPropertyTypes` disabled
452
+ type B = CollapseRestElement<[string?, string?, ...number[]]>;
453
+ //=> [string | undefined, string | undefined, number]
454
+ ```
455
+ */
456
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
457
+ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
458
+ ? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
459
+ // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
460
+ ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
461
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
462
+ : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
463
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
464
+ : never; // Should never happen
465
+ //#endregion
466
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/numeric.d.ts
467
+ type _Numeric = number | bigint;
468
+ type Zero = 0 | 0n;
469
+ /**
470
+ Matches the hidden `Infinity` type.
471
+
472
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
473
+
474
+ @see {@link NegativeInfinity}
475
+
476
+ @category Numeric
477
+ */
478
+ // See https://github.com/microsoft/TypeScript/issues/31752
479
+ // eslint-disable-next-line no-loss-of-precision
480
+ type PositiveInfinity = 1e999;
481
+ /**
482
+ Matches the hidden `-Infinity` type.
483
+
484
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
485
+
486
+ @see {@link PositiveInfinity}
487
+
488
+ @category Numeric
489
+ */
490
+ // See https://github.com/microsoft/TypeScript/issues/31752
491
+ // eslint-disable-next-line no-loss-of-precision
492
+ type NegativeInfinity = -1e999;
493
+ /**
494
+ A negative `number`/`bigint` (`-∞ < x < 0`)
495
+
496
+ Use-case: Validating and documenting parameters.
497
+
498
+ @see {@link NegativeInteger}
499
+ @see {@link NonNegative}
500
+
501
+ @category Numeric
502
+ */
503
+ type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
504
+ /**
505
+ Returns a boolean for whether the given number is a negative number.
506
+
507
+ @see {@link Negative}
508
+
509
+ @example
510
+ ```
511
+ import type {IsNegative} from 'type-fest';
512
+
513
+ type ShouldBeFalse = IsNegative<1>;
514
+ type ShouldBeTrue = IsNegative<-1>;
515
+ ```
516
+
517
+ @category Numeric
518
+ */
519
+ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
520
+ //#endregion
521
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tuple-of.d.ts
522
+ /**
523
+ Create a tuple type of the specified length with elements of the specified type.
524
+
525
+ @example
526
+ ```
527
+ import type {TupleOf} from 'type-fest';
528
+
529
+ type RGB = TupleOf<3, number>;
530
+ //=> [number, number, number]
531
+
532
+ type Line = TupleOf<2, {x: number; y: number}>;
533
+ //=> [{x: number; y: number}, {x: number; y: number}]
534
+
535
+ type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
536
+ //=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
537
+ ```
538
+
539
+ @example
540
+ ```
541
+ import type {TupleOf} from 'type-fest';
542
+
543
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
544
+
545
+ type ZeroToFour = Range<0, 5>;
546
+ //=> '0' | '1' | '2' | '3' | '4'
547
+
548
+ type ThreeToEight = Range<3, 9>;
549
+ //=> '5' | '3' | '4' | '6' | '7' | '8'
550
+ ```
551
+
552
+ Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
553
+
554
+ @example
555
+ ```
556
+ import type {TupleOf} from 'type-fest';
557
+
558
+ type StringArray = TupleOf<number, string>;
559
+ //=> string[]
560
+ ```
561
+
562
+ Note: If the type for elements is not specified, it will default to `unknown`.
563
+
564
+ @example
565
+ ```
566
+ import type {TupleOf} from 'type-fest';
567
+
568
+ type UnknownTriplet = TupleOf<3>;
569
+ //=> [unknown, unknown, unknown]
570
+ ```
571
+
572
+ Note: If the specified length is negative, the result will be an empty tuple.
573
+
574
+ @example
575
+ ```
576
+ import type {TupleOf} from 'type-fest';
577
+
578
+ type EmptyTuple = TupleOf<-3, string>;
579
+ //=> []
580
+ ```
581
+
582
+ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
583
+
584
+ @category Array
585
+ */
586
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill, []>, Fill[], []>;
587
+ type _TupleOf<L extends number, Fill, Accumulator extends UnknownArray> = number extends L ? Fill[] : L extends Accumulator['length'] ? Accumulator : _TupleOf<L, Fill, [...Accumulator, Fill]>;
588
+ //#endregion
589
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/string.d.ts
590
+ /**
591
+ Return a string representation of the given string or number.
592
+
593
+ Note: This type is not the return type of the `.toString()` function.
594
+ */
595
+ type ToString<T> = T extends string | number ? `${T}` : never;
596
+ /**
597
+ Converts a numeric string to a number.
598
+
599
+ @example
600
+ ```
601
+ type PositiveInt = StringToNumber<'1234'>;
602
+ //=> 1234
603
+
604
+ type NegativeInt = StringToNumber<'-1234'>;
605
+ //=> -1234
606
+
607
+ type PositiveFloat = StringToNumber<'1234.56'>;
608
+ //=> 1234.56
609
+
610
+ type NegativeFloat = StringToNumber<'-1234.56'>;
611
+ //=> -1234.56
612
+
613
+ type PositiveInfinity = StringToNumber<'Infinity'>;
614
+ //=> Infinity
615
+
616
+ type NegativeInfinity = StringToNumber<'-Infinity'>;
617
+ //=> -Infinity
618
+ ```
619
+
620
+ @category String
621
+ @category Numeric
622
+ @category Template literal
623
+ */
624
+ type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends 'Infinity' ? PositiveInfinity : S extends '-Infinity' ? NegativeInfinity : never;
625
+ /**
626
+ Returns an array of the characters of the string.
627
+
628
+ @example
629
+ ```
630
+ type A = StringToArray<'abcde'>;
631
+ //=> ['a', 'b', 'c', 'd', 'e']
632
+
633
+ type B = StringToArray<string>;
634
+ //=> never
635
+ ```
636
+
637
+ @category String
638
+ */
639
+ type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [...Result, F]> : Result;
640
+ /**
641
+ Returns the length of the given string.
642
+
643
+ @example
644
+ ```
645
+ type A = StringLength<'abcde'>;
646
+ //=> 5
647
+
648
+ type B = StringLength<string>;
649
+ //=> never
650
+ ```
651
+
652
+ @category String
653
+ @category Template literal
654
+ */
655
+ type StringLength<S extends string> = string extends S ? never : StringToArray<S>['length'];
656
+ /**
657
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
658
+
659
+ @example
660
+ ```
661
+ type A = SameLengthPositiveNumericStringGt<'50', '10'>;
662
+ //=> true
663
+
664
+ type B = SameLengthPositiveNumericStringGt<'10', '10'>;
665
+ //=> false
666
+ ```
667
+ */
668
+ type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
669
+ type NumericString = '0123456789';
670
+ /**
671
+ Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
672
+
673
+ @example
674
+ ```
675
+ type A = PositiveNumericStringGt<'500', '1'>;
676
+ //=> true
677
+
678
+ type B = PositiveNumericStringGt<'1', '1'>;
679
+ //=> false
680
+
681
+ type C = PositiveNumericStringGt<'1', '500'>;
682
+ //=> false
683
+ ```
684
+ */
685
+ type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [TupleOf<StringLength<A>, 0>, TupleOf<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain['length'] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
686
+ /**
687
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
688
+
689
+ @example
690
+ ```
691
+ type A = PositiveNumericCharacterGt<'5', '1'>;
692
+ //=> true
693
+
694
+ type B = PositiveNumericCharacterGt<'1', '1'>;
695
+ //=> false
696
+ ```
697
+ */
698
+ type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
699
+ //#endregion
700
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/numeric.d.ts
701
+ /**
702
+ Returns the absolute value of a given value.
703
+
704
+ @example
705
+ ```
706
+ type A = NumberAbsolute<-1>;
707
+ //=> 1
708
+
709
+ type B = NumberAbsolute<1>;
710
+ //=> 1
711
+
712
+ type C = NumberAbsolute<NegativeInfinity>;
713
+ //=> PositiveInfinity
714
+ ```
715
+ */
716
+ type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
717
+ /**
718
+ Check whether the given type is a number or a number string.
719
+
720
+ Supports floating-point as a string.
721
+
722
+ @example
723
+ ```
724
+ type A = IsNumberLike<'1'>;
725
+ //=> true
726
+
727
+ type B = IsNumberLike<'-1.1'>;
728
+ //=> true
729
+
730
+ type C = IsNumberLike<'5e-20'>;
731
+ //=> true
732
+
733
+ type D = IsNumberLike<1>;
734
+ //=> true
735
+
736
+ type E = IsNumberLike<'a'>;
737
+ //=> false
738
+ */
739
+ type IsNumberLike<N> = IfNotAnyOrNever<N, N extends number | `${number}` ? true : false, boolean, false>;
740
+ /**
741
+ Returns the number with reversed sign.
742
+
743
+ @example
744
+ ```
745
+ type A = ReverseSign<-1>;
746
+ //=> 1
747
+
748
+ type B = ReverseSign<1>;
749
+ //=> -1
750
+
751
+ type C = ReverseSign<NegativeInfinity>;
752
+ //=> PositiveInfinity
753
+
754
+ type D = ReverseSign<PositiveInfinity>;
755
+ //=> NegativeInfinity
756
+ ```
757
+ */
758
+ type ReverseSign<N extends number> = // Handle edge cases
759
+ N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends NegativeInfinity ? PositiveInfinity : // Handle negative numbers
760
+ `${N}` extends `-${infer P extends number}` ? P // Handle positive numbers
761
+ : `-${N}` extends `${infer R extends number}` ? R : never;
762
+ //#endregion
763
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/simplify.d.ts
764
+ /**
765
+ 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.
766
+
767
+ @example
768
+ ```
769
+ import type {Simplify} from 'type-fest';
770
+
771
+ type PositionProps = {
772
+ top: number;
773
+ left: number;
774
+ };
775
+
776
+ type SizeProps = {
777
+ width: number;
778
+ height: number;
779
+ };
780
+
781
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
782
+ type Props = Simplify<PositionProps & SizeProps>;
783
+ ```
784
+
785
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
786
+
787
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
788
+
789
+ @example
790
+ ```
791
+ import type {Simplify} from 'type-fest';
792
+
793
+ interface SomeInterface {
794
+ foo: number;
795
+ bar?: string;
796
+ baz: number | undefined;
797
+ }
798
+
799
+ type SomeType = {
800
+ foo: number;
801
+ bar?: string;
802
+ baz: number | undefined;
803
+ };
804
+
805
+ const literal = {foo: 123, bar: 'hello', baz: 456};
806
+ const someType: SomeType = literal;
807
+ const someInterface: SomeInterface = literal;
808
+
809
+ declare function fn(object: Record<string, unknown>): void;
810
+
811
+ fn(literal); // Good: literal object type is sealed
812
+ fn(someType); // Good: type is sealed
813
+ // @ts-expect-error
814
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
815
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
816
+ ```
817
+
818
+ @link https://github.com/microsoft/TypeScript/issues/15300
819
+ @see {@link SimplifyDeep}
820
+ @category Object
821
+ */
822
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
823
+ //#endregion
824
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-equal.d.ts
825
+ /**
826
+ Returns a boolean for whether the two given types are equal.
827
+
828
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
829
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
830
+
831
+ Use-cases:
832
+ - If you want to make a conditional branch based on the result of a comparison of two types.
833
+
834
+ @example
835
+ ```
836
+ import type {IsEqual} from 'type-fest';
837
+
838
+ // This type returns a boolean for whether the given array includes the given item.
839
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
840
+ type Includes<Value extends readonly any[], Item> =
841
+ Value extends readonly [Value[0], ...infer rest]
842
+ ? IsEqual<Value[0], Item> extends true
843
+ ? true
844
+ : Includes<rest, Item>
845
+ : false;
846
+ ```
847
+
848
+ @category Type Guard
849
+ @category Utilities
850
+ */
851
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
852
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
853
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
854
+ //#endregion
855
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/omit-index-signature.d.ts
856
+ /**
857
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
858
+
859
+ This is the counterpart of `PickIndexSignature`.
860
+
861
+ Use-cases:
862
+ - Remove overly permissive signatures from third-party types.
863
+
864
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
865
+
866
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
867
+
868
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
869
+
870
+ ```
871
+ const indexed: Record<string, unknown> = {}; // Allowed
872
+
873
+ // @ts-expect-error
874
+ const keyed: Record<'foo', unknown> = {}; // Error
875
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
876
+ ```
877
+
878
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
879
+
880
+ ```
881
+ type Indexed = {} extends Record<string, unknown>
882
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
883
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
884
+
885
+ type IndexedResult = Indexed;
886
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
887
+
888
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
889
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
890
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
891
+
892
+ type KeyedResult = Keyed;
893
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
894
+ ```
895
+
896
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
897
+
898
+ ```
899
+ type OmitIndexSignature<ObjectType> = {
900
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
901
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
902
+ };
903
+ ```
904
+
905
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
906
+
907
+ ```
908
+ type OmitIndexSignature<ObjectType> = {
909
+ [KeyType in keyof ObjectType
910
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
911
+ as {} extends Record<KeyType, unknown>
912
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
913
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
914
+ ]: ObjectType[KeyType];
915
+ };
916
+ ```
917
+
918
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
919
+
920
+ @example
921
+ ```
922
+ import type {OmitIndexSignature} from 'type-fest';
923
+
924
+ type Example = {
925
+ // These index signatures will be removed.
926
+ [x: string]: any;
927
+ [x: number]: any;
928
+ [x: symbol]: any;
929
+ [x: `head-${string}`]: string;
930
+ [x: `${string}-tail`]: string;
931
+ [x: `head-${string}-tail`]: string;
932
+ [x: `${bigint}`]: string;
933
+ [x: `embedded-${number}`]: string;
934
+
935
+ // These explicitly defined keys will remain.
936
+ foo: 'bar';
937
+ qux?: 'baz';
938
+ };
939
+
940
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
941
+ //=> {foo: 'bar'; qux?: 'baz'}
942
+ ```
943
+
944
+ @see {@link PickIndexSignature}
945
+ @category Object
946
+ */
947
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
948
+ //#endregion
949
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/pick-index-signature.d.ts
950
+ /**
951
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
952
+
953
+ This is the counterpart of `OmitIndexSignature`.
954
+
955
+ @example
956
+ ```
957
+ import type {PickIndexSignature} from 'type-fest';
958
+
959
+ declare const symbolKey: unique symbol;
960
+
961
+ type Example = {
962
+ // These index signatures will remain.
963
+ [x: string]: unknown;
964
+ [x: number]: unknown;
965
+ [x: symbol]: unknown;
966
+ [x: `head-${string}`]: string;
967
+ [x: `${string}-tail`]: string;
968
+ [x: `head-${string}-tail`]: string;
969
+ [x: `${bigint}`]: string;
970
+ [x: `embedded-${number}`]: string;
971
+
972
+ // These explicitly defined keys will be removed.
973
+ ['kebab-case-key']: string;
974
+ [symbolKey]: string;
975
+ foo: 'bar';
976
+ qux?: 'baz';
977
+ };
978
+
979
+ type ExampleIndexSignature = PickIndexSignature<Example>;
980
+ // {
981
+ // [x: string]: unknown;
982
+ // [x: number]: unknown;
983
+ // [x: symbol]: unknown;
984
+ // [x: `head-${string}`]: string;
985
+ // [x: `${string}-tail`]: string;
986
+ // [x: `head-${string}-tail`]: string;
987
+ // [x: `${bigint}`]: string;
988
+ // [x: `embedded-${number}`]: string;
989
+ // }
990
+ ```
991
+
992
+ @see {@link OmitIndexSignature}
993
+ @category Object
994
+ */
995
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
996
+ //#endregion
997
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/merge.d.ts
998
+ // Merges two objects without worrying about index signatures.
999
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
1000
+ /**
1001
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
1002
+
1003
+ This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
1004
+
1005
+ @example
1006
+ ```
1007
+ import type {Merge} from 'type-fest';
1008
+
1009
+ type Foo = {
1010
+ a: string;
1011
+ b: number;
1012
+ };
1013
+
1014
+ type Bar = {
1015
+ a: number; // Conflicts with Foo['a']
1016
+ c: boolean;
1017
+ };
1018
+
1019
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
1020
+ type WithIntersection = (Foo & Bar)['a'];
1021
+ //=> never
1022
+
1023
+ // With `Merge`, `a` is cleanly overridden to `number`.
1024
+ type WithMerge = Merge<Foo, Bar>['a'];
1025
+ //=> number
1026
+ ```
1027
+
1028
+ @example
1029
+ ```
1030
+ import type {Merge} from 'type-fest';
1031
+
1032
+ type Foo = {
1033
+ [x: string]: unknown;
1034
+ [x: number]: unknown;
1035
+ foo: string;
1036
+ bar: symbol;
1037
+ };
1038
+
1039
+ type Bar = {
1040
+ [x: number]: number;
1041
+ [x: symbol]: unknown;
1042
+ bar: Date;
1043
+ baz: boolean;
1044
+ };
1045
+
1046
+ export type FooBar = Merge<Foo, Bar>;
1047
+ //=> {
1048
+ // [x: string]: unknown;
1049
+ // [x: number]: number;
1050
+ // [x: symbol]: unknown;
1051
+ // foo: string;
1052
+ // bar: Date;
1053
+ // baz: boolean;
1054
+ // }
1055
+ ```
1056
+
1057
+ Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
1058
+
1059
+ @see {@link ObjectMerge}
1060
+ @category Object
1061
+ */
1062
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
1063
+ ? Source extends unknown // For distributing `Source`
1064
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
1065
+ : never;
1066
+ // Should never happen
1067
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
1068
+ //#endregion
1069
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/object.d.ts
1070
+ /**
1071
+ Merges user specified options with default options.
1072
+
1073
+ @example
1074
+ ```
1075
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1076
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1077
+ type SpecifiedOptions = {leavesOnly: true};
1078
+
1079
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1080
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
1081
+ ```
1082
+
1083
+ @example
1084
+ ```
1085
+ // Complains if default values are not provided for optional options
1086
+
1087
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1088
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
1089
+ type SpecifiedOptions = {};
1090
+
1091
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1092
+ // ~~~~~~~~~~~~~~~~~~~
1093
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
1094
+ ```
1095
+
1096
+ @example
1097
+ ```
1098
+ // Complains if an option's default type does not conform to the expected type
1099
+
1100
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1101
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
1102
+ type SpecifiedOptions = {};
1103
+
1104
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1105
+ // ~~~~~~~~~~~~~~~~~~~
1106
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1107
+ ```
1108
+
1109
+ @example
1110
+ ```
1111
+ // Complains if an option's specified type does not conform to the expected type
1112
+
1113
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1114
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1115
+ type SpecifiedOptions = {leavesOnly: 'yes'};
1116
+
1117
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1118
+ // ~~~~~~~~~~~~~~~~
1119
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1120
+ ```
1121
+ */
1122
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
1123
+ //#endregion
1124
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/some-extend.d.ts
1125
+ /**
1126
+ @see {@link SomeExtend}
1127
+ */
1128
+ type SomeExtendOptions = {
1129
+ /**
1130
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1131
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1132
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1133
+ @default true
1134
+ @example
1135
+ ```
1136
+ import type {SomeExtend} from 'type-fest';
1137
+ type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
1138
+ //=> false
1139
+ type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
1140
+ //=> true
1141
+ type C = SomeExtend<[1, never], never, {strictNever: true}>;
1142
+ //=> true
1143
+ type D = SomeExtend<[1, never], never, {strictNever: false}>;
1144
+ //=> true
1145
+ type E = SomeExtend<[never], any, {strictNever: true}>;
1146
+ //=> true
1147
+ type F = SomeExtend<[never], any, {strictNever: false}>;
1148
+ //=> true
1149
+ ```
1150
+ */
1151
+ strictNever?: boolean;
1152
+ };
1153
+ type DefaultSomeExtendOptions = {
1154
+ strictNever: true;
1155
+ };
1156
+ /**
1157
+ Returns a boolean for whether some element in an array type extends another type.
1158
+
1159
+ @example
1160
+ ```
1161
+ import type {SomeExtend} from 'type-fest';
1162
+
1163
+ type A = SomeExtend<['1', '2', 3], number>;
1164
+ //=> true
1165
+
1166
+ type B = SomeExtend<[1, 2, 3], string>;
1167
+ //=> false
1168
+
1169
+ type C = SomeExtend<[string, number | string], number>;
1170
+ //=> boolean
1171
+
1172
+ type D = SomeExtend<[true, boolean, true], false>;
1173
+ //=> boolean
1174
+ ```
1175
+
1176
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1177
+
1178
+ ```
1179
+ // @exactOptionalPropertyTypes: true
1180
+ import type {SomeExtend} from 'type-fest';
1181
+
1182
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
1183
+ //=> true
1184
+ ```
1185
+
1186
+ ```
1187
+ // @exactOptionalPropertyTypes: false
1188
+ import type {SomeExtend} from 'type-fest';
1189
+
1190
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
1191
+ //=> boolean
1192
+
1193
+ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
1194
+ //=> true
1195
+ ```
1196
+
1197
+ @see {@link SomeExtendOptions}
1198
+
1199
+ @category Utilities
1200
+ @category Array
1201
+ */
1202
+ type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
1203
+ type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
1204
+ ? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
1205
+ //#endregion
1206
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or-all.d.ts
1207
+ /**
1208
+ Returns a boolean for whether any of the given elements is `true`.
1209
+
1210
+ Use-cases:
1211
+ - Check if at least one condition in a list of booleans is met.
1212
+
1213
+ @example
1214
+ ```
1215
+ import type {OrAll} from 'type-fest';
1216
+
1217
+ type FFT = OrAll<[false, false, true]>;
1218
+ //=> true
1219
+
1220
+ type FFF = OrAll<[false, false, false]>;
1221
+ //=> false
1222
+ ```
1223
+
1224
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
1225
+ For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
1226
+
1227
+ @example
1228
+ ```
1229
+ import type {OrAll} from 'type-fest';
1230
+
1231
+ type A = OrAll<[false, boolean]>;
1232
+ //=> boolean
1233
+
1234
+ type B = OrAll<[true, boolean]>;
1235
+ //=> true
1236
+ ```
1237
+
1238
+ Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
1239
+
1240
+ @example
1241
+ ```
1242
+ import type {OrAll} from 'type-fest';
1243
+
1244
+ type A = OrAll<[never, never, true]>;
1245
+ //=> true
1246
+
1247
+ type B = OrAll<[never, never, false]>;
1248
+ //=> false
1249
+
1250
+ type C = OrAll<[never, never, never]>;
1251
+ //=> false
1252
+
1253
+ type D = OrAll<[never, never, boolean]>;
1254
+ //=> boolean
1255
+ ```
1256
+
1257
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
1258
+
1259
+ @example
1260
+ ```
1261
+ import type {OrAll} from 'type-fest';
1262
+
1263
+ type A = OrAll<[false, any]>;
1264
+ //=> boolean
1265
+
1266
+ type B = OrAll<[true, any]>;
1267
+ //=> true
1268
+ ```
1269
+
1270
+ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
1271
+
1272
+ @see {@link Or}
1273
+ @see {@link AndAll}
1274
+ */
1275
+ type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
1276
+ //#endregion
1277
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/or.d.ts
1278
+ /**
1279
+ Returns a boolean for whether either of two given types is true.
1280
+
1281
+ Use-case: Constructing complex conditional types where at least one condition must be satisfied.
1282
+
1283
+ @example
1284
+ ```
1285
+ import type {Or} from 'type-fest';
1286
+
1287
+ type TT = Or<true, true>;
1288
+ //=> true
1289
+
1290
+ type TF = Or<true, false>;
1291
+ //=> true
1292
+
1293
+ type FT = Or<false, true>;
1294
+ //=> true
1295
+
1296
+ type FF = Or<false, false>;
1297
+ //=> false
1298
+ ```
1299
+
1300
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
1301
+ For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
1302
+
1303
+ @example
1304
+ ```
1305
+ import type {Or} from 'type-fest';
1306
+
1307
+ type A = Or<false, boolean>;
1308
+ //=> boolean
1309
+
1310
+ type B = Or<boolean, false>;
1311
+ //=> boolean
1312
+
1313
+ type C = Or<true, boolean>;
1314
+ //=> true
1315
+
1316
+ type D = Or<boolean, true>;
1317
+ //=> true
1318
+
1319
+ type E = Or<boolean, boolean>;
1320
+ //=> boolean
1321
+ ```
1322
+
1323
+ Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
1324
+
1325
+ @example
1326
+ ```
1327
+ import type {Or} from 'type-fest';
1328
+
1329
+ type A = Or<true, never>;
1330
+ //=> true
1331
+
1332
+ type B = Or<never, true>;
1333
+ //=> true
1334
+
1335
+ type C = Or<false, never>;
1336
+ //=> false
1337
+
1338
+ type D = Or<never, false>;
1339
+ //=> false
1340
+
1341
+ type E = Or<boolean, never>;
1342
+ //=> boolean
1343
+
1344
+ type F = Or<never, boolean>;
1345
+ //=> boolean
1346
+
1347
+ type G = Or<never, never>;
1348
+ //=> false
1349
+ ```
1350
+
1351
+ @see {@link OrAll}
1352
+ @see {@link And}
1353
+ @see {@link Xor}
1354
+ */
1355
+ type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
1356
+ //#endregion
1357
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/all-extend.d.ts
1358
+ /**
1359
+ @see {@link AllExtend}
1360
+ */
1361
+ type AllExtendOptions = {
1362
+ /**
1363
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1364
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1365
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1366
+ @default true
1367
+ @example
1368
+ ```
1369
+ import type {AllExtend} from 'type-fest';
1370
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1371
+ //=> false
1372
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1373
+ //=> true
1374
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
1375
+ //=> true
1376
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
1377
+ //=> true
1378
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1379
+ //=> true
1380
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1381
+ //=> true
1382
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
1383
+ //=> false
1384
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
1385
+ //=> false
1386
+ ```
1387
+ */
1388
+ strictNever?: boolean;
1389
+ };
1390
+ type DefaultAllExtendOptions = {
1391
+ strictNever: true;
1392
+ };
1393
+ /**
1394
+ Returns a boolean for whether every element in an array type extends another type.
1395
+
1396
+ @example
1397
+ ```
1398
+ import type {AllExtend} from 'type-fest';
1399
+
1400
+ type A = AllExtend<[1, 2, 3], number>;
1401
+ //=> true
1402
+
1403
+ type B = AllExtend<[1, 2, '3'], number>;
1404
+ //=> false
1405
+
1406
+ type C = AllExtend<[number, number | string], number>;
1407
+ //=> boolean
1408
+
1409
+ type D = AllExtend<[true, boolean, true], true>;
1410
+ //=> boolean
1411
+ ```
1412
+
1413
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
1414
+
1415
+ ```
1416
+ // @exactOptionalPropertyTypes: true
1417
+ import type {AllExtend} from 'type-fest';
1418
+
1419
+ type A = AllExtend<[1?, 2?, 3?], number>;
1420
+ //=> true
1421
+ ```
1422
+
1423
+ ```
1424
+ // @exactOptionalPropertyTypes: false
1425
+ import type {AllExtend} from 'type-fest';
1426
+
1427
+ type A = AllExtend<[1?, 2?, 3?], number>;
1428
+ //=> boolean
1429
+
1430
+ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
1431
+ //=> true
1432
+ ```
1433
+
1434
+ @see {@link AllExtendOptions}
1435
+
1436
+ @category Utilities
1437
+ @category Array
1438
+ */
1439
+ type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
1440
+ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
1441
+ ? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
1442
+ //#endregion
1443
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/and-all.d.ts
1444
+ /**
1445
+ Returns a boolean for whether all of the given elements are `true`.
1446
+
1447
+ Use-cases:
1448
+ - Check if all conditions in a list of booleans are met.
1449
+
1450
+ @example
1451
+ ```
1452
+ import type {AndAll} from 'type-fest';
1453
+
1454
+ type TTT = AndAll<[true, true, true]>;
1455
+ //=> true
1456
+
1457
+ type TTF = AndAll<[true, true, false]>;
1458
+ //=> false
1459
+
1460
+ type TFT = AndAll<[true, false, true]>;
1461
+ //=> false
1462
+ ```
1463
+
1464
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
1465
+ For example, `AndAll<[true, boolean]>` expands to `AndAll<[true, true]> | AndAll<[true, false]>`, which simplifies to `true | false` (i.e., `boolean`).
1466
+
1467
+ @example
1468
+ ```
1469
+ import type {AndAll} from 'type-fest';
1470
+
1471
+ type A = AndAll<[true, boolean]>;
1472
+ //=> boolean
1473
+
1474
+ type B = AndAll<[false, boolean]>;
1475
+ //=> false
1476
+ ```
1477
+
1478
+ Note: If any of the elements is `never`, the result becomes `false`.
1479
+
1480
+ @example
1481
+ ```
1482
+ import type {AndAll} from 'type-fest';
1483
+
1484
+ type A = AndAll<[true, true, never]>;
1485
+ //=> false
1486
+
1487
+ type B = AndAll<[false, never, never]>;
1488
+ //=> false
1489
+
1490
+ type C = AndAll<[never, never, never]>;
1491
+ //=> false
1492
+
1493
+ type D = AndAll<[boolean, true, never]>;
1494
+ //=> false
1495
+ ```
1496
+
1497
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
1498
+
1499
+ @example
1500
+ ```
1501
+ import type {AndAll} from 'type-fest';
1502
+
1503
+ type A = AndAll<[false, any]>;
1504
+ //=> false
1505
+
1506
+ type B = AndAll<[true, any]>;
1507
+ //=> boolean
1508
+ ```
1509
+
1510
+ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](https://en.wikipedia.org/wiki/Logical_conjunction#:~:text=In%20keeping%20with%20the%20concept%20of%20vacuous%20truth%2C%20when%20conjunction%20is%20defined%20as%20an%20operator%20or%20function%20of%20arbitrary%20arity%2C%20the%20empty%20conjunction%20(AND%2Ding%20over%20an%20empty%20set%20of%20operands)%20is%20often%20defined%20as%20having%20the%20result%20true.), i.e., there are no `false` elements in an empty tuple.
1511
+
1512
+ @see {@link And}
1513
+ @see {@link OrAll}
1514
+ */
1515
+ type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
1516
+ //#endregion
1517
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/and.d.ts
13
1518
  /**
14
- * Interaction events that can trigger a validation check for a field.
15
- */
16
- type ValidationTriggers = 'blur' | 'change' | 'input' | 'mount' | 'focus';
1519
+ Returns a boolean for whether two given types are both true.
1520
+
1521
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
1522
+
1523
+ @example
1524
+ ```
1525
+ import type {And} from 'type-fest';
1526
+
1527
+ type TT = And<true, true>;
1528
+ //=> true
1529
+
1530
+ type TF = And<true, false>;
1531
+ //=> false
1532
+
1533
+ type FT = And<false, true>;
1534
+ //=> false
1535
+
1536
+ type FF = And<false, false>;
1537
+ //=> false
1538
+ ```
1539
+
1540
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
1541
+ For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
1542
+
1543
+ @example
1544
+ ```
1545
+ import type {And} from 'type-fest';
1546
+
1547
+ type A = And<true, boolean>;
1548
+ //=> boolean
1549
+
1550
+ type B = And<boolean, true>;
1551
+ //=> boolean
1552
+
1553
+ type C = And<false, boolean>;
1554
+ //=> false
1555
+
1556
+ type D = And<boolean, false>;
1557
+ //=> false
1558
+
1559
+ type E = And<boolean, boolean>;
1560
+ //=> boolean
1561
+ ```
1562
+
1563
+ Note: If either of the types is `never`, the result becomes `false`.
1564
+
1565
+ @example
1566
+ ```
1567
+ import type {And} from 'type-fest';
1568
+
1569
+ type A = And<true, never>;
1570
+ //=> false
1571
+
1572
+ type B = And<never, true>;
1573
+ //=> false
1574
+
1575
+ type C = And<false, never>;
1576
+ //=> false
1577
+
1578
+ type D = And<never, false>;
1579
+ //=> false
1580
+
1581
+ type E = And<boolean, never>;
1582
+ //=> false
1583
+
1584
+ type F = And<never, boolean>;
1585
+ //=> false
1586
+
1587
+ type G = And<never, never>;
1588
+ //=> false
1589
+ ```
1590
+
1591
+ @see {@link AndAll}
1592
+ @see {@link Or}
1593
+ @see {@link Xor}
1594
+ */
1595
+ type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
1596
+ //#endregion
1597
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/greater-than.d.ts
17
1598
  /**
18
- * Represents a validation schema for object-based data structures.
19
- * Complies with the Standard Schema specification.
20
- */
21
- type ObjectSchema = StandardSchemaV1 & {
22
- '~standard': StandardSchemaV1['~standard'] & {
23
- types?: {
24
- input: object;
25
- };
26
- };
27
- };
1599
+ Returns a boolean for whether a given number is greater than another number.
1600
+
1601
+ @example
1602
+ ```
1603
+ import type {GreaterThan} from 'type-fest';
1604
+
1605
+ type A = GreaterThan<1, -5>;
1606
+ //=> true
1607
+
1608
+ type B = GreaterThan<1, 1>;
1609
+ //=> false
1610
+
1611
+ type C = GreaterThan<1, 5>;
1612
+ //=> false
1613
+ ```
1614
+
1615
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1616
+
1617
+ @example
1618
+ ```
1619
+ import type {GreaterThan} from 'type-fest';
1620
+
1621
+ type A = GreaterThan<number, 1>;
1622
+ //=> boolean
1623
+
1624
+ type B = GreaterThan<1, number>;
1625
+ //=> boolean
1626
+
1627
+ type C = GreaterThan<number, number>;
1628
+ //=> boolean
1629
+ ```
1630
+
1631
+ @example
1632
+ ```
1633
+ import type {GreaterThan} from 'type-fest';
1634
+
1635
+ // Use `GreaterThan` to constrain a function parameter to positive numbers.
1636
+ declare function setPositive<N extends number>(value: GreaterThan<N, 0> extends true ? N : never): void;
1637
+
1638
+ setPositive(1); // ✅ Allowed
1639
+ setPositive(2); // ✅ Allowed
1640
+
1641
+ // @ts-expect-error
1642
+ setPositive(0);
1643
+
1644
+ // @ts-expect-error
1645
+ setPositive(-1);
1646
+ ```
1647
+ */
1648
+ type GreaterThan<A extends number, B extends number> = A extends number // For distributing `A`
1649
+ ? B extends number // For distributing `B`
1650
+ ? number extends A | B ? boolean : [IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>, IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`> : never : never : never // Should never happen
1651
+ : never;
1652
+ //#endregion
1653
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
28
1654
  /**
29
- * Represents a validation schema for array-based data structures.
30
- * Complies with the Standard Schema specification.
31
- */
32
- type ArraySchema = StandardSchemaV1 & {
33
- '~standard': StandardSchemaV1['~standard'] & {
34
- types?: {
35
- input: Array<any>;
36
- };
37
- };
38
- };
1655
+ Returns a boolean for whether a given number is greater than or equal to another number.
1656
+
1657
+ @example
1658
+ ```
1659
+ import type {GreaterThanOrEqual} from 'type-fest';
1660
+
1661
+ type A = GreaterThanOrEqual<1, -5>;
1662
+ //=> true
1663
+
1664
+ type B = GreaterThanOrEqual<1, 1>;
1665
+ //=> true
1666
+
1667
+ type C = GreaterThanOrEqual<1, 5>;
1668
+ //=> false
1669
+ ```
1670
+
1671
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1672
+
1673
+ @example
1674
+ ```
1675
+ import type {GreaterThanOrEqual} from 'type-fest';
1676
+
1677
+ type A = GreaterThanOrEqual<number, 1>;
1678
+ //=> boolean
1679
+
1680
+ type B = GreaterThanOrEqual<1, number>;
1681
+ //=> boolean
1682
+
1683
+ type C = GreaterThanOrEqual<number, number>;
1684
+ //=> boolean
1685
+ ```
1686
+
1687
+ @example
1688
+ ```
1689
+ import type {GreaterThanOrEqual} from 'type-fest';
1690
+
1691
+ // Use `GreaterThanOrEqual` to constrain a function parameter to non-negative numbers.
1692
+ declare function setNonNegative<N extends number>(value: GreaterThanOrEqual<N, 0> extends true ? N : never): void;
1693
+
1694
+ setNonNegative(0); // ✅ Allowed
1695
+ setNonNegative(1); // ✅ Allowed
1696
+
1697
+ // @ts-expect-error
1698
+ setNonNegative(-1);
1699
+
1700
+ // @ts-expect-error
1701
+ setNonNegative(-2);
1702
+ ```
1703
+ */
1704
+ type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? boolean : A extends number // For distributing `A`
1705
+ ? B extends number // For distributing `B`
1706
+ ? A extends B ? true : GreaterThan<A, B> : never // Should never happen
1707
+ : never;
39
1708
  //#endregion
40
- //#region src/types/utils.d.ts
1709
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/less-than.d.ts
41
1710
  /**
42
- * Constructs a type where all properties of the input type are optional recursively.
43
- * @template TData The base data structure to transform.
44
- */
45
- type DeepPartial<TData> = PartialDeep<TData, {
46
- recurseIntoArrays: true;
47
- allowUndefinedInNonTupleArrays: true;
48
- }>;
1711
+ Returns a boolean for whether a given number is less than another number.
1712
+
1713
+ @example
1714
+ ```
1715
+ import type {LessThan} from 'type-fest';
1716
+
1717
+ type A = LessThan<1, -5>;
1718
+ //=> false
1719
+
1720
+ type B = LessThan<1, 1>;
1721
+ //=> false
1722
+
1723
+ type C = LessThan<1, 5>;
1724
+ //=> true
1725
+ ```
1726
+
1727
+ Note: If either argument is the non-literal `number` type, the result is `boolean`.
1728
+
1729
+ @example
1730
+ ```
1731
+ import type {LessThan} from 'type-fest';
1732
+
1733
+ type A = LessThan<number, 1>;
1734
+ //=> boolean
1735
+
1736
+ type B = LessThan<1, number>;
1737
+ //=> boolean
1738
+
1739
+ type C = LessThan<number, number>;
1740
+ //=> boolean
1741
+ ```
1742
+
1743
+ @example
1744
+ ```
1745
+ import type {LessThan} from 'type-fest';
1746
+
1747
+ // Use `LessThan` to constrain a function parameter to negative numbers.
1748
+ declare function setNegative<N extends number>(value: LessThan<N, 0> extends true ? N : never): void;
1749
+
1750
+ setNegative(-1); // ✅ Allowed
1751
+ setNegative(-2); // ✅ Allowed
1752
+
1753
+ // @ts-expect-error
1754
+ setNegative(0);
1755
+
1756
+ // @ts-expect-error
1757
+ setNegative(1);
1758
+ ```
1759
+ */
1760
+ type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
1761
+ //#endregion
1762
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/internal/tuple.d.ts
1763
+ // Should never happen
49
1764
  /**
50
- * Constructs a type representing all possible dot-separated paths within an object.
51
- * @template TReference The object type for which to generate paths.
52
- */
53
- type Paths<TReference> = Paths$1<TReference, {
54
- maxRecursionDepth: 10;
55
- bracketNotation: true;
56
- leavesOnly: false;
57
- }> | (string & {});
1765
+ Returns the maximum value from a tuple of integers.
1766
+
1767
+ Note:
1768
+ - Float numbers are not supported.
1769
+
1770
+ @example
1771
+ ```
1772
+ type A = TupleMax<[1, 2, 5, 3]>;
1773
+ //=> 5
1774
+
1775
+ type B = TupleMax<[1, 2, 5, 3, 99, -1]>;
1776
+ //=> 99
1777
+ ```
1778
+ */
1779
+ type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? GreaterThan<F, Result> extends true ? TupleMax<R, F> : TupleMax<R, Result> : Result;
58
1780
  //#endregion
59
- //#region src/types/not-form.d.ts
1781
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/partial-deep.d.ts
60
1782
  /**
61
- * Configuration options for initializing a new form instance.
62
- * @template TSchema The validation schema type derived from ObjectSchema.
63
- */
64
- type UseNotFormOptions<TSchema extends ObjectSchema> = {
65
- /** Unique form identifier (autogenerated if omitted) */
66
- id?: string;
67
- /** The validation schema used to parse and validate form data */
68
- schema: MaybeRefOrGetter<TSchema>;
69
- /** Initial form data values */
70
- initialState?: DeepPartial<StandardSchemaV1.InferInput<TSchema>>;
71
- /** List of validation issues to display initially */
72
- initialErrors?: StandardSchemaV1.Issue[];
73
- /** Validation behavioral strategy (lazy or eager) */
74
- mode?: ValidationMode;
75
- /** Events that trigger individual field validation */
76
- validateOn?: ValidationTriggers[];
77
- /**
78
- * Custom validation logic that runs after schema validation.
79
- * @param data The validated data from the schema.
80
- * @returns Success boolean, issues array, or void.
81
- */
82
- onValidate?: (data: StandardSchemaV1.InferOutput<TSchema>) => boolean | void | StandardSchemaV1.Issue[] | Promise<boolean | void | StandardSchemaV1.Issue[]>;
83
- /** Callback triggered when the form is reset */
84
- onReset?: () => void;
1783
+ @see {@link PartialDeep}
1784
+ */
1785
+ type PartialDeepOptions = {
85
1786
  /**
86
- * Callback triggered when form validation fails.
87
- * @param errors The list of identified issues.
88
- */
89
- onError?: (errors: StandardSchemaV1.Issue[]) => void;
1787
+ Whether to affect the individual elements of arrays and tuples.
1788
+ @default false
1789
+ */
1790
+ readonly recurseIntoArrays?: boolean;
90
1791
  /**
91
- * Callback triggered when form validation passes and form is submitted.
92
- * @param data The validated data from the schema.
93
- */
94
- onSubmit?: (data: StandardSchemaV1.InferOutput<TSchema>) => void | Promise<void>;
1792
+ Allows `undefined` values in non-tuple arrays.
1793
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
1794
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
1795
+ @default false
1796
+ @example
1797
+ You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
1798
+ ```
1799
+ import type {PartialDeep} from 'type-fest';
1800
+ type Settings = {
1801
+ languages: string[];
1802
+ };
1803
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
1804
+ partialSettings.languages = [undefined]; // OK
1805
+ ```
1806
+ */
1807
+ readonly allowUndefinedInNonTupleArrays?: boolean;
95
1808
  };
96
- /**
97
- * The core state and methods provided by a form instance.
98
- * @template TSchema The validation schema type derived from ObjectSchema.
99
- */
100
- type NotFormContext<TSchema extends ObjectSchema> = {
101
- /** Unique form identifier */
102
- id: string;
103
- /** Deeply reactive object of field values */
104
- state: Ref<StandardSchemaV1.InferInput<TSchema>>;
105
- /**
106
- * Updates the form state.
107
- * @param _state The new state to apply.
108
- * @param _validate Re-validate after update (default: true).
109
- */
110
- setState: (_state: DeepPartial<StandardSchemaV1.InferInput<TSchema>>, _validate?: boolean) => void;
111
- /** Baseline form data at moment of initialization */
112
- initialState: StandardSchemaV1.InferInput<TSchema>;
113
- /** Reactive array of active validation issues */
114
- errors: Ref<StandardSchemaV1.Issue[]>;
115
- /**
116
- * Directly sets the form errors.
117
- * @param _errors The issues to apply.
118
- */
119
- setErrors: (_errors: StandardSchemaV1.Issue[]) => void;
120
- /** Removes all active validation issues */
121
- clearErrors: () => void;
122
- /**
123
- * Retrieves validation issues for a specific field.
124
- * @param field The path to the field.
125
- * @returns Array of issues for that field.
126
- */
127
- getFieldErrors: (field: Paths<StandardSchemaV1.InferInput<TSchema>>) => StandardSchemaV1.Issue[];
128
- /** List of issues provided during initialization */
129
- initialErrors: StandardSchemaV1.Issue[];
130
- /** Computed reference to the active validation schema */
131
- schema: ComputedRef<TSchema>;
132
- /** Strategy for how/when validation occurs */
133
- mode: ValidationMode;
134
- /** Interaction events configured to trigger validation */
135
- validateOn: ValidationTriggers[];
136
- /**
137
- * Validates entire form.
138
- * @returns Promise resolving to validation results.
139
- */
140
- validate: () => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
141
- /**
142
- * Validates a single specified field.
143
- * @param field The path to the field.
144
- * @returns Promise resolving to validation results.
145
- */
146
- validateField: (field: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
147
- /**
148
- * Reverts state and errors to initial or custom baseline.
149
- * @param _state Optional partial state baseline.
150
- * @param _errors Optional issues list baseline.
151
- * @param _validate Re-validate after resetting (default: false).
152
- */
153
- reset: (_state?: DeepPartial<StandardSchemaV1.InferInput<TSchema>>, _errors?: StandardSchemaV1.Issue[], _validate?: boolean) => void;
154
- /** Reactive status of async validation process */
155
- isValidating: Ref<boolean>;
156
- /** Reactive status of form submission */
157
- isSubmitting: Ref<boolean>;
158
- /** Computed status of form validity */
159
- isValid: ComputedRef<boolean>;
160
- /** Computed status of field interactions */
161
- isTouched: ComputedRef<boolean>;
162
- /**
163
- * Marks a field as interacted with.
164
- * @param field The path to the field.
165
- */
166
- touchField: (field: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
167
- /** Marks all fields in the form as touched */
168
- touchAllFields: () => void;
169
- /** Reactive set of touched field paths */
170
- touchedFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>;
171
- /** Computed status of form modifications */
172
- isDirty: ComputedRef<boolean>;
173
- /** Reactive set of dirty field paths */
174
- dirtyFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>;
175
- /**
176
- * Programmatically marks a field as dirty.
177
- * @param field The path to the field.
178
- */
179
- dirtyField: (field: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
180
- /** Marks all fields in the form as dirty */
181
- dirtyAllFields: () => void;
182
- /**
183
- * Validates and then triggers form submission.
184
- * @param event The original form submission event.
185
- */
186
- submit: (event: Event) => Promise<void>;
1809
+ type DefaultPartialDeepOptions = {
1810
+ recurseIntoArrays: false;
1811
+ allowUndefinedInNonTupleArrays: false;
187
1812
  };
188
1813
  /**
189
- * Properties accepted by the NotForm component.
190
- * @template TSchema The validation schema type derived from ObjectSchema.
191
- */
192
- type NotFormProps<TSchema extends ObjectSchema> = Pick<NotFormContext<TSchema>, 'id'> & {
193
- /** Render `NotForm` as it nearest child - use to make it renderless and override `as` option */
194
- asChild?: boolean;
195
- /** HTML Tag `NotForm` should render as - default is `form`. */
196
- as?: string;
1814
+ Create a type from another type with all keys and nested keys set to optional.
1815
+
1816
+ Use-cases:
1817
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
1818
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
1819
+
1820
+ @example
1821
+ ```
1822
+ import type {PartialDeep} from 'type-fest';
1823
+
1824
+ let settings = {
1825
+ textEditor: {
1826
+ fontSize: 14,
1827
+ fontColor: '#000000',
1828
+ fontWeight: 400,
1829
+ },
1830
+ autocomplete: false,
1831
+ autosave: true,
197
1832
  };
198
- /**
199
- * Slots provided by the NotForm component.
200
- * @template TSchema The validation schema type derived from ObjectSchema.
201
- */
202
- type NotFormSlots<TSchema extends ObjectSchema> = {
203
- /** The default slot receives the form context as its scope */
204
- default: (props: NotFormContext<TSchema> & {
205
- attributes?: ReturnType<typeof useAttrs>;
206
- }) => VNodeChild;
1833
+
1834
+ const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
1835
+ {...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
1836
+ );
1837
+
1838
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
1839
+ ```
1840
+
1841
+ By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
1842
+
1843
+ ```
1844
+ import type {PartialDeep} from 'type-fest';
1845
+
1846
+ type Shape = {
1847
+ dimensions: [number, number];
1848
+ };
1849
+
1850
+ const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
1851
+ dimensions: [], // OK
207
1852
  };
1853
+
1854
+ partialShape.dimensions = [15]; // OK
1855
+ ```
1856
+
1857
+ @see {@link PartialDeepOptions}
1858
+
1859
+ @category Object
1860
+ @category Array
1861
+ @category Set
1862
+ @category Map
1863
+ */
1864
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
1865
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T // For functions with no properties
1866
+ : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
1867
+ ? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
1868
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
1869
+ ? 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
1870
+ : T // If they don't opt into array testing, just use the original type
1871
+ : PartialObjectDeep<T, Options> : unknown;
208
1872
  /**
209
- * Expected return type for the useNotForm composable.
210
- * @template TSchema The validation schema type derived from ObjectSchema.
211
- */
212
- type UseNotFormReturn<TSchema extends ObjectSchema> = NotFormContext<TSchema>;
1873
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
1874
+ */
1875
+ type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
1876
+ /**
1877
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
1878
+ */
1879
+ type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
1880
+ /**
1881
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
1882
+ */
1883
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
1884
+ /**
1885
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
1886
+ */
1887
+ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
1888
+ /**
1889
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
1890
+ */
1891
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
213
1892
  //#endregion
214
- //#region src/types/not-field.d.ts
215
- /** Configuration properties for the NotField component */
216
- type NotFieldProps = {
217
- /** The unique name/path identifying the field within the form state */
218
- name: string;
219
- };
1893
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/subtract.d.ts
220
1894
  /**
221
- * State and methods provided to the NotField component's scope.
222
- */
223
- type NotFieldContext = {
224
- /** The name/path of the field */
225
- name: string;
226
- /** Array of validation error messages currently active for this field */
227
- errors: string[];
228
- /** Indicates if the field has been interacted with (focus lost) */
229
- isTouched: boolean;
230
- /** Indicates if the field's current value differs from its initial value */
231
- isDirty: boolean;
232
- /** Indicates if the field currently passes all validation rules */
233
- isValid: boolean;
1895
+ Returns the difference between two numbers.
1896
+
1897
+ Note:
1898
+ - A or B can only support `-999` ~ `999`.
1899
+
1900
+ @example
1901
+ ```
1902
+ import type {Subtract, PositiveInfinity} from 'type-fest';
1903
+
1904
+ type A = Subtract<333, 222>;
1905
+ //=> 111
1906
+
1907
+ type B = Subtract<111, -222>;
1908
+ //=> 333
1909
+
1910
+ type C = Subtract<-111, 222>;
1911
+ //=> -333
1912
+
1913
+ type D = Subtract<18, 96>;
1914
+ //=> -78
1915
+
1916
+ type E = Subtract<PositiveInfinity, 9999>;
1917
+ //=> Infinity
1918
+
1919
+ type F = Subtract<PositiveInfinity, PositiveInfinity>;
1920
+ //=> number
1921
+ ```
1922
+
1923
+ @category Numeric
1924
+ */
1925
+ // TODO: Support big integer.
1926
+ type Subtract<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
1927
+ number extends A | B ? number // Handle cases when A and B are both +/- infinity
1928
+ : A extends B & (PositiveInfinity | NegativeInfinity) ? number // Handle cases when A is - infinity or B is + infinity
1929
+ : A extends NegativeInfinity ? NegativeInfinity : B extends PositiveInfinity ? NegativeInfinity // Handle cases when A is + infinity or B is - infinity
1930
+ : A extends PositiveInfinity ? PositiveInfinity : B extends NegativeInfinity ? PositiveInfinity // Handle case when numbers are equal to each other
1931
+ : A extends B ? 0 // Handle cases when A or B is 0
1932
+ : A extends 0 ? ReverseSign<B> : B extends 0 ? A // Handle remaining regular cases
1933
+ : SubtractPostChecks<A, B>;
1934
+ /**
1935
+ Subtracts two numbers A and B, such that they are not equal and neither of them are 0, +/- infinity or the `number` type
1936
+ */
1937
+ type SubtractPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] ? SubtractPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we subtract the absolute values and then reverse the sign
1938
+ ? ReverseSign<SubtractPositives<NumberAbsolute<A>, NumberAbsolute<B>>> // When the signs are different we can add the absolute values and then reverse the sign if A < B
1939
+ : [...TupleOf<NumberAbsolute<A>>, ...TupleOf<NumberAbsolute<B>>] extends infer R extends unknown[] ? LessThan<A, B> extends true ? ReverseSign<R['length']> : R['length'] : never;
1940
+ /**
1941
+ Subtracts two positive numbers.
1942
+ */
1943
+ type SubtractPositives<A extends number, B extends number> = LessThan<A, B> extends true // When A < B we can reverse the result of B - A
1944
+ ? ReverseSign<SubtractIfAGreaterThanB<B, A>> : SubtractIfAGreaterThanB<A, B>;
1945
+ /**
1946
+ Subtracts two positive numbers A and B such that A > B.
1947
+ */
1948
+ type SubtractIfAGreaterThanB<A extends number, B extends number> = // This is where we always want to end up and do the actual subtraction
1949
+ TupleOf<A> extends [...TupleOf<B>, ...infer R] ? R['length'] : never;
1950
+ //#endregion
1951
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/sum.d.ts
1952
+ /**
1953
+ Returns the sum of two numbers.
1954
+
1955
+ Note:
1956
+ - A or B can only support `-999` ~ `999`.
1957
+
1958
+ @example
1959
+ ```
1960
+ import type {Sum, PositiveInfinity, NegativeInfinity} from 'type-fest';
1961
+
1962
+ type A = Sum<111, 222>;
1963
+ //=> 333
1964
+
1965
+ type B = Sum<-111, 222>;
1966
+ //=> 111
1967
+
1968
+ type C = Sum<111, -222>;
1969
+ //=> -111
1970
+
1971
+ type D = Sum<PositiveInfinity, -9999>;
1972
+ //=> Infinity
1973
+
1974
+ type E = Sum<PositiveInfinity, NegativeInfinity>;
1975
+ //=> number
1976
+ ```
1977
+
1978
+ @category Numeric
1979
+ */
1980
+ // TODO: Support big integer.
1981
+ type Sum<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
1982
+ number extends A | B ? number // Handle cases when A and B are both +/- infinity
1983
+ : A extends B & (PositiveInfinity | NegativeInfinity) ? A // A or B could be used here as they are equal
1984
+ // Handle cases when A and B are opposite infinities
1985
+ : A | B extends PositiveInfinity | NegativeInfinity ? number // Handle cases when A is +/- infinity
1986
+ : A extends PositiveInfinity | NegativeInfinity ? A // Handle cases when B is +/- infinity
1987
+ : B extends PositiveInfinity | NegativeInfinity ? B // Handle cases when A or B is 0 or it's the same number with different signs
1988
+ : A extends 0 ? B : B extends 0 ? A : A extends ReverseSign<B> ? 0 // Handle remaining regular cases
1989
+ : SumPostChecks<A, B>;
1990
+ /**
1991
+ Adds two numbers A and B, such that they are not equal with different signs and neither of them are 0, +/- infinity or the `number` type
1992
+ */
1993
+ type SumPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] // When both numbers are positive we can add them together
1994
+ ? SumPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we add the absolute values and then reverse the sign
1995
+ ? ReverseSign<SumPositives<NumberAbsolute<A>, NumberAbsolute<B>>> // When the signs are different we can subtract the absolute values, remove the sign
1996
+ // and then reverse the sign if the larger absolute value is negative
1997
+ : NumberAbsolute<Subtract<NumberAbsolute<A>, NumberAbsolute<B>>> extends infer Result extends number ? TupleMax<[NumberAbsolute<A>, NumberAbsolute<B>]> extends infer Max_ extends number ? Max_ extends A | B // The larger absolute value is positive, so the result is positive
1998
+ ? Result // The larger absolute value is negative, so the result is negative
1999
+ : ReverseSign<Result> : never : never;
2000
+ /**
2001
+ Adds two positive numbers.
2002
+ */
2003
+ type SumPositives<A extends number, B extends number> = [...TupleOf<A>, ...TupleOf<B>]['length'] extends infer Result extends number ? Result : never;
2004
+ //#endregion
2005
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/paths.d.ts
2006
+ /**
2007
+ Paths options.
2008
+
2009
+ @see {@link Paths}
2010
+ */
2011
+ type PathsOptions = {
2012
+ /**
2013
+ The maximum depth to recurse when searching for paths. Range: 0 ~ 10.
2014
+ @default 5
2015
+ */
2016
+ maxRecursionDepth?: number;
2017
+ /**
2018
+ Use bracket notation for array indices and numeric object keys.
2019
+ @default false
2020
+ @example
2021
+ ```
2022
+ import type {Paths} from 'type-fest';
2023
+ type ArrayExample = {
2024
+ array: ['foo'];
2025
+ };
2026
+ type A = Paths<ArrayExample, {bracketNotation: false}>;
2027
+ //=> 'array' | 'array.0'
2028
+ type B = Paths<ArrayExample, {bracketNotation: true}>;
2029
+ //=> 'array' | 'array[0]'
2030
+ ```
2031
+ @example
2032
+ ```
2033
+ import type {Paths} from 'type-fest';
2034
+ type NumberKeyExample = {
2035
+ 1: ['foo'];
2036
+ };
2037
+ type A = Paths<NumberKeyExample, {bracketNotation: false}>;
2038
+ //=> 1 | '1' | '1.0'
2039
+ type B = Paths<NumberKeyExample, {bracketNotation: true}>;
2040
+ //=> '[1]' | '[1][0]'
2041
+ ```
2042
+ */
2043
+ bracketNotation?: boolean;
234
2044
  /**
235
- * Triggers a manual validation check for only this field.
236
- * @returns Resolve with the validation result object.
237
- */
238
- validate: () => Promise<StandardSchemaV1.Result<ObjectSchema>>;
239
- /** Collection of event handlers for common field interactions. */
240
- methods: {
241
- /** Logic to execute when the field loses focus */
242
- onBlur: () => void;
243
- /** Logic to execute when the field's value is committed */
244
- onChange: () => void;
245
- /** Logic to execute when the field receives user input */
246
- onInput: () => void;
247
- /** Logic to execute when the field gains focus */
248
- onFocus: () => void;
2045
+ Only include leaf paths in the output.
2046
+ @default false
2047
+ @example
2048
+ ```
2049
+ import type {Paths} from 'type-fest';
2050
+ type Post = {
2051
+ id: number;
2052
+ author: {
2053
+ id: number;
2054
+ name: {
2055
+ first: string;
2056
+ last: string;
2057
+ };
2058
+ };
249
2059
  };
2060
+ type AllPaths = Paths<Post, {leavesOnly: false}>;
2061
+ //=> 'id' | 'author' | 'author.id' | 'author.name' | 'author.name.first' | 'author.name.last'
2062
+ type LeafPaths = Paths<Post, {leavesOnly: true}>;
2063
+ //=> 'id' | 'author.id' | 'author.name.first' | 'author.name.last'
2064
+ ```
2065
+ @example
2066
+ ```
2067
+ import type {Paths} from 'type-fest';
2068
+ type ArrayExample = {
2069
+ array: Array<{foo: string}>;
2070
+ tuple: [string, {bar: string}];
2071
+ };
2072
+ type AllPaths = Paths<ArrayExample, {leavesOnly: false}>;
2073
+ //=> 'array' | 'tuple' | `array.${number}` | `array.${number}.foo` | 'tuple.0' | 'tuple.1' | 'tuple.1.bar'
2074
+ type LeafPaths = Paths<ArrayExample, {leavesOnly: true}>;
2075
+ //=> `array.${number}.foo` | 'tuple.0' | 'tuple.1.bar'
2076
+ ```
2077
+ */
2078
+ leavesOnly?: boolean;
2079
+ /**
2080
+ Only include paths at the specified depth. By default all paths up to {@link PathsOptions.maxRecursionDepth | `maxRecursionDepth`} are included.
2081
+ Note: Depth starts at `0` for root properties.
2082
+ @default number
2083
+ @example
2084
+ ```
2085
+ import type {Paths} from 'type-fest';
2086
+ type Post = {
2087
+ id: number;
2088
+ author: {
2089
+ id: number;
2090
+ name: {
2091
+ first: string;
2092
+ last: string;
2093
+ };
2094
+ };
2095
+ };
2096
+ type DepthZero = Paths<Post, {depth: 0}>;
2097
+ //=> 'id' | 'author'
2098
+ type DepthOne = Paths<Post, {depth: 1}>;
2099
+ //=> 'author.id' | 'author.name'
2100
+ type DepthTwo = Paths<Post, {depth: 2}>;
2101
+ //=> 'author.name.first' | 'author.name.last'
2102
+ type LeavesAtDepthOne = Paths<Post, {leavesOnly: true; depth: 1}>;
2103
+ //=> 'author.id'
2104
+ ```
2105
+ */
2106
+ depth?: number;
2107
+ };
2108
+ type DefaultPathsOptions = {
2109
+ maxRecursionDepth: 5;
2110
+ bracketNotation: false;
2111
+ leavesOnly: false;
2112
+ depth: number;
250
2113
  };
251
2114
  /**
252
- * Slots provided by the NotField component.
253
- */
254
- type NotFieldSlots = {
255
- /** The default slot receives the field context for use within templates */
256
- default: (props: NotFieldContext) => VNodeChild;
2115
+ Generate a union of all possible paths to properties in the given object.
2116
+
2117
+ It also works with arrays.
2118
+
2119
+ Use-case: You want a type-safe way to access deeply nested properties in an object.
2120
+
2121
+ @example
2122
+ ```
2123
+ import type {Paths} from 'type-fest';
2124
+
2125
+ type Project = {
2126
+ filename: string;
2127
+ listA: string[];
2128
+ listB: [{filename: string}];
2129
+ folder: {
2130
+ subfolder: {
2131
+ filename: string;
2132
+ };
2133
+ };
257
2134
  };
2135
+
2136
+ type ProjectPaths = Paths<Project>;
2137
+ //=> 'filename' | 'listA' | 'listB' | 'folder' | `listA.${number}` | 'listB.0' | 'listB.0.filename' | 'folder.subfolder' | 'folder.subfolder.filename'
2138
+
2139
+ declare function open<Path extends ProjectPaths>(path: Path): void;
2140
+
2141
+ open('filename'); // Pass
2142
+ open('folder.subfolder'); // Pass
2143
+ open('folder.subfolder.filename'); // Pass
2144
+ // @ts-expect-error
2145
+ open('foo'); // TypeError
2146
+
2147
+ // Also works with arrays
2148
+ open('listA.1'); // Pass
2149
+ open('listB.0'); // Pass
2150
+ // @ts-expect-error
2151
+ open('listB.1'); // TypeError. Because listB only has one element.
2152
+ ```
2153
+
2154
+ @category Object
2155
+ @category Array
2156
+ */
2157
+ type Paths$1<T, Options extends PathsOptions = {}> = _Paths<T, ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, Options>>;
2158
+ type _Paths<T, Options extends Required<PathsOptions>, CurrentDepth extends number = 0> = T extends NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray> ? never : IsAny<T> extends true ? never : T extends object ? InternalPaths<Required<T>, Options, CurrentDepth> : never;
2159
+ type InternalPaths<T, Options extends Required<PathsOptions>, CurrentDepth extends number> = { [Key in keyof T]: Key extends string | number // Limit `Key` to `string | number`
2160
+ ? (And<Options['bracketNotation'], IsNumberLike<Key>> extends true ? `[${Key}]` : CurrentDepth extends 0 // Return both `Key` and `ToString<Key>` because for number keys, like `1`, both `1` and `'1'` are valid keys.
2161
+ ? Key | ToString<Key> : `.${(Key | ToString<Key>)}`) extends infer TransformedKey extends string | number ? ((Options['leavesOnly'] extends true ? Options['maxRecursionDepth'] extends CurrentDepth ? TransformedKey : IsNever<T[Key]> extends true ? TransformedKey : T[Key] extends infer Value // For distributing `T[Key]`
2162
+ ? (Value extends readonly [] | NonRecursiveType | Exclude<MapsSetsOrArrays, UnknownArray> ? TransformedKey : IsNever<keyof Value> extends true // Check for empty object & `unknown`, because `keyof unknown` is `never`.
2163
+ ? TransformedKey : never) : never // Should never happen
2164
+ : TransformedKey) extends infer _TransformedKey // If `depth` is provided, the condition becomes truthy only when it matches `CurrentDepth`.
2165
+ // Otherwise, since `depth` defaults to `number`, the condition is always truthy, returning paths at all depths.
2166
+ ? CurrentDepth extends Options['depth'] ? _TransformedKey : never : never) // Recursively generate paths for the current key
2167
+ | (GreaterThan<Options['maxRecursionDepth'], CurrentDepth> extends true // Limit the depth to prevent infinite recursion
2168
+ ? `${TransformedKey}${_Paths<T[Key], Options, Sum<CurrentDepth, 1>> & (string | number)}` : never) : never : never }[keyof T & (T extends UnknownArray ? number : unknown)];
258
2169
  //#endregion
259
- //#region src/types/not-message.d.ts
2170
+ //#region src/types/shared.d.ts
260
2171
  /**
261
- * Configuration properties for the NotMessage component.
262
- * @template TSchema The validation schema type derived from ObjectSchema.
2172
+ * Validation execution strategy.
2173
+ * - `lazy`: Validates on blur or submission.
2174
+ * - `eager`: Validates on blur, then on every change if an error exists.
263
2175
  */
264
- type NotMessageProps = {
265
- /** The name/path of the field whose error message should be displayed */
266
- name: string;
267
- /** HTML Tag `NotMessage` should render as - default is `span`. */
268
- as?: string;
2176
+ type ValidationMode = 'lazy' | 'eager';
2177
+ /** Interaction events that can trigger a validation check for a field. */
2178
+ type ValidationTriggers = {
2179
+ /** Trigger validation when the field is blurred. */onBlur?: boolean; /** Trigger validation when the field value changes. */
2180
+ onChange?: boolean; /** Trigger validation when the field value is input. */
2181
+ onInput?: boolean; /** Trigger validation when the field is mounted. */
2182
+ onMount?: boolean; /** Trigger validation when the field is focused. */
2183
+ onFocus?: boolean;
269
2184
  };
270
2185
  /**
271
- * State provided to the NotMessage component's scope.
2186
+ * Constructs a type where all properties of the input type are optional recursively.
2187
+ * @template TData The base data structure to transform.
272
2188
  */
273
- type NotMessageContext = {
274
- /** The first active validation error message for the specified field */
275
- message: NotFieldContext['errors'][number];
276
- };
2189
+ type DeepPartial<TData> = PartialDeep<TData, {
2190
+ recurseIntoArrays: true;
2191
+ allowUndefinedInNonTupleArrays: true;
2192
+ }>;
277
2193
  /**
278
- * Slots provided by the NotMessage component.
2194
+ * Constructs a type representing all possible dot-separated paths within an object.
2195
+ * @template TReference The object type for which to generate paths.
279
2196
  */
280
- type NotMessageSlots = {
281
- /** The default slot receives the error message context for custom rendering */
282
- default: (props: NotMessageContext & {
283
- attributes?: ReturnType<typeof useAttrs>;
284
- }) => VNodeChild;
285
- };
286
- //#endregion
287
- //#region src/components/not-form.vue.d.ts
288
- declare const __VLS_export$3: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$2<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
289
- props: vue0.PublicProps & __VLS_PrettifyLocal$2<NotFormProps<TSchema>> & (typeof globalThis extends {
290
- __VLS_PROPS_FALLBACK: infer P;
291
- } ? P : {});
292
- expose: (exposed: {}) => void;
293
- attrs: any;
294
- slots: NotFormSlots<TSchema>;
295
- emit: {};
296
- }>) => vue0.VNode & {
297
- __ctx?: Awaited<typeof __VLS_setup>;
298
- };
299
- declare const _default$2: typeof __VLS_export$3;
300
- type __VLS_PrettifyLocal$2<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
301
- //#endregion
302
- //#region src/components/not-field.vue.d.ts
303
- /**
304
- * Slots provided by the NotField component.
2197
+ type Paths<TReference> = Paths$1<TReference, {
2198
+ maxRecursionDepth: 10;
2199
+ bracketNotation: true;
2200
+ leavesOnly: false;
2201
+ }> | (string & {});
2202
+ /**
2203
+ * Represents a validation schema for object-based data structures.
2204
+ * Complies with the Standard Schema specification.
305
2205
  */
306
- type __VLS_Slots = NotFieldSlots;
307
- declare const __VLS_base: vue0.DefineComponent<NotFieldProps, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<NotFieldProps> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
308
- declare const __VLS_export$2: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
309
- declare const _default$1: typeof __VLS_export$2;
310
- type __VLS_WithSlots<T, S> = T & {
311
- new (): {
312
- $slots: S;
2206
+ type ObjectSchema = StandardSchemaV1 & {
2207
+ '~standard': StandardSchemaV1['~standard'] & {
2208
+ types?: {
2209
+ input: object;
2210
+ };
313
2211
  };
314
2212
  };
315
- //#endregion
316
- //#region src/components/not-message.vue.d.ts
317
- declare const __VLS_export$1: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
318
- props: vue0.PublicProps & __VLS_PrettifyLocal$1<NotMessageProps> & (typeof globalThis extends {
319
- __VLS_PROPS_FALLBACK: infer P;
320
- } ? P : {});
321
- expose: (exposed: {}) => void;
322
- attrs: any;
323
- slots: NotMessageSlots;
324
- emit: {};
325
- }>) => vue0.VNode & {
326
- __ctx?: Awaited<typeof __VLS_setup>;
327
- };
328
- declare const _default$3: typeof __VLS_export$1;
329
- type __VLS_PrettifyLocal$1<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
330
- //#endregion
331
- //#region src/types/not-array-field.d.ts
332
2213
  /**
333
- * Properties accepted by the NotArrayField component.
334
- * @template TSchema The schema of the array field.
2214
+ * Represents a validation schema for array-based data structures.
2215
+ * Complies with the Standard Schema specification.
335
2216
  */
336
- type NotArrayFieldProps<TSchema extends ArraySchema> = {
337
- /** The unique name/path identifying the array field in the form state */
338
- name: string;
339
- /** The specific schema instance used to validate the array items */
340
- schema: TSchema;
2217
+ type ArraySchema = StandardSchemaV1 & {
2218
+ '~standard': StandardSchemaV1['~standard'] & {
2219
+ types?: {
2220
+ input: Array<any>;
2221
+ };
2222
+ };
341
2223
  };
342
- /**
343
- * The core state and methods provided by an NotArrayField instance.
344
- * @template TSchema The schema of the array field.
345
- */
346
- type NotArrayFieldContext<TSchema extends ArraySchema> = {
347
- /** The unique name/path identifying the array field in the form state */
348
- name: string;
349
- /** Array-level validation errors for the field path */
350
- errors: string[];
351
- /**
352
- * Array of individual field contexts for each item in the collection.
353
- * Useful for mapping components to array elements.
354
- */
355
- fields: Array<{
356
- /** A unique identifier for the field (defaults to index) */
357
- key: string | number;
358
- /** The 0-based position of the field within the array */
359
- index: number;
360
- /** The current value of the field at this index */
361
- value: StandardSchemaV1.InferInput<TSchema>[number];
362
- /** True if this is first item in the collection */
363
- first: boolean;
364
- /** True if this is the last item in the collection */
365
- last: boolean;
366
- }>;
367
- /** Adds a new item to the end of the collection */
368
- append: (data: StandardSchemaV1.InferInput<TSchema>[number]) => void;
369
- /** Adds a new item to the beginning of the collection */
370
- prepend: (data: StandardSchemaV1.InferInput<TSchema>[number]) => void;
371
- /**
372
- * Removes the item at the specified index.
373
- * @param index The index to remove.
374
- */
375
- remove: (index: number) => void;
376
- /**
377
- * Inserts a new item at a specific position.
378
- * @param index The insertion index.
379
- * @param data Initial data for the new item.
380
- */
381
- insert: (index: number, data: StandardSchemaV1.InferInput<TSchema>[number]) => void;
382
- /**
383
- * Replaces data at a specific index.
384
- * @param index The target index.
385
- * @param data New data to apply.
386
- */
387
- update: (index: number, data: StandardSchemaV1.InferInput<TSchema>[number]) => void;
2224
+ //#endregion
2225
+ //#region src/types/use-not-form.d.ts
2226
+ type UseNotFormOptions<TSchema extends ObjectSchema> = {
2227
+ /** The validation schema used to parse and validate form data */schema: MaybeRefOrGetter<TSchema>;
388
2228
  };
389
- /**
390
- * Slots provided by the NotArrayField component.
391
- * @template TSchema The schema of the array field.
392
- */
393
- type NotArrayFieldSlots<TSchema extends ArraySchema> = {
394
- /** The default slot receives the array field context as its scope */
395
- default: (props: NotArrayFieldContext<TSchema>) => VNodeChild;
396
- };
397
- //#endregion
398
- //#region src/components/not-array-field.vue.d.ts
399
- declare const __VLS_export: <TArraySchema extends ArraySchema, TObjectSchema extends ObjectSchema = ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
400
- props: vue0.PublicProps & __VLS_PrettifyLocal<NotArrayFieldProps<TArraySchema>> & (typeof globalThis extends {
401
- __VLS_PROPS_FALLBACK: infer P;
402
- } ? P : {});
403
- expose: (exposed: {}) => void;
404
- attrs: any;
405
- slots: NotArrayFieldSlots<TArraySchema>;
406
- emit: {};
407
- }>) => vue0.VNode & {
408
- __ctx?: Awaited<typeof __VLS_setup>;
409
- };
410
- declare const _default: typeof __VLS_export;
411
- type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
412
- //#endregion
413
- //#region src/composables/use-not-form.d.ts
414
- /**
415
- * Initializes a form instance with validation logic, reactive state, and lifecycle methods.
416
- * @template TSchema The validation schema type derived from ObjectSchema.
417
- * @param options Configuration object for the form behavior and initial state.
418
- * @returns The gathered form context object.
419
- */
420
- declare function useNotForm<TSchema extends ObjectSchema>(options: UseNotFormOptions<TSchema>): UseNotFormReturn<TSchema>;
421
2229
  //#endregion
422
- export { ArraySchema, DeepPartial, _default as NotArrayField, _default$1 as NotField, NotFieldContext, NotFieldProps, NotFieldSlots, _default$2 as NotForm, NotFormContext, NotFormProps, NotFormSlots, _default$3 as NotMessage, NotMessageContext, NotMessageProps, NotMessageSlots, ObjectSchema, Paths, UseNotFormOptions, UseNotFormReturn, ValidationMode, ValidationTriggers, useNotForm };
2230
+ export { ArraySchema, DeepPartial, ObjectSchema, Paths, UseNotFormOptions, ValidationMode, ValidationTriggers };