@fileverse-dev/fortune-react 1.2.99 → 1.3.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.
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import "./index.css";
3
3
  import "./formating.css";
4
4
  declare const ConditionRules: React.FC<{
5
- type?: string;
6
5
  context?: any;
7
6
  }>;
8
7
  export default ConditionRules;
@@ -11,9 +11,7 @@ import { injectDatepickerStyles } from "../../utils/datepickerStyles";
11
11
  import "./formating.css";
12
12
  injectDatepickerStyles();
13
13
  var ConditionRules = function ConditionRules(_a) {
14
- var rulesType = _a.type,
15
- context = _a.context;
16
- console.log("rulesType", rulesType);
14
+ var context = _a.context;
17
15
  var _b = useState("greaterThan"),
18
16
  type = _b[0],
19
17
  setType = _b[1];
@@ -120,7 +120,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
120
120
  onClick: function onClick() {
121
121
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
122
122
  showDialog(/*#__PURE__*/React.createElement(ConditionRules, {
123
- type: v.text
123
+ context: context
124
124
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
125
125
  },
126
126
  tabIndex: 0
@@ -167,7 +167,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
167
167
  onClick: function onClick() {
168
168
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
169
169
  showDialog(/*#__PURE__*/React.createElement(ConditionRules, {
170
- type: v.text
170
+ context: context
171
171
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
172
172
  },
173
173
  tabIndex: 0
@@ -0,0 +1,9 @@
1
+ import { Context } from "@fileverse-dev/fortune-core";
2
+ export declare function findMatchingCells(ctx: Context, currentRow: number, currentCol: number): {
3
+ row: number;
4
+ col: number;
5
+ }[];
6
+ export declare function cellsToRangeString(ctx: Context, cells: {
7
+ row: number;
8
+ col: number;
9
+ }[]): string;
@@ -0,0 +1,71 @@
1
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { getSheetIndex, getRangetxt, indexToColumnChar } from "@fileverse-dev/fortune-core";
11
+ export function findMatchingCells(ctx, currentRow, currentCol) {
12
+ var _a;
13
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
14
+ var dataVerification = (_a = ctx.luckysheetfile[sheetIndex].dataVerification) !== null && _a !== void 0 ? _a : {};
15
+ var currentValidation = dataVerification["".concat(currentRow, "_").concat(currentCol)];
16
+ if (!currentValidation) return [];
17
+ var matchingCells = [];
18
+ Object.keys(dataVerification).forEach(function (key) {
19
+ var _a = key.split("_").map(Number),
20
+ r = _a[0],
21
+ c = _a[1];
22
+ var validation = dataVerification[key];
23
+ if (validation.type === currentValidation.type && validation.type2 === currentValidation.type2 && validation.value1 === currentValidation.value1 && validation.value2 === currentValidation.value2 && validation.color === currentValidation.color && validation.validity === currentValidation.validity && validation.remote === currentValidation.remote && validation.prohibitInput === currentValidation.prohibitInput && validation.hintShow === currentValidation.hintShow && validation.hintValue === currentValidation.hintValue) {
24
+ matchingCells.push({
25
+ row: r,
26
+ col: c
27
+ });
28
+ }
29
+ });
30
+ return matchingCells;
31
+ }
32
+ export function cellsToRangeString(ctx, cells) {
33
+ if (cells.length === 0) return "";
34
+ if (cells.length === 1) {
35
+ return indexToColumnChar(cells[0].col) + (cells[0].row + 1);
36
+ }
37
+ var sorted = __spreadArray([], cells, true).sort(function (a, b) {
38
+ return a.row === b.row ? a.col - b.col : a.row - b.row;
39
+ });
40
+ var ranges = [];
41
+ var startRow = sorted[0].row;
42
+ var endRow = sorted[0].row;
43
+ var startCol = sorted[0].col;
44
+ var endCol = sorted[0].col;
45
+ for (var i = 1; i < sorted.length; i += 1) {
46
+ var _a = sorted[i],
47
+ row = _a.row,
48
+ col = _a.col;
49
+ if (col === startCol && col === endCol && row === endRow + 1) {
50
+ endRow = row;
51
+ } else if (row === startRow && row === endRow && col === endCol + 1) {
52
+ endCol = col;
53
+ } else {
54
+ var range_1 = getRangetxt(ctx, ctx.currentSheetId, {
55
+ row: [startRow, endRow],
56
+ column: [startCol, endCol]
57
+ });
58
+ ranges.push(range_1);
59
+ startRow = row;
60
+ endRow = row;
61
+ startCol = col;
62
+ endCol = col;
63
+ }
64
+ }
65
+ var range = getRangetxt(ctx, ctx.currentSheetId, {
66
+ row: [startRow, endRow],
67
+ column: [startCol, endCol]
68
+ });
69
+ ranges.push(range);
70
+ return ranges.join(",");
71
+ }
@@ -15,6 +15,7 @@ import DynamicInputList from "./DropdownOption";
15
15
  import WorkbookContext from "../../context";
16
16
  import { useDialog } from "../../hooks/useDialog";
17
17
  import { injectDatepickerStyles } from "../../utils/datepickerStyles";
18
+ import { findMatchingCells, cellsToRangeString } from "./helpers";
18
19
  import "./index.css";
19
20
  function createId() {
20
21
  return "".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2));
@@ -33,7 +34,7 @@ var DataVerification = function DataVerification() {
33
34
  button = _r.button,
34
35
  generalDialog = _r.generalDialog;
35
36
  var dateCondition = useState(["between", "notBetween", "equal", "notEqualTo", "earlierThan", "noEarlierThan", "laterThan", "noLaterThan"])[0];
36
- function getSheetIndex() {
37
+ var getSheetIndex = useCallback(function () {
37
38
  var _a;
38
39
  for (var i = 0; i < context.luckysheetfile.length; i += 1) {
39
40
  if (((_a = context.luckysheetfile[i]) === null || _a === void 0 ? void 0 : _a.id) === context.currentSheetId) {
@@ -41,7 +42,7 @@ var DataVerification = function DataVerification() {
41
42
  }
42
43
  }
43
44
  return null;
44
- }
45
+ }, [context.luckysheetfile, context.currentSheetId]);
45
46
  var _s = useState([]),
46
47
  optionItems = _s[0],
47
48
  setOptionItems = _s[1];
@@ -92,45 +93,68 @@ var DataVerification = function DataVerification() {
92
93
  ctx.rangeDialog.rangeTxt = value;
93
94
  });
94
95
  }, [hideDialog, setContext]);
96
+ var applyValidation = useCallback(function (rangeString) {
97
+ setContext(function (ctx) {
98
+ var _a;
99
+ var range = getRangeByTxt(ctx, rangeString);
100
+ if (range.length === 0) {
101
+ return;
102
+ }
103
+ var regulation = ctx.dataVerification.dataRegulation;
104
+ var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
105
+ var value1 = regulation.value1;
106
+ var item = __assign(__assign({}, regulation), {
107
+ checked: false
108
+ });
109
+ if (verifacationT === "dropdown") {
110
+ var list = getDropdownList(ctx, value1);
111
+ item.value1 = list.join(",");
112
+ }
113
+ var currentDataVerification = (_a = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _a !== void 0 ? _a : {};
114
+ var d = getFlowdata(ctx);
115
+ if (!d) return;
116
+ for (var ri = 0; ri < range.length; ri += 1) {
117
+ var str = range[ri].row[0];
118
+ var edr = range[ri].row[1];
119
+ var stc = range[ri].column[0];
120
+ var edc = range[ri].column[1];
121
+ for (var r = str; r <= edr; r += 1) {
122
+ for (var c = stc; c <= edc; c += 1) {
123
+ var key = "".concat(r, "_").concat(c);
124
+ currentDataVerification[key] = item;
125
+ if (regulation.type === "checkbox") {
126
+ setCellValue(ctx, r, c, d, item.value2);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
132
+ ctx.dataVerification.updateScope = undefined;
133
+ ctx.dataVerification.sourceCell = undefined;
134
+ });
135
+ }, [getSheetIndex, setContext]);
95
136
  var btn = useCallback(function (type) {
137
+ var _a, _b, _c;
96
138
  if (type === "confirm") {
97
- setContext(function (ctx) {
98
- var _a, _b, _c;
99
- var isPass = confirmMessage(ctx, generalDialog, dataVerification);
100
- if (isPass) {
101
- var range = getRangeByTxt(ctx, (_b = (_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.dataRegulation) === null || _b === void 0 ? void 0 : _b.rangeTxt);
102
- if (range.length === 0) {
103
- return;
104
- }
105
- var regulation = ctx.dataVerification.dataRegulation;
106
- var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
107
- var value1 = regulation.value1;
108
- var item = __assign(__assign({}, regulation), {
109
- checked: false
139
+ var isValid = confirmMessage(context, generalDialog, dataVerification);
140
+ if (!isValid) return;
141
+ var sourceCell = (_a = context.dataVerification) === null || _a === void 0 ? void 0 : _a.sourceCell;
142
+ var modalRangeString_1 = (_c = (_b = context.dataVerification) === null || _b === void 0 ? void 0 : _b.dataRegulation) === null || _c === void 0 ? void 0 : _c.rangeTxt;
143
+ if (sourceCell) {
144
+ var matchingCells = findMatchingCells(context, sourceCell.row, sourceCell.col);
145
+ if (matchingCells.length > 1) {
146
+ var allMatchingRange_1 = cellsToRangeString(context, matchingCells);
147
+ showDialog("Found ".concat(matchingCells.length, " cells with matching validation. Apply changes to:"), "yesno", "Apply Changes", "All Matching Cells", "Just Selected Range", function () {
148
+ applyValidation(allMatchingRange_1);
149
+ hideDialog();
150
+ }, function () {
151
+ applyValidation(modalRangeString_1);
152
+ hideDialog();
110
153
  });
111
- if (verifacationT === "dropdown") {
112
- var list = getDropdownList(ctx, value1);
113
- item.value1 = list.join(",");
114
- }
115
- var currentDataVerification = (_c = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _c !== void 0 ? _c : {};
116
- var str = range[range.length - 1].row[0];
117
- var edr = range[range.length - 1].row[1];
118
- var stc = range[range.length - 1].column[0];
119
- var edc = range[range.length - 1].column[1];
120
- var d = getFlowdata(ctx);
121
- if (!d) return;
122
- for (var r = str; r <= edr; r += 1) {
123
- for (var c = stc; c <= edc; c += 1) {
124
- var key = "".concat(r, "_").concat(c);
125
- currentDataVerification[key] = item;
126
- if (regulation.type === "checkbox") {
127
- setCellValue(ctx, r, c, d, item.value2);
128
- }
129
- }
130
- }
131
- ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
154
+ return;
132
155
  }
133
- });
156
+ }
157
+ applyValidation(modalRangeString_1);
134
158
  } else if (type === "delete") {
135
159
  setContext(function (ctx) {
136
160
  var _a, _b, _c;
@@ -149,17 +173,26 @@ var DataVerification = function DataVerification() {
149
173
  delete currentDataVerification["".concat(r, "_").concat(c)];
150
174
  }
151
175
  }
176
+ ctx.dataVerification.updateScope = undefined;
152
177
  });
153
178
  }
154
179
  hideDialog();
155
- }, [dataVerification, generalDialog, hideDialog, setContext, showDialog]);
180
+ }, [applyValidation, context, dataVerification, generalDialog, getSheetIndex, hideDialog, setContext, showDialog]);
156
181
  useEffect(function () {
157
182
  setContext(function (ctx) {
158
- var _a, _b, _c;
183
+ var _a, _b, _c, _d;
159
184
  var rangeT = "";
185
+ var updateScope = ((_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.updateScope) || "current";
160
186
  if (ctx.luckysheet_select_save) {
161
187
  var range = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
162
- rangeT = getRangetxt(context, context.currentSheetId, range, context.currentSheetId);
188
+ var rowIndex = range.row_focus;
189
+ var colIndex = range.column_focus;
190
+ if (updateScope === "all" && rowIndex != null && colIndex != null) {
191
+ var matchingCells = findMatchingCells(ctx, rowIndex, colIndex);
192
+ rangeT = cellsToRangeString(ctx, matchingCells);
193
+ } else {
194
+ rangeT = getRangetxt(context, context.currentSheetId, range, context.currentSheetId);
195
+ }
163
196
  }
164
197
  var index = getSheetIndex();
165
198
  var ctxDataVerification = ctx.luckysheetfile[index].dataVerification;
@@ -169,13 +202,17 @@ var DataVerification = function DataVerification() {
169
202
  var rowIndex = last.row_focus;
170
203
  var colIndex = last.column_focus;
171
204
  if (rowIndex == null || colIndex == null) return;
205
+ ctx.dataVerification.sourceCell = {
206
+ row: rowIndex,
207
+ col: colIndex
208
+ };
172
209
  var item = ctxDataVerification["".concat(rowIndex, "_").concat(colIndex)];
173
210
  var defaultItem = item !== null && item !== void 0 ? item : {};
174
- var rangValue = (_a = defaultItem.value1) !== null && _a !== void 0 ? _a : "";
175
- if (((_b = ctx.rangeDialog) === null || _b === void 0 ? void 0 : _b.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
211
+ var rangValue = (_b = defaultItem.value1) !== null && _b !== void 0 ? _b : "";
212
+ if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
176
213
  rangeT = ctx.dataVerification.dataRegulation.rangeTxt;
177
214
  rangValue = ctx.rangeDialog.rangeTxt;
178
- } else if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
215
+ } else if (((_d = ctx.rangeDialog) === null || _d === void 0 ? void 0 : _d.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
179
216
  rangValue = ctx.dataVerification.dataRegulation.value1;
180
217
  rangeT = ctx.rangeDialog.rangeTxt;
181
218
  }
@@ -9,43 +9,6 @@
9
9
  overflow: auto;
10
10
  }
11
11
 
12
- /* BEM selectors for testing and styling */
13
- .fortune-dialog__header {
14
- /* header container */
15
- }
16
-
17
- .fortune-dialog__heading {
18
- /* dialog title */
19
- }
20
-
21
- .fortune-dialog__para {
22
- /* dialog body content */
23
- }
24
-
25
- .fortune-dialog__icon {
26
- /* icon in header (e.g. close) */
27
- }
28
-
29
- .fortune-dialog__icon--close {
30
- /* close button icon */
31
- }
32
-
33
- .fortune-dialog__actions {
34
- /* footer action container */
35
- }
36
-
37
- .fortune-dialog__cta {
38
- /* primary/secondary action button */
39
- }
40
-
41
- .fortune-dialog__cta--cancel {
42
- /* cancel button */
43
- }
44
-
45
- .fortune-dialog__cta--confirm {
46
- /* confirm/ok button */
47
- }
48
-
49
12
  .fortune-dialog-box-button-container {
50
13
  display: flex;
51
14
  align-items: center;
@@ -105,6 +105,7 @@ export var useSmoothScroll = function useSmoothScroll(scrollContainerRef) {
105
105
  autoScrollAnimationId = requestAnimationFrame(autoScroll);
106
106
  }
107
107
  function onMouseDown(e) {
108
+ if (context.luckysheetCellUpdate.length > 0) return;
108
109
  if (e.button !== 0) return;
109
110
  var target = e.target;
110
111
  if (target.tagName === "INPUT" || target.tagName === "BUTTON" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.closest("button") || target.closest("input")) {
@@ -367,5 +368,5 @@ export var useSmoothScroll = function useSmoothScroll(scrollContainerRef) {
367
368
  if (!scrollContainerEl || !horizontalScrollbarEl || !verticalScrollbarEl) return function () {};
368
369
  var unmountScrollEventHandlers = mountScrollEventHandlers(scrollContainerEl, horizontalScrollbarEl, verticalScrollbarEl);
369
370
  return unmountScrollEventHandlers;
370
- }, [context.zoomRatio]);
371
+ }, [context.zoomRatio, context.luckysheetCellUpdate]);
371
372
  };
@@ -1199,7 +1199,6 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
1199
1199
  getShowDialog: () => typeof useDialog;
1200
1200
  getSplitColComponent: () => import("react").FC<{}>;
1201
1201
  getConditionalFormatComponent: () => import("react").FC<{
1202
- type?: string | undefined;
1203
1202
  context?: any;
1204
1203
  }>;
1205
1204
  };
@@ -1206,7 +1206,6 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
1206
1206
  getShowDialog: () => typeof import("../../hooks/useDialog").useDialog;
1207
1207
  getSplitColComponent: () => React.FC<{}>;
1208
1208
  getConditionalFormatComponent: () => React.FC<{
1209
- type?: string | undefined;
1210
1209
  context?: any;
1211
1210
  }>;
1212
1211
  }>>;
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import "./index.css";
3
3
  import "./formating.css";
4
4
  declare const ConditionRules: React.FC<{
5
- type?: string;
6
5
  context?: any;
7
6
  }>;
8
7
  export default ConditionRules;
@@ -20,9 +20,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
20
20
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _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); }
21
21
  (0, _datepickerStyles.injectDatepickerStyles)();
22
22
  var ConditionRules = function ConditionRules(_a) {
23
- var rulesType = _a.type,
24
- context = _a.context;
25
- console.log("rulesType", rulesType);
23
+ var context = _a.context;
26
24
  var _b = (0, _react.useState)("greaterThan"),
27
25
  type = _b[0],
28
26
  setType = _b[1];
@@ -129,7 +129,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
129
129
  onClick: function onClick() {
130
130
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
131
131
  showDialog(/*#__PURE__*/_react.default.createElement(_ConditionRules.default, {
132
- type: v.text
132
+ context: context
133
133
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
134
134
  },
135
135
  tabIndex: 0
@@ -176,7 +176,7 @@ var ConditionalFormat = function ConditionalFormat(_a) {
176
176
  onClick: function onClick() {
177
177
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
178
178
  showDialog(/*#__PURE__*/_react.default.createElement(_ConditionRules.default, {
179
- type: v.text
179
+ context: context
180
180
  }), undefined, conditionformat["conditionformat_".concat(v.text)]);
181
181
  },
182
182
  tabIndex: 0
@@ -0,0 +1,9 @@
1
+ import { Context } from "@fileverse-dev/fortune-core";
2
+ export declare function findMatchingCells(ctx: Context, currentRow: number, currentCol: number): {
3
+ row: number;
4
+ col: number;
5
+ }[];
6
+ export declare function cellsToRangeString(ctx: Context, cells: {
7
+ row: number;
8
+ col: number;
9
+ }[]): string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cellsToRangeString = cellsToRangeString;
7
+ exports.findMatchingCells = findMatchingCells;
8
+ var _fortuneCore = require("@fileverse-dev/fortune-core");
9
+ var __spreadArray = void 0 && (void 0).__spreadArray || function (to, from, pack) {
10
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
11
+ if (ar || !(i in from)) {
12
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
13
+ ar[i] = from[i];
14
+ }
15
+ }
16
+ return to.concat(ar || Array.prototype.slice.call(from));
17
+ };
18
+ function findMatchingCells(ctx, currentRow, currentCol) {
19
+ var _a;
20
+ var sheetIndex = (0, _fortuneCore.getSheetIndex)(ctx, ctx.currentSheetId);
21
+ var dataVerification = (_a = ctx.luckysheetfile[sheetIndex].dataVerification) !== null && _a !== void 0 ? _a : {};
22
+ var currentValidation = dataVerification["".concat(currentRow, "_").concat(currentCol)];
23
+ if (!currentValidation) return [];
24
+ var matchingCells = [];
25
+ Object.keys(dataVerification).forEach(function (key) {
26
+ var _a = key.split("_").map(Number),
27
+ r = _a[0],
28
+ c = _a[1];
29
+ var validation = dataVerification[key];
30
+ if (validation.type === currentValidation.type && validation.type2 === currentValidation.type2 && validation.value1 === currentValidation.value1 && validation.value2 === currentValidation.value2 && validation.color === currentValidation.color && validation.validity === currentValidation.validity && validation.remote === currentValidation.remote && validation.prohibitInput === currentValidation.prohibitInput && validation.hintShow === currentValidation.hintShow && validation.hintValue === currentValidation.hintValue) {
31
+ matchingCells.push({
32
+ row: r,
33
+ col: c
34
+ });
35
+ }
36
+ });
37
+ return matchingCells;
38
+ }
39
+ function cellsToRangeString(ctx, cells) {
40
+ if (cells.length === 0) return "";
41
+ if (cells.length === 1) {
42
+ return (0, _fortuneCore.indexToColumnChar)(cells[0].col) + (cells[0].row + 1);
43
+ }
44
+ var sorted = __spreadArray([], cells, true).sort(function (a, b) {
45
+ return a.row === b.row ? a.col - b.col : a.row - b.row;
46
+ });
47
+ var ranges = [];
48
+ var startRow = sorted[0].row;
49
+ var endRow = sorted[0].row;
50
+ var startCol = sorted[0].col;
51
+ var endCol = sorted[0].col;
52
+ for (var i = 1; i < sorted.length; i += 1) {
53
+ var _a = sorted[i],
54
+ row = _a.row,
55
+ col = _a.col;
56
+ if (col === startCol && col === endCol && row === endRow + 1) {
57
+ endRow = row;
58
+ } else if (row === startRow && row === endRow && col === endCol + 1) {
59
+ endCol = col;
60
+ } else {
61
+ var range_1 = (0, _fortuneCore.getRangetxt)(ctx, ctx.currentSheetId, {
62
+ row: [startRow, endRow],
63
+ column: [startCol, endCol]
64
+ });
65
+ ranges.push(range_1);
66
+ startRow = row;
67
+ endRow = row;
68
+ startCol = col;
69
+ endCol = col;
70
+ }
71
+ }
72
+ var range = (0, _fortuneCore.getRangetxt)(ctx, ctx.currentSheetId, {
73
+ row: [startRow, endRow],
74
+ column: [startCol, endCol]
75
+ });
76
+ ranges.push(range);
77
+ return ranges.join(",");
78
+ }
@@ -12,6 +12,7 @@ var _DropdownOption = _interopRequireDefault(require("./DropdownOption"));
12
12
  var _context = _interopRequireDefault(require("../../context"));
13
13
  var _useDialog = require("../../hooks/useDialog");
14
14
  var _datepickerStyles = require("../../utils/datepickerStyles");
15
+ var _helpers = require("./helpers");
15
16
  require("./index.css");
16
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
18
  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); }
@@ -42,7 +43,7 @@ var DataVerification = function DataVerification() {
42
43
  button = _r.button,
43
44
  generalDialog = _r.generalDialog;
44
45
  var dateCondition = (0, _react.useState)(["between", "notBetween", "equal", "notEqualTo", "earlierThan", "noEarlierThan", "laterThan", "noLaterThan"])[0];
45
- function getSheetIndex() {
46
+ var getSheetIndex = (0, _react.useCallback)(function () {
46
47
  var _a;
47
48
  for (var i = 0; i < context.luckysheetfile.length; i += 1) {
48
49
  if (((_a = context.luckysheetfile[i]) === null || _a === void 0 ? void 0 : _a.id) === context.currentSheetId) {
@@ -50,7 +51,7 @@ var DataVerification = function DataVerification() {
50
51
  }
51
52
  }
52
53
  return null;
53
- }
54
+ }, [context.luckysheetfile, context.currentSheetId]);
54
55
  var _s = (0, _react.useState)([]),
55
56
  optionItems = _s[0],
56
57
  setOptionItems = _s[1];
@@ -101,45 +102,68 @@ var DataVerification = function DataVerification() {
101
102
  ctx.rangeDialog.rangeTxt = value;
102
103
  });
103
104
  }, [hideDialog, setContext]);
105
+ var applyValidation = (0, _react.useCallback)(function (rangeString) {
106
+ setContext(function (ctx) {
107
+ var _a;
108
+ var range = (0, _fortuneCore.getRangeByTxt)(ctx, rangeString);
109
+ if (range.length === 0) {
110
+ return;
111
+ }
112
+ var regulation = ctx.dataVerification.dataRegulation;
113
+ var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
114
+ var value1 = regulation.value1;
115
+ var item = __assign(__assign({}, regulation), {
116
+ checked: false
117
+ });
118
+ if (verifacationT === "dropdown") {
119
+ var list = (0, _fortuneCore.getDropdownList)(ctx, value1);
120
+ item.value1 = list.join(",");
121
+ }
122
+ var currentDataVerification = (_a = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _a !== void 0 ? _a : {};
123
+ var d = (0, _fortuneCore.getFlowdata)(ctx);
124
+ if (!d) return;
125
+ for (var ri = 0; ri < range.length; ri += 1) {
126
+ var str = range[ri].row[0];
127
+ var edr = range[ri].row[1];
128
+ var stc = range[ri].column[0];
129
+ var edc = range[ri].column[1];
130
+ for (var r = str; r <= edr; r += 1) {
131
+ for (var c = stc; c <= edc; c += 1) {
132
+ var key = "".concat(r, "_").concat(c);
133
+ currentDataVerification[key] = item;
134
+ if (regulation.type === "checkbox") {
135
+ (0, _fortuneCore.setCellValue)(ctx, r, c, d, item.value2);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
141
+ ctx.dataVerification.updateScope = undefined;
142
+ ctx.dataVerification.sourceCell = undefined;
143
+ });
144
+ }, [getSheetIndex, setContext]);
104
145
  var btn = (0, _react.useCallback)(function (type) {
146
+ var _a, _b, _c;
105
147
  if (type === "confirm") {
106
- setContext(function (ctx) {
107
- var _a, _b, _c;
108
- var isPass = (0, _fortuneCore.confirmMessage)(ctx, generalDialog, dataVerification);
109
- if (isPass) {
110
- var range = (0, _fortuneCore.getRangeByTxt)(ctx, (_b = (_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.dataRegulation) === null || _b === void 0 ? void 0 : _b.rangeTxt);
111
- if (range.length === 0) {
112
- return;
113
- }
114
- var regulation = ctx.dataVerification.dataRegulation;
115
- var verifacationT = regulation === null || regulation === void 0 ? void 0 : regulation.type;
116
- var value1 = regulation.value1;
117
- var item = __assign(__assign({}, regulation), {
118
- checked: false
148
+ var isValid = (0, _fortuneCore.confirmMessage)(context, generalDialog, dataVerification);
149
+ if (!isValid) return;
150
+ var sourceCell = (_a = context.dataVerification) === null || _a === void 0 ? void 0 : _a.sourceCell;
151
+ var modalRangeString_1 = (_c = (_b = context.dataVerification) === null || _b === void 0 ? void 0 : _b.dataRegulation) === null || _c === void 0 ? void 0 : _c.rangeTxt;
152
+ if (sourceCell) {
153
+ var matchingCells = (0, _helpers.findMatchingCells)(context, sourceCell.row, sourceCell.col);
154
+ if (matchingCells.length > 1) {
155
+ var allMatchingRange_1 = (0, _helpers.cellsToRangeString)(context, matchingCells);
156
+ showDialog("Found ".concat(matchingCells.length, " cells with matching validation. Apply changes to:"), "yesno", "Apply Changes", "All Matching Cells", "Just Selected Range", function () {
157
+ applyValidation(allMatchingRange_1);
158
+ hideDialog();
159
+ }, function () {
160
+ applyValidation(modalRangeString_1);
161
+ hideDialog();
119
162
  });
120
- if (verifacationT === "dropdown") {
121
- var list = (0, _fortuneCore.getDropdownList)(ctx, value1);
122
- item.value1 = list.join(",");
123
- }
124
- var currentDataVerification = (_c = ctx.luckysheetfile[getSheetIndex()].dataVerification) !== null && _c !== void 0 ? _c : {};
125
- var str = range[range.length - 1].row[0];
126
- var edr = range[range.length - 1].row[1];
127
- var stc = range[range.length - 1].column[0];
128
- var edc = range[range.length - 1].column[1];
129
- var d = (0, _fortuneCore.getFlowdata)(ctx);
130
- if (!d) return;
131
- for (var r = str; r <= edr; r += 1) {
132
- for (var c = stc; c <= edc; c += 1) {
133
- var key = "".concat(r, "_").concat(c);
134
- currentDataVerification[key] = item;
135
- if (regulation.type === "checkbox") {
136
- (0, _fortuneCore.setCellValue)(ctx, r, c, d, item.value2);
137
- }
138
- }
139
- }
140
- ctx.luckysheetfile[getSheetIndex()].dataVerification = currentDataVerification;
163
+ return;
141
164
  }
142
- });
165
+ }
166
+ applyValidation(modalRangeString_1);
143
167
  } else if (type === "delete") {
144
168
  setContext(function (ctx) {
145
169
  var _a, _b, _c;
@@ -158,17 +182,26 @@ var DataVerification = function DataVerification() {
158
182
  delete currentDataVerification["".concat(r, "_").concat(c)];
159
183
  }
160
184
  }
185
+ ctx.dataVerification.updateScope = undefined;
161
186
  });
162
187
  }
163
188
  hideDialog();
164
- }, [dataVerification, generalDialog, hideDialog, setContext, showDialog]);
189
+ }, [applyValidation, context, dataVerification, generalDialog, getSheetIndex, hideDialog, setContext, showDialog]);
165
190
  (0, _react.useEffect)(function () {
166
191
  setContext(function (ctx) {
167
- var _a, _b, _c;
192
+ var _a, _b, _c, _d;
168
193
  var rangeT = "";
194
+ var updateScope = ((_a = ctx.dataVerification) === null || _a === void 0 ? void 0 : _a.updateScope) || "current";
169
195
  if (ctx.luckysheet_select_save) {
170
196
  var range = ctx.luckysheet_select_save[ctx.luckysheet_select_save.length - 1];
171
- rangeT = (0, _fortuneCore.getRangetxt)(context, context.currentSheetId, range, context.currentSheetId);
197
+ var rowIndex = range.row_focus;
198
+ var colIndex = range.column_focus;
199
+ if (updateScope === "all" && rowIndex != null && colIndex != null) {
200
+ var matchingCells = (0, _helpers.findMatchingCells)(ctx, rowIndex, colIndex);
201
+ rangeT = (0, _helpers.cellsToRangeString)(ctx, matchingCells);
202
+ } else {
203
+ rangeT = (0, _fortuneCore.getRangetxt)(context, context.currentSheetId, range, context.currentSheetId);
204
+ }
172
205
  }
173
206
  var index = getSheetIndex();
174
207
  var ctxDataVerification = ctx.luckysheetfile[index].dataVerification;
@@ -178,13 +211,17 @@ var DataVerification = function DataVerification() {
178
211
  var rowIndex = last.row_focus;
179
212
  var colIndex = last.column_focus;
180
213
  if (rowIndex == null || colIndex == null) return;
214
+ ctx.dataVerification.sourceCell = {
215
+ row: rowIndex,
216
+ col: colIndex
217
+ };
181
218
  var item = ctxDataVerification["".concat(rowIndex, "_").concat(colIndex)];
182
219
  var defaultItem = item !== null && item !== void 0 ? item : {};
183
- var rangValue = (_a = defaultItem.value1) !== null && _a !== void 0 ? _a : "";
184
- if (((_b = ctx.rangeDialog) === null || _b === void 0 ? void 0 : _b.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
220
+ var rangValue = (_b = defaultItem.value1) !== null && _b !== void 0 ? _b : "";
221
+ if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "dropDown" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.rangeTxt) {
185
222
  rangeT = ctx.dataVerification.dataRegulation.rangeTxt;
186
223
  rangValue = ctx.rangeDialog.rangeTxt;
187
- } else if (((_c = ctx.rangeDialog) === null || _c === void 0 ? void 0 : _c.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
224
+ } else if (((_d = ctx.rangeDialog) === null || _d === void 0 ? void 0 : _d.type) === "rangeTxt" && ctx.dataVerification && ctx.dataVerification.dataRegulation && ctx.dataVerification.dataRegulation.value1) {
188
225
  rangValue = ctx.dataVerification.dataRegulation.value1;
189
226
  rangeT = ctx.rangeDialog.rangeTxt;
190
227
  }
@@ -9,43 +9,6 @@
9
9
  overflow: auto;
10
10
  }
11
11
 
12
- /* BEM selectors for testing and styling */
13
- .fortune-dialog__header {
14
- /* header container */
15
- }
16
-
17
- .fortune-dialog__heading {
18
- /* dialog title */
19
- }
20
-
21
- .fortune-dialog__para {
22
- /* dialog body content */
23
- }
24
-
25
- .fortune-dialog__icon {
26
- /* icon in header (e.g. close) */
27
- }
28
-
29
- .fortune-dialog__icon--close {
30
- /* close button icon */
31
- }
32
-
33
- .fortune-dialog__actions {
34
- /* footer action container */
35
- }
36
-
37
- .fortune-dialog__cta {
38
- /* primary/secondary action button */
39
- }
40
-
41
- .fortune-dialog__cta--cancel {
42
- /* cancel button */
43
- }
44
-
45
- .fortune-dialog__cta--confirm {
46
- /* confirm/ok button */
47
- }
48
-
49
12
  .fortune-dialog-box-button-container {
50
13
  display: flex;
51
14
  align-items: center;
@@ -112,6 +112,7 @@ var useSmoothScroll = exports.useSmoothScroll = function useSmoothScroll(scrollC
112
112
  autoScrollAnimationId = requestAnimationFrame(autoScroll);
113
113
  }
114
114
  function onMouseDown(e) {
115
+ if (context.luckysheetCellUpdate.length > 0) return;
115
116
  if (e.button !== 0) return;
116
117
  var target = e.target;
117
118
  if (target.tagName === "INPUT" || target.tagName === "BUTTON" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.closest("button") || target.closest("input")) {
@@ -374,5 +375,5 @@ var useSmoothScroll = exports.useSmoothScroll = function useSmoothScroll(scrollC
374
375
  if (!scrollContainerEl || !horizontalScrollbarEl || !verticalScrollbarEl) return function () {};
375
376
  var unmountScrollEventHandlers = mountScrollEventHandlers(scrollContainerEl, horizontalScrollbarEl, verticalScrollbarEl);
376
377
  return unmountScrollEventHandlers;
377
- }, [context.zoomRatio]);
378
+ }, [context.zoomRatio, context.luckysheetCellUpdate]);
378
379
  };
@@ -1199,7 +1199,6 @@ export declare function generateAPIs(context: Context, setContext: (recipe: (ctx
1199
1199
  getShowDialog: () => typeof useDialog;
1200
1200
  getSplitColComponent: () => import("react").FC<{}>;
1201
1201
  getConditionalFormatComponent: () => import("react").FC<{
1202
- type?: string | undefined;
1203
1202
  context?: any;
1204
1203
  }>;
1205
1204
  };
@@ -1206,7 +1206,6 @@ declare const Workbook: React.ForwardRefExoticComponent<Settings & AdditionalPro
1206
1206
  getShowDialog: () => typeof import("../../hooks/useDialog").useDialog;
1207
1207
  getSplitColComponent: () => React.FC<{}>;
1208
1208
  getConditionalFormatComponent: () => React.FC<{
1209
- type?: string | undefined;
1210
1209
  context?: any;
1211
1210
  }>;
1212
1211
  }>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-react",
3
- "version": "1.2.99",
3
+ "version": "1.3.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.99",
19
+ "@fileverse-dev/fortune-core": "1.3.1",
20
20
  "@fileverse/ui": "5.0.0",
21
21
  "@tippyjs/react": "^4.2.6",
22
22
  "@types/regenerator-runtime": "^0.13.6",