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,229 @@
|
|
|
1
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../lit-all.min.js';
|
|
3
|
+
import { boolTrueFalse } from '../utils/propConverters.js';
|
|
4
|
+
|
|
5
|
+
export default class Accordion extends ShadowComponent {
|
|
6
|
+
/*
|
|
7
|
+
Properties
|
|
8
|
+
*/
|
|
9
|
+
static properties = {};
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
Public Methods
|
|
13
|
+
*/
|
|
14
|
+
getHeader(panelName) {
|
|
15
|
+
return this.querySelector(`k-accordion-header[for-panel="${panelName}"]`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getPanel(panelName) {
|
|
19
|
+
return this.querySelector(`k-accordion-panel[name="${panelName}"]`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
openPanel(panelName) {
|
|
23
|
+
const currentlyActivePanel = this.querySelector(`k-accordion-panel[active="true"]`);
|
|
24
|
+
if(currentlyActivePanel && currentlyActivePanel.name !== panelName) {
|
|
25
|
+
currentlyActivePanel.active = false;
|
|
26
|
+
const currentlyActiveHeader = this.getHeader(currentlyActivePanel.name);
|
|
27
|
+
if(currentlyActiveHeader) currentlyActiveHeader.active = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const panel = this.getPanel(panelName);
|
|
31
|
+
if(panel) {
|
|
32
|
+
panel.active = true;
|
|
33
|
+
panel.transitioning = true;
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
panel.transitioning = false;
|
|
36
|
+
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
37
|
+
|
|
38
|
+
const header = this.getHeader(panelName);
|
|
39
|
+
if(header) header.active = true;
|
|
40
|
+
|
|
41
|
+
this.dispatchEvent(new CustomEvent('openpanel', { detail: { panelName } }));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
closePanel(panelName) {
|
|
46
|
+
const panel = this.getPanel(panelName);
|
|
47
|
+
if(panel) {
|
|
48
|
+
panel.active = false;
|
|
49
|
+
panel.transitioning = true;
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
panel.transitioning = false;
|
|
52
|
+
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
53
|
+
|
|
54
|
+
const header = this.getHeader(panelName);
|
|
55
|
+
if(header) header.active = false;
|
|
56
|
+
|
|
57
|
+
this.dispatchEvent(new CustomEvent('closepanel', { detail: { panelName } }));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
togglePanel(panelName) {
|
|
62
|
+
const panel = this.getPanel(panelName);
|
|
63
|
+
if(panel) {
|
|
64
|
+
if(panel.active) {
|
|
65
|
+
this.closePanel(panelName);
|
|
66
|
+
} else {
|
|
67
|
+
this.openPanel(panelName);
|
|
68
|
+
}
|
|
69
|
+
this.dispatchEvent(new CustomEvent('togglepanel', { detail: { panelName } }));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
Getters
|
|
75
|
+
*/
|
|
76
|
+
get activeHeader() {
|
|
77
|
+
return this.querySelector('k-accordion-header[active="true"]');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get activePanel() {
|
|
81
|
+
return this.querySelector('k-accordion-panel[active="true"]');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/*
|
|
85
|
+
Styles
|
|
86
|
+
*/
|
|
87
|
+
static styles = css`
|
|
88
|
+
:host {
|
|
89
|
+
display: block;
|
|
90
|
+
border: 1px solid var(--c_border);
|
|
91
|
+
border-radius: var(--radius);
|
|
92
|
+
}
|
|
93
|
+
::slotted(k-accordion-header) {
|
|
94
|
+
border-top: 1px solid var(--c_border);
|
|
95
|
+
}
|
|
96
|
+
::slotted(k-accordion-header[active="true"]) {
|
|
97
|
+
border-bottom: 1px solid var(--c_border);
|
|
98
|
+
}
|
|
99
|
+
::slotted(k-accordion-header:first-of-type) {
|
|
100
|
+
border-top: 0;
|
|
101
|
+
}
|
|
102
|
+
::slotted(k-accordion-header:last-of-type:not([active="true"])) {
|
|
103
|
+
border-bottom: 0;
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
Rendering
|
|
109
|
+
*/
|
|
110
|
+
render() {
|
|
111
|
+
return html`<slot></slot>`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class AccordionHeader extends ShadowComponent {
|
|
116
|
+
/*
|
|
117
|
+
Properties
|
|
118
|
+
*/
|
|
119
|
+
static properties = {
|
|
120
|
+
forPanel: { type: String, reflect: true, attribute: 'for-panel' },
|
|
121
|
+
active: { type: Boolean, reflect: true, converter: boolTrueFalse }
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
constructor() {
|
|
125
|
+
super();
|
|
126
|
+
this.forPanel = '';
|
|
127
|
+
this.active = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
Event Handlers
|
|
132
|
+
*/
|
|
133
|
+
handleClick = () => {
|
|
134
|
+
this.accordion?.togglePanel(this.forPanel);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
Lifecycle Callbacks
|
|
139
|
+
*/
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
super.connectedCallback();
|
|
142
|
+
this.addEventListener('click', this.handleClick);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
disconnectedCallback() {
|
|
146
|
+
super.disconnectedCallback();
|
|
147
|
+
this.removeEventListener('click', this.handleClick);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/*
|
|
151
|
+
Getters
|
|
152
|
+
*/
|
|
153
|
+
get accordion() {
|
|
154
|
+
return this.closest('k-accordion');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
Styles
|
|
159
|
+
*/
|
|
160
|
+
static styles = css`
|
|
161
|
+
:host {
|
|
162
|
+
display: block;
|
|
163
|
+
padding: 1rem;
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
}
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
/*
|
|
169
|
+
Rendering
|
|
170
|
+
*/
|
|
171
|
+
render() {
|
|
172
|
+
return html`<slot></slot>`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export class AccordionPanel extends ShadowComponent {
|
|
177
|
+
/*
|
|
178
|
+
Properties
|
|
179
|
+
*/
|
|
180
|
+
static properties = {
|
|
181
|
+
name: { type: String, reflect: true },
|
|
182
|
+
active: { type: Boolean, reflect: true, converter: boolTrueFalse },
|
|
183
|
+
transitioning: { type: Boolean, reflect: true, converter: boolTrueFalse }
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
constructor() {
|
|
187
|
+
super();
|
|
188
|
+
this.name = '';
|
|
189
|
+
this.active = false;
|
|
190
|
+
this.transitioning = false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
Getters
|
|
195
|
+
*/
|
|
196
|
+
get accordion() {
|
|
197
|
+
return this.closest('k-accordion');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/*
|
|
201
|
+
Styles
|
|
202
|
+
*/
|
|
203
|
+
static styles = css`
|
|
204
|
+
:host {
|
|
205
|
+
display: block;
|
|
206
|
+
interpolate-size: allow-keywords;
|
|
207
|
+
height: 0;
|
|
208
|
+
overflow: hidden;
|
|
209
|
+
transition: height var(--animation_ms, 256ms) ease-in-out;
|
|
210
|
+
}
|
|
211
|
+
:host([active="true"]) {
|
|
212
|
+
height: max-content;
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
Rendering
|
|
218
|
+
*/
|
|
219
|
+
render() {
|
|
220
|
+
return html`<slot></slot>`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
Custom Element Registration
|
|
226
|
+
*/
|
|
227
|
+
customElements.define('k-accordion', Accordion);
|
|
228
|
+
customElements.define('k-accordion-header', AccordionHeader);
|
|
229
|
+
customElements.define('k-accordion-panel', AccordionPanel);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../lit-all.min.js';
|
|
3
|
+
|
|
4
|
+
export default class Card extends ShadowComponent {
|
|
5
|
+
/*
|
|
6
|
+
Properties
|
|
7
|
+
*/
|
|
8
|
+
static properties = {
|
|
9
|
+
label: { type: String, reflect: true }
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.label = '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Styles
|
|
19
|
+
*/
|
|
20
|
+
static styles = css`
|
|
21
|
+
:host {
|
|
22
|
+
display: block;
|
|
23
|
+
}
|
|
24
|
+
#card {
|
|
25
|
+
border: 1px solid var(--c_border);
|
|
26
|
+
border-radius: var(--radius);
|
|
27
|
+
margin-bottom: var(--spacer);
|
|
28
|
+
padding: var(--spacer);
|
|
29
|
+
position: relative;
|
|
30
|
+
background-color: var(--c_bg);
|
|
31
|
+
}
|
|
32
|
+
#label {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: -1.25em;
|
|
35
|
+
left: 1.25em;
|
|
36
|
+
background-color: var(--c_bg);
|
|
37
|
+
border: 1px solid var(--c_border);
|
|
38
|
+
border-radius: var(--radius);
|
|
39
|
+
padding: var(--spacer_h);
|
|
40
|
+
}
|
|
41
|
+
:host([label]) {
|
|
42
|
+
padding-top: calc(1.5 * var(--spacer));
|
|
43
|
+
margin-top: var(--spacer);
|
|
44
|
+
}
|
|
45
|
+
:host([label]) #card {
|
|
46
|
+
padding-top: calc(1.5 * var(--spacer));
|
|
47
|
+
}
|
|
48
|
+
:host(:not([label])) #label {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
Rendering
|
|
55
|
+
*/
|
|
56
|
+
render() {
|
|
57
|
+
return html`
|
|
58
|
+
<div id="card">
|
|
59
|
+
<div id="label">${this.label}</div>
|
|
60
|
+
<slot></slot>
|
|
61
|
+
</div>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
window.customElements.define('k-card', Card);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../lit-all.min.js';
|
|
3
|
+
import { boolTrueFalse } from '../utils/propConverters.js';
|
|
4
|
+
import './Icon.js';
|
|
5
|
+
|
|
6
|
+
export default class Collapsible extends ShadowComponent {
|
|
7
|
+
/*
|
|
8
|
+
Properties
|
|
9
|
+
*/
|
|
10
|
+
static properties = {
|
|
11
|
+
opened: { type: Boolean, reflect: true, converter: boolTrueFalse }
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.opened = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Event Handlers
|
|
21
|
+
*/
|
|
22
|
+
handleLabelClick = () => {
|
|
23
|
+
this.toggle();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
Lifecycle Callbacks
|
|
28
|
+
*/
|
|
29
|
+
updated(changedProperties) {
|
|
30
|
+
super.updated(changedProperties);
|
|
31
|
+
|
|
32
|
+
if(changedProperties.has('opened')) {
|
|
33
|
+
this.dispatchEvent(new CustomEvent('openedchanged', {
|
|
34
|
+
detail: this.opened ? 'open' : 'close'
|
|
35
|
+
}));
|
|
36
|
+
this.dispatchEvent(new CustomEvent(this.opened ? 'open' : 'close'));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
Public Methods
|
|
42
|
+
*/
|
|
43
|
+
open() {
|
|
44
|
+
this.opened = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
close() {
|
|
48
|
+
this.opened = false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toggle() {
|
|
52
|
+
this.opened = !this.opened;
|
|
53
|
+
this.dispatchEvent(new CustomEvent('openedtoggled'));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
Styles
|
|
58
|
+
*/
|
|
59
|
+
static styles = css`
|
|
60
|
+
:host {
|
|
61
|
+
display: block;
|
|
62
|
+
}
|
|
63
|
+
#labelContainer {
|
|
64
|
+
display: flex;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
#label {
|
|
68
|
+
flex: 1 1 auto;
|
|
69
|
+
}
|
|
70
|
+
#labelIcon {
|
|
71
|
+
flex: 0 0 none;
|
|
72
|
+
opacity: 0.5;
|
|
73
|
+
transform: rotate(90deg);
|
|
74
|
+
transition: transform var(--animation_ms, 256ms);
|
|
75
|
+
}
|
|
76
|
+
#labelContainer:hover #labelIcon {
|
|
77
|
+
opacity: 1;
|
|
78
|
+
}
|
|
79
|
+
:host([opened="true"]) #labelIcon {
|
|
80
|
+
transform: rotate(-90deg);
|
|
81
|
+
}
|
|
82
|
+
:host(:not([opened="true"])) #content {
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
Rendering
|
|
89
|
+
*/
|
|
90
|
+
render() {
|
|
91
|
+
return html`
|
|
92
|
+
<div id="labelContainer" @click=${this.handleLabelClick}>
|
|
93
|
+
<div id="label">
|
|
94
|
+
<slot name="label"></slot>
|
|
95
|
+
</div>
|
|
96
|
+
<div id="labelIcon">
|
|
97
|
+
<slot name="labelIcon">
|
|
98
|
+
<k-icon name="chevron-right"></k-icon>
|
|
99
|
+
</slot>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
<div id="content">
|
|
103
|
+
<slot></slot>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
customElements.define('k-collapsible', Collapsible);
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../lit-all.min.js';
|
|
3
|
+
import { boolTrueFalse } from '../utils/propConverters.js';
|
|
4
|
+
import './Icon.js';
|
|
5
|
+
|
|
6
|
+
export default class ContentSlider extends ShadowComponent {
|
|
7
|
+
/*
|
|
8
|
+
Properties
|
|
9
|
+
*/
|
|
10
|
+
static properties = {
|
|
11
|
+
index: { type: Number, reflect: true },
|
|
12
|
+
controls: { type: Boolean, reflect: true, converter: boolTrueFalse },
|
|
13
|
+
globalControls: { type: Boolean, reflect: true, attribute: 'global-controls', converter: boolTrueFalse },
|
|
14
|
+
keyboardControls: { type: Boolean, reflect: true, attribute: 'keyboard-controls', converter: boolTrueFalse },
|
|
15
|
+
loop: { type: Boolean, reflect: true, converter: boolTrueFalse }
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.index = 0;
|
|
21
|
+
this.controls = true;
|
|
22
|
+
this.globalControls = false;
|
|
23
|
+
this.keyboardControls = true;
|
|
24
|
+
this.loop = false;
|
|
25
|
+
this.content = [];
|
|
26
|
+
this.tabIndex = 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
Event Handlers
|
|
31
|
+
*/
|
|
32
|
+
handlePrevClick = () => {
|
|
33
|
+
this.previous();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
handleNextClick = () => {
|
|
37
|
+
this.next();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
handleKeydown = event => {
|
|
41
|
+
if(event.code === 'ArrowLeft') {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
this.dispatchEvent(new CustomEvent('keyleft'));
|
|
44
|
+
this.previous();
|
|
45
|
+
} else if(event.code === 'ArrowRight') {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
this.dispatchEvent(new CustomEvent('keyright'));
|
|
48
|
+
this.next();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
Lifecycle Callbacks
|
|
54
|
+
*/
|
|
55
|
+
connectedCallback() {
|
|
56
|
+
super.connectedCallback();
|
|
57
|
+
this.updateContent();
|
|
58
|
+
this.setupKeyboardControls();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
disconnectedCallback() {
|
|
62
|
+
super.disconnectedCallback();
|
|
63
|
+
this.removeKeyboardControls();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
updated(changedProperties) {
|
|
67
|
+
super.updated(changedProperties);
|
|
68
|
+
|
|
69
|
+
if(changedProperties.has('index')) {
|
|
70
|
+
this.validateAndSetIndex();
|
|
71
|
+
this.renderContent();
|
|
72
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { index: this.index } }));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if(changedProperties.has('keyboardControls') || changedProperties.has('globalControls')) {
|
|
76
|
+
this.removeKeyboardControls();
|
|
77
|
+
this.setupKeyboardControls();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
Private Methods
|
|
83
|
+
*/
|
|
84
|
+
updateContent() {
|
|
85
|
+
this.content = [...this.querySelectorAll(':scope > *')];
|
|
86
|
+
this.validateAndSetIndex();
|
|
87
|
+
this.renderContent();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
validateAndSetIndex() {
|
|
91
|
+
if(this.content.length === 0) return;
|
|
92
|
+
|
|
93
|
+
const validIndex = Math.max(Math.min(this.content.length - 1, this.index), 0);
|
|
94
|
+
if(this.index !== validIndex) {
|
|
95
|
+
this.index = validIndex;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
renderContent() {
|
|
100
|
+
if(this.content.length === 0) return;
|
|
101
|
+
|
|
102
|
+
this.innerHTML = '';
|
|
103
|
+
if(this.content[this.index]) {
|
|
104
|
+
this.appendChild(this.content[this.index]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setupKeyboardControls() {
|
|
109
|
+
if(this.keyboardControls) {
|
|
110
|
+
if(this.globalControls) {
|
|
111
|
+
window.addEventListener('keydown', this.handleKeydown);
|
|
112
|
+
} else {
|
|
113
|
+
this.addEventListener('keydown', this.handleKeydown);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
removeKeyboardControls() {
|
|
119
|
+
window.removeEventListener('keydown', this.handleKeydown);
|
|
120
|
+
this.removeEventListener('keydown', this.handleKeydown);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
Public Methods
|
|
125
|
+
*/
|
|
126
|
+
previous() {
|
|
127
|
+
let newIndex = this.index - 1;
|
|
128
|
+
if(this.loop && newIndex < 0) {
|
|
129
|
+
newIndex = this.content.length - 1;
|
|
130
|
+
}
|
|
131
|
+
this.dispatchEvent(new CustomEvent('previous', { detail: { index: newIndex } }));
|
|
132
|
+
this.index = newIndex;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
next() {
|
|
136
|
+
let newIndex = this.index + 1;
|
|
137
|
+
if(this.loop && newIndex >= this.content.length) {
|
|
138
|
+
newIndex = 0;
|
|
139
|
+
}
|
|
140
|
+
this.dispatchEvent(new CustomEvent('next', { detail: { index: newIndex } }));
|
|
141
|
+
this.index = newIndex;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
goto(newIndex) {
|
|
145
|
+
this.dispatchEvent(new CustomEvent('goto', { detail: { index: newIndex } }));
|
|
146
|
+
this.index = newIndex;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
Styles
|
|
151
|
+
*/
|
|
152
|
+
static styles = css`
|
|
153
|
+
:host {
|
|
154
|
+
display: block;
|
|
155
|
+
position: relative;
|
|
156
|
+
outline: none;
|
|
157
|
+
}
|
|
158
|
+
#prev,
|
|
159
|
+
#next {
|
|
160
|
+
position: absolute;
|
|
161
|
+
top: 50%;
|
|
162
|
+
transform: translateY(-50%);
|
|
163
|
+
font-size: 2rem;
|
|
164
|
+
}
|
|
165
|
+
#next {
|
|
166
|
+
right: 0;
|
|
167
|
+
}
|
|
168
|
+
:host(:not([controls="true"])) #controls {
|
|
169
|
+
display: none;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
/*
|
|
174
|
+
Rendering
|
|
175
|
+
*/
|
|
176
|
+
render() {
|
|
177
|
+
return html`
|
|
178
|
+
<div id="content">
|
|
179
|
+
<slot></slot>
|
|
180
|
+
</div>
|
|
181
|
+
<div id="controls">
|
|
182
|
+
<button
|
|
183
|
+
id="prev"
|
|
184
|
+
class="no-btn"
|
|
185
|
+
@click=${this.handlePrevClick}
|
|
186
|
+
>
|
|
187
|
+
<slot name="prev">
|
|
188
|
+
<k-icon name="chevron-left"></k-icon>
|
|
189
|
+
</slot>
|
|
190
|
+
</button>
|
|
191
|
+
<button
|
|
192
|
+
id="next"
|
|
193
|
+
class="no-btn"
|
|
194
|
+
@click=${this.handleNextClick}
|
|
195
|
+
>
|
|
196
|
+
<slot name="next">
|
|
197
|
+
<k-icon name="chevron-right"></k-icon>
|
|
198
|
+
</slot>
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
customElements.define('k-content-slider', ContentSlider);
|