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

@commercetools-uikit/creatable-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/creatable-select-input

## Description

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

Version published
Weekly downloads
3.3K
increased by18.64%
Maintainers
3
Weekly downloads
 
Created
Source

CreatableSelectInput

Description

An input component getting a selection from the user, and where options can also be created by the user.

Usage

import CreatableSelectInput from '@commercetools-uikit/creatable-select-input';

<CreatableSelectInput
  name="form-field-name"
  value={value}
  onChange={handleChange}
  options={[
    { value: 'one', label: 'One' },
    { value: 'two', label: 'Two' },
  ]}
/>;

Properties

PropsTypeRequiredValuesDefaultDescription
horizontalConstraintobject-s, m, l, xl, scalescaleHorizontal size limit of the input fields.
hasErrorbool---Indicates the input field has an error
hasWarningbool---Indicates the input field has a warning
aria-labelstring---Aria label (for assistive tech)
aria-labelledbystring---HTML ID of an element that should be used as the label (for assistive tech)
isAutofocussedbool---Focus the control when it is mounted
backspaceRemovesValuebool--trueRemove 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
filterOptionfunc---Custom method to filter whether an option should be displayed in the menu
idstring---The id of the search input
containerIdstring---The id to set on the SelectContainer component
isClearablebool---Is the select value clearable
isDisabledbool---Is the select disabled
isReadOnlybool---Is the select read-only
isOptionDisabledfunc---Override the built-in logic to detect whether an option is disabled
isMultibool---Support multiple selected options
isSearchablebool--trueWhether to enable search functionality
maxMenuHeightnumber---Maximum height of the menu before scrolling
menuPortalTargetHTMLElement---Dom element to portal the select menu to
menuPortalZIndexnumber---z-index value for the menu portal
menuShouldBlockScrollbool--falsewhether the menu should block scroll while open
namestring---Name of the HTML Input (optional - without this, no input will be rendered)
noOptionsMessagefunc---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.
onBlurfunc---Handle blur events on the control
onChangefunc--Called 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.
onFocusfunc---Handle focus events on the control
onInputChangefunc---Handle change events on the input
optionsarrayOf()---Array of options that populate the select menu
placeholderstring---Placeholder text for the select value
tabIndexstring--"0"Sets the tabIndex attribute on the input
tabSelectsValuebool--trueSelect the currently focused option when the user presses tab
valuestring / array---The value of the select; reflected by the selected option
allowCreateWhileLoadingbool---Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded.
formatCreateLabelfunc---Gets the label for the "create new ..." option in the menu. Is given the current input value.
isValidNewOptionfunc---Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
getNewOptionDatafunc---Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
onCreateOptionfunc---If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.
createOptionPositionstring-"first", "last""last"Sets the position of the createOption element in your options list.
showOptionGroupDividerboolean--falseDetermines if option groups will be separated by a divider

This input is built on top of react-select v2. It supports mostly same properties as react-select. Behaviour 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.

options

The options support a isDisabled property which will render the option with a disabled style and will prevent users from selecting it.

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 17 Aug 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