@iamproperty/components 3.2.0 → 3.4.4

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 (92) hide show
  1. package/assets/css/core.min.css.map +1 -1
  2. package/assets/css/style.min.css.map +1 -1
  3. package/assets/js/main.js +9 -9
  4. package/assets/js/modules/accordion.js +1 -0
  5. package/assets/js/modules/alert.js +37 -53
  6. package/assets/js/modules/carousel.js +74 -100
  7. package/assets/js/modules/chart.js +142 -209
  8. package/assets/js/modules/drawer.js +9 -15
  9. package/assets/js/modules/file-upload.js +30 -45
  10. package/assets/js/modules/form.js +111 -157
  11. package/assets/js/modules/helpers.js +64 -93
  12. package/assets/js/modules/modal.js +67 -88
  13. package/assets/js/modules/nav.js +17 -27
  14. package/assets/js/modules/orderablelist.js +84 -115
  15. package/assets/js/modules/table.js +387 -521
  16. package/assets/js/modules/testimonial.js +61 -80
  17. package/assets/js/modules/youtubevideo.js +104 -135
  18. package/assets/js/scripts.bundle.js +870 -936
  19. package/assets/js/scripts.bundle.js.map +1 -1
  20. package/assets/js/scripts.bundle.min.js +3 -3
  21. package/assets/js/scripts.bundle.min.js.map +1 -1
  22. package/assets/sass/_corefiles.scss +9 -9
  23. package/assets/sass/_forms.scss +1 -1
  24. package/assets/sass/_tests/{sass.spec.js → colours.spec.js} +2 -2
  25. package/assets/sass/_tests/func.spec.js +9 -0
  26. package/assets/sass/_tests/mixins.spec.js +9 -0
  27. package/assets/sass/_tests/typography.spec.js +9 -0
  28. package/assets/ts/main.ts +9 -9
  29. package/assets/ts/modules/accordion.ts +1 -0
  30. package/assets/ts/modules/alert.ts +58 -0
  31. package/assets/ts/modules/carousel.ts +103 -0
  32. package/assets/ts/modules/chart.ts +219 -0
  33. package/assets/ts/modules/drawer.ts +17 -0
  34. package/assets/ts/modules/file-upload.ts +49 -0
  35. package/assets/ts/modules/form.ts +169 -0
  36. package/assets/ts/modules/helpers.ts +120 -0
  37. package/assets/ts/modules/modal.ts +91 -0
  38. package/assets/ts/modules/nav.ts +29 -0
  39. package/assets/ts/modules/orderablelist.ts +123 -0
  40. package/assets/ts/modules/table.ts +586 -0
  41. package/assets/ts/modules/testimonial.ts +84 -0
  42. package/assets/ts/modules/youtubevideo.ts +146 -0
  43. package/dist/components.es.js +405 -421
  44. package/dist/components.umd.js +8 -8
  45. package/package.json +48 -35
  46. package/src/components/Accordion/Accordion.vue +1 -1
  47. package/src/components/Alert/Alert.vue +1 -1
  48. package/src/{elements → components}/Card/Card.vue +1 -1
  49. package/src/components/CardDeck/CardDeck.spec.js +1 -1
  50. package/src/components/CardDeck/CardDeck.vue +1 -1
  51. package/src/components/Carousel/Carousel.vue +2 -2
  52. package/src/components/Chart/Chart.vue +2 -2
  53. package/src/components/Drawer/Drawer.vue +1 -1
  54. package/src/{elements → components}/FileUploads/FileUploads.vue +1 -1
  55. package/src/components/Modal/Modal.vue +1 -1
  56. package/src/components/Nav/Nav.vue +2 -2
  57. package/src/components/NoteFeed/NoteFeed.vue +2 -2
  58. package/src/components/PropertySearchbar/PropertySearchbar.vue +1 -1
  59. package/src/{elements → components}/Table/Table.vue +1 -1
  60. package/src/components/Testimonial/Testimonial.vue +1 -1
  61. package/src/foundations/YoutubeVideo/YoutubeVideo.vue +1 -1
  62. package/src/index.js +4 -4
  63. package/assets/.DS_Store +0 -0
  64. package/assets/css/email.min.css +0 -1
  65. package/assets/css/email.min.css.map +0 -1
  66. package/assets/css/error.min.css +0 -1
  67. package/assets/css/error.min.css.map +0 -1
  68. package/assets/ts/main.js +0 -57
  69. package/assets/ts/main.js.map +0 -1
  70. package/assets/ts/modules/accordion.js +0 -33
  71. package/assets/ts/modules/accordion.js.map +0 -1
  72. package/src/.DS_Store +0 -0
  73. package/src/components/Accordion/Accordion.screenshot.vue +0 -57
  74. package/src/components/Accordion/__screenshots__/win32/laptop/Accordion.png +0 -0
  75. package/src/components/Accordion/__screenshots__/win32/mobile/Accordion.png +0 -0
  76. package/src/components/Accordion/__screenshots__/win32/tablet/Accordion.png +0 -0
  77. /package/assets/sass/{elements → components}/buttons.scss +0 -0
  78. /package/assets/sass/{elements → components}/card.scss +0 -0
  79. /package/assets/sass/{elements → components}/container.scss +0 -0
  80. /package/assets/sass/{elements → components}/forms.scss +0 -0
  81. /package/assets/sass/{elements → components}/links.scss +0 -0
  82. /package/assets/sass/{elements → components}/lists.scss +0 -0
  83. /package/assets/sass/{elements → components}/panel.scss +0 -0
  84. /package/assets/sass/{elements → components}/tables.scss +0 -0
  85. /package/assets/sass/{elements → components}/tooltips.scss +0 -0
  86. /package/assets/sass/{elements → foundations}/type.scss +0 -0
  87. /package/src/{elements → components}/Card/README.md +0 -0
  88. /package/src/{elements → components}/FileUploads/README.md +0 -0
  89. /package/src/{elements → components}/Input/Input.vue +0 -0
  90. /package/src/{elements → components}/Input/README.md +0 -0
  91. /package/src/{elements → components}/Table/README.md +0 -0
  92. /package/src/{elements → components}/Table/Table.spec.js +0 -0
