@react-querybuilder/datetime 8.9.2 → 8.11.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/getDatetimeRuleProcessorSQL-COEhnVIZ.js +478 -0
- package/dist/cjs/getDatetimeRuleProcessorSQL-COEhnVIZ.js.map +1 -0
- package/dist/cjs/{getDatetimeRuleProcessorSQL-D95jgDK6.js → getDatetimeRuleProcessorSQL-CSxxM8ce.js} +2 -2
- package/dist/cjs/{getDatetimeRuleProcessorSQL-D95jgDK6.js.map → getDatetimeRuleProcessorSQL-CSxxM8ce.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.date-fns.js +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 +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +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.date-fns.js.map +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.dayjs.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +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.jsdate.js.map +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/react-querybuilder_datetime.cjs.production.luxon.js.map +1 -1
- package/dist/{types-CDEkL2M_.d.mts → cjs/types-A60rB27l.d.ts} +450 -428
- package/dist/{getDatetimeRuleProcessorSQL-CN80oEFK.js → getDatetimeRuleProcessorSQL-B8y0RI7t.js} +12 -14
- package/dist/{getDatetimeRuleProcessorSQL-CN80oEFK.js.map → getDatetimeRuleProcessorSQL-B8y0RI7t.js.map} +1 -1
- package/dist/{getDatetimeRuleProcessorSQL-KYRPP9qd.mjs → getDatetimeRuleProcessorSQL-CSl2zGza.mjs} +13 -15
- package/dist/{getDatetimeRuleProcessorSQL-KYRPP9qd.mjs.map → getDatetimeRuleProcessorSQL-CSl2zGza.mjs.map} +1 -1
- 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.date-fns.mjs.map +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.dayjs.mjs.map +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.jsdate.mjs.map +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.luxon.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
- package/dist/{types-EgfSemtR.d.ts → types-BjHLhGXX.d.mts} +450 -428
- package/dist/{cjs/types-QCQUGVZa.d.ts → types-Dq7BlQzI.d.ts} +450 -428
- package/package.json +14 -14
|
@@ -1,407 +1,480 @@
|
|
|
1
1
|
import { RulesLogic } from "json-logic-js";
|
|
2
2
|
|
|
3
|
-
//#region
|
|
3
|
+
//#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
|
|
6
|
+
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
8
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
@example
|
|
11
|
+
```
|
|
12
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
13
|
+
|
|
14
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
15
|
+
|
|
16
|
+
type Intersection = UnionToIntersection<Union>;
|
|
17
|
+
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
A more applicable example which could make its way into your library code follows.
|
|
13
21
|
|
|
14
22
|
@example
|
|
15
23
|
```
|
|
16
|
-
import type {
|
|
24
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
class CommandOne {
|
|
27
|
+
commands: {
|
|
28
|
+
a1: () => undefined,
|
|
29
|
+
b1: () => undefined,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class CommandTwo {
|
|
34
|
+
commands: {
|
|
35
|
+
a2: (argA: string) => undefined,
|
|
36
|
+
b2: (argB: string) => undefined,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
41
|
+
type Union = typeof union;
|
|
42
|
+
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
43
|
+
|
|
44
|
+
type Intersection = UnionToIntersection<Union>;
|
|
45
|
+
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
26
46
|
```
|
|
27
47
|
|
|
28
|
-
@
|
|
29
|
-
*/
|
|
30
|
-
type
|
|
48
|
+
@category Type
|
|
49
|
+
*/
|
|
50
|
+
type UnionToIntersection<Union> = (
|
|
51
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
52
|
+
// `Union` into a [distributive conditional
|
|
53
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
54
|
+
Union extends unknown
|
|
55
|
+
// The union type is used as the only argument to a function since the union
|
|
56
|
+
// of function arguments is an intersection.
|
|
57
|
+
? (distributedUnion: Union) => void
|
|
58
|
+
// This won't happen.
|
|
59
|
+
: never
|
|
60
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
61
|
+
// arguments of unions of functions as an intersection of the union.
|
|
62
|
+
) extends ((mergedIntersection: infer Intersection) => void)
|
|
63
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
64
|
+
? Intersection & Union : never;
|
|
31
65
|
//#endregion
|
|
32
|
-
//#region
|
|
66
|
+
//#region ../../node_modules/type-fest/source/keys-of-union.d.ts
|
|
33
67
|
/**
|
|
34
|
-
|
|
68
|
+
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
35
69
|
|
|
36
|
-
|
|
37
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
38
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
70
|
+
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
39
71
|
|
|
40
|
-
|
|
72
|
+
@link https://stackoverflow.com/a/49402091
|
|
41
73
|
|
|
42
74
|
@example
|
|
43
75
|
```
|
|
44
|
-
import type {
|
|
76
|
+
import type {KeysOfUnion} from 'type-fest';
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
51
|
-
>;
|
|
78
|
+
type A = {
|
|
79
|
+
common: string;
|
|
80
|
+
a: number;
|
|
81
|
+
};
|
|
52
82
|
|
|
53
|
-
type
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
type B = {
|
|
84
|
+
common: string;
|
|
85
|
+
b: string;
|
|
86
|
+
};
|
|
57
87
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}
|
|
88
|
+
type C = {
|
|
89
|
+
common: string;
|
|
90
|
+
c: boolean;
|
|
91
|
+
};
|
|
63
92
|
|
|
64
|
-
|
|
65
|
-
//=> never
|
|
93
|
+
type Union = A | B | C;
|
|
66
94
|
|
|
67
|
-
|
|
68
|
-
//=>
|
|
95
|
+
type CommonKeys = keyof Union;
|
|
96
|
+
//=> 'common'
|
|
97
|
+
|
|
98
|
+
type AllKeys = KeysOfUnion<Union>;
|
|
99
|
+
//=> 'common' | 'a' | 'b' | 'c'
|
|
69
100
|
```
|
|
70
101
|
|
|
71
|
-
@
|
|
102
|
+
@category Object
|
|
72
103
|
*/
|
|
73
|
-
type
|
|
104
|
+
type KeysOfUnion<ObjectType> =
|
|
105
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
106
|
+
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
74
107
|
//#endregion
|
|
75
|
-
//#region
|
|
108
|
+
//#region ../../node_modules/type-fest/source/is-any.d.ts
|
|
76
109
|
/**
|
|
77
|
-
|
|
110
|
+
Returns a boolean for whether the given type is `any`.
|
|
111
|
+
|
|
112
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
78
113
|
|
|
79
|
-
|
|
114
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
80
115
|
|
|
81
116
|
@example
|
|
82
117
|
```
|
|
83
|
-
import type {
|
|
118
|
+
import type {IsAny} from 'type-fest';
|
|
84
119
|
|
|
85
|
-
|
|
86
|
-
|
|
120
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
121
|
+
const anyObject: any = {a: 1, b: 2};
|
|
87
122
|
|
|
88
|
-
|
|
89
|
-
|
|
123
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
124
|
+
return obj[key];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const typedA = get(typedObject, 'a');
|
|
128
|
+
//=> 1
|
|
129
|
+
|
|
130
|
+
const anyA = get(anyObject, 'a');
|
|
131
|
+
//=> any
|
|
90
132
|
```
|
|
91
133
|
|
|
92
|
-
@
|
|
134
|
+
@category Type Guard
|
|
135
|
+
@category Utilities
|
|
93
136
|
*/
|
|
94
|
-
type
|
|
137
|
+
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
95
138
|
//#endregion
|
|
96
|
-
//#region
|
|
139
|
+
//#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
97
140
|
/**
|
|
98
|
-
|
|
141
|
+
Returns a boolean for whether the given key is an optional key of type.
|
|
99
142
|
|
|
100
|
-
|
|
143
|
+
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
101
144
|
|
|
102
145
|
@example
|
|
103
146
|
```
|
|
104
|
-
import type {
|
|
147
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
105
148
|
|
|
106
|
-
|
|
149
|
+
interface User {
|
|
150
|
+
name: string;
|
|
151
|
+
surname: string;
|
|
107
152
|
|
|
108
|
-
|
|
109
|
-
|
|
153
|
+
luckyNumber?: number;
|
|
154
|
+
}
|
|
110
155
|
|
|
111
|
-
|
|
156
|
+
interface Admin {
|
|
157
|
+
name: string;
|
|
158
|
+
surname?: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
112
162
|
//=> true
|
|
113
163
|
|
|
114
|
-
type
|
|
164
|
+
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
115
165
|
//=> false
|
|
116
|
-
```
|
|
117
166
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
type UnknownArray = readonly unknown[];
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region ../core/src/types/type-fest/internal/array.d.ts
|
|
167
|
+
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
168
|
+
//=> boolean
|
|
123
169
|
|
|
124
|
-
|
|
125
|
-
|
|
170
|
+
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
171
|
+
//=> false
|
|
126
172
|
|
|
127
|
-
|
|
173
|
+
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
174
|
+
//=> boolean
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
@category Type Guard
|
|
178
|
+
@category Utilities
|
|
128
179
|
*/
|
|
129
|
-
type
|
|
180
|
+
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
|
|
130
183
|
/**
|
|
131
|
-
|
|
184
|
+
Extract all optional keys from the given type.
|
|
132
185
|
|
|
133
|
-
|
|
186
|
+
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
134
187
|
|
|
135
188
|
@example
|
|
136
189
|
```
|
|
137
|
-
import type {
|
|
190
|
+
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
138
191
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
: never;
|
|
192
|
+
interface User {
|
|
193
|
+
name: string;
|
|
194
|
+
surname: string;
|
|
143
195
|
|
|
144
|
-
|
|
145
|
-
|
|
196
|
+
luckyNumber?: number;
|
|
197
|
+
}
|
|
146
198
|
|
|
147
|
-
|
|
148
|
-
|
|
199
|
+
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
200
|
+
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
201
|
+
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
202
|
+
};
|
|
149
203
|
|
|
150
|
-
|
|
151
|
-
|
|
204
|
+
const update1: UpdateOperation<User> = {
|
|
205
|
+
name: 'Alice'
|
|
206
|
+
};
|
|
152
207
|
|
|
153
|
-
|
|
154
|
-
|
|
208
|
+
const update2: UpdateOperation<User> = {
|
|
209
|
+
name: 'Bob',
|
|
210
|
+
luckyNumber: REMOVE_FIELD
|
|
211
|
+
};
|
|
155
212
|
```
|
|
156
213
|
|
|
157
|
-
@
|
|
214
|
+
@category Utilities
|
|
158
215
|
*/
|
|
159
|
-
type
|
|
216
|
+
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
217
|
+
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
218
|
+
: never;
|
|
160
219
|
//#endregion
|
|
161
|
-
//#region
|
|
162
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
220
|
+
//#region ../../node_modules/type-fest/source/required-keys-of.d.ts
|
|
163
221
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
222
|
+
Extract all required keys from the given type.
|
|
167
223
|
|
|
168
|
-
|
|
224
|
+
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
169
225
|
|
|
170
226
|
@example
|
|
171
227
|
```
|
|
172
|
-
import type {
|
|
228
|
+
import type {RequiredKeysOf} from 'type-fest';
|
|
173
229
|
|
|
174
|
-
|
|
175
|
-
const anyObject: any = {a: 1, b: 2};
|
|
230
|
+
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
176
231
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
232
|
+
interface User {
|
|
233
|
+
name: string;
|
|
234
|
+
surname: string;
|
|
180
235
|
|
|
181
|
-
|
|
182
|
-
|
|
236
|
+
luckyNumber?: number;
|
|
237
|
+
}
|
|
183
238
|
|
|
184
|
-
const
|
|
185
|
-
|
|
239
|
+
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
240
|
+
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
186
241
|
```
|
|
187
242
|
|
|
188
|
-
@
|
|
243
|
+
@category Utilities
|
|
189
244
|
*/
|
|
190
|
-
type
|
|
245
|
+
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
246
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
191
247
|
//#endregion
|
|
192
|
-
//#region
|
|
248
|
+
//#region ../../node_modules/type-fest/source/is-never.d.ts
|
|
193
249
|
/**
|
|
194
|
-
|
|
250
|
+
Returns a boolean for whether the given type is `never`.
|
|
251
|
+
|
|
252
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
253
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
254
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
255
|
+
|
|
256
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
195
257
|
|
|
196
258
|
@example
|
|
197
259
|
```
|
|
198
|
-
import type {
|
|
260
|
+
import type {IsNever, And} from 'type-fest';
|
|
199
261
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
262
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
263
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
264
|
+
And<
|
|
265
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
266
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
267
|
+
>;
|
|
204
268
|
|
|
205
|
-
type
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
269
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
270
|
+
AreStringsEqual<I, O> extends true
|
|
271
|
+
? never
|
|
272
|
+
: void;
|
|
209
273
|
|
|
210
|
-
|
|
211
|
-
|
|
274
|
+
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
275
|
+
if (input === output) {
|
|
276
|
+
process.exit(0);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
endIfEqual('abc', 'abc');
|
|
281
|
+
//=> never
|
|
282
|
+
|
|
283
|
+
endIfEqual('abc', '123');
|
|
284
|
+
//=> void
|
|
212
285
|
```
|
|
213
286
|
|
|
214
|
-
|
|
287
|
+
@category Type Guard
|
|
288
|
+
@category Utilities
|
|
289
|
+
*/
|
|
290
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region ../../node_modules/type-fest/source/if.d.ts
|
|
293
|
+
/**
|
|
294
|
+
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
215
295
|
|
|
216
|
-
|
|
296
|
+
Use-cases:
|
|
297
|
+
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
298
|
+
|
|
299
|
+
Note:
|
|
300
|
+
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
301
|
+
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
217
302
|
|
|
218
303
|
@example
|
|
219
304
|
```
|
|
220
|
-
import
|
|
305
|
+
import {If} from 'type-fest';
|
|
221
306
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
bar?: string;
|
|
225
|
-
baz: number | undefined;
|
|
226
|
-
}
|
|
307
|
+
type A = If<true, 'yes', 'no'>;
|
|
308
|
+
//=> 'yes'
|
|
227
309
|
|
|
228
|
-
type
|
|
229
|
-
|
|
230
|
-
bar?: string;
|
|
231
|
-
baz: number | undefined;
|
|
232
|
-
};
|
|
310
|
+
type B = If<false, 'yes', 'no'>;
|
|
311
|
+
//=> 'no'
|
|
233
312
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const someInterface: SomeInterface = literal;
|
|
313
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
314
|
+
//=> 'yes' | 'no'
|
|
237
315
|
|
|
238
|
-
|
|
316
|
+
type D = If<any, 'yes', 'no'>;
|
|
317
|
+
//=> 'yes' | 'no'
|
|
239
318
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
243
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
319
|
+
type E = If<never, 'yes', 'no'>;
|
|
320
|
+
//=> 'no'
|
|
244
321
|
```
|
|
245
322
|
|
|
246
|
-
@
|
|
247
|
-
|
|
323
|
+
@example
|
|
324
|
+
```
|
|
325
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
248
326
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
252
|
-
//#endregion
|
|
253
|
-
//#region ../core/src/types/type-fest/union-to-intersection.d.ts
|
|
254
|
-
/**
|
|
255
|
-
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
327
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
328
|
+
//=> 'not any'
|
|
256
329
|
|
|
257
|
-
|
|
330
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
331
|
+
//=> 'is never'
|
|
332
|
+
```
|
|
258
333
|
|
|
259
334
|
@example
|
|
260
335
|
```
|
|
261
|
-
import
|
|
336
|
+
import {If, IsEqual} from 'type-fest';
|
|
262
337
|
|
|
263
|
-
type
|
|
338
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
264
339
|
|
|
265
|
-
type
|
|
266
|
-
//=>
|
|
340
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
341
|
+
//=> 'equal'
|
|
342
|
+
|
|
343
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
344
|
+
//=> 'not equal'
|
|
267
345
|
```
|
|
268
346
|
|
|
269
|
-
|
|
347
|
+
@category Type Guard
|
|
348
|
+
@category Utilities
|
|
349
|
+
*/
|
|
350
|
+
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region ../../node_modules/type-fest/source/unknown-array.d.ts
|
|
353
|
+
/**
|
|
354
|
+
Represents an array with `unknown` value.
|
|
355
|
+
|
|
356
|
+
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
270
357
|
|
|
271
358
|
@example
|
|
272
359
|
```
|
|
273
|
-
import type {
|
|
360
|
+
import type {UnknownArray} from 'type-fest';
|
|
274
361
|
|
|
275
|
-
|
|
276
|
-
commands: {
|
|
277
|
-
a1: () => undefined,
|
|
278
|
-
b1: () => undefined,
|
|
279
|
-
}
|
|
280
|
-
}
|
|
362
|
+
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
281
363
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
a2: (argA: string) => undefined,
|
|
285
|
-
b2: (argB: string) => undefined,
|
|
286
|
-
}
|
|
287
|
-
}
|
|
364
|
+
type A = IsArray<['foo']>;
|
|
365
|
+
//=> true
|
|
288
366
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
367
|
+
type B = IsArray<readonly number[]>;
|
|
368
|
+
//=> true
|
|
292
369
|
|
|
293
|
-
type
|
|
294
|
-
//=>
|
|
370
|
+
type C = IsArray<string>;
|
|
371
|
+
//=> false
|
|
295
372
|
```
|
|
296
373
|
|
|
297
|
-
@
|
|
374
|
+
@category Type
|
|
375
|
+
@category Array
|
|
298
376
|
*/
|
|
299
|
-
type
|
|
377
|
+
type UnknownArray = readonly unknown[];
|
|
300
378
|
//#endregion
|
|
301
|
-
//#region
|
|
302
|
-
/**
|
|
303
|
-
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
304
|
-
|
|
305
|
-
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
379
|
+
//#region ../../node_modules/type-fest/source/internal/array.d.ts
|
|
306
380
|
|
|
307
|
-
|
|
381
|
+
/**
|
|
382
|
+
Returns whether the given array `T` is readonly.
|
|
383
|
+
*/
|
|
384
|
+
type IsArrayReadonly<T extends UnknownArray> = If<IsNever<T>, false, T extends unknown[] ? false : true>;
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region ../../node_modules/type-fest/source/simplify.d.ts
|
|
387
|
+
/**
|
|
388
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
308
389
|
|
|
309
390
|
@example
|
|
310
391
|
```
|
|
311
|
-
import type {
|
|
312
|
-
|
|
313
|
-
type A = {
|
|
314
|
-
common: string;
|
|
315
|
-
a: number;
|
|
316
|
-
};
|
|
392
|
+
import type {Simplify} from 'type-fest';
|
|
317
393
|
|
|
318
|
-
type
|
|
319
|
-
|
|
320
|
-
|
|
394
|
+
type PositionProps = {
|
|
395
|
+
top: number;
|
|
396
|
+
left: number;
|
|
321
397
|
};
|
|
322
398
|
|
|
323
|
-
type
|
|
324
|
-
|
|
325
|
-
|
|
399
|
+
type SizeProps = {
|
|
400
|
+
width: number;
|
|
401
|
+
height: number;
|
|
326
402
|
};
|
|
327
403
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
type CommonKeys = keyof Union;
|
|
331
|
-
//=> 'common'
|
|
332
|
-
|
|
333
|
-
type AllKeys = KeysOfUnion<Union>;
|
|
334
|
-
//=> 'common' | 'a' | 'b' | 'c'
|
|
404
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
405
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
335
406
|
```
|
|
336
407
|
|
|
337
|
-
|
|
338
|
-
*/
|
|
339
|
-
type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region ../core/src/types/type-fest/optional-keys-of.d.ts
|
|
342
|
-
/**
|
|
343
|
-
Extract all optional keys from the given type.
|
|
408
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
344
409
|
|
|
345
|
-
|
|
410
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
346
411
|
|
|
347
412
|
@example
|
|
348
413
|
```
|
|
349
|
-
import type {
|
|
350
|
-
|
|
351
|
-
interface User {
|
|
352
|
-
name: string;
|
|
353
|
-
surname: string;
|
|
414
|
+
import type {Simplify} from 'type-fest';
|
|
354
415
|
|
|
355
|
-
|
|
416
|
+
interface SomeInterface {
|
|
417
|
+
foo: number;
|
|
418
|
+
bar?: string;
|
|
419
|
+
baz: number | undefined;
|
|
356
420
|
}
|
|
357
421
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
422
|
+
type SomeType = {
|
|
423
|
+
foo: number;
|
|
424
|
+
bar?: string;
|
|
425
|
+
baz: number | undefined;
|
|
361
426
|
};
|
|
362
427
|
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
428
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
429
|
+
const someType: SomeType = literal;
|
|
430
|
+
const someInterface: SomeInterface = literal;
|
|
366
431
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
432
|
+
function fn(object: Record<string, unknown>): void {}
|
|
433
|
+
|
|
434
|
+
fn(literal); // Good: literal object type is sealed
|
|
435
|
+
fn(someType); // Good: type is sealed
|
|
436
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
437
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
371
438
|
```
|
|
372
439
|
|
|
373
|
-
@
|
|
440
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
441
|
+
@see SimplifyDeep
|
|
442
|
+
@category Object
|
|
374
443
|
*/
|
|
375
|
-
type
|
|
444
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
376
445
|
//#endregion
|
|
377
|
-
//#region
|
|
446
|
+
//#region ../../node_modules/type-fest/source/is-equal.d.ts
|
|
378
447
|
/**
|
|
379
|
-
|
|
448
|
+
Returns a boolean for whether the two given types are equal.
|
|
380
449
|
|
|
381
|
-
|
|
450
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
451
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
452
|
+
|
|
453
|
+
Use-cases:
|
|
454
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
382
455
|
|
|
383
456
|
@example
|
|
384
457
|
```
|
|
385
|
-
import type {
|
|
386
|
-
|
|
387
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
388
|
-
|
|
389
|
-
interface User {
|
|
390
|
-
name: string;
|
|
391
|
-
surname: string;
|
|
392
|
-
|
|
393
|
-
luckyNumber?: number;
|
|
394
|
-
}
|
|
458
|
+
import type {IsEqual} from 'type-fest';
|
|
395
459
|
|
|
396
|
-
|
|
397
|
-
|
|
460
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
461
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
462
|
+
type Includes<Value extends readonly any[], Item> =
|
|
463
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
464
|
+
? IsEqual<Value[0], Item> extends true
|
|
465
|
+
? true
|
|
466
|
+
: Includes<rest, Item>
|
|
467
|
+
: false;
|
|
398
468
|
```
|
|
399
469
|
|
|
400
|
-
@
|
|
470
|
+
@category Type Guard
|
|
471
|
+
@category Utilities
|
|
401
472
|
*/
|
|
402
|
-
type
|
|
473
|
+
type IsEqual<A, B> = [A, B] extends [infer AA, infer BB] ? [AA] extends [never] ? [BB] extends [never] ? true : false : [BB] extends [never] ? false : _IsEqual<AA, BB> : false;
|
|
474
|
+
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
475
|
+
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
403
476
|
//#endregion
|
|
404
|
-
//#region
|
|
477
|
+
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
405
478
|
/**
|
|
406
479
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
407
480
|
|
|
@@ -427,13 +500,13 @@ Instead of causing a type error like the above, you can also use a [conditional
|
|
|
427
500
|
|
|
428
501
|
```
|
|
429
502
|
type Indexed = {} extends Record<string, unknown>
|
|
430
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
431
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
503
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
504
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
432
505
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
433
506
|
|
|
434
507
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
435
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
436
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
508
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
509
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
437
510
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
438
511
|
```
|
|
439
512
|
|
|
@@ -443,8 +516,8 @@ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-type
|
|
|
443
516
|
import type {OmitIndexSignature} from 'type-fest';
|
|
444
517
|
|
|
445
518
|
type OmitIndexSignature<ObjectType> = {
|
|
446
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
447
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
519
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
520
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
448
521
|
};
|
|
449
522
|
```
|
|
450
523
|
|
|
@@ -454,12 +527,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
454
527
|
import type {OmitIndexSignature} from 'type-fest';
|
|
455
528
|
|
|
456
529
|
type OmitIndexSignature<ObjectType> = {
|
|
457
|
-
[KeyType in keyof ObjectType
|
|
458
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
459
|
-
as {} extends Record<KeyType, unknown>
|
|
460
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
461
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
462
|
-
]: ObjectType[KeyType];
|
|
530
|
+
[KeyType in keyof ObjectType
|
|
531
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
532
|
+
as {} extends Record<KeyType, unknown>
|
|
533
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
534
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
535
|
+
]: ObjectType[KeyType];
|
|
463
536
|
};
|
|
464
537
|
```
|
|
465
538
|
|
|
@@ -470,19 +543,19 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
470
543
|
import type {OmitIndexSignature} from 'type-fest';
|
|
471
544
|
|
|
472
545
|
interface Example {
|
|
473
|
-
// These index signatures will be removed.
|
|
474
|
-
[x: string]: any
|
|
475
|
-
[x: number]: any
|
|
476
|
-
[x: symbol]: any
|
|
477
|
-
[x: `head-${string}`]: string
|
|
478
|
-
[x: `${string}-tail`]: string
|
|
479
|
-
[x: `head-${string}-tail`]: string
|
|
480
|
-
[x: `${bigint}`]: string
|
|
481
|
-
[x: `embedded-${number}`]: string
|
|
482
|
-
|
|
483
|
-
// These explicitly defined keys will remain.
|
|
484
|
-
foo: 'bar';
|
|
485
|
-
qux?: 'baz';
|
|
546
|
+
// These index signatures will be removed.
|
|
547
|
+
[x: string]: any
|
|
548
|
+
[x: number]: any
|
|
549
|
+
[x: symbol]: any
|
|
550
|
+
[x: `head-${string}`]: string
|
|
551
|
+
[x: `${string}-tail`]: string
|
|
552
|
+
[x: `head-${string}-tail`]: string
|
|
553
|
+
[x: `${bigint}`]: string
|
|
554
|
+
[x: `embedded-${number}`]: string
|
|
555
|
+
|
|
556
|
+
// These explicitly defined keys will remain.
|
|
557
|
+
foo: 'bar';
|
|
558
|
+
qux?: 'baz';
|
|
486
559
|
}
|
|
487
560
|
|
|
488
561
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
@@ -490,12 +563,11 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
490
563
|
```
|
|
491
564
|
|
|
492
565
|
@see PickIndexSignature
|
|
493
|
-
|
|
494
|
-
@group type-fest
|
|
566
|
+
@category Object
|
|
495
567
|
*/
|
|
496
568
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
497
569
|
//#endregion
|
|
498
|
-
//#region
|
|
570
|
+
//#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
|
|
499
571
|
/**
|
|
500
572
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
501
573
|
|
|
@@ -508,21 +580,21 @@ import type {PickIndexSignature} from 'type-fest';
|
|
|
508
580
|
declare const symbolKey: unique symbol;
|
|
509
581
|
|
|
510
582
|
type Example = {
|
|
511
|
-
// These index signatures will remain.
|
|
512
|
-
[x: string]: unknown;
|
|
513
|
-
[x: number]: unknown;
|
|
514
|
-
[x: symbol]: unknown;
|
|
515
|
-
[x: `head-${string}`]: string;
|
|
516
|
-
[x: `${string}-tail`]: string;
|
|
517
|
-
[x: `head-${string}-tail`]: string;
|
|
518
|
-
[x: `${bigint}`]: string;
|
|
519
|
-
[x: `embedded-${number}`]: string;
|
|
520
|
-
|
|
521
|
-
// These explicitly defined keys will be removed.
|
|
522
|
-
['kebab-case-key']: string;
|
|
523
|
-
[symbolKey]: string;
|
|
524
|
-
foo: 'bar';
|
|
525
|
-
qux?: 'baz';
|
|
583
|
+
// These index signatures will remain.
|
|
584
|
+
[x: string]: unknown;
|
|
585
|
+
[x: number]: unknown;
|
|
586
|
+
[x: symbol]: unknown;
|
|
587
|
+
[x: `head-${string}`]: string;
|
|
588
|
+
[x: `${string}-tail`]: string;
|
|
589
|
+
[x: `head-${string}-tail`]: string;
|
|
590
|
+
[x: `${bigint}`]: string;
|
|
591
|
+
[x: `embedded-${number}`]: string;
|
|
592
|
+
|
|
593
|
+
// These explicitly defined keys will be removed.
|
|
594
|
+
['kebab-case-key']: string;
|
|
595
|
+
[symbolKey]: string;
|
|
596
|
+
foo: 'bar';
|
|
597
|
+
qux?: 'baz';
|
|
526
598
|
};
|
|
527
599
|
|
|
528
600
|
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
@@ -539,13 +611,14 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
539
611
|
```
|
|
540
612
|
|
|
541
613
|
@see OmitIndexSignature
|
|
542
|
-
|
|
543
|
-
@group type-fest
|
|
614
|
+
@category Object
|
|
544
615
|
*/
|
|
545
616
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
546
617
|
//#endregion
|
|
547
|
-
//#region
|
|
618
|
+
//#region ../../node_modules/type-fest/source/merge.d.ts
|
|
619
|
+
// Merges two objects without worrying about index signatures.
|
|
548
620
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
621
|
+
|
|
549
622
|
/**
|
|
550
623
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
551
624
|
|
|
@@ -554,17 +627,17 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
554
627
|
import type {Merge} from 'type-fest';
|
|
555
628
|
|
|
556
629
|
interface Foo {
|
|
557
|
-
[x: string]: unknown;
|
|
558
|
-
[x: number]: unknown;
|
|
559
|
-
foo: string;
|
|
560
|
-
bar: symbol;
|
|
630
|
+
[x: string]: unknown;
|
|
631
|
+
[x: number]: unknown;
|
|
632
|
+
foo: string;
|
|
633
|
+
bar: symbol;
|
|
561
634
|
}
|
|
562
635
|
|
|
563
636
|
type Bar = {
|
|
564
|
-
[x: number]: number;
|
|
565
|
-
[x: symbol]: unknown;
|
|
566
|
-
bar: Date;
|
|
567
|
-
baz: boolean;
|
|
637
|
+
[x: number]: number;
|
|
638
|
+
[x: symbol]: unknown;
|
|
639
|
+
bar: Date;
|
|
640
|
+
baz: boolean;
|
|
568
641
|
};
|
|
569
642
|
|
|
570
643
|
export type FooBar = Merge<Foo, Bar>;
|
|
@@ -578,55 +651,11 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
578
651
|
// }
|
|
579
652
|
```
|
|
580
653
|
|
|
581
|
-
@
|
|
654
|
+
@category Object
|
|
582
655
|
*/
|
|
583
656
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
584
657
|
//#endregion
|
|
585
|
-
//#region
|
|
586
|
-
/**
|
|
587
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
588
|
-
|
|
589
|
-
@see {@link IsAny}
|
|
590
|
-
|
|
591
|
-
@example
|
|
592
|
-
```
|
|
593
|
-
import type {IfAny} from 'type-fest';
|
|
594
|
-
|
|
595
|
-
type ShouldBeTrue = IfAny<any>;
|
|
596
|
-
//=> true
|
|
597
|
-
|
|
598
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
599
|
-
//=> 'bar'
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
@group type-fest
|
|
603
|
-
*/
|
|
604
|
-
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
605
|
-
//#endregion
|
|
606
|
-
//#region ../core/src/types/type-fest/internal/type.d.ts
|
|
607
|
-
/**
|
|
608
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
609
|
-
|
|
610
|
-
@example
|
|
611
|
-
```
|
|
612
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
613
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
614
|
-
//=> 'VALID'
|
|
615
|
-
|
|
616
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
617
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
618
|
-
//=> 'IS_ANY'
|
|
619
|
-
|
|
620
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
621
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
622
|
-
//=> 'IS_NEVER'
|
|
623
|
-
```
|
|
624
|
-
|
|
625
|
-
@group type-fest
|
|
626
|
-
*/
|
|
627
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region ../core/src/types/type-fest/internal/object.d.ts
|
|
658
|
+
//#region ../../node_modules/type-fest/source/internal/object.d.ts
|
|
630
659
|
/**
|
|
631
660
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
632
661
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -637,15 +666,15 @@ Works similar to the built-in `Pick` utility type, except for the following diff
|
|
|
637
666
|
@example
|
|
638
667
|
```
|
|
639
668
|
type ImageUpload = {
|
|
640
|
-
url: string;
|
|
641
|
-
size: number;
|
|
642
|
-
thumbnailUrl: string;
|
|
669
|
+
url: string;
|
|
670
|
+
size: number;
|
|
671
|
+
thumbnailUrl: string;
|
|
643
672
|
};
|
|
644
673
|
|
|
645
674
|
type VideoUpload = {
|
|
646
|
-
url: string;
|
|
647
|
-
duration: number;
|
|
648
|
-
encodingFormat: string;
|
|
675
|
+
url: string;
|
|
676
|
+
duration: number;
|
|
677
|
+
encodingFormat: string;
|
|
649
678
|
};
|
|
650
679
|
|
|
651
680
|
// Distributes over union types and allows picking keys from any member of the union type
|
|
@@ -663,8 +692,6 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
663
692
|
// Doesn't pick `number` from a `string` index signature
|
|
664
693
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
665
694
|
//=> {}
|
|
666
|
-
|
|
667
|
-
@group type-fest
|
|
668
695
|
*/
|
|
669
696
|
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
670
697
|
/**
|
|
@@ -718,12 +745,10 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
718
745
|
// ~~~~~~~~~~~~~~~~
|
|
719
746
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
720
747
|
```
|
|
721
|
-
|
|
722
|
-
@group type-fest
|
|
723
748
|
*/
|
|
724
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
749
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
725
750
|
//#endregion
|
|
726
|
-
//#region
|
|
751
|
+
//#region ../../node_modules/type-fest/source/except.d.ts
|
|
727
752
|
/**
|
|
728
753
|
Filter out keys from an object.
|
|
729
754
|
|
|
@@ -751,20 +776,19 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
751
776
|
|
|
752
777
|
@see {Except}
|
|
753
778
|
*/
|
|
754
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
779
|
+
type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
|
|
755
780
|
type ExceptOptions = {
|
|
756
781
|
/**
|
|
757
782
|
Disallow assigning non-specified properties.
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
@default false
|
|
783
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
784
|
+
@default false
|
|
762
785
|
*/
|
|
763
786
|
requireExactProps?: boolean;
|
|
764
787
|
};
|
|
765
788
|
type DefaultExceptOptions = {
|
|
766
789
|
requireExactProps: false;
|
|
767
790
|
};
|
|
791
|
+
|
|
768
792
|
/**
|
|
769
793
|
Create a type from an object type without certain keys.
|
|
770
794
|
|
|
@@ -779,8 +803,8 @@ This type was proposed to the TypeScript team, which declined it, saying they pr
|
|
|
779
803
|
import type {Except} from 'type-fest';
|
|
780
804
|
|
|
781
805
|
type Foo = {
|
|
782
|
-
a: number;
|
|
783
|
-
b: string;
|
|
806
|
+
a: number;
|
|
807
|
+
b: string;
|
|
784
808
|
};
|
|
785
809
|
|
|
786
810
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
@@ -800,10 +824,10 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
|
800
824
|
// Consider the following example:
|
|
801
825
|
|
|
802
826
|
type UserData = {
|
|
803
|
-
[metadata: string]: string;
|
|
804
|
-
email: string;
|
|
805
|
-
name: string;
|
|
806
|
-
role: 'admin' | 'user';
|
|
827
|
+
[metadata: string]: string;
|
|
828
|
+
email: string;
|
|
829
|
+
name: string;
|
|
830
|
+
role: 'admin' | 'user';
|
|
807
831
|
};
|
|
808
832
|
|
|
809
833
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
@@ -816,37 +840,12 @@ type PostPayload = Except<UserData, 'email'>;
|
|
|
816
840
|
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
817
841
|
```
|
|
818
842
|
|
|
819
|
-
@
|
|
843
|
+
@category Object
|
|
820
844
|
*/
|
|
821
845
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
822
|
-
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options[
|
|
823
|
-
//#endregion
|
|
824
|
-
//#region ../core/src/types/type-fest/require-at-least-one.d.ts
|
|
825
|
-
/**
|
|
826
|
-
Create a type that requires at least one of the given keys. The remaining keys are kept as is.
|
|
827
|
-
|
|
828
|
-
@example
|
|
829
|
-
```
|
|
830
|
-
import type {RequireAtLeastOne} from 'type-fest';
|
|
831
|
-
|
|
832
|
-
type Responder = {
|
|
833
|
-
text?: () => string;
|
|
834
|
-
json?: () => string;
|
|
835
|
-
secure?: boolean;
|
|
836
|
-
};
|
|
837
|
-
|
|
838
|
-
const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
839
|
-
json: () => '{"message": "ok"}',
|
|
840
|
-
secure: true
|
|
841
|
-
};
|
|
842
|
-
```
|
|
843
|
-
|
|
844
|
-
@group type-fest
|
|
845
|
-
*/
|
|
846
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireAtLeastOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
|
|
847
|
-
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
846
|
+
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
848
847
|
//#endregion
|
|
849
|
-
//#region
|
|
848
|
+
//#region ../../node_modules/type-fest/source/set-required.d.ts
|
|
850
849
|
/**
|
|
851
850
|
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
852
851
|
|
|
@@ -857,9 +856,9 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
|
857
856
|
import type {SetRequired} from 'type-fest';
|
|
858
857
|
|
|
859
858
|
type Foo = {
|
|
860
|
-
a?: number;
|
|
861
|
-
b: string;
|
|
862
|
-
c?: boolean;
|
|
859
|
+
a?: number;
|
|
860
|
+
b: string;
|
|
861
|
+
c?: boolean;
|
|
863
862
|
}
|
|
864
863
|
|
|
865
864
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
@@ -874,15 +873,32 @@ type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
|
|
|
874
873
|
//=> [number, number, number?]
|
|
875
874
|
```
|
|
876
875
|
|
|
877
|
-
@
|
|
876
|
+
@category Object
|
|
878
877
|
*/
|
|
879
|
-
type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends
|
|
878
|
+
type SetRequired<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetRequired<BaseType, Keys>;
|
|
879
|
+
type _SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? If<IsArrayReadonly<BaseType>, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
|
|
880
|
+
// Pick just the keys that are optional from the base type.
|
|
881
|
+
Except<BaseType, Keys> &
|
|
882
|
+
// Pick the keys that should be required from the base type and make them required.
|
|
883
|
+
Required<HomomorphicPick<BaseType, Keys>>>;
|
|
884
|
+
|
|
880
885
|
/**
|
|
881
886
|
Remove the optional modifier from the specified keys in an array.
|
|
882
887
|
*/
|
|
883
|
-
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown
|
|
888
|
+
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
|
|
889
|
+
? keyof TArray & `${number}` extends never
|
|
890
|
+
// Exit if `TArray` is empty (e.g., []), or
|
|
891
|
+
// `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
892
|
+
? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
|
|
893
|
+
? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
|
|
894
|
+
? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
|
|
895
|
+
// If the current element is optional, but it doesn't need to be required,
|
|
896
|
+
// then we can exit early, since no further elements can now be made required.
|
|
897
|
+
: [...Accumulator, ...TArray] : SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, TArray[0]]> : never // Should never happen, since `[(infer F)?, ...infer R]` is a top-type for arrays.
|
|
898
|
+
: never; // Should never happen
|
|
884
899
|
//#endregion
|
|
885
900
|
//#region ../core/src/types/options.d.ts
|
|
901
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
886
902
|
/**
|
|
887
903
|
* Adds an `unknown` index property to an interface.
|
|
888
904
|
*/
|
|
@@ -905,8 +921,8 @@ interface BaseOption<N extends string = string> {
|
|
|
905
921
|
}
|
|
906
922
|
/**
|
|
907
923
|
* A generic {@link Option} with either a `name` or `value` as its primary identifier.
|
|
908
|
-
* {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
|
|
909
|
-
* but corresponding props passed down to subcomponents will always be
|
|
924
|
+
* {@link OptionList}-type props on the {@link react-querybuilder!QueryBuilder QueryBuilder} component accept this type,
|
|
925
|
+
* but corresponding props passed down to subcomponents will always be augmented
|
|
910
926
|
* to {@link FullOption} first.
|
|
911
927
|
*
|
|
912
928
|
* @group Option Lists
|
|
@@ -918,11 +934,11 @@ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<Requi
|
|
|
918
934
|
*
|
|
919
935
|
* @group Option Lists
|
|
920
936
|
*/
|
|
921
|
-
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
937
|
+
type ToFlexibleOption<Opt$1 extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt$1 extends string ? FlexibleOption<Opt$1> : Opt$1, "name" | "value">>;
|
|
922
938
|
/**
|
|
923
939
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
924
940
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
925
|
-
* corresponding props sent to subcomponents will always be
|
|
941
|
+
* corresponding props sent to subcomponents will always be augmented to this
|
|
926
942
|
* type first to ensure both `name` and `value` are available.
|
|
927
943
|
*
|
|
928
944
|
* NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
|
|
@@ -946,24 +962,24 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
946
962
|
*
|
|
947
963
|
* @group Option Lists
|
|
948
964
|
*/
|
|
949
|
-
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
965
|
+
type ToFullOption<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1 : Opt$1 extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt$1 & FullOption<IdentifierType>> : never;
|
|
950
966
|
/**
|
|
951
967
|
* A group of {@link Option}s, usually within an {@link OptionList}.
|
|
952
968
|
*
|
|
953
969
|
* @group Option Lists
|
|
954
970
|
*/
|
|
955
|
-
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
971
|
+
interface OptionGroup<Opt$1 extends BaseOption = FlexibleOption> {
|
|
956
972
|
label: string;
|
|
957
|
-
options: WithUnknownIndex<Opt>[];
|
|
973
|
+
options: WithUnknownIndex<Opt$1>[];
|
|
958
974
|
}
|
|
959
975
|
/**
|
|
960
976
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
961
977
|
*
|
|
962
978
|
* @group Option Lists
|
|
963
979
|
*/
|
|
964
|
-
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
980
|
+
type FlexibleOptionGroup<Opt$1 extends BaseOption | string = BaseOption> = {
|
|
965
981
|
label: string;
|
|
966
|
-
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
982
|
+
options: (Opt$1 extends BaseFullOption ? Opt$1 : ToFlexibleOption<Opt$1>)[];
|
|
967
983
|
};
|
|
968
984
|
/**
|
|
969
985
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
@@ -971,7 +987,7 @@ type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
|
971
987
|
*
|
|
972
988
|
* @group Option Lists
|
|
973
989
|
*/
|
|
974
|
-
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
990
|
+
type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1>>[];
|
|
975
991
|
/**
|
|
976
992
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
977
993
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -979,7 +995,7 @@ type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | Flex
|
|
|
979
995
|
*
|
|
980
996
|
* @group Option Lists
|
|
981
997
|
*/
|
|
982
|
-
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
998
|
+
type FullOptionList<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1[] | OptionGroup<Opt$1>[] : ToFullOption<Opt$1>[] | OptionGroup<ToFullOption<Opt$1>>[];
|
|
983
999
|
//#endregion
|
|
984
1000
|
//#region ../core/src/types/ruleGroups.d.ts
|
|
985
1001
|
/**
|
|
@@ -989,15 +1005,21 @@ interface CommonRuleAndGroupProperties {
|
|
|
989
1005
|
path?: Path;
|
|
990
1006
|
id?: string;
|
|
991
1007
|
disabled?: boolean;
|
|
1008
|
+
/**
|
|
1009
|
+
* Whether this rule or group is muted. When muted, the rule or group
|
|
1010
|
+
* is excluded from query export formats (SQL, JSON, MongoDB, etc.).
|
|
1011
|
+
* For groups, muting recursively mutes all children.
|
|
1012
|
+
*/
|
|
1013
|
+
muted?: boolean;
|
|
992
1014
|
}
|
|
993
1015
|
/**
|
|
994
1016
|
* The main rule type. The `field`, `operator`, and `value` properties
|
|
995
1017
|
* can be narrowed with generics.
|
|
996
1018
|
*/
|
|
997
|
-
interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1019
|
+
interface RuleType<F extends string = string, O extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
998
1020
|
field: F;
|
|
999
1021
|
operator: O;
|
|
1000
|
-
value: V;
|
|
1022
|
+
value: V$1;
|
|
1001
1023
|
valueSource?: ValueSource;
|
|
1002
1024
|
match?: MatchConfig;
|
|
1003
1025
|
/**
|
|
@@ -1090,7 +1112,7 @@ type Classname = string | string[] | Record<string, any>;
|
|
|
1090
1112
|
*/
|
|
1091
1113
|
type ValueSource = "value" | "field";
|
|
1092
1114
|
/**
|
|
1093
|
-
* Type of {@link ValueEditor} that will be displayed.
|
|
1115
|
+
* Type of {@link react-querybuilder!ValueEditor ValueEditor} that will be displayed.
|
|
1094
1116
|
*/
|
|
1095
1117
|
type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
|
|
1096
1118
|
/**
|
|
@@ -1141,7 +1163,7 @@ interface BaseFullField<FieldName extends string = string, OperatorName extends
|
|
|
1141
1163
|
comparator?: string | ((f: FullField, operator: string) => boolean);
|
|
1142
1164
|
}
|
|
1143
1165
|
/**
|
|
1144
|
-
* Full field definition used in the `fields` prop of {@link QueryBuilder}.
|
|
1166
|
+
* Full field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1145
1167
|
* This type requires both `name` and `value`, but the `fields` prop itself
|
|
1146
1168
|
* can use a {@link FlexibleOption} where only one of `name` or `value` is
|
|
1147
1169
|
* required (along with `label`), or {@link Field} where only `name` and
|
|
@@ -1155,12 +1177,12 @@ interface BaseFullField<FieldName extends string = string, OperatorName extends
|
|
|
1155
1177
|
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>>;
|
|
1156
1178
|
/**
|
|
1157
1179
|
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
1158
|
-
* a number less than two will cause the default {@link ValueEditor} to render `null`.
|
|
1180
|
+
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
1159
1181
|
*/
|
|
1160
1182
|
type Arity = number | "unary" | "binary" | "ternary";
|
|
1161
1183
|
/**
|
|
1162
1184
|
* Full operator definition used in the `operators`/`getOperators` props of
|
|
1163
|
-
* {@link QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1185
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1164
1186
|
* `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
|
|
1165
1187
|
* where only one of `name` or `value` is required, or {@link FullOperator} where
|
|
1166
1188
|
* only `name` is required.
|
|
@@ -1179,7 +1201,7 @@ type ParseNumberMethodName = "enhanced" | "native" | "strict";
|
|
|
1179
1201
|
|
|
1180
1202
|
type ParseNumbersModerationLevel = "-limited" | "";
|
|
1181
1203
|
/**
|
|
1182
|
-
* Options for the `parseNumbers` prop of {@link QueryBuilder}.
|
|
1204
|
+
* Options for the `parseNumbers` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1183
1205
|
*/
|
|
1184
1206
|
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
1185
1207
|
//#endregion
|
|
@@ -1287,11 +1309,11 @@ interface FormatQueryOptions {
|
|
|
1287
1309
|
quoteValuesWith?: string;
|
|
1288
1310
|
/**
|
|
1289
1311
|
* Validator function for the entire query. Can be the same function passed
|
|
1290
|
-
* as `validator` prop to {@link QueryBuilder}.
|
|
1312
|
+
* as `validator` prop to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1291
1313
|
*/
|
|
1292
1314
|
validator?: QueryValidator;
|
|
1293
1315
|
/**
|
|
1294
|
-
* This can be the same {@link FullField} array passed to {@link QueryBuilder}, but
|
|
1316
|
+
* This can be the same {@link FullField} array passed to {@link react-querybuilder!QueryBuilder QueryBuilder}, but
|
|
1295
1317
|
* really all you need to provide is the `name` and `validator` for each field.
|
|
1296
1318
|
*
|
|
1297
1319
|
* The full field object from this array, where the field's identifying property
|
|
@@ -1299,7 +1321,7 @@ interface FormatQueryOptions {
|
|
|
1299
1321
|
*/
|
|
1300
1322
|
fields?: FlexibleOptionList<FullField>;
|
|
1301
1323
|
/**
|
|
1302
|
-
* This can be the same `getOperators` function passed to {@link QueryBuilder}.
|
|
1324
|
+
* This can be the same `getOperators` function passed to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
1303
1325
|
*
|
|
1304
1326
|
* The full operator object from this array, where the operator's identifying property
|
|
1305
1327
|
* matches the rule's `operator`, will be passed to the rule processor.
|
|
@@ -1690,5 +1712,5 @@ type RQBJsonLogicDateTimeOperations = {
|
|
|
1690
1712
|
type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boolean;
|
|
1691
1713
|
type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
|
|
1692
1714
|
//#endregion
|
|
1693
|
-
export {
|
|
1694
|
-
//# sourceMappingURL=types-
|
|
1715
|
+
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 };
|
|
1716
|
+
//# sourceMappingURL=types-BjHLhGXX.d.mts.map
|