@eui/eds-wc 22.0.0-alpha.17 → 22.0.0-alpha.18

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 (115) hide show
  1. package/eds-accordion/eds-wc-accordion.js +3 -3
  2. package/eds-alert/eds-wc-alert.d.ts +1 -1
  3. package/eds-alert/eds-wc-alert.js +2 -2
  4. package/eds-blockquote/eds-wc-blockquote.js +1 -1
  5. package/eds-calendar/eds-wc-calendar.d.ts +274 -0
  6. package/eds-calendar/eds-wc-calendar.d.ts.map +1 -0
  7. package/eds-calendar/eds-wc-calendar.js +1236 -0
  8. package/eds-calendar/eds-wc-calendar.js.map +1 -0
  9. package/eds-calendar/index.d.ts +3 -0
  10. package/eds-calendar/index.d.ts.map +1 -0
  11. package/eds-calendar/index.js +2 -0
  12. package/eds-calendar/index.js.map +1 -0
  13. package/eds-card/eds-wc-card.js +1 -1
  14. package/eds-date-block/eds-wc-date-block.js +2 -2
  15. package/eds-datepicker/eds-wc-datepicker.js +1 -1
  16. package/eds-dialog/eds-wc-dialog.js +1 -1
  17. package/eds-discussion-thread/eds-wc-discussion-thread.js +2 -2
  18. package/eds-empty-state/eds-wc-empty-state.js +1 -1
  19. package/eds-fieldset/eds-wc-fieldset.js +1 -1
  20. package/eds-file-upload/eds-wc-file-upload.js +1 -1
  21. package/eds-growl/eds-wc-growl.js +1 -1
  22. package/eds-input-checkbox/eds-wc-input-checkbox.js +3 -3
  23. package/eds-input-number/eds-wc-input-number.js +1 -1
  24. package/eds-input-radio/eds-wc-input-radio.js +3 -3
  25. package/eds-input-text/eds-wc-input-text.js +1 -1
  26. package/eds-label/eds-wc-label.js +1 -1
  27. package/eds-language-selector/eds-wc-language-selector.d.ts +108 -0
  28. package/eds-language-selector/eds-wc-language-selector.d.ts.map +1 -0
  29. package/eds-language-selector/eds-wc-language-selector.js +650 -0
  30. package/eds-language-selector/eds-wc-language-selector.js.map +1 -0
  31. package/eds-language-selector/index.d.ts +3 -0
  32. package/eds-language-selector/index.d.ts.map +1 -0
  33. package/eds-language-selector/index.js +2 -0
  34. package/eds-language-selector/index.js.map +1 -0
  35. package/eds-menu/eds-wc-menu.d.ts +178 -0
  36. package/eds-menu/eds-wc-menu.d.ts.map +1 -0
  37. package/eds-menu/eds-wc-menu.js +933 -0
  38. package/eds-menu/eds-wc-menu.js.map +1 -0
  39. package/eds-menu/index.d.ts +3 -0
  40. package/eds-menu/index.d.ts.map +1 -0
  41. package/eds-menu/index.js +2 -0
  42. package/eds-menu/index.js.map +1 -0
  43. package/eds-message-box/eds-wc-message-box.js +1 -1
  44. package/eds-multiselect/eds-wc-multiselect.d.ts +118 -0
  45. package/eds-multiselect/eds-wc-multiselect.d.ts.map +1 -0
  46. package/eds-multiselect/eds-wc-multiselect.js +617 -0
  47. package/eds-multiselect/eds-wc-multiselect.js.map +1 -0
  48. package/eds-multiselect/index.d.ts +3 -0
  49. package/eds-multiselect/index.d.ts.map +1 -0
  50. package/eds-multiselect/index.js +2 -0
  51. package/eds-multiselect/index.js.map +1 -0
  52. package/eds-overlay/eds-wc-overlay-content.d.ts +17 -0
  53. package/eds-overlay/eds-wc-overlay-content.d.ts.map +1 -0
  54. package/eds-overlay/eds-wc-overlay-content.js +34 -0
  55. package/eds-overlay/eds-wc-overlay-content.js.map +1 -0
  56. package/eds-overlay/eds-wc-overlay-footer.d.ts +17 -0
  57. package/eds-overlay/eds-wc-overlay-footer.d.ts.map +1 -0
  58. package/eds-overlay/eds-wc-overlay-footer.js +35 -0
  59. package/eds-overlay/eds-wc-overlay-footer.js.map +1 -0
  60. package/eds-overlay/eds-wc-overlay-header-action-items.d.ts +18 -0
  61. package/eds-overlay/eds-wc-overlay-header-action-items.d.ts.map +1 -0
  62. package/eds-overlay/eds-wc-overlay-header-action-items.js +34 -0
  63. package/eds-overlay/eds-wc-overlay-header-action-items.js.map +1 -0
  64. package/eds-overlay/eds-wc-overlay-header-label.d.ts +17 -0
  65. package/eds-overlay/eds-wc-overlay-header-label.d.ts.map +1 -0
  66. package/eds-overlay/eds-wc-overlay-header-label.js +32 -0
  67. package/eds-overlay/eds-wc-overlay-header-label.js.map +1 -0
  68. package/eds-overlay/eds-wc-overlay-header-sublabel.d.ts +17 -0
  69. package/eds-overlay/eds-wc-overlay-header-sublabel.d.ts.map +1 -0
  70. package/eds-overlay/eds-wc-overlay-header-sublabel.js +32 -0
  71. package/eds-overlay/eds-wc-overlay-header-sublabel.js.map +1 -0
  72. package/eds-overlay/eds-wc-overlay-header.d.ts +25 -0
  73. package/eds-overlay/eds-wc-overlay-header.d.ts.map +1 -0
  74. package/eds-overlay/eds-wc-overlay-header.js +105 -0
  75. package/eds-overlay/eds-wc-overlay-header.js.map +1 -0
  76. package/eds-overlay/eds-wc-overlay.d.ts +92 -0
  77. package/eds-overlay/eds-wc-overlay.d.ts.map +1 -0
  78. package/eds-overlay/eds-wc-overlay.js +336 -0
  79. package/eds-overlay/eds-wc-overlay.js.map +1 -0
  80. package/eds-overlay/index.d.ts +9 -0
  81. package/eds-overlay/index.d.ts.map +1 -0
  82. package/eds-overlay/index.js +8 -0
  83. package/eds-overlay/index.js.map +1 -0
  84. package/eds-popover/eds-wc-popover.js +1 -1
  85. package/eds-progress-bar/eds-wc-progress-bar.js +1 -1
  86. package/eds-progress-circle/eds-wc-progress-circle.js +3 -3
  87. package/eds-select/eds-wc-select.js +1 -1
  88. package/eds-skeleton/eds-wc-skeleton.js +1 -1
  89. package/eds-swiper/eds-wc-swiper.d.ts +100 -0
  90. package/eds-swiper/eds-wc-swiper.d.ts.map +1 -0
  91. package/eds-swiper/eds-wc-swiper.js +384 -0
  92. package/eds-swiper/eds-wc-swiper.js.map +1 -0
  93. package/eds-swiper/index.d.ts +2 -0
  94. package/eds-swiper/index.d.ts.map +1 -0
  95. package/eds-swiper/index.js +2 -0
  96. package/eds-swiper/index.js.map +1 -0
  97. package/eds-table/eds-wc-table.js +1 -1
  98. package/eds-tabs/eds-wc-tabs.js +1 -1
  99. package/eds-textarea/eds-wc-textarea.js +1 -1
  100. package/eds-timeline/eds-wc-timeline.js +2 -2
  101. package/eds-timepicker/eds-wc-timepicker.js +1 -1
  102. package/eds-user-profile/eds-wc-user-profile.d.ts +146 -0
  103. package/eds-user-profile/eds-wc-user-profile.d.ts.map +1 -0
  104. package/eds-user-profile/eds-wc-user-profile.js +562 -0
  105. package/eds-user-profile/eds-wc-user-profile.js.map +1 -0
  106. package/eds-user-profile/index.d.ts +2 -0
  107. package/eds-user-profile/index.d.ts.map +1 -0
  108. package/eds-user-profile/index.js +2 -0
  109. package/eds-user-profile/index.js.map +1 -0
  110. package/eds-wizard/eds-wc-wizard.js +1 -1
  111. package/index.d.ts +12 -0
  112. package/index.d.ts.map +1 -1
  113. package/index.js +12 -0
  114. package/index.js.map +1 -1
  115. package/package.json +29 -1
