kempo-ui 0.1.6 → 0.2.2

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 (119) hide show
  1. package/.github/skills/highlight-code/SKILL.md +22 -6
  2. package/.github/skills/new-component/SKILL.md +68 -4
  3. package/AGENTS.md +11 -0
  4. package/bin/highlight_code.js +7 -15
  5. package/dist/components/Aside.js +326 -0
  6. package/dist/components/Dialog.js +1 -1
  7. package/dist/components/Dropdown.js +1 -1
  8. package/dist/components/Main.js +2 -2
  9. package/dist/components/Nav.js +27 -0
  10. package/dist/components/PhotoViewer.js +1 -1
  11. package/dist/components/ShadowComponent.js +1 -1
  12. package/dist/components/ThemeSwitcher.js +1 -0
  13. package/dist/components/Toast.js +1 -1
  14. package/docs/components/accordion.html +4 -3
  15. package/docs/components/aside-items.html +43 -0
  16. package/docs/components/aside-menu.html +43 -0
  17. package/docs/components/aside-push.html +26 -0
  18. package/docs/components/aside.html +567 -0
  19. package/docs/components/card.html +4 -3
  20. package/docs/components/color-picker.html +4 -3
  21. package/docs/components/content-slider.html +4 -3
  22. package/docs/components/dialog.html +4 -3
  23. package/docs/components/dropdown.html +4 -3
  24. package/docs/components/filter-list.html +4 -3
  25. package/docs/components/focus-capture.html +6 -5
  26. package/docs/components/html-editor.html +5 -4
  27. package/docs/components/hybrid-component.html +5 -4
  28. package/docs/components/icon.html +4 -3
  29. package/docs/components/import.html +5 -4
  30. package/docs/components/light-component.html +4 -3
  31. package/docs/components/nav.html +117 -0
  32. package/docs/components/photo-viewer.html +5 -4
  33. package/docs/components/resize.html +5 -4
  34. package/docs/components/shadow-component.html +4 -3
  35. package/docs/components/show-more.html +5 -4
  36. package/docs/components/sortable.html +4 -3
  37. package/docs/components/spinner.html +4 -3
  38. package/docs/components/split.html +5 -4
  39. package/docs/components/table.html +4 -3
  40. package/docs/components/tableControls.html +4 -3
  41. package/docs/components/tableCustomFields.html +4 -3
  42. package/docs/components/tableFetchRecords.html +5 -4
  43. package/docs/components/tableFieldSortHide.html +5 -4
  44. package/docs/components/tablePagination.html +4 -3
  45. package/docs/components/tableRecordEditing.html +4 -3
  46. package/docs/components/tableRecordFiltering.html +5 -4
  47. package/docs/components/tableRecordHiding.html +4 -3
  48. package/docs/components/tableRecordSearching.html +5 -4
  49. package/docs/components/tableRecordSelection.html +4 -3
  50. package/docs/components/tableRowControls.html +4 -3
  51. package/docs/components/tableServerSync.html +5 -4
  52. package/docs/components/tableSorting.html +5 -4
  53. package/docs/components/tabs.html +4 -3
  54. package/docs/components/tags.html +4 -3
  55. package/docs/components/theme-select.html +4 -3
  56. package/docs/components/theme-switcher.html +5 -4
  57. package/docs/components/timestamp.html +4 -3
  58. package/docs/components/toast.html +4 -3
  59. package/docs/components/toggle.html +5 -4
  60. package/docs/components/tree.html +5 -4
  61. package/docs/index.html +22 -21
  62. package/docs/nav-1.inc.html +18 -12
  63. package/docs/nav.inc.html +20 -13
  64. package/docs/nav.inc.js +1 -1
  65. package/docs/src/components/Aside.js +326 -0
  66. package/docs/src/components/Dialog.js +1 -1
  67. package/docs/src/components/Dropdown.js +1 -1
  68. package/docs/src/components/Main.js +2 -2
  69. package/docs/src/components/Nav.js +27 -0
  70. package/docs/src/components/PhotoViewer.js +1 -1
  71. package/docs/src/components/ShadowComponent.js +1 -1
  72. package/docs/src/components/ThemeSwitcher.js +1 -0
  73. package/docs/src/components/Toast.js +1 -1
  74. package/docs/utils/context.html +4 -3
  75. package/docs/utils/cookie.html +4 -3
  76. package/docs/utils/debounce.html +4 -3
  77. package/docs/utils/drag.html +4 -3
  78. package/docs/utils/elevation.html +156 -0
  79. package/docs/utils/formatTimestamp.html +4 -3
  80. package/docs/utils/object.html +4 -3
  81. package/docs/utils/propConverters.html +4 -3
  82. package/docs/utils/string.html +4 -3
  83. package/docs/utils/theme.html +4 -3
  84. package/docs/utils/toTitleCase.html +4 -3
  85. package/docs/utils/type.html +4 -3
  86. package/docs/utils/wait.html +4 -3
  87. package/llm.txt +247 -0
  88. package/package.json +3 -4
  89. package/src/components/Aside.js +726 -0
  90. package/src/components/Dialog.js +1 -1
  91. package/src/components/Dropdown.js +1 -1
  92. package/src/components/Main.js +34 -30
  93. package/src/components/Nav.js +53 -0
  94. package/src/components/PhotoViewer.js +1 -1
  95. package/src/components/ShadowComponent.js +1 -1
  96. package/src/components/ThemeSwitcher.js +1 -0
  97. package/src/components/Toast.js +1 -1
  98. package/tests/bin/get_icon.node-test.js +26 -0
  99. package/tests/bin/highlight_code.node-test.js +108 -0
  100. package/tests/bin/list_icons.node-test.js +26 -0
  101. package/tests/components/Aside.browser-test.js +778 -0
  102. package/tests/components/Main.browser-test.js +115 -283
  103. package/dist/components/SideMenu.js +0 -97
  104. package/dist/components/SidePanel.js +0 -236
  105. package/docs/components/side-menu.html +0 -189
  106. package/docs/components/side-panel-basic.html +0 -44
  107. package/docs/components/side-panel-dual.html +0 -70
  108. package/docs/components/side-panel-menu.html +0 -50
  109. package/docs/components/side-panel-persistent.html +0 -90
  110. package/docs/components/side-panel-scroll.html +0 -176
  111. package/docs/components/side-panel.html +0 -245
  112. package/docs/src/components/SideMenu.js +0 -97
  113. package/docs/src/components/SidePanel.js +0 -236
  114. package/scripts/update-kempo-css.js +0 -53
  115. package/src/components/SideMenu.js +0 -178
  116. package/src/components/SidePanel.js +0 -513
  117. package/tests/components/SideMenu.browser-test.js +0 -667
  118. package/tests/components/SidePanel.browser-test.js +0 -520
  119. package/tools/highlight.js +0 -51
