@react-querybuilder/bootstrap 8.8.4 → 8.9.2

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