@react-querybuilder/bootstrap 8.9.2 → 8.11.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 +775 -699
- package/dist/cjs/react-querybuilder_bootstrap.cjs.production.d.ts +775 -699
- package/dist/react-querybuilder_bootstrap.d.mts +775 -699
- package/dist/react-querybuilder_bootstrap.legacy-esm.d.ts +775 -699
- package/dist/react-querybuilder_bootstrap.legacy-esm.js +5 -5
- package/dist/react-querybuilder_bootstrap.production.d.mts +775 -699
- package/package.json +11 -11
|
@@ -1,408 +1,481 @@
|
|
|
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/union-to-intersection.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
|
|
7
|
+
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).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
9
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
@example
|
|
12
|
+
```
|
|
13
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
14
|
+
|
|
15
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
16
|
+
|
|
17
|
+
type Intersection = UnionToIntersection<Union>;
|
|
18
|
+
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
A more applicable example which could make its way into your library code follows.
|
|
14
22
|
|
|
15
23
|
@example
|
|
16
24
|
```
|
|
17
|
-
import type {
|
|
25
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
class CommandOne {
|
|
28
|
+
commands: {
|
|
29
|
+
a1: () => undefined,
|
|
30
|
+
b1: () => undefined,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class CommandTwo {
|
|
35
|
+
commands: {
|
|
36
|
+
a2: (argA: string) => undefined,
|
|
37
|
+
b2: (argB: string) => undefined,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
42
|
+
type Union = typeof union;
|
|
43
|
+
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
44
|
+
|
|
45
|
+
type Intersection = UnionToIntersection<Union>;
|
|
46
|
+
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
27
47
|
```
|
|
28
48
|
|
|
29
|
-
@
|
|
30
|
-
*/
|
|
31
|
-
type
|
|
49
|
+
@category Type
|
|
50
|
+
*/
|
|
51
|
+
type UnionToIntersection<Union> = (
|
|
52
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
53
|
+
// `Union` into a [distributive conditional
|
|
54
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
55
|
+
Union extends unknown
|
|
56
|
+
// The union type is used as the only argument to a function since the union
|
|
57
|
+
// of function arguments is an intersection.
|
|
58
|
+
? (distributedUnion: Union) => void
|
|
59
|
+
// This won't happen.
|
|
60
|
+
: never
|
|
61
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
62
|
+
// arguments of unions of functions as an intersection of the union.
|
|
63
|
+
) extends ((mergedIntersection: infer Intersection) => void)
|
|
64
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
65
|
+
? Intersection & Union : never;
|
|
32
66
|
//#endregion
|
|
33
|
-
//#region
|
|
67
|
+
//#region ../../node_modules/type-fest/source/keys-of-union.d.ts
|
|
34
68
|
/**
|
|
35
|
-
|
|
69
|
+
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
36
70
|
|
|
37
|
-
|
|
38
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
39
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
71
|
+
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
40
72
|
|
|
41
|
-
|
|
73
|
+
@link https://stackoverflow.com/a/49402091
|
|
42
74
|
|
|
43
75
|
@example
|
|
44
76
|
```
|
|
45
|
-
import type {
|
|
77
|
+
import type {KeysOfUnion} from 'type-fest';
|
|
46
78
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
52
|
-
>;
|
|
79
|
+
type A = {
|
|
80
|
+
common: string;
|
|
81
|
+
a: number;
|
|
82
|
+
};
|
|
53
83
|
|
|
54
|
-
type
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
type B = {
|
|
85
|
+
common: string;
|
|
86
|
+
b: string;
|
|
87
|
+
};
|
|
58
88
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
89
|
+
type C = {
|
|
90
|
+
common: string;
|
|
91
|
+
c: boolean;
|
|
92
|
+
};
|
|
64
93
|
|
|
65
|
-
|
|
66
|
-
//=> never
|
|
94
|
+
type Union = A | B | C;
|
|
67
95
|
|
|
68
|
-
|
|
69
|
-
//=>
|
|
96
|
+
type CommonKeys = keyof Union;
|
|
97
|
+
//=> 'common'
|
|
98
|
+
|
|
99
|
+
type AllKeys = KeysOfUnion<Union>;
|
|
100
|
+
//=> 'common' | 'a' | 'b' | 'c'
|
|
70
101
|
```
|
|
71
102
|
|
|
72
|
-
@
|
|
103
|
+
@category Object
|
|
73
104
|
*/
|
|
74
|
-
type
|
|
105
|
+
type KeysOfUnion<ObjectType> =
|
|
106
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
107
|
+
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
75
108
|
//#endregion
|
|
76
|
-
//#region
|
|
109
|
+
//#region ../../node_modules/type-fest/source/is-any.d.ts
|
|
77
110
|
/**
|
|
78
|
-
|
|
111
|
+
Returns a boolean for whether the given type is `any`.
|
|
79
112
|
|
|
80
|
-
@
|
|
113
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
114
|
+
|
|
115
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
81
116
|
|
|
82
117
|
@example
|
|
83
118
|
```
|
|
84
|
-
import type {
|
|
119
|
+
import type {IsAny} from 'type-fest';
|
|
85
120
|
|
|
86
|
-
|
|
87
|
-
|
|
121
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
122
|
+
const anyObject: any = {a: 1, b: 2};
|
|
88
123
|
|
|
89
|
-
|
|
90
|
-
|
|
124
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
125
|
+
return obj[key];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const typedA = get(typedObject, 'a');
|
|
129
|
+
//=> 1
|
|
130
|
+
|
|
131
|
+
const anyA = get(anyObject, 'a');
|
|
132
|
+
//=> any
|
|
91
133
|
```
|
|
92
134
|
|
|
93
|
-
@
|
|
135
|
+
@category Type Guard
|
|
136
|
+
@category Utilities
|
|
94
137
|
*/
|
|
95
|
-
type
|
|
138
|
+
type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
|
|
96
139
|
//#endregion
|
|
97
|
-
//#region
|
|
140
|
+
//#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
98
141
|
/**
|
|
99
|
-
|
|
142
|
+
Returns a boolean for whether the given key is an optional key of type.
|
|
100
143
|
|
|
101
|
-
|
|
144
|
+
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
102
145
|
|
|
103
146
|
@example
|
|
104
147
|
```
|
|
105
|
-
import type {
|
|
148
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
106
149
|
|
|
107
|
-
|
|
150
|
+
interface User {
|
|
151
|
+
name: string;
|
|
152
|
+
surname: string;
|
|
108
153
|
|
|
109
|
-
|
|
110
|
-
|
|
154
|
+
luckyNumber?: number;
|
|
155
|
+
}
|
|
111
156
|
|
|
112
|
-
|
|
157
|
+
interface Admin {
|
|
158
|
+
name: string;
|
|
159
|
+
surname?: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
113
163
|
//=> true
|
|
114
164
|
|
|
115
|
-
type
|
|
165
|
+
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
116
166
|
//=> false
|
|
117
|
-
```
|
|
118
167
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type UnknownArray = readonly unknown[];
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region ../core/src/types/type-fest/internal/array.d.ts
|
|
168
|
+
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
169
|
+
//=> boolean
|
|
124
170
|
|
|
125
|
-
|
|
126
|
-
|
|
171
|
+
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
172
|
+
//=> false
|
|
173
|
+
|
|
174
|
+
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
175
|
+
//=> boolean
|
|
176
|
+
```
|
|
127
177
|
|
|
128
|
-
@
|
|
178
|
+
@category Type Guard
|
|
179
|
+
@category Utilities
|
|
129
180
|
*/
|
|
130
|
-
type
|
|
181
|
+
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
|
|
131
184
|
/**
|
|
132
|
-
|
|
185
|
+
Extract all optional keys from the given type.
|
|
133
186
|
|
|
134
|
-
|
|
187
|
+
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
135
188
|
|
|
136
189
|
@example
|
|
137
190
|
```
|
|
138
|
-
import type {
|
|
191
|
+
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
139
192
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
: never;
|
|
193
|
+
interface User {
|
|
194
|
+
name: string;
|
|
195
|
+
surname: string;
|
|
144
196
|
|
|
145
|
-
|
|
146
|
-
|
|
197
|
+
luckyNumber?: number;
|
|
198
|
+
}
|
|
147
199
|
|
|
148
|
-
|
|
149
|
-
|
|
200
|
+
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
201
|
+
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
202
|
+
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
203
|
+
};
|
|
150
204
|
|
|
151
|
-
|
|
152
|
-
|
|
205
|
+
const update1: UpdateOperation<User> = {
|
|
206
|
+
name: 'Alice'
|
|
207
|
+
};
|
|
153
208
|
|
|
154
|
-
|
|
155
|
-
|
|
209
|
+
const update2: UpdateOperation<User> = {
|
|
210
|
+
name: 'Bob',
|
|
211
|
+
luckyNumber: REMOVE_FIELD
|
|
212
|
+
};
|
|
156
213
|
```
|
|
157
214
|
|
|
158
|
-
@
|
|
215
|
+
@category Utilities
|
|
159
216
|
*/
|
|
160
|
-
type
|
|
217
|
+
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
218
|
+
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
219
|
+
: never;
|
|
161
220
|
//#endregion
|
|
162
|
-
//#region
|
|
163
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
221
|
+
//#region ../../node_modules/type-fest/source/required-keys-of.d.ts
|
|
164
222
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
223
|
+
Extract all required keys from the given type.
|
|
168
224
|
|
|
169
|
-
|
|
225
|
+
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...
|
|
170
226
|
|
|
171
227
|
@example
|
|
172
228
|
```
|
|
173
|
-
import type {
|
|
229
|
+
import type {RequiredKeysOf} from 'type-fest';
|
|
174
230
|
|
|
175
|
-
|
|
176
|
-
const anyObject: any = {a: 1, b: 2};
|
|
231
|
+
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
177
232
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
233
|
+
interface User {
|
|
234
|
+
name: string;
|
|
235
|
+
surname: string;
|
|
181
236
|
|
|
182
|
-
|
|
183
|
-
|
|
237
|
+
luckyNumber?: number;
|
|
238
|
+
}
|
|
184
239
|
|
|
185
|
-
const
|
|
186
|
-
|
|
240
|
+
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
241
|
+
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
187
242
|
```
|
|
188
243
|
|
|
189
|
-
@
|
|
244
|
+
@category Utilities
|
|
190
245
|
*/
|
|
191
|
-
type
|
|
246
|
+
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
247
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
192
248
|
//#endregion
|
|
193
|
-
//#region
|
|
249
|
+
//#region ../../node_modules/type-fest/source/is-never.d.ts
|
|
194
250
|
/**
|
|
195
|
-
|
|
251
|
+
Returns a boolean for whether the given type is `never`.
|
|
252
|
+
|
|
253
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
254
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
255
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
256
|
+
|
|
257
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
196
258
|
|
|
197
259
|
@example
|
|
198
260
|
```
|
|
199
|
-
import type {
|
|
261
|
+
import type {IsNever, And} from 'type-fest';
|
|
200
262
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
263
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
264
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
265
|
+
And<
|
|
266
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
267
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
268
|
+
>;
|
|
205
269
|
|
|
206
|
-
type
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
270
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
271
|
+
AreStringsEqual<I, O> extends true
|
|
272
|
+
? never
|
|
273
|
+
: void;
|
|
210
274
|
|
|
211
|
-
|
|
212
|
-
|
|
275
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
276
|
+
if (input === output) {
|
|
277
|
+
process.exit(0);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
endIfEqual('abc', 'abc');
|
|
282
|
+
//=> never
|
|
283
|
+
|
|
284
|
+
endIfEqual('abc', '123');
|
|
285
|
+
//=> void
|
|
213
286
|
```
|
|
214
287
|
|
|
215
|
-
|
|
288
|
+
@category Type Guard
|
|
289
|
+
@category Utilities
|
|
290
|
+
*/
|
|
291
|
+
type IsNever<T$1> = [T$1] extends [never] ? true : false;
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region ../../node_modules/type-fest/source/if.d.ts
|
|
294
|
+
/**
|
|
295
|
+
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
216
296
|
|
|
217
|
-
|
|
297
|
+
Use-cases:
|
|
298
|
+
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
299
|
+
|
|
300
|
+
Note:
|
|
301
|
+
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
302
|
+
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
218
303
|
|
|
219
304
|
@example
|
|
220
305
|
```
|
|
221
|
-
import
|
|
306
|
+
import {If} from 'type-fest';
|
|
222
307
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
bar?: string;
|
|
226
|
-
baz: number | undefined;
|
|
227
|
-
}
|
|
308
|
+
type A = If<true, 'yes', 'no'>;
|
|
309
|
+
//=> 'yes'
|
|
228
310
|
|
|
229
|
-
type
|
|
230
|
-
|
|
231
|
-
bar?: string;
|
|
232
|
-
baz: number | undefined;
|
|
233
|
-
};
|
|
311
|
+
type B = If<false, 'yes', 'no'>;
|
|
312
|
+
//=> 'no'
|
|
234
313
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const someInterface: SomeInterface = literal;
|
|
314
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
315
|
+
//=> 'yes' | 'no'
|
|
238
316
|
|
|
239
|
-
|
|
317
|
+
type D = If<any, 'yes', 'no'>;
|
|
318
|
+
//=> 'yes' | 'no'
|
|
240
319
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
244
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
320
|
+
type E = If<never, 'yes', 'no'>;
|
|
321
|
+
//=> 'no'
|
|
245
322
|
```
|
|
246
323
|
|
|
247
|
-
@
|
|
248
|
-
|
|
324
|
+
@example
|
|
325
|
+
```
|
|
326
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
249
327
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region ../core/src/types/type-fest/union-to-intersection.d.ts
|
|
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).
|
|
328
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
329
|
+
//=> 'not any'
|
|
257
330
|
|
|
258
|
-
|
|
331
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
332
|
+
//=> 'is never'
|
|
333
|
+
```
|
|
259
334
|
|
|
260
335
|
@example
|
|
261
336
|
```
|
|
262
|
-
import
|
|
337
|
+
import {If, IsEqual} from 'type-fest';
|
|
263
338
|
|
|
264
|
-
type
|
|
339
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
265
340
|
|
|
266
|
-
type
|
|
267
|
-
//=>
|
|
341
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
342
|
+
//=> 'equal'
|
|
343
|
+
|
|
344
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
345
|
+
//=> 'not equal'
|
|
268
346
|
```
|
|
269
347
|
|
|
270
|
-
|
|
348
|
+
@category Type Guard
|
|
349
|
+
@category Utilities
|
|
350
|
+
*/
|
|
351
|
+
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region ../../node_modules/type-fest/source/unknown-array.d.ts
|
|
354
|
+
/**
|
|
355
|
+
Represents an array with `unknown` value.
|
|
356
|
+
|
|
357
|
+
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
271
358
|
|
|
272
359
|
@example
|
|
273
360
|
```
|
|
274
|
-
import type {
|
|
361
|
+
import type {UnknownArray} from 'type-fest';
|
|
275
362
|
|
|
276
|
-
|
|
277
|
-
commands: {
|
|
278
|
-
a1: () => undefined,
|
|
279
|
-
b1: () => undefined,
|
|
280
|
-
}
|
|
281
|
-
}
|
|
363
|
+
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
282
364
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
a2: (argA: string) => undefined,
|
|
286
|
-
b2: (argB: string) => undefined,
|
|
287
|
-
}
|
|
288
|
-
}
|
|
365
|
+
type A = IsArray<['foo']>;
|
|
366
|
+
//=> true
|
|
289
367
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
368
|
+
type B = IsArray<readonly number[]>;
|
|
369
|
+
//=> true
|
|
293
370
|
|
|
294
|
-
type
|
|
295
|
-
//=>
|
|
371
|
+
type C = IsArray<string>;
|
|
372
|
+
//=> false
|
|
296
373
|
```
|
|
297
374
|
|
|
298
|
-
@
|
|
375
|
+
@category Type
|
|
376
|
+
@category Array
|
|
299
377
|
*/
|
|
300
|
-
type
|
|
378
|
+
type UnknownArray = readonly unknown[];
|
|
301
379
|
//#endregion
|
|
302
|
-
//#region
|
|
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.
|
|
380
|
+
//#region ../../node_modules/type-fest/source/internal/array.d.ts
|
|
307
381
|
|
|
308
|
-
|
|
382
|
+
/**
|
|
383
|
+
Returns whether the given array `T` is readonly.
|
|
384
|
+
*/
|
|
385
|
+
type IsArrayReadonly<T$1 extends UnknownArray> = If<IsNever<T$1>, false, T$1 extends unknown[] ? false : true>;
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region ../../node_modules/type-fest/source/simplify.d.ts
|
|
388
|
+
/**
|
|
389
|
+
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.
|
|
309
390
|
|
|
310
391
|
@example
|
|
311
392
|
```
|
|
312
|
-
import type {
|
|
313
|
-
|
|
314
|
-
type A = {
|
|
315
|
-
common: string;
|
|
316
|
-
a: number;
|
|
317
|
-
};
|
|
393
|
+
import type {Simplify} from 'type-fest';
|
|
318
394
|
|
|
319
|
-
type
|
|
320
|
-
|
|
321
|
-
|
|
395
|
+
type PositionProps = {
|
|
396
|
+
top: number;
|
|
397
|
+
left: number;
|
|
322
398
|
};
|
|
323
399
|
|
|
324
|
-
type
|
|
325
|
-
|
|
326
|
-
|
|
400
|
+
type SizeProps = {
|
|
401
|
+
width: number;
|
|
402
|
+
height: number;
|
|
327
403
|
};
|
|
328
404
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
type CommonKeys = keyof Union;
|
|
332
|
-
//=> 'common'
|
|
333
|
-
|
|
334
|
-
type AllKeys = KeysOfUnion<Union>;
|
|
335
|
-
//=> 'common' | 'a' | 'b' | 'c'
|
|
405
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
406
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
336
407
|
```
|
|
337
408
|
|
|
338
|
-
|
|
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.
|
|
409
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
345
410
|
|
|
346
|
-
|
|
411
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
347
412
|
|
|
348
413
|
@example
|
|
349
414
|
```
|
|
350
|
-
import type {
|
|
351
|
-
|
|
352
|
-
interface User {
|
|
353
|
-
name: string;
|
|
354
|
-
surname: string;
|
|
415
|
+
import type {Simplify} from 'type-fest';
|
|
355
416
|
|
|
356
|
-
|
|
417
|
+
interface SomeInterface {
|
|
418
|
+
foo: number;
|
|
419
|
+
bar?: string;
|
|
420
|
+
baz: number | undefined;
|
|
357
421
|
}
|
|
358
422
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
423
|
+
type SomeType = {
|
|
424
|
+
foo: number;
|
|
425
|
+
bar?: string;
|
|
426
|
+
baz: number | undefined;
|
|
362
427
|
};
|
|
363
428
|
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
429
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
430
|
+
const someType: SomeType = literal;
|
|
431
|
+
const someInterface: SomeInterface = literal;
|
|
432
|
+
|
|
433
|
+
function fn(object: Record<string, unknown>): void {}
|
|
367
434
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
435
|
+
fn(literal); // Good: literal object type is sealed
|
|
436
|
+
fn(someType); // Good: type is sealed
|
|
437
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
438
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
372
439
|
```
|
|
373
440
|
|
|
374
|
-
@
|
|
441
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
442
|
+
@see SimplifyDeep
|
|
443
|
+
@category Object
|
|
375
444
|
*/
|
|
376
|
-
type
|
|
445
|
+
type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
|
|
377
446
|
//#endregion
|
|
378
|
-
//#region
|
|
447
|
+
//#region ../../node_modules/type-fest/source/is-equal.d.ts
|
|
379
448
|
/**
|
|
380
|
-
|
|
449
|
+
Returns a boolean for whether the two given types are equal.
|
|
381
450
|
|
|
382
|
-
|
|
451
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
452
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
453
|
+
|
|
454
|
+
Use-cases:
|
|
455
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
383
456
|
|
|
384
457
|
@example
|
|
385
458
|
```
|
|
386
|
-
import type {
|
|
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
|
-
}
|
|
459
|
+
import type {IsEqual} from 'type-fest';
|
|
396
460
|
|
|
397
|
-
|
|
398
|
-
|
|
461
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
462
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
463
|
+
type Includes<Value extends readonly any[], Item> =
|
|
464
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
465
|
+
? IsEqual<Value[0], Item> extends true
|
|
466
|
+
? true
|
|
467
|
+
: Includes<rest, Item>
|
|
468
|
+
: false;
|
|
399
469
|
```
|
|
400
470
|
|
|
401
|
-
@
|
|
471
|
+
@category Type Guard
|
|
472
|
+
@category Utilities
|
|
402
473
|
*/
|
|
403
|
-
type
|
|
474
|
+
type IsEqual<A, B> = [A, B] extends [infer AA, infer BB] ? [AA] extends [never] ? [BB] extends [never] ? true : false : [BB] extends [never] ? false : _IsEqual<AA, BB> : false;
|
|
475
|
+
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
476
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
404
477
|
//#endregion
|
|
405
|
-
//#region
|
|
478
|
+
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
406
479
|
/**
|
|
407
480
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
408
481
|
|
|
@@ -428,13 +501,13 @@ Instead of causing a type error like the above, you can also use a [conditional
|
|
|
428
501
|
|
|
429
502
|
```
|
|
430
503
|
type Indexed = {} extends Record<string, unknown>
|
|
431
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
432
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
504
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
505
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
433
506
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
434
507
|
|
|
435
508
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
436
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
437
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
509
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
510
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
438
511
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
439
512
|
```
|
|
440
513
|
|
|
@@ -444,8 +517,8 @@ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-type
|
|
|
444
517
|
import type {OmitIndexSignature} from 'type-fest';
|
|
445
518
|
|
|
446
519
|
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`.
|
|
520
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
521
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
449
522
|
};
|
|
450
523
|
```
|
|
451
524
|
|
|
@@ -455,12 +528,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
455
528
|
import type {OmitIndexSignature} from 'type-fest';
|
|
456
529
|
|
|
457
530
|
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];
|
|
531
|
+
[KeyType in keyof ObjectType
|
|
532
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
533
|
+
as {} extends Record<KeyType, unknown>
|
|
534
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
535
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
536
|
+
]: ObjectType[KeyType];
|
|
464
537
|
};
|
|
465
538
|
```
|
|
466
539
|
|
|
@@ -471,19 +544,19 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
471
544
|
import type {OmitIndexSignature} from 'type-fest';
|
|
472
545
|
|
|
473
546
|
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';
|
|
547
|
+
// These index signatures will be removed.
|
|
548
|
+
[x: string]: any
|
|
549
|
+
[x: number]: any
|
|
550
|
+
[x: symbol]: any
|
|
551
|
+
[x: `head-${string}`]: string
|
|
552
|
+
[x: `${string}-tail`]: string
|
|
553
|
+
[x: `head-${string}-tail`]: string
|
|
554
|
+
[x: `${bigint}`]: string
|
|
555
|
+
[x: `embedded-${number}`]: string
|
|
556
|
+
|
|
557
|
+
// These explicitly defined keys will remain.
|
|
558
|
+
foo: 'bar';
|
|
559
|
+
qux?: 'baz';
|
|
487
560
|
}
|
|
488
561
|
|
|
489
562
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
@@ -491,12 +564,11 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
491
564
|
```
|
|
492
565
|
|
|
493
566
|
@see PickIndexSignature
|
|
494
|
-
|
|
495
|
-
@group type-fest
|
|
567
|
+
@category Object
|
|
496
568
|
*/
|
|
497
569
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
498
570
|
//#endregion
|
|
499
|
-
//#region
|
|
571
|
+
//#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
|
|
500
572
|
/**
|
|
501
573
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
502
574
|
|
|
@@ -509,21 +581,21 @@ import type {PickIndexSignature} from 'type-fest';
|
|
|
509
581
|
declare const symbolKey: unique symbol;
|
|
510
582
|
|
|
511
583
|
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';
|
|
584
|
+
// These index signatures will remain.
|
|
585
|
+
[x: string]: unknown;
|
|
586
|
+
[x: number]: unknown;
|
|
587
|
+
[x: symbol]: unknown;
|
|
588
|
+
[x: `head-${string}`]: string;
|
|
589
|
+
[x: `${string}-tail`]: string;
|
|
590
|
+
[x: `head-${string}-tail`]: string;
|
|
591
|
+
[x: `${bigint}`]: string;
|
|
592
|
+
[x: `embedded-${number}`]: string;
|
|
593
|
+
|
|
594
|
+
// These explicitly defined keys will be removed.
|
|
595
|
+
['kebab-case-key']: string;
|
|
596
|
+
[symbolKey]: string;
|
|
597
|
+
foo: 'bar';
|
|
598
|
+
qux?: 'baz';
|
|
527
599
|
};
|
|
528
600
|
|
|
529
601
|
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
@@ -540,13 +612,14 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
540
612
|
```
|
|
541
613
|
|
|
542
614
|
@see OmitIndexSignature
|
|
543
|
-
|
|
544
|
-
@group type-fest
|
|
615
|
+
@category Object
|
|
545
616
|
*/
|
|
546
617
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
547
618
|
//#endregion
|
|
548
|
-
//#region
|
|
619
|
+
//#region ../../node_modules/type-fest/source/merge.d.ts
|
|
620
|
+
// Merges two objects without worrying about index signatures.
|
|
549
621
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
622
|
+
|
|
550
623
|
/**
|
|
551
624
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
552
625
|
|
|
@@ -555,17 +628,17 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
555
628
|
import type {Merge} from 'type-fest';
|
|
556
629
|
|
|
557
630
|
interface Foo {
|
|
558
|
-
[x: string]: unknown;
|
|
559
|
-
[x: number]: unknown;
|
|
560
|
-
foo: string;
|
|
561
|
-
bar: symbol;
|
|
631
|
+
[x: string]: unknown;
|
|
632
|
+
[x: number]: unknown;
|
|
633
|
+
foo: string;
|
|
634
|
+
bar: symbol;
|
|
562
635
|
}
|
|
563
636
|
|
|
564
637
|
type Bar = {
|
|
565
|
-
[x: number]: number;
|
|
566
|
-
[x: symbol]: unknown;
|
|
567
|
-
bar: Date;
|
|
568
|
-
baz: boolean;
|
|
638
|
+
[x: number]: number;
|
|
639
|
+
[x: symbol]: unknown;
|
|
640
|
+
bar: Date;
|
|
641
|
+
baz: boolean;
|
|
569
642
|
};
|
|
570
643
|
|
|
571
644
|
export type FooBar = Merge<Foo, Bar>;
|
|
@@ -579,55 +652,11 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
579
652
|
// }
|
|
580
653
|
```
|
|
581
654
|
|
|
582
|
-
@
|
|
655
|
+
@category Object
|
|
583
656
|
*/
|
|
584
657
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
585
658
|
//#endregion
|
|
586
|
-
//#region
|
|
587
|
-
/**
|
|
588
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
589
|
-
|
|
590
|
-
@see {@link IsAny}
|
|
591
|
-
|
|
592
|
-
@example
|
|
593
|
-
```
|
|
594
|
-
import type {IfAny} from 'type-fest';
|
|
595
|
-
|
|
596
|
-
type ShouldBeTrue = IfAny<any>;
|
|
597
|
-
//=> true
|
|
598
|
-
|
|
599
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
600
|
-
//=> 'bar'
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
@group type-fest
|
|
604
|
-
*/
|
|
605
|
-
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region ../core/src/types/type-fest/internal/type.d.ts
|
|
608
|
-
/**
|
|
609
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
610
|
-
|
|
611
|
-
@example
|
|
612
|
-
```
|
|
613
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
614
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
615
|
-
//=> 'VALID'
|
|
616
|
-
|
|
617
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
618
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
619
|
-
//=> 'IS_ANY'
|
|
620
|
-
|
|
621
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
622
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
623
|
-
//=> 'IS_NEVER'
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
@group type-fest
|
|
627
|
-
*/
|
|
628
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
629
|
-
//#endregion
|
|
630
|
-
//#region ../core/src/types/type-fest/internal/object.d.ts
|
|
659
|
+
//#region ../../node_modules/type-fest/source/internal/object.d.ts
|
|
631
660
|
/**
|
|
632
661
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
633
662
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -638,15 +667,15 @@ Works similar to the built-in `Pick` utility type, except for the following diff
|
|
|
638
667
|
@example
|
|
639
668
|
```
|
|
640
669
|
type ImageUpload = {
|
|
641
|
-
url: string;
|
|
642
|
-
size: number;
|
|
643
|
-
thumbnailUrl: string;
|
|
670
|
+
url: string;
|
|
671
|
+
size: number;
|
|
672
|
+
thumbnailUrl: string;
|
|
644
673
|
};
|
|
645
674
|
|
|
646
675
|
type VideoUpload = {
|
|
647
|
-
url: string;
|
|
648
|
-
duration: number;
|
|
649
|
-
encodingFormat: string;
|
|
676
|
+
url: string;
|
|
677
|
+
duration: number;
|
|
678
|
+
encodingFormat: string;
|
|
650
679
|
};
|
|
651
680
|
|
|
652
681
|
// Distributes over union types and allows picking keys from any member of the union type
|
|
@@ -664,10 +693,8 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
664
693
|
// Doesn't pick `number` from a `string` index signature
|
|
665
694
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
666
695
|
//=> {}
|
|
667
|
-
|
|
668
|
-
@group type-fest
|
|
669
696
|
*/
|
|
670
|
-
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
697
|
+
type HomomorphicPick<T$1, Keys extends KeysOfUnion<T$1>> = { [P in keyof T$1 as Extract<P, Keys>]: T$1[P] };
|
|
671
698
|
/**
|
|
672
699
|
Merges user specified options with default options.
|
|
673
700
|
|
|
@@ -719,12 +746,10 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
719
746
|
// ~~~~~~~~~~~~~~~~
|
|
720
747
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
721
748
|
```
|
|
722
|
-
|
|
723
|
-
@group type-fest
|
|
724
749
|
*/
|
|
725
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
750
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
726
751
|
//#endregion
|
|
727
|
-
//#region
|
|
752
|
+
//#region ../../node_modules/type-fest/source/except.d.ts
|
|
728
753
|
/**
|
|
729
754
|
Filter out keys from an object.
|
|
730
755
|
|
|
@@ -752,20 +777,19 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
752
777
|
|
|
753
778
|
@see {Except}
|
|
754
779
|
*/
|
|
755
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
780
|
+
type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
|
|
756
781
|
type ExceptOptions = {
|
|
757
782
|
/**
|
|
758
783
|
Disallow assigning non-specified properties.
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
@default false
|
|
784
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
785
|
+
@default false
|
|
763
786
|
*/
|
|
764
787
|
requireExactProps?: boolean;
|
|
765
788
|
};
|
|
766
789
|
type DefaultExceptOptions = {
|
|
767
790
|
requireExactProps: false;
|
|
768
791
|
};
|
|
792
|
+
|
|
769
793
|
/**
|
|
770
794
|
Create a type from an object type without certain keys.
|
|
771
795
|
|
|
@@ -780,8 +804,8 @@ This type was proposed to the TypeScript team, which declined it, saying they pr
|
|
|
780
804
|
import type {Except} from 'type-fest';
|
|
781
805
|
|
|
782
806
|
type Foo = {
|
|
783
|
-
a: number;
|
|
784
|
-
b: string;
|
|
807
|
+
a: number;
|
|
808
|
+
b: string;
|
|
785
809
|
};
|
|
786
810
|
|
|
787
811
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
@@ -801,10 +825,10 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
|
801
825
|
// Consider the following example:
|
|
802
826
|
|
|
803
827
|
type UserData = {
|
|
804
|
-
[metadata: string]: string;
|
|
805
|
-
email: string;
|
|
806
|
-
name: string;
|
|
807
|
-
role: 'admin' | 'user';
|
|
828
|
+
[metadata: string]: string;
|
|
829
|
+
email: string;
|
|
830
|
+
name: string;
|
|
831
|
+
role: 'admin' | 'user';
|
|
808
832
|
};
|
|
809
833
|
|
|
810
834
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
@@ -817,37 +841,64 @@ type PostPayload = Except<UserData, 'email'>;
|
|
|
817
841
|
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
818
842
|
```
|
|
819
843
|
|
|
820
|
-
@
|
|
844
|
+
@category Object
|
|
821
845
|
*/
|
|
822
846
|
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[
|
|
847
|
+
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
848
|
//#endregion
|
|
825
|
-
//#region
|
|
849
|
+
//#region ../../node_modules/type-fest/source/set-required.d.ts
|
|
826
850
|
/**
|
|
827
|
-
Create a type that
|
|
851
|
+
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
852
|
+
|
|
853
|
+
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.
|
|
828
854
|
|
|
829
855
|
@example
|
|
830
856
|
```
|
|
831
|
-
import type {
|
|
857
|
+
import type {SetRequired} from 'type-fest';
|
|
832
858
|
|
|
833
|
-
type
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
859
|
+
type Foo = {
|
|
860
|
+
a?: number;
|
|
861
|
+
b: string;
|
|
862
|
+
c?: boolean;
|
|
863
|
+
}
|
|
838
864
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
865
|
+
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
866
|
+
// type SomeRequired = {
|
|
867
|
+
// a?: number;
|
|
868
|
+
// b: string; // Was already required and still is.
|
|
869
|
+
// c: boolean; // Is now required.
|
|
870
|
+
// }
|
|
871
|
+
|
|
872
|
+
// Set specific indices in an array to be required.
|
|
873
|
+
type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
|
|
874
|
+
//=> [number, number, number?]
|
|
843
875
|
```
|
|
844
876
|
|
|
845
|
-
@
|
|
877
|
+
@category Object
|
|
878
|
+
*/
|
|
879
|
+
type SetRequired<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetRequired<BaseType, Keys>;
|
|
880
|
+
type _SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? If<IsArrayReadonly<BaseType>, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
|
|
881
|
+
// Pick just the keys that are optional from the base type.
|
|
882
|
+
Except<BaseType, Keys> &
|
|
883
|
+
// Pick the keys that should be required from the base type and make them required.
|
|
884
|
+
Required<HomomorphicPick<BaseType, Keys>>>;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
Remove the optional modifier from the specified keys in an array.
|
|
846
888
|
*/
|
|
847
|
-
type
|
|
848
|
-
|
|
889
|
+
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
|
|
890
|
+
? keyof TArray & `${number}` extends never
|
|
891
|
+
// Exit if `TArray` is empty (e.g., []), or
|
|
892
|
+
// `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
893
|
+
? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
|
|
894
|
+
? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
|
|
895
|
+
? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
|
|
896
|
+
// If the current element is optional, but it doesn't need to be required,
|
|
897
|
+
// then we can exit early, since no further elements can now be made required.
|
|
898
|
+
: [...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.
|
|
899
|
+
: never; // Should never happen
|
|
849
900
|
//#endregion
|
|
850
|
-
//#region
|
|
901
|
+
//#region ../../node_modules/type-fest/source/set-non-nullable.d.ts
|
|
851
902
|
/**
|
|
852
903
|
Create a type that makes the given keys non-nullable, where the remaining keys are kept as is.
|
|
853
904
|
|
|
@@ -860,9 +911,9 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
|
860
911
|
import type {SetNonNullable} from 'type-fest';
|
|
861
912
|
|
|
862
913
|
type Foo = {
|
|
863
|
-
a: number | null;
|
|
864
|
-
b: string | undefined;
|
|
865
|
-
c?: boolean | null;
|
|
914
|
+
a: number | null;
|
|
915
|
+
b: string | undefined;
|
|
916
|
+
c?: boolean | null;
|
|
866
917
|
}
|
|
867
918
|
|
|
868
919
|
type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
|
|
@@ -880,47 +931,12 @@ type AllNonNullable = SetNonNullable<Foo>;
|
|
|
880
931
|
// }
|
|
881
932
|
```
|
|
882
933
|
|
|
883
|
-
@
|
|
934
|
+
@category Object
|
|
884
935
|
*/
|
|
885
936
|
type SetNonNullable<BaseType, Keys extends keyof BaseType = keyof BaseType> = { [Key in keyof BaseType]: Key extends Keys ? NonNullable<BaseType[Key]> : BaseType[Key] };
|
|
886
937
|
//#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
938
|
//#region ../core/src/types/options.d.ts
|
|
939
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
924
940
|
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
925
941
|
/**
|
|
926
942
|
* Extracts the type of the identifying property from a {@link Option},
|
|
@@ -928,11 +944,11 @@ type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown
|
|
|
928
944
|
*
|
|
929
945
|
* @group Option Lists
|
|
930
946
|
*/
|
|
931
|
-
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
947
|
+
type GetOptionIdentifierType<Opt$1 extends BaseOption> = Opt$1 extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
932
948
|
/**
|
|
933
949
|
* Adds an `unknown` index property to an interface.
|
|
934
950
|
*/
|
|
935
|
-
type WithUnknownIndex<T> = T & {
|
|
951
|
+
type WithUnknownIndex<T$1> = T$1 & {
|
|
936
952
|
[key: string]: unknown;
|
|
937
953
|
};
|
|
938
954
|
/**
|
|
@@ -964,8 +980,8 @@ type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<B
|
|
|
964
980
|
type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "value">>>;
|
|
965
981
|
/**
|
|
966
982
|
* A generic {@link Option} with either a `name` or `value` as its primary identifier.
|
|
967
|
-
* {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
|
|
968
|
-
* but corresponding props passed down to subcomponents will always be
|
|
983
|
+
* {@link OptionList}-type props on the {@link react-querybuilder!QueryBuilder QueryBuilder} component accept this type,
|
|
984
|
+
* but corresponding props passed down to subcomponents will always be augmented
|
|
969
985
|
* to {@link FullOption} first.
|
|
970
986
|
*
|
|
971
987
|
* @group Option Lists
|
|
@@ -977,11 +993,11 @@ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<Requi
|
|
|
977
993
|
*
|
|
978
994
|
* @group Option Lists
|
|
979
995
|
*/
|
|
980
|
-
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
996
|
+
type ToFlexibleOption<Opt$1 extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt$1 extends string ? FlexibleOption<Opt$1> : Opt$1, "name" | "value">>;
|
|
981
997
|
/**
|
|
982
998
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
983
999
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
984
|
-
* corresponding props sent to subcomponents will always be
|
|
1000
|
+
* corresponding props sent to subcomponents will always be augmented to this
|
|
985
1001
|
* type first to ensure both `name` and `value` are available.
|
|
986
1002
|
*
|
|
987
1003
|
* NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
|
|
@@ -1005,45 +1021,45 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1005
1021
|
*
|
|
1006
1022
|
* @group Option Lists
|
|
1007
1023
|
*/
|
|
1008
|
-
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1024
|
+
type ToFullOption<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1 : Opt$1 extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt$1 & FullOption<IdentifierType>> : never;
|
|
1009
1025
|
/**
|
|
1010
1026
|
* A group of {@link Option}s, usually within an {@link OptionList}.
|
|
1011
1027
|
*
|
|
1012
1028
|
* @group Option Lists
|
|
1013
1029
|
*/
|
|
1014
|
-
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1030
|
+
interface OptionGroup<Opt$1 extends BaseOption = FlexibleOption> {
|
|
1015
1031
|
label: string;
|
|
1016
|
-
options: WithUnknownIndex<Opt>[];
|
|
1032
|
+
options: WithUnknownIndex<Opt$1>[];
|
|
1017
1033
|
}
|
|
1018
1034
|
/**
|
|
1019
1035
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1020
1036
|
*
|
|
1021
1037
|
* @group Option Lists
|
|
1022
1038
|
*/
|
|
1023
|
-
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1039
|
+
type FlexibleOptionGroup<Opt$1 extends BaseOption | string = BaseOption> = {
|
|
1024
1040
|
label: string;
|
|
1025
|
-
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1041
|
+
options: (Opt$1 extends BaseFullOption ? Opt$1 : ToFlexibleOption<Opt$1>)[];
|
|
1026
1042
|
};
|
|
1027
1043
|
/**
|
|
1028
1044
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1029
1045
|
*
|
|
1030
1046
|
* @group Option Lists
|
|
1031
1047
|
*/
|
|
1032
|
-
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1048
|
+
type OptionList<Opt$1 extends Option = Option> = Opt$1[] | OptionGroup<Opt$1>[];
|
|
1033
1049
|
/**
|
|
1034
1050
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1035
1051
|
* may use either `name` or `value` as the primary identifier.
|
|
1036
1052
|
*
|
|
1037
1053
|
* @group Option Lists
|
|
1038
1054
|
*/
|
|
1039
|
-
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1055
|
+
type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1>>[];
|
|
1040
1056
|
/**
|
|
1041
1057
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1042
1058
|
* may use either `name` or `value` as the primary identifier.
|
|
1043
1059
|
*
|
|
1044
1060
|
* @group Option Lists
|
|
1045
1061
|
*/
|
|
1046
|
-
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
|
|
1062
|
+
type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>>[];
|
|
1047
1063
|
/**
|
|
1048
1064
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1049
1065
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1051,13 +1067,13 @@ type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | G
|
|
|
1051
1067
|
*
|
|
1052
1068
|
* @group Option Lists
|
|
1053
1069
|
*/
|
|
1054
|
-
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1070
|
+
type FullOptionList<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1[] | OptionGroup<Opt$1>[] : ToFullOption<Opt$1>[] | OptionGroup<ToFullOption<Opt$1>>[];
|
|
1055
1071
|
/**
|
|
1056
1072
|
* Map of option identifiers to their respective {@link Option}.
|
|
1057
1073
|
*
|
|
1058
1074
|
* @group Option Lists
|
|
1059
1075
|
*/
|
|
1060
|
-
type BaseOptionMap<V extends BaseOption = BaseOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: ToFlexibleOption<V> };
|
|
1076
|
+
type BaseOptionMap<V$1 extends BaseOption = BaseOption, K$1 extends string = GetOptionIdentifierType<V$1>> = { [k in K$1]?: ToFlexibleOption<V$1> };
|
|
1061
1077
|
//#endregion
|
|
1062
1078
|
//#region ../core/src/types/ruleGroups.d.ts
|
|
1063
1079
|
/**
|
|
@@ -1067,15 +1083,21 @@ interface CommonRuleAndGroupProperties {
|
|
|
1067
1083
|
path?: Path;
|
|
1068
1084
|
id?: string;
|
|
1069
1085
|
disabled?: boolean;
|
|
1086
|
+
/**
|
|
1087
|
+
* Whether this rule or group is muted. When muted, the rule or group
|
|
1088
|
+
* is excluded from query export formats (SQL, JSON, MongoDB, etc.).
|
|
1089
|
+
* For groups, muting recursively mutes all children.
|
|
1090
|
+
*/
|
|
1091
|
+
muted?: boolean;
|
|
1070
1092
|
}
|
|
1071
1093
|
/**
|
|
1072
1094
|
* The main rule type. The `field`, `operator`, and `value` properties
|
|
1073
1095
|
* can be narrowed with generics.
|
|
1074
1096
|
*/
|
|
1075
|
-
interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1097
|
+
interface RuleType<F extends string = string, O extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1076
1098
|
field: F;
|
|
1077
1099
|
operator: O;
|
|
1078
|
-
value: V;
|
|
1100
|
+
value: V$1;
|
|
1079
1101
|
valueSource?: ValueSource;
|
|
1080
1102
|
match?: MatchConfig;
|
|
1081
1103
|
/**
|
|
@@ -1087,15 +1109,15 @@ interface RuleType<F extends string = string, O extends string = string, V = any
|
|
|
1087
1109
|
* The main rule group type. This type is used for query definitions as well as
|
|
1088
1110
|
* all sub-groups of queries.
|
|
1089
1111
|
*/
|
|
1090
|
-
interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1112
|
+
interface RuleGroupType<R$1 extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1091
1113
|
combinator: C;
|
|
1092
|
-
rules: RuleGroupArray<RuleGroupType<R, C>, R>;
|
|
1114
|
+
rules: RuleGroupArray<RuleGroupType<R$1, C>, R$1>;
|
|
1093
1115
|
not?: boolean;
|
|
1094
1116
|
}
|
|
1095
1117
|
/**
|
|
1096
1118
|
* The type of the `rules` array in a {@link RuleGroupType}.
|
|
1097
1119
|
*/
|
|
1098
|
-
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
|
|
1120
|
+
type RuleGroupArray<RG$1 extends RuleGroupType = RuleGroupType, R$1 extends RuleType = RuleType> = (R$1 | RG$1)[];
|
|
1099
1121
|
//#endregion
|
|
1100
1122
|
//#region ../core/src/types/ruleGroupsIC.utils.d.ts
|
|
1101
1123
|
type MAXIMUM_ALLOWED_BOUNDARY = 80;
|
|
@@ -1106,9 +1128,9 @@ type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [
|
|
|
1106
1128
|
* The main rule group interface when using independent combinators. This type is used
|
|
1107
1129
|
* for query definitions as well as all sub-groups of queries.
|
|
1108
1130
|
*/
|
|
1109
|
-
interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
|
|
1131
|
+
interface RuleGroupTypeIC<R$1 extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R$1, C>, "combinator" | "rules"> {
|
|
1110
1132
|
combinator?: undefined;
|
|
1111
|
-
rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
|
|
1133
|
+
rules: RuleGroupICArray<RuleGroupTypeIC<R$1, C>, R$1, C>;
|
|
1112
1134
|
/**
|
|
1113
1135
|
* Only used when adding a rule to a query that uses independent combinators
|
|
1114
1136
|
*/
|
|
@@ -1117,11 +1139,11 @@ interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = stri
|
|
|
1117
1139
|
/**
|
|
1118
1140
|
* Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
|
|
1119
1141
|
*/
|
|
1120
|
-
type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
|
|
1142
|
+
type RuleGroupTypeAny<R$1 extends RuleType = RuleType, C extends string = string> = RuleGroupType<R$1, C> | RuleGroupTypeIC<R$1, C>;
|
|
1121
1143
|
/**
|
|
1122
1144
|
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
|
|
1123
1145
|
*/
|
|
1124
|
-
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
|
|
1146
|
+
type RuleGroupICArray<RG$1 extends RuleGroupTypeIC = RuleGroupTypeIC, R$1 extends RuleType = RuleType, C extends string = string> = [R$1 | RG$1] | [R$1 | RG$1, ...MappedTuple<[C, R$1 | RG$1]>] | ((R$1 | RG$1)[] & {
|
|
1125
1147
|
length: 0;
|
|
1126
1148
|
});
|
|
1127
1149
|
/**
|
|
@@ -1131,7 +1153,7 @@ type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
|
|
|
1131
1153
|
/**
|
|
1132
1154
|
* Converts a narrowed rule group type to its most generic form.
|
|
1133
1155
|
*/
|
|
1134
|
-
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1156
|
+
type GenericizeRuleGroupType<RG$1> = RG$1 extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1135
1157
|
//#endregion
|
|
1136
1158
|
//#region ../core/src/types/validation.d.ts
|
|
1137
1159
|
/**
|
|
@@ -1170,7 +1192,7 @@ type Classname = string | string[] | Record<string, any>;
|
|
|
1170
1192
|
*/
|
|
1171
1193
|
type ValueSource = "value" | "field";
|
|
1172
1194
|
/**
|
|
1173
|
-
* Type of {@link ValueEditor} that will be displayed.
|
|
1195
|
+
* Type of {@link react-querybuilder!ValueEditor ValueEditor} that will be displayed.
|
|
1174
1196
|
*/
|
|
1175
1197
|
type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
|
|
1176
1198
|
/**
|
|
@@ -1187,7 +1209,7 @@ type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown
|
|
|
1187
1209
|
label: string;
|
|
1188
1210
|
} } : never;
|
|
1189
1211
|
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
|
|
1190
|
-
type WithOptionalClassName<T> = T & {
|
|
1212
|
+
type WithOptionalClassName<T$1> = T$1 & {
|
|
1191
1213
|
className?: Classname;
|
|
1192
1214
|
};
|
|
1193
1215
|
/**
|
|
@@ -1213,24 +1235,24 @@ type ValueChangeEventHandler = (value?: any, context?: any) => void;
|
|
|
1213
1235
|
/**
|
|
1214
1236
|
* Base for all Field types/interfaces.
|
|
1215
1237
|
*/
|
|
1216
|
-
interface BaseFullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> extends WithOptionalClassName<BaseFullOption<FieldName>> {
|
|
1238
|
+
interface BaseFullField<FieldName extends string = string, OperatorName$1 extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName$1>, ValueObj extends FullOption = FullOption<ValueName>> extends WithOptionalClassName<BaseFullOption<FieldName>> {
|
|
1217
1239
|
id?: string;
|
|
1218
|
-
operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
|
|
1219
|
-
valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
|
|
1220
|
-
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
|
|
1240
|
+
operators?: FlexibleOptionList<OperatorObj> | OperatorName$1[] | FlexibleOption<OperatorName$1>[] | (OperatorName$1 | FlexibleOption<OperatorName$1>)[];
|
|
1241
|
+
valueEditorType?: ValueEditorType | ((operator: OperatorName$1) => ValueEditorType);
|
|
1242
|
+
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName$1) => ValueSources | ValueSourceFlexibleOptions);
|
|
1221
1243
|
inputType?: InputType | null;
|
|
1222
1244
|
values?: FlexibleOptionList<ValueObj>;
|
|
1223
1245
|
matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
|
|
1224
1246
|
/** Properties of items in the value. */
|
|
1225
1247
|
subproperties?: FlexibleOptionList<FullField>;
|
|
1226
|
-
defaultOperator?: OperatorName;
|
|
1248
|
+
defaultOperator?: OperatorName$1;
|
|
1227
1249
|
defaultValue?: any;
|
|
1228
1250
|
placeholder?: string;
|
|
1229
1251
|
validator?: RuleValidator;
|
|
1230
1252
|
comparator?: string | ((f: FullField, operator: string) => boolean);
|
|
1231
1253
|
}
|
|
1232
1254
|
/**
|
|
1233
|
-
* Full field definition used in the `fields` prop of {@link QueryBuilder}.
|
|
1255
|
+
* Full field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1234
1256
|
* This type requires both `name` and `value`, but the `fields` prop itself
|
|
1235
1257
|
* can use a {@link FlexibleOption} where only one of `name` or `value` is
|
|
1236
1258
|
* required (along with `label`), or {@link Field} where only `name` and
|
|
@@ -1241,15 +1263,15 @@ interface BaseFullField<FieldName extends string = string, OperatorName extends
|
|
|
1241
1263
|
*
|
|
1242
1264
|
* @group Option Lists
|
|
1243
1265
|
*/
|
|
1244
|
-
type FullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> = Simplify<FullOption<FieldName> & BaseFullField<FieldName, OperatorName, ValueName, OperatorObj, ValueObj>>;
|
|
1266
|
+
type FullField<FieldName extends string = string, OperatorName$1 extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName$1>, ValueObj extends FullOption = FullOption<ValueName>> = Simplify<FullOption<FieldName> & BaseFullField<FieldName, OperatorName$1, ValueName, OperatorObj, ValueObj>>;
|
|
1245
1267
|
/**
|
|
1246
1268
|
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
1247
|
-
* a number less than two will cause the default {@link ValueEditor} to render `null`.
|
|
1269
|
+
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
1248
1270
|
*/
|
|
1249
1271
|
type Arity = number | "unary" | "binary" | "ternary";
|
|
1250
1272
|
/**
|
|
1251
1273
|
* Full operator definition used in the `operators`/`getOperators` props of
|
|
1252
|
-
* {@link QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1274
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1253
1275
|
* `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
|
|
1254
1276
|
* where only one of `name` or `value` is required, or {@link FullOperator} where
|
|
1255
1277
|
* only `name` is required.
|
|
@@ -1262,7 +1284,7 @@ interface FullOperator<N extends string = string> extends WithOptionalClassName<
|
|
|
1262
1284
|
arity?: Arity;
|
|
1263
1285
|
}
|
|
1264
1286
|
/**
|
|
1265
|
-
* Full combinator definition used in the `combinators` prop of {@link QueryBuilder}.
|
|
1287
|
+
* Full combinator definition used in the `combinators` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1266
1288
|
* This type requires both `name` and `value`, but the `combinators` prop itself
|
|
1267
1289
|
* can use a {@link FlexibleOption} where only one of `name` or `value` is required,
|
|
1268
1290
|
* or {@link Combinator} where only `name` is required.
|
|
@@ -1279,12 +1301,12 @@ type ParseNumberMethodName = "enhanced" | "native" | "strict";
|
|
|
1279
1301
|
|
|
1280
1302
|
type ParseNumbersModerationLevel = "-limited" | "";
|
|
1281
1303
|
/**
|
|
1282
|
-
* Options for the `parseNumbers` prop of {@link QueryBuilder}.
|
|
1304
|
+
* Options for the `parseNumbers` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1283
1305
|
*/
|
|
1284
1306
|
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
1285
1307
|
/**
|
|
1286
|
-
* Signature of `accessibleDescriptionGenerator` prop, used by {@link QueryBuilder} to generate
|
|
1287
|
-
* accessible descriptions for each {@link RuleGroup}.
|
|
1308
|
+
* Signature of `accessibleDescriptionGenerator` prop, used by {@link react-querybuilder!QueryBuilder QueryBuilder} to generate
|
|
1309
|
+
* accessible descriptions for each {@link react-querybuilder!RuleGroup RuleGroup}.
|
|
1288
1310
|
*/
|
|
1289
1311
|
type AccessibleDescriptionGenerator = (props: {
|
|
1290
1312
|
path: Path;
|
|
@@ -1294,7 +1316,7 @@ type AccessibleDescriptionGenerator = (props: {
|
|
|
1294
1316
|
//#region ../core/src/types/dnd.d.ts
|
|
1295
1317
|
type DropEffect = "move" | "copy";
|
|
1296
1318
|
//#endregion
|
|
1297
|
-
//#region ../core/src/types/
|
|
1319
|
+
//#region ../core/src/types/queryBuilder.d.ts
|
|
1298
1320
|
/**
|
|
1299
1321
|
* Base interface for all rule subcomponents.
|
|
1300
1322
|
*
|
|
@@ -1398,82 +1420,278 @@ interface Classnames {
|
|
|
1398
1420
|
*/
|
|
1399
1421
|
lockGroup: Classname;
|
|
1400
1422
|
/**
|
|
1423
|
+
* Classnames applied to the `<button>` to mute a Rule.
|
|
1424
|
+
*/
|
|
1425
|
+
muteRule: Classname;
|
|
1426
|
+
/**
|
|
1427
|
+
* Classnames applied to the `<button>` to mute a RuleGroup.
|
|
1428
|
+
*/
|
|
1429
|
+
muteGroup: Classname;
|
|
1430
|
+
/**
|
|
1401
1431
|
* Classnames applied to the `<select>` control for value sources.
|
|
1402
1432
|
*/
|
|
1403
|
-
valueSource: Classname;
|
|
1433
|
+
valueSource: Classname;
|
|
1434
|
+
/**
|
|
1435
|
+
* Classnames applied to all action elements.
|
|
1436
|
+
*/
|
|
1437
|
+
actionElement: Classname;
|
|
1438
|
+
/**
|
|
1439
|
+
* Classnames applied to all select elements.
|
|
1440
|
+
*/
|
|
1441
|
+
valueSelector: Classname;
|
|
1442
|
+
/**
|
|
1443
|
+
* Classname(s) applied to inline combinator elements.
|
|
1444
|
+
*/
|
|
1445
|
+
betweenRules: Classname;
|
|
1446
|
+
/**
|
|
1447
|
+
* Classname(s) applied to valid rules and groups.
|
|
1448
|
+
*/
|
|
1449
|
+
valid: Classname;
|
|
1450
|
+
/**
|
|
1451
|
+
* Classname(s) applied to invalid rules and groups.
|
|
1452
|
+
*/
|
|
1453
|
+
invalid: Classname;
|
|
1454
|
+
/**
|
|
1455
|
+
* Classname(s) applied to rules and groups while being dragged.
|
|
1456
|
+
*/
|
|
1457
|
+
dndDragging: Classname;
|
|
1458
|
+
/**
|
|
1459
|
+
* Classname(s) applied to rules and groups hovered over by a dragged element.
|
|
1460
|
+
*/
|
|
1461
|
+
dndOver: Classname;
|
|
1462
|
+
/**
|
|
1463
|
+
* Classname(s) applied to rules and groups hovered over by a dragged element
|
|
1464
|
+
* when the drop effect is "copy" (modifier key is pressed).
|
|
1465
|
+
*/
|
|
1466
|
+
dndCopy: Classname;
|
|
1467
|
+
/**
|
|
1468
|
+
* Classname(s) applied to rules and groups hovered over by a dragged element
|
|
1469
|
+
* when the Ctrl key is pressed, indicating the items will form a new group.
|
|
1470
|
+
*/
|
|
1471
|
+
dndGroup: Classname;
|
|
1472
|
+
/**
|
|
1473
|
+
* Classname(s) applied to rules and groups that cannot accept a drop from
|
|
1474
|
+
* the dragged element hovering over it.
|
|
1475
|
+
*/
|
|
1476
|
+
dndDropNotAllowed: Classname;
|
|
1477
|
+
/**
|
|
1478
|
+
* Classname(s) applied to disabled elements.
|
|
1479
|
+
*/
|
|
1480
|
+
disabled: Classname;
|
|
1481
|
+
/**
|
|
1482
|
+
* Classname(s) applied to muted elements.
|
|
1483
|
+
*/
|
|
1484
|
+
muted: Classname;
|
|
1485
|
+
/**
|
|
1486
|
+
* Classname(s) applied to each element in a series of value editors.
|
|
1487
|
+
*/
|
|
1488
|
+
valueListItem: Classname;
|
|
1489
|
+
/**
|
|
1490
|
+
* Not applied, but see CSS styles.
|
|
1491
|
+
*/
|
|
1492
|
+
branches: Classname;
|
|
1493
|
+
/**
|
|
1494
|
+
* Classname(s) rules that render a subquery.
|
|
1495
|
+
*/
|
|
1496
|
+
hasSubQuery: Classname;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Placeholder strings for option lists.
|
|
1500
|
+
*
|
|
1501
|
+
* @group Props
|
|
1502
|
+
*/
|
|
1503
|
+
interface Placeholder {
|
|
1504
|
+
/**
|
|
1505
|
+
* Value for the placeholder field option if autoSelectField is false,
|
|
1506
|
+
* or the placeholder operator option if autoSelectOperator is false.
|
|
1507
|
+
*/
|
|
1508
|
+
placeholderName?: string;
|
|
1509
|
+
/**
|
|
1510
|
+
* Label for the placeholder field option if autoSelectField is false,
|
|
1511
|
+
* or the placeholder operator option if autoSelectOperator is false.
|
|
1512
|
+
*/
|
|
1513
|
+
placeholderLabel?: string;
|
|
1514
|
+
/**
|
|
1515
|
+
* Label for the placeholder field optgroup if autoSelectField is false,
|
|
1516
|
+
* or the placeholder operator optgroup if autoSelectOperator is false.
|
|
1517
|
+
*/
|
|
1518
|
+
placeholderGroupLabel?: string;
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* A translation for a component with `title` only.
|
|
1522
|
+
*
|
|
1523
|
+
* @group Props
|
|
1524
|
+
*/
|
|
1525
|
+
interface BaseTranslation {
|
|
1526
|
+
title?: string;
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* A translation for a component with `title` and `label`.
|
|
1530
|
+
*
|
|
1531
|
+
* @group Props
|
|
1532
|
+
*/
|
|
1533
|
+
interface BaseTranslationWithLabel<LabelType = string> extends BaseTranslation {
|
|
1534
|
+
label?: LabelType;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* A translation for a component with `title` and a placeholder.
|
|
1538
|
+
*
|
|
1539
|
+
* @group Props
|
|
1540
|
+
*/
|
|
1541
|
+
interface BaseTranslationWithPlaceholders extends BaseTranslation, Placeholder {}
|
|
1542
|
+
/**
|
|
1543
|
+
* The shape of the `translations` prop.
|
|
1544
|
+
*
|
|
1545
|
+
* @group Props
|
|
1546
|
+
*/
|
|
1547
|
+
interface BaseTranslations<LabelType = string> {
|
|
1548
|
+
fields: BaseTranslationWithPlaceholders;
|
|
1549
|
+
operators: BaseTranslationWithPlaceholders;
|
|
1550
|
+
values: BaseTranslationWithPlaceholders;
|
|
1551
|
+
matchMode: BaseTranslation;
|
|
1552
|
+
matchThreshold: BaseTranslation;
|
|
1553
|
+
value: BaseTranslation;
|
|
1554
|
+
removeRule: BaseTranslationWithLabel<LabelType>;
|
|
1555
|
+
removeGroup: BaseTranslationWithLabel<LabelType>;
|
|
1556
|
+
addRule: BaseTranslationWithLabel<LabelType>;
|
|
1557
|
+
addGroup: BaseTranslationWithLabel<LabelType>;
|
|
1558
|
+
combinators: BaseTranslation;
|
|
1559
|
+
notToggle: BaseTranslationWithLabel<LabelType>;
|
|
1560
|
+
cloneRule: BaseTranslationWithLabel<LabelType>;
|
|
1561
|
+
cloneRuleGroup: BaseTranslationWithLabel<LabelType>;
|
|
1562
|
+
shiftActionUp: BaseTranslationWithLabel<LabelType>;
|
|
1563
|
+
shiftActionDown: BaseTranslationWithLabel<LabelType>;
|
|
1564
|
+
dragHandle: BaseTranslationWithLabel<LabelType>;
|
|
1565
|
+
lockRule: BaseTranslationWithLabel<LabelType>;
|
|
1566
|
+
lockGroup: BaseTranslationWithLabel<LabelType>;
|
|
1567
|
+
lockRuleDisabled: BaseTranslationWithLabel<LabelType>;
|
|
1568
|
+
lockGroupDisabled: BaseTranslationWithLabel<LabelType>;
|
|
1569
|
+
muteRule: BaseTranslationWithLabel<LabelType>;
|
|
1570
|
+
muteGroup: BaseTranslationWithLabel<LabelType>;
|
|
1571
|
+
unmuteRule: BaseTranslationWithLabel<LabelType>;
|
|
1572
|
+
unmuteGroup: BaseTranslationWithLabel<LabelType>;
|
|
1573
|
+
valueSourceSelector: BaseTranslation;
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Functions included in the `actions` prop passed to every subcomponent.
|
|
1577
|
+
*
|
|
1578
|
+
* @group Props
|
|
1579
|
+
*/
|
|
1580
|
+
interface QueryActions {
|
|
1581
|
+
onGroupAdd(group: RuleGroupTypeAny, parentPath: Path, context?: any): void;
|
|
1582
|
+
onGroupRemove(path: Path): void;
|
|
1583
|
+
onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, "id" | "path">, value: any, path: Path, context?: any): void;
|
|
1584
|
+
onRuleAdd(rule: RuleType, parentPath: Path, context?: any): void;
|
|
1585
|
+
onRuleRemove(path: Path): void;
|
|
1586
|
+
moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
|
|
1587
|
+
groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
|
|
1588
|
+
}
|
|
1589
|
+
interface QueryBuilderFlags {
|
|
1590
|
+
/**
|
|
1591
|
+
* Set to `false` to avoid calling the `onQueryChange` callback
|
|
1592
|
+
* when the component mounts.
|
|
1593
|
+
*
|
|
1594
|
+
* @default true
|
|
1595
|
+
*/
|
|
1596
|
+
enableMountQueryChange?: boolean;
|
|
1597
|
+
/**
|
|
1598
|
+
* Enables drag-and-drop features.
|
|
1599
|
+
*
|
|
1600
|
+
* @default false
|
|
1601
|
+
*/
|
|
1602
|
+
enableDragAndDrop?: boolean;
|
|
1603
|
+
/**
|
|
1604
|
+
* Enables debug logging for query builders (and React DnD when applicable).
|
|
1605
|
+
*
|
|
1606
|
+
* @default false
|
|
1607
|
+
*/
|
|
1608
|
+
debugMode?: boolean;
|
|
1404
1609
|
/**
|
|
1405
|
-
*
|
|
1610
|
+
* Show group combinator selectors in the body of the group, between each child rule/group,
|
|
1611
|
+
* instead of in the group header.
|
|
1612
|
+
*
|
|
1613
|
+
* @default false
|
|
1406
1614
|
*/
|
|
1407
|
-
|
|
1615
|
+
showCombinatorsBetweenRules?: boolean;
|
|
1408
1616
|
/**
|
|
1409
|
-
*
|
|
1617
|
+
* Show the "not" (aka inversion) toggle for rule groups.
|
|
1618
|
+
*
|
|
1619
|
+
* @default false
|
|
1410
1620
|
*/
|
|
1411
|
-
|
|
1621
|
+
showNotToggle?: boolean;
|
|
1412
1622
|
/**
|
|
1413
|
-
*
|
|
1623
|
+
* Show the "Shift up"/"Shift down" actions.
|
|
1624
|
+
*
|
|
1625
|
+
* @default false
|
|
1414
1626
|
*/
|
|
1415
|
-
|
|
1627
|
+
showShiftActions?: boolean;
|
|
1416
1628
|
/**
|
|
1417
|
-
*
|
|
1629
|
+
* Show the "Clone rule" and "Clone group" buttons.
|
|
1630
|
+
*
|
|
1631
|
+
* @default false
|
|
1418
1632
|
*/
|
|
1419
|
-
|
|
1633
|
+
showCloneButtons?: boolean;
|
|
1420
1634
|
/**
|
|
1421
|
-
*
|
|
1635
|
+
* Show the "Lock rule" and "Lock group" buttons.
|
|
1636
|
+
*
|
|
1637
|
+
* @default false
|
|
1422
1638
|
*/
|
|
1423
|
-
|
|
1639
|
+
showLockButtons?: boolean;
|
|
1424
1640
|
/**
|
|
1425
|
-
*
|
|
1641
|
+
* Show the "Mute rule" and "Mute group" buttons.
|
|
1642
|
+
*
|
|
1643
|
+
* @default false
|
|
1426
1644
|
*/
|
|
1427
|
-
|
|
1645
|
+
showMuteButtons?: boolean;
|
|
1428
1646
|
/**
|
|
1429
|
-
*
|
|
1647
|
+
* Reset the `operator` and `value` when the `field` changes.
|
|
1648
|
+
*
|
|
1649
|
+
* @default true
|
|
1430
1650
|
*/
|
|
1431
|
-
|
|
1651
|
+
resetOnFieldChange?: boolean;
|
|
1432
1652
|
/**
|
|
1433
|
-
*
|
|
1434
|
-
*
|
|
1653
|
+
* Reset the `value` when the `operator` changes.
|
|
1654
|
+
*
|
|
1655
|
+
* @default false
|
|
1435
1656
|
*/
|
|
1436
|
-
|
|
1657
|
+
resetOnOperatorChange?: boolean;
|
|
1437
1658
|
/**
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
1659
|
+
* Select the first field in the array automatically.
|
|
1660
|
+
*
|
|
1661
|
+
* @default true
|
|
1440
1662
|
*/
|
|
1441
|
-
|
|
1663
|
+
autoSelectField?: boolean;
|
|
1442
1664
|
/**
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1665
|
+
* Select the first operator in the array automatically.
|
|
1666
|
+
*
|
|
1667
|
+
* @default true
|
|
1445
1668
|
*/
|
|
1446
|
-
|
|
1669
|
+
autoSelectOperator?: boolean;
|
|
1447
1670
|
/**
|
|
1448
|
-
*
|
|
1671
|
+
* Select the first value in the array automatically. Only applicable when the value editor renders a select list.
|
|
1672
|
+
*
|
|
1673
|
+
* @default false
|
|
1449
1674
|
*/
|
|
1450
|
-
|
|
1675
|
+
autoSelectValue?: boolean;
|
|
1451
1676
|
/**
|
|
1452
|
-
*
|
|
1677
|
+
* Adds a new default rule automatically to each new group.
|
|
1678
|
+
*
|
|
1679
|
+
* @default false
|
|
1453
1680
|
*/
|
|
1454
|
-
|
|
1681
|
+
addRuleToNewGroups?: boolean;
|
|
1455
1682
|
/**
|
|
1456
|
-
*
|
|
1683
|
+
* Store list-type values as native arrays instead of comma-separated strings.
|
|
1684
|
+
*
|
|
1685
|
+
* @default false
|
|
1457
1686
|
*/
|
|
1458
|
-
|
|
1687
|
+
listsAsArrays?: boolean;
|
|
1459
1688
|
/**
|
|
1460
|
-
*
|
|
1689
|
+
* Prevent _any_ assignment of standard classes to elements. This includes conditional
|
|
1690
|
+
* and event-based classes for validation, drag-and-drop, etc.
|
|
1691
|
+
*
|
|
1692
|
+
* @default false
|
|
1461
1693
|
*/
|
|
1462
|
-
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* Functions included in the `actions` prop passed to every subcomponent.
|
|
1466
|
-
*
|
|
1467
|
-
* @group Props
|
|
1468
|
-
*/
|
|
1469
|
-
interface QueryActions {
|
|
1470
|
-
onGroupAdd(group: RuleGroupTypeAny, parentPath: Path, context?: any): void;
|
|
1471
|
-
onGroupRemove(path: Path): void;
|
|
1472
|
-
onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, "id" | "path">, value: any, path: Path, context?: any): void;
|
|
1473
|
-
onRuleAdd(rule: RuleType, parentPath: Path, context?: any): void;
|
|
1474
|
-
onRuleRemove(path: Path): void;
|
|
1475
|
-
moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
|
|
1476
|
-
groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
|
|
1694
|
+
suppressStandardClassnames?: boolean;
|
|
1477
1695
|
}
|
|
1478
1696
|
//#endregion
|
|
1479
1697
|
//#region ../core/src/utils/queryTools.d.ts
|
|
@@ -1525,7 +1743,8 @@ interface UseRuleGroup extends RuleGroupProps {
|
|
|
1525
1743
|
addGroup: ActionElementEventHandler;
|
|
1526
1744
|
addRule: ActionElementEventHandler;
|
|
1527
1745
|
accessibleDescription: string;
|
|
1528
|
-
|
|
1746
|
+
muted?: boolean;
|
|
1747
|
+
classNames: Pick<{ [k in keyof Classnames]: string }, "header" | "shiftActions" | "dragHandle" | "combinators" | "notToggle" | "addRule" | "addGroup" | "cloneGroup" | "lockGroup" | "muteGroup" | "removeGroup" | "body">;
|
|
1529
1748
|
cloneGroup: ActionElementEventHandler;
|
|
1530
1749
|
onCombinatorChange: ValueChangeEventHandler;
|
|
1531
1750
|
onGroupAdd: (group: RuleGroupTypeAny, parentPath: Path, context?: any) => void;
|
|
@@ -1541,6 +1760,7 @@ interface UseRuleGroup extends RuleGroupProps {
|
|
|
1541
1760
|
shiftGroupDown: (event?: MouseEvent, context?: any) => void;
|
|
1542
1761
|
shiftGroupUp: (event?: MouseEvent, context?: any) => void;
|
|
1543
1762
|
toggleLockGroup: ActionElementEventHandler;
|
|
1763
|
+
toggleMuteGroup: ActionElementEventHandler;
|
|
1544
1764
|
validationClassName: string;
|
|
1545
1765
|
validationResult: boolean | ValidationResult;
|
|
1546
1766
|
}
|
|
@@ -1677,74 +1897,13 @@ interface ValueSourceSelectorProps extends BaseSelectorProps<FullOption>, Common
|
|
|
1677
1897
|
*
|
|
1678
1898
|
* @group Props
|
|
1679
1899
|
*/
|
|
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 {}
|
|
1900
|
+
interface TranslationWithLabel extends BaseTranslationWithLabel<ReactNode> {}
|
|
1719
1901
|
/**
|
|
1720
1902
|
* The shape of the `translations` prop.
|
|
1721
1903
|
*
|
|
1722
1904
|
* @group Props
|
|
1723
1905
|
*/
|
|
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
|
-
}
|
|
1906
|
+
interface Translations extends BaseTranslations<ReactNode> {}
|
|
1748
1907
|
/**
|
|
1749
1908
|
* Props passed to every action component (rendered as `<button>` by default).
|
|
1750
1909
|
*
|
|
@@ -1948,6 +2107,18 @@ type ControlElementsProp<F extends FullField, O extends string> = Partial<{
|
|
|
1948
2107
|
*/
|
|
1949
2108
|
lockRuleAction: ComponentType<ActionProps> | null;
|
|
1950
2109
|
/**
|
|
2110
|
+
* Mutes the current group (sets the `muted` property to `true`).
|
|
2111
|
+
*
|
|
2112
|
+
* @default ActionElement
|
|
2113
|
+
*/
|
|
2114
|
+
muteGroupAction: ComponentType<ActionProps> | null;
|
|
2115
|
+
/**
|
|
2116
|
+
* Mutes the current rule (sets the `muted` property to `true`).
|
|
2117
|
+
*
|
|
2118
|
+
* @default ActionElement
|
|
2119
|
+
*/
|
|
2120
|
+
muteRuleAction: ComponentType<ActionProps> | null;
|
|
2121
|
+
/**
|
|
1951
2122
|
* Selects the `match` property for the current rule.
|
|
1952
2123
|
*
|
|
1953
2124
|
* @default MatchModeEditor
|
|
@@ -2077,6 +2248,7 @@ interface Schema<F extends FullField, O extends string> {
|
|
|
2077
2248
|
showShiftActions: boolean;
|
|
2078
2249
|
showCloneButtons: boolean;
|
|
2079
2250
|
showLockButtons: boolean;
|
|
2251
|
+
showMuteButtons: boolean;
|
|
2080
2252
|
autoSelectField: boolean;
|
|
2081
2253
|
autoSelectOperator: boolean;
|
|
2082
2254
|
autoSelectValue: boolean;
|
|
@@ -2097,6 +2269,7 @@ interface CommonRuleAndGroupProps<F extends FullField = FullField, O extends str
|
|
|
2097
2269
|
id?: string;
|
|
2098
2270
|
path: Path;
|
|
2099
2271
|
parentDisabled?: boolean;
|
|
2272
|
+
parentMuted?: boolean;
|
|
2100
2273
|
translations: Translations;
|
|
2101
2274
|
schema: Schema<F, O>;
|
|
2102
2275
|
actions: QueryActions;
|
|
@@ -2187,19 +2360,12 @@ interface RuleProps<F extends string = string, O extends string = string> extend
|
|
|
2187
2360
|
*
|
|
2188
2361
|
* @group Props
|
|
2189
2362
|
*/
|
|
2190
|
-
interface QueryBuilderContextProps<F extends FullField, O extends string> {
|
|
2363
|
+
interface QueryBuilderContextProps<F extends FullField = FullField, O extends string = string> extends QueryBuilderFlags {
|
|
2191
2364
|
/**
|
|
2192
2365
|
* Defines replacement components.
|
|
2193
2366
|
*/
|
|
2194
2367
|
controlElements?: ControlElementsProp<F, O>;
|
|
2195
2368
|
/**
|
|
2196
|
-
* Set to `false` to avoid calling the `onQueryChange` callback
|
|
2197
|
-
* when the component mounts.
|
|
2198
|
-
*
|
|
2199
|
-
* @default true
|
|
2200
|
-
*/
|
|
2201
|
-
enableMountQueryChange?: boolean;
|
|
2202
|
-
/**
|
|
2203
2369
|
* This can be used to assign specific CSS classes to various controls
|
|
2204
2370
|
* that are rendered by {@link QueryBuilder}.
|
|
2205
2371
|
*/
|
|
@@ -2209,23 +2375,11 @@ interface QueryBuilderContextProps<F extends FullField, O extends string> {
|
|
|
2209
2375
|
* controls that are rendered by {@link QueryBuilder}.
|
|
2210
2376
|
*/
|
|
2211
2377
|
translations?: Partial<Translations>;
|
|
2212
|
-
/**
|
|
2213
|
-
* Enables drag-and-drop features.
|
|
2214
|
-
*
|
|
2215
|
-
* @default false
|
|
2216
|
-
*/
|
|
2217
|
-
enableDragAndDrop?: boolean;
|
|
2218
|
-
/**
|
|
2219
|
-
* Enables debug logging for {@link QueryBuilder} (and React DnD when applicable).
|
|
2220
|
-
*
|
|
2221
|
-
* @default false
|
|
2222
|
-
*/
|
|
2223
|
-
debugMode?: boolean;
|
|
2224
2378
|
}
|
|
2225
2379
|
/**
|
|
2226
2380
|
* @group Props
|
|
2227
2381
|
*/
|
|
2228
|
-
interface QueryBuilderContextProviderProps extends QueryBuilderContextProps
|
|
2382
|
+
interface QueryBuilderContextProviderProps extends QueryBuilderContextProps {
|
|
2229
2383
|
children?: ReactNode;
|
|
2230
2384
|
}
|
|
2231
2385
|
/**
|
|
@@ -2249,15 +2403,15 @@ type QueryBuilderContextProvider<ExtraProps extends object = Record<string, any>
|
|
|
2249
2403
|
*
|
|
2250
2404
|
* @group Props
|
|
2251
2405
|
*/
|
|
2252
|
-
type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O extends FullOperator, C extends FullCombinator> = RG extends RuleGroupType<infer R> | RuleGroupTypeIC<infer R> ? QueryBuilderContextProps<F, GetOptionIdentifierType<O>> & {
|
|
2406
|
+
type QueryBuilderProps<RG$1 extends RuleGroupTypeAny, F extends FullField, O extends FullOperator, C extends FullCombinator> = RG$1 extends RuleGroupType<infer R> | RuleGroupTypeIC<infer R> ? QueryBuilderContextProps<F, GetOptionIdentifierType<O>> & {
|
|
2253
2407
|
/**
|
|
2254
2408
|
* Initial query object for uncontrolled components.
|
|
2255
2409
|
*/
|
|
2256
|
-
defaultQuery?: RG;
|
|
2410
|
+
defaultQuery?: RG$1;
|
|
2257
2411
|
/**
|
|
2258
2412
|
* Query object for controlled components.
|
|
2259
2413
|
*/
|
|
2260
|
-
query?: RG;
|
|
2414
|
+
query?: RG$1;
|
|
2261
2415
|
/**
|
|
2262
2416
|
* List of valid {@link FullField}s.
|
|
2263
2417
|
*
|
|
@@ -2409,7 +2563,7 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
|
|
|
2409
2563
|
*/
|
|
2410
2564
|
getSubQueryBuilderProps?(field: GetOptionIdentifierType<F>, misc: {
|
|
2411
2565
|
fieldData: F;
|
|
2412
|
-
}): QueryBuilderProps<GenericizeRuleGroupType<RG>, FullOption, FullOption, FullOption>;
|
|
2566
|
+
}): QueryBuilderProps<GenericizeRuleGroupType<RG$1>, FullOption, FullOption, FullOption>;
|
|
2413
2567
|
/**
|
|
2414
2568
|
* The return value of this function will be used to apply classnames to the
|
|
2415
2569
|
* outer `<div>` of the given {@link Rule}.
|
|
@@ -2421,56 +2575,56 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
|
|
|
2421
2575
|
* The return value of this function will be used to apply classnames to the
|
|
2422
2576
|
* outer `<div>` of the given {@link RuleGroup}.
|
|
2423
2577
|
*/
|
|
2424
|
-
getRuleGroupClassname?(ruleGroup: RG): Classname;
|
|
2578
|
+
getRuleGroupClassname?(ruleGroup: RG$1): Classname;
|
|
2425
2579
|
/**
|
|
2426
2580
|
* This callback is invoked before a new rule is added. The function should either manipulate
|
|
2427
2581
|
* the rule and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2428
2582
|
* or return `false` to cancel the addition of the rule.
|
|
2429
2583
|
*/
|
|
2430
|
-
onAddRule?(rule: R, parentPath: Path, query: RG, context?: any): RuleType | boolean;
|
|
2584
|
+
onAddRule?(rule: R, parentPath: Path, query: RG$1, context?: any): RuleType | boolean;
|
|
2431
2585
|
/**
|
|
2432
2586
|
* This callback is invoked before a new group is added. The function should either manipulate
|
|
2433
2587
|
* the group and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2434
2588
|
* or return `false` to cancel the addition of the group.
|
|
2435
2589
|
*/
|
|
2436
|
-
onAddGroup?(ruleGroup: RG, parentPath: Path, query: RG, context?: any): RG | boolean;
|
|
2590
|
+
onAddGroup?(ruleGroup: RG$1, parentPath: Path, query: RG$1, context?: any): RG$1 | boolean;
|
|
2437
2591
|
/**
|
|
2438
2592
|
* This callback is invoked before a rule is moved or shifted. The function should return
|
|
2439
2593
|
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2440
2594
|
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2441
2595
|
* query state.
|
|
2442
2596
|
*/
|
|
2443
|
-
onMoveRule?(rule: R, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2597
|
+
onMoveRule?(rule: R, fromPath: Path, toPath: Path | "up" | "down", query: RG$1, nextQuery: RG$1, options: MoveOptions, context?: any): RG$1 | boolean;
|
|
2444
2598
|
/**
|
|
2445
2599
|
* This callback is invoked before a group is moved or shifted. The function should return
|
|
2446
2600
|
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2447
2601
|
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2448
2602
|
* query state.
|
|
2449
2603
|
*/
|
|
2450
|
-
onMoveGroup?(ruleGroup: RG, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2604
|
+
onMoveGroup?(ruleGroup: RG$1, fromPath: Path, toPath: Path | "up" | "down", query: RG$1, nextQuery: RG$1, options: MoveOptions, context?: any): RG$1 | boolean;
|
|
2451
2605
|
/**
|
|
2452
2606
|
* This callback is invoked before a rule is grouped with another object. The function should
|
|
2453
2607
|
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2454
2608
|
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2455
2609
|
* query state.
|
|
2456
2610
|
*/
|
|
2457
|
-
onGroupRule?(rule: R, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2611
|
+
onGroupRule?(rule: R, fromPath: Path, toPath: Path, query: RG$1, nextQuery: RG$1, options: GroupOptions, context?: any): RG$1 | boolean;
|
|
2458
2612
|
/**
|
|
2459
2613
|
* This callback is invoked before a group is grouped with another object. The function should
|
|
2460
2614
|
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2461
2615
|
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2462
2616
|
* query state.
|
|
2463
2617
|
*/
|
|
2464
|
-
onGroupGroup?(ruleGroup: RG, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2618
|
+
onGroupGroup?(ruleGroup: RG$1, fromPath: Path, toPath: Path, query: RG$1, nextQuery: RG$1, options: GroupOptions, context?: any): RG$1 | boolean;
|
|
2465
2619
|
/**
|
|
2466
2620
|
* This callback is invoked before a rule or group is removed. The function should return
|
|
2467
2621
|
* `true` if the rule or group should be removed or `false` if it should not be removed.
|
|
2468
2622
|
*/
|
|
2469
|
-
onRemove?(ruleOrGroup: R | RG, path: Path, query: RG, context?: any): boolean;
|
|
2623
|
+
onRemove?(ruleOrGroup: R | RG$1, path: Path, query: RG$1, context?: any): boolean;
|
|
2470
2624
|
/**
|
|
2471
2625
|
* This callback is invoked anytime the query state is updated.
|
|
2472
2626
|
*/
|
|
2473
|
-
onQueryChange?(query: RG): void;
|
|
2627
|
+
onQueryChange?(query: RG$1): void;
|
|
2474
2628
|
/**
|
|
2475
2629
|
* Each log object will be passed to this function when `debugMode` is `true`.
|
|
2476
2630
|
*
|
|
@@ -2478,84 +2632,20 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
|
|
|
2478
2632
|
*/
|
|
2479
2633
|
onLog?(obj: any): void;
|
|
2480
2634
|
/**
|
|
2481
|
-
* Show group combinator selectors in the body of the group, between each child rule/group,
|
|
2482
|
-
* instead of in the group header.
|
|
2483
|
-
*
|
|
2484
|
-
* @default false
|
|
2485
|
-
*/
|
|
2486
|
-
showCombinatorsBetweenRules?: boolean;
|
|
2487
|
-
/**
|
|
2488
2635
|
* @deprecated As of v7, this prop is ignored. To enable independent combinators, use
|
|
2489
2636
|
* {@link RuleGroupTypeIC} for the `query` or `defaultQuery` prop. The query builder
|
|
2490
2637
|
* will detect the query type and behave accordingly.
|
|
2491
2638
|
*/
|
|
2492
2639
|
independentCombinators?: boolean;
|
|
2493
2640
|
/**
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
*
|
|
2497
|
-
|
|
2498
|
-
showNotToggle?: boolean;
|
|
2499
|
-
/**
|
|
2500
|
-
* Show the "Shift up"/"Shift down" actions.
|
|
2501
|
-
*
|
|
2502
|
-
* @default false
|
|
2503
|
-
*/
|
|
2504
|
-
showShiftActions?: boolean;
|
|
2505
|
-
/**
|
|
2506
|
-
* Show the "Clone rule" and "Clone group" buttons.
|
|
2507
|
-
*
|
|
2508
|
-
* @default false
|
|
2509
|
-
*/
|
|
2510
|
-
showCloneButtons?: boolean;
|
|
2511
|
-
/**
|
|
2512
|
-
* Show the "Lock rule" and "Lock group" buttons.
|
|
2513
|
-
*
|
|
2514
|
-
* @default false
|
|
2515
|
-
*/
|
|
2516
|
-
showLockButtons?: boolean;
|
|
2517
|
-
/**
|
|
2518
|
-
* Reset the `operator` and `value` when the `field` changes.
|
|
2519
|
-
*
|
|
2520
|
-
* @default true
|
|
2521
|
-
*/
|
|
2522
|
-
resetOnFieldChange?: boolean;
|
|
2523
|
-
/**
|
|
2524
|
-
* Reset the `value` when the `operator` changes.
|
|
2525
|
-
*
|
|
2526
|
-
* @default false
|
|
2527
|
-
*/
|
|
2528
|
-
resetOnOperatorChange?: boolean;
|
|
2529
|
-
/**
|
|
2530
|
-
* Select the first field in the array automatically.
|
|
2531
|
-
*
|
|
2532
|
-
* @default true
|
|
2533
|
-
*/
|
|
2534
|
-
autoSelectField?: boolean;
|
|
2535
|
-
/**
|
|
2536
|
-
* Select the first operator in the array automatically.
|
|
2537
|
-
*
|
|
2538
|
-
* @default true
|
|
2539
|
-
*/
|
|
2540
|
-
autoSelectOperator?: boolean;
|
|
2541
|
-
/**
|
|
2542
|
-
* Select the first value in the array automatically. Only applicable when the value editor renders a select list.
|
|
2543
|
-
*
|
|
2544
|
-
* @default false
|
|
2545
|
-
*/
|
|
2546
|
-
autoSelectValue?: boolean;
|
|
2547
|
-
/**
|
|
2548
|
-
* Adds a new default rule automatically to each new group.
|
|
2549
|
-
*
|
|
2550
|
-
* @default false
|
|
2551
|
-
*/
|
|
2552
|
-
addRuleToNewGroups?: boolean;
|
|
2553
|
-
/**
|
|
2554
|
-
* Store list-type values as native arrays instead of comma-separated strings.
|
|
2641
|
+
* Disables the entire query builder if true, or the rules and groups at
|
|
2642
|
+
* the specified paths (as well as all child rules/groups and subcomponents)
|
|
2643
|
+
* if an array of paths is provided. If the root path is specified (`disabled={[[]]}`),
|
|
2644
|
+
* no changes to the query are allowed.
|
|
2555
2645
|
*
|
|
2556
2646
|
* @default false
|
|
2557
2647
|
*/
|
|
2558
|
-
|
|
2648
|
+
disabled?: boolean | Path[];
|
|
2559
2649
|
/**
|
|
2560
2650
|
* Store values as numbers whenever possible.
|
|
2561
2651
|
*
|
|
@@ -2581,15 +2671,6 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
|
|
|
2581
2671
|
*/
|
|
2582
2672
|
parseNumbers?: ParseNumbersPropConfig;
|
|
2583
2673
|
/**
|
|
2584
|
-
* Disables the entire query builder if true, or the rules and groups at
|
|
2585
|
-
* the specified paths (as well as all child rules/groups and subcomponents)
|
|
2586
|
-
* if an array of paths is provided. If the root path is specified (`disabled={[[]]}`),
|
|
2587
|
-
* no changes to the query are allowed.
|
|
2588
|
-
*
|
|
2589
|
-
* @default false
|
|
2590
|
-
*/
|
|
2591
|
-
disabled?: boolean | Path[];
|
|
2592
|
-
/**
|
|
2593
2674
|
* Query validation function.
|
|
2594
2675
|
*/
|
|
2595
2676
|
validator?: QueryValidator;
|
|
@@ -2606,11 +2687,6 @@ type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O exten
|
|
|
2606
2687
|
*/
|
|
2607
2688
|
accessibleDescriptionGenerator?: AccessibleDescriptionGenerator;
|
|
2608
2689
|
/**
|
|
2609
|
-
* Prevent _any_ assignment of standard classes to elements. This includes conditional
|
|
2610
|
-
* and event-based classes for validation, drag-and-drop, etc.
|
|
2611
|
-
*/
|
|
2612
|
-
suppressStandardClassnames?: boolean;
|
|
2613
|
-
/**
|
|
2614
2690
|
* Maximum number of levels deep the query is allowed to go. The minimum is 1; values
|
|
2615
2691
|
* less than 1 will be ignored.
|
|
2616
2692
|
*/
|