kempo-ui 0.0.2 → 0.0.4
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/.github/copilot-instructions.md +149 -149
- package/.github/workflows/publish-major.yml +39 -0
- package/.github/workflows/publish-minor.yml +39 -0
- package/.github/workflows/{publish-npm.yml → publish-patch.yml} +44 -44
- package/.vscode/settings.json +2 -0
- package/CONTRIBUTING.md +149 -149
- package/README.md +0 -0
- package/dist/kempo-hljs.css +1 -0
- package/dist/kempo-vars.css +0 -0
- package/dist/src/components/Accordion.js +36 -0
- package/dist/src/components/Card.js +37 -0
- package/dist/src/components/Collapsible.js +41 -0
- package/dist/src/components/ContentSlider.js +44 -0
- package/dist/src/components/Dialog.js +113 -0
- package/dist/src/components/FocusCapture.js +7 -0
- package/dist/src/components/Icon.js +10 -0
- package/dist/src/components/Import.js +1 -0
- package/dist/src/components/PersistantCollapsible.js +1 -0
- package/dist/src/components/PhotoViewer.js +135 -0
- package/dist/src/components/Resize.js +96 -0
- package/dist/src/components/ShadowComponent.js +1 -0
- package/dist/src/components/ShowMore.js +42 -0
- package/dist/src/components/SideMenu.js +97 -0
- package/dist/src/components/Split.js +84 -0
- package/dist/src/components/Tabs.js +155 -0
- package/dist/src/components/Tags.js +69 -0
- package/dist/src/components/ThemeSwitcher.js +23 -0
- package/dist/src/components/Timestamp.js +1 -0
- package/dist/src/lit-all.min.js +120 -0
- package/dist/src/utils/debounce.js +1 -0
- package/dist/src/utils/drag.js +1 -0
- package/dist/src/utils/formatTimestamp.js +1 -0
- package/dist/src/utils/propConverters.js +1 -0
- package/dist/src/utils/watchWindowSize.js +1 -0
- package/docs/components/accordion.html +166 -0
- package/docs/components/card.html +92 -0
- package/docs/components/collapsible.html +198 -0
- package/docs/components/content-slider.html +223 -0
- package/docs/components/dialog.html +251 -0
- package/docs/components/focus-capture.html +67 -0
- package/docs/components/icon.html +158 -0
- package/docs/components/import.html +73 -0
- package/docs/components/persistant-collapsible.html +123 -0
- package/docs/components/photo-viewer.html +226 -0
- package/docs/components/resize.html +178 -0
- package/docs/components/show-more.html +129 -0
- package/docs/components/side-menu.html +159 -0
- package/docs/components/split.html +147 -0
- package/docs/components/table.html +312 -0
- package/docs/components/tableControls.html +77 -0
- package/docs/components/tableCustomFields.html +113 -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 +88 -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/components/tabs.html +180 -0
- package/docs/components/tags.html +110 -0
- package/docs/components/theme-switcher.html +126 -0
- package/docs/components/timestamp.html +82 -0
- package/docs/components/toast.html +319 -0
- package/docs/components/toggle.html +156 -0
- package/docs/dev.config.json +20 -0
- package/docs/icons/add.svg +1 -0
- package/docs/icons/arrow-back.svg +1 -0
- package/docs/icons/arrow-down-double.svg +1 -0
- package/docs/icons/arrow-down.svg +1 -0
- package/docs/icons/arrow-forward.svg +1 -0
- package/docs/icons/arrow-up-double.svg +1 -0
- package/docs/icons/arrow-up.svg +1 -0
- package/docs/icons/cards.svg +1 -0
- package/docs/icons/check.svg +1 -0
- package/docs/icons/chevron-left.svg +1 -0
- package/docs/icons/chevron-right.svg +1 -0
- package/docs/icons/close.svg +2 -0
- package/docs/icons/compare.svg +1 -0
- package/docs/icons/delete.svg +1 -0
- package/docs/icons/drag-handle.svg +1 -0
- package/docs/icons/drawing2.svg +124 -0
- package/docs/icons/edit.svg +1 -0
- package/docs/icons/error.svg +1 -0
- package/docs/icons/export-file.svg +1 -0
- package/docs/icons/file-text.svg +1 -0
- package/docs/icons/file.svg +1 -0
- package/docs/icons/filter-off.svg +1 -0
- package/docs/icons/filter.svg +1 -0
- package/docs/icons/first.svg +1 -0
- package/docs/icons/folder-clear.svg +1 -0
- package/docs/icons/folder-create.svg +1 -0
- package/docs/icons/folder-open.svg +1 -0
- package/docs/icons/folder.svg +1 -0
- package/docs/icons/hide.svg +1 -0
- package/docs/icons/image.svg +1 -0
- package/docs/icons/label-add.svg +1 -0
- package/docs/icons/label.svg +1 -0
- package/docs/icons/last.svg +1 -0
- package/docs/icons/menu.svg +1 -0
- package/docs/icons/mode-auto.svg +1 -0
- package/docs/icons/mode-dark.svg +1 -0
- package/docs/icons/mode-light.svg +1 -0
- package/docs/icons/open-in-browser.svg +1 -0
- package/docs/icons/pause.svg +1 -0
- package/docs/icons/play.svg +1 -0
- package/docs/icons/refresh.svg +1 -0
- package/docs/icons/remove.svg +1 -0
- package/docs/icons/save.svg +1 -0
- package/docs/icons/search.svg +1 -0
- package/docs/icons/settings.svg +1 -0
- package/docs/icons/show.svg +1 -0
- package/docs/icons/storage.svg +1 -0
- package/docs/icons/table-visibility.svg +1 -0
- package/docs/icons/tag.svg +1 -0
- package/docs/icons/tools.svg +1 -0
- package/docs/icons/trash-x.svg +1 -0
- package/docs/icons/warning.svg +1 -0
- package/docs/index.html +28 -21
- package/docs/kempo-hljs.css +1 -0
- package/docs/media/civic.jpg +0 -0
- package/docs/media/corvette.jpg +0 -0
- package/docs/media/evo.jpg +0 -0
- package/docs/media/gtr.jpg +0 -0
- package/docs/media/nsx.jpg +0 -0
- package/docs/nav.inc.html +67 -0
- package/docs/nav.inc.js +4 -0
- package/{config/production.json → docs/prod.config.json} +20 -16
- package/docs/src/components/Accordion.js +36 -0
- package/docs/src/components/Card.js +37 -0
- package/docs/src/components/Collapsible.js +41 -0
- package/docs/src/components/ContentSlider.js +44 -0
- package/docs/src/components/Dialog.js +113 -0
- package/docs/src/components/FocusCapture.js +7 -0
- package/docs/src/components/HybridComponent.js +1 -0
- package/docs/src/components/Icon.js +10 -0
- package/docs/src/components/Import.js +1 -0
- package/docs/src/components/LightComponent.js +1 -0
- package/docs/src/components/PersistantCollapsible.js +1 -0
- package/docs/src/components/PhotoViewer.js +135 -0
- package/docs/src/components/Resize.js +96 -0
- package/docs/src/components/ShadowComponent.js +1 -0
- package/docs/src/components/ShowMore.js +42 -0
- package/docs/src/components/SideMenu.js +97 -0
- package/docs/src/components/Split.js +84 -0
- package/docs/src/components/Tabs.js +155 -0
- package/docs/src/components/Tags.js +69 -0
- package/docs/src/components/ThemeSwitcher.js +23 -0
- package/docs/src/components/Timestamp.js +1 -0
- package/docs/src/lit-all.min.js +120 -0
- package/docs/src/utils/debounce.js +1 -0
- package/docs/src/utils/drag.js +1 -0
- package/docs/src/utils/formatTimestamp.js +1 -0
- package/docs/src/utils/propConverters.js +1 -0
- package/docs/src/utils/watchWindowSize.js +1 -0
- package/docs/styles.css +6 -0
- package/docs/utils/debounce.html +78 -0
- package/docs/utils/drag.html +104 -0
- package/docs/utils/formatTimestamp.html +114 -0
- package/docs/utils/propConverters.html +132 -0
- package/docs/utils/watchWindowSize.html +166 -0
- package/icons/add.svg +1 -0
- package/icons/arrow-back.svg +1 -0
- package/icons/arrow-down-double.svg +1 -0
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-forward.svg +1 -0
- package/icons/arrow-up-double.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/cards.svg +1 -0
- package/icons/check.svg +1 -0
- package/icons/chevron-left.svg +1 -0
- package/icons/chevron-right.svg +1 -0
- package/icons/close.svg +2 -0
- package/icons/compare.svg +1 -0
- package/icons/delete.svg +1 -0
- package/icons/drag-handle.svg +1 -0
- package/icons/drawing2.svg +124 -0
- package/icons/edit.svg +1 -0
- package/icons/error.svg +1 -0
- package/icons/export-file.svg +1 -0
- package/icons/file-text.svg +1 -0
- package/icons/file.svg +1 -0
- package/icons/filter-off.svg +1 -0
- package/icons/filter.svg +1 -0
- package/icons/first.svg +1 -0
- package/icons/folder-clear.svg +1 -0
- package/icons/folder-create.svg +1 -0
- package/icons/folder-open.svg +1 -0
- package/icons/folder.svg +1 -0
- package/icons/hide.svg +1 -0
- package/icons/image.svg +1 -0
- package/icons/label-add.svg +1 -0
- package/icons/label.svg +1 -0
- package/icons/last.svg +1 -0
- package/icons/menu.svg +1 -0
- package/icons/mode-auto.svg +1 -0
- package/icons/mode-dark.svg +1 -0
- package/icons/mode-light.svg +1 -0
- package/icons/open-in-browser.svg +1 -0
- package/icons/pause.svg +1 -0
- package/icons/play.svg +1 -0
- package/icons/refresh.svg +1 -0
- package/icons/remove.svg +1 -0
- package/icons/save.svg +1 -0
- package/icons/search.svg +1 -0
- package/icons/settings.svg +1 -0
- package/icons/show.svg +1 -0
- package/icons/storage.svg +1 -0
- package/icons/table-visibility.svg +1 -0
- package/icons/tag.svg +1 -0
- package/icons/tools.svg +1 -0
- package/icons/trash-x.svg +1 -0
- package/icons/warning.svg +1 -0
- package/package.json +2 -2
- package/scripts/build.js +109 -138
- package/scripts/docs.js +62 -60
- package/src/components/Accordion.js +229 -0
- package/src/components/Card.js +66 -0
- package/src/components/Collapsible.js +109 -0
- package/src/components/ContentSlider.js +205 -0
- package/src/components/Dialog.js +368 -0
- package/src/components/FocusCapture.js +23 -0
- package/src/components/HybridComponent.js +40 -40
- package/src/components/Icon.js +155 -0
- package/src/components/Import.js +104 -0
- package/src/components/LightComponent.js +32 -32
- package/src/components/PersistantCollapsible.js +69 -0
- package/src/components/PhotoViewer.js +368 -0
- package/src/components/Resize.js +210 -0
- package/src/components/ShadowComponent.js +32 -17
- package/src/components/ShowMore.js +109 -0
- package/src/components/SideMenu.js +167 -0
- package/src/components/Sortable.js +193 -0
- package/src/components/Split.js +192 -0
- package/src/components/Table.js +1202 -0
- package/src/components/Tabs.js +428 -0
- package/src/components/Tags.js +253 -0
- package/src/components/ThemeSwitcher.js +108 -0
- package/src/components/Timestamp.js +31 -0
- package/src/components/Toast.js +454 -0
- package/src/components/Toggle.js +173 -0
- package/src/components/tableControls/DeleteRecord.js +29 -0
- package/src/components/tableControls/Edit.js +88 -0
- package/src/components/tableControls/ExportCSV.js +71 -0
- package/src/components/tableControls/ExportJson.js +55 -0
- package/src/components/tableControls/FieldSortHide.js +76 -0
- package/src/components/tableControls/Filters.js +114 -0
- package/src/components/tableControls/FirstPage.js +65 -0
- package/src/components/tableControls/HiddenCount.js +45 -0
- package/src/components/tableControls/Hide.js +34 -0
- package/src/components/tableControls/LastPage.js +65 -0
- package/src/components/tableControls/NextPage.js +65 -0
- package/src/components/tableControls/PageSelect.js +109 -0
- package/src/components/tableControls/PageSize.js +68 -0
- package/src/components/tableControls/PrevPage.js +65 -0
- package/src/components/tableControls/Search.js +58 -0
- package/src/components/tableControls/ShowAll.js +34 -0
- package/src/components/tableControls/TableControl.js +105 -0
- package/src/kempo-hljs.css +146 -0
- package/src/utils/debounce.js +9 -0
- package/src/utils/drag.js +80 -0
- package/src/utils/formatTimestamp.js +27 -0
- package/src/utils/propConverters.js +11 -0
- package/src/utils/toTitleCase.js +9 -0
- package/src/utils/watchWindowSize.js +16 -0
- package/tests/HybridComponent.browser-test.js +214 -214
- package/tests/LightComponent.browser-test.js +169 -169
- package/tests/ShadowComponent.browser-test.js +130 -130
- package/config/development.json +0 -14
- package/docs/components/ShadowComponent.js +0 -1
- package/src/utils/cli.js +0 -43
- package/src/utils/fs-utils.js +0 -41
- /package/{docs → dist/src}/components/HybridComponent.js +0 -0
- /package/{docs → dist/src}/components/LightComponent.js +0 -0
- /package/docs/{utils → src/utils}/cli.js +0 -0
- /package/docs/{utils → src/utils}/fs-utils.js +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class HiddenCount extends TableControl {
|
|
5
|
+
/*
|
|
6
|
+
Properties
|
|
7
|
+
*/
|
|
8
|
+
static properties = {
|
|
9
|
+
hiddenCount: { type: Number }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Lifecycle Callbacks
|
|
14
|
+
*/
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
this.updateHiddenCount();
|
|
18
|
+
this.onTableEvent('recordHidden recordShown', this.handleHiddenChange);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Event Handlers
|
|
23
|
+
*/
|
|
24
|
+
handleHiddenChange = () => {
|
|
25
|
+
this.updateHiddenCount();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
Methods
|
|
30
|
+
*/
|
|
31
|
+
updateHiddenCount = () => {
|
|
32
|
+
this.hiddenCount = this.table?.getHiddenRecords().length || 0;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
Rendering
|
|
37
|
+
*/
|
|
38
|
+
render() {
|
|
39
|
+
return html`
|
|
40
|
+
<div class="pyq pxh"><span>${this.hiddenCount}</span> Hidden Records</div>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
customElements.define('k-tc-hidden-count', HiddenCount);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class Hide extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Constructor
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super({ maxWidth: 40 });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Event Handlers
|
|
15
|
+
*/
|
|
16
|
+
handleHide = () => {
|
|
17
|
+
if(this.record){
|
|
18
|
+
this.table.hideRecord(this.record);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Rendering
|
|
24
|
+
*/
|
|
25
|
+
render() {
|
|
26
|
+
return html`
|
|
27
|
+
<button class="no-btn icon-btn" @click="${this.handleHide}">
|
|
28
|
+
<k-icon name="hide"></k-icon>
|
|
29
|
+
</button>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
customElements.define('k-tc-hide', Hide);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class LastPage extends TableControl {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.pageChangeHandler = () => this.requestUpdate();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Lifecycle Callbacks
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
if(this.table){
|
|
18
|
+
this.table.addEventListener('pageChange', this.pageChangeHandler);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
super.disconnectedCallback();
|
|
24
|
+
if(this.table){
|
|
25
|
+
this.table.removeEventListener('pageChange', this.pageChangeHandler);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Event Handlers
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
handleClick = () => {
|
|
34
|
+
if(this.table){
|
|
35
|
+
this.table.lastPage();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
Utility Functions
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
get isDisabled() {
|
|
44
|
+
if(!this.table) return true;
|
|
45
|
+
return this.table.getCurrentPage() === this.table.getTotalPages();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
Rendering Logic
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return html`
|
|
54
|
+
<button
|
|
55
|
+
class="no-btn icon-btn"
|
|
56
|
+
?disabled="${this.isDisabled}"
|
|
57
|
+
@click="${this.handleClick}"
|
|
58
|
+
>
|
|
59
|
+
<k-icon name="last"></k-icon>
|
|
60
|
+
</button>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
customElements.define('k-tc-last-page', LastPage);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class NextPage extends TableControl {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.pageChangeHandler = () => this.requestUpdate();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Lifecycle Callbacks
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
if(this.table){
|
|
18
|
+
this.table.addEventListener('pageChange', this.pageChangeHandler);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
super.disconnectedCallback();
|
|
24
|
+
if(this.table){
|
|
25
|
+
this.table.removeEventListener('pageChange', this.pageChangeHandler);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Event Handlers
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
handleClick = () => {
|
|
34
|
+
if(this.table){
|
|
35
|
+
this.table.nextPage();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
Utility Functions
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
get isDisabled() {
|
|
44
|
+
if(!this.table) return true;
|
|
45
|
+
return this.table.getCurrentPage() === this.table.getTotalPages();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
Rendering Logic
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return html`
|
|
54
|
+
<button
|
|
55
|
+
class="no-btn icon-btn"
|
|
56
|
+
?disabled="${this.isDisabled}"
|
|
57
|
+
@click="${this.handleClick}"
|
|
58
|
+
>
|
|
59
|
+
<k-icon name="chevron-right"></k-icon>
|
|
60
|
+
</button>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
customElements.define('k-tc-next-page', NextPage);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class PageSelect extends TableControl {
|
|
5
|
+
static properties = {
|
|
6
|
+
...TableControl.properties,
|
|
7
|
+
currentPage: { type: Number, state: true },
|
|
8
|
+
totalPages: { type: Number, state: true }
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
maxWidth: null
|
|
14
|
+
});
|
|
15
|
+
this.currentPage = 1;
|
|
16
|
+
this.totalPages = 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Lifecycle Callbacks
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.onTableEvent('pageChange', this.handlePageChange);
|
|
26
|
+
this.onTableEvent('pageSizeChange', this.handlePageSizeChange);
|
|
27
|
+
this.onTableEvent('pageCountChanged', this.handlePageCountChange);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback();
|
|
32
|
+
if(this.table){
|
|
33
|
+
this.table.removeEventListener('pageChange', this.handlePageChange);
|
|
34
|
+
this.table.removeEventListener('pageSizeChange', this.handlePageSizeChange);
|
|
35
|
+
this.table.removeEventListener('pageCountChanged', this.handlePageCountChange);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
Event Handlers
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
handlePageChange = () => {
|
|
44
|
+
if(this.table){
|
|
45
|
+
this.currentPage = this.table.getCurrentPage();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
handlePageSizeChange = () => {
|
|
50
|
+
if(this.table){
|
|
51
|
+
this.currentPage = this.table.getCurrentPage();
|
|
52
|
+
this.totalPages = this.table.getTotalPages();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
handlePageCountChange = () => {
|
|
57
|
+
if(this.table){
|
|
58
|
+
this.totalPages = this.table.getTotalPages();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
handleSelectChange = e => {
|
|
63
|
+
if(this.table){
|
|
64
|
+
this.table.setPage(parseInt(e.target.value));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
Rendering Logic
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
if(!this.table){
|
|
74
|
+
return html`<div>No table found</div>`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const options = [];
|
|
78
|
+
for(let i = 1; i <= this.totalPages; i++){
|
|
79
|
+
options.push(html`<option value="${i}" ?selected="${i === this.currentPage}">Page ${i}</option>`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return html`
|
|
83
|
+
<div class="page-select">
|
|
84
|
+
<select class="no-btn ph b r" @change="${this.handleSelectChange}" ?disabled="${this.totalPages <= 1}">
|
|
85
|
+
${options}
|
|
86
|
+
</select>
|
|
87
|
+
<label> out of ${this.totalPages}</label>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static styles = css`
|
|
93
|
+
${TableControl.styles}
|
|
94
|
+
|
|
95
|
+
.page-select {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 0.25rem;
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
label {
|
|
103
|
+
padding: 0;
|
|
104
|
+
margin: 0;
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
customElements.define('k-tc-page-select', PageSelect);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class PageSize extends TableControl {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({
|
|
7
|
+
maxWidth: null
|
|
8
|
+
});
|
|
9
|
+
this.pageChangeHandler = () => this.requestUpdate();
|
|
10
|
+
this.pageSizeChangeHandler = () => this.requestUpdate();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Lifecycle Callbacks
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
super.connectedCallback();
|
|
19
|
+
this.onTableEvent('pageChange', this.pageChangeHandler);
|
|
20
|
+
this.onTableEvent('pageSizeChange', this.pageSizeChangeHandler);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
if(this.table){
|
|
26
|
+
this.table.removeEventListener('pageChange', this.pageChangeHandler);
|
|
27
|
+
this.table.removeEventListener('pageSizeChange', this.pageSizeChangeHandler);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
Event Handlers
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
handleChange = e => {
|
|
36
|
+
if(this.table){
|
|
37
|
+
this.table.setPageSize(parseInt(e.target.value));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
Utility Functions
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
get currentPageSize() {
|
|
46
|
+
return this.table ? this.table.getPageSize() : 10;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get pageSizeOptions() {
|
|
50
|
+
return this.table ? this.table.pageSizeOptions : [10, 25, 50, 100, 500];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
Rendering Logic
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
return html`
|
|
59
|
+
<select class="no-btn ph b r" @change="${this.handleChange}">
|
|
60
|
+
${this.pageSizeOptions.map(size =>
|
|
61
|
+
html`<option value="${size}" ?selected="${size === this.currentPageSize}">${size} per page</option>`
|
|
62
|
+
)}
|
|
63
|
+
</select>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
customElements.define('k-tc-page-size', PageSize);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class PrevPage extends TableControl {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.pageChangeHandler = () => this.requestUpdate();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Lifecycle Callbacks
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
if(this.table){
|
|
18
|
+
this.table.addEventListener('pageChange', this.pageChangeHandler);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
super.disconnectedCallback();
|
|
24
|
+
if(this.table){
|
|
25
|
+
this.table.removeEventListener('pageChange', this.pageChangeHandler);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Event Handlers
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
handleClick = () => {
|
|
34
|
+
if(this.table){
|
|
35
|
+
this.table.prevPage();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
Utility Functions
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
get isDisabled() {
|
|
44
|
+
if(!this.table) return true;
|
|
45
|
+
return this.table.getCurrentPage() === 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
Rendering Logic
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return html`
|
|
54
|
+
<button
|
|
55
|
+
class="no-btn icon-btn"
|
|
56
|
+
?disabled="${this.isDisabled}"
|
|
57
|
+
@click="${this.handleClick}"
|
|
58
|
+
>
|
|
59
|
+
<k-icon name="chevron-left"></k-icon>
|
|
60
|
+
</button>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
customElements.define('k-tc-prev-page', PrevPage);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import debounce from '../../utils/debounce.js';
|
|
4
|
+
|
|
5
|
+
export default class Search extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Properties
|
|
8
|
+
*/
|
|
9
|
+
static properties = {
|
|
10
|
+
searchTerm: { type: String }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super({ maxWidth: 200 });
|
|
18
|
+
this.debouncedSearch = debounce(this.performSearch, 200);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Event Handlers
|
|
23
|
+
*/
|
|
24
|
+
handleInput = (e) => {
|
|
25
|
+
this.searchTerm = e.target.value;
|
|
26
|
+
this.debouncedSearch();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Methods
|
|
31
|
+
*/
|
|
32
|
+
performSearch = () => {
|
|
33
|
+
if(!this.table) return;
|
|
34
|
+
|
|
35
|
+
if(!this.searchTerm || this.searchTerm.length < 3){
|
|
36
|
+
this.table.showAllRecords();
|
|
37
|
+
} else {
|
|
38
|
+
this.table.search(this.searchTerm);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
Rendering
|
|
44
|
+
*/
|
|
45
|
+
render() {
|
|
46
|
+
return html`
|
|
47
|
+
<input
|
|
48
|
+
type="search"
|
|
49
|
+
placeholder="Search"
|
|
50
|
+
class="px pyh"
|
|
51
|
+
.value="${this.searchTerm || ''}"
|
|
52
|
+
@input="${this.handleInput}"
|
|
53
|
+
/>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
customElements.define('k-tc-search', Search);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class ShowAll extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Constructor
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super({ maxWidth: 40 });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Event Handlers
|
|
15
|
+
*/
|
|
16
|
+
handleShowAll = () => {
|
|
17
|
+
if(this.table){
|
|
18
|
+
this.table.showAllRecords();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Rendering
|
|
24
|
+
*/
|
|
25
|
+
render() {
|
|
26
|
+
return html`
|
|
27
|
+
<button class="no-btn icon-btn" @click="${this.handleShowAll}">
|
|
28
|
+
<k-icon name="show"></k-icon>
|
|
29
|
+
</button>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
customElements.define('k-tc-show-all', ShowAll);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import ShadowComponent from '../ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class TableControl extends ShadowComponent {
|
|
5
|
+
/*
|
|
6
|
+
Properties
|
|
7
|
+
*/
|
|
8
|
+
static properties = {
|
|
9
|
+
maxWidth: { type: Number, reflect: true, attribute: 'max-width' }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
Constructor
|
|
14
|
+
*/
|
|
15
|
+
constructor({
|
|
16
|
+
maxWidth = 40
|
|
17
|
+
} = {}) {
|
|
18
|
+
super();
|
|
19
|
+
this.maxWidth = maxWidth;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Lifecycle Callbacks
|
|
24
|
+
*/
|
|
25
|
+
updated(changedProperties) {
|
|
26
|
+
super.updated(changedProperties);
|
|
27
|
+
if(changedProperties.has('maxWidth')){
|
|
28
|
+
if(this.maxWidth){
|
|
29
|
+
this.style.setProperty('--max-width', `${this.maxWidth}px`);
|
|
30
|
+
} else {
|
|
31
|
+
this.style.removeProperty('--max-width');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
firstUpdated() {
|
|
37
|
+
if(this.maxWidth){
|
|
38
|
+
this.style.setProperty('--max-width', `${this.maxWidth}px`);
|
|
39
|
+
} else {
|
|
40
|
+
this.style.removeProperty('--max-width');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
Getters for Table Integration
|
|
46
|
+
*/
|
|
47
|
+
get table() {
|
|
48
|
+
if (this.getRootNode() instanceof ShadowRoot) {
|
|
49
|
+
return this.getRootNode().host.closest('k-table');
|
|
50
|
+
} else {
|
|
51
|
+
return this.closest('k-table');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get record() {
|
|
56
|
+
if (this.getRootNode() instanceof ShadowRoot) {
|
|
57
|
+
const $record = this.closest('.record');
|
|
58
|
+
if ($record) {
|
|
59
|
+
const index = $record.dataset.index;
|
|
60
|
+
if (index !== undefined) {
|
|
61
|
+
return this.table.records[index];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
Table Event Handling
|
|
70
|
+
*/
|
|
71
|
+
async onTableEvent(eventNames, handler) {
|
|
72
|
+
// Wait for k-table to be defined before trying to find it
|
|
73
|
+
await customElements.whenDefined('k-table');
|
|
74
|
+
|
|
75
|
+
if(this.table){
|
|
76
|
+
const events = eventNames.split(' ');
|
|
77
|
+
events.forEach(eventName => {
|
|
78
|
+
this.table.addEventListener(eventName, handler);
|
|
79
|
+
});
|
|
80
|
+
this.requestUpdate(); // Force update after table is found
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
Styles
|
|
86
|
+
*/
|
|
87
|
+
static styles = css`
|
|
88
|
+
:host {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.icon-btn {
|
|
93
|
+
display: inline-flex !important;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
width: 40px;
|
|
97
|
+
height: 40px;
|
|
98
|
+
}
|
|
99
|
+
.icon-btn:disabled {
|
|
100
|
+
opacity: 0.6;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
customElements.define('k-table-control', TableControl);
|