@rowsncolumns/spreadsheet-state 28.0.73 → 28.0.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/advanced-filter.d.ts +72 -0
- package/dist/cjs/api/advanced-filter.d.ts.map +1 -0
- package/dist/cjs/api/advanced-filter.js +0 -0
- package/dist/cjs/api/datatype.d.ts.map +1 -1
- package/dist/cjs/api/datatype.js +8 -1
- package/dist/cjs/api/fill-series-spec.d.ts +35 -0
- package/dist/cjs/api/fill-series-spec.d.ts.map +1 -0
- package/dist/cjs/api/fill-series-spec.js +164 -0
- package/dist/cjs/api/fill.d.ts +95 -3
- package/dist/cjs/api/fill.d.ts.map +1 -1
- package/dist/cjs/api/fill.js +1186 -418
- package/dist/cjs/api/goal-seek.d.ts +29 -0
- package/dist/cjs/api/goal-seek.d.ts.map +1 -0
- package/dist/cjs/api/goal-seek.js +131 -0
- package/dist/cjs/api/immer-utils.d.ts.map +1 -1
- package/dist/cjs/api/immer-utils.js +21 -15
- package/dist/cjs/api/intl.d.ts.map +1 -1
- package/dist/cjs/api/paint-format.d.ts +55 -0
- package/dist/cjs/api/paint-format.d.ts.map +1 -0
- package/dist/cjs/api/paint-format.js +174 -0
- package/dist/cjs/api/split-text.d.ts +12 -0
- package/dist/cjs/api/split-text.d.ts.map +1 -1
- package/dist/cjs/api/split-text.js +41 -0
- package/dist/cjs/api/subtotal.d.ts +85 -0
- package/dist/cjs/api/subtotal.d.ts.map +1 -0
- package/dist/cjs/api/subtotal.js +250 -0
- package/dist/cjs/commands.d.ts +19 -1
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.js +83 -16
- package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation-worker.js +1 -0
- package/dist/cjs/hooks/use-calculation.d.ts +1 -1
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-advanced-filter.js +42 -0
- package/dist/cjs/hooks/use-on-fill.d.ts +13 -4
- package/dist/cjs/hooks/use-on-fill.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-fill.js +28 -7
- package/dist/cjs/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/cjs/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-goal-seek.js +140 -0
- package/dist/cjs/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/cjs/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-import-excel.js +8 -4
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.js +53 -34
- package/dist/cjs/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/cjs/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-subtotal.js +53 -0
- package/dist/cjs/hooks/use-paint-format.d.ts +19 -3
- package/dist/cjs/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/cjs/hooks/use-paint-format.js +89 -32
- package/dist/cjs/hooks/use-sheet-properties.d.ts +2 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sheet-properties.js +4 -0
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-split-text-to-columns.js +3 -2
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +109 -19
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/interface/apply-fill.d.ts +3 -3
- package/dist/cjs/interface/apply-fill.d.ts.map +1 -1
- package/dist/cjs/interface/apply-fill.js +100 -53
- package/dist/cjs/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch-stream.js +12 -6
- package/dist/cjs/interface/change-batch.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch.js +17 -9
- package/dist/cjs/interface/change-formatting.d.ts.map +1 -1
- package/dist/cjs/interface/change-formatting.js +30 -11
- package/dist/cjs/interface/split-text.d.ts +2 -1
- package/dist/cjs/interface/split-text.d.ts.map +1 -1
- package/dist/cjs/interface/split-text.js +7 -3
- package/dist/cjs/interface/spreadsheet-interface.d.ts +1 -1
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/cjs/interface/spreadsheet-interface.js +2 -2
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/sheet-cell.js +37 -6
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/advanced-filter.d.ts +72 -0
- package/dist/esm/api/advanced-filter.d.ts.map +1 -0
- package/dist/esm/api/advanced-filter.js +0 -0
- package/dist/esm/api/datatype.d.ts.map +1 -1
- package/dist/esm/api/datatype.js +8 -1
- package/dist/esm/api/fill-series-spec.d.ts +35 -0
- package/dist/esm/api/fill-series-spec.d.ts.map +1 -0
- package/dist/esm/api/fill-series-spec.js +160 -0
- package/dist/esm/api/fill.d.ts +95 -3
- package/dist/esm/api/fill.d.ts.map +1 -1
- package/dist/esm/api/fill.js +1158 -418
- package/dist/esm/api/goal-seek.d.ts +29 -0
- package/dist/esm/api/goal-seek.d.ts.map +1 -0
- package/dist/esm/api/goal-seek.js +108 -0
- package/dist/esm/api/immer-utils.d.ts.map +1 -1
- package/dist/esm/api/immer-utils.js +21 -15
- package/dist/esm/api/intl.d.ts.map +1 -1
- package/dist/esm/api/paint-format.d.ts +55 -0
- package/dist/esm/api/paint-format.d.ts.map +1 -0
- package/dist/esm/api/paint-format.js +122 -0
- package/dist/esm/api/split-text.d.ts +12 -0
- package/dist/esm/api/split-text.d.ts.map +1 -1
- package/dist/esm/api/split-text.js +28 -0
- package/dist/esm/api/subtotal.d.ts +85 -0
- package/dist/esm/api/subtotal.d.ts.map +1 -0
- package/dist/esm/api/subtotal.js +181 -0
- package/dist/esm/commands.d.ts +19 -1
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.js +52 -4
- package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation-worker.js +1 -0
- package/dist/esm/hooks/use-calculation.d.ts +1 -1
- package/dist/esm/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/esm/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-advanced-filter.js +41 -0
- package/dist/esm/hooks/use-on-fill.d.ts +13 -4
- package/dist/esm/hooks/use-on-fill.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-fill.js +24 -4
- package/dist/esm/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/esm/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-goal-seek.js +82 -0
- package/dist/esm/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/esm/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-import-excel.js +8 -4
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-merge-unmerge-cells.js +13 -13
- package/dist/esm/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/esm/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-subtotal.js +48 -0
- package/dist/esm/hooks/use-paint-format.d.ts +19 -3
- package/dist/esm/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/esm/hooks/use-paint-format.js +75 -30
- package/dist/esm/hooks/use-sheet-properties.d.ts +2 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/esm/hooks/use-sheet-properties.js +4 -0
- package/dist/esm/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/esm/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-split-text-to-columns.js +3 -2
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +100 -17
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/interface/apply-fill.d.ts +3 -3
- package/dist/esm/interface/apply-fill.d.ts.map +1 -1
- package/dist/esm/interface/apply-fill.js +93 -48
- package/dist/esm/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/esm/interface/change-batch-stream.js +12 -6
- package/dist/esm/interface/change-batch.d.ts.map +1 -1
- package/dist/esm/interface/change-batch.js +15 -9
- package/dist/esm/interface/change-formatting.d.ts.map +1 -1
- package/dist/esm/interface/change-formatting.js +28 -11
- package/dist/esm/interface/split-text.d.ts +2 -1
- package/dist/esm/interface/split-text.d.ts.map +1 -1
- package/dist/esm/interface/split-text.js +6 -3
- package/dist/esm/interface/spreadsheet-interface.d.ts +1 -1
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/esm/interface/spreadsheet-interface.js +2 -2
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/sheet-cell.js +37 -6
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -20
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { CrossCircledIcon } from "@rowsncolumns/icons";
|
|
3
|
-
import { CONDITION_NONE, FormulaInput, shouldShowFromValue, shouldShowToValue, useFormulaInputState, useGetNamedRanges, VALIDATION_CONDITION_LABELS, } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
import { buildExcelValidationRule, CONDITION_NONE, EXCEL_VALIDATION_KIND_LABELS, EXCEL_VALIDATION_OPERATOR_LABELS, FormulaInput, getValidationAnchor, isTwoSidedOperator, readExcelValidationSpec, shouldShowFromValue, shouldShowToValue, useFormulaInputState, useGetNamedRanges, VALIDATION_CONDITION_LABELS, } from "@rowsncolumns/spreadsheet";
|
|
4
4
|
import { Button, IconButton, Input, Select, SelectContent, SelectItem, SelectPortal, SelectTrigger, SelectValue, Stack, useIsomorphicLayoutEffect, } from "@rowsncolumns/ui";
|
|
5
5
|
import { uuid } from "@rowsncolumns/utils";
|
|
6
6
|
import { useFormik } from "formik";
|
|
7
7
|
import React, { useMemo, useState } from "react";
|
|
8
8
|
export var DataValidationRuleEditor = function (_a) {
|
|
9
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
9
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
10
10
|
var sheetId = _a.sheetId, dataValidationRule = _a.dataValidationRule, functionDescriptions = _a.functionDescriptions, idCreationStrategy = _a.idCreationStrategy, onCancel = _a.onCancel, onSubmit = _a.onSubmit;
|
|
11
11
|
var ensureFormula = function (value) {
|
|
12
12
|
if (!value)
|
|
@@ -17,19 +17,30 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
17
17
|
return trimmed.startsWith("=") ? trimmed : "=".concat(trimmed);
|
|
18
18
|
};
|
|
19
19
|
var getNamedRanges = useGetNamedRanges();
|
|
20
|
-
|
|
20
|
+
// Excel's Whole number / Time / Text length kinds live outside the
|
|
21
|
+
// ConditionType union; the select shows them as `EXCEL_KIND_*` entries and
|
|
22
|
+
// the rule is composed on save (see `buildExcelValidationRule`).
|
|
23
|
+
var _3 = __read(useState(function () { return readExcelValidationSpec(dataValidationRule); }), 2), excelSpec = _3[0], setExcelSpec = _3[1];
|
|
24
|
+
var _4 = useFormik({
|
|
21
25
|
initialValues: dataValidationRule,
|
|
22
26
|
onSubmit: function (values) {
|
|
27
|
+
if (excelSpec) {
|
|
28
|
+
var composed = buildExcelValidationRule(excelSpec, getValidationAnchor(values.ranges[0]));
|
|
29
|
+
if (!composed)
|
|
30
|
+
return;
|
|
31
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(__assign(__assign({}, values), composed), dataValidationRule);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
23
34
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(values, dataValidationRule);
|
|
24
35
|
},
|
|
25
|
-
}), values =
|
|
36
|
+
}), values = _4.values, handleSubmit = _4.handleSubmit, resetForm = _4.resetForm, setFieldValue = _4.setFieldValue;
|
|
26
37
|
// Cancel
|
|
27
38
|
var onCancelForm = function () {
|
|
28
39
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
29
40
|
resetForm();
|
|
30
41
|
};
|
|
31
|
-
var
|
|
32
|
-
var
|
|
42
|
+
var _5 = __read(useState(function () { var _a, _b; return shouldShowToValue((_b = (_a = values.condition) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : undefined); }), 2), showToValue = _5[0], setShowToValue = _5[1];
|
|
43
|
+
var _6 = __read(useState(function () { var _a, _b; return shouldShowFromValue((_b = (_a = values === null || values === void 0 ? void 0 : values.condition) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : undefined); }), 2), showFromValue = _6[0], setShowFromValue = _6[1];
|
|
33
44
|
var fromValue = (_d = (_c = (_b = values === null || values === void 0 ? void 0 : values.condition) === null || _b === void 0 ? void 0 : _b.values) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.userEnteredValue;
|
|
34
45
|
var toValue = (_g = (_f = (_e = values === null || values === void 0 ? void 0 : values.condition) === null || _e === void 0 ? void 0 : _e.values) === null || _f === void 0 ? void 0 : _f[1]) === null || _g === void 0 ? void 0 : _g.userEnteredValue;
|
|
35
46
|
var updateDataValidationInputs = function (nextFromValue, nextToValue, nextType, includeToValue, includeFromValue) {
|
|
@@ -38,6 +49,11 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
38
49
|
if (includeToValue === void 0) { includeToValue = showToValue; }
|
|
39
50
|
if (includeFromValue === void 0) { includeFromValue = showFromValue; }
|
|
40
51
|
var shouldIncludeFrom = includeFromValue && nextFromValue !== undefined;
|
|
52
|
+
// The condition no longer matches the imported Excel description — drop
|
|
53
|
+
// it so the exporter synthesizes from `condition` instead of replaying
|
|
54
|
+
// the stale source rule.
|
|
55
|
+
if (values.xlsxSource)
|
|
56
|
+
setFieldValue("xlsxSource", undefined);
|
|
41
57
|
if (nextType === "CUSTOM_FORMULA") {
|
|
42
58
|
setFieldValue("condition.values", __spreadArray([], __read((shouldIncludeFrom
|
|
43
59
|
? [{ userEnteredValue: (_b = ensureFormula(nextFromValue)) !== null && _b !== void 0 ? _b : "" }]
|
|
@@ -101,8 +117,24 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
101
117
|
}, type: "button", className: "cursor-pointer" }, "Add range"))),
|
|
102
118
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-1" },
|
|
103
119
|
React.createElement("label", { className: "font-system text-sm" }, "Format rules"),
|
|
104
|
-
React.createElement(Select, { value:
|
|
120
|
+
React.createElement(Select, { value: excelSpec
|
|
121
|
+
? "".concat(EXCEL_KIND_PREFIX).concat(excelSpec.kind)
|
|
122
|
+
: (_k = (_j = values === null || values === void 0 ? void 0 : values.condition) === null || _j === void 0 ? void 0 : _j.type) !== null && _k !== void 0 ? _k : CONDITION_NONE, onValueChange: function (value) {
|
|
105
123
|
var _a, _b, _c, _d;
|
|
124
|
+
if (value.startsWith(EXCEL_KIND_PREFIX)) {
|
|
125
|
+
var kind_1 = value.slice(EXCEL_KIND_PREFIX.length);
|
|
126
|
+
setExcelSpec(function (prev) {
|
|
127
|
+
var _a;
|
|
128
|
+
return ({
|
|
129
|
+
kind: kind_1,
|
|
130
|
+
operator: (_a = prev === null || prev === void 0 ? void 0 : prev.operator) !== null && _a !== void 0 ? _a : "between",
|
|
131
|
+
formula1: (prev === null || prev === void 0 ? void 0 : prev.kind) === kind_1 ? prev.formula1 : undefined,
|
|
132
|
+
formula2: (prev === null || prev === void 0 ? void 0 : prev.kind) === kind_1 ? prev.formula2 : undefined,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
setExcelSpec(undefined);
|
|
106
138
|
var nextShowTo = shouldShowToValue(value);
|
|
107
139
|
var nextShowFrom = shouldShowFromValue(value);
|
|
108
140
|
setFieldValue("condition.type", value);
|
|
@@ -118,23 +150,56 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
118
150
|
React.createElement(SelectPortal, null,
|
|
119
151
|
React.createElement(SelectContent, null,
|
|
120
152
|
React.createElement(SelectItem, { value: CONDITION_NONE }, "None"),
|
|
153
|
+
EXCEL_VALIDATION_KIND_LABELS.map(function (_a) {
|
|
154
|
+
var kind = _a.kind, label = _a.label;
|
|
155
|
+
return (React.createElement(SelectItem, { key: kind, value: "".concat(EXCEL_KIND_PREFIX).concat(kind) }, label));
|
|
156
|
+
}),
|
|
121
157
|
VALIDATION_CONDITION_LABELS.map(function (_a) {
|
|
122
158
|
var condition = _a.condition, label = _a.label;
|
|
123
159
|
return (React.createElement(SelectItem, { key: condition, value: condition }, label));
|
|
124
160
|
}))))),
|
|
161
|
+
excelSpec ? (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
162
|
+
React.createElement(Select, { value: excelSpec.operator, onValueChange: function (operator) {
|
|
163
|
+
return setExcelSpec(function (prev) { return (prev ? __assign(__assign({}, prev), { operator: operator }) : prev); });
|
|
164
|
+
} },
|
|
165
|
+
React.createElement(SelectTrigger, { className: "mb-1 text-sm", "aria-label": "Data" },
|
|
166
|
+
React.createElement(SelectValue, { placeholder: "between" })),
|
|
167
|
+
React.createElement(SelectPortal, null,
|
|
168
|
+
React.createElement(SelectContent, null, EXCEL_VALIDATION_OPERATOR_LABELS.map(function (_a) {
|
|
169
|
+
var operator = _a.operator, label = _a.label;
|
|
170
|
+
return (React.createElement(SelectItem, { key: operator, value: operator }, label));
|
|
171
|
+
})))),
|
|
172
|
+
React.createElement(Input, { value: (_l = excelSpec.formula1) !== null && _l !== void 0 ? _l : "", type: "text", name: "excelFormula1", onChange: function (e) {
|
|
173
|
+
return setExcelSpec(function (prev) {
|
|
174
|
+
return prev ? __assign(__assign({}, prev), { formula1: e.target.value }) : prev;
|
|
175
|
+
});
|
|
176
|
+
}, className: "text-xs", placeholder: isTwoSidedOperator(excelSpec.operator)
|
|
177
|
+
? excelSpec.kind === "time"
|
|
178
|
+
? "Start time"
|
|
179
|
+
: "Minimum"
|
|
180
|
+
: excelSpec.kind === "time"
|
|
181
|
+
? "Time"
|
|
182
|
+
: excelSpec.kind === "textLength"
|
|
183
|
+
? "Length"
|
|
184
|
+
: "Value" }),
|
|
185
|
+
isTwoSidedOperator(excelSpec.operator) ? (React.createElement(Input, { value: (_m = excelSpec.formula2) !== null && _m !== void 0 ? _m : "", type: "text", name: "excelFormula2", onChange: function (e) {
|
|
186
|
+
return setExcelSpec(function (prev) {
|
|
187
|
+
return prev ? __assign(__assign({}, prev), { formula2: e.target.value }) : prev;
|
|
188
|
+
});
|
|
189
|
+
}, className: "text-xs", placeholder: excelSpec.kind === "time" ? "End time" : "Maximum" })) : null)) : null,
|
|
125
190
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
126
|
-
showFromValue ? (((
|
|
127
|
-
((
|
|
191
|
+
!excelSpec && showFromValue ? (((_o = values.condition) === null || _o === void 0 ? void 0 : _o.type) === "CUSTOM_FORMULA" ||
|
|
192
|
+
((_p = values.condition) === null || _p === void 0 ? void 0 : _p.type) === "ONE_OF_RANGE" ? (React.createElement(FormulaInput, { onChange: function (value) {
|
|
128
193
|
var _a, _b;
|
|
129
194
|
return updateDataValidationInputs(value, undefined, (_b = (_a = values.condition) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : undefined, false, true);
|
|
130
195
|
}, value: fromValue !== null && fromValue !== void 0 ? fromValue : "=", required: true, placeholder: "Enter a formula", autoFocus: true, functionDescriptions: functionDescriptions, getNamedRanges: getNamedRanges })) : (React.createElement(Input, { value: fromValue, type: "text", name: "fromValue", onChange: function (e) {
|
|
131
196
|
return updateDataValidationInputs(e.target.value, toValue);
|
|
132
197
|
}, className: "text-xs", placeholder: "Value or formula" }))) : null,
|
|
133
|
-
showToValue ? (React.createElement(Input, { value: toValue, type: "text", name: "toValue", onChange: function (e) {
|
|
198
|
+
!excelSpec && showToValue ? (React.createElement(Input, { value: toValue, type: "text", name: "toValue", onChange: function (e) {
|
|
134
199
|
return updateDataValidationInputs(fromValue, e.target.value);
|
|
135
200
|
}, className: "text-xs", placeholder: "Value or formula" })) : null),
|
|
136
201
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-1 flex-row" },
|
|
137
|
-
React.createElement("input", { type: "checkbox", checked: (
|
|
202
|
+
React.createElement("input", { type: "checkbox", checked: (_q = values.allowBlank) !== null && _q !== void 0 ? _q : undefined, onChange: function (e) {
|
|
138
203
|
setFieldValue("allowBlank", e.target.checked);
|
|
139
204
|
}, id: "validationAllowBlank" }),
|
|
140
205
|
React.createElement("label", { htmlFor: "validationAllowBlank", className: "font-system text-sm" }, "Allow blank")),
|
|
@@ -145,10 +210,10 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
145
210
|
}, id: "validationShowInputMessage" }),
|
|
146
211
|
React.createElement("label", { htmlFor: "validationShowInputMessage", className: "font-system text-sm" }, "Show input message when cell is selected")),
|
|
147
212
|
values.inputMessage ? (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
148
|
-
React.createElement(Input, { value: (
|
|
213
|
+
React.createElement(Input, { value: (_s = (_r = values.inputMessage) === null || _r === void 0 ? void 0 : _r.title) !== null && _s !== void 0 ? _s : "", type: "text", name: "inputMessageTitle", onChange: function (e) {
|
|
149
214
|
return setFieldValue("inputMessage.title", e.target.value);
|
|
150
215
|
}, className: "text-xs", placeholder: "Title" }),
|
|
151
|
-
React.createElement(Input, { value: (
|
|
216
|
+
React.createElement(Input, { value: (_u = (_t = values.inputMessage) === null || _t === void 0 ? void 0 : _t.message) !== null && _u !== void 0 ? _u : "", type: "text", name: "inputMessageBody", onChange: function (e) {
|
|
152
217
|
return setFieldValue("inputMessage.message", e.target.value);
|
|
153
218
|
}, className: "text-xs", placeholder: "Input message" }))) : null,
|
|
154
219
|
React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-1 flex-row" },
|
|
@@ -158,7 +223,7 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
158
223
|
}, id: "validationShowErrorAlert" }),
|
|
159
224
|
React.createElement("label", { htmlFor: "validationShowErrorAlert", className: "font-system text-sm" }, "Show error alert after invalid data is entered")),
|
|
160
225
|
values.alert ? (React.createElement(Stack, { direction: "vertical", className: "gap-1 pb-3" },
|
|
161
|
-
React.createElement(Select, { value: (
|
|
226
|
+
React.createElement(Select, { value: (_w = (_v = values.alert) === null || _v === void 0 ? void 0 : _v.style) !== null && _w !== void 0 ? _w : "stop", onValueChange: function (value) {
|
|
162
227
|
return setFieldValue("alert.style", value);
|
|
163
228
|
} },
|
|
164
229
|
React.createElement(SelectTrigger, { className: "mb-1 text-sm" },
|
|
@@ -168,14 +233,16 @@ export var DataValidationRuleEditor = function (_a) {
|
|
|
168
233
|
React.createElement(SelectItem, { value: "stop" }, "Stop"),
|
|
169
234
|
React.createElement(SelectItem, { value: "warning" }, "Warning"),
|
|
170
235
|
React.createElement(SelectItem, { value: "information" }, "Information")))),
|
|
171
|
-
React.createElement(Input, { value: (
|
|
172
|
-
React.createElement(Input, { value: (
|
|
236
|
+
React.createElement(Input, { value: (_z = (_y = (_x = values.alert) === null || _x === void 0 ? void 0 : _x.message) === null || _y === void 0 ? void 0 : _y.title) !== null && _z !== void 0 ? _z : "", type: "text", name: "alertTitle", onChange: function (e) { return setFieldValue("alert.message.title", e.target.value); }, className: "text-xs", placeholder: "Title" }),
|
|
237
|
+
React.createElement(Input, { value: (_2 = (_1 = (_0 = values.alert) === null || _0 === void 0 ? void 0 : _0.message) === null || _1 === void 0 ? void 0 : _1.message) !== null && _2 !== void 0 ? _2 : "", type: "text", name: "alertBody", onChange: function (e) {
|
|
173
238
|
return setFieldValue("alert.message.message", e.target.value);
|
|
174
239
|
}, className: "text-xs", placeholder: "Error message" }))) : null,
|
|
175
240
|
React.createElement("div", { className: "flex gap-1 py-2" },
|
|
176
241
|
React.createElement(Button, { type: "submit", variant: "primary", size: "xs" }, "Save"),
|
|
177
242
|
React.createElement(Button, { size: "xs", onClick: onCancelForm, type: "button" }, "Cancel"))));
|
|
178
243
|
};
|
|
244
|
+
/** Select values for the Excel kinds (kept out of the ConditionType union). */
|
|
245
|
+
var EXCEL_KIND_PREFIX = "EXCEL_KIND_";
|
|
179
246
|
var DataValidationRangeInput = function (_a) {
|
|
180
247
|
var sheetId = _a.sheetId, range = _a.range, autoFocus = _a.autoFocus, onValidRange = _a.onValidRange;
|
|
181
248
|
var formulaInput = useFormulaInputState(sheetId, range);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calculation-worker.d.ts","sourceRoot":"","sources":["../../../hooks/use-calculation-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,8BAA8B,EAQ9B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAU1C,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,4BAA4B,CAAC;AAmBpC,OAAO,KAAK,EAEV,UAAU,EACV,SAAS,EACV,MAAM,2BAA2B,CAAC;AAgBnC,OAAO,KAAK,EAKV,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,KAAK,wBAAwB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EACD,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,iBAAiB,GACjB,yBAAyB,GACzB,cAAc,GACd,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAyEF,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAC5D,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,2BAA2B,CAAC;IACnD,kBAAkB,CAAC,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAClD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AA8KF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,yBAAyB,KAC/B,
|
|
1
|
+
{"version":3,"file":"use-calculation-worker.d.ts","sourceRoot":"","sources":["../../../hooks/use-calculation-worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,8BAA8B,EAQ9B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAU1C,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,4BAA4B,CAAC;AAmBpC,OAAO,KAAK,EAEV,UAAU,EACV,SAAS,EACV,MAAM,2BAA2B,CAAC;AAgBnC,OAAO,KAAK,EAKV,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,KAAK,wBAAwB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EACD,OAAO,GACP,YAAY,GACZ,iBAAiB,GACjB,iBAAiB,GACjB,yBAAyB,GACzB,cAAc,GACd,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAyEF,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAC5D,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,2BAA2B,CAAC;IACnD,kBAAkB,CAAC,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAClD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AA8KF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,yBAAyB,KAC/B,wBA+/DF,CAAC"}
|
|
@@ -1813,6 +1813,7 @@ export var useCalculationWorker = function (props) {
|
|
|
1813
1813
|
position: position,
|
|
1814
1814
|
formula: formula,
|
|
1815
1815
|
precedents: dependencies,
|
|
1816
|
+
cellFormulas: graph.collectCellFormulas(formula, dependencies),
|
|
1816
1817
|
isPreview: !disablePreview,
|
|
1817
1818
|
},
|
|
1818
1819
|
],
|
|
@@ -148,7 +148,7 @@ export declare const useCalculation: ({ locale, functions, iterativeCalculation,
|
|
|
148
148
|
disablePreview?: boolean;
|
|
149
149
|
overrides?: CalculationOverrides;
|
|
150
150
|
skipOnDemand?: boolean;
|
|
151
|
-
}) => Promise<string | number | boolean |
|
|
151
|
+
}) => Promise<string | number | boolean | Date | StructuredResult | FormulaError | FormulaResultArray | import("@rowsncolumns/fast-formula-parser").RecursiveFormula | DataSource | null | undefined>;
|
|
152
152
|
getGraphNodes: () => Map<string, CellNode | StaticNode | CellRangeNode>;
|
|
153
153
|
getGraphNodesInSheet: (sheetId: number) => ReadonlyMap<string, CellNode | CellRangeNode> | undefined;
|
|
154
154
|
addStaticReference: (source: StaticReference, sourcePosition: CellCoordinate | CellCoordinateRange) => Calculator<any>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import { type AdvancedFilterOptions, type AdvancedFilterPlan, type AdvancedFilterPlanExecutor } from "../api/advanced-filter";
|
|
3
|
+
import type { useSheetProperties } from "./use-sheet-properties";
|
|
4
|
+
export type { AdvancedFilterOptions, AdvancedFilterPlan };
|
|
5
|
+
export type UseOnAdvancedFilterProps = {
|
|
6
|
+
getEffectiveValue: ReturnType<typeof useSheetProperties>["getEffectiveValue"];
|
|
7
|
+
getFormattedValue: ReturnType<typeof useSheetProperties>["getFormattedValue"];
|
|
8
|
+
onHideRow: AdvancedFilterPlanExecutor["onHideRow"];
|
|
9
|
+
onShowRow: AdvancedFilterPlanExecutor["onShowRow"];
|
|
10
|
+
onChangeBatch: (sheetId: number, ranges: GridRange, values: (string | number | boolean | null)[][]) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Excel's Data → Sort & Filter → Advanced, composed over the existing
|
|
14
|
+
* hide/show-row and batch-write callbacks so both engines execute it through
|
|
15
|
+
* the same streamed commands. Records are compared by their effective value
|
|
16
|
+
* (numbers stay numeric) and fall back to the displayed text. Returns the
|
|
17
|
+
* applied plan, or `undefined` when the list has no records, the copy
|
|
18
|
+
* destination is missing / protected, or the sheet cannot be edited.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useOnAdvancedFilter: ({ getEffectiveValue, getFormattedValue, onHideRow, onShowRow, onChangeBatch, }: UseOnAdvancedFilterProps) => (sheetId: number, options: AdvancedFilterOptions) => AdvancedFilterPlan | undefined;
|
|
21
|
+
//# sourceMappingURL=use-on-advanced-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-on-advanced-filter.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-advanced-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAGhC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;AAE1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,CAAC;IACnD,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,CAAC;IACnD,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,KAC3C,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,gFAMjC,wBAAwB,eAKb,MAAM,WAAW,qBAAqB,KAAG,kBAAkB,GAAG,SA2B3E,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { applyAdvancedFilterPlan, planAdvancedFilter, } from "../api/advanced-filter";
|
|
3
|
+
import { useCanEditCellRange, useCanEditSheet } from "./use-can-edit-cellrange";
|
|
4
|
+
/**
|
|
5
|
+
* Excel's Data → Sort & Filter → Advanced, composed over the existing
|
|
6
|
+
* hide/show-row and batch-write callbacks so both engines execute it through
|
|
7
|
+
* the same streamed commands. Records are compared by their effective value
|
|
8
|
+
* (numbers stay numeric) and fall back to the displayed text. Returns the
|
|
9
|
+
* applied plan, or `undefined` when the list has no records, the copy
|
|
10
|
+
* destination is missing / protected, or the sheet cannot be edited.
|
|
11
|
+
*/
|
|
12
|
+
export var useOnAdvancedFilter = function (_a) {
|
|
13
|
+
var getEffectiveValue = _a.getEffectiveValue, getFormattedValue = _a.getFormattedValue, onHideRow = _a.onHideRow, onShowRow = _a.onShowRow, onChangeBatch = _a.onChangeBatch;
|
|
14
|
+
var canEditCellRange = useCanEditCellRange();
|
|
15
|
+
var canEditSheet = useCanEditSheet();
|
|
16
|
+
return useCallback(function (sheetId, options) {
|
|
17
|
+
if (!canEditSheet(sheetId)) {
|
|
18
|
+
console.debug("This sheet is protected, users cannot filter it.");
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
var plan = planAdvancedFilter(options, function (rowIndex, columnIndex) {
|
|
22
|
+
var value = getEffectiveValue(sheetId, rowIndex, columnIndex);
|
|
23
|
+
return value !== null && value !== void 0 ? value : getFormattedValue(sheetId, rowIndex, columnIndex);
|
|
24
|
+
});
|
|
25
|
+
if (!plan)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (plan.copy && !canEditCellRange(sheetId, plan.copy.range)) {
|
|
28
|
+
console.debug("This range is protected, users cannot edit this cell range.");
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
applyAdvancedFilterPlan(sheetId, plan, { onHideRow: onHideRow, onShowRow: onShowRow, onChangeBatch: onChangeBatch });
|
|
32
|
+
return plan;
|
|
33
|
+
}, [
|
|
34
|
+
canEditSheet,
|
|
35
|
+
canEditCellRange,
|
|
36
|
+
getEffectiveValue,
|
|
37
|
+
getFormattedValue,
|
|
38
|
+
onHideRow,
|
|
39
|
+
onShowRow,
|
|
40
|
+
onChangeBatch,
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CellInterface, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
|
-
import { type CellData, type SelectionAttributes, type Sheet } from "@rowsncolumns/spreadsheet";
|
|
3
|
-
import type
|
|
1
|
+
import type { CellInterface, GridRange, SelectionArea } from "@rowsncolumns/common-types";
|
|
2
|
+
import { type CellData, type FillOptions, type SelectionAttributes, type Sheet } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
import { type AutoFillType } from "../api/fill";
|
|
4
4
|
import type { OnCommand } from "../commands";
|
|
5
5
|
import type { CalculationOperation, useCalculation } from "./use-calculation";
|
|
6
6
|
import type { CellXfsRegistry } from "./use-cellxfs-registry";
|
|
@@ -24,6 +24,15 @@ export type UseOnFillProps<T extends CellData, S extends Sheet> = {
|
|
|
24
24
|
getAutoFillValues: NonNullable<UseSpreadsheetProps<T, S>["getAutoFillValues"]>;
|
|
25
25
|
getSheetName(sheetId: number): string;
|
|
26
26
|
onCommand?: OnCommand;
|
|
27
|
+
/**
|
|
28
|
+
* The sheet's merged ranges — a source tiled by identically sized merges fills block by block.
|
|
29
|
+
*/
|
|
30
|
+
getMerges?(sheetId: number): GridRange[] | null | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Land the merge blocks a merged-seed fill produced: the target's own merges in `clearRange`
|
|
33
|
+
* give way, `merges` are created, and `selectRange` (the snapped fill extent) is re-selected.
|
|
34
|
+
*/
|
|
35
|
+
onFillMerges?(sheetId: number, activeCell: CellInterface, clearRange: GridRange, merges: GridRange[], selectRange: GridRange): void;
|
|
27
36
|
};
|
|
28
|
-
export declare const useOnFill: <T extends CellData, S extends Sheet>({ locale, cellXfsRegistry, sharedStringRegistry, getCellData, getDataValidationById, getEffectiveValue, getFormattedValue, getAutoFillValues, getSheetName, enqueueCalculation, enqueueStructureChange, onChangeSheetData, onChangeDataValidations, createHistory, onCommand, }: UseOnFillProps<T, S>) => (sheetId: number, activeCell: CellInterface, fillSelection: SelectionArea, selections: SelectionArea<SelectionAttributes>[], fillableSelections?: SelectionArea<SelectionAttributes>[], fillType?: AutoFillType) => Promise<void>;
|
|
37
|
+
export declare const useOnFill: <T extends CellData, S extends Sheet>({ locale, cellXfsRegistry, sharedStringRegistry, getCellData, getDataValidationById, getEffectiveValue, getFormattedValue, getAutoFillValues, getSheetName, enqueueCalculation, enqueueStructureChange, onChangeSheetData, onChangeDataValidations, createHistory, onCommand, getMerges, onFillMerges, }: UseOnFillProps<T, S>) => (sheetId: number, activeCell: CellInterface, fillSelection: SelectionArea, selections: SelectionArea<SelectionAttributes>[], fillableSelections?: SelectionArea<SelectionAttributes>[], fillType?: AutoFillType, options?: FillOptions) => Promise<void>;
|
|
29
38
|
//# sourceMappingURL=use-on-fill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-fill.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-fill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"use-on-fill.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-fill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,KAAK,EAEX,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,IAAI;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,WAAW,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IACrE,qBAAqB,CAAC,EAAE,UAAU,CAChC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAC7B,CAAC,uBAAuB,CAAC,CAAC;IAC3B,iBAAiB,EAAE,UAAU,CAC3B,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAC7B,CAAC,mBAAmB,CAAC,CAAC;IACvB,iBAAiB,EAAE,UAAU,CAC3B,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAC7B,CAAC,mBAAmB,CAAC,CAAC;IACvB,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC1D,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,cAAc,CACtB,CAAC,wBAAwB,CAAC,CAAC;IAC5B,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAClE,uBAAuB,CAAC,EAAE,mBAAmB,CAC3C,CAAC,EACD,CAAC,CACF,CAAC,yBAAyB,CAAC,CAAC;IAC7B,aAAa,IAAI,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,WAAW,CAC5B,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAC/C,CAAC;IACF,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5D;;;OAGG;IACH,YAAY,CAAC,CACX,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,EACzB,UAAU,EAAE,SAAS,EACrB,MAAM,EAAE,SAAS,EAAE,EACnB,WAAW,EAAE,SAAS,GACrB,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,KAAK,EAAE,0SAkB5D,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,eAKR,MAAM,cACH,aAAa,iBACV,aAAa,cAChB,aAAa,CAAC,mBAAmB,CAAC,EAAE,uBAC3B,aAAa,CAAC,mBAAmB,CAAC,EAAE,aAC9C,YAAY,YAGb,WAAW,kBAuF1B,CAAC"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { __awaiter, __generator, __read } from "tslib";
|
|
2
2
|
import { useLoadingIndicator, } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
import { error } from "@rowsncolumns/utils";
|
|
3
4
|
import { useCallback } from "react";
|
|
5
|
+
import { MergedFillSizeError } from "../api/fill";
|
|
4
6
|
import { applyFill } from "../interface/apply-fill";
|
|
5
7
|
import { useCanEditCellRange } from "./use-can-edit-cellrange";
|
|
6
8
|
export var useOnFill = function (_a) {
|
|
7
|
-
var locale = _a.locale, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getCellData = _a.getCellData, getDataValidationById = _a.getDataValidationById, getEffectiveValue = _a.getEffectiveValue, getFormattedValue = _a.getFormattedValue, getAutoFillValues = _a.getAutoFillValues, getSheetName = _a.getSheetName, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, onChangeSheetData = _a.onChangeSheetData, onChangeDataValidations = _a.onChangeDataValidations, createHistory = _a.createHistory, onCommand = _a.onCommand;
|
|
9
|
+
var locale = _a.locale, cellXfsRegistry = _a.cellXfsRegistry, sharedStringRegistry = _a.sharedStringRegistry, getCellData = _a.getCellData, getDataValidationById = _a.getDataValidationById, getEffectiveValue = _a.getEffectiveValue, getFormattedValue = _a.getFormattedValue, getAutoFillValues = _a.getAutoFillValues, getSheetName = _a.getSheetName, enqueueCalculation = _a.enqueueCalculation, enqueueStructureChange = _a.enqueueStructureChange, onChangeSheetData = _a.onChangeSheetData, onChangeDataValidations = _a.onChangeDataValidations, createHistory = _a.createHistory, onCommand = _a.onCommand, getMerges = _a.getMerges, onFillMerges = _a.onFillMerges;
|
|
8
10
|
var canEditCellRange = useCanEditCellRange();
|
|
9
11
|
var _b = __read(useLoadingIndicator(), 2), showLoader = _b[0], hideLoader = _b[1];
|
|
10
|
-
return useCallback(function (sheetId, activeCell, fillSelection, selections, fillableSelections, fillType
|
|
12
|
+
return useCallback(function (sheetId, activeCell, fillSelection, selections, fillableSelections, fillType,
|
|
13
|
+
// Modifier held on the fill handle / Series-dialog parameters. The
|
|
14
|
+
// positional `fillType` keeps working; `options.fillType` is a fallback.
|
|
15
|
+
options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
16
|
+
var resolvedFillType, err_1;
|
|
11
17
|
return __generator(this, function (_a) {
|
|
12
18
|
switch (_a.label) {
|
|
13
19
|
case 0:
|
|
20
|
+
resolvedFillType = fillType !== null && fillType !== void 0 ? fillType : options === null || options === void 0 ? void 0 : options.fillType;
|
|
14
21
|
if (!canEditCellRange(sheetId, fillSelection.range)) {
|
|
15
22
|
console.debug("This range is protected, users cannot edit this cell range.");
|
|
16
23
|
return [2 /*return*/];
|
|
@@ -19,7 +26,7 @@ export var useOnFill = function (_a) {
|
|
|
19
26
|
showLoader();
|
|
20
27
|
_a.label = 1;
|
|
21
28
|
case 1:
|
|
22
|
-
_a.trys.push([1, ,
|
|
29
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
23
30
|
return [4 /*yield*/, applyFill({
|
|
24
31
|
locale: locale,
|
|
25
32
|
cellXfsRegistry: cellXfsRegistry,
|
|
@@ -35,14 +42,24 @@ export var useOnFill = function (_a) {
|
|
|
35
42
|
onChangeSheetData: onChangeSheetData,
|
|
36
43
|
onChangeDataValidations: onChangeDataValidations,
|
|
37
44
|
createHistory: createHistory,
|
|
38
|
-
|
|
45
|
+
getMerges: getMerges,
|
|
46
|
+
onFillMerges: onFillMerges,
|
|
47
|
+
})(sheetId, activeCell, fillSelection, selections, fillableSelections, resolvedFillType, options)];
|
|
39
48
|
case 2:
|
|
40
49
|
_a.sent();
|
|
41
|
-
return [3 /*break*/,
|
|
50
|
+
return [3 /*break*/, 5];
|
|
42
51
|
case 3:
|
|
52
|
+
err_1 = _a.sent();
|
|
53
|
+
// Excel refuses a fill whose source mixes unequal merged blocks; nothing was written.
|
|
54
|
+
if (err_1 instanceof MergedFillSizeError) {
|
|
55
|
+
error(err_1.message);
|
|
56
|
+
return [2 /*return*/];
|
|
57
|
+
}
|
|
58
|
+
throw err_1;
|
|
59
|
+
case 4:
|
|
43
60
|
hideLoader();
|
|
44
61
|
return [7 /*endfinally*/];
|
|
45
|
-
case
|
|
62
|
+
case 5:
|
|
46
63
|
onCommand === null || onCommand === void 0 ? void 0 : onCommand({
|
|
47
64
|
command: "fill",
|
|
48
65
|
sheetId: sheetId,
|
|
@@ -50,7 +67,9 @@ export var useOnFill = function (_a) {
|
|
|
50
67
|
fillSelection: fillSelection,
|
|
51
68
|
selections: selections,
|
|
52
69
|
fillableSelections: fillableSelections,
|
|
53
|
-
fillType:
|
|
70
|
+
fillType: resolvedFillType,
|
|
71
|
+
modifier: options === null || options === void 0 ? void 0 : options.modifier,
|
|
72
|
+
series: options === null || options === void 0 ? void 0 : options.series,
|
|
54
73
|
});
|
|
55
74
|
return [2 /*return*/];
|
|
56
75
|
}
|
|
@@ -74,5 +93,7 @@ export var useOnFill = function (_a) {
|
|
|
74
93
|
onChangeDataValidations,
|
|
75
94
|
getSheetName,
|
|
76
95
|
onCommand,
|
|
96
|
+
getMerges,
|
|
97
|
+
onFillMerges,
|
|
77
98
|
]);
|
|
78
99
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CellInterface } from "@rowsncolumns/common-types";
|
|
2
|
+
import { type GoalSeekResult } from "../api/goal-seek";
|
|
3
|
+
import type { useCalculation } from "./use-calculation";
|
|
4
|
+
import type { useOnChange } from "./use-on-change";
|
|
5
|
+
import type { useSheetProperties } from "./use-sheet-properties";
|
|
6
|
+
export type { GoalSeekResult };
|
|
7
|
+
export type UseOnGoalSeekProps = {
|
|
8
|
+
getFormulaValue: ReturnType<typeof useSheetProperties>["getFormulaValue"];
|
|
9
|
+
getEffectiveValue: ReturnType<typeof useSheetProperties>["getEffectiveValue"];
|
|
10
|
+
/** The calculator's scratch evaluation (UNFORMATTED results). */
|
|
11
|
+
onRequestCalculate: ReturnType<typeof useCalculation>["onRequestCalculate"];
|
|
12
|
+
getDependents: ReturnType<typeof useCalculation>["getDependents"];
|
|
13
|
+
onChange: ReturnType<typeof useOnChange>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Excel's Goal Seek (Data → What-If Analysis): find the value of
|
|
17
|
+
* `changingCell` that makes the formula in `setCell` evaluate to
|
|
18
|
+
* `targetValue`. Every trial is a scratch evaluation — the changing cell is
|
|
19
|
+
* pinned through the calculator's override map and the formula cells between
|
|
20
|
+
* it and the set cell (its transitive dependents, in dependency order) are
|
|
21
|
+
* re-evaluated into the same map, so nothing is written until the search
|
|
22
|
+
* ends. The final value is committed through `onChange` (one undo step,
|
|
23
|
+
* streamed to any engine consumer like a typed edit).
|
|
24
|
+
*
|
|
25
|
+
* Resolves to `undefined` when the set cell holds no formula or the changing
|
|
26
|
+
* cell is protected; otherwise the {@link GoalSeekResult} — Excel reports
|
|
27
|
+
* "found a solution" / "may not have found a solution" from `status`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useOnGoalSeek: ({ getFormulaValue, getEffectiveValue, onRequestCalculate, getDependents, onChange, }: UseOnGoalSeekProps) => (sheetId: number, setCell: CellInterface, targetValue: number, changingCell: CellInterface) => Promise<GoalSeekResult | undefined>;
|
|
30
|
+
//# sourceMappingURL=use-on-goal-seek.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-on-goal-seek.d.ts","sourceRoot":"","sources":["../../../hooks/use-on-goal-seek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC1E,iBAAiB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC9E,iEAAiE;IACjE,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAC5E,aAAa,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,eAAe,CAAC,CAAC;IAClE,QAAQ,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;CAC1C,CAAC;AAUF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GAAI,sFAM3B,kBAAkB,eAKN,MAAM,WACN,aAAa,eACT,MAAM,gBACL,aAAa,KAC1B,OAAO,CAAC,cAAc,GAAG,SAAS,CA+DxC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator, __values } from "tslib";
|
|
2
|
+
import { isCellNode, makeKey } from "@rowsncolumns/dag";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { goalSeek } from "../api/goal-seek";
|
|
5
|
+
import { useCanEditCellRange } from "./use-can-edit-cellrange";
|
|
6
|
+
/** Cap on the formula chain re-evaluated per trial (a runaway dependency fan-out). */
|
|
7
|
+
var MAX_AFFECTED_CELLS = 2000;
|
|
8
|
+
var sameCell = function (a, sheetId, b) {
|
|
9
|
+
var _a;
|
|
10
|
+
return ((_a = a.sheetId) !== null && _a !== void 0 ? _a : sheetId) === sheetId &&
|
|
11
|
+
a.rowIndex === b.rowIndex &&
|
|
12
|
+
a.columnIndex === b.columnIndex;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Excel's Goal Seek (Data → What-If Analysis): find the value of
|
|
16
|
+
* `changingCell` that makes the formula in `setCell` evaluate to
|
|
17
|
+
* `targetValue`. Every trial is a scratch evaluation — the changing cell is
|
|
18
|
+
* pinned through the calculator's override map and the formula cells between
|
|
19
|
+
* it and the set cell (its transitive dependents, in dependency order) are
|
|
20
|
+
* re-evaluated into the same map, so nothing is written until the search
|
|
21
|
+
* ends. The final value is committed through `onChange` (one undo step,
|
|
22
|
+
* streamed to any engine consumer like a typed edit).
|
|
23
|
+
*
|
|
24
|
+
* Resolves to `undefined` when the set cell holds no formula or the changing
|
|
25
|
+
* cell is protected; otherwise the {@link GoalSeekResult} — Excel reports
|
|
26
|
+
* "found a solution" / "may not have found a solution" from `status`.
|
|
27
|
+
*/
|
|
28
|
+
export var useOnGoalSeek = function (_a) {
|
|
29
|
+
var getFormulaValue = _a.getFormulaValue, getEffectiveValue = _a.getEffectiveValue, onRequestCalculate = _a.onRequestCalculate, getDependents = _a.getDependents, onChange = _a.onChange;
|
|
30
|
+
var canEditCellRange = useCanEditCellRange();
|
|
31
|
+
return useCallback(function (sheetId, setCell, targetValue, changingCell) { return __awaiter(void 0, void 0, void 0, function () {
|
|
32
|
+
var formula, changingPosition, affected, _a, _b, node, position, evaluate, current, initialValue, result;
|
|
33
|
+
var e_1, _c;
|
|
34
|
+
return __generator(this, function (_d) {
|
|
35
|
+
switch (_d.label) {
|
|
36
|
+
case 0:
|
|
37
|
+
if (!Number.isFinite(targetValue))
|
|
38
|
+
return [2 /*return*/, undefined];
|
|
39
|
+
if (!canEditCellRange(sheetId, changingCell)) {
|
|
40
|
+
console.debug("This range is protected, users cannot edit this cell range.");
|
|
41
|
+
return [2 /*return*/, undefined];
|
|
42
|
+
}
|
|
43
|
+
formula = getFormulaValue(sheetId, setCell.rowIndex, setCell.columnIndex);
|
|
44
|
+
if (!formula)
|
|
45
|
+
return [2 /*return*/, undefined];
|
|
46
|
+
if (sameCell(setCell, sheetId, changingCell))
|
|
47
|
+
return [2 /*return*/, undefined];
|
|
48
|
+
changingPosition = __assign({ sheetId: sheetId }, changingCell);
|
|
49
|
+
affected = [];
|
|
50
|
+
try {
|
|
51
|
+
for (_a = __values(getDependents(changingPosition)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
52
|
+
node = _b.value;
|
|
53
|
+
if (!isCellNode(node))
|
|
54
|
+
continue;
|
|
55
|
+
position = node.position;
|
|
56
|
+
if (sameCell(position, sheetId, setCell) && position.sheetId === sheetId)
|
|
57
|
+
continue;
|
|
58
|
+
if (position.conditionalFormatId != null || position.dataValidationId != null)
|
|
59
|
+
continue;
|
|
60
|
+
affected.push(position);
|
|
61
|
+
if (affected.length >= MAX_AFFECTED_CELLS)
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
66
|
+
finally {
|
|
67
|
+
try {
|
|
68
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
69
|
+
}
|
|
70
|
+
finally { if (e_1) throw e_1.error; }
|
|
71
|
+
}
|
|
72
|
+
evaluate = function (trial) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
+
var overrides, scratch, affected_1, affected_1_1, position, cellFormula, value, e_2_1, result;
|
|
74
|
+
var e_2, _a;
|
|
75
|
+
return __generator(this, function (_b) {
|
|
76
|
+
switch (_b.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
overrides = new Map([[makeKey(changingPosition), trial]]);
|
|
79
|
+
scratch = function (text, position) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/, onRequestCalculate(text, position.sheetId, position.rowIndex, position.columnIndex, {
|
|
82
|
+
overrides: overrides,
|
|
83
|
+
disablePreview: true,
|
|
84
|
+
})];
|
|
85
|
+
});
|
|
86
|
+
}); };
|
|
87
|
+
_b.label = 1;
|
|
88
|
+
case 1:
|
|
89
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
90
|
+
affected_1 = __values(affected), affected_1_1 = affected_1.next();
|
|
91
|
+
_b.label = 2;
|
|
92
|
+
case 2:
|
|
93
|
+
if (!!affected_1_1.done) return [3 /*break*/, 5];
|
|
94
|
+
position = affected_1_1.value;
|
|
95
|
+
cellFormula = getFormulaValue(position.sheetId, position.rowIndex, position.columnIndex);
|
|
96
|
+
if (!cellFormula)
|
|
97
|
+
return [3 /*break*/, 4];
|
|
98
|
+
return [4 /*yield*/, scratch(cellFormula, position)];
|
|
99
|
+
case 3:
|
|
100
|
+
value = _b.sent();
|
|
101
|
+
// An errored intermediate reads as an error in the set cell too,
|
|
102
|
+
// which the solver treats as an unusable trial.
|
|
103
|
+
overrides.set(makeKey(position), value instanceof Error ? undefined : value);
|
|
104
|
+
_b.label = 4;
|
|
105
|
+
case 4:
|
|
106
|
+
affected_1_1 = affected_1.next();
|
|
107
|
+
return [3 /*break*/, 2];
|
|
108
|
+
case 5: return [3 /*break*/, 8];
|
|
109
|
+
case 6:
|
|
110
|
+
e_2_1 = _b.sent();
|
|
111
|
+
e_2 = { error: e_2_1 };
|
|
112
|
+
return [3 /*break*/, 8];
|
|
113
|
+
case 7:
|
|
114
|
+
try {
|
|
115
|
+
if (affected_1_1 && !affected_1_1.done && (_a = affected_1.return)) _a.call(affected_1);
|
|
116
|
+
}
|
|
117
|
+
finally { if (e_2) throw e_2.error; }
|
|
118
|
+
return [7 /*endfinally*/];
|
|
119
|
+
case 8: return [4 /*yield*/, scratch(formula, __assign({ sheetId: sheetId }, setCell))];
|
|
120
|
+
case 9:
|
|
121
|
+
result = _b.sent();
|
|
122
|
+
return [2 /*return*/, typeof result === "number" && Number.isFinite(result) ? result : undefined];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); };
|
|
126
|
+
current = getEffectiveValue(sheetId, changingCell.rowIndex, changingCell.columnIndex);
|
|
127
|
+
initialValue = typeof current === "number"
|
|
128
|
+
? current
|
|
129
|
+
: typeof current === "string" && current.trim() !== "" && Number.isFinite(Number(current))
|
|
130
|
+
? Number(current)
|
|
131
|
+
: 0;
|
|
132
|
+
return [4 /*yield*/, goalSeek({ evaluate: evaluate, targetValue: targetValue, initialValue: initialValue })];
|
|
133
|
+
case 1:
|
|
134
|
+
result = _d.sent();
|
|
135
|
+
onChange(sheetId, changingCell, String(result.value), undefined);
|
|
136
|
+
return [2 /*return*/, result];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); }, [canEditCellRange, getFormulaValue, getEffectiveValue, onRequestCalculate, getDependents, onChange]);
|
|
140
|
+
};
|