@react-querybuilder/datetime 8.14.0 → 8.14.2

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.
Files changed (98) hide show
  1. package/dist/cjs/{getDatetimeRuleProcessorSQL-Dkg4HEtH.js → getDatetimeRuleProcessorSQL-Bn34z-S-.js} +73 -79
  2. package/dist/cjs/getDatetimeRuleProcessorSQL-Bn34z-S-.js.map +1 -0
  3. package/dist/cjs/getDatetimeRuleProcessorSQL-Cs8MroHp.js +2 -0
  4. package/dist/cjs/getDatetimeRuleProcessorSQL-Cs8MroHp.js.map +1 -0
  5. package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +2 -2
  6. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +2 -2
  7. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +4 -5
  8. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js.map +1 -1
  9. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +2 -2
  10. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +10 -16
  11. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js.map +1 -1
  12. package/dist/cjs/react-querybuilder_datetime.cjs.development.js +7 -8
  13. package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
  14. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +2 -2
  15. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +3 -4
  16. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js.map +1 -1
  17. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +2 -2
  18. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +4 -5
  19. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js.map +1 -1
  20. package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +2 -2
  21. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +2 -2
  22. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
  23. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js.map +1 -1
  24. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +2 -2
  25. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
  26. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js.map +1 -1
  27. package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
  28. package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
  29. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +2 -2
  30. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
  31. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js.map +1 -1
  32. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +2 -2
  33. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
  34. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js.map +1 -1
  35. package/dist/cjs/types-BIfMyAwh.d.ts +105 -0
  36. package/dist/{getDatetimeRuleProcessorSQL-Dcqi5kh5.mjs → getDatetimeRuleProcessorSQL-Cbq2-tqd.mjs} +1 -1
  37. package/dist/getDatetimeRuleProcessorSQL-Cbq2-tqd.mjs.map +1 -0
  38. package/dist/{getDatetimeRuleProcessorSQL-CugqyF_a.mjs → getDatetimeRuleProcessorSQL-CnAPMZf2.mjs} +2 -8
  39. package/dist/getDatetimeRuleProcessorSQL-CnAPMZf2.mjs.map +1 -0
  40. package/dist/{getDatetimeRuleProcessorSQL-Cxyajj0g.js → getDatetimeRuleProcessorSQL-r7Vd5Cm4.js} +17 -28
  41. package/dist/getDatetimeRuleProcessorSQL-r7Vd5Cm4.js.map +1 -0
  42. package/dist/react-querybuilder_datetime.d.mts +2 -2
  43. package/dist/react-querybuilder_datetime.date-fns.d.mts +2 -2
  44. package/dist/react-querybuilder_datetime.date-fns.mjs +2 -4
  45. package/dist/react-querybuilder_datetime.date-fns.mjs.map +1 -1
  46. package/dist/react-querybuilder_datetime.dayjs.d.mts +2 -2
  47. package/dist/react-querybuilder_datetime.dayjs.mjs +2 -4
  48. package/dist/react-querybuilder_datetime.dayjs.mjs.map +1 -1
  49. package/dist/react-querybuilder_datetime.jsdate.d.mts +2 -2
  50. package/dist/react-querybuilder_datetime.jsdate.mjs +2 -4
  51. package/dist/react-querybuilder_datetime.jsdate.mjs.map +1 -1
  52. package/dist/react-querybuilder_datetime.legacy-esm.d.ts +2 -2
  53. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +2 -2
  54. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -4
  55. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js.map +1 -1
  56. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +2 -2
  57. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -4
  58. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js.map +1 -1
  59. package/dist/react-querybuilder_datetime.legacy-esm.js +5 -7
  60. package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
  61. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +2 -2
  62. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -4
  63. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js.map +1 -1
  64. package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +2 -2
  65. package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -4
  66. package/dist/react-querybuilder_datetime.legacy-esm.luxon.js.map +1 -1
  67. package/dist/react-querybuilder_datetime.luxon.d.mts +2 -2
  68. package/dist/react-querybuilder_datetime.luxon.mjs +2 -4
  69. package/dist/react-querybuilder_datetime.luxon.mjs.map +1 -1
  70. package/dist/react-querybuilder_datetime.mjs +5 -7
  71. package/dist/react-querybuilder_datetime.mjs.map +1 -1
  72. package/dist/react-querybuilder_datetime.production.d.mts +2 -2
  73. package/dist/react-querybuilder_datetime.production.date-fns.d.mts +2 -2
  74. package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
  75. package/dist/react-querybuilder_datetime.production.date-fns.mjs.map +1 -1
  76. package/dist/react-querybuilder_datetime.production.dayjs.d.mts +2 -2
  77. package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
  78. package/dist/react-querybuilder_datetime.production.dayjs.mjs.map +1 -1
  79. package/dist/react-querybuilder_datetime.production.jsdate.d.mts +2 -2
  80. package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
  81. package/dist/react-querybuilder_datetime.production.jsdate.mjs.map +1 -1
  82. package/dist/react-querybuilder_datetime.production.luxon.d.mts +2 -2
  83. package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
  84. package/dist/react-querybuilder_datetime.production.luxon.mjs.map +1 -1
  85. package/dist/react-querybuilder_datetime.production.mjs +1 -1
  86. package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
  87. package/dist/types-Dbg6IgzZ.d.ts +105 -0
  88. package/dist/types-IRRXKZl4.d.mts +105 -0
  89. package/package.json +16 -16
  90. package/dist/cjs/getDatetimeRuleProcessorSQL-Dkg4HEtH.js.map +0 -1
  91. package/dist/cjs/getDatetimeRuleProcessorSQL-xGETy1ec.js +0 -2
  92. package/dist/cjs/getDatetimeRuleProcessorSQL-xGETy1ec.js.map +0 -1
  93. package/dist/cjs/types-B0Eveeq4.d.ts +0 -1752
  94. package/dist/getDatetimeRuleProcessorSQL-CugqyF_a.mjs.map +0 -1
  95. package/dist/getDatetimeRuleProcessorSQL-Cxyajj0g.js.map +0 -1
  96. package/dist/getDatetimeRuleProcessorSQL-Dcqi5kh5.mjs.map +0 -1
  97. package/dist/types-C-P0L9xh.d.mts +0 -1753
  98. package/dist/types-DuaAB95e.d.ts +0 -1753
