3.5.88 • Published 5 years ago

the-input v3.5.88

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

the-input

Build Status npm Version JS Standard

Input of the-components

Installation

$ npm install the-input --save

Usage

Live Demo is hosted on GitHub Page

'use strict'

import React from 'react'
import { TheInput, TheInputStyle } from 'the-input'
import { TheSpinStyle } from 'the-spin'

class ExampleComponent extends React.PureComponent {
  constructor (props) {
    super(props)
    this.state = {
      values: {}
    }
    this.onUpdate = this.onUpdate.bind(this)
  }

  onUpdate (values) {
    console.log('values', values)
    this.setState({
      values: Object.assign({}, this.state.values, values)
    })
  }

  render () {
    const { values } = this.state
    const { onUpdate } = this

    const {
      Text,
      Password,
      Search,
      Number,
      TextArea,
      Radio,
      Checkbox,
      Select,
      Toggle,
      PinCode,
      Slider,
      Range,
      Upload,
      Date,
      Tag
    } = TheInput
    return (
      <div>
        <TheInputStyle/>
        <TheSpinStyle/>

        <h3>Text</h3>

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              placeholder='value01'
              options={['Banana', 'Orange', 'Apple']}
        />

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              parser={(v) => String(v).toUpperCase()}
              placeholder='value01 only with uppercase parser'
              autoCapitalize={false}
              selectWhenFocused
              autoCorrect="off"
              options={['Banana', 'Orange', 'Apple']}
        />

        <Text name='value01'
              value={values['value01']}
              prefix={'Oh!'}
              suffix={', Yes it is!'}
              onUpdate={onUpdate}
              placeholder='value01'
              options={['Banana', 'Orange', 'Apple']}
        />

        <h3>Text with hint</h3>

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              placeholder='eg: hoge@example.com'
              pattern={Text.EMAIL_PATTERN}
              patternHint='Needs to be email'
        />

        <h3>Select on focus</h3>

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              placeholder='Select on focus'
              selectOnFocus
        />

        <br/>

        <h3>Search</h3>
        <Search name='value01'
                value={values['value01']}
                onUpdate={onUpdate}
                placeholder='value01'
        />


        <br/>

        <h3>Password</h3>
        <Password name='value01'
                  value={values['value01']}
                  onUpdate={onUpdate}
                  placeholder='value01'
        />

        <br/>

        <h3>Text Area</h3>
        <TextArea name='value01'
                  value={values['value01']}
                  onUpdate={onUpdate}
                  onCombineEnter={() => console.log('combine enter')}
                  onEnter={() => console.log('enter')}
                  placeholder='value01'
        />

        <TextArea name='value01'
                  autoExpand
                  minRows={1}
                  maxRows={8}
                  value={values['value01']}
                  onUpdate={onUpdate}
                  onCombineEnter={() => console.log('combine enter')}
                  onEnter={() => console.log('enter')}
                  placeholder='auto expand'
        />

        <TextArea name='value01'
                  value={values['value01']}
                  onUpdate={onUpdate}
                  placeholder='value01 readonly'
                  readOnly
        />


        <hr/>

        <h3>Radio</h3>

        <div>
          <Radio name='value02'
                 value={values['value02']}
                 onUpdate={onUpdate}
                 options={['Car', 'Ship', 'Plane']}
          />
        </div>

        <div>

          <Radio name='value02'
                 value={values['value02']}
                 onUpdate={onUpdate}
                 options={['Car', 'Ship', 'Plane']}
                 asButton
          />

        </div>

        <div>

          <Radio name='value02'
                 value={values['value02']}
                 onUpdate={onUpdate}
                 options={['Car', 'Ship', 'Plane']}
                 asToggle
          />

        </div>

        <hr/>

        <h3>Checkbox</h3>

        <div>
          <Checkbox name='value03'
                    value={values['value03']}
                    onUpdate={onUpdate}
                    options={['Green', 'Pink', 'Brown']}
          />
        </div>

        <div>
          <Checkbox name='value03'
                    asButton
                    value={values['value03']}
                    onUpdate={onUpdate}
                    options={['Green', 'Pink', 'Brown']}
          />
        </div>

        <hr/>
        <h3>Select</h3>

        <div>
          <Select name='value04'
                  placeholder='Any drink?'
                  nullable
                  value={values['value04']}
                  onUpdate={onUpdate}
                  sorter={(a, b) => a.localeCompare(b)}
                  disabledValues={['Coffee']}
                  options={['Tea', 'Coffee', 'Water', ...'abcdefghijlkmnlopqrstu'.split('')]}
          />


          <Select name='value04'
                  value={values['value04']}
                  placeholder='Full screen select'
                  onUpdate={onUpdate}
                  fullScreen
                  nullable
                  disabledValues={['Coffee']}
                  options={['Tea', 'Coffee', 'Water', ...new Array(100).fill(null).map((_, i) => `option-${i}`)]}
          />

          <Select.WithOptionsArray name='value04'
                                   value={values['value04']}
                                   onUpdate={onUpdate}
                                   optionsArray={[
                                     ['Tea', 'This is Tea!'],
                                     ['Water', 'This is Water!'],
                                   ]}
          />
        </div>

        <hr/>
        <h3>Toggle</h3>

        <div>
          <Toggle name='value05'
                  on={Boolean(values['value05'])}
                  onUpdate={onUpdate}
          />
        </div>

        <div>
          <Toggle name='value05'
                  on={Boolean(values['value05'])}
                  onTitle='This is on'
                  offTitle='This is off'
                  onUpdate={onUpdate}
          />
        </div>

        <hr/>
        <h3>Slider</h3>

        <div>
          <Slider name='value06'
                  value={values['value06'] || 10}
                  min={0}
                  max={100}
                  step={1}
                  onUpdate={onUpdate}
          />
        </div>

        <hr/>
        <h3>Range</h3>

        <div>
          <Range name='value07'
                 value={values['value07'] || [10, 80]}
                 min={0}
                 max={100}
                 step={1}
                 onUpdate={onUpdate}
          />
        </div>

        <hr/>
        <h3>Upload</h3>

        <div>
          <Upload name='value08'
                  value={values['value08']}
                  multiple={true}
                  onUpdate={onUpdate}
          />
        </div>


        <hr/>
        <h3>Tag</h3>

        <Tag name='value01'
             value={values['value01']}
             onUpdate={onUpdate}
             placeholder='value01'
             options={['Banana', 'Orange', 'Apple']}
        />

        <hr/>


        <h3>Date</h3>
        <Date name='value-date-01'
              value={values['value-date-01']}
              minDate={'2018-03-09'}
              placeholder={'date only'}
              onUpdate={onUpdate}
        />

        <Date name='value-date-01'
              value={values['value-date-01']}
              placeholder={'date and time'}
              timeEnabled
              minDate={'2018-03-09'}
              onUpdate={onUpdate}
        />

        <Date name='value-date-01-time'
              value={values['value-date-01-time']}
              placeholder={'time only'}
              noCalendar
              dateFormat={'H:i'}
              timeEnabled
              minDate={'2018-03-09'}
              onUpdate={onUpdate}
        />

        <br/>


        <h3>PinCode</h3>
        <PinCode name='value-pin-code-01'
                 value={values['value-pin-code-01']}
                 onUpdate={onUpdate}
        />

        <br/>

        <h3>Number</h3>
        <Number name='value-number-01'
                value={values['value-number-01']}
                min={-2}
                max={100}
                onUpdate={onUpdate}
        />

        <Number name='value-number-01'
                value={values['value-number-01']}
                placeholder={'number without min/max'}
                onUpdate={onUpdate}
        />

        <br/>
        <br/>

        <hr/>

        <h2>Error</h2>

        <TheInput name='@'
                  type='hidden'
                  error='This is global error'/>

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              placeholder='value01'
              options={['Banana', 'Orange', 'Apple']}
              error='Something Wrong with This!'
        />


        <Password name='value01'
                  value={values['value01']}
                  onUpdate={onUpdate}
                  placeholder='value01'
                  error='Something Wrong with This!'
        />

        <TextArea name='value01'
                  value={values['value01']}
                  onUpdate={onUpdate}
                  placeholder='value01'
                  error='Something Wrong with This!'
                  onKeyDown={(e) => console.log('key down', e.keyCode)}
        />

        <Select name='value04'
                value={values['value04']}
                onUpdate={onUpdate}
                options={['Tea', 'Coffee', 'Water']}
                error='Something Wrong with This!'
        />

        <Select name='value04'
                spinning
                value={values['value04']}
                onUpdate={onUpdate}
                options={['Tea', 'Coffee', 'Water']}
                error='Something Wrong with This!'
        />

        <Radio name='value02'
               value={values['value02']}
               onUpdate={onUpdate}
               options={['Car', 'Ship', 'Plane']}
               error='Something Wrong with This!'
        />
        <Checkbox name='value03'
                  value={values['value03']}
                  onUpdate={onUpdate}
                  options={['Green', 'Pink', 'Brown']}
                  disabledValues={['Pink']}
                  error='Something Wrong with This!'
        />

        <Upload name='value08'
                value={values['value08']}
                multiple={true}
                error='Something Wrong with This!'
                onUpdate={onUpdate}
        />


        <br/>
        <br/>
        <br/>

        <hr/>

        <h2>Readonly</h2>

        <Text name='value01'
              value={values['value01']}
              onUpdate={onUpdate}
              readOnly
              placeholder='value01'
        />

        <Select name='value04'
                value={values['value04']}
                onUpdate={onUpdate}
                options={['Tea', 'Coffee', 'Water']}
                readOnly
        />

        <Radio name='value02'
               value={values['value02']}
               onUpdate={onUpdate}
               options={['Car', 'Ship', 'Plane']}
               readOnly
        />
        <Checkbox name='value03'
                  value={values['value03']}
                  onUpdate={onUpdate}
                  options={['Green', 'Pink', 'Brown']}
                  readOnly
        />

        <Upload name='value08'
                value={values['value08']}
                multiple={true}
                readOnly
                onUpdate={onUpdate}
        />
      </div>

    )
  }
}

