@iamproperty/components 3.7.1 → 3.7.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.
Files changed (36) hide show
  1. package/assets/css/components/dialog.css +1 -1
  2. package/assets/css/components/dialog.css.map +1 -1
  3. package/assets/css/components/pagination.css +1 -1
  4. package/assets/css/components/pagination.css.map +1 -1
  5. package/assets/css/components/table.css +1 -1
  6. package/assets/css/components/table.css.map +1 -1
  7. package/assets/css/core.min.css +1 -1
  8. package/assets/css/core.min.css.map +1 -1
  9. package/assets/css/style.min.css +1 -1
  10. package/assets/css/style.min.css.map +1 -1
  11. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  12. package/assets/js/components/applied-filters/applied-filters.component.min.js +14 -0
  13. package/assets/js/components/applied-filters/applied-filters.component.min.js.map +1 -0
  14. package/assets/js/components/card/card.component.min.js +1 -1
  15. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  16. package/assets/js/components/header/header.component.min.js +1 -1
  17. package/assets/js/components/pagination/pagination.component.min.js +18 -0
  18. package/assets/js/components/pagination/pagination.component.min.js.map +1 -0
  19. package/assets/js/components/table/table.component.js +1 -0
  20. package/assets/js/components/table/table.component.min.js +13 -13
  21. package/assets/js/components/table/table.component.min.js.map +1 -1
  22. package/assets/js/components/tabs/tabs.component.min.js +1 -1
  23. package/assets/js/dynamic.min.js +1 -1
  24. package/assets/js/modules/table.js +137 -68
  25. package/assets/js/scripts.bundle.js +19 -19
  26. package/assets/js/scripts.bundle.js.map +1 -1
  27. package/assets/js/scripts.bundle.min.js +2 -2
  28. package/assets/js/scripts.bundle.min.js.map +1 -1
  29. package/assets/sass/components/dialog.scss +11 -0
  30. package/assets/sass/components/pagination.scss +2 -1
  31. package/assets/sass/components/table.scss +63 -38
  32. package/assets/ts/components/table/table.component.ts +1 -0
  33. package/assets/ts/modules/table.ts +147 -69
  34. package/dist/components.es.js +726 -690
  35. package/dist/components.umd.js +21 -21
  36. package/package.json +1 -1
@@ -510,6 +510,17 @@ dialog::backdrop {
510
510
  }
511
511
 
512
512
  // Show hide the indidual or multiple label
513
+ .dialog__wrapper :is(.empty, .individual) {
514
+ display: none;
515
+ }
516
+
517
+ @supports selector(:has(*)) {
518
+
519
+ .dialog__wrapper :is(.empty, .individual) {
520
+ display: inline;
521
+ }
522
+ }
523
+
513
524
  .dialog__wrapper:has(input:checked) .empty,
514
525
  .dialog__wrapper:not(:has(input:checked)) .individual,
515
526
  .dialog__wrapper:has(input:checked ~ input:checked) .individual,
@@ -76,6 +76,7 @@
76
76
 
77
77
  .page-item {
78
78
  display: none;
79
+ overflow: visible;
79
80
  }
80
81
 
81
82
  .page-item:is(:first-child, :last-child, :nth-child(2), :nth-last-child(2)) {
@@ -122,7 +123,7 @@
122
123
 
123
124
  &:after {
124
125
  left: auto;
125
- right: calc(100% + #{rem(4)} + 2px);
126
+ right: calc(100% + #{rem(4)} + 1px);
126
127
  }
127
128
  }
128
129
 
@@ -58,13 +58,34 @@ thead {
58
58
  }
59
59
  }
60
60
 
61
+ // Error messages
62
+ tr td[colspan="100%"]:first-child:last-child span {
63
+
64
+ max-width: rem(624);
65
+ font-weight: bold;
66
+ padding: 3rem;
67
+ text-align: center;
68
+ display: block;
69
+ color: var(--colour-heading);
70
+
71
+ @include media-breakpoint-up(md) {
72
+ max-width: rem(1048);
73
+ }
74
+ }
75
+
61
76
  @container (width >= 60em) {
62
77
  thead {
63
78
 
64
79
  th {
65
80
  white-space: nowrap;
66
- min-width: #{$td-mw};
67
- }
81
+ min-width: #{$td-mw};
82
+ }
83
+ th.th--mw-md {
84
+ min-width: rem(240);
85
+ }
86
+ th.th--mw-lg {
87
+ min-width: rem(360);
88
+ }
68
89
  }
69
90
  }
