@react-querybuilder/datetime 8.13.0 → 8.14.1

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