@bit.rhplus/ag-grid 0.0.11
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/AgGridAddNewItem.js +6 -0
- package/AgGridColumn.js +368 -0
- package/AgGridColumnFilter.js +22 -0
- package/AgGridOnGridReady.js +9 -0
- package/AgGridOnRowDataChanged.js +8 -0
- package/AgGridOnRowDataUpdated.js +32 -0
- package/AgGridPostSort.js +34 -0
- package/AggregationNotification.js +111 -0
- package/Aggregations.js +185 -0
- package/CheckBoxRenderer.jsx +29 -0
- package/Components/ExtendButton.css +6 -0
- package/Components/ExtendButton.jsx +17 -0
- package/CountryCellRenderer.jsx +18 -0
- package/Functions/index.js +21 -0
- package/HeaderTemplates/CommonHeaderTemplate.js +15 -0
- package/HyperModuleEditor.js +139 -0
- package/HyperModuleRenderer.js +152 -0
- package/NotificationOptions.jsx +53 -0
- package/OnCellDoubleClicked.js +10 -0
- package/OnCellEditingStarted.js +9 -0
- package/OnCellValueChanged.js +12 -0
- package/Renderers/BooleanRenderer.jsx +39 -0
- package/Renderers/ButtonRenderer.jsx +48 -0
- package/Renderers/CheckboxRenderer.jsx +35 -0
- package/Renderers/CountrySelectRenderer.jsx +37 -0
- package/Renderers/SelectRenderer.jsx +15 -0
- package/dist/AgGridAddNewItem.d.ts +0 -0
- package/dist/AgGridAddNewItem.js +6 -0
- package/dist/AgGridAddNewItem.js.map +1 -0
- package/dist/AgGridColumn.d.ts +3 -0
- package/dist/AgGridColumn.js +325 -0
- package/dist/AgGridColumn.js.map +1 -0
- package/dist/AgGridColumnFilter.d.ts +4 -0
- package/dist/AgGridColumnFilter.js +19 -0
- package/dist/AgGridColumnFilter.js.map +1 -0
- package/dist/AgGridOnGridReady.d.ts +1 -0
- package/dist/AgGridOnGridReady.js +6 -0
- package/dist/AgGridOnGridReady.js.map +1 -0
- package/dist/AgGridOnRowDataChanged.d.ts +0 -0
- package/dist/AgGridOnRowDataChanged.js +8 -0
- package/dist/AgGridOnRowDataChanged.js.map +1 -0
- package/dist/AgGridOnRowDataUpdated.d.ts +1 -0
- package/dist/AgGridOnRowDataUpdated.js +27 -0
- package/dist/AgGridOnRowDataUpdated.js.map +1 -0
- package/dist/AgGridPostSort.d.ts +1 -0
- package/dist/AgGridPostSort.js +32 -0
- package/dist/AgGridPostSort.js.map +1 -0
- package/dist/AggregationNotification.d.ts +0 -0
- package/dist/AggregationNotification.js +107 -0
- package/dist/AggregationNotification.js.map +1 -0
- package/dist/Aggregations.d.ts +25 -0
- package/dist/Aggregations.js +171 -0
- package/dist/Aggregations.js.map +1 -0
- package/dist/CheckBoxRenderer.d.ts +6 -0
- package/dist/CheckBoxRenderer.js +18 -0
- package/dist/CheckBoxRenderer.js.map +1 -0
- package/dist/Components/ExtendButton.css +6 -0
- package/dist/Components/ExtendButton.d.ts +2 -0
- package/dist/Components/ExtendButton.js +12 -0
- package/dist/Components/ExtendButton.js.map +1 -0
- package/dist/CountryCellRenderer.d.ts +1 -0
- package/dist/CountryCellRenderer.js +12 -0
- package/dist/CountryCellRenderer.js.map +1 -0
- package/dist/Functions/index.d.ts +2 -0
- package/dist/Functions/index.js +19 -0
- package/dist/Functions/index.js.map +1 -0
- package/dist/HeaderTemplates/CommonHeaderTemplate.d.ts +1 -0
- package/dist/HeaderTemplates/CommonHeaderTemplate.js +15 -0
- package/dist/HeaderTemplates/CommonHeaderTemplate.js.map +1 -0
- package/dist/HyperModuleEditor.d.ts +0 -0
- package/dist/HyperModuleEditor.js +119 -0
- package/dist/HyperModuleEditor.js.map +1 -0
- package/dist/HyperModuleRenderer.d.ts +0 -0
- package/dist/HyperModuleRenderer.js +138 -0
- package/dist/HyperModuleRenderer.js.map +1 -0
- package/dist/NotificationOptions.d.ts +9 -0
- package/dist/NotificationOptions.js +21 -0
- package/dist/NotificationOptions.js.map +1 -0
- package/dist/OnCellDoubleClicked.d.ts +1 -0
- package/dist/OnCellDoubleClicked.js +6 -0
- package/dist/OnCellDoubleClicked.js.map +1 -0
- package/dist/OnCellEditingStarted.d.ts +1 -0
- package/dist/OnCellEditingStarted.js +7 -0
- package/dist/OnCellEditingStarted.js.map +1 -0
- package/dist/OnCellValueChanged.d.ts +1 -0
- package/dist/OnCellValueChanged.js +10 -0
- package/dist/OnCellValueChanged.js.map +1 -0
- package/dist/Renderers/BooleanRenderer.d.ts +1 -0
- package/dist/Renderers/BooleanRenderer.js +27 -0
- package/dist/Renderers/BooleanRenderer.js.map +1 -0
- package/dist/Renderers/ButtonRenderer.d.ts +1 -0
- package/dist/Renderers/ButtonRenderer.js +25 -0
- package/dist/Renderers/ButtonRenderer.js.map +1 -0
- package/dist/Renderers/CheckboxRenderer.d.ts +1 -0
- package/dist/Renderers/CheckboxRenderer.js +23 -0
- package/dist/Renderers/CheckboxRenderer.js.map +1 -0
- package/dist/Renderers/CountrySelectRenderer.d.ts +1 -0
- package/dist/Renderers/CountrySelectRenderer.js +20 -0
- package/dist/Renderers/CountrySelectRenderer.js.map +1 -0
- package/dist/Renderers/SelectRenderer.d.ts +1 -0
- package/dist/Renderers/SelectRenderer.js +12 -0
- package/dist/Renderers/SelectRenderer.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1727859392810.js +7 -0
- package/dist/util.d.ts +15 -0
- package/dist/util.js +95 -0
- package/dist/util.js.map +1 -0
- package/index.jsx +143 -0
- package/package.json +35 -0
- package/types/asset.d.ts +43 -0
- package/types/style.d.ts +42 -0
- package/util.js +116 -0
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../util.js"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CACnD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;KACnB,MAAM,CAAC,CAAC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EAAE,CAAC;IACpF,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAEpG,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC;IACjD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC;IACxD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC;IAExD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA"}
|
package/index.jsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
|
+
import { notification } from "antd";
|
|
4
|
+
import { AgGridReact } from "ag-grid-react";
|
|
5
|
+
import { AgGridColumns } from "./AgGridColumn";
|
|
6
|
+
import { RhPlusOnCellEditingStarted } from "./OnCellEditingStarted";
|
|
7
|
+
import { RhPlusOnCellDoubleClicked } from "./OnCellDoubleClicked";
|
|
8
|
+
import { RhPlusOnCellValueChanged } from "./OnCellValueChanged";
|
|
9
|
+
import { AgGridPostSort } from "./AgGridPostSort";
|
|
10
|
+
import { AgGridOnRowDataChanged } from "./AgGridOnRowDataChanged";
|
|
11
|
+
import { AgGridOnRowDataUpdated } from "./AgGridOnRowDataUpdated";
|
|
12
|
+
// import HyperModuleEditor from "./HyperModuleEditor";
|
|
13
|
+
import CheckboxRenderer from "./Renderers/CheckboxRenderer";
|
|
14
|
+
import BooleanRenderer from "./Renderers/BooleanRenderer";
|
|
15
|
+
import SelectRenderer from "./Renderers/SelectRenderer";
|
|
16
|
+
import ButtonRenderer from "./Renderers/ButtonRenderer";
|
|
17
|
+
import Aggregations from "./Aggregations";
|
|
18
|
+
import CountrySelectRenderer from "./Renderers/CountrySelectRenderer";
|
|
19
|
+
// import BooleanRenderer from './Renderers/BooleanRenderer';
|
|
20
|
+
import NotificationOptionsInit from "./NotificationOptions";
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const key = uuidv4();
|
|
24
|
+
|
|
25
|
+
const AgGrid = React.forwardRef((props, ref) => {
|
|
26
|
+
const internalRef = React.useRef();
|
|
27
|
+
const {
|
|
28
|
+
rowData = [],
|
|
29
|
+
enableNotification,
|
|
30
|
+
notificationOptions: {
|
|
31
|
+
notificationHead = NotificationOptionsInit.head,
|
|
32
|
+
notificationBody = NotificationOptionsInit.body,
|
|
33
|
+
style = NotificationOptionsInit.style,
|
|
34
|
+
placement = NotificationOptionsInit.placement
|
|
35
|
+
} = {},
|
|
36
|
+
newRowFlash = true
|
|
37
|
+
} = props;
|
|
38
|
+
const [, setIsGridReady] = React.useState(false);
|
|
39
|
+
const previousRowDataRef = React.useRef(rowData);
|
|
40
|
+
|
|
41
|
+
const findNewRows = (oldData, newData) => {
|
|
42
|
+
const oldIds = new Set(oldData.map((row) => row.id));
|
|
43
|
+
return newData.filter((row) => !oldIds.has(row.id));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
React.useImperativeHandle(ref, () => internalRef.current, [internalRef]);
|
|
47
|
+
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (!newRowFlash) return;
|
|
50
|
+
|
|
51
|
+
const previousRowData = previousRowDataRef.current;
|
|
52
|
+
|
|
53
|
+
const addedRows = findNewRows(previousRowData, rowData);
|
|
54
|
+
|
|
55
|
+
if (addedRows.length > 0) {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
const newRowNodes = [];
|
|
58
|
+
internalRef.current.api.forEachNode((node) => {
|
|
59
|
+
if (addedRows.some((row) => row.id === node.data.id)) {
|
|
60
|
+
newRowNodes.push(node);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log("🚀 ~ setTimeout ~ internalRef.current.columnApi:", internalRef.current.columnApi);
|
|
65
|
+
|
|
66
|
+
if (internalRef.current && internalRef.current.columnApi && internalRef.current.columnApi.getColumnState) {
|
|
67
|
+
const allColumns = internalRef.current.columnApi.getColumnState().map(colState => colState.colId);
|
|
68
|
+
internalRef.current.api.flashCells({
|
|
69
|
+
rowNodes: newRowNodes,
|
|
70
|
+
columns: allColumns,
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
console.error("columnApi není dostupné.");
|
|
74
|
+
}
|
|
75
|
+
}, 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
previousRowDataRef.current = rowData;
|
|
79
|
+
}, [rowData]);
|
|
80
|
+
|
|
81
|
+
const RhPlusRangeSelectionChanged = React.useCallback(
|
|
82
|
+
event => {
|
|
83
|
+
if (internalRef && !!internalRef.current && enableNotification) {
|
|
84
|
+
const messageInfo = Aggregations(internalRef);
|
|
85
|
+
if (messageInfo.count > 1) {
|
|
86
|
+
if (props.onAggregationChanged) props.onAggregationChanged(messageInfo);
|
|
87
|
+
notification.info({
|
|
88
|
+
key,
|
|
89
|
+
message: notificationHead(messageInfo),
|
|
90
|
+
description: notificationBody(messageInfo),
|
|
91
|
+
duration: 0,
|
|
92
|
+
showDate: false,
|
|
93
|
+
style,
|
|
94
|
+
placement
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (props.onRangeSelectionChanged) props.onRangeSelectionChanged(event);
|
|
99
|
+
},
|
|
100
|
+
[internalRef]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const AgGridOnGridReady = (event, options) => {
|
|
104
|
+
setTimeout(() => setIsGridReady(true), 1000);
|
|
105
|
+
if (options.onGridReady) options.onGridReady(event);
|
|
106
|
+
|
|
107
|
+
if (internalRef.current) {
|
|
108
|
+
internalRef.current.api = event.api;
|
|
109
|
+
internalRef.current.columnApi = event.columnApi;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const components = React.useMemo(() => {
|
|
114
|
+
return {
|
|
115
|
+
checkboxRenderer: CheckboxRenderer,
|
|
116
|
+
selectRenderer: SelectRenderer,
|
|
117
|
+
countrySelectRenderer: CountrySelectRenderer,
|
|
118
|
+
booleanRenderer: BooleanRenderer,
|
|
119
|
+
buttonRenderer: ButtonRenderer,
|
|
120
|
+
...props.frameworkComponents
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<AgGridReact
|
|
126
|
+
ref={internalRef}
|
|
127
|
+
{...props}
|
|
128
|
+
columnDefs={AgGridColumns(props.columnDefs, props)}
|
|
129
|
+
onCellEditingStarted={event => RhPlusOnCellEditingStarted(event, props)}
|
|
130
|
+
onCellDoubleClicked={event => RhPlusOnCellDoubleClicked(event, props)}
|
|
131
|
+
onCellValueChanged={event => RhPlusOnCellValueChanged(event, props)}
|
|
132
|
+
postSort={event => AgGridPostSort(event, props)}
|
|
133
|
+
onGridReady={event => AgGridOnGridReady(event, props)}
|
|
134
|
+
onRowDataChanged={event => AgGridOnRowDataChanged(event, props)}
|
|
135
|
+
onRowDataUpdated={event => AgGridOnRowDataUpdated(event, props)}
|
|
136
|
+
onRangeSelectionChanged={event => RhPlusRangeSelectionChanged(event)}
|
|
137
|
+
context={{ componentParent: { ...props } }}
|
|
138
|
+
frameworkComponents={components}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export default AgGrid;
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bit.rhplus/ag-grid",
|
|
3
|
+
"version": "0.0.11",
|
|
4
|
+
"homepage": "https://bit.cloud/remote-scope/ag-grid",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "remote-scope",
|
|
8
|
+
"name": "ag-grid",
|
|
9
|
+
"version": "0.0.11"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"linq": "^4.0.3",
|
|
13
|
+
"moment": "^2.30.1",
|
|
14
|
+
"lodash": "^4.17.21",
|
|
15
|
+
"ag-grid-react": "^31.3.4",
|
|
16
|
+
"antd": "^5.20.6",
|
|
17
|
+
"uuid": "^10.0.0",
|
|
18
|
+
"@rhplus/wieldy.linq": "0.0.4",
|
|
19
|
+
"@rhplus/wieldy.icons": "0.0.3"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@teambit/react.react-env": "1.0.98"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^17.0.0 || ^18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"license": "SEE LICENSE IN UNLICENSED",
|
|
28
|
+
"optionalDependencies": {},
|
|
29
|
+
"peerDependenciesMeta": {},
|
|
30
|
+
"private": false,
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"scope": "@bit.rhplus",
|
|
33
|
+
"registry": "https://registry.npmjs.org/"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// @TODO Gilad
|
|
16
|
+
declare module '*.jpg' {
|
|
17
|
+
const value: any;
|
|
18
|
+
export = value;
|
|
19
|
+
}
|
|
20
|
+
declare module '*.jpeg' {
|
|
21
|
+
const value: any;
|
|
22
|
+
export = value;
|
|
23
|
+
}
|
|
24
|
+
declare module '*.gif' {
|
|
25
|
+
const value: any;
|
|
26
|
+
export = value;
|
|
27
|
+
}
|
|
28
|
+
declare module '*.bmp' {
|
|
29
|
+
const value: any;
|
|
30
|
+
export = value;
|
|
31
|
+
}
|
|
32
|
+
declare module '*.otf' {
|
|
33
|
+
const value: any;
|
|
34
|
+
export = value;
|
|
35
|
+
}
|
|
36
|
+
declare module '*.woff' {
|
|
37
|
+
const value: any;
|
|
38
|
+
export = value;
|
|
39
|
+
}
|
|
40
|
+
declare module '*.woff2' {
|
|
41
|
+
const value: any;
|
|
42
|
+
export = value;
|
|
43
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
package/util.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
import Enumerable from '@rhplus/wieldy.linq';
|
|
3
|
+
|
|
4
|
+
export const getValueFromObject = (array, dataKey) =>
|
|
5
|
+
Enumerable.from(array)
|
|
6
|
+
.select(s => s[dataKey])
|
|
7
|
+
.toArray();
|
|
8
|
+
|
|
9
|
+
export const getDataValue = (gridRef, rowIndex) => {
|
|
10
|
+
const rowModel = gridRef.current.api.getModel();
|
|
11
|
+
const rowNode = rowModel.getRow(rowIndex);
|
|
12
|
+
return rowNode.data;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const getDataValueSelectedRows = (gridRef) => {
|
|
16
|
+
let result = [];
|
|
17
|
+
if (!gridRef || !gridRef.current || !gridRef.current.api)
|
|
18
|
+
return [];
|
|
19
|
+
|
|
20
|
+
const ranges = gridRef.current.api.getCellRanges();
|
|
21
|
+
|
|
22
|
+
ranges.forEach(range => {
|
|
23
|
+
const start = Math.min(range.startRow.rowIndex, range.endRow.rowIndex);
|
|
24
|
+
const end = Math.max(range.startRow.rowIndex, range.endRow.rowIndex);
|
|
25
|
+
|
|
26
|
+
for (let rowIndex = start; rowIndex <= end; rowIndex+=1) {
|
|
27
|
+
const value = getDataValue(gridRef, rowIndex);
|
|
28
|
+
result = [...result, value];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const getColumnValue = (gridRef, column, rowIndex) => {
|
|
35
|
+
const rowModel = gridRef.current.api.getModel();
|
|
36
|
+
const rowNode = rowModel.getRow(rowIndex);
|
|
37
|
+
const value = gridRef.current.api.getValue(column, rowNode);
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const getColumnValueSelectedRows = (gridRef, columnName) => {
|
|
42
|
+
let result = [];
|
|
43
|
+
if (!gridRef || !gridRef.current || !gridRef.current.api)
|
|
44
|
+
return [];
|
|
45
|
+
|
|
46
|
+
const ranges = gridRef.current.api.getCellRanges();
|
|
47
|
+
|
|
48
|
+
const column = gridRef.current.columnApi.getColumn(columnName);
|
|
49
|
+
if (!column)
|
|
50
|
+
return [];
|
|
51
|
+
|
|
52
|
+
ranges.forEach(range => {
|
|
53
|
+
const start = Math.min(range.startRow.rowIndex, range.endRow.rowIndex);
|
|
54
|
+
const end = Math.max(range.startRow.rowIndex, range.endRow.rowIndex);
|
|
55
|
+
|
|
56
|
+
for (let rowIndex = start; rowIndex <= end; rowIndex+=1) {
|
|
57
|
+
|
|
58
|
+
const value = getColumnValue(gridRef, column, rowIndex);
|
|
59
|
+
result = [...result, value];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const first = params => {
|
|
66
|
+
const { node: { allLeafChildren } = {} } = params;
|
|
67
|
+
if (!allLeafChildren || allLeafChildren.length === 0)
|
|
68
|
+
return undefined;
|
|
69
|
+
if (allLeafChildren.length > 0)
|
|
70
|
+
return allLeafChildren[0].data;
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const last = params => {
|
|
75
|
+
const { node: { allLeafChildren } = {} } = params;
|
|
76
|
+
if (!allLeafChildren || allLeafChildren.length === 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
if (allLeafChildren.length > 0)
|
|
79
|
+
return allLeafChildren[allLeafChildren.length - 1].data;
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const isGroupData = params => {
|
|
84
|
+
const { data } = params;
|
|
85
|
+
return !data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const rowOrFirst = params => {
|
|
89
|
+
if (isGroupData(params))
|
|
90
|
+
return first(params);
|
|
91
|
+
return params.data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const rowOrLast = params => {
|
|
95
|
+
if (isGroupData(params))
|
|
96
|
+
return last(params);
|
|
97
|
+
return params.data;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const getRowDataTransaction = (prev, newe, pk) => {
|
|
101
|
+
const joiner = Enumerable.from(prev)
|
|
102
|
+
.fullOuterJoin(newe, s => pk(s), s => pk(s), (p, n) => ({ p, n }))
|
|
103
|
+
.where(w => JSON.stringify(w.p) !== JSON.stringify(w.n));
|
|
104
|
+
|
|
105
|
+
const addedRows = joiner.where(w => w.p === null).select(s => s.n.data).toArray();
|
|
106
|
+
const removedRows = joiner.where(w => w.n === null).select(s => s.p.data).toArray();
|
|
107
|
+
const updatedRows = joiner.where(w => w.p !== null && w.n !== null).select(s => s.n.data).toArray();
|
|
108
|
+
|
|
109
|
+
const result = {};
|
|
110
|
+
|
|
111
|
+
if (addedRows.length > 0) result.add = addedRows;
|
|
112
|
+
if (removedRows.length > 0) result.remove = removedRows;
|
|
113
|
+
if (updatedRows.length > 0) result.update = updatedRows;
|
|
114
|
+
|
|
115
|
+
return result;
|
|
116
|
+
}
|