The class that manages the state of the search within a combobox.
- Source:
- Copyright:
- 2023 Mathew May
- 2023 Mathew May
- License:
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Members
moveToFirstNode
Set the focus on the first node within the array.
moveToLastNode
Set the focus to the final node within the array.
moveToNode
Set focus on any given specified node within the node array.
selectNode
Set focus on a given node after parsed through the calling functions.
Methods
(async) clickHandler(e)
The handler for when a user interacts with the component.
Parameters:
Name | Type | Description |
---|---|---|
e |
MouseEvent | The triggering event that we are working with. |
closeSearch(clear)
When called, close the dropdown and reset the input field attributes.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
clear |
Boolean |
false
|
Conditionality clear the input box. |
componentSelector()
Stub out a required function.
dropdownSelector()
Stub out a required function.
fetchDataset()
Stub out a required function.
filterDataset(dataset)
Stub out a required function.
Parameters:
Name | Type | Description |
---|---|---|
dataset |
Array |
filterMatchDataset()
Stub out a required function.
(async) filterrenderpipe() → {Promise.<void>}
Update any changeable nodes, filter and then render the result.
Returns:
- Type
- Promise.<void>
(async) getDataset() → {Promise.<null>}
Return the dataset that we will be searching upon.
Returns:
- Type
- Promise.<null>
getDatasetSize() → {number}
Return the size of the dataset.
Returns:
- Type
- number
getHTMLElements() → {object}
Return an object containing a handfull of dom nodes that we sometimes need the value of.
Returns:
- Type
- object
getMatchedResults() → {Array}
Return the results of the filter upon the dataset.
Returns:
- Type
- Array
getPreppedSearchTerm() → {string}
Get the transformed search value.
Returns:
- Type
- string
getSearchTerm() → {string}
Get the value that the user entered.
Returns:
- Type
- string
keyHandler(e)
The handler for when a user presses a key within the component.
Parameters:
Name | Type | Description |
---|---|---|
e |
KeyboardEvent | The triggering event that we are working with. |
keyUpDown(direction, e)
Set the current focus either on the preceding or next result item.
Parameters:
Name | Type | Description |
---|---|---|
direction |
Number | Is the user moving up or down the resultset? |
e |
KeyboardEvent | The JS event from the event handler. |
registerClickHandlers()
Register clickable event listeners.
registerInputHandlers()
Register input event listener for the text input area.
registerKeyHandlers()
Register key event listeners.
(async) renderAndShow() → {Promise.<void>}
A combo method to take the matching fields and render out the results.
Returns:
- Type
- Promise.<void>
renderDropdown()
Stub out a required function.
searchResultsVisible() → {Boolean}
Check whether search results are currently visible.
Returns:
- Type
- Boolean
setMatchedResults(result)
Given a filter has been run across the dataset, store the matched results.
Parameters:
Name | Type | Description |
---|---|---|
result |
Array |
setSearchTerms(result)
When a user searches for something, set our variable to manage it.
Parameters:
Name | Type | Description |
---|---|---|
result |
string |
toggleDropdown(on)
When called, update the dropdown fields.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
on |
Boolean |
false
|
Flag to toggle hiding or showing values. |
triggerSelector()
Stub out a required function.
updateNodes()
These class members change when a new result set is rendered. So update for fresh data.