From 93f04419499d70151709bc547f80dbb16e54fd7c Mon Sep 17 00:00:00 2001 From: Yury Uvarov Date: Tue, 7 Nov 2023 11:54:52 +0300 Subject: [PATCH] Release v2.7.1 --- demo/index.css | 2 +- package/README.md | 112 +++++++++++------------- package/build/vanilla-calendar.min.css | 2 +- package/build/vanilla-calendar.min.js | 2 +- package/build/vanilla-calendar.min.mjs | 14 +++ package/package.json | 4 +- package/src/styles/vanilla-calendar.css | 6 +- 7 files changed, 74 insertions(+), 68 deletions(-) diff --git a/demo/index.css b/demo/index.css index 3029353c..28d6bf47 100644 --- a/demo/index.css +++ b/demo/index.css @@ -19,7 +19,7 @@ } .wrapper-calendar { - @apply w-[550px] max-w-max justify-center items-center flex flex-col mb-4 relative + @apply w-[550px] } .input { diff --git a/package/README.md b/package/README.md index 8ac6ab40..9dd71921 100644 --- a/package/README.md +++ b/package/README.md @@ -1,32 +1,42 @@ +# Vanilla Calendar - A Lightweight, Feature-Rich JavaScript Date and Time Picker + [![vanilla-calendar preview](https://vanilla-calendar.com/vanilla-calendar-preview.png)](https://vanilla-calendar.com/) -# Lightweight, simple, feature-rich and no dependencies. [![package-badge]][package] -VanillaCalendar is a pure JavaScript date and time picker using TypeScript so it supports any JS framework and library. +Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies. -The final minified .js file is ~ **44.4 KB** and with gzip is ~ **10.8** KB. +## Key Features -Latest version without TypeScript - [v1.5.5](https://www.npmjs.com/package/@uvarov.frontend/vanilla-calendar/v/1.5.5) (**No longer supported**) +- **Lightweight**: The final minified .js file is only approximately **44.4 KB**, and with gzip compression, it's just around **10.8 KB**. +- **No Dependencies**: Vanilla Calendar is entirely self-contained, ensuring you don't need to include additional libraries. +- **Simple Localization**: Supports simple localization for any language. +- **Customizable**: Can be easily configured using CSS and HTML markup. +- **Multiple Instances**: Allows for an unlimited number of calendar instances on a single page. +- **Theme Support**: Includes two themes - the light theme and the dark theme. +- **Week Start Customization**: Supports both Sunday and Monday as the beginning of the week. +- **Week Number Display**: Can display week numbers throughout the year. +- **Not Tied to Input Tags**: Unlike many date pickers, it's not limited to the `` tag. -This plugin is completely free, any support from you is important. Please report problems or new ideas, it's really important! +## Browser Support -If you like VanillaCalendar, please give it a 🌟 star on GitHub. +Vanilla Calendar is compatible with a wide range of browsers: -## Support browsers ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png) --- | --- | --- | --- | --- | 57+ ✔ | 52+ ✔ | 80+ ✔ | 44+ ✔ | 10.1+ ✔ | -## Getting Started +## Support and Feedback -This calendar has no dependencies, has a simple localization for any language, is displayed anywhere, is not tied to the **«input»** tag, can have an unlimited number of copies on the page and is easily configurable both using CSS and by changing the html markup. +This plugin is completely free, and your support is important. Please feel free to report any issues or share your new ideas; it's really important! -You can include it as a separate script in your html document or import it into your bundler. +If you like Vanilla Calendar, please consider giving it a 🌟 star on GitHub. + +## Getting Started -### Install +### Installation -You can get it via npm or yarn: +You can install Vanilla Calendar using npm or yarn: ```sh npm install @uvarov.frontend/vanilla-calendar @@ -34,11 +44,11 @@ npm install @uvarov.frontend/vanilla-calendar yarn add @uvarov.frontend/vanilla-calendar ``` -If you are not using a package manager, connect locally or via [CDN](https://cdn.jsdelivr.net/npm/@uvarov.frontend/vanilla-calendar/build/). +If you prefer not to use a package manager, you can also include it via [CDN](https://cdn.jsdelivr.net/npm/@uvarov.frontend/vanilla-calendar/build/) or [download](https://vanilla-calendar.com/vanilla-calendar.zip) it from the website. ### Usage -Simple usage example: +Here's a simple example of how to use Vanilla Calendar in your HTML: ```html @@ -52,28 +62,28 @@ Simple usage example: ``` -The **vanilla-calendar.min.css** file contains the properties of the calendar skeleton, other css files in the **themes** directory contain only the calendar color scheme. -The calendar automatically displays the theme used in the user's system. You can disable this default behavior and install any of the themes forcibly. In this case, you don't need to import all the themes. +To add the necessary styles and scripts, you can use the following code: ```js -// JS Script -import VanillaCalendar from '@uvarov.frontend/vanilla-calendar'; +// Import Vanilla Calendar +import Vanilla Calendar from '@uvarov.frontend/vanilla-calendar'; -// Basic styles +// Import the basic styles import '@uvarov.frontend/vanilla-calendar/build/vanilla-calendar.min.css'; -// Additional styles +// Import additional styles import '@uvarov.frontend/vanilla-calendar/build/themes/light.min.css'; import '@uvarov.frontend/vanilla-calendar/build/themes/dark.min.css'; -const calendar = new VanillaCalendar('#calendar'); +// Initialize the calendar +const calendar = new Vanilla Calendar('#calendar'); calendar.init(); // or // const calendarWithInput = new VanillaCalendar('#calendar-input', { input: true }); // calendarWithInput.init(); ``` -If you downloaded the files manually or decided to use a CDN, then instead of the example above, you need to add all the necessary files to the **head** tag of your HTML document. Here is an example of such usage: +If you're not using a package manager and prefer manual installation or CDN usage, you can include the necessary files in your HTML document's ``: ```html @@ -98,11 +108,21 @@ If you downloaded the files manually or decided to use a CDN, then instead of th ``` -### DOM Templates +## CSS Themes + +Vanilla Calendar includes two CSS themes: the **light theme** and the **dark theme**. + +- The **vanilla-calendar.min.css** file contains the essential structural styles for the calendar. +- The **light.min.css** theme provides a light color scheme. +- The **dark.min.css** theme offers a dark color scheme. + +The calendar will automatically display the theme based on the user's system preferences. If you want to enforce a specific theme, you can do so manually without the need to import all themes separately. + +## DOM Templates -The calendar has registered components with which you can completely change the structure of the calendar. -Tags containing the **«#»** character are registered calendar components and must include a trailing slash at the end of the tag. -Default Template: +Vanilla Calendar features customizable DOM templates that allow you to modify the structure of the calendar to fit your needs. The templates are identified by tags containing the **#** character, and they should include a trailing slash at the end. + +Here's an example of the default template: ```js new VanillaCalendar('#calendar', { @@ -118,7 +138,7 @@ new VanillaCalendar('#calendar', {
<#WeekNumbers /> -
+
<#Week /> <#Days />
@@ -129,45 +149,13 @@ new VanillaCalendar('#calendar', { }); ``` -### Example using React + TypeScript - -Since the final plugin file is pure JavaScript without any dependencies, if desired, it can be used with any framework or library, such as Vue, React, Angular, etc. +## React Component -```tsx -import { useEffect, useRef } from 'react'; -import VanillaCalendar from '@uvarov.frontend/vanilla-calendar'; -import '@uvarov.frontend/vanilla-calendar/build/vanilla-calendar.min.css'; -import '@uvarov.frontend/vanilla-calendar/build/themes/light.min.css'; -import '@uvarov.frontend/vanilla-calendar/build/themes/dark.min.css'; - -const Calendar: React.FC = () => { - const calendarEl = useRef(null); - - useEffect(() => { - if (!calendarEl.current) return; - - const calendar = new VanillaCalendar(calendarEl.current, { - settings: { - lang: 'en', - selection: { - time: 12, - }, - }, - }); - calendar.init(); - }, [calendarEl]); - - return ( -
- ); -}; - -export default Calendar; -``` +For detailed instructions on using Vanilla Calendar in a React component with TypeScript, please visit the [website](https://vanilla-calendar.com/docs/learn/additional-features/react-component) for comprehensive documentation and examples. ## API Reference -You can see all the parameters and settings of the calendar in the [reference](https://vanilla-calendar.com/docs/reference/). +For detailed information on the available parameters and settings, please refer to the [API reference](https://vanilla-calendar.com/docs/reference/). ## Sponsor diff --git a/package/build/vanilla-calendar.min.css b/package/build/vanilla-calendar.min.css index c1954e8f..082e5241 100644 --- a/package/build/vanilla-calendar.min.css +++ b/package/build/vanilla-calendar.min.css @@ -1,2 +1,2 @@ /*! name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar */ -.vanilla-calendar{position:relative;display:flex;height:-webkit-max-content;height:max-content;min-width:275px;max-width:100%;flex-direction:column;border-radius:.75rem;padding:1rem;opacity:1;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.vanilla-calendar button:focus-visible{border-radius:.5rem;outline-style:solid;outline-width:1px}.vanilla-calendar.vanilla-calendar_multiple .vanilla-calendar-days{flex-grow:0}.vanilla-calendar_hidden{pointer-events:none;opacity:0}.vanilla-calendar_to-input{position:absolute;left:0;bottom:0;margin-top:.25rem}.vanilla-calendar-controls{pointer-events:none;position:absolute;left:0;right:0;top:0;z-index:20;box-sizing:content-box;display:flex;align-items:center;justify-content:space-between;padding-left:1rem;padding-right:1rem;padding-top:1.25rem}.vanilla-calendar-arrow{pointer-events:auto;position:relative;display:block;height:1.5rem;width:1.5rem;cursor:pointer;border-width:0px;background-color:transparent}.vanilla-calendar-arrow:before{position:absolute;inset:0;content:var(--tw-content);content:"";-webkit-mask-image:url('data:image/svg+xml, %3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M12 16c-.3 0-.5-.1-.7-.3l-6-6c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l5.3 5.3 5.3-5.3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-6 6c-.2.2-.4.3-.7.3z"/%3E%3C/svg%3E');mask-image:url('data:image/svg+xml, %3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M12 16c-.3 0-.5-.1-.7-.3l-6-6c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l5.3 5.3 5.3-5.3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-6 6c-.2.2-.4.3-.7.3z"/%3E%3C/svg%3E');-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:50% 50%;mask-position:50% 50%}.vanilla-calendar-arrow.vanilla-calendar-arrow_prev:before{-webkit-transform:rotateZ(90deg);transform:rotate(90deg)}.vanilla-calendar-arrow.vanilla-calendar-arrow_next:before{-webkit-transform:rotateZ(-90deg);transform:rotate(-90deg)}.vanilla-calendar-grid{display:grid;flex-grow:1;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1.75rem}.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column{pointer-events:none;opacity:.3}.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column.vanilla-calendar-column_month,.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column.vanilla-calendar-column_year{pointer-events:auto;opacity:1}.vanilla-calendar-column{display:flex;min-width:-webkit-min-content;min-width:min-content;flex-direction:column}.vanilla-calendar-header{position:relative;margin-bottom:.75rem;display:flex;align-items:center;padding-left:.25rem;padding-right:.25rem}.vanilla-calendar-header__content{display:grid;flex-grow:1;grid-auto-columns:-webkit-max-content;grid-auto-columns:max-content;grid-auto-flow:column;align-items:center;justify-content:center;white-space:pre-wrap;padding-left:1rem;padding-right:1rem}.vanilla-calendar-month,.vanilla-calendar-year{cursor:pointer;border-radius:.25rem;border-width:0px;background-color:transparent;padding:.25rem;font-size:1rem;line-height:1.5rem;font-weight:700}.vanilla-calendar-month.vanilla-calendar-month_disabled,.vanilla-calendar-year.vanilla-calendar-year_disabled{pointer-events:none}.vanilla-calendar-months{display:grid;flex-grow:1;grid-template-columns:repeat(4,minmax(0,1fr));align-items:center;row-gap:1rem;-webkit-column-gap:.5rem;column-gap:.5rem}.vanilla-calendar-years{display:grid;flex-grow:1;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;row-gap:1rem;-webkit-column-gap:.5rem;column-gap:.5rem}.vanilla-calendar-months_selecting .vanilla-calendar-months__month,.vanilla-calendar-years_selecting .vanilla-calendar-years__year{cursor:pointer}.vanilla-calendar-months_selecting .vanilla-calendar-months__month .vanilla-calendar-months__month_disabled,.vanilla-calendar-years_selecting .vanilla-calendar-years__year .vanilla-calendar-years__year_disabled{cursor:default}.vanilla-calendar-months__month,.vanilla-calendar-years__year{display:flex;height:2.5rem;align-items:center;justify-content:center;word-break:break-all;border-radius:.5rem;border-width:0px;padding:.25rem;text-align:center;font-size:.75rem;line-height:1rem;font-weight:600}.vanilla-calendar-months__month.vanilla-calendar-months__month_disabled,.vanilla-calendar-years__year.vanilla-calendar-years__year_disabled{pointer-events:none}.vanilla-calendar-week-numbers{display:flex;flex-grow:1;flex-direction:column}.vanilla-calendar-week-numbers__title{margin-bottom:.5rem;display:flex;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:700}.vanilla-calendar-week-numbers__content{display:grid;grid-auto-flow:row;align-items:center;justify-items:center;row-gap:.25rem}.vanilla-calendar-week-number{display:flex;height:100%;min-height:1.875rem;width:100%;min-width:1.875rem;cursor:pointer;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:600}.vanilla-calendar-wrapper{display:flex;flex-grow:1}.vanilla-calendar-content{display:flex;flex-grow:1;flex-direction:column}.vanilla-calendar-week{margin-bottom:.5rem;display:grid;grid-template-columns:repeat(7,1fr);justify-items:center}.vanilla-calendar-week__day{display:flex;height:100%;width:100%;min-width:1.875rem;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:700}.vanilla-calendar-days{display:grid;flex-grow:1;grid-template-columns:repeat(7,1fr);align-items:center;justify-items:center;row-gap:.25rem}.vanilla-calendar-days_selecting .vanilla-calendar-day__btn{cursor:pointer}.vanilla-calendar-days_selecting .vanilla-calendar-day__btn_disabled{cursor:default}.vanilla-calendar-day{position:relative;display:flex;height:100%;width:100%;align-items:center;justify-content:center}.vanilla-calendar-day:focus-visible .vanilla-calendar-day__popup,.vanilla-calendar-day:hover .vanilla-calendar-day__popup{pointer-events:auto;opacity:1}.vanilla-calendar-day_selected-first .vanilla-calendar-day__btn_selected{border-top-right-radius:0;border-bottom-right-radius:0;border-top-left-radius:.5rem;border-bottom-left-radius:.5rem}.vanilla-calendar-day_selected-last .vanilla-calendar-day__btn_selected{border-top-left-radius:0;border-bottom-left-radius:0;border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.vanilla-calendar-day_selected-intermediate .vanilla-calendar-day__btn_intermediate{border-radius:0}.vanilla-calendar-day__btn{display:flex;height:100%;min-height:1.875rem;width:100%;min-width:1.875rem;cursor:default;align-items:center;justify-content:center;border-radius:.5rem;border-width:0px;font-size:.75rem;line-height:1rem;font-weight:400}.vanilla-calendar-day__btn_today{font-weight:700}.vanilla-calendar-day__btn_disabled{pointer-events:none}.vanilla-calendar-day__popup{-webkit-transform:translateX(-50%);transform:translate(-50%);pointer-events:none;position:absolute;left:50%;top:100%;z-index:20;width:8rem;padding:1rem .75rem .5rem;font-size:.75rem;line-height:1rem;font-weight:400;opacity:0}.vanilla-calendar-day__popup:before{content:var(--tw-content);position:absolute}.vanilla-calendar-day__popup:after{content:var(--tw-content);position:absolute}.vanilla-calendar-day__popup:hover{pointer-events:auto;opacity:1}.vanilla-calendar-day__popup:before{content:"";left:0;bottom:0;z-index:-10;display:block;height:calc(100% - 8px);width:100%;border-radius:.5rem}.vanilla-calendar-day__popup:after{content:"";-webkit-transform:translateX(-50%);transform:translate(-50%);left:50%;top:1px;z-index:-10;display:block;height:0px;width:0px;border-left-width:8px;border-right-width:8px;border-top-width:0px;border-bottom-width:8px;border-style:solid;border-left-color:transparent;border-right-color:transparent;border-top-color:transparent}.vanilla-calendar-time{margin-top:.75rem;display:grid;grid-template-columns:auto 1fr;gap:.75rem;border-top-width:1px;border-bottom-width:0px;border-left-width:0px;border-right-width:0px;border-style:solid;padding-top:.75rem}.vanilla-calendar-time__content{display:grid;grid-auto-flow:column;align-items:center}.vanilla-calendar-time__hours{position:relative;margin-right:.35rem;width:1.75rem}.vanilla-calendar-time__hours:after{position:absolute;right:-5px;top:50%;margin-top:calc(-50% + 1px);display:block;--tw-content: ":";content:var(--tw-content)}.vanilla-calendar-time__minutes{width:1.75rem}.vanilla-calendar-time__hours input,.vanilla-calendar-time__minutes input{position:relative;margin:0;box-sizing:border-box;display:block;width:100%;border-radius:.25rem;border-width:0px;padding:.125rem;text-align:center;font-size:1.125rem;font-weight:600;line-height:1.125rem}.vanilla-calendar-time__hours input:focus-visible,.vanilla-calendar-time__minutes input:focus-visible{outline-style:solid;outline-width:1px}.vanilla-calendar-time__hours input:disabled,.vanilla-calendar-time__minutes input:disabled{cursor:default}.vanilla-calendar-time__hours input:hover:disabled,.vanilla-calendar-time__minutes input:hover:disabled{background-color:transparent}.vanilla-calendar-time__keeping{margin-left:1px;margin-top:.25rem;width:22px;cursor:pointer;border-radius:.25rem;border-width:0px;background-color:transparent;padding:0;font-size:11px}.vanilla-calendar-time__keeping:focus-visible{outline-style:solid;outline-width:1px}.vanilla-calendar-time__keeping:disabled{cursor:default}.vanilla-calendar-time__keeping:hover:disabled{background-color:transparent}.vanilla-calendar-time__ranges{display:grid;grid-auto-flow:row}.vanilla-calendar-time__range{position:relative;z-index:10;font-size:0}.vanilla-calendar-time__range:before{content:var(--tw-content);left:0}.vanilla-calendar-time__range:after{content:var(--tw-content);right:0}.vanilla-calendar-time__range:before,.vanilla-calendar-time__range:after{content:"";-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none;position:absolute;top:50%;z-index:10;height:.5rem;width:1px}.vanilla-calendar-time__range input{position:relative;margin:0;height:1.25rem;width:100%;cursor:pointer;-webkit-appearance:none;appearance:none;outline-width:0px}.vanilla-calendar-time__range input::-webkit-slider-thumb{position:relative;z-index:20;margin-top:-.5rem;box-sizing:border-box;height:1rem;width:.75rem;cursor:pointer;-webkit-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;border-style:solid;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-moz-range-thumb{position:relative;z-index:20;box-sizing:border-box;height:1rem;width:.75rem;cursor:pointer;border-radius:.25rem;border-width:1px;border-style:solid;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-webkit-slider-runnable-track{margin-top:1px;box-sizing:border-box;height:1px;width:100%;cursor:pointer;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-moz-range-track{margin-top:1px;box-sizing:border-box;height:1px;width:100%;cursor:pointer;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)} +.vanilla-calendar{position:relative;display:flex;height:-webkit-max-content;height:max-content;width:-webkit-max-content;width:max-content;min-width:275px;max-width:100%;flex-direction:column;border-radius:.75rem;padding:1rem;opacity:1;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.vanilla-calendar_multiple{width:auto}.vanilla-calendar button:focus-visible{border-radius:.5rem;outline-style:solid;outline-width:1px}.vanilla-calendar.vanilla-calendar_multiple .vanilla-calendar-days{flex-grow:0}.vanilla-calendar_hidden{pointer-events:none;opacity:0}.vanilla-calendar_to-input{position:absolute;left:0;bottom:0;margin-top:.25rem}.vanilla-calendar-controls{pointer-events:none;position:absolute;left:0;right:0;top:0;z-index:20;box-sizing:content-box;display:flex;align-items:center;justify-content:space-between;padding-left:1rem;padding-right:1rem;padding-top:1.25rem}.vanilla-calendar-arrow{pointer-events:auto;position:relative;display:block;height:1.5rem;width:1.5rem;cursor:pointer;border-width:0px;background-color:transparent}.vanilla-calendar-arrow:before{position:absolute;inset:0;content:var(--tw-content);content:"";-webkit-mask-image:url('data:image/svg+xml, %3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M12 16c-.3 0-.5-.1-.7-.3l-6-6c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l5.3 5.3 5.3-5.3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-6 6c-.2.2-.4.3-.7.3z"/%3E%3C/svg%3E');mask-image:url('data:image/svg+xml, %3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"%3E%3Cpath d="M12 16c-.3 0-.5-.1-.7-.3l-6-6c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l5.3 5.3 5.3-5.3c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-6 6c-.2.2-.4.3-.7.3z"/%3E%3C/svg%3E');-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:50% 50%;mask-position:50% 50%}.vanilla-calendar-arrow.vanilla-calendar-arrow_prev:before{-webkit-transform:rotateZ(90deg);transform:rotate(90deg)}.vanilla-calendar-arrow.vanilla-calendar-arrow_next:before{-webkit-transform:rotateZ(-90deg);transform:rotate(-90deg)}.vanilla-calendar-grid{display:grid;flex-grow:1;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1.75rem}.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column{pointer-events:none;opacity:.3}.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column.vanilla-calendar-column_month,.vanilla-calendar-grid.vanilla-calendar-grid_disabled .vanilla-calendar-column.vanilla-calendar-column_year{pointer-events:auto;opacity:1}.vanilla-calendar-column{display:flex;min-width:-webkit-min-content;min-width:min-content;flex-direction:column}.vanilla-calendar-header{position:relative;margin-bottom:.75rem;display:flex;align-items:center;padding-left:.25rem;padding-right:.25rem}.vanilla-calendar-header__content{display:grid;flex-grow:1;grid-auto-columns:-webkit-max-content;grid-auto-columns:max-content;grid-auto-flow:column;align-items:center;justify-content:center;white-space:pre-wrap;padding-left:1rem;padding-right:1rem}.vanilla-calendar-month,.vanilla-calendar-year{cursor:pointer;border-radius:.25rem;border-width:0px;background-color:transparent;padding:.25rem;font-size:1rem;line-height:1.5rem;font-weight:700}.vanilla-calendar-month.vanilla-calendar-month_disabled,.vanilla-calendar-year.vanilla-calendar-year_disabled{pointer-events:none}.vanilla-calendar-months{display:grid;flex-grow:1;grid-template-columns:repeat(4,minmax(0,1fr));align-items:center;row-gap:1rem;-webkit-column-gap:.5rem;column-gap:.5rem}.vanilla-calendar-years{display:grid;flex-grow:1;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;row-gap:1rem;-webkit-column-gap:.5rem;column-gap:.5rem}.vanilla-calendar-months_selecting .vanilla-calendar-months__month,.vanilla-calendar-years_selecting .vanilla-calendar-years__year{cursor:pointer}.vanilla-calendar-months_selecting .vanilla-calendar-months__month .vanilla-calendar-months__month_disabled,.vanilla-calendar-years_selecting .vanilla-calendar-years__year .vanilla-calendar-years__year_disabled{cursor:default}.vanilla-calendar-months__month,.vanilla-calendar-years__year{display:flex;height:2.5rem;align-items:center;justify-content:center;word-break:break-all;border-radius:.5rem;border-width:0px;padding:.25rem;text-align:center;font-size:.75rem;line-height:1rem;font-weight:600}.vanilla-calendar-months__month.vanilla-calendar-months__month_disabled,.vanilla-calendar-years__year.vanilla-calendar-years__year_disabled{pointer-events:none}.vanilla-calendar-week-numbers{display:flex;flex-grow:1;flex-direction:column}.vanilla-calendar-week-numbers__title{margin-bottom:.5rem;display:flex;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:700}.vanilla-calendar-week-numbers__content{display:grid;grid-auto-flow:row;align-items:center;justify-items:center;row-gap:.25rem}.vanilla-calendar-week-number{display:flex;height:100%;min-height:1.875rem;width:100%;min-width:1.875rem;cursor:pointer;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:600}.vanilla-calendar-wrapper{display:flex;flex-grow:1}.vanilla-calendar-content{display:flex;flex-grow:1;flex-direction:column}.vanilla-calendar-week{margin-bottom:.5rem;display:grid;grid-template-columns:repeat(7,1fr);justify-items:center}.vanilla-calendar-week__day{display:flex;height:100%;width:100%;min-width:1.875rem;align-items:center;justify-content:center;font-size:.75rem;line-height:1rem;font-weight:700}.vanilla-calendar-days{display:grid;flex-grow:1;grid-template-columns:repeat(7,1fr);align-items:center;justify-items:center;row-gap:.25rem}.vanilla-calendar-days_selecting .vanilla-calendar-day__btn{cursor:pointer}.vanilla-calendar-days_selecting .vanilla-calendar-day__btn_disabled{cursor:default}.vanilla-calendar-day{position:relative;display:flex;height:100%;width:100%;align-items:center;justify-content:center}.vanilla-calendar-day:focus-visible .vanilla-calendar-day__popup,.vanilla-calendar-day:hover .vanilla-calendar-day__popup{pointer-events:auto;opacity:1}.vanilla-calendar-day_selected-first .vanilla-calendar-day__btn_selected{border-top-right-radius:0;border-bottom-right-radius:0;border-top-left-radius:.5rem;border-bottom-left-radius:.5rem}.vanilla-calendar-day_selected-last .vanilla-calendar-day__btn_selected{border-top-left-radius:0;border-bottom-left-radius:0;border-top-right-radius:.5rem;border-bottom-right-radius:.5rem}.vanilla-calendar-day_selected-intermediate .vanilla-calendar-day__btn_intermediate{border-radius:0}.vanilla-calendar-day__btn{display:flex;height:100%;min-height:1.875rem;width:100%;min-width:1.875rem;cursor:default;align-items:center;justify-content:center;border-radius:.5rem;border-width:0px;font-size:.75rem;line-height:1rem;font-weight:400}.vanilla-calendar-day__btn_today{font-weight:700}.vanilla-calendar-day__btn_disabled{pointer-events:none}.vanilla-calendar-day__popup{-webkit-transform:translateX(-50%);transform:translate(-50%);pointer-events:none;position:absolute;left:50%;top:100%;z-index:20;width:8rem;padding:1rem .75rem .5rem;font-size:.75rem;line-height:1rem;font-weight:400;opacity:0}.vanilla-calendar-day__popup:before{content:var(--tw-content);position:absolute}.vanilla-calendar-day__popup:after{content:var(--tw-content);position:absolute}.vanilla-calendar-day__popup:hover{pointer-events:auto;opacity:1}.vanilla-calendar-day__popup:before{content:"";left:0;bottom:0;z-index:-10;display:block;height:calc(100% - 8px);width:100%;border-radius:.5rem}.vanilla-calendar-day__popup:after{content:"";-webkit-transform:translateX(-50%);transform:translate(-50%);left:50%;top:1px;z-index:-10;display:block;height:0px;width:0px;border-left-width:8px;border-right-width:8px;border-top-width:0px;border-bottom-width:8px;border-style:solid;border-left-color:transparent;border-right-color:transparent;border-top-color:transparent}.vanilla-calendar-time{margin-top:.75rem;display:grid;grid-template-columns:auto 1fr;gap:.75rem;border-top-width:1px;border-bottom-width:0px;border-left-width:0px;border-right-width:0px;border-style:solid;padding-top:.75rem}.vanilla-calendar-time__content{display:grid;grid-auto-flow:column;align-items:center}.vanilla-calendar-time__hours{position:relative;margin-right:.35rem;width:1.75rem}.vanilla-calendar-time__hours:after{position:absolute;right:-5px;top:50%;margin-top:calc(-50% + 1px);display:block;--tw-content: ":";content:var(--tw-content)}.vanilla-calendar-time__minutes{width:1.75rem}.vanilla-calendar-time__hours input,.vanilla-calendar-time__minutes input{position:relative;margin:0;box-sizing:border-box;display:block;width:100%;border-radius:.25rem;border-width:0px;padding:.125rem;text-align:center;font-size:1.125rem;font-weight:600;line-height:1.125rem}.vanilla-calendar-time__hours input:focus-visible,.vanilla-calendar-time__minutes input:focus-visible{outline-style:solid;outline-width:1px}.vanilla-calendar-time__hours input:disabled,.vanilla-calendar-time__minutes input:disabled{cursor:default}.vanilla-calendar-time__hours input:hover:disabled,.vanilla-calendar-time__minutes input:hover:disabled{background-color:transparent}.vanilla-calendar-time__keeping{margin-left:1px;margin-top:.25rem;width:22px;cursor:pointer;border-radius:.25rem;border-width:0px;background-color:transparent;padding:0;font-size:11px}.vanilla-calendar-time__keeping:focus-visible{outline-style:solid;outline-width:1px}.vanilla-calendar-time__keeping:disabled{cursor:default}.vanilla-calendar-time__keeping:hover:disabled{background-color:transparent}.vanilla-calendar-time__ranges{display:grid;grid-auto-flow:row}.vanilla-calendar-time__range{position:relative;z-index:10;font-size:0}.vanilla-calendar-time__range:before{content:var(--tw-content);left:0}.vanilla-calendar-time__range:after{content:var(--tw-content);right:0}.vanilla-calendar-time__range:before,.vanilla-calendar-time__range:after{content:"";-webkit-transform:translateY(-50%);transform:translateY(-50%);pointer-events:none;position:absolute;top:50%;z-index:10;height:.5rem;width:1px}.vanilla-calendar-time__range input{position:relative;margin:0;height:1.25rem;width:100%;cursor:pointer;-webkit-appearance:none;appearance:none;outline-width:0px}.vanilla-calendar-time__range input::-webkit-slider-thumb{position:relative;z-index:20;margin-top:-.5rem;box-sizing:border-box;height:1rem;width:.75rem;cursor:pointer;-webkit-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;border-style:solid;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-moz-range-thumb{position:relative;z-index:20;box-sizing:border-box;height:1rem;width:.75rem;cursor:pointer;border-radius:.25rem;border-width:1px;border-style:solid;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-webkit-slider-runnable-track{margin-top:1px;box-sizing:border-box;height:1px;width:100%;cursor:pointer;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.vanilla-calendar-time__range input::-moz-range-track{margin-top:1px;box-sizing:border-box;height:1px;width:100%;cursor:pointer;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)} diff --git a/package/build/vanilla-calendar.min.js b/package/build/vanilla-calendar.min.js index 7e9c3e91..f01f5158 100644 --- a/package/build/vanilla-calendar.min.js +++ b/package/build/vanilla-calendar.min.js @@ -1,2 +1,2 @@ /*! name: @uvarov.frontend/vanilla-calendar | url: https://github.com/uvarov-frontend/vanilla-calendar */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VanillaCalendar=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(t,l,s)=>l in t?e(t,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[l]=s,n=(e,t,l)=>(a(e,"symbol"!=typeof t?t+"":t,l),l);const i=e=>{const t=e.getFullYear();let l=e.getMonth()+1,s=e.getDate();return l=l<10?`0${l}`:l,s=s<10?`0${s}`:s,`${t}-${l}-${s}`},d=e=>{const t=[];return e.forEach((e=>{e.match(/^(\d{4}-\d{2}-\d{2})$/g)?t.push(e):e.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g,((e,l,s)=>{const a=new Date(`${l}T00:00:00`),n=new Date(`${s}T00:00:00`),d=new Date(a.getTime());for(;d<=n;d.setDate(d.getDate()+1))t.push(i(d));return e}))})),t},r=e=>{const t=Number(e);let l=String(t);return 0===t?l="12":13===t?l="01":14===t?l="02":15===t?l="03":16===t?l="04":17===t?l="05":18===t?l="06":19===t?l="07":20===t?l="08":21===t?l="09":22===t?l="10":23===t&&(l="11"),l},c=e=>{var t,l;e.rangeMin=e.settings.range.min,e.rangeMax=e.settings.range.max,e.rangeDisabled=e.settings.range.disabled?d([...e.settings.range.disabled]):[],e.rangeEnabled=e.settings.range.enabled?d([...e.settings.range.enabled]):[],e.selectedDates=e.settings.selected.dates?d([...e.settings.selected.dates]):[],e.selectedHolidays=e.settings.selected.holidays?d([...e.settings.selected.holidays]):[],e.settings.range.disablePast&&!e.settings.range.disableAllDays&&new Date(`${e.settings.range.min}T00:00:00`)+new Date(e)-+new Date(t))),(null==(l=e.rangeEnabled)?void 0:l[0])&&e.settings.range.disableAllDays&&(e.rangeMin=e.rangeEnabled[0],e.rangeMax=e.rangeEnabled[e.rangeEnabled.length-1]);const s=new Date(`${e.rangeMin}T00:00:00`),a=new Date(`${e.rangeMax}T00:00:00`);s.setDate(s.getDate()-1),a.setDate(a.getDate()+1),e.rangeDisabled.push(i(s)),e.rangeDisabled.push(i(a)),null!==e.settings.selected.month&&e.settings.selected.month>=0&&e.settings.selected.month<12?e.selectedMonth=e.settings.selected.month:e.selectedMonth=e.date.today.getMonth(),null!==e.settings.selected.year&&e.settings.selected.year>=0&&e.settings.selected.year<=9999?e.selectedYear=e.settings.selected.year:e.selectedYear=e.date.today.getFullYear(),e.viewYear=e.selectedYear,e.dateMin=e.settings.visibility.disabled?new Date(`${e.date.min}T00:00:00`):new Date(`${e.rangeMin}T00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max}T00:00:00`):new Date(`${e.rangeMax}T00:00:00`);const n=!0===e.settings.selection.time||12===e.settings.selection.time;if(n||24===e.settings.selection.time){if(e.userTime=!1,"string"==typeof e.settings.selected.time){const t=n?/^([0-9]|0[1-9]|1[0-2]):([0-5][0-9])|(AM|PM)/g:/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])/g;e.settings.selected.time.replace(t,((t,l,s,a)=>(l&&s&&(e.userTime=!0,e.selectedHours=l,e.selectedMinutes=s),a&&n?e.selectedKeeping=a:n&&(e.selectedKeeping="AM"),"")))}!e.userTime&&n?(e.selectedHours=r(String(e.date.today.getHours())),e.selectedMinutes=String(e.date.today.getMinutes()),e.selectedKeeping=Number(e.date.today.getHours())>=12?"PM":"AM"):e.userTime||(e.selectedHours=String(e.date.today.getHours()),e.selectedMinutes=String(e.date.today.getMinutes())),e.selectedHours=Number(e.selectedHours)<10?`0${Number(e.selectedHours)}`:`${e.selectedHours}`,e.selectedMinutes=Number(e.selectedMinutes)<10?`0${Number(e.selectedMinutes)}`:`${e.selectedMinutes}`,e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`}else e.settings.selection.time&&(e.settings.selection.time=!1,console.error("The value of the time property can be: false, true, 12 or 24."));"multiple"===e.type&&(1===e.months?(console.warn("The value of the «months» parameter cannot be less than «2», the minimum available value will be initialized."),e.correctMonths=2):e.months>12?(console.warn("The value of the «months» parameter cannot be greater than «12», the maximum available value will be initialized."),e.correctMonths=12):e.correctMonths=e.months)},o=e=>{if(!["default","multiple","year"].includes(e.currentType))return;const t=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowPrev}`),l=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowNext}`);if(!t||!l)return;"default"!==e.currentType&&"multiple"!==e.currentType||(()=>{if(!e.dateMin||!e.dateMax)return;const s=new Date(`${i(new Date(e.selectedYear,e.selectedMonth,1))}T00:00:00`),a=new Date(s.getTime());s.setMonth(s.getMonth()-e.jumpMonths),a.setMonth(a.getMonth()+e.jumpMonths),!e.settings.selection.month||s.getFullYear()e.dateMax.getFullYear()||a.getFullYear()===e.dateMax.getFullYear()&&a.getMonth()>e.dateMax.getMonth()?l.style.visibility="hidden":l.style.visibility=""})(),"year"===e.currentType&&e.dateMin&&e.dateMax&&void 0!==e.viewYear&&(e.dateMin.getFullYear()&&e.viewYear-7<=e.dateMin.getFullYear()?t.style.visibility="hidden":t.style.visibility="",e.dateMax.getFullYear()&&e.viewYear+7>=e.dateMax.getFullYear()?l.style.visibility="hidden":l.style.visibility="")},u=(e,t)=>{if(!e)return null;const l=new Date(`${e}T00:00:00`).getDate(),s=new Date(`${e}T00:00:00`).getMonth(),a=new Date(`${e}T00:00:00`).getFullYear(),n=new Date(a,s,l),i=t?n.getDay()||7:n.getDay();n.setDate(n.getDate()+4-i);const d=new Date(n.getFullYear(),0,1);return{year:a,week:Math.ceil(((+n-+d)/864e5+1)/7)}},m=e=>{var t,l;const s=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.days}`),a=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.weekNumbers}`),n=new Date(e.selectedYear,e.selectedMonth,1),d=document.createElement("div"),r=document.createElement("button");d.className=e.CSSClasses.day,r.className=e.CSSClasses.dayBtn,r.type="button",null==(t=e.selectedDates)||t.sort(((e,t)=>+new Date(e)-+new Date(t))),s.forEach(((t,l)=>{const c=new Date(n.setMonth(e.selectedMonth+l)).getMonth(),o=new Date(n.setFullYear(e.selectedYear,e.selectedMonth+l)).getFullYear(),m=new Date(o,c,1),g=new Date(o,c+1,0).getDate();let v=Number(m.getDay());e.settings.iso8601&&(v=Number((0!==m.getDay()?m.getDay():7)-1)),e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&s[l].classList.add(e.CSSClasses.daysSelecting),s[l].innerHTML="";const y=(t,a,n,i,c)=>{var m,g,v,y,h,S,M,p,C;const b=d.cloneNode(!0),D=r.cloneNode(!0);if(c&&D.classList.add(c),D.innerText=t,D.dataset.calendarDay=n,e.settings.visibility.weekNumbers){const t=u(n,e.settings.iso8601);if(!t)return;D.dataset.calendarWeekNumber=`${t.week}`}(null==(m=e.rangeEnabled)?void 0:m[0])&&e.settings.range.disableAllDays&&!(null==(g=e.rangeDisabled)?void 0:g.includes(n))&&(null==(v=e.rangeDisabled)||v.push(n)),(null==(y=e.rangeEnabled)?void 0:y[0])&&(null==(h=e.rangeDisabled)?void 0:h.includes(n))&&(e.rangeDisabled=null==(S=e.rangeDisabled)?void 0:S.filter((t=>{var l;return!(null==(l=e.rangeEnabled)?void 0:l.includes(t))}))),(null==(M=e.settings.range.disableWeekday)?void 0:M.includes(a))&&!(null==(p=e.rangeDisabled)?void 0:p.includes(n))&&(null==(C=e.rangeDisabled)||C.push(n)),((t,l,s,a,n)=>{(e.rangeMin>a||e.rangeMax{t===a&&l.classList.add(e.CSSClasses.dayBtnHoliday)}));let i=e.date.today.getDate(),d=e.date.today.getMonth()+1;i=i<10?`0${i}`:i,d=d<10?`0${d}`:d;const r=`${e.date.today.getFullYear()}-${d}-${i}`;e.settings.visibility.today&&l.dataset.calendarDay===r&&l.classList.add(e.CSSClasses.dayBtnToday),e.selectedDates&&0===e.selectedDates.indexOf(a)?("multiple-ranged"===e.settings.selection.day&&e.selectedDates.length>1?t.classList.add(e.CSSClasses.daySelectedFirst):t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates[0]&&e.selectedDates.indexOf(a)===e.selectedDates.length-1?(t.classList.add(e.CSSClasses.daySelected),"multiple-ranged"===e.settings.selection.day?t.classList.add(e.CSSClasses.daySelectedLast):t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&"multiple-ranged"===e.settings.selection.day?(t.classList.add(e.CSSClasses.daySelectedIntermediate),l.classList.add(e.CSSClasses.dayBtnSelected),l.classList.add(e.CSSClasses.dayBtnIntermediate)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&(t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)),Array.isArray(e.rangeDisabled)&&e.rangeDisabled[0]&&e.rangeDisabled.forEach((t=>{t===a&&(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1)})),!e.settings.selection.month&&n&&(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1),e.settings.selection.year||new Date(`${a}T00:00:00`).getFullYear()===o||(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1)})(b,D,a,n,i),i?e.settings.visibility.daysOutside&&b.append(D):b.append(D),s[l].append(b),e.actions.getDays&&e.actions.getDays(Number(t),n,b,D)};(()=>{let t=new Date(o,c,0).getDate()-v,l=o,s=c;0===c?(s=e.locale.months.length,l=o-1):c<10&&(s=`0${c}`);for(let a=0;a{for(let e=1;e<=g;e++){const t=new Date(o,c,e),l=i(t),s=t.getDay();y(String(e),s,l,!1,null)}})(),(()=>{const t=v+g,l=Math.ceil(t/e.locale.weekday.length),s=e.locale.weekday.length*l-t;let a=o,n=String(c+2);c+1===e.locale.months.length?(n="01",a=o+1):c+2<10&&(n=`0${c+2}`);for(let i=1;i<=s;i++){const t=`${a}-${n}-${i<10?`0${i}`:String(i)}`,l=new Date(o,c,i).getMonth()+1,s=new Date(o,l,i).getDay();y(String(i),s,t,!0,e.CSSClasses.dayBtnNext)}})(),((e,t)=>{e.popups&&Object.keys(e.popups).forEach((l=>{var s;const a=t.querySelector(`[data-calendar-day="${l}"]`);if(a){const t=null==(s=e.popups)?void 0:s[l];(null==t?void 0:t.modifier)&&t.modifier.trim().split(" ").forEach((e=>{a.classList.add(e)})),(null==t?void 0:t.html)&&(a.parentNode.innerHTML+=`
${t.html}
`)}}))})(e,s[l]),((e,t,l,s,a)=>{if(!e.settings.visibility.weekNumbers)return;const n=a.querySelectorAll(`.${e.CSSClasses.day}`);s.innerHTML="";const i=Math.ceil((t+l)/7),d=document.createElement("b");d.className=e.CSSClasses.weekNumbersTitle,d.innerText="#",s.append(d);const r=document.createElement("div");r.className=e.CSSClasses.weekNumbersContent,s.append(r);const c=document.createElement("span");c.className=e.CSSClasses.weekNumber;for(let o=0;o+new Date(e)-+new Date(t)))},g=e=>`\n\t\n`,v=e=>`\n\t\n`,y=e=>`\n\t\n`,h=e=>`\n\t\n`,S=e=>`\n\t
\n`,M=e=>`\n\t
\n`,p=e=>`\n\t
\n`,C=e=>`\n\t
\n`,b=e=>e.settings.visibility.weekNumbers?`\n\t
\n`:"",D=e=>e.settings.selection.time?`\n\t
\n`:"",T=(e,t)=>t.replace(/<#(.*?)\/>/g,((t,l)=>{const s=(e=>{let t=null;switch(e){case"ArrowPrev":t=g;break;case"ArrowNext":t=v;break;case"Month":t=y;break;case"Year":t=h;break;case"Week":t=S;break;case"Days":t=M;break;case"Months":t=p;break;case"Years":t=C;break;case"WeekNumbers":t=b;break;case"ControlTime":t=D}return t})(l.replace(/[\s\n\t]/g,""));return s?s(e):""})).replace(/[\n\t]/g,""),w=(e,t)=>{const l=e.HTMLElement;l.classList.add(e.CSSClasses.calendar);const s=(l,s)=>{if(!t)return;const a=e.HTMLElement.querySelector(`.${e.CSSClasses.controls}`);a&&e.HTMLElement.removeChild(a);e.HTMLElement.querySelector(`.${e.CSSClasses.grid}`).classList.add(e.CSSClasses.gridDisabled);const n=t.closest(`.${e.CSSClasses.column}`);n.classList.add(l),n.innerHTML=T(e,s)};switch(e.currentType){case"default":l.classList.add(e.CSSClasses.calendarDefault),l.classList.remove(e.CSSClasses.calendarMonth),l.classList.remove(e.CSSClasses.calendarYear),l.innerHTML=T(e,e.DOMTemplates.default);break;case"multiple":if(!e.correctMonths)break;l.classList.add(e.CSSClasses.calendarMultiple),l.classList.remove(e.CSSClasses.calendarMonth),l.classList.remove(e.CSSClasses.calendarYear),l.innerHTML=((e,t)=>t.replace(/<#Multiple>(.*?)<#\/Multiple>/g,((t,l)=>{let s="";for(let a=0;a{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-month]");if(!t[0]||void 0===e.selectedMonth)return;const l=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((s,a)=>{const n=new Date(l.setMonth(e.selectedMonth+a)).getMonth();t[a].dataset.calendarSelectedMonth=String(n),t[a].innerText=e.locale.months[n],!1===e.settings.selection.month||"only-arrows"===e.settings.selection.month?(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.monthDisabled)):(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.monthDisabled))}))},f=e=>{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-year]");if(!t||void 0===e.selectedMonth)return;const l=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((s,a)=>{const n=new Date(l.setFullYear(e.selectedYear,e.selectedMonth+a)).getFullYear();t[a].dataset.calendarSelectedYear=String(n),t[a].innerText=String(n),!1===e.settings.selection.year||"only-arrows"===e.settings.selection.year?(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.yearDisabled)):(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.yearDisabled))}))},L=(e,t)=>{var l;const s=(null==t?void 0:t.dataset.calendarSelectedMonth)?Number(t.dataset.calendarSelectedMonth):e.selectedMonth,a=null==(l=null==t?void 0:t.closest(`.${e.CSSClasses.column}`))?void 0:l.querySelector(`.${e.CSSClasses.year}`),n=a?Number(a.dataset.calendarSelectedYear):e.selectedYear;e.currentType="month",w(e,t),$(e),f(e);const i=e.HTMLElement.querySelector(`.${e.CSSClasses.months}`);if(!e.dateMin||!e.dateMax||!i)return;e.settings.selection.month&&i.classList.add(e.CSSClasses.monthsSelecting);const d=e.jumpMonths>1?e.locale.months.map(((t,l)=>s-e.jumpMonths*l)).concat(e.locale.months.map(((t,l)=>s+e.jumpMonths*l))).filter((e=>e>=0&&e<=12)):Array.from(Array(12).keys()),r=document.createElement("button");r.type="button",r.className=e.CSSClasses.monthsMonth;const c=()=>{if("multiple"!==e.type)return 0;const t=[...e.HTMLElement.querySelectorAll(`.${e.CSSClasses.column}`)].findIndex((t=>t.classList.contains(`${e.CSSClasses.columnMonth}`)));return t>0?t:0};for(let o=0;oe.dateMax.getMonth()+c()&&n>=e.dateMax.getFullYear()||o!==s&&!d.includes(o))&&(l.classList.add(e.CSSClasses.monthsMonthDisabled),l.tabIndex=-1),l.dataset.calendarMonth=String(o),l.title=`${t}`,l.innerText=`${e.settings.visibility.monthShort?t.substring(0,3):t}`,i.append(l)}},k=e=>({hide(){e.HTMLElement.classList.add(e.CSSClasses.calendarHidden),e.actions.hideCalendar&&e.actions.hideCalendar(e.HTMLInputElement,e.HTMLElement)},show(){e.HTMLElement.classList.remove(e.CSSClasses.calendarHidden),e.actions.showCalendar&&e.actions.showCalendar(e.HTMLInputElement,e.HTMLElement)},HTMLInputElement:e.HTMLInputElement,HTMLElement:e.HTMLElement}),H=(e,t)=>{const l=Number(e);let s=String(l);return"AM"===t?12===l&&(s="00"):"PM"===t&&(1===l?s="13":2===l?s="14":3===l?s="15":4===l?s="16":5===l?s="17":6===l?s="18":7===l?s="19":8===l?s="20":9===l?s="21":10===l?s="22":11===l&&(s="23")),s},Y=e=>{const t=e.HTMLElement.querySelector(`.${e.CSSClasses.time}`);if(!t)return;const l=!0===e.settings.selection.time?12:e.settings.selection.time,s="range"===e.settings.selection.controlTime;t.innerHTML=`\n\t
\n\t\t\n\t\t\n\t\t${12===l?`\n\t\t\n\t\t`:""}\n\t
\n\t
\n\t\t\n\t\t\n\t
`,((e,t)=>{const l=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="hours"]`),s=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="minutes"]`),a=e.HTMLElement.querySelector(`.${e.CSSClasses.timeHours} input[name="hours"]`),n=e.HTMLElement.querySelector(`.${e.CSSClasses.timeMinutes} input[name="minutes"]`),i=e.HTMLElement.querySelector(`.${e.CSSClasses.timeKeeping}`),d=(t,l)=>{t.addEventListener("mouseover",(()=>l.classList.add(e.CSSClasses.isFocus)))},c=(t,l)=>{t.addEventListener("mouseout",(()=>l.classList.remove(e.CSSClasses.isFocus)))},o=(t,l,s)=>{"hours"===s?e.selectedHours=`${l}`:"minutes"===s&&(e.selectedMinutes=`${l}`),e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`,e.actions.changeTime&&e.actions.changeTime(t,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,k(e),e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping)},u=(t,l,s,a)=>{t.addEventListener("input",(t=>{let n=Number(t.target.value);n=n<10?`0${n}`:`${n}`,"hours"===s&&12===a?Number(t.target.value)0?(l.value=n,e.selectedKeeping="AM",i.innerText=e.selectedKeeping,o(t,n,s)):(0===Number(t.target.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),l.value=r(t.target.value),o(t,r(t.target.value),s)):(l.value=n,o(t,n,s))}))},m=(t,l,s,a)=>{l.addEventListener("change",(l=>{const n=l.target;let d=Number(n.value);d=d<10?`0${d}`:`${d}`,"hours"===s&&12===a?n.value&&Number(n.value)<=a&&Number(n.value)>0?(n.value=d,t.value=H(d,e.selectedKeeping),o(l,d,s)):n.value&&Number(n.value)<24&&(Number(n.value)>a||0===Number(n.value))?(0===Number(n.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),n.value=r(n.value),t.value=d,o(l,r(n.value),s)):n.value=e.selectedHours:n.value&&Number(n.value)<=a&&Number(n.value)>=0?(n.value=d,t.value=d,o(l,d,s)):"hours"===s?n.value=e.selectedHours:"minutes"===s&&(n.value=e.selectedMinutes)}))};d(l,a),d(s,n),c(l,a),c(s,n),u(l,a,"hours",24===t?23:12),u(s,n,"minutes",0),m(l,a,"hours",24===t?23:12),m(s,n,"minutes",59),i&&i.addEventListener("click",(t=>{i.innerText.includes("AM")?e.selectedKeeping="PM":e.selectedKeeping="AM",l.value=H(e.selectedHours,e.selectedKeeping),o(t,e.selectedHours,"hours"),i.innerText=e.selectedKeeping}))})(e,l)},E=e=>{const t=[...e.locale.weekday];if(!t[0])return;const l=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.week}`),s=document.createElement("b");s.className=e.CSSClasses.weekDay,e.settings.iso8601&&t.push(t.shift()),l.forEach((l=>{l.innerHTML="";for(let a=0;a{if(void 0===e.viewYear||!e.dateMin||!e.dateMax)return;const l=(null==t?void 0:t.dataset.calendarSelectedYear)?Number(null==t?void 0:t.dataset.calendarSelectedYear):e.selectedYear;e.currentType="year",w(e,t),$(e),f(e),o(e);const s=e.HTMLElement.querySelector(`.${e.CSSClasses.years}`);if(!s)return;e.settings.selection.year&&s.classList.add(e.CSSClasses.yearsSelecting);const a=document.createElement("button");a.type="button",a.className=e.CSSClasses.yearsYear;for(let n=e.viewYear-7;ne.dateMax.getFullYear())&&(i.classList.add(e.CSSClasses.yearsYearDisabled),i.tabIndex=-1),i.dataset.calendarYear=String(t),i.innerText=`${t}`,s.append(i)}},N=["light","dark","system"];let _=!1;const A=(e,t)=>{var l;let s=null;for(let a=0;a{e.HTMLElement&&(N.includes(t)?e.HTMLElement.dataset.calendarTheme=t:console.error("Incorrect name of theme in settings.visibility.theme"))},I=(e,t)=>{if(!t)return void F(e,"light");const l=e=>e.matches?"dark":"light";e.HTMLElement.dataset.calendarTheme=l(t),_||(t.onchange=t=>{"system"===e.settings.visibility.theme&&(e.HTMLElement.dataset.calendarTheme=l(t))},_=!0)},B=(e,t)=>{if(!e.HTMLElement)return;const l=!!e.settings.visibility.themeDetect&&document.querySelector(e.settings.visibility.themeDetect);if(!l)return void I(e,t);const s=e.settings.visibility.themeDetect.replace(/^.*\[(.+)\]/g,((e,t)=>t)),a=l.hasAttribute(s);if(!s||!a)return void I(e,t);const n=A(l,s);n?(F(e,n),((e,t,l)=>{new MutationObserver((s=>{for(let a=0;a{const t={default(){E(e),m(e)},multiple(){E(e),m(e)},month(){L(e)},year(){x(e)}};(e=>{if(!e.HTMLElement)return;let t;"not all"!==window.matchMedia("(prefers-color-scheme)").media&&(t=window.matchMedia("(prefers-color-scheme: dark)")),"system"===e.settings.visibility.theme?B(e,t):F(e,e.settings.visibility.theme)})(e),(e=>{if("define"!==e.settings.lang){e.locale.weekday=[];for(let t=0;t<7;t++){let l=new Date(0,0,t).toLocaleString(e.settings.lang,{weekday:"short"});l=`${l.charAt(0).toUpperCase()}${l.substring(1,l.length)}`,l=l.replace(/\./,""),e.locale.weekday.push(l)}e.locale.months=[];for(let t=0;t<12;t++){let l=new Date(0,t).toLocaleString(e.settings.lang,{month:"long"});l=`${l.charAt(0).toUpperCase()}${l.substring(1,l.length)}`,l=l.replace(/\./,""),e.locale.months.push(l)}}})(e),w(e),$(e),f(e),o(e),Y(e),t[e.currentType]()},O=e=>{c(e),q(e)},P=(e,t)=>{if(void 0===e.selectedMonth||void 0===e.selectedYear)return;const l=new Date(`${i(new Date(e.selectedYear,e.selectedMonth,1))}T00:00:00`);switch(t){case"prev":l.setMonth(l.getMonth()-e.jumpMonths);break;case"next":l.setMonth(l.getMonth()+e.jumpMonths)}e.selectedMonth=l.getMonth(),e.selectedYear=l.getFullYear(),$(e),f(e),o(e),m(e)};let K=null;const W=()=>{var e;if(!K)return;const t=null==(e=K.HTMLElement)?void 0:e.querySelectorAll(`.${K.CSSClasses.dayBtnHover}`);t&&t.forEach((e=>e.classList.remove(K.CSSClasses.dayBtnHover)))},j=e=>{var t;if(!K||!K.selectedDates)return;const l=i(e);if(K.rangeDisabled&&K.rangeDisabled.includes(l))return;const s=null==(t=K.HTMLElement)?void 0:t.querySelectorAll(`[data-calendar-day="${l}"]`);null==s||s.forEach((e=>{e.classList.add(K.CSSClasses.dayBtnHover)}))},R=e=>{if(!e.target||!K||!K.selectedDates)return;if(!e.target.closest(`.${K.CSSClasses.days}`))return void W();const t=e.target.dataset.calendarDay;if(!t)return;W();const l=new Date(new Date(`${K.selectedDates[0]}T00:00:00`).getFullYear(),new Date(`${K.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${K.selectedDates[0]}T00:00:00`).getDate()),s=new Date(new Date(`${t}T00:00:00`).getFullYear(),new Date(`${t}T00:00:00`).getMonth(),new Date(`${t}T00:00:00`).getDate());if(s>l)for(let a=l;a<=s;a.setDate(a.getDate()+1))j(a);else for(let a=l;a>=s;a.setDate(a.getDate()-1))j(a)},G=e=>{K&&"Escape"===e.key&&(K.selectedDates=[],K.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),q(K))},z=e=>{e&&e.selectedDates&&(K=e,e.selectedDates[0]&&e.selectedDates.length<=1?(e.HTMLElement.addEventListener("mousemove",R),document.addEventListener("keydown",G),e.settings.range.disableGaps&&(()=>{var e;if(!K||!(null==(e=K.selectedDates)?void 0:e[0])||!K.rangeDisabled||K.rangeDisabled.length<2)return;const t=new Date(`${K.selectedDates[0]}T00:00:00`);let l=null,s=null;for(let a=0;a=e)){s=e;break}l=e}l&&(l=new Date(l.setDate(l.getDate()+1)),K.rangeMin=i(l)),s&&(s=new Date(s.setDate(s.getDate()-1)),K.rangeMax=i(s))})()):(e.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),e.settings.range.disableGaps&&K&&(K.rangeMin=K.settings.range.min,K.rangeMax=K.settings.range.max,K.settings.range.disablePast&&new Date(`${K.settings.range.min}T00:00:00`){const n=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.column}`),i=[...n].findIndex((e=>e.classList.contains(t))),d=Number(n[i].querySelector(`.${l}`).getAttribute(a));return"month"===e.currentType&&i>=0?s-i:"year"===e.currentType&&e.selectedYear!==d?s-1:s},V=e=>{e.HTMLElement.addEventListener("click",(t=>{const l=t.target,s=l.closest(`.${e.CSSClasses.arrow}`),a=l.closest(`.${e.CSSClasses.arrowPrev}`),n=l.closest(`.${e.CSSClasses.arrowNext}`),d=l.closest(`.${e.CSSClasses.dayBtn}`),r=l.closest(`.${e.CSSClasses.dayBtnPrev}`),c=l.closest(`.${e.CSSClasses.dayBtnNext}`),o=l.closest(`.${e.CSSClasses.weekNumber}`),u=l.closest(`.${e.CSSClasses.year}`),g=l.closest(`.${e.CSSClasses.yearsYear}`),v=l.closest(`.${e.CSSClasses.month}`),y=l.closest(`.${e.CSSClasses.monthsMonth}`),h=l.closest(`.${e.CSSClasses.grid}`),S=l.closest(`.${e.CSSClasses.column}`);s&&"year"!==e.currentType&&"month"!==e.currentType&&P(e,l.dataset.calendarArrow),s&&e.actions.clickArrow&&e.actions.clickArrow(t,Number(e.selectedYear),Number(e.selectedMonth)),(()=>{if(e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&d){switch(e.settings.selection.day){case"single":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):(e.selectedDates=[],e.selectedDates.push(d.dataset.calendarDay)));break;case"multiple":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):e.selectedDates.push(d.dataset.calendarDay));break;case"multiple-ranged":(()=>{if(e.selectedDates&&d&&d.dataset.calendarDay){if(e.selectedDates.length<=1&&e.selectedDates[0]&&e.selectedDates[0].includes(d.dataset.calendarDay)?e.selectedDates=[]:(e.selectedDates.length>1&&(e.selectedDates=[]),e.selectedDates.push(d.dataset.calendarDay)),e.selectedDates[1]){const t=new Date(new Date(`${e.selectedDates[0]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[0]}T00:00:00`).getDate()),l=new Date(new Date(`${e.selectedDates[1]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[1]}T00:00:00`).getDate()),s=t=>{if(!e.selectedDates)return;const l=i(t);e.rangeDisabled&&e.rangeDisabled.includes(l)||e.selectedDates.push(l)};if(e.selectedDates=[],l>t)for(let e=t;e<=l;e.setDate(e.getDate()+1))s(e);else for(let e=t;e>=l;e.setDate(e.getDate()-1))s(e)}z(e)}})()}e.actions.clickDay&&e.actions.clickDay(t,e.selectedDates),e.input&&e.HTMLInputElement&&e.HTMLElement&&e.actions.changeToInput&&e.actions.changeToInput(t,k(e),e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),r?P(e,"prev"):c?P(e,"next"):m(e)}})(),(()=>{var l;if(!e.settings.visibility.weekNumbers||!o||!e.actions.clickWeekNumber)return;const s=null==(l=e.HTMLElement)?void 0:l.querySelectorAll("[data-calendar-week-number]");if(!s)return;const a=Number(o.innerText),n=Number(o.dataset.calendarYearWeek),i=[...s].filter((e=>Number(e.dataset.calendarWeekNumber)===a));e.actions.clickWeekNumber(t,a,i,n)})(),(()=>{if(e.settings.selection.year)if(s&&"year"===e.currentType){if(void 0===e.viewYear)return;n?e.viewYear+=15:a&&(e.viewYear-=15),x(e,t.target)}else if("year"!==e.currentType&&u)x(e,t.target);else if("year"===e.currentType&&u)e.currentType=e.type,q(e);else if(g){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;e.selectedYear="multiple"===e.type?U(e,e.CSSClasses.columnYear,e.CSSClasses.year,Number(g.dataset.calendarYear),"data-calendar-selected-year"):Number(g.dataset.calendarYear),e.currentType=e.type,(e.selectedMonthe.dateMax.getMonth()&&e.selectedYear>=e.dateMax.getFullYear()||e.selectedYear>e.dateMax.getFullYear())&&(e.selectedMonth=e.dateMax.getMonth(),e.selectedYear=e.dateMax.getFullYear()),e.actions.clickYear&&e.actions.clickYear(t,e.selectedYear),q(e)}else"multiple"===e.type&&"year"===e.currentType&&h&&!S&&(e.currentType=e.type,q(e))})(),(()=>{if(e.settings.selection.month)if("month"!==e.currentType&&v)L(e,t.target);else if("month"===e.currentType&&v)e.currentType=e.type,q(e);else if(y){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;if(e.selectedMonth="multiple"===e.type?U(e,e.CSSClasses.columnMonth,e.CSSClasses.month,Number(y.dataset.calendarMonth),"data-calendar-selected-month"):Number(y.dataset.calendarMonth),"multiple"===e.type){const t=y.closest(`.${e.CSSClasses.columnMonth}`).querySelector(`.${e.CSSClasses.year}`);e.selectedYear=Number(t.dataset.calendarSelectedYear),e.selectedMonthe.dateMax.getMonth()&&e.selectedYear>=e.dateMax.getFullYear()&&(e.selectedMonth=e.dateMax.getMonth())}e.currentType=e.type,e.actions.clickMonth&&e.actions.clickMonth(t,e.selectedMonth),q(e)}else"multiple"===e.type&&"month"===e.currentType&&h&&!S&&(e.currentType=e.type,q(e))})()}))},J=(e,t)=>{let l=e.offsetHeight,s=0;for(let a=e;a;a=a.offsetParent)l+=a.offsetTop||0,s+=a.offsetLeft||0;Object.assign(t.style,{left:`${s}px`,top:`${l}px`})},Q=e=>{if(!e)return;e.HTMLInputElement=e.HTMLElement,e.HTMLElement=null;const t=l=>{var s;e&&l.target!==e.HTMLInputElement&&!(null==(s=e.HTMLElement)?void 0:s.contains(l.target))&&(k(e).hide(),document.removeEventListener("click",t,{capture:!0}))};e.HTMLInputElement.addEventListener("click",(()=>{e.HTMLElement?(J(e.HTMLInputElement,e.HTMLElement),k(e).show()):(()=>{if(!e.HTMLInputElement)return;const t=document.createElement("div");t.className=`${e.CSSClasses.calendar} ${e.CSSClasses.calendarToInput} ${e.CSSClasses.calendarHidden}`,J(e.HTMLInputElement,t),e.HTMLElement=t,document.body.append(e.HTMLElement),setTimeout((()=>k(e).show()),0),O(e),V(e)})(),document.addEventListener("click",t,{capture:!0})}))},X=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#Multiple>\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Month />\n\t\t\t\t\t\t<#Year />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t<#WeekNumbers />\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Week />\n\t\t\t\t\t\t<#Days />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t<#/Multiple>\n\t
\n\t<#ControlTime />\n`,Z=e=>`\n\t
\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t\t<#Months />\n\t\t
\n\t
\n`,ee=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t
\n\t\t\t<#Years />\n\t\t
\n\t
\n`,te={calendar:"vanilla-calendar",calendarDefault:"vanilla-calendar_default",calendarMultiple:"vanilla-calendar_multiple",calendarMonth:"vanilla-calendar_month",calendarYear:"vanilla-calendar_year",calendarHidden:"vanilla-calendar_hidden",calendarToInput:"vanilla-calendar_to-input",controls:"vanilla-calendar-controls",grid:"vanilla-calendar-grid",gridDisabled:"vanilla-calendar-grid_disabled",column:"vanilla-calendar-column",columnMonth:"vanilla-calendar-column_month",columnYear:"vanilla-calendar-column_year",header:"vanilla-calendar-header",headerContent:"vanilla-calendar-header__content",month:"vanilla-calendar-month",monthDisabled:"vanilla-calendar-month_disabled",year:"vanilla-calendar-year",yearDisabled:"vanilla-calendar-year_disabled",arrow:"vanilla-calendar-arrow",arrowPrev:"vanilla-calendar-arrow_prev",arrowNext:"vanilla-calendar-arrow_next",wrapper:"vanilla-calendar-wrapper",content:"vanilla-calendar-content",week:"vanilla-calendar-week",weekDay:"vanilla-calendar-week__day",weekDayWeekend:"vanilla-calendar-week__day_weekend",days:"vanilla-calendar-days",daysSelecting:"vanilla-calendar-days_selecting",months:"vanilla-calendar-months",monthsSelecting:"vanilla-calendar-months_selecting",monthsMonth:"vanilla-calendar-months__month",monthsMonthSelected:"vanilla-calendar-months__month_selected",monthsMonthDisabled:"vanilla-calendar-months__month_disabled",years:"vanilla-calendar-years",yearsSelecting:"vanilla-calendar-years_selecting",yearsYear:"vanilla-calendar-years__year",yearsYearSelected:"vanilla-calendar-years__year_selected",yearsYearDisabled:"vanilla-calendar-years__year_disabled",time:"vanilla-calendar-time",timeContent:"vanilla-calendar-time__content",timeHours:"vanilla-calendar-time__hours",timeMinutes:"vanilla-calendar-time__minutes",timeKeeping:"vanilla-calendar-time__keeping",timeRanges:"vanilla-calendar-time__ranges",timeRange:"vanilla-calendar-time__range",day:"vanilla-calendar-day",daySelected:"vanilla-calendar-day_selected",daySelectedFirst:"vanilla-calendar-day_selected-first",daySelectedLast:"vanilla-calendar-day_selected-last",daySelectedIntermediate:"vanilla-calendar-day_selected-intermediate",dayPopup:"vanilla-calendar-day__popup",dayBtn:"vanilla-calendar-day__btn",dayBtnPrev:"vanilla-calendar-day__btn_prev",dayBtnNext:"vanilla-calendar-day__btn_next",dayBtnToday:"vanilla-calendar-day__btn_today",dayBtnSelected:"vanilla-calendar-day__btn_selected",dayBtnHover:"vanilla-calendar-day__btn_hover",dayBtnDisabled:"vanilla-calendar-day__btn_disabled",dayBtnIntermediate:"vanilla-calendar-day__btn_intermediate",dayBtnWeekend:"vanilla-calendar-day__btn_weekend",dayBtnHoliday:"vanilla-calendar-day__btn_holiday",weekNumbers:"vanilla-calendar-week-numbers",weekNumbersTitle:"vanilla-calendar-week-numbers__title",weekNumbersContent:"vanilla-calendar-week-numbers__content",weekNumber:"vanilla-calendar-week-number",isFocus:"vanilla-calendar-is-focus"};return class{constructor(e,i){var d,r,o,u,m,g,v,y,h,S,M,p,C,b,D,T,w,$,f,L,k,H,Y,E,x,N,_,A,F,I,B,P,K,W,j,R,G,z,U,J,le,se,ae,ne,ie,de,re,ce,oe,ue,me,ge,ve,ye,he,Se,Me,pe,Ce,be,De,Te,we,$e,fe,Le,ke,He,Ye,Ee,xe,Ne,_e,Ae,Fe,Ie,Be,qe,Oe,Pe,Ke,We,je,Re,Ge,ze,Ue,Ve,Je,Qe,Xe,Ze,et,tt,lt,st,at,nt,it,dt,rt,ct,ot,ut,mt,gt,vt,yt,ht,St,Mt,pt,Ct,bt,Dt,Tt,wt,$t,ft,Lt,kt,Ht,Yt,Et,xt,Nt,_t,At,Ft,It,Bt,qt;(n(this,"HTMLElement"),n(this,"input"),n(this,"type"),n(this,"months"),n(this,"jumpMonths"),n(this,"date"),n(this,"settings"),n(this,"locale"),n(this,"actions"),n(this,"popups"),n(this,"CSSClasses"),n(this,"DOMTemplates"),n(this,"currentType"),n(this,"reset",(()=>O(this))),n(this,"update",(()=>(e=>{var t;let l=null,s=null,a=null;(null==(t=e.settings.selected.dates)?void 0:t[0])||(l=e.settings.selected.dates,e.settings.selected.dates=e.selectedDates),e.settings.selected.month||(s=e.settings.selected.month,e.settings.selected.month=e.selectedMonth),e.settings.selected.year||(a=e.settings.selected.year,e.settings.selected.year=e.selectedYear),c(e),q(e),e.settings.selected.dates=l,e.settings.selected.month=s,e.settings.selected.year=a})(this))),n(this,"init",(()=>{var e;(e=this).HTMLElement&&(e.input?Q(e):(O(e),V(e)))})),this.HTMLElement="string"==typeof e?document.querySelector(e):e,this.HTMLElement)&&(this.input=null!=(d=null==i?void 0:i.input)&&d,this.type=null!=(r=null==i?void 0:i.type)?r:"default",this.months=null!=(o=null==i?void 0:i.months)?o:2,this.jumpMonths=null!=(u=null==i?void 0:i.jumpMonths)?u:1,this.date={min:null!=(g=null==(m=null==i?void 0:i.date)?void 0:m.min)?g:"1970-01-01",max:null!=(y=null==(v=null==i?void 0:i.date)?void 0:v.max)?y:"2470-12-31",today:null!=(S=null==(h=null==i?void 0:i.date)?void 0:h.today)?S:new Date},this.settings={lang:null!=(p=null==(M=null==i?void 0:i.settings)?void 0:M.lang)?p:"en",iso8601:null==(b=null==(C=null==i?void 0:i.settings)?void 0:C.iso8601)||b,range:{min:null!=(w=null==(T=null==(D=null==i?void 0:i.settings)?void 0:D.range)?void 0:T.min)?w:this.date.min,max:null!=(L=null==(f=null==($=null==i?void 0:i.settings)?void 0:$.range)?void 0:f.max)?L:this.date.max,disablePast:null!=(Y=null==(H=null==(k=null==i?void 0:i.settings)?void 0:k.range)?void 0:H.disablePast)&&Y,disableGaps:null!=(N=null==(x=null==(E=null==i?void 0:i.settings)?void 0:E.range)?void 0:x.disableGaps)&&N,disableAllDays:null!=(F=null==(A=null==(_=null==i?void 0:i.settings)?void 0:_.range)?void 0:A.disableAllDays)&&F,disableWeekday:null!=(P=null==(B=null==(I=null==i?void 0:i.settings)?void 0:I.range)?void 0:B.disableWeekday)?P:null,disabled:null!=(j=null==(W=null==(K=null==i?void 0:i.settings)?void 0:K.range)?void 0:W.disabled)?j:null,enabled:null!=(z=null==(G=null==(R=null==i?void 0:i.settings)?void 0:R.range)?void 0:G.enabled)?z:null},selection:{day:null!=(le=null==(J=null==(U=null==i?void 0:i.settings)?void 0:U.selection)?void 0:J.day)?le:"single",month:null==(ne=null==(ae=null==(se=null==i?void 0:i.settings)?void 0:se.selection)?void 0:ae.month)||ne,year:null==(re=null==(de=null==(ie=null==i?void 0:i.settings)?void 0:ie.selection)?void 0:de.year)||re,time:null!=(ue=null==(oe=null==(ce=null==i?void 0:i.settings)?void 0:ce.selection)?void 0:oe.time)&&ue,controlTime:null!=(ve=null==(ge=null==(me=null==i?void 0:i.settings)?void 0:me.selection)?void 0:ge.controlTime)?ve:"all",stepHours:null!=(Se=null==(he=null==(ye=null==i?void 0:i.settings)?void 0:ye.selection)?void 0:he.stepHours)?Se:1,stepMinutes:null!=(Ce=null==(pe=null==(Me=null==i?void 0:i.settings)?void 0:Me.selection)?void 0:pe.stepMinutes)?Ce:1},selected:{dates:null!=(Te=null==(De=null==(be=null==i?void 0:i.settings)?void 0:be.selected)?void 0:De.dates)?Te:null,month:null!=(fe=null==($e=null==(we=null==i?void 0:i.settings)?void 0:we.selected)?void 0:$e.month)?fe:null,year:null!=(He=null==(ke=null==(Le=null==i?void 0:i.settings)?void 0:Le.selected)?void 0:ke.year)?He:null,holidays:null!=(xe=null==(Ee=null==(Ye=null==i?void 0:i.settings)?void 0:Ye.selected)?void 0:Ee.holidays)?xe:null,time:null!=(Ae=null==(_e=null==(Ne=null==i?void 0:i.settings)?void 0:Ne.selected)?void 0:_e.time)?Ae:null},visibility:{theme:null!=(Be=null==(Ie=null==(Fe=null==i?void 0:i.settings)?void 0:Fe.visibility)?void 0:Ie.theme)?Be:"system",themeDetect:null!=(Pe=null==(Oe=null==(qe=null==i?void 0:i.settings)?void 0:qe.visibility)?void 0:Oe.themeDetect)?Pe:"html[data-theme]",monthShort:null==(je=null==(We=null==(Ke=null==i?void 0:i.settings)?void 0:Ke.visibility)?void 0:We.monthShort)||je,weekNumbers:null!=(ze=null==(Ge=null==(Re=null==i?void 0:i.settings)?void 0:Re.visibility)?void 0:Ge.weekNumbers)&&ze,weekend:null==(Je=null==(Ve=null==(Ue=null==i?void 0:i.settings)?void 0:Ue.visibility)?void 0:Ve.weekend)||Je,today:null==(Ze=null==(Xe=null==(Qe=null==i?void 0:i.settings)?void 0:Qe.visibility)?void 0:Xe.today)||Ze,disabled:null!=(lt=null==(tt=null==(et=null==i?void 0:i.settings)?void 0:et.visibility)?void 0:tt.disabled)&<,daysOutside:null==(nt=null==(at=null==(st=null==i?void 0:i.settings)?void 0:st.visibility)?void 0:at.daysOutside)||nt}},this.locale={months:null!=(dt=null==(it=null==i?void 0:i.locale)?void 0:it.months)?dt:[],weekday:null!=(ct=null==(rt=null==i?void 0:i.locale)?void 0:rt.weekday)?ct:[]},this.actions={clickDay:null!=(ut=null==(ot=null==i?void 0:i.actions)?void 0:ot.clickDay)?ut:null,clickWeekNumber:null!=(gt=null==(mt=null==i?void 0:i.actions)?void 0:mt.clickWeekNumber)?gt:null,clickMonth:null!=(yt=null==(vt=null==i?void 0:i.actions)?void 0:vt.clickMonth)?yt:null,clickYear:null!=(St=null==(ht=null==i?void 0:i.actions)?void 0:ht.clickYear)?St:null,clickArrow:null!=(pt=null==(Mt=null==i?void 0:i.actions)?void 0:Mt.clickArrow)?pt:null,changeTime:null!=(bt=null==(Ct=null==i?void 0:i.actions)?void 0:Ct.changeTime)?bt:null,changeToInput:null!=(Tt=null==(Dt=null==i?void 0:i.actions)?void 0:Dt.changeToInput)?Tt:null,getDays:null!=($t=null==(wt=null==i?void 0:i.actions)?void 0:wt.getDays)?$t:null,hideCalendar:null!=(Lt=null==(ft=null==i?void 0:i.actions)?void 0:ft.hideCalendar)?Lt:null,showCalendar:null!=(Ht=null==(kt=null==i?void 0:i.actions)?void 0:kt.showCalendar)?Ht:null},this.popups=null!=(Yt=null==i?void 0:i.popups)?Yt:null,this.CSSClasses=(()=>{const e=((e,n)=>{for(var i in n||(n={}))l.call(n,i)&&a(e,i,n[i]);if(t)for(var i of t(n))s.call(n,i)&&a(e,i,n[i]);return e})({},te);return Object.keys(te).forEach((t=>{var l;(null==(l=null==i?void 0:i.CSSClasses)?void 0:l[t])?e[t]=i.CSSClasses[t]:e[t]=te[t]})),e})(),this.DOMTemplates={default:null!=(xt=null==(Et=null==i?void 0:i.DOMTemplates)?void 0:Et.default)?xt:(qt=this.CSSClasses,`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#WeekNumbers />\n\t\t
\n\t\t\t<#Week />\n\t\t\t<#Days />\n\t\t
\n\t
\n\t<#ControlTime />\n`),multiple:null!=(_t=null==(Nt=null==i?void 0:i.DOMTemplates)?void 0:Nt.multiple)?_t:X(this.CSSClasses),month:null!=(Ft=null==(At=null==i?void 0:i.DOMTemplates)?void 0:At.month)?Ft:Z(this.CSSClasses),year:null!=(Bt=null==(It=null==i?void 0:i.DOMTemplates)?void 0:It.year)?Bt:ee(this.CSSClasses)},this.currentType=this.type)}}})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VanillaCalendar=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(t,l,s)=>l in t?e(t,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[l]=s,n=(e,t,l)=>(a(e,"symbol"!=typeof t?t+"":t,l),l);const i=e=>{const t=e.getFullYear();let l=e.getMonth()+1,s=e.getDate();return l=l<10?`0${l}`:l,s=s<10?`0${s}`:s,`${t}-${l}-${s}`},d=e=>{const t=[];return e.forEach((e=>{e.match(/^(\d{4}-\d{2}-\d{2})$/g)?t.push(e):e.replace(/(\d{4}-\d{2}-\d{2}).*?(\d{4}-\d{2}-\d{2})/g,((e,l,s)=>{const a=new Date(`${l}T00:00:00`),n=new Date(`${s}T00:00:00`),d=new Date(a.getTime());for(;d<=n;d.setDate(d.getDate()+1))t.push(i(d));return e}))})),t},r=e=>{const t=Number(e);let l=String(t);return 0===t?l="12":13===t?l="01":14===t?l="02":15===t?l="03":16===t?l="04":17===t?l="05":18===t?l="06":19===t?l="07":20===t?l="08":21===t?l="09":22===t?l="10":23===t&&(l="11"),l},c=e=>{var t,l;e.rangeMin=e.settings.range.min,e.rangeMax=e.settings.range.max,e.rangeDisabled=e.settings.range.disabled?d([...e.settings.range.disabled]):[],e.rangeEnabled=e.settings.range.enabled?d([...e.settings.range.enabled]):[],e.selectedDates=e.settings.selected.dates?d([...e.settings.selected.dates]):[],e.selectedHolidays=e.settings.selected.holidays?d([...e.settings.selected.holidays]):[],e.settings.range.disablePast&&!e.settings.range.disableAllDays&&new Date(`${e.settings.range.min}T00:00:00`)+new Date(e)-+new Date(t))),(null==(l=e.rangeEnabled)?void 0:l[0])&&e.settings.range.disableAllDays&&(e.rangeMin=e.rangeEnabled[0],e.rangeMax=e.rangeEnabled[e.rangeEnabled.length-1]);const s=new Date(`${e.rangeMin}T00:00:00`),a=new Date(`${e.rangeMax}T00:00:00`);s.setDate(s.getDate()-1),a.setDate(a.getDate()+1),e.rangeDisabled.push(i(s)),e.rangeDisabled.push(i(a)),null!==e.settings.selected.month&&e.settings.selected.month>=0&&e.settings.selected.month<12?e.selectedMonth=e.settings.selected.month:e.selectedMonth=e.date.today.getMonth(),null!==e.settings.selected.year&&e.settings.selected.year>=0&&e.settings.selected.year<=9999?e.selectedYear=e.settings.selected.year:e.selectedYear=e.date.today.getFullYear(),e.viewYear=e.selectedYear,e.dateMin=e.settings.visibility.disabled?new Date(`${e.date.min}T00:00:00`):new Date(`${e.rangeMin}T00:00:00`),e.dateMax=e.settings.visibility.disabled?new Date(`${e.date.max}T00:00:00`):new Date(`${e.rangeMax}T00:00:00`);const n=!0===e.settings.selection.time||12===e.settings.selection.time;if(n||24===e.settings.selection.time){if(e.userTime=!1,"string"==typeof e.settings.selected.time){const t=n?/^([0-9]|0[1-9]|1[0-2]):([0-5][0-9])|(AM|PM)/g:/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])/g;e.settings.selected.time.replace(t,((t,l,s,a)=>(l&&s&&(e.userTime=!0,e.selectedHours=l,e.selectedMinutes=s),a&&n?e.selectedKeeping=a:n&&(e.selectedKeeping="AM"),"")))}!e.userTime&&n?(e.selectedHours=r(String(e.date.today.getHours())),e.selectedMinutes=String(e.date.today.getMinutes()),e.selectedKeeping=Number(e.date.today.getHours())>=12?"PM":"AM"):e.userTime||(e.selectedHours=String(e.date.today.getHours()),e.selectedMinutes=String(e.date.today.getMinutes())),e.selectedHours=Number(e.selectedHours)<10?`0${Number(e.selectedHours)}`:`${e.selectedHours}`,e.selectedMinutes=Number(e.selectedMinutes)<10?`0${Number(e.selectedMinutes)}`:`${e.selectedMinutes}`,e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`}else e.settings.selection.time&&(e.settings.selection.time=!1,console.error("The value of the time property can be: false, true, 12 or 24."));"multiple"===e.type&&(1===e.months?(console.warn("The value of the «months» parameter cannot be less than «2», the minimum available value will be initialized."),e.correctMonths=2):e.months>12?(console.warn("The value of the «months» parameter cannot be greater than «12», the maximum available value will be initialized."),e.correctMonths=12):e.correctMonths=e.months)},o=e=>{if(!["default","multiple","year"].includes(e.currentType))return;const t=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowPrev}`),l=e.HTMLElement.querySelector(`.${e.CSSClasses.arrowNext}`);if(!t||!l)return;"default"!==e.currentType&&"multiple"!==e.currentType||(()=>{if(!e.dateMin||!e.dateMax)return;const s=new Date(`${i(new Date(e.selectedYear,e.selectedMonth,1))}T00:00:00`),a=new Date(s.getTime());s.setMonth(s.getMonth()-e.jumpMonths),a.setMonth(a.getMonth()+e.jumpMonths),!e.settings.selection.month||s.getFullYear()e.dateMax.getFullYear()||a.getFullYear()===e.dateMax.getFullYear()&&a.getMonth()>e.dateMax.getMonth()?l.style.visibility="hidden":l.style.visibility=""})(),"year"===e.currentType&&e.dateMin&&e.dateMax&&void 0!==e.viewYear&&(e.dateMin.getFullYear()&&e.viewYear-7<=e.dateMin.getFullYear()?t.style.visibility="hidden":t.style.visibility="",e.dateMax.getFullYear()&&e.viewYear+7>=e.dateMax.getFullYear()?l.style.visibility="hidden":l.style.visibility="")},u=(e,t)=>{if(!e)return null;const l=new Date(`${e}T00:00:00`).getDate(),s=new Date(`${e}T00:00:00`).getMonth(),a=new Date(`${e}T00:00:00`).getFullYear(),n=new Date(a,s,l),i=t?n.getDay()||7:n.getDay();n.setDate(n.getDate()+4-i);const d=new Date(n.getFullYear(),0,1);return{year:a,week:Math.ceil(((+n-+d)/864e5+1)/7)}},m=e=>{var t,l;const s=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.days}`),a=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.weekNumbers}`),n=new Date(e.selectedYear,e.selectedMonth,1),d=document.createElement("div"),r=document.createElement("button");d.className=e.CSSClasses.day,r.className=e.CSSClasses.dayBtn,r.type="button",null==(t=e.selectedDates)||t.sort(((e,t)=>+new Date(e)-+new Date(t))),s.forEach(((t,l)=>{const c=new Date(n.setMonth(e.selectedMonth+l)).getMonth(),o=new Date(n.setFullYear(e.selectedYear,e.selectedMonth+l)).getFullYear(),m=new Date(o,c,1),g=new Date(o,c+1,0).getDate();let v=Number(m.getDay());e.settings.iso8601&&(v=Number((0!==m.getDay()?m.getDay():7)-1)),e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&s[l].classList.add(e.CSSClasses.daysSelecting),s[l].innerHTML="";const y=(t,a,n,i,c)=>{var m,g,v,y,h,S,M,p,C;const b=d.cloneNode(!0),D=r.cloneNode(!0);if(c&&D.classList.add(c),D.innerText=t,D.dataset.calendarDay=n,e.settings.visibility.weekNumbers){const t=u(n,e.settings.iso8601);if(!t)return;D.dataset.calendarWeekNumber=`${t.week}`}(null==(m=e.rangeEnabled)?void 0:m[0])&&e.settings.range.disableAllDays&&!(null==(g=e.rangeDisabled)?void 0:g.includes(n))&&(null==(v=e.rangeDisabled)||v.push(n)),(null==(y=e.rangeEnabled)?void 0:y[0])&&(null==(h=e.rangeDisabled)?void 0:h.includes(n))&&(e.rangeDisabled=null==(S=e.rangeDisabled)?void 0:S.filter((t=>{var l;return!(null==(l=e.rangeEnabled)?void 0:l.includes(t))}))),(null==(M=e.settings.range.disableWeekday)?void 0:M.includes(a))&&!(null==(p=e.rangeDisabled)?void 0:p.includes(n))&&(null==(C=e.rangeDisabled)||C.push(n)),((t,l,s,a,n)=>{(e.rangeMin>a||e.rangeMax{t===a&&l.classList.add(e.CSSClasses.dayBtnHoliday)}));let i=e.date.today.getDate(),d=e.date.today.getMonth()+1;i=i<10?`0${i}`:i,d=d<10?`0${d}`:d;const r=`${e.date.today.getFullYear()}-${d}-${i}`;e.settings.visibility.today&&l.dataset.calendarDay===r&&l.classList.add(e.CSSClasses.dayBtnToday),e.selectedDates&&0===e.selectedDates.indexOf(a)?("multiple-ranged"===e.settings.selection.day&&e.selectedDates.length>1?t.classList.add(e.CSSClasses.daySelectedFirst):t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates[0]&&e.selectedDates.indexOf(a)===e.selectedDates.length-1?(t.classList.add(e.CSSClasses.daySelected),"multiple-ranged"===e.settings.selection.day?t.classList.add(e.CSSClasses.daySelectedLast):t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&"multiple-ranged"===e.settings.selection.day?(t.classList.add(e.CSSClasses.daySelectedIntermediate),l.classList.add(e.CSSClasses.dayBtnSelected),l.classList.add(e.CSSClasses.dayBtnIntermediate)):e.selectedDates&&e.selectedDates.indexOf(a)>0&&(t.classList.add(e.CSSClasses.daySelected),l.classList.add(e.CSSClasses.dayBtnSelected)),Array.isArray(e.rangeDisabled)&&e.rangeDisabled[0]&&e.rangeDisabled.forEach((t=>{t===a&&(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1)})),!e.settings.selection.month&&n&&(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1),e.settings.selection.year||new Date(`${a}T00:00:00`).getFullYear()===o||(l.classList.add(e.CSSClasses.dayBtnDisabled),l.tabIndex=-1)})(b,D,a,n,i),i?e.settings.visibility.daysOutside&&b.append(D):b.append(D),s[l].append(b),e.actions.getDays&&e.actions.getDays(Number(t),n,b,D)};(()=>{let t=new Date(o,c,0).getDate()-v,l=o,s=c;0===c?(s=e.locale.months.length,l=o-1):c<10&&(s=`0${c}`);for(let a=0;a{for(let e=1;e<=g;e++){const t=new Date(o,c,e),l=i(t),s=t.getDay();y(String(e),s,l,!1,null)}})(),(()=>{const t=v+g,l=Math.ceil(t/e.locale.weekday.length),s=e.locale.weekday.length*l-t;let a=o,n=String(c+2);c+1===e.locale.months.length?(n="01",a=o+1):c+2<10&&(n=`0${c+2}`);for(let i=1;i<=s;i++){const t=`${a}-${n}-${i<10?`0${i}`:String(i)}`,l=new Date(o,c,i).getMonth()+1,s=new Date(o,l,i).getDay();y(String(i),s,t,!0,e.CSSClasses.dayBtnNext)}})(),((e,t)=>{e.popups&&Object.keys(e.popups).forEach((l=>{var s;const a=t.querySelector(`[data-calendar-day="${l}"]`);if(a){const t=null==(s=e.popups)?void 0:s[l];(null==t?void 0:t.modifier)&&t.modifier.trim().split(" ").forEach((e=>{a.classList.add(e)})),(null==t?void 0:t.html)&&(a.parentNode.innerHTML+=`
${t.html}
`)}}))})(e,s[l]),((e,t,l,s,a)=>{if(!e.settings.visibility.weekNumbers)return;const n=a.querySelectorAll(`.${e.CSSClasses.day}`);s.innerHTML="";const i=Math.ceil((t+l)/7),d=document.createElement("b");d.className=e.CSSClasses.weekNumbersTitle,d.innerText="#",s.append(d);const r=document.createElement("div");r.className=e.CSSClasses.weekNumbersContent,s.append(r);const c=document.createElement("span");c.className=e.CSSClasses.weekNumber;for(let o=0;o+new Date(e)-+new Date(t)))},g=e=>`\n\t\n`,v=e=>`\n\t\n`,y=e=>`\n\t\n`,h=e=>`\n\t\n`,S=e=>`\n\t
\n`,M=e=>`\n\t
\n`,p=e=>`\n\t
\n`,C=e=>`\n\t
\n`,b=e=>e.settings.visibility.weekNumbers?`\n\t
\n`:"",D=e=>e.settings.selection.time?`\n\t
\n`:"",T=(e,t)=>t.replace(/<#(.*?)\/>/g,((t,l)=>{const s=(e=>{let t=null;switch(e){case"ArrowPrev":t=g;break;case"ArrowNext":t=v;break;case"Month":t=y;break;case"Year":t=h;break;case"Week":t=S;break;case"Days":t=M;break;case"Months":t=p;break;case"Years":t=C;break;case"WeekNumbers":t=b;break;case"ControlTime":t=D}return t})(l.replace(/[\s\n\t]/g,""));return s?s(e):""})).replace(/[\n\t]/g,""),w=(e,t)=>{const l=e.HTMLElement;l.classList.add(e.CSSClasses.calendar);const s=(l,s)=>{if(!t)return;const a=e.HTMLElement.querySelector(`.${e.CSSClasses.controls}`);a&&e.HTMLElement.removeChild(a);e.HTMLElement.querySelector(`.${e.CSSClasses.grid}`).classList.add(e.CSSClasses.gridDisabled);const n=t.closest(`.${e.CSSClasses.column}`);n.classList.add(l),n.innerHTML=T(e,s)};switch(e.currentType){case"default":l.classList.add(e.CSSClasses.calendarDefault),l.classList.remove(e.CSSClasses.calendarMonth),l.classList.remove(e.CSSClasses.calendarYear),l.innerHTML=T(e,e.DOMTemplates.default);break;case"multiple":if(!e.correctMonths)break;l.classList.add(e.CSSClasses.calendarMultiple),l.classList.remove(e.CSSClasses.calendarMonth),l.classList.remove(e.CSSClasses.calendarYear),l.innerHTML=((e,t)=>t.replace(/<#Multiple>(.*?)<#\/Multiple>/g,((t,l)=>{let s="";for(let a=0;a{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-month]");if(!t[0]||void 0===e.selectedMonth)return;const l=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((s,a)=>{const n=new Date(l.setMonth(e.selectedMonth+a)).getMonth();t[a].dataset.calendarSelectedMonth=String(n),t[a].innerText=e.locale.months[n],!1===e.settings.selection.month||"only-arrows"===e.settings.selection.month?(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.monthDisabled)):(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.monthDisabled))}))},f=e=>{const t=e.HTMLElement.querySelectorAll("[data-calendar-selected-year]");if(!t||void 0===e.selectedMonth)return;const l=new Date(e.selectedYear,e.selectedMonth,1);t.forEach(((s,a)=>{const n=new Date(l.setFullYear(e.selectedYear,e.selectedMonth+a)).getFullYear();t[a].dataset.calendarSelectedYear=String(n),t[a].innerText=String(n),!1===e.settings.selection.year||"only-arrows"===e.settings.selection.year?(t[a].tabIndex=-1,t[a].classList.add(e.CSSClasses.yearDisabled)):(t[a].tabIndex=0,t[a].classList.remove(e.CSSClasses.yearDisabled))}))},L=(e,t)=>{var l;const s=(null==t?void 0:t.dataset.calendarSelectedMonth)?Number(t.dataset.calendarSelectedMonth):e.selectedMonth,a=null==(l=null==t?void 0:t.closest(`.${e.CSSClasses.column}`))?void 0:l.querySelector(`.${e.CSSClasses.year}`),n=a?Number(a.dataset.calendarSelectedYear):e.selectedYear;e.currentType="month",w(e,t),$(e),f(e);const i=e.HTMLElement.querySelector(`.${e.CSSClasses.months}`);if(!e.dateMin||!e.dateMax||!i)return;e.settings.selection.month&&i.classList.add(e.CSSClasses.monthsSelecting);const d=e.jumpMonths>1?e.locale.months.map(((t,l)=>s-e.jumpMonths*l)).concat(e.locale.months.map(((t,l)=>s+e.jumpMonths*l))).filter((e=>e>=0&&e<=12)):Array.from(Array(12).keys()),r=document.createElement("button");r.type="button",r.className=e.CSSClasses.monthsMonth;const c=()=>{if("multiple"!==e.type)return 0;const t=[...e.HTMLElement.querySelectorAll(`.${e.CSSClasses.column}`)].findIndex((t=>t.classList.contains(`${e.CSSClasses.columnMonth}`)));return t>0?t:0};for(let o=0;oe.dateMax.getMonth()+c()&&n>=e.dateMax.getFullYear()||o!==s&&!d.includes(o))&&(l.classList.add(e.CSSClasses.monthsMonthDisabled),l.tabIndex=-1),l.dataset.calendarMonth=String(o),l.title=`${t}`,l.innerText=`${e.settings.visibility.monthShort?t.substring(0,3):t}`,i.append(l)}},k=e=>({hide(){e.HTMLElement.classList.add(e.CSSClasses.calendarHidden),e.actions.hideCalendar&&e.actions.hideCalendar(e.HTMLInputElement,e.HTMLElement)},show(){e.HTMLElement.classList.remove(e.CSSClasses.calendarHidden),e.actions.showCalendar&&e.actions.showCalendar(e.HTMLInputElement,e.HTMLElement)},HTMLInputElement:e.HTMLInputElement,HTMLElement:e.HTMLElement}),H=(e,t)=>{const l=Number(e);let s=String(l);return"AM"===t?12===l&&(s="00"):"PM"===t&&(1===l?s="13":2===l?s="14":3===l?s="15":4===l?s="16":5===l?s="17":6===l?s="18":7===l?s="19":8===l?s="20":9===l?s="21":10===l?s="22":11===l&&(s="23")),s},E=e=>{const t=e.HTMLElement.querySelector(`.${e.CSSClasses.time}`);if(!t)return;const l=!0===e.settings.selection.time?12:e.settings.selection.time,s="range"===e.settings.selection.controlTime;t.innerHTML=`\n\t
\n\t\t\n\t\t\n\t\t${12===l?`\n\t\t\n\t\t`:""}\n\t
\n\t
\n\t\t\n\t\t\n\t
`,((e,t)=>{const l=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="hours"]`),s=e.HTMLElement.querySelector(`.${e.CSSClasses.timeRange} input[name="minutes"]`),a=e.HTMLElement.querySelector(`.${e.CSSClasses.timeHours} input[name="hours"]`),n=e.HTMLElement.querySelector(`.${e.CSSClasses.timeMinutes} input[name="minutes"]`),i=e.HTMLElement.querySelector(`.${e.CSSClasses.timeKeeping}`),d=(t,l)=>{t.addEventListener("mouseover",(()=>l.classList.add(e.CSSClasses.isFocus)))},c=(t,l)=>{t.addEventListener("mouseout",(()=>l.classList.remove(e.CSSClasses.isFocus)))},o=(t,l,s)=>{"hours"===s?e.selectedHours=`${l}`:"minutes"===s&&(e.selectedMinutes=`${l}`),e.selectedTime=`${e.selectedHours}:${e.selectedMinutes}${e.selectedKeeping?` ${e.selectedKeeping}`:""}`,e.actions.changeTime&&e.actions.changeTime(t,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),e.input&&e.HTMLInputElement&&e.actions.changeToInput&&e.actions.changeToInput(t,k(e),e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping)},u=(t,l,s,a)=>{t.addEventListener("input",(t=>{let n=Number(t.target.value);n=n<10?`0${n}`:`${n}`,"hours"===s&&12===a?Number(t.target.value)0?(l.value=n,e.selectedKeeping="AM",i.innerText=e.selectedKeeping,o(t,n,s)):(0===Number(t.target.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),l.value=r(t.target.value),o(t,r(t.target.value),s)):(l.value=n,o(t,n,s))}))},m=(t,l,s,a)=>{l.addEventListener("change",(l=>{const n=l.target;let d=Number(n.value);d=d<10?`0${d}`:`${d}`,"hours"===s&&12===a?n.value&&Number(n.value)<=a&&Number(n.value)>0?(n.value=d,t.value=H(d,e.selectedKeeping),o(l,d,s)):n.value&&Number(n.value)<24&&(Number(n.value)>a||0===Number(n.value))?(0===Number(n.value)?(e.selectedKeeping="AM",i.innerText="AM"):(e.selectedKeeping="PM",i.innerText="PM"),n.value=r(n.value),t.value=d,o(l,r(n.value),s)):n.value=e.selectedHours:n.value&&Number(n.value)<=a&&Number(n.value)>=0?(n.value=d,t.value=d,o(l,d,s)):"hours"===s?n.value=e.selectedHours:"minutes"===s&&(n.value=e.selectedMinutes)}))};d(l,a),d(s,n),c(l,a),c(s,n),u(l,a,"hours",24===t?23:12),u(s,n,"minutes",0),m(l,a,"hours",24===t?23:12),m(s,n,"minutes",59),i&&i.addEventListener("click",(t=>{i.innerText.includes("AM")?e.selectedKeeping="PM":e.selectedKeeping="AM",l.value=H(e.selectedHours,e.selectedKeeping),o(t,e.selectedHours,"hours"),i.innerText=e.selectedKeeping}))})(e,l)},Y=e=>{const t=[...e.locale.weekday];if(!t[0])return;const l=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.week}`),s=document.createElement("b");s.className=e.CSSClasses.weekDay,e.settings.iso8601&&t.push(t.shift()),l.forEach((l=>{l.innerHTML="";for(let a=0;a{if(void 0===e.viewYear||!e.dateMin||!e.dateMax)return;const l=(null==t?void 0:t.dataset.calendarSelectedYear)?Number(null==t?void 0:t.dataset.calendarSelectedYear):e.selectedYear;e.currentType="year",w(e,t),$(e),f(e),o(e);const s=e.HTMLElement.querySelector(`.${e.CSSClasses.years}`);if(!s)return;e.settings.selection.year&&s.classList.add(e.CSSClasses.yearsSelecting);const a=document.createElement("button");a.type="button",a.className=e.CSSClasses.yearsYear;for(let n=e.viewYear-7;ne.dateMax.getFullYear())&&(i.classList.add(e.CSSClasses.yearsYearDisabled),i.tabIndex=-1),i.dataset.calendarYear=String(t),i.innerText=`${t}`,s.append(i)}},N=["light","dark","system"];let _=!1;const A=(e,t)=>{var l;let s=null;for(let a=0;a{e.HTMLElement&&(N.includes(t)?e.HTMLElement.dataset.calendarTheme=t:console.error("Incorrect name of theme in settings.visibility.theme"))},I=(e,t)=>{if(!t)return void F(e,"light");const l=e=>e.matches?"dark":"light";e.HTMLElement.dataset.calendarTheme=l(t),_||(t.onchange=t=>{"system"===e.settings.visibility.theme&&(e.HTMLElement.dataset.calendarTheme=l(t))},_=!0)},O=(e,t)=>{if(!e.HTMLElement)return;const l=!!e.settings.visibility.themeDetect&&document.querySelector(e.settings.visibility.themeDetect);if(!l)return void I(e,t);const s=e.settings.visibility.themeDetect.replace(/^.*\[(.+)\]/g,((e,t)=>t)),a=l.hasAttribute(s);if(!s||!a)return void I(e,t);const n=A(l,s);n?(F(e,n),((e,t,l)=>{new MutationObserver((s=>{for(let a=0;a{const t={default(){Y(e),m(e)},multiple(){Y(e),m(e)},month(){L(e)},year(){x(e)}};(e=>{if(!e.HTMLElement)return;let t;"not all"!==window.matchMedia("(prefers-color-scheme)").media&&(t=window.matchMedia("(prefers-color-scheme: dark)")),"system"===e.settings.visibility.theme?O(e,t):F(e,e.settings.visibility.theme)})(e),(e=>{if("define"!==e.settings.lang){e.locale.weekday=[];for(let t=0;t<7;t++){let l=new Date(0,0,t).toLocaleString(e.settings.lang,{weekday:"short"});l=`${l.charAt(0).toUpperCase()}${l.substring(1,l.length)}`,l=l.replace(/\./,""),e.locale.weekday.push(l)}e.locale.months=[];for(let t=0;t<12;t++){let l=new Date(0,t).toLocaleString(e.settings.lang,{month:"long"});l=`${l.charAt(0).toUpperCase()}${l.substring(1,l.length)}`,l=l.replace(/\./,""),e.locale.months.push(l)}}})(e),w(e),$(e),f(e),o(e),E(e),t[e.currentType]()},q=e=>{c(e),B(e)},P=(e,t)=>{if(void 0===e.selectedMonth||void 0===e.selectedYear)return;const l=new Date(`${i(new Date(e.selectedYear,e.selectedMonth,1))}T00:00:00`);switch(t){case"prev":l.setMonth(l.getMonth()-e.jumpMonths);break;case"next":l.setMonth(l.getMonth()+e.jumpMonths)}e.selectedMonth=l.getMonth(),e.selectedYear=l.getFullYear(),$(e),f(e),o(e),m(e)};let K=null;const W=()=>{var e;if(!K)return;const t=null==(e=K.HTMLElement)?void 0:e.querySelectorAll(`.${K.CSSClasses.dayBtnHover}`);t&&t.forEach((e=>e.classList.remove(K.CSSClasses.dayBtnHover)))},j=e=>{var t;if(!K||!K.selectedDates)return;const l=i(e);if(K.rangeDisabled&&K.rangeDisabled.includes(l))return;const s=null==(t=K.HTMLElement)?void 0:t.querySelectorAll(`[data-calendar-day="${l}"]`);null==s||s.forEach((e=>{e.classList.add(K.CSSClasses.dayBtnHover)}))},R=e=>{if(!e.target||!K||!K.selectedDates)return;if(!e.target.closest(`.${K.CSSClasses.days}`))return void W();const t=e.target.dataset.calendarDay;if(!t)return;W();const l=new Date(new Date(`${K.selectedDates[0]}T00:00:00`).getFullYear(),new Date(`${K.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${K.selectedDates[0]}T00:00:00`).getDate()),s=new Date(new Date(`${t}T00:00:00`).getFullYear(),new Date(`${t}T00:00:00`).getMonth(),new Date(`${t}T00:00:00`).getDate());if(s>l)for(let a=l;a<=s;a.setDate(a.getDate()+1))j(a);else for(let a=l;a>=s;a.setDate(a.getDate()-1))j(a)},G=e=>{K&&"Escape"===e.key&&(K.selectedDates=[],K.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),B(K))},z=e=>{e&&e.selectedDates&&(K=e,e.selectedDates[0]&&e.selectedDates.length<=1?(e.HTMLElement.addEventListener("mousemove",R),document.addEventListener("keydown",G),e.settings.range.disableGaps&&(()=>{var e;if(!K||!(null==(e=K.selectedDates)?void 0:e[0])||!K.rangeDisabled||K.rangeDisabled.length<2)return;const t=new Date(`${K.selectedDates[0]}T00:00:00`);let l=null,s=null;for(let a=0;a=e)){s=e;break}l=e}l&&(l=new Date(l.setDate(l.getDate()+1)),K.rangeMin=i(l)),s&&(s=new Date(s.setDate(s.getDate()-1)),K.rangeMax=i(s))})()):(e.HTMLElement.removeEventListener("mousemove",R),document.removeEventListener("keydown",G),e.settings.range.disableGaps&&K&&(K.rangeMin=K.settings.range.min,K.rangeMax=K.settings.range.max,K.settings.range.disablePast&&new Date(`${K.settings.range.min}T00:00:00`){const n=e.HTMLElement.querySelectorAll(`.${e.CSSClasses.column}`),i=[...n].findIndex((e=>e.classList.contains(t))),d=Number(n[i].querySelector(`.${l}`).getAttribute(a));return"month"===e.currentType&&i>=0?s-i:"year"===e.currentType&&e.selectedYear!==d?s-1:s},V=e=>{e.HTMLElement.addEventListener("click",(t=>{const l=t.target,s=l.closest(`.${e.CSSClasses.arrow}`),a=l.closest(`.${e.CSSClasses.arrowPrev}`),n=l.closest(`.${e.CSSClasses.arrowNext}`),d=l.closest(`.${e.CSSClasses.dayBtn}`),r=l.closest(`.${e.CSSClasses.dayBtnPrev}`),c=l.closest(`.${e.CSSClasses.dayBtnNext}`),o=l.closest(`.${e.CSSClasses.weekNumber}`),u=l.closest(`.${e.CSSClasses.year}`),g=l.closest(`.${e.CSSClasses.yearsYear}`),v=l.closest(`.${e.CSSClasses.month}`),y=l.closest(`.${e.CSSClasses.monthsMonth}`),h=l.closest(`.${e.CSSClasses.grid}`),S=l.closest(`.${e.CSSClasses.column}`);s&&"year"!==e.currentType&&"month"!==e.currentType&&P(e,l.dataset.calendarArrow),s&&e.actions.clickArrow&&e.actions.clickArrow(t,Number(e.selectedYear),Number(e.selectedMonth)),(()=>{if(e.settings.selection.day&&["single","multiple","multiple-ranged"].includes(e.settings.selection.day)&&d){switch(e.settings.selection.day){case"single":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):(e.selectedDates=[],e.selectedDates.push(d.dataset.calendarDay)));break;case"multiple":e.selectedDates&&d&&d.dataset.calendarDay&&(d.classList.contains(e.CSSClasses.dayBtnSelected)?e.selectedDates.splice(e.selectedDates.indexOf(d.dataset.calendarDay),1):e.selectedDates.push(d.dataset.calendarDay));break;case"multiple-ranged":(()=>{if(e.selectedDates&&d&&d.dataset.calendarDay){if(e.selectedDates.length<=1&&e.selectedDates[0]&&e.selectedDates[0].includes(d.dataset.calendarDay)?e.selectedDates=[]:(e.selectedDates.length>1&&(e.selectedDates=[]),e.selectedDates.push(d.dataset.calendarDay)),e.selectedDates[1]){const t=new Date(new Date(`${e.selectedDates[0]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[0]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[0]}T00:00:00`).getDate()),l=new Date(new Date(`${e.selectedDates[1]}T00:00:00`).getFullYear(),new Date(`${e.selectedDates[1]}T00:00:00`).getMonth(),new Date(`${e.selectedDates[1]}T00:00:00`).getDate()),s=t=>{if(!e.selectedDates)return;const l=i(t);e.rangeDisabled&&e.rangeDisabled.includes(l)||e.selectedDates.push(l)};if(e.selectedDates=[],l>t)for(let e=t;e<=l;e.setDate(e.getDate()+1))s(e);else for(let e=t;e>=l;e.setDate(e.getDate()-1))s(e)}z(e)}})()}e.actions.clickDay&&e.actions.clickDay(t,e.selectedDates),e.input&&e.HTMLInputElement&&e.HTMLElement&&e.actions.changeToInput&&e.actions.changeToInput(t,k(e),e.selectedDates,e.selectedTime,e.selectedHours,e.selectedMinutes,e.selectedKeeping),r?P(e,"prev"):c?P(e,"next"):m(e)}})(),(()=>{var l;if(!e.settings.visibility.weekNumbers||!o||!e.actions.clickWeekNumber)return;const s=null==(l=e.HTMLElement)?void 0:l.querySelectorAll("[data-calendar-week-number]");if(!s)return;const a=Number(o.innerText),n=Number(o.dataset.calendarYearWeek),i=[...s].filter((e=>Number(e.dataset.calendarWeekNumber)===a));e.actions.clickWeekNumber(t,a,i,n)})(),(()=>{if(e.settings.selection.year)if(s&&"year"===e.currentType){if(void 0===e.viewYear)return;n?e.viewYear+=15:a&&(e.viewYear-=15),x(e,t.target)}else if("year"!==e.currentType&&u)x(e,t.target);else if("year"===e.currentType&&u)e.currentType=e.type,B(e);else if(g){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;e.selectedYear="multiple"===e.type?U(e,e.CSSClasses.columnYear,e.CSSClasses.year,Number(g.dataset.calendarYear),"data-calendar-selected-year"):Number(g.dataset.calendarYear),e.currentType=e.type,(e.selectedMonthe.dateMax.getMonth()&&e.selectedYear>=e.dateMax.getFullYear()||e.selectedYear>e.dateMax.getFullYear())&&(e.selectedMonth=e.dateMax.getMonth(),e.selectedYear=e.dateMax.getFullYear()),e.actions.clickYear&&e.actions.clickYear(t,e.selectedYear),B(e)}else"multiple"===e.type&&"year"===e.currentType&&h&&!S&&(e.currentType=e.type,B(e))})(),(()=>{if(e.settings.selection.month)if("month"!==e.currentType&&v)L(e,t.target);else if("month"===e.currentType&&v)e.currentType=e.type,B(e);else if(y){if(void 0===e.selectedMonth||!e.dateMin||!e.dateMax)return;if(e.selectedMonth="multiple"===e.type?U(e,e.CSSClasses.columnMonth,e.CSSClasses.month,Number(y.dataset.calendarMonth),"data-calendar-selected-month"):Number(y.dataset.calendarMonth),"multiple"===e.type){const t=y.closest(`.${e.CSSClasses.columnMonth}`).querySelector(`.${e.CSSClasses.year}`);e.selectedYear=Number(t.dataset.calendarSelectedYear),e.selectedMonthe.dateMax.getMonth()&&e.selectedYear>=e.dateMax.getFullYear()&&(e.selectedMonth=e.dateMax.getMonth())}e.currentType=e.type,e.actions.clickMonth&&e.actions.clickMonth(t,e.selectedMonth),B(e)}else"multiple"===e.type&&"month"===e.currentType&&h&&!S&&(e.currentType=e.type,B(e))})()}))},J=(e,t)=>{let l=e.offsetHeight,s=0;for(let a=e;a;a=a.offsetParent)l+=a.offsetTop||0,s+=a.offsetLeft||0;Object.assign(t.style,{left:`${s}px`,top:`${l}px`})},Q=e=>{if(!e)return;e.HTMLInputElement=e.HTMLElement,e.HTMLElement=null;const t=l=>{var s;e&&l.target!==e.HTMLInputElement&&!(null==(s=e.HTMLElement)?void 0:s.contains(l.target))&&(k(e).hide(),document.removeEventListener("click",t,{capture:!0}))};e.HTMLInputElement.addEventListener("click",(()=>{e.HTMLElement?(J(e.HTMLInputElement,e.HTMLElement),k(e).show()):(()=>{if(!e.HTMLInputElement)return;const t=document.createElement("div");t.className=`${e.CSSClasses.calendar} ${e.CSSClasses.calendarToInput} ${e.CSSClasses.calendarHidden}`,J(e.HTMLInputElement,t),e.HTMLElement=t,document.body.append(e.HTMLElement),setTimeout((()=>k(e).show()),0),q(e),V(e)})(),document.addEventListener("click",t,{capture:!0})}))},X=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#Multiple>\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Month />\n\t\t\t\t\t\t<#Year />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t<#WeekNumbers />\n\t\t\t\t\t
\n\t\t\t\t\t\t<#Week />\n\t\t\t\t\t\t<#Days />\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t<#/Multiple>\n\t
\n\t<#ControlTime />\n`,Z=e=>`\n\t
\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t
\n\t
\n\t\t
\n\t\t\t<#Months />\n\t\t
\n\t
\n`,ee=e=>`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t
\n\t\t\t<#Years />\n\t\t
\n\t
\n`,te={calendar:"vanilla-calendar",calendarDefault:"vanilla-calendar_default",calendarMultiple:"vanilla-calendar_multiple",calendarMonth:"vanilla-calendar_month",calendarYear:"vanilla-calendar_year",calendarHidden:"vanilla-calendar_hidden",calendarToInput:"vanilla-calendar_to-input",controls:"vanilla-calendar-controls",grid:"vanilla-calendar-grid",gridDisabled:"vanilla-calendar-grid_disabled",column:"vanilla-calendar-column",columnMonth:"vanilla-calendar-column_month",columnYear:"vanilla-calendar-column_year",header:"vanilla-calendar-header",headerContent:"vanilla-calendar-header__content",month:"vanilla-calendar-month",monthDisabled:"vanilla-calendar-month_disabled",year:"vanilla-calendar-year",yearDisabled:"vanilla-calendar-year_disabled",arrow:"vanilla-calendar-arrow",arrowPrev:"vanilla-calendar-arrow_prev",arrowNext:"vanilla-calendar-arrow_next",wrapper:"vanilla-calendar-wrapper",content:"vanilla-calendar-content",week:"vanilla-calendar-week",weekDay:"vanilla-calendar-week__day",weekDayWeekend:"vanilla-calendar-week__day_weekend",days:"vanilla-calendar-days",daysSelecting:"vanilla-calendar-days_selecting",months:"vanilla-calendar-months",monthsSelecting:"vanilla-calendar-months_selecting",monthsMonth:"vanilla-calendar-months__month",monthsMonthSelected:"vanilla-calendar-months__month_selected",monthsMonthDisabled:"vanilla-calendar-months__month_disabled",years:"vanilla-calendar-years",yearsSelecting:"vanilla-calendar-years_selecting",yearsYear:"vanilla-calendar-years__year",yearsYearSelected:"vanilla-calendar-years__year_selected",yearsYearDisabled:"vanilla-calendar-years__year_disabled",time:"vanilla-calendar-time",timeContent:"vanilla-calendar-time__content",timeHours:"vanilla-calendar-time__hours",timeMinutes:"vanilla-calendar-time__minutes",timeKeeping:"vanilla-calendar-time__keeping",timeRanges:"vanilla-calendar-time__ranges",timeRange:"vanilla-calendar-time__range",day:"vanilla-calendar-day",daySelected:"vanilla-calendar-day_selected",daySelectedFirst:"vanilla-calendar-day_selected-first",daySelectedLast:"vanilla-calendar-day_selected-last",daySelectedIntermediate:"vanilla-calendar-day_selected-intermediate",dayPopup:"vanilla-calendar-day__popup",dayBtn:"vanilla-calendar-day__btn",dayBtnPrev:"vanilla-calendar-day__btn_prev",dayBtnNext:"vanilla-calendar-day__btn_next",dayBtnToday:"vanilla-calendar-day__btn_today",dayBtnSelected:"vanilla-calendar-day__btn_selected",dayBtnHover:"vanilla-calendar-day__btn_hover",dayBtnDisabled:"vanilla-calendar-day__btn_disabled",dayBtnIntermediate:"vanilla-calendar-day__btn_intermediate",dayBtnWeekend:"vanilla-calendar-day__btn_weekend",dayBtnHoliday:"vanilla-calendar-day__btn_holiday",weekNumbers:"vanilla-calendar-week-numbers",weekNumbersTitle:"vanilla-calendar-week-numbers__title",weekNumbersContent:"vanilla-calendar-week-numbers__content",weekNumber:"vanilla-calendar-week-number",isFocus:"vanilla-calendar-is-focus"};return class{constructor(e,i){var d,r,o,u,m,g,v,y,h,S,M,p,C,b,D,T,w,$,f,L,k,H,E,Y,x,N,_,A,F,I,O,P,K,W,j,R,G,z,U,J,le,se,ae,ne,ie,de,re,ce,oe,ue,me,ge,ve,ye,he,Se,Me,pe,Ce,be,De,Te,we,$e,fe,Le,ke,He,Ee,Ye,xe,Ne,_e,Ae,Fe,Ie,Oe,Be,qe,Pe,Ke,We,je,Re,Ge,ze,Ue,Ve,Je,Qe,Xe,Ze,et,tt,lt,st,at,nt,it,dt,rt,ct,ot,ut,mt,gt,vt,yt,ht,St,Mt,pt,Ct,bt,Dt,Tt,wt,$t,ft,Lt,kt,Ht,Et,Yt,xt,Nt,_t,At,Ft,It,Ot,Bt;(n(this,"HTMLElement"),n(this,"input"),n(this,"type"),n(this,"months"),n(this,"jumpMonths"),n(this,"date"),n(this,"settings"),n(this,"locale"),n(this,"actions"),n(this,"popups"),n(this,"CSSClasses"),n(this,"DOMTemplates"),n(this,"currentType"),n(this,"reset",(()=>q(this))),n(this,"update",(()=>(e=>{var t;let l=null,s=null,a=null;(null==(t=e.settings.selected.dates)?void 0:t[0])||(l=e.settings.selected.dates,e.settings.selected.dates=e.selectedDates),e.settings.selected.month||(s=e.settings.selected.month,e.settings.selected.month=e.selectedMonth),e.settings.selected.year||(a=e.settings.selected.year,e.settings.selected.year=e.selectedYear),c(e),B(e),e.settings.selected.dates=l,e.settings.selected.month=s,e.settings.selected.year=a})(this))),n(this,"init",(()=>{var e;(e=this).HTMLElement&&(e.HTMLOriginalElement=e.HTMLElement.cloneNode(!0),e.input?Q(e):(q(e),V(e)))})),n(this,"destroy",(()=>(e=>{var t,l,s,a;e.HTMLOriginalElement&&(e.input?(null==(t=e.HTMLInputElement)||t.replaceWith(e.HTMLOriginalElement),null==(s=null==(l=e.HTMLElement)?void 0:l.parentNode)||s.removeChild(e.HTMLElement)):null==(a=e.HTMLElement)||a.replaceWith(e.HTMLOriginalElement),e.HTMLElement=e.HTMLOriginalElement)})(this))),this.HTMLElement="string"==typeof e?document.querySelector(e):e,this.HTMLElement)&&(this.input=null!=(d=null==i?void 0:i.input)&&d,this.type=null!=(r=null==i?void 0:i.type)?r:"default",this.months=null!=(o=null==i?void 0:i.months)?o:2,this.jumpMonths=null!=(u=null==i?void 0:i.jumpMonths)?u:1,this.date={min:null!=(g=null==(m=null==i?void 0:i.date)?void 0:m.min)?g:"1970-01-01",max:null!=(y=null==(v=null==i?void 0:i.date)?void 0:v.max)?y:"2470-12-31",today:null!=(S=null==(h=null==i?void 0:i.date)?void 0:h.today)?S:new Date},this.settings={lang:null!=(p=null==(M=null==i?void 0:i.settings)?void 0:M.lang)?p:"en",iso8601:null==(b=null==(C=null==i?void 0:i.settings)?void 0:C.iso8601)||b,range:{min:null!=(w=null==(T=null==(D=null==i?void 0:i.settings)?void 0:D.range)?void 0:T.min)?w:this.date.min,max:null!=(L=null==(f=null==($=null==i?void 0:i.settings)?void 0:$.range)?void 0:f.max)?L:this.date.max,disablePast:null!=(E=null==(H=null==(k=null==i?void 0:i.settings)?void 0:k.range)?void 0:H.disablePast)&&E,disableGaps:null!=(N=null==(x=null==(Y=null==i?void 0:i.settings)?void 0:Y.range)?void 0:x.disableGaps)&&N,disableAllDays:null!=(F=null==(A=null==(_=null==i?void 0:i.settings)?void 0:_.range)?void 0:A.disableAllDays)&&F,disableWeekday:null!=(P=null==(O=null==(I=null==i?void 0:i.settings)?void 0:I.range)?void 0:O.disableWeekday)?P:null,disabled:null!=(j=null==(W=null==(K=null==i?void 0:i.settings)?void 0:K.range)?void 0:W.disabled)?j:null,enabled:null!=(z=null==(G=null==(R=null==i?void 0:i.settings)?void 0:R.range)?void 0:G.enabled)?z:null},selection:{day:null!=(le=null==(J=null==(U=null==i?void 0:i.settings)?void 0:U.selection)?void 0:J.day)?le:"single",month:null==(ne=null==(ae=null==(se=null==i?void 0:i.settings)?void 0:se.selection)?void 0:ae.month)||ne,year:null==(re=null==(de=null==(ie=null==i?void 0:i.settings)?void 0:ie.selection)?void 0:de.year)||re,time:null!=(ue=null==(oe=null==(ce=null==i?void 0:i.settings)?void 0:ce.selection)?void 0:oe.time)&&ue,controlTime:null!=(ve=null==(ge=null==(me=null==i?void 0:i.settings)?void 0:me.selection)?void 0:ge.controlTime)?ve:"all",stepHours:null!=(Se=null==(he=null==(ye=null==i?void 0:i.settings)?void 0:ye.selection)?void 0:he.stepHours)?Se:1,stepMinutes:null!=(Ce=null==(pe=null==(Me=null==i?void 0:i.settings)?void 0:Me.selection)?void 0:pe.stepMinutes)?Ce:1},selected:{dates:null!=(Te=null==(De=null==(be=null==i?void 0:i.settings)?void 0:be.selected)?void 0:De.dates)?Te:null,month:null!=(fe=null==($e=null==(we=null==i?void 0:i.settings)?void 0:we.selected)?void 0:$e.month)?fe:null,year:null!=(He=null==(ke=null==(Le=null==i?void 0:i.settings)?void 0:Le.selected)?void 0:ke.year)?He:null,holidays:null!=(xe=null==(Ye=null==(Ee=null==i?void 0:i.settings)?void 0:Ee.selected)?void 0:Ye.holidays)?xe:null,time:null!=(Ae=null==(_e=null==(Ne=null==i?void 0:i.settings)?void 0:Ne.selected)?void 0:_e.time)?Ae:null},visibility:{theme:null!=(Oe=null==(Ie=null==(Fe=null==i?void 0:i.settings)?void 0:Fe.visibility)?void 0:Ie.theme)?Oe:"system",themeDetect:null!=(Pe=null==(qe=null==(Be=null==i?void 0:i.settings)?void 0:Be.visibility)?void 0:qe.themeDetect)?Pe:"html[data-theme]",monthShort:null==(je=null==(We=null==(Ke=null==i?void 0:i.settings)?void 0:Ke.visibility)?void 0:We.monthShort)||je,weekNumbers:null!=(ze=null==(Ge=null==(Re=null==i?void 0:i.settings)?void 0:Re.visibility)?void 0:Ge.weekNumbers)&&ze,weekend:null==(Je=null==(Ve=null==(Ue=null==i?void 0:i.settings)?void 0:Ue.visibility)?void 0:Ve.weekend)||Je,today:null==(Ze=null==(Xe=null==(Qe=null==i?void 0:i.settings)?void 0:Qe.visibility)?void 0:Xe.today)||Ze,disabled:null!=(lt=null==(tt=null==(et=null==i?void 0:i.settings)?void 0:et.visibility)?void 0:tt.disabled)&<,daysOutside:null==(nt=null==(at=null==(st=null==i?void 0:i.settings)?void 0:st.visibility)?void 0:at.daysOutside)||nt}},this.locale={months:null!=(dt=null==(it=null==i?void 0:i.locale)?void 0:it.months)?dt:[],weekday:null!=(ct=null==(rt=null==i?void 0:i.locale)?void 0:rt.weekday)?ct:[]},this.actions={clickDay:null!=(ut=null==(ot=null==i?void 0:i.actions)?void 0:ot.clickDay)?ut:null,clickWeekNumber:null!=(gt=null==(mt=null==i?void 0:i.actions)?void 0:mt.clickWeekNumber)?gt:null,clickMonth:null!=(yt=null==(vt=null==i?void 0:i.actions)?void 0:vt.clickMonth)?yt:null,clickYear:null!=(St=null==(ht=null==i?void 0:i.actions)?void 0:ht.clickYear)?St:null,clickArrow:null!=(pt=null==(Mt=null==i?void 0:i.actions)?void 0:Mt.clickArrow)?pt:null,changeTime:null!=(bt=null==(Ct=null==i?void 0:i.actions)?void 0:Ct.changeTime)?bt:null,changeToInput:null!=(Tt=null==(Dt=null==i?void 0:i.actions)?void 0:Dt.changeToInput)?Tt:null,getDays:null!=($t=null==(wt=null==i?void 0:i.actions)?void 0:wt.getDays)?$t:null,hideCalendar:null!=(Lt=null==(ft=null==i?void 0:i.actions)?void 0:ft.hideCalendar)?Lt:null,showCalendar:null!=(Ht=null==(kt=null==i?void 0:i.actions)?void 0:kt.showCalendar)?Ht:null},this.popups=null!=(Et=null==i?void 0:i.popups)?Et:null,this.CSSClasses=(()=>{const e=((e,n)=>{for(var i in n||(n={}))l.call(n,i)&&a(e,i,n[i]);if(t)for(var i of t(n))s.call(n,i)&&a(e,i,n[i]);return e})({},te);return Object.keys(te).forEach((t=>{var l;(null==(l=null==i?void 0:i.CSSClasses)?void 0:l[t])?e[t]=i.CSSClasses[t]:e[t]=te[t]})),e})(),this.DOMTemplates={default:null!=(xt=null==(Yt=null==i?void 0:i.DOMTemplates)?void 0:Yt.default)?xt:(Bt=this.CSSClasses,`\n\t
\n\t\t<#ArrowPrev />\n\t\t
\n\t\t\t<#Month />\n\t\t\t<#Year />\n\t\t
\n\t\t<#ArrowNext />\n\t
\n\t
\n\t\t<#WeekNumbers />\n\t\t
\n\t\t\t<#Week />\n\t\t\t<#Days />\n\t\t
\n\t
\n\t<#ControlTime />\n`),multiple:null!=(_t=null==(Nt=null==i?void 0:i.DOMTemplates)?void 0:Nt.multiple)?_t:X(this.CSSClasses),month:null!=(Ft=null==(At=null==i?void 0:i.DOMTemplates)?void 0:At.month)?Ft:Z(this.CSSClasses),year:null!=(Ot=null==(It=null==i?void 0:i.DOMTemplates)?void 0:It.year)?Ot:ee(this.CSSClasses)},this.currentType=this.type)}}})); diff --git a/package/build/vanilla-calendar.min.mjs b/package/build/vanilla-calendar.min.mjs index 7b8da3df..f6822d1d 100644 --- a/package/build/vanilla-calendar.min.mjs +++ b/package/build/vanilla-calendar.min.mjs @@ -1508,6 +1508,7 @@ const handlerInput = (self) => { const initCalendar = (self) => { if (!self.HTMLElement) return; + self.HTMLOriginalElement = self.HTMLElement.cloneNode(true); if (self.input) { handlerInput(self); } else { @@ -1656,6 +1657,18 @@ const classes = { weekNumber: "vanilla-calendar-week-number", isFocus: "vanilla-calendar-is-focus" }; +const destroyCalendar = (self) => { + var _a, _b, _c, _d; + if (!self.HTMLOriginalElement) + return; + if (self.input) { + (_a = self.HTMLInputElement) == null ? void 0 : _a.replaceWith(self.HTMLOriginalElement); + (_c = (_b = self.HTMLElement) == null ? void 0 : _b.parentNode) == null ? void 0 : _c.removeChild(self.HTMLElement); + } else { + (_d = self.HTMLElement) == null ? void 0 : _d.replaceWith(self.HTMLOriginalElement); + } + self.HTMLElement = self.HTMLOriginalElement; +}; class VanillaCalendar { constructor(selector, option) { __publicField(this, "HTMLElement"); @@ -1674,6 +1687,7 @@ class VanillaCalendar { __publicField(this, "reset", () => resetCalendar(this)); __publicField(this, "update", () => updateCalendar(this)); __publicField(this, "init", () => initCalendar(this)); + __publicField(this, "destroy", () => destroyCalendar(this)); var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb; this.HTMLElement = typeof selector === "string" ? document.querySelector(selector) : selector; if (!this.HTMLElement) diff --git a/package/package.json b/package/package.json index f080910a..6bfec5f5 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { "name": "@uvarov.frontend/vanilla-calendar", - "version": "2.7.0", - "description": "VanillaCalendar is a pure JavaScript date and time picker that uses TypeScript so it supports any JS framework and library.", + "version": "2.7.1", + "description": "Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.", "homepage": "https://vanilla-calendar.com", "keywords": [ "calendar", diff --git a/package/src/styles/vanilla-calendar.css b/package/src/styles/vanilla-calendar.css index e9e6c5c8..4d5d8f3a 100644 --- a/package/src/styles/vanilla-calendar.css +++ b/package/src/styles/vanilla-calendar.css @@ -1,5 +1,9 @@ .vanilla-calendar { - @apply p-4 rounded-xl opacity-100 transition-opacity relative flex flex-col min-w-[275px] max-w-full h-max + @apply p-4 rounded-xl opacity-100 transition-opacity relative flex flex-col min-w-[275px] max-w-full h-max w-max +} + +.vanilla-calendar_multiple { + @apply w-auto } .vanilla-calendar button:focus-visible {