@fileverse-dev/fortune-react 1.2.98 → 1.2.99-ydoc

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 (37) 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/Dialog/index.js +24 -10
  6. package/es/components/ErrorState/index.js +6 -3
  7. package/es/components/LinkEidtCard/index.js +22 -13
  8. package/es/components/SheetOverlay/FormulaHint/index.js +48 -33
  9. package/es/components/SheetTab/SheetItem.js +29 -16
  10. package/es/components/SheetTab/index.js +35 -20
  11. package/es/components/Toolbar/Button.js +10 -3
  12. package/es/components/Toolbar/Combo.js +10 -2
  13. package/es/components/Toolbar/CustomButton.js +12 -3
  14. package/es/components/Toolbar/Select.js +7 -1
  15. package/es/components/Workbook/api.d.ts +2 -3
  16. package/es/components/Workbook/api.js +4 -4
  17. package/es/components/Workbook/index.d.ts +2 -3
  18. package/es/components/Workbook/index.js +114 -0
  19. package/lib/components/ConditionFormat/ConditionRules.d.ts +0 -1
  20. package/lib/components/ConditionFormat/ConditionRules.js +21 -12
  21. package/lib/components/ConditionFormat/index.js +2 -2
  22. package/lib/components/DataVerification/RangeDialog.js +19 -8
  23. package/lib/components/Dialog/index.js +24 -10
  24. package/lib/components/ErrorState/index.js +6 -3
  25. package/lib/components/LinkEidtCard/index.js +22 -13
  26. package/lib/components/SheetOverlay/FormulaHint/index.js +48 -33
  27. package/lib/components/SheetTab/SheetItem.js +29 -16
  28. package/lib/components/SheetTab/index.js +35 -20
  29. package/lib/components/Toolbar/Button.js +10 -3
  30. package/lib/components/Toolbar/Combo.js +10 -2
  31. package/lib/components/Toolbar/CustomButton.js +12 -3
  32. package/lib/components/Toolbar/Select.js +7 -1
  33. package/lib/components/Workbook/api.d.ts +2 -3
  34. package/lib/components/Workbook/api.js +4 -4
  35. package/lib/components/Workbook/index.d.ts +2 -3
  36. package/lib/components/Workbook/index.js +114 -0
  37. 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;
@@ -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,15 +282,16 @@ 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;
281
289
  _.set(refs.globalCache, "linkCard.mouseEnter", false);
