UNPKG

@medyll/idae-be

Version:

A modern, lightweight, and extensible DOM manipulation library built with TypeScript. Designed for precise element targeting and manipulation using a callback-based approach. Features include advanced DOM traversal, event handling, style management, attri

59 lines (58 loc) 2.26 kB
import { Be } from '../be.js'; import type { CommonHandler } from '../types.js'; declare enum beStyleMethods { set = "set", get = "get", unset = "unset" } export interface BeStylesHandler { set?: Record<string, string> | string; get?: string; unset?: string; } export type BeStylesHandlerMethods = keyof typeof beStyleMethods; export declare class StylesHandler implements CommonHandler<StylesHandler, Partial<BeStylesHandler>> { private beElement; constructor(beElement: Be); methods: string[]; valueOf(): string; static methods: beStyleMethods[]; handle(actions: Partial<BeStylesHandler>): Be; private resolveIndirection; /** * Sets one or more CSS styles for the selected element(s), including CSS custom properties. * @param styles - An object of CSS properties and values, or a string of CSS properties and values. * @param value - The value for a single CSS property when styles is a property name string. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test"></div> * const beInstance = be('#test'); * beInstance.setStyle({ color: 'red', backgroundColor: 'blue' }); // Sets multiple styles * beInstance.setStyle('color', 'green'); // Sets a single style */ set(styles: Record<string, string> | string, value?: string): Be; /** * Gets the value of a CSS property for the first matched element. * @param key - The CSS property name. * @returns The value of the CSS property, or null if not found. * @example * // HTML: <div id="test" style="color: red;"></div> * const beInstance = be('#test'); * const color = beInstance.getStyle('color'); * console.log(color); // Output: "red" */ get(key: string): string | null; /** * Removes a CSS property from the selected element(s). * @param key - The CSS property name to remove. * @returns The Be instance for method chaining. * @example * // HTML: <div id="test" style="color: red;"></div> * const beInstance = be('#test'); * beInstance.unsetStyle('color'); // Removes the "color" style */ unset(key: string): Be; private applyStyle; private getKey; } export {};