@fileverse-dev/fortune-react 1.1.4 → 1.1.5-live-query-2

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.
@@ -1,4 +1,4 @@
1
- import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache } from "@fileverse-dev/fortune-core";
1
+ import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
2
2
  import { getCryptoPrice } from "../../utils/cryptoApi";
3
3
  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): {
@@ -9,6 +9,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
9
9
  }) => any;
10
10
  onboardingActiveCell: (functionName: string) => void;
11
11
  initializeComment: (row: number, column: number) => void;
12
+ updateSheetLiveQueryList: (subsheetIndex: number, _data: LiveQueryData) => void;
13
+ removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
12
14
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
13
15
  type?: keyof Cell;
14
16
  }) => void;
@@ -109,6 +111,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
109
111
  column_focus: number;
110
112
  } | undefined;
111
113
  } | undefined;
114
+ liveQueryList?: Record<string, LiveQueryData> | undefined;
112
115
  };
113
116
  addSheet: () => void;
114
117
  deleteSheet: (options?: api.CommonOptions) => void;
@@ -1,3 +1,13 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
+ }
7
+ return t;
8
+ };
9
+ return __assign.apply(this, arguments);
10
+ };
1
11
  import { addSheet, api, deleteRowCol, deleteSheet, insertRowCol, opToPatch, createFilterOptions, getSheetIndex, locale, setCaretPosition, newComment } from "@fileverse-dev/fortune-core";
2
12
  import { applyPatches } from "immer";
3
13
  import _ from "lodash";
@@ -103,6 +113,24 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
103
113
  newComment(ctx, undefined, row, column);
104
114
  });
105
115
  },
116
+ updateSheetLiveQueryList: function updateSheetLiveQueryList(subsheetIndex, _data) {
117
+ setContext(function (ctx) {
118
+ var _a;
119
+ var previousLiveQuery = ctx.luckysheetfile[subsheetIndex].liveQueryList;
120
+ ctx.luckysheetfile[subsheetIndex] = __assign(__assign({}, ctx.luckysheetfile[subsheetIndex]), {
121
+ liveQueryList: __assign(__assign({}, previousLiveQuery), (_a = {}, _a["".concat(_data.data.id)] = _data, _a))
122
+ });
123
+ });
124
+ },
125
+ removeFromLiveQueryList: function removeFromLiveQueryList(subSheetIndex, id) {
126
+ setContext(function (ctx) {
127
+ var previousLiveQuery = __assign({}, ctx.luckysheetfile[subSheetIndex].liveQueryList);
128
+ previousLiveQuery === null || previousLiveQuery === void 0 ? true : delete previousLiveQuery[id];
129
+ ctx.luckysheetfile[subSheetIndex] = __assign(__assign({}, ctx.luckysheetfile[subSheetIndex]), {
130
+ liveQueryList: previousLiveQuery
131
+ });
132
+ });
133
+ },
106
134
  setCellValue: function setCellValue(row, column, value, options) {
107
135
  if (options === void 0) {
108
136
  options = {};
@@ -16,6 +16,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
16
16
  }) => any;
17
17
  onboardingActiveCell: (functionName: string) => void;
18
18
  initializeComment: (row: number, column: number) => void;
19
+ updateSheetLiveQueryList: (subsheetIndex: number, _data: import("@fileverse-dev/fortune-core").LiveQueryData) => void;
20
+ removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
19
21
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
20
22
  type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
21
23
  }) => void;
@@ -116,6 +118,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
116
118
  column_focus: number;
117
119
  } | undefined;
118
120
  } | undefined;
121
+ liveQueryList?: Record<string, import("@fileverse-dev/fortune-core").LiveQueryData> | undefined;
119
122
  };
120
123
  addSheet: () => void;
121
124
  deleteSheet: (options?: api.CommonOptions) => void;
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useContext, useRef, useState } from "react";
1
+ import React, { useCallback, useContext, useRef, useState, useEffect } from "react";
2
2
  import { MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, getSheetIndex } from "@fileverse-dev/fortune-core";
