Sha256: 47976391f000e60b8aaf54811bd8a28b4ed27e39ac15e028a430f1df08e7c694

Contents?: true

Size: 1.8 KB

Versions: 23

Compression:

Stored size: 1.8 KB

Contents

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

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

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

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

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

export default TextInput

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-6.4.2 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.1.pre.alpha1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha9 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha8 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha7 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-6.4.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha6 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha5 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-6.4.0 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-6.3.1 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha4 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha3 app/pb_kits/playbook/pb_text_input/_text_input.jsx
playbook_ui-7.0.0.pre.alpha2 app/pb_kits/playbook/pb_text_input/_text_input.jsx