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