@ministryofjustice/frontend 5.0.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.
Files changed (114) hide show
  1. package/moj/all.bundle.js +1598 -1062
  2. package/moj/all.bundle.js.map +1 -1
  3. package/moj/all.bundle.mjs +1894 -1054
  4. package/moj/all.bundle.mjs.map +1 -1
  5. package/moj/all.mjs +7 -90
  6. package/moj/all.mjs.map +1 -1
  7. package/moj/all.scss +1 -0
  8. package/moj/all.scss.map +1 -1
  9. package/moj/common/index.mjs +57 -0
  10. package/moj/common/index.mjs.map +1 -0
  11. package/moj/common/moj-frontend-version.mjs +14 -0
  12. package/moj/common/moj-frontend-version.mjs.map +1 -0
  13. package/moj/components/add-another/add-another.bundle.js +105 -76
  14. package/moj/components/add-another/add-another.bundle.js.map +1 -1
  15. package/moj/components/add-another/add-another.bundle.mjs +222 -71
  16. package/moj/components/add-another/add-another.bundle.mjs.map +1 -1
  17. package/moj/components/add-another/add-another.mjs +103 -72
  18. package/moj/components/add-another/add-another.mjs.map +1 -1
  19. package/moj/components/alert/alert.bundle.js +115 -191
  20. package/moj/components/alert/alert.bundle.js.map +1 -1
  21. package/moj/components/alert/alert.bundle.mjs +354 -186
  22. package/moj/components/alert/alert.bundle.mjs.map +1 -1
  23. package/moj/components/alert/alert.mjs +55 -140
  24. package/moj/components/alert/alert.mjs.map +1 -1
  25. package/moj/components/button-menu/README.md +3 -1
  26. package/moj/components/button-menu/button-menu.bundle.js +91 -120
  27. package/moj/components/button-menu/button-menu.bundle.js.map +1 -1
  28. package/moj/components/button-menu/button-menu.bundle.mjs +329 -114
  29. package/moj/components/button-menu/button-menu.bundle.mjs.map +1 -1
  30. package/moj/components/button-menu/button-menu.mjs +89 -116
  31. package/moj/components/button-menu/button-menu.mjs.map +1 -1
  32. package/moj/components/date-picker/date-picker.bundle.js +174 -154
  33. package/moj/components/date-picker/date-picker.bundle.js.map +1 -1
  34. package/moj/components/date-picker/date-picker.bundle.mjs +411 -147
  35. package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -1
  36. package/moj/components/date-picker/date-picker.mjs +172 -150
  37. package/moj/components/date-picker/date-picker.mjs.map +1 -1
  38. package/moj/components/filter/template.njk +1 -1
  39. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js +133 -44
  40. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.js.map +1 -1
  41. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs +374 -41
  42. package/moj/components/filter-toggle-button/filter-toggle-button.bundle.mjs.map +1 -1
  43. package/moj/components/filter-toggle-button/filter-toggle-button.mjs +131 -40
  44. package/moj/components/filter-toggle-button/filter-toggle-button.mjs.map +1 -1
  45. package/moj/components/form-validator/form-validator.bundle.js +159 -69
  46. package/moj/components/form-validator/form-validator.bundle.js.map +1 -1
  47. package/moj/components/form-validator/form-validator.bundle.mjs +399 -65
  48. package/moj/components/form-validator/form-validator.bundle.mjs.map +1 -1
  49. package/moj/components/form-validator/form-validator.mjs +134 -54
  50. package/moj/components/form-validator/form-validator.mjs.map +1 -1
  51. package/moj/components/multi-file-upload/multi-file-upload.bundle.js +291 -117
  52. package/moj/components/multi-file-upload/multi-file-upload.bundle.js.map +1 -1
  53. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs +527 -109
  54. package/moj/components/multi-file-upload/multi-file-upload.bundle.mjs.map +1 -1
  55. package/moj/components/multi-file-upload/multi-file-upload.mjs +288 -101
  56. package/moj/components/multi-file-upload/multi-file-upload.mjs.map +1 -1
  57. package/moj/components/multi-file-upload/template.njk +1 -1
  58. package/moj/components/multi-select/multi-select.bundle.js +106 -41
  59. package/moj/components/multi-select/multi-select.bundle.js.map +1 -1
  60. package/moj/components/multi-select/multi-select.bundle.mjs +346 -37
  61. package/moj/components/multi-select/multi-select.bundle.mjs.map +1 -1
  62. package/moj/components/multi-select/multi-select.mjs +104 -37
  63. package/moj/components/multi-select/multi-select.mjs.map +1 -1
  64. package/moj/components/password-reveal/_password-reveal.scss +3 -1
  65. package/moj/components/password-reveal/_password-reveal.scss.map +1 -1
  66. package/moj/components/password-reveal/password-reveal.bundle.js +32 -29
  67. package/moj/components/password-reveal/password-reveal.bundle.js.map +1 -1
  68. package/moj/components/password-reveal/password-reveal.bundle.mjs +149 -24
  69. package/moj/components/password-reveal/password-reveal.bundle.mjs.map +1 -1
  70. package/moj/components/password-reveal/password-reveal.mjs +30 -25
  71. package/moj/components/password-reveal/password-reveal.mjs.map +1 -1
  72. package/moj/components/rich-text-editor/README.md +4 -3
  73. package/moj/components/rich-text-editor/rich-text-editor.bundle.js +127 -62
  74. package/moj/components/rich-text-editor/rich-text-editor.bundle.js.map +1 -1
  75. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs +367 -58
  76. package/moj/components/rich-text-editor/rich-text-editor.bundle.mjs.map +1 -1
  77. package/moj/components/rich-text-editor/rich-text-editor.mjs +125 -58
  78. package/moj/components/rich-text-editor/rich-text-editor.mjs.map +1 -1
  79. package/moj/components/search-toggle/search-toggle.bundle.js +94 -26
  80. package/moj/components/search-toggle/search-toggle.bundle.js.map +1 -1
  81. package/moj/components/search-toggle/search-toggle.bundle.mjs +334 -22
  82. package/moj/components/search-toggle/search-toggle.bundle.mjs.map +1 -1
  83. package/moj/components/search-toggle/search-toggle.mjs +92 -22
  84. package/moj/components/search-toggle/search-toggle.mjs.map +1 -1
  85. package/moj/components/sortable-table/_sortable-table.scss +3 -42
  86. package/moj/components/sortable-table/_sortable-table.scss.map +1 -1
  87. package/moj/components/sortable-table/sortable-table.bundle.js +200 -83
  88. package/moj/components/sortable-table/sortable-table.bundle.js.map +1 -1
  89. package/moj/components/sortable-table/sortable-table.bundle.mjs +439 -78
  90. package/moj/components/sortable-table/sortable-table.bundle.mjs.map +1 -1
  91. package/moj/components/sortable-table/sortable-table.mjs +198 -79
  92. package/moj/components/sortable-table/sortable-table.mjs.map +1 -1
  93. package/moj/core/_all.scss +3 -0
  94. package/moj/core/_all.scss.map +1 -0
  95. package/moj/core/_moj-frontend-properties.scss +7 -0
  96. package/moj/core/_moj-frontend-properties.scss.map +1 -0
  97. package/moj/filters/prototype-kit-13-filters.js +4 -3
  98. package/moj/helpers.bundle.js +22 -77
  99. package/moj/helpers.bundle.js.map +1 -1
  100. package/moj/helpers.bundle.mjs +23 -74
  101. package/moj/helpers.bundle.mjs.map +1 -1
  102. package/moj/helpers.mjs +23 -74
  103. package/moj/helpers.mjs.map +1 -1
  104. package/moj/moj-frontend.min.css +1 -1
  105. package/moj/moj-frontend.min.css.map +1 -1
  106. package/moj/moj-frontend.min.js +1 -1
  107. package/moj/moj-frontend.min.js.map +1 -1
  108. package/package.json +1 -1
  109. package/moj/version.bundle.js +0 -12
  110. package/moj/version.bundle.js.map +0 -1
  111. package/moj/version.bundle.mjs +0 -4
  112. package/moj/version.bundle.mjs.map +0 -1
  113. package/moj/version.mjs +0 -4
  114. package/moj/version.mjs.map +0 -1
