@react-querybuilder/bootstrap 8.11.2 → 8.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/react-querybuilder_bootstrap.cjs.development.d.ts +155 -115
- package/dist/cjs/react-querybuilder_bootstrap.cjs.development.js +10 -7
- package/dist/cjs/react-querybuilder_bootstrap.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_bootstrap.cjs.production.d.ts +155 -115
- package/dist/cjs/react-querybuilder_bootstrap.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_bootstrap.cjs.production.js.map +1 -1
- package/dist/react-querybuilder_bootstrap.d.mts +155 -115
- package/dist/react-querybuilder_bootstrap.legacy-esm.d.ts +155 -115
- package/dist/react-querybuilder_bootstrap.legacy-esm.js +5 -5
- package/dist/react-querybuilder_bootstrap.production.d.mts +155 -115
- package/package.json +7 -7
|
@@ -18,34 +18,6 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
18
18
|
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
A more applicable example which could make its way into your library code follows.
|
|
22
|
-
|
|
23
|
-
@example
|
|
24
|
-
```
|
|
25
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
26
|
-
|
|
27
|
-
class CommandOne {
|
|
28
|
-
commands: {
|
|
29
|
-
a1: () => undefined,
|
|
30
|
-
b1: () => undefined,
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
class CommandTwo {
|
|
35
|
-
commands: {
|
|
36
|
-
a2: (argA: string) => undefined,
|
|
37
|
-
b2: (argB: string) => undefined,
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
42
|
-
type Union = typeof union;
|
|
43
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
44
|
-
|
|
45
|
-
type Intersection = UnionToIntersection<Union>;
|
|
46
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
21
|
@category Type
|
|
50
22
|
*/
|
|
51
23
|
type UnionToIntersection<Union> = (
|
|
@@ -121,8 +93,8 @@ import type {IsAny} from 'type-fest';
|
|
|
121
93
|
const typedObject = {a: 1, b: 2} as const;
|
|
122
94
|
const anyObject: any = {a: 1, b: 2};
|
|
123
95
|
|
|
124
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
125
|
-
return
|
|
96
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
97
|
+
return object[key];
|
|
126
98
|
}
|
|
127
99
|
|
|
128
100
|
const typedA = get(typedObject, 'a');
|
|
@@ -147,17 +119,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
147
119
|
```
|
|
148
120
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
149
121
|
|
|
150
|
-
|
|
122
|
+
type User = {
|
|
151
123
|
name: string;
|
|
152
124
|
surname: string;
|
|
153
125
|
|
|
154
126
|
luckyNumber?: number;
|
|
155
|
-
}
|
|
127
|
+
};
|
|
156
128
|
|
|
157
|
-
|
|
129
|
+
type Admin = {
|
|
158
130
|
name: string;
|
|
159
131
|
surname?: string;
|
|
160
|
-
}
|
|
132
|
+
};
|
|
161
133
|
|
|
162
134
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
163
135
|
//=> true
|
|
@@ -190,12 +162,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
190
162
|
```
|
|
191
163
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
192
164
|
|
|
193
|
-
|
|
165
|
+
type User = {
|
|
194
166
|
name: string;
|
|
195
167
|
surname: string;
|
|
196
168
|
|
|
197
169
|
luckyNumber?: number;
|
|
198
|
-
}
|
|
170
|
+
};
|
|
199
171
|
|
|
200
172
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
201
173
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -203,12 +175,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
203
175
|
};
|
|
204
176
|
|
|
205
177
|
const update1: UpdateOperation<User> = {
|
|
206
|
-
name: 'Alice'
|
|
178
|
+
name: 'Alice',
|
|
207
179
|
};
|
|
208
180
|
|
|
209
181
|
const update2: UpdateOperation<User> = {
|
|
210
182
|
name: 'Bob',
|
|
211
|
-
luckyNumber: REMOVE_FIELD
|
|
183
|
+
luckyNumber: REMOVE_FIELD,
|
|
212
184
|
};
|
|
213
185
|
```
|
|
214
186
|
|
|
@@ -228,17 +200,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
228
200
|
```
|
|
229
201
|
import type {RequiredKeysOf} from 'type-fest';
|
|
230
202
|
|
|
231
|
-
declare function createValidation<
|
|
203
|
+
declare function createValidation<
|
|
204
|
+
Entity extends object,
|
|
205
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
206
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
232
207
|
|
|
233
|
-
|
|
208
|
+
type User = {
|
|
234
209
|
name: string;
|
|
235
210
|
surname: string;
|
|
236
|
-
|
|
237
211
|
luckyNumber?: number;
|
|
238
|
-
}
|
|
212
|
+
};
|
|
239
213
|
|
|
240
214
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
241
215
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
216
|
+
|
|
217
|
+
// @ts-expect-error
|
|
218
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
219
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
242
220
|
```
|
|
243
221
|
|
|
244
222
|
@category Utilities
|
|
@@ -260,29 +238,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
260
238
|
```
|
|
261
239
|
import type {IsNever, And} from 'type-fest';
|
|
262
240
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
And<
|
|
266
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
267
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
268
|
-
>;
|
|
269
|
-
|
|
270
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
271
|
-
AreStringsEqual<I, O> extends true
|
|
272
|
-
? never
|
|
273
|
-
: void;
|
|
274
|
-
|
|
275
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
276
|
-
if (input === output) {
|
|
277
|
-
process.exit(0);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
241
|
+
type A = IsNever<never>;
|
|
242
|
+
//=> true
|
|
280
243
|
|
|
281
|
-
|
|
282
|
-
//=>
|
|
244
|
+
type B = IsNever<any>;
|
|
245
|
+
//=> false
|
|
283
246
|
|
|
284
|
-
|
|
285
|
-
//=>
|
|
247
|
+
type C = IsNever<unknown>;
|
|
248
|
+
//=> false
|
|
249
|
+
|
|
250
|
+
type D = IsNever<never[]>;
|
|
251
|
+
//=> false
|
|
252
|
+
|
|
253
|
+
type E = IsNever<object>;
|
|
254
|
+
//=> false
|
|
255
|
+
|
|
256
|
+
type F = IsNever<string>;
|
|
257
|
+
//=> false
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
@example
|
|
261
|
+
```
|
|
262
|
+
import type {IsNever} from 'type-fest';
|
|
263
|
+
|
|
264
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
265
|
+
|
|
266
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
267
|
+
type A = IsTrue<never>;
|
|
268
|
+
// ^? type A = never
|
|
269
|
+
|
|
270
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
271
|
+
type IsTrueFixed<T> =
|
|
272
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
273
|
+
|
|
274
|
+
type B = IsTrueFixed<never>;
|
|
275
|
+
// ^? type B = false
|
|
286
276
|
```
|
|
287
277
|
|
|
288
278
|
@category Type Guard
|
|
@@ -303,7 +293,7 @@ Note:
|
|
|
303
293
|
|
|
304
294
|
@example
|
|
305
295
|
```
|
|
306
|
-
import {If} from 'type-fest';
|
|
296
|
+
import type {If} from 'type-fest';
|
|
307
297
|
|
|
308
298
|
type A = If<true, 'yes', 'no'>;
|
|
309
299
|
//=> 'yes'
|
|
@@ -323,7 +313,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
323
313
|
|
|
324
314
|
@example
|
|
325
315
|
```
|
|
326
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
316
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
327
317
|
|
|
328
318
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
329
319
|
//=> 'not any'
|
|
@@ -334,7 +324,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
334
324
|
|
|
335
325
|
@example
|
|
336
326
|
```
|
|
337
|
-
import {If, IsEqual} from 'type-fest';
|
|
327
|
+
import type {If, IsEqual} from 'type-fest';
|
|
338
328
|
|
|
339
329
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
340
330
|
|
|
@@ -345,6 +335,41 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
|
345
335
|
//=> 'not equal'
|
|
346
336
|
```
|
|
347
337
|
|
|
338
|
+
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
339
|
+
|
|
340
|
+
@example
|
|
341
|
+
```
|
|
342
|
+
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
343
|
+
|
|
344
|
+
type HundredZeroes = StringRepeat<'0', 100>;
|
|
345
|
+
|
|
346
|
+
// The following implementation is not tail recursive
|
|
347
|
+
type Includes<S extends string, Char extends string> =
|
|
348
|
+
S extends `${infer First}${infer Rest}`
|
|
349
|
+
? If<IsEqual<First, Char>,
|
|
350
|
+
'found',
|
|
351
|
+
Includes<Rest, Char>>
|
|
352
|
+
: 'not found';
|
|
353
|
+
|
|
354
|
+
// Hence, instantiations with long strings will fail
|
|
355
|
+
// @ts-expect-error
|
|
356
|
+
type Fails = Includes<HundredZeroes, '1'>;
|
|
357
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
358
|
+
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
359
|
+
|
|
360
|
+
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
361
|
+
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
362
|
+
S extends `${infer First}${infer Rest}`
|
|
363
|
+
? IsEqual<First, Char> extends true
|
|
364
|
+
? 'found'
|
|
365
|
+
: IncludesWithoutIf<Rest, Char>
|
|
366
|
+
: 'not found';
|
|
367
|
+
|
|
368
|
+
// Now, instantiations with long strings will work
|
|
369
|
+
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
370
|
+
//=> 'not found'
|
|
371
|
+
```
|
|
372
|
+
|
|
348
373
|
@category Type Guard
|
|
349
374
|
@category Utilities
|
|
350
375
|
*/
|
|
@@ -430,16 +455,17 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
430
455
|
const someType: SomeType = literal;
|
|
431
456
|
const someInterface: SomeInterface = literal;
|
|
432
457
|
|
|
433
|
-
function fn(object: Record<string, unknown>): void
|
|
458
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
434
459
|
|
|
435
460
|
fn(literal); // Good: literal object type is sealed
|
|
436
461
|
fn(someType); // Good: type is sealed
|
|
462
|
+
// @ts-expect-error
|
|
437
463
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
438
464
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
439
465
|
```
|
|
440
466
|
|
|
441
467
|
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
442
|
-
@see SimplifyDeep
|
|
468
|
+
@see {@link SimplifyDeep}
|
|
443
469
|
@category Object
|
|
444
470
|
*/
|
|
445
471
|
type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
|
|
@@ -471,7 +497,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
471
497
|
@category Type Guard
|
|
472
498
|
@category Utilities
|
|
473
499
|
*/
|
|
474
|
-
type IsEqual<A, B> = [A
|
|
500
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
475
501
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
476
502
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
477
503
|
//#endregion
|
|
@@ -493,6 +519,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
493
519
|
```
|
|
494
520
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
495
521
|
|
|
522
|
+
// @ts-expect-error
|
|
496
523
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
497
524
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
498
525
|
```
|
|
@@ -506,16 +533,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
506
533
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
507
534
|
|
|
508
535
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
509
|
-
?
|
|
510
|
-
:
|
|
536
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
537
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
511
538
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
512
539
|
```
|
|
513
540
|
|
|
514
541
|
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
515
542
|
|
|
516
543
|
```
|
|
517
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
518
|
-
|
|
519
544
|
type OmitIndexSignature<ObjectType> = {
|
|
520
545
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
521
546
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -525,14 +550,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
525
550
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
526
551
|
|
|
527
552
|
```
|
|
528
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
529
|
-
|
|
530
553
|
type OmitIndexSignature<ObjectType> = {
|
|
531
554
|
[KeyType in keyof ObjectType
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
555
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
556
|
+
as {} extends Record<KeyType, unknown>
|
|
557
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
558
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
536
559
|
]: ObjectType[KeyType];
|
|
537
560
|
};
|
|
538
561
|
```
|
|
@@ -543,27 +566,27 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
543
566
|
```
|
|
544
567
|
import type {OmitIndexSignature} from 'type-fest';
|
|
545
568
|
|
|
546
|
-
|
|
569
|
+
type Example = {
|
|
547
570
|
// These index signatures will be removed.
|
|
548
|
-
[x: string]: any
|
|
549
|
-
[x: number]: any
|
|
550
|
-
[x: symbol]: any
|
|
551
|
-
[x: `head-${string}`]: string
|
|
552
|
-
[x: `${string}-tail`]: string
|
|
553
|
-
[x: `head-${string}-tail`]: string
|
|
554
|
-
[x: `${bigint}`]: string
|
|
555
|
-
[x: `embedded-${number}`]: string
|
|
571
|
+
[x: string]: any;
|
|
572
|
+
[x: number]: any;
|
|
573
|
+
[x: symbol]: any;
|
|
574
|
+
[x: `head-${string}`]: string;
|
|
575
|
+
[x: `${string}-tail`]: string;
|
|
576
|
+
[x: `head-${string}-tail`]: string;
|
|
577
|
+
[x: `${bigint}`]: string;
|
|
578
|
+
[x: `embedded-${number}`]: string;
|
|
556
579
|
|
|
557
580
|
// These explicitly defined keys will remain.
|
|
558
581
|
foo: 'bar';
|
|
559
582
|
qux?: 'baz';
|
|
560
|
-
}
|
|
583
|
+
};
|
|
561
584
|
|
|
562
585
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
563
586
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
564
587
|
```
|
|
565
588
|
|
|
566
|
-
@see PickIndexSignature
|
|
589
|
+
@see {@link PickIndexSignature}
|
|
567
590
|
@category Object
|
|
568
591
|
*/
|
|
569
592
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
@@ -611,7 +634,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
611
634
|
// }
|
|
612
635
|
```
|
|
613
636
|
|
|
614
|
-
@see OmitIndexSignature
|
|
637
|
+
@see {@link OmitIndexSignature}
|
|
615
638
|
@category Object
|
|
616
639
|
*/
|
|
617
640
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
@@ -627,12 +650,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
627
650
|
```
|
|
628
651
|
import type {Merge} from 'type-fest';
|
|
629
652
|
|
|
630
|
-
|
|
653
|
+
type Foo = {
|
|
631
654
|
[x: string]: unknown;
|
|
632
655
|
[x: number]: unknown;
|
|
633
656
|
foo: string;
|
|
634
657
|
bar: symbol;
|
|
635
|
-
}
|
|
658
|
+
};
|
|
636
659
|
|
|
637
660
|
type Bar = {
|
|
638
661
|
[x: number]: number;
|
|
@@ -811,12 +834,14 @@ type Foo = {
|
|
|
811
834
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
812
835
|
//=> {b: string}
|
|
813
836
|
|
|
837
|
+
// @ts-expect-error
|
|
814
838
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
815
839
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
816
840
|
|
|
817
841
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
818
842
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
819
843
|
|
|
844
|
+
// @ts-expect-error
|
|
820
845
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
821
846
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
822
847
|
|
|
@@ -833,12 +858,12 @@ type UserData = {
|
|
|
833
858
|
|
|
834
859
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
835
860
|
type PostPayload = Omit<UserData, 'email'>;
|
|
836
|
-
//=>
|
|
861
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
837
862
|
|
|
838
863
|
// In situations like this, `Except` works better.
|
|
839
864
|
// It simply removes the `email` key while preserving all the other keys.
|
|
840
|
-
type
|
|
841
|
-
//=>
|
|
865
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
866
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
842
867
|
```
|
|
843
868
|
|
|
844
869
|
@category Object
|
|
@@ -860,7 +885,7 @@ type Foo = {
|
|
|
860
885
|
a?: number;
|
|
861
886
|
b: string;
|
|
862
887
|
c?: boolean;
|
|
863
|
-
}
|
|
888
|
+
};
|
|
864
889
|
|
|
865
890
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
866
891
|
// type SomeRequired = {
|
|
@@ -914,7 +939,7 @@ type Foo = {
|
|
|
914
939
|
a: number | null;
|
|
915
940
|
b: string | undefined;
|
|
916
941
|
c?: boolean | null;
|
|
917
|
-
}
|
|
942
|
+
};
|
|
918
943
|
|
|
919
944
|
type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
|
|
920
945
|
// type SomeNonNullable = {
|
|
@@ -1117,7 +1142,7 @@ interface RuleGroupType<R$1 extends RuleType = RuleType, C extends string = stri
|
|
|
1117
1142
|
/**
|
|
1118
1143
|
* The type of the `rules` array in a {@link RuleGroupType}.
|
|
1119
1144
|
*/
|
|
1120
|
-
type RuleGroupArray<RG
|
|
1145
|
+
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R$1 extends RuleType = RuleType> = (R$1 | RG)[];
|
|
1121
1146
|
//#endregion
|
|
1122
1147
|
//#region ../core/src/types/ruleGroupsIC.utils.d.ts
|
|
1123
1148
|
type MAXIMUM_ALLOWED_BOUNDARY = 80;
|
|
@@ -1143,7 +1168,7 @@ type RuleGroupTypeAny<R$1 extends RuleType = RuleType, C extends string = string
|
|
|
1143
1168
|
/**
|
|
1144
1169
|
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
|
|
1145
1170
|
*/
|
|
1146
|
-
type RuleGroupICArray<RG
|
|
1171
|
+
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R$1 extends RuleType = RuleType, C extends string = string> = [R$1 | RG] | [R$1 | RG, ...MappedTuple<[C, R$1 | RG]>] | ((R$1 | RG)[] & {
|
|
1147
1172
|
length: 0;
|
|
1148
1173
|
});
|
|
1149
1174
|
/**
|
|
@@ -1153,7 +1178,7 @@ type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
|
|
|
1153
1178
|
/**
|
|
1154
1179
|
* Converts a narrowed rule group type to its most generic form.
|
|
1155
1180
|
*/
|
|
1156
|
-
type GenericizeRuleGroupType<RG
|
|
1181
|
+
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1157
1182
|
//#endregion
|
|
1158
1183
|
//#region ../core/src/types/validation.d.ts
|
|
1159
1184
|
/**
|
|
@@ -1491,9 +1516,13 @@ interface Classnames {
|
|
|
1491
1516
|
*/
|
|
1492
1517
|
branches: Classname;
|
|
1493
1518
|
/**
|
|
1494
|
-
* Classname(s) rules that render a subquery.
|
|
1519
|
+
* Classname(s) applied to rules that render a subquery.
|
|
1495
1520
|
*/
|
|
1496
1521
|
hasSubQuery: Classname;
|
|
1522
|
+
/**
|
|
1523
|
+
* Classname(s) applied to async components in their "loading" state.
|
|
1524
|
+
*/
|
|
1525
|
+
loading: Classname;
|
|
1497
1526
|
}
|
|
1498
1527
|
/**
|
|
1499
1528
|
* Placeholder strings for option lists.
|
|
@@ -2403,15 +2432,15 @@ type QueryBuilderContextProvider<ExtraProps extends object = Record<string, any>
|
|
|
2403
2432
|
*
|
|
2404
2433
|
* @group Props
|
|
2405
2434
|
*/
|
|
2406
|
-
type QueryBuilderProps<RG
|
|
2435
|
+
type QueryBuilderProps<RG extends RuleGroupTypeAny, F extends FullField, O extends FullOperator, C extends FullCombinator> = RG extends RuleGroupType<infer R> | RuleGroupTypeIC<infer R> ? QueryBuilderContextProps<F, GetOptionIdentifierType<O>> & {
|
|
2407
2436
|
/**
|
|
2408
2437
|
* Initial query object for uncontrolled components.
|
|
2409
2438
|
*/
|
|
2410
|
-
defaultQuery?: RG
|
|
2439
|
+
defaultQuery?: RG;
|
|
2411
2440
|
/**
|
|
2412
2441
|
* Query object for controlled components.
|
|
2413
2442
|
*/
|
|
2414
|
-
query?: RG
|
|
2443
|
+
query?: RG;
|
|
2415
2444
|
/**
|
|
2416
2445
|
* List of valid {@link FullField}s.
|
|
2417
2446
|
*
|
|
@@ -2563,7 +2592,7 @@ type QueryBuilderProps<RG$1 extends RuleGroupTypeAny, F extends FullField, O ext
|
|
|
2563
2592
|
*/
|
|
2564
2593
|
getSubQueryBuilderProps?(field: GetOptionIdentifierType<F>, misc: {
|
|
2565
2594
|
fieldData: F;
|
|
2566
|
-
}): QueryBuilderProps<GenericizeRuleGroupType<RG
|
|
2595
|
+
}): QueryBuilderProps<GenericizeRuleGroupType<RG>, FullOption, FullOption, FullOption>;
|
|
2567
2596
|
/**
|
|
2568
2597
|
* The return value of this function will be used to apply classnames to the
|
|
2569
2598
|
* outer `<div>` of the given {@link Rule}.
|
|
@@ -2575,56 +2604,56 @@ type QueryBuilderProps<RG$1 extends RuleGroupTypeAny, F extends FullField, O ext
|
|
|
2575
2604
|
* The return value of this function will be used to apply classnames to the
|
|
2576
2605
|
* outer `<div>` of the given {@link RuleGroup}.
|
|
2577
2606
|
*/
|
|
2578
|
-
getRuleGroupClassname?(ruleGroup: RG
|
|
2607
|
+
getRuleGroupClassname?(ruleGroup: RG): Classname;
|
|
2579
2608
|
/**
|
|
2580
2609
|
* This callback is invoked before a new rule is added. The function should either manipulate
|
|
2581
2610
|
* the rule and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2582
2611
|
* or return `false` to cancel the addition of the rule.
|
|
2583
2612
|
*/
|
|
2584
|
-
onAddRule?(rule: R, parentPath: Path, query: RG
|
|
2613
|
+
onAddRule?(rule: R, parentPath: Path, query: RG, context?: any): RuleType | boolean;
|
|
2585
2614
|
/**
|
|
2586
2615
|
* This callback is invoked before a new group is added. The function should either manipulate
|
|
2587
2616
|
* the group and return the new object, return `true` to allow the addition to proceed as normal,
|
|
2588
2617
|
* or return `false` to cancel the addition of the group.
|
|
2589
2618
|
*/
|
|
2590
|
-
onAddGroup?(ruleGroup: RG
|
|
2619
|
+
onAddGroup?(ruleGroup: RG, parentPath: Path, query: RG, context?: any): RG | boolean;
|
|
2591
2620
|
/**
|
|
2592
2621
|
* This callback is invoked before a rule is moved or shifted. The function should return
|
|
2593
2622
|
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2594
2623
|
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2595
2624
|
* query state.
|
|
2596
2625
|
*/
|
|
2597
|
-
onMoveRule?(rule: R, fromPath: Path, toPath: Path | "up" | "down", query: RG
|
|
2626
|
+
onMoveRule?(rule: R, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2598
2627
|
/**
|
|
2599
2628
|
* This callback is invoked before a group is moved or shifted. The function should return
|
|
2600
2629
|
* `true` to allow the move/shift to proceed as normal, `false` to cancel the move/shift, or
|
|
2601
2630
|
* a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2602
2631
|
* query state.
|
|
2603
2632
|
*/
|
|
2604
|
-
onMoveGroup?(ruleGroup: RG
|
|
2633
|
+
onMoveGroup?(ruleGroup: RG, fromPath: Path, toPath: Path | "up" | "down", query: RG, nextQuery: RG, options: MoveOptions, context?: any): RG | boolean;
|
|
2605
2634
|
/**
|
|
2606
2635
|
* This callback is invoked before a rule is grouped with another object. The function should
|
|
2607
2636
|
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2608
2637
|
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2609
2638
|
* query state.
|
|
2610
2639
|
*/
|
|
2611
|
-
onGroupRule?(rule: R, fromPath: Path, toPath: Path, query: RG
|
|
2640
|
+
onGroupRule?(rule: R, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2612
2641
|
/**
|
|
2613
2642
|
* This callback is invoked before a group is grouped with another object. The function should
|
|
2614
2643
|
* return `true` to allow the grouping to proceed as normal, `false` to cancel the grouping,
|
|
2615
2644
|
* or a new query object (presumably based on `query` or `nextQuery`) which will become the new
|
|
2616
2645
|
* query state.
|
|
2617
2646
|
*/
|
|
2618
|
-
onGroupGroup?(ruleGroup: RG
|
|
2647
|
+
onGroupGroup?(ruleGroup: RG, fromPath: Path, toPath: Path, query: RG, nextQuery: RG, options: GroupOptions, context?: any): RG | boolean;
|
|
2619
2648
|
/**
|
|
2620
2649
|
* This callback is invoked before a rule or group is removed. The function should return
|
|
2621
2650
|
* `true` if the rule or group should be removed or `false` if it should not be removed.
|
|
2622
2651
|
*/
|
|
2623
|
-
onRemove?(ruleOrGroup: R | RG
|
|
2652
|
+
onRemove?(ruleOrGroup: R | RG, path: Path, query: RG, context?: any): boolean;
|
|
2624
2653
|
/**
|
|
2625
2654
|
* This callback is invoked anytime the query state is updated.
|
|
2626
2655
|
*/
|
|
2627
|
-
onQueryChange?(query: RG
|
|
2656
|
+
onQueryChange?(query: RG): void;
|
|
2628
2657
|
/**
|
|
2629
2658
|
* Each log object will be passed to this function when `debugMode` is `true`.
|
|
2630
2659
|
*
|
|
@@ -2697,6 +2726,17 @@ type QueryBuilderProps<RG$1 extends RuleGroupTypeAny, F extends FullField, O ext
|
|
|
2697
2726
|
context?: any;
|
|
2698
2727
|
} : never;
|
|
2699
2728
|
//#endregion
|
|
2729
|
+
//#region ../react-querybuilder/src/redux/getRqbStore.d.ts
|
|
2730
|
+
declare global {
|
|
2731
|
+
var __RQB_DEVTOOLS__: boolean | undefined;
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* Gets the singleton React Query Builder store instance.
|
|
2735
|
+
* DevTools are enabled if either:
|
|
2736
|
+
* - globalThis.__RQB_DEVTOOLS__ is truthy
|
|
2737
|
+
* - window.__RQB_DEVTOOLS__ is truthy
|
|
2738
|
+
*/
|
|
2739
|
+
//#endregion
|
|
2700
2740
|
//#region src/BootstrapNotToggle.d.ts
|
|
2701
2741
|
/**
|
|
2702
2742
|
* @group Components
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`react-querybuilder`);
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`react-querybuilder`);const u=({className:e,handleOnChange:t,title:n,label:r,checked:i,disabled:a})=>{let o=(0,c.useId)();return c.createElement(`div`,{className:`form-check-inline form-switch ${e}`},c.createElement(`input`,{id:o,className:`form-check-input`,type:`checkbox`,onChange:e=>t(e.target.checked),checked:!!i,disabled:a}),c.createElement(`label`,{title:n,htmlFor:o,className:`form-check-label`},r))},d=e=>{let t=c.useId();return c.createElement(`div`,{className:`form-check form-check-inline`},c.createElement(`input`,{className:`form-check-input`,type:`radio`,id:t,value:e.name,checked:e.checked,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.value)}),c.createElement(`label`,{className:`form-check-label`,htmlFor:t},e.label))},f=e=>{let{valueListItemClassName:t}=(0,l.useValueEditor)(e);if(e.operator===`null`||e.operator===`notNull`)return null;if((e.operator===`between`||e.operator===`notBetween`)&&(e.type===`select`||e.type===`text`)){let n=e.type===`text`?`form-control form-control-sm`:`form-select form-select-sm`;return c.createElement(l.ValueEditor,{...e,skipHook:!0,schema:{...e.schema,classNames:{...e.schema.classNames,valueListItem:`${t} ${n}`}}})}switch(e.type){case`select`:case`multiselect`:return c.createElement(l.ValueEditor,{...e,skipHook:!0,className:`${e.className} form-select form-select-sm`});case`switch`:return c.createElement(`span`,{className:`${e.className} custom-control custom-switch`},c.createElement(`input`,{type:`checkbox`,className:`form-check-input custom-control-input`,title:e.title,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.checked),checked:!!e.value}));case`checkbox`:return c.createElement(l.ValueEditor,{...e,skipHook:!0,className:`${e.className} form-check-input`});case`radio`:return c.createElement(`span`,{title:e.title,className:l.standardClassnames.value},e.values?.map(t=>c.createElement(d,{key:t.name,name:t.name,disabled:e.disabled,checked:e.value===t.name,handleOnChange:e.handleOnChange,label:t.label})))}return c.createElement(l.ValueEditor,{...e,skipHook:!0,className:`${e.className} form-control form-control-sm`})},p={notToggle:u,valueEditor:f},m={actionElement:`btn btn-sm`,addGroup:`btn-secondary`,addRule:`btn-primary`,cloneGroup:`btn-secondary`,cloneRule:`btn-secondary`,lockGroup:`btn-secondary`,lockRule:`btn-secondary`,removeGroup:`btn-danger`,removeRule:`btn-danger`,valueSelector:`form-select form-select-sm`},h={removeGroup:{label:c.createElement(`i`,{className:`bi bi-x`})},removeRule:{label:c.createElement(`i`,{className:`bi bi-x`})},cloneRule:{label:c.createElement(`i`,{className:`bi bi-copy`})},cloneRuleGroup:{label:c.createElement(`i`,{className:`bi bi-copy`})},dragHandle:{label:c.createElement(`i`,{className:`bi bi-grip-vertical`})},lockGroup:{label:c.createElement(`i`,{className:`bi bi-unlock`})},lockRule:{label:c.createElement(`i`,{className:`bi bi-unlock`})},lockGroupDisabled:{label:c.createElement(`i`,{className:`bi bi-lock`})},lockRuleDisabled:{label:c.createElement(`i`,{className:`bi bi-lock`})},shiftActionUp:{label:c.createElement(`i`,{className:`bi bi-chevron-compact-up`})},shiftActionDown:{label:c.createElement(`i`,{className:`bi bi-chevron-compact-down`})}},g=(0,l.getCompatContextProvider)({controlClassnames:m,controlElements:p,translations:h});exports.BootstrapNotToggle=u,exports.BootstrapValueEditor=f,exports.QueryBuilderBootstrap=g,exports.bootstrapControlClassnames=m,exports.bootstrapControlElements=p,exports.bootstrapTranslations=h;
|
|
2
2
|
//# sourceMappingURL=react-querybuilder_bootstrap.cjs.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-querybuilder_bootstrap.cjs.production.js","names":["React","ValueEditor","standardClassnames","bootstrapControlElements: ControlElementsProp<FullField, string>","bootstrapControlClassnames: Partial<Classnames>","bootstrapTranslations: Partial<Translations>","QueryBuilderBootstrap: QueryBuilderContextProvider"],"sources":["../../src/BootstrapNotToggle.tsx","../../src/BootstrapValueEditor.tsx","../../src/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useId } from 'react';\nimport type { NotToggleProps } from 'react-querybuilder';\n\n/**\n * @group Components\n */\nexport const BootstrapNotToggle = ({\n className,\n handleOnChange,\n title,\n label,\n checked,\n disabled,\n}: NotToggleProps): React.JSX.Element => {\n const id = useId();\n\n return (\n <div className={`form-check-inline form-switch ${className}`}>\n <input\n id={id}\n className=\"form-check-input\"\n type=\"checkbox\"\n onChange={e => handleOnChange(e.target.checked)}\n checked={!!checked}\n disabled={disabled}\n />\n <label title={title} htmlFor={id} className=\"form-check-label\">\n {label}\n </label>\n </div>\n );\n};\n","import * as React from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\nimport { standardClassnames, useValueEditor, ValueEditor } from 'react-querybuilder';\n\n// Extracted from callback so we can use `useId`\nconst RadioButton = (props: {\n name: string;\n disabled?: boolean;\n checked: boolean;\n handleOnChange: (v: string) => void;\n label: string;\n}) => {\n const id = React.useId();\n return (\n <div className=\"form-check form-check-inline\">\n <input\n className=\"form-check-input\"\n type=\"radio\"\n id={id}\n value={props.name}\n checked={props.checked}\n disabled={props.disabled}\n onChange={e => props.handleOnChange(e.target.value)}\n />\n <label className=\"form-check-label\" htmlFor={id}>\n {props.label}\n </label>\n </div>\n );\n};\n\n/**\n * @group Components\n */\nexport const BootstrapValueEditor = (props: ValueEditorProps): React.JSX.Element | null => {\n const { valueListItemClassName } = useValueEditor(props);\n\n if (props.operator === 'null' || props.operator === 'notNull') {\n return null;\n }\n\n if (\n (props.operator === 'between' || props.operator === 'notBetween') &&\n (props.type === 'select' || props.type === 'text')\n ) {\n const listItemClasses =\n props.type === 'text' ? 'form-control form-control-sm' : 'form-select form-select-sm';\n return (\n <ValueEditor\n {...props}\n skipHook\n schema={{\n ...props.schema,\n classNames: {\n ...props.schema.classNames,\n valueListItem: `${valueListItemClassName} ${listItemClasses}`,\n },\n }}\n />\n );\n }\n\n switch (props.type) {\n case 'select':\n case 'multiselect':\n return (\n <ValueEditor\n {...props}\n skipHook\n className={`${props.className} form-select form-select-sm`}\n />\n );\n\n case 'switch':\n return (\n <span className={`${props.className} custom-control custom-switch`}>\n <input\n type=\"checkbox\"\n className=\"form-check-input custom-control-input\"\n title={props.title}\n disabled={props.disabled}\n onChange={e => props.handleOnChange(e.target.checked)}\n checked={!!props.value}\n />\n </span>\n );\n\n case 'checkbox':\n return <ValueEditor {...props} skipHook className={`${props.className} form-check-input`} />;\n\n case 'radio':\n return (\n <span title={props.title} className={standardClassnames.value}>\n {props.values?.map(v => (\n <RadioButton\n key={v.name}\n name={v.name}\n disabled={props.disabled}\n checked={props.value === v.name}\n handleOnChange={props.handleOnChange}\n label={v.label}\n />\n ))}\n </span>\n );\n }\n\n return (\n <ValueEditor\n {...props}\n skipHook\n className={`${props.className} form-control form-control-sm`}\n />\n );\n};\n","import * as React from 'react';\nimport type {\n Classnames,\n ControlElementsProp,\n FullField,\n QueryBuilderContextProvider,\n Translations,\n} from 'react-querybuilder';\nimport { getCompatContextProvider } from 'react-querybuilder';\nimport { BootstrapNotToggle } from './BootstrapNotToggle';\nimport { BootstrapValueEditor } from './BootstrapValueEditor';\n\nexport * from './BootstrapNotToggle';\nexport * from './BootstrapValueEditor';\n\n/**\n * @group Props\n */\nexport const bootstrapControlElements: ControlElementsProp<FullField, string> = {\n notToggle: BootstrapNotToggle,\n valueEditor: BootstrapValueEditor,\n};\n\n/**\n * @group Props\n */\nexport const bootstrapControlClassnames: Partial<Classnames> = {\n actionElement: 'btn btn-sm',\n addGroup: 'btn-secondary',\n addRule: 'btn-primary',\n cloneGroup: 'btn-secondary',\n cloneRule: 'btn-secondary',\n lockGroup: 'btn-secondary',\n lockRule: 'btn-secondary',\n removeGroup: 'btn-danger',\n removeRule: 'btn-danger',\n // BootstrapValueEditor adds its own classnames\n // value: '',\n valueSelector: 'form-select form-select-sm',\n};\n\n/**\n * @group Props\n */\nexport const bootstrapTranslations: Partial<Translations> = {\n removeGroup: { label: <i className=\"bi bi-x\" /> },\n removeRule: { label: <i className=\"bi bi-x\" /> },\n cloneRule: { label: <i className=\"bi bi-copy\" /> },\n cloneRuleGroup: { label: <i className=\"bi bi-copy\" /> },\n dragHandle: { label: <i className=\"bi bi-grip-vertical\" /> },\n lockGroup: { label: <i className=\"bi bi-unlock\" /> },\n lockRule: { label: <i className=\"bi bi-unlock\" /> },\n lockGroupDisabled: { label: <i className=\"bi bi-lock\" /> },\n lockRuleDisabled: { label: <i className=\"bi bi-lock\" /> },\n shiftActionUp: { label: <i className=\"bi bi-chevron-compact-up\" /> },\n shiftActionDown: { label: <i className=\"bi bi-chevron-compact-down\" /> },\n};\n\n/**\n * @group Components\n */\nexport const QueryBuilderBootstrap: QueryBuilderContextProvider = getCompatContextProvider({\n controlClassnames: bootstrapControlClassnames,\n controlElements: bootstrapControlElements,\n translations: bootstrapTranslations,\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-querybuilder_bootstrap.cjs.production.js","names":["React","ValueEditor","standardClassnames","bootstrapControlElements: ControlElementsProp<FullField, string>","bootstrapControlClassnames: Partial<Classnames>","bootstrapTranslations: Partial<Translations>","QueryBuilderBootstrap: QueryBuilderContextProvider"],"sources":["../../src/BootstrapNotToggle.tsx","../../src/BootstrapValueEditor.tsx","../../src/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useId } from 'react';\nimport type { NotToggleProps } from 'react-querybuilder';\n\n/**\n * @group Components\n */\nexport const BootstrapNotToggle = ({\n className,\n handleOnChange,\n title,\n label,\n checked,\n disabled,\n}: NotToggleProps): React.JSX.Element => {\n const id = useId();\n\n return (\n <div className={`form-check-inline form-switch ${className}`}>\n <input\n id={id}\n className=\"form-check-input\"\n type=\"checkbox\"\n onChange={e => handleOnChange(e.target.checked)}\n checked={!!checked}\n disabled={disabled}\n />\n <label title={title} htmlFor={id} className=\"form-check-label\">\n {label}\n </label>\n </div>\n );\n};\n","import * as React from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\nimport { standardClassnames, useValueEditor, ValueEditor } from 'react-querybuilder';\n\n// Extracted from callback so we can use `useId`\nconst RadioButton = (props: {\n name: string;\n disabled?: boolean;\n checked: boolean;\n handleOnChange: (v: string) => void;\n label: string;\n}) => {\n const id = React.useId();\n return (\n <div className=\"form-check form-check-inline\">\n <input\n className=\"form-check-input\"\n type=\"radio\"\n id={id}\n value={props.name}\n checked={props.checked}\n disabled={props.disabled}\n onChange={e => props.handleOnChange(e.target.value)}\n />\n <label className=\"form-check-label\" htmlFor={id}>\n {props.label}\n </label>\n </div>\n );\n};\n\n/**\n * @group Components\n */\nexport const BootstrapValueEditor = (props: ValueEditorProps): React.JSX.Element | null => {\n const { valueListItemClassName } = useValueEditor(props);\n\n if (props.operator === 'null' || props.operator === 'notNull') {\n return null;\n }\n\n if (\n (props.operator === 'between' || props.operator === 'notBetween') &&\n (props.type === 'select' || props.type === 'text')\n ) {\n const listItemClasses =\n props.type === 'text' ? 'form-control form-control-sm' : 'form-select form-select-sm';\n return (\n <ValueEditor\n {...props}\n skipHook\n schema={{\n ...props.schema,\n classNames: {\n ...props.schema.classNames,\n valueListItem: `${valueListItemClassName} ${listItemClasses}`,\n },\n }}\n />\n );\n }\n\n switch (props.type) {\n case 'select':\n case 'multiselect':\n return (\n <ValueEditor\n {...props}\n skipHook\n className={`${props.className} form-select form-select-sm`}\n />\n );\n\n case 'switch':\n return (\n <span className={`${props.className} custom-control custom-switch`}>\n <input\n type=\"checkbox\"\n className=\"form-check-input custom-control-input\"\n title={props.title}\n disabled={props.disabled}\n onChange={e => props.handleOnChange(e.target.checked)}\n checked={!!props.value}\n />\n </span>\n );\n\n case 'checkbox':\n return <ValueEditor {...props} skipHook className={`${props.className} form-check-input`} />;\n\n case 'radio':\n return (\n <span title={props.title} className={standardClassnames.value}>\n {props.values?.map(v => (\n <RadioButton\n key={v.name}\n name={v.name}\n disabled={props.disabled}\n checked={props.value === v.name}\n handleOnChange={props.handleOnChange}\n label={v.label}\n />\n ))}\n </span>\n );\n }\n\n return (\n <ValueEditor\n {...props}\n skipHook\n className={`${props.className} form-control form-control-sm`}\n />\n );\n};\n","import * as React from 'react';\nimport type {\n Classnames,\n ControlElementsProp,\n FullField,\n QueryBuilderContextProvider,\n Translations,\n} from 'react-querybuilder';\nimport { getCompatContextProvider } from 'react-querybuilder';\nimport { BootstrapNotToggle } from './BootstrapNotToggle';\nimport { BootstrapValueEditor } from './BootstrapValueEditor';\n\nexport * from './BootstrapNotToggle';\nexport * from './BootstrapValueEditor';\n\n/**\n * @group Props\n */\nexport const bootstrapControlElements: ControlElementsProp<FullField, string> = {\n notToggle: BootstrapNotToggle,\n valueEditor: BootstrapValueEditor,\n};\n\n/**\n * @group Props\n */\nexport const bootstrapControlClassnames: Partial<Classnames> = {\n actionElement: 'btn btn-sm',\n addGroup: 'btn-secondary',\n addRule: 'btn-primary',\n cloneGroup: 'btn-secondary',\n cloneRule: 'btn-secondary',\n lockGroup: 'btn-secondary',\n lockRule: 'btn-secondary',\n removeGroup: 'btn-danger',\n removeRule: 'btn-danger',\n // BootstrapValueEditor adds its own classnames\n // value: '',\n valueSelector: 'form-select form-select-sm',\n};\n\n/**\n * @group Props\n */\nexport const bootstrapTranslations: Partial<Translations> = {\n removeGroup: { label: <i className=\"bi bi-x\" /> },\n removeRule: { label: <i className=\"bi bi-x\" /> },\n cloneRule: { label: <i className=\"bi bi-copy\" /> },\n cloneRuleGroup: { label: <i className=\"bi bi-copy\" /> },\n dragHandle: { label: <i className=\"bi bi-grip-vertical\" /> },\n lockGroup: { label: <i className=\"bi bi-unlock\" /> },\n lockRule: { label: <i className=\"bi bi-unlock\" /> },\n lockGroupDisabled: { label: <i className=\"bi bi-lock\" /> },\n lockRuleDisabled: { label: <i className=\"bi bi-lock\" /> },\n shiftActionUp: { label: <i className=\"bi bi-chevron-compact-up\" /> },\n shiftActionDown: { label: <i className=\"bi bi-chevron-compact-down\" /> },\n};\n\n/**\n * @group Components\n */\nexport const QueryBuilderBootstrap: QueryBuilderContextProvider = getCompatContextProvider({\n controlClassnames: bootstrapControlClassnames,\n controlElements: bootstrapControlElements,\n translations: bootstrapTranslations,\n});\n"],"mappings":"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"}
|