@react-querybuilder/antd 8.9.1 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,36 +3,197 @@ import * as React from "react";
3
3
  import { ComponentPropsWithRef, ComponentPropsWithoutRef, ComponentType, ForwardRefExoticComponent, MouseEvent, ReactNode, Ref, RefAttributes } from "react";
4
4
  import { Button, Select, Switch } from "antd";
5
5
 
6
- //#region ../core/src/types/type-fest/is-equal.d.ts
6
+ //#region ../../node_modules/type-fest/source/observable-like.d.ts
7
+ declare global {
8
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
9
+ interface SymbolConstructor {
10
+ readonly observable: symbol;
11
+ }
12
+ }
7
13
 
8
14
  /**
9
- Returns a boolean for whether the two given types are equal.
15
+ @remarks
16
+ The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
17
+ As well, some guidance on making an `Observable` to not include `closed` property.
18
+ @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
19
+ @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
20
+ @see https://github.com/benlesh/symbol-observable#making-an-object-observable
10
21
 
11
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
12
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
22
+ @category Observable
23
+ */
13
24
 
14
- Use-cases:
15
- - If you want to make a conditional branch based on the result of a comparison of two types.
25
+ //#endregion
26
+ //#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
27
+ /**
28
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
29
+
30
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
16
31
 
17
32
  @example
18
33
  ```
19
- import type {IsEqual} from 'type-fest';
34
+ import type {UnionToIntersection} from 'type-fest';
20
35
 
21
- // This type returns a boolean for whether the given array includes the given item.
22
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
23
- type Includes<Value extends readonly any[], Item> =
24
- Value extends readonly [Value[0], ...infer rest]
25
- ? IsEqual<Value[0], Item> extends true
26
- ? true
27
- : Includes<rest, Item>
28
- : false;
36
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
37
+
38
+ type Intersection = UnionToIntersection<Union>;
39
+ //=> {the(): void; great(arg: string): void; escape: boolean};
29
40
  ```
30
41
 
31
- @group type-fest
42
+ A more applicable example which could make its way into your library code follows.
43
+
44
+ @example
45
+ ```
46
+ import type {UnionToIntersection} from 'type-fest';
47
+
48
+ class CommandOne {
49
+ commands: {
50
+ a1: () => undefined,
51
+ b1: () => undefined,
52
+ }
53
+ }
54
+
55
+ class CommandTwo {
56
+ commands: {
57
+ a2: (argA: string) => undefined,
58
+ b2: (argB: string) => undefined,
59
+ }
60
+ }
61
+
62
+ const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
63
+ type Union = typeof union;
64
+ //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
65
+
66
+ type Intersection = UnionToIntersection<Union>;
67
+ //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
68
+ ```
69
+
70
+ @category Type
71
+ */
72
+ type UnionToIntersection<Union> = (
73
+ // `extends unknown` is always going to be the case and is used to convert the
74
+ // `Union` into a [distributive conditional
75
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
76
+ Union extends unknown
77
+ // The union type is used as the only argument to a function since the union
78
+ // of function arguments is an intersection.
79
+ ? (distributedUnion: Union) => void
80
+ // This won't happen.
81
+ : never
82
+ // Infer the `Intersection` type since TypeScript represents the positional
83
+ // arguments of unions of functions as an intersection of the union.
84
+ ) extends ((mergedIntersection: infer Intersection) => void)
85
+ // The `& Union` is to allow indexing by the resulting type
86
+ ? Intersection & Union : never;
87
+ //#endregion
88
+ //#region ../../node_modules/type-fest/source/keys-of-union.d.ts
89
+ /**
90
+ Create a union of all keys from a given type, even those exclusive to specific union members.
91
+
92
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
93
+
94
+ @link https://stackoverflow.com/a/49402091
95
+
96
+ @example
97
+ ```
98
+ import type {KeysOfUnion} from 'type-fest';
99
+
100
+ type A = {
101
+ common: string;
102
+ a: number;
103
+ };
104
+
105
+ type B = {
106
+ common: string;
107
+ b: string;
108
+ };
109
+
110
+ type C = {
111
+ common: string;
112
+ c: boolean;
113
+ };
114
+
115
+ type Union = A | B | C;
116
+
117
+ type CommonKeys = keyof Union;
118
+ //=> 'common'
119
+
120
+ type AllKeys = KeysOfUnion<Union>;
121
+ //=> 'common' | 'a' | 'b' | 'c'
122
+ ```
123
+
124
+ @category Object
32
125
  */
33
- type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
126
+ type KeysOfUnion<ObjectType> =
127
+ // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
128
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
129
+ //#endregion
130
+ //#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
131
+ /**
132
+ Extract all optional keys from the given type.
133
+
134
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
135
+
136
+ @example
137
+ ```
138
+ import type {OptionalKeysOf, Except} from 'type-fest';
139
+
140
+ interface User {
141
+ name: string;
142
+ surname: string;
143
+
144
+ luckyNumber?: number;
145
+ }
146
+
147
+ const REMOVE_FIELD = Symbol('remove field symbol');
148
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
149
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
150
+ };
151
+
152
+ const update1: UpdateOperation<User> = {
153
+ name: 'Alice'
154
+ };
155
+
156
+ const update2: UpdateOperation<User> = {
157
+ name: 'Bob',
158
+ luckyNumber: REMOVE_FIELD
159
+ };
160
+ ```
161
+
162
+ @category Utilities
163
+ */
164
+ type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
165
+ ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
166
+ : never;
34
167
  //#endregion
