import * as react from 'react'; /** * Used for specifying slot name on a TemplateComponent. * We set it as a property on the function */ declare const SLOT_NAME: unique symbol; declare const COMPONENT_TYPE: unique symbol; declare const SLOT_TYPE_IDENTIFIER: "slot"; declare const TEMPLATE_TYPE_IDENTIFIER: "template"; declare const DEFAULT_TEMPLATE_AS: react.ExoticComponent<{ children?: react.ReactNode; }>; declare const DEFAULT_SLOT_NAME = "default"; type DefaultSlotName = typeof DEFAULT_SLOT_NAME; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type Pretty = { [K in keyof T]: T[K]; } & {}; type NoInfer = [T][T extends any ? 0 : never]; type ElementType = Exclude, SlotComponent> | Exclude>; type MergeTPropsAndTAsProps = { [K in keyof _TAsProps]: K extends "children" ? _TAsProps[K] extends react.ReactNode ? _TAsProps[K] | ((props: TProps) => _TAsProps[K]) : never : _TAsProps[K]; }; type TemplateProps, TAsProps extends TAs extends SlotComponent ? TProps : {}> = { as?: TAs; } & (TAs extends SlotComponent ? // When we have: { children?: react.ReactNode; } & Partial & Omit : MergeTPropsAndTAsProps); type UnwrapProps = T extends SlotComponent ? TProps : react.ComponentPropsWithoutRef; type TemplateComponent = { = typeof DEFAULT_TEMPLATE_AS>(props: [UnwrapProps] extends [ TAs extends SlotComponent ? TProps : any ] ? TemplateProps> : "Custom error: Props of `SlotComponent<:Props:>` must extend props of `TemplateComponent<:Name:, :Props:>` when used for `as` prop"): react.ReactElement | null; [SLOT_NAME]: TName; [COMPONENT_TYPE]: typeof TEMPLATE_TYPE_IDENTIFIER; }; type TemplateComponentLikeElement = react.ReactElement<{ children?: react.ReactNode | ((props: TProps) => react.ReactNode); as?: react.ElementType; }, { (props: any): any; [SLOT_NAME]: TName; [COMPONENT_TYPE]: typeof TEMPLATE_TYPE_IDENTIFIER; }>; type TemplateAsSlotComponentLikeElement = react.ReactElement<{ children?: react.ReactNode; as?: SlotComponent; }, { (props: any): any; [SLOT_NAME]: TName; [COMPONENT_TYPE]: typeof TEMPLATE_TYPE_IDENTIFIER; }>; type SlottableNode = TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": TName; }> | (DefaultSlotName extends TName ? (props: TProps) => react.ReactNode : never) | (DefaultSlotName extends TName ? string | number | boolean | null | undefined : never); type SlotTuple = [TName, TProps]; type SlotTupleToSlottableNode> = T extends SlotTuple ? SlottableNode : never; /** * Removes the disallowed props without cluttering the type declaration. * Compared to Omit which shows up on hover */ type OmitDisallowedProps = T extends { children?: any; } | { key?: any; } | { as?: any; } | { ref?: any; } | { "slot-name"?: any; } ? { [P in Exclude]: T[P]; } : T; type DistributiveKeyOf = T extends unknown ? keyof T : never; type Slot = { value: 0 extends TName & 1 ? SlotTuple : TName extends object ? SlotTuple> : SlotTuple, 0 extends TProps & 1 ? any : DistributiveKeyOf> extends never ? {} : TProps extends unknown ? OmitDisallowedProps : never>; }; type MergeDuplicateSlots, _U extends SlotTuple = U> = U extends unknown ? SlotTuple[1]> : never; type Children> = T | Iterable>; type UnwrapValue> = T["value"]; type AnyCase = 0 extends TSlot & 1 ? Slot : TSlot; /** * Declares the type of children based on slots. * Provide the type union of `Slot` to accept different types of slotted children. * @example * ```ts * // The following type accepts children with three types of slots * type Children = Slots | Slot<"bar", {baz: boolean}>> * ``` */ type SlotChildren = Slot> = SlotTupleToSlottableNode>>> | Children>>>>; /** * @example * ```ts * type X = GetTemplateUnions | Slot<"bar", {baz: string}>>> * // | {default: TemplateComponent<"default", {}> * // | {foo: TemplateComponent<'foo', {}> * // | {bar: TemplateComponent<'bar', {baz: string}>} * ``` */ type GetTemplateUnions = U extends TemplateAsSlotComponentLikeElement ? { [Name in Exclude]: TemplateComponent; } : never; /** * Create type-safe template */ type CreateTemplate = Pretty>>>; type SlotProps = TProps & { children?: react.ReactNode; }; type SlotComponent

= { [COMPONENT_TYPE]: typeof SLOT_TYPE_IDENTIFIER; } & ([Partial

] extends [P] ? { /** Slot Component */ (props: SlotProps

): react.ReactElement | null; /** Slot Function */ (defaultContent?: react.ReactNode, props?: P & { key?: react.Key; }, key?: react.Key): react.ReactElement | null; } : { /** Slot Component */ (props: SlotProps

): react.ReactElement | null; /** Slot Function */ (defaultContent: react.ReactNode, props: P & { key?: react.Key; }, key?: react.Key): react.ReactElement | null; }); type GetSlotComponentUnions = T extends TemplateAsSlotComponentLikeElement ? { [Name in N]: SlotComponent

; } : never; type CreateSlotComponent = {} & Pretty>>; type CreateSlot = CreateSlotComponent; type HasSlot = Pretty<{ [Name in Extract>["props"]["slot-name"]]: true | undefined; }>; declare function useSlot(children: T): { slot: CreateSlot; hasSlot: HasSlot; }; declare const template: { [x: string]: TemplateComponent; }; /** Create Type-safe Template */ declare function createTemplate(): UnionToIntersection | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | any>>>>>>>>>>> : T, undefined> extends infer T_3 ? T_3 extends Exclude<0 extends T & 1 ? (string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | any>>>>>>>>>>> : T, undefined> ? T_3 extends TemplateAsSlotComponentLikeElement ? { [Name in Exclude]: TemplateComponent; } : never : never : never> extends infer T_1 ? { [K in keyof T_1]: UnionToIntersection | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | any>>>>>>>>>>> : T, undefined> extends infer T_2 ? T_2 extends Exclude<0 extends T & 1 ? (string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | Iterable<(string | number | boolean | TemplateComponentLikeElement | TemplateAsSlotComponentLikeElement | react.ReactElement<{ "slot-name": string; }, string | react.JSXElementConstructor> | ((props: any) => react.ReactNode) | null | undefined) | any>>>>>>>>>>> : T, undefined> ? T_2 extends TemplateAsSlotComponentLikeElement ? { [Name in Exclude]: TemplateComponent; } : never : never : never>[K]; } : never; type AllowedNodes = react.ElementType | StringConstructor | NumberConstructor; type GetProps = T extends StringConstructor ? never : T extends NumberConstructor ? never : react.ComponentPropsWithRef; type GetNode = T extends NumberConstructor ? number : T extends StringConstructor ? string : react.ReactElement, Exclude>; type OverrideNodeProps, TProps = Pretty>> = { /** * An array specifying allowed React intrinsic element names or custom component names. * It restricts the provided element types or direct children types (if no content is provided). * Include capital String or capital Number to denote string and number nodes. * Combine with `enforce` to handle disallowed nodes and with `props` or `node` to transform matching nodes. */ allowedNodes?: readonly T[]; /** * Specifies the action to take with nodes that aren't allowed, in combination with `allowedNodes`. * By default an error is thrown when it comes across a disallowed node. */ enforce?: U; children?: U extends "ignore" ? react.ReactNode : TNode; /** * Transforms the props of provided elements or fallback elements. You can provide a function that will be * called with the current props of the element, and the returned object will be merged into the existing props. * Alternatively, you can use an object with prop names and transformation functions. * Return value of transformation functions overrides the prop. There are some predefined Transformation * functions on OverrideNode object which you can use. */ props?: ((props: TProps) => Partial) | { [K in keyof TProps]?: (prop: Exclude, propName: K, slotName: string) => TProps[K]; }; /** * Called with each provided node and can be used to transform or replace each node. */ node?: (node: TNode) => react.ReactNode; }; type OverrideNode = { (props: OverrideNodeProps): react.ReactElement | null; /** Concatenates a string x with a space to the original prop. */ stringAppend: (x: string) => (prop: T) => string | (undefined extends T ? undefined : never) | (null extends T ? null : never); /** prepends a string x with a space to the original prop. */ stringPrepend: (x: string) => (prop: T) => string | (undefined extends T ? undefined : never) | (null extends T ? null : never); /** Intercepts a call to a prop and executes the x function before the original function. */ chainBefore: any>(x: NoInfer) => (prop: T, propName: keyof any, slotName: string) => T; /** Intercepts a call to a prop and executes the x function after the original function. */ chainAfter: any>(x: NoInfer) => (prop: T, propName: keyof any, slotName: string) => T; /** Overrides prop */ override: (x: NoInfer) => (prop: T) => T; }; declare const OverrideNode: OverrideNode; export { CreateSlot, CreateTemplate, OverrideNode, Slot, SlotChildren, createTemplate, template, useSlot };