@cellaware/utils 8.6.11 → 8.6.13

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.
@@ -150,8 +150,7 @@ export declare function mapTeamsStyles(columnNames: string[], htmlRowStyles: str
150
150
  /**
151
151
  * **Important:** `html` and `teamsRows` output will be limited to **1,000 rows/64 rows** and **8 columns**, respectively.
152
152
  *
153
- * All outputs respect and will be filtered by optional `condition` argument.
153
+ * ~All outputs respect and will be filtered by optional `condition` argument.~
154
154
  */
155
- export declare function _transformDatagrid(rows: any[], datagridState: DatagridStateBase, locale: string, condition?: DatagridCondition): VisualDatagridState;
156
155
  export declare function transformDatagrid(rows: any[], datagridState: DatagridStateBase, locale: string, condition?: DatagridCondition): VisualDatagridState;
157
156
  export {};
@@ -806,7 +806,6 @@ function processHtmlStyles(value, columnFormat, rowStyles, columnStyles) {
806
806
  export function mapTeamsStyles(columnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles) {
807
807
  // IMPORTANT: both column/row style sorting have **already** been reversed (line 1170).
808
808
  // We can simply iterate over all the matched styles and accumulate them.
809
- console.log(htmlColumnStyles);
810
809
  const getColumnStyle = (style) => {
811
810
  switch (style) {
812
811
  case 'conditional-format-style-green-background':
@@ -868,6 +867,8 @@ export function mapTeamsStyles(columnNames, htmlRowStyles, htmlColumnStyles, tea
868
867
  styles: htmlColumnStyle.styles.map(style => getColumnStyle(style))
869
868
  });
870
869
  }
870
+ console.log('A.');
871
+ console.log(JSON.stringify(teamsColumnStyles));
871
872
  const applyRowStyleToColumns = (style) => {
872
873
  for (const columnName of columnNames) {
873
874
  const columnStyle = getColumnStyle(style);
@@ -1016,14 +1017,16 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
1016
1017
  for (const style of rowStyles) {
1017
1018
  rowStyle = style;
1018
1019
  }
1019
- console.log(rowStyles);
1020
- console.log(columnStyles);
1020
+ console.log('B.');
1021
+ console.log(JSON.stringify(columnStyles));
1021
1022
  return {
1022
1023
  type: "TableRow",
1023
1024
  style: rowStyle,
1024
1025
  cells: values.map((value, idx) => {
1025
1026
  const columnName = columnNames[idx];
1026
- const columnStyle = columnStyles.find(columnStyle => columnStyle.columnName === columnName);
1027
+ const columnStyle = columnStyles[idx];
1028
+ console.log('C.');
1029
+ console.log(columnStyle);
1027
1030
  let style = undefined;
1028
1031
  for (const styles of columnStyle?.styles ?? []) {
1029
1032
  if (!!styles.style) {
@@ -1041,178 +1044,8 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
1041
1044
  /**
1042
1045
  * **Important:** `html` and `teamsRows` output will be limited to **1,000 rows/64 rows** and **8 columns**, respectively.
1043
1046
  *
1044
- * All outputs respect and will be filtered by optional `condition` argument.
1047
+ * ~All outputs respect and will be filtered by optional `condition` argument.~
1045
1048
  */
1046
- export function _transformDatagrid(rows, datagridState, locale, condition) {
1047
- const HTML_ROWS = 1000;
1048
- const HTML_COLS = 8;
1049
- const TEAMS_ROWS = 64;
1050
- const columnState = datagridState.columnState ?? [];
1051
- const filterModel = datagridState.filterModel ?? {};
1052
- const isPivotMode = !!datagridState.isPivotMode;
1053
- const columnFormats = datagridState.columnFormats ?? [];
1054
- const { rowGroupCols, pivotCols, valueCols, sortModel } = parseColumnState(columnState);
1055
- rows = filterRows(rows, filterModel);
1056
- const chartRows = [];
1057
- let htmlBuf = '';
1058
- const htmlColumnNames = [];
1059
- const teamsRows = [];
1060
- // IMPORTANT: we evaluate the datagrid condition AFTER we are done with all transformations.
1061
- // NOTE: we do not need any pivot columns for pivot mode to be valid.
1062
- // https://chatwms.io/user-manual/chatwms/faq#q-do-i-have-to-have-a-group-column-to-just-display-a-count-in-the-datagrid
1063
- if (isPivotMode && valueCols.length > 0) {
1064
- const pivotOutput = pivotData(rows, rowGroupCols, pivotCols, valueCols);
1065
- rows = pivotOutput.rows;
1066
- rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
1067
- let mappedDisplayColumnNames = new Map();
1068
- // Should not need to do hidden/visible column analysis -- pivoting creates new results with only the necessary columns.
1069
- let rowIdx = 0;
1070
- rows.forEach(row => {
1071
- columnFormats.forEach(columnFormat => {
1072
- if (columnFormat.name in row) {
1073
- row[columnFormat.displayName] = evaluateValueFormat(columnFormat, row[columnFormat.name], locale);
1074
- if (columnFormat.displayName !== columnFormat.name) { // Remove name in favor of display name.
1075
- delete row[columnFormat.name];
1076
- }
1077
- if (rowIdx === 0) {
1078
- htmlColumnNames.push(columnFormat.displayName);
1079
- }
1080
- }
1081
- else {
1082
- const mappedColumnNamesSet = pivotOutput.mappedColumnNames.get(columnFormat.name);
1083
- if (!!mappedColumnNamesSet) {
1084
- const mappedColumnNamesArr = Array.from(mappedColumnNamesSet);
1085
- for (const mappedColumnName of mappedColumnNamesArr) {
1086
- if (mappedColumnName in row) {
1087
- const adjDisplayName = mappedColumnName.replace(columnFormat.name, columnFormat.displayName);
1088
- row[adjDisplayName] = evaluateValueFormat(columnFormat, row[mappedColumnName], locale);
1089
- if (adjDisplayName !== mappedColumnName) { // Remove name in favor of display name.
1090
- delete row[mappedColumnName];
1091
- }
1092
- let displayColumnNames = mappedDisplayColumnNames.get(columnFormat.displayName);
1093
- if (!!displayColumnNames) {
1094
- displayColumnNames.add(adjDisplayName);
1095
- }
1096
- else {
1097
- displayColumnNames = new Set([adjDisplayName]);
1098
- mappedDisplayColumnNames.set(columnFormat.displayName, displayColumnNames);
1099
- }
1100
- if (rowIdx === 0) {
1101
- htmlColumnNames.push(columnFormat.displayName);
1102
- }
1103
- }
1104
- }
1105
- }
1106
- }
1107
- });
1108
- rowIdx++;
1109
- });
1110
- if (!!condition) {
1111
- rows = evaluatePivotDatagridCondition(rows, condition, mappedDisplayColumnNames);
1112
- }
1113
- rowIdx = 0;
1114
- rows.forEach(row => {
1115
- let chartRow = {};
1116
- let htmlRowValues = [];
1117
- let htmlRowStyles = [];
1118
- let htmlColumnStyles = [];
1119
- let teamsRowStyles = [];
1120
- let teamsColumnStyles = [];
1121
- columnFormats.forEach(columnFormat => {
1122
- if (columnFormat.name in row) {
1123
- const formattedValue = evaluateValueFormat(columnFormat, row[columnFormat.displayName], locale);
1124
- chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
1125
- htmlRowValues.push(formattedValue);
1126
- [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
1127
- [teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
1128
- }
1129
- else {
1130
- const mappedColumnNamesSet = pivotOutput.mappedColumnNames.get(columnFormat.name);
1131
- if (!!mappedColumnNamesSet) {
1132
- const mappedColumnNamesArr = Array.from(mappedColumnNamesSet);
1133
- for (const mappedColumnName of mappedColumnNamesArr) {
1134
- if (mappedColumnName in row) {
1135
- const adjDisplayName = mappedColumnName.replace(columnFormat.name, columnFormat.displayName);
1136
- const formattedValue = row[adjDisplayName];
1137
- chartRow[adjDisplayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
1138
- htmlRowValues.push(formattedValue);
1139
- [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
1140
- [teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
1141
- if (rowIdx === 0) {
1142
- htmlColumnNames.push(columnFormat.displayName);
1143
- }
1144
- }
1145
- }
1146
- }
1147
- }
1148
- });
1149
- chartRows.push(chartRow);
1150
- if (rowIdx < HTML_ROWS) {
1151
- htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
1152
- if (rowIdx < TEAMS_ROWS) {
1153
- teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
1154
- }
1155
- }
1156
- rowIdx++;
1157
- });
1158
- }
1159
- else {
1160
- if (rowGroupCols.length > 0) {
1161
- rows = groupAndAggregate(rows, rowGroupCols, [], valueCols);
1162
- }
1163
- rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
1164
- const hiddenColumnNames = columnState.filter(column => !!column.hide && !column.rowGroup).map(column => column.colId) ?? [];
1165
- const visibleColumnFormats = columnFormats.filter(column => !hiddenColumnNames.includes(column.name)) ?? [];
1166
- rows.forEach(row => {
1167
- hiddenColumnNames.forEach(columnName => {
1168
- delete row[columnName];
1169
- });
1170
- visibleColumnFormats.forEach(columnFormat => {
1171
- row[columnFormat.displayName] = evaluateValueFormat(columnFormat, row[columnFormat.name], locale);
1172
- if (columnFormat.displayName !== columnFormat.name) { // Remove name in favor of display name.
1173
- delete row[columnFormat.name];
1174
- }
1175
- });
1176
- });
1177
- if (!!condition) {
1178
- rows = evaluateDatagridCondition(rows, condition);
1179
- }
1180
- let rowIdx = 0;
1181
- rows.forEach(row => {
1182
- let chartRow = {};
1183
- let htmlRowValues = [];
1184
- let htmlRowStyles = [];
1185
- let htmlColumnStyles = [];
1186
- let teamsRowStyles = [];
1187
- let teamsColumnStyles = [];
1188
- visibleColumnFormats.forEach(columnFormat => {
1189
- const formattedValue = row[columnFormat.displayName];
1190
- chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
1191
- htmlRowValues.push(formattedValue);
1192
- [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
1193
- [teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
1194
- });
1195
- chartRows.push(chartRow);
1196
- if (rowIdx < HTML_ROWS) {
1197
- htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
1198
- if (rowIdx < TEAMS_ROWS) {
1199
- teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
1200
- }
1201
- }
1202
- rowIdx++;
1203
- });
1204
- }
1205
- return {
1206
- ...datagridState,
1207
- adjRows: rows,
1208
- chartRows,
1209
- html: `${buildHtmlTableHeader(htmlColumnNames.slice(0, HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
1210
- teamsRows: [
1211
- createTeamsTableColumns(htmlColumnNames),
1212
- ...teamsRows
1213
- ]
1214
- };
1215
- }
1216
1049
  export function transformDatagrid(rows, datagridState, locale, condition) {
1217
1050
  const HTML_ROWS = 1000;
1218
1051
  const HTML_COLS = 8;
@@ -1360,6 +1193,9 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1360
1193
  adjRows: rows,
1361
1194
  chartRows,
1362
1195
  html: `${buildHtmlTableHeader(htmlColumnNames.slice(0, HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
1363
- teamsRows
1196
+ teamsRows: [
1197
+ createTeamsTableColumns(htmlColumnNames),
1198
+ ...teamsRows
1199
+ ]
1364
1200
  };
1365
1201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.6.11",
3
+ "version": "8.6.13",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",