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.
@@ -268,6 +268,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
268
268
  * Activate ripple
269
269
  */
270
270
  this.ripple = false;
271
+ this.showRipple = (event) => {
272
+ const x = event.clientX;
273
+ const y = event.clientY;
274
+ const { offsetWidth, offsetHeight } = this;
275
+ const container = document.createElement("span");
276
+ container.classList.add("ripple", "open");
277
+ const element = document.createElement("span");
278
+ container.appendChild(element);
279
+ this.shadowRoot.appendChild(container);
280
+ const rect = this.getBoundingClientRect();
281
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
282
+ element.style.width = element.style.height = diameter + "px";
283
+ element.style.left = x - rect.left - diameter / 2 + "px";
284
+ element.style.top = y - rect.top - diameter / 2 + "px";
285
+ const inAnimation = element.animate({
286
+ transform: [`scale(0)`, `scale(1)`]
287
+ }, {
288
+ easing: "ease-out",
289
+ fill: "both",
290
+ duration: 500
291
+ });
292
+ inAnimation.onfinish = () => {
293
+ container.classList.remove("open");
294
+ const outAnimation = element.animate({
295
+ opacity: ["0.5", "0"]
296
+ }, {
297
+ easing: "ease-in",
298
+ fill: "both",
299
+ duration: 300
300
+ });
301
+ outAnimation.onfinish = () => {
302
+ requestAnimationFrame(() => {
303
+ container.remove();
304
+ });
305
+ };
306
+ };
307
+ };
308
+ this.hideRipple = (event) => {
309
+ var _a;
310
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
311
+ const element = container.querySelector("span");
312
+ const outAnimation = element.animate({
313
+ opacity: ["0.5", "0"]
314
+ }, {
315
+ easing: "ease-out",
316
+ fill: "both",
317
+ duration: 300
318
+ });
319
+ outAnimation.onfinish = () => {
320
+ requestAnimationFrame(() => {
321
+ container.remove();
322
+ });
323
+ };
324
+ });
325
+ };
271
326
  }
272
327
  static get styles() {
273
328
  return [
@@ -283,14 +338,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
283
338
  }
284
339
  connectedCallback() {
285
340
  if (this.ripple) {
286
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
287
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
341
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
342
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
288
343
  }
289
344
  super.connectedCallback();
290
345
  }
291
346
  disconnectedCallback() {
292
347
  this.removeEventListener("mousedown", this.showRipple);
293
- this.addEventListener("mouseup", this.hideRipple);
348
+ this.removeEventListener("mouseup", this.hideRipple);
294
349
  super.disconnectedCallback();
295
350
  }
296
351
  updated(props) {
@@ -300,61 +355,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
300
355
  // this.style.setProperty("color", this.color.toString());
301
356
  super.updated(props);
302
357
  }
303
- showRipple(event) {
304
- const x = event.clientX;
305
- const y = event.clientY;
306
- const { offsetWidth, offsetHeight } = this;
307
- const container = document.createElement("span");
308
- container.classList.add("ripple", "open");
309
- const element = document.createElement("span");
310
- container.appendChild(element);
311
- this.shadowRoot.appendChild(container);
312
- const rect = this.getBoundingClientRect();
313
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
314
- element.style.width = element.style.height = diameter + "px";
315
- element.style.left = x - rect.left - diameter / 2 + "px";
316
- element.style.top = y - rect.top - diameter / 2 + "px";
317
- const inAnimation = element.animate({
318
- transform: [`scale(0)`, `scale(1)`]
319
- }, {
320
- easing: "ease-out",
321
- fill: "both",
322
- duration: 500
323
- });
324
- inAnimation.onfinish = () => {
325
- container.classList.remove("open");
326
- const outAnimation = element.animate({
327
- opacity: ["0.5", "0"]
328
- }, {
329
- easing: "ease-in",
330
- fill: "both",
331
- duration: 300
332
- });
333
- outAnimation.onfinish = () => {
334
- requestAnimationFrame(() => {
335
- container.remove();
336
- });
337
- };
338
- };
339
- }
340
- hideRipple(event) {
341
- var _a;
342
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
343
- const element = container.querySelector("span");
344
- const outAnimation = element.animate({
345
- opacity: ["0.5", "0"]
346
- }, {
347
- easing: "ease-out",
348
- fill: "both",
349
- duration: 300
350
- });
351
- outAnimation.onfinish = () => {
352
- requestAnimationFrame(() => {
353
- container.remove();
354
- });
355
- };
356
- });
357
- }
358
358
  };
