@fluentui/react-charting 5.24.32 → 5.24.33

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.
@@ -7,6 +7,7 @@ var Utilities_1 = require("@fluentui/react/lib/Utilities");
7
7
  var image_export_utils_1 = require("../../utilities/image-export-utils");
8
8
  var d3 = require("d3-color");
9
9
  var colors_1 = require("../../utilities/colors");
10
+ var utilities_1 = require("../../utilities/utilities");
10
11
  function invertHexColor(hex, theme) {
11
12
  var color = d3.color(hex);
12
13
  if (!color) {
@@ -15,14 +16,19 @@ function invertHexColor(hex, theme) {
15
16
  var rgb = color.rgb();
16
17
  return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();
17
18
  }
18
- function getSafeBackgroundColor(theme, foreground, background) {
19
+ function getSafeBackgroundColor(theme, chartContainer, foreground, background) {
19
20
  var fallbackFg = theme.semanticColors.bodyText;
20
21
  var fallbackBg = theme.semanticColors.bodyBackground;
21
- var fg = d3.color(foreground || fallbackFg);
22
- var bg = d3.color(background || fallbackBg);
23
- if (!fg || !bg) {
22
+ if (!chartContainer) {
24
23
  return fallbackBg;
25
24
  }
25
+ var resolvedFg = (0, utilities_1.resolveCSSVariables)(chartContainer, foreground || fallbackFg);
26
+ var resolvedBg = (0, utilities_1.resolveCSSVariables)(chartContainer, background || fallbackBg);
27
+ var fg = d3.color(resolvedFg);
28
+ var bg = d3.color(resolvedBg);
29
+ if (!fg || !bg) {
30
+ return resolvedBg;
31
+ }
26
32
  var contrast = (0, colors_1.getColorContrast)(fg.formatHex(), bg.formatHex());
27
33
  if (contrast >= 3) {
28
34
  return bg.formatHex();
@@ -107,7 +113,7 @@ var ChartTableBase = /** @class */ (function (_super) {
107
113
  style.backgroundColor = sharedBackgroundColor;
108
114
  }
109
115
  else if (fg || bg) {
110
- style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
116
+ style.backgroundColor = getSafeBackgroundColor(theme, _this._rootElem, fg, bg);
111
117
  }
112
118
  return (React.createElement("th", { key: idx, className: classNames.headerCell, style: style }, header.value));
113
119
  }))),
@@ -116,7 +122,7 @@ var ChartTableBase = /** @class */ (function (_super) {
116
122
  var fg = style.color;
117
123
  var bg = style.backgroundColor;
118
124
  if (fg || bg) {
119
- style.backgroundColor = getSafeBackgroundColor(theme, fg, bg);
125
+ style.backgroundColor = getSafeBackgroundColor(theme, _this._rootElem, fg, bg);
120
126
  }
121
127
  return (React.createElement("td", { key: colIdx, className: classNames.bodyCell, style: style }, cell.value));
122
128
  }))); })))))))));
