/* flatpickr v4.5.2, @license MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.confirmDatePlugin = factory()); }(this, (function () { 'use strict'; const defaultConfig = { confirmIcon: " ", confirmText: "OK ", showAlways: false, theme: "light", }; function confirmDatePlugin(pluginConfig) { const config = Object.assign({}, defaultConfig, pluginConfig); let confirmContainer; return function (fp) { if (fp.config.noCalendar || fp.isMobile) return {}; return Object.assign({ onKeyDown(_, __, ___, e) { if (fp.config.enableTime && e.key === "Tab" && e.target === fp.amPM) { e.preventDefault(); confirmContainer.focus(); } else if (e.key === "Enter" && e.target === confirmContainer) fp.close(); }, onReady() { confirmContainer = fp._createElement("div", `flatpickr-confirm ${config.showAlways ? "visible" : ""} ${config.theme}Theme`, config.confirmText); confirmContainer.tabIndex = -1; confirmContainer.innerHTML += config.confirmIcon; confirmContainer.addEventListener("click", fp.close); fp.calendarContainer.appendChild(confirmContainer); } }, (!config.showAlways ? { onChange: function (_, dateStr) { const showCondition = fp.config.enableTime || fp.config.mode === "multiple"; if (dateStr && !fp.config.inline && showCondition) return confirmContainer.classList.add("visible"); confirmContainer.classList.remove("visible"); }, } : {})); }; } return confirmDatePlugin; })));