359
359
  __decorate([
360
360
  (0,decorators_js_.property)({ type: Boolean })
package/box/index.js CHANGED
@@ -106,6 +106,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
106
106
  * Activate ripple
107
107
  */
108
108
  this.ripple = false;
109
+ this.showRipple = (event) => {
110
+ const x = event.clientX;
111
+ const y = event.clientY;
112
+ const { offsetWidth, offsetHeight } = this;
113
+ const container = document.createElement("span");
114
+ container.classList.add("ripple", "open");
115
+ const element = document.createElement("span");
116
+ container.appendChild(element);
117
+ this.shadowRoot.appendChild(container);
118
+ const rect = this.getBoundingClientRect();
119
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
120
+ element.style.width = element.style.height = diameter + "px";
121
+ element.style.left = x - rect.left - diameter / 2 + "px";
122
+ element.style.top = y - rect.top - diameter / 2 + "px";
123
+ const inAnimation = element.animate({
124
+ transform: [`scale(0)`, `scale(1)`]
125
+ }, {
126
+ easing: "ease-out",
127
+ fill: "both",
128
+ duration: 500
129
+ });
130
+ inAnimation.onfinish = () => {
131
+ container.classList.remove("open");
132
+ const outAnimation = element.animate({
133
+ opacity: ["0.5", "0"]
134
+ }, {
135
+ easing: "ease-in",
136
+ fill: "both",
137
+ duration: 300
138
+ });
139
+ outAnimation.onfinish = () => {
140
+ requestAnimationFrame(() => {
141
+ container.remove();
142
+ });
143
+ };
144
+ };
145
+ };
146
+ this.hideRipple = (event) => {
147
+ var _a;
148
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
149
+ const element = container.querySelector("span");
150
+ const outAnimation = element.animate({
151
+ opacity: ["0.5", "0"]
152
+ }, {
153
+ easing: "ease-out",
154
+ fill: "both",
155
+ duration: 300
156
+ });
157
+ outAnimation.onfinish = () => {
158
+ requestAnimationFrame(() => {
159
+ container.remove();
160
+ });
161
+ };
162
+ });
163
+ };
109
164
  }
110
165
  static get styles() {
111
166
  return [
@@ -121,14 +176,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
121
176
  }
122
177
  connectedCallback() {
123
178
  if (this.ripple) {
124
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
125
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
179
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
180
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
126
181
  }
127
182
  super.connectedCallback();
128
183
  }
129
184
  disconnectedCallback() {
130
185
  this.removeEventListener("mousedown", this.showRipple);
131
- this.addEventListener("mouseup", this.hideRipple);
186
+ this.removeEventListener("mouseup", this.hideRipple);
132
187
  super.disconnectedCallback();
133
188
  }
134
189
  updated(props) {
@@ -138,61 +193,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
138
193
  // this.style.setProperty("color", this.color.toString());
139
194
  super.updated(props);
140
195
  }
141
- showRipple(event) {
142
- const x = event.clientX;
143
- const y = event.clientY;
144
- const { offsetWidth, offsetHeight } = this;
145
- const container = document.createElement("span");
146
- container.classList.add("ripple", "open");
147
- const element = document.createElement("span");
148
- container.appendChild(element);
149
- this.shadowRoot.appendChild(container);
150
- const rect = this.getBoundingClientRect();
151
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
152
- element.style.width = element.style.height = diameter + "px";
153
- element.style.left = x - rect.left - diameter / 2 + "px";
154
- element.style.top = y - rect.top - diameter / 2 + "px";
155
- const inAnimation = element.animate({
156
- transform: [`scale(0)`, `scale(1)`]
157
- }, {
158
- easing: "ease-out",
159
- fill: "both",
160
- duration: 500
161
- });
162
- inAnimation.onfinish = () => {
163
- container.classList.remove("open");
164
- const outAnimation = element.animate({
165
- opacity: ["0.5", "0"]
166
- }, {
167
- easing: "ease-in",
168
- fill: "both",
169
- duration: 300
170
- });
171
- outAnimation.onfinish = () => {
172
- requestAnimationFrame(() => {
173
- container.remove();
174
- });
175
- };
176
- };
177
- }
178
- hideRipple(event) {
179
- var _a;
180
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
181
- const element = container.querySelector("span");
182
- const outAnimation = element.animate({
183
- opacity: ["0.5", "0"]
184
- }, {
185
- easing: "ease-out",
186
- fill: "both",
187
- duration: 300
188
- });
189
- outAnimation.onfinish = () => {
190
- requestAnimationFrame(() => {
191
- container.remove();
192
- });
193
- };
194
- });
195
- }
196
196
  };
