kempo-ui 0.3.15 → 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.
Files changed (73) hide show
  1. package/dist/components/ThemeSwitcher.js +77 -14
  2. package/docs/components/accordion.html +281 -95
  3. package/docs/components/aside.html +281 -95
  4. package/docs/components/card.html +281 -95
  5. package/docs/components/code-editor.html +281 -95
  6. package/docs/components/color-picker.html +281 -95
  7. package/docs/components/combobox.html +281 -95
  8. package/docs/components/content-slider.html +281 -95
  9. package/docs/components/context.html +281 -95
  10. package/docs/components/dialog.html +281 -95
  11. package/docs/components/dropdown.html +281 -95
  12. package/docs/components/filter-list.html +281 -95
  13. package/docs/components/focus-capture.html +281 -95
  14. package/docs/components/html-editor.html +281 -95
  15. package/docs/components/hybrid-component.html +281 -95
  16. package/docs/components/icon.html +281 -95
  17. package/docs/components/import.html +281 -95
  18. package/docs/components/light-component.html +281 -95
  19. package/docs/components/nav-spacer.html +281 -95
  20. package/docs/components/nav.html +281 -95
  21. package/docs/components/photo-viewer.html +281 -95
  22. package/docs/components/resize.html +281 -95
  23. package/docs/components/shadow-component.html +281 -95
  24. package/docs/components/show-more.html +281 -95
  25. package/docs/components/sortable.html +281 -95
  26. package/docs/components/spinner.html +281 -95
  27. package/docs/components/split.html +281 -95
  28. package/docs/components/table.html +281 -95
  29. package/docs/components/tableControls.html +281 -95
  30. package/docs/components/tableCustomFields.html +281 -95
  31. package/docs/components/tableFetchRecords.html +281 -95
  32. package/docs/components/tableFieldSortHide.html +281 -95
  33. package/docs/components/tablePagination.html +281 -95
  34. package/docs/components/tablePlaceholder.html +281 -95
  35. package/docs/components/tableRecordEditing.html +281 -95
  36. package/docs/components/tableRecordFiltering.html +281 -95
  37. package/docs/components/tableRecordHiding.html +281 -95
  38. package/docs/components/tableRecordSearching.html +281 -95
  39. package/docs/components/tableRecordSelection.html +281 -95
  40. package/docs/components/tableRowControls.html +281 -95
  41. package/docs/components/tableServerSync.html +281 -95
  42. package/docs/components/tableSorting.html +281 -95
  43. package/docs/components/tabs.html +281 -95
  44. package/docs/components/tags.html +281 -95
  45. package/docs/components/theme-select.html +281 -95
  46. package/docs/components/theme-switcher-aside.html +47 -0
  47. package/docs/components/theme-switcher.html +440 -102
  48. package/docs/components/timestamp.html +281 -95
  49. package/docs/components/toast.html +281 -95
  50. package/docs/components/toggle.html +281 -95
  51. package/docs/components/tree.html +281 -95
  52. package/docs/index.html +281 -95
  53. package/docs/src/components/ThemeSwitcher.js +77 -14
  54. package/docs/utils/context.html +281 -95
  55. package/docs/utils/cookie.html +281 -95
  56. package/docs/utils/debounce.html +281 -95
  57. package/docs/utils/drag.html +281 -95
  58. package/docs/utils/elevation.html +281 -95
  59. package/docs/utils/formatTimestamp.html +281 -95
  60. package/docs/utils/object.html +281 -95
  61. package/docs/utils/propConverters.html +281 -95
  62. package/docs/utils/string.html +281 -95
  63. package/docs/utils/theme.html +281 -95
  64. package/docs/utils/toTitleCase.html +281 -95
  65. package/docs/utils/type.html +281 -95
  66. package/docs/utils/wait.html +281 -95
  67. package/docs-src/components/theme-switcher-aside.page.html +35 -0
  68. package/docs-src/components/theme-switcher.page.html +159 -7
  69. package/docs-src/nav.fragment.html +282 -96
  70. package/llms.txt +1 -1
  71. package/package.json +1 -1
  72. package/src/components/ThemeSwitcher.js +171 -24
  73. package/tests/components/ThemeSwitcher.browser-test.js +361 -33
@@ -5,7 +5,11 @@
5
5
  <k-accordion-panel name="toc-panel">
6
6
  <div class="m pl">
7
7
  <h6>Examples</h6>
8
- <a href="#basicUsage">Basic Usage</a><br />
8
+ <a href="#basicUsage">Basic Usage (Segmented)</a><br />
9
+ <a href="#toggleMode">Toggle Mode</a><br />
10
+ <a href="#customOptions">Custom Options</a><br />
11
+ <a href="#autoMode">Auto Mode (Aside Detection)</a><br />
12
+ <a href="#labels">Labels</a><br />
9
13
  <a href="#customPadding">Custom Padding</a><br />