@@ -1 +1 @@
1
- {"version":3,"file":"ChartTable.base.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAG/B,2DAAmG;AAEnG,yEAA6D;AAC7D,6BAA+B;AAC/B,iDAA0D;AAG1D,SAAS,cAAc,CAAC,GAAW,EAAE,KAAa;IAChD,IAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,cAAc,CAAC,QAAS,CAAC;IACxC,CAAC;IACD,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa,EAAE,UAAmB,EAAE,UAAmB;IACrF,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;IACjD,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAEvD,IAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,UAAU,CAAC,CAAC;IAC9C,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,CAAC,CACI,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA9HD,CAAoC,KAAK,CAAC,SAAS,GA8HlD;AA9HY,wCAAc","sourcesContent":["import * as React from 'react';\nimport { IChartTableProps } from './ChartTable.types';\nimport { IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { classNamesFunction, getRTL, initializeComponentRef } from '@fluentui/react/lib/Utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\nimport * as d3 from 'd3-color';\nimport { getColorContrast } from '../../utilities/colors';\nimport { ITheme } from '@fluentui/react';\n\nfunction invertHexColor(hex: string, theme: ITheme): string {\n const color = d3.color(hex);\n if (!color) {\n return theme.semanticColors.bodyText!;\n }\n const rgb = color.rgb();\n return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();\n}\n\nfunction getSafeBackgroundColor(theme: ITheme, foreground?: string, background?: string): string {\n const fallbackFg = theme.semanticColors.bodyText;\n const fallbackBg = theme.semanticColors.bodyBackground;\n\n const fg = d3.color(foreground || fallbackFg);\n const bg = d3.color(background || fallbackBg);\n if (!fg || !bg) {\n return fallbackBg;\n }\n const contrast = getColorContrast(fg.formatHex(), bg.formatHex());\n if (contrast >= 3) {\n return bg.formatHex();\n }\n\n const invertedBg = invertHexColor(bg.formatHex(), theme);\n const invertedContrast = getColorContrast(fg.formatHex(), invertedBg);\n return invertedContrast >= 3 ? invertedBg : fallbackBg;\n}\n\nconst getClassNames = classNamesFunction<IChartTableStyleProps, IChartTableStyles>();\n\nexport class ChartTableBase extends React.Component<IChartTableProps> {\n private _isRTL: boolean;\n private _rootElem: HTMLDivElement | null;\n\n constructor(props: IChartTableProps) {\n super(props);\n initializeComponentRef(this);\n this._isRTL = getRTL(props.theme);\n }\n public toImage = (opts?: IImageExportOptions): Promise<string> => {\n return toImage(this._rootElem, undefined, this._isRTL, opts);\n };\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public render(): JSX.Element {\n const { headers, rows, width, height, styles, theme } = this.props;\n\n const classNames = getClassNames(styles!, {\n theme: theme!,\n });\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n const bgColorSet = new Set<string>();\n headers.forEach(header => {\n const bg = header?.style?.backgroundColor;\n const normalized = d3.color(bg || '')?.formatHex();\n if (normalized) {\n bgColorSet.add(normalized);\n }\n });\n let sharedBackgroundColor: string | undefined;\n let useSharedBackground = false;\n\n /*\n If we have only one or two unique background colors, we can consider using a shared background color\n for the table headers. This is to ensure better contrast with the foreground text.\n For size 1, we will consider that as default color if it satisfies the contrast ratio.\n There could also be a scenario where backgroundcolor array is of size 2, for eg: [\"dimsgray\", \"gray\"],\n which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background\n color won't run here. So will consider for size 2 as well.\n For size greater than this, we will consider that user wants different colors and will let color contrast fail\n if any.\n */\n if (bgColorSet.size === 1 || bgColorSet.size === 2) {\n const candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];\n for (const header of headers) {\n const fg = header?.style?.color;\n if (fg && getColorContrast(fg, candidateBg) >= 3) {\n sharedBackgroundColor = candidateBg;\n useSharedBackground = true;\n break;\n }\n }\n }\n\n return (\n <div\n ref={el => (this._rootElem = el)}\n className={classNames.root}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'} className={classNames.chart}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classNames.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => {\n const style = { ...header?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n\n if (useSharedBackground) {\n style.backgroundColor = sharedBackgroundColor;\n } else if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, fg, bg);\n }\n return (\n <th key={idx} className={classNames.headerCell} style={style}>\n {header.value}\n </th>\n );\n })}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => {\n const style = { ...cell?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, fg, bg);\n }\n return (\n <td key={colIdx} className={classNames.bodyCell} style={style}>\n {cell.value}\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ChartTable.base.js","sourceRoot":"../src/","sources":["components/ChartTable/ChartTable.base.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAG/B,2DAAmG;AAEnG,yEAA6D;AAC7D,6BAA+B;AAC/B,iDAA0D;AAE1D,uDAAgE;AAEhE,SAAS,cAAc,CAAC,GAAW,EAAE,KAAa;IAChD,IAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,cAAc,CAAC,QAAS,CAAC;IACxC,CAAC;IACD,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;IACxB,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACnE,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAa,EACb,cAA2B,EAC3B,UAAmB,EACnB,UAAmB;IAEnB,IAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;IACjD,IAAM,UA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,IAAM,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC;gCACjC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;oCACb,KAAK,CAAC,eAAe,GAAG,sBAAsB,CAAC,KAAM,EAAE,KAAI,CAAC,SAAU,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;gCAClF,CAAC;gCACD,OAAO,CACL,4BAAI,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,IAC1D,IAAI,CAAC,KAAK,CACR,CACN,CAAC;4BACJ,CAAC,CAAC,CACC,CACN,EAhB0B,CAgB1B,CAAC,CACI,CACT,CACK,CACJ,CACQ,CACZ,CACF,CACP,CAAC;IACJ,CAAC;IACH,qBAAC;AAAD,CAAC,AA9HD,CAAoC,KAAK,CAAC,SAAS,GA8HlD;AA9HY,wCAAc","sourcesContent":["import * as React from 'react';\nimport { IChartTableProps } from './ChartTable.types';\nimport { IChartTableStyleProps, IChartTableStyles } from '../../index';\nimport { classNamesFunction, getRTL, initializeComponentRef } from '@fluentui/react/lib/Utilities';\nimport { IImageExportOptions } from '../../types/index';\nimport { toImage } from '../../utilities/image-export-utils';\nimport * as d3 from 'd3-color';\nimport { getColorContrast } from '../../utilities/colors';\nimport { ITheme } from '@fluentui/react';\nimport { resolveCSSVariables } from '../../utilities/utilities';\n\nfunction invertHexColor(hex: string, theme: ITheme): string {\n const color = d3.color(hex);\n if (!color) {\n return theme.semanticColors.bodyText!;\n }\n const rgb = color.rgb();\n return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();\n}\n\nfunction getSafeBackgroundColor(\n theme: ITheme,\n chartContainer: HTMLElement,\n foreground?: string,\n background?: string,\n): string {\n const fallbackFg = theme.semanticColors.bodyText;\n const fallbackBg = theme.semanticColors.bodyBackground;\n if (!chartContainer) {\n return fallbackBg;\n }\n\n const resolvedFg = resolveCSSVariables(chartContainer, foreground || fallbackFg);\n const resolvedBg = resolveCSSVariables(chartContainer, background || fallbackBg);\n\n const fg = d3.color(resolvedFg);\n const bg = d3.color(resolvedBg);\n\n if (!fg || !bg) {\n return resolvedBg;\n }\n const contrast = getColorContrast(fg.formatHex(), bg.formatHex());\n if (contrast >= 3) {\n return bg.formatHex();\n }\n\n const invertedBg = invertHexColor(bg.formatHex(), theme);\n const invertedContrast = getColorContrast(fg.formatHex(), invertedBg);\n return invertedContrast >= 3 ? invertedBg : fallbackBg;\n}\n\nconst getClassNames = classNamesFunction<IChartTableStyleProps, IChartTableStyles>();\n\nexport class ChartTableBase extends React.Component<IChartTableProps> {\n private _isRTL: boolean;\n private _rootElem: HTMLDivElement | null;\n\n constructor(props: IChartTableProps) {\n super(props);\n initializeComponentRef(this);\n this._isRTL = getRTL(props.theme);\n }\n public toImage = (opts?: IImageExportOptions): Promise<string> => {\n return toImage(this._rootElem, undefined, this._isRTL, opts);\n };\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public render(): JSX.Element {\n const { headers, rows, width, height, styles, theme } = this.props;\n\n const classNames = getClassNames(styles!, {\n theme: theme!,\n });\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n const bgColorSet = new Set<string>();\n headers.forEach(header => {\n const bg = header?.style?.backgroundColor;\n const normalized = d3.color(bg || '')?.formatHex();\n if (normalized) {\n bgColorSet.add(normalized);\n }\n });\n let sharedBackgroundColor: string | undefined;\n let useSharedBackground = false;\n\n /*\n If we have only one or two unique background colors, we can consider using a shared background color\n for the table headers. This is to ensure better contrast with the foreground text.\n For size 1, we will consider that as default color if it satisfies the contrast ratio.\n There could also be a scenario where backgroundcolor array is of size 2, for eg: [\"dimsgray\", \"gray\"],\n which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background\n color won't run here. So will consider for size 2 as well.\n For size greater than this, we will consider that user wants different colors and will let color contrast fail\n if any.\n */\n if (bgColorSet.size === 1 || bgColorSet.size === 2) {\n const candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];\n for (const header of headers) {\n const fg = header?.style?.color;\n if (fg && getColorContrast(fg, candidateBg) >= 3) {\n sharedBackgroundColor = candidateBg;\n useSharedBackground = true;\n break;\n }\n }\n }\n\n return (\n <div\n ref={el => (this._rootElem = el)}\n className={classNames.root}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'} className={classNames.chart}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classNames.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => {\n const style = { ...header?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n\n if (useSharedBackground) {\n style.backgroundColor = sharedBackgroundColor;\n } else if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, this._rootElem!, fg, bg);\n }\n return (\n <th key={idx} className={classNames.headerCell} style={style}>\n {header.value}\n </th>\n );\n })}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => {\n const style = { ...cell?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(theme!, this._rootElem!, fg, bg);\n }\n return (\n <td key={colIdx} className={classNames.bodyCell} style={style}>\n {cell.value}\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n }\n}\n"]}
@@ -744,6 +744,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
744
744
  axisLabel: series.__axisLabel
745
745
  ? series.__axisLabel
746
746
  : {},
747
+ fill: series.fill,
747
748
  }
748
749
  : {})),