@@ -1,162 +1,190 @@
1
- import { dragAndDropSupported, formDataSupported, fileApiSupported } from '../../helpers.mjs';
1
+ import { ConfigurableComponent } from 'govuk-frontend';
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-empty-function */
4
4
 
5
- class MultiFileUpload {
5
+
6
+ /**
7
+ * @augments {ConfigurableComponent<MultiFileUploadConfig>}
8
+ */
9
+ class MultiFileUpload extends ConfigurableComponent {
6
10
  /**
7
- * @param {MultiFileUploadConfig} [params] - Multi file upload config
11
+ * @param {Element | null} $root - HTML element to use for multi file upload
12
+ * @param {MultiFileUploadConfig} [config] - Multi file upload config
8
13
  */
9
- constructor(params = {}) {
10
- const {
11
- container
12
- } = params;
13
- if (!container || !(container instanceof HTMLElement) || !(dragAndDropSupported() && formDataSupported() && fileApiSupported())) {
14
+ constructor($root, config = {}) {
15
+ var _this$config$feedback;
16
+ super($root, config);
17
+ if (!MultiFileUpload.isSupported()) {
14
18
  return this;
15
19
  }
16
- this.container = container;
17
- this.container.classList.add('moj-multi-file-upload--enhanced');
18
- this.defaultParams = {
19
- uploadFileEntryHook: () => {},
20
- uploadFileExitHook: () => {},
21
- uploadFileErrorHook: () => {},
22
- fileDeleteHook: () => {},
23
- uploadStatusText: 'Uploading files, please wait',
24
- dropzoneHintText: 'Drag and drop files here or',
25
- dropzoneButtonText: 'Choose files'
26
- };
27
- this.params = Object.assign({}, this.defaultParams, params);
28
- this.feedbackContainer = /** @type {HTMLDivElement} */
29
- this.container.querySelector('.moj-multi-file__uploaded-files');
20
+ const $feedbackContainer = (_this$config$feedback = this.config.feedbackContainer.element) != null ? _this$config$feedback : this.$root.querySelector(this.config.feedbackContainer.selector);
21
+ if (!$feedbackContainer || !($feedbackContainer instanceof HTMLElement)) {
22
+ return this;
23
+ }
24
+ this.$feedbackContainer = $feedbackContainer;
30
25
  this.setupFileInput();
31
26
  this.setupDropzone();
32
27
  this.setupLabel();
33
28
  this.setupStatusBox();
34
- this.container.addEventListener('click', this.onFileDeleteClick.bind(this));
29
+ this.$root.addEventListener('click', this.onFileDeleteClick.bind(this));
30
+ this.$root.classList.add('moj-multi-file-upload--enhanced');
35
31
  }
36
32
  setupDropzone() {
37
- this.dropzone = document.createElement('div');
38
- this.dropzone.classList.add('moj-multi-file-upload__dropzone');
39
- this.dropzone.addEventListener('dragover', this.onDragOver.bind(this));
40
- this.dropzone.addEventListener('dragleave', this.onDragLeave.bind(this));
41
- this.dropzone.addEventListener('drop', this.onDrop.bind(this));
42
- this.fileInput.replaceWith(this.dropzone);
43
- this.dropzone.appendChild(this.fileInput);
33
+ this.$dropzone = document.createElement('div');
34
+ this.$dropzone.classList.add('moj-multi-file-upload__dropzone');
35
+ this.$dropzone.addEventListener('dragover', this.onDragOver.bind(this));
36
+ this.$dropzone.addEventListener('dragleave', this.onDragLeave.bind(this));
37
+ this.$dropzone.addEventListener('drop', this.onDrop.bind(this));
38
+ this.$fileInput.replaceWith(this.$dropzone);
39
+ this.$dropzone.appendChild(this.$fileInput);
44
40
  }
45
41
  setupLabel() {
46
- const label = document.createElement('label');
47
- label.setAttribute('for', this.fileInput.id);
48
- label.classList.add('govuk-button', 'govuk-button--secondary');
49
- label.textContent = this.params.dropzoneButtonText;
50
- const hint = document.createElement('p');
51
- hint.classList.add('govuk-body');
52
- hint.textContent = this.params.dropzoneHintText;
53
- this.label = label;
54
- this.dropzone.append(hint);
55
- this.dropzone.append(label);
42
+ const $label = document.createElement('label');
43
+ $label.setAttribute('for', this.$fileInput.id);
44
+ $label.classList.add('govuk-button', 'govuk-button--secondary');
45
+ $label.textContent = this.config.dropzoneButtonText;
46
+ const $hint = document.createElement('p');
47
+ $hint.classList.add('govuk-body');
48
+ $hint.textContent = this.config.dropzoneHintText;
49
+ this.$label = $label;
50
+ this.$dropzone.append($hint);
51
+ this.$dropzone.append($label);
56
52
  }
57
53
  setupFileInput() {
58
- this.fileInput = /** @type {HTMLInputElement} */
59
- this.container.querySelector('.moj-multi-file-upload__input');
60
- this.fileInput.addEventListener('change', this.onFileChange.bind(this));
61
- this.fileInput.addEventListener('focus', this.onFileFocus.bind(this));
62
- this.fileInput.addEventListener('blur', this.onFileBlur.bind(this));
54
+ this.$fileInput = /** @type {HTMLInputElement} */
55
+ this.$root.querySelector('.moj-multi-file-upload__input');
56
+ this.$fileInput.addEventListener('change', this.onFileChange.bind(this));
57
+ this.$fileInput.addEventListener('focus', this.onFileFocus.bind(this));
58
+ this.$fileInput.addEventListener('blur', this.onFileBlur.bind(this));
63
59
  }
64
60
  setupStatusBox() {
65
- this.status = document.createElement('div');
66
- this.status.classList.add('govuk-visually-hidden');
67
- this.status.setAttribute('aria-live', 'polite');
68
- this.status.setAttribute('role', 'status');
69
- this.dropzone.append(this.status);
61
+ this.$status = document.createElement('div');
62
+ this.$status.classList.add('govuk-visually-hidden');
63
+ this.$status.setAttribute('aria-live', 'polite');
64
+ this.$status.setAttribute('role', 'status');
65
+ this.$dropzone.append(this.$status);
70
66
  }
67
+
68
+ /**
69
+ * @param {DragEvent} event - Drag event
70
+ */
71
71
  onDragOver(event) {
72
72
  event.preventDefault();
73
- this.dropzone.classList.add('moj-multi-file-upload--dragover');
73
+ this.$dropzone.classList.add('moj-multi-file-upload--dragover');
74
74
  }
75
75
  onDragLeave() {
76
- this.dropzone.classList.remove('moj-multi-file-upload--dragover');
76
+ this.$dropzone.classList.remove('moj-multi-file-upload--dragover');
77
77
  }
78
+
79
+ /**
80
+ * @param {DragEvent} event - Drag event
81
+ */
78
82
  onDrop(event) {
79
83
  event.preventDefault();
80
- this.dropzone.classList.remove('moj-multi-file-upload--dragover');
81
- this.feedbackContainer.classList.remove('moj-hidden');
82
- this.status.textContent = this.params.uploadStatusText;
84
+ this.$dropzone.classList.remove('moj-multi-file-upload--dragover');
85
+ this.$feedbackContainer.classList.remove('moj-hidden');
86
+ this.$status.textContent = this.config.uploadStatusText;
83
87
  this.uploadFiles(event.dataTransfer.files);
84
88
  }
89
+
90
+ /**
91
+ * @param {FileList} files - File list
92
+ */
85
93
  uploadFiles(files) {
86
94
  for (const file of Array.from(files)) {
87
95
  this.uploadFile(file);
88
96
  }
89
97
  }
90
98
  onFileChange() {
91
- this.feedbackContainer.classList.remove('moj-hidden');
92
- this.status.textContent = this.params.uploadStatusText;
93
- this.uploadFiles(this.fileInput.files);
94
- const fileInput = this.fileInput.cloneNode(true);
95
- if (!fileInput || !(fileInput instanceof HTMLInputElement)) {
99
+ this.$feedbackContainer.classList.remove('moj-hidden');
100
+ this.$status.textContent = this.config.uploadStatusText;
101
+ this.uploadFiles(this.$fileInput.files);
102
+ const $fileInput = this.$fileInput.cloneNode(true);
103
+ if (!$fileInput || !($fileInput instanceof HTMLInputElement)) {
96
104
  return;
97
105
  }
98
- fileInput.value = '';
99
- this.fileInput.replaceWith(fileInput);
106
+ $fileInput.value = '';
107
+ this.$fileInput.replaceWith($fileInput);
100
108
  this.setupFileInput();
101
- this.fileInput.focus();
109
+ this.$fileInput.focus();
102
110
  }
103
111
  onFileFocus() {
104
- this.label.classList.add('moj-multi-file-upload--focused');
112
+ this.$label.classList.add('moj-multi-file-upload--focused');
105
113
  }
106
114
  onFileBlur() {
107
- this.label.classList.remove('moj-multi-file-upload--focused');
115
+ this.$label.classList.remove('moj-multi-file-upload--focused');
108
116
  }
117
+
118
+ /**
119
+ * @param {UploadResponseSuccess['success']} success
120
+ */
109
121
  getSuccessHtml(success) {
110
122
  return `<span class="moj-multi-file-upload__success"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z"/></svg>${success.messageHtml}</span>`;
111
123
  }
124
+
125
+ /**
126
+ * @param {UploadResponseError['error']} error
127
+ */
112
128
  getErrorHtml(error) {
113
129
  return `<span class="moj-multi-file-upload__error"> <svg class="moj-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25"><path d="M13.6,15.4h-2.3v-4.5h2.3V15.4z M13.6,19.8h-2.3v-2.2h2.3V19.8z M0,23.2h25L12.5,2L0,23.2z"/></svg>${error.message}</span>`;
114
130
  }
131
+
132
+ /**
133
+ * @param {File} file
134
+ */
115
135
  getFileRow(file) {
116
- const row = document.createElement('div');
117
- row.classList.add('govuk-summary-list__row', 'moj-multi-file-upload__row');
118
- row.innerHTML = `
136
+ const $row = document.createElement('div');
137
+ $row.classList.add('govuk-summary-list__row', 'moj-multi-file-upload__row');
138
+ $row.innerHTML = `
119
139
  <div class="govuk-summary-list__value moj-multi-file-upload__message">
120
140
  <span class="moj-multi-file-upload__filename">${file.name}</span>
121
141
  <span class="moj-multi-file-upload__progress">0%</span>
122
142
  </div>
123
143
  <div class="govuk-summary-list__actions moj-multi-file-upload__actions"></div>
124
144
  `;
125
- return row;
145
+ return $row;
126
146
  }
147
+
148
+ /**
149
+ * @param {UploadResponseFile} file
150
+ */
127
151
  getDeleteButton(file) {
128
- const button = document.createElement('button');
129
- button.setAttribute('type', 'button');
130
- button.setAttribute('name', 'delete');
131
- button.setAttribute('value', file.filename);
132
- button.classList.add('moj-multi-file-upload__delete', 'govuk-button', 'govuk-button--secondary', 'govuk-!-margin-bottom-0');
133
- button.innerHTML = `Delete <span class="govuk-visually-hidden">${file.originalname}</span>`;
134
- return button;
152
+ const $button = document.createElement('button');
153
+ $button.setAttribute('type', 'button');
154
+ $button.setAttribute('name', 'delete');
155
+ $button.setAttribute('value', file.filename);
156
+ $button.classList.add('moj-multi-file-upload__delete', 'govuk-button', 'govuk-button--secondary', 'govuk-!-margin-bottom-0');
157
+ $button.innerHTML = `Delete <span class="govuk-visually-hidden">${file.originalname}</span>`;
158
+ return $button;
135
159
  }
160
+
161
+ /**
162
+ * @param {File} file
163
+ */
136
164
  uploadFile(file) {
137
- this.params.uploadFileEntryHook(this, file);
138
- const item = this.getFileRow(file);
139
- const message = item.querySelector('.moj-multi-file-upload__message');
140
- const actions = item.querySelector('.moj-multi-file-upload__actions');
141
- const progress = item.querySelector('.moj-multi-file-upload__progress');
165
+ this.config.hooks.entryHook(this, file);
166
+ const $item = this.getFileRow(file);
167
+ const $message = $item.querySelector('.moj-multi-file-upload__message');
168
+ const $actions = $item.querySelector('.moj-multi-file-upload__actions');
169
+ const $progress = $item.querySelector('.moj-multi-file-upload__progress');
142
170
  const formData = new FormData();
143
171
  formData.append('documents', file);
144
- this.feedbackContainer.querySelector('.moj-multi-file-upload__list').append(item);
172
+ this.$feedbackContainer.querySelector('.moj-multi-file-upload__list').append($item);
145
173
  const xhr = new XMLHttpRequest();
146
174
  const onLoad = () => {
147
175
  if (xhr.status < 200 || xhr.status >= 300 || !('success' in xhr.response)) {
148
176
  return onError();
149
177
  }
150
- message.innerHTML = this.getSuccessHtml(xhr.response.success);
151
- this.status.textContent = xhr.response.success.messageText;
152
- actions.append(this.getDeleteButton(xhr.response.file));
153
- this.params.uploadFileExitHook(this, file, xhr, xhr.responseText);
178
+ $message.innerHTML = this.getSuccessHtml(xhr.response.success);
179
+ this.$status.textContent = xhr.response.success.messageText;
180
+ $actions.append(this.getDeleteButton(xhr.response.file));
181
+ this.config.hooks.exitHook(this, file, xhr, xhr.responseText);
154
182
  };
155
183
  const onError = () => {
156
184
  const error = new Error(xhr.response && 'error' in xhr.response ? xhr.response.error.message : xhr.statusText || 'Upload failed');
157
- message.innerHTML = this.getErrorHtml(error);
158
- this.status.textContent = error.message;
159
- this.params.uploadFileErrorHook(this, file, xhr, xhr.responseText, error);
185
+ $message.innerHTML = this.getErrorHtml(error);
186
+ this.$status.textContent = error.message;
187
+ this.config.hooks.errorHook(this, file, xhr, xhr.responseText, error);
160
188
  };
161
189
  xhr.addEventListener('load', onLoad);
162
190
  xhr.addEventListener('error', onError);
@@ -165,15 +193,19 @@ class MultiFileUpload {
165
193
  return;
166
194
  }
167
195
  const percentComplete = Math.round(event.loaded / event.total * 100);
168
- progress.textContent = ` ${percentComplete}%`;
196
+ $progress.textContent = ` ${percentComplete}%`;
169
197
  });
170
- xhr.open('POST', this.params.uploadUrl);
198
+ xhr.open('POST', this.config.uploadUrl);
171
199
  xhr.responseType = 'json';
172
200
  xhr.send(formData);
173
201
  }
202
+
203
+ /**
204
+ * @param {MouseEvent} event - Click event
205
+ */
174
206
  onFileDeleteClick(event) {
175
- const button = event.target;
176
- if (!button || !(button instanceof HTMLButtonElement) || !button.classList.contains('moj-multi-file-upload__delete')) {
207
+ const $button = event.target;
208
+ if (!$button || !($button instanceof HTMLButtonElement) || !$button.classList.contains('moj-multi-file-upload__delete')) {
177
209
  return;
178
210
  }
179
211
  event.preventDefault(); // if user refreshes page and then deletes
@@ -183,22 +215,177 @@ class MultiFileUpload {
183
215
  if (xhr.status < 200 || xhr.status >= 300) {
184
216
  return;
185
217
  }
186
- const rows = Array.from(this.feedbackContainer.querySelectorAll('.moj-multi-file-upload__row'));
187
- if (rows.length === 1) {
188
- this.feedbackContainer.classList.add('moj-hidden');
218
+ const $rows = Array.from(this.$feedbackContainer.querySelectorAll('.moj-multi-file-upload__row'));
219
+ if ($rows.length === 1) {
220
+ this.$feedbackContainer.classList.add('moj-hidden');
189
221
  }
190
- const row = rows.find(row => row.contains(button));
191
- if (row) row.remove();
192
- this.params.fileDeleteHook(this, undefined, xhr, xhr.responseText);
222
+ const $rowDelete = $rows.find($row => $row.contains($button));
223
+ if ($rowDelete) $rowDelete.remove();
224
+ this.config.hooks.deleteHook(this, undefined, xhr, xhr.responseText);
193
225
  });
194
- xhr.open('POST', this.params.deleteUrl);
226
+ xhr.open('POST', this.config.deleteUrl);
195
227
  xhr.setRequestHeader('Content-Type', 'application/json');
196
228
  xhr.responseType = 'json';
197
229
  xhr.send(JSON.stringify({
198
- [button.name]: button.value
230
+ [$button.name]: $button.value
199
231
  }));
200
232
  }
233
+ static isSupported() {
234
+ return this.isDragAndDropSupported() && this.isFormDataSupported() && this.isFileApiSupported();
235
+ }
236
+ static isDragAndDropSupported() {
237
+ const div = document.createElement('div');
238
+ return typeof div.ondrop !== 'undefined';
239
+ }
240
+ static isFormDataSupported() {
241
+ return typeof FormData === 'function';
242
+ }
243
+ static isFileApiSupported() {
244
+ const input = document.createElement('input');
245
+ input.type = 'file';
246
+ return typeof input.files !== 'undefined';
247
+ }
248
+
249
+ /**
250
+ * Name for the component used when initialising using data-module attributes.
251
+ */
201
252
  }
202
253
 
254
+ /**
255
+ * Multi file upload config
256
+ *
257
+ * @typedef {object} MultiFileUploadConfig
258
+ * @property {string} [uploadUrl] - File upload URL
259
+ * @property {string} [deleteUrl] - File delete URL
260
+ * @property {string} [uploadStatusText] - Upload status text
261
+ * @property {string} [dropzoneHintText] - Dropzone hint text
262
+ * @property {string} [dropzoneButtonText] - Dropzone button text
263
+ * @property {object} [feedbackContainer] - Feedback container config
264
+ * @property {string} [feedbackContainer.selector] - Selector for feedback container
265
+ * @property {Element | null} [feedbackContainer.element] - HTML element for feedback container
266
+ * @property {MultiFileUploadHooks} [hooks] - Upload hooks
267
+ */
268
+
269
+ /**
270
+ * Multi file upload hooks
271
+ *
272
+ * @typedef {object} MultiFileUploadHooks
273
+ * @property {OnUploadFileEntryHook} [entryHook] - File upload entry hook
274
+ * @property {OnUploadFileExitHook} [exitHook] - File upload exit hook
275
+ * @property {OnUploadFileErrorHook} [errorHook] - File upload error hook
276
+ * @property {OnUploadFileDeleteHook} [deleteHook] - File delete hook
277
+ */
278
+
279
+ /**
280
+ * Upload hook: File entry
281
+ *
282
+ * @callback OnUploadFileEntryHook
283
+ * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload
284
+ * @param {File} file - File upload
285
+ */
286
+
287
+ /**
288
+ * Upload hook: File exit
289
+ *
290
+ * @callback OnUploadFileExitHook
291
+ * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload
292
+ * @param {File} file - File upload
293
+ * @param {XMLHttpRequest} xhr - XMLHttpRequest
294
+ * @param {string} textStatus - Text status
295
+ */
296
+
297
+ /**
298
+ * Upload hook: File error
299
+ *
300
+ * @callback OnUploadFileErrorHook
301
+ * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload
302
+ * @param {File} file - File upload
303
+ * @param {XMLHttpRequest} xhr - XMLHttpRequest
304
+ * @param {string} textStatus - Text status
305
+ * @param {Error} errorThrown - Error thrown
306
+ */
307
+
308
+ /**
309
+ * Upload hook: File delete
310
+ *
311
+ * @callback OnUploadFileDeleteHook
312
+ * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload
313
+ * @param {File} [file] - File upload
314
+ * @param {XMLHttpRequest} xhr - XMLHttpRequest
315
+ * @param {string} textStatus - Text status
316
+ */
317
+
318
+ /**
319
+ * @typedef {object} UploadResponseSuccess
320
+ * @property {{ messageText: string, messageHtml: string }} success - Response success
321
+ * @property {UploadResponseFile} file - Response file
322
+ */
323
+
324
+ /**
325
+ * @typedef {object} UploadResponseError
326
+ * @property {{ message: string }} error - Response error
327
+ * @property {UploadResponseFile} file - Response file
328
+ */
329
+
330
+ /**
331
+ * @typedef {object} UploadResponseFile
332
+ * @property {string} filename - File name
333
+ * @property {string} originalname - Original file name
334
+ */
335
+
336
+ /**
337
+ * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'
338
+ */
339
+ MultiFileUpload.moduleName = 'moj-multi-file-upload';
340
+ /**
341
+ * Multi file upload default config
342
+ *
343
+ * @type {MultiFileUploadConfig}
344
+ */
345
+ MultiFileUpload.defaults = Object.freeze({
346
+ uploadStatusText: 'Uploading files, please wait',
347
+ dropzoneHintText: 'Drag and drop files here or',
348
+ dropzoneButtonText: 'Choose files',
349
+ feedbackContainer: {
350
+ selector: '.moj-multi-file__uploaded-files'
351
+ },
352
+ hooks: {
353
+ entryHook: () => {},
354
+ exitHook: () => {},
355
+ errorHook: () => {},
356
+ deleteHook: () => {}
357
+ }
358
+ });
359
+ /**
360
+ * Multi file upload config schema
361
+ *
362
+ * @satisfies {Schema<MultiFileUploadConfig>}
363
+ */
364
+ MultiFileUpload.schema = Object.freeze(/** @type {const} */{
365
+ properties: {
366
+ uploadUrl: {
367
+ type: 'string'
368
+ },
369
+ deleteUrl: {
370
+ type: 'string'
371
+ },
372
+ uploadStatusText: {
373
+ type: 'string'
374
+ },
375
+ dropzoneHintText: {
376
+ type: 'string'
377
+ },
378
+ dropzoneButtonText: {
379
+ type: 'string'
380
+ },
381
+ feedbackContainer: {
382
+ type: 'object'
383
+ },
384
+ hooks: {
385
+ type: 'object'
386
+ }
387
+ }
388
+ });
389
+
203
390
  export { MultiFileUpload };
204
391
  //# sourceMappingURL=multi-file-upload.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-file-upload.mjs","sources":["../../../../src/moj/components/multi-file-upload/multi-file-upload.mjs"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n\nimport {\n dragAndDropSupported,\n fileApiSupported,\n formDataSupported\n} from '../../helpers.mjs'\n\nexport class MultiFileUpload {\n /**\n * @param {MultiFileUploadConfig} [params] - Multi file upload config\n */\n constructor(params = {}) {\n const { container } = params\n\n if (\n !container ||\n !(container instanceof HTMLElement) ||\n !(dragAndDropSupported() && formDataSupported() && fileApiSupported())\n ) {\n return this\n }\n\n this.container = container\n this.container.classList.add('moj-multi-file-upload--enhanced')\n\n this.defaultParams = {\n uploadFileEntryHook: () => {},\n uploadFileExitHook: () => {},\n uploadFileErrorHook: () => {},\n fileDeleteHook: () => {},\n uploadStatusText: 'Uploading files, please wait',\n dropzoneHintText: 'Drag and drop files here or',\n dropzoneButtonText: 'Choose files'\n }\n\n this.params = Object.assign({}, this.defaultParams, params)\n\n this.feedbackContainer = /** @type {HTMLDivElement} */ (\n this.container.querySelector('.moj-multi-file__uploaded-files')\n )\n\n this.setupFileInput()\n this.setupDropzone()\n this.setupLabel()\n this.setupStatusBox()\n\n this.container.addEventListener('click', this.onFileDeleteClick.bind(this))\n }\n\n setupDropzone() {\n this.dropzone = document.createElement('div')\n this.dropzone.classList.add('moj-multi-file-upload__dropzone')\n\n this.dropzone.addEventListener('dragover', this.onDragOver.bind(this))\n this.dropzone.addEventListener('dragleave', this.onDragLeave.bind(this))\n this.dropzone.addEventListener('drop', this.onDrop.bind(this))\n\n this.fileInput.replaceWith(this.dropzone)\n this.dropzone.appendChild(this.fileInput)\n }\n\n setupLabel() {\n const label = document.createElement('label')\n label.setAttribute('for', this.fileInput.id)\n label.classList.add('govuk-button', 'govuk-button--secondary')\n label.textContent = this.params.dropzoneButtonText\n\n const hint = document.createElement('p')\n hint.classList.add('govuk-body')\n hint.textContent = this.params.dropzoneHintText\n\n this.label = label\n this.dropzone.append(hint)\n this.dropzone.append(label)\n }\n\n setupFileInput() {\n this.fileInput = /** @type {HTMLInputElement} */ (\n this.container.querySelector('.moj-multi-file-upload__input')\n )\n this.fileInput.addEventListener('change', this.onFileChange.bind(this))\n this.fileInput.addEventListener('focus', this.onFileFocus.bind(this))\n this.fileInput.addEventListener('blur', this.onFileBlur.bind(this))\n }\n\n setupStatusBox() {\n this.status = document.createElement('div')\n this.status.classList.add('govuk-visually-hidden')\n this.status.setAttribute('aria-live', 'polite')\n this.status.setAttribute('role', 'status')\n this.dropzone.append(this.status)\n }\n\n onDragOver(event) {\n event.preventDefault()\n this.dropzone.classList.add('moj-multi-file-upload--dragover')\n }\n\n onDragLeave() {\n this.dropzone.classList.remove('moj-multi-file-upload--dragover')\n }\n\n onDrop(event) {\n event.preventDefault()\n this.dropzone.classList.remove('moj-multi-file-upload--dragover')\n this.feedbackContainer.classList.remove('moj-hidden')\n this.status.textContent = this.params.uploadStatusText\n this.uploadFiles(event.dataTransfer.files)\n }\n\n uploadFiles(files) {\n for (const file of Array.from(files)) {\n this.uploadFile(file)\n }\n }\n\n onFileChange() {\n this.feedbackContainer.classList.remove('moj-hidden')\n this.status.textContent = this.params.uploadStatusText\n this.uploadFiles(this.fileInput.files)\n\n const fileInput = this.fileInput.cloneNode(true)\n if (!fileInput || !(fileInput instanceof HTMLInputElement)) {\n return\n }\n\n fileInput.value = ''\n this.fileInput.replaceWith(fileInput)\n\n this.setupFileInput()\n this.fileInput.focus()\n }\n\n onFileFocus() {\n this.label.classList.add('moj-multi-file-upload--focused')\n }\n\n onFileBlur() {\n this.label.classList.remove('moj-multi-file-upload--focused')\n }\n\n getSuccessHtml(success) {\n return `<span class=\"moj-multi-file-upload__success\"> <svg class=\"moj-banner__icon\" fill=\"currentColor\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 25 25\" height=\"25\" width=\"25\"><path d=\"M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z\"/></svg>${success.messageHtml}</span>`\n }\n\n getErrorHtml(error) {\n return `<span class=\"moj-multi-file-upload__error\"> <svg class=\"moj-banner__icon\" fill=\"currentColor\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 25 25\" height=\"25\" width=\"25\"><path d=\"M13.6,15.4h-2.3v-4.5h2.3V15.4z M13.6,19.8h-2.3v-2.2h2.3V19.8z M0,23.2h25L12.5,2L0,23.2z\"/></svg>${error.message}</span>`\n }\n\n getFileRow(file) {\n const row = document.createElement('div')\n\n row.classList.add('govuk-summary-list__row', 'moj-multi-file-upload__row')\n\n row.innerHTML = `\n <div class=\"govuk-summary-list__value moj-multi-file-upload__message\">\n <span class=\"moj-multi-file-upload__filename\">${file.name}</span>\n <span class=\"moj-multi-file-upload__progress\">0%</span>\n </div>\n <div class=\"govuk-summary-list__actions moj-multi-file-upload__actions\"></div>\n `\n\n return row\n }\n\n getDeleteButton(file) {\n const button = document.createElement('button')\n\n button.setAttribute('type', 'button')\n button.setAttribute('name', 'delete')\n button.setAttribute('value', file.filename)\n\n button.classList.add(\n 'moj-multi-file-upload__delete',\n 'govuk-button',\n 'govuk-button--secondary',\n 'govuk-!-margin-bottom-0'\n )\n\n button.innerHTML = `Delete <span class=\"govuk-visually-hidden\">${file.originalname}</span>`\n\n return button\n }\n\n uploadFile(file) {\n this.params.uploadFileEntryHook(this, file)\n\n const item = this.getFileRow(file)\n const message = item.querySelector('.moj-multi-file-upload__message')\n const actions = item.querySelector('.moj-multi-file-upload__actions')\n const progress = item.querySelector('.moj-multi-file-upload__progress')\n\n const formData = new FormData()\n formData.append('documents', file)\n\n this.feedbackContainer\n .querySelector('.moj-multi-file-upload__list')\n .append(item)\n\n const xhr = new XMLHttpRequest()\n\n const onLoad = () => {\n if (\n xhr.status < 200 ||\n xhr.status >= 300 ||\n !('success' in xhr.response)\n ) {\n return onError()\n }\n\n message.innerHTML = this.getSuccessHtml(xhr.response.success)\n this.status.textContent = xhr.response.success.messageText\n\n actions.append(this.getDeleteButton(xhr.response.file))\n this.params.uploadFileExitHook(this, file, xhr, xhr.responseText)\n }\n\n const onError = () => {\n const error = new Error(\n xhr.response && 'error' in xhr.response\n ? xhr.response.error.message\n : xhr.statusText || 'Upload failed'\n )\n\n message.innerHTML = this.getErrorHtml(error)\n this.status.textContent = error.message\n\n this.params.uploadFileErrorHook(this, file, xhr, xhr.responseText, error)\n }\n\n xhr.addEventListener('load', onLoad)\n xhr.addEventListener('error', onError)\n\n xhr.upload.addEventListener('progress', (event) => {\n if (!event.lengthComputable) {\n return\n }\n\n const percentComplete = Math.round((event.loaded / event.total) * 100)\n progress.textContent = ` ${percentComplete}%`\n })\n\n xhr.open('POST', this.params.uploadUrl)\n xhr.responseType = 'json'\n\n xhr.send(formData)\n }\n\n onFileDeleteClick(event) {\n const button = event.target\n\n if (\n !button ||\n !(button instanceof HTMLButtonElement) ||\n !button.classList.contains('moj-multi-file-upload__delete')\n ) {\n return\n }\n\n event.preventDefault() // if user refreshes page and then deletes\n\n const xhr = new XMLHttpRequest()\n\n xhr.addEventListener('load', () => {\n if (xhr.status < 200 || xhr.status >= 300) {\n return\n }\n\n const rows = Array.from(\n this.feedbackContainer.querySelectorAll('.moj-multi-file-upload__row')\n )\n\n if (rows.length === 1) {\n this.feedbackContainer.classList.add('moj-hidden')\n }\n\n const row = rows.find((row) => row.contains(button))\n if (row) row.remove()\n\n this.params.fileDeleteHook(this, undefined, xhr, xhr.responseText)\n })\n\n xhr.open('POST', this.params.deleteUrl)\n xhr.setRequestHeader('Content-Type', 'application/json')\n xhr.responseType = 'json'\n\n xhr.send(\n JSON.stringify({\n [button.name]: button.value\n })\n )\n }\n}\n"],"names":["MultiFileUpload","constructor","params","container","HTMLElement","dragAndDropSupported","formDataSupported","fileApiSupported","classList","add","defaultParams","uploadFileEntryHook","uploadFileExitHook","uploadFileErrorHook","fileDeleteHook","uploadStatusText","dropzoneHintText","dropzoneButtonText","Object","assign","feedbackContainer","querySelector","setupFileInput","setupDropzone","setupLabel","setupStatusBox","addEventListener","onFileDeleteClick","bind","dropzone","document","createElement","onDragOver","onDragLeave","onDrop","fileInput","replaceWith","appendChild","label","setAttribute","id","textContent","hint","append","onFileChange","onFileFocus","onFileBlur","status","event","preventDefault","remove","uploadFiles","dataTransfer","files","file","Array","from","uploadFile","cloneNode","HTMLInputElement","value","focus","getSuccessHtml","success","messageHtml","getErrorHtml","error","message","getFileRow","row","innerHTML","name","getDeleteButton","button","filename","originalname","item","actions","progress","formData","FormData","xhr","XMLHttpRequest","onLoad","response","onError","messageText","responseText","Error","statusText","upload","lengthComputable","percentComplete","Math","round","loaded","total","open","uploadUrl","responseType","send","target","HTMLButtonElement","contains","rows","querySelectorAll","length","find","undefined","deleteUrl","setRequestHeader","JSON","stringify"],"mappings":";;AAAA;;AAQO,MAAMA,eAAe,CAAC;AAC3B;AACF;AACA;AACEC,EAAAA,WAAWA,CAACC,MAAM,GAAG,EAAE,EAAE;IACvB,MAAM;AAAEC,MAAAA;AAAU,KAAC,GAAGD,MAAM;IAE5B,IACE,CAACC,SAAS,IACV,EAAEA,SAAS,YAAYC,WAAW,CAAC,IACnC,EAAEC,oBAAoB,EAAE,IAAIC,iBAAiB,EAAE,IAAIC,gBAAgB,EAAE,CAAC,EACtE;AACA,MAAA,OAAO,IAAI;AACb;IAEA,IAAI,CAACJ,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACA,SAAS,CAACK,SAAS,CAACC,GAAG,CAAC,iCAAiC,CAAC;IAE/D,IAAI,CAACC,aAAa,GAAG;AACnBC,MAAAA,mBAAmB,EAAEA,MAAM,EAAE;AAC7BC,MAAAA,kBAAkB,EAAEA,MAAM,EAAE;AAC5BC,MAAAA,mBAAmB,EAAEA,MAAM,EAAE;AAC7BC,MAAAA,cAAc,EAAEA,MAAM,EAAE;AACxBC,MAAAA,gBAAgB,EAAE,8BAA8B;AAChDC,MAAAA,gBAAgB,EAAE,6BAA6B;AAC/CC,MAAAA,kBAAkB,EAAE;KACrB;AAED,IAAA,IAAI,CAACf,MAAM,GAAGgB,MAAM,CAACC,MAAM,CAAC,EAAE,EAAE,IAAI,CAACT,aAAa,EAAER,MAAM,CAAC;IAE3D,IAAI,CAACkB,iBAAiB;AACpB,IAAA,IAAI,CAACjB,SAAS,CAACkB,aAAa,CAAC,iCAAiC,CAC/D;IAED,IAAI,CAACC,cAAc,EAAE;IACrB,IAAI,CAACC,aAAa,EAAE;IACpB,IA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A,IAAI,CAAChD,MAAM,CAACY,cAAc,CAAC,IAAI,EAAE8F,SAAS,EAAE3B,GAAG,EAAEA,GAAG,CAACM,YAAY,CAAC;AACpE,KAAC,CAAC;IAEFN,GAAG,CAACgB,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC/F,MAAM,CAAC2G,SAAS,CAAC;AACvC5B,IAAAA,GAAG,CAAC6B,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;IACxD7B,GAAG,CAACkB,YAAY,GAAG,MAAM;AAEzBlB,IAAAA,GAAG,CAACmB,IAAI,CACNW,IAAI,CAACC,SAAS,CAAC;AACb,MAAA,CAACvC,MAAM,CAACF,IAAI,GAAGE,MAAM,CAACb;AACxB,KAAC,CACH,CAAC;AACH;AACF;;;;"}
1
+ {"version":3,"file":"multi-file-upload.mjs","sources":["../../../../src/moj/components/multi-file-upload/multi-file-upload.mjs"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n\nimport { ConfigurableComponent } from 'govuk-frontend'\n\n/**\n * @augments {ConfigurableComponent<MultiFileUploadConfig>}\n */\nexport class MultiFileUpload extends ConfigurableComponent {\n /**\n * @param {Element | null} $root - HTML element to use for multi file upload\n * @param {MultiFileUploadConfig} [config] - Multi file upload config\n */\n constructor($root, config = {}) {\n super($root, config)\n\n if (!MultiFileUpload.isSupported()) {\n return this\n }\n\n const $feedbackContainer =\n this.config.feedbackContainer.element ??\n this.$root.querySelector(this.config.feedbackContainer.selector)\n\n if (!$feedbackContainer || !($feedbackContainer instanceof HTMLElement)) {\n return this\n }\n\n this.$feedbackContainer = $feedbackContainer\n\n this.setupFileInput()\n this.setupDropzone()\n this.setupLabel()\n this.setupStatusBox()\n\n this.$root.addEventListener('click', this.onFileDeleteClick.bind(this))\n this.$root.classList.add('moj-multi-file-upload--enhanced')\n }\n\n setupDropzone() {\n this.$dropzone = document.createElement('div')\n this.$dropzone.classList.add('moj-multi-file-upload__dropzone')\n\n this.$dropzone.addEventListener('dragover', this.onDragOver.bind(this))\n this.$dropzone.addEventListener('dragleave', this.onDragLeave.bind(this))\n this.$dropzone.addEventListener('drop', this.onDrop.bind(this))\n\n this.$fileInput.replaceWith(this.$dropzone)\n this.$dropzone.appendChild(this.$fileInput)\n }\n\n setupLabel() {\n const $label = document.createElement('label')\n $label.setAttribute('for', this.$fileInput.id)\n $label.classList.add('govuk-button', 'govuk-button--secondary')\n $label.textContent = this.config.dropzoneButtonText\n\n const $hint = document.createElement('p')\n $hint.classList.add('govuk-body')\n $hint.textContent = this.config.dropzoneHintText\n\n this.$label = $label\n this.$dropzone.append($hint)\n this.$dropzone.append($label)\n }\n\n setupFileInput() {\n this.$fileInput = /** @type {HTMLInputElement} */ (\n this.$root.querySelector('.moj-multi-file-upload__input')\n )\n this.$fileInput.addEventListener('change', this.onFileChange.bind(this))\n this.$fileInput.addEventListener('focus', this.onFileFocus.bind(this))\n this.$fileInput.addEventListener('blur', this.onFileBlur.bind(this))\n }\n\n setupStatusBox() {\n this.$status = document.createElement('div')\n this.$status.classList.add('govuk-visually-hidden')\n this.$status.setAttribute('aria-live', 'polite')\n this.$status.setAttribute('role', 'status')\n this.$dropzone.append(this.$status)\n }\n\n /**\n * @param {DragEvent} event - Drag event\n */\n onDragOver(event) {\n event.preventDefault()\n this.$dropzone.classList.add('moj-multi-file-upload--dragover')\n }\n\n onDragLeave() {\n this.$dropzone.classList.remove('moj-multi-file-upload--dragover')\n }\n\n /**\n * @param {DragEvent} event - Drag event\n */\n onDrop(event) {\n event.preventDefault()\n this.$dropzone.classList.remove('moj-multi-file-upload--dragover')\n this.$feedbackContainer.classList.remove('moj-hidden')\n this.$status.textContent = this.config.uploadStatusText\n this.uploadFiles(event.dataTransfer.files)\n }\n\n /**\n * @param {FileList} files - File list\n */\n uploadFiles(files) {\n for (const file of Array.from(files)) {\n this.uploadFile(file)\n }\n }\n\n onFileChange() {\n this.$feedbackContainer.classList.remove('moj-hidden')\n this.$status.textContent = this.config.uploadStatusText\n this.uploadFiles(this.$fileInput.files)\n\n const $fileInput = this.$fileInput.cloneNode(true)\n if (!$fileInput || !($fileInput instanceof HTMLInputElement)) {\n return\n }\n\n $fileInput.value = ''\n this.$fileInput.replaceWith($fileInput)\n\n this.setupFileInput()\n this.$fileInput.focus()\n }\n\n onFileFocus() {\n this.$label.classList.add('moj-multi-file-upload--focused')\n }\n\n onFileBlur() {\n this.$label.classList.remove('moj-multi-file-upload--focused')\n }\n\n /**\n * @param {UploadResponseSuccess['success']} success\n */\n getSuccessHtml(success) {\n return `<span class=\"moj-multi-file-upload__success\"> <svg class=\"moj-banner__icon\" fill=\"currentColor\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 25 25\" height=\"25\" width=\"25\"><path d=\"M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z\"/></svg>${success.messageHtml}</span>`\n }\n\n /**\n * @param {UploadResponseError['error']} error\n */\n getErrorHtml(error) {\n return `<span class=\"moj-multi-file-upload__error\"> <svg class=\"moj-banner__icon\" fill=\"currentColor\" role=\"presentation\" focusable=\"false\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 25 25\" height=\"25\" width=\"25\"><path d=\"M13.6,15.4h-2.3v-4.5h2.3V15.4z M13.6,19.8h-2.3v-2.2h2.3V19.8z M0,23.2h25L12.5,2L0,23.2z\"/></svg>${error.message}</span>`\n }\n\n /**\n * @param {File} file\n */\n getFileRow(file) {\n const $row = document.createElement('div')\n\n $row.classList.add('govuk-summary-list__row', 'moj-multi-file-upload__row')\n\n $row.innerHTML = `\n <div class=\"govuk-summary-list__value moj-multi-file-upload__message\">\n <span class=\"moj-multi-file-upload__filename\">${file.name}</span>\n <span class=\"moj-multi-file-upload__progress\">0%</span>\n </div>\n <div class=\"govuk-summary-list__actions moj-multi-file-upload__actions\"></div>\n `\n\n return $row\n }\n\n /**\n * @param {UploadResponseFile} file\n */\n getDeleteButton(file) {\n const $button = document.createElement('button')\n\n $button.setAttribute('type', 'button')\n $button.setAttribute('name', 'delete')\n $button.setAttribute('value', file.filename)\n\n $button.classList.add(\n 'moj-multi-file-upload__delete',\n 'govuk-button',\n 'govuk-button--secondary',\n 'govuk-!-margin-bottom-0'\n )\n\n $button.innerHTML = `Delete <span class=\"govuk-visually-hidden\">${file.originalname}</span>`\n\n return $button\n }\n\n /**\n * @param {File} file\n */\n uploadFile(file) {\n this.config.hooks.entryHook(this, file)\n\n const $item = this.getFileRow(file)\n const $message = $item.querySelector('.moj-multi-file-upload__message')\n const $actions = $item.querySelector('.moj-multi-file-upload__actions')\n const $progress = $item.querySelector('.moj-multi-file-upload__progress')\n\n const formData = new FormData()\n formData.append('documents', file)\n\n this.$feedbackContainer\n .querySelector('.moj-multi-file-upload__list')\n .append($item)\n\n const xhr = new XMLHttpRequest()\n\n const onLoad = () => {\n if (\n xhr.status < 200 ||\n xhr.status >= 300 ||\n !('success' in xhr.response)\n ) {\n return onError()\n }\n\n $message.innerHTML = this.getSuccessHtml(xhr.response.success)\n this.$status.textContent = xhr.response.success.messageText\n\n $actions.append(this.getDeleteButton(xhr.response.file))\n this.config.hooks.exitHook(this, file, xhr, xhr.responseText)\n }\n\n const onError = () => {\n const error = new Error(\n xhr.response && 'error' in xhr.response\n ? xhr.response.error.message\n : xhr.statusText || 'Upload failed'\n )\n\n $message.innerHTML = this.getErrorHtml(error)\n this.$status.textContent = error.message\n\n this.config.hooks.errorHook(this, file, xhr, xhr.responseText, error)\n }\n\n xhr.addEventListener('load', onLoad)\n xhr.addEventListener('error', onError)\n\n xhr.upload.addEventListener('progress', (event) => {\n if (!event.lengthComputable) {\n return\n }\n\n const percentComplete = Math.round((event.loaded / event.total) * 100)\n $progress.textContent = ` ${percentComplete}%`\n })\n\n xhr.open('POST', this.config.uploadUrl)\n xhr.responseType = 'json'\n\n xhr.send(formData)\n }\n\n /**\n * @param {MouseEvent} event - Click event\n */\n onFileDeleteClick(event) {\n const $button = event.target\n\n if (\n !$button ||\n !($button instanceof HTMLButtonElement) ||\n !$button.classList.contains('moj-multi-file-upload__delete')\n ) {\n return\n }\n\n event.preventDefault() // if user refreshes page and then deletes\n\n const xhr = new XMLHttpRequest()\n\n xhr.addEventListener('load', () => {\n if (xhr.status < 200 || xhr.status >= 300) {\n return\n }\n\n const $rows = Array.from(\n this.$feedbackContainer.querySelectorAll('.moj-multi-file-upload__row')\n )\n\n if ($rows.length === 1) {\n this.$feedbackContainer.classList.add('moj-hidden')\n }\n\n const $rowDelete = $rows.find(($row) => $row.contains($button))\n if ($rowDelete) $rowDelete.remove()\n\n this.config.hooks.deleteHook(this, undefined, xhr, xhr.responseText)\n })\n\n xhr.open('POST', this.config.deleteUrl)\n xhr.setRequestHeader('Content-Type', 'application/json')\n xhr.responseType = 'json'\n\n xhr.send(\n JSON.stringify({\n [$button.name]: $button.value\n })\n )\n }\n\n static isSupported() {\n return (\n this.isDragAndDropSupported() &&\n this.isFormDataSupported() &&\n this.isFileApiSupported()\n )\n }\n\n static isDragAndDropSupported() {\n const div = document.createElement('div')\n return typeof div.ondrop !== 'undefined'\n }\n\n static isFormDataSupported() {\n return typeof FormData === 'function'\n }\n\n static isFileApiSupported() {\n const input = document.createElement('input')\n input.type = 'file'\n return typeof input.files !== 'undefined'\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'moj-multi-file-upload'\n\n /**\n * Multi file upload default config\n *\n * @type {MultiFileUploadConfig}\n */\n static defaults = Object.freeze({\n uploadStatusText: 'Uploading files, please wait',\n dropzoneHintText: 'Drag and drop files here or',\n dropzoneButtonText: 'Choose files',\n feedbackContainer: {\n selector: '.moj-multi-file__uploaded-files'\n },\n hooks: {\n entryHook: () => {},\n exitHook: () => {},\n errorHook: () => {},\n deleteHook: () => {}\n }\n })\n\n /**\n * Multi file upload config schema\n *\n * @satisfies {Schema<MultiFileUploadConfig>}\n */\n static schema = Object.freeze(\n /** @type {const} */ ({\n properties: {\n uploadUrl: { type: 'string' },\n deleteUrl: { type: 'string' },\n uploadStatusText: { type: 'string' },\n dropzoneHintText: { type: 'string' },\n dropzoneButtonText: { type: 'string' },\n feedbackContainer: { type: 'object' },\n hooks: { type: 'object' }\n }\n })\n )\n}\n\n/**\n * Multi file upload config\n *\n * @typedef {object} MultiFileUploadConfig\n * @property {string} [uploadUrl] - File upload URL\n * @property {string} [deleteUrl] - File delete URL\n * @property {string} [uploadStatusText] - Upload status text\n * @property {string} [dropzoneHintText] - Dropzone hint text\n * @property {string} [dropzoneButtonText] - Dropzone button text\n * @property {object} [feedbackContainer] - Feedback container config\n * @property {string} [feedbackContainer.selector] - Selector for feedback container\n * @property {Element | null} [feedbackContainer.element] - HTML element for feedback container\n * @property {MultiFileUploadHooks} [hooks] - Upload hooks\n */\n\n/**\n * Multi file upload hooks\n *\n * @typedef {object} MultiFileUploadHooks\n * @property {OnUploadFileEntryHook} [entryHook] - File upload entry hook\n * @property {OnUploadFileExitHook} [exitHook] - File upload exit hook\n * @property {OnUploadFileErrorHook} [errorHook] - File upload error hook\n * @property {OnUploadFileDeleteHook} [deleteHook] - File delete hook\n */\n\n/**\n * Upload hook: File entry\n *\n * @callback OnUploadFileEntryHook\n * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload\n * @param {File} file - File upload\n */\n\n/**\n * Upload hook: File exit\n *\n * @callback OnUploadFileExitHook\n * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload\n * @param {File} file - File upload\n * @param {XMLHttpRequest} xhr - XMLHttpRequest\n * @param {string} textStatus - Text status\n */\n\n/**\n * Upload hook: File error\n *\n * @callback OnUploadFileErrorHook\n * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload\n * @param {File} file - File upload\n * @param {XMLHttpRequest} xhr - XMLHttpRequest\n * @param {string} textStatus - Text status\n * @param {Error} errorThrown - Error thrown\n */\n\n/**\n * Upload hook: File delete\n *\n * @callback OnUploadFileDeleteHook\n * @param {InstanceType<typeof MultiFileUpload>} upload - Multi file upload\n * @param {File} [file] - File upload\n * @param {XMLHttpRequest} xhr - XMLHttpRequest\n * @param {string} textStatus - Text status\n */\n\n/**\n * @typedef {object} UploadResponseSuccess\n * @property {{ messageText: string, messageHtml: string }} success - Response success\n * @property {UploadResponseFile} file - Response file\n */\n\n/**\n * @typedef {object} UploadResponseError\n * @property {{ message: string }} error - Response error\n * @property {UploadResponseFile} file - Response file\n */\n\n/**\n * @typedef {object} UploadResponseFile\n * @property {string} filename - File name\n * @property {string} originalname - Original file name\n */\n\n/**\n * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'\n */\n"],"names":["MultiFileUpload","ConfigurableComponent","constructor","$root","config","_this$config$feedback","isSupported","$feedbackContainer","feedbackContainer","element","querySelector","selector","HTMLElement","setupFileInput","setupDropzone","setupLabel","setupStatusBox","addEventListener","onFileDeleteClick","bind","classList","add","$dropzone","document","createElement","onDragOver","onDragLeave","onDrop","$fileInput","replaceWith","appendChild","$label","setAttribute","id","textContent","dropzoneButtonText","$hint","dropzoneHintText","append","onFileChange","onFileFocus","onFileBlur","$status","event","preventDefault","remove","uploadStatusText","uploadFiles","dataTransfer","files","file","Array","from","uploadFile","cloneNode","HTMLInputElement","value","focus","getSuccessHtml","success","messageHtml","getErrorHtml","error","message","getFileRow","$row","innerHTML","name","getDeleteButton","$button","filename","originalname","hooks","entryHook","$item","$message","$actions","$progress","formData","FormData","xhr","XMLHttpRequest","onLoad","status","response","onError","messageText","exitHook","responseText","Error","statusText","errorHook","upload","lengthComputable","percentComplete","Math","round","loaded","total","open","uploadUrl","responseType","send","target","HTMLButtonElement","contains","$rows","querySelectorAll","length","$rowDelete","find","deleteHook","undefined","deleteUrl","setRequestHeader","JSON","stringify","isDragAndDropSupported","isFormDataSupported","isFileApiSupported","div","ondrop","input","type","moduleName","defaults","Object","freeze","schema","properties"],"mappings":";;AAAA;;;AAIA;AACA;AACA;AACO,MAAMA,eAAe,SAASC,qBAAqB,CAAC;AACzD;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC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C,MAAM,CAACC,MAAM,CAAC;AAC9BjF,EAAAA,gBAAgB,EAAE,8BAA8B;AAChDT,EAAAA,gBAAgB,EAAE,6BAA6B;AAC/CF,EAAAA,kBAAkB,EAAE,cAAc;AAClC3B,EAAAA,iBAAiB,EAAE;AACjBG,IAAAA,QAAQ,EAAE;GACX;AACD6D,EAAAA,KAAK,EAAE;AACLC,IAAAA,SAAS,EAAEA,MAAM,EAAE;AACnBc,IAAAA,QAAQ,EAAEA,MAAM,EAAE;AAClBI,IAAAA,SAAS,EAAEA,MAAM,EAAE;IACnBoB,UAAU,EAAEA,MAAM;AACpB;AACF,CAAC,CAAC;AAEF;AACF;AACA;AACA;AACA;AAlWa/G,eAAe,CAmWnBgI,MAAM,GAAGF,MAAM,CAACC,MAAM,qBACL;AACpBE,EAAAA,UAAU,EAAE;AACV7B,IAAAA,SAAS,EAAE;AAAEuB,MAAAA,IAAI,EAAE;KAAU;AAC7BV,IAAAA,SAAS,EAAE;AAAEU,MAAAA,IAAI,EAAE;KAAU;AAC7B7E,IAAAA,gBAAgB,EAAE;AAAE6E,MAAAA,IAAI,EAAE;KAAU;AACpCtF,IAAAA,gBAAgB,EAAE;AAAEsF,MAAAA,IAAI,EAAE;KAAU;AACpCxF,IAAAA,kBAAkB,EAAE;AAAEwF,MAAAA,IAAI,EAAE;KAAU;AACtCnH,IAAAA,iBAAiB,EAAE;AAAEmH,MAAAA,IAAI,EAAE;KAAU;AACrCnD,IAAAA,KAAK,EAAE;AAAEmD,MAAAA,IAAI,EAAE;AAAS;AAC1B;AACF,CACF,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- <div class="moj-multi-file-upload {{- " " + params.classes if params.classes}}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
1
+ <div class="moj-multi-file-upload {{- " " + params.classes if params.classes}}" data-module="moj-multi-file-upload" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
2
2
  <div class="moj-multi-file__uploaded-files {% if params.uploadedFiles.items.length == 0 %}moj-hidden{% endif%}">
3
3
  <h2 class="govuk-heading-m">{{ params.uploadedFiles.heading.html | safe if params.uploadedFiles.heading.html else params.uploadedFiles.heading.text }}</h2>
4
4
  <div class="govuk-summary-list moj-multi-file-upload__list">