Input JAVASCRIPT UI Component API

Input Javascript API

Class

Input

Input specifies an input field where the user can enter data. Auto-complete options are displayed for easier input.

Selector

smart-input

Properties

AautoCompleteDelayDetermines the delay before the drop down opens to show the matches from the auto complete operation. The delay is measured in miliseconds.
DdataSourceDetermines the data source that will be loaded to the Input. The dataSource can be an array of strings/numbers or objects where the attributes represent the properties of a List Item. For example label, value. It can also be a callback that returns an Array of items as previously described. The data source item object may have the following fields: 'label' - string, 'value' - string or number, 'selected' - boolean, 'prefix' - string, 'suffix' - string, 'title' - string. The 'prefix' and 'suffix' add html before and after the label.
DdisabledEnables or disables the element.
DdropDownClassListSets additional class names to the Input drop down.
DdropDownButtonPositionDetermines the position of the drop down button.
DdropDownHeightSets the height of the drop down. By default it's set to an empty string. In this case the height of the drop down is controlled by a CSS variable.
DdropDownWidthSets the width of the drop down. By default it's set to an empty string. In this case the width of the drop down is controlled by a CSS variable.
IinputPurposeSets the purpose of the input and what, if any, permission the user agent has to provide automated assistance in filling out the element's input when in a form, as well as guidance to the browser as to the type of information expected in the element. This value corresponds to the standard HTML autocomplete attribute and can be set to values such as 'on', 'name', 'organization', 'street-address', etc.
IitemsDetermines the maximum number of matched items that should be visible inside the drop down as a result of a new autoComplete query. By default the maximum number of 8 items can be displayed inside the drop down.
LlocaleSets or gets the language. Used in conjunction with the property messages.
LlocalizeFormatFunctionCallback used to customize the format of the messages that are returned from the Localization Module.
MmessagesSets or gets an object specifying strings used in the widget that can be localized. Used in conjunction with the property locale.
MminLengthDetermines the minimum number of characters inside the input in order to trigger the autocomplete functionality that will open the drop down and show the matched items.
NnameSets or gets the name attribute for the element. Name is used when submiting data inside an HTML form.
OopenedDetermines whether the drop down is opened or not.
PplaceholderDetermines the placeholder of the input.
QquerySets or gets the query that is used to filter the items. Query is used by the autoComplete operation. Empty string means that all items from the data source will be displayed and no filter query is applied.
QqueryModeDetermines the auto complete query mode. This property also determines the matching algorithm for the autocomplete operation.
RreadonlyDetermines whether ot not the user can enter text inside the input. if dropDownButtonPosition is set to 'left' or 'right' then readonly determines whether the element acts as a ComboBox or a DropDownList if a dataSource is provided.
RrightToLeftSets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.
SsortedDetermines whether the items are sorted alphabetically or not
SsortDirectionDetermines the sorting algorithm - ascending(asc) or descending(desc) if sort is enabled.
SselectedIndexDetermines the selected index.
SselectedValueDetermines the selected value.
TthemeDetermines the theme for the element. Themes define the look of the elements.
TtypeDetermines the input type. Input type determines what input can be entered.
UunfocusableIf is set to true, the element cannot be focused.
VvalueSets or gets the value of the element.

Events

CchangeThis event is triggered when the selection is changed.
CchangingThis event is triggered on each key up event of the Input, if the value is changed.
OopenThis event is triggered when the popup is opened.
CcloseThis event is triggered when the popup is closed.
IitemClickThis event is triggered when the user clicks on an item from the popup list.

Methods

CcloseCloses the drop down.
EensureVisibleEnsures that the active ( selected ) item is always visible.
OopenOpens the drop down.
SselectFocuses and selects the text inside the input or if it is readonly then the element is focused.
SselectItemSelects an item by value. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'], you can use 'Item 1' as an argument. If your data source is an object with label and value, pass the value when you call selectItem.
GgetItemGets an item by value. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'], you can use 'Item 1' as an argument. If your data source is an object with label and value, pass the value when you call selectItem.
GgetSelectedItemGets the selected item. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'] and the user selected the second item, the method returns 'Item 2'. If your data source is an object with label and value, the returned value would be the 'value'.

Properties

autoCompleteDelaynumber

Determines the delay before the drop down opens to show the matches from the auto complete operation. The delay is measured in miliseconds.

Default value

100

Example

Set the autoCompleteDelay property.

 <smart-input auto-complete-delay='50'></smart-input>