35
- //#region ../core/src/types/type-fest/is-never.d.ts
168
+ //#region ../../node_modules/type-fest/source/required-keys-of.d.ts
169
+ /**
170
+ Extract all required keys from the given type.
171
+
172
+ 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...
173
+
174
+ @example
175
+ ```
176
+ import type {RequiredKeysOf} from 'type-fest';
177
+
178
+ declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
179
+
180
+ interface User {
181
+ name: string;
182
+ surname: string;
183
+
184
+ luckyNumber?: number;
185
+ }
186
+
187
+ const validator1 = createValidation<User>('name', value => value.length < 25);
188
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
189
+ ```
190
+
191
+ @category Utilities
192
+ */
193
+ type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
194
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
195
+ //#endregion
196
+ //#region ../../node_modules/type-fest/source/is-never.d.ts
36
197
  /**
37
198
  Returns a boolean for whether the given type is `never`.
38
199
 
@@ -48,20 +209,20 @@ import type {IsNever, And} from 'type-fest';
48
209
 
49
210
  // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
50
211
  type AreStringsEqual<A extends string, B extends string> =
51
- And<
52
- IsNever<Exclude<A, B>> extends true ? true : false,
53
- IsNever<Exclude<B, A>> extends true ? true : false
54
- >;
212
+ And<
213
+ IsNever<Exclude<A, B>> extends true ? true : false,
214
+ IsNever<Exclude<B, A>> extends true ? true : false
215
+ >;
55
216
 
56
217
  type EndIfEqual<I extends string, O extends string> =
57
- AreStringsEqual<I, O> extends true
58
- ? never
59
- : void;
218
+ AreStringsEqual<I, O> extends true
219
+ ? never
220
+ : void;
60
221
 
61
222
  function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
62
- if (input === output) {
63
- process.exit(0);
64
- }
223
+ if (input === output) {
224
+ process.exit(0);
225
+ }
65
226
  }
66
227
 
67
228
  endIfEqual('abc', 'abc');
@@ -71,11 +232,12 @@ endIfEqual('abc', '123');
71
232
  //=> void
72
233
  ```
73
234
 
74
- @group type-fest
235
+ @category Type Guard
236
+ @category Utilities
75
237
  */
76
238
  type IsNever<T> = [T] extends [never] ? true : false;
77
239
  //#endregion
78
- //#region ../core/src/types/type-fest/if-never.d.ts
240
+ //#region ../../node_modules/type-fest/source/if-never.d.ts
79
241
  /**
80
242
  An if-else-like type that resolves depending on whether the given type is `never`.
81
243
 
@@ -92,11 +254,12 @@ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
92
254
  //=> 'bar'
93
255
  ```
94
256
 
95
- @group type-fest
257
+ @category Type Guard
258
+ @category Utilities
96
259
  */
97
260
  type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
98
261
  //#endregion
99
- //#region ../core/src/types/type-fest/unknown-array.d.ts
262
+ //#region ../../node_modules/type-fest/source/unknown-array.d.ts
100
263
  /**
101
264
  Represents an array with `unknown` value.
102
265
 
@@ -118,16 +281,15 @@ type C = IsArray<string>;
118
281
  //=> false
119
282
  ```
120
283
 
121
- @group type-fest
284
+ @category Type
285
+ @category Array
122
286
  */
123
287
  type UnknownArray = readonly unknown[];
124
288
  //#endregion
125
- //#region ../core/src/types/type-fest/internal/array.d.ts
289
+ //#region ../../node_modules/type-fest/source/internal/array.d.ts
126
290
 
127
291
  /**
128
292
  Returns whether the given array `T` is readonly.
129
-
130
- @group type-fest
131
293
  */
132
294
  type IsArrayReadonly<T extends UnknownArray> = IfNever$1<T, false, T extends unknown[] ? false : true>;
133
295
  /**
@@ -140,9 +302,9 @@ An if-else-like type that resolves depending on whether the given array is reado
140
302
  import type {ArrayTail} from 'type-fest';
141
303
 
142
304
  type ReadonlyPreservingArrayTail<TArray extends readonly unknown[]> =
143
- ArrayTail<TArray> extends infer Tail
144
- ? IfArrayReadonly<TArray, Readonly<Tail>, Tail>
145
- : never;
305
+ ArrayTail<TArray> extends infer Tail
306
+ ? IfArrayReadonly<TArray, Readonly<Tail>, Tail>
307
+ : never;
146
308
 
147
309
  type ReadonlyTail = ReadonlyPreservingArrayTail<readonly [string, number, boolean]>;
148
310
  //=> readonly [number, boolean]
@@ -156,13 +318,14 @@ type ShouldBeTrue = IfArrayReadonly<readonly unknown[]>;
156
318
  type ShouldBeBar = IfArrayReadonly<unknown[], 'foo', 'bar'>;
157
319
  //=> 'bar'
158
320
  ```
159
-
160
- @group type-fest
161
321
  */
162
322
  type IfArrayReadonly<T extends UnknownArray, TypeIfArrayReadonly = true, TypeIfNotArrayReadonly = false> = IsArrayReadonly<T> extends infer Result ? Result extends true ? TypeIfArrayReadonly : TypeIfNotArrayReadonly : never;
163
323
  //#endregion
164
- //#region ../core/src/types/type-fest/is-any.d.ts
324
+ //#region ../../node_modules/type-fest/source/is-any.d.ts
325
+ // Can eventually be replaced with the built-in once this library supports
326
+ // TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
165
327
  type NoInfer<T> = T extends infer U ? U : never;
328
+
166
329
  /**
167
330
  Returns a boolean for whether the given type is `any`.
168
331
 
@@ -178,7 +341,7 @@ const typedObject = {a: 1, b: 2} as const;
178
341
  const anyObject: any = {a: 1, b: 2};
179
342
 
180
343
  function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
181
- return obj[key];
344
+ return obj[key];
182
345
  }
183
346
 
184
347
  const typedA = get(typedObject, 'a');
@@ -188,11 +351,41 @@ const anyA = get(anyObject, 'a');
188
351
  //=> any
189
352
  ```
190
353
 
191
- @group type-fest
354
+ @category Type Guard
355
+ @category Utilities
192
356
  */
193
357
  type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
194
358
  //#endregion
