@iamproperty/components 3.7.0 → 3.7.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 (34) hide show
  1. package/assets/css/components/table.css +1 -1
  2. package/assets/css/components/table.css.map +1 -1
  3. package/assets/css/core.min.css +1 -1
  4. package/assets/css/core.min.css.map +1 -1
  5. package/assets/css/style.min.css +1 -1
  6. package/assets/css/style.min.css.map +1 -1
  7. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  8. package/assets/js/components/card/card.component.min.js +1 -1
  9. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  10. package/assets/js/components/header/header.component.min.js +1 -1
  11. package/assets/js/components/table/table.component.js +8 -1
  12. package/assets/js/components/table/table.component.min.js +13 -13
  13. package/assets/js/components/table/table.component.min.js.map +1 -1
  14. package/assets/js/components/tabs/tabs.component.min.js +1 -1
  15. package/assets/js/dynamic.min.js +2 -2
  16. package/assets/js/dynamic.min.js.map +1 -1
  17. package/assets/js/modules/applied-filters.js +1 -1
  18. package/assets/js/modules/dialogs.js +12 -1
  19. package/assets/js/modules/table.js +103 -29
  20. package/assets/js/scripts.bundle.js +19 -19
  21. package/assets/js/scripts.bundle.js.map +1 -1
  22. package/assets/js/scripts.bundle.min.js +2 -2
  23. package/assets/js/scripts.bundle.min.js.map +1 -1
  24. package/assets/js/tests/table.spec.js +19 -13
  25. package/assets/sass/components/table.scss +80 -53
  26. package/assets/sass/foundations/reboot.scss +7 -3
  27. package/assets/ts/components/table/table.component.ts +12 -1
  28. package/assets/ts/modules/applied-filters.ts +1 -1
  29. package/assets/ts/modules/dialogs.ts +16 -5
  30. package/assets/ts/modules/table.ts +139 -34
  31. package/assets/ts/tests/table.spec.ts +6 -6
  32. package/dist/components.es.js +758 -724
  33. package/dist/components.umd.js +21 -21
  34. package/package.json +1 -1
@@ -55,8 +55,8 @@ describe('addDataAttributes', () => {
55
55
  expect(table.querySelector('tbody td:nth-child(2)').getAttribute('data-label')).toEqual('Heading 2');
56
56
  });
57
57
  test('should add data-content attribute to the table cells if the content matches a pre-defined list', () => {
58
- expect(table.querySelector('tbody tr:nth-child(2) td:nth-child(2)').getAttribute('data-content')).toEqual('Low');
59
- expect(table.querySelector('tbody tr:nth-child(3) td:nth-child(2)').getAttribute('data-content')).toEqual('Medium');
58
+ expect(table.querySelector('tbody tr:nth-child(2) td:nth-child(2)').getAttribute('data-content')).toEqual('low');
59
+ expect(table.querySelector('tbody tr:nth-child(3) td:nth-child(2)').getAttribute('data-content')).toEqual('medium');
60
60
  });
61
61
  });
