UNPKG

@noema/hyle

Version:
20 lines (19 loc) 1.15 kB
import { CSSProperties } from '@vanilla-extract/css'; import { ComponentPropsWithRef, JSX } from 'react'; import { CSSProps, HyleStyle } from './hyle-style.js'; export type Elements = keyof JSX.IntrinsicElements; export type SprinklesFn<Props = any> = { (props: Props): string; properties: Set<string>; }; export type SprinklesProps<S> = S extends SprinklesFn<infer P> ? P : never; export type CSSPropertiesSubset<P extends CSSProps> = { [K in P]?: K extends keyof CSSProperties ? CSSProperties[K] : never; }; export type Shorthands<SH extends string> = { [K in SH]?: string | number | undefined | null; }; export type HyleProps<E extends Elements, S extends SprinklesFn, P extends CSSProps = never, SH extends string = never> = ComponentPropsWithRef<E> & { inlineVars?: Record<string, string | undefined | null>; } & CSSPropertiesSubset<P> & Shorthands<SH> & SprinklesProps<S>; export declare function hyle<E extends Elements, S extends SprinklesFn, P extends CSSProps, SH extends string = string>(element: E, sprinkles: S, hyleStyle: HyleStyle<P, SH>): (props: HyleProps<E, S, P, SH>) => import("react/jsx-runtime").JSX.Element;