@platforma-sdk/ui-vue 1.22.51 → 1.22.55
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 +12 -0
- package/dist/lib.js +6955 -6895
- package/dist/lib.js.map +1 -1
- package/dist/lib.umd.cjs +16 -16
- package/dist/lib.umd.cjs.map +1 -1
- package/dist/src/AgGridVue/createAgGridColDef.d.ts +30 -2
- package/dist/src/AgGridVue/createAgGridColDef.d.ts.map +1 -1
- package/dist/src/AgGridVue/index.d.ts +1 -1
- package/dist/src/AgGridVue/index.d.ts.map +1 -1
- package/dist/src/AgGridVue/useAgGridOptions.d.ts +61 -0
- package/dist/src/AgGridVue/useAgGridOptions.d.ts.map +1 -0
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts +17 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgOverlayLoading.vue.d.ts +2 -23
- package/dist/src/components/PlAgDataTable/PlAgOverlayLoading.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgOverlayNoRows.vue.d.ts +6 -1
- package/dist/src/components/PlAgDataTable/PlAgOverlayNoRows.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/sources/row-number.d.ts +1 -1
- package/dist/src/components/PlAgDataTable/sources/row-number.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/types.d.ts +23 -3
- package/dist/src/components/PlAgDataTable/types.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/AgGridVue/createAgGridColDef.ts +53 -4
- package/src/AgGridVue/index.ts +1 -1
- package/src/AgGridVue/useAgGridOptions.ts +167 -0
- package/src/components/PlAgDataTable/PlAgDataTable.vue +24 -8
- package/src/components/PlAgDataTable/PlAgOverlayLoading.vue +5 -24
- package/src/components/PlAgDataTable/PlAgOverlayNoRows.vue +9 -1
- package/src/components/PlAgDataTable/sources/row-number.ts +3 -1
- package/src/components/PlAgDataTable/types.ts +36 -13
- package/dist/src/AgGridVue/useAgGridOptionsSimple.d.ts +0 -22
- package/dist/src/AgGridVue/useAgGridOptionsSimple.d.ts.map +0 -1
- package/src/AgGridVue/useAgGridOptionsSimple.ts +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/lib.umd.cjs",
|
|
6
6
|
"module": "dist/lib.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"canonicalize": "^2.0.0",
|
|
24
24
|
"ag-grid-enterprise": "^33.0.4",
|
|
25
25
|
"ag-grid-vue3": "^33.0.4",
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
26
|
+
"@platforma-sdk/model": "^1.22.18",
|
|
27
|
+
"@milaboratories/uikit": "^2.2.58"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@faker-js/faker": "^9.2.0",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import type { ColDef, ICellRendererParams } from 'ag-grid-enterprise';
|
|
3
3
|
import { PlAgCellProgress } from '../components/PlAgCellProgress';
|
|
4
|
-
import type { PlProgressCellProps } from '@milaboratories/uikit';
|
|
4
|
+
import type { MaskIconName16, PlProgressCellProps } from '@milaboratories/uikit';
|
|
5
5
|
import { tapIf } from '@milaboratories/helpers';
|
|
6
|
+
import type { PlAgHeaderComponentParams } from '../lib';
|
|
7
|
+
import { PlAgColumnHeader } from '../components/PlAgColumnHeader';
|
|
8
|
+
import { PlAgTextAndButtonCell } from '../components/PlAgTextAndButtonCell';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Represents the available progress statuses for a cell.
|
|
@@ -62,7 +65,10 @@ export type ColDefProgress = {
|
|
|
62
65
|
* @returns A {@link ColDefProgress} object to configure the progress overlay,
|
|
63
66
|
* or `undefined` if no progress overlay should be rendered.
|
|
64
67
|
*/
|
|
65
|
-
export type ColDefProgressCallback<TData, TValue = any> = (
|
|
68
|
+
export type ColDefProgressCallback<TData = any, TValue = any> = (
|
|
69
|
+
value: TValue,
|
|
70
|
+
cellData: ICellRendererParams<TData, TValue>
|
|
71
|
+
) => ColDefProgress;
|
|
66
72
|
|
|
67
73
|
/**
|
|
68
74
|
* Extended AG Grid column definition that supports additional properties for
|
|
@@ -74,9 +80,35 @@ export type ColDefProgressCallback<TData, TValue = any> = (cellData: ICellRender
|
|
|
74
80
|
* @property progress - An optional callback to provide progress overlay configuration.
|
|
75
81
|
* @property noGutters - If `true`, removes padding from the cell.
|
|
76
82
|
*/
|
|
77
|
-
export interface ColDefExtended<TData, TValue = any> extends ColDef<TData> {
|
|
83
|
+
export interface ColDefExtended<TData, TValue = any> extends ColDef<TData, TValue> {
|
|
78
84
|
progress?: ColDefProgressCallback<TData, TValue>;
|
|
79
85
|
noGutters?: boolean;
|
|
86
|
+
headerComponentParams?: PlAgHeaderComponentParams;
|
|
87
|
+
textWithButton?: true | {
|
|
88
|
+
/**
|
|
89
|
+
* Button icon MaskIconName16
|
|
90
|
+
*/
|
|
91
|
+
icon?: MaskIconName16;
|
|
92
|
+
/**
|
|
93
|
+
* Button label
|
|
94
|
+
*/
|
|
95
|
+
btnLabel?: string;
|
|
96
|
+
/**
|
|
97
|
+
* If invokeRowsOnDoubleClick = true, clicking a button inside the row
|
|
98
|
+
* triggers the doubleClick event for the entire row. In this case,
|
|
99
|
+
* the handler passed to the component is not called, even if it is defined.
|
|
100
|
+
*
|
|
101
|
+
* If invokeRowsOnDoubleClick = false, the doubleClick event for the row
|
|
102
|
+
* is not triggered, but the provided handler will be called, receiving
|
|
103
|
+
* the ICellRendererParams as an argument.
|
|
104
|
+
*/
|
|
105
|
+
invokeRowsOnDoubleClick?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* plHandler parameter is a click handler that is invoked when
|
|
108
|
+
* the invokeRowsOnDoubleClick property is set to false.
|
|
109
|
+
*/
|
|
110
|
+
onClick?: (params: ICellRendererParams) => void;
|
|
111
|
+
};
|
|
80
112
|
}
|
|
81
113
|
|
|
82
114
|
/**
|
|
@@ -127,7 +159,7 @@ function handleProgress<TData>(def: ColDefExtended<TData>) {
|
|
|
127
159
|
def.cellStyle = Object.assign({}, def.cellStyle ?? {}, noGuttersStyle());
|
|
128
160
|
|
|
129
161
|
def.cellRendererSelector = (cellData) => {
|
|
130
|
-
const pt = progress(cellData);
|
|
162
|
+
const pt = progress(cellData.value, cellData);
|
|
131
163
|
|
|
132
164
|
if (!pt) {
|
|
133
165
|
return cellRendererSelector?.(cellData);
|
|
@@ -164,6 +196,23 @@ export function createAgGridColDef<TData, TValue = any>(def: ColDefExtended<TDat
|
|
|
164
196
|
def.cellStyle = Object.assign({}, def.cellStyle ?? {}, noGuttersStyle());
|
|
165
197
|
}
|
|
166
198
|
|
|
199
|
+
if (def.headerComponentParams) {
|
|
200
|
+
def.headerComponent = PlAgColumnHeader;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (def.textWithButton) {
|
|
204
|
+
def.cellRenderer = PlAgTextAndButtonCell;
|
|
205
|
+
if (typeof def.textWithButton !== 'boolean') {
|
|
206
|
+
def.cellRendererParams = def.textWithButton;
|
|
207
|
+
} else {
|
|
208
|
+
def.cellRendererParams = {
|
|
209
|
+
invokeRowsOnDoubleClick: true,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
delete def.textWithButton;
|
|
215
|
+
|
|
167
216
|
delete def.progress;
|
|
168
217
|
|
|
169
218
|
delete def.noGutters;
|
package/src/AgGridVue/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './useAgGridOptions';
|
|
2
2
|
export * from './createAgGridColDef';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type { ColGroupDef, GridApi, GridOptions, GridReadyEvent } from 'ag-grid-enterprise';
|
|
3
|
+
import { computed, shallowRef, watch } from 'vue';
|
|
4
|
+
import { AgGridTheme } from '../aggrid';
|
|
5
|
+
import PlAgOverlayLoading from '../components/PlAgDataTable/PlAgOverlayLoading.vue';
|
|
6
|
+
import PlAgOverlayNoRows from '../components/PlAgDataTable/PlAgOverlayNoRows.vue';
|
|
7
|
+
import type { ColDefExtended } from './createAgGridColDef';
|
|
8
|
+
import type { PlAgOverlayLoadingParams } from '../lib';
|
|
9
|
+
import { autoSizeRowNumberColumn, createAgGridColDef, makeRowNumberColDef } from '../lib';
|
|
10
|
+
import { whenever } from '@vueuse/core';
|
|
11
|
+
import PlAgCellFile from '../components/PlAgCellFile/PlAgCellFile.vue';
|
|
12
|
+
|
|
13
|
+
interface GridOptionsExtended<TData = any> extends Omit<GridOptions<TData>, 'columnDefs'> {
|
|
14
|
+
/**
|
|
15
|
+
* Array of Column / Column Group definitions.
|
|
16
|
+
*/
|
|
17
|
+
columnDefs?: (ColDefExtended<TData> | ColGroupDef<TData>)[] | null;
|
|
18
|
+
/**
|
|
19
|
+
* Show row numbers column
|
|
20
|
+
*/
|
|
21
|
+
rowNumbersColumn?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Not ready overlay (No datasource). Takes priority over "loading"
|
|
24
|
+
*/
|
|
25
|
+
notReady?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* "No datasource" by default
|
|
28
|
+
*/
|
|
29
|
+
notReadyText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Use "transparent" to make table headers visible below the loading layer (experimental)
|
|
32
|
+
*/
|
|
33
|
+
loadingOverlayType?: 'transparent';
|
|
34
|
+
/**
|
|
35
|
+
* Override standard 'Empty' text for the "no rows" overlay
|
|
36
|
+
*/
|
|
37
|
+
noRowsText?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// @TODO (super simple builder for now)
|
|
41
|
+
class Builder<TData> {
|
|
42
|
+
#options: GridOptionsExtended<TData> = {};
|
|
43
|
+
|
|
44
|
+
public options(options: GridOptionsExtended<TData>) {
|
|
45
|
+
this.#options = Object.assign({}, this.#options, options);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get columnDefs() {
|
|
50
|
+
return this.#options.columnDefs ?? [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public column<TValue = any>(def: ColDefExtended<TData, TValue>) {
|
|
54
|
+
this.#options.columnDefs = [...this.columnDefs, def];
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public build() {
|
|
59
|
+
return this.#options;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Simple helper to use like column<string> in grid options literal
|
|
64
|
+
type ColumnFunc<TData> = <TValue>(def: ColDefExtended<TData, TValue>) => ColDefExtended<TData, TValue>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns a set of Ag Grid options along with a reference to the Ag Grid API.
|
|
68
|
+
* (This is a fast prototype)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const { gridOptions, gridApi } = useAgGridOptions(() => ({
|
|
73
|
+
* // custom grid options here
|
|
74
|
+
* }));
|
|
75
|
+
*
|
|
76
|
+
* // Usage in a template (v-bind is required!)
|
|
77
|
+
* <template>
|
|
78
|
+
* <AgGridVue :style="{ height: '100%' }" v-bind="gridOptions" />
|
|
79
|
+
* </template>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function useAgGridOptions<TData>(
|
|
83
|
+
factory: (context: { builder: Builder<TData>; column: ColumnFunc<TData> }) => Builder<TData> | GridOptionsExtended<TData>,
|
|
84
|
+
) {
|
|
85
|
+
const gridApi = shallowRef<GridApi>();
|
|
86
|
+
|
|
87
|
+
const gridOptions = computed<GridOptionsExtended>(() => {
|
|
88
|
+
const def: GridOptionsExtended<TData> = {
|
|
89
|
+
theme: AgGridTheme,
|
|
90
|
+
loadingOverlayComponent: PlAgOverlayLoading,
|
|
91
|
+
noRowsOverlayComponent: PlAgOverlayNoRows,
|
|
92
|
+
onGridReady: (e: GridReadyEvent) => {
|
|
93
|
+
gridApi.value = e.api;
|
|
94
|
+
autoSizeRowNumberColumn(e.api); // @TODO
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const column = <TValue>(def: ColDefExtended<TData, TValue>) => {
|
|
99
|
+
return def;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const result = factory({ builder: new Builder(), column });
|
|
103
|
+
|
|
104
|
+
const options = Object.assign({}, def, result instanceof Builder ? result.build() : result);
|
|
105
|
+
|
|
106
|
+
if (options.rowNumbersColumn) {
|
|
107
|
+
options.columnDefs = [makeRowNumberColDef(), ...(options.columnDefs ?? [])];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (options.noRowsText) {
|
|
111
|
+
options.noRowsOverlayComponentParams = {
|
|
112
|
+
text: options.noRowsText,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
options.loading = options.notReady || options.loading;
|
|
117
|
+
|
|
118
|
+
// @TODO
|
|
119
|
+
if (options.loading) {
|
|
120
|
+
options.loadingOverlayComponentParams = {
|
|
121
|
+
notReady: options.notReady,
|
|
122
|
+
notReadyText: options.notReadyText,
|
|
123
|
+
overlayType: options.loadingOverlayType,
|
|
124
|
+
} satisfies PlAgOverlayLoadingParams;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
options.columnDefs = options.columnDefs?.map((it) => createAgGridColDef(it));
|
|
128
|
+
|
|
129
|
+
// Register all special components
|
|
130
|
+
options.components = Object.assign({}, options.components ?? {}, {
|
|
131
|
+
PlAgCellFile,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return options;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
whenever(() => gridOptions.value.rowNumbersColumn, () => {
|
|
138
|
+
if (gridApi.value) {
|
|
139
|
+
autoSizeRowNumberColumn(gridApi.value);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
watch([
|
|
144
|
+
() => gridOptions.value.notReady,
|
|
145
|
+
() => gridOptions.value.loading,
|
|
146
|
+
], ([notReady, loading]) => {
|
|
147
|
+
const loadingOverlayComponentParams = {
|
|
148
|
+
notReady,
|
|
149
|
+
// we probably don't need to update the parameters below
|
|
150
|
+
notReadyText: gridOptions.value.notReadyText,
|
|
151
|
+
overlayType: gridOptions.value.loadingOverlayType,
|
|
152
|
+
} satisfies PlAgOverlayLoadingParams;
|
|
153
|
+
|
|
154
|
+
// Hack to apply loadingOverlayComponentParams
|
|
155
|
+
gridApi.value?.updateGridOptions({
|
|
156
|
+
loading: !loading,
|
|
157
|
+
loadingOverlayComponentParams,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
gridApi.value?.updateGridOptions({
|
|
161
|
+
loading,
|
|
162
|
+
loadingOverlayComponentParams,
|
|
163
|
+
});
|
|
164
|
+
}, { deep: true, immediate: true });
|
|
165
|
+
|
|
166
|
+
return { gridOptions, gridApi };
|
|
167
|
+
};
|
|
@@ -36,7 +36,7 @@ import PlOverlayLoading from './PlAgOverlayLoading.vue';
|
|
|
36
36
|
import PlOverlayNoRows from './PlAgOverlayNoRows.vue';
|
|
37
37
|
import { updateXsvGridOptions } from './sources/file-source';
|
|
38
38
|
import { makeRowId, parseColId, updatePFrameGridOptions } from './sources/table-source';
|
|
39
|
-
import type { PlAgDataTableController, PlDataTableSettings, PlAgDataTableRow, PTableRowKey } from './types';
|
|
39
|
+
import type { PlAgDataTableController, PlDataTableSettings, PlAgDataTableRow, PTableRowKey, PlDataTableSettingsPTable } from './types';
|
|
40
40
|
import { PlAgGridColumnManager } from '../PlAgGridColumnManager';
|
|
41
41
|
import { autoSizeRowNumberColumn, PlAgDataTableRowNumberColId } from './sources/row-number';
|
|
42
42
|
import { focusRow, makeOnceTracker, trackFirstDataRendered } from './sources/focus-row';
|
|
@@ -180,6 +180,14 @@ const sheetsState = computed({
|
|
|
180
180
|
},
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
+
const hasSheets = (
|
|
184
|
+
settings?: Readonly<PlDataTableSettings>,
|
|
185
|
+
): settings is PlDataTableSettingsPTable => {
|
|
186
|
+
return settings?.sourceType === 'ptable'
|
|
187
|
+
&& !!settings.sheets
|
|
188
|
+
&& settings.sheets.length > 0;
|
|
189
|
+
};
|
|
190
|
+
|
|
183
191
|
watch(
|
|
184
192
|
() => settings.value,
|
|
185
193
|
(settings, oldSettings) => {
|
|
@@ -460,15 +468,23 @@ watch(
|
|
|
460
468
|
<PlAgGridColumnManager v-if="gridApi && showColumnsPanel" :api="gridApi" :width="columnsPanelWidth" />
|
|
461
469
|
<PlAgCsvExporter v-if="gridApi && showExportButton" :api="gridApi" />
|
|
462
470
|
<div
|
|
463
|
-
v-if="settings
|
|
471
|
+
v-if="hasSheets(settings) || $slots['before-sheets'] || $slots['after-sheets']"
|
|
464
472
|
class="ap-ag-data-table-sheets"
|
|
465
473
|
>
|
|
466
|
-
<
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
474
|
+
<slot name="before-sheets" />
|
|
475
|
+
<template
|
|
476
|
+
v-if="hasSheets(settings)"
|
|
477
|
+
>
|
|
478
|
+
<PlDropdownLine
|
|
479
|
+
v-for="(sheet, i) in settings.sheets"
|
|
480
|
+
:key="i"
|
|
481
|
+
:model-value="sheetsState[makeSheetId(sheet.axis)]"
|
|
482
|
+
:options="sheet.options"
|
|
483
|
+
:prefix="(sheet.axis.annotations?.['pl7.app/label']?.trim() ?? `Unlabeled axis ${i}`) + ':'"
|
|
484
|
+
@update:model-value="(newValue) => onSheetChanged(makeSheetId(sheet.axis), newValue)"
|
|
485
|
+
/>
|
|
486
|
+
</template>
|
|
487
|
+
<slot name="after-sheets" />
|
|
472
488
|
</div>
|
|
473
489
|
<AgGridVue
|
|
474
490
|
:key="reloadKey" :theme="AgGridTheme" class="ap-ag-data-table-grid" :grid-options="gridOptions"
|
|
@@ -1,34 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import style from './pl-ag-overlay-loading.module.scss';
|
|
3
3
|
import { PlSplash } from '@milaboratories/uikit';
|
|
4
|
+
import type { PlAgOverlayLoadingParams } from './types';
|
|
5
|
+
|
|
6
|
+
// @TODO move this component from this folder
|
|
4
7
|
|
|
5
8
|
defineProps<{
|
|
6
9
|
/**
|
|
7
10
|
* Required object that contains props from loadingOverlayComponentParams.
|
|
8
11
|
*/
|
|
9
|
-
params:
|
|
10
|
-
/**
|
|
11
|
-
* Required flag, that shows catInBag icon with message if `true`, shows PlSplash component if `false`.
|
|
12
|
-
*/
|
|
13
|
-
notReady: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Prop to override default "Loading" text
|
|
16
|
-
*/
|
|
17
|
-
loadingText?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Prop to override default "No datasource" text (So why props name is notReady? Good question)
|
|
20
|
-
*/
|
|
21
|
-
notReadyText?: string;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated
|
|
24
|
-
* Use notReadyText
|
|
25
|
-
*/
|
|
26
|
-
message?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Use "transparent" to make table headers visible below the loading layer
|
|
29
|
-
*/
|
|
30
|
-
overlayType?: 'transparent';
|
|
31
|
-
};
|
|
12
|
+
params: PlAgOverlayLoadingParams;
|
|
32
13
|
}>();
|
|
33
14
|
</script>
|
|
34
15
|
|
|
@@ -41,7 +22,7 @@ defineProps<{
|
|
|
41
22
|
>
|
|
42
23
|
<div v-if="params.notReady" :class="style.notReadyWrapper">
|
|
43
24
|
<div :class="style.iconCatInBag" />
|
|
44
|
-
<h3 :class="style.text">{{ params.notReadyText ||
|
|
25
|
+
<h3 :class="style.text">{{ params.notReadyText || 'No datasource' }}</h3>
|
|
45
26
|
</div>
|
|
46
27
|
</PlSplash>
|
|
47
28
|
</template>
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
defineProps<{
|
|
3
|
+
params: {
|
|
4
|
+
text?: string;
|
|
5
|
+
};
|
|
6
|
+
}>();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<template>
|
|
2
10
|
<div class="grid-overlay-container">
|
|
3
11
|
<div class="grid-icon-sad-cat" />
|
|
4
|
-
<span class="text-subtitle-m">Empty</span>
|
|
12
|
+
<span class="text-subtitle-m">{{ params.text || 'Empty' }}</span>
|
|
5
13
|
</div>
|
|
6
14
|
</template>
|
|
7
15
|
|
|
@@ -6,7 +6,8 @@ export const PlAgDataTableRowNumberColId = '"##RowNumberColumnId##"';
|
|
|
6
6
|
|
|
7
7
|
const HeaderSize = 45;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
export function makeRowNumberColDef<TData = any>(): ColDef<TData> {
|
|
10
11
|
return {
|
|
11
12
|
colId: PlAgDataTableRowNumberColId,
|
|
12
13
|
headerName: '#',
|
|
@@ -62,6 +63,7 @@ function adjustRowNumberColumnWidth(gridApi: GridApi, cellFake: HTMLDivElement,
|
|
|
62
63
|
rowNode: gridApi.getDisplayedRowAtIndex(gridApi.getLastDisplayedRowIndex())!,
|
|
63
64
|
colKey: PlAgDataTableRowNumberColId,
|
|
64
65
|
});
|
|
66
|
+
|
|
65
67
|
if (typeof lastDisplayedRowNumber !== 'number') return;
|
|
66
68
|
|
|
67
69
|
const lastDisplayedRowNumberDigitCount = lastDisplayedRowNumber.toString().length;
|
|
@@ -9,21 +9,25 @@ import type {
|
|
|
9
9
|
RemoteBlobHandleAndSize,
|
|
10
10
|
} from '@platforma-sdk/model';
|
|
11
11
|
|
|
12
|
+
export type PlDataTableSettingsPTable = {
|
|
13
|
+
/** The type of the source to feed the data into the table */
|
|
14
|
+
sourceType: 'ptable';
|
|
15
|
+
/** PTable handle output */
|
|
16
|
+
pTable?: PTableHandle;
|
|
17
|
+
/** Sheets that we want to show in our table */
|
|
18
|
+
sheets?: PlDataTableSheet[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type PlDataTableSettingsXsv = {
|
|
22
|
+
/** The type of the source to feed the data into the table */
|
|
23
|
+
sourceType: 'xsv';
|
|
24
|
+
xsvFile?: LocalBlobHandleAndSize | RemoteBlobHandleAndSize;
|
|
25
|
+
};
|
|
26
|
+
|
|
12
27
|
/** Data table settings */
|
|
13
28
|
export type PlDataTableSettings =
|
|
14
|
-
|
|
|
15
|
-
|
|
16
|
-
sourceType: 'ptable';
|
|
17
|
-
/** PTable handle output */
|
|
18
|
-
pTable?: PTableHandle;
|
|
19
|
-
/** Sheets that we want to show in our table */
|
|
20
|
-
sheets?: PlDataTableSheet[];
|
|
21
|
-
}
|
|
22
|
-
| {
|
|
23
|
-
/** The type of the source to feed the data into the table */
|
|
24
|
-
sourceType: 'xsv';
|
|
25
|
-
xsvFile?: LocalBlobHandleAndSize | RemoteBlobHandleAndSize;
|
|
26
|
-
};
|
|
29
|
+
| PlDataTableSettingsPTable
|
|
30
|
+
| PlDataTableSettingsXsv;
|
|
27
31
|
|
|
28
32
|
/** PlTableFilters restriction entry */
|
|
29
33
|
export type PlTableFiltersRestriction = {
|
|
@@ -62,3 +66,22 @@ export type PlAgDataTableRow = {
|
|
|
62
66
|
/** Row values by column; sheet axes and labeled axes are excluded */
|
|
63
67
|
[field: `${number}` | `hC${number}`]: PTableValue;
|
|
64
68
|
};
|
|
69
|
+
|
|
70
|
+
export type PlAgOverlayLoadingParams = {
|
|
71
|
+
/**
|
|
72
|
+
* Required flag, that shows catInBag icon with message if `true`, shows PlSplash component if `false`.
|
|
73
|
+
*/
|
|
74
|
+
notReady?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Prop to override default "Loading" text
|
|
77
|
+
*/
|
|
78
|
+
loadingText?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Prop to override default "No datasource" text (So why props name is notReady? Good question)
|
|
81
|
+
*/
|
|
82
|
+
notReadyText?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Use "transparent" to make table headers visible below the loading layer
|
|
85
|
+
*/
|
|
86
|
+
overlayType?: 'transparent';
|
|
87
|
+
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { GridApi, GridOptions } from 'ag-grid-enterprise';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a set of Ag Grid options along with a reference to the Ag Grid API.
|
|
4
|
-
* (This is a fast prototype)
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const { gridOptions, gridApi } = useAgDataTableOptionsSimple(() => ({
|
|
9
|
-
* // custom grid options here
|
|
10
|
-
* }));
|
|
11
|
-
*
|
|
12
|
-
* // Usage in a template (v-bind is required!)
|
|
13
|
-
* <template>
|
|
14
|
-
* <AgGridVue :style="{ height: '100%' }" v-bind="gridOptions" />
|
|
15
|
-
* </template>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function useAgGridOptionsSimple<TData>(factory: () => GridOptions<TData>): {
|
|
19
|
-
gridOptions: import("vue").ComputedRef<GridOptions<any>>;
|
|
20
|
-
gridApi: import("vue").ShallowRef<GridApi<any> | undefined, GridApi<any> | undefined>;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=useAgGridOptionsSimple.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useAgGridOptionsSimple.d.ts","sourceRoot":"","sources":["../../../src/AgGridVue/useAgGridOptionsSimple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AAO/E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAC1C,OAAO,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC;;;EA+BlC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { GridApi, GridOptions, GridReadyEvent } from 'ag-grid-enterprise';
|
|
2
|
-
import { computed, shallowRef, watch } from 'vue';
|
|
3
|
-
import { AgGridTheme } from '../aggrid';
|
|
4
|
-
import PlAgOverlayLoading from '../components/PlAgDataTable/PlAgOverlayLoading.vue';
|
|
5
|
-
import PlAgOverlayNoRows from '../components/PlAgDataTable/PlAgOverlayNoRows.vue';
|
|
6
|
-
import { autoSizeRowNumberColumn } from '../lib';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns a set of Ag Grid options along with a reference to the Ag Grid API.
|
|
10
|
-
* (This is a fast prototype)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const { gridOptions, gridApi } = useAgDataTableOptionsSimple(() => ({
|
|
15
|
-
* // custom grid options here
|
|
16
|
-
* }));
|
|
17
|
-
*
|
|
18
|
-
* // Usage in a template (v-bind is required!)
|
|
19
|
-
* <template>
|
|
20
|
-
* <AgGridVue :style="{ height: '100%' }" v-bind="gridOptions" />
|
|
21
|
-
* </template>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function useAgGridOptionsSimple<TData>(
|
|
25
|
-
factory: () => GridOptions<TData>,
|
|
26
|
-
) {
|
|
27
|
-
const gridApi = shallowRef<GridApi>();
|
|
28
|
-
|
|
29
|
-
const gridOptions = computed<GridOptions>(() => {
|
|
30
|
-
const def: GridOptions<TData> = {
|
|
31
|
-
theme: AgGridTheme,
|
|
32
|
-
loadingOverlayComponent: PlAgOverlayLoading,
|
|
33
|
-
noRowsOverlayComponent: PlAgOverlayNoRows,
|
|
34
|
-
onGridReady: (e: GridReadyEvent) => {
|
|
35
|
-
gridApi.value = e.api;
|
|
36
|
-
autoSizeRowNumberColumn(e.api);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return Object.assign({}, def, factory());
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
watch(() => gridOptions.value.loadingOverlayComponentParams, (newParams) => {
|
|
44
|
-
// Hack to apply loadingOverlayComponentParams
|
|
45
|
-
gridApi.value?.updateGridOptions({
|
|
46
|
-
loading: !gridOptions.value.loading,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
gridApi.value?.updateGridOptions({
|
|
50
|
-
loading: gridOptions.value.loading,
|
|
51
|
-
loadingOverlayComponentParams: newParams,
|
|
52
|
-
});
|
|
53
|
-
}, { deep: true });
|
|
54
|
-
|
|
55
|
-
return { gridOptions, gridApi };
|
|
56
|
-
};
|