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,17 +1,18 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>Tree - Components - Kempo Docs - A Web Components Solution</title>
|
|
7
|
-
<link rel="stylesheet" href="
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
8
|
+
<link rel="stylesheet" href="/kempo-ui/kempo-vars.css" />
|
|
9
|
+
<link rel="stylesheet" href="/kempo-ui/kempo.min.css" />
|
|
10
|
+
<link rel="stylesheet" href="/kempo-ui/kempo-hljs.css" />
|
|
11
|
+
<link rel="stylesheet" href="/kempo-ui/styles.css" />
|
|
10
12
|
<script>window.litDisableBundleWarning = true;</script>
|
|
11
|
-
<script type="module" src="./init.js"></script>
|
|
12
13
|
</head>
|
|
13
14
|
<body>
|
|
14
|
-
<k-import src="
|
|
15
|
+
<k-import src="/kempo-ui/nav.inc.html"></k-import>
|
|
15
16
|
<h1 class="ta-center">Tree</h1>
|
|
16
17
|
<main>
|
|
17
18
|
<details class="b r mb">
|
|
@@ -34,12 +35,12 @@
|
|
|
34
35
|
<p>Create a tree using the <code>k-tree</code> component. Set your data by setting the <code>data</code> property.</p>
|
|
35
36
|
<div class="row -mx mb">
|
|
36
37
|
<div class="col d-span-6 m-span-12 px">
|
|
37
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"myTree"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
38
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"myTree"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo-ui/src/components/Tree.js'</span>;<br /> <span class="hljs-keyword">const</span> tree = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'myTree'</span>);<br /> tree.data = {<br /> <span class="hljs-attr">name</span>: <span class="hljs-string">'John Doe'</span>,<br /> <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>,<br /> <span class="hljs-attr">active</span>: <span class="hljs-literal">true</span>,<br /> <span class="hljs-attr">hobbies</span>: [<span class="hljs-string">'reading'</span>, <span class="hljs-string">'coding'</span>],<br /> <span class="hljs-attr">address</span>: {<br /> <span class="hljs-attr">street</span>: <span class="hljs-string">'123 Main St'</span>,<br /> <span class="hljs-attr">city</span>: <span class="hljs-string">'New York'</span><br /> }<br /> };<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
38
39
|
</div>
|
|
39
40
|
<div class="col d-span-6 m-span-12 px">
|
|
40
41
|
<k-tree id="myTree"></k-tree>
|
|
41
42
|
<script type="module">
|
|
42
|
-
import Tree from '
|
|
43
|
+
import Tree from '/kempo-ui/src/components/Tree.js';
|
|
43
44
|
const tree = document.getElementById('myTree');
|
|
44
45
|
tree.data = {
|
|
45
46
|
name: 'John Doe',
|
|
@@ -59,12 +60,12 @@
|
|
|
59
60
|
<p>Use the <code>depth</code> attribute to control how many levels of branches are open by default. This example shows depth set to <code>2</code>:</p>
|
|
60
61
|
<div class="row -mx mb">
|
|
61
62
|
<div class="col d-span-6 m-span-12 px">
|
|
62
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"depthTree"</span> <span class="hljs-attr">depth</span>=<span class="hljs-string">"2"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
63
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"depthTree"</span> <span class="hljs-attr">depth</span>=<span class="hljs-string">"2"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo-ui/src/components/Tree.js'</span>;<br /> <span class="hljs-keyword">const</span> tree = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'depthTree'</span>);<br /> tree.data = {<br /> <span class="hljs-attr">company</span>: <span class="hljs-string">'Tech Corp'</span>,<br /> <span class="hljs-attr">departments</span>: {<br /> <span class="hljs-attr">engineering</span>: {<br /> <span class="hljs-attr">frontend</span>: [<span class="hljs-string">'Alice'</span>, <span class="hljs-string">'Bob'</span>],<br /> <span class="hljs-attr">backend</span>: [<span class="hljs-string">'Charlie'</span>, <span class="hljs-string">'Diana'</span>]<br /> },<br /> <span class="hljs-attr">sales</span>: {<br /> <span class="hljs-attr">team</span>: [<span class="hljs-string">'Eve'</span>, <span class="hljs-string">'Frank'</span>]<br /> }<br /> }<br /> };<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
63
64
|
</div>
|
|
64
65
|
<div class="col d-span-6 m-span-12 px">
|
|
65
66
|
<k-tree id="depthTree" depth="2"></k-tree>
|
|
66
67
|
<script type="module">
|
|
67
|
-
import Tree from '
|
|
68
|
+
import Tree from '/kempo-ui/src/components/Tree.js';
|
|
68
69
|
const tree = document.getElementById('depthTree');
|
|
69
70
|
tree.data = {
|
|
70
71
|
company: 'Tech Corp',
|
|
@@ -86,13 +87,13 @@
|
|
|
86
87
|
<p>You can define custom leaf types to handle specific data types. Create a class that extends <code>TreeLeaf</code>, implement a <code>detect</code> static method that checks for specific properties, and a <code>render</code> method, then register it with <code>Tree.addLeaf()</code>.</p>
|
|
87
88
|
<div class="row -mx mb">
|
|
88
89
|
<div class="col d-span-6 m-span-12 px">
|
|
89
|
-
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"customTree"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree, { TreeLeaf } <span class="hljs-keyword">from</span> <span class="hljs-string">'
|
|
90
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">k-tree</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"customTree"</span>></span><span class="hljs-tag"></<span class="hljs-name">k-tree</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span>></span><span class="javascript"><br /> <span class="hljs-keyword">import</span> Tree, { TreeLeaf } <span class="hljs-keyword">from</span> <span class="hljs-string">'/kempo-ui/src/components/Tree.js'</span>;<br /> <span class="hljs-keyword">import</span> { html } <span class="hljs-keyword">from</span> <span class="hljs-string">'../src/lit-all.min.js'</span>;<br /><br /> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DateLeaf</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">TreeLeaf</span> </span>{<br /> render(){<br /> <span class="hljs-keyword">const</span> { month, day, year } = <span class="hljs-keyword">this</span>.value;<br /> <span class="hljs-keyword">return</span> html`<span class="xml"><span class="hljs-tag"><<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"tc-warning"</span>></span>📅 </span><span class="hljs-subst">${month}</span><span class="xml">/</span><span class="hljs-subst">${day}</span><span class="xml">/</span><span class="hljs-subst">${year}</span><span class="xml"><span class="hljs-tag"></<span class="hljs-name">span</span>></span>`</span>;<br /> }<br /><br /> <span class="hljs-keyword">static</span> detect = <span class="hljs-function"><span class="hljs-params">value</span> =></span> {<br /> <span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> value === <span class="hljs-string">'object'</span> <br /> && value !== <span class="hljs-literal">null</span><br /> && <span class="hljs-string">'month'</span> <span class="hljs-keyword">in</span> value <br /> && <span class="hljs-string">'day'</span> <span class="hljs-keyword">in</span> value <br /> && <span class="hljs-string">'year'</span> <span class="hljs-keyword">in</span> value;<br /> };<br /> }<br /><br /> Tree.addLeaf(DateLeaf);<br /><br /> <span class="hljs-keyword">const</span> tree = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'customTree'</span>);<br /> tree.data = {<br /> <span class="hljs-attr">event</span>: <span class="hljs-string">'Tech Conference 2025'</span>,<br /> <span class="hljs-attr">startDate</span>: { <span class="hljs-attr">month</span>: <span class="hljs-number">10</span>, <span class="hljs-attr">day</span>: <span class="hljs-number">15</span>, <span class="hljs-attr">year</span>: <span class="hljs-number">2025</span> },<br /> <span class="hljs-attr">endDate</span>: { <span class="hljs-attr">month</span>: <span class="hljs-number">10</span>, <span class="hljs-attr">day</span>: <span class="hljs-number">17</span>, <span class="hljs-attr">year</span>: <span class="hljs-number">2025</span> },<br /> <span class="hljs-attr">location</span>: <span class="hljs-string">'San Francisco'</span>,<br /> <span class="hljs-attr">attendees</span>: <span class="hljs-number">250</span><br /> };<br /></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
90
91
|
</div>
|
|
91
92
|
<div class="col d-span-6 m-span-12 px">
|
|
92
93
|
<k-tree id="customTree"></k-tree>
|
|
93
94
|
<script type="module">
|
|
94
|
-
import Tree, { TreeLeaf } from '
|
|
95
|
-
import { html } from '
|
|
95
|
+
import Tree, { TreeLeaf } from '/kempo-ui/src/components/Tree.js';
|
|
96
|
+
import { html } from '/kempo-ui/src/lit-all.min.js';
|
|
96
97
|
|
|
97
98
|
class DateLeaf extends TreeLeaf {
|
|
98
99
|
render(){
|
|
@@ -171,7 +172,8 @@
|
|
|
171
172
|
|
|
172
173
|
</main>
|
|
173
174
|
<div style="height:33vh"></div>
|
|
174
|
-
<script type="module" src="
|
|
175
|
-
<script type="module" src="
|
|
175
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
176
|
+
<script type="module" src="/kempo-ui/src/components/Card.js"></script>
|
|
177
|
+
<script type="module" src="/kempo-ui/src/components/Tree.js"></script>
|
|
176
178
|
</body>
|
|
177
179
|
</html>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>Kempo UI Documentation</title>
|
|
7
|
-
<link rel="stylesheet" href="
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
8
|
+
<link rel="stylesheet" href="kempo.min.css">
|
|
9
|
+
<link rel="stylesheet" href="kempo-vars.css">
|
|
10
|
+
<link rel="stylesheet" href="styles.css">
|
|
10
11
|
<script>window.litDisableBundleWarning = true;</script>
|
|
11
|
-
<script type="module" src="./init.js"></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
|
-
<k-import src="
|
|
14
|
+
<k-import src="nav.inc.html"></k-import>
|
|
15
15
|
<main>
|
|
16
16
|
<h1>Kempo UI</h1>
|
|
17
|
-
<p>
|
|
17
|
+
<p>A lit-based web component library.</p>
|
|
18
18
|
|
|
19
19
|
<h2>Components</h2>
|
|
20
20
|
<div class="row -mx">
|
|
@@ -30,18 +30,6 @@
|
|
|
30
30
|
<p class="tc-muted">Container component with optional labels and border styling.</p>
|
|
31
31
|
</a>
|
|
32
32
|
</div>
|
|
33
|
-
<div class="span-12 t-span-6 d-span-4 px">
|
|
34
|
-
<a href="./components/collapsible.html" class="card mb no-link d-b">
|
|
35
|
-
<h3 class="tc-primary">Collapsible</h3>
|
|
36
|
-
<p class="tc-muted">Toggle visibility of content with smooth expand/collapse transitions.</p>
|
|
37
|
-
</a>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="span-12 t-span-6 d-span-4 px">
|
|
40
|
-
<a href="./components/persistant-collapsible.html" class="card mb no-link d-b">
|
|
41
|
-
<h3 class="tc-primary">PersistantCollapsible</h3>
|
|
42
|
-
<p class="tc-muted">Collapsible with localStorage to remember state across sessions.</p>
|
|
43
|
-
</a>
|
|
44
|
-
</div>
|
|
45
33
|
<div class="span-12 t-span-6 d-span-4 px">
|
|
46
34
|
<a href="./components/content-slider.html" class="card mb no-link d-b">
|
|
47
35
|
<h3 class="tc-primary">Content Slider</h3>
|
|
@@ -221,5 +209,6 @@
|
|
|
221
209
|
</div>
|
|
222
210
|
<div style="height:33vh"></div>
|
|
223
211
|
</main>
|
|
212
|
+
<script type="module" src="src/components/Import.js"></script>
|
|
224
213
|
</body>
|
|
225
214
|
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Define Kempo Vars Here */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<nav
|
|
2
|
+
class="d-f bg-primary fixed"
|
|
3
|
+
>
|
|
4
|
+
<button
|
|
5
|
+
id="toggleNavSideMenu"
|
|
6
|
+
class="link"
|
|
7
|
+
>
|
|
8
|
+
<k-icon name="menu"></k-icon>
|
|
9
|
+
</button>
|
|
10
|
+
<a href="/kempo-ui/">Home</a>
|
|
11
|
+
<div class="flex"></div>
|
|
12
|
+
<k-theme-switcher></k-theme-switcher>
|
|
13
|
+
</nav>
|
|
14
|
+
<div style="width: 100%; height: 4rem;"></div>
|
|
15
|
+
<k-side-menu
|
|
16
|
+
id="navSideMenu"
|
|
17
|
+
>
|
|
18
|
+
<h1>Kempo Docs</h1>
|
|
19
|
+
<menu>
|
|
20
|
+
<a href="/kempo-ui/" class="h5 pl0 mb">Home</a>
|
|
21
|
+
<div class="pl mb">
|
|
22
|
+
<h3>Components</h3>
|
|
23
|
+
<a href="/kempo-ui/components/accordion.html">Accordion</a>
|
|
24
|
+
<a href="/kempo-ui/components/card.html">Card</a>
|
|
25
|
+
<a href="/kempo-ui/components/content-slider.html">Content Slider</a>
|
|
26
|
+
<a href="/kempo-ui/components/dialog.html">Dialog</a>
|
|
27
|
+
<a href="/kempo-ui/components/focus-capture.html">FocusCapture</a>
|
|
28
|
+
<a href="/kempo-ui/components/icon.html">Icon</a>
|
|
29
|
+
<a href="/kempo-ui/components/import.html">Import</a>
|
|
30
|
+
<a href="/kempo-ui/components/photo-viewer.html">Photo Viewer</a>
|
|
31
|
+
<a href="/kempo-ui/components/resize.html">Resize</a>
|
|
32
|
+
<a href="/kempo-ui/components/show-more.html">Show More</a>
|
|
33
|
+
<a href="/kempo-ui/components/side-menu.html">Side Menu</a>
|
|
34
|
+
<a href="/kempo-ui/components/sortable.html">Sortable</a>
|
|
35
|
+
<a href="/kempo-ui/components/split.html">Split</a>
|
|
36
|
+
<a href="/kempo-ui/components/table.html">Table</a>
|
|
37
|
+
<a href="/kempo-ui/components/tabs.html">Tabs</a>
|
|
38
|
+
<a href="/kempo-ui/components/tags.html">Tags</a>
|
|
39
|
+
<a href="/kempo-ui/components/toast.html">Toast</a>
|
|
40
|
+
<a href="/kempo-ui/components/theme-switcher.html">Theme Switcher</a>
|
|
41
|
+
<a href="/kempo-ui/components/timestamp.html">Timestamp</a>
|
|
42
|
+
<a href="/kempo-ui/components/toggle.html">Toggle</a>
|
|
43
|
+
<a href="/kempo-ui/components/tree.html">Tree</a>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<h5 class="mb0">Base Components</h5>
|
|
47
|
+
<div class="pl mb">
|
|
48
|
+
<a href="/kempo-ui/components/shadow-component.html">Shadow Component</a>
|
|
49
|
+
<a href="/kempo-ui/components/light-component.html">Light Component</a>
|
|
50
|
+
<a href="/kempo-ui/components/hybrid-component.html">Hybrid Component</a>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<h5 class="mb0">Utils</h5>
|
|
54
|
+
<div class="pl mb">
|
|
55
|
+
<a href="/kempo-ui/utils/debounce.html">debounce</a>
|
|
56
|
+
<a href="/kempo-ui/utils/drag.html">drag</a>
|
|
57
|
+
<a href="/kempo-ui/utils/formatTimestamp.html">formatTimestamp</a>
|
|
58
|
+
<a href="/kempo-ui/utils/propConverters.html">propConverters</a>
|
|
59
|
+
<a href="/kempo-ui/utils/toTitleCase.html">toTitleCase</a>
|
|
60
|
+
<a href="/kempo-ui/utils/watchWindowSize.html">watchWindowSize</a>
|
|
61
|
+
</div>
|
|
62
|
+
</menu>
|
|
63
|
+
</k-side-menu>
|
|
64
|
+
<script src="/kempo-ui/src/components/SideMenu.js" type="module"></script>
|
|
65
|
+
<script src="/kempo-ui/src/components/Icon.js" type="module"></script>
|
|
66
|
+
<script src="/kempo-ui/src/components/ThemeSwitcher.js" type="module"></script>
|
|
67
|
+
<script src="/kempo-ui/nav.inc.js" type="module"></script>
|
|
@@ -0,0 +1,56 @@
|
|
|
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>debounce - 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>debounce</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="#parameters">Parameters</a><br />
|
|
27
|
+
<a href="#examples">Examples</a><br />
|
|
28
|
+
</div>
|
|
29
|
+
</details>
|
|
30
|
+
|
|
31
|
+
<h3>Description</h3>
|
|
32
|
+
<p>The <code>debounce</code> utility function limits the rate at which a function can be executed. It delays the execution of a function until after a specified timeout has passed since the last time it was invoked.</p>
|
|
33
|
+
|
|
34
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
35
|
+
<p>Import and use the debounce function to limit function execution frequency:</p>
|
|
36
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">import</span> debounce <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/debounce.js'</span>;<br /><br /><span class="hljs-keyword">const</span> handleSearch = debounce(<span class="hljs-function">(<span class="hljs-params">query</span>) =></span> {<br /> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Searching for:'</span>, query);<br />}, <span class="hljs-number">300</span>);<br /><br /><span class="hljs-comment">// Will only execute after 300ms of no calls</span><br />handleSearch(<span class="hljs-string">'test'</span>);</code></pre>
|
|
37
|
+
|
|
38
|
+
<h3 id="parameters"><a href="#parameters" class="no-link">Parameters</a></h3>
|
|
39
|
+
<h5><code>func<i>: Function</i></code></h5>
|
|
40
|
+
<p>The function to debounce.</p>
|
|
41
|
+
<h5><code>timeout<i>: number</i></code> (optional)</h5>
|
|
42
|
+
<p>The number of milliseconds to delay execution. Defaults to 300ms.</p>
|
|
43
|
+
|
|
44
|
+
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
45
|
+
|
|
46
|
+
<h4>Search Input Debouncing</h4>
|
|
47
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> debouncedSearch = debounce(<span class="hljs-function">(<span class="hljs-params">searchTerm</span>) =></span> {<br /> <span class="hljs-comment">// API call or expensive search operation</span><br /> performSearch(searchTerm);<br />}, <span class="hljs-number">500</span>);<br /><br />searchInput.addEventListener(<span class="hljs-string">'input'</span>, (e) => {<br /> debouncedSearch(e.target.value);<br />});</code></pre>
|
|
48
|
+
|
|
49
|
+
<h4>Window Resize Handler</h4>
|
|
50
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> debouncedResize = debounce(<span class="hljs-function"><span class="hljs-params">()</span> =></span> {<br /> <span class="hljs-comment">// Expensive layout calculations</span><br /> recalculateLayout();<br />}, <span class="hljs-number">250</span>);<br /><br /><span class="hljs-built_in">window</span>.addEventListener(<span class="hljs-string">'resize'</span>, debouncedResize);</code></pre>
|
|
51
|
+
|
|
52
|
+
</main>
|
|
53
|
+
<div style="height:33vh"></div>
|
|
54
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>drag - Kempo UI</title>
|
|
7
|
-
<link rel="stylesheet" href="
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
10
|
-
<link rel="stylesheet" href="
|
|
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" />
|
|
11
12
|
<script>window.litDisableBundleWarning = true;</script>
|
|
12
|
-
<script type="module" src="./init.js"></script>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
|
-
<k-import src="
|
|
15
|
+
<k-import src="/kempo-ui/nav.inc.html"></k-import>
|
|
16
16
|
<main>
|
|
17
17
|
<h1>drag</h1>
|
|
18
18
|
|
|
@@ -61,17 +61,7 @@
|
|
|
61
61
|
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
62
62
|
|
|
63
63
|
<h4>Draggable Element</h4>
|
|
64
|
-
<pre><code class="hljs javascript">const box = document
|
|
65
|
-
let position = { x: 0, y: 0 };
|
|
66
|
-
|
|
67
|
-
drag({
|
|
68
|
-
element: box,
|
|
69
|
-
callback: (diff) => {
|
|
70
|
-
position.x += diff.x;
|
|
71
|
-
position.y += diff.y;
|
|
72
|
-
box.style.transform = `translate(${position.x}px, ${position.y}px)`;
|
|
73
|
-
}
|
|
74
|
-
});</code></pre>
|
|
64
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> box = <span class="hljs-built_in">document</span>.querySelector(<span class="hljs-string">'.box'</span>);<br /><span class="hljs-keyword">let</span> position = { <span class="hljs-attr">x</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">y</span>: <span class="hljs-number">0</span> };<br /><br />drag({<br /> <span class="hljs-attr">element</span>: box,<br /> <span class="hljs-attr">callback</span>: <span class="hljs-function">(<span class="hljs-params">diff</span>) =></span> {<br /> position.x += diff.x;<br /> position.y += diff.y;<br /> box.style.transform = <span class="hljs-string">`translate(<span class="hljs-subst">${position.x}</span>px, <span class="hljs-subst">${position.y}</span>px)`</span>;<br /> }<br />});</code></pre>
|
|
75
65
|
|
|
76
66
|
<h4>Resize Handle</h4>
|
|
77
67
|
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> resizeHandle = <span class="hljs-built_in">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'.resize-handle'</span>);<br /><span class="hljs-keyword">const</span> panel = <span class="hljs-built_in">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'.panel'</span>);<br /><br /><span class="hljs-title function_">drag</span>({<br /> <span class="hljs-attr">element</span>: resizeHandle,<br /> <span class="hljs-attr">preventScroll</span>: <span class="hljs-literal">true</span>,<br /> <span class="hljs-attr">callback</span>: <span class="hljs-function">(<span class="hljs-params">diff</span>) =></span> {<br /> <span class="hljs-keyword">const</span> newWidth = panel.offsetWidth + diff.x;<br /> panel.style.width = <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">max</span>(<span class="hljs-number">100</span>, newWidth) + <span class="hljs-string">'px'</span>;<br /> },<br /> <span class="hljs-attr">startCallback</span>: <span class="hljs-function">() =></span> {<br /> panel.classList.<span class="hljs-title function_">add</span>(<span class="hljs-string">'resizing'</span>);<br /> },<br /> <span class="hljs-attr">endCallback</span>: <span class="hljs-function">() =></span> {<br /> panel.classList.<span class="hljs-title function_">remove</span>(<span class="hljs-string">'resizing'</span>);<br /> }<br />});</code></pre>
|
|
@@ -81,5 +71,6 @@ drag({
|
|
|
81
71
|
|
|
82
72
|
</main>
|
|
83
73
|
<div style="height:33vh"></div>
|
|
74
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
84
75
|
</body>
|
|
85
76
|
</html>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>formatTimestamp - Kempo UI</title>
|
|
7
|
-
<link rel="stylesheet" href="
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
10
|
-
<link rel="stylesheet" href="
|
|
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" />
|
|
11
12
|
<script>window.litDisableBundleWarning = true;</script>
|
|
12
|
-
<script type="module" src="./init.js"></script>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
|
-
<k-import src="
|
|
15
|
+
<k-import src="/kempo-ui/nav.inc.html"></k-import>
|
|
16
16
|
<main>
|
|
17
17
|
<h1>formatTimestamp</h1>
|
|
18
18
|
|
|
@@ -34,11 +34,7 @@
|
|
|
34
34
|
|
|
35
35
|
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
36
36
|
<p>Import and use the formatTimestamp function to format dates:</p>
|
|
37
|
-
<pre><code class="hljs javascript">import formatTimestamp from './utils/formatTimestamp.js';
|
|
38
|
-
|
|
39
|
-
const timestamp = Date.now();
|
|
40
|
-
const formatted = formatTimestamp(timestamp, 'YYYY-MM-DD');
|
|
41
|
-
console.log(formatted); // "2025-09-19"</code></pre>
|
|
37
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">import</span> formatTimestamp <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/formatTimestamp.js'</span>;<br /><br /><span class="hljs-keyword">const</span> timestamp = <span class="hljs-built_in">Date</span>.now();<br /><span class="hljs-keyword">const</span> formatted = formatTimestamp(timestamp, <span class="hljs-string">'YYYY-MM-DD'</span>);<br /><span class="hljs-built_in">console</span>.log(formatted); <span class="hljs-comment">// "2025-09-19"</span></code></pre>
|
|
42
38
|
|
|
43
39
|
<h3 id="parameters"><a href="#parameters" class="no-link">Parameters</a></h3>
|
|
44
40
|
<h5><code>timestamp<i>: number|string</i></code></h5>
|
|
@@ -79,32 +75,19 @@ console.log(formatted); // "2025-09-19"</code></pre>
|
|
|
79
75
|
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
80
76
|
|
|
81
77
|
<h4>Date Formats</h4>
|
|
82
|
-
<pre><code class="hljs javascript">const timestamp = 1633024800000;
|
|
83
|
-
|
|
84
|
-
formatTimestamp(timestamp, 'YYYY-MM-DD'); // "2021-10-01"
|
|
85
|
-
formatTimestamp(timestamp, 'MM/DD/YYYY'); // "10/01/2021"
|
|
86
|
-
formatTimestamp(timestamp, 'DD-MM-YY'); // "01-10-21"</code></pre>
|
|
78
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> timestamp = <span class="hljs-number">1633024800000</span>;<br /><br />formatTimestamp(timestamp, <span class="hljs-string">'YYYY-MM-DD'</span>); <span class="hljs-comment">// "2021-10-01"</span><br />formatTimestamp(timestamp, <span class="hljs-string">'MM/DD/YYYY'</span>); <span class="hljs-comment">// "10/01/2021"</span><br />formatTimestamp(timestamp, <span class="hljs-string">'DD-MM-YY'</span>); <span class="hljs-comment">// "01-10-21"</span></code></pre>
|
|
87
79
|
|
|
88
80
|
<h4>Time Formats</h4>
|
|
89
|
-
<pre><code class="hljs javascript">formatTimestamp(timestamp, 'hh:mm:ss');
|
|
90
|
-
formatTimestamp(timestamp, 'h:mm'); // "0:00"
|
|
91
|
-
formatTimestamp(timestamp, 'hh:mm:ss.iii'); // "00:00:00.000"</code></pre>
|
|
81
|
+
<pre><code class="hljs javascript">formatTimestamp(timestamp, <span class="hljs-string">'hh:mm:ss'</span>); <span class="hljs-comment">// "00:00:00"</span><br />formatTimestamp(timestamp, <span class="hljs-string">'h:mm'</span>); <span class="hljs-comment">// "0:00"</span><br />formatTimestamp(timestamp, <span class="hljs-string">'hh:mm:ss.iii'</span>); <span class="hljs-comment">// "00:00:00.000"</span></code></pre>
|
|
92
82
|
|
|
93
83
|
<h4>Combined Formats</h4>
|
|
94
|
-
<pre><code class="hljs javascript">formatTimestamp(timestamp, 'YYYY-MM-DD hh:mm:ss');
|
|
95
|
-
// "2021-10-01 00:00:00"
|
|
96
|
-
|
|
97
|
-
formatTimestamp(timestamp, 'MM/DD/YY at h:mm');
|
|
98
|
-
// "10/01/21 at 0:00"</code></pre>
|
|
84
|
+
<pre><code class="hljs javascript">formatTimestamp(timestamp, <span class="hljs-string">'YYYY-MM-DD hh:mm:ss'</span>); <br /><span class="hljs-comment">// "2021-10-01 00:00:00"</span><br /><br />formatTimestamp(timestamp, <span class="hljs-string">'MM/DD/YY at h:mm'</span>);<br /><span class="hljs-comment">// "10/01/21 at 0:00"</span></code></pre>
|
|
99
85
|
|
|
100
86
|
<h4>Locale Formatting</h4>
|
|
101
|
-
<pre><code class="hljs javascript">// Uses browser locale when no format specified
|
|
102
|
-
formatTimestamp(timestamp); // "10/1/2021, 12:00:00 AM"
|
|
103
|
-
|
|
104
|
-
// Force specific locale
|
|
105
|
-
formatTimestamp(timestamp, null, 'de-DE'); // German formatting</code></pre>
|
|
87
|
+
<pre><code class="hljs javascript"><span class="hljs-comment">// Uses browser locale when no format specified</span><br />formatTimestamp(timestamp); <span class="hljs-comment">// "10/1/2021, 12:00:00 AM"</span><br /><br /><span class="hljs-comment">// Force specific locale</span><br />formatTimestamp(timestamp, <span class="hljs-literal">null</span>, <span class="hljs-string">'de-DE'</span>); <span class="hljs-comment">// German formatting</span></code></pre>
|
|
106
88
|
|
|
107
89
|
</main>
|
|
108
90
|
<div style="height:33vh"></div>
|
|
91
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
109
92
|
</body>
|
|
110
93
|
</html>
|
|
@@ -0,0 +1,90 @@
|
|
|
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>propConverters - 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>propConverters</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="#boolTrueFalse">boolTrueFalse</a><br />
|
|
27
|
+
<a href="#boolExists">boolExists</a><br />
|
|
28
|
+
<a href="#examples">Examples</a><br />
|
|
29
|
+
</div>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
<h3>Description</h3>
|
|
33
|
+
<p>The <code>propConverters</code> module provides Lit Element property converters for handling boolean attributes in web components. These converters manage the conversion between JavaScript boolean values and HTML attribute strings.</p>
|
|
34
|
+
|
|
35
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
36
|
+
<p>Import and use the converters in your Lit Element component properties:</p>
|
|
37
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">import</span> { boolTrueFalse, boolExists } <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/propConverters.js'</span>;<br /><br /><span class="hljs-keyword">static</span> properties = {<br /> <span class="hljs-attr">enabled</span>: { <span class="hljs-attr">type</span>: <span class="hljs-built_in">Boolean</span>, <span class="hljs-attr">reflect</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">converter</span>: boolTrueFalse },<br /> <span class="hljs-attr">visible</span>: { <span class="hljs-attr">type</span>: <span class="hljs-built_in">Boolean</span>, <span class="hljs-attr">reflect</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">converter</span>: boolExists }<br />};</code></pre>
|
|
38
|
+
|
|
39
|
+
<h3 id="boolTrueFalse"><a href="#boolTrueFalse" class="no-link">boolTrueFalse</a></h3>
|
|
40
|
+
<p>Converts between boolean values and explicit "true"/"false" string attributes.</p>
|
|
41
|
+
|
|
42
|
+
<h4>Behavior</h4>
|
|
43
|
+
<ul>
|
|
44
|
+
<li><strong>fromAttribute:</strong> "true" → true, "false" → false, null → undefined</li>
|
|
45
|
+
<li><strong>toAttribute:</strong> true → "true", false → "false"</li>
|
|
46
|
+
</ul>
|
|
47
|
+
|
|
48
|
+
<h4>HTML Usage</h4>
|
|
49
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">enabled</span>=<span class="hljs-string">"true"</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span><br /><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">enabled</span>=<span class="hljs-string">"false"</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span></code></pre>
|
|
50
|
+
|
|
51
|
+
<h3 id="boolExists"><a href="#boolExists" class="no-link">boolExists</a></h3>
|
|
52
|
+
<p>Converts between boolean values and attribute presence/absence.</p>
|
|
53
|
+
|
|
54
|
+
<h4>Behavior</h4>
|
|
55
|
+
<ul>
|
|
56
|
+
<li><strong>fromAttribute:</strong> attribute present → true, attribute absent → false</li>
|
|
57
|
+
<li><strong>toAttribute:</strong> true → "", false → null (removes attribute)</li>
|
|
58
|
+
</ul>
|
|
59
|
+
|
|
60
|
+
<h4>HTML Usage</h4>
|
|
61
|
+
<pre><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">visible</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span> <span class="hljs-comment"><!-- visible = true --></span><br /><span class="hljs-tag"><<span class="hljs-name">my-component</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span> <span class="hljs-comment"><!-- visible = false --></span></code></pre>
|
|
62
|
+
|
|
63
|
+
<h3 id="examples"><a href="#examples" class="no-link">Examples</a></h3>
|
|
64
|
+
|
|
65
|
+
<h4>Component with Both Converters</h4>
|
|
66
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">import</span> { LitElement, html } <span class="hljs-keyword">from</span> <span class="hljs-string">'lit'</span>;<br /><span class="hljs-keyword">import</span> { boolTrueFalse, boolExists } <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils/propConverters.js'</span>;<br /><br /><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyComponent</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">LitElement</span> </span>{<br /> <span class="hljs-keyword">static</span> properties = {<br /> <span class="hljs-attr">autoplay</span>: { <span class="hljs-attr">type</span>: <span class="hljs-built_in">Boolean</span>, <span class="hljs-attr">reflect</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">converter</span>: boolTrueFalse },<br /> <span class="hljs-attr">hidden</span>: { <span class="hljs-attr">type</span>: <span class="hljs-built_in">Boolean</span>, <span class="hljs-attr">reflect</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">converter</span>: boolExists },<br /> <span class="hljs-attr">loop</span>: { <span class="hljs-attr">type</span>: <span class="hljs-built_in">Boolean</span>, <span class="hljs-attr">reflect</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">converter</span>: boolTrueFalse }<br /> };<br /><br /> <span class="hljs-keyword">constructor</span>() {<br /> <span class="hljs-keyword">super</span>();<br /> <span class="hljs-keyword">this</span>.autoplay = <span class="hljs-literal">false</span>;<br /> <span class="hljs-keyword">this</span>.hidden = <span class="hljs-literal">false</span>;<br /> <span class="hljs-keyword">this</span>.loop = <span class="hljs-literal">false</span>;<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">hidden</span>=<span class="hljs-string">"</span></span></span><span class="hljs-subst">${<span class="hljs-keyword">this</span>.hidden}</span><span class="xml"><span class="hljs-tag"><span class="hljs-string">"</span>></span><br /> Content </span><span class="hljs-subst">${<span class="hljs-keyword">this</span>.autoplay ? <span class="hljs-string">'with'</span> : <span class="hljs-string">'without'</span>}</span><span class="xml"> autoplay<br /> </span><span class="hljs-subst">${<span class="hljs-keyword">this</span>.loop ? <span class="hljs-string">'(looping)'</span> : <span class="hljs-string">''</span>}</span><span class="xml"><br /> <span class="hljs-tag"></<span class="hljs-name">div</span>></span><br /> `</span>;<br /> }<br />}</code></pre>
|
|
67
|
+
|
|
68
|
+
<h4>HTML Usage Examples</h4>
|
|
69
|
+
<pre><code class="hljs xml"><span class="hljs-comment"><!-- Using boolTrueFalse converter --></span><br /><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">autoplay</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">loop</span>=<span class="hljs-string">"false"</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span><br /><br /><span class="hljs-comment"><!-- Using boolExists converter --></span><br /><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">hidden</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span><br /><br /><span class="hljs-comment"><!-- Combined usage --></span><br /><span class="hljs-tag"><<span class="hljs-name">my-component</span> <span class="hljs-attr">autoplay</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">loop</span>=<span class="hljs-string">"true"</span> <span class="hljs-attr">hidden</span>></span><span class="hljs-tag"></<span class="hljs-name">my-component</span>></span></code></pre>
|
|
70
|
+
|
|
71
|
+
<h4>When to Use Each Converter</h4>
|
|
72
|
+
<p><strong>Use boolTrueFalse when:</strong></p>
|
|
73
|
+
<ul>
|
|
74
|
+
<li>You need explicit true/false values in HTML</li>
|
|
75
|
+
<li>The attribute value is important for clarity</li>
|
|
76
|
+
<li>Working with form controls or interactive elements</li>
|
|
77
|
+
</ul>
|
|
78
|
+
|
|
79
|
+
<p><strong>Use boolExists when:</strong></p>
|
|
80
|
+
<ul>
|
|
81
|
+
<li>Following HTML standards (like hidden, disabled attributes)</li>
|
|
82
|
+
<li>The presence of the attribute is what matters</li>
|
|
83
|
+
<li>Creating more semantic HTML</li>
|
|
84
|
+
</ul>
|
|
85
|
+
|
|
86
|
+
</main>
|
|
87
|
+
<div style="height:33vh"></div>
|
|
88
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
89
|
+
</body>
|
|
90
|
+
</html>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
+
<base href="/kempo-ui/">
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>toTitleCase - Kempo UI</title>
|
|
7
|
-
<link rel="stylesheet" href="
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
10
|
-
<link rel="stylesheet" href="
|
|
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" />
|
|
11
12
|
<script>window.litDisableBundleWarning = true;</script>
|
|
12
|
-
<script type="module" src="./init.js"></script>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
|
-
<k-import src="
|
|
15
|
+
<k-import src="/kempo-ui/nav.inc.html"></k-import>
|
|
16
16
|
<main>
|
|
17
17
|
<h1>toTitleCase</h1>
|
|
18
18
|
|
|
@@ -63,5 +63,6 @@
|
|
|
63
63
|
|
|
64
64
|
</main>
|
|
65
65
|
<div style="height:33vh"></div>
|
|
66
|
+
<script type="module" src="/kempo-ui/src/components/Import.js"></script>
|
|
66
67
|
</body>
|
|
67
68
|
</html>
|