diff --git a/package.json b/package.json index 90e2a31..eb6e572 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pistonite/celera", - "version": "0.1.3", + "version": "0.1.4", "type": "module", "private": true, "description": "In-house UI framework", diff --git a/src/index.ts b/src/index.ts index 9d25a54..97ff270 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,17 @@ export { type DisplayModeOptions, } from "#pref"; -export { gale, GALE_BUILTIN_STYLES, injectStyle, ThemeProvider } from "#style"; +export { + gale, + GALE_BUILTIN_STYLES, + injectStyle, + ThemeProvider, + type GaleEngine, + type GaleKeys, + type GaleHook, + type GaleFn, + type GaleString, +} from "#style"; import { log } from "#util"; export { log as celeraLogger }; diff --git a/src/style/gale.ts b/src/style/gale.ts index 2063eaf..0f32658 100644 --- a/src/style/gale.ts +++ b/src/style/gale.ts @@ -170,14 +170,25 @@ export const gale = ( return Object.assign(useStyleEngine, { extend: makeComponentLevelStyleEngine }); }; -type GaleKeys = T | GaleBuiltinKey; -interface GaleEngine extends GaleHook { +/** + * Engine function created by {@link gale} + * + * Can either be used as a hook to get the `m` function, or use `.extend()` + * to extend the styles for component-specific hook. + */ +export interface GaleEngine extends GaleHook { + /** Extend the styles to get a component-specific hook */ extend: (componentStyles: Record) => GaleHook; } -type GaleHook = () => GaleFn; -type GaleFn = (classes: GaleString) => string; +/** Wrapper to concatenate built-in style keys with project-specific style keys */ +export type GaleKeys = T | GaleBuiltinKey; +/** Hook to be called inside a component to get the `m` function. See {@link gale} */ +export type GaleHook = () => GaleFn; +/** The `m` function that turns a style string into class names */ +export type GaleFn = (classes: GaleString) => string; -type GaleString = K extends T +/** Type-safe, space-separated style idents */ +export type GaleString = K extends T ? K : K extends `${infer U} ${infer N}` ? U extends T