UNPKG

2 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2018 Google LLC
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6import { AttributePart, noChange } from '../lit-html.js';
7import { Directive, DirectiveParameters, PartInfo } from '../directive.js';
8/**
9 * A key-value set of CSS properties and values.
10 *
11 * The key should be either a valid CSS property name string, like
12 * `'background-color'`, or a valid JavaScript camel case property name
13 * for CSSStyleDeclaration like `backgroundColor`.
14 */
15export interface StyleInfo {
16 readonly [name: string]: string | undefined | null;
17}
18declare class StyleMapDirective extends Directive {
19 _previousStyleProperties?: Set<string>;
20 constructor(partInfo: PartInfo);
21 render(styleInfo: StyleInfo): string;
22 update(part: AttributePart, [styleInfo]: DirectiveParameters<this>): string | typeof noChange;
23}
24/**
25 * A directive that applies CSS properties to an element.
26 *
27 * `styleMap` can only be used in the `style` attribute and must be the only
28 * expression in the attribute. It takes the property names in the `styleInfo`
29 * object and adds the property values as CSS properties. Property names with
30 * dashes (`-`) are assumed to be valid CSS property names and set on the
31 * element's style object using `setProperty()`. Names without dashes are
32 * assumed to be camelCased JavaScript property names and set on the element's
33 * style object using property assignment, allowing the style object to
34 * translate JavaScript-style names to CSS property names.
35 *
36 * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':
37 * '0'})` sets the `background-color`, `border-top` and `--size` properties.
38 *
39 * @param styleInfo
40 */
41export declare const styleMap: (styleInfo: StyleInfo) => import("../directive.js").DirectiveResult<typeof StyleMapDirective>;
42/**
43 * The type of the class that powers this directive. Necessary for naming the
44 * directive's return type.
45 */
46export type { StyleMapDirective };
47//# sourceMappingURL=style-map.d.ts.map
\No newline at end of file