juxscript 1.1.239 → 1.1.243

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 (297) hide show
  1. package/index.js +7 -137
  2. package/lib/components/dataframe.ts +0 -569
  3. package/lib/components/tag.ts +68 -0
  4. package/lib/styles/shadcn.css +20 -7
  5. package/lib/utils/idgen.ts +6 -0
  6. package/package.json +5 -6
  7. package/index.d.ts +0 -239
  8. package/index.d.ts.map +0 -1
  9. package/lib/components/alert.d.ts +0 -36
  10. package/lib/components/alert.d.ts.map +0 -1
  11. package/lib/components/alert.js +0 -172
  12. package/lib/components/alert.ts +0 -219
  13. package/lib/components/app.d.ts +0 -89
  14. package/lib/components/app.d.ts.map +0 -1
  15. package/lib/components/app.js +0 -175
  16. package/lib/components/app.ts +0 -247
  17. package/lib/components/badge.d.ts +0 -26
  18. package/lib/components/badge.d.ts.map +0 -1
  19. package/lib/components/badge.js +0 -91
  20. package/lib/components/badge.ts +0 -118
  21. package/lib/components/base/Animations.d.ts +0 -36
  22. package/lib/components/base/Animations.d.ts.map +0 -1
  23. package/lib/components/base/Animations.js +0 -70
  24. package/lib/components/base/Animations.ts +0 -112
  25. package/lib/components/base/BaseComponent.d.ts +0 -294
  26. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  27. package/lib/components/base/BaseComponent.js +0 -735
  28. package/lib/components/base/BaseComponent.ts +0 -884
  29. package/lib/components/base/FormInput.d.ts +0 -77
  30. package/lib/components/base/FormInput.d.ts.map +0 -1
  31. package/lib/components/base/FormInput.js +0 -171
  32. package/lib/components/base/FormInput.ts +0 -237
  33. package/lib/components/blueprint.d.ts +0 -40
  34. package/lib/components/blueprint.d.ts.map +0 -1
  35. package/lib/components/blueprint.js +0 -327
  36. package/lib/components/button.d.ts +0 -70
  37. package/lib/components/button.d.ts.map +0 -1
  38. package/lib/components/button.js +0 -177
  39. package/lib/components/button.ts +0 -237
  40. package/lib/components/card.d.ts +0 -35
  41. package/lib/components/card.d.ts.map +0 -1
  42. package/lib/components/card.js +0 -130
  43. package/lib/components/card.ts +0 -177
  44. package/lib/components/chart.d.ts +0 -49
  45. package/lib/components/chart.d.ts.map +0 -1
  46. package/lib/components/chart.js +0 -205
  47. package/lib/components/chart.ts +0 -254
  48. package/lib/components/checkbox.d.ts +0 -33
  49. package/lib/components/checkbox.d.ts.map +0 -1
  50. package/lib/components/checkbox.js +0 -202
  51. package/lib/components/checkbox.ts +0 -260
  52. package/lib/components/code.d.ts +0 -52
  53. package/lib/components/code.d.ts.map +0 -1
  54. package/lib/components/code.js +0 -201
  55. package/lib/components/code.ts +0 -260
  56. package/lib/components/container.d.ts +0 -60
  57. package/lib/components/container.d.ts.map +0 -1
  58. package/lib/components/container.js +0 -195
  59. package/lib/components/container.ts +0 -259
  60. package/lib/components/data.d.ts +0 -36
  61. package/lib/components/data.d.ts.map +0 -1
  62. package/lib/components/data.js +0 -110
  63. package/lib/components/data.ts +0 -135
  64. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  65. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  66. package/lib/components/dataframe/DataFrameSource.js +0 -421
  67. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  68. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  70. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  71. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  72. package/lib/components/dataframe.d.ts +0 -110
  73. package/lib/components/dataframe.d.ts.map +0 -1
  74. package/lib/components/dataframe.js +0 -470
  75. package/lib/components/datepicker.d.ts +0 -40
  76. package/lib/components/datepicker.d.ts.map +0 -1
  77. package/lib/components/datepicker.js +0 -193
  78. package/lib/components/datepicker.ts +0 -251
  79. package/lib/components/dialog.d.ts +0 -39
  80. package/lib/components/dialog.d.ts.map +0 -1
  81. package/lib/components/dialog.js +0 -131
  82. package/lib/components/dialog.ts +0 -178
  83. package/lib/components/divider.d.ts +0 -31
  84. package/lib/components/divider.d.ts.map +0 -1
  85. package/lib/components/divider.js +0 -72
  86. package/lib/components/divider.ts +0 -104
  87. package/lib/components/dropdown-menu.d.ts +0 -42
  88. package/lib/components/dropdown-menu.d.ts.map +0 -1
  89. package/lib/components/dropdown-menu.js +0 -177
  90. package/lib/components/dropdown-menu.ts +0 -214
  91. package/lib/components/dropdown.d.ts +0 -41
  92. package/lib/components/dropdown.d.ts.map +0 -1
  93. package/lib/components/dropdown.js +0 -136
  94. package/lib/components/dropdown.ts +0 -188
  95. package/lib/components/element.d.ts +0 -51
  96. package/lib/components/element.d.ts.map +0 -1
  97. package/lib/components/element.js +0 -209
  98. package/lib/components/element.ts +0 -271
  99. package/lib/components/event-chain.d.ts +0 -9
  100. package/lib/components/event-chain.d.ts.map +0 -1
  101. package/lib/components/event-chain.js +0 -33
  102. package/lib/components/fileupload.d.ts +0 -98
  103. package/lib/components/fileupload.d.ts.map +0 -1
  104. package/lib/components/fileupload.js +0 -351
  105. package/lib/components/fileupload.ts +0 -449
  106. package/lib/components/grid.d.ts +0 -88
  107. package/lib/components/grid.d.ts.map +0 -1
  108. package/lib/components/grid.js +0 -208
  109. package/lib/components/grid.ts +0 -295
  110. package/lib/components/heading.d.ts +0 -25
  111. package/lib/components/heading.d.ts.map +0 -1
  112. package/lib/components/heading.js +0 -83
  113. package/lib/components/heading.ts +0 -113
  114. package/lib/components/helpers.d.ts +0 -9
  115. package/lib/components/helpers.d.ts.map +0 -1
  116. package/lib/components/helpers.js +0 -30
  117. package/lib/components/helpers.ts +0 -41
  118. package/lib/components/hero.d.ts +0 -60
  119. package/lib/components/hero.d.ts.map +0 -1
  120. package/lib/components/hero.js +0 -239
  121. package/lib/components/hero.ts +0 -302
  122. package/lib/components/history/StateHistory.d.ts +0 -91
  123. package/lib/components/history/StateHistory.d.ts.map +0 -1
  124. package/lib/components/history/StateHistory.js +0 -154
  125. package/lib/components/history/StateHistory.ts +0 -200
  126. package/lib/components/icon.d.ts +0 -36
  127. package/lib/components/icon.d.ts.map +0 -1
  128. package/lib/components/icon.js +0 -135
  129. package/lib/components/icon.ts +0 -182
  130. package/lib/components/icons.d.ts +0 -25
  131. package/lib/components/icons.d.ts.map +0 -1
  132. package/lib/components/icons.js +0 -440
  133. package/lib/components/icons.ts +0 -464
  134. package/lib/components/image.d.ts +0 -42
  135. package/lib/components/image.d.ts.map +0 -1
  136. package/lib/components/image.js +0 -204
  137. package/lib/components/image.ts +0 -260
  138. package/lib/components/include.d.ts +0 -86
  139. package/lib/components/include.d.ts.map +0 -1
  140. package/lib/components/include.js +0 -238
  141. package/lib/components/include.ts +0 -281
  142. package/lib/components/input.d.ts +0 -85
  143. package/lib/components/input.d.ts.map +0 -1
  144. package/lib/components/input.js +0 -362
  145. package/lib/components/input.ts +0 -473
  146. package/lib/components/layer.d.ts +0 -72
  147. package/lib/components/layer.d.ts.map +0 -1
  148. package/lib/components/layer.js +0 -219
  149. package/lib/components/layer.ts +0 -304
  150. package/lib/components/link.d.ts +0 -41
  151. package/lib/components/link.d.ts.map +0 -1
  152. package/lib/components/link.js +0 -216
  153. package/lib/components/link.ts +0 -268
  154. package/lib/components/list.d.ts +0 -83
  155. package/lib/components/list.d.ts.map +0 -1
  156. package/lib/components/list.js +0 -314
  157. package/lib/components/list.ts +0 -423
  158. package/lib/components/loading.d.ts +0 -25
  159. package/lib/components/loading.d.ts.map +0 -1
  160. package/lib/components/loading.js +0 -76
  161. package/lib/components/loading.ts +0 -104
  162. package/lib/components/menu.d.ts +0 -38
  163. package/lib/components/menu.d.ts.map +0 -1
  164. package/lib/components/menu.js +0 -205
  165. package/lib/components/menu.ts +0 -279
  166. package/lib/components/modal.d.ts +0 -97
  167. package/lib/components/modal.d.ts.map +0 -1
  168. package/lib/components/modal.js +0 -463
  169. package/lib/components/modal.ts +0 -576
  170. package/lib/components/nav.d.ts +0 -46
  171. package/lib/components/nav.d.ts.map +0 -1
  172. package/lib/components/nav.js +0 -193
  173. package/lib/components/nav.ts +0 -261
  174. package/lib/components/paragraph.d.ts +0 -30
  175. package/lib/components/paragraph.d.ts.map +0 -1
  176. package/lib/components/paragraph.js +0 -93
  177. package/lib/components/paragraph.ts +0 -123
  178. package/lib/components/pen.d.ts +0 -125
  179. package/lib/components/pen.d.ts.map +0 -1
  180. package/lib/components/pen.js +0 -443
  181. package/lib/components/pen.ts +0 -567
  182. package/lib/components/progress.d.ts +0 -40
  183. package/lib/components/progress.d.ts.map +0 -1
  184. package/lib/components/progress.js +0 -116
  185. package/lib/components/progress.ts +0 -163
  186. package/lib/components/radio.d.ts +0 -43
  187. package/lib/components/radio.d.ts.map +0 -1
  188. package/lib/components/radio.js +0 -226
  189. package/lib/components/radio.ts +0 -303
  190. package/lib/components/registry.d.ts +0 -34
  191. package/lib/components/registry.d.ts.map +0 -1
  192. package/lib/components/registry.js +0 -163
  193. package/lib/components/registry.ts +0 -193
  194. package/lib/components/req.d.ts +0 -155
  195. package/lib/components/req.d.ts.map +0 -1
  196. package/lib/components/req.js +0 -253
  197. package/lib/components/req.ts +0 -303
  198. package/lib/components/script.d.ts +0 -14
  199. package/lib/components/script.d.ts.map +0 -1
  200. package/lib/components/script.js +0 -33
  201. package/lib/components/script.ts +0 -41
  202. package/lib/components/select.d.ts +0 -42
  203. package/lib/components/select.d.ts.map +0 -1
  204. package/lib/components/select.js +0 -209
  205. package/lib/components/select.ts +0 -281
  206. package/lib/components/sidebar.d.ts +0 -59
  207. package/lib/components/sidebar.d.ts.map +0 -1
  208. package/lib/components/sidebar.js +0 -298
  209. package/lib/components/sidebar.ts +0 -395
  210. package/lib/components/stack/BaseStack.d.ts +0 -65
  211. package/lib/components/stack/BaseStack.d.ts.map +0 -1
  212. package/lib/components/stack/BaseStack.js +0 -274
  213. package/lib/components/stack/BaseStack.ts +0 -328
  214. package/lib/components/stack/HStack.d.ts +0 -18
  215. package/lib/components/stack/HStack.d.ts.map +0 -1
  216. package/lib/components/stack/HStack.js +0 -22
  217. package/lib/components/stack/HStack.ts +0 -25
  218. package/lib/components/stack/VStack.d.ts +0 -19
  219. package/lib/components/stack/VStack.d.ts.map +0 -1
  220. package/lib/components/stack/VStack.js +0 -23
  221. package/lib/components/stack/VStack.ts +0 -26
  222. package/lib/components/stack/ZStack.d.ts +0 -18
  223. package/lib/components/stack/ZStack.d.ts.map +0 -1
  224. package/lib/components/stack/ZStack.js +0 -22
  225. package/lib/components/stack/ZStack.ts +0 -25
  226. package/lib/components/style.d.ts +0 -14
  227. package/lib/components/style.d.ts.map +0 -1
  228. package/lib/components/style.js +0 -33
  229. package/lib/components/style.ts +0 -41
  230. package/lib/components/switch.d.ts +0 -34
  231. package/lib/components/switch.d.ts.map +0 -1
  232. package/lib/components/switch.js +0 -209
  233. package/lib/components/switch.ts +0 -272
  234. package/lib/components/table.d.ts +0 -137
  235. package/lib/components/table.d.ts.map +0 -1
  236. package/lib/components/table.js +0 -1019
  237. package/lib/components/table.ts +0 -1225
  238. package/lib/components/tabs.d.ts +0 -53
  239. package/lib/components/tabs.d.ts.map +0 -1
  240. package/lib/components/tabs.js +0 -275
  241. package/lib/components/tabs.ts +0 -349
  242. package/lib/components/theme-toggle.d.ts +0 -45
  243. package/lib/components/theme-toggle.d.ts.map +0 -1
  244. package/lib/components/theme-toggle.js +0 -218
  245. package/lib/components/theme-toggle.ts +0 -297
  246. package/lib/components/tooltip.d.ts +0 -31
  247. package/lib/components/tooltip.d.ts.map +0 -1
  248. package/lib/components/tooltip.js +0 -112
  249. package/lib/components/tooltip.ts +0 -148
  250. package/lib/components/watcher.d.ts +0 -195
  251. package/lib/components/watcher.d.ts.map +0 -1
  252. package/lib/components/watcher.js +0 -241
  253. package/lib/components/watcher.ts +0 -261
  254. package/lib/components/write.d.ts +0 -107
  255. package/lib/components/write.d.ts.map +0 -1
  256. package/lib/components/write.js +0 -222
  257. package/lib/components/write.ts +0 -272
  258. package/lib/data/DataPipeline.d.ts +0 -113
  259. package/lib/data/DataPipeline.d.ts.map +0 -1
  260. package/lib/data/DataPipeline.js +0 -359
  261. package/lib/data/DataPipeline.ts +0 -452
  262. package/lib/facades/dataframe.jux +0 -0
  263. package/lib/globals.d.ts +0 -21
  264. package/lib/reactivity/state.d.ts +0 -36
  265. package/lib/reactivity/state.d.ts.map +0 -1
  266. package/lib/reactivity/state.js +0 -67
  267. package/lib/reactivity/state.ts +0 -78
  268. package/lib/storage/DataFrame.d.ts +0 -284
  269. package/lib/storage/DataFrame.d.ts.map +0 -1
  270. package/lib/storage/DataFrame.js +0 -1022
  271. package/lib/storage/DataFrame.ts +0 -1195
  272. package/lib/storage/DataFrameSource.d.ts +0 -158
  273. package/lib/storage/DataFrameSource.d.ts.map +0 -1
  274. package/lib/storage/DataFrameSource.js +0 -409
  275. package/lib/storage/DataFrameSource.ts +0 -556
  276. package/lib/storage/FileStorage.d.ts +0 -53
  277. package/lib/storage/FileStorage.d.ts.map +0 -1
  278. package/lib/storage/FileStorage.js +0 -80
  279. package/lib/storage/FileStorage.ts +0 -95
  280. package/lib/storage/IndexedDBDriver.d.ts +0 -75
  281. package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
  282. package/lib/storage/IndexedDBDriver.js +0 -177
  283. package/lib/storage/IndexedDBDriver.ts +0 -226
  284. package/lib/storage/TabularDriver.d.ts +0 -118
  285. package/lib/storage/TabularDriver.d.ts.map +0 -1
  286. package/lib/storage/TabularDriver.js +0 -731
  287. package/lib/storage/TabularDriver.ts +0 -874
  288. package/lib/utils/codeparser.d.ts +0 -29
  289. package/lib/utils/codeparser.d.ts.map +0 -1
  290. package/lib/utils/codeparser.js +0 -409
  291. package/lib/utils/fetch.d.ts +0 -176
  292. package/lib/utils/fetch.d.ts.map +0 -1
  293. package/lib/utils/fetch.js +0 -427
  294. package/lib/utils/formatId.d.ts +0 -16
  295. package/lib/utils/formatId.d.ts.map +0 -1
  296. package/lib/utils/formatId.js +0 -27
  297. package/lib/utils/path-resolver.js +0 -23
