@primer/view-components 0.2.0 → 0.2.1-rc.e5136bee

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.
@@ -2,6 +2,7 @@ declare class ToggleSwitchElement extends HTMLElement {
2
2
  switch: HTMLElement;
3
3
  loadingSpinner: HTMLElement;
4
4
  errorIcon: HTMLElement;
5
+ private toggling;
5
6
  get src(): string | null;
6
7
  get csrf(): string | null;
7
8
  get csrfField(): string;
@@ -5,8 +5,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { controller, target } from '@github/catalyst';
8
- import { debounce } from '@github/mini-throttle/decorators';
9
8
  let ToggleSwitchElement = class ToggleSwitchElement extends HTMLElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.toggling = false;
12
+ }
10
13
  get src() {
11
14
  const src = this.getAttribute('src');
12
15
  if (!src)
@@ -27,11 +30,15 @@ let ToggleSwitchElement = class ToggleSwitchElement extends HTMLElement {
27
30
  return this.src != null;
28
31
  }
29
32
  async toggle() {
33
+ if (this.toggling)
34
+ return;
35
+ this.toggling = true;
30
36
  if (this.isDisabled()) {
31
37
  return;
32
38
  }
33
39
  if (!this.isRemote()) {
34
40
  this.performToggle();
41
+ this.toggling = false;
35
42
  return;
36
43
  }
37
44
  // toggle immediately to tell screen readers the switch was clicked
@@ -49,6 +56,9 @@ let ToggleSwitchElement = class ToggleSwitchElement extends HTMLElement {
49
56
  }
50
57
  return;
51
58
  }
59
+ finally {
60
+ this.toggling = false;
61
+ }
52
62
  this.setSuccessState();
53
63
  }
54
64
  turnOn() {
@@ -146,9 +156,6 @@ __decorate([
146
156
  __decorate([
147
157
  target
148
158
  ], ToggleSwitchElement.prototype, "errorIcon", void 0);
149
- __decorate([
150
- debounce(300)
151
- ], ToggleSwitchElement.prototype, "toggle", null);
152
159
  ToggleSwitchElement = __decorate([
153
160
  controller
154
161
  ], ToggleSwitchElement);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-rc.e5136bee",
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",
@@ -51,7 +51,6 @@
51
51
  "@github/details-menu-element": "^1.0.12",
52
52
  "@github/image-crop-element": "^5.0.0",
53
53
  "@github/include-fragment-element": "^6.1.1",
54
- "@github/mini-throttle": "^2.1.0",
55
54
  "@github/relative-time-element": "^4.0.0",
56
55
  "@github/tab-container-element": "^3.1.2",
57
56
  "@oddbird/popover-polyfill": "^0.2.1",