@atlassian/aui 9.5.2 → 9.6.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlassian/aui",
3
3
  "description": "Atlassian User Interface library",
4
- "version": "9.5.2",
4
+ "version": "9.6.0",
5
5
  "author": "Atlassian Pty Ltd.",
6
6
  "homepage": "https://aui.atlassian.com",
7
7
  "license": "Apache-2.0",
@@ -34,29 +34,29 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@atlassian/tipsy": "1.3.3",
37
- "@popperjs/core": "2.4.4",
37
+ "@popperjs/core": "2.11.6",
38
38
  "backbone": "1.4.1",
39
39
  "css.escape": "1.5.1",
40
- "dompurify": "2.4.0",
40
+ "dompurify": "2.4.5",
41
41
  "fancy-file-input": "2.0.4",
42
42
  "jquery-ui": "1.13.2",
43
43
  "skatejs": "0.13.17",
44
44
  "skatejs-template-html": "0.0.0",
45
45
  "trim-extra-html-whitespace": "1.3.0",
46
- "underscore": "1.13.4"
46
+ "underscore": "1.13.6"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@atlassian/adg-server-iconfont": "3.1.0",
50
50
  "@atlassian/aui-webpack-config": "3.0.1",
51
- "@babel/core": "7.18.6",
52
- "@babel/preset-env": "7.18.6",
51
+ "@babel/core": "7.18.13",
52
+ "@babel/preset-env": "7.18.10",
53
53
  "bundlesize": "1.0.0-beta.2",
54
54
  "cross-env": "7.0.3",
55
55
  "eslint": "7.32.0",
56
56
  "glob": "7.2.3",
57
57
  "ignore-emit-webpack-plugin": "2.0.6",
58
58
  "jquery": "3.5.1",
59
- "jquery-migrate": "3.4.0",
59
+ "jquery-migrate": "3.4.1",
60
60
  "less": "3.13.1"
61
61
  },
62
62
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
2
+ Version: 3.5.4 Timestamp: Sun Aug 30 13:30:32 EDT 2015
3
3
  */
4
4
  .select2-container {
5
5
  margin: 0;
@@ -15,7 +15,6 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
15
15
  /*
16
16
  Force border-box so that % widths fit the parent
17
17
  container without overlap because of margin/padding.
18
-
19
18
  More Info : http://www.quirksmode.org/css/box.html
20
19
  */
21
20
  -webkit-box-sizing: border-box; /* webkit */
@@ -51,7 +50,11 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
51
50
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
52
51
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
53
52
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
54
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
53
+ background-image: linear-gradient(to top, #eee 0%, #fff 50%);
54
+ }
55
+
56
+ html[dir="rtl"] .select2-container .select2-choice {
57
+ padding: 0 8px 0 0;
55
58
  }
56
59
 
57
60
  .select2-container.select2-drop-above .select2-choice {
@@ -63,7 +66,7 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
63
66
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
64
67
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
65
68
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
66
- background-image: linear-gradient(top, #eee 0%, #fff 90%);
69
+ background-image: linear-gradient(to bottom, #eee 0%, #fff 90%);
67
70
  }
68
71
 
69
72
  .select2-container.select2-allowclear .select2-choice .select2-chosen {
@@ -78,6 +81,13 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
78
81
  white-space: nowrap;
79
82
 
80
83
  text-overflow: ellipsis;
84
+ float: none;
85
+ width: auto;
86
+ }
87
+
88
+ html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
89
+ margin-left: 26px;
90
+ margin-right: 0;
81
91
  }
82
92
 
83
93
  .select2-container .select2-choice abbr {
@@ -142,15 +152,6 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
142
152
  box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
143
153
  }
144
154
 
145
- .select2-drop-auto-width {
146
- border-top: 1px solid #aaa;
147
- width: auto;
148
- }
149
-
150
- .select2-drop-auto-width .select2-search {
151
- padding-top: 4px;
152
- }
153
-
154
155
  .select2-drop.select2-drop-above {
155
156
  margin-top: 1px;
156
157
  border-top: 1px solid #aaa;
@@ -171,6 +172,11 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
171
172
  border-top: 1px solid #5897fb;
172
173
  }
173
174
 
175
+ .select2-drop-auto-width {
176
+ border-top: 1px solid #aaa;
177
+ width: auto;
178
+ }
179
+
174
180
  .select2-container .select2-choice .select2-arrow {
175
181
  display: inline-block;
176
182
  width: 18px;
@@ -189,7 +195,16 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
189
195
  background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
190
196
  background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
191
197
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
192
- background-image: linear-gradient(top, #ccc 0%, #eee 60%);
198
+ background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
199
+ }
200
+
201
+ html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
202
+ left: 0;
203
+ right: auto;
204
+
205
+ border-left: none;
206
+ border-right: 1px solid #aaa;
207
+ border-radius: 4px 0 0 4px;
193
208
  }
194
209
 
195
210
  .select2-container .select2-choice .select2-arrow b {
@@ -199,13 +214,16 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
199
214
  background: url('select2.png') no-repeat 0 1px;
200
215
  }
201
216
 
217
+ html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
218
+ background-position: 2px 1px;
219
+ }
220
+
202
221
  .select2-search {
203
222
  display: inline-block;
204
223
  width: 100%;
205
224
  min-height: 26px;
206
225
  margin: 0;
207
- padding-left: 4px;
208
- padding-right: 4px;
226
+ padding: 4px 4px 0 4px;
209
227
 
210
228
  position: relative;
211
229
  z-index: 10000;
@@ -234,11 +252,17 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
234
252
  background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
235
253
  background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
236
254
  background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
237
- background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
255
+ background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
238
256
  }
239
257
 
240
- .select2-drop.select2-drop-above .select2-search input {
241
- margin-top: 4px;
258
+ html[dir="rtl"] .select2-search input {
259
+ padding: 4px 5px 4px 20px;
260
+
261
+ background: #fff url('select2.png') no-repeat -37px -22px;
262
+ background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
263
+ background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
264
+ background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
265
+ background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
242
266
  }
243
267
 
244
268
  .select2-search input.select2-active {
@@ -246,7 +270,7 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
246
270
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
247
271
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
248
272
  background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
249
- background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
273
+ background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
250
274
  }
251
275
 
252
276
  .select2-container-active .select2-choice,
@@ -271,7 +295,7 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
271
295
  background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
272
296
  background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
273
297
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
274
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
298
+ background-image: linear-gradient(to top, #fff 0%, #eee 50%);
275
299
  }
276
300
 
277
301
  .select2-dropdown-open.select2-drop-above .select2-choice,
@@ -283,7 +307,7 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
283
307
  background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
284
308
  background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
285
309
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
286
- background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
310
+ background-image: linear-gradient(to bottom, #fff 0%, #eee 50%);
287
311
  }
288
312
 
289
313
  .select2-dropdown-open .select2-choice .select2-arrow {
@@ -291,10 +315,29 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
291
315
  border-left: none;
292
316
  filter: none;
293
317
  }
318
+ html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
319
+ border-right: none;
320
+ }
321
+
294
322
  .select2-dropdown-open .select2-choice .select2-arrow b {
295
323
  background-position: -18px 1px;
296
324
  }
297
325
 
326
+ html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
327
+ background-position: -16px 1px;
328
+ }
329
+
330
+ .select2-hidden-accessible {
331
+ border: 0;
332
+ clip: rect(0 0 0 0);
333
+ height: 1px;
334
+ margin: -1px;
335
+ overflow: hidden;
336
+ padding: 0;
337
+ position: absolute;
338
+ width: 1px;
339
+ }
340
+
298
341
  /* results */
299
342
  .select2-results {
300
343
  max-height: 200px;
@@ -306,19 +349,16 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
306
349
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
307
350
  }
308
351
 
352
+ html[dir="rtl"] .select2-results {
353
+ padding: 0 4px 0 0;
354
+ margin: 4px 0 4px 4px;
355
+ }
356
+
309
357
  .select2-results ul.select2-result-sub {
310
358
  margin: 0;
311
359
  padding-left: 0;
312
360
  }
313
361
 
314
- .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
315
- .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
316
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
317
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
318
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
319
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
320
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
321
-
322
362
  .select2-results li {
323
363
  list-style: none;
324
364
  display: list-item;
@@ -343,6 +383,14 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
343
383
  user-select: none;
344
384
  }
345
385
 
386
+ .select2-results-dept-1 .select2-result-label { padding-left: 20px }
387
+ .select2-results-dept-2 .select2-result-label { padding-left: 40px }
388
+ .select2-results-dept-3 .select2-result-label { padding-left: 60px }
389
+ .select2-results-dept-4 .select2-result-label { padding-left: 80px }
390
+ .select2-results-dept-5 .select2-result-label { padding-left: 100px }
391
+ .select2-results-dept-6 .select2-result-label { padding-left: 110px }
392
+ .select2-results-dept-7 .select2-result-label { padding-left: 120px }
393
+
346
394
  .select2-results .select2-highlighted {
347
395
  background: #3875d7;
348
396
  color: #fff;
@@ -362,12 +410,13 @@ Version: 3.4.4 Timestamp: Thu Oct 24 13:23:11 PDT 2013
362
410
  color: #000;
363
411
  }
364
412
 
365
-
366
413
  .select2-results .select2-no-results,
367
414
  .select2-results .select2-searching,
415
+ .select2-results .select2-ajax-error,
368
416
  .select2-results .select2-selection-limit {
369
417
  background: #f4f4f4;
370
418
  display: list-item;
419
+ padding-left: 5px;
371
420
  }
372
421
 
373
422
  /*
@@ -393,6 +442,10 @@ disabled look for disabled choices in the results dropdown
393
442
  background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
394
443
  }
395
444
 
445
+ .select2-results .select2-ajax-error {
446
+ background: rgba(255, 50, 50, .2);
447
+ }
448
+
396
449
  .select2-more-results {
397
450
  background: #f4f4f4;
398
451
  display: list-item;
@@ -424,7 +477,7 @@ disabled look for disabled choices in the results dropdown
424
477
  height: auto !important;
425
478
  height: 1%;
426
479
  margin: 0;
427
- padding: 0;
480
+ padding: 0 5px 0 0;
428
481
  position: relative;
429
482
 
430
483
  border: 1px solid #aaa;
@@ -435,7 +488,11 @@ disabled look for disabled choices in the results dropdown
435
488
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
436
489
  background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
437
490
  background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
438
- background-image: linear-gradient(top, #eee 1%, #fff 15%);
491
+ background-image: linear-gradient(to bottom, #eee 1%, #fff 15%);
492
+ }
493
+
494
+ html[dir="rtl"] .select2-container-multi .select2-choices {
495
+ padding: 0 0 0 5px;
439
496
  }
440
497
 
441
498
  .select2-locked {
@@ -457,6 +514,10 @@ disabled look for disabled choices in the results dropdown
457
514
  float: left;
458
515
  list-style: none;
459
516
  }
517
+ html[dir="rtl"] .select2-container-multi .select2-choices li
518
+ {
519
+ float: right;
520
+ }
460
521
  .select2-container-multi .select2-choices .select2-search-field {
461
522
  margin: 0;
462
523
  padding: 0;
@@ -513,7 +574,12 @@ disabled look for disabled choices in the results dropdown
513
574
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
514
575
  background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
515
576
  background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
516
- background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
577
+ background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
578
+ }
579
+ html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
580
+ {
581
+ margin: 3px 5px 3px 0;
582
+ padding: 3px 18px 3px 5px;
517
583
  }
518
584
  .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
519
585
  cursor: default;
@@ -534,11 +600,20 @@ disabled look for disabled choices in the results dropdown
534
600
  outline: none;
535
601
  background: url('select2.png') right top no-repeat;
536
602
  }
603
+ html[dir="rtl"] .select2-search-choice-close {
604
+ right: auto;
605
+ left: 3px;
606
+ }
537
607
 
538
608
  .select2-container-multi .select2-search-choice-close {
539
609
  left: 3px;
540
610
  }
541
611
 
612
+ html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
613
+ left: auto;
614
+ right: 2px;
615
+ }
616
+
542
617
  .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
543
618
  background-position: right -11px;
544
619
  }
@@ -598,15 +673,20 @@ disabled look for disabled choices in the results dropdown
598
673
  height: 100px;
599
674
  overflow: scroll;
600
675
  }
676
+
601
677
  /* Retina-ize icons */
602
678
 
603
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
604
- .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
605
- background-image: url('select2x2.png') !important;
606
- background-repeat: no-repeat !important;
607
- background-size: 60px 40px !important;
608
- }
609
- .select2-search input {
610
- background-position: 100% -21px !important;
611
- }
679
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
680
+ .select2-search input,
681
+ .select2-search-choice-close,
682
+ .select2-container .select2-choice abbr,
683
+ .select2-container .select2-choice .select2-arrow b {
684
+ background-image: url('select2x2.png') !important;
685
+ background-repeat: no-repeat !important;
686
+ background-size: 60px 40px !important;
687
+ }
688
+
689
+ .select2-search input {
690
+ background-position: 100% -21px !important;
691
+ }
612
692
  }
@@ -4,7 +4,18 @@ import { recomputeStyle } from './internal/animation';
4
4
  import globalize from './internal/globalize';
5
5
 
6
6
  var overflowEl;
7
- var _hiddenByAui = [];
7
+
8
+ /**
9
+ * Blanketing is pattern for hiding all page content from user when overlapping layer is open.
10
+ *
11
+ * This pattern is old and should be removed, but it has a lot of dependants:
12
+ * - Layer, LayerManager
13
+ * - Dialog2, Dialog1
14
+ * - Dropdown2
15
+ * - InlineDialog2
16
+ *
17
+ * Removal should be done as separate process with usage research and go through deprecation.
18
+ */
8
19
 
9
20
  /**
10
21
  * Dims the screen using a blanket div
@@ -13,21 +24,14 @@ var _hiddenByAui = [];
13
24
  function dim (useShim, zIndex) {
14
25
 
15
26
  //if we're blanketing the page it means we want to hide the whatever is under the blanket from the screen readers as well
16
- function hasAriaHidden(element) {
27
+ function hasAriaHidden(element) { // eslint-disable-line no-unused-vars
17
28
  return element.hasAttribute('aria-hidden');
18
29
  }
19
30
 
20
- function isAuiLayer(element) {
31
+ function isAuiLayer(element) { // eslint-disable-line no-unused-vars
21
32
  return element.classList && element.classList.contains('aui-layer');
22
33
  }
23
34
 
24
- Array.prototype.forEach.call(document.body.children, function (element) {
25
- if (!hasAriaHidden(element) && !isAuiLayer(element)) {
26
- element.setAttribute('aria-hidden', 'true');
27
- _hiddenByAui.push(element);
28
- }
29
- });
30
-
31
35
  if (!overflowEl) {
32
36
  overflowEl = document.body;
33
37
  }
@@ -36,7 +40,7 @@ function dim (useShim, zIndex) {
36
40
  useShimDeprecationLogger();
37
41
  }
38
42
 
39
- var isBlanketShowing = (!!dim.$dim) && !dim.$dim[0].hasAttribute('hidden');
43
+ const isBlanketShowing = (!!dim.$dim) && !dim.$dim[0].hasAttribute('hidden');
40
44
 
41
45
  if (!!dim.$dim) {
42
46
  dim.$dim.remove();
@@ -44,7 +48,6 @@ function dim (useShim, zIndex) {
44
48
  }
45
49
 
46
50
  dim.$dim = $('<div aria-hidden="true"></div>').addClass('aui-blanket');
47
- dim.$dim.attr('tabindex', '0'); //required, or the last element's focusout event will go to the browser
48
51
  dim.$dim.appendTo(document.body);
49
52
 
50
53
  if (!isBlanketShowing) {
@@ -77,11 +80,6 @@ function dim (useShim, zIndex) {
77
80
  * @see dim
78
81
  */
79
82
  function undim () {
80
- _hiddenByAui.forEach(function (element) {
81
- element.removeAttribute('aria-hidden');
82
- });
83
-
84
- _hiddenByAui = [];
85
83
 
86
84
  if (dim.$dim) {
87
85
  dim.$dim[0].setAttribute('hidden', '');
@@ -94,7 +92,7 @@ function undim () {
94
92
  }
95
93
  }
96
94
 
97
- var useShimDeprecationLogger = getMessageLogger('useShim', {
95
+ const useShimDeprecationLogger = getMessageLogger('useShim', {
98
96
  extraInfo: 'useShim has no alternative as it is now calculated by dim().'
99
97
  });
100
98
 
@@ -4,29 +4,120 @@ import globalize from './internal/globalize';
4
4
  import layerWidget from './layer';
5
5
  import widget from './internal/widget';
6
6
  import keyCode from './key-code';
7
- import {CLOSE_BUTTON, CLOSE_BUTTON_CLASS_SELECTOR} from './close-button';
7
+ import { CLOSE_BUTTON, CLOSE_BUTTON_CLASS, CLOSE_BUTTON_CLASS_SELECTOR } from './close-button';
8
+ import * as deprecate from './internal/deprecation';
8
9
 
9
- var defaults = {
10
+ const defaults = {
10
11
  'aui-focus': 'false', // do not focus by default as it's overridden below
11
12
  'aui-blanketed': 'true'
12
13
  };
13
14
 
14
15
  function applyDefaults($el) {
15
16
  $.each(defaults, function (key, value) {
16
- var dataKey = 'data-' + key;
17
+ const dataKey = 'data-' + key;
17
18
  if (!$el[0].hasAttribute(dataKey)) {
18
19
  $el.attr(dataKey, value);
19
20
  }
20
21
  });
21
22
  }
22
23
 
24
+ /**
25
+ * Gets keyboard-focusable elements within a specified element
26
+ * https://zellwk.com/blog/keyboard-focusable-elements/
27
+ * @param {HTMLElement} [element=document] element
28
+ * @returns {Array}
29
+ */
30
+ function getKeyboardFocusableElements(element) {
31
+ const focusableSelector = 'a[href], button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])';
32
+ const elementList = [...element.querySelectorAll(focusableSelector)];
33
+
34
+ return elementList.filter(el => !el.hasAttribute('disabled') && !el.getAttribute('aria-hidden'));
35
+ }
36
+
37
+ function handleInitialFocus(el) {
38
+
39
+ // prevent inability to focus the close button.
40
+ const closeButton = el.querySelector(CLOSE_BUTTON_CLASS_SELECTOR)
41
+
42
+ if (closeButton) {
43
+ const lazyDeprecate = deprecate.getMessageLogger(`Dialog2 [${CLOSE_BUTTON_CLASS_SELECTOR}] element is deprecated.`, {
44
+ removeInVersion: '10.0.0',
45
+ sinceVersion: '9.6.0',
46
+ extraInfo: 'Replace it with another actionable element inside your Dialog which will trigger closing of the modal.',
47
+ deprecationType: 'MARKUP'
48
+ });
49
+ lazyDeprecate();
50
+ closeButton.setAttribute('tabindex', '0');
51
+ }
52
+
53
+ el.setAttribute('tabindex', '-1');
54
+
55
+ // Print deprecation note for old custom focus selection if found
56
+ const deprecatedFocusSelector = el.hasAttribute('data-aui-focus-selector');
57
+ if (deprecatedFocusSelector) {
58
+ const lazyDeprecate = deprecate.getMessageLogger('Dialog2 [data-aui-focus-selector] attribute is deprecated.', {
59
+ removeInVersion: '10.0.0',
60
+ alternativeName: 'initialisation on DOM insertion',
61
+ sinceVersion: '9.6.0',
62
+ extraInfo: 'Replace [data-aui-focus-selector] attribute with HTML [autofocus] attribute',
63
+ deprecationType: 'ATTRIBUTE'
64
+ });
65
+ lazyDeprecate();
66
+ }
67
+
68
+ // Focus custom element user marked by autofocus if found
69
+ const autofocusEl = el.querySelector('[autofocus]');
70
+ if (autofocusEl) {
71
+ // Set timeout and blur are needed to avoid Chrome complaining about focus already set on an element
72
+ // Also helps to ensure focus will 100% work in every environment
73
+ document.activeElement.blur();
74
+ setTimeout(() => autofocusEl.focus(), 0);
75
+ return;
76
+ }
77
+
78
+ // Deprecated focus selection, if autofocus not found
79
+ if (deprecatedFocusSelector) {
80
+ const elementToFocus = el.querySelector(deprecatedFocusSelector);
81
+ if (elementToFocus) {// Set timeout and blur are needed to avoid Chrome complaining about focus already set on an element
82
+ // Also helps to ensure focus will 100% work in every environment
83
+ elementToFocus.blur();
84
+ setTimeout(() => elementToFocus.focus(), 0);
85
+ return
86
+ }
87
+ }
88
+
89
+ // If not custom focus target, focus first focusable element if possible
90
+ const focusableElementList = getKeyboardFocusableElements(el);
91
+ if (focusableElementList.length) {
92
+ let focusableElement = focusableElementList.shift();
93
+
94
+ // if the first focusable element is Dialog's close button
95
+ // then take another one from the list
96
+ if (focusableElement.classList.contains(CLOSE_BUTTON_CLASS)) {
97
+ focusableElement = focusableElementList.shift();
98
+ }
99
+
100
+ if (focusableElement) {
101
+ // Set timeout and blur are needed to avoid Chrome complaining about focus already set on an element
102
+ // Also helps to ensure focus will 100% work in every environment
103
+ focusableElement.blur();
104
+ setTimeout(() => focusableElement.focus(), 0);
105
+ }
106
+
107
+ return;
108
+ }
109
+
110
+ // If no focusable elements found, put focus on dialog container itself
111
+ el.focus();
112
+ }
113
+
23
114
  function Dialog2(selector) {
24
115
  this._handlers = new WeakMap();
25
116
  if (selector) {
26
117
  this.$el = $(selector);
27
118
  } else {
28
119
  this.$el = $(`
29
- <section role="dialog" class="aui-layer aui-dialog2 aui-dialog2-medium">
120
+ <section role="dialog" aria-modal="true" class="aui-layer aui-dialog2 aui-dialog2-medium">
30
121
  <header class="aui-dialog2-header">
31
122
  <h2 class="aui-dialog2-header-main"></h2>
32
123
  ${CLOSE_BUTTON}
@@ -113,24 +204,11 @@ $(document).on('click keydown', `.aui-dialog2-header ${CLOSE_BUTTON_CLASS_SELECT
113
204
  });
114
205
 
115
206
  dialog2Widget.on('show', function (e, $el) {
116
- // prevent inability to focus the close button.
117
- $el.find(CLOSE_BUTTON_CLASS_SELECTOR).attr('tabindex', 0);
118
- $el.attr('tabindex', -1);
119
- // find appropriate content to focus, in order of importance of the content.
120
- var focusSelector = $el[0].hasAttribute('data-aui-focus-selector') && $el.attr('data-aui-focus-selector');
121
- if (focusSelector) {
122
- var $elementToFocus = $el.find(focusSelector);
123
- if ($elementToFocus.length > 0) {
124
- return $elementToFocus.first().focus();
125
- }
126
- }
127
-
128
- // focus the dialog element itself #a11y #FEP-607
129
- $el.focus();
207
+ handleInitialFocus($el[0]);
130
208
  });
131
209
 
132
210
  dialog2Widget.on('hide', function (e,$el) {
133
- var layer = layerWidget($el);
211
+ const layer = layerWidget($el);
134
212
 
135
213
  if ($el.data('aui-remove-on-hide')) {
136
214
  layer.remove();