@milaboratories/milaboratories.ui-examples.model 1.2.25 → 1.2.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/dist/index.cjs CHANGED
@@ -3,301 +3,312 @@
3
3
  var model = require('@platforma-sdk/model');
4
4
  var zod = require('zod');
5
5
 
6
- // src/index.ts
7
- var ImportFileHandleSchema = zod.z.string().optional().refine(
8
- (_a) => true
9
- );
6
+ const ImportFileHandleSchema = zod.z
7
+ .string()
8
+ .optional()
9
+ .refine(((_a) => true));
10
10
  function* range(from, to, step = 1) {
11
- for (let i = from; i < to; i += step) {
12
- yield i;
13
- }
11
+ for (let i = from; i < to; i += step) {
12
+ yield i;
13
+ }
14
14
  }
15
15
  function toList(iterable) {
16
- const lst = [];
17
- for (const it of iterable) {
18
- lst.push(it);
19
- }
20
- return lst;
16
+ const lst = [];
17
+ for (const it of iterable) {
18
+ lst.push(it);
19
+ }
20
+ return lst;
21
21
  }
22
22
  function times(n, cb) {
23
- return toList(range(0, n)).map(cb);
23
+ return toList(range(0, n)).map(cb);
24
24
  }
25
- var $BlockArgs = zod.z.object({
26
- numbers: zod.z.array(zod.z.coerce.number()),
27
- handles: zod.z.array(ImportFileHandleSchema)
25
+ const $BlockArgs = zod.z.object({
26
+ numbers: zod.z.array(zod.z.coerce.number()),
27
+ handles: zod.z.array(ImportFileHandleSchema),
28
28
  });
29
- var platforma = model.BlockModel.create("Heavy").withArgs({ numbers: [1, 2, 3, 4], handles: [] }).withUiState({
30
- dataTableV2: {
31
- sourceId: "source_1",
32
- numRows: 200,
33
- state: model.createPlDataTableStateV2()
34
- },
35
- dynamicSections: [],
36
- datasets: []
37
- }).argsValid((ctx) => {
38
- if (ctx.args.numbers.length === 5) {
39
- throw new Error("argsValid: test error");
40
- }
41
- return ctx.args.numbers.length > 0;
42
- }).output("numbers", (ctx) => ctx.outputs?.resolve("numbers")?.getDataAsJson()).output("progresses", (ctx) => {
43
- const m = ctx.outputs?.resolve("progresses");
44
- const progresses = m?.mapFields((name, val) => [name, val?.getImportProgress()]);
45
- return Object.fromEntries(progresses ?? []);
46
- }).output("ptV2Sheets", (ctx) => {
47
- const rowCount = ctx.uiState.dataTableV2.numRows ?? 0;
48
- const sheets = [
49
- {
50
- axis: {
51
- type: model.ValueType.Int,
52
- name: "part",
53
- annotations: {
54
- [model.Annotation.Label]: "Partitioned axis",
55
- [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1])
56
- }
57
- },
58
- options: [
59
- { value: 0, label: "Partition 1" },
60
- { value: 1, label: "Partition 2" }
61
- ]
29
+ const platforma = model.BlockModel.create('Heavy')
30
+ .withArgs({ numbers: [1, 2, 3, 4], handles: [] })
31
+ .withUiState({
32
+ dataTableV2: {
33
+ sourceId: 'source_1',
34
+ numRows: 200,
35
+ state: model.createPlDataTableStateV2(),
36
+ },
37
+ dynamicSections: [],
38
+ datasets: [],
39
+ })
40
+ .argsValid((ctx) => {
41
+ if (ctx.args.numbers.length === 5) {
42
+ throw new Error('argsValid: test error');
62
43
  }
63
- ];
64
- return rowCount > 0 ? sheets : [];
65
- }).output("ptV2", (ctx) => {
66
- const rowCount = ctx.uiState.dataTableV2.numRows ?? 0;
67
- const makePartitionId = (rowCount2, i) => Math.floor(2 * i / (rowCount2 + 1));
68
- const columns = [
69
- {
70
- id: "column1",
71
- spec: {
72
- kind: "PColumn",
73
- valueType: model.ValueType.String,
74
- name: "example",
75
- annotations: {
76
- [model.Annotation.Label]: "String column",
77
- [model.Annotation.DiscreteValues]: model.stringifyJson(["up", "down"]),
78
- [model.Annotation.Table.OrderPriority]: model.stringifyJson(101)
44
+ return ctx.args.numbers.length > 0;
45
+ })
46
+ .output('numbers', (ctx) => ctx.outputs?.resolve('numbers')?.getDataAsJson())
47
+ .output('progresses', (ctx) => {
48
+ const m = ctx.outputs?.resolve('progresses');
49
+ const progresses = m?.mapFields((name, val) => [name, val?.getImportProgress()]);
50
+ return Object.fromEntries(progresses ?? []);
51
+ })
52
+ .output('ptV2Sheets', (ctx) => {
53
+ const rowCount = ctx.uiState.dataTableV2.numRows ?? 0;
54
+ const sheets = [
55
+ {
56
+ axis: {
57
+ type: model.ValueType.Int,
58
+ name: 'part',
59
+ annotations: {
60
+ [model.Annotation.Label]: 'Partitioned axis',
61
+ [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1]),
62
+ },
63
+ },
64
+ options: [
65
+ { value: 0, label: 'Partition 1' },
66
+ { value: 1, label: 'Partition 2' },
67
+ ],
79
68
  },
80
- axesSpec: [
81
- {
82
- type: model.ValueType.Int,
83
- name: "part",
84
- annotations: {
85
- [model.Annotation.Label]: "Partitioned axis",
86
- [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1])
87
- }
88
- },
89
- {
90
- type: model.ValueType.Int,
91
- name: "index",
92
- annotations: {
93
- [model.Annotation.Label]: "Int axis"
94
- }
95
- }
96
- ]
97
- },
98
- data: times(rowCount, (i) => {
99
- const v = i + 1;
100
- return {
101
- key: [makePartitionId(rowCount, v), v],
102
- val: v.toString()
103
- };
104
- })
105
- },
106
- {
107
- id: "column2",
108
- spec: {
109
- kind: "PColumn",
110
- valueType: model.ValueType.Float,
111
- name: "value",
112
- annotations: {
113
- [model.Annotation.Label]: "Float column",
114
- [model.Annotation.Table.Visibility]: "optional",
115
- [model.Annotation.Table.OrderPriority]: model.stringifyJson(100)
69
+ ];
70
+ return rowCount > 0 ? sheets : [];
71
+ })
72
+ .output('ptV2', (ctx) => {
73
+ const rowCount = ctx.uiState.dataTableV2.numRows ?? 0;
74
+ const makePartitionId = (rowCount, i) => Math.floor((2 * i) / (rowCount + 1));
75
+ const columns = [
76
+ {
77
+ id: 'column1',
78
+ spec: {
79
+ kind: 'PColumn',
80
+ valueType: model.ValueType.String,
81
+ name: 'example',
82
+ annotations: {
83
+ [model.Annotation.Label]: 'String column',
84
+ [model.Annotation.DiscreteValues]: model.stringifyJson(['up', 'down']),
85
+ [model.Annotation.Table.OrderPriority]: model.stringifyJson(101),
86
+ },
87
+ axesSpec: [
88
+ {
89
+ type: model.ValueType.Int,
90
+ name: 'part',
91
+ annotations: {
92
+ [model.Annotation.Label]: 'Partitioned axis',
93
+ [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1]),
94
+ },
95
+ },
96
+ {
97
+ type: model.ValueType.Int,
98
+ name: 'index',
99
+ annotations: {
100
+ [model.Annotation.Label]: 'Int axis',
101
+ },
102
+ },
103
+ ],
104
+ },
105
+ data: times(rowCount, (i) => {
106
+ const v = i + 1;
107
+ return {
108
+ key: [makePartitionId(rowCount, v), v],
109
+ val: v.toString(),
110
+ };
111
+ }),
116
112
  },
117
- axesSpec: [
118
- {
119
- type: model.ValueType.Int,
120
- name: "part",
121
- annotations: {
122
- [model.Annotation.Label]: "Partitioned axis",
123
- [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1])
124
- }
125
- },
126
- {
127
- type: model.ValueType.Int,
128
- name: "index",
129
- annotations: {
130
- [model.Annotation.Label]: "Int axis"
131
- }
132
- }
133
- ]
134
- },
135
- data: times(rowCount, (i) => {
136
- const v = i + 1;
137
- return {
138
- key: [makePartitionId(rowCount, v), v],
139
- val: v + 0.1
140
- };
141
- })
142
- },
143
- {
144
- id: "labelColumn",
145
- spec: {
146
- kind: "PColumn",
147
- valueType: model.ValueType.Int,
148
- name: model.PColumnName.Label,
149
- annotations: {
150
- [model.Annotation.Label]: "Int axis labels"
113
+ {
114
+ id: 'column2',
115
+ spec: {
116
+ kind: 'PColumn',
117
+ valueType: model.ValueType.Float,
118
+ name: 'value',
119
+ annotations: {
120
+ [model.Annotation.Label]: 'Float column',
121
+ [model.Annotation.Table.Visibility]: 'optional',
122
+ [model.Annotation.Table.OrderPriority]: model.stringifyJson(100),
123
+ },
124
+ axesSpec: [
125
+ {
126
+ type: model.ValueType.Int,
127
+ name: 'part',
128
+ annotations: {
129
+ [model.Annotation.Label]: 'Partitioned axis',
130
+ [model.Annotation.DiscreteValues]: model.stringifyJson([0, 1]),
131
+ },
132
+ },
133
+ {
134
+ type: model.ValueType.Int,
135
+ name: 'index',
136
+ annotations: {
137
+ [model.Annotation.Label]: 'Int axis',
138
+ },
139
+ },
140
+ ],
141
+ },
142
+ data: times(rowCount, (i) => {
143
+ const v = i + 1;
144
+ return {
145
+ key: [makePartitionId(rowCount, v), v],
146
+ val: v + 0.1,
147
+ };
148
+ }),
151
149
  },
152
- axesSpec: [
153
- {
154
- type: model.ValueType.Int,
155
- name: "index",
156
- annotations: {
157
- [model.Annotation.Label]: "Int axis"
158
- }
159
- }
160
- ]
161
- },
162
- data: times(rowCount, (i) => {
163
- const v = i + 1;
164
- return {
165
- key: [v],
166
- val: 1e5 - v
167
- };
168
- })
169
- },
170
- {
171
- id: "linkerColumn",
172
- spec: {
173
- kind: "PColumn",
174
- valueType: model.ValueType.Int,
175
- name: "linker",
176
- annotations: {
177
- [model.Annotation.Label]: "Index axis linker",
178
- [model.Annotation.IsLinkerColumn]: model.stringifyJson(true),
179
- [model.Annotation.Table.Visibility]: "hidden"
150
+ {
151
+ id: 'labelColumn',
152
+ spec: {
153
+ kind: 'PColumn',
154
+ valueType: model.ValueType.Int,
155
+ name: model.PColumnName.Label,
156
+ annotations: {
157
+ [model.Annotation.Label]: 'Int axis labels',
158
+ },
159
+ axesSpec: [
160
+ {
161
+ type: model.ValueType.Int,
162
+ name: 'index',
163
+ annotations: {
164
+ [model.Annotation.Label]: 'Int axis',
165
+ },
166
+ },
167
+ ],
168
+ },
169
+ data: times(rowCount, (i) => {
170
+ const v = i + 1;
171
+ return {
172
+ key: [v],
173
+ val: 100000 - v,
174
+ };
175
+ }),
180
176
  },
181
- axesSpec: [
182
- {
183
- type: model.ValueType.Int,
184
- name: "index",
185
- annotations: {
186
- [model.Annotation.Label]: "Int axis"
187
- }
188
- },
189
- {
190
- type: model.ValueType.Int,
191
- name: "linkedIndex",
192
- annotations: {
193
- [model.Annotation.Label]: "Linked int axis"
194
- }
195
- }
196
- ]
197
- },
198
- data: times(rowCount, (i) => {
199
- const v = i + 1;
200
- return {
201
- key: [v, v],
202
- val: 1
203
- };
204
- })
205
- }
206
- ];
207
- for (let j = 1; j < 10; ++j) {
208
- columns.push({
209
- id: `alphabeticalColumn${j}`,
210
- spec: {
211
- kind: "PColumn",
212
- valueType: model.ValueType.String,
213
- name: "value",
214
- annotations: {
215
- [model.Annotation.Label]: `Alphabetical column ${j}`,
216
- [model.Annotation.Table.Visibility]: "optional",
217
- [model.Annotation.Table.OrderPriority]: model.stringifyJson(10 - j)
177
+ {
178
+ id: 'linkerColumn',
179
+ spec: {
180
+ kind: 'PColumn',
181
+ valueType: model.ValueType.Int,
182
+ name: 'linker',
183
+ annotations: {
184
+ [model.Annotation.Label]: 'Index axis linker',
185
+ [model.Annotation.IsLinkerColumn]: model.stringifyJson(true),
186
+ [model.Annotation.Table.Visibility]: 'hidden',
187
+ },
188
+ axesSpec: [
189
+ {
190
+ type: model.ValueType.Int,
191
+ name: 'index',
192
+ annotations: {
193
+ [model.Annotation.Label]: 'Int axis',
194
+ },
195
+ },
196
+ {
197
+ type: model.ValueType.Int,
198
+ name: 'linkedIndex',
199
+ annotations: {
200
+ [model.Annotation.Label]: 'Linked int axis',
201
+ },
202
+ },
203
+ ],
204
+ },
205
+ data: times(rowCount, (i) => {
206
+ const v = i + 1;
207
+ return {
208
+ key: [v, v],
209
+ val: 1,
210
+ };
211
+ }),
218
212
  },
219
- axesSpec: [
220
- {
221
- type: model.ValueType.Int,
222
- name: "linkedIndex",
223
- annotations: {
224
- [model.Annotation.Label]: "Linked int axis"
225
- }
226
- }
227
- ]
228
- },
229
- data: times(rowCount, (i) => {
230
- const v = i + 1;
231
- return {
232
- key: [v],
233
- val: v.toString().repeat(j)
234
- };
235
- })
236
- });
237
- }
238
- return model.createPlDataTableV2(
239
- ctx,
240
- columns,
241
- ctx.uiState.dataTableV2.state
242
- );
243
- }).title((ctx) => {
244
- if (ctx.args.numbers.length === 5) {
245
- throw new Error("block title: test error");
246
- }
247
- return "Ui Examples";
248
- }).sections((ctx) => {
249
- const dynamicSections = (ctx.uiState.dynamicSections ?? []).map((it) => ({
250
- type: "link",
251
- href: `/section?id=${it.id}`,
252
- label: it.label
253
- }));
254
- if (dynamicSections.some((it) => it.label === "Error")) {
255
- throw new Error("sections: test error");
256
- }
257
- return [
258
- { type: "link", href: "/loaders", label: "Loaders" },
259
- { type: "link", href: "/", label: "Icons/Masks" },
260
- { type: "link", href: "/state", label: "State" },
261
- { type: "link", href: "/layout", label: "Layout" },
262
- { type: "link", href: "/form-components", label: "Form Components" },
263
- { type: "link", href: "/log-view", label: "PlLogView" },
264
- { type: "link", href: "/modals", label: "Modals" },
265
- { type: "link", href: "/select-files", label: "Select Files" },
266
- { type: "link", href: "/inject-env", label: "Inject env" },
267
- { type: "link", href: "/use-watch-fetch", label: "useWatchFetch" },
268
- { type: "link", href: "/typography", label: "Typography" },
269
- { type: "link", href: "/ag-grid-vue", label: "AgGridVue" },
270
- { type: "link", href: "/ag-grid-vue-with-builder", label: "AgGridVue with builder" },
271
- { type: "link", href: "/pl-ag-data-table-v2", label: "PlAgDataTableV2" },
272
- { type: "link", href: "/pl-splash-page", label: "PlSplashPage" },
273
- { type: "link", href: "/pl-file-input-page", label: "PlFileInputPage" },
274
- { type: "link", href: "/pl-number-field-page", label: "PlNumberFieldPage" },
275
- { type: "link", href: "/pl-error-boundary-page", label: "PlErrorBoundaryPage" },
276
- { type: "link", href: "/pl-element-list-page", label: "PlElementList" },
277
- { type: "link", href: "/text-fields", label: "PlTextField" },
278
- { type: "link", href: "/tabs", label: "PlTabs" },
279
- { type: "link", href: "/pl-autocomplete", label: "PlAutocomplete" },
280
- { type: "link", href: "/radio", label: "PlRadio" },
281
- { type: "link", href: "/stacked-bar", label: "PlChartStackedBar" },
282
- { type: "link", href: "/histogram", label: "PlChartHistogram" },
283
- { type: "link", href: "/buttons", label: "ButtonsPage" },
284
- { type: "link", href: "/errors", label: "Errors" },
285
- { type: "link", href: "/downloads", label: "Downloads" },
286
- { type: "link", href: "/notifications", label: "Notifications" },
287
- { type: "link", href: "/drafts", label: "Drafts" },
288
- ...dynamicSections.length ? [
289
- { type: "delimiter" },
290
- ...dynamicSections,
291
- { type: "delimiter" }
292
- ] : [],
293
- {
294
- type: "link",
295
- href: "/add-section",
296
- appearance: "add-section",
297
- label: "New Dynamic section"
213
+ ];
214
+ for (let j = 1; j < 10; ++j) {
215
+ columns.push({
216
+ id: `alphabeticalColumn${j}`,
217
+ spec: {
218
+ kind: 'PColumn',
219
+ valueType: model.ValueType.String,
220
+ name: 'value',
221
+ annotations: {
222
+ [model.Annotation.Label]: `Alphabetical column ${j}`,
223
+ [model.Annotation.Table.Visibility]: 'optional',
224
+ [model.Annotation.Table.OrderPriority]: model.stringifyJson(10 - j),
225
+ },
226
+ axesSpec: [
227
+ {
228
+ type: model.ValueType.Int,
229
+ name: 'linkedIndex',
230
+ annotations: {
231
+ [model.Annotation.Label]: 'Linked int axis',
232
+ },
233
+ },
234
+ ],
235
+ },
236
+ data: times(rowCount, (i) => {
237
+ const v = i + 1;
238
+ return {
239
+ key: [v],
240
+ val: v.toString().repeat(j),
241
+ };
242
+ }),
243
+ });
244
+ }
245
+ return model.createPlDataTableV2(ctx, columns, ctx.uiState.dataTableV2.state);
246
+ })
247
+ .title((ctx) => {
248
+ if (ctx.args.numbers.length === 5) {
249
+ throw new Error('block title: test error');
298
250
  }
299
- ];
300
- }).done(2);
251
+ return 'Ui Examples';
252
+ })
253
+ .sections((ctx) => {
254
+ const dynamicSections = (ctx.uiState.dynamicSections ?? []).map((it) => ({
255
+ type: 'link',
256
+ href: `/section?id=${it.id}`,
257
+ label: it.label,
258
+ }));
259
+ if (dynamicSections.some((it) => it.label === 'Error')) {
260
+ throw new Error('sections: test error');
261
+ }
262
+ return [
263
+ { type: 'link', href: '/loaders', label: 'Loaders' },
264
+ { type: 'link', href: '/', label: 'Icons/Masks' },
265
+ { type: 'link', href: '/state', label: 'State' },
266
+ { type: 'link', href: '/layout', label: 'Layout' },
267
+ { type: 'link', href: '/form-components', label: 'Form Components' },
268
+ { type: 'link', href: '/log-view', label: 'PlLogView' },
269
+ { type: 'link', href: '/modals', label: 'Modals' },
270
+ { type: 'link', href: '/select-files', label: 'Select Files' },
271
+ { type: 'link', href: '/inject-env', label: 'Inject env' },
272
+ { type: 'link', href: '/use-watch-fetch', label: 'useWatchFetch' },
273
+ { type: 'link', href: '/typography', label: 'Typography' },
274
+ { type: 'link', href: '/ag-grid-vue', label: 'AgGridVue' },
275
+ { type: 'link', href: '/ag-grid-vue-with-builder', label: 'AgGridVue with builder' },
276
+ { type: 'link', href: '/pl-ag-data-table-v2', label: 'PlAgDataTableV2' },
277
+ { type: 'link', href: '/pl-splash-page', label: 'PlSplashPage' },
278
+ { type: 'link', href: '/pl-file-input-page', label: 'PlFileInputPage' },
279
+ { type: 'link', href: '/pl-number-field-page', label: 'PlNumberFieldPage' },
280
+ { type: 'link', href: '/pl-error-boundary-page', label: 'PlErrorBoundaryPage' },
281
+ { type: 'link', href: '/pl-element-list-page', label: 'PlElementList' },
282
+ { type: 'link', href: '/text-fields', label: 'PlTextField' },
283
+ { type: 'link', href: '/tabs', label: 'PlTabs' },
284
+ { type: 'link', href: '/pl-autocomplete', label: 'PlAutocomplete' },
285
+ { type: 'link', href: '/radio', label: 'PlRadio' },
286
+ { type: 'link', href: '/stacked-bar', label: 'PlChartStackedBar' },
287
+ { type: 'link', href: '/histogram', label: 'PlChartHistogram' },
288
+ { type: 'link', href: '/buttons', label: 'ButtonsPage' },
289
+ { type: 'link', href: '/errors', label: 'Errors' },
290
+ { type: 'link', href: '/downloads', label: 'Downloads' },
291
+ { type: 'link', href: '/notifications', label: 'Notifications' },
292
+ { type: 'link', href: '/drafts', label: 'Drafts' },
293
+ { type: 'link', href: '/pl-autocomplete', label: 'PlAutocomplete' },
294
+ { type: 'link', href: '/pl-autocomplete-multi', label: 'PlAutocompleteMulti' },
295
+ { type: 'link', href: '/radio', label: 'PlRadio' },
296
+ ...(dynamicSections.length
297
+ ? [
298
+ { type: 'delimiter' },
299
+ ...dynamicSections,
300
+ { type: 'delimiter' }
301
+ ]
302
+ : []),
303
+ {
304
+ type: 'link',
305
+ href: '/add-section',
306
+ appearance: 'add-section',
307
+ label: 'New Dynamic section',
308
+ },
309
+ ];
310
+ })
311
+ .done(); // api version 2
301
312
 
302
313
  exports.$BlockArgs = $BlockArgs;
303
314
  exports.ImportFileHandleSchema = ImportFileHandleSchema;
@@ -306,4 +317,3 @@ exports.range = range;
306
317
  exports.times = times;
307
318
  exports.toList = toList;
308
319
  //# sourceMappingURL=index.cjs.map
309
- //# sourceMappingURL=index.cjs.map