0.0.3: Exotic Type Gymnastics #3

Merged
Astrian merged 40 commits from dev into main 2025-05-22 01:17:51 +00:00
3 changed files with 25 additions and 26 deletions
Showing only changes of commit 3b344af52d - Show all commits

View File

@ -1,21 +1,5 @@
import utils from './utils/index'
interface ComponentOptions {
tag: string
template: string
style?: string
onMount?: (this: CustomElement) => void
onUnmount?: () => void
onAttributeChanged?: (
attrName: string,
oldValue: string,
newValue: string,
) => void
states?: Record<string, unknown>
statesListeners?: { [key: string]: (value: unknown) => void }
funcs?: { [key: string]: (...args: unknown[]) => void }
}
export default (options: ComponentOptions) => {
const {
tag,

25
src/types.d.ts vendored
View File

@ -2,3 +2,28 @@ interface CustomElement extends HTMLElement {
setState(key_path: string, value: unknown): void
getState(key_path: string): unknown
}
interface ListRenderingContext {
states: Record<string, unknown>
stateToElementsMap: Record<string, Set<HTMLElement>>
statesListeners: Record<string, (value: unknown) => void>
setState: (keyPath: string, value: unknown) => void
getState: (keyPath: string) => unknown
triggerFunc: (eventName: string, ...args: unknown[]) => void
}
interface ComponentOptions {
tag: string
template: string
style?: string
onMount?: (this: CustomElement) => void
onUnmount?: () => void
onAttributeChanged?: (
attrName: string,
oldValue: string,
newValue: string,
) => void
states?: Record<string, unknown>
statesListeners?: { [key: string]: (value: unknown) => void }
funcs?: { [key: string]: (...args: unknown[]) => void }
}

View File

@ -307,16 +307,6 @@ function setupConditionRendering(
}
}
// Interface for list rendering context
interface ListRenderingContext {
states: Record<string, unknown>
stateToElementsMap: Record<string, Set<HTMLElement>>
statesListeners: Record<string, (value: unknown) => void>
setState: (keyPath: string, value: unknown) => void
getState: (keyPath: string) => unknown
triggerFunc: (eventName: string, ...args: unknown[]) => void
}
// Evaluate expressions using the item context
function evaluateExpressionWithItemContext(
expression: string,