@fileverse-dev/fortune-core 1.1.90 → 1.1.92

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/es/api/rowcol.js CHANGED
@@ -112,6 +112,7 @@ export function setRowHeight(ctx, rowInfo, options, custom) {
112
112
  throw INVALID_PARAMS;
113
113
  }
114
114
  var sheet = getSheet(ctx, options);
115
+ console.log("sheet=======", sheet);
115
116
  var cfg = sheet.config || {};
116
117
  if (cfg.rowlen == null) {
117
118
  cfg.rowlen = {};
package/es/canvas.js CHANGED
@@ -2,6 +2,7 @@ import _ from "lodash";
2
2
  import { getFlowdata } from "./context";
3
3
  import { getRealCellValue, normalizedAttr } from "./modules/cell";
4
4
  import { clearMeasureTextCache, defaultFont, getCellTextInfo, getFontSet, getMeasureText } from "./modules/text";
5
+ import { getColumnWidth } from "./api";
5
6
  import { isInlineStringCell } from "./modules/inline-string";
6
7
  import { getSheetIndex, indexToColumnChar } from "./utils";
7
8
  import { getBorderInfoComputeRange } from "./modules/border";
@@ -783,6 +784,33 @@ var Canvas = function () {
783
784
  renderCtx.fill();
784
785
  renderCtx.closePath();
785
786
  }
787
+ var index = getSheetIndex(this.sheetCtx, this.sheetCtx.currentSheetId);
788
+ var dataVerification = this.sheetCtx.luckysheetfile[index].dataVerification;
789
+ if ((dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)].type) === "dropdown") {
790
+ var columnWidth = getColumnWidth(this.sheetCtx, [c]);
791
+ var finalPillWidth = ((columnWidth === null || columnWidth === void 0 ? void 0 : columnWidth[c]) || 70) - 5;
792
+ var ps_w = finalPillWidth * this.sheetCtx.zoomRatio;
793
+ var ps_h = 16 * this.sheetCtx.zoomRatio;
794
+ var radius = 5 * this.sheetCtx.zoomRatio;
795
+ var x = endX + offsetLeft - 4 - ps_w;
796
+ var y = startY + offsetTop + 2;
797
+ renderCtx.beginPath();
798
+ renderCtx.fillStyle = "rgba(232, 235, 236, 1)";
799
+ renderCtx.roundRect(x, y, ps_w, ps_h, radius);
800
+ renderCtx.fill();
801
+ renderCtx.closePath();
802
+ var chevronWidth = 7 * this.sheetCtx.zoomRatio;
803
+ var chevronHeight = 4 * this.sheetCtx.zoomRatio;
804
+ var chevronX = x + ps_w - chevronWidth - 2 * this.sheetCtx.zoomRatio;
805
+ var chevronY = y + (ps_h - chevronHeight) / 2;
806
+ renderCtx.beginPath();
807
+ renderCtx.fillStyle = "rgba(0, 0, 0, 1)";
808
+ renderCtx.moveTo(chevronX, chevronY);
809
+ renderCtx.lineTo(chevronX + chevronWidth, chevronY);
810
+ renderCtx.lineTo(chevronX + chevronWidth / 2, chevronY + chevronHeight);
811
+ renderCtx.closePath();
812
+ renderCtx.fill();
813
+ }
786
814
  var cellOverflow_colInObj = this.cellOverflow_colIn(cellOverflowMap, r, c, colStart, colEnd);
787
815
  if (cellOverflow_colInObj.colLast && !_.isNil(cellOverflow_colInObj.rowIndex) && !_.isNil(cellOverflow_colInObj.colIndex) && !_.isNil(cellOverflow_colInObj.stc) && !_.isNil(cellOverflow_colInObj.edc)) {
788
816
  this.cellOverflowRender(cellOverflow_colInObj.rowIndex, cellOverflow_colInObj.colIndex, cellOverflow_colInObj.stc, cellOverflow_colInObj.edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute);
@@ -817,7 +845,7 @@ var Canvas = function () {
817
845
  }, renderCtx);
818
846
  };
