Sha256: c1468f8fb84122262a3f7fa1222d67de207c4cc2467c05fb5767671276c355bc

Contents?: true

Size: 1.76 KB

Versions: 644

Compression:

Stored size: 1.76 KB

Contents

import React from 'react'
import classnames from 'classnames'

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

import Flex from '../pb_flex/_flex'
import Time from '../pb_time/_time'
import FormattedDate from '../pb_date/_date'

type DateTimeProps = {
  align?: "left" | "center" | "right",
  aria?: { [key: string]: string; },
  className?: string,
  data?: { [key: string]: string; },
  datetime: Date,
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
  id?: string,
  size?: "sm" | "md",
  showDayOfWeek: boolean,
  showIcon?: boolean,
  timeZone?: string
}

const DateTime = (props: DateTimeProps): React.ReactElement => {
  const {
    align = 'left',
    aria = {},
    className,
    data = {},
    htmlOptions = {},
    showDayOfWeek = false,
    datetime,
    id,
    showIcon = false,
    size = 'md',
    timeZone = 'America/New_York',
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const htmlProps = buildHtmlProps(htmlOptions)
  const classes = classnames(
    buildCss('pb_date_time', size),
    globalProps(props),
    className
  )

  return (
    <div
        {...ariaProps}
        {...dataProps}
        {...htmlProps}
        className={classes}
        id={id}
    >
      <Flex
          horizontal={align}
          vertical="baseline"
      >
        <FormattedDate
            showDayOfWeek={showDayOfWeek}
            size={size}
            value={datetime}
        />
        <Time
            date={datetime}
            marginLeft="sm"
            showIcon={showIcon}
            size={size}
            timeZone={timeZone}
        />
      </Flex>
    </div>
  )
}

export default DateTime

Version data entries

644 entries across 644 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_date_time/_date_time.tsx
playbook_ui-14.11.1 app/pb_kits/playbook/pb_date_time/_date_time.tsx