62
62
  /* TODO: This unit test doesn't work as puppeteer seems to have an issue with query selector all
@@ -142,19 +142,25 @@ describe('filterTable', () => {
142
142
  expect(table.querySelectorAll('tbody tr.filtered--matched').length).toEqual(1);
143
143
  });
144
144
  });
145
+ /*
145
146
  describe('populateDataQueries', () => {
146
- const table = document.createElement('table');
147
- table.innerHTML = basicTable;
148
- const form = document.createElement('form');
149
- form.innerHTML += `<div><input name="heading" value="Low" data-filter="Heading 2" /><span data-query="total"></span><span data-query="Heading 2 == Low"></span></div>`;
150
- tableModule.addDataAttributes(table);
151
- tableModule.filterTable(table, form, document.createElement('div'));
152
- tableModule.populateDataQueries(table, form);
153
- test('should populate elements with the data-query attribute with the result of the corresponding query', () => {
154
- expect(form.querySelector('[data-query="total"]').textContent).toEqual('4');
155
- expect(form.querySelector('[data-query="Heading 2 == Low"]').textContent).toEqual('2');
156
- });
147
+
148
+ const table = document.createElement('table');
149
+ table.innerHTML = basicTable;
150
+ const form = document.createElement('form');
151
+ form.innerHTML += `<div><input name="heading" value="Low" data-filter="Heading 2" /><span data-query="total"></span><span data-query="Heading 2 == Low"></span></div>`;
152
+
153
+ tableModule.addDataAttributes(table);
154
+ tableModule.filterTable(table, form, document.createElement('div'));
155
+ tableModule.populateDataQueries(table, form);
156
+
157
+ test('should populate elements with the data-query attribute with the result of the corresponding query', () => {
158
+
159
+ //expect(form.querySelector('[data-query="total"]').textContent).toEqual('4');
160
+ //expect(form.querySelector('[data-query="Heading 2 == Low"]').textContent).toEqual('2');
161
+ });
157
162
  });
163
+ */
158
164
  describe('formatCell', () => {
159
165
  test('should format the text correctly', () => {
160
166
  expect(tableModule.formatCell('date', '2023-05-15 12:10:45.000000')).toEqual('15 May 23');
@@ -29,6 +29,16 @@ td,th {
29
29
  &:first-child {
30
30
  padding-left: rem(2);
31
31
  }
32
+
33
+ p {
34
+ display: -webkit-box;
35
+ -webkit-line-clamp: 4;
36
+ -webkit-box-orient: vertical;
37
+ overflow: hidden;
38
+ font-size: inherit;
39
+ padding: 0;
40
+ min-width: rem(300);
41
+ }
32
42
  }
33
43
 
34
44
  th {
@@ -37,7 +47,11 @@ th {
37
47
  }
38
48
 
39
49
  thead {
50
+ tr {
40
51
 
52
+ border-bottom: var(--border-width) solid currentColor;
53
+ @include var(border-color,--colour-primary);
54
+ }
41
55
  th {
42
56
  font-weight: bold;
43
57
  vertical-align: bottom;
@@ -56,6 +70,8 @@ thead {
56
70
 
57
71
  tbody tr {
58
72
 
73
+ border-bottom: var(--border-width) solid currentColor;
74
+ @include var(border-color,--colour-border);
59
75
 
60
76
  &:is(:hover,:focus-within,.hover) {
61
77
 
@@ -69,12 +85,14 @@ tbody tr {
69
85
  }
70
86
  }
71
87
 
88
+ /*
72
89
  :is(td, th) {
73
90
 
74
91
  border-top: var(--border-width) solid currentColor;
75
92
  @include var(border-color,--colour-border);
76
93
  }
77
94
 
95
+
78
96
  &:first-child :is(td, th){
79
97
  border-top: var(--border-width) solid currentColor;
80
98
  @include var(border-color,--colour-primary);
@@ -84,6 +102,7 @@ tbody tr {
84
102
  border-bottom: var(--border-width) solid currentColor;
85
103
  @include var(border-color,--colour-border);
86
104
  }
105
+ */
87
106
  }
88
107
 
89
108
  .border-0 > table,
@@ -162,6 +181,7 @@ table.border-0 {
162
181
  margin-inline: 1.5rem;
163
182
  margin-bottom: 1.5rem;
164
183
  width: calc(100% - 3rem);
184
+ display: block;
165
185
 
166
186
  thead {
167
187
  display: none;
@@ -195,18 +215,6 @@ table.border-0 {
195
215
  background: transparent;
196
216
  }
197
217
  }
198
-
199
- &:last-child td:not(:last-child) {
200
- border-bottom:none;
201
- }
202
-
203
- &:first-child td:first-child {
204
- border-top: none;
205
- border-color: var(--colour-border);
206
- }
207
- &:first-child td {
208
- border-color: var(--colour-border);
209
- }
210
218
  }
211
219
 
212
220
  td,
@@ -313,6 +321,10 @@ table.border-0 {
313
321
  padding-left: 0;
314
322
  text-align: left;
315
323
  min-height: 0;
324
+
325
+ &:after {
326
+ display: none;
327
+ }
316
328
  }
317
329
 
318
330
  }
@@ -331,17 +343,7 @@ table.border-0 {
331
343
  position: relative;
332
344
  margin-right: calc(var(--cta-width) - 1.5rem);
333
345
 
334
- &::after {
335
- content: "";
336
- display: block;
337
- position: absolute;
338
- bottom: 0;
339
- left: 0;
340
- width: calc(100% + calc(var(--cta-width) - 1.5rem));
341
- border-bottom: 2px solid currentColor;
342
- @include var(border-color,--colour-border);
343
- z-index: 99;
344
- }
346
+
345
347
  }
346
348
 
347
349
  .table--cta .table__wrapper {
@@ -358,32 +360,40 @@ table.border-0 {
358
360
  top: auto;
359
361
  z-index: 3;
360
362
  background: transparent;
361
- width: var(--cta-width);
363
+ width: calc(var(--cta-width) + 1.5rem);
362
364
  padding-left: rem(40);
363
365
  margin-left: rem(-40);
364
- min-width: fit-content;
365
366
  min-height: var(--row-height);
366
367
  text-align: right;
367
368
  background: linear-gradient(90deg, transparent 0%, var(--colour-canvas-2) 1.25rem);
368
369
 
370
+ //border-bottom: var(--border-width) solid var(--colour-border);
371
+
372
+ &:after {
373
+ bottom: 0;
374
+ left: 0;
375
+ content: "";
376
+ position: absolute;
377
+ width: 100%;
378
+ height: 2px;
379
+ background-color: var(--colour-border);
380
+ }
381
+
369
382
  a {
370
383
  white-space: nowrap;
371
384
  }
372
385
  }
373
386
 
374
- tr:hover > *:last-child {
387
+ tr > th:last-child {
388
+ --colour-border: var(--colour-primary);
389
+ }
375
390
 
391
+ tbody tr:hover > *:last-child {
376
392
  background: linear-gradient(90deg, transparent 0%, var(--hover-background) 1.25rem);
377
393
  }
378
394
 
379
- tbody tr > *:last-child {
380
- margin-top: -1px;
381
- }
382
- tbody tr {
383
-
384
- &:last-child td{
385
- border-bottom: none;
386
- }
395
+ thead tr > *:last-child {
396
+ margin-top: 1px;
387
397
  }
388
398
  }
389
399
  }
@@ -453,23 +463,34 @@ iam-table:is(.mh-sm,.mh-md,.mh-lg):not(.table--cta) {
453
463
  display: none!important;
454
464
  }
455
465
 
456
- table:not(.table--filtered) tbody tr:nth-child(15) ~ tr {
466
+ table:not(.table--filtered):not(.table--ajax) tbody tr:nth-child(15) ~ tr {
457
467
  display: none;
458
468
  }
459
469
 
460
- // Statuses
461
470
 
471
+ // Loading via ajax
472
+ .table--loading {
473
+ opacity: 0.8;
474
+ pointer-events: none;
475
+
476
+ &.table--cta thead th:last-child {
477
+ opacity: 0;
478
+ }
479
+ }
480
+
481
+ // Statuses
462
482
  table {
463
483
 
464
- :is([data-content="Low"],
465
- [data-content="Medium"],
466
- [data-content="High"],
467
- [data-content="Incomplete"],
468
- [data-content="Requires approval"],
469
- [data-content="Verified"],
470
- [data-content="Not started"],
471
- [data-content="Completed"],
472
- .alert-status
484
+ :is([data-content="low"],
485
+ [data-content="medium"],
486
+ [data-content="high"],
487
+ [data-content="unknown"],
488
+ [data-content="incomplete"],
489
+ [data-content="requires approval"],
490
+ [data-content="verified"],
491
+ [data-content="not started"],
492
+ [data-content="completed"],
493
+ .alert-status:not([data-content="0"])
473
494
  ) {
474
495
 
475
496
  position: relative;
@@ -485,7 +506,6 @@ table {
485
506
  position: absolute;
486
507
  top: 1rem;
487
508
  left: 0;
488
- content: "";
489
509
  font-size: rem(16);
490
510
  line-height: 1;
491
511
  height: rem(16);
@@ -494,48 +514,55 @@ table {
494
514
  }
495
515
  }
496
516
 
497
- [data-content="High"]:after {
517
+ [data-content="high"]:after {
498
518
  content: "\f325";
499
519
  font-weight: normal;
500
520
  color: var(--colour-danger);
501
521
  }
502
522
 
503
- [data-content="Medium"]:after {
523
+ [data-content="medium"]:after {
504
524
 
505
525
  content: "\f7a4";
506
526
  font-weight: normal;
507
527
  color: var(--colour-warning);
508
528
  }
509
529
 
510
- [data-content="Low"]:after {
530
+ [data-content="low"]:after {
511
531
 
512
532
  content: "\e404";
513
533
  font-weight: normal;
514
534
  color: var(--colour-complete);
515
535
  }
516
536
 
517
- :is([data-content="Not started"],[data-content="Incomplete"]):after {
537
+ [data-content="unknown"]:after {
538
+
539
+ content: "\e404";
540
+ font-weight: normal;
541
+ color: var(--colour-muted);
542
+ }
543
+
544
+ :is([data-content="not started"],[data-content="incomplete"]):after {
518
545
 
519
546
  content: "\f024";
520
547
  font-weight: light;
521
548
  color: var(--colour-danger);
522
549
  }
523
550
 
524
- [data-content="Requires approval"]:after {
551
+ [data-content="requires approval"]:after {
525
552
 
526
553
  content: "\f024";
527
554
  font-weight: light;
528
555
  color: var(--colour-warning);
529
556
  }
530
557
 
531
- :is([data-content="Verified"],[data-content="Completed"]):after {
558
+ :is([data-content="verified"],[data-content="completed"]):after {
532
559
 
533
560
  content: "\f00c";
534
561
  font-weight: normal;
535
562
  color: var(--colour-complete);
536
563
  }
537
564
 
538
- .alert-status:not(:empty):after {
565
+ .alert-status:not([data-content="0"]):not(:empty):after {
539
566
 
540
567
  content: "\f06a";
541
568
  font-weight: light;
@@ -56,19 +56,23 @@ body {
56
56
  // #region scrollbars
57
57
  :is(div,form,fieldset)::-webkit-scrollbar {
58
58
  width: 10px;
59
- height: 6px;
59
+ height: 10px;
60
60
  }
61
61
 
62
62
  :is(div,form,fieldset)::-webkit-scrollbar-track {
63
63
  background-color: #f1f1f1;
64
- border-left: 4px solid var(--bg-colour,var(--colour-canvas));
64
+ border-top: 4px solid var(--colour-canvas-2);
65
+ border-left: 4px solid var(--colour-canvas-2);
65
66
  }
66
67
 
67
68
  :is(div,form,fieldset)::-webkit-scrollbar-thumb {
68
69
  background-color: #c1c1c1;
69
70
  width: 6px;
70
- border-left: 4px solid var(--bg-colour,var(--colour-canvas));
71
+ border-top: 4px solid var(--colour-canvas-2);
72
+ border-left: 4px solid var(--colour-canvas-2);
71
73
  }
74
+
75
+
72
76
  //#endregion
73
77
 
74
78
  body > footer,
@@ -52,6 +52,9 @@ class iamTable extends HTMLElement {
52
52
  if(!this.hasAttribute('data-show'))
53
53
  this.setAttribute('data-show', 15);
54
54
 
55
+ if(!this.hasAttribute('data-increment'))
56
+ this.setAttribute('data-increment', 15);
57
+
55
58
  this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / this.getAttribute('data-show')));
56
59
  }
57
60
 
@@ -72,6 +75,10 @@ class iamTable extends HTMLElement {
72
75
  this.table.parentNode.insertBefore(this.form, this.table.nextSibling);
73
76
  }
74
77
 
78
+ // Set ajax class
79
+ if(this.form.hasAttribute('data-ajax'))
80
+ this.table.classList.add('table--ajax');
81
+
75
82
  // Create a data list if a search input is present
76
83
  tableModule.createSearchDataList(this.table, this.form);
77
84
 
@@ -100,8 +107,12 @@ class iamTable extends HTMLElement {
100
107
 
101
108
  this.shadowRoot.querySelector('.table__wrapper').addEventListener("scroll", (event) => {
102
109
 
103
- if(this.table.querySelector('dialog[open]'))
110
+ if(this.table.querySelector('dialog[open]')){
111
+
104
112
  this.table.querySelector('dialog[open]').close();
113
+ this.table.querySelector('.dialog__wrapper > button.active').classList.remove('active');
114
+ }
115
+
105
116
  });
106
117
  }
107
118
 
@@ -121,7 +121,7 @@ function createAppliedFilters(container,filters) {
121
121
  if(name.match(/\[(.*)\]/)){
122
122
  let newName = name.replace(/\[(.*)\]/,`[]`);
123
123
  let value = name.replace(/.*\[(.*)\]/,`$1`);
124
- selector = `[name="${newName}"][value="${value}"]`;
124
+ selector = `[value="${value}"]`;
125
125
  }
126
126
 
127
127
  let inputs = container.querySelectorAll(selector);
@@ -31,11 +31,8 @@ const extendDialogs = (body) => {
31
31
 
32
32
  // Open the modal!
33
33
  dialog.showModal();
34
-
35
34
  dialog.focus();
36
35
 
37
- console.log(dialog.querySelector('button'));
38
-
39
36
  window.dataLayer = window.dataLayer || [];
40
37
  window.dataLayer.push({
41
38
  "event": "openModal",
@@ -49,7 +46,12 @@ const extendDialogs = (body) => {
49
46
 
50
47
  event.preventDefault();
51
48
  dialog.close()
52
-
49
+
50
+ // Remove active class from exiting active buttons
51
+ Array.from(document.querySelectorAll('.dialog__wrapper > button')).forEach((btnElement,index) => {
52
+ btnElement.classList.remove('active');
53
+ });
54
+
53
55
  window.dataLayer = window.dataLayer || [];
54
56
  window.dataLayer.push({
55
57
  "event": "closeModal",
@@ -61,6 +63,11 @@ const extendDialogs = (body) => {
61
63
  if (event && event.target instanceof HTMLElement && event.target.closest('button[formmethod="dialog"]')){
62
64
  const dialog = event.target.closest('dialog[open]');
63
65
 
66
+ // Remove active class from exiting active buttons
67
+ Array.from(document.querySelectorAll('.dialog__wrapper > button')).forEach((btnElement,index) => {
68
+ btnElement.classList.remove('active');
69
+ });
70
+
64
71
  window.dataLayer = window.dataLayer || [];
65
72
  window.dataLayer.push({
66
73
  "event": "closeModal",
@@ -105,6 +112,11 @@ const extendDialogs = (body) => {
105
112
  document.querySelector('dialog[open]').close();
106
113
 
107
114
 
115
+ // Remove active class from exiting active buttons
116
+ Array.from(document.querySelectorAll('.dialog__wrapper > button')).forEach((btnElement,index) => {
117
+ btnElement.classList.remove('active');
118
+ });
119
+
108
120
  if(popover.hasAttribute('open')){
109
121
 
110
122
  popover.close();
@@ -128,7 +140,6 @@ const extendDialogs = (body) => {
128
140
 
129
141
  topOffset -= container.top;
130
142
  leftOffset -= container.left;
131
-
132
143
  }
133
144
 
134
145
  if(popover.classList.contains('dialog--fix')){