juxscript 1.1.239 → 1.1.243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/index.js +7 -137
  2. package/lib/components/dataframe.ts +0 -569
  3. package/lib/components/tag.ts +68 -0
  4. package/lib/styles/shadcn.css +20 -7
  5. package/lib/utils/idgen.ts +6 -0
  6. package/package.json +5 -6
  7. package/index.d.ts +0 -239
  8. package/index.d.ts.map +0 -1
  9. package/lib/components/alert.d.ts +0 -36
  10. package/lib/components/alert.d.ts.map +0 -1
  11. package/lib/components/alert.js +0 -172
  12. package/lib/components/alert.ts +0 -219
  13. package/lib/components/app.d.ts +0 -89
  14. package/lib/components/app.d.ts.map +0 -1
  15. package/lib/components/app.js +0 -175
  16. package/lib/components/app.ts +0 -247
  17. package/lib/components/badge.d.ts +0 -26
  18. package/lib/components/badge.d.ts.map +0 -1
  19. package/lib/components/badge.js +0 -91
  20. package/lib/components/badge.ts +0 -118
  21. package/lib/components/base/Animations.d.ts +0 -36
  22. package/lib/components/base/Animations.d.ts.map +0 -1
  23. package/lib/components/base/Animations.js +0 -70
  24. package/lib/components/base/Animations.ts +0 -112
  25. package/lib/components/base/BaseComponent.d.ts +0 -294
  26. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  27. package/lib/components/base/BaseComponent.js +0 -735
  28. package/lib/components/base/BaseComponent.ts +0 -884
  29. package/lib/components/base/FormInput.d.ts +0 -77
  30. package/lib/components/base/FormInput.d.ts.map +0 -1
  31. package/lib/components/base/FormInput.js +0 -171
  32. package/lib/components/base/FormInput.ts +0 -237
  33. package/lib/components/blueprint.d.ts +0 -40
  34. package/lib/components/blueprint.d.ts.map +0 -1
  35. package/lib/components/blueprint.js +0 -327
  36. package/lib/components/button.d.ts +0 -70
  37. package/lib/components/button.d.ts.map +0 -1
  38. package/lib/components/button.js +0 -177
  39. package/lib/components/button.ts +0 -237
  40. package/lib/components/card.d.ts +0 -35
  41. package/lib/components/card.d.ts.map +0 -1
  42. package/lib/components/card.js +0 -130
  43. package/lib/components/card.ts +0 -177
  44. package/lib/components/chart.d.ts +0 -49
  45. package/lib/components/chart.d.ts.map +0 -1
  46. package/lib/components/chart.js +0 -205
  47. package/lib/components/chart.ts +0 -254
  48. package/lib/components/checkbox.d.ts +0 -33
  49. package/lib/components/checkbox.d.ts.map +0 -1
  50. package/lib/components/checkbox.js +0 -202
  51. package/lib/components/checkbox.ts +0 -260
  52. package/lib/components/code.d.ts +0 -52
  53. package/lib/components/code.d.ts.map +0 -1
  54. package/lib/components/code.js +0 -201
  55. package/lib/components/code.ts +0 -260
  56. package/lib/components/container.d.ts +0 -60
  57. package/lib/components/container.d.ts.map +0 -1
  58. package/lib/components/container.js +0 -195
  59. package/lib/components/container.ts +0 -259
  60. package/lib/components/data.d.ts +0 -36
  61. package/lib/components/data.d.ts.map +0 -1
  62. package/lib/components/data.js +0 -110
  63. package/lib/components/data.ts +0 -135
  64. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  65. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  66. package/lib/components/dataframe/DataFrameSource.js +0 -421
  67. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  68. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  70. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  71. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  72. package/lib/components/dataframe.d.ts +0 -110
  73. package/lib/components/dataframe.d.ts.map +0 -1
  74. package/lib/components/dataframe.js +0 -470
  75. package/lib/components/datepicker.d.ts +0 -40
  76. package/lib/components/datepicker.d.ts.map +0 -1
  77. package/lib/components/datepicker.js +0 -193
  78. package/lib/components/datepicker.ts +0 -251
  79. package/lib/components/dialog.d.ts +0 -39
  80. package/lib/components/dialog.d.ts.map +0 -1
  81. package/lib/components/dialog.js +0 -131
  82. package/lib/components/dialog.ts +0 -178
  83. package/lib/components/divider.d.ts +0 -31
  84. package/lib/components/divider.d.ts.map +0 -1
  85. package/lib/components/divider.js +0 -72
  86. package/lib/components/divider.ts +0 -104
  87. package/lib/components/dropdown-menu.d.ts +0 -42
  88. package/lib/components/dropdown-menu.d.ts.map +0 -1
  89. package/lib/components/dropdown-menu.js +0 -177
  90. package/lib/components/dropdown-menu.ts +0 -214
  91. package/lib/components/dropdown.d.ts +0 -41
  92. package/lib/components/dropdown.d.ts.map +0 -1
  93. package/lib/components/dropdown.js +0 -136
  94. package/lib/components/dropdown.ts +0 -188
  95. package/lib/components/element.d.ts +0 -51
  96. package/lib/components/element.d.ts.map +0 -1
  97. package/lib/components/element.js +0 -209
  98. package/lib/components/element.ts +0 -271
  99. package/lib/components/event-chain.d.ts +0 -9
  100. package/lib/components/event-chain.d.ts.map +0 -1
  101. package/lib/components/event-chain.js +0 -33
  102. package/lib/components/fileupload.d.ts +0 -98
  103. package/lib/components/fileupload.d.ts.map +0 -1
  104. package/lib/components/fileupload.js +0 -351
  105. package/lib/components/fileupload.ts +0 -449
  106. package/lib/components/grid.d.ts +0 -88
  107. package/lib/components/grid.d.ts.map +0 -1
  108. package/lib/components/grid.js +0 -208
  109. package/lib/components/grid.ts +0 -295
  110. package/lib/components/heading.d.ts +0 -25
  111. package/lib/components/heading.d.ts.map +0 -1
  112. package/lib/components/heading.js +0 -83
  113. package/lib/components/heading.ts +0 -113
  114. package/lib/components/helpers.d.ts +0 -9
  115. package/lib/components/helpers.d.ts.map +0 -1
  116. package/lib/components/helpers.js +0 -30
  117. package/lib/components/helpers.ts +0 -41
  118. package/lib/components/hero.d.ts +0 -60
  119. package/lib/components/hero.d.ts.map +0 -1
  120. package/lib/components/hero.js +0 -239
  121. package/lib/components/hero.ts +0 -302
  122. package/lib/components/history/StateHistory.d.ts +0 -91
  123. package/lib/components/history/StateHistory.d.ts.map +0 -1
  124. package/lib/components/history/StateHistory.js +0 -154
  125. package/lib/components/history/StateHistory.ts +0 -200
  126. package/lib/components/icon.d.ts +0 -36
  127. package/lib/components/icon.d.ts.map +0 -1
  128. package/lib/components/icon.js +0 -135
  129. package/lib/components/icon.ts +0 -182
  130. package/lib/components/icons.d.ts +0 -25
  131. package/lib/components/icons.d.ts.map +0 -1
  132. package/lib/components/icons.js +0 -440
  133. package/lib/components/icons.ts +0 -464
  134. package/lib/components/image.d.ts +0 -42
  135. package/lib/components/image.d.ts.map +0 -1
  136. package/lib/components/image.js +0 -204
  137. package/lib/components/image.ts +0 -260
  138. package/lib/components/include.d.ts +0 -86
  139. package/lib/components/include.d.ts.map +0 -1
  140. package/lib/components/include.js +0 -238
  141. package/lib/components/include.ts +0 -281
  142. package/lib/components/input.d.ts +0 -85
  143. package/lib/components/input.d.ts.map +0 -1
  144. package/lib/components/input.js +0 -362
  145. package/lib/components/input.ts +0 -473
  146. package/lib/components/layer.d.ts +0 -72
  147. package/lib/components/layer.d.ts.map +0 -1
  148. package/lib/components/layer.js +0 -219
  149. package/lib/components/layer.ts +0 -304
  150. package/lib/components/link.d.ts +0 -41
  151. package/lib/components/link.d.ts.map +0 -1
  152. package/lib/components/link.js +0 -216
  153. package/lib/components/link.ts +0 -268
  154. package/lib/components/list.d.ts +0 -83
  155. package/lib/components/list.d.ts.map +0 -1
  156. package/lib/components/list.js +0 -314
  157. package/lib/components/list.ts +0 -423
  158. package/lib/components/loading.d.ts +0 -25
  159. package/lib/components/loading.d.ts.map +0 -1
  160. package/lib/components/loading.js +0 -76
  161. package/lib/components/loading.ts +0 -104
  162. package/lib/components/menu.d.ts +0 -38
  163. package/lib/components/menu.d.ts.map +0 -1
  164. package/lib/components/menu.js +0 -205
  165. package/lib/components/menu.ts +0 -279
  166. package/lib/components/modal.d.ts +0 -97
  167. package/lib/components/modal.d.ts.map +0 -1
  168. package/lib/components/modal.js +0 -463
  169. package/lib/components/modal.ts +0 -576
  170. package/lib/components/nav.d.ts +0 -46
  171. package/lib/components/nav.d.ts.map +0 -1
  172. package/lib/components/nav.js +0 -193
  173. package/lib/components/nav.ts +0 -261
  174. package/lib/components/paragraph.d.ts +0 -30
  175. package/lib/components/paragraph.d.ts.map +0 -1
  176. package/lib/components/paragraph.js +0 -93
  177. package/lib/components/paragraph.ts +0 -123
  178. package/lib/components/pen.d.ts +0 -125
  179. package/lib/components/pen.d.ts.map +0 -1
  180. package/lib/components/pen.js +0 -443
  181. package/lib/components/pen.ts +0 -567
  182. package/lib/components/progress.d.ts +0 -40
  183. package/lib/components/progress.d.ts.map +0 -1
  184. package/lib/components/progress.js +0 -116
  185. package/lib/components/progress.ts +0 -163
  186. package/lib/components/radio.d.ts +0 -43
  187. package/lib/components/radio.d.ts.map +0 -1
  188. package/lib/components/radio.js +0 -226
  189. package/lib/components/radio.ts +0 -303
  190. package/lib/components/registry.d.ts +0 -34
  191. package/lib/components/registry.d.ts.map +0 -1
  192. package/lib/components/registry.js +0 -163
  193. package/lib/components/registry.ts +0 -193
  194. package/lib/components/req.d.ts +0 -155
  195. package/lib/components/req.d.ts.map +0 -1
  196. package/lib/components/req.js +0 -253
  197. package/lib/components/req.ts +0 -303
  198. package/lib/components/script.d.ts +0 -14
  199. package/lib/components/script.d.ts.map +0 -1
  200. package/lib/components/script.js +0 -33
  201. package/lib/components/script.ts +0 -41
  202. package/lib/components/select.d.ts +0 -42
  203. package/lib/components/select.d.ts.map +0 -1
  204. package/lib/components/select.js +0 -209
  205. package/lib/components/select.ts +0 -281
  206. package/lib/components/sidebar.d.ts +0 -59
  207. package/lib/components/sidebar.d.ts.map +0 -1
  208. package/lib/components/sidebar.js +0 -298
  209. package/lib/components/sidebar.ts +0 -395
  210. package/lib/components/stack/BaseStack.d.ts +0 -65
  211. package/lib/components/stack/BaseStack.d.ts.map +0 -1
  212. package/lib/components/stack/BaseStack.js +0 -274
  213. package/lib/components/stack/BaseStack.ts +0 -328
  214. package/lib/components/stack/HStack.d.ts +0 -18
  215. package/lib/components/stack/HStack.d.ts.map +0 -1
  216. package/lib/components/stack/HStack.js +0 -22
  217. package/lib/components/stack/HStack.ts +0 -25
  218. package/lib/components/stack/VStack.d.ts +0 -19
  219. package/lib/components/stack/VStack.d.ts.map +0 -1
  220. package/lib/components/stack/VStack.js +0 -23
  221. package/lib/components/stack/VStack.ts +0 -26
  222. package/lib/components/stack/ZStack.d.ts +0 -18
  223. package/lib/components/stack/ZStack.d.ts.map +0 -1
  224. package/lib/components/stack/ZStack.js +0 -22
  225. package/lib/components/stack/ZStack.ts +0 -25
  226. package/lib/components/style.d.ts +0 -14
  227. package/lib/components/style.d.ts.map +0 -1
  228. package/lib/components/style.js +0 -33
  229. package/lib/components/style.ts +0 -41
  230. package/lib/components/switch.d.ts +0 -34
  231. package/lib/components/switch.d.ts.map +0 -1
  232. package/lib/components/switch.js +0 -209
  233. package/lib/components/switch.ts +0 -272
  234. package/lib/components/table.d.ts +0 -137
  235. package/lib/components/table.d.ts.map +0 -1
  236. package/lib/components/table.js +0 -1019
  237. package/lib/components/table.ts +0 -1225
  238. package/lib/components/tabs.d.ts +0 -53
  239. package/lib/components/tabs.d.ts.map +0 -1
  240. package/lib/components/tabs.js +0 -275
  241. package/lib/components/tabs.ts +0 -349
  242. package/lib/components/theme-toggle.d.ts +0 -45
  243. package/lib/components/theme-toggle.d.ts.map +0 -1
  244. package/lib/components/theme-toggle.js +0 -218
  245. package/lib/components/theme-toggle.ts +0 -297
  246. package/lib/components/tooltip.d.ts +0 -31
  247. package/lib/components/tooltip.d.ts.map +0 -1
  248. package/lib/components/tooltip.js +0 -112
  249. package/lib/components/tooltip.ts +0 -148
  250. package/lib/components/watcher.d.ts +0 -195
  251. package/lib/components/watcher.d.ts.map +0 -1
  252. package/lib/components/watcher.js +0 -241
  253. package/lib/components/watcher.ts +0 -261
  254. package/lib/components/write.d.ts +0 -107
  255. package/lib/components/write.d.ts.map +0 -1
  256. package/lib/components/write.js +0 -222
  257. package/lib/components/write.ts +0 -272
  258. package/lib/data/DataPipeline.d.ts +0 -113
  259. package/lib/data/DataPipeline.d.ts.map +0 -1
  260. package/lib/data/DataPipeline.js +0 -359
  261. package/lib/data/DataPipeline.ts +0 -452
  262. package/lib/facades/dataframe.jux +0 -0
  263. package/lib/globals.d.ts +0 -21
  264. package/lib/reactivity/state.d.ts +0 -36
  265. package/lib/reactivity/state.d.ts.map +0 -1
  266. package/lib/reactivity/state.js +0 -67
  267. package/lib/reactivity/state.ts +0 -78
  268. package/lib/storage/DataFrame.d.ts +0 -284
  269. package/lib/storage/DataFrame.d.ts.map +0 -1
  270. package/lib/storage/DataFrame.js +0 -1022
  271. package/lib/storage/DataFrame.ts +0 -1195
  272. package/lib/storage/DataFrameSource.d.ts +0 -158
  273. package/lib/storage/DataFrameSource.d.ts.map +0 -1
  274. package/lib/storage/DataFrameSource.js +0 -409
  275. package/lib/storage/DataFrameSource.ts +0 -556
  276. package/lib/storage/FileStorage.d.ts +0 -53
  277. package/lib/storage/FileStorage.d.ts.map +0 -1
  278. package/lib/storage/FileStorage.js +0 -80
  279. package/lib/storage/FileStorage.ts +0 -95
  280. package/lib/storage/IndexedDBDriver.d.ts +0 -75
  281. package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
  282. package/lib/storage/IndexedDBDriver.js +0 -177
  283. package/lib/storage/IndexedDBDriver.ts +0 -226
  284. package/lib/storage/TabularDriver.d.ts +0 -118
  285. package/lib/storage/TabularDriver.d.ts.map +0 -1
  286. package/lib/storage/TabularDriver.js +0 -731
  287. package/lib/storage/TabularDriver.ts +0 -874
  288. package/lib/utils/codeparser.d.ts +0 -29
  289. package/lib/utils/codeparser.d.ts.map +0 -1
  290. package/lib/utils/codeparser.js +0 -409
  291. package/lib/utils/fetch.d.ts +0 -176
  292. package/lib/utils/fetch.d.ts.map +0 -1
  293. package/lib/utils/fetch.js +0 -427
  294. package/lib/utils/formatId.d.ts +0 -16
  295. package/lib/utils/formatId.d.ts.map +0 -1
  296. package/lib/utils/formatId.js +0 -27
  297. package/lib/utils/path-resolver.js +0 -23
