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,449 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { formatIdAsLabel } from '../utils/formatId.js';
4
- import { FileStorage } from '../storage/FileStorage.js';
5
- import { TabularDriver } from '../storage/TabularDriver.js';
6
- import { DataFrame } from '../storage/DataFrame.js';
7
-
8
- // Event definitions
9
- const TRIGGER_EVENTS = [] as const;
10
- const CALLBACK_EVENTS = ['change', 'filesSelected', 'clear', 'stored'] as const;
11
-
12
- export interface FileUploadOptions {
13
- label?: string;
14
- accept?: string;
15
- multiple?: boolean;
16
- icon?: string;
17
- variant?: 'outline' | 'primary' | 'ghost' | 'secondary';
18
- showFileList?: boolean;
19
- maxFiles?: number;
20
- maxFileSize?: number;
21
- disabled?: boolean;
22
- required?: boolean;
23
- name?: string;
24
- onValidate?: (files: File[]) => boolean | string;
25
- storage?: FileStorage;
26
- metadata?: Record<string, any>;
27
- style?: string;
28
- class?: string;
29
- }
30
-
31
- type FileUploadState = BaseState & {
32
- label: string;
33
- accept: string;
34
- multiple: boolean;
35
- icon: string;
36
- variant: string;
37
- showFileList: boolean;
38
- maxFiles: number;
39
- maxFileSize: number;
40
- files: File[];
41
- };
42
-
43
- export class FileUpload extends BaseComponent<FileUploadState> {
44
- private _fileListElement: HTMLElement | null = null;
45
- private _storage: FileStorage | null = null;
46
- private _metadata: Record<string, any> | undefined;
47
-
48
- /** IndexedDB caching */
49
- private _cacheEnabled: boolean = false;
50
- private _cacheDriver: TabularDriver | null = null;
51
- private _cacheDbName: string = 'jux-dataframes';
52
- private _cacheStoreName: string = 'frames';
53
- private _cacheKeyPrefix: string = '';
54
- private _storageKeys: Map<string, string> = new Map();
55
- private _lastStorageKey: string | null = null;
56
- private _cachedDataFrames: Map<string, DataFrame> = new Map();
57
-
58
- constructor(id: string, options: FileUploadOptions = {}) {
59
- super(id, {
60
- visible: true,
61
- disabled: options.disabled ?? false,
62
- loading: false,
63
- class: options.class ?? '',
64
- style: options.style ?? '',
65
- attributes: {},
66
- label: options.label ?? formatIdAsLabel(id),
67
- required: options.required ?? false,
68
- name: options.name ?? id,
69
- errorMessage: undefined,
70
- files: [],
71
- accept: options.accept ?? '',
72
- multiple: options.multiple ?? false,
73
- icon: options.icon ?? 'upload',
74
- variant: options.variant ?? 'outline',
75
- showFileList: options.showFileList ?? true,
76
- maxFiles: options.maxFiles ?? 10,
77
- maxFileSize: options.maxFileSize ?? 10,
78
- });
79
-
80
- if (options.onValidate) {
81
- this._onValidate = options.onValidate;
82
- }
83
-
84
- this._storage = options.storage ?? null;
85
- this._metadata = options.metadata;
86
- }
87
-
88
- protected getTriggerEvents(): readonly string[] {
89
- return TRIGGER_EVENTS;
90
- }
91
-
92
- protected getCallbackEvents(): readonly string[] {
93
- return CALLBACK_EVENTS;
94
- }
95
-
96
- /* ═════════════════════════════════════════════════════════════════
97
- * FLUENT API
98
- * ═════════════════════════════════════════════════════════════════ */
99
-
100
- accept(value: string): this {
101
- this.state.accept = value;
102
- return this;
103
- }
104
-
105
- multiple(value: boolean): this {
106
- this.state.multiple = value;
107
- return this;
108
- }
109
-
110
- icon(value: string): this {
111
- this.state.icon = value;
112
- return this;
113
- }
114
-
115
- variant(value: 'outline' | 'primary' | 'ghost' | 'secondary'): this {
116
- this.state.variant = value;
117
- return this;
118
- }
119
-
120
- storage(store: FileStorage, metadata?: Record<string, any>): this {
121
- this._storage = store;
122
- this._metadata = metadata;
123
- return this;
124
- }
125
-
126
- /**
127
- * Enable IndexedDB caching of uploaded files.
128
- * After upload, the file is parsed and stored as a DataFrame.
129
- * The storage key is available via .storageKey and a 'stored' event fires.
130
- *
131
- * Usage:
132
- * jux.fileUpload('my-upload', { accept: '.csv' })
133
- * .cache() // enable with defaults
134
- * .cache({ prefix: 'raw/' }) // key prefix
135
- * .cache({ dbName: 'my-db' }) // custom DB
136
- *
137
- * upload.bind('stored', (key, df) => {
138
- * await data().fromStorage(key).into(myTable);
139
- * });
140
- */
141
- cache(options: {
142
- enabled?: boolean;
143
- dbName?: string;
144
- storeName?: string;
145
- prefix?: string;
146
- } = {}): this {
147
- this._cacheEnabled = options.enabled ?? true;
148
- if (options.dbName) this._cacheDbName = options.dbName;
149
- if (options.storeName) this._cacheStoreName = options.storeName;
150
- if (options.prefix) this._cacheKeyPrefix = options.prefix;
151
-
152
- if (this._cacheEnabled && !this._cacheDriver) {
153
- this._cacheDriver = new TabularDriver(this._cacheDbName, this._cacheStoreName);
154
- }
155
-
156
- return this;
157
- }
158
-
159
- /* ═════════════════════════════════════════════════════════════════
160
- * STORAGE KEY ACCESSORS
161
- * ═════════════════════════════════════════════════════════════════ */
162
-
163
- /** The IndexedDB key for the most recently cached upload, or null. */
164
- get storageKey(): string | null {
165
- return this._lastStorageKey;
166
- }
167
-
168
- /** Map of filename → storage key for all cached files this session. */
169
- get storageKeys(): ReadonlyMap<string, string> {
170
- return this._storageKeys;
171
- }
172
-
173
- /** Get the storage key for a specific filename. */
174
- storageKeyFor(filename: string): string | null {
175
- return this._storageKeys.get(filename) ?? null;
176
- }
177
-
178
- /** The cached DataFrame for the most recent upload (after 'stored' fires). */
179
- get cachedDf(): DataFrame | null {
180
- if (!this._lastStorageKey) return null;
181
- return this._cachedDataFrames.get(this._lastStorageKey) ?? null;
182
- }
183
-
184
- clear(): this {
185
- this.state.files = [];
186
- if (this._inputElement) {
187
- (this._inputElement as HTMLInputElement).value = '';
188
- }
189
- if (this._fileListElement) {
190
- this._fileListElement.innerHTML = '';
191
- }
192
- this._lastStorageKey = null;
193
- this._triggerCallback('clear', null, null, this);
194
- return this;
195
- }
196
-
197
- clearFiles(): this {
198
- this.state.files = [];
199
- this._updateFileList();
200
- this._triggerCallback('change', [], null, this);
201
- return this;
202
- }
203
-
204
- /* ═════════════════════════════════════════════════════════════════
205
- * FORM INPUT IMPLEMENTATION
206
- * ═════════════════════════════════════════════════════════════════ */
207
-
208
- getValue(): File[] {
209
- return this.state.files;
210
- }
211
-
212
- setValue(files: File[]): this {
213
- this.state.files = files;
214
- this._updateFileList();
215
- return this;
216
- }
217
-
218
- validate(): boolean {
219
- this._hasBeenValidated = true;
220
- const files = this.getValue();
221
- const result = this._validateValue(files);
222
-
223
- if (result === true) {
224
- this._clearError();
225
- return true;
226
- } else {
227
- this._showError(result as string);
228
- return false;
229
- }
230
- }
231
-
232
- isValid(): boolean {
233
- const files = this.getValue();
234
- return this._validateValue(files) === true;
235
- }
236
-
237
- protected _validateValue(files: File[]): boolean | string {
238
- const { required } = this.state;
239
-
240
- if (required && files.length === 0) {
241
- return 'Please select at least one file';
242
- }
243
-
244
- if (this._onValidate) {
245
- const result = this._onValidate(files);
246
- if (result !== true) {
247
- return result || 'Invalid files';
248
- }
249
- }
250
-
251
- return true;
252
- }
253
-
254
- private _updateFileList(): void {
255
- if (!this._fileListElement) return;
256
-
257
- this._fileListElement.innerHTML = '';
258
-
259
- if (this.state.files.length === 0) {
260
- return;
261
- }
262
-
263
- this.state.files.forEach((file, index) => {
264
- const fileItem = document.createElement('div');
265
- fileItem.className = 'jux-fileupload-item';
266
- fileItem.innerHTML = `
267
- <span class="jux-fileupload-filename">${file.name}</span>
268
- <span class="jux-fileupload-filesize">${this._formatFileSize(file.size)}</span>
269
- <button class="jux-fileupload-remove" data-index="${index}">×</button>
270
- `;
271
-
272
- const removeBtn = fileItem.querySelector('.jux-fileupload-remove');
273
- removeBtn?.addEventListener('click', () => {
274
- this.state.files = this.state.files.filter((_, i) => i !== index);
275
- this._updateFileList();
276
- this._triggerCallback('change', this.state.files, null, this);
277
- });
278
-
279
- this._fileListElement!.appendChild(fileItem);
280
- });
281
- }
282
-
283
- private _formatFileSize(bytes: number): string {
284
- if (bytes === 0) return '0 Bytes';
285
- const k = 1024;
286
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
287
- const i = Math.floor(Math.log(bytes) / Math.log(k));
288
- return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i];
289
- }
290
-
291
- /* ═════════════════════════════════════════════════════════════════
292
- * INTERNAL — CACHE FILE TO INDEXEDDB
293
- * ═════════════════════════════════════════════════════════════════ */
294
-
295
- private async _cacheFile(file: File): Promise<void> {
296
- if (!this._cacheEnabled || !this._cacheDriver) return;
297
-
298
- try {
299
- const key = this._cacheKeyPrefix + file.name;
300
- let df: DataFrame;
301
-
302
- const isExcel = /\.(xlsx?|xls)$/i.test(file.name);
303
- if (isExcel) {
304
- const sheets = await this._cacheDriver.streamFileMultiSheet(file, {});
305
- const sheetNames = Object.keys(sheets);
306
- if (sheetNames.length === 0) return;
307
- df = sheets[sheetNames[0]];
308
- } else {
309
- const text = await file.text();
310
- df = this._cacheDriver.parseCSV(text, {
311
- autoDetectDelimiter: true,
312
- hasHeader: true
313
- });
314
- }
315
-
316
- await this._cacheDriver.store(key, df, {
317
- source: file.name,
318
- size: file.size,
319
- type: file.type,
320
- cachedAt: new Date().toISOString(),
321
- ...this._metadata
322
- });
323
-
324
- this._lastStorageKey = key;
325
- this._storageKeys.set(file.name, key);
326
- this._cachedDataFrames.set(key, df);
327
-
328
- this._triggerCallback('stored', key, null, this);
329
- } catch (err: any) {
330
- console.warn(`[FileUpload] Failed to cache ${file.name}:`, err.message);
331
- }
332
- }
333
-
334
- /* ═════════════════════════════════════════════════════════════════
335
- * RENDER
336
- * ═════════════════════════════════════════════════════════════════ */
337
-
338
- update(prop: string, value: any): void {
339
- // No reactive updates needed
340
- }
341
-
342
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
343
- const container = this._setupContainer(targetId);
344
-
345
- const { label, accept, multiple, icon, variant, showFileList, style, class: className } = this.state;
346
-
347
- const wrapper = document.createElement('div');
348
- wrapper.className = 'jux-fileupload';
349
- wrapper.id = this._id;
350
- if (className) wrapper.className += ` ${className}`;
351
- if (style) wrapper.setAttribute('style', style);
352
-
353
- const fileInput = document.createElement('input');
354
- fileInput.type = 'file';
355
- fileInput.accept = accept;
356
- fileInput.multiple = multiple;
357
- fileInput.style.display = 'none';
358
- fileInput.id = `${this._id}-input`;
359
- this._inputElement = fileInput;
360
-
361
- const btn = document.createElement('button');
362
- btn.className = `jux-fileupload-button jux-button-${variant}`;
363
- btn.type = 'button';
364
-
365
- if (icon) {
366
- const iconEl = document.createElement('span');
367
- iconEl.className = 'jux-fileupload-icon';
368
- iconEl.appendChild(renderIcon(icon));
369
- btn.appendChild(iconEl);
370
- }
371
-
372
- const labelSpan = document.createElement('span');
373
- labelSpan.textContent = label;
374
- btn.appendChild(labelSpan);
375
-
376
- const buttonContainer = document.createElement('div');
377
- buttonContainer.className = 'jux-fileupload-button-container';
378
- buttonContainer.appendChild(fileInput);
379
- buttonContainer.appendChild(btn);
380
- wrapper.appendChild(buttonContainer);
381
-
382
- if (showFileList) {
383
- const fileList = document.createElement('div');
384
- fileList.className = 'jux-fileupload-filelist';
385
- this._fileListElement = fileList;
386
- wrapper.appendChild(fileList);
387
- }
388
-
389
- wrapper.appendChild(this._renderError());
390
-
391
- btn.addEventListener('click', () => fileInput.click());
392
-
393
- // Wire up file input change — with caching
394
- fileInput.addEventListener('change', async (e) => {
395
- const files = Array.from(fileInput.files || []);
396
- this.state.files = files;
397
- this._updateFileList();
398
- this._clearError();
399
-
400
- this._triggerCallback('change', files, e, this);
401
- this._triggerCallback('filesSelected', files, e, this);
402
-
403
- if (this._storage && files.length > 0) {
404
- this._storage.storeAll(files, this._metadata).then((stored) => {
405
- this._triggerCallback('stored', stored, e, this);
406
- }).catch((err) => {
407
- console.error('[FileUpload] Storage error:', err);
408
- });
409
- }
410
-
411
- // Cache to IndexedDB as parsed DataFrames
412
- if (this._cacheEnabled && files.length > 0) {
413
- for (const file of files) {
414
- await this._cacheFile(file);
415
- }
416
- }
417
- });
418
-
419
- this._wireStandardEvents(wrapper);
420
-
421
- fileInput.addEventListener('blur', () => {
422
- if (this._hasBeenValidated) {
423
- this.validate();
424
- }
425
- });
426
-
427
- const labelSync = this._syncBindings.find(b => b.property === 'label');
428
- if (labelSync) {
429
- const transform = labelSync.toComponent || ((v: any) => String(v));
430
- labelSync.stateObj.subscribe((val: any) => {
431
- this.label(transform(val));
432
- });
433
- }
434
-
435
- container.appendChild(wrapper);
436
-
437
- requestAnimationFrame(() => {
438
- if ((window as any).lucide) {
439
- (window as any).lucide.createIcons();
440
- }
441
- });
442
-
443
- return this;
444
- }
445
- }
446
-
447
- export function fileupload(id: string, options: FileUploadOptions = {}): FileUpload {
448
- return new FileUpload(id, options);
449
- }
@@ -1,88 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- export interface GridRowConfig {
3
- height?: string;
4
- style?: string;
5
- class?: string;
6
- }
7
- export interface GridColumnConfig {
8
- width?: string;
9
- style?: string;
10
- class?: string;
11
- }
12
- export interface GridItemConfig {
13
- target: string;
14
- text?: string;
15
- html?: string;
16
- component?: any;
17
- }
18
- export interface GridCreateConfig {
19
- columns?: GridColumnConfig[] | number;
20
- rows?: GridRowConfig[] | number;
21
- items?: GridItemConfig[];
22
- }
23
- export interface GridOptions {
24
- columns?: GridColumnConfig[] | number;
25
- rows?: GridRowConfig[] | number;
26
- width?: string;
27
- height?: string;
28
- gap?: string;
29
- style?: string;
30
- class?: string;
31
- }
32
- type GridState = {
33
- rows: GridRowConfig[];
34
- columns: GridColumnConfig[];
35
- boundary: {
36
- width: string;
37
- height: string;
38
- };
39
- gap: string;
40
- cells: Map<string, HTMLElement>;
41
- style: string;
42
- class: string;
43
- gridder: boolean;
44
- };
45
- export declare class Grid extends BaseComponent<GridState> {
46
- constructor(id: string, options?: GridOptions);
47
- protected getTriggerEvents(): readonly string[];
48
- protected getCallbackEvents(): readonly string[];
49
- width(value: string): this;
50
- height(value: string): this;
51
- gap(value: string): this;
52
- /**
53
- * Define rows (SETTER)
54
- * @param config - Number (creates N equal rows) or Array of row configs
55
- */
56
- rows(config: GridRowConfig[] | number): this;
57
- /**
58
- * Define columns (SETTER)
59
- * @param config - Number (creates N equal columns) or Array of column configs
60
- */
61
- columns(config: GridColumnConfig[] | number): this;
62
- /**
63
- * Get the cell ID for a specific coordinate
64
- */
65
- getCellId(row: number, col: number): string;
66
- /**
67
- * Get the DOM element for a specific cell
68
- */
69
- getCell(row: number, col: number): HTMLElement | undefined;
70
- /**
71
- * ✅ Enable blueprint/wireframe visualization
72
- * Shows grid structure, cell coordinates, and geometric borders
73
- */
74
- gridder(value?: boolean): this;
75
- /**
76
- * Pattern B: The Static Orchestration
77
- * Creates the grid and populates it with items in one operation
78
- */
79
- create(config: GridCreateConfig): this;
80
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
81
- update(prop: string, value: any): void;
82
- }
83
- /**
84
- * Factory function
85
- */
86
- export declare function grid(id: string, options?: GridOptions): Grid;
87
- export {};
88
- //# sourceMappingURL=grid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["grid.ts"],"names":[],"mappings":"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"}