@commmerce/ui 1.21.1 → 1.21.3

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.
@@ -9,9 +9,10 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _CmAppFrame_instances, _CmAppFrame_ro, _CmAppFrame_returnFocus, _CmAppFrame_heights, _CmAppFrame_syncBottom, _CmAppFrame_set, _CmAppFrame_slotOf, _CmAppFrame_onNavigate, _CmAppFrame_onKey;
12
+ var _CmAppFrame_instances, _CmAppFrame_ro, _CmAppFrame_returnFocus, _CmAppFrame_locked, _CmAppFrame_heights, _CmAppFrame_covered, _CmAppFrame_syncLock, _CmAppFrame_syncBottom, _CmAppFrame_set, _CmAppFrame_slotOf, _CmAppFrame_onNavigate, _CmAppFrame_onKey;
13
13
  import { LitElement, html, css } from 'lit';
14
14
  import { base, define } from '../base.js';
15
+ import { lockScroll, unlockScroll } from '../overlay.js';
15
16
  /** Frames at least this wide show the side navigation; narrower ones show the bottom navigation. */
16
17
  const WIDE = 1024;
17
18
  /** The element that has focus, looking inside shadow roots. */
@@ -73,6 +74,7 @@ export class CmAppFrame extends LitElement {
73
74
  this._wide = false;
74
75
  _CmAppFrame_ro.set(this, void 0);
75
76
  _CmAppFrame_returnFocus.set(this, null);
77
+ _CmAppFrame_locked.set(this, false);
76
78
  _CmAppFrame_onNavigate.set(this, (e) => {
77
79
  if (!this.menuItem)
78
80
  return;
@@ -99,6 +101,8 @@ export class CmAppFrame extends LitElement {
99
101
  const w = this.getBoundingClientRect().width;
100
102
  if (w > 0)
101
103
  this._wide = w >= WIDE;
104
+ if (this.hasUpdated)
105
+ __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_syncLock).call(this); // moved back into the page with the menu still open
102
106
  }
103
107
  disconnectedCallback() {
104
108
  super.disconnectedCallback();
@@ -106,6 +110,10 @@ export class CmAppFrame extends LitElement {
106
110
  this.removeEventListener('keydown', __classPrivateFieldGet(this, _CmAppFrame_onKey, "f"));
107
111
  __classPrivateFieldGet(this, _CmAppFrame_ro, "f")?.disconnect();
108
112
  __classPrivateFieldSet(this, _CmAppFrame_ro, undefined, "f");
113
+ if (__classPrivateFieldGet(this, _CmAppFrame_locked, "f")) {
114
+ unlockScroll();
115
+ __classPrivateFieldSet(this, _CmAppFrame_locked, false, "f");
116
+ }
109
117
  }
110
118
  /** True while the frame is 1024px wide or more and shows the side navigation instead of the bottom navigation. */
111
119
  get wide() { return this._wide; }
@@ -130,6 +138,7 @@ export class CmAppFrame extends LitElement {
130
138
  __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_heights).call(this);
131
139
  if (changed.has('menuOpen') || changed.has('menuItem'))
132
140
  __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_syncBottom).call(this);
141
+ __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_syncLock).call(this);
133
142
  }
134
143
  /** Opens the mobile menu and moves focus into it. */
135
144
  openMenu() { __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_set).call(this, true); }
@@ -140,7 +149,7 @@ export class CmAppFrame extends LitElement {
140
149
  render() {
141
150
  const wide = this._wide;
142
151
  // While the menu covers the page, the page and header can't be reached behind it; the bottom bar can.
143
- const covered = this.menuOpen && !wide && !!this.querySelector(':scope > [slot="mobile-menu"]');
152
+ const covered = __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_covered).call(this);
144
153
  return html `<div class="frame ${wide ? 'wide' : ''}" part="frame">
145
154
  <div class="probe"></div>
146
155
  <div class="header" part="header" ?inert=${covered}><slot name="header"></slot></div>
@@ -153,13 +162,25 @@ export class CmAppFrame extends LitElement {
153
162
  </div>`;
154
163
  }
155
164
  }
156
- _CmAppFrame_ro = new WeakMap(), _CmAppFrame_returnFocus = new WeakMap(), _CmAppFrame_onNavigate = new WeakMap(), _CmAppFrame_onKey = new WeakMap(), _CmAppFrame_instances = new WeakSet(), _CmAppFrame_heights = function _CmAppFrame_heights() {
165
+ _CmAppFrame_ro = new WeakMap(), _CmAppFrame_returnFocus = new WeakMap(), _CmAppFrame_locked = new WeakMap(), _CmAppFrame_onNavigate = new WeakMap(), _CmAppFrame_onKey = new WeakMap(), _CmAppFrame_instances = new WeakSet(), _CmAppFrame_heights = function _CmAppFrame_heights() {
157
166
  const frame = this.renderRoot.querySelector('.frame');
158
167
  if (!frame)
159
168
  return;
160
169
  const h = (sel) => Math.round(this.renderRoot.querySelector(sel)?.getBoundingClientRect().height ?? 0);
161
170
  frame.style.setProperty('--_header', `${h('.header')}px`);
162
171
  frame.style.setProperty('--_bottom', `${this._wide ? 0 : h('.bottom')}px`);
172
+ }, _CmAppFrame_covered = function _CmAppFrame_covered() {
173
+ return this.menuOpen && !this._wide && !!this.querySelector(':scope > [slot="mobile-menu"]');
174
+ }, _CmAppFrame_syncLock = function _CmAppFrame_syncLock() {
175
+ const covered = this.isConnected && __classPrivateFieldGet(this, _CmAppFrame_instances, "m", _CmAppFrame_covered).call(this);
176
+ if (covered && !__classPrivateFieldGet(this, _CmAppFrame_locked, "f")) {
177
+ lockScroll();
178
+ __classPrivateFieldSet(this, _CmAppFrame_locked, true, "f");
179
+ }
180
+ else if (!covered && __classPrivateFieldGet(this, _CmAppFrame_locked, "f")) {
181
+ unlockScroll();
182
+ __classPrivateFieldSet(this, _CmAppFrame_locked, false, "f");
183
+ }
163
184
  }, _CmAppFrame_syncBottom = function _CmAppFrame_syncBottom() {
164
185
  if (!this.menuItem)
165
186
  return;
@@ -2635,6 +2635,15 @@
2635
2635
  },
2636
2636
  "default": "null"
2637
2637
  },
2638
+ {
2639
+ "kind": "field",
2640
+ "name": "#locked",
2641
+ "privacy": "private",
2642
+ "type": {
2643
+ "text": "boolean"
2644
+ },
2645
+ "default": "false"
2646
+ },
2638
2647
  {
2639
2648
  "kind": "field",
2640
2649
  "name": "wide",
@@ -2646,6 +2655,18 @@
2646
2655
  "name": "#heights",
2647
2656
  "privacy": "private"
2648
2657
  },
2658
+ {
2659
+ "kind": "method",
2660
+ "name": "#covered",
2661
+ "privacy": "private",
2662
+ "description": "True while the mobile menu covers the page: open, narrow, and a menu is slotted."
2663
+ },
2664
+ {
2665
+ "kind": "method",
2666
+ "name": "#syncLock",
2667
+ "privacy": "private",
2668
+ "description": "Stops the page behind the mobile menu from scrolling while the menu covers it, with the shared overlay lock (counted,\nkeeps a classic scrollbar's gutter so nothing jumps sideways). Released when the menu closes, the frame widens or\nthe frame leaves the page."
2669
+ },
2649
2670
  {
2650
2671
  "kind": "method",
2651
2672
  "name": "#syncBottom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commmerce/ui",
3
- "version": "1.21.1",
3
+ "version": "1.21.3",
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",
@@ -128,8 +128,8 @@
128
128
  "test": "vitest run"
129
129
  },
130
130
  "dependencies": {
131
- "@commmerce/icons": "1.21.1",
132
- "@commmerce/tokens": "1.21.1",
131
+ "@commmerce/icons": "1.21.3",
132
+ "@commmerce/tokens": "1.21.3",
133
133
  "lit": "3.2.1"
134
134
  },
135
135
  "devDependencies": {