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