10
14
 
11
15
  <h6 class="mt"><a href="#jsRef" class="no-link">JavaScript Reference</a></h6>
@@ -21,10 +25,11 @@
21
25
 
22
26
  <h3>Description</h3>
23
27
  <p>The <code>ThemeSwitcher</code> component provides a UI control for users to switch between different themes (auto, light, dark). It extends the <a href="./shadow-component.html">ShadowComponent</a> class and uses the <a href="{{pathToRoot}}utils/theme.html">theme utility</a> internally for state management, persistence, and synchronization.</p>
28
+ <p>The component supports two display modes: <strong>segmented</strong> (shows all options as buttons) and <strong>toggle</strong> (single button that cycles through options on click). When <code>mode</code> is <code>"auto"</code> (the default), the component detects if it is inside a <code>&lt;k-aside&gt;</code> and switches between segmented and toggle based on the aside state.</p>
24
29
  <p><strong>Note:</strong> You can manage theme state without this component by directly importing the <a href="{{pathToRoot}}utils/theme.html">theme utility</a>.</p>
25
30
 
26
- <h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage</a></h3>
27
- <p>Use the <code>ThemeSwitcher</code> component to allow users to cycle through themes. Clicking the button cycles through auto → light → dark → auto. The component automatically detects the user's system preference when in auto mode.</p>
31
+ <h3 id="basicUsage"><a href="#basicUsage" class="no-link">Basic Usage (Segmented)</a></h3>
32
+ <p>By default, the component renders as a segmented control with buttons for each theme option. The active theme is highlighted.</p>
28
33
 
29
34
  <div class="row -mx mb">
30
35
  <div class="col d-span-6 m-span-12 px">
@@ -39,6 +44,112 @@
39
44
  </div>
40
45
  </div>
41
46
 
