@ui5/webcomponents-react
Version:
React Wrapper for UI5 Web Components and additional components
42 lines (41 loc) • 2.85 kB
JavaScript
'use client';
import '@ui5/webcomponents/dist/Input.js';
import { withWebComponent } from '../../internal/withWebComponent.js';
/**
* The `Input` component allows the user to enter and edit text or numeric values in one line.
*
* Additionally, you can provide `suggestionItems`,
* that are displayed in a popover right under the input.
*
* The text field can be editable or read-only (`readonly` property),
* and it can be enabled or disabled (`disabled` property).
* To visualize semantic states, such as "Negative" or "Critical", the `valueState` property is provided.
* When the user makes changes to the text, the change event is fired,
* which enables you to react on any text change.
*
* **Note:** If you are using the `Input` as a single npm module,
* don't forget to import the `InputSuggestions` module from
* "@ui5/webcomponents/dist/features/InputSuggestions.js"
* to enable the suggestions functionality.
*
* ### Keyboard Handling
* The `Input` provides the following keyboard shortcuts:
*
* - [Escape] - Closes the suggestion list, if open. If closed or not enabled, cancels changes and reverts to the value which the Input field had when it got the focus.
* - [Enter] or [Return] - If suggestion list is open takes over the current matching item and closes it. If value state or group header is focused, does nothing.
* - [Down] - Focuses the next matching item in the suggestion list. Selection-change event is fired.
* - [Up] - Focuses the previous matching item in the suggestion list. Selection-change event is fired.
* - [Home] - If focus is in the text input, moves caret before the first character. If focus is in the list, highlights the first item and updates the input accordingly.
* - [End] - If focus is in the text input, moves caret after the last character. If focus is in the list, highlights the last item and updates the input accordingly.
* - [Page Up] - If focus is in the list, moves highlight up by page size (10 items by default). If focus is in the input, does nothing.
* - [Page Down] - If focus is in the list, moves highlight down by page size (10 items by default). If focus is in the input, does nothing.
*
*
*
* `import "@ui5/webcomponents/dist/features/InputSuggestions.js";` (optional - for input suggestions support)
*
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)
*/
const Input = withWebComponent('ui5-input', ['accessibleName', 'accessibleNameRef', 'maxlength', 'name', 'placeholder', 'type', 'value', 'valueState'], ['disabled', 'noTypeahead', 'open', 'readonly', 'required', 'showClearIcon', 'showSuggestions'], ['icon', 'valueStateMessage'], ['change', 'close', 'input', 'open', 'select', 'selection-change']);
Input.displayName = 'Input';
export { Input };