import type { Classes as JssClasses, GenerateId as JssGenerateId, Jss as DefaultJss, SheetsRegistry as JssSheetsRegistry, Styles as JssStyles, StyleSheetFactoryOptions as JssStyleSheetFactoryOptions } from "jss"; import * as React from "react"; import type { DefaultTheme } from "../styles/defaultTheme"; type GenerateStringUnion = Extract< { [Key in keyof T]: true extends T[Key] ? Key : never; }[keyof T], string >; /** Removes types from T that are assignable to U */ export type Diff = T extends U ? never : T; /** Removes types from T that are not assignable to U */ export type Filter = T extends U ? T : never; /** Constructs a type by including null and undefined to Type. */ export type Nullable = { [P in keyof T]: T[P] | null | undefined }; export type NotUndefined = T extends undefined ? never : T; /** * Like `T & U`, but using the value types from `U` where their properties overlap. */ export type Overwrite = Omit & U; /** * Generate a set of string literal types with the given default record `T` and * override record `U`. * * If the property value was `true`, the property key will be added to the * string union. */ export type OverridableStringUnion< T, U = EmptyIntersectionObject > = GenerateStringUnion>; export type GenerateClassName = JssGenerateId; export type SheetsRegistry = JssSheetsRegistry; export type Jss = DefaultJss; export type StyleSheetFactoryOptions = JssStyleSheetFactoryOptions; export interface MakeStylesOptions extends StyleSheetFactoryOptions { name?: string; } export type Styles = | JssStyles | ((theme: T) => JssStyles); export type Classes = JssClasses; // eslint-disable-next-line @typescript-eslint/ban-types export type EmptyIntersectionObject = {}; export type AnyObject = Record; export type EmptyObject = Record; export type MergeElementProps< T extends React.ElementType, P = EmptyIntersectionObject > = Overwrite, P>; /** * Helps create a type where at least one of the properties of an interface is required to exist. */ export type RequireAtLeastOne = Pick< T, Diff > & { [K in Keys]-?: Required> & Partial>>; }[Keys]; /** * Helps create a type where only one of the properties of an interface is required to exist. */ export type RequireOnlyOne = Pick< T, Diff > & { [K in Keys]-?: Required> & Partial, undefined>>; }[Keys];