@rowsncolumns/spreadsheet 10.2.73 → 10.2.75
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/evaluate-formula.d.ts +17 -0
- package/dist/cjs/api/evaluate-formula.d.ts.map +1 -0
- package/dist/cjs/api/evaluate-formula.js +141 -0
- package/dist/cjs/api/excel-validation-kinds.d.ts +71 -0
- package/dist/cjs/api/excel-validation-kinds.d.ts.map +1 -0
- package/dist/cjs/api/excel-validation-kinds.js +304 -0
- package/dist/cjs/api/go-to-special.d.ts +32 -0
- package/dist/cjs/api/go-to-special.d.ts.map +1 -0
- package/dist/cjs/api/go-to-special.js +111 -0
- package/dist/cjs/api/go-to.d.ts +19 -0
- package/dist/cjs/api/go-to.d.ts.map +1 -0
- package/dist/cjs/api/go-to.js +49 -0
- package/dist/cjs/api/validation-tooltip.d.ts +17 -0
- package/dist/cjs/api/validation-tooltip.d.ts.map +1 -0
- package/dist/cjs/api/validation-tooltip.js +42 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts +28 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/advanced-filter-dialog.atom.js +32 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.d.ts +36 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/evaluate-formula-dialog.atom.js +36 -0
- package/dist/cjs/atoms/go-to-dialog.atom.d.ts +46 -0
- package/dist/cjs/atoms/go-to-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/go-to-dialog.atom.js +34 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts +29 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/goal-seek-dialog.atom.js +30 -0
- package/dist/cjs/atoms/index.d.ts +5 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +5 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.d.ts +29 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/paste-special-dialog.atom.js +34 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.d.ts +45 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/remove-duplicates-dialog.atom.js +37 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.d.ts +39 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/subtotal-dialog.atom.js +30 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts +34 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/text-to-columns-dialog.atom.js +36 -0
- package/dist/cjs/atoms/watch-window.atom.d.ts +37 -0
- package/dist/cjs/atoms/watch-window.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/watch-window.atom.js +61 -0
- package/dist/cjs/components/advanced-filter-dialog/index.d.ts +28 -0
- package/dist/cjs/components/advanced-filter-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/advanced-filter-dialog/index.js +134 -0
- package/dist/cjs/components/calculation-options-dialog/index.d.ts +33 -0
- package/dist/cjs/components/calculation-options-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/calculation-options-dialog/index.js +69 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +208 -19
- package/dist/cjs/components/canvas-grid/typings.d.ts +72 -9
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.d.ts +30 -0
- package/dist/cjs/components/cell/alignment.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.js +56 -1
- package/dist/cjs/components/cell/index.d.ts.map +1 -1
- package/dist/cjs/components/cell/index.js +15 -7
- package/dist/cjs/components/cell-diff/index.d.ts +3 -2
- package/dist/cjs/components/cell-diff/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.js +2 -1
- package/dist/cjs/components/context-menu/index.d.ts +21 -3
- package/dist/cjs/components/context-menu/index.d.ts.map +1 -1
- package/dist/cjs/components/context-menu/index.js +256 -6
- package/dist/cjs/components/context-menu/total-row-functions.d.ts +32 -0
- package/dist/cjs/components/context-menu/total-row-functions.d.ts.map +1 -0
- package/dist/cjs/components/context-menu/total-row-functions.js +62 -0
- package/dist/cjs/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/cjs/components/embeds/embed-component.js +16 -1
- package/dist/cjs/components/evaluate-formula-dialog/index.d.ts +34 -0
- package/dist/cjs/components/evaluate-formula-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/evaluate-formula-dialog/index.js +106 -0
- package/dist/cjs/components/go-to-dialog/index.d.ts +45 -0
- package/dist/cjs/components/go-to-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/go-to-dialog/index.js +136 -0
- package/dist/cjs/components/goal-seek-dialog/index.d.ts +32 -0
- package/dist/cjs/components/goal-seek-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/goal-seek-dialog/index.js +149 -0
- package/dist/cjs/components/paste-special-dialog/index.d.ts +29 -0
- package/dist/cjs/components/paste-special-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/paste-special-dialog/index.js +99 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.d.ts +37 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/remove-duplicates-dialog/index.js +91 -0
- package/dist/cjs/components/subtotal-dialog/index.d.ts +30 -0
- package/dist/cjs/components/subtotal-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/subtotal-dialog/index.js +126 -0
- package/dist/cjs/components/text-to-columns-dialog/index.d.ts +37 -0
- package/dist/cjs/components/text-to-columns-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/text-to-columns-dialog/index.js +166 -0
- package/dist/cjs/components/toolbar/background-color-selector.d.ts +13 -1
- package/dist/cjs/components/toolbar/background-color-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/background-color-selector.js +57 -11
- package/dist/cjs/components/toolbar/cell-style-selector.d.ts +15 -2
- package/dist/cjs/components/toolbar/cell-style-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/cell-style-selector.js +56 -3
- package/dist/cjs/components/toolbar/fill-selectors.d.ts +49 -0
- package/dist/cjs/components/toolbar/fill-selectors.d.ts.map +1 -0
- package/dist/cjs/components/toolbar/fill-selectors.js +196 -0
- package/dist/cjs/components/toolbar/index.d.ts +2 -0
- package/dist/cjs/components/toolbar/index.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/index.js +2 -0
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/text-horizontal-align-selector.js +23 -4
- package/dist/cjs/components/toolbar/text-rotation-selector.d.ts +29 -0
- package/dist/cjs/components/toolbar/text-rotation-selector.d.ts.map +1 -0
- package/dist/cjs/components/toolbar/text-rotation-selector.js +78 -0
- package/dist/cjs/components/toolbar/text-wrap-selector.d.ts +7 -1
- package/dist/cjs/components/toolbar/text-wrap-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/text-wrap-selector.js +10 -3
- package/dist/cjs/components/watch-window/index.d.ts +25 -0
- package/dist/cjs/components/watch-window/index.d.ts.map +1 -0
- package/dist/cjs/components/watch-window/index.js +63 -0
- package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-cell-renderer.js +17 -6
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts +20 -1
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/cjs/hooks/use-copy-paste-cut.js +25 -20
- package/dist/cjs/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/cjs/hooks/use-get-tooltip.js +7 -2
- package/dist/cjs/hooks/use-keyboard-handler.d.ts +17 -2
- package/dist/cjs/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/cjs/hooks/use-keyboard-handler.js +206 -31
- package/dist/cjs/index.d.ts +14 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +15 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +289 -4
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +19 -1
- package/dist/esm/api/evaluate-formula.d.ts +17 -0
- package/dist/esm/api/evaluate-formula.d.ts.map +1 -0
- package/dist/esm/api/evaluate-formula.js +109 -0
- package/dist/esm/api/excel-validation-kinds.d.ts +71 -0
- package/dist/esm/api/excel-validation-kinds.d.ts.map +1 -0
- package/dist/esm/api/excel-validation-kinds.js +287 -0
- package/dist/esm/api/go-to-special.d.ts +32 -0
- package/dist/esm/api/go-to-special.d.ts.map +1 -0
- package/dist/esm/api/go-to-special.js +96 -0
- package/dist/esm/api/go-to.d.ts +19 -0
- package/dist/esm/api/go-to.d.ts.map +1 -0
- package/dist/esm/api/go-to.js +41 -0
- package/dist/esm/api/validation-tooltip.d.ts +17 -0
- package/dist/esm/api/validation-tooltip.d.ts.map +1 -0
- package/dist/esm/api/validation-tooltip.js +34 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts +28 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/advanced-filter-dialog.atom.js +21 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.d.ts +36 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/evaluate-formula-dialog.atom.js +25 -0
- package/dist/esm/atoms/go-to-dialog.atom.d.ts +46 -0
- package/dist/esm/atoms/go-to-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/go-to-dialog.atom.js +25 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.d.ts +29 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/goal-seek-dialog.atom.js +21 -0
- package/dist/esm/atoms/index.d.ts +5 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +5 -0
- package/dist/esm/atoms/paste-special-dialog.atom.d.ts +29 -0
- package/dist/esm/atoms/paste-special-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/paste-special-dialog.atom.js +25 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.d.ts +45 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/remove-duplicates-dialog.atom.js +26 -0
- package/dist/esm/atoms/subtotal-dialog.atom.d.ts +39 -0
- package/dist/esm/atoms/subtotal-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/subtotal-dialog.atom.js +21 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts +34 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.d.ts.map +1 -0
- package/dist/esm/atoms/text-to-columns-dialog.atom.js +25 -0
- package/dist/esm/atoms/watch-window.atom.d.ts +37 -0
- package/dist/esm/atoms/watch-window.atom.d.ts.map +1 -0
- package/dist/esm/atoms/watch-window.atom.js +37 -0
- package/dist/esm/components/advanced-filter-dialog/index.d.ts +28 -0
- package/dist/esm/components/advanced-filter-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/advanced-filter-dialog/index.js +125 -0
- package/dist/esm/components/calculation-options-dialog/index.d.ts +33 -0
- package/dist/esm/components/calculation-options-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/calculation-options-dialog/index.js +61 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +202 -19
- package/dist/esm/components/canvas-grid/typings.d.ts +72 -9
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.d.ts +30 -0
- package/dist/esm/components/cell/alignment.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.js +51 -0
- package/dist/esm/components/cell/index.d.ts.map +1 -1
- package/dist/esm/components/cell/index.js +16 -8
- package/dist/esm/components/cell-diff/index.d.ts +3 -2
- package/dist/esm/components/cell-diff/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.js +2 -1
- package/dist/esm/components/context-menu/index.d.ts +21 -3
- package/dist/esm/components/context-menu/index.d.ts.map +1 -1
- package/dist/esm/components/context-menu/index.js +251 -9
- package/dist/esm/components/context-menu/total-row-functions.d.ts +32 -0
- package/dist/esm/components/context-menu/total-row-functions.d.ts.map +1 -0
- package/dist/esm/components/context-menu/total-row-functions.js +50 -0
- package/dist/esm/components/embeds/embed-component.d.ts.map +1 -1
- package/dist/esm/components/embeds/embed-component.js +17 -1
- package/dist/esm/components/evaluate-formula-dialog/index.d.ts +34 -0
- package/dist/esm/components/evaluate-formula-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/evaluate-formula-dialog/index.js +86 -0
- package/dist/esm/components/go-to-dialog/index.d.ts +45 -0
- package/dist/esm/components/go-to-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/go-to-dialog/index.js +124 -0
- package/dist/esm/components/goal-seek-dialog/index.d.ts +32 -0
- package/dist/esm/components/goal-seek-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/goal-seek-dialog/index.js +125 -0
- package/dist/esm/components/paste-special-dialog/index.d.ts +29 -0
- package/dist/esm/components/paste-special-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/paste-special-dialog/index.js +90 -0
- package/dist/esm/components/remove-duplicates-dialog/index.d.ts +37 -0
- package/dist/esm/components/remove-duplicates-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/remove-duplicates-dialog/index.js +82 -0
- package/dist/esm/components/subtotal-dialog/index.d.ts +30 -0
- package/dist/esm/components/subtotal-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/subtotal-dialog/index.js +115 -0
- package/dist/esm/components/text-to-columns-dialog/index.d.ts +37 -0
- package/dist/esm/components/text-to-columns-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/text-to-columns-dialog/index.js +147 -0
- package/dist/esm/components/toolbar/background-color-selector.d.ts +13 -1
- package/dist/esm/components/toolbar/background-color-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/background-color-selector.js +61 -11
- package/dist/esm/components/toolbar/cell-style-selector.d.ts +15 -2
- package/dist/esm/components/toolbar/cell-style-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/cell-style-selector.js +46 -2
- package/dist/esm/components/toolbar/fill-selectors.d.ts +49 -0
- package/dist/esm/components/toolbar/fill-selectors.d.ts.map +1 -0
- package/dist/esm/components/toolbar/fill-selectors.js +162 -0
- package/dist/esm/components/toolbar/index.d.ts +2 -0
- package/dist/esm/components/toolbar/index.d.ts.map +1 -1
- package/dist/esm/components/toolbar/index.js +2 -0
- package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts +8 -0
- package/dist/esm/components/toolbar/text-horizontal-align-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/text-horizontal-align-selector.js +21 -5
- package/dist/esm/components/toolbar/text-rotation-selector.d.ts +29 -0
- package/dist/esm/components/toolbar/text-rotation-selector.d.ts.map +1 -0
- package/dist/esm/components/toolbar/text-rotation-selector.js +71 -0
- package/dist/esm/components/toolbar/text-wrap-selector.d.ts +7 -1
- package/dist/esm/components/toolbar/text-wrap-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/text-wrap-selector.js +10 -3
- package/dist/esm/components/watch-window/index.d.ts +25 -0
- package/dist/esm/components/watch-window/index.d.ts.map +1 -0
- package/dist/esm/components/watch-window/index.js +54 -0
- package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-cell-renderer.js +17 -6
- package/dist/esm/hooks/use-copy-paste-cut.d.ts +20 -1
- package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/esm/hooks/use-copy-paste-cut.js +8 -3
- package/dist/esm/hooks/use-get-tooltip.d.ts.map +1 -1
- package/dist/esm/hooks/use-get-tooltip.js +7 -2
- package/dist/esm/hooks/use-keyboard-handler.d.ts +17 -2
- package/dist/esm/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/esm/hooks/use-keyboard-handler.js +193 -31
- package/dist/esm/index.d.ts +14 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +13 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +289 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +18 -0
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EvaluationValue } from "@rowsncolumns/calculator";
|
|
2
|
+
import type { CellInterface } from "@rowsncolumns/grid";
|
|
3
|
+
import type { CanvasGridProps } from "../components/canvas-grid/typings";
|
|
4
|
+
/** `ERROR.TYPE` result → Excel error literal. */
|
|
5
|
+
export declare const ERROR_TYPE_CODES: Record<number, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Build the Evaluate Formula stepper's `evaluate` from the grid's
|
|
8
|
+
* `onRequestCalculate` (the cell editor's live-preview calculator — a
|
|
9
|
+
* read-only scratch evaluation in both engines). A string result is
|
|
10
|
+
* re-typed through the engine (see `retypeDisplayText`); a `FormulaError`
|
|
11
|
+
* instance (unwrapped reference calculator) becomes the error literal; the
|
|
12
|
+
* wrapped calculators report a formula error as an empty result, so a blank
|
|
13
|
+
* answer is re-asked as `ERROR.TYPE(expression)` to recover the error
|
|
14
|
+
* literal and a genuine blank stays `null`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createExpressionEvaluator: (onRequestCalculate: NonNullable<CanvasGridProps["onRequestCalculate"]>, sheetId: number, cell: CellInterface) => (expression: string) => Promise<EvaluationValue>;
|
|
17
|
+
//# sourceMappingURL=evaluate-formula.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-formula.d.ts","sourceRoot":"","sources":["../../../api/evaluate-formula.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASnD,CAAC;AAiFF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,GACpC,oBAAoB,WAAW,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,EACtE,SAAS,MAAM,EACf,MAAM,aAAa,MAIL,YAAY,MAAM,KAAG,OAAO,CAAC,eAAe,CAkB3D,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExpressionEvaluator = exports.ERROR_TYPE_CODES = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/** `ERROR.TYPE` result → Excel error literal. */
|
|
6
|
+
exports.ERROR_TYPE_CODES = {
|
|
7
|
+
1: "#NULL!",
|
|
8
|
+
2: "#DIV/0!",
|
|
9
|
+
3: "#VALUE!",
|
|
10
|
+
4: "#REF!",
|
|
11
|
+
5: "#NAME?",
|
|
12
|
+
6: "#NUM!",
|
|
13
|
+
7: "#N/A",
|
|
14
|
+
8: "#GETTING_DATA",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The error code of a `FormulaError`-shaped result (the unwrapped reference
|
|
18
|
+
* `useCalculation().onRequestCalculate` returns the error instance rather
|
|
19
|
+
* than throwing; the wrapped calculators return `undefined`). Duck-typed like
|
|
20
|
+
* the wrapper's `isFormulaErrorLike` so no parser import is needed here.
|
|
21
|
+
*/
|
|
22
|
+
var formulaErrorCode = function (value) {
|
|
23
|
+
if (!(value instanceof Error))
|
|
24
|
+
return undefined;
|
|
25
|
+
var code = value.error;
|
|
26
|
+
return typeof code === "string" && code.startsWith("#") ? code : undefined;
|
|
27
|
+
};
|
|
28
|
+
var toEvaluationValue = function (result) {
|
|
29
|
+
var error = formulaErrorCode(result);
|
|
30
|
+
if (error)
|
|
31
|
+
return { error: error };
|
|
32
|
+
if (Array.isArray(result)) {
|
|
33
|
+
return result.map(function (row) {
|
|
34
|
+
return Array.isArray(row)
|
|
35
|
+
? row.map(function (cell) { return toEvaluationValue(cell); })
|
|
36
|
+
: [toEvaluationValue(row)];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (result === null ||
|
|
40
|
+
result === undefined ||
|
|
41
|
+
typeof result === "string" ||
|
|
42
|
+
typeof result === "number" ||
|
|
43
|
+
typeof result === "boolean" ||
|
|
44
|
+
result instanceof Date) {
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
return String(result);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* `onRequestCalculate` is the cell editor's live preview, so it reports
|
|
51
|
+
* DISPLAY text: the rnc engine stringifies numbers and booleans, the
|
|
52
|
+
* reference wrapper returns the formatted value (`1,234.50`, `$5.00`,
|
|
53
|
+
* `TRUE`). Substituting that text verbatim would turn `=A1=15` into
|
|
54
|
+
* `"15"=15` (FALSE) or `"1,234.50"*2` (#VALUE!), so the text is re-typed
|
|
55
|
+
* through the engine itself: `TYPE(expression)` says number / text /
|
|
56
|
+
* boolean, and a number is re-read as General text (`&""` keeps both probes
|
|
57
|
+
* clear of the cell's number format) so it parses back to a number.
|
|
58
|
+
*/
|
|
59
|
+
var retypeDisplayText = function (text, expression, calculate) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
60
|
+
var typeCode, _a, direct, general, parsed, upper, numeric;
|
|
61
|
+
return tslib_1.__generator(this, function (_b) {
|
|
62
|
+
switch (_b.label) {
|
|
63
|
+
case 0: return [4 /*yield*/, calculate("=TYPE(".concat(expression, ")&\"\""))];
|
|
64
|
+
case 1:
|
|
65
|
+
typeCode = _b.sent();
|
|
66
|
+
_a = typeof typeCode === "string" ? typeCode.trim() : typeCode;
|
|
67
|
+
switch (_a) {
|
|
68
|
+
case "1": return [3 /*break*/, 2];
|
|
69
|
+
case 1: return [3 /*break*/, 2];
|
|
70
|
+
case "4": return [3 /*break*/, 4];
|
|
71
|
+
case 4: return [3 /*break*/, 4];
|
|
72
|
+
}
|
|
73
|
+
return [3 /*break*/, 6];
|
|
74
|
+
case 2:
|
|
75
|
+
direct = Number(text);
|
|
76
|
+
if (Number.isFinite(direct) && text.trim() !== "")
|
|
77
|
+
return [2 /*return*/, direct];
|
|
78
|
+
return [4 /*yield*/, calculate("=(".concat(expression, ")&\"\""))];
|
|
79
|
+
case 3:
|
|
80
|
+
general = _b.sent();
|
|
81
|
+
parsed = Number(typeof general === "string" ? general : NaN);
|
|
82
|
+
return [2 /*return*/, Number.isFinite(parsed) ? parsed : text];
|
|
83
|
+
case 4:
|
|
84
|
+
upper = text.trim().toUpperCase();
|
|
85
|
+
if (upper === "TRUE")
|
|
86
|
+
return [2 /*return*/, true];
|
|
87
|
+
if (upper === "FALSE")
|
|
88
|
+
return [2 /*return*/, false];
|
|
89
|
+
return [4 /*yield*/, calculate("=--(".concat(expression, ")&\"\""))];
|
|
90
|
+
case 5:
|
|
91
|
+
numeric = _b.sent();
|
|
92
|
+
return [2 /*return*/, typeof numeric === "string" ? numeric.trim() === "1" : text];
|
|
93
|
+
case 6: return [2 /*return*/, text];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}); };
|
|
97
|
+
/**
|
|
98
|
+
* Build the Evaluate Formula stepper's `evaluate` from the grid's
|
|
99
|
+
* `onRequestCalculate` (the cell editor's live-preview calculator — a
|
|
100
|
+
* read-only scratch evaluation in both engines). A string result is
|
|
101
|
+
* re-typed through the engine (see `retypeDisplayText`); a `FormulaError`
|
|
102
|
+
* instance (unwrapped reference calculator) becomes the error literal; the
|
|
103
|
+
* wrapped calculators report a formula error as an empty result, so a blank
|
|
104
|
+
* answer is re-asked as `ERROR.TYPE(expression)` to recover the error
|
|
105
|
+
* literal and a genuine blank stays `null`.
|
|
106
|
+
*/
|
|
107
|
+
var createExpressionEvaluator = function (onRequestCalculate, sheetId, cell) {
|
|
108
|
+
var calculate = function (formula) {
|
|
109
|
+
return onRequestCalculate(formula, sheetId, cell.rowIndex, cell.columnIndex);
|
|
110
|
+
};
|
|
111
|
+
return function (expression) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var value, _a, errorType, code;
|
|
113
|
+
return tslib_1.__generator(this, function (_b) {
|
|
114
|
+
switch (_b.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
_a = toEvaluationValue;
|
|
117
|
+
return [4 /*yield*/, calculate("=".concat(expression))];
|
|
118
|
+
case 1:
|
|
119
|
+
value = _a.apply(void 0, [_b.sent()]);
|
|
120
|
+
if (typeof value === "string") {
|
|
121
|
+
return [2 /*return*/, retypeDisplayText(value, expression, calculate)];
|
|
122
|
+
}
|
|
123
|
+
if (value !== null && value !== undefined)
|
|
124
|
+
return [2 /*return*/, value];
|
|
125
|
+
return [4 /*yield*/, calculate("=ERROR.TYPE(".concat(expression, ")&\"\""))];
|
|
126
|
+
case 2:
|
|
127
|
+
errorType = _b.sent();
|
|
128
|
+
code = typeof errorType === "number"
|
|
129
|
+
? errorType
|
|
130
|
+
: typeof errorType === "string"
|
|
131
|
+
? Number(errorType)
|
|
132
|
+
: NaN;
|
|
133
|
+
if (exports.ERROR_TYPE_CODES[code]) {
|
|
134
|
+
return [2 /*return*/, { error: exports.ERROR_TYPE_CODES[code] }];
|
|
135
|
+
}
|
|
136
|
+
return [2 /*return*/, null];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); };
|
|
140
|
+
};
|
|
141
|
+
exports.createExpressionEvaluator = createExpressionEvaluator;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { DataValidationRule, SheetRange } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Excel's data-validation "Allow" kinds that have no `ConditionType` of
|
|
4
|
+
* their own. Each is authored as Excel's `type` + `operator` + up to two
|
|
5
|
+
* formulas and stored two ways at once:
|
|
6
|
+
*
|
|
7
|
+
* - `condition` — what both engines evaluate for the red Invalid marker:
|
|
8
|
+
* `whole` and `textLength` compose a `CUSTOM_FORMULA` over the range
|
|
9
|
+
* anchor (the same shape both importers synthesize), `time` is a plain
|
|
10
|
+
* `NUMBER_*` comparison over day-fraction serials;
|
|
11
|
+
* - `xlsxSource` — the Excel-native description both xlsx exporters replay
|
|
12
|
+
* verbatim (`type="whole"` …), so the rule round-trips as what the user
|
|
13
|
+
* picked instead of a decimal / custom rule.
|
|
14
|
+
*
|
|
15
|
+
* Imported rules already carry `xlsxSource`, so the editor reads them back
|
|
16
|
+
* as "Whole number between 1 and 10" rather than a custom formula.
|
|
17
|
+
*/
|
|
18
|
+
export type ExcelValidationKind = "whole" | "time" | "textLength";
|
|
19
|
+
export type ExcelValidationOperator = "between" | "notBetween" | "equal" | "notEqual" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual";
|
|
20
|
+
export type ExcelValidationSpec = {
|
|
21
|
+
kind: ExcelValidationKind;
|
|
22
|
+
operator: ExcelValidationOperator;
|
|
23
|
+
/** Bound(s) as the user typed them: a literal (`10`, `9:30 AM`) or `=ref`. */
|
|
24
|
+
formula1?: string;
|
|
25
|
+
formula2?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare const EXCEL_VALIDATION_KIND_LABELS: ReadonlyArray<{
|
|
28
|
+
kind: ExcelValidationKind;
|
|
29
|
+
label: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const EXCEL_VALIDATION_OPERATOR_LABELS: ReadonlyArray<{
|
|
32
|
+
operator: ExcelValidationOperator;
|
|
33
|
+
label: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Two-sided operators need both bounds. */
|
|
36
|
+
export declare const isTwoSidedOperator: (operator: ExcelValidationOperator) => operator is "between" | "notBetween";
|
|
37
|
+
/**
|
|
38
|
+
* Parse a typed time (`9:30`, `9:30 AM`, `21:05:10`, `24:00`, `0.5`) to
|
|
39
|
+
* Excel's serial. A bare non-negative number is taken as a serial already and
|
|
40
|
+
* kept whole (Excel's Time validation compares the full serial, so a
|
|
41
|
+
* date-time is out of a same-day range). `undefined` when unparsable.
|
|
42
|
+
*/
|
|
43
|
+
export declare const parseTimeToSerial: (text: string | undefined) => number | undefined;
|
|
44
|
+
/** Render a day-fraction serial as `h:mm AM/PM` (seconds when non-zero). */
|
|
45
|
+
export declare const formatTimeSerial: (serial: number) => string;
|
|
46
|
+
/** The A1 anchor (range top-left) a relative custom formula is written against. */
|
|
47
|
+
export declare const getValidationAnchor: (range: SheetRange | undefined) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Build the `condition` + `xlsxSource` pair for an Excel kind. Returns
|
|
50
|
+
* `undefined` when a required bound is missing (the editor keeps the form
|
|
51
|
+
* open in that case).
|
|
52
|
+
*/
|
|
53
|
+
export declare const buildExcelValidationRule: (spec: ExcelValidationSpec, anchor: string) => Pick<DataValidationRule, "condition" | "xlsxSource"> | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Read an Excel kind back from a rule's `xlsxSource` (imported or authored
|
|
56
|
+
* here); `undefined` for every other rule. Time bounds come back as
|
|
57
|
+
* `h:mm AM/PM` text so the editor shows what the user would type.
|
|
58
|
+
*/
|
|
59
|
+
export declare const readExcelValidationSpec: (rule: Pick<DataValidationRule, "xlsxSource"> | undefined | null) => ExcelValidationSpec | undefined;
|
|
60
|
+
/** A typed value that is a formula (`=…`) — validated on its result, not its text. */
|
|
61
|
+
export declare const isFormulaEntry: (value: unknown) => value is string;
|
|
62
|
+
/**
|
|
63
|
+
* Decide an Excel-kind rule for a freshly typed value without the
|
|
64
|
+
* calculator — the commit-time enforcement Excel applies (`stop` blocks a
|
|
65
|
+
* decimal in a whole-number cell). `undefined` when the bounds are
|
|
66
|
+
* formulas / references, or when the typed value is itself a formula
|
|
67
|
+
* (Excel validates the formula's RESULT after the recalc, so `=5` is a
|
|
68
|
+
* valid whole number), so the caller falls back to the flag-only marker.
|
|
69
|
+
*/
|
|
70
|
+
export declare const checkExcelValidationValue: (rule: Pick<DataValidationRule, "xlsxSource"> | undefined | null, value: string | boolean) => boolean | undefined;
|
|
71
|
+
//# sourceMappingURL=excel-validation-kinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"excel-validation-kinds.d.ts","sourceRoot":"","sources":["../../../api/excel-validation-kinds.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,kBAAkB,EAClB,UAAU,EACX,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAAC;AAElE,MAAM,MAAM,uBAAuB,GAC/B,SAAS,GACT,YAAY,GACZ,OAAO,GACP,UAAU,GACV,aAAa,GACb,UAAU,GACV,oBAAoB,GACpB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAAa,CAAC;IACvD,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAIA,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,aAAa,CAAC;IAC3D,QAAQ,EAAE,uBAAuB,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,CASA,CAAC;AAOF,4CAA4C;AAC5C,eAAO,MAAM,kBAAkB,GAAI,UAAU,uBAAuB,yCACf,CAAC;AAwBtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,GAAG,SAAS,KACvB,MAAM,GAAG,SAuBX,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAUjD,CAAC;AAoBF,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,GAAI,OAAO,UAAU,GAAG,SAAS,KAAG,MAKzD,CAAC;AAgCZ;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,mBAAmB,EACzB,QAAQ,MAAM,KACb,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAiDzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,SAAS,GAAG,IAAI,KAC9D,mBAAmB,GAAG,SAuBxB,CAAC;AAmCF,sFAAsF;AACtF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACE,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,SAAS,GAAG,IAAI,EAC/D,OAAO,MAAM,GAAG,OAAO,KACtB,OAAO,GAAG,SAmCZ,CAAC"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkExcelValidationValue = exports.isFormulaEntry = exports.readExcelValidationSpec = exports.buildExcelValidationRule = exports.getValidationAnchor = exports.formatTimeSerial = exports.parseTimeToSerial = exports.isTwoSidedOperator = exports.EXCEL_VALIDATION_OPERATOR_LABELS = exports.EXCEL_VALIDATION_KIND_LABELS = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var utils_1 = require("@rowsncolumns/utils");
|
|
6
|
+
exports.EXCEL_VALIDATION_KIND_LABELS = [
|
|
7
|
+
{ kind: "whole", label: "Whole number" },
|
|
8
|
+
{ kind: "time", label: "Time" },
|
|
9
|
+
{ kind: "textLength", label: "Text length" },
|
|
10
|
+
];
|
|
11
|
+
exports.EXCEL_VALIDATION_OPERATOR_LABELS = [
|
|
12
|
+
{ operator: "between", label: "between" },
|
|
13
|
+
{ operator: "notBetween", label: "not between" },
|
|
14
|
+
{ operator: "equal", label: "equal to" },
|
|
15
|
+
{ operator: "notEqual", label: "not equal to" },
|
|
16
|
+
{ operator: "greaterThan", label: "greater than" },
|
|
17
|
+
{ operator: "lessThan", label: "less than" },
|
|
18
|
+
{ operator: "greaterThanOrEqual", label: "greater than or equal to" },
|
|
19
|
+
{ operator: "lessThanOrEqual", label: "less than or equal to" },
|
|
20
|
+
];
|
|
21
|
+
var EXCEL_KINDS = new Set(["whole", "time", "textLength"]);
|
|
22
|
+
var EXCEL_OPERATORS = new Set(exports.EXCEL_VALIDATION_OPERATOR_LABELS.map(function (entry) { return entry.operator; }));
|
|
23
|
+
/** Two-sided operators need both bounds. */
|
|
24
|
+
var isTwoSidedOperator = function (operator) {
|
|
25
|
+
return operator === "between" || operator === "notBetween";
|
|
26
|
+
};
|
|
27
|
+
exports.isTwoSidedOperator = isTwoSidedOperator;
|
|
28
|
+
var NUMBER_CONDITION_BY_OPERATOR = {
|
|
29
|
+
between: "NUMBER_BETWEEN",
|
|
30
|
+
notBetween: "NUMBER_NOT_BETWEEN",
|
|
31
|
+
equal: "NUMBER_EQ",
|
|
32
|
+
notEqual: "NUMBER_NOT_EQ",
|
|
33
|
+
greaterThan: "NUMBER_GREATER",
|
|
34
|
+
lessThan: "NUMBER_LESS",
|
|
35
|
+
greaterThanOrEqual: "NUMBER_GREATER_THAN_EQ",
|
|
36
|
+
lessThanOrEqual: "NUMBER_LESS_THAN_EQ",
|
|
37
|
+
};
|
|
38
|
+
var stripEquals = function (text) {
|
|
39
|
+
var _a;
|
|
40
|
+
var trimmed = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
|
|
41
|
+
return trimmed.startsWith("=") ? trimmed.slice(1).trim() : trimmed;
|
|
42
|
+
};
|
|
43
|
+
var TIME_PATTERN = /^(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?\s*([AaPp][Mm]?)?$/;
|
|
44
|
+
/**
|
|
45
|
+
* Parse a typed time (`9:30`, `9:30 AM`, `21:05:10`, `24:00`, `0.5`) to
|
|
46
|
+
* Excel's serial. A bare non-negative number is taken as a serial already and
|
|
47
|
+
* kept whole (Excel's Time validation compares the full serial, so a
|
|
48
|
+
* date-time is out of a same-day range). `undefined` when unparsable.
|
|
49
|
+
*/
|
|
50
|
+
var parseTimeToSerial = function (text) {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
var trimmed = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
|
|
53
|
+
if (!trimmed)
|
|
54
|
+
return undefined;
|
|
55
|
+
var asNumber = Number(trimmed);
|
|
56
|
+
if (Number.isFinite(asNumber)) {
|
|
57
|
+
return asNumber >= 0 ? asNumber : undefined;
|
|
58
|
+
}
|
|
59
|
+
var match = TIME_PATTERN.exec(trimmed);
|
|
60
|
+
if (!match)
|
|
61
|
+
return undefined;
|
|
62
|
+
var hours = Number(match[1]);
|
|
63
|
+
var minutes = Number((_b = match[2]) !== null && _b !== void 0 ? _b : 0);
|
|
64
|
+
var seconds = Number((_c = match[3]) !== null && _c !== void 0 ? _c : 0);
|
|
65
|
+
var meridiem = (_d = match[4]) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
|
66
|
+
if (minutes > 59 || seconds > 59)
|
|
67
|
+
return undefined;
|
|
68
|
+
if (meridiem) {
|
|
69
|
+
if (hours < 1 || hours > 12)
|
|
70
|
+
return undefined;
|
|
71
|
+
if (meridiem.startsWith("p") && hours !== 12)
|
|
72
|
+
hours += 12;
|
|
73
|
+
if (meridiem.startsWith("a") && hours === 12)
|
|
74
|
+
hours = 0;
|
|
75
|
+
}
|
|
76
|
+
else if (hours > 24 || (hours === 24 && (minutes > 0 || seconds > 0))) {
|
|
77
|
+
// Excel accepts `24:00` as exactly 1.0 (midnight at the end of the day).
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return (hours * 3600 + minutes * 60 + seconds) / 86400;
|
|
81
|
+
};
|
|
82
|
+
exports.parseTimeToSerial = parseTimeToSerial;
|
|
83
|
+
/** Render a day-fraction serial as `h:mm AM/PM` (seconds when non-zero). */
|
|
84
|
+
var formatTimeSerial = function (serial) {
|
|
85
|
+
var total = Math.round((serial - Math.floor(serial)) * 86400) % 86400;
|
|
86
|
+
var hours24 = Math.floor(total / 3600);
|
|
87
|
+
var minutes = Math.floor((total % 3600) / 60);
|
|
88
|
+
var seconds = total % 60;
|
|
89
|
+
var meridiem = hours24 >= 12 ? "PM" : "AM";
|
|
90
|
+
var hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
|
|
91
|
+
var mm = String(minutes).padStart(2, "0");
|
|
92
|
+
var ss = seconds ? ":".concat(String(seconds).padStart(2, "0")) : "";
|
|
93
|
+
return "".concat(hours12, ":").concat(mm).concat(ss, " ").concat(meridiem);
|
|
94
|
+
};
|
|
95
|
+
exports.formatTimeSerial = formatTimeSerial;
|
|
96
|
+
/**
|
|
97
|
+
* A bound as it goes into a formula / `xlsxSource`: references and formulas
|
|
98
|
+
* verbatim (no `=`), times as serials, numbers as typed.
|
|
99
|
+
*/
|
|
100
|
+
var toBoundFormula = function (kind, text) {
|
|
101
|
+
var _a;
|
|
102
|
+
var raw = (_a = text === null || text === void 0 ? void 0 : text.trim()) !== null && _a !== void 0 ? _a : "";
|
|
103
|
+
if (!raw)
|
|
104
|
+
return undefined;
|
|
105
|
+
if (raw.startsWith("="))
|
|
106
|
+
return stripEquals(raw);
|
|
107
|
+
if (kind === "time") {
|
|
108
|
+
var serial = (0, exports.parseTimeToSerial)(raw);
|
|
109
|
+
return serial === undefined ? raw : String(serial);
|
|
110
|
+
}
|
|
111
|
+
return raw;
|
|
112
|
+
};
|
|
113
|
+
/** The A1 anchor (range top-left) a relative custom formula is written against. */
|
|
114
|
+
var getValidationAnchor = function (range) {
|
|
115
|
+
var _a;
|
|
116
|
+
return (_a = (0, utils_1.cellToAddress)(range
|
|
117
|
+
? { rowIndex: range.startRowIndex, columnIndex: range.startColumnIndex }
|
|
118
|
+
: { rowIndex: 1, columnIndex: 1 })) !== null && _a !== void 0 ? _a : "A1";
|
|
119
|
+
};
|
|
120
|
+
exports.getValidationAnchor = getValidationAnchor;
|
|
121
|
+
var comparison = function (subject, operator, a, b) {
|
|
122
|
+
switch (operator) {
|
|
123
|
+
case "between":
|
|
124
|
+
return b === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: "AND(".concat(subject, ">=").concat(a, ",").concat(subject, "<=").concat(b, ")");
|
|
127
|
+
case "notBetween":
|
|
128
|
+
return b === undefined
|
|
129
|
+
? undefined
|
|
130
|
+
: "OR(".concat(subject, "<").concat(a, ",").concat(subject, ">").concat(b, ")");
|
|
131
|
+
case "equal":
|
|
132
|
+
return "".concat(subject, "=").concat(a);
|
|
133
|
+
case "notEqual":
|
|
134
|
+
return "".concat(subject, "<>").concat(a);
|
|
135
|
+
case "greaterThan":
|
|
136
|
+
return "".concat(subject, ">").concat(a);
|
|
137
|
+
case "lessThan":
|
|
138
|
+
return "".concat(subject, "<").concat(a);
|
|
139
|
+
case "greaterThanOrEqual":
|
|
140
|
+
return "".concat(subject, ">=").concat(a);
|
|
141
|
+
case "lessThanOrEqual":
|
|
142
|
+
return "".concat(subject, "<=").concat(a);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Build the `condition` + `xlsxSource` pair for an Excel kind. Returns
|
|
147
|
+
* `undefined` when a required bound is missing (the editor keeps the form
|
|
148
|
+
* open in that case).
|
|
149
|
+
*/
|
|
150
|
+
var buildExcelValidationRule = function (spec, anchor) {
|
|
151
|
+
var formula1 = toBoundFormula(spec.kind, spec.formula1);
|
|
152
|
+
var formula2 = toBoundFormula(spec.kind, spec.formula2);
|
|
153
|
+
if (!formula1)
|
|
154
|
+
return undefined;
|
|
155
|
+
if ((0, exports.isTwoSidedOperator)(spec.operator) && !formula2)
|
|
156
|
+
return undefined;
|
|
157
|
+
var xlsxSource = tslib_1.__assign({ type: spec.kind, operator: spec.operator, formula1: formula1 }, ((0, exports.isTwoSidedOperator)(spec.operator) ? { formula2: formula2 } : {}));
|
|
158
|
+
if (spec.kind === "time") {
|
|
159
|
+
var condition = {
|
|
160
|
+
type: NUMBER_CONDITION_BY_OPERATOR[spec.operator],
|
|
161
|
+
values: tslib_1.__spreadArray([
|
|
162
|
+
{
|
|
163
|
+
userEnteredValue: /^[A-Za-z$'!]/.test(formula1)
|
|
164
|
+
? "=".concat(formula1)
|
|
165
|
+
: formula1,
|
|
166
|
+
}
|
|
167
|
+
], tslib_1.__read(((0, exports.isTwoSidedOperator)(spec.operator) && formula2
|
|
168
|
+
? [
|
|
169
|
+
{
|
|
170
|
+
userEnteredValue: /^[A-Za-z$'!]/.test(formula2)
|
|
171
|
+
? "=".concat(formula2)
|
|
172
|
+
: formula2,
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
: [])), false),
|
|
176
|
+
};
|
|
177
|
+
return { condition: condition, xlsxSource: xlsxSource };
|
|
178
|
+
}
|
|
179
|
+
var subject = spec.kind === "textLength" ? "LEN(".concat(anchor, ")") : anchor;
|
|
180
|
+
var body = comparison(subject, spec.operator, formula1, formula2);
|
|
181
|
+
if (!body)
|
|
182
|
+
return undefined;
|
|
183
|
+
var formula = spec.kind === "whole"
|
|
184
|
+
? "=AND(ISNUMBER(".concat(anchor, "),").concat(anchor, "=INT(").concat(anchor, "),").concat(body, ")")
|
|
185
|
+
: "=".concat(body);
|
|
186
|
+
return {
|
|
187
|
+
condition: {
|
|
188
|
+
type: "CUSTOM_FORMULA",
|
|
189
|
+
values: [{ userEnteredValue: formula }],
|
|
190
|
+
},
|
|
191
|
+
xlsxSource: xlsxSource,
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
exports.buildExcelValidationRule = buildExcelValidationRule;
|
|
195
|
+
/**
|
|
196
|
+
* Read an Excel kind back from a rule's `xlsxSource` (imported or authored
|
|
197
|
+
* here); `undefined` for every other rule. Time bounds come back as
|
|
198
|
+
* `h:mm AM/PM` text so the editor shows what the user would type.
|
|
199
|
+
*/
|
|
200
|
+
var readExcelValidationSpec = function (rule) {
|
|
201
|
+
var source = rule === null || rule === void 0 ? void 0 : rule.xlsxSource;
|
|
202
|
+
if (!source || !EXCEL_KINDS.has(source.type))
|
|
203
|
+
return undefined;
|
|
204
|
+
var operator = (source.operator && EXCEL_OPERATORS.has(source.operator)
|
|
205
|
+
? source.operator
|
|
206
|
+
: "between");
|
|
207
|
+
var kind = source.type;
|
|
208
|
+
var display = function (formula) {
|
|
209
|
+
if (formula === undefined || formula === "")
|
|
210
|
+
return undefined;
|
|
211
|
+
var asNumber = Number(formula);
|
|
212
|
+
if (Number.isFinite(asNumber)) {
|
|
213
|
+
return kind === "time" ? (0, exports.formatTimeSerial)(asNumber) : formula;
|
|
214
|
+
}
|
|
215
|
+
return "=".concat(formula);
|
|
216
|
+
};
|
|
217
|
+
return {
|
|
218
|
+
kind: kind,
|
|
219
|
+
operator: operator,
|
|
220
|
+
formula1: display(source.formula1),
|
|
221
|
+
formula2: display(source.formula2),
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
exports.readExcelValidationSpec = readExcelValidationSpec;
|
|
225
|
+
var compare = function (subject, operator, a, b) {
|
|
226
|
+
switch (operator) {
|
|
227
|
+
case "between":
|
|
228
|
+
return (b !== undefined &&
|
|
229
|
+
subject >= Math.min(a, b) &&
|
|
230
|
+
subject <= Math.max(a, b));
|
|
231
|
+
case "notBetween":
|
|
232
|
+
return (b !== undefined &&
|
|
233
|
+
(subject < Math.min(a, b) || subject > Math.max(a, b)));
|
|
234
|
+
case "equal":
|
|
235
|
+
return subject === a;
|
|
236
|
+
case "notEqual":
|
|
237
|
+
return subject !== a;
|
|
238
|
+
case "greaterThan":
|
|
239
|
+
return subject > a;
|
|
240
|
+
case "lessThan":
|
|
241
|
+
return subject < a;
|
|
242
|
+
case "greaterThanOrEqual":
|
|
243
|
+
return subject >= a;
|
|
244
|
+
case "lessThanOrEqual":
|
|
245
|
+
return subject <= a;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
/** A typed value that is a formula (`=…`) — validated on its result, not its text. */
|
|
249
|
+
var isFormulaEntry = function (value) {
|
|
250
|
+
return typeof value === "string" && value.trim().startsWith("=");
|
|
251
|
+
};
|
|
252
|
+
exports.isFormulaEntry = isFormulaEntry;
|
|
253
|
+
/**
|
|
254
|
+
* Decide an Excel-kind rule for a freshly typed value without the
|
|
255
|
+
* calculator — the commit-time enforcement Excel applies (`stop` blocks a
|
|
256
|
+
* decimal in a whole-number cell). `undefined` when the bounds are
|
|
257
|
+
* formulas / references, or when the typed value is itself a formula
|
|
258
|
+
* (Excel validates the formula's RESULT after the recalc, so `=5` is a
|
|
259
|
+
* valid whole number), so the caller falls back to the flag-only marker.
|
|
260
|
+
*/
|
|
261
|
+
var checkExcelValidationValue = function (rule, value) {
|
|
262
|
+
var _a;
|
|
263
|
+
var source = rule === null || rule === void 0 ? void 0 : rule.xlsxSource;
|
|
264
|
+
if (!source || !EXCEL_KINDS.has(source.type))
|
|
265
|
+
return undefined;
|
|
266
|
+
if ((0, exports.isFormulaEntry)(value))
|
|
267
|
+
return undefined;
|
|
268
|
+
var operator = ((_a = source.operator) !== null && _a !== void 0 ? _a : "between");
|
|
269
|
+
if (!EXCEL_OPERATORS.has(operator))
|
|
270
|
+
return undefined;
|
|
271
|
+
var a = Number(source.formula1);
|
|
272
|
+
var b = source.formula2 === undefined ? undefined : Number(source.formula2);
|
|
273
|
+
if (!Number.isFinite(a))
|
|
274
|
+
return undefined;
|
|
275
|
+
if ((0, exports.isTwoSidedOperator)(operator) &&
|
|
276
|
+
!(b !== undefined && Number.isFinite(b))) {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
var text = typeof value === "boolean" ? (value ? "TRUE" : "FALSE") : value;
|
|
280
|
+
switch (source.type) {
|
|
281
|
+
case "textLength":
|
|
282
|
+
return compare(Array.from(text).length, operator, a, b);
|
|
283
|
+
case "whole": {
|
|
284
|
+
if (typeof value === "boolean")
|
|
285
|
+
return false;
|
|
286
|
+
var num = Number(text.trim());
|
|
287
|
+
if (!Number.isFinite(num) || !Number.isInteger(num))
|
|
288
|
+
return false;
|
|
289
|
+
return compare(num, operator, a, b);
|
|
290
|
+
}
|
|
291
|
+
case "time": {
|
|
292
|
+
if (typeof value === "boolean")
|
|
293
|
+
return false;
|
|
294
|
+
// Excel compares the cell's full serial against the bounds (a
|
|
295
|
+
// date-time such as 45292.5 is NOT between 9:00 and 12:00) — the same
|
|
296
|
+
// comparison the composed `NUMBER_*` condition makes for the marker.
|
|
297
|
+
var serial = (0, exports.parseTimeToSerial)(text);
|
|
298
|
+
if (serial === undefined)
|
|
299
|
+
return false;
|
|
300
|
+
return compare(serial, operator, a, b);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
exports.checkExcelValidationValue = checkExcelValidationValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/grid";
|
|
2
|
+
import type { CellData } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Excel's Go To Special categories that can be decided from cell data alone.
|
|
5
|
+
* (Row / column differences, precedents / dependents and objects are served
|
|
6
|
+
* by the trace arrows and the drawing layer, not by this dialog.)
|
|
7
|
+
*/
|
|
8
|
+
export type GoToSpecialKind = "blanks" | "constants" | "formulas" | "errors" | "notes" | "visible";
|
|
9
|
+
export declare const GO_TO_SPECIAL_OPTIONS: ReadonlyArray<{
|
|
10
|
+
kind: GoToSpecialKind;
|
|
11
|
+
label: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type GoToSpecialContext<T extends CellData = CellData> = {
|
|
14
|
+
sheetId: number;
|
|
15
|
+
/** The area to scan — the current selection, or the used range for a single cell. */
|
|
16
|
+
range: GridRange;
|
|
17
|
+
getCellData(sheetId: number, rowIndex: number, columnIndex: number): T | null | undefined;
|
|
18
|
+
isRowHidden?(rowIndex: number): boolean;
|
|
19
|
+
isColumnHidden?(columnIndex: number): boolean;
|
|
20
|
+
/** Scan guard — Excel refuses huge Go To Special selections as well. */
|
|
21
|
+
maxCells?: number;
|
|
22
|
+
};
|
|
23
|
+
/** Cells scanned before the search gives up (returns what it found so far). */
|
|
24
|
+
export declare const GO_TO_SPECIAL_MAX_CELLS = 250000;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a Go To Special category to the matching cells of `range`, packed
|
|
27
|
+
* into per-row runs of adjacent columns (what the selection layer paints).
|
|
28
|
+
* Hidden rows / columns are skipped for every kind — Excel never selects
|
|
29
|
+
* into a hidden cell from Go To Special. Returns `[]` when nothing matches.
|
|
30
|
+
*/
|
|
31
|
+
export declare const resolveGoToSpecial: <T extends CellData>(kind: GoToSpecialKind, context: GoToSpecialContext<T>) => GridRange[];
|
|
32
|
+
//# sourceMappingURL=go-to-special.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-to-special.d.ts","sourceRoot":"","sources":["../../../api/go-to-special.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,CAAC;AAEd,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC;IAChD,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAOA,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAAI;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CACT,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACxB,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACxC,cAAc,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9C,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAmD/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,QAAQ,EACnD,MAAM,eAAe,EACrB,SAAS,kBAAkB,CAAC,CAAC,CAAC,KAC7B,SAAS,EAoCX,CAAC"}
|