@mintplayer/web-components 2.7.0 → 2.8.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.
@@ -163,24 +163,24 @@ class y extends p {
163
163
  }
164
164
  /** Compute the weeks rendered for the current month, honoring firstDayOfWeek. */
165
165
  getWeeks(e) {
166
- const t = new Date(e.getFullYear(), e.getMonth(), 1), n = new Date(e.getFullYear(), e.getMonth() + 1, 0), r = this.startOfWeek(t), i = this.endOfWeek(n), s = this.daysBetween(r, i) + 1, l = [];
167
- for (let a = 0; a < s; a++) {
168
- const h = new Date(r.getFullYear(), r.getMonth(), r.getDate() + a);
166
+ const t = new Date(e.getFullYear(), e.getMonth(), 1), n = new Date(e.getFullYear(), e.getMonth() + 1, 0), r = this.startOfWeek(t), o = this.endOfWeek(n), s = this.daysBetween(r, o) + 1, l = [];
167
+ for (let i = 0; i < s; i++) {
168
+ const h = new Date(r.getFullYear(), r.getMonth(), r.getDate() + i);
169
169
  l.push({
170
170
  date: h,
171
171
  dayOfMonth: h.getDate(),
172
172
  isInMonth: h.getFullYear() === e.getFullYear() && h.getMonth() === e.getMonth()
173
173
  });
174
174
  }
175
- const o = [];
176
- for (let a = 0; a < l.length; a += 7) {
177
- const h = l.slice(a, a + 7), d = h.find((f) => f.isInMonth), g = d ? d.date : h[0].date;
178
- o.push({
179
- number: this.weekOfYear(g),
175
+ const a = [];
176
+ for (let i = 0; i < l.length; i += 7) {
177
+ const h = l.slice(i, i + 7), d = h.find((g) => g.isInMonth), f = d ? d.date : h[0].date;
178
+ a.push({
179
+ number: this.weekOfYear(f),
180
180
  days: h
181
181
  });
182
182
  }
183
- return o;
183
+ return a;
184
184
  }
185
185
  /** First day of the visible grid — Monday-on-top by default. */
186
186
  startOfWeek(e) {
@@ -194,12 +194,44 @@ class y extends p {
194
194
  daysBetween(e, t) {
195
195
  return Math.floor((this.dateOnly(t) - this.dateOnly(e)) / 864e5);
196
196
  }
197
- /** ISO-8601 week-of-year. */
197
+ /**
198
+ * How many days of a year a week must contain to count as that year's week 1.
199
+ * ISO says 4 (the Thursday rule); the US convention says 1 (week 1 is simply
200
+ * the week containing Jan 1). `Intl` reports it per locale, and it is the ONLY
201
+ * thing that distinguishes the two systems once the week start is known.
202
+ */
203
+ minimalDaysInFirstWeek() {
204
+ try {
205
+ const e = new Intl.Locale(this.locale ?? navigator.language), t = typeof e.getWeekInfo == "function" ? e.getWeekInfo()?.minimalDays : e.weekInfo?.minimalDays;
206
+ if (typeof t == "number") return t;
207
+ } catch {
208
+ }
209
+ return this.firstDayOfWeek === 1 ? 4 : 1;
210
+ }
211
+ /** The start of the week that owns week 1 of `year`. */
212
+ firstWeekStart(e) {
213
+ return this.startOfWeek(new Date(e, 0, this.minimalDaysInFirstWeek()));
214
+ }
215
+ /**
216
+ * Week-of-year honouring BOTH the week start and the locale's minimal-days
217
+ * rule.
218
+ *
219
+ * Was hardcoded ISO-8601, which is only correct for a Monday-start week. Under
220
+ * a Sunday start — what en-US and ja-JP resolve to — it labelled two
221
+ * consecutive rows of January 2026 "week 1" and ran one short from then on.
222
+ * That column is a real `<th scope="row">`, so a screen reader read the wrong
223
+ * number, and the scheduler's own editor renders this calendar.
224
+ */
198
225
  weekOfYear(e) {
199
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
200
- t.setUTCDate(t.getUTCDate() + 4 - (t.getUTCDay() || 7));
201
- const n = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
202
- return Math.ceil(((t.getTime() - n.getTime()) / 864e5 + 1) / 7);
226
+ const t = this.startOfWeek(e);
227
+ let n = t.getFullYear(), r = this.firstWeekStart(n);
228
+ if (t.getTime() < r.getTime())
229
+ r = this.firstWeekStart(--n);
230
+ else {
231
+ const o = this.firstWeekStart(n + 1);
232
+ t.getTime() >= o.getTime() && (r = o);
233
+ }
234
+ return Math.round(this.daysBetween(r, t) / 7) + 1;
203
235
  }
204
236
  /** Localized weekday short + long names, in the order driven by firstDayOfWeek. */
205
237
  weekdayNames() {
@@ -229,15 +261,15 @@ class y extends p {
229
261
  focusableDate() {
230
262
  const e = this.currentMonth;
231
263
  if (!e) return null;
232
- const t = (o) => o.getFullYear() === e.getFullYear() && o.getMonth() === e.getMonth(), n = (o) => o && t(o) ? o : null, r = n(this._focusedDate);
264
+ const t = (a) => a.getFullYear() === e.getFullYear() && a.getMonth() === e.getMonth(), n = (a) => a && t(a) ? a : null, r = n(this._focusedDate);
233
265
  if (r) return r;
234
- const i = n(this.selectedDate);
235
- if (i) return i;
266
+ const o = n(this.selectedDate);
267
+ if (o) return o;
236
268
  const l = n(/* @__PURE__ */ new Date());
237
269
  if (l) return l;
238
- for (const o of this.getWeeks(e))
239
- for (const a of o.days)
240
- if (a && a.isInMonth && !this.isDisabled(a.date)) return a.date;
270
+ for (const a of this.getWeeks(e))
271
+ for (const i of a.days)
272
+ if (i && i.isInMonth && !this.isDisabled(i.date)) return i.date;
241
273
  return null;
242
274
  }
243
275
  /* ---- Public API ---- */
@@ -280,21 +312,21 @@ class y extends p {
280
312
  /* ---- Keyboard ---- */
281
313
  onCellKeyDown(e, t) {
282
314
  if (!t || !t.isInMonth) return;
283
- const n = e.key, r = n === "ArrowLeft" || n === "ArrowRight" || n === "ArrowUp" || n === "ArrowDown" || n === "Home" || n === "End" || n === "PageUp" || n === "PageDown", i = n === "Enter" || n === " ";
284
- if (!r && !i) return;
285
- if (e.preventDefault(), i) {
315
+ const n = e.key, r = n === "ArrowLeft" || n === "ArrowRight" || n === "ArrowUp" || n === "ArrowDown" || n === "Home" || n === "End" || n === "PageUp" || n === "PageDown", o = n === "Enter" || n === " ";
316
+ if (!r && !o) return;
317
+ if (e.preventDefault(), o) {
286
318
  this.goto(t);
287
319
  return;
288
320
  }
289
321
  const s = t.date;
290
322
  let l = new Date(s);
291
- const o = getComputedStyle(this).direction === "rtl";
323
+ const a = getComputedStyle(this).direction === "rtl";
292
324
  switch (n) {
293
325
  case "ArrowLeft":
294
- l.setDate(s.getDate() + (o ? 1 : -1));
326
+ l.setDate(s.getDate() + (a ? 1 : -1));
295
327
  break;
296
328
  case "ArrowRight":
297
- l.setDate(s.getDate() + (o ? -1 : 1));
329
+ l.setDate(s.getDate() + (a ? -1 : 1));
298
330
  break;
299
331
  case "ArrowUp":
300
332
  l.setDate(s.getDate() - 7);
@@ -303,13 +335,13 @@ class y extends p {
303
335
  l.setDate(s.getDate() + 7);
304
336
  break;
305
337
  case "Home": {
306
- const a = (s.getDay() - this.firstDayOfWeek + 7) % 7;
307
- l.setDate(s.getDate() - a);
338
+ const i = (s.getDay() - this.firstDayOfWeek + 7) % 7;
339
+ l.setDate(s.getDate() - i);
308
340
  break;
309
341
  }
310
342
  case "End": {
311
- const a = (this.firstDayOfWeek + 6 - s.getDay() + 7) % 7;
312
- l.setDate(s.getDate() + a);
343
+ const i = (this.firstDayOfWeek + 6 - s.getDay() + 7) % 7;
344
+ l.setDate(s.getDate() + i);
313
345
  break;
314
346
  }
315
347
  case "PageUp":
@@ -357,14 +389,14 @@ class y extends p {
357
389
  rowheader in an unlabelled column. Visually empty, spoken. -->
358
390
  <th scope="col" role="columnheader"><span class="visually-hidden">Week</span></th>
359
391
  ${n.map(
360
- (i) => u`<th scope="col" role="columnheader" title="${i.long}">${i.short}</th>`
392
+ (o) => u`<th scope="col" role="columnheader" title="${o.long}">${o.short}</th>`
361
393
  )}
362
394
  </tr>
363
395
  ${t.map(
364
- (i) => u`
396
+ (o) => u`
365
397
  <tr role="row">
366
- <th scope="row" role="rowheader">${i.number}</th>
367
- ${i.days.map((s) => this.renderCell(s, r))}
398
+ <th scope="row" role="rowheader">${o.number}</th>
399
+ ${o.days.map((s) => this.renderCell(s, r))}
368
400
  </tr>
369
401
  `
370
402
  )}
@@ -372,15 +404,15 @@ class y extends p {
372
404
  `;
373
405
  }
374
406
  renderCell(e, t) {
375
- const n = !!e && e.isInMonth, r = !!e && this.isDisabled(e.date), i = !!e && e.isInMonth && this.isSameDate(this.selectedDate, e.date), s = !!e && e.isInMonth && this.isToday(e.date), l = !!e && e.isInMonth && this.isSameDate(t, e.date), o = [];
376
- i && o.push("selected"), n && !r && o.push("cursor-pointer");
377
- const a = o.length ? o.join(" ") : void 0, h = e && e.isInMonth ? this.cellId(e.date) : void 0;
407
+ const n = !!e && e.isInMonth, r = !!e && this.isDisabled(e.date), o = !!e && e.isInMonth && this.isSameDate(this.selectedDate, e.date), s = !!e && e.isInMonth && this.isToday(e.date), l = !!e && e.isInMonth && this.isSameDate(t, e.date), a = [];
408
+ o && a.push("selected"), n && !r && a.push("cursor-pointer");
409
+ const i = a.length ? a.join(" ") : void 0, h = e && e.isInMonth ? this.cellId(e.date) : void 0;
378
410
  return u`<td
379
411
  role="gridcell"
380
412
  id="${h ?? c}"
381
- class="${a ?? c}"
413
+ class="${i ?? c}"
382
414
  tabindex="${n ? l ? 0 : -1 : c}"
383
- aria-selected="${n ? i ? "true" : "false" : c}"
415
+ aria-selected="${n ? o ? "true" : "false" : c}"
384
416
  aria-current="${s ? "date" : c}"
385
417
  aria-disabled="${r ? "true" : c}"
386
418
  @click="${() => this.goto(e)}"
@@ -3,7 +3,7 @@ import { query as n } from "lit/decorators.js";
3
3
  import { L as w } from "./live-announcer-Bi0orG4n.mjs";
4
4
  import { e as D } from "./error-text-B45eDAt1.mjs";
5
5
  import { O as g } from "./overlay-controller-D6agzzOI.mjs";
6
- import "./mp-calendar.element-u6uS31_j.mjs";
6
+ import "./mp-calendar.element-CJ8-t-Zn.mjs";
7
7
  import { m as p } from "./mp-timepicker.element-COZEUIoE.mjs";
8
8
  import { i as $ } from "./invalid-feedback.styles-he0JYrJm.mjs";
9
9
  c`<!-- Rendered dynamically by render(). Codegen-wc emits styles from the
@@ -3,7 +3,7 @@ import { query as a } from "lit/decorators.js";
3
3
  import { O as h } from "../chunks/overlay-controller-D6agzzOI.mjs";
4
4
  import "lit/directives/ref.js";
5
5
  import { H as b } from "../chunks/host-aria-WSGs7SPQ.mjs";
6
- import "../chunks/mp-calendar.element-u6uS31_j.mjs";
6
+ import "../chunks/mp-calendar.element-CJ8-t-Zn.mjs";
7
7
  d`<!-- Rendered dynamically by render(). This file exists only so the codegen-wc
8
8
  target emits a \`styles\` export from the sibling .scss. -->`;
9
9
  const g = u(`:host {
@@ -1,4 +1,4 @@
1
- import { M as m } from "../chunks/mp-datetime-picker.element-MPTRHwyc.mjs";
1
+ import { M as m } from "../chunks/mp-datetime-picker.element-D1CiLbHm.mjs";
2
2
  export {
3
3
  m as MpDatetimePickerElement
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/web-components",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Framework-agnostic Lit web components for the @mintplayer/bootstrap design system. Consumed by @mintplayer/ng-bootstrap, @mintplayer/react-bootstrap, and @mintplayer/vue-bootstrap.",
5
5
  "license": "MIT",
6
6
  "repository": {