@lowdefy/blocks-aggrid 4.0.0-alpha.19 → 4.0.0-alpha.22

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,8 +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 { renderHtml } from '@lowdefy/block-utils';
33
- import { type } from '@lowdefy/helpers';
32
+ import processColDefs from './processColDefs.js';
34
33
  let AgGrid = class AgGrid extends React.Component {
35
34
  // see https://stackoverflow.com/questions/55182118/ag-grid-resize-detail-height-when-data-changes
36
35
  componentDidUpdate() {
@@ -126,20 +125,6 @@ let AgGrid = class AgGrid extends React.Component {
126
125
  if (quickFilterValue && quickFilterValue === '') {
127
126
  this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
128
127
  }
129
- const newColDefs = (columnDefs || []).map((col)=>{
130
- if (type.isFunction(col.cellRenderer)) {
131
- return {
132
- ...col,
133
- cellRenderer: (params)=>{
134
- return renderHtml({
135
- html: col.cellRenderer(params),
136
- methods: this.props.methods
137
- });
138
- }
139
- };
140
- }
141
- return col;
142
- });
143
128
  return /*#__PURE__*/ React.createElement(AgGridReact, _extends({
144
129
  onFilterChanged: this.onFilterChanged,
145
130
  onSelectionChanged: this.onSelectionChanged,
@@ -148,7 +133,7 @@ let AgGrid = class AgGrid extends React.Component {
148
133
  onCellClicked: this.onCellClicked,
149
134
  onGridReady: this.onGridReady,
150
135
  modules: AllCommunityModules,
151
- columnDefs: newColDefs
136
+ columnDefs: processColDefs(columnDefs, this.props.methods)
152
137
  }, someProperties));
153
138
  }
154
139
  constructor(props){
@@ -29,8 +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 { renderHtml } from '@lowdefy/block-utils';
33
- import { type } from '@lowdefy/helpers';
32
+ import processColDefs from './processColDefs.js';
34
33
  let AgGridInput = class AgGridInput extends React.Component {
35
34
  // see https://stackoverflow.com/questions/55182118/ag-grid-resize-detail-height-when-data-changes
36
35
  componentDidUpdate() {
@@ -168,20 +167,6 @@ let AgGridInput = class AgGridInput extends React.Component {
168
167
  if (quickFilterValue && quickFilterValue === '') {
169
168
  this.gridApi.setQuickFilter(quickFilterValue); // check if empty string matches all
170
169
  }
171
- const newColDefs = (columnDefs || []).map((col)=>{
172
- if (type.isFunction(col.cellRenderer)) {
173
- return {
174
- ...col,
175
- cellRenderer: (params)=>{
176
- return renderHtml({
177
- html: col.cellRenderer(params),
178
- methods: this.props.methods
179
- });
180
- }
181
- };
182
- }
183
- return col;
184
- });
185
170
  return /*#__PURE__*/ React.createElement(AgGridReact, _extends({
186
171
  onSelectionChanged: this.onSelectionChanged,
187
172
  onRowSelected: this.onRowSelected,
@@ -192,7 +177,7 @@ let AgGridInput = class AgGridInput extends React.Component {
192
177
  onCellValueChanged: this.onCellValueChanged,
193
178
  postSort: this.postSort,
194
179
  modules: AllCommunityModules,
195
- columnDefs: newColDefs
180
+ columnDefs: processColDefs(columnDefs, this.props.methods)
196
181
  }, someProperties, {
197
182
  rowData: this.props.value
198
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, methods) {
18
+ return columnDefs.map((col)=>{
19
+ const newColDef = {};
20
+ if (type.isArray(col.children)) {
21
+ newColDef.children = recProcessColDefs(col.children, methods);
22
+ }
23
+ if (type.isFunction(col.cellRenderer)) {
24
+ newColDef.cellRenderer = (params)=>{
25
+ return renderHtml({
26
+ html: col.cellRenderer(params),
27
+ methods
28
+ });
29
+ };
30
+ }
31
+ return {
32
+ ...col,
33
+ ...newColDef
34
+ };
35
+ });
36
+ }
37
+ function processColDefs(columnDefs = [], methods) {
38
+ return recProcessColDefs(columnDefs, methods);
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.19",
3
+ "version": "4.0.0-alpha.22",
4
4
  "license": "Apache-2.0",
5
5
  "description": "AgGrid Blocks for Lowdefy.",
6
6
  "homepage": "https://lowdefy.com",
@@ -54,15 +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.19",
58
- "@lowdefy/helpers": "4.0.0-alpha.19",
57
+ "@lowdefy/block-utils": "4.0.0-alpha.22",
58
+ "@lowdefy/helpers": "4.0.0-alpha.22",
59
59
  "react": "18.1.0",
60
60
  "react-dom": "18.1.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@emotion/jest": "11.9.1",
64
- "@lowdefy/block-dev": "4.0.0-alpha.19",
65
- "@lowdefy/jest-yaml-transform": "4.0.0-alpha.19",
64
+ "@lowdefy/block-dev": "4.0.0-alpha.22",
65
+ "@lowdefy/jest-yaml-transform": "4.0.0-alpha.22",
66
66
  "@swc/cli": "0.1.57",
67
67
  "@swc/core": "1.2.194",
68
68
  "@swc/jest": "0.2.21",
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "5240a074f7225295a8c92aaf0236b7680c296b57"
80
+ "gitHead": "66ce29562c016a8bcf0cbea4bbbbb71d364ae995"
81
81
  }