export default ExampleComponent

Components

TheInput

Input of the-components

Props

NameTypeDescriptionDefault
errorunionInput typenull
namestringName of input'_the'
onUpdatefuncHandle for update
typestring'text'
valuestringValue of input''
options{}
parserString

TheInputCheckbox

Checkbox input of the-components

Props

NameTypeDescriptionDefault
disabledValuesarrayDisabled values[]
errorunionnull
namestring
onUpdatefuncHandle for update
optionsunionOptions{}
parserfuncValue parserString
splitterstringValue Splitter text','
valueunionValue of input''

TheInputDate

Props

NameTypeDescriptionDefault
dateFormatstringnull
maxDateunionnull
minDateunionnull
namestring
noCalendarboolfalse
onUpdatefunc
timeEnabledboolfalse

TheInputNumber

TheInputPassword

TheInputPinCode

TheInputRadio

Radio input of the-components

Props

NameTypeDescriptionDefault
asButtonboolUsing button-like stylefalse
asToggleboolUsing toggle-like stylefalse
disabledValuesarrayDisabled values[]
errorunionInput errornull
namestringName of input
onUpdatefuncHandle for update
optionsunionOptions{}
parserfuncValue parserString
sorterfuncOptions sorter(v1, v2) => String(v1).localeCompare(v2)
valueunionValue of input''
role'radiogroup'