3
3
  import WorkbookContext from "../../context";
4
4
  import SVGIcon from "../SVGIcon";
@@ -59,6 +59,21 @@ var ZoomControl = function ZoomControl() {
59
59
  noHistory: true
60
60
  });
61
61
  }, [setContext]);
62
+ useEffect(function () {
63
+ var handleKeyDown = function handleKeyDown(e) {
64
+ if ((e.metaKey || e.ctrlKey) && e.code === "Equal") {
65
+ zoomTo(context.zoomRatio + 0.1);
66
+ e.stopPropagation();
67
+ } else if ((e.metaKey || e.ctrlKey) && e.code === "Minus") {
68
+ zoomTo(context.zoomRatio - 0.1);
69
+ e.stopPropagation();
70
+ }
71
+ };
72
+ document.addEventListener("keydown", handleKeyDown);
73
+ return function () {
74
+ document.removeEventListener("keydown", handleKeyDown);
75
+ };
76
+ }, [context.zoomRatio]);
62
77
  return /*#__PURE__*/React.createElement("div", {
63
78
  className: "fortune-zoom-container"
64
79
  }, /*#__PURE__*/React.createElement("div", {
@@ -2,4 +2,4 @@ import Workbook from "./Workbook";
2
2
  export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from "@fileverse-dev/formulajs/crypto-constants";
3
3
  export { Workbook };
4
4
  export type { WorkbookInstance } from "./Workbook";
5
- export type { Cell, Sheet } from "@fileverse-dev/fortune-core";
5
+ export type { Cell, Sheet, LiveQueryData } from "@fileverse-dev/fortune-core";
@@ -1,4 +1,4 @@
1
- import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache } from "@fileverse-dev/fortune-core";
1
+ import { api, Cell, Context, Op, Range, Selection, Presence, Settings, SingleRange, Sheet, CellMatrix, CellWithRowAndCol, GlobalCache, LiveQueryData } from "@fileverse-dev/fortune-core";
2
2
  import { getCryptoPrice } from "../../utils/cryptoApi";
3
3
  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): {
@@ -9,6 +9,8 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
9
9
  }) => any;
10
10
  onboardingActiveCell: (functionName: string) => void;
11
11
  initializeComment: (row: number, column: number) => void;
12
+ updateSheetLiveQueryList: (subsheetIndex: number, _data: LiveQueryData) => void;
13
+ removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
12
14
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
13
15
  type?: keyof Cell;
14
16
  }) => void;
@@ -109,6 +111,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
109
111
  column_focus: number;
110
112
  } | undefined;
111
113
  } | undefined;
114
+ liveQueryList?: Record<string, LiveQueryData> | undefined;
112
115
  };
113
116
  addSheet: () => void;
114
117
  deleteSheet: (options?: api.CommonOptions) => void;
@@ -9,6 +9,16 @@ var _immer = require("immer");
9
9
  var _lodash = _interopRequireDefault(require("lodash"));