819
847
  Canvas.prototype.cellRender = function (r, c, startY, startX, endY, endX, value, renderCtx, afCompute, cfCompute, offsetLeft, offsetTop, dynamicArrayCompute, cellOverflowMap, colStart, colEnd, scrollHeight, scrollWidth, bodrder05, isMerge) {
820
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
848
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
821
849
  if (isMerge === void 0) {
822
850
  isMerge = false;
823
851
  }
@@ -858,6 +886,72 @@ var Canvas = function () {
858
886
  renderCtx.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
859
887
  var index = getSheetIndex(this.sheetCtx, this.sheetCtx.currentSheetId);
860
888
  var dataVerification = this.sheetCtx.luckysheetfile[index].dataVerification;
889
+ var isDataVlidationAvailable = (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)].type) === "dropdown";
890
+ if (isDataVlidationAvailable) {
891
+ var option = cell === null || cell === void 0 ? void 0 : cell.v;
892
+ var color = (_c = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _c === void 0 ? void 0 : _c.color;
893
+ var allOptions = (_d = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _d === void 0 ? void 0 : _d.value1.split(",");
894
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
895
+ return v.trim();
896
+ });
897
+ var rgbArray_1 = [];
898
+ for (var i = 0; i < colorValues.length; i += 3) {
899
+ rgbArray_1.push(colorValues.slice(i, i + 3).join(", "));
900
+ }
901
+ var optionValue_1 = (_e = String(option)) === null || _e === void 0 ? void 0 : _e.split(",");
902
+ var columnWidth = getColumnWidth(this.sheetCtx, [c]);
903
+ var finalPillWidth = ((columnWidth === null || columnWidth === void 0 ? void 0 : columnWidth[c]) || 70) - 5;
904
+ var ps_w = finalPillWidth * this.sheetCtx.zoomRatio;
905
+ var ps_h = 16 * this.sheetCtx.zoomRatio;
906
+ var radius = 5 * this.sheetCtx.zoomRatio;
907
+ var baseX = endX + offsetLeft - 4 - ps_w;
908
+ var baseY = startY + offsetTop + 2;
909
+ var pillSpacing = 2 * this.sheetCtx.zoomRatio;
910
+ var _loop_1 = function _loop_1(i) {
911
+ var x = baseX;
912
+ var y = baseY + i * (ps_h + pillSpacing);
913
+ var bgColor;
914
+ allOptions === null || allOptions === void 0 ? void 0 : allOptions.forEach(function (opt, idx) {
915
+ if (opt === optionValue_1[i]) {
916
+ bgColor = "rgba(".concat(rgbArray_1 === null || rgbArray_1 === void 0 ? void 0 : rgbArray_1[idx], ", 1)");
917
+ }
918
+ });
919
+ renderCtx.beginPath();
920
+ renderCtx.fillStyle = bgColor || "rgba(232, 235, 236, 1)";
921
+ renderCtx.roundRect(x, y, ps_w - 8, ps_h, radius);
922
+ renderCtx.fill();
923
+ renderCtx.closePath();
924
+ if (i === 0) {
925
+ var chevronWidth = 7 * this_1.sheetCtx.zoomRatio;
926
+ var chevronHeight = 4 * this_1.sheetCtx.zoomRatio;
927
+ var chevronX = x + 3 + ps_w - chevronWidth - 2 * this_1.sheetCtx.zoomRatio;
928
+ var chevronY = y + (ps_h - chevronHeight) / 2;
929
+ renderCtx.beginPath();
930
+ renderCtx.fillStyle = "rgba(0, 0, 0, 1)";
931
+ renderCtx.moveTo(chevronX, chevronY);
932
+ renderCtx.lineTo(chevronX + chevronWidth, chevronY);
933
+ renderCtx.lineTo(chevronX + chevronWidth / 2, chevronY + chevronHeight);
934
+ renderCtx.closePath();
935
+ renderCtx.fill();
936
+ }
937
+ var text = optionValue_1[i];
938
+ var fontSize = (cell === null || cell === void 0 ? void 0 : cell.fs) * this_1.sheetCtx.zoomRatio;
939
+ renderCtx.font = "".concat(fontSize, "px sans-serif");
940
+ renderCtx.fillStyle = "rgba(0, 0, 0, 0.8)";
941
+ renderCtx.textBaseline = "middle";
942
+ renderCtx.textAlign = "left";
943
+ renderCtx.save();
944
+ renderCtx.beginPath();
945
+ renderCtx.rect(x, y, finalPillWidth - 12, ps_h);
946
+ renderCtx.clip();
947
+ renderCtx.fillText(text, x + 4, y + ps_h / 2);
948
+ renderCtx.restore();
949
+ };
950
+ var this_1 = this;
951
+ for (var i = 0; i < (optionValue_1 === null || optionValue_1 === void 0 ? void 0 : optionValue_1.length); i += 1) {
952
+ _loop_1(i);
953
+ }
954
+ }
861
955
  if ((dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && !validateCellData(this.sheetCtx, dataVerification["".concat(r, "_").concat(c)], value)) {
862
956
  var dv_w = 9 * this.sheetCtx.zoomRatio;
863
957
  var dv_h = 9 * this.sheetCtx.zoomRatio;
@@ -899,7 +993,7 @@ var Canvas = function () {
899
993
  } else {
900
994
  cellOverflow_bd_r_render = false;
901
995
  }
902
- } else if (((_c = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _c === void 0 ? void 0 : _c.type) === "checkbox") {
996
+ } else if (((_f = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _f === void 0 ? void 0 : _f.type) === "checkbox") {
903
997
  var pos_x = startX + offsetLeft;
904
998
  var pos_y = startY + offsetTop + 1;
905
999
  renderCtx.save();
@@ -960,7 +1054,7 @@ var Canvas = function () {
960
1054
  renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos + 18, verticalAlignPos_text);
961
1055
  renderCtx.restore();
962
1056
  } else {
963
- if (((_d = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _d === void 0 ? void 0 : _d.valueLen) && ((_f = (_e = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _e === void 0 ? void 0 : _e.valueLen) === null || _f === void 0 ? void 0 : _f.toString()) !== "NaN") {
1057
+ if (((_g = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _g === void 0 ? void 0 : _g.valueLen) && ((_j = (_h = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _h === void 0 ? void 0 : _h.valueLen) === null || _j === void 0 ? void 0 : _j.toString()) !== "NaN") {
964
1058
  var x = startX + offsetLeft + space_width;
965
1059
  var y = startY + offsetTop + space_height;
966
1060
  var w = cellWidth - space_width * 2;
@@ -1072,7 +1166,7 @@ var Canvas = function () {
1072
1166
  if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
1073
1167
  renderCtx.fillStyle = checksCF.textColor;
1074
1168
  }
1075
- if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
1169
+ if (((_m = (_l = (_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.fa) === null || _l === void 0 ? void 0 : _l.indexOf("[Red]")) !== null && _m !== void 0 ? _m : -1) > -1 && ((_o = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _o === void 0 ? void 0 : _o.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
1076
1170
  renderCtx.fillStyle = "#ff0000";
1077
1171
  }
1078
1172
  var sheetId = this.sheetCtx.currentSheetId;
@@ -1080,12 +1174,14 @@ var Canvas = function () {
1080
1174
  if (opacity < 0.999) {
1081
1175
  renderCtx.save();
1082
1176
  renderCtx.globalAlpha = opacity;
1083
- this.cellTextRender(textInfo, renderCtx, {
1084
- pos_x: pos_x,
1085
- pos_y: pos_y
1086
- });
1177
+ if (!isDataVlidationAvailable) {
1178
+ this.cellTextRender(textInfo, renderCtx, {
1179
+ pos_x: pos_x,
1180
+ pos_y: pos_y
1181
+ });
1182
+ }
1087
1183
  renderCtx.restore();
1088
- } else {
1184
+ } else if (!isDataVlidationAvailable) {
1089
1185
  this.cellTextRender(textInfo, renderCtx, {
1090
1186
  pos_x: pos_x,
1091
1187
  pos_y: pos_y
@@ -1113,7 +1209,7 @@ var Canvas = function () {
1113
1209
  renderCtx.stroke();
1114
1210
  renderCtx.closePath();
1115
1211
  }
1116
- (_m = (_l = this.sheetCtx.hooks).afterRenderCell) === null || _m === void 0 ? void 0 : _m.call(_l, (_o = flowdata[r]) === null || _o === void 0 ? void 0 : _o[c], {
1212
+ (_q = (_p = this.sheetCtx.hooks).afterRenderCell) === null || _q === void 0 ? void 0 : _q.call(_p, (_r = flowdata[r]) === null || _r === void 0 ? void 0 : _r[c], {
1117
1213
  row: r,
1118
1214
  column: c,
1119
1215
  startX: cellsize[0],
@@ -442,7 +442,7 @@ export function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, containe
442
442
  }
443
443
  export function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
444
444
  var _a, _b;
445
- var _c;
445
+ var _c, _d;
446
446
  var flowdata = getFlowdata(ctx);
447
447
  if (!flowdata || ctx.formulaCache.functionlistMap[ctx.functionHint || ""]) return;
448
448
  if (ctx.luckysheetCellUpdate.length > 0 && ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx)) {
@@ -456,9 +456,9 @@ export function handleCellAreaDoubleClick(ctx, globalCache, settings, e, contain
456
456
  var _x = mouseX + ctx.scrollLeft;
457
457
  var _y = mouseY + ctx.scrollTop;
458
458
  var freeze = (_c = globalCache.freezen) === null || _c === void 0 ? void 0 : _c[ctx.currentSheetId];
459
- var _d = fixPositionOnFrozenCells(freeze, _x, _y, mouseX, mouseY),
460
- x = _d.x,
461
- y = _d.y;
459
+ var _e = fixPositionOnFrozenCells(freeze, _x, _y, mouseX, mouseY),
460
+ x = _e.x,
461
+ y = _e.y;
462
462
  var row_location = rowLocation(y, ctx.visibledatarow);
463
463
  var row_index = row_location[2];
464
464
  var col_location = colLocation(x, ctx.visibledatacolumn);
@@ -467,6 +467,9 @@ export function handleCellAreaDoubleClick(ctx, globalCache, settings, e, contain
467
467
  removeEditingComment(ctx, globalCache);
468
468
  var index = getSheetIndex(ctx, ctx.currentSheetId);
469
469
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
470
+ if (dataVerification && ((_d = dataVerification["".concat(row_index, "_").concat(col_index)]) === null || _d === void 0 ? void 0 : _d.type) === "dropdown") {
471
+ return;
472
+ }
470
473
  if (dataVerification) {
471
474
  var item = dataVerification["".concat(row_index, "_").concat(col_index)];
472
475
  if (item && item.type === "checkbox") return;
@@ -476,9 +479,9 @@ export function handleCellAreaDoubleClick(ctx, globalCache, settings, e, contain
476
479
  _a = margeset.row, row_index = _a[2];
477
480
  _b = margeset.column, col_index = _b[2];
478
481
  }
479
- var _e = ctx.luckysheet_select_save[0],
480
- column_focus = _e.column_focus,
481
- row_focus = _e.row_focus;
482
+ var _f = ctx.luckysheet_select_save[0],
483
+ column_focus = _f.column_focus,
484
+ row_focus = _f.row_focus;
482
485
  if (!_.isNil(column_focus) && !_.isNil(row_focus) && (column_focus !== col_index || row_focus !== row_index)) {
483
486
  row_index = row_focus;
484
487
  col_index = column_focus;
@@ -104,6 +104,7 @@ export function getCellValue(r, c, data, attr) {
104
104
  }
105
105
  export function setCellValue(ctx, r, c, d, v) {
106
106
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
107
+ if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
107
108
  if (_.isNil(d)) {
108
109
  d = getFlowdata(ctx);
109
110
  }
@@ -528,6 +529,7 @@ export function cancelNormalSelected(ctx) {
528
529
  }
529
530
  export function updateCell(ctx, r, c, $input, value, canvas) {
530
531
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
532
+ if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
531
533
  var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
532
534
  var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
533
535
  var flowdata = getFlowdata(ctx);
@@ -1,4 +1,5 @@
1
1
  import { colLocationByIndex, diff, getcellrange, getCellValue, getFlowdata, getRangeByTxt, getSheetIndex, isAllowEdit, isAllowEditReadOnly, iscelldata, isdatetime, isRealNull, isRealNum, jfrefreshgrid, mergeBorder, rowLocationByIndex, setCellValue } from "..";
2
+ import { setRowHeight } from "../api";
2
3
  export function dataRangeSelection(ctx, cache, rangT, type, value) {
3
4
  var _a, _b;
4
5
  ctx.rangeDialog.show = true;
@@ -506,7 +507,12 @@ export function cellFocus(ctx, r, c, clickMode) {
506
507
  dropDownBtn.style.display = "none";
507
508
  var index = getSheetIndex(ctx, ctx.currentSheetId);
508
509
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
509
- ctx.dataVerificationDropDownList = false;
510
+ var item = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)];
511
+ if (!item) {
512
+ ctx.dataVerificationDropDownList = false;
513
+ } else if (item.type === "dropdown") {
514
+ ctx.dataVerificationDropDownList = true;
515
+ }
510
516
  if (!dataVerification) return;
511
517
  var row = ctx.visibledatarow[r];
512
518
  var row_pre = r === 0 ? 0 : ctx.visibledatarow[r - 1];
@@ -519,7 +525,6 @@ export function cellFocus(ctx, r, c, clickMode) {
519
525
  _a = margeSet.row, row_pre = _a[0], row = _a[1];
520
526
  _b = margeSet.column, col_pre = _b[0], col = _b[1];
521
527
  }
522
- var item = dataVerification["".concat(r, "_").concat(c)];
523
528
  if (!item) return;
524
529
  if (clickMode && item.type === "checkbox") {
525
530
  checkboxChange(ctx, r, c);
@@ -579,6 +584,7 @@ export function cellFocus(ctx, r, c, clickMode) {
579
584
  }
580
585
  }
581
586
  export function setDropdownValue(ctx, value, arr) {
587
+ var _a;
582
588
  if (!ctx.luckysheet_select_save) return;
583
589
  var d = getFlowdata(ctx);
584
590
  if (!d) return;
@@ -595,7 +601,36 @@ export function setDropdownValue(ctx, value, arr) {
595
601
  } else {
596
602
  ctx.dataVerificationDropDownList = false;
597
603
  }
598
- setCellValue(ctx, rowIndex, colIndex, d, value);
604
+ var valueData = item === null || item === void 0 ? void 0 : item.value1;
605
+ var color = item === null || item === void 0 ? void 0 : item.color;
606
+ var selectedColor = "";
607
+ if (valueData && color) {
608
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
609
+ return v.trim();
610
+ });
611
+ var rgbArray = [];
612
+ for (var i = 0; i < colorValues.length; i += 3) {
613
+ rgbArray.push(colorValues.slice(i, i + 3).join(", "));
614
+ }
615
+ valueData = valueData === null || valueData === void 0 ? void 0 : valueData.split(",");
616
+ var valueIndex = void 0;
617
+ for (var i = 0; i < (valueData === null || valueData === void 0 ? void 0 : valueData.length); i += 1) {
618
+ if (value.includes(valueData[i])) {
619
+ valueIndex = i;
620
+ break;
621
+ }
622
+ }
623
+ selectedColor = typeof valueIndex === "number" ? rgbArray[valueIndex] : "";
624
+ }
625
+ setCellValue(ctx, rowIndex, colIndex, d, {
626
+ ct: {
627
+ fa: "General",
628
+ t: "g"
629
+ },
630
+ v: value,
631
+ pillColor: selectedColor
632
+ });
633
+ setRowHeight(ctx, (_a = {}, _a[String(rowIndex)] = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22, _a));
599
634
  jfrefreshgrid(ctx, null, undefined);
600
635
  }
601
636
  export function confirmMessage(ctx, generalDialog, dataVerification) {
package/es/types.d.ts CHANGED
@@ -270,6 +270,7 @@ export type RangeDialogProps = {
270
270
  singleSelect: boolean;
271
271
  };
272
272
  export type DataRegulationProps = {
273
+ color?: string;
273
274
  type: string;
274
275
  type2: string;
275
276
  rangeTxt: string;
package/lib/api/rowcol.js CHANGED
@@ -127,6 +127,7 @@ function setRowHeight(ctx, rowInfo, options, custom) {
127
127
  throw _errors.INVALID_PARAMS;
128
128
  }
129
129
  var sheet = (0, _common.getSheet)(ctx, options);
130
+ console.log("sheet=======", sheet);
130
131
  var cfg = sheet.config || {};
131
132
  if (cfg.rowlen == null) {
132
133
  cfg.rowlen = {};
package/lib/canvas.js CHANGED
@@ -8,6 +8,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
8
8
  var _context = require("./context");
9
9
  var _cell = require("./modules/cell");
10
10
  var _text = require("./modules/text");
11
+ var _api = require("./api");
11
12
  var _inlineString = require("./modules/inline-string");
12
13
  var _utils = require("./utils");
13
14
  var _border = require("./modules/border");
@@ -790,6 +791,33 @@ var Canvas = exports.Canvas = function () {
790
791
  renderCtx.fill();
791
792
  renderCtx.closePath();
792
793
  }
794
+ var index = (0, _utils.getSheetIndex)(this.sheetCtx, this.sheetCtx.currentSheetId);
795
+ var dataVerification = this.sheetCtx.luckysheetfile[index].dataVerification;
796
+ if ((dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)].type) === "dropdown") {
797
+ var columnWidth = (0, _api.getColumnWidth)(this.sheetCtx, [c]);
798
+ var finalPillWidth = ((columnWidth === null || columnWidth === void 0 ? void 0 : columnWidth[c]) || 70) - 5;
799
+ var ps_w = finalPillWidth * this.sheetCtx.zoomRatio;
800
+ var ps_h = 16 * this.sheetCtx.zoomRatio;
801
+ var radius = 5 * this.sheetCtx.zoomRatio;
802
+ var x = endX + offsetLeft - 4 - ps_w;
803
+ var y = startY + offsetTop + 2;
804
+ renderCtx.beginPath();
805
+ renderCtx.fillStyle = "rgba(232, 235, 236, 1)";
806
+ renderCtx.roundRect(x, y, ps_w, ps_h, radius);
807
+ renderCtx.fill();
808
+ renderCtx.closePath();
809
+ var chevronWidth = 7 * this.sheetCtx.zoomRatio;
810
+ var chevronHeight = 4 * this.sheetCtx.zoomRatio;
811
+ var chevronX = x + ps_w - chevronWidth - 2 * this.sheetCtx.zoomRatio;
812
+ var chevronY = y + (ps_h - chevronHeight) / 2;
813
+ renderCtx.beginPath();
814
+ renderCtx.fillStyle = "rgba(0, 0, 0, 1)";
815
+ renderCtx.moveTo(chevronX, chevronY);
816
+ renderCtx.lineTo(chevronX + chevronWidth, chevronY);
817
+ renderCtx.lineTo(chevronX + chevronWidth / 2, chevronY + chevronHeight);
818
+ renderCtx.closePath();
819
+ renderCtx.fill();
820
+ }
793
821
  var cellOverflow_colInObj = this.cellOverflow_colIn(cellOverflowMap, r, c, colStart, colEnd);
794
822
  if (cellOverflow_colInObj.colLast && !_lodash.default.isNil(cellOverflow_colInObj.rowIndex) && !_lodash.default.isNil(cellOverflow_colInObj.colIndex) && !_lodash.default.isNil(cellOverflow_colInObj.stc) && !_lodash.default.isNil(cellOverflow_colInObj.edc)) {
795
823
  this.cellOverflowRender(cellOverflow_colInObj.rowIndex, cellOverflow_colInObj.colIndex, cellOverflow_colInObj.stc, cellOverflow_colInObj.edc, renderCtx, scrollHeight, scrollWidth, offsetLeft, offsetTop, afCompute, cfCompute);
@@ -824,7 +852,7 @@ var Canvas = exports.Canvas = function () {
824
852
  }, renderCtx);
825
853
  };
826
854
  Canvas.prototype.cellRender = function (r, c, startY, startX, endY, endX, value, renderCtx, afCompute, cfCompute, offsetLeft, offsetTop, dynamicArrayCompute, cellOverflowMap, colStart, colEnd, scrollHeight, scrollWidth, bodrder05, isMerge) {
827
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
855
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
828
856
  if (isMerge === void 0) {
829
857
  isMerge = false;
830
858
  }
@@ -865,6 +893,72 @@ var Canvas = exports.Canvas = function () {
865
893
  renderCtx.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
866
894
  var index = (0, _utils.getSheetIndex)(this.sheetCtx, this.sheetCtx.currentSheetId);
867
895
  var dataVerification = this.sheetCtx.luckysheetfile[index].dataVerification;
896
+ var isDataVlidationAvailable = (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && (dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)].type) === "dropdown";
897
+ if (isDataVlidationAvailable) {
898
+ var option = cell === null || cell === void 0 ? void 0 : cell.v;
899
+ var color = (_c = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _c === void 0 ? void 0 : _c.color;
900
+ var allOptions = (_d = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _d === void 0 ? void 0 : _d.value1.split(",");
901
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
902
+ return v.trim();
903
+ });
904
+ var rgbArray_1 = [];
905
+ for (var i = 0; i < colorValues.length; i += 3) {
906
+ rgbArray_1.push(colorValues.slice(i, i + 3).join(", "));
907
+ }
908
+ var optionValue_1 = (_e = String(option)) === null || _e === void 0 ? void 0 : _e.split(",");
909
+ var columnWidth = (0, _api.getColumnWidth)(this.sheetCtx, [c]);
910
+ var finalPillWidth = ((columnWidth === null || columnWidth === void 0 ? void 0 : columnWidth[c]) || 70) - 5;
911
+ var ps_w = finalPillWidth * this.sheetCtx.zoomRatio;
912
+ var ps_h = 16 * this.sheetCtx.zoomRatio;
913
+ var radius = 5 * this.sheetCtx.zoomRatio;
914
+ var baseX = endX + offsetLeft - 4 - ps_w;
915
+ var baseY = startY + offsetTop + 2;
916
+ var pillSpacing = 2 * this.sheetCtx.zoomRatio;
917
+ var _loop_1 = function _loop_1(i) {
918
+ var x = baseX;
919
+ var y = baseY + i * (ps_h + pillSpacing);
920
+ var bgColor;
921
+ allOptions === null || allOptions === void 0 ? void 0 : allOptions.forEach(function (opt, idx) {
922
+ if (opt === optionValue_1[i]) {
923
+ bgColor = "rgba(".concat(rgbArray_1 === null || rgbArray_1 === void 0 ? void 0 : rgbArray_1[idx], ", 1)");
924
+ }
925
+ });
926
+ renderCtx.beginPath();
927
+ renderCtx.fillStyle = bgColor || "rgba(232, 235, 236, 1)";
928
+ renderCtx.roundRect(x, y, ps_w - 8, ps_h, radius);
929
+ renderCtx.fill();
930
+ renderCtx.closePath();
931
+ if (i === 0) {
932
+ var chevronWidth = 7 * this_1.sheetCtx.zoomRatio;
933
+ var chevronHeight = 4 * this_1.sheetCtx.zoomRatio;
934
+ var chevronX = x + 3 + ps_w - chevronWidth - 2 * this_1.sheetCtx.zoomRatio;
935
+ var chevronY = y + (ps_h - chevronHeight) / 2;
936
+ renderCtx.beginPath();
937
+ renderCtx.fillStyle = "rgba(0, 0, 0, 1)";
938
+ renderCtx.moveTo(chevronX, chevronY);
939
+ renderCtx.lineTo(chevronX + chevronWidth, chevronY);
940
+ renderCtx.lineTo(chevronX + chevronWidth / 2, chevronY + chevronHeight);
941
+ renderCtx.closePath();
942
+ renderCtx.fill();
943
+ }
944
+ var text = optionValue_1[i];
945
+ var fontSize = (cell === null || cell === void 0 ? void 0 : cell.fs) * this_1.sheetCtx.zoomRatio;
946
+ renderCtx.font = "".concat(fontSize, "px sans-serif");
947
+ renderCtx.fillStyle = "rgba(0, 0, 0, 0.8)";
948
+ renderCtx.textBaseline = "middle";
949
+ renderCtx.textAlign = "left";
950
+ renderCtx.save();
951
+ renderCtx.beginPath();
952
+ renderCtx.rect(x, y, finalPillWidth - 12, ps_h);
953
+ renderCtx.clip();
954
+ renderCtx.fillText(text, x + 4, y + ps_h / 2);
955
+ renderCtx.restore();
956
+ };
957
+ var this_1 = this;
958
+ for (var i = 0; i < (optionValue_1 === null || optionValue_1 === void 0 ? void 0 : optionValue_1.length); i += 1) {
959
+ _loop_1(i);
960
+ }
961
+ }
868
962
  if ((dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) && !(0, _modules.validateCellData)(this.sheetCtx, dataVerification["".concat(r, "_").concat(c)], value)) {
869
963
  var dv_w = 9 * this.sheetCtx.zoomRatio;
870
964
  var dv_h = 9 * this.sheetCtx.zoomRatio;
@@ -906,7 +1000,7 @@ var Canvas = exports.Canvas = function () {
906
1000
  } else {
907
1001
  cellOverflow_bd_r_render = false;
908
1002
  }
909
- } else if (((_c = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _c === void 0 ? void 0 : _c.type) === "checkbox") {
1003
+ } else if (((_f = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)]) === null || _f === void 0 ? void 0 : _f.type) === "checkbox") {
910
1004
  var pos_x = startX + offsetLeft;
911
1005
  var pos_y = startY + offsetTop + 1;
912
1006
  renderCtx.save();
@@ -967,7 +1061,7 @@ var Canvas = exports.Canvas = function () {
967
1061
  renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos + 18, verticalAlignPos_text);
968
1062
  renderCtx.restore();
969
1063
  } else {
970
- if (((_d = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _d === void 0 ? void 0 : _d.valueLen) && ((_f = (_e = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _e === void 0 ? void 0 : _e.valueLen) === null || _f === void 0 ? void 0 : _f.toString()) !== "NaN") {
1064
+ if (((_g = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _g === void 0 ? void 0 : _g.valueLen) && ((_j = (_h = checksCF === null || checksCF === void 0 ? void 0 : checksCF.dataBar) === null || _h === void 0 ? void 0 : _h.valueLen) === null || _j === void 0 ? void 0 : _j.toString()) !== "NaN") {
971
1065
  var x = startX + offsetLeft + space_width;
972
1066
  var y = startY + offsetTop + space_height;
973
1067
  var w = cellWidth - space_width * 2;
@@ -1079,7 +1173,7 @@ var Canvas = exports.Canvas = function () {
1079
1173
  if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
1080
1174
  renderCtx.fillStyle = checksCF.textColor;
1081
1175
  }
1082
- if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
1176
+ if (((_m = (_l = (_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.fa) === null || _l === void 0 ? void 0 : _l.indexOf("[Red]")) !== null && _m !== void 0 ? _m : -1) > -1 && ((_o = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _o === void 0 ? void 0 : _o.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
1083
1177
  renderCtx.fillStyle = "#ff0000";
1084
1178
  }
1085
1179
  var sheetId = this.sheetCtx.currentSheetId;
@@ -1087,12 +1181,14 @@ var Canvas = exports.Canvas = function () {
1087
1181
  if (opacity < 0.999) {
1088
1182
  renderCtx.save();
1089
1183
  renderCtx.globalAlpha = opacity;
1090
- this.cellTextRender(textInfo, renderCtx, {
1091
- pos_x: pos_x,
1092
- pos_y: pos_y
1093
- });
1184
+ if (!isDataVlidationAvailable) {
1185
+ this.cellTextRender(textInfo, renderCtx, {
1186
+ pos_x: pos_x,
1187
+ pos_y: pos_y
1188
+ });
1189
+ }
1094
1190
  renderCtx.restore();
1095
- } else {
1191
+ } else if (!isDataVlidationAvailable) {
1096
1192
  this.cellTextRender(textInfo, renderCtx, {
1097
1193
  pos_x: pos_x,
1098
1194
  pos_y: pos_y
@@ -1120,7 +1216,7 @@ var Canvas = exports.Canvas = function () {
1120
1216
  renderCtx.stroke();
1121
1217
  renderCtx.closePath();
1122
1218
  }
1123
- (_m = (_l = this.sheetCtx.hooks).afterRenderCell) === null || _m === void 0 ? void 0 : _m.call(_l, (_o = flowdata[r]) === null || _o === void 0 ? void 0 : _o[c], {
1219
+ (_q = (_p = this.sheetCtx.hooks).afterRenderCell) === null || _q === void 0 ? void 0 : _q.call(_p, (_r = flowdata[r]) === null || _r === void 0 ? void 0 : _r[c], {
1124
1220
  row: r,
1125
1221
  column: c,
1126
1222
  startX: cellsize[0],
@@ -461,7 +461,7 @@ function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, container, fxIn
461
461
  }
462
462
  function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
463
463
  var _a, _b;
464
- var _c;
464
+ var _c, _d;
465
465
  var flowdata = (0, _context.getFlowdata)(ctx);
466
466
  if (!flowdata || ctx.formulaCache.functionlistMap[ctx.functionHint || ""]) return;
467
467
  if (ctx.luckysheetCellUpdate.length > 0 && ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx)) {
@@ -475,9 +475,9 @@ function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
475
475
  var _x = mouseX + ctx.scrollLeft;
476
476
  var _y = mouseY + ctx.scrollTop;
477
477
  var freeze = (_c = globalCache.freezen) === null || _c === void 0 ? void 0 : _c[ctx.currentSheetId];
478
- var _d = fixPositionOnFrozenCells(freeze, _x, _y, mouseX, mouseY),
479
- x = _d.x,
480
- y = _d.y;
478
+ var _e = fixPositionOnFrozenCells(freeze, _x, _y, mouseX, mouseY),
479
+ x = _e.x,
480
+ y = _e.y;
481
481
  var row_location = (0, _location.rowLocation)(y, ctx.visibledatarow);
482
482
  var row_index = row_location[2];
483
483
  var col_location = (0, _location.colLocation)(x, ctx.visibledatacolumn);
@@ -486,6 +486,9 @@ function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
486
486
  (0, _modules.removeEditingComment)(ctx, globalCache);
487
487
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
488
488
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
489
+ if (dataVerification && ((_d = dataVerification["".concat(row_index, "_").concat(col_index)]) === null || _d === void 0 ? void 0 : _d.type) === "dropdown") {
490
+ return;
491
+ }
489
492
  if (dataVerification) {
490
493
  var item = dataVerification["".concat(row_index, "_").concat(col_index)];
491
494
  if (item && item.type === "checkbox") return;
@@ -495,9 +498,9 @@ function handleCellAreaDoubleClick(ctx, globalCache, settings, e, container) {
495
498
  _a = margeset.row, row_index = _a[2];
496
499
  _b = margeset.column, col_index = _b[2];
497
500
  }
498
- var _e = ctx.luckysheet_select_save[0],
499
- column_focus = _e.column_focus,
500
- row_focus = _e.row_focus;
501
+ var _f = ctx.luckysheet_select_save[0],
502
+ column_focus = _f.column_focus,
503
+ row_focus = _f.row_focus;
501
504
  if (!_lodash.default.isNil(column_focus) && !_lodash.default.isNil(row_focus) && (column_focus !== col_index || row_focus !== row_index)) {
502
505
  row_index = row_focus;
503
506
  col_index = column_focus;
@@ -137,6 +137,7 @@ function getCellValue(r, c, data, attr) {
137
137
  }
138
138
  function setCellValue(ctx, r, c, d, v) {
139
139
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
140
+ if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
140
141
  if (_lodash.default.isNil(d)) {
141
142
  d = (0, _context.getFlowdata)(ctx);
142
143
  }
@@ -561,6 +562,7 @@ function cancelNormalSelected(ctx) {
561
562
  }
562
563
  function updateCell(ctx, r, c, $input, value, canvas) {
563
564
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
565
+ if (ctx.allowEdit === false || ctx.isFlvReadOnly) return;
564
566
  var inputText = $input === null || $input === void 0 ? void 0 : $input.innerText;
565
567
  var inputHtml = $input === null || $input === void 0 ? void 0 : $input.innerHTML;
566
568
  var flowdata = (0, _context.getFlowdata)(ctx);
@@ -14,6 +14,7 @@ exports.setDropdownValue = setDropdownValue;
14
14
  exports.validateCellData = validateCellData;
15
15
  exports.validateIdCard = validateIdCard;
16
16
  var _ = require("..");
17
+ var _api = require("../api");
17
18
  function dataRangeSelection(ctx, cache, rangT, type, value) {
18
19
  var _a, _b;
19
20
  ctx.rangeDialog.show = true;
@@ -521,7 +522,12 @@ function cellFocus(ctx, r, c, clickMode) {
521
522
  dropDownBtn.style.display = "none";
522
523
  var index = (0, _.getSheetIndex)(ctx, ctx.currentSheetId);
523
524
  var dataVerification = ctx.luckysheetfile[index].dataVerification;
524
- ctx.dataVerificationDropDownList = false;
525
+ var item = dataVerification === null || dataVerification === void 0 ? void 0 : dataVerification["".concat(r, "_").concat(c)];
526
+ if (!item) {
527
+ ctx.dataVerificationDropDownList = false;
528
+ } else if (item.type === "dropdown") {
529
+ ctx.dataVerificationDropDownList = true;
530
+ }
525
531
  if (!dataVerification) return;
526
532
  var row = ctx.visibledatarow[r];
527
533
  var row_pre = r === 0 ? 0 : ctx.visibledatarow[r - 1];
@@ -534,7 +540,6 @@ function cellFocus(ctx, r, c, clickMode) {
534
540
  _a = margeSet.row, row_pre = _a[0], row = _a[1];
535
541
  _b = margeSet.column, col_pre = _b[0], col = _b[1];
536
542
  }
537
- var item = dataVerification["".concat(r, "_").concat(c)];
538
543
  if (!item) return;
539
544
  if (clickMode && item.type === "checkbox") {
540
545
  checkboxChange(ctx, r, c);
@@ -594,6 +599,7 @@ function cellFocus(ctx, r, c, clickMode) {
594
599
  }
595
600
  }
596
601
  function setDropdownValue(ctx, value, arr) {
602
+ var _a;
597
603
  if (!ctx.luckysheet_select_save) return;
598
604
  var d = (0, _.getFlowdata)(ctx);
599
605
  if (!d) return;
@@ -610,7 +616,36 @@ function setDropdownValue(ctx, value, arr) {
610
616
  } else {
611
617
  ctx.dataVerificationDropDownList = false;
612
618
  }
613
- (0, _.setCellValue)(ctx, rowIndex, colIndex, d, value);
619
+ var valueData = item === null || item === void 0 ? void 0 : item.value1;
620
+ var color = item === null || item === void 0 ? void 0 : item.color;
621
+ var selectedColor = "";
622
+ if (valueData && color) {
623
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
624
+ return v.trim();
625
+ });
626
+ var rgbArray = [];
627
+ for (var i = 0; i < colorValues.length; i += 3) {
628
+ rgbArray.push(colorValues.slice(i, i + 3).join(", "));
629
+ }
630
+ valueData = valueData === null || valueData === void 0 ? void 0 : valueData.split(",");
631
+ var valueIndex = void 0;
632
+ for (var i = 0; i < (valueData === null || valueData === void 0 ? void 0 : valueData.length); i += 1) {
633
+ if (value.includes(valueData[i])) {
634
+ valueIndex = i;
635
+ break;
636
+ }
637
+ }
638
+ selectedColor = typeof valueIndex === "number" ? rgbArray[valueIndex] : "";
639
+ }
640
+ (0, _.setCellValue)(ctx, rowIndex, colIndex, d, {
641
+ ct: {
642
+ fa: "General",
643
+ t: "g"
644
+ },
645
+ v: value,
646
+ pillColor: selectedColor
647
+ });
648
+ (0, _api.setRowHeight)(ctx, (_a = {}, _a[String(rowIndex)] = 22 * (value.split(",").length || (valueData === null || valueData === void 0 ? void 0 : valueData.length)) || 22, _a));
614
649
  (0, _.jfrefreshgrid)(ctx, null, undefined);
615
650
  }
616
651
  function confirmMessage(ctx, generalDialog, dataVerification) {
package/lib/types.d.ts CHANGED
@@ -270,6 +270,7 @@ export type RangeDialogProps = {
270
270
  singleSelect: boolean;
271
271
  };
272
272
  export type DataRegulationProps = {
273
+ color?: string;
273
274
  type: string;
274
275
  type2: string;
275
276
  rangeTxt: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.90",
3
+ "version": "1.1.92",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",