New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools-uikit/async-select-input

Package Overview
Dependencies
Maintainers
3
Versions
1018
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools-uikit/async-select-input

<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. --> <!-- This file is created by the `yarn generate-readme` script. -->

  • 0.0.0-canary-20208111242
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.1K
increased by31.99%
Maintainers
3
Weekly downloads
 
Created
Source

AsyncSelectInput

Description

An input component getting a selection from an asynchronously loaded list from the user.

Installation

yarn add @commercetools-uikit/async-select-input
npm --save install @commercetools-uikit/async-select-input

Additionally install the peer dependencies (if not present)

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

Usage

import React from 'react';
import PropTypes from 'prop-types';
import AsyncSelectInput from '@commercetools-uikit/async-select-input';

const Example = (props) => (
  <AsyncSelectInput
    name="form-field-name"
    value={props.value}
    onChange={
      (/** event */) => {
        // console.log(event)
      }
    }
    options={[
      { value: 'one', label: 'One' },
      { value: 'two', label: 'Two' },
    ]}
  />
);

Example.propTypes = {
  value: PropTypes.string,
};

export default Example;

Properties

PropsTypeRequiredDefaultDescription
horizontalConstraintenum
Possible values:
's' | 'm' | 'l' | 'xl' | 'scale'
Horizontal size limit of the input fields.
hasErrorboolIndicates the input field has an error
hasWarningboolIndicates the input field has a warning
isReadOnlyboolIndicates that the field is displaying read-only content
aria-labelstringAria label (for assistive tech)
aria-labelledbystringHTML ID of an element that should be used as the label (for assistive tech)
isAutofocussedboolFocus the control when it is mounted
backspaceRemovesValueboolRemove the currently focused option when the user presses backspace
componentsobjectOf(func)Map of components to overwrite the default ones, see what components you can override
filterOptionfuncCustom method to filter whether an option should be displayed in the menu
idstringThe id of the search input
inputValuestring
containerIdstringThe id to set on the SelectContainer component
isClearableboolIs the select value clearable
isDisabledboolIs the select disabled
isOptionDisabledfuncOverride the built-in logic to detect whether an option is disabled
isMultiboolSupport multiple selected options
isSearchablebooltrueWhether to enable search functionality
maxMenuHeightnumberMaximum height of the menu before scrolling
menuPortalTargetSafeHTMLElementDom element to portal the select menu to
menuPortalZIndexnumber1z-index value for the menu portal
menuShouldBlockScrollboolwhether the menu should block scroll while open
namestringName of the HTML Input (optional - without this, no input will be rendered)
noOptionsMessagefuncCan 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.
onBlurfuncHandle blur events on the control
onChangefuncCalled with a fake event when value changes. The event's target.name will be the name supplied in props. The event's target.value will hold the value. The value will be the selected option, or an array of options in case isMulti is true.
onFocusfuncHandle focus events on the control
onInputChangefuncHandle change events on the input
placeholderstringPlaceholder text for the select value
tabIndexstringSets the tabIndex attribute on the input
tabSelectsValueboolSelect the currently focused option when the user presses tab
valuecustomnullThe value of the select; reflected by the selected option
defaultOptions<bool|arrayOf>The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded.
defaultOptions<arrayOf>array
defaultOptions<arrayOf>[].valuestring
loadOptionsfuncFunction that returns a promise, which is the set of options to be used once the promise resolves.
cacheOptionsanyIf cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
showOptionGroupDividerboolDetermines if option groups will be separated by a divider
iconLeftnodeIcon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.

This input is built on top of react-select v2. It supports mostly same properties as react-select. Behavior for some props was changed, and support for others was dropped.

In case you need one of the currently excluded props, feel free to open a PR adding them.

Static Properties

isTouched(touched)

Expects to be called with an array or boolean. Returns true when truthy.

Components

It is possible to customize SelectInput by passing the components property. SelectInput exports the default underlying components as static exports.

Components available as static exports are:

  • ClearIndicator
  • Control
  • DropdownIndicator
  • DownChevron
  • CrossIcon
  • Group
  • GroupHeading
  • IndicatorsContainer
  • IndicatorSeparator
  • Input
  • LoadingIndicator
  • Menu
  • MenuList
  • MenuPortal
  • LoadingMessage
  • NoOptionsMessage
  • MultiValue
  • MultiValueContainer
  • MultiValueLabel
  • MultiValueRemove
  • Option
  • Placeholder
  • SelectContainer
  • SingleValue
  • ValueContainer

See the official documentation for more information about the props they receive.

FAQs

Package last updated on 11 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc