Sha256: f66d88cfdd2e7ce86ca249b259b02a97fe0ec2929154c65a9a57d5f9407360b2

Contents?: true

Size: 1.78 KB

Versions: 44

Compression:

Stored size: 1.78 KB

Contents

/* @flow */
import React from 'react'
import classnames from 'classnames'
import { Body, Caption } from '../'
import { spacing } from '../utilities/spacing.js'

import {
  buildAriaProps,
  buildDataProps,
} from '../utilities/props'

type TextInputProps = {
  aria?: object,
  className: String,
  dark: boolean,
  data?: object,
  error?: String,
  id?: String,
  name: String,
  label: String,
  onChange: (String) => void,
  placeholder: String,
  type: String,
  value: String | number,
  children: Node,
}

const TextInput = ({
  aria = {},
  className,
  dark = false,
  data = {},
  error,
  id,
  name,
  label,
  onChange = () => {},
  placeholder,
  type = 'text',
  value,
  children = null,
  ...props
}: TextInputProps) => {
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const css = classnames([
    `pb_text_input_kit${dark === true ? '_dark' : ''}`,
    className,
    error ? 'error' : null,
  ])

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={css}
    >
      <Caption
          className="pb_text_input_kit_label"
          dark={dark}
          text={label}
      />
      <div className={classnames('text_input_wrapper', spacing(props))}>
        <If condition={children}>
          {children}
          <Else />
          <input
              {...props}
              className="text_input"
              id={id}
              name={name}
              onChange={onChange}
              placeholder={placeholder}
              type={type}
              value={value}
          />
          <If condition={error}>
            <Body
                dark={dark}
                status="negative"
                text={error}
            />
          </If>
        </If>
      </div>
    </div>
  )
}

export default TextInput

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.4.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.3.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0.pre.alpha2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.2.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.1.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.0.3 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.0.2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.0.1.pre.beta app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.1.0.pre.alpha4 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.1.0.pre.alpha2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.1.0.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.0.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-5.0.1.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx