@react-querybuilder/antd 8.13.0 → 8.14.1
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 +4 -2745
- package/dist/cjs/react-querybuilder_antd.cjs.development.js +28 -114
- package/dist/cjs/react-querybuilder_antd.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_antd.cjs.production.d.ts +4 -2745
- 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 +3 -2744
- package/dist/react-querybuilder_antd.legacy-esm.d.ts +3 -2744
- package/dist/react-querybuilder_antd.legacy-esm.js +21 -112
- package/dist/react-querybuilder_antd.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_antd.mjs +7 -92
- package/dist/react-querybuilder_antd.mjs.map +1 -1
- package/dist/react-querybuilder_antd.production.d.mts +3 -2744
- package/dist/react-querybuilder_antd.production.mjs +1 -1
- package/dist/react-querybuilder_antd.production.mjs.map +1 -1
- package/package.json +14 -14
|
@@ -1,2752 +1,11 @@
|
|
|
1
1
|
import { HolderOutlined } from "@ant-design/icons";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { ComponentPropsWithRef, ComponentPropsWithoutRef
|
|
3
|
+
import { ComponentPropsWithRef, ComponentPropsWithoutRef } from "react";
|
|
4
|
+
import { ActionProps, ControlElementsProp, DragHandleProps, FullField, NotToggleProps, QueryBuilderContextProvider, ShiftActionsProps, Translations, ValueEditorProps, VersatileSelectorProps } from "react-querybuilder";
|
|
4
5
|
import { Button, Select, Switch } from "antd";
|
|
5
6
|
|
|
6
|
-
//#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
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
|
-
|
|
11
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
12
|
-
|
|
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
|
-
@category Type
|
|
24
|
-
*/
|
|
25
|
-
type UnionToIntersection<Union> = (
|
|
26
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
27
|
-
// `Union` into a [distributive conditional
|
|
28
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
29
|
-
Union extends unknown
|
|
30
|
-
// The union type is used as the only argument to a function since the union
|
|
31
|
-
// of function arguments is an intersection.
|
|
32
|
-
? (distributedUnion: Union) => void
|
|
33
|
-
// This won't happen.
|
|
34
|
-
: never
|
|
35
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
36
|
-
// arguments of unions of functions as an intersection of the union.
|
|
37
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
38
|
-
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
39
|
-
? Intersection & Union : never;
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region ../../node_modules/type-fest/source/keys-of-union.d.ts
|
|
42
|
-
/**
|
|
43
|
-
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
44
|
-
|
|
45
|
-
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
46
|
-
|
|
47
|
-
@link https://stackoverflow.com/a/49402091
|
|
48
|
-
|
|
49
|
-
@example
|
|
50
|
-
```
|
|
51
|
-
import type {KeysOfUnion} from 'type-fest';
|
|
52
|
-
|
|
53
|
-
type A = {
|
|
54
|
-
common: string;
|
|
55
|
-
a: number;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type B = {
|
|
59
|
-
common: string;
|
|
60
|
-
b: string;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
type C = {
|
|
64
|
-
common: string;
|
|
65
|
-
c: boolean;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
type Union = A | B | C;
|
|
69
|
-
|
|
70
|
-
type CommonKeys = keyof Union;
|
|
71
|
-
//=> 'common'
|
|
72
|
-
|
|
73
|
-
type AllKeys = KeysOfUnion<Union>;
|
|
74
|
-
//=> 'common' | 'a' | 'b' | 'c'
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
@category Object
|
|
78
|
-
*/
|
|
79
|
-
type KeysOfUnion<ObjectType> =
|
|
80
|
-
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
81
|
-
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region ../../node_modules/type-fest/source/is-any.d.ts
|
|
84
|
-
/**
|
|
85
|
-
Returns a boolean for whether the given type is `any`.
|
|
86
|
-
|
|
87
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
88
|
-
|
|
89
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
90
|
-
|
|
91
|
-
@example
|
|
92
|
-
```
|
|
93
|
-
import type {IsAny} from 'type-fest';
|
|
94
|
-
|
|
95
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
96
|
-
const anyObject: any = {a: 1, b: 2};
|
|
97
|
-
|
|
98
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
99
|
-
return object[key];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const typedA = get(typedObject, 'a');
|
|
103
|
-
//=> 1
|
|
104
|
-
|
|
105
|
-
const anyA = get(anyObject, 'a');
|
|
106
|
-
//=> any
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
@category Type Guard
|
|
110
|
-
@category Utilities
|
|
111
|
-
*/
|
|
112
|
-
type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
115
|
-
/**
|
|
116
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
117
|
-
|
|
118
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
119
|
-
|
|
120
|
-
@example
|
|
121
|
-
```
|
|
122
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
123
|
-
|
|
124
|
-
type User = {
|
|
125
|
-
name: string;
|
|
126
|
-
surname: string;
|
|
127
|
-
|
|
128
|
-
luckyNumber?: number;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
type Admin = {
|
|
132
|
-
name: string;
|
|
133
|
-
surname?: string;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
137
|
-
//=> true
|
|
138
|
-
|
|
139
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
140
|
-
//=> false
|
|
141
|
-
|
|
142
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
143
|
-
//=> boolean
|
|
144
|
-
|
|
145
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
146
|
-
//=> false
|
|
147
|
-
|
|
148
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
149
|
-
//=> boolean
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
@category Type Guard
|
|
153
|
-
@category Utilities
|
|
154
|
-
*/
|
|
155
|
-
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;
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
|
|
158
|
-
/**
|
|
159
|
-
Extract all optional keys from the given type.
|
|
160
|
-
|
|
161
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
162
|
-
|
|
163
|
-
@example
|
|
164
|
-
```
|
|
165
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
166
|
-
|
|
167
|
-
type User = {
|
|
168
|
-
name: string;
|
|
169
|
-
surname: string;
|
|
170
|
-
|
|
171
|
-
luckyNumber?: number;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
175
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
176
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const update1: UpdateOperation<User> = {
|
|
180
|
-
name: 'Alice',
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const update2: UpdateOperation<User> = {
|
|
184
|
-
name: 'Bob',
|
|
185
|
-
luckyNumber: REMOVE_FIELD,
|
|
186
|
-
};
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
@category Utilities
|
|
190
|
-
*/
|
|
191
|
-
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
192
|
-
? (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`
|
|
193
|
-
: never;
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region ../../node_modules/type-fest/source/required-keys-of.d.ts
|
|
196
|
-
/**
|
|
197
|
-
Extract all required keys from the given type.
|
|
198
|
-
|
|
199
|
-
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...
|
|
200
|
-
|
|
201
|
-
@example
|
|
202
|
-
```
|
|
203
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
204
|
-
|
|
205
|
-
declare function createValidation<
|
|
206
|
-
Entity extends object,
|
|
207
|
-
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
208
|
-
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
209
|
-
|
|
210
|
-
type User = {
|
|
211
|
-
name: string;
|
|
212
|
-
surname: string;
|
|
213
|
-
luckyNumber?: number;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
217
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
218
|
-
|
|
219
|
-
// @ts-expect-error
|
|
220
|
-
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
221
|
-
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
@category Utilities
|
|
225
|
-
*/
|
|
226
|
-
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
227
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region ../../node_modules/type-fest/source/is-never.d.ts
|
|
230
|
-
/**
|
|
231
|
-
Returns a boolean for whether the given type is `never`.
|
|
232
|
-
|
|
233
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
234
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
235
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
236
|
-
|
|
237
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
238
|
-
|
|
239
|
-
@example
|
|
240
|
-
```
|
|
241
|
-
import type {IsNever, And} from 'type-fest';
|
|
242
|
-
|
|
243
|
-
type A = IsNever<never>;
|
|
244
|
-
//=> true
|
|
245
|
-
|
|
246
|
-
type B = IsNever<any>;
|
|
247
|
-
//=> false
|
|
248
|
-
|
|
249
|
-
type C = IsNever<unknown>;
|
|
250
|
-
//=> false
|
|
251
|
-
|
|
252
|
-
type D = IsNever<never[]>;
|
|
253
|
-
//=> false
|
|
254
|
-
|
|
255
|
-
type E = IsNever<object>;
|
|
256
|
-
//=> false
|
|
257
|
-
|
|
258
|
-
type F = IsNever<string>;
|
|
259
|
-
//=> false
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
@example
|
|
263
|
-
```
|
|
264
|
-
import type {IsNever} from 'type-fest';
|
|
265
|
-
|
|
266
|
-
type IsTrue<T> = T extends true ? true : false;
|
|
267
|
-
|
|
268
|
-
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
269
|
-
type A = IsTrue<never>;
|
|
270
|
-
// ^? type A = never
|
|
271
|
-
|
|
272
|
-
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
273
|
-
type IsTrueFixed<T> =
|
|
274
|
-
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
275
|
-
|
|
276
|
-
type B = IsTrueFixed<never>;
|
|
277
|
-
// ^? type B = false
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
@category Type Guard
|
|
281
|
-
@category Utilities
|
|
282
|
-
*/
|
|
283
|
-
type IsNever<T$1> = [T$1] extends [never] ? true : false;
|
|
284
|
-
//#endregion
|
|
285
|
-
//#region ../../node_modules/type-fest/source/if.d.ts
|
|
286
|
-
/**
|
|
287
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
288
|
-
|
|
289
|
-
Use-cases:
|
|
290
|
-
- 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'>`.
|
|
291
|
-
|
|
292
|
-
Note:
|
|
293
|
-
- 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'`.
|
|
294
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
295
|
-
|
|
296
|
-
@example
|
|
297
|
-
```
|
|
298
|
-
import type {If} from 'type-fest';
|
|
299
|
-
|
|
300
|
-
type A = If<true, 'yes', 'no'>;
|
|
301
|
-
//=> 'yes'
|
|
302
|
-
|
|
303
|
-
type B = If<false, 'yes', 'no'>;
|
|
304
|
-
//=> 'no'
|
|
305
|
-
|
|
306
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
307
|
-
//=> 'yes' | 'no'
|
|
308
|
-
|
|
309
|
-
type D = If<any, 'yes', 'no'>;
|
|
310
|
-
//=> 'yes' | 'no'
|
|
311
|
-
|
|
312
|
-
type E = If<never, 'yes', 'no'>;
|
|
313
|
-
//=> 'no'
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
@example
|
|
317
|
-
```
|
|
318
|
-
import type {If, IsAny, IsNever} from 'type-fest';
|
|
319
|
-
|
|
320
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
321
|
-
//=> 'not any'
|
|
322
|
-
|
|
323
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
324
|
-
//=> 'is never'
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
@example
|
|
328
|
-
```
|
|
329
|
-
import type {If, IsEqual} from 'type-fest';
|
|
330
|
-
|
|
331
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
332
|
-
|
|
333
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
334
|
-
//=> 'equal'
|
|
335
|
-
|
|
336
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
337
|
-
//=> 'not equal'
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
341
|
-
|
|
342
|
-
@example
|
|
343
|
-
```
|
|
344
|
-
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
345
|
-
|
|
346
|
-
type HundredZeroes = StringRepeat<'0', 100>;
|
|
347
|
-
|
|
348
|
-
// The following implementation is not tail recursive
|
|
349
|
-
type Includes<S extends string, Char extends string> =
|
|
350
|
-
S extends `${infer First}${infer Rest}`
|
|
351
|
-
? If<IsEqual<First, Char>,
|
|
352
|
-
'found',
|
|
353
|
-
Includes<Rest, Char>>
|
|
354
|
-
: 'not found';
|
|
355
|
-
|
|
356
|
-
// Hence, instantiations with long strings will fail
|
|
357
|
-
// @ts-expect-error
|
|
358
|
-
type Fails = Includes<HundredZeroes, '1'>;
|
|
359
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
360
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
361
|
-
|
|
362
|
-
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
363
|
-
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
364
|
-
S extends `${infer First}${infer Rest}`
|
|
365
|
-
? IsEqual<First, Char> extends true
|
|
366
|
-
? 'found'
|
|
367
|
-
: IncludesWithoutIf<Rest, Char>
|
|
368
|
-
: 'not found';
|
|
369
|
-
|
|
370
|
-
// Now, instantiations with long strings will work
|
|
371
|
-
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
372
|
-
//=> 'not found'
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
@category Type Guard
|
|
376
|
-
@category Utilities
|
|
377
|
-
*/
|
|
378
|
-
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region ../../node_modules/type-fest/source/unknown-array.d.ts
|
|
381
|
-
/**
|
|
382
|
-
Represents an array with `unknown` value.
|
|
383
|
-
|
|
384
|
-
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
385
|
-
|
|
386
|
-
@example
|
|
387
|
-
```
|
|
388
|
-
import type {UnknownArray} from 'type-fest';
|
|
389
|
-
|
|
390
|
-
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
391
|
-
|
|
392
|
-
type A = IsArray<['foo']>;
|
|
393
|
-
//=> true
|
|
394
|
-
|
|
395
|
-
type B = IsArray<readonly number[]>;
|
|
396
|
-
//=> true
|
|
397
|
-
|
|
398
|
-
type C = IsArray<string>;
|
|
399
|
-
//=> false
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
@category Type
|
|
403
|
-
@category Array
|
|
404
|
-
*/
|
|
405
|
-
type UnknownArray = readonly unknown[];
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region ../../node_modules/type-fest/source/internal/array.d.ts
|
|
408
|
-
/**
|
|
409
|
-
Returns whether the given array `T` is readonly.
|
|
410
|
-
*/
|
|
411
|
-
type IsArrayReadonly<T$1 extends UnknownArray> = If<IsNever<T$1>, false, T$1 extends unknown[] ? false : true>;
|
|
412
|
-
//#endregion
|
|
413
|
-
//#region ../../node_modules/type-fest/source/simplify.d.ts
|
|
414
|
-
/**
|
|
415
|
-
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.
|
|
416
|
-
|
|
417
|
-
@example
|
|
418
|
-
```
|
|
419
|
-
import type {Simplify} from 'type-fest';
|
|
420
|
-
|
|
421
|
-
type PositionProps = {
|
|
422
|
-
top: number;
|
|
423
|
-
left: number;
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
type SizeProps = {
|
|
427
|
-
width: number;
|
|
428
|
-
height: number;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
432
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
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.
|
|
436
|
-
|
|
437
|
-
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`.
|
|
438
|
-
|
|
439
|
-
@example
|
|
440
|
-
```
|
|
441
|
-
import type {Simplify} from 'type-fest';
|
|
442
|
-
|
|
443
|
-
interface SomeInterface {
|
|
444
|
-
foo: number;
|
|
445
|
-
bar?: string;
|
|
446
|
-
baz: number | undefined;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
type SomeType = {
|
|
450
|
-
foo: number;
|
|
451
|
-
bar?: string;
|
|
452
|
-
baz: number | undefined;
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
456
|
-
const someType: SomeType = literal;
|
|
457
|
-
const someInterface: SomeInterface = literal;
|
|
458
|
-
|
|
459
|
-
declare function fn(object: Record<string, unknown>): void;
|
|
460
|
-
|
|
461
|
-
fn(literal); // Good: literal object type is sealed
|
|
462
|
-
fn(someType); // Good: type is sealed
|
|
463
|
-
// @ts-expect-error
|
|
464
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
465
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
469
|
-
@see {@link SimplifyDeep}
|
|
470
|
-
@category Object
|
|
471
|
-
*/
|
|
472
|
-
type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region ../../node_modules/type-fest/source/is-equal.d.ts
|
|
475
|
-
/**
|
|
476
|
-
Returns a boolean for whether the two given types are equal.
|
|
477
|
-
|
|
478
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
479
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
480
|
-
|
|
481
|
-
Use-cases:
|
|
482
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
483
|
-
|
|
484
|
-
@example
|
|
485
|
-
```
|
|
486
|
-
import type {IsEqual} from 'type-fest';
|
|
487
|
-
|
|
488
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
489
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
490
|
-
type Includes<Value extends readonly any[], Item> =
|
|
491
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
492
|
-
? IsEqual<Value[0], Item> extends true
|
|
493
|
-
? true
|
|
494
|
-
: Includes<rest, Item>
|
|
495
|
-
: false;
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
@category Type Guard
|
|
499
|
-
@category Utilities
|
|
500
|
-
*/
|
|
501
|
-
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
502
|
-
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
503
|
-
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
504
|
-
//#endregion
|
|
505
|
-
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
506
|
-
/**
|
|
507
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
508
|
-
|
|
509
|
-
This is the counterpart of `PickIndexSignature`.
|
|
510
|
-
|
|
511
|
-
Use-cases:
|
|
512
|
-
- Remove overly permissive signatures from third-party types.
|
|
513
|
-
|
|
514
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
515
|
-
|
|
516
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
517
|
-
|
|
518
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
519
|
-
|
|
520
|
-
```
|
|
521
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
522
|
-
|
|
523
|
-
// @ts-expect-error
|
|
524
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
525
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
526
|
-
```
|
|
527
|
-
|
|
528
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
529
|
-
|
|
530
|
-
```
|
|
531
|
-
type Indexed = {} extends Record<string, unknown>
|
|
532
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
533
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
534
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
535
|
-
|
|
536
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
537
|
-
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
538
|
-
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
539
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
543
|
-
|
|
544
|
-
```
|
|
545
|
-
type OmitIndexSignature<ObjectType> = {
|
|
546
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
547
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
548
|
-
};
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
552
|
-
|
|
553
|
-
```
|
|
554
|
-
type OmitIndexSignature<ObjectType> = {
|
|
555
|
-
[KeyType in keyof ObjectType
|
|
556
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
557
|
-
as {} extends Record<KeyType, unknown>
|
|
558
|
-
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
559
|
-
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
560
|
-
]: ObjectType[KeyType];
|
|
561
|
-
};
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
565
|
-
|
|
566
|
-
@example
|
|
567
|
-
```
|
|
568
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
569
|
-
|
|
570
|
-
type Example = {
|
|
571
|
-
// These index signatures will be removed.
|
|
572
|
-
[x: string]: any;
|
|
573
|
-
[x: number]: any;
|
|
574
|
-
[x: symbol]: any;
|
|
575
|
-
[x: `head-${string}`]: string;
|
|
576
|
-
[x: `${string}-tail`]: string;
|
|
577
|
-
[x: `head-${string}-tail`]: string;
|
|
578
|
-
[x: `${bigint}`]: string;
|
|
579
|
-
[x: `embedded-${number}`]: string;
|
|
580
|
-
|
|
581
|
-
// These explicitly defined keys will remain.
|
|
582
|
-
foo: 'bar';
|
|
583
|
-
qux?: 'baz';
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
587
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
@see {@link PickIndexSignature}
|
|
591
|
-
@category Object
|
|
592
|
-
*/
|
|
593
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
594
|
-
//#endregion
|
|
595
|
-
//#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
|
|
596
|
-
/**
|
|
597
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
598
|
-
|
|
599
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
600
|
-
|
|
601
|
-
@example
|
|
602
|
-
```
|
|
603
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
604
|
-
|
|
605
|
-
declare const symbolKey: unique symbol;
|
|
606
|
-
|
|
607
|
-
type Example = {
|
|
608
|
-
// These index signatures will remain.
|
|
609
|
-
[x: string]: unknown;
|
|
610
|
-
[x: number]: unknown;
|
|
611
|
-
[x: symbol]: unknown;
|
|
612
|
-
[x: `head-${string}`]: string;
|
|
613
|
-
[x: `${string}-tail`]: string;
|
|
614
|
-
[x: `head-${string}-tail`]: string;
|
|
615
|
-
[x: `${bigint}`]: string;
|
|
616
|
-
[x: `embedded-${number}`]: string;
|
|
617
|
-
|
|
618
|
-
// These explicitly defined keys will be removed.
|
|
619
|
-
['kebab-case-key']: string;
|
|
620
|
-
[symbolKey]: string;
|
|
621
|
-
foo: 'bar';
|
|
622
|
-
qux?: 'baz';
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
626
|
-
// {
|
|
627
|
-
// [x: string]: unknown;
|
|
628
|
-
// [x: number]: unknown;
|
|
629
|
-
// [x: symbol]: unknown;
|
|
630
|
-
// [x: `head-${string}`]: string;
|
|
631
|
-
// [x: `${string}-tail`]: string;
|
|
632
|
-
// [x: `head-${string}-tail`]: string;
|
|
633
|
-
// [x: `${bigint}`]: string;
|
|
634
|
-
// [x: `embedded-${number}`]: string;
|
|
635
|
-
// }
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
@see {@link OmitIndexSignature}
|
|
639
|
-
@category Object
|
|
640
|
-
*/
|
|
641
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region ../../node_modules/type-fest/source/merge.d.ts
|
|
644
|
-
// Merges two objects without worrying about index signatures.
|
|
645
|
-
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
649
|
-
|
|
650
|
-
@example
|
|
651
|
-
```
|
|
652
|
-
import type {Merge} from 'type-fest';
|
|
653
|
-
|
|
654
|
-
type Foo = {
|
|
655
|
-
[x: string]: unknown;
|
|
656
|
-
[x: number]: unknown;
|
|
657
|
-
foo: string;
|
|
658
|
-
bar: symbol;
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
type Bar = {
|
|
662
|
-
[x: number]: number;
|
|
663
|
-
[x: symbol]: unknown;
|
|
664
|
-
bar: Date;
|
|
665
|
-
baz: boolean;
|
|
666
|
-
};
|
|
667
|
-
|
|
668
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
669
|
-
// => {
|
|
670
|
-
// [x: string]: unknown;
|
|
671
|
-
// [x: number]: number;
|
|
672
|
-
// [x: symbol]: unknown;
|
|
673
|
-
// foo: string;
|
|
674
|
-
// bar: Date;
|
|
675
|
-
// baz: boolean;
|
|
676
|
-
// }
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
@category Object
|
|
680
|
-
*/
|
|
681
|
-
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
682
|
-
//#endregion
|
|
683
|
-
//#region ../../node_modules/type-fest/source/internal/object.d.ts
|
|
684
|
-
/**
|
|
685
|
-
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
686
|
-
- Distributes over union types and allows picking keys from any member of the union type.
|
|
687
|
-
- Primitives types are returned as-is.
|
|
688
|
-
- Picks all keys if `Keys` is `any`.
|
|
689
|
-
- Doesn't pick `number` from a `string` index signature.
|
|
690
|
-
|
|
691
|
-
@example
|
|
692
|
-
```
|
|
693
|
-
type ImageUpload = {
|
|
694
|
-
url: string;
|
|
695
|
-
size: number;
|
|
696
|
-
thumbnailUrl: string;
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
type VideoUpload = {
|
|
700
|
-
url: string;
|
|
701
|
-
duration: number;
|
|
702
|
-
encodingFormat: string;
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
// Distributes over union types and allows picking keys from any member of the union type
|
|
706
|
-
type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
|
|
707
|
-
//=> {url: string; size: number} | {url: string; duration: number}
|
|
708
|
-
|
|
709
|
-
// Primitive types are returned as-is
|
|
710
|
-
type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
|
|
711
|
-
//=> string | number
|
|
712
|
-
|
|
713
|
-
// Picks all keys if `Keys` is `any`
|
|
714
|
-
type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
715
|
-
//=> {a: 1; b: 2} | {c: 3}
|
|
716
|
-
|
|
717
|
-
// Doesn't pick `number` from a `string` index signature
|
|
718
|
-
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
719
|
-
//=> {}
|
|
720
|
-
*/
|
|
721
|
-
type HomomorphicPick<T$1, Keys extends KeysOfUnion<T$1>> = { [P in keyof T$1 as Extract<P, Keys>]: T$1[P] };
|
|
722
|
-
/**
|
|
723
|
-
Merges user specified options with default options.
|
|
724
|
-
|
|
725
|
-
@example
|
|
726
|
-
```
|
|
727
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
728
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
729
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
730
|
-
|
|
731
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
732
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
@example
|
|
736
|
-
```
|
|
737
|
-
// Complains if default values are not provided for optional options
|
|
738
|
-
|
|
739
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
740
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
741
|
-
type SpecifiedOptions = {};
|
|
742
|
-
|
|
743
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
744
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
745
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
@example
|
|
749
|
-
```
|
|
750
|
-
// Complains if an option's default type does not conform to the expected type
|
|
751
|
-
|
|
752
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
753
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
754
|
-
type SpecifiedOptions = {};
|
|
755
|
-
|
|
756
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
757
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
758
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
@example
|
|
762
|
-
```
|
|
763
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
764
|
-
|
|
765
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
766
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
767
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
768
|
-
|
|
769
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
770
|
-
// ~~~~~~~~~~~~~~~~
|
|
771
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
772
|
-
```
|
|
773
|
-
*/
|
|
774
|
-
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>>>>;
|
|
775
|
-
//#endregion
|
|
776
|
-
//#region ../../node_modules/type-fest/source/except.d.ts
|
|
777
|
-
/**
|
|
778
|
-
Filter out keys from an object.
|
|
779
|
-
|
|
780
|
-
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
781
|
-
Returns `never` if `Key` extends `Exclude`.
|
|
782
|
-
Returns `Key` otherwise.
|
|
783
|
-
|
|
784
|
-
@example
|
|
785
|
-
```
|
|
786
|
-
type Filtered = Filter<'foo', 'foo'>;
|
|
787
|
-
//=> never
|
|
788
|
-
```
|
|
789
|
-
|
|
790
|
-
@example
|
|
791
|
-
```
|
|
792
|
-
type Filtered = Filter<'bar', string>;
|
|
793
|
-
//=> never
|
|
794
|
-
```
|
|
795
|
-
|
|
796
|
-
@example
|
|
797
|
-
```
|
|
798
|
-
type Filtered = Filter<'bar', 'foo'>;
|
|
799
|
-
//=> 'bar'
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
@see {Except}
|
|
803
|
-
*/
|
|
804
|
-
type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
|
|
805
|
-
type ExceptOptions = {
|
|
806
|
-
/**
|
|
807
|
-
Disallow assigning non-specified properties.
|
|
808
|
-
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
809
|
-
@default false
|
|
810
|
-
*/
|
|
811
|
-
requireExactProps?: boolean;
|
|
812
|
-
};
|
|
813
|
-
type DefaultExceptOptions = {
|
|
814
|
-
requireExactProps: false;
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
Create a type from an object type without certain keys.
|
|
819
|
-
|
|
820
|
-
We recommend setting the `requireExactProps` option to `true`.
|
|
821
|
-
|
|
822
|
-
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
823
|
-
|
|
824
|
-
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
825
|
-
|
|
826
|
-
@example
|
|
827
|
-
```
|
|
828
|
-
import type {Except} from 'type-fest';
|
|
829
|
-
|
|
830
|
-
type Foo = {
|
|
831
|
-
a: number;
|
|
832
|
-
b: string;
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
type FooWithoutA = Except<Foo, 'a'>;
|
|
836
|
-
//=> {b: string}
|
|
837
|
-
|
|
838
|
-
// @ts-expect-error
|
|
839
|
-
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
840
|
-
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
841
|
-
|
|
842
|
-
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
843
|
-
//=> {a: number} & Partial<Record<"b", never>>
|
|
844
|
-
|
|
845
|
-
// @ts-expect-error
|
|
846
|
-
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
847
|
-
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
848
|
-
|
|
849
|
-
// The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
|
|
850
|
-
|
|
851
|
-
// Consider the following example:
|
|
852
|
-
|
|
853
|
-
type UserData = {
|
|
854
|
-
[metadata: string]: string;
|
|
855
|
-
email: string;
|
|
856
|
-
name: string;
|
|
857
|
-
role: 'admin' | 'user';
|
|
858
|
-
};
|
|
859
|
-
|
|
860
|
-
// `Omit` clearly doesn't behave as expected in this case:
|
|
861
|
-
type PostPayload = Omit<UserData, 'email'>;
|
|
862
|
-
//=> { [x: string]: string; [x: number]: string; }
|
|
863
|
-
|
|
864
|
-
// In situations like this, `Except` works better.
|
|
865
|
-
// It simply removes the `email` key while preserving all the other keys.
|
|
866
|
-
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
867
|
-
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
868
|
-
```
|
|
869
|
-
|
|
870
|
-
@category Object
|
|
871
|
-
*/
|
|
872
|
-
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
873
|
-
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>> : {});
|
|
874
|
-
//#endregion
|
|
875
|
-
//#region ../../node_modules/type-fest/source/set-required.d.ts
|
|
876
|
-
/**
|
|
877
|
-
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
878
|
-
|
|
879
|
-
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.
|
|
880
|
-
|
|
881
|
-
@example
|
|
882
|
-
```
|
|
883
|
-
import type {SetRequired} from 'type-fest';
|
|
884
|
-
|
|
885
|
-
type Foo = {
|
|
886
|
-
a?: number;
|
|
887
|
-
b: string;
|
|
888
|
-
c?: boolean;
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
892
|
-
// type SomeRequired = {
|
|
893
|
-
// a?: number;
|
|
894
|
-
// b: string; // Was already required and still is.
|
|
895
|
-
// c: boolean; // Is now required.
|
|
896
|
-
// }
|
|
897
|
-
|
|
898
|
-
// Set specific indices in an array to be required.
|
|
899
|
-
type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
|
|
900
|
-
//=> [number, number, number?]
|
|
901
|
-
```
|
|
902
|
-
|
|
903
|
-
@category Object
|
|
904
|
-
*/
|
|
905
|
-
type SetRequired<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetRequired<BaseType, Keys>;
|
|
906
|
-
type _SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? If<IsArrayReadonly<BaseType>, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
|
|
907
|
-
// Pick just the keys that are optional from the base type.
|
|
908
|
-
Except<BaseType, Keys> &
|
|
909
|
-
// Pick the keys that should be required from the base type and make them required.
|
|
910
|
-
Required<HomomorphicPick<BaseType, Keys>>>;
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
Remove the optional modifier from the specified keys in an array.
|
|
914
|
-
*/
|
|
915
|
-
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
|
|
916
|
-
? keyof TArray & `${number}` extends never
|
|
917
|
-
// Exit if `TArray` is empty (e.g., []), or
|
|
918
|
-
// `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
919
|
-
? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
|
|
920
|
-
? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
|
|
921
|
-
? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
|
|
922
|
-
// If the current element is optional, but it doesn't need to be required,
|
|
923
|
-
// then we can exit early, since no further elements can now be made required.
|
|
924
|
-
: [...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.
|
|
925
|
-
: never; // Should never happen
|
|
926
|
-
//#endregion
|
|
927
|
-
//#region ../../node_modules/type-fest/source/set-non-nullable.d.ts
|
|
928
|
-
/**
|
|
929
|
-
Create a type that makes the given keys non-nullable, where the remaining keys are kept as is.
|
|
930
|
-
|
|
931
|
-
If no keys are given, all keys will be made non-nullable.
|
|
932
|
-
|
|
933
|
-
Use-case: You want to define a single model where the only thing that changes is whether or not some or all of the keys are non-nullable.
|
|
934
|
-
|
|
935
|
-
@example
|
|
936
|
-
```
|
|
937
|
-
import type {SetNonNullable} from 'type-fest';
|
|
938
|
-
|
|
939
|
-
type Foo = {
|
|
940
|
-
a: number | null;
|
|
941
|
-
b: string | undefined;
|
|
942
|
-
c?: boolean | null;
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
|
|
946
|
-
// type SomeNonNullable = {
|
|
947
|
-
// a: number | null;
|
|
948
|
-
// b: string; // Can no longer be undefined.
|
|
949
|
-
// c?: boolean; // Can no longer be null, but is still optional.
|
|
950
|
-
// }
|
|
951
|
-
|
|
952
|
-
type AllNonNullable = SetNonNullable<Foo>;
|
|
953
|
-
// type AllNonNullable = {
|
|
954
|
-
// a: number; // Can no longer be null.
|
|
955
|
-
// b: string; // Can no longer be undefined.
|
|
956
|
-
// c?: boolean; // Can no longer be null, but is still optional.
|
|
957
|
-
// }
|
|
958
|
-
```
|
|
959
|
-
|
|
960
|
-
@category Object
|
|
961
|
-
*/
|
|
962
|
-
type SetNonNullable<BaseType, Keys extends keyof BaseType = keyof BaseType> = { [Key in keyof BaseType]: Key extends Keys ? NonNullable<BaseType[Key]> : BaseType[Key] };
|
|
963
|
-
//#endregion
|
|
964
|
-
//#region ../core/src/types/options.d.ts
|
|
965
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
966
|
-
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
967
|
-
/**
|
|
968
|
-
* Extracts the type of the identifying property from a {@link Option},
|
|
969
|
-
* {@link ValueOption}, or {@link FullOption}.
|
|
970
|
-
*
|
|
971
|
-
* @group Option Lists
|
|
972
|
-
*/
|
|
973
|
-
type GetOptionIdentifierType<Opt$1 extends BaseOption> = Opt$1 extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
974
|
-
/**
|
|
975
|
-
* Adds an `unknown` index property to an interface.
|
|
976
|
-
*/
|
|
977
|
-
type WithUnknownIndex<T$1> = T$1 & {
|
|
978
|
-
[key: string]: unknown;
|
|
979
|
-
};
|
|
980
|
-
/**
|
|
981
|
-
* Do not use this type directly; use {@link Option}, {@link ValueOption},
|
|
982
|
-
* or {@link FullOption} instead. For specific option types, you can use
|
|
983
|
-
* {@link FullField}, {@link FullOperator}, or {@link FullCombinator},
|
|
984
|
-
* all of which extend {@link FullOption}.
|
|
985
|
-
*
|
|
986
|
-
* @group Option Lists
|
|
987
|
-
*/
|
|
988
|
-
interface BaseOption<N extends string = string> {
|
|
989
|
-
name?: N;
|
|
990
|
-
value?: N;
|
|
991
|
-
label: string;
|
|
992
|
-
disabled?: boolean;
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* A generic option. Used directly in {@link OptionList} or
|
|
996
|
-
* as the child element of an {@link OptionGroup}.
|
|
997
|
-
*
|
|
998
|
-
* @group Option Lists
|
|
999
|
-
*/
|
|
1000
|
-
type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name">>>;
|
|
1001
|
-
/**
|
|
1002
|
-
* Like {@link Option} but requiring `value` instead of `name`.
|
|
1003
|
-
*
|
|
1004
|
-
* @group Option Lists
|
|
1005
|
-
*/
|
|
1006
|
-
type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "value">>>;
|
|
1007
|
-
/**
|
|
1008
|
-
* A generic {@link Option} with either a `name` or `value` as its primary identifier.
|
|
1009
|
-
* {@link OptionList}-type props on the {@link react-querybuilder!QueryBuilder QueryBuilder} component accept this type,
|
|
1010
|
-
* but corresponding props passed down to subcomponents will always be augmented
|
|
1011
|
-
* to {@link FullOption} first.
|
|
1012
|
-
*
|
|
1013
|
-
* @group Option Lists
|
|
1014
|
-
*/
|
|
1015
|
-
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
|
|
1016
|
-
/**
|
|
1017
|
-
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
|
|
1018
|
-
* into a {@link FlexibleOption}.
|
|
1019
|
-
*
|
|
1020
|
-
* @group Option Lists
|
|
1021
|
-
*/
|
|
1022
|
-
type ToFlexibleOption<Opt$1 extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt$1 extends string ? FlexibleOption<Opt$1> : Opt$1, "name" | "value">>;
|
|
1023
|
-
/**
|
|
1024
|
-
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
1025
|
-
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
1026
|
-
* corresponding props sent to subcomponents will always be augmented to this
|
|
1027
|
-
* type first to ensure both `name` and `value` are available.
|
|
1028
|
-
*
|
|
1029
|
-
* NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
|
|
1030
|
-
* (optionally wrapped in {@link WithUnknownIndex}) instead, otherwise
|
|
1031
|
-
* the `unknown` index property will cause issues. See {@link Option} and
|
|
1032
|
-
* {@link ValueOption} for examples.
|
|
1033
|
-
*
|
|
1034
|
-
* @group Option Lists
|
|
1035
|
-
*/
|
|
1036
|
-
type FullOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name" | "value">>>;
|
|
1037
|
-
/**
|
|
1038
|
-
* This type is identical to {@link FullOption} but without the `unknown` index
|
|
1039
|
-
* property. Extend from this type instead of {@link FullOption} directly.
|
|
1040
|
-
*
|
|
1041
|
-
* @group Option Lists
|
|
1042
|
-
*/
|
|
1043
|
-
type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption<N>, "name" | "value">>;
|
|
1044
|
-
/**
|
|
1045
|
-
* Utility type to turn an {@link Option}, {@link ValueOption} or
|
|
1046
|
-
* {@link BaseOption} into a {@link FullOption}.
|
|
1047
|
-
*
|
|
1048
|
-
* @group Option Lists
|
|
1049
|
-
*/
|
|
1050
|
-
type ToFullOption<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1 : Opt$1 extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt$1 & FullOption<IdentifierType>> : never;
|
|
1051
|
-
/**
|
|
1052
|
-
* A group of {@link Option}s, usually within an {@link OptionList}.
|
|
1053
|
-
*
|
|
1054
|
-
* @group Option Lists
|
|
1055
|
-
*/
|
|
1056
|
-
interface OptionGroup<Opt$1 extends BaseOption = FlexibleOption> {
|
|
1057
|
-
label: string;
|
|
1058
|
-
options: WithUnknownIndex<Opt$1>[];
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1062
|
-
*
|
|
1063
|
-
* @group Option Lists
|
|
1064
|
-
*/
|
|
1065
|
-
type FlexibleOptionGroup<Opt$1 extends BaseOption | string = BaseOption> = {
|
|
1066
|
-
label: string;
|
|
1067
|
-
options: (Opt$1 extends BaseFullOption ? Opt$1 : ToFlexibleOption<Opt$1>)[];
|
|
1068
|
-
};
|
|
1069
|
-
/**
|
|
1070
|
-
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1071
|
-
*
|
|
1072
|
-
* @group Option Lists
|
|
1073
|
-
*/
|
|
1074
|
-
type OptionList<Opt$1 extends Option = Option> = Opt$1[] | OptionGroup<Opt$1>[];
|
|
1075
|
-
/**
|
|
1076
|
-
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1077
|
-
* may use either `name` or `value` as the primary identifier.
|
|
1078
|
-
*
|
|
1079
|
-
* @group Option Lists
|
|
1080
|
-
*/
|
|
1081
|
-
type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1>>[];
|
|
1082
|
-
/**
|
|
1083
|
-
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1084
|
-
* may use either `name` or `value` as the primary identifier.
|
|
1085
|
-
*
|
|
1086
|
-
* @group Option Lists
|
|
1087
|
-
*/
|
|
1088
|
-
type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>>[];
|
|
1089
|
-
/**
|
|
1090
|
-
* An array of options or option groups, like {@link OptionList}, but using
|
|
1091
|
-
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
1092
|
-
* guaranteed to have both `name` and `value`.
|
|
1093
|
-
*
|
|
1094
|
-
* @group Option Lists
|
|
1095
|
-
*/
|
|
1096
|
-
type FullOptionList<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1[] | OptionGroup<Opt$1>[] : ToFullOption<Opt$1>[] | OptionGroup<ToFullOption<Opt$1>>[];
|
|
1097
|
-
/**
|
|
1098
|
-
* Map of option identifiers to their respective {@link Option}.
|
|
1099
|
-
*
|
|
1100
|
-
* @group Option Lists
|
|
1101
|
-
*/
|
|
1102
|
-
type BaseOptionMap<V$1 extends BaseOption = BaseOption, K$1 extends string = GetOptionIdentifierType<V$1>> = { [k in K$1]?: ToFlexibleOption<V$1> };
|
|
1103
|
-
//#endregion
|
|
1104
|
-
//#region ../core/src/types/ruleGroups.d.ts
|
|
1105
|
-
/**
|
|
1106
|
-
* Properties common to both rules and groups.
|
|
1107
|
-
*/
|
|
1108
|
-
interface CommonRuleAndGroupProperties {
|
|
1109
|
-
path?: Path;
|
|
1110
|
-
id?: string;
|
|
1111
|
-
disabled?: boolean;
|
|
1112
|
-
/**
|
|
1113
|
-
* Whether this rule or group is muted. When muted, the rule or group
|
|
1114
|
-
* is excluded from query export formats (SQL, JSON, MongoDB, etc.).
|
|
1115
|
-
* For groups, muting recursively mutes all children.
|
|
1116
|
-
*/
|
|
1117
|
-
muted?: boolean;
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* The main rule type. The `field`, `operator`, and `value` properties
|
|
1121
|
-
* can be narrowed with generics.
|
|
1122
|
-
*/
|
|
1123
|
-
interface RuleType<F extends string = string, O extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1124
|
-
field: F;
|
|
1125
|
-
operator: O;
|
|
1126
|
-
value: V$1;
|
|
1127
|
-
valueSource?: ValueSource;
|
|
1128
|
-
match?: MatchConfig;
|
|
1129
|
-
/**
|
|
1130
|
-
* Only used when adding a rule to a query that uses independent combinators.
|
|
1131
|
-
*/
|
|
1132
|
-
combinatorPreceding?: C;
|
|
1133
|
-
}
|
|
1134
|
-
/**
|
|
1135
|
-
* The main rule group type. This type is used for query definitions as well as
|
|
1136
|
-
* all sub-groups of queries.
|
|
1137
|
-
*/
|
|
1138
|
-
interface RuleGroupType<R$1 extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1139
|
-
combinator: C;
|
|
1140
|
-
rules: RuleGroupArray<RuleGroupType<R$1, C>, R$1>;
|
|
1141
|
-
not?: boolean;
|
|
1142
|
-
}
|
|
1143
|
-
/**
|
|
1144
|
-
* The type of the `rules` array in a {@link RuleGroupType}.
|
|
1145
|
-
*/
|
|
1146
|
-
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R$1 extends RuleType = RuleType> = (R$1 | RG)[];
|
|
1147
|
-
//#endregion
|
|
1148
|
-
//#region ../core/src/types/ruleGroupsIC.utils.d.ts
|
|
1149
|
-
type MAXIMUM_ALLOWED_BOUNDARY = 80;
|
|
1150
|
-
type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [], Count extends ReadonlyArray<number> = []> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result : Tuple extends [] ? [] : Result extends [] ? MappedTuple<Tuple, Tuple, [...Count, 1]> : MappedTuple<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;
|
|
1151
|
-
//#endregion
|
|
1152
|
-
//#region ../core/src/types/ruleGroupsIC.d.ts
|
|
1153
|
-
/**
|
|
1154
|
-
* The main rule group interface when using independent combinators. This type is used
|
|
1155
|
-
* for query definitions as well as all sub-groups of queries.
|
|
1156
|
-
*/
|
|
1157
|
-
interface RuleGroupTypeIC<R$1 extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R$1, C>, "combinator" | "rules"> {
|
|
1158
|
-
combinator?: undefined;
|
|
1159
|
-
rules: RuleGroupICArray<RuleGroupTypeIC<R$1, C>, R$1, C>;
|
|
1160
|
-
/**
|
|
1161
|
-
* Only used when adding a rule to a query that uses independent combinators
|
|
1162
|
-
*/
|
|
1163
|
-
combinatorPreceding?: C;
|
|
1164
|
-
}
|
|
1165
|
-
/**
|
|
1166
|
-
* Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
|
|
1167
|
-
*/
|
|
1168
|
-
type RuleGroupTypeAny<R$1 extends RuleType = RuleType, C extends string = string> = RuleGroupType<R$1, C> | RuleGroupTypeIC<R$1, C>;
|
|
1169
|
-
/**
|
|
1170
|
-
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
|
|
1171
|
-
*/
|
|
1172
|
-
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R$1 extends RuleType = RuleType, C extends string = string> = [R$1 | RG] | [R$1 | RG, ...MappedTuple<[C, R$1 | RG]>] | ((R$1 | RG)[] & {
|
|
1173
|
-
length: 0;
|
|
1174
|
-
});
|
|
1175
|
-
/**
|
|
1176
|
-
* Shorthand for "either {@link RuleGroupArray} or {@link RuleGroupICArray}".
|
|
1177
|
-
*/
|
|
1178
|
-
type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
|
|
1179
|
-
/**
|
|
1180
|
-
* Converts a narrowed rule group type to its most generic form.
|
|
1181
|
-
*/
|
|
1182
|
-
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1183
|
-
//#endregion
|
|
1184
|
-
//#region ../core/src/types/validation.d.ts
|
|
1185
|
-
/**
|
|
1186
|
-
* Object with a `valid` boolean value and optional `reasons`.
|
|
1187
|
-
*/
|
|
1188
|
-
interface ValidationResult {
|
|
1189
|
-
valid: boolean;
|
|
1190
|
-
reasons?: any[];
|
|
1191
|
-
}
|
|
1192
|
-
/**
|
|
1193
|
-
* Map of rule/group `id` to its respective {@link ValidationResult}.
|
|
1194
|
-
*/
|
|
1195
|
-
type ValidationMap = Record<string, boolean | ValidationResult>;
|
|
1196
|
-
/**
|
|
1197
|
-
* Function that validates a query.
|
|
1198
|
-
*/
|
|
1199
|
-
type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
|
|
1200
|
-
/**
|
|
1201
|
-
* Function that validates a rule.
|
|
1202
|
-
*/
|
|
1203
|
-
type RuleValidator = (rule: RuleType) => boolean | ValidationResult;
|
|
1204
|
-
//#endregion
|
|
1205
|
-
//#region ../core/src/types/basic.d.ts
|
|
1206
|
-
/**
|
|
1207
|
-
* @see https://react-querybuilder.js.org/docs/tips/path
|
|
1208
|
-
*/
|
|
1209
|
-
type Path = number[];
|
|
1210
|
-
/**
|
|
1211
|
-
* String of classnames, array of classname strings, or object where the
|
|
1212
|
-
* keys are classnames and those with truthy values will be included.
|
|
1213
|
-
* Suitable for passing to the `clsx` package.
|
|
1214
|
-
*/
|
|
1215
|
-
type Classname = string | string[] | Record<string, any>;
|
|
1216
|
-
/**
|
|
1217
|
-
* A source for the `value` property of a rule.
|
|
1218
|
-
*/
|
|
1219
|
-
type ValueSource = "value" | "field";
|
|
1220
|
-
/**
|
|
1221
|
-
* Type of {@link react-querybuilder!ValueEditor ValueEditor} that will be displayed.
|
|
1222
|
-
*/
|
|
1223
|
-
type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
|
|
1224
|
-
/**
|
|
1225
|
-
* A valid array of potential value sources.
|
|
1226
|
-
*
|
|
1227
|
-
* @see {@link ValueSource}
|
|
1228
|
-
*/
|
|
1229
|
-
type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
|
|
1230
|
-
type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
|
|
1231
|
-
type ValueSourceFullOptions = ToOptionArrays<ValueSources>;
|
|
1232
|
-
type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: {
|
|
1233
|
-
name: Sources[K];
|
|
1234
|
-
value: Sources[K];
|
|
1235
|
-
label: string;
|
|
1236
|
-
} } : never;
|
|
1237
|
-
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
|
|
1238
|
-
type WithOptionalClassName<T$1> = T$1 & {
|
|
1239
|
-
className?: Classname;
|
|
1240
|
-
};
|
|
1241
|
-
/**
|
|
1242
|
-
* HTML5 input types
|
|
1243
|
-
*/
|
|
1244
|
-
type InputType = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week" | "bigint" | (string & {});
|
|
1245
|
-
/**
|
|
1246
|
-
* Quantification mode describing how many elements of the value array must pass
|
|
1247
|
-
* the filter for the rule itself to pass.
|
|
1248
|
-
*
|
|
1249
|
-
* For "atLeast", "atMost", and "exactly", the threshold value will be converted to
|
|
1250
|
-
* a percentage if the number is less than 1. Non-numeric values and numbers less
|
|
1251
|
-
* than 0 will be ignored.
|
|
1252
|
-
*/
|
|
1253
|
-
interface MatchConfig {
|
|
1254
|
-
mode: MatchMode;
|
|
1255
|
-
threshold?: number | null | undefined;
|
|
1256
|
-
}
|
|
1257
|
-
type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
|
|
1258
|
-
type MatchModeOptions = StringUnionToFullOptionArray<MatchMode>;
|
|
1259
|
-
type ActionElementEventHandler = (event?: any, context?: any) => void;
|
|
1260
|
-
type ValueChangeEventHandler = (value?: any, context?: any) => void;
|
|
1261
|
-
/**
|
|
1262
|
-
* Base for all Field types/interfaces.
|
|
1263
|
-
*/
|
|
1264
|
-
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>> {
|
|
1265
|
-
id?: string;
|
|
1266
|
-
operators?: FlexibleOptionList<OperatorObj> | OperatorName$1[] | FlexibleOption<OperatorName$1>[] | (OperatorName$1 | FlexibleOption<OperatorName$1>)[];
|
|
1267
|
-
valueEditorType?: ValueEditorType | ((operator: OperatorName$1) => ValueEditorType);
|
|
1268
|
-
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName$1) => ValueSources | ValueSourceFlexibleOptions);
|
|
1269
|
-
inputType?: InputType | null;
|
|
1270
|
-
values?: FlexibleOptionList<ValueObj>;
|
|
1271
|
-
matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
|
|
1272
|
-
/** Properties of items in the value. */
|
|
1273
|
-
subproperties?: FlexibleOptionList<FullField>;
|
|
1274
|
-
defaultOperator?: OperatorName$1;
|
|
1275
|
-
defaultValue?: any;
|
|
1276
|
-
placeholder?: string;
|
|
1277
|
-
validator?: RuleValidator;
|
|
1278
|
-
comparator?: string | ((f: FullField, operator: string) => boolean);
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* Full field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1282
|
-
* This type requires both `name` and `value`, but the `fields` prop itself
|
|
1283
|
-
* can use a {@link FlexibleOption} where only one of `name` or `value` is
|
|
1284
|
-
* required (along with `label`), or {@link Field} where only `name` and
|
|
1285
|
-
* `label` are required.
|
|
1286
|
-
*
|
|
1287
|
-
* The `name`/`value`, `operators`, and `values` properties of this interface
|
|
1288
|
-
* can be narrowed with generics.
|
|
1289
|
-
*
|
|
1290
|
-
* @group Option Lists
|
|
1291
|
-
*/
|
|
1292
|
-
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>>;
|
|
1293
|
-
/**
|
|
1294
|
-
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
1295
|
-
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
1296
|
-
*/
|
|
1297
|
-
type Arity = number | "unary" | "binary" | "ternary";
|
|
1298
|
-
/**
|
|
1299
|
-
* Full operator definition used in the `operators`/`getOperators` props of
|
|
1300
|
-
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1301
|
-
* `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
|
|
1302
|
-
* where only one of `name` or `value` is required, or {@link FullOperator} where
|
|
1303
|
-
* only `name` is required.
|
|
1304
|
-
*
|
|
1305
|
-
* The `name`/`value` properties of this interface can be narrowed with generics.
|
|
1306
|
-
*
|
|
1307
|
-
* @group Option Lists
|
|
1308
|
-
*/
|
|
1309
|
-
interface FullOperator<N extends string = string> extends WithOptionalClassName<FullOption<N>> {
|
|
1310
|
-
arity?: Arity;
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Full combinator definition used in the `combinators` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1314
|
-
* This type requires both `name` and `value`, but the `combinators` prop itself
|
|
1315
|
-
* can use a {@link FlexibleOption} where only one of `name` or `value` is required,
|
|
1316
|
-
* or {@link Combinator} where only `name` is required.
|
|
1317
|
-
*
|
|
1318
|
-
* The `name`/`value` properties of this interface can be narrowed with generics.
|
|
1319
|
-
*
|
|
1320
|
-
* @group Option Lists
|
|
1321
|
-
*/
|
|
1322
|
-
type FullCombinator<N extends string = string> = WithOptionalClassName<FullOption<N>>;
|
|
1323
|
-
type ParseNumberMethodName = "enhanced" | "native" | "strict";
|
|
1324
|
-
/**
|
|
1325
|
-
* Parsing algorithms used by {@link parseNumber}.
|
|
1326
|
-
*/
|
|
1327
|
-
|
|
1328
|
-
type ParseNumbersModerationLevel = "-limited" | "";
|
|
1329
|
-
/**
|
|
1330
|
-
* Options for the `parseNumbers` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1331
|
-
*/
|
|
1332
|
-
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
1333
|
-
/**
|
|
1334
|
-
* Signature of `accessibleDescriptionGenerator` prop, used by {@link react-querybuilder!QueryBuilder QueryBuilder} to generate
|
|
1335
|
-
* accessible descriptions for each {@link react-querybuilder!RuleGroup RuleGroup}.
|
|
1336
|
-
*/
|
|
1337
|
-
type AccessibleDescriptionGenerator = (props: {
|
|
1338
|
-
path: Path;
|
|
1339
|
-
qbId: string;
|
|
1340
|
-
}) => string;
|
|
1341
|
-
//#endregion
|
|
1342
|
-
//#region ../core/src/types/dnd.d.ts
|
|
1343
|
-
type DropEffect = "move" | "copy";
|
|
1344
|
-
//#endregion
|
|
1345
|
-
//#region ../core/src/types/queryBuilder.d.ts
|
|
1346
|
-
/**
|
|
1347
|
-
* Base interface for all rule subcomponents.
|
|
1348
|
-
*
|
|
1349
|
-
* @group Props
|
|
1350
|
-
*/
|
|
1351
|
-
interface CommonRuleSubComponentProps {
|
|
1352
|
-
rule: RuleType;
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Classnames applied to each component.
|
|
1356
|
-
*
|
|
1357
|
-
* @group Props
|
|
1358
|
-
*/
|
|
1359
|
-
interface Classnames {
|
|
1360
|
-
/**
|
|
1361
|
-
* Classnames applied to the root `<div>` element.
|
|
1362
|
-
*/
|
|
1363
|
-
queryBuilder: Classname;
|
|
1364
|
-
/**
|
|
1365
|
-
* Classnames applied to the `<div>` containing the RuleGroup.
|
|
1366
|
-
*/
|
|
1367
|
-
ruleGroup: Classname;
|
|
1368
|
-
/**
|
|
1369
|
-
* Classnames applied to the `<div>` containing the RuleGroup header controls.
|
|
1370
|
-
*/
|
|
1371
|
-
header: Classname;
|
|
1372
|
-
/**
|
|
1373
|
-
* Classnames applied to the `<div>` containing the RuleGroup child rules/groups.
|
|
1374
|
-
*/
|
|
1375
|
-
body: Classname;
|
|
1376
|
-
/**
|
|
1377
|
-
* Classnames applied to the `<select>` control for combinators.
|
|
1378
|
-
*/
|
|
1379
|
-
combinators: Classname;
|
|
1380
|
-
/**
|
|
1381
|
-
* Classnames applied to the `<button>` to add a Rule.
|
|
1382
|
-
*/
|
|
1383
|
-
addRule: Classname;
|
|
1384
|
-
/**
|
|
1385
|
-
* Classnames applied to the `<button>` to add a RuleGroup.
|
|
1386
|
-
*/
|
|
1387
|
-
addGroup: Classname;
|
|
1388
|
-
/**
|
|
1389
|
-
* Classnames applied to the `<button>` to clone a Rule.
|
|
1390
|
-
*/
|
|
1391
|
-
cloneRule: Classname;
|
|
1392
|
-
/**
|
|
1393
|
-
* Classnames applied to the `<button>` to clone a RuleGroup.
|
|
1394
|
-
*/
|
|
1395
|
-
cloneGroup: Classname;
|
|
1396
|
-
/**
|
|
1397
|
-
* Classnames applied to the `<button>` to remove a RuleGroup.
|
|
1398
|
-
*/
|
|
1399
|
-
removeGroup: Classname;
|
|
1400
|
-
/**
|
|
1401
|
-
* Classnames applied to the `<div>` containing the Rule.
|
|
1402
|
-
*/
|
|
1403
|
-
rule: Classname;
|
|
1404
|
-
/**
|
|
1405
|
-
* Classnames applied to the `<select>` control for fields.
|
|
1406
|
-
*/
|
|
1407
|
-
fields: Classname;
|
|
1408
|
-
/**
|
|
1409
|
-
* Classnames applied to the `<select>` control for match modes.
|
|
1410
|
-
*/
|
|
1411
|
-
matchMode: Classname;
|
|
1412
|
-
/**
|
|
1413
|
-
* Classnames applied to the `<input>` for match thresholds.
|
|
1414
|
-
*/
|
|
1415
|
-
matchThreshold: Classname;
|
|
1416
|
-
/**
|
|
1417
|
-
* Classnames applied to the `<select>` control for operators.
|
|
1418
|
-
*/
|
|
1419
|
-
operators: Classname;
|
|
1420
|
-
/**
|
|
1421
|
-
* Classnames applied to the `<input>` for the rule value.
|
|
1422
|
-
*/
|
|
1423
|
-
value: Classname;
|
|
1424
|
-
/**
|
|
1425
|
-
* Classnames applied to the `<button>` to remove a Rule.
|
|
1426
|
-
*/
|
|
1427
|
-
removeRule: Classname;
|
|
1428
|
-
/**
|
|
1429
|
-
* Classnames applied to the `<label>` on the "not" toggle.
|
|
1430
|
-
*/
|
|
1431
|
-
notToggle: Classname;
|
|
1432
|
-
/**
|
|
1433
|
-
* Classnames applied to the `<span>` handle for dragging rules/groups.
|
|
1434
|
-
*/
|
|
1435
|
-
shiftActions: Classname;
|
|
1436
|
-
/**
|
|
1437
|
-
* Classnames applied to the `<span>` handle for dragging rules/groups.
|
|
1438
|
-
*/
|
|
1439
|
-
dragHandle: Classname;
|
|
1440
|
-
/**
|
|
1441
|
-
* Classnames applied to the `<button>` to lock/disable a Rule.
|
|
1442
|
-
*/
|
|
1443
|
-
lockRule: Classname;
|
|
1444
|
-
/**
|
|
1445
|
-
* Classnames applied to the `<button>` to lock/disable a RuleGroup.
|
|
1446
|
-
*/
|
|
1447
|
-
lockGroup: Classname;
|
|
1448
|
-
/**
|
|
1449
|
-
* Classnames applied to the `<button>` to mute a Rule.
|
|
1450
|
-
*/
|
|
1451
|
-
muteRule: Classname;
|
|
1452
|
-
/**
|
|
1453
|
-
* Classnames applied to the `<button>` to mute a RuleGroup.
|
|
1454
|
-
*/
|
|
1455
|
-
muteGroup: Classname;
|
|
1456
|
-
/**
|
|
1457
|
-
* Classnames applied to the `<select>` control for value sources.
|
|
1458
|
-
*/
|
|
1459
|
-
valueSource: Classname;
|
|
1460
|
-
/**
|
|
1461
|
-
* Classnames applied to all action elements.
|
|
1462
|
-
*/
|
|
1463
|
-
actionElement: Classname;
|
|
1464
|
-
/**
|
|
1465
|
-
* Classnames applied to all select elements.
|
|
1466
|
-
*/
|
|
1467
|
-
valueSelector: Classname;
|
|
1468
|
-
/**
|
|
1469
|
-
* Classname(s) applied to inline combinator elements.
|
|
1470
|
-
*/
|
|
1471
|
-
betweenRules: Classname;
|
|
1472
|
-
/**
|
|
1473
|
-
* Classname(s) applied to valid rules and groups.
|
|
1474
|
-
*/
|
|
1475
|
-
valid: Classname;
|
|
1476
|
-
/**
|
|
1477
|
-
* Classname(s) applied to invalid rules and groups.
|
|
1478
|
-
*/
|
|
1479
|
-
invalid: Classname;
|
|
1480
|
-
/**
|
|
1481
|
-
* Classname(s) applied to rules and groups while being dragged.
|
|
1482
|
-
*/
|
|
1483
|
-
dndDragging: Classname;
|
|
1484
|
-
/**
|
|
1485
|
-
* Classname(s) applied to rules and groups hovered over by a dragged element.
|
|
1486
|
-
*/
|
|
1487
|
-
dndOver: Classname;
|
|
1488
|
-
/**
|
|
1489
|
-
* Classname(s) applied to rules and groups hovered over by a dragged element
|
|
1490
|
-
* when the drop effect is "copy" (modifier key is pressed).
|
|
1491
|
-
*/
|
|
1492
|
-
dndCopy: Classname;
|
|
1493
|
-
/**
|
|
1494
|
-
* Classname(s) applied to rules and groups hovered over by a dragged element
|
|
1495
|
-
* when the Ctrl key is pressed, indicating the items will form a new group.
|
|
1496
|
-
*/
|
|
1497
|
-
dndGroup: Classname;
|
|
1498
|
-
/**
|
|
1499
|
-
* Classname(s) applied to rules and groups that cannot accept a drop from
|
|
1500
|
-
* the dragged element hovering over it.
|
|
1501
|
-
*/
|
|
1502
|
-
dndDropNotAllowed: Classname;
|
|
1503
|
-
/**
|
|
1504
|
-
* Classname(s) applied to disabled elements.
|
|
1505
|
-
*/
|
|
1506
|
-
disabled: Classname;
|
|
1507
|
-
/**
|
|
1508
|
-
* Classname(s) applied to muted elements.
|
|
1509
|
-
*/
|
|
1510
|
-
muted: Classname;
|
|
1511
|
-
/**
|
|
1512
|
-
* Classname(s) applied to each element in a series of value editors.
|
|
1513
|
-
*/
|
|
1514
|
-
valueListItem: Classname;
|
|
1515
|
-
/**
|
|
1516
|
-
* Not applied, but see CSS styles.
|
|
1517
|
-
*/
|
|
1518
|
-
branches: Classname;
|
|
1519
|
-
/**
|
|
1520
|
-
* Classname(s) applied to rules that render a subquery.
|
|
1521
|
-
*/
|
|
1522
|
-
hasSubQuery: Classname;
|
|
1523
|
-
/**
|
|
1524
|
-
* Classname(s) applied to async components in their "loading" state.
|
|
1525
|
-
*/
|
|
1526
|
-
loading: Classname;
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* Placeholder strings for option lists.
|
|
1530
|
-
*
|
|
1531
|
-
* @group Props
|
|
1532
|
-
*/
|
|
1533
|
-
interface Placeholder {
|
|
1534
|
-
/**
|
|
1535
|
-
* Value for the placeholder field option if autoSelectField is false,
|
|
1536
|
-
* or the placeholder operator option if autoSelectOperator is false.
|
|
1537
|
-
*/
|
|
1538
|
-
placeholderName?: string;
|
|
1539
|
-
/**
|
|
1540
|
-
* Label for the placeholder field option if autoSelectField is false,
|
|
1541
|
-
* or the placeholder operator option if autoSelectOperator is false.
|
|
1542
|
-
*/
|
|
1543
|
-
placeholderLabel?: string;
|
|
1544
|
-
/**
|
|
1545
|
-
* Label for the placeholder field optgroup if autoSelectField is false,
|
|
1546
|
-
* or the placeholder operator optgroup if autoSelectOperator is false.
|
|
1547
|
-
*/
|
|
1548
|
-
placeholderGroupLabel?: string;
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* A translation for a component with `title` only.
|
|
1552
|
-
*
|
|
1553
|
-
* @group Props
|
|
1554
|
-
*/
|
|
1555
|
-
interface BaseTranslation {
|
|
1556
|
-
title?: string;
|
|
1557
|
-
}
|
|
1558
|
-
/**
|
|
1559
|
-
* A translation for a component with `title` and `label`.
|
|
1560
|
-
*
|
|
1561
|
-
* @group Props
|
|
1562
|
-
*/
|
|
1563
|
-
interface BaseTranslationWithLabel<LabelType = string> extends BaseTranslation {
|
|
1564
|
-
label?: LabelType;
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* A translation for a component with `title` and a placeholder.
|
|
1568
|
-
*
|
|
1569
|
-
* @group Props
|
|
1570
|
-
*/
|
|
1571
|
-
interface BaseTranslationWithPlaceholders extends BaseTranslation, Placeholder {}
|
|
1572
|
-
/**
|
|
1573
|
-
* The shape of the `translations` prop.
|
|
1574
|
-
*
|
|
1575
|
-
* @group Props
|
|
1576
|
-
*/
|
|
1577
|
-
interface BaseTranslations<LabelType = string> {
|
|
1578
|
-
fields: BaseTranslationWithPlaceholders;
|
|
1579
|
-
operators: BaseTranslationWithPlaceholders;
|
|
1580
|
-
values: BaseTranslationWithPlaceholders;
|
|
1581
|
-
matchMode: BaseTranslation;
|
|
1582
|
-
matchThreshold: BaseTranslation;
|
|
1583
|
-
value: BaseTranslation;
|
|
1584
|
-
removeRule: BaseTranslationWithLabel<LabelType>;
|
|
1585
|
-
removeGroup: BaseTranslationWithLabel<LabelType>;
|
|
1586
|
-
addRule: BaseTranslationWithLabel<LabelType>;
|
|
1587
|
-
addGroup: BaseTranslationWithLabel<LabelType>;
|
|
1588
|
-
combinators: BaseTranslation;
|
|
1589
|
-
notToggle: BaseTranslationWithLabel<LabelType>;
|
|
1590
|
-
cloneRule: BaseTranslationWithLabel<LabelType>;
|
|
1591
|
-
cloneRuleGroup: BaseTranslationWithLabel<LabelType>;
|
|
1592
|
-
shiftActionUp: BaseTranslationWithLabel<LabelType>;
|
|
1593
|
-
shiftActionDown: BaseTranslationWithLabel<LabelType>;
|
|
1594
|
-
dragHandle: BaseTranslationWithLabel<LabelType>;
|
|
1595
|
-
lockRule: BaseTranslationWithLabel<LabelType>;
|
|
1596
|
-
lockGroup: BaseTranslationWithLabel<LabelType>;
|
|
1597
|
-
lockRuleDisabled: BaseTranslationWithLabel<LabelType>;
|
|
1598
|
-
lockGroupDisabled: BaseTranslationWithLabel<LabelType>;
|
|
1599
|
-
muteRule: BaseTranslationWithLabel<LabelType>;
|
|
1600
|
-
muteGroup: BaseTranslationWithLabel<LabelType>;
|
|
1601
|
-
unmuteRule: BaseTranslationWithLabel<LabelType>;
|
|
1602
|
-
unmuteGroup: BaseTranslationWithLabel<LabelType>;
|
|
1603
|
-
valueSourceSelector: BaseTranslation;
|
|
1604
|
-
}
|
|
1605
|
-
/**
|
|
1606
|
-
* Functions included in the `actions` prop passed to every subcomponent.
|
|
1607
|
-
*
|
|
1608
|
-
* @group Props
|
|
1609
|
-
*/
|
|
1610
|
-
interface QueryActions {
|
|
1611
|
-
onGroupAdd(group: RuleGroupTypeAny, parentPath: Path, context?: any): void;
|
|
1612
|
-
onGroupRemove(path: Path): void;
|
|
1613
|
-
onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, "id" | "path">, value: any, path: Path, context?: any): void;
|
|
1614
|
-
onRuleAdd(rule: RuleType, parentPath: Path, context?: any): void;
|
|
1615
|
-
onRuleRemove(path: Path): void;
|
|
1616
|
-
moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
|
|
1617
|
-
groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
|
|
1618
|
-
}
|
|
1619
|
-
interface QueryBuilderFlags {
|
|
1620
|
-
/**
|
|
1621
|
-
* Set to `false` to avoid calling the `onQueryChange` callback
|
|
1622
|
-
* when the component mounts.
|
|
1623
|
-
*
|
|
1624
|
-
* @default true
|
|
1625
|
-
*/
|
|
1626
|
-
enableMountQueryChange?: boolean;
|
|
1627
|
-
/**
|
|
1628
|
-
* Enables drag-and-drop features.
|
|
1629
|
-
*
|
|
1630
|
-
* @default false
|
|
1631
|
-
*/
|
|
1632
|
-
enableDragAndDrop?: boolean;
|
|
1633
|
-
/**
|
|
1634
|
-
* Enables debug logging for query builders (and React DnD when applicable).
|
|
1635
|
-
*
|
|
1636
|
-
* @default false
|
|
1637
|
-
*/
|
|
1638
|
-
debugMode?: boolean;
|
|
1639
|
-
/**
|
|
1640
|
-
* Show group combinator selectors in the body of the group, between each child rule/group,
|
|
1641
|
-
* instead of in the group header.
|
|
1642
|
-
*
|
|
1643
|
-
* @default false
|
|
1644
|
-
*/
|
|
1645
|
-
showCombinatorsBetweenRules?: boolean;
|
|
1646
|
-
/**
|
|
1647
|
-
* Show the "not" (aka inversion) toggle for rule groups.
|
|
1648
|
-
*
|
|
1649
|
-
* @default false
|
|
1650
|
-
*/
|
|
1651
|
-
showNotToggle?: boolean;
|
|
1652
|
-
/**
|
|
1653
|
-
* Show the "Shift up"/"Shift down" actions.
|
|
1654
|
-
*
|
|
1655
|
-
* @default false
|
|
1656
|
-
*/
|
|
1657
|
-
showShiftActions?: boolean;
|
|
1658
|
-
/**
|
|
1659
|
-
* Show the "Clone rule" and "Clone group" buttons.
|
|
1660
|
-
*
|
|
1661
|
-
* @default false
|
|
1662
|
-
*/
|
|
1663
|
-
showCloneButtons?: boolean;
|
|
1664
|
-
/**
|
|
1665
|
-
* Show the "Lock rule" and "Lock group" buttons.
|
|
1666
|
-
*
|
|
1667
|
-
* @default false
|
|
1668
|
-
*/
|
|
1669
|
-
showLockButtons?: boolean;
|
|
1670
|
-
/**
|
|
1671
|
-
* Show the "Mute rule" and "Mute group" buttons.
|
|
1672
|
-
*
|
|
1673
|
-
* @default false
|
|
1674
|
-
*/
|
|
1675
|
-
showMuteButtons?: boolean;
|
|
1676
|
-
/**
|
|
1677
|
-
* Reset the `operator` and `value` when the `field` changes.
|
|
1678
|
-
*
|
|
1679
|
-
* @default true
|
|
1680
|
-
*/
|
|
1681
|
-
resetOnFieldChange?: boolean;
|
|
1682
|
-
/**
|
|
1683
|
-
* Reset the `value` when the `operator` changes.
|
|
1684
|
-
*
|
|
1685
|
-
* @default false
|
|
1686
|
-
*/
|
|
1687
|
-
resetOnOperatorChange?: boolean;
|
|
1688
|
-
/**
|
|
1689
|
-
* Select the first field in the array automatically.
|
|
1690
|
-
*
|
|
1691
|
-
* @default true
|
|
1692
|
-
*/
|
|
1693
|
-
autoSelectField?: boolean;
|
|
1694
|
-
/**
|
|
1695
|
-
* Select the first operator in the array automatically.
|
|
1696
|
-
*
|
|
1697
|
-
* @default true
|
|
1698
|
-
*/
|
|
1699
|
-
autoSelectOperator?: boolean;
|
|
1700
|
-
/**
|
|
1701
|
-
* Select the first value in the array automatically. Only applicable when the value editor renders a select list.
|
|
1702
|
-
*
|
|
1703
|
-
* @default false
|
|
1704
|
-
*/
|
|
1705
|
-
autoSelectValue?: boolean;
|
|
1706
|
-
/**
|
|
1707
|
-
* Adds a new default rule automatically to each new group.
|
|
1708
|
-
*
|
|
1709
|
-
* @default false
|
|
1710
|
-
*/
|
|
1711
|
-
addRuleToNewGroups?: boolean;
|
|
1712
|
-
/**
|
|
1713
|
-
* Store list-type values as native arrays instead of comma-separated strings.
|
|
1714
|
-
*
|
|
1715
|
-
* @default false
|
|
1716
|
-
*/
|
|
1717
|
-
listsAsArrays?: boolean;
|
|
1718
|
-
/**
|
|
1719
|
-
* Prevent _any_ assignment of standard classes to elements. This includes conditional
|
|
1720
|
-
* and event-based classes for validation, drag-and-drop, etc.
|
|
1721
|
-
*
|
|
1722
|
-
* @default false
|
|
1723
|
-
*/
|
|
1724
|
-
suppressStandardClassnames?: boolean;
|
|
1725
|
-
}
|
|
1726
|
-
//#endregion
|
|
1727
|
-
//#region ../core/src/utils/queryTools.d.ts
|
|
1728
|
-
/**
|
|
1729
|
-
* Options for {@link move}.
|
|
1730
|
-
*
|
|
1731
|
-
* @group Query Tools
|
|
1732
|
-
*/
|
|
1733
|
-
interface MoveOptions {
|
|
1734
|
-
/**
|
|
1735
|
-
* When `true`, the source rule/group will not be removed from its original path.
|
|
1736
|
-
*/
|
|
1737
|
-
clone?: boolean;
|
|
1738
|
-
/**
|
|
1739
|
-
* If the query extends `RuleGroupTypeIC` (i.e. the query is using independent
|
|
1740
|
-
* combinators), then the first combinator in this list will be inserted before
|
|
1741
|
-
* the rule/group if necessary.
|
|
1742
|
-
*/
|
|
1743
|
-
combinators?: OptionList;
|
|
1744
|
-
/**
|
|
1745
|
-
* ID generator.
|
|
1746
|
-
*/
|
|
1747
|
-
idGenerator?: () => string;
|
|
1748
|
-
}
|
|
1749
|
-
/**
|
|
1750
|
-
* Options for {@link group}.
|
|
1751
|
-
*
|
|
1752
|
-
* @group Query Tools
|
|
1753
|
-
*/
|
|
1754
|
-
interface GroupOptions {
|
|
1755
|
-
/**
|
|
1756
|
-
* When `true`, the source rule/group will not be removed from its original path.
|
|
1757
|
-
*/
|
|
1758
|
-
clone?: boolean;
|
|
1759
|
-
/**
|
|
1760
|
-
* If the query extends `RuleGroupTypeIC` (i.e. the query is using independent
|
|
1761
|
-
* combinators), then the first combinator in this list will be inserted between
|
|
1762
|
-
* the two rules/groups.
|
|
1763
|
-
*/
|
|
1764
|
-
combinators?: OptionList;
|
|
1765
|
-
/**
|
|
1766
|
-
* ID generator.
|
|
1767
|
-
*/
|
|
1768
|
-
idGenerator?: () => string;
|
|
1769
|
-
}
|
|
1770
|
-
//#endregion
|
|
1771
|
-
//#region ../react-querybuilder/src/components/RuleGroup.d.ts
|
|
1772
|
-
interface UseRuleGroup extends RuleGroupProps {
|
|
1773
|
-
addGroup: ActionElementEventHandler;
|
|
1774
|
-
addRule: ActionElementEventHandler;
|
|
1775
|
-
accessibleDescription: string;
|
|
1776
|
-
muted?: boolean;
|
|
1777
|
-
classNames: Pick<{ [k in keyof Classnames]: string }, "header" | "shiftActions" | "dragHandle" | "combinators" | "notToggle" | "addRule" | "addGroup" | "cloneGroup" | "lockGroup" | "muteGroup" | "removeGroup" | "body">;
|
|
1778
|
-
cloneGroup: ActionElementEventHandler;
|
|
1779
|
-
onCombinatorChange: ValueChangeEventHandler;
|
|
1780
|
-
onGroupAdd: (group: RuleGroupTypeAny, parentPath: Path, context?: any) => void;
|
|
1781
|
-
onIndependentCombinatorChange: (value: any, index: number, context?: any) => void;
|
|
1782
|
-
onNotToggleChange: (checked: boolean, context?: any) => void;
|
|
1783
|
-
outerClassName: string;
|
|
1784
|
-
pathsMemo: {
|
|
1785
|
-
path: Path;
|
|
1786
|
-
disabled: boolean;
|
|
1787
|
-
}[];
|
|
1788
|
-
removeGroup: ActionElementEventHandler;
|
|
1789
|
-
ruleGroup: RuleGroupType | RuleGroupTypeIC;
|
|
1790
|
-
shiftGroupDown: (event?: MouseEvent, context?: any) => void;
|
|
1791
|
-
shiftGroupUp: (event?: MouseEvent, context?: any) => void;
|
|
1792
|
-
toggleLockGroup: ActionElementEventHandler;
|
|
1793
|
-
toggleMuteGroup: ActionElementEventHandler;
|
|
1794
|
-
validationClassName: string;
|
|
1795
|
-
validationResult: boolean | ValidationResult;
|
|
1796
|
-
}
|
|
1797
|
-
//#endregion
|
|
1798
|
-
//#region ../react-querybuilder/src/types/props.d.ts
|
|
1799
|
-
/**
|
|
1800
|
-
* Base interface for all subcomponents.
|
|
1801
|
-
*
|
|
1802
|
-
* @group Props
|
|
1803
|
-
*/
|
|
1804
|
-
interface CommonSubComponentProps<F extends FullOption = FullField, O extends string = string> {
|
|
1805
|
-
/**
|
|
1806
|
-
* CSS classNames to be applied.
|
|
1807
|
-
*
|
|
1808
|
-
* This is `string` and not {@link Classname} because the {@link Rule}
|
|
1809
|
-
* and {@link RuleGroup} components run `clsx()` to produce the `className`
|
|
1810
|
-
* that gets passed to each subcomponent.
|
|
1811
|
-
*/
|
|
1812
|
-
className?: string;
|
|
1813
|
-
/**
|
|
1814
|
-
* Path to this subcomponent's rule/group within the query.
|
|
1815
|
-
*/
|
|
1816
|
-
path: Path;
|
|
1817
|
-
/**
|
|
1818
|
-
* The level of the current group. Always equal to `path.length`.
|
|
1819
|
-
*/
|
|
1820
|
-
level: number;
|
|
1821
|
-
/**
|
|
1822
|
-
* The title/tooltip for this control.
|
|
1823
|
-
*/
|
|
1824
|
-
title?: string;
|
|
1825
|
-
/**
|
|
1826
|
-
* Disables the control.
|
|
1827
|
-
*/
|
|
1828
|
-
disabled?: boolean;
|
|
1829
|
-
/**
|
|
1830
|
-
* Container for custom props that are passed to all components.
|
|
1831
|
-
*/
|
|
1832
|
-
context?: any;
|
|
1833
|
-
/**
|
|
1834
|
-
* Validation result of the parent rule/group.
|
|
1835
|
-
*/
|
|
1836
|
-
validation?: boolean | ValidationResult;
|
|
1837
|
-
/**
|
|
1838
|
-
* Test ID for this component.
|
|
1839
|
-
*/
|
|
1840
|
-
testID?: string;
|
|
1841
|
-
/**
|
|
1842
|
-
* All subcomponents receive the configuration schema as a prop.
|
|
1843
|
-
*/
|
|
1844
|
-
schema: Schema<F, O>;
|
|
1845
|
-
}
|
|
1846
|
-
/**
|
|
1847
|
-
* Base interface for selectors and editors.
|
|
1848
|
-
*
|
|
1849
|
-
* @group Props
|
|
1850
|
-
*/
|
|
1851
|
-
interface SelectorOrEditorProps<F extends FullOption = FullField, O extends string = string> extends CommonSubComponentProps<F, O> {
|
|
1852
|
-
value?: string;
|
|
1853
|
-
handleOnChange(value: any): void;
|
|
1854
|
-
}
|
|
1855
|
-
/**
|
|
1856
|
-
* Base interface for selector components.
|
|
1857
|
-
*/
|
|
1858
|
-
interface BaseSelectorProps<OptType extends Option> extends SelectorOrEditorProps<ToFullOption<OptType>> {
|
|
1859
|
-
options: FullOptionList<OptType>;
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* Props for all `value` selector components.
|
|
1863
|
-
*
|
|
1864
|
-
* @group Props
|
|
1865
|
-
*/
|
|
1866
|
-
interface ValueSelectorProps<OptType extends Option = FullOption> extends BaseSelectorProps<OptType> {
|
|
1867
|
-
multiple?: boolean;
|
|
1868
|
-
listsAsArrays?: boolean;
|
|
1869
|
-
}
|
|
1870
|
-
/**
|
|
1871
|
-
* Props for `combinatorSelector` components.
|
|
1872
|
-
*
|
|
1873
|
-
* @group Props
|
|
1874
|
-
*/
|
|
1875
|
-
interface CombinatorSelectorProps extends BaseSelectorProps<FullOption> {
|
|
1876
|
-
options: FullOptionList<FullCombinator>;
|
|
1877
|
-
rules: RuleOrGroupArray;
|
|
1878
|
-
ruleGroup: RuleGroupTypeAny;
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Props for `fieldSelector` components.
|
|
1882
|
-
*
|
|
1883
|
-
* @group Props
|
|
1884
|
-
*/
|
|
1885
|
-
interface FieldSelectorProps<F extends FullField = FullField> extends BaseSelectorProps<F>, CommonRuleSubComponentProps {
|
|
1886
|
-
operator?: F extends FullField<string, infer OperatorName> ? OperatorName : string;
|
|
1887
|
-
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Props for `matchModeEditor` components.
|
|
1890
|
-
*
|
|
1891
|
-
* @group Props
|
|
1892
|
-
*/
|
|
1893
|
-
interface MatchModeEditorProps extends BaseSelectorProps<FullOption>, CommonRuleSubComponentProps {
|
|
1894
|
-
match: MatchConfig;
|
|
1895
|
-
selectorComponent?: ComponentType<ValueSelectorProps>;
|
|
1896
|
-
numericEditorComponent?: ComponentType<ValueEditorProps>;
|
|
1897
|
-
classNames: {
|
|
1898
|
-
matchMode: string;
|
|
1899
|
-
matchThreshold: string;
|
|
1900
|
-
};
|
|
1901
|
-
options: FullOptionList<FullOption<MatchMode>>;
|
|
1902
|
-
field: string;
|
|
1903
|
-
fieldData: FullField;
|
|
1904
|
-
}
|
|
1905
|
-
/**
|
|
1906
|
-
* Props for `operatorSelector` components.
|
|
1907
|
-
*
|
|
1908
|
-
* @group Props
|
|
1909
|
-
*/
|
|
1910
|
-
interface OperatorSelectorProps extends BaseSelectorProps<FullOption>, CommonRuleSubComponentProps {
|
|
1911
|
-
options: FullOptionList<FullOperator>;
|
|
1912
|
-
field: string;
|
|
1913
|
-
fieldData: FullField;
|
|
1914
|
-
}
|
|
1915
|
-
/**
|
|
1916
|
-
* Props for `valueSourceSelector` components.
|
|
1917
|
-
*
|
|
1918
|
-
* @group Props
|
|
1919
|
-
*/
|
|
1920
|
-
interface ValueSourceSelectorProps extends BaseSelectorProps<FullOption>, CommonRuleSubComponentProps {
|
|
1921
|
-
options: FullOptionList<FullOption<ValueSource>>;
|
|
1922
|
-
field: string;
|
|
1923
|
-
fieldData: FullField;
|
|
1924
|
-
}
|
|
1925
|
-
/**
|
|
1926
|
-
* Utility type representing props for selector components
|
|
1927
|
-
* that could potentially be any of the standard selector types.
|
|
1928
|
-
*
|
|
1929
|
-
* @group Props
|
|
1930
|
-
*/
|
|
1931
|
-
type VersatileSelectorProps = ValueSelectorProps & Partial<FieldSelectorProps> & Partial<OperatorSelectorProps> & Partial<CombinatorSelectorProps>;
|
|
1932
|
-
/**
|
|
1933
|
-
* A translation for a component with `title` and `label`.
|
|
1934
|
-
*
|
|
1935
|
-
* @group Props
|
|
1936
|
-
*/
|
|
1937
|
-
interface TranslationWithLabel extends BaseTranslationWithLabel<ReactNode> {}
|
|
1938
|
-
/**
|
|
1939
|
-
* The shape of the `translations` prop.
|
|
1940
|
-
*
|
|
1941
|
-
* @group Props
|
|
1942
|
-
*/
|
|
1943
|
-
interface Translations extends BaseTranslations<ReactNode> {}
|
|
1944
|
-
/**
|
|
1945
|
-
* Props passed to every action component (rendered as `<button>` by default).
|
|
1946
|
-
*
|
|
1947
|
-
* @group Props
|
|
1948
|
-
*/
|
|
1949
|
-
interface ActionProps extends CommonSubComponentProps {
|
|
1950
|
-
/** Visible text. */
|
|
1951
|
-
label?: ReactNode;
|
|
1952
|
-
/**
|
|
1953
|
-
* Triggers the action, e.g. the addition of a new rule or group. The second parameter
|
|
1954
|
-
* will be forwarded to the `onAddRule` or `onAddGroup` callback if appropriate.
|
|
1955
|
-
*/
|
|
1956
|
-
handleOnClick(e?: MouseEvent, context?: any): void;
|
|
1957
|
-
/**
|
|
1958
|
-
* Translation which overrides the regular `label`/`title` props when
|
|
1959
|
-
* the element is disabled.
|
|
1960
|
-
*/
|
|
1961
|
-
disabledTranslation?: TranslationWithLabel;
|
|
1962
|
-
/**
|
|
1963
|
-
* The {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
|
|
1964
|
-
* associated with this element.
|
|
1965
|
-
*/
|
|
1966
|
-
ruleOrGroup: RuleGroupTypeAny | RuleType;
|
|
1967
|
-
/**
|
|
1968
|
-
* Rules in this group (if the action element is for a group).
|
|
1969
|
-
*/
|
|
1970
|
-
rules?: RuleOrGroupArray;
|
|
1971
|
-
}
|
|
1972
|
-
/**
|
|
1973
|
-
* Props for `notToggle` components.
|
|
1974
|
-
*
|
|
1975
|
-
* @group Props
|
|
1976
|
-
*/
|
|
1977
|
-
interface NotToggleProps extends CommonSubComponentProps {
|
|
1978
|
-
checked?: boolean;
|
|
1979
|
-
handleOnChange(checked: boolean): void;
|
|
1980
|
-
label?: ReactNode;
|
|
1981
|
-
ruleGroup: RuleGroupTypeAny;
|
|
1982
|
-
}
|
|
1983
|
-
/**
|
|
1984
|
-
* Props passed to `shiftActions` components.
|
|
1985
|
-
*
|
|
1986
|
-
* @group Props
|
|
1987
|
-
*/
|
|
1988
|
-
interface ShiftActionsProps extends CommonSubComponentProps {
|
|
1989
|
-
/**
|
|
1990
|
-
* Visible text for "shift up"/"shift down" elements.
|
|
1991
|
-
*/
|
|
1992
|
-
labels?: {
|
|
1993
|
-
shiftUp?: ReactNode;
|
|
1994
|
-
shiftDown?: ReactNode;
|
|
1995
|
-
};
|
|
1996
|
-
/**
|
|
1997
|
-
* Tooltips for "shift up"/"shift down" elements.
|
|
1998
|
-
*/
|
|
1999
|
-
titles?: {
|
|
2000
|
-
shiftUp?: string;
|
|
2001
|
-
shiftDown?: string;
|
|
2002
|
-
};
|
|
2003
|
-
/**
|
|
2004
|
-
* The {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
|
|
2005
|
-
* associated with this element.
|
|
2006
|
-
*/
|
|
2007
|
-
ruleOrGroup: RuleGroupTypeAny | RuleType;
|
|
2008
|
-
/**
|
|
2009
|
-
* Method to shift the rule/group up one place.
|
|
2010
|
-
*/
|
|
2011
|
-
shiftUp?: () => void;
|
|
2012
|
-
/**
|
|
2013
|
-
* Method to shift the rule/group down one place.
|
|
2014
|
-
*/
|
|
2015
|
-
shiftDown?: () => void;
|
|
2016
|
-
/**
|
|
2017
|
-
* Whether shifting the rule/group up is disallowed.
|
|
2018
|
-
*/
|
|
2019
|
-
shiftUpDisabled?: boolean;
|
|
2020
|
-
/**
|
|
2021
|
-
* Whether shifting the rule/group down is disallowed.
|
|
2022
|
-
*/
|
|
2023
|
-
shiftDownDisabled?: boolean;
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* Props for `dragHandle` components.
|
|
2027
|
-
*
|
|
2028
|
-
* @group Props
|
|
2029
|
-
*/
|
|
2030
|
-
interface DragHandleProps extends CommonSubComponentProps {
|
|
2031
|
-
label?: ReactNode;
|
|
2032
|
-
ruleOrGroup: RuleGroupTypeAny | RuleType;
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Props passed to `inlineCombinator` components.
|
|
2036
|
-
*
|
|
2037
|
-
* @group Props
|
|
2038
|
-
*/
|
|
2039
|
-
interface InlineCombinatorProps extends CombinatorSelectorProps {
|
|
2040
|
-
component: ComponentType<CombinatorSelectorProps>;
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* Props passed to `valueEditor` components.
|
|
2044
|
-
*
|
|
2045
|
-
* @group Props
|
|
2046
|
-
*/
|
|
2047
|
-
interface ValueEditorProps<F extends FullField = FullField, O extends string = string> extends SelectorOrEditorProps<F, O>, CommonRuleSubComponentProps {
|
|
2048
|
-
field: GetOptionIdentifierType<F>;
|
|
2049
|
-
operator: O;
|
|
2050
|
-
value?: any;
|
|
2051
|
-
valueSource: ValueSource;
|
|
2052
|
-
/** The entire {@link FullField} object. */
|
|
2053
|
-
fieldData: F;
|
|
2054
|
-
type?: ValueEditorType;
|
|
2055
|
-
inputType?: InputType | null;
|
|
2056
|
-
values?: any[];
|
|
2057
|
-
listsAsArrays?: boolean;
|
|
2058
|
-
parseNumbers?: ParseNumbersPropConfig;
|
|
2059
|
-
separator?: ReactNode;
|
|
2060
|
-
selectorComponent?: ComponentType<ValueSelectorProps>;
|
|
2061
|
-
/**
|
|
2062
|
-
* Only pass `true` if the {@link useValueEditor} hook has already run
|
|
2063
|
-
* in a parent/ancestor component. See usage in the compatibility packages.
|
|
2064
|
-
*/
|
|
2065
|
-
skipHook?: boolean;
|
|
2066
|
-
schema: Schema<F, O>;
|
|
2067
|
-
}
|
|
2068
|
-
/**
|
|
2069
|
-
* All subcomponents.
|
|
2070
|
-
*
|
|
2071
|
-
* @group Props
|
|
2072
|
-
*/
|
|
2073
|
-
type Controls<F extends FullField, O extends string> = Required<SetNonNullable<ControlElementsProp<F, O>, keyof ControlElementsProp<F, O>>>;
|
|
2074
|
-
/**
|
|
2075
|
-
* Subcomponents.
|
|
2076
|
-
*
|
|
2077
|
-
* @group Props
|
|
2078
|
-
*/
|
|
2079
|
-
type ControlElementsProp<F extends FullField, O extends string> = Partial<{
|
|
2080
|
-
/**
|
|
2081
|
-
* Default component for all button-type controls.
|
|
2082
|
-
*
|
|
2083
|
-
* @default ActionElement
|
|
2084
|
-
*/
|
|
2085
|
-
actionElement: ComponentType<ActionProps>;
|
|
2086
|
-
/**
|
|
2087
|
-
* Adds a sub-group to the current group.
|
|
2088
|
-
*
|
|
2089
|
-
* @default ActionElement
|
|
2090
|
-
*/
|
|
2091
|
-
addGroupAction: ComponentType<ActionProps> | null;
|
|
2092
|
-
/**
|
|
2093
|
-
* Adds a rule to the current group.
|
|
2094
|
-
*
|
|
2095
|
-
* @default ActionElement
|
|
2096
|
-
*/
|
|
2097
|
-
addRuleAction: ComponentType<ActionProps> | null;
|
|
2098
|
-
/**
|
|
2099
|
-
* Clones the current group.
|
|
2100
|
-
*
|
|
2101
|
-
* @default ActionElement
|
|
2102
|
-
*/
|
|
2103
|
-
cloneGroupAction: ComponentType<ActionProps> | null;
|
|
2104
|
-
/**
|
|
2105
|
-
* Clones the current rule.
|
|
2106
|
-
*
|
|
2107
|
-
* @default ActionElement
|
|
2108
|
-
*/
|
|
2109
|
-
cloneRuleAction: ComponentType<ActionProps> | null;
|
|
2110
|
-
/**
|
|
2111
|
-
* Selects the `combinator` property for the current group, or the current independent combinator value.
|
|
2112
|
-
*
|
|
2113
|
-
* @default ValueSelector
|
|
2114
|
-
*/
|
|
2115
|
-
combinatorSelector: ComponentType<CombinatorSelectorProps> | null;
|
|
2116
|
-
/**
|
|
2117
|
-
* Provides a draggable handle for reordering rules and groups.
|
|
2118
|
-
*
|
|
2119
|
-
* @default DragHandle
|
|
2120
|
-
*/
|
|
2121
|
-
dragHandle: ForwardRefExoticComponent<DragHandleProps & RefAttributes<HTMLElement>> | null;
|
|
2122
|
-
/**
|
|
2123
|
-
* Selects the `field` property for the current rule.
|
|
2124
|
-
*
|
|
2125
|
-
* @default ValueSelector
|
|
2126
|
-
*/
|
|
2127
|
-
fieldSelector: ComponentType<FieldSelectorProps<F>> | null;
|
|
2128
|
-
/**
|
|
2129
|
-
* A small wrapper around the `combinatorSelector` component.
|
|
2130
|
-
*
|
|
2131
|
-
* @default InlineCombinator
|
|
2132
|
-
*/
|
|
2133
|
-
inlineCombinator: ComponentType<InlineCombinatorProps> | null;
|
|
2134
|
-
/**
|
|
2135
|
-
* Locks the current group (sets the `disabled` property to `true`).
|
|
2136
|
-
*
|
|
2137
|
-
* @default ActionElement
|
|
2138
|
-
*/
|
|
2139
|
-
lockGroupAction: ComponentType<ActionProps> | null;
|
|
2140
|
-
/**
|
|
2141
|
-
* Locks the current rule (sets the `disabled` property to `true`).
|
|
2142
|
-
*
|
|
2143
|
-
* @default ActionElement
|
|
2144
|
-
*/
|
|
2145
|
-
lockRuleAction: ComponentType<ActionProps> | null;
|
|
2146
|
-
/**
|
|
2147
|
-
* Mutes the current group (sets the `muted` property to `true`).
|
|
2148
|
-
*
|
|
2149
|
-
* @default ActionElement
|
|
2150
|
-
*/
|
|
2151
|
-
muteGroupAction: ComponentType<ActionProps> | null;
|
|
2152
|
-
/**
|
|
2153
|
-
* Mutes the current rule (sets the `muted` property to `true`).
|
|
2154
|
-
*
|
|
2155
|
-
* @default ActionElement
|
|
2156
|
-
*/
|
|
2157
|
-
muteRuleAction: ComponentType<ActionProps> | null;
|
|
2158
|
-
/**
|
|
2159
|
-
* Selects the `match` property for the current rule.
|
|
2160
|
-
*
|
|
2161
|
-
* @default MatchModeEditor
|
|
2162
|
-
*/
|
|
2163
|
-
matchModeEditor: ComponentType<MatchModeEditorProps> | null;
|
|
2164
|
-
/**
|
|
2165
|
-
* Toggles the `not` property of the current group between `true` and `false`.
|
|
2166
|
-
*
|
|
2167
|
-
* @default NotToggle
|
|
2168
|
-
*/
|
|
2169
|
-
notToggle: ComponentType<NotToggleProps> | null;
|
|
2170
|
-
/**
|
|
2171
|
-
* Selects the `operator` property for the current rule.
|
|
2172
|
-
*
|
|
2173
|
-
* @default ValueSelector
|
|
2174
|
-
*/
|
|
2175
|
-
operatorSelector: ComponentType<OperatorSelectorProps> | null;
|
|
2176
|
-
/**
|
|
2177
|
-
* Removes the current group from its parent group's `rules` array.
|
|
2178
|
-
*
|
|
2179
|
-
* @default ActionElement
|
|
2180
|
-
*/
|
|
2181
|
-
removeGroupAction: ComponentType<ActionProps> | null;
|
|
2182
|
-
/**
|
|
2183
|
-
* Removes the current rule from its parent group's `rules` array.
|
|
2184
|
-
*
|
|
2185
|
-
* @default ActionElement
|
|
2186
|
-
*/
|
|
2187
|
-
removeRuleAction: ComponentType<ActionProps> | null;
|
|
2188
|
-
/**
|
|
2189
|
-
* Rule layout component.
|
|
2190
|
-
*
|
|
2191
|
-
* @default Rule
|
|
2192
|
-
*/
|
|
2193
|
-
rule: ComponentType<RuleProps>;
|
|
2194
|
-
/**
|
|
2195
|
-
* Rule group layout component.
|
|
2196
|
-
*
|
|
2197
|
-
* @default RuleGroup
|
|
2198
|
-
*/
|
|
2199
|
-
ruleGroup: ComponentType<RuleGroupProps<F, O>>;
|
|
2200
|
-
/**
|
|
2201
|
-
* Rule group body components.
|
|
2202
|
-
*
|
|
2203
|
-
* @default RuleGroupBodyComponents
|
|
2204
|
-
*/
|
|
2205
|
-
ruleGroupBodyElements: ComponentType<RuleGroupProps & UseRuleGroup>;
|
|
2206
|
-
/**
|
|
2207
|
-
* Rule group header components.
|
|
2208
|
-
*
|
|
2209
|
-
* @default RuleGroupHeaderComponents
|
|
2210
|
-
*/
|
|
2211
|
-
ruleGroupHeaderElements: ComponentType<RuleGroupProps & UseRuleGroup>;
|
|
2212
|
-
/**
|
|
2213
|
-
* Shifts the current rule/group up or down in the query hierarchy.
|
|
2214
|
-
*
|
|
2215
|
-
* @default ShiftActions
|
|
2216
|
-
*/
|
|
2217
|
-
shiftActions: ComponentType<ShiftActionsProps> | null;
|
|
2218
|
-
/**
|
|
2219
|
-
* Updates the `value` property for the current rule.
|
|
2220
|
-
*
|
|
2221
|
-
* @default ValueEditor
|
|
2222
|
-
*/
|
|
2223
|
-
valueEditor: ComponentType<ValueEditorProps<F, O>> | null;
|
|
2224
|
-
/**
|
|
2225
|
-
* Default component for all value selector controls.
|
|
2226
|
-
*
|
|
2227
|
-
* @default ValueSelector
|
|
2228
|
-
*/
|
|
2229
|
-
valueSelector: ComponentType<ValueSelectorProps>;
|
|
2230
|
-
/**
|
|
2231
|
-
* Selects the `valueSource` property for the current rule.
|
|
2232
|
-
*
|
|
2233
|
-
* @default ValueSelector
|
|
2234
|
-
*/
|
|
2235
|
-
valueSourceSelector: ComponentType<ValueSourceSelectorProps> | null;
|
|
2236
|
-
}>;
|
|
2237
|
-
/**
|
|
2238
|
-
* Configuration options passed in the `schema` prop from
|
|
2239
|
-
* {@link QueryBuilder} to each subcomponent.
|
|
2240
|
-
*
|
|
2241
|
-
* @group Props
|
|
2242
|
-
*/
|
|
2243
|
-
interface Schema<F extends FullField, O extends string> {
|
|
2244
|
-
qbId: string;
|
|
2245
|
-
fields: FullOptionList<F>;
|
|
2246
|
-
fieldMap: Partial<Record<GetOptionIdentifierType<F>, F>>;
|
|
2247
|
-
classNames: Classnames;
|
|
2248
|
-
combinators: FullOptionList<FullCombinator>;
|
|
2249
|
-
controls: Controls<F, O>;
|
|
2250
|
-
createRule(): RuleType;
|
|
2251
|
-
createRuleGroup(ic?: boolean): RuleGroupTypeAny;
|
|
2252
|
-
dispatchQuery(query: RuleGroupTypeAny): void;
|
|
2253
|
-
getQuery(): RuleGroupTypeAny;
|
|
2254
|
-
getOperators(field: string, meta: {
|
|
2255
|
-
fieldData: F;
|
|
2256
|
-
}): FullOptionList<FullOperator>;
|
|
2257
|
-
getValueEditorType(field: string, operator: string, meta: {
|
|
2258
|
-
fieldData: F;
|
|
2259
|
-
}): ValueEditorType;
|
|
2260
|
-
getValueEditorSeparator(field: string, operator: string, meta: {
|
|
2261
|
-
fieldData: F;
|
|
2262
|
-
}): ReactNode;
|
|
2263
|
-
getValueSources(field: string, operator: string, meta: {
|
|
2264
|
-
fieldData: F;
|
|
2265
|
-
}): ValueSourceFullOptions;
|
|
2266
|
-
getInputType(field: string, operator: string, meta: {
|
|
2267
|
-
fieldData: F;
|
|
2268
|
-
}): InputType | null;
|
|
2269
|
-
getValues(field: string, operator: string, meta: {
|
|
2270
|
-
fieldData: F;
|
|
2271
|
-
}): FullOptionList<Option>;
|
|
2272
|
-
getMatchModes(field: string, misc: {
|
|
2273
|
-
fieldData: F;
|
|
2274
|
-
}): MatchModeOptions;
|
|
2275
|
-
getSubQueryBuilderProps(field: GetOptionIdentifierType<F>, misc: {
|
|
2276
|
-
fieldData: F;
|
|
2277
|
-
}): QueryBuilderProps<RuleGroupTypeAny, FullOption, FullOption, FullOption>;
|
|
2278
|
-
getRuleClassname(rule: RuleType, misc: {
|
|
2279
|
-
fieldData: F;
|
|
2280
|
-
}): Classname;
|
|
2281
|
-
getRuleGroupClassname(ruleGroup: RuleGroupTypeAny): Classname;
|
|
2282
|
-
accessibleDescriptionGenerator: AccessibleDescriptionGenerator;
|
|
2283
|
-
showCombinatorsBetweenRules: boolean;
|
|
2284
|
-
showNotToggle: boolean;
|
|
2285
|
-
showShiftActions: boolean;
|
|
2286
|
-
showCloneButtons: boolean;
|
|
2287
|
-
showLockButtons: boolean;
|
|
2288
|
-
showMuteButtons: boolean;
|
|
2289
|
-
autoSelectField: boolean;
|
|
2290
|
-
autoSelectOperator: boolean;
|
|
2291
|
-
autoSelectValue: boolean;
|
|
2292
|
-
addRuleToNewGroups: boolean;
|
|
2293
|
-
enableDragAndDrop: boolean;
|
|
2294
|
-
validationMap: ValidationMap;
|
|
2295
|
-
independentCombinators: boolean;
|
|
2296
|
-
listsAsArrays: boolean;
|
|
2297
|
-
parseNumbers: ParseNumbersPropConfig;
|
|
2298
|
-
disabledPaths: Path[];
|
|
2299
|
-
suppressStandardClassnames: boolean;
|
|
2300
|
-
maxLevels: number;
|
|
2301
|
-
}
|
|
2302
|
-
/**
|
|
2303
|
-
* Common props between {@link Rule} and {@link RuleGroup}.
|
|
2304
|
-
*/
|
|
2305
|
-
interface CommonRuleAndGroupProps<F extends FullField = FullField, O extends string = string> {
|
|
2306
|
-
id?: string;
|
|
2307
|
-
path: Path;
|
|
2308
|
-
parentDisabled?: boolean;
|
|
2309
|
-
parentMuted?: boolean;
|
|
2310
|
-
translations: Translations;
|
|
2311
|
-
schema: Schema<F, O>;
|
|
2312
|
-
actions: QueryActions;
|
|
2313
|
-
disabled?: boolean;
|
|
2314
|
-
shiftUpDisabled?: boolean;
|
|
2315
|
-
shiftDownDisabled?: boolean;
|
|
2316
|
-
context?: any;
|
|
2317
|
-
}
|
|
2318
|
-
/**
|
|
2319
|
-
* Return type of {@link @react-querybuilder/dnd!useRuleGroupDnD} hook.
|
|
2320
|
-
*/
|
|
2321
|
-
interface UseRuleGroupDnD {
|
|
2322
|
-
isDragging: boolean;
|
|
2323
|
-
dragMonitorId: string | symbol;
|
|
2324
|
-
isOver: boolean;
|
|
2325
|
-
dropMonitorId: string | symbol;
|
|
2326
|
-
previewRef: Ref<HTMLDivElement>;
|
|
2327
|
-
dragRef: Ref<HTMLSpanElement>;
|
|
2328
|
-
dropRef: Ref<HTMLDivElement>;
|
|
2329
|
-
/** `"move"` by default; `"copy"` if the modifier key is pressed. */
|
|
2330
|
-
dropEffect?: DropEffect;
|
|
2331
|
-
/** True if the dragged and hovered items should form a new group. */
|
|
2332
|
-
groupItems?: boolean;
|
|
2333
|
-
dropNotAllowed?: boolean;
|
|
2334
|
-
}
|
|
2335
|
-
/**
|
|
2336
|
-
* {@link RuleGroup} props.
|
|
2337
|
-
*
|
|
2338
|
-
* @group Props
|
|
2339
|
-
*/
|
|
2340
|
-
interface RuleGroupProps<F extends FullOption = FullOption, O extends string = string> extends CommonRuleAndGroupProps<F, O>, Partial<UseRuleGroupDnD> {
|
|
2341
|
-
ruleGroup: RuleGroupTypeAny<RuleType<GetOptionIdentifierType<F>, O>>;
|
|
2342
|
-
/**
|
|
2343
|
-
* @deprecated Use the `combinator` property of the `ruleGroup` prop instead
|
|
2344
|
-
*/
|
|
2345
|
-
combinator?: string;
|
|
2346
|
-
/**
|
|
2347
|
-
* @deprecated Use the `rules` property of the `ruleGroup` prop instead
|
|
2348
|
-
*/
|
|
2349
|
-
rules?: RuleOrGroupArray;
|
|
2350
|
-
/**
|
|
2351
|
-
* @deprecated Use the `not` property of the `ruleGroup` prop instead
|
|
2352
|
-
*/
|
|
2353
|
-
not?: boolean;
|
|
2354
|
-
}
|
|
2355
|
-
/**
|
|
2356
|
-
* Return type of {@link @react-querybuilder/dnd!useRuleDnD} hook.
|
|
2357
|
-
*/
|
|
2358
|
-
interface UseRuleDnD {
|
|
2359
|
-
isDragging: boolean;
|
|
2360
|
-
dragMonitorId: string | symbol;
|
|
2361
|
-
isOver: boolean;
|
|
2362
|
-
dropMonitorId: string | symbol;
|
|
2363
|
-
dragRef: Ref<HTMLSpanElement>;
|
|
2364
|
-
dndRef: Ref<HTMLDivElement>;
|
|
2365
|
-
/** `"move"` by default; `"copy"` if the modifier key is pressed. */
|
|
2366
|
-
dropEffect?: DropEffect;
|
|
2367
|
-
/** True if the dragged and hovered items should form a new group. */
|
|
2368
|
-
groupItems?: boolean;
|
|
2369
|
-
dropNotAllowed?: boolean;
|
|
2370
|
-
}
|
|
2371
|
-
/**
|
|
2372
|
-
* {@link Rule} props.
|
|
2373
|
-
*
|
|
2374
|
-
* @group Props
|
|
2375
|
-
*/
|
|
2376
|
-
interface RuleProps<F extends string = string, O extends string = string> extends CommonRuleAndGroupProps<FullOption<F>, O>, Partial<UseRuleDnD> {
|
|
2377
|
-
rule: RuleType<F, O>;
|
|
2378
|
-
/**
|
|
2379
|
-
* @deprecated Use the `field` property of the `rule` prop instead
|
|
2380
|
-
*/
|
|
2381
|
-
field?: string;
|
|
2382
|
-
/**
|
|
2383
|
-
* @deprecated Use the `operator` property of the `rule` prop instead
|
|
2384
|
-
*/
|
|
2385
|
-
operator?: string;
|
|
2386
|
-
/**
|
|
2387
|
-
* @deprecated Use the `value` property of the `rule` prop instead
|
|
2388
|
-
*/
|
|
2389
|
-
value?: any;
|
|
2390
|
-
/**
|
|
2391
|
-
* @deprecated Use the `valueSource` property of the `rule` prop instead
|
|
2392
|
-
*/
|
|
2393
|
-
valueSource?: ValueSource;
|
|
2394
|
-
}
|
|
2395
|
-
/**
|
|
2396
|
-
* Props passed down through context from a {@link QueryBuilderContextProvider}.
|
|
2397
|
-
*
|
|
2398
|
-
* @group Props
|
|
2399
|
-
*/
|
|
2400
|
-
interface QueryBuilderContextProps<F extends FullField = FullField, O extends string = string> extends QueryBuilderFlags {
|
|
2401
|
-
/**
|
|
2402
|
-
* Defines replacement components.
|
|
2403
|
-
*/
|
|
2404
|
-
controlElements?: ControlElementsProp<F, O>;
|
|
2405
|
-
/**
|
|
2406
|
-
* This can be used to assign specific CSS classes to various controls
|
|
2407
|
-
* that are rendered by {@link QueryBuilder}.
|
|
2408
|
-
*/
|
|
2409
|
-
controlClassnames?: Partial<Classnames>;
|
|
2410
|
-
/**
|
|
2411
|
-
* This can be used to override translatable texts applied to the various
|
|
2412
|
-
* controls that are rendered by {@link QueryBuilder}.
|
|
2413
|
-
*/
|
|
2414
|
-
translations?: Partial<Translations>;
|
|
2415
|
-
}
|
|
2416
|
-
/**
|
|
2417
|
-
* @group Props
|
|
2418
|
-
*/
|
|
2419
|
-
interface QueryBuilderContextProviderProps extends QueryBuilderContextProps {
|
|
2420
|
-
children?: ReactNode;
|
|
2421
|
-
}
|
|
2422
|
-
/**
|
|
2423
|
-
* @group Components
|
|
2424
|
-
*/
|
|
2425
|
-
type QueryBuilderContextProvider<ExtraProps extends object = Record<string, any>> = ComponentType<QueryBuilderContextProviderProps & ExtraProps>;
|
|
2426
|
-
/**
|
|
2427
|
-
* Props for {@link QueryBuilder}.
|
|
2428
|
-
*
|
|
2429
|
-
* Notes:
|
|
2430
|
-
* - Only one of `query` or `defaultQuery` should be provided. If `query` is present,
|
|
2431
|
-
* then `defaultQuery` should be undefined and vice versa.
|
|
2432
|
-
* - If rendered initially with a `query` prop, then `query` must be defined in every
|
|
2433
|
-
* subsequent render or warnings will be logged (in non-production modes only).
|
|
2434
|
-
*
|
|
2435
|
-
* @typeParam RG - The type of the query object, inferred from either the `query` or `defaultQuery` prop.
|
|
2436
|
-
* Must extend {@link RuleGroupType} or {@link RuleGroupTypeIC}.
|
|
2437
|
-
* @typeParam F - The field type (see {@link Field}).
|
|
2438
|
-
* @typeParam O - The operator type (see {@link Operator}).
|
|
2439
|
-
* @typeParam C - The combinator type (see {@link Combinator}).
|
|
2440
|
-
*
|
|
2441
|
-
* @group Props
|
|
2442
|
-
*/
|
|
2443
|
-
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>> & {
|
|
2444
|
-
/**
|
|
2445
|
-
* Initial query object for uncontrolled components.
|
|
2446
|
-
*/
|
|
2447
|
-
defaultQuery?: RG;
|
|
2448
|
-
/**
|
|
2449
|
-
* Query object for controlled components.
|
|
2450
|
-
*/
|
|
2451
|
-
query?: RG;
|
|
2452
|
-
/**
|
|
2453
|
-
* List of valid {@link FullField}s.
|
|
2454
|
-
*
|
|
2455
|
-
* @default []
|
|
2456
|
-
*/
|
|
2457
|
-
fields?: FlexibleOptionListProp<F> | BaseOptionMap<F>;
|
|
2458
|
-
/**
|
|
2459
|
-
* List of valid {@link FullOperator}s.
|
|
2460
|
-
*
|
|
2461
|
-
* @see {@link DefaultOperatorName}
|
|
2462
|
-
*
|
|
2463
|
-
* @default
|
|
2464
|
-
* [
|
|
2465
|
-
* { name: '=', label: '=' },
|
|
2466
|
-
* { name: '!=', label: '!=' },
|
|
2467
|
-
* { name: '<', label: '<' },
|
|
2468
|
-
* { name: '>', label: '>' },
|
|
2469
|
-
* { name: '<=', label: '<=' },
|
|
2470
|
-
* { name: '>=', label: '>=' },
|
|
2471
|
-
* { name: 'contains', label: 'contains' },
|
|
2472
|
-
* { name: 'beginsWith', label: 'begins with' },
|
|
2473
|
-
* { name: 'endsWith', label: 'ends with' },
|
|
2474
|
-
* { name: 'doesNotContain', label: 'does not contain' },
|
|
2475
|
-
* { name: 'doesNotBeginWith', label: 'does not begin with' },
|
|
2476
|
-
* { name: 'doesNotEndWith', label: 'does not end with' },
|
|
2477
|
-
* { name: 'null', label: 'is null' },
|
|
2478
|
-
* { name: 'notNull', label: 'is not null' },
|
|
2479
|
-
* { name: 'in', label: 'in' },
|
|
2480
|
-
* { name: 'notIn', label: 'not in' },
|
|
2481
|
-
* { name: 'between', label: 'between' },
|
|
2482
|
-
* { name: 'notBetween', label: 'not between' },
|
|
2483
|
-
* ]
|
|
2484
|
-
*/
|
|
2485
|
-
operators?: FlexibleOptionListProp<O>;
|
|
2486
|
-
/**
|
|
2487
|
-
* List of valid {@link FullCombinator}s.
|
|
2488
|
-
*
|
|
2489
|
-
* @see {@link DefaultCombinatorName}
|
|
2490
|
-
*
|
|
2491
|
-
* @default
|
|
2492
|
-
* [
|
|
2493
|
-
* {name: 'and', label: 'AND'},
|
|
2494
|
-
* {name: 'or', label: 'OR'},
|
|
2495
|
-
* ]
|
|
2496
|
-
*/
|
|
2497
|
-
combinators?: FlexibleOptionListProp<C>;
|
|
2498
|
-
/**
|
|
2499
|
-
* Default properties applied to all objects in the `fields` prop. Properties on
|
|
2500
|
-
* individual field definitions will override these.
|
|
2501
|
-
*/
|
|
2502
|
-
baseField?: Record<string, unknown>;
|
|
2503
|
-
/**
|
|
2504
|
-
* Default properties applied to all objects in the `operators` prop. Properties on
|
|
2505
|
-
* individual operator definitions will override these.
|
|
2506
|
-
*/
|
|
2507
|
-
baseOperator?: Record<string, unknown>;
|
|
2508
|
-
/**
|
|
2509
|
-
* Default properties applied to all objects in the `combinators` prop. Properties on
|
|
2510
|
-
* individual combinator definitions will override these.
|
|
2511
|
-
*/
|
|
2512
|
-
baseCombinator?: Record<string, unknown>;
|
|
2513
|
-
/**
|
|
2514
|
-
* The default `field` value for new rules. This can be the field `name`
|
|
2515
|
-
* itself or a function that returns a valid {@link FullField} `name` given
|
|
2516
|
-
* the `fields` list.
|
|
2517
|
-
*/
|
|
2518
|
-
getDefaultField?: GetOptionIdentifierType<F> | ((fieldsData: FullOptionList<F>) => string);
|
|
2519
|
-
/**
|
|
2520
|
-
* The default `operator` value for new rules. This can be the operator
|
|
2521
|
-
* `name` or a function that returns a valid {@link FullOperator} `name` for
|
|
2522
|
-
* a given field name.
|
|
2523
|
-
*/
|
|
2524
|
-
getDefaultOperator?: GetOptionIdentifierType<O> | ((field: GetOptionIdentifierType<F>, misc: {
|
|
2525
|
-
fieldData: F;
|
|
2526
|
-
}) => string);
|
|
2527
|
-
/**
|
|
2528
|
-
* Returns the default `value` for new rules.
|
|
2529
|
-
*/
|
|
2530
|
-
getDefaultValue?(rule: R, misc: {
|
|
2531
|
-
fieldData: F;
|
|
2532
|
-
}): any;
|
|
2533
|
-
/**
|
|
2534
|
-
* This function should return the list of allowed {@link FullOperator}s
|
|
2535
|
-
* for the given {@link FullField} `name`. If `null` is returned, the
|
|
2536
|
-
* {@link DefaultOperator}s are used.
|
|
2537
|
-
*/
|
|
2538
|
-
getOperators?(field: GetOptionIdentifierType<F>, misc: {
|
|
2539
|
-
fieldData: F;
|
|
2540
|
-
}): FlexibleOptionListProp<FullOperator> | null;
|
|
2541
|
-
/**
|
|
2542
|
-
* This function should return the type of {@link ValueEditor} (see
|
|
2543
|
-
* {@link ValueEditorType}) for the given field `name` and operator `name`.
|
|
2544
|
-
*/
|
|
2545
|
-
getValueEditorType?(field: GetOptionIdentifierType<F>, operator: GetOptionIdentifierType<O>, misc: {
|
|
2546
|
-
fieldData: F;
|
|
2547
|
-
}): ValueEditorType;
|
|
2548
|
-
/**
|
|
2549
|
-
* This function should return the separator element for a given field
|
|
2550
|
-
* `name` and operator `name`. The element can be any valid React element,
|
|
2551
|
-
* including a bare string (e.g., "and" or "to") or an HTML element like
|
|
2552
|
-
* `<span />`. It will be placed in between value editors when multiple
|
|
2553
|
-
* editors are rendered, such as when the `operator` is `"between"`.
|
|
2554
|
-
*/
|
|
2555
|
-
getValueEditorSeparator?(field: GetOptionIdentifierType<F>, operator: GetOptionIdentifierType<O>, misc: {
|
|
2556
|
-
fieldData: F;
|
|
2557
|
-
}): ReactNode;
|
|
2558
|
-
/**
|
|
2559
|
-
* This function should return the list of valid {@link ValueSources}
|
|
2560
|
-
* for a given field `name` and operator `name`. The return value must
|
|
2561
|
-
* be an array that includes at least one valid {@link ValueSource}
|
|
2562
|
-
* (i.e. `["value"]`, `["field"]`, `["value", "field"]`, or
|
|
2563
|
-
* `["field", "value"]`).
|
|
2564
|
-
*/
|
|
2565
|
-
getValueSources?(field: GetOptionIdentifierType<F>, operator: GetOptionIdentifierType<O>, misc: {
|
|
2566
|
-
fieldData: F;
|
|
2567
|
-
}): ValueSources | ValueSourceFlexibleOptions;
|
|
2568
|
-
/**
|
|
2569
|
-
* This function should return the `type` of `<input />`
|
|
2570
|
-
* for the given field `name` and operator `name` (only applicable when
|
|
2571
|
-
* `getValueEditorType` returns `"text"` or a falsy value). If no
|
|
2572
|
-
* function is provided, `"text"` is used as the default.
|
|
2573
|
-
*/
|
|
2574
|
-
getInputType?(field: GetOptionIdentifierType<F>, operator: GetOptionIdentifierType<O>, misc: {
|
|
2575
|
-
fieldData: F;
|
|
2576
|
-
}): InputType | null;
|
|
2577
|
-
/**
|
|
2578
|
-
* This function should return the list of allowed values for the
|
|
2579
|
-
* given field `name` and operator `name` (only applicable when
|
|
2580
|
-
* `getValueEditorType` returns `"select"` or `"radio"`). If no
|
|
2581
|
-
* function is provided, an empty array is used as the default.
|
|
2582
|
-
*/
|
|
2583
|
-
getValues?(field: GetOptionIdentifierType<F>, operator: GetOptionIdentifierType<O>, misc: {
|
|
2584
|
-
fieldData: F;
|
|
2585
|
-
}): FlexibleOptionListProp<Option>;
|
|
2586
|
-
/**
|
|
2587
|
-
* This function should return the list of valid {@link MatchMode}s or
|
|
2588
|
-
* {@link MatchConfig}s for a given field `name`. The return value must
|
|
2589
|
-
* be an array that includes at least one valid {@link MatchMode}, or `true`
|
|
2590
|
-
* to indicate that all match modes are allowed. Any other return value
|
|
2591
|
-
* will be ignored (no match modes will be allowed).
|
|
2592
|
-
*/
|
|
2593
|
-
getMatchModes?(field: GetOptionIdentifierType<F>, misc: {
|
|
2594
|
-
fieldData: F;
|
|
2595
|
-
}): boolean | MatchMode[] | FlexibleOption<MatchMode>[];
|
|
2596
|
-
/**
|
|
2597
|
-
* This function should return any props that a subquery (see {@link MatchMode})
|
|
2598
|
-
* should override from the props provided to this query builder. Note that certain
|
|
2599
|
-
* props like `query`, `onQueryChange`, and `enableDragAndDrop` will be ignored.
|
|
2600
|
-
*/
|
|
2601
|
-
getSubQueryBuilderProps?(field: GetOptionIdentifierType<F>, misc: {
|
|
2602
|
-
fieldData: F;
|
|
2603
|
-
}): QueryBuilderProps<GenericizeRuleGroupType<RG>, FullOption, FullOption, FullOption>;
|
|
2604
|
-
/**
|
|
2605
|
-
* The return value of this function will be used to apply classnames to the
|
|
2606
|
-
* outer `<div>` of the given {@link Rule}.
|
|
2607
|
-
*/
|
|
2608
|
-
getRuleClassname?(rule: R, misc: {
|
|
2609
|
-
fieldData: F;
|
|
2610
|
-
}): Classname;
|
|
2611
|
-
/**
|
|
2612
|
-
* The return value of this function will be used to apply classnames to the
|
|
2613
|
-
* outer `<div>` of the given {@link RuleGroup}.
|
|
2614
|
-
*/
|
|
2615
|
-
getRuleGroupClassname?(ruleGroup: RG): Classname;
|
|
2616
|
-
/**
|
|
2617
|
-
* This callback is invoked before a new rule is added. The function should either manipulate
|
|
2618
|
-
* the rule and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2619
|
-
* or return `false` to cancel the addition of the rule.
|
|
2620
|
-
*/
|
|
2621
|
-
onAddRule?(rule: R, parentPath: Path, query: RG, context?: any): RuleType | boolean;
|
|
2622
|
-
/**
|
|
2623
|
-
* This callback is invoked before a new group is added. The function should either manipulate
|
|
2624
|
-
* the group and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2625
|
-
* or return `false` to cancel the addition of the group.
|
|
2626
|
-
*/
|
|
2627
|
-
onAddGroup?(ruleGroup: RG, parentPath: Path, query: RG, context?: any): RG | boolean;
|
|
2628
|
-
/**
|
|
2629
|
-
* This callback is invoked before a rule is moved or shifted. The function should return
|
|
2630
|
-
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2631
|
-
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2632
|
-
* query state.
|
|
2633
|
-
*/
|
|
2634
|
-
onMoveRule?(rule: R, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2635
|
-
/**
|
|
2636
|
-
* This callback is invoked before a group is moved or shifted. The function should return
|
|
2637
|
-
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2638
|
-
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2639
|
-
* query state.
|
|
2640
|
-
*/
|
|
2641
|
-
onMoveGroup?(ruleGroup: RG, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2642
|
-
/**
|
|
2643
|
-
* This callback is invoked before a rule is grouped with another object. The function should
|
|
2644
|
-
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2645
|
-
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2646
|
-
* query state.
|
|
2647
|
-
*/
|
|
2648
|
-
onGroupRule?(rule: R, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2649
|
-
/**
|
|
2650
|
-
* This callback is invoked before a group is grouped with another object. The function should
|
|
2651
|
-
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2652
|
-
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2653
|
-
* query state.
|
|
2654
|
-
*/
|
|
2655
|
-
onGroupGroup?(ruleGroup: RG, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2656
|
-
/**
|
|
2657
|
-
* This callback is invoked before a rule or group is removed. The function should return
|
|
2658
|
-
* `true` if the rule or group should be removed or `false` if it should not be removed.
|
|
2659
|
-
*/
|
|
2660
|
-
onRemove?(ruleOrGroup: R | RG, path: Path, query: RG, context?: any): boolean;
|
|
2661
|
-
/**
|
|
2662
|
-
* This callback is invoked anytime the query state is updated.
|
|
2663
|
-
*/
|
|
2664
|
-
onQueryChange?(query: RG): void;
|
|
2665
|
-
/**
|
|
2666
|
-
* Each log object will be passed to this function when `debugMode` is `true`.
|
|
2667
|
-
*
|
|
2668
|
-
* @default console.log
|
|
2669
|
-
*/
|
|
2670
|
-
onLog?(obj: any): void;
|
|
2671
|
-
/**
|
|
2672
|
-
* @deprecated As of v7, this prop is ignored. To enable independent combinators, use
|
|
2673
|
-
* {@link RuleGroupTypeIC} for the `query` or `defaultQuery` prop. The query builder
|
|
2674
|
-
* will detect the query type and behave accordingly.
|
|
2675
|
-
*/
|
|
2676
|
-
independentCombinators?: boolean;
|
|
2677
|
-
/**
|
|
2678
|
-
* Disables the entire query builder if true, or the rules and groups at
|
|
2679
|
-
* the specified paths (as well as all child rules/groups and subcomponents)
|
|
2680
|
-
* if an array of paths is provided. If the root path is specified (`disabled={[[]]}`),
|
|
2681
|
-
* no changes to the query are allowed.
|
|
2682
|
-
*
|
|
2683
|
-
* @default false
|
|
2684
|
-
*/
|
|
2685
|
-
disabled?: boolean | Path[];
|
|
2686
|
-
/**
|
|
2687
|
-
* Store values as numbers whenever possible.
|
|
2688
|
-
*
|
|
2689
|
-
* _**TIP: Try `"strict-limited"` first.**_
|
|
2690
|
-
*
|
|
2691
|
-
* Options include `true`, `false`, `"enhanced"`, `"native"`, and `"strict"`. The `string` options
|
|
2692
|
-
* can be suffixed with `"-limited"`.
|
|
2693
|
-
*
|
|
2694
|
-
* - `false` avoids numeric parsing
|
|
2695
|
-
* - `true` or `"strict"` parses values using `numeric-quantity`, bailing out (returning the original
|
|
2696
|
-
* string) when trailing invalid characters are present
|
|
2697
|
-
* - `"enhanced"` is the same as `true`/`"strict"`, but ignores trailing invalid characters (CAUTION:
|
|
2698
|
-
* this can lead to information loss)
|
|
2699
|
-
* - `"native"` parses values using `parseFloat`, returning `NaN` when parsing fails
|
|
2700
|
-
*
|
|
2701
|
-
* When the value is `true` or a string without the "-limited" suffix, the default {@link ValueEditor}
|
|
2702
|
-
* will attempt to parse *all* inputs as numbers. **CAUTION: This can lead to unexpected behavior.**
|
|
2703
|
-
*
|
|
2704
|
-
* When the value is a string with the "-limited" suffix, the default {@link ValueEditor} will
|
|
2705
|
-
* only attempt to parse inputs as numbers when the `inputType` is `"number"`.
|
|
2706
|
-
*
|
|
2707
|
-
* @default false
|
|
2708
|
-
*/
|
|
2709
|
-
parseNumbers?: ParseNumbersPropConfig;
|
|
2710
|
-
/**
|
|
2711
|
-
* Query validation function.
|
|
2712
|
-
*/
|
|
2713
|
-
validator?: QueryValidator;
|
|
2714
|
-
/**
|
|
2715
|
-
* `id` generator function. Should always produce a unique/random value.
|
|
2716
|
-
*
|
|
2717
|
-
* @default crypto.randomUUID
|
|
2718
|
-
*/
|
|
2719
|
-
idGenerator?: () => string;
|
|
2720
|
-
/**
|
|
2721
|
-
* Generator function for the `title` attribute applied to the outermost `<div>` of each
|
|
2722
|
-
* rule group. As this is intended to help with accessibility, the text output from this
|
|
2723
|
-
* function should be meaningful, descriptive, and unique within the page.
|
|
2724
|
-
*/
|
|
2725
|
-
accessibleDescriptionGenerator?: AccessibleDescriptionGenerator;
|
|
2726
|
-
/**
|
|
2727
|
-
* Maximum number of levels deep the query is allowed to go. The minimum is 1; values
|
|
2728
|
-
* less than 1 will be ignored.
|
|
2729
|
-
*/
|
|
2730
|
-
maxLevels?: number;
|
|
2731
|
-
/**
|
|
2732
|
-
* Container for custom props that are passed to all components.
|
|
2733
|
-
*/
|
|
2734
|
-
context?: any;
|
|
2735
|
-
} : never;
|
|
2736
|
-
//#endregion
|
|
2737
|
-
//#region ../react-querybuilder/src/redux/getRqbStore.d.ts
|
|
2738
|
-
declare global {
|
|
2739
|
-
var __RQB_DEVTOOLS__: boolean | undefined;
|
|
2740
|
-
}
|
|
2741
|
-
/**
|
|
2742
|
-
* Gets the singleton React Query Builder store instance.
|
|
2743
|
-
* DevTools are enabled if either:
|
|
2744
|
-
* - globalThis.__RQB_DEVTOOLS__ is truthy
|
|
2745
|
-
* - window.__RQB_DEVTOOLS__ is truthy
|
|
2746
|
-
*/
|
|
2747
|
-
//#endregion
|
|
2748
7
|
//#region src/AntDActionElement.d.ts
|
|
2749
|
-
type RemoveDataIndexKeys<T
|
|
8
|
+
type RemoveDataIndexKeys<T> = { [K in keyof T as `data-${string}` extends K ? never : K]: T[K] };
|
|
2750
9
|
/**
|
|
2751
10
|
* @group Props
|
|
2752
11
|
*/
|