@newview/ui 1.1.39 → 1.1.41

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ### 1.1.40
2
+ 1、优化LuckySheet 从Excel导入后,预览边框不显示问题。
3
+ 2、优化LuckySheet 获取行数、列数API逻辑
4
+ 3、优化LuckySheet 获取行高、列框API逻辑
5
+
6
+ ### 1.1.40
7
+ 1、LuckySheet 从Excel导入后,预览边框不显示问题。
8
+
1
9
  ### 1.1.39
2
10
  1、UploadFileList 新增分页控制
3
11
 
@@ -184006,6 +184006,11 @@ var HtmlBase$1 = (
184006
184006
  1: "left",
184007
184007
  2: "right"
184008
184008
  };
184009
+ this.textVHAlign = {
184010
+ 0: "center",
184011
+ 1: "start",
184012
+ 2: "end"
184013
+ };
184009
184014
  this.defaultColWidth = 72;
184010
184015
  this.defaultRowHeight = 17;
184011
184016
  }
@@ -184036,12 +184041,13 @@ var HtmlBase$1 = (
184036
184041
  this.setCss(style2, "font-weight", objValue.bl == 1 ? "bold" : "normal");
184037
184042
  this.setCss(style2, "font-style", objValue.it == 1 ? "italic" : "normal");
184038
184043
  this.setCss(style2, "display", "flex");
184039
- this.setCss(style2, "align-items", "center");
184044
+ this.setCss(style2, "align-items", objValue.vt == void 0 ? "center" : this.textVHAlign[objValue.vt]);
184045
+ this.setCss(style2, "justify-content", objValue.ht == void 0 ? "center" : this.textVHAlign[objValue.ht]);
184046
+ this.setCss(style2, "text-align", objValue.ht == void 0 ? void 0 : this.textAlign[objValue.ht]);
184040
184047
  this.setCss(style2, "font-size", objValue.fs == void 0 ? void 0 : objValue.fs + "pt");
184041
184048
  this.setCss(style2, "line-height", objValue.fs == void 0 ? void 0 : objValue.fs + "pt");
184042
184049
  this.pushTextDecoration(style2, objValue.cl && objValue.cl == 1 ? "line-through" : void 0);
184043
184050
  this.pushTextDecoration(style2, objValue.un && objValue.un == 1 ? "underline" : void 0);
184044
- this.setCss(style2, "text-align", objValue.ht == void 0 ? void 0 : this.textAlign[objValue.ht]);
184045
184051
  this.setCss(style2, "margin", objValue.ht == 0 ? "0px auto" : void 0);
184046
184052
  if (style2["text-decoration"]) {
184047
184053
  style2["text-decoration"] = style2["text-decoration"].join(" ");
@@ -184097,6 +184103,8 @@ var HtmlCells$1 = (
184097
184103
  _this.columnWidths = {};
184098
184104
  _this.tdBorders = {};
184099
184105
  _this.imageDict = {};
184106
+ _this.startTds = {};
184107
+ _this.endTdRightStyle = {};
184100
184108
  _this.verticalAlign = {
184101
184109
  0: "middle",
184102
184110
  1: "top",
@@ -184159,6 +184167,8 @@ var HtmlCells$1 = (
184159
184167
  HtmlCells2.prototype.setMerge = function(td, objValue) {
184160
184168
  if (objValue.mc) {
184161
184169
  td.isMerge = true;
184170
+ td.startRow = objValue.mc.r;
184171
+ td.startCol = objValue.mc.c;
184162
184172
  if (objValue.mc.cs == void 0) {
184163
184173
  td.isRender = false;
184164
184174
  } else {
@@ -184354,6 +184364,25 @@ var HtmlCells$1 = (
184354
184364
  if (!isMerge) {
184355
184365
  tdBorders[key2].right = rightStyle ? rightStyle.borderNumber : 0;
184356
184366
  this.setCss(style2, "border-right", rightStyle ? rightStyle.css : void 0);
184367
+ } else if (!td.isRender) {
184368
+ var startRow = td.startRow;
184369
+ var startCol = td.startCol;
184370
+ var startKey = startRow + "_" + startCol;
184371
+ var startTd = this.tds[startKey];
184372
+ var endRow = startRow + startTd.rowspan - 1;
184373
+ var endCol = startCol + startTd.colspan - 1;
184374
+ if (endRow == border.value.row_index && endCol == border.value.col_index) {
184375
+ tdBorders[startKey] = tdBorders[startKey] || {
184376
+ style: {},
184377
+ left: 0,
184378
+ right: 0,
184379
+ top: 0,
184380
+ bottom: 0
184381
+ };
184382
+ var startStyle = tdBorders[startKey].style;
184383
+ tdBorders[startKey].right = rightStyle ? rightStyle.borderNumber : 0;
184384
+ this.setCss(startStyle, "border-right", rightStyle ? rightStyle.css : void 0);
184385
+ }
184357
184386
  }
184358
184387
  };
184359
184388
  HtmlCells2.prototype.parseTdBorders = function(borderInfo) {
@@ -184371,6 +184400,12 @@ var HtmlCells$1 = (
184371
184400
  }
184372
184401
  return tdBorders;
184373
184402
  };
184403
+ HtmlCells2.prototype.getValue = function(value, styles) {
184404
+ if (styles === void 0) {
184405
+ styles = "";
184406
+ }
184407
+ return value.replace("/ /g", "&nbsp;").replace(/\r\n/g, "<br/>").replace(/\n/g, "<br/>").replace(/{sup}/g, "<sup " + styles + ">").replace(/{\/sup}/g, "</sup>").replace(/{sub}/g, "<sub>").replace(/{\/sub}/g, "</sub>");
184408
+ };
184374
184409
  HtmlCells2.prototype.isImage = function(value) {
184375
184410
  return this.imageDict[value] != void 0;
184376
184411
  };
@@ -184398,12 +184433,6 @@ var HtmlCells$1 = (
184398
184433
  var base64Url = this.imageDict[tdValue.value];
184399
184434
  return "<div " + style2 + '><img src="' + base64Url + '" style="width: 100%; height: 100%; object-fit: contain;" /></div>';
184400
184435
  };
184401
- HtmlCells2.prototype.getValue = function(value, styles) {
184402
- if (styles === void 0) {
184403
- styles = "";
184404
- }
184405
- return value.replace(/\r\n/g, "<br/>").replace(/\n/g, "<br/>").replace(/{sup}/g, "<sup " + styles + ">").replace(/{\/sup}/g, "</sup>").replace(/{sub}/g, "<sub>").replace(/{\/sub}/g, "</sub>");
184406
- };
184407
184436
  HtmlCells2.prototype.countTdStaticSize = function(tdcell, Rindex, Cindex, border) {
184408
184437
  var cellwidth = 0;
184409
184438
  var cellheight = 0;
@@ -184412,12 +184441,12 @@ var HtmlCells$1 = (
184412
184441
  if (tdcell.isMerge) {
184413
184442
  if (xcolwidth && tdcell.colspan) {
184414
184443
  for (var i2 = Cindex; i2 < Cindex + tdcell.colspan; i2++) {
184415
- cellwidth += Number(xcolwidth[i2]);
184444
+ cellwidth += xcolwidth[i2] == void 0 ? this.defaultColWidth : Number(xcolwidth[i2]);
184416
184445
  }
184417
184446
  }
184418
184447
  if (yrowheight && tdcell.rowspan) {
184419
184448
  for (var j2 = Rindex; j2 < Rindex + tdcell.rowspan; j2++) {
184420
- cellheight += Number(yrowheight[j2]);
184449
+ cellheight += yrowheight[j2] == void 0 ? this.defaultRowHeight : Number(yrowheight[j2]);
184421
184450
  }
184422
184451
  }
184423
184452
  } else {
@@ -184556,7 +184585,7 @@ var HtmlCells$1 = (
184556
184585
  style2 = style2.replace("flex", "block");
184557
184586
  return "<div " + style2 + " " + cellid + '><div style="' + transstr + '">' + this.getValue(tdValue.value, 'style="top:0"') + "</div></div>";
184558
184587
  }
184559
- return "<div " + style2 + " " + cellid + '><div style="margin:auto;' + transstr + '">' + this.getValue(tdValue.value, 'style="top:0"') + "</div></div>";
184588
+ return "<div " + style2 + " " + cellid + '><div style="maring:1px auto;' + transstr + '">' + this.getValue(tdValue.value, 'style="top:0"') + "</div></div>";
184560
184589
  };
184561
184590
  HtmlCells2.prototype.getTdContent = function(cellid, td, border, ishidenrow) {
184562
184591
  if (ishidenrow === void 0) {
@@ -184596,7 +184625,7 @@ var HtmlCells$1 = (
184596
184625
  var td = cells.tds[key2];
184597
184626
  var border = cells.borders[key2];
184598
184627
  if (row == 0) {
184599
- var width = this.sheet.config.columnlen ? this.sheet.config.columnlen[col_1] : this.defaultColWidth;
184628
+ var width = this.sheet.config.columnlen && this.sheet.config.columnlen[col_1] != void 0 ? this.sheet.config.columnlen[col_1] : this.defaultColWidth;
184600
184629
  if (!border)
184601
184630
  width++;
184602
184631
  width = ishiddencol ? 0 : width;
@@ -184612,7 +184641,7 @@ var HtmlCells$1 = (
184612
184641
  if (ishidenrow) {
184613
184642
  rowHeight = 0;
184614
184643
  } else {
184615
- rowHeight = this.sheet.config.rowlen ? this.sheet.config.rowlen[row] : this.defaultRowHeight;
184644
+ rowHeight = this.sheet.config.rowlen && this.sheet.config.rowlen[row] != void 0 ? this.sheet.config.rowlen[row] : this.defaultRowHeight;
184616
184645
  rowHeight = rowHeight || this.defaultRowHeight;
184617
184646
  if (rowHeight < 5) {
184618
184647
  rowHeight = 0;
@@ -187889,6 +187918,8 @@ class PrintApi extends BaseInstance {
187889
187918
  const sheetHeight = this.reportApi.sheetApi.getSheetHeight(sheetHandle);
187890
187919
  const countRow = this.reportApi.rowColApi.getRows(sheetHandle);
187891
187920
  const countCol = this.reportApi.rowColApi.getCols(sheetHandle);
187921
+ console.log(countRow, countCol);
187922
+ console.log(sheetWidth, sheetHeight);
187892
187923
  const dh = (a4Height - sheetHeight) / countRow;
187893
187924
  for (let i2 = 0; i2 < countRow - 1; i2++) {
187894
187925
  let height = this.reportApi.rowColApi.getRowHeight(i2, sheetHandle);
@@ -188052,7 +188083,8 @@ class RowColApi extends BaseInstance {
188052
188083
  getColWidth(colIndex, sheetHandle) {
188053
188084
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188054
188085
  const sheet = this.luckysheet.getSheet({ order: cindex });
188055
- let swidth = Number(sheet.config.columnlen[colIndex]);
188086
+ let defaultWidth = this.luckysheet.getDefaultColWidth({ order: cindex });
188087
+ let swidth = !this.utilities.isNull(sheet.config.columnlen[colIndex]) ? Number(sheet.config.columnlen[colIndex]) : defaultWidth;
188056
188088
  return swidth;
188057
188089
  }
188058
188090
  /**
@@ -188079,7 +188111,8 @@ class RowColApi extends BaseInstance {
188079
188111
  getRowHeight(rowIndex, sheetHandle) {
188080
188112
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188081
188113
  const sheet = this.luckysheet.getSheet({ order: cindex });
188082
- let sheight = Number(sheet.config.rowlen[rowIndex]);
188114
+ let defaultHeight = this.luckysheet.getDefaultRowHeight({ order: cindex });
188115
+ let sheight = !this.utilities.isNull(sheet.config.rowlen[rowIndex]) ? Number(sheet.config.rowlen[rowIndex]) : defaultHeight;
188083
188116
  return sheight;
188084
188117
  }
188085
188118
  /**
@@ -188121,26 +188154,39 @@ class RowColApi extends BaseInstance {
188121
188154
  * @param sheetHandle
188122
188155
  */
188123
188156
  getRows(sheetHandle) {
188124
- let config = this.reportApi.sheetApi.getSheetConfig(sheetHandle);
188125
- if (!this.utilities.isNull(config) && !this.utilities.isNull(config.rowlen)) {
188126
- const keys6 = Object.keys(config.rowlen);
188127
- return keys6.length;
188128
- } else {
188129
- return 0;
188157
+ let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188158
+ const datas = this.luckysheet.getSheetData({ order: cindex });
188159
+ let length = 0;
188160
+ if (datas.length == 0) {
188161
+ return length;
188162
+ }
188163
+ console.log(datas.length);
188164
+ for (const row of datas) {
188165
+ const cell = row[0];
188166
+ if (!this.utilities.isNull(cell)) {
188167
+ length++;
188168
+ }
188130
188169
  }
188170
+ return length;
188131
188171
  }
188132
188172
  /**
188133
188173
  * 获取总列数
188134
188174
  * @param sheetHandle
188135
188175
  */
188136
188176
  getCols(sheetHandle) {
188137
- let config = this.reportApi.sheetApi.getSheetConfig(sheetHandle);
188138
- if (!this.utilities.isNull(config) && !this.utilities.isNull(config.columnlen)) {
188139
- const keys6 = Object.keys(config.columnlen);
188140
- return keys6.length;
188141
- } else {
188142
- return 0;
188177
+ let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188178
+ const datas = this.luckysheet.getSheetData({ order: cindex });
188179
+ let length = 0;
188180
+ if (datas.length == 0) {
188181
+ return length;
188182
+ }
188183
+ const row = datas[0];
188184
+ for (const cell of row) {
188185
+ if (!this.utilities.isNull(cell)) {
188186
+ length++;
188187
+ }
188143
188188
  }
188189
+ return length;
188144
188190
  }
188145
188191
  /**
188146
188192
  * 删除行
@@ -188596,8 +188642,10 @@ class SheetApi extends BaseInstance {
188596
188642
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188597
188643
  let xsheet = this.luckysheet.getSheet({ order: cindex });
188598
188644
  let swidth = 0;
188599
- for (let p in xsheet.config.columnlen) {
188600
- swidth += Number(xsheet.config.columnlen[p]);
188645
+ let defaultWidth = this.luckysheet.getDefaultColWidth({ order: cindex });
188646
+ const colCount = this.reportApi.rowColApi.getCols(cindex);
188647
+ for (let col = 0; col < colCount; col++) {
188648
+ swidth += xsheet.config.columnlen && xsheet.config.columnlen[col] != void 0 ? Number(xsheet.config.columnlen[col]) : defaultWidth;
188601
188649
  }
188602
188650
  return swidth + this.reportApi.rowColApi.getCols(cindex);
188603
188651
  }
@@ -188608,8 +188656,10 @@ class SheetApi extends BaseInstance {
188608
188656
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188609
188657
  let xsheet = this.luckysheet.getSheet({ order: cindex });
188610
188658
  let sheight = 0;
188611
- for (let p in xsheet.config.rowlen) {
188612
- sheight += Number(xsheet.config.rowlen[p]);
188659
+ let defaultHeight = this.luckysheet.getDefaultRowHeight({ order: cindex });
188660
+ const rowCount = this.reportApi.rowColApi.getRows(cindex);
188661
+ for (let row = 0; row < rowCount; row++) {
188662
+ sheight += xsheet.config.rowlen && xsheet.config.rowlen[row] != void 0 ? Number(xsheet.config.rowlen[row]) : defaultHeight;
188613
188663
  }
188614
188664
  return sheight + this.reportApi.rowColApi.getRows(cindex);
188615
188665
  }