class-map.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @license
  3. * Copyright 2018 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { AttributePart, noChange } from '../lit-html.js';
  7. import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
  8. /**
  9. * A key-value set of class names to truthy values.
  10. */
  11. export interface ClassInfo {
  12. readonly [name: string]: string | boolean | number;
  13. }
  14. declare class ClassMapDirective extends Directive {
  15. /**
  16. * Stores the ClassInfo object applied to a given AttributePart.
  17. * Used to unset existing values when a new ClassInfo object is applied.
  18. */
  19. private _previousClasses?;
  20. private _staticClasses?;
  21. constructor(partInfo: PartInfo);
  22. render(classInfo: ClassInfo): string;
  23. update(part: AttributePart, [classInfo]: DirectiveParameters<this>): string | typeof noChange;
  24. }
  25. /**
  26. * A directive that applies dynamic CSS classes.
  27. *
  28. * This must be used in the `class` attribute and must be the only part used in
  29. * the attribute. It takes each property in the `classInfo` argument and adds
  30. * the property name to the element's `classList` if the property value is
  31. * truthy; if the property value is falsey, the property name is removed from
  32. * the element's `class`.
  33. *
  34. * For example `{foo: bar}` applies the class `foo` if the value of `bar` is
  35. * truthy.
  36. *
  37. * @param classInfo
  38. */
  39. export declare const classMap: (classInfo: ClassInfo) => import("../directive.js").DirectiveResult<typeof ClassMapDirective>;
  40. /**
  41. * The type of the class that powers this directive. Necessary for naming the
  42. * directive's return type.
  43. */
  44. export type { ClassMapDirective };
  45. //# sourceMappingURL=class-map.d.ts.map