package/llm.txt ADDED
@@ -0,0 +1,247 @@
1
+ # kempo-ui LLM Reference
2
+
3
+ Lit-based web component library. All custom elements are prefixed `k-`. Components use kempo-css for styling, which is automatically injected into every shadow root.
4
+
5
+ ---
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install kempo-ui
11
+ ```
12
+
13
+ ## Page Setup
14
+
15
+ Configure `window.kempo` before importing components. Both properties are optional:
16
+
17
+ ```html
18
+ <script>
19
+ window.kempo = {
20
+ pathToStylesheet: '/assets/kempo.min.css',
21
+ pathsToIcons: ['/icons']
22
+ };
23
+ </script>
24
+ ```
25
+
26
+ `pathToStylesheet` defaults to `https://cdn.jsdelivr.net/npm/kempo-css@2/dist/kempo.min.css` if unset.
27
+ `pathsToIcons` defaults to `['./icons', '/icons', '../icons', '../../icons']` if unset; these are local paths searched in order when resolving `<k-icon name="...">`.
28
+
29
+ ---
30
+
31
+ ## Importing Components
32
+
33
+ Each component file self-registers on import. Import individual files:
34
+
35
+ ```html
36
+ <script type="module" src="node_modules/kempo-ui/src/components/Toggle.js"></script>
37
+ ```
38
+
39
+ ```js
40
+ import 'kempo-ui/src/components/Toggle.js';
41
+ ```
42
+
43
+ Lit templates are available from `src/lit-all.min.js`:
44
+
45
+ ```js
46
+ import { html, css, LitElement } from 'kempo-ui/src/lit-all.min.js';
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Components
52
+
53
+ | Element(s) | File | Description | Docs |
54
+ |-----------|------|-------------|------|
55
+ | `<k-accordion>` `<k-accordion-header>` `<k-accordion-panel>` | `Accordion.js` | Collapsible panel groups; `for-panel` attribute links headers to panels | [accordion.html](https://dustinpoissant.github.io/kempo-ui/components/accordion.html) |
56
+ | `<k-aside>` `<k-aside-item>` `<k-aside-label>` `<k-aside-menu>` `<k-aside-spacer>` `<k-aside-toggle>` | `Aside.js` | Sidebar/drawer; `main="push"` or `main="overlay"`, `side="left|right"` | [aside.html](https://dustinpoissant.github.io/kempo-ui/components/aside.html) |
57
+ | `<k-card>` | `Card.js` | Bordered container; optional `label` attribute | [card.html](https://dustinpoissant.github.io/kempo-ui/components/card.html) |
58
+ | `<k-color-picker>` | `ColorPicker.js` | Full color picker (hex, rgb, hsl, hsv, alpha); `value` property | [color-picker.html](https://dustinpoissant.github.io/kempo-ui/components/color-picker.html) |
59
+ | `<k-content-slider>` | `ContentSlider.js` | Swipeable carousel | [content-slider.html](https://dustinpoissant.github.io/kempo-ui/components/content-slider.html) |
60
+ | `<k-dialog>` | `Dialog.js` | Modal dialog with focus trapping; call `.open()` / `.close()` | [dialog.html](https://dustinpoissant.github.io/kempo-ui/components/dialog.html) |
61
+ | `<k-dropdown>` | `Dropdown.js` | Action menu with keyboard navigation | [dropdown.html](https://dustinpoissant.github.io/kempo-ui/components/dropdown.html) |
62
+ | `<k-filter-list>` `<k-filter-item>` | `FilterList.js` `FilterItem.js` | Filter/search list; items have `filter` attribute with keywords | [filter-list.html](https://dustinpoissant.github.io/kempo-ui/components/filter-list.html) |
63
+ | `<k-focus-capture>` | `FocusCapture.js` | Traps keyboard focus within children | [focus-capture.html](https://dustinpoissant.github.io/kempo-ui/components/focus-capture.html) |
64
+ | `<k-html-editor>` | `HtmlEditor.js` | WYSIWYG rich text editor; `value` property | [html-editor.html](https://dustinpoissant.github.io/kempo-ui/components/html-editor.html) |
65
+ | `<k-icon>` | `Icon.js` | SVG icon; `name` (looked up in `pathsToIcons`) or `src` (direct URL); `rotation`, `direction`, `animation` attributes | [icon.html](https://dustinpoissant.github.io/kempo-ui/components/icon.html) |
66
+ | `<k-import>` | `Import.js` | Includes external HTML fragments; `src` attribute | [import.html](https://dustinpoissant.github.io/kempo-ui/components/import.html) |
67
+ | `<k-main>` | `Main.js` | Layout main; automatically adjusts margins when a `k-aside[main="push"]` opens | — |
68
+ | `<k-nav>` | `Nav.js` | Navigation bar | [nav.html](https://dustinpoissant.github.io/kempo-ui/components/nav.html) |
69
+ | `<k-photo-viewer>` | `PhotoViewer.js` | Lightbox/gallery viewer | [photo-viewer.html](https://dustinpoissant.github.io/kempo-ui/components/photo-viewer.html) |
70
+ | `<k-resize>` | `Resize.js` | Resizable pane with drag handle | [resize.html](https://dustinpoissant.github.io/kempo-ui/components/resize.html) |
71
+ | `<k-show-more>` | `ShowMore.js` | Truncated content with expand toggle | [show-more.html](https://dustinpoissant.github.io/kempo-ui/components/show-more.html) |
72
+ | `<k-sortable>` `<k-sortable-item>` | `Sortable.js` | Drag-to-reorder list | [sortable.html](https://dustinpoissant.github.io/kempo-ui/components/sortable.html) |
73
+ | `<k-spinner>` | `Spinner.js` | Loading indicator; `size` (xs/sm/md/lg/xl), `variant` (spinner/dots/bar) | [spinner.html](https://dustinpoissant.github.io/kempo-ui/components/spinner.html) |
74
+ | `<k-split>` | `Split.js` | Resizable split panes | [split.html](https://dustinpoissant.github.io/kempo-ui/components/split.html) |
75
+ | `<k-table>` | `Table.js` | Data table with sorting, filtering, pagination, row selection, server sync | [table.html](https://dustinpoissant.github.io/kempo-ui/components/table.html) |
76
+ | `<k-tabs>` `<k-tab>` `<k-tab-content>` `<k-tab-spacer>` | `Tabs.js` | Tabbed interface; `<k-tab for-content="id">` links to `<k-tab-content name="id">` | [tabs.html](https://dustinpoissant.github.io/kempo-ui/components/tabs.html) |
77
+ | `<k-tags>` `<k-tag>` | `Tags.js` | Tag input; add/remove tags; fires `change` | [tags.html](https://dustinpoissant.github.io/kempo-ui/components/tags.html) |
78
+ | `<k-theme-select>` | `ThemeSelect.js` | Dropdown to pick a theme | [theme-select.html](https://dustinpoissant.github.io/kempo-ui/components/theme-select.html) |
79
+ | `<k-theme-switcher>` | `ThemeSwitcher.js` | Light/dark/auto toggle button | [theme-switcher.html](https://dustinpoissant.github.io/kempo-ui/components/theme-switcher.html) |
80
+ | `<k-timestamp>` | `Timestamp.js` | Displays a `value` timestamp as human-readable relative time | [timestamp.html](https://dustinpoissant.github.io/kempo-ui/components/timestamp.html) |
81
+ | `<k-toast>` `<k-toast-container>` | `Toast.js` | Toast notifications; use `<k-toast-container>` once in page, call `.addToast(options)` | [toast.html](https://dustinpoissant.github.io/kempo-ui/components/toast.html) |
82
+ | `<k-toggle>` | `Toggle.js` | On/off toggle; `value` (Boolean, reflects); methods: `on()`, `off()`, `toggle()`; fires `change`, `on`, `off` | [toggle.html](https://dustinpoissant.github.io/kempo-ui/components/toggle.html) |
83
+ | `<k-tree>` `<k-tree-node>` | `Tree.js` | Expandable tree; nodes have `label`, `icon`, `href`, `expanded` | [tree.html](https://dustinpoissant.github.io/kempo-ui/components/tree.html) |
84
+
85
+ ---
86
+
87
+ ## Base Classes
88
+
89
+ All in `src/components/`. Built on Lit.
90
+
91
+ ### ShadowComponent ← LitElement
92
+
93
+ Standard shadow-DOM component. **kempo-css is automatically injected** into the shadow root alongside `static styles`. Use for fully encapsulated components.
94
+
95
+ - Override `render()` → returns a Lit `html` template
96
+ - Override `childrenUpdated()` → called when light-DOM children change (MutationObserver)
97
+ - `createRenderRoot()` returns an inner `div` (not the shadow root itself); `this.shadowRoot` is still the real shadow root
98
+
99
+ ### HybridComponent ← ShadowComponent
100
+
101
+ Renders into both shadow DOM and light DOM. kempo-css present in shadow DOM; light DOM is targetable by external page CSS.
102
+
103
+ - Override `render()` → shadow DOM content (default returns `<slot name="lightRoot"></slot>`)
104
+ - Override `renderLightDom()` → light DOM content (rendered into `this.lightRoot` div after every update)
105
+
106
+ ### LightComponent ← LitElement
107
+
108
+ No shadow root. Renders entirely to light DOM. No kempo-css injection; styles come from the page.
109
+
110
+ - Override `renderLightDom()` → returns a Lit `html` template
111
+ - Same `childrenUpdated()` hook as ShadowComponent
112
+
113
+ ---
114
+
115
+ ## Creating a Custom Component
116
+
117
+ ```js
118
+ import ShadowComponent from 'kempo-ui/src/components/ShadowComponent.js';
119
+ import { html, css } from 'kempo-ui/src/lit-all.min.js';
120
+
121
+ class MyWidget extends ShadowComponent {
122
+ /*
123
+ Reactive Props / Attributes
124
+ */
125
+ static properties = {
126
+ label: { type: String, reflect: true },
127
+ active: { type: Boolean, reflect: true }
128
+ };
129
+
130
+ /*
131
+ Lifecycle callbacks
132
+ */
133
+ constructor() {
134
+ super();
135
+ this.label = '';
136
+ this.active = false;
137
+ }
138
+
139
+ /*
140
+ Event Liseners
141
+ */
142
+ click(){
143
+ // Do something
144
+ }
145
+
146
+ /*
147
+ View
148
+ */
149
+ render() {
150
+ return html`
151
+ <button
152
+ class="primary"
153
+ @click=${this.click}
154
+ >
155
+ <strong>${this.label}</strong>
156
+ <slot></slot>
157
+ </button>
158
+ `;
159
+ }
160
+
161
+ static styles = css`
162
+ :host {
163
+ display: block;
164
+ border: 1px solid transparent;
165
+ }
166
+ :host([active]) {
167
+ border-color: var(--c_primary);
168
+ }
169
+ `;
170
+
171
+ }
172
+
173
+ customElements.define('my-widget', MyWidget);
174
+ ```
175
+
176
+ Key patterns:
177
+ - `static properties` declares Lit reactive properties; `reflect: true` mirrors the value to an HTML attribute
178
+ - `static styles` is a `css` tagged template; injected alongside kempo-css in shadow DOM
179
+ - `customElements.define` at the bottom of the file registers the element
180
+ - Use `this.dispatchEvent(new CustomEvent('change', { detail: {...}, bubbles: true }))` for events
181
+ - For internal reactive state not exposed as an attribute, use `state: true` in `static properties` (reactive, not reflected): `myProp: { state: true }`
182
+ - For true non-reactive private data, use Symbol keys (`const key = Symbol();` and `this[key] = value`) — avoid `#private` fields due to poor Safari support
183
+
184
+ ### propConverters
185
+
186
+ For non-standard boolean attribute patterns, import from `src/utils/propConverters.js`:
187
+
188
+ ```js
189
+ import { boolExists, boolTrueFalse } from 'kempo-ui/src/utils/propConverters.js';
190
+
191
+ static properties = {
192
+ active: { converter: boolExists, reflect: true }, // presence = true, absent = false
193
+ enabled: { converter: boolTrueFalse, reflect: true } // attribute value is "true"/"false"
194
+ };
195
+ ```
196
+
197
+ ---
198
+
199
+ ## kempo-css
200
+
201
+ kempo-css is injected automatically into every shadow root by `ShadowComponent`. Key CSS custom properties:
202
+
203
+ | Variable | Description |
204
+ |----------|-------------|
205
+ | `--c_primary` | Primary brand color |
206
+ | `--c_secondary` | Secondary color |
207
+ | `--c_bg` | Background |
208
+ | `--c_border` | Border color |
209
+ | `--tc_primary` | Primary text color |
210
+ | `--tc_muted` | Muted text color |
211
+ | `--spacer` | Base spacing unit |
212
+ | `--spacer_h` | Half spacer |
213
+ | `--radius` | Border radius |
214
+ | `--animation_ms` | Transition duration |
215
+ | `--container_width` | Max content width |
216
+
217
+ Common utility classes (usable inside shadow DOM via kempo-css injected styles):
218
+
219
+ - Layout: `row`, `span-*`, `t-span-*`, `d-span-*`, `d-b`, `d-ib`, `d-f`, `d-if`
220
+ - Spacing: `p`, `px`, `py`, `m`, `mx`, `my`, `mb`, `mt`
221
+ - Typography: `tc-primary`, `tc-muted`, `ta-center`
222
+ - Buttons: `btn`, `btn primary`, `btn secondary`, `btn danger`, `btn ghost`
223
+ - Cards: `card`
224
+ - Badges: `badge`, `pill`
225
+
226
+ Full kempo-css docs: https://raw.githubusercontent.com/dustinpoissant/kempo-css/refs/heads/main/llms.txt
227
+
228
+ ---
229
+
230
+ ## Utilities
231
+
232
+ Located in `src/utils/`. Import individually.
233
+
234
+ | Module | Named Exports | Description | Docs |
235
+ |--------|--------------|-------------|------|
236
+ | `debounce.js` | `default` | `debounce(fn, ms)` — delay fn until calls stop | [debounce.html](https://dustinpoissant.github.io/kempo-ui/utils/debounce.html) |
237
+ | `wait.js` | `wait`, `waitFrames` | `wait(ms)` → Promise; `waitFrames(n)` → Promise after n animation frames | [wait.html](https://dustinpoissant.github.io/kempo-ui/utils/wait.html) |
238
+ | `theme.js` | `setTheme`, `getTheme`, `subscribeToTheme`, `initTheme`, `getCalculatedTheme` | Manage light/dark/auto theme; persists to localStorage | [theme.html](https://dustinpoissant.github.io/kempo-ui/utils/theme.html) |
239
+ | `propConverters.js` | `boolExists`, `boolTrueFalse` | Lit property converters for boolean attributes | [propConverters.html](https://dustinpoissant.github.io/kempo-ui/utils/propConverters.html) |
240
+ | `context.js` | `default` | `createContext(key, initialValue)` → `{ get, set, subscribe }` pub/sub state | [context.html](https://dustinpoissant.github.io/kempo-ui/utils/context.html) |
241
+ | `cookie.js` | `saveCookie`, `getCookie`, `deleteCookie` | Get/set/delete browser cookies | [cookie.html](https://dustinpoissant.github.io/kempo-ui/utils/cookie.html) |
242
+ | `drag.js` | `default` | `drag(options)` — attach mouse/touch drag listeners to an element; options: `element`, `callback`, `startCallback`, `moveCallback`, `endCallback`, `preventScroll` | [drag.html](https://dustinpoissant.github.io/kempo-ui/utils/drag.html) |
243
+ | `object.js` | `toJson`, `flattenObject`, `flattenedObjects`, `objectSummary`, `clone`, `equalObjs`, `prune`, `getAllKeys`, `getDifferencesKeys`, `diff`, `mapObject` | Object utilities | [object.html](https://dustinpoissant.github.io/kempo-ui/utils/object.html) |
244
+ | `string.js` | `camelToDash`, `dashToCamel`, `isCamelCase`, `getCase`, `escapeHTML`, `unescapeHTML`, `trim`, `compoundKey`, `toTitleCase` | String utilities | [string.html](https://dustinpoissant.github.io/kempo-ui/utils/string.html) |
245
+ | `type.js` | `typeOf`, `isType` | Type-checking helpers | [type.html](https://dustinpoissant.github.io/kempo-ui/utils/type.html) |
246
+ | `formatTimestamp.js` | `default` | Format a Date/timestamp as a human-readable string | [formatTimestamp.html](https://dustinpoissant.github.io/kempo-ui/utils/formatTimestamp.html) |
247
+ | `formatCode.js` | `default` | Beautify/format a code string | — |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo-ui",
3
- "version": "0.1.6",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "A Lit based web-component library",
6
6
  "main": "index.js",
@@ -21,8 +21,7 @@
21
21
  "test": "npx kempo-test",
22
22
  "test:gui": "npx kempo-test --gui",
23
23
  "test:browser": "npx kempo-test -b",
24
- "test:node": "npx kempo-test -n",
25
- "update-kempo-css": "node scripts/update-kempo-css.js"
24
+ "test:node": "npx kempo-test -n"
26
25
  },
27
26
  "repository": {
28
27
  "type": "git",
@@ -43,6 +42,6 @@
43
42
  },
44
43
  "dependencies": {
45
44
  "@inquirer/prompts": "^8.3.0",
46
- "kempo-css": "^1.3.13"
45
+ "kempo-css": "^2.1.1"
47
46
  }
48
47
  }