1fb726d48Sopenharmony_ci/* 2fb726d48Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3fb726d48Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fb726d48Sopenharmony_ci * you may not use this file except in compliance with the License. 5fb726d48Sopenharmony_ci * You may obtain a copy of the License at 6fb726d48Sopenharmony_ci * 7fb726d48Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fb726d48Sopenharmony_ci * 9fb726d48Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fb726d48Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fb726d48Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fb726d48Sopenharmony_ci * See the License for the specific language governing permissions and 13fb726d48Sopenharmony_ci * limitations under the License. 14fb726d48Sopenharmony_ci */ 15fb726d48Sopenharmony_ci 16fb726d48Sopenharmony_ciimport { BaseElement, element } from '../BaseElement'; 17fb726d48Sopenharmony_ciimport { LitTabs } from './lit-tabs'; 18fb726d48Sopenharmony_ci 19fb726d48Sopenharmony_ci@element('lit-tabpane') 20fb726d48Sopenharmony_ciexport class LitTabpane extends BaseElement { 21fb726d48Sopenharmony_ci static get observedAttributes(): string[] { 22fb726d48Sopenharmony_ci return ['tab', 'key', 'disabled', 'icon', 'closeable', 'hidden']; 23fb726d48Sopenharmony_ci } 24fb726d48Sopenharmony_ci 25fb726d48Sopenharmony_ci get tab(): string | null { 26fb726d48Sopenharmony_ci return this.getAttribute('tab'); 27fb726d48Sopenharmony_ci } 28fb726d48Sopenharmony_ci 29fb726d48Sopenharmony_ci set tab(value) { 30fb726d48Sopenharmony_ci this.setAttribute('tab', value || ''); 31fb726d48Sopenharmony_ci } 32fb726d48Sopenharmony_ci 33fb726d48Sopenharmony_ci get icon(): string | null { 34fb726d48Sopenharmony_ci return this.getAttribute('icon'); 35fb726d48Sopenharmony_ci } 36fb726d48Sopenharmony_ci 37fb726d48Sopenharmony_ci get disabled(): boolean { 38fb726d48Sopenharmony_ci return this.getAttribute('disabled') !== null; 39fb726d48Sopenharmony_ci } 40fb726d48Sopenharmony_ci 41fb726d48Sopenharmony_ci set disabled(value) { 42fb726d48Sopenharmony_ci if (value === null || value === false) { 43fb726d48Sopenharmony_ci this.removeAttribute('disabled'); 44fb726d48Sopenharmony_ci } else { 45fb726d48Sopenharmony_ci this.setAttribute('disabled', value + ''); 46fb726d48Sopenharmony_ci } 47fb726d48Sopenharmony_ci } 48fb726d48Sopenharmony_ci 49fb726d48Sopenharmony_ci get hidden(): boolean { 50fb726d48Sopenharmony_ci return this.getAttribute('hidden') !== null; 51fb726d48Sopenharmony_ci } 52fb726d48Sopenharmony_ci 53fb726d48Sopenharmony_ci set hidden(value) { 54fb726d48Sopenharmony_ci this.setAttribute('hidden', `${value}`); 55fb726d48Sopenharmony_ci } 56fb726d48Sopenharmony_ci 57fb726d48Sopenharmony_ci get closeable(): boolean { 58fb726d48Sopenharmony_ci return this.getAttribute('closeable') !== null; 59fb726d48Sopenharmony_ci } 60fb726d48Sopenharmony_ci 61fb726d48Sopenharmony_ci set closeable(value) { 62fb726d48Sopenharmony_ci if (value === null || value === false) { 63fb726d48Sopenharmony_ci this.removeAttribute('closeable'); 64fb726d48Sopenharmony_ci } else { 65fb726d48Sopenharmony_ci this.setAttribute('closeable', value + ''); 66fb726d48Sopenharmony_ci } 67fb726d48Sopenharmony_ci } 68fb726d48Sopenharmony_ci 69fb726d48Sopenharmony_ci get key(): string { 70fb726d48Sopenharmony_ci return this.getAttribute('key') || ''; 71fb726d48Sopenharmony_ci } 72fb726d48Sopenharmony_ci 73fb726d48Sopenharmony_ci set key(value) { 74fb726d48Sopenharmony_ci this.setAttribute('key', value); 75fb726d48Sopenharmony_ci } 76fb726d48Sopenharmony_ci 77fb726d48Sopenharmony_ci initElements(): void {} 78fb726d48Sopenharmony_ci 79fb726d48Sopenharmony_ci initHtml(): string { 80fb726d48Sopenharmony_ci return ` 81fb726d48Sopenharmony_ci <style> 82fb726d48Sopenharmony_ci :host(){ 83fb726d48Sopenharmony_ci scroll-behavior: smooth; 84fb726d48Sopenharmony_ci -webkit-overflow-scrolling: touch; 85fb726d48Sopenharmony_ci overflow: auto; 86fb726d48Sopenharmony_ci width: 100%; 87fb726d48Sopenharmony_ci } 88fb726d48Sopenharmony_ci </style> 89fb726d48Sopenharmony_ci <slot></slot> 90fb726d48Sopenharmony_ci `; 91fb726d48Sopenharmony_ci } 92fb726d48Sopenharmony_ci 93fb726d48Sopenharmony_ci connectedCallback(): void {} 94fb726d48Sopenharmony_ci 95fb726d48Sopenharmony_ci disconnectedCallback(): void {} 96fb726d48Sopenharmony_ci 97fb726d48Sopenharmony_ci adoptedCallback(): void {} 98fb726d48Sopenharmony_ci 99fb726d48Sopenharmony_ci attributeChangedCallback(name: string, oldValue: string, newValue: string): void { 100fb726d48Sopenharmony_ci if (oldValue !== newValue && newValue !== undefined) { 101fb726d48Sopenharmony_ci if (name === 'tab' && this.parentNode && this.parentNode instanceof LitTabs) { 102fb726d48Sopenharmony_ci this.parentNode.updateLabel && this.parentNode.updateLabel(this.key, newValue); 103fb726d48Sopenharmony_ci } 104fb726d48Sopenharmony_ci if (name === 'disabled' && this.parentNode && this.parentNode instanceof LitTabs) { 105fb726d48Sopenharmony_ci this.parentNode.updateDisabled && this.parentNode.updateDisabled(this.key, newValue); 106fb726d48Sopenharmony_ci } 107fb726d48Sopenharmony_ci if (name === 'closeable' && this.parentNode && this.parentNode instanceof LitTabs) { 108fb726d48Sopenharmony_ci this.parentNode.updateCloseable && this.parentNode.updateCloseable(this.key, newValue); 109fb726d48Sopenharmony_ci } 110fb726d48Sopenharmony_ci if (name === 'hidden' && this.parentNode && this.parentNode instanceof LitTabs) { 111fb726d48Sopenharmony_ci this.parentNode.updateHidden && this.parentNode.updateHidden(this.key, newValue); 112fb726d48Sopenharmony_ci } 113fb726d48Sopenharmony_ci } 114fb726d48Sopenharmony_ci } 115fb726d48Sopenharmony_ci} 116