@rowsncolumns/spreadsheet-state 29.1.4 → 29.1.6
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/dist/cjs/api/circular-reference.d.ts +31 -0
- package/dist/cjs/api/circular-reference.d.ts.map +1 -0
- package/dist/cjs/api/circular-reference.js +85 -0
- package/dist/cjs/api/copy-paste.d.ts +6 -0
- package/dist/cjs/api/copy-paste.d.ts.map +1 -1
- package/dist/cjs/api/copy-paste.js +24 -15
- package/dist/cjs/api/datatype.d.ts +2 -0
- package/dist/cjs/api/datatype.d.ts.map +1 -1
- package/dist/cjs/api/datatype.js +50 -27
- package/dist/cjs/api/decimals.d.ts +10 -0
- package/dist/cjs/api/decimals.d.ts.map +1 -1
- package/dist/cjs/api/decimals.js +34 -11
- package/dist/cjs/api/dependency.d.ts +19 -1
- package/dist/cjs/api/dependency.d.ts.map +1 -1
- package/dist/cjs/api/dependency.js +30 -14
- package/dist/cjs/api/filter-condition.d.ts +58 -0
- package/dist/cjs/api/filter-condition.d.ts.map +1 -0
- package/dist/cjs/api/filter-condition.js +157 -0
- package/dist/cjs/api/formula.d.ts.map +1 -1
- package/dist/cjs/api/formula.js +9 -7
- package/dist/cjs/api/image-embed.d.ts +41 -0
- package/dist/cjs/api/image-embed.d.ts.map +1 -0
- package/dist/cjs/api/image-embed.js +55 -0
- package/dist/cjs/api/immer-utils.d.ts.map +1 -1
- package/dist/cjs/api/immer-utils.js +43 -15
- package/dist/cjs/api/named-range-structural.d.ts +29 -3
- package/dist/cjs/api/named-range-structural.d.ts.map +1 -1
- package/dist/cjs/api/named-range-structural.js +36 -11
- package/dist/cjs/api/parse-html.d.ts.map +1 -1
- package/dist/cjs/api/parse-html.js +11 -5
- package/dist/cjs/api/structural-formula-update.d.ts +20 -1
- package/dist/cjs/api/structural-formula-update.d.ts.map +1 -1
- package/dist/cjs/api/structural-formula-update.js +264 -90
- package/dist/cjs/api/structural-guards.d.ts +11 -0
- package/dist/cjs/api/structural-guards.d.ts.map +1 -1
- package/dist/cjs/api/structural-guards.js +45 -1
- package/dist/cjs/api/structural-table-refs.d.ts +15 -2
- package/dist/cjs/api/structural-table-refs.d.ts.map +1 -1
- package/dist/cjs/api/structural-table-refs.js +79 -35
- package/dist/cjs/commands.d.ts +17 -3
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/conditional-format-rule-editor.js +19 -7
- package/dist/cjs/constants.d.ts +4 -1
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +4 -0
- package/dist/cjs/helpers/sheet-title.d.ts +2 -1
- package/dist/cjs/helpers/sheet-title.d.ts.map +1 -1
- package/dist/cjs/helpers/sheet-title.js +3 -1
- package/dist/cjs/hooks/use-can-edit-cellrange.d.ts +1 -1
- package/dist/cjs/hooks/use-can-edit-cellrange.d.ts.map +1 -1
- package/dist/cjs/hooks/use-can-edit-cellrange.js +1 -1
- package/dist/cjs/hooks/use-on-calculation-success.d.ts +5 -1
- package/dist/cjs/hooks/use-on-calculation-success.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-calculation-success.js +20 -3
- package/dist/cjs/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-copy.js +23 -25
- package/dist/cjs/hooks/use-on-create-sheet.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-create-sheet.js +11 -1
- package/dist/cjs/hooks/use-on-delete.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-delete.js +15 -3
- package/dist/cjs/hooks/use-on-drag-n-drop.d.ts +5 -0
- package/dist/cjs/hooks/use-on-drag-n-drop.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-drag-n-drop.js +6 -5
- package/dist/cjs/hooks/use-on-filter-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-filter-table.js +6 -1
- package/dist/cjs/hooks/use-on-find-replace.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-find-replace.js +111 -23
- package/dist/cjs/hooks/use-on-insert-image.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-insert-image.js +20 -33
- package/dist/cjs/hooks/use-on-paste.d.ts +2 -1
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-paste.js +53 -24
- package/dist/cjs/hooks/use-on-rename-sheet.d.ts +3 -1
- package/dist/cjs/hooks/use-on-rename-sheet.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-rename-sheet.js +19 -9
- package/dist/cjs/hooks/use-on-sort-column.d.ts +7 -1
- package/dist/cjs/hooks/use-on-sort-column.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-column.js +25 -8
- package/dist/cjs/hooks/use-on-sort-range.d.ts +16 -2
- package/dist/cjs/hooks/use-on-sort-range.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-range.js +72 -40
- package/dist/cjs/hooks/use-on-sort-table.d.ts +7 -2
- package/dist/cjs/hooks/use-on-sort-table.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-sort-table.js +25 -4
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +5 -3
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +7 -0
- package/dist/cjs/hooks/utils/sort-rows.d.ts +15 -0
- package/dist/cjs/hooks/utils/sort-rows.d.ts.map +1 -1
- package/dist/cjs/hooks/utils/sort-rows.js +16 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/interface/delete-column.d.ts.map +1 -1
- package/dist/cjs/interface/delete-column.js +254 -101
- package/dist/cjs/interface/delete-row.d.ts.map +1 -1
- package/dist/cjs/interface/delete-row.js +233 -81
- package/dist/cjs/interface/duplicate-sheet.d.ts.map +1 -1
- package/dist/cjs/interface/duplicate-sheet.js +4 -9
- package/dist/cjs/interface/insert-column.d.ts.map +1 -1
- package/dist/cjs/interface/insert-column.js +1 -1
- package/dist/cjs/interface/insert-row.d.ts.map +1 -1
- package/dist/cjs/interface/insert-row.js +1 -1
- package/dist/cjs/interface/new-sheet.d.ts.map +1 -1
- package/dist/cjs/interface/new-sheet.js +6 -13
- package/dist/cjs/sheet-cell.d.ts +9 -0
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/sheet-cell.js +46 -9
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/circular-reference.d.ts +31 -0
- package/dist/esm/api/circular-reference.d.ts.map +1 -0
- package/dist/esm/api/circular-reference.js +55 -0
- package/dist/esm/api/copy-paste.d.ts +6 -0
- package/dist/esm/api/copy-paste.d.ts.map +1 -1
- package/dist/esm/api/copy-paste.js +26 -14
- package/dist/esm/api/datatype.d.ts +2 -0
- package/dist/esm/api/datatype.d.ts.map +1 -1
- package/dist/esm/api/datatype.js +50 -27
- package/dist/esm/api/decimals.d.ts +10 -0
- package/dist/esm/api/decimals.d.ts.map +1 -1
- package/dist/esm/api/decimals.js +31 -10
- package/dist/esm/api/dependency.d.ts +19 -1
- package/dist/esm/api/dependency.d.ts.map +1 -1
- package/dist/esm/api/dependency.js +15 -10
- package/dist/esm/api/filter-condition.d.ts +58 -0
- package/dist/esm/api/filter-condition.d.ts.map +1 -0
- package/dist/esm/api/filter-condition.js +146 -0
- package/dist/esm/api/formula.d.ts.map +1 -1
- package/dist/esm/api/formula.js +9 -7
- package/dist/esm/api/image-embed.d.ts +41 -0
- package/dist/esm/api/image-embed.d.ts.map +1 -0
- package/dist/esm/api/image-embed.js +52 -0
- package/dist/esm/api/immer-utils.d.ts.map +1 -1
- package/dist/esm/api/immer-utils.js +43 -14
- package/dist/esm/api/named-range-structural.d.ts +29 -3
- package/dist/esm/api/named-range-structural.d.ts.map +1 -1
- package/dist/esm/api/named-range-structural.js +35 -11
- package/dist/esm/api/parse-html.d.ts.map +1 -1
- package/dist/esm/api/parse-html.js +14 -5
- package/dist/esm/api/structural-formula-update.d.ts +20 -1
- package/dist/esm/api/structural-formula-update.d.ts.map +1 -1
- package/dist/esm/api/structural-formula-update.js +151 -55
- package/dist/esm/api/structural-guards.d.ts +11 -0
- package/dist/esm/api/structural-guards.d.ts.map +1 -1
- package/dist/esm/api/structural-guards.js +31 -0
- package/dist/esm/api/structural-table-refs.d.ts +15 -2
- package/dist/esm/api/structural-table-refs.d.ts.map +1 -1
- package/dist/esm/api/structural-table-refs.js +49 -18
- package/dist/esm/commands.d.ts +17 -3
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/conditional-format-rule-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/conditional-format-rule-editor.js +18 -7
- package/dist/esm/constants.d.ts +4 -1
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +4 -0
- package/dist/esm/helpers/sheet-title.d.ts +2 -1
- package/dist/esm/helpers/sheet-title.d.ts.map +1 -1
- package/dist/esm/helpers/sheet-title.js +3 -1
- package/dist/esm/hooks/use-can-edit-cellrange.d.ts +1 -1
- package/dist/esm/hooks/use-can-edit-cellrange.d.ts.map +1 -1
- package/dist/esm/hooks/use-can-edit-cellrange.js +1 -1
- package/dist/esm/hooks/use-on-calculation-success.d.ts +5 -1
- package/dist/esm/hooks/use-on-calculation-success.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-calculation-success.js +19 -3
- package/dist/esm/hooks/use-on-copy.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-copy.js +17 -17
- package/dist/esm/hooks/use-on-create-sheet.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-create-sheet.js +11 -1
- package/dist/esm/hooks/use-on-delete.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-delete.js +15 -3
- package/dist/esm/hooks/use-on-drag-n-drop.d.ts +5 -0
- package/dist/esm/hooks/use-on-drag-n-drop.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-drag-n-drop.js +7 -4
- package/dist/esm/hooks/use-on-filter-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-filter-table.js +13 -2
- package/dist/esm/hooks/use-on-find-replace.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-find-replace.js +111 -23
- package/dist/esm/hooks/use-on-insert-image.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-insert-image.js +15 -25
- package/dist/esm/hooks/use-on-paste.d.ts +2 -1
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-paste.js +46 -15
- package/dist/esm/hooks/use-on-rename-sheet.d.ts +3 -1
- package/dist/esm/hooks/use-on-rename-sheet.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-rename-sheet.js +19 -9
- package/dist/esm/hooks/use-on-sort-column.d.ts +7 -1
- package/dist/esm/hooks/use-on-sort-column.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-column.js +18 -1
- package/dist/esm/hooks/use-on-sort-range.d.ts +16 -2
- package/dist/esm/hooks/use-on-sort-range.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-range.js +30 -3
- package/dist/esm/hooks/use-on-sort-table.d.ts +7 -2
- package/dist/esm/hooks/use-on-sort-table.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-sort-table.js +25 -4
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +5 -3
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +7 -0
- package/dist/esm/hooks/utils/sort-rows.d.ts +15 -0
- package/dist/esm/hooks/utils/sort-rows.d.ts.map +1 -1
- package/dist/esm/hooks/utils/sort-rows.js +15 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/interface/delete-column.d.ts.map +1 -1
- package/dist/esm/interface/delete-column.js +111 -80
- package/dist/esm/interface/delete-row.d.ts.map +1 -1
- package/dist/esm/interface/delete-row.js +91 -59
- package/dist/esm/interface/duplicate-sheet.d.ts.map +1 -1
- package/dist/esm/interface/duplicate-sheet.js +4 -9
- package/dist/esm/interface/insert-column.d.ts.map +1 -1
- package/dist/esm/interface/insert-column.js +1 -1
- package/dist/esm/interface/insert-row.d.ts.map +1 -1
- package/dist/esm/interface/insert-row.js +1 -1
- package/dist/esm/interface/new-sheet.d.ts.map +1 -1
- package/dist/esm/interface/new-sheet.js +6 -13
- package/dist/esm/sheet-cell.d.ts +9 -0
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/sheet-cell.js +46 -7
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** A formula cell the engine stamped as a member of a circular reference. */
|
|
2
|
+
export type CircularReferenceCell = {
|
|
3
|
+
sheetId: number;
|
|
4
|
+
rowIndex: number;
|
|
5
|
+
columnIndex: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const CIRCULAR_REFERENCE_WARNING_TITLE = "Circular Reference";
|
|
8
|
+
/** Excel's circular-reference warning (iterative calculation off: the cells display 0). */
|
|
9
|
+
export declare const CIRCULAR_REFERENCE_WARNING = "There are one or more circular references where a formula refers to its own cell either directly or indirectly. This might cause them to calculate incorrectly. Try removing or changing these references, or moving the formulas to different cells.";
|
|
10
|
+
/**
|
|
11
|
+
* The warning text for a batch of newly circular cells: Excel's sentence plus the addresses so the
|
|
12
|
+
* user can find them (`Sheet2!N20` when the workbook has more than one sheet).
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatCircularReferenceWarning: (cells: readonly CircularReferenceCell[], getSheetName?: (sheetId: number) => string | undefined, qualifySheet?: boolean) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Excel warns ONCE when a circular reference appears, not on every recalculation of the loop —
|
|
17
|
+
* this tracks the cells already warned about so a batch only surfaces the NEW ones. A tracked
|
|
18
|
+
* cell is forgotten when a later batch recalculates it without stamping it circular (the loop
|
|
19
|
+
* was broken), so re-creating the loop warns again.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CircularReferenceTracker {
|
|
22
|
+
private readonly known;
|
|
23
|
+
/**
|
|
24
|
+
* @param circular the cells this batch stamped circular
|
|
25
|
+
* @param recalculated every cell this batch recomputed (optional — without it, a broken loop is
|
|
26
|
+
* never forgotten, so the same cell warns once per tracker lifetime)
|
|
27
|
+
* @returns the circular cells not warned about before
|
|
28
|
+
*/
|
|
29
|
+
next(circular: readonly CircularReferenceCell[] | undefined, recalculated?: Iterable<CircularReferenceCell>): CircularReferenceCell[];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=circular-reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circular-reference.d.ts","sourceRoot":"","sources":["../../../api/circular-reference.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gCAAgC,uBAAuB,CAAC;AAErE,2FAA2F;AAC3F,eAAO,MAAM,0BAA0B,0PACkN,CAAC;AAO1P;;;GAGG;AACH,eAAO,MAAM,8BAA8B,GACzC,OAAO,SAAS,qBAAqB,EAAE,EACvC,eAAe,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EACtD,sBAAoB,WAUrB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAE3C;;;;;OAKG;IACH,IAAI,CACF,QAAQ,EAAE,SAAS,qBAAqB,EAAE,GAAG,SAAS,EACtD,YAAY,CAAC,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAC7C,qBAAqB,EAAE;CAoB3B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
import { cellToAddress } from "@rowsncolumns/utils";
|
|
3
|
+
export var CIRCULAR_REFERENCE_WARNING_TITLE = "Circular Reference";
|
|
4
|
+
/** Excel's circular-reference warning (iterative calculation off: the cells display 0). */
|
|
5
|
+
export var CIRCULAR_REFERENCE_WARNING = "There are one or more circular references where a formula refers to its own cell either directly or indirectly. This might cause them to calculate incorrectly. Try removing or changing these references, or moving the formulas to different cells.";
|
|
6
|
+
var MAX_LISTED_CELLS = 8;
|
|
7
|
+
var cellKey = function (cell) {
|
|
8
|
+
return "".concat(cell.sheetId, ":").concat(cell.rowIndex, ":").concat(cell.columnIndex);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The warning text for a batch of newly circular cells: Excel's sentence plus the addresses so the
|
|
12
|
+
* user can find them (`Sheet2!N20` when the workbook has more than one sheet).
|
|
13
|
+
*/
|
|
14
|
+
export var formatCircularReferenceWarning = function (cells, getSheetName, qualifySheet) {
|
|
15
|
+
if (qualifySheet === void 0) { qualifySheet = false; }
|
|
16
|
+
var addresses = cells.slice(0, MAX_LISTED_CELLS).map(function (cell) {
|
|
17
|
+
var _a;
|
|
18
|
+
var address = (_a = cellToAddress(cell)) !== null && _a !== void 0 ? _a : "R".concat(cell.rowIndex, "C").concat(cell.columnIndex);
|
|
19
|
+
var sheetName = qualifySheet ? getSheetName === null || getSheetName === void 0 ? void 0 : getSheetName(cell.sheetId) : undefined;
|
|
20
|
+
return sheetName ? "".concat(sheetName, "!").concat(address) : address;
|
|
21
|
+
});
|
|
22
|
+
var more = cells.length - addresses.length;
|
|
23
|
+
var list = more > 0 ? "".concat(addresses.join(", "), " and ").concat(more, " more") : addresses.join(", ");
|
|
24
|
+
return list ? "".concat(CIRCULAR_REFERENCE_WARNING, "\n\nCircular references: ").concat(list) : CIRCULAR_REFERENCE_WARNING;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Excel warns ONCE when a circular reference appears, not on every recalculation of the loop —
|
|
28
|
+
* this tracks the cells already warned about so a batch only surfaces the NEW ones. A tracked
|
|
29
|
+
* cell is forgotten when a later batch recalculates it without stamping it circular (the loop
|
|
30
|
+
* was broken), so re-creating the loop warns again.
|
|
31
|
+
*/
|
|
32
|
+
var CircularReferenceTracker = /** @class */ (function () {
|
|
33
|
+
function CircularReferenceTracker() {
|
|
34
|
+
this.known = new Set();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param circular the cells this batch stamped circular
|
|
38
|
+
* @param recalculated every cell this batch recomputed (optional — without it, a broken loop is
|
|
39
|
+
* never forgotten, so the same cell warns once per tracker lifetime)
|
|
40
|
+
* @returns the circular cells not warned about before
|
|
41
|
+
*/
|
|
42
|
+
CircularReferenceTracker.prototype.next = function (circular, recalculated) {
|
|
43
|
+
var e_1, _a, e_2, _b;
|
|
44
|
+
var stamped = new Set((circular !== null && circular !== void 0 ? circular : []).map(cellKey));
|
|
45
|
+
if (recalculated && this.known.size) {
|
|
46
|
+
try {
|
|
47
|
+
for (var recalculated_1 = __values(recalculated), recalculated_1_1 = recalculated_1.next(); !recalculated_1_1.done; recalculated_1_1 = recalculated_1.next()) {
|
|
48
|
+
var cell = recalculated_1_1.value;
|
|
49
|
+
var key = cellKey(cell);
|
|
50
|
+
if (!stamped.has(key)) {
|
|
51
|
+
this.known.delete(key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (recalculated_1_1 && !recalculated_1_1.done && (_a = recalculated_1.return)) _a.call(recalculated_1);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e_1) throw e_1.error; }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
var fresh = [];
|
|
64
|
+
try {
|
|
65
|
+
for (var _c = __values(circular !== null && circular !== void 0 ? circular : []), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
66
|
+
var cell = _d.value;
|
|
67
|
+
var key = cellKey(cell);
|
|
68
|
+
if (!this.known.has(key)) {
|
|
69
|
+
this.known.add(key);
|
|
70
|
+
fresh.push(cell);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
75
|
+
finally {
|
|
76
|
+
try {
|
|
77
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
78
|
+
}
|
|
79
|
+
finally { if (e_2) throw e_2.error; }
|
|
80
|
+
}
|
|
81
|
+
return fresh;
|
|
82
|
+
};
|
|
83
|
+
return CircularReferenceTracker;
|
|
84
|
+
}());
|
|
85
|
+
export { CircularReferenceTracker };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CellInterface, GridRange } from "@rowsncolumns/common-types";
|
|
2
2
|
import type { CellData, EmbeddedObject, TableView } from "@rowsncolumns/spreadsheet";
|
|
3
3
|
import type { UseSpreadsheetProps } from "../hooks/use-spreadsheet-state";
|
|
4
|
+
import { type ImageViewport } from "./image-embed";
|
|
4
5
|
export type ClipBoardFormat = "text/html" | "text/csv" | "text/plain" | "application/json" | "image/apng" | "image/bmp" | "image/gif" | "image/jpeg" | "image/pjpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon";
|
|
5
6
|
export declare const SUPPORTED_IMAGE_TYPES: string[];
|
|
6
7
|
export declare const generateDataFromClipboard: <T extends CellData>(e: ClipboardEvent | undefined, activeCell: CellInterface, sheetId: number, activeSheetName: string, preserveFormatting?: boolean, locale?: string, idCreationStrategy?: UseSpreadsheetProps<T>["idCreationStrategy"], forcePlainText?: boolean, sanitizeHtml?: (html: string) => string, options?: {
|
|
@@ -10,6 +11,11 @@ export declare const generateDataFromClipboard: <T extends CellData>(e: Clipboar
|
|
|
10
11
|
* only repoints references INTO the moved block, which the consumer does itself.
|
|
11
12
|
*/
|
|
12
13
|
relocateFormulas?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The visible grid area (`CanvasGrid.getSheetDimensions()`): a pasted image FILE becomes a
|
|
16
|
+
* floating picture at its natural size, scaled down to fit this viewport (Excel / Sheets).
|
|
17
|
+
*/
|
|
18
|
+
imageViewport?: ImageViewport | null;
|
|
13
19
|
}) => Promise<{
|
|
14
20
|
results?: (CellData | null | undefined)[][];
|
|
15
21
|
merges?: GridRange[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-paste.d.ts","sourceRoot":"","sources":["../../../api/copy-paste.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,SAAS,EAEV,MAAM,2BAA2B,CAAC;AAcnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"copy-paste.d.ts","sourceRoot":"","sources":["../../../api/copy-paste.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,SAAS,EAEV,MAAM,2BAA2B,CAAC;AAcnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAS1E,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGrE,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,UAAU,GACV,YAAY,GACZ,kBAAkB,GAClB,YAAY,GACZ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,aAAa,GACb,WAAW,GACX,eAAe,GACf,YAAY,GACZ,YAAY,GACZ,cAAc,CAAC;AAEnB,eAAO,MAAM,qBAAqB,UAWjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,CAAC,SAAS,QAAQ,EAChE,GAAG,cAAc,GAAG,SAAS,EAC7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AAE,EAC7C,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,yCAwBhB;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7D,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,EAAE,KACnD,MAAM,EAmBR,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { uuid } from "@rowsncolumns/utils";
|
|
|
5
5
|
import { defaultCellCoords, defaultSheetId, isStyleReference, SheetCell, } from "../sheet-cell";
|
|
6
6
|
import { isRichSharedString } from "../types";
|
|
7
7
|
import { isBoolean, isValidURLorEmail } from "./datatype";
|
|
8
|
+
import { createImageEmbed } from "./image-embed";
|
|
8
9
|
import { parseHtml } from "./parse-html";
|
|
9
10
|
export var SUPPORTED_IMAGE_TYPES = [
|
|
10
11
|
"image/apng",
|
|
@@ -19,7 +20,7 @@ export var SUPPORTED_IMAGE_TYPES = [
|
|
|
19
20
|
"image/x-icon",
|
|
20
21
|
];
|
|
21
22
|
export var generateDataFromClipboard = function (e, activeCell, sheetId, activeSheetName, preserveFormatting, locale, idCreationStrategy, forcePlainText, sanitizeHtml, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
22
|
-
var items, files, formatOrder, plainTextValue, isFormula, format,
|
|
23
|
+
var items, files, formatOrder, plainTextValue, isFormula, format, embeds, filesArray, filesArray_1, filesArray_1_1, file, _a, imageUrl, width, height, e_1_1, clipboardValue, sheetCell, clipboard, isPlainTextOnly, _b, parsed, sheetData, tables, cellXfs, parsedSharedStrings, sharedStrings_1, tables_1, tables_1_1, table, rowDelta, colDelta, rowSpan, colSpan, merges_1, cellXfsMap_1, results, itemsArray, itemsArray_1, itemsArray_1_1, item, e_2_1, results, results;
|
|
23
24
|
var e_1, _c, e_3, _d, e_2, _e;
|
|
24
25
|
var _f, _g, _h, _j, _k, _l, _m;
|
|
25
26
|
return __generator(this, function (_o) {
|
|
@@ -39,7 +40,7 @@ export var generateDataFromClipboard = function (e, activeCell, sheetId, activeS
|
|
|
39
40
|
? "text/plain"
|
|
40
41
|
: formatOrder.find(function (type) { var _a; return (_a = e === null || e === void 0 ? void 0 : e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData(type); });
|
|
41
42
|
if (!((files === null || files === void 0 ? void 0 : files.length) && !format)) return [3 /*break*/, 9];
|
|
42
|
-
|
|
43
|
+
embeds = [];
|
|
43
44
|
filesArray = Array.from(files);
|
|
44
45
|
_o.label = 1;
|
|
45
46
|
case 1:
|
|
@@ -54,12 +55,16 @@ export var generateDataFromClipboard = function (e, activeCell, sheetId, activeS
|
|
|
54
55
|
}
|
|
55
56
|
return [4 /*yield*/, readImageFileAsDataUri(file)];
|
|
56
57
|
case 3:
|
|
57
|
-
_a = __read.apply(void 0, [_o.sent(),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
_a = __read.apply(void 0, [_o.sent(), 3]), imageUrl = _a[0], width = _a[1], height = _a[2];
|
|
59
|
+
embeds.push(createImageEmbed({
|
|
60
|
+
sheetId: sheetId,
|
|
61
|
+
anchorCell: activeCell,
|
|
62
|
+
imageUrl: imageUrl,
|
|
63
|
+
width: width,
|
|
64
|
+
height: height,
|
|
65
|
+
viewport: options === null || options === void 0 ? void 0 : options.imageViewport,
|
|
66
|
+
idCreationStrategy: idCreationStrategy,
|
|
67
|
+
}));
|
|
63
68
|
_o.label = 4;
|
|
64
69
|
case 4:
|
|
65
70
|
filesArray_1_1 = filesArray_1.next();
|
|
@@ -76,7 +81,8 @@ export var generateDataFromClipboard = function (e, activeCell, sheetId, activeS
|
|
|
76
81
|
finally { if (e_1) throw e_1.error; }
|
|
77
82
|
return [7 /*endfinally*/];
|
|
78
83
|
case 8: return [2 /*return*/, {
|
|
79
|
-
results:
|
|
84
|
+
results: [],
|
|
85
|
+
embeds: embeds,
|
|
80
86
|
}];
|
|
81
87
|
case 9:
|
|
82
88
|
if (!items || !format) {
|
|
@@ -252,13 +258,16 @@ export var generateDataFromClipboard = function (e, activeCell, sheetId, activeS
|
|
|
252
258
|
results = clipboardValue.split("\n").map(function (cellValues) {
|
|
253
259
|
return cellValues.split("\t").map(function (value) {
|
|
254
260
|
var trimmedValue = value.trim();
|
|
255
|
-
var isFormula = isAFormula(trimmedValue);
|
|
256
261
|
var isEmptyValue = trimmedValue.length === 0;
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
+
// A pasted `=…` cell is classified exactly like the same text typed into the cell
|
|
263
|
+
// (Excel / Google Sheets parse `=`-prefixed plain text as formulas; a `'=` quote
|
|
264
|
+
// prefix keeps it text, as when typing). Only an explicit "paste as plain text"
|
|
265
|
+
// request (Ctrl/Cmd+Shift+V) forces formulas, booleans (prevent coercion) and URLs
|
|
266
|
+
// (prevent auto-linking) to text.
|
|
267
|
+
var needsTextPrefix = forcePlainText &&
|
|
268
|
+
(isAFormula(trimmedValue) ||
|
|
269
|
+
isBoolean(trimmedValue) ||
|
|
270
|
+
isValidURLorEmail(trimmedValue));
|
|
262
271
|
var shouldForceText = isPlainTextOnly &&
|
|
263
272
|
!isEmptyValue &&
|
|
264
273
|
needsTextPrefix &&
|
|
@@ -5,6 +5,8 @@ export declare const pattern_percent = "0%";
|
|
|
5
5
|
export declare const pattern_percent_decimal = "0.00%";
|
|
6
6
|
export declare const pattern_currency = "\"$\"#,##0_);(\"$\"#,##0)";
|
|
7
7
|
export declare const pattern_currency_decimal = "\"$\"#,##0.00_);(\"$\"#,##0.00)";
|
|
8
|
+
export declare const pattern_comma = "_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)";
|
|
9
|
+
export declare const pattern_comma_rounded = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_);_(@_)";
|
|
8
10
|
export declare const date_pattern = "mm/dd/yyyy";
|
|
9
11
|
export declare const time_pattern_base = "hh:mm:ss";
|
|
10
12
|
export declare const time_pattern = "hh:mm:ss AM/PM";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datatype.d.ts","sourceRoot":"","sources":["../../../api/datatype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAYnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"datatype.d.ts","sourceRoot":"","sources":["../../../api/datatype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAYnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA2BlE,MAAM,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAM/C,eAAO,MAAM,gBAAgB,8BAA0B,CAAC;AACxD,eAAO,MAAM,wBAAwB,oCAAgC,CAAC;AAItE,eAAO,MAAM,aAAa,sDAAoD,CAAC;AAC/E,eAAO,MAAM,qBAAqB,gDAA8C,CAAC;AACjF,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAC5C,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAC7C,eAAO,MAAM,kBAAkB,eAAe,CAAC;AA6V/C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EACnD,SAAS,MAAM,EACf,yBAAsB,YAUvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,YAKnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO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MAAM,GAAG,SA0CX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,iBAAiB,EACxB,QAAQ,MAAM,GAAG,SAAS,EAC1B,yBAAsB,KACrB,SAkBF,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EACnD,QAAQ,MAAM,GAAG,SAAS,EAC1B,yBAAsB,EACtB,UAAU,OAAO,KAChB,CACD,WAAW,EAAE,MAAM,aAAa,EAChC,aAAa,CAAC,EAAE,gBAAgB,EAChC,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,CA8GjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,iBAAiB,EACxB,WAAW,SAAS,GAAG,SAAS,EAChC,SAAS,MAAM,EACf,SAAS,MAAM,WAOhB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,iBAAiB,EACxB,WAAW,SAAS,GAAG,SAAS,EAChC,SAAS,MAAM,KACd,MAAM,GAAG,SAMX,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,YAEnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,OAe/C,CAAC"}
|
package/dist/cjs/api/datatype.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __values } from "tslib";
|
|
2
2
|
import { getDefaultDateFormat, getDefaultDateTimeFormat, isAFormula, isNil, ssfFormat, ssfFormatColor, toDate, toSerial, } from "@rowsncolumns/utils";
|
|
3
3
|
import { detectDateFormatPattern, detectDateTimeFormatPattern, isValidDate, isValidDateTime, toTimeSerial, validateDate, validateDateTime, } from "./date";
|
|
4
|
-
import { detectDecimalPattern } from "./decimals";
|
|
4
|
+
import { changeDecimals, detectDecimalPattern, getDecimalPlaces, hasThousandsGrouping, pattern_number_thousands, } from "./decimals";
|
|
5
5
|
import { buildGroupRegex, getGroupingInfo, getLocaleDigitMap, getLocaleSeparators, getPercentSignInfo, getSignInfo, } from "./intl";
|
|
6
6
|
export var pattern_percent = "0%";
|
|
7
7
|
export var pattern_percent_decimal = "0.00%";
|
|
@@ -12,6 +12,11 @@ export var pattern_percent_decimal = "0.00%";
|
|
|
12
12
|
// Excel renders the workbook identically to one it produced itself.
|
|
13
13
|
export var pattern_currency = '"$"#,##0_);("$"#,##0)';
|
|
14
14
|
export var pattern_currency_decimal = '"$"#,##0.00_);("$"#,##0.00)';
|
|
15
|
+
// Excel's built-in "Comma Style" / "Comma [0]" cell styles (numFmtId 43 / 41):
|
|
16
|
+
// accounting layout without a currency symbol — negatives in parentheses,
|
|
17
|
+
// zero as `-`, padded so the digits align in a column. Neither is red.
|
|
18
|
+
export var pattern_comma = '_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)';
|
|
19
|
+
export var pattern_comma_rounded = '_(* #,##0_);_(* (#,##0);_(* "-"??_);_(@_)';
|
|
15
20
|
export var date_pattern = "mm/dd/yyyy";
|
|
16
21
|
export var time_pattern_base = "hh:mm:ss";
|
|
17
22
|
export var time_pattern = "hh:mm:ss AM/PM";
|
|
@@ -491,6 +496,33 @@ export var detectNumberFormatType = function (value, locale, lenientGrouping) {
|
|
|
491
496
|
return "DATE_TIME";
|
|
492
497
|
}
|
|
493
498
|
};
|
|
499
|
+
/**
|
|
500
|
+
* Currency base pattern for a typed literal: the detected symbol in the position it was typed
|
|
501
|
+
* (`$30` → `"$"#,##0`, `12,50 €` → `#,##0"€"`), defaulting to a `$` prefix.
|
|
502
|
+
*/
|
|
503
|
+
var currencyBasePattern = function (value) {
|
|
504
|
+
var currencyInfo = extractCurrencySymbol(String(value));
|
|
505
|
+
var symbol = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.symbol) || "$";
|
|
506
|
+
var position = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.position) || "prefix";
|
|
507
|
+
return position === "suffix" ? "#,##0\"".concat(symbol, "\"") : "\"".concat(symbol, "\"#,##0");
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Currency / percent pattern whose decimal places are the ones the user TYPED
|
|
511
|
+
* (`$1,234.50` → `"$"#,##0.00`, `50.00%` → `0.00%`), not the parsed number's (`1234.5` → one
|
|
512
|
+
* place), so trailing zeros survive like in Excel. The base already carries the symbol and
|
|
513
|
+
* grouping, so only the decimals are appended. Ports Rust `detect_decimal_pattern_typed`; both
|
|
514
|
+
* `detectValueTypeAndPattern` (typed cell entry) and `detectNumberFormatPattern` go through it
|
|
515
|
+
* so the two never disagree on the same literal.
|
|
516
|
+
*/
|
|
517
|
+
var detectTypedDecimalPattern = function (value, numberValue, basePattern, locale) {
|
|
518
|
+
// A JS number carries no typed digits; its own decimal expansion is the best we have (a
|
|
519
|
+
// percent's `numberValue` is already /100, so it must not be the source for a numeric input).
|
|
520
|
+
var typed = typeof value === "string" || typeof value === "number"
|
|
521
|
+
? value
|
|
522
|
+
: numberValue !== null && numberValue !== void 0 ? numberValue : 0;
|
|
523
|
+
var decimalsLen = getDecimalPlaces(typed, locale);
|
|
524
|
+
return decimalsLen ? changeDecimals(basePattern, decimalsLen, true) : basePattern;
|
|
525
|
+
};
|
|
494
526
|
/**
|
|
495
527
|
* Detect pattern of a number format
|
|
496
528
|
* @param type
|
|
@@ -499,16 +531,10 @@ export var detectNumberFormatType = function (value, locale, lenientGrouping) {
|
|
|
499
531
|
export var detectNumberFormatPattern = function (value, numberValue, type, locale, use1904) {
|
|
500
532
|
var _a, _b;
|
|
501
533
|
if (type === "PERCENT") {
|
|
502
|
-
return
|
|
534
|
+
return detectTypedDecimalPattern(value, numberValue, pattern_percent, locale);
|
|
503
535
|
}
|
|
504
536
|
if (type === "CURRENCY") {
|
|
505
|
-
|
|
506
|
-
var currencyInfo = extractCurrencySymbol(String(value));
|
|
507
|
-
var symbol = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.symbol) || "$";
|
|
508
|
-
var position = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.position) || "prefix";
|
|
509
|
-
// Create a pattern with the detected currency symbol in the correct position
|
|
510
|
-
var baseCurrencyPattern = position === "suffix" ? "#,##0\"".concat(symbol, "\"") : "\"".concat(symbol, "\"#,##0");
|
|
511
|
-
return detectDecimalPattern(numberValue, baseCurrencyPattern, locale);
|
|
537
|
+
return detectTypedDecimalPattern(value, numberValue, currencyBasePattern(value), locale);
|
|
512
538
|
}
|
|
513
539
|
if (type === "DATE") {
|
|
514
540
|
return (_a = detectDateFormatPattern(value, locale)) !== null && _a !== void 0 ? _a : date_pattern;
|
|
@@ -517,17 +543,20 @@ export var detectNumberFormatPattern = function (value, numberValue, type, local
|
|
|
517
543
|
return (_b = detectDateTimeFormatPattern(value)) !== null && _b !== void 0 ? _b : time_pattern;
|
|
518
544
|
}
|
|
519
545
|
if (type === "NUMBER") {
|
|
520
|
-
//
|
|
521
|
-
// `
|
|
522
|
-
//
|
|
523
|
-
//
|
|
524
|
-
//
|
|
525
|
-
//
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
546
|
+
// Excel leaves a General cell General for a plain number — `5`, `5.25`,
|
|
547
|
+
// `1.50`, `0.0000123` all display through General (`1.5`, `1.23E-05`)
|
|
548
|
+
// and stamp nothing, so a later entry in the same cell is never rounded
|
|
549
|
+
// through an inferred `#` / `#.00`. Only a thousands-grouped literal
|
|
550
|
+
// (`1,000`, `1,234.56`) is a formatting cue: it stamps `#,##0` plus the
|
|
551
|
+
// typed decimal places, and that stamp then sticks like any other format
|
|
552
|
+
// (Excel shows `0` for a later `0.25`). This rule is specific to the
|
|
553
|
+
// implicit NUMBER format; explicit CURRENCY / PERCENT formats keep their
|
|
554
|
+
// own base pattern (handled above), so `$0` stays `"$"#,##0`.
|
|
555
|
+
if (typeof value === "string" &&
|
|
556
|
+
hasThousandsGrouping(value, locale, numberValue)) {
|
|
557
|
+
return detectDecimalPattern(value, pattern_number_thousands, locale);
|
|
529
558
|
}
|
|
530
|
-
return
|
|
559
|
+
return "General";
|
|
531
560
|
}
|
|
532
561
|
return undefined;
|
|
533
562
|
};
|
|
@@ -590,18 +619,12 @@ export var detectValueTypeAndPattern = function (value, locale, lenientGrouping,
|
|
|
590
619
|
}
|
|
591
620
|
// Check currency
|
|
592
621
|
if (isCurr) {
|
|
593
|
-
|
|
594
|
-
var currencyInfo = extractCurrencySymbol(String(value));
|
|
595
|
-
var symbol = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.symbol) || "$";
|
|
596
|
-
var position = (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.position) || "prefix";
|
|
597
|
-
// Create a pattern with the detected currency symbol in the correct position
|
|
598
|
-
var baseCurrencyPattern = position === "suffix" ? "#,##0\"".concat(symbol, "\"") : "\"".concat(symbol, "\"#,##0");
|
|
599
|
-
var pattern = detectDecimalPattern(numberValue, baseCurrencyPattern, locale);
|
|
622
|
+
var pattern = detectTypedDecimalPattern(value, numberValue, currencyBasePattern(value), locale);
|
|
600
623
|
return ["numberValue", "CURRENCY", numberValue, pattern];
|
|
601
624
|
}
|
|
602
625
|
// Numbers can be number, percent, date, datetime
|
|
603
626
|
if (isPercentage(value, locale, lenientGrouping)) {
|
|
604
|
-
var pattern =
|
|
627
|
+
var pattern = detectTypedDecimalPattern(value, numberValue, pattern_percent, locale);
|
|
605
628
|
var percentValue = convertToNumber(value, locale, lenientGrouping) / 100;
|
|
606
629
|
return ["numberValue", "PERCENT", percentValue, pattern];
|
|
607
630
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export declare const pattern_number = "#";
|
|
2
2
|
export declare const pattern_number_thousands = "#,##0";
|
|
3
3
|
export declare const getDecimalPlaces: (value: string | number, locale?: string) => number;
|
|
4
|
+
/**
|
|
5
|
+
* Whether a typed literal groups its integer part with the locale's thousands
|
|
6
|
+
* separator (`1,000` / `1,234.56` in en-US, `1.234,56` in de-DE, `1 234` in
|
|
7
|
+
* fr-FR). In a comma-decimal locale a canonical dot-decimal string (`1.234`)
|
|
8
|
+
* is ambiguous — the programmatic decimal 1.234, or the grouped 1234 — so when
|
|
9
|
+
* the caller knows what the literal parsed to (`parsedValue`) that decides;
|
|
10
|
+
* without it the canonical reading wins, so the locale's `.` group separator
|
|
11
|
+
* is not mistaken for grouping. Rust `has_thousands_grouping`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const hasThousandsGrouping: (value: string | number, locale?: string, parsedValue?: number) => boolean;
|
|
4
14
|
export declare const detectDecimalPattern: (value: string | number | boolean | Date | undefined, defaultPattern?: string, locale?: string) => string;
|
|
5
15
|
export declare const changeDecimals: (pattern?: string | undefined, changeBy?: number, delta?: boolean) => string;
|
|
6
16
|
export declare const getCurrentDecimalCountInPattern: (pattern?: string | undefined | null) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimals.d.ts","sourceRoot":"","sources":["../../../api/decimals.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAyDhD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,MAAM,GAAG,MAAM,EACtB,SAAS,MAAM,KACd,MAsCF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EACnD,uBAA+B,EAC/B,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"decimals.d.ts","sourceRoot":"","sources":["../../../api/decimals.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAyDhD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,MAAM,GAAG,MAAM,EACtB,SAAS,MAAM,KACd,MAsCF,CAAC;AAcF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,GAAG,MAAM,EACtB,SAAS,MAAM,EACf,cAAc,MAAM,KACnB,OAeF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EACnD,uBAA+B,EAC/B,SAAS,MAAM,WAsBhB,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,UAAS,MAAM,GAAG,SAAc,EAChC,WAAU,MAAU,EACpB,eAAY,WAuCb,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,UAAS,MAAM,GAAG,SAAS,GAAG,IAAS,WAexC,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,UAAS,MAAM,GAAG,SAAc,WAwBpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,UAAS,MAAM,GAAG,SAAc,WAQvE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAS,MAAM,GAAG,SAAc,YAIrE,CAAC"}
|
package/dist/cjs/api/decimals.js
CHANGED
|
@@ -76,20 +76,43 @@ export var getDecimalPlaces = function (value, locale) {
|
|
|
76
76
|
// Return the length of the decimal part
|
|
77
77
|
return decimalPart.length;
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
var WHITESPACE_GROUP_REGEX = /[\s\u00A0\u202F]/;
|
|
80
|
+
/**
|
|
81
|
+
* Whether `integerPart` contains the locale's group separator. Locales that
|
|
82
|
+
* group with a space accept the whole whitespace family (regular, no-break,
|
|
83
|
+
* narrow no-break) — users type a plain space for fr-FR's `\u202F`.
|
|
84
|
+
*/
|
|
85
|
+
var integerPartHasGroup = function (integerPart, group) {
|
|
86
|
+
return group.trim() === ""
|
|
87
|
+
? WHITESPACE_GROUP_REGEX.test(integerPart)
|
|
88
|
+
: integerPart.includes(group);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Whether a typed literal groups its integer part with the locale's thousands
|
|
92
|
+
* separator (`1,000` / `1,234.56` in en-US, `1.234,56` in de-DE, `1 234` in
|
|
93
|
+
* fr-FR). In a comma-decimal locale a canonical dot-decimal string (`1.234`)
|
|
94
|
+
* is ambiguous — the programmatic decimal 1.234, or the grouped 1234 — so when
|
|
95
|
+
* the caller knows what the literal parsed to (`parsedValue`) that decides;
|
|
96
|
+
* without it the canonical reading wins, so the locale's `.` group separator
|
|
97
|
+
* is not mistaken for grouping. Rust `has_thousands_grouping`.
|
|
98
|
+
*/
|
|
99
|
+
export var hasThousandsGrouping = function (value, locale, parsedValue) {
|
|
100
|
+
var str = typeof value === "number" ? normalizeFloatingPointString(value) : value;
|
|
82
101
|
var _a = getLocaleSeparators(locale), decimal = _a.decimal, group = _a.group;
|
|
83
102
|
var groupSeparator = group !== null && group !== void 0 ? group : ",";
|
|
84
103
|
var decimalSeparator = decimal !== null && decimal !== void 0 ? decimal : ".";
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
if (decimalSeparator !== "." && CANONICAL_DOT_DECIMAL_REGEX.test(str)) {
|
|
105
|
+
return (parsedValue !== undefined &&
|
|
106
|
+
Number(str) !== parsedValue &&
|
|
107
|
+
integerPartHasGroup(str, groupSeparator));
|
|
108
|
+
}
|
|
109
|
+
var integerPart = str.split(decimalSeparator)[0];
|
|
110
|
+
return Boolean(groupSeparator) && integerPartHasGroup(integerPart, groupSeparator);
|
|
111
|
+
};
|
|
112
|
+
export var detectDecimalPattern = function (value, defaultPattern, locale) {
|
|
113
|
+
if (defaultPattern === void 0) { defaultPattern = pattern_number; }
|
|
114
|
+
var str = typeof value === "number" ? normalizeFloatingPointString(value) : String(value);
|
|
115
|
+
var hasThousands = hasThousandsGrouping(str, locale);
|
|
93
116
|
var decimalsLen = getDecimalPlaces(value, locale);
|
|
94
117
|
// Use "0" pattern for numbers less than 1 to ensure leading zero
|
|
95
118
|
var numValue = Number(str.replace(/[^0-9.-]/g, ""));
|
|
@@ -38,7 +38,17 @@ export declare const collectUniqueDependentsForRange: <T extends CellData>(param
|
|
|
38
38
|
rowIndex: number;
|
|
39
39
|
columnIndex: number;
|
|
40
40
|
}>;
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* One reference shift of a structural edit: the references inside `sourceRange` move by the
|
|
43
|
+
* deltas, those inside `deletedRange` break to `#REF!`.
|
|
44
|
+
*/
|
|
45
|
+
export type FormulaMoveStep = {
|
|
46
|
+
rowDelta: number;
|
|
47
|
+
columnDelta: number;
|
|
48
|
+
sourceRange?: GridRange;
|
|
49
|
+
deletedRange?: GridRange;
|
|
50
|
+
};
|
|
51
|
+
export declare const moveFormulaAtPosition: <T extends CellData>({ draft, position, destinationSheetId, activeSheetName, enqueueCalculation, enqueueGraphOperation, recalcCells, movedKeys, rowDelta, columnDelta, sourceRange, deletedRange, steps, destinationPosition, locale, rowCount, columnCount, cellXfsRegistry, sharedStringRegistry, }: {
|
|
42
52
|
draft: Draft<SheetData<T>>;
|
|
43
53
|
position: {
|
|
44
54
|
sheetId: number;
|
|
@@ -56,6 +66,14 @@ export declare const moveFormulaAtPosition: <T extends CellData>({ draft, positi
|
|
|
56
66
|
sourceRange?: GridRange;
|
|
57
67
|
/** Cells removed by a delete-cells shift — references into it become `#REF!` (SHF-09). */
|
|
58
68
|
deletedRange?: GridRange;
|
|
69
|
+
/**
|
|
70
|
+
* Several shifts applied to the formula text in order, one per deleted band of a
|
|
71
|
+
* non-contiguous delete (Ctrl-selected rows 2 and 4): each step shifts the references inside
|
|
72
|
+
* its own `sourceRange` by its delta and breaks those inside its `deletedRange`. Replaces the
|
|
73
|
+
* single `rowDelta` / `columnDelta` / `sourceRange` / `deletedRange` shift when given; pass
|
|
74
|
+
* `destinationPosition` with it (the cell's own move is not any single step's delta).
|
|
75
|
+
*/
|
|
76
|
+
steps?: FormulaMoveStep[];
|
|
59
77
|
/**
|
|
60
78
|
* Where the formula cell itself ends up. Defaults to `position + delta` (the cell moves with the
|
|
61
79
|
* shift). A dependent OUTSIDE the shifted band keeps its place while its references into the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency.d.ts","sourceRoot":"","sources":["../../../api/dependency.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIrD,KAAK,0BAA0B,CAAC,CAAC,SAAS,QAAQ,IAAI;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,aAAa,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,eAAe,CAAC,CAAC;IAClE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,kBAAkB,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC7E,qBAAqB,CAAC,EAAE,UAAU,CAChC,OAAO,cAAc,CACtB,CAAC,uBAAuB,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,C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AAc,CACtB,CAAC,uBAAuB,CAAC,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC/C,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C,SA6FA,CAAC"}
|
|
@@ -232,29 +232,45 @@ export var collectUniqueDependentsForRange = function (params) {
|
|
|
232
232
|
};
|
|
233
233
|
// Process a single formula move at a specific position with the specified deltas.
|
|
234
234
|
export var moveFormulaAtPosition = function (_a) {
|
|
235
|
-
var
|
|
236
|
-
var
|
|
235
|
+
var e_3, _b;
|
|
236
|
+
var _c, _d, _e, _f;
|
|
237
|
+
var draft = _a.draft, position = _a.position, destinationSheetId = _a.destinationSheetId, activeSheetName = _a.activeSheetName, enqueueCalculation = _a.enqueueCalculation, enqueueGraphOperation = _a.enqueueGraphOperation, recalcCells = _a.recalcCells, movedKeys = _a.movedKeys, _g = _a.rowDelta, rowDelta = _g === void 0 ? 0 : _g, _h = _a.columnDelta, columnDelta = _h === void 0 ? 0 : _h, sourceRange = _a.sourceRange, deletedRange = _a.deletedRange, steps = _a.steps, destinationPosition = _a.destinationPosition, locale = _a.locale, rowCount = _a.rowCount, columnCount = _a.columnCount, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry;
|
|
237
238
|
var sheetCell = new SheetCell();
|
|
238
239
|
var currentSheet = createSheetDraft(draft, position.sheetId, position.rowIndex);
|
|
239
|
-
var cellData = (
|
|
240
|
+
var cellData = (_d = (_c = currentSheet[position.rowIndex]) === null || _c === void 0 ? void 0 : _c.values) === null || _d === void 0 ? void 0 : _d[position.columnIndex];
|
|
240
241
|
sheetCell.assign(position.sheetId, { rowIndex: position.rowIndex, columnIndex: position.columnIndex }, cellData, { locale: locale, cellXfsRegistry: cellXfsRegistry, sharedStringRegistry: sharedStringRegistry });
|
|
241
242
|
if (!movedKeys.has(sheetCell.key) && sheetCell.isFormula()) {
|
|
242
243
|
movedKeys.add(sheetCell.key);
|
|
243
244
|
var previousFormula = sheetCell.formula;
|
|
244
|
-
var newRowIndex = (
|
|
245
|
-
var newColumnIndex = (
|
|
245
|
+
var newRowIndex = (_e = destinationPosition === null || destinationPosition === void 0 ? void 0 : destinationPosition.rowIndex) !== null && _e !== void 0 ? _e : position.rowIndex + rowDelta;
|
|
246
|
+
var newColumnIndex = (_f = destinationPosition === null || destinationPosition === void 0 ? void 0 : destinationPosition.columnIndex) !== null && _f !== void 0 ? _f : position.columnIndex + columnDelta;
|
|
246
247
|
var resolvedSheetName = activeSheetName !== null && activeSheetName !== void 0 ? activeSheetName : "";
|
|
247
248
|
// The delta is applied to the references inside `sourceRange`; the formula cell's own
|
|
248
249
|
// destination (for the graph re-key) may differ when it does not move itself.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
var moves = steps !== null && steps !== void 0 ? steps : [
|
|
251
|
+
{ rowDelta: rowDelta, columnDelta: columnDelta, sourceRange: sourceRange, deletedRange: deletedRange },
|
|
252
|
+
];
|
|
253
|
+
try {
|
|
254
|
+
for (var moves_1 = __values(moves), moves_1_1 = moves_1.next(); !moves_1_1.done; moves_1_1 = moves_1.next()) {
|
|
255
|
+
var move = moves_1_1.value;
|
|
256
|
+
sheetCell.moveFormula({ rowIndex: position.rowIndex, columnIndex: position.columnIndex }, {
|
|
257
|
+
rowIndex: position.rowIndex + move.rowDelta,
|
|
258
|
+
columnIndex: position.columnIndex + move.columnDelta,
|
|
259
|
+
}, resolvedSheetName, {
|
|
260
|
+
exclusionRange: move.sourceRange,
|
|
261
|
+
deletedRange: move.deletedRange,
|
|
262
|
+
rowCount: rowCount,
|
|
263
|
+
columnCount: columnCount,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
268
|
+
finally {
|
|
269
|
+
try {
|
|
270
|
+
if (moves_1_1 && !moves_1_1.done && (_b = moves_1.return)) _b.call(moves_1);
|
|
271
|
+
}
|
|
272
|
+
finally { if (e_3) throw e_3.error; }
|
|
273
|
+
}
|
|
258
274
|
if (previousFormula !== sheetCell.formula) {
|
|
259
275
|
// Set cell data at old position (formula updated prior to structural move)
|
|
260
276
|
currentSheet[position.rowIndex].values[position.columnIndex] =
|