File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - New typeahead helper function ` getAutosuggestHighlightParts ` .
13+
1014## [ 3.5.0] - 2025-06-18
1115
1216### Changed
Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ const renderHighlightedOptionFunction = (
5555 option : TypeaheadOption ,
5656 { inputValue } : AutocompleteRenderOptionState ,
5757) : JSX . Element => {
58- const finalOption = typeof option === "string" ? option : option . label ;
59- const matches = AutosuggestHighlightMatch ( finalOption , inputValue , { insideWords : true } ) ;
60- const parts = AutosuggestHighlightParse ( finalOption , matches ) as Array < { text : string ; highlight : boolean } > ;
58+ const parts = getAutosuggestHighlightParts ( option , inputValue ) ;
6159 return (
6260 < li { ...props } >
6361 < div >
@@ -71,6 +69,12 @@ const renderHighlightedOptionFunction = (
7169 ) ;
7270} ;
7371
72+ const getAutosuggestHighlightParts = ( option : TypeaheadOption , inputValue : string ) : Array < { text : string ; highlight : boolean } > => {
73+ const finalOption = typeof option === "string" ? option : option . label ;
74+ const matches = AutosuggestHighlightMatch ( finalOption , inputValue , { insideWords : true } ) ;
75+ return AutosuggestHighlightParse ( finalOption , matches ) ;
76+ } ;
77+
7478export {
7579 getSingleAutoCompleteValue ,
7680 getMultipleAutoCompleteValue ,
@@ -79,4 +83,5 @@ export {
7983 isDisabledGroup ,
8084 groupOptions ,
8185 renderHighlightedOptionFunction ,
86+ getAutosuggestHighlightParts ,
8287} ;
You can’t perform that action at this time.
0 commit comments