@rowsncolumns/utils 9.2.37 → 9.2.38
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/cell-data-helpers.d.ts +22 -1
- package/dist/cjs/cell-data-helpers.d.ts.map +1 -1
- package/dist/cjs/cell-data-helpers.js +29 -1
- package/dist/esm/cell-data-helpers.d.ts +22 -1
- package/dist/esm/cell-data-helpers.d.ts.map +1 -1
- package/dist/esm/cell-data-helpers.js +25 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Note: These functions use generic types to avoid circular dependencies
|
|
6
6
|
*/
|
|
7
|
-
import type { CellData, CellFormat, StyleReference } from "@rowsncolumns/common-types";
|
|
7
|
+
import type { CellData, CellFormat, DataValidationRule, HorizontalAlign, StyleReference } from "@rowsncolumns/common-types";
|
|
8
8
|
export declare const getCellUserEnteredValue: <T extends CellData>(cell?: T | null) => T["ue"];
|
|
9
9
|
export declare const getCellEffectiveValue: <T extends CellData>(cell?: T | null) => T["ev"];
|
|
10
10
|
export declare const getCellUserEnteredFormat: <T extends CellData>(cell?: T | null) => T["uf"];
|
|
@@ -16,4 +16,25 @@ export declare const getExtendedValueString: (extValue?: Record<string, any> | n
|
|
|
16
16
|
export declare const getExtendedValueBool: (extValue?: Record<string, any> | null) => boolean | undefined;
|
|
17
17
|
export declare const getExtendedValueFormula: (extValue?: Record<string, any> | null) => string | undefined;
|
|
18
18
|
export declare const getExtendedValueError: (extValue?: Record<string, any> | null) => any | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal alignment the grid paints for a cell that has no explicit
|
|
21
|
+
* `horizontalAlignment` (Excel / Google Sheets "General"): errors,
|
|
22
|
+
* user-entered booleans and checkbox cells centre, numeric effective values
|
|
23
|
+
* right, everything else falls back to the renderer default (left, returned
|
|
24
|
+
* here as `undefined`).
|
|
25
|
+
*
|
|
26
|
+
* A checkbox cell centres regardless of its VALUE: a blank checkbox (no `ue`
|
|
27
|
+
* at all) and a windowed host whose lean read reconstructs the boolean as
|
|
28
|
+
* text both miss the `bv` probe, so the BOOLEAN data-validation rule decides.
|
|
29
|
+
*
|
|
30
|
+
* Shared by the CanvasGrid renderer and the state hooks'
|
|
31
|
+
* `getDefaultHorizontalAlignment(sheetId, rowIndex, columnIndex)` so a toolbar
|
|
32
|
+
* alignment selector reports the alignment the grid actually draws.
|
|
33
|
+
*/
|
|
34
|
+
export declare const resolveDefaultHorizontalAlignment: ({ errorValue, userEnteredValue, effectiveValue, dataValidation, }: {
|
|
35
|
+
errorValue: unknown;
|
|
36
|
+
userEnteredValue: Record<string, any> | null | undefined;
|
|
37
|
+
effectiveValue: Record<string, any> | null | undefined;
|
|
38
|
+
dataValidation: Pick<DataValidationRule, "condition"> | null | undefined;
|
|
39
|
+
}) => HorizontalAlign | undefined;
|
|
19
40
|
//# sourceMappingURL=cell-data-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-data-helpers.d.ts","sourceRoot":"","sources":["../../cell-data-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACf,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,QAAQ,EACxD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EACtD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,QAAQ,EACzD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,QAAQ,EACvD,OAAO,CAAC,GAAG,IAAI,KACd,UAAU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C,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACzD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1E,KAAG,eAAe,GAAG,SASrB,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Note: These functions use generic types to avoid circular dependencies
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getExtendedValueError = exports.getExtendedValueFormula = exports.getExtendedValueBool = exports.getExtendedValueString = exports.getExtendedValueNumber = exports.getStyleId = exports.getCellFormattedValue = exports.getCellEffectiveFormat = exports.getCellUserEnteredFormat = exports.getCellEffectiveValue = exports.getCellUserEnteredValue = void 0;
|
|
9
|
+
exports.resolveDefaultHorizontalAlignment = exports.getExtendedValueError = exports.getExtendedValueFormula = exports.getExtendedValueBool = exports.getExtendedValueString = exports.getExtendedValueNumber = exports.getStyleId = exports.getCellFormattedValue = exports.getCellEffectiveFormat = exports.getCellUserEnteredFormat = exports.getCellEffectiveValue = exports.getCellUserEnteredValue = void 0;
|
|
10
10
|
var getCellUserEnteredValue = function (cell) {
|
|
11
11
|
var _a;
|
|
12
12
|
return (_a = cell === null || cell === void 0 ? void 0 : cell.ue) !== null && _a !== void 0 ? _a : cell === null || cell === void 0 ? void 0 : cell.userEnteredValue;
|
|
@@ -62,3 +62,31 @@ var getExtendedValueError = function (extValue) {
|
|
|
62
62
|
return (_a = extValue === null || extValue === void 0 ? void 0 : extValue.ev) !== null && _a !== void 0 ? _a : extValue === null || extValue === void 0 ? void 0 : extValue.errorValue;
|
|
63
63
|
};
|
|
64
64
|
exports.getExtendedValueError = getExtendedValueError;
|
|
65
|
+
/**
|
|
66
|
+
* Horizontal alignment the grid paints for a cell that has no explicit
|
|
67
|
+
* `horizontalAlignment` (Excel / Google Sheets "General"): errors,
|
|
68
|
+
* user-entered booleans and checkbox cells centre, numeric effective values
|
|
69
|
+
* right, everything else falls back to the renderer default (left, returned
|
|
70
|
+
* here as `undefined`).
|
|
71
|
+
*
|
|
72
|
+
* A checkbox cell centres regardless of its VALUE: a blank checkbox (no `ue`
|
|
73
|
+
* at all) and a windowed host whose lean read reconstructs the boolean as
|
|
74
|
+
* text both miss the `bv` probe, so the BOOLEAN data-validation rule decides.
|
|
75
|
+
*
|
|
76
|
+
* Shared by the CanvasGrid renderer and the state hooks'
|
|
77
|
+
* `getDefaultHorizontalAlignment(sheetId, rowIndex, columnIndex)` so a toolbar
|
|
78
|
+
* alignment selector reports the alignment the grid actually draws.
|
|
79
|
+
*/
|
|
80
|
+
var resolveDefaultHorizontalAlignment = function (_a) {
|
|
81
|
+
var _b;
|
|
82
|
+
var errorValue = _a.errorValue, userEnteredValue = _a.userEnteredValue, effectiveValue = _a.effectiveValue, dataValidation = _a.dataValidation;
|
|
83
|
+
var isBoolean = (0, exports.getExtendedValueBool)(userEnteredValue) !== undefined;
|
|
84
|
+
var isCheckbox = ((_b = dataValidation === null || dataValidation === void 0 ? void 0 : dataValidation.condition) === null || _b === void 0 ? void 0 : _b.type) === "BOOLEAN";
|
|
85
|
+
if (errorValue || isBoolean || isCheckbox) {
|
|
86
|
+
return "center";
|
|
87
|
+
}
|
|
88
|
+
return (0, exports.getExtendedValueNumber)(effectiveValue) !== undefined
|
|
89
|
+
? "right"
|
|
90
|
+
: undefined;
|
|
91
|
+
};
|
|
92
|
+
exports.resolveDefaultHorizontalAlignment = resolveDefaultHorizontalAlignment;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Note: These functions use generic types to avoid circular dependencies
|
|
6
6
|
*/
|
|
7
|
-
import type { CellData, CellFormat, StyleReference } from "@rowsncolumns/common-types";
|
|
7
|
+
import type { CellData, CellFormat, DataValidationRule, HorizontalAlign, StyleReference } from "@rowsncolumns/common-types";
|
|
8
8
|
export declare const getCellUserEnteredValue: <T extends CellData>(cell?: T | null) => T["ue"];
|
|
9
9
|
export declare const getCellEffectiveValue: <T extends CellData>(cell?: T | null) => T["ev"];
|
|
10
10
|
export declare const getCellUserEnteredFormat: <T extends CellData>(cell?: T | null) => T["uf"];
|
|
@@ -16,4 +16,25 @@ export declare const getExtendedValueString: (extValue?: Record<string, any> | n
|
|
|
16
16
|
export declare const getExtendedValueBool: (extValue?: Record<string, any> | null) => boolean | undefined;
|
|
17
17
|
export declare const getExtendedValueFormula: (extValue?: Record<string, any> | null) => string | undefined;
|
|
18
18
|
export declare const getExtendedValueError: (extValue?: Record<string, any> | null) => any | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal alignment the grid paints for a cell that has no explicit
|
|
21
|
+
* `horizontalAlignment` (Excel / Google Sheets "General"): errors,
|
|
22
|
+
* user-entered booleans and checkbox cells centre, numeric effective values
|
|
23
|
+
* right, everything else falls back to the renderer default (left, returned
|
|
24
|
+
* here as `undefined`).
|
|
25
|
+
*
|
|
26
|
+
* A checkbox cell centres regardless of its VALUE: a blank checkbox (no `ue`
|
|
27
|
+
* at all) and a windowed host whose lean read reconstructs the boolean as
|
|
28
|
+
* text both miss the `bv` probe, so the BOOLEAN data-validation rule decides.
|
|
29
|
+
*
|
|
30
|
+
* Shared by the CanvasGrid renderer and the state hooks'
|
|
31
|
+
* `getDefaultHorizontalAlignment(sheetId, rowIndex, columnIndex)` so a toolbar
|
|
32
|
+
* alignment selector reports the alignment the grid actually draws.
|
|
33
|
+
*/
|
|
34
|
+
export declare const resolveDefaultHorizontalAlignment: ({ errorValue, userEnteredValue, effectiveValue, dataValidation, }: {
|
|
35
|
+
errorValue: unknown;
|
|
36
|
+
userEnteredValue: Record<string, any> | null | undefined;
|
|
37
|
+
effectiveValue: Record<string, any> | null | undefined;
|
|
38
|
+
dataValidation: Pick<DataValidationRule, "condition"> | null | undefined;
|
|
39
|
+
}) => HorizontalAlign | undefined;
|
|
19
40
|
//# sourceMappingURL=cell-data-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-data-helpers.d.ts","sourceRoot":"","sources":["../../cell-data-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACf,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,QAAQ,EACxD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EACtD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,QAAQ,EACzD,OAAO,CAAC,GAAG,IAAI,KACd,CAAC,CAAC,IAAI,CAER,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,QAAQ,EACvD,OAAO,CAAC,GAAG,IAAI,KACd,UAAU,GAAG,cAAc,GAAG,IAAI,GAAG,SAEvC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EACtD,OAAO,CAAC,GAAG,IAAI,KACd,MAAM,GAAG,SAAS,GAAG,IAEvB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAE1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,WA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AO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,OAAO,GAAG,SAEZ,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,MAAM,GAAG,SAEX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KACpC,GAAG,GAAG,SAER,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAAI,mEAK/C;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACzD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1E,KAAG,eAAe,GAAG,SASrB,CAAC"}
|
|
@@ -37,3 +37,28 @@ export const getExtendedValueFormula = (extValue) => {
|
|
|
37
37
|
export const getExtendedValueError = (extValue) => {
|
|
38
38
|
return extValue?.ev ?? extValue?.errorValue;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Horizontal alignment the grid paints for a cell that has no explicit
|
|
42
|
+
* `horizontalAlignment` (Excel / Google Sheets "General"): errors,
|
|
43
|
+
* user-entered booleans and checkbox cells centre, numeric effective values
|
|
44
|
+
* right, everything else falls back to the renderer default (left, returned
|
|
45
|
+
* here as `undefined`).
|
|
46
|
+
*
|
|
47
|
+
* A checkbox cell centres regardless of its VALUE: a blank checkbox (no `ue`
|
|
48
|
+
* at all) and a windowed host whose lean read reconstructs the boolean as
|
|
49
|
+
* text both miss the `bv` probe, so the BOOLEAN data-validation rule decides.
|
|
50
|
+
*
|
|
51
|
+
* Shared by the CanvasGrid renderer and the state hooks'
|
|
52
|
+
* `getDefaultHorizontalAlignment(sheetId, rowIndex, columnIndex)` so a toolbar
|
|
53
|
+
* alignment selector reports the alignment the grid actually draws.
|
|
54
|
+
*/
|
|
55
|
+
export const resolveDefaultHorizontalAlignment = ({ errorValue, userEnteredValue, effectiveValue, dataValidation, }) => {
|
|
56
|
+
const isBoolean = getExtendedValueBool(userEnteredValue) !== undefined;
|
|
57
|
+
const isCheckbox = dataValidation?.condition?.type === "BOOLEAN";
|
|
58
|
+
if (errorValue || isBoolean || isCheckbox) {
|
|
59
|
+
return "center";
|
|
60
|
+
}
|
|
61
|
+
return getExtendedValueNumber(effectiveValue) !== undefined
|
|
62
|
+
? "right"
|
|
63
|
+
: undefined;
|
|
64
|
+
};
|