@m3e/dialog 1.2.2 → 1.3.1

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.
@@ -238,6 +238,13 @@
238
238
  "privacy": "private",
239
239
  "readonly": true
240
240
  },
241
+ {
242
+ "kind": "field",
243
+ "name": "#scrollLockController",
244
+ "privacy": "private",
245
+ "readonly": true,
246
+ "default": "new ScrollLockController(this)"
247
+ },
241
248
  {
242
249
  "kind": "field",
243
250
  "name": "alert",
package/dist/index.js CHANGED
@@ -3,8 +3,9 @@
3
3
  * Copyright (c) 2025 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import { ActionElementBase, EventAttribute, focusWhenReady, DesignToken, HtmlFor } from '@m3e/core';
6
+ import { ActionElementBase, EventAttribute, ScrollLockController, focusWhenReady, DesignToken, HtmlFor } from '@m3e/core';
7
7
  import { LitElement, html, unsafeCSS, css, nothing } from 'lit';
8
+ import '@m3e/core/a11y';
8
9
 
9
10
  /******************************************************************************
10
11
  Copyright (c) Microsoft Corporation.
@@ -779,7 +780,7 @@ j?.(N, R), (t.litHtmlVersions ??= []).push("3.3.1");
779
780
  */
780
781
  const o = o => o ?? E;
781
782
 
782
- var _M3eDialogElement_instances, _M3eDialogElement_id, _M3eDialogElement_open, _M3eDialogElement_escapePressedWithoutCancel, _M3eDialogElement_renderCloseButton, _M3eDialogElement_handleClose, _M3eDialogElement_handleCancel, _M3eDialogElement_handleClick, _M3eDialogElement_handleKeyDown, _M3eDialogElement_handleActionsSlotChange;
783
+ var _M3eDialogElement_instances, _M3eDialogElement_id, _M3eDialogElement_open, _M3eDialogElement_escapePressedWithoutCancel, _M3eDialogElement_scrollLockController, _M3eDialogElement_renderCloseButton, _M3eDialogElement_handleClose, _M3eDialogElement_handleCancel, _M3eDialogElement_handleClick, _M3eDialogElement_handleKeyDown, _M3eDialogElement_handleActionsSlotChange;
783
784
  var M3eDialogElement_1;
784
785
  /**
785
786
  * A dialog that provides important prompts in a user flow.
@@ -854,6 +855,8 @@ let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends Event
854
855
  _M3eDialogElement_escapePressedWithoutCancel.set(this, false);
855
856
  /** @private */
856
857
  this._hasActions = false;
858
+ /** @private */
859
+ _M3eDialogElement_scrollLockController.set(this, new ScrollLockController(this));
857
860
  /**
858
861
  * Whether the dialog is an alert.
859
862
  * @default false
@@ -916,6 +919,7 @@ let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends Event
916
919
  this.open = false;
917
920
  return;
918
921
  }
922
+ __classPrivateFieldGet(this, _M3eDialogElement_scrollLockController, "f").lock();
919
923
  this._base.showModal();
920
924
  this._content.scrollTop = 0;
921
925
  const focusable = this.querySelector("[autofocus]");
@@ -935,6 +939,7 @@ let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends Event
935
939
  return;
936
940
  }
937
941
  await this.updateComplete;
942
+ __classPrivateFieldGet(this, _M3eDialogElement_scrollLockController, "f").unlock();
938
943
  if (!this._base.open) {
939
944
  this.open = false;
940
945
  return;
@@ -959,6 +964,7 @@ let M3eDialogElement = M3eDialogElement_1 = class M3eDialogElement extends Event
959
964
  _M3eDialogElement_id = new WeakMap();
960
965
  _M3eDialogElement_open = new WeakMap();
961
966
  _M3eDialogElement_escapePressedWithoutCancel = new WeakMap();
967
+ _M3eDialogElement_scrollLockController = new WeakMap();
962
968
  _M3eDialogElement_instances = new WeakSet();
963
969
  _M3eDialogElement_renderCloseButton = function _M3eDialogElement_renderCloseButton() {
964
970
  return !this.dismissible ? nothing : html`<m3e-icon-button aria-label="${this.closeLabel}" class="close" @click="${this.hide}"><slot name="close-icon"><svg class="close-icon" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></slot></m3e-icon-button>`;
@@ -976,7 +982,7 @@ _M3eDialogElement_handleCancel = function _M3eDialogElement_handleCancel(e) {
976
982
  if (e.target !== this._base) return;
977
983
  __classPrivateFieldSet(this, _M3eDialogElement_escapePressedWithoutCancel, false, "f");
978
984
  e.preventDefault();
979
- if (!this.dispatchEvent(new Event("cancel", {
985
+ if (this.dispatchEvent(new Event("cancel", {
980
986
  cancelable: true
981
987
  }))) {
982
988
  this.hide();