@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,169 @@
1
+ import { LitElement, css, html } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import { calculateFloatingPosition } from '@progressive-development/pd-utils';
4
+ import { pdIcons } from '@progressive-development/pd-icon';
5
+ import '@progressive-development/pd-icon/pd-icon';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __decorateClass = (decorators, target, key, kind) => {
9
+ var result = void 0 ;
10
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
+ if (decorator = decorators[i])
12
+ result = (decorator(target, key, result) ) || result;
13
+ if (result) __defProp(target, key, result);
14
+ return result;
15
+ };
16
+ class PdCalendarPanelBase extends LitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this._boundClickOutside = this._handleClickOutside.bind(this);
20
+ this._boundKeyDown = this._handleKeyDown.bind(this);
21
+ this._boundScroll = this._handleScroll.bind(this);
22
+ }
23
+ static {
24
+ this.panelBaseStyles = css`
25
+ :host {
26
+ display: block;
27
+ position: fixed;
28
+ z-index: 9999;
29
+ }
30
+
31
+ .panel {
32
+ width: var(--pd-calendar-panel-width, 280px);
33
+ max-height: var(--pd-calendar-panel-max-height, 70vh);
34
+ background: var(--pd-calendar-panel-bg, var(--pd-default-bg-col, #fff));
35
+ border-radius: var(--pd-radius-md, 8px);
36
+ box-shadow: var(
37
+ --pd-calendar-panel-shadow,
38
+ 0 4px 12px rgba(0, 0, 0, 0.15)
39
+ );
40
+ font-family: var(--pd-default-font-content-family);
41
+ display: flex;
42
+ flex-direction: column;
43
+ overflow: hidden;
44
+ }
45
+
46
+ .panel-header {
47
+ display: flex;
48
+ align-items: center;
49
+ gap: var(--pd-spacing-xs, 0.25rem);
50
+ padding: var(--pd-spacing-sm, 0.5rem);
51
+ min-height: 32px;
52
+ flex-shrink: 0;
53
+ }
54
+
55
+ .panel-header-content {
56
+ flex: 1;
57
+ min-width: 0;
58
+ display: flex;
59
+ align-items: center;
60
+ gap: var(--pd-spacing-xs, 0.25rem);
61
+ }
62
+
63
+ .panel-close {
64
+ cursor: pointer;
65
+ opacity: 0.5;
66
+ transition: opacity 0.15s ease;
67
+ flex-shrink: 0;
68
+ --pd-icon-size: 16px;
69
+ }
70
+
71
+ .panel-close:hover {
72
+ opacity: 1;
73
+ }
74
+
75
+ .panel-body {
76
+ padding: 0 var(--pd-spacing-sm, 0.5rem) var(--pd-spacing-sm, 0.5rem);
77
+ display: flex;
78
+ flex-direction: column;
79
+ gap: var(--pd-spacing-xs, 0.25rem);
80
+ overflow-y: auto;
81
+ min-height: 0;
82
+ }
83
+ `;
84
+ }
85
+ // ===========================================================================
86
+ // Lifecycle
87
+ // ===========================================================================
88
+ connectedCallback() {
89
+ super.connectedCallback();
90
+ requestAnimationFrame(() => {
91
+ document.addEventListener("click", this._boundClickOutside);
92
+ document.addEventListener("keydown", this._boundKeyDown);
93
+ window.addEventListener("scroll", this._boundScroll, true);
94
+ });
95
+ }
96
+ disconnectedCallback() {
97
+ super.disconnectedCallback();
98
+ document.removeEventListener("click", this._boundClickOutside);
99
+ document.removeEventListener("keydown", this._boundKeyDown);
100
+ window.removeEventListener("scroll", this._boundScroll, true);
101
+ }
102
+ updated(changed) {
103
+ if (changed.has("anchorRect") && this.anchorRect) {
104
+ this._updatePosition();
105
+ }
106
+ }
107
+ // ===========================================================================
108
+ // Render
109
+ // ===========================================================================
110
+ render() {
111
+ return html`
112
+ <div class="panel">
113
+ <div class="panel-header">
114
+ <div class="panel-header-content">${this.renderHeaderContent()}</div>
115
+ <pd-icon
116
+ class="panel-close"
117
+ icon="${pdIcons.ICON_CLOSE}"
118
+ @click="${this._onClose}"
119
+ ></pd-icon>
120
+ </div>
121
+ <div class="panel-body">${this.renderBody()}</div>
122
+ </div>
123
+ `;
124
+ }
125
+ // ===========================================================================
126
+ // Positioning
127
+ // ===========================================================================
128
+ _updatePosition() {
129
+ if (!this.anchorRect) return;
130
+ const panelEl = this.shadowRoot?.querySelector(
131
+ ".panel"
132
+ );
133
+ const width = panelEl?.offsetWidth || 280;
134
+ const height = panelEl?.offsetHeight || 200;
135
+ const pos = calculateFloatingPosition({
136
+ anchor: this.anchorRect,
137
+ floating: { width, height },
138
+ preferY: "below"
139
+ });
140
+ this.style.top = `${pos.top}px`;
141
+ this.style.left = `${pos.left}px`;
142
+ }
143
+ // ===========================================================================
144
+ // Close
145
+ // ===========================================================================
146
+ _onClose() {
147
+ this.dispatchEvent(
148
+ new CustomEvent("close-panel", { bubbles: true, composed: true })
149
+ );
150
+ }
151
+ _handleClickOutside(e) {
152
+ if (!e.composedPath().includes(this)) {
153
+ this._onClose();
154
+ }
155
+ }
156
+ _handleKeyDown(e) {
157
+ if (e.key === "Escape") {
158
+ this._onClose();
159
+ }
160
+ }
161
+ _handleScroll() {
162
+ this._onClose();
163
+ }
164
+ }
165
+ __decorateClass([
166
+ property({ type: Object })
167
+ ], PdCalendarPanelBase.prototype, "anchorRect");
168
+
169
+ export { PdCalendarPanelBase };
@@ -0,0 +1,41 @@
1
+ import { CSSResultGroup, LitElement, PropertyValues } from 'lit';
2
+ import { ButtonData } from '@progressive-development/pd-forms';
3
+ import { AvailableCalendarPeriods, AvailableCalendarViewTypes } from '../../types';
4
+ export declare class CalendarButtonBar extends LitElement {
5
+ availableViewTypes: AvailableCalendarViewTypes;
6
+ availablePeriods: AvailableCalendarPeriods;
7
+ withYearPopup: string[];
8
+ currentTitle?: string;
9
+ currentDate?: Date;
10
+ year: number;
11
+ withSettings?: boolean;
12
+ hideNext?: boolean;
13
+ hidePrev?: boolean;
14
+ /** When true, navigation buttons are not rendered at all (as opposed to disabled). */
15
+ hideNavigation: boolean;
16
+ isCompact?: boolean;
17
+ _currentViewOptions: ButtonData[];
18
+ _currentPeriodOptions: ButtonData[];
19
+ /** Currently selected view type index for the button group. */
20
+ private _currentViewTypeIndex;
21
+ /** Currently selected period index for the button select group. */
22
+ private _currentPeriodIndex;
23
+ private _viewTypeSelectionEl;
24
+ private _periodSelectionEl;
25
+ private _openYearPopupState;
26
+ static styles: CSSResultGroup;
27
+ willUpdate(changedProps: PropertyValues<this>): void;
28
+ render(): import('lit').TemplateResult<1>;
29
+ private _navigationEvent;
30
+ private _changeViewEvent;
31
+ private _changePeriodEvent;
32
+ /**
33
+ * Opens the year selection popup with keyboard support.
34
+ */
35
+ private _onTriggerKeyDown;
36
+ /**
37
+ * Opens the year popup and manages focus.
38
+ */
39
+ private _openYearPopup;
40
+ }
41
+ //# sourceMappingURL=calendar-button-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-button-bar.d.ts","sourceRoot":"","sources":["../../../src/shared/calendar-button-bar/calendar-button-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK5E,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,6CAA6C,CAAC;AACrD,OAAO,mDAAmD,CAAC;AAC3D,OAAO,0DAA0D,CAAC;AAElE,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAG3B,MAAM,aAAa,CAAC;AAgBrB,qBAEa,iBAAkB,SAAQ,UAAU;IAE/C,kBAAkB,EAAG,0BAA0B,CAAC;IAGhD,gBAAgB,EAAG,wBAAwB,CAAC;IAG5C,aAAa,EAAE,MAAM,EAAE,CAAM;IAG7B,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,WAAW,CAAC,EAAE,IAAI,CAAC;IAGnB,IAAI,EAAE,MAAM,CAAK;IAGjB,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,sFAAsF;IAEtF,cAAc,UAAS;IAGvB,SAAS,CAAC,EAAE,OAAO,CAAC;IAIpB,mBAAmB,EAAE,UAAU,EAAE,CAI/B;IAGF,qBAAqB,EAAE,UAAU,EAAE,CAKjC;IAEF,+DAA+D;IAE/D,OAAO,CAAC,qBAAqB,CAAc;IAE3C,mEAAmE;IAEnE,OAAO,CAAC,mBAAmB,CAAc;IAGzC,OAAO,CAAC,oBAAoB,CAAM;IAGlC,OAAO,CAAC,kBAAkB,CAAM;IAEhC,OAAO,CAAC,mBAAmB,CAAkB;IAE7C,OAAgB,MAAM,EAAE,cAAc,CAyIpC;IAEO,UAAU,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAgCpD,MAAM;IAsFf,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,kBAAkB;IA2B1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,cAAc;CA8CvB"}
@@ -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,9 @@
1
+ export declare const loadLocales: () => {
2
+ monthNames: string[];
3
+ weekdaysShort: string[];
4
+ };
5
+ export declare const LOCALES: {
6
+ monthNames: string[];
7
+ weekdaysShort: string[];
8
+ };
9
+ //# sourceMappingURL=calendar-locales.d.ts.map
@@ -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 };