/** * Dynamic class binding directive. * * @packageDocumentation */ import { Directive } from '../types.js'; /** * Bind classes dynamically based on an expression. * * @remarks * Supported value shapes: * * - **String** `'a b'` — unconditional adds. The named classes are * added. These entries are never removed on re-evaluation. * - **Object** `{ name: boolean }` — toggled entries. Each key is * added when its value is truthy and removed when falsy. Re-runs * update every listed key based on the fresh condition. * - **Array** — a mix of the above. Each item is handled according * to its own shape, so `[$styles.root, { [$styles.open]: isOpen }]` * keeps `root` stamped and toggles `open`. * * Static classes from the HTML and classes managed by other * directives are untouched — the effect only adds or removes names * it was told about by the current expression. * * @example * ```html *