@platforma-sdk/ui-vue 1.12.0 → 1.13.0

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.12.0",
3
+ "version": "1.13.0",
4
4
  "type": "module",
5
5
  "main": "dist/lib.umd.cjs",
6
6
  "module": "dist/lib.js",
@@ -38,7 +38,7 @@
38
38
  "@ag-grid-enterprise/side-bar": "^32.3.3",
39
39
  "@ag-grid-enterprise/column-tool-panel": "^32.3.3",
40
40
  "@milaboratories/uikit": "^2.2.11",
41
- "@platforma-sdk/model": "^1.12.0"
41
+ "@platforma-sdk/model": "^1.13.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@faker-js/faker": "^8.4.1",
@@ -1,6 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
3
3
  import type {
4
+ ColDef,
5
+ ColGroupDef,
4
6
  GridApi,
5
7
  GridOptions,
6
8
  GridReadyEvent,
@@ -9,8 +11,6 @@ import type {
9
11
  ManagedGridOptions,
10
12
  SortState,
11
13
  StateUpdatedEvent,
12
- ColDef,
13
- ColGroupDef,
14
14
  } from '@ag-grid-community/core';
15
15
  import { ModuleRegistry } from '@ag-grid-community/core';
16
16
  import { AgGridVue } from '@ag-grid-community/vue3';
@@ -20,7 +20,7 @@ import { RangeSelectionModule } from '@ag-grid-enterprise/range-selection';
20
20
  import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
21
21
  import { SideBarModule } from '@ag-grid-enterprise/side-bar';
22
22
  import { PlDropdownLine } from '@milaboratories/uikit';
23
- import type { AxisId, PlDataTableState, PTableColumnSpec, PTableRecordFilter, PTableSorting } from '@platforma-sdk/model';
23
+ import type { AxisId, PlDataTableSheet, PlDataTableState, PTableColumnSpec, PTableRecordFilter, PTableSorting } from '@platforma-sdk/model';
24
24
  import canonicalize from 'canonicalize';
25
25
  import * as lodash from 'lodash';
26
26
  import { computed, ref, shallowRef, toRefs, watch } from 'vue';
@@ -30,7 +30,7 @@ import PlOverlayNoRows from './PlAgOverlayNoRows.vue';
30
30
  import { updateXsvGridOptions } from './sources/file-source';
31
31
  import type { PlAgDataTableRow } from './sources/table-source';
32
32
  import { enrichJoinWithLabelColumns, makeSheets, parseColId, updatePFrameGridOptions } from './sources/table-source';
33
- import type { PlDataTableSettings, PlDataTableSheet, PlAgDataTableController } from './types';
33
+ import type { PlAgDataTableController, PlDataTableSettings } from './types';
34
34
 
35
35
  ModuleRegistry.registerModules([
36
36
  ClientSideRowModelModule,
@@ -173,13 +173,13 @@ function makeFilters(sheetsState: Record<string, string | number>): PTableRecord
173
173
  type: 'bySingleColumn',
174
174
  column: sheet.column
175
175
  ? {
176
- type: 'column',
177
- id: sheet.column,
178
- }
176
+ type: 'column',
177
+ id: sheet.column,
178
+ }
179
179
  : {
180
- type: 'axis',
181
- id: sheet.axis,
182
- },
180
+ type: 'axis',
181
+ id: sheet.axis,
182
+ },
183
183
  predicate: {
184
184
  operator: 'Equal',
185
185
  reference: sheetsState[makeSheetId(sheet.axis)],
@@ -504,28 +504,14 @@ watch(
504
504
 
505
505
  <template>
506
506
  <div class="ap-ag-data-table-container">
507
- <Transition name="ap-ag-data-table-sheets-transition">
508
- <div v-if="sheets.value && sheets.value.length > 0" class="ap-ag-data-table-sheets">
509
- <PlDropdownLine
510
- v-for="(sheet, i) in sheets.value"
511
- :key="i"
512
- :model-value="sheetsState[makeSheetId(sheet.axis)]"
513
- :options="sheet.options"
514
- @update:model-value="(newValue) => onSheetChanged(makeSheetId(sheet.axis), newValue)"
515
- />
516
- </div>
517
- </Transition>
518
- <AgGridVue
519
- :key="reloadKey"
520
- :theme="AgGridTheme"
521
- class="ap-ag-data-table-grid"
522
- :grid-options="gridOptions"
523
- @grid-ready="onGridReady"
524
- @state-updated="onStateUpdated"
525
- @grid-pre-destroyed="onGridPreDestroyed"
526
- @store-refreshed="onStoreRefreshed"
527
- @model-updated="onModelUpdated"
528
- />
507
+ <div v-if="sheets.value && sheets.value.length > 0" class="ap-ag-data-table-sheets">
508
+ <PlDropdownLine v-for="(sheet, i) in sheets.value" :key="i" :model-value="sheetsState[makeSheetId(sheet.axis)]"
509
+ :options="sheet.options"
510
+ @update:model-value="(newValue) => onSheetChanged(makeSheetId(sheet.axis), newValue)" />
511
+ </div>
512
+ <AgGridVue :key="reloadKey" :theme="AgGridTheme" class="ap-ag-data-table-grid" :grid-options="gridOptions"
513
+ @grid-ready="onGridReady" @state-updated="onStateUpdated" @grid-pre-destroyed="onGridPreDestroyed"
514
+ @store-refreshed="onStoreRefreshed" @model-updated="onModelUpdated" />
529
515
  </div>
530
516
  </template>
531
517
 
@@ -537,16 +523,6 @@ watch(
537
523
  gap: 12px;
538
524
  }
539
525
 
540
- .ap-ag-data-table-sheets-transition-enter-active,
541
- .ap-ag-data-table-sheets-transition-leave-active {
542
- transition: all 0.2s ease-in-out;
543
- }
544
-
545
- .ap-ag-data-table-sheets-transition-enter-from,
546
- .ap-ag-data-table-sheets-transition-leave-to {
547
- margin-top: -52px;
548
- }
549
-
550
526
  .ap-ag-data-table-sheets {
551
527
  display: flex;
552
528
  flex-direction: row;
@@ -127,7 +127,7 @@ export function updatePFrameGridOptionsHeterogeneousAxes(
127
127
  // add additional column definitions
128
128
  for (let i = 0; i < hAxisValues.length; ++i) {
129
129
  const header = hAxisValues[i];
130
- const id = header + '@' + i; // at least add i to avoid name clash with other columns
130
+ const id = canonicalize(header + '@' + i); // at least add i to avoid name clash with other columns
131
131
 
132
132
  columnDefs.push({
133
133
  colId: id,
@@ -1,5 +1,5 @@
1
1
  import type { ColDef, IServerSideDatasource, IServerSideGetRowsParams, RowModelType } from '@ag-grid-community/core';
2
- import type { AxisId, JoinEntry, PColumnIdAndSpec, PFrameHandle, PObjectId } from '@platforma-sdk/model';
2
+ import type { AxisId, JoinEntry, PColumnIdAndSpec, PFrameHandle, PlDataTableSheet, PObjectId } from '@platforma-sdk/model';
3
3
  import {
4
4
  type PColumnSpec,
5
5
  type PFrameDriver,
@@ -9,13 +9,13 @@ import {
9
9
  type PValue,
10
10
  type ValueType,
11
11
  getAxesId,
12
+ getAxisId,
12
13
  isValueAbsent,
13
14
  isValueNA,
14
15
  mapJoinEntry,
15
16
  } from '@platforma-sdk/model';
16
17
  import canonicalize from 'canonicalize';
17
18
  import * as lodash from 'lodash';
18
- import type { PlDataTableSheet } from '../types';
19
19
  import { getHeterogeneousColumns, updatePFrameGridOptionsHeterogeneousAxes } from './table-source-heterogeneous';
20
20
 
21
21
  /**
@@ -215,7 +215,7 @@ export async function makeSheets(
215
215
  return axes.map((axis, i) => {
216
216
  const options = [...possibleValues[i]].map((value) => ({
217
217
  value: value,
218
- text: value.toString(),
218
+ label: value.toString(),
219
219
  }));
220
220
  const defaultValue = options[0].value;
221
221
  return {
@@ -311,9 +311,17 @@ export async function updatePFrameGridOptions(
311
311
  const idx = indices[i];
312
312
  if (!isLabelColumn(specs[idx])) continue;
313
313
 
314
- const axisId = getAxesId((specs[idx].spec as PColumnSpec).axesSpec)[0];
314
+ // axis of labels
315
+ const axisId = getAxisId((specs[idx].spec as PColumnSpec).axesSpec[0]);
315
316
  const axisIdx = lodash.findIndex(indices, (idx) => lodash.isEqual(specs[idx].id, axisId));
316
- if (axisIdx === -1) continue;
317
+ if (axisIdx === -1) {
318
+ // no axis, probably we are in the sheet
319
+ const sheetIdx = lodash.findIndex(sheets, (sheet) => lodash.isEqual(sheet.axis, axisId));
320
+ if (sheetIdx === -1) {
321
+ console.warn(`added label column, but the axis is not in the data; axisId: ${axisId}`);
322
+ continue;
323
+ }
324
+ }
317
325
 
318
326
  // replace in h-columns
319
327
  indices[axisIdx] = idx;
@@ -4,31 +4,15 @@ import type {
4
4
  LocalBlobHandleAndSize,
5
5
  PColumnIdAndSpec,
6
6
  PFrameHandle,
7
+ PlDataTableSheet,
7
8
  PlTableFilter,
8
9
  PlTableFilterType,
9
- PObjectId,
10
10
  PTableColumnId,
11
11
  PTableHandle,
12
12
  RemoteBlobHandleAndSize,
13
13
  ValueOrErrors,
14
14
  } from '@platforma-sdk/model';
15
15
 
16
- export type PlDataTableSheet = {
17
- /** id of the axis to use */
18
- axis: AxisId;
19
- /** id of label column to use in filter instead of axis */
20
- column?: PObjectId;
21
- /** options to show in the filter tan */
22
- options: {
23
- /** value of the option (should be one of the values in the axis or column) */
24
- value: string | number;
25
- /** corresponding label */
26
- text: string;
27
- }[];
28
- /** default (selected) value */
29
- defaultValue?: string | number;
30
- };
31
-
32
16
  /** Data table settings */
33
17
  export type PlDataTableSettings =
34
18
  | {