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.
- package/index.js +7 -137
- package/lib/components/dataframe.ts +0 -569
- package/lib/components/tag.ts +68 -0
- package/lib/styles/shadcn.css +20 -7
- package/lib/utils/idgen.ts +6 -0
- package/package.json +5 -6
- package/index.d.ts +0 -239
- package/index.d.ts.map +0 -1
- package/lib/components/alert.d.ts +0 -36
- package/lib/components/alert.d.ts.map +0 -1
- package/lib/components/alert.js +0 -172
- package/lib/components/alert.ts +0 -219
- package/lib/components/app.d.ts +0 -89
- package/lib/components/app.d.ts.map +0 -1
- package/lib/components/app.js +0 -175
- package/lib/components/app.ts +0 -247
- package/lib/components/badge.d.ts +0 -26
- package/lib/components/badge.d.ts.map +0 -1
- package/lib/components/badge.js +0 -91
- package/lib/components/badge.ts +0 -118
- package/lib/components/base/Animations.d.ts +0 -36
- package/lib/components/base/Animations.d.ts.map +0 -1
- package/lib/components/base/Animations.js +0 -70
- package/lib/components/base/Animations.ts +0 -112
- package/lib/components/base/BaseComponent.d.ts +0 -294
- package/lib/components/base/BaseComponent.d.ts.map +0 -1
- package/lib/components/base/BaseComponent.js +0 -735
- package/lib/components/base/BaseComponent.ts +0 -884
- package/lib/components/base/FormInput.d.ts +0 -77
- package/lib/components/base/FormInput.d.ts.map +0 -1
- package/lib/components/base/FormInput.js +0 -171
- package/lib/components/base/FormInput.ts +0 -237
- package/lib/components/blueprint.d.ts +0 -40
- package/lib/components/blueprint.d.ts.map +0 -1
- package/lib/components/blueprint.js +0 -327
- package/lib/components/button.d.ts +0 -70
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js +0 -177
- package/lib/components/button.ts +0 -237
- package/lib/components/card.d.ts +0 -35
- package/lib/components/card.d.ts.map +0 -1
- package/lib/components/card.js +0 -130
- package/lib/components/card.ts +0 -177
- package/lib/components/chart.d.ts +0 -49
- package/lib/components/chart.d.ts.map +0 -1
- package/lib/components/chart.js +0 -205
- package/lib/components/chart.ts +0 -254
- package/lib/components/checkbox.d.ts +0 -33
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js +0 -202
- package/lib/components/checkbox.ts +0 -260
- package/lib/components/code.d.ts +0 -52
- package/lib/components/code.d.ts.map +0 -1
- package/lib/components/code.js +0 -201
- package/lib/components/code.ts +0 -260
- package/lib/components/container.d.ts +0 -60
- package/lib/components/container.d.ts.map +0 -1
- package/lib/components/container.js +0 -195
- package/lib/components/container.ts +0 -259
- package/lib/components/data.d.ts +0 -36
- package/lib/components/data.d.ts.map +0 -1
- package/lib/components/data.js +0 -110
- package/lib/components/data.ts +0 -135
- package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
- package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
- package/lib/components/dataframe/DataFrameSource.js +0 -421
- package/lib/components/dataframe/DataFrameSource.ts +0 -532
- package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
- package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
- package/lib/components/dataframe/ImportSettingsModal.js +0 -442
- package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
- package/lib/components/dataframe.d.ts +0 -110
- package/lib/components/dataframe.d.ts.map +0 -1
- package/lib/components/dataframe.js +0 -470
- package/lib/components/datepicker.d.ts +0 -40
- package/lib/components/datepicker.d.ts.map +0 -1
- package/lib/components/datepicker.js +0 -193
- package/lib/components/datepicker.ts +0 -251
- package/lib/components/dialog.d.ts +0 -39
- package/lib/components/dialog.d.ts.map +0 -1
- package/lib/components/dialog.js +0 -131
- package/lib/components/dialog.ts +0 -178
- package/lib/components/divider.d.ts +0 -31
- package/lib/components/divider.d.ts.map +0 -1
- package/lib/components/divider.js +0 -72
- package/lib/components/divider.ts +0 -104
- package/lib/components/dropdown-menu.d.ts +0 -42
- package/lib/components/dropdown-menu.d.ts.map +0 -1
- package/lib/components/dropdown-menu.js +0 -177
- package/lib/components/dropdown-menu.ts +0 -214
- package/lib/components/dropdown.d.ts +0 -41
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -136
- package/lib/components/dropdown.ts +0 -188
- package/lib/components/element.d.ts +0 -51
- package/lib/components/element.d.ts.map +0 -1
- package/lib/components/element.js +0 -209
- package/lib/components/element.ts +0 -271
- package/lib/components/event-chain.d.ts +0 -9
- package/lib/components/event-chain.d.ts.map +0 -1
- package/lib/components/event-chain.js +0 -33
- package/lib/components/fileupload.d.ts +0 -98
- package/lib/components/fileupload.d.ts.map +0 -1
- package/lib/components/fileupload.js +0 -351
- package/lib/components/fileupload.ts +0 -449
- package/lib/components/grid.d.ts +0 -88
- package/lib/components/grid.d.ts.map +0 -1
- package/lib/components/grid.js +0 -208
- package/lib/components/grid.ts +0 -295
- package/lib/components/heading.d.ts +0 -25
- package/lib/components/heading.d.ts.map +0 -1
- package/lib/components/heading.js +0 -83
- package/lib/components/heading.ts +0 -113
- package/lib/components/helpers.d.ts +0 -9
- package/lib/components/helpers.d.ts.map +0 -1
- package/lib/components/helpers.js +0 -30
- package/lib/components/helpers.ts +0 -41
- package/lib/components/hero.d.ts +0 -60
- package/lib/components/hero.d.ts.map +0 -1
- package/lib/components/hero.js +0 -239
- package/lib/components/hero.ts +0 -302
- package/lib/components/history/StateHistory.d.ts +0 -91
- package/lib/components/history/StateHistory.d.ts.map +0 -1
- package/lib/components/history/StateHistory.js +0 -154
- package/lib/components/history/StateHistory.ts +0 -200
- package/lib/components/icon.d.ts +0 -36
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js +0 -135
- package/lib/components/icon.ts +0 -182
- package/lib/components/icons.d.ts +0 -25
- package/lib/components/icons.d.ts.map +0 -1
- package/lib/components/icons.js +0 -440
- package/lib/components/icons.ts +0 -464
- package/lib/components/image.d.ts +0 -42
- package/lib/components/image.d.ts.map +0 -1
- package/lib/components/image.js +0 -204
- package/lib/components/image.ts +0 -260
- package/lib/components/include.d.ts +0 -86
- package/lib/components/include.d.ts.map +0 -1
- package/lib/components/include.js +0 -238
- package/lib/components/include.ts +0 -281
- package/lib/components/input.d.ts +0 -85
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js +0 -362
- package/lib/components/input.ts +0 -473
- package/lib/components/layer.d.ts +0 -72
- package/lib/components/layer.d.ts.map +0 -1
- package/lib/components/layer.js +0 -219
- package/lib/components/layer.ts +0 -304
- package/lib/components/link.d.ts +0 -41
- package/lib/components/link.d.ts.map +0 -1
- package/lib/components/link.js +0 -216
- package/lib/components/link.ts +0 -268
- package/lib/components/list.d.ts +0 -83
- package/lib/components/list.d.ts.map +0 -1
- package/lib/components/list.js +0 -314
- package/lib/components/list.ts +0 -423
- package/lib/components/loading.d.ts +0 -25
- package/lib/components/loading.d.ts.map +0 -1
- package/lib/components/loading.js +0 -76
- package/lib/components/loading.ts +0 -104
- package/lib/components/menu.d.ts +0 -38
- package/lib/components/menu.d.ts.map +0 -1
- package/lib/components/menu.js +0 -205
- package/lib/components/menu.ts +0 -279
- package/lib/components/modal.d.ts +0 -97
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js +0 -463
- package/lib/components/modal.ts +0 -576
- package/lib/components/nav.d.ts +0 -46
- package/lib/components/nav.d.ts.map +0 -1
- package/lib/components/nav.js +0 -193
- package/lib/components/nav.ts +0 -261
- package/lib/components/paragraph.d.ts +0 -30
- package/lib/components/paragraph.d.ts.map +0 -1
- package/lib/components/paragraph.js +0 -93
- package/lib/components/paragraph.ts +0 -123
- package/lib/components/pen.d.ts +0 -125
- package/lib/components/pen.d.ts.map +0 -1
- package/lib/components/pen.js +0 -443
- package/lib/components/pen.ts +0 -567
- package/lib/components/progress.d.ts +0 -40
- package/lib/components/progress.d.ts.map +0 -1
- package/lib/components/progress.js +0 -116
- package/lib/components/progress.ts +0 -163
- package/lib/components/radio.d.ts +0 -43
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js +0 -226
- package/lib/components/radio.ts +0 -303
- package/lib/components/registry.d.ts +0 -34
- package/lib/components/registry.d.ts.map +0 -1
- package/lib/components/registry.js +0 -163
- package/lib/components/registry.ts +0 -193
- package/lib/components/req.d.ts +0 -155
- package/lib/components/req.d.ts.map +0 -1
- package/lib/components/req.js +0 -253
- package/lib/components/req.ts +0 -303
- package/lib/components/script.d.ts +0 -14
- package/lib/components/script.d.ts.map +0 -1
- package/lib/components/script.js +0 -33
- package/lib/components/script.ts +0 -41
- package/lib/components/select.d.ts +0 -42
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js +0 -209
- package/lib/components/select.ts +0 -281
- package/lib/components/sidebar.d.ts +0 -59
- package/lib/components/sidebar.d.ts.map +0 -1
- package/lib/components/sidebar.js +0 -298
- package/lib/components/sidebar.ts +0 -395
- package/lib/components/stack/BaseStack.d.ts +0 -65
- package/lib/components/stack/BaseStack.d.ts.map +0 -1
- package/lib/components/stack/BaseStack.js +0 -274
- package/lib/components/stack/BaseStack.ts +0 -328
- package/lib/components/stack/HStack.d.ts +0 -18
- package/lib/components/stack/HStack.d.ts.map +0 -1
- package/lib/components/stack/HStack.js +0 -22
- package/lib/components/stack/HStack.ts +0 -25
- package/lib/components/stack/VStack.d.ts +0 -19
- package/lib/components/stack/VStack.d.ts.map +0 -1
- package/lib/components/stack/VStack.js +0 -23
- package/lib/components/stack/VStack.ts +0 -26
- package/lib/components/stack/ZStack.d.ts +0 -18
- package/lib/components/stack/ZStack.d.ts.map +0 -1
- package/lib/components/stack/ZStack.js +0 -22
- package/lib/components/stack/ZStack.ts +0 -25
- package/lib/components/style.d.ts +0 -14
- package/lib/components/style.d.ts.map +0 -1
- package/lib/components/style.js +0 -33
- package/lib/components/style.ts +0 -41
- package/lib/components/switch.d.ts +0 -34
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js +0 -209
- package/lib/components/switch.ts +0 -272
- package/lib/components/table.d.ts +0 -137
- package/lib/components/table.d.ts.map +0 -1
- package/lib/components/table.js +0 -1019
- package/lib/components/table.ts +0 -1225
- package/lib/components/tabs.d.ts +0 -53
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js +0 -275
- package/lib/components/tabs.ts +0 -349
- package/lib/components/theme-toggle.d.ts +0 -45
- package/lib/components/theme-toggle.d.ts.map +0 -1
- package/lib/components/theme-toggle.js +0 -218
- package/lib/components/theme-toggle.ts +0 -297
- package/lib/components/tooltip.d.ts +0 -31
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js +0 -112
- package/lib/components/tooltip.ts +0 -148
- package/lib/components/watcher.d.ts +0 -195
- package/lib/components/watcher.d.ts.map +0 -1
- package/lib/components/watcher.js +0 -241
- package/lib/components/watcher.ts +0 -261
- package/lib/components/write.d.ts +0 -107
- package/lib/components/write.d.ts.map +0 -1
- package/lib/components/write.js +0 -222
- package/lib/components/write.ts +0 -272
- package/lib/data/DataPipeline.d.ts +0 -113
- package/lib/data/DataPipeline.d.ts.map +0 -1
- package/lib/data/DataPipeline.js +0 -359
- package/lib/data/DataPipeline.ts +0 -452
- package/lib/facades/dataframe.jux +0 -0
- package/lib/globals.d.ts +0 -21
- package/lib/reactivity/state.d.ts +0 -36
- package/lib/reactivity/state.d.ts.map +0 -1
- package/lib/reactivity/state.js +0 -67
- package/lib/reactivity/state.ts +0 -78
- package/lib/storage/DataFrame.d.ts +0 -284
- package/lib/storage/DataFrame.d.ts.map +0 -1
- package/lib/storage/DataFrame.js +0 -1022
- package/lib/storage/DataFrame.ts +0 -1195
- package/lib/storage/DataFrameSource.d.ts +0 -158
- package/lib/storage/DataFrameSource.d.ts.map +0 -1
- package/lib/storage/DataFrameSource.js +0 -409
- package/lib/storage/DataFrameSource.ts +0 -556
- package/lib/storage/FileStorage.d.ts +0 -53
- package/lib/storage/FileStorage.d.ts.map +0 -1
- package/lib/storage/FileStorage.js +0 -80
- package/lib/storage/FileStorage.ts +0 -95
- package/lib/storage/IndexedDBDriver.d.ts +0 -75
- package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
- package/lib/storage/IndexedDBDriver.js +0 -177
- package/lib/storage/IndexedDBDriver.ts +0 -226
- package/lib/storage/TabularDriver.d.ts +0 -118
- package/lib/storage/TabularDriver.d.ts.map +0 -1
- package/lib/storage/TabularDriver.js +0 -731
- package/lib/storage/TabularDriver.ts +0 -874
- package/lib/utils/codeparser.d.ts +0 -29
- package/lib/utils/codeparser.d.ts.map +0 -1
- package/lib/utils/codeparser.js +0 -409
- package/lib/utils/fetch.d.ts +0 -176
- package/lib/utils/fetch.d.ts.map +0 -1
- package/lib/utils/fetch.js +0 -427
- package/lib/utils/formatId.d.ts +0 -16
- package/lib/utils/formatId.d.ts.map +0 -1
- package/lib/utils/formatId.js +0 -27
- package/lib/utils/path-resolver.js +0 -23
package/lib/components/list.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { renderIcon } from './icons.js';
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [];
|
|
5
|
-
const CALLBACK_EVENTS = ['itemClick', 'itemDoubleClick', 'selectionChange'];
|
|
6
|
-
export class List extends BaseComponent {
|
|
7
|
-
constructor(id, options = {}) {
|
|
8
|
-
// ✅ Normalize items - convert strings to ListItem objects
|
|
9
|
-
const normalizedItems = (options.items ?? []).map(item => typeof item === 'string' ? { title: item } : item);
|
|
10
|
-
super(id, {
|
|
11
|
-
items: normalizedItems,
|
|
12
|
-
header: options.header ?? '',
|
|
13
|
-
gap: options.gap ?? '0.5rem',
|
|
14
|
-
direction: options.direction ?? 'vertical',
|
|
15
|
-
selectable: options.selectable ?? false,
|
|
16
|
-
multiSelect: options.multiSelect ?? false,
|
|
17
|
-
selectedIndex: options.selectedIndex ?? null,
|
|
18
|
-
selectedIndices: options.selectedIndices ?? [],
|
|
19
|
-
ordered: options.ordered ?? false,
|
|
20
|
-
striped: options.striped ?? false,
|
|
21
|
-
hoverable: options.hoverable ?? true,
|
|
22
|
-
bordered: options.bordered ?? false,
|
|
23
|
-
style: options.style ?? '',
|
|
24
|
-
class: options.class ?? ''
|
|
25
|
-
});
|
|
26
|
-
this._onItemClick = null;
|
|
27
|
-
this._onItemDoubleClick = null;
|
|
28
|
-
this._onSelectionChange = null;
|
|
29
|
-
this._listElement = null;
|
|
30
|
-
this._onItemClick = options.onItemClick ?? null;
|
|
31
|
-
this._onItemDoubleClick = options.onItemDoubleClick ?? null;
|
|
32
|
-
this._onSelectionChange = options.onSelectionChange ?? null;
|
|
33
|
-
}
|
|
34
|
-
getTriggerEvents() {
|
|
35
|
-
return TRIGGER_EVENTS;
|
|
36
|
-
}
|
|
37
|
-
getCallbackEvents() {
|
|
38
|
-
return CALLBACK_EVENTS;
|
|
39
|
-
}
|
|
40
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
41
|
-
* FLUENT API
|
|
42
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
43
|
-
// ✅ Inherited from BaseComponent
|
|
44
|
-
items(value) {
|
|
45
|
-
// ✅ Normalize items when setting via fluent API
|
|
46
|
-
this.state.items = value.map(item => typeof item === 'string' ? { title: item } : item);
|
|
47
|
-
this._updateList();
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
addItem(value) {
|
|
51
|
-
// ✅ Normalize single item
|
|
52
|
-
const normalizedItem = typeof value === 'string' ? { title: value } : value;
|
|
53
|
-
this.state.items = [...this.state.items, normalizedItem];
|
|
54
|
-
this._updateList();
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
removeItem(index) {
|
|
58
|
-
this.state.items = this.state.items.filter((_, i) => i !== index);
|
|
59
|
-
this._updateList();
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
updateItem(index, updates) {
|
|
63
|
-
this.state.items = this.state.items.map((item, i) => i === index ? { ...item, ...updates } : item);
|
|
64
|
-
this._updateList();
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
clearItems() {
|
|
68
|
-
this.state.items = [];
|
|
69
|
-
this._updateList();
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
itemClass(className) {
|
|
73
|
-
this.state.items = this.state.items.map(item => ({
|
|
74
|
-
...item,
|
|
75
|
-
itemClass: className
|
|
76
|
-
}));
|
|
77
|
-
this._updateList();
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
ordered(value) {
|
|
81
|
-
this.state.ordered = value;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
selectable(value) {
|
|
85
|
-
this.state.selectable = value;
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
multiSelect(value) {
|
|
89
|
-
this.state.multiSelect = value;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
striped(value) {
|
|
93
|
-
this.state.striped = value;
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
hoverable(value) {
|
|
97
|
-
this.state.hoverable = value;
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
bordered(value) {
|
|
101
|
-
this.state.bordered = value;
|
|
102
|
-
return this;
|
|
103
|
-
}
|
|
104
|
-
selectItem(index) {
|
|
105
|
-
if (!this.state.selectable)
|
|
106
|
-
return this;
|
|
107
|
-
if (this.state.multiSelect) {
|
|
108
|
-
if (!this.state.selectedIndices.includes(index)) {
|
|
109
|
-
this.state.selectedIndices = [...this.state.selectedIndices, index];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
this.state.selectedIndex = index;
|
|
114
|
-
this.state.selectedIndices = [index];
|
|
115
|
-
}
|
|
116
|
-
this._updateSelection();
|
|
117
|
-
this._triggerSelectionChange();
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
deselectItem(index) {
|
|
121
|
-
if (!this.state.selectable)
|
|
122
|
-
return this;
|
|
123
|
-
if (this.state.multiSelect) {
|
|
124
|
-
this.state.selectedIndices = this.state.selectedIndices.filter(i => i !== index);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this.state.selectedIndex = null;
|
|
128
|
-
this.state.selectedIndices = [];
|
|
129
|
-
}
|
|
130
|
-
this._updateSelection();
|
|
131
|
-
this._triggerSelectionChange();
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
clearSelection() {
|
|
135
|
-
this.state.selectedIndex = null;
|
|
136
|
-
this.state.selectedIndices = [];
|
|
137
|
-
this._updateSelection();
|
|
138
|
-
this._triggerSelectionChange();
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
getSelectedItems() {
|
|
142
|
-
return this.state.selectedIndices.map(i => this.state.items[i]).filter(Boolean);
|
|
143
|
-
}
|
|
144
|
-
getSelectedIndices() {
|
|
145
|
-
return this.state.selectedIndices;
|
|
146
|
-
}
|
|
147
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
148
|
-
* PRIVATE HELPERS
|
|
149
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
150
|
-
_updateList() {
|
|
151
|
-
if (!this._listElement)
|
|
152
|
-
return;
|
|
153
|
-
this._listElement.innerHTML = '';
|
|
154
|
-
this._renderItems(this._listElement);
|
|
155
|
-
}
|
|
156
|
-
_updateSelection() {
|
|
157
|
-
if (!this._listElement)
|
|
158
|
-
return;
|
|
159
|
-
const items = this._listElement.querySelectorAll('.jux-list-item');
|
|
160
|
-
items.forEach((el, index) => {
|
|
161
|
-
const isSelected = this.state.selectedIndices.includes(index);
|
|
162
|
-
el.classList.toggle('jux-list-item-selected', isSelected);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
_triggerSelectionChange() {
|
|
166
|
-
const selectedItems = this.getSelectedItems();
|
|
167
|
-
const selectedIndices = this.getSelectedIndices();
|
|
168
|
-
if (this._onSelectionChange) {
|
|
169
|
-
this._onSelectionChange(selectedItems, selectedIndices);
|
|
170
|
-
}
|
|
171
|
-
// 🎯 Fire the selectionChange callback event
|
|
172
|
-
this._triggerCallback('selectionChange', { items: selectedItems, indices: selectedIndices });
|
|
173
|
-
}
|
|
174
|
-
_renderItems(list) {
|
|
175
|
-
const { items, selectable, hoverable, striped, bordered } = this.state;
|
|
176
|
-
items.forEach((item, index) => {
|
|
177
|
-
const li = document.createElement('li');
|
|
178
|
-
li.className = 'jux-list-item';
|
|
179
|
-
if (item.itemClass)
|
|
180
|
-
li.className += ` ${item.itemClass}`;
|
|
181
|
-
if (item.type && item.type !== 'default')
|
|
182
|
-
li.classList.add(`jux-list-item-${item.type}`);
|
|
183
|
-
if (item.disabled)
|
|
184
|
-
li.classList.add('jux-list-item-disabled');
|
|
185
|
-
if (this.state.selectedIndices.includes(index))
|
|
186
|
-
li.classList.add('jux-list-item-selected');
|
|
187
|
-
if (hoverable && !item.disabled)
|
|
188
|
-
li.classList.add('jux-list-item-hoverable');
|
|
189
|
-
if (striped && index % 2 === 1)
|
|
190
|
-
li.classList.add('jux-list-item-striped');
|
|
191
|
-
if (bordered)
|
|
192
|
-
li.classList.add('jux-list-item-bordered');
|
|
193
|
-
// Content container
|
|
194
|
-
const content = document.createElement('div');
|
|
195
|
-
content.className = 'jux-list-item-content';
|
|
196
|
-
// Icon
|
|
197
|
-
if (item.icon) {
|
|
198
|
-
const iconEl = document.createElement('span');
|
|
199
|
-
iconEl.className = 'jux-list-item-icon';
|
|
200
|
-
iconEl.appendChild(renderIcon(item.icon));
|
|
201
|
-
content.appendChild(iconEl);
|
|
202
|
-
}
|
|
203
|
-
// Text content
|
|
204
|
-
const textContainer = document.createElement('div');
|
|
205
|
-
textContainer.className = 'jux-list-item-text';
|
|
206
|
-
if (item.title) {
|
|
207
|
-
const titleEl = document.createElement('div');
|
|
208
|
-
titleEl.className = 'jux-list-item-title';
|
|
209
|
-
titleEl.textContent = item.title;
|
|
210
|
-
textContainer.appendChild(titleEl);
|
|
211
|
-
}
|
|
212
|
-
if (item.body) {
|
|
213
|
-
const bodyEl = document.createElement('div');
|
|
214
|
-
bodyEl.className = 'jux-list-item-body';
|
|
215
|
-
bodyEl.textContent = item.body;
|
|
216
|
-
textContainer.appendChild(bodyEl);
|
|
217
|
-
}
|
|
218
|
-
content.appendChild(textContainer);
|
|
219
|
-
// Metadata
|
|
220
|
-
if (item.metadata) {
|
|
221
|
-
const metaEl = document.createElement('div');
|
|
222
|
-
metaEl.className = 'jux-list-item-metadata';
|
|
223
|
-
metaEl.textContent = item.metadata;
|
|
224
|
-
content.appendChild(metaEl);
|
|
225
|
-
}
|
|
226
|
-
li.appendChild(content);
|
|
227
|
-
// Click handlers
|
|
228
|
-
if (!item.disabled) {
|
|
229
|
-
li.addEventListener('click', (e) => {
|
|
230
|
-
if (selectable) {
|
|
231
|
-
if (this.state.selectedIndices.includes(index)) {
|
|
232
|
-
this.deselectItem(index);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
if (!this.state.multiSelect) {
|
|
236
|
-
this.clearSelection();
|
|
237
|
-
}
|
|
238
|
-
this.selectItem(index);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (this._onItemClick) {
|
|
242
|
-
this._onItemClick(item, index, e);
|
|
243
|
-
}
|
|
244
|
-
// 🎯 Fire the itemClick callback event
|
|
245
|
-
this._triggerCallback('itemClick', { item, index, event: e });
|
|
246
|
-
});
|
|
247
|
-
li.addEventListener('dblclick', (e) => {
|
|
248
|
-
if (this._onItemDoubleClick) {
|
|
249
|
-
this._onItemDoubleClick(item, index, e);
|
|
250
|
-
}
|
|
251
|
-
// 🎯 Fire the itemDoubleClick callback event
|
|
252
|
-
this._triggerCallback('itemDoubleClick', { item, index, event: e });
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
list.appendChild(li);
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
259
|
-
* RENDER
|
|
260
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
261
|
-
render(targetId) {
|
|
262
|
-
const container = this._setupContainer(targetId);
|
|
263
|
-
const { header, ordered, style, class: className } = this.state;
|
|
264
|
-
const wrapper = document.createElement('div');
|
|
265
|
-
wrapper.className = 'jux-list-wrapper';
|
|
266
|
-
wrapper.id = `${this._id}-wrapper`;
|
|
267
|
-
// Header
|
|
268
|
-
if (header) {
|
|
269
|
-
const headerEl = document.createElement('div');
|
|
270
|
-
headerEl.className = 'jux-list-header';
|
|
271
|
-
headerEl.textContent = header;
|
|
272
|
-
wrapper.appendChild(headerEl);
|
|
273
|
-
}
|
|
274
|
-
// List
|
|
275
|
-
const list = document.createElement(ordered ? 'ol' : 'ul');
|
|
276
|
-
list.className = `jux-list ${ordered ? 'jux-list-ordered' : 'jux-list-unordered'}`;
|
|
277
|
-
list.id = this._id;
|
|
278
|
-
if (className)
|
|
279
|
-
list.className += ` ${className}`;
|
|
280
|
-
if (style)
|
|
281
|
-
list.setAttribute('style', style);
|
|
282
|
-
this._listElement = list;
|
|
283
|
-
this._renderItems(list);
|
|
284
|
-
wrapper.appendChild(list);
|
|
285
|
-
this._wireStandardEvents(list);
|
|
286
|
-
// Wire sync bindings
|
|
287
|
-
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
288
|
-
if (property === 'items') {
|
|
289
|
-
const transform = toComponent || ((v) => v);
|
|
290
|
-
stateObj.subscribe((val) => {
|
|
291
|
-
const transformed = transform(val);
|
|
292
|
-
this.state.items = transformed;
|
|
293
|
-
this._updateList();
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
else if (property === 'selectedIndices') {
|
|
297
|
-
const transform = toComponent || ((v) => v);
|
|
298
|
-
stateObj.subscribe((val) => {
|
|
299
|
-
const transformed = transform(val);
|
|
300
|
-
this.state.selectedIndices = transformed;
|
|
301
|
-
this._updateSelection();
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
container.appendChild(wrapper);
|
|
306
|
-
return this;
|
|
307
|
-
}
|
|
308
|
-
update(prop, value) {
|
|
309
|
-
// No reactive updates needed
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
export function list(id, options = {}) {
|
|
313
|
-
return new List(id, options);
|
|
314
|
-
}
|