@@ -1,48 +1,33 @@
1
+ // @ts-nocheck
1
2
  function fileupload(form, callback) {
2
-
3
- const input = form.querySelector('[type="file"]');
4
- const label = form.querySelector(`[for="${input.getAttribute('id')}"]`);
5
- const add = form.querySelector('.file-upload__add');
6
-
7
- form.querySelector('button').remove()
8
-
9
- input.addEventListener("change", function( e ) {
10
- // prevent default to allow drop
11
-
12
- let url = form.getAttribute('action');
13
- let formData = new FormData(form);
14
-
15
- input.setAttribute('disabled', 'disabled');
16
-
17
- fetch(url, {
18
- method: 'POST',
19
- body: formData
20
- })
21
- .then(() => {
22
-
23
- form.classList.add('file-uploaded')
24
- label.innerHTML = 'File uploaded';
25
-
26
- if(typeof callback == "function")
27
- callback();
28
- })
29
-
30
-
31
- }, false);
32
-
33
-
34
- form.addEventListener("submit", function( e ) {
35
- // prevent default to allow drop
36
- e.preventDefault();
37
- }, false);
38
-
39
- add.addEventListener("click", function( e ) {
40
-
41
- form.classList.remove('file-uploaded')
42
- label.innerHTML = 'Select a file to upload';
43
- input.removeAttribute('disabled');
44
-
45
- }, false);
3
+ const input = form.querySelector('[type="file"]');
4
+ const label = form.querySelector(`[for="${input.getAttribute('id')}"]`);
5
+ const add = form.querySelector('.file-upload__add');
6
+ form.querySelector('button').remove();
7
+ input.addEventListener("change", function (e) {
8
+ // prevent default to allow drop
9
+ let url = form.getAttribute('action');
10
+ let formData = new FormData(form);
11
+ input.setAttribute('disabled', 'disabled');
12
+ fetch(url, {
13
+ method: 'POST',
14
+ body: formData
15
+ })
16
+ .then(() => {
17
+ form.classList.add('file-uploaded');
18
+ label.innerHTML = 'File uploaded';
19
+ if (typeof callback == "function")
20
+ callback();
21
+ });
22
+ }, false);
23
+ form.addEventListener("submit", function (e) {
24
+ // prevent default to allow drop
25
+ e.preventDefault();
26
+ }, false);
27
+ add.addEventListener("click", function (e) {
28
+ form.classList.remove('file-uploaded');
29
+ label.innerHTML = 'Select a file to upload';
30
+ input.removeAttribute('disabled');
31
+ }, false);
46
32
  }
