@lowdefy/blocks-aggrid 4.1.0 → 4.2.0

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/AgGrid.js CHANGED
@@ -22,6 +22,7 @@ const AgGrid = ({ properties, methods, loading, events })=>{
22
22
  const [rowData, setRowData] = useState(newRowData ?? []);
23
23
  const gridRef = useRef();
24
24
  const memoDefaultColDef = useMemo(()=>defaultColDef);
25
+ const getRowId = useCallback((params)=>params.data[properties.rowId] ?? params.data.id ?? params.data._id ?? JSON.stringify(params.data), []);
25
26
  const onRowClick = useCallback((event)=>{
26
27
  if (events.onRowClick) {
27
28
  methods.triggerEvent({
@@ -83,7 +84,7 @@ const AgGrid = ({ properties, methods, loading, events })=>{
83
84
  name: 'onFilterChanged',
84
85
  event: {
85
86
  rows: event.api.rowModel.rowsToDisplay.map((row)=>row.data),
86
- filter: this.gridApi.getFilterModel()
87
+ filter: gridRef.current.api.getFilterModel()
87
88
  }
88
89
  });
89
90
  }
@@ -100,7 +101,6 @@ const AgGrid = ({ properties, methods, loading, events })=>{
100
101
  }
101
102
  }, []);
102
103
  useEffect(()=>{
103
- methods.registerMethod('exportDataAsCsv', (args)=>gridRef.current.api.exportDataAsCsv(args));
104
104
  methods.registerMethod('exportDataAsCsv', (args)=>gridRef.current.api.exportDataAsCsv(args));
105
105
  methods.registerMethod('sizeColumnsToFit', ()=>gridRef.current.api.sizeColumnsToFit());
106
106
  methods.registerMethod('setFilterModel', (model)=>gridRef.current.api.setFilterModel(model));
@@ -149,7 +149,8 @@ const AgGrid = ({ properties, methods, loading, events })=>{
149
149
  CsvExportModule
150
150
  ],
151
151
  columnDefs: processColDefs(columnDefs, methods),
152
- ref: gridRef
152
+ ref: gridRef,
153
+ getRowId: getRowId
153
154
  });
154
155
  };
155
156
  export default AgGrid;
@@ -22,6 +22,7 @@ const AgGridInput = ({ properties, methods, loading, events, value })=>{
22
22
  const [rowData, setRowData] = useState(value ?? []);
23
23
  const gridRef = useRef();
24
24
  const memoDefaultColDef = useMemo(()=>defaultColDef);
25
+ const getRowId = useCallback((params)=>params.data[properties.rowId] ?? params.data.id ?? params.data._id ?? JSON.stringify(params.data), []);
25
26
  const onRowClick = useCallback((event)=>{
26
27
  if (events.onRowClick) {
27
28
  methods.triggerEvent({
@@ -83,7 +84,7 @@ const AgGridInput = ({ properties, methods, loading, events, value })=>{
83
84
  name: 'onFilterChanged',
84
85
  event: {
85
86
  rows: event.api.rowModel.rowsToDisplay.map((row)=>row.data),
86
- filter: this.gridApi.getFilterModel()
87
+ filter: gridRef.current.api.getFilterModel()
87
88
  }
88
89
  });
89
90
  }
@@ -200,7 +201,8 @@ const AgGridInput = ({ properties, methods, loading, events, value })=>{
200
201
  CsvExportModule
201
202
  ],
202
203
  columnDefs: processColDefs(columnDefs, methods),
203
- ref: gridRef
204
+ ref: gridRef,
205
+ getRowId: getRowId
204
206
  });
205
207
  };
206
208
  export default AgGridInput;
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
@@ -14,6 +14,10 @@
14
14
  "type": "array",
15
15
  "description": "The list of data to display on the table."
16
16
  },
17
+ "rowId": {
18
+ "type": "string",
19
+ "description": "The data field to use in `getRowId` which results in Row Selection being maintained across Row Data changes (assuming the Row exists in both sets). See Ag Grid docs for more details (https://www.ag-grid.com/react-data-grid/data-update-row-data/)."
20
+ },
17
21
  "defaultColDef": {
18
22
  "type": "object",
19
23
  "description": "Column properties which get applied to all columns. See all (https://www.ag-grid.com/javascript-data-grid/column-properties/)."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/blocks-aggrid",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "AgGrid Blocks for Lowdefy.",
6
6
  "homepage": "https://lowdefy.com",
@@ -47,15 +47,15 @@
47
47
  "@ag-grid-community/csv-export": "30.2.0",
48
48
  "@ag-grid-community/react": "30.2.0",
49
49
  "@ag-grid-community/styles": "30.2.0",
50
- "@lowdefy/block-utils": "4.1.0",
51
- "@lowdefy/helpers": "4.1.0",
50
+ "@lowdefy/block-utils": "4.2.0",
51
+ "@lowdefy/helpers": "4.2.0",
52
52
  "react": "18.2.0",
53
53
  "react-dom": "18.2.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@emotion/jest": "11.10.5",
57
- "@lowdefy/block-dev": "4.1.0",
58
- "@lowdefy/jest-yaml-transform": "4.1.0",
57
+ "@lowdefy/block-dev": "4.2.0",
58
+ "@lowdefy/jest-yaml-transform": "4.2.0",
59
59
  "@swc/cli": "0.1.63",
60
60
  "@swc/core": "1.3.99",
61
61
  "@swc/jest": "0.2.29",