@cellaware/utils 8.6.12 → 8.6.14
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/chatwms/datagrid.d.ts +1 -2
- package/dist/chatwms/datagrid.js +14 -178
- package/package.json +1 -1
|
@@ -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 {};
|
package/dist/chatwms/datagrid.js
CHANGED
|
@@ -780,9 +780,9 @@ function sortRows(data, sortModel) {
|
|
|
780
780
|
return 0;
|
|
781
781
|
});
|
|
782
782
|
}
|
|
783
|
-
function processHtmlStyles(value, columnFormat, rowStyles, columnStyles) {
|
|
783
|
+
function processHtmlStyles(value, columnName, columnFormat, rowStyles, columnStyles) {
|
|
784
784
|
let columnStyle = {
|
|
785
|
-
columnName
|
|
785
|
+
columnName,
|
|
786
786
|
styles: []
|
|
787
787
|
};
|
|
788
788
|
// Reminder: Value Formatting is performed **before** Conditional Formatting.
|
|
@@ -861,6 +861,7 @@ export function mapTeamsStyles(columnNames, htmlRowStyles, htmlColumnStyles, tea
|
|
|
861
861
|
return {};
|
|
862
862
|
}
|
|
863
863
|
};
|
|
864
|
+
console.log('COUNT: ' + htmlColumnStyles.length);
|
|
864
865
|
for (const htmlColumnStyle of htmlColumnStyles) {
|
|
865
866
|
teamsColumnStyles.push({
|
|
866
867
|
columnName: htmlColumnStyle.columnName,
|
|
@@ -1024,7 +1025,9 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
|
|
|
1024
1025
|
style: rowStyle,
|
|
1025
1026
|
cells: values.map((value, idx) => {
|
|
1026
1027
|
const columnName = columnNames[idx];
|
|
1027
|
-
const columnStyle = columnStyles.find(
|
|
1028
|
+
const columnStyle = columnStyles.find(cs => cs.columnName === columnName);
|
|
1029
|
+
console.log('C.');
|
|
1030
|
+
console.log(columnStyle);
|
|
1028
1031
|
let style = undefined;
|
|
1029
1032
|
for (const styles of columnStyle?.styles ?? []) {
|
|
1030
1033
|
if (!!styles.style) {
|
|
@@ -1042,178 +1045,8 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
|
|
|
1042
1045
|
/**
|
|
1043
1046
|
* **Important:** `html` and `teamsRows` output will be limited to **1,000 rows/64 rows** and **8 columns**, respectively.
|
|
1044
1047
|
*
|
|
1045
|
-
* All outputs respect and will be filtered by optional `condition` argument
|
|
1048
|
+
* ~All outputs respect and will be filtered by optional `condition` argument.~
|
|
1046
1049
|
*/
|
|
1047
|
-
export function _transformDatagrid(rows, datagridState, locale, condition) {
|
|
1048
|
-
const HTML_ROWS = 1000;
|
|
1049
|
-
const HTML_COLS = 8;
|
|
1050
|
-
const TEAMS_ROWS = 64;
|
|
1051
|
-
const columnState = datagridState.columnState ?? [];
|
|
1052
|
-
const filterModel = datagridState.filterModel ?? {};
|
|
1053
|
-
const isPivotMode = !!datagridState.isPivotMode;
|
|
1054
|
-
const columnFormats = datagridState.columnFormats ?? [];
|
|
1055
|
-
const { rowGroupCols, pivotCols, valueCols, sortModel } = parseColumnState(columnState);
|
|
1056
|
-
rows = filterRows(rows, filterModel);
|
|
1057
|
-
const chartRows = [];
|
|
1058
|
-
let htmlBuf = '';
|
|
1059
|
-
const htmlColumnNames = [];
|
|
1060
|
-
const teamsRows = [];
|
|
1061
|
-
// IMPORTANT: we evaluate the datagrid condition AFTER we are done with all transformations.
|
|
1062
|
-
// NOTE: we do not need any pivot columns for pivot mode to be valid.
|
|
1063
|
-
// https://chatwms.io/user-manual/chatwms/faq#q-do-i-have-to-have-a-group-column-to-just-display-a-count-in-the-datagrid
|
|
1064
|
-
if (isPivotMode && valueCols.length > 0) {
|
|
1065
|
-
const pivotOutput = pivotData(rows, rowGroupCols, pivotCols, valueCols);
|
|
1066
|
-
rows = pivotOutput.rows;
|
|
1067
|
-
rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
|
|
1068
|
-
let mappedDisplayColumnNames = new Map();
|
|
1069
|
-
// Should not need to do hidden/visible column analysis -- pivoting creates new results with only the necessary columns.
|
|
1070
|
-
let rowIdx = 0;
|
|
1071
|
-
rows.forEach(row => {
|
|
1072
|
-
columnFormats.forEach(columnFormat => {
|
|
1073
|
-
if (columnFormat.name in row) {
|
|
1074
|
-
row[columnFormat.displayName] = evaluateValueFormat(columnFormat, row[columnFormat.name], locale);
|
|
1075
|
-
if (columnFormat.displayName !== columnFormat.name) { // Remove name in favor of display name.
|
|
1076
|
-
delete row[columnFormat.name];
|
|
1077
|
-
}
|
|
1078
|
-
if (rowIdx === 0) {
|
|
1079
|
-
htmlColumnNames.push(columnFormat.displayName);
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
else {
|
|
1083
|
-
const mappedColumnNamesSet = pivotOutput.mappedColumnNames.get(columnFormat.name);
|
|
1084
|
-
if (!!mappedColumnNamesSet) {
|
|
1085
|
-
const mappedColumnNamesArr = Array.from(mappedColumnNamesSet);
|
|
1086
|
-
for (const mappedColumnName of mappedColumnNamesArr) {
|
|
1087
|
-
if (mappedColumnName in row) {
|
|
1088
|
-
const adjDisplayName = mappedColumnName.replace(columnFormat.name, columnFormat.displayName);
|
|
1089
|
-
row[adjDisplayName] = evaluateValueFormat(columnFormat, row[mappedColumnName], locale);
|
|
1090
|
-
if (adjDisplayName !== mappedColumnName) { // Remove name in favor of display name.
|
|
1091
|
-
delete row[mappedColumnName];
|
|
1092
|
-
}
|
|
1093
|
-
let displayColumnNames = mappedDisplayColumnNames.get(columnFormat.displayName);
|
|
1094
|
-
if (!!displayColumnNames) {
|
|
1095
|
-
displayColumnNames.add(adjDisplayName);
|
|
1096
|
-
}
|
|
1097
|
-
else {
|
|
1098
|
-
displayColumnNames = new Set([adjDisplayName]);
|
|
1099
|
-
mappedDisplayColumnNames.set(columnFormat.displayName, displayColumnNames);
|
|
1100
|
-
}
|
|
1101
|
-
if (rowIdx === 0) {
|
|
1102
|
-
htmlColumnNames.push(columnFormat.displayName);
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
rowIdx++;
|
|
1110
|
-
});
|
|
1111
|
-
if (!!condition) {
|
|
1112
|
-
rows = evaluatePivotDatagridCondition(rows, condition, mappedDisplayColumnNames);
|
|
1113
|
-
}
|
|
1114
|
-
rowIdx = 0;
|
|
1115
|
-
rows.forEach(row => {
|
|
1116
|
-
let chartRow = {};
|
|
1117
|
-
let htmlRowValues = [];
|
|
1118
|
-
let htmlRowStyles = [];
|
|
1119
|
-
let htmlColumnStyles = [];
|
|
1120
|
-
let teamsRowStyles = [];
|
|
1121
|
-
let teamsColumnStyles = [];
|
|
1122
|
-
columnFormats.forEach(columnFormat => {
|
|
1123
|
-
if (columnFormat.name in row) {
|
|
1124
|
-
const formattedValue = evaluateValueFormat(columnFormat, row[columnFormat.displayName], locale);
|
|
1125
|
-
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
|
|
1126
|
-
htmlRowValues.push(formattedValue);
|
|
1127
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1128
|
-
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1129
|
-
}
|
|
1130
|
-
else {
|
|
1131
|
-
const mappedColumnNamesSet = pivotOutput.mappedColumnNames.get(columnFormat.name);
|
|
1132
|
-
if (!!mappedColumnNamesSet) {
|
|
1133
|
-
const mappedColumnNamesArr = Array.from(mappedColumnNamesSet);
|
|
1134
|
-
for (const mappedColumnName of mappedColumnNamesArr) {
|
|
1135
|
-
if (mappedColumnName in row) {
|
|
1136
|
-
const adjDisplayName = mappedColumnName.replace(columnFormat.name, columnFormat.displayName);
|
|
1137
|
-
const formattedValue = row[adjDisplayName];
|
|
1138
|
-
chartRow[adjDisplayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
|
|
1139
|
-
htmlRowValues.push(formattedValue);
|
|
1140
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1141
|
-
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1142
|
-
if (rowIdx === 0) {
|
|
1143
|
-
htmlColumnNames.push(columnFormat.displayName);
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
});
|
|
1150
|
-
chartRows.push(chartRow);
|
|
1151
|
-
if (rowIdx < HTML_ROWS) {
|
|
1152
|
-
htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
|
|
1153
|
-
if (rowIdx < TEAMS_ROWS) {
|
|
1154
|
-
teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
rowIdx++;
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
else {
|
|
1161
|
-
if (rowGroupCols.length > 0) {
|
|
1162
|
-
rows = groupAndAggregate(rows, rowGroupCols, [], valueCols);
|
|
1163
|
-
}
|
|
1164
|
-
rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
|
|
1165
|
-
const hiddenColumnNames = columnState.filter(column => !!column.hide && !column.rowGroup).map(column => column.colId) ?? [];
|
|
1166
|
-
const visibleColumnFormats = columnFormats.filter(column => !hiddenColumnNames.includes(column.name)) ?? [];
|
|
1167
|
-
rows.forEach(row => {
|
|
1168
|
-
hiddenColumnNames.forEach(columnName => {
|
|
1169
|
-
delete row[columnName];
|
|
1170
|
-
});
|
|
1171
|
-
visibleColumnFormats.forEach(columnFormat => {
|
|
1172
|
-
row[columnFormat.displayName] = evaluateValueFormat(columnFormat, row[columnFormat.name], locale);
|
|
1173
|
-
if (columnFormat.displayName !== columnFormat.name) { // Remove name in favor of display name.
|
|
1174
|
-
delete row[columnFormat.name];
|
|
1175
|
-
}
|
|
1176
|
-
});
|
|
1177
|
-
});
|
|
1178
|
-
if (!!condition) {
|
|
1179
|
-
rows = evaluateDatagridCondition(rows, condition);
|
|
1180
|
-
}
|
|
1181
|
-
let rowIdx = 0;
|
|
1182
|
-
rows.forEach(row => {
|
|
1183
|
-
let chartRow = {};
|
|
1184
|
-
let htmlRowValues = [];
|
|
1185
|
-
let htmlRowStyles = [];
|
|
1186
|
-
let htmlColumnStyles = [];
|
|
1187
|
-
let teamsRowStyles = [];
|
|
1188
|
-
let teamsColumnStyles = [];
|
|
1189
|
-
visibleColumnFormats.forEach(columnFormat => {
|
|
1190
|
-
const formattedValue = row[columnFormat.displayName];
|
|
1191
|
-
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? stripNumericValueFormat(formattedValue) : formattedValue;
|
|
1192
|
-
htmlRowValues.push(formattedValue);
|
|
1193
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1194
|
-
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1195
|
-
});
|
|
1196
|
-
chartRows.push(chartRow);
|
|
1197
|
-
if (rowIdx < HTML_ROWS) {
|
|
1198
|
-
htmlBuf += buildHtmlRow(htmlRowValues, htmlRowStyles, htmlColumnStyles, HTML_COLS);
|
|
1199
|
-
if (rowIdx < TEAMS_ROWS) {
|
|
1200
|
-
teamsRows.push(createTeamsTableRow(htmlColumnNames, htmlRowValues, teamsRowStyles, teamsColumnStyles));
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
rowIdx++;
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
return {
|
|
1207
|
-
...datagridState,
|
|
1208
|
-
adjRows: rows,
|
|
1209
|
-
chartRows,
|
|
1210
|
-
html: `${buildHtmlTableHeader(htmlColumnNames.slice(0, HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
|
|
1211
|
-
teamsRows: [
|
|
1212
|
-
createTeamsTableColumns(htmlColumnNames),
|
|
1213
|
-
...teamsRows
|
|
1214
|
-
]
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
1050
|
export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
1218
1051
|
const HTML_ROWS = 1000;
|
|
1219
1052
|
const HTML_COLS = 8;
|
|
@@ -1252,7 +1085,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1252
1085
|
row[columnFormat.displayName] = formattedValue;
|
|
1253
1086
|
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1254
1087
|
htmlRowValues.push(formattedValue);
|
|
1255
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1088
|
+
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1256
1089
|
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1257
1090
|
if (rowIdx === 0) {
|
|
1258
1091
|
htmlColumnNames.push(columnFormat.displayName);
|
|
@@ -1274,7 +1107,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1274
1107
|
row[adjDisplayName] = formattedValue;
|
|
1275
1108
|
chartRow[adjDisplayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1276
1109
|
htmlRowValues.push(formattedValue);
|
|
1277
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1110
|
+
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, adjDisplayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1278
1111
|
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1279
1112
|
if (rowIdx === 0) {
|
|
1280
1113
|
htmlColumnNames.push(adjDisplayName);
|
|
@@ -1333,7 +1166,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1333
1166
|
row[columnFormat.displayName] = formattedValue;
|
|
1334
1167
|
chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
|
|
1335
1168
|
htmlRowValues.push(formattedValue);
|
|
1336
|
-
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1169
|
+
[htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
|
|
1337
1170
|
[teamsRowStyles, teamsColumnStyles] = mapTeamsStyles(htmlColumnNames, htmlRowStyles, htmlColumnStyles, teamsRowStyles, teamsColumnStyles);
|
|
1338
1171
|
if (rowIdx === 0) {
|
|
1339
1172
|
htmlColumnNames.push(columnFormat.displayName);
|
|
@@ -1361,6 +1194,9 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1361
1194
|
adjRows: rows,
|
|
1362
1195
|
chartRows,
|
|
1363
1196
|
html: `${buildHtmlTableHeader(htmlColumnNames.slice(0, HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
|
|
1364
|
-
teamsRows
|
|
1197
|
+
teamsRows: [
|
|
1198
|
+
createTeamsTableColumns(htmlColumnNames),
|
|
1199
|
+
...teamsRows
|
|
1200
|
+
]
|
|
1365
1201
|
};
|
|
1366
1202
|
}
|