kempo-ui 0.0.2 → 0.0.4

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 (278) hide show
  1. package/.github/copilot-instructions.md +149 -149
  2. package/.github/workflows/publish-major.yml +39 -0
  3. package/.github/workflows/publish-minor.yml +39 -0
  4. package/.github/workflows/{publish-npm.yml → publish-patch.yml} +44 -44
  5. package/.vscode/settings.json +2 -0
  6. package/CONTRIBUTING.md +149 -149
  7. package/README.md +0 -0
  8. package/dist/kempo-hljs.css +1 -0
  9. package/dist/kempo-vars.css +0 -0
  10. package/dist/src/components/Accordion.js +36 -0
  11. package/dist/src/components/Card.js +37 -0
  12. package/dist/src/components/Collapsible.js +41 -0
  13. package/dist/src/components/ContentSlider.js +44 -0
  14. package/dist/src/components/Dialog.js +113 -0
  15. package/dist/src/components/FocusCapture.js +7 -0
  16. package/dist/src/components/Icon.js +10 -0
  17. package/dist/src/components/Import.js +1 -0
  18. package/dist/src/components/PersistantCollapsible.js +1 -0
  19. package/dist/src/components/PhotoViewer.js +135 -0
  20. package/dist/src/components/Resize.js +96 -0
  21. package/dist/src/components/ShadowComponent.js +1 -0
  22. package/dist/src/components/ShowMore.js +42 -0
  23. package/dist/src/components/SideMenu.js +97 -0
  24. package/dist/src/components/Split.js +84 -0
  25. package/dist/src/components/Tabs.js +155 -0
  26. package/dist/src/components/Tags.js +69 -0
  27. package/dist/src/components/ThemeSwitcher.js +23 -0
  28. package/dist/src/components/Timestamp.js +1 -0
  29. package/dist/src/lit-all.min.js +120 -0
  30. package/dist/src/utils/debounce.js +1 -0
  31. package/dist/src/utils/drag.js +1 -0
  32. package/dist/src/utils/formatTimestamp.js +1 -0
  33. package/dist/src/utils/propConverters.js +1 -0
  34. package/dist/src/utils/watchWindowSize.js +1 -0
  35. package/docs/components/accordion.html +166 -0
  36. package/docs/components/card.html +92 -0
  37. package/docs/components/collapsible.html +198 -0
  38. package/docs/components/content-slider.html +223 -0
  39. package/docs/components/dialog.html +251 -0
  40. package/docs/components/focus-capture.html +67 -0
  41. package/docs/components/icon.html +158 -0
  42. package/docs/components/import.html +73 -0
  43. package/docs/components/persistant-collapsible.html +123 -0
  44. package/docs/components/photo-viewer.html +226 -0
  45. package/docs/components/resize.html +178 -0
  46. package/docs/components/show-more.html +129 -0
  47. package/docs/components/side-menu.html +159 -0
  48. package/docs/components/split.html +147 -0
  49. package/docs/components/table.html +312 -0
  50. package/docs/components/tableControls.html +77 -0
  51. package/docs/components/tableCustomFields.html +113 -0
  52. package/docs/components/tableFetchRecords.html +114 -0
  53. package/docs/components/tableFieldSortHide.html +75 -0
  54. package/docs/components/tablePagination.html +100 -0
  55. package/docs/components/tableRecordEditing.html +144 -0
  56. package/docs/components/tableRecordFiltering.html +88 -0
  57. package/docs/components/tableRecordHiding.html +80 -0
  58. package/docs/components/tableRecordSearching.html +75 -0
  59. package/docs/components/tableRecordSelection.html +75 -0
  60. package/docs/components/tableRowControls.html +78 -0
  61. package/docs/components/tableSorting.html +73 -0
  62. package/docs/components/tabs.html +180 -0
  63. package/docs/components/tags.html +110 -0
  64. package/docs/components/theme-switcher.html +126 -0
  65. package/docs/components/timestamp.html +82 -0
  66. package/docs/components/toast.html +319 -0
  67. package/docs/components/toggle.html +156 -0
  68. package/docs/dev.config.json +20 -0
  69. package/docs/icons/add.svg +1 -0
  70. package/docs/icons/arrow-back.svg +1 -0
  71. package/docs/icons/arrow-down-double.svg +1 -0
  72. package/docs/icons/arrow-down.svg +1 -0
  73. package/docs/icons/arrow-forward.svg +1 -0
  74. package/docs/icons/arrow-up-double.svg +1 -0
  75. package/docs/icons/arrow-up.svg +1 -0
  76. package/docs/icons/cards.svg +1 -0
  77. package/docs/icons/check.svg +1 -0
  78. package/docs/icons/chevron-left.svg +1 -0
  79. package/docs/icons/chevron-right.svg +1 -0
  80. package/docs/icons/close.svg +2 -0
  81. package/docs/icons/compare.svg +1 -0
  82. package/docs/icons/delete.svg +1 -0
  83. package/docs/icons/drag-handle.svg +1 -0
  84. package/docs/icons/drawing2.svg +124 -0
  85. package/docs/icons/edit.svg +1 -0
  86. package/docs/icons/error.svg +1 -0
  87. package/docs/icons/export-file.svg +1 -0
  88. package/docs/icons/file-text.svg +1 -0
  89. package/docs/icons/file.svg +1 -0
  90. package/docs/icons/filter-off.svg +1 -0
  91. package/docs/icons/filter.svg +1 -0
  92. package/docs/icons/first.svg +1 -0
  93. package/docs/icons/folder-clear.svg +1 -0
  94. package/docs/icons/folder-create.svg +1 -0
  95. package/docs/icons/folder-open.svg +1 -0
  96. package/docs/icons/folder.svg +1 -0
  97. package/docs/icons/hide.svg +1 -0
  98. package/docs/icons/image.svg +1 -0
  99. package/docs/icons/label-add.svg +1 -0
  100. package/docs/icons/label.svg +1 -0
  101. package/docs/icons/last.svg +1 -0
  102. package/docs/icons/menu.svg +1 -0
  103. package/docs/icons/mode-auto.svg +1 -0
  104. package/docs/icons/mode-dark.svg +1 -0
  105. package/docs/icons/mode-light.svg +1 -0
  106. package/docs/icons/open-in-browser.svg +1 -0
  107. package/docs/icons/pause.svg +1 -0
  108. package/docs/icons/play.svg +1 -0
  109. package/docs/icons/refresh.svg +1 -0
  110. package/docs/icons/remove.svg +1 -0
  111. package/docs/icons/save.svg +1 -0
  112. package/docs/icons/search.svg +1 -0
  113. package/docs/icons/settings.svg +1 -0
  114. package/docs/icons/show.svg +1 -0
  115. package/docs/icons/storage.svg +1 -0
  116. package/docs/icons/table-visibility.svg +1 -0
  117. package/docs/icons/tag.svg +1 -0
  118. package/docs/icons/tools.svg +1 -0
  119. package/docs/icons/trash-x.svg +1 -0
  120. package/docs/icons/warning.svg +1 -0
  121. package/docs/index.html +28 -21
  122. package/docs/kempo-hljs.css +1 -0
  123. package/docs/media/civic.jpg +0 -0
  124. package/docs/media/corvette.jpg +0 -0
  125. package/docs/media/evo.jpg +0 -0
  126. package/docs/media/gtr.jpg +0 -0
  127. package/docs/media/nsx.jpg +0 -0
  128. package/docs/nav.inc.html +67 -0
  129. package/docs/nav.inc.js +4 -0
  130. package/{config/production.json → docs/prod.config.json} +20 -16
  131. package/docs/src/components/Accordion.js +36 -0
  132. package/docs/src/components/Card.js +37 -0
  133. package/docs/src/components/Collapsible.js +41 -0
  134. package/docs/src/components/ContentSlider.js +44 -0
  135. package/docs/src/components/Dialog.js +113 -0
  136. package/docs/src/components/FocusCapture.js +7 -0
  137. package/docs/src/components/HybridComponent.js +1 -0
  138. package/docs/src/components/Icon.js +10 -0
  139. package/docs/src/components/Import.js +1 -0
  140. package/docs/src/components/LightComponent.js +1 -0
  141. package/docs/src/components/PersistantCollapsible.js +1 -0
  142. package/docs/src/components/PhotoViewer.js +135 -0
  143. package/docs/src/components/Resize.js +96 -0
  144. package/docs/src/components/ShadowComponent.js +1 -0
  145. package/docs/src/components/ShowMore.js +42 -0
  146. package/docs/src/components/SideMenu.js +97 -0
  147. package/docs/src/components/Split.js +84 -0
  148. package/docs/src/components/Tabs.js +155 -0
  149. package/docs/src/components/Tags.js +69 -0
  150. package/docs/src/components/ThemeSwitcher.js +23 -0
  151. package/docs/src/components/Timestamp.js +1 -0
  152. package/docs/src/lit-all.min.js +120 -0
  153. package/docs/src/utils/debounce.js +1 -0
  154. package/docs/src/utils/drag.js +1 -0
  155. package/docs/src/utils/formatTimestamp.js +1 -0
  156. package/docs/src/utils/propConverters.js +1 -0
  157. package/docs/src/utils/watchWindowSize.js +1 -0
  158. package/docs/styles.css +6 -0
  159. package/docs/utils/debounce.html +78 -0
  160. package/docs/utils/drag.html +104 -0
  161. package/docs/utils/formatTimestamp.html +114 -0
  162. package/docs/utils/propConverters.html +132 -0
  163. package/docs/utils/watchWindowSize.html +166 -0
  164. package/icons/add.svg +1 -0
  165. package/icons/arrow-back.svg +1 -0
  166. package/icons/arrow-down-double.svg +1 -0
  167. package/icons/arrow-down.svg +1 -0
  168. package/icons/arrow-forward.svg +1 -0
  169. package/icons/arrow-up-double.svg +1 -0
  170. package/icons/arrow-up.svg +1 -0
  171. package/icons/cards.svg +1 -0
  172. package/icons/check.svg +1 -0
  173. package/icons/chevron-left.svg +1 -0
  174. package/icons/chevron-right.svg +1 -0
  175. package/icons/close.svg +2 -0
  176. package/icons/compare.svg +1 -0
  177. package/icons/delete.svg +1 -0
  178. package/icons/drag-handle.svg +1 -0
  179. package/icons/drawing2.svg +124 -0
  180. package/icons/edit.svg +1 -0
  181. package/icons/error.svg +1 -0
  182. package/icons/export-file.svg +1 -0
  183. package/icons/file-text.svg +1 -0
  184. package/icons/file.svg +1 -0
  185. package/icons/filter-off.svg +1 -0
  186. package/icons/filter.svg +1 -0
  187. package/icons/first.svg +1 -0
  188. package/icons/folder-clear.svg +1 -0
  189. package/icons/folder-create.svg +1 -0
  190. package/icons/folder-open.svg +1 -0
  191. package/icons/folder.svg +1 -0
  192. package/icons/hide.svg +1 -0
  193. package/icons/image.svg +1 -0
  194. package/icons/label-add.svg +1 -0
  195. package/icons/label.svg +1 -0
  196. package/icons/last.svg +1 -0
  197. package/icons/menu.svg +1 -0
  198. package/icons/mode-auto.svg +1 -0
  199. package/icons/mode-dark.svg +1 -0
  200. package/icons/mode-light.svg +1 -0
  201. package/icons/open-in-browser.svg +1 -0
  202. package/icons/pause.svg +1 -0
  203. package/icons/play.svg +1 -0
  204. package/icons/refresh.svg +1 -0
  205. package/icons/remove.svg +1 -0
  206. package/icons/save.svg +1 -0
  207. package/icons/search.svg +1 -0
  208. package/icons/settings.svg +1 -0
  209. package/icons/show.svg +1 -0
  210. package/icons/storage.svg +1 -0
  211. package/icons/table-visibility.svg +1 -0
  212. package/icons/tag.svg +1 -0
  213. package/icons/tools.svg +1 -0
  214. package/icons/trash-x.svg +1 -0
  215. package/icons/warning.svg +1 -0
  216. package/package.json +2 -2
  217. package/scripts/build.js +109 -138
  218. package/scripts/docs.js +62 -60
  219. package/src/components/Accordion.js +229 -0
  220. package/src/components/Card.js +66 -0
  221. package/src/components/Collapsible.js +109 -0
  222. package/src/components/ContentSlider.js +205 -0
  223. package/src/components/Dialog.js +368 -0
  224. package/src/components/FocusCapture.js +23 -0
  225. package/src/components/HybridComponent.js +40 -40
  226. package/src/components/Icon.js +155 -0
  227. package/src/components/Import.js +104 -0
  228. package/src/components/LightComponent.js +32 -32
  229. package/src/components/PersistantCollapsible.js +69 -0
  230. package/src/components/PhotoViewer.js +368 -0
  231. package/src/components/Resize.js +210 -0
  232. package/src/components/ShadowComponent.js +32 -17
  233. package/src/components/ShowMore.js +109 -0
  234. package/src/components/SideMenu.js +167 -0
  235. package/src/components/Sortable.js +193 -0
  236. package/src/components/Split.js +192 -0
  237. package/src/components/Table.js +1202 -0
  238. package/src/components/Tabs.js +428 -0
  239. package/src/components/Tags.js +253 -0
  240. package/src/components/ThemeSwitcher.js +108 -0
  241. package/src/components/Timestamp.js +31 -0
  242. package/src/components/Toast.js +454 -0
  243. package/src/components/Toggle.js +173 -0
  244. package/src/components/tableControls/DeleteRecord.js +29 -0
  245. package/src/components/tableControls/Edit.js +88 -0
  246. package/src/components/tableControls/ExportCSV.js +71 -0
  247. package/src/components/tableControls/ExportJson.js +55 -0
  248. package/src/components/tableControls/FieldSortHide.js +76 -0
  249. package/src/components/tableControls/Filters.js +114 -0
  250. package/src/components/tableControls/FirstPage.js +65 -0
  251. package/src/components/tableControls/HiddenCount.js +45 -0
  252. package/src/components/tableControls/Hide.js +34 -0
  253. package/src/components/tableControls/LastPage.js +65 -0
  254. package/src/components/tableControls/NextPage.js +65 -0
  255. package/src/components/tableControls/PageSelect.js +109 -0
  256. package/src/components/tableControls/PageSize.js +68 -0
  257. package/src/components/tableControls/PrevPage.js +65 -0
  258. package/src/components/tableControls/Search.js +58 -0
  259. package/src/components/tableControls/ShowAll.js +34 -0
  260. package/src/components/tableControls/TableControl.js +105 -0
  261. package/src/kempo-hljs.css +146 -0
  262. package/src/utils/debounce.js +9 -0
  263. package/src/utils/drag.js +80 -0
  264. package/src/utils/formatTimestamp.js +27 -0
  265. package/src/utils/propConverters.js +11 -0
  266. package/src/utils/toTitleCase.js +9 -0
  267. package/src/utils/watchWindowSize.js +16 -0
  268. package/tests/HybridComponent.browser-test.js +214 -214
  269. package/tests/LightComponent.browser-test.js +169 -169
  270. package/tests/ShadowComponent.browser-test.js +130 -130
  271. package/config/development.json +0 -14
  272. package/docs/components/ShadowComponent.js +0 -1
  273. package/src/utils/cli.js +0 -43
  274. package/src/utils/fs-utils.js +0 -41
  275. /package/{docs → dist/src}/components/HybridComponent.js +0 -0
  276. /package/{docs → dist/src}/components/LightComponent.js +0 -0
  277. /package/docs/{utils → src/utils}/cli.js +0 -0
  278. /package/docs/{utils → src/utils}/fs-utils.js +0 -0
