@primer/behaviors 0.0.0-202223113012 → 0.0.0-2022349143

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.
@@ -10,7 +10,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  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");
11
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _ModalDialogElement_instances, _ModalDialogElement_focusAbortController, _ModalDialogElement_abortController, _ModalDialogElement_isComposing, _ModalDialogElement_openButton, _ModalDialogElement_overlayBackdrop_get, _ModalDialogElement_keydown;
13
+ var _ModalDialogElement_instances, _ModalDialogElement_focusAbortController, _ModalDialogElement_abortController, _ModalDialogElement_openButton, _ModalDialogElement_overlayBackdrop_get, _ModalDialogElement_keydown;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const iterate_focusable_elements_js_1 = require("../utils/iterate-focusable-elements.js");
16
16
  const focus_trap_js_1 = require("../focus-trap.js");
@@ -19,8 +19,7 @@ class ModalDialogElement extends HTMLElement {
19
19
  super(...arguments);
20
20
  _ModalDialogElement_instances.add(this);
21
21
  _ModalDialogElement_focusAbortController.set(this, new AbortController());
22
- _ModalDialogElement_abortController.set(this, new AbortController());
23
- _ModalDialogElement_isComposing.set(this, false);
22
+ _ModalDialogElement_abortController.set(this, null);
24
23
  _ModalDialogElement_openButton.set(this, void 0);
25
24
  }
