@progressive-development/pd-calendar 0.6.7 → 0.9.2
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/dist/generated/locales/be.d.ts +4 -0
- package/dist/generated/locales/be.d.ts.map +1 -1
- package/dist/generated/locales/de.d.ts +4 -0
- package/dist/generated/locales/de.d.ts.map +1 -1
- package/dist/generated/locales/en.d.ts +4 -0
- package/dist/generated/locales/en.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -10
- package/dist/locales/be.js +7 -4
- package/dist/locales/de.js +7 -4
- package/dist/locales/en.js +7 -4
- package/dist/pd-calendar/PdCalendar.d.ts +50 -0
- package/dist/pd-calendar/PdCalendar.d.ts.map +1 -0
- package/dist/pd-calendar/PdCalendar.js +434 -0
- package/dist/{pd-calendar-cell.d.ts → pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts} +4 -2
- package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts.map +1 -0
- package/dist/{pd-calendar-cell.js → pd-calendar/pd-calendar-cell/PdCalendarCell.js} +97 -102
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.js +8 -0
- package/dist/{stories/cell.stories.d.ts → pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts} +2 -2
- package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts.map +1 -0
- package/dist/pd-calendar/pd-calendar.d.ts +3 -0
- package/dist/pd-calendar/pd-calendar.d.ts.map +1 -0
- package/dist/{stories/index.stories.d.ts → pd-calendar/pd-calendar.stories.d.ts} +2 -2
- package/dist/pd-calendar/pd-calendar.stories.d.ts.map +1 -0
- package/dist/{pd-year-popup.d.ts → pd-calendar/pd-year-popup/PdYearPopup.d.ts} +4 -2
- package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts.map +1 -0
- package/dist/{pd-year-popup.js → pd-calendar/pd-year-popup/PdYearPopup.js} +57 -62
- package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts +3 -0
- package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts.map +1 -0
- package/dist/pd-calendar/pd-year-popup/pd-year-popup.js +8 -0
- package/dist/pd-calendar.d.ts +2 -48
- package/dist/pd-calendar.js +6 -437
- package/dist/pd-datepicker/PdDatepicker.d.ts +112 -0
- package/dist/pd-datepicker/PdDatepicker.d.ts.map +1 -0
- package/dist/pd-datepicker/PdDatepicker.js +494 -0
- package/dist/pd-datepicker/pd-date-picker.stories.d.ts +23 -0
- package/dist/pd-datepicker/pd-date-picker.stories.d.ts.map +1 -0
- package/dist/pd-datepicker/pd-datepicker.d.ts +3 -0
- package/dist/pd-datepicker/pd-datepicker.d.ts.map +1 -0
- package/dist/pd-datepicker.d.ts +2 -0
- package/dist/pd-datepicker.js +8 -0
- package/package.json +29 -46
- package/dist/pd-calendar-cell.d.ts.map +0 -1
- package/dist/pd-calendar.d.ts.map +0 -1
- package/dist/pd-year-popup.d.ts.map +0 -1
- package/dist/stories/cell.stories.d.ts.map +0 -1
- package/dist/stories/index.stories.d.ts.map +0 -1
package/dist/pd-calendar.js
CHANGED
|
@@ -1,439 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { property, state, customElement } from "lit/decorators.js";
|
|
3
|
-
import { msg, localized } from "@lit/localize";
|
|
4
|
-
import { format } from "fecha";
|
|
5
|
-
import "@progressive-development/pd-icon/pd-icon";
|
|
6
|
-
import { PdColorStyles, PdFontStyles } from "@progressive-development/pd-shared-styles";
|
|
7
|
-
import { PdYearPopup } from "./pd-year-popup.js";
|
|
8
|
-
import "./pd-calendar-cell.js";
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
12
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
13
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
-
if (decorator = decorators[i])
|
|
15
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
16
|
-
if (kind && result) __defProp(target, key, result);
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
const TOUCH_MIN_MOVE = 70;
|
|
20
|
-
const loadLocales = () => ({
|
|
21
|
-
monthNames: [
|
|
22
|
-
msg("Januar", { id: "pd.datepicker.month.jan" }),
|
|
23
|
-
msg("Februar", { id: "pd.datepicker.month.feb" }),
|
|
24
|
-
msg("März", { id: "pd.datepicker.month.mar" }),
|
|
25
|
-
msg("April", { id: "pd.datepicker.month.apr" }),
|
|
26
|
-
msg("Mai", { id: "pd.datepicker.month.may" }),
|
|
27
|
-
msg("Juni", { id: "pd.datepicker.month.jun" }),
|
|
28
|
-
msg("Juli", { id: "pd.datepicker.month.jul" }),
|
|
29
|
-
msg("August", { id: "pd.datepicker.month.aug" }),
|
|
30
|
-
msg("September", { id: "pd.datepicker.month.sep" }),
|
|
31
|
-
msg("Oktober", { id: "pd.datepicker.month.oct" }),
|
|
32
|
-
msg("November", { id: "pd.datepicker.month.nov" }),
|
|
33
|
-
msg("Dezember", { id: "pd.datepicker.month.dec" })
|
|
34
|
-
],
|
|
35
|
-
weekdaysShort: [
|
|
36
|
-
msg("Mo", { id: "pd.datepicker.shortday.mon" }),
|
|
37
|
-
msg("Di", { id: "pd.datepicker.shortday.tue" }),
|
|
38
|
-
msg("Mi", { id: "pd.datepicker.shortday.wed" }),
|
|
39
|
-
msg("Do", { id: "pd.datepicker.shortday.thi" }),
|
|
40
|
-
msg("Fr", { id: "pd.datepicker.shortday.fri" }),
|
|
41
|
-
msg("Sa", { id: "pd.datepicker.shortday.sat" }),
|
|
42
|
-
msg("So", { id: "pd.datepicker.shortday.sun" })
|
|
43
|
-
]
|
|
44
|
-
});
|
|
45
|
-
const LOCALES = loadLocales();
|
|
46
|
-
const VIEW_MONTH = 2;
|
|
47
|
-
function isToday(date) {
|
|
48
|
-
const today = /* @__PURE__ */ new Date();
|
|
49
|
-
return !!date && date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
|
|
50
|
-
}
|
|
51
|
-
function isSelected(date1, date2) {
|
|
52
|
-
return !!date1 && !!date2 && date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
|
|
53
|
-
}
|
|
54
|
-
let PdCalendar = class extends LitElement {
|
|
55
|
-
constructor() {
|
|
56
|
-
super(...arguments);
|
|
57
|
-
this.selectableDates = false;
|
|
58
|
-
this.withYearPopup = [];
|
|
59
|
-
this.withWheelNavigation = false;
|
|
60
|
-
this.withTouchNavigation = false;
|
|
61
|
-
this.showSelection = false;
|
|
62
|
-
this.hideWeekend = false;
|
|
63
|
-
this.prevMonthConstraint = -1;
|
|
64
|
-
this.nextMonthConstraint = -1;
|
|
65
|
-
this.data = {};
|
|
66
|
-
this.numberClass = "top-left";
|
|
67
|
-
this._viewType = VIEW_MONTH;
|
|
68
|
-
this._currentDate = /* @__PURE__ */ new Date();
|
|
69
|
-
this._wheelDelta = 0;
|
|
70
|
-
this._monthName = "";
|
|
71
|
-
this._year = 0;
|
|
72
|
-
this._numberOfDays = 0;
|
|
73
|
-
this._daysFromPreviousMonth = [];
|
|
74
|
-
this._currentMonthNavNr = 0;
|
|
75
|
-
}
|
|
76
|
-
connectedCallback() {
|
|
77
|
-
super.connectedCallback();
|
|
78
|
-
this._initFromDate(this.refDate ?? /* @__PURE__ */ new Date());
|
|
79
|
-
}
|
|
80
|
-
update(changedProperties) {
|
|
81
|
-
if (changedProperties.has("refDate") && this.refDate) {
|
|
82
|
-
this._initFromDate(this.refDate);
|
|
83
|
-
}
|
|
84
|
-
super.update(changedProperties);
|
|
85
|
-
}
|
|
86
|
-
render() {
|
|
87
|
-
return html`
|
|
88
|
-
${this.renderMonthCalendar()}
|
|
89
|
-
<slot name="calFooter"></slot>
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
renderMonthCalendar() {
|
|
93
|
-
const sizeClass = this._numberOfDays >= 31 && this._daysFromPreviousMonth.length >= 5 ? "max" : "normal";
|
|
94
|
-
const days = Array.from({ length: this._numberOfDays }, (_, i) => {
|
|
95
|
-
var _a;
|
|
96
|
-
const day = i + 1;
|
|
97
|
-
const date = new Date(this._year, this._currentDate.getMonth(), day);
|
|
98
|
-
if (this.hideWeekend && [0, 6].includes(date.getDay())) return null;
|
|
99
|
-
const key = format(date, "YYYY-MM-DD");
|
|
100
|
-
const cellData = this.data ? (_a = this.data[key]) == null ? void 0 : _a[0] : void 0;
|
|
101
|
-
return html`
|
|
102
|
-
<pd-calendar-cell
|
|
103
|
-
key=${key}
|
|
104
|
-
.dayNumber=${day}
|
|
105
|
-
.weekDayNumber=${date.getDay()}
|
|
106
|
-
.infoTxt=${(cellData == null ? void 0 : cellData.info) || ""}
|
|
107
|
-
?selectEnabled=${this.selectableDates || !!(cellData == null ? void 0 : cellData.info)}
|
|
108
|
-
?special=${(cellData == null ? void 0 : cellData.special) ?? false}
|
|
109
|
-
.numberClass=${this.numberClass}
|
|
110
|
-
?today=${this.selectableDates && isToday(date)}
|
|
111
|
-
?selected=${this.showSelection && isSelected(this.refDate, date)}
|
|
112
|
-
></pd-calendar-cell>
|
|
113
|
-
`;
|
|
114
|
-
});
|
|
115
|
-
return html`
|
|
116
|
-
<div class="layout-container">
|
|
117
|
-
<div class="header">
|
|
118
|
-
<div class="header-main">
|
|
119
|
-
<div class="icon-container">
|
|
120
|
-
<pd-icon
|
|
121
|
-
class="arrow"
|
|
122
|
-
icon="previousArrow"
|
|
123
|
-
activeIcon
|
|
124
|
-
@click=${this._previousMonth}
|
|
125
|
-
></pd-icon>
|
|
126
|
-
<pd-icon
|
|
127
|
-
class="arrow"
|
|
128
|
-
icon="nextArrow"
|
|
129
|
-
activeIcon
|
|
130
|
-
@click=${this._nextMonth}
|
|
131
|
-
></pd-icon>
|
|
132
|
-
</div>
|
|
133
|
-
<div id="titleContentId" class="content-title">
|
|
134
|
-
${this._monthName}
|
|
135
|
-
${this.withYearPopup.length > 0 ? html`<span
|
|
136
|
-
class="year-popup-link"
|
|
137
|
-
@click=${this._openYearPopup}
|
|
138
|
-
>${this._year}</span
|
|
139
|
-
>` : this._year}
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
<div
|
|
145
|
-
class="content grid-container ${sizeClass}"
|
|
146
|
-
@wheel=${this._wheelEvent}
|
|
147
|
-
@touchstart=${this._touchStartEvent}
|
|
148
|
-
@touchend=${this._touchEndEvent}
|
|
149
|
-
>
|
|
150
|
-
${this._getWeekDays().map(
|
|
151
|
-
(day) => html`<div class="title-week-day">${day}</div>`
|
|
152
|
-
)}
|
|
153
|
-
${this._daysFromPreviousMonth.map(
|
|
154
|
-
() => html`<div class="cell cell-empty"></div>`
|
|
155
|
-
)}
|
|
156
|
-
${days}
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
`;
|
|
160
|
-
}
|
|
161
|
-
_openYearPopup() {
|
|
162
|
-
var _a, _b;
|
|
163
|
-
const popup = new PdYearPopup();
|
|
164
|
-
popup.yearSelection = this.withYearPopup;
|
|
165
|
-
(_b = (_a = this.shadowRoot) == null ? void 0 : _a.getElementById("titleContentId")) == null ? void 0 : _b.appendChild(popup);
|
|
166
|
-
popup.addEventListener("abort-year-selection", () => {
|
|
167
|
-
var _a2, _b2;
|
|
168
|
-
(_b2 = (_a2 = this.shadowRoot) == null ? void 0 : _a2.getElementById("titleContentId")) == null ? void 0 : _b2.removeChild(popup);
|
|
169
|
-
});
|
|
170
|
-
popup.addEventListener("change-year-selection", (e) => {
|
|
171
|
-
var _a2, _b2;
|
|
172
|
-
const year = e.detail.year;
|
|
173
|
-
const newDate = new Date(this._currentDate);
|
|
174
|
-
newDate.setFullYear(year);
|
|
175
|
-
this.dispatchEvent(
|
|
176
|
-
new CustomEvent("change-month", { detail: { newDate } })
|
|
177
|
-
);
|
|
178
|
-
this._initFromDate(newDate);
|
|
179
|
-
(_b2 = (_a2 = this.shadowRoot) == null ? void 0 : _a2.getElementById("titleContentId")) == null ? void 0 : _b2.removeChild(popup);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
_getWeekDays() {
|
|
183
|
-
return this.hideWeekend ? LOCALES.weekdaysShort.slice(0, 5) : LOCALES.weekdaysShort;
|
|
184
|
-
}
|
|
185
|
-
_nextMonth() {
|
|
186
|
-
if (this._checkNextMonthConstraint()) {
|
|
187
|
-
const next = new Date(
|
|
188
|
-
this._currentDate.getFullYear(),
|
|
189
|
-
this._currentDate.getMonth() + 1,
|
|
190
|
-
1
|
|
191
|
-
);
|
|
192
|
-
this.dispatchEvent(
|
|
193
|
-
new CustomEvent("change-month", {
|
|
194
|
-
detail: { newDate: next, next: true }
|
|
195
|
-
})
|
|
196
|
-
);
|
|
197
|
-
this._currentMonthNavNr += 1;
|
|
198
|
-
this._initFromDate(next);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
_previousMonth() {
|
|
202
|
-
if (this._checkPrevMonthConstraint()) {
|
|
203
|
-
const prev = new Date(
|
|
204
|
-
this._currentDate.getFullYear(),
|
|
205
|
-
this._currentDate.getMonth() - 1,
|
|
206
|
-
1
|
|
207
|
-
);
|
|
208
|
-
this.dispatchEvent(
|
|
209
|
-
new CustomEvent("change-month", {
|
|
210
|
-
detail: { newDate: prev, prev: true }
|
|
211
|
-
})
|
|
212
|
-
);
|
|
213
|
-
this._currentMonthNavNr -= 1;
|
|
214
|
-
this._initFromDate(prev);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
_wheelEvent(e) {
|
|
218
|
-
if (this.withWheelNavigation) {
|
|
219
|
-
this._wheelDelta += e.deltaY;
|
|
220
|
-
if (this._wheelDelta > 360) {
|
|
221
|
-
this._wheelDelta = 0;
|
|
222
|
-
this._nextMonth();
|
|
223
|
-
} else if (this._wheelDelta < -360) {
|
|
224
|
-
this._wheelDelta = 0;
|
|
225
|
-
this._previousMonth();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
e.stopPropagation();
|
|
230
|
-
}
|
|
231
|
-
_touchStartEvent(e) {
|
|
232
|
-
if (this.withTouchNavigation) {
|
|
233
|
-
this._wheelDelta = e.changedTouches[0].screenX;
|
|
234
|
-
}
|
|
235
|
-
e.stopPropagation();
|
|
236
|
-
}
|
|
237
|
-
_touchEndEvent(e) {
|
|
238
|
-
if (this.withTouchNavigation) {
|
|
239
|
-
const diff = this._wheelDelta - e.changedTouches[0].screenX;
|
|
240
|
-
if (diff < -70) {
|
|
241
|
-
this._nextMonth();
|
|
242
|
-
} else if (diff > TOUCH_MIN_MOVE) {
|
|
243
|
-
this._previousMonth();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
e.stopPropagation();
|
|
247
|
-
}
|
|
248
|
-
_initFromDate(date) {
|
|
249
|
-
this._monthName = date.toLocaleString("default", { month: "long" });
|
|
250
|
-
this._year = date.getFullYear();
|
|
251
|
-
this._currentDate = date;
|
|
252
|
-
this._daysFromPreviousMonth = PdCalendar._getPreviousMonthDays(date);
|
|
253
|
-
const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
254
|
-
this._numberOfDays = lastDay.getDate();
|
|
255
|
-
}
|
|
256
|
-
static _getPreviousMonthDays(date) {
|
|
257
|
-
const start = new Date(date.getFullYear(), date.getMonth(), 1);
|
|
258
|
-
const missing = start.getDay() > 0 ? Math.abs(1 - start.getDay()) : 6;
|
|
259
|
-
return Array.from({ length: missing }, (_, i) => {
|
|
260
|
-
const d = new Date(start);
|
|
261
|
-
d.setDate(start.getDate() - (missing - i));
|
|
262
|
-
return d;
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
_checkNextMonthConstraint() {
|
|
266
|
-
return this.nextMonthConstraint === -1 || this.nextMonthConstraint > this._currentMonthNavNr;
|
|
267
|
-
}
|
|
268
|
-
_checkPrevMonthConstraint() {
|
|
269
|
-
return this.prevMonthConstraint === -1 || this._currentMonthNavNr > 0 || this.prevMonthConstraint > this._currentMonthNavNr * -1;
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
PdCalendar.styles = [
|
|
273
|
-
PdColorStyles,
|
|
274
|
-
PdFontStyles,
|
|
275
|
-
css`
|
|
276
|
-
:host {
|
|
277
|
-
--my-cell-height: var(--pd-calendar-cell-height, 70px);
|
|
278
|
-
|
|
279
|
-
display: block;
|
|
280
|
-
/*padding: 8px;
|
|
281
|
-
width: 100vw;
|
|
282
|
-
height: 100vh;*/
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
:host([hideWeekend]) .grid-container {
|
|
286
|
-
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/* Layout Grid for the Calendar Component => Not really needed at the moment, more a test */
|
|
290
|
-
.layout-container {
|
|
291
|
-
width: var(--pd-calendar-width, 100%);
|
|
292
|
-
min-width: 220px;
|
|
293
|
-
height: 100%;
|
|
294
|
-
display: grid;
|
|
295
|
-
grid-template-columns: 1fr 1fr 1fr;
|
|
296
|
-
grid-template-rows: 40px auto;
|
|
297
|
-
gap: 1px;
|
|
298
|
-
grid-template-areas:
|
|
299
|
-
"header header header"
|
|
300
|
-
"content content content";
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/* Grid Area positions for layout container above */
|
|
304
|
-
.header {
|
|
305
|
-
grid-area: header;
|
|
306
|
-
position: relative;
|
|
307
|
-
font-family: var(--pd-default-font-title-family);
|
|
308
|
-
color: var(--pd-default-font-title-col);
|
|
309
|
-
display: flex;
|
|
310
|
-
justify-content: left;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.header-main {
|
|
314
|
-
display: flex;
|
|
315
|
-
align-items: center;
|
|
316
|
-
justify-content: space-between;
|
|
317
|
-
width: 100%;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
.content {
|
|
321
|
-
grid-area: content;
|
|
322
|
-
}
|
|
323
|
-
.footer {
|
|
324
|
-
grid-area: footer;
|
|
325
|
-
}
|
|
1
|
+
import { PdCalendar } from './pd-calendar/PdCalendar.js';
|
|
326
2
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
332
|
-
gap: 3px;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.grid-container.max {
|
|
336
|
-
grid-template-rows: minmax(10px, 30px) repeat(
|
|
337
|
-
6,
|
|
338
|
-
minmax(var(--my-cell-height), 1fr)
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
.grid-container.normal {
|
|
343
|
-
grid-template-rows: minmax(10px, 30px) repeat(
|
|
344
|
-
5,
|
|
345
|
-
minmax(var(--my-cell-height), 1fr)
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
.title-week-day {
|
|
350
|
-
display: flex;
|
|
351
|
-
align-items: center;
|
|
352
|
-
justify-content: center;
|
|
353
|
-
background-color: var(
|
|
354
|
-
--pd-calendar-week-title-bg-col,
|
|
355
|
-
var(--pd-default-dark-col)
|
|
356
|
-
);
|
|
357
|
-
font-size: var(--pd-calendar-weekday-title-font-size, 1em);
|
|
358
|
-
font-weight: bold;
|
|
359
|
-
color: var(--pd-calendar-week-title-font-col, var(--pd-default-bg-col));
|
|
360
|
-
font-family: var(--pd-default-font-title-family);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
.content-title {
|
|
364
|
-
position: relative;
|
|
365
|
-
font-size: var(--pd-calendar-title-font-size, 1.2em);
|
|
366
|
-
font-weight: bold;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
.icon-container {
|
|
370
|
-
display: flex;
|
|
371
|
-
align-items: center;
|
|
372
|
-
justify-content: center;
|
|
373
|
-
gap: 5px;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.arrow {
|
|
377
|
-
cursor: pointer;
|
|
378
|
-
--pd-icon-size: var(--pd-calendar-title-icon-size, 1.2em);
|
|
379
|
-
--pd-icon-bg-col-hover: lightgrey;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
.year-popup-link {
|
|
383
|
-
}
|
|
3
|
+
const tag = "pd-calendar";
|
|
4
|
+
if (!customElements.get(tag)) {
|
|
5
|
+
customElements.define(tag, PdCalendar);
|
|
6
|
+
}
|
|
384
7
|
|
|
385
|
-
|
|
386
|
-
cursor: pointer;
|
|
387
|
-
color: var(--pd-default-hover-col);
|
|
388
|
-
}
|
|
389
|
-
`
|
|
390
|
-
];
|
|
391
|
-
__decorateClass([
|
|
392
|
-
property({ type: Object })
|
|
393
|
-
], PdCalendar.prototype, "refDate", 2);
|
|
394
|
-
__decorateClass([
|
|
395
|
-
property({ type: Boolean })
|
|
396
|
-
], PdCalendar.prototype, "selectableDates", 2);
|
|
397
|
-
__decorateClass([
|
|
398
|
-
property({ type: Array })
|
|
399
|
-
], PdCalendar.prototype, "withYearPopup", 2);
|
|
400
|
-
__decorateClass([
|
|
401
|
-
property({ type: Boolean })
|
|
402
|
-
], PdCalendar.prototype, "withWheelNavigation", 2);
|
|
403
|
-
__decorateClass([
|
|
404
|
-
property({ type: Boolean })
|
|
405
|
-
], PdCalendar.prototype, "withTouchNavigation", 2);
|
|
406
|
-
__decorateClass([
|
|
407
|
-
property({ type: Boolean })
|
|
408
|
-
], PdCalendar.prototype, "showSelection", 2);
|
|
409
|
-
__decorateClass([
|
|
410
|
-
property({ type: Boolean, reflect: true })
|
|
411
|
-
], PdCalendar.prototype, "hideWeekend", 2);
|
|
412
|
-
__decorateClass([
|
|
413
|
-
property({ type: Number })
|
|
414
|
-
], PdCalendar.prototype, "prevMonthConstraint", 2);
|
|
415
|
-
__decorateClass([
|
|
416
|
-
property({ type: Number })
|
|
417
|
-
], PdCalendar.prototype, "nextMonthConstraint", 2);
|
|
418
|
-
__decorateClass([
|
|
419
|
-
property({ type: Object })
|
|
420
|
-
], PdCalendar.prototype, "data", 2);
|
|
421
|
-
__decorateClass([
|
|
422
|
-
property({ type: String })
|
|
423
|
-
], PdCalendar.prototype, "numberClass", 2);
|
|
424
|
-
__decorateClass([
|
|
425
|
-
state()
|
|
426
|
-
], PdCalendar.prototype, "_viewType", 2);
|
|
427
|
-
__decorateClass([
|
|
428
|
-
state()
|
|
429
|
-
], PdCalendar.prototype, "_currentDate", 2);
|
|
430
|
-
__decorateClass([
|
|
431
|
-
state()
|
|
432
|
-
], PdCalendar.prototype, "_wheelDelta", 2);
|
|
433
|
-
PdCalendar = __decorateClass([
|
|
434
|
-
customElement("pd-calendar"),
|
|
435
|
-
localized()
|
|
436
|
-
], PdCalendar);
|
|
437
|
-
export {
|
|
438
|
-
PdCalendar
|
|
439
|
-
};
|
|
8
|
+
export { PdCalendar };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { PropertyValues, CSSResultGroup } from 'lit';
|
|
2
|
+
import { PdBaseInputElement } from '@progressive-development/pd-forms';
|
|
3
|
+
/**
|
|
4
|
+
* @tagname pd-datepicker
|
|
5
|
+
*
|
|
6
|
+
* Datepicker Komponente zur Auswahl einzelner oder von Zeiträumen, inkl. optionaler Uhrzeitangabe.
|
|
7
|
+
* Unterstützt Darstellung über eingebetteten Kalender mit konfigurierbarem Jahr-Popup.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PdDatepicker extends PdBaseInputElement {
|
|
10
|
+
locale?: string;
|
|
11
|
+
initialDate?: Date;
|
|
12
|
+
/**
|
|
13
|
+
* Format für Datum. Default ist "yyyy-MM-dd".
|
|
14
|
+
*/
|
|
15
|
+
dateFormat?: string;
|
|
16
|
+
dateRange: boolean;
|
|
17
|
+
hideToday: boolean;
|
|
18
|
+
withYearPopup: string[];
|
|
19
|
+
placeHolderTime?: string;
|
|
20
|
+
withTime: boolean;
|
|
21
|
+
min?: string;
|
|
22
|
+
max?: string;
|
|
23
|
+
private _showCalendar;
|
|
24
|
+
private _startDateValue?;
|
|
25
|
+
private _endDateValue?;
|
|
26
|
+
private _rangeSelection?;
|
|
27
|
+
private _timeSelection;
|
|
28
|
+
private _calendarPosition;
|
|
29
|
+
static styles: CSSResultGroup;
|
|
30
|
+
constructor();
|
|
31
|
+
private _requiredDateTimeValidator;
|
|
32
|
+
update(changedProps: PropertyValues<this>): void;
|
|
33
|
+
render(): import('lit').TemplateResult<1>;
|
|
34
|
+
/**
|
|
35
|
+
* Getter for outside call.
|
|
36
|
+
*
|
|
37
|
+
* @returns obj: { start?: Date; end?: Date } - the prepared date values.
|
|
38
|
+
*/
|
|
39
|
+
get dateValues(): {
|
|
40
|
+
start?: Date;
|
|
41
|
+
end?: Date;
|
|
42
|
+
};
|
|
43
|
+
reset(): void;
|
|
44
|
+
clear(): void;
|
|
45
|
+
/**
|
|
46
|
+
* @returns formated value from current field selections.
|
|
47
|
+
*/
|
|
48
|
+
_getInitialValue(): string;
|
|
49
|
+
/**
|
|
50
|
+
* @returns parsed date
|
|
51
|
+
*/
|
|
52
|
+
_getParsedValue(): any;
|
|
53
|
+
/**
|
|
54
|
+
* Init _startDateValue and _timeSelection from initial date.
|
|
55
|
+
*/
|
|
56
|
+
private _prepareFieldsFromInitDate;
|
|
57
|
+
/**
|
|
58
|
+
* Clear _startDateValue and _timeSelection.
|
|
59
|
+
*/
|
|
60
|
+
private _clearFields;
|
|
61
|
+
/**
|
|
62
|
+
* Update element value from input fields.
|
|
63
|
+
*/
|
|
64
|
+
private _updateInputField;
|
|
65
|
+
/**
|
|
66
|
+
* Toogle view calendar on click into pd-input field.
|
|
67
|
+
*/
|
|
68
|
+
private _inputClick;
|
|
69
|
+
/**
|
|
70
|
+
* Triggered by date selection in small calendar.
|
|
71
|
+
* Set internal values depending on daterange configuration.
|
|
72
|
+
*
|
|
73
|
+
* @param e Event from small calendar.
|
|
74
|
+
*/
|
|
75
|
+
private _triggerCalendarDateSelected;
|
|
76
|
+
/**
|
|
77
|
+
* Triggered by Today button in small calendar view.
|
|
78
|
+
* Set calendar date to today.
|
|
79
|
+
*/
|
|
80
|
+
private _triggerSetTodayButton;
|
|
81
|
+
/**
|
|
82
|
+
* Triggered by Reset button in small calendar view.
|
|
83
|
+
* Reset selected values to origin state (initaldate or empty).
|
|
84
|
+
*/
|
|
85
|
+
private _triggerResetButton;
|
|
86
|
+
/**
|
|
87
|
+
* Triggered by ok button in small calendar view.
|
|
88
|
+
* Set selected value and close calendar.
|
|
89
|
+
*/
|
|
90
|
+
private _triggerSetValueButton;
|
|
91
|
+
/**
|
|
92
|
+
* Calculate range of dates between two dates on mouse over.
|
|
93
|
+
* Only needed for date range visuell selection in small calendar.
|
|
94
|
+
*
|
|
95
|
+
* @param e
|
|
96
|
+
*/
|
|
97
|
+
private _triggerHoverCalculateRange;
|
|
98
|
+
/**
|
|
99
|
+
* Format date value from _startDateValue and _startDateValue and _timeSelection.
|
|
100
|
+
* Depending on daterange and withtime configuration.
|
|
101
|
+
*
|
|
102
|
+
* @returns string with date value
|
|
103
|
+
*/
|
|
104
|
+
private _formatDateValue;
|
|
105
|
+
private _innerEnter;
|
|
106
|
+
private _innerRegister;
|
|
107
|
+
private _innerUnRegister;
|
|
108
|
+
private _innerFocus;
|
|
109
|
+
private _innerBlur;
|
|
110
|
+
private _innerFormChange;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=PdDatepicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PdDatepicker.d.ts","sourceRoot":"","sources":["../../src/pd-datepicker/PdDatepicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAMhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAIvE,OAAO,4CAA4C,CAAC;AACpD,OAAO,6CAA6C,CAAC;AACrD,OAAO,6CAA6C,CAAC;AAIrD,OAAO,+BAA+B,CAAC;AA2EvC;;;;;GAKG;AACH,qBACa,YAAa,SAAQ,kBAAkB;IAElD,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,WAAW,CAAC,EAAE,IAAI,CAAC;IAEnB;;OAEG;IAEH,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,SAAS,UAAS;IAGlB,SAAS,UAAS;IAGlB,aAAa,EAAE,MAAM,EAAE,CAAM;IAG7B,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,QAAQ,UAAS;IAGjB,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,GAAG,CAAC,EAAE,MAAM,CAAC;IAGb,OAAO,CAAC,aAAa,CAAS;IAG9B,OAAO,CAAC,eAAe,CAAC,CAAO;IAG/B,OAAO,CAAC,aAAa,CAAC,CAAO;IAG7B,OAAO,CAAC,eAAe,CAAC,CAAe;IAGvC,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,iBAAiB,CAA8B;IAEvD,OAAgB,MAAM,EAAE,cAAc,CAqDpC;;IAQF,OAAO,CAAC,0BAA0B;IAUzB,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC;IAQzC,MAAM;IAuFf;;;;OAIG;IACH,IAAI,UAAU,IAAI;QAAE,KAAK,CAAC,EAAE,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,CAAA;KAAE,CAU7C;IAEQ,KAAK;IASL,KAAK;IAKd;;OAEG;IACM,gBAAgB,IAAI,MAAM;IAInC;;OAEG;IACM,eAAe,IAAI,GAAG;IAI/B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAclC;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,WAAW;IAkBnB;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IA8CpC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAM9B;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAcnC;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,gBAAgB;CAGzB"}
|