1.2.1 • Published 5 years ago

@crpt/react-select v1.2.1

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

react-select

Travis npm package Coveralls

SingleSelect and MultiSelect React components.

Install

npm i --save @crpt/react-select

Usage

import { SingleSelect, MultiSelect } from "@crpt/react-select";

<SingleSelect onSelect={val => console.log(vaL)} values={[{id:1, title: "Left"}, {id:2, title: "Right"]} />

SingleSelect

PropNameDescriptionExample
values: Array (Required)Values. See Note1<SingleSelect values=[{id:1, title: "value 1"}, {id: 2, title: "value 2"}] />
disabled: BooleanCan be disabled.<SingleSelect disabled />
onSelect: FunctionCallback for select event.<SingleSelect onSelect={val => console.log(val)} />
onChange: FunctionCallback for change event
placeholder: StringPlaceholder value.<SingleSelect placeholder="Some placeholder" />
savePlaceholder: BooleanWhen true, placeholder's text is placed on top if any of value is selected and in the center otherwise
selectedId: IntegerIf passed, child with id = selectedId becomes selected.<SingleSelect values=[{id:1, title: "value 1"}, {id: 2, title: "value 2"}] selectedId={2} />
truncate: BooleanLong text truncation. Select options width will not exceed input width.<SingleSelect truncate values=[{id:1, title: "very looong text"}] />
multiline: BooleanLong text wrap.<SingleSelect multiline values=[{id:1, title: "very looong text"}] />
isLoading: BooleanIf true, there is "Загрузка..." displayed on drop list
RenderValues: React element or functionIt is a function for rendering title to inputText.See note 2.
RenderOption: React element or functionIt is rendered instead of all of titles in values (working with renderValue)
RenderIcon: React element or functionIt is rendered instead of option selected icon
onRefReturn {this of SingleSelect} in componentDidMount and undefined in componentWillUnmount
hideOptionsPanel: BooleanIf true optionList isn't shown
withoutIcon: BooleanSeach and BottomArrow Icons are not shown when properties is true
filterDisabled: BooleanWhen you are writing in text field, option list is filtered using typing text. If filterDisabled is true optionList isn't filtered
iconPosition: StringIcon position. Default: 'right'
showPointer: BooleanShow options panel dialog pointer. Default: false
noValuesText: StringShow text if values empty
onTogglePanel: FunctionCallback on toggle Options Panel
rightIconReplacer: JSX expressionreplaces right icon

Note1. Values is array of objects. You can add any properties and then use renderValue or renderOption for render them. But some properties are special.

Property nameProperty typeProperty description
id (required)NumberMust be unique integer
value (required)String or elementValue is returned on onSelect
title (required)String or elementTitle is shown on the text field after the select
titleTextString or elementTitle for textField. If undefined title field is displayed
titleOptionString or elementTitle for optionList. If undefined title field is displayed
filterStringStringIf defined filter process use this properties instead of title
disabledBooleanCan't select option if disabled

Examples of title:

  • simple title:
title: 'empty'
  • object title:
title: (
  <div>
    Title <b>text</b> here
  </div>)

Note 2 RenderOption. Values item properties are passed to function using value propertie. Renders function example: RenderValue. Values item properties are passed to function using selected and value (it's the same) property. Renders function example:

const renderOption = (props) => (
  <div>
    To option field:<br/>
    <b>{props.value.prop1}</b><br/>
    <i>{props.value.prop2}</i>
  </div>
);

MultiSelect

PropNameDescriptionExample
values: Array (Required)Values.<MultiSelect values=[{id:1, title: "value 1"}, {id: 2, title: "value 2"}] />
disabled: BooleanCan be disabled.<MultiSelect disabled />
onSelect: FunctionCallback for select event.<MultiSelect onSelect={val => console.log(val)} />
placeholder: StringPlaceholder value.<MultiSelect placeholder="Some placeholder" />
selectedIds: ArrayIf passed, childs with id in selectedIds becomes selected.<MultiSelect values=[{id:1, title: "value 1"}, {id: 2, title: "value 2"}] selectedIds={[1,2]} />
truncate: BooleanLong text truncation. Select options width will not exceed input width.<MultiSelect truncate values=[{id:1, title: "very looong text"}] />
multiline: BooleanLong text wrap.<MultiSelect multiline values=[{id:1, title: "very looong text"}] />
iconPosition: StringIcon position. Default: 'right'
showPointer: BooleanShow options panel dialog pointer. Default: false
noValuesText: StringShow text if values empty
onTogglePanel: FunctionCallback on toggle Options Panel
1.2.1

5 years ago

1.2.0

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.53

5 years ago

1.0.52

5 years ago

1.0.51

5 years ago

1.0.50

5 years ago

1.0.49

5 years ago

1.0.48

5 years ago

1.0.47

5 years ago

1.0.46

5 years ago

1.0.45

5 years ago

1.0.44

5 years ago

1.0.43

5 years ago

1.0.42

5 years ago

1.0.41

5 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago