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,205 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { Chart } from 'chart.js/auto';
3
- /**
4
- * Chart component using Chart.js
5
- * Provides fluent API for creating and configuring charts
6
- */
7
- export class ChartComponent extends BaseComponent {
8
- constructor(id, type = 'bar', options) {
9
- super(id, {
10
- type,
11
- data: { datasets: [] },
12
- options: {},
13
- ...options
14
- });
15
- this.chartInstance = null;
16
- }
17
- getTriggerEvents() {
18
- return ChartComponent.TRIGGER_EVENTS;
19
- }
20
- getCallbackEvents() {
21
- return ChartComponent.CALLBACK_EVENTS;
22
- }
23
- /* ═════════════════════════════════════════════════════════════════
24
- * CHART TYPE
25
- * ═════════════════════════════════════════════════════════════════ */
26
- type(value) {
27
- this.state.type = value;
28
- if (this.chartInstance) {
29
- // Destroy and recreate chart with new type
30
- const canvas = this.chartInstance.canvas;
31
- this.chartInstance.destroy();
32
- const config = {
33
- type: this.state.type,
34
- data: this.state.data,
35
- options: this.state.options
36
- };
37
- this.chartInstance = new Chart(canvas, config);
38
- }
39
- return this;
40
- }
41
- /* ═════════════════════════════════════════════════════════════════
42
- * DATA CONFIGURATION
43
- * ═════════════════════════════════════════════════════════════════ */
44
- data(value) {
45
- this.state.data = value;
46
- if (this.chartInstance) {
47
- this.chartInstance.data = value;
48
- this.chartInstance.update();
49
- }
50
- return this;
51
- }
52
- labels(value) {
53
- this.state.data.labels = value;
54
- if (this.chartInstance) {
55
- this.chartInstance.data.labels = value;
56
- this.chartInstance.update();
57
- }
58
- return this;
59
- }
60
- datasets(value) {
61
- this.state.data.datasets = value;
62
- if (this.chartInstance) {
63
- this.chartInstance.data.datasets = value;
64
- this.chartInstance.update();
65
- }
66
- return this;
67
- }
68
- addDataset(dataset) {
69
- this.state.data.datasets.push(dataset);
70
- if (this.chartInstance) {
71
- this.chartInstance.data.datasets.push(dataset);
72
- this.chartInstance.update();
73
- }
74
- return this;
75
- }
76
- /* ═════════════════════════════════════════════════════════════════
77
- * OPTIONS CONFIGURATION
78
- * ═════════════════════════════════════════════════════════════════ */
79
- options(value) {
80
- this.state.options = { ...this.state.options, ...value };
81
- if (this.chartInstance) {
82
- this.chartInstance.options = this.state.options;
83
- this.chartInstance.update();
84
- }
85
- return this;
86
- }
87
- responsive(value = true) {
88
- return this.options({ responsive: value });
89
- }
90
- maintainAspectRatio(value = true) {
91
- return this.options({ maintainAspectRatio: value });
92
- }
93
- title(text, display = true) {
94
- return this.options({
95
- plugins: {
96
- ...this.state.options.plugins,
97
- title: { display, text }
98
- }
99
- });
100
- }
101
- legend(display = true, position = 'top') {
102
- return this.options({
103
- plugins: {
104
- ...this.state.options.plugins,
105
- legend: { display, position }
106
- }
107
- });
108
- }
109
- tooltip(enabled = true) {
110
- return this.options({
111
- plugins: {
112
- ...this.state.options.plugins,
113
- tooltip: { enabled }
114
- }
115
- });
116
- }
117
- /* ═════════════════════════════════════════════════════════════════
118
- * CHART OPERATIONS
119
- * ═════════════════════════════════════════════════════════════════ */
120
- /**
121
- * Update chart with new data or configuration
122
- */
123
- updateChart(mode) {
124
- if (this.chartInstance) {
125
- this.chartInstance.update(mode);
126
- }
127
- return this;
128
- }
129
- reset() {
130
- if (this.chartInstance) {
131
- this.chartInstance.reset();
132
- }
133
- return this;
134
- }
135
- destroy() {
136
- if (this.chartInstance) {
137
- this.chartInstance.destroy();
138
- this.chartInstance = null;
139
- this._triggerCallback('destroy');
140
- }
141
- return this;
142
- }
143
- getChart() {
144
- return this.chartInstance;
145
- }
146
- /* ═════════════════════════════════════════════════════════════════
147
- * RENDER
148
- * ═════════════════════════════════════════════════════════════════ */
149
- render(targetId) {
150
- const container = this._setupContainer(targetId);
151
- // Destroy existing chart
152
- if (this.chartInstance) {
153
- this.chartInstance.destroy();
154
- }
155
- // Clear container and create canvas
156
- container.innerHTML = '';
157
- const canvas = document.createElement('canvas');
158
- canvas.id = `${this._id}-canvas`;
159
- // Apply styles and classes
160
- if (this.state.style)
161
- container.setAttribute('style', this.state.style);
162
- if (this.state.class)
163
- container.className = this.state.class;
164
- if (this.state.visible === false)
165
- container.style.display = 'none';
166
- container.appendChild(canvas);
167
- // Create Chart.js instance
168
- const config = {
169
- type: this.state.type,
170
- data: this.state.data,
171
- options: this.state.options
172
- };
173
- this.chartInstance = new Chart(canvas, config);
174
- // Wire sync for data
175
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
176
- if (property === 'data') {
177
- const transform = toComponent || ((v) => v);
178
- stateObj.subscribe((val) => {
179
- const transformed = transform(val);
180
- this.state.data = transformed;
181
- if (this.chartInstance) {
182
- this.chartInstance.data = transformed;
183
- this.chartInstance.update();
184
- }
185
- });
186
- }
187
- });
188
- // Wire events and syncs
189
- this._wireStandardEvents(container);
190
- this._wireAllSyncs();
191
- this._triggerCallback('render', this.chartInstance);
192
- return this;
193
- }
194
- update(prop, value) {
195
- // No reactive updates needed - uses manual updateChart()
196
- }
197
- }
198
- ChartComponent.TRIGGER_EVENTS = [];
199
- ChartComponent.CALLBACK_EVENTS = ['render', 'update', 'destroy'];
200
- /**
201
- * Factory function for creating chart components
202
- */
203
- export function chart(id, type = 'bar', options) {
204
- return new ChartComponent(id, type, options);
205
- }
@@ -1,254 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { Chart, ChartConfiguration, ChartType, ChartOptions, ChartData } from 'chart.js/auto';
3
-
4
- // filepath: /Users/timkerr/newprojects2025/compile-sqljs/packages/jux/lib/components/chart.ts
5
-
6
- export interface ChartState {
7
- type: ChartType;
8
- data: ChartData;
9
- options: ChartOptions;
10
- style?: string;
11
- class?: string;
12
- visible?: boolean;
13
- disabled?: boolean;
14
- loading?: boolean;
15
- }
16
-
17
- /**
18
- * Chart component using Chart.js
19
- * Provides fluent API for creating and configuring charts
20
- */
21
- export class ChartComponent extends BaseComponent<ChartState> {
22
- private static readonly TRIGGER_EVENTS: readonly string[] = [];
23
- private static readonly CALLBACK_EVENTS: readonly string[] = ['render', 'update', 'destroy'];
24
- private chartInstance: Chart | null = null;
25
-
26
- constructor(id: string, type: ChartType = 'bar', options?: Partial<ChartState>) {
27
- super(id, {
28
- type,
29
- data: { datasets: [] },
30
- options: {},
31
- ...options
32
- });
33
- }
34
-
35
- protected getTriggerEvents(): readonly string[] {
36
- return ChartComponent.TRIGGER_EVENTS;
37
- }
38
-
39
- protected getCallbackEvents(): readonly string[] {
40
- return ChartComponent.CALLBACK_EVENTS;
41
- }
42
-
43
- /* ═════════════════════════════════════════════════════════════════
44
- * CHART TYPE
45
- * ═════════════════════════════════════════════════════════════════ */
46
-
47
- type(value: ChartType): this {
48
- this.state.type = value;
49
- if (this.chartInstance) {
50
- // Destroy and recreate chart with new type
51
- const canvas = this.chartInstance.canvas;
52
- this.chartInstance.destroy();
53
- const config: ChartConfiguration = {
54
- type: this.state.type,
55
- data: this.state.data,
56
- options: this.state.options
57
- };
58
- this.chartInstance = new Chart(canvas, config);
59
- }
60
- return this;
61
- }
62
-
63
- /* ═════════════════════════════════════════════════════════════════
64
- * DATA CONFIGURATION
65
- * ═════════════════════════════════════════════════════════════════ */
66
-
67
- data(value: ChartData): this {
68
- this.state.data = value;
69
- if (this.chartInstance) {
70
- this.chartInstance.data = value;
71
- this.chartInstance.update();
72
- }
73
- return this;
74
- }
75
-
76
- labels(value: string[]): this {
77
- this.state.data.labels = value;
78
- if (this.chartInstance) {
79
- this.chartInstance.data.labels = value;
80
- this.chartInstance.update();
81
- }
82
- return this;
83
- }
84
-
85
- datasets(value: any[]): this {
86
- this.state.data.datasets = value;
87
- if (this.chartInstance) {
88
- this.chartInstance.data.datasets = value;
89
- this.chartInstance.update();
90
- }
91
- return this;
92
- }
93
-
94
- addDataset(dataset: any): this {
95
- this.state.data.datasets.push(dataset);
96
- if (this.chartInstance) {
97
- this.chartInstance.data.datasets.push(dataset);
98
- this.chartInstance.update();
99
- }
100
- return this;
101
- }
102
-
103
- /* ═════════════════════════════════════════════════════════════════
104
- * OPTIONS CONFIGURATION
105
- * ═════════════════════════════════════════════════════════════════ */
106
-
107
- options(value: ChartOptions): this {
108
- this.state.options = { ...this.state.options, ...value };
109
- if (this.chartInstance) {
110
- this.chartInstance.options = this.state.options;
111
- this.chartInstance.update();
112
- }
113
- return this;
114
- }
115
-
116
- responsive(value: boolean = true): this {
117
- return this.options({ responsive: value });
118
- }
119
-
120
- maintainAspectRatio(value: boolean = true): this {
121
- return this.options({ maintainAspectRatio: value });
122
- }
123
-
124
- title(text: string, display: boolean = true): this {
125
- return this.options({
126
- plugins: {
127
- ...this.state.options.plugins,
128
- title: { display, text }
129
- }
130
- });
131
- }
132
-
133
- legend(display: boolean = true, position: 'top' | 'bottom' | 'left' | 'right' = 'top'): this {
134
- return this.options({
135
- plugins: {
136
- ...this.state.options.plugins,
137
- legend: { display, position }
138
- }
139
- });
140
- }
141
-
142
- tooltip(enabled: boolean = true): this {
143
- return this.options({
144
- plugins: {
145
- ...this.state.options.plugins,
146
- tooltip: { enabled }
147
- }
148
- });
149
- }
150
-
151
- /* ═════════════════════════════════════════════════════════════════
152
- * CHART OPERATIONS
153
- * ═════════════════════════════════════════════════════════════════ */
154
-
155
- /**
156
- * Update chart with new data or configuration
157
- */
158
- updateChart(mode?: 'resize' | 'reset' | 'none' | 'hide' | 'show' | 'default'): this {
159
- if (this.chartInstance) {
160
- this.chartInstance.update(mode);
161
- }
162
- return this;
163
- }
164
-
165
- reset(): this {
166
- if (this.chartInstance) {
167
- this.chartInstance.reset();
168
- }
169
- return this;
170
- }
171
-
172
- destroy(): this {
173
- if (this.chartInstance) {
174
- this.chartInstance.destroy();
175
- this.chartInstance = null;
176
- this._triggerCallback('destroy');
177
- }
178
- return this;
179
- }
180
-
181
- getChart(): Chart | null {
182
- return this.chartInstance;
183
- }
184
-
185
- /* ═════════════════════════════════════════════════════════════════
186
- * RENDER
187
- * ═════════════════════════════════════════════════════════════════ */
188
-
189
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
190
- const container = this._setupContainer(targetId);
191
-
192
- // Destroy existing chart
193
- if (this.chartInstance) {
194
- this.chartInstance.destroy();
195
- }
196
-
197
- // Clear container and create canvas
198
- container.innerHTML = '';
199
- const canvas = document.createElement('canvas');
200
- canvas.id = `${this._id}-canvas`;
201
-
202
- // Apply styles and classes
203
- if (this.state.style) container.setAttribute('style', this.state.style);
204
- if (this.state.class) container.className = this.state.class;
205
- if (this.state.visible === false) container.style.display = 'none';
206
-
207
- container.appendChild(canvas);
208
-
209
- // Create Chart.js instance
210
- const config: ChartConfiguration = {
211
- type: this.state.type,
212
- data: this.state.data,
213
- options: this.state.options
214
- };
215
-
216
- this.chartInstance = new Chart(canvas, config);
217
-
218
- // Wire sync for data
219
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
220
- if (property === 'data') {
221
- const transform = toComponent || ((v: any) => v);
222
-
223
- stateObj.subscribe((val: any) => {
224
- const transformed = transform(val);
225
- this.state.data = transformed;
226
-
227
- if (this.chartInstance) {
228
- this.chartInstance.data = transformed;
229
- this.chartInstance.update();
230
- }
231
- });
232
- }
233
- });
234
-
235
- // Wire events and syncs
236
- this._wireStandardEvents(container);
237
- this._wireAllSyncs();
238
-
239
- this._triggerCallback('render', this.chartInstance);
240
-
241
- return this;
242
- }
243
-
244
- update(prop: string, value: any): void {
245
- // No reactive updates needed - uses manual updateChart()
246
- }
247
- }
248
-
249
- /**
250
- * Factory function for creating chart components
251
- */
252
- export function chart(id: string, type: ChartType = 'bar', options?: Partial<ChartState>): ChartComponent {
253
- return new ChartComponent(id, type, options);
254
- }
@@ -1,33 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- export interface CheckboxOptions {
3
- checked?: boolean;
4
- label?: string;
5
- required?: boolean;
6
- disabled?: boolean;
7
- name?: string;
8
- value?: string;
9
- style?: string;
10
- class?: string;
11
- onValidate?: (checked: boolean) => boolean | string;
12
- }
13
- interface CheckboxState extends BaseState {
14
- checked: boolean;
15
- value: string;
16
- }
17
- export declare class Checkbox extends BaseComponent<CheckboxState> {
18
- constructor(id: string, options?: CheckboxOptions);
19
- protected getTriggerEvents(): readonly string[];
20
- protected getCallbackEvents(): readonly string[];
21
- checked(value: boolean): this;
22
- value(value: string): this;
23
- getValue(): boolean;
24
- setValue(value: boolean): this;
25
- validate(): boolean;
26
- isValid(): boolean;
27
- protected _validateValue(checked: boolean): boolean | string;
28
- protected _buildInputElement(): HTMLElement;
29
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
30
- }
31
- export declare function checkbox(id: string, options?: CheckboxOptions): Checkbox;
32
- export {};
33
- //# sourceMappingURL=checkbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,eAAe;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;CACvD;AAED,UAAU,aAAc,SAAQ,SAAS;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,QAAS,SAAQ,aAAa,CAAC,aAAa,CAAC;gBAC1C,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;IAqBrD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI7B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS1B,QAAQ,IAAI,OAAO;IAInB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAQ9B,QAAQ,IAAI,OAAO;IAcnB,OAAO,IAAI,OAAO;IAKlB,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM;IAiB5D,SAAS,CAAC,kBAAkB,IAAI,WAAW;IAoB3C,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CAmHrE;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAE5E"}
@@ -1,202 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
4
- // Event definitions
5
- const TRIGGER_EVENTS = [];
6
- const CALLBACK_EVENTS = ['change'];
7
- export class Checkbox extends BaseComponent {
8
- constructor(id, options = {}) {
9
- super(id, {
10
- visible: true,
11
- disabled: options.disabled ?? false,
12
- loading: false,
13
- class: options.class ?? '',
14
- style: options.style ?? '',
15
- attributes: {},
16
- label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
17
- required: options.required ?? false,
18
- name: options.name ?? id,
19
- errorMessage: undefined,
20
- checked: options.checked ?? false,
21
- value: options.value ?? 'on'
22
- });
23
- if (options.onValidate) {
24
- this._onValidate = options.onValidate;
25
- }
26
- }
27
- getTriggerEvents() {
28
- return TRIGGER_EVENTS;
29
- }
30
- getCallbackEvents() {
31
- return CALLBACK_EVENTS;
32
- }
33
- /* ═════════════════════════════════════════════════════════════════
34
- * FLUENT API
35
- * ═════════════════════════════════════════════════════════════════ */
36
- checked(value) {
37
- return this.setValue(value);
38
- }
39
- value(value) {
40
- this.state.value = value;
41
- return this;
42
- }
43
- /* ═════════════════════════════════════════════════════════════════
44
- * FORM INPUT IMPLEMENTATION
45
- * ═════════════════════════════════════════════════════════════════ */
46
- getValue() {
47
- return this.state.checked;
48
- }
49
- setValue(value) {
50
- this.state.checked = value;
51
- if (this._inputElement) {
52
- this._inputElement.checked = value;
53
- }
54
- return this;
55
- }
56
- validate() {
57
- this._hasBeenValidated = true;
58
- const value = this.getValue();
59
- const result = this._validateValue(value);
60
- if (result === true) {
61
- this._clearError();
62
- return true;
63
- }
64
- else {
65
- this._showError(result);
66
- return false;
67
- }
68
- }
69
- isValid() {
70
- const value = this.getValue();
71
- return this._validateValue(value) === true;
72
- }
73
- _validateValue(checked) {
74
- const { required } = this.state;
75
- if (required && !checked) {
76
- return 'This field must be checked';
77
- }
78
- if (this._onValidate) {
79
- const result = this._onValidate(checked);
80
- if (result !== true) {
81
- return result || 'Invalid value';
82
- }
83
- }
84
- return true;
85
- }
86
- _buildInputElement() {
87
- const { checked, value, required, disabled, name } = this.state;
88
- const input = document.createElement('input');
89
- input.type = 'checkbox';
90
- input.className = 'jux-checkbox-input';
91
- input.id = `${this._id}-input`;
92
- input.name = name;
93
- input.value = value;
94
- input.checked = checked;
95
- input.required = required;
96
- input.disabled = disabled;
97
- return input;
98
- }
99
- /* ═════════════════════════════════════════════════════════════════
100
- * RENDER
101
- * ═════════════════════════════════════════════════════════════════ */
102
- render(targetId) {
103
- const container = this._setupContainer(targetId);
104
- const { style, class: className } = this.state;
105
- // Build wrapper
106
- const wrapper = document.createElement('div');
107
- wrapper.className = 'jux-checkbox';
108
- wrapper.id = this._id;
109
- if (className)
110
- wrapper.className += ` ${className}`;
111
- if (style)
112
- wrapper.setAttribute('style', style);
113
- // Checkbox container
114
- const checkboxContainer = document.createElement('label');
115
- checkboxContainer.className = 'jux-checkbox-container';
116
- checkboxContainer.htmlFor = `${this._id}-input`;
117
- // Input element
118
- const inputEl = this._buildInputElement();
119
- this._inputElement = inputEl;
120
- checkboxContainer.appendChild(inputEl);
121
- // Checkmark (custom styled)
122
- const checkmark = document.createElement('span');
123
- checkmark.className = 'jux-checkbox-checkmark';
124
- checkmark.appendChild(renderIcon('check'));
125
- checkboxContainer.appendChild(checkmark);
126
- // Label text
127
- if (this.state.label) {
128
- const labelText = document.createElement('span');
129
- labelText.className = 'jux-checkbox-label-text';
130
- labelText.textContent = this.state.label;
131
- if (this.state.required) {
132
- const requiredSpan = document.createElement('span');
133
- requiredSpan.className = 'jux-input-required';
134
- requiredSpan.textContent = ' *';
135
- labelText.appendChild(requiredSpan);
136
- }
137
- checkboxContainer.appendChild(labelText);
138
- }
139
- wrapper.appendChild(checkboxContainer);
140
- // Error element
141
- wrapper.appendChild(this._renderError());
142
- // Wire events
143
- this._wireStandardEvents(wrapper);
144
- // Wire checkbox-specific sync (maps 'checked' to 'value' property for consistency)
145
- const valueSync = this._syncBindings.find(b => b.property === 'value' || b.property === 'checked');
146
- if (valueSync) {
147
- const { stateObj, toState, toComponent } = valueSync;
148
- const transformToState = toState || ((v) => v);
149
- const transformToComponent = toComponent || ((v) => Boolean(v));
150
- let isUpdating = false;
151
- // State → Component
152
- stateObj.subscribe((val) => {
153
- if (isUpdating)
154
- return;
155
- const transformed = transformToComponent(val);
156
- this.setValue(transformed);
157
- });
158
- // Component → State
159
- inputEl.addEventListener('change', (e) => {
160
- if (isUpdating)
161
- return;
162
- isUpdating = true;
163
- const checked = inputEl.checked;
164
- this.state.checked = checked;
165
- this._clearError();
166
- const transformed = transformToState(checked);
167
- stateObj.set(transformed);
168
- // 🎯 Fire the change callback event
169
- this._triggerCallback('change', checked, e, this);
170
- setTimeout(() => { isUpdating = false; }, 0);
171
- });
172
- }
173
- else {
174
- // Default behavior without sync
175
- inputEl.addEventListener('change', (e) => {
176
- this.state.checked = inputEl.checked;
177
- this._clearError();
178
- // 🎯 Fire the change callback event
179
- this._triggerCallback('change', inputEl.checked, e, this);
180
- });
181
- }
182
- // Always add blur validation
183
- inputEl.addEventListener('blur', () => {
184
- if (this._hasBeenValidated) {
185
- this.validate();
186
- }
187
- });
188
- // Sync label changes
189
- const labelSync = this._syncBindings.find(b => b.property === 'label');
190
- if (labelSync) {
191
- const transform = labelSync.toComponent || ((v) => String(v));
192
- labelSync.stateObj.subscribe((val) => {
193
- this.label(transform(val));
194
- });
195
- }
196
- container.appendChild(wrapper);
197
- return this;
198
- }
199
- }
200
- export function checkbox(id, options = {}) {
201
- return new Checkbox(id, options);
202
- }