26
25
  get open() {
@@ -53,7 +52,7 @@ class ModalDialogElement extends HTMLElement {
53
52
  connectedCallback() {
54
53
  if (!this.hasAttribute('role'))
55
54
  this.setAttribute('role', 'dialog');
56
- const signal = __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f").signal;
55
+ const { signal } = (__classPrivateFieldSet(this, _ModalDialogElement_abortController, new AbortController(), "f"));
57
56
  this.ownerDocument.addEventListener('click', event => {
58
57
  const target = event.target;
59
58
  const clickOutsideDialog = target.closest(this.tagName) !== this;
@@ -75,12 +74,11 @@ class ModalDialogElement extends HTMLElement {
75
74
  this.show();
76
75
  }
77
76
  }, { signal });
78
- this.addEventListener('compositionstart', () => (__classPrivateFieldSet(this, _ModalDialogElement_isComposing, true, "f")));
79
- this.addEventListener('compositionend', () => (__classPrivateFieldSet(this, _ModalDialogElement_isComposing, false, "f")));
80
77
  this.addEventListener('keydown', e => __classPrivateFieldGet(this, _ModalDialogElement_instances, "m", _ModalDialogElement_keydown).call(this, e));
81
78
  }
82
79
  disconnectedCallback() {
83
- __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f").abort();
80
+ var _a;
81
+ (_a = __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
84
82
  }
85
83
  show() {
86
84
  this.open = true;
@@ -89,7 +87,7 @@ class ModalDialogElement extends HTMLElement {
89
87
  this.open = false;
90
88
  }
91
89
  }
92
- _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_abortController = new WeakMap(), _ModalDialogElement_isComposing = new WeakMap(), _ModalDialogElement_openButton = new WeakMap(), _ModalDialogElement_instances = new WeakSet(), _ModalDialogElement_overlayBackdrop_get = function _ModalDialogElement_overlayBackdrop_get() {
90
+ _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_abortController = new WeakMap(), _ModalDialogElement_openButton = new WeakMap(), _ModalDialogElement_instances = new WeakSet(), _ModalDialogElement_overlayBackdrop_get = function _ModalDialogElement_overlayBackdrop_get() {
93
91
  var _a;
94
92
  if ((_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('Overlay-backdrop')) {
95
93
  return this.parentElement;
@@ -98,7 +96,7 @@ _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_ab
98
96
  }, _ModalDialogElement_keydown = function _ModalDialogElement_keydown(event) {
99
97
  if (!(event instanceof KeyboardEvent))
100
98
  return;
101
- if (__classPrivateFieldGet(this, _ModalDialogElement_isComposing, "f"))
99
+ if (event.isComposing)
102
100
  return;
103
101
  switch (event.key) {
104
102
  case 'Escape':
@@ -9,7 +9,7 @@ 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 _ModalDialogElement_instances, _ModalDialogElement_focusAbortController, _ModalDialogElement_abortController, _ModalDialogElement_isComposing, _ModalDialogElement_openButton, _ModalDialogElement_overlayBackdrop_get, _ModalDialogElement_keydown;
12
+ var _ModalDialogElement_instances, _ModalDialogElement_focusAbortController, _ModalDialogElement_abortController, _ModalDialogElement_openButton, _ModalDialogElement_overlayBackdrop_get, _ModalDialogElement_keydown;
13
13
  import { focusIfNeeded } from '../utils/iterate-focusable-elements.js';
14
14
  import { focusTrap } from '../focus-trap.js';
15
15
  class ModalDialogElement extends HTMLElement {
@@ -17,8 +17,7 @@ class ModalDialogElement extends HTMLElement {
17
17
  super(...arguments);
18
18
  _ModalDialogElement_instances.add(this);
19
19
  _ModalDialogElement_focusAbortController.set(this, new AbortController());
20
- _ModalDialogElement_abortController.set(this, new AbortController());
21
- _ModalDialogElement_isComposing.set(this, false);
20
+ _ModalDialogElement_abortController.set(this, null);
22
21
  _ModalDialogElement_openButton.set(this, void 0);
23
22
  }
24
23
  get open() {
@@ -51,7 +50,7 @@ class ModalDialogElement extends HTMLElement {
51
50
  connectedCallback() {
52
51
  if (!this.hasAttribute('role'))
53
52
  this.setAttribute('role', 'dialog');
54
- const signal = __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f").signal;
53
+ const { signal } = (__classPrivateFieldSet(this, _ModalDialogElement_abortController, new AbortController(), "f"));
55
54
  this.ownerDocument.addEventListener('click', event => {
56
55
  const target = event.target;
57
56
  const clickOutsideDialog = target.closest(this.tagName) !== this;
@@ -73,12 +72,11 @@ class ModalDialogElement extends HTMLElement {
73
72
  this.show();
74
73
  }
75
74
  }, { signal });
76
- this.addEventListener('compositionstart', () => (__classPrivateFieldSet(this, _ModalDialogElement_isComposing, true, "f")));
77
- this.addEventListener('compositionend', () => (__classPrivateFieldSet(this, _ModalDialogElement_isComposing, false, "f")));
78
75
  this.addEventListener('keydown', e => __classPrivateFieldGet(this, _ModalDialogElement_instances, "m", _ModalDialogElement_keydown).call(this, e));
79
76
  }
80
77
  disconnectedCallback() {
81
- __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f").abort();
78
+ var _a;
79
+ (_a = __classPrivateFieldGet(this, _ModalDialogElement_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
82
80
  }
83
81
  show() {
84
82
  this.open = true;
@@ -87,7 +85,7 @@ class ModalDialogElement extends HTMLElement {
87
85
  this.open = false;
88
86
  }
89
87
  }
90
- _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_abortController = new WeakMap(), _ModalDialogElement_isComposing = new WeakMap(), _ModalDialogElement_openButton = new WeakMap(), _ModalDialogElement_instances = new WeakSet(), _ModalDialogElement_overlayBackdrop_get = function _ModalDialogElement_overlayBackdrop_get() {
88
+ _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_abortController = new WeakMap(), _ModalDialogElement_openButton = new WeakMap(), _ModalDialogElement_instances = new WeakSet(), _ModalDialogElement_overlayBackdrop_get = function _ModalDialogElement_overlayBackdrop_get() {
91
89
  var _a;
92
90
  if ((_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('Overlay-backdrop')) {
93
91
  return this.parentElement;
@@ -96,7 +94,7 @@ _ModalDialogElement_focusAbortController = new WeakMap(), _ModalDialogElement_ab
96
94
  }, _ModalDialogElement_keydown = function _ModalDialogElement_keydown(event) {
97
95
  if (!(event instanceof KeyboardEvent))
98
96
  return;
99
- if (__classPrivateFieldGet(this, _ModalDialogElement_isComposing, "f"))
97
+ if (event.isComposing)
100
98
  return;
101
99
  switch (event.key) {
102
100
  case 'Escape':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-202223113012",
3
+ "version": "0.0.0-2022349143",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",