@@ -16,44 +16,17 @@ import { msg } from '@lit/localize';
1616
1717import {
1818 hasAnyOf ,
19+ isSubsequence ,
1920 type IAComboBoxBehavior ,
2021 type IAComboBoxFilterFunction ,
2122 type IAComboBoxFilterOption ,
2223 type IAComboBoxFilterPreset ,
2324 type IAComboBoxOption ,
2425} from './models' ;
2526
26- import caretClosedIcon from './caret-closed-icon' ;
27- import caretOpenIcon from './caret-open-icon' ;
28- import clearIcon from './clear-icon' ;
29-
30- /**
31- * Tests whether the given `haystack` string has the given `needle` as a subsequence.
32- * Returns `true` if the characters of `needle` appear in order within `haystack`,
33- * regardless of whether they are contiguous. Returns `false` otherwise.
34- *
35- * E.g., `ace` is a subsequence of `archive` (but not a contiguous substring).
36- *
37- * Note: The empty string is a subsequence of any string, including itself.
38- *
39- * @param needle The potential subsequence to check for inside `haystack`.
40- * @param haystack The string to be tested for containing the `needle` subsequence.
41- * @returns Whether `haystack` has `needle` as a subsequence.
42- */
43- const isSubsequence = ( needle : string , haystack : string ) : boolean => {
44- const needleLen = needle . length ;
45- const haystackLen = haystack . length ;
46- if ( needleLen === 0 ) return true ;
47-
48- let needleIdx = 0 ;
49- let haystackIdx = 0 ;
50- while ( haystackIdx < haystackLen ) {
51- if ( haystack [ haystackIdx ] === needle [ needleIdx ] ) needleIdx += 1 ;
52- if ( needleIdx >= needleLen ) return true ;
53- haystackIdx += 1 ;
54- }
55- return false ;
56- } ;
27+ import caretClosedIcon from './caret-closed.svg' ;
28+ import caretOpenIcon from './caret-open.svg' ;
29+ import clearIcon from './clear.svg' ;
5730
5831/**
5932 * Map from filter preset keys to their associated filtering function.
@@ -434,10 +407,13 @@ export class IAComboBox extends LitElement {
434407 id = "clear- butto n"
435408 class= ${ classMap ( { visible : this . shouldShowClearButton } ) }
436409 part= "clear- butto n"
410+ tabindex= "-1"
437411 @click = ${ this . handleClearButtonClick }
438412 >
439413 <span class= "sr-only" > ${ msg ( 'Clear' ) } </ span>
440- <slot name= "clear-button" class = "clear- icon"> ${ clearIcon } </ slot>
414+ <slot name= "clear-button" >
415+ <img class= "icon" src = ${ clearIcon } >
416+ </ slot>
441417 </ butto n>
442418 ` ;
443419 }
@@ -448,11 +424,11 @@ export class IAComboBox extends LitElement {
448424 */
449425 private get caretTemplate ( ) : TemplateResult {
450426 return html `
451- <slot name= "caret-closed" class = "caret - icon" ?hidden= ${ this . open } >
452- ${ caretClosedIcon }
427+ <slot name= "caret-closed" ?hidden= ${ this . open } >
428+ <img class = "icon" src = ${ caretClosedIcon } >
453429 </ slot>
454- <slot name= "caret-open" class = "caret - icon" ?hidden= ${ ! this . open } >
455- ${ caretOpenIcon }
430+ <slot name= "caret-open" ?hidden= ${ ! this . open } >
431+ <img class = "icon" src = ${ caretOpenIcon } >
456432 </ slot>
457433 ` ;
458434 }
@@ -1211,8 +1187,7 @@ export class IAComboBox extends LitElement {
12111187 text-align : center;
12121188 }
12131189
1214- .caret-icon > svg ,
1215- .clear-icon > svg {
1190+ .icon {
12161191 width : 14px ;
12171192 height : 14px ;
12181193 }
0 commit comments