@@ -8,13 +8,15 @@ import {
88import { classMap } from 'lit/directives/class-map.js' ;
99import { ifDefined } from 'lit/directives/if-defined.js' ;
1010import { repeat } from 'lit/directives/repeat.js' ;
11+ import { when } from 'lit/directives/when.js' ;
1112import '../../vscode-button/index.js' ;
1213import '../../vscode-option/index.js' ;
1314import { VscodeOption } from '../../vscode-option/index.js' ;
1415import { VscElement } from '../VscElement.js' ;
1516import { filterOptionsByPattern , highlightRanges } from './helpers.js' ;
1617import type { InternalOption , Option , FilterMethod } from './types.js' ;
1718import { OptionListController } from './OptionListController.js' ;
19+ import { checkIcon } from './template-elements.js' ;
1820
1921export const VISIBLE_OPTS = 10 ;
2022export const OPT_HEIGHT = 22 ;
@@ -604,6 +606,19 @@ export class VscodeSelectBase extends VscElement {
604606 //#endregion
605607
606608 //#region render functions
609+ private _renderCheckbox (
610+ checked : boolean ,
611+ label : string | TemplateResult | TemplateResult [ ]
612+ ) {
613+ const checkboxClasses = {
614+ 'checkbox-icon' : true ,
615+ checked,
616+ } ;
617+
618+ return html `< span class =${ classMap ( checkboxClasses ) } > ${ checkIcon } </ span
619+ > < span class ="option-label "> ${ label } </ span > ` ;
620+ }
621+
607622 protected _renderOptions ( ) : TemplateResult | TemplateResult [ ] {
608623 const list = this . _opts . options ;
609624
@@ -640,11 +655,6 @@ export class VscodeSelectBase extends VscElement {
640655 selected,
641656 } ;
642657
643- const checkboxClasses = {
644- 'checkbox-icon' : true ,
645- checked : selected ,
646- } ;
647-
648658 const labelText =
649659 ( op . ranges ?. length ?? 0 > 0 )
650660 ? highlightRanges ( op . label , op . ranges ?? [ ] )
@@ -660,10 +670,11 @@ export class VscodeSelectBase extends VscElement {
660670 role="option"
661671 tabindex="-1"
662672 >
663- ${ this . _opts . multiSelect
664- ? html `< span class =${ classMap ( checkboxClasses ) } > </ span
665- > < span class ="option-label "> ${ labelText } </ span > `
666- : labelText }
673+ ${ when (
674+ this . _opts . multiSelect ,
675+ ( ) => this . _renderCheckbox ( selected , labelText ) ,
676+ ( ) => labelText
677+ ) }
667678 </ li >
668679 ` ;
669680 }
0 commit comments