@maggioli-design-system/mds-modal 3.1.0 → 3.2.1

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.
Files changed (54) hide show
  1. package/dist/cjs/{index-90939077.js → index-d859a858.js} +217 -195
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/mds-modal.cjs.entry.js +34 -7
  4. package/dist/cjs/mds-modal.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +1 -1
  6. package/dist/collection/common/aria.js +19 -0
  7. package/dist/collection/components/mds-modal/mds-modal.css +37 -67
  8. package/dist/collection/components/mds-modal/mds-modal.js +33 -6
  9. package/dist/collection/components/mds-modal/test/mds-modal.stories.js +8 -0
  10. package/dist/collection/dictionary/typography.js +3 -3
  11. package/dist/components/mds-modal.js +33 -6
  12. package/dist/esm/{index-5dfae565.js → index-a5a41aa8.js} +217 -195
  13. package/dist/esm/loader.js +2 -2
  14. package/dist/esm/mds-modal.entry.js +34 -7
  15. package/dist/esm/mds-modal.js +2 -2
  16. package/dist/esm/polyfills/css-shim.js +1 -1
  17. package/dist/esm-es5/index-a5a41aa8.js +2 -0
  18. package/dist/esm-es5/loader.js +1 -1
  19. package/dist/esm-es5/mds-modal.entry.js +1 -1
  20. package/dist/esm-es5/mds-modal.js +1 -1
  21. package/dist/mds-modal/mds-modal.esm.js +1 -1
  22. package/dist/mds-modal/mds-modal.js +1 -1
  23. package/dist/mds-modal/p-4fe02e5f.entry.js +1 -0
  24. package/dist/mds-modal/{p-4288d1a7.system.entry.js → p-52cd3b82.system.entry.js} +1 -1
  25. package/dist/mds-modal/p-76a04b9e.system.js +2 -0
  26. package/dist/mds-modal/p-931319fa.js +2 -0
  27. package/dist/mds-modal/{p-5935b9a5.system.js → p-a2cf985e.system.js} +1 -1
  28. package/dist/stats.json +36 -32
  29. package/dist/types/common/aria.d.ts +4 -0
  30. package/dist/types/components/mds-modal/test/mds-modal.stories.d.ts +1 -0
  31. package/dist/types/stencil-public-runtime.d.ts +20 -4
  32. package/dist/types/types/typography.d.ts +3 -3
  33. package/package.json +3 -3
  34. package/src/common/aria.ts +27 -0
  35. package/src/components/mds-modal/mds-modal.tsx +39 -4
  36. package/src/components/mds-modal/test/mds-modal.e2e.ts +2 -2
  37. package/src/components/mds-modal/test/mds-modal.stories.tsx +20 -0
  38. package/src/dictionary/typography.ts +3 -3
  39. package/src/fixtures/icons.json +2 -2
  40. package/src/types/typography.ts +3 -3
  41. package/www/build/mds-modal.esm.js +1 -1
  42. package/www/build/mds-modal.js +1 -1
  43. package/www/build/p-4fe02e5f.entry.js +1 -0
  44. package/www/build/{p-4288d1a7.system.entry.js → p-52cd3b82.system.entry.js} +1 -1
  45. package/www/build/p-76a04b9e.system.js +2 -0
  46. package/www/build/p-931319fa.js +2 -0
  47. package/www/build/{p-5935b9a5.system.js → p-a2cf985e.system.js} +1 -1
  48. package/dist/esm-es5/index-5dfae565.js +0 -2
  49. package/dist/mds-modal/p-19fa0f59.js +0 -2
  50. package/dist/mds-modal/p-9c47a964.system.js +0 -2
  51. package/dist/mds-modal/p-f1135a2e.entry.js +0 -1
  52. package/www/build/p-19fa0f59.js +0 -2
  53. package/www/build/p-9c47a964.system.js +0 -2
  54. package/www/build/p-f1135a2e.entry.js +0 -1
@@ -84,7 +84,7 @@
84
84
  height: 100%;
85
85
  width: 100%;
86
86
  }
87
- .animate-left,
87
+ .animate-left,
88
88
  .animate-right{
89
89
  opacity: 0;
90
90
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -137,10 +137,10 @@
137
137
  justify-content: center;
138
138
  }
139
139
 
