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,210 @@
|
|
|
1
|
+
import { LitElement, html, css } from '../lit-all.min.js';
|
|
2
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
3
|
+
import Icon from './Icon.js';
|
|
4
|
+
import drag from '../utils/drag.js';
|
|
5
|
+
|
|
6
|
+
export default class Resize extends ShadowComponent {
|
|
7
|
+
/*
|
|
8
|
+
Properties
|
|
9
|
+
*/
|
|
10
|
+
static properties = {
|
|
11
|
+
resizing: { type: String, reflect: true },
|
|
12
|
+
dimention: { type: String, reflect: true }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
Lifecycle Callbacks
|
|
17
|
+
*/
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.resizing = '';
|
|
21
|
+
this.dimension = '';
|
|
22
|
+
this.startSize = { width: 0, height: 0 };
|
|
23
|
+
this.cleanupFuncs = [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
firstUpdated() {
|
|
27
|
+
super.firstUpdated();
|
|
28
|
+
this.setupDragHandlers();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.cleanupFuncs.forEach(cleanup => cleanup());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
Event Handlers
|
|
38
|
+
*/
|
|
39
|
+
dragStartHandler = ({ element }) => {
|
|
40
|
+
const { width, height } = this.getBoundingClientRect();
|
|
41
|
+
this.startSize.width = width;
|
|
42
|
+
this.startSize.height = height;
|
|
43
|
+
this.resizing = element.id;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
dragEndHandler = () => {
|
|
47
|
+
this.resizing = '';
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
dragSideHandler = ({ x }) => {
|
|
51
|
+
this.style.width = this.startSize.width + x + 'px';
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
dragBottomHandler = ({ y }) => {
|
|
55
|
+
this.style.height = this.startSize.height + y + 'px';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
dragCornerHandler = ({ x, y }) => {
|
|
59
|
+
this.style.width = this.startSize.width + x + 'px';
|
|
60
|
+
this.style.height = this.startSize.height + y + 'px';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
Utility Methods
|
|
65
|
+
*/
|
|
66
|
+
setupDragHandlers() {
|
|
67
|
+
const sideHandle = this.shadowRoot.getElementById('side');
|
|
68
|
+
const bottomHandle = this.shadowRoot.getElementById('bottom');
|
|
69
|
+
const cornerHandle = this.shadowRoot.getElementById('corner');
|
|
70
|
+
|
|
71
|
+
if(sideHandle) {
|
|
72
|
+
this.cleanupFuncs.push(drag({
|
|
73
|
+
element: sideHandle,
|
|
74
|
+
startCallback: this.dragStartHandler,
|
|
75
|
+
endCallback: this.dragEndHandler,
|
|
76
|
+
callback: this.dragSideHandler,
|
|
77
|
+
preventScroll: true
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(bottomHandle) {
|
|
82
|
+
this.cleanupFuncs.push(drag({
|
|
83
|
+
element: bottomHandle,
|
|
84
|
+
startCallback: this.dragStartHandler,
|
|
85
|
+
endCallback: this.dragEndHandler,
|
|
86
|
+
callback: this.dragBottomHandler,
|
|
87
|
+
preventScroll: true
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if(cornerHandle) {
|
|
92
|
+
this.cleanupFuncs.push(drag({
|
|
93
|
+
element: cornerHandle,
|
|
94
|
+
startCallback: this.dragStartHandler,
|
|
95
|
+
endCallback: this.dragEndHandler,
|
|
96
|
+
callback: this.dragCornerHandler,
|
|
97
|
+
preventScroll: true
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
Styles
|
|
104
|
+
*/
|
|
105
|
+
static styles = css`
|
|
106
|
+
:host {
|
|
107
|
+
--handle_size: 1rem;
|
|
108
|
+
|
|
109
|
+
display: grid;
|
|
110
|
+
grid-template-columns: 1fr var(--handle_size);
|
|
111
|
+
grid-template-rows: 1fr var(--handle_size);
|
|
112
|
+
border: 1px solid var(--c_border);
|
|
113
|
+
border-radius: var(--radius);
|
|
114
|
+
min-width: 10rem;
|
|
115
|
+
max-width: 100%;
|
|
116
|
+
min-height: 10rem;
|
|
117
|
+
max-height: 100%;
|
|
118
|
+
}
|
|
119
|
+
:host([dimension="height"]) {
|
|
120
|
+
grid-template-columns: 1fr;
|
|
121
|
+
}
|
|
122
|
+
:host([dimension="width"]) {
|
|
123
|
+
grid-template-rows: 1fr;
|
|
124
|
+
}
|
|
125
|
+
#main {
|
|
126
|
+
grid-row: 1;
|
|
127
|
+
grid-column: 1;
|
|
128
|
+
overflow: auto;
|
|
129
|
+
}
|
|
130
|
+
#side {
|
|
131
|
+
grid-row: 1;
|
|
132
|
+
grid-column: 2;
|
|
133
|
+
cursor: ew-resize;
|
|
134
|
+
}
|
|
135
|
+
#bottom {
|
|
136
|
+
grid-row: 2;
|
|
137
|
+
grid-column: 1;
|
|
138
|
+
text-align: center;
|
|
139
|
+
cursor: ns-resize;
|
|
140
|
+
}
|
|
141
|
+
#corner {
|
|
142
|
+
grid-row: 2;
|
|
143
|
+
grid-column: 2;
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
cursor: nwse-resize;
|
|
146
|
+
}
|
|
147
|
+
.handle {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
}
|
|
152
|
+
.handle svg {
|
|
153
|
+
transform: scale(0.5);
|
|
154
|
+
}
|
|
155
|
+
#bottom svg {
|
|
156
|
+
height: var(--handle_size);
|
|
157
|
+
}
|
|
158
|
+
#side svg {
|
|
159
|
+
width: var(--handle_size);
|
|
160
|
+
}
|
|
161
|
+
#corner svg {
|
|
162
|
+
width: var(--handle_size);
|
|
163
|
+
height: var(--handle_size);
|
|
164
|
+
}
|
|
165
|
+
:host(:not([resizing=""])) #main {
|
|
166
|
+
pointer-events: none;
|
|
167
|
+
}
|
|
168
|
+
:host([resizing="side"]) #side,
|
|
169
|
+
:host([resizing="corner"]) #side,
|
|
170
|
+
:host([resizing="corner"]) #corner,
|
|
171
|
+
:host([resizing="corner"]) #bottom,
|
|
172
|
+
:host([resizing="bottom"]) #bottom {
|
|
173
|
+
background-color: var(--c_highlight);
|
|
174
|
+
}
|
|
175
|
+
:host([dimension="height"]) #side,
|
|
176
|
+
:host([dimension="height"]) #corner,
|
|
177
|
+
:host([dimension="width"]) #bottom,
|
|
178
|
+
:host([dimension="width"]) #corner {
|
|
179
|
+
display: none;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
/*
|
|
184
|
+
Rendering
|
|
185
|
+
*/
|
|
186
|
+
render() {
|
|
187
|
+
return html`
|
|
188
|
+
<div id="main">
|
|
189
|
+
<slot></slot>
|
|
190
|
+
</div>
|
|
191
|
+
<div id="side" class="handle">
|
|
192
|
+
<svg viewBox="0 0 15 64" xmlns="http://www.w3.org/2000/svg">
|
|
193
|
+
<path fill="currentColor" d="m 15.000001,3 c 0,-1.661998 -1.115001,-3 -2.5,-3 -1.384999,0 -2.5,1.338002 -2.5,3 v 58 c 0,1.661998 1.115001,3 2.5,3 1.384999,0 2.5,-1.338002 2.5,-3 z M 5.0000008,3 c 0,-1.661998 -1.115001,-3 -2.5,-3 C 1.1150018,0 7.5891117e-7,1.338002 7.5891117e-7,3 v 58 c 0,1.661998 1.11500104108883,3 2.50000004108883,3 1.384999,0 2.5,-1.338002 2.5,-3 z" />
|
|
194
|
+
</svg>
|
|
195
|
+
</div>
|
|
196
|
+
<div id="bottom" class="handle">
|
|
197
|
+
<svg viewBox="0 0 64 15" xmlns="http://www.w3.org/2000/svg">
|
|
198
|
+
<path fill="currentColor" d="M 3,0 C 1.3380017,0 0,1.1150014 0,2.5 0,3.8849986 1.3380017,5 3,5 H 61 C 62.661998,5 64,3.8849986 64,2.5 64,1.1150014 62.661998,0 61,0 Z M 3,10 C 1.3380017,10 0,11.115001 0,12.5 0,13.884999 1.3380017,15 3,15 h 58 c 1.661998,0 3,-1.115001 3,-2.5 C 64,11.115001 62.661998,10 61,10 Z" />
|
|
199
|
+
</svg>
|
|
200
|
+
</div>
|
|
201
|
+
<div id="corner" class="handle">
|
|
202
|
+
<svg version="1.1" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg">
|
|
203
|
+
<path fill="currentColor" d="m12.735 3.0095e-4c-0.77288 0.011702-1.6098 0.36368-2.2773 1.0313l-9.4258 9.4258c-1.1868 1.1868-1.3772 2.908-0.42773 3.8574 0.94943 0.94943 2.6687 0.7571 3.8555-0.42969l9.4258-9.4258c1.1868-1.1868 1.3772-2.906 0.42774-3.8555-0.41537-0.41537-0.977-0.61262-1.5781-0.60352zm0 8.5684c-0.77288 0.011702-1.6098 0.36564-2.2773 1.0332l-0.85744 0.85546c-1.1868 1.1868-1.3772 2.908-0.42773 3.8574 0.94943 0.94943 2.6687 0.7571 3.8555-0.42969l0.85742-0.85742c1.1868-1.1868 1.3772-2.906 0.42773-3.8555-0.41537-0.41537-0.977-0.61262-1.5781-0.60352z" />
|
|
204
|
+
</svg>
|
|
205
|
+
</div>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
customElements.define('k-resize', Resize);
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import { LitElement } from '../lit-all.min.js';
|
|
2
|
-
|
|
3
|
-
export default class ShadowComponent extends LitElement {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
link
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { LitElement } from '../lit-all.min.js';
|
|
2
|
+
|
|
3
|
+
export default class ShadowComponent extends LitElement {
|
|
4
|
+
static stylesheetPath = '/kempo.min.css';
|
|
5
|
+
|
|
6
|
+
createRenderRoot() {
|
|
7
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
8
|
+
|
|
9
|
+
const link = document.createElement('link');
|
|
10
|
+
link.rel = 'stylesheet';
|
|
11
|
+
link.href = this.constructor.stylesheetPath;
|
|
12
|
+
shadowRoot.appendChild(link);
|
|
13
|
+
|
|
14
|
+
// Inject component styles if they exist
|
|
15
|
+
const styles = this.constructor.styles;
|
|
16
|
+
if (styles) {
|
|
17
|
+
const styleEl = document.createElement('style');
|
|
18
|
+
if (Array.isArray(styles)) {
|
|
19
|
+
styleEl.textContent = styles.map(s => s.cssText || s).join('\n');
|
|
20
|
+
} else {
|
|
21
|
+
styleEl.textContent = styles.cssText || styles;
|
|
22
|
+
}
|
|
23
|
+
shadowRoot.appendChild(styleEl);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const renderContainer = document.createElement('div');
|
|
27
|
+
renderContainer.style.display = 'contents';
|
|
28
|
+
shadowRoot.appendChild(renderContainer);
|
|
29
|
+
|
|
30
|
+
return renderContainer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LitElement, html, css } from '../lit-all.min.js';
|
|
2
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
3
|
+
import Icon from './Icon.js';
|
|
4
|
+
import { boolExists } from '../utils/propConverters.js';
|
|
5
|
+
|
|
6
|
+
export default class ShowMore extends ShadowComponent {
|
|
7
|
+
/*
|
|
8
|
+
Properties
|
|
9
|
+
*/
|
|
10
|
+
static properties = {
|
|
11
|
+
opened: { type: Boolean, converter: boolExists, reflect: true }
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
Lifecycle Callbacks
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.opened = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
updated(changedProperties) {
|
|
23
|
+
super.updated(changedProperties);
|
|
24
|
+
|
|
25
|
+
if(changedProperties.has('opened')) {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
27
|
+
detail: { opened: this.opened }
|
|
28
|
+
}));
|
|
29
|
+
this.dispatchEvent(new CustomEvent(this.opened ? 'opened' : 'closed'));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
Event Handlers
|
|
35
|
+
*/
|
|
36
|
+
handleToggleClick = () => {
|
|
37
|
+
this.toggle();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
Public Methods
|
|
42
|
+
*/
|
|
43
|
+
more() {
|
|
44
|
+
this.opened = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
less() {
|
|
48
|
+
this.opened = false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toggle() {
|
|
52
|
+
this.opened = !this.opened;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
Styles
|
|
57
|
+
*/
|
|
58
|
+
static styles = css`
|
|
59
|
+
:host {
|
|
60
|
+
--closed_height: 7rem;
|
|
61
|
+
|
|
62
|
+
display: block;
|
|
63
|
+
}
|
|
64
|
+
:host(:not([opened])) #content {
|
|
65
|
+
height: var(--closed_height);
|
|
66
|
+
overflow-y: hidden;
|
|
67
|
+
}
|
|
68
|
+
:host(:not([opened])) #content {
|
|
69
|
+
margin-bottom: calc(var(--closed_height) * -0.9);
|
|
70
|
+
}
|
|
71
|
+
:host(:not([opened])) #toggle {
|
|
72
|
+
padding-top: calc(var(--closed_height) - 2rem);
|
|
73
|
+
background: linear-gradient(to bottom, transparent 0%, var(--c_bg) 95%);
|
|
74
|
+
}
|
|
75
|
+
#toggle {
|
|
76
|
+
width: 100%;
|
|
77
|
+
padding: var(--spacer_h);
|
|
78
|
+
text-align: center;
|
|
79
|
+
background: var(--c_bg);
|
|
80
|
+
}
|
|
81
|
+
:host([opened]) #more,
|
|
82
|
+
:host(:not([opened])) #less {
|
|
83
|
+
display: none;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
Rendering
|
|
89
|
+
*/
|
|
90
|
+
render() {
|
|
91
|
+
return html`
|
|
92
|
+
<div id="wrapper">
|
|
93
|
+
<div id="content">
|
|
94
|
+
<slot></slot>
|
|
95
|
+
</div>
|
|
96
|
+
<button id="toggle" @click=${this.handleToggleClick} class="no-btn">
|
|
97
|
+
<span id="more">
|
|
98
|
+
<slot name="more">Show More <k-icon name="arrow-down-double"></k-icon></slot>
|
|
99
|
+
</span>
|
|
100
|
+
<span id="less">
|
|
101
|
+
<slot name="less">Show Less <k-icon name="arrow-up-double"></k-icon></slot>
|
|
102
|
+
</span>
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
customElements.define('k-show-more', ShowMore);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import ShadowComponent from './ShadowComponent.js';
|
|
2
|
+
import { html, css } from '../lit-all.min.js';
|
|
3
|
+
import { boolTrueFalse } from '../utils/propConverters.js';
|
|
4
|
+
import './FocusCapture.js';
|
|
5
|
+
|
|
6
|
+
export default class SideMenu extends ShadowComponent {
|
|
7
|
+
/*
|
|
8
|
+
Properties
|
|
9
|
+
*/
|
|
10
|
+
static properties = {
|
|
11
|
+
opened: { type: Boolean, reflect: true },
|
|
12
|
+
overlayClose: { type: Boolean, reflect: true, attribute: 'overlay-close', converter: boolTrueFalse },
|
|
13
|
+
side: { type: String, reflect: true }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.opened = false;
|
|
19
|
+
this.overlayClose = true;
|
|
20
|
+
this.side = 'left';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
Event Handlers
|
|
25
|
+
*/
|
|
26
|
+
overlayClick = () => {
|
|
27
|
+
if(this.overlayClose) this.close();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
Lifecycle Callbacks
|
|
32
|
+
*/
|
|
33
|
+
updated(changedProperties) {
|
|
34
|
+
super.updated(changedProperties);
|
|
35
|
+
|
|
36
|
+
if(changedProperties.has('opened')) {
|
|
37
|
+
if(this.opened) {
|
|
38
|
+
this.dispatchEvent(new CustomEvent('change', { detail: 'open' }));
|
|
39
|
+
this.dispatchEvent(new CustomEvent('open'));
|
|
40
|
+
} else {
|
|
41
|
+
this.dispatchEvent(new CustomEvent('change', { detail: 'close' }));
|
|
42
|
+
this.dispatchEvent(new CustomEvent('close'));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
Methods
|
|
49
|
+
*/
|
|
50
|
+
open() {
|
|
51
|
+
this.opened = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
close() {
|
|
55
|
+
this.opened = false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
toggle() {
|
|
59
|
+
this.opened ? this.close() : this.open();
|
|
60
|
+
this.dispatchEvent(new CustomEvent('toggle'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
Rendering
|
|
65
|
+
*/
|
|
66
|
+
render() {
|
|
67
|
+
return html`
|
|
68
|
+
<k-focus-capture>
|
|
69
|
+
<div id="container">
|
|
70
|
+
<button id="overlay" @click=${this.overlayClick}>
|
|
71
|
+
<div id="overlay-x">✕</div>
|
|
72
|
+
</button>
|
|
73
|
+
<div id="menu">
|
|
74
|
+
<slot></slot>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</k-focus-capture>
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
static styles = css`
|
|
81
|
+
:host {
|
|
82
|
+
--bg: var(--c_bg);
|
|
83
|
+
--width: 20rem;
|
|
84
|
+
|
|
85
|
+
position: fixed;
|
|
86
|
+
top: 0;
|
|
87
|
+
left: 0;
|
|
88
|
+
width: 100vw;
|
|
89
|
+
max-width: 100%;
|
|
90
|
+
height: 100vh;
|
|
91
|
+
z-index: 100;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
}
|
|
94
|
+
:host([opened]) {
|
|
95
|
+
pointer-events: auto;
|
|
96
|
+
}
|
|
97
|
+
k-focus-capture {
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
}
|
|
101
|
+
#container {
|
|
102
|
+
position: relative;
|
|
103
|
+
width: 100%;
|
|
104
|
+
height: 100%;
|
|
105
|
+
opacity: 0;
|
|
106
|
+
transition: opacity var(--animation_ms, 256ms);
|
|
107
|
+
}
|
|
108
|
+
:host([opened]) #container {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
}
|
|
111
|
+
#overlay {
|
|
112
|
+
position: absolute;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
left: 0;
|
|
116
|
+
top: 0;
|
|
117
|
+
background: var(--overlay, rgba(0, 0, 0, 0.5));
|
|
118
|
+
border: none;
|
|
119
|
+
padding: 0;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
z-index: 1;
|
|
122
|
+
}
|
|
123
|
+
#overlay-x {
|
|
124
|
+
position: absolute;
|
|
125
|
+
top: var(--spacer_h);
|
|
126
|
+
right: var(--spacer_h);
|
|
127
|
+
font-size: 1.75rem;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
color: var(--tc_light);
|
|
130
|
+
}
|
|
131
|
+
:host([overlay-close="false"]) #overlay-x {
|
|
132
|
+
display: none;
|
|
133
|
+
}
|
|
134
|
+
:host([overlay-close="false"]) #overlay {
|
|
135
|
+
cursor: default;
|
|
136
|
+
}
|
|
137
|
+
#menu {
|
|
138
|
+
position: absolute;
|
|
139
|
+
width: var(--width);
|
|
140
|
+
max-width: calc(100vw - 6rem);
|
|
141
|
+
height: 100vh;
|
|
142
|
+
overflow-y: auto;
|
|
143
|
+
left: calc(var(--width) * -1);
|
|
144
|
+
top: 0;
|
|
145
|
+
background: var(--bg);
|
|
146
|
+
transition: left var(--animation_ms, 256ms);
|
|
147
|
+
padding: var(--menu_padding, var(--spacer));
|
|
148
|
+
z-index: 2;
|
|
149
|
+
}
|
|
150
|
+
:host([opened]) #menu {
|
|
151
|
+
left: 0;
|
|
152
|
+
}
|
|
153
|
+
:host([side="right"]) #menu {
|
|
154
|
+
left: auto;
|
|
155
|
+
transition: right var(--animation_ms, 256ms);
|
|
156
|
+
right: calc(var(--width) * -1);
|
|
157
|
+
}
|
|
158
|
+
:host([opened][side="right"]) #menu {
|
|
159
|
+
right: 0;
|
|
160
|
+
}
|
|
161
|
+
:host([side="right"]) #overlay-x {
|
|
162
|
+
right: auto;
|
|
163
|
+
left: var(--spacer_h);
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
window.customElements.define('k-side-menu', SideMenu);
|