TheInputRange

Range Input

Props

NameTypeDescriptionDefault
barOnlyboolHides min/max value textfalse
errorunionInput errornull
maxnumberMax value100
minnumberMin value0
namestring
onUpdatefuncHandle for update
stepnumberValue step0.1
valuearrayOf numberValue of input[0, 100]

TheInputSearch

TheInputSelect

Select Input

Props

NameTypeDescriptionDefault
disabledValuesarrayOf stringUnselecatable values[]
errorunionInput errornull
namestringName of input
nullableboolAllow null selectfalse
nullTextnodeText for null'( no select )'
onEnterfuncHandle for enternull
onUpdatefuncHandle for update
optionsunionOptions{}
parserfuncValue parserString
sorterfuncOptions sorter(v1, v2) => String(v1).localeCompare(v2)
spinningboolfalse
valuestringValue of input''

TheInputSlider

Slider Input

Props

NameTypeDescriptionDefault
barOnlyboolHides min/max value textfalse
errorunionInput errornull
maxnumberMax value100
minnumberMin value0
namestring
onUpdatefuncHandle for update
stepnumberValue step0.1
valuenumberValue of input0

TheInputTag

TheInputText

Text Input

Props

NameTypeDescriptionDefault
errorunionInput errornull
matcherfuncOptions parser`(candidate, value) => {

return ( candidate.indexOf(value) !== -1 || candidate.toLowerCase().indexOf(value.toLowerCase()) !== -1 ) }| |name| string | Name of input | `` | |onDown| func | Handle for down | `` | |onEnter| func | Handle for enter |null| |onLeft| func | Handle for left | `` | |onRight| func | Handle for right | `` | |onUp| func | Handle for up | `` | |onUpdate| func | Handle for update | `` | |options| union | Options |{}| |parser| func | Value parser |(v) => String(v || '')| |pattern| instanceOf | Regexp for input |null| |patternWarning| string | Warning text when pattern failed |null| |prefix| node | prefix |null| |suffix| node | suffix |null| |tabIndex| number | Tab index | `` | |type| string | Text type |'text'| |value| union | Value of input |''| |readOnly| | |false| |role| | |'textbox'| |selectOnFocus| | |false` |

TheInputTextArea

TextArea Input

Props

NameTypeDescriptionDefault
autoExpandboolAuto expanding text area heightfalse
maxRowsnumberMax rows when autoExpand is enabled10
minRowsnumberMin rows when autoExpand is enabled1
namestringName of input
onUpdatefuncHandle for update
parserfuncValue parserString
rowsnumberTextArea rows5
valuestringValue of input''
errornull
readOnlyfalse
role'textbox'
spellCheckfalse

TheInputToggle

Toggle input of the-components

Props

