import React, { createContext, useContext, useMemo, ReactNode, forwardRef, DetailedHTMLProps, ComponentType, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react' import {IRenderer, combineRules} from 'fela' import {renderToMarkup, renderToSheetList} from 'fela-dom' import {PropertiesFallback} from 'csstype' export interface CSSStyle extends PropertiesFallback { ':active'?: CSSStyle ':any-link'?: CSSStyle ':blank'?: CSSStyle ':checked'?: CSSStyle ':current'?: CSSStyle ':default'?: CSSStyle ':defined'?: CSSStyle ':dir()'?: CSSStyle ':disabled'?: CSSStyle ':drop'?: CSSStyle ':empty'?: CSSStyle ':enabled'?: CSSStyle ':first'?: CSSStyle ':first-child'?: CSSStyle ':first-of-type'?: CSSStyle ':fullscreen'?: CSSStyle ':future'?: CSSStyle ':focus'?: CSSStyle ':focus-visible'?: CSSStyle ':focus-within'?: CSSStyle ':has()'?: CSSStyle ':host'?: CSSStyle ':host()'?: CSSStyle ':host-context()'?: CSSStyle ':hover'?: CSSStyle ':indeterminate'?: CSSStyle ':in-range'?: CSSStyle ':invalid'?: CSSStyle ':is()'?: CSSStyle ':lang()'?: CSSStyle ':last-child'?: CSSStyle ':last-of-type'?: CSSStyle ':left'?: CSSStyle ':link'?: CSSStyle ':local-link'?: CSSStyle ':not()'?: CSSStyle ':nth-child()'?: CSSStyle ':nth-col()'?: CSSStyle ':nth-last-child()'?: CSSStyle ':nth-last-col()'?: CSSStyle ':nth-last-of-type()'?: CSSStyle ':nth-of-type()'?: CSSStyle ':only-child'?: CSSStyle ':only-of-type'?: CSSStyle ':optional'?: CSSStyle ':out-of-range'?: CSSStyle ':past'?: CSSStyle ':placeholder-shown'?: CSSStyle ':read-only'?: CSSStyle ':read-write'?: CSSStyle ':required'?: CSSStyle ':right'?: CSSStyle ':root'?: CSSStyle ':scope'?: CSSStyle ':target'?: CSSStyle ':target-within'?: CSSStyle ':user-invalid'?: CSSStyle ':valid'?: CSSStyle ':visited'?: CSSStyle ':where()'?: CSSStyle '::after'?: CSSStyle '::backdrop'?: CSSStyle '::before'?: CSSStyle '::cue'?: CSSStyle '::first-letter'?: CSSStyle '::first-line'?: CSSStyle '::grammar-error'?: CSSStyle '::marker'?: CSSStyle '::part()'?: CSSStyle '::placeholder'?: CSSStyle '::selection'?: CSSStyle '::slotted()'?: CSSStyle '::spelling-error'?: CSSStyle '+ *'?: CSSStyle '~ *'?: CSSStyle '> *'?: CSSStyle '@media screen and (min-width: 768px)'?: CSSStyle [selector: string]: number | string | CSSStyle | undefined | (string | number)[] } export type CSSRenderer = IRenderer export type CSSRule

= (props: P, renderer: CSSRenderer) => CSSStyle export type CSSKeyframes

= ( props: P, renderer: CSSRenderer ) => Record export interface StyleContextType { readonly renderer: CSSRenderer } export const StyleContext = createContext(null) export interface StyleRendererProviderProps { readonly renderer: CSSRenderer readonly children?: ReactNode } export function StyleProvider(props: StyleRendererProviderProps) { const value = useMemo(() => ({renderer: props.renderer}), [props.renderer]) return {props.children} } export function renderStylesToComponents(renderer: CSSRenderer): ReactNode { // `(sheet as any)` is needed because typings don't include rehydration property. return renderToSheetList(renderer).map((sheet, index) => (