juxscript 1.1.4 → 1.1.6

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 (205) hide show
  1. package/index.d.ts +10 -10
  2. package/index.d.ts.map +1 -0
  3. package/lib/components/alert.d.ts +32 -0
  4. package/lib/components/alert.d.ts.map +1 -0
  5. package/lib/components/alert.js +153 -0
  6. package/lib/components/alert.ts +200 -0
  7. package/lib/components/app.d.ts +89 -0
  8. package/lib/components/app.d.ts.map +1 -0
  9. package/lib/components/app.js +175 -0
  10. package/lib/components/app.ts +247 -0
  11. package/lib/components/badge.d.ts +27 -0
  12. package/lib/components/badge.d.ts.map +1 -0
  13. package/lib/components/badge.js +70 -0
  14. package/lib/components/badge.ts +101 -0
  15. package/lib/components/base/BaseComponent.d.ts +142 -0
  16. package/lib/components/base/BaseComponent.d.ts.map +1 -0
  17. package/lib/components/base/BaseComponent.js +363 -0
  18. package/lib/components/base/BaseComponent.ts +421 -0
  19. package/lib/components/base/FormInput.d.ts +73 -0
  20. package/lib/components/base/FormInput.d.ts.map +1 -0
  21. package/lib/components/base/FormInput.js +163 -0
  22. package/lib/components/base/FormInput.ts +227 -0
  23. package/lib/components/button.d.ts +48 -0
  24. package/lib/components/button.d.ts.map +1 -0
  25. package/lib/components/button.js +121 -0
  26. package/lib/components/button.ts +178 -0
  27. package/lib/components/card.d.ts +34 -0
  28. package/lib/components/card.d.ts.map +1 -0
  29. package/lib/components/card.js +127 -0
  30. package/lib/components/card.ts +173 -0
  31. package/lib/components/chart.d.ts +45 -0
  32. package/lib/components/chart.d.ts.map +1 -0
  33. package/lib/components/chart.js +186 -0
  34. package/lib/components/chart.ts +231 -0
  35. package/lib/components/checkbox.d.ts +31 -0
  36. package/lib/components/checkbox.d.ts.map +1 -0
  37. package/lib/components/checkbox.js +185 -0
  38. package/lib/components/checkbox.ts +242 -0
  39. package/lib/components/code.d.ts +24 -0
  40. package/lib/components/code.d.ts.map +1 -0
  41. package/lib/components/code.js +88 -0
  42. package/lib/components/code.ts +123 -0
  43. package/lib/components/container.d.ts +42 -0
  44. package/lib/components/container.d.ts.map +1 -0
  45. package/lib/components/container.js +93 -0
  46. package/lib/components/container.ts +140 -0
  47. package/lib/components/data.d.ts +36 -0
  48. package/lib/components/data.d.ts.map +1 -0
  49. package/lib/components/data.js +110 -0
  50. package/lib/components/data.ts +135 -0
  51. package/lib/components/datepicker.d.ts +38 -0
  52. package/lib/components/datepicker.d.ts.map +1 -0
  53. package/lib/components/datepicker.js +177 -0
  54. package/lib/components/datepicker.ts +234 -0
  55. package/lib/components/dialog.d.ts +38 -0
  56. package/lib/components/dialog.d.ts.map +1 -0
  57. package/lib/components/dialog.js +126 -0
  58. package/lib/components/dialog.ts +172 -0
  59. package/lib/components/divider.d.ts +30 -0
  60. package/lib/components/divider.d.ts.map +1 -0
  61. package/lib/components/divider.js +69 -0
  62. package/lib/components/divider.ts +100 -0
  63. package/lib/components/dropdown.d.ts +39 -0
  64. package/lib/components/dropdown.d.ts.map +1 -0
  65. package/lib/components/dropdown.js +133 -0
  66. package/lib/components/dropdown.ts +186 -0
  67. package/lib/components/element.d.ts +50 -0
  68. package/lib/components/element.d.ts.map +1 -0
  69. package/lib/components/element.js +206 -0
  70. package/lib/components/element.ts +267 -0
  71. package/lib/components/fileupload.d.ts +40 -0
  72. package/lib/components/fileupload.d.ts.map +1 -0
  73. package/lib/components/fileupload.js +241 -0
  74. package/lib/components/fileupload.ts +309 -0
  75. package/lib/components/grid.d.ts +87 -0
  76. package/lib/components/grid.d.ts.map +1 -0
  77. package/lib/components/grid.js +205 -0
  78. package/lib/components/grid.ts +291 -0
  79. package/lib/components/guard.d.ts +41 -0
  80. package/lib/components/guard.d.ts.map +1 -0
  81. package/lib/components/guard.js +56 -0
  82. package/lib/components/guard.ts +92 -0
  83. package/lib/components/heading.d.ts +24 -0
  84. package/lib/components/heading.d.ts.map +1 -0
  85. package/lib/components/heading.js +67 -0
  86. package/lib/components/heading.ts +96 -0
  87. package/lib/components/helpers.d.ts +9 -0
  88. package/lib/components/helpers.d.ts.map +1 -0
  89. package/lib/components/helpers.js +30 -0
  90. package/lib/components/helpers.ts +41 -0
  91. package/lib/components/hero.d.ts +45 -0
  92. package/lib/components/hero.d.ts.map +1 -0
  93. package/lib/components/hero.js +165 -0
  94. package/lib/components/hero.ts +224 -0
  95. package/lib/components/icon.d.ts +35 -0
  96. package/lib/components/icon.d.ts.map +1 -0
  97. package/lib/components/icon.js +132 -0
  98. package/lib/components/icon.ts +178 -0
  99. package/lib/components/icons.d.ts +25 -0
  100. package/lib/components/icons.d.ts.map +1 -0
  101. package/lib/components/icons.js +440 -0
  102. package/lib/components/icons.ts +464 -0
  103. package/lib/components/include.d.ts +120 -0
  104. package/lib/components/include.d.ts.map +1 -0
  105. package/lib/components/include.js +350 -0
  106. package/lib/components/include.ts +410 -0
  107. package/lib/components/input.d.ts +83 -0
  108. package/lib/components/input.d.ts.map +1 -0
  109. package/lib/components/input.js +348 -0
  110. package/lib/components/input.ts +457 -0
  111. package/lib/components/list.d.ts +82 -0
  112. package/lib/components/list.d.ts.map +1 -0
  113. package/lib/components/list.js +311 -0
  114. package/lib/components/list.ts +419 -0
  115. package/lib/components/loading.d.ts +24 -0
  116. package/lib/components/loading.d.ts.map +1 -0
  117. package/lib/components/loading.js +73 -0
  118. package/lib/components/loading.ts +100 -0
  119. package/lib/components/menu.d.ts +37 -0
  120. package/lib/components/menu.d.ts.map +1 -0
  121. package/lib/components/menu.js +202 -0
  122. package/lib/components/menu.ts +275 -0
  123. package/lib/components/modal.d.ts +51 -0
  124. package/lib/components/modal.d.ts.map +1 -0
  125. package/lib/components/modal.js +227 -0
  126. package/lib/components/modal.ts +284 -0
  127. package/lib/components/nav.d.ts +45 -0
  128. package/lib/components/nav.d.ts.map +1 -0
  129. package/lib/components/nav.js +190 -0
  130. package/lib/components/nav.ts +257 -0
  131. package/lib/components/paragraph.d.ts +21 -0
  132. package/lib/components/paragraph.d.ts.map +1 -0
  133. package/lib/components/paragraph.js +70 -0
  134. package/lib/components/paragraph.ts +97 -0
  135. package/lib/components/progress.d.ts +39 -0
  136. package/lib/components/progress.d.ts.map +1 -0
  137. package/lib/components/progress.js +113 -0
  138. package/lib/components/progress.ts +159 -0
  139. package/lib/components/radio.d.ts +41 -0
  140. package/lib/components/radio.d.ts.map +1 -0
  141. package/lib/components/radio.js +203 -0
  142. package/lib/components/radio.ts +278 -0
  143. package/lib/components/req.d.ts +155 -0
  144. package/lib/components/req.d.ts.map +1 -0
  145. package/lib/components/req.js +253 -0
  146. package/lib/components/req.ts +303 -0
  147. package/lib/components/script.d.ts +14 -0
  148. package/lib/components/script.d.ts.map +1 -0
  149. package/lib/components/script.js +33 -0
  150. package/lib/components/script.ts +41 -0
  151. package/lib/components/select.d.ts +40 -0
  152. package/lib/components/select.d.ts.map +1 -0
  153. package/lib/components/select.js +183 -0
  154. package/lib/components/select.ts +252 -0
  155. package/lib/components/sidebar.d.ts +48 -0
  156. package/lib/components/sidebar.d.ts.map +1 -0
  157. package/lib/components/sidebar.js +207 -0
  158. package/lib/components/sidebar.ts +275 -0
  159. package/lib/components/style.d.ts +14 -0
  160. package/lib/components/style.d.ts.map +1 -0
  161. package/lib/components/style.js +33 -0
  162. package/lib/components/style.ts +41 -0
  163. package/lib/components/switch.d.ts +32 -0
  164. package/lib/components/switch.d.ts.map +1 -0
  165. package/lib/components/switch.js +186 -0
  166. package/lib/components/switch.ts +246 -0
  167. package/lib/components/table.d.ts +137 -0
  168. package/lib/components/table.d.ts.map +1 -0
  169. package/lib/components/table.js +1045 -0
  170. package/lib/components/table.ts +1249 -0
  171. package/lib/components/tabs.d.ts +36 -0
  172. package/lib/components/tabs.d.ts.map +1 -0
  173. package/lib/components/tabs.js +198 -0
  174. package/lib/components/tabs.ts +250 -0
  175. package/lib/components/theme-toggle.d.ts +44 -0
  176. package/lib/components/theme-toggle.d.ts.map +1 -0
  177. package/lib/components/theme-toggle.js +215 -0
  178. package/lib/components/theme-toggle.ts +293 -0
  179. package/lib/components/tooltip.d.ts +30 -0
  180. package/lib/components/tooltip.d.ts.map +1 -0
  181. package/lib/components/tooltip.js +109 -0
  182. package/lib/components/tooltip.ts +144 -0
  183. package/lib/components/view.d.ts +48 -0
  184. package/lib/components/view.d.ts.map +1 -0
  185. package/lib/components/view.js +149 -0
  186. package/lib/components/view.ts +190 -0
  187. package/lib/components/write.d.ts +107 -0
  188. package/lib/components/write.d.ts.map +1 -0
  189. package/lib/components/write.js +222 -0
  190. package/lib/components/write.ts +272 -0
  191. package/lib/layouts/default.css +260 -0
  192. package/lib/layouts/figma.css +334 -0
  193. package/lib/reactivity/state.d.ts +36 -0
  194. package/lib/reactivity/state.d.ts.map +1 -0
  195. package/lib/reactivity/state.js +67 -0
  196. package/lib/reactivity/state.ts +78 -0
  197. package/lib/utils/fetch.d.ts +176 -0
  198. package/lib/utils/fetch.d.ts.map +1 -0
  199. package/lib/utils/fetch.js +427 -0
  200. package/lib/utils/fetch.ts +553 -0
  201. package/machinery/compiler3.js +78 -0
  202. package/machinery/doc-generator.js +136 -0
  203. package/machinery/imports.js +155 -0
  204. package/machinery/ts-shim.js +46 -0
  205. package/package.json +9 -15
