@fileverse-dev/fortune-react 1.1.95 → 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",
@@ -3,7 +3,7 @@ import { createPortal } from "react-dom";
3
3
  import DataVerification from "../DataVerification";
4
4
  var DataVerificationPortal = function DataVerificationPortal(_a) {
5
5
  var visible = _a.visible;
6
- var container = document.getElementById("placeholder-data-validation");
6
+ var container = document.getElementById("placeholder-data-verification");
7
7
  if (!visible || !container) return null;
8
8
  return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(DataVerification, null), container);
9
9
  };
@@ -125,6 +125,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
125
125
  import React, { useContext, useCallback, useRef, useEffect, useState } from "react";
126
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";
@@ -971,6 +972,17 @@ var Toolbar = function Toolbar(_a) {
971
972
  key: name,
972
973
  onClick: function onClick() {
973
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
+ }
974
986
  (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
975
987
  setTimeout(function () {
976
988
  setShowDataValidation(true);
@@ -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",
@@ -10,7 +10,7 @@ var _DataVerification = _interopRequireDefault(require("../DataVerification"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  var DataVerificationPortal = function DataVerificationPortal(_a) {
12
12
  var visible = _a.visible;
13
- var container = document.getElementById("placeholder-data-validation");
13
+ var container = document.getElementById("placeholder-data-verification");
14
14
  if (!visible || !container) return null;
15
15
  return /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_DataVerification.default, null), container);
16
16
  };
@@ -8,6 +8,7 @@ exports.getLucideIcon = exports.default = exports.CurrencySelector = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
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"));
@@ -980,6 +981,17 @@ var Toolbar = function Toolbar(_a) {
980
981
  key: name,
981
982
  onClick: function onClick() {
982
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
+ }
983
995
  (_a = document.getElementById("data-verification-button")) === null || _a === void 0 ? void 0 : _a.click();
984
996
  setTimeout(function () {
985
997
  setShowDataValidation(true);
@@ -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.95",
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.95",
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",