@jsxstyle/react
Advanced tools
Comparing version 0.0.0-canary-20241218033935 to 0.0.0-canary-20241218215034
import { cacheSingleton } from '@jsxstyle/core'; | ||
export type { CSSProperties } from '@jsxstyle/core'; | ||
export type { CSSProperties, JsxstyleComponentStyleProps, } from '@jsxstyle/core'; | ||
export type { StylableComponentProps } from './types.js'; | ||
@@ -7,3 +7,3 @@ export { cacheSingleton as cache }; | ||
export declare const makeCustomProperties: <KPropKeys extends string>(props: Record<KPropKeys, string | number>) => import("@jsxstyle/core").MakeCustomPropertiesFunction<KPropKeys, "default">; | ||
export declare const css: (...params: Array<import("@jsxstyle/core").CSSParams | string | null | undefined | false>) => string; | ||
export declare const css: (...params: Array<import("@jsxstyle/core").JsxstyleComponentStyleProps | string | null | undefined | false>) => string; | ||
export declare const Box: { | ||
@@ -10,0 +10,0 @@ <T extends import("./types.js").ValidComponentPropValue = "div">(props: import("./types.js").JsxstyleProps<T>): React.ReactElement; |
@@ -1,4 +0,4 @@ | ||
import type { CSSProperties, CommonComponentProp } from '@jsxstyle/core'; | ||
import type { JsxstyleComponentStyleProps, CommonComponentProp, EventHandlerKeys } from '@jsxstyle/core'; | ||
export type IntrinsicElement = keyof JSX.IntrinsicElements; | ||
export type ValidComponentPropValue = false | null | undefined | IntrinsicElement | React.FunctionComponent<any> | React.ComponentClass<any>; | ||
export type ValidComponentPropValue = IntrinsicElement | React.FunctionComponent<any> | React.ComponentClass<any>; | ||
/** | ||
@@ -8,24 +8,12 @@ * Generic that returns either the extracted props type for a React component | ||
*/ | ||
export type ExtractProps<T extends ValidComponentPropValue> = T extends false | null | undefined ? JSX.IntrinsicElements['div'] : T extends IntrinsicElement ? JSX.IntrinsicElements[T] : T extends React.FunctionComponent<infer FCProps> ? keyof FCProps extends never ? Record<string, unknown> : FCProps : T extends React.ComponentClass<infer ClassProps> ? keyof ClassProps extends never ? Record<string, unknown> : ClassProps : Record<string, unknown>; | ||
type UpperCaseLetter = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'; | ||
/** Union of patterns that match event handler names. */ | ||
type EventHandlerKeys = `on${UpperCaseLetter}${string}`; | ||
export type ExtractProps<T extends ValidComponentPropValue> = T extends IntrinsicElement ? JSX.IntrinsicElements[T] : T extends React.FunctionComponent<infer FCProps> ? keyof FCProps extends never ? never : FCProps : T extends React.ComponentClass<infer ClassProps> ? keyof ClassProps extends never ? never : ClassProps : never; | ||
/** Props that will be passed through to whatever component is specified */ | ||
export type StylableComponentProps<T extends ValidComponentPropValue> = Pick<ExtractProps<T>, Extract<keyof ExtractProps<T>, CommonComponentProp | EventHandlerKeys>>; | ||
/** Props for jsxstyle components that have a `component` prop set */ | ||
interface JsxstylePropsWithComponent<C extends ValidComponentPropValue> { | ||
/** Props for jsxstyle components */ | ||
export type JsxstyleProps<T extends ValidComponentPropValue = 'div'> = { | ||
/** Component value can be either a React component or a tag name string. Defaults to `div`. */ | ||
component: C; | ||
component?: T | false | null; | ||
/** Object of props that will be passed down to the component specified in the `component` prop */ | ||
props?: ExtractProps<C>; | ||
} | ||
/** Props for jsxstyle components that have no `component` prop set */ | ||
interface JsxstyleDefaultProps { | ||
/** Component value can be either a React component or a tag name string. Defaults to `div`. */ | ||
component?: undefined; | ||
/** Object of props that will be passed down to the underlying div */ | ||
props?: JSX.IntrinsicElements['div']; | ||
} | ||
export type JsxstyleProps<T extends ValidComponentPropValue = 'div'> = (JsxstyleDefaultProps | JsxstylePropsWithComponent<T>) & StylableComponentProps<T> & CSSProperties; | ||
export {}; | ||
props?: ExtractProps<T>; | ||
} & StylableComponentProps<T> & JsxstyleComponentStyleProps; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@jsxstyle/react", | ||
"version": "0.0.0-canary-20241218033935", | ||
"version": "0.0.0-canary-20241218215034", | ||
"type": "module", | ||
@@ -12,5 +12,6 @@ "files": [ | ||
"peerDependencies": { | ||
"@jsxstyle/core": "0.0.0-canary-20241218033935", | ||
"@types/react": "^18.0.0" | ||
"@jsxstyle/core": "0.0.0-canary-20241218215034", | ||
"@types/react": "^18.0.0 || ^19.0.0", | ||
"react": "^18.0.0 || ^19.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13279
3
134