tinkiet 0.11.2 → 0.11.4

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.
@@ -11,10 +11,10 @@ export declare class TkDrawer extends LitElement {
11
11
  swipeable: boolean;
12
12
  private $drawer;
13
13
  private mql;
14
+ private overMediaQueryListener;
14
15
  render(): import("lit").TemplateResult<1>;
15
16
  updated(props: any): void;
16
17
  protected overMediaQuery(): void;
17
- private overMediaQueryListener;
18
18
  hideIfOver(): void;
19
19
  show(): void;
20
20
  hide(): void;
@@ -25,6 +25,7 @@ export declare class TkDrawer extends LitElement {
25
25
  touchStart(event: TouchEvent): void;
26
26
  touchMove(event: TouchEvent): void;
27
27
  touchEnd(event: TouchEvent): void;
28
+ disconnectedCallback(): void;
28
29
  }
29
30
  declare global {
30
31
  interface HTMLElementTagNameMap {
package/drawer/index.js CHANGED
@@ -46,6 +46,9 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
46
46
  this.over = false;
47
47
  this.right = false;
48
48
  this.swipeable = false;
49
+ this.overMediaQueryListener = (e) => {
50
+ e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
51
+ };
49
52
  this.swipeX = 0;
50
53
  this.swipeY = 0;
51
54
  this.isHorizontalSwipe = false;
@@ -100,13 +103,10 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
100
103
  }
101
104
  overMediaQuery() {
102
105
  if (this.mql)
103
- this.mql.removeEventListener("change", this.overMediaQueryListener.bind(this));
106
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
104
107
  this.mql = window.matchMedia(this.overQuery);
105
108
  this.mql.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
106
- this.mql.addEventListener("change", this.overMediaQueryListener.bind(this));
107
- }
108
- overMediaQueryListener(e) {
109
- e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
109
+ this.mql.addEventListener("change", this.overMediaQueryListener);
110
110
  }
111
111
  hideIfOver() {
112
112
  var _a;
@@ -163,6 +163,11 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
163
163
  }
164
164
  this.isHorizontalSwipe = false;
165
165
  }
166
+ disconnectedCallback() {
167
+ if (this.mql)
168
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
169
+ super.disconnectedCallback();
170
+ }
166
171
  };