package/CONTRIBUTING.md CHANGED
@@ -1,149 +1,149 @@
1
- # Code Contribution Guidelines
2
-
3
- ## Project Structure
4
-
5
- - All code should be in the `src/` directory, with the exception of npm scripts.
6
- - All components should be in the `src/components/` directory.
7
- - All utility function module files should be in the `src/utils/` directory.
8
- - All documnentation should be in the `docs/` directory. This directory is used by GitHub as the "GitHub Pages", so all links need to be relative, and there will be a build script which copies all code to the `docs/` directory.
9
-
10
- ## Coding Style Guidelines
11
-
12
- ### Code Organization
13
- Use multi-line comments to separate code into logical sections. Group related functionality together.
14
- - Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
15
-
16
- ```javascript
17
- /*
18
- Lifecycle Callbacks
19
- */
20
- ```
21
-
22
- ### Avoid single-use variables/functions
23
- Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
24
- - recursion
25
- - scope encapsulation (IIFE)
26
- - context changes
27
-
28
- ### Minimal Comments, Empty Lines, and Spacing
29
-
30
- Use minimal comments. Assume readers understand the language. Some exceptions include:
31
- - complex logic
32
- - anti-patterns
33
- - code organization
34
-
35
- Do not put random empty lines within code; put them where they make sense for readability, for example:
36
- - above and below definitions for functions and classes.
37
- - to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
38
- - above multi-line comments to indicate the comment belongs to the code below
39
-
40
- No empty lines in css.
41
-
42
- End each file with an empty line.
43
-
44
- End each line with a `;` when possible, even if it is optional.
45
-
46
- Avoid unnecessary spacing, for example:
47
- - after the word `if`
48
- - within parentheses for conditional statements
49
-
50
- ```javascript
51
- let count = 1;
52
-
53
- const incrementOdd = (n) => {
54
- if(n % 2 !== 0){
55
- return n++;
56
- }
57
- return n;
58
- };
59
-
60
- count = incrementOdd(count);
61
- ```
62
-
63
- ### Prefer Arrow Functions
64
- Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
65
- - For very basic logic, use implicit returns
66
- - If there is a single parameter, omit the parentheses.
67
- ```javascript
68
- const addOne = n => n + 1;
69
- ```
70
-
71
- ### Module Exports
72
- - If a module has only one export, use the "default" export, not a named export.
73
- - Do not declare the default export as a const or give it a name; just export the value.
74
-
75
- ```javascript
76
- export default (n) => n + 1;
77
- ```
78
- - If a module has multiple exports, use named exports and do not use a "default" export.
79
-
80
- ### Code Reuse
81
- Create utility functions for shared logic.
82
- - If the shared logic is used in a single file, define a utility function in that file.
83
- - If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
84
-
85
- ### Naming
86
- Do not prefix identifiers with underscores.
87
- - Never use leading underscores (`_`) for variable, property, method, or function names.
88
- - Use clear, descriptive names without prefixes.
89
- - When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
90
-
91
- ## Components
92
-
93
- ### Base Component Architecture
94
-
95
- The project provides three base components for different rendering strategies. Choose the appropriate base component and extend it:
96
-
97
- #### ShadowComponent
98
- For components that need shadow DOM encapsulation and automatic `/kempo.css` stylesheet injection.
99
-
100
- ```javascript
101
- import ShadowComponent from './ShadowComponent.js';
102
-
103
- export default class MyComponent extends ShadowComponent {
104
- render() {
105
- return html`<p>Shadow DOM content with scoped styles</p>`;
106
- }
107
- }
108
- ```
109
-
110
- #### LightComponent
111
- For components that render directly to light DOM without shadow DOM encapsulation.
112
-
113
- ```javascript
114
- import LightComponent from './LightComponent.js';
115
-
116
- export default class MyComponent extends LightComponent {
117
- renderLightDom() {
118
- return html`<p>Light DOM content</p>`;
119
- }
120
- }
121
- ```
122
-
123
- #### HybridComponent
124
- For components that need both shadow DOM (with automatic `/kempo.css`) and light DOM rendering.
125
-
126
- ```javascript
127
- import HybridComponent from './HybridComponent.js';
128
-
129
- export default class MyComponent extends HybridComponent {
130
- render() {
131
- return html`<p>Shadow DOM content</p>`;
132
- }
133
-
134
- renderLightDom() {
135
- return html`<p>Light DOM content alongside natural children</p>`;
136
- }
137
- }
138
- ```
139
-
140
- **Important:** Always call `super.updated()` when overriding the `updated()` method in LightComponent or HybridComponent to ensure proper rendering.
141
-
142
- ### Component Architecture and Communication
143
-
144
- - Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
145
- - Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
146
-
147
- - Wrap dependent components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
148
-
149
- - Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
1
+ # Code Contribution Guidelines
2
+
3
+ ## Project Structure
4
+
5
+ - All code should be in the `src/` directory, with the exception of npm scripts.
6
+ - All components should be in the `src/components/` directory.
7
+ - All utility function module files should be in the `src/utils/` directory.
8
+ - All documnentation should be in the `docs/` directory. This directory is used by GitHub as the "GitHub Pages", so all links need to be relative, and there will be a build script which copies all code to the `docs/` directory.
9
+
10
+ ## Coding Style Guidelines
11
+
12
+ ### Code Organization
13
+ Use multi-line comments to separate code into logical sections. Group related functionality together.
14
+ - Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
15
+
16
+ ```javascript
17
+ /*
18
+ Lifecycle Callbacks
19
+ */
20
+ ```
21
+
22
+ ### Avoid single-use variables/functions
23
+ Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
24
+ - recursion
25
+ - scope encapsulation (IIFE)
26
+ - context changes
27
+
28
+ ### Minimal Comments, Empty Lines, and Spacing
29
+
30
+ Use minimal comments. Assume readers understand the language. Some exceptions include:
31
+ - complex logic
32
+ - anti-patterns
33
+ - code organization
34
+
35
+ Do not put random empty lines within code; put them where they make sense for readability, for example:
36
+ - above and below definitions for functions and classes.
37
+ - to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
38
+ - above multi-line comments to indicate the comment belongs to the code below
39
+
40
+ No empty lines in css.
41
+
42
+ End each file with an empty line.
43
+
44
+ End each line with a `;` when possible, even if it is optional.
45
+
46
+ Avoid unnecessary spacing, for example:
47
+ - after the word `if`
48
+ - within parentheses for conditional statements
49
+
50
+ ```javascript
51
+ let count = 1;
52
+
53
+ const incrementOdd = (n) => {
54
+ if(n % 2 !== 0){
55
+ return n++;
56
+ }
57
+ return n;
58
+ };
59
+
60
+ count = incrementOdd(count);
61
+ ```
62
+
63
+ ### Prefer Arrow Functions
64
+ Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
65
+ - For very basic logic, use implicit returns
66
+ - If there is a single parameter, omit the parentheses.
67
+ ```javascript
68
+ const addOne = n => n + 1;
69
+ ```
70
+
71
+ ### Module Exports
72
+ - If a module has only one export, use the "default" export, not a named export.
73
+ - Do not declare the default export as a const or give it a name; just export the value.
74
+
75
+ ```javascript
76
+ export default (n) => n + 1;
77
+ ```
78
+ - If a module has multiple exports, use named exports and do not use a "default" export.
79
+
80
+ ### Code Reuse
81
+ Create utility functions for shared logic.
82
+ - If the shared logic is used in a single file, define a utility function in that file.
83
+ - If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
84
+
85
+ ### Naming
86
+ Do not prefix identifiers with underscores.
87
+ - Never use leading underscores (`_`) for variable, property, method, or function names.
88
+ - Use clear, descriptive names without prefixes.
89
+ - When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
90
+
91
+ ## Components
92
+
93
+ ### Base Component Architecture
94
+
95
+ The project provides three base components for different rendering strategies. Choose the appropriate base component and extend it:
96
+
97
+ #### ShadowComponent
98
+ For components that need shadow DOM encapsulation and automatic `/kempo.css` stylesheet injection.
99
+
100
+ ```javascript
101
+ import ShadowComponent from './ShadowComponent.js';
102
+
103
+ export default class MyComponent extends ShadowComponent {
104
+ render() {
105
+ return html`<p>Shadow DOM content with scoped styles</p>`;
106
+ }
107
+ }
108
+ ```
109
+
110
+ #### LightComponent
111
+ For components that render directly to light DOM without shadow DOM encapsulation.
112
+
113
+ ```javascript
114
+ import LightComponent from './LightComponent.js';
115
+
116
+ export default class MyComponent extends LightComponent {
117
+ renderLightDom() {
118
+ return html`<p>Light DOM content</p>`;
119
+ }
120
+ }
121
+ ```
122
+
123
+ #### HybridComponent
124
+ For components that need both shadow DOM (with automatic `/kempo.css`) and light DOM rendering.
125
+
126
+ ```javascript
127
+ import HybridComponent from './HybridComponent.js';
128
+
129
+ export default class MyComponent extends HybridComponent {
130
+ render() {
131
+ return html`<p>Shadow DOM content</p>`;
132
+ }
133
+
134
+ renderLightDom() {
135
+ return html`<p>Light DOM content alongside natural children</p>`;
136
+ }
137
+ }
138
+ ```
139
+
140
+ **Important:** Always call `super.updated()` when overriding the `updated()` method in LightComponent or HybridComponent to ensure proper rendering.
141
+
142
+ ### Component Architecture and Communication
143
+
144
+ - Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
145
+ - Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
146
+
147
+ - Wrap dependent components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
148
+
149
+ - Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
package/README.md ADDED
File without changes
@@ -0,0 +1 @@
1
+ :root,[theme="light"]{--c_text:#000000;--c_keyword:#0000ff;--c_builtin:#00b0e8;--c_number:#709756;--c_string:#a31515;--c_regex:#914525;--c_function:inherit;--c_comment:#008000;--c_doc:#808080;--c_tag:#7d7d7d;--c_var:#b436bf;--c_attr:#ff0000;--c_section:#a31515;--c_selector:#0000ff;--c_addition:#a31515;--c_deletion:#2b91af;--c_caret:black}[auto-theme="dark"]:not([theme="light"]),[theme="dark"]{--c_text:#DCDCDC;--c_keyword:#569CD6;--c_builtin:#4EC9B0;--c_number:#B8D7A3;--c_string:#D69D85;--c_regex:#9A5334;--c_function:inehrit;--c_comment:#57A64A;--c_doc:#608B4E;--c_tag:#9B9B9B;--c_var:#BD63C5;--c_attr:#9CDCFE;--c_section:#ffd700;--c_selector:#569CD6;--c_addition:#144212;--c_deletion:#600;--c_caret:white}.hljs{display:block;overflow-x:auto;color:var(--c_text)}.hljs-keyword,.hljs-literal,.hljs-symbol,.hljs-name,.hljs-link{color:var(--c_keyword)}.hljs-link{text-decoration:underline}.hljs-built_in,.hljs-type{color:var(--c_builtin)}.hljs-number,.hljs-class{color:var(--c_number)}.hljs-string,.hljs-meta-string{color:var(--c_string)}.hljs-regexp,.hljs-template-tag{color:var(--c_regex)}.hljs-subst,.hljs-function,.hljs-title,.hljs-params,.hljs-formula{color:var(--c_function)}.hljs-comment,.hljs-quote{color:var(--c_comment);font-style:italic}.hljs-doctag{color:var(--c_doc)}.hljs-meta,.hljs-meta-keyword,.hljs-tag{color:var(--c_tag)}.hljs-variable,.hljs-template-variable{color:var(--c_var)}.hljs-attr,.hljs-attribute,.hljs-builtin-name{color:var(--c_attr)}.hljs-section{color:var(--c_section)}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}.hljs-bullet,.hljs-selector-tag,.hljs-selector-id,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo{color:var(--c_selector)}.hljs-addition{background-color:var(--c_addition);display:inline-block;width:100%}.hljs-deletion{background-color:var(--c_deletion);display:inline-block;width:100%}
File without changes
@@ -0,0 +1,36 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolTrueFalse}from"../utils/propConverters.js";export default class Accordion extends ShadowComponent{static properties={};getHeader(e){return this.querySelector(`k-accordion-header[for-panel="${e}"]`)}getPanel(e){return this.querySelector(`k-accordion-panel[name="${e}"]`)}openPanel(e){const t=this.querySelector('k-accordion-panel[active="true"]');if(t&&t.name!==e){t.active=!1;const e=this.getHeader(t.name);e&&(e.active=!1)}const o=this.getPanel(e);if(o){o.active=!0,o.transitioning=!0,setTimeout(()=>{o.transitioning=!1},parseInt(getComputedStyle(this).getPropertyValue("--animation_ms")||256));const t=this.getHeader(e);t&&(t.active=!0),this.dispatchEvent(new CustomEvent("openpanel",{detail:{panelName:e}}))}}closePanel(e){const t=this.getPanel(e);if(t){t.active=!1,t.transitioning=!0,setTimeout(()=>{t.transitioning=!1},parseInt(getComputedStyle(this).getPropertyValue("--animation_ms")||256));const o=this.getHeader(e);o&&(o.active=!1),this.dispatchEvent(new CustomEvent("closepanel",{detail:{panelName:e}}))}}togglePanel(e){const t=this.getPanel(e);t&&(t.active?this.closePanel(e):this.openPanel(e),this.dispatchEvent(new CustomEvent("togglepanel",{detail:{panelName:e}})))}get activeHeader(){return this.querySelector('k-accordion-header[active="true"]')}get activePanel(){return this.querySelector('k-accordion-panel[active="true"]')}static styles=css`
2
+ :host {
3
+ display: block;
4
+ border: 1px solid var(--c_border);
5
+ border-radius: var(--radius);
6
+ }
7
+ ::slotted(k-accordion-header) {
8
+ border-top: 1px solid var(--c_border);
9
+ }
10
+ ::slotted(k-accordion-header[active="true"]) {
11
+ border-bottom: 1px solid var(--c_border);
12
+ }
13
+ ::slotted(k-accordion-header:first-of-type) {
14
+ border-top: 0;
15
+ }
16
+ ::slotted(k-accordion-header:last-of-type:not([active="true"])) {
17
+ border-bottom: 0;
18
+ }
19
+ `;render(){return html`<slot></slot>`}}export class AccordionHeader extends ShadowComponent{static properties={forPanel:{type:String,reflect:!0,attribute:"for-panel"},active:{type:Boolean,reflect:!0,converter:boolTrueFalse}};constructor(){super(),this.forPanel="",this.active=!1}handleClick=()=>{this.accordion?.togglePanel(this.forPanel)};connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClick)}get accordion(){return this.closest("k-accordion")}static styles=css`
20
+ :host {
21
+ display: block;
22
+ padding: 1rem;
23
+ cursor: pointer;
24
+ }
25
+ `;render(){return html`<slot></slot>`}}export class AccordionPanel extends ShadowComponent{static properties={name:{type:String,reflect:!0},active:{type:Boolean,reflect:!0,converter:boolTrueFalse},transitioning:{type:Boolean,reflect:!0,converter:boolTrueFalse}};constructor(){super(),this.name="",this.active=!1,this.transitioning=!1}get accordion(){return this.closest("k-accordion")}static styles=css`
26
+ :host {
27
+ display: block;
28
+ interpolate-size: allow-keywords;
29
+ height: 0;
30
+ overflow: hidden;
31
+ transition: height var(--animation_ms, 256ms) ease-in-out;
32
+ }
33
+ :host([active="true"]) {
34
+ height: max-content;
35
+ }
36
+ `;render(){return html`<slot></slot>`}}customElements.define("k-accordion",Accordion),customElements.define("k-accordion-header",AccordionHeader),customElements.define("k-accordion-panel",AccordionPanel);
@@ -0,0 +1,37 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";export default class Card extends ShadowComponent{static properties={label:{type:String,reflect:!0}};constructor(){super(),this.label=""}static styles=css`
2
+ :host {
3
+ display: block;
4
+ }
5
+ #card {
6
+ border: 1px solid var(--c_border);
7
+ border-radius: var(--radius);
8
+ margin-bottom: var(--spacer);
9
+ padding: var(--spacer);
10
+ position: relative;
11
+ background-color: var(--c_bg);
12
+ }
13
+ #label {
14
+ position: absolute;
15
+ top: -1.25em;
16
+ left: 1.25em;
17
+ background-color: var(--c_bg);
18
+ border: 1px solid var(--c_border);
19
+ border-radius: var(--radius);
20
+ padding: var(--spacer_h);
21
+ }
22
+ :host([label]) {
23
+ padding-top: calc(1.5 * var(--spacer));
24
+ margin-top: var(--spacer);
25
+ }
26
+ :host([label]) #card {
27
+ padding-top: calc(1.5 * var(--spacer));
28
+ }
29
+ :host(:not([label])) #label {
30
+ display: none;
31
+ }
32
+ `;render(){return html`
33
+ <div id="card">
34
+ <div id="label">${this.label}</div>
35
+ <slot></slot>
36
+ </div>
37
+ `}}window.customElements.define("k-card",Card);
@@ -0,0 +1,41 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolTrueFalse}from"../utils/propConverters.js";import"./Icon.js";export default class Collapsible extends ShadowComponent{static properties={opened:{type:Boolean,reflect:!0,converter:boolTrueFalse}};constructor(){super(),this.opened=!1}handleLabelClick=()=>{this.toggle()};updated(e){super.updated(e),e.has("opened")&&(this.dispatchEvent(new CustomEvent("openedchanged",{detail:this.opened?"open":"close"})),this.dispatchEvent(new CustomEvent(this.opened?"open":"close")))}open(){this.opened=!0}close(){this.opened=!1}toggle(){this.opened=!this.opened,this.dispatchEvent(new CustomEvent("openedtoggled"))}static styles=css`
2
+ :host {
3
+ display: block;
4
+ }
5
+ #labelContainer {
6
+ display: flex;
7
+ cursor: pointer;
8
+ }
9
+ #label {
10
+ flex: 1 1 auto;
11
+ }
12
+ #labelIcon {
13
+ flex: 0 0 none;
14
+ opacity: 0.5;
15
+ transform: rotate(90deg);
16
+ transition: transform var(--animation_ms, 256ms);
17
+ }
18
+ #labelContainer:hover #labelIcon {
19
+ opacity: 1;
20
+ }
21
+ :host([opened="true"]) #labelIcon {
22
+ transform: rotate(-90deg);
23
+ }
24
+ :host(:not([opened="true"])) #content {
25
+ display: none;
26
+ }
27
+ `;render(){return html`
28
+ <div id="labelContainer" @click=${this.handleLabelClick}>
29
+ <div id="label">
30
+ <slot name="label"></slot>
31
+ </div>
32
+ <div id="labelIcon">
33
+ <slot name="labelIcon">
34
+ <k-icon name="chevron-right"></k-icon>
35
+ </slot>
36
+ </div>
37
+ </div>
38
+ <div id="content">
39
+ <slot></slot>
40
+ </div>
41
+ `}}customElements.define("k-collapsible",Collapsible);
@@ -0,0 +1,44 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolTrueFalse}from"../utils/propConverters.js";import"./Icon.js";export default class ContentSlider extends ShadowComponent{static properties={index:{type:Number,reflect:!0},controls:{type:Boolean,reflect:!0,converter:boolTrueFalse},globalControls:{type:Boolean,reflect:!0,attribute:"global-controls",converter:boolTrueFalse},keyboardControls:{type:Boolean,reflect:!0,attribute:"keyboard-controls",converter:boolTrueFalse},loop:{type:Boolean,reflect:!0,converter:boolTrueFalse}};constructor(){super(),this.index=0,this.controls=!0,this.globalControls=!1,this.keyboardControls=!0,this.loop=!1,this.content=[],this.tabIndex=0}handlePrevClick=()=>{this.previous()};handleNextClick=()=>{this.next()};handleKeydown=t=>{"ArrowLeft"===t.code?(t.preventDefault(),this.dispatchEvent(new CustomEvent("keyleft")),this.previous()):"ArrowRight"===t.code&&(t.preventDefault(),this.dispatchEvent(new CustomEvent("keyright")),this.next())};connectedCallback(){super.connectedCallback(),this.updateContent(),this.setupKeyboardControls()}disconnectedCallback(){super.disconnectedCallback(),this.removeKeyboardControls()}updated(t){super.updated(t),t.has("index")&&(this.validateAndSetIndex(),this.renderContent(),this.dispatchEvent(new CustomEvent("change",{detail:{index:this.index}}))),(t.has("keyboardControls")||t.has("globalControls"))&&(this.removeKeyboardControls(),this.setupKeyboardControls())}updateContent(){this.content=[...this.querySelectorAll(":scope > *")],this.validateAndSetIndex(),this.renderContent()}validateAndSetIndex(){if(0===this.content.length)return;const t=Math.max(Math.min(this.content.length-1,this.index),0);this.index!==t&&(this.index=t)}renderContent(){0!==this.content.length&&(this.innerHTML="",this.content[this.index]&&this.appendChild(this.content[this.index]))}setupKeyboardControls(){this.keyboardControls&&(this.globalControls?window.addEventListener("keydown",this.handleKeydown):this.addEventListener("keydown",this.handleKeydown))}removeKeyboardControls(){window.removeEventListener("keydown",this.handleKeydown),this.removeEventListener("keydown",this.handleKeydown)}previous(){let t=this.index-1;this.loop&&t<0&&(t=this.content.length-1),this.dispatchEvent(new CustomEvent("previous",{detail:{index:t}})),this.index=t}next(){let t=this.index+1;this.loop&&t>=this.content.length&&(t=0),this.dispatchEvent(new CustomEvent("next",{detail:{index:t}})),this.index=t}goto(t){this.dispatchEvent(new CustomEvent("goto",{detail:{index:t}})),this.index=t}static styles=css`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ outline: none;
6
+ }
7
+ #prev,
8
+ #next {
9
+ position: absolute;
10
+ top: 50%;
11
+ transform: translateY(-50%);
12
+ font-size: 2rem;
13
+ }
14
+ #next {
15
+ right: 0;
16
+ }
17
+ :host(:not([controls="true"])) #controls {
18
+ display: none;
19
+ }
20
+ `;render(){return html`
21
+ <div id="content">
22
+ <slot></slot>
23
+ </div>
24
+ <div id="controls">
25
+ <button
26
+ id="prev"
27
+ class="no-btn"
28
+ @click=${this.handlePrevClick}
29
+ >
30
+ <slot name="prev">
31
+ <k-icon name="chevron-left"></k-icon>
32
+ </slot>
33
+ </button>
34
+ <button
35
+ id="next"
36
+ class="no-btn"
37
+ @click=${this.handleNextClick}
38
+ >
39
+ <slot name="next">
40
+ <k-icon name="chevron-right"></k-icon>
41
+ </slot>
42
+ </button>
43
+ </div>
44
+ `}}customElements.define("k-content-slider",ContentSlider);
@@ -0,0 +1,113 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css}from"../lit-all.min.js";import{boolExists}from"../utils/propConverters.js";import"./Icon.js";const firstFocusable=t=>t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')[0];export default class Dialog extends ShadowComponent{static properties={opened:{type:Boolean,reflect:!0,converter:boolExists},closeBtn:{type:Boolean,reflect:!0,attribute:"close-btn",converter:boolExists},overlayClose:{type:Boolean,reflect:!0,attribute:"overlay-close",converter:boolExists},confirmText:{type:String,reflect:!0,attribute:"confirm-text"},confirmClasses:{type:String,reflect:!0,attribute:"confirm-classes"},cancelText:{type:String,reflect:!0,attribute:"cancel-text"},cancelClasses:{type:String,reflect:!0,attribute:"cancel-classes"}};constructor(){super(),this.opened=!1,this.closeBtn=!0,this.overlayClose=!0,this.confirmText="",this.confirmClasses="success ml",this.cancelText="",this.cancelClasses="",this.confirmAction=()=>{},this.cancelAction=()=>{},this.closeCallback=()=>{},this.previousFocus=null}handleClick=t=>{const{target:e}=t,o=e.id||e.closest("[id]")?.id;"overlay"===o&&this.overlayClose||"close"===o?this.close():"cancel"===o?(this.cancelAction(t),t.defaultPrevented||this.close()):"confirm"===o&&(this.confirmAction(t),t.defaultPrevented||this.close())};handleKeydown=t=>{27===t.keyCode&&this.close()};connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.handleKeydown)}updated(t){super.updated(t),t.has("opened")&&this.dispatchEvent(new CustomEvent(this.opened?"opened":"close"))}open(){this.opened=!0,window.addEventListener("keydown",this.handleKeydown);const t=this.updateComplete||this.requestUpdate();t&&t.then?t.then(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()}):setTimeout(()=>{const t=this.shadowRoot.querySelector("[autofocus]")||firstFocusable(this.shadowRoot);t&&t.focus()},0)}close(){this.opened=!1,this.blur(),this.closeCallback(),window.removeEventListener("keydown",this.handleKeydown)}toggle(){this.opened?this.close():this.open()}focus(){const t=firstFocusable(this.shadowRoot);t&&(this.previousFocus=document.activeElement,t.focus())}blur(){this.previousFocus&&this.previousFocus.focus()}hasTitle(){return!!this.querySelector('[slot="title"]')}static styles=css`
2
+ :host {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ width: 100vw;
7
+ height: 100vh;
8
+ z-index: 100;
9
+ display: none;
10
+ justify-content: center;
11
+ align-items: center;
12
+ }
13
+ :host([opened]) {
14
+ display: flex;
15
+ }
16
+ #overlay {
17
+ position: absolute;
18
+ width: 100%;
19
+ height: 100%;
20
+ top: 0;
21
+ left: 0;
22
+ background-color: var(--c_overlay);
23
+ border: 0px solid transparent;
24
+ box-shadow: 0 0 0 transparent;
25
+ }
26
+ #wrapper {
27
+ position: relative;
28
+ z-index: 1;
29
+ pointer-events: none;
30
+ }
31
+ #dialog {
32
+ display: flex;
33
+ flex-direction: column;
34
+ min-width: var(--min_width, 20rem);
35
+ width: var(--width, fit-content);
36
+ max-width: var(--max_width, calc(100vw - 4rem));
37
+ min-height: var(--min_height, 12rem);
38
+ height: var(--height, fit-content);
39
+ max-height: var(--max_height, calc(100vh - 4rem));
40
+ background-color: var(--c_bg);
41
+ box-shadow: var(--drop_shadow);
42
+ border-radius: var(--radius);
43
+ pointer-events: all;
44
+ }
45
+ #header {
46
+ display: flex;
47
+ align-items: center;
48
+ }
49
+ #header.has-title {
50
+ border-bottom: 1px solid var(--c_border);
51
+ }
52
+ #title {
53
+ flex: 1 1 auto;
54
+ }
55
+ #close {
56
+ border: 0px;
57
+ background: transparent;
58
+ box-shadow: 0 0 0 transparent;
59
+ color: var(--tc);
60
+ }
61
+ #close k-icon {
62
+ pointer-events: none;
63
+ }
64
+ #body {
65
+ flex: 1 1 auto;
66
+ }
67
+ #footer {
68
+ display: flex;
69
+ justify-content: flex-end;
70
+ padding: var(--spacer_h);
71
+ }
72
+ `;render(){return html`
73
+ <button id="overlay" aria-label="Close the Dialog" @click=${this.handleClick}></button>
74
+ <div id="wrapper">
75
+ <div
76
+ id="dialog"
77
+ role="dialog"
78
+ aria-modal="true"
79
+ aria-labelledby="title"
80
+ >
81
+ <div
82
+ id="header"
83
+ class="${this.hasTitle()?"has-title":""}"
84
+ >
85
+ <div id="title">
86
+ <slot name="title"></slot>
87
+ </div>
88
+ ${this.closeBtn?html`
89
+ <button id="close" @click=${this.handleClick}>
90
+ <k-icon name="close"></k-icon>
91
+ </button>
92
+ `:""}
93
+ </div>
94
+ <div id="body">
95
+ <slot></slot>
96
+ </div>
97
+ ${this.cancelText||this.confirmText?html`
98
+ <div id="footer">
99
+ ${this.cancelText?html`
100
+ <button id="cancel" class="${this.cancelClasses}" @click=${this.handleClick}>
101
+ ${this.cancelText}
102
+ </button>
103
+ `:""}
104
+ ${this.confirmText?html`
105
+ <button id="confirm" class="${this.confirmClasses}" @click=${this.handleClick}>
106
+ ${this.confirmText}
107
+ </button>
108
+ `:""}
109
+ </div>
110
+ `:""}
111
+ </div>
112
+ </div>
113
+ `}static create(t="",e={}){!1!==e.closeExisting&&document.querySelectorAll("k-dialog").forEach(t=>t.close());const{removeOnClose:o=!0,closeCallback:s=()=>{}}=e,i=new Dialog;return Object.assign(i,{opened:!0,...e,closeCallback:(...t)=>{o&&i.remove(),s(...t)}}),t instanceof HTMLElement||t instanceof DocumentFragment?i.appendChild(t):t&&(i.innerHTML=t),e.width&&i.style.setProperty("--width",e.width),e.minWidth&&i.style.setProperty("--min_width",e.minWidth),e.maxWidth&&i.style.setProperty("--max_width",e.maxWidth),e.height&&i.style.setProperty("--height",e.height),e.minHeight&&i.style.setProperty("--min_height",e.minHeight),e.maxHeight&&i.style.setProperty("--max_height",e.maxHeight),document.body.appendChild(i),i.open(),i}static confirm(t,e,o={}){const s=o.title||"Confirm";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeBtn:!1,overlayClose:!1,confirmText:"Yes",confirmClasses:"success ml",confirmAction:()=>e(!0),cancelText:"No",cancelClasses:"danger",cancelAction:()=>e(!1),...o})}static alert(t,e,o={}){const s=o.title||"Alert";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}static error(t,e,o={}){const s=o.title||"Error";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0 tc-danger">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}static success(t,e,o={}){const s=o.title||"Success";return Dialog.create(`\n\t\t\t<h5 slot="title" class="pyh px m0 tc-success">${s}</h5>\n\t\t\t<p class="p">${t}</p>\n\t\t`,{closeCallback:e,cancelText:"Ok",...o})}}customElements.define("k-dialog",Dialog);
@@ -0,0 +1,7 @@
1
+ import{LitElement,html}from"../lit-all.min.js";export default class FocusCapture extends LitElement{static shadowRootOptions={mode:"open",delegatesFocus:!0};afterFocus=()=>{this.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])').focus()};render(){return html`
2
+ <slot></slot>
3
+ <div
4
+ tabindex="0"
5
+ @focus=${this.afterFocus}
6
+ ></div>
7
+ `}}window.customElements.define("k-focus-capture",FocusCapture);
@@ -0,0 +1,10 @@
1
+ import ShadowComponent from"./ShadowComponent.js";import{html,css,unsafeHTML}from"../lit-all.min.js";const cache={},getIconByPath=async t=>(cache[t]||(cache[t]=new Promise(async(e,n)=>{const o=(new AbortController).signal;try{const n=await fetch(t,{signal:o});200===n.status?e(await n.text()):404===n.status&&e(null)}catch(t){"AbortError"!==t.name&&n(t)}}).catch(()=>null)),await cache[t]),getIconByName=t=>{const e=async e=>getIconByPath(`${e}/${t}.svg`);return new Promise(async(t,n)=>{let o;for(let t=0;t<Icon.pathToIcons.length&&!o;t++)try{o=await e(Icon.pathToIcons[t])}catch(t){}t(o||null)})};export default class Icon extends ShadowComponent{static properties={src:{type:String,reflect:!0},name:{type:String,reflect:!0},iconContent:{type:String}};constructor(t=""){super(),this.src="",this.name=t,this.iconContent=""}updated(t){super.updated(),(t.has("src")||t.has("name"))&&this.loadIcon(),t.has("iconContent")&&this.fixSVG()}async loadIcon(){let t;if(this.src?t=await getIconByPath(this.src):this.name&&(t=await getIconByName(this.name)),t)this.iconContent=t;else{const t=this.innerHTML.trim();this.iconContent=t||Icon.fallback}}fixSVG(){setTimeout(()=>{const t=this.querySelector("svg");t&&(t.removeAttribute("width"),t.removeAttribute("height"),t.querySelectorAll("path, rect, circle").forEach(t=>{t.setAttribute("fill","currentColor")}))},0)}static styles=css`
2
+ :host {
3
+ display: inline-block;
4
+ vertical-align: bottom;
5
+ }
6
+ ::slotted(svg), svg {
7
+ height: 1.35em;
8
+ vertical-align: middle;
9
+ }
10
+ `;render(){return this.iconContent?html`${unsafeHTML(this.iconContent)}`:html`<slot></slot>`}static pathToIcons=["/icons"];static fallback='\n\t\t<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M480-79q-16 0-30.5-6T423-102L102-423q-11-12-17-26.5T79-480q0-16 6-31t17-26l321-321q12-12 26.5-17.5T480-881q16 0 31 5.5t26 17.5l321 321q12 11 17.5 26t5.5 31q0 16-5.5 30.5T858-423L537-102q-11 11-26 17t-31 6Zm0-80 321-321-321-321-321 321 321 321Zm-40-281h80v-240h-80v240Zm40 120q17 0 28.5-11.5T520-360q0-17-11.5-28.5T480-400q-17 0-28.5 11.5T440-360q0 17 11.5 28.5T480-320Zm0-160Z"/></svg>\n\t'}window.customElements.define("k-icon",Icon);
@@ -0,0 +1 @@
1
+ import LightComponent from"./LightComponent.js";import{html,render,unsafeHTML}from"../lit-all.min.js";export default class Import extends LightComponent{static properties={src:{type:String,reflect:!0},content:{type:String},scripts:{type:Array}};static replacements={};constructor(){super(),this.src="",this.content="",this.scripts=[]}updated(t){super.updated(),t.has("src")&&this.fetch(),t.has("content")&&this.scripts.length>0&&setTimeout(()=>this.executeScripts(),0)}async fetch(){let t=await(await fetch(this.src)).text();for(const[e,r]of Object.entries(Import.replacements))t=t.replace(new RegExp(`%%${e}%%`,"g"),r);const e=(new DOMParser).parseFromString(t,"text/html"),r=e.querySelectorAll("script");this.scripts=Array.from(r).map(t=>({src:t.src,text:t.textContent,type:t.type||"text/javascript"})),r.forEach(t=>t.remove()),this.content=e.body?e.body.innerHTML:t}executeScripts(){this.scripts.forEach(t=>{const e=document.createElement("script");e.type=t.type,t.src?e.src=t.src:t.text&&(e.textContent=t.text),document.head.appendChild(e)}),this.scripts=[]}renderLightDom(){return this.content?html`${unsafeHTML(this.content)}`:html``}}window.customElements.define("k-import",Import);
@@ -0,0 +1 @@
1
+ import Collapsible from"./Collapsible.js";export default class PersistantCollapsible extends Collapsible{constructor(){super(),this.storageKey=""}connectedCallback(){super.connectedCallback(),this.updateStorageKey(),this.loadFromStorage(),window.addEventListener("storage",this.handleStorageChange)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("storage",this.handleStorageChange)}updated(e){super.updated(e),e.has("opened")&&this.saveToStorage(),e.has("id")&&(this.updateStorageKey(),this.loadFromStorage())}handleStorageChange=e=>{e.key===this.storageKey&&this.loadFromStorage()};updateStorageKey(){this.storageKey=this.id?`PersistantCollapsible-${this.id}`:""}loadFromStorage(){if(this.storageKey){const e=localStorage.getItem(this.storageKey);null!==e&&(this.opened="true"===e)}}saveToStorage(){this.storageKey&&localStorage.setItem(this.storageKey,this.opened.toString())}}customElements.define("k-p-collapsible",PersistantCollapsible);