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