47
+ <h3 id="toggleMode"><a href="#toggleMode" class="no-link">Toggle Mode</a></h3>
48
+ <p>Set <code>mode="toggle"</code> to display a single button that cycles through the theme options on each click.</p>
49
+
50
+ <div class="row -mx mb">
51
+ <div class="col d-span-6 m-span-12 px">
52
+ <k-card label="HTML">
53
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">&#x27;toggle&#x27;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
54
+ </k-card>
55
+ </div>
56
+ <div class="col d-span-6 m-span-12 px">
57
+ <k-card label="Output">
58
+ <k-theme-switcher mode="toggle"></k-theme-switcher>
59
+ </k-card>
60
+ </div>
61
+ </div>
62
+
63
+ <h3 id="customOptions"><a href="#customOptions" class="no-link">Custom Options</a></h3>
64
+ <p>Use the <code>options</code> attribute to control which themes are available and in what order. Provide a comma-separated list. Both toggle and segmented modes respect this attribute.</p>
65
+
66
+ <div class="row -mx mb">
67
+ <div class="col d-span-6 m-span-12 px">
68
+ <k-card label="HTML (segmented, dark &amp; light only)">
69
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">options</span>=<span class="hljs-string">&#x27;dark, light&#x27;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
70
+ </k-card>
71
+ </div>
72
+ <div class="col d-span-6 m-span-12 px">
73
+ <k-card label="Output">
74
+ <k-theme-switcher options="dark, light"></k-theme-switcher>
75
+ </k-card>
76
+ </div>
77
+ </div>
78
+
79
+ <div class="row -mx mb">
80
+ <div class="col d-span-6 m-span-12 px">
81
+ <k-card label="HTML (toggle, dark &amp; light only)">
82
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">&#x27;toggle&#x27;</span> <span class="hljs-attr">options</span>=<span class="hljs-string">&#x27;dark, light&#x27;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
83
+ </k-card>
84
+ </div>
85
+ <div class="col d-span-6 m-span-12 px">
86
+ <k-card label="Output">
87
+ <k-theme-switcher mode="toggle" options="dark, light"></k-theme-switcher>
88
+ </k-card>
89
+ </div>
90
+ </div>
91
+
92
+ <h3 id="autoMode"><a href="#autoMode" class="no-link">Auto Mode (Aside Detection)</a></h3>
93
+ <p>When <code>mode="auto"</code> (the default), the component checks if it is inside a <code>&lt;k-aside&gt;</code>. If so, it renders as <strong>segmented</strong> when the aside is expanded or offscreen, and as <strong>toggle</strong> when the aside is collapsed. If the component is not inside an aside, it always renders as segmented.</p>
94
+ <div class="row -mx">
95
+ <div class="col m-span-12 px">
96
+ <k-card label="HTML">
97
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-aside</span> <span class="hljs-attr">main</span>=<span class="hljs-string">&#x27;push&#x27;</span> <span class="hljs-attr">state</span>=<span class="hljs-string">&#x27;expanded&#x27;</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&#x27;--aside_padding: 0;&#x27;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-aside-toggle</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">h5</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&#x27;m0&#x27;</span>&gt;</span>Kempo<span class="hljs-tag">&lt;/<span class="hljs-name">h5</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">k-aside-toggle</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-aside-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">&#x27;cards&#x27;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&#x27;#&#x27;</span> <span class="hljs-attr">active</span>&gt;</span>Dashboard<span class="hljs-tag">&lt;/<span class="hljs-name">k-aside-item</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-aside-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">&#x27;check&#x27;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&#x27;#&#x27;</span>&gt;</span>Tasks<span class="hljs-tag">&lt;/<span class="hljs-name">k-aside-item</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-aside-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">&#x27;label&#x27;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&#x27;#&#x27;</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">k-aside-item</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-aside-spacer</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-aside-spacer</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&#x27;p d-f jc-c&#x27;</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&#x27;--padding: 0.5rem;&#x27;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">k-aside</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">k-main</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>Main Content<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Toggle the aside to see the ThemeSwitcher switch modes.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">k-main</span>&gt;</span></code></pre>
98
+ </k-card>
99
+ </div>
100
+ <div class="col m-span-12 px">
101
+ <k-card label="Output">
102
+ <iframe src="./theme-switcher-aside.html" style="width: 100%; height: 400px; border: 1px solid var(--c_border); border-radius: var(--radius);"></iframe>
103
+ </k-card>
104
+ </div>
105
+ </div>
106
+
107
+ <h3 id="labels"><a href="#labels" class="no-link">Labels</a></h3>
108
+ <p>The <code>labels</code> attribute adds text labels next to each icon. Works in both segmented and toggle modes. Labels are automatically hidden when inside a collapsed <code>&lt;k-aside&gt;</code> to preserve space.</p>
109
+ <ul>
110
+ <li><code>labels</code> (no value) — uses capitalized option names: "Light", "Auto", "Dark"</li>
111
+ <li><code>labels="Claro, Auto, Oscuro"</code> — uses custom labels in the same order as <code>options</code></li>
112
+ </ul>
113
+
114
+ <div class="row -mx mb">
115
+ <div class="col d-span-6 m-span-12 px">
116
+ <k-card label="HTML (Segmented)">
117
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">labels</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
118
+ </k-card>
119
+ </div>
120
+ <div class="col d-span-6 m-span-12 px">
121
+ <k-card label="Output">
122
+ <k-theme-switcher labels></k-theme-switcher>
123
+ </k-card>
124
+ </div>
125
+ </div>
126
+
127
+ <div class="row -mx mb">
128
+ <div class="col d-span-6 m-span-12 px">
129
+ <k-card label="HTML (Custom Labels)">
130
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">labels</span>=<span class="hljs-string">&#x27;Claro, Auto, Oscuro&#x27;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
131
+ </k-card>
132
+ </div>
133
+ <div class="col d-span-6 m-span-12 px">
134
+ <k-card label="Output">
135
+ <k-theme-switcher labels="Claro, Auto, Oscuro"></k-theme-switcher>
136
+ </k-card>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="row -mx mb">
141
+ <div class="col d-span-6 m-span-12 px">
142
+ <k-card label="HTML (Toggle)">
143
+ <pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">k-theme-switcher</span> <span class="hljs-attr">mode</span>=<span class="hljs-string">&#x27;toggle&#x27;</span> <span class="hljs-attr">labels</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">k-theme-switcher</span>&gt;</span></code></pre>
144
+ </k-card>
145
+ </div>
146
+ <div class="col d-span-6 m-span-12 px">
147
+ <k-card label="Output">
148
+ <k-theme-switcher mode="toggle" labels></k-theme-switcher>
149
+ </k-card>
150
+ </div>
151
+ </div>
152
+
42
153
  <h3 id="customPadding"><a href="#customPadding" class="no-link">Custom Padding</a></h3>
43
154
  <p>You can customize the button padding by setting the <code>--padding</code> CSS custom property. The default padding uses <code>var(--spacer, 1rem)</code>.</p>
44
155
 
@@ -75,12 +186,53 @@
75
186
  <h5><code>currentTheme<i>: string</i></code></h5>
76
187
  <p>Gets or sets the current theme. Possible values are <code>"auto"</code>, <code>"light"</code>, or <code>"dark"</code>. This property is reactive and will trigger a re-render when changed. Syncs to <code>current-theme</code> attribute.</p>
77
188
 
