@milaboratories/milaboratories.ui-examples.ui 1.3.32 → 1.3.33

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.html CHANGED
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta http-equiv="Content-Security-Policy" content="script-src 'self' blob:">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <script type="module" crossorigin src="./assets/index-C4q4aF0W.js"></script>
8
- <link rel="stylesheet" crossorigin href="./assets/index-DUhLA4Sp.css">
7
+ <script type="module" crossorigin src="./assets/index-Dx2p5uyS.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-ObHJBe-Q.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/milaboratories.ui-examples.ui",
3
- "version": "1.3.32",
3
+ "version": "1.3.33",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "vue": "^3.5.13",
@@ -17,8 +17,8 @@
17
17
  "ag-grid-enterprise": "^33.0.4",
18
18
  "ag-grid-vue3": "^33.0.4",
19
19
  "rollup-plugin-sourcemaps2": "^0.4.3",
20
- "@platforma-sdk/ui-vue": "^1.22.30",
21
- "@milaboratories/helpers": "^1.6.11"
20
+ "@milaboratories/helpers": "^1.6.11",
21
+ "@platforma-sdk/ui-vue": "^1.22.39"
22
22
  },
23
23
  "scripts": {
24
24
  "dev": "vite",
package/src/app.ts CHANGED
@@ -6,7 +6,7 @@ import ModalsPage from './pages/ModalsPage.vue';
6
6
  import InjectEnvPage from './pages/InjectEnvPage.vue';
7
7
  import UseWatchFetchPage from './pages/UseWatchFetchPage.vue';
8
8
  import TypographyPage from './pages/TypographyPage.vue';
9
- import AgGridVuePage from './pages/AgGridVuePage.vue';
9
+ import { AgGridVuePage } from './pages/AgGridVuePage';
10
10
  import SelectFilesPage from './pages/SelectFilesPage.vue';
11
11
  import ErrorsPage from './pages/ErrorsPage.vue';
12
12
  import PlAgDataTablePage from './pages/PlAgDataTablePage.vue';
@@ -0,0 +1,295 @@
1
+ <script setup lang="ts">
2
+ import type { Component } from 'vue';
3
+ import { computed, h, ref } from 'vue';
4
+ import {
5
+ PlBlockPage,
6
+ PlAgDataTableToolsPanel,
7
+ PlAgGridColumnManager,
8
+ makeRowNumberColDef,
9
+ PlAgCellFile,
10
+ PlAgTextAndButtonCell,
11
+ PlAgColumnHeader,
12
+ type PlAgHeaderComponentParams,
13
+ PlAgCsvExporter,
14
+ PlAgCellProgress,
15
+ defaultMainMenuItems,
16
+ PlAgChartStackedBarCell,
17
+ PlAgChartHistogramCell,
18
+ PlCheckbox,
19
+ PlRow,
20
+ useAgGridOptionsSimple,
21
+ makeEaseOut,
22
+ animate,
23
+ PlBtnPrimary,
24
+ createAgGridColDef,
25
+ } from '@platforma-sdk/ui-vue';
26
+ import { AgGridVue } from 'ag-grid-vue3';
27
+ import type { ColDef } from 'ag-grid-enterprise';
28
+ import { times } from '@milaboratories/helpers';
29
+ import { faker } from '@faker-js/faker';
30
+ import { stackedSettings } from './stackedSettings';
31
+ import { histogramSettings } from './histogramSettings';
32
+ import { LinkComponent } from './LinkComponent';
33
+
34
+ type Row = {
35
+ id: number;
36
+ label: string;
37
+ progress: number | undefined;
38
+ stacked_bar: unknown;
39
+ date: Date;
40
+ file: string;
41
+ link: string;
42
+ time: string;
43
+ };
44
+
45
+ function generateData(): Row[] {
46
+ return times(10, (i) => {
47
+ return {
48
+ id: i,
49
+ label: faker.company.buzzNoun(),
50
+ progress: faker.number.int({ min: 24, max: 100 }),
51
+ stacked_bar: (i % 2 === 0) ? stackedSettings.value : undefined,
52
+ date: faker.date.birthdate(),
53
+ file: '',
54
+ link: faker.internet.url(),
55
+ time: `${faker.number.int()} h`,
56
+ };
57
+ });
58
+ }
59
+
60
+ const result = ref(generateData());
61
+
62
+ function showProgress() {
63
+ animate({
64
+ duration: 10000,
65
+ timing: makeEaseOut((t) => t),
66
+ draw: (progress) => {
67
+ result.value.forEach((it) => {
68
+ it.progress = progress * 100;
69
+ });
70
+ },
71
+ });
72
+ }
73
+
74
+ const BlankComponent: Component = {
75
+ props: ['params'],
76
+ setup(props) {
77
+ return () =>
78
+ h('div', { style: `padding: 0 15px` }, props.params.value);
79
+ },
80
+ };
81
+
82
+ const columnDefs = computed<ColDef<Row>[]>(() => {
83
+ return [
84
+ makeRowNumberColDef(),
85
+ createAgGridColDef<Row>({
86
+ colId: 'id',
87
+ field: 'id',
88
+ headerName: 'ID',
89
+ mainMenuItems: defaultMainMenuItems,
90
+ headerComponent: PlAgColumnHeader,
91
+ headerComponentParams: { type: 'Number' } satisfies PlAgHeaderComponentParams,
92
+ }),
93
+ {
94
+ colId: 'label',
95
+ field: 'label',
96
+ pinned: 'left',
97
+ lockPinned: true,
98
+ lockPosition: true,
99
+ headerName: 'Sample label long text for overflow label long text for overflow',
100
+ cellRenderer: 'PlAgTextAndButtonCell',
101
+ headerComponent: PlAgColumnHeader,
102
+ headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
103
+ cellRendererParams: {
104
+ onClick: onClickHandler,
105
+ invokeRowsOnDoubleClick: true,
106
+ },
107
+ },
108
+ createAgGridColDef(({
109
+ colId: 'progress',
110
+ field: 'progress',
111
+ headerName: 'Progress',
112
+ progress: (cellData) => {
113
+ const percent = cellData.data?.progress ?? 0;
114
+
115
+ if (cellData.data?.id === 2) {
116
+ return {
117
+ status: 'not_started',
118
+ error: 'Test Error',
119
+ };
120
+ }
121
+
122
+ if (cellData.data?.id === 3) {
123
+ return {
124
+ status: 'running',
125
+ text: 'Infinite progress',
126
+ };
127
+ }
128
+
129
+ if (percent < 10) {
130
+ return {
131
+ status: 'not_started',
132
+ };
133
+ }
134
+
135
+ if (percent >= 100) {
136
+ return undefined;
137
+ }
138
+
139
+ if (percent > 90) {
140
+ return {
141
+ status: 'done',
142
+ };
143
+ }
144
+
145
+ return {
146
+ status: 'running',
147
+ percent,
148
+ text: `Progress`,
149
+ suffix: `${percent.toFixed(1)}%`,
150
+ };
151
+ },
152
+ cellRendererSelector: (cellData) => {
153
+ return {
154
+ component: BlankComponent,
155
+ params: { value: cellData.value },
156
+ };
157
+ },
158
+ headerComponent: PlAgColumnHeader,
159
+ headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
160
+ })),
161
+ createAgGridColDef<Row>(({
162
+ colId: 'stacked_bar',
163
+ field: 'stacked_bar',
164
+ headerName: 'StackedBar',
165
+ progress: (cellData) => {
166
+ if (cellData.value) {
167
+ return undefined;
168
+ }
169
+
170
+ return {
171
+ status: 'running',
172
+ text: 'Loading data...',
173
+ };
174
+ },
175
+ cellRendererSelector: (cellData) => {
176
+ console.log('cellData.value', cellData.value);
177
+ return {
178
+ component: PlAgChartStackedBarCell,
179
+ params: { value: cellData.value },
180
+ };
181
+ },
182
+ })),
183
+ {
184
+ colId: 'histogram',
185
+ headerName: 'Histogram',
186
+ cellRendererSelector: (cellData) => {
187
+ const value = (cellData.data?.id ?? 0 % 2 === 0)
188
+ ? histogramSettings.value
189
+ : undefined;
190
+ return {
191
+ component: PlAgChartHistogramCell,
192
+ params: { value },
193
+ };
194
+ },
195
+ },
196
+ {
197
+ colId: 'date',
198
+ field: 'date',
199
+ headerName: 'Date',
200
+ headerComponent: PlAgColumnHeader,
201
+ headerComponentParams: { type: 'Date' } satisfies PlAgHeaderComponentParams,
202
+ },
203
+ {
204
+ colId: 'file',
205
+ field: 'file',
206
+ headerName: 'File input',
207
+ cellRenderer: 'PlAgCellFile',
208
+
209
+ headerComponent: PlAgColumnHeader,
210
+ headerComponentParams: { type: 'File' } satisfies PlAgHeaderComponentParams,
211
+ cellStyle: { padding: 0 },
212
+ },
213
+ {
214
+ colId: 'link',
215
+ field: 'link',
216
+ headerName: 'Link',
217
+ headerComponent: PlAgColumnHeader,
218
+ headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
219
+ cellRenderer: 'LinkComponent',
220
+ },
221
+ {
222
+ colId: 'time',
223
+ field: 'time',
224
+ headerName: 'Duration',
225
+ headerComponent: PlAgColumnHeader,
226
+ headerComponentParams: { type: 'Duration' } satisfies PlAgHeaderComponentParams,
227
+ },
228
+ ];
229
+ });
230
+
231
+ function onClickHandler() {
232
+ // will be invoked when invokeRowsOnDoubleClick: false
233
+ console.log('onClickHandler');
234
+ }
235
+
236
+ const isOverlayTransparent = ref(false);
237
+
238
+ const loading = ref(false);
239
+
240
+ const notReady = ref(false);
241
+
242
+ const hasRows = ref(true);
243
+
244
+ const { gridOptions, gridApi } = useAgGridOptionsSimple<Row>(() => {
245
+ return {
246
+ columnDefs: columnDefs.value,
247
+ rowSelection: {
248
+ mode: 'multiRow' as const,
249
+ checkboxes: false,
250
+ headerCheckbox: false,
251
+ },
252
+ loading: loading.value,
253
+ rowData: hasRows.value ? result.value : [],
254
+ onRowDoubleClicked: (e) => {
255
+ console.log('Example "Open" button was clicked', e);
256
+ },
257
+ loadingOverlayComponentParams: {
258
+ notReady: notReady.value,
259
+ overlayType: isOverlayTransparent.value ? 'transparent' : undefined,
260
+ },
261
+ components: {
262
+ PlAgCellProgress,
263
+ LinkComponent,
264
+ PlAgCellFile,
265
+ PlAgTextAndButtonCell,
266
+ },
267
+ };
268
+ });
269
+ </script>
270
+
271
+ <template>
272
+ <PlBlockPage style="max-width: 100%">
273
+ <template #title>AgGridVue</template>
274
+ <template #append>
275
+ <PlRow>
276
+ <PlCheckbox v-model="isOverlayTransparent">Use transparent overlay</PlCheckbox>
277
+ <PlCheckbox v-model="loading">Loading</PlCheckbox>
278
+ <PlCheckbox v-model="notReady">Not Ready</PlCheckbox>
279
+ <PlCheckbox v-model="hasRows">Has rows</PlCheckbox>
280
+ <PlBtnPrimary @click="showProgress">Show progress</PlBtnPrimary>
281
+ </PlRow>
282
+ <PlAgDataTableToolsPanel>
283
+ <PlAgGridColumnManager v-if="gridApi" :api="gridApi" />
284
+ <PlAgCsvExporter v-if="gridApi" :api="gridApi" />
285
+ </PlAgDataTableToolsPanel>
286
+ </template>
287
+
288
+ <pre v-if="false">{{ result }}</pre>
289
+
290
+ <AgGridVue
291
+ :style="{ height: '100%' }"
292
+ v-bind="gridOptions"
293
+ />
294
+ </PlBlockPage>
295
+ </template>
@@ -0,0 +1,10 @@
1
+ import type { Component } from 'vue';
2
+ import { h } from 'vue';
3
+
4
+ export const LinkComponent: Component = {
5
+ props: ['params'],
6
+ setup(props) {
7
+ return () =>
8
+ h('a', { href: props.params.value, style: 'text-decoration: underline' }, props.params.value);
9
+ },
10
+ };
@@ -0,0 +1,13 @@
1
+ import { computed } from 'vue';
2
+ import bins from '../HistogramPage/assets/bins';
3
+
4
+ export const histogramSettings = computed(() => {
5
+ return {
6
+ type: 'log-bins' as const,
7
+ title: 'Predefined bins (log x scale)',
8
+ bins,
9
+ threshold: 19.0,
10
+ yAxisLabel: 'Number of UMIs',
11
+ xAxisLabel: 'Number of reads per UMI',
12
+ };
13
+ });
@@ -0,0 +1 @@
1
+ export { default as AgGridVuePage } from './AgGridVuePage.vue';
@@ -0,0 +1,33 @@
1
+ import { Gradient } from '@platforma-sdk/ui-vue';
2
+ import { computed } from 'vue';
3
+
4
+ const data = [{
5
+ label: 'The best',
6
+ value: 100,
7
+ }, {
8
+ label: 'Good but not great',
9
+ value: 60,
10
+ }, {
11
+ label: 'A little worse',
12
+ value: 40,
13
+ }, {
14
+ label: 'Not good',
15
+ value: 33,
16
+ }, {
17
+ label: 'Awful',
18
+ value: 330,
19
+ }, {
20
+ label: 'Nightmare',
21
+ value: 30,
22
+ }, {
23
+ label: 'Hell',
24
+ value: 30,
25
+ }];
26
+
27
+ export const stackedSettings = computed(() => {
28
+ const colors = Gradient('viridis').split(data.length);
29
+
30
+ return {
31
+ data: data.map((it, i) => ({ ...it, color: colors[i] })),
32
+ };
33
+ });
@@ -1,259 +0,0 @@
1
- <script setup lang="ts">
2
- import type { Component } from 'vue';
3
- import { computed, h, ref } from 'vue';
4
- import {
5
- PlBlockPage,
6
- PlAgDataTableToolsPanel,
7
- PlAgGridColumnManager,
8
- makeRowNumberColDef,
9
- PlAgCellFile,
10
- PlAgTextAndButtonCell,
11
- PlAgColumnHeader,
12
- type PlAgHeaderComponentParams,
13
- PlAgCsvExporter,
14
- PlAgCellProgress,
15
- defaultMainMenuItems,
16
- PlAgChartStackedBarCell,
17
- PlAgChartHistogramCell,
18
- Gradient,
19
- PlCheckbox,
20
- PlRow,
21
- useAgGridOptionsSimple,
22
- } from '@platforma-sdk/ui-vue';
23
- import { AgGridVue } from 'ag-grid-vue3';
24
- import type { ColDef } from 'ag-grid-enterprise';
25
- import { times } from '@milaboratories/helpers';
26
- import { faker } from '@faker-js/faker';
27
- import bins from './HistogramPage/assets/bins';
28
-
29
- const LinkComponent: Component = {
30
- props: ['params'],
31
- setup(props) {
32
- return () =>
33
- h('a', { href: props.params.value, style: 'text-decoration: underline' }, props.params.value);
34
- },
35
- };
36
-
37
- const data = [{
38
- label: 'The best',
39
- value: 100,
40
- }, {
41
- label: 'Good but not great',
42
- value: 60,
43
- }, {
44
- label: 'A little worse',
45
- value: 40,
46
- }, {
47
- label: 'Not good',
48
- value: 33,
49
- }, {
50
- label: 'Awful',
51
- value: 330,
52
- }, {
53
- label: 'Nightmare',
54
- value: 30,
55
- }, {
56
- label: 'Hell',
57
- value: 30,
58
- }];
59
-
60
- const stackedSettings = computed(() => {
61
- const colors = Gradient('viridis').split(data.length);
62
-
63
- return {
64
- data: data.map((it, i) => ({ ...it, color: colors[i] })),
65
- };
66
- });
67
-
68
- const histogramSettings = computed(() => {
69
- return {
70
- type: 'log-bins' as const,
71
- title: 'Predefined bins (log x scale)',
72
- bins,
73
- threshold: 19.0,
74
- yAxisLabel: 'Number of UMIs',
75
- xAxisLabel: 'Number of reads per UMI',
76
- };
77
- });
78
-
79
- const columnDefs: ColDef[] = [
80
- makeRowNumberColDef(),
81
- {
82
- colId: 'id',
83
- field: 'id',
84
- headerName: 'ID',
85
- mainMenuItems: defaultMainMenuItems,
86
- headerComponent: PlAgColumnHeader,
87
- headerComponentParams: { type: 'Number' } satisfies PlAgHeaderComponentParams,
88
- },
89
- {
90
- colId: 'label',
91
- field: 'label',
92
- pinned: 'left',
93
- lockPinned: true,
94
- lockPosition: true,
95
- headerName: 'Sample label long text for overflow label long text for overflow',
96
- cellRenderer: 'PlAgTextAndButtonCell',
97
- headerComponent: PlAgColumnHeader,
98
- headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
99
- cellRendererParams: {
100
- onClick: onClickHandler,
101
- invokeRowsOnDoubleClick: true,
102
- },
103
- },
104
- {
105
- colId: 'progress',
106
- field: 'progress',
107
- headerName: 'Progress',
108
- cellRendererSelector: (cellData) => {
109
- return {
110
- component: PlAgCellProgress,
111
- params: {
112
- progress: cellData.value,
113
- progressString: cellData.value,
114
- step: cellData.value === undefined ? 'Queued' : 'Loading',
115
- stage: cellData.value === undefined ? 'not_started' : 'running',
116
- },
117
- };
118
- },
119
- cellStyle: {
120
- '--ag-cell-horizontal-padding': '0px',
121
- '--ag-cell-vertical-padding': '0px',
122
- },
123
- headerComponent: PlAgColumnHeader,
124
- headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
125
- },
126
- {
127
- colId: 'stacked_bar',
128
- headerName: 'StackedBar',
129
- cellRendererSelector: (_cellData) => {
130
- const value = Math.random() > 0.5
131
- ? stackedSettings.value
132
- : undefined;
133
- return {
134
- component: PlAgChartStackedBarCell,
135
- params: { value },
136
- };
137
- },
138
- },
139
- {
140
- colId: 'histogram',
141
- headerName: 'Histogram',
142
- cellRendererSelector: (_cellData) => {
143
- const value = Math.random() > 0.5
144
- ? histogramSettings.value
145
- : undefined;
146
- return {
147
- component: PlAgChartHistogramCell,
148
- params: { value },
149
- };
150
- },
151
- },
152
- {
153
- colId: 'date',
154
- field: 'date',
155
- headerName: 'Date',
156
- headerComponent: PlAgColumnHeader,
157
- headerComponentParams: { type: 'Date' } satisfies PlAgHeaderComponentParams,
158
- },
159
- {
160
- colId: 'file',
161
- field: 'file',
162
- headerName: 'File input',
163
- cellRenderer: 'PlAgCellFile',
164
-
165
- headerComponent: PlAgColumnHeader,
166
- headerComponentParams: { type: 'File' } satisfies PlAgHeaderComponentParams,
167
- cellStyle: { padding: 0 },
168
- },
169
- {
170
- colId: 'link',
171
- field: 'link',
172
- headerName: 'Link',
173
- headerComponent: PlAgColumnHeader,
174
- headerComponentParams: { type: 'Text' } satisfies PlAgHeaderComponentParams,
175
- cellRenderer: 'LinkComponent',
176
- },
177
- {
178
- colId: 'time',
179
- field: 'time',
180
- headerName: 'Duration',
181
- headerComponent: PlAgColumnHeader,
182
- headerComponentParams: { type: 'Duration' } satisfies PlAgHeaderComponentParams,
183
- },
184
- ];
185
-
186
- const result = times(100, (i) => {
187
- return {
188
- id: faker.number.int(),
189
- label: faker.company.buzzNoun(),
190
- progress: i % 2 === 0 ? undefined : faker.number.int({ min: 24, max: 100 }),
191
- date: faker.date.birthdate(),
192
- file: '',
193
- link: faker.internet.url(),
194
- time: `${faker.number.int()} h`,
195
- };
196
- });
197
-
198
- function onClickHandler() {
199
- // will be invoked when invokeRowsOnDoubleClick: false
200
- console.log('onClickHandler');
201
- }
202
-
203
- const isOverlayTransparent = ref(false);
204
-
205
- const loading = ref(false);
206
-
207
- const notReady = ref(false);
208
-
209
- const hasRows = ref(false);
210
-
211
- const { gridOptions, gridApi } = useAgGridOptionsSimple(() => {
212
- return {
213
- columnDefs,
214
- rowSelection: {
215
- mode: 'multiRow' as const,
216
- checkboxes: false,
217
- headerCheckbox: false,
218
- },
219
- loading: loading.value,
220
- rowData: hasRows.value ? result : [],
221
- onRowDoubleClicked: (e) => {
222
- console.log('Example "Open" button was clicked', e);
223
- },
224
- loadingOverlayComponentParams: {
225
- notReady: notReady.value,
226
- overlayType: isOverlayTransparent.value ? 'transparent' : undefined,
227
- },
228
- components: {
229
- PlAgCellProgress,
230
- LinkComponent,
231
- PlAgCellFile,
232
- PlAgTextAndButtonCell,
233
- },
234
- };
235
- });
236
- </script>
237
-
238
- <template>
239
- <PlBlockPage style="max-width: 100%">
240
- <template #title>AgGridVue</template>
241
- <template #append>
242
- <PlRow>
243
- <PlCheckbox v-model="isOverlayTransparent">Use transparent overlay</PlCheckbox>
244
- <PlCheckbox v-model="loading">Loading</PlCheckbox>
245
- <PlCheckbox v-model="notReady">Not Ready</PlCheckbox>
246
- <PlCheckbox v-model="hasRows">Has rows</PlCheckbox>
247
- </PlRow>
248
- <PlAgDataTableToolsPanel>
249
- <PlAgGridColumnManager v-if="gridApi" :api="gridApi" />
250
- <PlAgCsvExporter v-if="gridApi" :api="gridApi" />
251
- </PlAgDataTableToolsPanel>
252
- </template>
253
-
254
- <AgGridVue
255
- :style="{ height: '100%' }"
256
- v-bind="gridOptions"
257
- />
258
- </PlBlockPage>
259
- </template>