195
- //#region ../core/src/types/type-fest/simplify.d.ts
359
+ //#region ../../node_modules/type-fest/source/is-equal.d.ts
360
+ /**
361
+ Returns a boolean for whether the two given types are equal.
362
+
363
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
364
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
365
+
366
+ Use-cases:
367
+ - If you want to make a conditional branch based on the result of a comparison of two types.
368
+
369
+ @example
370
+ ```
371
+ import type {IsEqual} from 'type-fest';
372
+
373
+ // This type returns a boolean for whether the given array includes the given item.
374
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
375
+ type Includes<Value extends readonly any[], Item> =
376
+ Value extends readonly [Value[0], ...infer rest]
377
+ ? IsEqual<Value[0], Item> extends true
378
+ ? true
379
+ : Includes<rest, Item>
380
+ : false;
381
+ ```
382
+
383
+ @category Type Guard
384
+ @category Utilities
385
+ */
386
+ type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
387
+ //#endregion
388
+ //#region ../../node_modules/type-fest/source/simplify.d.ts
196
389
  /**
197
390
  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.
198
391
 
@@ -201,13 +394,13 @@ Useful to flatten the type output to improve type hints shown in editors. And al
201
394
  import type {Simplify} from 'type-fest';
202
395
 
203
396
  type PositionProps = {
204
- top: number;
205
- left: number;
397
+ top: number;
398
+ left: number;
206
399
  };
207
400
 
208
401
  type SizeProps = {
209
- width: number;
210
- height: number;
402
+ width: number;
403
+ height: number;
211
404
  };
212
405
 
213
406
  // In your editor, hovering over `Props` will show a flattened object with all the properties.
@@ -223,15 +416,15 @@ If the type definition must be an interface (perhaps it was defined in a third-p
223
416
  import type {Simplify} from 'type-fest';
224
417
 
225
418
  interface SomeInterface {
226
- foo: number;
227
- bar?: string;
228
- baz: number | undefined;
419
+ foo: number;
420
+ bar?: string;
421
+ baz: number | undefined;
229
422
  }
230
423
 
231
424
  type SomeType = {
232
- foo: number;
233
- bar?: string;
234
- baz: number | undefined;
425
+ foo: number;
426
+ bar?: string;
427
+ baz: number | undefined;
235
428
  };
236
429
 
237
430
  const literal = {foo: 123, bar: 'hello', baz: 456};
@@ -248,163 +441,11 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
248
441
 
249
442
  @link https://github.com/microsoft/TypeScript/issues/15300
250
443
  @see SimplifyDeep
251
-
252
- @group type-fest
444
+ @category Object
253
445
  */
254
446
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
255
447
  //#endregion
