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/modal.js
DELETED
|
@@ -1,463 +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 = ['open', 'close'];
|
|
6
|
-
export class Modal extends BaseComponent {
|
|
7
|
-
constructor(id, options = {}) {
|
|
8
|
-
super(id, {
|
|
9
|
-
title: options.title ?? '',
|
|
10
|
-
content: options.content ?? '',
|
|
11
|
-
icon: options.icon ?? undefined,
|
|
12
|
-
close: options.close ?? true,
|
|
13
|
-
backdropClose: options.backdropClose ?? true,
|
|
14
|
-
position: options.position,
|
|
15
|
-
size: options.size ?? 'medium',
|
|
16
|
-
open: false,
|
|
17
|
-
actions: options.actions ?? [],
|
|
18
|
-
style: options.style ?? '',
|
|
19
|
-
class: options.class ?? ''
|
|
20
|
-
});
|
|
21
|
-
this._overlay = null;
|
|
22
|
-
}
|
|
23
|
-
getTriggerEvents() {
|
|
24
|
-
return TRIGGER_EVENTS;
|
|
25
|
-
}
|
|
26
|
-
getCallbackEvents() {
|
|
27
|
-
return CALLBACK_EVENTS;
|
|
28
|
-
}
|
|
29
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
30
|
-
* REACTIVE UPDATE (Precision DOM edits)
|
|
31
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
32
|
-
update(prop, value) {
|
|
33
|
-
super.update(prop, value);
|
|
34
|
-
if (!this._overlay)
|
|
35
|
-
return;
|
|
36
|
-
const modal = this._overlay.querySelector('.jux-modal');
|
|
37
|
-
if (!modal)
|
|
38
|
-
return;
|
|
39
|
-
switch (prop) {
|
|
40
|
-
case 'open':
|
|
41
|
-
this._overlay.style.display = value ? 'flex' : 'none';
|
|
42
|
-
if (value) {
|
|
43
|
-
this._triggerCallback('open');
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this._triggerCallback('close');
|
|
47
|
-
}
|
|
48
|
-
break;
|
|
49
|
-
case 'title':
|
|
50
|
-
this._updateTitle(value);
|
|
51
|
-
break;
|
|
52
|
-
case 'content':
|
|
53
|
-
this._updateContent(value);
|
|
54
|
-
break;
|
|
55
|
-
case 'icon':
|
|
56
|
-
this._updateIcon(value);
|
|
57
|
-
break;
|
|
58
|
-
case 'size':
|
|
59
|
-
modal.className = modal.className.replace(/jux-modal-(small|medium|large)/, `jux-modal-${value}`);
|
|
60
|
-
break;
|
|
61
|
-
case 'position':
|
|
62
|
-
// Remove existing position classes
|
|
63
|
-
this._overlay.className = this._overlay.className
|
|
64
|
-
.split(' ')
|
|
65
|
-
.filter(c => !c.startsWith('jux-modal-position-'))
|
|
66
|
-
.join(' ');
|
|
67
|
-
// Add new position class
|
|
68
|
-
if (value) {
|
|
69
|
-
this._overlay.classList.add(`jux-modal-position-${value}`);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case 'actions':
|
|
73
|
-
this._rebuildActions();
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
_updateTitle(value) {
|
|
78
|
-
let headerEl = this._overlay.querySelector('.jux-modal-header');
|
|
79
|
-
if (!headerEl && value) {
|
|
80
|
-
// Create header if it doesn't exist
|
|
81
|
-
headerEl = document.createElement('div');
|
|
82
|
-
headerEl.className = 'jux-modal-header';
|
|
83
|
-
const modal = this._overlay.querySelector('.jux-modal');
|
|
84
|
-
const body = modal.querySelector('.jux-modal-body');
|
|
85
|
-
modal.insertBefore(headerEl, body);
|
|
86
|
-
}
|
|
87
|
-
if (headerEl) {
|
|
88
|
-
// Preserve icon if exists
|
|
89
|
-
const iconEl = headerEl.querySelector('.jux-modal-header-icon');
|
|
90
|
-
headerEl.innerHTML = '';
|
|
91
|
-
if (iconEl) {
|
|
92
|
-
headerEl.appendChild(iconEl);
|
|
93
|
-
}
|
|
94
|
-
const titleEl = document.createElement('span');
|
|
95
|
-
titleEl.className = 'jux-modal-header-title';
|
|
96
|
-
titleEl.textContent = value;
|
|
97
|
-
headerEl.appendChild(titleEl);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
_updateIcon(value) {
|
|
101
|
-
const headerEl = this._overlay.querySelector('.jux-modal-header');
|
|
102
|
-
if (!headerEl)
|
|
103
|
-
return;
|
|
104
|
-
let iconEl = headerEl.querySelector('.jux-modal-header-icon');
|
|
105
|
-
if (value) {
|
|
106
|
-
if (!iconEl) {
|
|
107
|
-
iconEl = document.createElement('span');
|
|
108
|
-
iconEl.className = 'jux-modal-header-icon';
|
|
109
|
-
headerEl.insertBefore(iconEl, headerEl.firstChild);
|
|
110
|
-
}
|
|
111
|
-
iconEl.innerHTML = '';
|
|
112
|
-
iconEl.appendChild(renderIcon(value.icon, value.collection));
|
|
113
|
-
}
|
|
114
|
-
else if (iconEl) {
|
|
115
|
-
iconEl.remove();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
_updateContent(value) {
|
|
119
|
-
const contentEl = this._overlay.querySelector('.jux-modal-content');
|
|
120
|
-
if (!contentEl)
|
|
121
|
-
return;
|
|
122
|
-
contentEl.innerHTML = '';
|
|
123
|
-
const items = Array.isArray(value) ? value : [value];
|
|
124
|
-
items.forEach(item => {
|
|
125
|
-
if (typeof item === 'string') {
|
|
126
|
-
const tempDiv = document.createElement('div');
|
|
127
|
-
tempDiv.innerHTML = item;
|
|
128
|
-
while (tempDiv.firstChild) {
|
|
129
|
-
contentEl.appendChild(tempDiv.firstChild);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else if (item instanceof BaseComponent) {
|
|
133
|
-
item.render(contentEl);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
_rebuildActions() {
|
|
138
|
-
const modal = this._overlay.querySelector('.jux-modal');
|
|
139
|
-
if (!modal)
|
|
140
|
-
return;
|
|
141
|
-
let footerEl = modal.querySelector('.jux-modal-footer');
|
|
142
|
-
if (this.state.actions.length === 0) {
|
|
143
|
-
if (footerEl)
|
|
144
|
-
footerEl.remove();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (!footerEl) {
|
|
148
|
-
footerEl = document.createElement('div');
|
|
149
|
-
footerEl.className = 'jux-modal-footer';
|
|
150
|
-
modal.appendChild(footerEl);
|
|
151
|
-
}
|
|
152
|
-
footerEl.innerHTML = '';
|
|
153
|
-
this.state.actions.forEach(action => {
|
|
154
|
-
// Check if it's an array of BaseComponents
|
|
155
|
-
if (Array.isArray(action)) {
|
|
156
|
-
action.forEach(component => {
|
|
157
|
-
if (component instanceof BaseComponent) {
|
|
158
|
-
component.render(footerEl);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
// Otherwise it's an action object with label property
|
|
163
|
-
else if ('label' in action) {
|
|
164
|
-
const btn = document.createElement('button');
|
|
165
|
-
btn.className = `jux-modal-action jux-modal-action-${action.variant || 'default'}`;
|
|
166
|
-
btn.textContent = action.label;
|
|
167
|
-
btn.type = 'button';
|
|
168
|
-
btn.addEventListener('click', () => {
|
|
169
|
-
if (action.click)
|
|
170
|
-
action.click();
|
|
171
|
-
});
|
|
172
|
-
footerEl.appendChild(btn);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
177
|
-
* FLUENT API (Just set state, update() handles DOM)
|
|
178
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
179
|
-
title(value) {
|
|
180
|
-
this.state.title = value;
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
content(value) {
|
|
184
|
-
this.state.content = value;
|
|
185
|
-
return this;
|
|
186
|
-
}
|
|
187
|
-
icon(value) {
|
|
188
|
-
this.state.icon = value;
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
close(value) {
|
|
192
|
-
this.state.close = value;
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
backdropClose(value) {
|
|
196
|
-
this.state.backdropClose = value;
|
|
197
|
-
return this;
|
|
198
|
-
}
|
|
199
|
-
size(value) {
|
|
200
|
-
this.state.size = value;
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
position(value) {
|
|
204
|
-
this.state.position = value;
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
actions(value) {
|
|
208
|
-
this.state.actions = value;
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
addAction(action) {
|
|
212
|
-
this.state.actions = [...this.state.actions, action];
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
open() {
|
|
216
|
-
this.state.open = true;
|
|
217
|
-
this._triggerCallback('open', true, null, this);
|
|
218
|
-
return this;
|
|
219
|
-
}
|
|
220
|
-
closeModal() {
|
|
221
|
-
this.state.open = false;
|
|
222
|
-
this._triggerCallback('close', false, null, this);
|
|
223
|
-
return this;
|
|
224
|
-
}
|
|
225
|
-
toggle() {
|
|
226
|
-
this.state.open = !this.state.open;
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Check if modal is currently open
|
|
231
|
-
*/
|
|
232
|
-
isOpen() {
|
|
233
|
-
return this.state.open;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Check if modal is currently closed
|
|
237
|
-
*/
|
|
238
|
-
isClosed() {
|
|
239
|
-
return !this.state.open;
|
|
240
|
-
}
|
|
241
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
242
|
-
* DYNAMIC CONTENT ADDITION (Like tabs.addTabContent)
|
|
243
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
244
|
-
/**
|
|
245
|
-
* Add content to modal (supports strings and BaseComponents)
|
|
246
|
-
*/
|
|
247
|
-
addContent(content) {
|
|
248
|
-
const contentEl = this._overlay?.querySelector('.jux-modal-content');
|
|
249
|
-
if (!contentEl) {
|
|
250
|
-
console.warn('[Modal] Content element not found');
|
|
251
|
-
return this;
|
|
252
|
-
}
|
|
253
|
-
const items = Array.isArray(content) ? content : [content];
|
|
254
|
-
items.forEach(item => {
|
|
255
|
-
if (typeof item === 'string') {
|
|
256
|
-
const tempDiv = document.createElement('div');
|
|
257
|
-
tempDiv.innerHTML = item;
|
|
258
|
-
while (tempDiv.firstChild) {
|
|
259
|
-
contentEl.appendChild(tempDiv.firstChild);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
else if (item instanceof BaseComponent) {
|
|
263
|
-
item.render(contentEl);
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
return this;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Clear all content from modal
|
|
270
|
-
*/
|
|
271
|
-
clearContent() {
|
|
272
|
-
const contentEl = this._overlay?.querySelector('.jux-modal-content');
|
|
273
|
-
if (contentEl) {
|
|
274
|
-
contentEl.innerHTML = '';
|
|
275
|
-
}
|
|
276
|
-
return this;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Get the modal content element ID for rendering child components
|
|
280
|
-
*/
|
|
281
|
-
contentId() {
|
|
282
|
-
return `${this._id}-content`;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Get the modal content element (only available after render)
|
|
286
|
-
*/
|
|
287
|
-
getContentElement() {
|
|
288
|
-
return document.getElementById(this.contentId());
|
|
289
|
-
}
|
|
290
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
291
|
-
* RENDER
|
|
292
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
293
|
-
render(targetId) {
|
|
294
|
-
const container = this._setupContainer(targetId);
|
|
295
|
-
const { open, title, content, icon, size, position, close, backdropClose, actions, style, class: className } = this.state;
|
|
296
|
-
const hasOpenSync = this._syncBindings.some(b => b.property === 'open');
|
|
297
|
-
const overlay = document.createElement('div');
|
|
298
|
-
overlay.className = 'jux-modal-overlay';
|
|
299
|
-
overlay.id = this._id;
|
|
300
|
-
overlay.style.display = open ? 'flex' : 'none';
|
|
301
|
-
// Add position class
|
|
302
|
-
if (position) {
|
|
303
|
-
overlay.classList.add(`jux-modal-position-${position}`);
|
|
304
|
-
}
|
|
305
|
-
if (className)
|
|
306
|
-
overlay.className += ` ${className}`;
|
|
307
|
-
if (style)
|
|
308
|
-
overlay.setAttribute('style', style);
|
|
309
|
-
this._overlay = overlay;
|
|
310
|
-
const modal = document.createElement('div');
|
|
311
|
-
modal.className = `jux-modal jux-modal-${size}`;
|
|
312
|
-
if (close) {
|
|
313
|
-
const closeButton = document.createElement('button');
|
|
314
|
-
closeButton.className = 'jux-modal-close';
|
|
315
|
-
closeButton.innerHTML = '×';
|
|
316
|
-
closeButton.type = 'button';
|
|
317
|
-
modal.appendChild(closeButton);
|
|
318
|
-
}
|
|
319
|
-
if (title || icon) {
|
|
320
|
-
const header = document.createElement('div');
|
|
321
|
-
header.className = 'jux-modal-header';
|
|
322
|
-
if (icon) {
|
|
323
|
-
const iconEl = document.createElement('span');
|
|
324
|
-
iconEl.className = 'jux-modal-header-icon';
|
|
325
|
-
iconEl.appendChild(renderIcon(icon.icon, icon.collection));
|
|
326
|
-
header.appendChild(iconEl);
|
|
327
|
-
}
|
|
328
|
-
if (title) {
|
|
329
|
-
const titleEl = document.createElement('span');
|
|
330
|
-
titleEl.className = 'jux-modal-header-title';
|
|
331
|
-
titleEl.textContent = title;
|
|
332
|
-
header.appendChild(titleEl);
|
|
333
|
-
}
|
|
334
|
-
modal.appendChild(header);
|
|
335
|
-
}
|
|
336
|
-
const contentElement = document.createElement('div');
|
|
337
|
-
contentElement.className = 'jux-modal-content';
|
|
338
|
-
contentElement.id = this.contentId();
|
|
339
|
-
modal.appendChild(contentElement);
|
|
340
|
-
// Render initial content
|
|
341
|
-
if (content) {
|
|
342
|
-
const items = Array.isArray(content) ? content : [content];
|
|
343
|
-
items.forEach(item => {
|
|
344
|
-
if (typeof item === 'string') {
|
|
345
|
-
const tempDiv = document.createElement('div');
|
|
346
|
-
tempDiv.innerHTML = item;
|
|
347
|
-
while (tempDiv.firstChild) {
|
|
348
|
-
contentElement.appendChild(tempDiv.firstChild);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else if (item instanceof BaseComponent) {
|
|
352
|
-
item.render(contentElement);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
if (actions.length > 0) {
|
|
357
|
-
const footer = document.createElement('div');
|
|
358
|
-
footer.className = 'jux-modal-footer';
|
|
359
|
-
actions.forEach(action => {
|
|
360
|
-
// Check if it's an array of BaseComponents
|
|
361
|
-
if (Array.isArray(action)) {
|
|
362
|
-
action.forEach(component => {
|
|
363
|
-
if (component instanceof BaseComponent) {
|
|
364
|
-
component.render(footer);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
// Otherwise it's an action object with label property
|
|
369
|
-
else if ('label' in action) {
|
|
370
|
-
const btn = document.createElement('button');
|
|
371
|
-
btn.className = `jux-modal-action jux-modal-action-${action.variant || 'default'}`;
|
|
372
|
-
btn.textContent = action.label;
|
|
373
|
-
btn.type = 'button';
|
|
374
|
-
btn.addEventListener('click', () => {
|
|
375
|
-
if (action.click)
|
|
376
|
-
action.click();
|
|
377
|
-
});
|
|
378
|
-
footer.appendChild(btn);
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
modal.appendChild(footer);
|
|
382
|
-
}
|
|
383
|
-
overlay.appendChild(modal);
|
|
384
|
-
// Default dismiss behavior (only if NOT using sync)
|
|
385
|
-
if (!hasOpenSync) {
|
|
386
|
-
if (close) {
|
|
387
|
-
const closeButton = modal.querySelector('.jux-modal-close');
|
|
388
|
-
closeButton?.addEventListener('click', () => {
|
|
389
|
-
this.state.open = false;
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
if (backdropClose) {
|
|
393
|
-
overlay.addEventListener('click', (e) => {
|
|
394
|
-
if (e.target === overlay) {
|
|
395
|
-
this.state.open = false;
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
this._wireStandardEvents(overlay);
|
|
401
|
-
// Wire sync bindings
|
|
402
|
-
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
403
|
-
if (property === 'open') {
|
|
404
|
-
const transformToState = toState || ((v) => Boolean(v));
|
|
405
|
-
const transformToComponent = toComponent || ((v) => Boolean(v));
|
|
406
|
-
let isUpdating = false;
|
|
407
|
-
stateObj.subscribe((val) => {
|
|
408
|
-
if (isUpdating)
|
|
409
|
-
return;
|
|
410
|
-
const transformed = transformToComponent(val);
|
|
411
|
-
this.state.open = transformed;
|
|
412
|
-
});
|
|
413
|
-
if (close) {
|
|
414
|
-
const closeButton = modal.querySelector('.jux-modal-close');
|
|
415
|
-
closeButton?.addEventListener('click', () => {
|
|
416
|
-
if (isUpdating)
|
|
417
|
-
return;
|
|
418
|
-
isUpdating = true;
|
|
419
|
-
this.state.open = false;
|
|
420
|
-
stateObj.set(transformToState(false));
|
|
421
|
-
setTimeout(() => { isUpdating = false; }, 0);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
if (backdropClose) {
|
|
425
|
-
overlay.addEventListener('click', (e) => {
|
|
426
|
-
if (e.target === overlay) {
|
|
427
|
-
if (isUpdating)
|
|
428
|
-
return;
|
|
429
|
-
isUpdating = true;
|
|
430
|
-
this.state.open = false;
|
|
431
|
-
stateObj.set(transformToState(false));
|
|
432
|
-
setTimeout(() => { isUpdating = false; }, 0);
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
else if (property === 'content') {
|
|
438
|
-
const transform = toComponent || ((v) => String(v));
|
|
439
|
-
stateObj.subscribe((val) => {
|
|
440
|
-
const transformed = transform(val);
|
|
441
|
-
this.state.content = transformed;
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
else if (property === 'title') {
|
|
445
|
-
const transform = toComponent || ((v) => String(v));
|
|
446
|
-
stateObj.subscribe((val) => {
|
|
447
|
-
const transformed = transform(val);
|
|
448
|
-
this.state.title = transformed;
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
container.appendChild(overlay);
|
|
453
|
-
requestAnimationFrame(() => {
|
|
454
|
-
if (window.Iconify) {
|
|
455
|
-
window.Iconify.scan();
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
return this;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
export function modal(id, options = {}) {
|
|
462
|
-
return new Modal(id, options);
|
|
463
|
-
}
|