10
10
  var _cryptoApi = require("../../utils/cryptoApi");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ var __assign = void 0 && (void 0).__assign || function () {
13
+ __assign = Object.assign || function (t) {
14
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
15
+ s = arguments[i];
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
12
22
  function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache) {
13
23
  return {
14
24
  applyOp: function applyOp(ops) {
@@ -110,6 +120,24 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
110
120
  (0, _fortuneCore.newComment)(ctx, undefined, row, column);
111
121
  });
112
122
  },
123
+ updateSheetLiveQueryList: function updateSheetLiveQueryList(subsheetIndex, _data) {
124
+ setContext(function (ctx) {
125
+ var _a;
126
+ var previousLiveQuery = ctx.luckysheetfile[subsheetIndex].liveQueryList;
127
+ ctx.luckysheetfile[subsheetIndex] = __assign(__assign({}, ctx.luckysheetfile[subsheetIndex]), {
128
+ liveQueryList: __assign(__assign({}, previousLiveQuery), (_a = {}, _a["".concat(_data.data.id)] = _data, _a))
129
+ });
130
+ });
131
+ },
132
+ removeFromLiveQueryList: function removeFromLiveQueryList(subSheetIndex, id) {
133
+ setContext(function (ctx) {
134
+ var previousLiveQuery = __assign({}, ctx.luckysheetfile[subSheetIndex].liveQueryList);
135
+ previousLiveQuery === null || previousLiveQuery === void 0 ? true : delete previousLiveQuery[id];
136
+ ctx.luckysheetfile[subSheetIndex] = __assign(__assign({}, ctx.luckysheetfile[subSheetIndex]), {
137
+ liveQueryList: previousLiveQuery
138
+ });
139
+ });
140
+ },
113
141
  setCellValue: function setCellValue(row, column, value, options) {
114
142
  if (options === void 0) {
115
143
  options = {};
@@ -16,6 +16,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
16
16
  }) => any;
17
17
  onboardingActiveCell: (functionName: string) => void;
18
18
  initializeComment: (row: number, column: number) => void;
19
+ updateSheetLiveQueryList: (subsheetIndex: number, _data: import("@fileverse-dev/fortune-core").LiveQueryData) => void;
20
+ removeFromLiveQueryList: (subSheetIndex: number, id: string) => void;
19
21
  setCellValue: (row: number, column: number, value: any, options?: api.CommonOptions & {
20
22
  type?: "rt" | "m" | "v" | "mc" | "f" | "ct" | "qp" | "spl" | "bg" | "lo" | "baseValue" | "baseCurrency" | "baseCurrencyPrice" | "isDataBlockFormula" | "ps" | "hl" | keyof import("@fileverse-dev/fortune-core").CellStyle | undefined;
21
23
  }) => void;
@@ -116,6 +118,7 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
116
118
  column_focus: number;
117
119
  } | undefined;
118
120
  } | undefined;
121
+ liveQueryList?: Record<string, import("@fileverse-dev/fortune-core").LiveQueryData> | undefined;
119
122
  };
120
123
  addSheet: () => void;
121
124
  deleteSheet: (options?: api.CommonOptions) => void;
@@ -68,6 +68,21 @@ var ZoomControl = function ZoomControl() {
68
68
  noHistory: true
69
69
  });
70
70
  }, [setContext]);
71
+ (0, _react.useEffect)(function () {
72
+ var handleKeyDown = function handleKeyDown(e) {
73
+ if ((e.metaKey || e.ctrlKey) && e.code === "Equal") {
74
+ zoomTo(context.zoomRatio + 0.1);
75
+ e.stopPropagation();
76
+ } else if ((e.metaKey || e.ctrlKey) && e.code === "Minus") {
77
+ zoomTo(context.zoomRatio - 0.1);
78
+ e.stopPropagation();
79
+ }
80
+ };
81
+ document.addEventListener("keydown", handleKeyDown);
82
+ return function () {
83
+ document.removeEventListener("keydown", handleKeyDown);
84
+ };
85
+ }, [context.zoomRatio]);
71
86
  return /*#__PURE__*/_react.default.createElement("div", {
72
87
  className: "fortune-zoom-container"
73
88
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -2,4 +2,4 @@ import Workbook from "./Workbook";
2
2
  export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from "@fileverse-dev/formulajs/crypto-constants";
3
3
  export { Workbook };
4
4
  export type { WorkbookInstance } from "./Workbook";
5
- export type { Cell, Sheet } from "@fileverse-dev/fortune-core";
5
+ export type { Cell, Sheet, LiveQueryData } from "@fileverse-dev/fortune-core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.1.4",
3
+ "version": "1.1.5-live-query-2",
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.4",
19
+ "@fileverse-dev/fortune-core": "1.1.5-live-query-2",
20
20
  "@fileverse/ui": "^4.1.7-patch-21",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",