6.1.11 • Published 2 years ago

bpk-component-input-css v6.1.11

Weekly downloads
202
License
Apache-2.0
Repository
github
Last release
2 years ago

bpk-component-input

Backpack input component.

Installation

npm install bpk-component-input --save-dev

Usage

import React from 'react';
import BpkInput, { INPUT_TYPES, CLEAR_BUTTON_MODES } from 'bpk-component-input';

export default () => (
  <BpkInput
    id="origin"
    type={INPUT_TYPES.text}
    name="origin"
    value="Edinburgh"
    onChange={() => console.log('input changed!')}
    placeholder="Country, city or airport"
    clearButtonMode={CLEAR_BUTTON_MODES.whileEditing}
    clearButtonLabel="Clear"
    onClear={() => console.log('input cleared!')}
  />
);

Props

PropertyPropTypeRequiredDefault Value
idstringtrue-
namestringtrue-
typeINPUT_TYPES (one of)falseINPUT_TYPES.text
valuestringtrue-
clearButtonModeCLEAR_BUTTON_MODES (one of)falseCLEAR_BUTTON_MODES.never
clearButtonLabelstringif clearable={true}null
dockedFirstboolfalsefalse
dockedLastboolfalsefalse
dockedMiddleboolfalsefalse
inputReffuncfalsenull
largeboolfalsefalse
onClearfuncif clearable={true}null
validboolfalsenull

Additionally, all native <input /> attributes such as placeholder and onChange are supported.

Note: When clearButtonMode is set to always, validity icons will not appear.

withOpenEvents

The withOpenEvents higher-order component encapsulates input event handlers for opening popovers or modals.

The onOpen callback is called on the following events:

  • click
  • focus
  • touchend
  • keydown (Enter key)
  • keyup (Space key)

You can still attach custom handlers for these events as they will still be called. All other key events are prevented.

It is important you pass the isOpen prop, as it is necessary to work around an IE bug.

PropertyPropTypeRequiredDefault Value
isOpenboolfalsefalse
onOpenfuncfalsenull
hasTouchSupportboolfalse(feature detection)
import React from 'react';
import BpkInput, { withOpenEvents } from 'bpk-component-input';
import BpkPopover from 'bpk-component-popover';

const EnhancedInput = withOpenEvents(BpkInput);

export default () => {
  constructor() {
    super();

    this.state = { isOpen: false };
  }

  onOpen = () => {
    this.setState({ isOpen: true });
  }

  onClose = () => {
    this.setState({ isOpen: false });
  }

  render() {
    return (
      <BpkPopover
        id="popover"
        target={
          <EnhancedInput
            id="input"
            value="An input?"
            isOpen={this.state.isOpen}
            onOpen={this.onOpen}
            onChange={() => null}
          />
        }
        onClose={this.onClose}
        isOpen={this.state.isOpen}
        label="Popover"
        closeButtonText="Close"
      >
        A popover!
      </BpkPopover>
    );
  }
}
6.1.11

2 years ago

6.1.9

2 years ago

6.1.5

2 years ago

6.1.7

2 years ago

6.1.2

2 years ago

6.1.4

2 years ago

6.1.1

2 years ago

6.0.40

2 years ago

6.0.43

2 years ago

6.0.38

2 years ago

6.0.37

2 years ago

6.0.31

2 years ago

6.0.29

2 years ago

6.0.28

2 years ago

6.0.26

3 years ago

6.0.20

3 years ago

6.0.17

3 years ago

6.0.15

3 years ago

6.0.14

3 years ago

6.0.13

3 years ago

6.0.12

3 years ago

6.0.11

3 years ago

6.0.9

3 years ago

6.0.10

3 years ago

6.0.8

3 years ago

6.0.7

3 years ago

6.0.6

3 years ago

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.1.8

3 years ago

5.1.6

3 years ago

5.1.5

3 years ago

5.1.4

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.130

3 years ago

5.0.129

3 years ago

5.0.128

3 years ago

5.0.127

3 years ago

5.0.126

3 years ago

5.0.124

3 years ago

5.0.123

3 years ago

5.0.122

3 years ago

5.0.121

3 years ago

5.0.120

3 years ago

5.0.118

3 years ago

5.0.119

3 years ago

5.0.116

3 years ago

5.0.117

3 years ago

5.0.115

3 years ago

5.0.114

3 years ago

5.0.113

3 years ago

5.0.112

3 years ago

5.0.111

3 years ago

5.0.110

3 years ago

5.0.109

3 years ago

5.0.108

3 years ago

5.0.107

3 years ago

5.0.106

3 years ago

5.0.104

3 years ago

5.0.105

3 years ago

5.0.103

3 years ago

5.0.102

3 years ago

5.0.101

3 years ago

5.0.100

3 years ago

5.0.99

3 years ago

5.0.97

3 years ago

5.0.98

3 years ago

5.0.95

3 years ago

5.0.96

3 years ago

5.0.92

3 years ago

5.0.91

4 years ago

5.0.90

4 years ago

5.0.89

4 years ago

5.0.88

4 years ago

5.0.86

4 years ago

5.0.85

4 years ago

5.0.83

4 years ago

5.0.84

4 years ago

5.0.82

4 years ago

5.0.81

4 years ago

5.0.79

4 years ago

5.0.78

4 years ago

5.0.77

4 years ago

5.0.72

4 years ago

5.0.71

4 years ago

5.0.70

4 years ago

5.0.68

4 years ago

5.0.67

4 years ago

5.0.66

4 years ago

5.0.65

4 years ago