197
197
  __decorate([
198
198
  (0,decorators_js_.property)({ type: Boolean })
@@ -30,9 +30,9 @@ export declare class TkButton extends TkBox {
30
30
  connectedCallback(): void;
31
31
  disconnectedCallback(): void;
32
32
  updated(props: any): void;
33
- protected onKeyDown(e: KeyboardEvent): void;
33
+ protected onKeyDown: (e: KeyboardEvent) => void;
34
34
  firstUpdated(): void;
35
- protected handleClick(e: Event): void;
35
+ protected handleClick: (e: Event) => void;
36
36
  slotChanged(): void;
37
37
  }
38
38
  declare global {
package/button/index.js CHANGED
@@ -107,6 +107,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
107
107
  * Activate ripple
108
108
  */
109
109
  this.ripple = false;
110
+ this.showRipple = (event) => {
111
+ const x = event.clientX;
112
+ const y = event.clientY;
113
+ const { offsetWidth, offsetHeight } = this;
114
+ const container = document.createElement("span");
115
+ container.classList.add("ripple", "open");
116
+ const element = document.createElement("span");
117
+ container.appendChild(element);
118
+ this.shadowRoot.appendChild(container);
119
+ const rect = this.getBoundingClientRect();
120
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
121
+ element.style.width = element.style.height = diameter + "px";
122
+ element.style.left = x - rect.left - diameter / 2 + "px";
123
+ element.style.top = y - rect.top - diameter / 2 + "px";
124
+ const inAnimation = element.animate({
125
+ transform: [`scale(0)`, `scale(1)`]
126
+ }, {
127
+ easing: "ease-out",
128
+ fill: "both",
129
+ duration: 500
130
+ });
131
+ inAnimation.onfinish = () => {
132
+ container.classList.remove("open");
133
+ const outAnimation = element.animate({
134
+ opacity: ["0.5", "0"]
135
+ }, {
136
+ easing: "ease-in",
137
+ fill: "both",
138
+ duration: 300
139
+ });
140
+ outAnimation.onfinish = () => {
141
+ requestAnimationFrame(() => {
142
+ container.remove();
143
+ });
144
+ };
145
+ };
146
+ };
147
+ this.hideRipple = (event) => {
148
+ var _a;
149
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
150
+ const element = container.querySelector("span");
151
+ const outAnimation = element.animate({
152
+ opacity: ["0.5", "0"]
153
+ }, {
154
+ easing: "ease-out",
155
+ fill: "both",
156
+ duration: 300
157
+ });
158
+ outAnimation.onfinish = () => {
159
+ requestAnimationFrame(() => {
160
+ container.remove();
161
+ });
162
+ };
163
+ });
164
+ };
110
165
  }