Set the autoCompleteDelay property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.autoCompleteDelay = 200;

Get the autoCompleteDelay property.

 const input = document.querySelector('smart-input');
 let autoCompleteDelay = input.autoCompleteDelay;

dataSourceany

Determines the data source that will be loaded to the Input. The dataSource can be an array of strings/numbers or objects where the attributes represent the properties of a List Item. For example label, value. It can also be a callback that returns an Array of items as previously described. The data source item object may have the following fields: 'label' - string, 'value' - string or number, 'selected' - boolean, 'prefix' - string, 'suffix' - string, 'title' - string. The 'prefix' and 'suffix' add html before and after the label.

Example

Set the dataSource property.

 <smart-input data-source='[{ label: "item 1", value: 1 }, { label: "item 2", value: 2 }]'></smart-input>

Set the dataSource property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.dataSource = ["new item 1", "new item 2"];

Get the dataSource property.

 const input = document.querySelector('smart-input');
 let dataSource = input.dataSource;

disabledboolean

Enables or disables the element.

Default value

false

Example

Set the disabled property.

 <smart-input disabled></smart-input>

Set the disabled property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.disabled = false;

Get the disabled property.

 const input = document.querySelector('smart-input');
 let disabled = input.disabled;

dropDownClassListarray

Sets additional class names to the Input drop down.

Example

Set the dropDownClassList property.

 <smart-input drop-down-class-list='my-custom-input-class-name'></smart-input>

Set the dropDownClassList property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.dropDownClassList = [];

Get the dropDownClassList property.

 const input = document.querySelector('smart-input');
 let dropDownClassList = input.dropDownClassList;

dropDownButtonPosition"none" | "left" | "right"

Determines the position of the drop down button.

Allowed Values

  • "none" - The drop down button is hidden and the element acts as a simple input.
  • "left" - A drop down button is displayed on the left side of the element. The element acts as a DropDownList or a ComboBox depending on the readonly property.
  • "right" - A drop down button is displayed on the right side of the element. The element acts as a DropDownList or a ComboBox depending on the readonly property.

Default value

"none"

Example

Set the dropDownButtonPosition property.

 <smart-input drop-down-button-position='top'></smart-input>

Set the dropDownButtonPosition property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.dropDownButtonPosition = 'bottom';

Get the dropDownButtonPosition property.

 const input = document.querySelector('smart-input');
 let dropDownButtonPosition = input.dropDownButtonPosition;

dropDownHeightstring | number

Sets the height of the drop down. By default it's set to an empty string. In this case the height of the drop down is controlled by a CSS variable.

Default value

""

Example

Set the dropDownHeight property.

 <smart-input drop-down-height='300'></smart-input>

Set the dropDownHeight property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.dropDownHeight = 500;

Get the dropDownHeight property.

 const input = document.querySelector('smart-input');
 let dropDownHeight = input.dropDownHeight;

dropDownWidthstring | number

Sets the width of the drop down. By default it's set to an empty string. In this case the width of the drop down is controlled by a CSS variable.

Default value

""

Example

Set the dropDownWidth property.

 <smart-input drop-down-width='300'></smart-input>

Set the dropDownWidth property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.dropDownWidth = 500;

Get the dropDownWidth property.

 const input = document.querySelector('smart-input');
 let dropDownWidth = input.dropDownWidth;

inputPurposestring

Sets the purpose of the input and what, if any, permission the user agent has to provide automated assistance in filling out the element's input when in a form, as well as guidance to the browser as to the type of information expected in the element. This value corresponds to the standard HTML autocomplete attribute and can be set to values such as 'on', 'name', 'organization', 'street-address', etc.

Default value

"off"

Example

Set the inputPurpose property.

 <smart-input input-purpose='on'></smart-input>

Set the inputPurpose property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.inputPurpose = 'country';

Get the inputPurpose property.

 const input = document.querySelector('smart-input');
 let inputPurpose = input.inputPurpose;

itemsnumber

Determines the maximum number of matched items that should be visible inside the drop down as a result of a new autoComplete query. By default the maximum number of 8 items can be displayed inside the drop down.

Default value

8

Example

Set the items property.

 <smart-input items='2'></smart-input>

Set the items property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.items = 5;

Get the items property.

 const input = document.querySelector('smart-input');
 let items = input.items;

localestring

Sets or gets the language. Used in conjunction with the property messages.

Default value

"en"

Example

Set the locale property.

 <smart-input locale='de'></smart-input>

Set the locale property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.locale = 'en';

