@react-querybuilder/core 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/{arrayUtils-BF1P8iHS.mjs → arrayUtils-A_OXU9W1.mjs} +3 -75
- package/dist/arrayUtils-A_OXU9W1.mjs.map +1 -0
- package/dist/arrayUtils-QxZOZTf6.js +73 -0
- package/dist/arrayUtils-QxZOZTf6.js.map +1 -0
- package/dist/basic-DEc65Kng.d.mts +363 -0
- package/dist/basic-Dd_M2f3M.d.ts +363 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +806 -1366
- package/dist/cjs/react-querybuilder_core.cjs.development.js +455 -116
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +806 -1366
- 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-H7RhQiIc.mjs → convertQuery-CqX3rPvj.mjs} +3 -3
- package/dist/{convertQuery-H7RhQiIc.mjs.map → convertQuery-CqX3rPvj.mjs.map} +1 -1
- package/dist/{export-DyrnTh6K.d.ts → export-Dy4FckB-.d.ts} +7 -6
- package/dist/{export-r-V7bU31.d.mts → export-t1V2N8pz.d.mts} +7 -6
- package/dist/formatQuery.d.mts +3 -2
- package/dist/formatQuery.d.ts +3 -2
- package/dist/formatQuery.js +217 -87
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +217 -87
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-Cksobmln.d.ts → import-Cz8canKo.d.mts} +3 -3
- package/dist/{import-BwbbP4oU.d.mts → import-DtS9Ocx5.d.ts} +3 -3
- package/dist/{isRuleGroup-CnhYpLOM.mjs → isRuleGroup-CYcfPgbg.mjs} +2 -2
- package/dist/{isRuleGroup-CnhYpLOM.mjs.map → isRuleGroup-CYcfPgbg.mjs.map} +1 -1
- package/dist/lexer-C53tqS2p.js +406 -0
- package/dist/lexer-C53tqS2p.js.map +1 -0
- package/dist/{optGroupUtils-CXLgyg2i.js → optGroupUtils-B0hTpodo.js} +114 -1
- package/dist/optGroupUtils-B0hTpodo.js.map +1 -0
- package/dist/{optGroupUtils-Duv-M8rf.mjs → optGroupUtils-VeZ3k7-1.mjs} +86 -3
- package/dist/optGroupUtils-VeZ3k7-1.mjs.map +1 -0
- package/dist/parseCEL.d.mts +292 -11
- package/dist/parseCEL.d.ts +292 -11
- package/dist/parseCEL.js +874 -1125
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +828 -1126
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +3 -2
- package/dist/parseJSONata.d.ts +3 -2
- package/dist/parseJSONata.js +49 -77
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +4 -5
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +4 -3
- package/dist/parseJsonLogic.d.ts +4 -3
- package/dist/parseJsonLogic.js +5 -6
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +5 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +3 -2
- package/dist/parseMongoDB.d.ts +3 -2
- package/dist/parseMongoDB.js +15 -16
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +5 -6
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/{parseNumber-BtGKa58z.mjs → parseNumber-CXdMVNFx.mjs} +2 -2
- package/dist/{parseNumber-BtGKa58z.mjs.map → parseNumber-CXdMVNFx.mjs.map} +1 -1
- package/dist/{parseNumber-Bcys1kOH.js → parseNumber-D4iQDxK-.js} +1 -1
- package/dist/{parseNumber-Bcys1kOH.js.map → parseNumber-D4iQDxK-.js.map} +1 -1
- package/dist/parseSQL.d.mts +3 -2
- package/dist/parseSQL.d.ts +3 -2
- package/dist/parseSQL.js +2691 -3036
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +2691 -3037
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +3 -2
- package/dist/parseSpEL.d.ts +3 -2
- package/dist/parseSpEL.js +7 -9
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +5 -6
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-BqFEs4eV.js → prepareQueryObjects-BOUWfel5.js} +4 -5
- package/dist/prepareQueryObjects-BOUWfel5.js.map +1 -0
- package/dist/{prepareQueryObjects-CS6Wmhmf.mjs → prepareQueryObjects-DPCC-iHp.mjs} +6 -7
- package/dist/prepareQueryObjects-DPCC-iHp.mjs.map +1 -0
- package/dist/query-builder-layout.css +1 -1
- package/dist/query-builder-layout.css.map +1 -1
- package/dist/query-builder.css +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +806 -1366
- package/dist/react-querybuilder_core.legacy-esm.d.ts +806 -1366
- package/dist/react-querybuilder_core.legacy-esm.js +455 -114
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +448 -117
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +806 -1366
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_layout.scss +61 -17
- package/dist/styles/_main.scss +22 -4
- package/dist/{transformQuery-FL_nlpp5.js → transformQuery-CWDPogO5.js} +1 -1
- package/dist/{transformQuery-FL_nlpp5.js.map → transformQuery-CWDPogO5.js.map} +1 -1
- package/dist/{transformQuery-DdMvmrCh.mjs → transformQuery-DCCpjtyq.mjs} +3 -3
- package/dist/{transformQuery-DdMvmrCh.mjs.map → transformQuery-DCCpjtyq.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +2 -2
- package/package.json +14 -12
- package/dist/arrayUtils-BF1P8iHS.mjs.map +0 -1
- package/dist/arrayUtils-D5EoIsKP.js +0 -164
- package/dist/arrayUtils-D5EoIsKP.js.map +0 -1
- package/dist/basic-BfD-7CN3.d.mts +0 -1235
- package/dist/basic-C8xXKHIA.d.ts +0 -1235
- package/dist/objectUtils-BBZSfZJz.js +0 -17
- package/dist/objectUtils-BBZSfZJz.js.map +0 -1
- package/dist/objectUtils-BtWdcZVG.mjs +0 -11
- package/dist/objectUtils-BtWdcZVG.mjs.map +0 -1
- package/dist/optGroupUtils-CXLgyg2i.js.map +0 -1
- package/dist/optGroupUtils-Duv-M8rf.mjs.map +0 -1
- package/dist/prepareQueryObjects-BqFEs4eV.js.map +0 -1
- package/dist/prepareQueryObjects-CS6Wmhmf.mjs.map +0 -1
|
@@ -2,1013 +2,433 @@ import { JsonLogicAll, JsonLogicAnd, JsonLogicDoubleNegation, JsonLogicEqual, Js
|
|
|
2
2
|
import { Column, Operators, SQL, Table } from "drizzle-orm";
|
|
3
3
|
import { WhereOptions } from "sequelize";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
Returns a boolean for whether the two given types are equal.
|
|
9
|
-
|
|
10
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
11
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
12
|
-
|
|
13
|
-
Use-cases:
|
|
14
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
15
|
-
|
|
16
|
-
@example
|
|
17
|
-
```
|
|
18
|
-
import type {IsEqual} from 'type-fest';
|
|
19
|
-
|
|
20
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
21
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
22
|
-
type Includes<Value extends readonly any[], Item> =
|
|
23
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
24
|
-
? IsEqual<Value[0], Item> extends true
|
|
25
|
-
? true
|
|
26
|
-
: Includes<rest, Item>
|
|
27
|
-
: false;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
@group type-fest
|
|
31
|
-
*/
|
|
32
|
-
type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/types/type-fest/and.d.ts
|
|
35
|
-
/**
|
|
36
|
-
Returns a boolean for whether two given types are both true.
|
|
37
|
-
|
|
38
|
-
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
39
|
-
|
|
40
|
-
@example
|
|
41
|
-
```
|
|
42
|
-
import type {And} from 'type-fest';
|
|
43
|
-
|
|
44
|
-
And<true, true>;
|
|
45
|
-
//=> true
|
|
46
|
-
|
|
47
|
-
And<true, false>;
|
|
48
|
-
//=> false
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
@see {@link Or}
|
|
52
|
-
|
|
53
|
-
@group type-fest
|
|
54
|
-
*/
|
|
55
|
-
type And<A extends boolean, B extends boolean> = [A, B][number] extends true ? true : true extends [IsEqual<A, false>, IsEqual<B, false>][number] ? false : never;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/types/type-fest/is-never.d.ts
|
|
58
|
-
/**
|
|
59
|
-
Returns a boolean for whether the given type is `never`.
|
|
60
|
-
|
|
61
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
62
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
63
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
64
|
-
|
|
65
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
66
|
-
|
|
67
|
-
@example
|
|
68
|
-
```
|
|
69
|
-
import type {IsNever, And} from 'type-fest';
|
|
70
|
-
|
|
71
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
72
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
73
|
-
And<
|
|
74
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
75
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
76
|
-
>;
|
|
77
|
-
|
|
78
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
79
|
-
AreStringsEqual<I, O> extends true
|
|
80
|
-
? never
|
|
81
|
-
: void;
|
|
82
|
-
|
|
83
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
84
|
-
if (input === output) {
|
|
85
|
-
process.exit(0);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
endIfEqual('abc', 'abc');
|
|
90
|
-
//=> never
|
|
91
|
-
|
|
92
|
-
endIfEqual('abc', '123');
|
|
93
|
-
//=> void
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
@group type-fest
|
|
97
|
-
*/
|
|
98
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/types/type-fest/if-never.d.ts
|
|
101
|
-
/**
|
|
102
|
-
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
103
|
-
|
|
104
|
-
@see {@link IsNever}
|
|
105
|
-
|
|
106
|
-
@example
|
|
107
|
-
```
|
|
108
|
-
import type {IfNever} from 'type-fest';
|
|
109
|
-
|
|
110
|
-
type ShouldBeTrue = IfNever<never>;
|
|
111
|
-
//=> true
|
|
112
|
-
|
|
113
|
-
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
114
|
-
//=> 'bar'
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
@group type-fest
|
|
118
|
-
*/
|
|
119
|
-
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/types/type-fest/unknown-array.d.ts
|
|
122
|
-
/**
|
|
123
|
-
Represents an array with `unknown` value.
|
|
124
|
-
|
|
125
|
-
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
126
|
-
|
|
127
|
-
@example
|
|
128
|
-
```
|
|
129
|
-
import type {UnknownArray} from 'type-fest';
|
|
130
|
-
|
|
131
|
-
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
132
|
-
|
|
133
|
-
type A = IsArray<['foo']>;
|
|
134
|
-
//=> true
|
|
135
|
-
|
|
136
|
-
type B = IsArray<readonly number[]>;
|
|
137
|
-
//=> true
|
|
138
|
-
|
|
139
|
-
type C = IsArray<string>;
|
|
140
|
-
//=> false
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
@group type-fest
|
|
144
|
-
*/
|
|
145
|
-
type UnknownArray = readonly unknown[];
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/types/type-fest/internal/array.d.ts
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
Returns whether the given array `T` is readonly.
|
|
151
|
-
|
|
152
|
-
@group type-fest
|
|
153
|
-
*/
|
|
154
|
-
type IsArrayReadonly<T extends UnknownArray> = IfNever$1<T, false, T extends unknown[] ? false : true>;
|
|
155
|
-
/**
|
|
156
|
-
An if-else-like type that resolves depending on whether the given array is readonly.
|
|
157
|
-
|
|
158
|
-
@see {@link IsArrayReadonly}
|
|
159
|
-
|
|
160
|
-
@example
|
|
161
|
-
```
|
|
162
|
-
import type {ArrayTail} from 'type-fest';
|
|
163
|
-
|
|
164
|
-
type ReadonlyPreservingArrayTail<TArray extends readonly unknown[]> =
|
|
165
|
-
ArrayTail<TArray> extends infer Tail
|
|
166
|
-
? IfArrayReadonly<TArray, Readonly<Tail>, Tail>
|
|
167
|
-
: never;
|
|
168
|
-
|
|
169
|
-
type ReadonlyTail = ReadonlyPreservingArrayTail<readonly [string, number, boolean]>;
|
|
170
|
-
//=> readonly [number, boolean]
|
|
171
|
-
|
|
172
|
-
type NonReadonlyTail = ReadonlyPreservingArrayTail<[string, number, boolean]>;
|
|
173
|
-
//=> [number, boolean]
|
|
174
|
-
|
|
175
|
-
type ShouldBeTrue = IfArrayReadonly<readonly unknown[]>;
|
|
176
|
-
//=> true
|
|
177
|
-
|
|
178
|
-
type ShouldBeBar = IfArrayReadonly<unknown[], 'foo', 'bar'>;
|
|
179
|
-
//=> 'bar'
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
@group type-fest
|
|
183
|
-
*/
|
|
184
|
-
type IfArrayReadonly<T extends UnknownArray, TypeIfArrayReadonly = true, TypeIfNotArrayReadonly = false> = IsArrayReadonly<T> extends infer Result ? Result extends true ? TypeIfArrayReadonly : TypeIfNotArrayReadonly : never;
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/types/type-fest/internal/characters.d.ts
|
|
187
|
-
/**
|
|
188
|
-
@group type-fest
|
|
189
|
-
*/
|
|
190
|
-
type Whitespace = " " | "\n" | "\v" | "\f" | "\r" | " " | "
" | "\xA0" | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | "\u2028" | "\u2029" | " " | " " | " " | "";
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region src/types/type-fest/is-any.d.ts
|
|
193
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
194
|
-
/**
|
|
195
|
-
Returns a boolean for whether the given type is `any`.
|
|
196
|
-
|
|
197
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
198
|
-
|
|
199
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
200
|
-
|
|
201
|
-
@example
|
|
202
|
-
```
|
|
203
|
-
import type {IsAny} from 'type-fest';
|
|
204
|
-
|
|
205
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
206
|
-
const anyObject: any = {a: 1, b: 2};
|
|
207
|
-
|
|
208
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
209
|
-
return obj[key];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const typedA = get(typedObject, 'a');
|
|
213
|
-
//=> 1
|
|
214
|
-
|
|
215
|
-
const anyA = get(anyObject, 'a');
|
|
216
|
-
//=> any
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
@group type-fest
|
|
220
|
-
*/
|
|
221
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/types/type-fest/primitive.d.ts
|
|
5
|
+
//#region ../../node_modules/type-fest/source/primitive.d.ts
|
|
224
6
|
/**
|
|
225
7
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
226
8
|
|
|
227
|
-
@
|
|
9
|
+
@category Type
|
|
228
10
|
*/
|
|
229
11
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
230
12
|
//#endregion
|
|
231
|
-
//#region
|
|
232
|
-
/**
|
|
233
|
-
Returns a boolean for whether the given number is a float, like `1.5` or `-1.5`.
|
|
234
|
-
|
|
235
|
-
Use-case:
|
|
236
|
-
- If you want to make a conditional branch based on the result of whether a number is a float or not.
|
|
237
|
-
|
|
238
|
-
@example
|
|
239
|
-
```
|
|
240
|
-
import type {IsFloat, PositiveInfinity} from "type-fest";
|
|
241
|
-
|
|
242
|
-
type A = IsFloat<1.5>;
|
|
243
|
-
//=> true
|
|
244
|
-
|
|
245
|
-
type B = IsFloat<-1.5>;
|
|
246
|
-
//=> true
|
|
247
|
-
|
|
248
|
-
type C = IsFloat<1e-7>;
|
|
249
|
-
//=> true
|
|
250
|
-
|
|
251
|
-
type D = IsFloat<1.0>;
|
|
252
|
-
//=> false
|
|
253
|
-
|
|
254
|
-
type E = IsFloat<PositiveInfinity>;
|
|
255
|
-
//=> false
|
|
256
|
-
|
|
257
|
-
type F = IsFloat<1.23e+21>;
|
|
258
|
-
//=> false
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
@group type-fest
|
|
262
|
-
*/
|
|
263
|
-
type IsFloat<T> = T extends number ? `${T}` extends `${number}e${infer E extends "-" | "+"}${number}` ? E extends "-" ? true : false : `${T}` extends `${number}.${number}` ? true : false : false;
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/types/type-fest/is-integer.d.ts
|
|
13
|
+
//#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
|
|
266
14
|
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
Use-case:
|
|
270
|
-
- If you want to make a conditional branch based on the result of whether a number is an integer or not.
|
|
271
|
-
|
|
272
|
-
@example
|
|
273
|
-
```
|
|
274
|
-
import type {IsInteger, PositiveInfinity} from "type-fest";
|
|
275
|
-
|
|
276
|
-
type A = IsInteger<1>;
|
|
277
|
-
//=> true
|
|
278
|
-
|
|
279
|
-
type B = IsInteger<1.0>;
|
|
280
|
-
//=> true
|
|
281
|
-
|
|
282
|
-
type C = IsInteger<-1>;
|
|
283
|
-
//=> true
|
|
284
|
-
|
|
285
|
-
type D = IsInteger<0b10>;
|
|
286
|
-
//=> true
|
|
287
|
-
|
|
288
|
-
type E = IsInteger<0o10>;
|
|
289
|
-
//=> true
|
|
290
|
-
|
|
291
|
-
type F = IsInteger<0x10>;
|
|
292
|
-
//=> true
|
|
293
|
-
|
|
294
|
-
type G = IsInteger<1.23+21>;
|
|
295
|
-
//=> true
|
|
296
|
-
|
|
297
|
-
type H = IsInteger<1.5>;
|
|
298
|
-
//=> false
|
|
299
|
-
|
|
300
|
-
type I = IsInteger<PositiveInfinity>;
|
|
301
|
-
//=> false
|
|
302
|
-
|
|
303
|
-
type J = IsInteger<1e-7>;
|
|
304
|
-
//=> false
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
@group type-fest
|
|
308
|
-
*/
|
|
309
|
-
type IsInteger<T> = T extends bigint ? true : T extends number ? number extends T ? false : T extends PositiveInfinity | NegativeInfinity ? false : Not<IsFloat<T>> : false;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/types/type-fest/numeric.d.ts
|
|
312
|
-
/**
|
|
313
|
-
@group type-fest
|
|
314
|
-
*/
|
|
315
|
-
type Numeric = number | bigint;
|
|
316
|
-
/**
|
|
317
|
-
@group type-fest
|
|
318
|
-
*/
|
|
319
|
-
type Zero = 0 | 0n;
|
|
320
|
-
/**
|
|
321
|
-
Matches the hidden `Infinity` type.
|
|
322
|
-
|
|
323
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
324
|
-
|
|
325
|
-
@see NegativeInfinity
|
|
326
|
-
|
|
327
|
-
@group type-fest
|
|
328
|
-
*/
|
|
329
|
-
type PositiveInfinity = 1e999;
|
|
330
|
-
/**
|
|
331
|
-
Matches the hidden `-Infinity` type.
|
|
332
|
-
|
|
333
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
334
|
-
|
|
335
|
-
@see PositiveInfinity
|
|
336
|
-
|
|
337
|
-
@group type-fest
|
|
338
|
-
*/
|
|
339
|
-
type NegativeInfinity = -1e999;
|
|
340
|
-
/**
|
|
341
|
-
A finite `number`.
|
|
342
|
-
You can't pass a `bigint` as they are already guaranteed to be finite.
|
|
343
|
-
|
|
344
|
-
Use-case: Validating and documenting parameters.
|
|
345
|
-
|
|
346
|
-
Note: This can't detect `NaN`, please upvote [this issue](https://github.com/microsoft/TypeScript/issues/28682) if you want to have this type as a built-in in TypeScript.
|
|
347
|
-
|
|
348
|
-
@example
|
|
349
|
-
```
|
|
350
|
-
import type {Finite} from 'type-fest';
|
|
351
|
-
|
|
352
|
-
declare function setScore<T extends number>(length: Finite<T>): void;
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
@group type-fest
|
|
356
|
-
*/
|
|
357
|
-
type Finite<T extends number> = T extends PositiveInfinity | NegativeInfinity ? never : T;
|
|
358
|
-
/**
|
|
359
|
-
A `number` that is an integer.
|
|
360
|
-
|
|
361
|
-
Use-case: Validating and documenting parameters.
|
|
362
|
-
|
|
363
|
-
@example
|
|
364
|
-
```
|
|
365
|
-
type Integer = Integer<1>;
|
|
366
|
-
//=> 1
|
|
367
|
-
|
|
368
|
-
type IntegerWithDecimal = Integer<1.0>;
|
|
369
|
-
//=> 1
|
|
370
|
-
|
|
371
|
-
type NegativeInteger = Integer<-1>;
|
|
372
|
-
//=> -1
|
|
373
|
-
|
|
374
|
-
type Float = Integer<1.5>;
|
|
375
|
-
//=> never
|
|
376
|
-
|
|
377
|
-
// Supports non-decimal numbers
|
|
378
|
-
|
|
379
|
-
type OctalInteger: Integer<0o10>;
|
|
380
|
-
//=> 0o10
|
|
381
|
-
|
|
382
|
-
type BinaryInteger: Integer<0b10>;
|
|
383
|
-
//=> 0b10
|
|
384
|
-
|
|
385
|
-
type HexadecimalInteger: Integer<0x10>;
|
|
386
|
-
//=> 0x10
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
@example
|
|
390
|
-
```
|
|
391
|
-
import type {Integer} from 'type-fest';
|
|
392
|
-
|
|
393
|
-
declare function setYear<T extends number>(length: Integer<T>): void;
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
@see NegativeInteger
|
|
397
|
-
@see NonNegativeInteger
|
|
398
|
-
|
|
399
|
-
@group type-fest
|
|
400
|
-
*/
|
|
401
|
-
type Integer<T> = T extends unknown ? IsInteger<T> extends true ? T : never : never;
|
|
402
|
-
/**
|
|
403
|
-
A `number` that is not an integer.
|
|
404
|
-
|
|
405
|
-
Use-case: Validating and documenting parameters.
|
|
406
|
-
|
|
407
|
-
It does not accept `Infinity`.
|
|
408
|
-
|
|
409
|
-
@example
|
|
410
|
-
```
|
|
411
|
-
import type {Float} from 'type-fest';
|
|
412
|
-
|
|
413
|
-
declare function setPercentage<T extends number>(length: Float<T>): void;
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
@see Integer
|
|
417
|
-
|
|
418
|
-
@group type-fest
|
|
419
|
-
*/
|
|
420
|
-
type Float<T> = T extends unknown ? IsFloat<T> extends true ? T : never : never;
|
|
421
|
-
/**
|
|
422
|
-
A negative (`-∞ < x < 0`) `number` that is not an integer.
|
|
423
|
-
Equivalent to `Negative<Float<T>>`.
|
|
424
|
-
|
|
425
|
-
Use-case: Validating and documenting parameters.
|
|
426
|
-
|
|
427
|
-
@see Negative
|
|
428
|
-
@see Float
|
|
429
|
-
|
|
430
|
-
@group type-fest
|
|
431
|
-
*/
|
|
432
|
-
type NegativeFloat<T extends number> = Negative<Float<T>>;
|
|
433
|
-
/**
|
|
434
|
-
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
435
|
-
|
|
436
|
-
Use-case: Validating and documenting parameters.
|
|
437
|
-
|
|
438
|
-
@see NegativeInteger
|
|
439
|
-
@see NonNegative
|
|
440
|
-
|
|
441
|
-
@group type-fest
|
|
442
|
-
*/
|
|
443
|
-
type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
|
|
444
|
-
/**
|
|
445
|
-
A negative (`-∞ < x < 0`) `number` that is an integer.
|
|
446
|
-
Equivalent to `Negative<Integer<T>>`.
|
|
447
|
-
|
|
448
|
-
You can't pass a `bigint` as they are already guaranteed to be integers, instead use `Negative<T>`.
|
|
449
|
-
|
|
450
|
-
Use-case: Validating and documenting parameters.
|
|
451
|
-
|
|
452
|
-
@see Negative
|
|
453
|
-
@see Integer
|
|
454
|
-
|
|
455
|
-
@group type-fest
|
|
456
|
-
*/
|
|
457
|
-
type NegativeInteger<T extends number> = Negative<Integer<T>>;
|
|
458
|
-
/**
|
|
459
|
-
A non-negative `number`/`bigint` (`0 <= x < ∞`).
|
|
460
|
-
|
|
461
|
-
Use-case: Validating and documenting parameters.
|
|
462
|
-
|
|
463
|
-
@see NonNegativeInteger
|
|
464
|
-
@see Negative
|
|
465
|
-
|
|
466
|
-
@example
|
|
467
|
-
```
|
|
468
|
-
import type {NonNegative} from 'type-fest';
|
|
469
|
-
|
|
470
|
-
declare function setLength<T extends number>(length: NonNegative<T>): void;
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
@group type-fest
|
|
474
|
-
*/
|
|
475
|
-
type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;
|
|
476
|
-
/**
|
|
477
|
-
A non-negative (`0 <= x < ∞`) `number` that is an integer.
|
|
478
|
-
Equivalent to `NonNegative<Integer<T>>`.
|
|
479
|
-
|
|
480
|
-
You can't pass a `bigint` as they are already guaranteed to be integers, instead use `NonNegative<T>`.
|
|
481
|
-
|
|
482
|
-
Use-case: Validating and documenting parameters.
|
|
483
|
-
|
|
484
|
-
@see NonNegative
|
|
485
|
-
@see Integer
|
|
486
|
-
|
|
487
|
-
@example
|
|
488
|
-
```
|
|
489
|
-
import type {NonNegativeInteger} from 'type-fest';
|
|
490
|
-
|
|
491
|
-
declare function setLength<T extends number>(length: NonNegativeInteger<T>): void;
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
@group type-fest
|
|
495
|
-
*/
|
|
496
|
-
type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
|
|
497
|
-
/**
|
|
498
|
-
Returns a boolean for whether the given number is a negative number.
|
|
499
|
-
|
|
500
|
-
@see Negative
|
|
501
|
-
|
|
502
|
-
@example
|
|
503
|
-
```
|
|
504
|
-
import type {IsNegative} from 'type-fest';
|
|
505
|
-
|
|
506
|
-
type ShouldBeFalse = IsNegative<1>;
|
|
507
|
-
type ShouldBeTrue = IsNegative<-1>;
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
@group type-fest
|
|
511
|
-
*/
|
|
512
|
-
type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
|
|
513
|
-
//#endregion
|
|
514
|
-
//#region src/types/type-fest/is-literal.d.ts
|
|
515
|
-
/**
|
|
516
|
-
Returns a boolean for whether the given type `T` is the specified `LiteralType`.
|
|
517
|
-
|
|
518
|
-
@link https://stackoverflow.com/a/52806744/10292952
|
|
519
|
-
|
|
520
|
-
@example
|
|
521
|
-
```
|
|
522
|
-
LiteralCheck<1, number>
|
|
523
|
-
//=> true
|
|
524
|
-
|
|
525
|
-
LiteralCheck<number, number>
|
|
526
|
-
//=> false
|
|
15
|
+
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).
|
|
527
16
|
|
|
528
|
-
|
|
529
|
-
//=> false
|
|
530
|
-
```
|
|
531
|
-
*/
|
|
532
|
-
type LiteralCheck<T, LiteralType extends Primitive> = (IsNever<T> extends false ? [T] extends [LiteralType & infer U] ? [U] extends [LiteralType] ? [LiteralType] extends [U] ? false : true : false : false : false);
|
|
533
|
-
/**
|
|
534
|
-
Returns a boolean for whether the given type `T` is one of the specified literal types in `LiteralUnionType`.
|
|
17
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
535
18
|
|
|
536
19
|
@example
|
|
537
20
|
```
|
|
538
|
-
|
|
539
|
-
//=> true
|
|
21
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
540
22
|
|
|
541
|
-
|
|
542
|
-
//=> true
|
|
23
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
543
24
|
|
|
544
|
-
|
|
545
|
-
//=>
|
|
25
|
+
type Intersection = UnionToIntersection<Union>;
|
|
26
|
+
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
546
27
|
```
|
|
547
|
-
*/
|
|
548
|
-
type LiteralChecks<T, LiteralUnionType> = (IsNotFalse<LiteralUnionType extends Primitive ? LiteralCheck<T, LiteralUnionType> : never>);
|
|
549
|
-
/**
|
|
550
|
-
Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
551
|
-
|
|
552
|
-
Useful for:
|
|
553
|
-
- providing strongly-typed string manipulation functions
|
|
554
|
-
- constraining strings to be a string literal
|
|
555
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
556
28
|
|
|
557
|
-
|
|
29
|
+
A more applicable example which could make its way into your library code follows.
|
|
558
30
|
|
|
559
31
|
@example
|
|
560
32
|
```
|
|
561
|
-
import type {
|
|
562
|
-
|
|
563
|
-
type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
|
|
33
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
564
34
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
35
|
+
class CommandOne {
|
|
36
|
+
commands: {
|
|
37
|
+
a1: () => undefined,
|
|
38
|
+
b1: () => undefined,
|
|
39
|
+
}
|
|
568
40
|
}
|
|
569
41
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
```
|
|
576
|
-
// String types with infinite set of possible values return `false`.
|
|
577
|
-
|
|
578
|
-
import type {IsStringLiteral} from 'type-fest';
|
|
579
|
-
|
|
580
|
-
type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
|
|
581
|
-
//=> false
|
|
582
|
-
|
|
583
|
-
type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
|
|
584
|
-
//=> false
|
|
585
|
-
|
|
586
|
-
// This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
|
|
587
|
-
|
|
588
|
-
type Length<S extends string, Counter extends never[] = []> =
|
|
589
|
-
IsStringLiteral<S> extends false
|
|
590
|
-
? number // return `number` for infinite string types
|
|
591
|
-
: S extends `${string}${infer Tail}`
|
|
592
|
-
? Length<Tail, [...Counter, never]>
|
|
593
|
-
: Counter['length'];
|
|
594
|
-
|
|
595
|
-
type L1 = Length<Lowercase<string>>;
|
|
596
|
-
//=> number
|
|
597
|
-
|
|
598
|
-
type L2 = Length<`${number}`>;
|
|
599
|
-
//=> number
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
@group type-fest
|
|
603
|
-
*/
|
|
604
|
-
type IsStringLiteral<T> = IfNever$1<T, false, T extends string ? {} extends Record<T, never> ? false : true : false>;
|
|
605
|
-
/**
|
|
606
|
-
Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
607
|
-
|
|
608
|
-
Useful for:
|
|
609
|
-
- providing strongly-typed functions when given literal arguments
|
|
610
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
611
|
-
|
|
612
|
-
@example
|
|
613
|
-
```
|
|
614
|
-
import type {IsNumericLiteral} from 'type-fest';
|
|
615
|
-
|
|
616
|
-
// https://github.com/inocan-group/inferred-types/blob/master/src/types/boolean-logic/EndsWith.ts
|
|
617
|
-
type EndsWith<TValue, TEndsWith extends string> =
|
|
618
|
-
TValue extends string
|
|
619
|
-
? IsStringLiteral<TEndsWith> extends true
|
|
620
|
-
? IsStringLiteral<TValue> extends true
|
|
621
|
-
? TValue extends `${string}${TEndsWith}`
|
|
622
|
-
? true
|
|
623
|
-
: false
|
|
624
|
-
: boolean
|
|
625
|
-
: boolean
|
|
626
|
-
: TValue extends number
|
|
627
|
-
? IsNumericLiteral<TValue> extends true
|
|
628
|
-
? EndsWith<`${TValue}`, TEndsWith>
|
|
629
|
-
: false
|
|
630
|
-
: false;
|
|
631
|
-
|
|
632
|
-
function endsWith<Input extends string | number, End extends string>(input: Input, end: End) {
|
|
633
|
-
return `${input}`.endsWith(end) as EndsWith<Input, End>;
|
|
42
|
+
class CommandTwo {
|
|
43
|
+
commands: {
|
|
44
|
+
a2: (argA: string) => undefined,
|
|
45
|
+
b2: (argB: string) => undefined,
|
|
46
|
+
}
|
|
634
47
|
}
|
|
635
48
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
endsWith(123456, '456');
|
|
640
|
-
//=> true
|
|
641
|
-
|
|
642
|
-
const end = '123' as string;
|
|
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}
|
|
643
52
|
|
|
644
|
-
|
|
645
|
-
//=>
|
|
53
|
+
type Intersection = UnionToIntersection<Union>;
|
|
54
|
+
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
646
55
|
```
|
|
647
56
|
|
|
648
|
-
@
|
|
649
|
-
*/
|
|
650
|
-
type
|
|
57
|
+
@category Type
|
|
58
|
+
*/
|
|
59
|
+
type UnionToIntersection<Union> = (
|
|
60
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
61
|
+
// `Union` into a [distributive conditional
|
|
62
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
63
|
+
Union extends unknown
|
|
64
|
+
// The union type is used as the only argument to a function since the union
|
|
65
|
+
// of function arguments is an intersection.
|
|
66
|
+
? (distributedUnion: Union) => void
|
|
67
|
+
// This won't happen.
|
|
68
|
+
: never
|
|
69
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
70
|
+
// arguments of unions of functions as an intersection of the union.
|
|
71
|
+
) extends ((mergedIntersection: infer Intersection) => void)
|
|
72
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
73
|
+
? Intersection & Union : never;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region ../../node_modules/type-fest/source/keys-of-union.d.ts
|
|
651
76
|
/**
|
|
652
|
-
|
|
77
|
+
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
78
|
+
|
|
79
|
+
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
653
80
|
|
|
654
|
-
|
|
655
|
-
- providing strongly-typed functions when given literal arguments
|
|
656
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
81
|
+
@link https://stackoverflow.com/a/49402091
|
|
657
82
|
|
|
658
83
|
@example
|
|
659
84
|
```
|
|
660
|
-
import type {
|
|
85
|
+
import type {KeysOfUnion} from 'type-fest';
|
|
661
86
|
|
|
662
|
-
|
|
87
|
+
type A = {
|
|
88
|
+
common: string;
|
|
89
|
+
a: number;
|
|
90
|
+
};
|
|
663
91
|
|
|
664
|
-
type
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
: typeof id
|
|
669
|
-
: number | string;
|
|
92
|
+
type B = {
|
|
93
|
+
common: string;
|
|
94
|
+
b: string;
|
|
95
|
+
};
|
|
670
96
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
97
|
+
type C = {
|
|
98
|
+
common: string;
|
|
99
|
+
c: boolean;
|
|
100
|
+
};
|
|
674
101
|
|
|
675
|
-
|
|
676
|
-
//=> 123
|
|
102
|
+
type Union = A | B | C;
|
|
677
103
|
|
|
678
|
-
|
|
679
|
-
//=> '
|
|
104
|
+
type CommonKeys = keyof Union;
|
|
105
|
+
//=> 'common'
|
|
680
106
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
//=> number | string
|
|
107
|
+
type AllKeys = KeysOfUnion<Union>;
|
|
108
|
+
//=> 'common' | 'a' | 'b' | 'c'
|
|
684
109
|
```
|
|
685
110
|
|
|
686
|
-
@
|
|
111
|
+
@category Object
|
|
687
112
|
*/
|
|
688
|
-
type
|
|
113
|
+
type KeysOfUnion<ObjectType> =
|
|
114
|
+
// Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
115
|
+
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region ../../node_modules/type-fest/source/is-any.d.ts
|
|
689
118
|
/**
|
|
690
|
-
Returns a boolean for whether the given type is
|
|
119
|
+
Returns a boolean for whether the given type is `any`.
|
|
120
|
+
|
|
121
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
691
122
|
|
|
692
|
-
Useful
|
|
693
|
-
- providing strongly-typed functions when given literal arguments
|
|
694
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
123
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
695
124
|
|
|
696
125
|
@example
|
|
697
126
|
```
|
|
698
|
-
import type {
|
|
127
|
+
import type {IsAny} from 'type-fest';
|
|
699
128
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
? Obj[Key]
|
|
703
|
-
: number;
|
|
129
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
130
|
+
const anyObject: any = {a: 1, b: 2};
|
|
704
131
|
|
|
705
|
-
function get<
|
|
706
|
-
return
|
|
132
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
133
|
+
return obj[key];
|
|
707
134
|
}
|
|
708
135
|
|
|
709
|
-
const
|
|
710
|
-
const symbolValue: symbol = Symbol('value');
|
|
711
|
-
|
|
712
|
-
get({[symbolLiteral]: 1} as const, symbolLiteral);
|
|
136
|
+
const typedA = get(typedObject, 'a');
|
|
713
137
|
//=> 1
|
|
714
138
|
|
|
715
|
-
|
|
716
|
-
//=>
|
|
139
|
+
const anyA = get(anyObject, 'a');
|
|
140
|
+
//=> any
|
|
717
141
|
```
|
|
718
142
|
|
|
719
|
-
@
|
|
143
|
+
@category Type Guard
|
|
144
|
+
@category Utilities
|
|
720
145
|
*/
|
|
721
|
-
type
|
|
722
|
-
|
|
723
|
-
type
|
|
146
|
+
type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
724
149
|
/**
|
|
725
|
-
Returns a boolean for whether the given
|
|
150
|
+
Returns a boolean for whether the given key is an optional key of type.
|
|
726
151
|
|
|
727
|
-
|
|
728
|
-
- providing strongly-typed functions when given literal arguments
|
|
729
|
-
- type utilities, such as when constructing parsers and ASTs
|
|
152
|
+
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
730
153
|
|
|
731
154
|
@example
|
|
732
155
|
```
|
|
733
|
-
import type {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
? string extends B ? never : A extends `${B & string}${infer After}` ? After : A
|
|
741
|
-
: string
|
|
742
|
-
: A
|
|
743
|
-
: A;
|
|
744
|
-
|
|
745
|
-
function stripLeading<Input extends string, Strip extends string>(input: Input, strip: Strip) {
|
|
746
|
-
return input.replace(`^${strip}`, '') as StripLeading<Input, Strip>;
|
|
156
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
157
|
+
|
|
158
|
+
interface User {
|
|
159
|
+
name: string;
|
|
160
|
+
surname: string;
|
|
161
|
+
|
|
162
|
+
luckyNumber?: number;
|
|
747
163
|
}
|
|
748
164
|
|
|
749
|
-
|
|
750
|
-
|
|
165
|
+
interface Admin {
|
|
166
|
+
name: string;
|
|
167
|
+
surname?: string;
|
|
168
|
+
}
|
|
751
169
|
|
|
752
|
-
|
|
170
|
+
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
171
|
+
//=> true
|
|
753
172
|
|
|
754
|
-
|
|
755
|
-
//=>
|
|
756
|
-
```
|
|
173
|
+
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
174
|
+
//=> false
|
|
757
175
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
type IsLiteral<T> = IsPrimitive<T> extends true ? IsNotFalse<IsLiteralUnion<T>> : false;
|
|
761
|
-
//#endregion
|
|
762
|
-
//#region src/types/type-fest/trim.d.ts
|
|
763
|
-
/**
|
|
764
|
-
Remove spaces from the left side.
|
|
765
|
-
*/
|
|
766
|
-
type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
|
|
767
|
-
/**
|
|
768
|
-
Remove spaces from the right side.
|
|
769
|
-
*/
|
|
770
|
-
type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
|
|
771
|
-
/**
|
|
772
|
-
Remove leading and trailing spaces from a string.
|
|
176
|
+
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
177
|
+
//=> boolean
|
|
773
178
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
import type {Trim} from 'type-fest';
|
|
179
|
+
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
180
|
+
//=> false
|
|
777
181
|
|
|
778
|
-
|
|
779
|
-
//=>
|
|
182
|
+
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
183
|
+
//=> boolean
|
|
780
184
|
```
|
|
781
185
|
|
|
782
|
-
@
|
|
186
|
+
@category Type Guard
|
|
187
|
+
@category Utilities
|
|
783
188
|
*/
|
|
784
|
-
type
|
|
189
|
+
type IsOptionalKeyOf<Type$1 extends object, Key$1 extends keyof Type$1> = IsAny<Type$1 | Key$1> extends true ? never : Key$1 extends keyof Type$1 ? Type$1 extends Record<Key$1, Type$1[Key$1]> ? false : true : false;
|
|
785
190
|
//#endregion
|
|
786
|
-
//#region
|
|
191
|
+
//#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
|
|
787
192
|
/**
|
|
788
|
-
|
|
193
|
+
Extract all optional keys from the given type.
|
|
789
194
|
|
|
790
|
-
|
|
195
|
+
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
791
196
|
|
|
792
197
|
@example
|
|
793
198
|
```
|
|
794
|
-
import type {
|
|
795
|
-
|
|
796
|
-
Or<true, false>;
|
|
797
|
-
//=> true
|
|
798
|
-
|
|
799
|
-
Or<false, false>;
|
|
800
|
-
//=> false
|
|
801
|
-
```
|
|
802
|
-
|
|
803
|
-
@see {@link And}
|
|
199
|
+
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
804
200
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
//#endregion
|
|
809
|
-
//#region src/types/type-fest/greater-than.d.ts
|
|
810
|
-
/**
|
|
811
|
-
Returns a boolean for whether a given number is greater than another number.
|
|
201
|
+
interface User {
|
|
202
|
+
name: string;
|
|
203
|
+
surname: string;
|
|
812
204
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
import type {GreaterThan} from 'type-fest';
|
|
205
|
+
luckyNumber?: number;
|
|
206
|
+
}
|
|
816
207
|
|
|
817
|
-
|
|
818
|
-
|
|
208
|
+
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
209
|
+
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
210
|
+
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
211
|
+
};
|
|
819
212
|
|
|
820
|
-
|
|
821
|
-
|
|
213
|
+
const update1: UpdateOperation<User> = {
|
|
214
|
+
name: 'Alice'
|
|
215
|
+
};
|
|
822
216
|
|
|
823
|
-
|
|
824
|
-
|
|
217
|
+
const update2: UpdateOperation<User> = {
|
|
218
|
+
name: 'Bob',
|
|
219
|
+
luckyNumber: REMOVE_FIELD
|
|
220
|
+
};
|
|
825
221
|
```
|
|
826
222
|
|
|
827
|
-
@
|
|
223
|
+
@category Utilities
|
|
828
224
|
*/
|
|
829
|
-
type
|
|
225
|
+
type OptionalKeysOf<Type$1 extends object> = Type$1 extends unknown // For distributing `Type`
|
|
226
|
+
? (keyof { [Key in keyof Type$1 as IsOptionalKeyOf<Type$1, Key> extends false ? never : Key]: never }) & keyof Type$1 // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
227
|
+
: never;
|
|
830
228
|
//#endregion
|
|
831
|
-
//#region
|
|
229
|
+
//#region ../../node_modules/type-fest/source/required-keys-of.d.ts
|
|
832
230
|
/**
|
|
833
|
-
|
|
231
|
+
Extract all required keys from the given type.
|
|
232
|
+
|
|
233
|
+
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...
|
|
834
234
|
|
|
835
235
|
@example
|
|
836
236
|
```
|
|
837
|
-
import type {
|
|
237
|
+
import type {RequiredKeysOf} from 'type-fest';
|
|
838
238
|
|
|
839
|
-
|
|
840
|
-
//=> true
|
|
239
|
+
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
841
240
|
|
|
842
|
-
|
|
843
|
-
|
|
241
|
+
interface User {
|
|
242
|
+
name: string;
|
|
243
|
+
surname: string;
|
|
844
244
|
|
|
845
|
-
|
|
846
|
-
|
|
245
|
+
luckyNumber?: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
249
|
+
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
847
250
|
```
|
|
848
251
|
|
|
849
|
-
@
|
|
252
|
+
@category Utilities
|
|
850
253
|
*/
|
|
851
|
-
type
|
|
254
|
+
type RequiredKeysOf<Type$1 extends object> = Type$1 extends unknown // For distributing `Type`
|
|
255
|
+
? Exclude<keyof Type$1, OptionalKeysOf<Type$1>> : never;
|
|
852
256
|
//#endregion
|
|
853
|
-
//#region
|
|
257
|
+
//#region ../../node_modules/type-fest/source/is-never.d.ts
|
|
854
258
|
/**
|
|
855
|
-
Returns a boolean for whether
|
|
259
|
+
Returns a boolean for whether the given type is `never`.
|
|
260
|
+
|
|
261
|
+
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
262
|
+
@link https://stackoverflow.com/a/53984913/10292952
|
|
263
|
+
@link https://www.zhenghao.io/posts/ts-never
|
|
264
|
+
|
|
265
|
+
Useful in type utilities, such as checking if something does not occur.
|
|
856
266
|
|
|
857
267
|
@example
|
|
858
268
|
```
|
|
859
|
-
import type {
|
|
269
|
+
import type {IsNever, And} from 'type-fest';
|
|
860
270
|
|
|
861
|
-
|
|
862
|
-
|
|
271
|
+
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
272
|
+
type AreStringsEqual<A extends string, B extends string> =
|
|
273
|
+
And<
|
|
274
|
+
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
275
|
+
IsNever<Exclude<B, A>> extends true ? true : false
|
|
276
|
+
>;
|
|
863
277
|
|
|
864
|
-
|
|
865
|
-
|
|
278
|
+
type EndIfEqual<I extends string, O extends string> =
|
|
279
|
+
AreStringsEqual<I, O> extends true
|
|
280
|
+
? never
|
|
281
|
+
: void;
|
|
866
282
|
|
|
867
|
-
|
|
868
|
-
|
|
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
|
+
}
|
|
288
|
+
|
|
289
|
+
endIfEqual('abc', 'abc');
|
|
290
|
+
//=> never
|
|
291
|
+
|
|
292
|
+
endIfEqual('abc', '123');
|
|
293
|
+
//=> void
|
|
869
294
|
```
|
|
870
295
|
|
|
871
|
-
@
|
|
296
|
+
@category Type Guard
|
|
297
|
+
@category Utilities
|
|
872
298
|
*/
|
|
873
|
-
type
|
|
299
|
+
type IsNever<T$1> = [T$1] extends [never] ? true : false;
|
|
874
300
|
//#endregion
|
|
875
|
-
//#region
|
|
301
|
+
//#region ../../node_modules/type-fest/source/if.d.ts
|
|
876
302
|
/**
|
|
877
|
-
|
|
303
|
+
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
878
304
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
@link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
305
|
+
Use-cases:
|
|
306
|
+
- 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'>`.
|
|
882
307
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
//#endregion
|
|
887
|
-
//#region src/types/type-fest/internal/string.d.ts
|
|
888
|
-
/**
|
|
889
|
-
Converts a numeric string to a number.
|
|
308
|
+
Note:
|
|
309
|
+
- 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'`.
|
|
310
|
+
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
890
311
|
|
|
891
312
|
@example
|
|
892
313
|
```
|
|
893
|
-
|
|
894
|
-
//=> 1234
|
|
314
|
+
import {If} from 'type-fest';
|
|
895
315
|
|
|
896
|
-
type
|
|
897
|
-
//=>
|
|
316
|
+
type A = If<true, 'yes', 'no'>;
|
|
317
|
+
//=> 'yes'
|
|
898
318
|
|
|
899
|
-
type
|
|
900
|
-
//=>
|
|
319
|
+
type B = If<false, 'yes', 'no'>;
|
|
320
|
+
//=> 'no'
|
|
901
321
|
|
|
902
|
-
type
|
|
903
|
-
//=>
|
|
322
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
323
|
+
//=> 'yes' | 'no'
|
|
904
324
|
|
|
905
|
-
type
|
|
906
|
-
//=>
|
|
325
|
+
type D = If<any, 'yes', 'no'>;
|
|
326
|
+
//=> 'yes' | 'no'
|
|
907
327
|
|
|
908
|
-
type
|
|
909
|
-
//=>
|
|
328
|
+
type E = If<never, 'yes', 'no'>;
|
|
329
|
+
//=> 'no'
|
|
910
330
|
```
|
|
911
331
|
|
|
912
|
-
@group type-fest
|
|
913
|
-
*/
|
|
914
|
-
type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends "Infinity" ? PositiveInfinity : S extends "-Infinity" ? NegativeInfinity : never;
|
|
915
|
-
/**
|
|
916
|
-
Returns an array of the characters of the string.
|
|
917
|
-
|
|
918
332
|
@example
|
|
919
333
|
```
|
|
920
|
-
|
|
921
|
-
//=> ['a', 'b', 'c', 'd', 'e']
|
|
334
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
922
335
|
|
|
923
|
-
|
|
924
|
-
//=>
|
|
925
|
-
```
|
|
336
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
337
|
+
//=> 'not any'
|
|
926
338
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
Returns the length of the given string.
|
|
339
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
340
|
+
//=> 'is never'
|
|
341
|
+
```
|
|
932
342
|
|
|
933
343
|
@example
|
|
934
344
|
```
|
|
935
|
-
|
|
936
|
-
//=> 5
|
|
345
|
+
import {If, IsEqual} from 'type-fest';
|
|
937
346
|
|
|
938
|
-
|
|
939
|
-
//=> never
|
|
940
|
-
```
|
|
347
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
941
348
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
type StringLength<S extends string> = string extends S ? never : StringToArray<S>["length"];
|
|
945
|
-
/**
|
|
946
|
-
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
|
|
349
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
350
|
+
//=> 'equal'
|
|
947
351
|
|
|
948
|
-
|
|
352
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
353
|
+
//=> 'not equal'
|
|
949
354
|
```
|
|
950
|
-
SameLengthPositiveNumericStringGt<'50', '10'>;
|
|
951
|
-
//=> true
|
|
952
355
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
```
|
|
356
|
+
@category Type Guard
|
|
357
|
+
@category Utilities
|
|
956
358
|
*/
|
|
957
|
-
type
|
|
958
|
-
|
|
359
|
+
type If<Type$1 extends boolean, IfBranch, ElseBranch> = IsNever<Type$1> extends true ? ElseBranch : Type$1 extends true ? IfBranch : ElseBranch;
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region ../../node_modules/type-fest/source/unknown-array.d.ts
|
|
959
362
|
/**
|
|
960
|
-
|
|
363
|
+
Represents an array with `unknown` value.
|
|
364
|
+
|
|
365
|
+
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
961
366
|
|
|
962
367
|
@example
|
|
963
368
|
```
|
|
964
|
-
|
|
369
|
+
import type {UnknownArray} from 'type-fest';
|
|
370
|
+
|
|
371
|
+
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
372
|
+
|
|
373
|
+
type A = IsArray<['foo']>;
|
|
965
374
|
//=> true
|
|
966
375
|
|
|
967
|
-
|
|
968
|
-
//=>
|
|
376
|
+
type B = IsArray<readonly number[]>;
|
|
377
|
+
//=> true
|
|
969
378
|
|
|
970
|
-
|
|
379
|
+
type C = IsArray<string>;
|
|
971
380
|
//=> false
|
|
972
381
|
```
|
|
973
382
|
|
|
974
|
-
@
|
|
383
|
+
@category Type
|
|
384
|
+
@category Array
|
|
385
|
+
*/
|
|
386
|
+
type UnknownArray = readonly unknown[];
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region ../../node_modules/type-fest/source/internal/type.d.ts
|
|
389
|
+
/**
|
|
390
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
975
391
|
*/
|
|
976
|
-
type
|
|
392
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
977
393
|
/**
|
|
978
|
-
|
|
394
|
+
Test if the given function has multiple call signatures.
|
|
979
395
|
|
|
980
|
-
|
|
981
|
-
```
|
|
982
|
-
PositiveNumericCharacterGt<'5', '1'>;
|
|
983
|
-
//=> true
|
|
396
|
+
Needed to handle the case of a single call signature with properties.
|
|
984
397
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
```
|
|
398
|
+
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
399
|
+
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
988
400
|
*/
|
|
989
|
-
type
|
|
990
|
-
|
|
991
|
-
|
|
401
|
+
type HasMultipleCallSignatures<T$1 extends (...arguments_: any[]) => unknown> = T$1 extends {
|
|
402
|
+
(...arguments_: infer A): unknown;
|
|
403
|
+
(...arguments_: infer B): unknown;
|
|
404
|
+
} ? B extends A ? A extends B ? false : true : true : false;
|
|
992
405
|
/**
|
|
993
|
-
|
|
406
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
994
407
|
|
|
995
408
|
@example
|
|
996
409
|
```
|
|
997
|
-
|
|
998
|
-
|
|
410
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
411
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
412
|
+
//=> 'VALID'
|
|
999
413
|
|
|
1000
|
-
|
|
1001
|
-
|
|
414
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
415
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
416
|
+
//=> 'IS_ANY'
|
|
1002
417
|
|
|
1003
|
-
|
|
1004
|
-
|
|
418
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
419
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
420
|
+
//=> 'IS_NEVER'
|
|
1005
421
|
```
|
|
1006
|
-
|
|
1007
|
-
@group type-fest
|
|
1008
422
|
*/
|
|
1009
|
-
type
|
|
423
|
+
type IfNotAnyOrNever<T$1, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T$1>, IfAny, If<IsNever<T$1>, IfNever, IfNotAnyOrNever$1>>;
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region ../../node_modules/type-fest/source/internal/array.d.ts
|
|
426
|
+
/**
|
|
427
|
+
Returns whether the given array `T` is readonly.
|
|
428
|
+
*/
|
|
429
|
+
type IsArrayReadonly<T$1 extends UnknownArray> = If<IsNever<T$1>, false, T$1 extends unknown[] ? false : true>;
|
|
1010
430
|
//#endregion
|
|
1011
|
-
//#region
|
|
431
|
+
//#region ../../node_modules/type-fest/source/simplify.d.ts
|
|
1012
432
|
/**
|
|
1013
433
|
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.
|
|
1014
434
|
|
|
@@ -1017,13 +437,13 @@ Useful to flatten the type output to improve type hints shown in editors. And al
|
|
|
1017
437
|
import type {Simplify} from 'type-fest';
|
|
1018
438
|
|
|
1019
439
|
type PositionProps = {
|
|
1020
|
-
top: number;
|
|
1021
|
-
left: number;
|
|
440
|
+
top: number;
|
|
441
|
+
left: number;
|
|
1022
442
|
};
|
|
1023
443
|
|
|
1024
444
|
type SizeProps = {
|
|
1025
|
-
width: number;
|
|
1026
|
-
height: number;
|
|
445
|
+
width: number;
|
|
446
|
+
height: number;
|
|
1027
447
|
};
|
|
1028
448
|
|
|
1029
449
|
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
@@ -1039,15 +459,15 @@ If the type definition must be an interface (perhaps it was defined in a third-p
|
|
|
1039
459
|
import type {Simplify} from 'type-fest';
|
|
1040
460
|
|
|
1041
461
|
interface SomeInterface {
|
|
1042
|
-
foo: number;
|
|
1043
|
-
bar?: string;
|
|
1044
|
-
baz: number | undefined;
|
|
462
|
+
foo: number;
|
|
463
|
+
bar?: string;
|
|
464
|
+
baz: number | undefined;
|
|
1045
465
|
}
|
|
1046
466
|
|
|
1047
467
|
type SomeType = {
|
|
1048
|
-
foo: number;
|
|
1049
|
-
bar?: string;
|
|
1050
|
-
baz: number | undefined;
|
|
468
|
+
foo: number;
|
|
469
|
+
bar?: string;
|
|
470
|
+
baz: number | undefined;
|
|
1051
471
|
};
|
|
1052
472
|
|
|
1053
473
|
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
@@ -1064,163 +484,42 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
1064
484
|
|
|
1065
485
|
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
1066
486
|
@see SimplifyDeep
|
|
1067
|
-
|
|
1068
|
-
@group type-fest
|
|
1069
|
-
*/
|
|
1070
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
1071
|
-
//#endregion
|
|
1072
|
-
//#region src/types/type-fest/union-to-intersection.d.ts
|
|
1073
|
-
/**
|
|
1074
|
-
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).
|
|
1075
|
-
|
|
1076
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
1077
|
-
|
|
1078
|
-
@example
|
|
1079
|
-
```
|
|
1080
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
1081
|
-
|
|
1082
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
1083
|
-
|
|
1084
|
-
type Intersection = UnionToIntersection<Union>;
|
|
1085
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
A more applicable example which could make its way into your library code follows.
|
|
1089
|
-
|
|
1090
|
-
@example
|
|
1091
|
-
```
|
|
1092
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
1093
|
-
|
|
1094
|
-
class CommandOne {
|
|
1095
|
-
commands: {
|
|
1096
|
-
a1: () => undefined,
|
|
1097
|
-
b1: () => undefined,
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
class CommandTwo {
|
|
1102
|
-
commands: {
|
|
1103
|
-
a2: (argA: string) => undefined,
|
|
1104
|
-
b2: (argB: string) => undefined,
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
1109
|
-
type Union = typeof union;
|
|
1110
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
1111
|
-
|
|
1112
|
-
type Intersection = UnionToIntersection<Union>;
|
|
1113
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
1114
|
-
```
|
|
1115
|
-
|
|
1116
|
-
@group type-fest
|
|
1117
|
-
*/
|
|
1118
|
-
type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
|
|
1119
|
-
//#endregion
|
|
1120
|
-
//#region src/types/type-fest/keys-of-union.d.ts
|
|
1121
|
-
/**
|
|
1122
|
-
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
1123
|
-
|
|
1124
|
-
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
|
|
1125
|
-
|
|
1126
|
-
@link https://stackoverflow.com/a/49402091
|
|
1127
|
-
|
|
1128
|
-
@example
|
|
1129
|
-
```
|
|
1130
|
-
import type {KeysOfUnion} from 'type-fest';
|
|
1131
|
-
|
|
1132
|
-
type A = {
|
|
1133
|
-
common: string;
|
|
1134
|
-
a: number;
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
type B = {
|
|
1138
|
-
common: string;
|
|
1139
|
-
b: string;
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
type C = {
|
|
1143
|
-
common: string;
|
|
1144
|
-
c: boolean;
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
type Union = A | B | C;
|
|
1148
|
-
|
|
1149
|
-
type CommonKeys = keyof Union;
|
|
1150
|
-
//=> 'common'
|
|
1151
|
-
|
|
1152
|
-
type AllKeys = KeysOfUnion<Union>;
|
|
1153
|
-
//=> 'common' | 'a' | 'b' | 'c'
|
|
1154
|
-
```
|
|
1155
|
-
|
|
1156
|
-
@group type-fest
|
|
1157
|
-
*/
|
|
1158
|
-
type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
1159
|
-
//#endregion
|
|
1160
|
-
//#region src/types/type-fest/optional-keys-of.d.ts
|
|
1161
|
-
/**
|
|
1162
|
-
Extract all optional keys from the given type.
|
|
1163
|
-
|
|
1164
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
1165
|
-
|
|
1166
|
-
@example
|
|
1167
|
-
```
|
|
1168
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
1169
|
-
|
|
1170
|
-
interface User {
|
|
1171
|
-
name: string;
|
|
1172
|
-
surname: string;
|
|
1173
|
-
|
|
1174
|
-
luckyNumber?: number;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
1178
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
1179
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
const update1: UpdateOperation<User> = {
|
|
1183
|
-
name: 'Alice'
|
|
1184
|
-
};
|
|
1185
|
-
|
|
1186
|
-
const update2: UpdateOperation<User> = {
|
|
1187
|
-
name: 'Bob',
|
|
1188
|
-
luckyNumber: REMOVE_FIELD
|
|
1189
|
-
};
|
|
1190
|
-
```
|
|
1191
|
-
|
|
1192
|
-
@group type-fest
|
|
487
|
+
@category Object
|
|
1193
488
|
*/
|
|
1194
|
-
type
|
|
489
|
+
type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
|
|
1195
490
|
//#endregion
|
|
1196
|
-
//#region
|
|
491
|
+
//#region ../../node_modules/type-fest/source/is-equal.d.ts
|
|
1197
492
|
/**
|
|
1198
|
-
|
|
493
|
+
Returns a boolean for whether the two given types are equal.
|
|
1199
494
|
|
|
1200
|
-
|
|
495
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
496
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
497
|
+
|
|
498
|
+
Use-cases:
|
|
499
|
+
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
1201
500
|
|
|
1202
501
|
@example
|
|
1203
502
|
```
|
|
1204
|
-
import type {
|
|
1205
|
-
|
|
1206
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
1207
|
-
|
|
1208
|
-
interface User {
|
|
1209
|
-
name: string;
|
|
1210
|
-
surname: string;
|
|
1211
|
-
|
|
1212
|
-
luckyNumber?: number;
|
|
1213
|
-
}
|
|
503
|
+
import type {IsEqual} from 'type-fest';
|
|
1214
504
|
|
|
1215
|
-
|
|
1216
|
-
|
|
505
|
+
// This type returns a boolean for whether the given array includes the given item.
|
|
506
|
+
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
507
|
+
type Includes<Value extends readonly any[], Item> =
|
|
508
|
+
Value extends readonly [Value[0], ...infer rest]
|
|
509
|
+
? IsEqual<Value[0], Item> extends true
|
|
510
|
+
? true
|
|
511
|
+
: Includes<rest, Item>
|
|
512
|
+
: false;
|
|
1217
513
|
```
|
|
1218
514
|
|
|
1219
|
-
@
|
|
515
|
+
@category Type Guard
|
|
516
|
+
@category Utilities
|
|
1220
517
|
*/
|
|
1221
|
-
type
|
|
518
|
+
type IsEqual<A$1, B$1> = [A$1, B$1] extends [infer AA, infer BB] ? [AA] extends [never] ? [BB] extends [never] ? true : false : [BB] extends [never] ? false : _IsEqual<AA, BB> : false;
|
|
519
|
+
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
520
|
+
type _IsEqual<A$1, B$1> = (<G>() => G extends A$1 & G | G ? 1 : 2) extends (<G>() => G extends B$1 & G | G ? 1 : 2) ? true : false;
|
|
1222
521
|
//#endregion
|
|
1223
|
-
//#region
|
|
522
|
+
//#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
|
|
1224
523
|
/**
|
|
1225
524
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
1226
525
|
|
|
@@ -1246,13 +545,13 @@ Instead of causing a type error like the above, you can also use a [conditional
|
|
|
1246
545
|
|
|
1247
546
|
```
|
|
1248
547
|
type Indexed = {} extends Record<string, unknown>
|
|
1249
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1250
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
548
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
549
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
1251
550
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
1252
551
|
|
|
1253
552
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
1254
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
1255
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
553
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
554
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
1256
555
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
1257
556
|
```
|
|
1258
557
|
|
|
@@ -1262,8 +561,8 @@ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-type
|
|
|
1262
561
|
import type {OmitIndexSignature} from 'type-fest';
|
|
1263
562
|
|
|
1264
563
|
type OmitIndexSignature<ObjectType> = {
|
|
1265
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
1266
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
564
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
565
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
1267
566
|
};
|
|
1268
567
|
```
|
|
1269
568
|
|
|
@@ -1273,12 +572,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
1273
572
|
import type {OmitIndexSignature} from 'type-fest';
|
|
1274
573
|
|
|
1275
574
|
type OmitIndexSignature<ObjectType> = {
|
|
1276
|
-
[KeyType in keyof ObjectType
|
|
1277
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
1278
|
-
as {} extends Record<KeyType, unknown>
|
|
1279
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
1280
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
1281
|
-
]: ObjectType[KeyType];
|
|
575
|
+
[KeyType in keyof ObjectType
|
|
576
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
577
|
+
as {} extends Record<KeyType, unknown>
|
|
578
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
579
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
580
|
+
]: ObjectType[KeyType];
|
|
1282
581
|
};
|
|
1283
582
|
```
|
|
1284
583
|
|
|
@@ -1289,19 +588,19 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
1289
588
|
import type {OmitIndexSignature} from 'type-fest';
|
|
1290
589
|
|
|
1291
590
|
interface Example {
|
|
1292
|
-
// These index signatures will be removed.
|
|
1293
|
-
[x: string]: any
|
|
1294
|
-
[x: number]: any
|
|
1295
|
-
[x: symbol]: any
|
|
1296
|
-
[x: `head-${string}`]: string
|
|
1297
|
-
[x: `${string}-tail`]: string
|
|
1298
|
-
[x: `head-${string}-tail`]: string
|
|
1299
|
-
[x: `${bigint}`]: string
|
|
1300
|
-
[x: `embedded-${number}`]: string
|
|
1301
|
-
|
|
1302
|
-
// These explicitly defined keys will remain.
|
|
1303
|
-
foo: 'bar';
|
|
1304
|
-
qux?: 'baz';
|
|
591
|
+
// These index signatures will be removed.
|
|
592
|
+
[x: string]: any
|
|
593
|
+
[x: number]: any
|
|
594
|
+
[x: symbol]: any
|
|
595
|
+
[x: `head-${string}`]: string
|
|
596
|
+
[x: `${string}-tail`]: string
|
|
597
|
+
[x: `head-${string}-tail`]: string
|
|
598
|
+
[x: `${bigint}`]: string
|
|
599
|
+
[x: `embedded-${number}`]: string
|
|
600
|
+
|
|
601
|
+
// These explicitly defined keys will remain.
|
|
602
|
+
foo: 'bar';
|
|
603
|
+
qux?: 'baz';
|
|
1305
604
|
}
|
|
1306
605
|
|
|
1307
606
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
@@ -1309,12 +608,11 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
1309
608
|
```
|
|
1310
609
|
|
|
1311
610
|
@see PickIndexSignature
|
|
1312
|
-
|
|
1313
|
-
@group type-fest
|
|
611
|
+
@category Object
|
|
1314
612
|
*/
|
|
1315
613
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
1316
614
|
//#endregion
|
|
1317
|
-
//#region
|
|
615
|
+
//#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
|
|
1318
616
|
/**
|
|
1319
617
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1320
618
|
|
|
@@ -1327,21 +625,21 @@ import type {PickIndexSignature} from 'type-fest';
|
|
|
1327
625
|
declare const symbolKey: unique symbol;
|
|
1328
626
|
|
|
1329
627
|
type Example = {
|
|
1330
|
-
// These index signatures will remain.
|
|
1331
|
-
[x: string]: unknown;
|
|
1332
|
-
[x: number]: unknown;
|
|
1333
|
-
[x: symbol]: unknown;
|
|
1334
|
-
[x: `head-${string}`]: string;
|
|
1335
|
-
[x: `${string}-tail`]: string;
|
|
1336
|
-
[x: `head-${string}-tail`]: string;
|
|
1337
|
-
[x: `${bigint}`]: string;
|
|
1338
|
-
[x: `embedded-${number}`]: string;
|
|
1339
|
-
|
|
1340
|
-
// These explicitly defined keys will be removed.
|
|
1341
|
-
['kebab-case-key']: string;
|
|
1342
|
-
[symbolKey]: string;
|
|
1343
|
-
foo: 'bar';
|
|
1344
|
-
qux?: 'baz';
|
|
628
|
+
// These index signatures will remain.
|
|
629
|
+
[x: string]: unknown;
|
|
630
|
+
[x: number]: unknown;
|
|
631
|
+
[x: symbol]: unknown;
|
|
632
|
+
[x: `head-${string}`]: string;
|
|
633
|
+
[x: `${string}-tail`]: string;
|
|
634
|
+
[x: `head-${string}-tail`]: string;
|
|
635
|
+
[x: `${bigint}`]: string;
|
|
636
|
+
[x: `embedded-${number}`]: string;
|
|
637
|
+
|
|
638
|
+
// These explicitly defined keys will be removed.
|
|
639
|
+
['kebab-case-key']: string;
|
|
640
|
+
[symbolKey]: string;
|
|
641
|
+
foo: 'bar';
|
|
642
|
+
qux?: 'baz';
|
|
1345
643
|
};
|
|
1346
644
|
|
|
1347
645
|
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
@@ -1358,13 +656,14 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
1358
656
|
```
|
|
1359
657
|
|
|
1360
658
|
@see OmitIndexSignature
|
|
1361
|
-
|
|
1362
|
-
@group type-fest
|
|
659
|
+
@category Object
|
|
1363
660
|
*/
|
|
1364
661
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
1365
662
|
//#endregion
|
|
1366
|
-
//#region
|
|
663
|
+
//#region ../../node_modules/type-fest/source/merge.d.ts
|
|
664
|
+
// Merges two objects without worrying about index signatures.
|
|
1367
665
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
666
|
+
|
|
1368
667
|
/**
|
|
1369
668
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
1370
669
|
|
|
@@ -1373,17 +672,17 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
1373
672
|
import type {Merge} from 'type-fest';
|
|
1374
673
|
|
|
1375
674
|
interface Foo {
|
|
1376
|
-
[x: string]: unknown;
|
|
1377
|
-
[x: number]: unknown;
|
|
1378
|
-
foo: string;
|
|
1379
|
-
bar: symbol;
|
|
675
|
+
[x: string]: unknown;
|
|
676
|
+
[x: number]: unknown;
|
|
677
|
+
foo: string;
|
|
678
|
+
bar: symbol;
|
|
1380
679
|
}
|
|
1381
680
|
|
|
1382
681
|
type Bar = {
|
|
1383
|
-
[x: number]: number;
|
|
1384
|
-
[x: symbol]: unknown;
|
|
1385
|
-
bar: Date;
|
|
1386
|
-
baz: boolean;
|
|
682
|
+
[x: number]: number;
|
|
683
|
+
[x: symbol]: unknown;
|
|
684
|
+
bar: Date;
|
|
685
|
+
baz: boolean;
|
|
1387
686
|
};
|
|
1388
687
|
|
|
1389
688
|
export type FooBar = Merge<Foo, Bar>;
|
|
@@ -1397,94 +696,11 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
1397
696
|
// }
|
|
1398
697
|
```
|
|
1399
698
|
|
|
1400
|
-
@
|
|
699
|
+
@category Object
|
|
1401
700
|
*/
|
|
1402
701
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
1403
702
|
//#endregion
|
|
1404
|
-
//#region
|
|
1405
|
-
/**
|
|
1406
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
1407
|
-
|
|
1408
|
-
@see {@link IsAny}
|
|
1409
|
-
|
|
1410
|
-
@example
|
|
1411
|
-
```
|
|
1412
|
-
import type {IfAny} from 'type-fest';
|
|
1413
|
-
|
|
1414
|
-
type ShouldBeTrue = IfAny<any>;
|
|
1415
|
-
//=> true
|
|
1416
|
-
|
|
1417
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
1418
|
-
//=> 'bar'
|
|
1419
|
-
```
|
|
1420
|
-
|
|
1421
|
-
@group type-fest
|
|
1422
|
-
*/
|
|
1423
|
-
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
1424
|
-
//#endregion
|
|
1425
|
-
//#region src/types/type-fest/internal/type.d.ts
|
|
1426
|
-
/**
|
|
1427
|
-
Returns a boolean for whether the given `boolean` is not `false`.
|
|
1428
|
-
|
|
1429
|
-
@group type-fest
|
|
1430
|
-
*/
|
|
1431
|
-
type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
|
|
1432
|
-
/**
|
|
1433
|
-
Returns a boolean for whether the given type is primitive value or primitive type.
|
|
1434
|
-
|
|
1435
|
-
@example
|
|
1436
|
-
```
|
|
1437
|
-
IsPrimitive<'string'>
|
|
1438
|
-
//=> true
|
|
1439
|
-
|
|
1440
|
-
IsPrimitive<string>
|
|
1441
|
-
//=> true
|
|
1442
|
-
|
|
1443
|
-
IsPrimitive<Object>
|
|
1444
|
-
//=> false
|
|
1445
|
-
```
|
|
1446
|
-
|
|
1447
|
-
@group type-fest
|
|
1448
|
-
*/
|
|
1449
|
-
type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
1450
|
-
/**
|
|
1451
|
-
Returns a boolean for whether A is false.
|
|
1452
|
-
|
|
1453
|
-
@example
|
|
1454
|
-
```
|
|
1455
|
-
Not<true>;
|
|
1456
|
-
//=> false
|
|
1457
|
-
|
|
1458
|
-
Not<false>;
|
|
1459
|
-
//=> true
|
|
1460
|
-
```
|
|
1461
|
-
|
|
1462
|
-
@group type-fest
|
|
1463
|
-
*/
|
|
1464
|
-
type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
|
|
1465
|
-
/**
|
|
1466
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
1467
|
-
|
|
1468
|
-
@example
|
|
1469
|
-
```
|
|
1470
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
1471
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
1472
|
-
//=> 'VALID'
|
|
1473
|
-
|
|
1474
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
1475
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
1476
|
-
//=> 'IS_ANY'
|
|
1477
|
-
|
|
1478
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
1479
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
1480
|
-
//=> 'IS_NEVER'
|
|
1481
|
-
```
|
|
1482
|
-
|
|
1483
|
-
@group type-fest
|
|
1484
|
-
*/
|
|
1485
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
1486
|
-
//#endregion
|
|
1487
|
-
//#region src/types/type-fest/internal/object.d.ts
|
|
703
|
+
//#region ../../node_modules/type-fest/source/internal/object.d.ts
|
|
1488
704
|
/**
|
|
1489
705
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
1490
706
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -1495,15 +711,15 @@ Works similar to the built-in `Pick` utility type, except for the following diff
|
|
|
1495
711
|
@example
|
|
1496
712
|
```
|
|
1497
713
|
type ImageUpload = {
|
|
1498
|
-
url: string;
|
|
1499
|
-
size: number;
|
|
1500
|
-
thumbnailUrl: string;
|
|
714
|
+
url: string;
|
|
715
|
+
size: number;
|
|
716
|
+
thumbnailUrl: string;
|
|
1501
717
|
};
|
|
1502
718
|
|
|
1503
719
|
type VideoUpload = {
|
|
1504
|
-
url: string;
|
|
1505
|
-
duration: number;
|
|
1506
|
-
encodingFormat: string;
|
|
720
|
+
url: string;
|
|
721
|
+
duration: number;
|
|
722
|
+
encodingFormat: string;
|
|
1507
723
|
};
|
|
1508
724
|
|
|
1509
725
|
// Distributes over union types and allows picking keys from any member of the union type
|
|
@@ -1521,10 +737,8 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
1521
737
|
// Doesn't pick `number` from a `string` index signature
|
|
1522
738
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
1523
739
|
//=> {}
|
|
1524
|
-
|
|
1525
|
-
@group type-fest
|
|
1526
740
|
*/
|
|
1527
|
-
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
741
|
+
type HomomorphicPick<T$1, Keys extends KeysOfUnion<T$1>> = { [P in keyof T$1 as Extract<P, Keys>]: T$1[P] };
|
|
1528
742
|
/**
|
|
1529
743
|
Merges user specified options with default options.
|
|
1530
744
|
|
|
@@ -1576,12 +790,10 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
1576
790
|
// ~~~~~~~~~~~~~~~~
|
|
1577
791
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1578
792
|
```
|
|
1579
|
-
|
|
1580
|
-
@group type-fest
|
|
1581
793
|
*/
|
|
1582
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
794
|
+
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>>>>;
|
|
1583
795
|
//#endregion
|
|
1584
|
-
//#region
|
|
796
|
+
//#region ../../node_modules/type-fest/source/except.d.ts
|
|
1585
797
|
/**
|
|
1586
798
|
Filter out keys from an object.
|
|
1587
799
|
|
|
@@ -1609,20 +821,19 @@ type Filtered = Filter<'bar', 'foo'>;
|
|
|
1609
821
|
|
|
1610
822
|
@see {Except}
|
|
1611
823
|
*/
|
|
1612
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
824
|
+
type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
|
|
1613
825
|
type ExceptOptions = {
|
|
1614
826
|
/**
|
|
1615
827
|
Disallow assigning non-specified properties.
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
@default false
|
|
828
|
+
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
829
|
+
@default false
|
|
1620
830
|
*/
|
|
1621
831
|
requireExactProps?: boolean;
|
|
1622
832
|
};
|
|
1623
833
|
type DefaultExceptOptions = {
|
|
1624
834
|
requireExactProps: false;
|
|
1625
835
|
};
|
|
836
|
+
|
|
1626
837
|
/**
|
|
1627
838
|
Create a type from an object type without certain keys.
|
|
1628
839
|
|
|
@@ -1637,8 +848,8 @@ This type was proposed to the TypeScript team, which declined it, saying they pr
|
|
|
1637
848
|
import type {Except} from 'type-fest';
|
|
1638
849
|
|
|
1639
850
|
type Foo = {
|
|
1640
|
-
a: number;
|
|
1641
|
-
b: string;
|
|
851
|
+
a: number;
|
|
852
|
+
b: string;
|
|
1642
853
|
};
|
|
1643
854
|
|
|
1644
855
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
@@ -1658,10 +869,10 @@ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
|
1658
869
|
// Consider the following example:
|
|
1659
870
|
|
|
1660
871
|
type UserData = {
|
|
1661
|
-
[metadata: string]: string;
|
|
1662
|
-
email: string;
|
|
1663
|
-
name: string;
|
|
1664
|
-
role: 'admin' | 'user';
|
|
872
|
+
[metadata: string]: string;
|
|
873
|
+
email: string;
|
|
874
|
+
name: string;
|
|
875
|
+
role: 'admin' | 'user';
|
|
1665
876
|
};
|
|
1666
877
|
|
|
1667
878
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
@@ -1674,38 +885,12 @@ type PostPayload = Except<UserData, 'email'>;
|
|
|
1674
885
|
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
1675
886
|
```
|
|
1676
887
|
|
|
1677
|
-
@
|
|
888
|
+
@category Object
|
|
1678
889
|
*/
|
|
1679
890
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
1680
|
-
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options[
|
|
1681
|
-
//#endregion
|
|
1682
|
-
//#region src/types/type-fest/override-properties.d.ts
|
|
1683
|
-
/**
|
|
1684
|
-
Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
|
|
1685
|
-
|
|
1686
|
-
This is useful when you want to override existing properties with a different type and make sure that these properties really exist in the original.
|
|
1687
|
-
|
|
1688
|
-
@example
|
|
1689
|
-
```
|
|
1690
|
-
type Foo = {
|
|
1691
|
-
a: string
|
|
1692
|
-
b: string
|
|
1693
|
-
}
|
|
1694
|
-
type Bar = OverrideProperties<Foo, {b: number}>
|
|
1695
|
-
//=> {a: string, b: number}
|
|
1696
|
-
|
|
1697
|
-
type Baz = OverrideProperties<Foo, {c: number}>
|
|
1698
|
-
// Error, type '{ c: number; }' does not satisfy the constraint '{ c: never; }'
|
|
1699
|
-
|
|
1700
|
-
type Fizz = OverrideProperties<Foo, {b: number; c: number}>
|
|
1701
|
-
// Error, type '{ b: number; c: number; }' does not satisfy the constraint '{ b: number; c: never; }'
|
|
1702
|
-
```
|
|
1703
|
-
|
|
1704
|
-
@group type-fest
|
|
1705
|
-
*/
|
|
1706
|
-
type OverrideProperties<TOriginal, TOverride extends Partial<Record<keyof TOriginal, unknown>> & { [Key in keyof TOverride]: Key extends keyof TOriginal ? TOverride[Key] : never }> = Merge<TOriginal, TOverride>;
|
|
891
|
+
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>> : {});
|
|
1707
892
|
//#endregion
|
|
1708
|
-
//#region
|
|
893
|
+
//#region ../../node_modules/type-fest/source/require-at-least-one.d.ts
|
|
1709
894
|
/**
|
|
1710
895
|
Create a type that requires at least one of the given keys. The remaining keys are kept as is.
|
|
1711
896
|
|
|
@@ -1714,60 +899,75 @@ Create a type that requires at least one of the given keys. The remaining keys a
|
|
|
1714
899
|
import type {RequireAtLeastOne} from 'type-fest';
|
|
1715
900
|
|
|
1716
901
|
type Responder = {
|
|
1717
|
-
text?: () => string;
|
|
1718
|
-
json?: () => string;
|
|
1719
|
-
secure?: boolean;
|
|
902
|
+
text?: () => string;
|
|
903
|
+
json?: () => string;
|
|
904
|
+
secure?: boolean;
|
|
1720
905
|
};
|
|
1721
906
|
|
|
1722
907
|
const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
1723
|
-
json: () => '{"message": "ok"}',
|
|
1724
|
-
secure: true
|
|
908
|
+
json: () => '{"message": "ok"}',
|
|
909
|
+
secure: true
|
|
1725
910
|
};
|
|
1726
911
|
```
|
|
1727
912
|
|
|
1728
|
-
@
|
|
913
|
+
@category Object
|
|
1729
914
|
*/
|
|
1730
|
-
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType,
|
|
1731
|
-
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
|
|
915
|
+
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If<IsNever<KeysType>, never, _RequireAtLeastOne<ObjectType, If<IsAny<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
916
|
+
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = {
|
|
917
|
+
// For each `Key` in `KeysType` make a mapped type:
|
|
918
|
+
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> &
|
|
919
|
+
// 1. Make `Key`'s type required
|
|
920
|
+
// 2. Make all other keys in `KeysType` optional
|
|
921
|
+
Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] &
|
|
922
|
+
// 3. Add the remaining keys not in `KeysType`
|
|
923
|
+
Except<ObjectType, KeysType>;
|
|
1732
924
|
//#endregion
|
|
1733
|
-
//#region
|
|
925
|
+
//#region ../../node_modules/type-fest/source/required-deep.d.ts
|
|
1734
926
|
/**
|
|
1735
|
-
Create a type
|
|
927
|
+
Create a type from another type with all keys and nested keys set to required.
|
|
1736
928
|
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
929
|
+
Use-cases:
|
|
930
|
+
- Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified.
|
|
931
|
+
- Modeling the resulting type after a deep merge with a set of defaults.
|
|
1740
932
|
|
|
1741
933
|
@example
|
|
1742
934
|
```
|
|
1743
|
-
import type {
|
|
935
|
+
import type {RequiredDeep} from 'type-fest';
|
|
1744
936
|
|
|
1745
|
-
type
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
// b: string; // Can no longer be undefined.
|
|
1755
|
-
// c?: boolean; // Can no longer be null, but is still optional.
|
|
1756
|
-
// }
|
|
937
|
+
type Settings = {
|
|
938
|
+
textEditor?: {
|
|
939
|
+
fontSize?: number;
|
|
940
|
+
fontColor?: string;
|
|
941
|
+
fontWeight?: number | undefined;
|
|
942
|
+
};
|
|
943
|
+
autocomplete?: boolean;
|
|
944
|
+
autosave?: boolean | undefined;
|
|
945
|
+
};
|
|
1757
946
|
|
|
1758
|
-
type
|
|
1759
|
-
|
|
1760
|
-
//
|
|
1761
|
-
//
|
|
1762
|
-
//
|
|
947
|
+
type RequiredSettings = RequiredDeep<Settings>;
|
|
948
|
+
//=> {
|
|
949
|
+
// textEditor: {
|
|
950
|
+
// fontSize: number;
|
|
951
|
+
// fontColor: string;
|
|
952
|
+
// fontWeight: number | undefined;
|
|
953
|
+
// };
|
|
954
|
+
// autocomplete: boolean;
|
|
955
|
+
// autosave: boolean | undefined;
|
|
1763
956
|
// }
|
|
1764
957
|
```
|
|
1765
958
|
|
|
1766
|
-
|
|
959
|
+
Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
|
|
960
|
+
|
|
961
|
+
@category Utilities
|
|
962
|
+
@category Object
|
|
963
|
+
@category Array
|
|
964
|
+
@category Set
|
|
965
|
+
@category Map
|
|
1767
966
|
*/
|
|
1768
|
-
type
|
|
967
|
+
type RequiredDeep<T$1> = T$1 extends BuiltIns ? T$1 : T$1 extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T$1 extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : T$1 extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T$1 extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : T$1 extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T$1 extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : T$1 extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : T$1 extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T$1> extends true ? T$1 : HasMultipleCallSignatures<T$1> extends true ? T$1 : ((...arguments_: Parameters<T$1>) => ReturnType<T$1>) & RequiredObjectDeep<T$1> : T$1 extends object ? RequiredObjectDeep<T$1> : unknown;
|
|
968
|
+
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
1769
969
|
//#endregion
|
|
1770
|
-
//#region
|
|
970
|
+
//#region ../../node_modules/type-fest/source/set-optional.d.ts
|
|
1771
971
|
/**
|
|
1772
972
|
Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
|
|
1773
973
|
|
|
@@ -1778,9 +978,9 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
|
1778
978
|
import type {SetOptional} from 'type-fest';
|
|
1779
979
|
|
|
1780
980
|
type Foo = {
|
|
1781
|
-
a: number;
|
|
1782
|
-
b?: string;
|
|
1783
|
-
c: boolean;
|
|
981
|
+
a: number;
|
|
982
|
+
b?: string;
|
|
983
|
+
c: boolean;
|
|
1784
984
|
}
|
|
1785
985
|
|
|
1786
986
|
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
@@ -1791,11 +991,17 @@ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
|
1791
991
|
// }
|
|
1792
992
|
```
|
|
1793
993
|
|
|
1794
|
-
@
|
|
994
|
+
@category Object
|
|
1795
995
|
*/
|
|
1796
|
-
type SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends
|
|
996
|
+
type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
|
|
997
|
+
type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
|
|
998
|
+
? Simplify<
|
|
999
|
+
// Pick just the keys that are readonly from the base type.
|
|
1000
|
+
Except<BaseType, Keys> &
|
|
1001
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
1002
|
+
Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
1797
1003
|
//#endregion
|
|
1798
|
-
//#region
|
|
1004
|
+
//#region ../../node_modules/type-fest/source/set-required.d.ts
|
|
1799
1005
|
/**
|
|
1800
1006
|
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
|
1801
1007
|
|
|
@@ -1806,9 +1012,9 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
|
1806
1012
|
import type {SetRequired} from 'type-fest';
|
|
1807
1013
|
|
|
1808
1014
|
type Foo = {
|
|
1809
|
-
a?: number;
|
|
1810
|
-
b: string;
|
|
1811
|
-
c?: boolean;
|
|
1015
|
+
a?: number;
|
|
1016
|
+
b: string;
|
|
1017
|
+
c?: boolean;
|
|
1812
1018
|
}
|
|
1813
1019
|
|
|
1814
1020
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
@@ -1823,62 +1029,32 @@ type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
|
|
|
1823
1029
|
//=> [number, number, number?]
|
|
1824
1030
|
```
|
|
1825
1031
|
|
|
1826
|
-
@
|
|
1032
|
+
@category Object
|
|
1827
1033
|
*/
|
|
1828
|
-
type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends
|
|
1034
|
+
type SetRequired<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetRequired<BaseType, Keys>;
|
|
1035
|
+
type _SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? If<IsArrayReadonly<BaseType>, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
|
|
1036
|
+
// Pick just the keys that are optional from the base type.
|
|
1037
|
+
Except<BaseType, Keys> &
|
|
1038
|
+
// Pick the keys that should be required from the base type and make them required.
|
|
1039
|
+
Required<HomomorphicPick<BaseType, Keys>>>;
|
|
1040
|
+
|
|
1829
1041
|
/**
|
|
1830
1042
|
Remove the optional modifier from the specified keys in an array.
|
|
1831
1043
|
*/
|
|
1832
|
-
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
Note: This type can make readonly `Set` and `Map` writable. This behavior is different from `Readonly<T>` (as of TypeScript 5.2.2). See: https://github.com/microsoft/TypeScript/issues/29655
|
|
1845
|
-
|
|
1846
|
-
This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509), or to define a single model where the only thing that changes is whether or not some of the keys are writable.
|
|
1847
|
-
|
|
1848
|
-
@example
|
|
1849
|
-
```
|
|
1850
|
-
import type {Writable} from 'type-fest';
|
|
1851
|
-
|
|
1852
|
-
type Foo = {
|
|
1853
|
-
readonly a: number;
|
|
1854
|
-
readonly b: readonly string[]; // To show that only the mutability status of the properties, not their values, are affected.
|
|
1855
|
-
readonly c: boolean;
|
|
1856
|
-
};
|
|
1857
|
-
|
|
1858
|
-
const writableFoo: Writable<Foo> = {a: 1, b: ['2'], c: true};
|
|
1859
|
-
writableFoo.a = 3;
|
|
1860
|
-
writableFoo.b[0] = 'new value'; // Will still fail as the value of property "b" is still a readonly type.
|
|
1861
|
-
writableFoo.b = ['something']; // Will work as the "b" property itself is no longer readonly.
|
|
1862
|
-
|
|
1863
|
-
type SomeWritable = Writable<Foo, 'b' | 'c'>;
|
|
1864
|
-
// type SomeWritable = {
|
|
1865
|
-
// readonly a: number;
|
|
1866
|
-
// b: readonly string[]; // It's now writable. The type of the property remains unaffected.
|
|
1867
|
-
// c: boolean; // It's now writable.
|
|
1868
|
-
// }
|
|
1869
|
-
|
|
1870
|
-
// Also supports array
|
|
1871
|
-
const readonlyArray: readonly number[] = [1, 2, 3];
|
|
1872
|
-
readonlyArray.push(4); // Will fail as the array itself is readonly.
|
|
1873
|
-
const writableArray: Writable<typeof readonlyArray> = readonlyArray as Writable<typeof readonlyArray>;
|
|
1874
|
-
writableArray.push(4); // Will work as the array itself is now writable.
|
|
1875
|
-
```
|
|
1876
|
-
|
|
1877
|
-
@group type-fest
|
|
1878
|
-
*/
|
|
1879
|
-
type Writable<BaseType, Keys extends keyof BaseType = keyof BaseType> = BaseType extends ReadonlyMap<infer KeyType, infer ValueType> ? Map<KeyType, ValueType> : BaseType extends ReadonlySet<infer ItemType> ? Set<ItemType> : BaseType extends readonly unknown[] ? WritableArray<BaseType> : Simplify<Except<BaseType, Keys> & { -readonly [KeyType in keyof Pick<BaseType, Keys>]: Pick<BaseType, Keys>[KeyType] }>;
|
|
1044
|
+
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
|
|
1045
|
+
? keyof TArray & `${number}` extends never
|
|
1046
|
+
// Exit if `TArray` is empty (e.g., []), or
|
|
1047
|
+
// `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
1048
|
+
? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
|
|
1049
|
+
? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
|
|
1050
|
+
? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
|
|
1051
|
+
// If the current element is optional, but it doesn't need to be required,
|
|
1052
|
+
// then we can exit early, since no further elements can now be made required.
|
|
1053
|
+
: [...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.
|
|
1054
|
+
: never; // Should never happen
|
|
1880
1055
|
//#endregion
|
|
1881
1056
|
//#region src/types/options.d.ts
|
|
1057
|
+
type RequireAtLeastOne$1<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
|
|
1882
1058
|
type StringUnionToFlexibleOptionArray<Op extends string> = Array<Op extends unknown ? FlexibleOption<Op> : never>;
|
|
1883
1059
|
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
|
|
1884
1060
|
/**
|
|
@@ -1886,18 +1062,18 @@ type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown
|
|
|
1886
1062
|
*
|
|
1887
1063
|
* @group Option Lists
|
|
1888
1064
|
*/
|
|
1889
|
-
type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends FlexibleOptionList<infer Opt> ? Opt : never;
|
|
1065
|
+
type GetOptionType<OL$1 extends FlexibleOptionList<FullOption>> = OL$1 extends FlexibleOptionList<infer Opt> ? Opt : never;
|
|
1890
1066
|
/**
|
|
1891
1067
|
* Extracts the type of the identifying property from a {@link Option},
|
|
1892
1068
|
* {@link ValueOption}, or {@link FullOption}.
|
|
1893
1069
|
*
|
|
1894
1070
|
* @group Option Lists
|
|
1895
1071
|
*/
|
|
1896
|
-
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
1072
|
+
type GetOptionIdentifierType<Opt$1 extends BaseOption> = Opt$1 extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
|
|
1897
1073
|
/**
|
|
1898
1074
|
* Adds an `unknown` index property to an interface.
|
|
1899
1075
|
*/
|
|
1900
|
-
type WithUnknownIndex<T> = T & {
|
|
1076
|
+
type WithUnknownIndex<T$1> = T$1 & {
|
|
1901
1077
|
[key: string]: unknown;
|
|
1902
1078
|
};
|
|
1903
1079
|
/**
|
|
@@ -1929,24 +1105,24 @@ type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<B
|
|
|
1929
1105
|
type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "value">>>;
|
|
1930
1106
|
/**
|
|
1931
1107
|
* A generic {@link Option} with either a `name` or `value` as its primary identifier.
|
|
1932
|
-
* {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
|
|
1933
|
-
* but corresponding props passed down to subcomponents will always be
|
|
1108
|
+
* {@link OptionList}-type props on the {@link react-querybuilder!QueryBuilder QueryBuilder} component accept this type,
|
|
1109
|
+
* but corresponding props passed down to subcomponents will always be augmented
|
|
1934
1110
|
* to {@link FullOption} first.
|
|
1935
1111
|
*
|
|
1936
1112
|
* @group Option Lists
|
|
1937
1113
|
*/
|
|
1938
|
-
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
|
|
1114
|
+
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne$1<BaseOption<N>, "name" | "value">>>;
|
|
1939
1115
|
/**
|
|
1940
1116
|
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
|
|
1941
1117
|
* into a {@link FlexibleOption}.
|
|
1942
1118
|
*
|
|
1943
1119
|
* @group Option Lists
|
|
1944
1120
|
*/
|
|
1945
|
-
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
|
|
1121
|
+
type ToFlexibleOption<Opt$1 extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne$1<Opt$1 extends string ? FlexibleOption<Opt$1> : Opt$1, "name" | "value">>;
|
|
1946
1122
|
/**
|
|
1947
1123
|
* A generic {@link Option} requiring both `name` _and_ `value` properties.
|
|
1948
1124
|
* Props that extend {@link OptionList} accept {@link BaseOption}, but
|
|
1949
|
-
* corresponding props sent to subcomponents will always be
|
|
1125
|
+
* corresponding props sent to subcomponents will always be augmented to this
|
|
1950
1126
|
* type first to ensure both `name` and `value` are available.
|
|
1951
1127
|
*
|
|
1952
1128
|
* NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
|
|
@@ -1970,7 +1146,7 @@ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption
|
|
|
1970
1146
|
*
|
|
1971
1147
|
* @group Option Lists
|
|
1972
1148
|
*/
|
|
1973
|
-
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
|
|
1149
|
+
type ToFullOption<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1 : Opt$1 extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt$1 & FullOption<IdentifierType>> : never;
|
|
1974
1150
|
/**
|
|
1975
1151
|
* @deprecated Renamed to {@link Option}.
|
|
1976
1152
|
*
|
|
@@ -1982,39 +1158,39 @@ type NameLabelPair<N extends string = string> = Option<N>;
|
|
|
1982
1158
|
*
|
|
1983
1159
|
* @group Option Lists
|
|
1984
1160
|
*/
|
|
1985
|
-
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
|
|
1161
|
+
interface OptionGroup<Opt$1 extends BaseOption = FlexibleOption> {
|
|
1986
1162
|
label: string;
|
|
1987
|
-
options: WithUnknownIndex<Opt>[];
|
|
1163
|
+
options: WithUnknownIndex<Opt$1>[];
|
|
1988
1164
|
}
|
|
1989
1165
|
/**
|
|
1990
1166
|
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
|
|
1991
1167
|
*
|
|
1992
1168
|
* @group Option Lists
|
|
1993
1169
|
*/
|
|
1994
|
-
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
|
|
1170
|
+
type FlexibleOptionGroup<Opt$1 extends BaseOption | string = BaseOption> = {
|
|
1995
1171
|
label: string;
|
|
1996
|
-
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
|
|
1172
|
+
options: (Opt$1 extends BaseFullOption ? Opt$1 : ToFlexibleOption<Opt$1>)[];
|
|
1997
1173
|
};
|
|
1998
1174
|
/**
|
|
1999
1175
|
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
|
|
2000
1176
|
*
|
|
2001
1177
|
* @group Option Lists
|
|
2002
1178
|
*/
|
|
2003
|
-
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
|
|
1179
|
+
type OptionList<Opt$1 extends Option = Option> = Opt$1[] | OptionGroup<Opt$1>[];
|
|
2004
1180
|
/**
|
|
2005
1181
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
2006
1182
|
* may use either `name` or `value` as the primary identifier.
|
|
2007
1183
|
*
|
|
2008
1184
|
* @group Option Lists
|
|
2009
1185
|
*/
|
|
2010
|
-
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
|
|
1186
|
+
type FlexibleOptionList<Opt$1 extends BaseOption> = ToFlexibleOption<Opt$1>[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1>>[];
|
|
2011
1187
|
/**
|
|
2012
1188
|
* An array of options or option groups, like {@link OptionList} but the option type
|
|
2013
1189
|
* may use either `name` or `value` as the primary identifier.
|
|
2014
1190
|
*
|
|
2015
1191
|
* @group Option Lists
|
|
2016
1192
|
*/
|
|
2017
|
-
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
|
|
1193
|
+
type FlexibleOptionListProp<Opt$1 extends BaseOption> = (ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt$1> | GetOptionIdentifierType<Opt$1>>[];
|
|
2018
1194
|
/**
|
|
2019
1195
|
* An array of options or option groups, like {@link OptionList}, but using
|
|
2020
1196
|
* {@link FullOption} instead of {@link Option}. This means that every member is
|
|
@@ -2022,26 +1198,26 @@ type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | G
|
|
|
2022
1198
|
*
|
|
2023
1199
|
* @group Option Lists
|
|
2024
1200
|
*/
|
|
2025
|
-
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
|
|
1201
|
+
type FullOptionList<Opt$1 extends BaseOption> = Opt$1 extends BaseFullOption ? Opt$1[] | OptionGroup<Opt$1>[] : ToFullOption<Opt$1>[] | OptionGroup<ToFullOption<Opt$1>>[];
|
|
2026
1202
|
/**
|
|
2027
1203
|
* Map of option identifiers to their respective {@link Option}.
|
|
2028
1204
|
*
|
|
2029
1205
|
* @group Option Lists
|
|
2030
1206
|
*/
|
|
2031
|
-
type BaseOptionMap<V extends BaseOption = BaseOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: ToFlexibleOption<V> };
|
|
1207
|
+
type BaseOptionMap<V$1 extends BaseOption = BaseOption, K$1 extends string = GetOptionIdentifierType<V$1>> = { [k in K$1]?: ToFlexibleOption<V$1> };
|
|
2032
1208
|
/**
|
|
2033
1209
|
* Map of option identifiers to their respective {@link FullOption}.
|
|
2034
1210
|
*
|
|
2035
1211
|
* @group Option Lists
|
|
2036
1212
|
*/
|
|
2037
|
-
type FullOptionMap<V extends BaseFullOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: V };
|
|
1213
|
+
type FullOptionMap<V$1 extends BaseFullOption, K$1 extends string = GetOptionIdentifierType<V$1>> = { [k in K$1]?: V$1 };
|
|
2038
1214
|
/**
|
|
2039
1215
|
* Map of option identifiers to their respective {@link FullOption}.
|
|
2040
1216
|
* Must include all possible strings from the identifier type.
|
|
2041
1217
|
*
|
|
2042
1218
|
* @group Option Lists
|
|
2043
1219
|
*/
|
|
2044
|
-
type FullOptionRecord<V extends BaseFullOption, K extends string = GetOptionIdentifierType<V>> = Record<K, V>;
|
|
1220
|
+
type FullOptionRecord<V$1 extends BaseFullOption, K$1 extends string = GetOptionIdentifierType<V$1>> = Record<K$1, V$1>;
|
|
2045
1221
|
//#endregion
|
|
2046
1222
|
//#region src/types/ruleGroups.d.ts
|
|
2047
1223
|
/**
|
|
@@ -2051,15 +1227,21 @@ interface CommonRuleAndGroupProperties {
|
|
|
2051
1227
|
path?: Path;
|
|
2052
1228
|
id?: string;
|
|
2053
1229
|
disabled?: boolean;
|
|
1230
|
+
/**
|
|
1231
|
+
* Whether this rule or group is muted. When muted, the rule or group
|
|
1232
|
+
* is excluded from query export formats (SQL, JSON, MongoDB, etc.).
|
|
1233
|
+
* For groups, muting recursively mutes all children.
|
|
1234
|
+
*/
|
|
1235
|
+
muted?: boolean;
|
|
2054
1236
|
}
|
|
2055
1237
|
/**
|
|
2056
1238
|
* The main rule type. The `field`, `operator`, and `value` properties
|
|
2057
1239
|
* can be narrowed with generics.
|
|
2058
1240
|
*/
|
|
2059
|
-
interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
2060
|
-
field: F;
|
|
2061
|
-
operator: O;
|
|
2062
|
-
value: V;
|
|
1241
|
+
interface RuleType<F$1 extends string = string, O$1 extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1242
|
+
field: F$1;
|
|
1243
|
+
operator: O$1;
|
|
1244
|
+
value: V$1;
|
|
2063
1245
|
valueSource?: ValueSource;
|
|
2064
1246
|
match?: MatchConfig;
|
|
2065
1247
|
/**
|
|
@@ -2071,15 +1253,15 @@ interface RuleType<F extends string = string, O extends string = string, V = any
|
|
|
2071
1253
|
* The main rule group type. This type is used for query definitions as well as
|
|
2072
1254
|
* all sub-groups of queries.
|
|
2073
1255
|
*/
|
|
2074
|
-
interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1256
|
+
interface RuleGroupType<R$1 extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
2075
1257
|
combinator: C;
|
|
2076
|
-
rules: RuleGroupArray<RuleGroupType<R, C>, R>;
|
|
1258
|
+
rules: RuleGroupArray<RuleGroupType<R$1, C>, R$1>;
|
|
2077
1259
|
not?: boolean;
|
|
2078
1260
|
}
|
|
2079
1261
|
/**
|
|
2080
1262
|
* The type of the `rules` array in a {@link RuleGroupType}.
|
|
2081
1263
|
*/
|
|
2082
|
-
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
|
|
1264
|
+
type RuleGroupArray<RG$1 extends RuleGroupType = RuleGroupType, R$1 extends RuleType = RuleType> = (R$1 | RG$1)[];
|
|
2083
1265
|
/**
|
|
2084
1266
|
* All updateable properties of rules and groups (everything except
|
|
2085
1267
|
* `id`, `path`, and `rules`).
|
|
@@ -2088,18 +1270,18 @@ type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "pa
|
|
|
2088
1270
|
/**
|
|
2089
1271
|
* The type of the `rules` array in a {@link DefaultRuleGroupType}.
|
|
2090
1272
|
*/
|
|
2091
|
-
type DefaultRuleGroupArray<F extends string = string> = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType<F>>;
|
|
1273
|
+
type DefaultRuleGroupArray<F$1 extends string = string> = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType<F$1>>;
|
|
2092
1274
|
/**
|
|
2093
1275
|
* {@link RuleGroupType} with the `combinator` property limited to
|
|
2094
1276
|
* {@link DefaultCombinatorNameExtended} and `rules` limited to {@link DefaultRuleType}.
|
|
2095
1277
|
*/
|
|
2096
|
-
type DefaultRuleGroupType<F extends string = string> = RuleGroupType<DefaultRuleType<F>, DefaultCombinatorNameExtended> & {
|
|
2097
|
-
rules: DefaultRuleGroupArray<F>;
|
|
1278
|
+
type DefaultRuleGroupType<F$1 extends string = string> = RuleGroupType<DefaultRuleType<F$1>, DefaultCombinatorNameExtended> & {
|
|
1279
|
+
rules: DefaultRuleGroupArray<F$1>;
|
|
2098
1280
|
};
|
|
2099
1281
|
/**
|
|
2100
1282
|
* {@link RuleType} with the `operator` property limited to {@link DefaultOperatorName}.
|
|
2101
1283
|
*/
|
|
2102
|
-
type DefaultRuleType<F extends string = string> = RuleType<F, DefaultOperatorName>;
|
|
1284
|
+
type DefaultRuleType<F$1 extends string = string> = RuleType<F$1, DefaultOperatorName>;
|
|
2103
1285
|
/**
|
|
2104
1286
|
* Default allowed values for the `combinator` property.
|
|
2105
1287
|
*
|
|
@@ -2146,9 +1328,9 @@ type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [
|
|
|
2146
1328
|
* The main rule group interface when using independent combinators. This type is used
|
|
2147
1329
|
* for query definitions as well as all sub-groups of queries.
|
|
2148
1330
|
*/
|
|
2149
|
-
interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
|
|
1331
|
+
interface RuleGroupTypeIC<R$1 extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R$1, C>, "combinator" | "rules"> {
|
|
2150
1332
|
combinator?: undefined;
|
|
2151
|
-
rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
|
|
1333
|
+
rules: RuleGroupICArray<RuleGroupTypeIC<R$1, C>, R$1, C>;
|
|
2152
1334
|
/**
|
|
2153
1335
|
* Only used when adding a rule to a query that uses independent combinators
|
|
2154
1336
|
*/
|
|
@@ -2157,11 +1339,11 @@ interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = stri
|
|
|
2157
1339
|
/**
|
|
2158
1340
|
* Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
|
|
2159
1341
|
*/
|
|
2160
|
-
type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
|
|
1342
|
+
type RuleGroupTypeAny<R$1 extends RuleType = RuleType, C extends string = string> = RuleGroupType<R$1, C> | RuleGroupTypeIC<R$1, C>;
|
|
2161
1343
|
/**
|
|
2162
1344
|
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
|
|
2163
1345
|
*/
|
|
2164
|
-
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
|
|
1346
|
+
type RuleGroupICArray<RG$1 extends RuleGroupTypeIC = RuleGroupTypeIC, R$1 extends RuleType = RuleType, C extends string = string> = [R$1 | RG$1] | [R$1 | RG$1, ...MappedTuple<[C, R$1 | RG$1]>] | ((R$1 | RG$1)[] & {
|
|
2165
1347
|
length: 0;
|
|
2166
1348
|
});
|
|
2167
1349
|
/**
|
|
@@ -2171,27 +1353,27 @@ type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
|
|
|
2171
1353
|
/**
|
|
2172
1354
|
* The type of the `rules` array in a {@link DefaultRuleGroupTypeIC}.
|
|
2173
1355
|
*/
|
|
2174
|
-
type DefaultRuleGroupICArray<F extends string = string> = RuleGroupICArray<DefaultRuleGroupTypeIC<F>, DefaultRuleType<F>, DefaultCombinatorName>;
|
|
1356
|
+
type DefaultRuleGroupICArray<F$1 extends string = string> = RuleGroupICArray<DefaultRuleGroupTypeIC<F$1>, DefaultRuleType<F$1>, DefaultCombinatorName>;
|
|
2175
1357
|
/**
|
|
2176
1358
|
* Shorthand for "either {@link DefaultRuleGroupArray} or {@link DefaultRuleGroupICArray}".
|
|
2177
1359
|
*/
|
|
2178
|
-
type DefaultRuleOrGroupArray<F extends string = string> = DefaultRuleGroupArray<F> | DefaultRuleGroupICArray<F>;
|
|
1360
|
+
type DefaultRuleOrGroupArray<F$1 extends string = string> = DefaultRuleGroupArray<F$1> | DefaultRuleGroupICArray<F$1>;
|
|
2179
1361
|
/**
|
|
2180
1362
|
* {@link RuleGroupTypeIC} with combinators limited to
|
|
2181
1363
|
* {@link DefaultCombinatorName} and rules limited to {@link DefaultRuleType}.
|
|
2182
1364
|
*/
|
|
2183
|
-
interface DefaultRuleGroupTypeIC<F extends string = string> extends RuleGroupTypeIC<DefaultRuleType<F>> {
|
|
2184
|
-
rules: DefaultRuleGroupICArray<F>;
|
|
1365
|
+
interface DefaultRuleGroupTypeIC<F$1 extends string = string> extends RuleGroupTypeIC<DefaultRuleType<F$1>> {
|
|
1366
|
+
rules: DefaultRuleGroupICArray<F$1>;
|
|
2185
1367
|
}
|
|
2186
1368
|
/**
|
|
2187
1369
|
* Shorthand for "either {@link DefaultRuleGroupType} or {@link DefaultRuleGroupTypeIC}".
|
|
2188
1370
|
*/
|
|
2189
|
-
type DefaultRuleGroupTypeAny<F extends string = string> = DefaultRuleGroupType<F> | DefaultRuleGroupTypeIC<F>;
|
|
1371
|
+
type DefaultRuleGroupTypeAny<F$1 extends string = string> = DefaultRuleGroupType<F$1> | DefaultRuleGroupTypeIC<F$1>;
|
|
2190
1372
|
/**
|
|
2191
1373
|
* Determines if a type extending {@link RuleGroupTypeAny} is actually
|
|
2192
1374
|
* {@link RuleGroupType} or {@link RuleGroupTypeIC}.
|
|
2193
1375
|
*/
|
|
2194
|
-
type GetRuleGroupType<RG> = RG extends {
|
|
1376
|
+
type GetRuleGroupType<RG$1> = RG$1 extends {
|
|
2195
1377
|
combinator: string;
|
|
2196
1378
|
} ? RuleGroupType : RuleGroupTypeIC;
|
|
2197
1379
|
/**
|
|
@@ -2202,11 +1384,11 @@ type GetRuleGroupType<RG> = RG extends {
|
|
|
2202
1384
|
* the rule type has its field and operator types narrowed to the
|
|
2203
1385
|
* identifier types of the provided Field and Operator types.
|
|
2204
1386
|
*/
|
|
2205
|
-
type GetRuleTypeFromGroupWithFieldAndOperator<RG extends RuleGroupTypeAny, F extends BaseOption, O extends BaseOption> = RG extends RuleGroupType<infer RT> | RuleGroupTypeIC<infer RT> ? RT extends RuleType<infer RuleFieldName, infer RuleOperatorName, infer RuleValueName, infer RuleCombinatorName> ? RuleFieldName extends GetOptionIdentifierType<F> ? RuleOperatorName extends GetOptionIdentifierType<O> ? RuleType<RuleFieldName, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<RuleFieldName, GetOptionIdentifierType<O>, RuleValueName, RuleCombinatorName> : RuleOperatorName extends GetOptionIdentifierType<O> ? RuleType<GetOptionIdentifierType<F>, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<GetOptionIdentifierType<F>, GetOptionIdentifierType<O>, RuleValueName, RuleCombinatorName> : never : never;
|
|
1387
|
+
type GetRuleTypeFromGroupWithFieldAndOperator<RG$1 extends RuleGroupTypeAny, F$1 extends BaseOption, O$1 extends BaseOption> = RG$1 extends RuleGroupType<infer RT> | RuleGroupTypeIC<infer RT> ? RT extends RuleType<infer RuleFieldName, infer RuleOperatorName, infer RuleValueName, infer RuleCombinatorName> ? RuleFieldName extends GetOptionIdentifierType<F$1> ? RuleOperatorName extends GetOptionIdentifierType<O$1> ? RuleType<RuleFieldName, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<RuleFieldName, GetOptionIdentifierType<O$1>, RuleValueName, RuleCombinatorName> : RuleOperatorName extends GetOptionIdentifierType<O$1> ? RuleType<GetOptionIdentifierType<F$1>, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<GetOptionIdentifierType<F$1>, GetOptionIdentifierType<O$1>, RuleValueName, RuleCombinatorName> : never : never;
|
|
2206
1388
|
/**
|
|
2207
1389
|
* Converts a narrowed rule group type to its most generic form.
|
|
2208
1390
|
*/
|
|
2209
|
-
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1391
|
+
type GenericizeRuleGroupType<RG$1> = RG$1 extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
2210
1392
|
//#endregion
|
|
2211
1393
|
//#region src/types/validation.d.ts
|
|
2212
1394
|
/**
|
|
@@ -2245,7 +1427,7 @@ type Classname = string | string[] | Record<string, any>;
|
|
|
2245
1427
|
*/
|
|
2246
1428
|
type ValueSource = "value" | "field";
|
|
2247
1429
|
/**
|
|
2248
|
-
* Type of {@link ValueEditor} that will be displayed.
|
|
1430
|
+
* Type of {@link react-querybuilder!ValueEditor ValueEditor} that will be displayed.
|
|
2249
1431
|
*/
|
|
2250
1432
|
type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
|
|
2251
1433
|
/**
|
|
@@ -2262,7 +1444,7 @@ type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown
|
|
|
2262
1444
|
label: string;
|
|
2263
1445
|
} } : never;
|
|
2264
1446
|
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
|
|
2265
|
-
type WithOptionalClassName<T> = T & {
|
|
1447
|
+
type WithOptionalClassName<T$1> = T$1 & {
|
|
2266
1448
|
className?: Classname;
|
|
2267
1449
|
};
|
|
2268
1450
|
/**
|
|
@@ -2305,7 +1487,7 @@ interface BaseFullField<FieldName extends string = string, OperatorName extends
|
|
|
2305
1487
|
comparator?: string | ((f: FullField, operator: string) => boolean);
|
|
2306
1488
|
}
|
|
2307
1489
|
/**
|
|
2308
|
-
* Full field definition used in the `fields` prop of {@link QueryBuilder}.
|
|
1490
|
+
* Full field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2309
1491
|
* This type requires both `name` and `value`, but the `fields` prop itself
|
|
2310
1492
|
* can use a {@link FlexibleOption} where only one of `name` or `value` is
|
|
2311
1493
|
* required (along with `label`), or {@link Field} where only `name` and
|
|
@@ -2318,7 +1500,7 @@ interface BaseFullField<FieldName extends string = string, OperatorName extends
|
|
|
2318
1500
|
*/
|
|
2319
1501
|
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>>;
|
|
2320
1502
|
/**
|
|
2321
|
-
* Field definition used in the `fields` prop of {@link QueryBuilder}.
|
|
1503
|
+
* Field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2322
1504
|
* This type is an extension of {@link FullField} where only `name` and
|
|
2323
1505
|
* `label` are required.
|
|
2324
1506
|
*
|
|
@@ -2331,7 +1513,7 @@ type Field<FieldName extends string = string, OperatorName extends string = stri
|
|
|
2331
1513
|
value?: FieldName;
|
|
2332
1514
|
} & Pick<BaseFullField<FieldName, OperatorName, ValueName, OperatorObj>, Exclude<keyof BaseFullField, "value">>>;
|
|
2333
1515
|
/**
|
|
2334
|
-
* Field definition used in the `fields` prop of {@link QueryBuilder}.
|
|
1516
|
+
* Field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2335
1517
|
* This type is an extension of {@link FullField} where only `value` and
|
|
2336
1518
|
* `label` are required.
|
|
2337
1519
|
*
|
|
@@ -2346,19 +1528,19 @@ type FieldByValue<FieldName extends string = string, OperatorName extends string
|
|
|
2346
1528
|
/**
|
|
2347
1529
|
* Utility type to make one or more properties required.
|
|
2348
1530
|
*/
|
|
2349
|
-
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
1531
|
+
type WithRequired<T$1, K$1 extends keyof T$1> = T$1 & { [P in K$1]-?: T$1[P] };
|
|
2350
1532
|
/**
|
|
2351
1533
|
* Utility type to make all properties non-nullable.
|
|
2352
1534
|
*/
|
|
2353
|
-
type RemoveNullability<T extends Record<string, unknown>> = { [k in keyof T]: NonNullable<T[k]> };
|
|
1535
|
+
type RemoveNullability<T$1 extends Record<string, unknown>> = { [k in keyof T$1]: NonNullable<T$1[k]> };
|
|
2354
1536
|
/**
|
|
2355
1537
|
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
2356
|
-
* a number less than two will cause the default {@link ValueEditor} to render `null`.
|
|
1538
|
+
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
2357
1539
|
*/
|
|
2358
1540
|
type Arity = number | "unary" | "binary" | "ternary";
|
|
2359
1541
|
/**
|
|
2360
1542
|
* Full operator definition used in the `operators`/`getOperators` props of
|
|
2361
|
-
* {@link QueryBuilder}. This type requires both `name` and `value`, but the
|
|
1543
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type requires both `name` and `value`, but the
|
|
2362
1544
|
* `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
|
|
2363
1545
|
* where only one of `name` or `value` is required, or {@link FullOperator} where
|
|
2364
1546
|
* only `name` is required.
|
|
@@ -2372,7 +1554,7 @@ interface FullOperator<N extends string = string> extends WithOptionalClassName<
|
|
|
2372
1554
|
}
|
|
2373
1555
|
/**
|
|
2374
1556
|
* Operator definition used in the `operators`/`getOperators` props of
|
|
2375
|
-
* {@link QueryBuilder}. This type is an extension of {@link FullOperator}
|
|
1557
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type is an extension of {@link FullOperator}
|
|
2376
1558
|
* where only `name` and `label` are required.
|
|
2377
1559
|
*
|
|
2378
1560
|
* The `name`/`value` properties of this interface can be narrowed with generics.
|
|
@@ -2384,7 +1566,7 @@ type Operator<N extends string = string> = WithUnknownIndex<SetOptional<BaseFull
|
|
|
2384
1566
|
}>>;
|
|
2385
1567
|
/**
|
|
2386
1568
|
* Operator definition used in the `operators`/`getOperators` props of
|
|
2387
|
-
* {@link QueryBuilder}. This type is an extension of {@link FullOperator}
|
|
1569
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}. This type is an extension of {@link FullOperator}
|
|
2388
1570
|
* where only `value` and `label` are required.
|
|
2389
1571
|
*
|
|
2390
1572
|
* The `name`/`value` properties of this interface can be narrowed with generics.
|
|
@@ -2395,7 +1577,7 @@ type OperatorByValue<N extends string = string> = WithUnknownIndex<SetOptional<B
|
|
|
2395
1577
|
arity?: Arity;
|
|
2396
1578
|
}>>;
|
|
2397
1579
|
/**
|
|
2398
|
-
* Full combinator definition used in the `combinators` prop of {@link QueryBuilder}.
|
|
1580
|
+
* Full combinator definition used in the `combinators` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2399
1581
|
* This type requires both `name` and `value`, but the `combinators` prop itself
|
|
2400
1582
|
* can use a {@link FlexibleOption} where only one of `name` or `value` is required,
|
|
2401
1583
|
* or {@link Combinator} where only `name` is required.
|
|
@@ -2406,7 +1588,7 @@ type OperatorByValue<N extends string = string> = WithUnknownIndex<SetOptional<B
|
|
|
2406
1588
|
*/
|
|
2407
1589
|
type FullCombinator<N extends string = string> = WithOptionalClassName<FullOption<N>>;
|
|
2408
1590
|
/**
|
|
2409
|
-
* Combinator definition used in the `combinators` prop of {@link QueryBuilder}.
|
|
1591
|
+
* Combinator definition used in the `combinators` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2410
1592
|
* This type is an extension of {@link FullCombinator} where only `name` and
|
|
2411
1593
|
* `label` are required.
|
|
2412
1594
|
*
|
|
@@ -2416,7 +1598,7 @@ type FullCombinator<N extends string = string> = WithOptionalClassName<FullOptio
|
|
|
2416
1598
|
*/
|
|
2417
1599
|
type Combinator<N extends string = string> = WithUnknownIndex<WithOptionalClassName<SetOptional<BaseFullOption<N>, "value">>>;
|
|
2418
1600
|
/**
|
|
2419
|
-
* Combinator definition used in the `combinators` prop of {@link QueryBuilder}.
|
|
1601
|
+
* Combinator definition used in the `combinators` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2420
1602
|
* This type is an extension of {@link FullCombinator} where only `value` and
|
|
2421
1603
|
* `label` are required.
|
|
2422
1604
|
*
|
|
@@ -2432,12 +1614,12 @@ type ParseNumberMethodName = "enhanced" | "native" | "strict";
|
|
|
2432
1614
|
type ParseNumberMethod = boolean | ParseNumberMethodName;
|
|
2433
1615
|
type ParseNumbersModerationLevel = "-limited" | "";
|
|
2434
1616
|
/**
|
|
2435
|
-
* Options for the `parseNumbers` prop of {@link QueryBuilder}.
|
|
1617
|
+
* Options for the `parseNumbers` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2436
1618
|
*/
|
|
2437
1619
|
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
|
|
2438
1620
|
/**
|
|
2439
|
-
* Signature of `accessibleDescriptionGenerator` prop, used by {@link QueryBuilder} to generate
|
|
2440
|
-
* accessible descriptions for each {@link RuleGroup}.
|
|
1621
|
+
* Signature of `accessibleDescriptionGenerator` prop, used by {@link react-querybuilder!QueryBuilder QueryBuilder} to generate
|
|
1622
|
+
* accessible descriptions for each {@link react-querybuilder!RuleGroup RuleGroup}.
|
|
2441
1623
|
*/
|
|
2442
1624
|
type AccessibleDescriptionGenerator = (props: {
|
|
2443
1625
|
path: Path;
|
|
@@ -2585,11 +1767,11 @@ interface FormatQueryOptions {
|
|
|
2585
1767
|
quoteValuesWith?: string;
|
|
2586
1768
|
/**
|
|
2587
1769
|
* Validator function for the entire query. Can be the same function passed
|
|
2588
|
-
* as `validator` prop to {@link QueryBuilder}.
|
|
1770
|
+
* as `validator` prop to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2589
1771
|
*/
|
|
2590
1772
|
validator?: QueryValidator;
|
|
2591
1773
|
/**
|
|
2592
|
-
* This can be the same {@link FullField} array passed to {@link QueryBuilder}, but
|
|
1774
|
+
* This can be the same {@link FullField} array passed to {@link react-querybuilder!QueryBuilder QueryBuilder}, but
|
|
2593
1775
|
* really all you need to provide is the `name` and `validator` for each field.
|
|
2594
1776
|
*
|
|
2595
1777
|
* The full field object from this array, where the field's identifying property
|
|
@@ -2597,7 +1779,7 @@ interface FormatQueryOptions {
|
|
|
2597
1779
|
*/
|
|
2598
1780
|
fields?: FlexibleOptionList<FullField>;
|
|
2599
1781
|
/**
|
|
2600
|
-
* This can be the same `getOperators` function passed to {@link QueryBuilder}.
|
|
1782
|
+
* This can be the same `getOperators` function passed to {@link react-querybuilder!QueryBuilder QueryBuilder}.
|
|
2601
1783
|
*
|
|
2602
1784
|
* The full operator object from this array, where the operator's identifying property
|
|
2603
1785
|
* matches the rule's `operator`, will be passed to the rule processor.
|
|
@@ -2931,7 +2113,7 @@ type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMo
|
|
|
2931
2113
|
*/
|
|
2932
2114
|
type NLTranslations = Partial<Record<NLTranslationKey, string>>;
|
|
2933
2115
|
//#endregion
|
|
2934
|
-
//#region src/types/
|
|
2116
|
+
//#region src/types/queryBuilder.d.ts
|
|
2935
2117
|
/**
|
|
2936
2118
|
* Base interface for all rule subcomponents.
|
|
2937
2119
|
*
|
|
@@ -3035,6 +2217,14 @@ interface Classnames {
|
|
|
3035
2217
|
*/
|
|
3036
2218
|
lockGroup: Classname;
|
|
3037
2219
|
/**
|
|
2220
|
+
* Classnames applied to the `<button>` to mute a Rule.
|
|
2221
|
+
*/
|
|
2222
|
+
muteRule: Classname;
|
|
2223
|
+
/**
|
|
2224
|
+
* Classnames applied to the `<button>` to mute a RuleGroup.
|
|
2225
|
+
*/
|
|
2226
|
+
muteGroup: Classname;
|
|
2227
|
+
/**
|
|
3038
2228
|
* Classnames applied to the `<select>` control for value sources.
|
|
3039
2229
|
*/
|
|
3040
2230
|
valueSource: Classname;
|
|
@@ -3086,6 +2276,10 @@ interface Classnames {
|
|
|
3086
2276
|
*/
|
|
3087
2277
|
disabled: Classname;
|
|
3088
2278
|
/**
|
|
2279
|
+
* Classname(s) applied to muted elements.
|
|
2280
|
+
*/
|
|
2281
|
+
muted: Classname;
|
|
2282
|
+
/**
|
|
3089
2283
|
* Classname(s) applied to each element in a series of value editors.
|
|
3090
2284
|
*/
|
|
3091
2285
|
valueListItem: Classname;
|
|
@@ -3099,6 +2293,89 @@ interface Classnames {
|
|
|
3099
2293
|
hasSubQuery: Classname;
|
|
3100
2294
|
}
|
|
3101
2295
|
/**
|
|
2296
|
+
* Placeholder strings for option lists.
|
|
2297
|
+
*
|
|
2298
|
+
* @group Props
|
|
2299
|
+
*/
|
|
2300
|
+
interface Placeholder {
|
|
2301
|
+
/**
|
|
2302
|
+
* Value for the placeholder field option if autoSelectField is false,
|
|
2303
|
+
* or the placeholder operator option if autoSelectOperator is false.
|
|
2304
|
+
*/
|
|
2305
|
+
placeholderName?: string;
|
|
2306
|
+
/**
|
|
2307
|
+
* Label for the placeholder field option if autoSelectField is false,
|
|
2308
|
+
* or the placeholder operator option if autoSelectOperator is false.
|
|
2309
|
+
*/
|
|
2310
|
+
placeholderLabel?: string;
|
|
2311
|
+
/**
|
|
2312
|
+
* Label for the placeholder field optgroup if autoSelectField is false,
|
|
2313
|
+
* or the placeholder operator optgroup if autoSelectOperator is false.
|
|
2314
|
+
*/
|
|
2315
|
+
placeholderGroupLabel?: string;
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* A translation for a component with `title` only.
|
|
2319
|
+
*
|
|
2320
|
+
* @group Props
|
|
2321
|
+
*/
|
|
2322
|
+
interface BaseTranslation {
|
|
2323
|
+
title?: string;
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* A translation for a component with `title` and `label`.
|
|
2327
|
+
*
|
|
2328
|
+
* @group Props
|
|
2329
|
+
*/
|
|
2330
|
+
interface BaseTranslationWithLabel<LabelType = string> extends BaseTranslation {
|
|
2331
|
+
label?: LabelType;
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2334
|
+
* A translation for a component with `title` and a placeholder.
|
|
2335
|
+
*
|
|
2336
|
+
* @group Props
|
|
2337
|
+
*/
|
|
2338
|
+
interface BaseTranslationWithPlaceholders extends BaseTranslation, Placeholder {}
|
|
2339
|
+
/**
|
|
2340
|
+
* The shape of the `translations` prop.
|
|
2341
|
+
*
|
|
2342
|
+
* @group Props
|
|
2343
|
+
*/
|
|
2344
|
+
interface BaseTranslations<LabelType = string> {
|
|
2345
|
+
fields: BaseTranslationWithPlaceholders;
|
|
2346
|
+
operators: BaseTranslationWithPlaceholders;
|
|
2347
|
+
values: BaseTranslationWithPlaceholders;
|
|
2348
|
+
matchMode: BaseTranslation;
|
|
2349
|
+
matchThreshold: BaseTranslation;
|
|
2350
|
+
value: BaseTranslation;
|
|
2351
|
+
removeRule: BaseTranslationWithLabel<LabelType>;
|
|
2352
|
+
removeGroup: BaseTranslationWithLabel<LabelType>;
|
|
2353
|
+
addRule: BaseTranslationWithLabel<LabelType>;
|
|
2354
|
+
addGroup: BaseTranslationWithLabel<LabelType>;
|
|
2355
|
+
combinators: BaseTranslation;
|
|
2356
|
+
notToggle: BaseTranslationWithLabel<LabelType>;
|
|
2357
|
+
cloneRule: BaseTranslationWithLabel<LabelType>;
|
|
2358
|
+
cloneRuleGroup: BaseTranslationWithLabel<LabelType>;
|
|
2359
|
+
shiftActionUp: BaseTranslationWithLabel<LabelType>;
|
|
2360
|
+
shiftActionDown: BaseTranslationWithLabel<LabelType>;
|
|
2361
|
+
dragHandle: BaseTranslationWithLabel<LabelType>;
|
|
2362
|
+
lockRule: BaseTranslationWithLabel<LabelType>;
|
|
2363
|
+
lockGroup: BaseTranslationWithLabel<LabelType>;
|
|
2364
|
+
lockRuleDisabled: BaseTranslationWithLabel<LabelType>;
|
|
2365
|
+
lockGroupDisabled: BaseTranslationWithLabel<LabelType>;
|
|
2366
|
+
muteRule: BaseTranslationWithLabel<LabelType>;
|
|
2367
|
+
muteGroup: BaseTranslationWithLabel<LabelType>;
|
|
2368
|
+
unmuteRule: BaseTranslationWithLabel<LabelType>;
|
|
2369
|
+
unmuteGroup: BaseTranslationWithLabel<LabelType>;
|
|
2370
|
+
valueSourceSelector: BaseTranslation;
|
|
2371
|
+
}
|
|
2372
|
+
/**
|
|
2373
|
+
* The full `translations` interface with all properties required.
|
|
2374
|
+
*
|
|
2375
|
+
* @group Props
|
|
2376
|
+
*/
|
|
2377
|
+
type BaseTranslationsFull<LabelType = string> = RequiredDeep<BaseTranslations<LabelType>>;
|
|
2378
|
+
/**
|
|
3102
2379
|
* Functions included in the `actions` prop passed to every subcomponent.
|
|
3103
2380
|
*
|
|
3104
2381
|
* @group Props
|
|
@@ -3112,6 +2389,113 @@ interface QueryActions {
|
|
|
3112
2389
|
moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
|
|
3113
2390
|
groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
|
|
3114
2391
|
}
|
|
2392
|
+
interface QueryBuilderFlags {
|
|
2393
|
+
/**
|
|
2394
|
+
* Set to `false` to avoid calling the `onQueryChange` callback
|
|
2395
|
+
* when the component mounts.
|
|
2396
|
+
*
|
|
2397
|
+
* @default true
|
|
2398
|
+
*/
|
|
2399
|
+
enableMountQueryChange?: boolean;
|
|
2400
|
+
/**
|
|
2401
|
+
* Enables drag-and-drop features.
|
|
2402
|
+
*
|
|
2403
|
+
* @default false
|
|
2404
|
+
*/
|
|
2405
|
+
enableDragAndDrop?: boolean;
|
|
2406
|
+
/**
|
|
2407
|
+
* Enables debug logging for query builders (and React DnD when applicable).
|
|
2408
|
+
*
|
|
2409
|
+
* @default false
|
|
2410
|
+
*/
|
|
2411
|
+
debugMode?: boolean;
|
|
2412
|
+
/**
|
|
2413
|
+
* Show group combinator selectors in the body of the group, between each child rule/group,
|
|
2414
|
+
* instead of in the group header.
|
|
2415
|
+
*
|
|
2416
|
+
* @default false
|
|
2417
|
+
*/
|
|
2418
|
+
showCombinatorsBetweenRules?: boolean;
|
|
2419
|
+
/**
|
|
2420
|
+
* Show the "not" (aka inversion) toggle for rule groups.
|
|
2421
|
+
*
|
|
2422
|
+
* @default false
|
|
2423
|
+
*/
|
|
2424
|
+
showNotToggle?: boolean;
|
|
2425
|
+
/**
|
|
2426
|
+
* Show the "Shift up"/"Shift down" actions.
|
|
2427
|
+
*
|
|
2428
|
+
* @default false
|
|
2429
|
+
*/
|
|
2430
|
+
showShiftActions?: boolean;
|
|
2431
|
+
/**
|
|
2432
|
+
* Show the "Clone rule" and "Clone group" buttons.
|
|
2433
|
+
*
|
|
2434
|
+
* @default false
|
|
2435
|
+
*/
|
|
2436
|
+
showCloneButtons?: boolean;
|
|
2437
|
+
/**
|
|
2438
|
+
* Show the "Lock rule" and "Lock group" buttons.
|
|
2439
|
+
*
|
|
2440
|
+
* @default false
|
|
2441
|
+
*/
|
|
2442
|
+
showLockButtons?: boolean;
|
|
2443
|
+
/**
|
|
2444
|
+
* Show the "Mute rule" and "Mute group" buttons.
|
|
2445
|
+
*
|
|
2446
|
+
* @default false
|
|
2447
|
+
*/
|
|
2448
|
+
showMuteButtons?: boolean;
|
|
2449
|
+
/**
|
|
2450
|
+
* Reset the `operator` and `value` when the `field` changes.
|
|
2451
|
+
*
|
|
2452
|
+
* @default true
|
|
2453
|
+
*/
|
|
2454
|
+
resetOnFieldChange?: boolean;
|
|
2455
|
+
/**
|
|
2456
|
+
* Reset the `value` when the `operator` changes.
|
|
2457
|
+
*
|
|
2458
|
+
* @default false
|
|
2459
|
+
*/
|
|
2460
|
+
resetOnOperatorChange?: boolean;
|
|
2461
|
+
/**
|
|
2462
|
+
* Select the first field in the array automatically.
|
|
2463
|
+
*
|
|
2464
|
+
* @default true
|
|
2465
|
+
*/
|
|
2466
|
+
autoSelectField?: boolean;
|
|
2467
|
+
/**
|
|
2468
|
+
* Select the first operator in the array automatically.
|
|
2469
|
+
*
|
|
2470
|
+
* @default true
|
|
2471
|
+
*/
|
|
2472
|
+
autoSelectOperator?: boolean;
|
|
2473
|
+
/**
|
|
2474
|
+
* Select the first value in the array automatically. Only applicable when the value editor renders a select list.
|
|
2475
|
+
*
|
|
2476
|
+
* @default false
|
|
2477
|
+
*/
|
|
2478
|
+
autoSelectValue?: boolean;
|
|
2479
|
+
/**
|
|
2480
|
+
* Adds a new default rule automatically to each new group.
|
|
2481
|
+
*
|
|
2482
|
+
* @default false
|
|
2483
|
+
*/
|
|
2484
|
+
addRuleToNewGroups?: boolean;
|
|
2485
|
+
/**
|
|
2486
|
+
* Store list-type values as native arrays instead of comma-separated strings.
|
|
2487
|
+
*
|
|
2488
|
+
* @default false
|
|
2489
|
+
*/
|
|
2490
|
+
listsAsArrays?: boolean;
|
|
2491
|
+
/**
|
|
2492
|
+
* Prevent _any_ assignment of standard classes to elements. This includes conditional
|
|
2493
|
+
* and event-based classes for validation, drag-and-drop, etc.
|
|
2494
|
+
*
|
|
2495
|
+
* @default false
|
|
2496
|
+
*/
|
|
2497
|
+
suppressStandardClassnames?: boolean;
|
|
2498
|
+
}
|
|
3115
2499
|
//#endregion
|
|
3116
2500
|
//#region src/defaults.d.ts
|
|
3117
2501
|
/**
|
|
@@ -3177,6 +2561,12 @@ declare const defaultPlaceholderValueLabel: typeof defaultPlaceholderLabel;
|
|
|
3177
2561
|
*/
|
|
3178
2562
|
declare const defaultPlaceholderValueGroupLabel: typeof defaultPlaceholderLabel;
|
|
3179
2563
|
/**
|
|
2564
|
+
* Default configuration of translatable strings.
|
|
2565
|
+
*
|
|
2566
|
+
* @group Defaults
|
|
2567
|
+
*/
|
|
2568
|
+
declare const defaultTranslations: BaseTranslationsFull;
|
|
2569
|
+
/**
|
|
3180
2570
|
* Default character used to `.join` and `.split` arrays.
|
|
3181
2571
|
*
|
|
3182
2572
|
* @group Defaults
|
|
@@ -3253,8 +2643,11 @@ declare const standardClassnames: {
|
|
|
3253
2643
|
readonly dndDropNotAllowed: "dndDropNotAllowed";
|
|
3254
2644
|
readonly dragHandle: "queryBuilder-dragHandle";
|
|
3255
2645
|
readonly disabled: "queryBuilder-disabled";
|
|
2646
|
+
readonly muted: "queryBuilder-muted";
|
|
3256
2647
|
readonly lockRule: "rule-lock";
|
|
3257
2648
|
readonly lockGroup: "ruleGroup-lock";
|
|
2649
|
+
readonly muteRule: "rule-mute";
|
|
2650
|
+
readonly muteGroup: "ruleGroup-mute";
|
|
3258
2651
|
readonly valueSource: "rule-valueSource";
|
|
3259
2652
|
readonly valueListItem: "rule-value-list-item";
|
|
3260
2653
|
readonly branches: "queryBuilder-branches";
|
|
@@ -3301,6 +2694,8 @@ declare const TestID: {
|
|
|
3301
2694
|
readonly dragHandle: "drag-handle";
|
|
3302
2695
|
readonly lockRule: "lock-rule";
|
|
3303
2696
|
readonly lockGroup: "lock-group";
|
|
2697
|
+
readonly muteRule: "mute-rule";
|
|
2698
|
+
readonly muteGroup: "mute-group";
|
|
3304
2699
|
readonly valueSourceSelector: "value-source-selector";
|
|
3305
2700
|
readonly matchModeEditor: "match-mode-editor";
|
|
3306
2701
|
};
|
|
@@ -3327,6 +2722,13 @@ declare const LogType: {
|
|
|
3327
2722
|
* @group Defaults
|
|
3328
2723
|
*/
|
|
3329
2724
|
declare const rootPath: Path;
|
|
2725
|
+
/**
|
|
2726
|
+
* Default values for all `boolean`
|
|
2727
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder} options.
|
|
2728
|
+
*
|
|
2729
|
+
* @group Defaults
|
|
2730
|
+
*/
|
|
2731
|
+
declare const queryBuilderFlagDefaults: Required<QueryBuilderFlags>;
|
|
3330
2732
|
//#endregion
|
|
3331
2733
|
//#region src/utils/arrayUtils.d.ts
|
|
3332
2734
|
/**
|
|
@@ -3421,7 +2823,7 @@ declare function convertQuery(query: RuleGroupTypeIC): RuleGroupType;
|
|
|
3421
2823
|
//#endregion
|
|
3422
2824
|
//#region src/utils/defaultValidator.d.ts
|
|
3423
2825
|
/**
|
|
3424
|
-
* This is an example validation function you can pass to {@link QueryBuilder} in the
|
|
2826
|
+
* This is an example validation function you can pass to {@link react-querybuilder!QueryBuilder QueryBuilder} in the
|
|
3425
2827
|
* `validator` prop. It assumes that you want to validate groups, and has a no-op
|
|
3426
2828
|
* for validating rules which you can replace with your own implementation.
|
|
3427
2829
|
*/
|
|
@@ -4183,10 +3585,18 @@ declare const isRuleGroupTypeIC: (rg: unknown) => rg is RuleGroupTypeIC;
|
|
|
4183
3585
|
declare const isValidationResult: (vr?: ValidationResult) => vr is ValidationResult;
|
|
4184
3586
|
/**
|
|
4185
3587
|
* Determines if a rule or group is valid based on a validation result (if defined)
|
|
4186
|
-
* or a validator function. Returns `true` if neither are defined
|
|
3588
|
+
* or a validator function. Returns `true` if neither are defined and the `muted`
|
|
3589
|
+
* property is not `true`.
|
|
4187
3590
|
*/
|
|
4188
3591
|
declare const isRuleOrGroupValid: (rg: RuleType | RuleGroupTypeAny, validationResult?: boolean | ValidationResult, validator?: RuleValidator) => boolean;
|
|
4189
3592
|
//#endregion
|
|
3593
|
+
//#region src/utils/mergeAnyTranslations.d.ts
|
|
3594
|
+
/**
|
|
3595
|
+
* Merges any number of partial translations into a single definition.
|
|
3596
|
+
*/
|
|
3597
|
+
declare const mergeAnyTranslations: (base: Record<string, Record<string, unknown>>, ...otherTranslations: (Record<string, Record<string, unknown>> | undefined)[]) => Record<string, Record<string, unknown>>;
|
|
3598
|
+
declare const mergeAnyTranslation: (el: string, keyPropContextMap: Record<string, [unknown, unknown]>, defaults?: Record<string, Record<string, unknown>>) => Record<string, Record<string, unknown>> | undefined;
|
|
3599
|
+
//#endregion
|
|
4190
3600
|
//#region src/utils/mergeClassnames.d.ts
|
|
4191
3601
|
type MergeClassnamesParams = (Partial<Classnames> | undefined)[];
|
|
4192
3602
|
/**
|
|
@@ -4220,7 +3630,7 @@ declare const nullOrUndefinedOrEmpty: (value: unknown) => value is null | undefi
|
|
|
4220
3630
|
* type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
|
|
4221
3631
|
* ```
|
|
4222
3632
|
*/
|
|
4223
|
-
type ObjectKeys<T extends object> = Exclude<keyof T, symbol>;
|
|
3633
|
+
type ObjectKeys<T$1 extends object> = Exclude<keyof T$1, symbol>;
|
|
4224
3634
|
/**
|
|
4225
3635
|
* A strongly-typed version of `Object.keys()`.
|
|
4226
3636
|
*
|
|
@@ -4241,14 +3651,14 @@ declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value:
|
|
|
4241
3651
|
*
|
|
4242
3652
|
* @group Option Lists
|
|
4243
3653
|
*/
|
|
4244
|
-
declare function toFullOption<Opt extends BaseOption>(opt: Opt | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt>;
|
|
3654
|
+
declare function toFullOption<Opt$1 extends BaseOption>(opt: Opt$1 | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt$1>;
|
|
4245
3655
|
/**
|
|
4246
3656
|
* Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
4247
3657
|
* Lists of full options are left unchanged.
|
|
4248
3658
|
*
|
|
4249
3659
|
* @group Option Lists
|
|
4250
3660
|
*/
|
|
4251
|
-
declare function toFullOptionList<Opt extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt>;
|
|
3661
|
+
declare function toFullOptionList<Opt$1 extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt$1>;
|
|
4252
3662
|
/**
|
|
4253
3663
|
* Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.
|
|
4254
3664
|
* Lists of full options are left unchanged.
|
|
@@ -4330,9 +3740,9 @@ declare function getOption<OptType extends Option>(arr: FlexibleOptionList<OptTy
|
|
|
4330
3740
|
*
|
|
4331
3741
|
* @group Option Lists
|
|
4332
3742
|
*/
|
|
4333
|
-
declare function getFirstOption<Opt extends FullOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
4334
|
-
declare function getFirstOption<Opt extends ValueOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
4335
|
-
declare function getFirstOption<Opt extends Option>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
|
|
3743
|
+
declare function getFirstOption<Opt$1 extends FullOption>(arr?: OptionGroup<Opt$1>[] | Opt$1[]): GetOptionIdentifierType<Opt$1> | null;
|
|
3744
|
+
declare function getFirstOption<Opt$1 extends ValueOption>(arr?: OptionGroup<Opt$1>[] | Opt$1[]): GetOptionIdentifierType<Opt$1> | null;
|
|
3745
|
+
declare function getFirstOption<Opt$1 extends Option>(arr?: OptionGroup<Opt$1>[] | Opt$1[]): GetOptionIdentifierType<Opt$1> | null;
|
|
4336
3746
|
/**
|
|
4337
3747
|
* Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.
|
|
4338
3748
|
* If the array is already flat, it is returned as is.
|
|
@@ -4354,6 +3764,19 @@ declare const uniqOptGroups: <T extends BaseOption>(originalArray: FlexibleOptio
|
|
|
4354
3764
|
* @group Option Lists
|
|
4355
3765
|
*/
|
|
4356
3766
|
declare const uniqOptList: <T extends BaseOption>(originalArray: FlexibleOptionList<T>) => WithUnknownIndex<BaseOption & FullOption>[] | OptionGroup<ToFullOption<T>>[];
|
|
3767
|
+
interface PreparedOptionList<O$1 extends FullOption> {
|
|
3768
|
+
defaultOption: FullOption;
|
|
3769
|
+
optionList: O$1[] | OptionGroup<O$1>[];
|
|
3770
|
+
optionsMap: Partial<FullOptionRecord<FullOption>>;
|
|
3771
|
+
}
|
|
3772
|
+
interface PrepareOptionListParams<O$1 extends FullOption> {
|
|
3773
|
+
placeholder?: Placeholder;
|
|
3774
|
+
optionList?: FlexibleOptionListProp<O$1> | BaseOptionMap<O$1>;
|
|
3775
|
+
baseOption?: Record<string, unknown>;
|
|
3776
|
+
labelMap?: Record<string, string>;
|
|
3777
|
+
autoSelectOption?: boolean;
|
|
3778
|
+
}
|
|
3779
|
+
declare const prepareOptionList: <O extends FullOption>(props: PrepareOptionListParams<O>) => PreparedOptionList<O>;
|
|
4357
3780
|
//#endregion
|
|
4358
3781
|
//#region src/utils/parseNumber.d.ts
|
|
4359
3782
|
/**
|
|
@@ -4421,6 +3844,23 @@ declare const getCommonAncestorPath: (path1: Path, path2: Path) => Path;
|
|
|
4421
3844
|
*/
|
|
4422
3845
|
declare const pathIsDisabled: (path: Path, query: RuleGroupTypeAny) => boolean;
|
|
4423
3846
|
//#endregion
|
|
3847
|
+
//#region src/utils/preferProp.d.ts
|
|
3848
|
+
/**
|
|
3849
|
+
* For given default, prop, and context values, return the first provided of prop,
|
|
3850
|
+
* context, and default, in that order.
|
|
3851
|
+
*/
|
|
3852
|
+
declare const preferProp: (def: boolean, prop?: boolean, context?: boolean, doNotFinalize?: boolean) => boolean;
|
|
3853
|
+
/**
|
|
3854
|
+
* For given default, prop, and context values, return the first provided of prop,
|
|
3855
|
+
* context, and default, in that order.
|
|
3856
|
+
*/
|
|
3857
|
+
declare const preferAnyProp: (def?: any, prop?: any, context?: any) => any;
|
|
3858
|
+
/**
|
|
3859
|
+
* For a given set of defaults, props, and context values, return the first provided of prop,
|
|
3860
|
+
* context, and default—in that order—for each property in the defaults object.
|
|
3861
|
+
*/
|
|
3862
|
+
declare const preferFlagProps: (props?: QueryBuilderFlags, contextVals?: QueryBuilderFlags, finalize?: boolean) => QueryBuilderFlags;
|
|
3863
|
+
//#endregion
|
|
4424
3864
|
//#region src/utils/prepareQueryObjects.d.ts
|
|
4425
3865
|
/**
|
|
4426
3866
|
* Options for {@link prepareRule}/{@link prepareRuleGroup}.
|
|
@@ -4684,7 +4124,7 @@ declare const regenerateIDs: <RG>(subject: RG, {
|
|
|
4684
4124
|
/**
|
|
4685
4125
|
* Options object for {@link index!transformQuery transformQuery}.
|
|
4686
4126
|
*/
|
|
4687
|
-
interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {
|
|
4127
|
+
interface TransformQueryOptions<RG$1 extends RuleGroupTypeAny = RuleGroupType> {
|
|
4688
4128
|
/**
|
|
4689
4129
|
* When a rule is encountered in the hierarchy, it will be replaced
|
|
4690
4130
|
* with the result of this function.
|
|
@@ -4698,7 +4138,7 @@ interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {
|
|
|
4698
4138
|
*
|
|
4699
4139
|
* @defaultValue `rg => rg`
|
|
4700
4140
|
*/
|
|
4701
|
-
ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;
|
|
4141
|
+
ruleGroupProcessor?: (ruleGroup: RG$1) => Record<string, any>;
|
|
4702
4142
|
/**
|
|
4703
4143
|
* For each rule and group in the query, any properties matching a key
|
|
4704
4144
|
* in this object will be renamed to the corresponding value. To retain both
|
|
@@ -4793,5 +4233,5 @@ declare function transformQuery(query: RuleGroupType, options?: TransformQueryOp
|
|
|
4793
4233
|
*/
|
|
4794
4234
|
declare function transformQuery(query: RuleGroupTypeIC, options?: TransformQueryOptions<RuleGroupTypeIC>): any;
|
|
4795
4235
|
//#endregion
|
|
4796
|
-
export { AccessibleDescriptionGenerator, ActionElementEventHandler, AddOptions,
|
|
4236
|
+
export { AccessibleDescriptionGenerator, ActionElementEventHandler, AddOptions, Arity, BaseFullOption, BaseOption, BaseOptionMap, BaseTranslation, BaseTranslationWithLabel, BaseTranslationWithPlaceholders, BaseTranslations, BaseTranslationsFull, Classname, Classnames, Combinator, CombinatorByValue, CommonRuleAndGroupProperties, CommonRuleSubComponentProps, ConstituentWordOrder, ConstituentWordOrderString, DefaultCombinator, DefaultCombinatorExtended, DefaultCombinatorName, DefaultCombinatorNameExtended, DefaultCombinators, DefaultCombinatorsExtended, DefaultMatchModes, DefaultOperator, DefaultOperatorName, DefaultOperators, DefaultRuleGroupArray, DefaultRuleGroupICArray, DefaultRuleGroupType, DefaultRuleGroupTypeAny, DefaultRuleGroupTypeIC, DefaultRuleOrGroupArray, DefaultRuleType, DndDropTargetType, DragCollection, DraggedItem, DropCollection, DropEffect, DropResult, ExportFormat, ExportObjectFormats, ExportOperatorMap, Field, FieldByValue, FindPathReturnType, FlexibleOption, FlexibleOptionGroup, FlexibleOptionList, FlexibleOptionListProp, FormatQueryFinalOptions, FormatQueryOptions, FormatQueryValidateRule, FullCombinator, FullField, FullOperator, FullOption, FullOptionList, FullOptionMap, FullOptionRecord, GenericizeRuleGroupType, GetOptionIdentifierType, GetOptionType, GetRuleGroupType, GetRuleTypeFromGroupWithFieldAndOperator, GroupOptions, GroupVariantCondition, InputType, InsertOptions, type JsonLogicAll, type JsonLogicAnd, type JsonLogicDoubleNegation, type JsonLogicEqual, type JsonLogicGreaterThan, type JsonLogicGreaterThanOrEqual, type JsonLogicInArray, type JsonLogicInString, type JsonLogicLessThan, type JsonLogicLessThanOrEqual, type JsonLogicNegation, type JsonLogicNone, type JsonLogicNotEqual, type JsonLogicOr, type JsonLogicReservedOperations, type JsonLogicRulesLogic, type JsonLogicSome, type JsonLogicStrictEqual, type JsonLogicStrictNotEqual, type JsonLogicVar, LogType, MatchConfig, MatchMode, MatchModeOptions, MoveOptions, NLTranslationKey, NLTranslations, NameLabelPair, Operator, OperatorByValue, Option, OptionGroup, OptionList, ParameterizedNamedSQL, ParameterizedSQL, ParseNumberMethod, ParseNumberOptions, ParseNumbersPropConfig, Path, Placeholder, PrepareOptionListParams, PreparedOptionList, PreparerOptions, QueryActions, QueryBuilderFlags, QueryValidator, RQBJsonLogic, RQBJsonLogicEndsWith, RQBJsonLogicStartsWith, RQBJsonLogicVar, RegenerateIdOptions, RemoveNullability, RuleGroupArray, RuleGroupICArray, RuleGroupProcessor, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleOrGroupArray, RuleProcessor, RuleType, RuleValidator, SQLPreset, StringUnionToFlexibleOptionArray, StringUnionToFullOptionArray, TestID, ToFlexibleOption, ToFullOption, TransformQueryOptions, UpdateOptions, UpdateableProperties, ValidationMap, ValidationResult, ValueChangeEventHandler, ValueEditorType, ValueOption, ValueProcessor, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions, ValueSource, ValueSourceFlexibleOptions, ValueSourceFullOptions, ValueSources, WithRequired, WithUnknownIndex, add, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleProcessorCEL, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInvalidReasons, insert, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, preferAnyProp, preferFlagProps, preferProp, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, queryBuilderFlagDefaults, regenerateID, regenerateIDs, remove, rootPath, shouldRenderAsNumber, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update };
|
|
4797
4237
|
//# sourceMappingURL=react-querybuilder_core.legacy-esm.d.ts.map
|