@progressive-development/pd-calendar 0.6.8 → 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.
Files changed (50) hide show
  1. package/dist/generated/locales/be.d.ts +4 -0
  2. package/dist/generated/locales/be.d.ts.map +1 -1
  3. package/dist/generated/locales/de.d.ts +4 -0
  4. package/dist/generated/locales/de.d.ts.map +1 -1
  5. package/dist/generated/locales/en.d.ts +4 -0
  6. package/dist/generated/locales/en.d.ts.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +7 -10
  10. package/dist/locales/be.js +7 -4
  11. package/dist/locales/de.js +7 -4
  12. package/dist/locales/en.js +7 -4
  13. package/dist/pd-calendar/PdCalendar.d.ts +50 -0
  14. package/dist/pd-calendar/PdCalendar.d.ts.map +1 -0
  15. package/dist/pd-calendar/PdCalendar.js +434 -0
  16. package/dist/{pd-calendar-cell.d.ts → pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts} +4 -2
  17. package/dist/pd-calendar/pd-calendar-cell/PdCalendarCell.d.ts.map +1 -0
  18. package/dist/{pd-calendar-cell.js → pd-calendar/pd-calendar-cell/PdCalendarCell.js} +97 -102
  19. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts +3 -0
  20. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.d.ts.map +1 -0
  21. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.js +8 -0
  22. package/dist/{stories/cell.stories.d.ts → pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts} +2 -2
  23. package/dist/pd-calendar/pd-calendar-cell/pd-calendar-cell.stories.d.ts.map +1 -0
  24. package/dist/pd-calendar/pd-calendar.d.ts +3 -0
  25. package/dist/pd-calendar/pd-calendar.d.ts.map +1 -0
  26. package/dist/{stories/index.stories.d.ts → pd-calendar/pd-calendar.stories.d.ts} +2 -2
  27. package/dist/pd-calendar/pd-calendar.stories.d.ts.map +1 -0
  28. package/dist/{pd-year-popup.d.ts → pd-calendar/pd-year-popup/PdYearPopup.d.ts} +4 -2
  29. package/dist/pd-calendar/pd-year-popup/PdYearPopup.d.ts.map +1 -0
  30. package/dist/{pd-year-popup.js → pd-calendar/pd-year-popup/PdYearPopup.js} +57 -62
  31. package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts +3 -0
  32. package/dist/pd-calendar/pd-year-popup/pd-year-popup.d.ts.map +1 -0
  33. package/dist/pd-calendar/pd-year-popup/pd-year-popup.js +8 -0
  34. package/dist/pd-calendar.d.ts +2 -48
  35. package/dist/pd-calendar.js +6 -437
  36. package/dist/pd-datepicker/PdDatepicker.d.ts +112 -0
  37. package/dist/pd-datepicker/PdDatepicker.d.ts.map +1 -0
  38. package/dist/pd-datepicker/PdDatepicker.js +494 -0
  39. package/dist/pd-datepicker/pd-date-picker.stories.d.ts +23 -0
  40. package/dist/pd-datepicker/pd-date-picker.stories.d.ts.map +1 -0
  41. package/dist/pd-datepicker/pd-datepicker.d.ts +3 -0
  42. package/dist/pd-datepicker/pd-datepicker.d.ts.map +1 -0
  43. package/dist/pd-datepicker.d.ts +2 -0
  44. package/dist/pd-datepicker.js +8 -0
  45. package/package.json +29 -46
  46. package/dist/pd-calendar-cell.d.ts.map +0 -1
  47. package/dist/pd-calendar.d.ts.map +0 -1
  48. package/dist/pd-year-popup.d.ts.map +0 -1
  49. package/dist/stories/cell.stories.d.ts.map +0 -1
  50. package/dist/stories/index.stories.d.ts.map +0 -1
