@platforma-sdk/ui-vue 1.30.22 → 1.30.24
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 +16 -0
- package/dist/lib.js +6578 -6528
- package/dist/lib.js.map +1 -1
- package/dist/lib.umd.cjs +14 -14
- package/dist/lib.umd.cjs.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgDataTableV2.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgDataTable/PlAgRowCount.vue.d.ts +9 -0
- package/dist/src/components/PlAgDataTable/PlAgRowCount.vue.d.ts.map +1 -0
- package/dist/src/components/PlAgDataTable/sources/row-number.d.ts.map +1 -1
- package/dist/src/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue.d.ts.map +1 -1
- package/dist/src/components/PlAgRowNumHeader.vue.d.ts +7 -0
- package/dist/src/components/PlAgRowNumHeader.vue.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/components/PlAgDataTable/PlAgDataTableV2.vue +6 -0
- package/src/components/PlAgDataTable/PlAgRowCount.vue +44 -0
- package/src/components/PlAgDataTable/sources/row-number.ts +2 -0
- package/src/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue +10 -15
- package/src/components/PlAgRowNumHeader.vue +67 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.24",
|
|
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.1.0",
|
|
24
24
|
"ag-grid-enterprise": "^33.0.4",
|
|
25
25
|
"ag-grid-vue3": "^33.0.4",
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
26
|
+
"@milaboratories/uikit": "^2.2.75",
|
|
27
|
+
"@platforma-sdk/model": "^1.30.24"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@faker-js/faker": "^9.2.0",
|
|
@@ -55,6 +55,7 @@ import { autoSizeRowNumberColumn, PlAgDataTableRowNumberColId } from './sources/
|
|
|
55
55
|
import { focusRow, makeOnceTracker, trackFirstDataRendered } from './sources/focus-row';
|
|
56
56
|
import PlAgCsvExporter from '../PlAgCsvExporter/PlAgCsvExporter.vue';
|
|
57
57
|
import { Deferred, isJsonEqual } from '@milaboratories/helpers';
|
|
58
|
+
import PlAgRowCount from './PlAgRowCount.vue';
|
|
58
59
|
|
|
59
60
|
ModuleRegistry.registerModules([
|
|
60
61
|
ClientSideRowModelModule,
|
|
@@ -319,6 +320,11 @@ const gridOptions = shallowRef<GridOptions<PlAgDataTableRow>>({
|
|
|
319
320
|
suppressQuotes: true,
|
|
320
321
|
fileName: 'table.csv',
|
|
321
322
|
},
|
|
323
|
+
statusBar: {
|
|
324
|
+
statusPanels: [
|
|
325
|
+
{ statusPanel: PlAgRowCount, align: 'left' },
|
|
326
|
+
],
|
|
327
|
+
},
|
|
322
328
|
});
|
|
323
329
|
|
|
324
330
|
const onGridReady = (event: GridReadyEvent) => {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { GridApi } from 'ag-grid-enterprise';
|
|
3
|
+
import { computed, onBeforeMount, onBeforeUnmount, ref } from 'vue';
|
|
4
|
+
|
|
5
|
+
const { params } = defineProps<{
|
|
6
|
+
params: { api: GridApi };
|
|
7
|
+
}>();
|
|
8
|
+
|
|
9
|
+
const totalRowCount = ref(params.api.getDisplayedRowCount());
|
|
10
|
+
const selectedRowCount = ref(params.api.getSelectedRows().length);
|
|
11
|
+
|
|
12
|
+
const pluralRules = new Intl.PluralRules('en');
|
|
13
|
+
const numberFormatter = new Intl.NumberFormat('en');
|
|
14
|
+
|
|
15
|
+
const output = computed(() => {
|
|
16
|
+
let result = numberFormatter.format(totalRowCount.value) + ' ';
|
|
17
|
+
result += pluralRules.select(totalRowCount.value) === 'one' ? 'row' : 'rows';
|
|
18
|
+
if (selectedRowCount.value > 0) {
|
|
19
|
+
result += ' (' + numberFormatter.format(selectedRowCount.value) + ' selected)';
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function updateRowCounts() {
|
|
25
|
+
totalRowCount.value = params.api.getDisplayedRowCount();
|
|
26
|
+
selectedRowCount.value = params.api.getSelectedRows().length;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onBeforeMount(() => {
|
|
30
|
+
params.api.addEventListener('selectionChanged', updateRowCounts);
|
|
31
|
+
params.api.addEventListener('rowDataUpdated', updateRowCounts);
|
|
32
|
+
params.api.addEventListener('modelUpdated', updateRowCounts);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
onBeforeUnmount(() => {
|
|
36
|
+
params.api.removeEventListener('selectionChanged', updateRowCounts);
|
|
37
|
+
params.api.removeEventListener('rowDataUpdated', updateRowCounts);
|
|
38
|
+
params.api.removeEventListener('modelUpdated', updateRowCounts);
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
{{ output }}
|
|
44
|
+
</template>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isColumnSelectionCol, type ColDef, type GridApi, type ValueGetterParams } from 'ag-grid-enterprise';
|
|
2
2
|
import { nextTick } from 'vue';
|
|
3
3
|
import { PlAgRowNumCheckbox } from '../../PlAgRowNumCheckbox';
|
|
4
|
+
import PlAgRowNumHeader from '../../PlAgRowNumHeader.vue';
|
|
4
5
|
|
|
5
6
|
export const PlAgDataTableRowNumberColId = '"##RowNumberColumnId##"';
|
|
6
7
|
|
|
@@ -11,6 +12,7 @@ export function makeRowNumberColDef<TData = any>(): ColDef<TData> {
|
|
|
11
12
|
return {
|
|
12
13
|
colId: PlAgDataTableRowNumberColId,
|
|
13
14
|
headerName: '#',
|
|
15
|
+
headerComponent: PlAgRowNumHeader,
|
|
14
16
|
valueGetter: (params: ValueGetterParams) => {
|
|
15
17
|
if (params.node === null) return null;
|
|
16
18
|
if (params.node.rowIndex === null) return null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { ICellRendererParams
|
|
2
|
+
import type { ICellRendererParams } from 'ag-grid-enterprise';
|
|
3
3
|
import { PlCheckbox } from '@milaboratories/uikit';
|
|
4
|
-
import { ref, computed } from 'vue';
|
|
4
|
+
import { ref, computed, onBeforeMount, onBeforeUnmount } from 'vue';
|
|
5
5
|
import $styles from './pl-ag-row-num-checkbox.module.scss';
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{ params: ICellRendererParams }>();
|
|
@@ -11,19 +11,6 @@ const isChecked = ref(!!props.params.node.isSelected());
|
|
|
11
11
|
const forceShowCheckbox = computed(() => isChecked.value || api.getGridOption('rowSelection'));
|
|
12
12
|
const allowedSelection = ref(api.getGridOption('rowSelection'));
|
|
13
13
|
|
|
14
|
-
const rowSelection = api.getGridOption('rowSelection');
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
function isRowSelectionWithMode(obj: any): obj is RowSelectionOptions<any, any> {
|
|
18
|
-
return obj && typeof obj === 'object' && 'mode' in obj;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (isRowSelectionWithMode(rowSelection) && rowSelection.mode === 'singleRow') {
|
|
22
|
-
props.params.node.addEventListener('rowSelected', (val) => {
|
|
23
|
-
isChecked.value = !!val.node.isSelected();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
14
|
const updateSelection = () => {
|
|
28
15
|
isChecked.value = !!props.params.node.isSelected();
|
|
29
16
|
};
|
|
@@ -34,6 +21,14 @@ const setSelection = (val: boolean) => {
|
|
|
34
21
|
updateSelection();
|
|
35
22
|
}
|
|
36
23
|
};
|
|
24
|
+
|
|
25
|
+
onBeforeMount(() => {
|
|
26
|
+
props.params.node.addEventListener('rowSelected', updateSelection);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
onBeforeUnmount(() => {
|
|
30
|
+
props.params.node.removeEventListener('rowSelected', updateSelection);
|
|
31
|
+
});
|
|
37
32
|
</script>
|
|
38
33
|
|
|
39
34
|
<template>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { PlCheckbox } from '@milaboratories/uikit';
|
|
3
|
+
import type { IHeaderParams } from 'ag-grid-enterprise';
|
|
4
|
+
import { computed, onBeforeMount, onBeforeUnmount, ref } from 'vue';
|
|
5
|
+
|
|
6
|
+
const { params } = defineProps<{
|
|
7
|
+
params: IHeaderParams;
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const selectedRowCount = ref(params.api.getSelectedRows().length);
|
|
11
|
+
const totalRowCount = ref(params.api.getDisplayedRowCount());
|
|
12
|
+
const isSelectable = ref(Boolean(params.api.getGridOption('rowSelection')));
|
|
13
|
+
|
|
14
|
+
const allRowsSelected = computed(() =>
|
|
15
|
+
selectedRowCount.value === totalRowCount.value
|
|
16
|
+
&& selectedRowCount.value > 0,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
function updateRowCounts() {
|
|
20
|
+
selectedRowCount.value = params.api.getSelectedRows().length;
|
|
21
|
+
totalRowCount.value = params.api.getDisplayedRowCount();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function updateIsSelectable() {
|
|
25
|
+
isSelectable.value = Boolean(params.api.getGridOption('rowSelection'));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onBeforeMount(() => {
|
|
29
|
+
params.api.addEventListener('selectionChanged', updateRowCounts);
|
|
30
|
+
params.api.addEventListener('rowDataUpdated', updateRowCounts);
|
|
31
|
+
params.api.addEventListener('modelUpdated', updateRowCounts);
|
|
32
|
+
params.api.addEventListener('stateUpdated', updateIsSelectable);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
onBeforeUnmount(() => {
|
|
36
|
+
params.api.removeEventListener('selectionChanged', updateRowCounts);
|
|
37
|
+
params.api.removeEventListener('rowDataUpdated', updateRowCounts);
|
|
38
|
+
params.api.removeEventListener('modelUpdated', updateRowCounts);
|
|
39
|
+
params.api.removeEventListener('stateUpdated', updateIsSelectable);
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div
|
|
45
|
+
style="
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
align-items: center;
|
|
51
|
+
"
|
|
52
|
+
>
|
|
53
|
+
<PlCheckbox
|
|
54
|
+
v-if="isSelectable"
|
|
55
|
+
:model-value="allRowsSelected"
|
|
56
|
+
:indeterminate="!allRowsSelected && selectedRowCount > 0"
|
|
57
|
+
@update:model-value="
|
|
58
|
+
allRowsSelected
|
|
59
|
+
? params.api.deselectAll()
|
|
60
|
+
: params.api.selectAll()
|
|
61
|
+
"
|
|
62
|
+
/>
|
|
63
|
+
<span v-else>
|
|
64
|
+
{{ params.displayName }}
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|