UNPKG

@exadel/esl

Version:

Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components

38 lines (37 loc) 1.98 kB
/** * CSS class manipulation utilities. * * Allows manipulating with CSS classes with the following set of sub-features: * - JQuery-like enumeration - you can pass multiple tokens separated by space * - safe checks - empty or falsy token sting will be ignored without throwing an error * - inversion syntax - tokens that start from '!' will be processed with inverted action * (e.g. addCls(el, '!class') - will remove 'class' from the element, while removeCls(el, '!class') adds 'class' to the element) * - class locks - you can manipulate with classes using `locker` option that takes into account the modification initiator. * That means the class added in 'locker' mode will not be removed until all initiators that requested add class have requested its removal. * */ export declare abstract class CSSClassUtils { /** Splitting passed token string into CSS class names array. */ static splitTokens(tokenString: string | null | undefined): string[]; /** * Add all classes from the class token string to the element. * @see CSSClassUtils * */ static add(els: Element | Element[], cls: string | null | undefined, locker?: Element): void; /** * Remove all classes from the class token string to the element. * @see CSSClassUtils * */ static remove(els: Element | Element[], cls: string | null | undefined, locker?: Element): void; /** * Toggle all classes from the class token string on the element to the passed state. * @see CSSClassUtils * */ static toggle(els: Element | Element[], cls: string | null | undefined, state: boolean, locker?: Element): void; /** * Check if all class from token string matches to the element or elements. * @see CSSClassUtils * */ static has(els: Element | Element[], cls: string): boolean; /** Remove all lockers for the element or passed element className */ static unlock(els: Element | Element[], className?: string): void; }