47
-
48
33
  export default fileupload;
@@ -1,168 +1,122 @@
1
+ // @ts-nocheck
1
2
  // Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
2
3
  // The link between the two will prevent the max input field form setting a lower value than the min and vice versa
3
- function inputRange(inputWrapper){
4
-
5
- inputWrapper.addEventListener('change', function(e){
6
-
7
- var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
8
- var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
9
-
10
- // Set attributes for input fields
11
- Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
12
-
13
- input.setAttribute('max',max);
14
- });
15
-
16
- Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
17
-
18
- input.setAttribute('min',min);
19
- });
20
-
21
- // Hide select options if they are higher or lower than the min and max values
22
- Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
23
-
24
- if(parseInt(option.getAttribute('value')) > max)
25
- option.classList.add('d-none');
26
- else
27
- option.classList.remove('d-none');
28
- });
29
-
30
- Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
31
-
32
- if(parseInt(option.getAttribute('value')) < min)
33
- option.classList.add('d-none');
34
- else
35
- option.classList.remove('d-none');
36
- });
37
-
38
- }, false);
4
+ function inputRange(inputWrapper) {
5
+ inputWrapper.addEventListener('change', function (e) {
6
+ var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
7
+ var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
8
+ // Set attributes for input fields
9
+ Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
10
+ input.setAttribute('max', max);
11
+ });
12
+ Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
13
+ input.setAttribute('min', min);
14
+ });
15
+ // Hide select options if they are higher or lower than the min and max values
16
+ Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
17
+ if (parseInt(option.getAttribute('value')) > max)
18
+ option.classList.add('d-none');
19
+ else
20
+ option.classList.remove('d-none');
21
+ });
22
+ Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
23
+ if (parseInt(option.getAttribute('value')) < min)
24
+ option.classList.add('d-none');
25
+ else
26
+ option.classList.remove('d-none');
27
+ });
28
+ }, false);
39
29
  }
