kempo-ui 0.0.13 → 0.0.15
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/dist/kempo-vars.css +1 -0
- package/docs/dev.config.json +5 -9
- package/docs/kempo-ui/components/accordion.html +236 -0
- package/docs/{components → kempo-ui/components}/card.html +8 -7
- package/docs/{components → kempo-ui/components}/content-slider.html +8 -7
- package/docs/kempo-ui/components/dialog.html +339 -0
- package/docs/{components → kempo-ui/components}/focus-capture.html +9 -8
- package/docs/{components → kempo-ui/components}/hybrid-component.html +7 -6
- package/docs/{components → kempo-ui/components}/icon.html +9 -8
- package/docs/{components → kempo-ui/components}/import.html +8 -7
- package/docs/{components → kempo-ui/components}/light-component.html +7 -6
- package/docs/{components → kempo-ui/components}/photo-viewer.html +8 -7
- package/docs/{components → kempo-ui/components}/resize.html +8 -7
- package/docs/{components → kempo-ui/components}/shadow-component.html +7 -6
- package/docs/{components → kempo-ui/components}/show-more.html +8 -7
- package/docs/{components → kempo-ui/components}/side-menu.html +8 -8
- package/docs/{components → kempo-ui/components}/sortable.html +8 -7
- package/docs/{components → kempo-ui/components}/split.html +9 -8
- package/docs/{components → kempo-ui/components}/table.html +32 -32
- package/docs/{components → kempo-ui/components}/tableControls.html +12 -12
- package/docs/{components → kempo-ui/components}/tableCustomFields.html +9 -9
- package/docs/{components → kempo-ui/components}/tableFetchRecords.html +16 -16
- package/docs/{components → kempo-ui/components}/tableFieldSortHide.html +11 -11
- package/docs/{components → kempo-ui/components}/tablePagination.html +17 -17
- package/docs/{components → kempo-ui/components}/tableRecordEditing.html +12 -12
- package/docs/{components → kempo-ui/components}/tableRecordFiltering.html +11 -11
- package/docs/{components → kempo-ui/components}/tableRecordHiding.html +13 -13
- package/docs/{components → kempo-ui/components}/tableRecordSearching.html +11 -11
- package/docs/{components → kempo-ui/components}/tableRecordSelection.html +11 -11
- package/docs/{components → kempo-ui/components}/tableRowControls.html +12 -12
- package/docs/{components → kempo-ui/components}/tableSorting.html +9 -9
- package/docs/{components → kempo-ui/components}/tabs.html +8 -7
- package/docs/{components → kempo-ui/components}/tags.html +8 -7
- package/docs/{components → kempo-ui/components}/theme-switcher.html +8 -7
- package/docs/{components → kempo-ui/components}/timestamp.html +8 -7
- package/docs/kempo-ui/components/toast.html +315 -0
- package/docs/{components → kempo-ui/components}/toggle.html +8 -7
- package/docs/{components → kempo-ui/components}/tree.html +16 -14
- package/docs/{index.html → kempo-ui/index.html} +7 -18
- package/docs/kempo-ui/kempo-vars.css +1 -0
- package/docs/kempo-ui/nav.inc.html +67 -0
- package/docs/kempo-ui/utils/debounce.html +56 -0
- package/docs/{utils → kempo-ui/utils}/drag.html +8 -17
- package/docs/{utils → kempo-ui/utils}/formatTimestamp.html +12 -29
- package/docs/kempo-ui/utils/propConverters.html +90 -0
- package/docs/{utils → kempo-ui/utils}/toTitleCase.html +7 -6
- package/docs/kempo-ui/utils/watchWindowSize.html +72 -0
- package/docs/prod.config.json +0 -8
- package/package.json +2 -2
- package/scripts/build.js +8 -8
- package/scripts/docs.js +3 -0
- package/src/components/Accordion.js +145 -57
- package/src/components/Tabs.js +14 -23
- package/src/kempo-vars.css +1 -0
- package/docs/components/accordion.html +0 -161
- package/docs/components/collapsible.html +0 -193
- package/docs/components/dialog.html +0 -105
- package/docs/components/init.js +0 -7
- package/docs/components/persistant-collapsible.html +0 -117
- package/docs/components/toast.html +0 -52
- package/docs/init.js +0 -7
- package/docs/kempo-vars.css +0 -0
- package/docs/kempo.css +0 -1
- package/docs/nav.inc.html +0 -69
- package/docs/utils/debounce.html +0 -74
- package/docs/utils/init.js +0 -8
- package/docs/utils/propConverters.html +0 -128
- package/docs/utils/watchWindowSize.html +0 -162
- package/src/components/Collapsible.js +0 -109
- package/src/components/PersistantCollapsible.js +0 -69
- /package/docs/{icons → kempo-ui/icons}/add.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-back.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-down-double.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-down.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-forward.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-up-double.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/arrow-up.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/cards.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/check.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/chevron-left.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/chevron-right.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/close.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/compare.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/delete.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/drag-handle.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/drawing2.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/edit.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/error.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/export-file.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/file-text.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/file.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/filter-off.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/filter.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/first.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/folder-clear.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/folder-create.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/folder-open.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/folder.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/hide.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/image.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/label-add.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/label.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/last.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/menu.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/mode-auto.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/mode-dark.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/mode-light.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/open-in-browser.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/pause.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/play.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/refresh.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/remove.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/save.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/search.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/settings.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/show.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/storage.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/table-visibility.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/tag.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/tools.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/trash-x.svg +0 -0
- /package/docs/{icons → kempo-ui/icons}/warning.svg +0 -0
- /package/docs/{kempo-hljs.css → kempo-ui/kempo-hljs.css} +0 -0
- /package/docs/{kempo.min.css → kempo-ui/kempo.min.css} +0 -0
- /package/docs/{media → kempo-ui/media}/civic.jpg +0 -0
- /package/docs/{media → kempo-ui/media}/corvette.jpg +0 -0
- /package/docs/{media → kempo-ui/media}/evo.jpg +0 -0
- /package/docs/{media → kempo-ui/media}/gtr.jpg +0 -0
- /package/docs/{media → kempo-ui/media}/nsx.jpg +0 -0
- /package/docs/{nav.inc.js → kempo-ui/nav.inc.js} +0 -0
- /package/docs/{src → kempo-ui/src}/components/Accordion.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Card.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Collapsible.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/ContentSlider.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Dialog.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/FocusCapture.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/HybridComponent.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Icon.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Import.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/LightComponent.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/PersistantCollapsible.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/PhotoViewer.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Resize.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/ShadowComponent.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/ShowMore.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/SideMenu.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Sortable.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Split.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Table.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Tabs.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Tags.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/ThemeSwitcher.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Timestamp.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Toast.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Toggle.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/Tree.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/DeleteRecord.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/Edit.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/ExportCSV.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/ExportJson.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/FieldSortHide.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/Filters.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/FirstPage.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/HiddenCount.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/Hide.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/LastPage.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/NextPage.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/PageSelect.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/PageSize.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/PrevPage.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/Search.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/ShowAll.js +0 -0
- /package/docs/{src → kempo-ui/src}/components/tableControls/TableControl.js +0 -0
- /package/docs/{src → kempo-ui/src}/lit-all.min.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/debounce.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/drag.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/formatTimestamp.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/propConverters.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/toTitleCase.js +0 -0
- /package/docs/{src → kempo-ui/src}/utils/watchWindowSize.js +0 -0
- /package/docs/{styles.css → kempo-ui/styles.css} +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>watchWindowSize - Kempo UI</title>
|
|
7
|
-
<link rel="stylesheet" href="../kempo-vars.css" />
|
|
8
|
-
<link rel="stylesheet" href="../kempo.min.css" />
|
|
9
|
-
<link rel="stylesheet" href="../kempo-hljs.css" />
|
|
10
|
-
<link rel="stylesheet" href="../styles.css" />
|
|
11
|
-
<script>window.litDisableBundleWarning = true;</script>
|
|
12
|
-
<script type="module" src="./init.js"></script>
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<k-import src="../nav.inc.html"></k-import>
|
|
16
|
-
<main>
|
|
17
|
-
<h1>watchWindowSize</h1>
|
|
18
|
-
|
|
19
|
-
<details
|
|
20
|
-
class="b r mb"
|
|
21
|
-
>
|
|
22
|
-
<summary class="p">Table of Contents</summary>
|
|
23
|
-
<div class="m mt0 pl">
|
|
24
|
-
<h6>Usage</h6>
|
|
25
|
-
<a href="#basicUsage">Basic Usage</a><br />
|
|
26
|
-
<a href="#functions">Functions</a><br />
|
|
27
|
-
<a href="#examples">Examples</a><br />
|
|
28
|
-
</div>
|
|
29
|
-
</details>
|
|
30
|
-
|
|
31
|
-
<h3>Description</h3>
|
|
32
|
-
<p>The <code>watchWindowSize</code> utility provides a debounced way to monitor window resize events. It manages multiple handlers efficiently and automatically debounces resize events to improve performance.</p>
|
|
33
|
-
|
|
34
|
-
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
35
|
-
<p>Import and use the window size watching functions:</p>
|
|
36
|
-
<pre><code class="hljs javascript">import { watchWindowSize, unwatchWindowSize } from './utils/watchWindowSize.js';
|
|
37
|
-
|
|
38
|
-
const handler = (width) => {
|
|
39
|
-
console.log('Window width:', width);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Start watching
|
|
43
|
-
const currentWidth = watchWindowSize(handler);
|
|
44
|
-
|
|
45
|
-
// Stop watching when done
|
|
46
|
-
unwatchWindowSize(handler);</code></pre>
|
|
47
|
-
|
|
48
|
-
<h3 id="functions"><a href="#functions" class="no-link">Functions</a></h3>
|
|
49
|
-
|
|
50
|
-
<h5><code>watchWindowSize(handler)</code></h5>
|
|
51
|
-
<p>Registers a handler function to be called when the window is resized.</p>
|
|
52
|
-
<ul>
|
|
53
|
-
<li><strong>handler:</strong> Function that receives the new window width</li>
|
|
54
|
-
<li><strong>Returns:</strong> Current window width</li>
|
|
55
|
-
</ul>
|
|
56
|
-
|
|
57
|
-
<h5><code>unwatchWindowSize(handler)</code></h5>
|
|
58
|
-
<p>Unregisters a previously registered handler function.</p>
|
|
59
|
-
<ul>
|
|
60
|
-
<li><strong>handler:</strong> The same function reference that was registered</li>
|
|
61
|
-
</ul>
|
|
62
|
-
|
|
63
|
-
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
64
|
-
|
|
65
|
-
<h4>Responsive Component</h4>
|
|
66
|
-
<pre><code class="hljs javascript">import { watchWindowSize, unwatchWindowSize } from './utils/watchWindowSize.js';
|
|
67
|
-
|
|
68
|
-
class ResponsiveComponent extends LitElement {
|
|
69
|
-
constructor() {
|
|
70
|
-
super();
|
|
71
|
-
this.isMobile = false;
|
|
72
|
-
this.resizeHandler = this.handleResize.bind(this);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
connectedCallback() {
|
|
76
|
-
super.connectedCallback();
|
|
77
|
-
const currentWidth = watchWindowSize(this.resizeHandler);
|
|
78
|
-
this.handleResize(currentWidth);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
disconnectedCallback() {
|
|
82
|
-
super.disconnectedCallback();
|
|
83
|
-
unwatchWindowSize(this.resizeHandler);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
handleResize(width) {
|
|
87
|
-
this.isMobile = width < 768;
|
|
88
|
-
this.requestUpdate();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
render() {
|
|
92
|
-
return html`
|
|
93
|
-
<div class="${this.isMobile ? 'mobile' : 'desktop'}">
|
|
94
|
-
Content adapts to screen size
|
|
95
|
-
</div>
|
|
96
|
-
`;
|
|
97
|
-
}
|
|
98
|
-
}</code></pre>
|
|
99
|
-
|
|
100
|
-
<h4>Multiple Handlers</h4>
|
|
101
|
-
<pre><code class="hljs javascript">// Handler for navigation
|
|
102
|
-
const navHandler = (width) => {
|
|
103
|
-
const nav = document.querySelector('.navigation');
|
|
104
|
-
nav.classList.toggle('mobile', width < 1024);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// Handler for sidebar
|
|
108
|
-
const sidebarHandler = (width) => {
|
|
109
|
-
const sidebar = document.querySelector('.sidebar');
|
|
110
|
-
sidebar.style.display = width < 768 ? 'none' : 'block';
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Both handlers will be called on resize
|
|
114
|
-
watchWindowSize(navHandler);
|
|
115
|
-
watchWindowSize(sidebarHandler);
|
|
116
|
-
|
|
117
|
-
// Clean up when needed
|
|
118
|
-
unwatchWindowSize(navHandler);
|
|
119
|
-
unwatchWindowSize(sidebarHandler);</code></pre>
|
|
120
|
-
|
|
121
|
-
<h4>Breakpoint Detection</h4>
|
|
122
|
-
<pre><code class="hljs javascript">const breakpoints = {
|
|
123
|
-
mobile: 768,
|
|
124
|
-
tablet: 1024,
|
|
125
|
-
desktop: 1200
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const breakpointHandler = (width) => {
|
|
129
|
-
let currentBreakpoint = 'mobile';
|
|
130
|
-
|
|
131
|
-
if (width >= breakpoints.desktop) {
|
|
132
|
-
currentBreakpoint = 'desktop';
|
|
133
|
-
} else if (width >= breakpoints.tablet) {
|
|
134
|
-
currentBreakpoint = 'tablet';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
document.body.setAttribute('data-breakpoint', currentBreakpoint);
|
|
138
|
-
|
|
139
|
-
// Dispatch custom event
|
|
140
|
-
window.dispatchEvent(new CustomEvent('breakpointchange', {
|
|
141
|
-
detail: { width, breakpoint: currentBreakpoint }
|
|
142
|
-
}));
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
watchWindowSize(breakpointHandler);</code></pre>
|
|
146
|
-
|
|
147
|
-
<h4>Performance Benefits</h4>
|
|
148
|
-
<p>The utility automatically debounces resize events, so you don't need to worry about performance:</p>
|
|
149
|
-
<pre><code class="hljs javascript">// This handler will only be called after resize events stop
|
|
150
|
-
const expensiveHandler = (width) => {
|
|
151
|
-
// Expensive DOM calculations or API calls
|
|
152
|
-
recalculateLayout();
|
|
153
|
-
updateCharts();
|
|
154
|
-
reflow();
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
watchWindowSize(expensiveHandler); // Automatically debounced</code></pre>
|
|
158
|
-
|
|
159
|
-
</main>
|
|
160
|
-
<div style="height:33vh"></div>
|
|
161
|
-
</body>
|
|
162
|
-
</html>
|
|
@@ -1,109 +0,0 @@
|
|
|
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);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import Collapsible from './Collapsible.js';
|
|
2
|
-
|
|
3
|
-
export default class PersistantCollapsible extends Collapsible {
|
|
4
|
-
constructor() {
|
|
5
|
-
super();
|
|
6
|
-
this.storageKey = '';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
Lifecycle Callbacks
|
|
11
|
-
*/
|
|
12
|
-
connectedCallback() {
|
|
13
|
-
super.connectedCallback();
|
|
14
|
-
this.updateStorageKey();
|
|
15
|
-
this.loadFromStorage();
|
|
16
|
-
window.addEventListener('storage', this.handleStorageChange);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
disconnectedCallback() {
|
|
20
|
-
super.disconnectedCallback();
|
|
21
|
-
window.removeEventListener('storage', this.handleStorageChange);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
updated(changedProperties) {
|
|
25
|
-
super.updated(changedProperties);
|
|
26
|
-
|
|
27
|
-
if(changedProperties.has('opened')) {
|
|
28
|
-
this.saveToStorage();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if(changedProperties.has('id')) {
|
|
32
|
-
this.updateStorageKey();
|
|
33
|
-
this.loadFromStorage();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
Event Handlers
|
|
39
|
-
*/
|
|
40
|
-
handleStorageChange = event => {
|
|
41
|
-
if(event.key === this.storageKey) {
|
|
42
|
-
this.loadFromStorage();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
Private Methods
|
|
48
|
-
*/
|
|
49
|
-
updateStorageKey() {
|
|
50
|
-
this.storageKey = this.id ? `PersistantCollapsible-${this.id}` : '';
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
loadFromStorage() {
|
|
54
|
-
if(this.storageKey) {
|
|
55
|
-
const stored = localStorage.getItem(this.storageKey);
|
|
56
|
-
if(stored !== null) {
|
|
57
|
-
this.opened = stored === 'true';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
saveToStorage() {
|
|
63
|
-
if(this.storageKey) {
|
|
64
|
-
localStorage.setItem(this.storageKey, this.opened.toString());
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
customElements.define('k-p-collapsible', PersistantCollapsible);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|