256
- //#region ../core/src/types/type-fest/union-to-intersection.d.ts
257
- /**
258
- Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
259
-
260
- Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
261
-
262
- @example
263
- ```
264
- import type {UnionToIntersection} from 'type-fest';
265
-
266
- type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
267
-
268
- type Intersection = UnionToIntersection<Union>;
269
- //=> {the(): void; great(arg: string): void; escape: boolean};
270
- ```
271
-
272
- A more applicable example which could make its way into your library code follows.
273
-
274
- @example
275
- ```
276
- import type {UnionToIntersection} from 'type-fest';
277
-
278
- class CommandOne {
279
- commands: {
280
- a1: () => undefined,
281
- b1: () => undefined,
282
- }
283
- }
284
-
285
- class CommandTwo {
286
- commands: {
287
- a2: (argA: string) => undefined,
288
- b2: (argB: string) => undefined,
289
- }
290
- }
291
-
292
- const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
293
- type Union = typeof union;
294
- //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
295
-
296
- type Intersection = UnionToIntersection<Union>;
297
- //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
298
- ```
299
-
300
- @group type-fest
301
- */
302
- type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
303
- //#endregion
304
- //#region ../core/src/types/type-fest/keys-of-union.d.ts
305
- /**
306
- Create a union of all keys from a given type, even those exclusive to specific union members.
307
-
308
- Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
309
-
310
- @link https://stackoverflow.com/a/49402091
311
-
312
- @example
313
- ```
314
- import type {KeysOfUnion} from 'type-fest';
315
-
316
- type A = {
317
- common: string;
318
- a: number;
319
- };
320
-
321
- type B = {
322
- common: string;
323
- b: string;
324
- };
325
-
326
- type C = {
327
- common: string;
328
- c: boolean;
329
- };
330
-
331
- type Union = A | B | C;
332
-
333
- type CommonKeys = keyof Union;
334
- //=> 'common'
335
-
336
- type AllKeys = KeysOfUnion<Union>;
337
- //=> 'common' | 'a' | 'b' | 'c'
338
- ```
339
-
340
- @group type-fest
341
- */
342
- type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
343
- //#endregion
344
- //#region ../core/src/types/type-fest/optional-keys-of.d.ts
345
- /**
346
- Extract all optional keys from the given type.
347
-
348
- This is useful when you want to create a new type that contains different type values for the optional keys only.
349
-
350
- @example
351
- ```
352
- import type {OptionalKeysOf, Except} from 'type-fest';
353
-
354
- interface User {
355
- name: string;
356
- surname: string;
357
-
358
- luckyNumber?: number;
359
- }
360
-
361
- const REMOVE_FIELD = Symbol('remove field symbol');
362
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
363
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
364
- };
365
-
366
- const update1: UpdateOperation<User> = {
367
- name: 'Alice'
368
- };
369
-
370
- const update2: UpdateOperation<User> = {
371
- name: 'Bob',
372
- luckyNumber: REMOVE_FIELD
373
- };
374
- ```
375
-
376
- @group type-fest
377
- */
378
- type OptionalKeysOf<BaseType extends object> = BaseType extends unknown ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) : never;
379
- //#endregion
380
- //#region ../core/src/types/type-fest/required-keys-of.d.ts
381
- /**
382
- Extract all required keys from the given type.
383
-
384
- 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...
385
-
386
- @example
387
- ```
388
- import type {RequiredKeysOf} from 'type-fest';
389
-
390
- declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
391
-
392
- interface User {
393
- name: string;
394
- surname: string;
395
-
396
- luckyNumber?: number;
397
- }
398
-
399
- const validator1 = createValidation<User>('name', value => value.length < 25);
400
- const validator2 = createValidation<User>('surname', value => value.length < 25);
401
- ```
402
-
403
- @group type-fest
404
- */
405
- type RequiredKeysOf<BaseType extends object> = BaseType extends unknown ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
406
- //#endregion
407
- //#region ../core/src/types/type-fest/omit-index-signature.d.ts
448
+ //#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
408
449
  /**
409
450
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
410
451
 
@@ -430,13 +471,13 @@ Instead of causing a type error like the above, you can also use a [conditional
430
471
 
431
472
  ```
432
473
  type Indexed = {} extends Record<string, unknown>
433
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
434
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
474
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
475
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
435
476
  // => '✅ `{}` is assignable to `Record<string, unknown>`'
436
477
 
437
478
  type Keyed = {} extends Record<'foo' | 'bar', unknown>
438
- ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
439
- : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
479
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
480
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
440
481
  // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
441
482
  ```
442
483
 
@@ -446,8 +487,8 @@ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-type
446
487
  import type {OmitIndexSignature} from 'type-fest';
447
488
 
448
489
  type OmitIndexSignature<ObjectType> = {
449
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
450
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
490
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
491
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
451
492
  };
452
493
  ```
453
494
 
@@ -457,12 +498,12 @@ type OmitIndexSignature<ObjectType> = {
457
498
  import type {OmitIndexSignature} from 'type-fest';
458
499
 
459
500
  type OmitIndexSignature<ObjectType> = {
460
- [KeyType in keyof ObjectType
461
- // Is `{}` assignable to `Record<KeyType, unknown>`?
462
- as {} extends Record<KeyType, unknown>
463
- ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
464
- : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
465
- ]: ObjectType[KeyType];
501
+ [KeyType in keyof ObjectType
502
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
503
+ as {} extends Record<KeyType, unknown>
504
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
505
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
506
+ ]: ObjectType[KeyType];
466
507
  };
467
508
  ```
468
509
 
@@ -473,19 +514,19 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
473
514
  import type {OmitIndexSignature} from 'type-fest';
474
515
 
475
516
  interface Example {
476
- // These index signatures will be removed.
477
- [x: string]: any
478
- [x: number]: any
479
- [x: symbol]: any
480
- [x: `head-${string}`]: string
481
- [x: `${string}-tail`]: string
482
- [x: `head-${string}-tail`]: string
483
- [x: `${bigint}`]: string
484
- [x: `embedded-${number}`]: string
485
-
486
- // These explicitly defined keys will remain.
487
- foo: 'bar';
488
- qux?: 'baz';
517
+ // These index signatures will be removed.
518
+ [x: string]: any
519
+ [x: number]: any
520
+ [x: symbol]: any
521
+ [x: `head-${string}`]: string
522
+ [x: `${string}-tail`]: string
523
+ [x: `head-${string}-tail`]: string
524
+ [x: `${bigint}`]: string
525
+ [x: `embedded-${number}`]: string
526
+
527
+ // These explicitly defined keys will remain.
528
+ foo: 'bar';
529
+ qux?: 'baz';
489
530
  }
490
531
 
491
532
  type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
@@ -493,12 +534,11 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
493
534
  ```
494
535
 
495
536
  @see PickIndexSignature
496
-
497
- @group type-fest
537
+ @category Object
498
538
  */
499
539
  type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
500
540
  //#endregion
501
- //#region ../core/src/types/type-fest/pick-index-signature.d.ts
541
+ //#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
502
542
  /**
503
543
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
504
544
 
@@ -511,21 +551,21 @@ import type {PickIndexSignature} from 'type-fest';
511
551
  declare const symbolKey: unique symbol;
512
552
 
513
553
  type Example = {
514
- // These index signatures will remain.
515
- [x: string]: unknown;
516
- [x: number]: unknown;
517
- [x: symbol]: unknown;
518
- [x: `head-${string}`]: string;
519
- [x: `${string}-tail`]: string;
520
- [x: `head-${string}-tail`]: string;
521
- [x: `${bigint}`]: string;
522
- [x: `embedded-${number}`]: string;
523
-
524
- // These explicitly defined keys will be removed.
525
- ['kebab-case-key']: string;
526
- [symbolKey]: string;
527
- foo: 'bar';
528
- qux?: 'baz';
554
+ // These index signatures will remain.
555
+ [x: string]: unknown;
556
+ [x: number]: unknown;
557
+ [x: symbol]: unknown;
558
+ [x: `head-${string}`]: string;
559
+ [x: `${string}-tail`]: string;
560
+ [x: `head-${string}-tail`]: string;
561
+ [x: `${bigint}`]: string;
562
+ [x: `embedded-${number}`]: string;
563
+
564
+ // These explicitly defined keys will be removed.
565
+ ['kebab-case-key']: string;
566
+ [symbolKey]: string;
567
+ foo: 'bar';
568
+ qux?: 'baz';
529
569
  };
530
570
 
531
571
  type ExampleIndexSignature = PickIndexSignature<Example>;
@@ -542,13 +582,14 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
542
582
  ```
543
583
 
544
584
  @see OmitIndexSignature
545
-
546
- @group type-fest
585
+ @category Object
547
586
  */
548
587
  type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
549
588
  //#endregion
550
- //#region ../core/src/types/type-fest/merge.d.ts
589
+ //#region ../../node_modules/type-fest/source/merge.d.ts
590
+ // Merges two objects without worrying about index signatures.
551
591
  type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
