@milaboratories/milaboratories.ui-examples.model 1.1.26 → 1.1.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.1.26",
3
+ "version": "1.1.27",
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.24.5"
11
+ "@platforma-sdk/model": "1.24.9"
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.5.24"
17
+ "@platforma-sdk/block-tools": "2.5.25"
18
18
  },
19
19
  "tsup": {
20
20
  "entry": [
package/src/index.ts CHANGED
@@ -12,7 +12,27 @@ import {
12
12
  } from '@platforma-sdk/model';
13
13
  import { z } from 'zod';
14
14
 
15
+ export function* range(from: number, to: number, step = 1) {
16
+ for (let i = from; i < to; i += step) {
17
+ yield i;
18
+ }
19
+ }
20
+
21
+ export function toList<T>(iterable: Iterable<T>): T[] {
22
+ const lst: T[] = [];
23
+ for (const it of iterable) {
24
+ lst.push(it);
25
+ }
26
+
27
+ return lst;
28
+ }
29
+
30
+ export function times<R>(n: number, cb: (i: number) => R): R[] {
31
+ return toList(range(0, n)).map(cb);
32
+ }
33
+
15
34
  export const $BlockArgs = z.object({
35
+ tableNumRows: z.number().default(100),
16
36
  numbers: z.array(z.coerce.number()),
17
37
  });
18
38
 
@@ -33,7 +53,7 @@ export type UiState = {
33
53
 
34
54
  export const platforma = BlockModel.create('Heavy')
35
55
 
36
- .withArgs<BlockArgs>({ numbers: [1, 2, 3, 4] })
56
+ .withArgs<BlockArgs>({ numbers: [1, 2, 3, 4], tableNumRows: 100 })
37
57
 
38
58
  .withUiState<UiState>({ dataTableState: undefined, dynamicSections: [] })
39
59
 
@@ -49,6 +69,15 @@ export const platforma = BlockModel.create('Heavy')
49
69
 
50
70
  .output('pt', (ctx) => {
51
71
  if (!ctx.uiState?.dataTableState?.tableState.pTableParams?.filters) return undefined;
72
+
73
+ const data = times(ctx.args.tableNumRows ?? 0, (i) => {
74
+ const v = i + 1;
75
+ return {
76
+ key: [v, v + 0.1],
77
+ val: v.toString(),
78
+ };
79
+ });
80
+
52
81
  return createPlDataTable(
53
82
  ctx,
54
83
  [
@@ -76,14 +105,12 @@ export const platforma = BlockModel.create('Heavy')
76
105
  name: 'value',
77
106
  annotations: {
78
107
  'pl7.app/label': 'Float axis',
108
+ 'pl7.app/table/visibility': 'optional',
79
109
  },
80
110
  },
81
111
  ],
82
112
  },
83
- data: [
84
- { key: [1, 1.1], val: '1' },
85
- { key: [2, 2.2], val: '2' },
86
- ],
113
+ data,
87
114
  } satisfies PColumn<PColumnValues>,
88
115
  ],
89
116
  ctx.uiState.dataTableState.tableState,