1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17import {element} from "../BaseElement.js"; 18 19@element('lit-table-column') 20export class LitTableColumn extends HTMLElement { 21 template: Element | undefined | null 22 private st: HTMLSlotElement | undefined | null 23 24 constructor() { 25 super(); 26 const shadowRoot = this.attachShadow({mode: 'open'}); 27 shadowRoot.innerHTML = ` 28 <style> 29 :host{ 30 overflow: auto; 31 width: 100%; 32 } 33 </style> 34 <slot id="slot"></slot> 35 ` 36 } 37 38 static get observedAttributes() { 39 return ['name', 'order'] 40 } 41 42 connectedCallback() { 43 this.template = null; 44 this.st = this.shadowRoot?.querySelector('#slot') 45 this.st?.addEventListener('slotchange', () => { 46 const elements = this.st!.assignedElements({flatten: false}); 47 if (elements!.length > 0) { 48 this.template = elements[0]; 49 } 50 }) 51 } 52 53 disconnectedCallback() { 54 55 } 56 57 adoptedCallback() { 58 } 59 60 attributeChangedCallback(name: string, oldValue: string, newValue: string) { 61 } 62 63}