@@ -1,204 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { formatIdAsLabel } from '../utils/formatId.js';
3
- // Event definitions
4
- const TRIGGER_EVENTS = [];
5
- const CALLBACK_EVENTS = ['load', 'error'];
6
- export class Image extends BaseComponent {
7
- constructor(id, options = {}) {
8
- super(id, {
9
- visible: true,
10
- disabled: false,
11
- loading: false,
12
- class: options.class ?? '',
13
- style: options.style ?? '',
14
- attributes: {},
15
- src: options.src ?? '',
16
- alt: options.alt ?? formatIdAsLabel(id),
17
- objectFit: options.objectFit ?? 'cover',
18
- loadingType: options.loading ?? 'lazy',
19
- crossOrigin: options.crossOrigin,
20
- isLoaded: false,
21
- hasError: false
22
- });
23
- // Apply width/height if provided
24
- if (options.width) {
25
- this.state.style = this.state.style ? `${this.state.style}; width: ${options.width}` : `width: ${options.width}`;
26
- }
27
- if (options.height) {
28
- this.state.style = this.state.style ? `${this.state.style}; height: ${options.height}` : `height: ${options.height}`;
29
- }
30
- }
31
- getTriggerEvents() {
32
- return TRIGGER_EVENTS;
33
- }
34
- getCallbackEvents() {
35
- return CALLBACK_EVENTS;
36
- }
37
- /* ═════════════════════════════════════════════════════════════════
38
- * FLUENT API
39
- * ═════════════════════════════════════════════════════════════════ */
40
- src(value) {
41
- this.state.src = value;
42
- if (this.container) {
43
- const img = this.container.querySelector(`#${this._id}`);
44
- if (img) {
45
- img.src = value;
46
- this.state.isLoaded = false;
47
- this.state.hasError = false;
48
- }
49
- }
50
- return this;
51
- }
52
- alt(value) {
53
- this.state.alt = value;
54
- if (this.container) {
55
- const img = this.container.querySelector(`#${this._id}`);
56
- if (img)
57
- img.alt = value;
58
- }
59
- return this;
60
- }
61
- objectFit(value) {
62
- this.state.objectFit = value;
63
- if (this.container) {
64
- const img = this.container.querySelector(`#${this._id}`);
65
- if (img)
66
- img.style.objectFit = value;
67
- }
68
- return this;
69
- }
70
- lazy() {
71
- this.state.loadingType = 'lazy';
72
- return this;
73
- }
74
- eager() {
75
- this.state.loadingType = 'eager';
76
- return this;
77
- }
78
- crossOrigin(value) {
79
- this.state.crossOrigin = value;
80
- return this;
81
- }
82
- /* ═════════════════════════════════════════════════════════════════
83
- * STATE GETTERS
84
- * ═════════════════════════════════════════════════════════════════ */
85
- isLoaded() {
86
- return this.state.isLoaded;
87
- }
88
- hasError() {
89
- return this.state.hasError;
90
- }
91
- /* ═════════════════════════════════════════════════════════════════
92
- * RENDER
93
- * ═════════════════════════════════════════════════════════════════ */
94
- render(targetId) {
95
- const container = this._setupContainer(targetId);
96
- const { src, alt, objectFit, loadingType, crossOrigin, style, class: className } = this.state;
97
- const img = document.createElement('img');
98
- img.id = this._id;
99
- img.className = 'jux-image';
100
- if (className)
101
- img.className += ` ${className}`;
102
- if (style)
103
- img.setAttribute('style', style);
104
- img.src = src;
105
- img.alt = alt;
106
- img.style.objectFit = objectFit;
107
- img.loading = loadingType;
108
- if (crossOrigin) {
109
- img.crossOrigin = crossOrigin;
110
- }
111
- // Wire load event
112
- img.addEventListener('load', () => {
113
- this.state.isLoaded = true;
114
- this.state.hasError = false;
115
- this._triggerCallback('load', img);
116
- });
117
- // Wire error event
118
- img.addEventListener('error', () => {
119
- this.state.isLoaded = false;
120
- this.state.hasError = true;
121
- this._triggerCallback('error', img);
122
- });
123
- // Wire standard events (click, mouseover, etc.)
124
- this._wireStandardEvents(img);
125
- // Sync src changes
126
- const srcSync = this._syncBindings.find(b => b.property === 'src');
127
- if (srcSync) {
128
- const transform = srcSync.toComponent || ((v) => String(v));
129
- srcSync.stateObj.subscribe((val) => {
130
- this.src(transform(val));
131
- });
132
- }
133
- // Sync alt changes
134
- const altSync = this._syncBindings.find(b => b.property === 'alt');
135
- if (altSync) {
136
- const transform = altSync.toComponent || ((v) => String(v));
137
- altSync.stateObj.subscribe((val) => {
138
- this.alt(transform(val));
139
- });
140
- }
141
- container.appendChild(img);
142
- return this;
143
- }
144
- update(prop, value) {
145
- if (!this.container)
146
- return;
147
- const img = this.container.querySelector(`#${this._id}`);
148
- if (!img)
149
- return;
150
- // Handle image-specific updates
151
- switch (prop) {
152
- case 'src':
153
- img.src = value;
154
- this.state.isLoaded = false;
155
- this.state.hasError = false;
156
- break;
157
- case 'alt':
158
- img.alt = value;
159
- break;
160
- case 'objectFit':
161
- img.style.objectFit = value;
162
- break;
163
- case 'loadingType':
164
- img.loading = value;
165
- break;
166
- case 'crossOrigin':
167
- img.crossOrigin = value;
168
- break;
169
- // Base properties handled by BaseComponent.update()
170
- default:
171
- super.update(prop, value);
172
- break;
173
- }
174
- }
175
- }
176
- export function image(id, options = {}) {
177
- return new Image(id, options);
178
- }
179
- // Convenience helper for avatar/profile images
180
- export function avatar(id, src, alt) {
181
- return new Image(id, {
182
- src,
183
- alt: alt || 'Avatar',
184
- objectFit: 'cover',
185
- style: 'border-radius: 50%'
186
- });
187
- }
188
- // Convenience helper for logo images
189
- export function logo(id, src, alt) {
190
- return new Image(id, {
191
- src,
192
- alt: alt || 'Logo',
193
- objectFit: 'contain'
194
- });
195
- }
196
- // Convenience helper for thumbnail images
197
- export function thumbnail(id, src, alt) {
198
- return new Image(id, {
199
- src,
200
- alt: alt || 'Thumbnail',
201
- objectFit: 'cover',
202
- loading: 'lazy'
203
- });
204
- }
@@ -1,260 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- import { formatIdAsLabel } from '../utils/formatId.js';
3
-
4
- // Event definitions
5
- const TRIGGER_EVENTS = [] as const;
6
- const CALLBACK_EVENTS = ['load', 'error'] as const;
7
-
8
- export interface ImageOptions {
9
- src?: string;
10
- alt?: string;
11
- width?: string;
12
- height?: string;
13
- objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
14
- loading?: 'lazy' | 'eager';
15
- crossOrigin?: 'anonymous' | 'use-credentials';
16
- style?: string;
17
- class?: string;
18
- }
19
-
20
- interface ImageState extends BaseState {
21
- src: string;
22
- alt: string;
23
- objectFit: string;
24
- loadingType: string;
25
- crossOrigin?: string;
26
- isLoaded: boolean;
27
- hasError: boolean;
28
- }
29
-
30
- export class Image extends BaseComponent<ImageState> {
31
- constructor(id: string, options: ImageOptions = {}) {
32
- super(id, {
33
- visible: true,
34
- disabled: false,
35
- loading: false,
36
- class: options.class ?? '',
37
- style: options.style ?? '',
38
- attributes: {},
39
- src: options.src ?? '',
40
- alt: options.alt ?? formatIdAsLabel(id),
41
- objectFit: options.objectFit ?? 'cover',
42
- loadingType: options.loading ?? 'lazy',
43
- crossOrigin: options.crossOrigin,
44
- isLoaded: false,
45
- hasError: false
46
- });
47
-
48
- // Apply width/height if provided
49
- if (options.width) {
50
- this.state.style = this.state.style ? `${this.state.style}; width: ${options.width}` : `width: ${options.width}`;
51
- }
52
- if (options.height) {
53
- this.state.style = this.state.style ? `${this.state.style}; height: ${options.height}` : `height: ${options.height}`;
54
- }
55
- }
56
-
57
- protected getTriggerEvents(): readonly string[] {
58
- return TRIGGER_EVENTS;
59
- }
60
-
61
- protected getCallbackEvents(): readonly string[] {
62
- return CALLBACK_EVENTS;
63
- }
64
-
65
- /* ═════════════════════════════════════════════════════════════════
66
- * FLUENT API
67
- * ═════════════════════════════════════════════════════════════════ */
68
-
69
- src(value: string): this {
70
- this.state.src = value;
71
- if (this.container) {
72
- const img = this.container.querySelector(`#${this._id}`) as HTMLImageElement;
73
- if (img) {
74
- img.src = value;
75
- this.state.isLoaded = false;
76
- this.state.hasError = false;
77
- }
78
- }
79
- return this;
80
- }
81
-
82
- alt(value: string): this {
83
- this.state.alt = value;
84
- if (this.container) {
85
- const img = this.container.querySelector(`#${this._id}`) as HTMLImageElement;
86
- if (img) img.alt = value;
87
- }
88
- return this;
89
- }
90
-
91
- objectFit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down'): this {
92
- this.state.objectFit = value;
93
- if (this.container) {
94
- const img = this.container.querySelector(`#${this._id}`) as HTMLImageElement;
95
- if (img) img.style.objectFit = value;
96
- }
97
- return this;
98
- }
99
-
100
- lazy(): this {
101
- this.state.loadingType = 'lazy';
102
- return this;
103
- }
104
-
105
- eager(): this {
106
- this.state.loadingType = 'eager';
107
- return this;
108
- }
109
-
110
- crossOrigin(value: 'anonymous' | 'use-credentials'): this {
111
- this.state.crossOrigin = value;
112
- return this;
113
- }
114
-
115
- /* ═════════════════════════════════════════════════════════════════
116
- * STATE GETTERS
117
- * ═════════════════════════════════════════════════════════════════ */
118
-
119
- isLoaded(): boolean {
120
- return this.state.isLoaded;
121
- }
122
-
123
- hasError(): boolean {
124
- return this.state.hasError;
125
- }
126
-
127
- /* ═════════════════════════════════════════════════════════════════
128
- * RENDER
129
- * ═════════════════════════════════════════════════════════════════ */
130
-
131
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
132
- const container = this._setupContainer(targetId);
133
-
134
- const { src, alt, objectFit, loadingType, crossOrigin, style, class: className } = this.state;
135
-
136
- const img = document.createElement('img');
137
- img.id = this._id;
138
- img.className = 'jux-image';
139
- if (className) img.className += ` ${className}`;
140
- if (style) img.setAttribute('style', style);
141
-
142
- img.src = src;
143
- img.alt = alt;
144
- img.style.objectFit = objectFit;
145
- img.loading = loadingType as 'lazy' | 'eager';
146
-
147
- if (crossOrigin) {
148
- img.crossOrigin = crossOrigin;
149
- }
150
-
151
- // Wire load event
152
- img.addEventListener('load', () => {
153
- this.state.isLoaded = true;
154
- this.state.hasError = false;
155
- this._triggerCallback('load', img);
156
- });
157
-
158
- // Wire error event
159
- img.addEventListener('error', () => {
160
- this.state.isLoaded = false;
161
- this.state.hasError = true;
162
- this._triggerCallback('error', img);
163
- });
164
-
165
- // Wire standard events (click, mouseover, etc.)
166
- this._wireStandardEvents(img);
167
-
168
- // Sync src changes
169
- const srcSync = this._syncBindings.find(b => b.property === 'src');
170
- if (srcSync) {
171
- const transform = srcSync.toComponent || ((v: any) => String(v));
172
- srcSync.stateObj.subscribe((val: any) => {
173
- this.src(transform(val));
174
- });
175
- }
176
-
177
- // Sync alt changes
178
- const altSync = this._syncBindings.find(b => b.property === 'alt');
179
- if (altSync) {
180
- const transform = altSync.toComponent || ((v: any) => String(v));
181
- altSync.stateObj.subscribe((val: any) => {
182
- this.alt(transform(val));
183
- });
184
- }
185
-
186
- container.appendChild(img);
187
-
188
- return this;
189
- }
190
-
191
- update(prop: string, value: any): void {
192
- if (!this.container) return;
193
-
194
- const img = this.container.querySelector(`#${this._id}`) as HTMLImageElement;
195
- if (!img) return;
196
-
197
- // Handle image-specific updates
198
- switch (prop) {
199
- case 'src':
200
- img.src = value;
201
- this.state.isLoaded = false;
202
- this.state.hasError = false;
203
- break;
204
-
205
- case 'alt':
206
- img.alt = value;
207
- break;
208
-
209
- case 'objectFit':
210
- img.style.objectFit = value;
211
- break;
212
-
213
- case 'loadingType':
214
- img.loading = value as 'lazy' | 'eager';
215
- break;
216
-
217
- case 'crossOrigin':
218
- img.crossOrigin = value;
219
- break;
220
-
221
- // Base properties handled by BaseComponent.update()
222
- default:
223
- super.update(prop, value);
224
- break;
225
- }
226
- }
227
- }
228
-
229
- export function image(id: string, options: ImageOptions = {}): Image {
230
- return new Image(id, options);
231
- }
232
-
233
- // Convenience helper for avatar/profile images
234
- export function avatar(id: string, src: string, alt?: string): Image {
235
- return new Image(id, {
236
- src,
237
- alt: alt || 'Avatar',
238
- objectFit: 'cover',
239
- style: 'border-radius: 50%'
240
- });
241
- }
242
-
243
- // Convenience helper for logo images
244
- export function logo(id: string, src: string, alt?: string): Image {
245
- return new Image(id, {
246
- src,
247
- alt: alt || 'Logo',
248
- objectFit: 'contain'
249
- });
250
- }
251
-
252
- // Convenience helper for thumbnail images
253
- export function thumbnail(id: string, src: string, alt?: string): Image {
254
- return new Image(id, {
255
- src,
256
- alt: alt || 'Thumbnail',
257
- objectFit: 'cover',
258
- loading: 'lazy'
259
- });
260
- }
@@ -1,86 +0,0 @@
1
- /**
2
- * Include - Simplified resource injection for bundled and external resources
3
- * Supports page-specific scoping and cleanup
4
- */
5
- type ResourceType = 'css' | 'js' | 'module';
6
- interface IncludeOptions {
7
- type?: ResourceType;
8
- target?: string;
9
- async?: boolean;
10
- defer?: boolean;
11
- crossOrigin?: 'anonymous' | 'use-credentials';
12
- integrity?: string;
13
- pageScoped?: boolean;
14
- }
15
- export declare class Include {
16
- private url;
17
- private options;
18
- private element;
19
- private pageId;
20
- constructor(url: string, options?: IncludeOptions);
21
- css(): this;
22
- js(): this;
23
- module(): this;
24
- async(): this;
25
- defer(): this;
26
- /**
27
- * Inject into specific container instead of <head>
28
- * Useful for page-specific styles
29
- *
30
- * @example
31
- * jux.include('/css/page1.css').into('#page1-container');
32
- */
33
- into(selector: string): this;
34
- /**
35
- * Mark as page-scoped for automatic cleanup
36
- *
37
- * @example
38
- * jux.include('/css/dashboard.css').forPage('dashboard');
39
- * // Later: Include.cleanupPage('dashboard');
40
- */
41
- forPage(pageId: string): this;
42
- render(): this;
43
- private createStylesheet;
44
- private createScript;
45
- private getContainer;
46
- private isAlreadyLoaded;
47
- remove(): this;
48
- /**
49
- * Remove all resources for a specific page
50
- *
51
- * @example
52
- * Include.cleanupPage('dashboard');
53
- */
54
- static cleanupPage(pageId: string): void;
55
- /**
56
- * Remove all page-scoped resources
57
- */
58
- static cleanupAll(): void;
59
- }
60
- /**
61
- * Factory function - simplified usage
62
- *
63
- * Usage:
64
- * // Basic (auto-detects from extension)
65
- * jux.include('/css/styles.css');
66
- * jux.include('/js/app.js');
67
- *
68
- * // Page-specific with cleanup
69
- * jux.include('/css/dashboard.css').forPage('dashboard');
70
- * jux.include('/js/dashboard.js').forPage('dashboard');
71
- *
72
- * // Later cleanup:
73
- * Include.cleanupPage('dashboard');
74
- *
75
- * // Inject into specific container
76
- * jux.include('/css/widget.css').into('#widget-container');
77
- *
78
- * // External CDN
79
- * jux.include('https://cdn.tailwindcss.com').js();
80
- *
81
- * // Module
82
- * jux.include('/js/app.mjs').module();
83
- */
84
- export declare function include(url: string, options?: IncludeOptions): Include;
85
- export {};
86
- //# sourceMappingURL=include.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["include.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,YAAY,GAAG,KAAK,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE5C,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAKD,qBAAa,OAAO;IAClB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAAuB;gBAEzB,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IAoBrD,GAAG,IAAI,IAAI;IAKX,EAAE,IAAI,IAAI;IAKV,MAAM,IAAI,IAAI;IAKd,KAAK,IAAI,IAAI;IAKb,KAAK,IAAI,IAAI;IAKb;;;;;;OAMG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAU7B,MAAM,IAAI,IAAI;IAoDd,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,eAAe;IAKvB,MAAM,IAAI,IAAI;IAYd;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYxC;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;CAS1B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAItE"}