40
-
41
- function inputRedirect(inputWrapper){
42
-
43
-
44
- inputWrapper.addEventListener('change', function(e){
45
-
46
- if(inputWrapper.matches('[data-value-if]')) {
47
-
48
- const url = inputWrapper.getAttribute('data-redirect');
49
- const desiredValue = inputWrapper.getAttribute('data-value-if');
50
-
51
- if(inputWrapper.value == desiredValue)
52
- document.location.href = url;
53
- }
54
- else {
55
-
56
- if(typeof inputWrapper.value != "undefined")
57
- document.location.href = inputWrapper.value;
58
- }
59
-
60
- }, false);
30
+ function inputRedirect(inputWrapper) {
31
+ inputWrapper.addEventListener('change', function (e) {
32
+ if (inputWrapper.matches('[data-value-if]')) {
33
+ const url = inputWrapper.getAttribute('data-redirect');
34
+ const desiredValue = inputWrapper.getAttribute('data-value-if');
35
+ if (inputWrapper.value == desiredValue)
36
+ document.location.href = url;
37
+ }
38
+ else {
39
+ if (typeof inputWrapper.value != "undefined")
40
+ document.location.href = inputWrapper.value;
41
+ }
42
+ }, false);
61
43
  }
62
-
63
44
  //
64
- function multipleFileUploads(wrapper){
65
-
66
- const fileTenplate = wrapper.querySelector('.row');
67
- const clone = fileTenplate.cloneNode(true);
68
- const addButton = wrapper.querySelector('[data-add]');
69
-
70
- wrapper.addEventListener('click', function(e){
71
- for (var target = e.target; target && target != this; target = target.parentNode) {
72
- if (target.matches('[data-add]')) { // Add a new row upload file input fields
73
-
74
- const tempClone = clone.cloneNode(true);
75
- wrapper.insertBefore(tempClone,target);
76
-
77
- if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles)
78
- addButton.setAttribute('disabled','disabled');
79
-
80
- break;
81
- }
82
- if (target.matches('[data-delete]')) { // Delete the current row
83
-
84
- let row = target.closest('.row');
85
- row.remove();
86
-
87
- if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles)
88
- addButton.removeAttribute('disabled');
89
-
90
- break;
91
- }
92
- }
93
-
94
- }, false);
45
+ function multipleFileUploads(wrapper) {
46
+ const fileTenplate = wrapper.querySelector('.row');
47
+ const clone = fileTenplate.cloneNode(true);
48
+ const addButton = wrapper.querySelector('[data-add]');
49
+ wrapper.addEventListener('click', function (e) {
50
+ for (var target = e.target; target && target != this; target = target.parentNode) {
51
+ if (target.matches('[data-add]')) { // Add a new row upload file input fields
52
+ const tempClone = clone.cloneNode(true);
53
+ wrapper.insertBefore(tempClone, target);
54
+ if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles)
55
+ addButton.setAttribute('disabled', 'disabled');
56
+ break;
57
+ }
58
+ if (target.matches('[data-delete]')) { // Delete the current row
59
+ let row = target.closest('.row');
60
+ row.remove();
61
+ if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles)
62
+ addButton.removeAttribute('disabled');
63
+ break;
64
+ }
65
+ }
66
+ }, false);
95
67
  }
96
-
97
68
  // Acts as an overall initialise function to trigger other functions.
98
69
  function form(formElement) {
99
-
100
- // Check for input range groups
101
- Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
102
- inputRange(arrayElement);
103
- });
104
-
105
- Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
106
- inputRedirect(arrayElement);
107
- });
108
-
109
- Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
110
- multipleFileUploads(arrayElement);
111
- });
112
-
113
-
114
- // Check the file size of a file when uploaded in case it exceeds the max file size set
115
- formElement.addEventListener('change', function(e){
116
- for (var target = e.target; target && target != this; target = target.parentNode) {
117
- if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
118
-
119
- const maxAllowedSize = target.dataset.filesize;
120
- if (target.files[0].size > maxAllowedSize) {
121
-
122
- target.value = '';
123
- alert('File too large');
124
- }
125
- break;
126
- }
127
- }
128
- }, false);
129
-
130
-
131
- // When a form is updated we may want to update some of the existing input fields; setting active fields when some data is selected.
132
- formElement.addEventListener('change', function(e){
133
-
134
- // Remove disabled attribute when a pre-selected input field equals a certain value
135
- Array.from(formElement.querySelectorAll('select[data-activeif][data-equals],input[data-activeif][data-equals]')).forEach((arrayElement, index) => {
136
-
137
- let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
138
- let selector = arrayElement.dataset.activeif;
139
- let value = arrayElement.dataset.equals;
140
- let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
141
-
142
- if(testElement.value == value){
143
- arrayElement.removeAttribute('disabled');
144
- }
145
- else {
146
- arrayElement.setAttribute('disabled','disabled');
147
- arrayElement.value = '';
148
- }
70
+ // Check for input range groups
71
+ Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
72
+ inputRange(arrayElement);
73
+ });
74
+ Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
75
+ inputRedirect(arrayElement);
149
76
  });