167
172
  TkDrawer.styles = (0,external_lit_.css) `
168
173
  ${(0,external_lit_.unsafeCSS)(drawer)}
package/icon/index.js CHANGED
@@ -146,6 +146,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
146
146
  * Activate ripple
147
147
  */
148
148
  this.ripple = false;
149
+ this.showRipple = (event) => {
150
+ const x = event.clientX;
151
+ const y = event.clientY;
152
+ const { offsetWidth, offsetHeight } = this;
153
+ const container = document.createElement("span");
154
+ container.classList.add("ripple", "open");
155
+ const element = document.createElement("span");
156
+ container.appendChild(element);
157
+ this.shadowRoot.appendChild(container);
158
+ const rect = this.getBoundingClientRect();
159
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
160
+ element.style.width = element.style.height = diameter + "px";
161
+ element.style.left = x - rect.left - diameter / 2 + "px";
162
+ element.style.top = y - rect.top - diameter / 2 + "px";
163
+ const inAnimation = element.animate({
164
+ transform: [`scale(0)`, `scale(1)`]
165
+ }, {
166
+ easing: "ease-out",
167
+ fill: "both",
168
+ duration: 500
169
+ });
170
+ inAnimation.onfinish = () => {
171
+ container.classList.remove("open");
172
+ const outAnimation = element.animate({
173
+ opacity: ["0.5", "0"]
174
+ }, {
175
+ easing: "ease-in",
176
+ fill: "both",
177
+ duration: 300
178
+ });
179
+ outAnimation.onfinish = () => {
180
+ requestAnimationFrame(() => {
181
+ container.remove();
182
+ });
183
+ };
184
+ };
185
+ };
186
+ this.hideRipple = (event) => {
187
+ var _a;
188
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
189
+ const element = container.querySelector("span");
190
+ const outAnimation = element.animate({
191
+ opacity: ["0.5", "0"]
192
+ }, {
193
+ easing: "ease-out",
194
+ fill: "both",
195
+ duration: 300
196
+ });
197
+ outAnimation.onfinish = () => {
198
+ requestAnimationFrame(() => {
199
+ container.remove();
200
+ });
201
+ };
202
+ });
203
+ };
149
204
  }
150
205
  static get styles() {
151
206
  return [
@@ -161,14 +216,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
161
216
  }
162
217
  connectedCallback() {
163
218
  if (this.ripple) {
164
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
165
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
219
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
220
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
166
221
  }
167
222
  super.connectedCallback();
168
223
  }
169
224
  disconnectedCallback() {
170
225
  this.removeEventListener("mousedown", this.showRipple);
171
- this.addEventListener("mouseup", this.hideRipple);
226
+ this.removeEventListener("mouseup", this.hideRipple);
172
227
  super.disconnectedCallback();
173
228
  }
174
229
  updated(props) {
@@ -178,61 +233,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
178
233
  // this.style.setProperty("color", this.color.toString());
179
234
  super.updated(props);
180
235
  }
181
- showRipple(event) {
182
- const x = event.clientX;
183
- const y = event.clientY;
184
- const { offsetWidth, offsetHeight } = this;
185
- const container = document.createElement("span");
186
- container.classList.add("ripple", "open");
187
- const element = document.createElement("span");
188
- container.appendChild(element);
189
- this.shadowRoot.appendChild(container);
190
- const rect = this.getBoundingClientRect();
191
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
192
- element.style.width = element.style.height = diameter + "px";
193
- element.style.left = x - rect.left - diameter / 2 + "px";
194
- element.style.top = y - rect.top - diameter / 2 + "px";
195
- const inAnimation = element.animate({
196
- transform: [`scale(0)`, `scale(1)`]
197
- }, {
198
- easing: "ease-out",
199
- fill: "both",
200
- duration: 500
201
- });
202
- inAnimation.onfinish = () => {
203
- container.classList.remove("open");
204
- const outAnimation = element.animate({
205
- opacity: ["0.5", "0"]
206
- }, {
207
- easing: "ease-in",
208
- fill: "both",
209
- duration: 300
210
- });
211
- outAnimation.onfinish = () => {
212
- requestAnimationFrame(() => {
213
- container.remove();
214
- });
215
- };
216
- };
217
- }
218
- hideRipple(event) {
219
- var _a;
220
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
221
- const element = container.querySelector("span");
222
- const outAnimation = element.animate({
223
- opacity: ["0.5", "0"]
224
- }, {
225
- easing: "ease-out",
226
- fill: "both",
227
- duration: 300
228
- });
229
- outAnimation.onfinish = () => {
230
- requestAnimationFrame(() => {
231
- container.remove();
232
- });
233
- };
234
- });
235
- }
236
236
  };
237
237
  __decorate([
238
238
  (0,decorators_js_.property)({ type: Boolean })
package/index.js CHANGED
@@ -157,6 +157,25 @@ let TkListItem = class TkListItem extends box/* TkBox */.P {
157
157
  super();
158
158
  this.href = "";
159
159
  this.target = "";
160
+ this.onKeyDown = (e) => {
161
+ if (e.code === "Space" || e.code === "Enter") {
162
+ e.preventDefault();
163
+ e.stopPropagation();
164
+ this.click();
165
+ }
166
+ };
167
+ this.handleClick = (e) => {
168
+ const target = e.target;
169
+ // In case click cames from a slotted element with href attribute we stop propagation
170
+ if (target.tagName == "BUTTON" || target.tagName == "TK-BUTTON" || target.tagName == "TK-SWITCH" || target.tagName == "TK-CHECKBOX") {
171
+ return;
172
+ }
173
+ if (this.href && e.isTrusted) {
174
+ e.stopPropagation();
175
+ e.preventDefault();
176
+ this.$ahref.click();
177
+ }
178
+ };
160
179
  }
161
180
  firstUpdated() {
162
181
  if (!this.ariaLabel && this.innerText)
@@ -164,33 +183,14 @@ let TkListItem = class TkListItem extends box/* TkBox */.P {
164
183
  }
165
184
  connectedCallback() {
166
185
  super.connectedCallback();
167
- this.addEventListener("keydown", this.onKeyDown.bind(this));
168
- this.addEventListener("click", this.handleClick.bind(this));
186
+ this.addEventListener("keydown", this.onKeyDown);
187
+ this.addEventListener("click", this.handleClick);
169
188
  }
170
189
  disconnectedCallback() {
171
190
  super.disconnectedCallback();
172
191
  this.removeEventListener("click", this.handleClick);
173
192
  this.removeEventListener("keydown", this.onKeyDown);
174
193
  }
175
- onKeyDown(e) {
176
- if (e.code === "Space" || e.code === "Enter") {
177
- e.preventDefault();
178
- e.stopPropagation();
179
- this.click();
180
- }
181
- }
182
- handleClick(e) {
183
- const target = e.target;
184
- // In case click cames from a slotted element with href attribute we stop propagation
185
- if (target.tagName == "BUTTON" || target.tagName == "TK-BUTTON" || target.tagName == "TK-SWITCH" || target.tagName == "TK-CHECKBOX") {
186
- return;
187
- }
188
- if (this.href && e.isTrusted) {
189
- e.stopPropagation();
190
- e.preventDefault();
191
- this.$ahref.click();
192
- }
193
- }
194
194
  };
195
195
  __decorate([
196
196
  (0,decorators_js_.property)({ attribute: true })
@@ -1012,6 +1012,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1012
1012
  * Activate ripple
1013
1013
  */
1014
1014
  this.ripple = false;
1015
+ this.showRipple = (event) => {
1016
+ const x = event.clientX;
1017
+ const y = event.clientY;
1018
+ const { offsetWidth, offsetHeight } = this;
1019
+ const container = document.createElement("span");
1020
+ container.classList.add("ripple", "open");
1021
+ const element = document.createElement("span");
1022
+ container.appendChild(element);
1023
+ this.shadowRoot.appendChild(container);
1024
+ const rect = this.getBoundingClientRect();
1025
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
1026
+ element.style.width = element.style.height = diameter + "px";
1027
+ element.style.left = x - rect.left - diameter / 2 + "px";
1028
+ element.style.top = y - rect.top - diameter / 2 + "px";
1029
+ const inAnimation = element.animate({
1030
+ transform: [`scale(0)`, `scale(1)`]
1031
+ }, {
1032
+ easing: "ease-out",
1033
+ fill: "both",
1034
+ duration: 500
1035
+ });
1036
+ inAnimation.onfinish = () => {
1037
+ container.classList.remove("open");
1038
+ const outAnimation = element.animate({
1039
+ opacity: ["0.5", "0"]
1040
+ }, {
1041
+ easing: "ease-in",
1042
+ fill: "both",
1043
+ duration: 300
1044
+ });
1045
+ outAnimation.onfinish = () => {
1046
+ requestAnimationFrame(() => {
1047
+ container.remove();
1048
+ });
1049
+ };
1050
+ };
1051
+ };
1052
+ this.hideRipple = (event) => {
1053
+ var _a;
1054
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
1055
+ const element = container.querySelector("span");
1056
+ const outAnimation = element.animate({
1057
+ opacity: ["0.5", "0"]
1058
+ }, {
1059
+ easing: "ease-out",
1060
+ fill: "both",
1061
+ duration: 300
1062
+ });
1063
+ outAnimation.onfinish = () => {
1064
+ requestAnimationFrame(() => {
1065
+ container.remove();
1066
+ });
1067
+ };
1068
+ });
1069
+ };
1015
1070
  }
1016
1071
  static get styles() {
1017
1072
  return [
@@ -1027,14 +1082,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1027
1082
  }
1028
1083
  connectedCallback() {
1029
1084
  if (this.ripple) {
1030
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
1031
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
1085
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
1086
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
1032
1087
  }
1033
1088
  super.connectedCallback();
1034
1089
  }
1035
1090
  disconnectedCallback() {
1036
1091
  this.removeEventListener("mousedown", this.showRipple);
1037
- this.addEventListener("mouseup", this.hideRipple);
1092
+ this.removeEventListener("mouseup", this.hideRipple);
1038
1093
  super.disconnectedCallback();
1039
1094
  }
1040
1095
  updated(props) {
@@ -1044,61 +1099,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
1044
1099
  // this.style.setProperty("color", this.color.toString());
1045
1100
  super.updated(props);
1046
1101
  }
1047
- showRipple(event) {
1048
- const x = event.clientX;
1049
- const y = event.clientY;
1050
- const { offsetWidth, offsetHeight } = this;
1051
- const container = document.createElement("span");
1052
- container.classList.add("ripple", "open");
1053
- const element = document.createElement("span");
1054
- container.appendChild(element);
1055
- this.shadowRoot.appendChild(container);
1056
- const rect = this.getBoundingClientRect();
1057
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
1058
- element.style.width = element.style.height = diameter + "px";
1059
- element.style.left = x - rect.left - diameter / 2 + "px";
1060
- element.style.top = y - rect.top - diameter / 2 + "px";
1061
- const inAnimation = element.animate({
1062
- transform: [`scale(0)`, `scale(1)`]
1063
- }, {
1064
- easing: "ease-out",
1065
- fill: "both",
1066
- duration: 500
1067
- });
1068
- inAnimation.onfinish = () => {
1069
- container.classList.remove("open");
1070
- const outAnimation = element.animate({
1071
- opacity: ["0.5", "0"]
1072
- }, {
1073
- easing: "ease-in",
1074
- fill: "both",
1075
- duration: 300
1076
- });
1077
- outAnimation.onfinish = () => {
1078
- requestAnimationFrame(() => {
1079
- container.remove();
1080
- });
1081
- };
1082
- };
1083
- }
1084
- hideRipple(event) {
1085
- var _a;
1086
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
1087
- const element = container.querySelector("span");
1088
- const outAnimation = element.animate({
1089
- opacity: ["0.5", "0"]
1090
- }, {
1091
- easing: "ease-out",
1092
- fill: "both",
1093
- duration: 300
1094
- });
1095
- outAnimation.onfinish = () => {
1096
- requestAnimationFrame(() => {
1097
- container.remove();
1098
- });
1099
- };
1100
- });
1101
- }
1102
1102
  };
1103
1103
  __decorate([
1104
1104
  (0,decorators_js_.property)({ type: Boolean })
@@ -1373,6 +1373,25 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1373
1373
  this.required = false;
1374
1374
  this.disabled = false;
1375
1375
  this.readonly = false;
1376
+ this.onKeyDown = (e) => {
1377
+ if (this.disabled)
1378
+ return;
1379
+ if (e.code === "Space" || e.code === "Enter") {
1380
+ e.preventDefault();
1381
+ e.stopPropagation();
1382
+ this.click();
1383
+ }
1384
+ };
1385
+ this.handleClick = () => {
1386
+ if (this.disabled)
1387
+ return;
1388
+ this.checked = !this.checked;
1389
+ if (this.checked && this.name)
1390
+ this.getRootNode()
1391
+ .querySelectorAll(`tk-radio[name="${this.name}"]`)
1392
+ .forEach(el => (el != this ? (el.checked = false) : null));
1393
+ setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
1394
+ };
1376
1395
  }
1377
1396
  render() {
1378
1397
  return (0,external_lit_.html) `