@@ -0,0 +1,1236 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, css, nothing } from 'lit';
8
+ import { customElement, property, state } from 'lit/decorators.js';
9
+ import { EdsBaseElement } from '../shared/eds-base.js';
10
+ const DAY_NAME_MAP = {
11
+ monday: 0, mon: 0,
12
+ tuesday: 1, tue: 1,
13
+ wednesday: 2, wed: 2,
14
+ thursday: 3, thu: 3,
15
+ friday: 4, fri: 4,
16
+ saturday: 5, sat: 5,
17
+ sunday: 6, sun: 6,
18
+ };
19
+ /**
20
+ * Parses a starting-day input (day name/abbreviation or 0-6) into an ISO-Monday-based
21
+ * index (0=Monday … 6=Sunday). Mirrors the Angular `parseStartingDay` util.
22
+ */
23
+ export function parseStartingDay(startingDay) {
24
+ if (typeof startingDay === 'number' || /^\d+$/.test(String(startingDay))) {
25
+ const numValue = typeof startingDay === 'string' ? parseInt(startingDay, 10) : startingDay;
26
+ if (numValue >= 0 && numValue <= 6) {
27
+ return numValue;
28
+ }
29
+ throw new Error(`Invalid starting day number: ${numValue}. Must be 0-6.`);
30
+ }
31
+ if (typeof startingDay === 'string') {
32
+ const normalized = startingDay.toLowerCase().trim();
33
+ if (normalized in DAY_NAME_MAP) {
34
+ return DAY_NAME_MAP[normalized];
35
+ }
36
+ throw new Error(`Invalid starting day: "${startingDay}". Use day name or abbreviation.`);
37
+ }
38
+ throw new Error('Starting day must be a string (day name) or number (0-6).');
39
+ }
40
+ /* -------------------------------------------------------------------------- */
41
+ /* eds-wc-calendar-day — a single day cell in the monthly grid. */
42
+ /* -------------------------------------------------------------------------- */
43
+ /**
44
+ * `<eds-wc-calendar-day>` — a single day cell inside the monthly calendar grid.
45
+ *
46
+ * Projection of the Angular `EdsCalendarDay` sub-component. Renders the day number
47
+ * button, an add-event icon button on hover, event tags, and a "+N more" popover
48
+ * trigger. Used internally by `<eds-wc-calendar-monthly>` but registered standalone
49
+ * so it can be composed directly.
50
+ *
51
+ * @fires add-item - `detail: {}` — fired when the add-event button is clicked.
52
+ *
53
+ * @cssprop --_eds-calendar-day-height
54
+ */
55
+ let EdsWcCalendarDay = class EdsWcCalendarDay extends EdsBaseElement {
56
+ constructor() {
57
+ super(...arguments);
58
+ this.dayOfTheMonth = 4;
59
+ this.maxNumberOfEventsToShow = 2;
60
+ this.disabled = false;
61
+ this.isSelected = false;
62
+ this.events = [];
63
+ this._hovered = false;
64
+ this._showAll = false;
65
+ }
66
+ get _renderNewEvent() {
67
+ return this._hovered && this.dayOfTheMonth !== null;
68
+ }
69
+ static { this.styles = css `
70
+ :host, *, *::before, *::after { box-sizing: border-box; }
71
+ :host {
72
+ --_eds-calendar-day-height: 8rem;
73
+ height: var(--_eds-calendar-day-height);
74
+ display: flex;
75
+ flex-direction: column;
76
+ justify-content: space-between;
77
+ align-items: flex-start;
78
+ gap: var(--eds-sp-2xs);
79
+ overflow: hidden;
80
+ width: 100%;
81
+ padding: var(--eds-sp-xs);
82
+ }
83
+ :host([disabled]) { opacity: 0.5; pointer-events: none; }
84
+
85
+ .eds-calendar-day__header {
86
+ display: flex;
87
+ flex-direction: row;
88
+ justify-content: space-between;
89
+ width: 100%;
90
+ }
91
+ .eds-calendar-day__day-btn {
92
+ display: inline-flex; align-items: center; justify-content: center;
93
+ min-width: var(--eds-si-2xl, 2rem); height: var(--eds-si-2xl, 2rem);
94
+ padding: 0 var(--eds-sp-2xs);
95
+ border: none; cursor: pointer; font: var(--eds-f-label-m-semibold);
96
+ border-radius: var(--eds-br-s); font-family: inherit;
97
+ background: transparent; color: var(--eds-c-foreground);
98
+ }
99
+ .eds-calendar-day__day-btn:hover { background: var(--eds-c-surface-hover); }
100
+ .eds-calendar-day__day-btn:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
101
+ .eds-calendar-day__day-btn--selected {
102
+ background: var(--eds-c-surface-primary);
103
+ color: var(--eds-c-on-surface-primary);
104
+ border-radius: var(--eds-br-full);
105
+ }
106
+
107
+ .eds-calendar-day__add-btn {
108
+ display: inline-flex; align-items: center; justify-content: center;
109
+ width: var(--eds-si-xl, 1.75rem); height: var(--eds-si-xl, 1.75rem);
110
+ border: none; background: transparent; cursor: pointer;
111
+ border-radius: var(--eds-br-s); color: var(--eds-c-foreground-info);
112
+ font-family: inherit;
113
+ }
114
+ .eds-calendar-day__add-btn:hover { background: var(--eds-c-surface-hover); }
115
+ .eds-calendar-day__add-btn:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
116
+ .eds-calendar-day__add-btn svg { width: var(--eds-is-s); height: var(--eds-is-s); fill: currentColor; }
117
+
118
+ .eds-calendar-day__show-more {
119
+ cursor: pointer;
120
+ font: var(--eds-f-paragraph-xs);
121
+ color: var(--eds-c-foreground-subtle);
122
+ background: none; border: none; padding: 0; font-family: inherit;
123
+ }
124
+ .eds-calendar-day__show-more:hover { text-decoration: underline; }
125
+ .eds-calendar-day__show-more:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
126
+
127
+ .eds-calendar-day__events {
128
+ display: flex; flex-direction: column; align-items: flex-start;
129
+ gap: var(--eds-sp-2xs); margin-top: auto; width: 100%;
130
+ }
131
+
132
+ .eds-calendar-day__event-tag {
133
+ display: inline-flex; align-items: center;
134
+ max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
135
+ padding: var(--eds-sp-3xs) var(--eds-sp-2xs);
136
+ border-radius: var(--eds-br-s); font: var(--eds-f-paragraph-xs);
137
+ background: var(--_eds-calendar-day-tag-surface, var(--eds-c-surface-info-subtler));
138
+ color: var(--_eds-calendar-day-tag-fg, var(--eds-c-foreground));
139
+ }
140
+ .eds-calendar-day__event-tag--success { --_eds-calendar-day-tag-surface: var(--eds-c-surface-success-subtler); }
141
+ .eds-calendar-day__event-tag--warning { --_eds-calendar-day-tag-surface: var(--eds-c-surface-warning-subtler); }
142
+ .eds-calendar-day__event-tag--critical { --_eds-calendar-day-tag-surface: var(--eds-c-surface-critical-subtler); }
143
+ .eds-calendar-day__event-tag--info { --_eds-calendar-day-tag-surface: var(--eds-c-surface-info-subtler); }
144
+
145
+ .eds-calendar-day__popover {
146
+ display: none; position: absolute; z-index: 10000; margin-top: var(--eds-sp-3xs);
147
+ background: var(--eds-c-surface-elevation); border: var(--eds-bw-xs) solid var(--eds-c-border-divider);
148
+ border-radius: var(--eds-br-m); box-shadow: var(--eds-sh-2); padding: var(--eds-sp-s);
149
+ min-width: 200px;
150
+ }
151
+ .eds-calendar-day__popover.open { display: block; }
152
+ .eds-calendar-day__popover-title { font: var(--eds-f-label-m-semibold); margin-bottom: var(--eds-sp-xs); }
153
+ .eds-calendar-day__popover-events { display: flex; flex-direction: column; align-items: flex-start; gap: var(--eds-sp-xs); }
154
+ `; }
155
+ render() {
156
+ const baseUrl = EdsBaseElement.assetsBaseUrl;
157
+ const plusHref = `${baseUrl}/eds/icons/sprites/core.svg#plus`;
158
+ const events = this.events ?? [];
159
+ const visible = events.slice(0, this.maxNumberOfEventsToShow);
160
+ const overflow = events.length - this.maxNumberOfEventsToShow;
161
+ return html `
162
+ <div
163
+ @mouseenter="${this._onMouseOver}"
164
+ @mouseleave="${this._onMouseOut}"
165
+ style="display:contents;">
166
+ ${this.dayOfTheMonth !== null ? html `
167
+ <div class="eds-calendar-day__header">
168
+ <button
169
+ type="button"
170
+ class="eds-calendar-day__day-btn ${this.isSelected ? 'eds-calendar-day__day-btn--selected' : ''}"
171
+ aria-pressed="${this.isSelected ? 'true' : 'false'}">
172
+ ${this.dayOfTheMonth}
173
+ </button>
174
+ ${this._renderNewEvent ? html `
175
+ <button
176
+ type="button"
177
+ class="eds-calendar-day__add-btn"
178
+ aria-label="Add new event"
179
+ @click="${this._onAddClick}">
180
+ <svg aria-hidden="true"><use href="${plusHref}"></use></svg>
181
+ </button>
182
+ ` : nothing}
183
+ </div>
184
+ ` : nothing}
185
+
186
+ <div class="eds-calendar-day__events">
187
+ ${visible.map(ev => this._renderTag(ev))}
188
+ ${overflow > 0 ? html `
189
+ <button type="button" class="eds-calendar-day__show-more" @click="${this._togglePopover}">
190
+ +${overflow} more
191
+ </button>
192
+ ` : nothing}
193
+ </div>
194
+
195
+ <div class="eds-calendar-day__popover ${this._showAll ? 'open' : ''}" role="dialog" aria-label="Events">
196
+ <div class="eds-calendar-day__popover-title">Events</div>
197
+ <div class="eds-calendar-day__popover-events">
198
+ ${events.map(ev => this._renderTag(ev))}
199
+ </div>
200
+ </div>
201
+ </div>
202
+ `;
203
+ }
204
+ _renderTag(ev) {
205
+ const cls = ev.type ? `eds-calendar-day__event-tag eds-calendar-day__event-tag--${this._tagColor(ev.type)}` : 'eds-calendar-day__event-tag';
206
+ return html `<span class="${cls}">${ev.label}</span>`;
207
+ }
208
+ _tagColor(type) {
209
+ switch (type) {
210
+ case 'success': return 'success';
211
+ case 'warning': return 'warning';
212
+ case 'critical': return 'critical';
213
+ case 'primary':
214
+ case 'info':
215
+ default: return 'info';
216
+ }
217
+ }
218
+ _onMouseOver() {
219
+ if (!this.disabled)
220
+ this._hovered = true;
221
+ }
222
+ _onMouseOut() {
223
+ this._hovered = false;
224
+ }
225
+ _onAddClick() {
226
+ this.dispatchEvent(new CustomEvent('add-item', { bubbles: true, composed: true, detail: {} }));
227
+ }
228
+ _togglePopover() {
229
+ this._showAll = !this._showAll;
230
+ }
231
+ };
232
+ __decorate([
233
+ property({ type: Number, attribute: 'day-of-the-month' })
234
+ ], EdsWcCalendarDay.prototype, "dayOfTheMonth", void 0);
235
+ __decorate([
236
+ property({ type: Number, attribute: 'max-number-of-events-to-show' })
237
+ ], EdsWcCalendarDay.prototype, "maxNumberOfEventsToShow", void 0);
238
+ __decorate([
239
+ property({ type: Boolean, reflect: true })
240
+ ], EdsWcCalendarDay.prototype, "disabled", void 0);
241
+ __decorate([
242
+ property({ type: Boolean, reflect: true, attribute: 'is-selected' })
243
+ ], EdsWcCalendarDay.prototype, "isSelected", void 0);
244
+ __decorate([
245
+ property({ type: Array })
246
+ ], EdsWcCalendarDay.prototype, "events", void 0);
247
+ __decorate([
248
+ state()
249
+ ], EdsWcCalendarDay.prototype, "_hovered", void 0);
250
+ __decorate([
251
+ state()
252
+ ], EdsWcCalendarDay.prototype, "_showAll", void 0);
253
+ EdsWcCalendarDay = __decorate([
254
+ customElement('eds-wc-calendar-day')
255
+ ], EdsWcCalendarDay);
256
+ export { EdsWcCalendarDay };
257
+ /* -------------------------------------------------------------------------- */
258
+ /* eds-wc-calendar-monthly — month grid. */
259
+ /* -------------------------------------------------------------------------- */
260
+ /**
261
+ * `<eds-wc-calendar-monthly>` — the month grid view.
262
+ *
263
+ * Projection of the Angular `EdsCalendarMonthly`. Builds a 6×7 day grid for the
264
+ * reference `date`, honouring the disable rules, weekend/today flags, and event
265
+ * placement, and renders each cell as an `<eds-wc-calendar-day>`.
266
+ *
267
+ * @fires new-event-add - `detail: { day: EdsWcCalendarDayCell }` — fired when a day's
268
+ * add-event button is clicked.
269
+ */
270
+ let EdsWcCalendarMonthly = class EdsWcCalendarMonthly extends EdsBaseElement {
271
+ constructor() {
272
+ super(...arguments);
273
+ this.disabledDays = [];
274
+ this.events = [];
275
+ this.hasEmptyValue = false;
276
+ this.mode = 'truncated';
277
+ this.startingDay = 0;
278
+ this.date = new Date();
279
+ this.fillPreviousMonth = false;
280
+ this.fillNextMonth = false;
281
+ this.disableFutureDates = false;
282
+ this.disablePastDates = false;
283
+ this.disableWeekends = false;
284
+ this.disabledDaysNotInMonth = true;
285
+ this.locale = 'en-US';
286
+ }
287
+ static { this.styles = css `
288
+ :host, *, *::before, *::after { box-sizing: border-box; }
289
+ :host { display: block; }
290
+
291
+ table {
292
+ width: 100%;
293
+ table-layout: fixed;
294
+ border-collapse: collapse;
295
+ border-radius: var(--eds-br-s);
296
+ overflow: hidden;
297
+ }
298
+ table.eds-calendar-monthly--compact {
299
+ width: auto;
300
+ table-layout: auto;
301
+ }
302
+ table.eds-calendar-monthly--compact .eds-calendar-monthly--day {
303
+ height: 4rem;
304
+ }
305
+
306
+ .eds-calendar-monthly--day-header {
307
+ padding: var(--eds-sp-xs);
308
+ text-align: left;
309
+ font: var(--eds-f-label-s-semibold);
310
+ }
311
+
312
+ .eds-calendar-monthly--day {
313
+ overflow: hidden;
314
+ text-overflow: ellipsis;
315
+ border: 1px solid var(--eds-c-border-divider);
316
+ padding: var(--eds-sp-xs);
317
+ vertical-align: top;
318
+ height: 8rem;
319
+ position: relative;
320
+ }
321
+ .eds-calendar-monthly--day:hover { background-color: var(--eds-c-surface-hover); }
322
+ .eds-calendar-monthly--day.weekend { background-color: var(--eds-c-surface-default); }
323
+ .eds-calendar-monthly--day.disabled { opacity: 0.5; }
324
+ `; }
325
+ render() {
326
+ const weeks = this._monthlyCalendar();
327
+ const headers = this._daysHeaderArray();
328
+ return html `
329
+ <table
330
+ role="grid"
331
+ aria-label="Calendar"
332
+ class="${this.mode === 'compact' ? 'eds-calendar-monthly--compact' : 'eds-calendar-monthly--truncated'}">
333
+ <thead>
334
+ <tr>
335
+ ${headers.map(h => html `<th class="eds-calendar-monthly--day-header" scope="col">${h.short}</th>`)}
336
+ </tr>
337
+ </thead>
338
+ <tbody>
339
+ ${weeks.map(week => html `
340
+ <tr>
341
+ ${week.map(day => html `
342
+ <td
343
+ class="eds-calendar-monthly--day ${day?.isWeekend ? 'weekend' : ''} ${day?.isDisabled ? 'disabled' : ''}"
344
+ aria-disabled="${day?.isDisabled ? 'true' : nothing}"
345
+ aria-current="${day?.isToday ? 'date' : nothing}">
346
+ ${day ? html `
347
+ <eds-wc-calendar-day
348
+ day-of-the-month="${day.day}"
349
+ ?is-selected="${!!day.isToday}"
350
+ ?disabled="${!!day.isDisabled}"
351
+ max-number-of-events-to-show="2"
352
+ .events="${day.events ?? []}"
353
+ @add-item="${() => this._onAddNewItem(day)}">
354
+ </eds-wc-calendar-day>
355
+ ` : nothing}
356
+ </td>
357
+ `)}
358
+ </tr>
359
+ `)}
360
+ </tbody>
361
+ </table>
362
+ `;
363
+ }
364
+ _onAddNewItem(day) {
365
+ this.dispatchEvent(new CustomEvent('new-event-add', { bubbles: true, composed: true, detail: { day } }));
366
+ }
367
+ _daysHeaderArray() {
368
+ const days = Array.from({ length: 7 }, (_, i) => new Date(2024, 0, 1 + i));
369
+ return days.slice(this.startingDay).concat(days.slice(0, this.startingDay)).map(day => ({
370
+ short: day.toLocaleDateString(this.locale, { weekday: 'short' }),
371
+ date: day,
372
+ }));
373
+ }
374
+ _monthlyCalendar() {
375
+ const currentEvents = this.events ?? [];
376
+ return this._generateCalendarGrid(this.date.getMonth() + 1, this.startingDay, {
377
+ year: this.date.getFullYear(),
378
+ fillPreviousMonth: this.fillPreviousMonth,
379
+ fillNextMonth: this.fillNextMonth,
380
+ })
381
+ .filter(week => week.some(day => day && day.isCurrentMonth))
382
+ .map(week => week.map(day => {
383
+ if (day) {
384
+ let isDisabled = false;
385
+ if (this.disableFutureDates && day.isFuture)
386
+ isDisabled = true;
387
+ if (this.disablePastDates && day.isPast)
388
+ isDisabled = true;
389
+ if (this.disableWeekends && day.isWeekend)
390
+ isDisabled = true;
391
+ if (this.disabledDaysNotInMonth && !day.isCurrentMonth)
392
+ isDisabled = true;
393
+ const date = new Date(day.year, day.month - 1, day.day);
394
+ if (this.disabledDays.some(d => d.toDateString() === date.toDateString())) {
395
+ isDisabled = true;
396
+ }
397
+ day.isDisabled = isDisabled;
398
+ const dayEvents = currentEvents.filter(event => {
399
+ const ed = new Date(event.date);
400
+ return ed.getDate() === day.day &&
401
+ (ed.getMonth() + 1) === day.month &&
402
+ ed.getFullYear() === day.year;
403
+ });
404
+ if (dayEvents.length > 0)
405
+ day.events = dayEvents;
406
+ }
407
+ return day;
408
+ }));
409
+ }
410
+ _generateCalendarGrid(month, startingDay, options = {}) {
411
+ if (!Number.isInteger(month) || month < 1 || month > 12) {
412
+ throw new Error('Month must be an integer between 1 and 12.');
413
+ }
414
+ const { year = new Date().getFullYear(), fillPreviousMonth = false, fillNextMonth = false } = options;
415
+ const grid = Array(6).fill(null).map(() => Array(7).fill(null));
416
+ const daysInMonth = this._getDaysInMonth(month, year);
417
+ const firstDayOfMonth = this._getFirstDayOfMonth(month, year);
418
+ const firstDayISO = (firstDayOfMonth + 6) % 7;
419
+ const columnOffset = (firstDayISO - startingDay + 7) % 7;
420
+ if (fillPreviousMonth && columnOffset > 0) {
421
+ const prevMonth = month === 1 ? 12 : month - 1;
422
+ const prevYear = month === 1 ? year - 1 : year;
423
+ const daysInPrevMonth = this._getDaysInMonth(prevMonth, prevYear);
424
+ for (let i = columnOffset - 1; i >= 0; i--) {
425
+ const day = daysInPrevMonth - (columnOffset - 1 - i);
426
+ grid[0][i] = this._createDayCell(day, prevMonth, prevYear, false);
427
+ }
428
+ }
429
+ let currentDay = 1;
430
+ let row = 0;
431
+ let col = columnOffset;
432
+ while (currentDay <= daysInMonth) {
433
+ grid[row][col] = this._createDayCell(currentDay, month, year, true);
434
+ currentDay++;
435
+ col++;
436
+ if (col === 7) {
437
+ col = 0;
438
+ row++;
439
+ }
440
+ }
441
+ if (fillNextMonth && (row < 6 || col > 0)) {
442
+ const nextMonth = month === 12 ? 1 : month + 1;
443
+ const nextYear = month === 12 ? year + 1 : year;
444
+ let nextMonthDay = 1;
445
+ while (row < 6) {
446
+ while (col < 7) {
447
+ if (grid[row][col] === null) {
448
+ grid[row][col] = this._createDayCell(nextMonthDay, nextMonth, nextYear, false);
449
+ nextMonthDay++;
450
+ }
451
+ col++;
452
+ }
453
+ col = 0;
454
+ row++;
455
+ }
456
+ }
457
+ return grid;
458
+ }
459
+ _getDaysInMonth(month, year) {
460
+ return new Date(year, month, 0).getDate();
461
+ }
462
+ _getFirstDayOfMonth(month, year) {
463
+ return new Date(year, month - 1, 1).getDay();
464
+ }
465
+ _getISOWeekNumber(date) {
466
+ const tempDate = new Date(date.getTime());
467
+ tempDate.setHours(0, 0, 0, 0);
468
+ tempDate.setDate(tempDate.getDate() + 3 - (tempDate.getDay() + 6) % 7);
469
+ const week1 = new Date(tempDate.getFullYear(), 0, 4);
470
+ return 1 + Math.round(((tempDate.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
471
+ }
472
+ _compareDatesAtDayPrecision(date1, date2) {
473
+ const d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
474
+ const d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
475
+ if (d1 < d2)
476
+ return -1;
477
+ if (d1 > d2)
478
+ return 1;
479
+ return 0;
480
+ }
481
+ _createDayCell(day, month, year, isCurrentMonth) {
482
+ const cellDate = new Date(year, month - 1, day);
483
+ const today = new Date();
484
+ const weekendDays = [0, 6];
485
+ const comparison = this._compareDatesAtDayPrecision(cellDate, today);
486
+ const daysInMonth = this._getDaysInMonth(month, year);
487
+ return {
488
+ day,
489
+ month,
490
+ year,
491
+ isCurrentMonth,
492
+ dayOfWeek: cellDate.getDay(),
493
+ dateString: `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`,
494
+ isToday: comparison === 0,
495
+ isPast: comparison === -1,
496
+ isFuture: comparison === 1,
497
+ isWeekend: weekendDays.includes(cellDate.getDay()),
498
+ weekNumber: this._getISOWeekNumber(cellDate),
499
+ isFirstDayOfMonth: isCurrentMonth && day === 1,
500
+ isLastDayOfMonth: isCurrentMonth && day === daysInMonth,
501
+ };
502
+ }
503
+ };
504
+ __decorate([
505
+ property({ type: Array, attribute: false })
506
+ ], EdsWcCalendarMonthly.prototype, "disabledDays", void 0);
507
+ __decorate([
508
+ property({ type: Array })
509
+ ], EdsWcCalendarMonthly.prototype, "events", void 0);
510
+ __decorate([
511
+ property({ type: Boolean, reflect: true, attribute: 'has-empty-value' })
512
+ ], EdsWcCalendarMonthly.prototype, "hasEmptyValue", void 0);
513
+ __decorate([
514
+ property({ type: String, reflect: true })
515
+ ], EdsWcCalendarMonthly.prototype, "mode", void 0);
516
+ __decorate([
517
+ property({ type: Number, attribute: 'starting-day', converter: (v) => parseStartingDay(v ?? 0) })
518
+ ], EdsWcCalendarMonthly.prototype, "startingDay", void 0);
519
+ __decorate([
520
+ property({ attribute: false })
521
+ ], EdsWcCalendarMonthly.prototype, "date", void 0);
522
+ __decorate([
523
+ property({ type: Boolean, reflect: true, attribute: 'fill-previous-month' })
524
+ ], EdsWcCalendarMonthly.prototype, "fillPreviousMonth", void 0);
525
+ __decorate([
526
+ property({ type: Boolean, reflect: true, attribute: 'fill-next-month' })
527
+ ], EdsWcCalendarMonthly.prototype, "fillNextMonth", void 0);
528
+ __decorate([
529
+ property({ type: Boolean, reflect: true, attribute: 'disable-future-dates' })
530
+ ], EdsWcCalendarMonthly.prototype, "disableFutureDates", void 0);
531
+ __decorate([
532
+ property({ type: Boolean, reflect: true, attribute: 'disable-past-dates' })
533
+ ], EdsWcCalendarMonthly.prototype, "disablePastDates", void 0);
534
+ __decorate([
535
+ property({ type: Boolean, reflect: true, attribute: 'disable-weekends' })
536
+ ], EdsWcCalendarMonthly.prototype, "disableWeekends", void 0);
537
+ __decorate([
538
+ property({ type: Boolean, reflect: true, attribute: 'disabled-days-not-in-month' })
539
+ ], EdsWcCalendarMonthly.prototype, "disabledDaysNotInMonth", void 0);
540
+ __decorate([
541
+ property({ type: String })
542
+ ], EdsWcCalendarMonthly.prototype, "locale", void 0);
543
+ EdsWcCalendarMonthly = __decorate([
544
+ customElement('eds-wc-calendar-monthly')
545
+ ], EdsWcCalendarMonthly);
546
+ export { EdsWcCalendarMonthly };
547
+ /* -------------------------------------------------------------------------- */
548
+ /* eds-wc-calendar-header — navigation / mode header. */
549
+ /* -------------------------------------------------------------------------- */
550
+ /**
551
+ * `<eds-wc-calendar-header>` — the calendar navigation header.
552
+ *
553
+ * Projection of the Angular `EdsCalendarHeader`. Renders prev/next navigation, the
554
+ * formatted current-date label (+ optional sub-label), and a "Today" button. The
555
+ * `current-date` is a controlled value: navigation dispatches `navigation` with the
556
+ * computed new date; the consumer updates `current-date`.
557
+ *
558
+ * @fires navigation - `detail: { direction: 'previous' | 'next', current: string, new: string, mode: EdsWcCalendarMode }`
559
+ * @fires today - `detail: { date: string }` — fired when the "Today" button is clicked.
560
+ */
561
+ let EdsWcCalendarHeader = class EdsWcCalendarHeader extends EdsBaseElement {
562
+ constructor() {
563
+ super(...arguments);
564
+ this.containWeekends = true;
565
+ this.dateFormatOptions = null;
566
+ this.mode = 'monthly';
567
+ this.currentDate = '';
568
+ this.subLabel = '';
569
+ this.showTodayButton = true;
570
+ this.showNavigationButtons = true;
571
+ this.startingDay = 0;
572
+ this.locale = 'en-US';
573
+ }
574
+ get _current() {
575
+ const d = this.currentDate ? new Date(this.currentDate) : new Date();
576
+ return isNaN(d.getTime()) ? new Date() : d;
577
+ }
578
+ static { this.styles = css `
579
+ :host, *, *::before, *::after { box-sizing: border-box; }
580
+ :host { display: block; }
581
+
582
+ .eds-calendar-header__nav {
583
+ display: flex; justify-content: space-between; align-items: center; gap: var(--eds-sp-s);
584
+ }
585
+ .eds-calendar-header__left { display: flex; align-items: center; gap: var(--eds-sp-s); }
586
+ .eds-calendar-header__label { display: flex; flex-direction: column; align-items: flex-start; }
587
+ .eds-calendar-header__date { font: var(--eds-f-label-l-semibold); }
588
+ .eds-calendar-header__sublabel { font: var(--eds-f-paragraph-xs); color: var(--eds-c-foreground-subtler); }
589
+
590
+ .eds-calendar-header__nav-btn {
591
+ display: inline-flex; align-items: center; justify-content: center;
592
+ width: var(--eds-si-xl, 1.75rem); height: var(--eds-si-xl, 1.75rem);
593
+ border: var(--eds-bw-xs) solid var(--eds-c-border-neutral); background: var(--eds-c-surface-elevation);
594
+ border-radius: var(--eds-br-s); cursor: pointer; color: var(--eds-c-foreground-subtle);
595
+ font-family: inherit;
596
+ }
597
+ .eds-calendar-header__nav-btn:hover { background: var(--eds-c-surface-neutral-subtle); }
598
+ .eds-calendar-header__nav-btn:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
599
+ .eds-calendar-header__nav-btn svg { width: var(--eds-is-s); height: var(--eds-is-s); fill: currentColor; }
600
+
601
+ .eds-calendar-header__today-btn {
602
+ padding: var(--eds-sp-2xs) var(--eds-sp-s);
603
+ border: var(--eds-bw-xs) solid var(--eds-c-border-neutral); background: var(--eds-c-surface-elevation);
604
+ border-radius: var(--eds-br-s); cursor: pointer; font: var(--eds-f-label-m-semibold);
605
+ color: var(--eds-c-foreground); font-family: inherit;
606
+ }
607
+ .eds-calendar-header__today-btn:hover:not(:disabled) { background: var(--eds-c-surface-neutral-subtle); }
608
+ .eds-calendar-header__today-btn:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
609
+ .eds-calendar-header__today-btn:disabled { opacity: 0.5; cursor: not-allowed; }
610
+ `; }
611
+ render() {
612
+ const baseUrl = EdsBaseElement.assetsBaseUrl;
613
+ const prevHref = `${baseUrl}/eds/icons/sprites/core.svg#caret-left`;
614
+ const nextHref = `${baseUrl}/eds/icons/sprites/core.svg#caret-right`;
615
+ return html `
616
+ <div class="eds-calendar-header__nav">
617
+ <div class="eds-calendar-header__left">
618
+ ${this.showNavigationButtons ? html `
619
+ <button
620
+ type="button"
621
+ class="eds-calendar-header__nav-btn"
622
+ aria-label="Go to previous"
623
+ @click="${this.navigatePrevious}">
624
+ <svg aria-hidden="true"><use href="${prevHref}"></use></svg>
625
+ </button>
626
+ ` : nothing}
627
+ <div class="eds-calendar-header__label" style="min-width:${this._maxMonthWidth()}">
628
+ <span class="eds-calendar-header__date">${this._formattedDate()}</span>
629
+ ${this.subLabel ? html `<span class="eds-calendar-header__sublabel">${this.subLabel}</span>` : nothing}
630
+ </div>
631
+ ${this.showNavigationButtons ? html `
632
+ <button
633
+ type="button"
634
+ class="eds-calendar-header__nav-btn"
635
+ aria-label="Go to next"
636
+ @click="${this.navigateNext}">
637
+ <svg aria-hidden="true"><use href="${nextHref}"></use></svg>
638
+ </button>
639
+ ` : nothing}
640
+ </div>
641
+ ${this.showTodayButton ? html `
642
+ <button
643
+ type="button"
644
+ class="eds-calendar-header__today-btn"
645
+ ?disabled="${this._isCurrentDateToday()}"
646
+ @click="${this.goToToday}">
647
+ Today
648
+ </button>
649
+ ` : nothing}
650
+ </div>
651
+ `;
652
+ }
653
+ navigatePrevious() {
654
+ const current = this._current;
655
+ let next;
656
+ switch (this.mode) {
657
+ case 'daily':
658
+ next = new Date(current.getFullYear(), current.getMonth(), current.getDate() - 1);
659
+ break;
660
+ case 'weekly':
661
+ next = new Date(current.getFullYear(), current.getMonth(), current.getDate() - 7);
662
+ break;
663
+ case 'monthly':
664
+ default:
665
+ next = new Date(current.getFullYear(), current.getMonth() - 1, 1);
666
+ break;
667
+ }
668
+ this.currentDate = next.toISOString();
669
+ this.dispatchEvent(new CustomEvent('navigation', {
670
+ bubbles: true, composed: true,
671
+ detail: { direction: 'previous', current: current.toISOString(), new: next.toISOString(), mode: this.mode },
672
+ }));
673
+ }
674
+ navigateNext() {
675
+ const current = this._current;
676
+ let next;
677
+ switch (this.mode) {
678
+ case 'daily':
679
+ next = new Date(current.getFullYear(), current.getMonth(), current.getDate() + 1);
680
+ break;
681
+ case 'weekly':
682
+ next = new Date(current.getFullYear(), current.getMonth(), current.getDate() + 7);
683
+ break;
684
+ case 'monthly':
685
+ default:
686
+ next = new Date(current.getFullYear(), current.getMonth() + 1, 1);
687
+ break;
688
+ }
689
+ this.currentDate = next.toISOString();
690
+ this.dispatchEvent(new CustomEvent('navigation', {
691
+ bubbles: true, composed: true,
692
+ detail: { direction: 'next', current: current.toISOString(), new: next.toISOString(), mode: this.mode },
693
+ }));
694
+ }
695
+ goToToday() {
696
+ const today = new Date();
697
+ this.dispatchEvent(new CustomEvent('today', { bubbles: true, composed: true, detail: { date: today.toISOString() } }));
698
+ }
699
+ _formattedOptions() {
700
+ if (this.dateFormatOptions !== null)
701
+ return this.dateFormatOptions;
702
+ if (this.mode === 'monthly')
703
+ return { month: 'long', year: 'numeric' };
704
+ if (this.mode === 'weekly')
705
+ return { year: 'numeric', month: 'short', day: 'numeric' };
706
+ return { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
707
+ }
708
+ _formattedDate() {
709
+ const options = this._formattedOptions();
710
+ if (this.mode === 'monthly') {
711
+ return this._current.toLocaleDateString(this.locale, options);
712
+ }
713
+ else if (this.mode === 'weekly') {
714
+ const { start, end } = this._getWeekRange(this._current, this.startingDay);
715
+ return `${start.toLocaleDateString(this.locale, options)} - ${end.toLocaleDateString(this.locale, options)}`;
716
+ }
717
+ else if (this.mode === 'daily') {
718
+ return this._current.toLocaleDateString(this.locale, options);
719
+ }
720
+ return '';
721
+ }
722
+ _isCurrentDateToday() {
723
+ const current = this._current;
724
+ const today = new Date();
725
+ today.setHours(0, 0, 0, 0);
726
+ if (this.mode === 'daily') {
727
+ return current.getDate() === today.getDate() &&
728
+ current.getMonth() === today.getMonth() &&
729
+ current.getFullYear() === today.getFullYear();
730
+ }
731
+ else if (this.mode === 'weekly') {
732
+ const { start, end } = this._getWeekRange(current, this.startingDay);
733
+ const startDate = new Date(start);
734
+ startDate.setHours(0, 0, 0, 0);
735
+ const endDate = new Date(end);
736
+ endDate.setHours(23, 59, 59, 999);
737
+ return today >= startDate && today <= endDate;
738
+ }
739
+ return current.getMonth() === today.getMonth() && current.getFullYear() === today.getFullYear();
740
+ }
741
+ _maxMonthWidth() {
742
+ const currentYear = this._current.getFullYear();
743
+ const monthNames = [];
744
+ for (let i = 0; i < 12; i++) {
745
+ monthNames.push(new Date(currentYear, i, 1).toLocaleDateString(this.locale, this._formattedOptions()));
746
+ }
747
+ const longestMonth = monthNames.reduce((a, b) => a.length > b.length ? a : b);
748
+ return this.mode === 'weekly' ? `${longestMonth.length * 2 + 2}ch` : `${longestMonth.length}ch`;
749
+ }
750
+ _getWeekRange(date, startDay) {
751
+ const jsDay = date.getDay();
752
+ const targetStartDay = (startDay + 1) % 7;
753
+ const daysBack = (jsDay - targetStartDay + 7) % 7;
754
+ const start = new Date(date);
755
+ start.setDate(date.getDate() - daysBack);
756
+ const end = new Date(start);
757
+ const daysInWeek = this.containWeekends ? 6 : 4;
758
+ end.setDate(start.getDate() + daysInWeek);
759
+ return { start, end };
760
+ }
761
+ };
762
+ __decorate([
763
+ property({ type: Boolean, reflect: true, attribute: 'contain-weekends' })
764
+ ], EdsWcCalendarHeader.prototype, "containWeekends", void 0);
765
+ __decorate([
766
+ property({ attribute: false })
767
+ ], EdsWcCalendarHeader.prototype, "dateFormatOptions", void 0);
768
+ __decorate([
769
+ property({ type: String, reflect: true })
770
+ ], EdsWcCalendarHeader.prototype, "mode", void 0);
771
+ __decorate([
772
+ property({ type: String, attribute: 'current-date' })
773
+ ], EdsWcCalendarHeader.prototype, "currentDate", void 0);
774
+ __decorate([
775
+ property({ type: String, attribute: 'sub-label' })
776
+ ], EdsWcCalendarHeader.prototype, "subLabel", void 0);
777
+ __decorate([
778
+ property({ type: Boolean, reflect: true, attribute: 'show-today-button' })
779
+ ], EdsWcCalendarHeader.prototype, "showTodayButton", void 0);
780
+ __decorate([
781
+ property({ type: Boolean, reflect: true, attribute: 'show-navigation-buttons' })
782
+ ], EdsWcCalendarHeader.prototype, "showNavigationButtons", void 0);
783
+ __decorate([
784
+ property({ type: Number, attribute: 'starting-day', converter: (v) => parseStartingDay(v ?? 0) })
785
+ ], EdsWcCalendarHeader.prototype, "startingDay", void 0);
786
+ __decorate([
787
+ property({ type: String })
788
+ ], EdsWcCalendarHeader.prototype, "locale", void 0);
789
+ EdsWcCalendarHeader = __decorate([
790
+ customElement('eds-wc-calendar-header')
791
+ ], EdsWcCalendarHeader);
792
+ export { EdsWcCalendarHeader };
793
+ /* -------------------------------------------------------------------------- */
794
+ /* eds-wc-calendar-weekly-day-header — day column heading (weekly view). */
795
+ /* -------------------------------------------------------------------------- */
796
+ /**
797
+ * `<eds-wc-calendar-weekly-day-header>` — a weekly-view column heading.
798
+ *
799
+ * Projection of the Angular `EdsCalendarWeeklyDayHeader`. Renders the short weekday
800
+ * name (bold) followed by the day-of-month long form, plus an optional sub-label.
801
+ */
802
+ let EdsWcCalendarWeeklyDayHeader = class EdsWcCalendarWeeklyDayHeader extends EdsBaseElement {
803
+ constructor() {
804
+ super(...arguments);
805
+ this.date = new Date();
806
+ this.sublabel = '';
807
+ this.locale = 'en-US';
808
+ }
809
+ get _date() {
810
+ const d = this.date instanceof Date ? this.date : new Date(this.date);
811
+ return isNaN(d.getTime()) ? new Date() : d;
812
+ }
813
+ static { this.styles = css `
814
+ :host, *, *::before, *::after { box-sizing: border-box; }
815
+ :host { display: flex; flex-direction: row; justify-content: space-between; width: 100%; }
816
+ .eds-calendar-weekly-day-header__sublabel { font: var(--eds-f-paragraph-xs); color: var(--eds-c-foreground-subtler); }
817
+ `; }
818
+ render() {
819
+ const dayOfTheWeek = this._date.toLocaleDateString(this.locale, { weekday: 'short' }).toUpperCase();
820
+ const dayOfTheMonth = this._date.toLocaleDateString(this.locale, { day: 'numeric', month: 'long' });
821
+ return html `
822
+ <span class="eds-calendar-weekly-day-header__day"><strong>${dayOfTheWeek}</strong> ${dayOfTheMonth}</span>
823
+ ${this.sublabel ? html `<span class="eds-calendar-weekly-day-header__sublabel">${this.sublabel}</span>` : nothing}
824
+ `;
825
+ }
826
+ };
827
+ __decorate([
828
+ property({ attribute: 'date' })
829
+ ], EdsWcCalendarWeeklyDayHeader.prototype, "date", void 0);
830
+ __decorate([
831
+ property({ type: String })
832
+ ], EdsWcCalendarWeeklyDayHeader.prototype, "sublabel", void 0);
833
+ __decorate([
834
+ property({ type: String })
835
+ ], EdsWcCalendarWeeklyDayHeader.prototype, "locale", void 0);
836
+ EdsWcCalendarWeeklyDayHeader = __decorate([
837
+ customElement('eds-wc-calendar-weekly-day-header')
838
+ ], EdsWcCalendarWeeklyDayHeader);
839
+ export { EdsWcCalendarWeeklyDayHeader };
840
+ /* -------------------------------------------------------------------------- */
841
+ /* eds-wc-calendar-weekly-day-header-action — heading + actions dropdown. */
842
+ /* -------------------------------------------------------------------------- */
843
+ /**
844
+ * `<eds-wc-calendar-weekly-day-header-action>` — a weekly-view column heading with an
845
+ * actions dropdown.
846
+ *
847
+ * Projection of the Angular `EdsCalendarWeeklyDayHeaderAction`. Renders the weekday
848
+ * label plus a "more options" menu built from `options`. Selecting an option invokes
849
+ * its `callback` (if provided) and dispatches `action`.
850
+ *
851
+ * @fires action - `detail: { option: EdsWcCalendarDayHeaderActionOption, date: string }`
852
+ */
853
+ let EdsWcCalendarWeeklyDayHeaderAction = class EdsWcCalendarWeeklyDayHeaderAction extends EdsBaseElement {
854
+ constructor() {
855
+ super(...arguments);
856
+ this.disabled = false;
857
+ this.options = [];
858
+ this.date = new Date();
859
+ this.sublabel = '';
860
+ this.locale = 'en-US';
861
+ this._open = false;
862
+ }
863
+ get _date() {
864
+ const d = this.date instanceof Date ? this.date : new Date(this.date);
865
+ return isNaN(d.getTime()) ? new Date() : d;
866
+ }
867
+ static { this.styles = css `
868
+ :host, *, *::before, *::after { box-sizing: border-box; }
869
+ :host { display: flex; justify-content: space-between; align-items: center; width: 100%; position: relative; }
870
+ :host([disabled]) { opacity: 0.5; pointer-events: none; }
871
+
872
+ .eds-calendar-weekly-day-header-action__sublabel { font: var(--eds-f-paragraph-xs); color: var(--eds-c-foreground-subtler); display: block; }
873
+
874
+ .eds-calendar-weekly-day-header-action__trigger {
875
+ display: inline-flex; align-items: center; justify-content: center;
876
+ width: var(--eds-si-xl, 1.75rem); height: var(--eds-si-xl, 1.75rem);
877
+ border: none; background: transparent; cursor: pointer; color: var(--eds-c-foreground-subtle);
878
+ border-radius: var(--eds-br-s); font-family: inherit;
879
+ }
880
+ .eds-calendar-weekly-day-header-action__trigger:hover { background: var(--eds-c-surface-neutral-subtle); }
881
+ .eds-calendar-weekly-day-header-action__trigger:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: 2px; }
882
+ .eds-calendar-weekly-day-header-action__trigger svg { width: var(--eds-is-s); height: var(--eds-is-s); fill: currentColor; }
883
+
884
+ .eds-calendar-weekly-day-header-action__menu {
885
+ display: none; position: absolute; top: 100%; right: 0; z-index: 10000; margin-top: var(--eds-sp-3xs);
886
+ background: var(--eds-c-surface-elevation); border: var(--eds-bw-xs) solid var(--eds-c-border-divider);
887
+ border-radius: var(--eds-br-m); box-shadow: var(--eds-sh-2); padding: var(--eds-sp-3xs); min-width: 160px;
888
+ }
889
+ .eds-calendar-weekly-day-header-action__menu.open { display: block; }
890
+ .eds-calendar-weekly-day-header-action__item {
891
+ display: block; width: 100%; text-align: left;
892
+ padding: var(--eds-sp-2xs) var(--eds-sp-s); border: none; background: transparent; cursor: pointer;
893
+ font: var(--eds-f-paragraph-m); color: var(--eds-c-foreground); border-radius: var(--eds-br-s); font-family: inherit;
894
+ }
895
+ .eds-calendar-weekly-day-header-action__item:hover { background: var(--eds-c-surface-neutral-subtle); }
896
+ .eds-calendar-weekly-day-header-action__item:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: -2px; }
897
+ `; }
898
+ render() {
899
+ const baseUrl = EdsBaseElement.assetsBaseUrl;
900
+ const dotsHref = `${baseUrl}/eds/icons/sprites/core.svg#dots-three-vertical`;
901
+ const dayOfTheWeek = this._date.toLocaleDateString(this.locale, { weekday: 'short' }).toUpperCase();
902
+ const dayOfTheMonth = this._date.toLocaleDateString(this.locale, { day: 'numeric', month: 'long' });
903
+ return html `
904
+ <span class="eds-calendar-weekly-day-header-action__left">
905
+ <strong>${dayOfTheWeek}</strong> ${dayOfTheMonth}
906
+ ${this.sublabel ? html `<span class="eds-calendar-weekly-day-header-action__sublabel">${this.sublabel}</span>` : nothing}
907
+ </span>
908
+ <div class="eds-calendar-weekly-day-header-action__right">
909
+ <button
910
+ type="button"
911
+ class="eds-calendar-weekly-day-header-action__trigger"
912
+ aria-label="More options"
913
+ aria-haspopup="menu"
914
+ aria-expanded="${this._open ? 'true' : 'false'}"
915
+ ?disabled="${this.disabled}"
916
+ @click="${this._toggle}">
917
+ <svg aria-hidden="true"><use href="${dotsHref}"></use></svg>
918
+ </button>
919
+ <div class="eds-calendar-weekly-day-header-action__menu ${this._open ? 'open' : ''}" role="menu">
920
+ ${this.options.map(option => html `
921
+ <button
922
+ type="button"
923
+ role="menuitem"
924
+ class="eds-calendar-weekly-day-header-action__item"
925
+ @click="${(e) => this._select(e, option)}">
926
+ ${option.label}
927
+ </button>
928
+ `)}
929
+ </div>
930
+ </div>
931
+ `;
932
+ }
933
+ _toggle() {
934
+ this._open = !this._open;
935
+ }
936
+ _select(e, option) {
937
+ this._open = false;
938
+ option.callback?.(e, this._date);
939
+ this.dispatchEvent(new CustomEvent('action', {
940
+ bubbles: true, composed: true,
941
+ detail: { option, date: this._date.toISOString() },
942
+ }));
943
+ }
944
+ };
945
+ __decorate([
946
+ property({ type: Boolean, reflect: true })
947
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "disabled", void 0);
948
+ __decorate([
949
+ property({ type: Array })
950
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "options", void 0);
951
+ __decorate([
952
+ property({ attribute: 'date' })
953
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "date", void 0);
954
+ __decorate([
955
+ property({ type: String })
956
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "sublabel", void 0);
957
+ __decorate([
958
+ property({ type: String })
959
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "locale", void 0);
960
+ __decorate([
961
+ state()
962
+ ], EdsWcCalendarWeeklyDayHeaderAction.prototype, "_open", void 0);
963
+ EdsWcCalendarWeeklyDayHeaderAction = __decorate([
964
+ customElement('eds-wc-calendar-weekly-day-header-action')
965
+ ], EdsWcCalendarWeeklyDayHeaderAction);
966
+ export { EdsWcCalendarWeeklyDayHeaderAction };
967
+ let EdsWcCalendarWeeklyDayContent = class EdsWcCalendarWeeklyDayContent extends EdsBaseElement {
968
+ constructor() {
969
+ super(...arguments);
970
+ this.label = '';
971
+ this.subLabel = '';
972
+ this.color = 'primary';
973
+ }
974
+ static { this.styles = css `
975
+ :host, *, *::before, *::after { box-sizing: border-box; }
976
+ :host {
977
+ display: block;
978
+ --_eds-calendar-event-border: var(--eds-c-border-primary);
979
+ }
980
+ :host([color="success"]) { --_eds-calendar-event-border: var(--eds-c-border-success); }
981
+ :host([color="info"]) { --_eds-calendar-event-border: var(--eds-c-border-info); }
982
+ :host([color="warning"]) { --_eds-calendar-event-border: var(--eds-c-border-warning); }
983
+ :host([color="critical"]) { --_eds-calendar-event-border: var(--eds-c-border-critical); }
984
+
985
+ .eds-calendar-event__card {
986
+ background: var(--eds-c-surface-elevation);
987
+ border: var(--eds-bw-xs) solid var(--eds-c-border-divider);
988
+ border-left: var(--eds-bw-m) solid var(--_eds-calendar-event-border);
989
+ border-radius: var(--eds-br-m);
990
+ padding: var(--eds-sp-xs) var(--eds-sp-s);
991
+ box-shadow: var(--eds-sh-1);
992
+ }
993
+ .eds-calendar-event__sublabel { font: var(--eds-f-paragraph-xs); color: var(--eds-c-foreground-subtler); }
994
+ `; }
995
+ render() {
996
+ return html `
997
+ <div class="eds-calendar-event__card">
998
+ <strong>${this.label}</strong>
999
+ ${this.subLabel ? html `<div class="eds-calendar-event__sublabel">${this.subLabel}</div>` : nothing}
1000
+ </div>
1001
+ `;
1002
+ }
1003
+ };
1004
+ __decorate([
1005
+ property({ type: String })
1006
+ ], EdsWcCalendarWeeklyDayContent.prototype, "label", void 0);
1007
+ __decorate([
1008
+ property({ type: String, attribute: 'sub-label' })
1009
+ ], EdsWcCalendarWeeklyDayContent.prototype, "subLabel", void 0);
1010
+ __decorate([
1011
+ property({ type: String, reflect: true })
1012
+ ], EdsWcCalendarWeeklyDayContent.prototype, "color", void 0);
1013
+ EdsWcCalendarWeeklyDayContent = __decorate([
1014
+ customElement('eds-wc-calendar-weekly-day-content')
1015
+ ], EdsWcCalendarWeeklyDayContent);
1016
+ export { EdsWcCalendarWeeklyDayContent };
1017
+ /**
1018
+ * `<eds-wc-calendar-weekly>` — the week view.
1019
+ *
1020
+ * Projection of the Angular `EdsCalendarWeekly`. Renders one column per day of the
1021
+ * week (optionally hiding weekends), each with a `<eds-wc-calendar-weekly-day-header>`
1022
+ * and its events as `<eds-wc-calendar-weekly-day-content>` cards. Supports native HTML5
1023
+ * drag-and-drop of events between days (mirrors the Angular CDK drag-drop behavior).
1024
+ *
1025
+ * @fires event-moved - `detail: { event: EdsWcCalendarEvent, newDate: string }` — an
1026
+ * event was dragged to another day.
1027
+ * @fires day-action - `detail: { day: WeeklyDayData }` — reserved for day header actions.
1028
+ */
1029
+ let EdsWcCalendarWeekly = class EdsWcCalendarWeekly extends EdsBaseElement {
1030
+ constructor() {
1031
+ super(...arguments);
1032
+ this.dragAndDrop = true;
1033
+ this.date = new Date();
1034
+ this.events = [];
1035
+ this.showWeekends = false;
1036
+ this.startingDay = 0;
1037
+ this.disabledDays = [];
1038
+ this.locale = 'en-US';
1039
+ this._dragEventId = null;
1040
+ }
1041
+ static { this.styles = css `
1042
+ :host, *, *::before, *::after { box-sizing: border-box; }
1043
+ :host { display: flex; gap: var(--eds-sp-2xs); overflow-x: auto; }
1044
+
1045
+ .eds-day-column {
1046
+ flex: 1;
1047
+ display: flex;
1048
+ flex-direction: column;
1049
+ background-color: var(--eds-c-surface);
1050
+ border-radius: var(--eds-br-s);
1051
+ }
1052
+ .eds-day-column--weekend { background-color: var(--eds-c-surface-neutral-subtle); }
1053
+ .eds-day-column--today { background-color: var(--eds-c-surface-info-subtler); }
1054
+ .eds-day-column--disabled { opacity: 0.5; }
1055
+ .eds-day-column:focus-visible { outline: 2px solid var(--eds-c-border-focus); outline-offset: -2px; }
1056
+
1057
+ .eds-day-header { flex-shrink: 0; padding: var(--eds-sp-xs) var(--eds-sp-s); }
1058
+
1059
+ .eds-day-content {
1060
+ display: flex; flex-direction: column; gap: var(--eds-sp-xs);
1061
+ flex: 1; overflow-y: auto; padding: var(--eds-sp-xs); min-height: 4rem;
1062
+ }
1063
+ .eds-day-content--dragover { outline: 2px dashed var(--eds-c-border-primary); outline-offset: -2px; }
1064
+
1065
+ .eds-event-card { border-radius: var(--eds-br-s); }
1066
+ .eds-event-card[draggable="true"] { cursor: grab; }
1067
+ `; }
1068
+ render() {
1069
+ const days = this._daysInWeek();
1070
+ return html `
1071
+ ${days.map(day => html `
1072
+ <div
1073
+ class="eds-day-column ${day.isWeekend ? 'eds-day-column--weekend' : ''} ${day.isToday ? 'eds-day-column--today' : ''} ${day.disabled ? 'eds-day-column--disabled' : ''}"
1074
+ tabindex="0"
1075
+ role="region"
1076
+ aria-label="${day.date.toLocaleDateString()}"
1077
+ aria-current="${day.isToday ? 'date' : nothing}"
1078
+ aria-disabled="${day.disabled ? 'true' : nothing}">
1079
+ <div class="eds-day-header">
1080
+ <eds-wc-calendar-weekly-day-header .date="${day.date}" locale="${this.locale}"></eds-wc-calendar-weekly-day-header>
1081
+ </div>
1082
+ <div
1083
+ class="eds-day-content"
1084
+ @dragover="${(e) => this._onDragOver(e)}"
1085
+ @dragleave="${(e) => this._onDragLeave(e)}"
1086
+ @drop="${(e) => this._onDrop(e, day)}">
1087
+ ${day.events.map(event => html `
1088
+ <div
1089
+ class="eds-event-card"
1090
+ draggable="${this.dragAndDrop ? 'true' : 'false'}"
1091
+ @dragstart="${() => this._onDragStart(event)}"
1092
+ @dragend="${this._onDragEnd}">
1093
+ <eds-wc-calendar-weekly-day-content
1094
+ color="${event.type || 'primary'}"
1095
+ label="${event.label}"
1096
+ sub-label="${event.subLabel ?? ''}">
1097
+ </eds-wc-calendar-weekly-day-content>
1098
+ </div>
1099
+ `)}
1100
+ </div>
1101
+ </div>
1102
+ `)}
1103
+ `;
1104
+ }
1105
+ _daysInWeek() {
1106
+ const firstDayOfWeek = this._getWeekStartDate(this.date, this.startingDay);
1107
+ const days = [];
1108
+ const events = this.events ?? [];
1109
+ for (let i = 0; i < 7; i++) {
1110
+ const date = new Date(firstDayOfWeek);
1111
+ date.setDate(firstDayOfWeek.getDate() + i);
1112
+ if (!this.showWeekends && (date.getDay() === 0 || date.getDay() === 6))
1113
+ continue;
1114
+ days.push({
1115
+ id: i,
1116
+ date,
1117
+ isToday: date.toDateString() === new Date().toDateString(),
1118
+ isWeekend: date.getDay() === 0 || date.getDay() === 6,
1119
+ disabled: this.disabledDays.some(d => d.toDateString() === date.toDateString()),
1120
+ events: events.filter(event => {
1121
+ const ed = new Date(event.date);
1122
+ return ed.getFullYear() === date.getFullYear() &&
1123
+ ed.getMonth() === date.getMonth() &&
1124
+ ed.getDate() === date.getDate();
1125
+ }),
1126
+ });
1127
+ }
1128
+ return days;
1129
+ }
1130
+ _getWeekStartDate(referenceDate, startingDay) {
1131
+ const jsDay = referenceDate.getDay();
1132
+ const targetStartDay = (startingDay + 1) % 7;
1133
+ const daysBack = (jsDay - targetStartDay + 7) % 7;
1134
+ const result = new Date(referenceDate);
1135
+ result.setDate(referenceDate.getDate() - daysBack);
1136
+ return result;
1137
+ }
1138
+ _onDragStart(event) {
1139
+ if (!this.dragAndDrop)
1140
+ return;
1141
+ this._dragEventId = event.id;
1142
+ }
1143
+ _onDragEnd() {
1144
+ this._dragEventId = null;
1145
+ }
1146
+ _onDragOver(e) {
1147
+ if (!this.dragAndDrop || this._dragEventId === null)
1148
+ return;
1149
+ e.preventDefault();
1150
+ e.currentTarget.classList.add('eds-day-content--dragover');
1151
+ }
1152
+ _onDragLeave(e) {
1153
+ e.currentTarget.classList.remove('eds-day-content--dragover');
1154
+ }
1155
+ _onDrop(e, day) {
1156
+ if (!this.dragAndDrop || this._dragEventId === null)
1157
+ return;
1158
+ e.preventDefault();
1159
+ e.currentTarget.classList.remove('eds-day-content--dragover');
1160
+ const events = this.events ?? [];
1161
+ const movedEvent = events.find(ev => ev.id === this._dragEventId);
1162
+ this._dragEventId = null;
1163
+ if (!movedEvent)
1164
+ return;
1165
+ const newDate = day.date;
1166
+ const updated = events.map(ev => ev.id === movedEvent.id ? { ...ev, date: newDate.toISOString() } : ev);
1167
+ this.events = updated;
1168
+ this.dispatchEvent(new CustomEvent('event-moved', {
1169
+ bubbles: true, composed: true,
1170
+ detail: { event: { ...movedEvent, date: newDate.toISOString() }, newDate: newDate.toISOString() },
1171
+ }));
1172
+ }
1173
+ };
1174
+ __decorate([
1175
+ property({ type: Boolean, reflect: true, attribute: 'drag-and-drop' })
1176
+ ], EdsWcCalendarWeekly.prototype, "dragAndDrop", void 0);
1177
+ __decorate([
1178
+ property({ attribute: false })
1179
+ ], EdsWcCalendarWeekly.prototype, "date", void 0);
1180
+ __decorate([
1181
+ property({ type: Array })
1182
+ ], EdsWcCalendarWeekly.prototype, "events", void 0);
1183
+ __decorate([
1184
+ property({ type: Boolean, reflect: true, attribute: 'show-weekends' })
1185
+ ], EdsWcCalendarWeekly.prototype, "showWeekends", void 0);
1186
+ __decorate([
1187
+ property({ type: Number, attribute: 'starting-day', converter: (v) => parseStartingDay(v ?? 0) })
1188
+ ], EdsWcCalendarWeekly.prototype, "startingDay", void 0);
1189
+ __decorate([
1190
+ property({ type: Array, attribute: false })
1191
+ ], EdsWcCalendarWeekly.prototype, "disabledDays", void 0);
1192
+ __decorate([
1193
+ property({ type: String })
1194
+ ], EdsWcCalendarWeekly.prototype, "locale", void 0);
1195
+ __decorate([
1196
+ state()
1197
+ ], EdsWcCalendarWeekly.prototype, "_dragEventId", void 0);
1198
+ EdsWcCalendarWeekly = __decorate([
1199
+ customElement('eds-wc-calendar-weekly')
1200
+ ], EdsWcCalendarWeekly);
1201
+ export { EdsWcCalendarWeekly };
1202
+ /* -------------------------------------------------------------------------- */
1203
+ /* eds-wc-calendar — shell that composes header + monthly + weekly. */
1204
+ /* -------------------------------------------------------------------------- */
1205
+ /**
1206
+ * `<eds-wc-calendar>` — the calendar shell.
1207
+ *
1208
+ * Projection of the Angular `EdsCalendar`. A structural container that composes a
1209
+ * calendar header, a monthly grid, and/or a weekly view via slots. Mirrors the
1210
+ * Angular component whose template is three `<ng-content>` projections
1211
+ * (`eds-calendar-header`, `eds-calendar-monthly`, `eds-calendar-weekly`).
1212
+ *
1213
+ * @slot header - Slot for an `<eds-wc-calendar-header>`.
1214
+ * @slot monthly - Slot for an `<eds-wc-calendar-monthly>`.
1215
+ * @slot weekly - Slot for an `<eds-wc-calendar-weekly>`.
1216
+ * @slot - Default slot (any additional calendar content).
1217
+ */
1218
+ let EdsWcCalendar = class EdsWcCalendar extends EdsBaseElement {
1219
+ static { this.styles = css `
1220
+ :host, *, *::before, *::after { box-sizing: border-box; }
1221
+ :host { display: block; width: 100%; }
1222
+ `; }
1223
+ render() {
1224
+ return html `
1225
+ <slot name="header"></slot>
1226
+ <slot name="monthly"></slot>
1227
+ <slot name="weekly"></slot>
1228
+ <slot></slot>
1229
+ `;
1230
+ }
1231
+ };
1232
+ EdsWcCalendar = __decorate([
1233
+ customElement('eds-wc-calendar')
1234
+ ], EdsWcCalendar);
1235
+ export { EdsWcCalendar };
1236
+ //# sourceMappingURL=eds-wc-calendar.js.map