@fileverse-dev/fortune-core 1.2.72 → 1.2.74

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/context.js CHANGED
@@ -153,6 +153,7 @@ export function defaultContext(refs) {
153
153
  },
154
154
  dataVerificationDropDownList: false,
155
155
  conditionRules: {
156
+ editKey: null,
156
157
  rulesType: "",
157
158
  rulesValue: "",
158
159
  textColor: {
@@ -8,7 +8,7 @@ export declare function getCurrentRules(fileC: Sheet[]): {
8
8
  sheetIndex: number;
9
9
  luckysheet_conditionformat_save: any[] | undefined;
10
10
  }[];
11
- export declare function setConditionRules(ctx: Context, protection: any, generalDialog: any, conditionformat: any, rules: any): void;
11
+ export declare function setConditionRules(ctx: Context, protection: any, generalDialog: any, conditionformat: any, rules: any, edit?: boolean, editKey?: string): void;
12
12
  export declare function getColorGradation(color1: string, color2: string, value1: number, value2: number, value: number): string;
13
13
  export declare function compute(ctx: Context, ruleArr: any, d: CellMatrix): any;
14
14
  export declare function getComputeMap(ctx: Context): any;
@@ -8,6 +8,15 @@ var __assign = this && this.__assign || function () {
8
8
  };
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
12
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
13
+ if (ar || !(i in from)) {
14
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
15
+ ar[i] = from[i];
16
+ }
17
+ }
18
+ return to.concat(ar || Array.prototype.slice.call(from));
19
+ };
11
20
  import _ from "lodash";
12
21
  import { getFlowdata } from "../context";
13
22
  import { getSheetIndex } from "../utils";
@@ -116,7 +125,7 @@ export function getCurrentRules(fileC) {
116
125
  }
117
126
  return currentRules;
118
127
  }