592
+
552
593
  /**
553
594
  Merge two types into a new type. Keys of the second type overrides keys of the first type.
554
595
 
@@ -557,17 +598,17 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
557
598
  import type {Merge} from 'type-fest';
558
599
 
559
600
  interface Foo {
560
- [x: string]: unknown;
561
- [x: number]: unknown;
562
- foo: string;
563
- bar: symbol;
601
+ [x: string]: unknown;
602
+ [x: number]: unknown;
603
+ foo: string;
604
+ bar: symbol;
564
605
  }
565
606
 
566
607
  type Bar = {
567
- [x: number]: number;
568
- [x: symbol]: unknown;
569
- bar: Date;
570
- baz: boolean;
608
+ [x: number]: number;
609
+ [x: symbol]: unknown;
610
+ bar: Date;
611
+ baz: boolean;
571
612
  };
572
613
 
573
614
  export type FooBar = Merge<Foo, Bar>;
@@ -581,11 +622,11 @@ export type FooBar = Merge<Foo, Bar>;
581
622
  // }
582
623
  ```
583
624
 
584
- @group type-fest
625
+ @category Object
585
626
  */
586
627
  type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
587
628
  //#endregion
588
- //#region ../core/src/types/type-fest/if-any.d.ts
629
+ //#region ../../node_modules/type-fest/source/if-any.d.ts
589
630
  /**
590
631
  An if-else-like type that resolves depending on whether the given type is `any`.
591
632
 
@@ -602,11 +643,14 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
602
643
  //=> 'bar'
603
644
  ```
604
645
 
605
- @group type-fest
646
+ @category Type Guard
647
+ @category Utilities
606
648
  */
607
649
  type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
608
650
  //#endregion
609
- //#region ../core/src/types/type-fest/internal/type.d.ts
651
+ //#region ../../node_modules/type-fest/source/internal/type.d.ts
652
+ // Should never happen
653
+
610
654
  /**
611
655
  An if-else-like type that resolves depending on whether the given type is `any` or `never`.
612
656
 
@@ -624,12 +668,10 @@ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
624
668
  type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
625
669
  //=> 'IS_NEVER'
626
670
  ```
627
-
628
- @group type-fest
629
671
  */
630
672
  type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
631
673
  //#endregion
632
- //#region ../core/src/types/type-fest/internal/object.d.ts
674
+ //#region ../../node_modules/type-fest/source/internal/object.d.ts
633
675
  /**
634
676
  Works similar to the built-in `Pick` utility type, except for the following differences:
635
677
  - Distributes over union types and allows picking keys from any member of the union type.
@@ -640,15 +682,15 @@ Works similar to the built-in `Pick` utility type, except for the following diff
640
682
  @example
641
683
  ```
642
684
  type ImageUpload = {
643
- url: string;
644
- size: number;
645
- thumbnailUrl: string;
685
+ url: string;
686
+ size: number;
687
+ thumbnailUrl: string;
646
688
  };
647
689
 
648
690
  type VideoUpload = {
649
- url: string;
650
- duration: number;
651
- encodingFormat: string;
691
+ url: string;
692
+ duration: number;
693
+ encodingFormat: string;
652
694
  };
653
695
 
654
696
  // Distributes over union types and allows picking keys from any member of the union type
@@ -666,8 +708,6 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
666
708
  // Doesn't pick `number` from a `string` index signature
667
709
  type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
668
710
  //=> {}
669
-
670
- @group type-fest
671
711
  */
672
712
  type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
673
713
  /**
@@ -721,12 +761,11 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
721
761
  // ~~~~~~~~~~~~~~~~
722
762
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
723
763
  ```
724
-
725
- @group type-fest
726
764
  */
727
- type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny$1<SpecifiedOptions, Defaults, IfNever$1<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
765
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny$1<SpecifiedOptions, Defaults, IfNever$1<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
766
+ >>;
728
767
  //#endregion
729
- //#region ../core/src/types/type-fest/except.d.ts
768
+ //#region ../../node_modules/type-fest/source/except.d.ts
730
769
  /**
731
770
  Filter out keys from an object.
732
771
 
@@ -758,16 +797,15 @@ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ?
758
797
  type ExceptOptions = {
759
798
  /**
760
799
  Disallow assigning non-specified properties.
761
-
762
- Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
763
-
764
- @default false
800
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
801
+ @default false
765
802
  */
766
803
  requireExactProps?: boolean;
767
804
  };
768
805
  type DefaultExceptOptions = {
769
806
  requireExactProps: false;
770
807
  };
808
+
771
809
  /**
772
810
  Create a type from an object type without certain keys.
773
811
 
@@ -782,8 +820,8 @@ This type was proposed to the TypeScript team, which declined it, saying they pr
782
820
  import type {Except} from 'type-fest';
783
821
 
784
822
  type Foo = {
785
- a: number;
786
- b: string;
823
+ a: number;
824
+ b: string;
787
825
  };
788
826
 
789
827
  type FooWithoutA = Except<Foo, 'a'>;
@@ -803,10 +841,10 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
803
841
  // Consider the following example:
804
842
 
805
843
  type UserData = {
806
- [metadata: string]: string;
807
- email: string;
808
- name: string;
809
- role: 'admin' | 'user';
844
+ [metadata: string]: string;
845
+ email: string;
846
+ name: string;
847
+ role: 'admin' | 'user';
810
848
  };
811
849
 
812
850
  // `Omit` clearly doesn't behave as expected in this case:
@@ -819,12 +857,12 @@ type PostPayload = Except<UserData, 'email'>;
819
857
  //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
820
858
  ```
821
859
 
822
- @group type-fest
860
+ @category Object
823
861
  */
824
862
  type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
825
- type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options["requireExactProps"] extends true ? Partial<Record<KeysType, never>> : {});
863
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
826
864
  //#endregion
