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 16import {BaseElement, element} from "../BaseElement.js"; 17import {LitCheckBox} from "./LitCheckBox.js"; 18 19@element('lit-check-group') 20export class LitCheckGroup extends BaseElement { 21 22 get direction() { 23 return this.getAttribute("direction") 24 } 25 26 get value(): Array<string> { 27 let values = [] 28 for (const litCheckBoxElement of this.querySelectorAll<LitCheckBox>('lit-check-box[checked]')) { 29 values.push(litCheckBoxElement.value) 30 } 31 return values; 32 } 33 34 initElements(): void { 35 } 36 37 initHtml(): string { 38 return ` 39 <style> 40 :host { 41 display: -webkit-flex; 42 display: flex; 43 flex-direction: column; 44 } 45 :host([direction]) { 46 flex-direction: ${this.direction}; 47 } 48 :host(:not([direction])) { 49 flex-direction: column; 50 } 51 52 :host([layout="compact"]) { 53 gap:5px; 54 } 55 :host([layout="dispersion"]) { 56 gap:10px; 57 } 58 59 </style> 60 <slot class="check-group"></slot>`; 61 } 62}