@@ -0,0 +1,127 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ import { renderIcon } from './icons.js';
3
+ // Event definitions - Card is display-only, no interactive events
4
+ const TRIGGER_EVENTS = [];
5
+ const CALLBACK_EVENTS = ['click']; // ✅ Can be clicked for navigation/selection
6
+ export class Card extends BaseComponent {
7
+ constructor(id, options = {}) {
8
+ super(id, {
9
+ title: options.title ?? '',
10
+ content: options.content ?? '',
11
+ footer: options.footer ?? '',
12
+ variant: options.variant ?? 'default',
13
+ hoverable: options.hoverable ?? false,
14
+ icon: options.icon ?? '',
15
+ style: options.style ?? '',
16
+ class: options.class ?? ''
17
+ });
18
+ }
19
+ getTriggerEvents() {
20
+ return TRIGGER_EVENTS;
21
+ }
22
+ getCallbackEvents() {
23
+ return CALLBACK_EVENTS;
24
+ }
25
+ /* ═════════════════════════════════════════════════════════════════
26
+ * FLUENT API
27
+ * ═════════════════════════════════════════════════════════════════ */
28
+ // ✅ Inherited from BaseComponent
29
+ title(value) {
30
+ this.state.title = value;
31
+ return this;
32
+ }
33
+ content(value) {
34
+ this.state.content = value;
35
+ return this;
36
+ }
37
+ footer(value) {
38
+ this.state.footer = value;
39
+ return this;
40
+ }
41
+ icon(value) {
42
+ this.state.icon = value;
43
+ return this;
44
+ }
45
+ /* ═════════════════════════════════════════════════════════════════
46
+ * RENDER
47
+ * ═════════════════════════════════════════════════════════════════ */
48
+ render(targetId) {
49
+ const container = this._setupContainer(targetId);
50
+ const { title, content, footer, variant, hoverable, icon, style, class: className } = this.state;
51
+ const card = document.createElement('div');
52
+ card.className = `jux-card jux-card-${variant}`;
53
+ card.id = this._id;
54
+ if (hoverable)
55
+ card.classList.add('jux-card-hoverable');
56
+ if (className)
57
+ card.className += ` ${className}`;
58
+ if (style)
59
+ card.setAttribute('style', style);
60
+ if (title || icon) {
61
+ const header = document.createElement('div');
62
+ header.className = 'jux-card-header';
63
+ if (icon) {
64
+ const iconEl = document.createElement('span');
65
+ iconEl.className = 'jux-card-icon';
66
+ iconEl.appendChild(renderIcon(icon));
67
+ header.appendChild(iconEl);
68
+ }
69
+ if (title) {
70
+ const titleEl = document.createElement('span');
71
+ titleEl.className = 'jux-card-title';
72
+ titleEl.textContent = title;
73
+ header.appendChild(titleEl);
74
+ }
75
+ card.appendChild(header);
76
+ }
77
+ const body = document.createElement('div');
78
+ body.className = 'jux-card-body';
79
+ body.innerHTML = content;
80
+ card.appendChild(body);
81
+ if (footer) {
82
+ const footerEl = document.createElement('div');
83
+ footerEl.className = 'jux-card-footer';
84
+ footerEl.innerHTML = footer;
85
+ card.appendChild(footerEl);
86
+ }
87
+ this._wireStandardEvents(card);
88
+ // Wire sync bindings
89
+ this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
90
+ if (property === 'title') {
91
+ const transform = toComponent || ((v) => String(v));
92
+ stateObj.subscribe((val) => {
93
+ const transformed = transform(val);
94
+ const header = card.querySelector('.jux-card-header');
95
+ if (header) {
96
+ header.textContent = transformed;
97
+ }
98
+ this.state.title = transformed;
99
+ });
100
+ }
101
+ else if (property === 'content') {
102
+ const transform = toComponent || ((v) => String(v));
103
+ stateObj.subscribe((val) => {
104
+ const transformed = transform(val);
105
+ body.innerHTML = transformed;
106
+ this.state.content = transformed;
107
+ });
108
+ }
109
+ else if (property === 'footer') {
110
+ const transform = toComponent || ((v) => String(v));
111
+ stateObj.subscribe((val) => {
112
+ const transformed = transform(val);
113
+ const footerEl = card.querySelector('.jux-card-footer');
114
+ if (footerEl) {
115
+ footerEl.innerHTML = transformed;
116
+ }
117
+ this.state.footer = transformed;
118
+ });
119
+ }
120
+ });
121
+ container.appendChild(card);
122
+ return this;
123
+ }
124
+ }
125
+ export function card(id, options = {}) {
126
+ return new Card(id, options);
127
+ }
@@ -0,0 +1,173 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ import { renderIcon } from './icons.js';
3
+
4
+ // Event definitions - Card is display-only, no interactive events
5
+ const TRIGGER_EVENTS = [] as const;
6
+ const CALLBACK_EVENTS = ['click'] as const; // ✅ Can be clicked for navigation/selection
7
+
8
+ export interface CardOptions {
9
+ title?: string;
10
+ content?: string;
11
+ footer?: string;
12
+ variant?: string;
13
+ hoverable?: boolean;
14
+ icon?: string;
15
+ style?: string;
16
+ class?: string;
17
+ }
18
+
19
+ type CardState = {
20
+ title: string;
21
+ content: string;
22
+ footer: string;
23
+ variant: string;
24
+ hoverable: boolean;
25
+ icon: string;
26
+ style: string;
27
+ class: string;
28
+ };
29
+
30
+ export class Card extends BaseComponent<CardState> {
31
+ constructor(id: string, options: CardOptions = {}) {
32
+ super(id, {
33
+ title: options.title ?? '',
34
+ content: options.content ?? '',
35
+ footer: options.footer ?? '',
36
+ variant: options.variant ?? 'default',
37
+ hoverable: options.hoverable ?? false,
38
+ icon: options.icon ?? '',
39
+ style: options.style ?? '',
40
+ class: options.class ?? ''
41
+ });
42
+ }
43
+
44
+ protected getTriggerEvents(): readonly string[] {
45
+ return TRIGGER_EVENTS;
46
+ }
47
+
48
+ protected getCallbackEvents(): readonly string[] {
49
+ return CALLBACK_EVENTS;
50
+ }
51
+
52
+ /* ═════════════════════════════════════════════════════════════════
53
+ * FLUENT API
54
+ * ═════════════════════════════════════════════════════════════════ */
55
+
56
+ // ✅ Inherited from BaseComponent
57
+
58
+ title(value: string): this {
59
+ this.state.title = value;
60
+ return this;
61
+ }
62
+
63
+ content(value: string): this {
64
+ this.state.content = value;
65
+ return this;
66
+ }
67
+
68
+ footer(value: string): this {
69
+ this.state.footer = value;
70
+ return this;
71
+ }
72
+
73
+ icon(value: string): this {
74
+ this.state.icon = value;
75
+ return this;
76
+ }
77
+
78
+ /* ═════════════════════════════════════════════════════════════════
79
+ * RENDER
80
+ * ═════════════════════════════════════════════════════════════════ */
81
+
82
+ render(targetId?: string): this {
83
+ const container = this._setupContainer(targetId);
84
+
85
+ const { title, content, footer, variant, hoverable, icon, style, class: className } = this.state;
86
+
87
+ const card = document.createElement('div');
88
+ card.className = `jux-card jux-card-${variant}`;
89
+ card.id = this._id;
90
+ if (hoverable) card.classList.add('jux-card-hoverable');
91
+ if (className) card.className += ` ${className}`;
92
+ if (style) card.setAttribute('style', style);
93
+
94
+ if (title || icon) {
95
+ const header = document.createElement('div');
96
+ header.className = 'jux-card-header';
97
+
98
+ if (icon) {
99
+ const iconEl = document.createElement('span');
100
+ iconEl.className = 'jux-card-icon';
101
+ iconEl.appendChild(renderIcon(icon));
102
+ header.appendChild(iconEl);
103
+ }
104
+
105
+ if (title) {
106
+ const titleEl = document.createElement('span');
107
+ titleEl.className = 'jux-card-title';
108
+ titleEl.textContent = title;
109
+ header.appendChild(titleEl);
110
+ }
111
+
112
+ card.appendChild(header);
113
+ }
114
+
115
+ const body = document.createElement('div');
116
+ body.className = 'jux-card-body';
117
+ body.innerHTML = content;
118
+ card.appendChild(body);
119
+
120
+ if (footer) {
121
+ const footerEl = document.createElement('div');
122
+ footerEl.className = 'jux-card-footer';
123
+ footerEl.innerHTML = footer;
124
+ card.appendChild(footerEl);
125
+ }
126
+
127
+ this._wireStandardEvents(card);
128
+
129
+ // Wire sync bindings
130
+ this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
131
+ if (property === 'title') {
132
+ const transform = toComponent || ((v: any) => String(v));
133
+
134
+ stateObj.subscribe((val: any) => {
135
+ const transformed = transform(val);
136
+ const header = card.querySelector('.jux-card-header');
137
+ if (header) {
138
+ header.textContent = transformed;
139
+ }
140
+ this.state.title = transformed;
141
+ });
142
+ }
143
+ else if (property === 'content') {
144
+ const transform = toComponent || ((v: any) => String(v));
145
+
146
+ stateObj.subscribe((val: any) => {
147
+ const transformed = transform(val);
148
+ body.innerHTML = transformed;
149
+ this.state.content = transformed;
150
+ });
151
+ }
152
+ else if (property === 'footer') {
153
+ const transform = toComponent || ((v: any) => String(v));
154
+
155
+ stateObj.subscribe((val: any) => {
156
+ const transformed = transform(val);
157
+ const footerEl = card.querySelector('.jux-card-footer');
158
+ if (footerEl) {
159
+ footerEl.innerHTML = transformed;
160
+ }
161
+ this.state.footer = transformed;
162
+ });
163
+ }
164
+ });
165
+
166
+ container.appendChild(card);
167
+ return this;
168
+ }
169
+ }
170
+
171
+ export function card(id: string, options: CardOptions = {}): Card {
172
+ return new Card(id, options);
173
+ }
@@ -0,0 +1,45 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ import { Chart, ChartType, ChartOptions, ChartData } from 'chart.js/auto';
3
+ export interface ChartState {
4
+ type: ChartType;
5
+ data: ChartData;
6
+ options: ChartOptions;
7
+ style?: string;
8
+ class?: string;
9
+ visible?: boolean;
10
+ disabled?: boolean;
11
+ loading?: boolean;
12
+ }
13
+ /**
14
+ * Chart component using Chart.js
15
+ * Provides fluent API for creating and configuring charts
16
+ */
17
+ export declare class ChartComponent extends BaseComponent<ChartState> {
18
+ private static readonly TRIGGER_EVENTS;
19
+ private static readonly CALLBACK_EVENTS;
20
+ private chartInstance;
21
+ constructor(id: string, type?: ChartType, options?: Partial<ChartState>);
22
+ protected getTriggerEvents(): readonly string[];
23
+ protected getCallbackEvents(): readonly string[];
24
+ type(value: ChartType): this;
25
+ data(value: ChartData): this;
26
+ labels(value: string[]): this;
27
+ datasets(value: any[]): this;
28
+ addDataset(dataset: any): this;
29
+ options(value: ChartOptions): this;
30
+ responsive(value?: boolean): this;
31
+ maintainAspectRatio(value?: boolean): this;
32
+ title(text: string, display?: boolean): this;
33
+ legend(display?: boolean, position?: 'top' | 'bottom' | 'left' | 'right'): this;
34
+ tooltip(enabled?: boolean): this;
35
+ update(mode?: 'resize' | 'reset' | 'none' | 'hide' | 'show' | 'default'): this;
36
+ reset(): this;
37
+ destroy(): this;
38
+ getChart(): Chart | null;
39
+ render(targetId?: string): this;
40
+ }
41
+ /**
42
+ * Factory function for creating chart components
43
+ */
44
+ export declare function chart(id: string, type?: ChartType, options?: Partial<ChartState>): ChartComponent;
45
+ //# sourceMappingURL=chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAsB,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI9F,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,aAAa,CAAC,UAAU,CAAC;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAyB;IAC/D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAsD;IAC7F,OAAO,CAAC,aAAa,CAAsB;gBAE/B,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,SAAiB,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;IAS9E,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAoB5B,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAS5B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAS7B,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;IAS5B,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAa9B,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IASlC,UAAU,CAAC,KAAK,GAAE,OAAc,GAAG,IAAI;IAIvC,mBAAmB,CAAC,KAAK,GAAE,OAAc,GAAG,IAAI;IAIhD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,OAAc,GAAG,IAAI;IASlD,MAAM,CAAC,OAAO,GAAE,OAAc,EAAE,QAAQ,GAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAe,GAAG,IAAI;IAS5F,OAAO,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAatC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;IAQ9E,KAAK,IAAI,IAAI;IAOb,OAAO,IAAI,IAAI;IASf,QAAQ,IAAI,KAAK,GAAG,IAAI;IAQxB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAqClC;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,SAAiB,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,cAAc,CAExG"}
@@ -0,0 +1,186 @@
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
+ update(mode) {
121
+ if (this.chartInstance) {
122
+ this.chartInstance.update(mode);
123
+ this._triggerCallback('update', this.chartInstance);
124
+ }
125
+ return this;
126
+ }
127
+ reset() {
128
+ if (this.chartInstance) {
129
+ this.chartInstance.reset();
130
+ }
131
+ return this;
132
+ }
133
+ destroy() {
134
+ if (this.chartInstance) {
135
+ this.chartInstance.destroy();
136
+ this.chartInstance = null;
137
+ this._triggerCallback('destroy');
138
+ }
139
+ return this;
140
+ }
141
+ getChart() {
142
+ return this.chartInstance;
143
+ }
144
+ /* ═════════════════════════════════════════════════════════════════
145
+ * RENDER
146
+ * ═════════════════════════════════════════════════════════════════ */
147
+ render(targetId) {
148
+ const container = this._setupContainer(targetId);
149
+ // Destroy existing chart
150
+ if (this.chartInstance) {
151
+ this.chartInstance.destroy();
152
+ }
153
+ // Clear container and create canvas
154
+ container.innerHTML = '';
155
+ const canvas = document.createElement('canvas');
156
+ canvas.id = `${this._id}-canvas`;
157
+ // Apply styles and classes
158
+ if (this.state.style)
159
+ container.setAttribute('style', this.state.style);
160
+ if (this.state.class)
161
+ container.className = this.state.class;
162
+ if (this.state.visible === false)
163
+ container.style.display = 'none';
164
+ container.appendChild(canvas);
165
+ // Create Chart.js instance
166
+ const config = {
167
+ type: this.state.type,
168
+ data: this.state.data,
169
+ options: this.state.options
170
+ };
171
+ this.chartInstance = new Chart(canvas, config);
172
+ // Wire events and syncs
173
+ this._wireStandardEvents(container);
174
+ this._wireAllSyncs();
175
+ this._triggerCallback('render', this.chartInstance);
176
+ return this;
177
+ }
178
+ }
179
+ ChartComponent.TRIGGER_EVENTS = [];
180
+ ChartComponent.CALLBACK_EVENTS = ['render', 'update', 'destroy'];
181
+ /**
182
+ * Factory function for creating chart components
183
+ */
184
+ export function chart(id, type = 'bar', options) {
185
+ return new ChartComponent(id, type, options);
186
+ }