119
- export function setConditionRules(ctx, protection, generalDialog, conditionformat, rules) {
128
+ export function setConditionRules(ctx, protection, generalDialog, conditionformat, rules, edit, editKey) {
120
129
  var _a, _b;
121
130
  if (!checkProtectionFormatCells(ctx)) {
122
131
  return;
@@ -257,7 +266,12 @@ export function setConditionRules(ctx, protection, generalDialog, conditionforma
257
266
  };
258
267
  var index = getSheetIndex(ctx, ctx.currentSheetId);
259
268
  var ruleArr = (_b = ctx.luckysheetfile[index].luckysheet_conditionformat_save) !== null && _b !== void 0 ? _b : [];
260
- ruleArr === null || ruleArr === void 0 ? void 0 : ruleArr.push(rule);
269
+ console.log(rule, ruleArr, editKey, edit);
270
+ if (edit) {
271
+ ruleArr.splice(Number(editKey), 1, rule);
272
+ } else {
273
+ ruleArr.push(rule);
274
+ }
261
275
  ctx.luckysheetfile[index].luckysheet_conditionformat_save = ruleArr;
262
276
  ctx.luckysheetfile[index].conditionRules = __assign(__assign({}, rules), {
263
277
  rulesType: rules.rulesType || "",
@@ -990,10 +1004,32 @@ export function compute(ctx, ruleArr, d) {
990
1004
  return computeMap;
991
1005
  }
992
1006
  export function getComputeMap(ctx) {
1007
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
993
1008
  var index = getSheetIndex(ctx, ctx.currentSheetId);
994
- var ruleArr = ctx.luckysheetfile[index].luckysheet_conditionformat_save;
1009
+ var ruleArr = ((_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.luckysheet_conditionformat_save) ? __spreadArray([], (_b = ctx.luckysheetfile[index]) === null || _b === void 0 ? void 0 : _b.luckysheet_conditionformat_save, true) : [];
995
1010
  var data = ctx.luckysheetfile[index].data;
996
1011
  if (_.isNil(data)) return null;
1012
+ if (ctx.luckysheet_select_save && ((_c = ctx.luckysheetfile[index].conditionRules) === null || _c === void 0 ? void 0 : _c.rulesValue) !== "") {
1013
+ var editKey = (_d = ctx.luckysheetfile[index].conditionRules) === null || _d === void 0 ? void 0 : _d.editKey;
1014
+ if (editKey !== null) {
1015
+ ruleArr.splice(Number(editKey), 1);
1016
+ }
1017
+ ruleArr.push({
1018
+ type: "default",
1019
+ cellrange: ctx.luckysheet_select_save,
1020
+ format: {
1021
+ textColor: (_e = ctx.luckysheetfile[index].conditionRules) === null || _e === void 0 ? void 0 : _e.textColor.color,
1022
+ cellColor: (_f = ctx.luckysheetfile[index].conditionRules) === null || _f === void 0 ? void 0 : _f.cellColor.color,
1023
+ bold: (_g = ctx.luckysheetfile[index].conditionRules) === null || _g === void 0 ? void 0 : _g.font.bold,
1024
+ italic: (_h = ctx.luckysheetfile[index].conditionRules) === null || _h === void 0 ? void 0 : _h.font.italic,
1025
+ underline: (_j = ctx.luckysheetfile[index].conditionRules) === null || _j === void 0 ? void 0 : _j.font.underline,
1026
+ strikethrough: (_k = ctx.luckysheetfile[index].conditionRules) === null || _k === void 0 ? void 0 : _k.font.strikethrough
1027
+ },
1028
+ conditionName: (_l = ctx.luckysheetfile[index].conditionRules) === null || _l === void 0 ? void 0 : _l.rulesType,
1029
+ conditionRange: [],
1030
+ conditionValue: [(_m = ctx.luckysheetfile[index].conditionRules) === null || _m === void 0 ? void 0 : _m.rulesValue]
1031
+ });
1032
+ }
997
1033
  var computeMap = compute(ctx, ruleArr, data);
998
1034
  return computeMap;
999
1035
  }
package/es/types.d.ts CHANGED
@@ -134,6 +134,7 @@ export type Image = {
134
134
  src: string;
135
135
  };
136
136
  export type ConditionRulesProps = {
137
+ editKey?: string | null;
137
138
  rulesType: string;
138
139
  rulesValue: string;
139
140
  textColor: {
package/lib/context.js CHANGED
@@ -165,6 +165,7 @@ function defaultContext(refs) {
165
165
  },
166
166
  dataVerificationDropDownList: false,
167
167
  conditionRules: {
168
+ editKey: null,
168
169
  rulesType: "",
169
170
  rulesValue: "",
170
171
  textColor: {
@@ -8,7 +8,7 @@ export declare function getCurrentRules(fileC: Sheet[]): {
8
8
  sheetIndex: number;
9
9
  luckysheet_conditionformat_save: any[] | undefined;
10
10
  }[];
11
- export declare function setConditionRules(ctx: Context, protection: any, generalDialog: any, conditionformat: any, rules: any): void;
11
+ export declare function setConditionRules(ctx: Context, protection: any, generalDialog: any, conditionformat: any, rules: any, edit?: boolean, editKey?: string): void;
12
12
  export declare function getColorGradation(color1: string, color2: string, value1: number, value2: number, value: number): string;
13
13
  export declare function compute(ctx: Context, ruleArr: any, d: CellMatrix): any;
14
14
  export declare function getComputeMap(ctx: Context): any;
@@ -31,6 +31,15 @@ var __assign = void 0 && (void 0).__assign || function () {
31
31
  };
32
32
  return __assign.apply(this, arguments);
33
33
  };
34
+ var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack) {
35
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
36
+ if (ar || !(i in from)) {
37
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
38
+ ar[i] = from[i];
39
+ }
40
+ }
41
+ return to.concat(ar || Array.prototype.slice.call(from));
42
+ };
34
43
  function hasAlphabeticChars(value) {
35
44
  return /[a-zA-Z]/.test(String(value));
36
45
  }
@@ -131,7 +140,7 @@ function getCurrentRules(fileC) {
131
140
  }
132
141
  return currentRules;
133
142
  }
134
- function setConditionRules(ctx, protection, generalDialog, conditionformat, rules) {
143
+ function setConditionRules(ctx, protection, generalDialog, conditionformat, rules, edit, editKey) {
135
144
  var _a, _b;
136
145
  if (!(0, _protection.checkProtectionFormatCells)(ctx)) {
137
146
  return;
@@ -272,7 +281,12 @@ function setConditionRules(ctx, protection, generalDialog, conditionformat, rule
272
281
  };
273
282
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
274
283
  var ruleArr = (_b = ctx.luckysheetfile[index].luckysheet_conditionformat_save) !== null && _b !== void 0 ? _b : [];
275
- ruleArr === null || ruleArr === void 0 ? void 0 : ruleArr.push(rule);
284
+ console.log(rule, ruleArr, editKey, edit);
285
+ if (edit) {
286
+ ruleArr.splice(Number(editKey), 1, rule);
287
+ } else {
288
+ ruleArr.push(rule);
289
+ }
276
290
  ctx.luckysheetfile[index].luckysheet_conditionformat_save = ruleArr;
277
291
  ctx.luckysheetfile[index].conditionRules = __assign(__assign({}, rules), {
278
292
  rulesType: rules.rulesType || "",
@@ -1005,10 +1019,32 @@ function compute(ctx, ruleArr, d) {
1005
1019
  return computeMap;
1006
1020
  }
1007
1021
  function getComputeMap(ctx) {
1022
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1008
1023
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
1009
- var ruleArr = ctx.luckysheetfile[index].luckysheet_conditionformat_save;
1024
+ var ruleArr = ((_a = ctx.luckysheetfile[index]) === null || _a === void 0 ? void 0 : _a.luckysheet_conditionformat_save) ? __spreadArray([], (_b = ctx.luckysheetfile[index]) === null || _b === void 0 ? void 0 : _b.luckysheet_conditionformat_save, true) : [];
1010
1025
  var data = ctx.luckysheetfile[index].data;
1011
1026
  if (_lodash.default.isNil(data)) return null;
1027
+ if (ctx.luckysheet_select_save && ((_c = ctx.luckysheetfile[index].conditionRules) === null || _c === void 0 ? void 0 : _c.rulesValue) !== "") {
1028
+ var editKey = (_d = ctx.luckysheetfile[index].conditionRules) === null || _d === void 0 ? void 0 : _d.editKey;
1029
+ if (editKey !== null) {
1030
+ ruleArr.splice(Number(editKey), 1);
1031
+ }
1032
+ ruleArr.push({
1033
+ type: "default",
1034
+ cellrange: ctx.luckysheet_select_save,
1035
+ format: {
1036
+ textColor: (_e = ctx.luckysheetfile[index].conditionRules) === null || _e === void 0 ? void 0 : _e.textColor.color,
1037
+ cellColor: (_f = ctx.luckysheetfile[index].conditionRules) === null || _f === void 0 ? void 0 : _f.cellColor.color,
1038
+ bold: (_g = ctx.luckysheetfile[index].conditionRules) === null || _g === void 0 ? void 0 : _g.font.bold,
1039
+ italic: (_h = ctx.luckysheetfile[index].conditionRules) === null || _h === void 0 ? void 0 : _h.font.italic,
1040
+ underline: (_j = ctx.luckysheetfile[index].conditionRules) === null || _j === void 0 ? void 0 : _j.font.underline,
1041
+ strikethrough: (_k = ctx.luckysheetfile[index].conditionRules) === null || _k === void 0 ? void 0 : _k.font.strikethrough
1042
+ },
1043
+ conditionName: (_l = ctx.luckysheetfile[index].conditionRules) === null || _l === void 0 ? void 0 : _l.rulesType,
1044
+ conditionRange: [],
1045
+ conditionValue: [(_m = ctx.luckysheetfile[index].conditionRules) === null || _m === void 0 ? void 0 : _m.rulesValue]
1046
+ });
1047
+ }
1012
1048
  var computeMap = compute(ctx, ruleArr, data);
1013
1049
  return computeMap;
1014
1050
  }
package/lib/types.d.ts CHANGED
@@ -134,6 +134,7 @@ export type Image = {
134
134
  src: string;
135
135
  };
136
136
  export type ConditionRulesProps = {
137
+ editKey?: string | null;
137
138
  rulesType: string;
138
139
  rulesValue: string;
139
140
  textColor: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.2.72",
3
+ "version": "1.2.74",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",