827
- //#region ../core/src/types/type-fest/require-at-least-one.d.ts
865
+ //#region ../../node_modules/type-fest/source/require-at-least-one.d.ts
828
866
  /**
829
867
  Create a type that requires at least one of the given keys. The remaining keys are kept as is.
830
868
 
@@ -833,23 +871,80 @@ Create a type that requires at least one of the given keys. The remaining keys a
833
871
  import type {RequireAtLeastOne} from 'type-fest';
834
872
 
835
873
  type Responder = {
836
- text?: () => string;
837
- json?: () => string;
838
- secure?: boolean;
874
+ text?: () => string;
875
+ json?: () => string;
876
+ secure?: boolean;
839
877
  };
840
878
 
841
879
  const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
842
- json: () => '{"message": "ok"}',
843
- secure: true
880
+ json: () => '{"message": "ok"}',
881
+ secure: true
844
882
  };
845
883
  ```
846
884
 
847
- @group type-fest
885
+ @category Object
848
886
  */
849
887
  type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireAtLeastOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
850
- type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
888
+ type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
889
+ // For each `Key` in `KeysType` make a mapped type:
890
+ [Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
891
+ // 1. Make `Key`'s type required
892
+ // 2. Make all other keys in `KeysType` optional
893
+ Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] &
894
+ // 3. Add the remaining keys not in `KeysType`
895
+ Except<ObjectType, KeysType>;
896
+ //#endregion
897
+ //#region ../../node_modules/type-fest/source/set-required.d.ts
898
+ /**
899
+ Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
900
+
901
+ Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
902
+
903
+ @example
904
+ ```
905
+ import type {SetRequired} from 'type-fest';
906
+
907
+ type Foo = {
908
+ a?: number;
909
+ b: string;
910
+ c?: boolean;
911
+ }
912
+
913
+ type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
914
+ // type SomeRequired = {
915
+ // a?: number;
916
+ // b: string; // Was already required and still is.
917
+ // c: boolean; // Is now required.
918
+ // }
919
+
920
+ // Set specific indices in an array to be required.
921
+ type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
922
+ //=> [number, number, number?]
923
+ ```
924
+
925
+ @category Object
926
+ */
927
+ type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? IfArrayReadonly<BaseType, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
928
+ // Pick just the keys that are optional from the base type.
929
+ Except<BaseType, Keys> &
930
+ // Pick the keys that should be required from the base type and make them required.
931
+ Required<HomomorphicPick<BaseType, Keys>>>;
932
+ /**
933
+ Remove the optional modifier from the specified keys in an array.
934
+ */
935
+ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
936
+ ? keyof TArray & `${number}` extends never
937
+ // Exit if `TArray` is empty (e.g., []), or
938
+ // `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
939
+ ? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
940
+ ? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
941
+ ? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
942
+ // If the current element is optional, but it doesn't need to be required,
943
+ // then we can exit early, since no further elements can now be made required.
944
+ : [...Accumulator, ...TArray] : SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, TArray[0]]> : never // Should never happen, since `[(infer F)?, ...infer R]` is a top-type for arrays.
945
+ : never; // Should never happen
851
946
  //#endregion
852
- //#region ../core/src/types/type-fest/set-non-nullable.d.ts
947
+ //#region ../../node_modules/type-fest/source/set-non-nullable.d.ts
853
948
  /**
854
949
  Create a type that makes the given keys non-nullable, where the remaining keys are kept as is.
855
950
 
@@ -862,9 +957,9 @@ Use-case: You want to define a single model where the only thing that changes is
862
957
  import type {SetNonNullable} from 'type-fest';
863
958
 
864
959
  type Foo = {
865
- a: number | null;
866
- b: string | undefined;
867
- c?: boolean | null;
960
+ a: number | null;
961
+ b: string | undefined;
962
+ c?: boolean | null;
868
963
  }
869
964
 
870
965
  type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
@@ -882,46 +977,10 @@ type AllNonNullable = SetNonNullable<Foo>;
882
977
  // }
883
978
  ```
884
979
 
885
- @group type-fest
980
+ @category Object
886
981
  */
887
982
  type SetNonNullable<BaseType, Keys extends keyof BaseType = keyof BaseType> = { [Key in keyof BaseType]: Key extends Keys ? NonNullable<BaseType[Key]> : BaseType[Key] };
888
983
  //#endregion
889
- //#region ../core/src/types/type-fest/set-required.d.ts
890
- /**
891
- Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
892
-
893
- Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
894
-
895
- @example
896
- ```
897
- import type {SetRequired} from 'type-fest';
898
-
899
- type Foo = {
900
- a?: number;
901
- b: string;
902
- c?: boolean;
903
- }
904
-
905
- type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
906
- // type SomeRequired = {
907
- // a?: number;
908
- // b: string; // Was already required and still is.
909
- // c: boolean; // Is now required.
910
- // }
911
-
912
- // Set specific indices in an array to be required.
913
- type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
914
- //=> [number, number, number?]
915
- ```
916
-
917
- @group type-fest
918
- */
919
- type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? IfArrayReadonly<BaseType, Readonly<ResultantArray>, ResultantArray> : never : Simplify<Except<BaseType, Keys> & Required<HomomorphicPick<BaseType, Keys>>>;
920
- /**
921
- Remove the optional modifier from the specified keys in an array.
922
- */
923
- type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown ? keyof TArray & `${number}` extends never ? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? "0" extends OptionalKeysOf<TArray> ? `${Counter["length"]}` extends `${Keys & (string | number)}` ? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]> : [...Accumulator, ...TArray] : SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, TArray[0]]> : never : never;
924
- //#endregion
925
984
  //#region ../core/src/types/options.d.ts
926
985
  type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
927
986
  /**
@@ -1069,6 +1128,12 @@ interface CommonRuleAndGroupProperties {
1069
1128
  path?: Path;
1070
1129
  id?: string;
1071
1130
  disabled?: boolean;
1131
+ /**
1132
+ * Whether this rule or group is muted. When muted, the rule or group
1133
+ * is excluded from query export formats (SQL, JSON, MongoDB, etc.).
1134
+ * For groups, muting recursively mutes all children.
1135
+ */
1136
+ muted?: boolean;
1072
1137
  }
