@react-querybuilder/tremor
Version:
Custom Tremor components for react-querybuilder
1,486 lines (1,286 loc) • 88.9 kB
TypeScript
import { ButtonProps, MultiSelectProps, SelectProps, SwitchProps } from "@tremor/react";
import * as React from "react";
import { ComponentType, ForwardRefExoticComponent, MouseEvent, ReactNode, Ref, RefAttributes } from "react";
//#region ../core/src/types/type-fest/is-equal.d.ts
/**
Returns a boolean for whether the two given types are equal.
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
Use-cases:
- If you want to make a conditional branch based on the result of a comparison of two types.
@example
```
import type {IsEqual} from 'type-fest';
// This type returns a boolean for whether the given array includes the given item.
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
type Includes<Value extends readonly any[], Item> =
Value extends readonly [Value[0], ...infer rest]
? IsEqual<Value[0], Item> extends true
? true
: Includes<rest, Item>
: false;
```
@group type-fest
*/
type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
//#endregion
//#region ../core/src/types/type-fest/is-never.d.ts
/**
Returns a boolean for whether the given type is `never`.
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
@link https://stackoverflow.com/a/53984913/10292952
@link https://www.zhenghao.io/posts/ts-never
Useful in type utilities, such as checking if something does not occur.
@example
```
import type {IsNever, And} from 'type-fest';
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
type AreStringsEqual<A extends string, B extends string> =
And<
IsNever<Exclude<A, B>> extends true ? true : false,
IsNever<Exclude<B, A>> extends true ? true : false
>;
type EndIfEqual<I extends string, O extends string> =
AreStringsEqual<I, O> extends true
? never
: void;
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
if (input === output) {
process.exit(0);
}
}
endIfEqual('abc', 'abc');
//=> never
endIfEqual('abc', '123');
//=> void
```
@group type-fest
*/
type IsNever<T> = [T] extends [never] ? true : false;
//#endregion
//#region ../core/src/types/type-fest/if-never.d.ts
/**
An if-else-like type that resolves depending on whether the given type is `never`.
@see {@link IsNever}
@example
```
import type {IfNever} from 'type-fest';
type ShouldBeTrue = IfNever<never>;
//=> true
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
//=> 'bar'
```
@group type-fest
*/
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
//#endregion
//#region ../core/src/types/type-fest/unknown-array.d.ts
/**
Represents an array with `unknown` value.
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
@example
```
import type {UnknownArray} from 'type-fest';
type IsArray<T> = T extends UnknownArray ? true : false;
type A = IsArray<['foo']>;
//=> true
type B = IsArray<readonly number[]>;
//=> true
type C = IsArray<string>;
//=> false
```
@group type-fest
*/
type UnknownArray = readonly unknown[];
//#endregion
//#region ../core/src/types/type-fest/internal/array.d.ts
/**
Returns whether the given array `T` is readonly.
@group type-fest
*/
type IsArrayReadonly<T extends UnknownArray> = IfNever$1<T, false, T extends unknown[] ? false : true>;
/**
An if-else-like type that resolves depending on whether the given array is readonly.
@see {@link IsArrayReadonly}
@example
```
import type {ArrayTail} from 'type-fest';
type ReadonlyPreservingArrayTail<TArray extends readonly unknown[]> =
ArrayTail<TArray> extends infer Tail
? IfArrayReadonly<TArray, Readonly<Tail>, Tail>
: never;
type ReadonlyTail = ReadonlyPreservingArrayTail<readonly [string, number, boolean]>;
//=> readonly [number, boolean]
type NonReadonlyTail = ReadonlyPreservingArrayTail<[string, number, boolean]>;
//=> [number, boolean]
type ShouldBeTrue = IfArrayReadonly<readonly unknown[]>;
//=> true
type ShouldBeBar = IfArrayReadonly<unknown[], 'foo', 'bar'>;
//=> 'bar'
```
@group type-fest
*/
type IfArrayReadonly<T extends UnknownArray, TypeIfArrayReadonly = true, TypeIfNotArrayReadonly = false> = IsArrayReadonly<T> extends infer Result ? Result extends true ? TypeIfArrayReadonly : TypeIfNotArrayReadonly : never;
//#endregion
//#region ../core/src/types/type-fest/is-any.d.ts
type NoInfer<T> = T extends infer U ? U : never;
/**
Returns a boolean for whether the given type is `any`.
@link https://stackoverflow.com/a/49928360/1490091
Useful in type utilities, such as disallowing `any`s to be passed to a function.
@example
```
import type {IsAny} from 'type-fest';
const typedObject = {a: 1, b: 2} as const;
const anyObject: any = {a: 1, b: 2};
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
return obj[key];
}
const typedA = get(typedObject, 'a');
//=> 1
const anyA = get(anyObject, 'a');
//=> any
```
@group type-fest
*/
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
//#endregion
//#region ../core/src/types/type-fest/simplify.d.ts
/**
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.
@example
```
import type {Simplify} from 'type-fest';
type PositionProps = {
top: number;
left: number;
};
type SizeProps = {
width: number;
height: number;
};
// In your editor, hovering over `Props` will show a flattened object with all the properties.
type Props = Simplify<PositionProps & SizeProps>;
```
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.
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`.
@example
```
import type {Simplify} from 'type-fest';
interface SomeInterface {
foo: number;
bar?: string;
baz: number | undefined;
}
type SomeType = {
foo: number;
bar?: string;
baz: number | undefined;
};
const literal = {foo: 123, bar: 'hello', baz: 456};
const someType: SomeType = literal;
const someInterface: SomeInterface = literal;
function fn(object: Record<string, unknown>): void {}
fn(literal); // Good: literal object type is sealed
fn(someType); // Good: type is sealed
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
```
@link https://github.com/microsoft/TypeScript/issues/15300
@see SimplifyDeep
@group type-fest
*/
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
//#endregion
//#region ../core/src/types/type-fest/union-to-intersection.d.ts
/**
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).
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
@example
```
import type {UnionToIntersection} from 'type-fest';
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
type Intersection = UnionToIntersection<Union>;
//=> {the(): void; great(arg: string): void; escape: boolean};
```
A more applicable example which could make its way into your library code follows.
@example
```
import type {UnionToIntersection} from 'type-fest';
class CommandOne {
commands: {
a1: () => undefined,
b1: () => undefined,
}
}
class CommandTwo {
commands: {
a2: (argA: string) => undefined,
b2: (argB: string) => undefined,
}
}
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
type Union = typeof union;
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
type Intersection = UnionToIntersection<Union>;
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
```
@group type-fest
*/
type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
//#endregion
//#region ../core/src/types/type-fest/keys-of-union.d.ts
/**
Create a union of all keys from a given type, even those exclusive to specific union members.
Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
@link https://stackoverflow.com/a/49402091
@example
```
import type {KeysOfUnion} from 'type-fest';
type A = {
common: string;
a: number;
};
type B = {
common: string;
b: string;
};
type C = {
common: string;
c: boolean;
};
type Union = A | B | C;
type CommonKeys = keyof Union;
//=> 'common'
type AllKeys = KeysOfUnion<Union>;
//=> 'common' | 'a' | 'b' | 'c'
```
@group type-fest
*/
type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
//#endregion
//#region ../core/src/types/type-fest/optional-keys-of.d.ts
/**
Extract all optional keys from the given type.
This is useful when you want to create a new type that contains different type values for the optional keys only.
@example
```
import type {OptionalKeysOf, Except} from 'type-fest';
interface User {
name: string;
surname: string;
luckyNumber?: number;
}
const REMOVE_FIELD = Symbol('remove field symbol');
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
};
const update1: UpdateOperation<User> = {
name: 'Alice'
};
const update2: UpdateOperation<User> = {
name: 'Bob',
luckyNumber: REMOVE_FIELD
};
```
@group type-fest
*/
type OptionalKeysOf<BaseType extends object> = BaseType extends unknown ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) : never;
//#endregion
//#region ../core/src/types/type-fest/required-keys-of.d.ts
/**
Extract all required keys from the given type.
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...
@example
```
import type {RequiredKeysOf} from 'type-fest';
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
interface User {
name: string;
surname: string;
luckyNumber?: number;
}
const validator1 = createValidation<User>('name', value => value.length < 25);
const validator2 = createValidation<User>('surname', value => value.length < 25);
```
@group type-fest
*/
type RequiredKeysOf<BaseType extends object> = BaseType extends unknown ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
//#endregion
//#region ../core/src/types/type-fest/omit-index-signature.d.ts
/**
Omit any index signatures from the given object type, leaving only explicitly defined properties.
This is the counterpart of `PickIndexSignature`.
Use-cases:
- Remove overly permissive signatures from third-party types.
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
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>`.
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
```
const indexed: Record<string, unknown> = {}; // Allowed
const keyed: Record<'foo', unknown> = {}; // Error
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
```
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:
```
type Indexed = {} extends Record<string, unknown>
? '✅ `{}` is assignable to `Record<string, unknown>`'
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
// => '✅ `{}` is assignable to `Record<string, unknown>`'
type Keyed = {} extends Record<'foo' | 'bar', unknown>
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
```
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`...
```
import type {OmitIndexSignature} from 'type-fest';
type OmitIndexSignature<ObjectType> = {
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
};
```
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
```
import type {OmitIndexSignature} from 'type-fest';
type OmitIndexSignature<ObjectType> = {
[KeyType in keyof ObjectType
// Is `{}` assignable to `Record<KeyType, unknown>`?
as {} extends Record<KeyType, unknown>
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
]: ObjectType[KeyType];
};
```
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.
@example
```
import type {OmitIndexSignature} from 'type-fest';
interface Example {
// These index signatures will be removed.
[x: string]: any
[x: number]: any
[x: symbol]: any
[x: `head-${string}`]: string
[x: `${string}-tail`]: string
[x: `head-${string}-tail`]: string
[x: `${bigint}`]: string
[x: `embedded-${number}`]: string
// These explicitly defined keys will remain.
foo: 'bar';
qux?: 'baz';
}
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
// => { foo: 'bar'; qux?: 'baz' | undefined; }
```
@see PickIndexSignature
@group type-fest
*/
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
//#endregion
//#region ../core/src/types/type-fest/pick-index-signature.d.ts
/**
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
This is the counterpart of `OmitIndexSignature`.
@example
```
import type {PickIndexSignature} from 'type-fest';
declare const symbolKey: unique symbol;
type Example = {
// These index signatures will remain.
[x: string]: unknown;
[x: number]: unknown;
[x: symbol]: unknown;
[x: `head-${string}`]: string;
[x: `${string}-tail`]: string;
[x: `head-${string}-tail`]: string;
[x: `${bigint}`]: string;
[x: `embedded-${number}`]: string;
// These explicitly defined keys will be removed.
['kebab-case-key']: string;
[symbolKey]: string;
foo: 'bar';
qux?: 'baz';
};
type ExampleIndexSignature = PickIndexSignature<Example>;
// {
// [x: string]: unknown;
// [x: number]: unknown;
// [x: symbol]: unknown;
// [x: `head-${string}`]: string;
// [x: `${string}-tail`]: string;
// [x: `head-${string}-tail`]: string;
// [x: `${bigint}`]: string;
// [x: `embedded-${number}`]: string;
// }
```
@see OmitIndexSignature
@group type-fest
*/
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
//#endregion
//#region ../core/src/types/type-fest/merge.d.ts
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
/**
Merge two types into a new type. Keys of the second type overrides keys of the first type.
@example
```
import type {Merge} from 'type-fest';
interface Foo {
[x: string]: unknown;
[x: number]: unknown;
foo: string;
bar: symbol;
}
type Bar = {
[x: number]: number;
[x: symbol]: unknown;
bar: Date;
baz: boolean;
};
export type FooBar = Merge<Foo, Bar>;
// => {
// [x: string]: unknown;
// [x: number]: number;
// [x: symbol]: unknown;
// foo: string;
// bar: Date;
// baz: boolean;
// }
```
@group type-fest
*/
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
//#endregion
//#region ../core/src/types/type-fest/if-any.d.ts
/**
An if-else-like type that resolves depending on whether the given type is `any`.
@see {@link IsAny}
@example
```
import type {IfAny} from 'type-fest';
type ShouldBeTrue = IfAny<any>;
//=> true
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
//=> 'bar'
```
@group type-fest
*/
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
//#endregion
//#region ../core/src/types/type-fest/internal/type.d.ts
/**
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
@example
```
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
//=> 'VALID'
// When `T` is `any` => Returns `IfAny` branch
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
//=> 'IS_ANY'
// When `T` is `never` => Returns `IfNever` branch
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
//=> 'IS_NEVER'
```
@group type-fest
*/
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
//#endregion
//#region ../core/src/types/type-fest/internal/object.d.ts
/**
Works similar to the built-in `Pick` utility type, except for the following differences:
- Distributes over union types and allows picking keys from any member of the union type.
- Primitives types are returned as-is.
- Picks all keys if `Keys` is `any`.
- Doesn't pick `number` from a `string` index signature.
@example
```
type ImageUpload = {
url: string;
size: number;
thumbnailUrl: string;
};
type VideoUpload = {
url: string;
duration: number;
encodingFormat: string;
};
// Distributes over union types and allows picking keys from any member of the union type
type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
//=> {url: string; size: number} | {url: string; duration: number}
// Primitive types are returned as-is
type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
//=> string | number
// Picks all keys if `Keys` is `any`
type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
//=> {a: 1; b: 2} | {c: 3}
// Doesn't pick `number` from a `string` index signature
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
//=> {}
@group type-fest
*/
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
/**
Merges user specified options with default options.
@example
```
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
type SpecifiedOptions = {leavesOnly: true};
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
//=> {maxRecursionDepth: 10; leavesOnly: true}
```
@example
```
// Complains if default values are not provided for optional options
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
type DefaultPathsOptions = {maxRecursionDepth: 10};
type SpecifiedOptions = {};
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
// ~~~~~~~~~~~~~~~~~~~
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
```
@example
```
// Complains if an option's default type does not conform to the expected type
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
type SpecifiedOptions = {};
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
// ~~~~~~~~~~~~~~~~~~~
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
```
@example
```
// Complains if an option's specified type does not conform to the expected type
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
type SpecifiedOptions = {leavesOnly: 'yes'};
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
// ~~~~~~~~~~~~~~~~
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
```
@group type-fest
*/
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny$1<SpecifiedOptions, Defaults, IfNever$1<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
//#endregion
//#region ../core/src/types/type-fest/except.d.ts
/**
Filter out keys from an object.
Returns `never` if `Exclude` is strictly equal to `Key`.
Returns `never` if `Key` extends `Exclude`.
Returns `Key` otherwise.
@example
```
type Filtered = Filter<'foo', 'foo'>;
//=> never
```
@example
```
type Filtered = Filter<'bar', string>;
//=> never
```
@example
```
type Filtered = Filter<'bar', 'foo'>;
//=> 'bar'
```
@see {Except}
*/
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
type ExceptOptions = {
/**
Disallow assigning non-specified properties.
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
@default false
*/
requireExactProps?: boolean;
};
type DefaultExceptOptions = {
requireExactProps: false;
};
/**
Create a type from an object type without certain keys.
We recommend setting the `requireExactProps` option to `true`.
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.
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)).
@example
```
import type {Except} from 'type-fest';
type Foo = {
a: number;
b: string;
};
type FooWithoutA = Except<Foo, 'a'>;
//=> {b: string}
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
//=> errors: 'a' does not exist in type '{ b: string; }'
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
//=> {a: number} & Partial<Record<"b", never>>
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
// The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
// Consider the following example:
type UserData = {
[metadata: string]: string;
email: string;
name: string;
role: 'admin' | 'user';
};
// `Omit` clearly doesn't behave as expected in this case:
type PostPayload = Omit<UserData, 'email'>;
//=> type PostPayload = { [x: string]: string; [x: number]: string; }
// In situations like this, `Except` works better.
// It simply removes the `email` key while preserving all the other keys.
type PostPayload = Except<UserData, 'email'>;
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
```
@group type-fest
*/
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
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>> : {});
//#endregion
//#region ../core/src/types/type-fest/require-at-least-one.d.ts
/**
Create a type that requires at least one of the given keys. The remaining keys are kept as is.
@example
```
import type {RequireAtLeastOne} from 'type-fest';
type Responder = {
text?: () => string;
json?: () => string;
secure?: boolean;
};
const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
json: () => '{"message": "ok"}',
secure: true
};
```
@group type-fest
*/
type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireAtLeastOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
//#endregion
//#region ../core/src/types/type-fest/set-non-nullable.d.ts
/**
Create a type that makes the given keys non-nullable, where the remaining keys are kept as is.
If no keys are given, all keys will be made non-nullable.
Use-case: You want to define a single model where the only thing that changes is whether or not some or all of the keys are non-nullable.
@example
```
import type {SetNonNullable} from 'type-fest';
type Foo = {
a: number | null;
b: string | undefined;
c?: boolean | null;
}
type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
// type SomeNonNullable = {
// a: number | null;
// b: string; // Can no longer be undefined.
// c?: boolean; // Can no longer be null, but is still optional.
// }
type AllNonNullable = SetNonNullable<Foo>;
// type AllNonNullable = {
// a: number; // Can no longer be null.
// b: string; // Can no longer be undefined.
// c?: boolean; // Can no longer be null, but is still optional.
// }
```
@group type-fest
*/
type SetNonNullable<BaseType, Keys extends keyof BaseType = keyof BaseType> = { [Key in keyof BaseType]: Key extends Keys ? NonNullable<BaseType[Key]> : BaseType[Key] };
//#endregion
//#region ../core/src/types/type-fest/set-required.d.ts
/**
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
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.
@example
```
import type {SetRequired} from 'type-fest';
type Foo = {
a?: number;
b: string;
c?: boolean;
}
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
// type SomeRequired = {
// a?: number;
// b: string; // Was already required and still is.
// c: boolean; // Is now required.
// }
// Set specific indices in an array to be required.
type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
//=> [number, number, number?]
```
@group type-fest
*/
type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? IfArrayReadonly<BaseType, Readonly<ResultantArray>, ResultantArray> : never : Simplify<Except<BaseType, Keys> & Required<HomomorphicPick<BaseType, Keys>>>;
/**
Remove the optional modifier from the specified keys in an array.
*/
type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown ? keyof TArray & `${number}` extends never ? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? "0" extends OptionalKeysOf<TArray> ? `${Counter["length"]}` extends `${Keys & (string | number)}` ? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]> : [...Accumulator, ...TArray] : SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, TArray[0]]> : never : never;
//#endregion
//#region ../core/src/types/options.d.ts
type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
/**
* Extracts the type of the identifying property from a {@link Option},
* {@link ValueOption}, or {@link FullOption}.
*
* @group Option Lists
*/
type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
/**
* Adds an `unknown` index property to an interface.
*/
type WithUnknownIndex<T> = T & {
[key: string]: unknown;
};
/**
* Do not use this type directly; use {@link Option}, {@link ValueOption},
* or {@link FullOption} instead. For specific option types, you can use
* {@link FullField}, {@link FullOperator}, or {@link FullCombinator},
* all of which extend {@link FullOption}.
*
* @group Option Lists
*/
interface BaseOption<N extends string = string> {
name?: N;
value?: N;
label: string;
disabled?: boolean;
}
/**
* A generic option. Used directly in {@link OptionList} or
* as the child element of an {@link OptionGroup}.
*
* @group Option Lists
*/
type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name">>>;
/**
* Like {@link Option} but requiring `value` instead of `name`.
*
* @group Option Lists
*/
type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "value">>>;
/**
* A generic {@link Option} with either a `name` or `value` as its primary identifier.
* {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
* but corresponding props passed down to subcomponents will always be translated
* to {@link FullOption} first.
*
* @group Option Lists
*/
type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
/**
* Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
* into a {@link FlexibleOption}.
*
* @group Option Lists
*/
type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
/**
* A generic {@link Option} requiring both `name` _and_ `value` properties.
* Props that extend {@link OptionList} accept {@link BaseOption}, but
* corresponding props sent to subcomponents will always be translated to this
* type first to ensure both `name` and `value` are available.
*
* NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
* (optionally wrapped in {@link WithUnknownIndex}) instead, otherwise
* the `unknown` index property will cause issues. See {@link Option} and
* {@link ValueOption} for examples.
*
* @group Option Lists
*/
type FullOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name" | "value">>>;
/**
* This type is identical to {@link FullOption} but without the `unknown` index
* property. Extend from this type instead of {@link FullOption} directly.
*
* @group Option Lists
*/
type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption<N>, "name" | "value">>;
/**
* Utility type to turn an {@link Option}, {@link ValueOption} or
* {@link BaseOption} into a {@link FullOption}.
*
* @group Option Lists
*/
type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
/**
* A group of {@link Option}s, usually within an {@link OptionList}.
*
* @group Option Lists
*/
interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
label: string;
options: WithUnknownIndex<Opt>[];
}
/**
* A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
*
* @group Option Lists
*/
type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
label: string;
options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
};
/**
* Either an array of {@link Option}s or an array of {@link OptionGroup}s.
*
* @group Option Lists
*/
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
/**
* An array of options or option groups, like {@link OptionList} but the option type
* may use either `name` or `value` as the primary identifier.
*
* @group Option Lists
*/
type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
/**
* An array of options or option groups, like {@link OptionList} but the option type
* may use either `name` or `value` as the primary identifier.
*
* @group Option Lists
*/
type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
/**
* An array of options or option groups, like {@link OptionList}, but using
* {@link FullOption} instead of {@link Option}. This means that every member is
* guaranteed to have both `name` and `value`.
*
* @group Option Lists
*/
type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
/**
* Map of option identifiers to their respective {@link Option}.
*
* @group Option Lists
*/
type BaseOptionMap<V extends BaseOption = BaseOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: ToFlexibleOption<V> };
//#endregion
//#region ../core/src/types/ruleGroups.d.ts
/**
* Properties common to both rules and groups.
*/
interface CommonRuleAndGroupProperties {
path?: Path;
id?: string;
disabled?: boolean;
}
/**
* The main rule type. The `field`, `operator`, and `value` properties
* can be narrowed with generics.
*/
interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
field: F;
operator: O;
value: V;
valueSource?: ValueSource;
match?: MatchConfig;
/**
* Only used when adding a rule to a query that uses independent combinators.
*/
combinatorPreceding?: C;
}
/**
* The main rule group type. This type is used for query definitions as well as
* all sub-groups of queries.
*/
interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
combinator: C;
rules: RuleGroupArray<RuleGroupType<R, C>, R>;
not?: boolean;
}
/**
* The type of the `rules` array in a {@link RuleGroupType}.
*/
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
//#endregion
//#region ../core/src/types/ruleGroupsIC.utils.d.ts
type MAXIMUM_ALLOWED_BOUNDARY = 80;
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]>;
//#endregion
//#region ../core/src/types/ruleGroupsIC.d.ts
/**
* The main rule group interface when using independent combinators. This type is used
* for query definitions as well as all sub-groups of queries.
*/
interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
combinator?: undefined;
rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
/**
* Only used when adding a rule to a query that uses independent combinators
*/
combinatorPreceding?: C;
}
/**
* Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
*/
type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
/**
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
*/
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
length: 0;
});
/**
* Shorthand for "either {@link RuleGroupArray} or {@link RuleGroupICArray}".
*/
type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
/**
* Converts a narrowed rule group type to its most generic form.
*/
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
//#endregion
//#region ../core/src/types/validation.d.ts
/**
* Object with a `valid` boolean value and optional `reasons`.
*/
interface ValidationResult {
valid: boolean;
reasons?: any[];
}
/**
* Map of rule/group `id` to its respective {@link ValidationResult}.
*/
type ValidationMap = Record<string, boolean | ValidationResult>;
/**
* Function that validates a query.
*/
type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
/**
* Function that validates a rule.
*/
type RuleValidator = (rule: RuleType) => boolean | ValidationResult;
//#endregion
//#region ../core/src/types/basic.d.ts
/**
* @see https://react-querybuilder.js.org/docs/tips/path
*/
type Path = number[];
/**
* String of classnames, array of classname strings, or object where the
* keys are classnames and those with truthy values will be included.
* Suitable for passing to the `clsx` package.
*/
type Classname = string | string[] | Record<string, any>;
/**
* A source for the `value` property of a rule.
*/
type ValueSource = "value" | "field";
/**
* Type of {@link ValueEditor} that will be displayed.
*/
type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
/**
* A valid array of potential value sources.
*
* @see {@link ValueSource}
*/
type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
type ValueSourceFullOptions = ToOptionArrays<ValueSources>;
type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: {
name: Sources[K];
value: Sources[K];
label: string;
} } : never;
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
type WithOptionalClassName<T> = T & {
className?: Classname;
};
/**
* HTML5 input types
*/
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 & {});
/**
* Quantification mode describing how many elements of the value array must pass
* the filter for the rule itself to pass.
*
* For "atLeast", "atMost", and "exactly", the threshold value will be converted to
* a percentage if the number is less than 1. Non-numeric values and numbers less
* than 0 will be ignored.
*/
interface MatchConfig {
mode: MatchMode;
threshold?: number | null | undefined;
}
type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
type MatchModeOptions = StringUnionToFullOptionArray<MatchMode>;
type ActionElementEventHandler = (event?: any, context?: any) => void;
type ValueChangeEventHandler = (value?: any, context?: any) => void;
/**
* Base for all Field types/interfaces.
*/
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>> {
id?: string;
operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
inputType?: InputType | null;
values?: FlexibleOptionList<ValueObj>;
matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
/** Properties of items in the value. */
subproperties?: FlexibleOptionList<FullField>;
defaultOperator?: OperatorName;
defaultValue?: any;
placeholder?: string;
validator?: RuleValidator;
comparator?: string | ((f: FullField, operator: string) => boolean);
}
/**
* Full field definition used in the `fields` prop of {@link QueryBuilder}.
* This type requires both `name` and `value`, but the `fields` prop itself
* can use a {@link FlexibleOption} where only one of `name` or `value` is
* required (along with `label`), or {@link Field} where only `name` and
* `label` are required.
*
* The `name`/`value`, `operators`, and `values` properties of this interface
* can be narrowed with generics.
*
* @group Option Lists
*/
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>>;
/**
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
* a number less than two will cause the default {@link ValueEditor} to render `null`.
*/
type Arity = number | "unary" | "binary" | "ternary";
/**
* Full operator definition used in the `operators`/`getOperators` props of
* {@link QueryBuilder}. This type requires both `name` and `value`, but the
* `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
* where only one of `name` or `value` is required, or {@link FullOperator} where
* only `name` is required.
*
* The `name`/`value` properties of this interface can be narrowed with generics.
*
* @group Option Lists
*/
interface FullOperator<N extends string = string> extends WithOptionalClassName<FullOption<N>> {
arity?: Arity;
}
/**
* Full combinator definition used in the `combinators` prop of {@link QueryBuilder}.
* This type requires both `name` and `value`, but the `combinators` prop itself
* can use a {@link FlexibleOption} where only one of `name` or `value` is required,
* or {@link Combinator} where only `name` is required.
*
* The `name`/`value` properties of this interface can be narrowed with generics.
*
* @group Option Lists
*/
type FullCombinator<N extends string = string> = WithOptionalClassName<FullOption<N>>;
type ParseNumberMethodName = "enhanced" | "native" | "strict";
/**
* Parsing algorithms used by {@link parseNumber}.
*/
type ParseNumbersModerationLevel = "-limited" | "";
/**
* Options for the `parseNumbers` prop of {@link QueryBuilder}.
*/
type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
/**
* Signature of `accessibleDescriptionGenerator` prop, used by {@link QueryBuilder} to generate
* accessible descriptions for each {@link RuleGroup}.
*/
type AccessibleDescriptionGenerator = (props: {
path: Path;
qbId: string;
}) => string;
//#endregion
//#region ../core/src/types/dnd.d.ts
type DropEffect = "move" | "copy";
//#endregion
//#region ../core/src/types/props.d.ts
/**
* Base interface for all rule subcomponents.
*
* @group Props
*/
interface CommonRuleSubComponentProps {
rule: RuleType;
}
/**
* Classnames applied to each component.
*
* @group Props
*/
interface Classnames {
/**
* Classnames applied to the root `<div>` element.
*/
queryBuilder: Classname;
/**
* Classnames applied to the `<div>` containing the RuleGroup.
*/
ruleGroup: Classname;
/**
* Classnames applied to the `<div>` containing the RuleGroup header controls.
*/
header: Classname;
/**
* Classnames applied to the `<div>` containing the RuleGroup child rules/groups.
*/
body: Classname;
/**
* Classnames applied to the `<select>` control for combinators.
*/
combinators: Classname;
/**
* Classnames applied to the `<button>` to add a Rule.
*/
addRule: Classname;
/**
* Classnames applied to the `<button>` to add a RuleGroup.
*/
addGroup: Classname;
/**
* Classnames applied to the `<button>` to clone a Rule.
*/
cloneRule: Classname;
/**
* Classnames applied to the `<button>` to clone a RuleGroup.
*/
cloneGroup: Classname;
/**
* Classnames applied to the `<button>` to remove a RuleGroup.
*/
removeGroup: Classname;
/**
* Classnames applied to the `<div>` containing the Rule.
*/
rule: Classname;
/**
* Classnames applied to the `<select>` control for fields.
*/
fields: Classname;
/**
* Classnames applied to the `<select>` control for match modes.
*/
matchMode: Classname;
/**
* Classnames applied to the `<input>` for match thresholds.
*/
matchThreshold: Classname;
/**
* Classnames applied to the `<select>` control for operators.
*/
operators: Classname;
/**
* Classnames applied to the `<input>` for the rule value.
*/
value: Classname;
/**
* Classnames applied to the `<button>` to remove a Rule.
*/
removeRule: Classname;
/**
* Classnames applied to the `<label>` on the "not" toggle.
*/
notToggle: Classname;
/**
* Classnames applied to the `<span>` handle for dragging rules/groups.
*/
shiftActions: Classname;
/**
* Classnames applied to the `<span>` handle for dragging rules/groups.
*/
dragHandle: Classname;
/**
* Classnames applied to the `<button>` to lock/disable a Rule.
*/
lockRule: Classname;
/**
* Classnames applied to the `<button>` to lock/disable a RuleGroup.
*/
lockGroup: Classname;
/**
* Classnames applied to the `<select>` control for value sources.
*/
valueSource: Classname;
/**
* Classnames applied to all action elements.
*/
actionElement: Classname;
/**
* Classnames applied to all select elements.
*/
valueSelector: Classname;
/**
* Classname(s) applied to inline combinator elements.
*/
betweenRules: Classname;
/**
* Classname(s) applied to valid rules and groups.
*/
valid: Classname;
/**
* Classname(s) applied to invalid rules and groups.
*/
invalid: Classname;
/**
* Classname(s) applied to rules and groups while being dragged.
*/
dndDragging: Classname;
/**
* Classname(s) applied to rules and groups hovered over by a dragged element.
*/
dndOver: Classname;
/**
* Classname(s) applied to rules and groups hovered over by a dragged element
* when the drop effect is "copy" (modifier key is pressed).
*/
dndCopy: Classname;
/**
* Classname(s) applied to rules and groups hovered over by a dragged element
* when the Ctrl key is pressed, indicating the items will form a new group.
*/
dndGroup: Classname;
/**
* Classname(s) applied to rules and groups that cannot accept a drop from
* the dragged element hovering over it.
*/
dndDropNotAllowed: Classname;
/**
* Classname(s) applied to disabled elements.
*/
disabled: Classname;
/**
* Classname(s) applied to each element in a series of value editors.
*/
valueListItem: Classname;
/**
* Not applied, but see CSS styles.
*/
branches: Classname;
/**
* Classname(s) rules that render a subquery.
*/
hasSubQuery: Classname;
}
/**
* Functions included in the `actions` prop passed to every subcomponent.
*
* @group Props
*/
interface QueryActions {
onGroupAdd(group: RuleGroupTypeAny, parentPath: Path, context?: any): void;
onGroupRemove(path: Path): void;
onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, "id" | "path">, value: any, path: Path, context?: any): void;
onRuleAdd(rule: RuleType, parentPath: Path, context?: any): void;
onRuleRemove(path: Path): void;
moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
}
//#endregion
//#region ../core/src/utils/queryTools.d.ts
/**
* Options for {@link move}.
*
* @group Query Tools
*/
interface MoveOptions