packages/react-components/react-utilities/etc/react-utilities.api.md
Do not edit this file. It is a report generated by API Extractor.
import * as React_2 from 'react';
// @public
function always<Props extends UnknownSlotProps>(value: Props | SlotShorthandValue | undefined, options: SlotOptions<Props>): SlotComponentType<Props>;
// @internal
export function applyTriggerPropsToChildren<TriggerChildProps>(children: TriggerProps<TriggerChildProps>['children'], triggerChildProps: TriggerChildProps): React_2.ReactElement | null;
// @internal
export function assertSlots<Slots extends SlotPropsRecord>(state: unknown): asserts state is SlotComponents<Slots>;
// @public
export function canUseDOM(): boolean;
// @internal
export const clamp: (value: number, min: number, max: number) => number;
// @public
export type ComponentProps<Slots extends SlotPropsRecord, Primary extends keyof Slots = 'root'> = Omit<Slots, Primary & 'root'> & PropsWithoutRef<ExtractSlotProps<Slots[Primary]>>;
// @public
export type ComponentState<Slots extends SlotPropsRecord> = {
components: {
[Key in keyof Slots]-?: React_2.ElementType;
};
} & {
[Key in keyof Slots]: ReplaceNullWithUndefined<WithoutSlotRenderFunction<Exclude<Slots[Key], SlotShorthandValue | (Key extends 'root' ? null : never)>>>;
};
// @internal (undocumented)
export function createPriorityQueue<T>(compare: PriorityQueueCompareFn<T>): PriorityQueue<T>;
// @public
export type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : T;
// @internal
export function elementContains(parent: Node | null, child: Node | null): boolean;
// @public
export type EventData<Type extends string, TEvent> = {
type: undefined;
event: React_2.SyntheticEvent | Event;
} | {
type: Type;
event: TEvent;
};
// @public
export type EventHandler<TData extends EventData<string, unknown>> = (ev: React_2.SyntheticEvent | Event, data: TData) => void;
// @public
export type ExtractSlotProps<S> = Exclude<S, SlotShorthandValue | null | undefined>;
// @internal
export type FluentTriggerComponent = {
isFluentTriggerComponent?: boolean;
};
// @public
export type ForwardRefComponent<Props> = NamedExoticComponent<Props & RefAttributes<InferredElementRefType<Props>>>;
// @public
export function getEventClientCoords(event: TouchOrMouseEvent): {
clientX: number;
clientY: number;
};
// @public
export const getIntrinsicElementProps: <Props extends UnknownSlotProps, ExcludedPropKeys extends Extract<keyof Props, string> = never>(tagName: NonNullable<Props["as"]>, props: Props & React_2.RefAttributes<InferredElementRefType<Props>>, excludedPropNames?: ExcludedPropKeys[]) => DistributiveOmit<Props, ExcludedPropKeys | Exclude<keyof Props, "as" | keyof HTMLAttributes>>;
// @public @deprecated
export function getNativeElementProps<TAttributes extends React_2.HTMLAttributes<any>>(tagName: string, props: {}, excludedPropNames?: string[]): TAttributes;
// @internal
export function getParent(child: Node | null, options?: GetParentOptions): Node | null;
// @public
export const getPartitionedNativeProps: <Props extends Pick<React_2.HTMLAttributes<HTMLElement>, "style" | "className">, ExcludedPropKeys extends Extract<keyof Props, string> = never>({ primarySlotTagName, props, excludedPropNames, }: {
primarySlotTagName: JSXIntrinsicElementKeys;
props: Props;
excludedPropNames?: ExcludedPropKeys[];
}) => {
root: {
style: React_2.CSSProperties | undefined;
className: string | undefined;
};
primary: Omit<Props, ExcludedPropKeys>;
};
// @public
export function getReactElementRef<T>(element: React_2.ReactElement | null | undefined): React_2.Ref<T> | undefined;
// @internal
export const getRTLSafeKey: (key: string, dir: "ltr" | "rtl") => string;
// @public
export const getSlotClassNameProp_unstable: (slot: UnknownSlotProps) => string | undefined;
// @public @deprecated
export function getSlots<R extends SlotPropsRecord>(state: unknown): {
slots: Slots<R>;
slotProps: ObjectSlotProps<R>;
};
// @internal @deprecated
export function getSlotsNext<R extends SlotPropsRecord>(state: unknown): {
slots: Slots<R>;
slotProps: ObjectSlotProps<R>;
};
// @internal
export function getTriggerChild<TriggerChildProps>(children: TriggerProps<TriggerChildProps>['children']): (React_2.ReactElement<Partial<TriggerChildProps>> & {
ref?: React_2.Ref<any>;
}) | null;
// @public
export const IdPrefixProvider: React_2.Provider<string | undefined>;
// @public
export type InferredElementRefType<Props> = ObscureEventName extends keyof Props ? Required<Props>[ObscureEventName] extends React_2.PointerEventHandler<infer Element> ? Element : never : never;
// @internal
export function isFluentTrigger(element: React_2.ReactElement): element is React_2.ReactElement<TriggerProps>;
// @public
export function isHTMLElement<ConstructorName extends HTMLElementConstructorName = 'HTMLElement'>(element?: unknown, options?: {
constructorName?: ConstructorName;
}): element is InstanceType<(typeof globalThis)[ConstructorName]>;
// @internal
export function isInteractiveHTMLElement(element: unknown): boolean;
// @public
export function isMouseEvent(event: TouchOrMouseEvent): event is MouseEvent | React_2.MouseEvent;
// @public
export function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(shorthand?: Shorthand): shorthand is ExtractSlotProps<Shorthand>;
// @public
export function isSlot<Props extends {}>(element: unknown): element is SlotComponentType<Props>;
// @public
export function isTouchEvent(event: TouchOrMouseEvent): event is TouchEvent | React_2.TouchEvent;
// @public
export type JSXElement = React_2.ReactElement<any, any>;
// @public
export type JSXIntrinsicElement<Element extends JSXIntrinsicElementKeys> = React_2.ComponentProps<Element>;
// @public
export type JSXIntrinsicElementKeys = Exclude<React_2.ElementType, React_2.ComponentType>;
// @internal
export function mergeCallbacks<Args extends unknown[]>(callback1: ((...args: Args) => void) | undefined, callback2: ((...args: Args) => void) | undefined): (...args: Args) => void;
// @public (undocumented)
export type NativeTouchOrMouseEvent = MouseEvent | TouchEvent;
// @public
export function omit<TObj extends Record<string, any>, Exclusions extends (keyof TObj)[]>(obj: TObj, exclusions: Exclusions): Omit<TObj, Exclusions[number]>;
// @public (undocumented)
export type OnSelectionChangeCallback = (event: React_2.SyntheticEvent, selectedItems: Set<SelectionItemId>) => void;
// @public (undocumented)
export type OnSelectionChangeData = {
selectedItems: Set<SelectionItemId>;
};
// @public
function optional<Props extends UnknownSlotProps>(value: Props | SlotShorthandValue | undefined | null, options: {
renderByDefault?: boolean;
} & SlotOptions<Props>): SlotComponentType<Props> | undefined;
// @internal (undocumented)
export interface PriorityQueue<T> {
// (undocumented)
all: () => T[];
// (undocumented)
clear: () => void;
// (undocumented)
contains: (item: T) => boolean;
// (undocumented)
dequeue: () => T;
// (undocumented)
enqueue: (item: T) => void;
// (undocumented)
peek: () => T | null;
// (undocumented)
remove: (item: T) => void;
// (undocumented)
size: () => number;
}
// @public (undocumented)
export type ReactTouchOrMouseEvent = React_2.MouseEvent | React_2.TouchEvent;
// @public
export interface RefAttributes<T> extends React_2.Attributes {
// (undocumented)
ref?: React_2.Ref<T> | undefined;
}
// @public
export type RefObjectFunction<T> = React_2.RefObject<T | null> & ((value: T | null) => void);
// @public
export function resetIdsForTests(): void;
// @public @deprecated
export const resolveShorthand: ResolveShorthandFunction<UnknownSlotProps>;
// @public
function resolveShorthand_2<Props extends UnknownSlotProps | null | undefined>(value: Props | SlotShorthandValue): Props;
// @public @deprecated (undocumented)
export type ResolveShorthandFunction<Props extends UnknownSlotProps = UnknownSlotProps> = {
<P extends Props>(value: P | SlotShorthandValue | undefined, options: ResolveShorthandOptions<P, true>): WithoutSlotRenderFunction<P>;
<P extends Props>(value: P | SlotShorthandValue | null | undefined, options?: ResolveShorthandOptions<P, boolean>): WithoutSlotRenderFunction<P> | undefined;
};
// @public @deprecated (undocumented)
export type ResolveShorthandOptions<Props, Required extends boolean = false> = Required extends true ? {
required: true;
defaultProps?: Props;
} : {
required?: Required;
defaultProps?: Props;
};
// @public (undocumented)
export type SelectionHookParams = {
selectionMode: SelectionMode_2;
defaultSelectedItems?: Iterable<SelectionItemId>;
selectedItems?: Iterable<SelectionItemId>;
onSelectionChange?(event: React_2.SyntheticEvent, data: OnSelectionChangeData): void;
};
// @public (undocumented)
export type SelectionItemId = string | number;
// @public (undocumented)
export interface SelectionMethods {
// (undocumented)
clearItems(event: React_2.SyntheticEvent): void;
// (undocumented)
deselectItem(event: React_2.SyntheticEvent, id: SelectionItemId): void;
// (undocumented)
isSelected(id: SelectionItemId): boolean;
// (undocumented)
selectItem(event: React_2.SyntheticEvent, id: SelectionItemId): void;
// (undocumented)
toggleAllItems(event: React_2.SyntheticEvent, itemIds: SelectionItemId[]): void;
// (undocumented)
toggleItem(event: React_2.SyntheticEvent, id: SelectionItemId): void;
}
// @public (undocumented)
type SelectionMode_2 = 'single' | 'multiselect';
export { SelectionMode_2 as SelectionMode }
// @internal
export function setVirtualParent(child: Node, parent?: Node): void;
// @public
export type Slot<Type extends JSXIntrinsicElementKeys | ComponentType<any> | UnknownSlotProps, AlternateAs extends JSXIntrinsicElementKeys = never> = IsSingleton<Extract<Type, string>> extends true ? WithSlotShorthandValue<Type extends JSXIntrinsicElementKeys ? {
as?: Type;
} & WithSlotRenderFunction<IntrinsicElementProps<Type>> : Type extends ComponentType<infer Props> ? Props extends UnknownSlotProps ? Props : WithSlotRenderFunction<Props> : Type> | (AlternateAs extends unknown ? {
as: AlternateAs;
} & WithSlotRenderFunction<IntrinsicElementProps<AlternateAs>> : never) | null : 'Error: First parameter to Slot must not be not a union of types. See documentation of Slot type.';
declare namespace slot {
export {
always,
optional,
resolveShorthand_2 as resolveShorthand,
SlotOptions
}
}
export { slot }
// @internal
export const SLOT_CLASS_NAME_PROP_SYMBOL: unique symbol;
// @internal
export const SLOT_ELEMENT_TYPE_SYMBOL: unique symbol;
// @internal
export const SLOT_RENDER_FUNCTION_SYMBOL: unique symbol;
// @public
export type SlotClassNames<Slots> = {
[SlotName in keyof Slots]-?: string;
};
// @public
export type SlotComponentType<Props> = WithoutSlotRenderFunction<Props> & FunctionComponent<{
children?: ReactNode;
}> & {
[SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<Props>;
[SLOT_ELEMENT_TYPE_SYMBOL]: ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);
[SLOT_CLASS_NAME_PROP_SYMBOL]?: string;
};
// @public (undocumented)
export type SlotOptions<Props extends UnknownSlotProps> = {
elementType: React_2.ComponentType<Props> | (Props extends AsIntrinsicElement<infer As> ? As : JSXIntrinsicElementKeys);
defaultProps?: Partial<Props>;
};
// @public
export type SlotPropsRecord = Record<string, UnknownSlotProps | SlotShorthandValue | null | undefined>;
// @public (undocumented)
export type SlotRenderFunction<Props> = (Component: React_2.ElementType<Props>, props: Omit<Props, 'as'>) => ReactNode;
// @public @deprecated (undocumented)
export type Slots<S extends SlotPropsRecord> = {
[K in keyof S]: React_2.ElementType<any>;
};
// @public
export type SlotShorthandValue = React_2.ReactElement | string | number | Iterable<ReactNode> | React_2.ReactPortal;
// @public
export const SSRProvider: React_2.FC<{
children: React_2.ReactNode;
}>;
// @public (undocumented)
export type TouchOrMouseEvent = NativeTouchOrMouseEvent | ReactTouchOrMouseEvent;
// @public
export type TriggerProps<TriggerChildProps = unknown> = {
children?: React_2.ReactElement | ((props: TriggerChildProps) => React_2.ReactElement | null) | null;
};
// @public
export type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
// @public
export type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'className' | 'style'> & {
as?: JSXIntrinsicElementKeys;
children?: ReactNode;
};
// @internal
export function useAnimationFrame(): readonly [(fn: FrameRequestCallback) => number, () => void];
// @public
export function useApplyScrollbarWidth<T extends HTMLElement>(options?: UseApplyScrollbarWidthOptions): React_2.RefCallback<T>;
// @internal
export const useControllableState: <State>(options: UseControllableStateOptions<State>) => [State, React_2.Dispatch<React_2.SetStateAction<State>>];
// @internal (undocumented)
export type UseControllableStateOptions<State> = {
defaultState?: State | (() => State);
state: State | undefined;
initialState: State;
};
// @internal
export const useEventCallback: <Args extends unknown[], Return>(fn: (...args: Args) => Return) => ((...args: Args) => Return);
// @internal
export function useFirstMount(): boolean;
// @internal
export function useForceUpdate(): React_2.DispatchWithoutAction;
// @public
export function useId(prefix?: string, providedId?: string): string;
// @public
export const useIsomorphicLayoutEffect: typeof React_2.useEffect;
// @public
export function useIsSSR(): boolean;
// @public
export function useMergedRefs<T>(...refs: (React_2.Ref<T> | undefined)[]): RefObjectFunction<T>;
// @internal (undocumented)
export type UseOnClickOrScrollOutsideOptions = {
element: Document | undefined;
refs: React_2.MutableRefObject<HTMLElement | undefined | null>[];
contains?(parent: HTMLElement | null, child: HTMLElement): boolean;
disabled?: boolean;
disabledFocusOnIframe?: boolean;
callback: (ev: MouseEvent | TouchEvent) => void;
};
// @internal
export const useOnClickOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
// @internal
export const useOnScrollOutside: (options: UseOnClickOrScrollOutsideOptions) => void;
// @internal (undocumented)
export const usePrevious: <ValueType = unknown>(value: ValueType) => ValueType | null;
// @public (undocumented)
export function useScrollbarWidth(options: UseScrollbarWidthOptions): number | undefined;
// @public (undocumented)
export function useSelection(params: SelectionHookParams): readonly [Set<SelectionItemId>, SelectionMethods];
// @internal
export function useTimeout(): readonly [(fn: () => void, delay?: number) => number, () => void];
// (No @packageDocumentation comment for this package)