140
- :host ( .animate-bottom-opened ),
141
- :host ( .animate-center-opened ),
142
- :host ( .animate-left-opened ),
143
- :host ( .animate-right-opened ),
140
+ :host ( .animate-bottom-opened ),
141
+ :host ( .animate-center-opened ),
142
+ :host ( .animate-left-opened ),
143
+ :host ( .animate-right-opened ),
144
144
  :host ( .animate-top-opened ){
145
145
  pointer-events: auto;
146
146
  transition-duration: 500ms;
@@ -202,7 +202,7 @@
202
202
  }
203
203
  }
204
204
 
205
- :host ( .animate-bottom ) .window,
205
+ :host ( .animate-bottom ) .window,
206
206
  :host ( .animate-bottom ) > ::slotted ( [slot=window] ){
207
207
  opacity: 0;
208
208
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -211,21 +211,21 @@
211
211
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
212
212
  }
213
213
 
214
- :host ( .animate-bottom-intro ) .window,
214
+ :host ( .animate-bottom-intro ) .window,
215
215
  :host ( .animate-bottom-intro ) > ::slotted ( [slot=window] ) {
216
216
  transform: rotateX(-22deg) scale(0.5) translateY(40%);
217
217
  }
218
218
 
219
- :host ( .animate-bottom-opened.animate-bottom-outro ) .window,
220
- :host ( .animate-bottom-opened.animate-bottom-outro ) > ::slotted ( [slot=window] ),
221
- :host ( .animate-bottom-opened ) .window,
219
+ :host ( .animate-bottom-opened.animate-bottom-outro ) .window,
220
+ :host ( .animate-bottom-opened.animate-bottom-outro ) > ::slotted ( [slot=window] ),
221
+ :host ( .animate-bottom-opened ) .window,
222
222
  :host ( .animate-bottom-opened ) > ::slotted ( [slot=window] ){
223
223
  opacity: 1;
224
224
 
225
225
  transform: rotateX(0) scale(1) translateY(0);
226
226
  }
227
227
 
228
- :host ( .animate-bottom-outro ) .window,
228
+ :host ( .animate-bottom-outro ) .window,
229
229
  :host ( .animate-bottom-outro ) > ::slotted ( [slot=window] ) {
230
230
  transform: rotateX(-22deg) scale(0.5) translateY(-40%);
231
231
  }
@@ -241,9 +241,7 @@
241
241
  }
242
242
  }
243
243
 
244
-
245
- :host ( .animate-center ) .window,
246
-
244
+ :host ( .animate-center ) .window,
247
245
  :host ( .animate-center ) > ::slotted ( [slot=window] ){
248
246
  opacity: 0;
249
247
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -252,29 +250,21 @@
252
250
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
253
251
  }
254
252
 
255
-
256
- :host ( .animate-center-intro ) .window,
257
-
253
+ :host ( .animate-center-intro ) .window,
258
254
  :host ( .animate-center-intro ) > ::slotted ( [slot=window] ) {
259
255
  transform: rotateX(-22deg) scale(0.5) translateY(40%);
260
256
  }
261
257
 
262
-
263
- :host ( .animate-center-opened.animate-center-outro ) .window,
264
-
265
- :host ( .animate-center-opened.animate-center-outro ) > ::slotted ( [slot=window] ),
266
-
267
- :host ( .animate-center-opened ) .window,
268
-
258
+ :host ( .animate-center-opened.animate-center-outro ) .window,
259
+ :host ( .animate-center-opened.animate-center-outro ) > ::slotted ( [slot=window] ),
260
+ :host ( .animate-center-opened ) .window,
269
261
  :host ( .animate-center-opened ) > ::slotted ( [slot=window] ){
270
262
  opacity: 1;
271
263
 
272
264
  transform: rotateX(0) scale(1) translateY(0);
273
265
  }
274
266
 
275
-
276
- :host ( .animate-center-outro ) .window,
277
-
267
+ :host ( .animate-center-outro ) .window,
278
268
  :host ( .animate-center-outro ) > ::slotted ( [slot=window] ) {
279
269
  transform: rotateX(-22deg) scale(0.5) translateY(-40%);
280
270
  }
@@ -283,7 +273,7 @@
283
273
  justify-content: flex-start;
284
274
  }
285
275
 
286
- :host ( .animate-left ) .window,
276
+ :host ( .animate-left ) .window,
287
277
  :host ( .animate-left ) > ::slotted ( [slot=window] ){
288
278
  opacity: 0;
289
279
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -292,34 +282,28 @@
292
282
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
293
283
  }
