@cellaware/utils 8.11.14 → 8.11.15

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.
@@ -1250,6 +1250,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1250
1250
  rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
1251
1251
  let mappedDisplayColumnNames = new Map();
1252
1252
  // Should not need to do hidden/visible column analysis -- pivoting creates new results with only the necessary columns.
1253
+ // Also should not need to analyze column sequence -- our newly created results *should* respect the correct sequence.
1253
1254
  let rowIdx = 0;
1254
1255
  rows.forEach(row => {
1255
1256
  let chartRow = {};
@@ -1339,6 +1340,7 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1339
1340
  rows = groupAndAggregate(rows, rowGroupCols, [], valueCols);
1340
1341
  }
1341
1342
  rows = sortModel.length > 0 ? sortRows(rows, sortModel) : rows;
1343
+ const visibleColumnState = columnState.filter(column => !column.hide);
1342
1344
  const hiddenColumnNames = columnState.filter(column => !!column.hide && !column.rowGroup).map(column => column.colId) ?? [];
1343
1345
  const visibleColumnFormats = columnFormats.filter(column => !hiddenColumnNames.includes(column.name)) ?? [];
1344
1346
  let rowIdx = 0;
@@ -1353,20 +1355,24 @@ export function transformDatagrid(rows, datagridState, locale, condition) {
1353
1355
  hiddenColumnNames.forEach(columnName => {
1354
1356
  delete row[columnName];
1355
1357
  });
1356
- visibleColumnFormats.forEach(columnFormat => {
1357
- const value = row[columnFormat.name];
1358
- const formattedValue = evaluateValueFormat(columnFormat, value, locale);
1359
- row[columnFormat.displayName] = formattedValue;
1360
- chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
1361
- htmlRowValues.push(formattedValue);
1362
- [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
1363
- htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, columnFormat.displayName, columnFormat, htmlTransposeColumnStyles);
1364
- if (rowIdx === 0) {
1365
- htmlColumnNames.push(columnFormat.displayName);
1366
- }
1367
- // Remove name in favor of display name.
1368
- if (columnFormat.displayName !== columnFormat.name) {
1369
- delete row[columnFormat.name];
1358
+ // Important: anchoring to column state will ensure we add columns in the correct sequence.
1359
+ visibleColumnState.forEach(column => {
1360
+ const columnFormat = visibleColumnFormats.find(columnFormat => columnFormat.name === column.colId);
1361
+ if (!!columnFormat) {
1362
+ const value = row[columnFormat.name];
1363
+ const formattedValue = evaluateValueFormat(columnFormat, value, locale);
1364
+ row[columnFormat.displayName] = formattedValue;
1365
+ chartRow[columnFormat.displayName] = formatNumberEnabled(columnFormat.valueFormat) ? value : formattedValue;
1366
+ htmlRowValues.push(formattedValue);
1367
+ [htmlRowStyles, htmlColumnStyles] = processHtmlStyles(formattedValue, columnFormat.displayName, columnFormat, htmlRowStyles, htmlColumnStyles);
1368
+ htmlTransposeColumnStyles = processHtmlTransposeStyles(formattedValue, columnFormat.displayName, columnFormat, htmlTransposeColumnStyles);
1369
+ if (rowIdx === 0) {
1370
+ htmlColumnNames.push(columnFormat.displayName);
1371
+ }
1372
+ // Remove name in favor of display name.
1373
+ if (columnFormat.displayName !== columnFormat.name) {
1374
+ delete row[columnFormat.name];
1375
+ }
1370
1376
  }
1371
1377
  });
1372
1378
  chartRows.push(chartRow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.11.14",
3
+ "version": "8.11.15",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",