111
166
  static get styles() {
112
167
  return [
@@ -122,14 +177,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
122
177
  }
123
178
  connectedCallback() {
124
179
  if (this.ripple) {
125
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
126
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
180
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
181
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
127
182
  }
128
183
  super.connectedCallback();
129
184
  }
130
185
  disconnectedCallback() {
131
186
  this.removeEventListener("mousedown", this.showRipple);
132
- this.addEventListener("mouseup", this.hideRipple);
187
+ this.removeEventListener("mouseup", this.hideRipple);
133
188
  super.disconnectedCallback();
134
189
  }
135
190
  updated(props) {
@@ -139,61 +194,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
139
194
  // this.style.setProperty("color", this.color.toString());
140
195
  super.updated(props);
141
196
  }
142
- showRipple(event) {
143
- const x = event.clientX;
144
- const y = event.clientY;
145
- const { offsetWidth, offsetHeight } = this;
146
- const container = document.createElement("span");
147
- container.classList.add("ripple", "open");
148
- const element = document.createElement("span");
149
- container.appendChild(element);
150
- this.shadowRoot.appendChild(container);
151
- const rect = this.getBoundingClientRect();
152
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
153
- element.style.width = element.style.height = diameter + "px";
154
- element.style.left = x - rect.left - diameter / 2 + "px";
155
- element.style.top = y - rect.top - diameter / 2 + "px";
156
- const inAnimation = element.animate({
157
- transform: [`scale(0)`, `scale(1)`]
158
- }, {
159
- easing: "ease-out",
160
- fill: "both",
161
- duration: 500
162
- });
163
- inAnimation.onfinish = () => {
164
- container.classList.remove("open");
165
- const outAnimation = element.animate({
166
- opacity: ["0.5", "0"]
167
- }, {
168
- easing: "ease-in",
169
- fill: "both",
170
- duration: 300
171
- });
172
- outAnimation.onfinish = () => {
173
- requestAnimationFrame(() => {
174
- container.remove();
175
- });
176
- };
177
- };
178
- }
179
- hideRipple(event) {
180
- var _a;
181
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
182
- const element = container.querySelector("span");
183
- const outAnimation = element.animate({
184
- opacity: ["0.5", "0"]
185
- }, {
186
- easing: "ease-out",
187
- fill: "both",
188
- duration: 300
189
- });
190
- outAnimation.onfinish = () => {
191
- requestAnimationFrame(() => {
192
- container.remove();
193
- });
194
- };
195
- });
196
- }
197
197
  };
