{"version":3,"sources":["webpack:///./node_modules/micromodal/dist/micromodal.es.js"],"names":["_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_toConsumableArray","arr","Array","isArray","_arrayLikeToArray","_arrayWithoutHoles","iter","Symbol","iterator","from","_iterableToArray","o","minLen","n","prototype","toString","call","slice","constructor","name","test","_unsupportedIterableToArray","TypeError","_nonIterableSpread","len","arr2","FOCUSABLE_ELEMENTS","Modal","activeModal","validateModalPresence","validateArgs","MicroModal","_ref","targetModal","_ref$triggers","triggers","_ref$onShow","onShow","_ref$onClose","onClose","_ref$openTrigger","openTrigger","_ref$closeTrigger","closeTrigger","_ref$openClass","openClass","_ref$disableScroll","disableScroll","_ref$disableFocus","disableFocus","_ref$awaitCloseAnimat","awaitCloseAnimation","_ref$awaitOpenAnimati","awaitOpenAnimation","_ref$debugMode","debugMode","instance","Constructor","_classCallCheck","this","modal","document","getElementById","config","registerTriggers","apply","onClick","bind","onKeydown","protoProps","staticProps","value","_this","_len","arguments","_key","filter","Boolean","forEach","trigger","addEventListener","event","showModal","_this2","undefined","activeElement","setAttribute","classList","add","scrollBehaviour","addEventListeners","handler","removeEventListener","setFocusToFirstNode","removeEventListeners","focus","remove","closeModal","toggle","body","querySelector","assign","style","overflow","hasAttribute","keyCode","retainFocus","nodes","querySelectorAll","_this3","focusableNodes","getFocusableNodes","nodesWhichAreNotCloseTargets","node","offsetParent","contains","focusedItemIndex","indexOf","shiftKey","preventDefault","id","console","warn","concat","triggerMap","validateTriggerPresence","init","options","triggerAttr","attributes","push","generateTriggerMap","show","close","closeModalById","window"],"mappings":"2FAKA,SAASA,EAAkBC,EAAQC,GACjC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CACrC,IAAIE,EAAaH,EAAMC,GACvBE,EAAWC,WAAaD,EAAWC,aAAc,EACjDD,EAAWE,cAAe,EACtB,UAAWF,IAAYA,EAAWG,UAAW,GACjDC,OAAOC,eAAeT,EAAQI,EA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F,CACLM,KAhDS,SAAc/D,GAEvB,IAAIgE,EAAUlI,OAAOwG,OAAO,GAAI,CAC9B5D,YAAa,2BACZsB,GAEC5B,EAAWnC,EAAmB6D,SAAS+C,iBAAiB,IAAIe,OAAOI,EAAQtF,YAAa,OAExFmF,EAnEmB,SAA4BzF,EAAU6F,GAC7D,IAAIJ,EAAa,GAMjB,OALAzF,EAAS2C,SAAQ,SAAUC,GACzB,IAAI9C,EAAc8C,EAAQkD,WAAWD,GAAazD,WAClBa,IAA5BwC,EAAW3F,KAA4B2F,EAAW3F,GAAe,IACrE2F,EAAW3F,GAAaiG,KAAKnD,MAExB6C,EA4DUO,CAAmBhG,EAAU4F,EAAQtF,aAEtD,IAA0B,IAAtBsF,EAAQxE,YAA6D,IAAvCzB,EAAaK,EAAUyF,GAEzD,IAAK,IAAI7H,KAAO6H,EAAY,CAC1B,IAAIrD,EAAQqD,EAAW7H,GACvBgI,EAAQ9F,YAAclC,EACtBgI,EAAQ5F,SAAWnC,EAAmBuE,GACtC3C,EAAc,IAAID,EAAMoG,KAiC1BK,KAvBS,SAAcnG,EAAa8B,GACpC,IAAIgE,EAAUhE,GAAU,GACxBgE,EAAQ9F,YAAcA,GAEI,IAAtB8F,EAAQxE,YAA6D,IAAvC1B,EAAsBI,KAEpDL,GAAaA,EAAYkE,wBAE7BlE,EAAc,IAAID,EAAMoG,IAEZ7C,cAcZmD,MANU,SAAepG,GACzBA,EAAcL,EAAY0G,eAAerG,GAAeL,EAAYqE,gBAQxEsC,OAAOxG,WAAaA,EACL","file":"js/10-eea92cc8d2e9e412894a.chunk.js","sourcesContent":["function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\nfunction _toConsumableArray(arr) {\n return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();\n}\nfunction _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return _arrayLikeToArray(arr);\n}\nfunction _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter);\n}\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n}\nfunction _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}\nfunction _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nvar MicroModal = function () {\n var FOCUSABLE_ELEMENTS = ['a[href]', 'area[href]', 'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])', 'select:not([disabled]):not([aria-hidden])', 'textarea:not([disabled]):not([aria-hidden])', 'button:not([disabled]):not([aria-hidden])', 'iframe', 'object', 'embed', '[contenteditable]', '[tabindex]:not([tabindex^=\"-\"])'];\n var Modal = /*#__PURE__*/function () {\n function Modal(_ref) {\n var targetModal = _ref.targetModal,\n _ref$triggers = _ref.triggers,\n triggers = _ref$triggers === void 0 ? [] : _ref$triggers,\n _ref$onShow = _ref.onShow,\n onShow = _ref$onShow === void 0 ? function () {} : _ref$onShow,\n _ref$onClose = _ref.onClose,\n onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,\n _ref$openTrigger = _ref.openTrigger,\n openTrigger = _ref$openTrigger === void 0 ? 'data-micromodal-trigger' : _ref$openTrigger,\n _ref$closeTrigger = _ref.closeTrigger,\n closeTrigger = _ref$closeTrigger === void 0 ? 'data-micromodal-close' : _ref$closeTrigger,\n _ref$openClass = _ref.openClass,\n openClass = _ref$openClass === void 0 ? 'is-open' : _ref$openClass,\n _ref$disableScroll = _ref.disableScroll,\n disableScroll = _ref$disableScroll === void 0 ? false : _ref$disableScroll,\n _ref$disableFocus = _ref.disableFocus,\n disableFocus = _ref$disableFocus === void 0 ? false : _ref$disableFocus,\n _ref$awaitCloseAnimat = _ref.awaitCloseAnimation,\n awaitCloseAnimation = _ref$awaitCloseAnimat === void 0 ? false : _ref$awaitCloseAnimat,\n _ref$awaitOpenAnimati = _ref.awaitOpenAnimation,\n awaitOpenAnimation = _ref$awaitOpenAnimati === void 0 ? false : _ref$awaitOpenAnimati,\n _ref$debugMode = _ref.debugMode,\n debugMode = _ref$debugMode === void 0 ? false : _ref$debugMode;\n _classCallCheck(this, Modal);\n\n // Save a reference of the modal\n this.modal = document.getElementById(targetModal); // Save a reference to the passed config\n\n this.config = {\n debugMode: debugMode,\n disableScroll: disableScroll,\n openTrigger: openTrigger,\n closeTrigger: closeTrigger,\n openClass: openClass,\n onShow: onShow,\n onClose: onClose,\n awaitCloseAnimation: awaitCloseAnimation,\n awaitOpenAnimation: awaitOpenAnimation,\n disableFocus: disableFocus\n }; // Register click events only if pre binding eventListeners\n\n if (triggers.length > 0) this.registerTriggers.apply(this, _toConsumableArray(triggers)); // pre bind functions for event listeners\n\n this.onClick = this.onClick.bind(this);\n this.onKeydown = this.onKeydown.bind(this);\n }\n /**\n * Loops through all openTriggers and binds click event\n * @param {array} triggers [Array of node elements]\n * @return {void}\n */\n\n _createClass(Modal, [{\n key: \"registerTriggers\",\n value: function registerTriggers() {\n var _this = this;\n for (var _len = arguments.length, triggers = new Array(_len), _key = 0; _key < _len; _key++) {\n triggers[_key] = arguments[_key];\n }\n triggers.filter(Boolean).forEach(function (trigger) {\n trigger.addEventListener('click', function (event) {\n return _this.showModal(event);\n });\n });\n }\n }, {\n key: \"showModal\",\n value: function showModal() {\n var _this2 = this;\n var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n this.activeElement = document.activeElement;\n this.modal.setAttribute('aria-hidden', 'false');\n this.modal.classList.add(this.config.openClass);\n this.scrollBehaviour('disable');\n this.addEventListeners();\n if (this.config.awaitOpenAnimation) {\n var handler = function handler() {\n _this2.modal.removeEventListener('animationend', handler, false);\n _this2.setFocusToFirstNode();\n };\n this.modal.addEventListener('animationend', handler, false);\n } else {\n this.setFocusToFirstNode();\n }\n this.config.onShow(this.modal, this.activeElement, event);\n }\n }, {\n key: \"closeModal\",\n value: function closeModal() {\n var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var modal = this.modal;\n this.modal.setAttribute('aria-hidden', 'true');\n this.removeEventListeners();\n this.scrollBehaviour('enable');\n if (this.activeElement && this.activeElement.focus) {\n this.activeElement.focus();\n }\n this.config.onClose(this.modal, this.activeElement, event);\n if (this.config.awaitCloseAnimation) {\n var openClass = this.config.openClass; // <- old school ftw\n\n this.modal.addEventListener('animationend', function handler() {\n modal.classList.remove(openClass);\n modal.removeEventListener('animationend', handler, false);\n }, false);\n } else {\n modal.classList.remove(this.config.openClass);\n }\n }\n }, {\n key: \"closeModalById\",\n value: function closeModalById(targetModal) {\n this.modal = document.getElementById(targetModal);\n if (this.modal) this.closeModal();\n }\n }, {\n key: \"scrollBehaviour\",\n value: function scrollBehaviour(toggle) {\n if (!this.config.disableScroll) return;\n var body = document.querySelector('body');\n switch (toggle) {\n case 'enable':\n Object.assign(body.style, {\n overflow: ''\n });\n break;\n case 'disable':\n Object.assign(body.style, {\n overflow: 'hidden'\n });\n break;\n }\n }\n }, {\n key: \"addEventListeners\",\n value: function addEventListeners() {\n this.modal.addEventListener('touchstart', this.onClick);\n this.modal.addEventListener('click', this.onClick);\n document.addEventListener('keydown', this.onKeydown);\n }\n }, {\n key: \"removeEventListeners\",\n value: function removeEventListeners() {\n this.modal.removeEventListener('touchstart', this.onClick);\n this.modal.removeEventListener('click', this.onClick);\n document.removeEventListener('keydown', this.onKeydown);\n }\n }, {\n key: \"onClick\",\n value: function onClick(event) {\n if (event.target.hasAttribute(this.config.closeTrigger)) {\n this.closeModal(event);\n }\n }\n }, {\n key: \"onKeydown\",\n value: function onKeydown(event) {\n if (event.keyCode === 27) this.closeModal(event); // esc\n\n if (event.keyCode === 9) this.retainFocus(event); // tab\n }\n }, {\n key: \"getFocusableNodes\",\n value: function getFocusableNodes() {\n var nodes = this.modal.querySelectorAll(FOCUSABLE_ELEMENTS);\n return Array.apply(void 0, _toConsumableArray(nodes));\n }\n /**\n * Tries to set focus on a node which is not a close trigger\n * if no other nodes exist then focuses on first close trigger\n */\n }, {\n key: \"setFocusToFirstNode\",\n value: function setFocusToFirstNode() {\n var _this3 = this;\n if (this.config.disableFocus) return;\n var focusableNodes = this.getFocusableNodes(); // no focusable nodes\n\n if (focusableNodes.length === 0) return; // remove nodes on whose click, the modal closes\n // could not think of a better name :(\n\n var nodesWhichAreNotCloseTargets = focusableNodes.filter(function (node) {\n return !node.hasAttribute(_this3.config.closeTrigger);\n });\n if (nodesWhichAreNotCloseTargets.length > 0) nodesWhichAreNotCloseTargets[0].focus();\n if (nodesWhichAreNotCloseTargets.length === 0) focusableNodes[0].focus();\n }\n }, {\n key: \"retainFocus\",\n value: function retainFocus(event) {\n var focusableNodes = this.getFocusableNodes(); // no focusable nodes\n\n if (focusableNodes.length === 0) return;\n /**\n * Filters nodes which are hidden to prevent\n * focus leak outside modal\n */\n\n focusableNodes = focusableNodes.filter(function (node) {\n return node.offsetParent !== null;\n }); // if disableFocus is true\n\n if (!this.modal.contains(document.activeElement)) {\n focusableNodes[0].focus();\n } else {\n var focusedItemIndex = focusableNodes.indexOf(document.activeElement);\n if (event.shiftKey && focusedItemIndex === 0) {\n focusableNodes[focusableNodes.length - 1].focus();\n event.preventDefault();\n }\n if (!event.shiftKey && focusableNodes.length > 0 && focusedItemIndex === focusableNodes.length - 1) {\n focusableNodes[0].focus();\n event.preventDefault();\n }\n }\n }\n }]);\n return Modal;\n }();\n /**\n * Modal prototype ends.\n * Here on code is responsible for detecting and\n * auto binding event handlers on modal triggers\n */\n // Keep a reference to the opened modal\n\n var activeModal = null;\n /**\n * Generates an associative array of modals and it's\n * respective triggers\n * @param {array} triggers An array of all triggers\n * @param {string} triggerAttr The data-attribute which triggers the module\n * @return {array}\n */\n\n var generateTriggerMap = function generateTriggerMap(triggers, triggerAttr) {\n var triggerMap = [];\n triggers.forEach(function (trigger) {\n var targetModal = trigger.attributes[triggerAttr].value;\n if (triggerMap[targetModal] === undefined) triggerMap[targetModal] = [];\n triggerMap[targetModal].push(trigger);\n });\n return triggerMap;\n };\n /**\n * Validates whether a modal of the given id exists\n * in the DOM\n * @param {number} id The id of the modal\n * @return {boolean}\n */\n\n var validateModalPresence = function validateModalPresence(id) {\n if (!document.getElementById(id)) {\n console.warn(\"MicroModal: \\u2757Seems like you have missed %c'\".concat(id, \"'\"), 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', 'ID somewhere in your code. Refer example below to resolve it.');\n console.warn(\"%cExample:\", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', \"
\"));\n return false;\n }\n };\n /**\n * Validates if there are modal triggers present\n * in the DOM\n * @param {array} triggers An array of data-triggers\n * @return {boolean}\n */\n\n var validateTriggerPresence = function validateTriggerPresence(triggers) {\n if (triggers.length <= 0) {\n console.warn(\"MicroModal: \\u2757Please specify at least one %c'micromodal-trigger'\", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', 'data attribute.');\n console.warn(\"%cExample:\", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', \"\");\n return false;\n }\n };\n /**\n * Checks if triggers and their corresponding modals\n * are present in the DOM\n * @param {array} triggers Array of DOM nodes which have data-triggers\n * @param {array} triggerMap Associative array of modals and their triggers\n * @return {boolean}\n */\n\n var validateArgs = function validateArgs(triggers, triggerMap) {\n validateTriggerPresence(triggers);\n if (!triggerMap) return true;\n for (var id in triggerMap) {\n validateModalPresence(id);\n }\n return true;\n };\n /**\n * Binds click handlers to all modal triggers\n * @param {object} config [description]\n * @return void\n */\n\n var init = function init(config) {\n // Create an config object with default openTrigger\n var options = Object.assign({}, {\n openTrigger: 'data-micromodal-trigger'\n }, config); // Collects all the nodes with the trigger\n\n var triggers = _toConsumableArray(document.querySelectorAll(\"[\".concat(options.openTrigger, \"]\"))); // Makes a mappings of modals with their trigger nodes\n\n var triggerMap = generateTriggerMap(triggers, options.openTrigger); // Checks if modals and triggers exist in dom\n\n if (options.debugMode === true && validateArgs(triggers, triggerMap) === false) return; // For every target modal creates a new instance\n\n for (var key in triggerMap) {\n var value = triggerMap[key];\n options.targetModal = key;\n options.triggers = _toConsumableArray(value);\n activeModal = new Modal(options); // eslint-disable-line no-new\n }\n };\n /**\n * Shows a particular modal\n * @param {string} targetModal [The id of the modal to display]\n * @param {object} config [The configuration object to pass]\n * @return {void}\n */\n\n var show = function show(targetModal, config) {\n var options = config || {};\n options.targetModal = targetModal; // Checks if modals and triggers exist in dom\n\n if (options.debugMode === true && validateModalPresence(targetModal) === false) return; // clear events in case previous modal wasn't close\n\n if (activeModal) activeModal.removeEventListeners(); // stores reference to active modal\n\n activeModal = new Modal(options); // eslint-disable-line no-new\n\n activeModal.showModal();\n };\n /**\n * Closes the active modal\n * @param {string} targetModal [The id of the modal to close]\n * @return {void}\n */\n\n var close = function close(targetModal) {\n targetModal ? activeModal.closeModalById(targetModal) : activeModal.closeModal();\n };\n return {\n init: init,\n show: show,\n close: close\n };\n}();\nwindow.MicroModal = MicroModal;\nexport default MicroModal;"],"sourceRoot":""}