Sha256: 77dcf39a8d7f86f49a0cd357c561e8e4bfe98db8a5a39520f2f58d4e14c01f92

Contents?: true

Size: 1.64 KB

Versions: 59

Compression:

Stored size: 1.64 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { Body, Caption } from '../'
import type { InputCallback } from '../types.js'
import { globalProps } from '../utilities/globalProps.js'

type TextareaProps = {
  className?: string,
  children?: array<React.ReactChild>,
  data?: string,
  disabled?: boolean,
  error?: string,
  id?: string,
  object?: string,
  method?: string,
  label?: string,
  placeholder?: string,
  value?: string,
  name?: string,
  required?: boolean,
  rows?: number,
  resize: 'none' | 'both' | 'horizontal' | 'vertical',
  onChange?: InputCallback<HTMLTextAreaElement>,
}

const Textarea = ({
  className,
  children,
  disabled,
  resize = 'none',
  error,
  label,
  name,
  onChange = () => {},
  placeholder,
  required,
  rows = 4,
  value,
  ...props
}: TextareaProps) => {
  const errorClass = error ? 'error' : null
  const resizeClass = `resize_${resize}`
  const classes = classnames('pb_textarea_kit', errorClass, resizeClass, globalProps(props), className)

  return (
    <div className={classes}>
      <Caption
          text={label}
      />
      <If condition={children}>
        {children}
        <Else />
        <textarea
            {...props}
            className="pb_textarea_kit"
            disabled={disabled}
            name={name}
            onChange={onChange}
            placeholder={placeholder}
            required={required}
            rows={rows}
            value={value}
        />
        <If condition={error}>
          <Body
              status="negative"
              text={error}
          />
        </If>
      </If>
    </div>
  )
}

export default Textarea

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
playbook_ui-7.4.0.pre.alpha5 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.test4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.test3 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.test2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.alpha4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.alpha2 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.4.0.pre.alpha1 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha12 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha11 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha10 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha9 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha8 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha7 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha6 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha5 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha4 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha3 app/pb_kits/playbook/pb_textarea/_textarea.jsx
playbook_ui-7.3.0.pre.alpha1 app/pb_kits/playbook/pb_textarea/_textarea.jsx