@react-querybuilder/datetime 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/date-fns/package.json +4 -0
- package/dayjs/package.json +4 -0
- package/dist/cjs/{getDatetimeRuleProcessorSQL-B0uQUU_F.js → getDatetimeRuleProcessorSQL-xGETy1ec.js} +1 -1
- package/dist/cjs/{getDatetimeRuleProcessorSQL-B0uQUU_F.js.map → getDatetimeRuleProcessorSQL-xGETy1ec.js.map} +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +10 -6
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
- package/dist/cjs/{types-BF3ibCEu.d.ts → types-B0Eveeq4.d.ts} +104 -103
- package/dist/{getDatetimeRuleProcessorSQL-Cf79Th_c.mjs → getDatetimeRuleProcessorSQL-CugqyF_a.mjs} +1 -1
- package/dist/{getDatetimeRuleProcessorSQL-Cf79Th_c.mjs.map → getDatetimeRuleProcessorSQL-CugqyF_a.mjs.map} +1 -1
- package/dist/{getDatetimeRuleProcessorSQL-DfPnCZiT.js → getDatetimeRuleProcessorSQL-Cxyajj0g.js} +6 -6
- package/dist/{getDatetimeRuleProcessorSQL-DfPnCZiT.js.map → getDatetimeRuleProcessorSQL-Cxyajj0g.js.map} +1 -1
- package/dist/getDatetimeRuleProcessorSQL-Dcqi5kh5.mjs +2 -0
- package/dist/getDatetimeRuleProcessorSQL-Dcqi5kh5.mjs.map +1 -0
- package/dist/react-querybuilder_datetime.d.mts +1 -1
- package/dist/react-querybuilder_datetime.date-fns.d.mts +1 -1
- package/dist/react-querybuilder_datetime.date-fns.mjs +1 -1
- package/dist/react-querybuilder_datetime.dayjs.d.mts +1 -1
- package/dist/react-querybuilder_datetime.dayjs.mjs +1 -1
- package/dist/react-querybuilder_datetime.jsdate.d.mts +1 -1
- package/dist/react-querybuilder_datetime.jsdate.mjs +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.d.ts +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.js +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +1 -1
- package/dist/react-querybuilder_datetime.luxon.d.mts +1 -1
- package/dist/react-querybuilder_datetime.luxon.mjs +1 -1
- package/dist/react-querybuilder_datetime.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.d.mts +1 -1
- package/dist/react-querybuilder_datetime.production.date-fns.d.mts +1 -1
- package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.d.mts +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.d.mts +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.d.mts +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.mjs +1 -1
- package/dist/{types-CU16s8jw.d.ts → types-C-P0L9xh.d.mts} +110 -109
- package/dist/{types-DNawVAiI.d.mts → types-DuaAB95e.d.ts} +110 -109
- package/jsdate/package.json +4 -0
- package/luxon/package.json +4 -0
- package/package.json +17 -13
- package/dist/chunk-DrjzjjTJ.mjs +0 -23
- package/dist/chunk-Dv2ph0Ay.js +0 -23
|
@@ -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
|
|
246
|
+
|
|
247
|
+
type C = IsNever<unknown>;
|
|
248
|
+
//=> false
|
|
249
|
+
|
|
250
|
+
type D = IsNever<never[]>;
|
|
251
|
+
//=> false
|
|
252
|
+
|
|
253
|
+
type E = IsNever<object>;
|
|
254
|
+
//=> false
|
|
283
255
|
|
|
284
|
-
|
|
285
|
-
//=>
|
|
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
|
|
|
@@ -465,10 +455,11 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
465
455
|
const someType: SomeType = literal;
|
|
466
456
|
const someInterface: SomeInterface = literal;
|
|
467
457
|
|
|
468
|
-
function fn(object: Record<string, unknown>): void
|
|
458
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
469
459
|
|
|
470
460
|
fn(literal); // Good: literal object type is sealed
|
|
471
461
|
fn(someType); // Good: type is sealed
|
|
462
|
+
// @ts-expect-error
|
|
472
463
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
473
464
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
474
465
|
```
|
|
@@ -506,7 +497,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
506
497
|
@category Type Guard
|
|
507
498
|
@category Utilities
|
|
508
499
|
*/
|
|
509
|
-
type IsEqual<A, B> = [A
|
|
500
|
+
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
510
501
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
511
502
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
512
503
|
//#endregion
|
|
@@ -528,6 +519,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
528
519
|
```
|
|
529
520
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
530
521
|
|
|
522
|
+
// @ts-expect-error
|
|
531
523
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
532
524
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
533
525
|
```
|
|
@@ -541,16 +533,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
541
533
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
542
534
|
|
|
543
535
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
544
|
-
?
|
|
545
|
-
:
|
|
536
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
537
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
546
538
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
547
539
|
```
|
|
548
540
|
|
|
549
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`...
|
|
550
542
|
|
|
551
543
|
```
|
|
552
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
553
|
-
|
|
554
544
|
type OmitIndexSignature<ObjectType> = {
|
|
555
545
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
556
546
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -560,14 +550,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
560
550
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
561
551
|
|
|
562
552
|
```
|
|
563
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
564
|
-
|
|
565
553
|
type OmitIndexSignature<ObjectType> = {
|
|
566
554
|
[KeyType in keyof ObjectType
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
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>`
|
|
571
559
|
]: ObjectType[KeyType];
|
|
572
560
|
};
|
|
573
561
|
```
|
|
@@ -578,21 +566,21 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
578
566
|
```
|
|
579
567
|
import type {OmitIndexSignature} from 'type-fest';
|
|
580
568
|
|
|
581
|
-
|
|
569
|
+
type Example = {
|
|
582
570
|
// These index signatures will be removed.
|
|
583
|
-
[x: string]: any
|
|
584
|
-
[x: number]: any
|
|
585
|
-
[x: symbol]: any
|
|
586
|
-
[x: `head-${string}`]: string
|
|
587
|
-
[x: `${string}-tail`]: string
|
|
588
|
-
[x: `head-${string}-tail`]: string
|
|
589
|
-
[x: `${bigint}`]: string
|
|
590
|
-
[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;
|
|
591
579
|
|
|
592
580
|
// These explicitly defined keys will remain.
|
|
593
581
|
foo: 'bar';
|
|
594
582
|
qux?: 'baz';
|
|
595
|
-
}
|
|
583
|
+
};
|
|
596
584
|
|
|
597
585
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
598
586
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
@@ -662,12 +650,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
662
650
|
```
|
|
663
651
|
import type {Merge} from 'type-fest';
|
|
664
652
|
|
|
665
|
-
|
|
653
|
+
type Foo = {
|
|
666
654
|
[x: string]: unknown;
|
|
667
655
|
[x: number]: unknown;
|
|
668
656
|
foo: string;
|
|
669
657
|
bar: symbol;
|
|
670
|
-
}
|
|
658
|
+
};
|
|
671
659
|
|
|
672
660
|
type Bar = {
|
|
673
661
|
[x: number]: number;
|
|
@@ -846,12 +834,14 @@ type Foo = {
|
|
|
846
834
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
847
835
|
//=> {b: string}
|
|
848
836
|
|
|
837
|
+
// @ts-expect-error
|
|
849
838
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
850
839
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
851
840
|
|
|
852
841
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
853
842
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
854
843
|
|
|
844
|
+
// @ts-expect-error
|
|
855
845
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
856
846
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
857
847
|
|
|
@@ -868,12 +858,12 @@ type UserData = {
|
|
|
868
858
|
|
|
869
859
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
870
860
|
type PostPayload = Omit<UserData, 'email'>;
|
|
871
|
-
//=>
|
|
861
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
872
862
|
|
|
873
863
|
// In situations like this, `Except` works better.
|
|
874
864
|
// It simply removes the `email` key while preserving all the other keys.
|
|
875
|
-
type
|
|
876
|
-
//=>
|
|
865
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
866
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
877
867
|
```
|
|
878
868
|
|
|
879
869
|
@category Object
|
|
@@ -895,7 +885,7 @@ type Foo = {
|
|
|
895
885
|
a?: number;
|
|
896
886
|
b: string;
|
|
897
887
|
c?: boolean;
|
|
898
|
-
}
|
|
888
|
+
};
|
|
899
889
|
|
|
900
890
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
901
891
|
// type SomeRequired = {
|
|
@@ -970,7 +960,7 @@ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<Requi
|
|
|
970
960
|
*
|
|
971
961
|
* @group Option Lists
|
|
972
962
|
*/
|
|
973
|
-
type ToFlexibleOption<Opt
|
|
963
|
+
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
974
964
|
/**
|
|
975
965
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
976
966
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
@@ -998,24 +988,24 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
998
988
|
*
|
|
999
989
|
* @group Option Lists
|
|
1000
990
|
*/
|
|
1001
|
-
type ToFullOption<Opt
|
|
991
|
+
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1002
992
|
/**
|
|
1003
993
|
* A group of {@link Option}s, usually within an {@link OptionList}.
|
|
1004
994
|
*
|
|
1005
995
|
* @group Option Lists
|
|
1006
996
|
*/
|
|
1007
|
-
interface OptionGroup<Opt
|
|
997
|
+
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1008
998
|
label: string;
|
|
1009
|
-
options: WithUnknownIndex<Opt
|
|
999
|
+
options: WithUnknownIndex<Opt>[];
|
|
1010
1000
|
}
|
|
1011
1001
|
/**
|
|
1012
1002
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1013
1003
|
*
|
|
1014
1004
|
* @group Option Lists
|
|
1015
1005
|
*/
|
|
1016
|
-
type FlexibleOptionGroup<Opt
|
|
1006
|
+
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1017
1007
|
label: string;
|
|
1018
|
-
options: (Opt
|
|
1008
|
+
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1019
1009
|
};
|
|
1020
1010
|
/**
|
|
1021
1011
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
@@ -1023,7 +1013,7 @@ type FlexibleOptionGroup<Opt$1 extends BaseOption | string = BaseOption> = {
|
|
|
1023
1013
|
*
|
|
1024
1014
|
* @group Option Lists
|
|
1025
1015
|
*/
|
|
1026
|
-
type FlexibleOptionList<Opt
|
|
1016
|
+
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1027
1017
|
/**
|
|
1028
1018
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
1029
1019
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -1031,7 +1021,7 @@ type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] |
|
|
|
1031
1021
|
*
|
|
1032
1022
|
* @group Option Lists
|
|
1033
1023
|
*/
|
|
1034
|
-
type FullOptionList<Opt
|
|
1024
|
+
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1035
1025
|
//#endregion
|
|
1036
1026
|
//#region ../core/src/types/ruleGroups.d.ts
|
|
1037
1027
|
/**
|
|
@@ -1182,17 +1172,17 @@ type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
|
|
|
1182
1172
|
/**
|
|
1183
1173
|
* Base for all Field types/interfaces.
|
|
1184
1174
|
*/
|
|
1185
|
-
interface BaseFullField<FieldName extends string = string, OperatorName
|
|
1175
|
+
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>> {
|
|
1186
1176
|
id?: string;
|
|
1187
|
-
operators?: FlexibleOptionList<OperatorObj> | OperatorName
|
|
1188
|
-
valueEditorType?: ValueEditorType | ((operator: OperatorName
|
|
1189
|
-
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName
|
|
1177
|
+
operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
|
|
1178
|
+
valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
|
|
1179
|
+
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
|
|
1190
1180
|
inputType?: InputType | null;
|
|
1191
1181
|
values?: FlexibleOptionList<ValueObj>;
|
|
1192
1182
|
matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
|
|
1193
1183
|
/** Properties of items in the value. */
|
|
1194
1184
|
subproperties?: FlexibleOptionList<FullField>;
|
|
1195
|
-
defaultOperator?: OperatorName
|
|
1185
|
+
defaultOperator?: OperatorName;
|
|
1196
1186
|
defaultValue?: any;
|
|
1197
1187
|
placeholder?: string;
|
|
1198
1188
|
validator?: RuleValidator;
|
|
@@ -1210,7 +1200,7 @@ interface BaseFullField<FieldName extends string = string, OperatorName$1 extend
|
|
|
1210
1200
|
*
|
|
1211
1201
|
* @group Option Lists
|
|
1212
1202
|
*/
|
|
1213
|
-
type FullField<FieldName extends string = string, OperatorName
|
|
1203
|
+
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>>;
|
|
1214
1204
|
/**
|
|
1215
1205
|
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
1216
1206
|
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
@@ -1638,6 +1628,17 @@ type ZeroOrMoreGroupVariants = RepeatStrings<["xor", "not"]>;
|
|
|
1638
1628
|
*/
|
|
1639
1629
|
type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
|
|
1640
1630
|
//#endregion
|
|
1631
|
+
//#region ../react-querybuilder/src/redux/getRqbStore.d.ts
|
|
1632
|
+
declare global {
|
|
1633
|
+
var __RQB_DEVTOOLS__: boolean | undefined;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Gets the singleton React Query Builder store instance.
|
|
1637
|
+
* DevTools are enabled if either:
|
|
1638
|
+
* - globalThis.__RQB_DEVTOOLS__ is truthy
|
|
1639
|
+
* - window.__RQB_DEVTOOLS__ is truthy
|
|
1640
|
+
*/
|
|
1641
|
+
//#endregion
|
|
1641
1642
|
//#region src/types.d.ts
|
|
1642
1643
|
interface RQBJsonLogicDateBetween {
|
|
1643
1644
|
dateBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
|
|
@@ -1749,4 +1750,4 @@ type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boole
|
|
|
1749
1750
|
type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
|
|
1750
1751
|
//#endregion
|
|
1751
1752
|
export { RuleProcessor as _, RQBJsonLogicDateAfter as a, RQBJsonLogicDateIn as c, RQBJsonLogicDateNotOn as d, RQBJsonLogicDateOn as f, ExportOperatorMap as g, RQBJsonLogicDateTimeOperations as h, RQBDateTimeLibraryAPI as i, RQBJsonLogicDateNotBetween as l, RQBJsonLogicDateOnOrBefore as m, IsDateFieldFunction as n, RQBJsonLogicDateBefore as o, RQBJsonLogicDateOnOrAfter as p, RQBDateTimeJsonLogic as r, RQBJsonLogicDateBetween as s, IsDateField as t, RQBJsonLogicDateNotIn as u, ValueProcessorByRule as v };
|
|
1752
|
-
//# sourceMappingURL=types-
|
|
1753
|
+
//# sourceMappingURL=types-C-P0L9xh.d.mts.map
|