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,173 @@
|
|
|
1
|
+
import { html, css } from '../lit-all.min.js';
|
|
2
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
3
|
+
|
|
4
|
+
export default class Toggle extends ShadowComponent {
|
|
5
|
+
static properties = {
|
|
6
|
+
value: { type: Boolean, reflect: true }
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
static styles = css`
|
|
10
|
+
:host {
|
|
11
|
+
--switch_height: 2rem;
|
|
12
|
+
--switch_width: 3rem;
|
|
13
|
+
--switch_border: 1px solid var(--c_border);
|
|
14
|
+
--switch_background__off: var(--c_bg__alt);
|
|
15
|
+
--switch_background__on: var(--c_success);
|
|
16
|
+
--handle_size__off: 1rem;
|
|
17
|
+
--handle_size__on: 1.5rem;
|
|
18
|
+
--handle_border: 1px solid var(--c_border);
|
|
19
|
+
--handle_background__off: var(--c_border);
|
|
20
|
+
--handle_background__on: white;
|
|
21
|
+
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
margin-bottom: var(--spacer);
|
|
26
|
+
border-radius: 999rem;
|
|
27
|
+
outline: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host(:focus) {
|
|
31
|
+
outline: 2px solid var(--c_primary, blue);
|
|
32
|
+
outline-offset: 2px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#switch {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
width: var(--switch_width);
|
|
39
|
+
height: var(--switch_height);
|
|
40
|
+
border: var(--switch_border);
|
|
41
|
+
background: var(--switch_background__off);
|
|
42
|
+
border-radius: 999rem;
|
|
43
|
+
margin-right: var(--spacer);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#handle {
|
|
47
|
+
--margin: calc( (var(--switch_height) - var(--handle_size__off)) / 2);
|
|
48
|
+
width: var(--handle_size__off);
|
|
49
|
+
height: var(--handle_size__off);
|
|
50
|
+
border: var(--handle_border);
|
|
51
|
+
background: var(--handle_background__off);
|
|
52
|
+
border-radius: 999rem;
|
|
53
|
+
transform: translateX(var(--margin));
|
|
54
|
+
transition: width var(--animation_ms, 256ms), height var(--animation_ms, 256ms), transform var(--animation_ms, 256ms);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([value]) #switch {
|
|
58
|
+
background: var(--switch_background__on);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([value]) #handle {
|
|
62
|
+
--m: calc( (var(--switch_height) - var(--handle_size__on)) / 2);
|
|
63
|
+
--d: calc( var(--switch_width) - var(--handle_size__on) - var(--m));
|
|
64
|
+
width: var(--handle_size__on);
|
|
65
|
+
height: var(--handle_size__on);
|
|
66
|
+
background: var(--handle_background__on);
|
|
67
|
+
transform: translateX(var(--d));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#label {
|
|
71
|
+
display: block;
|
|
72
|
+
flex: 1 1 auto;
|
|
73
|
+
padding: 0;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.value = false;
|
|
80
|
+
this.tabIndex = 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
Lifecycle Methods
|
|
85
|
+
*/
|
|
86
|
+
updated(changedProperties) {
|
|
87
|
+
super.updated(changedProperties);
|
|
88
|
+
|
|
89
|
+
if (changedProperties.has('value')) {
|
|
90
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
91
|
+
detail: { value: this.value },
|
|
92
|
+
bubbles: true
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
connectedCallback() {
|
|
98
|
+
super.connectedCallback();
|
|
99
|
+
this.addEventListener('click', this.handleClick);
|
|
100
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
disconnectedCallback() {
|
|
104
|
+
super.disconnectedCallback();
|
|
105
|
+
this.removeEventListener('click', this.handleClick);
|
|
106
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
Event Handlers
|
|
111
|
+
*/
|
|
112
|
+
handleClick = () => {
|
|
113
|
+
this.toggle();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
handleKeyDown = (event) => {
|
|
117
|
+
if (['Space', 'Enter'].includes(event.code)) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
this.toggle();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
Public Methods
|
|
125
|
+
*/
|
|
126
|
+
on() {
|
|
127
|
+
this.value = true;
|
|
128
|
+
this.dispatchEvent(new CustomEvent('on', {
|
|
129
|
+
detail: { value: true },
|
|
130
|
+
bubbles: true
|
|
131
|
+
}));
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
off() {
|
|
136
|
+
this.value = false;
|
|
137
|
+
this.dispatchEvent(new CustomEvent('off', {
|
|
138
|
+
detail: { value: false },
|
|
139
|
+
bubbles: true
|
|
140
|
+
}));
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toggle() {
|
|
145
|
+
if (this.value) {
|
|
146
|
+
this.off();
|
|
147
|
+
} else {
|
|
148
|
+
this.on();
|
|
149
|
+
}
|
|
150
|
+
this.dispatchEvent(new CustomEvent('toggle', {
|
|
151
|
+
detail: { value: this.value },
|
|
152
|
+
bubbles: true
|
|
153
|
+
}));
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
Rendering Logic
|
|
159
|
+
*/
|
|
160
|
+
render() {
|
|
161
|
+
return html`
|
|
162
|
+
<div id="switch">
|
|
163
|
+
<div id="handle"></div>
|
|
164
|
+
</div>
|
|
165
|
+
<label id="label">
|
|
166
|
+
<slot></slot>
|
|
167
|
+
</label>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Register custom element
|
|
173
|
+
window.customElements.define('k-toggle', Toggle);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class DeleteRecord extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Public Methods
|
|
8
|
+
*/
|
|
9
|
+
delete = () => {
|
|
10
|
+
if(this.record) {
|
|
11
|
+
this.table.deleteRecord(this.record);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
Rendering
|
|
17
|
+
*/
|
|
18
|
+
render() {
|
|
19
|
+
return html`
|
|
20
|
+
<button class="no-btn icon-btn" @click="${this.delete}">
|
|
21
|
+
<slot>
|
|
22
|
+
<k-icon name="delete"></k-icon>
|
|
23
|
+
</slot>
|
|
24
|
+
</button>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
customElements.define('k-tc-delete-record', DeleteRecord);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html, css } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class Edit extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Properties
|
|
8
|
+
*/
|
|
9
|
+
static properties = {
|
|
10
|
+
isEditing: { type: Boolean }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
Styles
|
|
15
|
+
*/
|
|
16
|
+
static styles = [
|
|
17
|
+
TableControl.styles,
|
|
18
|
+
css`
|
|
19
|
+
:host {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
width: max-content;
|
|
22
|
+
align-items: baseline;
|
|
23
|
+
}
|
|
24
|
+
`
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
Constructor
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
super({ maxWidth: 80 });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
Lifecycle Callbacks
|
|
36
|
+
*/
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
this.onTableEvent('editingChange', this.handleEditingChange);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
Event Handlers
|
|
44
|
+
*/
|
|
45
|
+
handleEditingChange = (e) => {
|
|
46
|
+
if(e.detail.record === this.record){
|
|
47
|
+
this.isEditing = e.detail.editing;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
handleEdit = () => {
|
|
52
|
+
if(this.record){
|
|
53
|
+
this.table.editRecord(this.record);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
handleSave = () => {
|
|
58
|
+
if(this.record){
|
|
59
|
+
this.table.saveEditedRecord(this.record);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
handleCancel = () => {
|
|
64
|
+
if(this.record){
|
|
65
|
+
this.table.cancelEditedRecord(this.record);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
Rendering
|
|
71
|
+
*/
|
|
72
|
+
render() {
|
|
73
|
+
return this.isEditing ? html`
|
|
74
|
+
<button class="no-btn icon-btn bg-success" @click="${this.handleSave}">
|
|
75
|
+
<k-icon name="check"></k-icon>
|
|
76
|
+
</button>
|
|
77
|
+
<button class="no-btn icon-btn bg-danger" @click="${this.handleCancel}">
|
|
78
|
+
<k-icon name="close"></k-icon>
|
|
79
|
+
</button>
|
|
80
|
+
` : html`
|
|
81
|
+
<button class="no-btn icon-btn" @click="${this.handleEdit}">
|
|
82
|
+
<k-icon name="edit"></k-icon>
|
|
83
|
+
</button>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
customElements.define('k-tc-edit', Edit);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class ExportCSV extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Constructor
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.maxWidth = 136;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Public Methods
|
|
16
|
+
*/
|
|
17
|
+
getCSV() {
|
|
18
|
+
const table = this.table;
|
|
19
|
+
if(!table) return '';
|
|
20
|
+
|
|
21
|
+
let csv = '';
|
|
22
|
+
const fields = [];
|
|
23
|
+
|
|
24
|
+
table.fields.forEach(({ name, calculator }) => {
|
|
25
|
+
if(!calculator) {
|
|
26
|
+
fields.push(name);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
csv += fields.join(',') + '\n';
|
|
31
|
+
|
|
32
|
+
if(this.record) {
|
|
33
|
+
const row = fields.map(field => this.record[field] || '');
|
|
34
|
+
csv += row.join(',') + '\n';
|
|
35
|
+
} else {
|
|
36
|
+
table.records.forEach(record => {
|
|
37
|
+
const row = fields.map(field => record[field] || '');
|
|
38
|
+
csv += row.join(',') + '\n';
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return csv;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export = () => {
|
|
46
|
+
const data = this.getCSV();
|
|
47
|
+
const blob = new Blob([data], { type: 'text/csv' });
|
|
48
|
+
const url = URL.createObjectURL(blob);
|
|
49
|
+
const a = document.createElement('a');
|
|
50
|
+
a.href = url;
|
|
51
|
+
a.download = 'data.csv';
|
|
52
|
+
a.click();
|
|
53
|
+
URL.revokeObjectURL(url);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
Rendering
|
|
58
|
+
*/
|
|
59
|
+
render() {
|
|
60
|
+
return html`
|
|
61
|
+
<button class="no-btn ph" @click="${this.export}">
|
|
62
|
+
<slot>
|
|
63
|
+
<k-icon name="export-file"></k-icon>
|
|
64
|
+
Export CSV
|
|
65
|
+
</slot>
|
|
66
|
+
</button>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
customElements.define('k-tc-export-csv', ExportCSV);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
|
|
5
|
+
export default class ExportJson extends TableControl {
|
|
6
|
+
/*
|
|
7
|
+
Constructor
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.maxWidth = 136;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Public Methods
|
|
16
|
+
*/
|
|
17
|
+
export = () => {
|
|
18
|
+
const record = this.record;
|
|
19
|
+
if(record) {
|
|
20
|
+
const data = JSON.stringify(record);
|
|
21
|
+
const blob = new Blob([data], { type: 'application/json' });
|
|
22
|
+
const url = URL.createObjectURL(blob);
|
|
23
|
+
const a = document.createElement('a');
|
|
24
|
+
a.href = url;
|
|
25
|
+
a.download = 'data.json';
|
|
26
|
+
a.click();
|
|
27
|
+
URL.revokeObjectURL(url);
|
|
28
|
+
} else {
|
|
29
|
+
const data = JSON.stringify(this.table.records);
|
|
30
|
+
const blob = new Blob([data], { type: 'application/json' });
|
|
31
|
+
const url = URL.createObjectURL(blob);
|
|
32
|
+
const a = document.createElement('a');
|
|
33
|
+
a.href = url;
|
|
34
|
+
a.download = 'data.json';
|
|
35
|
+
a.click();
|
|
36
|
+
URL.revokeObjectURL(url);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
Rendering
|
|
42
|
+
*/
|
|
43
|
+
render() {
|
|
44
|
+
return html`
|
|
45
|
+
<button class="no-btn ph" @click="${this.export}">
|
|
46
|
+
<slot>
|
|
47
|
+
<k-icon name="export-file"></k-icon>
|
|
48
|
+
Export JSON
|
|
49
|
+
</slot>
|
|
50
|
+
</button>
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
customElements.define('k-tc-export-json', ExportJson);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html, render } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
import Dialog from '../Dialog.js';
|
|
5
|
+
|
|
6
|
+
export default class FieldSortHide extends TableControl {
|
|
7
|
+
/*
|
|
8
|
+
Constructor
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ maxWidth: 40 });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Event Handlers
|
|
16
|
+
*/
|
|
17
|
+
handleClick = () => {
|
|
18
|
+
this.openDialog();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Methods
|
|
23
|
+
*/
|
|
24
|
+
openDialog = () => {
|
|
25
|
+
import('../Sortable.js');
|
|
26
|
+
|
|
27
|
+
const dialogContent = document.createElement('div');
|
|
28
|
+
|
|
29
|
+
render(html`
|
|
30
|
+
<h3 class="m0 ph" slot="title">Show / Hide Fields</h3>
|
|
31
|
+
<div class="m">
|
|
32
|
+
<k-sortable id="sorting" @sort="${(e) => {
|
|
33
|
+
const newOrder = Array.from(e.target.querySelectorAll('k-sortable-item'))
|
|
34
|
+
.map(item => item.getAttribute('data-field'));
|
|
35
|
+
this.table.reorderFields(newOrder);
|
|
36
|
+
}}">
|
|
37
|
+
${this.table.fields.map(field => html`
|
|
38
|
+
<k-sortable-item data-field="${field.name}">
|
|
39
|
+
<label class="field pb0">
|
|
40
|
+
<input
|
|
41
|
+
class="field-visibility"
|
|
42
|
+
data-field="${field.name}"
|
|
43
|
+
type="checkbox"
|
|
44
|
+
.checked="${!field.hidden}"
|
|
45
|
+
@change="${(e) => {
|
|
46
|
+
this.table.setFieldHiddenState(field.name, !e.target.checked);
|
|
47
|
+
}}"
|
|
48
|
+
style="height: 1.25rem; width: 1.25rem"
|
|
49
|
+
/>
|
|
50
|
+
${field.label}
|
|
51
|
+
</label>
|
|
52
|
+
</k-sortable-item>
|
|
53
|
+
`)}
|
|
54
|
+
</k-sortable>
|
|
55
|
+
</div>
|
|
56
|
+
`, dialogContent);
|
|
57
|
+
|
|
58
|
+
Dialog.create(dialogContent, {
|
|
59
|
+
width: '400px',
|
|
60
|
+
cancelText: 'Close'
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
Rendering
|
|
66
|
+
*/
|
|
67
|
+
render() {
|
|
68
|
+
return html`
|
|
69
|
+
<button class="no-btn icon-btn" @click="${this.handleClick}">
|
|
70
|
+
<k-icon name="table-visibility"></k-icon>
|
|
71
|
+
</button>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
customElements.define('k-tc-field-sort-hide', FieldSortHide);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import TableControl from './TableControl.js';
|
|
2
|
+
import { html, render } from '../../lit-all.min.js';
|
|
3
|
+
import '../Icon.js';
|
|
4
|
+
import Dialog from '../Dialog.js';
|
|
5
|
+
|
|
6
|
+
export default class Filters extends TableControl {
|
|
7
|
+
/*
|
|
8
|
+
Constructor
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
super({ maxWidth: 40 });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Event Handlers
|
|
16
|
+
*/
|
|
17
|
+
handleFilter = () => {
|
|
18
|
+
this.openDialog();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Methods
|
|
23
|
+
*/
|
|
24
|
+
openDialog = () => {
|
|
25
|
+
const conditionOptions = {
|
|
26
|
+
'equals': 'equals',
|
|
27
|
+
'not-equals': 'does not equal',
|
|
28
|
+
'contains': 'contains',
|
|
29
|
+
'not-contains': 'does not contain',
|
|
30
|
+
'greater-than': 'is greater than',
|
|
31
|
+
'greater-than-or-equal': 'is greater than or equal to',
|
|
32
|
+
'less-than': 'is less than',
|
|
33
|
+
'less-than-or-equal': 'is less than or equal to'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const dialogContent = document.createElement('div');
|
|
37
|
+
|
|
38
|
+
render(html`
|
|
39
|
+
<h3 slot="title" class="m0 pyh px">Filters</h3>
|
|
40
|
+
<div class="p">
|
|
41
|
+
${this.table.filters.length === 0 ? html`
|
|
42
|
+
<p>No Current Filters.</p>
|
|
43
|
+
` : html`
|
|
44
|
+
<h5>Current Filters</h5>
|
|
45
|
+
<ul id="currentFilters">
|
|
46
|
+
${this.table.filters.map(({field, condition, value}) => html`
|
|
47
|
+
<li
|
|
48
|
+
data-field="${field}"
|
|
49
|
+
data-condition="${condition}"
|
|
50
|
+
data-value="${value}"
|
|
51
|
+
>
|
|
52
|
+
${field} ${conditionOptions[condition]} ${value}
|
|
53
|
+
<button class="remove-filter no-btn pq" @click="${(e) => {
|
|
54
|
+
this.table.removeFilter(field, condition, value);
|
|
55
|
+
dialog.close();
|
|
56
|
+
this.openDialog();
|
|
57
|
+
}}">
|
|
58
|
+
<k-icon name="close"></k-icon>
|
|
59
|
+
</button>
|
|
60
|
+
</li>
|
|
61
|
+
`)}
|
|
62
|
+
</ul>
|
|
63
|
+
`}
|
|
64
|
+
<hr />
|
|
65
|
+
<h5>Add A Filter</h5>
|
|
66
|
+
<form id="addFilter" @submit="${(e) => {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
const form = e.target;
|
|
69
|
+
this.table.addFilter(
|
|
70
|
+
form.filterField.value,
|
|
71
|
+
form.filterCondition.value,
|
|
72
|
+
form.filterValue.value
|
|
73
|
+
);
|
|
74
|
+
dialog.close();
|
|
75
|
+
this.openDialog();
|
|
76
|
+
}}">
|
|
77
|
+
<select id="filterField" class="mb">
|
|
78
|
+
${this.table.fields.map(({name, label}) => html`
|
|
79
|
+
<option value="${name}">${label}</option>
|
|
80
|
+
`)}
|
|
81
|
+
</select>
|
|
82
|
+
<select id="filterCondition" class="mb">
|
|
83
|
+
${Object.entries(conditionOptions).map(([key, value]) => html`
|
|
84
|
+
<option value="${key}" ?selected="${key === 'contains'}">${value}</option>
|
|
85
|
+
`)}
|
|
86
|
+
</select>
|
|
87
|
+
<input id="filterValue" type="text" class="mb" />
|
|
88
|
+
<button type="submit" class="btn primary mb mr">Add Filter</button>
|
|
89
|
+
${this.table.filters.length === 0 ? '' : html`
|
|
90
|
+
<button type="button" class="btn danger mb mr" @click="${() => {
|
|
91
|
+
this.table.removeAllFilters();
|
|
92
|
+
dialog.close();
|
|
93
|
+
}}">Clear All Filters</button>
|
|
94
|
+
`}
|
|
95
|
+
</form>
|
|
96
|
+
</div>
|
|
97
|
+
`, dialogContent);
|
|
98
|
+
|
|
99
|
+
const dialog = Dialog.create(dialogContent, { width: '600px' });
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
Rendering
|
|
104
|
+
*/
|
|
105
|
+
render() {
|
|
106
|
+
return html`
|
|
107
|
+
<button class="no-btn icon-btn" @click="${this.handleFilter}">
|
|
108
|
+
<k-icon name="filter"></k-icon>
|
|
109
|
+
</button>
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
customElements.define('k-tc-filters', Filters);
|
|
@@ -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 FirstPage 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.firstPage();
|
|
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="first"></k-icon>
|
|
60
|
+
</button>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
customElements.define('k-tc-first-page', FirstPage);
|