@iamproperty/components 4.1.0-beta-2 → 4.1.0
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/accordion.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/address-lookup.css +1 -0
- package/assets/css/components/address-lookup.css.map +1 -0
- package/assets/css/components/admin-panel.css +1 -1
- package/assets/css/components/admin-panel.css.map +1 -1
- package/assets/css/components/dialog.css +1 -1
- package/assets/css/components/dialog.css.map +1 -1
- package/assets/css/components/fileupload.css +1 -1
- package/assets/css/components/fileupload.css.map +1 -1
- package/assets/css/components/forms.css +1 -1
- package/assets/css/components/forms.css.map +1 -1
- package/assets/css/components/header.css +1 -1
- package/assets/css/components/header.css.map +1 -1
- package/assets/css/components/lists.css +1 -1
- package/assets/css/components/lists.css.map +1 -1
- package/assets/css/components/nav-global.css +1 -1
- package/assets/css/components/nav-global.css.map +1 -1
- package/assets/css/components/nav.css +1 -1
- package/assets/css/components/nav.css.map +1 -1
- package/assets/css/components/nav.old.css +1 -1
- package/assets/css/components/nav.old.css.map +1 -1
- package/assets/css/components/notification.css +1 -1
- package/assets/css/components/notification.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/property-searchbar.css +1 -1
- package/assets/css/components/property-searchbar.css.map +1 -1
- package/assets/css/components/table.css +1 -1
- package/assets/css/components/table.css.map +1 -1
- package/assets/css/components/table.extras.css +1 -0
- package/assets/css/components/table.extras.css.map +1 -0
- package/assets/css/components/table.global.css +1 -0
- package/assets/css/components/table.global.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/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 +3 -3
- package/assets/js/components/actionbar/actionbar.component.min.js.map +1 -1
- package/assets/js/components/address-lookup/address-lookup.component.js +172 -0
- package/assets/js/components/address-lookup/address-lookup.component.min.js +36 -0
- package/assets/js/components/address-lookup/address-lookup.component.min.js.map +1 -0
- package/assets/js/components/applied-filters/applied-filters.component.min.js +2 -2
- package/assets/js/components/applied-filters/applied-filters.component.min.js.map +1 -1
- package/assets/js/components/card/card.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.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 +2 -2
- package/assets/js/components/nav/nav.component.min.js +2 -2
- package/assets/js/components/notification/notification.component.min.js +4 -4
- package/assets/js/components/notification/notification.component.min.js.map +1 -1
- package/assets/js/components/pagination/pagination.component.js +152 -7
- package/assets/js/components/pagination/pagination.component.min.js +38 -12
- package/assets/js/components/pagination/pagination.component.min.js.map +1 -1
- package/assets/js/components/table/table.component.js +95 -69
- package/assets/js/components/table/table.component.min.js +9 -13
- package/assets/js/components/table/table.component.min.js.map +1 -1
- package/assets/js/components/tabs/tabs.component.js +3 -1
- package/assets/js/components/tabs/tabs.component.min.js +7 -5
- package/assets/js/components/tabs/tabs.component.min.js.map +1 -1
- package/assets/js/dynamic.min.js +5 -5
- package/assets/js/dynamic.min.js.map +1 -1
- package/assets/js/modules/applied-filters.js +3 -4
- package/assets/js/modules/dialogs.js +15 -3
- package/assets/js/modules/dynamicEvents.js +116 -0
- package/assets/js/modules/helpers.js +9 -0
- package/assets/js/modules/pagination.js +7 -10
- package/assets/js/modules/table.js +51 -52
- package/assets/js/modules/tabs.js +10 -1
- package/assets/js/scripts.bundle.js +53 -25
- 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/tests/table.spec.js +0 -57
- package/assets/sass/_components.scss +2 -0
- package/assets/sass/_corefiles.scss +6 -2
- package/assets/sass/_functions/variables.scss +5 -1
- package/assets/sass/components/actionbar-global.scss +11 -2
- package/assets/sass/components/address-lookup.scss +22 -0
- package/assets/sass/components/admin-panel.scss +4 -0
- package/assets/sass/components/dialog.scss +22 -13
- package/assets/sass/components/fileupload.scss +2 -0
- package/assets/sass/components/forms.scss +231 -71
- package/assets/sass/components/lists.scss +119 -1
- package/assets/sass/components/nav-global.scss +1 -0
- package/assets/sass/components/notification.scss +6 -1
- package/assets/sass/components/pagination.scss +192 -100
- package/assets/sass/components/table.extras.scss +650 -0
- package/assets/sass/components/table.global.scss +103 -0
- package/assets/sass/components/table.scss +41 -565
- package/assets/sass/components/tabs.scss +95 -32
- package/assets/sass/foundations/brand.scss +4 -0
- package/assets/sass/foundations/buttons.scss +14 -12
- package/assets/sass/foundations/links.scss +2 -1
- package/assets/sass/helpers/dynamic.scss +3 -0
- package/assets/sass/templates/form.scss +84 -0
- package/assets/svg/logo.svg +7 -0
- package/assets/ts/components/address-lookup/address-lookup.component.ts +215 -0
- package/assets/ts/components/pagination/README.md +11 -0
- package/assets/ts/components/pagination/pagination.component.ts +182 -8
- package/assets/ts/components/table/README.md +4 -2
- package/assets/ts/components/table/table.component.ts +134 -83
- package/assets/ts/components/tabs/README.md +6 -5
- package/assets/ts/components/tabs/tabs.component.ts +3 -1
- package/assets/ts/modules/applied-filters.ts +5 -8
- package/assets/ts/modules/dialogs.ts +19 -4
- package/assets/ts/modules/dynamicEvents.ts +145 -0
- package/assets/ts/modules/helpers.ts +16 -1
- package/assets/ts/modules/pagination.ts +7 -10
- package/assets/ts/modules/table.ts +70 -57
- package/assets/ts/modules/tabs.ts +21 -10
- package/assets/ts/tests/table.spec.ts +1 -61
- package/dist/components.es.js +1123 -1008
- package/dist/components.umd.js +165 -80
- package/dist/style.css +1 -1
- package/package.json +3 -2
- package/src/components/AddressLookup/AddressLookup.vue +27 -0
- package/src/components/Pagination/README.md +11 -0
- package/src/components/Table/README.md +4 -3
- package/src/components/Table/Table.vue +4 -0
- package/src/components/Tabs/README.md +10 -7
- package/src/components/Tabs/Tab.vue +7 -8
- package/src/components/Tabs/Tabs.vue +0 -1
- package/src/index.js +1 -0
- package/assets/js/tests/pagination.spec.js +0 -15
- package/assets/ts/tests/pagination.spec.ts +0 -21
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import createPaginationButttons from "../../modules/pagination";
|
|
3
|
-
|
|
4
2
|
class iamPagination extends HTMLElement {
|
|
5
3
|
|
|
6
4
|
constructor(){
|
|
@@ -8,15 +6,45 @@ class iamPagination extends HTMLElement {
|
|
|
8
6
|
this.attachShadow({ mode: 'open'});
|
|
9
7
|
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
10
8
|
const coreCSS = document.body.hasAttribute('data-core-css') ? document.body.getAttribute('data-core-css') : `${assetLocation}/css/core.min.css`;
|
|
9
|
+
const loadCSS = `@import "${assetLocation}/css/components/pagination.css";`;
|
|
11
10
|
|
|
12
11
|
const template = document.createElement('template');
|
|
13
12
|
template.innerHTML = `
|
|
14
13
|
<style>
|
|
15
14
|
@import "${coreCSS}";
|
|
15
|
+
${loadCSS}
|
|
16
16
|
|
|
17
17
|
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
18
18
|
</style>
|
|
19
|
-
<
|
|
19
|
+
<link rel="stylesheet" href="https://kit.fontawesome.com/26fdbf0179.css" crossorigin="anonymous">
|
|
20
|
+
<div class="pagination d-none">
|
|
21
|
+
|
|
22
|
+
<div class="minimal" part="minimal">
|
|
23
|
+
<div class="page-jump">
|
|
24
|
+
<div><select class="select--minimal"></select></div>
|
|
25
|
+
<span class="total-pages"></span>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<button class="prev" disabled>Prev</button>
|
|
29
|
+
<button class="next" disabled>Next</button>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="item-count" part="item-count"></div>
|
|
33
|
+
<div class="per-page" part="per-page">
|
|
34
|
+
<div>
|
|
35
|
+
<select class="select--minimal">
|
|
36
|
+
<option value="15">15</option>
|
|
37
|
+
<option value="25">25</option>
|
|
38
|
+
<option value="40">40</option>
|
|
39
|
+
<option value="50">50</option>
|
|
40
|
+
</select>
|
|
41
|
+
</div>
|
|
42
|
+
<span> / page</span>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="mobile-controls m-auto text-center">
|
|
45
|
+
<i class="fa-solid fa-spinner fa-spin"></i>
|
|
46
|
+
<button class="load-more btn btn-primary m-auto">Load more</a>
|
|
47
|
+
</div>
|
|
20
48
|
</div>
|
|
21
49
|
`;
|
|
22
50
|
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -28,7 +56,7 @@ class iamPagination extends HTMLElement {
|
|
|
28
56
|
const params = new URLSearchParams(window.location.search);
|
|
29
57
|
|
|
30
58
|
if(!this.hasAttribute('data-total'))
|
|
31
|
-
this.setAttribute('data-total',
|
|
59
|
+
this.setAttribute('data-total', 15);
|
|
32
60
|
|
|
33
61
|
if(!this.hasAttribute('data-page'))
|
|
34
62
|
this.setAttribute('data-page', (params.has('page') ? params.get('page') : 1));
|
|
@@ -37,12 +65,158 @@ class iamPagination extends HTMLElement {
|
|
|
37
65
|
this.setAttribute('data-show', (params.has('show') ? params.get('show') : 15));
|
|
38
66
|
|
|
39
67
|
if(!this.hasAttribute('data-increment'))
|
|
40
|
-
this.setAttribute('data-increment',
|
|
68
|
+
this.setAttribute('data-increment', this.getAttribute('data-show'));
|
|
69
|
+
|
|
70
|
+
// Elements
|
|
71
|
+
const select = this.shadowRoot.querySelector('.page-jump select');
|
|
72
|
+
const prev = this.shadowRoot.querySelector('.prev');
|
|
73
|
+
const next = this.shadowRoot.querySelector('.next');
|
|
74
|
+
const perPage = this.shadowRoot.querySelector('.per-page select');
|
|
75
|
+
const loadMore = this.shadowRoot.querySelector('.load-more');
|
|
76
|
+
|
|
77
|
+
// Add the select inputs, enable or disable buttons, update the helper text
|
|
78
|
+
this.setup();
|
|
79
|
+
|
|
80
|
+
// Select on change will update the data-page attr which will dispatch an event
|
|
81
|
+
select.addEventListener('change',(event) => {
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
this.setAttribute('data-show',this.getAttribute('data-increment'))
|
|
85
|
+
this.setAttribute('data-page',event.target.value);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Next and previous buttons will simply trigger and on change on the select which in turn will dispatch an event
|
|
89
|
+
next.addEventListener('click',(event) => {
|
|
90
|
+
|
|
91
|
+
select.value = parseInt(select.value) + 1;
|
|
92
|
+
select.dispatchEvent(new Event('change'));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
prev.addEventListener('click',(event) => {
|
|
96
|
+
|
|
97
|
+
select.value = parseInt(select.value) - 1;
|
|
98
|
+
select.dispatchEvent(new Event('change'));
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Update how many is shown
|
|
102
|
+
perPage.addEventListener('change',(event) => {
|
|
103
|
+
|
|
104
|
+
this.setAttribute('data-increment',event.target.value);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
loadMore.addEventListener('click',(event) => {
|
|
108
|
+
|
|
109
|
+
let newValue = parseInt(this.getAttribute('data-show')) + parseInt(this.getAttribute('data-increment'));
|
|
110
|
+
this.setAttribute('data-show',newValue);
|
|
111
|
+
|
|
112
|
+
if(newValue > parseInt(this.getAttribute('data-total'))){
|
|
113
|
+
loadMore.remove();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setup() {
|
|
119
|
+
// Elements
|
|
120
|
+
const wrapper = this.shadowRoot.querySelector('.pagination');
|
|
121
|
+
const select = this.shadowRoot.querySelector('.page-jump select');
|
|
122
|
+
const prev = this.shadowRoot.querySelector('.prev');
|
|
123
|
+
const next = this.shadowRoot.querySelector('.next');
|
|
124
|
+
const itemCount = this.shadowRoot.querySelector('.item-count');
|
|
125
|
+
const perPage = this.shadowRoot.querySelector('.per-page select');
|
|
126
|
+
const totalPages = this.shadowRoot.querySelector('.total-pages');
|
|
127
|
+
|
|
128
|
+
// Values
|
|
129
|
+
const currentPage = parseInt(this.getAttribute('data-page'));
|
|
130
|
+
const total = parseInt(this.getAttribute('data-total'));
|
|
131
|
+
const show = parseInt(this.getAttribute('data-show'));
|
|
132
|
+
const increment = parseInt(this.getAttribute('data-increment'));
|
|
133
|
+
const numberPages = Math.ceil(total / increment);
|
|
134
|
+
|
|
135
|
+
if(total > show)
|
|
136
|
+
wrapper.classList.remove('d-none');
|
|
137
|
+
|
|
138
|
+
// Populate the select input with the number of pages
|
|
139
|
+
let strOptions = '';
|
|
140
|
+
for (let i = 1; i <= numberPages; i++) {
|
|
141
|
+
strOptions += `<option value="${i}" ${i == currentPage ? 'selected' : ''}>${i}</option>`;
|
|
142
|
+
}
|
|
143
|
+
select.innerHTML = strOptions;
|
|
144
|
+
|
|
145
|
+
totalPages.innerHTML = `of ${numberPages}`;
|
|
146
|
+
|
|
147
|
+
// Next button
|
|
148
|
+
if(currentPage == numberPages)
|
|
149
|
+
next.setAttribute('disabled','disabled');
|
|
150
|
+
else
|
|
151
|
+
next.removeAttribute('disabled');
|
|
152
|
+
|
|
153
|
+
if(currentPage == 1)
|
|
154
|
+
prev.setAttribute('disabled','disabled');
|
|
155
|
+
else
|
|
156
|
+
prev.removeAttribute('disabled');
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
// Update the item count text
|
|
160
|
+
let startPoint = currentPage == 1 ? 1 : ((currentPage-1)*show)+1;
|
|
161
|
+
let endPoint = currentPage == 1 ? show : ((currentPage)*show);
|
|
162
|
+
itemCount.innerHTML = `${startPoint} - ${endPoint > total ? total : endPoint} of ${total} items`;
|
|
163
|
+
|
|
164
|
+
const defaultValues = [15,25,40,50];
|
|
165
|
+
|
|
166
|
+
// Update the per page options if needed
|
|
167
|
+
if(increment && perPage.value != increment && !defaultValues.includes(increment)){
|
|
168
|
+
perPage.innerHTML = `<option value="${increment}">${increment}</option>
|
|
169
|
+
<option value="${increment*2}">${increment*2}</option>
|
|
170
|
+
<option value="${increment*3}">${increment*3}</option>
|
|
171
|
+
<option value="${increment*4}">${increment*4}</option>`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
perPage.value = increment;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static get observedAttributes() {
|
|
178
|
+
return ["data-total","data-increment","data-page","data-show"];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
attributeChangedCallback(attrName, oldVal, newVal) {
|
|
182
|
+
|
|
183
|
+
switch (attrName) {
|
|
184
|
+
case "data-total": {
|
|
185
|
+
if(oldVal != newVal){
|
|
186
|
+
this.setAttribute('data-page', 1);
|
|
187
|
+
this.setup();
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case "data-show": {
|
|
192
|
+
if(oldVal != newVal){
|
|
193
|
+
|
|
194
|
+
this.setAttribute('data-page', 1);
|
|
195
|
+
this.setup();
|
|
196
|
+
this.dispatchEvent(new CustomEvent('update-show', { detail: { show: newVal } }));
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "data-increment": {
|
|
201
|
+
if(oldVal != newVal){
|
|
202
|
+
this.setAttribute('data-show', newVal);
|
|
203
|
+
this.setAttribute('data-page', 1);
|
|
204
|
+
this.setup();
|
|
205
|
+
this.dispatchEvent(new CustomEvent('update-show', { detail: { show: newVal } }));
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case "data-page": {
|
|
41
210
|
|
|
42
|
-
|
|
43
|
-
createPaginationButttons(this,this.shadowRoot.querySelector('.pagination__wrapper'));
|
|
211
|
+
if(oldVal != newVal) {
|
|
44
212
|
|
|
45
|
-
|
|
213
|
+
this.setup();
|
|
214
|
+
// Dispact the event for other components to use as triggers
|
|
215
|
+
this.dispatchEvent(new CustomEvent('update-page', { detail: { page: newVal } }));
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
46
220
|
}
|
|
47
221
|
}
|
|
48
222
|
|
|
@@ -28,11 +28,13 @@ import('../node_modules/@iamproperty/components/assets/js/components/table/table
|
|
|
28
28
|
| ------ | ---- | ------------- | ----------- |
|
|
29
29
|
| data-show | int | 15 | Update how many rows can be shown per page |
|
|
30
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 |
|
|
31
33
|
|
|
34
|
+
*Pagination properties can also be added to the table component so that they can be passed down to the child pagination element.*
|
|
32
35
|
|
|
33
36
|
**Class modifiers**
|
|
34
37
|
|
|
35
|
-
- 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).
|
|
36
|
-
- Adding a class of **.table--export** to the table component will create a button at the bottom of the table to export its contents out as a CSV file.
|
|
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).
|
|
37
39
|
- Adding a class of **.table--fullwidth** to the table component will prevent it from becoming a stacked view on mobile.
|
|
38
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.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as tableModule from "../../modules/table";
|
|
3
|
-
import createPaginationButttons from "../../modules/pagination";
|
|
4
|
-
|
|
5
3
|
class iamTable extends HTMLElement {
|
|
6
4
|
|
|
7
5
|
constructor(){
|
|
@@ -9,11 +7,14 @@ class iamTable extends HTMLElement {
|
|
|
9
7
|
this.attachShadow({ mode: 'open'});
|
|
10
8
|
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
11
9
|
const coreCSS = document.body.hasAttribute('data-core-css') ? document.body.getAttribute('data-core-css') : `${assetLocation}/css/core.min.css`;
|
|
12
|
-
|
|
10
|
+
const loadCSS = `@import "${assetLocation}/css/components/table.css";`;
|
|
11
|
+
const loadExtraCSS = `@import "${assetLocation}/css/components/table.extras.css";`;
|
|
12
|
+
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = `
|
|
15
15
|
<style>
|
|
16
16
|
@import "${coreCSS}";
|
|
17
|
+
${loadCSS}
|
|
17
18
|
|
|
18
19
|
:host(.mh-sm){
|
|
19
20
|
max-height: none!important;
|
|
@@ -33,10 +34,13 @@ class iamTable extends HTMLElement {
|
|
|
33
34
|
<slot></slot>
|
|
34
35
|
</div>
|
|
35
36
|
</div>
|
|
36
|
-
<
|
|
37
|
+
<iam-pagination class="pagination--table" ${this.hasAttribute('data-page')?`data-page="${this.getAttribute('data-page')}"`:''} ></iam-pagination>
|
|
37
38
|
`;
|
|
38
39
|
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
39
40
|
|
|
41
|
+
// insert extra CSS
|
|
42
|
+
if(!document.getElementById('tableExtras'))
|
|
43
|
+
document.head.insertAdjacentHTML('beforeend',`<style id="tableExtras">${loadExtraCSS}</style>`);
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
connectedCallback() {
|
|
@@ -51,12 +55,10 @@ class iamTable extends HTMLElement {
|
|
|
51
55
|
this.setAttribute('data-page', (params.has('page') ? params.get('page') : 1));
|
|
52
56
|
|
|
53
57
|
if(!this.hasAttribute('data-show'))
|
|
54
|
-
this.setAttribute('data-show', 15);
|
|
55
|
-
|
|
58
|
+
this.setAttribute('data-show', (params.has('show') ? params.get('show') : 15));
|
|
59
|
+
|
|
56
60
|
if(!this.hasAttribute('data-increment'))
|
|
57
|
-
this.setAttribute('data-increment',
|
|
58
|
-
|
|
59
|
-
this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / this.getAttribute('data-show')));
|
|
61
|
+
this.setAttribute('data-increment', this.getAttribute('data-show'));
|
|
60
62
|
|
|
61
63
|
// Update table__wrapper class
|
|
62
64
|
let classList = this.classList.toString();
|
|
@@ -71,7 +73,28 @@ class iamTable extends HTMLElement {
|
|
|
71
73
|
|
|
72
74
|
this.table = this.querySelector('table');
|
|
73
75
|
this.savedTableBody = this.table.querySelector('tbody').cloneNode(true);
|
|
74
|
-
|
|
76
|
+
|
|
77
|
+
this.pagination = this.shadowRoot.querySelector('iam-pagination');
|
|
78
|
+
this.pagination.setAttribute('data-total', this.getAttribute('data-total'));
|
|
79
|
+
this.pagination.setAttribute('data-page', this.getAttribute('data-page'));
|
|
80
|
+
this.pagination.setAttribute('data-show', this.getAttribute('data-show'));
|
|
81
|
+
this.pagination.setAttribute('data-increment', this.getAttribute('data-show'));
|
|
82
|
+
|
|
83
|
+
if(this.hasAttribute('data-page-jump'))
|
|
84
|
+
this.pagination.setAttribute('data-page-jump', 'true');
|
|
85
|
+
|
|
86
|
+
if(this.hasAttribute('data-per-page'))
|
|
87
|
+
this.pagination.setAttribute('data-per-page', 'true');
|
|
88
|
+
|
|
89
|
+
if(this.hasAttribute('data-item-count'))
|
|
90
|
+
this.pagination.setAttribute('data-item-count', 'true');
|
|
91
|
+
|
|
92
|
+
if(this.hasAttribute('data-loading'))
|
|
93
|
+
this.pagination.setAttribute('data-loading', 'true');
|
|
94
|
+
|
|
95
|
+
if(this.classList.contains('table--fullwidth'))
|
|
96
|
+
this.pagination.setAttribute('data-minimal', 'true');
|
|
97
|
+
|
|
75
98
|
|
|
76
99
|
// Remove table CTA
|
|
77
100
|
const isCTA = this.classList.contains('table--cta');
|
|
@@ -97,7 +120,7 @@ class iamTable extends HTMLElement {
|
|
|
97
120
|
// Create a data list if a search input is present
|
|
98
121
|
tableModule.createSearchDataList(this.table, this.form);
|
|
99
122
|
|
|
100
|
-
if(!this.form.querySelector('[data-
|
|
123
|
+
if(!this.form.querySelector('[data-pagination]')){
|
|
101
124
|
this.form.innerHTML += `<input name="page" type="hidden" value="${this.getAttribute('data-page')}" data-pagination="true" />`
|
|
102
125
|
}
|
|
103
126
|
if(!this.form.querySelector('[data-show]')){
|
|
@@ -114,123 +137,151 @@ class iamTable extends HTMLElement {
|
|
|
114
137
|
tableModule.loadAjaxTable(this.table, this.form, this.pagination, this);
|
|
115
138
|
}
|
|
116
139
|
else {
|
|
117
|
-
tableModule.makeTableFunctional(this.table, this.form, this.pagination, this);
|
|
118
|
-
tableModule.filterTable(this.table, this.form,this);
|
|
119
|
-
createPaginationButttons(this,this.pagination);
|
|
120
|
-
tableModule.populateDataQueries(this.table, this.form);
|
|
121
|
-
}
|
|
122
140
|
|
|
123
|
-
this.shadowRoot.querySelector('.table__wrapper').addEventListener("scroll", (event) => {
|
|
124
|
-
|
|
125
|
-
if(this.table.querySelector('dialog[open]')){
|
|
126
|
-
|
|
127
|
-
this.table.querySelector('dialog[open]').close();
|
|
128
|
-
this.table.querySelector('.dialog__wrapper > button.active').classList.remove('active');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
});
|
|
132
141
|
|
|
142
|
+
function uniqueID(index = 1){
|
|
133
143
|
|
|
134
|
-
|
|
144
|
+
let ID = Math.floor(Math.random() * Date.now() * (index+1));
|
|
135
145
|
|
|
136
|
-
|
|
146
|
+
return ID;
|
|
147
|
+
}
|
|
137
148
|
|
|
138
|
-
const actionbar = this.querySelector('iam-actionbar[data-selectall]');
|
|
139
149
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
row.insertAdjacentHTML(
|
|
143
|
-
'afterbegin',
|
|
144
|
-
"<th></th>"
|
|
145
|
-
);
|
|
146
|
-
});
|
|
150
|
+
// Add in the checkboxes
|
|
147
151
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
'afterbegin',
|
|
152
|
-
`<td class="selectrow"><input type="checkbox" name="row" id="row${index}"/><label for="row${index}"><span class="visually-hidden">Select row</span></label></td>`
|
|
153
|
-
);
|
|
154
|
-
});
|
|
152
|
+
if(this.querySelector('iam-actionbar[data-selectall]')){
|
|
153
|
+
|
|
154
|
+
const actionbar = this.querySelector('iam-actionbar[data-selectall]');
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
Array.from(this.table.querySelectorAll('thead tr')).forEach((row,index) => {
|
|
157
|
+
|
|
158
|
+
row.insertAdjacentHTML(
|
|
159
|
+
'afterbegin',
|
|
160
|
+
`<th class="th--fixed"></th>`
|
|
161
|
+
);
|
|
162
|
+
});
|
|
157
163
|
|
|
158
|
-
|
|
164
|
+
Array.from(this.table.querySelectorAll('tbody tr')).forEach((row,index) => {
|
|
165
|
+
|
|
166
|
+
let rowID = `row${uniqueID(index)}`;
|
|
167
|
+
row.insertAdjacentHTML(
|
|
168
|
+
'afterbegin',
|
|
169
|
+
`<td class="td--fixed selectrow"><input type="checkbox" name="row" id="${rowID}"/><label for="${rowID}"><span class="visually-hidden">Select row</span></label></td>`
|
|
170
|
+
);
|
|
171
|
+
});
|
|
159
172
|
|
|
160
|
-
|
|
161
|
-
let count = this.table.querySelectorAll('.selectrow input[type="checkbox"]').length;
|
|
162
|
-
let countChecked = this.table.querySelectorAll('.selectrow input[type="checkbox"]:checked').length;
|
|
173
|
+
this.table.addEventListener('change',(event) => {
|
|
163
174
|
|
|
164
|
-
|
|
175
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('.selectrow input')){
|
|
165
176
|
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
|
|
178
|
+
let count = this.table.querySelectorAll('.selectrow input[type="checkbox"]').length;
|
|
179
|
+
let countChecked = this.table.querySelectorAll('.selectrow input[type="checkbox"]:checked').length;
|
|
168
180
|
|
|
169
|
-
|
|
181
|
+
actionbar.setAttribute('data-selected', count == countChecked ? "all" : countChecked);
|
|
182
|
+
};
|
|
170
183
|
|
|
171
|
-
|
|
184
|
+
});
|
|
172
185
|
|
|
173
|
-
|
|
186
|
+
actionbar.addEventListener('selected', (event) => {
|
|
174
187
|
|
|
188
|
+
if(event.detail.selected == '0'){
|
|
175
189
|
|
|
176
|
-
|
|
190
|
+
Array.from(this.table.querySelectorAll('.selectrow input[type="checkbox"]')).forEach((input,index) => {
|
|
191
|
+
|
|
192
|
+
input.checked = false;
|
|
193
|
+
});
|
|
177
194
|
|
|
178
|
-
|
|
195
|
+
}
|
|
196
|
+
else if(event.detail.selected == 'all'){
|
|
179
197
|
|
|
180
|
-
|
|
181
|
-
|
|
198
|
+
Array.from(this.table.querySelectorAll('.selectrow input[type="checkbox"]')).forEach((input,index) => {
|
|
199
|
+
|
|
200
|
+
input.checked = true;
|
|
201
|
+
});
|
|
182
202
|
|
|
183
|
-
|
|
184
|
-
else if(event.detail.selected == 'all'){
|
|
203
|
+
}
|
|
185
204
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
}
|
|
190
208
|
|
|
209
|
+
// Make the dialog menus columns fixed
|
|
210
|
+
let colIndex = -1;
|
|
211
|
+
Array.from(this.table.querySelectorAll('tbody tr')).forEach((row,index) => {
|
|
212
|
+
|
|
213
|
+
if(row.querySelector(':scope > td > .dialog__wrapper')){
|
|
214
|
+
|
|
215
|
+
let columnn = row.querySelector(':scope > td > .dialog__wrapper').parentNode;
|
|
216
|
+
|
|
217
|
+
columnn.classList.add('td--fixed');
|
|
218
|
+
|
|
219
|
+
colIndex = Array.from(columnn.parentNode.children).indexOf(columnn);
|
|
191
220
|
}
|
|
192
|
-
|
|
193
221
|
});
|
|
194
222
|
|
|
223
|
+
if(colIndex != -1){
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
this.table.querySelector(`thead tr th:nth-child(${colIndex+1})`).classList.add('th--fixed');
|
|
227
|
+
|
|
228
|
+
Array.from(this.table.querySelectorAll(`tbody tr td:nth-child(${colIndex+1})`)).forEach((col,index) => {
|
|
229
|
+
|
|
230
|
+
col.classList.add('td--fixed');
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
tableModule.makeTableFunctional(this.table, this.form, this.pagination, this);
|
|
237
|
+
tableModule.filterTable(this.table, this.form,this);
|
|
238
|
+
tableModule.populateDataQueries(this.table, this.form);
|
|
195
239
|
}
|
|
240
|
+
|
|
241
|
+
this.shadowRoot.querySelector('.table__wrapper').addEventListener("scroll", (event) => {
|
|
242
|
+
|
|
243
|
+
if(this.table.querySelector('dialog[open]')){
|
|
244
|
+
|
|
245
|
+
this.table.querySelector('dialog[open]').close();
|
|
246
|
+
this.table.querySelector('.dialog__wrapper > button.active').classList.remove('active');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
});
|
|
250
|
+
|
|
196
251
|
}
|
|
197
252
|
|
|
198
253
|
|
|
199
254
|
static get observedAttributes() {
|
|
200
|
-
return ["data-total","data-
|
|
255
|
+
return ["data-total","data-page","data-show"];
|
|
201
256
|
}
|
|
202
257
|
|
|
203
258
|
attributeChangedCallback(attrName, oldVal, newVal) {
|
|
204
|
-
|
|
259
|
+
|
|
260
|
+
this.pagination = this.shadowRoot.querySelector('iam-pagination');
|
|
261
|
+
|
|
205
262
|
switch (attrName) {
|
|
206
263
|
case "data-total": {
|
|
207
|
-
|
|
264
|
+
|
|
265
|
+
if(oldVal != newVal){
|
|
266
|
+
this.pagination.setAttribute('data-total',newVal);
|
|
267
|
+
}
|
|
208
268
|
break;
|
|
209
269
|
}
|
|
210
270
|
case "data-show": {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
console.log('create pagination');
|
|
216
|
-
|
|
217
|
-
tableModule.filterTable(this.table, this.form);
|
|
218
|
-
createPaginationButttons(this,this.pagination);
|
|
219
|
-
|
|
271
|
+
|
|
272
|
+
if(oldVal != newVal){
|
|
273
|
+
this.pagination.setAttribute('data-show',newVal);
|
|
274
|
+
}
|
|
220
275
|
break;
|
|
221
276
|
}
|
|
222
277
|
case "data-page": {
|
|
223
278
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
//tableModule.filterTable(this.table, this.form);
|
|
229
|
-
|
|
279
|
+
if(oldVal != newVal){
|
|
280
|
+
this.pagination.setAttribute('data-page',newVal);
|
|
281
|
+
}
|
|
230
282
|
break;
|
|
231
283
|
}
|
|
232
284
|
}
|
|
233
|
-
*/
|
|
234
285
|
}
|
|
235
286
|
}
|
|
236
287
|
|
|
@@ -16,12 +16,12 @@ import('../node_modules/@iamproperty/components/assets/js/components/tabs/tabs.c
|
|
|
16
16
|
```
|
|
17
17
|
<iam-tabs class="container">
|
|
18
18
|
<details>
|
|
19
|
-
<summary>
|
|
20
|
-
<p>
|
|
19
|
+
<summary>Tab one</summary>
|
|
20
|
+
<p>Content one... Any element after summary is within content. First tab is active by default.</p>
|
|
21
21
|
</details>
|
|
22
22
|
<details>
|
|
23
|
-
<summary>
|
|
24
|
-
<p>
|
|
23
|
+
<summary>Tab two</summary>
|
|
24
|
+
<p>Content two... </p>
|
|
25
25
|
</details>
|
|
26
26
|
</iam-tabs>
|
|
27
27
|
```
|
|
@@ -30,4 +30,5 @@ import('../node_modules/@iamproperty/components/assets/js/components/tabs/tabs.c
|
|
|
30
30
|
|
|
31
31
|
| Option | Type | Default Value | Description |
|
|
32
32
|
| ------ | ---- | ------------- | ----------- |
|
|
33
|
-
| title | String | - | Used for the heading of the component |
|
|
33
|
+
| title | String | - | Used for the heading of the component |
|
|
34
|
+
| disabled | Boolean | - | Used to apply disabled state for a tab (tab content will not be reachable) |
|
|
@@ -29,7 +29,9 @@ class iamTabs extends HTMLElement {
|
|
|
29
29
|
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
30
30
|
</style>
|
|
31
31
|
<div class="tabs">
|
|
32
|
-
<div class="
|
|
32
|
+
<div class="tabs__links__wrapper">
|
|
33
|
+
<div class="tabs__links"></div>
|
|
34
|
+
</div>
|
|
33
35
|
<slot></slot>
|
|
34
36
|
</div>
|
|
35
37
|
`;
|
|
@@ -97,15 +97,12 @@ function createAppliedFilters(container,filters) {
|
|
|
97
97
|
addFilterButton(filters, input)
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
+
Array.from(container.querySelectorAll('input[data-filter-text]')).forEach((input, index) => {
|
|
101
|
+
|
|
102
|
+
input.addEventListener('change', function(event){
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (event && event.target instanceof HTMLElement && event.target.closest('input[data-filter-text]')){
|
|
104
|
-
|
|
105
|
-
let input = event.target.closest('input[data-filter-text]');
|
|
106
|
-
|
|
107
|
-
addFilterButton (filters, input);
|
|
108
|
-
}
|
|
104
|
+
addFilterButton(filters, input)
|
|
105
|
+
});
|
|
109
106
|
});
|
|
110
107
|
|
|
111
108
|
filters.addEventListener('click', function(event){
|
|
@@ -261,6 +261,7 @@ export const createMultiFormDialog = (dialog) => {
|
|
|
261
261
|
|
|
262
262
|
let buttons = "";
|
|
263
263
|
let fieldsets = Array.from(dialog.querySelectorAll('fieldset[data-title]'));
|
|
264
|
+
let form = dialog.querySelector('form');
|
|
264
265
|
|
|
265
266
|
fieldsets.forEach((fieldset,index) => {
|
|
266
267
|
buttons += `<button data-title="${fieldset.getAttribute('data-title')}" type="button" class="${index == 0 ? "active":""}" tabindex="-1">${fieldset.getAttribute('data-title')}</button>`;
|
|
@@ -275,8 +276,18 @@ export const createMultiFormDialog = (dialog) => {
|
|
|
275
276
|
if(index != fieldsets.length - 1)
|
|
276
277
|
btnWrapper.innerHTML += `<button data-title="${fieldsets[index+1].getAttribute('data-title')}" class="btn btn-primary mb-0" data-next type="button">Next</button>`;
|
|
277
278
|
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
// Last fieldset
|
|
280
|
+
if(index == fieldsets.length - 1){
|
|
281
|
+
if(form && form.querySelector(':scope > button[type="submit"]')){
|
|
282
|
+
|
|
283
|
+
let existingButton = form.querySelector(':scope > button[type="submit"]');
|
|
284
|
+
existingButton.classList.add('mb-0')
|
|
285
|
+
|
|
286
|
+
btnWrapper.insertAdjacentElement('beforeend',existingButton);
|
|
287
|
+
}
|
|
288
|
+
else
|
|
289
|
+
btnWrapper.innerHTML += `<button data-title="${fieldsets[index].getAttribute('data-title')}" class="btn btn-primary mb-0" data-next type="submit">Submit</button>`;
|
|
290
|
+
}
|
|
280
291
|
});
|
|
281
292
|
|
|
282
293
|
dialog.insertAdjacentHTML('afterbegin',`<div class="steps bg-primary">${buttons}</div>`);
|
|
@@ -376,11 +387,12 @@ export const createMultiFormDialog = (dialog) => {
|
|
|
376
387
|
|
|
377
388
|
const button = event.target.closest('button');
|
|
378
389
|
|
|
379
|
-
if(event.keyCode == 13){
|
|
390
|
+
if(event.keyCode == 13 && button.getAttribute('type') != "submit"){
|
|
380
391
|
|
|
381
392
|
event.preventDefault();
|
|
382
393
|
validateFieldset(button);
|
|
383
394
|
}
|
|
395
|
+
|
|
384
396
|
}
|
|
385
397
|
|
|
386
398
|
if (event && event.target instanceof HTMLElement && event.target.closest('input')){
|
|
@@ -388,7 +400,10 @@ export const createMultiFormDialog = (dialog) => {
|
|
|
388
400
|
|
|
389
401
|
input.classList.remove('is-invalid');
|
|
390
402
|
|
|
391
|
-
|
|
403
|
+
if(event.keyCode == 13){
|
|
404
|
+
|
|
405
|
+
event.preventDefault();
|
|
406
|
+
}
|
|
392
407
|
}
|
|
393
408
|
});
|
|
394
409
|
|