nsw-design-system 3.5.2 → 3.5.3

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/dist/js/main.js CHANGED
@@ -788,38 +788,43 @@
788
788
  }
789
789
  }
790
790
  selectedItems() {
791
- this.filtersItems.forEach(filter => {
792
- const button = filter.querySelector('.nsw-filters__item-name');
793
- const content = filter.querySelector('.nsw-filters__item-content');
794
- const text = content ? content.querySelectorAll('input[type="text"]') : null;
795
- const selects = content ? content.querySelectorAll('select') : null;
796
- const checkboxes = content ? content.querySelectorAll('input[type="checkbox"]') : null;
797
- if (!content) return;
798
- this.updateCount({
799
- array: text,
800
- title: button
801
- });
802
- this.updateCount({
803
- array: selects,
804
- title: button
805
- });
806
- this.updateCount({
807
- array: checkboxes,
808
- title: button
809
- });
810
- this.updateStatus({
811
- array: text,
812
- title: button
813
- });
814
- this.updateStatus({
815
- array: selects,
816
- title: button
817
- });
818
- this.updateStatus({
819
- array: checkboxes,
820
- title: button
821
- });
822
- });
791
+ const stateCheck = setInterval(() => {
792
+ if (document.readyState === 'complete') {
793
+ clearInterval(stateCheck);
794
+ this.filtersItems.forEach(filter => {
795
+ const button = filter.querySelector('.nsw-filters__item-name');
796
+ const content = filter.querySelector('.nsw-filters__item-content');
797
+ const text = content ? content.querySelectorAll('input[type="text"]') : null;
798
+ const selects = content ? content.querySelectorAll('select') : null;
799
+ const checkboxes = content ? content.querySelectorAll('input[type="checkbox"]:not([id$="-all"])') : null;
800
+ if (!content) return;
801
+ this.updateCount({
802
+ array: text,
803
+ title: button
804
+ });
805
+ this.updateCount({
806
+ array: selects,
807
+ title: button
808
+ });
809
+ this.updateCount({
810
+ array: checkboxes,
811
+ title: button
812
+ });
813
+ this.updateStatus({
814
+ array: text,
815
+ title: button
816
+ });
817
+ this.updateStatus({
818
+ array: selects,
819
+ title: button
820
+ });
821
+ this.updateStatus({
822
+ array: checkboxes,
823
+ title: button
824
+ });
825
+ });
826
+ }
827
+ }, 100);
823
828
  }
824
829
  clearAllFilters(e) {
825
830
  e.preventDefault();
@@ -829,7 +834,7 @@
829
834
  const content = filter.querySelector('.nsw-filters__item-content');
830
835
  const text = content.querySelectorAll('input[type="text"]');
831
836
  const selects = content.querySelectorAll('select');
832
- const checkboxes = content.querySelectorAll('input[type="checkbox"]');
837
+ const checkboxes = content.querySelectorAll('input[type="checkbox"]:not([id$="-all"])');
833
838
  const allFields = [...text, ...selects, ...checkboxes];
834
839
  if (!content) return;
835
840
  if (allFields.length > 0) {
@@ -838,6 +843,7 @@
838
843
  if (this.constructor.getCondition(field) && (field.type === 'text' || field.type === 'select-one')) {
839
844
  field.value = '';
840
845
  } else {
846
+ field.click();
841
847
  field.checked = false;
842
848
  }
843
849
  });
