Skip to content

Commit

Permalink
Implement case_sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 3, 2025
1 parent 47b0199 commit 400bf66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/panel_material_ui/widgets/Autocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ export function render({model, el}) {
}

const filt_func = (options, state) => {
const input = state.inputValue
let input = state.inputValue
if (input.length < model.min_characters) {
return []
}
return options.filter((opt) => {
if (!model.case_sensitive) {
opt = opt.toLowerCase()
input = input.toLowerCase()
}
return model.search_strategy == 'includes' ? opt.includes(input) : opt.startsWith(input)
})
}
Expand Down
3 changes: 3 additions & 0 deletions src/panel_material_ui/widgets/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class AutocompleteInput(MaterialSingleSelectBase):
... )
"""

case_sensitive = param.Boolean(default=True, doc="""
Enable or disable case sensitivity.""")

min_characters = param.Integer(default=2, doc="""
The number of characters a user must type before
completions are presented.""")
Expand Down

0 comments on commit 400bf66

Please sign in to comment.