Get the locale property.

 const input = document.querySelector('smart-input');
 let locale = input.locale;

localizeFormatFunctionfunction

Callback used to customize the format of the messages that are returned from the Localization Module.

Example

Set the localizeFormatFunction property.

 <smart-input localize-format-function='function(defaultMessage, message, messageArguments){return '...'}'></smart-input>

Set the localizeFormatFunction property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.localizeFormatFunction = function(defaultMessage, message, messageArguments){return '...'};

Get the localizeFormatFunction property.

 const input = document.querySelector('smart-input');
 let localizeFormatFunction = input.localizeFormatFunction;

messagesobject

Sets or gets an object specifying strings used in the widget that can be localized. Used in conjunction with the property locale.

Default value




"en": {

"propertyUnknownType": "'{{name}}' property is with undefined 'type' member!",

"propertyInvalidValue": "Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!",

"propertyInvalidValueType": "Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!",

"elementNotInDOM": "Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",

"moduleUndefined": "Module is undefined.",

"missingReference": "{{elementType}}: Missing reference to {{files}}.",

"htmlTemplateNotSuported": "{{elementType}}: Browser doesn't support HTMLTemplate elements.",

"invalidTemplate": "{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM.",

"invalidNode": "{{elementType}}: Invalid parameter '{{node}}' when calling {{method}}."

}

Example

Set the messages property.

 <smart-input messages='{"de":{"propertyUnknownType":"Die Eigenschaft '{{name}}' hat ein nicht definiertes 'type'-Member!","propertyInvalidValue":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualValue}}, Erwarteter Wert: {{value}}!","propertyInvalidValueType":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualType}}, Erwarteter Wert: {{type}}!","elementNotInDOM":"Element existiert nicht in DOM! Bitte fugen Sie das Element zum DOM hinzu, bevor Sie eine Methode aufrufen.","moduleUndefined":"Modul ist nicht definiert.","missingReference":"{{elementType}}: Fehlender Verweis auf {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser unterstutzt keine HTMLTemplate-Elemente.","invalidTemplate":"{{elementType}}: '{{property}}' Die Eigenschaft akzeptiert eine Zeichenfolge, die mit der ID eines HTMLTemplate-Elements aus dem DOM ubereinstimmen muss.","invalidNode":"{{elementType}}: Ungultiger Parameter '{{node}}' beim Aufruf von {{method}}."}}'></smart-input>

Set the messages property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.messages = {"en":{"propertyUnknownType":"'{{name}}' property is with undefined 'type' member!","propertyInvalidValue":"Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!","propertyInvalidValueType":"Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!","elementNotInDOM":"Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.","moduleUndefined":"Module is undefined.","missingReference":"{{elementType}}: Missing reference to {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser doesn't support HTMLTemplate elements.","invalidTemplate":"{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM.","invalidNode":"{{elementType}}: Invalid parameter '{{node}}' when calling {{method}}."}};

Get the messages property.

 const input = document.querySelector('smart-input');
 let messages = input.messages;

minLengthnumber

Determines the minimum number of characters inside the input in order to trigger the autocomplete functionality that will open the drop down and show the matched items.

Default value

1

Example

Set the minLength property.

 <smart-input min-length='2'></smart-input>

Set the minLength property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.minLength = 0;

Get the minLength property.

 const input = document.querySelector('smart-input');
 let minLength = input.minLength;

namestring

Sets or gets the name attribute for the element. Name is used when submiting data inside an HTML form.

Default value

""

Example

Set the name property.

 <smart-input name='dropdown'></smart-input>

Set the name property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.name = 'dropDown2';

Get the name property.

 const input = document.querySelector('smart-input');
 let name = input.name;

openedboolean

Determines whether the drop down is opened or not.

Default value

false

Example

Set the opened property.

 <smart-input opened></smart-input>

Set the opened property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.opened = false;

Get the opened property.

 const input = document.querySelector('smart-input');
 let opened = input.opened;

placeholderstring

Determines the placeholder of the input.

Default value

""

Example

Set the placeholder property.

 <smart-input placeholder='Empty'></smart-input>

Set the placeholder property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.placeholder = 'Enter:';

Get the placeholder property.

 const input = document.querySelector('smart-input');
 let placeholder = input.placeholder;

querystring | number

Sets or gets the query that is used to filter the items. Query is used by the autoComplete operation. Empty string means that all items from the data source will be displayed and no filter query is applied.

Default value

""

Example

