Compare commits

...

2 Commits

Author SHA1 Message Date
9301aed3e3 Add ForgeComponent type and define overloads 2026-04-08 14:44:27 -07:00
dcf4f1062b 0.0.9 2026-04-07 22:37:36 -07:00
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@because/forge",
"version": "0.0.8",
"version": "0.0.9",
"type": "module",
"main": "src/index.tsx",
"module": "src/index.tsx",

View File

@ -1,5 +1,9 @@
import { type TagDef, type HTMLTag, UnitlessProps, NonStyleKeys } from './types'
type ForgeComponent<Parts = {}> =
((props: Record<string, any>) => any) &
{ [K in keyof Parts]: (props: Record<string, any>) => any }
export const styles: Record<string, Record<string, string>> = {}
const themes: Record<string, Record<string, any>> = {}
@ -288,6 +292,8 @@ export function createScope(scope: string) {
}
// the main event
export function define<const T extends TagDef>(name: string, def: T): ForgeComponent<T['parts']>
export function define<const T extends TagDef>(def: T): ForgeComponent<T['parts']>
export function define(nameOrDef: string | TagDef, defIfNamed?: TagDef) {
const def = defIfNamed ?? nameOrDef as TagDef
const name = defIfNamed ? (nameOrDef as string) : anonName(def)