@fileverse-dev/fortune-react 1.1.96 → 1.1.98
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.
- package/es/components/DataVerification/DropdownList.js +10 -1
- package/es/components/DataVerification/DropdownOption.js +9 -1
- package/es/components/DataVerification/index.js +1 -19
- package/es/components/SheetOverlay/FormulaHint/index.js +11 -4
- package/es/components/SheetOverlay/InputBox.js +21 -8
- package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +18 -0
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +18 -0
- package/es/components/SheetOverlay/helper.d.ts +2 -0
- package/es/components/SheetOverlay/helper.js +33 -0
- package/es/components/Toolbar/index.js +1 -1
- package/lib/components/DataVerification/DropdownList.js +10 -1
- package/lib/components/DataVerification/DropdownOption.js +9 -1
- package/lib/components/DataVerification/index.js +1 -19
- package/lib/components/SheetOverlay/FormulaHint/index.js +11 -4
- package/lib/components/SheetOverlay/InputBox.js +21 -8
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +18 -0
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +18 -0
- package/lib/components/SheetOverlay/helper.d.ts +2 -0
- package/lib/components/SheetOverlay/helper.js +35 -0
- package/lib/components/Toolbar/index.js +1 -1
- package/package.json +2 -2
|
@@ -24,7 +24,16 @@ var DropDownList = function DropDownList() {
|
|
|
24
24
|
var _f = useState([]),
|
|
25
25
|
rbgColor = _f[0],
|
|
26
26
|
setRbgColor = _f[1];
|
|
27
|
-
var close = useCallback(function () {
|
|
27
|
+
var close = useCallback(function () {
|
|
28
|
+
setContext(function (ctx) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
var index = getSheetIndex(ctx, ctx.currentSheetId);
|
|
31
|
+
var verification = context.luckysheetfile[index].dataVerification;
|
|
32
|
+
if (!verification["".concat((_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0].row_focus, "_").concat((_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0].column_focus)]) {
|
|
33
|
+
ctx.dataVerificationDropDownList = false;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}, [setContext]);
|
|
28
37
|
useOutsideClick(containerRef, close, [close]);
|
|
29
38
|
useEffect(function () {
|
|
30
39
|
var _a, _b;
|
|
@@ -235,11 +235,19 @@ var DynamicInputList = function DynamicInputList(_a) {
|
|
|
235
235
|
})), /*#__PURE__*/React.createElement("div", {
|
|
236
236
|
className: "flex flex-1 optionItems-center transition"
|
|
237
237
|
}, /*#__PURE__*/React.createElement(TextField, {
|
|
238
|
+
type: "text",
|
|
239
|
+
onMouseDown: function onMouseDown(e) {
|
|
240
|
+
e.stopPropagation();
|
|
241
|
+
e.target.focus();
|
|
242
|
+
},
|
|
243
|
+
key: item.id,
|
|
238
244
|
className: "w-full",
|
|
239
245
|
placeholder: "Option ".concat(index + 1),
|
|
240
246
|
value: item.value,
|
|
241
247
|
onChange: function onChange(e) {
|
|
242
|
-
|
|
248
|
+
e.stopPropagation();
|
|
249
|
+
handleChange(index, e.target.value);
|
|
250
|
+
e.target.focus();
|
|
243
251
|
},
|
|
244
252
|
"aria-label": "Option ".concat(index + 1)
|
|
245
253
|
})), optionItems.length > 1 && (/*#__PURE__*/React.createElement(IconButton, {
|
|
@@ -84,14 +84,6 @@ var DataVerification = function DataVerification() {
|
|
|
84
84
|
}));
|
|
85
85
|
}
|
|
86
86
|
}, []);
|
|
87
|
-
var dataSelectRange = useCallback(function (type, value) {
|
|
88
|
-
hideDialog();
|
|
89
|
-
setContext(function (ctx) {
|
|
90
|
-
ctx.rangeDialog.show = true;
|
|
91
|
-
ctx.rangeDialog.type = type;
|
|
92
|
-
ctx.rangeDialog.rangeTxt = value;
|
|
93
|
-
});
|
|
94
|
-
}, [hideDialog, setContext]);
|
|
95
87
|
var btn = useCallback(function (type) {
|
|
96
88
|
if (type === "confirm") {
|
|
97
89
|
setContext(function (ctx) {
|
|
@@ -234,17 +226,7 @@ var DataVerification = function DataVerification() {
|
|
|
234
226
|
}),
|
|
235
227
|
"aria-hidden": "true",
|
|
236
228
|
readOnly: true,
|
|
237
|
-
value: (_a = context.dataVerification.dataRegulation) === null || _a === void 0 ? void 0 : _a.rangeTxt
|
|
238
|
-
onChange: function onChange(e) {
|
|
239
|
-
var value = e.target.value;
|
|
240
|
-
setContext(function (ctx) {
|
|
241
|
-
ctx.dataVerification.dataRegulation.rangeTxt = value;
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
onClick: function onClick() {
|
|
245
|
-
hideDialog();
|
|
246
|
-
dataSelectRange("rangeTxt", context.dataVerification.dataRegulation.value1);
|
|
247
|
-
}
|
|
229
|
+
value: (_a = context.dataVerification.dataRegulation) === null || _a === void 0 ? void 0 : _a.rangeTxt
|
|
248
230
|
})), /*#__PURE__*/React.createElement("div", {
|
|
249
231
|
className: "flex flex-col"
|
|
250
232
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -17,7 +17,8 @@ import { DraggableDiv } from "./dragable-div";
|
|
|
17
17
|
var FormulaHint = function FormulaHint(props) {
|
|
18
18
|
var _a;
|
|
19
19
|
var showFormulaHint = props.showFormulaHint,
|
|
20
|
-
handleShowFormulaHint = props.handleShowFormulaHint
|
|
20
|
+
handleShowFormulaHint = props.handleShowFormulaHint,
|
|
21
|
+
commaCount = props.commaCount;
|
|
21
22
|
var dragHasMoved = useRef(false);
|
|
22
23
|
var context = useContext(WorkbookContext).context;
|
|
23
24
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -186,7 +187,10 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
186
187
|
return /*#__PURE__*/React.createElement("code", {
|
|
187
188
|
className: "luckysheet-arguments-help-parameter font-family-mono mb-1 mt-2 color-text-default",
|
|
188
189
|
dir: "auto",
|
|
189
|
-
key: name
|
|
190
|
+
key: name,
|
|
191
|
+
style: {
|
|
192
|
+
backgroundColor: commaCount === i ? (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) || "#FFDF0A" : "transparent"
|
|
193
|
+
}
|
|
190
194
|
}, name, i !== fn.p.length - 1 && ", ");
|
|
191
195
|
})), /*#__PURE__*/React.createElement("code", {
|
|
192
196
|
className: "luckysheet-arguments-paren font-family-mono mb-1 mt-2 color-text-default"
|
|
@@ -354,12 +358,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
354
358
|
paddingTop: "16px"
|
|
355
359
|
},
|
|
356
360
|
className: "luckysheet-formula-help-content-param"
|
|
357
|
-
}, fn.p.map(function (param) {
|
|
361
|
+
}, fn.p.map(function (param, index) {
|
|
358
362
|
return /*#__PURE__*/React.createElement("div", {
|
|
359
363
|
className: "",
|
|
360
364
|
key: param.name
|
|
361
365
|
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("code", {
|
|
362
|
-
className: "font-family-mono mb-1 mt-2 color-text-default font-family-mono"
|
|
366
|
+
className: "font-family-mono mb-1 mt-2 color-text-default font-family-mono",
|
|
367
|
+
style: {
|
|
368
|
+
backgroundColor: commaCount === index ? (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) || "#FFDF0A" : "transparent"
|
|
369
|
+
}
|
|
363
370
|
}, param.name, param.repeat === "y" && (/*#__PURE__*/React.createElement("span", {
|
|
364
371
|
className: "luckysheet-arguments-help-argument-info example-value",
|
|
365
372
|
style: {
|
|
@@ -17,7 +17,7 @@ import ContentEditable from "./ContentEditable";
|
|
|
17
17
|
import FormulaSearch from "./FormulaSearch";
|
|
18
18
|
import FormulaHint from "./FormulaHint";
|
|
19
19
|
import usePrevious from "../../hooks/usePrevious";
|
|
20
|
-
import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, incrementColumn, decrementColumn, incrementRow, decrementRow } from "./helper";
|
|
20
|
+
import { moveCursorToEnd, getCursorPosition, isLetterNumberPattern, removeLastSpan, incrementColumn, decrementColumn, incrementRow, decrementRow, countCommasBeforeCursor } from "./helper";
|
|
21
21
|
import { LucideIcon } from "./LucideIcon";
|
|
22
22
|
var InputBox = function InputBox() {
|
|
23
23
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -51,13 +51,16 @@ var InputBox = function InputBox() {
|
|
|
51
51
|
var _q = useState({}),
|
|
52
52
|
firstSelectionActiveCell = _q[0],
|
|
53
53
|
setFirstSelectionActiveCell = _q[1];
|
|
54
|
+
var _r = useState(0),
|
|
55
|
+
commaCount = _r[0],
|
|
56
|
+
setCommaCount = _r[1];
|
|
54
57
|
var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
|
|
55
|
-
var
|
|
56
|
-
showFormulaHint =
|
|
57
|
-
setShowFormulaHint =
|
|
58
|
-
var
|
|
59
|
-
showSearchHint =
|
|
60
|
-
setShowSearchHint =
|
|
58
|
+
var _s = useState(!hideFormulaHintLocal),
|
|
59
|
+
showFormulaHint = _s[0],
|
|
60
|
+
setShowFormulaHint = _s[1];
|
|
61
|
+
var _t = useState(false),
|
|
62
|
+
showSearchHint = _t[0],
|
|
63
|
+
setShowSearchHint = _t[1];
|
|
61
64
|
var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
62
65
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
63
66
|
var preText = useRef("");
|
|
@@ -242,6 +245,9 @@ var InputBox = function InputBox() {
|
|
|
242
245
|
var _a, _b;
|
|
243
246
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
244
247
|
preText.current = inputRef.current.innerText;
|
|
248
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
249
|
+
console.log("currentCommaCount", currentCommaCount);
|
|
250
|
+
setCommaCount(currentCommaCount);
|
|
245
251
|
var allowListNavigation = true;
|
|
246
252
|
if ((e.key === "Delete" || e.key === "Backspace") && getCursorPosition(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
|
|
247
253
|
setTimeout(function () {
|
|
@@ -344,6 +350,8 @@ var InputBox = function InputBox() {
|
|
|
344
350
|
} else {
|
|
345
351
|
setShowSearchHint(false);
|
|
346
352
|
}
|
|
353
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
354
|
+
setCommaCount(currentCommaCount);
|
|
347
355
|
var e = lastKeyDownEventRef.current;
|
|
348
356
|
if (!e) return;
|
|
349
357
|
var kcode = e.keyCode;
|
|
@@ -487,6 +495,10 @@ var InputBox = function InputBox() {
|
|
|
487
495
|
minHeight: firstSelection.height
|
|
488
496
|
}, inputBoxStyle) : {}
|
|
489
497
|
}, /*#__PURE__*/React.createElement(ContentEditable, {
|
|
498
|
+
onMouseUp: function onMouseUp(e) {
|
|
499
|
+
var currentCommaCount = countCommasBeforeCursor(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
500
|
+
setCommaCount(currentCommaCount);
|
|
501
|
+
},
|
|
490
502
|
innerRef: function innerRef(e) {
|
|
491
503
|
inputRef.current = e;
|
|
492
504
|
refs.cellInput.current = e;
|
|
@@ -520,7 +532,8 @@ var InputBox = function InputBox() {
|
|
|
520
532
|
}
|
|
521
533
|
})), showFormulaHint && fn && ((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.innerText.includes("(")) && (/*#__PURE__*/React.createElement(FormulaHint, {
|
|
522
534
|
handleShowFormulaHint: handleShowFormulaHint,
|
|
523
|
-
showFormulaHint: showFormulaHint
|
|
535
|
+
showFormulaHint: showFormulaHint,
|
|
536
|
+
commaCount: commaCount
|
|
524
537
|
})), !showFormulaHint && fn && (/*#__PURE__*/React.createElement(Tooltip, {
|
|
525
538
|
text: "Turn on formula suggestions (F10)",
|
|
526
539
|
placement: "top",
|
|
@@ -272,6 +272,24 @@ export var useColumnDragAndDrop = function useColumnDragAndDrop(containerRef, se
|
|
|
272
272
|
}
|
|
273
273
|
});
|
|
274
274
|
});
|
|
275
|
+
var newDataVerification = {};
|
|
276
|
+
Object.keys(_sheet.dataVerification).forEach(function (item) {
|
|
277
|
+
var _a;
|
|
278
|
+
var itemData = (_a = _sheet.dataVerification) === null || _a === void 0 ? void 0 : _a[item];
|
|
279
|
+
var colRow = item.split("_");
|
|
280
|
+
if (colRow.length !== 2) return;
|
|
281
|
+
var presentcol = parseInt(colRow[1], 10);
|
|
282
|
+
var updatedCol = presentcol;
|
|
283
|
+
if (presentcol === sourceIndex_1) {
|
|
284
|
+
updatedCol = targetIndex;
|
|
285
|
+
} else if (presentcol > sourceIndex_1 && presentcol < targetIndex) {
|
|
286
|
+
updatedCol -= 1;
|
|
287
|
+
} else if (presentcol < sourceIndex_1 && presentcol >= targetIndex) {
|
|
288
|
+
updatedCol += 1;
|
|
289
|
+
}
|
|
290
|
+
newDataVerification["".concat(colRow[0], "_").concat(updatedCol)] = itemData;
|
|
291
|
+
});
|
|
292
|
+
_sheet.dataVerification = newDataVerification;
|
|
275
293
|
(_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
|
|
276
294
|
if (item.c === sourceIndex_1) {
|
|
277
295
|
item.c = targetIndex;
|
|
@@ -253,6 +253,24 @@ export var useRowDragAndDrop = function useRowDragAndDrop(containerRef, selected
|
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
255
|
});
|
|
256
|
+
var newDataVerification = {};
|
|
257
|
+
Object.keys(_sheet.dataVerification).forEach(function (item) {
|
|
258
|
+
var _a;
|
|
259
|
+
var itemData = (_a = _sheet.dataVerification) === null || _a === void 0 ? void 0 : _a[item];
|
|
260
|
+
var colRow = item.split("_");
|
|
261
|
+
if (colRow.length !== 2) return;
|
|
262
|
+
var presentRow = parseInt(colRow[0], 10);
|
|
263
|
+
var updatedRow = presentRow;
|
|
264
|
+
if (presentRow === sourceIndex_1) {
|
|
265
|
+
updatedRow = targetIndex;
|
|
266
|
+
} else if (presentRow > sourceIndex_1 && presentRow < targetIndex) {
|
|
267
|
+
updatedRow -= 1;
|
|
268
|
+
} else if (presentRow < sourceIndex_1 && presentRow >= targetIndex) {
|
|
269
|
+
updatedRow += 1;
|
|
270
|
+
}
|
|
271
|
+
newDataVerification["".concat(updatedRow, "_").concat(colRow[1])] = itemData;
|
|
272
|
+
});
|
|
273
|
+
_sheet.dataVerification = newDataVerification;
|
|
256
274
|
(_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
|
|
257
275
|
if (item.r === sourceIndex_1) {
|
|
258
276
|
item.r = targetIndex;
|
|
@@ -6,3 +6,5 @@ export declare function incrementColumn(cell: string): string;
|
|
|
6
6
|
export declare function decrementColumn(cell: string): string;
|
|
7
7
|
export declare function incrementRow(cell: string): string;
|
|
8
8
|
export declare function decrementRow(cell: string): string;
|
|
9
|
+
export declare function countCommasOutsideQuotes(str: string): number;
|
|
10
|
+
export declare function countCommasBeforeCursor(editableDiv: HTMLDivElement): number;
|
|
@@ -83,4 +83,37 @@ export function decrementRow(cell) {
|
|
|
83
83
|
if (!parsed) return "";
|
|
84
84
|
var newRowPart = Math.max(1, parsed.rowPart - 1);
|
|
85
85
|
return parsed.colPart + newRowPart;
|
|
86
|
+
}
|
|
87
|
+
export function countCommasOutsideQuotes(str) {
|
|
88
|
+
var inQuotes = false;
|
|
89
|
+
var count = 0;
|
|
90
|
+
for (var i = 0; i < str.length; i++) {
|
|
91
|
+
var char = str[i];
|
|
92
|
+
if (char === '"') {
|
|
93
|
+
inQuotes = !inQuotes;
|
|
94
|
+
} else if (char === ',' && !inQuotes) {
|
|
95
|
+
count++;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return count;
|
|
99
|
+
}
|
|
100
|
+
export function countCommasBeforeCursor(editableDiv) {
|
|
101
|
+
var selection = window.getSelection();
|
|
102
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.rangeCount)) return 0;
|
|
103
|
+
var range = selection.getRangeAt(0);
|
|
104
|
+
var preCaretRange = range.cloneRange();
|
|
105
|
+
preCaretRange.selectNodeContents(editableDiv);
|
|
106
|
+
preCaretRange.setEnd(range.endContainer, range.endOffset);
|
|
107
|
+
var textBeforeCursor = preCaretRange.toString();
|
|
108
|
+
var inQuotes = false;
|
|
109
|
+
var count = 0;
|
|
110
|
+
for (var i = 0; i < textBeforeCursor.length; i++) {
|
|
111
|
+
var char = textBeforeCursor[i];
|
|
112
|
+
if (char === '"') {
|
|
113
|
+
inQuotes = !inQuotes;
|
|
114
|
+
} else if (char === ',' && !inQuotes) {
|
|
115
|
+
count++;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return count;
|
|
86
119
|
}
|
|
@@ -123,11 +123,11 @@ 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 DataVerificationPortal from "./dataVerificationPortal";
|
|
127
126
|
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
127
|
import { setSelection, getSelection } from "@fileverse-dev/fortune-core/lib/api";
|
|
129
128
|
import _ from "lodash";
|
|
130
129
|
import { IconButton, LucideIcon, Tooltip, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "@fileverse/ui";
|
|
130
|
+
import DataVerificationPortal from "./dataVerificationPortal";
|
|
131
131
|
import WorkbookContext from "../../context";
|
|
132
132
|
import "./index.css";
|
|
133
133
|
import Button from "./Button";
|
|
@@ -33,7 +33,16 @@ var DropDownList = function DropDownList() {
|
|
|
33
33
|
var _f = (0, _react.useState)([]),
|
|
34
34
|
rbgColor = _f[0],
|
|
35
35
|
setRbgColor = _f[1];
|
|
36
|
-
var close = (0, _react.useCallback)(function () {
|
|
36
|
+
var close = (0, _react.useCallback)(function () {
|
|
37
|
+
setContext(function (ctx) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var index = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
|
|
40
|
+
var verification = context.luckysheetfile[index].dataVerification;
|
|
41
|
+
if (!verification["".concat((_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0].row_focus, "_").concat((_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0].column_focus)]) {
|
|
42
|
+
ctx.dataVerificationDropDownList = false;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, [setContext]);
|
|
37
46
|
(0, _useOutsideClick.useOutsideClick)(containerRef, close, [close]);
|
|
38
47
|
(0, _react.useEffect)(function () {
|
|
39
48
|
var _a, _b;
|
|
@@ -242,11 +242,19 @@ var DynamicInputList = function DynamicInputList(_a) {
|
|
|
242
242
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
243
243
|
className: "flex flex-1 optionItems-center transition"
|
|
244
244
|
}, /*#__PURE__*/_react.default.createElement(_ui.TextField, {
|
|
245
|
+
type: "text",
|
|
246
|
+
onMouseDown: function onMouseDown(e) {
|
|
247
|
+
e.stopPropagation();
|
|
248
|
+
e.target.focus();
|
|
249
|
+
},
|
|
250
|
+
key: item.id,
|
|
245
251
|
className: "w-full",
|
|
246
252
|
placeholder: "Option ".concat(index + 1),
|
|
247
253
|
value: item.value,
|
|
248
254
|
onChange: function onChange(e) {
|
|
249
|
-
|
|
255
|
+
e.stopPropagation();
|
|
256
|
+
handleChange(index, e.target.value);
|
|
257
|
+
e.target.focus();
|
|
250
258
|
},
|
|
251
259
|
"aria-label": "Option ".concat(index + 1)
|
|
252
260
|
})), optionItems.length > 1 && (/*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
@@ -93,14 +93,6 @@ var DataVerification = function DataVerification() {
|
|
|
93
93
|
}));
|
|
94
94
|
}
|
|
95
95
|
}, []);
|
|
96
|
-
var dataSelectRange = (0, _react.useCallback)(function (type, value) {
|
|
97
|
-
hideDialog();
|
|
98
|
-
setContext(function (ctx) {
|
|
99
|
-
ctx.rangeDialog.show = true;
|
|
100
|
-
ctx.rangeDialog.type = type;
|
|
101
|
-
ctx.rangeDialog.rangeTxt = value;
|
|
102
|
-
});
|
|
103
|
-
}, [hideDialog, setContext]);
|
|
104
96
|
var btn = (0, _react.useCallback)(function (type) {
|
|
105
97
|
if (type === "confirm") {
|
|
106
98
|
setContext(function (ctx) {
|
|
@@ -243,17 +235,7 @@ var DataVerification = function DataVerification() {
|
|
|
243
235
|
}),
|
|
244
236
|
"aria-hidden": "true",
|
|
245
237
|
readOnly: true,
|
|
246
|
-
value: (_a = context.dataVerification.dataRegulation) === null || _a === void 0 ? void 0 : _a.rangeTxt
|
|
247
|
-
onChange: function onChange(e) {
|
|
248
|
-
var value = e.target.value;
|
|
249
|
-
setContext(function (ctx) {
|
|
250
|
-
ctx.dataVerification.dataRegulation.rangeTxt = value;
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
onClick: function onClick() {
|
|
254
|
-
hideDialog();
|
|
255
|
-
dataSelectRange("rangeTxt", context.dataVerification.dataRegulation.value1);
|
|
256
|
-
}
|
|
238
|
+
value: (_a = context.dataVerification.dataRegulation) === null || _a === void 0 ? void 0 : _a.rangeTxt
|
|
257
239
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
258
240
|
className: "flex flex-col"
|
|
259
241
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -26,7 +26,8 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
26
26
|
var FormulaHint = function FormulaHint(props) {
|
|
27
27
|
var _a;
|
|
28
28
|
var showFormulaHint = props.showFormulaHint,
|
|
29
|
-
handleShowFormulaHint = props.handleShowFormulaHint
|
|
29
|
+
handleShowFormulaHint = props.handleShowFormulaHint,
|
|
30
|
+
commaCount = props.commaCount;
|
|
30
31
|
var dragHasMoved = (0, _react.useRef)(false);
|
|
31
32
|
var context = (0, _react.useContext)(_context.default).context;
|
|
32
33
|
var firstSelection = (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -195,7 +196,10 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
195
196
|
return /*#__PURE__*/_react.default.createElement("code", {
|
|
196
197
|
className: "luckysheet-arguments-help-parameter font-family-mono mb-1 mt-2 color-text-default",
|
|
197
198
|
dir: "auto",
|
|
198
|
-
key: name
|
|
199
|
+
key: name,
|
|
200
|
+
style: {
|
|
201
|
+
backgroundColor: commaCount === i ? (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) || "#FFDF0A" : "transparent"
|
|
202
|
+
}
|
|
199
203
|
}, name, i !== fn.p.length - 1 && ", ");
|
|
200
204
|
})), /*#__PURE__*/_react.default.createElement("code", {
|
|
201
205
|
className: "luckysheet-arguments-paren font-family-mono mb-1 mt-2 color-text-default"
|
|
@@ -363,12 +367,15 @@ var FormulaHint = function FormulaHint(props) {
|
|
|
363
367
|
paddingTop: "16px"
|
|
364
368
|
},
|
|
365
369
|
className: "luckysheet-formula-help-content-param"
|
|
366
|
-
}, fn.p.map(function (param) {
|
|
370
|
+
}, fn.p.map(function (param, index) {
|
|
367
371
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
368
372
|
className: "",
|
|
369
373
|
key: param.name
|
|
370
374
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("code", {
|
|
371
|
-
className: "font-family-mono mb-1 mt-2 color-text-default font-family-mono"
|
|
375
|
+
className: "font-family-mono mb-1 mt-2 color-text-default font-family-mono",
|
|
376
|
+
style: {
|
|
377
|
+
backgroundColor: commaCount === index ? (fn === null || fn === void 0 ? void 0 : fn.BRAND_SECONDARY_COLOR) || "#FFDF0A" : "transparent"
|
|
378
|
+
}
|
|
372
379
|
}, param.name, param.repeat === "y" && (/*#__PURE__*/_react.default.createElement("span", {
|
|
373
380
|
className: "luckysheet-arguments-help-argument-info example-value",
|
|
374
381
|
style: {
|
|
@@ -17,7 +17,7 @@ var _usePrevious = _interopRequireDefault(require("../../hooks/usePrevious"));
|
|
|
17
17
|
var _helper = require("./helper");
|
|
18
18
|
var _LucideIcon = require("./LucideIcon");
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
20
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
21
21
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
22
22
|
__assign = Object.assign || function (t) {
|
|
23
23
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -60,13 +60,16 @@ var InputBox = function InputBox() {
|
|
|
60
60
|
var _q = (0, _react.useState)({}),
|
|
61
61
|
firstSelectionActiveCell = _q[0],
|
|
62
62
|
setFirstSelectionActiveCell = _q[1];
|
|
63
|
+
var _r = (0, _react.useState)(0),
|
|
64
|
+
commaCount = _r[0],
|
|
65
|
+
setCommaCount = _r[1];
|
|
63
66
|
var hideFormulaHintLocal = localStorage.getItem("formulaMore") === "true";
|
|
64
|
-
var
|
|
65
|
-
showFormulaHint =
|
|
66
|
-
setShowFormulaHint =
|
|
67
|
-
var
|
|
68
|
-
showSearchHint =
|
|
69
|
-
setShowSearchHint =
|
|
67
|
+
var _s = (0, _react.useState)(!hideFormulaHintLocal),
|
|
68
|
+
showFormulaHint = _s[0],
|
|
69
|
+
setShowFormulaHint = _s[1];
|
|
70
|
+
var _t = (0, _react.useState)(false),
|
|
71
|
+
showSearchHint = _t[0],
|
|
72
|
+
setShowSearchHint = _t[1];
|
|
70
73
|
var row_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.row_focus;
|
|
71
74
|
var col_index = firstSelection === null || firstSelection === void 0 ? void 0 : firstSelection.column_focus;
|
|
72
75
|
var preText = (0, _react.useRef)("");
|
|
@@ -251,6 +254,9 @@ var InputBox = function InputBox() {
|
|
|
251
254
|
var _a, _b;
|
|
252
255
|
lastKeyDownEventRef.current = new KeyboardEvent(e.type, e.nativeEvent);
|
|
253
256
|
preText.current = inputRef.current.innerText;
|
|
257
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
258
|
+
console.log("currentCommaCount", currentCommaCount);
|
|
259
|
+
setCommaCount(currentCommaCount);
|
|
254
260
|
var allowListNavigation = true;
|
|
255
261
|
if ((e.key === "Delete" || e.key === "Backspace") && (0, _helper.getCursorPosition)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.innerText.length)) {
|
|
256
262
|
setTimeout(function () {
|
|
@@ -353,6 +359,8 @@ var InputBox = function InputBox() {
|
|
|
353
359
|
} else {
|
|
354
360
|
setShowSearchHint(false);
|
|
355
361
|
}
|
|
362
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
363
|
+
setCommaCount(currentCommaCount);
|
|
356
364
|
var e = lastKeyDownEventRef.current;
|
|
357
365
|
if (!e) return;
|
|
358
366
|
var kcode = e.keyCode;
|
|
@@ -496,6 +504,10 @@ var InputBox = function InputBox() {
|
|
|
496
504
|
minHeight: firstSelection.height
|
|
497
505
|
}, inputBoxStyle) : {}
|
|
498
506
|
}, /*#__PURE__*/_react.default.createElement(_ContentEditable.default, {
|
|
507
|
+
onMouseUp: function onMouseUp(e) {
|
|
508
|
+
var currentCommaCount = (0, _helper.countCommasBeforeCursor)(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
509
|
+
setCommaCount(currentCommaCount);
|
|
510
|
+
},
|
|
499
511
|
innerRef: function innerRef(e) {
|
|
500
512
|
inputRef.current = e;
|
|
501
513
|
refs.cellInput.current = e;
|
|
@@ -529,7 +541,8 @@ var InputBox = function InputBox() {
|
|
|
529
541
|
}
|
|
530
542
|
})), showFormulaHint && fn && ((_h = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _h === void 0 ? void 0 : _h.innerText.includes("(")) && (/*#__PURE__*/_react.default.createElement(_FormulaHint.default, {
|
|
531
543
|
handleShowFormulaHint: handleShowFormulaHint,
|
|
532
|
-
showFormulaHint: showFormulaHint
|
|
544
|
+
showFormulaHint: showFormulaHint,
|
|
545
|
+
commaCount: commaCount
|
|
533
546
|
})), !showFormulaHint && fn && (/*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
534
547
|
text: "Turn on formula suggestions (F10)",
|
|
535
548
|
placement: "top",
|
|
@@ -280,6 +280,24 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
280
280
|
}
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
|
+
var newDataVerification = {};
|
|
284
|
+
Object.keys(_sheet.dataVerification).forEach(function (item) {
|
|
285
|
+
var _a;
|
|
286
|
+
var itemData = (_a = _sheet.dataVerification) === null || _a === void 0 ? void 0 : _a[item];
|
|
287
|
+
var colRow = item.split("_");
|
|
288
|
+
if (colRow.length !== 2) return;
|
|
289
|
+
var presentcol = parseInt(colRow[1], 10);
|
|
290
|
+
var updatedCol = presentcol;
|
|
291
|
+
if (presentcol === sourceIndex_1) {
|
|
292
|
+
updatedCol = targetIndex;
|
|
293
|
+
} else if (presentcol > sourceIndex_1 && presentcol < targetIndex) {
|
|
294
|
+
updatedCol -= 1;
|
|
295
|
+
} else if (presentcol < sourceIndex_1 && presentcol >= targetIndex) {
|
|
296
|
+
updatedCol += 1;
|
|
297
|
+
}
|
|
298
|
+
newDataVerification["".concat(colRow[0], "_").concat(updatedCol)] = itemData;
|
|
299
|
+
});
|
|
300
|
+
_sheet.dataVerification = newDataVerification;
|
|
283
301
|
(_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
|
|
284
302
|
if (item.c === sourceIndex_1) {
|
|
285
303
|
item.c = targetIndex;
|
|
@@ -260,6 +260,24 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
});
|
|
263
|
+
var newDataVerification = {};
|
|
264
|
+
Object.keys(_sheet.dataVerification).forEach(function (item) {
|
|
265
|
+
var _a;
|
|
266
|
+
var itemData = (_a = _sheet.dataVerification) === null || _a === void 0 ? void 0 : _a[item];
|
|
267
|
+
var colRow = item.split("_");
|
|
268
|
+
if (colRow.length !== 2) return;
|
|
269
|
+
var presentRow = parseInt(colRow[0], 10);
|
|
270
|
+
var updatedRow = presentRow;
|
|
271
|
+
if (presentRow === sourceIndex_1) {
|
|
272
|
+
updatedRow = targetIndex;
|
|
273
|
+
} else if (presentRow > sourceIndex_1 && presentRow < targetIndex) {
|
|
274
|
+
updatedRow -= 1;
|
|
275
|
+
} else if (presentRow < sourceIndex_1 && presentRow >= targetIndex) {
|
|
276
|
+
updatedRow += 1;
|
|
277
|
+
}
|
|
278
|
+
newDataVerification["".concat(updatedRow, "_").concat(colRow[1])] = itemData;
|
|
279
|
+
});
|
|
280
|
+
_sheet.dataVerification = newDataVerification;
|
|
263
281
|
(_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
|
|
264
282
|
if (item.r === sourceIndex_1) {
|
|
265
283
|
item.r = targetIndex;
|
|
@@ -6,3 +6,5 @@ export declare function incrementColumn(cell: string): string;
|
|
|
6
6
|
export declare function decrementColumn(cell: string): string;
|
|
7
7
|
export declare function incrementRow(cell: string): string;
|
|
8
8
|
export declare function decrementRow(cell: string): string;
|
|
9
|
+
export declare function countCommasOutsideQuotes(str: string): number;
|
|
10
|
+
export declare function countCommasBeforeCursor(editableDiv: HTMLDivElement): number;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.countCommasBeforeCursor = countCommasBeforeCursor;
|
|
7
|
+
exports.countCommasOutsideQuotes = countCommasOutsideQuotes;
|
|
6
8
|
exports.decrementColumn = decrementColumn;
|
|
7
9
|
exports.decrementRow = decrementRow;
|
|
8
10
|
exports.getCursorPosition = getCursorPosition;
|
|
@@ -96,4 +98,37 @@ function decrementRow(cell) {
|
|
|
96
98
|
if (!parsed) return "";
|
|
97
99
|
var newRowPart = Math.max(1, parsed.rowPart - 1);
|
|
98
100
|
return parsed.colPart + newRowPart;
|
|
101
|
+
}
|
|
102
|
+
function countCommasOutsideQuotes(str) {
|
|
103
|
+
var inQuotes = false;
|
|
104
|
+
var count = 0;
|
|
105
|
+
for (var i = 0; i < str.length; i++) {
|
|
106
|
+
var char = str[i];
|
|
107
|
+
if (char === '"') {
|
|
108
|
+
inQuotes = !inQuotes;
|
|
109
|
+
} else if (char === ',' && !inQuotes) {
|
|
110
|
+
count++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return count;
|
|
114
|
+
}
|
|
115
|
+
function countCommasBeforeCursor(editableDiv) {
|
|
116
|
+
var selection = window.getSelection();
|
|
117
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.rangeCount)) return 0;
|
|
118
|
+
var range = selection.getRangeAt(0);
|
|
119
|
+
var preCaretRange = range.cloneRange();
|
|
120
|
+
preCaretRange.selectNodeContents(editableDiv);
|
|
121
|
+
preCaretRange.setEnd(range.endContainer, range.endOffset);
|
|
122
|
+
var textBeforeCursor = preCaretRange.toString();
|
|
123
|
+
var inQuotes = false;
|
|
124
|
+
var count = 0;
|
|
125
|
+
for (var i = 0; i < textBeforeCursor.length; i++) {
|
|
126
|
+
var char = textBeforeCursor[i];
|
|
127
|
+
if (char === '"') {
|
|
128
|
+
inQuotes = !inQuotes;
|
|
129
|
+
} else if (char === ',' && !inQuotes) {
|
|
130
|
+
count++;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return count;
|
|
99
134
|
}
|
|
@@ -6,11 +6,11 @@ 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 _dataVerificationPortal = _interopRequireDefault(require("./dataVerificationPortal"));
|
|
10
9
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
11
10
|
var _api = require("@fileverse-dev/fortune-core/lib/api");
|
|
12
11
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
12
|
var _ui = require("@fileverse/ui");
|
|
13
|
+
var _dataVerificationPortal = _interopRequireDefault(require("./dataVerificationPortal"));
|
|
14
14
|
var _context = _interopRequireDefault(require("../../context"));
|
|
15
15
|
require("./index.css");
|
|
16
16
|
var _Button = _interopRequireDefault(require("./Button"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.98",
|
|
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.
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.1.98",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-21",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|