749
750
  useSecondaryYScale: usesSecondaryYScale(series, input.layout),
@@ -1142,8 +1143,20 @@ function resolveCellStyle(raw, rowIndex, colIndex) {
1142
1143
  }
1143
1144
  return raw;
1144
1145
  }
1146
+ function mergeCells(tableCells, templateCells) {
1147
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1148
+ return {
1149
+ values: (_b = (_a = tableCells === null || tableCells === void 0 ? void 0 : tableCells.values) !== null && _a !== void 0 ? _a : templateCells === null || templateCells === void 0 ? void 0 : templateCells.values) !== null && _b !== void 0 ? _b : [],
1150
+ align: (_c = tableCells === null || tableCells === void 0 ? void 0 : tableCells.align) !== null && _c !== void 0 ? _c : templateCells === null || templateCells === void 0 ? void 0 : templateCells.align,
1151
+ fill: tslib_1.__assign(tslib_1.__assign({}, ((_d = templateCells === null || templateCells === void 0 ? void 0 : templateCells.fill) !== null && _d !== void 0 ? _d : {})), ((_e = tableCells === null || tableCells === void 0 ? void 0 : tableCells.fill) !== null && _e !== void 0 ? _e : {})),
1152
+ font: tslib_1.__assign(tslib_1.__assign({}, ((_f = templateCells === null || templateCells === void 0 ? void 0 : templateCells.font) !== null && _f !== void 0 ? _f : {})), ((_g = tableCells === null || tableCells === void 0 ? void 0 : tableCells.font) !== null && _g !== void 0 ? _g : {})),
1153
+ format: (_h = tableCells === null || tableCells === void 0 ? void 0 : tableCells.format) !== null && _h !== void 0 ? _h : templateCells === null || templateCells === void 0 ? void 0 : templateCells.format,
1154
+ prefix: (_j = tableCells === null || tableCells === void 0 ? void 0 : tableCells.prefix) !== null && _j !== void 0 ? _j : templateCells === null || templateCells === void 0 ? void 0 : templateCells.prefix,
1155
+ suffix: (_k = tableCells === null || tableCells === void 0 ? void 0 : tableCells.suffix) !== null && _k !== void 0 ? _k : templateCells === null || templateCells === void 0 ? void 0 : templateCells.suffix,
1156
+ };
1157
+ }
1145
1158
  var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
