import { HTMLAttributes } from 'react'; /** * Allows creating a literal string union type with auto-completion in IDEs */ export type LiteralStringUnion = T | (string & {}); /** * Enforces props from one type and excludes props from the other */ export type ExactlyOne = (T & { [K in keyof U]?: never; }) | (U & { [K in keyof T]?: never; }); export type DataAttributes = Record<`data-${string}`, string>; /** * `data-*` / `aria-*` attributes that can be forwarded to a component's outermost wrapper element. * Declared with index signatures so it can be intersected with a component's named props * (`OwnProps & PassthroughAttributes`) without constraining those named props. */ export type PassthroughAttributes = { [dataAttr: `data-${string}`]: string | number | boolean | undefined; [ariaAttr: `aria-${string}`]: string | number | boolean | undefined; }; export type WithHTMLAttributes> = BaseType & Omit & DataAttributes; export type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T; /** * Makes selected props of the base type required */ export type RequiredProps = Required> & Omit; /** * Literal string union of keys from object */ export type ObjectStringKeys = { [K in keyof T]: T[K] extends string ? K : never; }[keyof T];