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

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.
@@ -23,39 +23,49 @@ var ConditionRules = function ConditionRules(_a) {
23
23
  var buttonClickCreateRef = useRef(false);
24
24
  var textColorInputRef = useRef(null);
25
25
  var cellColorInputRef = useRef(null);
26
- var _d = useState([]),
27
- matchedConditionFormatKey = _d[0],
28
- setMatchedConditionFormatKey = _d[1];
29
- var _e = useState(null),
30
- allConditionFormats = _e[0],
31
- setAllConditionFormats = _e[1];
26
+ var _d = useState(null),
27
+ editConditionFormatKey = _d[0],
28
+ setEditConditionFormatKey = _d[1];
29
+ var _e = useState(""),
30
+ editConditionRange = _e[0],
31
+ setEditConditionRange = _e[1];
32
+ var _f = useState(null),
33
+ editConditionFormatValue = _f[0],
34
+ setEditConditionFormatValue = _f[1];
35
+ var _g = useState([]),
36
+ matchedConditionFormatKey = _g[0],
37
+ setMatchedConditionFormatKey = _g[1];
38
+ var _h = useState(null),
39
+ allConditionFormats = _h[0],
40
+ setAllConditionFormats = _h[1];
32
41
  var setContext = useContext(WorkbookContext).setContext;
33
42
  var hideDialog = useDialog().hideDialog;
34
- var _f = locale(context),
35
- conditionformat = _f.conditionformat,
36
- button = _f.button,
37
- protection = _f.protection,
38
- generalDialog = _f.generalDialog;
39
- var _g = useState({
43
+ var _j = locale(context),
44
+ conditionformat = _j.conditionformat,
45
+ button = _j.button,
46
+ protection = _j.protection,
47
+ generalDialog = _j.generalDialog;
48
+ var _k = useState({
40
49
  textColor: "#FFFFFF",
41
50
  cellColor: "#D82E2A"
42
51
  }),
43
- colorRules = _g[0],
44
- setColorRules = _g[1];
45
- var _h = useState(false),
46
- bold = _h[0],
47
- setBold = _h[1];
48
- var _j = useState(false),
49
- italic = _j[0],
50
- setItalic = _j[1];
51
- var _k = useState(false),
52
- underline = _k[0],
53
- setUnderline = _k[1];
52
+ colorRules = _k[0],
53
+ setColorRules = _k[1];
54
54
  var _l = useState(false),
55
- strikethrough = _l[0],
56
- setStrikethrough = _l[1];
55
+ bold = _l[0],
56
+ setBold = _l[1];
57
+ var _m = useState(false),
58
+ italic = _m[0],
59
+ setItalic = _m[1];
60
+ var _o = useState(false),
61
+ underline = _o[0],
62
+ setUnderline = _o[1];
63
+ var _p = useState(false),
64
+ strikethrough = _p[0],
65
+ setStrikethrough = _p[1];
57
66
  useEffect(function () {
58
67
  var _a, _b;
68
+ console.log("context", context);
59
69
  var index = getSheetIndex(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
60
70
  var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
61
71
  setAllConditionFormats(allCondition);
@@ -111,9 +121,26 @@ var ConditionRules = function ConditionRules(_a) {
111
121
  };
112
122
  setConditionRules(ctx, protection, generalDialog, conditionformat, ctx.conditionRules);
113
123
  });
114
- } else {
124
+ } else if (closeType === "close") {
115
125
  buttonClickCreateRef.current = true;
116
126
  setCreate(false);
127
+ } else if (closeType === "edit") {
128
+ buttonClickCreateRef.current = false;
129
+ setCreate(false);
130
+ setContext(function (ctx) {
131
+ console.log(type, "tttttttt", ctx.conditionRules.rulesType);
132
+ console.log(editConditionFormatKey, colorRules.textColor, colorRules.cellColor);
133
+ ctx.conditionRules.rulesType = type;
134
+ ctx.conditionRules.textColor.color = colorRules.textColor;
135
+ ctx.conditionRules.cellColor.color = colorRules.cellColor;
136
+ ctx.conditionRules.font = {
137
+ bold: bold,
138
+ italic: italic,
139
+ underline: underline,
140
+ strikethrough: strikethrough
141
+ };
142
+ setConditionRules(ctx, protection, generalDialog, conditionformat, ctx.conditionRules, true, editConditionFormatKey);
143
+ });
117
144
  }
118
145
  setContext(function (ctx) {
119
146
  ctx.conditionRules = {
@@ -255,7 +282,22 @@ var ConditionRules = function ConditionRules(_a) {
255
282
  }
256
283
  }, matchedConditionFormatKey.map(function (key) {
257
284
  var _a, _b;
285
+ console.log(allConditionFormats[key], allConditionFormats[key].format.cellColor);
258
286
  return /*#__PURE__*/React.createElement("div", {
287
+ onClick: function onClick() {
288
+ var _a;
289
+ setEditConditionFormatKey(key);
290
+ setType(allConditionFormats[key].conditionName);
291
+ var rangeEdit = (_a = allConditionFormats[key].cellrange) === null || _a === void 0 ? void 0 : _a.map(function (range) {
292
+ var startCol = numberToColumn(range.column[0] + 1);
293
+ var endCol = numberToColumn(range.column[1] + 1);
294
+ var startRow = range.row[0] + 1;
295
+ var endRow = range.row[1] + 1;
296
+ return "".concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
297
+ }).join(", ");
298
+ setEditConditionRange(rangeEdit);
299
+ setEditConditionFormatValue(allConditionFormats[key].conditionValue);
300
+ },
259
301
  className: "group flex items-center border-b border-gray-200 condition-list-parent",
260
302
  key: key
261
303
  }, /*#__PURE__*/React.createElement("div", {
@@ -273,6 +315,10 @@ var ConditionRules = function ConditionRules(_a) {
273
315
  style: {
274
316
  width: "200px",
275
317
  padding: "8px 0px"
318
+ },
319
+ onClick: function onClick() {
320
+ setCreate(true);
321
+ buttonClickCreateRef.current = true;
276
322
  }
277
323
  }, /*#__PURE__*/React.createElement("h3", {
278
324
  className: "condition-list-type"
@@ -300,7 +346,6 @@ var ConditionRules = function ConditionRules(_a) {
300
346
  setContext(function (ctx) {
301
347
  var index = getSheetIndex(ctx, ctx.currentSheetId);
302
348
  var ruleArr = ctx.luckysheetfile[index].luckysheet_conditionformat_save || [];
303
- console.log(matchedConditionFormatKey, ruleArr, allConditionFormats);
304
349
  ruleArr.splice(Number(key), 1);
305
350
  ctx.luckysheetfile[index].luckysheet_conditionformat_save = ruleArr;
306
351
  return ctx;
@@ -308,13 +353,17 @@ var ConditionRules = function ConditionRules(_a) {
308
353
  }
309
354
  })));
310
355
  })), /*#__PURE__*/React.createElement(Button, {
356
+ toggleLeftIcon: true,
357
+ leftIcon: "Plus",
311
358
  size: "md",
312
359
  variant: "secondary",
313
360
  onClick: function onClick() {
361
+ setType("greaterThan");
314
362
  setCreate(true);
363
+ setEditConditionFormatKey(null);
315
364
  buttonClickCreateRef.current = true;
316
365
  }
317
- }, "Create New Condition Format"))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
366
+ }, "Add another rule"))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
318
367
  className: "flex flex-col"
319
368
  }, /*#__PURE__*/React.createElement("div", {
320
369
  className: "condition-rules-value text-heading-xsm"
@@ -329,8 +378,9 @@ var ConditionRules = function ConditionRules(_a) {
329
378
  "aria-hidden": "true",
330
379
  readOnly: true,
331
380
  placeholder: conditionformat.selectRange,
332
- value: getDisplayedRangeTxt(context),
381
+ value: editConditionRange || getDisplayedRangeTxt(context),
333
382
  onClick: function onClick() {
383
+ setEditConditionRange(null);
334
384
  dataSelectRange("conditionRules".concat(type));
335
385
  }
336
386
  })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
@@ -365,8 +415,9 @@ var ConditionRules = function ConditionRules(_a) {
365
415
  onKeyDown: function onKeyDown(e) {
366
416
  e.stopPropagation();
367
417
  },
368
- value: context.conditionRules.rulesValue,
418
+ value: editConditionFormatValue || context.conditionRules.rulesValue,
369
419
  onChange: function onChange(e) {
420
+ setEditConditionFormatValue(null);
370
421
  var value = e.target.value;
371
422
  setContext(function (ctx) {
372
423
  ctx.conditionRules.rulesValue = value;
@@ -547,7 +598,8 @@ var ConditionRules = function ConditionRules(_a) {
547
598
  className: cn("fortune-toolbar-combo-button !min-w-fit !px-0", {}),
548
599
  style: {
549
600
  width: 30,
550
- height: 30
601
+ height: 30,
602
+ backgroundColor: strikethrough ? "hsl(var(--color-bg-default-selected))" : ""
551
603
  }
552
604
  }, /*#__PURE__*/React.createElement(LucideIcon, {
553
605
  name: "Strikethrough",
@@ -652,7 +704,16 @@ var ConditionRules = function ConditionRules(_a) {
652
704
  close("close");
653
705
  },
654
706
  tabIndex: 0
655
- }, button.cancel), /*#__PURE__*/React.createElement(Button, {
707
+ }, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/React.createElement(Button, {
708
+ variant: "default",
709
+ style: {
710
+ minWidth: "80px"
711
+ },
712
+ onClick: function onClick() {
713
+ close("edit");
714
+ },
715
+ tabIndex: 0
716
+ }, "Edit rule")) : (/*#__PURE__*/React.createElement(Button, {
656
717
  variant: "default",
657
718
  style: {
658
719
  minWidth: "80px"
@@ -661,6 +722,6 @@ var ConditionRules = function ConditionRules(_a) {
661
722
  close("confirm");
662
723
  },
663
724
  tabIndex: 0
664
- }, "Create rule")))));
725
+ }, "Create rule"))))));
665
726
  };
