@fileverse-dev/fortune-react 1.1.94 → 1.1.96

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.
@@ -242,7 +242,7 @@ var DynamicInputList = function DynamicInputList(_a) {
242
242
  return handleChange(index, e.target.value);
243
243
  },
244
244
  "aria-label": "Option ".concat(index + 1)
245
- })), /*#__PURE__*/React.createElement(IconButton, {
245
+ })), optionItems.length > 1 && (/*#__PURE__*/React.createElement(IconButton, {
246
246
  icon: "Trash2",
247
247
  type: "button",
248
248
  variant: "ghost",
@@ -252,9 +252,9 @@ var DynamicInputList = function DynamicInputList(_a) {
252
252
  className: "",
253
253
  "aria-label": "Delete row ".concat(index + 1),
254
254
  title: "Delete"
255
- }));
255
+ })));
256
256
  })), /*#__PURE__*/React.createElement("div", {
257
- className: "mt-8"
257
+ className: ""
258
258
  }, /*#__PURE__*/React.createElement(Button, {
259
259
  variant: "secondary",
260
260
  onClick: handleAdd,
@@ -62,9 +62,7 @@ var DataVerification = function DataVerification() {
62
62
  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];
63
63
  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];
64
64
  var sheetIndex = getSheetIndex();
65
- console.log('sheetIndex', sheetIndex);
66
65
  var dataVerificationInfo = (_h = (_g = context.luckysheetfile[sheetIndex]) === null || _g === void 0 ? void 0 : _g.dataVerification) !== null && _h !== void 0 ? _h : {};
67
- console.log('dataVerificationInfo', dataVerificationInfo);
68
66
  if (!dataVerificationInfo) return;
69
67
  var value = (_j = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _j === void 0 ? void 0 : _j.value1;
70
68
  var color = (_k = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _k === void 0 ? void 0 : _k.color;
@@ -220,7 +218,11 @@ var DataVerification = function DataVerification() {
220
218
  return /*#__PURE__*/React.createElement("div", {
221
219
  id: "fortune-data-verification"
222
220
  }, /*#__PURE__*/React.createElement("div", {
223
- className: "flex flex-col gap-4"
221
+ className: "flex flex-col gap-4",
222
+ style: {
223
+ width: "345px",
224
+ padding: "16px"
225
+ }
224
226
  }, /*#__PURE__*/React.createElement("div", {
225
227
  className: "flex flex-col"
226
228
  }, /*#__PURE__*/React.createElement("div", {
@@ -417,16 +419,13 @@ var DataVerification = function DataVerification() {
417
419
  }))))), /*#__PURE__*/React.createElement(Divider, {
418
420
  className: "w-full border-t-[1px] my-4"
419
421
  }), /*#__PURE__*/React.createElement("div", {
420
- className: "flex gap-2 justify-between items-center"
421
- }, /*#__PURE__*/React.createElement(Button, {
422
- variant: "secondary",
422
+ className: "flex gap-2 justify-between items-center",
423
423
  style: {
424
- minWidth: "80px"
425
- },
426
- onClick: function onClick() {
427
- btn("close");
424
+ width: "345px",
425
+ paddingRight: "16px",
426
+ justifyContent: "flex-end"
428
427
  }
429
- }, button.cancel), /*#__PURE__*/React.createElement("div", {
428
+ }, /*#__PURE__*/React.createElement("div", {
430
429
  className: "flex gap-2"
431
430
  }, /*#__PURE__*/React.createElement(Button, {
432
431
  variant: "secondary",
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const DataVerificationPortal: ({ visible }: {
3
+ visible: boolean;
4
+ }) => React.ReactPortal | null;
5
+ export default DataVerificationPortal;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { createPortal } from "react-dom";
3
+ import DataVerification from "../DataVerification";
4
+ var DataVerificationPortal = function DataVerificationPortal(_a) {
5
+ var visible = _a.visible;
6
+ var container = document.getElementById("placeholder-data-verification");
7
+ if (!visible || !container) return null;
8
+ return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(DataVerification, null), container);
9
+ };
10
+ export default DataVerificationPortal;
@@ -123,8 +123,9 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
123
123
  return to.concat(ar || Array.prototype.slice.call(from));
124
124
  };
125
125
  import React, { useContext, useCallback, useRef, useEffect, useState } from "react";
126
- import ReactDOM from 'react-dom/client';
126
+ import DataVerificationPortal from "./dataVerificationPortal";
127
127
  import { toolbarItemClickHandler, handleTextBackground, handleTextColor, handleTextSize, normalizedCellAttr, getFlowdata, newComment, editComment, deleteComment, showHideComment, showHideAllComments, autoSelectionFormula, handleSum, locale, handleMerge, handleBorder, toolbarItemSelectedFunc, handleFreeze, insertImage, showImgChooser, updateFormat, handleSort, handleHorizontalAlign, handleVerticalAlign, handleScreenShot, createFilter, clearFilter, applyLocation, insertDuneChart } from "@fileverse-dev/fortune-core";
128
+ import { setSelection, getSelection } from "@fileverse-dev/fortune-core/lib/api";
128
129
  import _ from "lodash";
129
130
  import { IconButton, LucideIcon, Tooltip, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@fileverse/ui";
130
131
  import WorkbookContext from "../../context";
@@ -137,7 +138,6 @@ import SVGIcon from "../SVGIcon";
137
138
  import { useDialog } from "../../hooks/useDialog";
138
139
  import { SplitColumn } from "../SplitColumn";
139
140
  import { LocationCondition } from "../LocationCondition";
140
- import DataVerification from "../DataVerification";
141
141
  import ConditionalFormat from "../ConditionFormat";
142
142
  import CustomButton from "./CustomButton";
143
143
  import { CustomColor } from "./CustomColor";
@@ -585,6 +585,9 @@ var Toolbar = function Toolbar(_a) {
585
585
  }
586
586
  }
587
587
  }, [itemLocations, setMoreItems, settings.toolbarItems.length, sheetWidth, isDesktop]);
588
+ var _o = useState(false),
589
+ showDataValidation = _o[0],
590
+ setShowDataValidation = _o[1];
588
591
  var getToolbarItem = useCallback(function (name, i) {
589
592
  var _a, _b, _c, _d, _e, _f, _g;
590
593
  var tooltip = toolbar[name];
@@ -961,24 +964,31 @@ var Toolbar = function Toolbar(_a) {
961
964
  });
962
965
  }
963
966
  if (name === "dataVerification") {
964
- return /*#__PURE__*/React.createElement(Button, {
967
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataVerificationPortal, {
968
+ visible: showDataValidation
969
+ }), /*#__PURE__*/React.createElement(Button, {
965
970
  iconId: name,
966
971
  tooltip: tooltip,
967
972
  key: name,
968
973
  onClick: function onClick() {
969
974
  var _a;
975
+ var selection = getSelection(context);
976
+ if (!selection) {
977
+ setContext(function (ctx) {
978
+ setSelection(ctx, [{
979
+ row: [0, 0],
980
+ column: [0, 0]
981
+ }], {
982
+ id: context.currentSheetId
983
+ });
984
+ });
985
+ }
970
986
  (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
971
987
  setTimeout(function () {
972
- var target = document.getElementById('placeholder-data-validation');
973
- console.log("Target for DataValidation:", target);
974
- console.log("DataValidationComponent:", DataVerification);
975
- if (target) {
976
- var root = ReactDOM.createRoot(target);
977
- root.render(/*#__PURE__*/React.createElement(DataVerification, null));
978
- }
988
+ setShowDataValidation(true);
979
989
  }, 100);
980
990
  }
981
- });
991
+ }));
982
992
  }
983
993
  if (name === "locationCondition") {
984
994
  var items_3 = [{
@@ -4,7 +4,6 @@ import { SetContextOptions } from "../../context";
4
4
  export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
5
5
  applyOp: (ops: Op[]) => void;
6
6
  getCryptoPrice: typeof getCryptoPrice;
7
- DataVerificationComponent: import("react").FC<{}>;
8
7
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
9
8
  type?: keyof Cell;
10
9
  }) => any;
@@ -9,7 +9,6 @@ var __assign = this && this.__assign || function () {
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
11
  import { addSheet, api, deleteRowCol, deleteSheet, insertRowCol, opToPatch, createFilterOptions, getSheetIndex, locale, setCaretPosition, newComment } from "@fileverse-dev/fortune-core";
12
- import DataVerification from "../DataVerification";
13
12
  import { applyPatches } from "immer";
14
13
  import _ from "lodash";
15
14
  import { getCryptoPrice } from "../../utils/cryptoApi";
@@ -67,7 +66,6 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
67
66
  });
68
67
  },
69
68
  getCryptoPrice: getCryptoPrice,
70
- DataVerificationComponent: DataVerification,
71
69
  getCellValue: function getCellValue(row, column, options) {
72
70
  if (options === void 0) {
73
71
  options = {};
@@ -11,7 +11,6 @@ type AdditionalProps = {
11
11
  declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalProps & React.RefAttributes<{
12
12
  applyOp: (ops: Op[]) => void;
13
13
  getCryptoPrice: typeof getCryptoPrice;
14
- DataVerificationComponent: React.FC<{}>;
15
14
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
16
15
  type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
17
16
  }) => any;
@@ -249,7 +249,7 @@ var DynamicInputList = function DynamicInputList(_a) {
249
249
  return handleChange(index, e.target.value);
250
250
  },
251
251
  "aria-label": "Option ".concat(index + 1)
252
- })), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
252
+ })), optionItems.length > 1 && (/*#__PURE__*/_react.default.createElement(_ui.IconButton, {
253
253
  icon: "Trash2",
254
254
  type: "button",
255
255
  variant: "ghost",
@@ -259,9 +259,9 @@ var DynamicInputList = function DynamicInputList(_a) {
259
259
  className: "",
260
260
  "aria-label": "Delete row ".concat(index + 1),
261
261
  title: "Delete"
262
- }));
262
+ })));
263
263
  })), /*#__PURE__*/_react.default.createElement("div", {
264
- className: "mt-8"
264
+ className: ""
265
265
  }, /*#__PURE__*/_react.default.createElement(_ui.Button, {
266
266
  variant: "secondary",
267
267
  onClick: handleAdd,
@@ -71,9 +71,7 @@ var DataVerification = function DataVerification() {
71
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
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
73
  var sheetIndex = getSheetIndex();
74
- console.log('sheetIndex', sheetIndex);
75
74
  var dataVerificationInfo = (_h = (_g = context.luckysheetfile[sheetIndex]) === null || _g === void 0 ? void 0 : _g.dataVerification) !== null && _h !== void 0 ? _h : {};
76
- console.log('dataVerificationInfo', dataVerificationInfo);
77
75
  if (!dataVerificationInfo) return;
78
76
  var value = (_j = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _j === void 0 ? void 0 : _j.value1;
79
77
  var color = (_k = dataVerificationInfo === null || dataVerificationInfo === void 0 ? void 0 : dataVerificationInfo["".concat(selectRow, "_").concat(selectCol)]) === null || _k === void 0 ? void 0 : _k.color;
@@ -229,7 +227,11 @@ var DataVerification = function DataVerification() {
229
227
  return /*#__PURE__*/_react.default.createElement("div", {
230
228
  id: "fortune-data-verification"
231
229
  }, /*#__PURE__*/_react.default.createElement("div", {
232
- className: "flex flex-col gap-4"
230
+ className: "flex flex-col gap-4",
231
+ style: {
232
+ width: "345px",
233
+ padding: "16px"
234
+ }
233
235
  }, /*#__PURE__*/_react.default.createElement("div", {
234
236
  className: "flex flex-col"
235
237
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -426,16 +428,13 @@ var DataVerification = function DataVerification() {
426
428
  }))))), /*#__PURE__*/_react.default.createElement(_ui.Divider, {
427
429
  className: "w-full border-t-[1px] my-4"
428
430
  }), /*#__PURE__*/_react.default.createElement("div", {
429
- className: "flex gap-2 justify-between items-center"
430
- }, /*#__PURE__*/_react.default.createElement(_ui.Button, {
431
- variant: "secondary",
431
+ className: "flex gap-2 justify-between items-center",
432
432
  style: {
433
- minWidth: "80px"
434
- },
435
- onClick: function onClick() {
436
- btn("close");
433
+ width: "345px",
434
+ paddingRight: "16px",
435
+ justifyContent: "flex-end"
437
436
  }
438
- }, button.cancel), /*#__PURE__*/_react.default.createElement("div", {
437
+ }, /*#__PURE__*/_react.default.createElement("div", {
439
438
  className: "flex gap-2"
440
439
  }, /*#__PURE__*/_react.default.createElement(_ui.Button, {
441
440
  variant: "secondary",
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const DataVerificationPortal: ({ visible }: {
3
+ visible: boolean;
4
+ }) => React.ReactPortal | null;
5
+ export default DataVerificationPortal;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactDom = require("react-dom");
9
+ var _DataVerification = _interopRequireDefault(require("../DataVerification"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var DataVerificationPortal = function DataVerificationPortal(_a) {
12
+ var visible = _a.visible;
13
+ var container = document.getElementById("placeholder-data-verification");
14
+ if (!visible || !container) return null;
15
+ return /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_DataVerification.default, null), container);
16
+ };
17
+ var _default = exports.default = DataVerificationPortal;
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getLucideIcon = exports.default = exports.CurrencySelector = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _client = _interopRequireDefault(require("react-dom/client"));
9
+ var _dataVerificationPortal = _interopRequireDefault(require("./dataVerificationPortal"));
10
10
  var _fortuneCore = require("@fileverse-dev/fortune-core");
11
+ var _api = require("@fileverse-dev/fortune-core/lib/api");
11
12
  var _lodash = _interopRequireDefault(require("lodash"));
12
13
  var _ui = require("@fileverse/ui");
13
14
  var _context = _interopRequireDefault(require("../../context"));
@@ -20,7 +21,6 @@ var _SVGIcon = _interopRequireDefault(require("../SVGIcon"));
20
21
  var _useDialog = require("../../hooks/useDialog");
21
22
  var _SplitColumn = require("../SplitColumn");
22
23
  var _LocationCondition = require("../LocationCondition");
23
- var _DataVerification = _interopRequireDefault(require("../DataVerification"));
24
24
  var _ConditionFormat = _interopRequireDefault(require("../ConditionFormat"));
25
25
  var _CustomButton = _interopRequireDefault(require("./CustomButton"));
26
26
  var _CustomColor = require("./CustomColor");
@@ -594,6 +594,9 @@ var Toolbar = function Toolbar(_a) {
594
594
  }
595
595
  }
596
596
  }, [itemLocations, setMoreItems, settings.toolbarItems.length, sheetWidth, isDesktop]);
597
+ var _o = (0, _react.useState)(false),
598
+ showDataValidation = _o[0],
599
+ setShowDataValidation = _o[1];
597
600
  var getToolbarItem = (0, _react.useCallback)(function (name, i) {
598
601
  var _a, _b, _c, _d, _e, _f, _g;
599
602
  var tooltip = toolbar[name];
@@ -970,24 +973,31 @@ var Toolbar = function Toolbar(_a) {
970
973
  });
971
974
  }
972
975
  if (name === "dataVerification") {
973
- return /*#__PURE__*/_react.default.createElement(_Button.default, {
976
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dataVerificationPortal.default, {
977
+ visible: showDataValidation
978
+ }), /*#__PURE__*/_react.default.createElement(_Button.default, {
974
979
  iconId: name,
975
980
  tooltip: tooltip,
976
981
  key: name,
977
982
  onClick: function onClick() {
978
983
  var _a;
984
+ var selection = (0, _api.getSelection)(context);
985
+ if (!selection) {
986
+ setContext(function (ctx) {
987
+ (0, _api.setSelection)(ctx, [{
988
+ row: [0, 0],
989
+ column: [0, 0]
990
+ }], {
991
+ id: context.currentSheetId
992
+ });
993
+ });
994
+ }
979
995
  (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
980
996
  setTimeout(function () {
981
- var target = document.getElementById('placeholder-data-validation');
982
- console.log("Target for DataValidation:", target);
983
- console.log("DataValidationComponent:", _DataVerification.default);
984
- if (target) {
985
- var root = _client.default.createRoot(target);
986
- root.render(/*#__PURE__*/_react.default.createElement(_DataVerification.default, null));
987
- }
997
+ setShowDataValidation(true);
988
998
  }, 100);
989
999
  }
990
- });
1000
+ }));
991
1001
  }
992
1002
  if (name === "locationCondition") {
993
1003
  var items_3 = [{
@@ -4,7 +4,6 @@ import { SetContextOptions } from "../../context";
4
4
  export declare function generateAPIs(context: Context, setContext: (recipe: (ctx: Context) => void, options?: SetContextOptions) => void, handleUndo: () => void, handleRedo: () => void, settings: Required<Settings>, cellInput: HTMLDivElement | null, scrollbarX: HTMLDivElement | null, scrollbarY: HTMLDivElement | null, globalCache: GlobalCache | null): {
5
5
  applyOp: (ops: Op[]) => void;
6
6
  getCryptoPrice: typeof getCryptoPrice;
7
- DataVerificationComponent: import("react").FC<{}>;
8
7
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
9
8
  type?: keyof Cell;
10
9
  }) => any;
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.generateAPIs = generateAPIs;
7
7
  var _fortuneCore = require("@fileverse-dev/fortune-core");
8
- var _DataVerification = _interopRequireDefault(require("../DataVerification"));
9
8
  var _immer = require("immer");
10
9
  var _lodash = _interopRequireDefault(require("lodash"));
11
10
  var _cryptoApi = require("../../utils/cryptoApi");
@@ -74,7 +73,6 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
74
73
  });
75
74
  },
76
75
  getCryptoPrice: _cryptoApi.getCryptoPrice,
77
- DataVerificationComponent: _DataVerification.default,
78
76
  getCellValue: function getCellValue(row, column, options) {
79
77
  if (options === void 0) {
80
78
  options = {};
@@ -11,7 +11,6 @@ type AdditionalProps = {
11
11
  declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalProps & React.RefAttributes<{
12
12
  applyOp: (ops: Op[]) => void;
13
13
  getCryptoPrice: typeof getCryptoPrice;
14
- DataVerificationComponent: React.FC<{}>;
15
14
  getCellValue: (row: number, column: number, options?: api.CommonOptions & {
16
15
  type?: "error" | "rt" | "f" | "m" | "v" | "mc" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
17
16
  }) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.94",
3
+ "version": "1.1.96",
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.94",
19
+ "@fileverse-dev/fortune-core": "1.1.96",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",