@primer/view-components 0.21.1-rc.1c4aed32 → 0.21.1-rc.1f8abf9d

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _DialogHelperElement_abortController;
12
+ var _DialogHelperElement_instances, _DialogHelperElement_abortController, _DialogHelperElement_handleDialogOpenAttribute;
13
13
  function dialogInvokerButtonHandler(event) {
14
14
  const target = event.target;
15
15
  const button = target?.closest('button');
@@ -73,6 +73,7 @@ function dialogInvokerButtonHandler(event) {
73
73
  export class DialogHelperElement extends HTMLElement {
74
74
  constructor() {
75
75
  super(...arguments);
76
+ _DialogHelperElement_instances.add(this);
76
77
  _DialogHelperElement_abortController.set(this, null);
77
78
  }
78
79
  get dialog() {
@@ -86,10 +87,11 @@ export class DialogHelperElement extends HTMLElement {
86
87
  new MutationObserver(records => {
87
88
  for (const record of records) {
88
89
  if (record.target === this.dialog) {
89
- this.ownerDocument.body.classList.toggle('has-modal', this.dialog.hasAttribute('open'));
90
+ __classPrivateFieldGet(this, _DialogHelperElement_instances, "m", _DialogHelperElement_handleDialogOpenAttribute).call(this);
90
91
  }
91
92
  }
92
93
  }).observe(this, { subtree: true, attributeFilter: ['open'] });
94
+ __classPrivateFieldGet(this, _DialogHelperElement_instances, "m", _DialogHelperElement_handleDialogOpenAttribute).call(this);
93
95
  }
94
96
  disconnectedCallback() {
95
97
  __classPrivateFieldGet(this, _DialogHelperElement_abortController, "f")?.abort();
@@ -110,7 +112,18 @@ export class DialogHelperElement extends HTMLElement {
110
112
  }
111
113
  }
112
114
  }
113
- _DialogHelperElement_abortController = new WeakMap();
115
+ _DialogHelperElement_abortController = new WeakMap(), _DialogHelperElement_instances = new WeakSet(), _DialogHelperElement_handleDialogOpenAttribute = function _DialogHelperElement_handleDialogOpenAttribute() {
116
+ if (!this.dialog)
117
+ return;
118
+ this.ownerDocument.body.classList.toggle('has-modal', this.dialog.matches(':modal'));
119
+ // We don't want to show the Dialog component as non-modal
120
+ if (this.dialog.matches('[open]:not(:modal)')) {
121
+ // eslint-disable-next-line no-restricted-syntax
122
+ this.dialog.addEventListener('close', e => e.stopImmediatePropagation(), { once: true });
123
+ this.dialog.close();
124
+ this.dialog.showModal();
125
+ }
126
+ };
114
127
  if (!window.customElements.get('dialog-helper')) {
115
128
  window.DialogHelperElement = DialogHelperElement;
116
129
  window.customElements.define('dialog-helper', DialogHelperElement);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.21.1-rc.1c4aed32",
3
+ "version": "0.21.1-rc.1f8abf9d",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -3440,6 +3440,19 @@
3440
3440
  "color-contrast"
3441
3441
  ]
3442
3442
  }
3443
+ },
3444
+ {
3445
+ "preview_path": "primer/alpha/dialog/initally_open",
3446
+ "name": "initally_open",
3447
+ "snapshot": "interactive",
3448
+ "skip_rules": {
3449
+ "wont_fix": [
3450
+ "region"
3451
+ ],
3452
+ "will_fix": [
3453
+ "color-contrast"
3454
+ ]
3455
+ }
3443
3456
  }
3444
3457
  ],
3445
3458
  "subcomponents": [
@@ -3217,6 +3217,19 @@
3217
3217
  "color-contrast"
3218
3218
  ]
3219
3219
  }
3220
+ },
3221
+ {
3222
+ "preview_path": "primer/alpha/dialog/initally_open",
3223
+ "name": "initally_open",
3224
+ "snapshot": "interactive",
3225
+ "skip_rules": {
3226
+ "wont_fix": [
3227
+ "region"
3228
+ ],
3229
+ "will_fix": [
3230
+ "color-contrast"
3231
+ ]
3232
+ }
3220
3233
  }
3221
3234
  ]
3222
3235
  },