@fileverse-dev/fortune-react 1.2.72-condition-1 → 1.2.73

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.
@@ -26,6 +26,7 @@ var ConditionRules = function ConditionRules(_a) {
26
26
  var _d = useState(null),
27
27
  editConditionFormatKey = _d[0],
28
28
  setEditConditionFormatKey = _d[1];
29
+ var editKeyRef = useRef(null);
29
30
  var _e = useState(""),
30
31
  editConditionRange = _e[0],
31
32
  setEditConditionRange = _e[1];
@@ -95,6 +96,36 @@ var ConditionRules = function ConditionRules(_a) {
95
96
  setCreate(false);
96
97
  }
97
98
  }, [context]);
99
+ var updateCacheRules = function updateCacheRules() {
100
+ setContext(function (ctx) {
101
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
102
+ ctx.luckysheetfile[index].conditionRules = {
103
+ rulesType: type || "",
104
+ rulesValue: ctx.conditionRules.rulesValue || "",
105
+ textColor: {
106
+ check: true,
107
+ color: colorRules.textColor
108
+ },
109
+ cellColor: {
110
+ check: true,
111
+ color: colorRules.cellColor
112
+ },
113
+ font: {
114
+ bold: bold,
115
+ italic: italic,
116
+ underline: underline,
117
+ strikethrough: strikethrough
118
+ },
119
+ betweenValue: ctx.conditionRules.betweenValue || {
120
+ value1: "",
121
+ value2: ""
122
+ },
123
+ dateValue: ctx.conditionRules.dateValue || "",
124
+ repeatValue: ctx.conditionRules.repeatValue || "0",
125
+ projectValue: ctx.conditionRules.projectValue || "10"
126
+ };
127
+ });
128
+ };
98
129
  var dataSelectRange = useCallback(function (selectType) {
99
130
  hideDialog();
100
131
  setContext(function (ctx) {
@@ -105,7 +136,11 @@ var ConditionRules = function ConditionRules(_a) {
105
136
  ctx.rangeDialog.rangeTxt = ctx.conditionRules.rulesValue;
106
137
  ctx.rangeDialog.singleSelect = false;
107
138
  });
139
+ updateCacheRules();
108
140
  }, [colorRules.cellColor, colorRules.textColor, hideDialog, setContext]);
141
+ useEffect(function () {
142
+ updateCacheRules();
143
+ }, [type, bold, italic, underline, strikethrough, colorRules]);
109
144
  var close = useCallback(function (closeType) {
110
145
  if (closeType === "confirm") {
111
146
  buttonClickCreateRef.current = false;
@@ -128,8 +163,6 @@ var ConditionRules = function ConditionRules(_a) {
128
163
  buttonClickCreateRef.current = false;
129
164
  setCreate(false);
130
165
  setContext(function (ctx) {
131
- console.log(type, "tttttttt", ctx.conditionRules.rulesType);
132
- console.log(editConditionFormatKey, colorRules.textColor, colorRules.cellColor);
133
166
  ctx.conditionRules.rulesType = type;
134
167
  ctx.conditionRules.textColor.color = colorRules.textColor;
135
168
  ctx.conditionRules.cellColor.color = colorRules.cellColor;
@@ -169,8 +202,9 @@ var ConditionRules = function ConditionRules(_a) {
169
202
  projectValue: "10"
170
203
  };
171
204
  });
205
+ updateCacheRules();
172
206
  hideDialog();
173
- }, [colorRules, conditionformat, generalDialog, hideDialog, protection, setContext, bold, italic, underline, strikethrough]);
207
+ }, [colorRules, conditionformat, generalDialog, hideDialog, protection, setContext, bold, italic, underline, strikethrough, type, editConditionFormatKey, editConditionFormatValue, editConditionRange]);
174
208
  useEffect(function () {
175
209
  setContext(function (ctx) {
176
210
  ctx.conditionRules.rulesType = type;
@@ -282,11 +316,11 @@ var ConditionRules = function ConditionRules(_a) {
282
316
  }
283
317
  }, matchedConditionFormatKey.map(function (key) {
284
318
  var _a, _b;
285
- console.log(allConditionFormats[key], allConditionFormats[key].format.cellColor);
286
319
  return /*#__PURE__*/React.createElement("div", {
287
320
  onClick: function onClick() {
288
321
  var _a;
289
322
  setEditConditionFormatKey(key);
323
+ editKeyRef.current = key;
290
324
  setType(allConditionFormats[key].conditionName);
291
325
  var rangeEdit = (_a = allConditionFormats[key].cellrange) === null || _a === void 0 ? void 0 : _a.map(function (range) {
292
326
  var startCol = numberToColumn(range.column[0] + 1);
@@ -361,6 +395,7 @@ var ConditionRules = function ConditionRules(_a) {
361
395
  setType("greaterThan");
362
396
  setCreate(true);
363
397
  setEditConditionFormatKey(null);
398
+ editKeyRef.current = null;
364
399
  buttonClickCreateRef.current = true;
365
400
  }
366
401
  }, "Add another rule"))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -422,6 +457,7 @@ var ConditionRules = function ConditionRules(_a) {
422
457
  setContext(function (ctx) {
423
458
  ctx.conditionRules.rulesValue = value;
424
459
  });
460
+ updateCacheRules();
425
461
  }
426
462
  }))), type === "between" && (/*#__PURE__*/React.createElement("div", {
427
463
  className: "w-full flex gap-2 items-center"
@@ -35,6 +35,7 @@ var ConditionRules = function ConditionRules(_a) {
35
35
  var _d = (0, _react.useState)(null),
36
36
  editConditionFormatKey = _d[0],
37
37
  setEditConditionFormatKey = _d[1];
38
+ var editKeyRef = (0, _react.useRef)(null);
38
39
  var _e = (0, _react.useState)(""),
39
40
  editConditionRange = _e[0],
40
41
  setEditConditionRange = _e[1];
@@ -104,6 +105,36 @@ var ConditionRules = function ConditionRules(_a) {
104
105
  setCreate(false);
105
106
  }
106
107
  }, [context]);
108
+ var updateCacheRules = function updateCacheRules() {
109
+ setContext(function (ctx) {
110
+ var index = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
111
+ ctx.luckysheetfile[index].conditionRules = {
112
+ rulesType: type || "",
113
+ rulesValue: ctx.conditionRules.rulesValue || "",
114
+ textColor: {
115
+ check: true,
116
+ color: colorRules.textColor
117
+ },
118
+ cellColor: {
119
+ check: true,
120
+ color: colorRules.cellColor
121
+ },
122
+ font: {
123
+ bold: bold,
124
+ italic: italic,
125
+ underline: underline,
126
+ strikethrough: strikethrough
127
+ },
128
+ betweenValue: ctx.conditionRules.betweenValue || {
129
+ value1: "",
130
+ value2: ""
131
+ },
132
+ dateValue: ctx.conditionRules.dateValue || "",
133
+ repeatValue: ctx.conditionRules.repeatValue || "0",
134
+ projectValue: ctx.conditionRules.projectValue || "10"
135
+ };
136
+ });
137
+ };
107
138
  var dataSelectRange = (0, _react.useCallback)(function (selectType) {
108
139
  hideDialog();
109
140
  setContext(function (ctx) {
@@ -114,7 +145,11 @@ var ConditionRules = function ConditionRules(_a) {
114
145
  ctx.rangeDialog.rangeTxt = ctx.conditionRules.rulesValue;
115
146
  ctx.rangeDialog.singleSelect = false;
116
147
  });
148
+ updateCacheRules();
117
149
  }, [colorRules.cellColor, colorRules.textColor, hideDialog, setContext]);
150
+ (0, _react.useEffect)(function () {
151
+ updateCacheRules();
152
+ }, [type, bold, italic, underline, strikethrough, colorRules]);
118
153
  var close = (0, _react.useCallback)(function (closeType) {
119
154
  if (closeType === "confirm") {
120
155
  buttonClickCreateRef.current = false;
@@ -137,8 +172,6 @@ var ConditionRules = function ConditionRules(_a) {
137
172
  buttonClickCreateRef.current = false;
138
173
  setCreate(false);
139
174
  setContext(function (ctx) {
140
- console.log(type, "tttttttt", ctx.conditionRules.rulesType);
141
- console.log(editConditionFormatKey, colorRules.textColor, colorRules.cellColor);
142
175
  ctx.conditionRules.rulesType = type;
143
176
  ctx.conditionRules.textColor.color = colorRules.textColor;
144
177
  ctx.conditionRules.cellColor.color = colorRules.cellColor;
@@ -178,8 +211,9 @@ var ConditionRules = function ConditionRules(_a) {
178
211
  projectValue: "10"
179
212
  };
180
213
  });
214
+ updateCacheRules();
181
215
  hideDialog();
182
- }, [colorRules, conditionformat, generalDialog, hideDialog, protection, setContext, bold, italic, underline, strikethrough]);
216
+ }, [colorRules, conditionformat, generalDialog, hideDialog, protection, setContext, bold, italic, underline, strikethrough, type, editConditionFormatKey, editConditionFormatValue, editConditionRange]);
183
217
  (0, _react.useEffect)(function () {
184
218
  setContext(function (ctx) {
185
219
  ctx.conditionRules.rulesType = type;
@@ -291,11 +325,11 @@ var ConditionRules = function ConditionRules(_a) {
291
325
  }
292
326
  }, matchedConditionFormatKey.map(function (key) {
293
327
  var _a, _b;
294
- console.log(allConditionFormats[key], allConditionFormats[key].format.cellColor);
295
328
  return /*#__PURE__*/_react.default.createElement("div", {
296
329
  onClick: function onClick() {
297
330
  var _a;
298
331
  setEditConditionFormatKey(key);
332
+ editKeyRef.current = key;
299
333
  setType(allConditionFormats[key].conditionName);
300
334
  var rangeEdit = (_a = allConditionFormats[key].cellrange) === null || _a === void 0 ? void 0 : _a.map(function (range) {
301
335
  var startCol = (0, _helper.numberToColumn)(range.column[0] + 1);
@@ -370,6 +404,7 @@ var ConditionRules = function ConditionRules(_a) {
370
404
  setType("greaterThan");
371
405
  setCreate(true);
372
406
  setEditConditionFormatKey(null);
407
+ editKeyRef.current = null;
373
408
  buttonClickCreateRef.current = true;
374
409
  }
375
410
  }, "Add another rule"))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
@@ -431,6 +466,7 @@ var ConditionRules = function ConditionRules(_a) {
431
466
  setContext(function (ctx) {
432
467
  ctx.conditionRules.rulesValue = value;
433
468
  });
469
+ updateCacheRules();
434
470
  }
435
471
  }))), type === "between" && (/*#__PURE__*/_react.default.createElement("div", {
436
472
  className: "w-full flex gap-2 items-center"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.72-condition-1",
3
+ "version": "1.2.73",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "module": "es/index.js",
@@ -16,7 +16,7 @@
16
16
  "tsc": "tsc"
17
17
  },
18
18
  "dependencies": {
19
- "@fileverse-dev/fortune-core": "1.2.72-condition-1",
19
+ "@fileverse-dev/fortune-core": "1.2.73",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",