294
284
 
295
- :host ( .animate-left-intro ) .window,
285
+ :host ( .animate-left-intro ) .window,
296
286
  :host ( .animate-left-intro ) > ::slotted ( [slot=window] ) {
297
287
  transform: translateX(calc(-100% - 50px));
298
288
  }
299
289
 
300
-
301
- :host ( .animate-left-opened.animate-left-outro ) .window,
302
-
303
- :host ( .animate-left-opened.animate-left-outro ) > ::slotted ( [slot=window] ),
304
-
305
- :host ( .animate-left-opened ) .window,
306
-
290
+ :host ( .animate-left-opened.animate-left-outro ) .window,
291
+ :host ( .animate-left-opened.animate-left-outro ) > ::slotted ( [slot=window] ),
292
+ :host ( .animate-left-opened ) .window,
307
293
  :host ( .animate-left-opened ) > ::slotted ( [slot=window] ){
308
294
  opacity: 1;
309
295
 
310
296
  transform: translateX(0);
311
297
  }
312
298
 
313
- :host ( .animate-left-opened ) .close,
299
+ :host ( .animate-left-opened ) .close,
314
300
  :host ( .animate-left-opened.animate-left-outro ) .close{
315
301
  opacity: 1;
316
302
 
317
303
  transform: translate(-24px, 24px) rotate(0);
318
304
  }
319
305
 
320
-
321
- :host ( .animate-left-outro ) .window,
322
-
306
+ :host ( .animate-left-outro ) .window,
323
307
  :host ( .animate-left-outro ) > ::slotted ( [slot=window] ) {
324
308
  transform: translateX(calc(-100% - 50px));
325
309
  }
@@ -338,9 +322,7 @@
338
322
  justify-content: flex-end;
339
323
  }
340
324
 
341
-
342
- :host ( .animate-right ) .window,
343
-
325
+ :host ( .animate-right ) .window,
344
326
  :host ( .animate-right ) > ::slotted ( [slot=window] ){
345
327
  opacity: 0;
346
328
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -349,30 +331,28 @@
349
331
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
350
332
  }
351
333
 
352
- :host ( .animate-right-intro ) .window,
334
+ :host ( .animate-right-intro ) .window,
353
335
  :host ( .animate-right-intro ) > ::slotted ( [slot=window] ) {
354
336
  transform: translateX(calc(100% + 50px));
355
337
  }
356
338
 
357
- :host ( .animate-right-opened.animate-right-outro ) .window,
358
- :host ( .animate-right-opened.animate-right-outro ) > ::slotted ( [slot=window] ),
359
- :host ( .animate-right-opened ) .window,
339
+ :host ( .animate-right-opened.animate-right-outro ) .window,
340
+ :host ( .animate-right-opened.animate-right-outro ) > ::slotted ( [slot=window] ),
341
+ :host ( .animate-right-opened ) .window,
360
342
  :host ( .animate-right-opened ) > ::slotted ( [slot=window] ){
361
343
  opacity: 1;
362
344
 
363
345
  transform: translateX(0);
364
346
  }
365
347
 
366
- :host ( .animate-right-opened ) .close,
348
+ :host ( .animate-right-opened ) .close,
367
349
  :host ( .animate-right-opened.animate-right-outro ) .close{
368
350
  opacity: 1;
369
351
 
370
352
  transform: translate(24px, 24px) rotate(0);
371
353
  }
372
354
 
373
-
374
- :host ( .animate-right-outro ) .window,
375
-
355
+ :host ( .animate-right-outro ) .window,
376
356
  :host ( .animate-right-outro ) > ::slotted ( [slot=window] ) {
377
357
  transform: translateX(calc(100% + 50px));
378
358
  }
@@ -398,9 +378,7 @@
398
378
  }
399
379
  }
400
380
 
401
-
402
- :host ( .animate-top ) .window,
403
-
381
+ :host ( .animate-top ) .window,
404
382
  :host ( .animate-top ) > ::slotted ( [slot=window] ){
405
383
  opacity: 0;
406
384
  transition-property: background-color, border-color, box-shadow, color, fill, height, margin, opacity, padding, transform, width;
@@ -409,29 +387,21 @@
409
387
  transition-timing-function: cubic-bezier(1, 0, 0, 1);
410
388
  }
411
389
 
412
-
413
- :host ( .animate-top-intro ) .window,
414
-
390
+ :host ( .animate-top-intro ) .window,
415
391
  :host ( .animate-top-intro ) > ::slotted ( [slot=window] ) {
416
392
  transform: rotateX(-22deg) scale(0.5) translateY(40%);
417
393
  }
418
394
 
419
-
420
- :host ( .animate-top-opened.animate-top-outro ) .window,
421
-
422
- :host ( .animate-top-opened.animate-top-outro ) > ::slotted ( [slot=window] ),
423
-
424
- :host ( .animate-top-opened ) .window,
425
-
395
+ :host ( .animate-top-opened.animate-top-outro ) .window,
396
+ :host ( .animate-top-opened.animate-top-outro ) > ::slotted ( [slot=window] ),
397
+ :host ( .animate-top-opened ) .window,
426
398
  :host ( .animate-top-opened ) > ::slotted ( [slot=window] ){
427
399
  opacity: 1;
428
400
 
429
401
  transform: rotateX(0) scale(1) translateY(0);
430
402
  }
431
403
 
432
-
433
- :host ( .animate-top-outro ) .window,
434
-
404
+ :host ( .animate-top-outro ) .window,
435
405
  :host ( .animate-top-outro ) > ::slotted ( [slot=window] ) {
436
406
  transform: rotateX(-22deg) scale(0.5) translateY(-40%);
437
407
  }
@@ -7,13 +7,14 @@ export class MdsModal {
7
7
  this.top = null;
8
8
  this.bottom = null;
9
9
  this.animationState = 'intro';
10
- /**
11
- * Specifies the animation position of the modal window
12
- */
13
- this.position = null;
14
10
  this.animationName = (customState = null, customPosition = null) => {
15
11
  return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`;
16
12
  };
13
+ this.checkKeyboardEscape = (event) => {
14
+ if (event.code === 'Escape') {
15
+ this.close.emit();
16
+ }
17
+ };
17
18
  this.closeModal = (e = null) => {
18
19
  var _a;
19
20
  if (((_a = e.target) === null || _a === void 0 ? void 0 : _a.localName) !== 'mds-modal') {
@@ -24,6 +25,9 @@ export class MdsModal {
24
25
  this.close.emit();
25
26
  }
26
27
  };
28
+ this.stateOpened = undefined;
29
+ this.opened = undefined;
30
+ this.position = null;
27
31
  }
28
32
  componentWillLoad() {
29
33
  this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null;
@@ -36,6 +40,10 @@ export class MdsModal {
36
40
  if (this.position === null) {
37
41
  this.position = 'right';
38
42
  }
43
+ if (this.window) {
44
+ const modal = this.hostElement.querySelector('[slot="window"]');
45
+ modal.setAttribute('role', 'modal');
46
+ }
39
47
  }
40
48
  componentWillRender() {
41
49
  this.animationState = this.opened ? 'intro' : 'outro';
@@ -48,6 +56,14 @@ export class MdsModal {
48
56
  this.hostElement.classList.add(this.animationName(this.animationState));
49
57
  window.clearTimeout(this.animationDeelay);
50
58
  }, 500);
59
+ if (this.opened) {
60
+ this.addKeyboardEscapeListener();
61
+ return;
62
+ }
63
+ this.removeKeyboardEscapeListener();
64
+ }
65
+ disconnectedCallback() {
66
+ this.removeKeyboardEscapeListener();
51
67
  }
52
68
  positionChange(_newValue, oldValue) {
53
69
  window.clearTimeout(this.animationDeelay);
@@ -55,19 +71,30 @@ export class MdsModal {
55
71
  this.hostElement.classList.remove(this.animationName('intro', oldValue));
56
72
  this.hostElement.classList.remove(this.animationName('outro', oldValue));
57
73
  }
74
+ addKeyboardEscapeListener() {
75
+ window.addEventListener('keydown', this.checkKeyboardEscape.bind(this));
76
+ }
77
+ removeKeyboardEscapeListener() {
78
+ window.removeEventListener('keydown', this.checkKeyboardEscape.bind(this));
79
+ }
58
80
  openedChange(newValue) {
59
81
  this.stateOpened = newValue;
60
82
  window.clearTimeout(this.animationDeelay);
83
+ if (newValue) {
84
+ this.addKeyboardEscapeListener();
85
+ return;
86
+ }
87
+ this.removeKeyboardEscapeListener();
61
88
  }
62
89
  onCloseListener() {
63
90
  this.opened = false;
64
91
  }
65
92
  render() {
66
- return (h(Host, { class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
93
+ return (h(Host, { "aria-modal": clsx(this.opened ? 'true' : 'false'), class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
67
94
  ?
68
95
  h("slot", { name: "window" })
69
96
  :
70
- h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`) }, this.top &&
97
+ h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`), role: "dialog" }, this.top &&
71
98
  h("slot", { name: "top" }), h("slot", null), this.bottom &&
72
99
  h("slot", { name: "bottom" })), !this.window && h("i", { innerHTML: miBaselineClose, class: "svg close" })));
73
100
  }
@@ -1,4 +1,5 @@
1
1
  import { h } from '@stencil/core';
2
+ import { useState } from 'react';
2
3
  import { modalPositionDictionary } from '../meta/dictionary';
3
4
  export default {
4
5
  title: 'UI / Modal',
@@ -21,5 +22,12 @@ const fullName = `${firstName} ${lastName}`;
21
22
  const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@nintendo.com`;
22
23
  const Template = args => h("mds-modal", Object.assign({}, args), h("header", { slot: "top", class: "p-8 max-w-lg flex gap-4 items-center border-b border-tone-neutral-09" }, h("mds-img", { class: "w-16", src: "/logo-gruppo-maggioli-512w.webp" }), h("div", { class: "text-tone-neutral-02" }, h("mds-text", { typography: "h5", class: "truncate min-w-0" }, "Maggioli Editore"), h("mds-text", { typography: "detail", class: "truncate min-w-0" }, "Menu di servizio"))), h("div", { class: "p-8 max-w-lg" }, h("mds-text", null, "As a multi-brand design system, our components need to be flexible enough for any one of our brands to use them for multiple use cases. To achieve this, we ensure that all of the brands are involved in the specification stage, giving us more confidence that we\u2019re future-proofing our components as more brands adopt NewsKit.")), h("footer", { slot: "bottom", class: "p-8 max-w-lg flex gap-4 text-tone-neutral-02 border-t border-tone-neutral-09" }, h("mds-author", null, h("mds-avatar", { slot: "avatar", class: "w-16 mobile:w-12", src: "/avatar-01-200x200.jpeg" }), h("mds-text", { typography: "h6", class: "truncate min-w-0" }, fullName), h("mds-text", { typography: "caption", class: "text-tone-neutral-04 truncate min-w-0" }, email)), h("mds-button", { icon: "mdi/dots-vertical", class: "ml-auto bg-transparent text-tone-neutral-02 p-4 border border-tone-neutral-09 rounded-full" })));
23
24
  const CustomTemplate = args => h("mds-modal", Object.assign({}, args), h("mds-banner", { slot: "window", class: "max-w-xl mx-6", deletable: true, headline: "Action required" }, h("mds-text", { typography: "detail" }, "As a multi-brand design system, our components need to be flexible enough for any one of our brands to use them for multiple use cases. To achieve this, we ensure that all of the brands are involved in the specification stage, giving us more confidence that we\u2019re future-proofing our components as more brands adopt NewsKit."), h("mds-button", { slot: "actions", variant: "primary", tone: "quiet" }, "Cancel"), h("mds-button", { slot: "actions", variant: "primary" }, "Confirm")));
25
+ const AriaTemplate = () => {
26
+ // Click not working with reader
27
+ const [opened, setOpened] = useState(false);
28
+ window.addEventListener('close', () => { setOpened(false); });
29
+ return h("div", null, h("mds-button", { onClick: () => setOpened(true) }, "Apri modale"), h("mds-modal", { opened: opened, onClose: () => setOpened(false) }, h("mds-banner", { slot: "window", class: "max-w-xl mx-6", deletable: true, headline: "Action required" }, h("mds-text", { typography: "detail" }, "As a multi-brand design system, our components need to be flexible enough for any one of our brands to use them for multiple use cases. To achieve this, we ensure that all of the brands are involved in the specification stage, giving us more confidence that we\u2019re future-proofing our components as more brands adopt NewsKit."), h("mds-button", { slot: "actions", variant: "dark", tone: "quiet", onClick: () => setOpened(false) }, "Cancel"), h("mds-button", { slot: "actions", variant: "primary" }, "Confirm"))));
30
+ };
24
31
  export const Default = Template.bind({});
25
32
  export const CustomWindow = CustomTemplate.bind({});
