kempo 2.9.4 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Dialog.js +1 -1
- package/dist/components/Icon.js +1 -1
- 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 -0
- 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 -0
- package/dist/components/tableControls/FirstPage.js +1 -0
- package/dist/components/tableControls/HiddenCount.js +1 -0
- package/dist/components/tableControls/Hide.js +1 -0
- 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 -0
- package/dist/components/tableControls/ShowHideFields.js +1 -0
- package/dist/components/tableControls/TableControl.js +1 -0
- package/dist/index.js +1 -1
- package/dist/kempo-styles.css +1 -1
- package/dist/kempo-vars.css +1 -1
- package/docs/components/sortable.html +96 -0
- package/docs/components/table.html +108 -182
- package/docs/components/tableControls.html +77 -0
- package/docs/components/tableCustomFields.html +112 -0
- package/docs/components/tableFetchRecords.html +114 -0
- package/docs/components/tableFieldSortHide.html +75 -0
- package/docs/components/tablePagination.html +100 -0
- package/docs/components/tableRecordEditing.html +144 -0
- package/docs/components/tableRecordFiltering.html +75 -0
- package/docs/components/tableRecordHiding.html +80 -0
- package/docs/components/tableRecordSearching.html +75 -0
- package/docs/components/tableRecordSelection.html +75 -0
- package/docs/components/tableRowControls.html +78 -0
- 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/check.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/hide.svg +1 -0
- package/docs/icons/last.svg +1 -0
- package/docs/icons/show.svg +1 -0
- package/docs/icons/table-visibility.svg +1 -0
- package/docs/kempo/components/Dialog.js +1 -1
- package/docs/kempo/components/Icon.js +1 -1
- 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 -0
- 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 -0
- package/docs/kempo/components/tableControls/FirstPage.js +1 -0
- package/docs/kempo/components/tableControls/HiddenCount.js +1 -0
- package/docs/kempo/components/tableControls/Hide.js +1 -0
- 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 -0
- 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/docs/kempo/kempo-styles.css +1 -1
- package/docs/kempo/kempo-vars.css +1 -1
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/check.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/hide.svg +1 -0
- package/icons/last.svg +1 -0
- package/icons/show.svg +1 -0
- package/icons/table-visibility.svg +1 -0
- package/package.json +1 -1
- package/src/components/Dialog.js +12 -4
- package/src/components/Icon.js +3 -1
- package/src/components/Sortable.js +169 -0
- package/src/components/Table.js +703 -247
- package/src/components/tableControls/DeleteRecord.js +43 -0
- package/src/components/tableControls/DeleteSelected.js +36 -24
- package/src/components/tableControls/Edit.js +84 -0
- 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 +129 -0
- package/src/components/tableControls/FirstPage.js +69 -0
- package/src/components/tableControls/HiddenCount.js +37 -0
- package/src/components/tableControls/Hide.js +40 -0
- package/src/components/tableControls/LastPage.js +67 -0
- package/src/components/tableControls/NextPage.js +69 -0
- package/src/components/tableControls/PageSelect.js +55 -34
- package/src/components/tableControls/PageSize.js +31 -17
- 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 +37 -0
- package/src/components/tableControls/TableControl.js +51 -0
- package/src/kempo-styles.css +7 -0
- package/src/kempo-vars.css +2 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const clickHandler = Symbol('clickHandler');
|
|
5
|
+
|
|
6
|
+
export default class Hide extends TableControl {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Methods */
|
|
11
|
+
this[clickHandler] = (()=>{
|
|
12
|
+
const table = this.table;
|
|
13
|
+
const record = this.record;
|
|
14
|
+
if(table && record){
|
|
15
|
+
table.hideRecord(record);
|
|
16
|
+
}
|
|
17
|
+
}).bind(this);
|
|
18
|
+
}
|
|
19
|
+
async render(force = false) {
|
|
20
|
+
if (await super.render(force)) {
|
|
21
|
+
onEvent(this.shadowRoot.getElementById('hideButton'), 'click', this[clickHandler]);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback(){
|
|
27
|
+
super.disconnectedCallback();
|
|
28
|
+
offEvent(this.shadowRoot.getElementById('hideButton'), 'click', this[clickHandler]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Shadow DOM */
|
|
32
|
+
get shadowTemplate() {
|
|
33
|
+
return /*html*/`
|
|
34
|
+
<button id="hideButton" class="no-btn icon-btn">
|
|
35
|
+
<k-icon name="hide"></k-icon>
|
|
36
|
+
</button>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
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,47 +1,68 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
2
|
import { onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const updateOptions = Symbol('updateOptions'),
|
|
5
|
+
handleSelectChange = Symbol('handleSelectChange'),
|
|
6
|
+
handlePageSizeChange = Symbol('handlePageSizeChange'),
|
|
7
|
+
handlePageChange = Symbol('handlePageChange'),
|
|
8
|
+
handlePageCountChange = Symbol('handlePageCountChange');
|
|
9
|
+
export default class PageSelect extends TableControl {
|
|
10
|
+
constructor() {
|
|
6
11
|
super();
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
|
|
13
|
+
/* Private Methods */
|
|
14
|
+
this[updateOptions] = (()=>{
|
|
15
|
+
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
16
|
+
$select.innerHTML = '';
|
|
17
|
+
for (let i = 1; i <= this.table.getTotalPages(); i++) {
|
|
18
|
+
const $option = document.createElement('option');
|
|
19
|
+
$option.value = i;
|
|
20
|
+
$option.textContent = i;
|
|
21
|
+
$select.appendChild($option);
|
|
22
|
+
}
|
|
23
|
+
$select.value = this.table.getCurrentPage();
|
|
24
|
+
this.shadowRoot.getElementById('totalPages').textContent = this.table.getTotalPages();
|
|
25
|
+
}).bind(this);
|
|
26
|
+
this[handleSelectChange] = (() => {
|
|
27
|
+
this.table.setPage(parseInt(this.shadowRoot.getElementById('pageSelect').value));
|
|
28
|
+
}).bind(this);
|
|
29
|
+
this[handlePageSizeChange] = (() => {
|
|
30
|
+
this[updateOptions]();
|
|
31
|
+
this.shadowRoot.getElementById('pageSelect').value = this.table.getCurrentPage();
|
|
32
|
+
}).bind(this);
|
|
33
|
+
this[handlePageChange] = (() => {
|
|
34
|
+
this.shadowRoot.getElementById('pageSelect').value = this.table.getCurrentPage();
|
|
35
|
+
}).bind(this);
|
|
36
|
+
this[handlePageCountChange] = (() => {
|
|
37
|
+
this.shadowRoot.getElementById('totalPages').textContent = this.table.getTotalPages();
|
|
38
|
+
this[updateOptions]();
|
|
39
|
+
}).bind(this);
|
|
40
|
+
|
|
41
|
+
/* Init */
|
|
42
|
+
|
|
9
43
|
}
|
|
10
44
|
|
|
11
|
-
async render() {
|
|
12
|
-
if(await super.render()){
|
|
13
|
-
this.
|
|
45
|
+
async render(force = false) {
|
|
46
|
+
if(await super.render(force)){
|
|
47
|
+
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
48
|
+
onEvent($select, 'change', this[handleSelectChange]);
|
|
49
|
+
onEvent(this.table, 'pageSizeChange', this[handlePageSizeChange]);
|
|
50
|
+
onEvent(this.table, 'pageChange pageCountChanged', this[handlePageChange]);
|
|
51
|
+
onEvent(this.table, 'pageCountChanged', this[handlePageCountChange]);
|
|
52
|
+
this[updateOptions]();
|
|
14
53
|
return true;
|
|
15
54
|
}
|
|
16
55
|
return false;
|
|
17
56
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
$option.value = i;
|
|
25
|
-
$option.textContent = i;
|
|
26
|
-
$select.appendChild($option);
|
|
27
|
-
}
|
|
28
|
-
$select.value = this.table.getCurrentPage();
|
|
29
|
-
const $totalPages = this.shadowRoot.getElementById('totalPages');
|
|
30
|
-
$totalPages.textContent = this.table.getTotalPages();
|
|
31
|
-
|
|
32
|
-
onEvent($select, 'change', () => {
|
|
33
|
-
this.table.setPage(parseInt($select.value));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
onEvent(this.table, 'pageSizeChange', () => {
|
|
37
|
-
this.updateOptions();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
onEvent(this.table, 'pageChange', () => {
|
|
41
|
-
$select.value = this.table.getCurrentPage();
|
|
42
|
-
});
|
|
57
|
+
disconnectedCallback(){
|
|
58
|
+
super.disconnectedCallback();
|
|
59
|
+
offEvent(this.shadowRoot.getElementById('pageSelect'), 'change', this[handleSelectChange]);
|
|
60
|
+
offEvent(this.table, 'pageSizeChange', this[handlePageSizeChange]);
|
|
61
|
+
offEvent(this.table, 'pageChange pageCountChanged', this[handlePageChange]);
|
|
62
|
+
offEvent(this.table, 'pageCountChanged', this[handlePageCountChange]);
|
|
43
63
|
}
|
|
44
64
|
|
|
65
|
+
/* Shadow DOM */
|
|
45
66
|
get shadowTemplate() {
|
|
46
67
|
return /*html*/`
|
|
47
68
|
<select id="pageSelect" class="mxq"></select>
|
|
@@ -65,4 +86,4 @@ export default class PageSelect extends Component {
|
|
|
65
86
|
`;
|
|
66
87
|
}
|
|
67
88
|
}
|
|
68
|
-
window.customElements.define('k-
|
|
89
|
+
window.customElements.define('k-tc-page-select', PageSelect);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { onEvent } from '../../utils/element.js';
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const updateOptions = Symbol('updateOptions'),
|
|
5
|
+
changeHandler = Symbol('changeHandler'),
|
|
6
|
+
pageSizeChangeHandler = Symbol('pageSizeChangeHandler');
|
|
7
|
+
export default class PageSize extends TableControl {
|
|
8
|
+
constructor(_table) {
|
|
6
9
|
super();
|
|
7
|
-
this.table = table;
|
|
8
|
-
this.classList.add('mxq');
|
|
9
|
-
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/* Private Methods */
|
|
12
|
+
this[updateOptions] = (()=>{
|
|
13
13
|
const $select = this.shadowRoot.getElementById('pageSizeSelect');
|
|
14
14
|
const options = this.table.pageSizeOptions;
|
|
15
15
|
options.forEach(size => {
|
|
@@ -19,20 +19,34 @@ export default class PageSize extends Component {
|
|
|
19
19
|
$select.appendChild($option);
|
|
20
20
|
});
|
|
21
21
|
$select.value = this.table.pageSize;
|
|
22
|
+
}).bind(this);
|
|
23
|
+
this[changeHandler] = (()=>{
|
|
24
|
+
this.table.setPageSize(parseInt(this.shadowRoot.getElementById('pageSizeSelect').value));
|
|
25
|
+
}).bind(this);
|
|
26
|
+
this[pageSizeChangeHandler] = (()=>{
|
|
27
|
+
this.shadowRoot.getElementById('pageSizeSelect').value = this.table.pageSize;
|
|
28
|
+
}).bind(this);
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onEvent(this.table, 'pageSizeChange', () => {
|
|
28
|
-
$select.value = this.table.pageSize;
|
|
29
|
-
});
|
|
30
|
+
/* Init */
|
|
31
|
+
|
|
32
|
+
}
|
|
30
33
|
|
|
34
|
+
async render(force = false) {
|
|
35
|
+
if(await super.render(force)){
|
|
36
|
+
onEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
37
|
+
onEvent(this.table, 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
38
|
+
this[updateOptions]();
|
|
31
39
|
return true;
|
|
32
40
|
}
|
|
33
41
|
return false;
|
|
34
42
|
}
|
|
43
|
+
disconnectedCallback(){
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
offEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
46
|
+
offEvent(this.table, 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
47
|
+
}
|
|
35
48
|
|
|
49
|
+
/* Shadow DOM */
|
|
36
50
|
get shadowTemplate() {
|
|
37
51
|
return /*html*/`
|
|
38
52
|
<label for="pageSizeSelect">Page Size: </label>
|
|
@@ -53,4 +67,4 @@ export default class PageSize extends Component {
|
|
|
53
67
|
`;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
|
-
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>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const clickHandler = Symbol('clickHandler');
|
|
5
|
+
export default class HiddenCount extends TableControl {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
/* Private Methods */
|
|
10
|
+
this[clickHandler] = (()=>{
|
|
11
|
+
this.table.showAllRecords();
|
|
12
|
+
}).bind(this);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
async render(force = false) {
|
|
17
|
+
if (await super.render(force)) {
|
|
18
|
+
onEvent(this.shadowRoot.getElementById('showAllButton'), 'click', this[clickHandler]);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback(){
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
offEvent(this.shadowRoot.getElementById('showAllButton'), 'click', this[clickHandler]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Shadow DOM */
|
|
29
|
+
get shadowTemplate() {
|
|
30
|
+
return /*html*/`
|
|
31
|
+
<button id="showAllButton" class="no-btn icon-btn">
|
|
32
|
+
<k-icon name="show"></k-icon>
|
|
33
|
+
</button>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
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
|
package/src/kempo-styles.css
CHANGED
|
@@ -724,6 +724,13 @@ input[type="color"]::-webkit-color-swatch {
|
|
|
724
724
|
border-radius: var(--radius, 0.25rem);
|
|
725
725
|
cursor: pointer;
|
|
726
726
|
}
|
|
727
|
+
input[type="date"]::-webkit-calendar-picker-indicator,
|
|
728
|
+
input[type="month"]::-webkit-calendar-picker-indicator,
|
|
729
|
+
input[type="time"]::-webkit-calendar-picker-indicator,
|
|
730
|
+
input[type="week"]::-webkit-calendar-picker-indicator,
|
|
731
|
+
input[type="search"]::-webkit-search-cancel-button {
|
|
732
|
+
filter: var(--date_picker_icon_filter);
|
|
733
|
+
}
|
|
727
734
|
|
|
728
735
|
/*
|
|
729
736
|
Tables
|
package/src/kempo-vars.css
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
--input_padding: var(--spacer_h) var(--spacer);
|
|
25
25
|
--input_border_width: 2px;
|
|
26
26
|
--btn_padding: var(--spacer_h) var(--spacer);
|
|
27
|
+
--date_picker_icon_filter: invert(0);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
:root,
|
|
@@ -154,4 +155,5 @@
|
|
|
154
155
|
--drop_shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.25);
|
|
155
156
|
--link_decoration: underline;
|
|
156
157
|
--input_border_width: 2px;
|
|
158
|
+
--date_picker_icon_filter: invert(1)
|
|
157
159
|
}
|