px-jspreadsheet-ce 0.0.15 → 0.0.16
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/dist/index.d.ts +4 -0
- package/dist/index.js +51 -38
- package/dist/index.js.map +1 -1
- package/dist/jspreadsheet.css +7 -0
- package/package.json +1 -1
- package/src/utils/columns.js +1 -1
- package/src/utils/internal.js +6 -2
- package/src/utils/internalHelpers.js +6 -4
- package/src/utils/rows.js +1 -1
- package/src/utils/worksheets.js +23 -15
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1787,18 +1787,12 @@ const createCell = function (i, j, value) {
|
|
|
1787
1787
|
|
|
1788
1788
|
if (obj.options.freezeRows > j) {
|
|
1789
1789
|
td.classList.add('jss_frozen_row');
|
|
1790
|
-
|
|
1791
|
-
td.classList.add('jss_frozen_row_edge');
|
|
1792
|
-
}
|
|
1793
|
-
td.style.top = (0,_internalHelpers_js__WEBPACK_IMPORTED_MODULE_7__/* .getFreezeRowTop */ .bI)(j, obj.options.rows, obj.options.defaultRowHeight);
|
|
1790
|
+
td.style.top = (0,_internalHelpers_js__WEBPACK_IMPORTED_MODULE_7__/* .getFreezeRowTop */ .bI)(j, obj.options);
|
|
1794
1791
|
}
|
|
1795
1792
|
|
|
1796
1793
|
if (obj.options.freezeColumns > i) {
|
|
1797
1794
|
td.classList.add('jss_frozen');
|
|
1798
|
-
|
|
1799
|
-
td.classList.add('jss_frozen_edge');
|
|
1800
|
-
}
|
|
1801
|
-
td.style.left = (0,_internalHelpers_js__WEBPACK_IMPORTED_MODULE_7__/* .getFreezeColumnLeft */ .FD)(i, obj.options.columns, obj.options.defaultColWidth);
|
|
1795
|
+
td.style.left = (0,_internalHelpers_js__WEBPACK_IMPORTED_MODULE_7__/* .getFreezeColumnLeft */ .FD)(i, obj.options);
|
|
1802
1796
|
}
|
|
1803
1797
|
|
|
1804
1798
|
// Text align
|
|
@@ -1807,7 +1801,8 @@ const createCell = function (i, j, value) {
|
|
|
1807
1801
|
|
|
1808
1802
|
// Wrap option
|
|
1809
1803
|
if ((!config || config.wordWrap != false) && (obj.options.wordWrap == true || (config && config.wordWrap == true) || td.innerHTML.length > 200)) {
|
|
1810
|
-
td.style.
|
|
1804
|
+
td.style.overflowWrap = 'break-word';
|
|
1805
|
+
td.style.whiteSpace = 'normal';
|
|
1811
1806
|
}
|
|
1812
1807
|
|
|
1813
1808
|
// Overflow
|
|
@@ -1990,7 +1985,10 @@ const updateCell = function (x, y, value, force) {
|
|
|
1990
1985
|
}
|
|
1991
1986
|
|
|
1992
1987
|
// On change
|
|
1993
|
-
|
|
1988
|
+
if (!obj.createTableProcess) {
|
|
1989
|
+
obj.records[y][x].element.classList.add('jss_updated');
|
|
1990
|
+
_dispatch_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.call(obj, 'onchange', obj, obj.records[y] && obj.records[y][x] ? obj.records[y][x].element : null, x, y, value, record.oldValue);
|
|
1991
|
+
}
|
|
1994
1992
|
}
|
|
1995
1993
|
|
|
1996
1994
|
return record;
|
|
@@ -2538,6 +2536,9 @@ const createNestedHeader = function (nestedInformation) {
|
|
|
2538
2536
|
if (!nestedInformation[i].colspan) {
|
|
2539
2537
|
nestedInformation[i].colspan = 1;
|
|
2540
2538
|
}
|
|
2539
|
+
if (!nestedInformation[i].rowspan) {
|
|
2540
|
+
nestedInformation[i].rowspan = 1;
|
|
2541
|
+
}
|
|
2541
2542
|
if (!nestedInformation[i].title) {
|
|
2542
2543
|
nestedInformation[i].title = '';
|
|
2543
2544
|
}
|
|
@@ -2563,6 +2564,7 @@ const createNestedHeader = function (nestedInformation) {
|
|
|
2563
2564
|
const td = document.createElement('td');
|
|
2564
2565
|
td.setAttribute('data-column', column.join(','));
|
|
2565
2566
|
td.setAttribute('colspan', nestedInformation[i].colspan);
|
|
2567
|
+
td.setAttribute('rowspan', nestedInformation[i].rowspan);
|
|
2566
2568
|
td.setAttribute('align', nestedInformation[i].align || 'center');
|
|
2567
2569
|
td.setAttribute('id', nestedInformation[i].id);
|
|
2568
2570
|
td.textContent = nestedInformation[i].title;
|
|
@@ -3548,8 +3550,9 @@ const getColumnNameFromId = function (cellId) {
|
|
|
3548
3550
|
* 获取静态的左侧距离
|
|
3549
3551
|
*
|
|
3550
3552
|
*/
|
|
3551
|
-
const getFreezeColumnLeft = function (colNumber,
|
|
3552
|
-
|
|
3553
|
+
const getFreezeColumnLeft = function (colNumber, options) {
|
|
3554
|
+
const { columns, defaultColWidth: defaultWidth, hiddenIndex } = options;
|
|
3555
|
+
let left = hiddenIndex ? 0 : 50; // 距离左侧的位置
|
|
3553
3556
|
while (colNumber > 0) {
|
|
3554
3557
|
const obj = columns[colNumber - 1]; // 左侧单元格
|
|
3555
3558
|
if (obj.type !== 'hidden') {
|
|
@@ -3560,8 +3563,9 @@ const getFreezeColumnLeft = function (colNumber, columns, defaultWidth) {
|
|
|
3560
3563
|
return left + 'px';
|
|
3561
3564
|
};
|
|
3562
3565
|
|
|
3563
|
-
const getFreezeRowTop = function (rowNumber,
|
|
3564
|
-
|
|
3566
|
+
const getFreezeRowTop = function (rowNumber, options) {
|
|
3567
|
+
const { rows, defaultRowHeight: defaultHeight, hiddenColumnLabel } = options;
|
|
3568
|
+
let top = hiddenColumnLabel ? 0 : 30; // 距离顶部的位置
|
|
3565
3569
|
while (rowNumber > 0) {
|
|
3566
3570
|
const obj = rows[rowNumber - 1]; // 左侧单元格
|
|
3567
3571
|
top += parseInt(obj.height || defaultHeight);
|
|
@@ -5034,6 +5038,7 @@ const openEditor = function (cell, empty, e) {
|
|
|
5034
5038
|
editor.style.minHeight = info.height - 2 + 'px';
|
|
5035
5039
|
|
|
5036
5040
|
// Edit cell
|
|
5041
|
+
cell.classList.remove('jss_updated');
|
|
5037
5042
|
cell.classList.add('editor');
|
|
5038
5043
|
cell.innerHTML = '';
|
|
5039
5044
|
cell.appendChild(editor);
|
|
@@ -5059,6 +5064,7 @@ const openEditor = function (cell, empty, e) {
|
|
|
5059
5064
|
if (config && typeof config.type === 'object') {
|
|
5060
5065
|
// Custom editors
|
|
5061
5066
|
config.type.openEditor(cell, obj.options.data[y][x], parseInt(x), parseInt(y), obj, config, e);
|
|
5067
|
+
cell.classList.remove('jss_updated');
|
|
5062
5068
|
|
|
5063
5069
|
// On edition start
|
|
5064
5070
|
utils_dispatch/* default */.A.call(obj, 'oncreateeditor', obj, cell, parseInt(x), parseInt(y), null, config);
|
|
@@ -6346,10 +6352,7 @@ const createCellHeader = function (colNumber) {
|
|
|
6346
6352
|
// 表头冻结
|
|
6347
6353
|
if (obj.options.freezeColumns > colNumber) {
|
|
6348
6354
|
obj.headers[colNumber].classList.add('jss_frozen');
|
|
6349
|
-
|
|
6350
|
-
obj.headers[colNumber].classList.add('jss_frozen_edge');
|
|
6351
|
-
}
|
|
6352
|
-
obj.headers[colNumber].style.left = (0,internalHelpers/* getFreezeColumnLeft */.FD)(colNumber, obj.options.columns, obj.options.defaultColWidth);
|
|
6355
|
+
obj.headers[colNumber].style.left = (0,internalHelpers/* getFreezeColumnLeft */.FD)(colNumber, obj.options);
|
|
6353
6356
|
}
|
|
6354
6357
|
|
|
6355
6358
|
// Width control
|
|
@@ -7094,10 +7097,7 @@ const createRow = function (j, data) {
|
|
|
7094
7097
|
// freeze rows
|
|
7095
7098
|
if (obj.options.freezeRows > j) {
|
|
7096
7099
|
td.classList.add('jss_frozen_row');
|
|
7097
|
-
|
|
7098
|
-
td.classList.add('jss_frozen_row_edge');
|
|
7099
|
-
}
|
|
7100
|
-
td.style.top = (0,internalHelpers/* getFreezeRowTop */.bI)(j, obj.options.rows, obj.options.defaultRowHeight);
|
|
7100
|
+
td.style.top = (0,internalHelpers/* getFreezeRowTop */.bI)(j, obj.options);
|
|
7101
7101
|
}
|
|
7102
7102
|
row.element.appendChild(td);
|
|
7103
7103
|
|
|
@@ -10307,6 +10307,8 @@ const setWorksheetFunctions = function (worksheet) {
|
|
|
10307
10307
|
}
|
|
10308
10308
|
};
|
|
10309
10309
|
|
|
10310
|
+
const rowIndexWidth = 50;
|
|
10311
|
+
|
|
10310
10312
|
const createTable = function () {
|
|
10311
10313
|
let obj = this;
|
|
10312
10314
|
|
|
@@ -10382,17 +10384,18 @@ const createTable = function () {
|
|
|
10382
10384
|
// Colsgroup
|
|
10383
10385
|
obj.colgroupContainer = document.createElement('colgroup');
|
|
10384
10386
|
let tempCol = document.createElement('col');
|
|
10385
|
-
tempCol.setAttribute('width',
|
|
10387
|
+
tempCol.setAttribute('width', rowIndexWidth);
|
|
10386
10388
|
obj.colgroupContainer.appendChild(tempCol);
|
|
10387
10389
|
|
|
10388
10390
|
// Nested
|
|
10389
10391
|
if (obj.options.nestedHeaders && obj.options.nestedHeaders.length > 0 && obj.options.nestedHeaders[0] && obj.options.nestedHeaders[0][0]) {
|
|
10390
10392
|
for (let j = 0; j < obj.options.nestedHeaders.length; j++) {
|
|
10391
|
-
|
|
10393
|
+
const nestedHeader = internal/* createNestedHeader */.ju.call(obj, obj.options.nestedHeaders[j]);
|
|
10394
|
+
obj.thead.appendChild(nestedHeader);
|
|
10392
10395
|
}
|
|
10393
10396
|
}
|
|
10394
10397
|
|
|
10395
|
-
// Row
|
|
10398
|
+
// Header Row
|
|
10396
10399
|
obj.headerContainer = document.createElement('tr');
|
|
10397
10400
|
tempCol = document.createElement('td');
|
|
10398
10401
|
tempCol.classList.add('jss_selectall');
|
|
@@ -10408,6 +10411,10 @@ const createTable = function () {
|
|
|
10408
10411
|
obj.colgroupContainer.appendChild(obj.cols[i].colElement);
|
|
10409
10412
|
}
|
|
10410
10413
|
|
|
10414
|
+
if (obj.options.hiddenColumnLabel) {
|
|
10415
|
+
obj.headerContainer.style.visibility = 'collapse';
|
|
10416
|
+
}
|
|
10417
|
+
|
|
10411
10418
|
obj.thead.appendChild(obj.headerContainer);
|
|
10412
10419
|
|
|
10413
10420
|
// Filters
|
|
@@ -10433,6 +10440,7 @@ const createTable = function () {
|
|
|
10433
10440
|
// Content table
|
|
10434
10441
|
// obj.table = document.createElement('table');
|
|
10435
10442
|
obj.table.classList.add('jss_worksheet');
|
|
10443
|
+
if (obj.options.hiddenIndex) obj.table.classList.add('jss_hidden_index');
|
|
10436
10444
|
obj.table.setAttribute('cellpadding', '0');
|
|
10437
10445
|
obj.table.setAttribute('cellspacing', '0');
|
|
10438
10446
|
obj.table.setAttribute('unselectable', 'yes');
|
|
@@ -10516,18 +10524,18 @@ const createTable = function () {
|
|
|
10516
10524
|
}
|
|
10517
10525
|
|
|
10518
10526
|
// Actions
|
|
10519
|
-
if (obj.options.columnDrag != false) {
|
|
10520
|
-
|
|
10521
|
-
}
|
|
10522
|
-
if (obj.options.columnResize != false) {
|
|
10523
|
-
|
|
10524
|
-
}
|
|
10525
|
-
if (obj.options.rowDrag != false) {
|
|
10526
|
-
|
|
10527
|
-
}
|
|
10528
|
-
if (obj.options.rowResize != false) {
|
|
10529
|
-
|
|
10530
|
-
}
|
|
10527
|
+
// if (obj.options.columnDrag != false) {
|
|
10528
|
+
// obj.thead.classList.add('draggable');
|
|
10529
|
+
// }
|
|
10530
|
+
// if (obj.options.columnResize != false) {
|
|
10531
|
+
// obj.thead.classList.add('resizable');
|
|
10532
|
+
// }
|
|
10533
|
+
// if (obj.options.rowDrag != false) {
|
|
10534
|
+
// obj.tbody.classList.add('draggable');
|
|
10535
|
+
// }
|
|
10536
|
+
// if (obj.options.rowResize != false) {
|
|
10537
|
+
// obj.tbody.classList.add('resizable');
|
|
10538
|
+
// }
|
|
10531
10539
|
|
|
10532
10540
|
// Load data
|
|
10533
10541
|
obj.setData.call(obj);
|
|
@@ -10740,6 +10748,7 @@ const worksheets_buildWorksheet = async function () {
|
|
|
10740
10748
|
}
|
|
10741
10749
|
|
|
10742
10750
|
utils_libraryBase.jspreadsheet.current = obj;
|
|
10751
|
+
obj.createTableProcess = true;
|
|
10743
10752
|
// prepareTable
|
|
10744
10753
|
const promises = [];
|
|
10745
10754
|
|
|
@@ -10807,9 +10816,11 @@ const worksheets_buildWorksheet = async function () {
|
|
|
10807
10816
|
} else {
|
|
10808
10817
|
// Prepare table
|
|
10809
10818
|
prepareTable.call(obj);
|
|
10819
|
+
obj.createTableProcess = false;
|
|
10810
10820
|
}
|
|
10811
10821
|
|
|
10812
10822
|
await Promise.all(promises);
|
|
10823
|
+
obj.createTableProcess = false;
|
|
10813
10824
|
|
|
10814
10825
|
if (typeof spreadsheet.plugins === 'object') {
|
|
10815
10826
|
Object.entries(spreadsheet.plugins).forEach(function ([, plugin]) {
|
|
@@ -10923,13 +10934,15 @@ const updateWorksheet = function (options) {
|
|
|
10923
10934
|
|
|
10924
10935
|
obj.element.removeChild(obj.content);
|
|
10925
10936
|
obj.element.removeChild(obj.pagination);
|
|
10926
|
-
obj.element.removeChild(obj.ads);
|
|
10927
10937
|
|
|
10928
10938
|
obj.options = options;
|
|
10929
10939
|
obj.history = [];
|
|
10930
10940
|
obj.historyIndex = -1;
|
|
10941
|
+
|
|
10931
10942
|
// Prepare table
|
|
10943
|
+
obj.createTableProcess = true;
|
|
10932
10944
|
prepareTable.call(obj);
|
|
10945
|
+
obj.createTableProcess = false;
|
|
10933
10946
|
};
|
|
10934
10947
|
|
|
10935
10948
|
const worksheetPublicMethods = [
|