@progressive-development/pd-calendar 0.9.2 → 1.0.1
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/LICENSE +21 -2
- package/README.md +32 -57
- package/dist/generated/locales/be.d.ts +3 -0
- package/dist/generated/locales/be.d.ts.map +1 -1
- package/dist/generated/locales/de.d.ts +3 -0
- package/dist/generated/locales/de.d.ts.map +1 -1
- package/dist/generated/locales/en.d.ts +3 -0
- package/dist/generated/locales/en.d.ts.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/locales/be.js +4 -1
- package/dist/locales/de.js +3 -0
- package/dist/locales/en.js +4 -1
- package/dist/pd-calendar/PdCalendar.d.ts +101 -18
- package/dist/pd-calendar/PdCalendar.d.ts.map +1 -1
- package/dist/pd-calendar/PdCalendar.js +380 -264
- package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts +40 -33
- package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts.map +1 -1
- package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.js +173 -113
- package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.d.ts +27 -0
- package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.js +160 -0
- package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.js +8 -0
- package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.d.ts +55 -0
- package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.js +341 -0
- package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.js +8 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.d.ts +29 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.js +211 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.js +8 -0
- package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.d.ts +28 -0
- package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.js +252 -0
- package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.js +8 -0
- package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.d.ts +26 -0
- package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.js +165 -0
- package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.js +8 -0
- package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.d.ts +55 -0
- package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.js +461 -0
- package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.js +8 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.d.ts +32 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.js +468 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.js +8 -0
- package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.d.ts +31 -0
- package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.js +134 -0
- package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.js +8 -0
- package/dist/pd-calendar/pd-calendar.stories.d.ts +79 -19
- package/dist/pd-calendar/pd-calendar.stories.d.ts.map +1 -1
- package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts +22 -11
- package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts.map +1 -1
- package/dist/pd-calendar/pd-year-popup/PdYearPopup.js +152 -34
- package/dist/pd-datepicker/PdDatepicker.d.ts +76 -7
- package/dist/pd-datepicker/PdDatepicker.d.ts.map +1 -1
- package/dist/pd-datepicker/PdDatepicker.js +257 -50
- package/dist/pd-datepicker/pd-date-picker.stories.d.ts +78 -20
- package/dist/pd-datepicker/pd-date-picker.stories.d.ts.map +1 -1
- package/dist/pd-slot-picker/PdSlotPicker.d.ts +102 -0
- package/dist/pd-slot-picker/PdSlotPicker.d.ts.map +1 -0
- package/dist/pd-slot-picker/PdSlotPicker.js +339 -0
- package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.d.ts +35 -0
- package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.d.ts.map +1 -0
- package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.js +188 -0
- package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.d.ts +3 -0
- package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.d.ts.map +1 -0
- package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.js +8 -0
- package/dist/pd-slot-picker/pd-slot-picker.d.ts +3 -0
- package/dist/pd-slot-picker/pd-slot-picker.d.ts.map +1 -0
- package/dist/pd-slot-picker/pd-slot-picker.stories.d.ts +67 -0
- package/dist/pd-slot-picker/pd-slot-picker.stories.d.ts.map +1 -0
- package/dist/pd-slot-picker.d.ts +2 -0
- package/dist/pd-slot-picker.js +8 -0
- package/dist/shared/PdBaseCell.d.ts +68 -0
- package/dist/shared/PdBaseCell.d.ts.map +1 -0
- package/dist/shared/PdBaseCell.js +120 -0
- package/dist/shared/PdBaseView.d.ts +22 -0
- package/dist/shared/PdBaseView.d.ts.map +1 -0
- package/dist/shared/PdBaseView.js +46 -0
- package/dist/shared/PdCalendarPanelBase.d.ts +34 -0
- package/dist/shared/PdCalendarPanelBase.d.ts.map +1 -0
- package/dist/shared/PdCalendarPanelBase.js +169 -0
- package/dist/shared/calendar-button-bar/calendar-button-bar.d.ts +41 -0
- package/dist/shared/calendar-button-bar/calendar-button-bar.d.ts.map +1 -0
- package/dist/shared/calendar-button-bar/calendar-button-bar.js +435 -0
- package/dist/shared/calendar-locales.d.ts +9 -0
- package/dist/shared/calendar-locales.d.ts.map +1 -0
- package/dist/shared/calendar-locales.js +30 -0
- package/dist/shared/calendar-utils.d.ts +34 -0
- package/dist/shared/calendar-utils.d.ts.map +1 -0
- package/dist/shared/calendar-utils.js +99 -0
- package/dist/shared/calendar-utils.test.d.ts +2 -0
- package/dist/shared/calendar-utils.test.d.ts.map +1 -0
- package/dist/types.d.ts +102 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -5
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts +0 -15
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts.map +0 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { css, nothing, html } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { localized } from '@lit/localize';
|
|
4
|
+
import { format } from 'fecha';
|
|
5
|
+
import { PdBaseView } from '../../shared/PdBaseView.js';
|
|
6
|
+
import { LOCALES } from '../../shared/calendar-locales.js';
|
|
7
|
+
import { getWeeksArray, isToday, isSelected } from '../../shared/calendar-utils.js';
|
|
8
|
+
import '../pd-calendar-cell/pd-calendar-cell.js';
|
|
9
|
+
import '../pd-calendar-event-cell/pd-calendar-event-cell.js';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
if (decorator = decorators[i])
|
|
17
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
+
if (kind && result) __defProp(target, key, result);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const TOUCH_MIN_MOVE = 70;
|
|
22
|
+
let PdCalendarMonthView = class extends PdBaseView {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.currentDate = /* @__PURE__ */ new Date();
|
|
26
|
+
this.hideWeekend = false;
|
|
27
|
+
this.selectableDates = false;
|
|
28
|
+
this.numberClass = "top-left";
|
|
29
|
+
this.withWheelNavigation = false;
|
|
30
|
+
this.withTouchNavigation = false;
|
|
31
|
+
this.cellType = "simple";
|
|
32
|
+
this._wheelDelta = 0;
|
|
33
|
+
this._focusedDay = -1;
|
|
34
|
+
this._gridHasFocus = false;
|
|
35
|
+
// Derived values computed in willUpdate
|
|
36
|
+
this._numberOfDays = 0;
|
|
37
|
+
this._firstDayOfMonth = 0;
|
|
38
|
+
this._year = 0;
|
|
39
|
+
this._month = 0;
|
|
40
|
+
}
|
|
41
|
+
willUpdate(changedProperties) {
|
|
42
|
+
if (changedProperties.has("currentDate")) {
|
|
43
|
+
const date = this.currentDate;
|
|
44
|
+
this._year = date.getFullYear();
|
|
45
|
+
this._month = date.getMonth();
|
|
46
|
+
const firstDay = new Date(this._year, this._month, 1);
|
|
47
|
+
this._firstDayOfMonth = firstDay.getDay();
|
|
48
|
+
const lastDay = new Date(this._year, this._month + 1, 0);
|
|
49
|
+
this._numberOfDays = lastDay.getDate();
|
|
50
|
+
if (this._prevCurrentDate && (this._prevCurrentDate.getMonth() !== this._month || this._prevCurrentDate.getFullYear() !== this._year)) {
|
|
51
|
+
this._focusedDay = -1;
|
|
52
|
+
}
|
|
53
|
+
this._prevCurrentDate = date;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
const gridLabel = `${LOCALES.monthNames[this._month]} ${this._year}`;
|
|
58
|
+
const weeks = getWeeksArray(this._year, this._month, this.hideWeekend);
|
|
59
|
+
return html`
|
|
60
|
+
<div
|
|
61
|
+
id="calendarGrid"
|
|
62
|
+
class="calendar-grid"
|
|
63
|
+
role="grid"
|
|
64
|
+
aria-label="${gridLabel}"
|
|
65
|
+
tabindex="${this.selectableDates || this.withWheelNavigation ? 0 : -1}"
|
|
66
|
+
@wheel="${this._wheelEvent}"
|
|
67
|
+
@touchstart="${this._touchStartEvent}"
|
|
68
|
+
@touchend="${this._touchEndEvent}"
|
|
69
|
+
@keydown="${this.selectableDates ? this._onGridKeyDown : nothing}"
|
|
70
|
+
@focusin="${this._onGridFocusIn}"
|
|
71
|
+
@focusout="${this._onGridFocusOut}"
|
|
72
|
+
>
|
|
73
|
+
<!-- Weekday Headers -->
|
|
74
|
+
<div class="week-header" role="row">
|
|
75
|
+
${this._getWeekDays().map(
|
|
76
|
+
(day) => html`
|
|
77
|
+
<div class="title-week-day" role="columnheader">${day}</div>
|
|
78
|
+
`
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<!-- Week Rows -->
|
|
83
|
+
${weeks.map(
|
|
84
|
+
(week) => html`
|
|
85
|
+
<div class="week-row" role="row">
|
|
86
|
+
${week.map((day) => this._renderDay(day))}
|
|
87
|
+
</div>
|
|
88
|
+
`
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
// ===========================================================================
|
|
94
|
+
// Day Rendering
|
|
95
|
+
// ===========================================================================
|
|
96
|
+
_renderDay(day) {
|
|
97
|
+
if (day === null) {
|
|
98
|
+
return html`<div class="cell-empty" role="gridcell"></div>`;
|
|
99
|
+
}
|
|
100
|
+
if (this.cellType === "events") {
|
|
101
|
+
return this._renderEventDay(day);
|
|
102
|
+
}
|
|
103
|
+
const key = format(day, "YYYY-MM-DD");
|
|
104
|
+
const cellData = this.data ? this.data[key]?.[0] : void 0;
|
|
105
|
+
const dayNumber = day.getDate();
|
|
106
|
+
const isFocused = this._gridHasFocus && this._focusedDay === dayNumber;
|
|
107
|
+
const isDisabled = cellData?.disabled ?? false;
|
|
108
|
+
const category = cellData?.category;
|
|
109
|
+
const categoryConfig = this._resolveCategoryConfig(category);
|
|
110
|
+
return html`
|
|
111
|
+
<pd-calendar-cell
|
|
112
|
+
role="gridcell"
|
|
113
|
+
key="${key}"
|
|
114
|
+
.dayNumber="${dayNumber}"
|
|
115
|
+
.weekDayNumber="${day.getDay()}"
|
|
116
|
+
.title="${cellData?.info || ""}"
|
|
117
|
+
?selectEnabled="${this.selectableDates || !!cellData?.info}"
|
|
118
|
+
.category="${category || ""}"
|
|
119
|
+
.categoryColor="${categoryConfig?.color || ""}"
|
|
120
|
+
.categoryTextColor="${categoryConfig?.textColor || ""}"
|
|
121
|
+
?disabled="${isDisabled}"
|
|
122
|
+
.numberClass="${this.numberClass}"
|
|
123
|
+
?today="${this.selectableDates && isToday(day)}"
|
|
124
|
+
?selected="${this.showSelection && isSelected(this.refDate, day)}"
|
|
125
|
+
?focused="${isFocused}"
|
|
126
|
+
aria-selected="${this.showSelection && isSelected(this.refDate, day)}"
|
|
127
|
+
aria-disabled="${isDisabled}"
|
|
128
|
+
></pd-calendar-cell>
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
_renderEventDay(day) {
|
|
132
|
+
const key = format(day, "YYYY-MM-DD");
|
|
133
|
+
const entries = this.data ? this.data[key] ?? [] : [];
|
|
134
|
+
const dayNumber = day.getDate();
|
|
135
|
+
return html`
|
|
136
|
+
<pd-calendar-event-cell
|
|
137
|
+
role="gridcell"
|
|
138
|
+
key="${key}"
|
|
139
|
+
.dayNumber="${dayNumber}"
|
|
140
|
+
.weekDayNumber="${day.getDay()}"
|
|
141
|
+
.entries="${entries}"
|
|
142
|
+
.config="${this.config}"
|
|
143
|
+
?today="${isToday(day)}"
|
|
144
|
+
?selected="${this.showSelection && isSelected(this.refDate, day)}"
|
|
145
|
+
></pd-calendar-event-cell>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
_getWeekDays() {
|
|
149
|
+
return this.hideWeekend ? LOCALES.weekdaysShort.slice(0, 5) : LOCALES.weekdaysShort;
|
|
150
|
+
}
|
|
151
|
+
// ===========================================================================
|
|
152
|
+
// Navigation Events (dispatch pd-navigate to parent)
|
|
153
|
+
// ===========================================================================
|
|
154
|
+
_dispatchNavigate(direction) {
|
|
155
|
+
this.dispatchEvent(
|
|
156
|
+
new CustomEvent("pd-navigate", {
|
|
157
|
+
detail: { direction },
|
|
158
|
+
bubbles: true,
|
|
159
|
+
composed: true
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
// ===========================================================================
|
|
164
|
+
// Focus Management
|
|
165
|
+
// ===========================================================================
|
|
166
|
+
_onGridFocusIn() {
|
|
167
|
+
this._gridHasFocus = true;
|
|
168
|
+
}
|
|
169
|
+
_onGridFocusOut() {
|
|
170
|
+
this._gridHasFocus = false;
|
|
171
|
+
this._wheelDelta = 0;
|
|
172
|
+
}
|
|
173
|
+
// ===========================================================================
|
|
174
|
+
// Wheel Navigation
|
|
175
|
+
// ===========================================================================
|
|
176
|
+
_wheelEvent(e) {
|
|
177
|
+
if (!this.withWheelNavigation) return;
|
|
178
|
+
if (!this._gridHasFocus) return;
|
|
179
|
+
this._wheelDelta += e.deltaY;
|
|
180
|
+
if (this._wheelDelta > 360) {
|
|
181
|
+
this._wheelDelta = 0;
|
|
182
|
+
this._dispatchNavigate("next");
|
|
183
|
+
} else if (this._wheelDelta < -360) {
|
|
184
|
+
this._wheelDelta = 0;
|
|
185
|
+
this._dispatchNavigate("prev");
|
|
186
|
+
}
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
}
|
|
189
|
+
// ===========================================================================
|
|
190
|
+
// Touch Navigation
|
|
191
|
+
// ===========================================================================
|
|
192
|
+
_touchStartEvent(e) {
|
|
193
|
+
if (this.withTouchNavigation) {
|
|
194
|
+
this._wheelDelta = e.changedTouches[0].screenX;
|
|
195
|
+
}
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
}
|
|
198
|
+
_touchEndEvent(e) {
|
|
199
|
+
if (this.withTouchNavigation) {
|
|
200
|
+
const diff = this._wheelDelta - e.changedTouches[0].screenX;
|
|
201
|
+
if (diff < -TOUCH_MIN_MOVE) {
|
|
202
|
+
this._dispatchNavigate("next");
|
|
203
|
+
} else if (diff > TOUCH_MIN_MOVE) {
|
|
204
|
+
this._dispatchNavigate("prev");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
e.stopPropagation();
|
|
208
|
+
}
|
|
209
|
+
// ===========================================================================
|
|
210
|
+
// Keyboard Navigation
|
|
211
|
+
// ===========================================================================
|
|
212
|
+
_onGridKeyDown(e) {
|
|
213
|
+
if (!this.selectableDates) return;
|
|
214
|
+
const daysInWeek = this.hideWeekend ? 5 : 7;
|
|
215
|
+
let newFocusedDay = this._focusedDay;
|
|
216
|
+
switch (e.key) {
|
|
217
|
+
case "ArrowRight":
|
|
218
|
+
newFocusedDay = this._getNextSelectableDay(this._focusedDay, 1);
|
|
219
|
+
break;
|
|
220
|
+
case "ArrowLeft":
|
|
221
|
+
newFocusedDay = this._getNextSelectableDay(this._focusedDay, -1);
|
|
222
|
+
break;
|
|
223
|
+
case "ArrowDown":
|
|
224
|
+
newFocusedDay = this._getNextSelectableDay(
|
|
225
|
+
this._focusedDay,
|
|
226
|
+
daysInWeek
|
|
227
|
+
);
|
|
228
|
+
break;
|
|
229
|
+
case "ArrowUp":
|
|
230
|
+
newFocusedDay = this._getNextSelectableDay(
|
|
231
|
+
this._focusedDay,
|
|
232
|
+
-daysInWeek
|
|
233
|
+
);
|
|
234
|
+
break;
|
|
235
|
+
case "Home":
|
|
236
|
+
newFocusedDay = 1;
|
|
237
|
+
break;
|
|
238
|
+
case "End":
|
|
239
|
+
newFocusedDay = this._numberOfDays;
|
|
240
|
+
break;
|
|
241
|
+
case "PageDown":
|
|
242
|
+
this._dispatchNavigate("next");
|
|
243
|
+
return;
|
|
244
|
+
case "PageUp":
|
|
245
|
+
this._dispatchNavigate("prev");
|
|
246
|
+
return;
|
|
247
|
+
case "Enter":
|
|
248
|
+
case " ":
|
|
249
|
+
if (this._focusedDay > 0) {
|
|
250
|
+
this._selectFocusedDay();
|
|
251
|
+
}
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
return;
|
|
254
|
+
default:
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (newFocusedDay !== this._focusedDay && newFocusedDay >= 1 && newFocusedDay <= this._numberOfDays) {
|
|
258
|
+
this._focusedDay = newFocusedDay;
|
|
259
|
+
this._scrollFocusedDayIntoView();
|
|
260
|
+
}
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
}
|
|
263
|
+
_getNextSelectableDay(currentDay, delta) {
|
|
264
|
+
if (currentDay < 1) {
|
|
265
|
+
return delta > 0 ? 1 : this._numberOfDays;
|
|
266
|
+
}
|
|
267
|
+
let nextDay = currentDay + delta;
|
|
268
|
+
if (nextDay < 1) nextDay = 1;
|
|
269
|
+
if (nextDay > this._numberOfDays) nextDay = this._numberOfDays;
|
|
270
|
+
if (this.hideWeekend) {
|
|
271
|
+
const date = new Date(this._year, this._month, nextDay);
|
|
272
|
+
const dayOfWeek = date.getDay();
|
|
273
|
+
if (dayOfWeek === 0) nextDay += delta > 0 ? 1 : -2;
|
|
274
|
+
if (dayOfWeek === 6) nextDay += delta > 0 ? 2 : -1;
|
|
275
|
+
if (nextDay < 1) nextDay = 1;
|
|
276
|
+
if (nextDay > this._numberOfDays) nextDay = this._numberOfDays;
|
|
277
|
+
}
|
|
278
|
+
return nextDay;
|
|
279
|
+
}
|
|
280
|
+
_selectFocusedDay() {
|
|
281
|
+
const date = new Date(this._year, this._month, this._focusedDay);
|
|
282
|
+
const key = format(date, "YYYY-MM-DD");
|
|
283
|
+
this.dispatchEvent(
|
|
284
|
+
new CustomEvent("select-date", {
|
|
285
|
+
detail: { dateKey: key, date },
|
|
286
|
+
bubbles: true,
|
|
287
|
+
composed: true
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
_scrollFocusedDayIntoView() {
|
|
292
|
+
this.updateComplete.then(() => {
|
|
293
|
+
const focusedCell = this.shadowRoot?.querySelector(
|
|
294
|
+
`pd-calendar-cell[focused]`
|
|
295
|
+
);
|
|
296
|
+
focusedCell?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
PdCalendarMonthView.styles = [
|
|
301
|
+
PdBaseView.baseStyles,
|
|
302
|
+
css`
|
|
303
|
+
:host {
|
|
304
|
+
--_cell-height: var(--pd-calendar-cell-height, 70px);
|
|
305
|
+
--_columns: 7;
|
|
306
|
+
--_gap: var(--pd-calendar-gap, 2px);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
:host([hideWeekend]) {
|
|
310
|
+
--_columns: 5;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
:host([celltype="events"]) {
|
|
314
|
+
--_cell-height: var(--pd-calendar-cell-height, 100px);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.calendar-grid {
|
|
318
|
+
display: grid;
|
|
319
|
+
grid-template-columns: repeat(var(--_columns), minmax(0, 1fr));
|
|
320
|
+
gap: var(--_gap);
|
|
321
|
+
position: relative;
|
|
322
|
+
background-color: var(
|
|
323
|
+
--pd-calendar-grid-bg-col,
|
|
324
|
+
var(--pd-default-disabled-light-col)
|
|
325
|
+
);
|
|
326
|
+
padding: var(--_gap);
|
|
327
|
+
border-radius: var(--pd-radius-md);
|
|
328
|
+
overflow: hidden;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.week-row {
|
|
332
|
+
display: grid;
|
|
333
|
+
grid-column: 1 / -1;
|
|
334
|
+
grid-template-columns: subgrid;
|
|
335
|
+
gap: var(--_gap);
|
|
336
|
+
min-height: var(--_cell-height);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.week-header {
|
|
340
|
+
display: grid;
|
|
341
|
+
grid-column: 1 / -1;
|
|
342
|
+
grid-template-columns: subgrid;
|
|
343
|
+
gap: var(--_gap);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.title-week-day {
|
|
347
|
+
display: flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
min-height: 36px;
|
|
351
|
+
padding: var(--pd-spacing-xs) 0;
|
|
352
|
+
background-color: var(
|
|
353
|
+
--pd-calendar-week-title-bg-col,
|
|
354
|
+
var(--pd-default-dark-col)
|
|
355
|
+
);
|
|
356
|
+
font-size: var(--pd-calendar-weekday-title-font-size, 0.85em);
|
|
357
|
+
font-weight: 600;
|
|
358
|
+
color: var(--pd-calendar-week-title-font-col, var(--pd-on-primary-col));
|
|
359
|
+
font-family: var(--pd-default-font-title-family);
|
|
360
|
+
text-transform: uppercase;
|
|
361
|
+
letter-spacing: 0.08em;
|
|
362
|
+
border-radius: var(--pd-radius-sm);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.cell-empty {
|
|
366
|
+
min-height: var(--_cell-height);
|
|
367
|
+
background-color: var(
|
|
368
|
+
--pd-calendar-cell-empty-bg-col,
|
|
369
|
+
var(--pd-default-disabled-lightest-col)
|
|
370
|
+
);
|
|
371
|
+
border-radius: var(--pd-radius-sm);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.calendar-grid:focus {
|
|
375
|
+
outline: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.calendar-grid:focus-visible {
|
|
379
|
+
outline: 2px solid var(--pd-focus-ring-col);
|
|
380
|
+
outline-offset: 2px;
|
|
381
|
+
border-radius: var(--pd-radius-md, 4px);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
@container (max-width: 500px) {
|
|
385
|
+
.title-week-day {
|
|
386
|
+
font-size: 0.75em;
|
|
387
|
+
min-height: 28px;
|
|
388
|
+
letter-spacing: 0.02em;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.week-row {
|
|
392
|
+
min-height: var(--pd-calendar-cell-height, 50px);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.cell-empty {
|
|
396
|
+
min-height: var(--pd-calendar-cell-height, 50px);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@container (max-width: 300px) {
|
|
401
|
+
.title-week-day {
|
|
402
|
+
font-size: 0.7em;
|
|
403
|
+
min-height: 22px;
|
|
404
|
+
letter-spacing: 0;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.week-row {
|
|
408
|
+
min-height: var(--pd-calendar-cell-height, 40px);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.cell-empty {
|
|
412
|
+
min-height: var(--pd-calendar-cell-height, 40px);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.calendar-grid {
|
|
416
|
+
gap: 1px;
|
|
417
|
+
padding: 1px;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.week-row,
|
|
421
|
+
.week-header {
|
|
422
|
+
gap: 1px;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
`
|
|
426
|
+
];
|
|
427
|
+
__decorateClass([
|
|
428
|
+
property({ type: Object })
|
|
429
|
+
], PdCalendarMonthView.prototype, "currentDate", 2);
|
|
430
|
+
__decorateClass([
|
|
431
|
+
property({ type: Boolean, reflect: true })
|
|
432
|
+
], PdCalendarMonthView.prototype, "hideWeekend", 2);
|
|
433
|
+
__decorateClass([
|
|
434
|
+
property({ type: Boolean })
|
|
435
|
+
], PdCalendarMonthView.prototype, "selectableDates", 2);
|
|
436
|
+
__decorateClass([
|
|
437
|
+
property({ type: String })
|
|
438
|
+
], PdCalendarMonthView.prototype, "numberClass", 2);
|
|
439
|
+
__decorateClass([
|
|
440
|
+
property({ type: Boolean })
|
|
441
|
+
], PdCalendarMonthView.prototype, "withWheelNavigation", 2);
|
|
442
|
+
__decorateClass([
|
|
443
|
+
property({ type: Boolean })
|
|
444
|
+
], PdCalendarMonthView.prototype, "withTouchNavigation", 2);
|
|
445
|
+
__decorateClass([
|
|
446
|
+
property({ type: String, reflect: true })
|
|
447
|
+
], PdCalendarMonthView.prototype, "cellType", 2);
|
|
448
|
+
__decorateClass([
|
|
449
|
+
state()
|
|
450
|
+
], PdCalendarMonthView.prototype, "_wheelDelta", 2);
|
|
451
|
+
__decorateClass([
|
|
452
|
+
state()
|
|
453
|
+
], PdCalendarMonthView.prototype, "_focusedDay", 2);
|
|
454
|
+
__decorateClass([
|
|
455
|
+
state()
|
|
456
|
+
], PdCalendarMonthView.prototype, "_gridHasFocus", 2);
|
|
457
|
+
PdCalendarMonthView = __decorateClass([
|
|
458
|
+
localized()
|
|
459
|
+
], PdCalendarMonthView);
|
|
460
|
+
|
|
461
|
+
export { PdCalendarMonthView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pd-calendar-month-view.d.ts","sourceRoot":"","sources":["../../../src/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAO/D,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { nothing, CSSResultGroup } from 'lit';
|
|
2
|
+
import { PdBaseView } from '../../shared/PdBaseView.js';
|
|
3
|
+
import { WeekViewConfig } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Time grid (week) view component for the calendar.
|
|
6
|
+
* Displays a weekly view with hour rows and overlapping event layout.
|
|
7
|
+
*
|
|
8
|
+
* @internal - Not exported from package, used only by PdCalendar.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PdCalendarTimeGridView extends PdBaseView {
|
|
11
|
+
/** Monday of the currently displayed week. */
|
|
12
|
+
currentWeekStart?: Date;
|
|
13
|
+
/** Configuration for the week view (visible days, time window). */
|
|
14
|
+
weekViewConfig?: WeekViewConfig;
|
|
15
|
+
/** Hide Saturday and Sunday columns. */
|
|
16
|
+
hideWeekend: boolean;
|
|
17
|
+
static styles: CSSResultGroup;
|
|
18
|
+
render(): import('lit').TemplateResult<1> | typeof nothing;
|
|
19
|
+
/** Returns effective visible day indices from config, hideWeekend flag, or all 7 days. */
|
|
20
|
+
private _getVisibleDays;
|
|
21
|
+
/** Returns { startHour, endHour } from config or defaults. */
|
|
22
|
+
private _getTimeWindow;
|
|
23
|
+
/** Parses "HH:mm" -> decimal hours (e.g. "09:30" -> 9.5). */
|
|
24
|
+
private _parseTimeToDecimal;
|
|
25
|
+
/** Calculates the actual Date for a given monday-based day index. */
|
|
26
|
+
private _getDateForDayIndex;
|
|
27
|
+
/** Renders hour labels in the gutter. */
|
|
28
|
+
private _renderHourLabels;
|
|
29
|
+
/** Renders horizontal hour lines within a day column. */
|
|
30
|
+
private _renderHourLines;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PdCalendarTimeGridView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdCalendarTimeGridView.d.ts","sourceRoot":"","sources":["../../../src/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,EAAE,cAAc,EAAgB,MAAM,gBAAgB,CAAC;AAE9D,OAAO,mDAAmD,CAAC;AAE3D;;;;;GAKG;AACH,qBACa,sBAAuB,SAAQ,UAAU;IACpD,8CAA8C;IAE9C,gBAAgB,CAAC,EAAE,IAAI,CAAC;IAExB,mEAAmE;IAEnE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,wCAAwC;IAExC,WAAW,UAAS;IAEpB,OAAgB,MAAM,EAAE,cAAc,CAyMpC;IAEO,MAAM;IAwLf,0FAA0F;IAC1F,OAAO,CAAC,eAAe;IAUvB,8DAA8D;IAC9D,OAAO,CAAC,cAAc;IAOtB,6DAA6D;IAC7D,OAAO,CAAC,mBAAmB;IAK3B,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IAW3B,yCAAyC;IACzC,OAAO,CAAC,iBAAiB;IAyBzB,yDAAyD;IACzD,OAAO,CAAC,gBAAgB;CAyBzB"}
|