UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

25 lines (24 loc) 1.84 kB
/** biome-ignore-all lint/complexity/noBannedTypes: use `{}` literals */ import { type EventName, type Options } from '@lit/react'; import type React from 'react'; import type { WithDataContext } from './backfills.js'; export type { EventName } from '@lit/react'; type DistributiveOmit<T, K extends string | number | symbol> = T extends any ? K extends keyof T ? Omit<T, K> : T : T; type PropsWithoutRef<T> = DistributiveOmit<T, 'ref'>; type EventNames = Record<string, EventName | string>; type EventListeners<R extends EventNames> = { [K in keyof R]?: R[K] extends EventName ? (e: R[K]['__eventType']) => void : (e: Event) => void; }; type ElementProps<I> = Partial<Omit<I, keyof HTMLElement>>; type ComponentProps<I, E extends EventNames> = Omit<React.HTMLAttributes<I>, keyof E | keyof ElementProps<I>> & EventListeners<E> & ElementProps<I>; /** Mapped type to update the render props callback return type */ type WithJsxRenderProps<T, R extends Renderers> = { [K in keyof T]: K extends keyof R ? NonNullable<T[K]> extends (...args: any[]) => any ? (...args: WithDataContext<Parameters<T[K]>>) => React.ReactNode : T[K] : T[K]; }; export type ReactWebComponent<I extends HTMLElement, E extends EventNames, R extends Renderers> = React.ForwardRefExoticComponent<PropsWithoutRef<WithJsxRenderProps<ComponentProps<I, E>, R>> & React.RefAttributes<I>>; type Renderers = Record<string, string>; interface WrapperOptions<I extends HTMLElement, E extends EventNames, R extends Renderers> extends Options<I, E> { renderProps?: R; moveBackOnDelete?: boolean; } export declare const createComponent: <I extends HTMLElement, E extends EventNames = {}, R extends Renderers = {}>({ react: React, tagName, elementClass, events, displayName, renderProps, moveBackOnDelete, }: WrapperOptions<I, E, R>) => ReactWebComponent<I, E, R>;