19.2.0 • Published 3 days ago

@commercetools-uikit/search-text-input v19.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

SearchTextInput

Description

A controlled search text input component for single-line strings with validation states.

Installation

yarn add @commercetools-uikit/search-text-input
npm --save install @commercetools-uikit/search-text-input

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import SearchTextInput from '@commercetools-uikit/search-text-input';

const Example = () => (
  <SearchTextInput
    value="foo"
    onChange={(event) => alert(event.target.value)}
    onSubmit={(val) => alert(val)}
    onReset={() => alert('reset')}
  />
);

export default Example;

Properties

PropsTypeRequiredDefaultDescription
idstringUsed as HTML id property. An id is auto-generated when it is not specified.
autoCompletestringUsed as HTML autocomplete property
aria-invalidbooleanIndicate if the value entered in the input is invalid.
aria-errormessagestringHTML ID of an element containing an error message related to the input.
namestringUsed as HTML name of the input component property.
valuestringValue of the input component.
onChangeChangeEventHandlerCalled with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
onBlurFocusEventHandlerCalled when input is blurred
onFocusFocusEventHandlerCalled when input is focused
onSubmitFunctionSee signature.Handler when the search button is clicked.
onResetFunctionSee signature.Handler when the clear button is clicked.
isAutofocussedbooleanFocus the input on initial render
isDisabledbooleanIndicates that the input cannot be modified (e.g not authorized, or changes currently saving).
isReadOnlybooleanIndicates that the field is displaying read-only content
hasErrorbooleanIndicates if the input has invalid values
hasWarningbooleanIndicates if the input has warning values
placeholderstringPlaceholder text for the input
isClearablebooleantrueIndicates if the input should be cleared when the clear button is clicked. Defaults to true.
horizontalConstraintunionPossible values:, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto''scale'Horizontal size limit of the input fields.

Signatures

Signature onSubmit

(searchValue: string) => void

Signature onReset

() => void

data-* props

The component further forwards all data- attributes to the underlying input component.

Static methods

SearchTextInput.isEmpty

Returns true when the value is considered empty, which is when the value is empty or consists of spaces only.

SearchTextInput.isEmpty(''); // -> true
SearchTextInput.isEmpty(' '); // -> true
SearchTextInput.isEmpty('tree'); // -> false

Main Functions and use cases are:

  • Input field for single-line strings. Used for search.
19.2.0

7 days ago

19.1.0

19 days ago

19.0.0

1 month ago

18.5.0

2 months ago

18.4.0

2 months ago

18.3.0

2 months ago

18.2.0

2 months ago

18.1.0

3 months ago

18.0.0

3 months ago

17.1.0

3 months ago

17.0.1

3 months ago

17.0.0

4 months ago

16.12.1

5 months ago

16.12.0

5 months ago

16.9.0

6 months ago

16.11.0

6 months ago

16.5.0

10 months ago

16.10.0

6 months ago

16.6.1

9 months ago

16.6.0

9 months ago

16.7.3

8 months ago

16.7.2

8 months ago

16.7.1

8 months ago

16.7.0

9 months ago

16.7.5

8 months ago

16.7.4

8 months ago

16.8.0

6 months ago

16.4.1

10 months ago

16.4.0

10 months ago

16.2.1

11 months ago

16.3.0

11 months ago

16.2.0

11 months ago

16.1.1

12 months ago

16.1.0

12 months ago

15.15.0

1 year ago

15.15.1

1 year ago

16.0.0

1 year ago

15.13.2

1 year ago

15.14.3

1 year ago

15.14.1

1 year ago

15.14.2

1 year ago

15.14.0

1 year ago

15.13.1

1 year ago

15.13.0

1 year ago

15.12.0

1 year ago