150
-
151
- // Show this input wrapper when a pre-selected input field equals a certain value
152
- Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
153
-
154
- let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
155
- let selector = arrayElement.dataset.activeif;
156
- let value = arrayElement.dataset.equals;
157
- let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
158
-
159
- if(testElement.value == value)
160
- arrayElement.classList.remove('d-none');
161
- else
162
- arrayElement.classList.add('d-none');
77
+ Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
78
+ multipleFileUploads(arrayElement);
163
79
  });
164
-
165
- }, false);
80
+ // Check the file size of a file when uploaded in case it exceeds the max file size set
81
+ formElement.addEventListener('change', function (e) {
82
+ for (var target = e.target; target && target != this; target = target.parentNode) {
83
+ if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
84
+ const maxAllowedSize = target.dataset.filesize;
85
+ if (target.files[0].size > maxAllowedSize) {
86
+ target.value = '';
87
+ alert('File too large');
88
+ }
89
+ break;
90
+ }
91
+ }
92
+ }, false);
93
+ // When a form is updated we may want to update some of the existing input fields; setting active fields when some data is selected.
94
+ formElement.addEventListener('change', function (e) {
95
+ // Remove disabled attribute when a pre-selected input field equals a certain value
96
+ Array.from(formElement.querySelectorAll('select[data-activeif][data-equals],input[data-activeif][data-equals]')).forEach((arrayElement, index) => {
97
+ let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
98
+ let selector = arrayElement.dataset.activeif;
99
+ let value = arrayElement.dataset.equals;
100
+ let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
101
+ if (testElement.value == value) {
102
+ arrayElement.removeAttribute('disabled');
103
+ }
104
+ else {
105
+ arrayElement.setAttribute('disabled', 'disabled');
106
+ arrayElement.value = '';
107
+ }
108
+ });
109
+ // Show this input wrapper when a pre-selected input field equals a certain value
110
+ Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
111
+ let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
112
+ let selector = arrayElement.dataset.activeif;
113
+ let value = arrayElement.dataset.equals;
114
+ let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
115
+ if (testElement.value == value)
116
+ arrayElement.classList.remove('d-none');
117
+ else
118
+ arrayElement.classList.add('d-none');
119
+ });
120
+ }, false);
166
121
  }
167
-
168
- export default form
122
+ export default form;
@@ -1,119 +1,90 @@
1
- /**
1
+ // @ts-nocheck
2
+ /**
2
3
  * Global helper functions to help maintain and enhance framework elements.
3
- * @module Helpers
4
+ * @module Helpers
4
5
  */
5
-
6
6
  /**
7
7
  * Add global classes used by the CSS and later JavaScript.
8
8
  * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
9
9
  */
10
- export const addBodyClasses = (body) => {
11
-
12
- body.classList.add("js-enabled");
13
-
14
- if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
15
-
16
- body.classList.add("ie");
17
- }
18
-
19
- return null
20
- }
21
-
10
+ export const addBodyClasses = (body) => {
11
+ body.classList.add("js-enabled");
12
+ if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
13
+ body.classList.add("ie");
14
+ }
15
+ return null;
16
+ };
22
17
  /**
23
18
  * Add global events.
24
19
  * @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
25
20
  */
26
21
  export const addGlobalEvents = (body) => {
27
-
28
- window.addEventListener('hashchange', function() {
29
-
30
- const hash = location.hash.replace('#','');
31
- const label = document.querySelector(`label[for="${hash}"]`);
32
- const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
33
-
34
- if(label)
35
- label.click();
36
- else if(detail)
37
- detail.setAttribute('open','open');
38
-
39
- }, false);
40
-
41
- return null
42
- }
43
-
22
+ window.addEventListener('hashchange', function () {
23
+ const hash = location.hash.replace('#', '');
24
+ const label = document.querySelector(`label[for="${hash}"]`);
25
+ const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
26
+ if (label)
27
+ label.click();
28
+ else if (detail)
29
+ detail.setAttribute('open', 'open');
30
+ }, false);
31
+ return null;
32
+ };
44
33
  /**
45
- * Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
34
+ * Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
46
35
  * @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
47
36
  */
