@chalabi/svelte-sheets 2.0.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.
- package/Readme.md +110 -0
- package/dist/Menu.svelte +97 -0
- package/dist/Menu.svelte.d.ts +30 -0
- package/dist/Open.svelte +35 -0
- package/dist/Open.svelte.d.ts +23 -0
- package/dist/Sheet.svelte +1167 -0
- package/dist/Sheet.svelte.d.ts +42 -0
- package/dist/Toolbar.svelte +69 -0
- package/dist/Toolbar.svelte.d.ts +22 -0
- package/dist/actions/copypaste.d.ts +1 -0
- package/dist/actions/copypaste.js +24 -0
- package/dist/actions/draggable.d.ts +3 -0
- package/dist/actions/draggable.js +37 -0
- package/dist/actions/index.d.ts +5 -0
- package/dist/actions/index.js +5 -0
- package/dist/actions/resizable.d.ts +3 -0
- package/dist/actions/resizable.js +37 -0
- package/dist/actions/rightclick.d.ts +1 -0
- package/dist/actions/rightclick.js +1 -0
- package/dist/actions/selected.d.ts +5 -0
- package/dist/actions/selected.js +10 -0
- package/dist/convert.d.ts +16 -0
- package/dist/convert.js +164 -0
- package/dist/defaultconfig.d.ts +138 -0
- package/dist/defaultconfig.js +195 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/utilities.d.ts +13 -0
- package/dist/utilities.js +211 -0
- package/package.json +182 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export const defaultconfig = {
|
|
2
|
+
// External data
|
|
3
|
+
url: null,
|
|
4
|
+
// Data
|
|
5
|
+
// data,
|
|
6
|
+
// Copy behavior
|
|
7
|
+
copyCompatibility: false,
|
|
8
|
+
root: null,
|
|
9
|
+
// Rows and columns definitions
|
|
10
|
+
// rows: [],
|
|
11
|
+
// columns,
|
|
12
|
+
// Deprected legacy options
|
|
13
|
+
colHeaders: [],
|
|
14
|
+
colWidths: [],
|
|
15
|
+
colAlignments: [],
|
|
16
|
+
nestedHeaders: null,
|
|
17
|
+
// Column width that is used by default
|
|
18
|
+
defaultColWidth: 50,
|
|
19
|
+
defaultColAlign: "center",
|
|
20
|
+
// Spare rows and columns
|
|
21
|
+
minSpareRows: 0,
|
|
22
|
+
minSpareCols: 0,
|
|
23
|
+
// Minimal table dimensions
|
|
24
|
+
minDimensions: [0, 0],
|
|
25
|
+
// Allow Export
|
|
26
|
+
allowExport: true,
|
|
27
|
+
// @type {boolean} - Include the header titles on download
|
|
28
|
+
includeHeadersOnDownload: false,
|
|
29
|
+
// @type {boolean} - Include the header titles on copy
|
|
30
|
+
includeHeadersOnCopy: false,
|
|
31
|
+
// Allow column sorting
|
|
32
|
+
columnSorting: true,
|
|
33
|
+
// Allow column dragging
|
|
34
|
+
columnDrag: false,
|
|
35
|
+
// Allow column resizing
|
|
36
|
+
columnResize: true,
|
|
37
|
+
// Allow row resizing
|
|
38
|
+
rowResize: false,
|
|
39
|
+
// Allow row dragging
|
|
40
|
+
rowDrag: true,
|
|
41
|
+
// Allow table edition
|
|
42
|
+
editable: true,
|
|
43
|
+
// Global read-only mode (overrides editable)
|
|
44
|
+
readOnly: false,
|
|
45
|
+
// Disable hover tracking/selection updates
|
|
46
|
+
disableHover: false,
|
|
47
|
+
// Allow new rows
|
|
48
|
+
allowInsertRow: true,
|
|
49
|
+
// Allow new rows
|
|
50
|
+
allowManualInsertRow: true,
|
|
51
|
+
// Allow new columns
|
|
52
|
+
allowInsertColumn: true,
|
|
53
|
+
// Allow new rows
|
|
54
|
+
allowManualInsertColumn: true,
|
|
55
|
+
// Allow row delete
|
|
56
|
+
allowDeleteRow: true,
|
|
57
|
+
// Allow deleting of all rows
|
|
58
|
+
allowDeletingAllRows: false,
|
|
59
|
+
// Allow column delete
|
|
60
|
+
allowDeleteColumn: true,
|
|
61
|
+
// Allow rename column
|
|
62
|
+
allowRenameColumn: true,
|
|
63
|
+
// Allow comments
|
|
64
|
+
allowComments: false,
|
|
65
|
+
// Global wrap
|
|
66
|
+
wordWrap: false,
|
|
67
|
+
// Image options
|
|
68
|
+
imageOptions: null,
|
|
69
|
+
// CSV source
|
|
70
|
+
csv: null,
|
|
71
|
+
// Filename
|
|
72
|
+
csvFileName: "jexcel",
|
|
73
|
+
// Consider first line as header
|
|
74
|
+
csvHeaders: true,
|
|
75
|
+
// Delimiters
|
|
76
|
+
csvDelimiter: ",",
|
|
77
|
+
// First row as header
|
|
78
|
+
parseTableFirstRowAsHeader: false,
|
|
79
|
+
parseTableAutoCellType: false,
|
|
80
|
+
// Disable corner selection
|
|
81
|
+
selectionCopy: true,
|
|
82
|
+
// Merged cells
|
|
83
|
+
// mergeCells: {},
|
|
84
|
+
// Create toolbar
|
|
85
|
+
toolbar: null,
|
|
86
|
+
// Allow search
|
|
87
|
+
search: false,
|
|
88
|
+
// Create pagination
|
|
89
|
+
pagination: false,
|
|
90
|
+
paginationOptions: null,
|
|
91
|
+
// Full screen
|
|
92
|
+
fullscreen: false,
|
|
93
|
+
// Lazy loading
|
|
94
|
+
lazyLoading: false,
|
|
95
|
+
loadingSpin: false,
|
|
96
|
+
// Table overflow
|
|
97
|
+
tableOverflow: false,
|
|
98
|
+
tableHeight: "300px",
|
|
99
|
+
tableWidth: null,
|
|
100
|
+
// Meta
|
|
101
|
+
meta: null,
|
|
102
|
+
// Style
|
|
103
|
+
style: null,
|
|
104
|
+
// Execute formulas
|
|
105
|
+
parseFormulas: true,
|
|
106
|
+
autoIncrement: true,
|
|
107
|
+
autoCasting: true,
|
|
108
|
+
// Security
|
|
109
|
+
secureFormulas: true,
|
|
110
|
+
stripHTML: true,
|
|
111
|
+
stripHTMLOnCopy: false,
|
|
112
|
+
// Filters
|
|
113
|
+
filters: false,
|
|
114
|
+
footers: null,
|
|
115
|
+
// Event handles
|
|
116
|
+
onundo: null,
|
|
117
|
+
onredo: null,
|
|
118
|
+
onload: null,
|
|
119
|
+
onchange: null,
|
|
120
|
+
oncomments: null,
|
|
121
|
+
onbeforechange: null,
|
|
122
|
+
onafterchanges: null,
|
|
123
|
+
onbeforeinsertrow: null,
|
|
124
|
+
oninsertrow: null,
|
|
125
|
+
onbeforeinsertcolumn: null,
|
|
126
|
+
oninsertcolumn: null,
|
|
127
|
+
onbeforedeleterow: null,
|
|
128
|
+
ondeleterow: null,
|
|
129
|
+
onbeforedeletecolumn: null,
|
|
130
|
+
ondeletecolumn: null,
|
|
131
|
+
onmoverow: null,
|
|
132
|
+
onmovecolumn: null,
|
|
133
|
+
onresizerow: null,
|
|
134
|
+
onresizecolumn: null,
|
|
135
|
+
onsort: null,
|
|
136
|
+
onselection: null,
|
|
137
|
+
oncopy: null,
|
|
138
|
+
onpaste: null,
|
|
139
|
+
onbeforepaste: null,
|
|
140
|
+
onmerge: null,
|
|
141
|
+
onfocus: null,
|
|
142
|
+
onblur: null,
|
|
143
|
+
onchangeheader: null,
|
|
144
|
+
oncreateeditor: null,
|
|
145
|
+
oneditionstart: null,
|
|
146
|
+
oneditionend: null,
|
|
147
|
+
onchangestyle: null,
|
|
148
|
+
onchangemeta: null,
|
|
149
|
+
onchangepage: null,
|
|
150
|
+
onbeforesave: null,
|
|
151
|
+
onsave: null,
|
|
152
|
+
// Global event dispatcher
|
|
153
|
+
onevent: null,
|
|
154
|
+
// Persistance
|
|
155
|
+
persistance: false,
|
|
156
|
+
// Customize any cell behavior
|
|
157
|
+
updateTable: null,
|
|
158
|
+
// Detach the HTML table when calling updateTable
|
|
159
|
+
detachForUpdates: false,
|
|
160
|
+
freezeColumns: null,
|
|
161
|
+
// Texts
|
|
162
|
+
text: {
|
|
163
|
+
noRecordsFound: "No records found",
|
|
164
|
+
showingPage: "Showing page {0} of {1} entries",
|
|
165
|
+
show: "Show ",
|
|
166
|
+
search: "Search",
|
|
167
|
+
entries: " entries",
|
|
168
|
+
columnName: "Column name",
|
|
169
|
+
insertANewColumnBefore: "Insert a new column before",
|
|
170
|
+
insertANewColumnAfter: "Insert a new column after",
|
|
171
|
+
deleteSelectedColumns: "Delete selected columns",
|
|
172
|
+
renameThisColumn: "Rename this column",
|
|
173
|
+
orderAscending: "Order ascending",
|
|
174
|
+
orderDescending: "Order descending",
|
|
175
|
+
insertANewRowBefore: "Insert a new row before",
|
|
176
|
+
insertANewRowAfter: "Insert a new row after",
|
|
177
|
+
deleteSelectedRows: "Delete selected rows",
|
|
178
|
+
editComments: "Edit comments",
|
|
179
|
+
addComments: "Add comments",
|
|
180
|
+
comments: "Comments",
|
|
181
|
+
clearComments: "Clear comments",
|
|
182
|
+
copy: "Copy...",
|
|
183
|
+
paste: "Paste...",
|
|
184
|
+
saveAs: "Save as...",
|
|
185
|
+
about: "About",
|
|
186
|
+
areYouSureToDeleteTheSelectedRows: "Are you sure to delete the selected rows?",
|
|
187
|
+
areYouSureToDeleteTheSelectedColumns: "Are you sure to delete the selected columns?",
|
|
188
|
+
thisActionWillDestroyAnyExistingMergedCellsAreYouSure: "This action will destroy any existing merged cells. Are you sure?",
|
|
189
|
+
thisActionWillClearYourSearchResultsAreYouSure: "This action will clear your search results. Are you sure?",
|
|
190
|
+
thereIsAConflictWithAnotherMergedCell: "There is a conflict with another merged cell",
|
|
191
|
+
invalidMergeProperties: "Invalid merged properties",
|
|
192
|
+
cellAlreadyMerged: "Cell already merged",
|
|
193
|
+
noCellsSelected: "No cells selected",
|
|
194
|
+
},
|
|
195
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Menu } from "./Menu.svelte";
|
|
2
|
+
export { default as Open } from "./Open.svelte";
|
|
3
|
+
export { default as Sheet } from "./Sheet.svelte";
|
|
4
|
+
export { default as Toolbar } from "./Toolbar.svelte";
|
|
5
|
+
export * from "./actions/index.js";
|
|
6
|
+
export * from "./utilities.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Menu } from "./Menu.svelte";
|
|
2
|
+
export { default as Open } from "./Open.svelte";
|
|
3
|
+
export { default as Sheet } from "./Sheet.svelte";
|
|
4
|
+
export { default as Toolbar } from "./Toolbar.svelte";
|
|
5
|
+
export * from "./actions/index.js";
|
|
6
|
+
export * from "./utilities.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as XLSX from "xlsx";
|
|
2
|
+
export declare const computeStyles: (c: any, r: any, row: any, style: any, options: any, value: any, nextValue: any) => string;
|
|
3
|
+
export declare function GetCellByAddress(map: any, c: any, r: any): any;
|
|
4
|
+
export declare function GetColSpan(map: any, c: any, r: any): any;
|
|
5
|
+
export declare function GetRowSpan(map: any, c: any, r: any): any;
|
|
6
|
+
export declare function download(sheets: any[], fileName: string): Promise<void>;
|
|
7
|
+
export declare function upload(sheets: any[], uploadURL: string): Promise<Error[]>;
|
|
8
|
+
export declare function removeColumns(selection: XLSX.CellAddress[], data: any[][]): any[][];
|
|
9
|
+
export declare function removeRows(selection: XLSX.CellAddress[], data: any[][]): any[][];
|
|
10
|
+
export declare function pasteSelection(data: any, pasted: [string, string], selected: [string, string]): any;
|
|
11
|
+
export declare function clearSelection(data: any, selected: [string, string]): any;
|
|
12
|
+
export declare function deleteSelection(data: any, selected: [string, string]): any;
|
|
13
|
+
export declare function mergeSelectExtends(data: any[][], selected: [string, string], extended: [string, string]): any[][];
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as XLSX from "xlsx";
|
|
11
|
+
import btob from "b64-to-blob";
|
|
12
|
+
function getRowHeight(row) {
|
|
13
|
+
var _a;
|
|
14
|
+
try {
|
|
15
|
+
const height = Number(typeof (row === null || row === void 0 ? void 0 : row.height) == "string"
|
|
16
|
+
? (_a = row === null || row === void 0 ? void 0 : row.height) === null || _a === void 0 ? void 0 : _a.replace("px", "")
|
|
17
|
+
: (row === null || row === void 0 ? void 0 : row.height) || 24);
|
|
18
|
+
return height > 24 ? height : 24;
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return 24;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const computeStyles = (c, r, row, style, options, value, nextValue) => {
|
|
25
|
+
// ${
|
|
26
|
+
// c.wordWrap != false &&
|
|
27
|
+
// (options.wordWrap || c.wordwrap || value?.length > 200)
|
|
28
|
+
// ? "white-space: pre-wrap;"
|
|
29
|
+
// : ""
|
|
30
|
+
// }
|
|
31
|
+
return `text-align: ${c.align || "center"};
|
|
32
|
+
height: ${getRowHeight(row)}px;
|
|
33
|
+
overflow: ${nextValue && nextValue.length ? "hidden" : "visible"};
|
|
34
|
+
${style[XLSX.utils.encode_cell({ c, r })]};
|
|
35
|
+
`;
|
|
36
|
+
};
|
|
37
|
+
export function GetCellByAddress(map, c, r) {
|
|
38
|
+
return map[XLSX.utils.encode_cell({
|
|
39
|
+
c,
|
|
40
|
+
r,
|
|
41
|
+
})];
|
|
42
|
+
}
|
|
43
|
+
export function GetColSpan(map, c, r) {
|
|
44
|
+
return ((GetCellByAddress(map, c, r) && GetCellByAddress(map, c, r)[0]) || undefined);
|
|
45
|
+
}
|
|
46
|
+
export function GetRowSpan(map, c, r) {
|
|
47
|
+
return ((GetCellByAddress(map, c, r) && GetCellByAddress(map, c, r)[1]) || undefined);
|
|
48
|
+
}
|
|
49
|
+
export function download(sheets, fileName) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const wb = XLSX.utils.book_new();
|
|
52
|
+
const wss = [];
|
|
53
|
+
sheets.map((s, i) => {
|
|
54
|
+
const ws = XLSX.utils.aoa_to_sheet(s.data);
|
|
55
|
+
XLSX.utils.book_append_sheet(wb, ws, s.sheetName);
|
|
56
|
+
});
|
|
57
|
+
XLSX.writeFile(wb, fileName);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function upload(sheets, uploadURL) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (!sheets)
|
|
63
|
+
return;
|
|
64
|
+
const wb = XLSX.utils.book_new();
|
|
65
|
+
sheets.map((s, i) => {
|
|
66
|
+
const ws = XLSX.utils.aoa_to_sheet(s.data);
|
|
67
|
+
XLSX.utils.book_append_sheet(wb, ws, s.sheetName);
|
|
68
|
+
});
|
|
69
|
+
const wbout = XLSX.write(wb, {
|
|
70
|
+
bookType: "xlsx",
|
|
71
|
+
bookSST: false,
|
|
72
|
+
type: "base64",
|
|
73
|
+
});
|
|
74
|
+
const formData = new FormData();
|
|
75
|
+
formData.append("file", btob(wbout, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), "test.xlsx");
|
|
76
|
+
const req = yield fetch(uploadURL, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
body: formData,
|
|
79
|
+
});
|
|
80
|
+
if (req.status == 400) {
|
|
81
|
+
const res = yield req.json(); // res contains the list of errors
|
|
82
|
+
return res;
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Return bottomRight, and topLeft border for one selection
|
|
88
|
+
function getBorder(selection) {
|
|
89
|
+
const br = {
|
|
90
|
+
c: selection[0].c > selection[1].c ? selection[0].c : selection[1].c,
|
|
91
|
+
r: selection[0].r > selection[1].r ? selection[0].r : selection[1].r,
|
|
92
|
+
};
|
|
93
|
+
const tl = {
|
|
94
|
+
c: selection[0].c < selection[1].c ? selection[0].c : selection[1].c,
|
|
95
|
+
r: selection[0].r < selection[1].r ? selection[0].r : selection[1].r,
|
|
96
|
+
};
|
|
97
|
+
return { tl, br };
|
|
98
|
+
}
|
|
99
|
+
export function removeColumns(selection, data) {
|
|
100
|
+
const { tl, br } = getBorder(selection);
|
|
101
|
+
return data.map((d) => d.filter((_, i) => !(i >= tl.c && i <= br.c)));
|
|
102
|
+
}
|
|
103
|
+
export function removeRows(selection, data) {
|
|
104
|
+
const { tl, br } = getBorder(selection);
|
|
105
|
+
return data.filter((d, i) => !(i >= tl.c && i <= br.c));
|
|
106
|
+
}
|
|
107
|
+
function decode(address) {
|
|
108
|
+
return [
|
|
109
|
+
XLSX.utils.decode_cell(address[0]),
|
|
110
|
+
XLSX.utils.decode_cell(address[1]),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
export function pasteSelection(data, pasted, selected) {
|
|
114
|
+
const dpaste = getBorder(decode(pasted));
|
|
115
|
+
const dselect = getBorder(decode(selected));
|
|
116
|
+
const dx = dselect.tl.c - dpaste.tl.c;
|
|
117
|
+
const dy = dselect.tl.r - dpaste.tl.r;
|
|
118
|
+
console.log(dx, dy);
|
|
119
|
+
for (var r = dpaste.tl.r; r <= dpaste.br.r; r++) {
|
|
120
|
+
for (var c = dpaste.tl.c; c <= dpaste.br.c; c++) {
|
|
121
|
+
if (data.length - 1 < r + dy) {
|
|
122
|
+
data = [...data, Array.from({ length: r + dy - data.length + 1 })];
|
|
123
|
+
}
|
|
124
|
+
data[r + dy][c + dx] = data[r][c];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
export function clearSelection(data, selected) {
|
|
130
|
+
console.log("clear");
|
|
131
|
+
const dselect = getBorder(decode(selected));
|
|
132
|
+
for (var r = dselect.tl.r; r <= dselect.br.r; r++) {
|
|
133
|
+
for (var c = dselect.tl.c; c <= dselect.br.c; c++) {
|
|
134
|
+
if (data.length - 1 < r)
|
|
135
|
+
return;
|
|
136
|
+
data[r][c] = "";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return data;
|
|
140
|
+
}
|
|
141
|
+
export function deleteSelection(data, selected) {
|
|
142
|
+
const dselect = getBorder(decode(selected));
|
|
143
|
+
if (dselect.br.c == data[0].length - 1) {
|
|
144
|
+
// delete rows
|
|
145
|
+
data = data.filter((v, i) => {
|
|
146
|
+
return i < dselect.tl.r || i > dselect.br.r;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (dselect.br.r == data.length - 1) {
|
|
150
|
+
// delete columns
|
|
151
|
+
console.log("delete columns");
|
|
152
|
+
data = data.map((c) => c.filter((v, i) => {
|
|
153
|
+
return i < dselect.tl.c || i > dselect.br.c;
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
return data;
|
|
157
|
+
}
|
|
158
|
+
export function mergeSelectExtends(data, selected, extended) {
|
|
159
|
+
// merge logic here...
|
|
160
|
+
const sel = getBorder(decode(selected));
|
|
161
|
+
const ext = getBorder(decode(extended));
|
|
162
|
+
// if extended is inside selected
|
|
163
|
+
if (ext.tl.c >= sel.tl.c &&
|
|
164
|
+
ext.br.c <= sel.br.c &&
|
|
165
|
+
ext.tl.r >= sel.tl.r &&
|
|
166
|
+
ext.br.r <= sel.br.r) {
|
|
167
|
+
// every cells outside ext and inside sel are emptied
|
|
168
|
+
for (var c = sel.tl.c; c <= sel.br.c; c++) {
|
|
169
|
+
for (var r = sel.tl.r; r <= sel.br.r; r++) {
|
|
170
|
+
// if the cell is outside extended and inside selected erase it
|
|
171
|
+
if (c > ext.br.c || r > ext.br.r) {
|
|
172
|
+
data[r][c] = "";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// extended extend the selection
|
|
179
|
+
// for all cells outside selection
|
|
180
|
+
for (var c = ext.tl.c; c <= ext.br.c; c++) {
|
|
181
|
+
for (var r = ext.tl.r; r <= ext.br.r; r++) {
|
|
182
|
+
const brsel = { c: sel.br.c + 1, r: sel.br.r + 1 };
|
|
183
|
+
const selwidth = brsel.c - sel.tl.c;
|
|
184
|
+
const selheight = brsel.r - sel.tl.r;
|
|
185
|
+
if (c < sel.tl.c) {
|
|
186
|
+
// cell is on the left
|
|
187
|
+
data[r][c] =
|
|
188
|
+
data[r][sel.br.c - (Math.abs(c - sel.tl.c + 1) % selwidth)];
|
|
189
|
+
}
|
|
190
|
+
if (c > sel.br.c) {
|
|
191
|
+
// cell is on the right
|
|
192
|
+
data[r][c] = data[r][sel.tl.c + ((c - sel.br.c - 1) % selwidth)];
|
|
193
|
+
}
|
|
194
|
+
// if extended to unknown rows territory
|
|
195
|
+
if (data.length - 1 < r) {
|
|
196
|
+
data = [...data, Array.from({ length: r - data.length + 1 })];
|
|
197
|
+
}
|
|
198
|
+
if (r < sel.tl.r) {
|
|
199
|
+
// cell is on top
|
|
200
|
+
data[r][c] =
|
|
201
|
+
data[sel.br.r - (Math.abs(r - sel.tl.r + 1) % selheight)][c];
|
|
202
|
+
}
|
|
203
|
+
if (r > sel.br.r) {
|
|
204
|
+
// cell is below
|
|
205
|
+
data[r][c] = data[sel.tl.r + ((r - sel.br.r - 1) % selheight)][c];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chalabi/svelte-sheets",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Run your excel sheet in the browser!",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"dev": "vite dev",
|
|
10
|
+
"package": "svelte-package",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"prepare": "svelte-kit sync",
|
|
13
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
14
|
+
"test": "vitest run"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"svelte",
|
|
18
|
+
"xlsx",
|
|
19
|
+
"excel",
|
|
20
|
+
"spreadsheets"
|
|
21
|
+
],
|
|
22
|
+
"author": "Thibaut Duchêne",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/chalabi2/svelte-sheets.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/chalabi2/svelte-sheets/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/chalabi2/svelte-sheets#readme",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@sveltejs/adapter-auto": "^7.0.0",
|
|
34
|
+
"@sveltejs/adapter-static": "^3.0.10",
|
|
35
|
+
"@sveltejs/kit": "^2.50.1",
|
|
36
|
+
"@sveltejs/package": "^2.5.7",
|
|
37
|
+
"@tsconfig/svelte": "^3.0.0",
|
|
38
|
+
"prettier": "^3.8.1",
|
|
39
|
+
"prettier-plugin-svelte": "^3.4.1",
|
|
40
|
+
"svelte": "^5.48.5",
|
|
41
|
+
"svelte-check": "^4.3.5",
|
|
42
|
+
"svelte-preprocess": "^6.0.3",
|
|
43
|
+
"svelte2tsx": "^0.7.46",
|
|
44
|
+
"tslib": "^2.8.1",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vite": "^7.3.1",
|
|
47
|
+
"vitest": "^4.0.18"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"b64-to-blob": "^1.2.19",
|
|
51
|
+
"hotkeys-js": "^4.0.0",
|
|
52
|
+
"svelte": "^5.48.5",
|
|
53
|
+
"xlsx": "^0.18.5"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"b64-to-blob": "^1.2.19",
|
|
57
|
+
"hotkeys-js": "^4.0.0",
|
|
58
|
+
"xlsx": "^0.18.5"
|
|
59
|
+
},
|
|
60
|
+
"type": "module",
|
|
61
|
+
"files": [
|
|
62
|
+
"dist"
|
|
63
|
+
],
|
|
64
|
+
"exports": {
|
|
65
|
+
".": {
|
|
66
|
+
"types": "./dist/index.d.ts",
|
|
67
|
+
"svelte": "./dist/index.js",
|
|
68
|
+
"browser": "./dist/index.js",
|
|
69
|
+
"default": "./dist/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./Menu.svelte": {
|
|
72
|
+
"types": "./dist/Menu.svelte.d.ts",
|
|
73
|
+
"svelte": "./dist/Menu.svelte",
|
|
74
|
+
"default": "./dist/Menu.svelte"
|
|
75
|
+
},
|
|
76
|
+
"./Open.svelte": {
|
|
77
|
+
"types": "./dist/Open.svelte.d.ts",
|
|
78
|
+
"svelte": "./dist/Open.svelte",
|
|
79
|
+
"default": "./dist/Open.svelte"
|
|
80
|
+
},
|
|
81
|
+
"./Sheet.svelte": {
|
|
82
|
+
"types": "./dist/Sheet.svelte.d.ts",
|
|
83
|
+
"svelte": "./dist/Sheet.svelte",
|
|
84
|
+
"default": "./dist/Sheet.svelte"
|
|
85
|
+
},
|
|
86
|
+
"./Toolbar.svelte": {
|
|
87
|
+
"types": "./dist/Toolbar.svelte.d.ts",
|
|
88
|
+
"svelte": "./dist/Toolbar.svelte",
|
|
89
|
+
"default": "./dist/Toolbar.svelte"
|
|
90
|
+
},
|
|
91
|
+
"./actions": {
|
|
92
|
+
"types": "./dist/actions/index.d.ts",
|
|
93
|
+
"svelte": "./dist/actions/index.js",
|
|
94
|
+
"default": "./dist/actions/index.js"
|
|
95
|
+
},
|
|
96
|
+
"./actions/copypaste": {
|
|
97
|
+
"types": "./dist/actions/copypaste.d.ts",
|
|
98
|
+
"svelte": "./dist/actions/copypaste.js",
|
|
99
|
+
"default": "./dist/actions/copypaste.js"
|
|
100
|
+
},
|
|
101
|
+
"./actions/draggable": {
|
|
102
|
+
"types": "./dist/actions/draggable.d.ts",
|
|
103
|
+
"svelte": "./dist/actions/draggable.js",
|
|
104
|
+
"default": "./dist/actions/draggable.js"
|
|
105
|
+
},
|
|
106
|
+
"./actions/resizable": {
|
|
107
|
+
"types": "./dist/actions/resizable.d.ts",
|
|
108
|
+
"svelte": "./dist/actions/resizable.js",
|
|
109
|
+
"default": "./dist/actions/resizable.js"
|
|
110
|
+
},
|
|
111
|
+
"./actions/rightclick": {
|
|
112
|
+
"types": "./dist/actions/rightclick.d.ts",
|
|
113
|
+
"svelte": "./dist/actions/rightclick.js",
|
|
114
|
+
"default": "./dist/actions/rightclick.js"
|
|
115
|
+
},
|
|
116
|
+
"./actions/selected": {
|
|
117
|
+
"types": "./dist/actions/selected.d.ts",
|
|
118
|
+
"svelte": "./dist/actions/selected.js",
|
|
119
|
+
"default": "./dist/actions/selected.js"
|
|
120
|
+
},
|
|
121
|
+
"./convert": {
|
|
122
|
+
"types": "./dist/convert.d.ts",
|
|
123
|
+
"svelte": "./dist/convert.js",
|
|
124
|
+
"default": "./dist/convert.js"
|
|
125
|
+
},
|
|
126
|
+
"./defaultconfig": {
|
|
127
|
+
"types": "./dist/defaultconfig.d.ts",
|
|
128
|
+
"svelte": "./dist/defaultconfig.js",
|
|
129
|
+
"default": "./dist/defaultconfig.js"
|
|
130
|
+
},
|
|
131
|
+
"./utilities": {
|
|
132
|
+
"types": "./dist/utilities.d.ts",
|
|
133
|
+
"svelte": "./dist/utilities.js",
|
|
134
|
+
"default": "./dist/utilities.js"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"svelte": "./dist/index.js",
|
|
138
|
+
"browser": "./dist/index.js",
|
|
139
|
+
"sideEffects": [
|
|
140
|
+
"**/*.css"
|
|
141
|
+
],
|
|
142
|
+
"publishConfig": {
|
|
143
|
+
"access": "public"
|
|
144
|
+
},
|
|
145
|
+
"typesVersions": {
|
|
146
|
+
">4.0": {
|
|
147
|
+
"index": [
|
|
148
|
+
"./dist/index.d.ts"
|
|
149
|
+
],
|
|
150
|
+
"Menu.svelte": [
|
|
151
|
+
"./dist/Menu.svelte.d.ts"
|
|
152
|
+
],
|
|
153
|
+
"Open.svelte": [
|
|
154
|
+
"./dist/Open.svelte.d.ts"
|
|
155
|
+
],
|
|
156
|
+
"Sheet.svelte": [
|
|
157
|
+
"./dist/Sheet.svelte.d.ts"
|
|
158
|
+
],
|
|
159
|
+
"Toolbar.svelte": [
|
|
160
|
+
"./dist/Toolbar.svelte.d.ts"
|
|
161
|
+
],
|
|
162
|
+
"actions": [
|
|
163
|
+
"./dist/actions/index.d.ts"
|
|
164
|
+
],
|
|
165
|
+
"actions/*": [
|
|
166
|
+
"./dist/actions/*"
|
|
167
|
+
],
|
|
168
|
+
"convert": [
|
|
169
|
+
"./dist/convert.d.ts"
|
|
170
|
+
],
|
|
171
|
+
"defaultconfig": [
|
|
172
|
+
"./dist/defaultconfig.d.ts"
|
|
173
|
+
],
|
|
174
|
+
"utilities": [
|
|
175
|
+
"./dist/utilities.d.ts"
|
|
176
|
+
],
|
|
177
|
+
"*": [
|
|
178
|
+
"./dist/*"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|