@rowsncolumns/utils 9.2.44 → 9.4.0
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/formula-locale/formula-locale-data.generated.d.ts +44 -0
- package/dist/cjs/formula-locale/formula-locale-data.generated.d.ts.map +1 -0
- package/dist/cjs/formula-locale/formula-locale-data.generated.js +5567 -0
- package/dist/cjs/formula-locale.d.ts +159 -0
- package/dist/cjs/formula-locale.d.ts.map +1 -0
- package/dist/cjs/formula-locale.js +804 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/sparkline-groups.d.ts +102 -0
- package/dist/cjs/sparkline-groups.d.ts.map +1 -0
- package/dist/cjs/sparkline-groups.js +452 -0
- package/dist/cjs/string.d.ts +15 -0
- package/dist/cjs/string.d.ts.map +1 -1
- package/dist/cjs/string.js +46 -1
- package/dist/cjs/table-names.d.ts +55 -0
- package/dist/cjs/table-names.d.ts.map +1 -0
- package/dist/cjs/table-names.js +189 -0
- package/dist/cjs/table-styles.d.ts +9 -0
- package/dist/cjs/table-styles.d.ts.map +1 -1
- package/dist/cjs/table-styles.js +53 -1
- package/dist/cjs/table-totals.d.ts +31 -0
- package/dist/cjs/table-totals.d.ts.map +1 -0
- package/dist/cjs/table-totals.js +84 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/formula-locale/formula-locale-data.generated.d.ts +44 -0
- package/dist/esm/formula-locale/formula-locale-data.generated.d.ts.map +1 -0
- package/dist/esm/formula-locale/formula-locale-data.generated.js +5564 -0
- package/dist/esm/formula-locale.d.ts +159 -0
- package/dist/esm/formula-locale.d.ts.map +1 -0
- package/dist/esm/formula-locale.js +0 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/sparkline-groups.d.ts +102 -0
- package/dist/esm/sparkline-groups.d.ts.map +1 -0
- package/dist/esm/sparkline-groups.js +387 -0
- package/dist/esm/string.d.ts +15 -0
- package/dist/esm/string.d.ts.map +1 -1
- package/dist/esm/string.js +43 -0
- package/dist/esm/table-names.d.ts +55 -0
- package/dist/esm/table-names.d.ts.map +1 -0
- package/dist/esm/table-names.js +129 -0
- package/dist/esm/table-styles.d.ts +9 -0
- package/dist/esm/table-styles.d.ts.map +1 -1
- package/dist/esm/table-styles.js +34 -1
- package/dist/esm/table-totals.d.ts +31 -0
- package/dist/esm/table-totals.d.ts.map +1 -0
- package/dist/esm/table-totals.js +68 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-styles.d.ts","sourceRoot":"","sources":["../../table-styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAG5C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;AAExC,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,cAAc,GACd,aAAa,GACb,QAAQ,CAAC;AAGb,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,C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B,GAAG,SAAS;CAC7C,CAAC;AAKF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,OAAO,GAAG,SAAS,EACnC,mBAAmB,OAAO,GAAG,SAAS,KACrC,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAoX/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,UAAU,EACtB,gBAAgB,OAAO,GAAG,SAAS,EACnC,mBAAmB,OAAO,GAAG,SAAS,KACrC,gBAAgB,GAAG,SAcrB,CAAC"}
|
package/dist/esm/table-styles.js
CHANGED
|
@@ -11,7 +11,7 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
11
11
|
let runningLightIndex = 1;
|
|
12
12
|
let runningMediumIndex = 1;
|
|
13
13
|
let runningDarkIndex = 1;
|
|
14
|
-
|
|
14
|
+
const styles = new Map([
|
|
15
15
|
[
|
|
16
16
|
"Light",
|
|
17
17
|
[
|
|
@@ -285,6 +285,10 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
285
285
|
...colorIndexes.map((value) => {
|
|
286
286
|
const firstTint = value - 1 === 0 ? 0.25 : -0.25;
|
|
287
287
|
const secondTint = value - 1 === 0 ? 0.5 : 0;
|
|
288
|
+
const edgeColumnColor = {
|
|
289
|
+
theme: value,
|
|
290
|
+
tint: value - 1 === 0 ? 0.15 : -0.5,
|
|
291
|
+
};
|
|
288
292
|
return [
|
|
289
293
|
("TableStyleDark" + runningDarkIndex++),
|
|
290
294
|
firstTint,
|
|
@@ -300,6 +304,8 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
300
304
|
theme: value,
|
|
301
305
|
tint: secondTint,
|
|
302
306
|
},
|
|
307
|
+
firstColumnColor: edgeColumnColor,
|
|
308
|
+
lastColumnColor: edgeColumnColor,
|
|
303
309
|
},
|
|
304
310
|
columnProperties: showColumnStripes
|
|
305
311
|
? {
|
|
@@ -315,6 +321,10 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
315
321
|
...[1, 5, 7, 9].map((value) => {
|
|
316
322
|
const firstTint = value - 1 === 0 ? -0.35 : 0.6;
|
|
317
323
|
const secondTint = value - 1 === 0 ? -0.15 : 0.8;
|
|
324
|
+
const edgeColumnColor = {
|
|
325
|
+
theme: value - 1,
|
|
326
|
+
tint: value - 1 === 0 ? -0.5 : 0.4,
|
|
327
|
+
};
|
|
318
328
|
return [
|
|
319
329
|
("TableStyleDark" + runningDarkIndex++),
|
|
320
330
|
firstTint,
|
|
@@ -330,6 +340,8 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
330
340
|
theme: value - 1,
|
|
331
341
|
tint: secondTint,
|
|
332
342
|
},
|
|
343
|
+
firstColumnColor: edgeColumnColor,
|
|
344
|
+
lastColumnColor: edgeColumnColor,
|
|
333
345
|
},
|
|
334
346
|
columnProperties: showColumnStripes
|
|
335
347
|
? {
|
|
@@ -345,6 +357,27 @@ export const getTableBorderStyles = (showRowStripes, showColumnStripes) => {
|
|
|
345
357
|
],
|
|
346
358
|
],
|
|
347
359
|
]);
|
|
360
|
+
// Excel's built-in table styles bold the totals row and rule it with a double top border in
|
|
361
|
+
// the style's accent colour — the header border's colour, else the header fill's, else the
|
|
362
|
+
// stripe border's.
|
|
363
|
+
for (const entries of styles.values()) {
|
|
364
|
+
for (const [, , , bandDefinition] of entries) {
|
|
365
|
+
const rows = bandDefinition?.rowProperties;
|
|
366
|
+
if (!rows)
|
|
367
|
+
continue;
|
|
368
|
+
rows.totalRowBold = true;
|
|
369
|
+
const accent = rows.headerBorder?.top?.color ??
|
|
370
|
+
rows.headerBorder?.bottom?.color ??
|
|
371
|
+
rows.headerColor ??
|
|
372
|
+
rows.firstBandBorder?.bottom?.color;
|
|
373
|
+
if (accent && !rows.totalRowBorder) {
|
|
374
|
+
rows.totalRowBorder = {
|
|
375
|
+
top: { width: 1, style: "double", color: accent },
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return styles;
|
|
348
381
|
};
|
|
349
382
|
/**
|
|
350
383
|
* Find the banded definition for a given table theme
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's table totals row: the `totalsRowFunction` values a `<tableColumn>` carries
|
|
3
|
+
* (ECMA-376 `ST_TotalsRowFunction`), the hidden-row-aware `SUBTOTAL` number each one
|
|
4
|
+
* writes into the totals cell, and the structured-reference formula for it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TOTALS_ROW_FUNCTIONS: readonly ["none", "average", "count", "countNums", "max", "min", "sum", "stdDev", "var", "custom"];
|
|
7
|
+
export type TotalsRowFunction = (typeof TOTALS_ROW_FUNCTIONS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* `SUBTOTAL` function numbers of the 101–111 family (ignore rows hidden by a filter),
|
|
10
|
+
* as Excel writes them into a totals-row cell. `none` and `custom` have none.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOTALS_ROW_FUNCTION_SUBTOTAL: Readonly<Partial<Record<TotalsRowFunction, number>>>;
|
|
13
|
+
export declare const isTotalsRowFunction: (value: unknown) => value is TotalsRowFunction;
|
|
14
|
+
/**
|
|
15
|
+
* Escape a column name for use inside a structured reference: `[`, `]`, `#`
|
|
16
|
+
* and `'` are prefixed with `'`, as Excel does (`Sales[Amount '[est']]`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const escapeStructuredColumnName: (name: string) => string;
|
|
19
|
+
/**
|
|
20
|
+
* The totals-row formula for `fn` over a table column, qualified with the table
|
|
21
|
+
* name so it evaluates from any engine and matches what Excel writes:
|
|
22
|
+
* `=SUBTOTAL(109,Sales[Amount])`. `undefined` for `none` / `custom`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getTotalsRowFormula: (fn: TotalsRowFunction, tableName: string, columnName: string) => string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Recognise the aggregation a totals-row formula uses. Both the hidden-row-aware
|
|
27
|
+
* (1xx) and plain (1–11) `SUBTOTAL` numbers map to the same function; anything
|
|
28
|
+
* else is `none`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const getTotalsRowFunctionFromFormula: (formula: string | null | undefined) => TotalsRowFunction;
|
|
31
|
+
//# sourceMappingURL=table-totals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-totals.d.ts","sourceRoot":"","sources":["../../table-totals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,oGAWvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CACjD,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAU3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,KACb,KAAK,IAAI,iBAEiD,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,MAAM,WACnB,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,IAAI,iBAAiB,EACrB,WAAW,MAAM,EACjB,YAAY,MAAM,KACjB,MAAM,GAAG,SAQX,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAC1C,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,KACjC,iBAcF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel's table totals row: the `totalsRowFunction` values a `<tableColumn>` carries
|
|
3
|
+
* (ECMA-376 `ST_TotalsRowFunction`), the hidden-row-aware `SUBTOTAL` number each one
|
|
4
|
+
* writes into the totals cell, and the structured-reference formula for it.
|
|
5
|
+
*/
|
|
6
|
+
export const TOTALS_ROW_FUNCTIONS = [
|
|
7
|
+
"none",
|
|
8
|
+
"average",
|
|
9
|
+
"count",
|
|
10
|
+
"countNums",
|
|
11
|
+
"max",
|
|
12
|
+
"min",
|
|
13
|
+
"sum",
|
|
14
|
+
"stdDev",
|
|
15
|
+
"var",
|
|
16
|
+
"custom",
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* `SUBTOTAL` function numbers of the 101–111 family (ignore rows hidden by a filter),
|
|
20
|
+
* as Excel writes them into a totals-row cell. `none` and `custom` have none.
|
|
21
|
+
*/
|
|
22
|
+
export const TOTALS_ROW_FUNCTION_SUBTOTAL = {
|
|
23
|
+
average: 101,
|
|
24
|
+
countNums: 102,
|
|
25
|
+
count: 103,
|
|
26
|
+
max: 104,
|
|
27
|
+
min: 105,
|
|
28
|
+
stdDev: 107,
|
|
29
|
+
sum: 109,
|
|
30
|
+
var: 110,
|
|
31
|
+
};
|
|
32
|
+
export const isTotalsRowFunction = (value) => typeof value === "string" &&
|
|
33
|
+
TOTALS_ROW_FUNCTIONS.includes(value);
|
|
34
|
+
/**
|
|
35
|
+
* Escape a column name for use inside a structured reference: `[`, `]`, `#`
|
|
36
|
+
* and `'` are prefixed with `'`, as Excel does (`Sales[Amount '[est']]`).
|
|
37
|
+
*/
|
|
38
|
+
export const escapeStructuredColumnName = (name) => name.replace(/(['\[\]#])/g, "'$1");
|
|
39
|
+
/**
|
|
40
|
+
* The totals-row formula for `fn` over a table column, qualified with the table
|
|
41
|
+
* name so it evaluates from any engine and matches what Excel writes:
|
|
42
|
+
* `=SUBTOTAL(109,Sales[Amount])`. `undefined` for `none` / `custom`.
|
|
43
|
+
*/
|
|
44
|
+
export const getTotalsRowFormula = (fn, tableName, columnName) => {
|
|
45
|
+
const subtotal = TOTALS_ROW_FUNCTION_SUBTOTAL[fn];
|
|
46
|
+
if (subtotal === undefined) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
return `=SUBTOTAL(${subtotal},${tableName}[${escapeStructuredColumnName(columnName)}])`;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Recognise the aggregation a totals-row formula uses. Both the hidden-row-aware
|
|
53
|
+
* (1xx) and plain (1–11) `SUBTOTAL` numbers map to the same function; anything
|
|
54
|
+
* else is `none`.
|
|
55
|
+
*/
|
|
56
|
+
export const getTotalsRowFunctionFromFormula = (formula) => {
|
|
57
|
+
if (!formula) {
|
|
58
|
+
return "none";
|
|
59
|
+
}
|
|
60
|
+
const match = /^\s*=\s*SUBTOTAL\s*\(\s*(\d{1,3})\s*,/i.exec(formula);
|
|
61
|
+
if (!match) {
|
|
62
|
+
return "none";
|
|
63
|
+
}
|
|
64
|
+
const number = Number(match[1]);
|
|
65
|
+
const normalized = number > 100 ? number - 100 : number;
|
|
66
|
+
const found = Object.entries(TOTALS_ROW_FUNCTION_SUBTOTAL).find(([, subtotal]) => subtotal - 100 === normalized);
|
|
67
|
+
return found?.[0] ?? "none";
|
|
68
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../array.ts","../../cell-data-helpers.ts","../../color.ts","../../colors.ts","../../conditional-format.ts","../../content-hash.ts","../../data-validation.ts","../../date.ts","../../dom.ts","../../excel-number-format.ts","../../formatter.ts","../../formula-refs.ts","../../formula.ts","../../index.ts","../../keyboard.ts","../../locale.ts","../../log.ts","../../memoize.ts","../../numbers.ts","../../selection.ts","../../shared-string-canonical.ts","../../sheet-span.ts","../../sort.ts","../../string.ts","../../table-styles.ts","../../typeguards.ts","../../uuid.ts","../../vitest.config.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../../array.ts","../../cell-data-helpers.ts","../../color.ts","../../colors.ts","../../conditional-format.ts","../../content-hash.ts","../../data-validation.ts","../../date.ts","../../dom.ts","../../excel-number-format.ts","../../formatter.ts","../../formula-locale.ts","../../formula-refs.ts","../../formula.ts","../../index.ts","../../keyboard.ts","../../locale.ts","../../log.ts","../../memoize.ts","../../numbers.ts","../../selection.ts","../../shared-string-canonical.ts","../../sheet-span.ts","../../sort.ts","../../sparkline-groups.ts","../../string.ts","../../table-names.ts","../../table-styles.ts","../../table-totals.ts","../../typeguards.ts","../../uuid.ts","../../vitest.config.ts","../../formula-locale/formula-locale-data.generated.ts"],"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/utils",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"author": "Vinay M",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"clean": "rimraf dist",
|
|
29
29
|
"build:watch": "tsc -p ./tsconfig.esm.json --watch",
|
|
30
30
|
"test": "vitest --run",
|
|
31
|
-
"types": "tsc -p . --noEmit"
|
|
31
|
+
"types": "tsc -p . --noEmit",
|
|
32
|
+
"types:specs": "node ../../scripts/typecheck-specs.mjs",
|
|
33
|
+
"types:specs:update": "node ../../scripts/typecheck-specs.mjs --update"
|
|
32
34
|
},
|
|
33
35
|
"files": [
|
|
34
36
|
"dist"
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
46
|
"numfmt": "^3.2.2",
|
|
45
|
-
"@rowsncolumns/common-types": ">=5.2.
|
|
47
|
+
"@rowsncolumns/common-types": ">=5.2.34"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {},
|
|
48
50
|
"peerDependencies": {}
|