@commmerce/ui 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -342,7 +342,12 @@ export declare class CmCalendar extends CmLocalizedElement {
342
342
  disconnectedCallback(): void;
343
343
  protected willUpdate(changed: PropertyValues): void;
344
344
  protected firstUpdated(): void;
345
- protected updated(): void;
345
+ /**
346
+ * Scrolls the week or day view so `hour` (0–23) is at the top. Useful after loading events, e.g. to open at the first one.
347
+ * Does nothing in the month view.
348
+ */
349
+ scrollToHour(hour: number): void;
350
+ protected updated(changed: Map<PropertyKey, unknown>): void;
346
351
  /** Shows the previous month, week (three days when narrow) or day. */
347
352
  previous(): void;
348
353
  /** Shows the next month, week (three days when narrow) or day. */
@@ -499,7 +499,21 @@ export class CmCalendar extends CmLocalizedElement {
499
499
  firstUpdated() {
500
500
  this.renderRoot.appendChild(__classPrivateFieldGet(this, _CmCalendar_announcer, "f").element);
501
501
  }
502
- updated() {
502
+ /**
503
+ * Scrolls the week or day view so `hour` (0–23) is at the top. Useful after loading events, e.g. to open at the first one.
504
+ * Does nothing in the month view.
505
+ */
506
+ scrollToHour(hour) {
507
+ const tg = this.renderRoot.querySelector('.tg');
508
+ const cell = tg?.querySelector('.tcell');
509
+ if (!tg || !cell)
510
+ return;
511
+ tg.scrollTop = cell.offsetHeight * Math.max(0, Math.min(23, Math.trunc(Number(hour)) || 0));
512
+ }
513
+ updated(changed) {
514
+ // A day-start changed after the first render (e.g. set once events have loaded) scrolls again.
515
+ if (changed.has('dayStart') && changed.get('dayStart') !== undefined)
516
+ __classPrivateFieldSet(this, _CmCalendar_scrollToStart, true, "f");
503
517
  __classPrivateFieldGet(this, _CmCalendar_instances, "m", _CmCalendar_syncTabStops).call(this);
504
518
  if (__classPrivateFieldGet(this, _CmCalendar_pendingFocus, "f")) {
505
519
  const el = __classPrivateFieldGet(this, _CmCalendar_instances, "m", _CmCalendar_find).call(this, __classPrivateFieldGet(this, _CmCalendar_pendingFocus, "f").key);
@@ -5990,6 +5990,19 @@
5990
5990
  "name": "#measure",
5991
5991
  "privacy": "private"
5992
5992
  },
5993
+ {
5994
+ "kind": "method",
5995
+ "name": "scrollToHour",
5996
+ "parameters": [
5997
+ {
5998
+ "name": "hour",
5999
+ "type": {
6000
+ "text": "number"
6001
+ }
6002
+ }
6003
+ ],
6004
+ "description": "Scrolls the week or day view so `hour` (0–23) is at the top. Useful after loading events, e.g. to open at the first one.\nDoes nothing in the month view."
6005
+ },
5993
6006
  {
5994
6007
  "kind": "method",
5995
6008
  "name": "#shift",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commmerce/ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Commmerce UI web components: build apps that feel native to the Commmerce admin. Works in plain HTML, React, Vue and server-rendered pages.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -50,8 +50,8 @@
50
50
  "test": "vitest run"
51
51
  },
52
52
  "dependencies": {
53
- "@commmerce/icons": "1.5.1",
54
- "@commmerce/tokens": "1.5.1",
53
+ "@commmerce/icons": "1.5.2",
54
+ "@commmerce/tokens": "1.5.2",
55
55
  "lit": "3.2.1"
56
56
  },
57
57
  "devDependencies": {