1/** 2* @license 3* Package: @easepick/core 4* Version: 1.2.1 5* https://easepick.com/ 6* Copyright 2023 Rinat G. 7* 8* Licensed under the terms of GNU General Public License Version 2 or later. (http://www.gnu.org/licenses/gpl.html) 9*/ 10!(function (e, t) { 11 "object" == typeof exports && "undefined" != typeof module 12 ? t(exports, require("@easepick/datetime")) 13 : "function" == typeof define && define.amd 14 ? define(["exports", "@easepick/datetime"], t) 15 : t( 16 ((e = 17 "undefined" != typeof globalThis ? globalThis : e || self).easepick = 18 e.easepick || {}), 19 e.easepick 20 ); 21})(this, function (e, t) { 22 "use strict"; 23 class i { 24 picker; 25 constructor(e) { 26 this.picker = e; 27 } 28 render(e, i) { 29 e || (e = new t.DateTime()), 30 e.setDate(1), 31 e.setHours(0, 0, 0, 0), 32 "function" == typeof this[`get${i}View`] && this[`get${i}View`](e); 33 } 34 getContainerView(e) { 35 (this.picker.ui.container.innerHTML = ""), 36 this.picker.options.header && 37 this.picker.trigger("render", { date: e.clone(), view: "Header" }), 38 this.picker.trigger("render", { date: e.clone(), view: "Main" }), 39 this.picker.options.autoApply || 40 this.picker.trigger("render", { date: e.clone(), view: "Footer" }); 41 } 42 getHeaderView(e) { 43 const t = document.createElement("header"); 44 this.picker.options.header instanceof HTMLElement && 45 t.appendChild(this.picker.options.header), 46 "string" == typeof this.picker.options.header && 47 (t.innerHTML = this.picker.options.header), 48 this.picker.ui.container.appendChild(t), 49 this.picker.trigger("view", { 50 target: t, 51 date: e.clone(), 52 view: "Header", 53 }); 54 } 55 getMainView(e) { 56 const t = document.createElement("main"); 57 this.picker.ui.container.appendChild(t); 58 const i = document.createElement("div"); 59 i.className = `calendars grid-${this.picker.options.grid}`; 60 for (let t = 0; t < this.picker.options.calendars; t++) { 61 const n = document.createElement("div"); 62 (n.className = "calendar"), i.appendChild(n); 63 const s = this.getCalendarHeaderView(e.clone()); 64 n.appendChild(s), 65 this.picker.trigger("view", { 66 date: e.clone(), 67 view: "CalendarHeader", 68 index: t, 69 target: s, 70 }); 71 const a = this.getCalendarDayNamesView(); 72 n.appendChild(a), 73 this.picker.trigger("view", { 74 date: e.clone(), 75 view: "CalendarDayNames", 76 index: t, 77 target: a, 78 }); 79 const o = this.getCalendarDaysView(e.clone()); 80 n.appendChild(o), 81 this.picker.trigger("view", { 82 date: e.clone(), 83 view: "CalendarDays", 84 index: t, 85 target: o, 86 }); 87 const r = this.getCalendarFooterView( 88 this.picker.options.lang, 89 e.clone() 90 ); 91 n.appendChild(r), 92 this.picker.trigger("view", { 93 date: e.clone(), 94 view: "CalendarFooter", 95 index: t, 96 target: r, 97 }), 98 this.picker.trigger("view", { 99 date: e.clone(), 100 view: "CalendarItem", 101 index: t, 102 target: n, 103 }), 104 e.add(1, "month"); 105 } 106 t.appendChild(i), 107 this.picker.trigger("view", { 108 date: e.clone(), 109 view: "Calendars", 110 target: i, 111 }), 112 this.picker.trigger("view", { 113 date: e.clone(), 114 view: "Main", 115 target: t, 116 }); 117 } 118 getFooterView(e) { 119 const t = document.createElement("footer"), 120 i = document.createElement("div"); 121 i.className = "footer-buttons"; 122 const n = document.createElement("button"); 123 (n.className = "cancel-button unit"), 124 (n.innerHTML = this.picker.options.locale.cancel), 125 i.appendChild(n); 126 const s = document.createElement("button"); 127 (s.className = "apply-button unit"), 128 (s.innerHTML = this.picker.options.locale.apply), 129 (s.disabled = !0), 130 i.appendChild(s), 131 t.appendChild(i), 132 this.picker.ui.container.appendChild(t), 133 this.picker.trigger("view", { date: e, target: t, view: "Footer" }); 134 } 135 getCalendarHeaderView(e) { 136 const t = document.createElement("div"); 137 t.className = "header"; 138 const i = document.createElement("div"); 139 (i.className = "month-name"), 140 (i.innerHTML = `<span>
140${e.toLocaleString(this.picker.options.lang, { 141 month: "long", 142 })}</span> ${e.format("YYYY")}`), 143 t.appendChild(i); 144 const n = document.createElement("button"); 145 (n.className = "previous-button unit"), 146 (n.innerHTML = this.picker.options.locale.previousMonth), 147 t.appendChild(n); 148 const s = document.createElement("button"); 149 return ( 150 (s.className = "next-button unit"), 151 (s.innerHTML = this.picker.options.locale.nextMonth), 152 t.appendChild(s), 153 t 154 ); 155 } 156 getCalendarDayNamesView() { 157 const e = document.createElement("div"); 158 e.className = "daynames-row"; 159 for (let t = 1; t <= 7; t++) { 160 const i = 3 + this.picker.options.firstDay + t, 161 n = document.createElement("div"); 162 (n.className = "dayname"), 163 (n.innerHTML = new Date(1970, 0, i, 12, 0, 0, 0).toLocaleString( 164 this.picker.options.lang, 165 { weekday: "short" } 166 )), 167 (n.title = new Date(1970, 0, i, 12, 0, 0, 0).toLocaleString( 168 this.picker.options.lang, 169 { weekday: "long" } 170 )), 171 e.appendChild(n), 172 this.picker.trigger("view", { 173 dayIdx: i, 174 view: "CalendarDayName", 175 target: n, 176 }); 177 } 178 return e; 179 } 180 getCalendarDaysView(e) { 181 const t = document.createElement("div"); 182 t.className = "days-grid"; 183 const i = this.calcOffsetDays(e, this.picker.options.firstDay), 184 n = 32 - new Date(e.getFullYear(), e.getMonth(), 32).getDate(); 185 for (let e = 0; e < i; e++) { 186 const e = document.createElement("div"); 187 (e.className = "offset"), t.appendChild(e); 188 } 189 for (let i = 1; i <= n; i++) { 190 e.setDate(i); 191 const n = this.getCalendarDayView(e); 192 t.appendChild(n), 193 this.picker.trigger("view", { 194 date: e, 195 view: "CalendarDay", 196 target: n, 197 }); 198 } 199 return t; 200 } 201 getCalendarDayView(e) { 202 const i = this.picker.options.date 203 ? new t.DateTime(this.picker.options.date) 204 : null, 205 n = new t.DateTime(), 206 s = document.createElement("div"); 207 return ( 208 (s.className = "day unit"), 209 (s.innerHTML = e.format("D")), 210 (s.dataset.time = String(e.getTime())), 211 e.isSame(n, "day") && s.classList.add("today"), 212 [0, 6].includes(e.getDay()) && s.classList.add("weekend"), 213 this.picker.datePicked.length 214 ? this.picker.datePicked[0].isSame(e, "day") && 215 s.classList.add("selected") 216 : i && e.isSame(i, "day") && s.classList.add("selected"), 217 this.picker.trigger("view", { 218 date: e, 219 view: "CalendarDay", 220 target: s, 221 }), 222 s 223 ); 224 } 225 getCalendarFooterView(e, t) { 226 const i = document.createElement("div"); 227 return (i.className = "footer"), i; 228 } 229 calcOffsetDays(e, t) { 230 let i = e.getDay() - t; 231 return i < 0 && (i += 7), i; 232 } 233 } 234 class n { 235 picker; 236 instances = {}; 237 constructor(e) { 238 this.picker = e; 239 } 240 initialize() { 241 const e = []; 242 this.picker.options.plugins.forEach((t) => { 243 "function" == typeof t 244 ? e.push(new t()) 245 : "string" == typeof t && 246 "undefined" != typeof easepick && 247 Object.prototype.hasOwnProperty.call(easepick, t) 248 ? e.push(new easepick[t]()) 249 : console.warn(`easepick: ${t} not found.`); 250 }), 251 e.sort((e, t) => 252 e.priority > t.priority 253 ? -1 254 : e.priority < t.priority || 255 e.dependencies.length > t.dependencies.length 256 ? 1 257 : e.dependencies.length < t.dependencies.length 258 ? -1 259 : 0 260 ), 261 e.forEach((e) => { 262 e.attach(this.picker), (this.instances[e.getName()] = e); 263 }); 264 } 265 getInstance(e) { 266 return this.instances[e]; 267 } 268 addInstance(e) { 269 if (Object.prototype.hasOwnProperty.call(this.instances, e)) 270 console.warn(`easepick: ${e} already added.`); 271 else { 272 if ( 273 "undefined" != typeof easepick && 274 Object.prototype.hasOwnProperty.call(easepick, e) 275 ) { 276 const t = new easepick[e](); 277 return t.attach(this.picker), (this.instances[t.getName()] = t), t; 278 } 279 if ("undefined" !== this.getPluginFn(e)) { 280 const t = new (this.getPluginFn(e))(); 281 return t.attach(this.picker), (this.instances[t.getName()] = t), t; 282 } 283 console.warn(`easepick: ${e} not found.`); 284 } 285 return null; 286 } 287 removeInstance(e) { 288 return ( 289 e in this.instances && this.instances[e].detach(), 290 delete this.instances[e] 291 ); 292 } 293 reloadInstance(e) { 294 return this.removeInstance(e), this.addInstance(e); 295 } 296 getPluginFn(e) { 297 return [...this.picker.options.plugins] 298 .filter((t) => "function" == typeof t && new t().getName() === e) 299 .shift(); 300 } 301 } 302 class s { 303 Calendar = new i(this); 304 PluginManager = new n(this); 305 calendars = []; 306 datePicked = []; 307 cssLoaded = 0; 308 binds = { 309 hidePicker: this.hidePicker.bind(this), 310 show: this.show.bind(this), 311 }; 312 options = { 313 doc: document, 314 css: ["https://new.differenthotels.be/wp-content/plugins/mylighthouse
314-booker/assets/vendor/easepick/easepick.css"], 315 element: null, 316 firstDay: 1, 317 grid: 1, 318 calendars: 1, 319 lang: "nl-NL", 320 date: null, 321 format: "YYYY-MM-DD", 322 readonly: !0, 323 autoApply: !0, 324 header: !1, 325 inline: !1, 326 scrollToDate: !0, 327 locale: { 328 nextMonth: 329 '<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M2.748 16L0 13.333 5.333 8 0 2.667 2.748 0l7.919 8z" fill-rule="nonzero"/></svg>', 330 previousMonth: 331 '<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M7.919 0l2.748 2.667L5.333 8l5.334 5.333L7.919 16 0 8z" fill-rule="nonzero"/></svg>', 332 cancel: "Cancel", 333 apply: "Apply", 334 }, 335 documentClick: this.binds.hidePicker, 336 plugins: [], 337 }; 338 ui = { container: null, shadowRoot: null, wrapper: null }; 339 version = "1.2.1"; 340 constructor(e) { 341 const t = { ...this.options.locale, ...e.locale }; 342 (this.options = { ...this.options, ...e }), 343 (this.options.locale = t), 344 this.handleOptions(), 345 (this.ui.wrapper = document.createElement("span")), 346 (this.ui.wrapper.style.display = "none"), 347 (this.ui.wrapper.style.position = "absolute"), 348 (this.ui.wrapper.style.pointerEvents = "none"), 349 (this.ui.wrapper.className = "easepick-wrapper"), 350 this.ui.wrapper.attachShadow({ mode: "open" }), 351 (this.ui.shadowRoot = this.ui.wrapper.shadowRoot), 352 (this.ui.container = document.createElement("div")), 353 (this.ui.container.className = "container"), 354 this.options.zIndex && 355 (this.ui.container.style.zIndex = String(this.options.zIndex)), 356 this.options.inline && 357 ((this.ui.wrapper.style.position = "relative"), 358 this.ui.container.classList.add("inline")), 359 this.ui.shadowRoot.appendChild(this.ui.container), 360 this.options.element.after(this.ui.wrapper), 361 this.handleCSS(), 362 this.options.element.addEventListener("click", this.binds.show), 363 this.on("view", this.onView.bind(this)), 364 this.on("render", this.onRender.bind(this)), 365 this.PluginManager.initialize(), 366 this.parseValues(), 367 "function" == typeof this.options.setup && this.options.setup(this), 368 this.on("click", this.onClick.bind(this)); 369 const i = this.options.scrollToDate ? this.getDate() : null; 370 this.renderAll(i); 371 } 372 on(e, t, i = {}) { 373 this.ui.container.addEventListener(e, t, i); 374 } 375 off(e, t, i = {}) { 376 this.ui.container.removeEventListener(e, t, i); 377 } 378 trigger(e, t = {}) { 379 return this.ui.container.dispatchEvent(new CustomEvent(e, { detail: t })); 380 } 381 destroy() { 382 this.options.element.removeEventListener("click", this.binds.show), 383 "function" == typeof this.options.documentClick && 384 document.removeEventListener("click", this.options.documentClick, !0), 385 Object.keys(this.PluginManager.instances).forEach((e) => { 386 this.PluginManager.removeInstance(e); 387 }), 388 this.ui.wrapper.remove(); 389 } 390 onRender(e) { 391 const { view: t, date: i } = e.detail; 392 this.Calendar.render(i, t); 393 } 394 onView(e) { 395 const { view: t, target: i } = e.detail; 396 if ("Footer" === t && this.datePicked.length) { 397 i.querySelector(".apply-button").disabled = !1; 398 } 399 } 400 onClickHeaderButton(e) { 401 this.isCalendarHeaderButton(e) && 402 (e.classList.contains("next-button") 403 ? this.calendars[0].add(1, "month") 404 : this.calendars[0].subtract(1, "month"), 405 this.renderAll(this.calendars[0])); 406 } 407 onClickCalendarDay(e) { 408 if (this.isCalendarDay(e)) { 409 const i = new t.DateTime(e.dataset.time); 410 this.options.autoApply 411 ? (this.setDate(i), 412 this.trigger("select", { date: this.getDate() }), 413 this.hide()) 414 : ((this.datePicked[0] = i), 415 this.trigger("preselect", { date: this.getDate() }), 416 this.renderAll()); 417 } 418 } 419 onClickApplyButton(e) { 420 if (this.isApplyButton(e)) { 421 if (this.datePicked[0] instanceof Date) { 422 const e = this.datePicked[0].clone(); 423 this.setDate(e); 424 } 425 this.hide(), this.trigger("select", { date: this.getDate() }); 426 } 427 } 428 onClickCancelButton(e) { 429 this.isCancelButton(e) && this.hide(); 430 } 431 onClick(e) { 432 const t = e.target; 433 if (t instanceof HTMLElement) { 434 const e = t.closest(".unit"); 435 if (!(e instanceof HTMLElement)) return; 436 this.onClickHeaderButton(e), 437 this.onClickCalendarDay(e), 438 this.onClickApplyButton(e), 439 this.onClickCancelButton(e); 440 } 441 } 442 isShown() { 443 return ( 444 this.ui.container.classList.contains("inline") || 445 this.ui.container.classList.contains("show") 446 ); 447 } 448 show(e) { 449 if (this.isShown()) return; 450 const t = e && "target" in e ? e.target : this.options.element, 451 { top: i, left: n } = this.adjustPosition(t); 452 (this.ui.container.style.top = `${i}px`), 453 (this.ui.container.style.left = `${n}px`), 454 this.ui.container.classList.add("show"), 455 this.trigger("show", { target: t }); 456 } 457 hide() { 458 this.ui.container.classList.remove("show"), 459 (this.datePicked.length = 0), 460 this.renderAll(), 461 this.trigger("hide"); 462 } 463 setDate(e) { 464 const i = new t.DateTime(e, this.options.format); 465 (this.options.date = i.clone()),
466 this.updateValues(), 467 this.calendars.length && this.renderAll(); 468 } 469 getDate() { 470 return this.options.date instanceof t.DateTime 471 ? this.options.date.clone() 472 : null; 473 } 474 parseValues() { 475 this.options.date 476 ? this.setDate(this.options.date) 477 : this.options.element instanceof HTMLInputElement && 478 this.options.element.value.length && 479 this.setDate(this.options.element.value), 480 this.options.date instanceof Date || (this.options.date = null); 481 } 482 updateValues() { 483 const e = this.getDate(), 484 t = 485 e instanceof Date 486 ? e.format(this.options.format, this.options.lang) 487 : "", 488 i = this.options.element; 489 i instanceof HTMLInputElement 490 ? (i.value = t) 491 : i instanceof HTMLElement && (i.innerText = t); 492 } 493 hidePicker(e) { 494 let t = e.target, 495 i = null; 496 t.shadowRoot && ((t = e.composedPath()[0]), (i = t.getRootNode().host)), 497 this.isShown() && 498 i !== this.ui.wrapper && 499 t !== this.options.element && 500 this.hide(); 501 } 502 renderAll(e) { 503 this.trigger("render", { 504 view: "Container", 505 date: (e || this.calendars[0]).clone(), 506 }); 507 } 508 isCalendarHeaderButton(e) { 509 return ["previous-button", "next-button"].some((t) => 510 e.classList.contains(t) 511 ); 512 } 513 isCalendarDay(e) { 514 return e.classList.contains("day"); 515 } 516 isApplyButton(e) { 517 return e.classList.contains("apply-button"); 518 } 519 isCancelButton(e) { 520 return e.classList.contains("cancel-button"); 521 } 522 gotoDate(e) { 523 const i = new t.DateTime(e, this.options.format); 524 i.setDate(1), (this.calendars[0] = i.clone()), this.renderAll(); 525 } 526 clear() { 527 (this.options.date = null), 528 (this.datePicked.length = 0), 529 this.updateValues(), 530 this.renderAll(), 531 this.trigger("clear"); 532 } 533 handleOptions() { 534 this.options.element instanceof HTMLElement || 535 (this.options.element = this.options.doc.querySelector( 536 this.options.element 537 )), 538 "function" == typeof this.options.documentClick && 539 document.addEventListener("click", this.options.documentClick, !0), 540 this.options.element instanceof HTMLInputElement && 541 (this.options.element.readOnly = this.options.readonly), 542 this.options.date 543 ? (this.calendars[0] = new t.DateTime( 544 this.options.date, 545 this.options.format 546 )) 547 : (this.calendars[0] = new t.DateTime()); 548 } 549 handleCSS() { 550 if (Array.isArray(this.options.css)) 551 this.options.css.forEach((e) => { 552 const t = document.createElement("link"); 553 (t.href = e), (t.rel = "stylesheet"); 554 const i = () => { 555 this.cssLoaded++, 556 this.cssLoaded === this.options.css.length && 557 (this.ui.wrapper.style.display = ""); 558 }; 559 t.addEventListener("load", i), 560 t.addEventListener("error", i), 561 this.ui.shadowRoot.append(t); 562 }); 563 else if ("string" == typeof this.options.css) { 564 const e = document.createElement("style"), 565 t = document.createTextNode(this.options.css); 566 e.appendChild(t), 567 this.ui.shadowRoot.append(e), 568 (this.ui.wrapper.style.display = ""); 569 } else 570 "function" == typeof this.options.css && 571 (this.options.css.call(this, this), 572 (this.ui.wrapper.style.display = "")); 573 } 574 adjustPosition(e) { 575 const t = e.getBoundingClientRect(), 576 i = this.ui.wrapper.getBoundingClientRect(); 577 this.ui.container.classList.add("calc"); 578 const n = this.ui.container.getBoundingClientRect(); 579 this.ui.container.classList.remove("calc"); 580 let s = t.bottom - i.bottom, 581 a = t.left - i.left; 582 return ( 583 "undefined" != typeof window && 584 (window.innerHeight < s + n.height && 585 s - n.height >= 0 && 586 (s = t.top - i.top - n.height), 587 window.innerWidth < a + n.width && 588 t.right - n.width >= 0 && 589 (a = t.right - i.right - n.width)), 590 { left: a, top: s } 591 ); 592 } 593 } 594 var a = Object.freeze({ __proto__: null, Core: s, create: s }); 595 (e.Core = s), 596 (e.create = s), 597 (e.easepick = a), 598 Object.defineProperty(e, "__esModule", { value: !0 }); 599});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.