282
290
  setContext(function (draftCtx) {
283
- return saveHyperlink(draftCtx, r, c, linkText, linkType, linkAddress);
291
+ 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;
@@ -15,7 +15,7 @@ import WorkbookContext from "../../../context";
15
15
  import "./index.css";
16
16
  import { DraggableDiv } from "./dragable-div";
17
17
  var FormulaHint = function FormulaHint(props) {
18
- var _a;
18
+ var _a, _b, _c;
19
19
  var showFormulaHint = props.showFormulaHint,
20
20
  handleShowFormulaHint = props.handleShowFormulaHint,
21
21
  commaCount = props.commaCount,
@@ -25,19 +25,19 @@ var FormulaHint = function FormulaHint(props) {
25
25
  var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
26
26
  var formulaMore = locale(context).formulaMore;
27
27
  var fn = functionName ? context.formulaCache.functionlistMap[functionName] : context.formulaCache.functionlistMap[(context === null || context === void 0 ? void 0 : context.functionHint) || ""];
28
- var _b = useState(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
29
- API_KEY = _b[0],
30
- setAPI_KEY = _b[1];
31
- var _c = useState(!API_KEY),
32
- showAPInput = _c[0],
33
- setShowAPInput = _c[1];
34
- var _d = useState(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
35
- isKeyAdded = _d[0],
36
- setApiKeyAdded = _d[1];
28
+ var _d = useState(localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
29
+ API_KEY = _d[0],
30
+ setAPI_KEY = _d[1];
31
+ var _e = useState(!API_KEY),
32
+ showAPInput = _e[0],
33
+ setShowAPInput = _e[1];
34
+ var _f = useState(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY)),
35
+ isKeyAdded = _f[0],
36
+ setApiKeyAdded = _f[1];
37
37
  var formulaExpand = localStorage.getItem("formula-expand") === "true";
38
- var _e = useState(formulaExpand),
39
- showFunctionBody = _e[0],
40
- setShouldShowFunctionBody = _e[1];
38
+ var _g = useState(formulaExpand),
39
+ showFunctionBody = _g[0],
40
+ setShouldShowFunctionBody = _g[1];
41
41
  useEffect(function () {
42
42
  if (fn) {
43
43
  setApiKeyAdded(!!localStorage.getItem(fn === null || fn === void 0 ? void 0 : fn.API_KEY));
@@ -49,12 +49,12 @@ var FormulaHint = function FormulaHint(props) {
49
49
  ETHERSCAN_API_KEY: "Etherscan API key"
50
50
  };
51
51
  var hintRef = useRef(null);
52
- var _f = useState(0),
53
- top = _f[0],
54
- setTop = _f[1];
55
- var _g = useState(false),
56
- showDelayedHint = _g[0],
57
- setShowDelayedHint = _g[1];
52
+ var _h = useState(0),
53
+ top = _h[0],
54
+ setTop = _h[1];
55
+ var _j = useState(false),
56
+ showDelayedHint = _j[0],
57
+ setShowDelayedHint = _j[1];
58
58
  var calcuatePopUpPlacement = function calcuatePopUpPlacement() {
59
59
  var _a, _b, _c, _d, _e, _f;
60
60
  if (!((_a = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.top) === null || _a === void 0 ? void 0 : _a.toString()) || !((_b = firstSelection.height_move) === null || _b === void 0 ? void 0 : _b.toString()) || !hintRef.current) return;
@@ -94,6 +94,7 @@ var FormulaHint = function FormulaHint(props) {
94
94
  }
95
95
  }, [top]);
96
96
  if (!fn) return null;
97
+ var fnNameClass = fn.n ? String(fn.n).replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-") : "";
97
98
  return /*#__PURE__*/React.createElement(DraggableDiv, {
98
99
  initialTop: top,
99
100
  dragHasMoved: dragHasMoved,
@@ -110,7 +111,7 @@ var FormulaHint = function FormulaHint(props) {
110
111
  }
111
112
  }, /*#__PURE__*/React.createElement("button", {
112
113
  type: "button",
113
- className: "flex items-center justify-center w-4 h-4 rounded-full",
114
+ className: "fortune-formula-hint__icon fortune-formula-hint__action flex items-center justify-center w-4 h-4 rounded-full",
114
115
  style: {
115
116
  backgroundColor: "black",
116
117
  zIndex: 2000,
@@ -121,7 +122,8 @@ var FormulaHint = function FormulaHint(props) {
121
122
  color: "white"
122
123
  },
123
124
  onClick: handleShowFormulaHint,
124
- "aria-label": "Close formula hint"
125
+ "aria-label": "Close formula hint",
126
+ "data-testid": "formula-hint-icon-close"
125
127
  }, /*#__PURE__*/React.createElement("svg", {
126
128
  xmlns: "http://www.w3.org/2000/svg",
127
129
  width: "20",
@@ -140,7 +142,9 @@ var FormulaHint = function FormulaHint(props) {
140
142
  })))), /*#__PURE__*/React.createElement("div", __assign({}, props, {
141
143
  ref: hintRef,
142
144
  id: "luckysheet-formula-help-c",
143
- className: "luckysheet-formula-help-c",
145
+ className: "fortune-formula-hint fortune-formula-hint--".concat(fnNameClass || "unknown", " luckysheet-formula-help-c"),
146
+ "data-function-name": (_b = fn.n) !== null && _b !== void 0 ? _b : undefined,
147
+ "data-testid": "formula-hint-".concat((_c = fn.n) !== null && _c !== void 0 ? _c : "unknown"),
144
148
  style: {
145
149
  top: "0px",
146
150
  left: "0px",
@@ -151,14 +155,16 @@ var FormulaHint = function FormulaHint(props) {
151
155
  padding: "0px"
152
156
  }
153
157
  }), /*#__PURE__*/React.createElement("div", {
154
- className: "luckysheet-formula-help-close",
155
- title: "\u5173\u95ED"
158
+ className: "fortune-formula-hint__icon fortune-formula-help-close",
159
+ title: "\u5173\u95ED",
160
+ "data-testid": "formula-hint-icon-close-legacy"
156
161
  }, /*#__PURE__*/React.createElement("i", {
157
162
  className: "fa fa-times",
158
163
  "aria-hidden": "true"
159
164
  })), /*#__PURE__*/React.createElement("div", {
160
- className: "luckysheet-formula-help-collapse",
161
- title: "\u6536\u8D77"
165
+ className: "fortune-formula-hint__icon fortune-formula-help-collapse",
166
+ title: "\u6536\u8D77",
167
+ "data-testid": "formula-hint-icon-collapse"
162
168
  }, /*#__PURE__*/React.createElement("i", {
163
169
  className: "fa fa-angle-up",
164
170
  "aria-hidden": "true"
@@ -173,8 +179,9 @@ var FormulaHint = function FormulaHint(props) {
173
179
  }
174
180
  dragHasMoved.current = false;
175
181
  },
176
- className: "flex !cursor-grab active:cursor-grabbing items-start justify-between",
182
+ className: "fortune-formula-hint__heading flex !cursor-grab active:cursor-grabbing items-start justify-between",
177
183
  id: "luckysheet-formula-help-title",
184
+ "data-testid": "formula-hint-heading",
178
185
  style: {
179
186
  backgroundColor: "".concat(fn.BRAND_COLOR ? fn.BRAND_COLOR : "#F8F9FA"),
180
187
  padding: "10px",
@@ -183,7 +190,8 @@ var FormulaHint = function FormulaHint(props) {
183
190
  userSelect: "none"
184
191
  }
185
192
  }, /*#__PURE__*/React.createElement("div", {
186
- className: " flex-grow color-text-default"
193
+ className: "fortune-formula-hint__para flex-grow color-text-default",
194
+ "data-testid": "formula-hint-para"
187
195
  }, /*#__PURE__*/React.createElement("code", {
188
196
  style: {
189
197
  fontWeight: "bold"
@@ -285,12 +293,14 @@ var FormulaHint = function FormulaHint(props) {
285
293
  },
286
294
  onClick: function onClick() {
287
295
  return setShowAPInput(!showAPInput);
288
- }
296
+ },
297
+ "data-testid": "formula-hint-info-api"
289
298
  }, /*#__PURE__*/React.createElement("h3", {
290
299
  style: {
291
300
  margin: "0 0 8px 0"
292
301
  },
293
- className: "text-heading-xsm color-text-default"
302
+ className: "fortune-formula-hint__heading-sm text-heading-xsm color-text-default",
303
+ "data-testid": "formula-hint-info-heading"
294
304
  }, isKeyAdded ? "API key provided" : "API key is required"), /*#__PURE__*/React.createElement(LucideIcon, {
295
305
  name: showAPInput ? "ChevronUp" : "ChevronDown",
296
306
  width: 24,
@@ -298,11 +308,15 @@ var FormulaHint = function FormulaHint(props) {
298
308
  style: {
299
309
  cursor: "pointer"
300
310
  }
301
- })), showAPInput && (/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", {
311
+ })), showAPInput && (/*#__PURE__*/React.createElement("div", {
312
+ className: "fortune-formula-hint__info-content",
313
+ "data-testid": "formula-hint-info-content"
314
+ }, /*#__PURE__*/React.createElement("p", {
302
315
  style: {
303
316
  margin: "0 0 16px 0"
304
317
  },
305
- className: "text-body-sm color-text-default"
318
+ className: "fortune-formula-hint__para fortune-formula-hint__para--api text-body-sm color-text-default",
319
+ "data-testid": "formula-hint-para-api"
306
320
  }, "This function requires an API key. Please paste it below and\n press 'Ok'."), /*#__PURE__*/React.createElement("div", {
307
321
  className: "w-full"
308
322
  }, /*#__PURE__*/React.createElement(TextField, {
@@ -323,7 +337,8 @@ var FormulaHint = function FormulaHint(props) {
323
337
  setShowAPInput(false);
324
338
  },
325
339
  disabled: !API_KEY,
326
- className: "min-w-[80px]"
340
+ className: "fortune-formula-hint__cta min-w-[80px]",
341
+ "data-testid": "formula-hint-cta-ok"
327
342
  }, "Ok"))))))), /*#__PURE__*/React.createElement("div", {
328
343
  style: {
329
344
  backgroundColor: "white",
@@ -4,22 +4,28 @@ import React, { useContext, useState, useEffect, useRef, useCallback } from "rea
4
4
  import WorkbookContext from "../../context";
5
5
  import { useAlert } from "../../hooks/useAlert";
6
6
  import SVGIcon from "../SVGIcon";
7
+ var toCssId = function toCssId(s) {
8
+ return String(s).replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-");
9
+ };
7
10
  var SheetItem = function SheetItem(_a) {
11
+ var _b, _c, _d, _e;
8
12
  var sheet = _a.sheet,
9
13
  isDropPlaceholder = _a.isDropPlaceholder;
10
- var _b = useContext(WorkbookContext),
11
- context = _b.context,
12
- setContext = _b.setContext,
13
- refs = _b.refs;
14
- var _c = useState(false),
15
- editing = _c[0],
16
- setEditing = _c[1];
14
+ var _f = useContext(WorkbookContext),
15
+ context = _f.context,
16
+ setContext = _f.setContext,
17
+ refs = _f.refs;
18
+ var _g = useState(false),
19
+ editing = _g[0],
20
+ setEditing = _g[1];
17
21
  var containerRef = useRef(null);
18
22
  var editable = useRef(null);
19
- var _d = useState(false),
20
- dragOver = _d[0],
21
- setDragOver = _d[1];
23
+ var _h = useState(false),
24
+ dragOver = _h[0],
25
+ setDragOver = _h[1];
22
26
  var showAlert = useAlert().showAlert;
27
+ var sheetIdClass = sheet.id != null ? toCssId(String(sheet.id)) : "placeholder";
28
+ var sheetNameClass = sheet.name ? toCssId(sheet.name) : "";
23
29
  useEffect(function () {
24
30
  setContext(function (draftCtx) {
25
31
  var _a, _b, _c, _d;
@@ -127,7 +133,10 @@ var SheetItem = function SheetItem(_a) {
127
133
  draggable: context.allowEdit && !editing,
128
134
  key: sheet.id,
129
135
  ref: containerRef,
130
- className: isDropPlaceholder ? "fortune-sheettab-placeholder" : "luckysheet-sheets-item".concat(context.currentSheetId === sheet.id ? " luckysheet-sheets-item-active" : ""),
136
+ className: isDropPlaceholder ? "fortune-sheettab-item fortune-sheettab-placeholder" : "fortune-sheettab-item fortune-sheettab-item--".concat(sheetIdClass).concat(sheetNameClass ? " fortune-sheettab-item--name-".concat(sheetNameClass) : "", " luckysheet-sheets-item").concat(context.currentSheetId === sheet.id ? " luckysheet-sheets-item-active" : ""),
137
+ "data-sheet-id": sheet.id != null ? String(sheet.id) : undefined,
138
+ "data-sheet-name": sheet.name || undefined,
139
+ "data-testid": "sheettab-item-".concat((_b = sheet.id) !== null && _b !== void 0 ? _b : "placeholder"),
131
140
  onClick: function onClick() {
132
141
  if (isDropPlaceholder) return;
133
142
  setContext(function (draftCtx) {
@@ -171,13 +180,14 @@ var SheetItem = function SheetItem(_a) {
171
180
  display: sheet.hide === 1 ? "none" : ""
172
181
  }
173
182
  }, editing === false && (/*#__PURE__*/React.createElement("p", {
174
- className: "luckysheet-sheets-item-name",
183
+ className: "fortune-sheettab-item__para luckysheet-sheets-item-name",
175
184
  onDoubleClick: function onDoubleClick() {
176
185
  if (context.isFlvReadOnly) return;
177
186
  setEditing(true);
178
- }
187
+ },
188
+ "data-testid": "sheettab-item-para-".concat((_c = sheet.id) !== null && _c !== void 0 ? _c : "placeholder")
179
189
  }, sheet.name)), editing && (/*#__PURE__*/React.createElement("span", {
180
- className: "luckysheet-sheets-item-name",
190
+ className: "fortune-sheettab-item__para luckysheet-sheets-item-name",
181
191
  spellCheck: "false",
182
192
  suppressContentEditableWarning: true,
183
193
  contentEditable: isDropPlaceholder ? false : editing,
@@ -190,13 +200,16 @@ var SheetItem = function SheetItem(_a) {
190
200
  ref: editable,
191
201
  style: dragOver ? {
192
202
  pointerEvents: "none"
193
- } : {}
203
+ } : {},
204
+ "data-testid": "sheettab-item-para-editable-".concat((_d = sheet.id) !== null && _d !== void 0 ? _d : "placeholder")
194
205
  }, sheet.name)), /*#__PURE__*/React.createElement("span", {
195
- className: "luckysheet-sheets-item-function",
206
+ className: "fortune-sheettab-item__icon fortune-sheettab-item__action fortune-sheettab-item__icon--menu luckysheet-sheets-item-function",
196
207
  style: {
197
208
  marginRight: "4px",
198
209
  marginLeft: "4px"
199
210
  },
211
+ "data-sheet-id": sheet.id != null ? String(sheet.id) : undefined,
212
+ "data-testid": "sheettab-item-icon-menu-".concat((_e = sheet.id) !== null && _e !== void 0 ? _e : "placeholder"),
200
213
  onClick: function onClick(e) {
201
214
  if (isDropPlaceholder || context.allowEdit === false) return;
202
215
  var rect = refs.workbookContainer.current.getBoundingClientRect();