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 { LitPopContent } from './LitPopContent'; 18fb726d48Sopenharmony_ciimport { LitPopoverTitle } from './LitPopoverTitle'; 19fb726d48Sopenharmony_ciimport { LitRadioGroup } from '../radiobox/LitRadioGroup'; 20fb726d48Sopenharmony_ciimport { LitRadioBox } from '../radiobox/LitRadioBox'; 21fb726d48Sopenharmony_ciimport { LitCheckBox } from '../checkbox/LitCheckBox'; 22fb726d48Sopenharmony_ciimport { LitCheckGroup } from '../checkbox/LitCheckGroup'; 23fb726d48Sopenharmony_ciimport { LitCheckBoxWithText } from '../checkbox/LitCheckBoxWithText'; 24fb726d48Sopenharmony_ci 25fb726d48Sopenharmony_ciconst initHtmlStyle = ` 26fb726d48Sopenharmony_ci <style> 27fb726d48Sopenharmony_ci :host { 28fb726d48Sopenharmony_ci display:inline-block; 29fb726d48Sopenharmony_ci position:relative; 30fb726d48Sopenharmony_ci overflow:visible; 31fb726d48Sopenharmony_ci } 32fb726d48Sopenharmony_ci :host([direction="top"]) ::slotted(lit-pop-content){ 33fb726d48Sopenharmony_ci bottom:100%; 34fb726d48Sopenharmony_ci left:50%; 35fb726d48Sopenharmony_ci transform:translate(-50%,-10px) scale(0); 36fb726d48Sopenharmony_ci transform-origin: center bottom; 37fb726d48Sopenharmony_ci } 38fb726d48Sopenharmony_ci :host([direction="top"]) ::slotted(lit-pop-content)::after{ 39fb726d48Sopenharmony_ci content: ''; 40fb726d48Sopenharmony_ci position: absolute; 41fb726d48Sopenharmony_ci top: 100%; 42fb726d48Sopenharmony_ci left: 50%; 43fb726d48Sopenharmony_ci border-top: 10px solid #FFF; 44fb726d48Sopenharmony_ci border-right: 10px solid transparent; 45fb726d48Sopenharmony_ci border-left: 10px solid transparent; 46fb726d48Sopenharmony_ci 47fb726d48Sopenharmony_ci } 48fb726d48Sopenharmony_ci :host([direction="top"]) ::slotted(lit-pop-content[open]), 49fb726d48Sopenharmony_ci :host([direction="top"][trigger="hover"]:hover) ::slotted(lit-pop-content), 50fb726d48Sopenharmony_ci :host([direction="top"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 51fb726d48Sopenharmony_ci transform:translate(-50%,-10px) scale(1); 52fb726d48Sopenharmony_ci } 53fb726d48Sopenharmony_ci 54fb726d48Sopenharmony_ci :host([direction="bottom"]) ::slotted(lit-pop-content){ 55fb726d48Sopenharmony_ci top:100%; 56fb726d48Sopenharmony_ci left:50%; 57fb726d48Sopenharmony_ci transform:translate(-50%,10px) scale(0); 58fb726d48Sopenharmony_ci transform-origin: center top; 59fb726d48Sopenharmony_ci } 60fb726d48Sopenharmony_ci :host([direction="bottom"]) ::slotted(lit-pop-content)::after{ 61fb726d48Sopenharmony_ci content: ''; 62fb726d48Sopenharmony_ci position: absolute; 63fb726d48Sopenharmony_ci bottom: 100%; 64fb726d48Sopenharmony_ci left: 50%; 65fb726d48Sopenharmony_ci border-bottom: 10px solid #FFF; 66fb726d48Sopenharmony_ci border-right: 10px solid transparent; 67fb726d48Sopenharmony_ci border-left: 10px solid transparent; 68fb726d48Sopenharmony_ci } 69fb726d48Sopenharmony_ci :host([direction="bottom"]) ::slotted(lit-pop-content[open]), 70fb726d48Sopenharmony_ci :host([direction="bottom"][trigger="hover"]:hover) ::slotted(lit-pop-content), 71fb726d48Sopenharmony_ci :host([direction="bottom"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 72fb726d48Sopenharmony_ci transform:translate(-50%,10px) scale(1); 73fb726d48Sopenharmony_ci } 74fb726d48Sopenharmony_ci 75fb726d48Sopenharmony_ci 76fb726d48Sopenharmony_ci :host([direction="left"]) ::slotted(lit-pop-content){ 77fb726d48Sopenharmony_ci right:100%; 78fb726d48Sopenharmony_ci top:50%; 79fb726d48Sopenharmony_ci transform:translate(-10px,-50%) scale(0); 80fb726d48Sopenharmony_ci transform-origin: right; 81fb726d48Sopenharmony_ci } 82fb726d48Sopenharmony_ci :host([direction="left"]) ::slotted(lit-pop-content)::after{ 83fb726d48Sopenharmony_ci content: ''; 84fb726d48Sopenharmony_ci position: absolute; 85fb726d48Sopenharmony_ci bottom: 40%; 86fb726d48Sopenharmony_ci left: 100%; 87fb726d48Sopenharmony_ci border-left: 10px solid #FFF; 88fb726d48Sopenharmony_ci border-bottom: 10px solid transparent; 89fb726d48Sopenharmony_ci border-top: 10px solid transparent; 90fb726d48Sopenharmony_ci } 91fb726d48Sopenharmony_ci :host([direction="left"]) ::slotted(lit-pop-content[open]), 92fb726d48Sopenharmony_ci :host([direction="left"][trigger="hover"]:hover) ::slotted(lit-pop-content), 93fb726d48Sopenharmony_ci :host([direction="left"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 94fb726d48Sopenharmony_ci transform:translate(-10px,-50%) scale(1); 95fb726d48Sopenharmony_ci } 96fb726d48Sopenharmony_ci :host([direction="right"]) ::slotted(lit-pop-content){ 97fb726d48Sopenharmony_ci left:100%; 98fb726d48Sopenharmony_ci top:50%; 99fb726d48Sopenharmony_ci transform:translate(10px,-50%) scale(0); 100fb726d48Sopenharmony_ci transform-origin: left; 101fb726d48Sopenharmony_ci } 102fb726d48Sopenharmony_ci :host([direction="right"]) ::slotted(lit-pop-content)::after{ 103fb726d48Sopenharmony_ci content: ''; 104fb726d48Sopenharmony_ci position: absolute; 105fb726d48Sopenharmony_ci bottom: 40%; 106fb726d48Sopenharmony_ci right: 100%; 107fb726d48Sopenharmony_ci border-right: 10px solid #FFF; 108fb726d48Sopenharmony_ci border-bottom: 10px solid transparent; 109fb726d48Sopenharmony_ci border-top: 10px solid transparent; 110fb726d48Sopenharmony_ci } 111fb726d48Sopenharmony_ci :host([direction="right"]) ::slotted(lit-pop-content[open]), 112fb726d48Sopenharmony_ci :host([direction="right"][trigger="hover"]:hover) ::slotted(lit-pop-content), 113fb726d48Sopenharmony_ci :host([direction="right"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 114fb726d48Sopenharmony_ci transform:translate(10px,-50%) scale(1); 115fb726d48Sopenharmony_ci } 116fb726d48Sopenharmony_ci 117fb726d48Sopenharmony_ci 118fb726d48Sopenharmony_ci 119fb726d48Sopenharmony_ci :host([direction="leftbottom"]) ::slotted(lit-pop-content){ 120fb726d48Sopenharmony_ci right:100%; 121fb726d48Sopenharmony_ci top:0; 122fb726d48Sopenharmony_ci transform:translate(-10px) scale(0); 123fb726d48Sopenharmony_ci } 124fb726d48Sopenharmony_ci :host([direction="leftbottom"]) ::slotted(lit-pop-content[open]), 125fb726d48Sopenharmony_ci :host([direction="leftbottom"][trigger="hover"]:hover) ::slotted(lit-pop-content), 126fb726d48Sopenharmony_ci :host([direction="leftbottom"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 127fb726d48Sopenharmony_ci transform:translate(-10px) scale(1); 128fb726d48Sopenharmony_ci } 129fb726d48Sopenharmony_ci 130fb726d48Sopenharmony_ci :host([direction="leftbottom"]) ::slotted(lit-pop-content)::after{ 131fb726d48Sopenharmony_ci content: ''; 132fb726d48Sopenharmony_ci position: absolute; 133fb726d48Sopenharmony_ci top: 10%; 134fb726d48Sopenharmony_ci left: 100%; 135fb726d48Sopenharmony_ci border-left: 10px solid #FFF; 136fb726d48Sopenharmony_ci border-bottom: 10px solid transparent; 137fb726d48Sopenharmony_ci } 138fb726d48Sopenharmony_ci 139fb726d48Sopenharmony_ci :host([direction="lefttop"]) ::slotted(lit-pop-content){ 140fb726d48Sopenharmony_ci right:100%; 141fb726d48Sopenharmony_ci bottom:0; 142fb726d48Sopenharmony_ci transform:translate(-10px) scale(0); 143fb726d48Sopenharmony_ci transform-origin: right bottom; 144fb726d48Sopenharmony_ci } 145fb726d48Sopenharmony_ci :host([direction="lefttop"]) ::slotted(lit-pop-content)::after{ 146fb726d48Sopenharmony_ci content: ''; 147fb726d48Sopenharmony_ci position: absolute; 148fb726d48Sopenharmony_ci bottom: 10%; 149fb726d48Sopenharmony_ci left: 100%; 150fb726d48Sopenharmony_ci border-left: 10px solid #FFF; 151fb726d48Sopenharmony_ci border-top: 10px solid transparent; 152fb726d48Sopenharmony_ci } 153fb726d48Sopenharmony_ci :host([direction="lefttop"]) ::slotted(lit-pop-content[open]), 154fb726d48Sopenharmony_ci :host([direction="lefttop"][trigger="hover"]:hover) ::slotted(lit-pop-content), 155fb726d48Sopenharmony_ci :host([direction="lefttop"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 156fb726d48Sopenharmony_ci transform:translate(-10px) scale(1); 157fb726d48Sopenharmony_ci } 158fb726d48Sopenharmony_ci :host([direction="topright"]) ::slotted(lit-pop-content){ 159fb726d48Sopenharmony_ci bottom:100%; 160fb726d48Sopenharmony_ci left:50%; 161fb726d48Sopenharmony_ci transform:translate(0,-10px) scale(0); 162fb726d48Sopenharmony_ci transform-origin: left bottom; 163fb726d48Sopenharmony_ci } 164fb726d48Sopenharmony_ci :host([direction="topright"]) ::slotted(lit-pop-content)::after{ 165fb726d48Sopenharmony_ci content: ''; 166fb726d48Sopenharmony_ci position: absolute; 167fb726d48Sopenharmony_ci top: 100%; 168fb726d48Sopenharmony_ci left: 0%; 169fb726d48Sopenharmony_ci border-top: 10px solid #FFF; 170fb726d48Sopenharmony_ci border-right: 10px solid transparent; 171fb726d48Sopenharmony_ci } 172fb726d48Sopenharmony_ci :host([direction="topright"]) ::slotted(lit-pop-content[open]), 173fb726d48Sopenharmony_ci :host([direction="topright"][trigger="hover"]:hover) ::slotted(lit-pop-content), 174fb726d48Sopenharmony_ci :host([direction="topright"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 175fb726d48Sopenharmony_ci transform:translate(0,-10px) scale(1); 176fb726d48Sopenharmony_ci } 177fb726d48Sopenharmony_ci 178fb726d48Sopenharmony_ci 179fb726d48Sopenharmony_ci :host([direction="topleft"]) ::slotted(lit-pop-content){ 180fb726d48Sopenharmony_ci bottom:100%; 181fb726d48Sopenharmony_ci right:50%; 182fb726d48Sopenharmony_ci transform:translate(0,-10px) scale(0); 183fb726d48Sopenharmony_ci transform-origin: right bottom; 184fb726d48Sopenharmony_ci } 185fb726d48Sopenharmony_ci :host([direction="topleft"]) ::slotted(lit-pop-content)::after{ 186fb726d48Sopenharmony_ci content: ''; 187fb726d48Sopenharmony_ci position: absolute; 188fb726d48Sopenharmony_ci top: 100%; 189fb726d48Sopenharmony_ci right: 0%; 190fb726d48Sopenharmony_ci border-top: 10px solid #FFF; 191fb726d48Sopenharmony_ci border-left: 10px solid transparent; 192fb726d48Sopenharmony_ci } 193fb726d48Sopenharmony_ci :host([direction="topleft"]) ::slotted(lit-pop-content[open]), 194fb726d48Sopenharmony_ci :host([direction="topleft"][trigger="hover"]:hover) ::slotted(lit-pop-content), 195fb726d48Sopenharmony_ci :host([direction="topleft"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 196fb726d48Sopenharmony_ci transform:translate(0,-10px) scale(1); 197fb726d48Sopenharmony_ci } 198fb726d48Sopenharmony_ci 199fb726d48Sopenharmony_ci 200fb726d48Sopenharmony_ci :host([direction="rightbottom"]) ::slotted(lit-pop-content){ 201fb726d48Sopenharmony_ci left:100%; 202fb726d48Sopenharmony_ci top:0; 203fb726d48Sopenharmony_ci transform:translate(10px) scale(0); 204fb726d48Sopenharmony_ci transform-origin: left top; 205fb726d48Sopenharmony_ci } 206fb726d48Sopenharmony_ci :host([direction="rightbottom"]) ::slotted(lit-pop-content)::after{ 207fb726d48Sopenharmony_ci content: ''; 208fb726d48Sopenharmony_ci position: absolute; 209fb726d48Sopenharmony_ci top: 10%; 210fb726d48Sopenharmony_ci right: 100%; 211fb726d48Sopenharmony_ci border-top: 10px solid #FFF; 212fb726d48Sopenharmony_ci border-left: 10px solid transparent; 213fb726d48Sopenharmony_ci } 214fb726d48Sopenharmony_ci :host([direction="rightbottom"]) ::slotted(lit-pop-content[open]), 215fb726d48Sopenharmony_ci :host([direction="rightbottom"][trigger="hover"]:hover) ::slotted(lit-pop-content), 216fb726d48Sopenharmony_ci :host([direction="rightbottom"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 217fb726d48Sopenharmony_ci transform:translate(10px) scale(1); 218fb726d48Sopenharmony_ci } 219fb726d48Sopenharmony_ci :host([direction="righttop"]) ::slotted(lit-pop-content){ 220fb726d48Sopenharmony_ci left:100%; 221fb726d48Sopenharmony_ci bottom:0; 222fb726d48Sopenharmony_ci transform:translate(10px) scale(0); 223fb726d48Sopenharmony_ci transform-origin: left bottom; 224fb726d48Sopenharmony_ci } 225fb726d48Sopenharmony_ci :host([direction="righttop"]) ::slotted(lit-pop-content[open]), 226fb726d48Sopenharmony_ci :host([direction="righttop"][trigger="hover"]:hover) ::slotted(lit-pop-content), 227fb726d48Sopenharmony_ci :host([direction="righttop"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 228fb726d48Sopenharmony_ci transform:translate(10px) scale(1); 229fb726d48Sopenharmony_ci } 230fb726d48Sopenharmony_ci :host([direction="righttop"]) ::slotted(lit-pop-content)::after{ 231fb726d48Sopenharmony_ci content: ''; 232fb726d48Sopenharmony_ci position: absolute; 233fb726d48Sopenharmony_ci bottom: 10%; 234fb726d48Sopenharmony_ci right: 100%; 235fb726d48Sopenharmony_ci border-bottom: 10px solid #FFF; 236fb726d48Sopenharmony_ci border-left: 10px solid transparent; 237fb726d48Sopenharmony_ci } 238fb726d48Sopenharmony_ci 239fb726d48Sopenharmony_ci :host([direction="bottomright"]) ::slotted(lit-pop-content), 240fb726d48Sopenharmony_ci :host(:not([direction])) ::slotted(lit-pop-content){ 241fb726d48Sopenharmony_ci left:0; 242fb726d48Sopenharmony_ci top:100%; 243fb726d48Sopenharmony_ci transform:translate(0,10px) scale(0); 244fb726d48Sopenharmony_ci transform-origin: left top; 245fb726d48Sopenharmony_ci } 246fb726d48Sopenharmony_ci :host([direction="bottomright"]) ::slotted(lit-pop-content)::after, 247fb726d48Sopenharmony_ci :host(:not([direction])) ::slotted(lit-pop-content)::after{ 248fb726d48Sopenharmony_ci content: ''; 249fb726d48Sopenharmony_ci position: absolute; 250fb726d48Sopenharmony_ci left: 10%; 251fb726d48Sopenharmony_ci bottom: 100%; 252fb726d48Sopenharmony_ci border-bottom: 10px solid #FFF; 253fb726d48Sopenharmony_ci border-right: 10px solid transparent; 254fb726d48Sopenharmony_ci } 255fb726d48Sopenharmony_ci :host(:not([direction])) ::slotted(lit-pop-content[open]), 256fb726d48Sopenharmony_ci :host(:not([direction])[trigger="hover"]:hover) ::slotted(lit-pop-content), 257fb726d48Sopenharmony_ci :host(:not([direction])[trigger="focus"]:focus-within) ::slotted(lit-pop-content), 258fb726d48Sopenharmony_ci :host([direction="bottomright"]) ::slotted(lit-pop-content[open]), 259fb726d48Sopenharmony_ci :host([direction="bottomright"][trigger="hover"]:hover) ::slotted(lit-pop-content), 260fb726d48Sopenharmony_ci :host([direction="bottomright"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 261fb726d48Sopenharmony_ci transform:translate(0,10px) scale(1); 262fb726d48Sopenharmony_ci } 263fb726d48Sopenharmony_ci 264fb726d48Sopenharmony_ci :host([direction="bottomleft"]) ::slotted(lit-pop-content){ 265fb726d48Sopenharmony_ci right:0; 266fb726d48Sopenharmony_ci top:100%; 267fb726d48Sopenharmony_ci transform:translate(0,10px) scale(0); 268fb726d48Sopenharmony_ci transform-origin: right top; 269fb726d48Sopenharmony_ci } 270fb726d48Sopenharmony_ci :host([direction="bottomleft"]) ::slotted(lit-pop-content)::after, 271fb726d48Sopenharmony_ci :host(:not([direction])) ::slotted(lit-pop-content)::after{ 272fb726d48Sopenharmony_ci content: ''; 273fb726d48Sopenharmony_ci position: absolute; 274fb726d48Sopenharmony_ci right: 10%; 275fb726d48Sopenharmony_ci bottom: 100%; 276fb726d48Sopenharmony_ci border-bottom: 10px solid #FFF; 277fb726d48Sopenharmony_ci border-left: 10px solid transparent; 278fb726d48Sopenharmony_ci } 279fb726d48Sopenharmony_ci :host([direction="bottomleft"]) ::slotted(lit-pop-content[open]), 280fb726d48Sopenharmony_ci :host([direction="bottomleft"][trigger="hover"]:hover) ::slotted(lit-pop-content), 281fb726d48Sopenharmony_ci :host([direction="bottomleft"][trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 282fb726d48Sopenharmony_ci transform:translate(0,10px) scale(1); 283fb726d48Sopenharmony_ci } 284fb726d48Sopenharmony_ci 285fb726d48Sopenharmony_ci :host ::slotted(lit-pop-content[open]), 286fb726d48Sopenharmony_ci :host([trigger="hover"]:hover) ::slotted(lit-pop-content), 287fb726d48Sopenharmony_ci :host([trigger="focus"]:focus-within) ::slotted(lit-pop-content){ 288fb726d48Sopenharmony_ci opacity:1; 289fb726d48Sopenharmony_ci visibility:visible; 290fb726d48Sopenharmony_ci } 291fb726d48Sopenharmony_ci slot{ 292fb726d48Sopenharmony_ci } 293fb726d48Sopenharmony_ci </style> 294fb726d48Sopenharmony_ci `; 295fb726d48Sopenharmony_ci 296fb726d48Sopenharmony_ci@element('lit-popover') 297fb726d48Sopenharmony_ciexport class LitPopover extends BaseElement { 298fb726d48Sopenharmony_ci private popContent: LitPopContent | null | undefined; 299fb726d48Sopenharmony_ci private litGroup: LitRadioGroup | LitCheckGroup | undefined; 300fb726d48Sopenharmony_ci private _texBox: LitCheckBoxWithText | undefined; 301fb726d48Sopenharmony_ci 302fb726d48Sopenharmony_ci static get observedAttributes(): string[] { 303fb726d48Sopenharmony_ci return []; 304fb726d48Sopenharmony_ci } 305fb726d48Sopenharmony_ci 306fb726d48Sopenharmony_ci get type(): string { 307fb726d48Sopenharmony_ci return this.getAttribute('type') || ''; 308fb726d48Sopenharmony_ci } 309fb726d48Sopenharmony_ci 310fb726d48Sopenharmony_ci set type(type: string) { 311fb726d48Sopenharmony_ci this.setAttribute('type', type); 312fb726d48Sopenharmony_ci } 313fb726d48Sopenharmony_ci 314fb726d48Sopenharmony_ci get title(): string { 315fb726d48Sopenharmony_ci return this.getAttribute('title') || ''; 316fb726d48Sopenharmony_ci } 317fb726d48Sopenharmony_ci 318fb726d48Sopenharmony_ci set title(title: string) { 319fb726d48Sopenharmony_ci this.setAttribute('title', title); 320fb726d48Sopenharmony_ci } 321fb726d48Sopenharmony_ci 322fb726d48Sopenharmony_ci get limit(): LimitText { 323fb726d48Sopenharmony_ci if (this._texBox?.checked) { 324fb726d48Sopenharmony_ci return { 325fb726d48Sopenharmony_ci textLowerLimit: this._texBox.lowerLimit, 326fb726d48Sopenharmony_ci textUpperLimit: this._texBox.upLimit, 327fb726d48Sopenharmony_ci }; 328fb726d48Sopenharmony_ci } 329fb726d48Sopenharmony_ci return { textLowerLimit: '', textUpperLimit: '' }; 330fb726d48Sopenharmony_ci } 331fb726d48Sopenharmony_ci 332fb726d48Sopenharmony_ci set dataSource(dataSource: Array<SelectBean>) { 333fb726d48Sopenharmony_ci this.popContent = this.querySelector<LitPopContent>('lit-pop-content'); 334fb726d48Sopenharmony_ci if (!this.popContent) { 335fb726d48Sopenharmony_ci this.popContent = new LitPopContent(); 336fb726d48Sopenharmony_ci this.appendChild(this.popContent); 337fb726d48Sopenharmony_ci } 338fb726d48Sopenharmony_ci switch (this.type) { 339fb726d48Sopenharmony_ci case 'multiple': 340fb726d48Sopenharmony_ci this.setMultiple(dataSource); 341fb726d48Sopenharmony_ci break; 342fb726d48Sopenharmony_ci case 'radio': 343fb726d48Sopenharmony_ci this.litGroup = new LitRadioGroup(); 344fb726d48Sopenharmony_ci if (this.title !== '') { 345fb726d48Sopenharmony_ci let title = new LitPopoverTitle(); 346fb726d48Sopenharmony_ci title.setAttribute('title', this.title || ''); 347fb726d48Sopenharmony_ci this.popContent!.appendChild(title); 348fb726d48Sopenharmony_ci this.litGroup.setAttribute('layout', 'compact'); 349fb726d48Sopenharmony_ci } else { 350fb726d48Sopenharmony_ci this.litGroup.setAttribute('layout', 'dispersion'); 351fb726d48Sopenharmony_ci } 352fb726d48Sopenharmony_ci this.popContent!.appendChild(this.litGroup); 353fb726d48Sopenharmony_ci dataSource.forEach((data) => { 354fb726d48Sopenharmony_ci let litRadioBox = new LitRadioBox(); 355fb726d48Sopenharmony_ci if (this.title === '') { 356fb726d48Sopenharmony_ci litRadioBox.setAttribute('dis', 'round'); 357fb726d48Sopenharmony_ci } else { 358fb726d48Sopenharmony_ci litRadioBox.setAttribute('dis', 'check'); 359fb726d48Sopenharmony_ci } 360fb726d48Sopenharmony_ci if (data.isSelected) { 361fb726d48Sopenharmony_ci litRadioBox.setAttribute('checked', 'true'); 362fb726d48Sopenharmony_ci } 363fb726d48Sopenharmony_ci this.litGroup?.appendChild(litRadioBox); 364fb726d48Sopenharmony_ci litRadioBox.setAttribute('value', data.text); 365fb726d48Sopenharmony_ci }); 366fb726d48Sopenharmony_ci break; 367fb726d48Sopenharmony_ci case 'multiple-text': 368fb726d48Sopenharmony_ci dataSource.forEach((data) => { 369fb726d48Sopenharmony_ci this._texBox = new LitCheckBoxWithText(); 370fb726d48Sopenharmony_ci this._texBox.setAttribute('text', data.text); 371fb726d48Sopenharmony_ci this._texBox.setAttribute('checked', ''); 372fb726d48Sopenharmony_ci this.popContent!.appendChild(this._texBox); 373fb726d48Sopenharmony_ci }); 374fb726d48Sopenharmony_ci break; 375fb726d48Sopenharmony_ci case 'data-ming': 376fb726d48Sopenharmony_ci break; 377fb726d48Sopenharmony_ci } 378fb726d48Sopenharmony_ci } 379fb726d48Sopenharmony_ci 380fb726d48Sopenharmony_ci setMultiple(dataSource: Array<SelectBean>): void { 381fb726d48Sopenharmony_ci this.litGroup = new LitCheckGroup(); 382fb726d48Sopenharmony_ci this.litGroup.setAttribute('layout', 'dispersion'); 383fb726d48Sopenharmony_ci this.popContent!.appendChild(this.litGroup); 384fb726d48Sopenharmony_ci dataSource.forEach((data) => { 385fb726d48Sopenharmony_ci let litCheckBox = new LitCheckBox(); 386fb726d48Sopenharmony_ci this.litGroup?.appendChild(litCheckBox); 387fb726d48Sopenharmony_ci if (data.isSelected) { 388fb726d48Sopenharmony_ci litCheckBox.setAttribute('checked', 'true'); 389fb726d48Sopenharmony_ci } 390fb726d48Sopenharmony_ci litCheckBox.setAttribute('value', data.text); 391fb726d48Sopenharmony_ci }); 392fb726d48Sopenharmony_ci } 393fb726d48Sopenharmony_ci 394fb726d48Sopenharmony_ci get select(): Array<string> | undefined { 395fb726d48Sopenharmony_ci if (this._texBox?.checked) { 396fb726d48Sopenharmony_ci return [this._texBox!.text]; 397fb726d48Sopenharmony_ci } 398fb726d48Sopenharmony_ci return this.litGroup?.value; 399fb726d48Sopenharmony_ci } 400fb726d48Sopenharmony_ci 401fb726d48Sopenharmony_ci get trigger(): string | null { 402fb726d48Sopenharmony_ci return this.getAttribute('trigger'); 403fb726d48Sopenharmony_ci } 404fb726d48Sopenharmony_ci 405fb726d48Sopenharmony_ci get direction(): string { 406fb726d48Sopenharmony_ci return this.getAttribute('direction') || 'topright'; 407fb726d48Sopenharmony_ci } 408fb726d48Sopenharmony_ci 409fb726d48Sopenharmony_ci set direction(value: string) { 410fb726d48Sopenharmony_ci this.setAttribute('direction', value); 411fb726d48Sopenharmony_ci } 412fb726d48Sopenharmony_ci 413fb726d48Sopenharmony_ci get open(): boolean { 414fb726d48Sopenharmony_ci return this.getAttribute('open') !== null; 415fb726d48Sopenharmony_ci } 416fb726d48Sopenharmony_ci 417fb726d48Sopenharmony_ci set open(value: boolean) { 418fb726d48Sopenharmony_ci if (value === null || value === false) { 419fb726d48Sopenharmony_ci this.removeAttribute('open'); 420fb726d48Sopenharmony_ci } else { 421fb726d48Sopenharmony_ci this.setAttribute('open', ''); 422fb726d48Sopenharmony_ci } 423fb726d48Sopenharmony_ci } 424fb726d48Sopenharmony_ci 425fb726d48Sopenharmony_ci initElements(): void {} 426fb726d48Sopenharmony_ci 427fb726d48Sopenharmony_ci initHtml(): string { 428fb726d48Sopenharmony_ci return ` 429fb726d48Sopenharmony_ci ${initHtmlStyle} 430fb726d48Sopenharmony_ci <slot></slot> 431fb726d48Sopenharmony_ci `; 432fb726d48Sopenharmony_ci } 433fb726d48Sopenharmony_ci 434fb726d48Sopenharmony_ci connectedCallback(): void { 435fb726d48Sopenharmony_ci if (!(this.trigger && this.trigger !== 'click')) { 436fb726d48Sopenharmony_ci this.addEventListener('click', () => { 437fb726d48Sopenharmony_ci this.popContent = this.querySelector<LitPopContent>('lit-pop-content'); 438fb726d48Sopenharmony_ci if (!this.popContent) { 439fb726d48Sopenharmony_ci this.popContent = new LitPopContent(); 440fb726d48Sopenharmony_ci this.appendChild(this.popContent); 441fb726d48Sopenharmony_ci } 442fb726d48Sopenharmony_ci this.popContent?.setAttribute('open', 'true'); 443fb726d48Sopenharmony_ci }); 444fb726d48Sopenharmony_ci } 445fb726d48Sopenharmony_ci document.addEventListener('mousedown', (ev) => { 446fb726d48Sopenharmony_ci const path = ev.composedPath && ev.composedPath(); 447fb726d48Sopenharmony_ci if ( 448fb726d48Sopenharmony_ci // @ts-ignore 449fb726d48Sopenharmony_ci this.popContent && 450fb726d48Sopenharmony_ci !path.includes(this.popContent) && 451fb726d48Sopenharmony_ci !path.includes(this.children[0]) && 452fb726d48Sopenharmony_ci !path.includes(this.popContent) 453fb726d48Sopenharmony_ci ) { 454fb726d48Sopenharmony_ci this.popContent!.open = false; 455fb726d48Sopenharmony_ci } 456fb726d48Sopenharmony_ci }); 457fb726d48Sopenharmony_ci } 458fb726d48Sopenharmony_ci} 459fb726d48Sopenharmony_ci 460fb726d48Sopenharmony_ciexport interface SelectBean { 461fb726d48Sopenharmony_ci text: string; 462fb726d48Sopenharmony_ci isSelected: boolean; 463fb726d48Sopenharmony_ci limitText?: LimitText; 464fb726d48Sopenharmony_ci} 465fb726d48Sopenharmony_ci 466fb726d48Sopenharmony_ciexport interface LimitText { 467fb726d48Sopenharmony_ci textUpperLimit: string; 468fb726d48Sopenharmony_ci textLowerLimit: string; 469fb726d48Sopenharmony_ci} 470fb726d48Sopenharmony_ci 471fb726d48Sopenharmony_ciexport interface Charge { 472fb726d48Sopenharmony_ci text: string; 473fb726d48Sopenharmony_ci isSelected: boolean; 474fb726d48Sopenharmony_ci} 475