@@ -1402,8 +1421,8 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1402
1421
  }
1403
1422
  connectedCallback() {
1404
1423
  super.connectedCallback();
1405
- this.addEventListener("click", this.handleClick.bind(this));
1406
- this.addEventListener("keydown", this.onKeyDown.bind(this));
1424
+ this.addEventListener("click", this.handleClick);
1425
+ this.addEventListener("keydown", this.onKeyDown);
1407
1426
  }
1408
1427
  disconnectedCallback() {
1409
1428
  super.disconnectedCallback();
@@ -1413,25 +1432,6 @@ let TkRadio = class TkRadio extends external_lit_.LitElement {
1413
1432
  firstUpdated() {
1414
1433
  this.appendChild(this.$input);
1415
1434
  }
1416
- onKeyDown(e) {
1417
- if (this.disabled)
1418
- return;
1419
- if (e.code === "Space" || e.code === "Enter") {
1420
- e.preventDefault();
1421
- e.stopPropagation();
1422
- this.click();
1423
- }
1424
- }
1425
- handleClick() {
1426
- if (this.disabled)
1427
- return;
1428
- this.checked = !this.checked;
1429
- if (this.checked && this.name)
1430
- this.getRootNode()
1431
- .querySelectorAll(`tk-radio[name="${this.name}"]`)
1432
- .forEach(el => (el != this ? (el.checked = false) : null));
1433
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
1434
- }
1435
1435
  };
1436
1436
  TkRadio.styles = (0,external_lit_.css) `
1437
1437
  ${(0,external_lit_.unsafeCSS)(radio_radio)}
@@ -2028,6 +2028,9 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2028
2028
  this.over = false;
2029
2029
  this.right = false;
2030
2030
  this.swipeable = false;
2031
+ this.overMediaQueryListener = (e) => {
2032
+ e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2033
+ };
2031
2034
  this.swipeX = 0;
2032
2035
  this.swipeY = 0;
2033
2036
  this.isHorizontalSwipe = false;
@@ -2082,13 +2085,10 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2082
2085
  }
2083
2086
  overMediaQuery() {
2084
2087
  if (this.mql)
2085
- this.mql.removeEventListener("change", this.overMediaQueryListener.bind(this));
2088
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
2086
2089
  this.mql = window.matchMedia(this.overQuery);
2087
2090
  this.mql.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2088
- this.mql.addEventListener("change", this.overMediaQueryListener.bind(this));
2089
- }
2090
- overMediaQueryListener(e) {
2091
- e.matches ? this.setAttribute("over", "") : this.removeAttribute("over");
2091
+ this.mql.addEventListener("change", this.overMediaQueryListener);
2092
2092
  }
2093
2093
  hideIfOver() {
2094
2094
  var _a;
@@ -2145,6 +2145,11 @@ let TkDrawer = class TkDrawer extends external_lit_.LitElement {
2145
2145
  }
2146
2146
  this.isHorizontalSwipe = false;
2147
2147
  }
2148
+ disconnectedCallback() {
2149
+ if (this.mql)
2150
+ this.mql.removeEventListener("change", this.overMediaQueryListener);
2151
+ super.disconnectedCallback();
2152
+ }
2148
2153
  };
2149
2154
  TkDrawer.styles = (0,external_lit_.css) `
2150
2155
  ${(0,external_lit_.unsafeCSS)(drawer)}
@@ -2356,6 +2361,24 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2356
2361
  this.disabled = false;
2357
2362
  this.fab = false;
2358
2363
  this.ripple = true;
2364
+ this.onKeyDown = (e) => {
2365
+ if (e.code === "Space" || e.code === "Enter") {
2366
+ e.preventDefault();
2367
+ e.stopPropagation();
2368
+ this.click();
2369
+ }
2370
+ };
2371
+ this.handleClick = (e) => {
2372
+ var _a;
2373
+ if (this.href && e.isTrusted) {
2374
+ e.stopPropagation();
2375
+ e.preventDefault();
2376
+ this.$ahref.click();
2377
+ }
2378
+ else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
2379
+ (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
2380
+ }
2381
+ };
2359
2382
  }
