Sha256: 4c9007aad02fd37f6431822fe7d61939956cfecb8d0a00f3510cd002868961cc

Contents?: true

Size: 928 Bytes

Versions: 1065

Compression:

Stored size: 928 Bytes

Contents

import React, { useState } from 'react'
import { DatePicker, LabelValue } from '../..'

const DatePickerOnChange = (props) => {
  const today = new Date()
  const [dateString, setDateString] = useState(today.toLocaleDateString())
  const [dateObj, setDateObj] = useState([today])

  const changeHandler = (dateStr, selectedDates) => {
    setDateString(dateStr)
    setDateObj(selectedDates)
  }

  return (
    <div>
      <DatePicker
          defaultDate={dateString}
          marginBottom="lg"
          onChange={changeHandler}
          pickerId="date-picker-onchange"
          {...props}
      />
      <LabelValue
          label="Date Object"
          marginBottom="lg"
          value={dateObj[0] ? dateObj[0].toString() : ''}
          {...props}
      />
      <LabelValue
          label="Date String"
          value={dateString}
          {...props}
      />
    </div>
  )
}
export default DatePickerOnChange

Version data entries

1,065 entries across 1,065 versions & 2 rubygems

Version Path
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.12.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.10.0.pre.date.time.stacked.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.9.0.alpha.inline1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.9.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.8.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.7.0.pre.alphawidth1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.7.0.pre.alpha.a11y.btn app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.7.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.6.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.6.1.pre.deps1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-9.6.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx