11// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
22// SPDX-License-Identifier: BSD-3-Clause-Clear
33
4- import { Component } from "@angular/core"
4+ import { booleanAttribute , Component , input } from "@angular/core"
55
66import { useComboboxContext } from "@qualcomm-ui/angular-core/combobox"
7+ import type { Booleanish } from "@qualcomm-ui/utils/coercion"
78
89@Component ( {
910 selector : "q-combobox-items" ,
@@ -21,14 +22,32 @@ import {useComboboxContext} from "@qualcomm-ui/angular-core/combobox"
2122 track comboboxContext().collection.getItemValue(item)
2223 ) {
2324 <div q-combobox-item [item]="item">
24- <span q-combobox-item-text>
25- {{ comboboxContext().collection.stringifyItem(item) }}
26- </span>
25+ @if (highlightMatchingText()) {
26+ <span
27+ ignoreCase
28+ q-combobox-item-text
29+ q-highlight
30+ [query]="comboboxContext().inputValue"
31+ [text]="comboboxContext().collection.stringifyItem(item)"
32+ ></span>
33+ } @else {
34+ <span q-combobox-item-text>
35+ {{ comboboxContext().collection.stringifyItem(item) }}
36+ </span>
37+ }
2738 <span q-combobox-item-indicator></span>
2839 </div>
2940 }
3041 ` ,
3142} )
3243export class ComboboxItemsComponent {
44+ /**
45+ * Set to `true` to highlight option text matches during filtering.
46+ */
47+ readonly highlightMatchingText = input < boolean | undefined , Booleanish > (
48+ undefined ,
49+ { transform : booleanAttribute } ,
50+ )
51+
3352 protected readonly comboboxContext = useComboboxContext ( )
3453}
0 commit comments