kempo-ui 0.4.0 → 0.4.2
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/bin/get_icon.js +0 -0
- package/bin/highlight_code.js +0 -0
- package/bin/icon.js +0 -0
- package/bin/list_icons.js +0 -0
- package/dist/components/Slider.js +188 -0
- package/dist/components/Split.js +31 -13
- package/docs/components/accordion.html +4 -0
- package/docs/components/aside.html +4 -0
- package/docs/components/card.html +4 -0
- package/docs/components/code-editor.html +4 -0
- package/docs/components/color-picker.html +4 -0
- package/docs/components/combobox.html +4 -0
- package/docs/components/content-slider.html +4 -0
- package/docs/components/context.html +4 -0
- package/docs/components/dialog.html +4 -0
- package/docs/components/dropdown.html +4 -0
- package/docs/components/filter-list.html +4 -0
- package/docs/components/focus-capture.html +4 -0
- package/docs/components/html-editor.html +4 -0
- package/docs/components/hybrid-component.html +4 -0
- package/docs/components/icon.html +4 -0
- package/docs/components/import.html +4 -0
- package/docs/components/light-component.html +4 -0
- package/docs/components/nav-spacer.html +4 -0
- package/docs/components/nav.html +4 -0
- package/docs/components/photo-viewer.html +4 -0
- package/docs/components/progress.html +4 -0
- package/docs/components/resize.html +4 -0
- package/docs/components/shadow-component.html +4 -0
- package/docs/components/show-more.html +4 -0
- package/docs/components/slider.html +781 -0
- package/docs/components/sortable.html +4 -0
- package/docs/components/spinner.html +4 -0
- package/docs/components/split.html +32 -3
- package/docs/components/table.html +4 -0
- package/docs/components/tableControls.html +4 -0
- package/docs/components/tableCustomFields.html +4 -0
- package/docs/components/tableFetchRecords.html +4 -0
- package/docs/components/tableFieldSortHide.html +4 -0
- package/docs/components/tablePagination.html +4 -0
- package/docs/components/tablePlaceholder.html +4 -0
- package/docs/components/tableRecordEditing.html +4 -0
- package/docs/components/tableRecordFiltering.html +4 -0
- package/docs/components/tableRecordHiding.html +4 -0
- package/docs/components/tableRecordSearching.html +4 -0
- package/docs/components/tableRecordSelection.html +4 -0
- package/docs/components/tableRowControls.html +4 -0
- package/docs/components/tableServerSync.html +4 -0
- package/docs/components/tableSorting.html +4 -0
- package/docs/components/tabs.html +4 -0
- package/docs/components/tags.html +4 -0
- package/docs/components/theme-select.html +4 -0
- package/docs/components/theme-switcher.html +4 -0
- package/docs/components/timestamp.html +4 -0
- package/docs/components/toast.html +4 -0
- package/docs/components/toggle.html +4 -0
- package/docs/components/tree.html +4 -0
- package/docs/index.html +10 -0
- package/docs/src/components/Slider.js +188 -0
- package/docs/src/components/Split.js +31 -13
- package/docs/utils/context.html +4 -0
- package/docs/utils/cookie.html +4 -0
- package/docs/utils/debounce.html +4 -0
- package/docs/utils/drag.html +4 -0
- package/docs/utils/elevation.html +4 -0
- package/docs/utils/formatTimestamp.html +4 -0
- package/docs/utils/object.html +4 -0
- package/docs/utils/propConverters.html +4 -0
- package/docs/utils/string.html +4 -0
- package/docs/utils/theme.html +4 -0
- package/docs/utils/toTitleCase.html +4 -0
- package/docs/utils/type.html +4 -0
- package/docs/utils/wait.html +4 -0
- package/docs-src/components/slider.page.html +331 -0
- package/docs-src/components/split.page.html +28 -3
- package/docs-src/index.page.html +6 -0
- package/docs-src/nav.fragment.html +4 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/src/components/Slider.js +480 -0
- package/src/components/Split.js +163 -132
- package/tests/components/Slider.browser-test.js +823 -0
package/src/components/Split.js
CHANGED
|
@@ -1,125 +1,157 @@
|
|
|
1
1
|
import { html, css } from '../lit-all.min.js';
|
|
2
2
|
import ShadowComponent from './ShadowComponent.js';
|
|
3
3
|
import drag from '../utils/drag.js';
|
|
4
|
+
import { boolExists } from '../utils/propConverters.js';
|
|
4
5
|
|
|
5
6
|
export default class Split extends ShadowComponent {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
7
|
+
static properties = {
|
|
8
|
+
resizing: { type: Boolean, reflect: true },
|
|
9
|
+
stacked: { type: Boolean, reflect: true },
|
|
10
|
+
stackWidth: { type: Number, attribute: 'stack-width' },
|
|
11
|
+
direction: { type: String, reflect: true },
|
|
12
|
+
persistentId: { type: String, reflect: true, attribute: 'persistent-id' },
|
|
13
|
+
grip: { type: Boolean, reflect: true, converter: boolExists }
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this.resizing = false;
|
|
20
|
+
this.stacked = false;
|
|
21
|
+
this.stackWidth = 0;
|
|
22
|
+
this.direction = 'horizontal';
|
|
23
|
+
this.persistentId = null;
|
|
24
|
+
this.grip = false;
|
|
25
|
+
|
|
26
|
+
// Private state
|
|
27
|
+
this.dragStartSize = 0;
|
|
28
|
+
this.dragCleanup = () => { };
|
|
29
|
+
this.resizeObserver = null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Lifecycle Callbacks
|
|
34
|
+
*/
|
|
35
|
+
firstUpdated() {
|
|
36
|
+
super.firstUpdated();
|
|
37
|
+
if(this.grip){
|
|
38
|
+
const el = document.createElement('div');
|
|
39
|
+
el.style.cssText = 'position:absolute;visibility:hidden;width:var(--handle_width)';
|
|
40
|
+
this.shadowRoot.appendChild(el);
|
|
41
|
+
const handleWidth = el.offsetWidth;
|
|
42
|
+
this.shadowRoot.removeChild(el);
|
|
43
|
+
const gripWidth = handleWidth % 2 === 0 ? handleWidth - 1 : handleWidth;
|
|
44
|
+
this.style.setProperty('--handle_grip_width', `${gripWidth}px`);
|
|
45
|
+
}
|
|
46
|
+
this.setupDragHandler();
|
|
47
|
+
this.setupResizeObserver();
|
|
48
|
+
if (this.persistentId && window?.localStorage) {
|
|
49
|
+
const size = window.localStorage.getItem(`split-persistent-id-${this.persistentId}`);
|
|
50
|
+
if (size) this.setSize(size);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
disconnectedCallback() {
|
|
55
|
+
super.disconnectedCallback();
|
|
56
|
+
this.dragCleanup();
|
|
57
|
+
if (this.resizeObserver) {
|
|
58
|
+
this.resizeObserver.disconnect();
|
|
59
|
+
this.resizeObserver = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
Event Handlers
|
|
65
|
+
*/
|
|
66
|
+
handleDragStart = () => {
|
|
67
|
+
this.resizing = true;
|
|
68
|
+
this.dragStartSize = Math.round(this.shadowRoot.getElementById('pane-1').getBoundingClientRect()[this.direction === 'vertical' ? 'height' : 'width']);
|
|
69
|
+
this.dispatchEvent(new CustomEvent('resizestart', {
|
|
70
|
+
detail: { startSize: this.dragStartSize },
|
|
71
|
+
bubbles: true
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
handleDrag = ({ x, y }) => {
|
|
76
|
+
const delta = this.direction === 'vertical' ? y : x;
|
|
77
|
+
const size = `${this.dragStartSize + delta}px`;
|
|
78
|
+
this.setSize(size);
|
|
79
|
+
this.dispatchEvent(new CustomEvent('resize', {
|
|
80
|
+
detail: { size },
|
|
81
|
+
bubbles: true
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
handleDragEnd = ({ x, y }) => {
|
|
86
|
+
this.resizing = false;
|
|
87
|
+
const delta = this.direction === 'vertical' ? y : x;
|
|
88
|
+
const size = `${this.dragStartSize + delta}px`;
|
|
89
|
+
this.setSize(size);
|
|
90
|
+
if (this.persistentId && window?.localStorage) {
|
|
91
|
+
window.localStorage.setItem(`split-persistent-id-${this.persistentId}`, size);
|
|
92
|
+
}
|
|
93
|
+
this.dispatchEvent(new CustomEvent('resizeend', {
|
|
94
|
+
detail: { size },
|
|
95
|
+
bubbles: true
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
Public Methods
|
|
101
|
+
*/
|
|
102
|
+
setSize(size) {
|
|
103
|
+
this.style.setProperty('--pane_1_size', size);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setupDragHandler() {
|
|
107
|
+
const handle = this.shadowRoot.getElementById('divider-handle');
|
|
108
|
+
if (handle) {
|
|
109
|
+
this.dragCleanup = drag({
|
|
110
|
+
element: handle,
|
|
111
|
+
callback: this.handleDrag,
|
|
112
|
+
startCallback: this.handleDragStart,
|
|
113
|
+
endCallback: this.handleDragEnd
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setupResizeObserver() {
|
|
119
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
const width = entry.contentRect.width;
|
|
122
|
+
this.stacked = width <= this.stackWidth;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
this.resizeObserver.observe(this);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
Styles
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
/*
|
|
134
|
+
Rendering
|
|
135
|
+
*/
|
|
136
|
+
render() {
|
|
137
|
+
return html`
|
|
138
|
+
<div id="pane-1" class="pane">
|
|
139
|
+
<slot></slot>
|
|
140
|
+
</div>
|
|
141
|
+
<div id="divider-handle">
|
|
142
|
+
<div id="divider-border">
|
|
143
|
+
${this.grip ? html`<div id="divider-grip"></div>` : ''}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div id="pane-2" class="pane">
|
|
147
|
+
<slot name="right"></slot>
|
|
148
|
+
</div>
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
static styles = css`
|
|
120
152
|
:host {
|
|
121
153
|
--pane_1_size: calc((100% - var(--handle_width)) / 2);
|
|
122
|
-
--handle_width:
|
|
154
|
+
--handle_width: 7px;
|
|
123
155
|
--min_pane_size: 6rem;
|
|
124
156
|
|
|
125
157
|
height: 100%;
|
|
@@ -145,6 +177,7 @@ export default class Split extends ShadowComponent {
|
|
|
145
177
|
}
|
|
146
178
|
|
|
147
179
|
#divider-handle {
|
|
180
|
+
position: relative;
|
|
148
181
|
display: flex;
|
|
149
182
|
flex-shrink: 0;
|
|
150
183
|
justify-content: center;
|
|
@@ -165,10 +198,21 @@ export default class Split extends ShadowComponent {
|
|
|
165
198
|
}
|
|
166
199
|
|
|
167
200
|
#divider-border {
|
|
201
|
+
position: relative;
|
|
168
202
|
width: 1px;
|
|
169
203
|
height: 100%;
|
|
170
204
|
border-left: 1px solid var(--c_border);
|
|
171
205
|
}
|
|
206
|
+
#divider-grip {
|
|
207
|
+
position: absolute;
|
|
208
|
+
top: 50%;
|
|
209
|
+
left: 50%;
|
|
210
|
+
transform: translate(-50%, -50%);
|
|
211
|
+
width: var(--handle_grip_width, var(--handle_width));
|
|
212
|
+
height: 2rem;
|
|
213
|
+
border-radius: 0.25rem;
|
|
214
|
+
background-color: var(--c_border);
|
|
215
|
+
}
|
|
172
216
|
|
|
173
217
|
#pane-2 {
|
|
174
218
|
flex: 1 1;
|
|
@@ -223,24 +267,11 @@ export default class Split extends ShadowComponent {
|
|
|
223
267
|
border-left: none;
|
|
224
268
|
border-top: 1px solid var(--c_border);
|
|
225
269
|
}
|
|
270
|
+
:host([direction="vertical"]) #divider-grip {
|
|
271
|
+
width: 2rem;
|
|
272
|
+
height: 0.5rem;
|
|
273
|
+
}
|
|
226
274
|
`;
|
|
227
|
-
|
|
228
|
-
/*
|
|
229
|
-
Rendering
|
|
230
|
-
*/
|
|
231
|
-
render() {
|
|
232
|
-
return html`
|
|
233
|
-
<div id="pane-1" class="pane">
|
|
234
|
-
<slot></slot>
|
|
235
|
-
</div>
|
|
236
|
-
<div id="divider-handle">
|
|
237
|
-
<div id="divider-border"></div>
|
|
238
|
-
</div>
|
|
239
|
-
<div id="pane-2" class="pane">
|
|
240
|
-
<slot name="right"></slot>
|
|
241
|
-
</div>
|
|
242
|
-
`;
|
|
243
|
-
}
|
|
244
275
|
}
|
|
245
276
|
|
|
246
277
|
customElements.define('k-split', Split);
|