@platforma-open/milaboratories.repertoire-diversity-2.model 1.3.1 → 1.5.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,14 +1,14 @@
1
1
  {
2
2
  "name": "@platforma-open/milaboratories.repertoire-diversity-2.model",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "dependencies": {
10
- "@platforma-sdk/model": "^1.34.10",
11
- "@milaboratories/graph-maker": "^1.1.121"
10
+ "@platforma-sdk/model": "^1.38.0",
11
+ "@milaboratories/graph-maker": "^1.1.127"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@platforma-sdk/block-tools": "^2.5.57",
@@ -0,0 +1,10 @@
1
+ import type { Metric, MetricUI } from './index';
2
+
3
+ export const convertMetricsUiToArgs = (metrics: MetricUI[]): Metric[] => {
4
+ return metrics.map((metric): Metric => {
5
+ return {
6
+ type: metric.type,
7
+ downsampling: metric.downsampling,
8
+ };
9
+ });
10
+ };
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { GraphMakerState } from '@milaboratories/graph-maker';
2
- import type { InferOutputsType, PColumnIdAndSpec, PlDataTableState, PlRef } from '@platforma-sdk/model';
3
- import { BlockModel, createPFrameForGraphs, createPlDataTable } from '@platforma-sdk/model';
2
+ import type { InferOutputsType, PColumnIdAndSpec, PlDataTableStateV2, PlRef } from '@platforma-sdk/model';
3
+ import { BlockModel, createPFrameForGraphs, createPlDataTableStateV2, createPlDataTableV2 } from '@platforma-sdk/model';
4
+
5
+ export * from './converters';
4
6
 
5
7
  export type DiversityType = 'chao1' | 'd50' | 'efronThisted' |
6
8
  'observed' | 'shannonWienerIndex' | 'shannonWiener' |
@@ -15,76 +17,87 @@ export type Metric = {
15
17
  };
16
18
  };
17
19
 
20
+ export type MetricUI = Metric & {
21
+ id: string;
22
+ isExpanded?: boolean;
23
+ };
24
+
18
25
  export type BlockArgs = {
19
26
  abundanceRef?: PlRef;
20
27
  metrics: Metric[];
21
28
  };
22
29
 
23
30
  export type UiState = {
31
+ metrics: MetricUI[];
24
32
  blockTitle: string;
25
- tableState?: PlDataTableState;
33
+ tableState: PlDataTableStateV2;
26
34
  graphState: GraphMakerState;
27
35
  };
28
36
 
29
37
  export const model = BlockModel.create()
30
-
31
38
  .withArgs<BlockArgs>({
39
+ metrics: [],
40
+ })
41
+
42
+ .withUiState<UiState>({
43
+ blockTitle: 'Repertoire Diversity',
44
+ graphState: {
45
+ title: 'Repertoire Diversity',
46
+ template: 'bar',
47
+ currentTab: null,
48
+ },
49
+
50
+ tableState: createPlDataTableStateV2(),
51
+
32
52
  metrics: [
33
53
  {
54
+ id: 'observed',
34
55
  type: 'observed',
35
56
  downsampling: {
36
57
  type: 'hypergeometric',
37
58
  valueChooser: 'auto',
38
59
  },
60
+ isExpanded: false,
39
61
  },
40
62
  {
63
+ id: 'shannonWiener',
41
64
  type: 'shannonWiener',
42
65
  downsampling: {
43
66
  type: 'hypergeometric',
44
67
  valueChooser: 'auto',
45
68
  },
69
+ isExpanded: false,
46
70
  },
47
71
  {
72
+ id: 'chao1',
48
73
  type: 'chao1',
49
74
  downsampling: {
50
75
  type: 'hypergeometric',
51
76
  valueChooser: 'auto',
52
77
  },
78
+ isExpanded: false,
53
79
  },
54
80
  {
81
+ id: 'gini',
55
82
  type: 'gini',
56
83
  downsampling: {
57
84
  type: 'hypergeometric',
58
85
  valueChooser: 'auto',
59
86
  },
87
+ isExpanded: false,
60
88
  },
61
89
  {
90
+ id: 'd50',
62
91
  type: 'd50',
63
92
  downsampling: {
64
93
  type: 'hypergeometric',
65
94
  valueChooser: 'auto',
66
95
  },
96
+ isExpanded: false,
67
97
  },
68
98
  ],
69
99
  })
70
100
 
71
- .withUiState<UiState>({
72
- blockTitle: 'Repertoire Diversity',
73
- graphState: {
74
- title: 'Repertoire Diversity',
75
- template: 'bar',
76
- currentTab: null,
77
- },
78
-
79
- tableState: {
80
- gridState: {},
81
- pTableParams: {
82
- sorting: [],
83
- filters: [],
84
- },
85
- },
86
- })
87
-
88
101
  .argsValid((ctx) => ctx.args.abundanceRef !== undefined)
89
102
 
90
103
  .output('abundanceOptions', (ctx) =>
@@ -108,7 +121,7 @@ export const model = BlockModel.create()
108
121
  return undefined;
109
122
  }
110
123
 
111
- return createPlDataTable(ctx, pCols, ctx.uiState?.tableState);
124
+ return createPlDataTableV2(ctx, pCols, ctx.uiState.tableState);
112
125
  })
113
126
 
114
127
  .output('pf', (ctx) => {