48
37
  export const checkElements = (element) => {
49
-
50
- // Tables
51
- Array.from(element.querySelectorAll('table')).forEach((table, index) => {
52
-
53
- tableStacked(table);
54
- tableWrap(table);
55
- });
56
- }
57
-
38
+ // Tables
39
+ Array.from(element.querySelectorAll('table')).forEach((table, index) => {
40
+ tableStacked(table);
41
+ tableWrap(table);
42
+ });
43
+ };
58
44
  /**
59
45
  * Wrap tables with a table wrapper div to help maintain its responsive design.
60
46
  * @param {HTMLElement} table Dom table element
61
47
  */
62
48
  export const tableWrap = (table) => {
63
-
64
- if(!table.parentNode.classList.contains('table__wrapper')){
65
-
66
- const tableHTML = table.outerHTML;
67
-
68
- table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
69
- }
70
- }
71
-
49
+ if (!table.parentNode.classList.contains('table__wrapper')) {
50
+ const tableHTML = table.outerHTML;
51
+ table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
52
+ }
53
+ };
72
54
  /**
73
55
  * Creates data attributes to be used by the CSS for mobile views.
74
56
  * @param {HTMLElement} table Dom table element
75
57
  */
76
58
  export const tableStacked = (table) => {
77
-
78
- const colHeadings = Array.from(table.querySelectorAll('thead th'));
79
- const colRows = Array.from(table.querySelectorAll('tbody tr'));
80
-
81
- colRows.forEach((row, index) => {
82
-
83
- const cells = Array.from(row.querySelectorAll('th, td'));
84
-
85
- cells.forEach((cell, cellIndex) => {
86
-
87
- const heading = colHeadings[cellIndex];
88
- if(typeof heading != "undefined"){
89
-
90
- let tempDiv = document.createElement("div");
91
- tempDiv.innerHTML = heading.innerHTML;
92
- let headingText = tempDiv.textContent || tempDiv.innerText || "";
93
- cell.setAttribute('data-label',headingText);
94
- }
59
+ const colHeadings = Array.from(table.querySelectorAll('thead th'));
60
+ const colRows = Array.from(table.querySelectorAll('tbody tr'));
61
+ colRows.forEach((row, index) => {
62
+ const cells = Array.from(row.querySelectorAll('th, td'));
63
+ cells.forEach((cell, cellIndex) => {
64
+ const heading = colHeadings[cellIndex];
65
+ if (typeof heading != "undefined") {
66
+ let tempDiv = document.createElement("div");
67
+ tempDiv.innerHTML = heading.innerHTML;
68
+ let headingText = tempDiv.textContent || tempDiv.innerText || "";
69
+ cell.setAttribute('data-label', headingText);
70
+ }
71
+ });
95
72
  });
96
- });
97
- }
98
-
99
-
100
- export const isNumeric = function(str) {
101
- if (typeof str != "string") return false // we only process strings!
102
- return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
103
- !isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
104
- }
105
-
106
- export const zeroPad = (num, places) => String(num).padStart(places, '0')
107
-
108
- export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
109
- export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ')
110
- export const unsnake = (str) => str.replace(/_/g, ' ')
111
- export const snake = (str) => str.replace(/ /g, '_')
112
- export const safeID = function(str){
113
-
114
- str = str.toLowerCase();
115
- str = snake(str);
116
- str = str.replace(/\W/g,'');
117
-
118
- return str;
119
- }
73
+ };
74
+ export const isNumeric = function (str) {
75
+ if (typeof str != "string")
76
+ return false; // we only process strings!
77
+ return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
78
+ !isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail
79
+ };
80
+ export const zeroPad = (num, places) => String(num).padStart(places, '0');
81
+ export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);
82
+ export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ');
83
+ export const unsnake = (str) => str.replace(/_/g, ' ');
84
+ export const snake = (str) => str.replace(/ /g, '_');
85
+ export const safeID = function (str) {
86
+ str = str.toLowerCase();
87
+ str = snake(str);
88
+ str = str.replace(/\W/g, '');
89
+ return str;
90
+ };