@fileverse-dev/fortune-react 1.2.98 → 1.2.99-data-validation-fix-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.
Files changed (39) hide show
  1. package/es/components/ConditionFormat/ConditionRules.d.ts +0 -1
  2. package/es/components/ConditionFormat/ConditionRules.js +21 -12
  3. package/es/components/ConditionFormat/index.js +2 -2
  4. package/es/components/DataVerification/RangeDialog.js +19 -8
  5. package/es/components/DataVerification/helpers.d.ts +9 -0
  6. package/es/components/DataVerification/helpers.js +69 -0
  7. package/es/components/DataVerification/index.js +80 -43
  8. package/es/components/Dialog/index.js +24 -10
  9. package/es/components/ErrorState/index.js +6 -3
  10. package/es/components/LinkEidtCard/index.js +21 -12
  11. package/es/components/SheetOverlay/FormulaHint/index.js +48 -33
  12. package/es/components/SheetTab/SheetItem.js +29 -16
  13. package/es/components/SheetTab/index.js +35 -20
  14. package/es/components/Toolbar/Button.js +10 -3
  15. package/es/components/Toolbar/Combo.js +10 -2
  16. package/es/components/Toolbar/CustomButton.js +12 -3
  17. package/es/components/Toolbar/Select.js +7 -1
  18. package/es/components/Workbook/api.d.ts +0 -1
  19. package/es/components/Workbook/index.d.ts +0 -1
  20. package/lib/components/ConditionFormat/ConditionRules.d.ts +0 -1
  21. package/lib/components/ConditionFormat/ConditionRules.js +21 -12
  22. package/lib/components/ConditionFormat/index.js +2 -2
  23. package/lib/components/DataVerification/RangeDialog.js +19 -8
  24. package/lib/components/DataVerification/helpers.d.ts +9 -0
  25. package/lib/components/DataVerification/helpers.js +76 -0
  26. package/lib/components/DataVerification/index.js +80 -43
  27. package/lib/components/Dialog/index.js +24 -10
  28. package/lib/components/ErrorState/index.js +6 -3
  29. package/lib/components/LinkEidtCard/index.js +21 -12
  30. package/lib/components/SheetOverlay/FormulaHint/index.js +48 -33
  31. package/lib/components/SheetTab/SheetItem.js +29 -16
  32. package/lib/components/SheetTab/index.js +35 -20
  33. package/lib/components/Toolbar/Button.js +10 -3
  34. package/lib/components/Toolbar/Combo.js +10 -2
  35. package/lib/components/Toolbar/CustomButton.js +12 -3
  36. package/lib/components/Toolbar/Select.js +7 -1
  37. package/lib/components/Workbook/api.d.ts +0 -1
  38. package/lib/components/Workbook/index.d.ts +0 -1
  39. package/package.json +2 -2
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import "./index.css";
3
3
  import "./formating.css";
4
4
  declare const ConditionRules: React.FC<{
5
- type?: string;
6
5
  context?: any;
7
6
  }>;
8
7
  export default ConditionRules;
@@ -11,9 +11,7 @@ import { injectDatepickerStyles } from "../../utils/datepickerStyles";
11
11
  import "./formating.css";
12
12
  injectDatepickerStyles();
