@rowsncolumns/spreadsheet 10.10.1 → 10.10.3
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/error-checking.d.ts +8 -2
- package/dist/cjs/api/error-checking.d.ts.map +1 -1
- package/dist/cjs/api/error-checking.js +23 -8
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +5 -0
- package/dist/cjs/components/formula-input/index.d.ts.map +1 -1
- package/dist/cjs/components/formula-input/index.js +7 -3
- package/dist/cjs/components/outline-gutter/index.d.ts +25 -8
- package/dist/cjs/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/cjs/components/outline-gutter/index.js +108 -85
- package/dist/cjs/release-date.js +1 -1
- package/dist/esm/api/error-checking.d.ts +8 -2
- package/dist/esm/api/error-checking.d.ts.map +1 -1
- package/dist/esm/api/error-checking.js +19 -6
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +3 -0
- package/dist/esm/components/formula-input/index.d.ts.map +1 -1
- package/dist/esm/components/formula-input/index.js +8 -4
- package/dist/esm/components/outline-gutter/index.d.ts +25 -8
- package/dist/esm/components/outline-gutter/index.d.ts.map +1 -1
- package/dist/esm/components/outline-gutter/index.js +68 -56
- package/dist/esm/release-date.js +1 -1
- package/package.json +2 -2
|
@@ -16,6 +16,11 @@ export declare const parseNumberStoredAsText: (text: string | null | undefined)
|
|
|
16
16
|
export type ErrorCheckInput = {
|
|
17
17
|
/** What the user typed (`uev`): a formula, a number, a string, … */
|
|
18
18
|
userEnteredValue: ExtendedValue | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The cell's value (`ev`). A typed number keeps what was typed in `uev.sv` and its number here,
|
|
21
|
+
* in `ev.nv`, so this tells text from a number. Without it, `userEnteredValue` decides.
|
|
22
|
+
*/
|
|
23
|
+
effectiveValue?: ExtendedValue | null;
|
|
19
24
|
/** The cell's error, if its effective value is one. */
|
|
20
25
|
errorValue: ErrorValue | null | undefined;
|
|
21
26
|
};
|
|
@@ -24,7 +29,7 @@ export type ErrorCheckInput = {
|
|
|
24
29
|
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
25
30
|
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
26
31
|
*/
|
|
27
|
-
export declare const getErrorCheckKind: ({ userEnteredValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
|
|
32
|
+
export declare const getErrorCheckKind: ({ userEnteredValue, effectiveValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
|
|
28
33
|
/** What the error-checking smart tag's menu can do. */
|
|
29
34
|
export type ErrorCheckOption = "convertToNumber" | "help" | "ignore" | "editInFormulaBar" | "options";
|
|
30
35
|
/** The menu's heading, as Excel words it. */
|
|
@@ -49,7 +54,7 @@ export type NumberRun = {
|
|
|
49
54
|
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
50
55
|
* only the used rows.
|
|
51
56
|
*/
|
|
52
|
-
export declare const collectNumberStoredAsTextRuns: (ranges: GridRange[], getUserEnteredValue: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined, maxRow: number, maxColumn: number) => NumberRun[];
|
|
57
|
+
export declare const collectNumberStoredAsTextRuns: (ranges: GridRange[], getUserEnteredValue: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined, maxRow: number, maxColumn: number, getEffectiveValue?: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined) => NumberRun[];
|
|
53
58
|
export type ErrorCheckActionContext = {
|
|
54
59
|
sheetId: number;
|
|
55
60
|
kind: ErrorCheckKind;
|
|
@@ -57,6 +62,7 @@ export type ErrorCheckActionContext = {
|
|
|
57
62
|
/** The selection's ranges (the active cell's when nothing else is selected). */
|
|
58
63
|
ranges: GridRange[];
|
|
59
64
|
getUserEnteredValue(rowIndex: number, columnIndex: number): ExtendedValue | null | undefined;
|
|
65
|
+
getEffectiveValue?(rowIndex: number, columnIndex: number): ExtendedValue | null | undefined;
|
|
60
66
|
/** The sheet's data extent: Convert to Number scans no further. */
|
|
61
67
|
maxRow: number;
|
|
62
68
|
maxColumn: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-checking.d.ts","sourceRoot":"","sources":["../../../api/error-checking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAShE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,KAC9B,MAAM,GAAG,SAQX,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,gBAAgB,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,uDAAuD;IACvD,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,CAAC;
|
|
1
|
+
{"version":3,"file":"error-checking.d.ts","sourceRoot":"","sources":["../../../api/error-checking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAShE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,KAC9B,MAAM,GAAG,SAQX,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,gBAAgB,EAAE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EF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,gBAAgB,EACxB,SAAS,uBAAuB,SAkDjC,CAAC"}
|
|
@@ -24,19 +24,30 @@ var parseNumberStoredAsText = function (text) {
|
|
|
24
24
|
return isPercent ? value / 100 : value;
|
|
25
25
|
};
|
|
26
26
|
exports.parseNumberStoredAsText = parseNumberStoredAsText;
|
|
27
|
+
/**
|
|
28
|
+
* The text a cell's value is, or `undefined` when its value is not text: `ev.sv` when the cell has
|
|
29
|
+
* an effective value (a number typed into a Text-formatted cell, or after an apostrophe, is text
|
|
30
|
+
* there), else `uev.sv`.
|
|
31
|
+
*/
|
|
32
|
+
var getCellText = function (userEnteredValue, effectiveValue) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
return effectiveValue
|
|
35
|
+
? ((_a = effectiveValue.sv) !== null && _a !== void 0 ? _a : effectiveValue.stringValue)
|
|
36
|
+
: ((_b = userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.sv) !== null && _b !== void 0 ? _b : userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.stringValue);
|
|
37
|
+
};
|
|
27
38
|
/**
|
|
28
39
|
* Which error-checking rule (if any) flags this cell, before ignored errors are applied.
|
|
29
40
|
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
30
41
|
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
31
42
|
*/
|
|
32
43
|
var getErrorCheckKind = function (_a) {
|
|
33
|
-
var _b
|
|
34
|
-
var userEnteredValue = _a.userEnteredValue, errorValue = _a.errorValue;
|
|
44
|
+
var _b;
|
|
45
|
+
var userEnteredValue = _a.userEnteredValue, effectiveValue = _a.effectiveValue, errorValue = _a.errorValue;
|
|
35
46
|
var formula = (_b = userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.fv) !== null && _b !== void 0 ? _b : userEnteredValue === null || userEnteredValue === void 0 ? void 0 : userEnteredValue.formulaValue;
|
|
36
47
|
if (formula) {
|
|
37
48
|
return (errorValue === null || errorValue === void 0 ? void 0 : errorValue.type) === "Error" ? "evalError" : undefined;
|
|
38
49
|
}
|
|
39
|
-
var text = (
|
|
50
|
+
var text = getCellText(userEnteredValue, effectiveValue);
|
|
40
51
|
if ((0, exports.parseNumberStoredAsText)(text) !== undefined)
|
|
41
52
|
return "numberStoredAsText";
|
|
42
53
|
return undefined;
|
|
@@ -102,9 +113,8 @@ exports.appendIgnoredError = appendIgnoredError;
|
|
|
102
113
|
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
103
114
|
* only the used rows.
|
|
104
115
|
*/
|
|
105
|
-
var collectNumberStoredAsTextRuns = function (ranges, getUserEnteredValue, maxRow, maxColumn) {
|
|
116
|
+
var collectNumberStoredAsTextRuns = function (ranges, getUserEnteredValue, maxRow, maxColumn, getEffectiveValue) {
|
|
106
117
|
var e_1, _a;
|
|
107
|
-
var _b;
|
|
108
118
|
var runs = [];
|
|
109
119
|
var seen = new Set();
|
|
110
120
|
try {
|
|
@@ -117,10 +127,15 @@ var collectNumberStoredAsTextRuns = function (ranges, getUserEnteredValue, maxRo
|
|
|
117
127
|
for (var col = range.startColumnIndex; col <= endColumn; col++) {
|
|
118
128
|
var key = "".concat(row, ":").concat(col);
|
|
119
129
|
var uev = seen.has(key) ? null : getUserEnteredValue(row, col);
|
|
130
|
+
var ev = seen.has(key) ? null : getEffectiveValue === null || getEffectiveValue === void 0 ? void 0 : getEffectiveValue(row, col);
|
|
120
131
|
seen.add(key);
|
|
121
|
-
var kind = (0, exports.getErrorCheckKind)({
|
|
132
|
+
var kind = (0, exports.getErrorCheckKind)({
|
|
133
|
+
userEnteredValue: uev,
|
|
134
|
+
effectiveValue: ev,
|
|
135
|
+
errorValue: null,
|
|
136
|
+
});
|
|
122
137
|
var value = kind === "numberStoredAsText"
|
|
123
|
-
? (0, exports.parseNumberStoredAsText)((
|
|
138
|
+
? (0, exports.parseNumberStoredAsText)(getCellText(uev, ev))
|
|
124
139
|
: undefined;
|
|
125
140
|
if (value === undefined) {
|
|
126
141
|
run = null;
|
|
@@ -157,7 +172,7 @@ var runErrorCheckOption = function (option, context) {
|
|
|
157
172
|
var sheetId = context.sheetId, kind = context.kind, ranges = context.ranges;
|
|
158
173
|
switch (option) {
|
|
159
174
|
case "convertToNumber": {
|
|
160
|
-
var runs_1 = (0, exports.collectNumberStoredAsTextRuns)(ranges, context.getUserEnteredValue, context.maxRow, context.maxColumn);
|
|
175
|
+
var runs_1 = (0, exports.collectNumberStoredAsTextRuns)(ranges, context.getUserEnteredValue, context.maxRow, context.maxColumn, context.getEffectiveValue);
|
|
161
176
|
if (!runs_1.length)
|
|
162
177
|
return;
|
|
163
178
|
var write = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAgkOnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
|
|
@@ -1203,6 +1203,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1203
1203
|
var getErrorCheck = (0, react_1.useCallback)(function (targetSheetId, rowIndex, columnIndex) {
|
|
1204
1204
|
var kind = (0, error_checking_1.getErrorCheckKind)({
|
|
1205
1205
|
userEnteredValue: getUserEnteredValue(targetSheetId, rowIndex, columnIndex),
|
|
1206
|
+
effectiveValue: getEffectiveValue(targetSheetId, rowIndex, columnIndex),
|
|
1206
1207
|
errorValue: getErrorValue(targetSheetId, rowIndex, columnIndex),
|
|
1207
1208
|
});
|
|
1208
1209
|
if (kind &&
|
|
@@ -1214,6 +1215,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1214
1215
|
return kind;
|
|
1215
1216
|
}, [
|
|
1216
1217
|
getUserEnteredValue,
|
|
1218
|
+
getEffectiveValue,
|
|
1217
1219
|
getErrorValue,
|
|
1218
1220
|
getIgnoredErrorsStable,
|
|
1219
1221
|
stableIgnoredErrors,
|
|
@@ -3795,6 +3797,9 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3795
3797
|
getUserEnteredValue: function (rowIndex, columnIndex) {
|
|
3796
3798
|
return getUserEnteredValue(sheetId, rowIndex, columnIndex);
|
|
3797
3799
|
},
|
|
3800
|
+
getEffectiveValue: function (rowIndex, columnIndex) {
|
|
3801
|
+
return getEffectiveValue(sheetId, rowIndex, columnIndex);
|
|
3802
|
+
},
|
|
3798
3803
|
maxRow: (_a = getDataRowCount === null || getDataRowCount === void 0 ? void 0 : getDataRowCount(sheetId)) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER,
|
|
3799
3804
|
maxColumn: (_b = getDataColumnCount === null || getDataColumnCount === void 0 ? void 0 : getDataColumnCount(sheetId)) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER,
|
|
3800
3805
|
getIgnoredErrors: getIgnoredErrors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAIrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGAyLxB,CAAC"}
|
|
@@ -4,9 +4,11 @@ exports.FormulaInput = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var ui_1 = require("@rowsncolumns/ui");
|
|
6
6
|
var utils_1 = require("@rowsncolumns/utils");
|
|
7
|
+
var jotai_1 = require("jotai");
|
|
7
8
|
var react_1 = require("react");
|
|
8
9
|
var react_2 = tslib_1.__importStar(require("react"));
|
|
9
10
|
var atoms_1 = require("../../atoms");
|
|
11
|
+
var active_editor_atom_1 = require("../../atoms/active-editor.atom");
|
|
10
12
|
var cell_input_context_atom_1 = require("../../atoms/cell-input-context.atom");
|
|
11
13
|
var use_isomorphic_layout_effect_1 = require("../../hooks/use-isomorphic-layout-effect");
|
|
12
14
|
var use_merge_refs_1 = require("../../hooks/use-merge.refs");
|
|
@@ -22,7 +24,7 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
|
|
|
22
24
|
var editorRef = (0, react_2.useRef)(null);
|
|
23
25
|
var _d = tslib_1.__read((0, atoms_1.useFormulaMode)(), 2), isFormulaMode = _d[0], setFormulaMode = _d[1];
|
|
24
26
|
var setFormulaSelections = (0, atoms_1.useSetFormulaSelections)();
|
|
25
|
-
var
|
|
27
|
+
var store = (0, jotai_1.useStore)();
|
|
26
28
|
var setActiveEditor = (0, atoms_1.useSetActiveEditor)();
|
|
27
29
|
var getSelectionsFromFormula = (0, atoms_1.useGetSelectionsFromFormula)();
|
|
28
30
|
var onEditorKeyDown = (0, atoms_1.useOnEditorKeyDown)();
|
|
@@ -117,7 +119,9 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
|
|
|
117
119
|
}, [closeFormulaMode, isFormulaMode, setActiveEditor, onCancel, getGridRef, onBlur]);
|
|
118
120
|
var handleChange = (0, react_1.useCallback)(function (value, textFormatRuns) {
|
|
119
121
|
onChange === null || onChange === void 0 ? void 0 : onChange(value, textFormatRuns);
|
|
120
|
-
// Prevent selecting when there is no active editor
|
|
122
|
+
// Prevent selecting when there is no active editor. Read it from the store, not the
|
|
123
|
+
// render: a blur clears it, and ProseMirror's blur transaction then lands here.
|
|
124
|
+
var activeEditor = store.get(active_editor_atom_1.activeEditorAtom);
|
|
121
125
|
if (!activeEditor || activeEditor !== editorRef.current) {
|
|
122
126
|
return;
|
|
123
127
|
}
|
|
@@ -129,7 +133,7 @@ exports.FormulaInput = (0, react_1.forwardRef)(function (_a, forwardedRef) {
|
|
|
129
133
|
setFormulaSelections(selections);
|
|
130
134
|
}
|
|
131
135
|
}, [
|
|
132
|
-
|
|
136
|
+
store,
|
|
133
137
|
onChange,
|
|
134
138
|
enterFormulaMode,
|
|
135
139
|
setFormulaSelections,
|
|
@@ -2,7 +2,22 @@ import React from "react";
|
|
|
2
2
|
import { COLUMN_HEADER_HEIGHT, ROW_HEADER_WIDTH } from "../../config";
|
|
3
3
|
import type { DimensionProperties } from "../../types";
|
|
4
4
|
type DimensionMetadata = (DimensionProperties | null | undefined)[] | null | undefined;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The grid's sizing, which the gutters need to line up with the canvas.
|
|
7
|
+
* Pass the same values given to `CanvasGrid`; every one defaults to the
|
|
8
|
+
* grid's own default.
|
|
9
|
+
*/
|
|
10
|
+
export type OutlineGutterSizingProps = {
|
|
11
|
+
defaultColumnWidth?: number;
|
|
12
|
+
defaultRowHeight?: number;
|
|
13
|
+
rowHeaderWidth?: number;
|
|
14
|
+
columnHeaderHeight?: number;
|
|
15
|
+
/** `false` when the grid hides its row and column headers. */
|
|
16
|
+
showHeaders?: boolean;
|
|
17
|
+
/** The grid's zoom (`CanvasGrid` `scale`). */
|
|
18
|
+
scale?: number;
|
|
19
|
+
};
|
|
20
|
+
export type ColumnOutlineGutterProps = OutlineGutterSizingProps & {
|
|
6
21
|
sheetId: number;
|
|
7
22
|
columnMetadata?: DimensionMetadata;
|
|
8
23
|
/** Row metadata for the same sheet. Used to compute the row outline
|
|
@@ -11,25 +26,27 @@ export type ColumnOutlineGutterProps = {
|
|
|
11
26
|
rowMetadata?: DimensionMetadata;
|
|
12
27
|
/** True when summaries sit right of the group (Excel default). */
|
|
13
28
|
summaryRight?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
/** `level` is the outline level of the group whose button was pressed. */
|
|
30
|
+
onCollapseColumnGroup?(sheetId: number, summaryColumnIndex: number, level?: number): void;
|
|
31
|
+
onExpandColumnGroup?(sheetId: number, summaryColumnIndex: number, level?: number): void;
|
|
16
32
|
/** Excel-style level selector. Renders N+1 numbered buttons in the
|
|
17
33
|
* gutter's leftInset area. */
|
|
18
34
|
onSetOutlineDepth?(sheetId: number, axis: "row" | "column", depth: number): void;
|
|
19
35
|
};
|
|
20
|
-
export declare const ColumnOutlineGutter: React.MemoExoticComponent<({ sheetId, columnMetadata, rowMetadata, summaryRight, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, }: ColumnOutlineGutterProps) => React.JSX.Element | null>;
|
|
21
|
-
export type RowOutlineGutterProps = {
|
|
36
|
+
export declare const ColumnOutlineGutter: React.MemoExoticComponent<({ sheetId, columnMetadata, rowMetadata, summaryRight, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, defaultColumnWidth, rowHeaderWidth, showHeaders, scale, }: ColumnOutlineGutterProps) => React.JSX.Element | null>;
|
|
37
|
+
export type RowOutlineGutterProps = OutlineGutterSizingProps & {
|
|
22
38
|
sheetId: number;
|
|
23
39
|
rowMetadata?: DimensionMetadata;
|
|
24
40
|
/** True when summaries sit below the group (Excel default). */
|
|
25
41
|
summaryBelow?: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
/** `level` is the outline level of the group whose button was pressed. */
|
|
43
|
+
onCollapseRowGroup?(sheetId: number, summaryRowIndex: number, level?: number): void;
|
|
44
|
+
onExpandRowGroup?(sheetId: number, summaryRowIndex: number, level?: number): void;
|
|
28
45
|
/** Excel-style level selector. Renders N+1 numbered buttons at the
|
|
29
46
|
* top of the row gutter strip (in the topInset area). */
|
|
30
47
|
onSetOutlineDepth?(sheetId: number, axis: "row" | "column", depth: number): void;
|
|
31
48
|
};
|
|
32
|
-
export declare const RowOutlineGutter: React.MemoExoticComponent<({ sheetId, rowMetadata, summaryBelow, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, }: RowOutlineGutterProps) => React.JSX.Element | null>;
|
|
49
|
+
export declare const RowOutlineGutter: React.MemoExoticComponent<({ sheetId, rowMetadata, summaryBelow, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, defaultRowHeight, columnHeaderHeight, showHeaders, scale, }: RowOutlineGutterProps) => React.JSX.Element | null>;
|
|
33
50
|
/**
|
|
34
51
|
* Pixel width / height the outline gutter will reserve for the given
|
|
35
52
|
* axis. Returns 0 when the metadata has no `outlineLevel > 0`. Use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,EACL,oBAAoB,EAKpB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAwDvD,KAAK,iBAAiB,GAClB,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,IAAI,GACJ,SAAS,CAAC;AAgId;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAkBF,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC;;wEAEoE;IACpE,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,kEAAkE;IAClE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0EAA0E;IAC1E,qBAAqB,CAAC,CACpB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,EAC1B,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR,mBAAmB,CAAC,CAClB,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,MAAM,EAC1B,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR;kCAC8B;IAC9B,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,mBAAmB,6MAa3B,wBAAwB,8BAuN5B,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,GAAG;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0EAA0E;IAC1E,kBAAkB,CAAC,CACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR,gBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR;6DACyD;IACzD,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,gBAAgB,yLAYxB,qBAAqB,8BAwMzB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,KACtE,MAIF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
//
|
|
17
17
|
// Buttons are positioned by `getRowOffset` / `getColumnOffset` so they
|
|
18
18
|
// stay aligned with the cell their summary lives on; scroll position
|
|
19
|
-
// shifts the buttons horizontally / vertically.
|
|
19
|
+
// shifts the buttons horizontally / vertically. Those offsets have to
|
|
20
|
+
// use the grid's own sizing (default sizes, header sizes, zoom), so the
|
|
21
|
+
// host passes the same values it gives `CanvasGrid` — see
|
|
22
|
+
// `OutlineGutterSizingProps`.
|
|
20
23
|
//
|
|
21
24
|
// Bracket lines and the "1 / 2 / 3" level bar are intentionally minimal
|
|
22
25
|
// here — the goal is a functional MVP. Polish can layer on later.
|
|
@@ -156,12 +159,80 @@ var findSummaries = function (metadata, summaryAfter) {
|
|
|
156
159
|
}
|
|
157
160
|
return out;
|
|
158
161
|
};
|
|
162
|
+
var resolveSharedSummaries = function (summaries, metadata, summaryAfter) {
|
|
163
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
164
|
+
var _d;
|
|
165
|
+
var levelsAtIndex = new Map();
|
|
166
|
+
try {
|
|
167
|
+
for (var summaries_1 = tslib_1.__values(summaries), summaries_1_1 = summaries_1.next(); !summaries_1_1.done; summaries_1_1 = summaries_1.next()) {
|
|
168
|
+
var s = summaries_1_1.value;
|
|
169
|
+
levelsAtIndex.set(s.index, ((_d = levelsAtIndex.get(s.index)) !== null && _d !== void 0 ? _d : 0) + 1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
173
|
+
finally {
|
|
174
|
+
try {
|
|
175
|
+
if (summaries_1_1 && !summaries_1_1.done && (_a = summaries_1.return)) _a.call(summaries_1);
|
|
176
|
+
}
|
|
177
|
+
finally { if (e_1) throw e_1.error; }
|
|
178
|
+
}
|
|
179
|
+
var resolved = summaries.map(function (s) {
|
|
180
|
+
var _a, _b;
|
|
181
|
+
if (((_a = levelsAtIndex.get(s.index)) !== null && _a !== void 0 ? _a : 0) < 2) {
|
|
182
|
+
return tslib_1.__assign(tslib_1.__assign({}, s), { showButton: true, shared: false });
|
|
183
|
+
}
|
|
184
|
+
var _c = tslib_1.__read(summaryAfter
|
|
185
|
+
? [s.startIndex, s.index - 1]
|
|
186
|
+
: [s.index + 1, s.startIndex], 2), from = _c[0], to = _c[1];
|
|
187
|
+
var collapsed = to >= from;
|
|
188
|
+
for (var c = from; c <= to && collapsed; c++) {
|
|
189
|
+
if (!((_b = metadata === null || metadata === void 0 ? void 0 : metadata[c]) === null || _b === void 0 ? void 0 : _b.hiddenByGroup))
|
|
190
|
+
collapsed = false;
|
|
191
|
+
}
|
|
192
|
+
return tslib_1.__assign(tslib_1.__assign({}, s), { collapsed: collapsed, showButton: true, shared: true });
|
|
193
|
+
});
|
|
194
|
+
var collapsedLevelAtIndex = new Map();
|
|
195
|
+
try {
|
|
196
|
+
for (var resolved_1 = tslib_1.__values(resolved), resolved_1_1 = resolved_1.next(); !resolved_1_1.done; resolved_1_1 = resolved_1.next()) {
|
|
197
|
+
var s = resolved_1_1.value;
|
|
198
|
+
if (!s.collapsed)
|
|
199
|
+
continue;
|
|
200
|
+
var prev = collapsedLevelAtIndex.get(s.index);
|
|
201
|
+
if (prev === undefined || s.level < prev) {
|
|
202
|
+
collapsedLevelAtIndex.set(s.index, s.level);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
207
|
+
finally {
|
|
208
|
+
try {
|
|
209
|
+
if (resolved_1_1 && !resolved_1_1.done && (_b = resolved_1.return)) _b.call(resolved_1);
|
|
210
|
+
}
|
|
211
|
+
finally { if (e_2) throw e_2.error; }
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
for (var resolved_2 = tslib_1.__values(resolved), resolved_2_1 = resolved_2.next(); !resolved_2_1.done; resolved_2_1 = resolved_2.next()) {
|
|
215
|
+
var s = resolved_2_1.value;
|
|
216
|
+
var outer = collapsedLevelAtIndex.get(s.index);
|
|
217
|
+
if (outer !== undefined && s.level > outer)
|
|
218
|
+
s.showButton = false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
222
|
+
finally {
|
|
223
|
+
try {
|
|
224
|
+
if (resolved_2_1 && !resolved_2_1.done && (_c = resolved_2.return)) _c.call(resolved_2);
|
|
225
|
+
}
|
|
226
|
+
finally { if (e_3) throw e_3.error; }
|
|
227
|
+
}
|
|
228
|
+
return resolved;
|
|
229
|
+
};
|
|
159
230
|
/**
|
|
160
231
|
* Walk a sparse `DimensionProperties` array once and report the
|
|
161
232
|
* largest `outlineLevel` seen. Returns 0 when no grouping is in use.
|
|
162
233
|
*/
|
|
163
234
|
var computeMaxOutlineLevel = function (metadata) {
|
|
164
|
-
var
|
|
235
|
+
var e_4, _a;
|
|
165
236
|
var _b;
|
|
166
237
|
if (!(metadata === null || metadata === void 0 ? void 0 : metadata.length))
|
|
167
238
|
return 0;
|
|
@@ -174,60 +245,36 @@ var computeMaxOutlineLevel = function (metadata) {
|
|
|
174
245
|
max = level;
|
|
175
246
|
}
|
|
176
247
|
}
|
|
177
|
-
catch (
|
|
248
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
178
249
|
finally {
|
|
179
250
|
try {
|
|
180
251
|
if (metadata_1_1 && !metadata_1_1.done && (_a = metadata_1.return)) _a.call(metadata_1);
|
|
181
252
|
}
|
|
182
|
-
finally { if (
|
|
253
|
+
finally { if (e_4) throw e_4.error; }
|
|
183
254
|
}
|
|
184
255
|
return max;
|
|
185
256
|
};
|
|
186
257
|
exports.ColumnOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
187
|
-
var sheetId = _a.sheetId, columnMetadata = _a.columnMetadata, rowMetadata = _a.rowMetadata, _b = _a.summaryRight, summaryRight = _b === void 0 ? true : _b, onCollapseColumnGroup = _a.onCollapseColumnGroup, onExpandColumnGroup = _a.onExpandColumnGroup, onSetOutlineDepth = _a.onSetOutlineDepth;
|
|
258
|
+
var sheetId = _a.sheetId, columnMetadata = _a.columnMetadata, rowMetadata = _a.rowMetadata, _b = _a.summaryRight, summaryRight = _b === void 0 ? true : _b, onCollapseColumnGroup = _a.onCollapseColumnGroup, onExpandColumnGroup = _a.onExpandColumnGroup, onSetOutlineDepth = _a.onSetOutlineDepth, _c = _a.defaultColumnWidth, defaultColumnWidth = _c === void 0 ? config_1.DEFAULT_COLUMN_WIDTH : _c, _d = _a.rowHeaderWidth, rowHeaderWidth = _d === void 0 ? config_1.ROW_HEADER_WIDTH : _d, _e = _a.showHeaders, showHeaders = _e === void 0 ? true : _e, _f = _a.scale, scale = _f === void 0 ? 1 : _f;
|
|
188
259
|
// Shift the strip right by the row outline gutter's width when one
|
|
189
260
|
// exists, so the strip's content lines up with the canvas (which
|
|
190
261
|
// sits to the right of the row gutter).
|
|
191
262
|
var leftInset = (0, react_1.useMemo)(function () { return (0, exports.computeOutlineGutterSize)(rowMetadata); }, [rowMetadata]);
|
|
192
263
|
var maxColumnOutlineLevel = (0, react_1.useMemo)(function () { return computeMaxOutlineLevel(columnMetadata); }, [columnMetadata]);
|
|
193
|
-
var columnOffsets = (0, react_1.useMemo)(function () { return (0, offsets_1.buildOffsetIndex)(columnMetadata,
|
|
264
|
+
var columnOffsets = (0, react_1.useMemo)(function () { return (0, offsets_1.buildOffsetIndex)(columnMetadata, defaultColumnWidth); }, [columnMetadata, defaultColumnWidth]);
|
|
265
|
+
// The canvas draws every size (headers included) times its zoom, and
|
|
266
|
+
// its scroll position is in those scaled pixels.
|
|
267
|
+
var headerWidth = showHeaders ? rowHeaderWidth : 0;
|
|
194
268
|
var getColumnOffset = (0, react_1.useCallback)(function (columnIndex) {
|
|
195
|
-
return (0, offsets_1.offsetAt)(columnOffsets, columnIndex) +
|
|
196
|
-
}, [columnOffsets]);
|
|
269
|
+
return ((0, offsets_1.offsetAt)(columnOffsets, columnIndex) + headerWidth) * scale;
|
|
270
|
+
}, [columnOffsets, headerWidth, scale]);
|
|
197
271
|
var scrollLeft = useGridScrollPosition().scrollLeft;
|
|
198
|
-
var
|
|
272
|
+
var _g = tslib_1.__read((0, use_resize_observer_1.useResizeObserver)(), 2), stripRef = _g[0], stripRect = _g[1];
|
|
199
273
|
var summaries = (0, react_1.useMemo)(function () {
|
|
200
274
|
return maxColumnOutlineLevel > 0
|
|
201
|
-
? findSummaries(columnMetadata, summaryRight)
|
|
275
|
+
? resolveSharedSummaries(findSummaries(columnMetadata, summaryRight), columnMetadata, summaryRight)
|
|
202
276
|
: [];
|
|
203
277
|
}, [columnMetadata, maxColumnOutlineLevel, summaryRight]);
|
|
204
|
-
// When nested groups share the same summary cell (common with
|
|
205
|
-
// `summaryRight=true`: outer and inner end at the same column), we
|
|
206
|
-
// render the bracket for every level but only the OUTERMOST
|
|
207
|
-
// (lowest level number) gets a +/- button — matches Excel.
|
|
208
|
-
// Granular collapse of inner groups uses the level-selector
|
|
209
|
-
// buttons instead.
|
|
210
|
-
var buttonLevelForIndex = (0, react_1.useMemo)(function () {
|
|
211
|
-
var e_2, _a;
|
|
212
|
-
var m = new Map();
|
|
213
|
-
try {
|
|
214
|
-
for (var summaries_1 = tslib_1.__values(summaries), summaries_1_1 = summaries_1.next(); !summaries_1_1.done; summaries_1_1 = summaries_1.next()) {
|
|
215
|
-
var s = summaries_1_1.value;
|
|
216
|
-
var existing = m.get(s.index);
|
|
217
|
-
if (existing === undefined || s.level < existing) {
|
|
218
|
-
m.set(s.index, s.level);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
223
|
-
finally {
|
|
224
|
-
try {
|
|
225
|
-
if (summaries_1_1 && !summaries_1_1.done && (_a = summaries_1.return)) _a.call(summaries_1);
|
|
226
|
-
}
|
|
227
|
-
finally { if (e_2) throw e_2.error; }
|
|
228
|
-
}
|
|
229
|
-
return m;
|
|
230
|
-
}, [summaries]);
|
|
231
278
|
if (maxColumnOutlineLevel <= 0)
|
|
232
279
|
return null;
|
|
233
280
|
// N+1 level-selector buttons. `depth=1` collapses every group;
|
|
@@ -239,15 +286,14 @@ exports.ColumnOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
239
286
|
// Summary +/- buttons, the bracket line, and dots all get clipped
|
|
240
287
|
// to this boundary so they never bleed into the level-selector
|
|
241
288
|
// lane or the row-header column above the grid.
|
|
242
|
-
var summaryMinX = leftInset +
|
|
289
|
+
var summaryMinX = leftInset + headerWidth * scale;
|
|
243
290
|
// Right edge of the strip in its own coord space. Anything past it
|
|
244
291
|
// is clipped by `overflow-hidden`, so it is never rendered.
|
|
245
292
|
var viewportMaxX = leftInset +
|
|
246
293
|
resolveViewportSize(stripRect.width, typeof window === "undefined" ? undefined : window.innerWidth);
|
|
247
294
|
// Columns intersecting the strip, for the per-column dots.
|
|
248
|
-
var firstVisibleColumn = Math.max(1, (0, offsets_1.cellAtOffset)(columnOffsets, scrollLeft) - OVERSCAN_CELLS);
|
|
249
|
-
var lastVisibleColumn = (0, offsets_1.cellAtOffset)(columnOffsets, scrollLeft + viewportMaxX - summaryMinX) +
|
|
250
|
-
OVERSCAN_CELLS;
|
|
295
|
+
var firstVisibleColumn = Math.max(1, (0, offsets_1.cellAtOffset)(columnOffsets, scrollLeft / scale) - OVERSCAN_CELLS);
|
|
296
|
+
var lastVisibleColumn = (0, offsets_1.cellAtOffset)(columnOffsets, (scrollLeft + viewportMaxX - summaryMinX) / scale) + OVERSCAN_CELLS;
|
|
251
297
|
return (react_1.default.createElement("div", { ref: stripRef, "data-testid": "column-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-l border-r border-r-rnc-border border-l-rnc-border border-solid border-t-rnc-border border-t border-b-0", style: {
|
|
252
298
|
height: gutterHeight,
|
|
253
299
|
paddingLeft: leftInset,
|
|
@@ -261,7 +307,7 @@ exports.ColumnOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
261
307
|
onSetOutlineDepth === null || onSetOutlineDepth === void 0 ? void 0 : onSetOutlineDepth(sheetId, "column", depth);
|
|
262
308
|
} }, depth)); })),
|
|
263
309
|
summaries.map(function (_a) {
|
|
264
|
-
var index = _a.index, startIndex = _a.startIndex, collapsed = _a.collapsed, level = _a.level;
|
|
310
|
+
var index = _a.index, startIndex = _a.startIndex, collapsed = _a.collapsed, level = _a.level, showButton = _a.showButton, shared = _a.shared;
|
|
265
311
|
// Anchor positions inside the cell area; add `leftInset` so
|
|
266
312
|
// x=0 of the strip lines up with the grid's content origin.
|
|
267
313
|
var buttonX = getColumnOffset(index) - scrollLeft + leftInset;
|
|
@@ -324,57 +370,36 @@ exports.ColumnOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
324
370
|
top: lineCenterY + 3,
|
|
325
371
|
} }));
|
|
326
372
|
}))) : null,
|
|
327
|
-
showSummary &&
|
|
328
|
-
? "Expand column group at ".concat(index)
|
|
329
|
-
: "Collapse column group at ".concat(index), size: "xs", variant: "outline", className: "absolute p-0 min-w-0 min-h-0", style: {
|
|
373
|
+
showSummary && showButton ? (react_1.default.createElement(ui_1.Button, { "aria-label": "".concat(collapsed ? "Expand" : "Collapse", " column group at ").concat(index).concat(shared ? " level ".concat(level) : ""), size: "xs", variant: "outline", className: "absolute p-0 min-w-0 min-h-0", style: {
|
|
330
374
|
left: buttonX,
|
|
331
375
|
top: y,
|
|
332
376
|
}, onClick: function (e) {
|
|
333
377
|
e.stopPropagation();
|
|
334
378
|
if (collapsed)
|
|
335
|
-
onExpandColumnGroup === null || onExpandColumnGroup === void 0 ? void 0 : onExpandColumnGroup(sheetId, index);
|
|
379
|
+
onExpandColumnGroup === null || onExpandColumnGroup === void 0 ? void 0 : onExpandColumnGroup(sheetId, index, level);
|
|
336
380
|
else
|
|
337
|
-
onCollapseColumnGroup === null || onCollapseColumnGroup === void 0 ? void 0 : onCollapseColumnGroup(sheetId, index);
|
|
381
|
+
onCollapseColumnGroup === null || onCollapseColumnGroup === void 0 ? void 0 : onCollapseColumnGroup(sheetId, index, level);
|
|
338
382
|
} }, collapsed ? (react_1.default.createElement(icons_1.PlusIcon, { className: "w-3 h-3" })) : (react_1.default.createElement(icons_1.MinusIcon, { className: "w-3 h-3" })))) : null));
|
|
339
383
|
})));
|
|
340
384
|
});
|
|
341
385
|
exports.ColumnOutlineGutter.displayName = "ColumnOutlineGutter";
|
|
342
386
|
exports.RowOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
343
|
-
var sheetId = _a.sheetId, rowMetadata = _a.rowMetadata, _b = _a.summaryBelow, summaryBelow = _b === void 0 ? true : _b, onCollapseRowGroup = _a.onCollapseRowGroup, onExpandRowGroup = _a.onExpandRowGroup, onSetOutlineDepth = _a.onSetOutlineDepth;
|
|
387
|
+
var sheetId = _a.sheetId, rowMetadata = _a.rowMetadata, _b = _a.summaryBelow, summaryBelow = _b === void 0 ? true : _b, onCollapseRowGroup = _a.onCollapseRowGroup, onExpandRowGroup = _a.onExpandRowGroup, onSetOutlineDepth = _a.onSetOutlineDepth, _c = _a.defaultRowHeight, defaultRowHeight = _c === void 0 ? config_1.DEFAULT_ROW_HEIGHT : _c, _d = _a.columnHeaderHeight, columnHeaderHeight = _d === void 0 ? config_1.COLUMN_HEADER_HEIGHT : _d, _e = _a.showHeaders, showHeaders = _e === void 0 ? true : _e, _f = _a.scale, scale = _f === void 0 ? 1 : _f;
|
|
344
388
|
var topInset = 0;
|
|
345
389
|
var maxRowOutlineLevel = (0, react_1.useMemo)(function () { return computeMaxOutlineLevel(rowMetadata); }, [rowMetadata]);
|
|
346
|
-
var rowOffsets = (0, react_1.useMemo)(function () { return (0, offsets_1.buildOffsetIndex)(rowMetadata,
|
|
390
|
+
var rowOffsets = (0, react_1.useMemo)(function () { return (0, offsets_1.buildOffsetIndex)(rowMetadata, defaultRowHeight); }, [rowMetadata, defaultRowHeight]);
|
|
391
|
+
// Same scaling as the column gutter: canvas sizes and scroll are zoomed.
|
|
392
|
+
var headerHeight = showHeaders ? columnHeaderHeight : 0;
|
|
347
393
|
var getRowOffset = (0, react_1.useCallback)(function (rowIndex) {
|
|
348
|
-
return (0, offsets_1.offsetAt)(rowOffsets, rowIndex) +
|
|
349
|
-
}, [rowOffsets]);
|
|
394
|
+
return ((0, offsets_1.offsetAt)(rowOffsets, rowIndex) + headerHeight) * scale;
|
|
395
|
+
}, [rowOffsets, headerHeight, scale]);
|
|
350
396
|
var scrollTop = useGridScrollPosition().scrollTop;
|
|
351
|
-
var
|
|
397
|
+
var _g = tslib_1.__read((0, use_resize_observer_1.useResizeObserver)(), 2), stripRef = _g[0], stripRect = _g[1];
|
|
352
398
|
var summaries = (0, react_1.useMemo)(function () {
|
|
353
|
-
return maxRowOutlineLevel > 0
|
|
399
|
+
return maxRowOutlineLevel > 0
|
|
400
|
+
? resolveSharedSummaries(findSummaries(rowMetadata, summaryBelow), rowMetadata, summaryBelow)
|
|
401
|
+
: [];
|
|
354
402
|
}, [rowMetadata, maxRowOutlineLevel, summaryBelow]);
|
|
355
|
-
// Dedup buttons by index (outermost level wins) — matches Excel.
|
|
356
|
-
// See the matching `ColumnOutlineGutter` block for the rationale.
|
|
357
|
-
var buttonLevelForIndex = (0, react_1.useMemo)(function () {
|
|
358
|
-
var e_3, _a;
|
|
359
|
-
var m = new Map();
|
|
360
|
-
try {
|
|
361
|
-
for (var summaries_2 = tslib_1.__values(summaries), summaries_2_1 = summaries_2.next(); !summaries_2_1.done; summaries_2_1 = summaries_2.next()) {
|
|
362
|
-
var s = summaries_2_1.value;
|
|
363
|
-
var existing = m.get(s.index);
|
|
364
|
-
if (existing === undefined || s.level < existing) {
|
|
365
|
-
m.set(s.index, s.level);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
370
|
-
finally {
|
|
371
|
-
try {
|
|
372
|
-
if (summaries_2_1 && !summaries_2_1.done && (_a = summaries_2.return)) _a.call(summaries_2);
|
|
373
|
-
}
|
|
374
|
-
finally { if (e_3) throw e_3.error; }
|
|
375
|
-
}
|
|
376
|
-
return m;
|
|
377
|
-
}, [summaries]);
|
|
378
403
|
if (maxRowOutlineLevel <= 0)
|
|
379
404
|
return null;
|
|
380
405
|
// N+1 level-selector buttons, stacked horizontally at the top of
|
|
@@ -386,14 +411,14 @@ exports.RowOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
386
411
|
// Summary +/- buttons, the bracket line, and dots all get clipped
|
|
387
412
|
// to this boundary so they never bleed into the level-selector
|
|
388
413
|
// row or the column-header band beside the grid.
|
|
389
|
-
var summaryMinY = topInset +
|
|
414
|
+
var summaryMinY = topInset + headerHeight * scale;
|
|
390
415
|
// Bottom edge of the strip in its own coord space. Anything below
|
|
391
416
|
// it is clipped by `overflow-hidden`, so it is never rendered.
|
|
392
417
|
var viewportMaxY = topInset +
|
|
393
418
|
resolveViewportSize(stripRect.height, typeof window === "undefined" ? undefined : window.innerHeight);
|
|
394
419
|
// Rows intersecting the strip, for the per-row dots.
|
|
395
|
-
var firstVisibleRow = Math.max(1, (0, offsets_1.cellAtOffset)(rowOffsets, scrollTop) - OVERSCAN_CELLS);
|
|
396
|
-
var lastVisibleRow = (0, offsets_1.cellAtOffset)(rowOffsets, scrollTop + viewportMaxY - summaryMinY) +
|
|
420
|
+
var firstVisibleRow = Math.max(1, (0, offsets_1.cellAtOffset)(rowOffsets, scrollTop / scale) - OVERSCAN_CELLS);
|
|
421
|
+
var lastVisibleRow = (0, offsets_1.cellAtOffset)(rowOffsets, (scrollTop + viewportMaxY - summaryMinY) / scale) +
|
|
397
422
|
OVERSCAN_CELLS;
|
|
398
423
|
return (react_1.default.createElement("div", { ref: stripRef, "data-testid": "row-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-t border-b border-t-rnc-border border-b-rnc-border border-solid border-l-rnc-border border-l border-r-0", style: {
|
|
399
424
|
width: gutterWidth,
|
|
@@ -408,7 +433,7 @@ exports.RowOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
408
433
|
onSetOutlineDepth === null || onSetOutlineDepth === void 0 ? void 0 : onSetOutlineDepth(sheetId, "row", depth);
|
|
409
434
|
} }, depth)); })),
|
|
410
435
|
summaries.map(function (_a) {
|
|
411
|
-
var index = _a.index, startIndex = _a.startIndex, collapsed = _a.collapsed, level = _a.level;
|
|
436
|
+
var index = _a.index, startIndex = _a.startIndex, collapsed = _a.collapsed, level = _a.level, showButton = _a.showButton, shared = _a.shared;
|
|
412
437
|
var buttonY = getRowOffset(index) - scrollTop + topInset;
|
|
413
438
|
var lineStartY = getRowOffset(startIndex) - scrollTop + topInset + 2;
|
|
414
439
|
// The whole group sits below the strip: nothing to paint.
|
|
@@ -465,17 +490,15 @@ exports.RowOutlineGutter = (0, react_1.memo)(function (_a) {
|
|
|
465
490
|
top: cy - 1,
|
|
466
491
|
} }));
|
|
467
492
|
}))) : null,
|
|
468
|
-
showSummary &&
|
|
469
|
-
? "Expand row group at ".concat(index)
|
|
470
|
-
: "Collapse row group at ".concat(index), className: "absolute p-0 min-w-0 min-h-0", size: "xs", variant: "outline", style: {
|
|
493
|
+
showSummary && showButton ? (react_1.default.createElement(ui_1.Button, { "aria-label": "".concat(collapsed ? "Expand" : "Collapse", " row group at ").concat(index).concat(shared ? " level ".concat(level) : ""), className: "absolute p-0 min-w-0 min-h-0", size: "xs", variant: "outline", style: {
|
|
471
494
|
left: x,
|
|
472
495
|
top: buttonY,
|
|
473
496
|
}, onClick: function (e) {
|
|
474
497
|
e.stopPropagation();
|
|
475
498
|
if (collapsed)
|
|
476
|
-
onExpandRowGroup === null || onExpandRowGroup === void 0 ? void 0 : onExpandRowGroup(sheetId, index);
|
|
499
|
+
onExpandRowGroup === null || onExpandRowGroup === void 0 ? void 0 : onExpandRowGroup(sheetId, index, level);
|
|
477
500
|
else
|
|
478
|
-
onCollapseRowGroup === null || onCollapseRowGroup === void 0 ? void 0 : onCollapseRowGroup(sheetId, index);
|
|
501
|
+
onCollapseRowGroup === null || onCollapseRowGroup === void 0 ? void 0 : onCollapseRowGroup(sheetId, index, level);
|
|
479
502
|
} }, collapsed ? (react_1.default.createElement(icons_1.PlusIcon, { className: "w-3 h-3" })) : (react_1.default.createElement(icons_1.MinusIcon, { className: "w-3 h-3" })))) : null));
|
|
480
503
|
})));
|
|
481
504
|
});
|
package/dist/cjs/release-date.js
CHANGED
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.releaseDate = void 0;
|
|
5
5
|
exports.releaseDate =
|
|
6
6
|
// @ts-ignore
|
|
7
|
-
(_a = new Date("2026-11-
|
|
7
|
+
(_a = new Date("2026-11-12")) !== null && _a !== void 0 ? _a : new Date("2025-06-18");
|
|
@@ -16,6 +16,11 @@ export declare const parseNumberStoredAsText: (text: string | null | undefined)
|
|
|
16
16
|
export type ErrorCheckInput = {
|
|
17
17
|
/** What the user typed (`uev`): a formula, a number, a string, … */
|
|
18
18
|
userEnteredValue: ExtendedValue | null | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The cell's value (`ev`). A typed number keeps what was typed in `uev.sv` and its number here,
|
|
21
|
+
* in `ev.nv`, so this tells text from a number. Without it, `userEnteredValue` decides.
|
|
22
|
+
*/
|
|
23
|
+
effectiveValue?: ExtendedValue | null;
|
|
19
24
|
/** The cell's error, if its effective value is one. */
|
|
20
25
|
errorValue: ErrorValue | null | undefined;
|
|
21
26
|
};
|
|
@@ -24,7 +29,7 @@ export type ErrorCheckInput = {
|
|
|
24
29
|
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
25
30
|
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
26
31
|
*/
|
|
27
|
-
export declare const getErrorCheckKind: ({ userEnteredValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
|
|
32
|
+
export declare const getErrorCheckKind: ({ userEnteredValue, effectiveValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
|
|
28
33
|
/** What the error-checking smart tag's menu can do. */
|
|
29
34
|
export type ErrorCheckOption = "convertToNumber" | "help" | "ignore" | "editInFormulaBar" | "options";
|
|
30
35
|
/** The menu's heading, as Excel words it. */
|
|
@@ -49,7 +54,7 @@ export type NumberRun = {
|
|
|
49
54
|
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
50
55
|
* only the used rows.
|
|
51
56
|
*/
|
|
52
|
-
export declare const collectNumberStoredAsTextRuns: (ranges: GridRange[], getUserEnteredValue: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined, maxRow: number, maxColumn: number) => NumberRun[];
|
|
57
|
+
export declare const collectNumberStoredAsTextRuns: (ranges: GridRange[], getUserEnteredValue: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined, maxRow: number, maxColumn: number, getEffectiveValue?: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined) => NumberRun[];
|
|
53
58
|
export type ErrorCheckActionContext = {
|
|
54
59
|
sheetId: number;
|
|
55
60
|
kind: ErrorCheckKind;
|
|
@@ -57,6 +62,7 @@ export type ErrorCheckActionContext = {
|
|
|
57
62
|
/** The selection's ranges (the active cell's when nothing else is selected). */
|
|
58
63
|
ranges: GridRange[];
|
|
59
64
|
getUserEnteredValue(rowIndex: number, columnIndex: number): ExtendedValue | null | undefined;
|
|
65
|
+
getEffectiveValue?(rowIndex: number, columnIndex: number): ExtendedValue | null | undefined;
|
|
60
66
|
/** The sheet's data extent: Convert to Number scans no further. */
|
|
61
67
|
maxRow: number;
|
|
62
68
|
maxColumn: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-checking.d.ts","sourceRoot":"","sources":["../../../api/error-checking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAShE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,KAC9B,MAAM,GAAG,SAQX,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,gBAAgB,EAAE,aAAa,GAAG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C;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACtE,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IAC5E,2DAA2D;IAC3D,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,aAAa,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,8FAA8F;IAC9F,gBAAgB,IAAI,IAAI,CAAC;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,gBAAgB,EACxB,SAAS,uBAAuB,SAkDjC,CAAC"}
|
|
@@ -19,17 +19,25 @@ export const parseNumberStoredAsText = (text) => {
|
|
|
19
19
|
return undefined;
|
|
20
20
|
return isPercent ? value / 100 : value;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* The text a cell's value is, or `undefined` when its value is not text: `ev.sv` when the cell has
|
|
24
|
+
* an effective value (a number typed into a Text-formatted cell, or after an apostrophe, is text
|
|
25
|
+
* there), else `uev.sv`.
|
|
26
|
+
*/
|
|
27
|
+
const getCellText = (userEnteredValue, effectiveValue) => effectiveValue
|
|
28
|
+
? (effectiveValue.sv ?? effectiveValue.stringValue)
|
|
29
|
+
: (userEnteredValue?.sv ?? userEnteredValue?.stringValue);
|
|
22
30
|
/**
|
|
23
31
|
* Which error-checking rule (if any) flags this cell, before ignored errors are applied.
|
|
24
32
|
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
25
33
|
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
26
34
|
*/
|
|
27
|
-
export const getErrorCheckKind = ({ userEnteredValue, errorValue, }) => {
|
|
35
|
+
export const getErrorCheckKind = ({ userEnteredValue, effectiveValue, errorValue, }) => {
|
|
28
36
|
const formula = userEnteredValue?.fv ?? userEnteredValue?.formulaValue;
|
|
29
37
|
if (formula) {
|
|
30
38
|
return errorValue?.type === "Error" ? "evalError" : undefined;
|
|
31
39
|
}
|
|
32
|
-
const text = userEnteredValue
|
|
40
|
+
const text = getCellText(userEnteredValue, effectiveValue);
|
|
33
41
|
if (parseNumberStoredAsText(text) !== undefined)
|
|
34
42
|
return "numberStoredAsText";
|
|
35
43
|
return undefined;
|
|
@@ -78,7 +86,7 @@ export const appendIgnoredError = (ignoredErrors, ranges, kind) => [
|
|
|
78
86
|
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
79
87
|
* only the used rows.
|
|
80
88
|
*/
|
|
81
|
-
export const collectNumberStoredAsTextRuns = (ranges, getUserEnteredValue, maxRow, maxColumn) => {
|
|
89
|
+
export const collectNumberStoredAsTextRuns = (ranges, getUserEnteredValue, maxRow, maxColumn, getEffectiveValue) => {
|
|
82
90
|
const runs = [];
|
|
83
91
|
const seen = new Set();
|
|
84
92
|
for (const range of ranges) {
|
|
@@ -89,10 +97,15 @@ export const collectNumberStoredAsTextRuns = (ranges, getUserEnteredValue, maxRo
|
|
|
89
97
|
for (let col = range.startColumnIndex; col <= endColumn; col++) {
|
|
90
98
|
const key = `${row}:${col}`;
|
|
91
99
|
const uev = seen.has(key) ? null : getUserEnteredValue(row, col);
|
|
100
|
+
const ev = seen.has(key) ? null : getEffectiveValue?.(row, col);
|
|
92
101
|
seen.add(key);
|
|
93
|
-
const kind = getErrorCheckKind({
|
|
102
|
+
const kind = getErrorCheckKind({
|
|
103
|
+
userEnteredValue: uev,
|
|
104
|
+
effectiveValue: ev,
|
|
105
|
+
errorValue: null,
|
|
106
|
+
});
|
|
94
107
|
const value = kind === "numberStoredAsText"
|
|
95
|
-
? parseNumberStoredAsText(uev
|
|
108
|
+
? parseNumberStoredAsText(getCellText(uev, ev))
|
|
96
109
|
: undefined;
|
|
97
110
|
if (value === undefined) {
|
|
98
111
|
run = null;
|
|
@@ -119,7 +132,7 @@ export const runErrorCheckOption = (option, context) => {
|
|
|
119
132
|
const { sheetId, kind, ranges } = context;
|
|
120
133
|
switch (option) {
|
|
121
134
|
case "convertToNumber": {
|
|
122
|
-
const runs = collectNumberStoredAsTextRuns(ranges, context.getUserEnteredValue, context.maxRow, context.maxColumn);
|
|
135
|
+
const runs = collectNumberStoredAsTextRuns(ranges, context.getUserEnteredValue, context.maxRow, context.maxColumn, context.getEffectiveValue);
|
|
123
136
|
if (!runs.length)
|
|
124
137
|
return;
|
|
125
138
|
const write = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/canvas-grid/index.tsx"],"names":[],"mappings":"AAmEA,OAAO,KASN,MAAM,OAAO,CAAC;AAuQf,OAAO,KAAK,EAGV,QAAQ,EAYT,MAAM,aAAa,CAAC;AA4CrB,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAgkOnB,eAAO,MAAM,UAAU,EAA4C,CACjE,CAAC,SAAS,QAAQ,CAAC,GAAG,CAAC,EAEvB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GACvB,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAChE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC"}
|
|
@@ -1064,6 +1064,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1064
1064
|
const getErrorCheck = useCallback((targetSheetId, rowIndex, columnIndex) => {
|
|
1065
1065
|
const kind = getErrorCheckKind({
|
|
1066
1066
|
userEnteredValue: getUserEnteredValue(targetSheetId, rowIndex, columnIndex),
|
|
1067
|
+
effectiveValue: getEffectiveValue(targetSheetId, rowIndex, columnIndex),
|
|
1067
1068
|
errorValue: getErrorValue(targetSheetId, rowIndex, columnIndex),
|
|
1068
1069
|
});
|
|
1069
1070
|
if (kind &&
|
|
@@ -1075,6 +1076,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
1075
1076
|
return kind;
|
|
1076
1077
|
}, [
|
|
1077
1078
|
getUserEnteredValue,
|
|
1079
|
+
getEffectiveValue,
|
|
1078
1080
|
getErrorValue,
|
|
1079
1081
|
getIgnoredErrorsStable,
|
|
1080
1082
|
stableIgnoredErrors,
|
|
@@ -3592,6 +3594,7 @@ function CanvasGridComponent(props, forwardedRef) {
|
|
|
3592
3594
|
errorName: activeErrorName,
|
|
3593
3595
|
ranges,
|
|
3594
3596
|
getUserEnteredValue: (rowIndex, columnIndex) => getUserEnteredValue(sheetId, rowIndex, columnIndex),
|
|
3597
|
+
getEffectiveValue: (rowIndex, columnIndex) => getEffectiveValue(sheetId, rowIndex, columnIndex),
|
|
3595
3598
|
maxRow: getDataRowCount?.(sheetId) ?? Number.MAX_SAFE_INTEGER,
|
|
3596
3599
|
maxColumn: getDataColumnCount?.(sheetId) ?? Number.MAX_SAFE_INTEGER,
|
|
3597
3600
|
getIgnoredErrors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/formula-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAIrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAiB,MAAM,OAAO,CAAC;AActC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,sGAyLxB,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { cn } from "@rowsncolumns/ui";
|
|
2
2
|
import { debug, isAFormula } from "@rowsncolumns/utils";
|
|
3
|
+
import { useStore } from "jotai";
|
|
3
4
|
import { forwardRef, useCallback } from "react";
|
|
4
5
|
import React, { useRef } from "react";
|
|
5
|
-
import {
|
|
6
|
+
import { useFormulaMode, useGetGridRef, useGetSelectionsFromFormula, useOnEditorKeyDown, useSetActiveEditor, useSetFormulaSelections, } from "../../atoms";
|
|
7
|
+
import { activeEditorAtom } from "../../atoms/active-editor.atom";
|
|
6
8
|
import { useCellInputContext } from "../../atoms/cell-input-context.atom";
|
|
7
9
|
import { useIsomorphicLayoutEffect } from "../../hooks/use-isomorphic-layout-effect";
|
|
8
10
|
import { useMergeRefs } from "../../hooks/use-merge.refs";
|
|
@@ -17,7 +19,7 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
|
|
|
17
19
|
const editorRef = useRef(null);
|
|
18
20
|
const [isFormulaMode, setFormulaMode] = useFormulaMode();
|
|
19
21
|
const setFormulaSelections = useSetFormulaSelections();
|
|
20
|
-
const
|
|
22
|
+
const store = useStore();
|
|
21
23
|
const setActiveEditor = useSetActiveEditor();
|
|
22
24
|
const getSelectionsFromFormula = useGetSelectionsFromFormula();
|
|
23
25
|
const onEditorKeyDown = useOnEditorKeyDown();
|
|
@@ -108,7 +110,9 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
|
|
|
108
110
|
}, [closeFormulaMode, isFormulaMode, setActiveEditor, onCancel, getGridRef, onBlur]);
|
|
109
111
|
const handleChange = useCallback((value, textFormatRuns) => {
|
|
110
112
|
onChange?.(value, textFormatRuns);
|
|
111
|
-
// Prevent selecting when there is no active editor
|
|
113
|
+
// Prevent selecting when there is no active editor. Read it from the store, not the
|
|
114
|
+
// render: a blur clears it, and ProseMirror's blur transaction then lands here.
|
|
115
|
+
const activeEditor = store.get(activeEditorAtom);
|
|
112
116
|
if (!activeEditor || activeEditor !== editorRef.current) {
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
@@ -120,7 +124,7 @@ export const FormulaInput = forwardRef(({ value = "", onChange, onCancel, onBlur
|
|
|
120
124
|
setFormulaSelections(selections);
|
|
121
125
|
}
|
|
122
126
|
}, [
|
|
123
|
-
|
|
127
|
+
store,
|
|
124
128
|
onChange,
|
|
125
129
|
enterFormulaMode,
|
|
126
130
|
setFormulaSelections,
|
|
@@ -2,7 +2,22 @@ import React from "react";
|
|
|
2
2
|
import { COLUMN_HEADER_HEIGHT, ROW_HEADER_WIDTH } from "../../config";
|
|
3
3
|
import type { DimensionProperties } from "../../types";
|
|
4
4
|
type DimensionMetadata = (DimensionProperties | null | undefined)[] | null | undefined;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The grid's sizing, which the gutters need to line up with the canvas.
|
|
7
|
+
* Pass the same values given to `CanvasGrid`; every one defaults to the
|
|
8
|
+
* grid's own default.
|
|
9
|
+
*/
|
|
10
|
+
export type OutlineGutterSizingProps = {
|
|
11
|
+
defaultColumnWidth?: number;
|
|
12
|
+
defaultRowHeight?: number;
|
|
13
|
+
rowHeaderWidth?: number;
|
|
14
|
+
columnHeaderHeight?: number;
|
|
15
|
+
/** `false` when the grid hides its row and column headers. */
|
|
16
|
+
showHeaders?: boolean;
|
|
17
|
+
/** The grid's zoom (`CanvasGrid` `scale`). */
|
|
18
|
+
scale?: number;
|
|
19
|
+
};
|
|
20
|
+
export type ColumnOutlineGutterProps = OutlineGutterSizingProps & {
|
|
6
21
|
sheetId: number;
|
|
7
22
|
columnMetadata?: DimensionMetadata;
|
|
8
23
|
/** Row metadata for the same sheet. Used to compute the row outline
|
|
@@ -11,25 +26,27 @@ export type ColumnOutlineGutterProps = {
|
|
|
11
26
|
rowMetadata?: DimensionMetadata;
|
|
12
27
|
/** True when summaries sit right of the group (Excel default). */
|
|
13
28
|
summaryRight?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
/** `level` is the outline level of the group whose button was pressed. */
|
|
30
|
+
onCollapseColumnGroup?(sheetId: number, summaryColumnIndex: number, level?: number): void;
|
|
31
|
+
onExpandColumnGroup?(sheetId: number, summaryColumnIndex: number, level?: number): void;
|
|
16
32
|
/** Excel-style level selector. Renders N+1 numbered buttons in the
|
|
17
33
|
* gutter's leftInset area. */
|
|
18
34
|
onSetOutlineDepth?(sheetId: number, axis: "row" | "column", depth: number): void;
|
|
19
35
|
};
|
|
20
|
-
export declare const ColumnOutlineGutter: React.MemoExoticComponent<({ sheetId, columnMetadata, rowMetadata, summaryRight, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, }: ColumnOutlineGutterProps) => React.JSX.Element | null>;
|
|
21
|
-
export type RowOutlineGutterProps = {
|
|
36
|
+
export declare const ColumnOutlineGutter: React.MemoExoticComponent<({ sheetId, columnMetadata, rowMetadata, summaryRight, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, defaultColumnWidth, rowHeaderWidth, showHeaders, scale, }: ColumnOutlineGutterProps) => React.JSX.Element | null>;
|
|
37
|
+
export type RowOutlineGutterProps = OutlineGutterSizingProps & {
|
|
22
38
|
sheetId: number;
|
|
23
39
|
rowMetadata?: DimensionMetadata;
|
|
24
40
|
/** True when summaries sit below the group (Excel default). */
|
|
25
41
|
summaryBelow?: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
/** `level` is the outline level of the group whose button was pressed. */
|
|
43
|
+
onCollapseRowGroup?(sheetId: number, summaryRowIndex: number, level?: number): void;
|
|
44
|
+
onExpandRowGroup?(sheetId: number, summaryRowIndex: number, level?: number): void;
|
|
28
45
|
/** Excel-style level selector. Renders N+1 numbered buttons at the
|
|
29
46
|
* top of the row gutter strip (in the topInset area). */
|
|
30
47
|
onSetOutlineDepth?(sheetId: number, axis: "row" | "column", depth: number): void;
|
|
31
48
|
};
|
|
32
|
-
export declare const RowOutlineGutter: React.MemoExoticComponent<({ sheetId, rowMetadata, summaryBelow, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, }: RowOutlineGutterProps) => React.JSX.Element | null>;
|
|
49
|
+
export declare const RowOutlineGutter: React.MemoExoticComponent<({ sheetId, rowMetadata, summaryBelow, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, defaultRowHeight, columnHeaderHeight, showHeaders, scale, }: RowOutlineGutterProps) => React.JSX.Element | null>;
|
|
33
50
|
/**
|
|
34
51
|
* Pixel width / height the outline gutter will reserve for the given
|
|
35
52
|
* axis. Returns 0 when the metadata has no `outlineLevel > 0`. Use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/outline-gutter/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,EACL,oBAAoB,EAKpB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,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AC,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0EAA0E;IAC1E,kBAAkB,CAAC,CACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR,gBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAAC;IACR;6DACyD;IACzD,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,EACtB,KAAK,EAAE,MAAM,GACZ,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,gBAAgB,yLAYxB,qBAAqB,8BAwMzB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,KACtE,MAIF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
//
|
|
16
16
|
// Buttons are positioned by `getRowOffset` / `getColumnOffset` so they
|
|
17
17
|
// stay aligned with the cell their summary lives on; scroll position
|
|
18
|
-
// shifts the buttons horizontally / vertically.
|
|
18
|
+
// shifts the buttons horizontally / vertically. Those offsets have to
|
|
19
|
+
// use the grid's own sizing (default sizes, header sizes, zoom), so the
|
|
20
|
+
// host passes the same values it gives `CanvasGrid` — see
|
|
21
|
+
// `OutlineGutterSizingProps`.
|
|
19
22
|
//
|
|
20
23
|
// Bracket lines and the "1 / 2 / 3" level bar are intentionally minimal
|
|
21
24
|
// here — the goal is a functional MVP. Polish can layer on later.
|
|
@@ -144,6 +147,41 @@ const findSummaries = (metadata, summaryAfter) => {
|
|
|
144
147
|
}
|
|
145
148
|
return out;
|
|
146
149
|
};
|
|
150
|
+
const resolveSharedSummaries = (summaries, metadata, summaryAfter) => {
|
|
151
|
+
const levelsAtIndex = new Map();
|
|
152
|
+
for (const s of summaries) {
|
|
153
|
+
levelsAtIndex.set(s.index, (levelsAtIndex.get(s.index) ?? 0) + 1);
|
|
154
|
+
}
|
|
155
|
+
const resolved = summaries.map((s) => {
|
|
156
|
+
if ((levelsAtIndex.get(s.index) ?? 0) < 2) {
|
|
157
|
+
return { ...s, showButton: true, shared: false };
|
|
158
|
+
}
|
|
159
|
+
const [from, to] = summaryAfter
|
|
160
|
+
? [s.startIndex, s.index - 1]
|
|
161
|
+
: [s.index + 1, s.startIndex];
|
|
162
|
+
let collapsed = to >= from;
|
|
163
|
+
for (let c = from; c <= to && collapsed; c++) {
|
|
164
|
+
if (!metadata?.[c]?.hiddenByGroup)
|
|
165
|
+
collapsed = false;
|
|
166
|
+
}
|
|
167
|
+
return { ...s, collapsed, showButton: true, shared: true };
|
|
168
|
+
});
|
|
169
|
+
const collapsedLevelAtIndex = new Map();
|
|
170
|
+
for (const s of resolved) {
|
|
171
|
+
if (!s.collapsed)
|
|
172
|
+
continue;
|
|
173
|
+
const prev = collapsedLevelAtIndex.get(s.index);
|
|
174
|
+
if (prev === undefined || s.level < prev) {
|
|
175
|
+
collapsedLevelAtIndex.set(s.index, s.level);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const s of resolved) {
|
|
179
|
+
const outer = collapsedLevelAtIndex.get(s.index);
|
|
180
|
+
if (outer !== undefined && s.level > outer)
|
|
181
|
+
s.showButton = false;
|
|
182
|
+
}
|
|
183
|
+
return resolved;
|
|
184
|
+
};
|
|
147
185
|
/**
|
|
148
186
|
* Walk a sparse `DimensionProperties` array once and report the
|
|
149
187
|
* largest `outlineLevel` seen. Returns 0 when no grouping is in use.
|
|
@@ -159,35 +197,22 @@ const computeMaxOutlineLevel = (metadata) => {
|
|
|
159
197
|
}
|
|
160
198
|
return max;
|
|
161
199
|
};
|
|
162
|
-
export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata, summaryRight = true, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, }) => {
|
|
200
|
+
export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata, summaryRight = true, onCollapseColumnGroup, onExpandColumnGroup, onSetOutlineDepth, defaultColumnWidth = DEFAULT_COLUMN_WIDTH, rowHeaderWidth = ROW_HEADER_WIDTH, showHeaders = true, scale = 1, }) => {
|
|
163
201
|
// Shift the strip right by the row outline gutter's width when one
|
|
164
202
|
// exists, so the strip's content lines up with the canvas (which
|
|
165
203
|
// sits to the right of the row gutter).
|
|
166
204
|
const leftInset = useMemo(() => computeOutlineGutterSize(rowMetadata), [rowMetadata]);
|
|
167
205
|
const maxColumnOutlineLevel = useMemo(() => computeMaxOutlineLevel(columnMetadata), [columnMetadata]);
|
|
168
|
-
const columnOffsets = useMemo(() => buildOffsetIndex(columnMetadata,
|
|
169
|
-
|
|
206
|
+
const columnOffsets = useMemo(() => buildOffsetIndex(columnMetadata, defaultColumnWidth), [columnMetadata, defaultColumnWidth]);
|
|
207
|
+
// The canvas draws every size (headers included) times its zoom, and
|
|
208
|
+
// its scroll position is in those scaled pixels.
|
|
209
|
+
const headerWidth = showHeaders ? rowHeaderWidth : 0;
|
|
210
|
+
const getColumnOffset = useCallback((columnIndex) => (offsetAt(columnOffsets, columnIndex) + headerWidth) * scale, [columnOffsets, headerWidth, scale]);
|
|
170
211
|
const { scrollLeft } = useGridScrollPosition();
|
|
171
212
|
const [stripRef, stripRect] = useResizeObserver();
|
|
172
213
|
const summaries = useMemo(() => maxColumnOutlineLevel > 0
|
|
173
|
-
? findSummaries(columnMetadata, summaryRight)
|
|
214
|
+
? resolveSharedSummaries(findSummaries(columnMetadata, summaryRight), columnMetadata, summaryRight)
|
|
174
215
|
: [], [columnMetadata, maxColumnOutlineLevel, summaryRight]);
|
|
175
|
-
// When nested groups share the same summary cell (common with
|
|
176
|
-
// `summaryRight=true`: outer and inner end at the same column), we
|
|
177
|
-
// render the bracket for every level but only the OUTERMOST
|
|
178
|
-
// (lowest level number) gets a +/- button — matches Excel.
|
|
179
|
-
// Granular collapse of inner groups uses the level-selector
|
|
180
|
-
// buttons instead.
|
|
181
|
-
const buttonLevelForIndex = useMemo(() => {
|
|
182
|
-
const m = new Map();
|
|
183
|
-
for (const s of summaries) {
|
|
184
|
-
const existing = m.get(s.index);
|
|
185
|
-
if (existing === undefined || s.level < existing) {
|
|
186
|
-
m.set(s.index, s.level);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return m;
|
|
190
|
-
}, [summaries]);
|
|
191
216
|
if (maxColumnOutlineLevel <= 0)
|
|
192
217
|
return null;
|
|
193
218
|
// N+1 level-selector buttons. `depth=1` collapses every group;
|
|
@@ -199,15 +224,14 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
199
224
|
// Summary +/- buttons, the bracket line, and dots all get clipped
|
|
200
225
|
// to this boundary so they never bleed into the level-selector
|
|
201
226
|
// lane or the row-header column above the grid.
|
|
202
|
-
const summaryMinX = leftInset +
|
|
227
|
+
const summaryMinX = leftInset + headerWidth * scale;
|
|
203
228
|
// Right edge of the strip in its own coord space. Anything past it
|
|
204
229
|
// is clipped by `overflow-hidden`, so it is never rendered.
|
|
205
230
|
const viewportMaxX = leftInset +
|
|
206
231
|
resolveViewportSize(stripRect.width, typeof window === "undefined" ? undefined : window.innerWidth);
|
|
207
232
|
// Columns intersecting the strip, for the per-column dots.
|
|
208
|
-
const firstVisibleColumn = Math.max(1, cellAtOffset(columnOffsets, scrollLeft) - OVERSCAN_CELLS);
|
|
209
|
-
const lastVisibleColumn = cellAtOffset(columnOffsets, scrollLeft + viewportMaxX - summaryMinX) +
|
|
210
|
-
OVERSCAN_CELLS;
|
|
233
|
+
const firstVisibleColumn = Math.max(1, cellAtOffset(columnOffsets, scrollLeft / scale) - OVERSCAN_CELLS);
|
|
234
|
+
const lastVisibleColumn = cellAtOffset(columnOffsets, (scrollLeft + viewportMaxX - summaryMinX) / scale) + OVERSCAN_CELLS;
|
|
211
235
|
return (React.createElement("div", { ref: stripRef, "data-testid": "column-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-l border-r border-r-rnc-border border-l-rnc-border border-solid border-t-rnc-border border-t border-b-0", style: {
|
|
212
236
|
height: gutterHeight,
|
|
213
237
|
paddingLeft: leftInset,
|
|
@@ -220,7 +244,7 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
220
244
|
e.stopPropagation();
|
|
221
245
|
onSetOutlineDepth?.(sheetId, "column", depth);
|
|
222
246
|
} }, depth)))),
|
|
223
|
-
summaries.map(({ index, startIndex, collapsed, level }) => {
|
|
247
|
+
summaries.map(({ index, startIndex, collapsed, level, showButton, shared }) => {
|
|
224
248
|
// Anchor positions inside the cell area; add `leftInset` so
|
|
225
249
|
// x=0 of the strip lines up with the grid's content origin.
|
|
226
250
|
const buttonX = getColumnOffset(index) - scrollLeft + leftInset;
|
|
@@ -283,41 +307,31 @@ export const ColumnOutlineGutter = memo(({ sheetId, columnMetadata, rowMetadata,
|
|
|
283
307
|
top: lineCenterY + 3,
|
|
284
308
|
} }));
|
|
285
309
|
}))) : null,
|
|
286
|
-
showSummary &&
|
|
287
|
-
? `Expand column group at ${index}`
|
|
288
|
-
: `Collapse column group at ${index}`, size: "xs", variant: "outline", className: "absolute p-0 min-w-0 min-h-0", style: {
|
|
310
|
+
showSummary && showButton ? (React.createElement(Button, { "aria-label": `${collapsed ? "Expand" : "Collapse"} column group at ${index}${shared ? ` level ${level}` : ""}`, size: "xs", variant: "outline", className: "absolute p-0 min-w-0 min-h-0", style: {
|
|
289
311
|
left: buttonX,
|
|
290
312
|
top: y,
|
|
291
313
|
}, onClick: (e) => {
|
|
292
314
|
e.stopPropagation();
|
|
293
315
|
if (collapsed)
|
|
294
|
-
onExpandColumnGroup?.(sheetId, index);
|
|
316
|
+
onExpandColumnGroup?.(sheetId, index, level);
|
|
295
317
|
else
|
|
296
|
-
onCollapseColumnGroup?.(sheetId, index);
|
|
318
|
+
onCollapseColumnGroup?.(sheetId, index, level);
|
|
297
319
|
} }, collapsed ? (React.createElement(PlusIcon, { className: "w-3 h-3" })) : (React.createElement(MinusIcon, { className: "w-3 h-3" })))) : null));
|
|
298
320
|
})));
|
|
299
321
|
});
|
|
300
322
|
ColumnOutlineGutter.displayName = "ColumnOutlineGutter";
|
|
301
|
-
export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = true, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, }) => {
|
|
323
|
+
export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = true, onCollapseRowGroup, onExpandRowGroup, onSetOutlineDepth, defaultRowHeight = DEFAULT_ROW_HEIGHT, columnHeaderHeight = COLUMN_HEADER_HEIGHT, showHeaders = true, scale = 1, }) => {
|
|
302
324
|
const topInset = 0;
|
|
303
325
|
const maxRowOutlineLevel = useMemo(() => computeMaxOutlineLevel(rowMetadata), [rowMetadata]);
|
|
304
|
-
const rowOffsets = useMemo(() => buildOffsetIndex(rowMetadata,
|
|
305
|
-
|
|
326
|
+
const rowOffsets = useMemo(() => buildOffsetIndex(rowMetadata, defaultRowHeight), [rowMetadata, defaultRowHeight]);
|
|
327
|
+
// Same scaling as the column gutter: canvas sizes and scroll are zoomed.
|
|
328
|
+
const headerHeight = showHeaders ? columnHeaderHeight : 0;
|
|
329
|
+
const getRowOffset = useCallback((rowIndex) => (offsetAt(rowOffsets, rowIndex) + headerHeight) * scale, [rowOffsets, headerHeight, scale]);
|
|
306
330
|
const { scrollTop } = useGridScrollPosition();
|
|
307
331
|
const [stripRef, stripRect] = useResizeObserver();
|
|
308
|
-
const summaries = useMemo(() => maxRowOutlineLevel > 0
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const buttonLevelForIndex = useMemo(() => {
|
|
312
|
-
const m = new Map();
|
|
313
|
-
for (const s of summaries) {
|
|
314
|
-
const existing = m.get(s.index);
|
|
315
|
-
if (existing === undefined || s.level < existing) {
|
|
316
|
-
m.set(s.index, s.level);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return m;
|
|
320
|
-
}, [summaries]);
|
|
332
|
+
const summaries = useMemo(() => maxRowOutlineLevel > 0
|
|
333
|
+
? resolveSharedSummaries(findSummaries(rowMetadata, summaryBelow), rowMetadata, summaryBelow)
|
|
334
|
+
: [], [rowMetadata, maxRowOutlineLevel, summaryBelow]);
|
|
321
335
|
if (maxRowOutlineLevel <= 0)
|
|
322
336
|
return null;
|
|
323
337
|
// N+1 level-selector buttons, stacked horizontally at the top of
|
|
@@ -329,14 +343,14 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
329
343
|
// Summary +/- buttons, the bracket line, and dots all get clipped
|
|
330
344
|
// to this boundary so they never bleed into the level-selector
|
|
331
345
|
// row or the column-header band beside the grid.
|
|
332
|
-
const summaryMinY = topInset +
|
|
346
|
+
const summaryMinY = topInset + headerHeight * scale;
|
|
333
347
|
// Bottom edge of the strip in its own coord space. Anything below
|
|
334
348
|
// it is clipped by `overflow-hidden`, so it is never rendered.
|
|
335
349
|
const viewportMaxY = topInset +
|
|
336
350
|
resolveViewportSize(stripRect.height, typeof window === "undefined" ? undefined : window.innerHeight);
|
|
337
351
|
// Rows intersecting the strip, for the per-row dots.
|
|
338
|
-
const firstVisibleRow = Math.max(1, cellAtOffset(rowOffsets, scrollTop) - OVERSCAN_CELLS);
|
|
339
|
-
const lastVisibleRow = cellAtOffset(rowOffsets, scrollTop + viewportMaxY - summaryMinY) +
|
|
352
|
+
const firstVisibleRow = Math.max(1, cellAtOffset(rowOffsets, scrollTop / scale) - OVERSCAN_CELLS);
|
|
353
|
+
const lastVisibleRow = cellAtOffset(rowOffsets, (scrollTop + viewportMaxY - summaryMinY) / scale) +
|
|
340
354
|
OVERSCAN_CELLS;
|
|
341
355
|
return (React.createElement("div", { ref: stripRef, "data-testid": "row-outline-gutter", className: "bg-rnc-background relative overflow-hidden border-t border-b border-t-rnc-border border-b-rnc-border border-solid border-l-rnc-border border-l border-r-0", style: {
|
|
342
356
|
width: gutterWidth,
|
|
@@ -350,7 +364,7 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
350
364
|
e.stopPropagation();
|
|
351
365
|
onSetOutlineDepth?.(sheetId, "row", depth);
|
|
352
366
|
} }, depth)))),
|
|
353
|
-
summaries.map(({ index, startIndex, collapsed, level }) => {
|
|
367
|
+
summaries.map(({ index, startIndex, collapsed, level, showButton, shared }) => {
|
|
354
368
|
const buttonY = getRowOffset(index) - scrollTop + topInset;
|
|
355
369
|
const lineStartY = getRowOffset(startIndex) - scrollTop + topInset + 2;
|
|
356
370
|
// The whole group sits below the strip: nothing to paint.
|
|
@@ -407,17 +421,15 @@ export const RowOutlineGutter = memo(({ sheetId, rowMetadata, summaryBelow = tru
|
|
|
407
421
|
top: cy - 1,
|
|
408
422
|
} }));
|
|
409
423
|
}))) : null,
|
|
410
|
-
showSummary &&
|
|
411
|
-
? `Expand row group at ${index}`
|
|
412
|
-
: `Collapse row group at ${index}`, className: "absolute p-0 min-w-0 min-h-0", size: "xs", variant: "outline", style: {
|
|
424
|
+
showSummary && showButton ? (React.createElement(Button, { "aria-label": `${collapsed ? "Expand" : "Collapse"} row group at ${index}${shared ? ` level ${level}` : ""}`, className: "absolute p-0 min-w-0 min-h-0", size: "xs", variant: "outline", style: {
|
|
413
425
|
left: x,
|
|
414
426
|
top: buttonY,
|
|
415
427
|
}, onClick: (e) => {
|
|
416
428
|
e.stopPropagation();
|
|
417
429
|
if (collapsed)
|
|
418
|
-
onExpandRowGroup?.(sheetId, index);
|
|
430
|
+
onExpandRowGroup?.(sheetId, index, level);
|
|
419
431
|
else
|
|
420
|
-
onCollapseRowGroup?.(sheetId, index);
|
|
432
|
+
onCollapseRowGroup?.(sheetId, index, level);
|
|
421
433
|
} }, collapsed ? (React.createElement(PlusIcon, { className: "w-3 h-3" })) : (React.createElement(MinusIcon, { className: "w-3 h-3" })))) : null));
|
|
422
434
|
})));
|
|
423
435
|
});
|
package/dist/esm/release-date.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/spreadsheet",
|
|
3
|
-
"version": "10.10.
|
|
3
|
+
"version": "10.10.3",
|
|
4
4
|
"author": "Vinay M",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
42
42
|
"@dnd-kit/sortable": "^10.0.0",
|
|
43
43
|
"@dnd-kit/utilities": "^3.2.2",
|
|
44
|
-
"@rowsncolumns/calculator": ">=7.3.
|
|
44
|
+
"@rowsncolumns/calculator": ">=7.3.6",
|
|
45
45
|
"@rowsncolumns/common-types": ">=5.5.1",
|
|
46
46
|
"@rowsncolumns/fast-formula-parser": ">=6.2.49",
|
|
47
47
|
"@rowsncolumns/functions": ">=15.1.4",
|