@platforma-sdk/ui-vue 1.19.0 → 1.20.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/ui-vue",
3
- "version": "1.19.0",
3
+ "version": "1.20.2",
4
4
  "type": "module",
5
5
  "main": "dist/lib.umd.cjs",
6
6
  "module": "dist/lib.js",
@@ -37,8 +37,8 @@
37
37
  "@ag-grid-community/theming": "^32.3.3",
38
38
  "@ag-grid-enterprise/side-bar": "^32.3.3",
39
39
  "@ag-grid-enterprise/column-tool-panel": "^32.3.3",
40
- "@platforma-sdk/model": "^1.19.0",
41
- "@milaboratories/uikit": "^2.2.32"
40
+ "@milaboratories/uikit": "^2.2.32",
41
+ "@platforma-sdk/model": "^1.20.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@faker-js/faker": "^9.2.0",
@@ -58,8 +58,8 @@
58
58
  "yarpm": "^1.2.0",
59
59
  "semver": "^7.6.3",
60
60
  "@types/semver": "^7.5.8",
61
- "@milaboratories/helpers": "^1.6.9",
62
- "@milaboratories/eslint-config": "^1.0.0"
61
+ "@milaboratories/eslint-config": "^1.0.0",
62
+ "@milaboratories/helpers": "^1.6.9"
63
63
  },
64
64
  "scripts": {
65
65
  "test": "vitest run --passWithNoTests",
@@ -28,7 +28,7 @@ export function trackFirstDataRendered(gridApi: GridApi, tracker: OnceTracker<Gr
28
28
  });
