juxscript 1.0.131 → 1.1.0

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 (129) hide show
  1. package/README.md +1 -32
  2. package/bin/cli.js +4 -2
  3. package/index.d.ts +200 -0
  4. package/index.js +96 -22
  5. package/juxconfig.example.js +58 -63
  6. package/lib/components/alert.ts +200 -0
  7. package/lib/components/app.ts +247 -0
  8. package/lib/components/badge.ts +101 -0
  9. package/lib/components/base/BaseComponent.ts +421 -0
  10. package/lib/components/base/FormInput.ts +227 -0
  11. package/lib/components/button.ts +178 -0
  12. package/lib/components/card.ts +173 -0
  13. package/lib/components/chart.ts +231 -0
  14. package/lib/components/checkbox.ts +242 -0
  15. package/lib/components/code.ts +123 -0
  16. package/lib/components/container.ts +140 -0
  17. package/lib/components/data.ts +135 -0
  18. package/lib/components/datepicker.ts +234 -0
  19. package/lib/components/dialog.ts +172 -0
  20. package/lib/components/divider.ts +100 -0
  21. package/lib/components/dropdown.ts +186 -0
  22. package/lib/components/element.ts +267 -0
  23. package/lib/components/fileupload.ts +309 -0
  24. package/lib/components/grid.ts +291 -0
  25. package/lib/components/guard.ts +92 -0
  26. package/lib/components/heading.ts +96 -0
  27. package/lib/components/helpers.ts +41 -0
  28. package/lib/components/hero.ts +224 -0
  29. package/lib/components/icon.ts +178 -0
  30. package/lib/components/icons.ts +464 -0
  31. package/lib/components/include.ts +410 -0
  32. package/lib/components/input.ts +457 -0
  33. package/lib/components/list.ts +419 -0
  34. package/lib/components/loading.ts +100 -0
  35. package/lib/components/menu.ts +275 -0
  36. package/lib/components/modal.ts +284 -0
  37. package/lib/components/nav.ts +257 -0
  38. package/lib/components/paragraph.ts +97 -0
  39. package/lib/components/progress.ts +159 -0
  40. package/lib/components/radio.ts +278 -0
  41. package/lib/components/req.ts +303 -0
  42. package/lib/components/script.ts +41 -0
  43. package/lib/components/select.ts +252 -0
  44. package/lib/components/sidebar.ts +275 -0
  45. package/lib/components/style.ts +41 -0
  46. package/lib/components/switch.ts +246 -0
  47. package/lib/components/table.ts +1249 -0
  48. package/lib/components/tabs.ts +250 -0
  49. package/lib/components/theme-toggle.ts +293 -0
  50. package/lib/components/tooltip.ts +144 -0
  51. package/lib/components/view.ts +190 -0
  52. package/lib/components/write.ts +272 -0
  53. package/lib/globals.d.ts +19 -5
  54. package/lib/layouts/default.css +260 -0
  55. package/lib/layouts/figma.css +334 -0
  56. package/lib/reactivity/state.ts +78 -0
  57. package/lib/utils/{fetch.js → fetch.ts} +206 -81
  58. package/package.json +9 -31
  59. package/create/index.jux +0 -77
  60. package/create/layout.jux +0 -18
  61. package/create/style.css +0 -57
  62. package/create/themes/assets/jux.svg +0 -34
  63. package/create/themes/base.css +0 -197
  64. package/create/themes/base2.css +0 -54
  65. package/create/themes/layouts/base.jux +0 -16
  66. package/create/themes/layouts/base_blog.jux +0 -0
  67. package/create/themes/layouts/base_docs.jux +0 -0
  68. package/create/themes/layouts/base_login.jux +0 -0
  69. package/create/themes/layouts/base_marketing.jux +0 -0
  70. package/create/themes/layouts/base_saas.jux +0 -0
  71. package/lib/componentsv2/base/BaseEngine.d.ts +0 -112
  72. package/lib/componentsv2/base/BaseEngine.js +0 -279
  73. package/lib/componentsv2/base/BaseSkin.d.ts +0 -74
  74. package/lib/componentsv2/base/BaseSkin.js +0 -130
  75. package/lib/componentsv2/base/Neighborhood.d.ts +0 -22
  76. package/lib/componentsv2/base/Neighborhood.js +0 -56
  77. package/lib/componentsv2/base/OptionsContract.d.ts +0 -20
  78. package/lib/componentsv2/base/OptionsContract.js +0 -107
  79. package/lib/componentsv2/base/State.d.ts +0 -18
  80. package/lib/componentsv2/base/State.js +0 -68
  81. package/lib/componentsv2/element/Element.d.ts +0 -29
  82. package/lib/componentsv2/element/Element.js +0 -49
  83. package/lib/componentsv2/element/ElementEngine.d.ts +0 -58
  84. package/lib/componentsv2/element/ElementEngine.js +0 -112
  85. package/lib/componentsv2/element/ElementSkin.d.ts +0 -10
  86. package/lib/componentsv2/element/ElementSkin.js +0 -56
  87. package/lib/componentsv2/element/structure.css +0 -261
  88. package/lib/componentsv2/grid/Grid.d.ts +0 -13
  89. package/lib/componentsv2/grid/Grid.js +0 -27
  90. package/lib/componentsv2/grid/GridEngine.d.ts +0 -77
  91. package/lib/componentsv2/grid/GridEngine.js +0 -153
  92. package/lib/componentsv2/grid/GridSkin.d.ts +0 -11
  93. package/lib/componentsv2/grid/GridSkin.js +0 -84
  94. package/lib/componentsv2/grid/structure.css +0 -27
  95. package/lib/componentsv2/input/Input.d.ts +0 -6
  96. package/lib/componentsv2/input/Input.js +0 -21
  97. package/lib/componentsv2/input/InputEngine.d.ts +0 -70
  98. package/lib/componentsv2/input/InputEngine.js +0 -143
  99. package/lib/componentsv2/input/InputSkin.d.ts +0 -11
  100. package/lib/componentsv2/input/InputSkin.js +0 -89
  101. package/lib/componentsv2/input/structure.css +0 -47
  102. package/lib/componentsv2/list/List.d.ts +0 -49
  103. package/lib/componentsv2/list/List.js +0 -105
  104. package/lib/componentsv2/list/ListEngine.d.ts +0 -121
  105. package/lib/componentsv2/list/ListEngine.js +0 -322
  106. package/lib/componentsv2/list/ListSkin.d.ts +0 -20
  107. package/lib/componentsv2/list/ListSkin.js +0 -345
  108. package/lib/componentsv2/list/structure.css +0 -359
  109. package/lib/componentsv2/plugins/ClientSQLitePlugin.d.ts +0 -21
  110. package/lib/componentsv2/plugins/ClientSQLitePlugin.js +0 -130
  111. package/lib/componentsv2/plugins/IndexedDBPlugin.d.ts +0 -18
  112. package/lib/componentsv2/plugins/IndexedDBPlugin.js +0 -75
  113. package/lib/componentsv2/plugins/LocalStoragePlugin.d.ts +0 -20
  114. package/lib/componentsv2/plugins/LocalStoragePlugin.js +0 -65
  115. package/lib/componentsv2/plugins/ServerSQLitePlugin.d.ts +0 -25
  116. package/lib/componentsv2/plugins/ServerSQLitePlugin.js +0 -70
  117. package/lib/componentsv2/stubs/ComponentComposition.ts.stub +0 -32
  118. package/lib/componentsv2/stubs/ComponentEngine.ts.stub +0 -36
  119. package/lib/componentsv2/stubs/ComponentSkin.ts.stub +0 -35
  120. package/lib/componentsv2/stubs/ComponentStructure.css.d.ts.stub +0 -2
  121. package/lib/componentsv2/stubs/ComponentStructure.css.stub +0 -13
  122. package/lib/utils/fetch.d.ts +0 -176
  123. package/machinery/build3.js +0 -159
  124. package/machinery/compiler3.js +0 -688
  125. package/machinery/config.js +0 -155
  126. package/machinery/serve.js +0 -255
  127. package/machinery/validators/file-validator.js +0 -123
  128. package/machinery/watcher.js +0 -59
  129. package/types/css.d.ts +0 -10
@@ -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,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
+ }