svg-table 0.0.1
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/LICENSE +21 -0
- package/README.md +3 -0
- package/d3types.ts +17 -0
- package/dist/d3types.d.ts +12 -0
- package/dist/d3types.d.ts.map +1 -0
- package/dist/d3types.js +3 -0
- package/dist/d3types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/stylings.d.ts +206 -0
- package/dist/stylings.d.ts.map +1 -0
- package/dist/stylings.js +123 -0
- package/dist/stylings.js.map +1 -0
- package/dist/tableData.d.ts +168 -0
- package/dist/tableData.d.ts.map +1 -0
- package/dist/tableData.js +329 -0
- package/dist/tableData.js.map +1 -0
- package/dist/tableData.test.d.ts +2 -0
- package/dist/tableData.test.d.ts.map +1 -0
- package/dist/tableData.test.js +259 -0
- package/dist/tableData.test.js.map +1 -0
- package/dist/tableFormatter.d.ts +179 -0
- package/dist/tableFormatter.d.ts.map +1 -0
- package/dist/tableFormatter.js +298 -0
- package/dist/tableFormatter.js.map +1 -0
- package/dist/tableFormatter.test.d.ts +2 -0
- package/dist/tableFormatter.test.d.ts.map +1 -0
- package/dist/tableFormatter.test.js +101 -0
- package/dist/tableFormatter.test.js.map +1 -0
- package/dist/tableStyler.d.ts +310 -0
- package/dist/tableStyler.d.ts.map +1 -0
- package/dist/tableStyler.js +665 -0
- package/dist/tableStyler.js.map +1 -0
- package/dist/tableStyler.test.d.ts +2 -0
- package/dist/tableStyler.test.d.ts.map +1 -0
- package/dist/tableStyler.test.js +225 -0
- package/dist/tableStyler.test.js.map +1 -0
- package/dist/tableSvg.d.ts +41 -0
- package/dist/tableSvg.d.ts.map +1 -0
- package/dist/tableSvg.js +634 -0
- package/dist/tableSvg.js.map +1 -0
- package/dist/tableUtils.d.ts +14 -0
- package/dist/tableUtils.d.ts.map +1 -0
- package/dist/tableUtils.js +18 -0
- package/dist/tableUtils.js.map +1 -0
- package/eslint.config.js +23 -0
- package/index.ts +82 -0
- package/jest.config.js +5 -0
- package/package.json +44 -0
- package/stylings.ts +311 -0
- package/svg-table-0.0.1-snapshot.tgz +0 -0
- package/tableData.test.ts +290 -0
- package/tableData.ts +359 -0
- package/tableFormatter.test.ts +122 -0
- package/tableFormatter.ts +306 -0
- package/tableStyler.test.ts +268 -0
- package/tableStyler.ts +798 -0
- package/tableSvg.ts +820 -0
- package/tableUtils.ts +20 -0
- package/tsconfig.json +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rob Philipp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/d3types.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// the axis-element type return when calling the ".call(axis)" function
|
|
2
|
+
import type {Selection} from "d3";
|
|
3
|
+
|
|
4
|
+
export type GroupSelection = Selection<SVGGElement, any, null, undefined>
|
|
5
|
+
export type TextSelection = Selection<SVGTextElement, any, null, undefined>
|
|
6
|
+
export type RectSelection = Selection<SVGRectElement, any, null, undefined>
|
|
7
|
+
export type LineSelection = Selection<SVGLineElement, any, null, undefined>
|
|
8
|
+
|
|
9
|
+
export type BorderSelection = {
|
|
10
|
+
top?: LineSelection
|
|
11
|
+
bottom?: LineSelection
|
|
12
|
+
left?: LineSelection
|
|
13
|
+
right?: LineSelection
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Selection } from "d3";
|
|
2
|
+
export type GroupSelection = Selection<SVGGElement, any, null, undefined>;
|
|
3
|
+
export type TextSelection = Selection<SVGTextElement, any, null, undefined>;
|
|
4
|
+
export type RectSelection = Selection<SVGRectElement, any, null, undefined>;
|
|
5
|
+
export type LineSelection = Selection<SVGLineElement, any, null, undefined>;
|
|
6
|
+
export type BorderSelection = {
|
|
7
|
+
top?: LineSelection;
|
|
8
|
+
bottom?: LineSelection;
|
|
9
|
+
left?: LineSelection;
|
|
10
|
+
right?: LineSelection;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=d3types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d3types.d.ts","sourceRoot":"","sources":["../d3types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,IAAI,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;AACzE,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;AAC3E,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;AAC3E,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;AAE3E,MAAM,MAAM,eAAe,GAAG;IAC1B,GAAG,CAAC,EAAE,aAAa,CAAA;IACnB,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,KAAK,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA"}
|
package/dist/d3types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d3types.js","sourceRoot":"","sources":["../d3types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { GroupSelection, TextSelection, RectSelection, LineSelection, BorderSelection } from './d3types';
|
|
2
|
+
export type { Styling, TableStylerProps, TableFont, Background, Padding, Margin, BorderElement, Border, Dimension, ColumnStyle, RowStyle, TextAlignment, VerticalTextAlignment, CellStyle, ColumnHeaderStyle, RowHeaderStyle, FooterStyle, Stylings, } from './stylings';
|
|
3
|
+
export { stylingFor, TableStyleType, defaultTableFont, defaultTableBackground, defaultTablePadding, defaultTableMargin, defaultBorderElement, defaultBorder, defaultDimension, defaultColumnStyle, defaultRowStyle, defaultCellStyle, defaultColumnHeaderStyle, defaultRowHeaderStyle, defaultFooterStyle, } from './stylings';
|
|
4
|
+
export { TableData, TableTagType } from './tableData';
|
|
5
|
+
export type { Formatter, Formatting, } from './tableFormatter';
|
|
6
|
+
export { defaultFormatter, defaultFormatting, TableFormatterType, isFormattingTag, TableFormatter } from './tableFormatter';
|
|
7
|
+
export { StyledTable, TableStyler } from './tableStyler';
|
|
8
|
+
export type { ElementPlacementInfo, TextAnchor, DominantBaseline, CellRenderingDimensions, TableRenderingInfo } from './tableSvg';
|
|
9
|
+
export { elementInfoFrom, createTable, tableId, } from './tableSvg';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EAClB,MAAM,WAAW,CAAA;AAElB,YAAY,EACR,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,OAAO,EACP,MAAM,EACN,aAAa,EACb,MAAM,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,QAAQ,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACH,SAAS,EACT,YAAY,EACf,MAAM,aAAa,CAAC;AAErB,YAAY,EACR,SAAS,EACT,UAAU,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACH,WAAW,EACX,WAAW,EACd,MAAM,eAAe,CAAC;AAEvB,YAAY,EACR,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACH,eAAe,EACf,WAAW,EACX,OAAO,GACV,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableId = exports.createTable = exports.elementInfoFrom = exports.TableStyler = exports.StyledTable = exports.TableFormatter = exports.isFormattingTag = exports.TableFormatterType = exports.defaultFormatting = exports.defaultFormatter = exports.TableTagType = exports.TableData = exports.defaultFooterStyle = exports.defaultRowHeaderStyle = exports.defaultColumnHeaderStyle = exports.defaultCellStyle = exports.defaultRowStyle = exports.defaultColumnStyle = exports.defaultDimension = exports.defaultBorder = exports.defaultBorderElement = exports.defaultTableMargin = exports.defaultTablePadding = exports.defaultTableBackground = exports.defaultTableFont = exports.TableStyleType = exports.stylingFor = void 0;
|
|
4
|
+
var stylings_1 = require("./stylings");
|
|
5
|
+
Object.defineProperty(exports, "stylingFor", { enumerable: true, get: function () { return stylings_1.stylingFor; } });
|
|
6
|
+
Object.defineProperty(exports, "TableStyleType", { enumerable: true, get: function () { return stylings_1.TableStyleType; } });
|
|
7
|
+
Object.defineProperty(exports, "defaultTableFont", { enumerable: true, get: function () { return stylings_1.defaultTableFont; } });
|
|
8
|
+
Object.defineProperty(exports, "defaultTableBackground", { enumerable: true, get: function () { return stylings_1.defaultTableBackground; } });
|
|
9
|
+
Object.defineProperty(exports, "defaultTablePadding", { enumerable: true, get: function () { return stylings_1.defaultTablePadding; } });
|
|
10
|
+
Object.defineProperty(exports, "defaultTableMargin", { enumerable: true, get: function () { return stylings_1.defaultTableMargin; } });
|
|
11
|
+
Object.defineProperty(exports, "defaultBorderElement", { enumerable: true, get: function () { return stylings_1.defaultBorderElement; } });
|
|
12
|
+
Object.defineProperty(exports, "defaultBorder", { enumerable: true, get: function () { return stylings_1.defaultBorder; } });
|
|
13
|
+
Object.defineProperty(exports, "defaultDimension", { enumerable: true, get: function () { return stylings_1.defaultDimension; } });
|
|
14
|
+
Object.defineProperty(exports, "defaultColumnStyle", { enumerable: true, get: function () { return stylings_1.defaultColumnStyle; } });
|
|
15
|
+
Object.defineProperty(exports, "defaultRowStyle", { enumerable: true, get: function () { return stylings_1.defaultRowStyle; } });
|
|
16
|
+
Object.defineProperty(exports, "defaultCellStyle", { enumerable: true, get: function () { return stylings_1.defaultCellStyle; } });
|
|
17
|
+
Object.defineProperty(exports, "defaultColumnHeaderStyle", { enumerable: true, get: function () { return stylings_1.defaultColumnHeaderStyle; } });
|
|
18
|
+
Object.defineProperty(exports, "defaultRowHeaderStyle", { enumerable: true, get: function () { return stylings_1.defaultRowHeaderStyle; } });
|
|
19
|
+
Object.defineProperty(exports, "defaultFooterStyle", { enumerable: true, get: function () { return stylings_1.defaultFooterStyle; } });
|
|
20
|
+
var tableData_1 = require("./tableData");
|
|
21
|
+
Object.defineProperty(exports, "TableData", { enumerable: true, get: function () { return tableData_1.TableData; } });
|
|
22
|
+
Object.defineProperty(exports, "TableTagType", { enumerable: true, get: function () { return tableData_1.TableTagType; } });
|
|
23
|
+
var tableFormatter_1 = require("./tableFormatter");
|
|
24
|
+
Object.defineProperty(exports, "defaultFormatter", { enumerable: true, get: function () { return tableFormatter_1.defaultFormatter; } });
|
|
25
|
+
Object.defineProperty(exports, "defaultFormatting", { enumerable: true, get: function () { return tableFormatter_1.defaultFormatting; } });
|
|
26
|
+
Object.defineProperty(exports, "TableFormatterType", { enumerable: true, get: function () { return tableFormatter_1.TableFormatterType; } });
|
|
27
|
+
Object.defineProperty(exports, "isFormattingTag", { enumerable: true, get: function () { return tableFormatter_1.isFormattingTag; } });
|
|
28
|
+
Object.defineProperty(exports, "TableFormatter", { enumerable: true, get: function () { return tableFormatter_1.TableFormatter; } });
|
|
29
|
+
var tableStyler_1 = require("./tableStyler");
|
|
30
|
+
Object.defineProperty(exports, "StyledTable", { enumerable: true, get: function () { return tableStyler_1.StyledTable; } });
|
|
31
|
+
Object.defineProperty(exports, "TableStyler", { enumerable: true, get: function () { return tableStyler_1.TableStyler; } });
|
|
32
|
+
var tableSvg_1 = require("./tableSvg");
|
|
33
|
+
Object.defineProperty(exports, "elementInfoFrom", { enumerable: true, get: function () { return tableSvg_1.elementInfoFrom; } });
|
|
34
|
+
Object.defineProperty(exports, "createTable", { enumerable: true, get: function () { return tableSvg_1.createTable; } });
|
|
35
|
+
Object.defineProperty(exports, "tableId", { enumerable: true, get: function () { return tableSvg_1.tableId; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AA4BA,uCAgBoB;AAfhB,sGAAA,UAAU,OAAA;AACV,0GAAA,cAAc,OAAA;AACd,4GAAA,gBAAgB,OAAA;AAChB,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,gHAAA,oBAAoB,OAAA;AACpB,yGAAA,aAAa,OAAA;AACb,4GAAA,gBAAgB,OAAA;AAChB,8GAAA,kBAAkB,OAAA;AAClB,2GAAA,eAAe,OAAA;AACf,4GAAA,gBAAgB,OAAA;AAChB,oHAAA,wBAAwB,OAAA;AACxB,iHAAA,qBAAqB,OAAA;AACrB,8GAAA,kBAAkB,OAAA;AAGtB,yCAGqB;AAFjB,sGAAA,SAAS,OAAA;AACT,yGAAA,YAAY,OAAA;AAQhB,mDAM0B;AALtB,kHAAA,gBAAgB,OAAA;AAChB,mHAAA,iBAAiB,OAAA;AACjB,oHAAA,kBAAkB,OAAA;AAClB,iHAAA,eAAe,OAAA;AACf,gHAAA,cAAc,OAAA;AAGlB,6CAGuB;AAFnB,0GAAA,WAAW,OAAA;AACX,0GAAA,WAAW,OAAA;AAWf,uCAIoB;AAHhB,2GAAA,eAAe,OAAA;AACf,uGAAA,WAAW,OAAA;AACX,mGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { DataFrame } from "data-frame-ts";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a styling configuration with a priority level.
|
|
4
|
+
* Higher priority styles will override lower priority styles when multiple styles are applied.
|
|
5
|
+
*/
|
|
6
|
+
export type Styling<S> = {
|
|
7
|
+
style: S;
|
|
8
|
+
priority: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates a Styling object with the given style and priority.
|
|
12
|
+
* @param style The style to apply
|
|
13
|
+
* @param defaultStyle The default style that is used to fill in missing style attributes
|
|
14
|
+
* @param priority The priority level of the style (higher values take precedence)
|
|
15
|
+
* @returns A Styling object containing the style and priority
|
|
16
|
+
*/
|
|
17
|
+
export declare function stylingFor<S>(style: Partial<S>, defaultStyle: S, priority?: number): Styling<S>;
|
|
18
|
+
/**
|
|
19
|
+
* Enum representing different types of table styling elements.
|
|
20
|
+
* Used as identifiers when tagging different parts of the table with styles.
|
|
21
|
+
*/
|
|
22
|
+
export declare enum TableStyleType {
|
|
23
|
+
COLUMN_HEADER = "column_header_style",
|
|
24
|
+
ROW_HEADER = "row_header_style",
|
|
25
|
+
FOOTER = "footer_style",
|
|
26
|
+
ROW = "row_style",
|
|
27
|
+
COLUMN = "column_style",
|
|
28
|
+
CELL = "cell_style"
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Properties for the TableStyler class.
|
|
32
|
+
* Contains all the styling information and data for a table.
|
|
33
|
+
*/
|
|
34
|
+
export type TableStylerProps<V> = {
|
|
35
|
+
dataFrame: DataFrame<V>;
|
|
36
|
+
readonly font: TableFont;
|
|
37
|
+
border: Border;
|
|
38
|
+
background: Background;
|
|
39
|
+
dimension: Pick<Dimension, "width" | "height">;
|
|
40
|
+
padding: Padding;
|
|
41
|
+
margin: Margin;
|
|
42
|
+
readonly errors: Array<string>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Defines the font properties for table text.
|
|
46
|
+
*/
|
|
47
|
+
export type TableFont = {
|
|
48
|
+
size: number;
|
|
49
|
+
color: string;
|
|
50
|
+
family: string;
|
|
51
|
+
weight: number;
|
|
52
|
+
};
|
|
53
|
+
export declare const defaultTableFont: TableFont;
|
|
54
|
+
/**
|
|
55
|
+
* Defines the background properties for table elements.
|
|
56
|
+
*/
|
|
57
|
+
export type Background = {
|
|
58
|
+
color: string;
|
|
59
|
+
opacity: number;
|
|
60
|
+
};
|
|
61
|
+
export declare const defaultTableBackground: Background;
|
|
62
|
+
/**
|
|
63
|
+
* Defines the padding properties for table elements.
|
|
64
|
+
* Specifies the space between the content and the border.
|
|
65
|
+
*/
|
|
66
|
+
export type Padding = {
|
|
67
|
+
left: number;
|
|
68
|
+
right: number;
|
|
69
|
+
top: number;
|
|
70
|
+
bottom: number;
|
|
71
|
+
};
|
|
72
|
+
export declare const defaultTablePadding: Padding;
|
|
73
|
+
/**
|
|
74
|
+
* Defines the margin properties for table elements.
|
|
75
|
+
* Specifies the space outside the border.
|
|
76
|
+
*/
|
|
77
|
+
export type Margin = {
|
|
78
|
+
left: number;
|
|
79
|
+
right: number;
|
|
80
|
+
top: number;
|
|
81
|
+
bottom: number;
|
|
82
|
+
};
|
|
83
|
+
export declare const defaultTableMargin: Margin;
|
|
84
|
+
/**
|
|
85
|
+
* Defines the border properties for table elements.
|
|
86
|
+
* Controls the appearance of the border around table elements.
|
|
87
|
+
*/
|
|
88
|
+
export type BorderElement = {
|
|
89
|
+
color: string;
|
|
90
|
+
opacity: number;
|
|
91
|
+
width: number;
|
|
92
|
+
radius: number;
|
|
93
|
+
};
|
|
94
|
+
export declare const defaultBorderElement: BorderElement;
|
|
95
|
+
export declare enum BorderLocation {
|
|
96
|
+
TOP = "top",
|
|
97
|
+
BOTTOM = "bottom",
|
|
98
|
+
LEFT = "left",
|
|
99
|
+
RIGHT = "right"
|
|
100
|
+
}
|
|
101
|
+
export type Border = {
|
|
102
|
+
top: BorderElement;
|
|
103
|
+
bottom: BorderElement;
|
|
104
|
+
left: BorderElement;
|
|
105
|
+
right: BorderElement;
|
|
106
|
+
};
|
|
107
|
+
export declare const defaultBorder: Border;
|
|
108
|
+
/**
|
|
109
|
+
* Defines the dimension properties for table elements.
|
|
110
|
+
* Controls the size constraints including width and height with their minimum,
|
|
111
|
+
* maximum, and default values.
|
|
112
|
+
*/
|
|
113
|
+
export type Dimension = {
|
|
114
|
+
width: number;
|
|
115
|
+
defaultWidth: number;
|
|
116
|
+
minWidth: number;
|
|
117
|
+
maxWidth: number;
|
|
118
|
+
height: number;
|
|
119
|
+
defaultHeight: number;
|
|
120
|
+
minHeight: number;
|
|
121
|
+
maxHeight: number;
|
|
122
|
+
};
|
|
123
|
+
export declare const defaultDimension: Dimension;
|
|
124
|
+
/**
|
|
125
|
+
* The style for each column (for what is not determined by each row's style).
|
|
126
|
+
*/
|
|
127
|
+
export type ColumnStyle = {
|
|
128
|
+
alignText: TextAlignment;
|
|
129
|
+
verticalAlignText: VerticalTextAlignment;
|
|
130
|
+
dimension: Pick<Dimension, "defaultWidth" | "minWidth" | "maxWidth">;
|
|
131
|
+
padding: Pick<Padding, "left" | "right">;
|
|
132
|
+
border: Border;
|
|
133
|
+
};
|
|
134
|
+
export declare const defaultColumnStyle: ColumnStyle;
|
|
135
|
+
/**
|
|
136
|
+
* Note that the {@link ColumnStyle} determines the text alignment for
|
|
137
|
+
* each column. Therefore, the alignment of the text in a row is determined
|
|
138
|
+
* by the alignment for all the rows in the column.
|
|
139
|
+
*/
|
|
140
|
+
export type RowStyle = {
|
|
141
|
+
font: TableFont;
|
|
142
|
+
background: Background;
|
|
143
|
+
dimension: Pick<Dimension, "defaultHeight" | "minHeight" | "maxHeight">;
|
|
144
|
+
padding: Pick<Padding, "top" | "bottom">;
|
|
145
|
+
border: Border;
|
|
146
|
+
};
|
|
147
|
+
export declare const defaultRowStyle: RowStyle;
|
|
148
|
+
export type TextAlignment = "left" | "center" | "right";
|
|
149
|
+
export type VerticalTextAlignment = "top" | "middle" | "bottom";
|
|
150
|
+
export type CellStyle = {
|
|
151
|
+
font: TableFont;
|
|
152
|
+
alignText: TextAlignment;
|
|
153
|
+
verticalAlignText: VerticalTextAlignment;
|
|
154
|
+
background: Background;
|
|
155
|
+
dimension: Dimension;
|
|
156
|
+
padding: Padding;
|
|
157
|
+
border: Border;
|
|
158
|
+
};
|
|
159
|
+
export declare const defaultCellStyle: CellStyle;
|
|
160
|
+
/**
|
|
161
|
+
* Confusing as it may be, this is the style for the **row** that holds the
|
|
162
|
+
* headers for each column. The styling for this row may differ from the
|
|
163
|
+
* other rows in the table.
|
|
164
|
+
*/
|
|
165
|
+
export type ColumnHeaderStyle = {
|
|
166
|
+
font: TableFont;
|
|
167
|
+
alignText: TextAlignment;
|
|
168
|
+
verticalAlignText: VerticalTextAlignment;
|
|
169
|
+
dimension: Pick<Dimension, "height" | "maxHeight" | "minHeight">;
|
|
170
|
+
padding: Pick<Padding, "top" | "bottom">;
|
|
171
|
+
background: Background;
|
|
172
|
+
border: Border;
|
|
173
|
+
};
|
|
174
|
+
export declare const defaultColumnHeaderStyle: ColumnHeaderStyle;
|
|
175
|
+
/**
|
|
176
|
+
* Confusing as it may be, this is the style for the **column** that holds
|
|
177
|
+
* the headers for each row. The styling for this column may differ from the
|
|
178
|
+
* columns in the table.
|
|
179
|
+
*/
|
|
180
|
+
export type RowHeaderStyle = {
|
|
181
|
+
font: TableFont;
|
|
182
|
+
alignText: TextAlignment;
|
|
183
|
+
verticalAlignText: VerticalTextAlignment;
|
|
184
|
+
dimension: Pick<Dimension, "width" | "maxWidth" | "minWidth">;
|
|
185
|
+
padding: Pick<Padding, "left" | "right">;
|
|
186
|
+
background: Background;
|
|
187
|
+
border: Border;
|
|
188
|
+
};
|
|
189
|
+
export declare const defaultRowHeaderStyle: RowHeaderStyle;
|
|
190
|
+
/**
|
|
191
|
+
* Defines the style for the footer row of the table.
|
|
192
|
+
* Controls the appearance of the footer including font, text alignment,
|
|
193
|
+
* height, padding, and background.
|
|
194
|
+
*/
|
|
195
|
+
export type FooterStyle = {
|
|
196
|
+
font: TableFont;
|
|
197
|
+
alignText: TextAlignment;
|
|
198
|
+
verticalAlignText: VerticalTextAlignment;
|
|
199
|
+
dimension: Pick<Dimension, "height">;
|
|
200
|
+
padding: Pick<Padding, "top" | "bottom">;
|
|
201
|
+
background: Background;
|
|
202
|
+
border: Border;
|
|
203
|
+
};
|
|
204
|
+
export declare const defaultFooterStyle: FooterStyle;
|
|
205
|
+
export type Stylings = Styling<RowHeaderStyle> | Styling<ColumnHeaderStyle> | Styling<FooterStyle> | Styling<RowStyle> | Styling<ColumnStyle> | Styling<CellStyle>;
|
|
206
|
+
//# sourceMappingURL=stylings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylings.d.ts","sourceRoot":"","sources":["../stylings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACrB,KAAK,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,GAAE,MAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAElG;AAGD;;;GAGG;AACH,oBAAY,cAAc;IACtB,aAAa,wBAAwB;IACrC,UAAU,qBAAqB;IAC/B,MAAM,iBAAiB;IACvB,GAAG,cAAc;IACjB,MAAM,iBAAiB;IACvB,IAAI,eAAe;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAC9B,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OA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UAAU,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,cASnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,EAAE,aAAa,CAAA;IACxB,iBAAiB,EAAE,qBAAqB,CAAA;IACxC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACpC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAA;IACxC,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,WAShC,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,GAC1C,OAAO,CAAC,iBAAiB,CAAC,GAC1B,OAAO,CAAC,WAAW,CAAC,GACpB,OAAO,CAAC,QAAQ,CAAC,GACjB,OAAO,CAAC,WAAW,CAAC,GACpB,OAAO,CAAC,SAAS,CAAC,CAAA"}
|
package/dist/stylings.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.defaultFooterStyle = exports.defaultRowHeaderStyle = exports.defaultColumnHeaderStyle = exports.defaultCellStyle = exports.defaultRowStyle = exports.defaultColumnStyle = exports.defaultDimension = exports.defaultBorder = exports.BorderLocation = exports.defaultBorderElement = exports.defaultTableMargin = exports.defaultTablePadding = exports.defaultTableBackground = exports.defaultTableFont = exports.TableStyleType = void 0;
|
|
15
|
+
exports.stylingFor = stylingFor;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Styling object with the given style and priority.
|
|
18
|
+
* @param style The style to apply
|
|
19
|
+
* @param defaultStyle The default style that is used to fill in missing style attributes
|
|
20
|
+
* @param priority The priority level of the style (higher values take precedence)
|
|
21
|
+
* @returns A Styling object containing the style and priority
|
|
22
|
+
*/
|
|
23
|
+
function stylingFor(style, defaultStyle, priority) {
|
|
24
|
+
if (priority === void 0) { priority = 0; }
|
|
25
|
+
return { style: __assign(__assign({}, defaultStyle), style), priority: priority };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enum representing different types of table styling elements.
|
|
29
|
+
* Used as identifiers when tagging different parts of the table with styles.
|
|
30
|
+
*/
|
|
31
|
+
var TableStyleType;
|
|
32
|
+
(function (TableStyleType) {
|
|
33
|
+
TableStyleType["COLUMN_HEADER"] = "column_header_style";
|
|
34
|
+
TableStyleType["ROW_HEADER"] = "row_header_style";
|
|
35
|
+
TableStyleType["FOOTER"] = "footer_style";
|
|
36
|
+
TableStyleType["ROW"] = "row_style";
|
|
37
|
+
TableStyleType["COLUMN"] = "column_style";
|
|
38
|
+
TableStyleType["CELL"] = "cell_style";
|
|
39
|
+
})(TableStyleType || (exports.TableStyleType = TableStyleType = {}));
|
|
40
|
+
exports.defaultTableFont = {
|
|
41
|
+
size: 13,
|
|
42
|
+
color: '#d2933f',
|
|
43
|
+
family: 'sans-serif',
|
|
44
|
+
weight: 450,
|
|
45
|
+
};
|
|
46
|
+
exports.defaultTableBackground = { color: '#fff', opacity: 0 };
|
|
47
|
+
exports.defaultTablePadding = { left: 0, right: 0, top: 0, bottom: 0 };
|
|
48
|
+
exports.defaultTableMargin = { left: 0, right: 0, top: 0, bottom: 0 };
|
|
49
|
+
exports.defaultBorderElement = { color: 'black', radius: 0, width: 0, opacity: 0 };
|
|
50
|
+
var BorderLocation;
|
|
51
|
+
(function (BorderLocation) {
|
|
52
|
+
BorderLocation["TOP"] = "top";
|
|
53
|
+
BorderLocation["BOTTOM"] = "bottom";
|
|
54
|
+
BorderLocation["LEFT"] = "left";
|
|
55
|
+
BorderLocation["RIGHT"] = "right";
|
|
56
|
+
})(BorderLocation || (exports.BorderLocation = BorderLocation = {}));
|
|
57
|
+
exports.defaultBorder = {
|
|
58
|
+
top: exports.defaultBorderElement,
|
|
59
|
+
bottom: exports.defaultBorderElement,
|
|
60
|
+
left: exports.defaultBorderElement,
|
|
61
|
+
right: exports.defaultBorderElement,
|
|
62
|
+
};
|
|
63
|
+
exports.defaultDimension = {
|
|
64
|
+
width: 60,
|
|
65
|
+
defaultWidth: 70,
|
|
66
|
+
minWidth: 50,
|
|
67
|
+
maxWidth: 100,
|
|
68
|
+
height: 15,
|
|
69
|
+
defaultHeight: 20,
|
|
70
|
+
minHeight: 10,
|
|
71
|
+
maxHeight: 50
|
|
72
|
+
};
|
|
73
|
+
exports.defaultColumnStyle = {
|
|
74
|
+
alignText: "left",
|
|
75
|
+
verticalAlignText: "middle",
|
|
76
|
+
dimension: __assign(__assign({}, exports.defaultDimension), { defaultWidth: 60, minWidth: 40, maxWidth: 80 }),
|
|
77
|
+
padding: __assign(__assign({}, exports.defaultTablePadding), { left: 0, right: 0 }),
|
|
78
|
+
border: exports.defaultBorder
|
|
79
|
+
};
|
|
80
|
+
exports.defaultRowStyle = {
|
|
81
|
+
font: exports.defaultTableFont,
|
|
82
|
+
background: exports.defaultTableBackground,
|
|
83
|
+
dimension: { defaultHeight: 20, minHeight: 15, maxHeight: 50 },
|
|
84
|
+
padding: { top: 0, bottom: 0 },
|
|
85
|
+
border: exports.defaultBorder
|
|
86
|
+
};
|
|
87
|
+
exports.defaultCellStyle = {
|
|
88
|
+
font: exports.defaultTableFont,
|
|
89
|
+
alignText: "left",
|
|
90
|
+
verticalAlignText: "middle",
|
|
91
|
+
background: exports.defaultTableBackground,
|
|
92
|
+
dimension: exports.defaultDimension,
|
|
93
|
+
padding: exports.defaultTablePadding,
|
|
94
|
+
border: exports.defaultBorder
|
|
95
|
+
};
|
|
96
|
+
exports.defaultColumnHeaderStyle = {
|
|
97
|
+
font: __assign(__assign({}, exports.defaultTableFont), { weight: 600 }),
|
|
98
|
+
alignText: "left",
|
|
99
|
+
verticalAlignText: "middle",
|
|
100
|
+
dimension: __assign(__assign({}, exports.defaultDimension), { height: 20, maxHeight: 50, minHeight: 15 }),
|
|
101
|
+
padding: __assign(__assign({}, exports.defaultTablePadding), { top: 0, bottom: 0 }),
|
|
102
|
+
background: exports.defaultTableBackground,
|
|
103
|
+
border: exports.defaultBorder
|
|
104
|
+
};
|
|
105
|
+
exports.defaultRowHeaderStyle = {
|
|
106
|
+
font: exports.defaultTableFont,
|
|
107
|
+
alignText: "left",
|
|
108
|
+
verticalAlignText: "middle",
|
|
109
|
+
dimension: __assign(__assign({}, exports.defaultDimension), { width: 60, minWidth: 15, maxWidth: 100 }),
|
|
110
|
+
padding: __assign(__assign({}, exports.defaultTablePadding), { left: 0, right: 0 }),
|
|
111
|
+
background: exports.defaultTableBackground,
|
|
112
|
+
border: exports.defaultBorder
|
|
113
|
+
};
|
|
114
|
+
exports.defaultFooterStyle = {
|
|
115
|
+
font: exports.defaultTableFont,
|
|
116
|
+
alignText: "left",
|
|
117
|
+
verticalAlignText: "middle",
|
|
118
|
+
dimension: { height: 20 },
|
|
119
|
+
padding: __assign(__assign({}, exports.defaultTablePadding), { top: 0, bottom: 0 }),
|
|
120
|
+
background: exports.defaultTableBackground,
|
|
121
|
+
border: exports.defaultBorder
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=stylings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylings.js","sourceRoot":"","sources":["../stylings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,gCAEC;AATD;;;;;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AG,GAAC;IACxC,SAAS,EAAE,MAAM;IACjB,iBAAiB,EAAE,QAAQ;IAC3B,SAAS,wBAAM,wBAAgB,KAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,GAAC;IAC1E,OAAO,wBAAM,2BAAmB,KAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAC;IACpD,UAAU,EAAE,8BAAsB;IAClC,MAAM,EAAE,qBAAa;CAExB,CAAA;AAiBY,QAAA,qBAAqB,GAAmB;IACjD,IAAI,EAAE,wBAAgB;IACtB,SAAS,EAAE,MAAM;IACjB,iBAAiB,EAAE,QAAQ;IAC3B,SAAS,wBAAM,wBAAgB,KAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,GAAC;IACxE,OAAO,wBAAM,2BAAmB,KAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAC;IACpD,UAAU,EAAE,8BAAsB;IAClC,MAAM,EAAE,qBAAa;CAExB,CAAA;AAiBY,QAAA,kBAAkB,GAAgB;IAC3C,IAAI,EAAE,wBAAgB;IACtB,SAAS,EAAE,MAAM;IACjB,iBAAiB,EAAE,QAAQ;IAC3B,SAAS,EAAE,EAAC,MAAM,EAAE,EAAE,EAAC;IACvB,OAAO,wBAAM,2BAAmB,KAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAC;IACpD,UAAU,EAAE,8BAAsB;IAClC,MAAM,EAAE,qBAAa;CAExB,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { DataFrame } from "data-frame-ts";
|
|
2
|
+
import { type Result } from "result-fn";
|
|
3
|
+
import { type Formatting } from "./tableFormatter";
|
|
4
|
+
/**
|
|
5
|
+
* The types of tags the {@link TableData} supports
|
|
6
|
+
*/
|
|
7
|
+
export declare enum TableTagType {
|
|
8
|
+
COLUMN_HEADER = "column-header",
|
|
9
|
+
ROW_HEADER = "row-header",
|
|
10
|
+
FOOTER = "footer"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents the table data, row and column headers, and footers
|
|
14
|
+
*/
|
|
15
|
+
export declare class TableData<V> {
|
|
16
|
+
private readonly dataFrame;
|
|
17
|
+
/**
|
|
18
|
+
* The matrix of data, including row, column headers, and footers, if they exist
|
|
19
|
+
*/
|
|
20
|
+
private constructor();
|
|
21
|
+
static fromDataFrame<V>(dataFrame: DataFrame<V>): TableData<V>;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a column-header where each element in the column-header is the name of the column.
|
|
24
|
+
* Note that the specified column {@link header} determines the number of data columns in the table. This
|
|
25
|
+
* means that you must specify a header for each data column. No need to account for a possible column
|
|
26
|
+
* containing row-headers. The builder will take care of any adjustments needed for that.
|
|
27
|
+
* @param header An array describing the columns in the table.
|
|
28
|
+
* @param formatting The formatter, and its priority, for the row that represents the column-header. Note that the column
|
|
29
|
+
* header should not account for a possible column containing row-headers. The builder will take care
|
|
30
|
+
* of any adjustments needed for that.
|
|
31
|
+
* @param rowHeaderProvider
|
|
32
|
+
* @return A {@link TableData} which represents the next step in the guided builder
|
|
33
|
+
*/
|
|
34
|
+
withColumnHeader(header: Array<V>, formatting?: Formatting<V>, rowHeaderProvider?: () => V | undefined): Result<TableData<V>, string>;
|
|
35
|
+
withRowHeader(header: Array<V>, formatting?: Formatting<V>, columnHeaderProvider?: () => V | undefined, footerProvider?: () => V | undefined): Result<TableData<V>, string>;
|
|
36
|
+
withFooter(footer: Array<V>, formatting?: Formatting<V>, rowHeaderProvider?: () => V | undefined): Result<TableData<V>, string>;
|
|
37
|
+
static hasColumnHeader<V>(dataFrame: DataFrame<V>): boolean;
|
|
38
|
+
static hasRowHeader<V>(dataFrame: DataFrame<V>): boolean;
|
|
39
|
+
static hasFooter<V>(dataFrame: DataFrame<V>): boolean;
|
|
40
|
+
static dataRowCount<V>(dataFrame: DataFrame<V>): number;
|
|
41
|
+
static dataColumnCount<V>(dataFrame: DataFrame<V>): number;
|
|
42
|
+
static tableRowCount<V>(dataFrame: DataFrame<V>): number;
|
|
43
|
+
static tableColumnCount<V>(dataFrame: DataFrame<V>): number;
|
|
44
|
+
hasColumnHeader(): boolean;
|
|
45
|
+
hasRowHeader(): boolean;
|
|
46
|
+
hasFooter(): boolean;
|
|
47
|
+
dataRowCount(): number;
|
|
48
|
+
dataColumnCount(): number;
|
|
49
|
+
tableRowCount(): number;
|
|
50
|
+
tableColumnCount(): number;
|
|
51
|
+
/**
|
|
52
|
+
* @param [includeRowHeader=false] When `true` includes an extra empty column element when the table
|
|
53
|
+
* has a row-header. When `false` returns only the column-header elements
|
|
54
|
+
* @return A {@link Result} holding the column header if it exists; or a failure if no column-header exists
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const columnHeader = ['A', 'B', 'C', 'D', 'E']
|
|
58
|
+
* const rowHeader = ['one', 'two', 'three', 'four']
|
|
59
|
+
* const footer = ['a10', 'b10', 'c10', 'd10', 'e10']
|
|
60
|
+
* const data = DataFrame.from([
|
|
61
|
+
* ['a1', 'b1', 'c1', 'd1', 'e1'],
|
|
62
|
+
* ['a2', 'b2', 'c2', 'd2', 'e2'],
|
|
63
|
+
* ['a3', 'b3', 'c3', 'd3', 'e3'],
|
|
64
|
+
* ['a4', 'b4', 'c4', 'd4', 'e4'],
|
|
65
|
+
* ]).getOrThrow()
|
|
66
|
+
*
|
|
67
|
+
* // create a data-table with a column-header, row-header, footer, and data
|
|
68
|
+
* const tableData = createTableData<string>(data)
|
|
69
|
+
* .withColumnHeader(columnHeader)
|
|
70
|
+
* .flatMap(table => table.withRowHeader(rowHeader))
|
|
71
|
+
* .flatMap(table => table.withFooter(footer))
|
|
72
|
+
* .getOrThrow()
|
|
73
|
+
*
|
|
74
|
+
* // the column-header retrieved from the table-data should equal the column-header originally set
|
|
75
|
+
* expect(tableData.columnHeader().getOrThrow().equals(columnHeader)).toBeTruthy()
|
|
76
|
+
* ``` */
|
|
77
|
+
columnHeader(includeRowHeader?: boolean): Result<Array<V>, string>;
|
|
78
|
+
/**
|
|
79
|
+
* @param [includeColumnHeader=false] When `true` returns an extra empty row element if the table data
|
|
80
|
+
* has a column header. When `false` does not include the empty extra row element.
|
|
81
|
+
* @param [includeFooter=false] When `true` returns an extra empty row element if the table data
|
|
82
|
+
* has a footer. When `false` does not include the empty extra row element.
|
|
83
|
+
* @return A {@link Result} holding the row-header if it exists; or a failure if no row-header exists
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const columnHeader = ['A', 'B', 'C', 'D', 'E']
|
|
87
|
+
* const rowHeader = ['one', 'two', 'three', 'four']
|
|
88
|
+
* const footer = ['a10', 'b10', 'c10', 'd10', 'e10']
|
|
89
|
+
* const data = DataFrame.from([
|
|
90
|
+
* ['a1', 'b1', 'c1', 'd1', 'e1'],
|
|
91
|
+
* ['a2', 'b2', 'c2', 'd2', 'e2'],
|
|
92
|
+
* ['a3', 'b3', 'c3', 'd3', 'e3'],
|
|
93
|
+
* ['a4', 'b4', 'c4', 'd4', 'e4'],
|
|
94
|
+
* ]).getOrThrow()
|
|
95
|
+
*
|
|
96
|
+
* // create a data-table with a column-header, row-header, footer, and data
|
|
97
|
+
* const tableData = createTableData<string>(data)
|
|
98
|
+
* .withColumnHeader(columnHeader)
|
|
99
|
+
* .flatMap(table => table.withRowHeader(rowHeader))
|
|
100
|
+
* .flatMap(table => table.withFooter(footer))
|
|
101
|
+
* .getOrThrow()
|
|
102
|
+
*
|
|
103
|
+
* // the row-header retrieved from the table-data should equal the row-header originally set
|
|
104
|
+
* expect(tableData.rowHeader().getOrThrow().equals(rowHeader)).toBeTruthy()
|
|
105
|
+
* ``` */
|
|
106
|
+
rowHeader(includeColumnHeader?: boolean, includeFooter?: boolean): Result<Array<V>, string>;
|
|
107
|
+
/**
|
|
108
|
+
* @param [includeRowHeader=false] When `true` includes an extra empty column element when the table
|
|
109
|
+
* has a row-header. When `false` returns only the column-header elements
|
|
110
|
+
* @return A {@link Result} holding the footer, if exists; or a failure if no footer exists
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const columnHeader = ['A', 'B', 'C', 'D', 'E']
|
|
114
|
+
* const rowHeader = ['one', 'two', 'three', 'four']
|
|
115
|
+
* const footer = ['a10', 'b10', 'c10', 'd10', 'e10']
|
|
116
|
+
* const data = DataFrame.from([
|
|
117
|
+
* ['a1', 'b1', 'c1', 'd1', 'e1'],
|
|
118
|
+
* ['a2', 'b2', 'c2', 'd2', 'e2'],
|
|
119
|
+
* ['a3', 'b3', 'c3', 'd3', 'e3'],
|
|
120
|
+
* ['a4', 'b4', 'c4', 'd4', 'e4'],
|
|
121
|
+
* ]).getOrThrow()
|
|
122
|
+
*
|
|
123
|
+
* // create a data-table with a column-header, row-header, footer, and data
|
|
124
|
+
* const tableData = createTableData<string>(data)
|
|
125
|
+
* .withColumnHeader(columnHeader)
|
|
126
|
+
* .flatMap(table => table.withRowHeader(rowHeader))
|
|
127
|
+
* .flatMap(table => table.withFooter(footer))
|
|
128
|
+
* .getOrThrow()
|
|
129
|
+
*
|
|
130
|
+
* // the footer retrieved from the table-data should equal the footer originally set
|
|
131
|
+
* expect(tableData.footer().getOrThrow().equals(footer)).toBeTruthy()
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
footer(includeRowHeader?: boolean): Result<Array<V>, string>;
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves the "data" from the data-table. This excludes any column headers, row-headers, and footers.
|
|
137
|
+
* @return A {@link Result} holding a {@link DataFrame} with the "data" from the data-table. This excludes any
|
|
138
|
+
* column headers, row-headers, and footers.
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const columnHeader = ['A', 'B', 'C', 'D', 'E']
|
|
142
|
+
* const rowHeader = ['one', 'two', 'three', 'four']
|
|
143
|
+
* const footer = ['a10', 'b10', 'c10', 'd10', 'e10']
|
|
144
|
+
* const data = DataFrame.from([
|
|
145
|
+
* ['a1', 'b1', 'c1', 'd1', 'e1'],
|
|
146
|
+
* ['a2', 'b2', 'c2', 'd2', 'e2'],
|
|
147
|
+
* ['a3', 'b3', 'c3', 'd3', 'e3'],
|
|
148
|
+
* ['a4', 'b4', 'c4', 'd4', 'e4'],
|
|
149
|
+
* ]).getOrThrow()
|
|
150
|
+
*
|
|
151
|
+
* // create a data-table with a column-header, row-header, footer, and data
|
|
152
|
+
* const tableData = createTableData<string>(data)
|
|
153
|
+
* .withColumnHeader(columnHeader)
|
|
154
|
+
* .flatMap(table => table.withRowHeader(rowHeader))
|
|
155
|
+
* .flatMap(table => table.withFooter(footer))
|
|
156
|
+
* .getOrThrow()
|
|
157
|
+
*
|
|
158
|
+
* // the data retrieved from the table-data should equal the data originally set
|
|
159
|
+
* expect(tableData.data().getOrThrow().equals(data)).toBeTruthy()
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
data(): Result<DataFrame<V>, string>;
|
|
163
|
+
/**
|
|
164
|
+
* @return a copy of the {@link DataFrame} that has been prepared by this class.
|
|
165
|
+
*/
|
|
166
|
+
unwrapDataFrame(): DataFrame<V>;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=tableData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableData.d.ts","sourceRoot":"","sources":["../tableData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAgB,KAAK,MAAM,EAAgB,MAAM,WAAW,CAAC;AAEpE,OAAO,EAAoB,KAAK,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AAExF;;GAEG;AACH,oBAAY,YAAY;IACpB,aAAa,kBAAkB;IAC/B,UAAU,eAAe;IACzB,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,qBAAa,SAAS,CAAC,CAAC;IAIA,OAAO,CAAC,QAAQ,CAAC,SAAS;IAH9C;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