UNPKG

@universal-material/web

Version:
39 lines 1.31 kB
import { __decorate } from "tslib"; import { LitElement, html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { styles as baseStyles } from '../shared/base.styles.js'; import { styles } from './card-content.styles.js'; let UmCardContent = class UmCardContent extends LitElement { constructor() { super(...arguments); this.hasContent = false; } static { this.styles = [baseStyles, styles]; } render() { return html ` <slot @slotchange="${this.handleSlotChange}"></slot>`; } handleSlotChange(e) { const slot = e.target; this.hasContent = slot.assignedElements({ flatten: true }).length > 0; if (this.hasContent) { return; } const nodes = slot.assignedNodes({ flatten: true }); for (const node of nodes) { if (node.nodeValue?.trim()) { this.hasContent = true; return; } } this.hasContent = false; } }; __decorate([ property({ type: Boolean, attribute: 'has-content', reflect: true }) ], UmCardContent.prototype, "hasContent", void 0); UmCardContent = __decorate([ customElement('u-card-content') ], UmCardContent); export { UmCardContent }; //# sourceMappingURL=card-content.js.map