Sha256: b08d9650f3fa22cffc9424032c8919e9d1eb034fdada817a55658e032053b463

Contents?: true

Size: 1.69 KB

Versions: 62

Compression:

Stored size: 1.69 KB

Contents

/* @flow */
/*eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */

import React, { forwardRef } from 'react'
import Body from '../pb_body/_body.jsx'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'

type RadioProps = {
  aria?: object,
  alignment?: String,
  checked?: Boolean,
  children?: Node,
  className?: String,
  dark?: boolean,
  data?: object,
  error?: Boolean,
  id?: String,
  label: String,
  name: String,
  value: String,
  text: String,
  onChange: (Boolean)=>void,
}

const Radio = ({
  aria = {},
  alignment = '',
  children,
  className,
  dark = false,
  data = {},
  error = false,
  id,
  label,
  name = 'radio_name',
  text = 'Radio Text',
  value = 'radio_text',
  onChange = () => {},
  ...props
}: RadioProps, ref) => {
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_radio_kit'), { error }, { dark }, globalProps(props), alignment, className)

  return (
    <label
        {...ariaProps}
        {...dataProps}
        className={classes}
        htmlFor={id}
    >
      <If condition={children}>
        {children}
        <Else />
        <input
            {...props}
            id={id}
            name={name}
            onChange={onChange}
            ref={ref}
            text={text}
            type="radio"
            value={value}
        />
      </If>
      <span className="pb_radio_button" />
      <Body
          dark={dark}
          status={error ? 'negative' : null}
          text={label}
      />
    </label>
  )
}

export default forwardRef(Radio)

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
playbook_ui-10.23.0.pre.cachetest app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.lightbox.2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.lightbox app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.rg1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.jg1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.na1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.21.0.pre.alpha.jd1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.20.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.19.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.19.0.pre.lightbox app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.18.2 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.19.0.pre.popover.alpha1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.18.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.18.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.17.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.16.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.15.1 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.15.1.pre.alpha.rubocop.deps app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.15.0 app/pb_kits/playbook/pb_radio/_radio.jsx
playbook_ui-10.14.1.pre.alpha2 app/pb_kits/playbook/pb_radio/_radio.jsx