Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools-uikit/select-field

Package Overview
Dependencies
Maintainers
0
Versions
1032
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools-uikit/select-field

A controlled input component with validation states and a label getting a selection from the user.

  • 19.16.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
increased by14.83%
Maintainers
0
Weekly downloads
 
Created
Source

SelectField

Description

A controlled input component with validation states and a label getting a selection from the user.

Installation

yarn add @commercetools-uikit/select-field
npm --save install @commercetools-uikit/select-field

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import SelectField from '@commercetools-uikit/select-field';

const Example = () => (
  <SelectField
    title="State"
    value="ready"
    options={[
      { value: 'ready', label: 'Ready' },
      { value: 'shipped', label: 'Shipped' },
    ]}
    onChange={(event) => alert(event.target.value)}
  />
);

export default Example;

Properties

PropsTypeRequiredDefaultDescription
idstringUsed as HTML id property. An id is generated automatically when not provided.
horizontalConstraintunion
Possible values:
, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'
'scale'
errorsObject
See signature.
A map of errors. Error messages for known errors are rendered automatically.
Unknown errors will be forwarded to renderError.
renderErrorFunction
See signature.
This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
warningsRecordA map of warnings. Warning messages for known warnings are rendered automatically.
Unknown warnings will be forwarded to renderWarning.
renderWarningFunction
See signature.
Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
It can also return null to show no warning.
isRequiredbooleanIndicates if the value is required. Shows an the "required asterisk" if so.
touchedunion
Possible values:
boolean[] , boolean
Indicates whether the field was touched. Errors will only be shown when the field was touched.
appearanceunion
Possible values:
'default' , 'quiet'
Indicates the appearance of the input. Quiet appearance is meant to be used with the horizontalConstraint="auto".
aria-labelReactSelectProps['aria-label']Aria label (for assistive tech)
Props from React select was used
aria-labelledbyReactSelectProps['aria-labelledby']HTML ID of an element that should be used as the label (for assistive tech)
Props from React select was used
isAutofocussedbooleanFocus the control when it is mounted
backspaceRemovesValuebooleanRemove the currently focused option when the user presses backspace
componentsReactSelectProps['components']Map of components to overwrite the default ones, see what components you can override
Props from React select was used
controlShouldRenderValueReactSelectProps['controlShouldRenderValue']Control whether the selected values should be rendered in the control
Props from React select was used
filterOptionReactSelectProps['filterOption']Custom method to filter whether an option should be displayed in the menu
Props from React select was used
containerIdstringThe id to set on the SelectContainer component
isClearablebooleanIs the select value clearable
isDisabledbooleanIs the select disabled
isReadOnlybooleanIs the select read-only
isCondensedbooleanWhether the input and its options are rendered with condensed paddings
isOptionDisabledReactSelectProps['isOptionDisabled']Override the built-in logic to detect whether an option is disabled
Props from React select was used
isMultibooleanSupport multiple selected options
isSearchablebooleanWhether to enable search functionality
maxMenuHeightnumberMaximum height of the menu before scrolling
menuPortalTargetReactSelectProps['menuPortalTarget']Dom element to portal the select menu to
Props from React select was used
menuPortalZIndexnumberz-index value for the menu portal
Use in conjunction with menuPortalTarget
menuShouldBlockScrollbooleanwhether the menu should block scroll while open
namestringName of the HTML Input (optional - without this, no input will be rendered)
noOptionsMessageReactSelectProps['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
onBlurFunction
See signature.
Handle blur events on the control
onChangeFunction
See signature.
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.
onFocusReactSelectProps['onFocus']Handle focus events on the control
Props from React select was used
onInputChangeReactSelectProps['onInputChange']Handle change events on the input
Props from React select was used
optionsunion
Possible values:
TOption[] , TOptionObject[]
Array of options that populate the select menu
showOptionGroupDividerboolean
placeholderstringPlaceholder text for the select value
tabIndexReactSelectProps['tabIndex']Sets the tabIndex attribute on the input
Props from React select was used
tabSelectsValuebooleanSelect the currently focused option when the user presses tab
valueReactSelectProps['value']The value of the select; reflected by the selected option
Props from React select was used
titleReactNodeTitle of the label
hintReactNodeHint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.
Can also receive a hintIcon.
descriptionReactNodeProvides a description for the title.
onInfoButtonClickFunction
See signature.
Function called when info button is pressed.
Info button will only be visible when this prop is passed.
hintIconReactElementIcon to be displayed beside the hint text. Will only get rendered when hint is passed as well.
badgeReactNodeBadge to be displayed beside the label. Might be used to display additional information about the content of the field (E.g verified email)
hasWarningbooleanControl to indicate on the input if there are selected values that are potentially invalid @deprecated Please use the warnings prop instead so users know the reason why the field is in warning state.
iconLeftReactNodeIcon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
inputValueReactSelectProps['inputValue']The value of the search input
Props from React select was used

Signatures

Signature errors

{
  missing?: boolean;
}

Signature renderError

(key: string, error?: boolean) => ReactNode;

Signature renderWarning

(key: string, warning?: boolean) => ReactNode;

Signature onBlur

(event: TCustomEvent) => void

Signature onChange

(event: TCustomEvent) => void

Signature onInfoButtonClick

(
  event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
) => void

Keywords

FAQs

Package last updated on 14 Nov 2024

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