Set the query property.

 <smart-input query='ABC'></smart-input>

Set the query property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.query = 'some query';

Get the query property.

 const input = document.querySelector('smart-input');
 let query = input.query;

queryMode"contains" | "containsIgnoreCase" | "doesNotContain" | "doesNotContainIgnoreCase" | "equals" | "equalsIgnoreCase" | "startsWith" | "startsWithIgnoreCase" | "endsWith" | "endsWithIgnoreCase"

Determines the auto complete query mode. This property also determines the matching algorithm for the autocomplete operation.

Allowed Values

  • "contains" - Displays the items that contain the search query (case sensitive)
  • "containsIgnoreCase" - Displays the items that contain the search query (case insensitive)
  • "doesNotContain" - Displays the items that do not contain the search query (case sensitive)
  • "doesNotContainIgnoreCase" - Displays the items that do not contain the search query (case insensitive)
  • "equals" - Displays the items that are equal the search query (case sensitive)
  • "equalsIgnoreCase" - Displays the items that are equal the search query (case insensitive)
  • "startsWith" - Displays the items that start with the search query (case sensitive)
  • "startsWithIgnoreCase" - Displays the items that start with the search query (case insensitive)
  • "endsWith" - Displays the items that end with the search query (case sensitive)
  • "endsWithIgnoreCase" - Displays the items that start with the search query (case insensitive)

Default value

"containsIgnoreCase"

Example

Set the queryMode property.

 <smart-input query-mode='contains'></smart-input>

Set the queryMode property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.queryMode = 'endsWith';

Get the queryMode property.

 const input = document.querySelector('smart-input');
 let queryMode = input.queryMode;

readonlyboolean

Determines whether ot not the user can enter text inside the input. if dropDownButtonPosition is set to 'left' or 'right' then readonly determines whether the element acts as a ComboBox or a DropDownList if a dataSource is provided.

Default value

false

Example

Set the readonly property.

 <smart-input readonly></smart-input>

Set the readonly property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.readonly = false;

Get the readonly property.

 const input = document.querySelector('smart-input');
 let readonly = input.readonly;

rightToLeftboolean

Sets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.

Default value

false

Example

Set the rightToLeft property.

 <smart-input right-to-left></smart-input>

Set the rightToLeft property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.rightToLeft = true;

Get the rightToLeft property.

 const input = document.querySelector('smart-input');
 let rightToLeft = input.rightToLeft;

sortedboolean

Determines whether the items are sorted alphabetically or not

Default value

false

Example

Set the sorted property.

 <smart-input sorted></smart-input>

Set the sorted property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.sorted = false;

Get the sorted property.

 const input = document.querySelector('smart-input');
 let sorted = input.sorted;

sortDirectionstring

Determines the sorting algorithm - ascending(asc) or descending(desc) if sort is enabled.

Default value

"asc"

Example

Set the sortDirection property.

 <smart-input sort-direction='desc'></smart-input>

Set the sortDirection property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.sortDirection = 'asc';

Get the sortDirection property.

 const input = document.querySelector('smart-input');
 let sortDirection = input.sortDirection;

selectedIndexnumber

Determines the selected index.

Default value

-1

Example

Set the selectedIndex property.

 <smart-input selected-index='2'></smart-input>

Set the selectedIndex property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.selectedIndex = 0;

Get the selectedIndex property.

 const input = document.querySelector('smart-input');
 let selectedIndex = input.selectedIndex;

selectedValuestring | number

Determines the selected value.

Default value

""

Example

Set the selectedValue property.

 <smart-input selected-value='2'></smart-input>

Set the selectedValue property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.selectedValue = 0;

Get the selectedValue property.

 const input = document.querySelector('smart-input');
 let selectedValue = input.selectedValue;

themestring

Determines the theme for the element. Themes define the look of the elements.

Default value

""

Example

Set the theme property.

 <smart-input theme='blue'></smart-input>

Set the theme property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.theme = 'red';

Get the theme property.

 const input = document.querySelector('smart-input');
 let theme = input.theme;

typestring

Determines the input type. Input type determines what input can be entered.

Default value

""

Example

Set the type property.

 <smart-input type='blue'></smart-input>

Set the type property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.type = 'red';

Get the type property.

 const input = document.querySelector('smart-input');
 let type = input.type;

unfocusableboolean

If is set to true, the element cannot be focused.

Default value

false

Example

Set the unfocusable property.

 <smart-input unfocusable></smart-input>

Set the unfocusable property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.unfocusable = false;

