@fileverse-dev/fortune-react 1.2.64-linkPasteFix-patch-2 → 1.2.64-patch-1
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/ConditionFormat/ConditionRules.d.ts +1 -1
- package/es/components/ConditionFormat/ConditionRules.js +182 -17
- package/es/components/SheetOverlay/helper.d.ts +1 -0
- package/es/components/SheetOverlay/helper.js +1 -1
- package/es/components/Toolbar/index.js +36 -25
- package/es/components/Workbook/api.d.ts +3 -0
- package/es/components/Workbook/api.js +4 -0
- package/es/components/Workbook/index.d.ts +3 -0
- package/es/components/Workbook/index.js +19 -1
- package/lib/components/ConditionFormat/ConditionRules.d.ts +1 -1
- package/lib/components/ConditionFormat/ConditionRules.js +181 -16
- package/lib/components/SheetOverlay/helper.d.ts +1 -0
- package/lib/components/SheetOverlay/helper.js +1 -0
- package/lib/components/Toolbar/index.js +36 -25
- package/lib/components/Workbook/api.d.ts +3 -0
- package/lib/components/Workbook/api.js +4 -0
- package/lib/components/Workbook/index.d.ts +3 -0
- package/lib/components/Workbook/index.js +19 -1
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useEffect, useState } from "react";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
import { locale, setConditionRules } from "@fileverse-dev/fortune-core";
|
|
3
|
+
import { locale, setConditionRules, getSheetIndex } from "@fileverse-dev/fortune-core";
|
|
4
|
+
import { numberToColumn } from "../SheetOverlay/helper";
|
|
4
5
|
import produce from "immer";
|
|
5
6
|
import { Button, Checkbox, Divider, IconButton, LucideIcon, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, TextField } from "@fileverse/ui";
|
|
6
7
|
import WorkbookContext from "../../context";
|
|
@@ -9,22 +10,69 @@ import { getDisplayedRangeTxt } from "../DataVerification/getDisplayedRangeTxt";
|
|
|
9
10
|
import { injectDatepickerStyles } from "../../utils/datepickerStyles";
|
|
10
11
|
injectDatepickerStyles();
|
|
11
12
|
var ConditionRules = function ConditionRules(_a) {
|
|
12
|
-
var
|
|
13
|
-
var _b =
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var rulesType = _a.type;
|
|
14
|
+
var _b = useState('greaterThan'),
|
|
15
|
+
type = _b[0],
|
|
16
|
+
setType = _b[1];
|
|
17
|
+
var _c = useState(false),
|
|
18
|
+
create = _c[0],
|
|
19
|
+
setCreate = _c[1];
|
|
20
|
+
var _d = useState([]),
|
|
21
|
+
matchedConditionFormatKey = _d[0],
|
|
22
|
+
setMatchedConditionFormatKey = _d[1];
|
|
23
|
+
var _e = useState(null),
|
|
24
|
+
allConditionFormats = _e[0],
|
|
25
|
+
setAllConditionFormats = _e[1];
|
|
26
|
+
var _f = useContext(WorkbookContext),
|
|
27
|
+
context = _f.context,
|
|
28
|
+
setContext = _f.setContext;
|
|
16
29
|
var hideDialog = useDialog().hideDialog;
|
|
17
|
-
var
|
|
18
|
-
conditionformat =
|
|
19
|
-
button =
|
|
20
|
-
protection =
|
|
21
|
-
generalDialog =
|
|
22
|
-
var
|
|
30
|
+
var _g = locale(context),
|
|
31
|
+
conditionformat = _g.conditionformat,
|
|
32
|
+
button = _g.button,
|
|
33
|
+
protection = _g.protection,
|
|
34
|
+
generalDialog = _g.generalDialog;
|
|
35
|
+
var _h = useState({
|
|
23
36
|
textColor: "#FFFFFF",
|
|
24
37
|
cellColor: "#D82E2A"
|
|
25
38
|
}),
|
|
26
|
-
colorRules =
|
|
27
|
-
setColorRules =
|
|
39
|
+
colorRules = _h[0],
|
|
40
|
+
setColorRules = _h[1];
|
|
41
|
+
useEffect(function () {
|
|
42
|
+
var _a, _b, _c, _d;
|
|
43
|
+
var index = getSheetIndex(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
|
|
44
|
+
var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
|
|
45
|
+
if (allCondition && (allCondition === null || allCondition === void 0 ? void 0 : allCondition.length) === (allConditionFormats === null || allConditionFormats === void 0 ? void 0 : allConditionFormats.length)) return;
|
|
46
|
+
setAllConditionFormats(allCondition);
|
|
47
|
+
console.log("allConditionFormats", allCondition, (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0], context);
|
|
48
|
+
console.log("typed", context);
|
|
49
|
+
var selectionColumn = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0].column;
|
|
50
|
+
var selectionRow = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[0].row;
|
|
51
|
+
var matchedCondition = [];
|
|
52
|
+
if (allCondition) {
|
|
53
|
+
for (var key in allCondition) {
|
|
54
|
+
var conditionFormat = allCondition[key];
|
|
55
|
+
var range = (_d = conditionFormat.cellrange) === null || _d === void 0 ? void 0 : _d[0];
|
|
56
|
+
console.log("rangeObj", conditionFormat, range);
|
|
57
|
+
if (!range || !selectionColumn || !selectionRow) continue;
|
|
58
|
+
var rangeColumns = range.column;
|
|
59
|
+
var rangeRows = range.row;
|
|
60
|
+
var isColumnOverlap = !(selectionColumn[1] < rangeColumns[0] || selectionColumn[0] > rangeColumns[1]);
|
|
61
|
+
var isRowOverlap = !(selectionRow[1] < rangeRows[0] || selectionRow[0] > rangeRows[1]);
|
|
62
|
+
if (isColumnOverlap && isRowOverlap) {
|
|
63
|
+
matchedCondition.push(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
setMatchedConditionFormatKey(matchedCondition);
|
|
67
|
+
}
|
|
68
|
+
console.log("kkkkk", matchedConditionFormatKey, matchedCondition);
|
|
69
|
+
if (matchedCondition.length === 0) {
|
|
70
|
+
console.log('whyyyyyyy');
|
|
71
|
+
setCreate(true);
|
|
72
|
+
} else if (matchedCondition.length > 0) {
|
|
73
|
+
setCreate(false);
|
|
74
|
+
}
|
|
75
|
+
}, [context]);
|
|
28
76
|
var dataSelectRange = useCallback(function (selectType) {
|
|
29
77
|
hideDialog();
|
|
30
78
|
setContext(function (ctx) {
|
|
@@ -103,11 +151,104 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
103
151
|
ctx.rangeDialog.type = "";
|
|
104
152
|
ctx.rangeDialog.rangeTxt = "";
|
|
105
153
|
});
|
|
106
|
-
}, []);
|
|
154
|
+
}, [type]);
|
|
155
|
+
var conditionList = [{
|
|
156
|
+
text: "greaterThan",
|
|
157
|
+
value: ">",
|
|
158
|
+
label: "Greater Than"
|
|
159
|
+
}, {
|
|
160
|
+
text: "greaterThanOrEqual",
|
|
161
|
+
value: ">=",
|
|
162
|
+
label: "Greater Than or Equal"
|
|
163
|
+
}, {
|
|
164
|
+
text: "lessThan",
|
|
165
|
+
value: "<",
|
|
166
|
+
label: "Less Than"
|
|
167
|
+
}, {
|
|
168
|
+
text: "lessThanOrEqual",
|
|
169
|
+
value: "<=",
|
|
170
|
+
label: "Less Than or Equal"
|
|
171
|
+
}, {
|
|
172
|
+
text: "between",
|
|
173
|
+
value: "[]",
|
|
174
|
+
label: "Between"
|
|
175
|
+
}, {
|
|
176
|
+
text: "equal",
|
|
177
|
+
value: "=",
|
|
178
|
+
label: "Equal"
|
|
179
|
+
}, {
|
|
180
|
+
text: "textContains",
|
|
181
|
+
value: "()",
|
|
182
|
+
label: "Text Contains"
|
|
183
|
+
}, {
|
|
184
|
+
text: "occurrenceDate",
|
|
185
|
+
value: conditionformat.yesterday,
|
|
186
|
+
label: "Occurrence Date"
|
|
187
|
+
}, {
|
|
188
|
+
text: "duplicateValue",
|
|
189
|
+
value: "##",
|
|
190
|
+
label: "Duplicate Value"
|
|
191
|
+
}, {
|
|
192
|
+
text: "top10",
|
|
193
|
+
value: conditionformat.top10
|
|
194
|
+
}, {
|
|
195
|
+
text: "top10_percent",
|
|
196
|
+
value: conditionformat.top10_percent,
|
|
197
|
+
label: "Top 10 Percent"
|
|
198
|
+
}, {
|
|
199
|
+
text: "last10",
|
|
200
|
+
value: conditionformat.last10,
|
|
201
|
+
label: "Last 10"
|
|
202
|
+
}, {
|
|
203
|
+
text: "last10_percent",
|
|
204
|
+
value: conditionformat.last10_percent,
|
|
205
|
+
label: "Last 10 Percent"
|
|
206
|
+
}, {
|
|
207
|
+
text: "aboveAverage",
|
|
208
|
+
value: conditionformat.above,
|
|
209
|
+
label: "Above Average"
|
|
210
|
+
}, {
|
|
211
|
+
text: "belowAverage",
|
|
212
|
+
value: conditionformat.below,
|
|
213
|
+
label: "Below Average"
|
|
214
|
+
}];
|
|
107
215
|
var titleType = type === "top10_percent" ? "top10" : type === "last10_percent" ? "last10" : type;
|
|
108
216
|
return /*#__PURE__*/React.createElement("div", {
|
|
109
217
|
className: "condition-rules"
|
|
110
|
-
}, !
|
|
218
|
+
}, !create ? (/*#__PURE__*/React.createElement("div", null, matchedConditionFormatKey.map(function (key) {
|
|
219
|
+
var _a, _b;
|
|
220
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
className: "flex items-center gap-6 py-6 border-b border-gray-200 last:border-b-0",
|
|
222
|
+
key: key
|
|
223
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
224
|
+
className: "flex items-center justify-center !w-40 !h-40 rounded-3xl !bg-[".concat(allConditionFormats[key].format.cellColor || "", "]"),
|
|
225
|
+
style: {
|
|
226
|
+
backgroundColor: allConditionFormats[key].format.cellColor || "",
|
|
227
|
+
width: '44px',
|
|
228
|
+
height: '56px'
|
|
229
|
+
}
|
|
230
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
231
|
+
className: "text-6xl font-bold !text-[".concat(allConditionFormats[key].format.textColor || "", "] pb-1")
|
|
232
|
+
}, "123")), /*#__PURE__*/React.createElement("div", {
|
|
233
|
+
className: "flex flex-col"
|
|
234
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
235
|
+
className: "text-4xl font-normal text-gray-900 mb-2"
|
|
236
|
+
}, conditionformat[allConditionFormats[key].conditionName], ' ', (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]), /*#__PURE__*/React.createElement("p", {
|
|
237
|
+
className: "text-3xl text-gray-400"
|
|
238
|
+
}, (_b = allConditionFormats[key].cellrange) === null || _b === void 0 ? void 0 : _b.map(function (range) {
|
|
239
|
+
var startCol = numberToColumn(range.column[0] + 1);
|
|
240
|
+
var endCol = numberToColumn(range.column[1] + 1);
|
|
241
|
+
var startRow = range.row[0] + 1;
|
|
242
|
+
var endRow = range.row[1] + 1;
|
|
243
|
+
return "".concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
|
|
244
|
+
}).join(", "))));
|
|
245
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
246
|
+
size: "md",
|
|
247
|
+
variant: "secondary",
|
|
248
|
+
onClick: function onClick() {
|
|
249
|
+
setCreate(true);
|
|
250
|
+
}
|
|
251
|
+
}, "Create New Condition Format"))) : (/*#__PURE__*/React.createElement(React.Fragment, null, !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/React.createElement("div", {
|
|
111
252
|
className: "flex flex-col"
|
|
112
253
|
}, /*#__PURE__*/React.createElement("div", {
|
|
113
254
|
className: "condition-rules-value text-heading-xsm"
|
|
@@ -215,7 +356,31 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
215
356
|
ctx.conditionRules.projectValue = String(current + 1);
|
|
216
357
|
});
|
|
217
358
|
}
|
|
218
|
-
})))))), /*#__PURE__*/React.createElement("div", {
|
|
359
|
+
})))))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
360
|
+
className: "condition-rules-value text-heading-xsm"
|
|
361
|
+
}, "Cell(s) format if"), /*#__PURE__*/React.createElement(Select, {
|
|
362
|
+
value: type,
|
|
363
|
+
onValueChange: function onValueChange(value) {
|
|
364
|
+
console.log(value);
|
|
365
|
+
setType(value);
|
|
366
|
+
}
|
|
367
|
+
}, /*#__PURE__*/React.createElement(SelectTrigger, null, /*#__PURE__*/React.createElement(SelectValue, null, /*#__PURE__*/React.createElement("div", {
|
|
368
|
+
className: "flex items-center gap-2"
|
|
369
|
+
}, /*#__PURE__*/React.createElement("span", null, conditionformat[type])))), /*#__PURE__*/React.createElement(SelectContent, {
|
|
370
|
+
position: "popper",
|
|
371
|
+
side: "bottom",
|
|
372
|
+
align: "start",
|
|
373
|
+
sideOffset: 4,
|
|
374
|
+
className: "z-[100]",
|
|
375
|
+
"data-dropdown-content": "true"
|
|
376
|
+
}, conditionList.map(function (option) {
|
|
377
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
378
|
+
key: option.value,
|
|
379
|
+
value: option.text
|
|
380
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
381
|
+
className: "flex items-center gap-2"
|
|
382
|
+
}, /*#__PURE__*/React.createElement("span", null, conditionformat[option.text])));
|
|
383
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
219
384
|
className: "flex flex-col"
|
|
220
385
|
}, /*#__PURE__*/React.createElement("div", {
|
|
221
386
|
className: "condition-rules-value text-heading-xsm"
|
|
@@ -318,6 +483,6 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
318
483
|
close("confirm");
|
|
319
484
|
},
|
|
320
485
|
tabIndex: 0
|
|
321
|
-
}, button.apply)));
|
|
486
|
+
}, button.apply)))));
|
|
322
487
|
};
|
|
323
488
|
export default ConditionRules;
|
|
@@ -2,6 +2,7 @@ export declare function moveCursorToEnd(editableDiv: HTMLDivElement): void;
|
|
|
2
2
|
export declare function getCursorPosition(editableDiv: HTMLDivElement): number;
|
|
3
3
|
export declare function isLetterNumberPattern(str: string): boolean;
|
|
4
4
|
export declare function removeLastSpan(htmlString: string): string;
|
|
5
|
+
export declare function numberToColumn(colNumber: number): string;
|
|
5
6
|
export declare function incrementColumn(cell: string): string;
|
|
6
7
|
export declare function decrementColumn(cell: string): string;
|
|
7
8
|
export declare function incrementRow(cell: string): string;
|
|
@@ -137,7 +137,6 @@ import SVGIcon from "../SVGIcon";
|
|
|
137
137
|
import { useDialog } from "../../hooks/useDialog";
|
|
138
138
|
import { SplitColumn } from "../SplitColumn";
|
|
139
139
|
import { LocationCondition } from "../LocationCondition";
|
|
140
|
-
import ConditionalFormat from "../ConditionFormat";
|
|
141
140
|
import CustomButton from "./CustomButton";
|
|
142
141
|
import { CustomColor } from "./CustomColor";
|
|
143
142
|
import { FormatSearch } from "../FormatSearch";
|
|
@@ -617,6 +616,22 @@ var Toolbar = function Toolbar(_a) {
|
|
|
617
616
|
useEffect(function () {
|
|
618
617
|
window.dataVerificationClick = dataVerificationClick;
|
|
619
618
|
}, []);
|
|
619
|
+
var conditionalFormatClick = function conditionalFormatClick(selectedCells) {
|
|
620
|
+
var _a;
|
|
621
|
+
console.log("conditionalFormatClick called");
|
|
622
|
+
var selection = api.getSelection(context);
|
|
623
|
+
if (!selection && !selectedCells) {
|
|
624
|
+
setContext(function (ctx) {
|
|
625
|
+
api.setSelection(ctx, [{
|
|
626
|
+
row: [0, 0],
|
|
627
|
+
column: [0, 0]
|
|
628
|
+
}], {
|
|
629
|
+
id: context.currentSheetId
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
(_a = document.getElementById("conditional-format-button")) === null || _a === void 0 ? void 0 : _a.click();
|
|
634
|
+
};
|
|
620
635
|
var getToolbarItem = useCallback(function (name, i) {
|
|
621
636
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
622
637
|
var tooltip = toolbar[name];
|
|
@@ -1112,17 +1127,13 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1112
1127
|
});
|
|
1113
1128
|
}
|
|
1114
1129
|
if (name === "conditionFormat") {
|
|
1115
|
-
var
|
|
1116
|
-
return /*#__PURE__*/React.createElement(
|
|
1117
|
-
|
|
1130
|
+
var items = ["highlightCellRules", "itemSelectionRules", "-", "deleteRule"];
|
|
1131
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
1132
|
+
id: "conditionFormat",
|
|
1133
|
+
iconId: name,
|
|
1134
|
+
tooltip: tooltip,
|
|
1118
1135
|
key: name,
|
|
1119
|
-
|
|
1120
|
-
showArrow: false
|
|
1121
|
-
}, function (setOpen) {
|
|
1122
|
-
return /*#__PURE__*/React.createElement(ConditionalFormat, {
|
|
1123
|
-
items: items_4,
|
|
1124
|
-
setOpen: setOpen
|
|
1125
|
-
});
|
|
1136
|
+
onClick: conditionalFormatClick
|
|
1126
1137
|
});
|
|
1127
1138
|
}
|
|
1128
1139
|
if (name === "image") {
|
|
@@ -1315,7 +1326,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1315
1326
|
});
|
|
1316
1327
|
}
|
|
1317
1328
|
if (name === "border") {
|
|
1318
|
-
var
|
|
1329
|
+
var items_4 = [{
|
|
1319
1330
|
text: border.borderTop,
|
|
1320
1331
|
value: "border-top",
|
|
1321
1332
|
icon: "BorderTop"
|
|
@@ -1370,7 +1381,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1370
1381
|
}, function (setOpen) {
|
|
1371
1382
|
return /*#__PURE__*/React.createElement("div", {
|
|
1372
1383
|
className: "fortune-toolbar-select fortune-border-grid"
|
|
1373
|
-
},
|
|
1384
|
+
}, items_4.map(function (_a) {
|
|
1374
1385
|
var value = _a.value,
|
|
1375
1386
|
icon = _a.icon;
|
|
1376
1387
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1391,7 +1402,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1391
1402
|
});
|
|
1392
1403
|
}
|
|
1393
1404
|
if (name === "freeze") {
|
|
1394
|
-
var
|
|
1405
|
+
var items_5 = [{
|
|
1395
1406
|
text: freezen.freezenRowRange,
|
|
1396
1407
|
value: "freeze-row"
|
|
1397
1408
|
}, {
|
|
@@ -1415,7 +1426,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1415
1426
|
});
|
|
1416
1427
|
}
|
|
1417
1428
|
}, function (setOpen) {
|
|
1418
|
-
return /*#__PURE__*/React.createElement(Select, null,
|
|
1429
|
+
return /*#__PURE__*/React.createElement(Select, null, items_5.map(function (_a) {
|
|
1419
1430
|
var text = _a.text,
|
|
1420
1431
|
value = _a.value;
|
|
1421
1432
|
return /*#__PURE__*/React.createElement(Option, {
|
|
@@ -1437,7 +1448,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1437
1448
|
});
|
|
1438
1449
|
}
|
|
1439
1450
|
if (name === "text-wrap") {
|
|
1440
|
-
var
|
|
1451
|
+
var items_6 = [{
|
|
1441
1452
|
text: textWrap.clip,
|
|
1442
1453
|
iconId: "text-clip",
|
|
1443
1454
|
value: "clip"
|
|
@@ -1450,9 +1461,9 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1450
1461
|
iconId: "text-wrap",
|
|
1451
1462
|
value: "wrap"
|
|
1452
1463
|
}];
|
|
1453
|
-
var curr_3 =
|
|
1464
|
+
var curr_3 = items_6[0];
|
|
1454
1465
|
if ((cell === null || cell === void 0 ? void 0 : cell.tb) != null) {
|
|
1455
|
-
curr_3 = _.get(
|
|
1466
|
+
curr_3 = _.get(items_6, cell.tb);
|
|
1456
1467
|
}
|
|
1457
1468
|
return /*#__PURE__*/React.createElement(Combo, {
|
|
1458
1469
|
iconId: curr_3.iconId,
|
|
@@ -1469,7 +1480,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1469
1480
|
justifyContent: "center",
|
|
1470
1481
|
gap: 4
|
|
1471
1482
|
}
|
|
1472
|
-
},
|
|
1483
|
+
}, items_6.map(function (_a) {
|
|
1473
1484
|
var iconId = _a.iconId,
|
|
1474
1485
|
value = _a.value;
|
|
1475
1486
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
@@ -1500,7 +1511,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1500
1511
|
});
|
|
1501
1512
|
}
|
|
1502
1513
|
if (name === "text-rotation") {
|
|
1503
|
-
var
|
|
1514
|
+
var items_7 = [{
|
|
1504
1515
|
text: rotation.none,
|
|
1505
1516
|
iconId: "text-rotation-none",
|
|
1506
1517
|
value: "none"
|
|
@@ -1525,9 +1536,9 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1525
1536
|
iconId: "text-rotation-down",
|
|
1526
1537
|
value: "rotation-down"
|
|
1527
1538
|
}];
|
|
1528
|
-
var curr =
|
|
1539
|
+
var curr = items_7[0];
|
|
1529
1540
|
if ((cell === null || cell === void 0 ? void 0 : cell.tr) != null) {
|
|
1530
|
-
curr = _.get(
|
|
1541
|
+
curr = _.get(items_7, cell.tr);
|
|
1531
1542
|
}
|
|
1532
1543
|
return /*#__PURE__*/React.createElement(Combo, {
|
|
1533
1544
|
iconId: curr.iconId,
|
|
@@ -1535,7 +1546,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1535
1546
|
tooltip: toolbar.textRotate,
|
|
1536
1547
|
showArrow: false
|
|
1537
1548
|
}, function (setOpen) {
|
|
1538
|
-
return /*#__PURE__*/React.createElement(Select, null,
|
|
1549
|
+
return /*#__PURE__*/React.createElement(Select, null, items_7.map(function (_a) {
|
|
1539
1550
|
var text = _a.text,
|
|
1540
1551
|
iconId = _a.iconId,
|
|
1541
1552
|
value = _a.value;
|
|
@@ -1560,7 +1571,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1560
1571
|
});
|
|
1561
1572
|
}
|
|
1562
1573
|
if (name === "filter") {
|
|
1563
|
-
var
|
|
1574
|
+
var items_8 = [{
|
|
1564
1575
|
iconId: "sort-asc",
|
|
1565
1576
|
value: "sort-asc",
|
|
1566
1577
|
text: sort.asc,
|
|
@@ -1610,7 +1621,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1610
1621
|
style: {
|
|
1611
1622
|
minWidth: "11.25rem"
|
|
1612
1623
|
}
|
|
1613
|
-
},
|
|
1624
|
+
}, items_8.map(function (_a, index) {
|
|
1614
1625
|
var text = _a.text,
|
|
1615
1626
|
iconId = _a.iconId,
|
|
1616
1627
|
value = _a.value,
|
|
@@ -1196,4 +1196,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
1196
1196
|
getRefs: () => any;
|
|
1197
1197
|
getShowDialog: () => typeof useDialog;
|
|
1198
1198
|
getSplitColComponent: () => import("react").FC<{}>;
|
|
1199
|
+
getConditionalFormatComponent: () => import("react").FC<{
|
|
1200
|
+
type?: string | undefined;
|
|
1201
|
+
}>;
|
|
1199
1202
|
};
|
|
@@ -14,6 +14,7 @@ import _ from "lodash";
|
|
|
14
14
|
import { getCryptoPrice } from "../../utils/cryptoApi";
|
|
15
15
|
import { useDialog } from "../../hooks/useDialog";
|
|
16
16
|
import { SplitColumn } from "../../components/SplitColumn";
|
|
17
|
+
import ConditionRules from "../ConditionFormat/ConditionRules";
|
|
17
18
|
export function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cellInput, scrollbarX, scrollbarY, globalCache, refs) {
|
|
18
19
|
return {
|
|
19
20
|
applyOp: function applyOp(ops) {
|
|
@@ -452,6 +453,9 @@ export function generateAPIs(context, setContext, handleUndo, handleRedo, settin
|
|
|
452
453
|
},
|
|
453
454
|
getSplitColComponent: function getSplitColComponent() {
|
|
454
455
|
return SplitColumn;
|
|
456
|
+
},
|
|
457
|
+
getConditionalFormatComponent: function getConditionalFormatComponent() {
|
|
458
|
+
return ConditionRules;
|
|
455
459
|
}
|
|
456
460
|
};
|
|
457
461
|
}
|
|
@@ -1203,5 +1203,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
1203
1203
|
getRefs: () => any;
|
|
1204
1204
|
getShowDialog: () => typeof import("../../hooks/useDialog").useDialog;
|
|
1205
1205
|
getSplitColComponent: () => React.FC<{}>;
|
|
1206
|
+
getConditionalFormatComponent: () => React.FC<{
|
|
1207
|
+
type?: string | undefined;
|
|
1208
|
+
}>;
|
|
1206
1209
|
}>>;
|
|
1207
1210
|
export default Workbook;
|
|
@@ -34,6 +34,7 @@ import { ModalProvider } from "../../context/modal";
|
|
|
34
34
|
import FilterMenu from "../ContextMenu/FilterMenu";
|
|
35
35
|
import SheetList from "../SheetList";
|
|
36
36
|
import DunePreview from "../DunePreview/DunePreview";
|
|
37
|
+
import ConditionRules from "../ConditionFormat/ConditionRules";
|
|
37
38
|
enablePatches();
|
|
38
39
|
var triggerGroupValuesRefresh = function triggerGroupValuesRefresh(ctx) {
|
|
39
40
|
if (ctx.groupValuesRefreshData.length > 0) {
|
|
@@ -353,6 +354,10 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
353
354
|
refs: refs
|
|
354
355
|
};
|
|
355
356
|
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
|
|
357
|
+
var _e = useState(false),
|
|
358
|
+
show = _e[0],
|
|
359
|
+
setShow = _e[1];
|
|
360
|
+
var getCond = function getCond() {};
|
|
356
361
|
useEffect(function () {
|
|
357
362
|
if (!_.isEmpty(context.luckysheetfile)) {
|
|
358
363
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|
|
@@ -680,7 +685,20 @@ var Workbook = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
680
685
|
}
|
|
681
686
|
return /*#__PURE__*/React.createElement(WorkbookContext.Provider, {
|
|
682
687
|
value: providerValue
|
|
683
|
-
}, /*#__PURE__*/React.createElement(
|
|
688
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
689
|
+
onClick: function onClick() {
|
|
690
|
+
setShow(!show);
|
|
691
|
+
}
|
|
692
|
+
}, "Click"), show && /*#__PURE__*/React.createElement("div", {
|
|
693
|
+
id: "placeholder-conditional-formatting",
|
|
694
|
+
style: {
|
|
695
|
+
width: "500px",
|
|
696
|
+
height: "500px",
|
|
697
|
+
position: "fixed",
|
|
698
|
+
zIndex: "1000",
|
|
699
|
+
backgroundColor: "white"
|
|
700
|
+
}
|
|
701
|
+
}, /*#__PURE__*/React.createElement(ConditionRules, null)), /*#__PURE__*/React.createElement(ModalProvider, null, /*#__PURE__*/React.createElement("div", {
|
|
684
702
|
className: "fortune-container",
|
|
685
703
|
ref: workbookContainer,
|
|
686
704
|
onKeyDown: onKeyDown
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
require("./index.css");
|
|
10
10
|
var _fortuneCore = require("@fileverse-dev/fortune-core");
|
|
11
|
+
var _helper = require("../SheetOverlay/helper");
|
|
11
12
|
var _immer = _interopRequireDefault(require("immer"));
|
|
12
13
|
var _ui = require("@fileverse/ui");
|
|
13
14
|
var _context = _interopRequireDefault(require("../../context"));
|
|
@@ -18,22 +19,69 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
18
19
|
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); }
|
|
19
20
|
(0, _datepickerStyles.injectDatepickerStyles)();
|
|
20
21
|
var ConditionRules = function ConditionRules(_a) {
|
|
21
|
-
var
|
|
22
|
-
var _b = (0, _react.
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
var rulesType = _a.type;
|
|
23
|
+
var _b = (0, _react.useState)('greaterThan'),
|
|
24
|
+
type = _b[0],
|
|
25
|
+
setType = _b[1];
|
|
26
|
+
var _c = (0, _react.useState)(false),
|
|
27
|
+
create = _c[0],
|
|
28
|
+
setCreate = _c[1];
|
|
29
|
+
var _d = (0, _react.useState)([]),
|
|
30
|
+
matchedConditionFormatKey = _d[0],
|
|
31
|
+
setMatchedConditionFormatKey = _d[1];
|
|
32
|
+
var _e = (0, _react.useState)(null),
|
|
33
|
+
allConditionFormats = _e[0],
|
|
34
|
+
setAllConditionFormats = _e[1];
|
|
35
|
+
var _f = (0, _react.useContext)(_context.default),
|
|
36
|
+
context = _f.context,
|
|
37
|
+
setContext = _f.setContext;
|
|
25
38
|
var hideDialog = (0, _useDialog.useDialog)().hideDialog;
|
|
26
|
-
var
|
|
27
|
-
conditionformat =
|
|
28
|
-
button =
|
|
29
|
-
protection =
|
|
30
|
-
generalDialog =
|
|
31
|
-
var
|
|
39
|
+
var _g = (0, _fortuneCore.locale)(context),
|
|
40
|
+
conditionformat = _g.conditionformat,
|
|
41
|
+
button = _g.button,
|
|
42
|
+
protection = _g.protection,
|
|
43
|
+
generalDialog = _g.generalDialog;
|
|
44
|
+
var _h = (0, _react.useState)({
|
|
32
45
|
textColor: "#FFFFFF",
|
|
33
46
|
cellColor: "#D82E2A"
|
|
34
47
|
}),
|
|
35
|
-
colorRules =
|
|
36
|
-
setColorRules =
|
|
48
|
+
colorRules = _h[0],
|
|
49
|
+
setColorRules = _h[1];
|
|
50
|
+
(0, _react.useEffect)(function () {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
var index = (0, _fortuneCore.getSheetIndex)(context, context === null || context === void 0 ? void 0 : context.currentSheetId) || 0;
|
|
53
|
+
var allCondition = context.luckysheetfile[index].luckysheet_conditionformat_save;
|
|
54
|
+
if (allCondition && (allCondition === null || allCondition === void 0 ? void 0 : allCondition.length) === (allConditionFormats === null || allConditionFormats === void 0 ? void 0 : allConditionFormats.length)) return;
|
|
55
|
+
setAllConditionFormats(allCondition);
|
|
56
|
+
console.log("allConditionFormats", allCondition, (_a = context.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0], context);
|
|
57
|
+
console.log("typed", context);
|
|
58
|
+
var selectionColumn = (_b = context.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b[0].column;
|
|
59
|
+
var selectionRow = (_c = context.luckysheet_select_save) === null || _c === void 0 ? void 0 : _c[0].row;
|
|
60
|
+
var matchedCondition = [];
|
|
61
|
+
if (allCondition) {
|
|
62
|
+
for (var key in allCondition) {
|
|
63
|
+
var conditionFormat = allCondition[key];
|
|
64
|
+
var range = (_d = conditionFormat.cellrange) === null || _d === void 0 ? void 0 : _d[0];
|
|
65
|
+
console.log("rangeObj", conditionFormat, range);
|
|
66
|
+
if (!range || !selectionColumn || !selectionRow) continue;
|
|
67
|
+
var rangeColumns = range.column;
|
|
68
|
+
var rangeRows = range.row;
|
|
69
|
+
var isColumnOverlap = !(selectionColumn[1] < rangeColumns[0] || selectionColumn[0] > rangeColumns[1]);
|
|
70
|
+
var isRowOverlap = !(selectionRow[1] < rangeRows[0] || selectionRow[0] > rangeRows[1]);
|
|
71
|
+
if (isColumnOverlap && isRowOverlap) {
|
|
72
|
+
matchedCondition.push(key);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
setMatchedConditionFormatKey(matchedCondition);
|
|
76
|
+
}
|
|
77
|
+
console.log("kkkkk", matchedConditionFormatKey, matchedCondition);
|
|
78
|
+
if (matchedCondition.length === 0) {
|
|
79
|
+
console.log('whyyyyyyy');
|
|
80
|
+
setCreate(true);
|
|
81
|
+
} else if (matchedCondition.length > 0) {
|
|
82
|
+
setCreate(false);
|
|
83
|
+
}
|
|
84
|
+
}, [context]);
|
|
37
85
|
var dataSelectRange = (0, _react.useCallback)(function (selectType) {
|
|
38
86
|
hideDialog();
|
|
39
87
|
setContext(function (ctx) {
|
|
@@ -112,11 +160,104 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
112
160
|
ctx.rangeDialog.type = "";
|
|
113
161
|
ctx.rangeDialog.rangeTxt = "";
|
|
114
162
|
});
|
|
115
|
-
}, []);
|
|
163
|
+
}, [type]);
|
|
164
|
+
var conditionList = [{
|
|
165
|
+
text: "greaterThan",
|
|
166
|
+
value: ">",
|
|
167
|
+
label: "Greater Than"
|
|
168
|
+
}, {
|
|
169
|
+
text: "greaterThanOrEqual",
|
|
170
|
+
value: ">=",
|
|
171
|
+
label: "Greater Than or Equal"
|
|
172
|
+
}, {
|
|
173
|
+
text: "lessThan",
|
|
174
|
+
value: "<",
|
|
175
|
+
label: "Less Than"
|
|
176
|
+
}, {
|
|
177
|
+
text: "lessThanOrEqual",
|
|
178
|
+
value: "<=",
|
|
179
|
+
label: "Less Than or Equal"
|
|
180
|
+
}, {
|
|
181
|
+
text: "between",
|
|
182
|
+
value: "[]",
|
|
183
|
+
label: "Between"
|
|
184
|
+
}, {
|
|
185
|
+
text: "equal",
|
|
186
|
+
value: "=",
|
|
187
|
+
label: "Equal"
|
|
188
|
+
}, {
|
|
189
|
+
text: "textContains",
|
|
190
|
+
value: "()",
|
|
191
|
+
label: "Text Contains"
|
|
192
|
+
}, {
|
|
193
|
+
text: "occurrenceDate",
|
|
194
|
+
value: conditionformat.yesterday,
|
|
195
|
+
label: "Occurrence Date"
|
|
196
|
+
}, {
|
|
197
|
+
text: "duplicateValue",
|
|
198
|
+
value: "##",
|
|
199
|
+
label: "Duplicate Value"
|
|
200
|
+
}, {
|
|
201
|
+
text: "top10",
|
|
202
|
+
value: conditionformat.top10
|
|
203
|
+
}, {
|
|
204
|
+
text: "top10_percent",
|
|
205
|
+
value: conditionformat.top10_percent,
|
|
206
|
+
label: "Top 10 Percent"
|
|
207
|
+
}, {
|
|
208
|
+
text: "last10",
|
|
209
|
+
value: conditionformat.last10,
|
|
210
|
+
label: "Last 10"
|
|
211
|
+
}, {
|
|
212
|
+
text: "last10_percent",
|
|
213
|
+
value: conditionformat.last10_percent,
|
|
214
|
+
label: "Last 10 Percent"
|
|
215
|
+
}, {
|
|
216
|
+
text: "aboveAverage",
|
|
217
|
+
value: conditionformat.above,
|
|
218
|
+
label: "Above Average"
|
|
219
|
+
}, {
|
|
220
|
+
text: "belowAverage",
|
|
221
|
+
value: conditionformat.below,
|
|
222
|
+
label: "Below Average"
|
|
223
|
+
}];
|
|
116
224
|
var titleType = type === "top10_percent" ? "top10" : type === "last10_percent" ? "last10" : type;
|
|
117
225
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
118
226
|
className: "condition-rules"
|
|
119
|
-
}, !
|
|
227
|
+
}, !create ? (/*#__PURE__*/_react.default.createElement("div", null, matchedConditionFormatKey.map(function (key) {
|
|
228
|
+
var _a, _b;
|
|
229
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
230
|
+
className: "flex items-center gap-6 py-6 border-b border-gray-200 last:border-b-0",
|
|
231
|
+
key: key
|
|
232
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
233
|
+
className: "flex items-center justify-center !w-40 !h-40 rounded-3xl !bg-[".concat(allConditionFormats[key].format.cellColor || "", "]"),
|
|
234
|
+
style: {
|
|
235
|
+
backgroundColor: allConditionFormats[key].format.cellColor || "",
|
|
236
|
+
width: '44px',
|
|
237
|
+
height: '56px'
|
|
238
|
+
}
|
|
239
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
240
|
+
className: "text-6xl font-bold !text-[".concat(allConditionFormats[key].format.textColor || "", "] pb-1")
|
|
241
|
+
}, "123")), /*#__PURE__*/_react.default.createElement("div", {
|
|
242
|
+
className: "flex flex-col"
|
|
243
|
+
}, /*#__PURE__*/_react.default.createElement("h3", {
|
|
244
|
+
className: "text-4xl font-normal text-gray-900 mb-2"
|
|
245
|
+
}, conditionformat[allConditionFormats[key].conditionName], ' ', (_a = allConditionFormats[key].conditionValue) === null || _a === void 0 ? void 0 : _a[0]), /*#__PURE__*/_react.default.createElement("p", {
|
|
246
|
+
className: "text-3xl text-gray-400"
|
|
247
|
+
}, (_b = allConditionFormats[key].cellrange) === null || _b === void 0 ? void 0 : _b.map(function (range) {
|
|
248
|
+
var startCol = (0, _helper.numberToColumn)(range.column[0] + 1);
|
|
249
|
+
var endCol = (0, _helper.numberToColumn)(range.column[1] + 1);
|
|
250
|
+
var startRow = range.row[0] + 1;
|
|
251
|
+
var endRow = range.row[1] + 1;
|
|
252
|
+
return "".concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
|
|
253
|
+
}).join(", "))));
|
|
254
|
+
}), /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
255
|
+
size: "md",
|
|
256
|
+
variant: "secondary",
|
|
257
|
+
onClick: function onClick() {
|
|
258
|
+
setCreate(true);
|
|
259
|
+
}
|
|
260
|
+
}, "Create New Condition Format"))) : (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !["aboveAverage", "belowAverage"].includes(type) && (/*#__PURE__*/_react.default.createElement("div", {
|
|
120
261
|
className: "flex flex-col"
|
|
121
262
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
122
263
|
className: "condition-rules-value text-heading-xsm"
|
|
@@ -224,7 +365,31 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
224
365
|
ctx.conditionRules.projectValue = String(current + 1);
|
|
225
366
|
});
|
|
226
367
|
}
|
|
227
|
-
})))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
368
|
+
})))))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
369
|
+
className: "condition-rules-value text-heading-xsm"
|
|
370
|
+
}, "Cell(s) format if"), /*#__PURE__*/_react.default.createElement(_ui.Select, {
|
|
371
|
+
value: type,
|
|
372
|
+
onValueChange: function onValueChange(value) {
|
|
373
|
+
console.log(value);
|
|
374
|
+
setType(value);
|
|
375
|
+
}
|
|
376
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.SelectTrigger, null, /*#__PURE__*/_react.default.createElement(_ui.SelectValue, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
377
|
+
className: "flex items-center gap-2"
|
|
378
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, conditionformat[type])))), /*#__PURE__*/_react.default.createElement(_ui.SelectContent, {
|
|
379
|
+
position: "popper",
|
|
380
|
+
side: "bottom",
|
|
381
|
+
align: "start",
|
|
382
|
+
sideOffset: 4,
|
|
383
|
+
className: "z-[100]",
|
|
384
|
+
"data-dropdown-content": "true"
|
|
385
|
+
}, conditionList.map(function (option) {
|
|
386
|
+
return /*#__PURE__*/_react.default.createElement(_ui.SelectItem, {
|
|
387
|
+
key: option.value,
|
|
388
|
+
value: option.text
|
|
389
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
390
|
+
className: "flex items-center gap-2"
|
|
391
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, conditionformat[option.text])));
|
|
392
|
+
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
228
393
|
className: "flex flex-col"
|
|
229
394
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
230
395
|
className: "condition-rules-value text-heading-xsm"
|
|
@@ -327,6 +492,6 @@ var ConditionRules = function ConditionRules(_a) {
|
|
|
327
492
|
close("confirm");
|
|
328
493
|
},
|
|
329
494
|
tabIndex: 0
|
|
330
|
-
}, button.apply)));
|
|
495
|
+
}, button.apply)))));
|
|
331
496
|
};
|
|
332
497
|
var _default = exports.default = ConditionRules;
|
|
@@ -2,6 +2,7 @@ export declare function moveCursorToEnd(editableDiv: HTMLDivElement): void;
|
|
|
2
2
|
export declare function getCursorPosition(editableDiv: HTMLDivElement): number;
|
|
3
3
|
export declare function isLetterNumberPattern(str: string): boolean;
|
|
4
4
|
export declare function removeLastSpan(htmlString: string): string;
|
|
5
|
+
export declare function numberToColumn(colNumber: number): string;
|
|
5
6
|
export declare function incrementColumn(cell: string): string;
|
|
6
7
|
export declare function decrementColumn(cell: string): string;
|
|
7
8
|
export declare function incrementRow(cell: string): string;
|
|
@@ -11,6 +11,7 @@ exports.incrementColumn = incrementColumn;
|
|
|
11
11
|
exports.incrementRow = incrementRow;
|
|
12
12
|
exports.isLetterNumberPattern = isLetterNumberPattern;
|
|
13
13
|
exports.moveCursorToEnd = moveCursorToEnd;
|
|
14
|
+
exports.numberToColumn = numberToColumn;
|
|
14
15
|
exports.removeLastSpan = removeLastSpan;
|
|
15
16
|
function moveCursorToEnd(editableDiv) {
|
|
16
17
|
editableDiv.focus();
|
|
@@ -20,7 +20,6 @@ var _SVGIcon = _interopRequireDefault(require("../SVGIcon"));
|
|
|
20
20
|
var _useDialog = require("../../hooks/useDialog");
|
|
21
21
|
var _SplitColumn = require("../SplitColumn");
|
|
22
22
|
var _LocationCondition = require("../LocationCondition");
|
|
23
|
-
var _ConditionFormat = _interopRequireDefault(require("../ConditionFormat"));
|
|
24
23
|
var _CustomButton = _interopRequireDefault(require("./CustomButton"));
|
|
25
24
|
var _CustomColor = require("./CustomColor");
|
|
26
25
|
var _FormatSearch = require("../FormatSearch");
|
|
@@ -626,6 +625,22 @@ var Toolbar = function Toolbar(_a) {
|
|
|
626
625
|
(0, _react.useEffect)(function () {
|
|
627
626
|
window.dataVerificationClick = dataVerificationClick;
|
|
628
627
|
}, []);
|
|
628
|
+
var conditionalFormatClick = function conditionalFormatClick(selectedCells) {
|
|
629
|
+
var _a;
|
|
630
|
+
console.log("conditionalFormatClick called");
|
|
631
|
+
var selection = _fortuneCore.api.getSelection(context);
|
|
632
|
+
if (!selection && !selectedCells) {
|
|
633
|
+
setContext(function (ctx) {
|
|
634
|
+
_fortuneCore.api.setSelection(ctx, [{
|
|
635
|
+
row: [0, 0],
|
|
636
|
+
column: [0, 0]
|
|
637
|
+
}], {
|
|
638
|
+
id: context.currentSheetId
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
(_a = document.getElementById("conditional-format-button")) === null || _a === void 0 ? void 0 : _a.click();
|
|
643
|
+
};
|
|
629
644
|
var getToolbarItem = (0, _react.useCallback)(function (name, i) {
|
|
630
645
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
631
646
|
var tooltip = toolbar[name];
|
|
@@ -1121,17 +1136,13 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1121
1136
|
});
|
|
1122
1137
|
}
|
|
1123
1138
|
if (name === "conditionFormat") {
|
|
1124
|
-
var
|
|
1125
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
1126
|
-
|
|
1139
|
+
var items = ["highlightCellRules", "itemSelectionRules", "-", "deleteRule"];
|
|
1140
|
+
return /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
1141
|
+
id: "conditionFormat",
|
|
1142
|
+
iconId: name,
|
|
1143
|
+
tooltip: tooltip,
|
|
1127
1144
|
key: name,
|
|
1128
|
-
|
|
1129
|
-
showArrow: false
|
|
1130
|
-
}, function (setOpen) {
|
|
1131
|
-
return /*#__PURE__*/_react.default.createElement(_ConditionFormat.default, {
|
|
1132
|
-
items: items_4,
|
|
1133
|
-
setOpen: setOpen
|
|
1134
|
-
});
|
|
1145
|
+
onClick: conditionalFormatClick
|
|
1135
1146
|
});
|
|
1136
1147
|
}
|
|
1137
1148
|
if (name === "image") {
|
|
@@ -1324,7 +1335,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1324
1335
|
});
|
|
1325
1336
|
}
|
|
1326
1337
|
if (name === "border") {
|
|
1327
|
-
var
|
|
1338
|
+
var items_4 = [{
|
|
1328
1339
|
text: border.borderTop,
|
|
1329
1340
|
value: "border-top",
|
|
1330
1341
|
icon: "BorderTop"
|
|
@@ -1379,7 +1390,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1379
1390
|
}, function (setOpen) {
|
|
1380
1391
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1381
1392
|
className: "fortune-toolbar-select fortune-border-grid"
|
|
1382
|
-
},
|
|
1393
|
+
}, items_4.map(function (_a) {
|
|
1383
1394
|
var value = _a.value,
|
|
1384
1395
|
icon = _a.icon;
|
|
1385
1396
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -1400,7 +1411,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1400
1411
|
});
|
|
1401
1412
|
}
|
|
1402
1413
|
if (name === "freeze") {
|
|
1403
|
-
var
|
|
1414
|
+
var items_5 = [{
|
|
1404
1415
|
text: freezen.freezenRowRange,
|
|
1405
1416
|
value: "freeze-row"
|
|
1406
1417
|
}, {
|
|
@@ -1424,7 +1435,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1424
1435
|
});
|
|
1425
1436
|
}
|
|
1426
1437
|
}, function (setOpen) {
|
|
1427
|
-
return /*#__PURE__*/_react.default.createElement(_Select.default, null,
|
|
1438
|
+
return /*#__PURE__*/_react.default.createElement(_Select.default, null, items_5.map(function (_a) {
|
|
1428
1439
|
var text = _a.text,
|
|
1429
1440
|
value = _a.value;
|
|
1430
1441
|
return /*#__PURE__*/_react.default.createElement(_Select.Option, {
|
|
@@ -1446,7 +1457,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1446
1457
|
});
|
|
1447
1458
|
}
|
|
1448
1459
|
if (name === "text-wrap") {
|
|
1449
|
-
var
|
|
1460
|
+
var items_6 = [{
|
|
1450
1461
|
text: textWrap.clip,
|
|
1451
1462
|
iconId: "text-clip",
|
|
1452
1463
|
value: "clip"
|
|
@@ -1459,9 +1470,9 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1459
1470
|
iconId: "text-wrap",
|
|
1460
1471
|
value: "wrap"
|
|
1461
1472
|
}];
|
|
1462
|
-
var curr_3 =
|
|
1473
|
+
var curr_3 = items_6[0];
|
|
1463
1474
|
if ((cell === null || cell === void 0 ? void 0 : cell.tb) != null) {
|
|
1464
|
-
curr_3 = _lodash.default.get(
|
|
1475
|
+
curr_3 = _lodash.default.get(items_6, cell.tb);
|
|
1465
1476
|
}
|
|
1466
1477
|
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1467
1478
|
iconId: curr_3.iconId,
|
|
@@ -1478,7 +1489,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1478
1489
|
justifyContent: "center",
|
|
1479
1490
|
gap: 4
|
|
1480
1491
|
}
|
|
1481
|
-
},
|
|
1492
|
+
}, items_6.map(function (_a) {
|
|
1482
1493
|
var iconId = _a.iconId,
|
|
1483
1494
|
value = _a.value;
|
|
1484
1495
|
return /*#__PURE__*/_react.default.createElement(_ui.IconButton, {
|
|
@@ -1509,7 +1520,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1509
1520
|
});
|
|
1510
1521
|
}
|
|
1511
1522
|
if (name === "text-rotation") {
|
|
1512
|
-
var
|
|
1523
|
+
var items_7 = [{
|
|
1513
1524
|
text: rotation.none,
|
|
1514
1525
|
iconId: "text-rotation-none",
|
|
1515
1526
|
value: "none"
|
|
@@ -1534,9 +1545,9 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1534
1545
|
iconId: "text-rotation-down",
|
|
1535
1546
|
value: "rotation-down"
|
|
1536
1547
|
}];
|
|
1537
|
-
var curr =
|
|
1548
|
+
var curr = items_7[0];
|
|
1538
1549
|
if ((cell === null || cell === void 0 ? void 0 : cell.tr) != null) {
|
|
1539
|
-
curr = _lodash.default.get(
|
|
1550
|
+
curr = _lodash.default.get(items_7, cell.tr);
|
|
1540
1551
|
}
|
|
1541
1552
|
return /*#__PURE__*/_react.default.createElement(_Combo.default, {
|
|
1542
1553
|
iconId: curr.iconId,
|
|
@@ -1544,7 +1555,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1544
1555
|
tooltip: toolbar.textRotate,
|
|
1545
1556
|
showArrow: false
|
|
1546
1557
|
}, function (setOpen) {
|
|
1547
|
-
return /*#__PURE__*/_react.default.createElement(_Select.default, null,
|
|
1558
|
+
return /*#__PURE__*/_react.default.createElement(_Select.default, null, items_7.map(function (_a) {
|
|
1548
1559
|
var text = _a.text,
|
|
1549
1560
|
iconId = _a.iconId,
|
|
1550
1561
|
value = _a.value;
|
|
@@ -1569,7 +1580,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1569
1580
|
});
|
|
1570
1581
|
}
|
|
1571
1582
|
if (name === "filter") {
|
|
1572
|
-
var
|
|
1583
|
+
var items_8 = [{
|
|
1573
1584
|
iconId: "sort-asc",
|
|
1574
1585
|
value: "sort-asc",
|
|
1575
1586
|
text: sort.asc,
|
|
@@ -1619,7 +1630,7 @@ var Toolbar = function Toolbar(_a) {
|
|
|
1619
1630
|
style: {
|
|
1620
1631
|
minWidth: "11.25rem"
|
|
1621
1632
|
}
|
|
1622
|
-
},
|
|
1633
|
+
}, items_8.map(function (_a, index) {
|
|
1623
1634
|
var text = _a.text,
|
|
1624
1635
|
iconId = _a.iconId,
|
|
1625
1636
|
value = _a.value,
|
|
@@ -1196,4 +1196,7 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
|
|
|
1196
1196
|
getRefs: () => any;
|
|
1197
1197
|
getShowDialog: () => typeof useDialog;
|
|
1198
1198
|
getSplitColComponent: () => import("react").FC<{}>;
|
|
1199
|
+
getConditionalFormatComponent: () => import("react").FC<{
|
|
1200
|
+
type?: string | undefined;
|
|
1201
|
+
}>;
|
|
1199
1202
|
};
|
|
@@ -10,6 +10,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
10
10
|
var _cryptoApi = require("../../utils/cryptoApi");
|
|
11
11
|
var _useDialog = require("../../hooks/useDialog");
|
|
12
12
|
var _SplitColumn = require("../../components/SplitColumn");
|
|
13
|
+
var _ConditionRules = _interopRequireDefault(require("../ConditionFormat/ConditionRules"));
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
15
16
|
__assign = Object.assign || function (t) {
|
|
@@ -459,6 +460,9 @@ function generateAPIs(context, setContext, handleUndo, handleRedo, settings, cel
|
|
|
459
460
|
},
|
|
460
461
|
getSplitColComponent: function getSplitColComponent() {
|
|
461
462
|
return _SplitColumn.SplitColumn;
|
|
463
|
+
},
|
|
464
|
+
getConditionalFormatComponent: function getConditionalFormatComponent() {
|
|
465
|
+
return _ConditionRules.default;
|
|
462
466
|
}
|
|
463
467
|
};
|
|
464
468
|
}
|
|
@@ -1203,5 +1203,8 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
|
|
|
1203
1203
|
getRefs: () => any;
|
|
1204
1204
|
getShowDialog: () => typeof import("../../hooks/useDialog").useDialog;
|
|
1205
1205
|
getSplitColComponent: () => React.FC<{}>;
|
|
1206
|
+
getConditionalFormatComponent: () => React.FC<{
|
|
1207
|
+
type?: string | undefined;
|
|
1208
|
+
}>;
|
|
1206
1209
|
}>>;
|
|
1207
1210
|
export default Workbook;
|
|
@@ -24,6 +24,7 @@ var _modal = require("../../context/modal");
|
|
|
24
24
|
var _FilterMenu = _interopRequireDefault(require("../ContextMenu/FilterMenu"));
|
|
25
25
|
var _SheetList = _interopRequireDefault(require("../SheetList"));
|
|
26
26
|
var _DunePreview = _interopRequireDefault(require("../DunePreview/DunePreview"));
|
|
27
|
+
var _ConditionRules = _interopRequireDefault(require("../ConditionFormat/ConditionRules"));
|
|
27
28
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
29
|
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); }
|
|
29
30
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
@@ -362,6 +363,10 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
362
363
|
refs: refs
|
|
363
364
|
};
|
|
364
365
|
}, [context, handleRedo, handleUndo, mergedSettings, refs, setContextWithProduce]);
|
|
366
|
+
var _e = (0, _react.useState)(false),
|
|
367
|
+
show = _e[0],
|
|
368
|
+
setShow = _e[1];
|
|
369
|
+
var getCond = function getCond() {};
|
|
365
370
|
(0, _react.useEffect)(function () {
|
|
366
371
|
if (!_lodash.default.isEmpty(context.luckysheetfile)) {
|
|
367
372
|
onChange === null || onChange === void 0 ? void 0 : onChange(context.luckysheetfile);
|
|
@@ -689,7 +694,20 @@ var Workbook = /*#__PURE__*/_react.default.forwardRef(function (_a, ref) {
|
|
|
689
694
|
}
|
|
690
695
|
return /*#__PURE__*/_react.default.createElement(_context.default.Provider, {
|
|
691
696
|
value: providerValue
|
|
692
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
697
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
698
|
+
onClick: function onClick() {
|
|
699
|
+
setShow(!show);
|
|
700
|
+
}
|
|
701
|
+
}, "Click"), show && /*#__PURE__*/_react.default.createElement("div", {
|
|
702
|
+
id: "placeholder-conditional-formatting",
|
|
703
|
+
style: {
|
|
704
|
+
width: "500px",
|
|
705
|
+
height: "500px",
|
|
706
|
+
position: "fixed",
|
|
707
|
+
zIndex: "1000",
|
|
708
|
+
backgroundColor: "white"
|
|
709
|
+
}
|
|
710
|
+
}, /*#__PURE__*/_react.default.createElement(_ConditionRules.default, null)), /*#__PURE__*/_react.default.createElement(_modal.ModalProvider, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
693
711
|
className: "fortune-container",
|
|
694
712
|
ref: workbookContainer,
|
|
695
713
|
onKeyDown: onKeyDown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fileverse-dev/fortune-react",
|
|
3
|
-
"version": "1.2.64-
|
|
3
|
+
"version": "1.2.64-patch-1",
|
|
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.2.64-
|
|
19
|
+
"@fileverse-dev/fortune-core": "1.2.64-patch-1",
|
|
20
20
|
"@fileverse/ui": "^4.1.7-patch-40",
|
|
21
21
|
"@tippyjs/react": "^4.2.6",
|
|
22
22
|
"@types/regenerator-runtime": "^0.13.6",
|