@cellaware/utils 8.6.12 → 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.
- package/dist/chatwms/datagrid.d.ts +1 -2
- package/dist/chatwms/datagrid.js +8 -173
- 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
|
@@ -1024,7 +1024,9 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
|
|
|
1024
1024
|
style: rowStyle,
|
|
1025
1025
|
cells: values.map((value, idx) => {
|
|
1026
1026
|
const columnName = columnNames[idx];
|
|
1027
|
-
const columnStyle = columnStyles
|
|
1027
|
+
const columnStyle = columnStyles[idx];
|
|
1028
|
+
console.log('C.');
|
|
1029
|
+
console.log(columnStyle);
|
|
1028
1030
|
let style = undefined;
|
|
1029
1031
|
for (const styles of columnStyle?.styles ?? []) {
|
|
1030
1032
|
if (!!styles.style) {
|
|
@@ -1042,178 +1044,8 @@ function createTeamsTableRow(columnNames, values, rowStyles, columnStyles) {
|
|
|
1042
1044
|
/**
|
|
1043
1045
|
* **Important:** `html` and `teamsRows` output will be limited to **1,000 rows/64 rows** and **8 columns**, respectively.
|
|
1044
1046
|
*
|
|
1045
|
-
* All outputs respect and will be filtered by optional `condition` argument
|
|
1047
|
+
* ~All outputs respect and will be filtered by optional `condition` argument.~
|
|
1046
1048
|
*/
|
|
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
1049
|
export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
1218
1050
|
const HTML_ROWS = 1000;
|
|
1219
1051
|
const HTML_COLS = 8;
|
|
@@ -1361,6 +1193,9 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
|
|
|
1361
1193
|
adjRows: rows,
|
|
1362
1194
|
chartRows,
|
|
1363
1195
|
html: `${buildHtmlTableHeader(htmlColumnNames.slice(0, HTML_COLS))}${htmlBuf}${buildHtmlTableFooter()}`,
|
|
1364
|
-
teamsRows
|
|
1196
|
+
teamsRows: [
|
|
1197
|
+
createTeamsTableColumns(htmlColumnNames),
|
|
1198
|
+
...teamsRows
|
|
1199
|
+
]
|
|
1365
1200
|
};
|
|
1366
1201
|
}
|