Usage
Signature:
interface CInputSearchElement<K extends oj-c.InputSearch.Key,D extends Data>
Typescript Import Format
//To typecheck the element APIs, import as below.
import { CInputSearchElement } from "oj-c/input-search";
//For the transpiled javascript to load the element's module, import as below
import "oj-c/input-search";
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.
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.
-
collectionTemplate
-
Note: When the template is executed for each item, it will have access to the binding context containing the following properties: oj-c.InputSearch.InputSearchCollectionTemplateContext
The
collectionTemplateslot is used to specify the template for rendering suggestions in collection mode. The slot must be a <template> element containing a child core-pack collection element (e.g. <oj-c-table/> or <oj-c-list-view/>).When provided,
collectionTemplatetakes precedence oversuggestionItemTemplate. Collection mode currently supports DataProvider-backed suggestions only.The collectionTemplate supports oj-c-table and oj-c-list-view.
Properties of $current:
Name Type Argument Description currentRowOverride{ rowKey: K; } <optional>
Current focused row/item override for the rendered collection. dataDataProvider.<K, D> | null <optional>
Data and metadata for the collection rendered by the template. onCurrentRowChanged(detail: { rowKey?: K; }) => void Callback invoked when the rendered collection changes its current row. onRowAction(detail: { item: Item<K, D>; }) => void Callback invoked when the user performs an action gesture on a row/item. searchTextstring <optional>
The text entered by the user for filtering the collection data. selectedImmutableKeySet.<K> Selected row/item keys for the rendered collection. -
suggestionItemTemplate
-
Note: When the template is executed for each item, it will have access to the binding context containing the following properties: oj-c.InputSearch.InputSearchSuggestionItemTemplateContext
ThesuggestionItemTemplateslot is used to specify the template for rendering each suggestion in the dropdown. 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.<K> The metadata for the current suggestion. searchTextstring <optional>
The search text entered by the user.
Attributes
-
autocomplete :"off"|"on"
-
Specifies whether suggestions can enable autocomplete typeahead preview. Prefix matches can preview the first suggestion inline. Desktop partial matches can also preview the first suggestion as floating text, but phones suppress floating autocomplete and keep non-prefix matches raw.
- 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 -
max-width :(number|string|"sm"|"md")
-
Specifies the component's max width. If unset, the default max width is 100%.
Supported Values:
Value smmdNames
Item Name Property maxWidthProperty change event maxWidthChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-max-width-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.
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
-
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, presses Enter, or selects a suggestion, thevalueproperty gets updated.This is a read-only attribute so page authors cannot set or change it directly.
- 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 property can be set to either:
- a string that specifies the name of a top level data field whose value will be rendered 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. Field values other than null or undefined are converted to strings.
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 :(Array.<D>|DataProvider.<K, D>|null)
-
Data for the InputSearch suggestions. This data is used to populate the list of suggestions in the dropdown or collection mode. 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.
Suggestions can be supplied as a DataProvider or as an array of suggestion objects.
When
collectionTemplateis provided, suggestions must be backed by a DataProvider.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.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 current value of the element. The value is updated when the user blurs the field, presses Enter, or selects a suggestion. However, blurring the field does not trigger an onOjValueAction.
- 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 -
variant :"standard"|"hero"
-
Specifies whether the field uses the standard or hero presentation.
- Default Value:
'standard'
Supported Values:
Value Description standardRenders the default input search presentation. heroRenders the larger hero search presentation. Names
Item Name Property variantProperty change event variantChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-variant-changed -
width :(number|string|"sm"|"md")
-
Specifies the component's width. If unset, the default width is 100%. Note that by default max-width is 100%, which will override the width if the container is smaller than the width specified.
Supported Values:
Value smmdNames
Item Name Property widthProperty change event widthChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-width-changed
Events
-
ojValueAction
-
Note: The event detail contains the following properties: oj-c.InputSearch.InputSearchValueActionDetail<K, D>
Triggered when search text is explicitly submitted by the user, even if the text has not changed. Submission is triggered by the Enter key or by selecting a suggestion. Blurring the field updates value but does not trigger this event.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.
-
InputSearchCollectionTemplateContext<K extends oj-c.InputSearch.Key = oj-c.InputSearch.Key,D extends Data = Data>
-
Context passed to the Core Pack collectionTemplate slot. The wrapper adapts Preact collection-mode callbacks to the row/current/selected contracts used by oj-c-table and oj-c-list-view.
Properties:
Name Type Argument Description currentRowOverride{ rowKey: K; } <optional>
Current focused row/item override for the rendered collection. dataDataProvider.<K, D> | null <optional>
Data and metadata for the collection rendered by the template. onCurrentRowChanged(detail: { rowKey?: K; }) => void Callback invoked when the rendered collection changes its current row. onRowAction(detail: { item: Item<K, D>; }) => void Callback invoked when the user performs an action gesture on a row/item. searchTextstring <optional>
The text entered by the user for filtering the collection data. selectedImmutableKeySet.<K> Selected row/item keys for the rendered collection. -
InputSearchSuggestionItemTemplateContext<K extends oj-c.InputSearch.Key = oj-c.InputSearch.Key,D extends Data = Data>
-
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.<K> The metadata for the current suggestion. searchTextstring <optional>
The search text entered by the user. -
InputSearchValueActionDetail<K extends oj-c.InputSearch.Key = oj-c.InputSearch.Key,D extends Data = Data>
-
Properties:
Name Type Argument Description itemContextItemContext<K, D> <optional>
The data provider context for the search text, if available. previousValue(string|null) <optional>
The previous submitted search text. value(string|null) The submitted search text. -
Key
-