kempo-ui 0.3.14 → 0.3.16
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/components/Combobox.js +97 -0
- package/dist/components/Option.js +1 -0
- package/dist/components/ThemeSwitcher.js +77 -14
- package/docs/components/accordion.html +282 -94
- package/docs/components/aside.html +282 -94
- package/docs/components/card.html +282 -94
- package/docs/components/code-editor.html +282 -94
- package/docs/components/color-picker.html +282 -94
- package/docs/components/combobox.html +798 -0
- package/docs/components/content-slider.html +282 -94
- package/docs/components/context.html +282 -94
- package/docs/components/dialog.html +282 -94
- package/docs/components/dropdown.html +282 -94
- package/docs/components/filter-list.html +282 -94
- package/docs/components/focus-capture.html +282 -94
- package/docs/components/html-editor.html +282 -94
- package/docs/components/hybrid-component.html +282 -94
- package/docs/components/icon.html +282 -94
- package/docs/components/import.html +282 -94
- package/docs/components/light-component.html +282 -94
- package/docs/components/nav-spacer.html +282 -94
- package/docs/components/nav.html +282 -94
- package/docs/components/photo-viewer.html +282 -94
- package/docs/components/resize.html +282 -94
- package/docs/components/shadow-component.html +282 -94
- package/docs/components/show-more.html +282 -94
- package/docs/components/sortable.html +282 -94
- package/docs/components/spinner.html +282 -94
- package/docs/components/split.html +282 -94
- package/docs/components/table.html +282 -94
- package/docs/components/tableControls.html +282 -94
- package/docs/components/tableCustomFields.html +282 -94
- package/docs/components/tableFetchRecords.html +282 -94
- package/docs/components/tableFieldSortHide.html +282 -94
- package/docs/components/tablePagination.html +282 -94
- package/docs/components/tablePlaceholder.html +282 -94
- package/docs/components/tableRecordEditing.html +282 -94
- package/docs/components/tableRecordFiltering.html +282 -94
- package/docs/components/tableRecordHiding.html +282 -94
- package/docs/components/tableRecordSearching.html +282 -94
- package/docs/components/tableRecordSelection.html +282 -94
- package/docs/components/tableRowControls.html +282 -94
- package/docs/components/tableServerSync.html +282 -94
- package/docs/components/tableSorting.html +282 -94
- package/docs/components/tabs.html +282 -94
- package/docs/components/tags.html +282 -94
- package/docs/components/theme-select.html +282 -94
- package/docs/components/theme-switcher-aside.html +47 -0
- package/docs/components/theme-switcher.html +441 -101
- package/docs/components/timestamp.html +282 -94
- package/docs/components/toast.html +282 -94
- package/docs/components/toggle.html +282 -94
- package/docs/components/tree.html +282 -94
- package/docs/index.html +288 -94
- package/docs/src/components/Combobox.js +97 -0
- package/docs/src/components/Option.js +1 -0
- package/docs/src/components/ThemeSwitcher.js +77 -14
- package/docs/utils/context.html +282 -94
- package/docs/utils/cookie.html +282 -94
- package/docs/utils/debounce.html +282 -94
- package/docs/utils/drag.html +282 -94
- package/docs/utils/elevation.html +282 -94
- package/docs/utils/formatTimestamp.html +282 -94
- package/docs/utils/object.html +282 -94
- package/docs/utils/propConverters.html +282 -94
- package/docs/utils/string.html +282 -94
- package/docs/utils/theme.html +282 -94
- package/docs/utils/toTitleCase.html +282 -94
- package/docs/utils/type.html +282 -94
- package/docs/utils/wait.html +282 -94
- package/docs-src/components/combobox.page.html +358 -0
- package/docs-src/components/theme-switcher-aside.page.html +35 -0
- package/docs-src/components/theme-switcher.page.html +159 -7
- package/docs-src/index.page.html +6 -0
- package/docs-src/nav.fragment.html +283 -95
- package/llms.txt +2 -1
- package/package.json +1 -1
- package/src/components/Combobox.js +338 -0
- package/src/components/Option.js +19 -0
- package/src/components/ThemeSwitcher.js +171 -24
- package/tests/components/Combobox.browser-test.js +790 -0
- package/tests/components/ThemeSwitcher.browser-test.js +361 -33
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
<page pageName="Combobox" title="Combobox - Components - Kempo Docs - A Web Components Solution">
|
|
2
|
+
<content location="header"></content>
|
|
3
|
+
<content>
|
|
4
|
+
<h1 class="ta-center">Combobox</h1>
|
|
5
|
+
|
|
6
|
+
<k-accordion persistent-id="toc" class="b r mb">
|
|
7
|
+
<k-accordion-header for-panel="toc-panel">Table of Contents</k-accordion-header>
|
|
8
|
+
<k-accordion-panel name="toc-panel">
|
|
9
|
+
<div class="m pl">
|
|
10
|
+
<h6>Examples</h6>
|
|
11
|
+
<a href="#basicUsage">Basic Usage</a><br />
|
|
12
|
+
<a href="#dynamicSearch">Dynamic Search</a><br />
|
|
13
|
+
<a href="#required">Required</a><br />
|
|
14
|
+
<a href="#requireMatch">Require Match</a><br />
|
|
15
|
+
<a href="#maxVisible">Max Visible</a><br />
|
|
16
|
+
|
|
17
|
+
<h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
|
|
18
|
+
<a href="#constructor">Constructor</a><br />
|
|
19
|
+
<a href="#requirements">Requirements</a><br />
|
|
20
|
+
<a href="#attributes">Attributes / Properties</a><br />
|
|
21
|
+
<a href="#children">Children</a><br />
|
|
22
|
+
<a href="#methods">Methods</a><br />
|
|
23
|
+
<a href="#eventsRef">Events</a><br />
|
|
24
|
+
<a href="#cssVars">CSS Custom Properties</a><br />
|
|
25
|
+
</div>
|
|
26
|
+
</k-accordion-panel>
|
|
27
|
+
</k-accordion>
|
|
28
|
+
|
|
29
|
+
<h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
|
|
30
|
+
<p>Define options as <code><k-option></code> children. As the user types, options are filtered to match the input.</p>
|
|
31
|
+
<div class="row -mx">
|
|
32
|
+
<div class="col m-span-12 px">
|
|
33
|
+
<k-card label="HTML">
|
|
34
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">k-combobox</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Select a fruit...'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'apple'</span>></span>Apple<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'banana'</span>></span>Banana<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'cherry'</span>></span>Cherry<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'date'</span>></span>Date<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'elderberry'</span>></span>Elderberry<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'fig'</span>></span>Fig<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'grape'</span>></span>Grape<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'honeydew'</span>></span>Honeydew<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'kiwi'</span>></span>Kiwi<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'lemon'</span>></span>Lemon<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br><span class="hljs-tag"></<span class="hljs-name">k-combobox</span>></span></code></pre>
|
|
35
|
+
</k-card>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="col m-span-12 px">
|
|
38
|
+
<k-card label="Output">
|
|
39
|
+
<k-combobox placeholder="Select a fruit...">
|
|
40
|
+
<k-option value="apple">Apple</k-option>
|
|
41
|
+
<k-option value="banana">Banana</k-option>
|
|
42
|
+
<k-option value="cherry">Cherry</k-option>
|
|
43
|
+
<k-option value="date">Date</k-option>
|
|
44
|
+
<k-option value="elderberry">Elderberry</k-option>
|
|
45
|
+
<k-option value="fig">Fig</k-option>
|
|
46
|
+
<k-option value="grape">Grape</k-option>
|
|
47
|
+
<k-option value="honeydew">Honeydew</k-option>
|
|
48
|
+
<k-option value="kiwi">Kiwi</k-option>
|
|
49
|
+
<k-option value="lemon">Lemon</k-option>
|
|
50
|
+
</k-combobox>
|
|
51
|
+
</k-card>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<h3 id="dynamicSearch"><a href="#dynamicSearch" class="no-link">Dynamic Search</a></h3>
|
|
56
|
+
<p>Listen for the <code>search</code> event to fetch options from an external source when the user pauses typing. Use <code>setOptions()</code> to replace the <code><k-option></code> children programmatically. Set the <code>searching</code> attribute to show a loading spinner while results load.</p>
|
|
57
|
+
<div class="row -mx">
|
|
58
|
+
<div class="col m-span-12 px">
|
|
59
|
+
<k-card label="HTML">
|
|
60
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">k-combobox</span> <span class="hljs-attr">id</span>=<span class="hljs-string">'dynamicCombobox'</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Search users...'</span> <span class="hljs-attr">debounce-ms</span>=<span class="hljs-string">'400'</span>></span><span class="hljs-tag"></<span class="hljs-name">k-combobox</span>></span></code></pre>
|
|
61
|
+
</k-card>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="col m-span-12 px">
|
|
64
|
+
<k-card label="JavaScript">
|
|
65
|
+
<pre><code class="hljs javascript"><span class="hljs-keyword">const</span> cb = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'#dynamicCombobox'</span>);<br>cb.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'search'</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =></span> {<br> cb.<span class="hljs-property">searching</span> = <span class="hljs-literal">true</span>;<br> <span class="hljs-title function_">fetch</span>(<span class="hljs-string">'/api/users?q='</span> + <span class="hljs-built_in">encodeURIComponent</span>(e.<span class="hljs-property">detail</span>.<span class="hljs-property">value</span>)).<span class="hljs-title function_">then</span>(<span class="hljs-function"><span class="hljs-params">r</span> =></span> r.<span class="hljs-title function_">json</span>()).<span class="hljs-title function_">then</span>(<span class="hljs-function"><span class="hljs-params">users</span> =></span> {<br> cb.<span class="hljs-title function_">setOptions</span>(users.<span class="hljs-title function_">map</span>(<span class="hljs-function"><span class="hljs-params">u</span> =></span> ({<br> <span class="hljs-attr">label</span>: u.<span class="hljs-property">email</span>,<br> <span class="hljs-attr">value</span>: u.<span class="hljs-property">id</span><br> })));<br> cb.<span class="hljs-property">searching</span> = <span class="hljs-literal">false</span>;<br> });<br>});<br>cb.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">'select'</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =></span> {<br> <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'Selected:'</span>, e.<span class="hljs-property">detail</span>.<span class="hljs-property">label</span>, e.<span class="hljs-property">detail</span>.<span class="hljs-property">value</span>);<br>});</code></pre>
|
|
66
|
+
</k-card>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="col m-span-12 px">
|
|
69
|
+
<k-card label="Output">
|
|
70
|
+
<k-combobox id="dynamicCombobox" placeholder="Search users..." debounce-ms="400"></k-combobox>
|
|
71
|
+
<p class="mt" id="dynamicResult"></p>
|
|
72
|
+
</k-card>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<h3 id="required"><a href="#required" class="no-link">Required</a></h3>
|
|
77
|
+
<p>The combobox is form-associated. Use the <code>required</code> attribute to prevent submitting when the field is empty.</p>
|
|
78
|
+
<div class="row -mx">
|
|
79
|
+
<div class="col m-span-12 px">
|
|
80
|
+
<k-card label="HTML">
|
|
81
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">form</span> <span class="hljs-attr">id</span>=<span class="hljs-string">'requiredForm'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-combobox</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'fruit'</span> <span class="hljs-attr">required</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Required field...'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'apple'</span>></span>Apple<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'banana'</span>></span>Banana<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'cherry'</span>></span>Cherry<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"></<span class="hljs-name">k-combobox</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'submit'</span> <span class="hljs-attr">class</span>=<span class="hljs-string">'btn primary mt'</span>></span>Submit<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br><span class="hljs-tag"></<span class="hljs-name">form</span>></span></code></pre>
|
|
82
|
+
</k-card>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="col m-span-12 px">
|
|
85
|
+
<k-card label="Output">
|
|
86
|
+
<form id="requiredForm">
|
|
87
|
+
<k-combobox name="fruit" required placeholder="Required field...">
|
|
88
|
+
<k-option value="apple">Apple</k-option>
|
|
89
|
+
<k-option value="banana">Banana</k-option>
|
|
90
|
+
<k-option value="cherry">Cherry</k-option>
|
|
91
|
+
</k-combobox>
|
|
92
|
+
<button type="submit" class="btn primary mt">Submit</button>
|
|
93
|
+
</form>
|
|
94
|
+
<p class="mt" id="requiredResult"></p>
|
|
95
|
+
</k-card>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<h3 id="requireMatch"><a href="#requireMatch" class="no-link">Require Match</a></h3>
|
|
100
|
+
<p>Use <code>require-match</code> to only accept values that match an existing option. An empty value is still valid (the field is not required), but any typed text that does not match an option label will fail validation.</p>
|
|
101
|
+
<div class="row -mx">
|
|
102
|
+
<div class="col m-span-12 px">
|
|
103
|
+
<k-card label="HTML">
|
|
104
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">form</span> <span class="hljs-attr">id</span>=<span class="hljs-string">'matchForm'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-combobox</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'color'</span> <span class="hljs-attr">require-match</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Type or pick a color...'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'red'</span>></span>Red<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'green'</span>></span>Green<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'blue'</span>></span>Blue<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"></<span class="hljs-name">k-combobox</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'submit'</span> <span class="hljs-attr">class</span>=<span class="hljs-string">'btn primary mt'</span>></span>Submit<span class="hljs-tag"></<span class="hljs-name">button</span>></span><br><span class="hljs-tag"></<span class="hljs-name">form</span>></span></code></pre>
|
|
105
|
+
</k-card>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="col m-span-12 px">
|
|
108
|
+
<k-card label="Output">
|
|
109
|
+
<form id="matchForm">
|
|
110
|
+
<k-combobox name="color" require-match placeholder="Type or pick a color...">
|
|
111
|
+
<k-option value="red">Red</k-option>
|
|
112
|
+
<k-option value="green">Green</k-option>
|
|
113
|
+
<k-option value="blue">Blue</k-option>
|
|
114
|
+
</k-combobox>
|
|
115
|
+
<button type="submit" class="btn primary mt">Submit</button>
|
|
116
|
+
</form>
|
|
117
|
+
<p class="mt" id="matchResult"></p>
|
|
118
|
+
</k-card>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<h3 id="maxVisible"><a href="#maxVisible" class="no-link">Max Visible</a></h3>
|
|
123
|
+
<p>Use <code>max-visible</code> to limit the number of options shown at once. A “more” indicator appears when additional matches exist.</p>
|
|
124
|
+
<div class="row -mx">
|
|
125
|
+
<div class="col m-span-12 px">
|
|
126
|
+
<k-card label="HTML">
|
|
127
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">k-combobox</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">'Shows 4 at a time...'</span> <span class="hljs-attr">max-visible</span>=<span class="hljs-string">'4'</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'1'</span>></span>Alpha<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'2'</span>></span>Bravo<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'3'</span>></span>Charlie<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'4'</span>></span>Delta<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'5'</span>></span>Echo<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'6'</span>></span>Foxtrot<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'7'</span>></span>Golf<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br> <span class="hljs-tag"><<span class="hljs-name">k-option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">'8'</span>></span>Hotel<span class="hljs-tag"></<span class="hljs-name">k-option</span>></span><br><span class="hljs-tag"></<span class="hljs-name">k-combobox</span>></span></code></pre>
|
|
128
|
+
</k-card>
|
|
129
|
+
</div>
|
|
130
|
+
<div class="col m-span-12 px">
|
|
131
|
+
<k-card label="Output">
|
|
132
|
+
<k-combobox placeholder="Shows 4 at a time..." max-visible="4">
|
|
133
|
+
<k-option value="1">Alpha</k-option>
|
|
134
|
+
<k-option value="2">Bravo</k-option>
|
|
135
|
+
<k-option value="3">Charlie</k-option>
|
|
136
|
+
<k-option value="4">Delta</k-option>
|
|
137
|
+
<k-option value="5">Echo</k-option>
|
|
138
|
+
<k-option value="6">Foxtrot</k-option>
|
|
139
|
+
<k-option value="7">Golf</k-option>
|
|
140
|
+
<k-option value="8">Hotel</k-option>
|
|
141
|
+
</k-combobox>
|
|
142
|
+
</k-card>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<h2 id="jsRef"><a href="#jsRef" class="no-link">JavaScript Reference</a></h2>
|
|
147
|
+
|
|
148
|
+
<h3 id="constructor"><a href="#constructor" class="no-link">Constructor</a></h3>
|
|
149
|
+
<pre><code class="hljs html"><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">'module'</span> <span class="hljs-attr">src</span>=<span class="hljs-string">'path/to/Combobox.js'</span>></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span></code></pre>
|
|
150
|
+
<p><code>Combobox.js</code> automatically imports <code>Option.js</code>, so only one script tag is needed. <code>k-spinner</code> must be loaded separately if using the <code>searching</code> indicator.</p>
|
|
151
|
+
|
|
152
|
+
<h3 id="requirements"><a href="#requirements" class="no-link">Requirements</a></h3>
|
|
153
|
+
<p>The following components are required:</p>
|
|
154
|
+
<ul>
|
|
155
|
+
<li><a href="./spinner.html"><code>k-spinner</code></a> — used for the searching indicator</li>
|
|
156
|
+
</ul>
|
|
157
|
+
|
|
158
|
+
<h3 id="attributes"><a href="#attributes" class="no-link">Attributes / Properties</a></h3>
|
|
159
|
+
<table class="b r">
|
|
160
|
+
<thead>
|
|
161
|
+
<tr>
|
|
162
|
+
<th>Attribute</th>
|
|
163
|
+
<th>Property</th>
|
|
164
|
+
<th>Type</th>
|
|
165
|
+
<th>Default</th>
|
|
166
|
+
<th>Description</th>
|
|
167
|
+
</tr>
|
|
168
|
+
</thead>
|
|
169
|
+
<tbody>
|
|
170
|
+
<tr>
|
|
171
|
+
<td><code>value</code></td>
|
|
172
|
+
<td><code>value</code></td>
|
|
173
|
+
<td><code>String</code></td>
|
|
174
|
+
<td><code>''</code></td>
|
|
175
|
+
<td>The current text input value.</td>
|
|
176
|
+
</tr>
|
|
177
|
+
<tr>
|
|
178
|
+
<td><code>name</code></td>
|
|
179
|
+
<td><code>name</code></td>
|
|
180
|
+
<td><code>String</code></td>
|
|
181
|
+
<td><code>''</code></td>
|
|
182
|
+
<td>Form field name, submitted with the form.</td>
|
|
183
|
+
</tr>
|
|
184
|
+
<tr>
|
|
185
|
+
<td><code>placeholder</code></td>
|
|
186
|
+
<td><code>placeholder</code></td>
|
|
187
|
+
<td><code>String</code></td>
|
|
188
|
+
<td><code>''</code></td>
|
|
189
|
+
<td>Placeholder text for the input field.</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td><code>opened</code></td>
|
|
193
|
+
<td><code>opened</code></td>
|
|
194
|
+
<td><code>Boolean</code></td>
|
|
195
|
+
<td><code>false</code></td>
|
|
196
|
+
<td>Whether the options dropdown is visible.</td>
|
|
197
|
+
</tr>
|
|
198
|
+
<tr>
|
|
199
|
+
<td><code>searching</code></td>
|
|
200
|
+
<td><code>searching</code></td>
|
|
201
|
+
<td><code>Boolean</code></td>
|
|
202
|
+
<td><code>false</code></td>
|
|
203
|
+
<td>Shows a loading spinner in the dropdown.</td>
|
|
204
|
+
</tr>
|
|
205
|
+
<tr>
|
|
206
|
+
<td><code>required</code></td>
|
|
207
|
+
<td><code>required</code></td>
|
|
208
|
+
<td><code>Boolean</code></td>
|
|
209
|
+
<td><code>false</code></td>
|
|
210
|
+
<td>Marks the field as required for form validation.</td>
|
|
211
|
+
</tr>
|
|
212
|
+
<tr>
|
|
213
|
+
<td><code>require-match</code></td>
|
|
214
|
+
<td><code>requireMatch</code></td>
|
|
215
|
+
<td><code>Boolean</code></td>
|
|
216
|
+
<td><code>false</code></td>
|
|
217
|
+
<td>When set, only values matching an existing option are valid.</td>
|
|
218
|
+
</tr>
|
|
219
|
+
<tr>
|
|
220
|
+
<td><code>disabled</code></td>
|
|
221
|
+
<td><code>disabled</code></td>
|
|
222
|
+
<td><code>Boolean</code></td>
|
|
223
|
+
<td><code>false</code></td>
|
|
224
|
+
<td>Disables the combobox.</td>
|
|
225
|
+
</tr>
|
|
226
|
+
<tr>
|
|
227
|
+
<td><code>debounce-ms</code></td>
|
|
228
|
+
<td><code>debounceMs</code></td>
|
|
229
|
+
<td><code>Number</code></td>
|
|
230
|
+
<td><code>300</code></td>
|
|
231
|
+
<td>Milliseconds to wait after typing before firing the <code>search</code> event.</td>
|
|
232
|
+
</tr>
|
|
233
|
+
<tr>
|
|
234
|
+
<td><code>max-visible</code></td>
|
|
235
|
+
<td><code>maxVisible</code></td>
|
|
236
|
+
<td><code>Number</code></td>
|
|
237
|
+
<td><code>8</code></td>
|
|
238
|
+
<td>Maximum number of options visible at once.</td>
|
|
239
|
+
</tr>
|
|
240
|
+
</tbody>
|
|
241
|
+
</table>
|
|
242
|
+
|
|
243
|
+
<h3 id="children"><a href="#children" class="no-link">Children</a></h3>
|
|
244
|
+
<table class="b r">
|
|
245
|
+
<thead>
|
|
246
|
+
<tr>
|
|
247
|
+
<th>Element</th>
|
|
248
|
+
<th>Description</th>
|
|
249
|
+
</tr>
|
|
250
|
+
</thead>
|
|
251
|
+
<tbody>
|
|
252
|
+
<tr>
|
|
253
|
+
<td><code><k-option value="...">Label</k-option></code></td>
|
|
254
|
+
<td>Defines a selectable option. The <code>value</code> attribute is the form value; the text content is the displayed label. If <code>value</code> is omitted, the text content is used as both.</td>
|
|
255
|
+
</tr>
|
|
256
|
+
</tbody>
|
|
257
|
+
</table>
|
|
258
|
+
|
|
259
|
+
<h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
|
|
260
|
+
<table class="b r">
|
|
261
|
+
<thead>
|
|
262
|
+
<tr>
|
|
263
|
+
<th>Method</th>
|
|
264
|
+
<th>Description</th>
|
|
265
|
+
</tr>
|
|
266
|
+
</thead>
|
|
267
|
+
<tbody>
|
|
268
|
+
<tr>
|
|
269
|
+
<td><code>setOptions(options)</code></td>
|
|
270
|
+
<td>Replaces all <code><k-option></code> children. Accepts an array of strings or <code>{label, value}</code> objects. Returns <code>this</code>.</td>
|
|
271
|
+
</tr>
|
|
272
|
+
<tr>
|
|
273
|
+
<td><code>clear()</code></td>
|
|
274
|
+
<td>Clears the input value and closes the dropdown. Returns <code>this</code>.</td>
|
|
275
|
+
</tr>
|
|
276
|
+
</tbody>
|
|
277
|
+
</table>
|
|
278
|
+
<p>Example:</p>
|
|
279
|
+
<pre><code class="hljs javascript">combobox.<span class="hljs-title function_">setOptions</span>([<span class="hljs-string">'Apple'</span>, <span class="hljs-string">'Banana'</span>, {<br> <span class="hljs-attr">label</span>: <span class="hljs-string">'alice@example.com'</span>,<br> <span class="hljs-attr">value</span>: <span class="hljs-number">101</span><br>}]);</code></pre>
|
|
280
|
+
|
|
281
|
+
<h3 id="eventsRef"><a href="#eventsRef" class="no-link">Events</a></h3>
|
|
282
|
+
<table class="b r">
|
|
283
|
+
<thead>
|
|
284
|
+
<tr>
|
|
285
|
+
<th>Event</th>
|
|
286
|
+
<th>Detail</th>
|
|
287
|
+
<th>Description</th>
|
|
288
|
+
</tr>
|
|
289
|
+
</thead>
|
|
290
|
+
<tbody>
|
|
291
|
+
<tr>
|
|
292
|
+
<td><code>search</code></td>
|
|
293
|
+
<td><code>{ value: String }</code></td>
|
|
294
|
+
<td>Fired after the user stops typing for <code>debounce-ms</code> milliseconds.</td>
|
|
295
|
+
</tr>
|
|
296
|
+
<tr>
|
|
297
|
+
<td><code>select</code></td>
|
|
298
|
+
<td><code>{ value: *, label: String }</code></td>
|
|
299
|
+
<td>Fired when the user selects an option from the list.</td>
|
|
300
|
+
</tr>
|
|
301
|
+
<tr>
|
|
302
|
+
<td><code>change</code></td>
|
|
303
|
+
<td>—</td>
|
|
304
|
+
<td>Fired after an option is selected.</td>
|
|
305
|
+
</tr>
|
|
306
|
+
</tbody>
|
|
307
|
+
</table>
|
|
308
|
+
|
|
309
|
+
<h3 id="cssVars"><a href="#cssVars" class="no-link">CSS Custom Properties</a></h3>
|
|
310
|
+
<p>The combobox inherits kempo-css variables for colors, borders, spacing, and animation timing. No additional custom properties are defined.</p>
|
|
311
|
+
</content>
|
|
312
|
+
<content location="scripts">
|
|
313
|
+
<script type="module" src="{{pathToRoot}}src/components/Combobox.js"></script>
|
|
314
|
+
<script type="module" src="{{pathToRoot}}src/components/Spinner.js"></script>
|
|
315
|
+
<script type="module" src="{{pathToRoot}}src/components/Accordion.js"></script>
|
|
316
|
+
<script type="module" src="{{pathToRoot}}src/components/Card.js"></script>
|
|
317
|
+
<script type="module">
|
|
318
|
+
const fakeUsers = [
|
|
319
|
+
'alice@example.com', 'bob@example.com', 'carol@example.com',
|
|
320
|
+
'dave@example.com', 'eve@example.com', 'frank@example.com',
|
|
321
|
+
'grace@example.com', 'heidi@example.com', 'ivan@example.com',
|
|
322
|
+
'judy@example.com', 'kate@example.com', 'leo@example.com'
|
|
323
|
+
];
|
|
324
|
+
const dynamicCb = document.querySelector('#dynamicCombobox');
|
|
325
|
+
const dynamicResult = document.querySelector('#dynamicResult');
|
|
326
|
+
dynamicCb.addEventListener('search', (e) => {
|
|
327
|
+
dynamicCb.searching = true;
|
|
328
|
+
setTimeout(() => {
|
|
329
|
+
dynamicCb.setOptions(
|
|
330
|
+
fakeUsers.filter(u => u.includes(e.detail.value.toLowerCase())).slice(0, 5)
|
|
331
|
+
);
|
|
332
|
+
dynamicCb.searching = false;
|
|
333
|
+
}, 800);
|
|
334
|
+
});
|
|
335
|
+
dynamicCb.addEventListener('select', (e) => {
|
|
336
|
+
dynamicResult.textContent = 'Selected: ' + e.detail.label;
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
document.querySelector('#requiredForm').addEventListener('submit', (e) => {
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
const data = new FormData(e.target);
|
|
342
|
+
document.querySelector('#requiredResult').textContent = 'Submitted: fruit=' + data.get('fruit');
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
document.querySelector('#matchForm').addEventListener('submit', (e) => {
|
|
346
|
+
e.preventDefault();
|
|
347
|
+
const data = new FormData(e.target);
|
|
348
|
+
document.querySelector('#matchResult').textContent = 'Submitted: color=' + data.get('colorruit');
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
document.querySelector('#matchForm').addEventListener('submit', (e) => {
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
const data = new FormData(e.target);
|
|
354
|
+
document.querySelector('#matchResult').textContent = 'Submitted: color=' + data.get('color');
|
|
355
|
+
});
|
|
356
|
+
</script>
|
|
357
|
+
</content>
|
|
358
|
+
</page>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<page template="bare" title="ThemeSwitcher Aside Example">
|
|
2
|
+
<content location="head">
|
|
3
|
+
<style>
|
|
4
|
+
body {
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
height: 100vh;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
</style>
|
|
11
|
+
<script type="module">
|
|
12
|
+
import theme from '{{pathToRoot}}src/utils/theme.js';
|
|
13
|
+
theme.init();
|
|
14
|
+
</script>
|
|
15
|
+
<script type="module" src="{{pathToRoot}}src/components/Aside.js"></script>
|
|
16
|
+
<script type="module" src="{{pathToRoot}}src/components/Main.js"></script>
|
|
17
|
+
<script type="module" src="{{pathToRoot}}src/components/ThemeSwitcher.js"></script>
|
|
18
|
+
</content>
|
|
19
|
+
<content>
|
|
20
|
+
<k-aside main="push" state="expanded" style="--aside_padding: 0;">
|
|
21
|
+
<k-aside-toggle><h5 class="m0">Kempo</h5></k-aside-toggle>
|
|
22
|
+
<k-aside-item icon="cards" href="#" active>Dashboard</k-aside-item>
|
|
23
|
+
<k-aside-item icon="check" href="#">Tasks</k-aside-item>
|
|
24
|
+
<k-aside-item icon="label" href="#">Email</k-aside-item>
|
|
25
|
+
<k-aside-spacer></k-aside-spacer>
|
|
26
|
+
<div class="p d-f jc-c">
|
|
27
|
+
<k-theme-switcher style="--padding: 0.5rem;"></k-theme-switcher>
|
|
28
|
+
</div>
|
|
29
|
+
</k-aside>
|
|
30
|
+
<k-main>
|
|
31
|
+
<h2>Main Content</h2>
|
|
32
|
+
<p>Toggle the aside between expanded and collapsed to see the ThemeSwitcher switch between segmented and toggle modes automatically.</p>
|
|
33
|
+
</k-main>
|
|
34
|
+
</content>
|
|
35
|
+
</page>
|