@@ -1 +0,0 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,YAAY,GAAG,SAAS,GAAG;IAC9B,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,OAAQ,SAAQ,aAAa,CAAC,YAAY,CAAC;IACtD,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IA4BpD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,WAAW;IA+FnB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAsCtC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAKvC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKjC,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKhC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKnC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK/B,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI;IAKjC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAKhC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK3B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK3B,MAAM,IAAI,IAAI;IAKd,mBAAmB,IAAI,IAAI;IAU3B,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA2FnE;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAEzE"}
@@ -1,298 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { req } from './req.js';
4
- // Event definitions
5
- const TRIGGER_EVENTS = [];
6
- const CALLBACK_EVENTS = ['toggle', 'itemClick'];
7
- export class Sidebar extends BaseComponent {
8
- constructor(id, options = {}) {
9
- // Restore collapsed state from localStorage if available
10
- const storageKey = `jux-sidebar-${id}-collapsed`;
11
- const savedCollapsed = localStorage.getItem(storageKey);
12
- const initialCollapsed = savedCollapsed !== null ? savedCollapsed === 'true' : (options.collapsed ?? false);
13
- super(id, {
14
- position: options.position ?? 'left',
15
- width: options.width ?? '',
16
- collapsible: options.collapsible ?? true,
17
- showToggle: options.showToggle ?? false,
18
- expandOnHover: options.expandOnHover ?? false,
19
- collapsed: initialCollapsed,
20
- items: options.items ?? [],
21
- header: options.header ?? '',
22
- footer: options.footer ?? '',
23
- style: options.style ?? '',
24
- class: options.class ?? ''
25
- });
26
- this._sidebar = null;
27
- this._setActiveStates();
28
- // Listen for URL changes to update active states
29
- if (typeof window !== 'undefined') {
30
- window.addEventListener('popstate', () => this.refreshActiveStates());
31
- }
32
- }
33
- getTriggerEvents() {
34
- return TRIGGER_EVENTS;
35
- }
36
- getCallbackEvents() {
37
- return CALLBACK_EVENTS;
38
- }
39
- /* ═════════════════════════════════════════════════════════════════
40
- * PRIVATE HELPERS
41
- * ═════════════════════════════════════════════════════════════════ */
42
- _setActiveStates() {
43
- this.state.items = this.state.items.map(item => ({
44
- ...item,
45
- active: item.href ? req.isActiveNavItem(item.href) : false,
46
- items: item.items?.map(subItem => ({
47
- ...subItem,
48
- active: subItem.href ? req.isActiveNavItem(subItem.href) : false
49
- }))
50
- }));
51
- }
52
- _renderItem(item) {
53
- const itemEl = document.createElement('div');
54
- itemEl.className = 'jux-sidebar-item';
55
- if (item.itemClass) {
56
- itemEl.className += ` ${item.itemClass}`;
57
- }
58
- if (item.active) {
59
- itemEl.classList.add('jux-sidebar-item-active');
60
- }
61
- if (item.href) {
62
- const link = document.createElement('a');
63
- link.className = 'jux-sidebar-link';
64
- link.href = item.href;
65
- if (item.active) {
66
- link.classList.add('jux-sidebar-link-active');
67
- }
68
- if (item.icon) {
69
- const icon = document.createElement('span');
70
- icon.className = 'jux-sidebar-icon';
71
- icon.appendChild(renderIcon(item.icon));
72
- link.appendChild(icon);
73
- }
74
- const label = document.createElement('span');
75
- label.className = 'jux-sidebar-label';
76
- label.textContent = item.label;
77
- link.appendChild(label);
78
- link.addEventListener('click', (e) => {
79
- this._triggerCallback('itemClick', { item, event: e });
80
- });
81
- itemEl.appendChild(link);
82
- }
83
- else {
84
- const button = document.createElement('button');
85
- button.className = 'jux-sidebar-button';
86
- button.type = 'button';
87
- if (item.icon) {
88
- const icon = document.createElement('span');
89
- icon.className = 'jux-sidebar-icon';
90
- icon.appendChild(renderIcon(item.icon));
91
- button.appendChild(icon);
92
- }
93
- const label = document.createElement('span');
94
- label.className = 'jux-sidebar-label';
95
- label.textContent = item.label;
96
- button.appendChild(label);
97
- button.addEventListener('click', (e) => {
98
- if (item.click) {
99
- item.click();
100
- }
101
- this._triggerCallback('itemClick', { item, event: e });
102
- });
103
- itemEl.appendChild(button);
104
- }
105
- if (item.items && item.items.length > 0) {
106
- itemEl.classList.add('jux-sidebar-item-has-submenu');
107
- const submenu = document.createElement('div');
108
- submenu.className = 'jux-sidebar-submenu';
109
- item.items.forEach(subItem => {
110
- submenu.appendChild(this._renderItem(subItem));
111
- });
112
- itemEl.appendChild(submenu);
113
- const clickTarget = itemEl.querySelector('a, button');
114
- if (clickTarget) {
115
- clickTarget.addEventListener('click', (e) => {
116
- if (!item.href) {
117
- e.preventDefault();
118
- }
119
- itemEl.classList.toggle('jux-sidebar-item-expanded');
120
- });
121
- }
122
- }
123
- return itemEl;
124
- }
125
- /* ═════════════════════════════════════════════════════════════════
126
- * REACTIVE UPDATE
127
- * ═════════════════════════════════════════════════════════════════ */
128
- update(prop, value) {
129
- if (!this._sidebar)
130
- return;
131
- if (prop === 'collapsed') {
132
- this._sidebar.classList.toggle('jux-sidebar-collapsed', value);
133
- // Update toggle button state
134
- const toggleBtn = this._sidebar.querySelector('.jux-sidebar-toggle');
135
- if (toggleBtn) {
136
- toggleBtn.classList.toggle('jux-sidebar-toggle-collapsed', value);
137
- }
138
- // Save to localStorage
139
- const storageKey = `jux-sidebar-${this._id}-collapsed`;
140
- localStorage.setItem(storageKey, String(value));
141
- }
142
- else if (prop === 'items') {
143
- this._setActiveStates();
144
- const nav = this._sidebar.querySelector('.jux-sidebar-nav');
145
- if (nav) {
146
- nav.innerHTML = '';
147
- this.state.items.forEach(item => {
148
- nav.appendChild(this._renderItem(item));
149
- });
150
- }
151
- }
152
- else if (prop === 'header') {
153
- const header = this._sidebar.querySelector('.jux-sidebar-header');
154
- if (header)
155
- header.textContent = value;
156
- }
157
- else if (prop === 'footer') {
158
- const footer = this._sidebar.querySelector('.jux-sidebar-footer');
159
- if (footer)
160
- footer.textContent = value;
161
- }
162
- }
163
- /* ═════════════════════════════════════════════════════════════════
164
- * FLUENT API
165
- * ═════════════════════════════════════════════════════════════════ */
166
- width(value) {
167
- this.state.width = value;
168
- if (this._sidebar) {
169
- this._sidebar.style.width = value;
170
- }
171
- return this;
172
- }
173
- position(value) {
174
- this.state.position = value;
175
- return this;
176
- }
177
- collapsible(value) {
178
- this.state.collapsible = value;
179
- return this;
180
- }
181
- showToggle(value) {
182
- this.state.showToggle = value;
183
- return this;
184
- }
185
- expandOnHover(value) {
186
- this.state.expandOnHover = value;
187
- return this;
188
- }
189
- collapsed(value) {
190
- this.state.collapsed = value;
191
- return this;
192
- }
193
- items(value) {
194
- this.state.items = value;
195
- return this;
196
- }
197
- addItem(item) {
198
- this.state.items = [...this.state.items, item];
199
- return this;
200
- }
201
- header(value) {
202
- this.state.header = value;
203
- return this;
204
- }
205
- footer(value) {
206
- this.state.footer = value;
207
- return this;
208
- }
209
- toggle() {
210
- this.state.collapsed = !this.state.collapsed;
211
- this._triggerCallback('toggle', this.state.collapsed);
212
- }
213
- refreshActiveStates() {
214
- this._setActiveStates();
215
- this.state.items = [...this.state.items]; // Trigger update
216
- return this;
217
- }
218
- /* ═════════════════════════════════════════════════════════════════
219
- * RENDER
220
- * ═════════════════════════════════════════════════════════════════ */
221
- render(targetId) {
222
- const container = this._setupContainer(targetId);
223
- const { position, collapsed, expandOnHover, items, header, footer, width, style, class: className } = this.state;
224
- const sidebar = document.createElement('aside');
225
- sidebar.className = `jux-sidebar jux-sidebar-${position}`;
226
- sidebar.id = this._id;
227
- if (collapsed) {
228
- sidebar.classList.add('jux-sidebar-collapsed');
229
- }
230
- if (className)
231
- sidebar.className += ` ${className}`;
232
- if (style)
233
- sidebar.setAttribute('style', style);
234
- if (width)
235
- sidebar.style.width = width;
236
- if (header) {
237
- const headerEl = document.createElement('div');
238
- headerEl.className = 'jux-sidebar-header';
239
- headerEl.textContent = header;
240
- sidebar.appendChild(headerEl);
241
- }
242
- const nav = document.createElement('nav');
243
- nav.className = 'jux-sidebar-nav';
244
- items.forEach(item => {
245
- nav.appendChild(this._renderItem(item));
246
- });
247
- sidebar.appendChild(nav);
248
- if (footer) {
249
- const footerEl = document.createElement('div');
250
- footerEl.className = 'jux-sidebar-footer';
251
- footerEl.textContent = footer;
252
- sidebar.appendChild(footerEl);
253
- }
254
- if (this.state.collapsible || this.state.showToggle) {
255
- const toggleBtn = document.createElement('button');
256
- toggleBtn.className = 'jux-sidebar-toggle';
257
- toggleBtn.type = 'button';
258
- toggleBtn.setAttribute('aria-label', 'Toggle sidebar');
259
- const toggleIcon = document.createElement('span');
260
- toggleIcon.className = 'jux-sidebar-toggle-icon';
261
- const chevronIcon = renderIcon(position === 'left' ? '➡️' : '⬅️');
262
- toggleIcon.appendChild(chevronIcon);
263
- toggleBtn.appendChild(toggleIcon);
264
- if (collapsed) {
265
- toggleBtn.classList.add('jux-sidebar-toggle-collapsed');
266
- }
267
- toggleBtn.addEventListener('click', () => {
268
- this.toggle();
269
- });
270
- sidebar.appendChild(toggleBtn);
271
- }
272
- if (expandOnHover) {
273
- sidebar.addEventListener('mouseenter', () => {
274
- if (this.state.collapsed) {
275
- sidebar.classList.add('jux-sidebar-hover-expanded');
276
- }
277
- });
278
- sidebar.addEventListener('mouseleave', () => {
279
- if (this.state.collapsed) {
280
- sidebar.classList.remove('jux-sidebar-hover-expanded');
281
- }
282
- });
283
- }
284
- this._wireStandardEvents(sidebar);
285
- this._wireAllSyncs();
286
- container.appendChild(sidebar);
287
- this._sidebar = sidebar;
288
- requestAnimationFrame(() => {
289
- if (window.Iconify) {
290
- window.Iconify.scan();
291
- }
292
- });
293
- return this;
294
- }
295
- }
296
- export function sidebar(id, options = {}) {
297
- return new Sidebar(id, options);
298
- }
@@ -1,395 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { req } from './req.js';
4
-
5
- // Event definitions
6
- const TRIGGER_EVENTS = [] as const;
7
- const CALLBACK_EVENTS = ['toggle', 'itemClick'] as const;
8
-
9
- export interface SidebarItem {
10
- label: string;
11
- href?: string;
12
- click?: () => void;
13
- icon?: string;
14
- items?: SidebarItem[];
15
- active?: boolean;
16
- itemClass?: string;
17
- }
18
-
19
- export interface SidebarOptions {
20
- position?: 'left' | 'right';
21
- width?: string;
22
- collapsible?: boolean;
23
- showToggle?: boolean;
24
- expandOnHover?: boolean;
25
- collapsed?: boolean;
26
- items?: SidebarItem[];
27
- header?: string;
28
- footer?: string;
29
- style?: string;
30
- class?: string;
31
- }
32
-
33
- type SidebarState = BaseState & {
34
- position: 'left' | 'right';
35
- width: string;
36
- collapsible: boolean;
37
- showToggle: boolean;
38
- expandOnHover: boolean;
39
- collapsed: boolean;
40
- items: SidebarItem[];
41
- header: string;
42
- footer: string;
43
- };
44
-
45
- export class Sidebar extends BaseComponent<SidebarState> {
46
- private _sidebar: HTMLElement | null = null;
47
-
48
- constructor(id: string, options: SidebarOptions = {}) {
49
- // Restore collapsed state from localStorage if available
50
- const storageKey = `jux-sidebar-${id}-collapsed`;
51
- const savedCollapsed = localStorage.getItem(storageKey);
52
- const initialCollapsed = savedCollapsed !== null ? savedCollapsed === 'true' : (options.collapsed ?? false);
53
-
54
- super(id, {
55
- position: options.position ?? 'left',
56
- width: options.width ?? '',
57
- collapsible: options.collapsible ?? true,
58
- showToggle: options.showToggle ?? false,
59
- expandOnHover: options.expandOnHover ?? false,
60
- collapsed: initialCollapsed,
61
- items: options.items ?? [],
62
- header: options.header ?? '',
63
- footer: options.footer ?? '',
64
- style: options.style ?? '',
65
- class: options.class ?? ''
66
- });
67
-
68
- this._setActiveStates();
69
-
70
- // Listen for URL changes to update active states
71
- if (typeof window !== 'undefined') {
72
- window.addEventListener('popstate', () => this.refreshActiveStates());
73
- }
74
- }
75
-
76
- protected getTriggerEvents(): readonly string[] {
77
- return TRIGGER_EVENTS;
78
- }
79
-
80
- protected getCallbackEvents(): readonly string[] {
81
- return CALLBACK_EVENTS;
82
- }
83
-
84
- /* ═════════════════════════════════════════════════════════════════
85
- * PRIVATE HELPERS
86
- * ═════════════════════════════════════════════════════════════════ */
87
-
88
- private _setActiveStates(): void {
89
- this.state.items = this.state.items.map(item => ({
90
- ...item,
91
- active: item.href ? req.isActiveNavItem(item.href) : false,
92
- items: item.items?.map(subItem => ({
93
- ...subItem,
94
- active: subItem.href ? req.isActiveNavItem(subItem.href) : false
95
- }))
96
- }));
97
- }
98
-
99
- private _renderItem(item: SidebarItem): HTMLElement {
100
- const itemEl = document.createElement('div');
101
- itemEl.className = 'jux-sidebar-item';
102
-
103
- if (item.itemClass) {
104
- itemEl.className += ` ${item.itemClass}`;
105
- }
106
-
107
- if (item.active) {
108
- itemEl.classList.add('jux-sidebar-item-active');
109
- }
110
-
111
- if (item.href) {
112
- const link = document.createElement('a');
113
- link.className = 'jux-sidebar-link';
114
- link.href = item.href;
115
-
116
- if (item.active) {
117
- link.classList.add('jux-sidebar-link-active');
118
- }
119
-
120
- if (item.icon) {
121
- const icon = document.createElement('span');
122
- icon.className = 'jux-sidebar-icon';
123
- icon.appendChild(renderIcon(item.icon));
124
- link.appendChild(icon);
125
- }
126
-
127
- const label = document.createElement('span');
128
- label.className = 'jux-sidebar-label';
129
- label.textContent = item.label;
130
- link.appendChild(label);
131
-
132
- link.addEventListener('click', (e) => {
133
- this._triggerCallback('itemClick', { item, event: e });
134
- });
135
-
136
- itemEl.appendChild(link);
137
- } else {
138
- const button = document.createElement('button');
139
- button.className = 'jux-sidebar-button';
140
- button.type = 'button';
141
-
142
- if (item.icon) {
143
- const icon = document.createElement('span');
144
- icon.className = 'jux-sidebar-icon';
145
- icon.appendChild(renderIcon(item.icon));
146
- button.appendChild(icon);
147
- }
148
-
149
- const label = document.createElement('span');
150
- label.className = 'jux-sidebar-label';
151
- label.textContent = item.label;
152
- button.appendChild(label);
153
-
154
- button.addEventListener('click', (e) => {
155
- if (item.click) {
156
- item.click();
157
- }
158
- this._triggerCallback('itemClick', { item, event: e });
159
- });
160
-
161
- itemEl.appendChild(button);
162
- }
163
-
164
- if (item.items && item.items.length > 0) {
165
- itemEl.classList.add('jux-sidebar-item-has-submenu');
166
-
167
- const submenu = document.createElement('div');
168
- submenu.className = 'jux-sidebar-submenu';
169
-
170
- item.items.forEach(subItem => {
171
- submenu.appendChild(this._renderItem(subItem));
172
- });
173
-
174
- itemEl.appendChild(submenu);
175
-
176
- const clickTarget = itemEl.querySelector('a, button');
177
- if (clickTarget) {
178
- clickTarget.addEventListener('click', (e) => {
179
- if (!item.href) {
180
- e.preventDefault();
181
- }
182
- itemEl.classList.toggle('jux-sidebar-item-expanded');
183
- });
184
- }
185
- }
186
-
187
- return itemEl;
188
- }
189
-
190
- /* ═════════════════════════════════════════════════════════════════
191
- * REACTIVE UPDATE
192
- * ═════════════════════════════════════════════════════════════════ */
193
-
194
- update(prop: string, value: any): void {
195
-
196
- if (!this._sidebar) return;
197
-
198
- if (prop === 'collapsed') {
199
- this._sidebar.classList.toggle('jux-sidebar-collapsed', value);
200
-
201
- // Update toggle button state
202
- const toggleBtn = this._sidebar.querySelector('.jux-sidebar-toggle');
203
- if (toggleBtn) {
204
- toggleBtn.classList.toggle('jux-sidebar-toggle-collapsed', value);
205
- }
206
-
207
- // Save to localStorage
208
- const storageKey = `jux-sidebar-${this._id}-collapsed`;
209
- localStorage.setItem(storageKey, String(value));
210
- } else if (prop === 'items') {
211
- this._setActiveStates();
212
- const nav = this._sidebar.querySelector('.jux-sidebar-nav');
213
- if (nav) {
214
- nav.innerHTML = '';
215
- this.state.items.forEach(item => {
216
- nav.appendChild(this._renderItem(item));
217
- });
218
- }
219
- } else if (prop === 'header') {
220
- const header = this._sidebar.querySelector('.jux-sidebar-header');
221
- if (header) header.textContent = value;
222
- } else if (prop === 'footer') {
223
- const footer = this._sidebar.querySelector('.jux-sidebar-footer');
224
- if (footer) footer.textContent = value;
225
- }
226
- }
227
-
228
- /* ═════════════════════════════════════════════════════════════════
229
- * FLUENT API
230
- * ═════════════════════════════════════════════════════════════════ */
231
-
232
- width(value: string): this {
233
- this.state.width = value;
234
- if (this._sidebar) {
235
- this._sidebar.style.width = value;
236
- }
237
- return this;
238
- }
239
-
240
- position(value: 'left' | 'right'): this {
241
- this.state.position = value;
242
- return this;
243
- }
244
-
245
- collapsible(value: boolean): this {
246
- this.state.collapsible = value;
247
- return this;
248
- }
249
-
250
- showToggle(value: boolean): this {
251
- this.state.showToggle = value;
252
- return this;
253
- }
254
-
255
- expandOnHover(value: boolean): this {
256
- this.state.expandOnHover = value;
257
- return this;
258
- }
259
-
260
- collapsed(value: boolean): this {
261
- this.state.collapsed = value;
262
- return this;
263
- }
264
-
265
- items(value: SidebarItem[]): this {
266
- this.state.items = value;
267
- return this;
268
- }
269
-
270
- addItem(item: SidebarItem): this {
271
- this.state.items = [...this.state.items, item];
272
- return this;
273
- }
274
-
275
- header(value: string): this {
276
- this.state.header = value;
277
- return this;
278
- }
279
-
280
- footer(value: string): this {
281
- this.state.footer = value;
282
- return this;
283
- }
284
-
285
- toggle(): void {
286
- this.state.collapsed = !this.state.collapsed;
287
- this._triggerCallback('toggle', this.state.collapsed);
288
- }
289
-
290
- refreshActiveStates(): this {
291
- this._setActiveStates();
292
- this.state.items = [...this.state.items]; // Trigger update
293
- return this;
294
- }
295
-
296
- /* ═════════════════════════════════════════════════════════════════
297
- * RENDER
298
- * ═════════════════════════════════════════════════════════════════ */
299
-
300
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
301
- const container = this._setupContainer(targetId);
302
-
303
- const { position, collapsed, expandOnHover, items, header, footer, width, style, class: className } = this.state;
304
-
305
- const sidebar = document.createElement('aside');
306
- sidebar.className = `jux-sidebar jux-sidebar-${position}`;
307
- sidebar.id = this._id;
308
-
309
- if (collapsed) {
310
- sidebar.classList.add('jux-sidebar-collapsed');
311
- }
312
-
313
- if (className) sidebar.className += ` ${className}`;
314
- if (style) sidebar.setAttribute('style', style);
315
- if (width) sidebar.style.width = width;
316
-
317
- if (header) {
318
- const headerEl = document.createElement('div');
319
- headerEl.className = 'jux-sidebar-header';
320
- headerEl.textContent = header;
321
- sidebar.appendChild(headerEl);
322
- }
323
-
324
- const nav = document.createElement('nav');
325
- nav.className = 'jux-sidebar-nav';
326
-
327
- items.forEach(item => {
328
- nav.appendChild(this._renderItem(item));
329
- });
330
-
331
- sidebar.appendChild(nav);
332
-
333
- if (footer) {
334
- const footerEl = document.createElement('div');
335
- footerEl.className = 'jux-sidebar-footer';
336
- footerEl.textContent = footer;
337
- sidebar.appendChild(footerEl);
338
- }
339
-
340
- if (this.state.collapsible || this.state.showToggle) {
341
- const toggleBtn = document.createElement('button');
342
- toggleBtn.className = 'jux-sidebar-toggle';
343
- toggleBtn.type = 'button';
344
- toggleBtn.setAttribute('aria-label', 'Toggle sidebar');
345
-
346
- const toggleIcon = document.createElement('span');
347
- toggleIcon.className = 'jux-sidebar-toggle-icon';
348
- const chevronIcon = renderIcon(position === 'left' ? '➡️' : '⬅️');
349
- toggleIcon.appendChild(chevronIcon);
350
- toggleBtn.appendChild(toggleIcon);
351
-
352
- if (collapsed) {
353
- toggleBtn.classList.add('jux-sidebar-toggle-collapsed');
354
- }
355
-
356
- toggleBtn.addEventListener('click', () => {
357
- this.toggle();
358
- });
359
-
360
- sidebar.appendChild(toggleBtn);
361
- }
362
-
363
- if (expandOnHover) {
364
- sidebar.addEventListener('mouseenter', () => {
365
- if (this.state.collapsed) {
366
- sidebar.classList.add('jux-sidebar-hover-expanded');
367
- }
368
- });
369
-
370
- sidebar.addEventListener('mouseleave', () => {
371
- if (this.state.collapsed) {
372
- sidebar.classList.remove('jux-sidebar-hover-expanded');
373
- }
374
- });
375
- }
376
-
377
- this._wireStandardEvents(sidebar);
378
- this._wireAllSyncs();
379
-
380
- container.appendChild(sidebar);
381
- this._sidebar = sidebar;
382
-
383
- requestAnimationFrame(() => {
384
- if ((window as any).Iconify) {
385
- (window as any).Iconify.scan();
386
- }
387
- });
388
-
389
- return this;
390
- }
391
- }
392
-
393
- export function sidebar(id: string, options: SidebarOptions = {}): Sidebar {
394
- return new Sidebar(id, options);
395
- }