Sha256: 7a78d691965104741bf0d79f64ce16db9171f000cde83d38ee6c37cbf1ee1ac4

Contents?: true

Size: 1019 Bytes

Versions: 1919

Compression:

Stored size: 1019 Bytes

Contents

import React from 'react'

import DatePicker from '../_date_picker'

const DatePickerHooks = (props) => {
  // Define hooks
  const changeHook = () => {
    alert('date changed')
  }
  const openHook = () => {
    alert('calendar opened')
  }

  // Access flatpickr instances with picker ids and assign them variables
  window.addEventListener('DOMContentLoaded', () => {
    const fpChange = document.querySelector('#date-picker-hooks-onchange')._flatpickr
    const fpOpen = document.querySelector('#date-picker-hooks-onopen')._flatpickr

    // Push one or more hooks to flatpickr instance's Event config arrays
    fpChange.config.onChange.push(changeHook)
    fpOpen.config.onOpen.push(openHook)
  })

  return (
    <div>
      <DatePicker
          label="onChange"
          pickerId="date-picker-hooks-onchange"
          {...props}
      />
      <DatePicker
          label="onOpen"
          pickerId="date-picker-hooks-onopen"
          {...props}
      />
    </div>
  )
}

export default DatePickerHooks

Version data entries

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

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