import type { CSSProperties } from 'react' import type { BoxShadowValue, FilterFunction, ImageStyle, TextStyle, ViewStyle } from 'react-native' import type { UnistylesBreakpoints } from '../global' import type { UnistylesMiniRuntime } from '../specs' import type { Pseudo } from '../web/convert/pseudo' import type { ReactNativeStyleSheet } from './breakpoints' import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core' import type { ExtractVariantNames } from './variants' // these props are treated differently to nest breakpoints and media queries type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset' | 'boxShadow' | 'filter' export type UnistyleView = Omit export type UnistyleText = Omit export type UnistyleImage = Omit type UnistyleNestedStyles = { shadowOffset?: ToDeepUnistyles, textShadowOffset?: ToDeepUnistyles, transform?: Array>, boxShadow?: Array> | string, filter?: Array> | string } type VariantsObject = { [variantName: string]: { [variant: string]: Omit } } type CustomClassName = { _classNames?: string | Array } type CompoundVariant = { styles: Omit } type VariantsAndCompoundVariants = { variants?: VariantsObject, compoundVariants?: Array } export type ToDeepUnistyles = { [K in keyof T]?: T[K] | { [key in BreakpointsOrMediaQueries]?: T[K] } } type AllAvailableStyles = UnistyleView & UnistyleText & UnistyleImage & UnistyleNestedStyles export type AllAvailableKeys = keyof (UnistyleView & UnistyleText & UnistyleImage) export type BreakpointsOrMediaQueries = keyof UnistylesBreakpoints | symbol type FlatUnistylesValues = { [propName in AllAvailableKeys]?: AllAvailableStyles[propName] | { [key in BreakpointsOrMediaQueries]?: AllAvailableStyles[propName] } } export type UnistylesValues = FlatUnistylesValues & { } & VariantsAndCompoundVariants & { [propName in NestedKeys]?: UnistyleNestedStyles[propName] } & { _web?: ToDeepUnistyles & CustomClassName & { [propName in Pseudo]?: ToDeepUnistyles } } export type StyleSheet = { [styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues) } export type StyleSheetWithSuperPowers = | ((theme: UnistylesTheme, miniRuntime: UnistylesMiniRuntime) => S) | S type UseVariantsFn = { useVariants: (variants: ExtractVariantNames) => void } const create = (stylesheet: StyleSheetWithSuperPowers): (ReactNativeStyleSheet & UseVariantsFn) => stylesheet as (ReactNativeStyleSheet & UseVariantsFn) export type CreateUnistylesStyleSheet = typeof create