1073
1138
  /**
1074
1139
  * The main rule type. The `field`, `operator`, and `value` properties
@@ -1400,6 +1465,14 @@ interface Classnames {
1400
1465
  */
1401
1466
  lockGroup: Classname;
1402
1467
  /**
1468
+ * Classnames applied to the `<button>` to mute a Rule.
1469
+ */
1470
+ muteRule: Classname;
1471
+ /**
1472
+ * Classnames applied to the `<button>` to mute a RuleGroup.
1473
+ */
1474
+ muteGroup: Classname;
1475
+ /**
1403
1476
  * Classnames applied to the `<select>` control for value sources.
1404
1477
  */
1405
1478
  valueSource: Classname;
@@ -1451,6 +1524,10 @@ interface Classnames {
1451
1524
  */
1452
1525
  disabled: Classname;
1453
1526
  /**
1527
+ * Classname(s) applied to muted elements.
1528
+ */
1529
+ muted: Classname;
1530
+ /**
1454
1531
  * Classname(s) applied to each element in a series of value editors.
1455
1532
  */
1456
1533
  valueListItem: Classname;
@@ -1464,6 +1541,83 @@ interface Classnames {
1464
1541
  hasSubQuery: Classname;
1465
1542
  }
1466
1543
  /**
1544
+ * Placeholder strings for option lists.
1545
+ *
1546
+ * @group Props
1547
+ */
1548
+ interface Placeholder {
1549
+ /**
1550
+ * Value for the placeholder field option if autoSelectField is false,
1551
+ * or the placeholder operator option if autoSelectOperator is false.
1552
+ */
1553
+ placeholderName?: string;
1554
+ /**
1555
+ * Label for the placeholder field option if autoSelectField is false,
1556
+ * or the placeholder operator option if autoSelectOperator is false.
1557
+ */
1558
+ placeholderLabel?: string;
1559
+ /**
1560
+ * Label for the placeholder field optgroup if autoSelectField is false,
1561
+ * or the placeholder operator optgroup if autoSelectOperator is false.
1562
+ */
1563
+ placeholderGroupLabel?: string;
1564
+ }
1565
+ /**
1566
+ * A translation for a component with `title` only.
1567
+ *
1568
+ * @group Props
1569
+ */
1570
+ interface BaseTranslation {
1571
+ title?: string;
1572
+ }
1573
+ /**
1574
+ * A translation for a component with `title` and `label`.
1575
+ *
1576
+ * @group Props
1577
+ */
1578
+ interface BaseTranslationWithLabel<LabelType = string> extends BaseTranslation {
1579
+ label?: LabelType;
1580
+ }
1581
+ /**
1582
+ * A translation for a component with `title` and a placeholder.
1583
+ *
1584
+ * @group Props
1585
+ */
1586
+ interface BaseTranslationWithPlaceholders extends BaseTranslation, Placeholder {}
1587
+ /**
1588
+ * The shape of the `translations` prop.
1589
+ *
1590
+ * @group Props
1591
+ */
1592
+ interface BaseTranslations<LabelType = string> {
1593
+ fields: BaseTranslationWithPlaceholders;
1594
+ operators: BaseTranslationWithPlaceholders;
1595
+ values: BaseTranslationWithPlaceholders;
1596
+ matchMode: BaseTranslation;
1597
+ matchThreshold: BaseTranslation;
1598
+ value: BaseTranslation;
1599
+ removeRule: BaseTranslationWithLabel<LabelType>;
1600
+ removeGroup: BaseTranslationWithLabel<LabelType>;
1601
+ addRule: BaseTranslationWithLabel<LabelType>;
1602
+ addGroup: BaseTranslationWithLabel<LabelType>;
1603
+ combinators: BaseTranslation;
1604
+ notToggle: BaseTranslationWithLabel<LabelType>;
1605
+ cloneRule: BaseTranslationWithLabel<LabelType>;
1606
+ cloneRuleGroup: BaseTranslationWithLabel<LabelType>;
1607
+ shiftActionUp: BaseTranslationWithLabel<LabelType>;
1608
+ shiftActionDown: BaseTranslationWithLabel<LabelType>;
1609
+ dragHandle: BaseTranslationWithLabel<LabelType>;
1610
+ lockRule: BaseTranslationWithLabel<LabelType>;
1611
+ lockGroup: BaseTranslationWithLabel<LabelType>;
1612
+ lockRuleDisabled: BaseTranslationWithLabel<LabelType>;
1613
+ lockGroupDisabled: BaseTranslationWithLabel<LabelType>;
1614
+ muteRule: BaseTranslationWithLabel<LabelType>;
1615
+ muteGroup: BaseTranslationWithLabel<LabelType>;
1616
+ unmuteRule: BaseTranslationWithLabel<LabelType>;
1617
+ unmuteGroup: BaseTranslationWithLabel<LabelType>;
1618
+ valueSourceSelector: BaseTranslation;
1619
+ }
1620
+ /**
1467
1621
  * Functions included in the `actions` prop passed to every subcomponent.
1468
1622
  *
1469
1623
  * @group Props
@@ -1527,7 +1681,8 @@ interface UseRuleGroup extends RuleGroupProps {
1527
1681
  addGroup: ActionElementEventHandler;
1528
1682
  addRule: ActionElementEventHandler;
1529
1683
  accessibleDescription: string;
1530
- classNames: Pick<{ [k in keyof Classnames]: string }, "header" | "shiftActions" | "dragHandle" | "combinators" | "notToggle" | "addRule" | "addGroup" | "cloneGroup" | "lockGroup" | "removeGroup" | "body">;
1684
+ muted?: boolean;
1685
+ classNames: Pick<{ [k in keyof Classnames]: string }, "header" | "shiftActions" | "dragHandle" | "combinators" | "notToggle" | "addRule" | "addGroup" | "cloneGroup" | "lockGroup" | "muteGroup" | "removeGroup" | "body">;
1531
1686
  cloneGroup: ActionElementEventHandler;
1532
1687
  onCombinatorChange: ValueChangeEventHandler;
1533
1688
  onGroupAdd: (group: RuleGroupTypeAny, parentPath: Path, context?: any) => void;
@@ -1543,6 +1698,7 @@ interface UseRuleGroup extends RuleGroupProps {
1543
1698
  shiftGroupDown: (event?: MouseEvent, context?: any) => void;
1544
1699
  shiftGroupUp: (event?: MouseEvent, context?: any) => void;
1545
1700
  toggleLockGroup: ActionElementEventHandler;
1701
+ toggleMuteGroup: ActionElementEventHandler;
1546
1702
  validationClassName: string;
1547
1703
  validationResult: boolean | ValidationResult;
1548
1704
  }
@@ -1686,74 +1842,13 @@ type VersatileSelectorProps = ValueSelectorProps & Partial<FieldSelectorProps> &
1686
1842
  *
1687
1843
  * @group Props
1688
1844
  */
1689
- interface TranslationWithLabel extends Translation {
1690
- label?: ReactNode;
1691
- }
1692
- /**
1693
- * A translation for a component with `title` only.
1694
- *
1695
- * @group Props
1696
- */
1697
- interface Translation {
1698
- title?: string;
1699
- }
1700
- /**
1701
- * Placeholder strings for option lists.
1702
- *
1703
- * @group Props
1704
- */
1705
- interface Placeholder {
1706
- /**
1707
- * Value for the placeholder field option if autoSelectField is false,
1708
- * or the placeholder operator option if autoSelectOperator is false.
1709
- */
1710
- placeholderName?: string;
1711
- /**
1712
- * Label for the placeholder field option if autoSelectField is false,
1713
- * or the placeholder operator option if autoSelectOperator is false.
1714
- */
1715
- placeholderLabel?: string;
1716
- /**
1717
- * Label for the placeholder field optgroup if autoSelectField is false,
1718
- * or the placeholder operator optgroup if autoSelectOperator is false.
1719
- */
1720
- placeholderGroupLabel?: string;
1721
- }
1722
- /**
1723
- * A translation for a component with `title` and a placeholder.
1724
- *
1725
- * @group Props
1726
- */
1727
- interface TranslationWithPlaceholders extends Translation, Placeholder {}
1845
+ interface TranslationWithLabel extends BaseTranslationWithLabel<ReactNode> {}
1728
1846
  /**
1729
1847
  * The shape of the `translations` prop.
1730
1848
  *
1731
1849
  * @group Props
1732
1850
  */
1733
- interface Translations {
1734
- fields: TranslationWithPlaceholders;
1735
- operators: TranslationWithPlaceholders;
1736
- values: TranslationWithPlaceholders;
1737
- matchMode: Translation;
1738
- matchThreshold: Translation;
1739
- value: Translation;
1740
- removeRule: TranslationWithLabel;
1741
- removeGroup: TranslationWithLabel;
1742
- addRule: TranslationWithLabel;
1743
- addGroup: TranslationWithLabel;
1744
- combinators: Translation;
1745
- notToggle: TranslationWithLabel;
1746
- cloneRule: TranslationWithLabel;
1747
- cloneRuleGroup: TranslationWithLabel;
1748
- shiftActionUp: TranslationWithLabel;
1749
- shiftActionDown: TranslationWithLabel;
1750
- dragHandle: TranslationWithLabel;
1751
- lockRule: TranslationWithLabel;
1752
- lockGroup: TranslationWithLabel;
1753
- lockRuleDisabled: TranslationWithLabel;
1754
- lockGroupDisabled: TranslationWithLabel;
1755
- valueSourceSelector: Translation;
1756
- }
1851
+ interface Translations extends BaseTranslations<ReactNode> {}
1757
1852
  /**
1758
1853
  * Props passed to every action component (rendered as `<button>` by default).
1759
1854
  *
@@ -1957,6 +2052,18 @@ type ControlElementsProp<F extends FullField, O extends string> = Partial<{
1957
2052
  */
1958
2053
  lockRuleAction: ComponentType<ActionProps> | null;
1959
2054
  /**
2055
+ * Mutes the current group (sets the `muted` property to `true`).
2056
+ *
2057
+ * @default ActionElement
2058
+ */
2059
+ muteGroupAction: ComponentType<ActionProps> | null;
2060
+ /**
2061
+ * Mutes the current rule (sets the `muted` property to `true`).
2062
+ *
2063
+ * @default ActionElement
2064
+ */
2065
+ muteRuleAction: ComponentType<ActionProps> | null;
2066
+ /**
1960
2067
  * Selects the `match` property for the current rule.
1961
2068
  *
1962
2069
  * @default MatchModeEditor
@@ -2086,6 +2193,7 @@ interface Schema<F extends FullField, O extends string> {
2086
2193
  showShiftActions: boolean;
2087
2194
  showCloneButtons: boolean;
2088
2195
  showLockButtons: boolean;
2196
+ showMuteButtons: boolean;
2089
2197
  autoSelectField: boolean;
2090
2198
  autoSelectOperator: boolean;
2091
2199
  autoSelectValue: boolean;
@@ -2106,6 +2214,7 @@ interface CommonRuleAndGroupProps<F extends FullField = FullField, O extends str
2106
2214
  id?: string;
2107
2215
  path: Path;
2108
2216
  parentDisabled?: boolean;
2217
+ parentMuted?: boolean;
2109
2218
  translations: Translations;
2110
2219
  schema: Schema<F, O>;
2111
2220
  actions: QueryActions;
@@ -2524,6 +2633,12 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
2524
2633
  */
2525
2634
  showLockButtons?: boolean;
2526
2635
  /**
2636
+ * Show the "Mute rule" and "Mute group" buttons.
2637
+ *
2638
+ * @default false
2639
+ */
2640
+ showMuteButtons?: boolean;
2641
+ /**
2527
2642
  * Reset the `operator` and `value` when the `field` changes.
2528
2643
  *
2529
2644
  * @default true