@progressive-development/pd-calendar 0.6.8 → 1.0.0

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.
Files changed (141) hide show
  1. package/LICENSE +21 -2
  2. package/README.md +32 -57
  3. package/dist/generated/locales/be.d.ts +7 -0
  4. package/dist/generated/locales/be.d.ts.map +1 -1
  5. package/dist/generated/locales/de.d.ts +7 -0
  6. package/dist/generated/locales/de.d.ts.map +1 -1
  7. package/dist/generated/locales/en.d.ts +7 -0
  8. package/dist/generated/locales/en.d.ts.map +1 -1
  9. package/dist/index.d.ts +12 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +23 -10
  12. package/dist/locales/be.js +10 -4
  13. package/dist/locales/de.js +10 -4
  14. package/dist/locales/en.js +10 -4
  15. package/dist/pd-calendar/PdCalendar.d.ts +133 -0
  16. package/dist/pd-calendar/PdCalendar.d.ts.map +1 -0
  17. package/dist/pd-calendar/PdCalendar.js +550 -0
  18. package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts +56 -0
  19. package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts.map +1 -0
  20. package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.js +337 -0
  21. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts +3 -0
  22. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts.map +1 -0
  23. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.js +8 -0
  24. package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.d.ts +27 -0
  25. package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.d.ts.map +1 -0
  26. package/dist/pd-calendar/pd-calendar-day-events-panel/PdCalendarDayEventsPanel.js +160 -0
  27. package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.d.ts +3 -0
  28. package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.d.ts.map +1 -0
  29. package/dist/pd-calendar/pd-calendar-day-events-panel/pd-calendar-day-events-panel.js +8 -0
  30. package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.d.ts +55 -0
  31. package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.d.ts.map +1 -0
  32. package/dist/pd-calendar/pd-calendar-event-cell/PdCalendarEventCell.js +341 -0
  33. package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.d.ts +3 -0
  34. package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.d.ts.map +1 -0
  35. package/dist/pd-calendar/pd-calendar-event-cell/pd-calendar-event-cell.js +8 -0
  36. package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.d.ts +29 -0
  37. package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.d.ts.map +1 -0
  38. package/dist/pd-calendar/pd-calendar-event-info-panel/PdCalendarEventInfoPanel.js +211 -0
  39. package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.d.ts +3 -0
  40. package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.d.ts.map +1 -0
  41. package/dist/pd-calendar/pd-calendar-event-info-panel/pd-calendar-event-info-panel.js +8 -0
  42. package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.d.ts +28 -0
  43. package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.d.ts.map +1 -0
  44. package/dist/pd-calendar/pd-calendar-list-cell/PdCalendarListCell.js +252 -0
  45. package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.d.ts +3 -0
  46. package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.d.ts.map +1 -0
  47. package/dist/pd-calendar/pd-calendar-list-cell/pd-calendar-list-cell.js +8 -0
  48. package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.d.ts +26 -0
  49. package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.d.ts.map +1 -0
  50. package/dist/pd-calendar/pd-calendar-list-view/PdCalendarListView.js +165 -0
  51. package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.d.ts +3 -0
  52. package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.d.ts.map +1 -0
  53. package/dist/pd-calendar/pd-calendar-list-view/pd-calendar-list-view.js +8 -0
  54. package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.d.ts +55 -0
  55. package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.d.ts.map +1 -0
  56. package/dist/pd-calendar/pd-calendar-month-view/PdCalendarMonthView.js +461 -0
  57. package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.d.ts +3 -0
  58. package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.d.ts.map +1 -0
  59. package/dist/pd-calendar/pd-calendar-month-view/pd-calendar-month-view.js +8 -0
  60. package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.d.ts +32 -0
  61. package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.d.ts.map +1 -0
  62. package/dist/pd-calendar/pd-calendar-time-grid-view/PdCalendarTimeGridView.js +468 -0
  63. package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.d.ts +3 -0
  64. package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.d.ts.map +1 -0
  65. package/dist/pd-calendar/pd-calendar-time-grid-view/pd-calendar-time-grid-view.js +8 -0
  66. package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.d.ts +31 -0
  67. package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.d.ts.map +1 -0
  68. package/dist/pd-calendar/pd-calendar-week-cell/PdCalendarWeekCell.js +134 -0
  69. package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.d.ts +3 -0
  70. package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.d.ts.map +1 -0
  71. package/dist/pd-calendar/pd-calendar-week-cell/pd-calendar-week-cell.js +8 -0
  72. package/dist/pd-calendar/pd-calendar.d.ts +3 -0
  73. package/dist/pd-calendar/pd-calendar.d.ts.map +1 -0
  74. package/dist/pd-calendar/pd-calendar.stories.d.ts +83 -0
  75. package/dist/pd-calendar/pd-calendar.stories.d.ts.map +1 -0
  76. package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts +38 -0
  77. package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts.map +1 -0
  78. package/dist/pd-calendar/pd-year-popup/PdYearPopup.js +249 -0
  79. package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts +3 -0
  80. package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts.map +1 -0
  81. package/dist/pd-calendar/pd-year-popup/pd-year-popup.js +8 -0
  82. package/dist/pd-calendar.d.ts +2 -48
  83. package/dist/pd-calendar.js +6 -437
  84. package/dist/pd-datepicker/PdDatepicker.d.ts +181 -0
  85. package/dist/pd-datepicker/PdDatepicker.d.ts.map +1 -0
  86. package/dist/pd-datepicker/PdDatepicker.js +701 -0
  87. package/dist/pd-datepicker/pd-date-picker.stories.d.ts +81 -0
  88. package/dist/pd-datepicker/pd-date-picker.stories.d.ts.map +1 -0
  89. package/dist/pd-datepicker/pd-datepicker.d.ts +3 -0
  90. package/dist/pd-datepicker/pd-datepicker.d.ts.map +1 -0
  91. package/dist/pd-datepicker.d.ts +2 -0
  92. package/dist/pd-datepicker.js +8 -0
  93. package/dist/pd-slot-picker/PdSlotPicker.d.ts +102 -0
  94. package/dist/pd-slot-picker/PdSlotPicker.d.ts.map +1 -0
  95. package/dist/pd-slot-picker/PdSlotPicker.js +339 -0
  96. package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.d.ts +35 -0
  97. package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.d.ts.map +1 -0
  98. package/dist/pd-slot-picker/pd-slot-cell/PdSlotCell.js +188 -0
  99. package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.d.ts +3 -0
  100. package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.d.ts.map +1 -0
  101. package/dist/pd-slot-picker/pd-slot-cell/pd-slot-cell.js +8 -0
  102. package/dist/pd-slot-picker/pd-slot-picker.d.ts +3 -0
  103. package/dist/pd-slot-picker/pd-slot-picker.d.ts.map +1 -0
  104. package/dist/pd-slot-picker/pd-slot-picker.stories.d.ts +67 -0
  105. package/dist/pd-slot-picker/pd-slot-picker.stories.d.ts.map +1 -0
  106. package/dist/pd-slot-picker.d.ts +2 -0
  107. package/dist/pd-slot-picker.js +8 -0
  108. package/dist/shared/PdBaseCell.d.ts +68 -0
  109. package/dist/shared/PdBaseCell.d.ts.map +1 -0
  110. package/dist/shared/PdBaseCell.js +120 -0
  111. package/dist/shared/PdBaseView.d.ts +22 -0
  112. package/dist/shared/PdBaseView.d.ts.map +1 -0
  113. package/dist/shared/PdBaseView.js +46 -0
  114. package/dist/shared/PdCalendarPanelBase.d.ts +34 -0
  115. package/dist/shared/PdCalendarPanelBase.d.ts.map +1 -0
  116. package/dist/shared/PdCalendarPanelBase.js +169 -0
  117. package/dist/shared/calendar-button-bar/calendar-button-bar.d.ts +41 -0
  118. package/dist/shared/calendar-button-bar/calendar-button-bar.d.ts.map +1 -0
  119. package/dist/shared/calendar-button-bar/calendar-button-bar.js +435 -0
  120. package/dist/shared/calendar-locales.d.ts +9 -0
  121. package/dist/shared/calendar-locales.d.ts.map +1 -0
  122. package/dist/shared/calendar-locales.js +30 -0
  123. package/dist/shared/calendar-utils.d.ts +34 -0
  124. package/dist/shared/calendar-utils.d.ts.map +1 -0
  125. package/dist/shared/calendar-utils.js +99 -0
  126. package/dist/shared/calendar-utils.test.d.ts +2 -0
  127. package/dist/shared/calendar-utils.test.d.ts.map +1 -0
  128. package/dist/types.d.ts +102 -1
  129. package/dist/types.d.ts.map +1 -1
  130. package/package.json +35 -47
  131. package/dist/pd-calendar-cell.d.ts +0 -47
  132. package/dist/pd-calendar-cell.d.ts.map +0 -1
  133. package/dist/pd-calendar-cell.js +0 -282
  134. package/dist/pd-calendar.d.ts.map +0 -1
  135. package/dist/pd-year-popup.d.ts +0 -25
  136. package/dist/pd-year-popup.d.ts.map +0 -1
  137. package/dist/pd-year-popup.js +0 -136
  138. package/dist/stories/cell.stories.d.ts +0 -15
  139. package/dist/stories/cell.stories.d.ts.map +0 -1
  140. package/dist/stories/index.stories.d.ts +0 -23
  141. package/dist/stories/index.stories.d.ts.map +0 -1
