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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>watchWindowSize - Kempo UI</title>
|
|
8
|
+
<link rel="stylesheet" href="kempo-vars.css" />
|
|
9
|
+
<link rel="stylesheet" href="kempo.min.css" />
|
|
10
|
+
<link rel="stylesheet" href="kempo-hljs.css" />
|
|
11
|
+
<link rel="stylesheet" href="styles.css" />
|
|
12
|
+
<script>window.litDisableBundleWarning = true;</script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<k-import src="/kempo-ui/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"><span class="hljs-keyword">import</span> { watchWindowSize, unwatchWindowSize } <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/watchWindowSize.js'</span>;<br /><br /><span class="hljs-keyword">const</span> handler = <span class="hljs-function">(<span class="hljs-params">width</span>) =></span> {<br /> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Window width:'</span>, width);<br />};<br /><br /><span class="hljs-comment">// Start watching</span><br /><span class="hljs-keyword">const</span> currentWidth = watchWindowSize(handler);<br /><br /><span class="hljs-comment">// Stop watching when done</span><br />unwatchWindowSize(handler);</code></pre>
|
|
37
|
+
|
|
38
|
+
<h3 id="functions"><a href="#functions" class="no-link">Functions</a></h3>
|
|
39
|
+
|
|
40
|
+
<h5><code>watchWindowSize(handler)</code></h5>
|
|
41
|
+
<p>Registers a handler function to be called when the window is resized.</p>
|
|
42
|
+
<ul>
|
|
43
|
+
<li><strong>handler:</strong> Function that receives the new window width</li>
|
|
44
|
+
<li><strong>Returns:</strong> Current window width</li>
|
|
45
|
+
</ul>
|
|
46
|
+
|
|
47
|
+
<h5><code>unwatchWindowSize(handler)</code></h5>
|
|
48
|
+
<p>Unregisters a previously registered handler function.</p>
|
|
49
|
+
<ul>
|
|
50
|
+
<li><strong>handler:</strong> The same function reference that was registered</li>
|
|
51
|
+
</ul>
|
|
52
|
+
|
|
53
|
+
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
54
|
+
|
|
55
|
+
<h4>Responsive Component</h4>
|
|
56
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">import</span> { watchWindowSize, unwatchWindowSize } <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/watchWindowSize.js'</span>;<br /><br /><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ResponsiveComponent</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">LitElement</span> </span>{<br /> <span class="hljs-keyword">constructor</span>() {<br /> <span class="hljs-keyword">super</span>();<br /> <span class="hljs-keyword">this</span>.isMobile = <span class="hljs-literal">false</span>;<br /> <span class="hljs-keyword">this</span>.resizeHandler = <span class="hljs-keyword">this</span>.handleResize.bind(<span class="hljs-keyword">this</span>);<br /> }<br /><br /> connectedCallback() {<br /> <span class="hljs-keyword">super</span>.connectedCallback();<br /> <span class="hljs-keyword">const</span> currentWidth = watchWindowSize(<span class="hljs-keyword">this</span>.resizeHandler);<br /> <span class="hljs-keyword">this</span>.handleResize(currentWidth);<br /> }<br /><br /> disconnectedCallback() {<br /> <span class="hljs-keyword">super</span>.disconnectedCallback();<br /> unwatchWindowSize(<span class="hljs-keyword">this</span>.resizeHandler);<br /> }<br /><br /> handleResize(width) {<br /> <span class="hljs-keyword">this</span>.isMobile = width < <span class="hljs-number">768</span>;<br /> <span class="hljs-keyword">this</span>.requestUpdate();<br /> }<br /><br /> render() {<br /> <span class="hljs-keyword">return</span> html`<span class="xml"><br /> <span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"</span></span></span><span class="hljs-subst">${<span class="hljs-keyword">this</span>.isMobile ? <span class="hljs-string">'mobile'</span> : <span class="hljs-string">'desktop'</span>}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>></span><br /> Content adapts to screen size<br /> <span class="hljs-tag"></<span class="hljs-name">div</span>></span><br /> `</span>;<br /> }<br />}</code></pre>
|
|
57
|
+
|
|
58
|
+
<h4>Multiple Handlers</h4>
|
|
59
|
+
<pre><code class="hljs javascript"><span class="hljs-comment">// Handler for navigation</span><br /><span class="hljs-keyword">const</span> navHandler = <span class="hljs-function">(<span class="hljs-params">width</span>) =></span> {<br /> <span class="hljs-keyword">const</span> nav = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">'.navigation'</span>);<br /> nav.classList.toggle(<span class="hljs-string">'mobile'</span>, width < <span class="hljs-number">1024</span>);<br />};<br /><br /><span class="hljs-comment">// Handler for sidebar</span><br /><span class="hljs-keyword">const</span> sidebarHandler = <span class="hljs-function">(<span class="hljs-params">width</span>) =></span> {<br /> <span class="hljs-keyword">const</span> sidebar = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">'.sidebar'</span>);<br /> sidebar.style.display = width < <span class="hljs-number">768</span> ? <span class="hljs-string">'none'</span> : <span class="hljs-string">'block'</span>;<br />};<br /><br /><span class="hljs-comment">// Both handlers will be called on resize</span><br />watchWindowSize(navHandler);<br />watchWindowSize(sidebarHandler);<br /><br /><span class="hljs-comment">// Clean up when needed</span><br />unwatchWindowSize(navHandler);<br />unwatchWindowSize(sidebarHandler);</code></pre>
|
|
60
|
+
|
|
61
|
+
<h4>Breakpoint Detection</h4>
|
|
62
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> breakpoints = {<br /> <span class="hljs-attr">mobile</span>: <span class="hljs-number">768</span>,<br /> <span class="hljs-attr">tablet</span>: <span class="hljs-number">1024</span>,<br /> <span class="hljs-attr">desktop</span>: <span class="hljs-number">1200</span><br />};<br /><br /><span class="hljs-keyword">const</span> breakpointHandler = <span class="hljs-function">(<span class="hljs-params">width</span>) =></span> {<br /> <span class="hljs-keyword">let</span> currentBreakpoint = <span class="hljs-string">'mobile'</span>;<br /> <br /> <span class="hljs-keyword">if</span> (width >= breakpoints.desktop) {<br /> currentBreakpoint = <span class="hljs-string">'desktop'</span>;<br /> } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (width >= breakpoints.tablet) {<br /> currentBreakpoint = <span class="hljs-string">'tablet'</span>;<br /> }<br /> <br /> <span class="hljs-built_in">document</span>.body.setAttribute(<span class="hljs-string">'data-breakpoint'</span>, currentBreakpoint);<br /> <br /> <span class="hljs-comment">// Dispatch custom event</span><br /> <span class="hljs-built_in">window</span>.dispatchEvent(<span class="hljs-keyword">new</span> CustomEvent(<span class="hljs-string">'breakpointchange'</span>, {<br /> <span class="hljs-attr">detail</span>: { width, <span class="hljs-attr">breakpoint</span>: currentBreakpoint }<br /> }));<br />};<br /><br />watchWindowSize(breakpointHandler);</code></pre>
|
|
63
|
+
|
|
64
|
+
<h4>Performance Benefits</h4>
|
|
65
|
+
<p>The utility automatically debounces resize events, so you don't need to worry about performance:</p>
|
|
66
|
+
<pre><code class="hljs javascript"><span class="hljs-comment">// This handler will only be called after resize events stop</span><br /><span class="hljs-keyword">const</span> expensiveHandler = <span class="hljs-function">(<span class="hljs-params">width</span>) =></span> {<br /> <span class="hljs-comment">// Expensive DOM calculations or API calls</span><br /> recalculateLayout();<br /> updateCharts();<br /> reflow();<br />};<br /><br />watchWindowSize(expensiveHandler); <span class="hljs-comment">// Automatically debounced</span></code></pre>
|
|
67
|
+
|
|
68
|
+
</main>
|
|
69
|
+
<div style="height:33vh"></div>
|
|
70
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
71
|
+
</body>
|
|
72
|
+
</html>
|
package/docs/prod.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Lit based web-component library",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/dustinpoissant/kempo-ui#readme",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"kempo-server": "^1.7.
|
|
28
|
+
"kempo-server": "^1.7.12",
|
|
29
29
|
"kempo-testing-framework": "^1.4.0",
|
|
30
30
|
"terser": "^5.43.1"
|
|
31
31
|
},
|
package/scripts/build.js
CHANGED
|
@@ -99,19 +99,19 @@ const minifiedKempoHljsCSS = kempoHljsCSS.replace(/\s*\{\s*/g, '{').replace(/\s*
|
|
|
99
99
|
console.log('Saving kempo-hljs.css');
|
|
100
100
|
await fs.writeFile('./dist/kempo-hljs.css', minifiedKempoHljsCSS, 'utf-8');
|
|
101
101
|
|
|
102
|
-
console.log('Cleaning docs/src/ directory');
|
|
103
|
-
await emptyDir('./docs/src/');
|
|
102
|
+
console.log('Cleaning docs/kempo-ui/src/ directory');
|
|
103
|
+
await emptyDir('./docs/kempo-ui/src/');
|
|
104
104
|
|
|
105
|
-
console.log('Copying dist/ to docs/');
|
|
106
|
-
await ensureDir('./docs/');
|
|
107
|
-
await copyDir('./dist', './docs/');
|
|
105
|
+
console.log('Copying dist/ to docs/kempo-ui/');
|
|
106
|
+
await ensureDir('./docs/kempo-ui/');
|
|
107
|
+
await copyDir('./dist', './docs/kempo-ui/');
|
|
108
108
|
|
|
109
|
-
console.log('Copying icons/ to docs/icons/');
|
|
110
|
-
await copyDir('./icons', './docs/icons/');
|
|
109
|
+
console.log('Copying icons/ to docs/kempo-ui/icons/');
|
|
110
|
+
await copyDir('./icons', './docs/kempo-ui/icons/');
|
|
111
111
|
|
|
112
112
|
console.log('Copying base kempo.min.css from external package');
|
|
113
113
|
const kempoCssSource = './node_modules/kempo-css/dist/kempo.min.css';
|
|
114
|
-
const kempoCssDest = './docs/kempo.min.css';
|
|
114
|
+
const kempoCssDest = './docs/kempo-ui/kempo.min.css';
|
|
115
115
|
try {
|
|
116
116
|
const kempoCssContent = await fs.readFile(kempoCssSource, 'utf-8');
|
|
117
117
|
await fs.writeFile(kempoCssDest, kempoCssContent, 'utf-8');
|
package/scripts/docs.js
CHANGED
|
@@ -41,6 +41,9 @@ const serverArgs = [
|
|
|
41
41
|
'--port', port.toString(),
|
|
42
42
|
'--config', configFile
|
|
43
43
|
];
|
|
44
|
+
setTimeout(()=>{
|
|
45
|
+
console.log(`\Docs are available at: http://localhost:${port}/kempo-ui/`);
|
|
46
|
+
}, 1000);
|
|
44
47
|
|
|
45
48
|
const serverProcess = spawn('npx', serverArgs, {
|
|
46
49
|
stdio: 'inherit',
|
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
import ShadowComponent from './ShadowComponent.js';
|
|
2
2
|
import { html, css } from '../lit-all.min.js';
|
|
3
|
-
import { boolTrueFalse } from '../utils/propConverters.js';
|
|
3
|
+
import { boolExists, boolTrueFalse } from '../utils/propConverters.js';
|
|
4
4
|
|
|
5
5
|
export default class Accordion extends ShadowComponent {
|
|
6
6
|
/*
|
|
7
7
|
Properties
|
|
8
8
|
*/
|
|
9
|
-
static properties = {
|
|
9
|
+
static properties = {
|
|
10
|
+
multiple: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
reflect: true,
|
|
13
|
+
converter: boolExists
|
|
14
|
+
},
|
|
15
|
+
persistentId: {
|
|
16
|
+
type: String,
|
|
17
|
+
reflect: true,
|
|
18
|
+
attribute: 'persistent-id'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.multiple = false;
|
|
25
|
+
this.persistentId = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback?.();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Lifecycle: Restore persistent state when persistentId changes
|
|
34
|
+
*/
|
|
35
|
+
updated(changedProps) {
|
|
36
|
+
super.updated?.(changedProps);
|
|
37
|
+
if (changedProps.has('persistentId') && this.persistentId && window?.localStorage) {
|
|
38
|
+
const key = `accordion-persistent-id-${this.persistentId}`;
|
|
39
|
+
const value = window.localStorage.getItem(key);
|
|
40
|
+
if (value) {
|
|
41
|
+
const openPanels = value.split(',');
|
|
42
|
+
this.querySelectorAll('k-accordion-panel').forEach(panel => {
|
|
43
|
+
panel.active = openPanels.includes(panel.name);
|
|
44
|
+
const header = this.getHeader(panel.name);
|
|
45
|
+
if (header) header.active = openPanels.includes(panel.name);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
10
50
|
|
|
11
51
|
/*
|
|
12
52
|
Public Methods
|
|
@@ -20,15 +60,19 @@ export default class Accordion extends ShadowComponent {
|
|
|
20
60
|
}
|
|
21
61
|
|
|
22
62
|
openPanel(panelName) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
63
|
+
if (!this.multiple) {
|
|
64
|
+
// Close all other panels (exclusive mode)
|
|
65
|
+
this.querySelectorAll('k-accordion-panel[active]').forEach(panel => {
|
|
66
|
+
if (panel.name !== panelName) {
|
|
67
|
+
panel.active = false;
|
|
68
|
+
const header = this.getHeader(panel.name);
|
|
69
|
+
if (header) header.active = false;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
28
72
|
}
|
|
29
73
|
|
|
30
74
|
const panel = this.getPanel(panelName);
|
|
31
|
-
if(panel) {
|
|
75
|
+
if (panel) {
|
|
32
76
|
panel.active = true;
|
|
33
77
|
panel.transitioning = true;
|
|
34
78
|
setTimeout(() => {
|
|
@@ -36,50 +80,68 @@ export default class Accordion extends ShadowComponent {
|
|
|
36
80
|
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
37
81
|
|
|
38
82
|
const header = this.getHeader(panelName);
|
|
39
|
-
if(header) header.active = true;
|
|
83
|
+
if (header) header.active = true;
|
|
40
84
|
|
|
41
85
|
this.dispatchEvent(new CustomEvent('openpanel', { detail: { panelName } }));
|
|
86
|
+
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
// Save state if persistentId is set
|
|
89
|
+
if (this.persistentId && window?.localStorage) {
|
|
90
|
+
const key = `accordion-persistent-id-${this.persistentId}`;
|
|
91
|
+
const openPanels = Array.from(this.querySelectorAll('k-accordion-panel[active]')).map(p => p.name);
|
|
92
|
+
window.localStorage.setItem(key, openPanels.join(','));
|
|
93
|
+
}
|
|
94
|
+
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
42
95
|
}
|
|
43
96
|
}
|
|
44
97
|
|
|
45
98
|
closePanel(panelName) {
|
|
46
99
|
const panel = this.getPanel(panelName);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
100
|
+
if (panel) {
|
|
101
|
+
panel.active = false;
|
|
102
|
+
panel.transitioning = true;
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
panel.transitioning = false;
|
|
105
|
+
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
53
106
|
|
|
54
|
-
|
|
55
|
-
|
|
107
|
+
const header = this.getHeader(panelName);
|
|
108
|
+
if (header) header.active = false;
|
|
56
109
|
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
110
|
+
this.dispatchEvent(new CustomEvent('closepanel', { detail: { panelName } }));
|
|
60
111
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
this.openPanel(panelName);
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
// Save state if persistentId is set
|
|
114
|
+
if (this.persistentId && window?.localStorage) {
|
|
115
|
+
const key = `accordion-persistent-id-${this.persistentId}`;
|
|
116
|
+
const openPanels = Array.from(this.querySelectorAll('k-accordion-panel[active]')).map(p => p.name);
|
|
117
|
+
window.localStorage.setItem(key, openPanels.join(','));
|
|
68
118
|
}
|
|
69
|
-
|
|
119
|
+
}, parseInt(getComputedStyle(this).getPropertyValue('--animation_ms') || 256));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
togglePanel(panelName) {
|
|
124
|
+
const panel = this.getPanel(panelName);
|
|
125
|
+
if (panel) {
|
|
126
|
+
if (panel.active) {
|
|
127
|
+
this.closePanel(panelName);
|
|
128
|
+
} else {
|
|
129
|
+
this.openPanel(panelName);
|
|
70
130
|
}
|
|
131
|
+
this.dispatchEvent(new CustomEvent('togglepanel', { detail: { panelName } }));
|
|
71
132
|
}
|
|
133
|
+
}
|
|
72
134
|
|
|
73
135
|
/*
|
|
74
136
|
Getters
|
|
75
137
|
*/
|
|
76
138
|
get activeHeader() {
|
|
77
|
-
|
|
78
|
-
|
|
139
|
+
return this.querySelector('k-accordion-header[active="true"]');
|
|
140
|
+
}
|
|
79
141
|
|
|
80
142
|
get activePanel() {
|
|
81
|
-
|
|
82
|
-
|
|
143
|
+
return this.querySelector('k-accordion-panel[active="true"]');
|
|
144
|
+
}
|
|
83
145
|
|
|
84
146
|
/*
|
|
85
147
|
Styles
|
|
@@ -87,29 +149,46 @@ export default class Accordion extends ShadowComponent {
|
|
|
87
149
|
static styles = css`
|
|
88
150
|
:host {
|
|
89
151
|
display: block;
|
|
90
|
-
border: 1px solid var(--c_border);
|
|
152
|
+
border: 1px solid var(--c_border, #ccc);
|
|
91
153
|
border-radius: var(--radius);
|
|
92
154
|
}
|
|
93
155
|
::slotted(k-accordion-header) {
|
|
94
|
-
border-top: 1px solid var(--c_border);
|
|
156
|
+
border-top: 1px solid var(--c_border, #ccc);
|
|
157
|
+
}
|
|
158
|
+
::slotted(k-accordion-header) {
|
|
159
|
+
position: relative;
|
|
160
|
+
}
|
|
161
|
+
::slotted(k-accordion-header)::after {
|
|
162
|
+
content: '';
|
|
163
|
+
display: block;
|
|
164
|
+
position: absolute;
|
|
165
|
+
left: var(--spacer_h, 0.5rem);
|
|
166
|
+
right: var(--spacer_h, 0.5rem);
|
|
167
|
+
bottom: 0;
|
|
168
|
+
height: 0;
|
|
169
|
+
width: calc(100% - var(--spacer, 1rem));
|
|
170
|
+
border-bottom: 1px solid var(--c_border, #ccc);
|
|
171
|
+
opacity: 0;
|
|
172
|
+
transition: opacity var(--animation_ms, 256ms);
|
|
173
|
+
pointer-events: none;
|
|
95
174
|
}
|
|
96
|
-
::slotted(k-accordion-header[active
|
|
97
|
-
|
|
175
|
+
::slotted(k-accordion-header[active])::after {
|
|
176
|
+
opacity: 0.4;
|
|
98
177
|
}
|
|
99
178
|
::slotted(k-accordion-header:first-of-type) {
|
|
100
179
|
border-top: 0;
|
|
101
180
|
}
|
|
102
|
-
::slotted(k-accordion-header:last-of-type:not([active
|
|
181
|
+
::slotted(k-accordion-header:last-of-type:not([active])) {
|
|
103
182
|
border-bottom: 0;
|
|
104
183
|
}
|
|
105
184
|
`;
|
|
106
185
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
186
|
+
/*
|
|
187
|
+
Rendering
|
|
188
|
+
*/
|
|
189
|
+
render() {
|
|
190
|
+
return html`<slot></slot>`;
|
|
191
|
+
}
|
|
113
192
|
}
|
|
114
193
|
|
|
115
194
|
export class AccordionHeader extends ShadowComponent {
|
|
@@ -118,7 +197,7 @@ export class AccordionHeader extends ShadowComponent {
|
|
|
118
197
|
*/
|
|
119
198
|
static properties = {
|
|
120
199
|
forPanel: { type: String, reflect: true, attribute: 'for-panel' },
|
|
121
|
-
active: { type: Boolean, reflect: true, converter:
|
|
200
|
+
active: { type: Boolean, reflect: true, converter: boolExists }
|
|
122
201
|
};
|
|
123
202
|
|
|
124
203
|
constructor() {
|
|
@@ -154,23 +233,32 @@ export class AccordionHeader extends ShadowComponent {
|
|
|
154
233
|
return this.closest('k-accordion');
|
|
155
234
|
}
|
|
156
235
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
236
|
+
|
|
237
|
+
/* Rendering */
|
|
238
|
+
render() {
|
|
239
|
+
return html`
|
|
240
|
+
<slot name="left-icon">
|
|
241
|
+
<k-icon id="icon" name="chevron-right"></k-icon>
|
|
242
|
+
</slot>
|
|
243
|
+
<slot></slot>
|
|
244
|
+
<slot name="right-icon"></slot>
|
|
245
|
+
`;
|
|
246
|
+
}
|
|
160
247
|
static styles = css`
|
|
161
248
|
:host {
|
|
162
249
|
display: block;
|
|
163
250
|
padding: 1rem;
|
|
164
251
|
cursor: pointer;
|
|
165
252
|
}
|
|
253
|
+
#icon {
|
|
254
|
+
will-change: trnasform;
|
|
255
|
+
transition: transform var(--animation_ms, 256ms);
|
|
256
|
+
transform: rotate(0deg);
|
|
257
|
+
}
|
|
258
|
+
:host([active]) #icon {
|
|
259
|
+
transform: rotate(90deg);
|
|
260
|
+
}
|
|
166
261
|
`;
|
|
167
|
-
|
|
168
|
-
/*
|
|
169
|
-
Rendering
|
|
170
|
-
*/
|
|
171
|
-
render() {
|
|
172
|
-
return html`<slot></slot>`;
|
|
173
|
-
}
|
|
174
262
|
}
|
|
175
263
|
|
|
176
264
|
export class AccordionPanel extends ShadowComponent {
|
|
@@ -179,8 +267,8 @@ export class AccordionPanel extends ShadowComponent {
|
|
|
179
267
|
*/
|
|
180
268
|
static properties = {
|
|
181
269
|
name: { type: String, reflect: true },
|
|
182
|
-
active: { type: Boolean, reflect: true, converter:
|
|
183
|
-
transitioning: { type: Boolean, reflect: true, converter:
|
|
270
|
+
active: { type: Boolean, reflect: true, converter: boolExists },
|
|
271
|
+
transitioning: { type: Boolean, reflect: true, converter: boolExists }
|
|
184
272
|
};
|
|
185
273
|
|
|
186
274
|
constructor() {
|
|
@@ -208,7 +296,7 @@ export class AccordionPanel extends ShadowComponent {
|
|
|
208
296
|
overflow: hidden;
|
|
209
297
|
transition: height var(--animation_ms, 256ms) ease-in-out;
|
|
210
298
|
}
|
|
211
|
-
|
|
299
|
+
:host([active]) {
|
|
212
300
|
height: max-content;
|
|
213
301
|
}
|
|
214
302
|
`;
|
package/src/components/Tabs.js
CHANGED
|
@@ -289,9 +289,14 @@ export class Tab extends ShadowComponent {
|
|
|
289
289
|
return this.parentElement?.tagName === 'K-TABS' ? this.parentElement : null;
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
/*
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
/* Rendering */
|
|
293
|
+
render() {
|
|
294
|
+
return html`
|
|
295
|
+
<button id="button" @click=${this.handleClick}>
|
|
296
|
+
<slot></slot>
|
|
297
|
+
</button>
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
295
300
|
static styles = css`
|
|
296
301
|
:host {
|
|
297
302
|
margin-bottom: -1px;
|
|
@@ -313,7 +318,7 @@ export class Tab extends ShadowComponent {
|
|
|
313
318
|
}
|
|
314
319
|
|
|
315
320
|
:host([active]) {
|
|
316
|
-
border-bottom:
|
|
321
|
+
border-bottom: 3px solid var(--c_primary);
|
|
317
322
|
margin-bottom: -1px;
|
|
318
323
|
}
|
|
319
324
|
|
|
@@ -321,17 +326,6 @@ export class Tab extends ShadowComponent {
|
|
|
321
326
|
color: var(--tc_primary);
|
|
322
327
|
}
|
|
323
328
|
`;
|
|
324
|
-
|
|
325
|
-
/*
|
|
326
|
-
Rendering
|
|
327
|
-
*/
|
|
328
|
-
render() {
|
|
329
|
-
return html`
|
|
330
|
-
<button id="button" @click=${this.handleClick}>
|
|
331
|
-
<slot></slot>
|
|
332
|
-
</button>
|
|
333
|
-
`;
|
|
334
|
-
}
|
|
335
329
|
}
|
|
336
330
|
|
|
337
331
|
/*
|
|
@@ -357,8 +351,11 @@ export class TabContent extends ShadowComponent {
|
|
|
357
351
|
}
|
|
358
352
|
|
|
359
353
|
/*
|
|
360
|
-
|
|
354
|
+
Rendering
|
|
361
355
|
*/
|
|
356
|
+
render() {
|
|
357
|
+
return html`<slot></slot>`;
|
|
358
|
+
}
|
|
362
359
|
static styles = css`
|
|
363
360
|
:host {
|
|
364
361
|
display: block;
|
|
@@ -366,6 +363,7 @@ export class TabContent extends ShadowComponent {
|
|
|
366
363
|
max-height: 100%;
|
|
367
364
|
flex: 1 1 auto;
|
|
368
365
|
overflow: auto;
|
|
366
|
+
padding-top: var(--spacer, 1rem);
|
|
369
367
|
}
|
|
370
368
|
|
|
371
369
|
:host([active]) {
|
|
@@ -376,13 +374,6 @@ export class TabContent extends ShadowComponent {
|
|
|
376
374
|
display: none;
|
|
377
375
|
}
|
|
378
376
|
`;
|
|
379
|
-
|
|
380
|
-
/*
|
|
381
|
-
Rendering
|
|
382
|
-
*/
|
|
383
|
-
render() {
|
|
384
|
-
return html`<slot></slot>`;
|
|
385
|
-
}
|
|
386
377
|
}
|
|
387
378
|
|
|
388
379
|
/*
|
package/src/kempo-vars.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Define Kempo Vars Here */
|