1146
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1159
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
1147
1160
  var tableData = input.data[0];
1148
1161
  var normalizeHeaders = function (values, header) {
1149
1162
  var cleanedValues = Array.isArray(values[0])
@@ -1167,9 +1180,7 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
1167
1180
  });
1168
1181
  };
1169
1182
  var columns = (_b = (_a = tableData.cells) === null || _a === void 0 ? void 0 : _a.values) !== null && _b !== void 0 ? _b : [];
1170
- var cells = tableData.cells && Object.keys(tableData.cells).length > 0
1171
- ? tableData.cells
1172
- : (_g = (_f = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.table) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cells;
1183
+ var cells = mergeCells(tableData.cells, (_g = (_f = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.table) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cells);
1173
1184
  var rows = columns[0].map(function (_, rowIndex) {
1174
1185
  return columns.map(function (col, colIndex) {
1175
1186
  var _a, _b, _c;
@@ -1192,13 +1203,19 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
1192
1203
  var styles = {
1193
1204
  root: tslib_1.__assign({}, (((_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.font) === null || _j === void 0 ? void 0 : _j.size) ? { fontSize: input.layout.font.size } : {})),
1194
1205
  };
1206
+ var templateHeader = (_p = (_o = (_m = (_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.template) === null || _l === void 0 ? void 0 : _l.data) === null || _m === void 0 ? void 0 : _m.table) === null || _o === void 0 ? void 0 : _o[0]) === null || _p === void 0 ? void 0 : _p.header;
1207
+ var tableHeader = tableData.header;
1208
+ var header = {
1209
+ align: (_q = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.align) !== null && _q !== void 0 ? _q : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.align,
1210
+ fill: tslib_1.__assign(tslib_1.__assign({}, ((_r = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.fill) !== null && _r !== void 0 ? _r : {})), ((_s = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.fill) !== null && _s !== void 0 ? _s : {})),
1211
+ font: tslib_1.__assign(tslib_1.__assign({}, ((_t = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.font) !== null && _t !== void 0 ? _t : {})), ((_u = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.font) !== null && _u !== void 0 ? _u : {})),
1212
+ values: (_w = (_v = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.values) !== null && _v !== void 0 ? _v : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.values) !== null && _w !== void 0 ? _w : [],
1213
+ };
1195
1214
  return {
1196
- headers: normalizeHeaders((_l = (_k = tableData.header) === null || _k === void 0 ? void 0 : _k.values) !== null && _l !== void 0 ? _l : [], tableData.header && Object.keys(tableData.header).length > 0
1197
- ? tableData.header
1198
- : (_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.data) === null || _p === void 0 ? void 0 : _p.table[0].header),
1215
+ headers: normalizeHeaders((_y = (_x = tableData.header) === null || _x === void 0 ? void 0 : _x.values) !== null && _y !== void 0 ? _y : [], header),
1199
1216
  rows: rows,
1200
- width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
1201
- height: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.height,
1217
+ width: (_z = input.layout) === null || _z === void 0 ? void 0 : _z.width,
1218
+ height: (_0 = input.layout) === null || _0 === void 0 ? void 0 : _0.height,
1202
1219
  styles: styles,
1203
1220
  };
1204
1221
  };