@milaboratories/milaboratories.ui-examples.model 1.0.25 → 1.0.27

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.25",
3
+ "version": "1.0.27",
4
4
  "description": "Block model",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -14,7 +14,7 @@
14
14
  "typescript": "~5.5.4",
15
15
  "vite": "^5.4.10",
16
16
  "tsup": "~8.2.4",
17
- "@platforma-sdk/block-tools": "2.3.19"
17
+ "@platforma-sdk/block-tools": "2.3.21"
18
18
  },
19
19
  "tsup": {
20
20
  "entry": [
package/src/index.ts CHANGED
@@ -1,4 +1,17 @@
1
- import { BlockModel, InferHrefType, InferOutputsType } from '@platforma-sdk/model';
1
+ import {
2
+ BlockModel,
3
+ InferHrefType,
4
+ InferOutputsType,
5
+ mapJoinEntry,
6
+ PColumnIdAndSpec,
7
+ AxisSpec,
8
+ JoinEntry,
9
+ AxisId,
10
+ PlDataTableState,
11
+ ValueType,
12
+ isPColumn,
13
+ PlDataTableGridState
14
+ } from '@platforma-sdk/model';
2
15
  import {z} from 'zod';
3
16
 
4
17
  export const $BlockArgs = z.object({
@@ -7,7 +20,25 @@ export const $BlockArgs = z.object({
7
20
 
8
21
  export type BlockArgs = z.infer<typeof $BlockArgs>;
9
22
 
10
- export const platforma = BlockModel.create<BlockArgs>('Heavy')
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
+ tableState: PlDataTableState;
35
+ };
36
+
37
+ export type UiState = {
38
+ dataTableState: TableState | undefined,
39
+ };
40
+
41
+ export const platforma = BlockModel.create<BlockArgs, UiState>('Heavy')
11
42
 
12
43
  .initialArgs({ numbers: [] })
13
44
 
@@ -15,9 +46,51 @@ export const platforma = BlockModel.create<BlockArgs>('Heavy')
15
46
  ctx.outputs?.resolve('numbers')?.getDataAsJson<number[]>()
16
47
  )
17
48
 
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
+ }
64
+ })
65
+ .output('pTable', (ctx) => {
66
+ const join = ctx.uiState?.dataTableState?.tableState.pTableParams?.join;
67
+ if (!join) return undefined;
68
+
69
+ const collection = ctx.resultPool.getData();
70
+ if (!collection || !collection.isComplete) return undefined;
71
+
72
+ const columns = collection.entries.map(({ obj }) => obj).filter(isPColumn);
73
+ if (columns.length === 0) return undefined;
74
+
75
+ try {
76
+ return ctx.createPTable({
77
+ src: mapJoinEntry(join, (idAndSpec) => {
78
+ const column = columns.find(it => it.id === idAndSpec.columnId);
79
+ if (!column) throw Error(`column '${column}' not ready`);
80
+ return column;
81
+ }),
82
+ filters: ctx.uiState.dataTableState?.tableState.pTableParams?.filters ?? [],
83
+ sorting: ctx.uiState.dataTableState?.tableState.pTableParams?.sorting ?? []
84
+ });
85
+ } catch (err) {
86
+ return undefined;
87
+ }
88
+ })
89
+
18
90
  .sections((ctx) => {
19
91
  return [
20
92
  { type: 'link', href: '/', label: 'PlLogView' },
93
+ { type: 'link', href: '/icons', label: 'Icons/Masks' },
21
94
  { type: 'link', href: '/modals', label: 'Modals' },
22
95
  { type: 'link', href: '/select-files', label: 'Select Files' },
23
96
  { type: 'link', href: '/inject-env', label: 'Inject env' },
@@ -26,6 +99,7 @@ export const platforma = BlockModel.create<BlockArgs>('Heavy')
26
99
  { type: 'link', href: '/form-components', label: 'Form Components' },
27
100
  { type: 'link', href: '/typography', label: 'Typography' },
28
101
  { type: 'link', href: '/ag-grid-vue', label: 'AgGridVue' },
102
+ { type: 'link', href: '/pl-ag-data-table', label: 'PlAgDataTable' },
29
103
  { type: 'link', href: '/errors', label: 'Errors' },
30
104
  ];
31
105
  })