John Cowen 25f3ebd66a
ui: CustomElement component (#12451)
Builds on attach-shadow, adopt-styles and ShadowTemplate, this commit adds ShadowHost and finally CustomElement.

CustomElement is a renderless component to help with the creation of native HTML Custom Elements along with runtime type checking and self-documentation for attributes, slots, cssprops and cssparts. As you will probably see there is a little more work to come here. But in the same breath, everything would be fine to go in as is.
2022-03-07 09:51:47 +00:00

17 lines
579 B
JavaScript

import { helper } from '@ember/component/helper';
import { CSSResult } from '@lit/reactive-element';
/**
* Conditionally maps cssInfos to an array ready for ShadowDom::styles
* usage.
*
* @typedef {([CSSResult, boolean] | [CSSResult])} cssInfo
* @param {(cssInfo | string)[]} entries - An array of 'entry-like' arrays of `cssInfo`s to map
*/
const cssMap = entries => {
return entries
.filter(entry => (entry instanceof CSSResult ? true : entry[entry.length - 1]))
.map(entry => (entry instanceof CSSResult ? entry : entry[0]))
};
export default helper(cssMap);