2360
2383
  static get styles() {
2361
2384
  return [
@@ -2387,7 +2410,8 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2387
2410
  }
2388
2411
  connectedCallback() {
2389
2412
  super.connectedCallback();
2390
- this.addEventListener("click", this.handleClick.bind(this));
2413
+ this.addEventListener("click", this.handleClick);
2414
+ this.addEventListener("keydown", this.onKeyDown);
2391
2415
  }
2392
2416
  disconnectedCallback() {
2393
2417
  super.disconnectedCallback();
@@ -2398,28 +2422,10 @@ let TkButton = class TkButton extends box/* TkBox */.P {
2398
2422
  this.tabIndex = this.disabled ? -1 : 0;
2399
2423
  super.updated(props);
2400
2424
  }
2401
- onKeyDown(e) {
2402
- if (e.code === "Space" || e.code === "Enter") {
2403
- e.preventDefault();
2404
- e.stopPropagation();
2405
- this.click();
2406
- }
2407
- }
2408
2425
  firstUpdated() {
2409
2426
  if (this.type == "submit" || this.type == "reset")
2410
2427
  this.appendChild(this.$button);
2411
2428
  }
2412
- handleClick(e) {
2413
- var _a;
2414
- if (this.href && e.isTrusted) {
2415
- e.stopPropagation();
2416
- e.preventDefault();
2417
- this.$ahref.click();
2418
- }
2419
- else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
2420
- (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
2421
- }
2422
- }
2423
2429
  slotChanged() {
2424
2430
  var _a;
2425
2431
  const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
@@ -2509,6 +2515,21 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2509
2515
  this.required = false;
2510
2516
  this.disabled = false;
2511
2517
  this.readonly = false;
2518
+ this.onKeyDown = (e) => {
2519
+ if (e.code === "Space" || e.code === "Enter") {
2520
+ e.preventDefault();
2521
+ e.stopPropagation();
2522
+ this.click();
2523
+ }
2524
+ };
2525
+ this.handleClick = () => {
2526
+ this.checked = !this.checked;
2527
+ if (this.checked && this.name)
2528
+ this.getRootNode()
2529
+ .querySelectorAll(`tk-radio[name="${this.name}"]`)
2530
+ .forEach(el => (el != this ? (el.checked = false) : null));
2531
+ setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
2532
+ };
2512
2533
  }
2513
2534
  render() {
2514
2535
  return (0,external_lit_.html) `
@@ -2538,8 +2559,8 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2538
2559
  }
2539
2560
  connectedCallback() {
2540
2561
  super.connectedCallback();
2541
- this.addEventListener("click", this.handleClick.bind(this));
2542
- this.addEventListener("keydown", this.onKeyDown.bind(this));
2562
+ this.addEventListener("click", this.handleClick);
2563
+ this.addEventListener("keydown", this.onKeyDown);
2543
2564
  }
2544
2565
  disconnectedCallback() {
2545
2566
  super.disconnectedCallback();
@@ -2549,21 +2570,6 @@ let TkSwitch = class TkSwitch extends external_lit_.LitElement {
2549
2570
  firstUpdated() {
2550
2571
  this.appendChild(this.$input);
2551
2572
  }
2552
- onKeyDown(e) {
2553
- if (e.code === "Space" || e.code === "Enter") {
2554
- e.preventDefault();
2555
- e.stopPropagation();
2556
- this.click();
2557
- }
2558
- }
2559
- handleClick() {
2560
- this.checked = !this.checked;
2561
- if (this.checked && this.name)
2562
- this.getRootNode()
2563
- .querySelectorAll(`tk-radio[name="${this.name}"]`)
2564
- .forEach(el => (el != this ? (el.checked = false) : null));
2565
- setTimeout(() => this.dispatchEvent(new Event("change", { bubbles: true, composed: true })));
2566
- }
2567
2573
  };
2568
2574
  TkSwitch.styles = (0,external_lit_.css) `
2569
2575
  ${(0,external_lit_.unsafeCSS)(switch_switch)}
@@ -3561,6 +3567,10 @@ let TkDialog = class TkDialog extends external_lit_.LitElement {
3561
3567
  this.modal = false;
3562
3568
  this.open = false;
3563
3569
  this.blurOverlay = false;
3570
+ this.handleKeyDown = (event) => {
3571
+ if (event.key === "Escape" && this.open && !this.modal)
3572
+ this.hide();
3573
+ };
3564
3574
  }
3565
3575
  render() {
3566
3576
  return (0,external_lit_.html) `
@@ -3580,6 +3590,14 @@ let TkDialog = class TkDialog extends external_lit_.LitElement {
3580
3590
  if (_changedProperties.has("open") && _changedProperties.get("open") == true && !this.open)
3581
3591
  this.dispatchEvent(new Event("did-close"));
3582
3592
  }
3593
+ connectedCallback() {
3594
+ super.connectedCallback();
3595
+ window.addEventListener("keydown", this.handleKeyDown);
3596
+ }
3597
+ disconnectedCallback() {
3598
+ window.removeEventListener("keydown", this.handleKeyDown);
3599
+ super.disconnectedCallback();
3600
+ }
3583
3601
  show() {
3584
3602
  this.open = true;
3585
3603
  return new Promise(resolve => {