UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

7 lines 1.08 kB
import{noChange as e}from"../lit-html.js";import{Directive as t,PartType as n,directive as r}from"../directive.js"; /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause */const i=r(class extends t{constructor(e){if(super(e),e.type!==n.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`}),``)}update(t,[n]){let{style:r}=t.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(n)),this.render(n);for(let e of this.ft)n[e]??(this.ft.delete(e),e.includes(`-`)?r.removeProperty(e):r[e]=null);for(let e in n){let t=n[e];if(t!=null){this.ft.add(e);let n=typeof t==`string`&&t.endsWith(` !important`);e.includes(`-`)||n?r.setProperty(e,n?t.slice(0,-11):t,n?`important`:``):r[e]=t}}return e}});export{i as styleMap}; //# sourceMappingURL=style-map.js.map