@@ -0,0 +1,701 @@
1
+ import { css, nothing, html } from 'lit';
2
+ import { localized, msg } from '@lit/localize';
3
+ import { property, state } from 'lit/decorators.js';
4
+ import { parse, format } from 'date-fns';
5
+ import { PdBaseInputElement } from '@progressive-development/pd-forms';
6
+ import { pdIcons } from '@progressive-development/pd-icon';
7
+ import '@progressive-development/pd-forms/pd-input';
8
+ import '@progressive-development/pd-forms/pd-button';
9
+ import '@progressive-development/pd-forms/pd-select';
10
+ import '../pd-calendar.js';
11
+
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __decorateClass = (decorators, target, key, kind) => {
15
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
16
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
17
+ if (decorator = decorators[i])
18
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
19
+ if (kind && result) __defProp(target, key, result);
20
+ return result;
21
+ };
22
+ const UNDEF = "UNDEF";
23
+ const INPUT_TYPE_DATE = 7;
24
+ const DEFAULT_FORMAT = "yyyy-MM-dd";
25
+ const TIME_VALUES = [
26
+ { name: "07:00", value: "07:00" },
27
+ { name: "07:30", value: "07:30" },
28
+ { name: "08:00", value: "08:00" },
29
+ { name: "08:30", value: "08:30" },
30
+ { name: "09:00", value: "09:00" },
31
+ { name: "09:30", value: "09:30" },
32
+ { name: "10:00", value: "10:00" },
33
+ { name: "10:30", value: "10:30" },
34
+ { name: "11:00", value: "11:00" },
35
+ { name: "11:30", value: "11:30" },
36
+ { name: "12:00", value: "12:00" },
37
+ { name: "12:30", value: "12:30" },
38
+ { name: "13:00", value: "13:00" },
39
+ { name: "13:30", value: "13:30" },
40
+ { name: "14:00", value: "14:00" },
41
+ { name: "14:30", value: "14:30" },
42
+ { name: "15:00", value: "15:00" },
43
+ { name: "15:30", value: "15:30" },
44
+ { name: "16:00", value: "16:00" },
45
+ { name: "16:30", value: "16:30" },
46
+ { name: "17:00", value: "17:00" },
47
+ { name: "17:30", value: "17:30" },
48
+ { name: "18:00", value: "18:00" },
49
+ { name: "18:30", value: "18:30" },
50
+ { name: "19:00", value: "19:00" },
51
+ { name: "19:30", value: "19:30" }
52
+ ];
53
+ function getDateRangeValue(start, end, formatStr = DEFAULT_FORMAT) {
54
+ return `${start ? format(start, formatStr) : "--"} - ${end ? format(end, formatStr) : "--"}`;
55
+ }
56
+ function getDateTimeValue(date, time, formatStr = DEFAULT_FORMAT) {
57
+ return `${date ? format(date, formatStr) : ""} ${time && time !== UNDEF ? time : ""}`;
58
+ }
59
+ function getDataForDaysBetween(start, end) {
60
+ const result = {};
61
+ let from = new Date(start);
62
+ let to = new Date(end);
63
+ if (from > to) [from, to] = [to, from];
64
+ while (from <= to) {
65
+ result[format(from, DEFAULT_FORMAT)] = [{ category: "range" }];
66
+ from.setDate(from.getDate() + 1);
67
+ }
68
+ return result;
69
+ }
70
+ let PdDatepicker = class extends PdBaseInputElement {
71
+ constructor() {
72
+ super();
73
+ this.dateRange = false;
74
+ this.hideToday = false;
75
+ this.withYearPopup = [];
76
+ this.withTime = false;
77
+ this.disabledDays = [];
78
+ this.modal = false;
79
+ this.modalBreakpoint = 480;
80
+ this._showCalendar = false;
81
+ this._timeSelection = UNDEF;
82
+ this._useModal = false;
83
+ this._displayedMonth = /* @__PURE__ */ new Date();
84
+ /** @ignore */
85
+ this._calendarPosition = "bottom";
86
+ this._inputType = INPUT_TYPE_DATE;
87
+ this._validators = [this._requiredDateTimeValidator.bind(this)];
88
+ }
89
+ /** Time selection options with i18n placeholder. */
90
+ get _timeOptions() {
91
+ return [
92
+ {
93
+ name: msg("Uhrzeit auswählen", { id: "pd.datepicker.selectTime" }),
94
+ value: UNDEF
95
+ },
96
+ ...TIME_VALUES
97
+ ];
98
+ }
99
+ disconnectedCallback() {
100
+ super.disconnectedCallback();
101
+ if (this._boundHandleClickOutside) {
102
+ document.removeEventListener("click", this._boundHandleClickOutside);
103
+ this._boundHandleClickOutside = void 0;
104
+ }
105
+ if (this._useModal && this._showCalendar) {
106
+ document.body.style.overflow = "";
107
+ }
108
+ }
109
+ _requiredDateTimeValidator() {
110
+ return this.required && !this._startDateValue || this.dateRange && this._startDateValue && !this._endDateValue || this.withTime && this._startDateValue && this._timeSelection === UNDEF ? msg("Eingabe unvollständig", {
111
+ id: "pd.form.field.selectDateTimeRequired"
112
+ }) : null;
113
+ }
114
+ update(changedProps) {
115
+ if (changedProps.has("initialDate") && this.initialDate) {
116
+ this._prepareFieldsFromInitDate();
117
+ this._updateInputField(this.handleChangeForInitVal, void 0);
118
+ }
119
+ super.update(changedProps);
120
+ }
121
+ render() {
122
+ const popupId = `${this.id || "datepicker"}-popup`;
123
+ return html`
124
+ <pd-input
125
+ id="datePickerId"
126
+ .label="${this.label}"
127
+ .placeHolder="${this.placeHolder}"
128
+ .icon="${pdIcons.ICON_DATE}"
129
+ .initValue="${this._value}"
130
+ ?readonly=${true}
131
+ ?required="${this.required}"
132
+ ?disabled="${this.disabled}"
133
+ icon-right
134
+ aria-haspopup="dialog"
135
+ aria-expanded="${this._showCalendar}"
136
+ aria-controls="${popupId}"
137
+ @click="${this._inputClick}"
138
+ @keydown="${this._onInputKeyDown}"
139
+ @pd-form-element-change="${this._innerFormChange}"
140
+ @pd-form-element-blur="${this._innerBlur}"
141
+ @pd-form-element-focus="${this._innerFocus}"
142
+ @pd-form-element-register="${this._innerRegister}"
143
+ @enter-pressed="${this._innerEnter}"
144
+ ></pd-input>
145
+ ${this._renderErrorMsg()}
146
+ <div
147
+ class="modal-backdrop ${this._useModal ? "active" : ""}"
148
+ @click="${this._closeCalendar}"
149
+ ></div>
150
+ <div
151
+ id="${popupId}"
152
+ class="calendar-small ${this._useModal ? "modal" : this._calendarPosition}"
153
+ role="dialog"
154
+ aria-modal="true"
155
+ aria-label="${msg("Datum auswählen", {
156
+ id: "pd.datepicker.selectDate"
157
+ })}"
158
+ @keydown="${this._onPopupKeyDown}"
159
+ >
160
+ <pd-calendar
161
+ .withYearPopup="${this.withYearPopup}"
162
+ .refDate="${this._startDateValue}"
163
+ .data="${this._buildConstrainedData(this._displayedMonth)}"
164
+ numberClass="center"
165
+ selectableDates
166
+ showSelection
167
+ withWheelNavigation
168
+ withTouchNavigation
169
+ prevMonthConstraint="-1"
170
+ nextMonthConstraint="-1"
171
+ @select-date="${this._triggerCalendarDateSelected}"
172
+ @mouse-enter-date="${this._triggerHoverCalculateRange}"
173
+ @change-month="${this._onCalendarMonthChange}"
174
+ ></pd-calendar>
175
+
176
+ ${this.withTime ? html`
177
+ <pd-select
178
+ class="date-time-select"
179
+ id="dateTimeSelectId"
180
+ .values="${this._timeOptions}"
181
+ label="${msg("Uhrzeit", { id: "pd.datepicker.time" })}"
182
+ initValue="${this._timeSelection}"
183
+ required
184
+ @pd-form-element-change="${(e) => {
185
+ this._timeSelection = e.detail.value;
186
+ e.stopPropagation();
187
+ }}"
188
+ @pd-form-element-blur="${this._innerBlur}"
189
+ @pd-form-element-focus="${this._innerFocus}"
190
+ @pd-form-element-register="${this._innerRegister}"
191
+ @enter-pressed="${this._innerEnter}"
192
+ ></pd-select>
193
+ ` : nothing}
194
+
195
+ <div class="bottom-buttons">
196
+ ${!this.hideToday && !this.dateRange ? html`<pd-button
197
+ text="${msg("Heute", { id: "pd.datepicker.today" })}"
198
+ @button-clicked="${this._triggerSetTodayButton}"
199
+ ></pd-button>` : nothing}
200
+ <pd-button
201
+ text="${msg("Reset", { id: "pd.datepicker.reset" })}"
202
+ @button-clicked="${this._triggerResetButton}"
203
+ ></pd-button>
204
+ ${this.withTime ? html`
205
+ <pd-button
206
+ id="buttonSetValueId"
207
+ text="Ok"
208
+ ?disabled="${!this._startDateValue || this._timeSelection === UNDEF}"
209
+ @button-clicked="${this._triggerSetValueButton}"
210
+ ></pd-button>
211
+ ` : ""}
212
+ </div>
213
+ </div>
214
+ `;
215
+ }
216
+ /**
217
+ * Getter for outside call.
218
+ *
219
+ * @returns obj: { start?: Date; end?: Date } - the prepared date values.
220
+ */
221
+ get dateValues() {
222
+ const start = this.withTime && this._startDateValue ? parse(
223
+ `${format(this._startDateValue, "yyyy-MM-dd")} ${this._timeSelection}`,
224
+ "yyyy-MM-dd HH:mm",
225
+ /* @__PURE__ */ new Date()
226
+ ) : this._startDateValue;
227
+ return { start, end: this._endDateValue };
228
+ }
229
+ reset() {
230
+ if (this.initialDate) {
231
+ this._prepareFieldsFromInitDate();
232
+ } else {
233
+ this._clearFields();
234
+ }
235
+ super.reset();
236
+ }
237
+ clear() {
238
+ this._clearFields();
239
+ this._updateInputField(true, void 0);
240
+ }
241
+ /**
242
+ * @returns formated value from current field selections.
243
+ */
244
+ _getInitialValue() {
245
+ return this._formatDateValue();
246
+ }
247
+ /**
248
+ * Returns the parsed date values.
249
+ * @returns Object with start and optional end date: `{ start?: Date; end?: Date }`
250
+ */
251
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
+ _getParsedValue() {
253
+ return this.dateValues;
254
+ }
255
+ /**
256
+ * Init _startDateValue and _timeSelection from initial date.
257
+ */
258
+ _prepareFieldsFromInitDate() {
259
+ if (this.initialDate) {
260
+ this._startDateValue = new Date(
261
+ this.initialDate.getFullYear(),
262
+ this.initialDate.getMonth(),
263
+ this.initialDate.getDate()
264
+ );
265
+ if (this.withTime) {
266
+ this._timeSelection = format(this.initialDate, "HH:mm");
267
+ }
268
+ }
269
+ }
270
+ /**
271
+ * Clear _startDateValue and _timeSelection.
272
+ */
273
+ _clearFields() {
274
+ this._startDateValue = void 0;
275
+ this._endDateValue = void 0;
276
+ this._rangeSelection = void 0;
277
+ this._timeSelection = UNDEF;
278
+ }
279
+ /**
280
+ * Update element value from input fields.
281
+ */
282
+ _updateInputField(dispatchEvent, e) {
283
+ this._handleChangedValue(
284
+ this._formatDateValue(),
285
+ e,
286
+ dispatchEvent,
287
+ false,
288
+ void 0
289
+ );
290
+ }
291
+ /**
292
+ * Toggle view calendar on click into pd-input field.
293
+ */
294
+ _inputClick() {
295
+ if (this._showCalendar) {
296
+ this._closeCalendar();
297
+ } else {
298
+ this._openCalendar();
299
+ }
300
+ }
301
+ /**
302
+ * Handle keyboard events on the input field.
303
+ * Enter toggles calendar, Space/ArrowDown opens, Escape closes.
304
+ */
305
+ _onInputKeyDown(e) {
306
+ switch (e.key) {
307
+ case " ":
308
+ case "Enter":
309
+ e.preventDefault();
310
+ if (this._showCalendar) {
311
+ this._closeCalendar();
312
+ } else {
313
+ this._openCalendar();
314
+ }
315
+ break;
316
+ case "ArrowDown":
317
+ e.preventDefault();
318
+ if (!this._showCalendar) this._openCalendar();
319
+ break;
320
+ case "Escape":
321
+ if (this._showCalendar) {
322
+ e.preventDefault();
323
+ this._closeCalendar();
324
+ }
325
+ break;
326
+ }
327
+ }
328
+ /**
329
+ * Handle keyboard events within the popup.
330
+ */
331
+ _onPopupKeyDown(e) {
332
+ if (e.key === "Escape") {
333
+ e.preventDefault();
334
+ e.stopPropagation();
335
+ this._closeCalendar();
336
+ }
337
+ }
338
+ /**
339
+ * Open the calendar popup.
340
+ */
341
+ _openCalendar() {
342
+ this._displayedMonth = this._startDateValue || /* @__PURE__ */ new Date();
343
+ this._useModal = this.modal || window.innerWidth < this.modalBreakpoint;
344
+ if (!this._useModal) {
345
+ const input = this.shadowRoot?.getElementById("datePickerId");
346
+ if (input) {
347
+ const rect = input.getBoundingClientRect();
348
+ const spaceBelow = window.innerHeight - rect.bottom;
349
+ const spaceAbove = rect.top;
350
+ this._calendarPosition = spaceBelow < 380 && spaceAbove > spaceBelow ? "top" : "bottom";
351
+ }
352
+ }
353
+ if (this._useModal) {
354
+ document.body.style.overflow = "hidden";
355
+ }
356
+ this._showCalendar = true;
357
+ if (!this._useModal) {
358
+ setTimeout(() => {
359
+ this._boundHandleClickOutside = this._handleClickOutside.bind(this);
360
+ document.addEventListener("click", this._boundHandleClickOutside);
361
+ }, 0);
362
+ }
363
+ }
364
+ /**
365
+ * Close the calendar popup and return focus to input.
366
+ */
367
+ _closeCalendar() {
368
+ this._showCalendar = false;
369
+ if (this._useModal) {
370
+ document.body.style.overflow = "";
371
+ }
372
+ if (this._boundHandleClickOutside) {
373
+ document.removeEventListener("click", this._boundHandleClickOutside);
374
+ this._boundHandleClickOutside = void 0;
375
+ }
376
+ const input = this.shadowRoot?.getElementById(
377
+ "datePickerId"
378
+ );
379
+ input?.focus();
380
+ }
381
+ /**
382
+ * Handle clicks outside the popup.
383
+ */
384
+ _handleClickOutside(e) {
385
+ const path = e.composedPath();
386
+ if (!path.includes(this)) {
387
+ this._closeCalendar();
388
+ }
389
+ }
390
+ /**
391
+ * Triggered by date selection in small calendar.
392
+ * Set internal values depending on daterange configuration.
393
+ *
394
+ * @param e Event from small calendar.
395
+ */
396
+ _triggerCalendarDateSelected(e) {
397
+ const date = e.detail.date;
398
+ if (this.dateRange) {
399
+ if (!this._startDateValue) {
400
+ this._startDateValue = date;
401
+ this._endDateValue = void 0;
402
+ } else if (!this._endDateValue) {
403
+ if (date.getTime() < this._startDateValue.getTime()) {
404
+ this._endDateValue = this._startDateValue;
405
+ this._startDateValue = date;
406
+ } else {
407
+ this._endDateValue = date;
408
+ }
409
+ this._closeCalendar();
410
+ } else {
411
+ this._startDateValue = date;
412
+ this._endDateValue = void 0;
413
+ }
414
+ } else {
415
+ this._startDateValue = date;
416
+ if (this.withTime) {
417
+ const el = this.shadowRoot?.getElementById(
418
+ this._timeSelection === UNDEF ? "dateTimeSelectId" : "buttonSetValueId"
419
+ );
420
+ el?.focus();
421
+ } else {
422
+ this._closeCalendar();
423
+ }
424
+ }
425
+ if (!this._showCalendar) {
426
+ this._updateInputField(true, e);
427
+ }
428
+ e.stopPropagation();
429
+ }
430
+ /**
431
+ * Triggered by Today button in small calendar view.
432
+ * Set calendar date to today.
433
+ */
434
+ _triggerSetTodayButton(e) {
435
+ this._startDateValue = /* @__PURE__ */ new Date();
436
+ if (this.dateRange) {
437
+ this._endDateValue = void 0;
438
+ this._rangeSelection = void 0;
439
+ } else if (!this.withTime) {
440
+ this._closeCalendar();
441
+ this._updateInputField(true, e);
442
+ e.stopPropagation();
443
+ return;
444
+ }
445
+ this._updateInputField(!this._showCalendar, e);
446
+ e.stopPropagation();
447
+ }
448
+ /**
449
+ * Triggered by Reset button in small calendar view.
450
+ * Reset selected values to origin state (initaldate or empty).
451
+ */
452
+ _triggerResetButton(e) {
453
+ this.reset();
454
+ this._closeCalendar();
455
+ e.stopPropagation();
456
+ }
457
+ /**
458
+ * Triggered by ok button in small calendar view.
459
+ * Set selected value and close calendar.
460
+ */
461
+ _triggerSetValueButton(e) {
462
+ this._updateInputField(true, e);
463
+ this._closeCalendar();
464
+ e.stopPropagation();
465
+ }
466
+ /**
467
+ * Handle month change from calendar navigation.
468
+ * Updates _displayedMonth to recalculate constraints for the new month.
469
+ */
470
+ _onCalendarMonthChange(e) {
471
+ if (e.detail.newDate) {
472
+ this._displayedMonth = e.detail.newDate;
473
+ }
474
+ e.stopPropagation();
475
+ }
476
+ /**
477
+ * Calculate range of dates between two dates on mouse over.
478
+ * Only needed for date range visuell selection in small calendar.
479
+ *
480
+ * @param e
481
+ */
482
+ _triggerHoverCalculateRange(e) {
483
+ if (this._startDateValue && this.dateRange && e.detail.date && !this._endDateValue) {
484
+ this._rangeSelection = getDataForDaysBetween(
485
+ this._startDateValue,
486
+ e.detail.date
487
+ );
488
+ }
489
+ }
490
+ /**
491
+ * Format date value from _startDateValue and _startDateValue and _timeSelection.
492
+ * Depending on daterange and withtime configuration.
493
+ *
494
+ * @returns string with date value
495
+ */
496
+ _formatDateValue() {
497
+ if (!this._startDateValue && !this._endDateValue && this._timeSelection === UNDEF)
498
+ return "";
499
+ return this.dateRange ? getDateRangeValue(
500
+ this._startDateValue,
501
+ this._endDateValue,
502
+ this.dateFormat
503
+ ) : getDateTimeValue(
504
+ this._startDateValue,
505
+ this._timeSelection,
506
+ this.dateFormat
507
+ );
508
+ }
509
+ /**
510
+ * Builds calendar data with disabled days based on min/max constraints and disabledDays.
511
+ * Merges with existing range selection data.
512
+ */
513
+ _buildConstrainedData(currentMonth) {
514
+ const result = { ...this._rangeSelection || {} };
515
+ const minDate = this.min ? parse(this.min, DEFAULT_FORMAT, /* @__PURE__ */ new Date()) : null;
516
+ const maxDate = this.max ? parse(this.max, DEFAULT_FORMAT, /* @__PURE__ */ new Date()) : null;
517
+ const year = currentMonth.getFullYear();
518
+ const month = currentMonth.getMonth();
519
+ const firstDay = new Date(year, month, 1);
520
+ const lastDay = new Date(year, month + 1, 0);
521
+ for (let day = new Date(firstDay); day <= lastDay; day.setDate(day.getDate() + 1)) {
522
+ const key = format(day, DEFAULT_FORMAT);
523
+ const isBeforeMin = minDate && day < minDate;
524
+ const isAfterMax = maxDate && day > maxDate;
525
+ const isInDisabledDays = this.disabledDays.includes(key);
526
+ if (isBeforeMin || isAfterMax || isInDisabledDays) {
527
+ result[key] = [{ ...result[key]?.[0], disabled: true }];
528
+ }
529
+ }
530
+ return result;
531
+ }
532
+ // ###### Start Inner Element Events
533
+ _innerEnter(e) {
534
+ e.stopPropagation();
535
+ }
536
+ _innerRegister(e) {
537
+ e.stopPropagation();
538
+ }
539
+ _innerUnRegister(e) {
540
+ e.stopPropagation();
541
+ }
542
+ _innerFocus(e) {
543
+ e.stopPropagation();
544
+ }
545
+ _innerBlur(e) {
546
+ e.stopPropagation();
547
+ }
548
+ _innerFormChange(e) {
549
+ e.stopPropagation();
550
+ }
551
+ };
552
+ PdDatepicker.styles = [
553
+ PdBaseInputElement.styles,
554
+ css`
555
+ :host {
556
+ position: relative;
557
+ display: inline-block;
558
+ }
559
+
560
+ :host([disabled]) {
561
+ pointer-events: none;
562
+ }
563
+
564
+ :host([_showCalendar]) .calendar-small {
565
+ visibility: visible;
566
+ opacity: 1;
567
+ }
568
+
569
+ .calendar-small {
570
+ position: absolute;
571
+ background-color: var(--pd-default-bg-col);
572
+ visibility: hidden;
573
+ z-index: var(--pd-datepicker-z-index, 1000);
574
+ box-shadow: var(--pd-menu-shadow, var(--pd-shadow-lg));
575
+ transition: 0.5s ease-out;
576
+ transform: translateY(0);
577
+ opacity: 0;
578
+ padding: 0.5em;
579
+ max-width: 400px;
580
+ --pd-calendar-cell-selectable-shadow: 0;
581
+ --pd-calendar-cell-day-free-bg-col: var(--pd-default-bg-col);
582
+ --pd-calendar-cell-day-info-free-col: var(--pd-default-font-title-col);
583
+ }
584
+
585
+ .calendar-small.bottom {
586
+ top: 100%; /* Unter dem Input-Feld */
587
+ }
588
+
589
+ .calendar-small.top {
590
+ bottom: 100%; /* Über dem Input-Feld */
591
+ }
592
+
593
+ .date-time-select {
594
+ display: block;
595
+ --pd-input-field-height: 32px;
596
+ margin-top: var(--pd-spacing-sm);
597
+ }
598
+
599
+ .bottom-buttons {
600
+ display: flex;
601
+ --pd-button-min-height: 32px;
602
+ --pd-button-height: 32px;
603
+ --pd-button-scale: 0.9;
604
+ gap: var(--pd-spacing-sm);
605
+ margin-top: var(--pd-spacing-sm);
606
+ }
607
+
608
+ /* Modal backdrop overlay */
609
+ .modal-backdrop {
610
+ display: none;
611
+ position: fixed;
612
+ inset: 0;
613
+ background-color: var(--pd-modal-overlay-col, rgba(0, 0, 0, 0.5));
614
+ z-index: calc(var(--pd-datepicker-z-index, 1000) - 1);
615
+ }
616
+
617
+ :host([_showCalendar]) .modal-backdrop.active {
618
+ display: block;
619
+ }
620
+
621
+ /* Modal mode: centered calendar, slightly above center for mobile usability */
622
+ .calendar-small.modal {
623
+ position: fixed;
624
+ top: 40%;
625
+ left: 50%;
626
+ transform: translate(-50%, -50%);
627
+ margin: 0;
628
+ padding: var(--pd-spacing-md);
629
+ border-radius: var(--pd-radius-lg);
630
+ max-height: 90vh;
631
+ min-height: 360px; /* Prevent jumping between months with different week counts */
632
+ overflow-y: auto;
633
+ width: calc(100vw - 2rem); /* 1rem Abstand links + rechts */
634
+ }
635
+ `
636
+ ];
637
+ __decorateClass([
638
+ property({ type: String })
639
+ ], PdDatepicker.prototype, "locale", 2);
640
+ __decorateClass([
641
+ property({ type: Object })
642
+ ], PdDatepicker.prototype, "initialDate", 2);
643
+ __decorateClass([
644
+ property({ type: String })
645
+ ], PdDatepicker.prototype, "dateFormat", 2);
646
+ __decorateClass([
647
+ property({ type: Boolean })
648
+ ], PdDatepicker.prototype, "dateRange", 2);
649
+ __decorateClass([
650
+ property({ type: Boolean })
651
+ ], PdDatepicker.prototype, "hideToday", 2);
652
+ __decorateClass([
653
+ property({ type: Array })
654
+ ], PdDatepicker.prototype, "withYearPopup", 2);
655
+ __decorateClass([
656
+ property({ type: String })
657
+ ], PdDatepicker.prototype, "placeHolderTime", 2);
658
+ __decorateClass([
659
+ property({ type: Boolean })
660
+ ], PdDatepicker.prototype, "withTime", 2);
661
+ __decorateClass([
662
+ property({ type: String })
663
+ ], PdDatepicker.prototype, "min", 2);
664
+ __decorateClass([
665
+ property({ type: String })
666
+ ], PdDatepicker.prototype, "max", 2);
667
+ __decorateClass([
668
+ property({ type: Array })
669
+ ], PdDatepicker.prototype, "disabledDays", 2);
670
+ __decorateClass([
671
+ property({ type: Boolean })
672
+ ], PdDatepicker.prototype, "modal", 2);
673
+ __decorateClass([
674
+ property({ type: Number })
675
+ ], PdDatepicker.prototype, "modalBreakpoint", 2);
676
+ __decorateClass([
677
+ property({ type: Boolean, reflect: true })
678
+ ], PdDatepicker.prototype, "_showCalendar", 2);
679
+ __decorateClass([
680
+ state()
681
+ ], PdDatepicker.prototype, "_startDateValue", 2);
682
+ __decorateClass([
683
+ state()
684
+ ], PdDatepicker.prototype, "_endDateValue", 2);
685
+ __decorateClass([
686
+ state()
687
+ ], PdDatepicker.prototype, "_rangeSelection", 2);
688
+ __decorateClass([
689
+ state()
690
+ ], PdDatepicker.prototype, "_timeSelection", 2);
691
+ __decorateClass([
692
+ state()
693
+ ], PdDatepicker.prototype, "_useModal", 2);
694
+ __decorateClass([
695
+ state()
696
+ ], PdDatepicker.prototype, "_displayedMonth", 2);
697
+ PdDatepicker = __decorateClass([
698
+ localized()
699
+ ], PdDatepicker);
700
+
701
+ export { PdDatepicker };