NameTypeDescriptionDefault
offTitlestringTitle text for off state''
onboolSwitch on or notfalse
onTitlestringTitle text for on state''
widthnumberWidth of component64
errornull

TheInputUpload

Props

NameTypeDescriptionDefault
acceptstringAccept file typenull
convertFilefuncConvert input file(file) => readFileAsDataURL(file)
errorunionError messagenull
heightnumberImage height180
multipleboolAllow multiple uploadfalse
namestring
onErrorfuncHandler for error event
onLoadfuncHandler for load event
onUpdatefuncHandle for update
spinnerstringSpinner theme
textstringGuide text'Upload File'
valueunionValue of input
widthnumberImage width180
readOnlyfalse

License

This software is released under the MIT License.

Links

3.5.88

5 years ago

3.5.87

5 years ago

3.5.86

5 years ago

3.5.85

5 years ago

3.5.84

5 years ago

3.5.83

5 years ago

3.5.82

5 years ago

3.5.81

5 years ago

3.5.80

5 years ago

3.5.79

5 years ago

3.5.78

5 years ago

3.5.77

5 years ago

3.5.76

5 years ago

3.5.75

5 years ago

3.5.74

5 years ago

3.5.73

5 years ago

3.5.72

5 years ago

3.5.71

5 years ago

3.5.70

5 years ago

3.5.69

5 years ago

3.5.68

5 years ago

3.5.67

5 years ago

3.5.66

5 years ago

3.5.65

5 years ago

3.5.64

5 years ago

3.5.63

5 years ago

3.5.62

6 years ago

3.5.61

6 years ago

3.5.60

6 years ago

3.5.59

6 years ago

3.5.58

6 years ago

3.5.57

6 years ago

3.5.56

6 years ago

3.5.55

6 years ago

3.5.54

6 years ago

3.5.53

6 years ago

3.5.52

6 years ago

3.5.51

6 years ago

3.5.50

6 years ago

3.5.49

6 years ago

3.5.48

6 years ago

3.5.47

6 years ago

3.5.46

6 years ago

3.5.45

6 years ago

3.5.42

6 years ago

3.5.41

6 years ago

3.5.40

6 years ago

3.5.39

6 years ago

3.5.38

6 years ago

3.5.37

6 years ago

3.5.36

6 years ago

3.5.35

6 years ago

3.5.34

6 years ago

3.5.33

6 years ago

3.5.32

6 years ago

3.5.31

6 years ago

3.5.30

6 years ago

3.5.29

6 years ago

3.5.28

6 years ago

3.5.27

6 years ago

3.5.26

6 years ago

3.5.25

6 years ago

3.5.23

6 years ago

3.5.22

6 years ago

3.5.21

6 years ago

3.5.20

6 years ago

3.5.19

6 years ago

3.5.18

6 years ago

3.5.17

6 years ago

3.5.16

6 years ago

3.5.15

6 years ago

3.5.14

6 years ago

3.5.13

6 years ago

3.5.12

6 years ago

3.5.11

6 years ago

3.5.10

6 years ago

3.5.9

6 years ago

3.5.8

6 years ago

3.5.7

6 years ago

3.5.5

6 years ago

3.5.4

6 years ago

3.5.3

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

3.4.18

6 years ago

3.4.17

6 years ago

3.4.16

6 years ago

3.4.15

6 years ago

3.4.14

6 years ago

3.4.13

6 years ago

3.4.12

6 years ago

3.4.11

6 years ago

3.4.10

6 years ago

3.4.9

6 years ago

3.4.8

6 years ago

3.4.7

6 years ago

3.4.6

6 years ago

3.4.5

6 years ago

3.4.4

6 years ago

3.4.3

6 years ago

3.4.2

6 years ago

3.4.1

6 years ago

3.3.3

6 years ago

3.3.2

6 years ago

3.3.1

6 years ago

3.3.0

6 years ago

3.2.1

6 years ago

3.2.0

6 years ago

3.1.5

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.28

6 years ago

3.0.27

6 years ago

3.0.26

6 years ago

3.0.25

6 years ago

3.0.24

6 years ago

3.0.23

6 years ago

3.0.22

6 years ago

3.0.21

6 years ago

3.0.20

6 years ago

3.0.19

6 years ago

3.0.18

6 years ago

3.0.17

6 years ago

3.0.16

6 years ago

3.0.15

6 years ago

3.0.14

6 years ago

3.0.13

6 years ago

3.0.12

6 years ago

3.0.11

6 years ago

3.0.10

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.3.0

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.10

6 years ago

2.1.9

6 years ago

2.1.8

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.14

7 years ago

1.4.13

7 years ago

1.4.12

7 years ago

1.4.11

7 years ago

1.4.10

7 years ago

1.4.9

7 years ago

1.4.8

7 years ago

1.4.7

7 years ago

1.4.6

7 years ago

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago