@ministryofjustice/frontend 4.0.1 → 4.0.2
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/moj/all.jquery.min.js +1 -1
- package/moj/all.jquery.min.js.map +1 -1
- package/moj/all.js +58 -3
- package/moj/all.js.map +1 -1
- package/moj/components/sortable-table/_sortable-table.scss +3 -42
- package/moj/components/sortable-table/sortable-table.js +57 -2
- package/moj/components/sortable-table/sortable-table.js.map +1 -1
- package/moj/components/sortable-table/sortable-table.mjs +57 -2
- package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
- package/moj/moj-frontend.min.css +1 -1
- package/moj/moj-frontend.min.css.map +1 -1
- package/moj/moj-frontend.min.js +1 -1
- package/moj/moj-frontend.min.js.map +1 -1
- package/package.json +1 -1
package/moj/all.js
CHANGED
|
@@ -2402,10 +2402,24 @@
|
|
|
2402
2402
|
}
|
|
2403
2403
|
|
|
2404
2404
|
this.table.data('moj-search-toggle-initialised', true);
|
|
2405
|
+
this.caption = this.table.find('caption');
|
|
2406
|
+
|
|
2407
|
+
this.upArrow = `<svg width="22" height="22" focusable="false" aria-hidden="true" role="img" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2408
|
+
<path d="M6.5625 15.5L11 6.63125L15.4375 15.5H6.5625Z" fill="currentColor"/>
|
|
2409
|
+
</svg>`;
|
|
2410
|
+
this.downArrow = `<svg width="22" height="22" focusable="false" aria-hidden="true" role="img" vviewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2411
|
+
<path d="M15.4375 7L11 15.8687L6.5625 7L15.4375 7Z" fill="currentColor"/>
|
|
2412
|
+
</svg>`;
|
|
2413
|
+
this.upDownArrow = `<svg width="22" height="22" focusable="false" aria-hidden="true" role="img" vviewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2414
|
+
<path d="M8.1875 9.5L10.9609 3.95703L13.7344 9.5H8.1875Z" fill="currentColor"/>
|
|
2415
|
+
<path d="M13.7344 12.0781L10.9609 17.6211L8.1875 12.0781H13.7344Z" fill="currentColor"/>
|
|
2416
|
+
</svg>`;
|
|
2405
2417
|
|
|
2406
2418
|
this.setupOptions(params);
|
|
2407
2419
|
this.body = this.table.find('tbody');
|
|
2408
2420
|
this.createHeadingButtons();
|
|
2421
|
+
this.updateCaption();
|
|
2422
|
+
this.updateDirectionIndicators();
|
|
2409
2423
|
this.createStatusBox();
|
|
2410
2424
|
this.initialiseSortedColumn();
|
|
2411
2425
|
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
@@ -2459,8 +2473,9 @@
|
|
|
2459
2473
|
};
|
|
2460
2474
|
|
|
2461
2475
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
2462
|
-
const
|
|
2463
|
-
const
|
|
2476
|
+
const button = e.target.closest('button');
|
|
2477
|
+
const columnNumber = button.getAttribute('data-index');
|
|
2478
|
+
const sortDirection = $(button).parent().attr('aria-sort');
|
|
2464
2479
|
let newSortDirection;
|
|
2465
2480
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
2466
2481
|
newSortDirection = 'ascending';
|
|
@@ -2472,6 +2487,26 @@
|
|
|
2472
2487
|
this.addRows(sortedRows);
|
|
2473
2488
|
this.removeButtonStates();
|
|
2474
2489
|
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
2490
|
+
this.updateDirectionIndicators();
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
SortableTable.prototype.updateCaption = function () {
|
|
2494
|
+
const captionElement = this.caption.get(0);
|
|
2495
|
+
|
|
2496
|
+
if (!captionElement) {
|
|
2497
|
+
return
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
let assistiveText = captionElement.querySelector('.govuk-visually-hidden');
|
|
2501
|
+
if (assistiveText) {
|
|
2502
|
+
return
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
assistiveText = document.createElement('span');
|
|
2506
|
+
assistiveText.classList.add('govuk-visually-hidden');
|
|
2507
|
+
assistiveText.textContent = ' (column headers with buttons are sortable).';
|
|
2508
|
+
|
|
2509
|
+
captionElement.appendChild(assistiveText);
|
|
2475
2510
|
};
|
|
2476
2511
|
|
|
2477
2512
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -2482,6 +2517,26 @@
|
|
|
2482
2517
|
this.status.text(message);
|
|
2483
2518
|
};
|
|
2484
2519
|
|
|
2520
|
+
SortableTable.prototype.updateDirectionIndicators = function () {
|
|
2521
|
+
const component = this;
|
|
2522
|
+
this.table.find('th').each(function () {
|
|
2523
|
+
const heading = $(this);
|
|
2524
|
+
const button = heading.find('button');
|
|
2525
|
+
const direction = heading.attr('aria-sort');
|
|
2526
|
+
button.find('svg').remove();
|
|
2527
|
+
switch (direction) {
|
|
2528
|
+
case 'ascending':
|
|
2529
|
+
button.append(component.upArrow);
|
|
2530
|
+
break
|
|
2531
|
+
case 'descending':
|
|
2532
|
+
button.append(component.downArrow);
|
|
2533
|
+
break
|
|
2534
|
+
case 'none':
|
|
2535
|
+
button.append(component.upDownArrow);
|
|
2536
|
+
}
|
|
2537
|
+
});
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2485
2540
|
SortableTable.prototype.removeButtonStates = function () {
|
|
2486
2541
|
this.table.find('thead th').attr('aria-sort', 'none');
|
|
2487
2542
|
};
|
|
@@ -2531,7 +2586,7 @@
|
|
|
2531
2586
|
return isNaN(valAsNumber) ? val : valAsNumber
|
|
2532
2587
|
};
|
|
2533
2588
|
|
|
2534
|
-
const version = '4.0.
|
|
2589
|
+
const version = '4.0.2';
|
|
2535
2590
|
|
|
2536
2591
|
/* eslint-disable no-new */
|
|
2537
2592
|
|