@grlt-hub/react-slots
Version:
Bring the power of slots to your React components effortlessly.
22 lines (19 loc) • 822 B
TypeScript
import React from 'react';
type EmptyObject = Record<string, never>;
type CreateSlotIdentifier = <T>() => (_: T) => T;
declare const createSlotIdentifier: CreateSlotIdentifier;
type SlotFunction<T> = (_: T) => T;
type Payload<T> = <R>(params: {
component: (props: unknown extends R ? EmptyObject : R extends void ? EmptyObject : R) => JSX.Element;
fn?: (arg: T) => R;
order?: number;
}) => void;
declare const createSlots: <T extends Record<string, SlotFunction<any>>>(config: T) => {
slotsApi: {
insert: {
into: { [key in keyof T]: T[key] extends (_: any) => unknown ? Payload<Parameters<T[key]>[0]> : never; };
};
};
Slots: { [key_1 in keyof T]: React.FunctionComponent<Parameters<T[key_1]>[0]>; };
};
export { type EmptyObject, createSlotIdentifier, createSlots };