Sha256: fa9f980b744844fe1c5f40ddb90c85b04ce1c50931a463c76c0b9e6b9004a40a

Contents?: true

Size: 934 Bytes

Versions: 948

Compression:

Stored size: 934 Bytes

Contents

import React, { useState } from 'react'
import { DatePicker, LabelValue } from 'playbook-ui'

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

948 entries across 948 versions & 2 rubygems

Version Path
playbook_ui_docs-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui_docs-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_on_change.jsx