666
727
  export default ConditionRules;
@@ -32,39 +32,49 @@ var ConditionRules = function ConditionRules(_a) {
32
32
  var buttonClickCreateRef = (0, _react.useRef)(false);
33
33
  var textColorInputRef = (0, _react.useRef)(null);
34
34
  var cellColorInputRef = (0, _react.useRef)(null);
35
- var _d = (0, _react.useState)([]),
36
- matchedConditionFormatKey = _d[0],
37
- setMatchedConditionFormatKey = _d[1];
38
- var _e = (0, _react.useState)(null),
39
- allConditionFormats = _e[0],
40
- setAllConditionFormats = _e[1];
35
+ var _d = (0, _react.useState)(null),
36
+ editConditionFormatKey = _d[0],
37
+ setEditConditionFormatKey = _d[1];
38
+ var _e = (0, _react.useState)(""),
39
+ editConditionRange = _e[0],
40
+ setEditConditionRange = _e[1];
41
+ var _f = (0, _react.useState)(null),
42
+ editConditionFormatValue = _f[0],
43
+ setEditConditionFormatValue = _f[1];
44
+ var _g = (0, _react.useState)([]),
45
+ matchedConditionFormatKey = _g[0],
46
+ setMatchedConditionFormatKey = _g[1];
47
+ var _h = (0, _react.useState)(null),
48
+ allConditionFormats = _h[0],
49
+ setAllConditionFormats = _h[1];
41
50
  var setContext = (0, _react.useContext)(_context.default).setContext;
42
51
  var hideDialog = (0, _useDialog.useDialog)().hideDialog;
43
- var _f = (0, _fortuneCore.locale)(context),
44
- conditionformat = _f.conditionformat,
45
- button = _f.button,
46
- protection = _f.protection,
47
- generalDialog = _f.generalDialog;
48
- var _g = (0, _react.useState)({
52
+ var _j = (0, _fortuneCore.locale)(context),
53
+ conditionformat = _j.conditionformat,
54
+ button = _j.button,
55
+ protection = _j.protection,
56
+ generalDialog = _j.generalDialog;
57
+ var _k = (0, _react.useState)({
49
58
  textColor: "#FFFFFF",
50
59
  cellColor: "#D82E2A"
51
60
  }),
52
- colorRules = _g[0],
53
- setColorRules = _g[1];
54
- var _h = (0, _react.useState)(false),
55
- bold = _h[0],
56
- setBold = _h[1];
57
- var _j = (0, _react.useState)(false),
58
- italic = _j[0],
59
- setItalic = _j[1];
60
- var _k = (0, _react.useState)(false),
61
- underline = _k[0],
62
- setUnderline = _k[1];
61
+ colorRules = _k[0],
62
+ setColorRules = _k[1];
63
63
  var _l = (0, _react.useState)(false),
64
- strikethrough = _l[0],
65
- setStrikethrough = _l[1];
64
+ bold = _l[0],
65
+ setBold = _l[1];
66
+ var _m = (0, _react.useState)(false),
67
+ italic = _m[0],
68
+ setItalic = _m[1];
69
+ var _o = (0, _react.useState)(false),
70
+ underline = _o[0],
71
+ setUnderline = _o[1];
72
+ var _p = (0, _react.useState)(false),
73
+ strikethrough = _p[0],
74
+ setStrikethrough = _p[1];
66
75
  (0, _react.useEffect)(function () {
67
76
  var _a, _b;
77
+ console.log("context", context);
68
78
  var index = (0, _fortuneCore.getSheetIndex)(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
69
79
  var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
70
80
  setAllConditionFormats(allCondition);
@@ -120,9 +130,26 @@ var ConditionRules = function ConditionRules(_a) {
120
130
  };
121
131
  (0, _fortuneCore.setConditionRules)(ctx, protection, generalDialog, conditionformat, ctx.conditionRules);
122
132
  });
123
- } else {
133
+ } else if (closeType === "close") {
124
134
  buttonClickCreateRef.current = true;
125
135
  setCreate(false);
136
+ } else if (closeType === "edit") {
137
+ buttonClickCreateRef.current = false;
138
+ setCreate(false);
139
+ setContext(function (ctx) {
140
+ console.log(type, "tttttttt", ctx.conditionRules.rulesType);
141
+ console.log(editConditionFormatKey, colorRules.textColor, colorRules.cellColor);
142
+ ctx.conditionRules.rulesType = type;
143
+ ctx.conditionRules.textColor.color = colorRules.textColor;
144
+ ctx.conditionRules.cellColor.color = colorRules.cellColor;
145
+ ctx.conditionRules.font = {
146
+ bold: bold,
147
+ italic: italic,
148
+ underline: underline,
149
+ strikethrough: strikethrough
150
+ };
151
+ (0, _fortuneCore.setConditionRules)(ctx, protection, generalDialog, conditionformat, ctx.conditionRules, true, editConditionFormatKey);
152
+ });
126
153
  }
127
154
  setContext(function (ctx) {
128
155
  ctx.conditionRules = {
@@ -264,7 +291,22 @@ var ConditionRules = function ConditionRules(_a) {
264
291
  }
265
292
  }, matchedConditionFormatKey.map(function (key) {
266
293
  var _a, _b;
294
+ console.log(allConditionFormats[key], allConditionFormats[key].format.cellColor);
267
295
  return /*#__PURE__*/_react.default.createElement("div", {
296
+ onClick: function onClick() {
297
+ var _a;
298
+ setEditConditionFormatKey(key);
299
+ setType(allConditionFormats[key].conditionName);
300
+ var rangeEdit = (_a = allConditionFormats[key].cellrange) === null || _a === void 0 ? void 0 : _a.map(function (range) {
301
+ var startCol = (0, _helper.numberToColumn)(range.column[0] + 1);
302
+ var endCol = (0, _helper.numberToColumn)(range.column[1] + 1);
303
+ var startRow = range.row[0] + 1;
304
+ var endRow = range.row[1] + 1;
305
+ return "".concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
306
+ }).join(", ");
307
+ setEditConditionRange(rangeEdit);
308
+ setEditConditionFormatValue(allConditionFormats[key].conditionValue);
309
+ },
268
310
  className: "group flex items-center border-b border-gray-200 condition-list-parent",
269
311
  key: key
270
312
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -282,6 +324,10 @@ var ConditionRules = function ConditionRules(_a) {
282
324
  style: {
283
325
  width: "200px",
284
326
  padding: "8px 0px"
327
+ },
328
+ onClick: function onClick() {
329
+ setCreate(true);
330
+ buttonClickCreateRef.current = true;
285
331
  }
286
332
  }, /*#__PURE__*/_react.default.createElement("h3", {
287
333
  className: "condition-list-type"
@@ -309,7 +355,6 @@ var ConditionRules = function ConditionRules(_a) {
309
355
  setContext(function (ctx) {
310
356
  var index = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
311
357
  var ruleArr = ctx.luckysheetfile[index].luckysheet_conditionformat_save || [];
312
- console.log(matchedConditionFormatKey, ruleArr, allConditionFormats);
313
358
  ruleArr.splice(Number(key), 1);
314
359
  ctx.luckysheetfile[index].luckysheet_conditionformat_save = ruleArr;
315
360
  return ctx;
@@ -317,13 +362,17 @@ var ConditionRules = function ConditionRules(_a) {
317
362
  }
318
363
  })));
319
364
  })), /*#__PURE__*/_react.default.createElement(_ui.Button, {
365
+ toggleLeftIcon: true,
366
+ leftIcon: "Plus",
320
367
  size: "md",
321
368
  variant: "secondary",
322
369
  onClick: function onClick() {
370
+ setType("greaterThan");
323
371
  setCreate(true);
372
+ setEditConditionFormatKey(null);
324
373
  buttonClickCreateRef.current = true;
325
374
  }
326
- }, "Create New Condition Format"))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
375
+ }, "Add another rule"))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
327
376
  className: "flex flex-col"
328
377
  }, /*#__PURE__*/_react.default.createElement("div", {
329
378
  className: "condition-rules-value text-heading-xsm"
@@ -338,8 +387,9 @@ var ConditionRules = function ConditionRules(_a) {
338
387
  "aria-hidden": "true",
339
388
  readOnly: true,
340
389
  placeholder: conditionformat.selectRange,
341
- value: (0, _getDisplayedRangeTxt.getDisplayedRangeTxt)(context),
390
+ value: editConditionRange || (0, _getDisplayedRangeTxt.getDisplayedRangeTxt)(context),
342
391
  onClick: function onClick() {
392
+ setEditConditionRange(null);
343
393
  dataSelectRange("conditionRules".concat(type));
344
394
  }
345
395
  })), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
@@ -374,8 +424,9 @@ var ConditionRules = function ConditionRules(_a) {
374
424
  onKeyDown: function onKeyDown(e) {
375
425
  e.stopPropagation();
376
426
  },
377
- value: context.conditionRules.rulesValue,
427
+ value: editConditionFormatValue || context.conditionRules.rulesValue,
378
428
  onChange: function onChange(e) {
429
+ setEditConditionFormatValue(null);
379
430
  var value = e.target.value;
380
431
  setContext(function (ctx) {
381
432
  ctx.conditionRules.rulesValue = value;
@@ -556,7 +607,8 @@ var ConditionRules = function ConditionRules(_a) {
556
607
  className: (0, _ui.cn)("fortune-toolbar-combo-button !min-w-fit !px-0", {}),
557
608
  style: {
558
609
  width: 30,
559
- height: 30
610
+ height: 30,
611
+ backgroundColor: strikethrough ? "hsl(var(--color-bg-default-selected))" : ""
560
612
  }
561
613
  }, /*#__PURE__*/_react.default.createElement(_ui.LucideIcon, {
562
614
  name: "Strikethrough",
@@ -661,7 +713,16 @@ var ConditionRules = function ConditionRules(_a) {
661
713
  close("close");
662
714
  },
663
715
  tabIndex: 0
664
- }, button.cancel), /*#__PURE__*/_react.default.createElement(_ui.Button, {
716
+ }, button.cancel), editConditionFormatKey !== null ? (/*#__PURE__*/_react.default.createElement(_ui.Button, {
717
+ variant: "default",
718
+ style: {
719
+ minWidth: "80px"
720
+ },
721
+ onClick: function onClick() {
722
+ close("edit");
723
+ },
724
+ tabIndex: 0
725
+ }, "Edit rule")) : (/*#__PURE__*/_react.default.createElement(_ui.Button, {
665
726
  variant: "default",
666
727
  style: {
667
728
  minWidth: "80px"
@@ -670,6 +731,6 @@ var ConditionRules = function ConditionRules(_a) {
670
731
  close("confirm");
671
732
  },
672
733
  tabIndex: 0
673
- }, "Create rule")))));
734
+ }, "Create rule"))))));
674
735
  };
675
736
  var _default = exports.default = ConditionRules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.70",
3
+ "version": "1.2.72-condition-1",
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.70",
19
+ "@fileverse-dev/fortune-core": "1.2.72-condition-1",
20
20
  "@fileverse/ui": "^4.1.7-patch-40",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",