33
+ export const ARIATest = AriaTemplate.bind({});
@@ -1,7 +1,7 @@
1
1
  const typographyDictionary = [
2
2
  'action',
3
3
  'caption',
4
- 'code',
4
+ 'snippet',
5
5
  'detail',
6
6
  'h1',
7
7
  'h2',
@@ -19,10 +19,10 @@ const typographyVariationsDictionary = [
19
19
  'title',
20
20
  'info',
21
21
  'read',
22
- 'mono',
22
+ 'code',
23
23
  ];
24
24
  const typographyMonoDictionary = [
25
- 'code',
25
+ 'snippet',
26
26
  'hack',
27
27
  ];
28
28
  const typographyTitleDictionary = [
@@ -16,13 +16,14 @@ const MdsModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
16
16
  this.top = null;
17
17
  this.bottom = null;
18
18
  this.animationState = 'intro';
19
- /**
20
- * Specifies the animation position of the modal window
21
- */
22
- this.position = null;
23
19
  this.animationName = (customState = null, customPosition = null) => {
24
20
  return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`;
25
21
  };
22
+ this.checkKeyboardEscape = (event) => {
23
+ if (event.code === 'Escape') {
24
+ this.close.emit();
25
+ }
26
+ };
26
27
  this.closeModal = (e = null) => {
27
28
  var _a;
28
29
  if (((_a = e.target) === null || _a === void 0 ? void 0 : _a.localName) !== 'mds-modal') {
@@ -33,6 +34,9 @@ const MdsModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
33
34
  this.close.emit();
34
35
  }
35
36
  };
37
+ this.stateOpened = undefined;
38
+ this.opened = undefined;
39
+ this.position = null;
36
40
  }
37
41
  componentWillLoad() {
38
42
  this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null;
@@ -45,6 +49,10 @@ const MdsModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
45
49
  if (this.position === null) {
46
50
  this.position = 'right';
47
51
  }
52
+ if (this.window) {
53
+ const modal = this.hostElement.querySelector('[slot="window"]');
54
+ modal.setAttribute('role', 'modal');
55
+ }
48
56
  }
49
57
  componentWillRender() {
50
58
  this.animationState = this.opened ? 'intro' : 'outro';
@@ -57,6 +65,14 @@ const MdsModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
57
65
  this.hostElement.classList.add(this.animationName(this.animationState));
58
66
  window.clearTimeout(this.animationDeelay);
59
67
  }, 500);
68
+ if (this.opened) {
69
+ this.addKeyboardEscapeListener();
70
+ return;
71
+ }
72
+ this.removeKeyboardEscapeListener();
73
+ }
74
+ disconnectedCallback() {
75
+ this.removeKeyboardEscapeListener();
60
76
  }
61
77
  positionChange(_newValue, oldValue) {
62
78
  window.clearTimeout(this.animationDeelay);
@@ -64,19 +80,30 @@ const MdsModal$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
64
80
  this.hostElement.classList.remove(this.animationName('intro', oldValue));
65
81
  this.hostElement.classList.remove(this.animationName('outro', oldValue));
66
82
  }
83
+ addKeyboardEscapeListener() {
84
+ window.addEventListener('keydown', this.checkKeyboardEscape.bind(this));
85
+ }
86
+ removeKeyboardEscapeListener() {
87
+ window.removeEventListener('keydown', this.checkKeyboardEscape.bind(this));
88
+ }
67
89
  openedChange(newValue) {
68
90
  this.stateOpened = newValue;
69
91
  window.clearTimeout(this.animationDeelay);
92
+ if (newValue) {
93
+ this.addKeyboardEscapeListener();
94
+ return;
95
+ }
96
+ this.removeKeyboardEscapeListener();
70
97
  }
71
98
  onCloseListener() {
72
99
  this.opened = false;
73
100
  }
74
101
  render() {
75
- return (h(Host, { class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
102
+ return (h(Host, { "aria-modal": clsx(this.opened ? 'true' : 'false'), class: clsx(this.stateOpened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
76
103
  ?
77
104
  h("slot", { name: "window" })
78
105
  :
79
- h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`) }, this.top &&
106
+ h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`), role: "dialog" }, this.top &&
80
107
  h("slot", { name: "top" }), h("slot", null), this.bottom &&
81
108
  h("slot", { name: "bottom" })), !this.window && h("i", { innerHTML: miBaselineClose, class: "svg close" })));
82
109
  }