@fileverse-dev/fortune-core 1.1.43 → 1.1.44

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.
@@ -177,7 +177,8 @@ export function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, containe
177
177
  var doc = parser.parseFromString("<div>".concat((_g = document.getElementById("luckysheet-rich-text-editor")) === null || _g === void 0 ? void 0 : _g.innerHTML, "</div>"), "text/html");
178
178
  var spans = doc.querySelectorAll("span");
179
179
  var firstSpan = spans[0];
180
- if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("="))) {
180
+ var lastSpan = spans[spans.length - 1];
181
+ if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || israngeseleciton(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) {
181
182
  var rowseleted = [row_index, row_index_ed];
182
183
  var columnseleted = [col_index, col_index_ed];
183
184
  var left = col_pre;
package/es/locale/en.js CHANGED
@@ -8684,7 +8684,7 @@ export default {
8684
8684
  }, {
8685
8685
  n: "SORT",
8686
8686
  t: "14",
8687
- d: "Sorts the rows of a given array or range by the values in a specified column.",
8687
+ d: "Sorts the rows of a given array or range by the values in one or more columns.",
8688
8688
  a: "Sorts rows of range by specified column.",
8689
8689
  m: [1, 4],
8690
8690
  p: [{
@@ -8696,7 +8696,7 @@ export default {
8696
8696
  type: "rangenumber"
8697
8697
  }, {
8698
8698
  name: "sort_column",
8699
- detail: "The index of the column in `range` to sort by. defaults to the first column. index starts at 1.",
8699
+ detail: "The index of the column in `range` to sort by. The first column in `range` is 1, the second column is 2, and so on.",
8700
8700
  example: "1",
8701
8701
  require: "o",
8702
8702
  repeat: "n",
package/es/locale/es.js CHANGED
@@ -8674,7 +8674,7 @@ export default {
8674
8674
  }, {
8675
8675
  n: "SORT",
8676
8676
  t: "14",
8677
- d: "Sorts the rows of a given array or range by the values in a specified column.",
8677
+ d: "Sorts the rows of a given array or range by the values in one or more columns.",
8678
8678
  a: "Sorts rows of range by specified column.",
8679
8679
  m: [1, 4],
8680
8680
  p: [{
@@ -126,6 +126,14 @@ export function setCellValue(ctx, r, c, d, v) {
126
126
  } else {
127
127
  vupdate = v;
128
128
  }
129
+ var commaPresent = false;
130
+ if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
131
+ commaPresent = vupdate.includes(",");
132
+ var removeCommasValidated = function removeCommasValidated(str) {
133
+ return /^[\d,]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
134
+ };
135
+ vupdate = removeCommasValidated(vupdate);
136
+ }
129
137
  if (isRealNull(vupdate)) {
130
138
  if (_.isPlainObject(cell)) {
131
139
  delete cell.m;
@@ -263,8 +271,18 @@ export function setCellValue(ctx, r, c, d, v) {
263
271
  }
264
272
  }
265
273
  cell.v = vupdate;
274
+ var format = void 0;
275
+ if (String(vupdate).includes(".")) {
276
+ format = "#,##0.00";
277
+ } else if (commaPresent) {
278
+ format = "#,##0.00";
279
+ } else {
280
+ format = "0";
281
+ }
282
+ cell.m = update(format, cell.v);
283
+ cell.ht = 2;
266
284
  cell.ct = {
267
- fa: "General",
285
+ fa: format,
268
286
  t: "n"
269
287
  };
270
288
  if (cell.v === Infinity || cell.v === -Infinity) {
@@ -196,7 +196,8 @@ function handleCellAreaMouseDown(ctx, globalCache, e, cellInput, container, fxIn
196
196
  var doc = parser.parseFromString("<div>".concat((_g = document.getElementById("luckysheet-rich-text-editor")) === null || _g === void 0 ? void 0 : _g.innerHTML, "</div>"), "text/html");
197
197
  var spans = doc.querySelectorAll("span");
198
198
  var firstSpan = spans[0];
199
- if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("="))) {
199
+ var lastSpan = spans[spans.length - 1];
200
+ if (ctx.formulaCache.rangestart || ctx.formulaCache.rangedrag_column_start || ctx.formulaCache.rangedrag_row_start || (0, _modules.israngeseleciton)(ctx) || (firstSpan === null || firstSpan === void 0 ? void 0 : firstSpan.innerText.includes("=")) && !(lastSpan === null || lastSpan === void 0 ? void 0 : lastSpan.innerText.includes(")"))) {
200
201
  var rowseleted = [row_index, row_index_ed];
201
202
  var columnseleted = [col_index, col_index_ed];
202
203
  var left = col_pre;
package/lib/locale/en.js CHANGED
@@ -8690,7 +8690,7 @@ var _default = exports.default = {
8690
8690
  }, {
8691
8691
  n: "SORT",
8692
8692
  t: "14",
8693
- d: "Sorts the rows of a given array or range by the values in a specified column.",
8693
+ d: "Sorts the rows of a given array or range by the values in one or more columns.",
8694
8694
  a: "Sorts rows of range by specified column.",
8695
8695
  m: [1, 4],
8696
8696
  p: [{
@@ -8702,7 +8702,7 @@ var _default = exports.default = {
8702
8702
  type: "rangenumber"
8703
8703
  }, {
8704
8704
  name: "sort_column",
8705
- detail: "The index of the column in `range` to sort by. defaults to the first column. index starts at 1.",
8705
+ detail: "The index of the column in `range` to sort by. The first column in `range` is 1, the second column is 2, and so on.",
8706
8706
  example: "1",
8707
8707
  require: "o",
8708
8708
  repeat: "n",
package/lib/locale/es.js CHANGED
@@ -8680,7 +8680,7 @@ var _default = exports.default = {
8680
8680
  }, {
8681
8681
  n: "SORT",
8682
8682
  t: "14",
8683
- d: "Sorts the rows of a given array or range by the values in a specified column.",
8683
+ d: "Sorts the rows of a given array or range by the values in one or more columns.",
8684
8684
  a: "Sorts rows of range by specified column.",
8685
8685
  m: [1, 4],
8686
8686
  p: [{
@@ -156,6 +156,14 @@ function setCellValue(ctx, r, c, d, v) {
156
156
  } else {
157
157
  vupdate = v;
158
158
  }
159
+ var commaPresent = false;
160
+ if (vupdate && typeof vupdate === "string" && vupdate.includes(",")) {
161
+ commaPresent = vupdate.includes(",");
162
+ var removeCommasValidated = function removeCommasValidated(str) {
163
+ return /^[\d,]+$/.test(str) ? str === null || str === void 0 ? void 0 : str.replace(/,/g, "") : str;
164
+ };
165
+ vupdate = removeCommasValidated(vupdate);
166
+ }
159
167
  if ((0, _validation.isRealNull)(vupdate)) {
160
168
  if (_lodash.default.isPlainObject(cell)) {
161
169
  delete cell.m;
@@ -293,8 +301,18 @@ function setCellValue(ctx, r, c, d, v) {
293
301
  }
294
302
  }
295
303
  cell.v = vupdate;
304
+ var format = void 0;
305
+ if (String(vupdate).includes(".")) {
306
+ format = "#,##0.00";
307
+ } else if (commaPresent) {
308
+ format = "#,##0.00";
309
+ } else {
310
+ format = "0";
311
+ }
312
+ cell.m = (0, _format.update)(format, cell.v);
313
+ cell.ht = 2;
296
314
  cell.ct = {
297
- fa: "General",
315
+ fa: format,
298
316
  t: "n"
299
317
  };
300
318
  if (cell.v === Infinity || cell.v === -Infinity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dev": "father-build --watch"
16
16
  },
17
17
  "dependencies": {
18
- "@fileverse-dev/formula-parser": "0.2.70",
18
+ "@fileverse-dev/formula-parser": "0.2.69",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",