UNPKG

@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.

89 lines (75 loc) 3.15 kB
import { S as Store, a as StoreState, b as StoreActions, c as StoreMember } from './store-fbNplHct.js'; import 'solid-js/store'; import 'solid-js'; import './directives-DK-Zzqy-.js'; /** * Creates a selector for a handler */ declare const buildHandlerSelector: (namespace: string, specifier: string, action: string) => string; /** * Recursively collects attributes from an element and its children * with flexible filtering options */ declare const deepCollectAttributes: (element: Element, attributePrefixes: string[], ignoreSelf?: true) => Attr[]; /** * Evaluates a path value from an object or array */ declare const evaluatePathValue: (value: Record<string, unknown> | Array<unknown>, path: string) => unknown; /** * Returns the inferred type of the given value */ declare const inferValueType: (value: unknown) => "object" | "string" | "null" | "undefined" | "array" | "boolean" | "number" | "unknown"; /** * Stringifies the given state value so it can be re-attached to an attribute * - if the value is an object, use the bind attribute value to select the correct key's value and stringify that * - if the value is an array, use the bind attribute value to select the correct index's value and stringify that */ declare const stringifyState: (value: unknown) => string; /** * Parses a state attribute value and returns an inferred type */ declare const parseStateString: (value: string | null) => any; /** * Prepends the attribute prefix to the given attribute */ declare const buildAttribute: (attribute: string) => string; /** * Infers a member values type and splits it into its segments. * * - data-bind--aria-label="scope:$state-member" * - data-handler--event.click="scope:@action-member" * - data-effect="scope:effect" */ declare const inferMemberValue: (memberValue: string) => { type: "action" | "state" | "basic"; scope: string; key: string; } | null; /** * Find store member (state or action) based on the member value * Expects format "scope:@action" or "scope:$state" */ declare const findStoreMember: (memberValue: string, store?: Store<StoreState, StoreActions>) => StoreMember | null; /** * Resolves the store memeber. * If its an action, it calls it and returns the result. * If its state, it calls it and returns the result. * * If the member.key is state and referencing an object or array value, resolve that as well. * * If the raw param is true, it wont evaluate the value based on the members key path */ declare const resolveMember: (member: StoreMember, raw?: boolean) => Promise<unknown>; /** * Extracts the base key from a value that may contain dot or bracket notation * e.g., "state.path[0]" -> "state" */ declare const extractBaseStateKey: <R extends string>(value: string) => R; /** * Logging object */ declare const _default: { debug: (msg: string, force?: boolean) => void; warn: (msg: string) => void; }; export { buildAttribute, buildHandlerSelector, deepCollectAttributes, evaluatePathValue, extractBaseStateKey, findStoreMember, inferMemberValue, inferValueType, _default as log, parseStateString, resolveMember, stringifyState };