@platforma-sdk/ui-vue 1.18.0 → 1.18.1
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/CHANGELOG.md +6 -0
- package/dist/lib.js +2117 -2084
- package/dist/lib.umd.cjs +22 -22
- package/dist/src/components/PlAgCsvExporter/PlAgCsvExporter.vue.d.ts +7 -0
- package/dist/src/components/PlAgCsvExporter/PlAgCsvExporter.vue.d.ts.map +1 -0
- package/dist/src/components/PlAgCsvExporter/export-csv.d.ts +3 -0
- package/dist/src/components/PlAgCsvExporter/export-csv.d.ts.map +1 -0
- package/dist/src/components/PlAgCsvExporter/index.d.ts +2 -0
- package/dist/src/components/PlAgCsvExporter/index.d.ts.map +1 -0
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts +7 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/index.d.ts +1 -0
- package/dist/src/components/PlAgDataTable/index.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/types.d.ts +0 -2
- package/dist/src/components/PlAgDataTable/types.d.ts.map +1 -1
- package/dist/src/lib.d.ts +2 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/PlAgCsvExporter/PlAgCsvExporter.vue +31 -0
- package/src/components/{PlAgDataTable/sources → PlAgCsvExporter}/export-csv.ts +17 -21
- package/src/components/PlAgCsvExporter/index.ts +1 -0
- package/src/components/PlAgDataTable/PlAgDataTable.vue +9 -2
- package/src/components/PlAgDataTable/index.ts +1 -1
- package/src/components/PlAgDataTable/types.ts +0 -2
- package/src/lib.ts +3 -1
- package/dist/src/components/PlAgDataTable/sources/export-csv.d.ts +0 -4
- package/dist/src/components/PlAgDataTable/sources/export-csv.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/lib.umd.cjs",
|
|
6
6
|
"module": "dist/lib.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@ag-grid-community/theming": "^32.3.3",
|
|
38
38
|
"@ag-grid-enterprise/side-bar": "^32.3.3",
|
|
39
39
|
"@ag-grid-enterprise/column-tool-panel": "^32.3.3",
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
40
|
+
"@platforma-sdk/model": "^1.18.0",
|
|
41
|
+
"@milaboratories/uikit": "^2.2.28"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@faker-js/faker": "^9.2.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"yarpm": "^1.2.0",
|
|
59
59
|
"semver": "^7.6.3",
|
|
60
60
|
"@types/semver": "^7.5.8",
|
|
61
|
-
"@milaboratories/
|
|
62
|
-
"@milaboratories/
|
|
61
|
+
"@milaboratories/eslint-config": "^1.0.0",
|
|
62
|
+
"@milaboratories/helpers": "^1.6.9"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"test": "vitest run --passWithNoTests",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { GridApi } from '@ag-grid-community/core';
|
|
3
|
+
import { PlBtnGhost, PlMaskIcon24 } from '@milaboratories/uikit';
|
|
4
|
+
import { shallowRef, toRefs } from 'vue';
|
|
5
|
+
import { PlAgDataTableToolsPanelId } from '../PlAgDataTableToolsPanel/PlAgDataTableToolsPanelId';
|
|
6
|
+
import { exportCsv } from './export-csv';
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
api: GridApi;
|
|
10
|
+
}>();
|
|
11
|
+
const { api: gridApi } = toRefs(props);
|
|
12
|
+
|
|
13
|
+
const exporting = shallowRef(false);
|
|
14
|
+
const initiateExport = () => {
|
|
15
|
+
exporting.value = true;
|
|
16
|
+
exportCsv(gridApi.value, () => exporting.value = false);
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div>
|
|
22
|
+
<Teleport :to="`#${PlAgDataTableToolsPanelId}`">
|
|
23
|
+
<PlBtnGhost :loading="exporting" @click.stop="initiateExport">
|
|
24
|
+
Export
|
|
25
|
+
<template #append>
|
|
26
|
+
<PlMaskIcon24 name="export" />
|
|
27
|
+
</template>
|
|
28
|
+
</PlBtnGhost>
|
|
29
|
+
</Teleport>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ColDef, ColGroupDef } from '@ag-grid-community/core';
|
|
2
2
|
import { createGrid, type GridApi, type GridOptions } from '@ag-grid-community/core';
|
|
3
|
-
import type { PlAgDataTableRow } from '../types';
|
|
4
3
|
import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';
|
|
5
4
|
|
|
6
5
|
function createGridDiv(): HTMLDivElement {
|
|
@@ -17,22 +16,19 @@ function destroyGridDiv(cellFake: HTMLDivElement) {
|
|
|
17
16
|
document.body.removeChild(cellFake);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export async function exportCsv(gridApi
|
|
21
|
-
if (!gridApi) return;
|
|
22
|
-
|
|
19
|
+
export async function exportCsv(gridApi: GridApi, completed: () => void) {
|
|
23
20
|
const rowModel = gridApi.getGridOption('rowModelType');
|
|
24
21
|
switch (rowModel) {
|
|
25
22
|
case 'clientSide': {
|
|
26
|
-
|
|
23
|
+
gridApi.exportDataAsCsv();
|
|
24
|
+
return completed();
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
case 'serverSide': {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (state.rowCount <= state.cacheBlockSize!) {
|
|
35
|
-
return gridApi.exportDataAsCsv();
|
|
28
|
+
const state = gridApi.getServerSideGroupLevelState();
|
|
29
|
+
if (state.length === 0 || state[0].rowCount <= state[0].cacheBlockSize!) {
|
|
30
|
+
gridApi.exportDataAsCsv();
|
|
31
|
+
return completed();
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
const gridDiv = createGridDiv();
|
|
@@ -47,23 +43,23 @@ export async function exportCsv(gridApi?: GridApi<PlAgDataTableRow>) {
|
|
|
47
43
|
valueGetter: def.valueGetter,
|
|
48
44
|
})) ?? [],
|
|
49
45
|
serverSideDatasource: gridApi.getGridOption('serverSideDatasource'),
|
|
50
|
-
cacheBlockSize: state.rowCount,
|
|
46
|
+
cacheBlockSize: state[0].rowCount,
|
|
51
47
|
onModelUpdated: (event) => {
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
event.api.exportDataAsCsv();
|
|
59
|
-
destroyGridDiv(gridDiv);
|
|
48
|
+
const state = event.api.getServerSideGroupLevelState();
|
|
49
|
+
if (state.length > 0 && state[0].rowCount === state[0].cacheBlockSize) {
|
|
50
|
+
event.api.exportDataAsCsv();
|
|
51
|
+
destroyGridDiv(gridDiv);
|
|
52
|
+
return completed();
|
|
53
|
+
}
|
|
60
54
|
},
|
|
61
55
|
defaultCsvExportParams: gridApi.getGridOption('defaultCsvExportParams'),
|
|
62
56
|
};
|
|
63
57
|
return createGrid(gridDiv, gridOptions, { modules: [ServerSideRowModelModule] });
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
default:
|
|
60
|
+
default: {
|
|
61
|
+
completed();
|
|
67
62
|
throw Error(`exportCsv unsupported for rowModelType = ${rowModel}`);
|
|
63
|
+
}
|
|
68
64
|
}
|
|
69
65
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PlAgCsvExporter } from './PlAgCsvExporter.vue';
|
|
@@ -39,8 +39,8 @@ import { makeRowId, parseColId, updatePFrameGridOptions } from './sources/table-
|
|
|
39
39
|
import type { PlAgDataTableController, PlDataTableSettings, PlAgDataTableRow } from './types';
|
|
40
40
|
import { PlAgGridColumnManager } from '../PlAgGridColumnManager';
|
|
41
41
|
import { autoSizeRowNumberColumn, PlAgDataTableRowNumberColId } from './sources/row-number';
|
|
42
|
-
import { exportCsv } from './sources/export-csv';
|
|
43
42
|
import { focusRow, makeOnceTracker, trackFirstDataRendered } from './sources/focus-row';
|
|
43
|
+
import PlAgCsvExporter from '../PlAgCsvExporter/PlAgCsvExporter.vue';
|
|
44
44
|
|
|
45
45
|
ModuleRegistry.registerModules([
|
|
46
46
|
ClientSideRowModelModule,
|
|
@@ -60,6 +60,13 @@ const props = defineProps<{
|
|
|
60
60
|
* This component serves as the target for teleporting the button.
|
|
61
61
|
*/
|
|
62
62
|
showColumnsPanel?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The showExportButton prop controls the display of a button that allows
|
|
65
|
+
* to export table data in CSV format. To make the button functional
|
|
66
|
+
* and visible, you must also include the PlAgDataTableToolsPanel component in your layout.
|
|
67
|
+
* This component serves as the target for teleporting the button.
|
|
68
|
+
*/
|
|
69
|
+
showExportButton?: boolean;
|
|
63
70
|
showCellButtonForAxisId?: AxisId;
|
|
64
71
|
}>();
|
|
65
72
|
const { settings } = toRefs(props);
|
|
@@ -247,7 +254,6 @@ const onGridPreDestroyed = () => {
|
|
|
247
254
|
};
|
|
248
255
|
|
|
249
256
|
defineExpose<PlAgDataTableController>({
|
|
250
|
-
exportCsv: () => exportCsv(gridApi.value),
|
|
251
257
|
focusRow: (rowKey) => focusRow(makeRowId(rowKey), firstDataRenderedTracker),
|
|
252
258
|
});
|
|
253
259
|
|
|
@@ -376,6 +382,7 @@ watch(
|
|
|
376
382
|
<template>
|
|
377
383
|
<div class="ap-ag-data-table-container">
|
|
378
384
|
<PlAgGridColumnManager v-if="gridApi && showColumnsPanel" :api="gridApi" />
|
|
385
|
+
<PlAgCsvExporter v-if="gridApi && showExportButton" :api="gridApi" />
|
|
379
386
|
<div v-if="settings?.sourceType === 'ptable' && !!settings.sheets && settings.sheets.length > 0" class="ap-ag-data-table-sheets">
|
|
380
387
|
<PlDropdownLine
|
|
381
388
|
v-for="(sheet, i) in settings.sheets"
|
|
@@ -46,8 +46,6 @@ export type PTableRowKey = PTableValue[];
|
|
|
46
46
|
|
|
47
47
|
/** PlAgDataTable controller contains all exported methods */
|
|
48
48
|
export type PlAgDataTableController = {
|
|
49
|
-
/** Export table data as Csv file */
|
|
50
|
-
exportCsv: () => void;
|
|
51
49
|
/** Scroll table to make row with provided key visible */
|
|
52
50
|
focusRow: (rowKey: PTableRowKey) => void;
|
|
53
51
|
};
|
package/src/lib.ts
CHANGED
|
@@ -12,8 +12,10 @@ export * from './components/PlAgColumnHeader';
|
|
|
12
12
|
export * from './components/PlAgCellFile';
|
|
13
13
|
|
|
14
14
|
export * from './components/PlAgDataTable/types';
|
|
15
|
-
|
|
16
15
|
export * from './components/PlAgDataTable/sources/row-number';
|
|
16
|
+
export * from './components/PlAgDataTable/sources/focus-row';
|
|
17
|
+
|
|
18
|
+
export * from './components/PlAgCsvExporter';
|
|
17
19
|
|
|
18
20
|
export * from './components/PlAgTextAndButtonCell';
|
|
19
21
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"export-csv.d.ts","sourceRoot":"","sources":["../../../../../src/components/PlAgDataTable/sources/export-csv.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAiBjD,wBAAsB,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,gCAiDlE"}
|