@@ -11,6 +11,7 @@ export declare const templates: {
11
11
  "pd.datepicker.month.nov": string;
12
12
  "pd.datepicker.month.oct": string;
13
13
  "pd.datepicker.month.sep": string;
14
+ "pd.datepicker.reset": string;
14
15
  "pd.datepicker.shortday.fri": string;
15
16
  "pd.datepicker.shortday.mon": string;
16
17
  "pd.datepicker.shortday.sat": string;
@@ -18,5 +19,8 @@ export declare const templates: {
18
19
  "pd.datepicker.shortday.thi": string;
19
20
  "pd.datepicker.shortday.tue": string;
20
21
  "pd.datepicker.shortday.wed": string;
22
+ "pd.datepicker.time": string;
23
+ "pd.datepicker.today": string;
24
+ "pd.form.field.selectDateTimeRequired": string;
21
25
  };
22
26
  //# sourceMappingURL=be.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/be.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC"}
1
+ {"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/be.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;CAwBrB,CAAC"}
@@ -18,5 +18,9 @@ export declare const templates: {
18
18
  "pd.datepicker.shortday.fri": string;
19
19
  "pd.datepicker.shortday.sat": string;
20
20
  "pd.datepicker.shortday.sun": string;
21
+ "pd.form.field.selectDateTimeRequired": string;
22
+ "pd.datepicker.time": string;
23
+ "pd.datepicker.today": string;
24
+ "pd.datepicker.reset": string;
21
25
  };
22
26
  //# sourceMappingURL=de.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/de.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC"}
1
+ {"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/de.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;CAwBrB,CAAC"}
@@ -11,6 +11,7 @@ export declare const templates: {
11
11
  "pd.datepicker.month.nov": string;
12
12
  "pd.datepicker.month.oct": string;
13
13
  "pd.datepicker.month.sep": string;
14
+ "pd.datepicker.reset": string;
14
15
  "pd.datepicker.shortday.fri": string;
15
16
  "pd.datepicker.shortday.mon": string;
16
17
  "pd.datepicker.shortday.sat": string;
@@ -18,5 +19,8 @@ export declare const templates: {
18
19
  "pd.datepicker.shortday.thi": string;
19
20
  "pd.datepicker.shortday.tue": string;
20
21
  "pd.datepicker.shortday.wed": string;
22
+ "pd.datepicker.time": string;
23
+ "pd.datepicker.today": string;
24
+ "pd.form.field.selectDateTimeRequired": string;
21
25
  };
22
26
  //# sourceMappingURL=en.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/en.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;CAoBrB,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/generated/locales/en.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;CAwBrB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { PdCalendar } from './pd-calendar.js';
2
- export type { CalendarCellInfo, CalendarData } from './types.ts';
1
+ export { PdCalendar } from './pd-calendar/pd-calendar.js';
2
+ export { PdDatepicker } from './pd-datepicker/pd-datepicker.js';
3
+ export type { CalendarCellInfo, CalendarData } from './types.js';
3
4
  export { templates as beTemplates } from './generated/locales/be.js';
4
5
  export { templates as deTemplates } from './generated/locales/de.js';
5
6
  export { templates as enTemplates } from './generated/locales/en.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
- import { PdCalendar } from "./pd-calendar.js";
2
- import { templates } from "./locales/be.js";
3
- import { templates as templates2 } from "./locales/de.js";
4
- import { templates as templates3 } from "./locales/en.js";
5
- export {
6
- PdCalendar,
7
- templates as beTemplates,
8
- templates2 as deTemplates,
9
- templates3 as enTemplates
10
- };
1
+ import './pd-calendar.js';
2
+ import './pd-datepicker.js';
3
+ export { templates as beTemplates } from './locales/be.js';
4
+ export { templates as deTemplates } from './locales/de.js';
5
+ export { templates as enTemplates } from './locales/en.js';
6
+ export { PdCalendar } from './pd-calendar/PdCalendar.js';
7
+ export { PdDatepicker } from './pd-datepicker/PdDatepicker.js';
@@ -11,14 +11,17 @@ const templates = {
11
11
  "pd.datepicker.month.nov": `November`,
12
12
  "pd.datepicker.month.oct": `Oktober`,
13
13
  "pd.datepicker.month.sep": `September`,
14
+ "pd.datepicker.reset": `Herstellen`,
14
15
  "pd.datepicker.shortday.fri": `Vr`,
15
16
  "pd.datepicker.shortday.mon": `Ma`,
16
17
  "pd.datepicker.shortday.sat": `Za`,
17
18
  "pd.datepicker.shortday.sun": `Zo`,
18
19
  "pd.datepicker.shortday.thi": `Do`,
19
20
  "pd.datepicker.shortday.tue": `Di`,
20
- "pd.datepicker.shortday.wed": `Wo`
21
- };
22
- export {
23
- templates
21
+ "pd.datepicker.shortday.wed": `Wo`,
22
+ "pd.datepicker.time": `Tijdstip`,
23
+ "pd.datepicker.today": `Vandaag`,
24
+ "pd.form.field.selectDateTimeRequired": `Invoer onvolledig`
24
25
  };
26
+
27
+ export { templates };
@@ -17,8 +17,11 @@ const templates = {
17
17
  "pd.datepicker.shortday.thi": `Do`,
18
18
  "pd.datepicker.shortday.fri": `Fr`,
19
19
  "pd.datepicker.shortday.sat": `Sa`,
20
- "pd.datepicker.shortday.sun": `So`
21
- };
22
- export {
23
- templates
20
+ "pd.datepicker.shortday.sun": `So`,
21
+ "pd.form.field.selectDateTimeRequired": `Eingabe unvollständig`,
22
+ "pd.datepicker.time": `Uhrzeit`,
23
+ "pd.datepicker.today": `Heute`,
24
+ "pd.datepicker.reset": `Reset`
24
25
  };
26
+
27
+ export { templates };
@@ -11,14 +11,17 @@ const templates = {
11
11
  "pd.datepicker.month.nov": `November`,
12
12
  "pd.datepicker.month.oct": `October`,
13
13
  "pd.datepicker.month.sep": `September`,
14
+ "pd.datepicker.reset": `Reset`,
14
15
  "pd.datepicker.shortday.fri": `Fri`,
15
16
  "pd.datepicker.shortday.mon": `Mon`,
16
17
  "pd.datepicker.shortday.sat": `Sat`,
17
18
  "pd.datepicker.shortday.sun": `Sun`,
18
19
  "pd.datepicker.shortday.thi": `Thu`,
19
20
  "pd.datepicker.shortday.tue": `Tue`,
20
- "pd.datepicker.shortday.wed": `Wed`
21
- };
22
- export {
23
- templates
21
+ "pd.datepicker.shortday.wed": `Wed`,
22
+ "pd.datepicker.time": `Time`,
23
+ "pd.datepicker.today": `Today`,
24
+ "pd.form.field.selectDateTimeRequired": `Input incomplete`
24
25
  };
26
+
27
+ export { templates };
@@ -0,0 +1,50 @@
1
+ import { LitElement, PropertyValues, CSSResultGroup } from 'lit';
2
+ import { CalendarData } from '../types.js';
3
+ /**
4
+ * PdCalendar displays monthly view with information (selectable day cell).
5
+ *
6
+ * @fires change-month
7
+ * @fires select-date
8
+ * @fires mouse-enter-date
9
+ * @fires mouse-leave-date
10
+ *
11
+ * @tagname pd-calendar
12
+ */
13
+ export declare class PdCalendar extends LitElement {
14
+ refDate?: Date;
15
+ selectableDates: boolean;
16
+ withYearPopup: string[];
17
+ withWheelNavigation: boolean;
18
+ withTouchNavigation: boolean;
19
+ showSelection: boolean;
20
+ hideWeekend: boolean;
21
+ prevMonthConstraint: number;
22
+ nextMonthConstraint: number;
23
+ data: CalendarData;
24
+ numberClass: string;
25
+ private _viewType;
26
+ private _currentDate;
27
+ private _wheelDelta;
28
+ private _monthName;
29
+ private _year;
30
+ private _numberOfDays;
31
+ private _daysFromPreviousMonth;
32
+ private _currentMonthNavNr;
33
+ static styles: CSSResultGroup;
34
+ connectedCallback(): void;
35
+ update(changedProperties: PropertyValues<this>): void;
36
+ render(): import('lit').TemplateResult<1>;
37
+ private renderMonthCalendar;
38
+ private _openYearPopup;
39
+ private _getWeekDays;
40
+ private _nextMonth;
41
+ private _previousMonth;
42
+ private _wheelEvent;
43
+ private _touchStartEvent;
44
+ private _touchEndEvent;
45
+ private _initFromDate;
46
+ private static _getPreviousMonthDays;
47
+ private _checkNextMonthConstraint;
48
+ private _checkPrevMonthConstraint;
49
+ }
50
+ //# sourceMappingURL=PdCalendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdCalendar.d.ts","sourceRoot":"","sources":["../../src/pd-calendar/PdCalendar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK5E,OAAO,0CAA0C,CAAC;AAIlD,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqD3C;;;;;;;;;GASG;AACH,qBACa,UAAW,SAAQ,UAAU;IAExC,OAAO,CAAC,EAAE,IAAI,CAAC;IAGf,eAAe,UAAS;IAGxB,aAAa,EAAE,MAAM,EAAE,CAAM;IAG7B,mBAAmB,UAAS;IAG5B,mBAAmB,UAAS;IAG5B,aAAa,UAAS;IAGtB,WAAW,UAAS;IAGpB,mBAAmB,SAAM;IAGzB,mBAAmB,SAAM;IAGzB,IAAI,EAAE,YAAY,CAAM;IAGxB,WAAW,SAAc;IAGzB,OAAO,CAAC,SAAS,CAAc;IAG/B,OAAO,CAAC,YAAY,CAAc;IAGlC,OAAO,CAAC,WAAW,CAAK;IAExB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,sBAAsB,CAAc;IAC5C,OAAO,CAAC,kBAAkB,CAAK;IAE/B,OAAgB,MAAM,EAAE,cAAc,CAsHpC;IAEO,iBAAiB,IAAI,IAAI;IAKzB,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAOrD,MAAM;IAOf,OAAO,CAAC,mBAAmB;IA6E3B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,yBAAyB;CAOlC"}
@@ -0,0 +1,434 @@
1
+ import { css, LitElement, html } from 'lit';
2
+ import { property, state } 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 './pd-year-popup/pd-year-popup.js';
7
+ import './pd-calendar-cell/pd-calendar-cell.js';
8
+ import { PdYearPopup } from './pd-year-popup/PdYearPopup.js';
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __decorateClass = (decorators, target, key, kind) => {
13
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
+ if (decorator = decorators[i])
16
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
17
+ if (kind && result) __defProp(target, key, result);
18
+ return result;
19
+ };
20
+ const TOUCH_MIN_MOVE = 70;
21
+ const loadLocales = () => ({
22
+ monthNames: [
23
+ msg("Januar", { id: "pd.datepicker.month.jan" }),
24
+ msg("Februar", { id: "pd.datepicker.month.feb" }),
25
+ msg("März", { id: "pd.datepicker.month.mar" }),
26
+ msg("April", { id: "pd.datepicker.month.apr" }),
27
+ msg("Mai", { id: "pd.datepicker.month.may" }),
28
+ msg("Juni", { id: "pd.datepicker.month.jun" }),
29
+ msg("Juli", { id: "pd.datepicker.month.jul" }),
30
+ msg("August", { id: "pd.datepicker.month.aug" }),
31
+ msg("September", { id: "pd.datepicker.month.sep" }),
32
+ msg("Oktober", { id: "pd.datepicker.month.oct" }),
33
+ msg("November", { id: "pd.datepicker.month.nov" }),
34
+ msg("Dezember", { id: "pd.datepicker.month.dec" })
35
+ ],
36
+ weekdaysShort: [
37
+ msg("Mo", { id: "pd.datepicker.shortday.mon" }),
38
+ msg("Di", { id: "pd.datepicker.shortday.tue" }),
39
+ msg("Mi", { id: "pd.datepicker.shortday.wed" }),
40
+ msg("Do", { id: "pd.datepicker.shortday.thi" }),
41
+ msg("Fr", { id: "pd.datepicker.shortday.fri" }),
42
+ msg("Sa", { id: "pd.datepicker.shortday.sat" }),
43
+ msg("So", { id: "pd.datepicker.shortday.sun" })
44
+ ]
45
+ });
46
+ const LOCALES = loadLocales();
47
+ const VIEW_MONTH = 2;
48
+ function isToday(date) {
49
+ const today = /* @__PURE__ */ new Date();
50
+ return !!date && date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
51
+ }
52
+ function isSelected(date1, date2) {
53
+ return !!date1 && !!date2 && date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear();
54
+ }
55
+ let PdCalendar = class extends LitElement {
56
+ constructor() {
57
+ super(...arguments);
58
+ this.selectableDates = false;
59
+ this.withYearPopup = [];
60
+ this.withWheelNavigation = false;
61
+ this.withTouchNavigation = false;
62
+ this.showSelection = false;
63
+ this.hideWeekend = false;
64
+ this.prevMonthConstraint = -1;
65
+ this.nextMonthConstraint = -1;
66
+ this.data = {};
67
+ this.numberClass = "top-left";
68
+ this._viewType = VIEW_MONTH;
69
+ this._currentDate = /* @__PURE__ */ new Date();
70
+ this._wheelDelta = 0;
71
+ this._monthName = "";
72
+ this._year = 0;
73
+ this._numberOfDays = 0;
74
+ this._daysFromPreviousMonth = [];
75
+ this._currentMonthNavNr = 0;
76
+ }
77
+ connectedCallback() {
78
+ super.connectedCallback();
79
+ this._initFromDate(this.refDate ?? /* @__PURE__ */ new Date());
80
+ }
81
+ update(changedProperties) {
82
+ if (changedProperties.has("refDate") && this.refDate) {
83
+ this._initFromDate(this.refDate);
84
+ }
85
+ super.update(changedProperties);
86
+ }
87
+ render() {
88
+ return html`
89
+ ${this.renderMonthCalendar()}
90
+ <slot name="calFooter"></slot>
91
+ `;
92
+ }
93
+ renderMonthCalendar() {
94
+ const sizeClass = this._numberOfDays >= 31 && this._daysFromPreviousMonth.length >= 5 ? "max" : "normal";
95
+ const days = Array.from({ length: this._numberOfDays }, (_, i) => {
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 ? this.data[key]?.[0] : void 0;
101
+ return html`
102
+ <pd-calendar-cell
103
+ key=${key}
104
+ .dayNumber=${day}
105
+ .weekDayNumber=${date.getDay()}
106
+ .infoTxt=${cellData?.info || ""}
107
+ ?selectEnabled=${this.selectableDates || !!cellData?.info}
108
+ ?special=${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
+ const popup = new PdYearPopup();
163
+ popup.yearSelection = this.withYearPopup;
164
+ this.shadowRoot?.getElementById("titleContentId")?.appendChild(popup);
165
+ popup.addEventListener("abort-year-selection", () => {
166
+ this.shadowRoot?.getElementById("titleContentId")?.removeChild(popup);
167
+ });
168
+ popup.addEventListener("change-year-selection", (e) => {
169
+ const year = e.detail.year;
170
+ const newDate = new Date(this._currentDate);
171
+ newDate.setFullYear(year);
172
+ this.dispatchEvent(
173
+ new CustomEvent("change-month", { detail: { newDate } })
174
+ );
175
+ this._initFromDate(newDate);
176
+ this.shadowRoot?.getElementById("titleContentId")?.removeChild(popup);
177
+ });
178
+ }
179
+ _getWeekDays() {
180
+ return this.hideWeekend ? LOCALES.weekdaysShort.slice(0, 5) : LOCALES.weekdaysShort;
181
+ }
182
+ _nextMonth() {
183
+ if (this._checkNextMonthConstraint()) {
184
+ const next = new Date(
185
+ this._currentDate.getFullYear(),
186
+ this._currentDate.getMonth() + 1,
187
+ 1
188
+ );
189
+ this.dispatchEvent(
190
+ new CustomEvent("change-month", {
191
+ detail: { newDate: next, next: true }
192
+ })
193
+ );
194
+ this._currentMonthNavNr += 1;
195
+ this._initFromDate(next);
196
+ }
197
+ }
198
+ _previousMonth() {
199
+ if (this._checkPrevMonthConstraint()) {
200
+ const prev = new Date(
201
+ this._currentDate.getFullYear(),
202
+ this._currentDate.getMonth() - 1,
203
+ 1
204
+ );
205
+ this.dispatchEvent(
206
+ new CustomEvent("change-month", {
207
+ detail: { newDate: prev, prev: true }
208
+ })
209
+ );
210
+ this._currentMonthNavNr -= 1;
211
+ this._initFromDate(prev);
212
+ }
213
+ }
214
+ _wheelEvent(e) {
215
+ if (this.withWheelNavigation) {
216
+ this._wheelDelta += e.deltaY;
217
+ if (this._wheelDelta > 360) {
218
+ this._wheelDelta = 0;
219
+ this._nextMonth();
220
+ } else if (this._wheelDelta < -360) {
221
+ this._wheelDelta = 0;
222
+ this._previousMonth();
223
+ }
224
+ }
225
+ e.preventDefault();
226
+ e.stopPropagation();
227
+ }
228
+ _touchStartEvent(e) {
229
+ if (this.withTouchNavigation) {
230
+ this._wheelDelta = e.changedTouches[0].screenX;
231
+ }
232
+ e.stopPropagation();
233
+ }
234
+ _touchEndEvent(e) {
235
+ if (this.withTouchNavigation) {
236
+ const diff = this._wheelDelta - e.changedTouches[0].screenX;
237
+ if (diff < -TOUCH_MIN_MOVE) {
238
+ this._nextMonth();
239
+ } else if (diff > TOUCH_MIN_MOVE) {
240
+ this._previousMonth();
241
+ }
242
+ }
243
+ e.stopPropagation();
244
+ }
245
+ _initFromDate(date) {
246
+ this._monthName = date.toLocaleString("default", { month: "long" });
247
+ this._year = date.getFullYear();
248
+ this._currentDate = date;
249
+ this._daysFromPreviousMonth = PdCalendar._getPreviousMonthDays(date);
250
+ const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
251
+ this._numberOfDays = lastDay.getDate();
252
+ }
253
+ static _getPreviousMonthDays(date) {
254
+ const start = new Date(date.getFullYear(), date.getMonth(), 1);
255
+ const missing = start.getDay() > 0 ? Math.abs(1 - start.getDay()) : 6;
256
+ return Array.from({ length: missing }, (_, i) => {
257
+ const d = new Date(start);
258
+ d.setDate(start.getDate() - (missing - i));
259
+ return d;
260
+ });
261
+ }
262
+ _checkNextMonthConstraint() {
263
+ return this.nextMonthConstraint === -1 || this.nextMonthConstraint > this._currentMonthNavNr;
264
+ }
265
+ _checkPrevMonthConstraint() {
266
+ return this.prevMonthConstraint === -1 || this._currentMonthNavNr > 0 || this.prevMonthConstraint > this._currentMonthNavNr * -1;
267
+ }
268
+ };
269
+ PdCalendar.styles = [
270
+ css`
271
+ :host {
272
+ --my-cell-height: var(--pd-calendar-cell-height, 70px);
273
+
274
+ display: block;
275
+ /*padding: 8px;
276
+ width: 100vw;
277
+ height: 100vh;*/
278
+ }
279
+
280
+ :host([hideWeekend]) .grid-container {
281
+ grid-template-columns: repeat(5, minmax(0, 1fr));
282
+ }
283
+
284
+ /* Layout Grid for the Calendar Component => Not really needed at the moment, more a test */
285
+ .layout-container {
286
+ width: var(--pd-calendar-width, 100%);
287
+ min-width: 220px;
288
+ height: 100%;
289
+ display: grid;
290
+ grid-template-columns: 1fr 1fr 1fr;
291
+ grid-template-rows: 40px auto;
292
+ gap: 1px;
293
+ grid-template-areas:
294
+ "header header header"
295
+ "content content content";
296
+ }
297
+
298
+ /* Grid Area positions for layout container above */
299
+ .header {
300
+ grid-area: header;
301
+ position: relative;
302
+ font-family: var(--pd-default-font-title-family);
303
+ color: var(--pd-default-font-title-col);
304
+ display: flex;
305
+ justify-content: left;
306
+ }
307
+
308
+ .header-main {
309
+ display: flex;
310
+ align-items: center;
311
+ justify-content: space-between;
312
+ width: 100%;
313
+ }
314
+
315
+ .content {
316
+ grid-area: content;
317
+ }
318
+ .footer {
319
+ grid-area: footer;
320
+ }
321
+
322
+ /* Grid definition for calendar day items */
323
+ .grid-container {
324
+ position: relative;
325
+ display: grid;
326
+ grid-template-columns: repeat(7, minmax(0, 1fr));
327
+ gap: 3px;
328
+ }
329
+
330
+ .grid-container.max {
331
+ grid-template-rows: minmax(10px, 30px) repeat(
332
+ 6,
333
+ minmax(var(--my-cell-height), 1fr)
334
+ );
335
+ }
336
+
337
+ .grid-container.normal {
338
+ grid-template-rows: minmax(10px, 30px) repeat(
339
+ 5,
340
+ minmax(var(--my-cell-height), 1fr)
341
+ );
342
+ }
343
+
344
+ .title-week-day {
345
+ display: flex;
346
+ align-items: center;
347
+ justify-content: center;
348
+ background-color: var(
349
+ --pd-calendar-week-title-bg-col,
350
+ var(--pd-default-dark-col)
351
+ );
352
+ font-size: var(--pd-calendar-weekday-title-font-size, 1em);
353
+ font-weight: bold;
354
+ color: var(--pd-calendar-week-title-font-col, var(--pd-default-bg-col));
355
+ font-family: var(--pd-default-font-title-family);
356
+ }
357
+
358
+ .content-title {
359
+ position: relative;
360
+ font-size: var(--pd-calendar-title-font-size, 1.2em);
361
+ font-weight: bold;
362
+ }
363
+
364
+ .icon-container {
365
+ display: flex;
366
+ align-items: center;
367
+ justify-content: center;
368
+ gap: 5px;
369
+ }
370
+
371
+ .arrow {
372
+ cursor: pointer;
373
+ --pd-icon-size: var(--pd-calendar-title-icon-size, 1.2em);
374
+ --pd-icon-bg-col-hover: lightgrey;
375
+ }
376
+
377
+ .year-popup-link {
378
+ color: var(--pd-default-font-link-col);
379
+ text-decoration: underline;
380
+ }
381
+
382
+ .year-popup-link:hover {
383
+ cursor: pointer;
384
+ color: var(--pd-default-hover-col);
385
+ }
386
+ `
387
+ ];
388
+ __decorateClass([
389
+ property({ type: Object })
390
+ ], PdCalendar.prototype, "refDate", 2);
391
+ __decorateClass([
392
+ property({ type: Boolean })
393
+ ], PdCalendar.prototype, "selectableDates", 2);
394
+ __decorateClass([
395
+ property({ type: Array })
396
+ ], PdCalendar.prototype, "withYearPopup", 2);
397
+ __decorateClass([
398
+ property({ type: Boolean })
399
+ ], PdCalendar.prototype, "withWheelNavigation", 2);
400
+ __decorateClass([
401
+ property({ type: Boolean })
402
+ ], PdCalendar.prototype, "withTouchNavigation", 2);
403
+ __decorateClass([
404
+ property({ type: Boolean })
405
+ ], PdCalendar.prototype, "showSelection", 2);
406
+ __decorateClass([
407
+ property({ type: Boolean, reflect: true })
408
+ ], PdCalendar.prototype, "hideWeekend", 2);
409
+ __decorateClass([
410
+ property({ type: Number })
411
+ ], PdCalendar.prototype, "prevMonthConstraint", 2);
412
+ __decorateClass([
413
+ property({ type: Number })
414
+ ], PdCalendar.prototype, "nextMonthConstraint", 2);
415
+ __decorateClass([
416
+ property({ type: Object })
417
+ ], PdCalendar.prototype, "data", 2);
418
+ __decorateClass([
419
+ property({ type: String })
420
+ ], PdCalendar.prototype, "numberClass", 2);
421
+ __decorateClass([
422
+ state()
423
+ ], PdCalendar.prototype, "_viewType", 2);
424
+ __decorateClass([
425
+ state()
426
+ ], PdCalendar.prototype, "_currentDate", 2);
427
+ __decorateClass([
428
+ state()
429
+ ], PdCalendar.prototype, "_wheelDelta", 2);
430
+ PdCalendar = __decorateClass([
431
+ localized()
432
+ ], PdCalendar);
433
+
434
+ export { PdCalendar };
@@ -6,6 +6,8 @@ import { LitElement, CSSResultGroup } from 'lit';
6
6
  * - `select-date`: Wird bei Klick auf ein auswählbares Feld ausgelöst
7
7
  * - `mouse-enter-date`: Wird beim Hover über ein auswählbares Feld ausgelöst
8
8
  * - `mouse-leave-date`: Wird beim Verlassen des Feldes ausgelöst
9
+ *
10
+ * @tagname pd-calendar-cell
9
11
  */
10
12
  export declare class PdCalendarCell extends LitElement {
11
13
  /**
@@ -37,11 +39,11 @@ export declare class PdCalendarCell extends LitElement {
37
39
  weekDayNumber: number;
38
40
  dayNumber: number;
39
41
  static styles: CSSResultGroup;
40
- render(): import('lit-html').TemplateResult<1>;
42
+ render(): import('lit').TemplateResult<1>;
41
43
  private _renderSelectableCell;
42
44
  private _renderEmptyCell;
43
45
  private _selectableCellClicked;
44
46
  private _mouseEnter;
45
47
  private _mouseLeave;
46
48
  }
47
- //# sourceMappingURL=pd-calendar-cell.d.ts.map
49
+ //# sourceMappingURL=PdCalendarCell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PdCalendarCell.d.ts","sourceRoot":"","sources":["../../../src/pd-calendar/pd-calendar-cell/PdCalendarCell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAI5D;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;;OAGG;IAEH,aAAa,UAAS;IAEtB;;OAEG;IAEH,KAAK,UAAS;IAEd;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;OAEG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,OAAO,SAAM;IAEb;;OAEG;IAEH,WAAW,SAAc;IAKzB,GAAG,SAAM;IAGT,aAAa,SAAM;IAGnB,SAAS,SAAM;IAEf,OAAgB,MAAM,EAAE,cAAc,CAkJpC;IAEO,MAAM;IAMf,OAAO,CAAC,qBAAqB;IA6B7B,OAAO,CAAC,gBAAgB;IAoBxB,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,WAAW;CAQpB"}