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
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import { Modal } from '../modal.js';
|
|
2
|
-
export class ImportSettingsModal {
|
|
3
|
-
constructor(id, driver, options = {}) {
|
|
4
|
-
this._reshapeModal = null;
|
|
5
|
-
this._reshapeModalRendered = false;
|
|
6
|
-
this._settingsModal = null;
|
|
7
|
-
this._modal = null;
|
|
8
|
-
this._modalRendered = false;
|
|
9
|
-
this._id = id;
|
|
10
|
-
this._driver = driver;
|
|
11
|
-
this._maxSheetSize = options.maxSheetSize ?? 100000;
|
|
12
|
-
this._sheetChunkSize = options.sheetChunkSize ?? 10000;
|
|
13
|
-
}
|
|
14
|
-
/* ═══════════════════════════════════════════════════
|
|
15
|
-
* SETTINGS MODAL (Overview)
|
|
16
|
-
* ═══════════════════════════════════════════════════ */
|
|
17
|
-
/**
|
|
18
|
-
* Show the data settings modal with file info and options
|
|
19
|
-
*/
|
|
20
|
-
showSettings(data, callbacks) {
|
|
21
|
-
this.cleanup();
|
|
22
|
-
this._settingsModal = new Modal(`${this._id}-settings-modal`, {
|
|
23
|
-
title: 'Data Settings',
|
|
24
|
-
size: 'medium',
|
|
25
|
-
close: true,
|
|
26
|
-
backdropClose: true
|
|
27
|
-
});
|
|
28
|
-
const fileSizeKB = data.fileSize ? (data.fileSize / 1024).toFixed(1) : '0';
|
|
29
|
-
let contentHTML = `
|
|
30
|
-
<div class="jux-dataframe-settings-content">
|
|
31
|
-
<div class="jux-dataframe-settings-section">
|
|
32
|
-
<div class="jux-dataframe-settings-label">Source</div>
|
|
33
|
-
<div class="jux-dataframe-settings-value">
|
|
34
|
-
<strong>${this._escapeHtml(data.fileName)}</strong>
|
|
35
|
-
${data.fileSize ? `<span class="jux-muted" style="margin-left: 8px;">${fileSizeKB} KB</span>` : ''}
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
<div class="jux-dataframe-settings-section">
|
|
39
|
-
<div class="jux-dataframe-settings-label">Data</div>
|
|
40
|
-
<div class="jux-dataframe-settings-value">
|
|
41
|
-
${data.rowCount > 0 ? `${data.rowCount} rows × ${data.colCount} columns` : 'No data loaded'}
|
|
42
|
-
${data.isMalformed ? '<span style="color: hsl(var(--warning)); margin-left: 8px;">⚠️ May need reformatting</span>' : ''}
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
46
|
-
if (data.hasRawFileData) {
|
|
47
|
-
contentHTML += `
|
|
48
|
-
<div class="jux-dataframe-settings-section">
|
|
49
|
-
<div class="jux-dataframe-settings-label">Import</div>
|
|
50
|
-
<div class="jux-dataframe-settings-value">
|
|
51
|
-
<button id="${this._id}-adjust-import" class="jux-button jux-button-outline jux-button-sm">
|
|
52
|
-
⚙️ Adjust Header Row / Delimiter
|
|
53
|
-
</button>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
`;
|
|
57
|
-
}
|
|
58
|
-
contentHTML += `</div>`;
|
|
59
|
-
this._settingsModal
|
|
60
|
-
.content(contentHTML)
|
|
61
|
-
.actions([
|
|
62
|
-
{
|
|
63
|
-
label: 'Remove Data',
|
|
64
|
-
variant: 'secondary',
|
|
65
|
-
click: async () => {
|
|
66
|
-
await callbacks.onClear();
|
|
67
|
-
this._settingsModal.closeModal();
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'Done',
|
|
72
|
-
variant: 'primary',
|
|
73
|
-
click: () => this._settingsModal.closeModal()
|
|
74
|
-
}
|
|
75
|
-
]);
|
|
76
|
-
this._settingsModal.render(document.body);
|
|
77
|
-
this._settingsModal.open();
|
|
78
|
-
requestAnimationFrame(() => {
|
|
79
|
-
const adjustBtn = document.getElementById(`${this._id}-adjust-import`);
|
|
80
|
-
if (adjustBtn) {
|
|
81
|
-
adjustBtn.addEventListener('click', () => {
|
|
82
|
-
this._settingsModal.closeModal();
|
|
83
|
-
callbacks.onAdjustImport();
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Close the settings modal if open
|
|
90
|
-
*/
|
|
91
|
-
closeSettings() {
|
|
92
|
-
if (this._settingsModal) {
|
|
93
|
-
this._settingsModal.closeModal();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/* ═══════════════════════════════════════════════════
|
|
97
|
-
* IMPORT/RESHAPE MODAL
|
|
98
|
-
* ═══════════════════════════════════════════════════ */
|
|
99
|
-
/**
|
|
100
|
-
* Show the appropriate reshape modal based on file type
|
|
101
|
-
*/
|
|
102
|
-
async showImportSettings(rawFileData, callbacks) {
|
|
103
|
-
if (!rawFileData)
|
|
104
|
-
return;
|
|
105
|
-
if (rawFileData.isExcel) {
|
|
106
|
-
await this._showExcelModal(rawFileData, callbacks);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
this._showCSVModal(rawFileData, callbacks);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Cleanup any existing modals
|
|
114
|
-
*/
|
|
115
|
-
cleanup() {
|
|
116
|
-
if (this._reshapeModal && this._reshapeModalRendered) {
|
|
117
|
-
const oldEl = document.getElementById(`${this._id}-reshape-modal`);
|
|
118
|
-
if (oldEl)
|
|
119
|
-
oldEl.remove();
|
|
120
|
-
this._reshapeModal = null;
|
|
121
|
-
this._reshapeModalRendered = false;
|
|
122
|
-
}
|
|
123
|
-
// Note: Don't close settings modal here - let it close itself
|
|
124
|
-
}
|
|
125
|
-
_escapeHtml(text) {
|
|
126
|
-
const div = document.createElement('div');
|
|
127
|
-
div.textContent = text;
|
|
128
|
-
return div.innerHTML;
|
|
129
|
-
}
|
|
130
|
-
_buildClickablePreviewHTML(rawRows, selectedSheetRow) {
|
|
131
|
-
let html = '<table style="width: 100%; border-collapse: collapse; font-size: 12px;">';
|
|
132
|
-
for (const { sheetRow, values } of rawRows) {
|
|
133
|
-
const isHeader = (sheetRow === selectedSheetRow);
|
|
134
|
-
const isSkipped = (sheetRow < selectedSheetRow);
|
|
135
|
-
let rowStyle = 'border-bottom: 1px solid hsl(var(--border)); cursor: pointer; transition: background 0.1s;';
|
|
136
|
-
if (isHeader) {
|
|
137
|
-
rowStyle += 'background: hsl(142 71% 45% / 0.15); font-weight: 600;';
|
|
138
|
-
}
|
|
139
|
-
else if (isSkipped) {
|
|
140
|
-
rowStyle += 'background: hsl(var(--muted) / 0.4); color: hsl(var(--muted-foreground)); font-style: italic; opacity: 0.7;';
|
|
141
|
-
}
|
|
142
|
-
html += `<tr data-sheet-row="${sheetRow}" style="${rowStyle}" onmouseover="this.style.outline='2px solid hsl(142 71% 45% / 0.5)'" onmouseout="this.style.outline=''">`;
|
|
143
|
-
html += `<td style="padding: 8px 12px; width: 60px; font-weight: 600; color: hsl(var(--muted-foreground)); border-right: 1px solid hsl(var(--border)); text-align: center; user-select: none;">`;
|
|
144
|
-
if (isHeader) {
|
|
145
|
-
html += `<span style="color: hsl(142 71% 45%);">▶ ${sheetRow}</span>`;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
html += `${sheetRow}`;
|
|
149
|
-
}
|
|
150
|
-
html += '</td>';
|
|
151
|
-
const displayCols = values.slice(0, 6);
|
|
152
|
-
displayCols.forEach(val => {
|
|
153
|
-
const displayVal = val != null ? String(val).substring(0, 20) : '';
|
|
154
|
-
const cellStyle = isHeader
|
|
155
|
-
? 'padding: 8px 12px; font-weight: 600; color: hsl(var(--foreground));'
|
|
156
|
-
: 'padding: 8px 12px;';
|
|
157
|
-
html += `<td style="${cellStyle}">${this._escapeHtml(displayVal)}</td>`;
|
|
158
|
-
});
|
|
159
|
-
if (values.length > 6) {
|
|
160
|
-
html += `<td style="padding: 8px 12px; color: hsl(var(--muted-foreground));">…</td>`;
|
|
161
|
-
}
|
|
162
|
-
html += `<td style="padding: 8px 12px; text-align: right; white-space: nowrap; user-select: none;">`;
|
|
163
|
-
if (isHeader) {
|
|
164
|
-
html += '<span style="background: hsl(142 71% 45%); color: white; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600;">HEADER</span>';
|
|
165
|
-
}
|
|
166
|
-
else if (isSkipped) {
|
|
167
|
-
html += '<span style="color: hsl(var(--muted-foreground)); font-size: 10px;">skipped</span>';
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
html += '<span style="color: hsl(var(--muted-foreground)); font-size: 10px;">data</span>';
|
|
171
|
-
}
|
|
172
|
-
html += '</td></tr>';
|
|
173
|
-
}
|
|
174
|
-
html += '</table>';
|
|
175
|
-
return html;
|
|
176
|
-
}
|
|
177
|
-
async _showExcelModal(rawFileData, callbacks) {
|
|
178
|
-
if (!rawFileData.file)
|
|
179
|
-
return;
|
|
180
|
-
this.cleanup();
|
|
181
|
-
const rawRows = await this._driver.readRawExcelRows(rawFileData.file, 15);
|
|
182
|
-
if (rawRows.length === 0)
|
|
183
|
-
return;
|
|
184
|
-
// Auto-detect best header row
|
|
185
|
-
let selectedSheetRow = rawRows[0].sheetRow;
|
|
186
|
-
for (const { sheetRow, values } of rawRows) {
|
|
187
|
-
const nonEmpty = values.filter(v => v !== null && v !== undefined && String(v).trim() !== '');
|
|
188
|
-
if (nonEmpty.length < values.length * 0.5)
|
|
189
|
-
continue;
|
|
190
|
-
const nonNumeric = nonEmpty.filter(v => {
|
|
191
|
-
const str = String(v).trim();
|
|
192
|
-
return isNaN(Number(str)) && str !== '';
|
|
193
|
-
}).length;
|
|
194
|
-
if (nonNumeric >= nonEmpty.length * 0.7) {
|
|
195
|
-
selectedSheetRow = sheetRow;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this._modal = new Modal(`${this._id}-reshape-modal`, {
|
|
200
|
-
title: 'Excel Import Settings',
|
|
201
|
-
size: 'large',
|
|
202
|
-
close: true,
|
|
203
|
-
backdropClose: false
|
|
204
|
-
});
|
|
205
|
-
const modalContentHTML = `
|
|
206
|
-
<div style="margin-bottom: 1rem;">
|
|
207
|
-
<div id="${this._id}-reshape-hint" style="padding: 0.75rem; background: hsl(var(--muted) / 0.5); border-radius: var(--radius); font-size: 0.875rem;"></div>
|
|
208
|
-
<input type="hidden" id="${this._id}-header-row" value="${selectedSheetRow}" />
|
|
209
|
-
</div>
|
|
210
|
-
<div>
|
|
211
|
-
<div style="font-weight: 600; margin-bottom: 0.5rem; color: hsl(var(--foreground));">Click a row to select it as the header:</div>
|
|
212
|
-
<div id="${this._id}-preview" style="font-family: ui-monospace, monospace; font-size: 12px; background: hsl(var(--muted) / 0.3); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0; overflow: hidden; max-height: 400px; overflow-y: auto;"></div>
|
|
213
|
-
</div>
|
|
214
|
-
`;
|
|
215
|
-
this._modal
|
|
216
|
-
.content(modalContentHTML)
|
|
217
|
-
.actions([
|
|
218
|
-
{
|
|
219
|
-
label: 'Cancel',
|
|
220
|
-
variant: 'secondary',
|
|
221
|
-
click: () => this._modal.closeModal()
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
label: 'Apply & Re-import',
|
|
225
|
-
variant: 'primary',
|
|
226
|
-
click: async () => {
|
|
227
|
-
const input = document.getElementById(`${this._id}-header-row`);
|
|
228
|
-
const headerRow = parseInt(input.value) || 0;
|
|
229
|
-
callbacks.onStatusUpdate('Re-parsing with new settings...', 'loading');
|
|
230
|
-
try {
|
|
231
|
-
const sheets = await this._driver.streamFileMultiSheet(rawFileData.file, {
|
|
232
|
-
headerRow,
|
|
233
|
-
maxSheetSize: this._maxSheetSize,
|
|
234
|
-
sheetChunkSize: this._sheetChunkSize
|
|
235
|
-
});
|
|
236
|
-
const sheetNames = Object.keys(sheets);
|
|
237
|
-
if (sheetNames.length === 0) {
|
|
238
|
-
callbacks.onError(`No data found with header at row ${headerRow}. Try a different row.`);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
await this._driver.store(rawFileData.file.name, sheets[sheetNames[0]], { source: rawFileData.file.name });
|
|
242
|
-
if (sheetNames.length > 1) {
|
|
243
|
-
callbacks.onReimport(sheets, rawFileData.file.name);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
callbacks.onReimport(sheets[sheetNames[0]], rawFileData.file.name);
|
|
247
|
-
}
|
|
248
|
-
this._modal.closeModal();
|
|
249
|
-
}
|
|
250
|
-
catch (err) {
|
|
251
|
-
callbacks.onError(`Error: ${err.message}`);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
]);
|
|
256
|
-
this._modal.render(document.body);
|
|
257
|
-
this._modalRendered = true;
|
|
258
|
-
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
259
|
-
const previewDiv = document.getElementById(`${this._id}-preview`);
|
|
260
|
-
const hintDiv = document.getElementById(`${this._id}-reshape-hint`);
|
|
261
|
-
const hiddenInput = document.getElementById(`${this._id}-header-row`);
|
|
262
|
-
const updateHint = (row) => {
|
|
263
|
-
if (!hintDiv)
|
|
264
|
-
return;
|
|
265
|
-
const vals = rawRows.find(r => r.sheetRow === row)?.values ?? [];
|
|
266
|
-
const headerNames = vals.filter((v) => v != null && String(v).trim() !== '').map((v) => String(v).trim());
|
|
267
|
-
const preview = headerNames.slice(0, 4).join(', ') + (headerNames.length > 4 ? '…' : '');
|
|
268
|
-
if (row > rawRows[0].sheetRow) {
|
|
269
|
-
hintDiv.innerHTML = `Sheet row <strong>${row}</strong> selected as header. Columns: <code>${this._escapeHtml(preview)}</code>. Rows before it will be skipped.`;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
hintDiv.innerHTML = `Sheet row <strong>${row}</strong> (first row) selected as header. Columns: <code>${this._escapeHtml(preview)}</code>`;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
const renderPreview = (selected) => {
|
|
276
|
-
if (!previewDiv)
|
|
277
|
-
return;
|
|
278
|
-
previewDiv.innerHTML = this._buildClickablePreviewHTML(rawRows, selected);
|
|
279
|
-
previewDiv.querySelectorAll('tr[data-sheet-row]').forEach(tr => {
|
|
280
|
-
tr.addEventListener('click', () => {
|
|
281
|
-
const rowIdx = parseInt(tr.dataset.sheetRow);
|
|
282
|
-
hiddenInput.value = String(rowIdx);
|
|
283
|
-
updateHint(rowIdx);
|
|
284
|
-
renderPreview(rowIdx);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
updateHint(selectedSheetRow);
|
|
289
|
-
renderPreview(selectedSheetRow);
|
|
290
|
-
this._modal.open();
|
|
291
|
-
}
|
|
292
|
-
_showCSVModal(rawFileData, callbacks) {
|
|
293
|
-
if (!rawFileData.text)
|
|
294
|
-
return;
|
|
295
|
-
this.cleanup();
|
|
296
|
-
const text = rawFileData.text;
|
|
297
|
-
const detected = this._driver._detectDelimiter(text);
|
|
298
|
-
const lines = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
299
|
-
const rawRows = [];
|
|
300
|
-
const maxPreviewRows = Math.min(lines.length, 15);
|
|
301
|
-
for (let i = 0; i < maxPreviewRows; i++) {
|
|
302
|
-
if (!lines[i]) {
|
|
303
|
-
rawRows.push({ sheetRow: i, values: [''] });
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
const values = this._driver._parseLine(lines[i], detected);
|
|
307
|
-
rawRows.push({ sheetRow: i, values });
|
|
308
|
-
}
|
|
309
|
-
// Auto-detect header row
|
|
310
|
-
let selectedRow = 0;
|
|
311
|
-
for (const { sheetRow, values } of rawRows) {
|
|
312
|
-
const nonEmpty = values.filter((v) => v.trim() !== '');
|
|
313
|
-
if (nonEmpty.length < values.length * 0.5)
|
|
314
|
-
continue;
|
|
315
|
-
const nonNumeric = nonEmpty.filter((v) => {
|
|
316
|
-
const trimmed = v.trim();
|
|
317
|
-
return isNaN(Number(trimmed)) && trimmed !== '';
|
|
318
|
-
}).length;
|
|
319
|
-
if (nonNumeric >= nonEmpty.length * 0.7) {
|
|
320
|
-
selectedRow = sheetRow;
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
this._modal = new Modal(`${this._id}-reshape-modal`, {
|
|
325
|
-
title: 'CSV Import Settings',
|
|
326
|
-
size: 'large',
|
|
327
|
-
close: true,
|
|
328
|
-
backdropClose: false
|
|
329
|
-
});
|
|
330
|
-
const modalContentHTML = `
|
|
331
|
-
<div style="margin-bottom: 1rem;">
|
|
332
|
-
<label style="display: block; font-weight: 600; margin-bottom: 0.5rem;">Delimiter</label>
|
|
333
|
-
<select id="${this._id}-delimiter" class="jux-input-element" style="width: 100%;">
|
|
334
|
-
<option value=",">Comma (,)</option>
|
|
335
|
-
<option value="|">Pipe (|)</option>
|
|
336
|
-
<option value="	">Tab (\\t)</option>
|
|
337
|
-
<option value=";">Semicolon (;)</option>
|
|
338
|
-
</select>
|
|
339
|
-
</div>
|
|
340
|
-
<div style="margin-bottom: 1rem;">
|
|
341
|
-
<div id="${this._id}-reshape-hint" style="padding: 0.75rem; background: hsl(var(--muted) / 0.5); border-radius: var(--radius); font-size: 0.875rem;"></div>
|
|
342
|
-
<input type="hidden" id="${this._id}-header-row" value="${selectedRow}" />
|
|
343
|
-
</div>
|
|
344
|
-
<div>
|
|
345
|
-
<div style="font-weight: 600; margin-bottom: 0.5rem; color: hsl(var(--foreground));">Click a row to select it as the header:</div>
|
|
346
|
-
<div id="${this._id}-preview" style="font-family: monospace; font-size: 12px; background: hsl(var(--muted) / 0.3); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0; overflow: hidden; max-height: 400px; overflow-y: auto;"></div>
|
|
347
|
-
</div>
|
|
348
|
-
`;
|
|
349
|
-
this._modal
|
|
350
|
-
.content(modalContentHTML)
|
|
351
|
-
.actions([
|
|
352
|
-
{
|
|
353
|
-
label: 'Cancel',
|
|
354
|
-
variant: 'secondary',
|
|
355
|
-
click: () => this._modal.closeModal()
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
label: 'Apply & Re-import',
|
|
359
|
-
variant: 'primary',
|
|
360
|
-
click: async () => {
|
|
361
|
-
const delimiterSelect = document.getElementById(`${this._id}-delimiter`);
|
|
362
|
-
const hiddenInput = document.getElementById(`${this._id}-header-row`);
|
|
363
|
-
const delim = delimiterSelect.value;
|
|
364
|
-
const headerRow = parseInt(hiddenInput.value) || 0;
|
|
365
|
-
callbacks.onStatusUpdate('Re-parsing with new settings...', 'loading');
|
|
366
|
-
try {
|
|
367
|
-
const df = this._driver.parseCSV(rawFileData.text, {
|
|
368
|
-
delimiter: delim,
|
|
369
|
-
headerRow,
|
|
370
|
-
hasHeader: true
|
|
371
|
-
});
|
|
372
|
-
await this._driver.store(rawFileData.file.name, df, { source: rawFileData.file.name });
|
|
373
|
-
callbacks.onReimport(df, rawFileData.file.name);
|
|
374
|
-
this._modal.closeModal();
|
|
375
|
-
}
|
|
376
|
-
catch (err) {
|
|
377
|
-
callbacks.onError(`Error: ${err.message}`);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
]);
|
|
382
|
-
this._modal.render(document.body);
|
|
383
|
-
this._modalRendered = true;
|
|
384
|
-
requestAnimationFrame(() => {
|
|
385
|
-
const delimiterSelect = document.getElementById(`${this._id}-delimiter`);
|
|
386
|
-
const previewDiv = document.getElementById(`${this._id}-preview`);
|
|
387
|
-
const hintDiv = document.getElementById(`${this._id}-reshape-hint`);
|
|
388
|
-
const hiddenInput = document.getElementById(`${this._id}-header-row`);
|
|
389
|
-
if (delimiterSelect)
|
|
390
|
-
delimiterSelect.value = detected;
|
|
391
|
-
const updateHint = (row) => {
|
|
392
|
-
if (!hintDiv)
|
|
393
|
-
return;
|
|
394
|
-
const vals = rawRows.find(r => r.sheetRow === row)?.values ?? [];
|
|
395
|
-
const headerNames = vals.filter((v) => v != null && String(v).trim() !== '').map((v) => String(v).trim());
|
|
396
|
-
const preview = headerNames.slice(0, 4).join(', ') + (headerNames.length > 4 ? '…' : '');
|
|
397
|
-
if (row > rawRows[0].sheetRow) {
|
|
398
|
-
hintDiv.innerHTML = `Sheet row <strong>${row}</strong> selected as header. Columns: <code>${this._escapeHtml(preview)}</code>. Rows before it will be skipped.`;
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
hintDiv.innerHTML = `Sheet row <strong>${row}</strong> (first row) selected as header. Columns: <code>${this._escapeHtml(preview)}</code>`;
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
const reparse = () => {
|
|
405
|
-
const delim = delimiterSelect?.value || ',';
|
|
406
|
-
rawRows.length = 0;
|
|
407
|
-
for (let i = 0; i < maxPreviewRows; i++) {
|
|
408
|
-
if (!lines[i]) {
|
|
409
|
-
rawRows.push({ sheetRow: i, values: [''] });
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
const values = this._driver._parseLine(lines[i], delim);
|
|
413
|
-
rawRows.push({ sheetRow: i, values });
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
const renderPreview = (selected) => {
|
|
417
|
-
if (!previewDiv)
|
|
418
|
-
return;
|
|
419
|
-
previewDiv.innerHTML = this._buildClickablePreviewHTML(rawRows, selected);
|
|
420
|
-
previewDiv.querySelectorAll('tr[data-sheet-row]').forEach(tr => {
|
|
421
|
-
tr.addEventListener('click', () => {
|
|
422
|
-
const rowIdx = parseInt(tr.dataset.sheetRow);
|
|
423
|
-
hiddenInput.value = String(rowIdx);
|
|
424
|
-
updateHint(rowIdx);
|
|
425
|
-
renderPreview(rowIdx);
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
};
|
|
429
|
-
if (delimiterSelect) {
|
|
430
|
-
delimiterSelect.addEventListener('change', () => {
|
|
431
|
-
reparse();
|
|
432
|
-
const current = parseInt(hiddenInput.value) || 0;
|
|
433
|
-
updateHint(current);
|
|
434
|
-
renderPreview(current);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
updateHint(selectedRow);
|
|
438
|
-
renderPreview(selectedRow);
|
|
439
|
-
this._modal.open();
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|