1.0.2 • Published 5 years ago

@rei/cdr-input v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

CdrInput

For the most up-to-date information, see REI Cedar documentation.

Properties

NameTypeDefault
idstringauto-generated

Requires unique ID that is mapped to the label for attribute. If this value is not set, it will be auto-generated.

NameTypeDefault
typestring'text'

Supports HTML5 <input> types for text, email, number, password, search, and URL. For more information, view WebAIM’s Future Web Accessibility: New input Types in HTML5.

NameTypeDefault
labelstringN/A

Sets the text value for the input label. Required for a11y compliance. Use hideLabel if the label display is not desired.

NameTypeDefault
hideLabelbooleanfalse

Hides the label element and sets the input aria-label to the label value for a11y compliance.

NameTypeDefault
rowsnumbernull

Sets the number of rows for the input field and converts input field to textarea if the rows value is greater than 1.

NameTypeDefault
disabledbooleanfalse

Sets disabled input field and label styling and restricts user input.

NameTypeDefault
requiredBooleanfalse

Sets the field to required and displays the text “Required” next to the input label.

NameTypeDefault
sizestring'medium'

Sets the input field size. Possible values: { 'medium', 'large' }

Slots

NameNotes
infoLocation for information link or icon markup to the right above the input field.
pre-iconLocation for icon markup to the left inside the input field.
post-iconLocation for icon markup to the right inside the input field.
helper-textLocation for helper or information text to the left below the input field.

Events

NameArgumentsNotes
changenewValue, eventEvent is emitted on input losing focus (onBlur) if the value has changed

Installation

Resources are available within the CdrInput package:

  • Component: @rei/cdr-input
  • Component styles: cdr-input.css

To incorporate the required assets for a component, use the following steps:

1. Install using NPM

Install the CdrInput package using npm in your terminal:

Terminal

npm i -S @rei/cdr-input

2. Import dependencies

main.js

// import your required CSS.
import "@rei/cdr-input/dist/cdr-input.css";

3. Add component to a template

local.vue

<template>
  ...
     <cdr-input
       v-model=”inputModel”
       label=”Input Label Text”
       placeholder=”Input Placeholder Text”
     />
  ...
</template>

<script>
import { CdrInput } from '@rei/cdr-input';
export default {
  ...
  components: {
     CdrInput
  },
  data() {
    inputModel: ‘Default Value’
  }
}
</script>

Usage

The CdrInput component requires v-model to bind the input value to your data model. You can also use helper-text to display additional information below the input.

<cdr-input
  class="demo-input"
  v-model="inputWithSlots"
  id="slots-demo"
  label="Billing address ZIP code">
  <template slot="helper-text">
    International customers, if no postal code, enter “NA”
  </template>
</cdr-input>

aria-label will automatically be added on compilation based upon what is provided in label when label is hidden using hide-label.

<cdr-input
  class="demo-input"
  v-model="ariaModel"
  id="aria-demo"
  label=”First Name"
  hide-label>
</cdr-input>

This will result in the following HTML:

<div class="cdr-input-wrap">
  <input
    id="aria-demo"
    type="text"
    class="cdr-input"
    aria-label="First Name">
</div>

Input inherits the placeholder attribute for the placeholder text. You can also use the post-icon slot for adding and icon.

<cdr-input
  class="demo-input"
  v-model="inputWithSlots"
  placeholder="mm/dd/yyyy"
  id="slots-demo"
  label="Event Date">
  <template slot="post-icon">
    <icon-calendar />
  </template>
</cdr-input>
1.0.2

5 years ago

1.0.2-alpha.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-alpha.5

5 years ago

1.0.0-alpha.4

6 years ago

0.1.3

6 years ago

1.0.0-alpha.3

6 years ago

1.0.0-alpha.2

6 years ago

1.0.0-alpha.1

6 years ago

1.0.0-alpha.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago