{"version":3,"sources":["webpack://ShortcutButtonsPlugin/webpack/universalModuleDefinition","webpack://ShortcutButtonsPlugin/webpack/bootstrap","webpack://ShortcutButtonsPlugin/./src/index.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","defaultConfig","theme","supportedAttributes","Set","config","cfg","fp","wrapper","onClick","event","stopPropagation","preventDefault","target","tagName","toLowerCase","index","parseInt","dataset","Array","isArray","callback","onKeyDown","shiftKey","previousSibling","nextSibling","element","focus","onReady","document","createElement","classList","add","label","length","textContent","appendChild","buttons","button","forEach","b","type","String","attributes","keys","filter","attribute","has","setAttribute","split","setButtonsAttributes","pluginElements","push","calendarContainer","addEventListener","onDestroy","removeEventListener","undefined"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA+B,sBAAID,IAEnCD,EAA4B,sBAAIC,IARlC,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EA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C,EAAOP,WAAUC,IAAG,QAAIW,EAAWnD,GAAKyD,MAAM,SAkC1CC,CAAqBZ,EAAQE,EAAEG,YAGnCN,EAAQD,YAAYE,GAEpB/B,EAAG4C,eAAeC,KAAKd,MAG3B9B,EAAQ4B,YAAYC,GAEpB9B,EAAG8C,kBAAkBjB,YAAY5B,GAEjCA,EAAQ8C,iBAAiB,QAAS7C,GAClCD,EAAQ8C,iBAAiB,UAAWhC,IAMxCiC,UAAW,WACP/C,EAAQgD,oBAAoB,UAAWlC,GACvCd,EAAQgD,oBAAoB,QAAS/C,GACrCD,OAAUiD,S","file":"shortcut-buttons-flatpickr.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ShortcutButtonsPlugin\"] = factory();\n\telse\n\t\troot[\"ShortcutButtonsPlugin\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/*\n * Copyright (c) 2018 João Morais under the MIT license.\n * https://github.com/jcsmorais/shortcut-buttons-flatpickr/\n */\n\nimport { Instance as Flatpickr } from 'flatpickr/dist/types/instance.d';\n\nexport namespace ShortcutButtonsFlatpickr {\n export type OnClickSignature = (index: number, fp: Flatpickr) => void;\n\n export type Attributes = { [name: string]: string };\n\n export type Button = {\n attributes?: Attributes,\n label: string,\n };\n\n export type Config = {\n button: Button | Button[],\n label?: string,\n onClick?: OnClickSignature | OnClickSignature[],\n theme?: string,\n };\n}\n\nconst defaultConfig: Partial = {\n theme: 'light',\n};\n\n/**\n * List of attributes that can be set through button's options.\n */\nconst supportedAttributes = new Set([\n 'accesskey',\n 'aria-label',\n 'class',\n 'tabindex',\n]);\n\n/**\n * Adds shortcut buttons to flatpickr providing users an alternative way to interact with the datetime picker.\n *\n * Example usage:\n *\n * ```ts\n * flatpickr('.target-input-element', {\n * // ...\n * plugins: [ShortcutButtonsPlugin({\n * button: {\n * label: 'The Beginning Of Time',\n * },\n * onClick: (index: number, fp: Flatpickr) => {\n * // Do something when a button is clicked\n * },\n * theme: 'light',\n * })],\n * })\n * ```\n *\n * @param config Configuration options.\n *\n * Supported options are:\n * `button`: button(s).\n * `button.attributes`: button's attributes.\n * `button.label`: button's label.\n * `label`: label including a sentence stating that the user can use the calendar controls or one of the buttons.\n * `onClick`: callback(s) invoked when plugin's buttons are clicked.\n * `theme`: flatpickr's theme.\n */\nexport function ShortcutButtonsPlugin(config: ShortcutButtonsFlatpickr.Config) {\n const cfg = { ...defaultConfig, ...config };\n\n return (fp: Flatpickr) => {\n /**\n * Element that wraps this plugin's dependent elements.\n */\n let wrapper: HTMLElement;\n\n /**\n * Handles click events on plugin's button.\n */\n function onClick(event: Event) {\n event.stopPropagation();\n event.preventDefault();\n\n const target = event.target as HTMLButtonElement;\n if (target.tagName.toLowerCase() !== 'button' || typeof cfg.onClick === 'undefined') {\n return;\n }\n\n const index = parseInt(target.dataset.index, 10);\n\n const callbacks: ShortcutButtonsFlatpickr.OnClickSignature[] = Array.isArray(cfg.onClick) ?\n cfg.onClick :\n [cfg.onClick];\n\n for (const callback of callbacks) {\n if (typeof callback === 'function') {\n callback(index, fp);\n }\n }\n }\n\n /**\n * Handles key down events on plugin's button.\n */\n function onKeyDown(event: KeyboardEvent) {\n const target = event.target as HTMLButtonElement;\n if (event.key !== 'Tab' || target.tagName.toLowerCase() !== 'button') {\n return;\n }\n\n if ((event.shiftKey && !target.previousSibling) || (!event.shiftKey && !target.nextSibling)) {\n event.preventDefault();\n fp.element.focus();\n }\n }\n\n /**\n * Set given button's attributes.\n */\n function setButtonsAttributes(button: HTMLButtonElement, attributes?: ShortcutButtonsFlatpickr.Attributes) {\n Object.keys(attributes).filter((attribute) => supportedAttributes.has(attribute)).forEach((key) => {\n if (key === 'class') {\n button.classList.add(...attributes[key].split(' '));\n return;\n }\n\n button.setAttribute(key, attributes[key])\n });\n }\n\n return {\n /**\n * Initialize plugin.\n */\n onReady: () => {\n wrapper = document.createElement('div');\n wrapper.classList.add('shortcut-buttons-flatpickr-wrapper', cfg.theme);\n\n if (typeof cfg.label !== 'undefined' && cfg.label.length) {\n const label = document.createElement('div');\n label.classList.add('shortcut-buttons-flatpickr-label');\n label.textContent = cfg.label;\n\n wrapper.appendChild(label);\n }\n\n const buttons = document.createElement('div');\n buttons.classList.add('shortcut-buttons-flatpickr-buttons');\n\n (Array.isArray(cfg.button) ? cfg.button : [cfg.button]).forEach((b, index) => {\n const button = document.createElement('button');\n button.type = 'button';\n button.classList.add('shortcut-buttons-flatpickr-button');\n button.textContent = b.label;\n button.dataset.index = String(index);\n if (typeof b.attributes !== 'undefined') {\n setButtonsAttributes(button, b.attributes);\n }\n\n buttons.appendChild(button);\n\n fp.pluginElements.push(button);\n });\n\n wrapper.appendChild(buttons);\n\n fp.calendarContainer.appendChild(wrapper);\n\n wrapper.addEventListener('click', onClick);\n wrapper.addEventListener('keydown', onKeyDown);\n },\n\n /**\n * Clean up before flatpickr is destroyed.\n */\n onDestroy: () => {\n wrapper.removeEventListener('keydown', onKeyDown);\n wrapper.removeEventListener('click', onClick);\n wrapper = undefined;\n },\n };\n };\n}\n"],"sourceRoot":""}