70
91
 
@@ -79,30 +100,12 @@ tbody tr {
79
100
 
80
101
  th,td {
81
102
  background: var(--hover-background);
82
- color: var(--colour-primary-theme);
103
+ //color: var(--colour-primary-theme);
83
104
  --colour-link: var(--colour-primary-theme);
84
105
  --colour-hover: var(--colour-primary-theme);
85
106
  }
86
107
  }
87
108
 
88
- /*
89
- :is(td, th) {
90
-
91
- border-top: var(--border-width) solid currentColor;
92
- @include var(border-color,--colour-border);
93
- }
94
-
95
-
96
- &:first-child :is(td, th){
97
- border-top: var(--border-width) solid currentColor;
98
- @include var(border-color,--colour-primary);
99
- }
100
-
101
- &:last-child :is(td, th){
102
- border-bottom: var(--border-width) solid currentColor;
103
- @include var(border-color,--colour-border);
104
- }
105
- */
106
109
  }
107
110
 
108
111
  .border-0 > table,
@@ -123,6 +126,7 @@ table.border-0 {
123
126
  box-shadow: 0px 6px 12px rgba(0,0,0,0.11);
124
127
  border-radius: rem(8);
125
128
  margin-bottom: rem(32);
129
+ overflow: hidden;
126
130
 
127
131
  &:before {
128
132
  display: none!important;
@@ -246,7 +250,7 @@ table.border-0 {
246
250
  top: 2.5rem;
247
251
  }
248
252
 
249
- tbody tr:first-child td:not(:first-child) {
253
+ tbody tr td:not(:first-child) {
250
254
  border-top: var(--border-width) solid currentColor!important;
251
255
  border-color: var(--colour-border)!important;
252
256
  }
@@ -312,7 +316,7 @@ table.border-0 {
312
316
  display: none !important;;
313
317
  }
314
318
  }
315
- .table--cta:not(.table--fullwidth) tr td:last-child {
319
+ .table--cta:not(.table--fullwidth) tr td:not(:first-child):last-child {
316
320
  display: block!important;
317
321
  position: static;
318
322
  width: 100%;
@@ -331,44 +335,48 @@ table.border-0 {
331
335
  // #endregion
332
336
 
333
337
  // #region CTA column
334
- @include media-breakpoint-up(sm) {
338
+ @container (width > 23.4375em) {
335
339
 
336
340
  :is(iam-table) {
337
341
 
338
342
  --cta-width: 8rem;
339
343
  }
340
344
 
345
+ :is(iam-table).table--loading {
346
+
347
+ --cta-width: 1.5rem!important;
348
+ }
349
+
341
350
  :not(iam-table).table--cta {
342
351
 
343
352
  position: relative;
344
353
  margin-right: calc(var(--cta-width) - 1.5rem);
345
-
346
-
347
354
  }
348
355
 
349
356
  .table--cta .table__wrapper {
350
357
  overflow-y: hidden;
351
358
  margin-bottom: 0;
352
359
  }
353
-
354
- .table--cta {
360
+
361
+ .table--cta:not(.table--loading):has(tr:first-child td:first-child:last-child) {
362
+ padding-right: calc(var(--wrapper-padding) + 1.5rem);
363
+ }
364
+ .table--cta:not(.table--loading):not(:has(tr:first-child td:first-child:last-child)) {
355
365
 
356
- tr > *:last-child {
366
+ tr > *:not(:first-child):last-child {
357
367
 
358
368
  position: absolute;
359
369
  left: 100%;
360
370
  top: auto;
361
371
  z-index: 3;
362
372
  background: transparent;
363
- width: calc(var(--cta-width) + 1.5rem);
373
+ width: calc(var(--cta-width) + 1rem);
364
374
  padding-left: rem(40);
365
375
  margin-left: rem(-40);
366
376
  min-height: var(--row-height);
367
377
  text-align: right;
368
378
  background: linear-gradient(90deg, transparent 0%, var(--colour-canvas-2) 1.25rem);
369
379
 
370
- //border-bottom: var(--border-width) solid var(--colour-border);
371
-
372
380
  &:after {
373
381
  bottom: 0;
374
382
  left: 0;
@@ -381,18 +389,19 @@ table.border-0 {
381
389
 
382
390
  a {
383
391
  white-space: nowrap;
392
+ padding-right: 0.2rem;
384
393
  }
385
394
  }
386
395
 
387
- tr > th:last-child {
396
+ tr > th:not(:first-child):last-child {
388
397
  --colour-border: var(--colour-primary);
389
398
  }
390
399
 
391
- tbody tr:hover > *:last-child {
400
+ tbody tr:hover > *:not(:first-child):last-child {
392
401
  background: linear-gradient(90deg, transparent 0%, var(--hover-background) 1.25rem);
393
402
  }
394
403
 
395
- thead tr > *:last-child {
404
+ thead tr > *:not(:first-child):last-child {
396
405
  margin-top: 1px;
397
406
  }
398
407
  }
@@ -470,11 +479,27 @@ table:not(.table--filtered):not(.table--ajax) tbody tr:nth-child(15) ~ tr {
470
479
 
471
480
  // Loading via ajax
472
481
  .table--loading {
473
- opacity: 0.8;
474
482
  pointer-events: none;
483
+ position: relative;
475
484
 
476
- &.table--cta thead th:last-child {
477
- opacity: 0;
485
+ table {
486
+ min-height: 20rem;
487
+ opacity: 0.5;
488
+ }
489
+
490
+ &::after {
491
+ content: "Loading...";
492
+ position: absolute;
493
+ top: rem(100);
494
+ left: 50%;
495
+ transform: translate(-50%,0);
496
+ font-weight: bold;
497
+ color: var(--colour-heading);
498
+ font-size: 1.5rem;
499
+ text-shadow: 0px 0px 10px var(--colour-canvas-2);
500
+ padding-inline: 2rem;
501
+ text-shadow: 0px 0px 10px var(--colour-canvas-2);
502
+ background: radial-gradient(var(--colour-canvas-2), transparent);
478
503
  }
479
504
  }
480
505
 
@@ -15,6 +15,7 @@ class iamTable extends HTMLElement {
15
15
  let classList = this.classList.toString();
16
16
 
17
17
  classList = classList.replace('table--cta','');
18
+ classList = classList.replace('table--loading','');
18
19
 
19
20
  const template = document.createElement('template');
20
21
  template.innerHTML = `
@@ -43,20 +43,18 @@ export const getLargestLastColWidth = (table) => {
43
43
 
44
44
  let largestWidth = 0;
45
45
 
46
- Array.from(table.querySelectorAll('tr')).forEach((row, index) => {
46
+ Array.from(table.querySelectorAll('tbody tr')).forEach((row, index) => {
47
47
 
48
48
  let htmlStyles = window.getComputedStyle(document.querySelector('html'));
49
49
  let lastColChild = row.querySelector(':scope > *:last-child > *:first-child');
50
50
 
51
51
  if(lastColChild){
52
52
 
53
+ lastColChild.classList.add('text-nowrap');
53
54
  let responsiveWidth = lastColChild.offsetWidth/parseFloat(htmlStyles.fontSize);
54
- responsiveWidth += 1.5;
55
+ responsiveWidth += 1.7;
55
56
  largestWidth = largestWidth > responsiveWidth ? largestWidth : responsiveWidth;
56
57
  }
57
-
58
- let rowHeight = row.offsetHeight/parseFloat(htmlStyles.fontSize);
59
- row.style.setProperty("--row-height", `${rowHeight}rem`);
60
58
  });
61
59
 
62
60
  return largestWidth;
@@ -284,8 +282,8 @@ export const addFilterEventListeners = (table, form, pagination, wrapper, savedT
284
282
  if(!forms.includes(parentForm))
285
283
  forms.push(parentForm);
286
284
 
287
- if(!fields.includes(mimicInput))
288
- fields.push(mimicInput);
285
+ if(!fields.includes(mimicField))
286
+ fields.push(mimicField);
289
287
 
290
288
  });
291
289
  });
@@ -297,7 +295,7 @@ export const addFilterEventListeners = (table, form, pagination, wrapper, savedT
297
295
  const updateMimicInput = function(){
298
296
  let mimickedAlready = [];
299
297
  let formData = new FormData(parentForm);
300
-
298
+
301
299
  let i = 1;
302
300
  for (const [key, value] of formData) {
303
301
 
@@ -316,6 +314,19 @@ export const addFilterEventListeners = (table, form, pagination, wrapper, savedT
316
314
  const event = new Event("force");
317
315
  form.dispatchEvent(event);
318
316
  }
317
+
318
+
319
+ // Check for empties
320
+ for (const field of fields) {
321
+ if(!formData.has(field) && parentForm.querySelector(`[name="${field}"]`)){
322
+
323
+ document.querySelector(`[data-mimic="${field}"]`).value = "";
324
+
325
+ const event = new Event("force");
326
+ form.dispatchEvent(event);
327
+ }
328
+ }
329
+
319
330
  }
320
331
 
321
332
  parentForm.addEventListener('force', (event) => {
@@ -767,10 +778,22 @@ export const makeTableFunctional = function(table, form, pagination, wrapper){
767
778
 
768
779
  const largestWidth = getLargestLastColWidth(table);
769
780
  wrapper.style.setProperty("--cta-width", `${largestWidth}rem`);
781
+
782
+ function outputsize() {
783
+
784
+ Array.from(table.querySelectorAll('tr')).forEach((row, index) => {
785
+ let rowHeight = row.offsetHeight;
786
+ row.style.setProperty("--row-height", `${rowHeight}px`);
787
+ });
788
+ }
789
+
790
+ new ResizeObserver(outputsize).observe(table)
770
791
  }
771
792
  }
772
793
 
773
- export const loadAjaxTable = function (table, form, pagination, wrapper){
794
+
795
+
796
+ export const loadAjaxTable = async function (table, form, pagination, wrapper){
774
797
 
775
798
  const resolvePath = (object, path, defaultValue) => path.split(/[\.\[\]\'\"]/).filter(p => p).reduce((o, p) => o ? o[p] : defaultValue, object);
776
799
 
@@ -778,89 +801,144 @@ export const loadAjaxTable = function (table, form, pagination, wrapper){
778
801
  let queryString = new URLSearchParams(formData).toString();
779
802
  let columns = table.querySelectorAll('thead tr th');
780
803
  let tbody = table.querySelector('tbody');
804
+ let ajaxURL = form.getAttribute('data-ajax');
781
805
 
782
806
  wrapper.classList.add('table--loading');
783
-
784
- fetch(form.getAttribute('data-ajax')+'?'+queryString, {
785
- method: 'get',
786
- credentials: 'same-origin',
787
- headers: new Headers({
788
- 'Content-Type': 'application/json',
789
- Accept: 'application/json',
790
- 'X-Requested-With': 'XMLHttpRequest'
807
+
808
+ // Setup controller vars if not already set
809
+ if(!window.controller)
810
+ window.controller = [];
811
+
812
+ // Abort if controller already present for this url
813
+ if(window.controller[ajaxURL])
814
+ window.controller[ajaxURL].abort();
815
+
816
+ // Create a new controller so it can be aborted if new fetch made
817
+ window.controller[ajaxURL] = new AbortController();
818
+ const { signal } = controller[ajaxURL];
819
+
820
+ try {
821
+ await fetch(ajaxURL+'?'+queryString, {
822
+ signal: signal,
823
+ method: 'get',
824
+ credentials: 'same-origin',
825
+ headers: new Headers({
826
+ 'Content-Type': 'application/json',
827
+ Accept: 'application/json',
828
+ 'X-Requested-With': 'XMLHttpRequest'
829
+ })
791
830
  })
792
- }).then((response) => response.json()).then((response) => {
831
+ .then((response) => response.json()).then((response) => {
793
832
 
794
- let schema = form.hasAttribute('data-schema') ? form.getAttribute('data-schema') : 'data';
795
- let totalNumberSchema = form.hasAttribute('data-schema-total') ? form.getAttribute('data-schema-total') : 'meta.total';
796
- let currentPageSchema = form.hasAttribute('data-schema-page') ? form.getAttribute('data-schema-page') : 'meta.current_page';
833
+ let schema = form.hasAttribute('data-schema') ? form.getAttribute('data-schema') : 'data';
834
+ let totalNumberSchema = form.hasAttribute('data-schema-total') ? form.getAttribute('data-schema-total') : 'meta.total';
835
+ let currentPageSchema = form.hasAttribute('data-schema-page') ? form.getAttribute('data-schema-page') : 'meta.current_page';
797
836
 
798
- let totalNumber = resolvePath(response, totalNumberSchema, 1);
799
- let currentPage = resolvePath(response, currentPageSchema, 1);
800
- let data = resolvePath(response, schema);
801
-
802
- if (data) {
837
+ let totalNumber = resolvePath(response, totalNumberSchema, 1);
838
+ let currentPage = resolvePath(response, currentPageSchema, 1);
839
+ let data = resolvePath(response, schema);
840
+ let emptyMsg = wrapper.hasAttribute('data-empty-msg') ? wrapper.getAttribute('data-empty-msg') : "No results found";
841
+
842
+ if (data) {
803
843
 
804
- tbody.innerHTML = '';
844
+ tbody.innerHTML = '';
805
845
 
806
- data.forEach((row, index) => {
846
+ data.forEach((row, index) => {
807
847
 
808
- var table_row = document.createElement('tr');
848
+ var table_row = document.createElement('tr');
809
849
 
810
- columns.forEach((col, index) => {
850
+ columns.forEach((col, index) => {
811
851
 
812
- let cellOutput = '';
813
- var table_cell = document.createElement('td');
814
- // Add some data to help with the mobile layout design
815
- table_cell.setAttribute('data-label',col.innerText);
852
+ let cellOutput = '';
853
+ var table_cell = document.createElement('td');
854
+ // Add some data to help with the mobile layout design
855
+ table_cell.setAttribute('data-label',col.innerText);
816
856
 
817
- if(col.getAttribute('data-output')){
818
- var cellTemplate = col.getAttribute('data-output');
819
- // Use a regex to replace {var} with actual values from the json data
820
- cellOutput = cellTemplate.replace( new RegExp(/{(.*?)}/,"gm"), function(matched){ return resolvePath(row, matched.replace('{','').replace('}','')); });
821
- }
857
+ if(col.getAttribute('data-output')){
858
+ var cellTemplate = col.getAttribute('data-output');
859
+ // Use a regex to replace {var} with actual values from the json data
860
+ cellOutput = cellTemplate.replace( new RegExp(/{(.*?)}/,"gm"), function(matched){ return resolvePath(row, matched.replace('{','').replace('}','')); });
861
+ }
822
862
 
823
- if(col.hasAttribute('data-transform')){
863
+ // If an output array is defined then the content is going to made of of multiple values from an array
864
+ if(col.hasAttribute('data-output-array')){
865
+
866
+ var cellTemplate = col.getAttribute('data-output');
867
+ let arrValue = resolvePath(row, cellTemplate.replace('{','').replace('}',''));
824
868
 
825
- const transforms = JSON.parse(col.getAttribute('data-transform'));
826
- cellOutput = transforms[cellOutput];
869
+ cellOutput = "";
870
+ arrValue.forEach((rowValue, i) => {
827
871
 
828
- if(!cellOutput && col.hasAttribute('data-default'))
829
- cellOutput = col.getAttribute('data-default');
830
- }
872
+ let cellTemplateValue = col.getAttribute('data-output-array');
873
+ let cellOutputValue = "";
874
+
875
+ // If we need to transform some of the data
876
+ if(col.hasAttribute('data-output-array-property') && col.hasAttribute('data-output-array-transform')){
877
+
878
+ const propertyValue = resolvePath(rowValue, col.getAttribute('data-output-array-property'));
879
+ const transforms = JSON.parse(col.getAttribute('data-output-array-transform'));
880
+ const transformValue = transforms[propertyValue];
881
+
882
+ cellOutputValue = cellTemplateValue.replace(`{${col.getAttribute('data-output-array-property')}}`,transformValue);
883
+ }
884
+
885
+ cellOutputValue = cellOutputValue.replace( new RegExp(/{(.*?)}/,"gm"), function(matched){ return resolvePath(rowValue, matched.replace('{','').replace('}','')); });
886
+ cellOutput += cellOutputValue;
887
+ });
888
+ }
889
+
890
+
891
+ if(col.hasAttribute('data-transform')){
892
+
893
+ const transforms = JSON.parse(col.getAttribute('data-transform'));
894
+ cellOutput = transforms[cellOutput];
895
+
896
+ if(!cellOutput && col.hasAttribute('data-default'))
897
+ cellOutput = col.getAttribute('data-default');
898
+ }
899
+
900
+ table_cell.innerHTML = cellOutput;
901
+ table_row.appendChild(table_cell)
902
+ });
831
903
 
832
- table_cell.innerHTML = cellOutput;
833
- table_row.appendChild(table_cell)
904
+ tbody.appendChild(table_row)
834
905
  });
835
906
 
836
- tbody.appendChild(table_row)
837
- });
907
+ createSearchDataList(table, form)
908
+ // Add data to the pagination
909
+ wrapper.setAttribute('data-total', parseInt(totalNumber));
910
+ wrapper.setAttribute('data-page', parseInt(currentPage));
911
+ wrapper.setAttribute('data-pages', Math.ceil(wrapper.getAttribute('data-total') / wrapper.getAttribute('data-show')));
838
912
 
839
- createSearchDataList(table, form)
840
- // Add data to the pagination
913
+ makeTableFunctional(table, form, pagination, wrapper);
914
+ createPaginationButttons(wrapper, pagination);
841
915
 
842
- wrapper.setAttribute('data-total', parseInt(totalNumber));
843
- wrapper.setAttribute('data-page', parseInt(currentPage));
844
- wrapper.setAttribute('data-pages', Math.ceil(wrapper.getAttribute('data-total') / wrapper.getAttribute('data-show')));
916
+ if(parseInt(totalNumber) == 0){
917
+ tbody.innerHTML = `<tr><td colspan="100%"><span>${emptyMsg}</span></td></tr>`;
918
+ }
845
919
 
846
- makeTableFunctional(table, form, pagination, wrapper);
847
- createPaginationButttons(wrapper, pagination);
920
+ wrapper.classList.remove('table--loading');
848
921
 
849
- if(response.data.length == 0){
850
- tbody.innerHTML = '<tr><td colspan="100%"><span class="h4 m-0">No results found</span></td></tr>';
922
+ window.dataLayer = window.dataLayer || [];
923
+ window.dataLayer.push({
924
+ "event": "Ajax table loaded",
925
+ "url": ajaxURL,
926
+ "formData": queryString
927
+ });
928
+ }
929
+ else {
930
+ tbody.innerHTML = '<tr><td colspan="100%"><span>Error loading table</span></td></tr>';
851
931
  }
852
932
 
853
- wrapper.classList.remove('table--loading');
854
- }
855
- else {
856
- tbody.innerHTML = '<tr><td colspan="100%"><span class="h6 m-0">Error loading table</span></td></tr>';
857
- }
858
- });
859
-
860
- if(form.hasAttribute('data-ajax-post')){
861
- const http = new XMLHttpRequest()
862
- http.open('GET', `${window.location.href}?ajax=true&${queryString}`);
863
- http.send()
933
+ // Pass post data back to the page
934
+ if(form.hasAttribute('data-ajax-post')){
935
+ const http = new XMLHttpRequest()
936
+ http.open('GET', `${window.location.href}?ajax=true&${queryString}`);
937
+ http.send();
938
+ }
939
+ });
940
+ } catch (error) {
941
+ console.log(error);
864
942
  }
865
943
  }
866
944