kempo 2.10.0 → 2.10.2
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/dist/components/Search.js +1 -1
- package/dist/components/Sortable.js +1 -0
- package/dist/components/Table.js +1 -1
- package/dist/components/tableControls/DeleteRecord.js +1 -0
- package/dist/components/tableControls/DeleteSelected.js +1 -1
- package/dist/components/tableControls/Edit.js +1 -1
- package/dist/components/tableControls/ExportCSV.js +1 -0
- package/dist/components/tableControls/ExportJson.js +1 -0
- package/dist/components/tableControls/FieldSortHide.js +1 -0
- package/dist/components/tableControls/Filters.js +1 -1
- package/dist/components/tableControls/FirstPage.js +1 -0
- package/dist/components/tableControls/HiddenCount.js +1 -1
- package/dist/components/tableControls/Hide.js +1 -1
- package/dist/components/tableControls/LastPage.js +1 -0
- package/dist/components/tableControls/NextPage.js +1 -0
- package/dist/components/tableControls/PageSelect.js +1 -1
- package/dist/components/tableControls/PageSize.js +1 -1
- package/dist/components/tableControls/PrevPage.js +1 -0
- package/dist/components/tableControls/Search.js +1 -0
- package/dist/components/tableControls/SelectCount.js +1 -1
- package/dist/components/tableControls/ShowAll.js +1 -1
- package/dist/components/tableControls/ShowHideFields.js +1 -0
- package/dist/components/tableControls/TableControl.js +1 -0
- package/dist/index.js +1 -1
- package/docs/components/sortable.html +96 -0
- package/docs/components/table.html +32 -7
- package/docs/components/tableControls.html +10 -24
- package/docs/components/tableCustomFields.html +2 -1
- package/docs/components/tableFetchRecords.html +114 -0
- package/docs/components/tableFieldSortHide.html +75 -0
- package/docs/components/tablePagination.html +33 -25
- package/docs/components/tableRecordEditing.html +8 -8
- package/docs/components/tableRecordFiltering.html +6 -13
- package/docs/components/tableRecordHiding.html +10 -14
- package/docs/components/tableRecordSearching.html +75 -0
- package/docs/components/tableRecordSelection.html +8 -19
- package/docs/components/tableRowControls.html +10 -35
- package/docs/components/tableSorting.html +73 -0
- package/docs/icons/arrow-down.svg +1 -0
- package/docs/icons/arrow-up.svg +1 -0
- package/docs/icons/drag-handle.svg +1 -0
- package/docs/icons/export-file.svg +1 -0
- package/docs/icons/first.svg +1 -0
- package/docs/icons/last.svg +1 -0
- package/docs/icons/table-visibility.svg +1 -0
- package/docs/kempo/components/Search.js +1 -1
- package/docs/kempo/components/Sortable.js +1 -0
- package/docs/kempo/components/Table.js +1 -1
- package/docs/kempo/components/tableControls/DeleteRecord.js +1 -0
- package/docs/kempo/components/tableControls/DeleteSelected.js +1 -1
- package/docs/kempo/components/tableControls/Edit.js +1 -1
- package/docs/kempo/components/tableControls/ExportCSV.js +1 -0
- package/docs/kempo/components/tableControls/ExportJson.js +1 -0
- package/docs/kempo/components/tableControls/FieldSortHide.js +1 -0
- package/docs/kempo/components/tableControls/Filters.js +1 -1
- package/docs/kempo/components/tableControls/FirstPage.js +1 -0
- package/docs/kempo/components/tableControls/HiddenCount.js +1 -1
- package/docs/kempo/components/tableControls/Hide.js +1 -1
- package/docs/kempo/components/tableControls/LastPage.js +1 -0
- package/docs/kempo/components/tableControls/NextPage.js +1 -0
- package/docs/kempo/components/tableControls/PageSelect.js +1 -1
- package/docs/kempo/components/tableControls/PageSize.js +1 -1
- package/docs/kempo/components/tableControls/PrevPage.js +1 -0
- package/docs/kempo/components/tableControls/Search.js +1 -0
- package/docs/kempo/components/tableControls/SelectCount.js +1 -1
- package/docs/kempo/components/tableControls/ShowAll.js +1 -1
- package/docs/kempo/components/tableControls/ShowHideFields.js +1 -0
- package/docs/kempo/components/tableControls/TableControl.js +1 -0
- package/docs/kempo/index.js +1 -1
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/drag-handle.svg +1 -0
- package/icons/export-file.svg +1 -0
- package/icons/first.svg +1 -0
- package/icons/last.svg +1 -0
- package/icons/table-visibility.svg +1 -0
- package/package.json +1 -1
- package/src/components/Search.js +1 -0
- package/src/components/Sortable.js +169 -0
- package/src/components/Table.js +422 -295
- package/src/components/tableControls/DeleteRecord.js +43 -0
- package/src/components/tableControls/DeleteSelected.js +11 -13
- package/src/components/tableControls/Edit.js +22 -26
- package/src/components/tableControls/ExportCSV.js +91 -0
- package/src/components/tableControls/ExportJson.js +62 -0
- package/src/components/tableControls/FieldSortHide.js +77 -0
- package/src/components/tableControls/Filters.js +18 -17
- package/src/components/tableControls/FirstPage.js +69 -0
- package/src/components/tableControls/HiddenCount.js +10 -15
- package/src/components/tableControls/Hide.js +12 -15
- package/src/components/tableControls/LastPage.js +67 -0
- package/src/components/tableControls/NextPage.js +69 -0
- package/src/components/tableControls/PageSelect.js +20 -23
- package/src/components/tableControls/PageSize.js +12 -15
- package/src/components/tableControls/PrevPage.js +69 -0
- package/src/components/tableControls/Search.js +49 -0
- package/src/components/tableControls/SelectCount.js +5 -10
- package/src/components/tableControls/ShowAll.js +9 -12
- package/src/components/tableControls/TableControl.js +51 -0
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
record = Symbol('record'),
|
|
6
|
-
clickHandler = Symbol('clickHandler');
|
|
4
|
+
const clickHandler = Symbol('clickHandler');
|
|
7
5
|
|
|
8
|
-
export default class Hide extends
|
|
9
|
-
constructor(
|
|
6
|
+
export default class Hide extends TableControl {
|
|
7
|
+
constructor() {
|
|
10
8
|
super();
|
|
11
|
-
|
|
12
|
-
/* Private Members */
|
|
13
|
-
this[table] = _table;
|
|
14
|
-
this[record] = _record;
|
|
15
9
|
|
|
16
10
|
/* Private Methods */
|
|
17
11
|
this[clickHandler] = (()=>{
|
|
18
|
-
this
|
|
12
|
+
const table = this.table;
|
|
13
|
+
const record = this.record;
|
|
14
|
+
if(table && record){
|
|
15
|
+
table.hideRecord(record);
|
|
16
|
+
}
|
|
19
17
|
}).bind(this);
|
|
20
|
-
|
|
21
|
-
this.classList.add('mxq');
|
|
22
18
|
}
|
|
23
19
|
async render(force = false) {
|
|
24
20
|
if (await super.render(force)) {
|
|
@@ -32,12 +28,13 @@ export default class Hide extends Component {
|
|
|
32
28
|
offEvent(this.shadowRoot.getElementById('hideButton'), 'click', this[clickHandler]);
|
|
33
29
|
}
|
|
34
30
|
|
|
31
|
+
/* Shadow DOM */
|
|
35
32
|
get shadowTemplate() {
|
|
36
33
|
return /*html*/`
|
|
37
|
-
<button id="hideButton" class="
|
|
34
|
+
<button id="hideButton" class="no-btn icon-btn">
|
|
38
35
|
<k-icon name="hide"></k-icon>
|
|
39
36
|
</button>
|
|
40
37
|
`;
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
window.customElements.define('k-
|
|
40
|
+
window.customElements.define('k-tc-hide', Hide);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const clickHandler = Symbol('clickHandler'),
|
|
5
|
+
handlePageChange = Symbol('handlePageChange');
|
|
6
|
+
export default class LastPage extends TableControl {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Methods */
|
|
11
|
+
this[clickHandler] = this.lastPage.bind(this);
|
|
12
|
+
this[handlePageChange] = (()=>{
|
|
13
|
+
const table = this.table;
|
|
14
|
+
if(!table || table.getCurrentPage() === table.getTotalPages()){
|
|
15
|
+
this.shadowRoot.getElementById('lastPage').disabled = true;
|
|
16
|
+
} else {
|
|
17
|
+
this.shadowRoot.getElementById('lastPage').disabled = false;
|
|
18
|
+
}
|
|
19
|
+
}).bind(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Lifecycle Callback */
|
|
23
|
+
async render(force = false) {
|
|
24
|
+
if(await super.render(force)) {
|
|
25
|
+
onEvent(this.shadowRoot.getElementById('lastPage'), 'click', this[clickHandler]);
|
|
26
|
+
this[handlePageChange]();
|
|
27
|
+
onEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback(){
|
|
33
|
+
super.disconnectedCallback();
|
|
34
|
+
offEvent(this.shadowRoot.getElementById('lastPage'), 'click', this[clickHandler]);
|
|
35
|
+
offEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Public Methods */
|
|
39
|
+
lastPage(){
|
|
40
|
+
const table = this.table;
|
|
41
|
+
if(table){
|
|
42
|
+
table.lastPage();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Shadow DOM */
|
|
47
|
+
get shadowTemplate(){
|
|
48
|
+
return /*html*/`
|
|
49
|
+
<button
|
|
50
|
+
id="lastPage"
|
|
51
|
+
class="no-btn icon-btn"
|
|
52
|
+
>
|
|
53
|
+
<slot><k-icon name="last"></k-icon></slot>
|
|
54
|
+
</button>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
get shadowStyles(){
|
|
58
|
+
return /*css*/`
|
|
59
|
+
${super.shadowStyles}
|
|
60
|
+
#lastPage[disabled] {
|
|
61
|
+
cursor: inherit;
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
window.customElements.define('k-tc-last-page', LastPage);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const clickHandler = Symbol('clickHandler'),
|
|
5
|
+
handlePageChange = Symbol('handlePageChange');
|
|
6
|
+
export default class NextPage extends TableControl {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Methods */
|
|
11
|
+
this[clickHandler] = this.nextPage.bind(this);
|
|
12
|
+
this[handlePageChange] = (()=>{
|
|
13
|
+
const table = this.table;
|
|
14
|
+
if(!table || table.getCurrentPage() === table.getTotalPages()){
|
|
15
|
+
this.shadowRoot.getElementById('nextPage').disabled = true;
|
|
16
|
+
} else {
|
|
17
|
+
this.shadowRoot.getElementById('nextPage').disabled = false;
|
|
18
|
+
}
|
|
19
|
+
}).bind(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Lifecycle Callback */
|
|
23
|
+
async render(force = false) {
|
|
24
|
+
if(await super.render(force)) {
|
|
25
|
+
onEvent(this.shadowRoot.getElementById('nextPage'), 'click', this[clickHandler]);
|
|
26
|
+
this[handlePageChange]();
|
|
27
|
+
onEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback(){
|
|
33
|
+
super.disconnectedCallback();
|
|
34
|
+
offEvent(this.shadowRoot.getElementById('nextPage'), 'click', this[clickHandler]);
|
|
35
|
+
offEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Public Methods */
|
|
39
|
+
nextPage(){
|
|
40
|
+
const table = this.table;
|
|
41
|
+
if(table){
|
|
42
|
+
table.nextPage();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Shadow DOM */
|
|
47
|
+
get shadowTemplate(){
|
|
48
|
+
return /*html*/`
|
|
49
|
+
<button
|
|
50
|
+
id="nextPage"
|
|
51
|
+
class="no-btn icon-btn"
|
|
52
|
+
>
|
|
53
|
+
<slot><k-icon name="chevron-right"></k-icon></slot>
|
|
54
|
+
</button>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
get shadowStyles(){
|
|
58
|
+
return /*css*/`
|
|
59
|
+
${super.shadowStyles}
|
|
60
|
+
#nextPage[disabled] {
|
|
61
|
+
cursor: inherit;
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
window.customElements.define('k-tc-next-page', NextPage);
|
|
@@ -1,58 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
updateOptions = Symbol('updateOptions'),
|
|
4
|
+
const updateOptions = Symbol('updateOptions'),
|
|
6
5
|
handleSelectChange = Symbol('handleSelectChange'),
|
|
7
6
|
handlePageSizeChange = Symbol('handlePageSizeChange'),
|
|
8
7
|
handlePageChange = Symbol('handlePageChange'),
|
|
9
8
|
handlePageCountChange = Symbol('handlePageCountChange');
|
|
10
|
-
export default class PageSelect extends
|
|
11
|
-
constructor(
|
|
9
|
+
export default class PageSelect extends TableControl {
|
|
10
|
+
constructor() {
|
|
12
11
|
super();
|
|
13
12
|
|
|
14
|
-
/* Private Members */
|
|
15
|
-
this[table] = _table;
|
|
16
|
-
|
|
17
13
|
/* Private Methods */
|
|
18
14
|
this[updateOptions] = (()=>{
|
|
19
15
|
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
20
16
|
$select.innerHTML = '';
|
|
21
|
-
for (let i = 1; i <= this
|
|
17
|
+
for (let i = 1; i <= this.table.getTotalPages(); i++) {
|
|
22
18
|
const $option = document.createElement('option');
|
|
23
19
|
$option.value = i;
|
|
24
20
|
$option.textContent = i;
|
|
25
21
|
$select.appendChild($option);
|
|
26
22
|
}
|
|
27
|
-
$select.value = this
|
|
28
|
-
this.shadowRoot.getElementById('totalPages').textContent = this
|
|
23
|
+
$select.value = this.table.getCurrentPage();
|
|
24
|
+
this.shadowRoot.getElementById('totalPages').textContent = this.table.getTotalPages();
|
|
29
25
|
}).bind(this);
|
|
30
26
|
this[handleSelectChange] = (() => {
|
|
31
|
-
this
|
|
27
|
+
this.table.setPage(parseInt(this.shadowRoot.getElementById('pageSelect').value));
|
|
32
28
|
}).bind(this);
|
|
33
29
|
this[handlePageSizeChange] = (() => {
|
|
34
30
|
this[updateOptions]();
|
|
35
|
-
this.shadowRoot.getElementById('pageSelect').value = this
|
|
31
|
+
this.shadowRoot.getElementById('pageSelect').value = this.table.getCurrentPage();
|
|
36
32
|
}).bind(this);
|
|
37
33
|
this[handlePageChange] = (() => {
|
|
38
|
-
this.shadowRoot.getElementById('pageSelect').value = this
|
|
34
|
+
this.shadowRoot.getElementById('pageSelect').value = this.table.getCurrentPage();
|
|
39
35
|
}).bind(this);
|
|
40
36
|
this[handlePageCountChange] = (() => {
|
|
41
|
-
this.shadowRoot.getElementById('totalPages').textContent = this
|
|
37
|
+
this.shadowRoot.getElementById('totalPages').textContent = this.table.getTotalPages();
|
|
42
38
|
this[updateOptions]();
|
|
43
39
|
}).bind(this);
|
|
44
40
|
|
|
45
41
|
/* Init */
|
|
46
|
-
|
|
42
|
+
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
async render(force = false) {
|
|
50
46
|
if(await super.render(force)){
|
|
51
47
|
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
52
48
|
onEvent($select, 'change', this[handleSelectChange]);
|
|
53
|
-
onEvent(this
|
|
54
|
-
onEvent(this
|
|
55
|
-
onEvent(this
|
|
49
|
+
onEvent(this.table, 'pageSizeChange', this[handlePageSizeChange]);
|
|
50
|
+
onEvent(this.table, 'pageChange pageCountChanged', this[handlePageChange]);
|
|
51
|
+
onEvent(this.table, 'pageCountChanged', this[handlePageCountChange]);
|
|
56
52
|
this[updateOptions]();
|
|
57
53
|
return true;
|
|
58
54
|
}
|
|
@@ -61,11 +57,12 @@ export default class PageSelect extends Component {
|
|
|
61
57
|
disconnectedCallback(){
|
|
62
58
|
super.disconnectedCallback();
|
|
63
59
|
offEvent(this.shadowRoot.getElementById('pageSelect'), 'change', this[handleSelectChange]);
|
|
64
|
-
offEvent(this
|
|
65
|
-
offEvent(this
|
|
66
|
-
offEvent(this
|
|
60
|
+
offEvent(this.table, 'pageSizeChange', this[handlePageSizeChange]);
|
|
61
|
+
offEvent(this.table, 'pageChange pageCountChanged', this[handlePageChange]);
|
|
62
|
+
offEvent(this.table, 'pageCountChanged', this[handlePageCountChange]);
|
|
67
63
|
}
|
|
68
64
|
|
|
65
|
+
/* Shadow DOM */
|
|
69
66
|
get shadowTemplate() {
|
|
70
67
|
return /*html*/`
|
|
71
68
|
<select id="pageSelect" class="mxq"></select>
|
|
@@ -89,4 +86,4 @@ export default class PageSelect extends Component {
|
|
|
89
86
|
`;
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
window.customElements.define('k-
|
|
89
|
+
window.customElements.define('k-tc-page-select', PageSelect);
|
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
updateOptions = Symbol('updateOptions'),
|
|
4
|
+
const updateOptions = Symbol('updateOptions'),
|
|
6
5
|
changeHandler = Symbol('changeHandler'),
|
|
7
6
|
pageSizeChangeHandler = Symbol('pageSizeChangeHandler');
|
|
8
|
-
export default class PageSize extends
|
|
7
|
+
export default class PageSize extends TableControl {
|
|
9
8
|
constructor(_table) {
|
|
10
9
|
super();
|
|
11
10
|
|
|
12
|
-
/* Private Members */
|
|
13
|
-
this[table] = _table;
|
|
14
|
-
|
|
15
11
|
/* Private Methods */
|
|
16
12
|
this[updateOptions] = (()=>{
|
|
17
13
|
const $select = this.shadowRoot.getElementById('pageSizeSelect');
|
|
18
|
-
const options = this
|
|
14
|
+
const options = this.table.pageSizeOptions;
|
|
19
15
|
options.forEach(size => {
|
|
20
16
|
const $option = document.createElement('option');
|
|
21
17
|
$option.value = size;
|
|
22
18
|
$option.textContent = size;
|
|
23
19
|
$select.appendChild($option);
|
|
24
20
|
});
|
|
25
|
-
$select.value = this
|
|
21
|
+
$select.value = this.table.pageSize;
|
|
26
22
|
}).bind(this);
|
|
27
23
|
this[changeHandler] = (()=>{
|
|
28
|
-
this
|
|
24
|
+
this.table.setPageSize(parseInt(this.shadowRoot.getElementById('pageSizeSelect').value));
|
|
29
25
|
}).bind(this);
|
|
30
26
|
this[pageSizeChangeHandler] = (()=>{
|
|
31
|
-
this.shadowRoot.getElementById('pageSizeSelect').value = this
|
|
27
|
+
this.shadowRoot.getElementById('pageSizeSelect').value = this.table.pageSize;
|
|
32
28
|
}).bind(this);
|
|
33
29
|
|
|
34
30
|
/* Init */
|
|
35
|
-
|
|
31
|
+
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
async render(force = false) {
|
|
39
35
|
if(await super.render(force)){
|
|
40
36
|
onEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
41
|
-
onEvent(this
|
|
37
|
+
onEvent(this.table, 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
42
38
|
this[updateOptions]();
|
|
43
39
|
return true;
|
|
44
40
|
}
|
|
@@ -47,9 +43,10 @@ export default class PageSize extends Component {
|
|
|
47
43
|
disconnectedCallback(){
|
|
48
44
|
super.disconnectedCallback();
|
|
49
45
|
offEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
50
|
-
offEvent(this
|
|
46
|
+
offEvent(this.table, 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
51
47
|
}
|
|
52
48
|
|
|
49
|
+
/* Shadow DOM */
|
|
53
50
|
get shadowTemplate() {
|
|
54
51
|
return /*html*/`
|
|
55
52
|
<label for="pageSizeSelect">Page Size: </label>
|
|
@@ -70,4 +67,4 @@ export default class PageSize extends Component {
|
|
|
70
67
|
`;
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
window.customElements.define('k-
|
|
70
|
+
window.customElements.define('k-tc-page-size', PageSize);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const clickHandler = Symbol('clickHandler'),
|
|
5
|
+
handlePageChange = Symbol('handlePageChange');
|
|
6
|
+
export default class PrevPage extends TableControl {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Methods */
|
|
11
|
+
this[clickHandler] = this.prevPage.bind(this);
|
|
12
|
+
this[handlePageChange] = (()=>{
|
|
13
|
+
const table = this.table;
|
|
14
|
+
if(!table || table.getCurrentPage() === 1){
|
|
15
|
+
this.shadowRoot.getElementById('prevPage').disabled = true;
|
|
16
|
+
} else {
|
|
17
|
+
this.shadowRoot.getElementById('prevPage').disabled = false;
|
|
18
|
+
}
|
|
19
|
+
}).bind(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Lifecycle Callback */
|
|
23
|
+
async render(force = false) {
|
|
24
|
+
if(await super.render(force)) {
|
|
25
|
+
onEvent(this.shadowRoot.getElementById('prevPage'), 'click', this[clickHandler]);
|
|
26
|
+
this[handlePageChange]();
|
|
27
|
+
onEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback(){
|
|
33
|
+
super.disconnectedCallback();
|
|
34
|
+
offEvent(this.shadowRoot.getElementById('prevPage'), 'click', this[clickHandler]);
|
|
35
|
+
offEvent(this.table, 'pageChange', this[handlePageChange]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Public Methods */
|
|
39
|
+
prevPage(){
|
|
40
|
+
const table = this.table;
|
|
41
|
+
if(table){
|
|
42
|
+
table.prevPage();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Shadow DOM */
|
|
47
|
+
get shadowTemplate(){
|
|
48
|
+
return /*html*/`
|
|
49
|
+
<button
|
|
50
|
+
id="prevPage"
|
|
51
|
+
class="no-btn icon-btn"
|
|
52
|
+
>
|
|
53
|
+
<slot><k-icon name="chevron-left"></k-icon></slot>
|
|
54
|
+
</button>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
get shadowStyles(){
|
|
58
|
+
return /*css*/`
|
|
59
|
+
${super.shadowStyles}
|
|
60
|
+
#prevPage[disabled] {
|
|
61
|
+
cursor: inherit;
|
|
62
|
+
opacity: 0.5;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
window.customElements.define('k-tc-prev-page', PrevPage);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
import debounce from '../../utils/debounce.js';
|
|
4
|
+
|
|
5
|
+
const changeHandler = Symbol('changeHandler');
|
|
6
|
+
export default class Search extends TableControl {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Methods */
|
|
11
|
+
this[changeHandler] = debounce(this.search.bind(this), 200);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Lifecycle Callbacks */
|
|
15
|
+
async render(force = false) {
|
|
16
|
+
if (await super.render(force)) {
|
|
17
|
+
onEvent(this.shadowRoot.getElementById('search'), 'input', this[changeHandler]);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
disconnectedCallback(){
|
|
23
|
+
super.disconnectedCallback();
|
|
24
|
+
offEvent(this.shadowRoot.getElementById('search'), 'input', this[changeHandler]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Public Methods */
|
|
28
|
+
search() {
|
|
29
|
+
const term = this.shadowRoot.getElementById('search').value;
|
|
30
|
+
if (term.length < 3) {
|
|
31
|
+
this.table.showAllRecords();
|
|
32
|
+
} else {
|
|
33
|
+
this.table.search(term);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get shadowTemplate(){
|
|
38
|
+
return /*html*/`
|
|
39
|
+
<input
|
|
40
|
+
id="search"
|
|
41
|
+
type="search"
|
|
42
|
+
placeholder="Search"
|
|
43
|
+
class="px pyh"
|
|
44
|
+
/>
|
|
45
|
+
${super.shadowTemplate}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
window.customElements.define('k-tc-search', Search);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
export default class SelectCount extends
|
|
5
|
-
|
|
6
|
-
super()
|
|
7
|
-
this.table = table;
|
|
8
|
-
this.classList.add('mxq');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async render() {
|
|
12
|
-
if (await super.render()) {
|
|
4
|
+
export default class SelectCount extends TableControl {
|
|
5
|
+
async render(forced = false) {
|
|
6
|
+
if (await super.render(forced)) {
|
|
13
7
|
this.updateCount();
|
|
14
8
|
onEvent(this.table, 'selectionChange', () => {
|
|
15
9
|
this.updateCount();
|
|
@@ -24,6 +18,7 @@ export default class SelectCount extends Component {
|
|
|
24
18
|
$count.textContent = this.table.getSelectedRecords().length;
|
|
25
19
|
}
|
|
26
20
|
|
|
21
|
+
/* Shadow DOM */
|
|
27
22
|
get shadowTemplate() {
|
|
28
23
|
return /*html*/`
|
|
29
24
|
Selected: <span id="selectCount"></span>
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor(_table) {
|
|
4
|
+
const clickHandler = Symbol('clickHandler');
|
|
5
|
+
export default class HiddenCount extends TableControl {
|
|
6
|
+
constructor() {
|
|
8
7
|
super();
|
|
9
8
|
|
|
10
|
-
/* Private Members */
|
|
11
|
-
this[table] = _table;
|
|
12
|
-
|
|
13
9
|
/* Private Methods */
|
|
14
10
|
this[clickHandler] = (()=>{
|
|
15
|
-
this
|
|
11
|
+
this.table.showAllRecords();
|
|
16
12
|
}).bind(this);
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
|
|
19
15
|
}
|
|
20
16
|
async render(force = false) {
|
|
21
17
|
if (await super.render(force)) {
|
|
@@ -29,12 +25,13 @@ export default class HiddenCount extends Component {
|
|
|
29
25
|
offEvent(this.shadowRoot.getElementById('showAllButton'), 'click', this[clickHandler]);
|
|
30
26
|
}
|
|
31
27
|
|
|
28
|
+
/* Shadow DOM */
|
|
32
29
|
get shadowTemplate() {
|
|
33
30
|
return /*html*/`
|
|
34
|
-
<button id="showAllButton" class="
|
|
31
|
+
<button id="showAllButton" class="no-btn icon-btn">
|
|
35
32
|
<k-icon name="show"></k-icon>
|
|
36
33
|
</button>
|
|
37
34
|
`;
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
window.customElements.define('k-
|
|
37
|
+
window.customElements.define('k-tc-show-all', HiddenCount);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
|
|
3
|
+
export default class TableControl extends Component {
|
|
4
|
+
constructor({
|
|
5
|
+
maxWidth = 40
|
|
6
|
+
} = {}){
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.registerAttributes({
|
|
10
|
+
maxWidth
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Protected Members */
|
|
15
|
+
get table(){
|
|
16
|
+
if (this.getRootNode() instanceof ShadowRoot) {
|
|
17
|
+
return this.getRootNode().host.closest('k-table');
|
|
18
|
+
} else {
|
|
19
|
+
return this.closest('k-table');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
get record(){
|
|
23
|
+
if (this.getRootNode() instanceof ShadowRoot) {
|
|
24
|
+
const $record = this.closest('.record');
|
|
25
|
+
if($record){
|
|
26
|
+
const index = $record.dataset.index;
|
|
27
|
+
if(index){
|
|
28
|
+
return this.table.records[index];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get shadowStyles(){
|
|
36
|
+
return /*css*/`
|
|
37
|
+
${super.shadowStyles}
|
|
38
|
+
:host {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
}
|
|
41
|
+
.icon-btn {
|
|
42
|
+
display: inline-flex !important;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
width: 40px;
|
|
46
|
+
height: 40px;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// we do not need to register this component as a custom element because it is only used as a base class for other components
|