29
29
  gridApi.addEventListener('modelUpdated', (event) => {
30
30
  const groupState = event.api.getServerSideGroupLevelState();
31
- if (groupState.length > 0 && groupState[0].lastRowIndexKnown) {
31
+ if (groupState && groupState.length > 0 && groupState[0].lastRowIndexKnown) {
32
32
  tracker.track(event.api);
33
33
  }
34
34
  });
@@ -41,10 +41,10 @@ export function getHeterogeneousColumns(specs: PTableColumnSpec[], indices: numb
41
41
  }
42
42
 
43
43
  const axisId = getAxisId(hAx);
44
- const axisIdx = specs.findIndex((s) => lodash.isEqual(s.id, axisId));
44
+ const axisIdx = indices.find((idx) => lodash.isEqual(specs[idx].id, axisId));
45
45
 
46
- if (axisIdx === -1) {
47
- console.error('axis not found', i, axisId, specs);
46
+ if (axisIdx === undefined) {
47
+ console.error('axis not found', i, axisId, specs, indices);
48
48
  throw Error('axis not found');
49
49
  }
50
50
 
@@ -57,12 +57,12 @@ export function getHeterogeneousColumns(specs: PTableColumnSpec[], indices: numb
57
57
  }
58
58
 
59
59
  // auxiliary function to get a field for i-th axis-value
60
- const hColumnField = (originalLength: number, i: number) => (originalLength + i).toString();
60
+ const hColumnField = (originalLength: number, i: number) => 'hC' + (originalLength + i).toString();
61
61
 
62
62
  /**
63
63
  * Calculate GridOptions for p-table data source type
64
64
  *
65
- * @param hColumns heterogeneous columns list
65
+ * @param hColumn heterogeneous column
66
66
  * @param shape table shape
67
67
  * @param columnDefs initial column definitions (with h-cols inside and no additional columns)
68
68
  * @param data data array (including initial columns)
@@ -70,7 +70,7 @@ const hColumnField = (originalLength: number, i: number) => (originalLength + i)
70
70
  * @param indices indices in the original specs array
71
71
  */
72
72
  export function updatePFrameGridOptionsHeterogeneousAxes(
73
- hColumns: HeterogeneousColumnInfo[],
73
+ hColumn: HeterogeneousColumnInfo,
74
74
  shape: PTableShape,
75
75
  columnDefs: ColDef[],
76
76
  data: PTableVector[],
@@ -82,12 +82,6 @@ export function updatePFrameGridOptionsHeterogeneousAxes(
82
82
  rowModelType: RowModelType;
83
83
  rowData?: unknown[];
84
84
  } {
85
- if (hColumns.length > 1) {
86
- throw Error('hColumns.length > 1 is not supported');
87
- }
88
-
89
- const hColumn = hColumns[0];
90
-
91
85
  // recalculate indices of h-cols to the positions in the resulting data
92
86
  // index of axis & column in indices array
93
87
  let axisIdx: number = -1;
@@ -100,6 +94,10 @@ export function updatePFrameGridOptionsHeterogeneousAxes(
100
94
  columnIdx = i;
101
95
  }
102
96
  }
97
+ if (axisIdx === -1 || columnIdx === -1) {
98
+ console.error(`axisIdx === -1 || columnIdx === -1: ${axisIdx} ${columnIdx}`, hColumn, indices);
99
+ throw Error(`axisIdx === -1 || columnIdx === -1: ${axisIdx} ${columnIdx}`);
100
+ }
103
101
 
104
102
  // columns to add into the data table definition
105
103
  const hAxisValues: string[] = (() => {
@@ -114,11 +112,11 @@ export function updatePFrameGridOptionsHeterogeneousAxes(
114
112
 
115
113
  // remove heterogeneous column from the column defs
116
114
  if (columnIdx > axisIdx) {
117
- columnDefs.splice(columnIdx, 1);
118
- columnDefs.splice(axisIdx, 1);
115
+ columnDefs.splice(columnIdx + 1, 1); // note '+1' added to account for # column
116
+ columnDefs.splice(axisIdx + 1, 1);
119
117
  } else {
120
- columnDefs.splice(axisIdx, 1);
121
- columnDefs.splice(columnIdx, 1);
118
+ columnDefs.splice(axisIdx + 1, 1);
119
+ columnDefs.splice(columnIdx + 1, 1);
122
120
  }
123
121
 
124
122
  // calculate row data
@@ -1,23 +1,23 @@
1
1
  import type { ColDef, ICellRendererParams, IServerSideDatasource, IServerSideGetRowsParams, RowModelType } from '@ag-grid-community/core';
2
2
  import {
3
+ getAxisId,
4
+ pTableValue,
3
5
  type AxisId,
4
6
  type PColumnSpec,
5
7
  type PFrameDriver,
8
+ type PlDataTableSheet,
6
9
  type PTableColumnSpec,
7
10
  type PTableHandle,
8
- type PTableVector,
9
- type PlDataTableSheet,
10
11
  type PTableValue,
11
- getAxisId,
12
- pTableValue,
12
+ type PTableVector,
13
13
  } from '@platforma-sdk/model';
14
14
  import canonicalize from 'canonicalize';
15
15
  import * as lodash from 'lodash';
16
- import { getHeterogeneousColumns, updatePFrameGridOptionsHeterogeneousAxes } from './table-source-heterogeneous';
16
+ import { PlAgColumnHeader, type PlAgHeaderComponentParams, type PlAgHeaderComponentType } from '../../PlAgColumnHeader';
17
+ import PlAgTextAndButtonCell from '../../PlAgTextAndButtonCell/PlAgTextAndButtonCell.vue';
17
18
  import type { PlAgDataTableRow } from '../types';
18
19
  import { makeRowNumberColDef, PlAgDataTableRowNumberColId } from './row-number';
19
- import { PlAgColumnHeader, type PlAgHeaderComponentType, type PlAgHeaderComponentParams } from '../../PlAgColumnHeader';
20
- import PlAgTextAndButtonCell from '../../PlAgTextAndButtonCell/PlAgTextAndButtonCell.vue';
20
+ import { getHeterogeneousColumns, updatePFrameGridOptionsHeterogeneousAxes } from './table-source-heterogeneous';
21
21
 
22
22
  /**
23
23
  * Generate unique colId based on the column spec.
@@ -187,21 +187,18 @@ export async function updatePFrameGridOptions(
187
187
 
188
188
  // axis of labels
189
189
  const axisId = getAxisId((specs[idx].spec as PColumnSpec).axesSpec[0]);
190
- const axisIdx = lodash.findIndex(indices, (idx) => lodash.isEqual(specs[idx].id, axisId));
190
+ const axisIdx = indices.findIndex((idx) => lodash.isEqual(specs[idx].id, axisId));
191
191
  if (axisIdx === -1) {
192
- // no axis, probably we are in the sheet
193
- const sheetIdx = lodash.findIndex(sheets, (sheet) => lodash.isEqual(getAxisId(sheet.axis), axisId));
194
- if (sheetIdx === -1) {
195
- console.warn(`added label column, but the axis is not in the data; axisId: ${axisId}`);
196
- continue;
197
- }
192
+ // no axis, it was already processed
193
+ continue;
198
194
  }
199
195
 
200
196
  // replace in h-columns
197
+ const oldIdx = indices[axisIdx];
201
198
  indices[axisIdx] = idx;
202
199
  for (const hCol of hColumns) {
203
- if (hCol.axisIdx === idx) {
204
- hCol.axisIdx = axisIdx;
200
+ if (hCol.axisIdx === oldIdx) {
201
+ hCol.axisIdx = idx;
205
202
  }
206
203
  }
207
204
 
@@ -212,15 +209,27 @@ export async function updatePFrameGridOptions(
212
209
 
213
210
  const ptShape = await pfDriver.getShape(pt);
214
211
  const rowCount = ptShape.rows;
215
- const columnDefs: ColDef<PlAgDataTableRow>[] = [makeRowNumberColDef(), ...fields.map((i) => getColDef(i, specs[i], hiddenColIds, showCellButtonForAxisId))];
216
-
217
- if (hColumns.length > 1) {
218
- console.warn('Currently, only one heterogeneous axis is supported in the table, got', hColumns.length, ' transposition will not be applied.');
219
- }
212
+ const columnDefs: ColDef<PlAgDataTableRow>[] = [
213
+ makeRowNumberColDef(),
214
+ ...fields.map((i) => getColDef(i, specs[i], hiddenColIds, showCellButtonForAxisId)),
215
+ ];
216
+
217
+ if (hColumns.length > 0) {
218
+ let valueColumn = undefined;
219
+ if (hColumns.length == 1) {
220
+ valueColumn = hColumns[0];
221
+ } else {
222
+ const vc = hColumns.filter((i) => specs[i.columnIdx].spec.annotations?.['pl7.app/table/hValue'] === 'true');
223
+ if (vc.length === 1) valueColumn = vc[0];
224
+ }
220
225
 
221
- if (hColumns.length === 1) {
222
- // return data
223
- return updatePFrameGridOptionsHeterogeneousAxes(hColumns, ptShape, columnDefs, await pfDriver.getData(pt, indices), fields, indices);
226
+ if (!valueColumn) {
227
+ console.warn(
228
+ `Currently, only one heterogeneous axis / column is supported in the table, got ${hColumns.length} transposition will not be applied.`,
229
+ );
230
+ } else {
231
+ return updatePFrameGridOptionsHeterogeneousAxes(valueColumn, ptShape, columnDefs, await pfDriver.getData(pt, indices), fields, indices);
232
+ }
224
233
  }
225
234
 
226
235
  // mixing in axis indices