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,419 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ import { renderIcon } from './icons.js';
3
+
4
+ // Event definitions
5
+ const TRIGGER_EVENTS = [] as const;
6
+ const CALLBACK_EVENTS = ['itemClick', 'itemDoubleClick', 'selectionChange'] as const;
7
+
8
+ export interface ListItem {
9
+ id?: string;
10
+ icon?: string;
11
+ title?: string;
12
+ body?: string;
13
+ type?: 'success' | 'warning' | 'error' | 'info' | 'default' | string;
14
+ metadata?: string;
15
+ itemClass?: string;
16
+ disabled?: boolean;
17
+ selected?: boolean;
18
+ data?: any; // Arbitrary data attached to item
19
+ }
20
+
21
+ export interface ListOptions {
22
+ items?: (ListItem | string)[]; // ✅ Allow string or ListItem
23
+ header?: string;
24
+ gap?: string;
25
+ direction?: 'vertical' | 'horizontal';
26
+ selectable?: boolean;
27
+ multiSelect?: boolean;
28
+ selectedIndex?: number | null;
29
+ selectedIndices?: number[];
30
+ onItemClick?: (item: ListItem, index: number, e: Event) => void;
31
+ onItemDoubleClick?: (item: ListItem, index: number, e: Event) => void;
32
+ onSelectionChange?: (selectedItems: ListItem[], selectedIndices: number[]) => void;
33
+ ordered?: boolean;
34
+ striped?: boolean;
35
+ hoverable?: boolean;
36
+ bordered?: boolean;
37
+ style?: string;
38
+ class?: string;
39
+ }
40
+
41
+ type ListState = {
42
+ items: ListItem[];
43
+ header: string;
44
+ gap: string;
45
+ direction: string;
46
+ selectable: boolean;
47
+ multiSelect: boolean;
48
+ selectedIndex: number | null;
49
+ selectedIndices: number[];
50
+ ordered: boolean;
51
+ striped: boolean;
52
+ hoverable: boolean;
53
+ bordered: boolean;
54
+ style: string;
55
+ class: string;
56
+ };
57
+
58
+ export class List extends BaseComponent<ListState> {
59
+ private _onItemClick: ((item: ListItem, index: number, e: Event) => void) | null = null;
60
+ private _onItemDoubleClick: ((item: ListItem, index: number, e: Event) => void) | null = null;
61
+ private _onSelectionChange: ((selectedItems: ListItem[], selectedIndices: number[]) => void) | null = null;
62
+ private _listElement: HTMLElement | null = null;
63
+
64
+ constructor(id: string, options: ListOptions = {}) {
65
+ // ✅ Normalize items - convert strings to ListItem objects
66
+ const normalizedItems = (options.items ?? []).map(item =>
67
+ typeof item === 'string' ? { title: item } : item
68
+ );
69
+
70
+ super(id, {
71
+ items: normalizedItems,
72
+ header: options.header ?? '',
73
+ gap: options.gap ?? '0.5rem',
74
+ direction: options.direction ?? 'vertical',
75
+ selectable: options.selectable ?? false,
76
+ multiSelect: options.multiSelect ?? false,
77
+ selectedIndex: options.selectedIndex ?? null,
78
+ selectedIndices: options.selectedIndices ?? [],
79
+ ordered: options.ordered ?? false,
80
+ striped: options.striped ?? false,
81
+ hoverable: options.hoverable ?? true,
82
+ bordered: options.bordered ?? false,
83
+ style: options.style ?? '',
84
+ class: options.class ?? ''
85
+ });
86
+
87
+ this._onItemClick = options.onItemClick ?? null;
88
+ this._onItemDoubleClick = options.onItemDoubleClick ?? null;
89
+ this._onSelectionChange = options.onSelectionChange ?? null;
90
+ }
91
+
92
+ protected getTriggerEvents(): readonly string[] {
93
+ return TRIGGER_EVENTS;
94
+ }
95
+
96
+ protected getCallbackEvents(): readonly string[] {
97
+ return CALLBACK_EVENTS;
98
+ }
99
+
100
+ /* ═════════════════════════════════════════════════════════════════
101
+ * FLUENT API
102
+ * ═════════════════════════════════════════════════════════════════ */
103
+
104
+ // ✅ Inherited from BaseComponent
105
+
106
+ items(value: (ListItem | string)[]): this {
107
+ // ✅ Normalize items when setting via fluent API
108
+ this.state.items = value.map(item =>
109
+ typeof item === 'string' ? { title: item } : item
110
+ );
111
+ this._updateList();
112
+ return this;
113
+ }
114
+
115
+ addItem(value: ListItem | string): this {
116
+ // ✅ Normalize single item
117
+ const normalizedItem = typeof value === 'string' ? { title: value } : value;
118
+ this.state.items = [...this.state.items, normalizedItem];
119
+ this._updateList();
120
+ return this;
121
+ }
122
+
123
+ removeItem(index: number): this {
124
+ this.state.items = this.state.items.filter((_, i) => i !== index);
125
+ this._updateList();
126
+ return this;
127
+ }
128
+
129
+ updateItem(index: number, updates: Partial<ListItem>): this {
130
+ this.state.items = this.state.items.map((item, i) =>
131
+ i === index ? { ...item, ...updates } : item
132
+ );
133
+ this._updateList();
134
+ return this;
135
+ }
136
+
137
+ clearItems(): this {
138
+ this.state.items = [];
139
+ this._updateList();
140
+ return this;
141
+ }
142
+
143
+ itemClass(className: string): this {
144
+ this.state.items = this.state.items.map(item => ({
145
+ ...item,
146
+ itemClass: className
147
+ }));
148
+ this._updateList();
149
+ return this;
150
+ }
151
+
152
+ ordered(value: boolean): this {
153
+ this.state.ordered = value;
154
+ return this;
155
+ }
156
+
157
+ selectable(value: boolean): this {
158
+ this.state.selectable = value;
159
+ return this;
160
+ }
161
+
162
+ multiSelect(value: boolean): this {
163
+ this.state.multiSelect = value;
164
+ return this;
165
+ }
166
+
167
+ striped(value: boolean): this {
168
+ this.state.striped = value;
169
+ return this;
170
+ }
171
+
172
+ hoverable(value: boolean): this {
173
+ this.state.hoverable = value;
174
+ return this;
175
+ }
176
+
177
+ bordered(value: boolean): this {
178
+ this.state.bordered = value;
179
+ return this;
180
+ }
181
+
182
+ selectItem(index: number): this {
183
+ if (!this.state.selectable) return this;
184
+
185
+ if (this.state.multiSelect) {
186
+ if (!this.state.selectedIndices.includes(index)) {
187
+ this.state.selectedIndices = [...this.state.selectedIndices, index];
188
+ }
189
+ } else {
190
+ this.state.selectedIndex = index;
191
+ this.state.selectedIndices = [index];
192
+ }
193
+
194
+ this._updateSelection();
195
+ this._triggerSelectionChange();
196
+ return this;
197
+ }
198
+
199
+ deselectItem(index: number): this {
200
+ if (!this.state.selectable) return this;
201
+
202
+ if (this.state.multiSelect) {
203
+ this.state.selectedIndices = this.state.selectedIndices.filter(i => i !== index);
204
+ } else {
205
+ this.state.selectedIndex = null;
206
+ this.state.selectedIndices = [];
207
+ }
208
+
209
+ this._updateSelection();
210
+ this._triggerSelectionChange();
211
+ return this;
212
+ }
213
+
214
+ clearSelection(): this {
215
+ this.state.selectedIndex = null;
216
+ this.state.selectedIndices = [];
217
+ this._updateSelection();
218
+ this._triggerSelectionChange();
219
+ return this;
220
+ }
221
+
222
+ getSelectedItems(): ListItem[] {
223
+ return this.state.selectedIndices.map(i => this.state.items[i]).filter(Boolean);
224
+ }
225
+
226
+ getSelectedIndices(): number[] {
227
+ return this.state.selectedIndices;
228
+ }
229
+
230
+ /* ═════════════════════════════════════════════════════════════════
231
+ * PRIVATE HELPERS
232
+ * ═════════════════════════════════════════════════════════════════ */
233
+
234
+ private _updateList(): void {
235
+ if (!this._listElement) return;
236
+ this._listElement.innerHTML = '';
237
+ this._renderItems(this._listElement);
238
+ }
239
+
240
+ private _updateSelection(): void {
241
+ if (!this._listElement) return;
242
+ const items = this._listElement.querySelectorAll('.jux-list-item');
243
+ items.forEach((el, index) => {
244
+ const isSelected = this.state.selectedIndices.includes(index);
245
+ el.classList.toggle('jux-list-item-selected', isSelected);
246
+ });
247
+ }
248
+
249
+ private _triggerSelectionChange(): void {
250
+ const selectedItems = this.getSelectedItems();
251
+ const selectedIndices = this.getSelectedIndices();
252
+
253
+ if (this._onSelectionChange) {
254
+ this._onSelectionChange(selectedItems, selectedIndices);
255
+ }
256
+
257
+ // 🎯 Fire the selectionChange callback event
258
+ this._triggerCallback('selectionChange', { items: selectedItems, indices: selectedIndices });
259
+ }
260
+
261
+ private _renderItems(list: HTMLElement): void {
262
+ const { items, selectable, hoverable, striped, bordered } = this.state;
263
+
264
+ items.forEach((item, index) => {
265
+ const li = document.createElement('li');
266
+ li.className = 'jux-list-item';
267
+
268
+ if (item.itemClass) li.className += ` ${item.itemClass}`;
269
+ if (item.type && item.type !== 'default') li.classList.add(`jux-list-item-${item.type}`);
270
+ if (item.disabled) li.classList.add('jux-list-item-disabled');
271
+ if (this.state.selectedIndices.includes(index)) li.classList.add('jux-list-item-selected');
272
+ if (hoverable && !item.disabled) li.classList.add('jux-list-item-hoverable');
273
+ if (striped && index % 2 === 1) li.classList.add('jux-list-item-striped');
274
+ if (bordered) li.classList.add('jux-list-item-bordered');
275
+
276
+ // Content container
277
+ const content = document.createElement('div');
278
+ content.className = 'jux-list-item-content';
279
+
280
+ // Icon
281
+ if (item.icon) {
282
+ const iconEl = document.createElement('span');
283
+ iconEl.className = 'jux-list-item-icon';
284
+ iconEl.appendChild(renderIcon(item.icon));
285
+ content.appendChild(iconEl);
286
+ }
287
+
288
+ // Text content
289
+ const textContainer = document.createElement('div');
290
+ textContainer.className = 'jux-list-item-text';
291
+
292
+ if (item.title) {
293
+ const titleEl = document.createElement('div');
294
+ titleEl.className = 'jux-list-item-title';
295
+ titleEl.textContent = item.title;
296
+ textContainer.appendChild(titleEl);
297
+ }
298
+
299
+ if (item.body) {
300
+ const bodyEl = document.createElement('div');
301
+ bodyEl.className = 'jux-list-item-body';
302
+ bodyEl.textContent = item.body;
303
+ textContainer.appendChild(bodyEl);
304
+ }
305
+
306
+ content.appendChild(textContainer);
307
+
308
+ // Metadata
309
+ if (item.metadata) {
310
+ const metaEl = document.createElement('div');
311
+ metaEl.className = 'jux-list-item-metadata';
312
+ metaEl.textContent = item.metadata;
313
+ content.appendChild(metaEl);
314
+ }
315
+
316
+ li.appendChild(content);
317
+
318
+ // Click handlers
319
+ if (!item.disabled) {
320
+ li.addEventListener('click', (e) => {
321
+ if (selectable) {
322
+ if (this.state.selectedIndices.includes(index)) {
323
+ this.deselectItem(index);
324
+ } else {
325
+ if (!this.state.multiSelect) {
326
+ this.clearSelection();
327
+ }
328
+ this.selectItem(index);
329
+ }
330
+ }
331
+
332
+ if (this._onItemClick) {
333
+ this._onItemClick(item, index, e);
334
+ }
335
+
336
+ // 🎯 Fire the itemClick callback event
337
+ this._triggerCallback('itemClick', { item, index, event: e });
338
+ });
339
+
340
+ li.addEventListener('dblclick', (e) => {
341
+ if (this._onItemDoubleClick) {
342
+ this._onItemDoubleClick(item, index, e);
343
+ }
344
+
345
+ // 🎯 Fire the itemDoubleClick callback event
346
+ this._triggerCallback('itemDoubleClick', { item, index, event: e });
347
+ });
348
+ }
349
+
350
+ list.appendChild(li);
351
+ });
352
+ }
353
+
354
+ /* ═════════════════════════════════════════════════════════════════
355
+ * RENDER
356
+ * ═════════════════════════════════════════════════════════════════ */
357
+
358
+ render(targetId?: string): this {
359
+ const container = this._setupContainer(targetId);
360
+
361
+ const { header, ordered, style, class: className } = this.state;
362
+
363
+ const wrapper = document.createElement('div');
364
+ wrapper.className = 'jux-list-wrapper';
365
+ wrapper.id = `${this._id}-wrapper`;
366
+
367
+ // Header
368
+ if (header) {
369
+ const headerEl = document.createElement('div');
370
+ headerEl.className = 'jux-list-header';
371
+ headerEl.textContent = header;
372
+ wrapper.appendChild(headerEl);
373
+ }
374
+
375
+ // List
376
+ const list = document.createElement(ordered ? 'ol' : 'ul') as HTMLOListElement | HTMLUListElement;
377
+ list.className = `jux-list ${ordered ? 'jux-list-ordered' : 'jux-list-unordered'}`;
378
+ list.id = this._id;
379
+ if (className) list.className += ` ${className}`;
380
+ if (style) list.setAttribute('style', style);
381
+
382
+ this._listElement = list;
383
+ this._renderItems(list);
384
+
385
+ wrapper.appendChild(list);
386
+
387
+ this._wireStandardEvents(list);
388
+
389
+ // Wire sync bindings
390
+ this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
391
+ if (property === 'items') {
392
+ const transform = toComponent || ((v: any) => v);
393
+
394
+ stateObj.subscribe((val: any) => {
395
+ const transformed = transform(val);
396
+ this.state.items = transformed;
397
+ this._updateList();
398
+ });
399
+ }
400
+ else if (property === 'selectedIndices') {
401
+ const transform = toComponent || ((v: any) => v);
402
+
403
+ stateObj.subscribe((val: any) => {
404
+ const transformed = transform(val);
405
+ this.state.selectedIndices = transformed;
406
+ this._updateSelection();
407
+ });
408
+ }
409
+ });
410
+
411
+ container.appendChild(wrapper);
412
+
413
+ return this;
414
+ }
415
+ }
416
+
417
+ export function list(id: string, options: ListOptions = {}): List {
418
+ return new List(id, options);
419
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ export interface LoadingOptions {
3
+ variant?: 'spinner' | 'dots' | 'pulse';
4
+ size?: 'sm' | 'md' | 'lg';
5
+ style?: string;
6
+ class?: string;
7
+ }
8
+ type LoadingState = {
9
+ variant: string;
10
+ size: string;
11
+ style: string;
12
+ class: string;
13
+ };
14
+ export declare class Loading extends BaseComponent<LoadingState> {
15
+ constructor(id: string, options?: LoadingOptions);
16
+ protected getTriggerEvents(): readonly string[];
17
+ protected getCallbackEvents(): readonly string[];
18
+ variant(value: 'spinner' | 'dots' | 'pulse'): this;
19
+ size(value: 'sm' | 'md' | 'lg'): this;
20
+ render(targetId?: string): this;
21
+ }
22
+ export declare function loading(id: string, options?: LoadingOptions): Loading;
23
+ export {};
24
+ //# sourceMappingURL=loading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["loading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,YAAY,GAAG;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,OAAQ,SAAQ,aAAa,CAAC,YAAY,CAAC;gBACxC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IASpD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAahD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;IAKlD,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IASrC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAkClC;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,73 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ // Event definitions
3
+ const TRIGGER_EVENTS = [];
4
+ const CALLBACK_EVENTS = [];
5
+ export class Loading extends BaseComponent {
6
+ constructor(id, options = {}) {
7
+ super(id, {
8
+ variant: options.variant ?? 'spinner',
9
+ size: options.size ?? 'md',
10
+ style: options.style ?? '',
11
+ class: options.class ?? ''
12
+ });
13
+ }
14
+ getTriggerEvents() {
15
+ return TRIGGER_EVENTS;
16
+ }
17
+ getCallbackEvents() {
18
+ return CALLBACK_EVENTS;
19
+ }
20
+ /* ═════════════════════════════════════════════════════════════════
21
+ * FLUENT API
22
+ * ═════════════════════════════════════════════════════════════════ */
23
+ // ✅ Inherited from BaseComponent:
24
+ // - style(), class()
25
+ // - bind(), sync(), renderTo()
26
+ // - visible(), show(), hide()
27
+ variant(value) {
28
+ this.state.variant = value;
29
+ return this;
30
+ }
31
+ size(value) {
32
+ this.state.size = value;
33
+ return this;
34
+ }
35
+ /* ═════════════════════════════════════════════════════════════════
36
+ * RENDER
37
+ * ═════════════════════════════════════════════════════════════════ */
38
+ render(targetId) {
39
+ const container = this._setupContainer(targetId);
40
+ const { variant, size, style, class: className } = this.state;
41
+ const loading = document.createElement('div');
42
+ loading.className = `jux-loading jux-loading-${variant} jux-loading-${size}`;
43
+ loading.id = this._id;
44
+ if (className)
45
+ loading.className += ` ${className}`;
46
+ if (style)
47
+ loading.setAttribute('style', style);
48
+ // Build variant-specific content
49
+ if (variant === 'spinner') {
50
+ const spinner = document.createElement('div');
51
+ spinner.className = 'jux-loading-spinner';
52
+ loading.appendChild(spinner);
53
+ }
54
+ else if (variant === 'dots') {
55
+ for (let i = 0; i < 3; i++) {
56
+ const dot = document.createElement('div');
57
+ dot.className = 'jux-loading-dot';
58
+ loading.appendChild(dot);
59
+ }
60
+ }
61
+ else if (variant === 'pulse') {
62
+ const pulse = document.createElement('div');
63
+ pulse.className = 'jux-loading-pulse';
64
+ loading.appendChild(pulse);
65
+ }
66
+ this._wireStandardEvents(loading);
67
+ container.appendChild(loading);
68
+ return this;
69
+ }
70
+ }
71
+ export function loading(id, options = {}) {
72
+ return new Loading(id, options);
73
+ }
@@ -0,0 +1,100 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+
3
+ // Event definitions
4
+ const TRIGGER_EVENTS = [] as const;
5
+ const CALLBACK_EVENTS = [] as const;
6
+
7
+ export interface LoadingOptions {
8
+ variant?: 'spinner' | 'dots' | 'pulse';
9
+ size?: 'sm' | 'md' | 'lg';
10
+ style?: string;
11
+ class?: string;
12
+ }
13
+
14
+ type LoadingState = {
15
+ variant: string;
16
+ size: string;
17
+ style: string;
18
+ class: string;
19
+ };
20
+
21
+ export class Loading extends BaseComponent<LoadingState> {
22
+ constructor(id: string, options: LoadingOptions = {}) {
23
+ super(id, {
24
+ variant: options.variant ?? 'spinner',
25
+ size: options.size ?? 'md',
26
+ style: options.style ?? '',
27
+ class: options.class ?? ''
28
+ });
29
+ }
30
+
31
+ protected getTriggerEvents(): readonly string[] {
32
+ return TRIGGER_EVENTS;
33
+ }
34
+
35
+ protected getCallbackEvents(): readonly string[] {
36
+ return CALLBACK_EVENTS;
37
+ }
38
+
39
+ /* ═════════════════════════════════════════════════════════════════
40
+ * FLUENT API
41
+ * ═════════════════════════════════════════════════════════════════ */
42
+
43
+ // ✅ Inherited from BaseComponent:
44
+ // - style(), class()
45
+ // - bind(), sync(), renderTo()
46
+ // - visible(), show(), hide()
47
+
48
+ variant(value: 'spinner' | 'dots' | 'pulse'): this {
49
+ this.state.variant = value;
50
+ return this;
51
+ }
52
+
53
+ size(value: 'sm' | 'md' | 'lg'): this {
54
+ this.state.size = value;
55
+ return this;
56
+ }
57
+
58
+ /* ═════════════════════════════════════════════════════════════════
59
+ * RENDER
60
+ * ═════════════════════════════════════════════════════════════════ */
61
+
62
+ render(targetId?: string): this {
63
+ const container = this._setupContainer(targetId);
64
+
65
+ const { variant, size, style, class: className } = this.state;
66
+
67
+ const loading = document.createElement('div');
68
+ loading.className = `jux-loading jux-loading-${variant} jux-loading-${size}`;
69
+ loading.id = this._id;
70
+ if (className) loading.className += ` ${className}`;
71
+ if (style) loading.setAttribute('style', style);
72
+
73
+ // Build variant-specific content
74
+ if (variant === 'spinner') {
75
+ const spinner = document.createElement('div');
76
+ spinner.className = 'jux-loading-spinner';
77
+ loading.appendChild(spinner);
78
+ } else if (variant === 'dots') {
79
+ for (let i = 0; i < 3; i++) {
80
+ const dot = document.createElement('div');
81
+ dot.className = 'jux-loading-dot';
82
+ loading.appendChild(dot);
83
+ }
84
+ } else if (variant === 'pulse') {
85
+ const pulse = document.createElement('div');
86
+ pulse.className = 'jux-loading-pulse';
87
+ loading.appendChild(pulse);
88
+ }
89
+
90
+ this._wireStandardEvents(loading);
91
+
92
+ container.appendChild(loading);
93
+
94
+ return this;
95
+ }
96
+ }
97
+
98
+ export function loading(id: string, options: LoadingOptions = {}): Loading {
99
+ return new Loading(id, options);
100
+ }
@@ -0,0 +1,37 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ export interface MenuItem {
3
+ label: string;
4
+ href?: string;
5
+ click?: () => void;
6
+ icon?: string;
7
+ items?: MenuItem[];
8
+ active?: boolean;
9
+ itemClass?: string;
10
+ }
11
+ export interface MenuOptions {
12
+ items?: MenuItem[];
13
+ orientation?: 'vertical' | 'horizontal';
14
+ style?: string;
15
+ class?: string;
16
+ }
17
+ type MenuState = {
18
+ items: MenuItem[];
19
+ orientation: string;
20
+ style: string;
21
+ class: string;
22
+ };
23
+ export declare class Menu extends BaseComponent<MenuState> {
24
+ constructor(id: string, options?: MenuOptions);
25
+ protected getTriggerEvents(): readonly string[];
26
+ protected getCallbackEvents(): readonly string[];
27
+ private _setActiveStates;
28
+ items(value: MenuItem[]): this;
29
+ addItem(item: MenuItem): this;
30
+ itemClass(className: string): this;
31
+ orientation(value: 'vertical' | 'horizontal'): this;
32
+ private _renderMenuItem;
33
+ render(targetId?: string): this;
34
+ }
35
+ export declare function menu(id: string, options?: MenuOptions): Menu;
36
+ export {};
37
+ //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAQxD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;gBACpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAWjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAIhD,OAAO,CAAC,gBAAgB;IAiBxB,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAM9B,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAM7B,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAYlC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI;IASnD,OAAO,CAAC,eAAe;IAmGvB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAqEhC;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}