Get the unfocusable property.

 const input = document.querySelector('smart-input');
 let unfocusable = input.unfocusable;

valuestring

Sets or gets the value of the element.

Default value

""

Example

Set the value property.

 <smart-input value='value1'></smart-input>

Set the value property by using the HTML Element's instance.

 const input = document.querySelector('smart-input');
 input.value = 'value2';

Get the value property.

 const input = document.querySelector('smart-input');
 let value = input.value;

Events

changeCustomEvent

This event is triggered when the selection is changed.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onChange

Arguments

evCustomEvent
ev.detailObject
ev.detail.label - The label of the new selected item.
ev.detail.oldLabel - The label of the item that was previously selected before the event was triggered.
ev.detail.oldValue - The value of the item that was previously selected before the event was triggered.
ev.detail.value - The value of the new selected item.

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of change event.

const input = document.querySelector('smart-input');
input.addEventListener('change', function (event) {
    const detail = event.detail,
        label = detail.label,
        oldLabel = detail.oldLabel,
        oldValue = detail.oldValue,
        value = detail.value;

	// event handling code goes here.
})

changingCustomEvent

This event is triggered on each key up event of the Input, if the value is changed.

  • Bubbles Yes
  • Cancelable Yes
  • Interface CustomEvent
  • Event handler property onChanging

Arguments

evCustomEvent
ev.detailObject
ev.detail.oldValue - The previous value before it was changed.
ev.detail.value - The new value.

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of changing event.

const input = document.querySelector('smart-input');
input.addEventListener('changing', function (event) {
    const detail = event.detail,
        oldValue = detail.oldValue,
        value = detail.value;

	// event handling code goes here.
})

openCustomEvent

This event is triggered when the popup is opened.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onOpen

Arguments

evCustomEvent

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of open event.

const input = document.querySelector('smart-input');
input.addEventListener('open', function (event) {
	// event handling code goes here.
})

closeCustomEvent

This event is triggered when the popup is closed.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onClose

Arguments

evCustomEvent

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of close event.

const input = document.querySelector('smart-input');
input.addEventListener('close', function (event) {
	// event handling code goes here.
})

itemClickCustomEvent

This event is triggered when the user clicks on an item from the popup list.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onItemClick

Arguments

evCustomEvent
ev.detailObject
ev.detail.item - The item that was clicked.
ev.detail.label - The label of the item that was clicked.
ev.detail.value - The value of the item that was clicked.

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of itemClick event.

const input = document.querySelector('smart-input');
input.addEventListener('itemClick', function (event) {
    const detail = event.detail,
        item = detail.item,
        label = detail.label,
        value = detail.value;

	// event handling code goes here.
})

Methods

close(): void

Closes the drop down.


Invoke the close method.

const input = document.querySelector('smart-input');
input.close();

Try a demo showcasing the close method.

ensureVisible(): void

Ensures that the active ( selected ) item is always visible.


Invoke the ensureVisible method.

const input = document.querySelector('smart-input');
input.ensureVisible();

open(): void

Opens the drop down.


Invoke the open method.

const input = document.querySelector('smart-input');
input.open();

Try a demo showcasing the open method.

select(): void

Focuses and selects the text inside the input or if it is readonly then the element is focused.


Invoke the select method.

const input = document.querySelector('smart-input');
input.select();

selectItem( value: string | number): void

Selects an item by value. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'], you can use 'Item 1' as an argument. If your data source is an object with label and value, pass the value when you call selectItem.

Arguments

valuestring | number

The item's value when the item is an object or string when the item is a string item.


Invoke the selectItem method.

const input = document.querySelector('smart-input');
input.selectItem("1","2");

getItem( value: string | number): any

Gets an item by value. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'], you can use 'Item 1' as an argument. If your data source is an object with label and value, pass the value when you call selectItem.

Arguments

valuestring | number

The item's value when the item is an object or string when the item is a string item.

Returnsany

Invoke the getItem method.

const input = document.querySelector('smart-input');
const result = input.getItem("1","2");

getSelectedItem( value: string | number): any

Gets the selected item. For example, if your data source is ['Item 1', 'Item 2', 'Item 3'] and the user selected the second item, the method returns 'Item 2'. If your data source is an object with label and value, the returned value would be the 'value'.

Arguments

valuestring | number

The item's value when the item is an object or string when the item is a string item.

Returnsany

Invoke the getSelectedItem method.

const input = document.querySelector('smart-input');
const result = input.getSelectedItem("1","2");