@lucidclient/elements
Version:
A lightweight, reactive UI library that bridges HTML and JavaScript through attributes, powered by SolidJS. Adds reactive state and dynamic behaviors to markup while maintaining simplicity.
73 lines (70 loc) • 2.19 kB
text/typescript
import { SetStoreFunction } from 'solid-js/store';
import { Signal } from 'solid-js';
import { e as StateDirectives, E as EffectDirectives, L as LoopDirectives, i as BindStateDirectives } from './directives-DK-Zzqy-.cjs';
type DirectiveMap = {
scope: string;
state: StateDirectives;
effects: EffectDirectives;
loops: LoopDirectives;
bindState: BindStateDirectives;
bindActions: BindStateDirectives;
};
type StoreDirectives = Map<string, DirectiveMap>;
type Refs = Map<string, Element | Element[]>;
type StoreState = Record<string, unknown>;
type Action = (...args: any[]) => unknown;
type StoreActions = Record<string, Action>;
type Effect = (context: {
isInitial: boolean;
}) => void;
type StoreEffects = Record<string, Effect>;
type StoreData<S extends StoreState, A extends StoreActions> = {
key: string;
initialised: boolean;
dispose: () => void;
stateObserver?: MutationObserver;
state: {
[K in keyof S]: Signal<S[K]>;
};
stateRegisteredEffects: Set<string>;
effectsRegistered: Set<string>;
actions: A;
effects: {
global: StoreEffects;
manual: StoreEffects;
};
refs: Refs;
cleanup?: () => void;
};
type Store<S extends StoreState, A extends StoreActions> = [
get: StoreData<S, A>,
set: SetStoreFunction<StoreData<S, A>>
];
type StoreInterface<S extends StoreState, A extends StoreActions> = {
state: {
[K in keyof S]: Signal<S[K]>;
};
actions: A;
refs: Refs;
};
type StoreModule<S extends StoreState, A extends StoreActions> = (store: StoreInterface<S, A>) => {
state?: Partial<{
[K in keyof S]: Signal<S[K]>;
}>;
actions: A;
effects?: {
global?: StoreEffects;
manual?: StoreEffects;
};
cleanup?: () => void;
};
type StoreMember = {
type: "action";
key: string;
member: Action;
} | {
type: "state";
key: string;
member: Signal<unknown>;
};
export type { Action as A, DirectiveMap as D, Effect as E, Refs as R, Store as S, StoreState as a, StoreActions as b, StoreMember as c, StoreModule as d, StoreDirectives as e, StoreEffects as f, StoreData as g, StoreInterface as h };