@ministryofjustice/frontend 5.1.0 → 5.1.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.
- package/moj/all.bundle.js +52 -3
- package/moj/all.bundle.js.map +1 -1
- package/moj/all.bundle.mjs +52 -3
- package/moj/all.bundle.mjs.map +1 -1
- package/moj/common/moj-frontend-version.mjs +1 -1
- package/moj/components/sortable-table/_sortable-table.scss +3 -42
- package/moj/components/sortable-table/_sortable-table.scss.map +1 -1
- package/moj/components/sortable-table/sortable-table.bundle.js +51 -2
- package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -1
- package/moj/components/sortable-table/sortable-table.bundle.mjs +51 -2
- package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -1
- package/moj/components/sortable-table/sortable-table.mjs +51 -2
- package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
- package/moj/core/_moj-frontend-properties.scss +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.bundle.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* {@link https://github.com/ministryofjustice/moj-frontend/releases}
|
|
16
16
|
*/
|
|
17
|
-
const version = '5.1.
|
|
17
|
+
const version = '5.1.1';
|
|
18
18
|
|
|
19
19
|
class AddAnother extends govukFrontend.Component {
|
|
20
20
|
/**
|
|
@@ -2799,8 +2799,21 @@
|
|
|
2799
2799
|
}
|
|
2800
2800
|
this.$head = $head;
|
|
2801
2801
|
this.$body = $body;
|
|
2802
|
+
this.$caption = this.$root.querySelector('caption');
|
|
2803
|
+
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">
|
|
2804
|
+
<path d="M6.5625 15.5L11 6.63125L15.4375 15.5H6.5625Z" fill="currentColor"/>
|
|
2805
|
+
</svg>`;
|
|
2806
|
+
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">
|
|
2807
|
+
<path d="M15.4375 7L11 15.8687L6.5625 7L15.4375 7Z" fill="currentColor"/>
|
|
2808
|
+
</svg>`;
|
|
2809
|
+
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">
|
|
2810
|
+
<path d="M8.1875 9.5L10.9609 3.95703L13.7344 9.5H8.1875Z" fill="currentColor"/>
|
|
2811
|
+
<path d="M13.7344 12.0781L10.9609 17.6211L8.1875 12.0781H13.7344Z" fill="currentColor"/>
|
|
2812
|
+
</svg>`;
|
|
2802
2813
|
this.$headings = this.$head ? Array.from(this.$head.querySelectorAll('th')) : [];
|
|
2803
2814
|
this.createHeadingButtons();
|
|
2815
|
+
this.updateCaption();
|
|
2816
|
+
this.updateDirectionIndicators();
|
|
2804
2817
|
this.createStatusBox();
|
|
2805
2818
|
this.initialiseSortedColumn();
|
|
2806
2819
|
this.$head.addEventListener('click', this.onSortButtonClick.bind(this));
|
|
@@ -2836,7 +2849,7 @@
|
|
|
2836
2849
|
initialiseSortedColumn() {
|
|
2837
2850
|
var _$sortButton$getAttri;
|
|
2838
2851
|
const $rows = this.getTableRowsArray();
|
|
2839
|
-
const $heading = this.$root.querySelector('th[aria-sort]');
|
|
2852
|
+
const $heading = this.$root.querySelector('th[aria-sort="ascending"], th[aria-sort="descending"]');
|
|
2840
2853
|
const $sortButton = $heading == null ? void 0 : $heading.querySelector('button');
|
|
2841
2854
|
const sortDirection = $heading == null ? void 0 : $heading.getAttribute('aria-sort');
|
|
2842
2855
|
const columnNumber = Number.parseInt((_$sortButton$getAttri = $sortButton == null ? void 0 : $sortButton.getAttribute('data-index')) != null ? _$sortButton$getAttri : '0', 10);
|
|
@@ -2852,7 +2865,8 @@
|
|
|
2852
2865
|
*/
|
|
2853
2866
|
onSortButtonClick(event) {
|
|
2854
2867
|
var _$button$getAttribute;
|
|
2855
|
-
const $
|
|
2868
|
+
const $target = /** @type {HTMLElement} */event.target;
|
|
2869
|
+
const $button = $target.closest('button');
|
|
2856
2870
|
if (!$button || !($button instanceof HTMLButtonElement) || !$button.parentElement) {
|
|
2857
2871
|
return;
|
|
2858
2872
|
}
|
|
@@ -2865,6 +2879,20 @@
|
|
|
2865
2879
|
this.addRows($sortedRows);
|
|
2866
2880
|
this.removeButtonStates();
|
|
2867
2881
|
this.updateButtonState($button, newSortDirection);
|
|
2882
|
+
this.updateDirectionIndicators();
|
|
2883
|
+
}
|
|
2884
|
+
updateCaption() {
|
|
2885
|
+
if (!this.$caption) {
|
|
2886
|
+
return;
|
|
2887
|
+
}
|
|
2888
|
+
let assistiveText = this.$caption.querySelector('.govuk-visually-hidden');
|
|
2889
|
+
if (assistiveText) {
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
assistiveText = document.createElement('span');
|
|
2893
|
+
assistiveText.classList.add('govuk-visually-hidden');
|
|
2894
|
+
assistiveText.textContent = ' (column headers with buttons are sortable).';
|
|
2895
|
+
this.$caption.appendChild(assistiveText);
|
|
2868
2896
|
}
|
|
2869
2897
|
|
|
2870
2898
|
/**
|
|
@@ -2881,6 +2909,27 @@
|
|
|
2881
2909
|
message = message.replace(/%direction%/, this.config[`${direction}Text`]);
|
|
2882
2910
|
this.$status.textContent = message;
|
|
2883
2911
|
}
|
|
2912
|
+
updateDirectionIndicators() {
|
|
2913
|
+
for (const $heading of this.$headings) {
|
|
2914
|
+
const $button = /** @type {HTMLButtonElement} */
|
|
2915
|
+
$heading.querySelector('button');
|
|
2916
|
+
if ($heading.hasAttribute('aria-sort') && $button) {
|
|
2917
|
+
var _$button$querySelecto;
|
|
2918
|
+
const direction = $heading.getAttribute('aria-sort');
|
|
2919
|
+
(_$button$querySelecto = $button.querySelector('svg')) == null || _$button$querySelecto.remove();
|
|
2920
|
+
switch (direction) {
|
|
2921
|
+
case 'ascending':
|
|
2922
|
+
$button.insertAdjacentHTML('beforeend', this.$upArrow);
|
|
2923
|
+
break;
|
|
2924
|
+
case 'descending':
|
|
2925
|
+
$button.insertAdjacentHTML('beforeend', this.$downArrow);
|
|
2926
|
+
break;
|
|
2927
|
+
default:
|
|
2928
|
+
$button.insertAdjacentHTML('beforeend', this.$upDownArrow);
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2884
2933
|
removeButtonStates() {
|
|
2885
2934
|
for (const $heading of this.$headings) {
|
|
2886
2935
|
$heading.setAttribute('aria-sort', 'none');
|