@milaboratories/milaboratories.ui-examples.model 1.0.46 → 1.0.48

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": "@milaboratories/milaboratories.ui-examples.model",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -8,13 +8,13 @@
8
8
  "types": "dist/index.d.ts",
9
9
  "dependencies": {
10
10
  "zod": "^3.23.8",
11
- "@platforma-sdk/model": "1.14.1"
11
+ "@platforma-sdk/model": "1.17.0"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "~5.5.4",
15
15
  "vite": "^5.4.11",
16
16
  "tsup": "~8.3.5",
17
- "@platforma-sdk/block-tools": "2.4.2"
17
+ "@platforma-sdk/block-tools": "2.4.9"
18
18
  },
19
19
  "tsup": {
20
20
  "entry": [
package/src/index.ts CHANGED
@@ -2,15 +2,15 @@ import {
2
2
  BlockModel,
3
3
  InferHrefType,
4
4
  InferOutputsType,
5
- mapJoinEntry,
6
- PColumnIdAndSpec,
7
- AxisSpec,
8
- JoinEntry,
9
- AxisId,
10
5
  PlDataTableState,
11
6
  ValueType,
12
7
  isPColumn,
13
- PlDataTableGridState
8
+ isPColumnSpec,
9
+ PlRef,
10
+ getUniquePartitionKeys,
11
+ createPlDataTableSheet,
12
+ createPlDataTable,
13
+ PlTableFiltersModel
14
14
  } from '@platforma-sdk/model';
15
15
  import { z } from 'zod';
16
16
 
@@ -21,17 +21,9 @@ export const $BlockArgs = z.object({
21
21
  export type BlockArgs = z.infer<typeof $BlockArgs>;
22
22
 
23
23
  export type TableState = {
24
- settingsOpened: boolean;
25
- gridState: PlDataTableGridState;
26
- group: {
27
- mainColumn?: PColumnIdAndSpec;
28
- additionalColumns: PColumnIdAndSpec[];
29
- enrichmentColumns: PColumnIdAndSpec[];
30
- possiblePartitioningAxes: AxisSpec[];
31
- join?: JoinEntry<PColumnIdAndSpec>;
32
- };
33
- partitioningAxes: AxisId[];
34
24
  tableState: PlDataTableState;
25
+ anchorColumn?: PlRef;
26
+ filterModel: PlTableFiltersModel;
35
27
  };
36
28
 
37
29
  export type UiState = {
@@ -46,47 +38,37 @@ export const platforma = BlockModel.create('Heavy')
46
38
 
47
39
  .output('numbers', (ctx) => ctx.outputs?.resolve('numbers')?.getDataAsJson<number[]>())
48
40
 
49
- .output('pFrame', (ctx) => {
50
- const collection = ctx.resultPool.getData();
51
- if (collection === undefined || !collection.isComplete) return undefined;
52
-
53
- const valueTypes = ['Int', 'Long', 'Float', 'Double', 'String', 'Bytes'] as ValueType[];
54
- const columns = collection.entries
55
- .map(({ obj }) => obj)
56
- .filter(isPColumn)
57
- .filter((column) => valueTypes.find((valueType) => valueType === column.spec.valueType));
58
-
59
- try {
60
- return ctx.createPFrame(columns);
61
- } catch (err) {
62
- return undefined;
63
- }
41
+ .retentiveOutput('inputOptions', (ctx) => {
42
+ return ctx.resultPool.getOptions((spec) => isPColumnSpec(spec));
64
43
  })
65
44
 
66
- .output('pTable', (ctx) => {
67
- const join = ctx.uiState?.dataTableState?.tableState.pTableParams?.join;
68
- if (!join) return undefined;
45
+ .output('sheets', (ctx) => {
46
+ if (!ctx.uiState?.dataTableState?.anchorColumn) return undefined;
69
47
 
70
- const collection = ctx.resultPool.getData();
71
- if (!collection || !collection.isComplete) return undefined;
48
+ const anchor = ctx.resultPool.getPColumnByRef(ctx.uiState.dataTableState.anchorColumn);
49
+ if (!anchor) return undefined;
72
50
 
73
- const columns = collection.entries.map(({ obj }) => obj).filter(isPColumn);
74
- if (columns.length === 0) return undefined;
51
+ const r = getUniquePartitionKeys(anchor.data);
52
+ if (!r) return undefined;
53
+ return r.map((values, i) => createPlDataTableSheet(ctx, anchor.spec.axesSpec[i], values));
54
+ })
55
+
56
+ .output('pt', (ctx) => {
57
+ if (ctx.uiState?.dataTableState?.anchorColumn === undefined) return undefined;
75
58
 
76
- let columnMissing = false;
77
- const src = mapJoinEntry(join, (idAndSpec) => {
78
- const column = columns.find((it) => it.id === idAndSpec.columnId);
79
- if (!column) columnMissing = true;
80
- return column!;
81
- });
59
+ const anchorColumn = ctx.resultPool.getDataByRef(ctx.uiState.dataTableState.anchorColumn);
60
+ if (!anchorColumn || !isPColumn(anchorColumn)) {
61
+ console.error('Anchor column is undefined or is not PColumn', anchorColumn);
62
+ return undefined;
63
+ }
82
64
 
83
- if (columnMissing) return undefined;
65
+ // wait until sheet filters are set
66
+ if (ctx.uiState.dataTableState.tableState.pTableParams?.filters === undefined) return undefined;
84
67
 
85
- return ctx.createPTable({
86
- src,
87
- filters: ctx.uiState.dataTableState?.tableState.pTableParams?.filters ?? [],
88
- sorting: ctx.uiState.dataTableState?.tableState.pTableParams?.sorting ?? []
89
- });
68
+ return createPlDataTable(ctx, [anchorColumn], ctx.uiState.dataTableState.tableState, [
69
+ ...ctx.uiState.dataTableState.tableState.pTableParams?.filters,
70
+ ...(ctx.uiState.dataTableState.filterModel?.filters ?? [])
71
+ ]);
90
72
  })
91
73
 
92
74
  .sections((ctx) => {