@iamproperty/components 7.2.0 → 7.2.1--beta2
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/assets/css/components/actionbar.component.css +1 -1
- package/assets/css/components/actionbar.component.css.map +1 -1
- package/assets/css/components/actionbar.global.css +1 -1
- package/assets/css/components/actionbar.global.css.map +1 -1
- package/assets/css/components/barchart.component.css +1 -1
- package/assets/css/components/barchart.component.css.map +1 -1
- package/assets/css/components/card.component.css +1 -1
- package/assets/css/components/card.component.css.map +1 -1
- package/assets/css/components/carousel.component.css +1 -1
- package/assets/css/components/carousel.component.css.map +1 -1
- package/assets/css/components/doughnutchart.component.css +1 -1
- package/assets/css/components/doughnutchart.component.css.map +1 -1
- package/assets/css/components/pagination.css +1 -1
- package/assets/css/components/pagination.css.map +1 -1
- package/assets/css/components/table-basic.component.css +1 -0
- package/assets/css/components/table-basic.component.css.map +1 -0
- package/assets/css/components/table-basic.global.css +1 -0
- package/assets/css/components/table-basic.global.css.map +1 -0
- package/assets/css/components/table.component.css +1 -1
- package/assets/css/components/table.component.css.map +1 -1
- package/assets/css/components/table.global.css +1 -1
- package/assets/css/components/table.global.css.map +1 -1
- package/assets/css/components/tabs.config.css +1 -0
- package/assets/css/components/tabs.config.css.map +1 -0
- package/assets/css/components/tabs.css +1 -1
- package/assets/css/components/tabs.css.map +1 -1
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/mobile-core.min.css +1 -1
- package/assets/css/mobile-core.min.css.map +1 -1
- package/assets/css/mobile.min.css +1 -1
- package/assets/css/mobile.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +4 -4
- package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/barchart/barchart.component.min.js +2 -2
- package/assets/js/components/barchart/barchart.component.min.js.map +1 -1
- package/assets/js/components/bento-grid/bento-grid.component.min.js +1 -1
- package/assets/js/components/card/card.component.min.js +2 -2
- package/assets/js/components/carousel/carousel.component.min.js +2 -2
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/doughnutchart/doughnutchart.component.min.js +2 -2
- package/assets/js/components/doughnutchart/doughnutchart.component.min.js.map +1 -1
- package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
- package/assets/js/components/filter-card/filter-card.component.min.js +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/menu/menu.component.min.js +1 -1
- package/assets/js/components/multi-step/multi-step.component.min.js +1 -1
- package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
- package/assets/js/components/nav/nav.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.js +11 -4
- package/assets/js/components/pagination/pagination.component.min.js +5 -5
- package/assets/js/components/pagination/pagination.component.min.js.map +1 -1
- package/assets/js/components/record-card/record-card.component.min.js +1 -1
- package/assets/js/components/search/search.component.min.js +1 -1
- package/assets/js/components/search/search.component.min.js.map +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/table/table.component.js +36 -198
- package/assets/js/components/table/table.component.min.js +13 -23
- package/assets/js/components/table/table.component.min.js.map +1 -1
- package/assets/js/components/table-ajax/table-ajax.component.js +46 -0
- package/assets/js/components/table-ajax/table-ajax.component.min.js +22 -0
- package/assets/js/components/table-ajax/table-ajax.component.min.js.map +1 -0
- package/assets/js/components/table-basic/table-basic.component.js +46 -0
- package/assets/js/components/table-basic/table-basic.component.min.js +22 -0
- package/assets/js/components/table-basic/table-basic.component.min.js.map +1 -0
- package/assets/js/components/table-no-submit/table-no-submit.component.js +77 -0
- package/assets/js/components/table-no-submit/table-no-submit.component.min.js +22 -0
- package/assets/js/components/table-no-submit/table-no-submit.component.min.js.map +1 -0
- package/assets/js/components/table-submit/table-submit.component.js +55 -0
- package/assets/js/components/table-submit/table-submit.component.min.js +22 -0
- package/assets/js/components/table-submit/table-submit.component.min.js.map +1 -0
- package/assets/js/components/tabs/tabs.component.js +2 -0
- package/assets/js/components/tabs/tabs.component.min.js +6 -4
- package/assets/js/components/tabs/tabs.component.min.js.map +1 -1
- package/assets/js/components/video-card/video-card.component.min.js +1 -1
- package/assets/js/modules/helpers.js +4 -0
- package/assets/js/modules/table.js +544 -294
- package/assets/js/modules/tabs.js +43 -13
- package/assets/js/scripts.bundle.js +3 -3
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/js/scripts.js +31 -24
- package/assets/js/tests/table.spec.js +0 -31
- package/assets/sass/_components.scss +3 -0
- package/assets/sass/components/actionbar.component.scss +1 -0
- package/assets/sass/components/actionbar.global.scss +0 -70
- package/assets/sass/components/pagination.scss +2 -1
- package/assets/sass/components/table-basic.component.scss +132 -0
- package/assets/sass/components/table-basic.global.scss +365 -0
- package/assets/sass/components/table.component.scss +2 -133
- package/assets/sass/components/table.global.scss +175 -434
- package/assets/sass/components/tabs.config.scss +27 -0
- package/assets/sass/components/tabs.scss +33 -1
- package/assets/sass/elements/buttons--global.scss +2 -1
- package/assets/sass/elements/table.element.scss +9 -7
- package/assets/sass/foundations/root.scss +1 -1
- package/assets/ts/components/pagination/pagination.component.ts +17 -4
- package/assets/ts/components/table/table.component.ts +49 -243
- package/assets/ts/components/table-ajax/table-ajax.component.ts +64 -0
- package/assets/ts/components/table-basic/README.md +40 -0
- package/assets/ts/components/table-basic/table-basic.component.ts +56 -0
- package/assets/ts/components/table-no-submit/table-no-submit.component.ts +134 -0
- package/assets/ts/components/table-submit/table-submit.component.ts +64 -0
- package/assets/ts/components/tabs/tabs.component.ts +2 -0
- package/assets/ts/modules/helpers.ts +6 -0
- package/assets/ts/modules/table.ts +656 -328
- package/assets/ts/modules/tabs.ts +54 -12
- package/assets/ts/scripts.ts +5 -3
- package/assets/ts/tests/table.spec.ts +0 -38
- package/dist/components.es.js +138 -136
- package/dist/components.umd.js +108 -116
- package/package.json +1 -1
- package/src/components/Table/TableAjax.vue +34 -0
- package/src/components/Table/TableBasic.vue +34 -0
- package/src/components/Table/TableNoSubmit.vue +34 -0
- package/src/components/Table/TableSubmit.vue +34 -0
- package/src/components/Table/Table.spec.js +0 -47
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@use '../_func' as *;
|
|
2
|
+
|
|
3
|
+
$layers: 'true' !default;
|
|
4
|
+
$mobileOnly: 'false' !default;
|
|
5
|
+
$darkMode: 'true' !default;
|
|
6
|
+
|
|
7
|
+
@include layer('components', $layers) {
|
|
8
|
+
.tabs__dropdown {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
iam-tabs:is(.tabs--dropdown) {
|
|
13
|
+
.tabs__dropdown {
|
|
14
|
+
display: block;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@container (min-width: 62em) {
|
|
19
|
+
iam-tabs:is(.tabs--dropdown-md) {
|
|
20
|
+
.tabs__dropdown {
|
|
21
|
+
display: block;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// #endregion
|
|
27
|
+
}
|
|
@@ -9,9 +9,38 @@ $darkMode: 'true' !default;
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
iam-tabs {
|
|
12
|
+
--colour-tab-underline: var(--colour-info);
|
|
13
|
+
|
|
12
14
|
details:not([open]) {
|
|
13
15
|
padding-bottom: 0;
|
|
14
16
|
}
|
|
17
|
+
|
|
18
|
+
.tabs__dropdown {
|
|
19
|
+
display: none;
|
|
20
|
+
width: fit-content;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&:is(.tabs--dropdown) {
|
|
24
|
+
.tabs__dropdown {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&::part(wrapper) {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@container (min-width: 62em) {
|
|
34
|
+
&:is(.tabs--dropdown) {
|
|
35
|
+
.tabs__dropdown {
|
|
36
|
+
display: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&::part(wrapper) {
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
15
44
|
}
|
|
16
45
|
|
|
17
46
|
iam-tabs::part(next-button) {
|
|
@@ -26,6 +55,7 @@ iam-tabs.tabs--guided::part(next-button) {
|
|
|
26
55
|
display: block;
|
|
27
56
|
}
|
|
28
57
|
}
|
|
58
|
+
|
|
29
59
|
iam-tabs.tabs--guided::part(next-button):not(:hover) {
|
|
30
60
|
background: var(--colour-success);
|
|
31
61
|
}
|
|
@@ -112,7 +142,7 @@ iam-tabs.tabs--guided::part(next-button):not(:hover) {
|
|
|
112
142
|
height: 3px;
|
|
113
143
|
width: 100%;
|
|
114
144
|
transform: translate(-50%, 0) scale(0, 0); // translate pulls this left so it's centered
|
|
115
|
-
background: var(--colour-
|
|
145
|
+
background: var(--colour-tab-underline);
|
|
116
146
|
transition: transform 0.4s;
|
|
117
147
|
}
|
|
118
148
|
|
|
@@ -210,12 +240,14 @@ iam-tabs.tabs--guided::part(next-button):not(:hover) {
|
|
|
210
240
|
pointer-events: none;
|
|
211
241
|
}
|
|
212
242
|
}
|
|
243
|
+
|
|
213
244
|
// #endregion
|
|
214
245
|
@include media-breakpoint-up(sm, $mobileOnly) {
|
|
215
246
|
:host(.tabs--inline) .tabs__links {
|
|
216
247
|
margin: 0;
|
|
217
248
|
justify-content: center;
|
|
218
249
|
}
|
|
250
|
+
|
|
219
251
|
:host(.tabs--inline) .tabs__links__wrapper:after {
|
|
220
252
|
width: 100%;
|
|
221
253
|
}
|
|
@@ -51,6 +51,15 @@ $darkMode: 'true' !default;
|
|
|
51
51
|
overflow: auto;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
div:has(> table:first-child:last-child) {
|
|
55
|
+
overflow: auto;
|
|
56
|
+
margin-bottom: rem(32);
|
|
57
|
+
|
|
58
|
+
table {
|
|
59
|
+
margin-bottom: 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
54
63
|
:is(td, th) {
|
|
55
64
|
padding: rem(12) rem(32) rem(12) 0;
|
|
56
65
|
|
|
@@ -69,13 +78,6 @@ $darkMode: 'true' !default;
|
|
|
69
78
|
p {
|
|
70
79
|
font-size: inherit;
|
|
71
80
|
padding: 0;
|
|
72
|
-
@container (width > 23.4375em) {
|
|
73
|
-
display: -webkit-box;
|
|
74
|
-
-webkit-line-clamp: 4;
|
|
75
|
-
-webkit-box-orient: vertical;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
min-width: rem(300);
|
|
78
|
-
}
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -83,6 +83,7 @@ class iamPagination extends HTMLElement {
|
|
|
83
83
|
// Next and previous buttons will simply trigger and on change on the select which in turn will dispatch an event
|
|
84
84
|
next.addEventListener('click', () => {
|
|
85
85
|
select.value = parseInt(select.value) + 1;
|
|
86
|
+
|
|
86
87
|
select.dispatchEvent(new Event('change'));
|
|
87
88
|
});
|
|
88
89
|
|
|
@@ -96,8 +97,17 @@ class iamPagination extends HTMLElement {
|
|
|
96
97
|
this.setAttribute('data-increment', event.target.value);
|
|
97
98
|
});
|
|
98
99
|
|
|
100
|
+
// Load more button
|
|
101
|
+
|
|
102
|
+
const increment = parseInt(this.getAttribute('data-increment'));
|
|
103
|
+
const show = parseInt(this.getAttribute('data-show'));
|
|
104
|
+
|
|
105
|
+
if (show >= parseInt(this.getAttribute('data-total'))) {
|
|
106
|
+
loadMore.remove();
|
|
107
|
+
}
|
|
108
|
+
|
|
99
109
|
loadMore.addEventListener('click', () => {
|
|
100
|
-
const newValue =
|
|
110
|
+
const newValue = show + increment;
|
|
101
111
|
this.setAttribute('data-show', newValue);
|
|
102
112
|
|
|
103
113
|
if (newValue > parseInt(this.getAttribute('data-total'))) {
|
|
@@ -167,14 +177,14 @@ class iamPagination extends HTMLElement {
|
|
|
167
177
|
switch (attrName) {
|
|
168
178
|
case 'data-total': {
|
|
169
179
|
if (oldVal != newVal) {
|
|
170
|
-
this.setAttribute('data-page', 1);
|
|
180
|
+
//this.setAttribute('data-page', 1);
|
|
171
181
|
this.setup();
|
|
172
182
|
}
|
|
173
183
|
break;
|
|
174
184
|
}
|
|
175
185
|
case 'data-show': {
|
|
176
186
|
if (oldVal != newVal) {
|
|
177
|
-
this.setAttribute('data-page', 1);
|
|
187
|
+
//this.setAttribute('data-page', 1);
|
|
178
188
|
this.setup();
|
|
179
189
|
this.dispatchEvent(new CustomEvent('update-show', { detail: { show: newVal } }));
|
|
180
190
|
}
|
|
@@ -183,7 +193,7 @@ class iamPagination extends HTMLElement {
|
|
|
183
193
|
case 'data-increment': {
|
|
184
194
|
if (oldVal != newVal) {
|
|
185
195
|
this.setAttribute('data-show', newVal);
|
|
186
|
-
this.setAttribute('data-page', 1);
|
|
196
|
+
//this.setAttribute('data-page', 1);
|
|
187
197
|
this.setup();
|
|
188
198
|
this.dispatchEvent(new CustomEvent('update-show', { detail: { show: newVal } }));
|
|
189
199
|
}
|
|
@@ -192,6 +202,9 @@ class iamPagination extends HTMLElement {
|
|
|
192
202
|
case 'data-page': {
|
|
193
203
|
if (oldVal && oldVal != newVal) {
|
|
194
204
|
this.setup();
|
|
205
|
+
|
|
206
|
+
console.log(newVal);
|
|
207
|
+
|
|
195
208
|
// Dispact the event for other components to use as triggers
|
|
196
209
|
this.dispatchEvent(new CustomEvent('update-page', { detail: { page: newVal } }));
|
|
197
210
|
}
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
moveAttributesToComponents,
|
|
3
|
+
findForm,
|
|
4
|
+
setupBasicTable,
|
|
5
|
+
setupAdvancedTable,
|
|
6
|
+
paginateRows,
|
|
7
|
+
setupNoSubmitTable,
|
|
8
|
+
setupSubmitTable,
|
|
9
|
+
setupAjaxTable,
|
|
10
|
+
loadAjaxTable,
|
|
11
|
+
paginateTable,
|
|
12
|
+
} from '../../modules/table';
|
|
13
|
+
|
|
14
|
+
class iamTableBasic extends HTMLElement {
|
|
3
15
|
constructor() {
|
|
4
16
|
super();
|
|
5
17
|
this.attachShadow({ mode: 'open' });
|
|
6
18
|
const assetLocation = document.body.hasAttribute('data-assets-location')
|
|
7
19
|
? document.body.getAttribute('data-assets-location')
|
|
8
20
|
: '/assets';
|
|
9
|
-
|
|
10
|
-
? document.body.getAttribute('data-core-css')
|
|
11
|
-
: `${assetLocation}/css/core.min.css`;
|
|
21
|
+
|
|
12
22
|
const loadCSS = `@import "${assetLocation}/css/components/table.component.css";`;
|
|
13
23
|
const loadExtraCSS = `@import "${assetLocation}/css/components/table.global.css";`;
|
|
14
24
|
|
|
15
25
|
const template = document.createElement('template');
|
|
16
26
|
template.innerHTML = `
|
|
17
27
|
<style>
|
|
18
|
-
@import "${coreCSS}";
|
|
19
28
|
${loadCSS}
|
|
20
29
|
|
|
21
|
-
:host(.mh-sm){
|
|
22
|
-
max-height: none!important;
|
|
23
|
-
}
|
|
24
|
-
:host(.mh-md){
|
|
25
|
-
max-height: none!important;
|
|
26
|
-
}
|
|
27
|
-
:host(.mh-lg){
|
|
28
|
-
max-height: none!important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
30
|
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
32
31
|
</style>
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
<div class="table__container">
|
|
33
|
+
<slot name="before"></slot>
|
|
34
|
+
<div class="table--cta">
|
|
35
|
+
<div class="table__wrapper">
|
|
36
|
+
<slot></slot>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<iam-pagination part="pagination" class="pagination--table" ></iam-pagination>
|
|
37
40
|
</div>
|
|
38
|
-
</div>
|
|
39
|
-
<iam-pagination part="pagination" class="pagination--table" ${this.hasAttribute('data-page') ? `data-page="${this.getAttribute('data-page')}"` : ''} ></iam-pagination>
|
|
40
41
|
`;
|
|
41
42
|
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
42
43
|
|
|
@@ -47,235 +48,40 @@ class iamTable extends HTMLElement {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
connectedCallback(): void {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
// Set default attributes
|
|
53
|
-
if (!this.hasAttribute('data-total')) {
|
|
54
|
-
this.setAttribute('data-total', this.querySelectorAll('table tbody tr').length);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!this.hasAttribute('data-page')) {
|
|
58
|
-
this.setAttribute('data-page', params.has('page') ? params.get('page') : 1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!this.hasAttribute('data-show')) {
|
|
62
|
-
this.setAttribute('data-show', params.has('show') ? params.get('show') : 15);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!this.hasAttribute('data-increment')) {
|
|
66
|
-
this.setAttribute('data-increment', this.getAttribute('data-show'));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Update table__wrapper class
|
|
70
|
-
let classList = this.classList.toString();
|
|
51
|
+
const pagination = this.shadowRoot.querySelector('iam-pagination');
|
|
52
|
+
const table = this.querySelector('table');
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
classList = classList.replace('table--loading', '');
|
|
74
|
-
//classList = classList.replace('mh-md','');
|
|
75
|
-
this.shadowRoot.querySelector('.table__wrapper').className += ` ${classList}`;
|
|
76
|
-
|
|
77
|
-
// set actionbar class if needed
|
|
78
|
-
if (this.querySelector('.actionbar__sticky')) {
|
|
79
|
-
this.shadowRoot.querySelector('.table__wrapper').classList.add('has-actionbar');
|
|
80
|
-
}
|
|
54
|
+
const form = findForm(this, table);
|
|
81
55
|
|
|
82
|
-
|
|
83
|
-
this.savedTableBody = this.table.querySelector('tbody').cloneNode(true);
|
|
56
|
+
const savedTableBody = table.querySelector('tbody').cloneNode(true);
|
|
84
57
|
|
|
85
|
-
this
|
|
86
|
-
this.pagination.setAttribute('data-total', this.getAttribute('data-total'));
|
|
87
|
-
this.pagination.setAttribute('data-page', this.getAttribute('data-page'));
|
|
88
|
-
this.pagination.setAttribute('data-show', this.getAttribute('data-show'));
|
|
89
|
-
this.pagination.setAttribute('data-increment', this.getAttribute('data-show'));
|
|
90
|
-
|
|
91
|
-
if (this.hasAttribute('data-page-jump')) {
|
|
92
|
-
this.pagination.setAttribute('data-page-jump', 'true');
|
|
93
|
-
}
|
|
94
|
-
if (this.hasAttribute('data-per-page')) {
|
|
95
|
-
this.pagination.setAttribute('data-per-page', 'true');
|
|
96
|
-
}
|
|
97
|
-
if (this.hasAttribute('data-item-count')) {
|
|
98
|
-
this.pagination.setAttribute('data-item-count', 'true');
|
|
99
|
-
}
|
|
100
|
-
if (this.hasAttribute('data-loading')) {
|
|
101
|
-
this.pagination.setAttribute('data-loading', 'true');
|
|
102
|
-
}
|
|
103
|
-
if (this.classList.contains('table--fullwidth')) {
|
|
104
|
-
this.pagination.setAttribute('data-minimal', 'true');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Remove table CTA
|
|
108
|
-
const isCTA = this.classList.contains('table--cta');
|
|
109
|
-
|
|
110
|
-
if (!isCTA) this.shadowRoot.querySelector('.table--cta').classList.remove('table--cta');
|
|
111
|
-
|
|
112
|
-
// Set events on the filter table
|
|
113
|
-
this.form = document.createElement('form');
|
|
114
|
-
if (this.hasAttribute('data-filterby')) {
|
|
115
|
-
this.form = document.querySelector(`#${this.getAttribute('data-filterby')}`);
|
|
116
|
-
} else {
|
|
117
|
-
this.table.parentNode.insertBefore(this.form, this.table.nextSibling);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Set ajax class
|
|
121
|
-
if (this.form.hasAttribute('data-ajax')) {
|
|
122
|
-
this.table.classList.add('table--ajax');
|
|
123
|
-
}
|
|
124
|
-
// Create a data list if a search input is present
|
|
125
|
-
tableModule.createSearchDataList(this.table, this.form);
|
|
126
|
-
|
|
127
|
-
if (!this.form.querySelector('[data-pagination]')) {
|
|
128
|
-
this.form.insertAdjacentHTML(
|
|
129
|
-
'beforeend',
|
|
130
|
-
`<input name="page" type="hidden" value="${this.getAttribute('data-page')}" data-pagination="true" />`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
if (!this.form.querySelector('[data-show]')) {
|
|
134
|
-
this.form.insertAdjacentHTML(
|
|
135
|
-
'beforeend',
|
|
136
|
-
`<input name="show" type="hidden" value="${this.getAttribute('data-show')}" data-show="true" />`
|
|
137
|
-
);
|
|
138
|
-
}
|
|
58
|
+
moveAttributesToComponents(this);
|
|
139
59
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
tableModule.addFilterEventListeners(this.table, this.form, this.pagination, this, this.savedTableBody);
|
|
143
|
-
tableModule.addPaginationEventListeners(this.table, this.form, this.pagination, this);
|
|
144
|
-
tableModule.addExportEventListeners(this.shadowRoot.querySelector('[data-export]'), this.table);
|
|
60
|
+
setupBasicTable(this, table, form, pagination);
|
|
61
|
+
setupAdvancedTable(this, table, form, pagination);
|
|
145
62
|
|
|
146
|
-
if (this.
|
|
147
|
-
|
|
63
|
+
if (this.hasAttribute('data-submit')) {
|
|
64
|
+
setupSubmitTable(this, table, form, pagination);
|
|
65
|
+
paginateTable(this, table, form, pagination, () => {
|
|
66
|
+
form.submit();
|
|
67
|
+
});
|
|
68
|
+
} else if (this.hasAttribute('data-no-submit') || this.hasAttribute('data-nosubmit')) {
|
|
69
|
+
setupNoSubmitTable(this, table, form, pagination, savedTableBody);
|
|
70
|
+
paginateTable(this, table, form, pagination, () => {
|
|
71
|
+
paginateRows(this);
|
|
72
|
+
});
|
|
73
|
+
} else if (this.hasAttribute('data-ajax')) {
|
|
74
|
+
setupAjaxTable(this, table, form, pagination);
|
|
75
|
+
paginateTable(this, table, form, pagination, () => {
|
|
76
|
+
loadAjaxTable(this, table, form, pagination);
|
|
77
|
+
});
|
|
148
78
|
} else {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return ID;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Add in the checkboxes
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
this.querySelector('iam-actionbar[data-selectall]') ||
|
|
159
|
-
document.querySelector(`iam-actionbar[data-for='${this.getAttribute('id')}']`)
|
|
160
|
-
) {
|
|
161
|
-
const actionbar = this.querySelector('iam-actionbar[data-selectall]')
|
|
162
|
-
? this.querySelector('iam-actionbar[data-selectall]')
|
|
163
|
-
: document.querySelector(`iam-actionbar[data-for='${this.getAttribute('id')}']`);
|
|
164
|
-
|
|
165
|
-
Array.from(this.table.querySelectorAll('thead tr')).forEach((row) => {
|
|
166
|
-
row.insertAdjacentHTML('afterbegin', `<th class="th--fixed"></th>`);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
Array.from(this.table.querySelectorAll('tbody tr')).forEach((row, index) => {
|
|
170
|
-
if (!row.querySelector('.selectrow')) {
|
|
171
|
-
const rowID = `row${uniqueID(index)}`;
|
|
172
|
-
row.insertAdjacentHTML(
|
|
173
|
-
'afterbegin',
|
|
174
|
-
`<td class="td--fixed selectrow selected"><input type="checkbox" name="row" id="${rowID}" ${row.hasAttribute('data-selected') ? `checked="true"` : ''}/><label for="${rowID}"><span class="visually-hidden">Select row</span></label></td>`
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
this.table.addEventListener('change', (event) => {
|
|
180
|
-
if (event && event.target instanceof HTMLElement && event.target.closest('.selectrow input')) {
|
|
181
|
-
const count = this.table.querySelectorAll('.selectrow input[type="checkbox"]').length;
|
|
182
|
-
const countChecked = this.table.querySelectorAll('.selectrow input[type="checkbox"]:checked').length;
|
|
183
|
-
|
|
184
|
-
actionbar.setAttribute('data-selected', count == countChecked ? 'all' : countChecked);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
actionbar.addEventListener('selected', (event) => {
|
|
189
|
-
if (event.detail.selected == '0') {
|
|
190
|
-
Array.from(this.table.querySelectorAll('.selectrow input[type="checkbox"]')).forEach((input) => {
|
|
191
|
-
input.checked = false;
|
|
192
|
-
});
|
|
193
|
-
} else if (event.detail.selected == 'all') {
|
|
194
|
-
Array.from(this.table.querySelectorAll('.selectrow input[type="checkbox"]')).forEach((input) => {
|
|
195
|
-
input.checked = true;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Make the dialog menus columns fixed
|
|
202
|
-
let colIndex = -1;
|
|
203
|
-
Array.from(this.table.querySelectorAll('tbody tr')).forEach((row) => {
|
|
204
|
-
if (row.querySelector(':scope > td > .dialog__wrapper')) {
|
|
205
|
-
const columnn = row.querySelector(':scope > td > .dialog__wrapper').parentNode;
|
|
206
|
-
|
|
207
|
-
columnn.classList.add('td--fixed');
|
|
208
|
-
|
|
209
|
-
colIndex = Array.from(columnn.parentNode.children).indexOf(columnn);
|
|
210
|
-
}
|
|
79
|
+
paginateRows(this);
|
|
80
|
+
paginateTable(this, table, form, pagination, () => {
|
|
81
|
+
paginateRows(this);
|
|
211
82
|
});
|
|
212
|
-
|
|
213
|
-
if (colIndex != -1) {
|
|
214
|
-
this.table.querySelector(`thead tr th:nth-child(${colIndex + 1})`).classList.add('th--fixed');
|
|
215
|
-
|
|
216
|
-
Array.from(this.table.querySelectorAll(`tbody tr td:nth-child(${colIndex + 1})`)).forEach((col) => {
|
|
217
|
-
col.classList.add('td--fixed');
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
tableModule.makeTableFunctional(this.table, this.form, this.pagination, this);
|
|
222
|
-
|
|
223
|
-
if (!this.hasAttribute('data-no-submit')) tableModule.filterTable(this.table, this.form, this);
|
|
224
|
-
|
|
225
|
-
tableModule.populateDataQueries(this.table, this.form);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
this.shadowRoot.querySelector('.table__wrapper').addEventListener('scroll', () => {
|
|
229
|
-
if (this.table.querySelector('dialog[open]')) {
|
|
230
|
-
this.table.querySelector('dialog[open]').close();
|
|
231
|
-
this.table.querySelector('.dialog__wrapper > button.active').classList.remove('active');
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// Push up the pagination events
|
|
236
|
-
this.pagination.addEventListener('update-show', (event) => {
|
|
237
|
-
const show = event.detail.show;
|
|
238
|
-
|
|
239
|
-
const updateEvent = new CustomEvent('update-show', { detail: { show: show } });
|
|
240
|
-
this.dispatchEvent(updateEvent);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
this.pagination.addEventListener('update-page', (event) => {
|
|
244
|
-
const page = event.detail.page;
|
|
245
|
-
|
|
246
|
-
const updateEvent = new CustomEvent('update-page', { detail: { page: page } });
|
|
247
|
-
this.dispatchEvent(updateEvent);
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
static get observedAttributes(): any {
|
|
252
|
-
return ['data-total', 'data-page', 'data-show'];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
attributeChangedCallback(attrName, oldVal, newVal): void {
|
|
256
|
-
this.pagination = this.shadowRoot.querySelector('iam-pagination');
|
|
257
|
-
|
|
258
|
-
switch (attrName) {
|
|
259
|
-
case 'data-total': {
|
|
260
|
-
if (oldVal != newVal) {
|
|
261
|
-
this.pagination.setAttribute('data-total', newVal);
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
case 'data-show': {
|
|
266
|
-
if (oldVal != newVal) {
|
|
267
|
-
this.pagination.setAttribute('data-show', newVal);
|
|
268
|
-
}
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
case 'data-page': {
|
|
272
|
-
if (oldVal != newVal) {
|
|
273
|
-
this.pagination.setAttribute('data-page', newVal);
|
|
274
|
-
}
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
83
|
}
|
|
278
84
|
}
|
|
279
85
|
}
|
|
280
86
|
|
|
281
|
-
export default
|
|
87
|
+
export default iamTableBasic;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setupBasicTable,
|
|
3
|
+
findForm,
|
|
4
|
+
setupAdvancedTable,
|
|
5
|
+
setupAjaxTable,
|
|
6
|
+
paginateTable,
|
|
7
|
+
loadAjaxTable,
|
|
8
|
+
} from '../../modules/table';
|
|
9
|
+
|
|
10
|
+
class iamTableAjax extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.attachShadow({ mode: 'open' });
|
|
14
|
+
const assetLocation = document.body.hasAttribute('data-assets-location')
|
|
15
|
+
? document.body.getAttribute('data-assets-location')
|
|
16
|
+
: '/assets';
|
|
17
|
+
|
|
18
|
+
const loadCSS = `@import "${assetLocation}/css/components/table.component.css";`;
|
|
19
|
+
const loadExtraCSS = `@import "${assetLocation}/css/components/table.global.css";`;
|
|
20
|
+
|
|
21
|
+
const template = document.createElement('template');
|
|
22
|
+
template.innerHTML = `
|
|
23
|
+
<style>
|
|
24
|
+
${loadCSS}
|
|
25
|
+
|
|
26
|
+
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
27
|
+
</style>
|
|
28
|
+
<div class="table__container">
|
|
29
|
+
<slot name="before"></slot>
|
|
30
|
+
<div class="table--cta">
|
|
31
|
+
<div class="table__wrapper">
|
|
32
|
+
<slot></slot>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<iam-pagination part="pagination" class="pagination--table" ${this.hasAttribute('data-page') ? `data-page="${this.getAttribute('data-page')}"` : ''} ></iam-pagination>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
39
|
+
|
|
40
|
+
// insert extra CSS
|
|
41
|
+
if (!document.getElementById('tableSingleExtras') && !document.getElementById('tableExtras')) {
|
|
42
|
+
document.head.insertAdjacentHTML('beforeend', `<style id="tableSingleExtras">${loadExtraCSS}</style>`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback(): void {
|
|
47
|
+
const pagination = this.shadowRoot.querySelector('iam-pagination');
|
|
48
|
+
const table = this.querySelector('table');
|
|
49
|
+
|
|
50
|
+
const form = findForm(this, table);
|
|
51
|
+
|
|
52
|
+
setupBasicTable(this, table, form, pagination);
|
|
53
|
+
|
|
54
|
+
setupAdvancedTable(this, table, form, pagination);
|
|
55
|
+
|
|
56
|
+
setupAjaxTable(this, table, form, pagination);
|
|
57
|
+
|
|
58
|
+
paginateTable(component, table, form, pagination, () => {
|
|
59
|
+
loadAjaxTable(component, table, form, pagination);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default iamTableAjax;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
**Add the below to your initialise script**
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
import('../node_modules/@iamproperty/components/assets/js/components/table/table.component.min').then(module => { // Might need to update the path
|
|
5
|
+
|
|
6
|
+
if (!window.customElements.get(`iam-table`))
|
|
7
|
+
window.customElements.define(`iam-table`, module.default);
|
|
8
|
+
|
|
9
|
+
}).catch((err) => {
|
|
10
|
+
console.log(err.message);
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**Add the below HTML code to where you want the component to live.**
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
<iam-table class="container">
|
|
18
|
+
<table>
|
|
19
|
+
<thead>....</thead>
|
|
20
|
+
<tbody>...</tbody>
|
|
21
|
+
</table>
|
|
22
|
+
</iam-tabs>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Properties**
|
|
26
|
+
|
|
27
|
+
| Option | Type | Default Value | Description |
|
|
28
|
+
| --------------- | ---------------- | ------------- | ----------------------------------------------------------------------------------------------- |
|
|
29
|
+
| data-show | int | 15 | Update how many rows can be shown per page |
|
|
30
|
+
| data-filterby | string (form ID) | | Give an optional form ID to connect a form to the table and make it act like a filtering system |
|
|
31
|
+
| data-no-scroll | flag | - | Stops the page from scrolling up to the top of the table |
|
|
32
|
+
| data-expandable | flag | - | Adds expandable buttons to rows with will allow for larger paragraphs to be shown correctly |
|
|
33
|
+
|
|
34
|
+
_Pagination properties can also be added to the table component so that they can be passed down to the child pagination element._
|
|
35
|
+
|
|
36
|
+
**Class modifiers**
|
|
37
|
+
|
|
38
|
+
- Adding a class of **.table--cta** to the table component will fix the last column of the table in place (While on tablet or desktop).
|
|
39
|
+
- Adding a class of **.table--fullwidth** to the table component will prevent it from becoming a stacked view on mobile.
|
|
40
|
+
- Adding a class of **.table--mh-small**,**.table--mh-medium** or **.table--mh-large** to the table component will give the table container a max height and the ability to scroll.
|