198
198
  __decorate([
199
199
  (0,decorators_js_.property)({ type: Boolean })
@@ -324,6 +324,24 @@ let TkButton = class TkButton extends box/* TkBox */.P {
324
324
  this.disabled = false;
325
325
  this.fab = false;
326
326
  this.ripple = true;
327
+ this.onKeyDown = (e) => {
328
+ if (e.code === "Space" || e.code === "Enter") {
329
+ e.preventDefault();
330
+ e.stopPropagation();
331
+ this.click();
332
+ }
333
+ };
334
+ this.handleClick = (e) => {
335
+ var _a;
336
+ if (this.href && e.isTrusted) {
337
+ e.stopPropagation();
338
+ e.preventDefault();
339
+ this.$ahref.click();
340
+ }
341
+ else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
342
+ (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
343
+ }
344
+ };
327
345
  }
328
346
  static get styles() {
329
347
  return [
@@ -355,7 +373,8 @@ let TkButton = class TkButton extends box/* TkBox */.P {
355
373
  }
356
374
  connectedCallback() {
357
375
  super.connectedCallback();
358
- this.addEventListener("click", this.handleClick.bind(this));
376
+ this.addEventListener("click", this.handleClick);
377
+ this.addEventListener("keydown", this.onKeyDown);
359
378
  }
360
379
  disconnectedCallback() {
361
380
  super.disconnectedCallback();
@@ -366,28 +385,10 @@ let TkButton = class TkButton extends box/* TkBox */.P {
366
385
  this.tabIndex = this.disabled ? -1 : 0;
367
386
  super.updated(props);
368
387
  }
369
- onKeyDown(e) {
370
- if (e.code === "Space" || e.code === "Enter") {
371
- e.preventDefault();
372
- e.stopPropagation();
373
- this.click();
374
- }
375
- }
376
388
  firstUpdated() {
377
389
  if (this.type == "submit" || this.type == "reset")
378
390
  this.appendChild(this.$button);
379
391
  }
380
- handleClick(e) {
381
- var _a;
382
- if (this.href && e.isTrusted) {
383
- e.stopPropagation();
384
- e.preventDefault();
385
- this.$ahref.click();
386
- }
387
- else if ((e.isTrusted && this.type == "submit") || this.type == "reset") {
388
- (_a = this.querySelector("button")) === null || _a === void 0 ? void 0 : _a.click();
389
- }
390
- }
391
392
  slotChanged() {
392
393
  var _a;
393
394
  const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
package/checkbox/index.js CHANGED
@@ -240,6 +240,61 @@ let TkBox = class TkBox extends external_lit_.LitElement {
240
240
  * Activate ripple
241
241
  */
242
242
  this.ripple = false;
243
+ this.showRipple = (event) => {
244
+ const x = event.clientX;
245
+ const y = event.clientY;
246
+ const { offsetWidth, offsetHeight } = this;
247
+ const container = document.createElement("span");
248
+ container.classList.add("ripple", "open");
249
+ const element = document.createElement("span");
250
+ container.appendChild(element);
251
+ this.shadowRoot.appendChild(container);
252
+ const rect = this.getBoundingClientRect();
253
+ const diameter = Math.max(offsetWidth, offsetWidth) * 2;
254
+ element.style.width = element.style.height = diameter + "px";
255
+ element.style.left = x - rect.left - diameter / 2 + "px";
256
+ element.style.top = y - rect.top - diameter / 2 + "px";
257
+ const inAnimation = element.animate({
258
+ transform: [`scale(0)`, `scale(1)`]
259
+ }, {
260
+ easing: "ease-out",
261
+ fill: "both",
262
+ duration: 500
263
+ });
264
+ inAnimation.onfinish = () => {
265
+ container.classList.remove("open");
266
+ const outAnimation = element.animate({
267
+ opacity: ["0.5", "0"]
268
+ }, {
269
+ easing: "ease-in",
270
+ fill: "both",
271
+ duration: 300
272
+ });
273
+ outAnimation.onfinish = () => {
274
+ requestAnimationFrame(() => {
275
+ container.remove();
276
+ });
277
+ };
278
+ };
279
+ };
280
+ this.hideRipple = (event) => {
281
+ var _a;
282
+ (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
283
+ const element = container.querySelector("span");
284
+ const outAnimation = element.animate({
285
+ opacity: ["0.5", "0"]
286
+ }, {
287
+ easing: "ease-out",
288
+ fill: "both",
289
+ duration: 300
290
+ });
291
+ outAnimation.onfinish = () => {
292
+ requestAnimationFrame(() => {
293
+ container.remove();
294
+ });
295
+ };
296
+ });
297
+ };
243
298
  }
244
299
  static get styles() {
245
300
  return [
@@ -255,14 +310,14 @@ let TkBox = class TkBox extends external_lit_.LitElement {
255
310
  }
256
311
  connectedCallback() {
257
312
  if (this.ripple) {
258
- this.addEventListener("mousedown", this.showRipple.bind(this), { passive: true });
259
- this.addEventListener("mouseup", this.hideRipple.bind(this), { passive: true });
313
+ this.addEventListener("mousedown", this.showRipple, { passive: true });
314
+ this.addEventListener("mouseup", this.hideRipple, { passive: true });
260
315
  }
261
316
  super.connectedCallback();
262
317
  }
263
318
  disconnectedCallback() {
264
319
  this.removeEventListener("mousedown", this.showRipple);
265
- this.addEventListener("mouseup", this.hideRipple);
320
+ this.removeEventListener("mouseup", this.hideRipple);
266
321
  super.disconnectedCallback();
267
322
  }
268
323
  updated(props) {
@@ -272,61 +327,6 @@ let TkBox = class TkBox extends external_lit_.LitElement {
272
327
  // this.style.setProperty("color", this.color.toString());
273
328
  super.updated(props);
274
329
  }
275
- showRipple(event) {
276
- const x = event.clientX;
277
- const y = event.clientY;
278
- const { offsetWidth, offsetHeight } = this;
279
- const container = document.createElement("span");
280
- container.classList.add("ripple", "open");
281
- const element = document.createElement("span");
282
- container.appendChild(element);
283
- this.shadowRoot.appendChild(container);
284
- const rect = this.getBoundingClientRect();
285
- const diameter = Math.max(offsetWidth, offsetWidth) * 2;
286
- element.style.width = element.style.height = diameter + "px";
287
- element.style.left = x - rect.left - diameter / 2 + "px";
288
- element.style.top = y - rect.top - diameter / 2 + "px";
289
- const inAnimation = element.animate({
290
- transform: [`scale(0)`, `scale(1)`]
291
- }, {
292
- easing: "ease-out",
293
- fill: "both",
294
- duration: 500
295
- });
296
- inAnimation.onfinish = () => {
297
- container.classList.remove("open");
298
- const outAnimation = element.animate({
299
- opacity: ["0.5", "0"]
300
- }, {
301
- easing: "ease-in",
302
- fill: "both",
303
- duration: 300
304
- });
305
- outAnimation.onfinish = () => {
306
- requestAnimationFrame(() => {
307
- container.remove();
308
- });
309
- };
310
- };
311
- }
312
- hideRipple(event) {
313
- var _a;
314
- (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".ripple:not([open])").forEach(container => {
315
- const element = container.querySelector("span");
316
- const outAnimation = element.animate({
317
- opacity: ["0.5", "0"]
318
- }, {
319
- easing: "ease-out",
320
- fill: "both",
321
- duration: 300
322
- });
323
- outAnimation.onfinish = () => {
324
- requestAnimationFrame(() => {
325
- container.remove();
326
- });
327
- };
328
- });
329
- }
330
330
  };
331
331
  __decorate([
332
332
  (0,decorators_js_.property)({ type: Boolean })
@@ -5,8 +5,11 @@ export declare class TkDialog extends LitElement {
5
5
  open: boolean;
6
6
  blurOverlay: boolean;
7
7
  private resolve;
8
+ private handleKeyDown;
8
9
  render(): import("lit").TemplateResult<1>;
9
10
  protected updated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
11
+ connectedCallback(): void;
12
+ disconnectedCallback(): void;
10
13
  show(): Promise<string | boolean | null>;
11
14
  hide(value?: boolean | string | null): void;
12
15
  }
package/dialog/index.js CHANGED
@@ -55,6 +55,10 @@ let TkDialog = class TkDialog extends external_lit_.LitElement {
55
55
  this.modal = false;
56
56
  this.open = false;
57
57
  this.blurOverlay = false;
58
+ this.handleKeyDown = (event) => {
59
+ if (event.key === "Escape" && this.open && !this.modal)
60
+ this.hide();
61
+ };
58
62
  }
59
63
  render() {
60
64
  return (0,external_lit_.html) `
@@ -74,6 +78,14 @@ let TkDialog = class TkDialog extends external_lit_.LitElement {
74
78
  if (_changedProperties.has("open") && _changedProperties.get("open") == true && !this.open)
75
79
  this.dispatchEvent(new Event("did-close"));
76
80
  }
81
+ connectedCallback() {
82
+ super.connectedCallback();
83
+ window.addEventListener("keydown", this.handleKeyDown);
84
+ }
85
+ disconnectedCallback() {
86
+ window.removeEventListener("keydown", this.handleKeyDown);
87
+ super.disconnectedCallback();
88
+ }
77
89
  show() {
78
90
  this.open = true;
79
91
  return new Promise(resolve => {