@fileverse-dev/fortune-core 1.1.2 → 1.1.4
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/events/keyboard.d.ts +1 -1
- package/es/events/keyboard.js +226 -99
- package/es/locale/en.d.ts +6 -0
- package/es/locale/en.js +11 -0
- package/es/modules/ConditionFormat.js +107 -16
- package/es/modules/selection.d.ts +2 -0
- package/es/modules/selection.js +86 -0
- package/lib/events/keyboard.d.ts +1 -1
- package/lib/events/keyboard.js +225 -98
- package/lib/locale/en.d.ts +6 -0
- package/lib/locale/en.js +11 -0
- package/lib/modules/ConditionFormat.js +107 -16
- package/lib/modules/selection.d.ts +2 -0
- package/lib/modules/selection.js +88 -0
- package/package.json +1 -1
|
@@ -31,6 +31,86 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
31
31
|
};
|
|
32
32
|
return __assign.apply(this, arguments);
|
|
33
33
|
};
|
|
34
|
+
function hasAlphabeticChars(value) {
|
|
35
|
+
return /[a-zA-Z]/.test(String(value));
|
|
36
|
+
}
|
|
37
|
+
function compareGreaterThan(cellValue, conditionValue, symbol) {
|
|
38
|
+
var cellStr = String(cellValue);
|
|
39
|
+
var conditionStr = String(conditionValue);
|
|
40
|
+
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
41
|
+
if (symbol === '>=') {
|
|
42
|
+
return cellStr.localeCompare(conditionStr) >= 0;
|
|
43
|
+
}
|
|
44
|
+
return cellStr.localeCompare(conditionStr) > 0;
|
|
45
|
+
}
|
|
46
|
+
var cellNum = Number(cellValue);
|
|
47
|
+
var conditionNum = Number(conditionValue);
|
|
48
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '>=') {
|
|
49
|
+
return cellNum >= conditionNum;
|
|
50
|
+
}
|
|
51
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '>') {
|
|
52
|
+
return cellNum > conditionNum;
|
|
53
|
+
}
|
|
54
|
+
if (symbol === '>=') {
|
|
55
|
+
return cellStr.localeCompare(conditionStr) >= 0;
|
|
56
|
+
}
|
|
57
|
+
return cellStr.localeCompare(conditionStr) > 0;
|
|
58
|
+
}
|
|
59
|
+
function compareLessThan(cellValue, conditionValue, symbol) {
|
|
60
|
+
var cellStr = String(cellValue);
|
|
61
|
+
var conditionStr = String(conditionValue);
|
|
62
|
+
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
63
|
+
if (symbol === '<=') {
|
|
64
|
+
return cellStr.localeCompare(conditionStr) <= 0;
|
|
65
|
+
}
|
|
66
|
+
return cellStr.localeCompare(conditionStr) < 0;
|
|
67
|
+
}
|
|
68
|
+
var cellNum = Number(cellValue);
|
|
69
|
+
var conditionNum = Number(conditionValue);
|
|
70
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === '<=') {
|
|
71
|
+
return cellNum <= conditionNum;
|
|
72
|
+
}
|
|
73
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum)) {
|
|
74
|
+
return cellNum < conditionNum;
|
|
75
|
+
}
|
|
76
|
+
if (symbol === '<=') {
|
|
77
|
+
return cellStr.localeCompare(conditionStr) <= 0;
|
|
78
|
+
}
|
|
79
|
+
return cellStr.localeCompare(conditionStr) < 0;
|
|
80
|
+
}
|
|
81
|
+
function compareBetween(cellValue, value1, value2) {
|
|
82
|
+
var cellStr = String(cellValue);
|
|
83
|
+
var val1Str = String(value1);
|
|
84
|
+
var val2Str = String(value2);
|
|
85
|
+
var smallerValue, biggerValue;
|
|
86
|
+
if (hasAlphabeticChars(value1) || hasAlphabeticChars(value2) || hasAlphabeticChars(cellValue)) {
|
|
87
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
88
|
+
biggerValue = val1Str;
|
|
89
|
+
smallerValue = val2Str;
|
|
90
|
+
} else {
|
|
91
|
+
biggerValue = val2Str;
|
|
92
|
+
smallerValue = val1Str;
|
|
93
|
+
}
|
|
94
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
95
|
+
} else {
|
|
96
|
+
var cellNum = Number(cellValue);
|
|
97
|
+
var val1Num = Number(value1);
|
|
98
|
+
var val2Num = Number(value2);
|
|
99
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
100
|
+
var smallerNum = Math.min(val1Num, val2Num);
|
|
101
|
+
var biggerNum = Math.max(val1Num, val2Num);
|
|
102
|
+
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
103
|
+
}
|
|
104
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
105
|
+
biggerValue = val1Str;
|
|
106
|
+
smallerValue = val2Str;
|
|
107
|
+
} else {
|
|
108
|
+
biggerValue = val2Str;
|
|
109
|
+
smallerValue = val1Str;
|
|
110
|
+
}
|
|
111
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
34
114
|
function getHistoryRules(fileH) {
|
|
35
115
|
var historyRules = [];
|
|
36
116
|
for (var h = 0; h < fileH.length; h += 1) {
|
|
@@ -59,7 +139,7 @@ function setConditionRules(ctx, protection, generalDialog, conditionformat, rule
|
|
|
59
139
|
var conditionName = rules.rulesType;
|
|
60
140
|
var conditionRange = [];
|
|
61
141
|
var conditionValue = [];
|
|
62
|
-
if (conditionName === "greaterThan" || conditionName === "lessThan" || conditionName === "equal" || conditionName === "textContains") {
|
|
142
|
+
if (conditionName === "greaterThan" || conditionName === "greaterThanOrEqual" || conditionName === "lessThan" || conditionName === "lessThanOrEqual" || conditionName === "equal" || conditionName === "textContains") {
|
|
63
143
|
var v = rules.rulesValue;
|
|
64
144
|
var rangeArr = (0, _cell.getRangeByTxt)(ctx, v);
|
|
65
145
|
if (rangeArr.length > 1) {
|
|
@@ -483,7 +563,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
483
563
|
var textColor_1 = format.textColor,
|
|
484
564
|
cellColor_1 = format.cellColor;
|
|
485
565
|
for (var s = 0; s < cellrange.length; s += 1) {
|
|
486
|
-
if (conditionName === "greaterThan" || conditionName === "lessThan" || conditionName === "equal" || conditionName === "textContains") {
|
|
566
|
+
if (conditionName === "greaterThan" || conditionName === "greaterThanOrEqual" || conditionName === "lessThan" || conditionName === "lessThanOrEqual" || conditionName === "equal" || conditionName === "textContains") {
|
|
487
567
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
488
568
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
489
569
|
if (_lodash.default.isNil(d[r]) || _lodash.default.isNil(d[r][c])) {
|
|
@@ -493,7 +573,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
493
573
|
if (_lodash.default.isNil(cell) || _lodash.default.isNil(cell.v) || (0, _validation.isRealNull)(cell.v)) {
|
|
494
574
|
continue;
|
|
495
575
|
}
|
|
496
|
-
if (conditionName === "greaterThan" &&
|
|
576
|
+
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0, '>')) {
|
|
497
577
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
498
578
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
499
579
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -503,7 +583,27 @@ function compute(ctx, ruleArr, d) {
|
|
|
503
583
|
cellColor: cellColor_1
|
|
504
584
|
};
|
|
505
585
|
}
|
|
506
|
-
} else if (conditionName === "
|
|
586
|
+
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0, '>=')) {
|
|
587
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
588
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
589
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
590
|
+
} else {
|
|
591
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
592
|
+
textColor: textColor_1,
|
|
593
|
+
cellColor: cellColor_1
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
} else if (conditionName === "lessThan" && compareLessThan(cell.v, conditionValue0, "<")) {
|
|
597
|
+
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
598
|
+
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
599
|
+
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
600
|
+
} else {
|
|
601
|
+
computeMap["".concat(r, "_").concat(c)] = {
|
|
602
|
+
textColor: textColor_1,
|
|
603
|
+
cellColor: cellColor_1
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0, '<=')) {
|
|
507
607
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
508
608
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
509
609
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -537,15 +637,6 @@ function compute(ctx, ruleArr, d) {
|
|
|
537
637
|
}
|
|
538
638
|
}
|
|
539
639
|
} else if (conditionName === "between") {
|
|
540
|
-
var vBig = 0;
|
|
541
|
-
var vSmall = 0;
|
|
542
|
-
if (conditionValue0 > conditionValue1) {
|
|
543
|
-
vBig = conditionValue0;
|
|
544
|
-
vSmall = conditionValue1;
|
|
545
|
-
} else {
|
|
546
|
-
vBig = conditionValue1;
|
|
547
|
-
vSmall = conditionValue0;
|
|
548
|
-
}
|
|
549
640
|
for (var r = cellrange[s].row[0]; r <= cellrange[s].row[1]; r += 1) {
|
|
550
641
|
for (var c = cellrange[s].column[0]; c <= cellrange[s].column[1]; c += 1) {
|
|
551
642
|
if (_lodash.default.isNil(d[r]) || _lodash.default.isNil(d[r][c])) {
|
|
@@ -555,7 +646,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
555
646
|
if (_lodash.default.isNil(cell) || _lodash.default.isNil(cell.v) || (0, _validation.isRealNull)(cell.v)) {
|
|
556
647
|
continue;
|
|
557
648
|
}
|
|
558
|
-
if (
|
|
649
|
+
if (compareBetween(cell.v, conditionValue0, conditionValue1)) {
|
|
559
650
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
560
651
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
561
652
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -1019,7 +1110,7 @@ function CFSplitRange(range1, range2, range3, type) {
|
|
|
1019
1110
|
row: [range2.row[1] + 1, r2],
|
|
1020
1111
|
column: [c1, c2]
|
|
1021
1112
|
}, {
|
|
1022
|
-
row: [
|
|
1113
|
+
row: [range2.row[0] + offset_r, r2 + offset_r],
|
|
1023
1114
|
column: [range2.column[0] + offset_c, c2 + offset_c]
|
|
1024
1115
|
}];
|
|
1025
1116
|
} else if (type === "restPart") {
|
|
@@ -1032,7 +1123,7 @@ function CFSplitRange(range1, range2, range3, type) {
|
|
|
1032
1123
|
}];
|
|
1033
1124
|
} else if (type === "operatePart") {
|
|
1034
1125
|
range = [{
|
|
1035
|
-
row: [
|
|
1126
|
+
row: [range2.row[0] + offset_r, r2 + offset_r],
|
|
1036
1127
|
column: [range2.column[0] + offset_c, c2 + offset_c]
|
|
1037
1128
|
}];
|
|
1038
1129
|
}
|
|
@@ -25,6 +25,8 @@ export declare function rangeValueToHtml(ctx: Context, sheetId: string, ranges?:
|
|
|
25
25
|
export declare function copy(ctx: Context): void;
|
|
26
26
|
export declare function deleteSelectedCellText(ctx: Context): string;
|
|
27
27
|
export declare function deleteSelectedCellFormat(ctx: Context): string;
|
|
28
|
+
export declare function fillRightData(ctx: Context): string;
|
|
29
|
+
export declare function fillDownData(ctx: Context): string;
|
|
28
30
|
export declare function textFormat(ctx: Context, type: "left" | "center" | "right"): string;
|
|
29
31
|
export declare function fillDate(ctx: Context): string;
|
|
30
32
|
export declare function fillTime(ctx: Context): string;
|
package/lib/modules/selection.js
CHANGED
|
@@ -9,6 +9,8 @@ exports.copy = copy;
|
|
|
9
9
|
exports.deleteSelectedCellFormat = deleteSelectedCellFormat;
|
|
10
10
|
exports.deleteSelectedCellText = deleteSelectedCellText;
|
|
11
11
|
exports.fillDate = fillDate;
|
|
12
|
+
exports.fillDownData = fillDownData;
|
|
13
|
+
exports.fillRightData = fillRightData;
|
|
12
14
|
exports.fillTime = fillTime;
|
|
13
15
|
exports.fixColumnStyleOverflowInFreeze = fixColumnStyleOverflowInFreeze;
|
|
14
16
|
exports.fixRowStyleOverflowInFreeze = fixRowStyleOverflowInFreeze;
|
|
@@ -43,6 +45,16 @@ var _ConditionFormat = require("./ConditionFormat");
|
|
|
43
45
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
44
46
|
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); }
|
|
45
47
|
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); }
|
|
48
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
49
|
+
__assign = Object.assign || function (t) {
|
|
50
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
51
|
+
s = arguments[i];
|
|
52
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
};
|
|
56
|
+
return __assign.apply(this, arguments);
|
|
57
|
+
};
|
|
46
58
|
var selectionCache = exports.selectionCache = {
|
|
47
59
|
isPasteAction: false
|
|
48
60
|
};
|
|
@@ -1619,6 +1631,82 @@ function deleteSelectedCellFormat(ctx) {
|
|
|
1619
1631
|
}
|
|
1620
1632
|
return "success";
|
|
1621
1633
|
}
|
|
1634
|
+
function fillRightData(ctx) {
|
|
1635
|
+
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1636
|
+
if (allowEdit === false) {
|
|
1637
|
+
return "allowEdit";
|
|
1638
|
+
}
|
|
1639
|
+
var selection = ctx.luckysheet_select_save;
|
|
1640
|
+
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
1641
|
+
var d = (0, _context.getFlowdata)(ctx);
|
|
1642
|
+
if (!d) return "dataNullError";
|
|
1643
|
+
var has_PartMC = false;
|
|
1644
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1645
|
+
var r1 = selection[s].row[0];
|
|
1646
|
+
var r2 = selection[s].row[1];
|
|
1647
|
+
var c1 = selection[s].column[0];
|
|
1648
|
+
var c2 = selection[s].column[1];
|
|
1649
|
+
if ((0, _validation.hasPartMC)(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1650
|
+
has_PartMC = true;
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
if (has_PartMC) {
|
|
1655
|
+
return "partMC";
|
|
1656
|
+
}
|
|
1657
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1658
|
+
var r1 = selection[s].row[0];
|
|
1659
|
+
var r2 = selection[s].row[1];
|
|
1660
|
+
var c1 = selection[s].column[0];
|
|
1661
|
+
var c2 = selection[s].column[1];
|
|
1662
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1663
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1664
|
+
var previousCell = d[r][c - 1];
|
|
1665
|
+
d[r][c] = __assign({}, previousCell);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
return "success";
|
|
1671
|
+
}
|
|
1672
|
+
function fillDownData(ctx) {
|
|
1673
|
+
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1674
|
+
if (allowEdit === false) {
|
|
1675
|
+
return "allowEdit";
|
|
1676
|
+
}
|
|
1677
|
+
var selection = ctx.luckysheet_select_save;
|
|
1678
|
+
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
1679
|
+
var d = (0, _context.getFlowdata)(ctx);
|
|
1680
|
+
if (!d) return "dataNullError";
|
|
1681
|
+
var has_PartMC = false;
|
|
1682
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1683
|
+
var r1 = selection[s].row[0];
|
|
1684
|
+
var r2 = selection[s].row[1];
|
|
1685
|
+
var c1 = selection[s].column[0];
|
|
1686
|
+
var c2 = selection[s].column[1];
|
|
1687
|
+
if ((0, _validation.hasPartMC)(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1688
|
+
has_PartMC = true;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
if (has_PartMC) {
|
|
1693
|
+
return "partMC";
|
|
1694
|
+
}
|
|
1695
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1696
|
+
var r1 = selection[s].row[0];
|
|
1697
|
+
var r2 = selection[s].row[1];
|
|
1698
|
+
var c1 = selection[s].column[0];
|
|
1699
|
+
var c2 = selection[s].column[1];
|
|
1700
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1701
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1702
|
+
var previousCell = d[r - 1][c];
|
|
1703
|
+
d[r][c] = __assign({}, previousCell);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
return "success";
|
|
1709
|
+
}
|
|
1622
1710
|
function textFormat(ctx, type) {
|
|
1623
1711
|
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1624
1712
|
if (allowEdit === false) {
|