@@ -1,1753 +0,0 @@
1
- import { RulesLogic } from "json-logic-js";
2
- import "react";
3
-
4
- //#region ../../node_modules/type-fest/source/union-to-intersection.d.ts
5
-
6
- /**
7
- 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).
8
-
9
- Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
10
-
11
- @example
12
- ```
13
- import type {UnionToIntersection} from 'type-fest';
14
-
15
- type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
16
-
17
- type Intersection = UnionToIntersection<Union>;
18
- //=> {the(): void; great(arg: string): void; escape: boolean};
19
- ```
20
-
21
- @category Type
22
- */
23
- type UnionToIntersection<Union> = (
24
- // `extends unknown` is always going to be the case and is used to convert the
25
- // `Union` into a [distributive conditional
26
- // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
27
- Union extends unknown
28
- // The union type is used as the only argument to a function since the union
29
- // of function arguments is an intersection.
30
- ? (distributedUnion: Union) => void
31
- // This won't happen.
32
- : never
33
- // Infer the `Intersection` type since TypeScript represents the positional
34
- // arguments of unions of functions as an intersection of the union.
35
- ) extends ((mergedIntersection: infer Intersection) => void)
36
- // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
37
- ? Intersection & Union : never;
38
- //#endregion
39
- //#region ../../node_modules/type-fest/source/keys-of-union.d.ts
40
- /**
41
- Create a union of all keys from a given type, even those exclusive to specific union members.
42
-
43
- Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
44
-
45
- @link https://stackoverflow.com/a/49402091
46
-
47
- @example
48
- ```
49
- import type {KeysOfUnion} from 'type-fest';
50
-
51
- type A = {
52
- common: string;
53
- a: number;
54
- };
55
-
56
- type B = {
57
- common: string;
58
- b: string;
59
- };
60
-
61
- type C = {
62
- common: string;
63
- c: boolean;
64
- };
65
-
66
- type Union = A | B | C;
67
-
68
- type CommonKeys = keyof Union;
69
- //=> 'common'
70
-
71
- type AllKeys = KeysOfUnion<Union>;
72
- //=> 'common' | 'a' | 'b' | 'c'
73
- ```
74
-
75
- @category Object
76
- */
77
- type KeysOfUnion<ObjectType> =
78
- // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
79
- keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
80
- //#endregion
81
- //#region ../../node_modules/type-fest/source/is-any.d.ts
82
- /**
83
- Returns a boolean for whether the given type is `any`.
84
-
85
- @link https://stackoverflow.com/a/49928360/1490091
86
-
87
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
88
-
89
- @example
90
- ```
91
- import type {IsAny} from 'type-fest';
92
-
93
- const typedObject = {a: 1, b: 2} as const;
94
- const anyObject: any = {a: 1, b: 2};
95
-
96
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
97
- return object[key];
98
- }
99
-
100
- const typedA = get(typedObject, 'a');
101
- //=> 1
102
-
103
- const anyA = get(anyObject, 'a');
104
- //=> any
105
- ```
106
-
107
- @category Type Guard
108
- @category Utilities
109
- */
110
- type IsAny<T$1> = 0 extends 1 & NoInfer<T$1> ? true : false;
111
- //#endregion
112
- //#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
113
- /**
114
- Returns a boolean for whether the given key is an optional key of type.
115
-
116
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
117
-
118
- @example
119
- ```
120
- import type {IsOptionalKeyOf} from 'type-fest';
121
-
122
- type User = {
123
- name: string;
124
- surname: string;
125
-
126
- luckyNumber?: number;
127
- };
128
-
129
- type Admin = {
130
- name: string;
131
- surname?: string;
132
- };
133
-
134
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
135
- //=> true
136
-
137
- type T2 = IsOptionalKeyOf<User, 'name'>;
138
- //=> false
139
-
140
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
141
- //=> boolean
142
-
143
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
144
- //=> false
145
-
146
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
147
- //=> boolean
148
- ```
149
-
150
- @category Type Guard
151
- @category Utilities
152
- */
153
- type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
154
- //#endregion
155
- //#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
156
- /**
157
- Extract all optional keys from the given type.
158
-
159
- This is useful when you want to create a new type that contains different type values for the optional keys only.
160
-
161
- @example
162
- ```
163
- import type {OptionalKeysOf, Except} from 'type-fest';
164
-
165
- type User = {
166
- name: string;
167
- surname: string;
168
-
169
- luckyNumber?: number;
170
- };
171
-
172
- const REMOVE_FIELD = Symbol('remove field symbol');
173
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
174
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
175
- };
176
-
177
- const update1: UpdateOperation<User> = {
178
- name: 'Alice',
179
- };
180
-
181
- const update2: UpdateOperation<User> = {
182
- name: 'Bob',
183
- luckyNumber: REMOVE_FIELD,
184
- };
185
- ```
186
-
187
- @category Utilities
188
- */
189
- type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
190
- ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
191
- : never;
192
- //#endregion
193
- //#region ../../node_modules/type-fest/source/required-keys-of.d.ts
194
- /**
195
- Extract all required keys from the given type.
196
-
197
- 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...
198
-
199
- @example
200
- ```
201
- import type {RequiredKeysOf} from 'type-fest';
202
-
203
- declare function createValidation<
204
- Entity extends object,
205
- Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
206
- >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
207
-
208
- type User = {
209
- name: string;
210
- surname: string;
211
- luckyNumber?: number;
212
- };
213
-
214
- const validator1 = createValidation<User>('name', value => value.length < 25);
215
- const validator2 = createValidation<User>('surname', value => value.length < 25);
216
-
217
- // @ts-expect-error
218
- const validator3 = createValidation<User>('luckyNumber', value => value > 0);
219
- // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
220
- ```
221
-
222
- @category Utilities
223
- */
224
- type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
225
- ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
226
- //#endregion
227
- //#region ../../node_modules/type-fest/source/is-never.d.ts
228
- /**
229
- Returns a boolean for whether the given type is `never`.
230
-
231
- @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
232
- @link https://stackoverflow.com/a/53984913/10292952
233
- @link https://www.zhenghao.io/posts/ts-never
234
-
235
- Useful in type utilities, such as checking if something does not occur.
236
-
237
- @example
238
- ```
239
- import type {IsNever, And} from 'type-fest';
240
-
241
- type A = IsNever<never>;
242
- //=> true
243
-
244
- type B = IsNever<any>;
245
- //=> false
246
-
247
- type C = IsNever<unknown>;
248
- //=> false
249
-
250
- type D = IsNever<never[]>;
251
- //=> false
252
-
253
- type E = IsNever<object>;
254
- //=> false
255
-
256
- type F = IsNever<string>;
257
- //=> false
258
- ```
259
-
260
- @example
261
- ```
262
- import type {IsNever} from 'type-fest';
263
-
264
- type IsTrue<T> = T extends true ? true : false;
265
-
266
- // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
267
- type A = IsTrue<never>;
268
- // ^? type A = never
269
-
270
- // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
271
- type IsTrueFixed<T> =
272
- IsNever<T> extends true ? false : T extends true ? true : false;
273
-
274
- type B = IsTrueFixed<never>;
275
- // ^? type B = false
276
- ```
277
-
278
- @category Type Guard
279
- @category Utilities
280
- */
281
- type IsNever<T$1> = [T$1] extends [never] ? true : false;
282
- //#endregion
283
- //#region ../../node_modules/type-fest/source/if.d.ts
284
- /**
285
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
286
-
287
- Use-cases:
288
- - 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'>`.
289
-
290
- Note:
291
- - 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'`.
292
- - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
293
-
294
- @example
295
- ```
296
- import type {If} from 'type-fest';
297
-
298
- type A = If<true, 'yes', 'no'>;
299
- //=> 'yes'
300
-
301
- type B = If<false, 'yes', 'no'>;
302
- //=> 'no'
303
-
304
- type C = If<boolean, 'yes', 'no'>;
305
- //=> 'yes' | 'no'
306
-
307
- type D = If<any, 'yes', 'no'>;
308
- //=> 'yes' | 'no'
309
-
310
- type E = If<never, 'yes', 'no'>;
311
- //=> 'no'
312
- ```
313
-
314
- @example
315
- ```
316
- import type {If, IsAny, IsNever} from 'type-fest';
317
-
318
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
319
- //=> 'not any'
320
-
321
- type B = If<IsNever<never>, 'is never', 'not never'>;
322
- //=> 'is never'
323
- ```
324
-
325
- @example
326
- ```
327
- import type {If, IsEqual} from 'type-fest';
328
-
329
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
330
-
331
- type A = IfEqual<string, string, 'equal', 'not equal'>;
332
- //=> 'equal'
333
-
334
- type B = IfEqual<string, number, 'equal', 'not equal'>;
335
- //=> 'not equal'
336
- ```
337
-
338
- Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
339
-
340
- @example
341
- ```
342
- import type {If, IsEqual, StringRepeat} from 'type-fest';
343
-
344
- type HundredZeroes = StringRepeat<'0', 100>;
345
-
346
- // The following implementation is not tail recursive
347
- type Includes<S extends string, Char extends string> =
348
- S extends `${infer First}${infer Rest}`
349
- ? If<IsEqual<First, Char>,
350
- 'found',
351
- Includes<Rest, Char>>
352
- : 'not found';
353
-
354
- // Hence, instantiations with long strings will fail
355
- // @ts-expect-error
356
- type Fails = Includes<HundredZeroes, '1'>;
357
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358
- // Error: Type instantiation is excessively deep and possibly infinite.
359
-
360
- // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
361
- type IncludesWithoutIf<S extends string, Char extends string> =
362
- S extends `${infer First}${infer Rest}`
363
- ? IsEqual<First, Char> extends true
364
- ? 'found'
365
- : IncludesWithoutIf<Rest, Char>
366
- : 'not found';
367
-
368
- // Now, instantiations with long strings will work
369
- type Works = IncludesWithoutIf<HundredZeroes, '1'>;
370
- //=> 'not found'
371
- ```
372
-
373
- @category Type Guard
374
- @category Utilities
375
- */
376
- type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
377
- //#endregion
378
- //#region ../../node_modules/type-fest/source/unknown-array.d.ts
379
- /**
380
- Represents an array with `unknown` value.
381
-
382
- Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
383
-
384
- @example
385
- ```
386
- import type {UnknownArray} from 'type-fest';
387
-
388
- type IsArray<T> = T extends UnknownArray ? true : false;
389
-
390
- type A = IsArray<['foo']>;
391
- //=> true
392
-
393
- type B = IsArray<readonly number[]>;
394
- //=> true
395
-
396
- type C = IsArray<string>;
397
- //=> false
398
- ```
399
-
400
- @category Type
401
- @category Array
402
- */
403
- type UnknownArray = readonly unknown[];
404
- //#endregion
405
- //#region ../../node_modules/type-fest/source/internal/array.d.ts
406
-
407
- /**
408
- Returns whether the given array `T` is readonly.
409
- */
410
- type IsArrayReadonly<T$1 extends UnknownArray> = If<IsNever<T$1>, false, T$1 extends unknown[] ? false : true>;
411
- //#endregion
412
- //#region ../../node_modules/type-fest/source/simplify.d.ts
413
- /**
414
- 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.
415
-
416
- @example
417
- ```
418
- import type {Simplify} from 'type-fest';
419
-
420
- type PositionProps = {
421
- top: number;
422
- left: number;
423
- };
424
-
425
- type SizeProps = {
426
- width: number;
427
- height: number;
428
- };
429
-
430
- // In your editor, hovering over `Props` will show a flattened object with all the properties.
431
- type Props = Simplify<PositionProps & SizeProps>;
432
- ```
433
-
434
- Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
435
-
436
- If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
437
-
438
- @example
439
- ```
440
- import type {Simplify} from 'type-fest';
441
-
442
- interface SomeInterface {
443
- foo: number;
444
- bar?: string;
445
- baz: number | undefined;
446
- }
447
-
448
- type SomeType = {
449
- foo: number;
450
- bar?: string;
451
- baz: number | undefined;
452
- };
453
-
454
- const literal = {foo: 123, bar: 'hello', baz: 456};
455
- const someType: SomeType = literal;
456
- const someInterface: SomeInterface = literal;
457
-
458
- declare function fn(object: Record<string, unknown>): void;
459
-
460
- fn(literal); // Good: literal object type is sealed
461
- fn(someType); // Good: type is sealed
462
- // @ts-expect-error
463
- fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
464
- fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
465
- ```
466
-
467
- @link https://github.com/microsoft/TypeScript/issues/15300
468
- @see {@link SimplifyDeep}
469
- @category Object
470
- */
471
- type Simplify<T$1> = { [KeyType in keyof T$1]: T$1[KeyType] } & {};
472
- //#endregion
473
- //#region ../../node_modules/type-fest/source/is-equal.d.ts
474
- /**
475
- Returns a boolean for whether the two given types are equal.
476
-
477
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
478
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
479
-
480
- Use-cases:
481
- - If you want to make a conditional branch based on the result of a comparison of two types.
482
-
483
- @example
484
- ```
485
- import type {IsEqual} from 'type-fest';
486
-
487
- // This type returns a boolean for whether the given array includes the given item.
488
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
489
- type Includes<Value extends readonly any[], Item> =
490
- Value extends readonly [Value[0], ...infer rest]
491
- ? IsEqual<Value[0], Item> extends true
492
- ? true
493
- : Includes<rest, Item>
494
- : false;
495
- ```
496
-
497
- @category Type Guard
498
- @category Utilities
499
- */
500
- type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
501
- // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
502
- type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
503
- //#endregion
504
- //#region ../../node_modules/type-fest/source/omit-index-signature.d.ts
505
- /**
506
- Omit any index signatures from the given object type, leaving only explicitly defined properties.
507
-
508
- This is the counterpart of `PickIndexSignature`.
509
-
510
- Use-cases:
511
- - Remove overly permissive signatures from third-party types.
512
-
513
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
514
-
515
- It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
516
-
517
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
518
-
519
- ```
520
- const indexed: Record<string, unknown> = {}; // Allowed
521
-
522
- // @ts-expect-error
523
- const keyed: Record<'foo', unknown> = {}; // Error
524
- // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
525
- ```
526
-
527
- Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
528
-
529
- ```
530
- type Indexed = {} extends Record<string, unknown>
531
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
532
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
533
- // => '✅ `{}` is assignable to `Record<string, unknown>`'
534
-
535
- type Keyed = {} extends Record<'foo' | 'bar', unknown>
536
- ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
537
- : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
538
- // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
539
- ```
540
-
541
- Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
542
-
543
- ```
544
- type OmitIndexSignature<ObjectType> = {
545
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
546
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
547
- };
548
- ```
549
-
550
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
551
-
552
- ```
553
- type OmitIndexSignature<ObjectType> = {
554
- [KeyType in keyof ObjectType
555
- // Is `{}` assignable to `Record<KeyType, unknown>`?
556
- as {} extends Record<KeyType, unknown>
557
- ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
558
- : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
559
- ]: ObjectType[KeyType];
560
- };
561
- ```
562
-
563
- If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
564
-
565
- @example
566
- ```
567
- import type {OmitIndexSignature} from 'type-fest';
568
-
569
- type Example = {
570
- // These index signatures will be removed.
571
- [x: string]: any;
572
- [x: number]: any;
573
- [x: symbol]: any;
574
- [x: `head-${string}`]: string;
575
- [x: `${string}-tail`]: string;
576
- [x: `head-${string}-tail`]: string;
577
- [x: `${bigint}`]: string;
578
- [x: `embedded-${number}`]: string;
579
-
580
- // These explicitly defined keys will remain.
581
- foo: 'bar';
582
- qux?: 'baz';
583
- };
584
-
585
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
586
- // => { foo: 'bar'; qux?: 'baz' | undefined; }
587
- ```
588
-
589
- @see {@link PickIndexSignature}
590
- @category Object
591
- */
592
- type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
593
- //#endregion
594
- //#region ../../node_modules/type-fest/source/pick-index-signature.d.ts
595
- /**
596
- Pick only index signatures from the given object type, leaving out all explicitly defined properties.
597
-
598
- This is the counterpart of `OmitIndexSignature`.
599
-
600
- @example
601
- ```
602
- import type {PickIndexSignature} from 'type-fest';
603
-
604
- declare const symbolKey: unique symbol;
605
-
606
- type Example = {
607
- // These index signatures will remain.
608
- [x: string]: unknown;
609
- [x: number]: unknown;
610
- [x: symbol]: unknown;
611
- [x: `head-${string}`]: string;
612
- [x: `${string}-tail`]: string;
613
- [x: `head-${string}-tail`]: string;
614
- [x: `${bigint}`]: string;
615
- [x: `embedded-${number}`]: string;
616
-
617
- // These explicitly defined keys will be removed.
618
- ['kebab-case-key']: string;
619
- [symbolKey]: string;
620
- foo: 'bar';
621
- qux?: 'baz';
622
- };
623
-
624
- type ExampleIndexSignature = PickIndexSignature<Example>;
625
- // {
626
- // [x: string]: unknown;
627
- // [x: number]: unknown;
628
- // [x: symbol]: unknown;
629
- // [x: `head-${string}`]: string;
630
- // [x: `${string}-tail`]: string;
631
- // [x: `head-${string}-tail`]: string;
632
- // [x: `${bigint}`]: string;
633
- // [x: `embedded-${number}`]: string;
634
- // }
635
- ```
636
-
637
- @see {@link OmitIndexSignature}
638
- @category Object
639
- */
640
- type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
641
- //#endregion
642
- //#region ../../node_modules/type-fest/source/merge.d.ts
643
- // Merges two objects without worrying about index signatures.
644
- type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
645
-
646
- /**
647
- Merge two types into a new type. Keys of the second type overrides keys of the first type.
648
-
649
- @example
650
- ```
651
- import type {Merge} from 'type-fest';
652
-
653
- type Foo = {
654
- [x: string]: unknown;
655
- [x: number]: unknown;
656
- foo: string;
657
- bar: symbol;
658
- };
659
-
660
- type Bar = {
661
- [x: number]: number;
662
- [x: symbol]: unknown;
663
- bar: Date;
664
- baz: boolean;
665
- };
666
-
667
- export type FooBar = Merge<Foo, Bar>;
668
- // => {
669
- // [x: string]: unknown;
670
- // [x: number]: number;
671
- // [x: symbol]: unknown;
672
- // foo: string;
673
- // bar: Date;
674
- // baz: boolean;
675
- // }
676
- ```
677
-
678
- @category Object
679
- */
680
- type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
681
- //#endregion
682
- //#region ../../node_modules/type-fest/source/internal/object.d.ts
683
- /**
684
- Works similar to the built-in `Pick` utility type, except for the following differences:
685
- - Distributes over union types and allows picking keys from any member of the union type.
686
- - Primitives types are returned as-is.
687
- - Picks all keys if `Keys` is `any`.
688
- - Doesn't pick `number` from a `string` index signature.
689
-
690
- @example
691
- ```
692
- type ImageUpload = {
693
- url: string;
694
- size: number;
695
- thumbnailUrl: string;
696
- };
697
-
698
- type VideoUpload = {
699
- url: string;
700
- duration: number;
701
- encodingFormat: string;
702
- };
703
-
704
- // Distributes over union types and allows picking keys from any member of the union type
705
- type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
706
- //=> {url: string; size: number} | {url: string; duration: number}
707
-
708
- // Primitive types are returned as-is
709
- type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
710
- //=> string | number
711
-
712
- // Picks all keys if `Keys` is `any`
713
- type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
714
- //=> {a: 1; b: 2} | {c: 3}
715
-
716
- // Doesn't pick `number` from a `string` index signature
717
- type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
718
- //=> {}
719
- */
720
- type HomomorphicPick<T$1, Keys extends KeysOfUnion<T$1>> = { [P in keyof T$1 as Extract<P, Keys>]: T$1[P] };
721
- /**
722
- Merges user specified options with default options.
723
-
724
- @example
725
- ```
726
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
727
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
728
- type SpecifiedOptions = {leavesOnly: true};
729
-
730
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
731
- //=> {maxRecursionDepth: 10; leavesOnly: true}
732
- ```
733
-
734
- @example
735
- ```
736
- // Complains if default values are not provided for optional options
737
-
738
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
739
- type DefaultPathsOptions = {maxRecursionDepth: 10};
740
- type SpecifiedOptions = {};
741
-
742
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
743
- // ~~~~~~~~~~~~~~~~~~~
744
- // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
745
- ```
746
-
747
- @example
748
- ```
749
- // Complains if an option's default type does not conform to the expected type
750
-
751
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
752
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
753
- type SpecifiedOptions = {};
754
-
755
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
756
- // ~~~~~~~~~~~~~~~~~~~
757
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
758
- ```
759
-
760
- @example
761
- ```
762
- // Complains if an option's specified type does not conform to the expected type
763
-
764
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
765
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
766
- type SpecifiedOptions = {leavesOnly: 'yes'};
767
-
768
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
769
- // ~~~~~~~~~~~~~~~~
770
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
771
- ```
772
- */
773
- 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>>>>;
774
- //#endregion
775
- //#region ../../node_modules/type-fest/source/except.d.ts
776
- /**
777
- Filter out keys from an object.
778
-
779
- Returns `never` if `Exclude` is strictly equal to `Key`.
780
- Returns `never` if `Key` extends `Exclude`.
781
- Returns `Key` otherwise.
782
-
783
- @example
784
- ```
785
- type Filtered = Filter<'foo', 'foo'>;
786
- //=> never
787
- ```
788
-
789
- @example
790
- ```
791
- type Filtered = Filter<'bar', string>;
792
- //=> never
793
- ```
794
-
795
- @example
796
- ```
797
- type Filtered = Filter<'bar', 'foo'>;
798
- //=> 'bar'
799
- ```
800
-
801
- @see {Except}
802
- */
803
- type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
804
- type ExceptOptions = {
805
- /**
806
- Disallow assigning non-specified properties.
807
- Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
808
- @default false
809
- */
810
- requireExactProps?: boolean;
811
- };
812
- type DefaultExceptOptions = {
813
- requireExactProps: false;
814
- };
815
-
816
- /**
817
- Create a type from an object type without certain keys.
818
-
819
- We recommend setting the `requireExactProps` option to `true`.
820
-
821
- This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
822
-
823
- This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
824
-
825
- @example
826
- ```
827
- import type {Except} from 'type-fest';
828
-
829
- type Foo = {
830
- a: number;
831
- b: string;
832
- };
833
-
834
- type FooWithoutA = Except<Foo, 'a'>;
835
- //=> {b: string}
836
-
837
- // @ts-expect-error
838
- const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
839
- //=> errors: 'a' does not exist in type '{ b: string; }'
840
-
841
- type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
842
- //=> {a: number} & Partial<Record<"b", never>>
843
-
844
- // @ts-expect-error
845
- const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
846
- //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
847
-
848
- // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
849
-
850
- // Consider the following example:
851
-
852
- type UserData = {
853
- [metadata: string]: string;
854
- email: string;
855
- name: string;
856
- role: 'admin' | 'user';
857
- };
858
-
859
- // `Omit` clearly doesn't behave as expected in this case:
860
- type PostPayload = Omit<UserData, 'email'>;
861
- //=> { [x: string]: string; [x: number]: string; }
862
-
863
- // In situations like this, `Except` works better.
864
- // It simply removes the `email` key while preserving all the other keys.
865
- type PostPayloadFixed = Except<UserData, 'email'>;
866
- //=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
867
- ```
868
-
869
- @category Object
870
- */
871
- type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
872
- 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>> : {});
873
- //#endregion
874
- //#region ../../node_modules/type-fest/source/set-required.d.ts
875
- /**
876
- Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
877
-
878
- Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
879
-
880
- @example
881
- ```
882
- import type {SetRequired} from 'type-fest';
883
-
884
- type Foo = {
885
- a?: number;
886
- b: string;
887
- c?: boolean;
888
- };
889
-
890
- type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
891
- // type SomeRequired = {
892
- // a?: number;
893
- // b: string; // Was already required and still is.
894
- // c: boolean; // Is now required.
895
- // }
896
-
897
- // Set specific indices in an array to be required.
898
- type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
899
- //=> [number, number, number?]
900
- ```
901
-
902
- @category Object
903
- */
904
- type SetRequired<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetRequired<BaseType, Keys>;
905
- type _SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? If<IsArrayReadonly<BaseType>, Readonly<ResultantArray>, ResultantArray> : never : Simplify<
906
- // Pick just the keys that are optional from the base type.
907
- Except<BaseType, Keys> &
908
- // Pick the keys that should be required from the base type and make them required.
909
- Required<HomomorphicPick<BaseType, Keys>>>;
910
-
911
- /**
912
- Remove the optional modifier from the specified keys in an array.
913
- */
914
- type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown // For distributing `TArray` when it's a union
915
- ? keyof TArray & `${number}` extends never
916
- // Exit if `TArray` is empty (e.g., []), or
917
- // `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
918
- ? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? '0' extends OptionalKeysOf<TArray> // If the first element of `TArray` is optional
919
- ? `${Counter['length']}` extends `${Keys & (string | number)}` // If the current index needs to be required
920
- ? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]>
921
- // If the current element is optional, but it doesn't need to be required,
922
- // then we can exit early, since no further elements can now be made required.
923
- : [...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.
924
- : never; // Should never happen
925
- //#endregion
926
- //#region ../core/src/types/options.d.ts
927
- type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
928
- /**
929
- * Adds an `unknown` index property to an interface.
930
- */
931
- type WithUnknownIndex<T$1> = T$1 & {
932
- [key: string]: unknown;
933
- };
934
- /**
935
- * Do not use this type directly; use {@link Option}, {@link ValueOption},
936
- * or {@link FullOption} instead. For specific option types, you can use
937
- * {@link FullField}, {@link FullOperator}, or {@link FullCombinator},
938
- * all of which extend {@link FullOption}.
939
- *
940
- * @group Option Lists
941
- */
942
- interface BaseOption<N extends string = string> {
943
- name?: N;
944
- value?: N;
945
- label: string;
946
- disabled?: boolean;
947
- }
948
- /**
949
- * A generic {@link Option} with either a `name` or `value` as its primary identifier.
950
- * {@link OptionList}-type props on the {@link react-querybuilder!QueryBuilder QueryBuilder} component accept this type,
951
- * but corresponding props passed down to subcomponents will always be augmented
952
- * to {@link FullOption} first.
953
- *
954
- * @group Option Lists
955
- */
956
- type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
957
- /**
958
- * Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
959
- * into a {@link FlexibleOption}.
960
- *
961
- * @group Option Lists
962
- */
963
- type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
964
- /**
965
- * A generic {@link Option} requiring both `name` _and_ `value` properties.
966
- * Props that extend {@link OptionList} accept {@link BaseOption}, but
967
- * corresponding props sent to subcomponents will always be augmented to this
968
- * type first to ensure both `name` and `value` are available.
969
- *
970
- * NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
971
- * (optionally wrapped in {@link WithUnknownIndex}) instead, otherwise
972
- * the `unknown` index property will cause issues. See {@link Option} and
973
- * {@link ValueOption} for examples.
974
- *
975
- * @group Option Lists
976
- */
977
- type FullOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name" | "value">>>;
978
- /**
979
- * This type is identical to {@link FullOption} but without the `unknown` index
980
- * property. Extend from this type instead of {@link FullOption} directly.
981
- *
982
- * @group Option Lists
983
- */
984
- type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption<N>, "name" | "value">>;
985
- /**
986
- * Utility type to turn an {@link Option}, {@link ValueOption} or
987
- * {@link BaseOption} into a {@link FullOption}.
988
- *
989
- * @group Option Lists
990
- */
991
- type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
992
- /**
993
- * A group of {@link Option}s, usually within an {@link OptionList}.
994
- *
995
- * @group Option Lists
996
- */
997
- interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
998
- label: string;
999
- options: WithUnknownIndex<Opt>[];
1000
- }
1001
- /**
1002
- * A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
1003
- *
1004
- * @group Option Lists
1005
- */
1006
- type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
1007
- label: string;
1008
- options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
1009
- };
1010
- /**
1011
- * An array of options or option groups, like {@link OptionList} but the option type
1012
- * may use either `name` or `value` as the primary identifier.
1013
- *
1014
- * @group Option Lists
1015
- */
1016
- type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
1017
- /**
1018
- * An array of options or option groups, like {@link OptionList}, but using
1019
- * {@link FullOption} instead of {@link Option}. This means that every member is
1020
- * guaranteed to have both `name` and `value`.
1021
- *
1022
- * @group Option Lists
1023
- */
1024
- type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
1025
- //#endregion
1026
- //#region ../core/src/types/ruleGroups.d.ts
1027
- /**
1028
- * Properties common to both rules and groups.
1029
- */
1030
- interface CommonRuleAndGroupProperties {
1031
- path?: Path;
1032
- id?: string;
1033
- disabled?: boolean;
1034
- /**
1035
- * Whether this rule or group is muted. When muted, the rule or group
1036
- * is excluded from query export formats (SQL, JSON, MongoDB, etc.).
1037
- * For groups, muting recursively mutes all children.
1038
- */
1039
- muted?: boolean;
1040
- }
1041
- /**
1042
- * The main rule type. The `field`, `operator`, and `value` properties
1043
- * can be narrowed with generics.
1044
- */
1045
- interface RuleType<F extends string = string, O extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
1046
- field: F;
1047
- operator: O;
1048
- value: V$1;
1049
- valueSource?: ValueSource;
1050
- match?: MatchConfig;
1051
- /**
1052
- * Only used when adding a rule to a query that uses independent combinators.
1053
- */
1054
- combinatorPreceding?: C;
1055
- }
1056
- /**
1057
- * The main rule group type. This type is used for query definitions as well as
1058
- * all sub-groups of queries.
1059
- */
1060
- interface RuleGroupType<R$1 extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
1061
- combinator: C;
1062
- rules: RuleGroupArray<RuleGroupType<R$1, C>, R$1>;
1063
- not?: boolean;
1064
- }
1065
- /**
1066
- * The type of the `rules` array in a {@link RuleGroupType}.
1067
- */
1068
- type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R$1 extends RuleType = RuleType> = (R$1 | RG)[];
1069
- /**
1070
- * Default values for the `operator` property.
1071
- *
1072
- * @group Option Lists
1073
- */
1074
- type DefaultOperatorName = "=" | "!=" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "endsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "in" | "notIn" | "between" | "notBetween";
1075
- //#endregion
1076
- //#region ../core/src/types/ruleGroupsIC.utils.d.ts
1077
- type MAXIMUM_ALLOWED_BOUNDARY = 80;
1078
- type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [], Count extends ReadonlyArray<number> = []> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result : Tuple extends [] ? [] : Result extends [] ? MappedTuple<Tuple, Tuple, [...Count, 1]> : MappedTuple<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;
1079
- //#endregion
1080
- //#region ../core/src/types/ruleGroupsIC.d.ts
1081
- /**
1082
- * The main rule group interface when using independent combinators. This type is used
1083
- * for query definitions as well as all sub-groups of queries.
1084
- */
1085
- interface RuleGroupTypeIC<R$1 extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R$1, C>, "combinator" | "rules"> {
1086
- combinator?: undefined;
1087
- rules: RuleGroupICArray<RuleGroupTypeIC<R$1, C>, R$1, C>;
1088
- /**
1089
- * Only used when adding a rule to a query that uses independent combinators
1090
- */
1091
- combinatorPreceding?: C;
1092
- }
1093
- /**
1094
- * Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
1095
- */
1096
- type RuleGroupTypeAny<R$1 extends RuleType = RuleType, C extends string = string> = RuleGroupType<R$1, C> | RuleGroupTypeIC<R$1, C>;
1097
- /**
1098
- * The type of the `rules` array in a {@link RuleGroupTypeIC}.
1099
- */
1100
- type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R$1 extends RuleType = RuleType, C extends string = string> = [R$1 | RG] | [R$1 | RG, ...MappedTuple<[C, R$1 | RG]>] | ((R$1 | RG)[] & {
1101
- length: 0;
1102
- });
1103
- //#endregion
1104
- //#region ../core/src/types/validation.d.ts
1105
- /**
1106
- * Object with a `valid` boolean value and optional `reasons`.
1107
- */
1108
- interface ValidationResult {
1109
- valid: boolean;
1110
- reasons?: any[];
1111
- }
1112
- /**
1113
- * Map of rule/group `id` to its respective {@link ValidationResult}.
1114
- */
1115
- type ValidationMap = Record<string, boolean | ValidationResult>;
1116
- /**
1117
- * Function that validates a query.
1118
- */
1119
- type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
1120
- /**
1121
- * Function that validates a rule.
1122
- */
1123
- type RuleValidator = (rule: RuleType) => boolean | ValidationResult;
1124
- //#endregion
1125
- //#region ../core/src/types/basic.d.ts
1126
- /**
1127
- * @see https://react-querybuilder.js.org/docs/tips/path
1128
- */
1129
- type Path = number[];
1130
- /**
1131
- * String of classnames, array of classname strings, or object where the
1132
- * keys are classnames and those with truthy values will be included.
1133
- * Suitable for passing to the `clsx` package.
1134
- */
1135
- type Classname = string | string[] | Record<string, any>;
1136
- /**
1137
- * A source for the `value` property of a rule.
1138
- */
1139
- type ValueSource = "value" | "field";
1140
- /**
1141
- * Type of {@link react-querybuilder!ValueEditor ValueEditor} that will be displayed.
1142
- */
1143
- type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
1144
- /**
1145
- * A valid array of potential value sources.
1146
- *
1147
- * @see {@link ValueSource}
1148
- */
1149
- type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
1150
- type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
1151
- type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
1152
- type WithOptionalClassName<T$1> = T$1 & {
1153
- className?: Classname;
1154
- };
1155
- /**
1156
- * HTML5 input types
1157
- */
1158
- type InputType = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week" | "bigint" | (string & {});
1159
- /**
1160
- * Quantification mode describing how many elements of the value array must pass
1161
- * the filter for the rule itself to pass.
1162
- *
1163
- * For "atLeast", "atMost", and "exactly", the threshold value will be converted to
1164
- * a percentage if the number is less than 1. Non-numeric values and numbers less
1165
- * than 0 will be ignored.
1166
- */
1167
- interface MatchConfig {
1168
- mode: MatchMode;
1169
- threshold?: number | null | undefined;
1170
- }
1171
- type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
1172
- /**
1173
- * Base for all Field types/interfaces.
1174
- */
1175
- interface BaseFullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> extends WithOptionalClassName<BaseFullOption<FieldName>> {
1176
- id?: string;
1177
- operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
1178
- valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
1179
- valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
1180
- inputType?: InputType | null;
1181
- values?: FlexibleOptionList<ValueObj>;
1182
- matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
1183
- /** Properties of items in the value. */
1184
- subproperties?: FlexibleOptionList<FullField>;
1185
- defaultOperator?: OperatorName;
1186
- defaultValue?: any;
1187
- placeholder?: string;
1188
- validator?: RuleValidator;
1189
- comparator?: string | ((f: FullField, operator: string) => boolean);
1190
- }
1191
- /**
1192
- * Full field definition used in the `fields` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
1193
- * This type requires both `name` and `value`, but the `fields` prop itself
1194
- * can use a {@link FlexibleOption} where only one of `name` or `value` is
1195
- * required (along with `label`), or {@link Field} where only `name` and
1196
- * `label` are required.
1197
- *
1198
- * The `name`/`value`, `operators`, and `values` properties of this interface
1199
- * can be narrowed with generics.
1200
- *
1201
- * @group Option Lists
1202
- */
1203
- type FullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> = Simplify<FullOption<FieldName> & BaseFullField<FieldName, OperatorName, ValueName, OperatorObj, ValueObj>>;
1204
- /**
1205
- * Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
1206
- * a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
1207
- */
1208
- type Arity = number | "unary" | "binary" | "ternary";
1209
- /**
1210
- * Full operator definition used in the `operators`/`getOperators` props of
1211
- * {@link react-querybuilder!QueryBuilder QueryBuilder}. This type requires both `name` and `value`, but the
1212
- * `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
1213
- * where only one of `name` or `value` is required, or {@link FullOperator} where
1214
- * only `name` is required.
1215
- *
1216
- * The `name`/`value` properties of this interface can be narrowed with generics.
1217
- *
1218
- * @group Option Lists
1219
- */
1220
- interface FullOperator<N extends string = string> extends WithOptionalClassName<FullOption<N>> {
1221
- arity?: Arity;
1222
- }
1223
- type ParseNumberMethodName = "enhanced" | "native" | "strict";
1224
- /**
1225
- * Parsing algorithms used by {@link parseNumber}.
1226
- */
1227
-
1228
- type ParseNumbersModerationLevel = "-limited" | "";
1229
- /**
1230
- * Options for the `parseNumbers` prop of {@link react-querybuilder!QueryBuilder QueryBuilder}.
1231
- */
1232
- type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
1233
- //#endregion
1234
- //#region ../core/src/types/export.d.ts
1235
- /**
1236
- * Available export formats for {@link formatQuery}.
1237
- *
1238
- * @group Export
1239
- */
1240
- type ExportFormat = "json" | "sql" | "json_without_ids" | "parameterized" | "parameterized_named" | "mongodb" | "mongodb_query" | "cel" | "jsonlogic" | "spel" | "elasticsearch" | "jsonata" | "natural_language" | "ldap" | "drizzle" | "prisma" | "sequelize";
1241
- /**
1242
- * Available presets for the "sql" export format.
1243
- *
1244
- * @group Export
1245
- */
1246
- type SQLPreset = "ansi" | "sqlite" | "postgresql" | "mysql" | "mssql" | "oracle";
1247
- /**
1248
- * A map of operators to strings to be used in the output of {@link formatQuery}. If the
1249
- * result can differ based on the `valueSource`, the key should map to an array where the
1250
- * second element represents the string to be used when `valueSource` is "field". The first
1251
- * element will be used in all other cases.
1252
- *
1253
- * @group Export
1254
- */
1255
- type ExportOperatorMap = Partial<Record<Lowercase<DefaultOperatorName> | DefaultOperatorName, string | [string, string]>>;
1256
- /**
1257
- * Options object shape for {@link formatQuery}.
1258
- *
1259
- * @group Export
1260
- */
1261
- interface FormatQueryOptions {
1262
- /**
1263
- * The {@link ExportFormat}.
1264
- */
1265
- format?: ExportFormat;
1266
- /**
1267
- * This function will be used to process the `operator` from each rule
1268
- * for query language formats. If not defined, the appropriate
1269
- * `defaultOperatorProcessor*` for the format will be used.
1270
- */
1271
- operatorProcessor?: RuleProcessor;
1272
- /**
1273
- * This function will be used to process the `value` from each rule
1274
- * for query language formats. If not defined, the appropriate
1275
- * `defaultValueProcessor*` for the format will be used.
1276
- */
1277
- valueProcessor?: ValueProcessorLegacy | ValueProcessorByRule;
1278
- /**
1279
- * This function will be used to process each rule. If not defined, the appropriate
1280
- * `defaultRuleProcessor*` for the given format will be used.
1281
- */
1282
- ruleProcessor?: RuleProcessor;
1283
- /**
1284
- * This function will be used to process each rule group. If not defined, the appropriate
1285
- * `defaultRuleGroupProcessor*` for the format will be used.
1286
- *
1287
- * If this function is defined, it will override the `format` option. This also allows
1288
- * `formatQuery` to produce completely custom output formats.
1289
- */
1290
- ruleGroupProcessor?: RuleGroupProcessor;
1291
- /**
1292
- * In the "sql", "parameterized", "parameterized_named", and "jsonata" export
1293
- * formats, field names will be bracketed by this string. If an array of strings
1294
- * is passed, field names will be preceded by the first element and
1295
- * succeeded by the second element.
1296
- *
1297
- * Tip: Use `fieldIdentifierSeparator` to bracket identifiers individually within field names.
1298
- *
1299
- * @default '' // the empty string
1300
- *
1301
- * @example
1302
- * formatQuery(query, { format: 'sql', quoteFieldNamesWith: '"' })
1303
- * // `"First name" = 'Steve'`
1304
- *
1305
- * @example
1306
- * formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
1307
- * // "[First name] = 'Steve'"
1308
- */
1309
- quoteFieldNamesWith?: string | [string, string];
1310
- /**
1311
- * When used in conjunction with the `quoteFieldNamesWith` option, field names will
1312
- * be split by this string, each part being individually processed as per the rules
1313
- * of the `quoteFieldNamesWith` configuration. The parts will then be re-joined
1314
- * by the same string.
1315
- *
1316
- * A common value for this option is `'.'`.
1317
- *
1318
- * A value of `''` (the empty string) will disable splitting/rejoining.
1319
- *
1320
- * @default ''
1321
- *
1322
- * @example
1323
- * formatQuery(query, {
1324
- * format: 'sql',
1325
- * quoteFieldNamesWith: ['[', ']'],
1326
- * fieldIdentifierSeparator: '.',
1327
- * })
1328
- * // "[dbo].[Musicians].[First name] = 'Steve'"
1329
- */
1330
- fieldIdentifierSeparator?: string;
1331
- /**
1332
- * Character to use for quoting string values in the SQL format.
1333
- * @default `'`
1334
- */
1335
- quoteValuesWith?: string;
1336
- /**
1337
- * Validator function for the entire query. Can be the same function passed
1338
- * as `validator` prop to {@link react-querybuilder!QueryBuilder QueryBuilder}.
1339
- */
1340
- validator?: QueryValidator;
1341
- /**
1342
- * This can be the same {@link FullField} array passed to {@link react-querybuilder!QueryBuilder QueryBuilder}, but
1343
- * really all you need to provide is the `name` and `validator` for each field.
1344
- *
1345
- * The full field object from this array, where the field's identifying property
1346
- * matches the rule's `field`, will be passed to the rule processor.
1347
- */
1348
- fields?: FlexibleOptionList<FullField>;
1349
- /**
1350
- * This can be the same `getOperators` function passed to {@link react-querybuilder!QueryBuilder QueryBuilder}.
1351
- *
1352
- * The full operator object from this array, where the operator's identifying property
1353
- * matches the rule's `operator`, will be passed to the rule processor.
1354
- */
1355
- getOperators?(field: string, misc: {
1356
- fieldData: FullField;
1357
- }): FlexibleOptionList<FullOperator> | null;
1358
- /**
1359
- * This string will be inserted in place of invalid groups for non-JSON formats.
1360
- * Defaults to `'(1 = 1)'` for "sql"/"parameterized"/"parameterized_named" and
1361
- * `'$and:[{$expr:true}]'` for "mongodb".
1362
- */
1363
- fallbackExpression?: string;
1364
- /**
1365
- * This string will be placed in front of named parameters (aka bind variables)
1366
- * when using the "parameterized_named" export format.
1367
- *
1368
- * @default ":"
1369
- */
1370
- paramPrefix?: string;
1371
- /**
1372
- * Maintains the parameter prefix in the `params` object keys when using the
1373
- * "parameterized_named" export format. Recommended when using SQLite.
1374
- *
1375
- * @default false
1376
- *
1377
- * @example
1378
- * console.log(formatQuery(query, {
1379
- * format: "parameterized_named",
1380
- * paramPrefix: "$",
1381
- * paramsKeepPrefix: true
1382
- * }).params)
1383
- * // { $firstName: "Stev" }
1384
- * // Default (`paramsKeepPrefix` is `false`):
1385
- * // { firstName: "Stev" }
1386
- */
1387
- paramsKeepPrefix?: boolean;
1388
- /**
1389
- * Renders parameter placeholders as a series of sequential numbers
1390
- * instead of '?' like the default. This option will respect the
1391
- * `paramPrefix` option like the 'parameterized_named' format.
1392
- *
1393
- * @default false
1394
- */
1395
- numberedParams?: boolean;
1396
- /**
1397
- * Preserves the order of values for "between" and "notBetween" rules, even if a larger
1398
- * value comes before a smaller value (which will always evaluate to false).
1399
- */
1400
- preserveValueOrder?: boolean;
1401
- /**
1402
- * Renders values as either `number`-types or unquoted strings, as
1403
- * appropriate and when possible. Each `string`-type value is evaluated
1404
- * against {@link numericRegex} to determine if it can be represented as a
1405
- * plain numeric value. If so, `parseFloat` is used to convert it to a number.
1406
- */
1407
- parseNumbers?: ParseNumbersPropConfig;
1408
- /**
1409
- * Any rules where the field is equal to this value will be ignored.
1410
- *
1411
- * @default '~'
1412
- */
1413
- placeholderFieldName?: string;
1414
- /**
1415
- * Any rules where the operator is equal to this value will be ignored.
1416
- *
1417
- * @default '~'
1418
- */
1419
- placeholderOperatorName?: string;
1420
- /**
1421
- * Any rules where the value is equal to this value will be ignored.
1422
- *
1423
- * @default '~'
1424
- */
1425
- placeholderValueName?: string;
1426
- /**
1427
- * Operator to use when concatenating wildcard characters and field names in "sql" format.
1428
- * The ANSI standard is `||`, while SQL Server uses `+`. MySQL does not implement a concatenation
1429
- * operator by default, and therefore requires use of the `CONCAT` function.
1430
- *
1431
- * If `concatOperator` is set to `"CONCAT"` (case-insensitive), the `CONCAT` function will be
1432
- * used. Note that Oracle SQL does not support more than two values in the `CONCAT` function,
1433
- * so this option should not be used in that context. The default setting (`"||"`) is already
1434
- * compatible with Oracle SQL.
1435
- *
1436
- * @default '||'
1437
- */
1438
- concatOperator?: "||" | "+" | "CONCAT" | (string & {});
1439
- /**
1440
- * Option presets to maximize compatibility with various SQL dialects.
1441
- */
1442
- preset?: SQLPreset;
1443
- /**
1444
- * Map of operators to their translations for the "natural_language" format. If the
1445
- * result can differ based on the `valueSource`, the key should map to an array where the
1446
- * second element represents the string to be used when `valueSource` is "field". The first
1447
- * element will be used in all other cases.
1448
- */
1449
- operatorMap?: ExportOperatorMap;
1450
- /**
1451
- * [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)
1452
- * for the "natural_language" format. Can be abbreviated like "SVO" or spelled out like
1453
- * "subject-verb-object".
1454
- *
1455
- * - Subject = field
1456
- * - Verb = operator
1457
- * - Object = value
1458
- */
1459
- wordOrder?: ConstituentWordOrderString | Lowercase<ConstituentWordOrderString> | ({} & string);
1460
- /**
1461
- * Translatable strings used by the "natural_language" format.
1462
- */
1463
- translations?: Partial<Record<NLTranslationKey, string>>;
1464
- context?: Record<string, any>;
1465
- }
1466
- /**
1467
- * Options object for {@link ValueProcessorByRule} functions.
1468
- *
1469
- * @group Export
1470
- */
1471
- interface ValueProcessorOptions extends FormatQueryOptions {
1472
- valueProcessor?: ValueProcessorByRule;
1473
- escapeQuotes?: boolean;
1474
- /**
1475
- * The full field object, if `fields` was provided in the
1476
- * {@link formatQuery} options parameter.
1477
- */
1478
- fieldData?: FullField;
1479
- /**
1480
- * Included for the "parameterized_named" format only. Keys of this object represent
1481
- * field names and values represent the current list of parameter names for that
1482
- * field based on the query rules processed up to that point. Use this list to
1483
- * ensure that parameter names generated by the custom rule processor are unique.
1484
- */
1485
- fieldParamNames?: Record<string, string[]>;
1486
- /**
1487
- * Included for the "parameterized_named" format only. Call this function with a
1488
- * field name to get a unique parameter name, as yet unused during query processing.
1489
- */
1490
- getNextNamedParam?: (field: string) => string;
1491
- /**
1492
- * Additional prefix and suffix characters to wrap the value in. Useful for augmenting
1493
- * the default value processor results with special syntax (e.g., for dates or function
1494
- * calls).
1495
- */
1496
- wrapValueWith?: [string, string];
1497
- /**
1498
- * Parse numbers in the rule value.
1499
- *
1500
- * @default false
1501
- */
1502
- parseNumbers?: boolean;
1503
- }
1504
- /**
1505
- * Options object curated by {@link formatQuery} and passed to a {@link RuleGroupProcessor}.
1506
- *
1507
- * @group Export
1508
- */
1509
- interface FormatQueryFinalOptions extends Required<Except<FormatQueryOptions, "context" | "valueProcessor" | "validator" | "placeholderValueName" | "ruleGroupProcessor" | "parseNumbers">> {
1510
- fields: FullOptionList<FullField>;
1511
- getParseNumberBoolean: (inputType?: InputType | null) => boolean | undefined;
1512
- parseNumbers?: ParseNumbersPropConfig | undefined;
1513
- placeholderValueName?: string | undefined;
1514
- valueProcessor: ValueProcessorByRule;
1515
- validator?: QueryValidator;
1516
- validateRule: FormatQueryValidateRule;
1517
- validationMap: ValidationMap;
1518
- context?: Record<string, unknown>;
1519
- }
1520
- /**
1521
- * Function that produces a processed value for a given {@link RuleType}.
1522
- *
1523
- * @group Export
1524
- */
1525
- type ValueProcessorByRule = (rule: RuleType, options?: ValueProcessorOptions) => string;
1526
- /**
1527
- * Function that produces a processed value for a given `field`, `operator`, `value`,
1528
- * and `valueSource`.
1529
- *
1530
- * @group Export
1531
- */
1532
- type ValueProcessorLegacy = (field: string, operator: string, value: any, valueSource?: ValueSource) => string;
1533
- /**
1534
- * Function to produce a result that {@link formatQuery} uses when processing a
1535
- * {@link RuleType} object.
1536
- *
1537
- * See the default rule processor for each format to know what type to return.
1538
- * | Format | Default rule processor |
1539
- * | ------------------------ | ----------------------------------------- |
1540
- * | `sql` | {@link defaultRuleProcessorSQL} |
1541
- * | `parameterized` | {@link defaultRuleProcessorParameterized} |
1542
- * | `parameterized_named` | {@link defaultRuleProcessorParameterized} |
1543
- * | `mongodb` _(deprecated)_ | {@link defaultRuleProcessorMongoDB} |
1544
- * | `mongodb_query` | {@link defaultRuleProcessorMongoDBQuery} |
1545
- * | `cel` | {@link defaultRuleProcessorCEL} |
1546
- * | `spel` | {@link defaultRuleProcessorSpEL} |
1547
- * | `jsonlogic` | {@link defaultRuleProcessorJsonLogic} |
1548
- * | `elasticsearch` | {@link defaultRuleProcessorElasticSearch} |
1549
- * | `jsonata` | {@link defaultRuleProcessorJSONata} |
1550
- *
1551
- * @group Export
1552
- */
1553
- type RuleProcessor = (rule: RuleType, options?: ValueProcessorOptions, meta?: {
1554
- processedParams?: Record<string, any> | any[];
1555
- context?: Record<string, any>;
1556
- }) => any;
1557
- /**
1558
- * Function to produce a result that {@link formatQuery} uses when processing a
1559
- * {@link RuleGroupType} or {@link RuleGroupTypeIC} object.
1560
- *
1561
- * See the default rule group processor for each format to know what type to return.
1562
- * | Format | Default rule group processor |
1563
- * | ------------------------ | ---------------------------------------------- |
1564
- * | `sql` | {@link defaultRuleGroupProcessorSQL} |
1565
- * | `parameterized` | {@link defaultRuleGroupProcessorParameterized} |
1566
- * | `parameterized_named` | {@link defaultRuleGroupProcessorParameterized} |
1567
- * | `mongodb` _(deprecated)_ | {@link defaultRuleGroupProcessorMongoDB} |
1568
- * | `mongodb_query` | {@link defaultRuleGroupProcessorMongoDBQuery} |
1569
- * | `cel` | {@link defaultRuleGroupProcessorCEL} |
1570
- * | `spel` | {@link defaultRuleGroupProcessorSpEL} |
1571
- * | `jsonlogic` | {@link defaultRuleGroupProcessorJsonLogic} |
1572
- * | `elasticsearch` | {@link defaultRuleGroupProcessorElasticSearch} |
1573
- * | `jsonata` | {@link defaultRuleGroupProcessorJSONata} |
1574
- *
1575
- * @group Export
1576
- */
1577
- type RuleGroupProcessor<TResult = unknown> = (ruleGroup: RuleGroupTypeAny, options: FormatQueryFinalOptions, meta?: {
1578
- processedParams?: Record<string, any> | any[];
1579
- context?: Record<string, any>;
1580
- }) => TResult;
1581
- /**
1582
- * Rule validator for {@link formatQuery}.
1583
- *
1584
- * @group Export
1585
- */
1586
- type FormatQueryValidateRule = (rule: RuleType) => readonly [boolean | ValidationResult | undefined, RuleValidator | undefined];
1587
- /**
1588
- * @group Export
1589
- */
1590
- interface RQBJsonLogicStartsWith {
1591
- startsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1592
- }
1593
- /**
1594
- * @group Export
1595
- */
1596
- interface RQBJsonLogicEndsWith {
1597
- endsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1598
- }
1599
- /**
1600
- * JsonLogic rule object with additional operators generated by {@link formatQuery}
1601
- * and accepted by {@link parseJsonLogic!parseJsonLogic}.
1602
- *
1603
- * @group Export
1604
- */
1605
- type RQBJsonLogic = RulesLogic<RQBJsonLogicStartsWith | RQBJsonLogicEndsWith>;
1606
- /**
1607
- * Constituent word order (as string) for the "natural_language" format.
1608
- *
1609
- * - S (subject) = field
1610
- * - V (verb) = operator
1611
- * - O (object) = value
1612
- *
1613
- * @group Export
1614
- */
1615
- type ConstituentWordOrderString = "SVO" | "SOV" | "OSV" | "OVS" | "VSO" | "VOS";
1616
- type RepeatStrings<S extends string[], Depth extends number[] = []> = Depth["length"] extends 2 ? "" : "" | `_${S[number]}${RepeatStrings<S, [...Depth, 1]>}`;
1617
- type ZeroOrMoreGroupVariants = RepeatStrings<["xor", "not"]>;
1618
- /**
1619
- * Rule group condition identifier for the "natural_language" format.
1620
- *
1621
- * @group Export
1622
- */
1623
-
1624
- /**
1625
- * Keys for the `translations` config object used by the "natural_language" format.
1626
- *
1627
- * @group Export
1628
- */
1629
- type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
1630
- //#endregion
1631
- //#region ../react-querybuilder/src/redux/getRqbStore.d.ts
1632
- declare global {
1633
- var __RQB_DEVTOOLS__: boolean | undefined;
1634
- }
1635
- /**
1636
- * Gets the singleton React Query Builder store instance.
1637
- * DevTools are enabled if either:
1638
- * - globalThis.__RQB_DEVTOOLS__ is truthy
1639
- * - window.__RQB_DEVTOOLS__ is truthy
1640
- */
1641
- //#endregion
1642
- //#region src/types.d.ts
1643
- interface RQBJsonLogicDateBetween {
1644
- dateBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
1645
- }
1646
- interface RQBJsonLogicDateNotBetween {
1647
- dateNotBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
1648
- }
1649
- interface RQBJsonLogicDateIn {
1650
- dateIn: [RQBJsonLogic, RQBJsonLogic[]];
1651
- }
1652
- interface RQBJsonLogicDateNotIn {
1653
- dateNotIn: [RQBJsonLogic, RQBJsonLogic[]];
1654
- }
1655
- interface RQBJsonLogicDateBefore {
1656
- dateBefore: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1657
- }
1658
- interface RQBJsonLogicDateOnOrBefore {
1659
- dateOnOrBefore: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1660
- }
1661
- interface RQBJsonLogicDateOn {
1662
- dateOn: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1663
- }
1664
- interface RQBJsonLogicDateNotOn {
1665
- dateNotOn: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1666
- }
1667
- interface RQBJsonLogicDateAfter {
1668
- dateAfter: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1669
- }
1670
- interface RQBJsonLogicDateOnOrAfter {
1671
- dateOnOrAfter: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
1672
- }
1673
- /**
1674
- * JsonLogic rule object with additional operators generated by
1675
- * {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
1676
- * {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
1677
- */
1678
- type RQBDateTimeJsonLogic = RQBJsonLogic | RulesLogic<RQBJsonLogicDateAfter | RQBJsonLogicDateBefore | RQBJsonLogicDateBetween | RQBJsonLogicDateIn | RQBJsonLogicDateNotBetween | RQBJsonLogicDateNotIn | RQBJsonLogicDateNotOn | RQBJsonLogicDateOn | RQBJsonLogicDateOnOrAfter | RQBJsonLogicDateOnOrBefore>;
1679
- type DateOrString = string | Date;
1680
- interface RQBDateTimeLibraryAPI {
1681
- /**
1682
- * Formats a date as a string.
1683
- */
1684
- format: (d: DateOrString, fmt: string) => string;
1685
- /**
1686
- * Formats a date as an ISO 8601 string, only including
1687
- * the year, month, and day ('YYYY-MM-DD').
1688
- */
1689
- toISOStringDateOnly: (d: DateOrString) => string;
1690
- /**
1691
- * Determines whether the first date is after the second date.
1692
- */
1693
- isAfter: (a: DateOrString, b: DateOrString) => boolean;
1694
- /**
1695
- * Determines whether the first date is before the second date.
1696
- */
1697
- isBefore: (a: DateOrString, b: DateOrString) => boolean;
1698
- /**
1699
- * Determines whether the first date is the same as the second date.
1700
- *
1701
- * If either the first date or the second date is a string in the
1702
- * format 'YYYY-MM-DD', then the dates will only be compared at
1703
- * the date level (no time component). Otherwise, they will be
1704
- * compared to the millisecond.
1705
- */
1706
- isSame: (a: DateOrString, b: DateOrString) => boolean;
1707
- /**
1708
- * Determines whether the date is either a valid `Date` object or an
1709
- * ISO 8601-formatted string representing a valid date.
1710
- */
1711
- isValid: (d: DateOrString) => boolean;
1712
- /**
1713
- * Converts a string to a `Date` object or returns a valid `Date` as is.
1714
- */
1715
- toDate: (d: DateOrString) => Date;
1716
- /**
1717
- * Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
1718
- * string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
1719
- * static; other parts represent standard time units, increasing in precision
1720
- * from left to right).
1721
- */
1722
- toISOString: (d: DateOrString) => string;
1723
- }
1724
- type FnDateDate = (a: DateOrString, b: DateOrString) => boolean;
1725
- type FnDateArrayOfDates = (a: DateOrString, b: DateOrString[]) => boolean;
1726
- type FnDateDateDate = (a: DateOrString, b: DateOrString, c: DateOrString) => boolean;
1727
- type RQBJsonLogicDateTimeOperations = {
1728
- /** Determines if the first date is after the second date. */
1729
- dateAfter: FnDateDate;
1730
- /** Determines if the first date is before the second date. */
1731
- dateBefore: FnDateDate;
1732
- /** Determines if the second date is between the first and third dates (inclusive). */
1733
- dateBetween: FnDateDateDate;
1734
- /** Determines if the first date is one of the values in the array of dates. */
1735
- dateIn: FnDateArrayOfDates;
1736
- /** Determines if the second date is not between the first and third dates. */
1737
- dateNotBetween: FnDateDateDate;
1738
- /** Determines if the first date is not one of the values in the array of dates. */
1739
- dateNotIn: FnDateArrayOfDates;
1740
- /** Determines if the first date is not the same as the second date. */
1741
- dateNotOn: FnDateDate;
1742
- /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
1743
- dateOn: FnDateDate;
1744
- /** Determines if the first date is either the same as the second date or after it. */
1745
- dateOnOrAfter: FnDateDate;
1746
- /** Determines if the first date is either the same as the second date or before it. */
1747
- dateOnOrBefore: FnDateDate;
1748
- };
1749
- type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boolean;
1750
- type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
1751
- //#endregion
1752
- export { RuleProcessor as _, RQBJsonLogicDateAfter as a, RQBJsonLogicDateIn as c, RQBJsonLogicDateNotOn as d, RQBJsonLogicDateOn as f, ExportOperatorMap as g, RQBJsonLogicDateTimeOperations as h, RQBDateTimeLibraryAPI as i, RQBJsonLogicDateNotBetween as l, RQBJsonLogicDateOnOrBefore as m, IsDateFieldFunction as n, RQBJsonLogicDateBefore as o, RQBJsonLogicDateOnOrAfter as p, RQBDateTimeJsonLogic as r, RQBJsonLogicDateBetween as s, IsDateField as t, RQBJsonLogicDateNotIn as u, ValueProcessorByRule as v };
1753
- //# sourceMappingURL=types-C-P0L9xh.d.mts.map