@fileverse-dev/fortune-react 1.1.89 → 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.
- package/es/components/ContextMenu/index.js +2 -2
- package/es/components/DataVerification/ColorPicker.d.ts +9 -0
- package/es/components/DataVerification/ColorPicker.js +98 -0
- package/es/components/DataVerification/DropdownList.js +22 -7
- package/es/components/DataVerification/DropdownOption.d.ts +11 -0
- package/es/components/DataVerification/DropdownOption.js +264 -0
- package/es/components/DataVerification/index.css +4 -0
- package/es/components/DataVerification/index.js +62 -14
- package/es/components/SheetOverlay/ColumnHeader.js +8 -2
- package/es/components/SheetOverlay/drag_and_drop/column-helpers.js +8 -10
- package/es/components/SheetOverlay/drag_and_drop/row-helpers.js +7 -9
- package/es/components/SheetOverlay/index.js +1 -6
- package/es/components/Toolbar/index.js +47 -44
- package/lib/components/ContextMenu/index.js +2 -2
- package/lib/components/DataVerification/ColorPicker.d.ts +9 -0
- package/lib/components/DataVerification/ColorPicker.js +106 -0
- package/lib/components/DataVerification/DropdownList.js +22 -7
- package/lib/components/DataVerification/DropdownOption.d.ts +11 -0
- package/lib/components/DataVerification/DropdownOption.js +271 -0
- package/lib/components/DataVerification/index.css +4 -0
- package/lib/components/DataVerification/index.js +61 -13
- package/lib/components/SheetOverlay/ColumnHeader.js +8 -2
- package/lib/components/SheetOverlay/drag_and_drop/column-helpers.js +8 -10
- package/lib/components/SheetOverlay/drag_and_drop/row-helpers.js +7 -9
- package/lib/components/SheetOverlay/index.js +1 -6
- package/lib/components/Toolbar/index.js +47 -44
- package/package.json +2 -2
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _ui = require("@fileverse/ui");
|
|
11
|
+
var _ColorPicker = require("./ColorPicker");
|
|
12
|
+
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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
14
|
+
__assign = Object.assign || function (t) {
|
|
15
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
16
|
+
s = arguments[i];
|
|
17
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
return __assign.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
32
|
+
function createId() {
|
|
33
|
+
return "".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
|
|
34
|
+
}
|
|
35
|
+
var DynamicInputList = function DynamicInputList(_a) {
|
|
36
|
+
var optionItems = _a.optionItems,
|
|
37
|
+
setOptionItems = _a.setOptionItems;
|
|
38
|
+
var dragFromIndexRef = (0, _react.useRef)(null);
|
|
39
|
+
var _b = (0, _react.useState)(null),
|
|
40
|
+
draggingIndex = _b[0],
|
|
41
|
+
setDraggingIndex = _b[1];
|
|
42
|
+
var _c = (0, _react.useState)(null),
|
|
43
|
+
overPosition = _c[0],
|
|
44
|
+
setOverPosition = _c[1];
|
|
45
|
+
var dragPreviewRef = (0, _react.useRef)(null);
|
|
46
|
+
var handleAdd = function handleAdd() {
|
|
47
|
+
var nextNum = optionItems.length + 1;
|
|
48
|
+
setOptionItems(function (prev) {
|
|
49
|
+
return __spreadArray(__spreadArray([], prev, true), [{
|
|
50
|
+
id: createId(),
|
|
51
|
+
value: "Option ".concat(nextNum),
|
|
52
|
+
color: "228, 232, 237"
|
|
53
|
+
}], false);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
(0, _react.useEffect)(function () {
|
|
57
|
+
handleAdd();
|
|
58
|
+
}, []);
|
|
59
|
+
var handleRemove = function handleRemove(index) {
|
|
60
|
+
setOptionItems(function (prev) {
|
|
61
|
+
return prev.filter(function (_, i) {
|
|
62
|
+
return i !== index;
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var handleChange = function handleChange(index, v) {
|
|
67
|
+
setOptionItems(function (prev) {
|
|
68
|
+
var next = prev.slice();
|
|
69
|
+
next[index] = __assign(__assign({}, next[index]), {
|
|
70
|
+
value: v
|
|
71
|
+
});
|
|
72
|
+
return next;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
function createDragPreview(node, cursorX, cursorY) {
|
|
76
|
+
if (cursorX === void 0) {
|
|
77
|
+
cursorX = 20;
|
|
78
|
+
}
|
|
79
|
+
if (cursorY === void 0) {
|
|
80
|
+
cursorY = 10;
|
|
81
|
+
}
|
|
82
|
+
var rect = node.getBoundingClientRect();
|
|
83
|
+
var clone = node.cloneNode(true);
|
|
84
|
+
clone.style.position = "fixed";
|
|
85
|
+
clone.style.top = "".concat(rect.top, "px");
|
|
86
|
+
clone.style.left = "".concat(rect.left, "px");
|
|
87
|
+
clone.style.width = "".concat(rect.width, "px");
|
|
88
|
+
clone.style.pointerEvents = "none";
|
|
89
|
+
clone.style.zIndex = "9999";
|
|
90
|
+
clone.style.transform = "scale(0.98)";
|
|
91
|
+
clone.style.borderRadius = "12px";
|
|
92
|
+
clone.style.background = getComputedStyle(document.documentElement).getPropertyValue("--color-card") || "white";
|
|
93
|
+
clone.style.boxShadow = "0 8px 24px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.08)";
|
|
94
|
+
clone.style.opacity = "0.95";
|
|
95
|
+
document.body.appendChild(clone);
|
|
96
|
+
return {
|
|
97
|
+
clone: clone,
|
|
98
|
+
offsetX: cursorX,
|
|
99
|
+
offsetY: cursorY
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
var _onDragStart = function onDragStart(index, e) {
|
|
103
|
+
dragFromIndexRef.current = index;
|
|
104
|
+
setDraggingIndex(index);
|
|
105
|
+
e.dataTransfer.effectAllowed = "move";
|
|
106
|
+
e.dataTransfer.setData("text/plain", String(index));
|
|
107
|
+
var handle = e.currentTarget;
|
|
108
|
+
var row = handle.closest("li");
|
|
109
|
+
if (row) {
|
|
110
|
+
var preview = createDragPreview(row);
|
|
111
|
+
dragPreviewRef.current = preview.clone;
|
|
112
|
+
try {
|
|
113
|
+
e.dataTransfer.setDragImage(preview.clone, preview.offsetX, preview.offsetY);
|
|
114
|
+
} catch (_a) {}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var onDragEnd = function onDragEnd() {
|
|
118
|
+
if (dragPreviewRef.current && dragPreviewRef.current.parentNode) {
|
|
119
|
+
dragPreviewRef.current.parentNode.removeChild(dragPreviewRef.current);
|
|
120
|
+
}
|
|
121
|
+
dragPreviewRef.current = null;
|
|
122
|
+
setDraggingIndex(null);
|
|
123
|
+
setOverPosition(null);
|
|
124
|
+
dragFromIndexRef.current = null;
|
|
125
|
+
};
|
|
126
|
+
var onDragOverRow = function onDragOverRow(index, e) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.dataTransfer.dropEffect = "move";
|
|
129
|
+
var target = e.currentTarget;
|
|
130
|
+
var rect = target.getBoundingClientRect();
|
|
131
|
+
var halfway = rect.top + rect.height / 2;
|
|
132
|
+
var pos = e.clientY < halfway ? "before" : "after";
|
|
133
|
+
setOverPosition(pos);
|
|
134
|
+
};
|
|
135
|
+
var onDragLeaveRow = function onDragLeaveRow() {};
|
|
136
|
+
function move(list, from, to) {
|
|
137
|
+
var result = list.slice();
|
|
138
|
+
var removed = result.splice(from, 1)[0];
|
|
139
|
+
result.splice(to, 0, removed);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
var onDropRow = function onDropRow(index, e) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
var fromText = e.dataTransfer.getData("text/plain");
|
|
145
|
+
var fromIndex = Number.isNaN(Number(fromText)) ? dragFromIndexRef.current : Number(fromText);
|
|
146
|
+
if (fromIndex == null) {
|
|
147
|
+
setOverPosition(null);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
var dest = index;
|
|
151
|
+
if (overPosition === "after") {
|
|
152
|
+
dest = index + 1;
|
|
153
|
+
}
|
|
154
|
+
var adjustedDest = fromIndex < dest ? dest - 1 : dest;
|
|
155
|
+
if (fromIndex !== adjustedDest) {
|
|
156
|
+
setOptionItems(function (prev) {
|
|
157
|
+
return move(prev, fromIndex, Math.max(0, Math.min(prev.length, adjustedDest)));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
setOverPosition(null);
|
|
161
|
+
dragFromIndexRef.current = null;
|
|
162
|
+
setDraggingIndex(null);
|
|
163
|
+
if (dragPreviewRef.current && dragPreviewRef.current.parentNode) {
|
|
164
|
+
dragPreviewRef.current.parentNode.removeChild(dragPreviewRef.current);
|
|
165
|
+
dragPreviewRef.current = null;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
var handleColorChange = function handleColorChange(index, color) {
|
|
169
|
+
setOptionItems(function (prev) {
|
|
170
|
+
var next = prev.slice();
|
|
171
|
+
next[index] = __assign(__assign({}, next[index]), {
|
|
172
|
+
color: color
|
|
173
|
+
});
|
|
174
|
+
return next;
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
178
|
+
className: "mx-auto max-w-2xl"
|
|
179
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
180
|
+
className: "flex flex-col"
|
|
181
|
+
}, optionItems.map(function (item, index) {
|
|
182
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
183
|
+
key: item.id,
|
|
184
|
+
className: (0, _ui.cn)("relative flex optionItems-center gap-3 transition mb-4", draggingIndex === index && "scale-[0.99] opacity-80 shadow-lg rounded-xl"),
|
|
185
|
+
onDragOver: function onDragOver(e) {
|
|
186
|
+
return onDragOverRow(index, e);
|
|
187
|
+
},
|
|
188
|
+
onDragLeave: onDragLeaveRow,
|
|
189
|
+
onDrop: function onDrop(e) {
|
|
190
|
+
return onDropRow(index, e);
|
|
191
|
+
}
|
|
192
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
193
|
+
className: "cursor-grab p-2 text-muted-foreground hover:text-foreground active:cursor-grabbing",
|
|
194
|
+
draggable: true,
|
|
195
|
+
onDragStart: function onDragStart(e) {
|
|
196
|
+
return _onDragStart(index, e);
|
|
197
|
+
},
|
|
198
|
+
onDragEnd: onDragEnd,
|
|
199
|
+
"aria-label": "Drag handle for row ".concat(index + 1),
|
|
200
|
+
title: "Drag to reorder",
|
|
201
|
+
style: {
|
|
202
|
+
cursor: "grab"
|
|
203
|
+
}
|
|
204
|
+
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
205
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
206
|
+
width: "16",
|
|
207
|
+
height: "20",
|
|
208
|
+
viewBox: "0 0 16 20",
|
|
209
|
+
fill: "currentColor",
|
|
210
|
+
"aria-hidden": "true"
|
|
211
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
212
|
+
cx: "4",
|
|
213
|
+
cy: "5",
|
|
214
|
+
r: "1.5"
|
|
215
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
216
|
+
cx: "4",
|
|
217
|
+
cy: "10",
|
|
218
|
+
r: "1.5"
|
|
219
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
220
|
+
cx: "4",
|
|
221
|
+
cy: "15",
|
|
222
|
+
r: "1.5"
|
|
223
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
224
|
+
cx: "10",
|
|
225
|
+
cy: "5",
|
|
226
|
+
r: "1.5"
|
|
227
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
228
|
+
cx: "10",
|
|
229
|
+
cy: "10",
|
|
230
|
+
r: "1.5"
|
|
231
|
+
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
232
|
+
cx: "10",
|
|
233
|
+
cy: "15",
|
|
234
|
+
r: "1.5"
|
|
235
|
+
}))), /*#__PURE__*/_react.default.createElement("div", {
|
|
236
|
+
className: "flex optionItems-center"
|
|
237
|
+
}, /*#__PURE__*/_react.default.createElement(_ColorPicker.ColorSection, {
|
|
238
|
+
onPick: function onPick(c) {
|
|
239
|
+
return handleColorChange(index, c);
|
|
240
|
+
},
|
|
241
|
+
trigerColor: item.color
|
|
242
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
243
|
+
className: "flex flex-1 optionItems-center transition"
|
|
244
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.TextField, {
|
|
245
|
+
className: "w-full",
|
|
246
|
+
placeholder: "Option ".concat(index + 1),
|
|
247
|
+
value: item.value,
|
|
248
|
+
onChange: function onChange(e) {
|
|
249
|
+
return handleChange(index, e.target.value);
|
|
250
|
+
},
|
|
251
|
+
"aria-label": "Option ".concat(index + 1)
|
|
252
|
+
})), /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
253
|
+
icon: "Trash2",
|
|
254
|
+
type: "button",
|
|
255
|
+
variant: "ghost",
|
|
256
|
+
onClick: function onClick() {
|
|
257
|
+
return handleRemove(index);
|
|
258
|
+
},
|
|
259
|
+
className: "",
|
|
260
|
+
"aria-label": "Delete row ".concat(index + 1),
|
|
261
|
+
title: "Delete"
|
|
262
|
+
}));
|
|
263
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
264
|
+
className: "mt-8"
|
|
265
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
266
|
+
variant: "secondary",
|
|
267
|
+
onClick: handleAdd,
|
|
268
|
+
className: ""
|
|
269
|
+
}, "Add another item")));
|
|
270
|
+
};
|
|
271
|
+
var _default = exports.default = DynamicInputList;
|
|
@@ -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[
|
|
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[
|
|
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[
|
|
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 =
|
|
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(
|
|
228
|
-
|
|
229
|
-
|
|
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, {
|
|
@@ -82,6 +82,12 @@ var ColumnHeader = function ColumnHeader() {
|
|
|
82
82
|
}]);
|
|
83
83
|
}, [context, hoverLocation.col_index, refs.globalCache.freezen]);
|
|
84
84
|
var onMouseDown = (0, _react.useCallback)(function (e) {
|
|
85
|
+
if (e.button === 0 && e.target.tagName === "use") {
|
|
86
|
+
var nativeEvent_1 = e.nativeEvent;
|
|
87
|
+
setContext(function (draft) {
|
|
88
|
+
(0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache, nativeEvent_1, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
85
91
|
if (e.button !== 0) return;
|
|
86
92
|
var targetEl = e.target;
|
|
87
93
|
if (targetEl.closest(".fortune-cols-change-size") || targetEl.closest(".fortune-cols-freeze-handle") || targetEl.closest(".header-arrow")) return;
|
|
@@ -94,9 +100,9 @@ var ColumnHeader = function ColumnHeader() {
|
|
|
94
100
|
draft.luckysheet_scroll_status = true;
|
|
95
101
|
});
|
|
96
102
|
} else {
|
|
97
|
-
var
|
|
103
|
+
var nativeEvent_2 = e.nativeEvent;
|
|
98
104
|
setContext(function (draft) {
|
|
99
|
-
(0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache,
|
|
105
|
+
(0, _fortuneCore.handleColumnHeaderMouseDown)(draft, refs.globalCache, nativeEvent_2, containerRef.current, refs.cellInput.current, refs.fxInput.current);
|
|
100
106
|
});
|
|
101
107
|
return;
|
|
102
108
|
}
|
|
@@ -10,7 +10,7 @@ var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
|
10
10
|
var _context = _interopRequireDefault(require("../../../context"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function numberToColumnName(num) {
|
|
13
|
-
var columnName =
|
|
13
|
+
var columnName = "";
|
|
14
14
|
while (num >= 0) {
|
|
15
15
|
var remainder = num % 26;
|
|
16
16
|
columnName = String.fromCharCode(65 + remainder) + columnName;
|
|
@@ -182,7 +182,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
182
182
|
var dragOffset = Math.abs(ev.pageX - dragRef.current.startX);
|
|
183
183
|
if (!isDragActivated(host, dragOffset)) return;
|
|
184
184
|
var lineLeftPx = computeInsertionFromPageX(ev.pageX).lineLeftPx;
|
|
185
|
-
var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 :
|
|
185
|
+
var ghostPosOffset = dragRef.current.startX > ev.pageX ? 0 : 80;
|
|
186
186
|
if (dragRef.current.lineEl) {
|
|
187
187
|
dragRef.current.lineEl.style.left = "".concat(lineLeftPx, "px");
|
|
188
188
|
}
|
|
@@ -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];
|
|
@@ -230,7 +229,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
230
229
|
var sourceColName = numberToColumnName(sourceIndex_1);
|
|
231
230
|
var targetColName_1 = numberToColumnName(targetIndex);
|
|
232
231
|
if (cell.f) {
|
|
233
|
-
cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"),
|
|
232
|
+
cell.f = cell.f.replace(new RegExp("\\b".concat(sourceColName, "(\\d+)\\b"), "g"), function (match, p1) {
|
|
234
233
|
if (/^\d+$/.test(p1)) {
|
|
235
234
|
return "".concat(targetColName_1).concat(p1);
|
|
236
235
|
}
|
|
@@ -257,7 +256,7 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
257
256
|
var formula_1 = cell.f;
|
|
258
257
|
var replacements_1 = [];
|
|
259
258
|
otherAffectedCols.forEach(function (col) {
|
|
260
|
-
var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"),
|
|
259
|
+
var regex = new RegExp("\\b".concat(col.source, "(\\d+)\\b"), "g");
|
|
261
260
|
var match;
|
|
262
261
|
while ((match = regex.exec(formula_1)) !== null) {
|
|
263
262
|
if (/^\d+$/.test(match[1])) {
|
|
@@ -281,16 +280,16 @@ var useColumnDragAndDrop = exports.useColumnDragAndDrop = function useColumnDrag
|
|
|
281
280
|
}
|
|
282
281
|
});
|
|
283
282
|
});
|
|
284
|
-
(_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.
|
|
283
|
+
(_c = _sheet.calcChain) === null || _c === void 0 ? void 0 : _c.forEach(function (item) {
|
|
285
284
|
if (item.c === sourceIndex_1) {
|
|
286
285
|
item.c = targetIndex;
|
|
287
286
|
} else if (item.c > sourceIndex_1 && item.c < targetIndex) {
|
|
288
|
-
item.c
|
|
287
|
+
item.c -= 1;
|
|
289
288
|
} else if (item.c < sourceIndex_1 && item.c >= targetIndex) {
|
|
290
|
-
item.c
|
|
289
|
+
item.c += 1;
|
|
291
290
|
}
|
|
292
291
|
});
|
|
293
|
-
(_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex,
|
|
292
|
+
(_d = window === null || window === void 0 ? void 0 : window.updateDataBlockCalcFunctionAfterRowDrag) === null || _d === void 0 ? void 0 : _d.call(window, sourceIndex_1, targetIndex, "column", context.currentSheetId);
|
|
294
293
|
});
|
|
295
294
|
}
|
|
296
295
|
}
|
|
@@ -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,15 +205,14 @@ 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
|
-
row.forEach(function (cell
|
|
210
|
+
row.forEach(function (cell) {
|
|
212
211
|
if (cell) {
|
|
213
212
|
var startingIndex = sourceIndex_1 + 1;
|
|
214
213
|
var targetingIndex_1 = targetIndex + 1;
|
|
215
214
|
if (cell.f) {
|
|
216
|
-
cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"),
|
|
215
|
+
cell.f = cell.f.replace(new RegExp("\\b([A-Z]+)".concat(startingIndex, "\\b"), "g"), function (match, p1) {
|
|
217
216
|
return "".concat(p1).concat(targetingIndex_1);
|
|
218
217
|
});
|
|
219
218
|
}
|
|
@@ -239,7 +238,7 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
239
238
|
otherAffectedRows.forEach(function (_a) {
|
|
240
239
|
var source = _a.source,
|
|
241
240
|
target = _a.target;
|
|
242
|
-
var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"),
|
|
241
|
+
var regex = new RegExp("\\b([A-Z]+)".concat(source, "\\b"), "g");
|
|
243
242
|
var match;
|
|
244
243
|
while ((match = regex.exec(formula_1)) !== null) {
|
|
245
244
|
replacements_1.push({
|
|
@@ -261,17 +260,16 @@ var useRowDragAndDrop = exports.useRowDragAndDrop = function useRowDragAndDrop(c
|
|
|
261
260
|
}
|
|
262
261
|
});
|
|
263
262
|
});
|
|
264
|
-
(_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.
|
|
263
|
+
(_a = _sheet.calcChain) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
|
|
265
264
|
if (item.r === sourceIndex_1) {
|
|
266
265
|
item.r = targetIndex;
|
|
267
266
|
} else if (item.r > sourceIndex_1 && item.r < targetIndex) {
|
|
268
|
-
item.r
|
|
267
|
+
item.r -= 1;
|
|
269
268
|
} else if (item.r < sourceIndex_1 && item.r >= targetIndex) {
|
|
270
|
-
item.r
|
|
269
|
+
item.r += 1;
|
|
271
270
|
}
|
|
272
271
|
});
|
|
273
|
-
|
|
274
|
-
(_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);
|
|
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
|
}
|
|
277
275
|
}
|
|
@@ -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(
|
|
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", {
|