189
+ <h5><code>mode<i>: string</i></code></h5>
190
+ <p>Controls the display mode of the component. Possible values:</p>
191
+ <ul>
192
+ <li><code>"auto"</code> (default) - Detects if inside a <code>&lt;k-aside&gt;</code>. Shows segmented when aside is expanded/offscreen, toggle when collapsed. If not in an aside, shows segmented.</li>
193
+ <li><code>"toggle"</code> - Single button that cycles through options on click.</li>
194
+ <li><code>"segmented"</code> - Shows all options as separate buttons with the active one highlighted.</li>
195
+ </ul>
196
+
197
+ <h5><code>options<i>: string</i></code></h5>
198
+ <p>A comma-separated list of theme options to display. Defaults to <code>"light, auto, dark"</code>. Controls which themes are available and in what order for both toggle and segmented modes. Spaces around commas are optional.</p>
199
+
200
+ <h5><code>labels<i>: string</i></code></h5>
201
+ <p>A comma-separated list of labels to display next to each icon, matching the order of <code>options</code>. When present with no value (e.g., just <code>labels</code>), defaults to capitalized option names ("Light", "Auto", "Dark"). Labels are automatically hidden when inside a collapsed <code>&lt;k-aside&gt;</code> to preserve space. Works in both segmented and toggle modes.</p>
202
+
78
203
  <h3 id="cssCustomProperties"><a href="#cssCustomProperties" class="no-link">CSS Custom Properties</a></h3>
79
204
  <h5><code>--padding<i>: length</i></code></h5>
80
- <p>Controls the padding of the theme switcher button. Defaults to <code>var(--spacer, 1rem)</code>. You can override this to customize the button's spacing.</p>
81
- <pre><code class="hljs css"><span class="hljs-selector-tag">k-theme-switcher</span> {
82
- <span class="hljs-attribute">--padding</span>: <span class="hljs-number">0.5rem</span>;
83
- }</code></pre>
205
+ <p>Padding of all buttons. Defaults to <code>var(--spacer, 1rem)</code>.</p>
206
+
207
+ <h5><code>--c_inactive<i>: color</i></code></h5>
208
+ <p>Background color of inactive buttons. Defaults to <code>transparent</code>.</p>
209
+
210
+ <h5><code>--tc_inactive<i>: color</i></code></h5>
211
+ <p>Text/icon color of inactive buttons. Defaults to <code>inherit</code>.</p>
212
+
213
+ <h5><code>--c_inactive__hover<i>: color</i></code></h5>
214
+ <p>Background color of inactive buttons on hover. Defaults to <code>var(--c_bg__alt)</code>.</p>
215
+
216
+ <h5><code>--tc_inactive__hover<i>: color</i></code></h5>
217
+ <p>Text/icon color of inactive buttons on hover. Defaults to <code>inherit</code>.</p>
218
+
219
+ <h5><code>--c_active<i>: color</i></code></h5>
220
+ <p>Background color of the active button. Defaults to <code>var(--c_primary)</code>.</p>
221
+
222
+ <h5><code>--tc_active<i>: color</i></code></h5>
223
+ <p>Text/icon color of the active button. Defaults to <code>var(--tc_light)</code>.</p>
224
+
225
+ <h5><code>--c_active__hover<i>: color</i></code></h5>
226
+ <p>Background color of the active button on hover. Defaults to <code>var(--c_active)</code>.</p>
227
+
228
+ <h5><code>--tc_active__hover<i>: color</i></code></h5>
229
+ <p>Text/icon color of the active button on hover. Defaults to <code>var(--tc_active)</code>.</p>
230
+
231
+ <h5><code>--border<i>: border</i></code></h5>
232
+ <p>Border applied to inactive buttons in segmented mode. Defaults to <code>1px solid var(--c_border)</code>.</p>
233
+
234
+ <p>Example — styling for use on a primary-colored nav background:</p>
235
+ <pre><code class="hljs css">k-theme-switcher {<br> <span class="hljs-attr">--padding</span>: <span class="hljs-number">0.5rem</span>;<br> <span class="hljs-attr">--c_inactive</span>: transparent;<br> <span class="hljs-attr">--tc_inactive</span>: <span class="hljs-built_in">var</span>(--tc_light);<br> <span class="hljs-attr">--c_active</span>: white;<br> <span class="hljs-attr">--tc_active</span>: <span class="hljs-built_in">var</span>(--c_primary);<br> <span class="hljs-attr">--border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-built_in">rgba</span>(<span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">0.4</span>);<br>}</code></pre>
84
236
 
85
237
  <h3 id="methods"><a href="#methods" class="no-link">Methods</a></h3>
86
238
  <p>The <code>ThemeSwitcher</code> class does not introduce any new public methods beyond those provided by the <a href="./shadow-component.html">ShadowComponent</a> class.</p>