kempo 2.9.4 → 2.10.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/dist/components/Dialog.js +1 -1
- package/dist/components/Icon.js +1 -1
- package/dist/components/Search.js +1 -1
- package/dist/components/Table.js +1 -1
- package/dist/components/tableControls/DeleteSelected.js +1 -1
- package/dist/components/tableControls/Edit.js +1 -0
- package/dist/components/tableControls/Filters.js +1 -0
- package/dist/components/tableControls/HiddenCount.js +1 -0
- package/dist/components/tableControls/Hide.js +1 -0
- package/dist/components/tableControls/PageSelect.js +1 -1
- package/dist/components/tableControls/PageSize.js +1 -1
- package/dist/components/tableControls/ShowAll.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/table.html +82 -181
- package/docs/components/tableControls.html +91 -0
- package/docs/components/tableCustomFields.html +112 -0
- package/docs/components/tablePagination.html +92 -0
- package/docs/components/tableRecordEditing.html +144 -0
- package/docs/components/tableRecordFiltering.html +82 -0
- package/docs/components/tableRecordHiding.html +84 -0
- package/docs/components/tableRecordSelection.html +86 -0
- package/docs/components/tableRowControls.html +103 -0
- package/docs/icons/check.svg +1 -0
- package/docs/icons/hide.svg +1 -0
- package/docs/icons/show.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/Table.js +1 -1
- package/docs/kempo/components/tableControls/DeleteSelected.js +1 -1
- package/docs/kempo/components/tableControls/Edit.js +1 -0
- package/docs/kempo/components/tableControls/Filters.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/PageSelect.js +1 -1
- package/docs/kempo/components/tableControls/PageSize.js +1 -1
- package/docs/kempo/components/tableControls/ShowAll.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/check.svg +1 -0
- package/icons/hide.svg +1 -0
- package/icons/show.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/Table.js +469 -139
- package/src/components/tableControls/DeleteSelected.js +36 -22
- package/src/components/tableControls/Edit.js +88 -0
- package/src/components/tableControls/Filters.js +128 -0
- package/src/components/tableControls/HiddenCount.js +42 -0
- package/src/components/tableControls/Hide.js +43 -0
- package/src/components/tableControls/PageSelect.js +54 -30
- package/src/components/tableControls/PageSize.js +33 -16
- package/src/components/tableControls/ShowAll.js +40 -0
- package/src/kempo-styles.css +7 -0
- package/src/kempo-vars.css +2 -0
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
import Component from '../Component.js';
|
|
2
|
-
import { onEvent } from '../../utils/element.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
deleteSelected = Symbol('deleteSelected'),
|
|
6
|
+
updateButtonState = Symbol('updateButtonState');
|
|
4
7
|
export default class DeleteSelected extends Component {
|
|
5
|
-
constructor(
|
|
8
|
+
constructor(_table) {
|
|
6
9
|
super();
|
|
7
|
-
|
|
10
|
+
|
|
11
|
+
/* Private Members */
|
|
12
|
+
this[table] = _table;
|
|
13
|
+
|
|
14
|
+
/* Private Methods */
|
|
15
|
+
this[deleteSelected] = this.deleteSelected.bind(this);
|
|
16
|
+
this[updateButtonState] = (()=>{
|
|
17
|
+
this.shadowRoot.getElementById('deleteSelectedButton').disabled = this[table].getSelectedRecords().length === 0;
|
|
18
|
+
}).bind(this);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/* Init */
|
|
8
22
|
this.classList.add('mxq');
|
|
9
23
|
}
|
|
10
|
-
|
|
11
|
-
async render() {
|
|
12
|
-
if (await super.render()) {
|
|
13
|
-
this
|
|
14
|
-
|
|
15
|
-
onEvent(
|
|
16
|
-
onEvent(this.table, 'selectionChange', () => this.updateButtonState());
|
|
24
|
+
/* Lifecycle Callbacks */
|
|
25
|
+
async render(force = false) {
|
|
26
|
+
if (await super.render(force)) {
|
|
27
|
+
this[updateButtonState]();
|
|
28
|
+
onEvent(this.shadowRoot.getElementById('deleteSelectedButton'), 'click', this[deleteSelected]);
|
|
29
|
+
onEvent(this[table], 'selectionChange', this[updateButtonState]);
|
|
17
30
|
return true;
|
|
18
31
|
}
|
|
19
32
|
return false;
|
|
20
33
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
selectedIndexes.forEach(index => this.table.deleteRecord(index));
|
|
26
|
-
this.table.selectedIndexes = [];
|
|
27
|
-
this.table.renderRecords();
|
|
28
|
-
this.updateButtonState();
|
|
34
|
+
disconnectedCallback(){
|
|
35
|
+
super.disconnectedCallback();
|
|
36
|
+
offEvent(this.shadowRoot.getElementById('deleteSelectedButton'), 'click', this[deleteSelected]);
|
|
37
|
+
offEvent(this[table], 'selectionChange', this[updateButtonState]);
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
deleteSelected() {
|
|
41
|
+
this[table].deleteSelected();
|
|
42
|
+
this[updateButtonState]();
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
get shadowTemplate() {
|
|
@@ -48,10 +57,15 @@ export default class DeleteSelected extends Component {
|
|
|
48
57
|
width: max-content;
|
|
49
58
|
align-items: baseline;
|
|
50
59
|
}
|
|
51
|
-
|
|
60
|
+
#deleteSelectedButton {
|
|
52
61
|
display: flex;
|
|
53
62
|
align-items: center;
|
|
54
63
|
}
|
|
64
|
+
#deleteSelectedButton:disabled,
|
|
65
|
+
#deleteSelectedButton[disabled] {
|
|
66
|
+
cursor: not-allowed;
|
|
67
|
+
opacity: 0.5;
|
|
68
|
+
}
|
|
55
69
|
`;
|
|
56
70
|
}
|
|
57
71
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
record = Symbol('record'),
|
|
6
|
+
editRecord = Symbol('editRecord'),
|
|
7
|
+
saveRecord = Symbol('saveRecord'),
|
|
8
|
+
cancelEdit = Symbol('cancelEdit');
|
|
9
|
+
export default class Edit extends Component {
|
|
10
|
+
constructor(_table, _record) {
|
|
11
|
+
super();
|
|
12
|
+
|
|
13
|
+
/* Private Members */
|
|
14
|
+
this[table] = _table;
|
|
15
|
+
this[record] = _record;
|
|
16
|
+
|
|
17
|
+
/* Private Methods */
|
|
18
|
+
this[editRecord] = this.editRecord.bind(this);
|
|
19
|
+
this[saveRecord] = this.saveRecord.bind(this);
|
|
20
|
+
this[cancelEdit] = this.cancelEdit.bind(this);
|
|
21
|
+
|
|
22
|
+
/* Init */
|
|
23
|
+
this.registerAttributes({
|
|
24
|
+
editing: this[table].recordIsEditing(_record)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.classList.add('mxq');
|
|
28
|
+
}
|
|
29
|
+
async render(force = false) {
|
|
30
|
+
if (await super.render(force)) {
|
|
31
|
+
onEvent(this.shadowRoot.getElementById('editButton'), 'click', this[editRecord]);
|
|
32
|
+
onEvent(this.shadowRoot.getElementById('saveButton'), 'click', this[saveRecord]);
|
|
33
|
+
onEvent(this.shadowRoot.getElementById('cancelButton'), 'click', this[cancelEdit]);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
disconnectedCallback(){
|
|
39
|
+
super.disconnectedCallback();
|
|
40
|
+
offEvent(this.shadowRoot.getElementById('editButton'), 'click', this[editRecord]);
|
|
41
|
+
offEvent(this.shadowRoot.getElementById('saveButton'), 'click', this[saveRecord]);
|
|
42
|
+
offEvent(this.shadowRoot.getElementById('cancelButton'), 'click', this[cancelEdit]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
editRecord() {
|
|
46
|
+
this[table].editRecord(this[record]);
|
|
47
|
+
}
|
|
48
|
+
saveRecord() {
|
|
49
|
+
this[table].saveEditedRecord(this[record]);
|
|
50
|
+
}
|
|
51
|
+
cancelEdit() {
|
|
52
|
+
this[table].cancelEditedRecord(this[record]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get shadowTemplate() {
|
|
56
|
+
return /*html*/`
|
|
57
|
+
<button id="editButton" class="pq no-btn">
|
|
58
|
+
<k-icon name="edit"></k-icon>
|
|
59
|
+
</button>
|
|
60
|
+
<button id="cancelButton" class="pq no-btn bg-danger">
|
|
61
|
+
<k-icon name="close"></k-icon>
|
|
62
|
+
</button>
|
|
63
|
+
<button id="saveButton" class="pq no-btn bg-success">
|
|
64
|
+
<k-icon name="check"></k-icon>
|
|
65
|
+
</button>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get shadowStyles() {
|
|
70
|
+
return /*css*/`
|
|
71
|
+
:host {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
width: max-content;
|
|
74
|
+
align-items: baseline;
|
|
75
|
+
}
|
|
76
|
+
button {
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
}
|
|
80
|
+
:host([editing]) #editButton,
|
|
81
|
+
:host(:not([editing])) #cancelButton,
|
|
82
|
+
:host(:not([editing])) #saveButton {
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
window.customElements.define('k-table-edit', Edit);
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
import Dialog from '../Dialog.js';
|
|
3
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
4
|
+
|
|
5
|
+
const table = Symbol('table'),
|
|
6
|
+
clickHandler = Symbol('clickHandler');
|
|
7
|
+
export default class Filters extends Component {
|
|
8
|
+
constructor(_table) {
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
/* Private Members */
|
|
12
|
+
this[table] = _table;
|
|
13
|
+
|
|
14
|
+
/* Private Methods */
|
|
15
|
+
this[clickHandler] = this.revealFilters.bind(this);
|
|
16
|
+
|
|
17
|
+
/* Init */
|
|
18
|
+
this.classList.add('mxq');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Lifecycle Callbacks */
|
|
22
|
+
async render(force = false) {
|
|
23
|
+
if (await super.render(force)) {
|
|
24
|
+
onEvent(this.shadowRoot.getElementById('filterBtn'), 'click', this[clickHandler]);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback(){
|
|
30
|
+
super.disconnectedCallback();
|
|
31
|
+
offEvent(this.shadowRoot.getElementById('filterBtn'), 'click', this[clickHandler]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Public Methods */
|
|
35
|
+
revealFilters() {
|
|
36
|
+
function formatFilter({field, condition, value}) {
|
|
37
|
+
const conditionLabel = {
|
|
38
|
+
eq: 'equals',
|
|
39
|
+
ne: 'does not equal',
|
|
40
|
+
gt: 'is greater than',
|
|
41
|
+
gte: 'is greater than or equal to',
|
|
42
|
+
lt: 'is less than',
|
|
43
|
+
lte: 'is less than or equal to',
|
|
44
|
+
contains: 'contains',
|
|
45
|
+
starts: 'starts with',
|
|
46
|
+
ends: 'ends with'
|
|
47
|
+
}[condition];
|
|
48
|
+
return /*html*/`<li
|
|
49
|
+
data-field="${field}"
|
|
50
|
+
data-condition="${condition}"
|
|
51
|
+
data-value="${value}"
|
|
52
|
+
>
|
|
53
|
+
${field} ${conditionLabel} ${value}
|
|
54
|
+
<button class="remove-filter no-btn pq">
|
|
55
|
+
<k-icon name="close"></k-icon>
|
|
56
|
+
</button>
|
|
57
|
+
</li>`;
|
|
58
|
+
}
|
|
59
|
+
const $dialog = Dialog.create( /*html*/`
|
|
60
|
+
<h3 slot="title" class="m0 pyh px">Filters</h3>
|
|
61
|
+
<div class="p">
|
|
62
|
+
${this[table].filters.length === 0 ? /*html*/`
|
|
63
|
+
<p>No Current Filters.</p>
|
|
64
|
+
` : /*html*/`
|
|
65
|
+
<h5>Current Filters</h5>
|
|
66
|
+
<ul id="currentFilters">${
|
|
67
|
+
this[table].filters.map(formatFilter).join('')
|
|
68
|
+
}</ul>
|
|
69
|
+
`}
|
|
70
|
+
<hr />
|
|
71
|
+
<h5>Add A Filter</h5>
|
|
72
|
+
<form id="addFilter">
|
|
73
|
+
<select id="filterField" class="mb">${
|
|
74
|
+
this[table].fields.map(({name, label}) => /*html*/`<option value="${name}">${label}</option>`).join('')
|
|
75
|
+
}</select>
|
|
76
|
+
<select id="filterCondition" class="mb">${
|
|
77
|
+
Object.entries({
|
|
78
|
+
eq: 'equals',
|
|
79
|
+
ne: 'does not equal',
|
|
80
|
+
gt: 'is greater than',
|
|
81
|
+
gte: 'is greater than or equal to',
|
|
82
|
+
lt: 'is less than',
|
|
83
|
+
lte: 'is less than or equal to',
|
|
84
|
+
contains: 'contains',
|
|
85
|
+
starts: 'starts with',
|
|
86
|
+
ends: 'ends with'
|
|
87
|
+
}).map(([key, value]) => /*html*/`<option value="${key}" ${key==='contains'?'selected':''}>${value}</option>`).join('')
|
|
88
|
+
}</select>
|
|
89
|
+
<input id="filterValue" type="text" class="mb" />
|
|
90
|
+
<button type="submit" class="btn primary">Add Filter</button>
|
|
91
|
+
</form>
|
|
92
|
+
</div>
|
|
93
|
+
`, {
|
|
94
|
+
width: '600px'
|
|
95
|
+
});
|
|
96
|
+
const $form = $dialog.querySelector('#addFilter');
|
|
97
|
+
onEvent($form, 'submit', (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
this[table].addFilter(
|
|
100
|
+
$form.filterField.value,
|
|
101
|
+
$form.filterCondition.value,
|
|
102
|
+
$form.filterValue.value
|
|
103
|
+
);
|
|
104
|
+
$dialog.close();
|
|
105
|
+
this.revealFilters();
|
|
106
|
+
});
|
|
107
|
+
onEvent($dialog, 'click', (e) => {
|
|
108
|
+
if(e.target.closest('button')?.classList.contains('remove-filter')){
|
|
109
|
+
const $li = e.target.closest('li');
|
|
110
|
+
if($li){
|
|
111
|
+
const {field, condition, value} = $li.dataset;
|
|
112
|
+
this[table].removeFilter(field, condition, value);
|
|
113
|
+
$dialog.close();
|
|
114
|
+
this.revealFilters();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get shadowTemplate() {
|
|
121
|
+
return /*html*/`
|
|
122
|
+
<button id="filterBtn" class="no-btn pq">
|
|
123
|
+
<k-icon name="filter"></k-icon>
|
|
124
|
+
</button>
|
|
125
|
+
`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
window.customElements.define('k-table-filters', Filters);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
record = Symbol('record'),
|
|
6
|
+
hiddenChangeHandler = Symbol('hiddenChangeHandler');
|
|
7
|
+
export default class HiddenCount extends Component {
|
|
8
|
+
constructor(_table, _record) {
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
/* Private Members */
|
|
12
|
+
this[table] = _table;
|
|
13
|
+
this[record] = _record;
|
|
14
|
+
|
|
15
|
+
/* Private Methods */
|
|
16
|
+
this[hiddenChangeHandler] = (()=>{
|
|
17
|
+
this.shadowRoot.getElementById('hiddenCount').textContent = this[table].getHiddenRecords().length;
|
|
18
|
+
}).bind(this);
|
|
19
|
+
|
|
20
|
+
/* Init */
|
|
21
|
+
this.classList.add('mq');
|
|
22
|
+
}
|
|
23
|
+
async render(force = false) {
|
|
24
|
+
if (await super.render(force)) {
|
|
25
|
+
this[hiddenChangeHandler]()
|
|
26
|
+
onEvent(this[table], 'recordHidden recordShown', this[hiddenChangeHandler]);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback(){
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
offEvent(this[table], 'recordHidden recordShown', this[hiddenChangeHandler]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get shadowTemplate() {
|
|
37
|
+
return /*html*/`
|
|
38
|
+
<span id="hiddenCount"></span> Hidden Records
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
window.customElements.define('k-table-hidden-count', HiddenCount);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
record = Symbol('record'),
|
|
6
|
+
clickHandler = Symbol('clickHandler');
|
|
7
|
+
|
|
8
|
+
export default class Hide extends Component {
|
|
9
|
+
constructor(_table, _record) {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
/* Private Members */
|
|
13
|
+
this[table] = _table;
|
|
14
|
+
this[record] = _record;
|
|
15
|
+
|
|
16
|
+
/* Private Methods */
|
|
17
|
+
this[clickHandler] = (()=>{
|
|
18
|
+
this[table].hideRecord(this[record]);
|
|
19
|
+
}).bind(this);
|
|
20
|
+
|
|
21
|
+
this.classList.add('mxq');
|
|
22
|
+
}
|
|
23
|
+
async render(force = false) {
|
|
24
|
+
if (await super.render(force)) {
|
|
25
|
+
onEvent(this.shadowRoot.getElementById('hideButton'), 'click', this[clickHandler]);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
disconnectedCallback(){
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
offEvent(this.shadowRoot.getElementById('hideButton'), 'click', this[clickHandler]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get shadowTemplate() {
|
|
36
|
+
return /*html*/`
|
|
37
|
+
<button id="hideButton" class="pq no-btn">
|
|
38
|
+
<k-icon name="hide"></k-icon>
|
|
39
|
+
</button>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
window.customElements.define('k-table-hide', Hide);
|
|
@@ -1,45 +1,69 @@
|
|
|
1
1
|
import Component from '../Component.js';
|
|
2
2
|
import { onEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
updateOptions = Symbol('updateOptions'),
|
|
6
|
+
handleSelectChange = Symbol('handleSelectChange'),
|
|
7
|
+
handlePageSizeChange = Symbol('handlePageSizeChange'),
|
|
8
|
+
handlePageChange = Symbol('handlePageChange'),
|
|
9
|
+
handlePageCountChange = Symbol('handlePageCountChange');
|
|
4
10
|
export default class PageSelect extends Component {
|
|
5
|
-
constructor(
|
|
11
|
+
constructor(_table) {
|
|
6
12
|
super();
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
/* Private Members */
|
|
15
|
+
this[table] = _table;
|
|
16
|
+
|
|
17
|
+
/* Private Methods */
|
|
18
|
+
this[updateOptions] = (()=>{
|
|
19
|
+
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
20
|
+
$select.innerHTML = '';
|
|
21
|
+
for (let i = 1; i <= this[table].getTotalPages(); i++) {
|
|
22
|
+
const $option = document.createElement('option');
|
|
23
|
+
$option.value = i;
|
|
24
|
+
$option.textContent = i;
|
|
25
|
+
$select.appendChild($option);
|
|
26
|
+
}
|
|
27
|
+
$select.value = this[table].getCurrentPage();
|
|
28
|
+
this.shadowRoot.getElementById('totalPages').textContent = this[table].getTotalPages();
|
|
29
|
+
}).bind(this);
|
|
30
|
+
this[handleSelectChange] = (() => {
|
|
31
|
+
this[table].setPage(parseInt(this.shadowRoot.getElementById('pageSelect').value));
|
|
32
|
+
}).bind(this);
|
|
33
|
+
this[handlePageSizeChange] = (() => {
|
|
34
|
+
this[updateOptions]();
|
|
35
|
+
this.shadowRoot.getElementById('pageSelect').value = this[table].getCurrentPage();
|
|
36
|
+
}).bind(this);
|
|
37
|
+
this[handlePageChange] = (() => {
|
|
38
|
+
this.shadowRoot.getElementById('pageSelect').value = this[table].getCurrentPage();
|
|
39
|
+
}).bind(this);
|
|
40
|
+
this[handlePageCountChange] = (() => {
|
|
41
|
+
this.shadowRoot.getElementById('totalPages').textContent = this[table].getTotalPages();
|
|
42
|
+
this[updateOptions]();
|
|
43
|
+
}).bind(this);
|
|
44
|
+
|
|
45
|
+
/* Init */
|
|
8
46
|
this.classList.add('mxq');
|
|
9
47
|
}
|
|
10
48
|
|
|
11
|
-
async render() {
|
|
12
|
-
if(await super.render()){
|
|
13
|
-
this.
|
|
49
|
+
async render(force = false) {
|
|
50
|
+
if(await super.render(force)){
|
|
51
|
+
const $select = this.shadowRoot.getElementById('pageSelect');
|
|
52
|
+
onEvent($select, 'change', this[handleSelectChange]);
|
|
53
|
+
onEvent(this[table], 'pageSizeChange', this[handlePageSizeChange]);
|
|
54
|
+
onEvent(this[table], 'pageChange pageCountChanged', this[handlePageChange]);
|
|
55
|
+
onEvent(this[table], 'pageCountChanged', this[handlePageCountChange]);
|
|
56
|
+
this[updateOptions]();
|
|
14
57
|
return true;
|
|
15
58
|
}
|
|
16
59
|
return false;
|
|
17
60
|
}
|
|
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
|
-
});
|
|
61
|
+
disconnectedCallback(){
|
|
62
|
+
super.disconnectedCallback();
|
|
63
|
+
offEvent(this.shadowRoot.getElementById('pageSelect'), 'change', this[handleSelectChange]);
|
|
64
|
+
offEvent(this[table], 'pageSizeChange', this[handlePageSizeChange]);
|
|
65
|
+
offEvent(this[table], 'pageChange pageCountChanged', this[handlePageChange]);
|
|
66
|
+
offEvent(this[table], 'pageCountChanged', this[handlePageCountChange]);
|
|
43
67
|
}
|
|
44
68
|
|
|
45
69
|
get shadowTemplate() {
|
|
@@ -1,37 +1,54 @@
|
|
|
1
1
|
import Component from '../Component.js';
|
|
2
|
-
import { onEvent } from '../../utils/element.js';
|
|
2
|
+
import { onEvent, offEvent } from '../../utils/element.js';
|
|
3
3
|
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
updateOptions = Symbol('updateOptions'),
|
|
6
|
+
changeHandler = Symbol('changeHandler'),
|
|
7
|
+
pageSizeChangeHandler = Symbol('pageSizeChangeHandler');
|
|
4
8
|
export default class PageSize extends Component {
|
|
5
|
-
constructor(
|
|
9
|
+
constructor(_table) {
|
|
6
10
|
super();
|
|
7
|
-
this.table = table;
|
|
8
|
-
this.classList.add('mxq');
|
|
9
|
-
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/* Private Members */
|
|
13
|
+
this[table] = _table;
|
|
14
|
+
|
|
15
|
+
/* Private Methods */
|
|
16
|
+
this[updateOptions] = (()=>{
|
|
13
17
|
const $select = this.shadowRoot.getElementById('pageSizeSelect');
|
|
14
|
-
const options = this
|
|
18
|
+
const options = this[table].pageSizeOptions;
|
|
15
19
|
options.forEach(size => {
|
|
16
20
|
const $option = document.createElement('option');
|
|
17
21
|
$option.value = size;
|
|
18
22
|
$option.textContent = size;
|
|
19
23
|
$select.appendChild($option);
|
|
20
24
|
});
|
|
21
|
-
$select.value = this
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
$select.value = this[table].pageSize;
|
|
26
|
+
}).bind(this);
|
|
27
|
+
this[changeHandler] = (()=>{
|
|
28
|
+
this[table].setPageSize(parseInt(this.shadowRoot.getElementById('pageSizeSelect').value));
|
|
29
|
+
}).bind(this);
|
|
30
|
+
this[pageSizeChangeHandler] = (()=>{
|
|
31
|
+
this.shadowRoot.getElementById('pageSizeSelect').value = this[table].pageSize;
|
|
32
|
+
}).bind(this);
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
/* Init */
|
|
35
|
+
this.classList.add('mxq');
|
|
36
|
+
}
|
|
30
37
|
|
|
38
|
+
async render(force = false) {
|
|
39
|
+
if(await super.render(force)){
|
|
40
|
+
onEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
41
|
+
onEvent(this[table], 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
42
|
+
this[updateOptions]();
|
|
31
43
|
return true;
|
|
32
44
|
}
|
|
33
45
|
return false;
|
|
34
46
|
}
|
|
47
|
+
disconnectedCallback(){
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
offEvent(this.shadowRoot.getElementById('pageSizeSelect'), 'change', this[changeHandler]);
|
|
50
|
+
offEvent(this[table], 'pageSizeChange', this[pageSizeChangeHandler]);
|
|
51
|
+
}
|
|
35
52
|
|
|
36
53
|
get shadowTemplate() {
|
|
37
54
|
return /*html*/`
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Component from '../Component.js';
|
|
2
|
+
import { offEvent, onEvent } from '../../utils/element.js';
|
|
3
|
+
|
|
4
|
+
const table = Symbol('table'),
|
|
5
|
+
clickHandler = Symbol('clickHandler');
|
|
6
|
+
export default class HiddenCount extends Component {
|
|
7
|
+
constructor(_table) {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/* Private Members */
|
|
11
|
+
this[table] = _table;
|
|
12
|
+
|
|
13
|
+
/* Private Methods */
|
|
14
|
+
this[clickHandler] = (()=>{
|
|
15
|
+
this[table].showAllRecords();
|
|
16
|
+
}).bind(this);
|
|
17
|
+
|
|
18
|
+
this.classList.add('mxq');
|
|
19
|
+
}
|
|
20
|
+
async render(force = false) {
|
|
21
|
+
if (await super.render(force)) {
|
|
22
|
+
onEvent(this.shadowRoot.getElementById('showAllButton'), 'click', this[clickHandler]);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
disconnectedCallback(){
|
|
28
|
+
super.disconnectedCallback();
|
|
29
|
+
offEvent(this.shadowRoot.getElementById('showAllButton'), 'click', this[clickHandler]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get shadowTemplate() {
|
|
33
|
+
return /*html*/`
|
|
34
|
+
<button id="showAllButton" class="pq no-btn">
|
|
35
|
+
<k-icon name="show"></k-icon>
|
|
36
|
+
</button>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
window.customElements.define('k-table-show-all', HiddenCount);
|
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
|
}
|