@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,435 @@
|
|
|
1
|
+
import { css, LitElement, html } from 'lit';
|
|
2
|
+
import { property, state, query, customElement } from 'lit/decorators.js';
|
|
3
|
+
import { localized } from '@lit/localize';
|
|
4
|
+
import { pdIcons } from '@progressive-development/pd-icon';
|
|
5
|
+
import '@progressive-development/pd-forms/pd-button';
|
|
6
|
+
import '@progressive-development/pd-forms/pd-button-group';
|
|
7
|
+
import '@progressive-development/pd-forms/pd-button-select-group';
|
|
8
|
+
import '../../pd-calendar/pd-year-popup/pd-year-popup.js';
|
|
9
|
+
import { PdYearPopup } from '../../pd-calendar/pd-year-popup/PdYearPopup.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 iconMap = {
|
|
22
|
+
list: { pdIcon: pdIcons.ICON_RULES },
|
|
23
|
+
dayGrid: { pdIcon: pdIcons.ICON_DATE },
|
|
24
|
+
timeGrid: { pdIcon: pdIcons.ICON_DATE_TIME }
|
|
25
|
+
};
|
|
26
|
+
const periodMap = {
|
|
27
|
+
Day: { text: "Tag" },
|
|
28
|
+
Week: { text: "Woche" },
|
|
29
|
+
Month: { text: "Monat" },
|
|
30
|
+
Year: { text: "Jahr" }
|
|
31
|
+
};
|
|
32
|
+
let CalendarButtonBar = class extends LitElement {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.withYearPopup = [];
|
|
36
|
+
this.year = 0;
|
|
37
|
+
this.hideNavigation = false;
|
|
38
|
+
this._currentViewOptions = [
|
|
39
|
+
{ pdIcon: pdIcons.ICON_DATE },
|
|
40
|
+
{ pdIcon: pdIcons.ICON_DATE_TIME },
|
|
41
|
+
{ pdIcon: pdIcons.ICON_RULES }
|
|
42
|
+
];
|
|
43
|
+
this._currentPeriodOptions = [
|
|
44
|
+
{ text: "Tag" },
|
|
45
|
+
{ text: "Woche" },
|
|
46
|
+
{ text: "Monat" },
|
|
47
|
+
{ text: "Jahr" }
|
|
48
|
+
];
|
|
49
|
+
this._currentViewTypeIndex = -1;
|
|
50
|
+
this._currentPeriodIndex = -1;
|
|
51
|
+
this._openYearPopupState = false;
|
|
52
|
+
}
|
|
53
|
+
willUpdate(changedProps) {
|
|
54
|
+
if (changedProps.has("availableViewTypes") && this.availableViewTypes.viewTypes?.length > 0) {
|
|
55
|
+
this._currentViewOptions = this.availableViewTypes.viewTypes.map((t) => {
|
|
56
|
+
const icon = iconMap[t];
|
|
57
|
+
if (!icon) throw new Error(`Unknown view type: ${t}`);
|
|
58
|
+
return icon;
|
|
59
|
+
});
|
|
60
|
+
if (this._currentViewTypeIndex === -1) {
|
|
61
|
+
this._currentViewTypeIndex = this.availableViewTypes.default ?? 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (changedProps.has("availablePeriods") && this.availablePeriods.periods.length > 0) {
|
|
65
|
+
this._currentPeriodOptions = this.availablePeriods.periods.map((t) => {
|
|
66
|
+
const period = periodMap[t];
|
|
67
|
+
if (!period) throw new Error(`Unknown period type: ${t}`);
|
|
68
|
+
return period;
|
|
69
|
+
});
|
|
70
|
+
if (this._currentPeriodIndex === -1) {
|
|
71
|
+
this._currentPeriodIndex = this.availablePeriods.default ?? 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
render() {
|
|
76
|
+
return html`
|
|
77
|
+
<div class="custom-toolbar">
|
|
78
|
+
<div class="header-bar">
|
|
79
|
+
${!this.hideNavigation ? html`
|
|
80
|
+
<div
|
|
81
|
+
class="view-controls"
|
|
82
|
+
@button-clicked="${this._navigationEvent}"
|
|
83
|
+
>
|
|
84
|
+
<pd-button
|
|
85
|
+
icon="${pdIcons.ICON_PREVIOUS}"
|
|
86
|
+
text=""
|
|
87
|
+
value="previous"
|
|
88
|
+
?disabled="${this.hidePrev}"
|
|
89
|
+
></pd-button>
|
|
90
|
+
<pd-button
|
|
91
|
+
icon="${pdIcons.ICON_NEXT}"
|
|
92
|
+
text=""
|
|
93
|
+
value="next"
|
|
94
|
+
?disabled="${this.hideNext}"
|
|
95
|
+
></pd-button>
|
|
96
|
+
</div>
|
|
97
|
+
` : ""}
|
|
98
|
+
|
|
99
|
+
<div id="titleContentId" class="view-title">
|
|
100
|
+
<div>
|
|
101
|
+
${this.currentTitle}
|
|
102
|
+
${this.withYearPopup.length > 0 ? html` <button
|
|
103
|
+
id="yearPopupTrigger"
|
|
104
|
+
class="year-popup-trigger"
|
|
105
|
+
type="button"
|
|
106
|
+
aria-haspopup="listbox"
|
|
107
|
+
aria-expanded="${this._openYearPopupState}"
|
|
108
|
+
@click=${this._openYearPopup}
|
|
109
|
+
@keydown=${this._onTriggerKeyDown}
|
|
110
|
+
>
|
|
111
|
+
${this.year}
|
|
112
|
+
</button>` : this.year === 0 ? "" : this.year}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div class="top-buttons">
|
|
118
|
+
<div class="view-range">
|
|
119
|
+
${this._currentViewOptions.length !== 1 ? html`
|
|
120
|
+
<pd-button-group
|
|
121
|
+
id="viewTypeSelectionId"
|
|
122
|
+
class="view-range-type-group"
|
|
123
|
+
.buttonList="${this._currentViewOptions}"
|
|
124
|
+
.initValue="${[this._currentViewTypeIndex]}"
|
|
125
|
+
@pd-button-group-change=${this._changeViewEvent}
|
|
126
|
+
></pd-button-group>
|
|
127
|
+
` : ""}
|
|
128
|
+
${this._currentPeriodOptions.length !== 1 ? html`
|
|
129
|
+
<pd-button-select-group
|
|
130
|
+
id="periodSelectionId"
|
|
131
|
+
class="view-period-range-select"
|
|
132
|
+
.options="${this._currentPeriodOptions}"
|
|
133
|
+
.initValue="${this._currentPeriodIndex}"
|
|
134
|
+
@pd-button-selection-changed=${this._changePeriodEvent}
|
|
135
|
+
></pd-button-select-group>
|
|
136
|
+
` : ""}
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
${this.withSettings ? html`
|
|
140
|
+
<div class="view-settings">
|
|
141
|
+
<pd-icon icon="${pdIcons.ICON_SETTINGS}" activeIcon></pd-icon>
|
|
142
|
+
</div>
|
|
143
|
+
` : ""}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
}
|
|
148
|
+
_navigationEvent(e) {
|
|
149
|
+
this.dispatchEvent(
|
|
150
|
+
new CustomEvent("pd-calendar-navigation", {
|
|
151
|
+
detail: {
|
|
152
|
+
previous: e.detail === "previous",
|
|
153
|
+
next: e.detail === "next"
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
e.stopPropagation();
|
|
158
|
+
}
|
|
159
|
+
_changeViewEvent(e) {
|
|
160
|
+
const selection = e.detail.selected;
|
|
161
|
+
const viewType = this.availableViewTypes?.viewTypes ? this.availableViewTypes.viewTypes[selection] : "list";
|
|
162
|
+
console.log("Selection: ", selection, viewType);
|
|
163
|
+
const detail = {
|
|
164
|
+
viewType,
|
|
165
|
+
updatePeriod: void 0
|
|
166
|
+
};
|
|
167
|
+
this.dispatchEvent(new CustomEvent("pd-calendar-change-view", { detail }));
|
|
168
|
+
if (detail.updatePeriod) {
|
|
169
|
+
console.log("Hier handeln: ", detail.updatePeriod);
|
|
170
|
+
this._periodSelectionEl.reset(1);
|
|
171
|
+
}
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
}
|
|
174
|
+
_changePeriodEvent(e) {
|
|
175
|
+
const selection = e.detail.selected;
|
|
176
|
+
const periodType = this.availablePeriods?.periods ? this.availablePeriods.periods[selection] : "Month";
|
|
177
|
+
console.log("Selection: ", selection, periodType);
|
|
178
|
+
const detail = {
|
|
179
|
+
periodType,
|
|
180
|
+
updateViewType: void 0
|
|
181
|
+
};
|
|
182
|
+
this.dispatchEvent(
|
|
183
|
+
new CustomEvent("pd-calendar-change-period", { detail })
|
|
184
|
+
);
|
|
185
|
+
if (detail.updateViewType) {
|
|
186
|
+
console.log("Hier handeln: ", detail.updateViewType);
|
|
187
|
+
this._viewTypeSelectionEl.reset(0);
|
|
188
|
+
}
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Opens the year selection popup with keyboard support.
|
|
193
|
+
*/
|
|
194
|
+
_onTriggerKeyDown(e) {
|
|
195
|
+
if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
this._openYearPopup();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Opens the year popup and manages focus.
|
|
202
|
+
*/
|
|
203
|
+
_openYearPopup() {
|
|
204
|
+
if (this._openYearPopupState) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this._openYearPopupState = true;
|
|
208
|
+
this.requestUpdate();
|
|
209
|
+
const popup = new PdYearPopup();
|
|
210
|
+
popup.yearSelection = this.withYearPopup;
|
|
211
|
+
popup.currentYear = this.year.toString();
|
|
212
|
+
this.shadowRoot?.getElementById("titleContentId")?.appendChild(popup);
|
|
213
|
+
const returnFocusToTrigger = () => {
|
|
214
|
+
this._openYearPopupState = false;
|
|
215
|
+
this.requestUpdate();
|
|
216
|
+
this.shadowRoot?.getElementById("titleContentId")?.removeChild(popup);
|
|
217
|
+
const trigger = this.shadowRoot?.getElementById(
|
|
218
|
+
"yearPopupTrigger"
|
|
219
|
+
);
|
|
220
|
+
trigger?.focus();
|
|
221
|
+
};
|
|
222
|
+
popup.addEventListener("abort-year-selection", () => {
|
|
223
|
+
returnFocusToTrigger();
|
|
224
|
+
});
|
|
225
|
+
popup.addEventListener("change-year-selection", (e) => {
|
|
226
|
+
const year = e.detail.year;
|
|
227
|
+
const newDate = new Date(this.currentDate || /* @__PURE__ */ new Date());
|
|
228
|
+
newDate.setFullYear(year);
|
|
229
|
+
this.dispatchEvent(
|
|
230
|
+
new CustomEvent("change-month", { detail: { newDate } })
|
|
231
|
+
);
|
|
232
|
+
this.dispatchEvent(
|
|
233
|
+
new CustomEvent("pd-calendar-navigation", {
|
|
234
|
+
detail: { newDate }
|
|
235
|
+
})
|
|
236
|
+
);
|
|
237
|
+
returnFocusToTrigger();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
CalendarButtonBar.styles = [
|
|
242
|
+
css`
|
|
243
|
+
:host {
|
|
244
|
+
display: block;
|
|
245
|
+
--my-button-size: var(--pd-cbar-title-button-size, 40px);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.custom-toolbar {
|
|
249
|
+
position: relative;
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-wrap: wrap-reverse;
|
|
252
|
+
justify-content: space-between;
|
|
253
|
+
margin: 0.4rem 0 0.3rem 0;
|
|
254
|
+
gap: 0.5rem;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.header-bar {
|
|
258
|
+
align-self: center;
|
|
259
|
+
flex: 1;
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: 5px;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.view-controls {
|
|
265
|
+
display: flex;
|
|
266
|
+
gap: 5px;
|
|
267
|
+
--pd-button-width: var(--my-button-size);
|
|
268
|
+
--pd-button-min-height: var(--my-button-size);
|
|
269
|
+
--pd-button-height: var(--my-button-size);
|
|
270
|
+
/* Check later --pd-button-border-radius: 10px; */
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.view-title {
|
|
274
|
+
flex: 1;
|
|
275
|
+
align-self: center;
|
|
276
|
+
text-align: var(--pd-cbar-title-align);
|
|
277
|
+
font-size: var(--pd-cbar-title-size, 1.4em);
|
|
278
|
+
color: var(--pd-cbar-title-col, var(--pd-default-font-title-col));
|
|
279
|
+
font-family: var(--pd-default-font-title-family);
|
|
280
|
+
font-weight: bold;
|
|
281
|
+
white-space: nowrap;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.top-buttons {
|
|
285
|
+
display: flex;
|
|
286
|
+
gap: 1em;
|
|
287
|
+
--pd-button-font-size: 85%;
|
|
288
|
+
justify-content: flex-end;
|
|
289
|
+
|
|
290
|
+
flex: 1;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
:host([hideButtonBar]) .top-buttons {
|
|
294
|
+
display: none;
|
|
295
|
+
flex: 0;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.view-range {
|
|
299
|
+
display: flex;
|
|
300
|
+
gap: 0.8rem;
|
|
301
|
+
|
|
302
|
+
--pd-button-border-col: var(--pd-default-light-col);
|
|
303
|
+
--pd-button-bg-col: var(--pd-default-lightest-col);
|
|
304
|
+
--pd-button-font-col: var(--pd-default-dark-col);
|
|
305
|
+
--pd-button-height: 2.2em;
|
|
306
|
+
--pd-button-selected-bg-col: var(--pd-secondary-light-col);
|
|
307
|
+
--pd-button-selected-shadow: none;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.view-range-type-group {
|
|
311
|
+
--pd-button-padding: 0;
|
|
312
|
+
--pd-button-width: 2.2em;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.view-range-type-select {
|
|
316
|
+
--pd-button-padding: 0;
|
|
317
|
+
--pd-button-width: 3.5em;
|
|
318
|
+
--pd-button-group-width: 3.5em;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.view-period-range-select {
|
|
322
|
+
--pd-button-padding: 0px 6px;
|
|
323
|
+
--pd-button-width: 5em;
|
|
324
|
+
--pd-button-group-width: 5em;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:host([isCompact]) .view-controls {
|
|
328
|
+
gap: 5px;
|
|
329
|
+
--my-button-size: calc(var(--pd-cbar-title-button-size, 40px) - 5px);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
:host([isCompact]) .view-title {
|
|
333
|
+
flex: 1;
|
|
334
|
+
align-self: flex-end;
|
|
335
|
+
text-align: center;
|
|
336
|
+
font-size: calc(var(--pd-cbar-title-size, 1.4em) - 3px);
|
|
337
|
+
font-weight: normal;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
:host([isCompact][hideButtonBar]) .view-title {
|
|
341
|
+
text-align: right;
|
|
342
|
+
align-self: center;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.view-settings {
|
|
346
|
+
display: flex;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.year-popup-trigger {
|
|
350
|
+
/* Reset button styles */
|
|
351
|
+
background: none;
|
|
352
|
+
border: none;
|
|
353
|
+
padding: 0;
|
|
354
|
+
margin: 0;
|
|
355
|
+
font: inherit;
|
|
356
|
+
|
|
357
|
+
/* Link-like appearance */
|
|
358
|
+
color: var(--pd-default-font-link-col);
|
|
359
|
+
text-decoration: underline;
|
|
360
|
+
cursor: pointer;
|
|
361
|
+
transition: color 0.15s ease;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.year-popup-trigger:hover {
|
|
365
|
+
color: var(--pd-default-hover-col);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.year-popup-trigger:focus {
|
|
369
|
+
outline: none;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.year-popup-trigger:focus-visible {
|
|
373
|
+
outline: 2px solid var(--pd-focus-ring-col);
|
|
374
|
+
outline-offset: 2px;
|
|
375
|
+
border-radius: 2px;
|
|
376
|
+
}
|
|
377
|
+
`
|
|
378
|
+
];
|
|
379
|
+
__decorateClass([
|
|
380
|
+
property({ type: Object })
|
|
381
|
+
], CalendarButtonBar.prototype, "availableViewTypes", 2);
|
|
382
|
+
__decorateClass([
|
|
383
|
+
property({ type: Object })
|
|
384
|
+
], CalendarButtonBar.prototype, "availablePeriods", 2);
|
|
385
|
+
__decorateClass([
|
|
386
|
+
property({ type: Array })
|
|
387
|
+
], CalendarButtonBar.prototype, "withYearPopup", 2);
|
|
388
|
+
__decorateClass([
|
|
389
|
+
property({ type: String })
|
|
390
|
+
], CalendarButtonBar.prototype, "currentTitle", 2);
|
|
391
|
+
__decorateClass([
|
|
392
|
+
property({ type: Object })
|
|
393
|
+
], CalendarButtonBar.prototype, "currentDate", 2);
|
|
394
|
+
__decorateClass([
|
|
395
|
+
property({ type: Number })
|
|
396
|
+
], CalendarButtonBar.prototype, "year", 2);
|
|
397
|
+
__decorateClass([
|
|
398
|
+
property({ type: Boolean })
|
|
399
|
+
], CalendarButtonBar.prototype, "withSettings", 2);
|
|
400
|
+
__decorateClass([
|
|
401
|
+
property({ type: Boolean })
|
|
402
|
+
], CalendarButtonBar.prototype, "hideNext", 2);
|
|
403
|
+
__decorateClass([
|
|
404
|
+
property({ type: Boolean })
|
|
405
|
+
], CalendarButtonBar.prototype, "hidePrev", 2);
|
|
406
|
+
__decorateClass([
|
|
407
|
+
property({ type: Boolean })
|
|
408
|
+
], CalendarButtonBar.prototype, "hideNavigation", 2);
|
|
409
|
+
__decorateClass([
|
|
410
|
+
property({ type: Boolean, reflect: true })
|
|
411
|
+
], CalendarButtonBar.prototype, "isCompact", 2);
|
|
412
|
+
__decorateClass([
|
|
413
|
+
state()
|
|
414
|
+
], CalendarButtonBar.prototype, "_currentViewOptions", 2);
|
|
415
|
+
__decorateClass([
|
|
416
|
+
state()
|
|
417
|
+
], CalendarButtonBar.prototype, "_currentPeriodOptions", 2);
|
|
418
|
+
__decorateClass([
|
|
419
|
+
state()
|
|
420
|
+
], CalendarButtonBar.prototype, "_currentViewTypeIndex", 2);
|
|
421
|
+
__decorateClass([
|
|
422
|
+
state()
|
|
423
|
+
], CalendarButtonBar.prototype, "_currentPeriodIndex", 2);
|
|
424
|
+
__decorateClass([
|
|
425
|
+
query("#viewTypeSelectionId")
|
|
426
|
+
], CalendarButtonBar.prototype, "_viewTypeSelectionEl", 2);
|
|
427
|
+
__decorateClass([
|
|
428
|
+
query("#periodSelectionId")
|
|
429
|
+
], CalendarButtonBar.prototype, "_periodSelectionEl", 2);
|
|
430
|
+
CalendarButtonBar = __decorateClass([
|
|
431
|
+
customElement("calendar-button-bar"),
|
|
432
|
+
localized()
|
|
433
|
+
], CalendarButtonBar);
|
|
434
|
+
|
|
435
|
+
export { CalendarButtonBar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-locales.d.ts","sourceRoot":"","sources":["../../src/shared/calendar-locales.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;CAwBtB,CAAC;AAEH,eAAO,MAAM,OAAO;;;CAAgB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { msg } from '@lit/localize';
|
|
2
|
+
|
|
3
|
+
const loadLocales = () => ({
|
|
4
|
+
monthNames: [
|
|
5
|
+
msg("Januar", { id: "pd.datepicker.month.jan" }),
|
|
6
|
+
msg("Februar", { id: "pd.datepicker.month.feb" }),
|
|
7
|
+
msg("März", { id: "pd.datepicker.month.mar" }),
|
|
8
|
+
msg("April", { id: "pd.datepicker.month.apr" }),
|
|
9
|
+
msg("Mai", { id: "pd.datepicker.month.may" }),
|
|
10
|
+
msg("Juni", { id: "pd.datepicker.month.jun" }),
|
|
11
|
+
msg("Juli", { id: "pd.datepicker.month.jul" }),
|
|
12
|
+
msg("August", { id: "pd.datepicker.month.aug" }),
|
|
13
|
+
msg("September", { id: "pd.datepicker.month.sep" }),
|
|
14
|
+
msg("Oktober", { id: "pd.datepicker.month.oct" }),
|
|
15
|
+
msg("November", { id: "pd.datepicker.month.nov" }),
|
|
16
|
+
msg("Dezember", { id: "pd.datepicker.month.dec" })
|
|
17
|
+
],
|
|
18
|
+
weekdaysShort: [
|
|
19
|
+
msg("Mo", { id: "pd.datepicker.shortday.mon" }),
|
|
20
|
+
msg("Di", { id: "pd.datepicker.shortday.tue" }),
|
|
21
|
+
msg("Mi", { id: "pd.datepicker.shortday.wed" }),
|
|
22
|
+
msg("Do", { id: "pd.datepicker.shortday.thi" }),
|
|
23
|
+
msg("Fr", { id: "pd.datepicker.shortday.fri" }),
|
|
24
|
+
msg("Sa", { id: "pd.datepicker.shortday.sat" }),
|
|
25
|
+
msg("So", { id: "pd.datepicker.shortday.sun" })
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
const LOCALES = loadLocales();
|
|
29
|
+
|
|
30
|
+
export { LOCALES, loadLocales };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CalendarWeek } from '../types.js';
|
|
2
|
+
export declare function isToday(date?: Date): boolean;
|
|
3
|
+
export declare function isSelected(date1?: Date, date2?: Date): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Generates a 2D array of weeks for a given month.
|
|
6
|
+
* Each week contains 7 days (or 5 if hideWeekend).
|
|
7
|
+
* null values represent empty padding cells.
|
|
8
|
+
*
|
|
9
|
+
* @param year - Full year (e.g. 2026)
|
|
10
|
+
* @param month - Zero-based month (0 = January)
|
|
11
|
+
* @param hideWeekend - If true, excludes Saturday and Sunday (5 columns)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getWeeksArray(year: number, month: number, hideWeekend: boolean): CalendarWeek[];
|
|
14
|
+
export interface OverlapEvent {
|
|
15
|
+
startDecimal: number;
|
|
16
|
+
endDecimal: number;
|
|
17
|
+
index: number;
|
|
18
|
+
}
|
|
19
|
+
export interface OverlapResult {
|
|
20
|
+
index: number;
|
|
21
|
+
column: number;
|
|
22
|
+
totalColumns: number;
|
|
23
|
+
startDecimal: number;
|
|
24
|
+
endDecimal: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Google Calendar-style overlap layout.
|
|
28
|
+
* Assigns column positions to overlapping events so they render side by side.
|
|
29
|
+
*
|
|
30
|
+
* Events are grouped into clusters (connected components of overlap).
|
|
31
|
+
* Within each cluster, events are greedily assigned to the first available column.
|
|
32
|
+
*/
|
|
33
|
+
export declare function layoutOverlappingEvents(events: OverlapEvent[]): OverlapResult[];
|
|
34
|
+
//# sourceMappingURL=calendar-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-utils.d.ts","sourceRoot":"","sources":["../../src/shared/calendar-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAQ5C;AAED,wBAAgB,UAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAQ9D;AAMD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,OAAO,GACnB,YAAY,EAAE,CAgDhB;AAMD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EAAE,GACrB,aAAa,EAAE,CAgEjB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
function isToday(date) {
|
|
2
|
+
const today = /* @__PURE__ */ new Date();
|
|
3
|
+
return !!date && date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
|
|
4
|
+
}
|
|
5
|
+
function isSelected(date1, date2) {
|
|
6
|
+
return !!date1 && !!date2 && date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
|
|
7
|
+
}
|
|
8
|
+
function getWeeksArray(year, month, hideWeekend) {
|
|
9
|
+
const weeks = [];
|
|
10
|
+
let currentWeek = [];
|
|
11
|
+
const daysPerWeek = hideWeekend ? 5 : 7;
|
|
12
|
+
const numberOfDays = new Date(year, month + 1, 0).getDate();
|
|
13
|
+
let firstWeekdayOfMonth = new Date(year, month, 1).getDay();
|
|
14
|
+
let firstDayNumber = 1;
|
|
15
|
+
if (hideWeekend) {
|
|
16
|
+
while (firstWeekdayOfMonth === 0 || firstWeekdayOfMonth === 6) {
|
|
17
|
+
firstDayNumber++;
|
|
18
|
+
firstWeekdayOfMonth = new Date(year, month, firstDayNumber).getDay();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const paddingDays = (firstWeekdayOfMonth + 6) % 7;
|
|
22
|
+
for (let i = 0; i < paddingDays; i++) {
|
|
23
|
+
currentWeek.push(null);
|
|
24
|
+
}
|
|
25
|
+
for (let day = 1; day <= numberOfDays; day++) {
|
|
26
|
+
const date = new Date(year, month, day);
|
|
27
|
+
const dayOfWeek = date.getDay();
|
|
28
|
+
if (hideWeekend && (dayOfWeek === 0 || dayOfWeek === 6)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
currentWeek.push(date);
|
|
32
|
+
if (currentWeek.length === daysPerWeek) {
|
|
33
|
+
weeks.push(currentWeek);
|
|
34
|
+
currentWeek = [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (currentWeek.length > 0) {
|
|
38
|
+
while (currentWeek.length < daysPerWeek) {
|
|
39
|
+
currentWeek.push(null);
|
|
40
|
+
}
|
|
41
|
+
weeks.push(currentWeek);
|
|
42
|
+
}
|
|
43
|
+
return weeks;
|
|
44
|
+
}
|
|
45
|
+
function layoutOverlappingEvents(events) {
|
|
46
|
+
if (events.length === 0) return [];
|
|
47
|
+
const sorted = [...events].sort((a, b) => {
|
|
48
|
+
if (a.startDecimal !== b.startDecimal)
|
|
49
|
+
return a.startDecimal - b.startDecimal;
|
|
50
|
+
return b.endDecimal - b.startDecimal - (a.endDecimal - a.startDecimal);
|
|
51
|
+
});
|
|
52
|
+
const clusters = [];
|
|
53
|
+
let currentCluster = [sorted[0]];
|
|
54
|
+
let clusterEnd = sorted[0].endDecimal;
|
|
55
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
56
|
+
if (sorted[i].startDecimal < clusterEnd) {
|
|
57
|
+
currentCluster.push(sorted[i]);
|
|
58
|
+
clusterEnd = Math.max(clusterEnd, sorted[i].endDecimal);
|
|
59
|
+
} else {
|
|
60
|
+
clusters.push(currentCluster);
|
|
61
|
+
currentCluster = [sorted[i]];
|
|
62
|
+
clusterEnd = sorted[i].endDecimal;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
clusters.push(currentCluster);
|
|
66
|
+
const result = [];
|
|
67
|
+
for (const cluster of clusters) {
|
|
68
|
+
const columnEnds = [];
|
|
69
|
+
const assignments = [];
|
|
70
|
+
for (const event of cluster) {
|
|
71
|
+
let col = -1;
|
|
72
|
+
for (let c = 0; c < columnEnds.length; c++) {
|
|
73
|
+
if (columnEnds[c] <= event.startDecimal) {
|
|
74
|
+
col = c;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (col === -1) {
|
|
79
|
+
col = columnEnds.length;
|
|
80
|
+
columnEnds.push(0);
|
|
81
|
+
}
|
|
82
|
+
columnEnds[col] = event.endDecimal;
|
|
83
|
+
assignments.push({ event, column: col });
|
|
84
|
+
}
|
|
85
|
+
const totalColumns = columnEnds.length;
|
|
86
|
+
for (const { event, column } of assignments) {
|
|
87
|
+
result.push({
|
|
88
|
+
index: event.index,
|
|
89
|
+
column,
|
|
90
|
+
totalColumns,
|
|
91
|
+
startDecimal: event.startDecimal,
|
|
92
|
+
endDecimal: event.endDecimal
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { getWeeksArray, isSelected, isToday, layoutOverlappingEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-utils.test.d.ts","sourceRoot":"","sources":["../../src/shared/calendar-utils.test.ts"],"names":[],"mappings":""}
|