@react-querybuilder/core 8.12.0 → 8.14.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/{basic-o1-sYjK6.d.ts → basic-Dxm6jWFu.d.ts} +94 -104
- package/dist/{basic-DbvrfPNz.d.mts → basic-GFsWfi0Z.d.mts} +94 -104
- package/dist/{chunk-BxBTb9qk.js → chunk-U64pC571.js} +13 -11
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +119 -118
- package/dist/cjs/react-querybuilder_core.cjs.development.js +39 -10
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +119 -118
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-Cj4t-LT4.mjs → convertQuery-DAj92cbM.mjs} +3 -3
- package/dist/{convertQuery-Cj4t-LT4.mjs.map → convertQuery-DAj92cbM.mjs.map} +1 -1
- package/dist/{convertQuery-DuY_BJHy.js → convertQuery-DRldbzhZ.js} +4 -4
- package/dist/{convertQuery-DuY_BJHy.js.map → convertQuery-DRldbzhZ.js.map} +1 -1
- package/dist/{export-WDHFbiPz.d.ts → export-6VbkhCrf.d.ts} +2 -2
- package/dist/{export-CCULKoP4.d.mts → export-_wipiqJZ.d.mts} +2 -2
- package/dist/formatQuery.d.mts +2 -2
- package/dist/formatQuery.d.ts +2 -2
- package/dist/formatQuery.js +43 -14
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +42 -13
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-BSWb9Vgd.d.ts → import-D8M7awTx.d.ts} +2 -2
- package/dist/{import-CLyHpgk8.d.mts → import-DRmutNSr.d.mts} +2 -2
- package/dist/{isRuleGroup-Do9KKsmt.js → isRuleGroup-Cjk1Q2mj.js} +2 -2
- package/dist/{isRuleGroup-Do9KKsmt.js.map → isRuleGroup-Cjk1Q2mj.js.map} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs → isRuleGroup-DztIOOKa.mjs} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs.map → isRuleGroup-DztIOOKa.mjs.map} +1 -1
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +9 -9
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +3 -3
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +13 -7
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +2 -3
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +3 -3
- package/dist/parseJsonLogic.d.ts +3 -3
- package/dist/parseJsonLogic.js +4 -4
- package/dist/parseJsonLogic.mjs +4 -4
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +5 -5
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +5 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +9 -9
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +3 -3
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +58 -7
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +3 -3
- package/dist/{prepareQueryObjects-BfnyRV5t.mjs → prepareQueryObjects-BBayjIn2.mjs} +4 -7
- package/dist/prepareQueryObjects-BBayjIn2.mjs.map +1 -0
- package/dist/{prepareQueryObjects-DCtJJrF5.js → prepareQueryObjects-BxWvIPI4.js} +5 -8
- package/dist/prepareQueryObjects-BxWvIPI4.js.map +1 -0
- package/dist/react-querybuilder_core.d.mts +119 -118
- package/dist/react-querybuilder_core.legacy-esm.d.ts +119 -118
- package/dist/react-querybuilder_core.legacy-esm.js +42 -16
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +39 -10
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +119 -118
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/{transformQuery-DvJTAvkh.js → transformQuery-ClBRfnFg.js} +3 -3
- package/dist/{transformQuery-DvJTAvkh.js.map → transformQuery-ClBRfnFg.js.map} +1 -1
- package/dist/{transformQuery-Bq4iyYsE.mjs → transformQuery-DUpbpqjX.mjs} +2 -2
- package/dist/{transformQuery-Bq4iyYsE.mjs.map → transformQuery-DUpbpqjX.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -2
- package/dist/transformQuery.mjs +1 -2
- package/dist/{utils-CoYbYnVo.js → utils-CR1ToTMW.js} +3 -3
- package/dist/{utils-CoYbYnVo.js.map → utils-CR1ToTMW.js.map} +1 -1
- package/dist/{utils-DxH23QtE.mjs → utils-nQU7WCM9.mjs} +2 -2
- package/dist/{utils-DxH23QtE.mjs.map → utils-nQU7WCM9.mjs.map} +1 -1
- package/package.json +14 -13
- package/dist/chunk-DrjzjjTJ.mjs +0 -23
- package/dist/chunk-Dv2ph0Ay.js +0 -23
- package/dist/prepareQueryObjects-BfnyRV5t.mjs.map +0 -1
- package/dist/prepareQueryObjects-DCtJJrF5.js.map +0 -1
|
@@ -26,34 +26,6 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
26
26
|
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
A more applicable example which could make its way into your library code follows.
|
|
30
|
-
|
|
31
|
-
@example
|
|
32
|
-
```
|
|
33
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
34
|
-
|
|
35
|
-
class CommandOne {
|
|
36
|
-
commands: {
|
|
37
|
-
a1: () => undefined,
|
|
38
|
-
b1: () => undefined,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class CommandTwo {
|
|
43
|
-
commands: {
|
|
44
|
-
a2: (argA: string) => undefined,
|
|
45
|
-
b2: (argB: string) => undefined,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
50
|
-
type Union = typeof union;
|
|
51
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
52
|
-
|
|
53
|
-
type Intersection = UnionToIntersection<Union>;
|
|
54
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
29
|
@category Type
|
|
58
30
|
*/
|
|
59
31
|
type UnionToIntersection<Union> = (
|
|
@@ -129,8 +101,8 @@ import type {IsAny} from 'type-fest';
|
|
|
129
101
|
const typedObject = {a: 1, b: 2} as const;
|
|
130
102
|
const anyObject: any = {a: 1, b: 2};
|
|
131
103
|
|
|
132
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
133
|
-
return
|
|
104
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
105
|
+
return object[key];
|
|
134
106
|
}
|
|
135
107
|
|
|
136
108
|
const typedA = get(typedObject, 'a');
|
|
@@ -155,17 +127,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
155
127
|
```
|
|
156
128
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
157
129
|
|
|
158
|
-
|
|
130
|
+
type User = {
|
|
159
131
|
name: string;
|
|
160
132
|
surname: string;
|
|
161
133
|
|
|
162
134
|
luckyNumber?: number;
|
|
163
|
-
}
|
|
135
|
+
};
|
|
164
136
|
|
|
165
|
-
|
|
137
|
+
type Admin = {
|
|
166
138
|
name: string;
|
|
167
139
|
surname?: string;
|
|
168
|
-
}
|
|
140
|
+
};
|
|
169
141
|
|
|
170
142
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
171
143
|
//=> true
|
|
@@ -198,12 +170,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
198
170
|
```
|
|
199
171
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
200
172
|
|
|
201
|
-
|
|
173
|
+
type User = {
|
|
202
174
|
name: string;
|
|
203
175
|
surname: string;
|
|
204
176
|
|
|
205
177
|
luckyNumber?: number;
|
|
206
|
-
}
|
|
178
|
+
};
|
|
207
179
|
|
|
208
180
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
209
181
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -211,12 +183,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
211
183
|
};
|
|
212
184
|
|
|
213
185
|
const update1: UpdateOperation<User> = {
|
|
214
|
-
name: 'Alice'
|
|
186
|
+
name: 'Alice',
|
|
215
187
|
};
|
|
216
188
|
|
|
217
189
|
const update2: UpdateOperation<User> = {
|
|
218
190
|
name: 'Bob',
|
|
219
|
-
luckyNumber: REMOVE_FIELD
|
|
191
|
+
luckyNumber: REMOVE_FIELD,
|
|
220
192
|
};
|
|
221
193
|
```
|
|
222
194
|
|
|
@@ -236,17 +208,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
236
208
|
```
|
|
237
209
|
import type {RequiredKeysOf} from 'type-fest';
|
|
238
210
|
|
|
239
|
-
declare function createValidation<
|
|
211
|
+
declare function createValidation<
|
|
212
|
+
Entity extends object,
|
|
213
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
214
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
240
215
|
|
|
241
|
-
|
|
216
|
+
type User = {
|
|
242
217
|
name: string;
|
|
243
218
|
surname: string;
|
|
244
|
-
|
|
245
219
|
luckyNumber?: number;
|
|
246
|
-
}
|
|
220
|
+
};
|
|
247
221
|
|
|
248
222
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
249
223
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
224
|
+
|
|
225
|
+
// @ts-expect-error
|
|
226
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
227
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
250
228
|
```
|
|
251
229
|
|
|
252
230
|
@category Utilities
|
|
@@ -268,29 +246,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
268
246
|
```
|
|
269
247
|
import type {IsNever, And} from 'type-fest';
|
|
270
248
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
And<
|
|
274
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
275
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
276
|
-
>;
|
|
277
|
-
|
|
278
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
279
|
-
AreStringsEqual<I, O> extends true
|
|
280
|
-
? never
|
|
281
|
-
: void;
|
|
282
|
-
|
|
283
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
284
|
-
if (input === output) {
|
|
285
|
-
process.exit(0);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
249
|
+
type A = IsNever<never>;
|
|
250
|
+
//=> true
|
|
288
251
|
|
|
289
|
-
|
|
290
|
-
//=>
|
|
252
|
+
type B = IsNever<any>;
|
|
253
|
+
//=> false
|
|
254
|
+
|
|
255
|
+
type C = IsNever<unknown>;
|
|
256
|
+
//=> false
|
|
257
|
+
|
|
258
|
+
type D = IsNever<never[]>;
|
|
259
|
+
//=> false
|
|
260
|
+
|
|
261
|
+
type E = IsNever<object>;
|
|
262
|
+
//=> false
|
|
263
|
+
|
|
264
|
+
type F = IsNever<string>;
|
|
265
|
+
//=> false
|
|
266
|
+
```
|
|
291
267
|
|
|
292
|
-
|
|
293
|
-
|
|
268
|
+
@example
|
|
269
|
+
```
|
|
270
|
+
import type {IsNever} from 'type-fest';
|
|
271
|
+
|
|
272
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
273
|
+
|
|
274
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
275
|
+
type A = IsTrue<never>;
|
|
276
|
+
// ^? type A = never
|
|
277
|
+
|
|
278
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
279
|
+
type IsTrueFixed<T> =
|
|
280
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
281
|
+
|
|
282
|
+
type B = IsTrueFixed<never>;
|
|
283
|
+
// ^? type B = false
|
|
294
284
|
```
|
|
295
285
|
|
|
296
286
|
@category Type Guard
|
|
@@ -311,7 +301,7 @@ Note:
|
|
|
311
301
|
|
|
312
302
|
@example
|
|
313
303
|
```
|
|
314
|
-
import {If} from 'type-fest';
|
|
304
|
+
import type {If} from 'type-fest';
|
|
315
305
|
|
|
316
306
|
type A = If<true, 'yes', 'no'>;
|
|
317
307
|
//=> 'yes'
|
|
@@ -331,7 +321,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
331
321
|
|
|
332
322
|
@example
|
|
333
323
|
```
|
|
334
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
324
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
335
325
|
|
|
336
326
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
337
327
|
//=> 'not any'
|
|
@@ -342,7 +332,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
342
332
|
|
|
343
333
|
@example
|
|
344
334
|
```
|
|
345
|
-
import {If, IsEqual} from 'type-fest';
|
|
335
|
+
import type {If, IsEqual} from 'type-fest';
|
|
346
336
|
|
|
347
337
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
348
338
|
|
|
@@ -535,10 +525,11 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
535
525
|
const someType: SomeType = literal;
|
|
536
526
|
const someInterface: SomeInterface = literal;
|
|
537
527
|
|
|
538
|
-
function fn(object: Record<string, unknown>): void
|
|
528
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
539
529
|
|
|
540
530
|
fn(literal); // Good: literal object type is sealed
|
|
541
531
|
fn(someType); // Good: type is sealed
|
|
532
|
+
// @ts-expect-error
|
|
542
533
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
543
534
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
544
535
|
```
|
|
@@ -576,9 +567,9 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
576
567
|
@category Type Guard
|
|
577
568
|
@category Utilities
|
|
578
569
|
*/
|
|
579
|
-
type IsEqual<A
|
|
570
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
580
571
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
581
|
-
type _IsEqual<A
|
|
572
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
582
573
|
//#endregion
|
|
583
574
|
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
584
575
|
/**
|
|
@@ -598,6 +589,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
598
589
|
```
|
|
599
590
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
600
591
|
|
|
592
|
+
// @ts-expect-error
|
|
601
593
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
602
594
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
603
595
|
```
|
|
@@ -611,16 +603,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
611
603
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
612
604
|
|
|
613
605
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
614
|
-
?
|
|
615
|
-
:
|
|
606
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
607
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
616
608
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
617
609
|
```
|
|
618
610
|
|
|
619
611
|
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`...
|
|
620
612
|
|
|
621
613
|
```
|
|
622
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
623
|
-
|
|
624
614
|
type OmitIndexSignature<ObjectType> = {
|
|
625
615
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
626
616
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -630,14 +620,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
630
620
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
631
621
|
|
|
632
622
|
```
|
|
633
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
634
|
-
|
|
635
623
|
type OmitIndexSignature<ObjectType> = {
|
|
636
624
|
[KeyType in keyof ObjectType
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
625
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
626
|
+
as {} extends Record<KeyType, unknown>
|
|
627
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
628
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
641
629
|
]: ObjectType[KeyType];
|
|
642
630
|
};
|
|
643
631
|
```
|
|
@@ -648,21 +636,21 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
648
636
|
```
|
|
649
637
|
import type {OmitIndexSignature} from 'type-fest';
|
|
650
638
|
|
|
651
|
-
|
|
639
|
+
type Example = {
|
|
652
640
|
// These index signatures will be removed.
|
|
653
|
-
[x: string]: any
|
|
654
|
-
[x: number]: any
|
|
655
|
-
[x: symbol]: any
|
|
656
|
-
[x: `head-${string}`]: string
|
|
657
|
-
[x: `${string}-tail`]: string
|
|
658
|
-
[x: `head-${string}-tail`]: string
|
|
659
|
-
[x: `${bigint}`]: string
|
|
660
|
-
[x: `embedded-${number}`]: string
|
|
641
|
+
[x: string]: any;
|
|
642
|
+
[x: number]: any;
|
|
643
|
+
[x: symbol]: any;
|
|
644
|
+
[x: `head-${string}`]: string;
|
|
645
|
+
[x: `${string}-tail`]: string;
|
|
646
|
+
[x: `head-${string}-tail`]: string;
|
|
647
|
+
[x: `${bigint}`]: string;
|
|
648
|
+
[x: `embedded-${number}`]: string;
|
|
661
649
|
|
|
662
650
|
// These explicitly defined keys will remain.
|
|
663
651
|
foo: 'bar';
|
|
664
652
|
qux?: 'baz';
|
|
665
|
-
}
|
|
653
|
+
};
|
|
666
654
|
|
|
667
655
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
668
656
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
@@ -732,12 +720,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
732
720
|
```
|
|
733
721
|
import type {Merge} from 'type-fest';
|
|
734
722
|
|
|
735
|
-
|
|
723
|
+
type Foo = {
|
|
736
724
|
[x: string]: unknown;
|
|
737
725
|
[x: number]: unknown;
|
|
738
726
|
foo: string;
|
|
739
727
|
bar: symbol;
|
|
740
|
-
}
|
|
728
|
+
};
|
|
741
729
|
|
|
742
730
|
type Bar = {
|
|
743
731
|
[x: number]: number;
|
|
@@ -916,12 +904,14 @@ type Foo = {
|
|
|
916
904
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
917
905
|
//=> {b: string}
|
|
918
906
|
|
|
907
|
+
// @ts-expect-error
|
|
919
908
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
920
909
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
921
910
|
|
|
922
911
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
923
912
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
924
913
|
|
|
914
|
+
// @ts-expect-error
|
|
925
915
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
926
916
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
927
917
|
|
|
@@ -938,12 +928,12 @@ type UserData = {
|
|
|
938
928
|
|
|
939
929
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
940
930
|
type PostPayload = Omit<UserData, 'email'>;
|
|
941
|
-
//=>
|
|
931
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
942
932
|
|
|
943
933
|
// In situations like this, `Except` works better.
|
|
944
934
|
// It simply removes the `email` key while preserving all the other keys.
|
|
945
|
-
type
|
|
946
|
-
//=>
|
|
935
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
936
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
947
937
|
```
|
|
948
938
|
|
|
949
939
|
@category Object
|
|
@@ -967,13 +957,13 @@ type Responder = {
|
|
|
967
957
|
|
|
968
958
|
const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
969
959
|
json: () => '{"message": "ok"}',
|
|
970
|
-
secure: true
|
|
960
|
+
secure: true,
|
|
971
961
|
};
|
|
972
962
|
```
|
|
973
963
|
|
|
974
964
|
@category Object
|
|
975
965
|
*/
|
|
976
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
966
|
+
type RequireAtLeastOne$1<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
977
967
|
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
|
|
978
968
|
// For each `Key` in `KeysType` make a mapped type:
|
|
979
969
|
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
|
|
@@ -1042,7 +1032,7 @@ type Foo = {
|
|
|
1042
1032
|
a: number;
|
|
1043
1033
|
b?: string;
|
|
1044
1034
|
c: boolean;
|
|
1045
|
-
}
|
|
1035
|
+
};
|
|
1046
1036
|
|
|
1047
1037
|
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
1048
1038
|
// type SomeOptional = {
|
|
@@ -1076,7 +1066,7 @@ type Foo = {
|
|
|
1076
1066
|
a?: number;
|
|
1077
1067
|
b: string;
|
|
1078
1068
|
c?: boolean;
|
|
1079
|
-
}
|
|
1069
|
+
};
|
|
1080
1070
|
|
|
1081
1071
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
1082
1072
|
// type SomeRequired = {
|
|
@@ -1115,7 +1105,7 @@ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] =
|
|
|
1115
1105
|
: never; // Should never happen
|
|
1116
1106
|
//#endregion
|
|
1117
1107
|
//#region src/types/options.d.ts
|
|
1118
|
-
type RequireAtLeastOne
|
|
1108
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
1119
1109
|
type StringUnionToFlexibleOptionArray<Op extends string> = Array<Op extends unknown ? FlexibleOption<Op> : never>;
|
|
1120
1110
|
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
1121
1111
|
/**
|
|
@@ -1130,7 +1120,7 @@ type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends Flexi
|
|
|
1130
1120
|
*
|
|
1131
1121
|
* @group Option Lists
|
|
1132
1122
|
*/
|
|
1133
|
-
type GetOptionIdentifierType<Opt
|
|
1123
|
+
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
1134
1124
|
/**
|
|
1135
1125
|
* Adds an `unknown` index property to an interface.
|
|
1136
1126
|
*/
|
|
@@ -1172,14 +1162,14 @@ type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequi
|
|
|
1172
1162
|
*
|
|
1173
1163
|
* @group Option Lists
|
|
1174
1164
|
*/
|
|
1175
|
-
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne
|
|
1165
|
+
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
|
|
1176
1166
|
/**
|
|
1177
1167
|
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
|
|
1178
1168
|
* into a {@link FlexibleOption}.
|
|
1179
1169
|
*
|
|
1180
1170
|
* @group Option Lists
|
|
1181
1171
|
*/
|
|
1182
|
-
type ToFlexibleOption<Opt
|
|
1172
|
+
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
1183
1173
|
/**
|
|
1184
1174
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
1185
1175
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
@@ -1207,7 +1197,7 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1207
1197
|
*
|
|
1208
1198
|
* @group Option Lists
|
|
1209
1199
|
*/
|
|
1210
|
-
type ToFullOption<Opt
|
|
1200
|
+
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1211
1201
|
/**
|
|
1212
1202
|
* @deprecated Renamed to {@link Option}.
|
|
1213
1203
|
*
|
|
@@ -1219,39 +1209,39 @@ type NameLabelPair<N extends string = string> = Option<N>;
|
|
|
1219
1209
|
*
|
|
1220
1210
|
* @group Option Lists
|
|
1221
1211
|
*/
|
|
1222
|
-
interface OptionGroup<Opt
|
|
1212
|
+
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1223
1213
|
label: string;
|
|
1224
|
-
options: WithUnknownIndex<Opt
|
|
1214
|
+
options: WithUnknownIndex<Opt>[];
|
|
1225
1215
|
}
|
|
1226
1216
|
/**
|
|
1227
1217
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1228
1218
|
*
|
|
1229
1219
|
* @group Option Lists
|
|
1230
1220
|
*/
|
|
1231
|
-
type FlexibleOptionGroup<Opt
|
|
1221
|
+
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1232
1222
|
label: string;
|
|
1233
|
-
options: (Opt
|
|
1223
|
+
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1234
1224
|
};
|
|
1235
1225
|
/**
|
|
1236
1226
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
1237
1227
|
*
|
|
1238
1228
|
* @group Option Lists
|
|
1239
1229
|
*/
|
|
1240
|
-
type OptionList<Opt
|
|
1230
|
+
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1241
1231
|
/**
|
|
1242
1232
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1243
1233
|
* may use either `name` or `value` as the primary identifier.
|
|
1244
1234
|
*
|
|
1245
1235
|
* @group Option Lists
|
|
1246
1236
|
*/
|
|
1247
|
-
type FlexibleOptionList<Opt
|
|
1237
|
+
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1248
1238
|
/**
|
|
1249
1239
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
1250
1240
|
* may use either `name` or `value` as the primary identifier.
|
|
1251
1241
|
*
|
|
1252
1242
|
* @group Option Lists
|
|
1253
1243
|
*/
|
|
1254
|
-
type FlexibleOptionListProp<Opt
|
|
1244
|
+
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
|
|
1255
1245
|
/**
|
|
1256
1246
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1257
1247
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1259,7 +1249,7 @@ type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1>
|
|
|
1259
1249
|
*
|
|
1260
1250
|
* @group Option Lists
|
|
1261
1251
|
*/
|
|
1262
|
-
type FullOptionList<Opt
|
|
1252
|
+
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1263
1253
|
/**
|
|
1264
1254
|
* Map of option identifiers to their respective {@link Option}.
|
|
1265
1255
|
*
|
|
@@ -1327,7 +1317,7 @@ type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType
|
|
|
1327
1317
|
* All updateable properties of rules and groups (everything except
|
|
1328
1318
|
* `id`, `path`, and `rules`).
|
|
1329
1319
|
*/
|
|
1330
|
-
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"
|
|
1320
|
+
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules"> | (string & {});
|
|
1331
1321
|
/**
|
|
1332
1322
|
* The type of the `rules` array in a {@link DefaultRuleGroupType}.
|
|
1333
1323
|
*/
|
|
@@ -3729,14 +3719,14 @@ declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value:
|
|
|
3729
3719
|
*
|
|
3730
3720
|
* @group Option Lists
|
|
3731
3721
|
*/
|
|
3732
|
-
declare function toFullOption<Opt
|
|
3722
|
+
declare function toFullOption<Opt extends BaseOption>(opt: Opt | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt>;
|
|
3733
3723
|
/**
|
|
3734
3724
|
* Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3735
3725
|
* Lists of full options are left unchanged.
|
|
3736
3726
|
*
|
|
3737
3727
|
* @group Option Lists
|
|
3738
3728
|
*/
|
|
3739
|
-
declare function toFullOptionList<Opt
|
|
3729
|
+
declare function toFullOptionList<Opt extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt>;
|
|
3740
3730
|
/**
|
|
3741
3731
|
* Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
3742
3732
|
* Lists of full options are left unchanged.
|
|
@@ -3762,7 +3752,7 @@ declare const uniqByName: <T extends {
|
|
|
3762
3752
|
*
|
|
3763
3753
|
* @group Option Lists
|
|
3764
3754
|
*/
|
|
3765
|
-
declare const uniqByIdentifier: <T extends RequireAtLeastOne<{
|
|
3755
|
+
declare const uniqByIdentifier: <T extends RequireAtLeastOne$1<{
|
|
3766
3756
|
name: string;
|
|
3767
3757
|
value: string;
|
|
3768
3758
|
}, "name" | "value">>(originalArray: T[]) => T[];
|
|
@@ -3818,9 +3808,9 @@ declare function getOption<OptType extends Option>(arr: FlexibleOptionList<OptTy
|
|
|
3818
3808
|
*
|
|
3819
3809
|
* @group Option Lists
|
|
3820
3810
|
*/
|
|
3821
|
-
declare function getFirstOption<Opt
|
|
3822
|
-
declare function getFirstOption<Opt
|
|
3823
|
-
declare function getFirstOption<Opt
|
|
3811
|
+
declare function getFirstOption<Opt extends FullOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3812
|
+
declare function getFirstOption<Opt extends ValueOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3813
|
+
declare function getFirstOption<Opt extends Option>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3824
3814
|
/**
|
|
3825
3815
|
* Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.
|
|
3826
3816
|
* If the array is already flat, it is returned as is.
|
|
@@ -3922,6 +3912,17 @@ declare const getCommonAncestorPath: (path1: Path, path2: Path) => Path;
|
|
|
3922
3912
|
*/
|
|
3923
3913
|
declare const pathIsDisabled: (path: Path, query: RuleGroupTypeAny) => boolean;
|
|
3924
3914
|
//#endregion
|
|
3915
|
+
//#region ../react-querybuilder/src/redux/getRqbStore.d.ts
|
|
3916
|
+
declare global {
|
|
3917
|
+
var __RQB_DEVTOOLS__: boolean | undefined;
|
|
3918
|
+
}
|
|
3919
|
+
/**
|
|
3920
|
+
* Gets the singleton React Query Builder store instance.
|
|
3921
|
+
* DevTools are enabled if either:
|
|
3922
|
+
* - globalThis.__RQB_DEVTOOLS__ is truthy
|
|
3923
|
+
* - window.__RQB_DEVTOOLS__ is truthy
|
|
3924
|
+
*/
|
|
3925
|
+
//#endregion
|
|
3925
3926
|
//#region src/utils/preferProp.d.ts
|
|
3926
3927
|
/**
|
|
3927
3928
|
* For given default, prop, and context values, return the first provided of prop,
|