@lowdefy/blocks-aggrid 4.0.0-alpha.17 → 4.0.0-alpha.20

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
@@ -29,6 +29,7 @@ function _extends() {
29
29
  */ import React from 'react';
30
30
  import { AgGridReact } from '@ag-grid-community/react';
31
31
  import { AllCommunityModules } from '@ag-grid-community/all-modules';
32
+ import processColDefs from './processColDefs.js';
32
33
  let AgGrid = class AgGrid extends React.Component {
33
34
  // see https://stackoverflow.com/questions/55182118/ag-grid-resize-detail-height-when-data-changes
34
35
  componentDidUpdate() {
@@ -120,7 +121,7 @@ let AgGrid = class AgGrid extends React.Component {
120
121
  }
121
122
  }
122
123
  render() {
123
- const { quickFilterValue , ...someProperties } = this.props.properties;
124
+ const { quickFilterValue , columnDefs , ...someProperties } = this.props.properties;
124
125
  if (quickFilterValue && quickFilterValue === '') {
125
126
  this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
126
127
  }
@@ -131,7 +132,8 @@ let AgGrid = class AgGrid extends React.Component {
131
132
  onRowClicked: this.onRowClick,
132
133
  onCellClicked: this.onCellClicked,
133
134
  onGridReady: this.onGridReady,
134
- modules: AllCommunityModules
135
+ modules: AllCommunityModules,
136
+ columnDefs: processColDefs(columnDefs)
135
137
  }, someProperties));
136
138
  }
137
139
  constructor(props){
@@ -29,6 +29,7 @@ function _extends() {
29
29
  */ import React from 'react';
30
30
  import { AgGridReact } from '@ag-grid-community/react';
31
31
  import { AllCommunityModules } from '@ag-grid-community/all-modules';
32
+ import processColDefs from './processColDefs.js';
32
33
  let AgGridInput = class AgGridInput extends React.Component {
33
34
  // see https://stackoverflow.com/questions/55182118/ag-grid-resize-detail-height-when-data-changes
34
35
  componentDidUpdate() {
@@ -162,7 +163,7 @@ let AgGridInput = class AgGridInput extends React.Component {
162
163
  });
163
164
  }
164
165
  render() {
165
- const { quickFilterValue , ...someProperties } = this.props.properties;
166
+ const { quickFilterValue , columnDefs , ...someProperties } = this.props.properties;
166
167
  if (quickFilterValue && quickFilterValue === '') {
167
168
  this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
168
169
  }
@@ -175,7 +176,8 @@ let AgGridInput = class AgGridInput extends React.Component {
175
176
  onRowDragEnd: this.onRowDragEnd,
176
177
  onCellValueChanged: this.onCellValueChanged,
177
178
  postSort: this.postSort,
178
- modules: AllCommunityModules
179
+ modules: AllCommunityModules,
180
+ columnDefs: processColDefs(columnDefs)
179
181
  }, someProperties, {
180
182
  rowData: this.props.value
181
183
  }));
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright 2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { renderHtml } from '@lowdefy/block-utils';
16
+ import { type } from '@lowdefy/helpers';
17
+ function recProcessColDefs(columnDefs) {
18
+ return columnDefs.map((col)=>{
19
+ const newColDef = {};
20
+ if (type.isArray(col.children)) {
21
+ newColDef.children = recProcessColDefs(col.children);
22
+ }
23
+ if (type.isFunction(col.cellRenderer)) {
24
+ newColDef.cellRenderer = (params)=>{
25
+ return renderHtml({
26
+ html: col.cellRenderer(params),
27
+ methods: this.props.methods
28
+ });
29
+ };
30
+ }
31
+ return {
32
+ ...col,
33
+ ...newColDef
34
+ };
35
+ });
36
+ }
37
+ function processColDefs(columnDefs = []) {
38
+ return recProcessColDefs(columnDefs);
39
+ }
40
+ export default processColDefs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/blocks-aggrid",
3
- "version": "4.0.0-alpha.17",
3
+ "version": "4.0.0-alpha.20",
4
4
  "license": "Apache-2.0",
5
5
  "description": "AgGrid Blocks for Lowdefy.",
6
6
  "homepage": "https://lowdefy.com",
@@ -54,14 +54,15 @@
54
54
  "@ag-grid-community/all-modules": "27.3.0",
55
55
  "@ag-grid-community/core": "27.3.0",
56
56
  "@ag-grid-community/react": "27.3.0",
57
- "@lowdefy/block-utils": "4.0.0-alpha.17",
57
+ "@lowdefy/block-utils": "4.0.0-alpha.20",
58
+ "@lowdefy/helpers": "4.0.0-alpha.20",
58
59
  "react": "18.1.0",
59
60
  "react-dom": "18.1.0"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@emotion/jest": "11.9.1",
63
- "@lowdefy/block-dev": "4.0.0-alpha.17",
64
- "@lowdefy/jest-yaml-transform": "4.0.0-alpha.17",
64
+ "@lowdefy/block-dev": "4.0.0-alpha.20",
65
+ "@lowdefy/jest-yaml-transform": "4.0.0-alpha.20",
65
66
  "@swc/cli": "0.1.57",
66
67
  "@swc/core": "1.2.194",
67
68
  "@swc/jest": "0.2.21",
@@ -76,5 +77,5 @@
76
77
  "publishConfig": {
77
78
  "access": "public"
78
79
  },
79
- "gitHead": "9172974b2fe19c527d3f0ea66b8dbde827ac9c0e"
80
+ "gitHead": "cf96c282e8ea38153ea815d72e2b95e5da1359f6"
80
81
  }