19.2.0 • Published 4 days ago

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

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

SelectableSearchInput

Description

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

Installation

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

Additionally install the peer dependencies (if not present)

yarn add react react-intl
npm --save install react react-intl

Usage

import SelectableSearchInput from '@commercetools-uikit/selectable-search-input';

const value = {
  text: 'foo',
  option: 'bar',
};

const Example = () => (
  <SelectableSearchInput
    value={value}
    onChange={(event) => alert(event.target.value)}
    onSubmit={(val) => alert(val)}
    onReset={() => alert('reset')}
    options={[
      { value: 'one', label: 'One' },
      { value: 'two', label: 'Two' },
    ]}
  />
);

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.
valueObjectSee signature.Value of the input. Consists of text input and selected option.
onChangeFunctionSee signature.Called with the event of the input or dropdown when either the selectable dropdown or the text input have changed. The change event from the text input has a suffix of .textInput and the change event from the dropdown has a suffix of .dropdown.
onBlurFunctionSee signature.Called when input is blurred
onFocusFunctionSee signature.Called 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:10 , 11 , 12 , 13 , 14 , 15 , 16 , 'scale' , 'auto''scale'Horizontal size limit of the input fields.
optionsunionPossible values:TOption[] , TOptionObject[]Array of options that populate the select menu
menuPortalZIndexnumberz-index value for the menu portal
menuPortalTargetReactSelectProps['menuPortalTarget']Dom element to portal the select menu to Props from React select was used
menuShouldBlockScrollReactSelectProps['menuShouldBlockScroll']whether the menu should block scroll while open Props from React select was used
onMenuInputChangeReactSelectProps['onInputChange']Handle change events on the menu input Props from React select was used
noMenuOptionsMessageReactSelectProps['noOptionsMessage']Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with { inputValue: String }. inputValue will be an empty string when no search text is present. Props from React select was used
isMenuSearchableReactSelectProps['isSearchable']Whether to enable search functionality. Props from React select was used
maxMenuHeightReactSelectProps['maxMenuHeight']Maximum height of the menu before scrolling Props from React select was used
closeMenuOnSelectReactSelectProps['closeMenuOnSelect']Whether the menu should close after a value is selected. Defaults to true. Props from React select was used
menuHorizontalConstraintunionPossible values:3 , 4 , 53Horizontal size limit for the dropdown menu.
showSubmitButtonbooleantrueShow submit button in the input

Signatures

Signature value

{
  text: string;
  option: string;
}

Signature onChange

(event: TCustomEvent) => void

Signature onBlur

(event: TCustomEvent) => void

Signature onFocus

(event: TCustomEvent) => void

Signature onSubmit

(value: TValue) => void

Signature onReset

() => void

data-* props

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

Static methods

SelectableSearchInput.isEmpty

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

SelectableSearchInput.isEmpty({
  text: '',
  option: '',
}); // -> true
SelectableSearchInput.isEmpty({
  text: '    ',
  option: 'bar',
}); // -> true
SelectableSearchInput.isEmpty({
  text: 'foo',
  option: 'bar',
}); // -> false

Main Functions and use cases are:

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

4 days ago

19.1.0

16 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

5 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

8 months ago

16.7.5

7 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.3.0

11 months ago

16.2.1

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.14.3

1 year ago

15.14.1

1 year ago

15.13.2

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