Sha256: 6cd015c6dcf03db5fc22c56a64f479ede402a182e06a0a202b278e7c6135eaee

Contents?: true

Size: 1013 Bytes

Versions: 94

Compression:

Stored size: 1013 Bytes

Contents

import React from 'react'
import { DatePicker } from '../../'

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

94 entries across 94 versions & 1 rubygems

Version Path
playbook_ui-9.3.0.alpha.inline2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.3.0.alpha.inline1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.3.0.pre.alpha.password.strength.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.3.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.2.2.pre.alpha.margin app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.2.2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.2.1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.2.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.1.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-9.0.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.3.0.alpha.select.pre.margin app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.3.0 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.pre.alpha5 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.pre.alpha4 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.alpha.iconacc app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.pre.alpha3 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.pre.alpha2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.3.0.deps2 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.3.0.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx
playbook_ui-8.2.1.pre.alpha1 app/pb_kits/playbook/pb_date_picker/docs/_date_picker_hooks.jsx