13
13
  var ConditionRules = function ConditionRules(_a) {
14
- var rulesType = _a.type,
15
- context = _a.context;
16
- console.log("rulesType", rulesType);
14
+ var context = _a.context;
17
15
  var _b = useState("greaterThan"),
18
16
  type = _b[0],
19
17
  setType = _b[1];
@@ -360,8 +358,10 @@ var ConditionRules = function ConditionRules(_a) {
360
358
  setEditConditionRange(rangeEdit);
361
359
  setEditConditionFormatValue(allConditionFormats[key].conditionValue);
362
360
  },
363
- className: "group flex items-center border-b border-gray-200 condition-list-parent",
364
- key: key
361
+ className: "group flex items-center border-b border-gray-200 condition-list-parent fortune-condition-rules__item fortune-condition-rules__item--".concat(String(key).replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-")),
362
+ "data-condition-key": key,
363
+ key: key,
364
+ "data-testid": "condition-rules-item-".concat(key)
365
365
  }, /*#__PURE__*/React.createElement("div", {
366
366
  className: "condition-list-pill",
367
367
  style: {
@@ -383,9 +383,11 @@ var ConditionRules = function ConditionRules(_a) {
383
383
  buttonClickCreateRef.current = true;
384
384
  }
385
385
  }, /*#__PURE__*/React.createElement("h3", {
386
- className: "condition-list-type"
386
+ className: "fortune-condition-rules__heading condition-list-type",
387
+ "data-testid": "condition-rules-heading-".concat(key)
387
388
  }, conditionformat[allConditionFormats[key].conditionName], " ", (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]), /*#__PURE__*/React.createElement("p", {
388
- className: "condition-list-range"
389
+ className: "fortune-condition-rules__para condition-list-range",
390
+ "data-testid": "condition-rules-para-".concat(key)
389
391
  }, (_b = allConditionFormats[key].cellrange) === null || _b === void 0 ? void 0 : _b.map(function (range) {
390
392
  var startCol = numberToColumn(range.column[0] + 1);
391
393
  var endCol = numberToColumn(range.column[1] + 1);
@@ -393,12 +395,15 @@ var ConditionRules = function ConditionRules(_a) {
393
395
  var endRow = range.row[1] + 1;
394
396
  return "".concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
395
397
  }).join(", "))), /*#__PURE__*/React.createElement("div", {
396
- className: "opacity-0 group-hover:opacity-100 transition-opacity"
398
+ className: "fortune-condition-rules__icon fortune-condition-rules__action opacity-0 group-hover:opacity-100 transition-opacity",
399
+ "data-condition-key": key,
400
+ "data-testid": "condition-rules-action-delete-".concat(key)
397
401
  }, /*#__PURE__*/React.createElement(IconButton, {
398
402
  elevation: 1,
399
403
  icon: "Trash2",
400
404
  size: "md",
401
405
  variant: "secondary",
406
+ className: "fortune-condition-rules__icon--trash",
402
407
  style: {
403
408
  border: "0px",
404
409
  boxShadow: "none",
@@ -419,6 +424,7 @@ var ConditionRules = function ConditionRules(_a) {
419
424
  leftIcon: "Plus",
420
425
  size: "md",
421
426
  variant: "secondary",
427
+ className: "fortune-condition-rules__cta fortune-condition-rules__cta--add",
422
428
  onClick: function onClick() {
423
429
  setType("greaterThan");
424
430
  setCreate(true);
@@ -432,11 +438,13 @@ var ConditionRules = function ConditionRules(_a) {
432
438
  });
433
439
  editKeyRef.current = null;
434
440
  buttonClickCreateRef.current = true;
435
- }
441
+ },
442
+ "data-testid": "condition-rules-cta-add"
436
443
  }, "Add another rule"))) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
437
- className: "flex flex-col"
444
+ className: "flex flex-col fortune-condition-rules__form"
438
445
  }, /*#__PURE__*/React.createElement("div", {
439
- className: "condition-rules-value text-heading-xsm"
446
+ className: "fortune-condition-rules__info condition-rules-value text-heading-xsm",
447
+ "data-testid": "condition-rules-info-range"
440
448
  }, conditionformat.applyRange, " range"), /*#__PURE__*/React.createElement(TextField, {
441
449
  rightIcon: /*#__PURE__*/React.createElement(LucideIcon, {
442
450
  name: "Grid2x2",
@@ -454,7 +462,8 @@ var ConditionRules = function ConditionRules(_a) {
454
462
  dataSelectRange("conditionRules".concat(type));
455
463
  }
456
464
  })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
457
- className: "condition-rules-value text-heading-xsm"
465
+ className: "fortune-condition-rules__heading-sm condition-rules-value text-heading-xsm",
466
+ "data-testid": "condition-rules-heading-format"
458
467
  }, "Format cells if"), /*#__PURE__*/React.createElement(Select, {
459
468
  value: type,
460
469
  onValueChange: function onValueChange(value) {
@@ -120,7 +120,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
120
120
  onClick: function onClick() {
121
121
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
122
122
  showDialog(/*#__PURE__*/React.createElement(ConditionRules, {
123
- type: v.text
123
+ context: context
124
124
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
125
125
  },
126
126
  tabIndex: 0
@@ -167,7 +167,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
167
167
  onClick: function onClick() {
168
168
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
169
169
  showDialog(/*#__PURE__*/React.createElement(ConditionRules, {
170
- type: v.text
170
+ context: context
171
171
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
172
172
  },
173
173
  tabIndex: 0
@@ -38,7 +38,8 @@ var RangeDialog = function RangeDialog() {
38
38
  }, [context, context.luckysheet_select_save]);
39
39
  return /*#__PURE__*/React.createElement("div", {
40
40
  id: "range-dialog",
41
- className: "fortune-dialog",
41
+ className: "fortune-dialog fortune-range-dialog",
42
+ "data-testid": "range-dialog",
42
43
  onClick: function onClick(e) {
43
44
  return e.stopPropagation();
44
45
  },
@@ -56,32 +57,41 @@ var RangeDialog = function RangeDialog() {
56
57
  },
57
58
  tabIndex: 0
58
59
  }, /*#__PURE__*/React.createElement("div", {
59
- className: cn("flex items-center justify-between border-b color-border-default py-3 px-6")
60
+ className: cn("fortune-range-dialog__header flex items-center justify-between border-b color-border-default py-3 px-6"),
61
+ "data-testid": "range-dialog-header"
60
62
  }, /*#__PURE__*/React.createElement("div", {
61
- className: "text-heading-sm"
63
+ className: "fortune-range-dialog__heading text-heading-sm",
64
+ "data-testid": "range-dialog-heading"
62
65
  }, dataVerification.selectCellRange), /*#__PURE__*/React.createElement(IconButton, {
63
66
  icon: "X",
64
67
  variant: "ghost",
65
68
  onClick: close,
66
- tabIndex: 0
69
+ tabIndex: 0,
70
+ className: "fortune-range-dialog__icon fortune-range-dialog__icon--close",
71
+ "data-testid": "range-dialog-icon-close"
67
72
  })), /*#__PURE__*/React.createElement("div", {
68
- className: "px-6 pb-6 pt-4 text-body-sm"
73
+ className: "fortune-range-dialog__para px-6 pb-6 pt-4 text-body-sm",
74
+ "data-testid": "range-dialog-para"
69
75
  }, /*#__PURE__*/React.createElement(TextField, {
70
76
  className: "w-full",
71
77
  readOnly: true,
72
78
  placeholder: dataVerification.selectCellRange2,
73
79
  value: rangeTxt2
74
80
  })), /*#__PURE__*/React.createElement("div", {
75
- className: "px-6 pb-6 flex flex-row gap-2 justify-end"
81
+ className: "fortune-range-dialog__actions px-6 pb-6 flex flex-row gap-2 justify-end",
82
+ "data-testid": "range-dialog-actions"
76
83
  }, /*#__PURE__*/React.createElement(Button, {
77
84
  variant: "secondary",
85
+ className: "fortune-range-dialog__cta fortune-range-dialog__cta--close",
78
86
  style: {
79
87
  minWidth: "80px"
80
88
  },
81
89
  onClick: close,
82
- tabIndex: 0
90
+ tabIndex: 0,
91
+ "data-testid": "range-dialog-cta-close"
83
92
  }, button.close), /*#__PURE__*/React.createElement(Button, {
84
93
  variant: "default",
94
+ className: "fortune-range-dialog__cta fortune-range-dialog__cta--confirm",
85
95
  style: {
86
96
  minWidth: "80px"
87
97
  },
@@ -91,7 +101,8 @@ var RangeDialog = function RangeDialog() {
91
101
  });
92
102
  close();
93
103
  },
94
- tabIndex: 0
104
+ tabIndex: 0,
105
+ "data-testid": "range-dialog-cta-confirm"
95
106
  }, button.confirm)));
96
107
  };
97
108
  export default RangeDialog;
@@ -0,0 +1,9 @@
1
+ import { Context } from "@fileverse-dev/fortune-core";
2
+ export declare function findMatchingCells(ctx: Context, currentRow: number, currentCol: number): {
3
+ row: number;
4
+ col: number;
5
+ }[];
6
+ export declare function cellsToRangeString(ctx: Context, cells: {
7
+ row: number;
8
+ col: number;
9
+ }[]): string;
@@ -0,0 +1,69 @@
1
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { getSheetIndex, getRangetxt, indexToColumnChar } from "@fileverse-dev/fortune-core";
11
+ export function findMatchingCells(ctx, currentRow, currentCol) {
12
+ var _a;
13
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
14
+ var dataVerification = (_a = ctx.luckysheetfile[sheetIndex].dataVerification) !== null && _a !== void 0 ? _a : {};
15
+ var currentValidation = dataVerification["".concat(currentRow, "_").concat(currentCol)];
16
+ if (!currentValidation) return [];
17
+ var matchingCells = [];
18
+ Object.keys(dataVerification).forEach(function (key) {
19
+ var _a = key.split("_").map(Number),
20
+ r = _a[0],
21
+ c = _a[1];
22
+ var validation = dataVerification[key];
23
+ if (validation.type === currentValidation.type && validation.type2 === currentValidation.type2 && validation.value1 === currentValidation.value1 && validation.value2 === currentValidation.value2 && validation.color === currentValidation.color && validation.validity === currentValidation.validity && validation.remote === currentValidation.remote && validation.prohibitInput === currentValidation.prohibitInput && validation.hintShow === currentValidation.hintShow && validation.hintValue === currentValidation.hintValue) {
24
+ matchingCells.push({
25
+ row: r,
26
+ col: c
27
+ });
28
+ }
29
+ });
30
+ return matchingCells;
31
+ }
32
+ export function cellsToRangeString(ctx, cells) {
33
+ if (cells.length === 0) return "";
34
+ if (cells.length === 1) {
35
+ return indexToColumnChar(cells[0].col) + (cells[0].row + 1);
36
+ }
37
+ var sorted = __spreadArray([], cells, true).sort(function (a, b) {
38
+ return a.row === b.row ? a.col - b.col : a.row - b.row;
39
+ });
40
+ var ranges = [];
41
+ var startRow = sorted[0].row;
42
+ var endRow = sorted[0].row;
43
+ var startCol = sorted[0].col;
44
+ var endCol = sorted[0].col;
45
+ for (var i = 1; i < sorted.length; i++) {
46
+ var _a = sorted[i],
47
+ row = _a.row,
48
+ col = _a.col;
49
+ if (col === startCol && col === endCol && row === endRow + 1) {
50
+ endRow = row;
51
+ } else if (row === startRow && row === endRow && col === endCol + 1) {
52
+ endCol = col;
53
+ } else {
54
+ var range_1 = getRangetxt(ctx, ctx.currentSheetId, {
55
+ row: [startRow, endRow],
56
+ column: [startCol, endCol]
57
+ });
58
+ ranges.push(range_1);
59
+ startRow = endRow = row;
60
+ startCol = endCol = col;
61
+ }
62
+ }
63
+ var range = getRangetxt(ctx, ctx.currentSheetId, {
64
+ row: [startRow, endRow],
65
+ column: [startCol, endCol]
66
+ });
67
+ ranges.push(range);
68
+ return ranges.join(",");
69
+ }
@@ -15,6 +15,7 @@ import DynamicInputList from "./DropdownOption";
15
15
  import WorkbookContext from "../../context";
16
16
  import { useDialog } from "../../hooks/useDialog";
17
17
  import { injectDatepickerStyles } from "../../utils/datepickerStyles";
18
+ import { findMatchingCells, cellsToRangeString } from "./helpers";
18
19
  import "./index.css";
19
20
  function createId() {
20
21
  return "".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
@@ -33,7 +34,7 @@ var DataVerification = function DataVerification() {
33
34
  button = _r.button,
34
35
  generalDialog = _r.generalDialog;
35
36
  var dateCondition = useState(["between", "notBetween", "equal", "notEqualTo", "earlierThan", "noEarlierThan", "laterThan", "noLaterThan"])[0];
36
- function getSheetIndex() {
37
+ var getSheetIndex = useCallback(function () {
37
38
  var _a;
38
39
  for (var i = 0; i < context.luckysheetfile.length; i += 1) {
39
40
  if (((_a = context.luckysheetfile[i]) === null || _a === void 0 ? void 0 : _a.id) === context.currentSheetId) {
@@ -41,7 +42,7 @@ var DataVerification = function DataVerification() {
41
42
  }
42
43
  }
43
44
  return null;
44
- }
45
+ }, [context.luckysheetfile, context.currentSheetId]);
45
46
  var _s = useState([]),
46
47
  optionItems = _s[0],
47
48
  setOptionItems = _s[1];
@@ -92,45 +93,68 @@ var DataVerification = function DataVerification() {
92
93
  ctx.rangeDialog.rangeTxt = value;
93
94
  });
94
95
  }, [hideDialog, setContext]);
96
+ var applyValidation = useCallback(function (rangeString) {
97
+ setContext(function (ctx) {
98
+ var _a;
99
+ var range = getRangeByTxt(ctx, rangeString);
100
+ if (range.length === 0) {
101
+ return;
102
+ }
103
+ var regulation = ctx.dataVerification.dataRegulation;
104
+ var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
105
+ var value1 = regulation.value1;
106
+ var item = __assign(__assign({}, regulation), {
107
+ checked: false
108
+ });
109
+ if (verifacationT === "dropdown") {
110
+ var list = getDropdownList(ctx, value1);
111
+ item.value1 = list.join(",");
112
+ }
113
+ var currentDataVerification = (_a = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _a !== void 0 ? _a : {};
114
+ var d = getFlowdata(ctx);
115
+ if (!d) return;
116
+ for (var ri = 0; ri < range.length; ri += 1) {
117
+ var str = range[ri].row[0];
118
+ var edr = range[ri].row[1];
119
+ var stc = range[ri].column[0];
120
+ var edc = range[ri].column[1];
121
+ for (var r = str; r <= edr; r += 1) {
122
+ for (var c = stc; c <= edc; c += 1) {
123
+ var key = "".concat(r, "_").concat(c);
124
+ currentDataVerification[key] = item;
125
+ if (regulation.type === "checkbox") {
126
+ setCellValue(ctx, r, c, d, item.value2);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
132
+ ctx.dataVerification.updateScope = undefined;
133
+ ctx.dataVerification.sourceCell = undefined;
134
+ });
135
+ }, [getSheetIndex, setContext]);
95
136
  var btn = useCallback(function (type) {
137
+ var _a, _b, _c;
96
138
  if (type === "confirm") {
97
- setContext(function (ctx) {
98
- var _a, _b, _c;
99
- var isPass = confirmMessage(ctx, generalDialog, dataVerification);
100
- if (isPass) {
101
- var range = getRangeByTxt(ctx, (_b = (_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.dataRegulation) === null || _b === void 0 ? void 0 : _b.rangeTxt);
102
- if (range.length === 0) {
103
- return;
104
- }
105
- var regulation = ctx.dataVerification.dataRegulation;
106
- var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
107
- var value1 = regulation.value1;
108
- var item = __assign(__assign({}, regulation), {
109
- checked: false
139
+ var isValid = confirmMessage(context, generalDialog, dataVerification);
140
+ if (!isValid) return;
141
+ var sourceCell = (_a = context.dataVerification) === null || _a === void 0 ? void 0 : _a.sourceCell;
142
+ var modalRangeString_1 = (_c = (_b = context.dataVerification) === null || _b === void 0 ? void 0 : _b.dataRegulation) === null || _c === void 0 ? void 0 : _c.rangeTxt;
143
+ if (sourceCell) {
144
+ var matchingCells = findMatchingCells(context, sourceCell.row, sourceCell.col);
145
+ if (matchingCells.length > 1) {
146
+ var allMatchingRange_1 = cellsToRangeString(context, matchingCells);
147
+ showDialog("Found ".concat(matchingCells.length, " cells with matching validation. Apply changes to:"), "yesno", "Apply Changes", "All Matching Cells", "Just Selected Range", function () {
148
+ applyValidation(allMatchingRange_1);
149
+ hideDialog();
150
+ }, function () {
151
+ applyValidation(modalRangeString_1);
152
+ hideDialog();
110
153
  });
111
- if (verifacationT === "dropdown") {
112
- var list = getDropdownList(ctx, value1);
113
- item.value1 = list.join(",");
114
- }
115
- var currentDataVerification = (_c = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _c !== void 0 ? _c : {};
116
- var str = range[range.length - 1].row[0];
117
- var edr = range[range.length - 1].row[1];
118
- var stc = range[range.length - 1].column[0];
119
- var edc = range[range.length - 1].column[1];
120
- var d = getFlowdata(ctx);
121
- if (!d) return;
122
- for (var r = str; r <= edr; r += 1) {
123
- for (var c = stc; c <= edc; c += 1) {
124
- var key = "".concat(r, "_").concat(c);
125
- currentDataVerification[key] = item;
126
- if (regulation.type === "checkbox") {
127
- setCellValue(ctx, r, c, d, item.value2);
128
- }
129
- }
130
- }
131
- ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
154
+ return;
132
155
  }
133
- });
156
+ }
157
+ applyValidation(modalRangeString_1);
134
158
  } else if (type === "delete") {
135
159
  setContext(function (ctx) {
136
160
  var _a, _b, _c;
@@ -149,17 +173,26 @@ var DataVerification = function DataVerification() {
149
173
  delete currentDataVerification["".concat(r, "_").concat(c)];
150
174
  }
151
175
  }
176
+ ctx.dataVerification.updateScope = undefined;
152
177
  });
153
178
  }
154
179
  hideDialog();
155
- }, [dataVerification, generalDialog, hideDialog, setContext, showDialog]);
180
+ }, [applyValidation, context, dataVerification, generalDialog, getSheetIndex, hideDialog, setContext, showDialog]);
156
181
  useEffect(function () {
157
182
  setContext(function (ctx) {
158
- var _a, _b, _c;
183
+ var _a, _b, _c, _d;
159
184
  var rangeT = "";
185
+ var updateScope = ((_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.updateScope) || "current";
160
186
  if (ctx.luckysheet_select_save) {
161
187
  var range = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
162
- rangeT = getRangetxt(context, context.currentSheetId, range, context.currentSheetId);
188
+ var rowIndex = range.row_focus;
189
+ var colIndex = range.column_focus;
190
+ if (updateScope === "all" && rowIndex != null && colIndex != null) {
191
+ var matchingCells = findMatchingCells(ctx, rowIndex, colIndex);
192
+ rangeT = cellsToRangeString(ctx, matchingCells);
193
+ } else {
194
+ rangeT = getRangetxt(context, context.currentSheetId, range, context.currentSheetId);
195
+ }
163
196
  }
164
197
  var index = getSheetIndex();
165
198
  var ctxDataVerification = ctx.luckysheetfile[index].dataVerification;
@@ -169,13 +202,17 @@ var DataVerification = function DataVerification() {
169
202
  var rowIndex = last.row_focus;
170
203
  var colIndex = last.column_focus;
171
204
  if (rowIndex == null || colIndex == null) return;
205
+ ctx.dataVerification.sourceCell = {
206
+ row: rowIndex,
207
+ col: colIndex
208
+ };
172
209
  var item = ctxDataVerification["".concat(rowIndex, "_").concat(colIndex)];
173
210
  var defaultItem = item !== null && item !== void 0 ? item : {};
174
- var rangValue = (_a = defaultItem.value1) !== null && _a !== void 0 ? _a : "";
175
- if (((_b = ctx.rangeDialog) === null || _b === void 0 ? void 0 : _b.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
211
+ var rangValue = (_b = defaultItem.value1) !== null && _b !== void 0 ? _b : "";
212
+ if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
176
213
  rangeT = ctx.dataVerification.dataRegulation.rangeTxt;
177
214
  rangValue = ctx.rangeDialog.rangeTxt;
178
- } else if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
215
+ } else if (((_d = ctx.rangeDialog) === null || _d === void 0 ? void 0 : _d.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
179
216
  rangValue = ctx.dataVerification.dataRegulation.value1;
180
217
  rangeT = ctx.rangeDialog.rangeTxt;
181
218
  }
@@ -27,46 +27,60 @@ var Dialog = function Dialog(_a) {
27
27
  var button = locale(context).button;
28
28
  return /*#__PURE__*/React.createElement("div", {
29
29
  className: "fortune-dialog",
30
+ "data-testid": "dialog",
30
31
  style: __assign(__assign({}, containerStyle), ["Data validation", "Split text to columns", "Resize column"].includes(title) ? {
31
32
  maxWidth: "unset"
32
33
  } : {})
33
34
  }, /*#__PURE__*/React.createElement("div", {
34
- className: cn("flex items-center justify-between border-b color-border-default py-3 px-6")
35
+ className: cn("fortune-dialog__header flex items-center justify-between border-b color-border-default py-3 px-6"),
36
+ "data-testid": "dialog-header"
35
37
  }, title ? (/*#__PURE__*/React.createElement("div", {
36
- className: "text-heading-sm"
38
+ className: "fortune-dialog__heading text-heading-sm",
39
+ "data-testid": "dialog-heading"
37
40
  }, title)) : (/*#__PURE__*/React.createElement("div", {
38
- className: "text-heading-sm"
41
+ className: "fortune-dialog__heading text-heading-sm",
42
+ "data-testid": "dialog-heading"
39
43
  }, "Oops! Something went wrong")), /*#__PURE__*/React.createElement(IconButton, {
40
44
  icon: "X",
41
45
  variant: "ghost",
42
46
  onClick: onCancel,
43
- tabIndex: 0
47
+ tabIndex: 0,
48
+ className: "fortune-dialog__icon fortune-dialog__icon--close",
49
+ "data-testid": "dialog-icon-close"
44
50
  })), /*#__PURE__*/React.createElement("div", {
45
- className: "px-6 pb-6 pt-4 text-body-sm",
46
- style: contentStyle
51
+ className: "fortune-dialog__para px-6 pb-6 pt-4 text-body-sm",
52
+ style: contentStyle,
53
+ "data-testid": "dialog-para"
47
54
  }, children), type != null && (/*#__PURE__*/React.createElement("div", {
48
- className: "px-6 pb-6 flex flex-row gap-2 justify-end"
55
+ className: "fortune-dialog__actions px-6 pb-6 flex flex-row gap-2 justify-end",
56
+ "data-testid": "dialog-actions"
49
57
  }, type === "ok" ? (/*#__PURE__*/React.createElement(Button, {
50
58
  variant: "default",
59
+ className: "fortune-dialog__cta fortune-dialog__cta--confirm",
51
60
  style: {
52
61
  minWidth: "80px"
53
62
  },
54
63
  onClick: onOk,
55
- tabIndex: 0
64
+ tabIndex: 0,
65
+ "data-testid": "dialog-cta-confirm"
56
66
  }, okLabel || button.confirm)) : (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
57
67
  variant: "secondary",
68
+ className: "fortune-dialog__cta fortune-dialog__cta--cancel",
58
69
  style: {
59
70
  minWidth: "80px"
60
71
  },
61
72
  onClick: onCancel,
62
- tabIndex: 0
73
+ tabIndex: 0,
74
+ "data-testid": "dialog-cta-cancel"
63
75
  }, cancelLabel || button.cancel), /*#__PURE__*/React.createElement(Button, {
64
76
  variant: "default",
77
+ className: "fortune-dialog__cta fortune-dialog__cta--confirm",
65
78
  style: {
66
79
  minWidth: "80px"
67
80
  },
68
81
  onClick: onOk,
69
- tabIndex: 0
82
+ tabIndex: 0,
83
+ "data-testid": "dialog-cta-confirm"
70
84
  }, okLabel || button.confirm))))));
71
85
  };
72
86
  export default Dialog;
@@ -22,11 +22,14 @@ var ErrorBoxes = function ErrorBoxes() {
22
22
  zIndex: 100,
23
23
  borderRadius: "4px"
24
24
  },
25
- className: "shadow-lg flex flex-col gap-2 break-all"
25
+ className: "fortune-error-state shadow-lg flex flex-col gap-2 break-all",
26
+ "data-testid": "error-state"
26
27
  }, /*#__PURE__*/React.createElement("h3", {
27
- className: "text-heading-xsm color-text-danger"
28
+ className: "fortune-error-state__heading text-heading-xsm color-text-danger",
29
+ "data-testid": "error-state-heading"
28
30
  }, title), /*#__PURE__*/React.createElement("div", {
29
- className: "color-text-default text-body-sm"
31
+ className: "fortune-error-state__para color-text-default text-body-sm",
32
+ "data-testid": "error-state-para"
30
33
  }, message));
31
34
  };
32
35
  export default ErrorBoxes;
@@ -96,10 +96,13 @@ export var LinkEditCard = function LinkEditCard(_a) {
96
96
  };
97
97
  }, [refs.globalCache, isButtonDisabled]);
98
98
  var renderToolbarButton = useCallback(function (iconId, onClick) {
99
+ var iconIdClass = iconId.replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-");
99
100
  return /*#__PURE__*/React.createElement("div", {
100
- className: "fortune-toolbar-button",
101
+ className: "fortune-link-card__icon fortune-link-card__action fortune-link-card__action--".concat(iconIdClass, " fortune-toolbar-button"),
102
+ "data-icon-id": iconId,
101
103
  onClick: onClick,
102
- tabIndex: 0
104
+ tabIndex: 0,
105
+ "data-testid": "link-card-action-".concat(iconId)
103
106
  }, /*#__PURE__*/React.createElement(SVGIcon, {
104
107
  name: iconId,
105
108
  style: {
@@ -152,19 +155,21 @@ export var LinkEditCard = function LinkEditCard(_a) {
152
155
  onKeyDown: function onKeyDown(e) {
153
156
  e.stopPropagation();
154
157
  },
155
- className: "fortune-link-modify-modal link-toolbar",
158
+ className: "fortune-link-card fortune-link-modify-modal link-toolbar",
156
159
  style: {
157
160
  left: position.cellLeft + 20,
158
161
  top: position.cellBottom - 5
159
- }
162
+ },
163
+ "data-testid": "link-card"
160
164
  }), /*#__PURE__*/React.createElement("div", {
161
- className: "link-content",
165
+ className: "fortune-link-card__info link-content",
162
166
  onClick: function onClick() {
163
167
  setContext(function (draftCtx) {
164
168
  return goToLink(draftCtx, r, c, linkType, linkAddress, refs.scrollbarX.current, refs.scrollbarY.current);
165
169
  });
166
170
  },
167
- tabIndex: 0
171
+ tabIndex: 0,
172
+ "data-testid": "link-card-info-open"
168
173
  }, linkType === "webpage" ? insertLink.openLink : replaceHtml(insertLink.goTo, {
169
174
  linkAddress: linkAddress
170
175
  })), context.allowEdit === true && /*#__PURE__*/React.createElement("div", {
@@ -188,13 +193,15 @@ export var LinkEditCard = function LinkEditCard(_a) {
188
193
  }));
189
194
  }
190
195
  return /*#__PURE__*/React.createElement("div", __assign({
191
- className: "fortune-link-card",
196
+ className: "fortune-link-card fortune-link-card--editing",
192
197
  ref: cardRef,
193
198
  style: {
194
199
  left: position.cellLeft + 20,
195
200
  top: cardTop
196
201
  }
197
- }, containerEvent), /*#__PURE__*/React.createElement(Select, {
202
+ }, containerEvent, {
203
+ "data-testid": "link-card-editing"
204
+ }), /*#__PURE__*/React.createElement(Select, {
198
205
  value: linkType,
199
206
  onValueChange: function onValueChange(value) {
200
207
  if (value === "sheet") {
@@ -219,9 +226,10 @@ export var LinkEditCard = function LinkEditCard(_a) {
219
226
  value: type.value
220
227
  }, type.text);
221
228
  }))), /*#__PURE__*/React.createElement("div", {
222
- className: "fortune-input-with-icon"
229
+ className: "fortune-link-card__para fortune-input-with-icon",
230
+ "data-testid": "link-card-para-text"
223
231
  }, /*#__PURE__*/React.createElement("div", {
224
- className: "input-icon"
232
+ className: "fortune-link-card__icon input-icon"
225
233
  }, /*#__PURE__*/React.createElement(LucideIcon, {
226
234
  name: "ALargeSmall"
227
235
  })), /*#__PURE__*/React.createElement(TextField, {
@@ -274,7 +282,7 @@ export var LinkEditCard = function LinkEditCard(_a) {
274
282
  value: sheet.name
275
283
  }, sheet.name);
276
284
  }))))), /*#__PURE__*/React.createElement(Button, {
277
- className: "fortune-insert-button",
285
+ className: "fortune-link-card__cta fortune-insert-button",
278
286
  disabled: isButtonDisabled,
279
287
  onClick: function onClick() {
280
288
  if (isButtonDisabled) return;
@@ -282,7 +290,8 @@ export var LinkEditCard = function LinkEditCard(_a) {
282
290
  setContext(function (draftCtx) {
283
291
  return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
284
292
  });
285
- }
293
+ },
294
+ "data-testid": "link-card-cta-insert"
286
295
  }, "Insert link"));
287
296
  };
288
297
  export default LinkEditCard;