@fileverse-dev/fortune-react 1.1.90 → 1.1.91

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.
@@ -8,6 +8,7 @@ exports.default = void 0;
8
8
  var _fortuneCore = require("@fileverse-dev/fortune-core");
9
9
  var _ui = require("@fileverse/ui");
10
10
  var _react = _interopRequireWildcard(require("react"));
11
+ var _DropdownOption = _interopRequireDefault(require("./DropdownOption"));
11
12
  var _context = _interopRequireDefault(require("../../context"));
12
13
  var _useDialog = require("../../hooks/useDialog");
13
14
  var _datepickerStyles = require("../../utils/datepickerStyles");
@@ -24,6 +25,9 @@ var __assign = void 0 && (void 0).__assign || function () {
24
25
  };
25
26
  return __assign.apply(this, arguments);
26
27
  };
28
+ function createId() {
29
+ return "".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
30
+ }
27
31
  (0, _datepickerStyles.injectDatepickerStyles)();
28
32
  var DataVerification = function DataVerification() {
29
33
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
@@ -38,6 +42,56 @@ var DataVerification = function DataVerification() {
38
42
  button = _r.button,
39
43
  generalDialog = _r.generalDialog;
40
44
  var dateCondition = (0, _react.useState)(["between", "notBetween", "equal", "notEqualTo", "earlierThan", "noEarlierThan", "laterThan", "noLaterThan"])[0];
45
+ function getSheetIndex() {
46
+ var _a;
47
+ for (var i = 0; i < context.luckysheetfile.length; i += 1) {
48
+ if (((_a = context.luckysheetfile[i]) === null || _a === void 0 ? void 0 : _a.id) === context.currentSheetId) {
49
+ return i;
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ var _s = (0, _react.useState)([]),
55
+ optionItems = _s[0],
56
+ setOptionItems = _s[1];
57
+ var valuesFromArray = optionItems.map(function (i) {
58
+ return i.value;
59
+ }).join(",");
60
+ var colors = optionItems.map(function (i) {
61
+ return i.color;
62
+ }).join(",");
63
+ (0, _react.useEffect)(function () {
64
+ setContext(function (ctx) {
65
+ ctx.dataVerification.dataRegulation.color = colors;
66
+ ctx.dataVerification.dataRegulation.value1 = valuesFromArray;
67
+ });
68
+ }, [optionItems]);
69
+ (0, _react.useEffect)(function () {
70
+ var _a, _b, _c, _d, _e, _f, _g, _h;
71
+ var selectRow = (_c = (_b = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.row) === null || _c === void 0 ? void 0 : _c[0];
72
+ var selectCol = (_f = (_e = (_d = context.luckysheet_select_save) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.column) === null || _f === void 0 ? void 0 : _f[0];
73
+ var sheetIndex = getSheetIndex();
74
+ var dataVerificationInfo = context.luckysheetfile[sheetIndex].dataVerification;
75
+ var value = (_g = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _g === void 0 ? void 0 : _g.value1;
76
+ var color = (_h = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _h === void 0 ? void 0 : _h.color;
77
+ if (value && color) {
78
+ var colorValues = color === null || color === void 0 ? void 0 : color.split(",").map(function (v) {
79
+ return v.trim();
80
+ });
81
+ var rgbArray_1 = [];
82
+ for (var i = 0; i < colorValues.length; i += 3) {
83
+ rgbArray_1.push(colorValues.slice(i, i + 3).join(", "));
84
+ }
85
+ value = value === null || value === void 0 ? void 0 : value.split(",");
86
+ setOptionItems(value.map(function (v, i) {
87
+ return {
88
+ id: createId(),
89
+ value: v,
90
+ color: rgbArray_1[i]
91
+ };
92
+ }));
93
+ }
94
+ }, []);
41
95
  var dataSelectRange = (0, _react.useCallback)(function (type, value) {
42
96
  hideDialog();
43
97
  setContext(function (ctx) {
@@ -66,7 +120,7 @@ var DataVerification = function DataVerification() {
66
120
  var list = (0, _fortuneCore.getDropdownList)(ctx, value1);
67
121
  item.value1 = list.join(",");
68
122
  }
69
- var currentDataVerification = (_c = ctx.luckysheetfile[(0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId)].dataVerification) !== null && _c !== void 0 ? _c : {};
123
+ var currentDataVerification = (_c = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _c !== void 0 ? _c : {};
70
124
  var str = range[range.length - 1].row[0];
71
125
  var edr = range[range.length - 1].row[1];
72
126
  var stc = range[range.length - 1].column[0];
@@ -82,7 +136,7 @@ var DataVerification = function DataVerification() {
82
136
  }
83
137
  }
84
138
  }
85
- ctx.luckysheetfile[(0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId)].dataVerification = currentDataVerification;
139
+ ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
86
140
  }
87
141
  });
88
142
  } else if (type === "delete") {
@@ -93,7 +147,7 @@ var DataVerification = function DataVerification() {
93
147
  showDialog(generalDialog.noSelectionError, "ok");
94
148
  return;
95
149
  }
96
- var currentDataVerification = (_c = ctx.luckysheetfile[(0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId)].dataVerification) !== null && _c !== void 0 ? _c : {};
150
+ var currentDataVerification = (_c = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _c !== void 0 ? _c : {};
97
151
  var str = range[range.length - 1].row[0];
98
152
  var edr = range[range.length - 1].row[1];
99
153
  var stc = range[range.length - 1].column[0];
@@ -115,7 +169,7 @@ var DataVerification = function DataVerification() {
115
169
  var range = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
116
170
  rangeT = (0, _fortuneCore.getRangetxt)(context, context.currentSheetId, range, context.currentSheetId);
117
171
  }
118
- var index = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
172
+ var index = getSheetIndex();
119
173
  var ctxDataVerification = ctx.luckysheetfile[index].dataVerification;
120
174
  if (ctxDataVerification) {
121
175
  if (!ctx.luckysheet_select_save) return;
@@ -224,15 +278,9 @@ var DataVerification = function DataVerification() {
224
278
  }, dataVerification[v]);
225
279
  }))), ((_c = (_b = context.dataVerification) === null || _b === void 0 ? void 0 : _b.dataRegulation) === null || _c === void 0 ? void 0 : _c.type) === "dropdown" && (/*#__PURE__*/_react.default.createElement("div", {
226
280
  className: "mt-4"
227
- }, /*#__PURE__*/_react.default.createElement(_ui.TextField, {
228
- value: context.dataVerification.dataRegulation.value1,
229
- placeholder: dataVerification.placeholder1,
230
- onChange: function onChange(e) {
231
- var value = e.target.value;
232
- setContext(function (ctx) {
233
- ctx.dataVerification.dataRegulation.value1 = value;
234
- });
235
- }
281
+ }, /*#__PURE__*/_react.default.createElement(_DropdownOption.default, {
282
+ optionItems: optionItems,
283
+ setOptionItems: setOptionItems
236
284
  }), /*#__PURE__*/_react.default.createElement("div", {
237
285
  className: "mt-4 flex items-center"
238
286
  }, /*#__PURE__*/_react.default.createElement(_ui.Checkbox, {
@@ -202,7 +202,6 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
202
202
  var sourceIndex_1 = dragRef.current.source;
203
203
  var sheetIdx_1 = (0, _fortuneCore.getSheetIndex)(context, context.currentSheetId);
204
204
  if (sheetIdx_1 != null && sourceIndex_1 >= 0 && Number.isFinite(finalInsertionIndex_1) && finalInsertionIndex_1 >= 0) {
205
- console.log("sourceIndex", sourceIndex_1);
206
205
  setContext(function (draft) {
207
206
  var _a, _b, _c, _d;
208
207
  var _sheet = draft.luckysheetfile[sheetIdx_1];
@@ -307,7 +306,6 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
307
306
  dragRef.current.startX = startX;
308
307
  dragRef.current.source = clickedColIndex;
309
308
  dragRef.current.active = false;
310
- console.log("initiateDrag", startX);
311
309
  dragRef.current.onDocMove = handleColumnDrag;
312
310
  dragRef.current.onDocUp = handleColumnDragEnd;
313
311
  document.addEventListener("mousemove", handleColumnDrag);
@@ -205,7 +205,6 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
205
205
  rows.splice(targetIndex, 0, rowData);
206
206
  _sheet.data = rows;
207
207
  (0, _fortuneCore.updateContextWithSheetData)(draft, _sheet.data);
208
- console.log("rows", sourceIndex_1);
209
208
  var d = (0, _fortuneCore.getFlowdata)(draft);
210
209
  d === null || d === void 0 ? void 0 : d.forEach(function (row) {
211
210
  row.forEach(function (cell) {
@@ -270,7 +269,6 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
270
269
  item.r += 1;
271
270
  }
272
271
  });
273
- console.log("_sheet.calcChain", _sheet.calcChain);
274
272
  (_b = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _b === void 0 ? void 0 : _b.call(window, sourceIndex_1, targetIndex, "row", context.currentSheetId);
275
273
  });
276
274
  }
@@ -22,7 +22,6 @@ var _ImgBoxs = _interopRequireDefault(require("../ImgBoxs"));
22
22
  var _NotationBoxes = _interopRequireDefault(require("../NotationBoxes"));
23
23
  var _RangeDialog = _interopRequireDefault(require("../DataVerification/RangeDialog"));
24
24
  var _useDialog = require("../../hooks/useDialog");
25
- var _SVGIcon = _interopRequireDefault(require("../SVGIcon"));
26
25
  var _DropdownList = _interopRequireDefault(require("../DataVerification/DropdownList"));
27
26
  var _iFrameBoxs = _interopRequireDefault(require("../IFrameBoxs/iFrameBoxs"));
28
27
  var _ErrorState = _interopRequireDefault(require("../ErrorState"));
@@ -491,11 +490,7 @@ var SheetOverlay = function SheetOverlay() {
491
490
  style: {
492
491
  display: "none"
493
492
  }
494
- }, /*#__PURE__*/_react.default.createElement(_SVGIcon.default, {
495
- name: "caret-down-fill",
496
- width: 16,
497
- height: 16
498
- })), context.dataVerificationDropDownList && (context.dataVerification.dataRegulation.value1 !== "" || context.dataVerification.dataRegulation.value2 !== "") && (/*#__PURE__*/_react.default.createElement(_DropdownList.default, null)), /*#__PURE__*/_react.default.createElement("div", {
493
+ }), context.dataVerificationDropDownList && (context.dataVerification.dataRegulation.value1 !== "" || context.dataVerification.dataRegulation.value2 !== "") && (/*#__PURE__*/_react.default.createElement(_DropdownList.default, null)), /*#__PURE__*/_react.default.createElement("div", {
499
494
  id: "luckysheet-dataVerification-showHintBox",
500
495
  ref: dataVerificationHintBoxRef
501
496
  }), /*#__PURE__*/_react.default.createElement("div", {
@@ -457,58 +457,58 @@ var CurrencySelector = exports.CurrencySelector = function CurrencySelector(_a)
457
457
  }));
458
458
  };
459
459
  var Toolbar = function Toolbar(_a) {
460
- var _b, _c, _d;
460
+ var _b, _c, _d, _e;
461
461
  var setMoreItems = _a.setMoreItems,
462
462
  moreItemsOpen = _a.moreItemsOpen,
463
463
  onMoreToolbarItemsClose = _a.onMoreToolbarItemsClose,
464
464
  moreToolbarItems = _a.moreToolbarItems;
465
- var _e = (0, _react.useContext)(_context.default),
466
- context = _e.context,
467
- setContext = _e.setContext,
468
- refs = _e.refs,
469
- settings = _e.settings,
470
- handleUndo = _e.handleUndo,
471
- handleRedo = _e.handleRedo;
465
+ var _f = (0, _react.useContext)(_context.default),
466
+ context = _f.context,
467
+ setContext = _f.setContext,
468
+ refs = _f.refs,
469
+ settings = _f.settings,
470
+ handleUndo = _f.handleUndo,
471
+ handleRedo = _f.handleRedo;
472
472
  var contextRef = (0, _react.useRef)(context);
473
473
  var containerRef = (0, _react.useRef)(null);
474
- var _f = (0, _react.useState)(-1),
475
- toolbarWrapIndex = _f[0],
476
- setToolbarWrapIndex = _f[1];
477
- var _g = (0, _react.useState)([]),
478
- itemLocations = _g[0],
479
- setItemLocations = _g[1];
480
- var _h = (0, _react.useState)(false),
481
- showDuneModal = _h[0],
482
- setShowDuneModal = _h[1];
483
- var _j = (0, _react.useState)(window.innerWidth >= 1280),
484
- isDesktop = _j[0],
485
- setIsDesktop = _j[1];
486
- var _k = (0, _useDialog.useDialog)(),
487
- showDialog = _k.showDialog,
488
- hideDialog = _k.hideDialog;
474
+ var _g = (0, _react.useState)(-1),
475
+ toolbarWrapIndex = _g[0],
476
+ setToolbarWrapIndex = _g[1];
477
+ var _h = (0, _react.useState)([]),
478
+ itemLocations = _h[0],
479
+ setItemLocations = _h[1];
480
+ var _j = (0, _react.useState)(false),
481
+ showDuneModal = _j[0],
482
+ setShowDuneModal = _j[1];
483
+ var _k = (0, _react.useState)(window.innerWidth >= 1280),
484
+ isDesktop = _k[0],
485
+ setIsDesktop = _k[1];
486
+ var _l = (0, _useDialog.useDialog)(),
487
+ showDialog = _l.showDialog,
488
+ hideDialog = _l.hideDialog;
489
489
  var firstSelection = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0];
490
490
  var flowdata = (0, _fortuneCore.getFlowdata)(context);
491
491
  contextRef.current = context;
492
492
  var row = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
493
493
  var col = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
494
494
  var cell = flowdata && row != null && col != null ? (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[row]) === null || _c === void 0 ? void 0 : _c[col] : undefined;
495
- var _l = (0, _fortuneCore.locale)(context),
496
- toolbar = _l.toolbar,
497
- merge = _l.merge,
498
- border = _l.border,
499
- freezen = _l.freezen,
500
- defaultFmt = _l.defaultFmt,
501
- formula = _l.formula,
502
- sort = _l.sort,
503
- align = _l.align,
504
- textWrap = _l.textWrap,
505
- rotation = _l.rotation,
506
- screenshot = _l.screenshot,
507
- filter = _l.filter,
508
- splitText = _l.splitText,
509
- findAndReplace = _l.findAndReplace,
510
- comment = _l.comment,
511
- fontarray = _l.fontarray;
495
+ var _m = (0, _fortuneCore.locale)(context),
496
+ toolbar = _m.toolbar,
497
+ merge = _m.merge,
498
+ border = _m.border,
499
+ freezen = _m.freezen,
500
+ defaultFmt = _m.defaultFmt,
501
+ formula = _m.formula,
502
+ sort = _m.sort,
503
+ align = _m.align,
504
+ textWrap = _m.textWrap,
505
+ rotation = _m.rotation,
506
+ screenshot = _m.screenshot,
507
+ filter = _m.filter,
508
+ splitText = _m.splitText,
509
+ findAndReplace = _m.findAndReplace,
510
+ comment = _m.comment,
511
+ fontarray = _m.fontarray;
512
512
  var toolbarFormat = (0, _fortuneCore.locale)(context).format;
513
513
  var sheetWidth = context.luckysheetTableContentHW[0];
514
514
  var currency = settings.currency;
@@ -543,6 +543,9 @@ var Toolbar = function Toolbar(_a) {
543
543
  subMenu.style.display = "none";
544
544
  }, []);
545
545
  (0, _react.useEffect)(function () {
546
+ window.getDataValidationComponent = function () {
547
+ return /*#__PURE__*/_react.default.createElement(_DataVerification.default, null);
548
+ };
546
549
  var handleResize = function handleResize() {
547
550
  setIsDesktop(window.innerWidth >= 1280);
548
551
  };
@@ -974,8 +977,8 @@ var Toolbar = function Toolbar(_a) {
974
977
  tooltip: tooltip,
975
978
  key: name,
976
979
  onClick: function onClick() {
977
- if (context.allowEdit === false) return;
978
- showDialog(/*#__PURE__*/_react.default.createElement(_DataVerification.default, null), undefined, toolbar.dataVerification);
980
+ var _a;
981
+ (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
979
982
  }
980
983
  });
981
984
  }
@@ -1652,7 +1655,7 @@ var Toolbar = function Toolbar(_a) {
1652
1655
  });
1653
1656
  }
1654
1657
  }));
1655
- }, [toolbar, cell, setContext, refs.cellInput, refs.fxInput, refs.globalCache, defaultFormat, align, handleUndo, handleRedo, flowdata, formula, showDuneModal, merge, border, freezen, screenshot, sort, textWrap, rotation, filter, splitText, findAndReplace, context.luckysheet_select_save, context.defaultFontSize, context.allowEdit, comment, fontarray, hideSubMenu, showSubMenu, refs.canvas, customColor, customStyle, toolbarFormat.moreCurrency]);
1658
+ }, [toolbar, cell, setContext, refs.cellInput, refs.fxInput, refs.globalCache, defaultFormat, align, handleUndo, handleRedo, flowdata, formula, showDuneModal, merge, border, freezen, screenshot, sort, textWrap, rotation, filter, splitText, findAndReplace, context.luckysheet_select_save, context.defaultFontSize, context.allowEdit, comment, fontarray, hideSubMenu, showSubMenu, refs.canvas, customColor, customStyle, toolbarFormat.moreCurrency, (_d = context.dataVerification) === null || _d === void 0 ? void 0 : _d.dataRegulation]);
1656
1659
  return /*#__PURE__*/_react.default.createElement("div", {
1657
1660
  ref: containerRef,
1658
1661
  className: "fortune-toolbar",
@@ -1669,7 +1672,7 @@ var Toolbar = function Toolbar(_a) {
1669
1672
  icon: n.icon,
1670
1673
  iconName: n.iconName
1671
1674
  }, n.children);
1672
- }), ((_d = settings.customToolbarItems) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (/*#__PURE__*/_react.default.createElement(_Divider.default, {
1675
+ }), ((_e = settings.customToolbarItems) === null || _e === void 0 ? void 0 : _e.length) > 0 ? (/*#__PURE__*/_react.default.createElement(_Divider.default, {
1673
1676
  key: "customDivider"
1674
1677
  })) : null, (toolbarWrapIndex === -1 || isDesktop ? settings.toolbarItems : settings.toolbarItems.slice(0, toolbarWrapIndex + 1)).map(function (name, i) {
1675
1678
  return getToolbarItem(name, i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.90",
3
+ "version": "1.1.91",
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.1.90",
19
+ "@fileverse-dev/fortune-core": "1.1.91",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",