juxscript 1.1.240 → 1.1.244

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/include.ts +229 -229
  4. package/lib/components/tag.ts +68 -0
  5. package/lib/styles/shadcn.css +17 -5
  6. package/lib/utils/idgen.ts +6 -0
  7. package/package.json +5 -6
  8. package/index.d.ts +0 -239
  9. package/index.d.ts.map +0 -1
  10. package/lib/components/alert.d.ts +0 -36
  11. package/lib/components/alert.d.ts.map +0 -1
  12. package/lib/components/alert.js +0 -172
  13. package/lib/components/alert.ts +0 -219
  14. package/lib/components/app.d.ts +0 -89
  15. package/lib/components/app.d.ts.map +0 -1
  16. package/lib/components/app.js +0 -175
  17. package/lib/components/app.ts +0 -247
  18. package/lib/components/badge.d.ts +0 -26
  19. package/lib/components/badge.d.ts.map +0 -1
  20. package/lib/components/badge.js +0 -91
  21. package/lib/components/badge.ts +0 -118
  22. package/lib/components/base/Animations.d.ts +0 -36
  23. package/lib/components/base/Animations.d.ts.map +0 -1
  24. package/lib/components/base/Animations.js +0 -70
  25. package/lib/components/base/Animations.ts +0 -112
  26. package/lib/components/base/BaseComponent.d.ts +0 -294
  27. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  28. package/lib/components/base/BaseComponent.js +0 -735
  29. package/lib/components/base/BaseComponent.ts +0 -884
  30. package/lib/components/base/FormInput.d.ts +0 -77
  31. package/lib/components/base/FormInput.d.ts.map +0 -1
  32. package/lib/components/base/FormInput.js +0 -171
  33. package/lib/components/base/FormInput.ts +0 -237
  34. package/lib/components/blueprint.d.ts +0 -40
  35. package/lib/components/blueprint.d.ts.map +0 -1
  36. package/lib/components/blueprint.js +0 -327
  37. package/lib/components/button.d.ts +0 -70
  38. package/lib/components/button.d.ts.map +0 -1
  39. package/lib/components/button.js +0 -177
  40. package/lib/components/button.ts +0 -237
  41. package/lib/components/card.d.ts +0 -35
  42. package/lib/components/card.d.ts.map +0 -1
  43. package/lib/components/card.js +0 -130
  44. package/lib/components/card.ts +0 -177
  45. package/lib/components/chart.d.ts +0 -49
  46. package/lib/components/chart.d.ts.map +0 -1
  47. package/lib/components/chart.js +0 -205
  48. package/lib/components/chart.ts +0 -254
  49. package/lib/components/checkbox.d.ts +0 -33
  50. package/lib/components/checkbox.d.ts.map +0 -1
  51. package/lib/components/checkbox.js +0 -202
  52. package/lib/components/checkbox.ts +0 -260
  53. package/lib/components/code.d.ts +0 -52
  54. package/lib/components/code.d.ts.map +0 -1
  55. package/lib/components/code.js +0 -201
  56. package/lib/components/code.ts +0 -260
  57. package/lib/components/container.d.ts +0 -60
  58. package/lib/components/container.d.ts.map +0 -1
  59. package/lib/components/container.js +0 -195
  60. package/lib/components/container.ts +0 -259
  61. package/lib/components/data.d.ts +0 -36
  62. package/lib/components/data.d.ts.map +0 -1
  63. package/lib/components/data.js +0 -110
  64. package/lib/components/data.ts +0 -135
  65. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  66. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  67. package/lib/components/dataframe/DataFrameSource.js +0 -421
  68. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  70. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  71. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  72. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  73. package/lib/components/dataframe.d.ts +0 -110
  74. package/lib/components/dataframe.d.ts.map +0 -1
  75. package/lib/components/dataframe.js +0 -470
  76. package/lib/components/datepicker.d.ts +0 -40
  77. package/lib/components/datepicker.d.ts.map +0 -1
  78. package/lib/components/datepicker.js +0 -193
  79. package/lib/components/datepicker.ts +0 -251
  80. package/lib/components/dialog.d.ts +0 -39
  81. package/lib/components/dialog.d.ts.map +0 -1
  82. package/lib/components/dialog.js +0 -131
  83. package/lib/components/dialog.ts +0 -178
  84. package/lib/components/divider.d.ts +0 -31
  85. package/lib/components/divider.d.ts.map +0 -1
  86. package/lib/components/divider.js +0 -72
  87. package/lib/components/divider.ts +0 -104
  88. package/lib/components/dropdown-menu.d.ts +0 -42
  89. package/lib/components/dropdown-menu.d.ts.map +0 -1
  90. package/lib/components/dropdown-menu.js +0 -177
  91. package/lib/components/dropdown-menu.ts +0 -214
  92. package/lib/components/dropdown.d.ts +0 -41
  93. package/lib/components/dropdown.d.ts.map +0 -1
  94. package/lib/components/dropdown.js +0 -136
  95. package/lib/components/dropdown.ts +0 -188
  96. package/lib/components/element.d.ts +0 -51
  97. package/lib/components/element.d.ts.map +0 -1
  98. package/lib/components/element.js +0 -209
  99. package/lib/components/element.ts +0 -271
  100. package/lib/components/event-chain.d.ts +0 -9
  101. package/lib/components/event-chain.d.ts.map +0 -1
  102. package/lib/components/event-chain.js +0 -33
  103. package/lib/components/fileupload.d.ts +0 -98
  104. package/lib/components/fileupload.d.ts.map +0 -1
  105. package/lib/components/fileupload.js +0 -351
  106. package/lib/components/fileupload.ts +0 -449
  107. package/lib/components/grid.d.ts +0 -88
  108. package/lib/components/grid.d.ts.map +0 -1
  109. package/lib/components/grid.js +0 -208
  110. package/lib/components/grid.ts +0 -295
  111. package/lib/components/heading.d.ts +0 -25
  112. package/lib/components/heading.d.ts.map +0 -1
  113. package/lib/components/heading.js +0 -83
  114. package/lib/components/heading.ts +0 -113
  115. package/lib/components/helpers.d.ts +0 -9
  116. package/lib/components/helpers.d.ts.map +0 -1
  117. package/lib/components/helpers.js +0 -30
  118. package/lib/components/helpers.ts +0 -41
  119. package/lib/components/hero.d.ts +0 -60
  120. package/lib/components/hero.d.ts.map +0 -1
  121. package/lib/components/hero.js +0 -239
  122. package/lib/components/hero.ts +0 -302
  123. package/lib/components/history/StateHistory.d.ts +0 -91
  124. package/lib/components/history/StateHistory.d.ts.map +0 -1
  125. package/lib/components/history/StateHistory.js +0 -154
  126. package/lib/components/history/StateHistory.ts +0 -200
  127. package/lib/components/icon.d.ts +0 -36
  128. package/lib/components/icon.d.ts.map +0 -1
  129. package/lib/components/icon.js +0 -135
  130. package/lib/components/icon.ts +0 -182
  131. package/lib/components/icons.d.ts +0 -25
  132. package/lib/components/icons.d.ts.map +0 -1
  133. package/lib/components/icons.js +0 -440
  134. package/lib/components/icons.ts +0 -464
  135. package/lib/components/image.d.ts +0 -42
  136. package/lib/components/image.d.ts.map +0 -1
  137. package/lib/components/image.js +0 -204
  138. package/lib/components/image.ts +0 -260
  139. package/lib/components/include.d.ts +0 -86
  140. package/lib/components/include.d.ts.map +0 -1
  141. package/lib/components/include.js +0 -238
  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,53 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- export interface Tab {
3
- id: string;
4
- label: string;
5
- content: string | BaseComponent<any>;
6
- icon?: string;
7
- }
8
- export interface TabsOptions {
9
- tabs?: Tab[];
10
- activeTab?: string;
11
- variant?: 'default' | 'pills' | 'underline';
12
- style?: string;
13
- class?: string;
14
- }
15
- type TabsState = BaseState & {
16
- tabs: Tab[];
17
- activeTab: string;
18
- variant: string;
19
- };
20
- export declare class Tabs extends BaseComponent<TabsState> {
21
- private _tabsWrapper;
22
- constructor(id: string, options?: TabsOptions);
23
- protected getTriggerEvents(): readonly string[];
24
- protected getCallbackEvents(): readonly string[];
25
- update(prop: string, value: any): void;
26
- private _updateActiveTab;
27
- private _rebuildTabs;
28
- tabs(value: Tab[]): this;
29
- addTab(tab: Tab): this;
30
- removeTab(tabId: string): this;
31
- activeTab(value: string): this;
32
- variant(value: 'default' | 'pills' | 'underline'): this;
33
- /**
34
- * Update content of a specific tab by ID
35
- */
36
- updateTabContent(tabId: string, content: string | BaseComponent<any>): this;
37
- /**
38
- * Add content to a specific tab panel
39
- */
40
- addTabContent(tabId: string, content: (string | BaseComponent<any>)[]): this;
41
- /**
42
- * Get tab by ID
43
- */
44
- getTab(tabId: string): Tab | undefined;
45
- /**
46
- * Get current active tab
47
- */
48
- getCurrentTab(): Tab | undefined;
49
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
50
- }
51
- export declare function tabs(id: string, options?: TabsOptions): Tabs;
52
- export {};
53
- //# sourceMappingURL=tabs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMnE,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG,SAAS,GAAG;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChD,OAAO,CAAC,YAAY,CAA4B;gBAEpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAUjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAuBtC,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,YAAY;IAqEpB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;IAKxB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAKtB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAW9B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,IAAI;IAKvD;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IAqB3E;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI;IAuB5E;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAItC;;OAEG;IACH,aAAa,IAAI,GAAG,GAAG,SAAS;IAQhC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA+EnE;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
@@ -1,275 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- // Event definitions
3
- const TRIGGER_EVENTS = [];
4
- const CALLBACK_EVENTS = ['tabChange'];
5
- export class Tabs extends BaseComponent {
6
- constructor(id, options = {}) {
7
- super(id, {
8
- tabs: options.tabs ?? [],
9
- activeTab: options.activeTab ?? (options.tabs?.[0]?.id ?? ''),
10
- variant: options.variant ?? 'default',
11
- style: options.style ?? '',
12
- class: options.class ?? ''
13
- });
14
- this._tabsWrapper = null;
15
- }
16
- getTriggerEvents() {
17
- return TRIGGER_EVENTS;
18
- }
19
- getCallbackEvents() {
20
- return CALLBACK_EVENTS;
21
- }
22
- /* ═════════════════════════════════════════════════════════════════
23
- * REACTIVE UPDATE
24
- * ═════════════════════════════════════════════════════════════════ */
25
- update(prop, value) {
26
- super.update(prop, value);
27
- if (!this._tabsWrapper)
28
- return;
29
- switch (prop) {
30
- case 'activeTab':
31
- this._updateActiveTab(value);
32
- break;
33
- case 'tabs':
34
- this._rebuildTabs();
35
- break;
36
- case 'variant':
37
- this._tabsWrapper.className = `jux-tabs jux-tabs-${value}`;
38
- if (this.state.class) {
39
- this._tabsWrapper.className += ` ${this.state.class}`;
40
- }
41
- break;
42
- }
43
- }
44
- _updateActiveTab(tabId) {
45
- if (!this._tabsWrapper)
46
- return;
47
- // Update button states
48
- this.state.tabs.forEach(tab => {
49
- const btn = document.getElementById(`${this._id}-${tab.id}-button`);
50
- if (btn) {
51
- btn.classList.toggle('jux-tabs-button-active', tab.id === tabId);
52
- }
53
- });
54
- // Update panel visibility
55
- this.state.tabs.forEach(tab => {
56
- const panel = document.getElementById(`${this._id}-${tab.id}-panel`);
57
- if (panel) {
58
- const isActive = tab.id === tabId;
59
- panel.classList.toggle('jux-tabs-panel-active', isActive);
60
- panel.style.display = isActive ? 'block' : 'none';
61
- }
62
- });
63
- }
64
- _rebuildTabs() {
65
- if (!this._tabsWrapper)
66
- return;
67
- const tabList = this._tabsWrapper.querySelector('.jux-tabs-list');
68
- const tabPanels = this._tabsWrapper.querySelector('.jux-tabs-panels');
69
- if (!tabList || !tabPanels)
70
- return;
71
- // Clear existing
72
- tabList.innerHTML = '';
73
- tabPanels.innerHTML = '';
74
- // Rebuild
75
- this.state.tabs.forEach(tab => {
76
- // Button with unique ID
77
- const tabButton = document.createElement('button');
78
- tabButton.id = `${this._id}-${tab.id}-button`;
79
- tabButton.className = 'jux-tabs-button';
80
- tabButton.setAttribute('data-tab-id', tab.id);
81
- if (tab.id === this.state.activeTab) {
82
- tabButton.classList.add('jux-tabs-button-active');
83
- }
84
- if (tab.icon) {
85
- const icon = document.createElement('span');
86
- icon.className = 'jux-tabs-icon';
87
- icon.textContent = tab.icon;
88
- tabButton.appendChild(icon);
89
- }
90
- tabButton.appendChild(document.createTextNode(tab.label));
91
- tabButton.addEventListener('click', (e) => {
92
- this.state.activeTab = tab.id;
93
- this._triggerCallback('tabChange', tab.id, e, this);
94
- });
95
- tabList.appendChild(tabButton);
96
- // Panel with unique ID
97
- const tabPanel = document.createElement('div');
98
- tabPanel.id = `${this._id}-${tab.id}-panel`;
99
- tabPanel.className = 'jux-tabs-panel';
100
- tabPanel.setAttribute('data-tab-id', tab.id);
101
- if (tab.id === this.state.activeTab) {
102
- tabPanel.classList.add('jux-tabs-panel-active');
103
- }
104
- else {
105
- tabPanel.style.display = 'none';
106
- }
107
- // ✅ Append panel to DOM FIRST
108
- tabPanels.appendChild(tabPanel);
109
- // THEN render content into it
110
- if (typeof tab.content === 'string') {
111
- tabPanel.innerHTML = tab.content;
112
- }
113
- else if (tab.content instanceof BaseComponent) {
114
- // Now panel exists in DOM, so render() can find it
115
- tab.content.render(`#${tabPanel.id}`);
116
- }
117
- });
118
- }
119
- /* ═════════════════════════════════════════════════════════════════
120
- * FLUENT API
121
- * ═════════════════════════════════════════════════════════════════ */
122
- tabs(value) {
123
- this.state.tabs = value;
124
- return this;
125
- }
126
- addTab(tab) {
127
- this.state.tabs = [...this.state.tabs, tab];
128
- return this;
129
- }
130
- removeTab(tabId) {
131
- this.state.tabs = this.state.tabs.filter(t => t.id !== tabId);
132
- // If removing active tab, switch to first tab
133
- if (this.state.activeTab === tabId && this.state.tabs.length > 0) {
134
- this.state.activeTab = this.state.tabs[0].id;
135
- }
136
- return this;
137
- }
138
- activeTab(value) {
139
- this.state.activeTab = value;
140
- return this;
141
- }
142
- variant(value) {
143
- this.state.variant = value;
144
- return this;
145
- }
146
- /**
147
- * Update content of a specific tab by ID
148
- */
149
- updateTabContent(tabId, content) {
150
- const tab = this.state.tabs.find(t => t.id === tabId);
151
- if (!tab)
152
- return this;
153
- tab.content = content;
154
- // Update DOM if rendered
155
- const panel = document.getElementById(`${this._id}-${tabId}-panel`);
156
- if (panel) {
157
- panel.innerHTML = ''; // Clear existing content
158
- if (typeof content === 'string') {
159
- panel.innerHTML = content;
160
- }
161
- else if (content instanceof BaseComponent) {
162
- content.render(`#${panel.id}`);
163
- }
164
- }
165
- return this;
166
- }
167
- /**
168
- * Add content to a specific tab panel
169
- */
170
- addTabContent(tabId, content) {
171
- const panel = document.getElementById(`${this._id}-${tabId}-panel`);
172
- if (!panel) {
173
- console.warn(`[Tabs] Panel not found for tab: ${tabId}`);
174
- return this;
175
- }
176
- content.forEach(item => {
177
- if (typeof item === 'string') {
178
- const tempDiv = document.createElement('div');
179
- tempDiv.innerHTML = item;
180
- while (tempDiv.firstChild) {
181
- panel.appendChild(tempDiv.firstChild);
182
- }
183
- }
184
- else if (item && typeof item.render === 'function') {
185
- // ✅ Render the component into the panel
186
- item.render(panel);
187
- }
188
- });
189
- return this;
190
- }
191
- /**
192
- * Get tab by ID
193
- */
194
- getTab(tabId) {
195
- return this.state.tabs.find(t => t.id === tabId);
196
- }
197
- /**
198
- * Get current active tab
199
- */
200
- getCurrentTab() {
201
- return this.state.tabs.find(t => t.id === this.state.activeTab);
202
- }
203
- /* ═════════════════════════════════════════════════════════════════
204
- * RENDER
205
- * ═════════════════════════════════════════════════════════════════ */
206
- render(targetId) {
207
- const container = this._setupContainer(targetId);
208
- const { tabs, activeTab, variant, style, class: className } = this.state;
209
- const wrapper = document.createElement('div');
210
- wrapper.className = `jux-tabs jux-tabs-${variant}`;
211
- wrapper.id = this._id;
212
- if (className)
213
- wrapper.className += ` ${className}`;
214
- if (style)
215
- wrapper.setAttribute('style', style);
216
- const tabList = document.createElement('div');
217
- tabList.className = 'jux-tabs-list';
218
- const tabPanels = document.createElement('div');
219
- tabPanels.className = 'jux-tabs-panels';
220
- // ✅ Append structure to DOM FIRST, then render content
221
- wrapper.appendChild(tabList);
222
- wrapper.appendChild(tabPanels);
223
- container.appendChild(wrapper);
224
- tabs.forEach(tab => {
225
- // Tab button with unique ID
226
- const tabButton = document.createElement('button');
227
- tabButton.id = `${this._id}-${tab.id}-button`;
228
- tabButton.className = 'jux-tabs-button';
229
- tabButton.setAttribute('data-tab-id', tab.id);
230
- if (tab.id === activeTab) {
231
- tabButton.classList.add('jux-tabs-button-active');
232
- }
233
- if (tab.icon) {
234
- const icon = document.createElement('span');
235
- icon.className = 'jux-tabs-icon';
236
- icon.textContent = tab.icon;
237
- tabButton.appendChild(icon);
238
- }
239
- tabButton.appendChild(document.createTextNode(tab.label));
240
- tabButton.addEventListener('click', (e) => {
241
- this.state.activeTab = tab.id;
242
- this._triggerCallback('tabChange', tab.id, e, this);
243
- });
244
- tabList.appendChild(tabButton);
245
- // Tab panel with unique ID
246
- const tabPanel = document.createElement('div');
247
- tabPanel.id = `${this._id}-${tab.id}-panel`;
248
- tabPanel.className = 'jux-tabs-panel';
249
- tabPanel.setAttribute('data-tab-id', tab.id);
250
- if (tab.id === activeTab) {
251
- tabPanel.classList.add('jux-tabs-panel-active');
252
- }
253
- else {
254
- tabPanel.style.display = 'none';
255
- }
256
- // ✅ Append panel to DOM FIRST
257
- tabPanels.appendChild(tabPanel);
258
- // ✅ THEN render content into it (panel is now in DOM)
259
- if (typeof tab.content === 'string') {
260
- tabPanel.innerHTML = tab.content;
261
- }
262
- else if (tab.content instanceof BaseComponent) {
263
- // Now panel exists in DOM, so render() can find it
264
- tab.content.render(`#${tabPanel.id}`);
265
- }
266
- });
267
- this._wireStandardEvents(wrapper);
268
- this._wireAllSyncs();
269
- this._tabsWrapper = wrapper;
270
- return this;
271
- }
272
- }
273
- export function tabs(id, options = {}) {
274
- return new Tabs(id, options);
275
- }
@@ -1,349 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = ['tabChange'] as const;
6
-
7
- export interface Tab {
8
- id: string;
9
- label: string;
10
- content: string | BaseComponent<any>;
11
- icon?: string;
12
- }
13
-
14
- export interface TabsOptions {
15
- tabs?: Tab[];
16
- activeTab?: string;
17
- variant?: 'default' | 'pills' | 'underline';
18
- style?: string;
19
- class?: string;
20
- }
21
-
22
- type TabsState = BaseState & {
23
- tabs: Tab[];
24
- activeTab: string;
25
- variant: string;
26
- };
27
-
28
- export class Tabs extends BaseComponent<TabsState> {
29
- private _tabsWrapper: HTMLElement | null = null;
30
-
31
- constructor(id: string, options: TabsOptions = {}) {
32
- super(id, {
33
- tabs: options.tabs ?? [],
34
- activeTab: options.activeTab ?? (options.tabs?.[0]?.id ?? ''),
35
- variant: options.variant ?? 'default',
36
- style: options.style ?? '',
37
- class: options.class ?? ''
38
- });
39
- }
40
-
41
- protected getTriggerEvents(): readonly string[] {
42
- return TRIGGER_EVENTS;
43
- }
44
-
45
- protected getCallbackEvents(): readonly string[] {
46
- return CALLBACK_EVENTS;
47
- }
48
-
49
- /* ═════════════════════════════════════════════════════════════════
50
- * REACTIVE UPDATE
51
- * ═════════════════════════════════════════════════════════════════ */
52
-
53
- update(prop: string, value: any): void {
54
- super.update(prop, value);
55
-
56
- if (!this._tabsWrapper) return;
57
-
58
- switch (prop) {
59
- case 'activeTab':
60
- this._updateActiveTab(value);
61
- break;
62
-
63
- case 'tabs':
64
- this._rebuildTabs();
65
- break;
66
-
67
- case 'variant':
68
- this._tabsWrapper.className = `jux-tabs jux-tabs-${value}`;
69
- if (this.state.class) {
70
- this._tabsWrapper.className += ` ${this.state.class}`;
71
- }
72
- break;
73
- }
74
- }
75
-
76
- private _updateActiveTab(tabId: string): void {
77
- if (!this._tabsWrapper) return;
78
-
79
- // Update button states
80
- this.state.tabs.forEach(tab => {
81
- const btn = document.getElementById(`${this._id}-${tab.id}-button`);
82
- if (btn) {
83
- btn.classList.toggle('jux-tabs-button-active', tab.id === tabId);
84
- }
85
- });
86
-
87
- // Update panel visibility
88
- this.state.tabs.forEach(tab => {
89
- const panel = document.getElementById(`${this._id}-${tab.id}-panel`);
90
- if (panel) {
91
- const isActive = tab.id === tabId;
92
- panel.classList.toggle('jux-tabs-panel-active', isActive);
93
- panel.style.display = isActive ? 'block' : 'none';
94
- }
95
- });
96
- }
97
-
98
- private _rebuildTabs(): void {
99
- if (!this._tabsWrapper) return;
100
-
101
- const tabList = this._tabsWrapper.querySelector('.jux-tabs-list');
102
- const tabPanels = this._tabsWrapper.querySelector('.jux-tabs-panels');
103
-
104
- if (!tabList || !tabPanels) return;
105
-
106
- // Clear existing
107
- tabList.innerHTML = '';
108
- tabPanels.innerHTML = '';
109
-
110
- // Rebuild
111
- this.state.tabs.forEach(tab => {
112
- // Button with unique ID
113
- const tabButton = document.createElement('button');
114
- tabButton.id = `${this._id}-${tab.id}-button`;
115
- tabButton.className = 'jux-tabs-button';
116
- tabButton.setAttribute('data-tab-id', tab.id);
117
-
118
- if (tab.id === this.state.activeTab) {
119
- tabButton.classList.add('jux-tabs-button-active');
120
- }
121
-
122
- if (tab.icon) {
123
- const icon = document.createElement('span');
124
- icon.className = 'jux-tabs-icon';
125
- icon.textContent = tab.icon;
126
- tabButton.appendChild(icon);
127
- }
128
-
129
- tabButton.appendChild(document.createTextNode(tab.label));
130
-
131
- tabButton.addEventListener('click', (e) => {
132
- this.state.activeTab = tab.id;
133
- this._triggerCallback('tabChange', tab.id, e, this);
134
- });
135
-
136
- tabList.appendChild(tabButton);
137
-
138
- // Panel with unique ID
139
- const tabPanel = document.createElement('div');
140
- tabPanel.id = `${this._id}-${tab.id}-panel`;
141
- tabPanel.className = 'jux-tabs-panel';
142
- tabPanel.setAttribute('data-tab-id', tab.id);
143
-
144
- if (tab.id === this.state.activeTab) {
145
- tabPanel.classList.add('jux-tabs-panel-active');
146
- } else {
147
- tabPanel.style.display = 'none';
148
- }
149
-
150
- // ✅ Append panel to DOM FIRST
151
- tabPanels.appendChild(tabPanel);
152
-
153
- // THEN render content into it
154
- if (typeof tab.content === 'string') {
155
- tabPanel.innerHTML = tab.content;
156
- } else if (tab.content instanceof BaseComponent) {
157
- // Now panel exists in DOM, so render() can find it
158
- tab.content.render(`#${tabPanel.id}`);
159
- }
160
- });
161
- }
162
-
163
- /* ═════════════════════════════════════════════════════════════════
164
- * FLUENT API
165
- * ═════════════════════════════════════════════════════════════════ */
166
-
167
- tabs(value: Tab[]): this {
168
- this.state.tabs = value;
169
- return this;
170
- }
171
-
172
- addTab(tab: Tab): this {
173
- this.state.tabs = [...this.state.tabs, tab];
174
- return this;
175
- }
176
-
177
- removeTab(tabId: string): this {
178
- this.state.tabs = this.state.tabs.filter(t => t.id !== tabId);
179
-
180
- // If removing active tab, switch to first tab
181
- if (this.state.activeTab === tabId && this.state.tabs.length > 0) {
182
- this.state.activeTab = this.state.tabs[0].id;
183
- }
184
-
185
- return this;
186
- }
187
-
188
- activeTab(value: string): this {
189
- this.state.activeTab = value;
190
- return this;
191
- }
192
-
193
- variant(value: 'default' | 'pills' | 'underline'): this {
194
- this.state.variant = value;
195
- return this;
196
- }
197
-
198
- /**
199
- * Update content of a specific tab by ID
200
- */
201
- updateTabContent(tabId: string, content: string | BaseComponent<any>): this {
202
- const tab = this.state.tabs.find(t => t.id === tabId);
203
- if (!tab) return this;
204
-
205
- tab.content = content;
206
-
207
- // Update DOM if rendered
208
- const panel = document.getElementById(`${this._id}-${tabId}-panel`);
209
- if (panel) {
210
- panel.innerHTML = ''; // Clear existing content
211
-
212
- if (typeof content === 'string') {
213
- panel.innerHTML = content;
214
- } else if (content instanceof BaseComponent) {
215
- content.render(`#${panel.id}`);
216
- }
217
- }
218
-
219
- return this;
220
- }
221
-
222
- /**
223
- * Add content to a specific tab panel
224
- */
225
- addTabContent(tabId: string, content: (string | BaseComponent<any>)[]): this {
226
- const panel = document.getElementById(`${this._id}-${tabId}-panel`);
227
- if (!panel) {
228
- console.warn(`[Tabs] Panel not found for tab: ${tabId}`);
229
- return this;
230
- }
231
-
232
- content.forEach(item => {
233
- if (typeof item === 'string') {
234
- const tempDiv = document.createElement('div');
235
- tempDiv.innerHTML = item;
236
- while (tempDiv.firstChild) {
237
- panel.appendChild(tempDiv.firstChild);
238
- }
239
- } else if (item && typeof item.render === 'function') {
240
- // ✅ Render the component into the panel
241
- item.render(panel);
242
- }
243
- });
244
-
245
- return this;
246
- }
247
-
248
- /**
249
- * Get tab by ID
250
- */
251
- getTab(tabId: string): Tab | undefined {
252
- return this.state.tabs.find(t => t.id === tabId);
253
- }
254
-
255
- /**
256
- * Get current active tab
257
- */
258
- getCurrentTab(): Tab | undefined {
259
- return this.state.tabs.find(t => t.id === this.state.activeTab);
260
- }
261
-
262
- /* ═════════════════════════════════════════════════════════════════
263
- * RENDER
264
- * ═════════════════════════════════════════════════════════════════ */
265
-
266
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
267
- const container = this._setupContainer(targetId);
268
- const { tabs, activeTab, variant, style, class: className } = this.state;
269
-
270
- const wrapper = document.createElement('div');
271
- wrapper.className = `jux-tabs jux-tabs-${variant}`;
272
- wrapper.id = this._id;
273
- if (className) wrapper.className += ` ${className}`;
274
- if (style) wrapper.setAttribute('style', style);
275
-
276
- const tabList = document.createElement('div');
277
- tabList.className = 'jux-tabs-list';
278
-
279
- const tabPanels = document.createElement('div');
280
- tabPanels.className = 'jux-tabs-panels';
281
-
282
- // ✅ Append structure to DOM FIRST, then render content
283
- wrapper.appendChild(tabList);
284
- wrapper.appendChild(tabPanels);
285
- container.appendChild(wrapper);
286
-
287
- tabs.forEach(tab => {
288
- // Tab button with unique ID
289
- const tabButton = document.createElement('button');
290
- tabButton.id = `${this._id}-${tab.id}-button`;
291
- tabButton.className = 'jux-tabs-button';
292
- tabButton.setAttribute('data-tab-id', tab.id);
293
-
294
- if (tab.id === activeTab) {
295
- tabButton.classList.add('jux-tabs-button-active');
296
- }
297
-
298
- if (tab.icon) {
299
- const icon = document.createElement('span');
300
- icon.className = 'jux-tabs-icon';
301
- icon.textContent = tab.icon;
302
- tabButton.appendChild(icon);
303
- }
304
-
305
- tabButton.appendChild(document.createTextNode(tab.label));
306
-
307
- tabButton.addEventListener('click', (e) => {
308
- this.state.activeTab = tab.id;
309
- this._triggerCallback('tabChange', tab.id, e, this);
310
- });
311
-
312
- tabList.appendChild(tabButton);
313
-
314
- // Tab panel with unique ID
315
- const tabPanel = document.createElement('div');
316
- tabPanel.id = `${this._id}-${tab.id}-panel`;
317
- tabPanel.className = 'jux-tabs-panel';
318
- tabPanel.setAttribute('data-tab-id', tab.id);
319
-
320
- if (tab.id === activeTab) {
321
- tabPanel.classList.add('jux-tabs-panel-active');
322
- } else {
323
- tabPanel.style.display = 'none';
324
- }
325
-
326
- // ✅ Append panel to DOM FIRST
327
- tabPanels.appendChild(tabPanel);
328
-
329
- // ✅ THEN render content into it (panel is now in DOM)
330
- if (typeof tab.content === 'string') {
331
- tabPanel.innerHTML = tab.content;
332
- } else if (tab.content instanceof BaseComponent) {
333
- // Now panel exists in DOM, so render() can find it
334
- tab.content.render(`#${tabPanel.id}`);
335
- }
336
- });
337
-
338
- this._wireStandardEvents(wrapper);
339
- this._wireAllSyncs();
340
-
341
- this._tabsWrapper = wrapper;
342
-
343
- return this;
344
- }
345
- }
346
-
347
- export function tabs(id: string, options: TabsOptions = {}): Tabs {
348
- return new Tabs(id, options);
349
- }