@fluentui/react-charting 5.24.27 → 5.24.28

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.
@@ -1088,6 +1088,17 @@ var formatValue = function (value, colIndex, cells) {
1088
1088
  }
1089
1089
  return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
1090
1090
  };
1091
+ function resolveCellStyle(raw, rowIndex, colIndex) {
1092
+ var _a, _b;
1093
+ if (Array.isArray(raw)) {
1094
+ var rowEntry = (_a = raw[colIndex]) !== null && _a !== void 0 ? _a : raw[0];
1095
+ if (Array.isArray(rowEntry)) {
1096
+ return (_b = rowEntry[rowIndex]) !== null && _b !== void 0 ? _b : rowEntry[0];
1097
+ }
1098
+ return rowEntry;
1099
+ }
1100
+ return raw;
1101
+ }
1091
1102
  var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
1092
1103
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1093
1104
  var tableData = input.data[0];
@@ -1101,41 +1112,13 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
1101
1112
  })
1102
1113
  : values.map(function (cell) { return cleanText(cell); });
1103
1114
  return cleanedValues.map(function (value, colIndex) {
1104
- var _a, _b, _c, _d, _e, _f, _g, _h;
1105
- var fontColorRaw = (_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color;
1106
- var fontColor;
1107
- if (Array.isArray(fontColorRaw)) {
1108
- var colorEntry = (_b = fontColorRaw[colIndex]) !== null && _b !== void 0 ? _b : fontColorRaw[0];
1109
- if (Array.isArray(colorEntry)) {
1110
- fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
1111
- }
1112
- else if (typeof colorEntry === 'string') {
1113
- fontColor = colorEntry;
1114
- }
1115
- }
1116
- else if (typeof fontColorRaw === 'string') {
1117
- fontColor = fontColorRaw;
1118
- }
1119
- var fontSizeRaw = (_c = header === null || header === void 0 ? void 0 : header.font) === null || _c === void 0 ? void 0 : _c.size;
1120
- var fontSize;
1121
- if (Array.isArray(fontSizeRaw)) {
1122
- var fontSizeEntry = (_d = fontSizeRaw[colIndex]) !== null && _d !== void 0 ? _d : fontSizeRaw[0];
1123
- fontSize = Array.isArray(fontSizeRaw[0])
1124
- ? (_e = fontSizeRaw[0][colIndex]) !== null && _e !== void 0 ? _e : fontSizeRaw[0][0]
1125
- : typeof fontSizeEntry === 'number'
1126
- ? fontSizeEntry
1127
- : undefined;
1128
- }
1129
- else if (typeof fontSizeRaw === 'number') {
1130
- fontSize = fontSizeRaw;
1131
- }
1132
- var updatedColIndex = colIndex >= 1 ? 1 : 0;
1133
- var fillColorRaw = (_f = header === null || header === void 0 ? void 0 : header.fill) === null || _f === void 0 ? void 0 : _f.color;
1134
- var backgroundColor = Array.isArray(fillColorRaw)
1135
- ? (_g = fillColorRaw[updatedColIndex]) !== null && _g !== void 0 ? _g : fillColorRaw[0]
1136
- : fillColorRaw;
1137
- var textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
1138
- var textAlign = Array.isArray(textAlignRaw) ? (_h = textAlignRaw[colIndex]) !== null && _h !== void 0 ? _h : textAlignRaw[0] : textAlignRaw;
1115
+ var _a, _b, _c;
1116
+ //headers are at first row only
1117
+ var rowIndex = 0;
1118
+ var fontColor = resolveCellStyle((_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color, rowIndex, colIndex);
1119
+ var fontSize = resolveCellStyle((_b = header === null || header === void 0 ? void 0 : header.font) === null || _b === void 0 ? void 0 : _b.size, rowIndex, colIndex);
1120
+ var backgroundColor = resolveCellStyle((_c = header === null || header === void 0 ? void 0 : header.fill) === null || _c === void 0 ? void 0 : _c.color, rowIndex, colIndex);
1121
+ var textAlign = resolveCellStyle(header === null || header === void 0 ? void 0 : header.align, rowIndex, colIndex);
1139
1122
  var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (typeof fontColor === 'string' ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (typeof backgroundColor === 'string' ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
1140
1123
  return { value: value, style: style };
1141
1124
  });
@@ -1146,45 +1129,16 @@ var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMa
1146
1129
  : (_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;
1147
1130
  var rows = columns[0].map(function (_, rowIndex) {
1148
1131
  return columns.map(function (col, colIndex) {
1149
- var _a, _b, _c, _d, _e, _f, _g;
1132
+ var _a, _b, _c;
1150
1133
  var cellValue = col[rowIndex];
1151
1134
  var cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
1152
1135
  var formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number'
1153
1136
  ? formatValue(cleanValue, colIndex, cells)
1154
1137
  : cleanValue;
1155
- var rawFontColor = (_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color;
1156
- var fontColor;
1157
- if (Array.isArray(rawFontColor)) {
1158
- var entry = (_b = rawFontColor[colIndex]) !== null && _b !== void 0 ? _b : rawFontColor[0];
1159
- var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1160
- fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1161
- }
1162
- else if (typeof rawFontColor === 'string') {
1163
- fontColor = rawFontColor;
1164
- }
1165
- var rawFontSize = (_c = cells === null || cells === void 0 ? void 0 : cells.font) === null || _c === void 0 ? void 0 : _c.size;
1166
- var fontSize;
1167
- if (Array.isArray(rawFontSize)) {
1168
- var entry = (_d = rawFontSize[colIndex]) !== null && _d !== void 0 ? _d : rawFontSize[0];
1169
- var fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1170
- fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1171
- }
1172
- else if (typeof rawFontSize === 'number') {
1173
- fontSize = rawFontSize;
1174
- }
1175
- var updatedColIndex = colIndex >= 1 ? 1 : 0;
1176
- var rawBackgroundColor = (_e = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _e === void 0 ? void 0 : _e.color;
1177
- var backgroundColor;
1178
- if (Array.isArray(rawBackgroundColor)) {
1179
- var entry = (_f = rawBackgroundColor[updatedColIndex]) !== null && _f !== void 0 ? _f : rawBackgroundColor[0];
1180
- var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1181
- backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1182
- }
1183
- else if (typeof rawBackgroundColor === 'string') {
1184
- backgroundColor = rawBackgroundColor;
1185
- }
1186
- var rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? (_g = cells.align[colIndex]) !== null && _g !== void 0 ? _g : cells.align[0] : cells === null || cells === void 0 ? void 0 : cells.align;
1187
- var textAlign = rawTextAlign;
1138
+ var fontColor = resolveCellStyle((_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color, rowIndex, colIndex);
1139
+ var fontSize = resolveCellStyle((_b = cells === null || cells === void 0 ? void 0 : cells.font) === null || _b === void 0 ? void 0 : _b.size, rowIndex, colIndex);
1140
+ var backgroundColor = resolveCellStyle((_c = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _c === void 0 ? void 0 : _c.color, rowIndex, colIndex);
1141
+ var textAlign = resolveCellStyle(cells === null || cells === void 0 ? void 0 : cells.align, rowIndex, colIndex);
1188
1142
  var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (fontColor ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (backgroundColor ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
1189
1143
  return {
1190
1144
  value: formattedValue,