@glatam/calendar-ui 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/glatam-calendar-mini.d.ts +7 -0
- package/dist/glatam-calendar-mini.d.ts.map +1 -1
- package/dist/glatam-calendar.cjs +106 -39
- package/dist/glatam-calendar.js +344 -254
- package/package.json +2 -2
package/dist/glatam-calendar.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { css as
|
|
1
|
+
import { css as M, LitElement as E, html as d } from "lit";
|
|
2
2
|
import { property as s, customElement as T, state as u } from "lit/decorators.js";
|
|
3
|
-
import { isTimeBlocked as
|
|
3
|
+
import { isTimeBlocked as C, formatISODate as _, generateMonthDays as P, generateWeekDays as j } from "@glatam/calendar-core";
|
|
4
4
|
import { formatISODate as nt, isTimeBlocked as dt, parseISODate as ct } from "@glatam/calendar-core";
|
|
5
5
|
import { classMap as N } from "lit/directives/class-map.js";
|
|
6
|
-
const
|
|
6
|
+
const A = M`
|
|
7
7
|
:host {
|
|
8
8
|
/* Fonts */
|
|
9
9
|
--glatam-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
@@ -91,7 +91,7 @@ const P = E`
|
|
|
91
91
|
--glatam-padding: 24px;
|
|
92
92
|
font-size: 1.1rem;
|
|
93
93
|
}
|
|
94
|
-
`, W =
|
|
94
|
+
`, W = M`
|
|
95
95
|
:host {
|
|
96
96
|
display: grid;
|
|
97
97
|
min-width: 0;
|
|
@@ -348,8 +348,8 @@ const P = E`
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
`;
|
|
351
|
-
function
|
|
352
|
-
if (
|
|
351
|
+
function I(t, e, a) {
|
|
352
|
+
if (e === a) return 0;
|
|
353
353
|
const i = (r, l) => {
|
|
354
354
|
const o = {
|
|
355
355
|
year: "numeric",
|
|
@@ -361,93 +361,93 @@ function C(e, t, a) {
|
|
|
361
361
|
hour12: !1
|
|
362
362
|
};
|
|
363
363
|
l !== "local" && (o.timeZone = l);
|
|
364
|
-
const n = new Intl.DateTimeFormat("en-US", o).formatToParts(r), c = new Map(n.map(($) => [$.type, $.value])), m = Number(c.get("hour")),
|
|
364
|
+
const n = new Intl.DateTimeFormat("en-US", o).formatToParts(r), c = new Map(n.map(($) => [$.type, $.value])), m = Number(c.get("hour")), v = m === 24 ? 0 : m;
|
|
365
365
|
return new Date(
|
|
366
366
|
Number(c.get("year")),
|
|
367
367
|
Number(c.get("month")) - 1,
|
|
368
368
|
Number(c.get("day")),
|
|
369
|
-
|
|
369
|
+
v,
|
|
370
370
|
Number(c.get("minute")),
|
|
371
371
|
Number(c.get("second"))
|
|
372
372
|
);
|
|
373
373
|
};
|
|
374
374
|
try {
|
|
375
|
-
const r = i(
|
|
376
|
-
return (i(
|
|
375
|
+
const r = i(t, e);
|
|
376
|
+
return (i(t, a).getTime() - r.getTime()) / (60 * 1e3);
|
|
377
377
|
} catch {
|
|
378
378
|
return 0;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function U(
|
|
382
|
-
if (
|
|
383
|
-
return { start:
|
|
381
|
+
function U(t, e) {
|
|
382
|
+
if (e === 0)
|
|
383
|
+
return { start: t.start, end: t.end, dayShift: 0 };
|
|
384
384
|
const a = (c) => {
|
|
385
|
-
const [m,
|
|
386
|
-
return m * 60 +
|
|
385
|
+
const [m, v] = c.split(":").map(Number);
|
|
386
|
+
return m * 60 + v;
|
|
387
387
|
}, i = (c) => {
|
|
388
388
|
let m = c % 1440;
|
|
389
389
|
m < 0 && (m += 1440);
|
|
390
|
-
const
|
|
391
|
-
return `${
|
|
392
|
-
}, r = a(
|
|
390
|
+
const v = String(Math.floor(m / 60)).padStart(2, "0"), $ = String(m % 60).padStart(2, "0");
|
|
391
|
+
return `${v}:${$}`;
|
|
392
|
+
}, r = a(t.start), l = a(t.end), o = r + e, h = l + e;
|
|
393
393
|
let n = 0;
|
|
394
394
|
return o < 0 ? n = -1 : o >= 1440 && (n = 1), {
|
|
395
395
|
start: i(o),
|
|
396
|
-
end: i(
|
|
396
|
+
end: i(h),
|
|
397
397
|
dayShift: n
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
-
var L = Object.defineProperty, F = Object.getOwnPropertyDescriptor, D = (
|
|
401
|
-
for (var r = i > 1 ? void 0 : i ? F(
|
|
402
|
-
(o =
|
|
403
|
-
return i && r && L(
|
|
400
|
+
var L = Object.defineProperty, F = Object.getOwnPropertyDescriptor, D = (t, e, a, i) => {
|
|
401
|
+
for (var r = i > 1 ? void 0 : i ? F(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
402
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
403
|
+
return i && r && L(e, a, r), r;
|
|
404
404
|
};
|
|
405
|
-
let f = class extends
|
|
405
|
+
let f = class extends E {
|
|
406
406
|
constructor() {
|
|
407
407
|
super(...arguments), this.days = [], this.locale = "es", this.startOfWeekDay = 0, this.selectedDates = [], this.role = "provider", this.size = "medium", this.minDate = "", this.maxDate = "", this.showNeighboringMonth = !0, this.tileClassName = null;
|
|
408
408
|
}
|
|
409
409
|
getWeekdayNames() {
|
|
410
|
-
const
|
|
410
|
+
const t = [], e = new Date(2026, 6, 12 + this.startOfWeekDay), a = new Intl.DateTimeFormat(this.locale, { weekday: "short" });
|
|
411
411
|
for (let i = 0; i < 7; i++)
|
|
412
|
-
|
|
413
|
-
return
|
|
412
|
+
t.push(a.format(e)), e.setDate(e.getDate() + 1);
|
|
413
|
+
return t;
|
|
414
414
|
}
|
|
415
|
-
handleDayClick(
|
|
416
|
-
const
|
|
417
|
-
this.role === "buyer" && (
|
|
418
|
-
detail: { dateString:
|
|
415
|
+
handleDayClick(t) {
|
|
416
|
+
const e = this.minDate && t.dateString < this.minDate || this.maxDate && t.dateString > this.maxDate;
|
|
417
|
+
this.role === "buyer" && (t.isBlocked || e) || this.dispatchEvent(new CustomEvent("day-select", {
|
|
418
|
+
detail: { dateString: t.dateString, isBlocked: t.isBlocked },
|
|
419
419
|
bubbles: !0,
|
|
420
420
|
composed: !0
|
|
421
421
|
}));
|
|
422
422
|
}
|
|
423
423
|
render() {
|
|
424
|
-
const
|
|
424
|
+
const t = this.getWeekdayNames();
|
|
425
425
|
return d`
|
|
426
|
-
${
|
|
426
|
+
${t.map((e) => d`<div class="weekday">${e}</div>`)}
|
|
427
427
|
|
|
428
|
-
${this.days.map((
|
|
429
|
-
var
|
|
430
|
-
if (!
|
|
428
|
+
${this.days.map((e) => {
|
|
429
|
+
var h;
|
|
430
|
+
if (!e.isCurrentMonth && !this.showNeighboringMonth)
|
|
431
431
|
return d`<div class="day-cell empty"></div>`;
|
|
432
|
-
const a =
|
|
432
|
+
const a = e.dateString === (/* @__PURE__ */ new Date()).toISOString().split("T")[0], i = this.selectedDates.includes(e.dateString), r = e.slots.filter((n) => n.isBlocked), l = this.minDate && e.dateString < this.minDate || this.maxDate && e.dateString > this.maxDate, o = this.tileClassName ? this.tileClassName({ date: e.date, dateString: e.dateString }) : "";
|
|
433
433
|
return d`
|
|
434
434
|
<div
|
|
435
435
|
class=${N({
|
|
436
436
|
"day-cell": !0,
|
|
437
|
-
padding: !
|
|
438
|
-
blocked:
|
|
437
|
+
padding: !e.isCurrentMonth,
|
|
438
|
+
blocked: e.isBlocked,
|
|
439
439
|
today: a,
|
|
440
440
|
selected: i,
|
|
441
441
|
disabled: !!l,
|
|
442
442
|
[o]: !!o
|
|
443
443
|
})}
|
|
444
444
|
part="day-cell ${o}"
|
|
445
|
-
@click=${() => this.handleDayClick(
|
|
445
|
+
@click=${() => this.handleDayClick(e)}
|
|
446
446
|
>
|
|
447
|
-
<div class="day-number">${
|
|
447
|
+
<div class="day-number">${e.dayNumber}</div>
|
|
448
448
|
|
|
449
449
|
<div class="slot-indicator">
|
|
450
|
-
${
|
|
450
|
+
${e.isBlocked ? d`<div class="badge blocked-day">${((h = e.rule) == null ? void 0 : h.description) || "Bloqueado"}</div>` : r.slice(0, 2).map((n) => {
|
|
451
451
|
var c, m;
|
|
452
452
|
return d`
|
|
453
453
|
<div class="badge blocked-slot" title=${((c = n.rule) == null ? void 0 : c.description) || ""}>
|
|
@@ -455,7 +455,7 @@ let f = class extends O {
|
|
|
455
455
|
</div>
|
|
456
456
|
`;
|
|
457
457
|
})}
|
|
458
|
-
${!
|
|
458
|
+
${!e.isBlocked && r.length > 2 ? d`<div style="text-align: center; font-size: 0.65rem; color: var(--glatam-text-secondary);">+${r.length - 2} tareas</div>` : ""}
|
|
459
459
|
</div>
|
|
460
460
|
</div>
|
|
461
461
|
`;
|
|
@@ -463,7 +463,7 @@ let f = class extends O {
|
|
|
463
463
|
`;
|
|
464
464
|
}
|
|
465
465
|
};
|
|
466
|
-
f.styles =
|
|
466
|
+
f.styles = M`
|
|
467
467
|
:host { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; width: 100%; }
|
|
468
468
|
.weekday { font-size: 0.75rem; font-weight: 600; color: var(--glatam-text-secondary); text-transform: uppercase; text-align: center; padding: 8px 0; letter-spacing: 0.05em; }
|
|
469
469
|
.day-cell {
|
|
@@ -529,12 +529,12 @@ D([
|
|
|
529
529
|
f = D([
|
|
530
530
|
T("glatam-calendar-month-view")
|
|
531
531
|
], f);
|
|
532
|
-
var
|
|
533
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
534
|
-
(o =
|
|
535
|
-
return i && r &&
|
|
532
|
+
var Y = Object.defineProperty, H = Object.getOwnPropertyDescriptor, R = (t, e, a, i) => {
|
|
533
|
+
for (var r = i > 1 ? void 0 : i ? H(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
534
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
535
|
+
return i && r && Y(e, a, r), r;
|
|
536
536
|
};
|
|
537
|
-
let w = class extends
|
|
537
|
+
let w = class extends E {
|
|
538
538
|
constructor() {
|
|
539
539
|
super(...arguments), this.days = [], this.slots = [], this.locale = "es", this.selectedRange = null, this.role = "provider", this.isDragging = !1, this.dragDayIndex = null, this.dragStartSlotIndex = null, this.dragEndSlotIndex = null, this.handleMouseUp = () => {
|
|
540
540
|
if (!this.isDragging || this.dragDayIndex === null || this.dragStartSlotIndex === null || this.dragEndSlotIndex === null) {
|
|
@@ -542,7 +542,7 @@ let w = class extends O {
|
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
544
|
this.isDragging = !1;
|
|
545
|
-
const
|
|
545
|
+
const t = Math.min(this.dragStartSlotIndex, this.dragEndSlotIndex), e = Math.max(this.dragStartSlotIndex, this.dragEndSlotIndex), a = this.days[this.dragDayIndex], i = a.slots.slice(t, e + 1);
|
|
546
546
|
i.some((r) => r.isBlocked) || this.dispatchEvent(new CustomEvent("range-select", {
|
|
547
547
|
detail: { dateString: a.dateString, start: i[0].start, end: i[i.length - 1].end },
|
|
548
548
|
bubbles: !0,
|
|
@@ -556,63 +556,63 @@ let w = class extends O {
|
|
|
556
556
|
disconnectedCallback() {
|
|
557
557
|
window.removeEventListener("mouseup", this.handleMouseUp), super.disconnectedCallback();
|
|
558
558
|
}
|
|
559
|
-
handleMouseDown(
|
|
559
|
+
handleMouseDown(t, e, a) {
|
|
560
560
|
if (a) {
|
|
561
561
|
if (this.role === "buyer") return;
|
|
562
562
|
this.dispatchEvent(new CustomEvent("slot-click", {
|
|
563
|
-
detail: { dateString: this.days[
|
|
563
|
+
detail: { dateString: this.days[t].dateString, slot: this.days[t].slots[e], isBlocked: !0 },
|
|
564
564
|
bubbles: !0,
|
|
565
565
|
composed: !0
|
|
566
566
|
}));
|
|
567
567
|
return;
|
|
568
568
|
}
|
|
569
|
-
this.isDragging = !0, this.dragDayIndex =
|
|
569
|
+
this.isDragging = !0, this.dragDayIndex = t, this.dragStartSlotIndex = e, this.dragEndSlotIndex = e;
|
|
570
570
|
}
|
|
571
|
-
handleMouseEnter(
|
|
572
|
-
this.isDragging &&
|
|
571
|
+
handleMouseEnter(t, e, a) {
|
|
572
|
+
this.isDragging && t === this.dragDayIndex && !a && (this.dragEndSlotIndex = e);
|
|
573
573
|
}
|
|
574
|
-
isSlotSelected(
|
|
575
|
-
return !this.selectedRange || this.selectedRange.dateString !==
|
|
574
|
+
isSlotSelected(t, e) {
|
|
575
|
+
return !this.selectedRange || this.selectedRange.dateString !== t ? !1 : e.start >= this.selectedRange.start && e.end <= this.selectedRange.end;
|
|
576
576
|
}
|
|
577
|
-
isSlotDragSelecting(
|
|
578
|
-
if (!this.isDragging ||
|
|
577
|
+
isSlotDragSelecting(t, e) {
|
|
578
|
+
if (!this.isDragging || t !== this.dragDayIndex) return !1;
|
|
579
579
|
const a = Math.min(this.dragStartSlotIndex, this.dragEndSlotIndex), i = Math.max(this.dragStartSlotIndex, this.dragEndSlotIndex);
|
|
580
|
-
return
|
|
580
|
+
return e >= a && e <= i;
|
|
581
581
|
}
|
|
582
582
|
render() {
|
|
583
|
-
const
|
|
583
|
+
const t = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
584
584
|
return d`
|
|
585
585
|
<div class="time-col">
|
|
586
586
|
<div class="header-cell">Hora</div>
|
|
587
|
-
${this.slots.map((
|
|
587
|
+
${this.slots.map((e) => d`<div class="slot-cell time-slot-label">${e.start}</div>`)}
|
|
588
588
|
</div>
|
|
589
589
|
|
|
590
|
-
${this.days.map((
|
|
591
|
-
const i =
|
|
590
|
+
${this.days.map((e, a) => {
|
|
591
|
+
const i = e.dateString === t, r = new Intl.DateTimeFormat(this.locale, { weekday: "short" }).format(e.date);
|
|
592
592
|
return d`
|
|
593
593
|
<div class="day-col">
|
|
594
594
|
<div class="header-cell ${i ? "today" : ""}">
|
|
595
595
|
<div>${r}</div>
|
|
596
|
-
<div class="day-num">${
|
|
596
|
+
<div class="day-num">${e.dayNumber}</div>
|
|
597
597
|
</div>
|
|
598
598
|
|
|
599
|
-
${
|
|
600
|
-
var m,
|
|
601
|
-
const
|
|
599
|
+
${e.slots.map((l, o) => {
|
|
600
|
+
var m, v;
|
|
601
|
+
const h = l.isBlocked, n = this.isSlotSelected(e.dateString, l), c = this.isSlotDragSelecting(a, o);
|
|
602
602
|
return d`
|
|
603
603
|
<div
|
|
604
604
|
class=${N({
|
|
605
605
|
"slot-cell": !0,
|
|
606
|
-
available: !
|
|
607
|
-
blocked:
|
|
606
|
+
available: !h,
|
|
607
|
+
blocked: h,
|
|
608
608
|
selected: n,
|
|
609
609
|
"drag-selecting": c
|
|
610
610
|
})}
|
|
611
|
-
@mousedown=${() => this.handleMouseDown(a, o,
|
|
612
|
-
@mouseenter=${() => this.handleMouseEnter(a, o,
|
|
613
|
-
title=${
|
|
611
|
+
@mousedown=${() => this.handleMouseDown(a, o, h)}
|
|
612
|
+
@mouseenter=${() => this.handleMouseEnter(a, o, h)}
|
|
613
|
+
title=${h && ((m = l.rule) != null && m.description) ? l.rule.description : ""}
|
|
614
614
|
>
|
|
615
|
-
${
|
|
615
|
+
${h ? ((v = l.rule) == null ? void 0 : v.description) || "Ocupado" : n ? "Reservado" : ""}
|
|
616
616
|
</div>
|
|
617
617
|
`;
|
|
618
618
|
})}
|
|
@@ -622,7 +622,7 @@ let w = class extends O {
|
|
|
622
622
|
`;
|
|
623
623
|
}
|
|
624
624
|
};
|
|
625
|
-
w.styles =
|
|
625
|
+
w.styles = M`
|
|
626
626
|
:host {
|
|
627
627
|
display: grid; grid-template-columns: var(--glatam-time-col-width) repeat(7, 1fr); gap: 2px;
|
|
628
628
|
width: 100%; background-color: var(--glatam-border); border: 1px solid var(--glatam-border);
|
|
@@ -705,12 +705,12 @@ R([
|
|
|
705
705
|
w = R([
|
|
706
706
|
T("glatam-calendar-week-view")
|
|
707
707
|
], w);
|
|
708
|
-
var
|
|
709
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
710
|
-
(o =
|
|
711
|
-
return i && r &&
|
|
708
|
+
var q = Object.defineProperty, G = Object.getOwnPropertyDescriptor, z = (t, e, a, i) => {
|
|
709
|
+
for (var r = i > 1 ? void 0 : i ? G(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
710
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
711
|
+
return i && r && q(e, a, r), r;
|
|
712
712
|
};
|
|
713
|
-
let S = class extends
|
|
713
|
+
let S = class extends E {
|
|
714
714
|
constructor() {
|
|
715
715
|
super(...arguments), this.day = null, this.slots = [], this.locale = "es", this.selectedRange = null, this.role = "provider", this.isDragging = !1, this.dragStartSlotIndex = null, this.dragEndSlotIndex = null, this.handleMouseUp = () => {
|
|
716
716
|
if (!this.isDragging || !this.day || this.dragStartSlotIndex === null || this.dragEndSlotIndex === null) {
|
|
@@ -718,7 +718,7 @@ let S = class extends O {
|
|
|
718
718
|
return;
|
|
719
719
|
}
|
|
720
720
|
this.isDragging = !1;
|
|
721
|
-
const
|
|
721
|
+
const t = Math.min(this.dragStartSlotIndex, this.dragEndSlotIndex), e = Math.max(this.dragStartSlotIndex, this.dragEndSlotIndex), a = this.day.slots.slice(t, e + 1);
|
|
722
722
|
a.some((i) => i.isBlocked) || this.dispatchEvent(new CustomEvent("range-select", {
|
|
723
723
|
detail: { dateString: this.day.dateString, start: a[0].start, end: a[a.length - 1].end },
|
|
724
724
|
bubbles: !0,
|
|
@@ -732,32 +732,32 @@ let S = class extends O {
|
|
|
732
732
|
disconnectedCallback() {
|
|
733
733
|
window.removeEventListener("mouseup", this.handleMouseUp), super.disconnectedCallback();
|
|
734
734
|
}
|
|
735
|
-
handleMouseDown(
|
|
736
|
-
if (
|
|
735
|
+
handleMouseDown(t, e) {
|
|
736
|
+
if (e && this.day) {
|
|
737
737
|
if (this.role === "buyer") return;
|
|
738
738
|
this.dispatchEvent(new CustomEvent("slot-click", {
|
|
739
|
-
detail: { dateString: this.day.dateString, slot: this.day.slots[
|
|
739
|
+
detail: { dateString: this.day.dateString, slot: this.day.slots[t], isBlocked: !0 },
|
|
740
740
|
bubbles: !0,
|
|
741
741
|
composed: !0
|
|
742
742
|
}));
|
|
743
743
|
return;
|
|
744
744
|
}
|
|
745
|
-
this.isDragging = !0, this.dragStartSlotIndex =
|
|
745
|
+
this.isDragging = !0, this.dragStartSlotIndex = t, this.dragEndSlotIndex = t;
|
|
746
746
|
}
|
|
747
|
-
handleMouseEnter(
|
|
748
|
-
this.isDragging && !
|
|
747
|
+
handleMouseEnter(t, e) {
|
|
748
|
+
this.isDragging && !e && (this.dragEndSlotIndex = t);
|
|
749
749
|
}
|
|
750
|
-
isSlotSelected(
|
|
751
|
-
return !this.day || !this.selectedRange || this.selectedRange.dateString !== this.day.dateString ? !1 :
|
|
750
|
+
isSlotSelected(t) {
|
|
751
|
+
return !this.day || !this.selectedRange || this.selectedRange.dateString !== this.day.dateString ? !1 : t.start >= this.selectedRange.start && t.end <= this.selectedRange.end;
|
|
752
752
|
}
|
|
753
|
-
isSlotDragSelecting(
|
|
753
|
+
isSlotDragSelecting(t) {
|
|
754
754
|
if (!this.isDragging) return !1;
|
|
755
|
-
const
|
|
756
|
-
return
|
|
755
|
+
const e = Math.min(this.dragStartSlotIndex, this.dragEndSlotIndex), a = Math.max(this.dragStartSlotIndex, this.dragEndSlotIndex);
|
|
756
|
+
return t >= e && t <= a;
|
|
757
757
|
}
|
|
758
758
|
render() {
|
|
759
759
|
if (!this.day) return d`<div>Cargando...</div>`;
|
|
760
|
-
const
|
|
760
|
+
const t = this.day.dateString === (/* @__PURE__ */ new Date()).toISOString().split("T")[0], e = new Intl.DateTimeFormat(this.locale, { weekday: "long", day: "numeric", month: "long" }).format(this.day.date);
|
|
761
761
|
return d`
|
|
762
762
|
<div class="time-col">
|
|
763
763
|
<div class="header-cell">Hora</div>
|
|
@@ -765,12 +765,12 @@ let S = class extends O {
|
|
|
765
765
|
</div>
|
|
766
766
|
|
|
767
767
|
<div class="day-col">
|
|
768
|
-
<div class="header-cell ${
|
|
769
|
-
<div style="text-transform: capitalize;">${
|
|
768
|
+
<div class="header-cell ${t ? "today" : ""}">
|
|
769
|
+
<div style="text-transform: capitalize;">${e}</div>
|
|
770
770
|
</div>
|
|
771
771
|
|
|
772
772
|
${this.day.slots.map((a, i) => {
|
|
773
|
-
var
|
|
773
|
+
var h, n;
|
|
774
774
|
const r = a.isBlocked, l = this.isSlotSelected(a), o = this.isSlotDragSelecting(i);
|
|
775
775
|
return d`
|
|
776
776
|
<div
|
|
@@ -783,7 +783,7 @@ let S = class extends O {
|
|
|
783
783
|
})}
|
|
784
784
|
@mousedown=${() => this.handleMouseDown(i, r)}
|
|
785
785
|
@mouseenter=${() => this.handleMouseEnter(i, r)}
|
|
786
|
-
title=${r && ((
|
|
786
|
+
title=${r && ((h = a.rule) != null && h.description) ? a.rule.description : ""}
|
|
787
787
|
>
|
|
788
788
|
${r ? ((n = a.rule) == null ? void 0 : n.description) || "Ocupado" : l ? "Reservado" : ""}
|
|
789
789
|
</div>
|
|
@@ -793,7 +793,7 @@ let S = class extends O {
|
|
|
793
793
|
`;
|
|
794
794
|
}
|
|
795
795
|
};
|
|
796
|
-
S.styles =
|
|
796
|
+
S.styles = M`
|
|
797
797
|
:host {
|
|
798
798
|
display: grid; grid-template-columns: var(--glatam-time-col-width) 1fr; gap: 2px;
|
|
799
799
|
width: 100%; background-color: var(--glatam-border); border: 1px solid var(--glatam-border);
|
|
@@ -850,7 +850,7 @@ z([
|
|
|
850
850
|
S = z([
|
|
851
851
|
T("glatam-calendar-day-view")
|
|
852
852
|
], S);
|
|
853
|
-
const
|
|
853
|
+
const V = M`
|
|
854
854
|
dialog {
|
|
855
855
|
background: transparent;
|
|
856
856
|
border: none;
|
|
@@ -1006,34 +1006,34 @@ const Y = E`
|
|
|
1006
1006
|
background: rgba(255, 69, 58, 0.18);
|
|
1007
1007
|
}
|
|
1008
1008
|
`;
|
|
1009
|
-
var
|
|
1010
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
1011
|
-
(o =
|
|
1012
|
-
return i && r &&
|
|
1009
|
+
var X = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, k = (t, e, a, i) => {
|
|
1010
|
+
for (var r = i > 1 ? void 0 : i ? Z(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
1011
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
1012
|
+
return i && r && X(e, a, r), r;
|
|
1013
1013
|
};
|
|
1014
|
-
let x = class extends
|
|
1014
|
+
let x = class extends E {
|
|
1015
1015
|
constructor() {
|
|
1016
1016
|
super(...arguments), this.open = !1, this.dateString = "", this.startTime = "", this.endTime = "", this.isRange = !1, this.existingRule = null, this.description = "", this.blockAllDay = !0, this.isRecurring = !1, this.selectedDays = [];
|
|
1017
1017
|
}
|
|
1018
|
-
willUpdate(
|
|
1019
|
-
|
|
1018
|
+
willUpdate(t) {
|
|
1019
|
+
t.has("open") && this.open && (this.existingRule ? (this.description = "Bloqueo", this.blockAllDay = !this.existingRule.slots || this.existingRule.slots.length === 0, this.isRecurring = this.existingRule.type === "weekly", this.selectedDays = this.existingRule.daysOfWeek || []) : (this.description = "", this.blockAllDay = !this.isRange, this.isRecurring = !1, this.selectedDays = [(/* @__PURE__ */ new Date(this.dateString + "T00:00:00")).getDay()]));
|
|
1020
1020
|
}
|
|
1021
|
-
updated(
|
|
1022
|
-
var
|
|
1023
|
-
if (
|
|
1024
|
-
const a = (
|
|
1021
|
+
updated(t) {
|
|
1022
|
+
var e;
|
|
1023
|
+
if (t.has("open")) {
|
|
1024
|
+
const a = (e = this.shadowRoot) == null ? void 0 : e.getElementById("booking-dialog");
|
|
1025
1025
|
a && (this.open ? a.open || a.showModal() : a.open && a.close());
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
handleDialogClose() {
|
|
1029
1029
|
this.open && this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
|
|
1030
1030
|
}
|
|
1031
|
-
toggleDay(
|
|
1032
|
-
const
|
|
1033
|
-
this.selectedDays =
|
|
1031
|
+
toggleDay(t) {
|
|
1032
|
+
const e = this.selectedDays.indexOf(t);
|
|
1033
|
+
this.selectedDays = e > -1 ? this.selectedDays.filter((a) => a !== t) : [...this.selectedDays, t];
|
|
1034
1034
|
}
|
|
1035
1035
|
handleSave() {
|
|
1036
|
-
const
|
|
1036
|
+
const t = {
|
|
1037
1037
|
title: this.description || "Bloqueo",
|
|
1038
1038
|
blockAllDay: this.blockAllDay,
|
|
1039
1039
|
isRecurring: this.isRecurring,
|
|
@@ -1042,7 +1042,7 @@ let x = class extends O {
|
|
|
1042
1042
|
startTime: this.startTime,
|
|
1043
1043
|
endTime: this.endTime
|
|
1044
1044
|
};
|
|
1045
|
-
this.dispatchEvent(new CustomEvent("save-rule", { detail:
|
|
1045
|
+
this.dispatchEvent(new CustomEvent("save-rule", { detail: t, bubbles: !0, composed: !0 }));
|
|
1046
1046
|
}
|
|
1047
1047
|
handleDelete() {
|
|
1048
1048
|
this.existingRule && this.dispatchEvent(new CustomEvent("delete-rule", {
|
|
@@ -1052,14 +1052,14 @@ let x = class extends O {
|
|
|
1052
1052
|
}));
|
|
1053
1053
|
}
|
|
1054
1054
|
render() {
|
|
1055
|
-
const
|
|
1055
|
+
const t = ["D", "L", "M", "M", "J", "V", "S"], e = this.isRange ? `${this.dateString} (${this.startTime} - ${this.endTime})` : this.dateString;
|
|
1056
1056
|
return d`
|
|
1057
1057
|
<dialog id="booking-dialog" @close=${this.handleDialogClose}>
|
|
1058
1058
|
<div class="modal-content">
|
|
1059
1059
|
<h3>${this.existingRule ? "Gestionar Bloqueo" : "Crear Bloqueo"}</h3>
|
|
1060
1060
|
|
|
1061
1061
|
<div style="font-size: 0.85rem; color: var(--glatam-text-secondary);">
|
|
1062
|
-
Selección: <strong>${
|
|
1062
|
+
Selección: <strong>${e}</strong>
|
|
1063
1063
|
</div>
|
|
1064
1064
|
|
|
1065
1065
|
<div class="form-group">
|
|
@@ -1105,7 +1105,7 @@ let x = class extends O {
|
|
|
1105
1105
|
class="day-btn ${this.selectedDays.includes(a) ? "selected" : ""}"
|
|
1106
1106
|
@click=${() => this.toggleDay(a)}
|
|
1107
1107
|
>
|
|
1108
|
-
${
|
|
1108
|
+
${t[a]}
|
|
1109
1109
|
</button>
|
|
1110
1110
|
`)}
|
|
1111
1111
|
</div>
|
|
@@ -1122,7 +1122,7 @@ let x = class extends O {
|
|
|
1122
1122
|
`;
|
|
1123
1123
|
}
|
|
1124
1124
|
};
|
|
1125
|
-
x.styles =
|
|
1125
|
+
x.styles = V;
|
|
1126
1126
|
k([
|
|
1127
1127
|
s({ type: Boolean })
|
|
1128
1128
|
], x.prototype, "open", 2);
|
|
@@ -1156,10 +1156,10 @@ k([
|
|
|
1156
1156
|
x = k([
|
|
1157
1157
|
T("glatam-calendar-modal")
|
|
1158
1158
|
], x);
|
|
1159
|
-
var
|
|
1160
|
-
for (var r = i > 1 ? void 0 : i ? K(
|
|
1161
|
-
(o =
|
|
1162
|
-
return i && r &&
|
|
1159
|
+
var J = Object.defineProperty, K = Object.getOwnPropertyDescriptor, p = (t, e, a, i) => {
|
|
1160
|
+
for (var r = i > 1 ? void 0 : i ? K(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
1161
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
1162
|
+
return i && r && J(e, a, r), r;
|
|
1163
1163
|
};
|
|
1164
1164
|
const Q = [
|
|
1165
1165
|
{ start: "09:00", end: "10:00" },
|
|
@@ -1172,91 +1172,91 @@ const Q = [
|
|
|
1172
1172
|
{ start: "16:00", end: "17:00" },
|
|
1173
1173
|
{ start: "17:00", end: "18:00" }
|
|
1174
1174
|
];
|
|
1175
|
-
let g = class extends
|
|
1175
|
+
let g = class extends E {
|
|
1176
1176
|
constructor() {
|
|
1177
1177
|
super(...arguments), this.role = "provider", this.size = "medium", this.view = "month", this.locale = "es", this.startOfWeekDay = 0, this.rules = [], this.selectedDates = [], this.selectedRange = null, this.hostTimezone = "America/Bogota", this.activeTimezone = "local", this.slots = Q, this.minDate = "", this.maxDate = "", this.showNeighboringMonth = !0, this.tileClassName = null, this.activeDate = /* @__PURE__ */ new Date(), this.localRules = [], this.darkMode = !1, this.modalOpen = !1, this.modalDateString = "", this.modalStartTime = "", this.modalEndTime = "", this.modalIsRange = !1, this.modalExistingRule = null;
|
|
1178
1178
|
}
|
|
1179
1179
|
firstUpdated() {
|
|
1180
1180
|
this.darkMode = window.matchMedia("(prefers-color-scheme: dark)").matches, this.localRules = [...this.rules];
|
|
1181
1181
|
}
|
|
1182
|
-
willUpdate(
|
|
1183
|
-
|
|
1182
|
+
willUpdate(t) {
|
|
1183
|
+
t.has("rules") && (this.localRules = [...this.rules || []]);
|
|
1184
1184
|
}
|
|
1185
|
-
updated(
|
|
1186
|
-
|
|
1185
|
+
updated(t) {
|
|
1186
|
+
t.has("darkMode") && this.classList.toggle("dark-mode", this.darkMode);
|
|
1187
1187
|
}
|
|
1188
1188
|
handlePrev() {
|
|
1189
|
-
const
|
|
1190
|
-
this.view === "month" ?
|
|
1189
|
+
const t = new Date(this.activeDate);
|
|
1190
|
+
this.view === "month" ? t.setMonth(t.getMonth() - 1) : this.view === "week" ? t.setDate(t.getDate() - 7) : t.setDate(t.getDate() - 1), this.activeDate = t;
|
|
1191
1191
|
}
|
|
1192
1192
|
handleNext() {
|
|
1193
|
-
const
|
|
1194
|
-
this.view === "month" ?
|
|
1193
|
+
const t = new Date(this.activeDate);
|
|
1194
|
+
this.view === "month" ? t.setMonth(t.getMonth() + 1) : this.view === "week" ? t.setDate(t.getDate() + 7) : t.setDate(t.getDate() + 1), this.activeDate = t;
|
|
1195
1195
|
}
|
|
1196
1196
|
getHeaderTitle() {
|
|
1197
|
-
const
|
|
1198
|
-
return new Intl.DateTimeFormat(this.locale,
|
|
1199
|
-
}
|
|
1200
|
-
handleDaySelect(
|
|
1201
|
-
const { dateString:
|
|
1202
|
-
this.role === "buyer" && a || (this.activeDate = /* @__PURE__ */ new Date(
|
|
1203
|
-
}
|
|
1204
|
-
handleRangeSelect(
|
|
1205
|
-
var $,
|
|
1206
|
-
const { dateString:
|
|
1207
|
-
if (this.role === "buyer" && o &&
|
|
1208
|
-
const
|
|
1197
|
+
const t = this.view === "month" ? { month: "long", year: "numeric" } : this.view === "week" ? { month: "short", year: "numeric" } : { day: "numeric", month: "long", year: "numeric" };
|
|
1198
|
+
return new Intl.DateTimeFormat(this.locale, t).format(this.activeDate);
|
|
1199
|
+
}
|
|
1200
|
+
handleDaySelect(t) {
|
|
1201
|
+
const { dateString: e, isBlocked: a } = t.detail;
|
|
1202
|
+
this.role === "buyer" && a || (this.activeDate = /* @__PURE__ */ new Date(e + "T00:00:00"), this.view = "day", this.dispatchEvent(new CustomEvent("date-selected", { detail: { dateString: e }, bubbles: !0, composed: !0 })));
|
|
1203
|
+
}
|
|
1204
|
+
handleRangeSelect(t) {
|
|
1205
|
+
var $, O;
|
|
1206
|
+
const { dateString: e, start: a, end: i } = t.detail, r = this.activeTimezone === "local" ? I(this.activeDate, this.hostTimezone, "local") : 0, l = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], o = this.minDate || (this.role === "buyer" ? l : "");
|
|
1207
|
+
if (this.role === "buyer" && o && e < o) return;
|
|
1208
|
+
const h = this.getDisplaySlots(r), n = h.findIndex((B) => B.start === a), c = h.findIndex((B) => B.end === i), m = (($ = this.slots[n]) == null ? void 0 : $.start) || a, v = ((O = this.slots[c]) == null ? void 0 : O.end) || i;
|
|
1209
1209
|
if (this.role === "buyer") {
|
|
1210
|
-
this.selectedRange = { dateString:
|
|
1210
|
+
this.selectedRange = { dateString: e, start: a, end: i }, this.dispatchEvent(new CustomEvent("booking-selected", { detail: { dateString: e, start: a, end: i, hostStart: m, hostEnd: v }, bubbles: !0, composed: !0 }));
|
|
1211
1211
|
return;
|
|
1212
1212
|
}
|
|
1213
|
-
this.openModal(
|
|
1213
|
+
this.openModal(e, m, v, !0, null);
|
|
1214
1214
|
}
|
|
1215
|
-
handleSlotClick(
|
|
1216
|
-
const { dateString:
|
|
1217
|
-
if (this.role === "buyer" && (a.isBlocked || o &&
|
|
1218
|
-
const
|
|
1215
|
+
handleSlotClick(t) {
|
|
1216
|
+
const { dateString: e, slot: a } = t.detail, i = /* @__PURE__ */ new Date(e + "T00:00:00"), r = this.activeTimezone === "local" ? I(this.activeDate, this.hostTimezone, "local") : 0, l = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], o = this.minDate || (this.role === "buyer" ? l : "");
|
|
1217
|
+
if (this.role === "buyer" && (a.isBlocked || o && e < o)) return;
|
|
1218
|
+
const h = this.getDisplaySlots(r), n = h.findIndex((v) => v.start === a.start), c = this.slots[n] || a;
|
|
1219
1219
|
if (this.role === "buyer") {
|
|
1220
|
-
this.selectedRange = { dateString:
|
|
1220
|
+
this.selectedRange = { dateString: e, start: a.start, end: a.end }, this.dispatchEvent(new CustomEvent("booking-selected", { detail: { dateString: e, start: a.start, end: a.end, hostStart: c.start, hostEnd: c.end }, bubbles: !0, composed: !0 }));
|
|
1221
1221
|
return;
|
|
1222
1222
|
}
|
|
1223
|
-
const m = this.localRules.find((
|
|
1224
|
-
this.openModal(
|
|
1223
|
+
const m = this.localRules.find((v) => C(i, c, [v]));
|
|
1224
|
+
this.openModal(e, c.start, c.end, !0, m || null);
|
|
1225
1225
|
}
|
|
1226
1226
|
handleBlockDayAction() {
|
|
1227
|
-
const
|
|
1228
|
-
this.openModal(
|
|
1227
|
+
const t = _(this.activeDate), e = this.localRules.find((a) => C(this.activeDate, void 0, [a]));
|
|
1228
|
+
this.openModal(t, "", "", !1, e || null);
|
|
1229
1229
|
}
|
|
1230
|
-
openModal(
|
|
1231
|
-
this.modalDateString =
|
|
1230
|
+
openModal(t, e, a, i, r) {
|
|
1231
|
+
this.modalDateString = t, this.modalStartTime = e, this.modalEndTime = a, this.modalIsRange = i, this.modalExistingRule = r, this.modalOpen = !0;
|
|
1232
1232
|
}
|
|
1233
|
-
handleSaveRule(
|
|
1234
|
-
const
|
|
1233
|
+
handleSaveRule(t) {
|
|
1234
|
+
const e = t.detail, a = this.modalExistingRule ? this.modalExistingRule.id : `rule-${Date.now()}`, i = {
|
|
1235
1235
|
id: a,
|
|
1236
|
-
type:
|
|
1237
|
-
slots:
|
|
1238
|
-
daysOfWeek:
|
|
1239
|
-
startDate:
|
|
1240
|
-
endDate:
|
|
1241
|
-
description:
|
|
1236
|
+
type: e.isRecurring ? "weekly" : "date-range",
|
|
1237
|
+
slots: e.blockAllDay ? void 0 : [{ start: e.startTime, end: e.endTime }],
|
|
1238
|
+
daysOfWeek: e.isRecurring ? e.selectedDays : void 0,
|
|
1239
|
+
startDate: e.isRecurring ? void 0 : e.dateString,
|
|
1240
|
+
endDate: e.isRecurring ? void 0 : e.dateString,
|
|
1241
|
+
description: e.title
|
|
1242
1242
|
};
|
|
1243
1243
|
this.localRules = this.modalExistingRule ? this.localRules.map((r) => r.id === a ? i : r) : [...this.localRules, i], this.modalOpen = !1, this.dispatchEvent(new CustomEvent("rules-changed", { detail: { rules: this.localRules }, bubbles: !0, composed: !0 }));
|
|
1244
1244
|
}
|
|
1245
|
-
handleDeleteRule(
|
|
1246
|
-
this.localRules = this.localRules.filter((
|
|
1245
|
+
handleDeleteRule(t) {
|
|
1246
|
+
this.localRules = this.localRules.filter((e) => e.id !== t.detail.id), this.modalOpen = !1, this.dispatchEvent(new CustomEvent("rules-changed", { detail: { rules: this.localRules }, bubbles: !0, composed: !0 }));
|
|
1247
1247
|
}
|
|
1248
|
-
getDisplaySlots(
|
|
1249
|
-
return
|
|
1250
|
-
const a = U(
|
|
1248
|
+
getDisplaySlots(t) {
|
|
1249
|
+
return t === 0 ? this.slots : this.slots.map((e) => {
|
|
1250
|
+
const a = U(e, t), i = a.dayShift > 0 ? " (+1d)" : a.dayShift < 0 ? " (-1d)" : "";
|
|
1251
1251
|
return { start: a.start + i, end: a.end + i };
|
|
1252
1252
|
});
|
|
1253
1253
|
}
|
|
1254
1254
|
render() {
|
|
1255
|
-
var
|
|
1256
|
-
const
|
|
1257
|
-
var $,
|
|
1258
|
-
return { ...m, start: (($ = r[
|
|
1259
|
-
}) })), o = ((
|
|
1255
|
+
var h;
|
|
1256
|
+
const t = this.activeDate.getFullYear(), e = this.activeDate.getMonth(), a = C(this.activeDate, void 0, this.localRules), i = this.activeTimezone === "local" ? I(this.activeDate, this.hostTimezone, "local") : 0, r = this.getDisplaySlots(i), l = (n) => n.map((c) => ({ ...c, slots: c.slots.map((m, v) => {
|
|
1257
|
+
var $, O;
|
|
1258
|
+
return { ...m, start: (($ = r[v]) == null ? void 0 : $.start) || m.start, end: ((O = r[v]) == null ? void 0 : O.end) || m.end };
|
|
1259
|
+
}) })), o = ((h = this.hostTimezone.split("/").pop()) == null ? void 0 : h.replace("_", " ")) || "Anfitrión";
|
|
1260
1260
|
return d`
|
|
1261
1261
|
<div class="calendar-header">
|
|
1262
1262
|
<div class="nav-group">
|
|
@@ -1287,7 +1287,7 @@ let g = class extends O {
|
|
|
1287
1287
|
</div>
|
|
1288
1288
|
|
|
1289
1289
|
<div class="calendar-body">
|
|
1290
|
-
${this.view === "month" ? d`<glatam-calendar-month-view .days=${
|
|
1290
|
+
${this.view === "month" ? d`<glatam-calendar-month-view .days=${P(t, e, this.localRules, this.slots, this.startOfWeekDay)} .locale=${this.locale} .startOfWeekDay=${this.startOfWeekDay} .role=${this.role} .size=${this.size} .minDate=${this.minDate || (this.role === "buyer" ? (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : "")} .maxDate=${this.maxDate} .showNeighboringMonth=${this.showNeighboringMonth} .tileClassName=${this.tileClassName} @day-select=${this.handleDaySelect}></glatam-calendar-month-view>` : this.view === "week" ? d`<glatam-calendar-week-view .days=${l(j(this.activeDate, this.localRules, this.slots, this.startOfWeekDay))} .slots=${r} .locale=${this.locale} .selectedRange=${this.selectedRange} .role=${this.role} @range-select=${this.handleRangeSelect} @slot-click=${this.handleSlotClick}></glatam-calendar-week-view>` : d`<glatam-calendar-day-view .day=${l(j(this.activeDate, this.localRules, this.slots, this.startOfWeekDay)).find((n) => n.dateString === _(this.activeDate)) || null} .slots=${r} .locale=${this.locale} .selectedRange=${this.selectedRange} .role=${this.role} @range-select=${this.handleRangeSelect} @slot-click=${this.handleSlotClick}></glatam-calendar-day-view>`}
|
|
1291
1291
|
</div>
|
|
1292
1292
|
|
|
1293
1293
|
<glatam-calendar-modal
|
|
@@ -1298,88 +1298,88 @@ let g = class extends O {
|
|
|
1298
1298
|
`;
|
|
1299
1299
|
}
|
|
1300
1300
|
};
|
|
1301
|
-
g.styles = [
|
|
1302
|
-
|
|
1301
|
+
g.styles = [A, W];
|
|
1302
|
+
p([
|
|
1303
1303
|
s({ type: String })
|
|
1304
1304
|
], g.prototype, "role", 2);
|
|
1305
|
-
|
|
1305
|
+
p([
|
|
1306
1306
|
s({ type: String, reflect: !0 })
|
|
1307
1307
|
], g.prototype, "size", 2);
|
|
1308
|
-
|
|
1308
|
+
p([
|
|
1309
1309
|
s({ type: String })
|
|
1310
1310
|
], g.prototype, "view", 2);
|
|
1311
|
-
|
|
1311
|
+
p([
|
|
1312
1312
|
s({ type: String })
|
|
1313
1313
|
], g.prototype, "locale", 2);
|
|
1314
|
-
|
|
1314
|
+
p([
|
|
1315
1315
|
s({ type: Number })
|
|
1316
1316
|
], g.prototype, "startOfWeekDay", 2);
|
|
1317
|
-
|
|
1317
|
+
p([
|
|
1318
1318
|
s({ type: Array })
|
|
1319
1319
|
], g.prototype, "rules", 2);
|
|
1320
|
-
|
|
1320
|
+
p([
|
|
1321
1321
|
s({ type: Array })
|
|
1322
1322
|
], g.prototype, "selectedDates", 2);
|
|
1323
|
-
|
|
1323
|
+
p([
|
|
1324
1324
|
s({ type: Object })
|
|
1325
1325
|
], g.prototype, "selectedRange", 2);
|
|
1326
|
-
|
|
1326
|
+
p([
|
|
1327
1327
|
s({ type: String })
|
|
1328
1328
|
], g.prototype, "hostTimezone", 2);
|
|
1329
|
-
|
|
1329
|
+
p([
|
|
1330
1330
|
s({ type: String })
|
|
1331
1331
|
], g.prototype, "activeTimezone", 2);
|
|
1332
|
-
|
|
1332
|
+
p([
|
|
1333
1333
|
s({ type: Array })
|
|
1334
1334
|
], g.prototype, "slots", 2);
|
|
1335
|
-
|
|
1335
|
+
p([
|
|
1336
1336
|
s({ type: String })
|
|
1337
1337
|
], g.prototype, "minDate", 2);
|
|
1338
|
-
|
|
1338
|
+
p([
|
|
1339
1339
|
s({ type: String })
|
|
1340
1340
|
], g.prototype, "maxDate", 2);
|
|
1341
|
-
|
|
1341
|
+
p([
|
|
1342
1342
|
s({ type: Boolean })
|
|
1343
1343
|
], g.prototype, "showNeighboringMonth", 2);
|
|
1344
|
-
|
|
1344
|
+
p([
|
|
1345
1345
|
s({ attribute: !1 })
|
|
1346
1346
|
], g.prototype, "tileClassName", 2);
|
|
1347
|
-
|
|
1347
|
+
p([
|
|
1348
1348
|
u()
|
|
1349
1349
|
], g.prototype, "activeDate", 2);
|
|
1350
|
-
|
|
1350
|
+
p([
|
|
1351
1351
|
u()
|
|
1352
1352
|
], g.prototype, "localRules", 2);
|
|
1353
|
-
|
|
1353
|
+
p([
|
|
1354
1354
|
u()
|
|
1355
1355
|
], g.prototype, "darkMode", 2);
|
|
1356
|
-
|
|
1356
|
+
p([
|
|
1357
1357
|
u()
|
|
1358
1358
|
], g.prototype, "modalOpen", 2);
|
|
1359
|
-
|
|
1359
|
+
p([
|
|
1360
1360
|
u()
|
|
1361
1361
|
], g.prototype, "modalDateString", 2);
|
|
1362
|
-
|
|
1362
|
+
p([
|
|
1363
1363
|
u()
|
|
1364
1364
|
], g.prototype, "modalStartTime", 2);
|
|
1365
|
-
|
|
1365
|
+
p([
|
|
1366
1366
|
u()
|
|
1367
1367
|
], g.prototype, "modalEndTime", 2);
|
|
1368
|
-
|
|
1368
|
+
p([
|
|
1369
1369
|
u()
|
|
1370
1370
|
], g.prototype, "modalIsRange", 2);
|
|
1371
|
-
|
|
1371
|
+
p([
|
|
1372
1372
|
u()
|
|
1373
1373
|
], g.prototype, "modalExistingRule", 2);
|
|
1374
|
-
g =
|
|
1374
|
+
g = p([
|
|
1375
1375
|
T("glatam-calendar")
|
|
1376
1376
|
], g);
|
|
1377
|
-
var tt = Object.defineProperty, et = Object.getOwnPropertyDescriptor,
|
|
1378
|
-
for (var r = i > 1 ? void 0 : i ? et(
|
|
1379
|
-
(o =
|
|
1380
|
-
return i && r && tt(
|
|
1377
|
+
var tt = Object.defineProperty, et = Object.getOwnPropertyDescriptor, y = (t, e, a, i) => {
|
|
1378
|
+
for (var r = i > 1 ? void 0 : i ? et(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
1379
|
+
(o = t[l]) && (r = (i ? o(e, a, r) : o(r)) || r);
|
|
1380
|
+
return i && r && tt(e, a, r), r;
|
|
1381
1381
|
};
|
|
1382
|
-
let b = class extends
|
|
1382
|
+
let b = class extends E {
|
|
1383
1383
|
constructor() {
|
|
1384
1384
|
super(...arguments), this.role = "buyer", this.locale = "es", this.startOfWeekDay = 0, this.rules = [], this.selectedRange = null, this.size = "medium", this.hostTimezone = "America/Bogota", this.activeTimezone = "local", this.minDate = "", this.maxDate = "", this.showNeighboringMonth = !0, this.tileClassName = null, this.slots = [
|
|
1385
1385
|
{ start: "09:00", end: "10:00" },
|
|
@@ -1391,35 +1391,58 @@ let b = class extends O {
|
|
|
1391
1391
|
{ start: "15:00", end: "16:00" },
|
|
1392
1392
|
{ start: "16:00", end: "17:00" },
|
|
1393
1393
|
{ start: "17:00", end: "18:00" }
|
|
1394
|
-
], this.activeDate = /* @__PURE__ */ new Date(), this.dropdownOpen = !1, this.dropdownSelectedDateString = "";
|
|
1394
|
+
], this.activeDate = /* @__PURE__ */ new Date(), this.dropdownOpen = !1, this.dropdownSelectedDateString = "", this.touchStartX = 0, this.touchStartY = 0;
|
|
1395
1395
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1396
|
+
handlePrevMonth(t) {
|
|
1397
|
+
t.stopPropagation();
|
|
1398
|
+
const e = new Date(this.activeDate);
|
|
1399
|
+
e.setMonth(e.getMonth() - 1), this.activeDate = e;
|
|
1398
1400
|
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
+
handleNextMonth(t) {
|
|
1402
|
+
t.stopPropagation();
|
|
1403
|
+
const e = new Date(this.activeDate);
|
|
1404
|
+
e.setMonth(e.getMonth() + 1), this.activeDate = e;
|
|
1405
|
+
}
|
|
1406
|
+
handleTouchStart(t) {
|
|
1407
|
+
t.touches && t.touches.length > 0 && (this.touchStartX = t.touches[0].clientX, this.touchStartY = t.touches[0].clientY);
|
|
1408
|
+
}
|
|
1409
|
+
handleTouchEnd(t) {
|
|
1410
|
+
if (t.changedTouches && t.changedTouches.length > 0) {
|
|
1411
|
+
const e = t.changedTouches[0].clientX, a = t.changedTouches[0].clientY, i = this.touchStartX - e, r = this.touchStartY - a;
|
|
1412
|
+
Math.abs(i) > 50 && Math.abs(i) > Math.abs(r) && (i > 0 ? this.handleNextMonth(t) : this.handlePrevMonth(t));
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
getFormattedMonthTitle() {
|
|
1416
|
+
const t = this.activeDate.toLocaleDateString(this.locale || "es", { month: "long", year: "numeric" });
|
|
1417
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
1418
|
+
}
|
|
1419
|
+
handleDropdownDaySelect(t) {
|
|
1420
|
+
this.dropdownSelectedDateString = t.detail.dateString;
|
|
1421
|
+
}
|
|
1422
|
+
selectDropdownSlot(t) {
|
|
1423
|
+
const e = {
|
|
1401
1424
|
dateString: this.dropdownSelectedDateString,
|
|
1402
|
-
start:
|
|
1403
|
-
end:
|
|
1404
|
-
hostStart:
|
|
1405
|
-
hostEnd:
|
|
1425
|
+
start: t.displayStart,
|
|
1426
|
+
end: t.displayEnd,
|
|
1427
|
+
hostStart: t.start,
|
|
1428
|
+
hostEnd: t.end
|
|
1406
1429
|
};
|
|
1407
|
-
this.selectedRange = { dateString: this.dropdownSelectedDateString, start:
|
|
1430
|
+
this.selectedRange = { dateString: this.dropdownSelectedDateString, start: t.displayStart, end: t.displayEnd }, this.dispatchEvent(new CustomEvent("booking-selected", { detail: e, bubbles: !0, composed: !0 })), this.dropdownOpen = !1, this.dropdownSelectedDateString = "";
|
|
1408
1431
|
}
|
|
1409
1432
|
render() {
|
|
1410
|
-
const
|
|
1411
|
-
const
|
|
1433
|
+
const t = this.selectedRange ? `Reserva: ${this.selectedRange.dateString} (${this.selectedRange.start} - ${this.selectedRange.end})` : "Seleccionar Fecha y Hora", e = this.activeDate.getFullYear(), a = this.activeDate.getMonth(), i = this.dropdownSelectedDateString ? /* @__PURE__ */ new Date(this.dropdownSelectedDateString + "T00:00:00") : null, r = i && this.activeTimezone === "local" ? I(i, this.hostTimezone, "local") : 0, l = i ? this.slots.map((o) => {
|
|
1434
|
+
const h = C(i, o, this.rules), n = U(o, r), c = n.dayShift > 0 ? " (+1d)" : n.dayShift < 0 ? " (-1d)" : "";
|
|
1412
1435
|
return {
|
|
1413
1436
|
...o,
|
|
1414
1437
|
displayStart: n.start + c,
|
|
1415
1438
|
displayEnd: n.end + c,
|
|
1416
|
-
isBlocked:
|
|
1439
|
+
isBlocked: h
|
|
1417
1440
|
};
|
|
1418
1441
|
}) : [];
|
|
1419
1442
|
return d`
|
|
1420
1443
|
<div class="dropdown-container">
|
|
1421
1444
|
<button class="btn btn-primary dropdown-toggle" @click=${() => this.dropdownOpen = !this.dropdownOpen}>
|
|
1422
|
-
<span>${
|
|
1445
|
+
<span>${t}</span> <span>${this.dropdownOpen ? "▲" : "▼"}</span>
|
|
1423
1446
|
</button>
|
|
1424
1447
|
|
|
1425
1448
|
${this.dropdownOpen ? d`
|
|
@@ -1441,19 +1464,45 @@ let b = class extends O {
|
|
|
1441
1464
|
`)}
|
|
1442
1465
|
</div>
|
|
1443
1466
|
` : d`
|
|
1444
|
-
<div
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1467
|
+
<div class="mini-calendar-header">
|
|
1468
|
+
<button
|
|
1469
|
+
type="button"
|
|
1470
|
+
class="mini-nav-btn"
|
|
1471
|
+
aria-label="Mes anterior"
|
|
1472
|
+
@click=${this.handlePrevMonth}
|
|
1473
|
+
>
|
|
1474
|
+
<
|
|
1475
|
+
</button>
|
|
1476
|
+
<span class="mini-month-title">
|
|
1477
|
+
${this.getFormattedMonthTitle()}
|
|
1478
|
+
</span>
|
|
1479
|
+
<button
|
|
1480
|
+
type="button"
|
|
1481
|
+
class="mini-nav-btn"
|
|
1482
|
+
aria-label="Mes siguiente"
|
|
1483
|
+
@click=${this.handleNextMonth}
|
|
1484
|
+
>
|
|
1485
|
+
>
|
|
1486
|
+
</button>
|
|
1487
|
+
</div>
|
|
1488
|
+
<div
|
|
1489
|
+
class="mini-calendar-touch-wrapper"
|
|
1490
|
+
@touchstart=${this.handleTouchStart}
|
|
1491
|
+
@touchend=${this.handleTouchEnd}
|
|
1492
|
+
>
|
|
1493
|
+
<glatam-calendar-month-view
|
|
1494
|
+
.days=${P(e, a, this.rules, this.slots, this.startOfWeekDay)}
|
|
1495
|
+
.locale=${this.locale}
|
|
1496
|
+
.startOfWeekDay=${this.startOfWeekDay}
|
|
1497
|
+
.role=${this.role}
|
|
1498
|
+
size="small"
|
|
1499
|
+
.minDate=${this.minDate}
|
|
1500
|
+
.maxDate=${this.maxDate}
|
|
1501
|
+
.showNeighboringMonth=${this.showNeighboringMonth}
|
|
1502
|
+
.tileClassName=${this.tileClassName}
|
|
1503
|
+
@day-select=${this.handleDropdownDaySelect}
|
|
1504
|
+
></glatam-calendar-month-view>
|
|
1505
|
+
</div>
|
|
1457
1506
|
`}
|
|
1458
1507
|
</div>
|
|
1459
1508
|
` : ""}
|
|
@@ -1462,9 +1511,9 @@ let b = class extends O {
|
|
|
1462
1511
|
}
|
|
1463
1512
|
};
|
|
1464
1513
|
b.styles = [
|
|
1465
|
-
|
|
1514
|
+
A,
|
|
1466
1515
|
W,
|
|
1467
|
-
|
|
1516
|
+
M`
|
|
1468
1517
|
:host {
|
|
1469
1518
|
display: inline-block;
|
|
1470
1519
|
background: transparent;
|
|
@@ -1473,57 +1522,98 @@ b.styles = [
|
|
|
1473
1522
|
box-shadow: none;
|
|
1474
1523
|
width: 100%;
|
|
1475
1524
|
}
|
|
1525
|
+
|
|
1526
|
+
.mini-calendar-header {
|
|
1527
|
+
display: flex;
|
|
1528
|
+
justify-content: space-between;
|
|
1529
|
+
align-items: center;
|
|
1530
|
+
padding: 4px 8px;
|
|
1531
|
+
margin-bottom: 8px;
|
|
1532
|
+
user-select: none;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
.mini-month-title {
|
|
1536
|
+
font-size: 0.875rem;
|
|
1537
|
+
font-weight: 600;
|
|
1538
|
+
color: var(--glatam-text);
|
|
1539
|
+
text-transform: capitalize;
|
|
1540
|
+
letter-spacing: -0.01em;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
.mini-nav-btn {
|
|
1544
|
+
background: transparent;
|
|
1545
|
+
border: 1px solid var(--glatam-border);
|
|
1546
|
+
border-radius: 8px;
|
|
1547
|
+
color: var(--glatam-text);
|
|
1548
|
+
width: 28px;
|
|
1549
|
+
height: 28px;
|
|
1550
|
+
display: flex;
|
|
1551
|
+
align-items: center;
|
|
1552
|
+
justify-content: center;
|
|
1553
|
+
cursor: pointer;
|
|
1554
|
+
font-size: 0.75rem;
|
|
1555
|
+
transition: background-color var(--glatam-transition-fast), border-color var(--glatam-transition-fast), transform var(--glatam-transition-fast);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
.mini-nav-btn:hover:not(:disabled) {
|
|
1559
|
+
background-color: var(--glatam-surface);
|
|
1560
|
+
border-color: var(--glatam-text-secondary);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
.mini-nav-btn:active:not(:disabled) {
|
|
1564
|
+
transform: scale(0.95);
|
|
1565
|
+
}
|
|
1476
1566
|
`
|
|
1477
1567
|
];
|
|
1478
|
-
|
|
1568
|
+
y([
|
|
1479
1569
|
s({ type: String })
|
|
1480
1570
|
], b.prototype, "role", 2);
|
|
1481
|
-
|
|
1571
|
+
y([
|
|
1482
1572
|
s({ type: String })
|
|
1483
1573
|
], b.prototype, "locale", 2);
|
|
1484
|
-
|
|
1574
|
+
y([
|
|
1485
1575
|
s({ type: Number })
|
|
1486
1576
|
], b.prototype, "startOfWeekDay", 2);
|
|
1487
|
-
|
|
1577
|
+
y([
|
|
1488
1578
|
s({ type: Array })
|
|
1489
1579
|
], b.prototype, "rules", 2);
|
|
1490
|
-
|
|
1580
|
+
y([
|
|
1491
1581
|
s({ type: Object })
|
|
1492
1582
|
], b.prototype, "selectedRange", 2);
|
|
1493
|
-
|
|
1583
|
+
y([
|
|
1494
1584
|
s({ type: String, reflect: !0 })
|
|
1495
1585
|
], b.prototype, "size", 2);
|
|
1496
|
-
|
|
1586
|
+
y([
|
|
1497
1587
|
s({ type: String })
|
|
1498
1588
|
], b.prototype, "hostTimezone", 2);
|
|
1499
|
-
|
|
1589
|
+
y([
|
|
1500
1590
|
s({ type: String })
|
|
1501
1591
|
], b.prototype, "activeTimezone", 2);
|
|
1502
|
-
|
|
1592
|
+
y([
|
|
1503
1593
|
s({ type: String })
|
|
1504
1594
|
], b.prototype, "minDate", 2);
|
|
1505
|
-
|
|
1595
|
+
y([
|
|
1506
1596
|
s({ type: String })
|
|
1507
1597
|
], b.prototype, "maxDate", 2);
|
|
1508
|
-
|
|
1598
|
+
y([
|
|
1509
1599
|
s({ type: Boolean })
|
|
1510
1600
|
], b.prototype, "showNeighboringMonth", 2);
|
|
1511
|
-
|
|
1601
|
+
y([
|
|
1512
1602
|
s({ attribute: !1 })
|
|
1513
1603
|
], b.prototype, "tileClassName", 2);
|
|
1514
|
-
|
|
1604
|
+
y([
|
|
1515
1605
|
s({ type: Array })
|
|
1516
1606
|
], b.prototype, "slots", 2);
|
|
1517
|
-
|
|
1607
|
+
y([
|
|
1518
1608
|
u()
|
|
1519
1609
|
], b.prototype, "activeDate", 2);
|
|
1520
|
-
|
|
1610
|
+
y([
|
|
1521
1611
|
u()
|
|
1522
1612
|
], b.prototype, "dropdownOpen", 2);
|
|
1523
|
-
|
|
1613
|
+
y([
|
|
1524
1614
|
u()
|
|
1525
1615
|
], b.prototype, "dropdownSelectedDateString", 2);
|
|
1526
|
-
b =
|
|
1616
|
+
b = y([
|
|
1527
1617
|
T("glatam-calendar-mini")
|
|
1528
1618
|
], b);
|
|
1529
1619
|
export {
|
|
@@ -1537,5 +1627,5 @@ export {
|
|
|
1537
1627
|
nt as formatISODate,
|
|
1538
1628
|
dt as isTimeBlocked,
|
|
1539
1629
|
ct as parseISODate,
|
|
1540
|
-
|
|
1630
|
+
A as variablesStyles
|
|
1541
1631
|
};
|