@@ -1205,11 +1211,13 @@
1205
1211
  this.customOptions.forEach(check => {
1206
1212
  const input = check.querySelector('.nsw-form__checkbox-input');
1207
1213
  if (count === this.options.length) {
1214
+ input.click();
1208
1215
  input.checked = false;
1209
1216
  input.removeAttribute('checked');
1210
1217
  check.setAttribute('aria-selected', 'false');
1211
1218
  this.updateNativeSelect(check.getAttribute('data-index'), false);
1212
1219
  } else {
1220
+ input.click();
1213
1221
  input.checked = true;
1214
1222
  input.setAttribute('checked', '');
1215
1223
  check.setAttribute('aria-selected', 'true');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/main.js",
6
6
  "style": "dist/main.css",
@@ -231,6 +231,7 @@ class Filters {
231
231
  updateCount(options) {
232
232
  const id = uniqueId()
233
233
  const GroupArray = []
234
+
234
235
  if (options.array.length > 0) {
235
236
  options.array.forEach((element, index) => {
236
237
  const getEventType = this.constructor.getEventType(element.type)
@@ -307,22 +308,27 @@ class Filters {
307
308
  }
308
309
 
309
310
  selectedItems() {
310
- this.filtersItems.forEach((filter) => {
311
- const button = filter.querySelector('.nsw-filters__item-name')
312
- const content = filter.querySelector('.nsw-filters__item-content')
313
- const text = content ? content.querySelectorAll('input[type="text"]') : null
314
- const selects = content ? content.querySelectorAll('select') : null
315
- const checkboxes = content ? content.querySelectorAll('input[type="checkbox"]') : null
316
-
317
- if (!content) return
318
-
319
- this.updateCount({ array: text, title: button })
320
- this.updateCount({ array: selects, title: button })
321
- this.updateCount({ array: checkboxes, title: button })
322
- this.updateStatus({ array: text, title: button })
323
- this.updateStatus({ array: selects, title: button })
324
- this.updateStatus({ array: checkboxes, title: button })
325
- })
311
+ const stateCheck = setInterval(() => {
312
+ if (document.readyState === 'complete') {
313
+ clearInterval(stateCheck)
314
+ this.filtersItems.forEach((filter) => {
315
+ const button = filter.querySelector('.nsw-filters__item-name')
316
+ const content = filter.querySelector('.nsw-filters__item-content')
317
+ const text = content ? content.querySelectorAll('input[type="text"]') : null
318
+ const selects = content ? content.querySelectorAll('select') : null
319
+ const checkboxes = content ? content.querySelectorAll('input[type="checkbox"]:not([id$="-all"])') : null
320
+
321
+ if (!content) return
322
+
323
+ this.updateCount({ array: text, title: button })
324
+ this.updateCount({ array: selects, title: button })
325
+ this.updateCount({ array: checkboxes, title: button })
326
+ this.updateStatus({ array: text, title: button })
327
+ this.updateStatus({ array: selects, title: button })
328
+ this.updateStatus({ array: checkboxes, title: button })
329
+ })
330
+ }
331
+ }, 100)
326
332
  }
327
333
 
328
334
  clearAllFilters(e) {
@@ -333,7 +339,7 @@ class Filters {
333
339
  const content = filter.querySelector('.nsw-filters__item-content')
334
340
  const text = content.querySelectorAll('input[type="text"]')
335
341
  const selects = content.querySelectorAll('select')
336
- const checkboxes = content.querySelectorAll('input[type="checkbox"]')
342
+ const checkboxes = content.querySelectorAll('input[type="checkbox"]:not([id$="-all"])')
337
343
  const allFields = [...text, ...selects, ...checkboxes]
338
344
 
339
345
  if (!content) return
@@ -344,6 +350,7 @@ class Filters {
344
350
  if (this.constructor.getCondition(field) && (field.type === 'text' || field.type === 'select-one')) {
345
351
  field.value = ''
346
352
  } else {
353
+ field.click()
347
354
  field.checked = false
348
355
  }
349
356
  })
@@ -160,12 +160,14 @@ class Select {
160
160
  const input = check.querySelector('.nsw-form__checkbox-input')
161
161
 
162
162
  if (count === this.options.length) {
163
+ input.click()
163
164
  input.checked = false
164
165
  input.removeAttribute('checked')
165
166
  check.setAttribute('aria-selected', 'false')
166
167
 
167
168
  this.updateNativeSelect(check.getAttribute('data-index'), false)
168
169
  } else {
170
+ input.click()
169
171
  input.checked = true
170
172
  input.setAttribute('checked', '')
171
173
  check.setAttribute('aria-selected', 'true')