Usage
Signature:
interface InputSearchElement<K,D>
Generic Parameters
Parameter Description K Type of key of the dataprovider D Type of data from the dataprovider
Typescript Import Format
//To typecheck the element APIs, import as below.
import { InputSearchElement } from "ojs/ojinputsearch";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojinputsearch";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Styling Classes
-
.oj-input-search-hero
-
Render a larger search field that is more prominent on the page
Example
<oj-input-search class="oj-input-search-hero"> <!-- Content --> </oj-input-search> -
Category: form-control-max-width
-
In the Redwood theme the default max width of a text field is 100%. These max width convenience classes are available to create a medium or small field.
The class is applied to the root element.Classes:
-
.oj-form-control-max-width-sm
-
Sets the max width for a small field.
-
.oj-form-control-max-width-md
-
Sets the max width for a medium field.
-
-
Category: form-control-width
-
In the Redwood theme the default width of a text field is 100%. These width convenience classes are available to create a medium or small field.
The class is applied to the root element.Classes:
-
.oj-form-control-width-sm
-
Sets the width for a small field.
-
.oj-form-control-width-md
-
Sets the width for a medium field.
-
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
suggestionItemTemplate
-
Note: When the template is executed for each item, it will have access to the binding context containing the following properties: oj.ojInputSearch.SuggestionItemTemplateContext
The
suggestionItemTemplateslot is used to specify the template for rendering each suggestion in the dropdown list. The slot must be a <template> element.When the template is executed for each suggestion, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current suggestion. (See the table below for a list of properties available on $current)
- alias - if the data-oj-as attribute was specified on the template, the value will be used to provide an application-named alias for $current.
If no
suggestionItemTemplateis specified, the component will render based on the value of thesuggestionItemTextproperty.Properties of $current:
Name Type Argument Description dataD The data for the current suggestion indexnumber The zero-based index of the current suggestion keyK The key of the current suggestion metadataItemMetadata.<Key> The metadata for the current suggestion searchText(string|null) <optional>
The search text entered by the user
Attributes
-
autocomplete :"on"|"off"
-
Specifies whether the component will enable the autocomplete type ahead feature.
- Default Value:
'on'
Names
Item Name Property autocompleteProperty change event autocompleteChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-autocomplete-changed -
placeholder :string
-
The placeholder text to set on the element. The placeholder specifies a short hint that can be displayed before the user selects or enters a value.
- Default Value:
''
Names
Item Name Property placeholderProperty change event placeholderChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-placeholder-changed -
(readonly) raw-value :(string|null)
-
The
rawValueis the read-only property for retrieving the current value from the input field in string form.The
rawValueupdates on the 'input' javascript event, so therawValuechanges as the value of the input is changed. If the user types in '1,200' into the field, the rawValue will be '1', then '1,', then '1,2', ..., and finally '1,200'. Then when the user blurs or presses Enter thevalueproperty gets updated.This is a read-only attribute so page authors cannot set or change it directly.
- Default Value:
null
- Supports writeback:
true
Names
Item Name Property rawValueProperty change event rawValueChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-raw-value-changed -
suggestion-item-text :keyof D|(itemContext: ojcommontypes.ItemContext<K, D>) => string
-
Specifies the text string to render for a suggestion. This attribute can be set to either:
- a string that specifies the name of a top level data field to render as text, or
- a callback function that takes a context object and returns the text string to display
By default, the component will attempt to render a 'label' data field as text.
This text will be rendered for the selected value of the component. It will also be rendered for each suggestion in the dropdown if no suggestionItemTemplate is provided. When rendered for the dropdown suggestions, default matching search term highlighting will still be applied.
- Default Value:
'label'
Names
Item Name Property suggestionItemTextProperty change event suggestionItemTextChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-suggestion-item-text-changed -
suggestions :(oj.ojInputSearch.DataProvider.<K, D>|null)
-
Data for the InputSearch suggestions. This data is used to populate the list of suggestions in the dropdown. When a user selects a suggestion from the dropdown, the ojValueAction event will contain the data for that suggestion. If no suggestions data is provided, then the dropdown will not be shown. Note that the InputSearch only shows up to a maximum of 12 suggestions in the dropdown even if there are more suggestions available in the data.
Note that the
suggestion-item-textattribute allows for customizing the rendering of each suggestion. If it is not specified, then the component will attempt to render as text the 'label' field in the suggestion by default.- Default Value:
null
Names
Item Name Property suggestionsProperty change event suggestionsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-suggestions-changed -
value :(string|null)
-
The value of the element.
- Default Value:
null
- Supports writeback:
true
Names
Item Name Property valueProperty change event valueChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-value-changed
Events
-
ojValueAction
-
Note: The event detail contains the following properties: oj.ojInputSearch.ValueDetail<Key, Data>
Triggered when search text is submitted by the user, even if the text hasn't changed. Submission is triggered by the enter key, either to directly submit text or to select a highlighted value from the suggestions dropdown, or by selecting a value from the dropdown using a mouse or touch gesture. Note that the value property is guaranteed to be up-to-date at the time the ojValueAction event is dispatched.See Events and Listeners for additional information.
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesobject An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a corresponding event.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. Returns:
- Type
- void
Type Definitions
Documentation-only Types
Note: Type definitions in this section have been provided for documentation purposes and cannot be imported into application code.
-
DataProvider<K,D>
-
The interface for DataProvider
Properties:
Name Type Argument Description addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options: boolean | AddEventListenerOptions | undefined) => void The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) containsKeys(parameters: ojInputSearch.FetchByKeysParameters<K>) => Promise<ContainsKeysResults<K>> Check if rows are contained by keys createOptimizedKeyMap(initialMap: Map<K, D> | undefined) => Map<K, D> <optional>
Returns an empty Map which will efficiently store Keys returned by the DataProvider createOptimizedKeySet(initialSet: Set<K> | undefined) => Set<K> <optional>
Return an empty Set which is optimized to store keys dispatchEvent(event: Event) => boolean The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) fetchByKeys(parameters: ojInputSearch.FetchByKeysParameters<K>) => Promise<FetchByKeysResults<K, D>> Fetch rows by keys fetchByOffset(parameters: ojInputSearch.FetchByOffsetParameters<D>) => Promise<FetchByOffsetResults<K, D>> Fetch rows by offset fetchFirstFetchFunc<K, D> Fetch the first block of data getCapabilityoj.ojInputSearch.DedupCapability Determines whether this DataProvider defines certain features. getTotalSizefunction Returns a Promise which resolves to the total size which is -1 if unknown count. isEmptyfunction Returns a string that indicates if this data provider is empty. Valid values are: "yes": this data provider is empty. "no": this data provider is not empty. "unknown": it is not known if this data provider is empty until a fetch is made. removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options: boolean | EventListenerOptions | undefined) => void The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) -
DedupCapability
-
Properties:
Name Type type"none" | "global" | "iterator" -
FetchAttribute
-
Properties:
Name Type Argument Description attributesArray<string | ojInputSearch.FetchAttribute> <optional>
Optional attributes property which specifies at least which attributes of the value we want to include. If not specified then the default attributes are included. If the value is a primitive then this is ignored. Expressions like "!" and "@default" are also supported. e.g. ['!lastName', '@default'] for everything except 'lastName'. For only 'firstName' and 'lastName' we'd have ['firstName', 'lastName']. Order does not matter when namestring The name of the attribute or sub object or related object. -
FetchByKeysParameters<K>
-
The interface for FetchByKeysParameters
Properties:
Name Type Argument Description attributesArray<string | ojInputSearch.FetchAttribute> <optional>
attributes to include in the result. If specified, then at least these set of attributes will be included in each row results. If not specified then the default attributes will be included. keysSet<K> scope"global" | "local" <optional>
signalAbortSignal <optional>
Optional signal to be assocated with fetchByKeys request so that the request can be aborted this signal later -
FetchByOffsetParameters<D>
-
The interface for FetchByOffsetParameters
Properties:
Name Type Argument Description attributesArray<string | ojInputSearch.FetchAttribute> <optional>
attributes to include in the result. If specified, then at least these set of attributes will be included in each row results. If not specified then the default attributes will be included. clientIdsymbol <optional>
Optional symbol that can uniquely identify the consumer of the DataProvider. filterCriterionFilter<D> <optional>
filter criterion to apply. includeFilteredRowCount"enabled" | "disabled" <optional>
Optional property to request that the total filtered row count be included in the fetch result. offsetnumber signalAbortSignal <optional>
Optional signal to be assocated with fetchByOffset request so that the request can be aborted this signal later sizenumber <optional>
# of rows to fetch starting from offset. If fewer than that number of rows exist, the fetch will succeed but be truncated. sortCriteriaArray.<oj.ojInputSearch.SortCriterion.<D>> <optional>
sort criteria to apply. -
SortCriterion<D>
-
Properties:
Name Type Description attributekeyof D sort attribute. direction"ascending" | "descending" sort direction. -
SuggestionItemTemplateContext<K,D>
-
Properties:
Name Type Argument Description dataD The data for the current suggestion indexnumber The zero-based index of the current suggestion keyK The key of the current suggestion metadataItemMetadata.<Key> The metadata for the current suggestion searchText(string|null) <optional>
The search text entered by the user -
ValueDetail<K,D>
-
Properties:
Name Type Argument Description itemContextojcommontypes.ItemContext.<Key, Data> <optional>
The data provider context for the search text, if available. previousValuestring <optional>
The previous search text. valuestring <optional>
The search text.