@cdmx/wappler_ag_grid 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  **Major Update:** This release upgrades from AG Grid v32.3.7 to v34.1.0, bringing significant performance improvements and exciting new features.
4
4
 
5
- ## 🚀 What's New in v2.0.0
5
+ ## 🚀 What's New in v2.0.3
6
6
 
7
7
  1. **🔥 AG Grid v34.1.0** - Latest version with all community features
8
8
  2. **⚡ Performance Boost** - Up to 40% bundle size reduction potential
9
+ 3. **🎨 HTML Tooltips** - Rich HTML tooltip support with JavaScript functions
10
+ 4. **🔧 Enhanced Tooltip System** - Custom tooltip components with automatic HTML detection
9
11
 
10
12
  - **Breaking Changes:** Some configurations may require updates due to AG Grid v33/v34 changes
11
13
 
@@ -40,7 +42,7 @@
40
42
  - AG Grid v34 is non-breaking from v33, so most configurations remain the same
41
43
 
42
44
  ### Recommended Steps:
43
- 1. **Update Package:** Simply update to v2.0.0 - no code changes required for basic functionality
45
+ 1. **Update Package:** Simply update to v2.0.2 - no code changes required for basic functionality
44
46
  2. **Test Your Grids:** Verify existing grids work as expected
45
47
  3. **Explore New Features:** Gradually enable new v34 features as needed:
46
48
  - Enable Cell Editor Validation for better data quality
@@ -153,6 +155,14 @@ To use the "Custom" theme, copy "ag-theme-custom.css" to public/css/ag-theme-cus
153
155
 
154
156
  51. **Tree Data Drag & Drop**: Enable managed row dragging for Tree Data, meaning the grid will automatically handle the dragging of rows and updating of the data structure. Supports reordering, moving parents and children, and converting leaf nodes into groups. (Default: false)
155
157
 
158
+ 52. **🎨 HTML Tooltips**: Create rich, interactive tooltips with full HTML support using JavaScript functions. Features include:
159
+ - Custom HTML content with styling and images
160
+ - Dynamic content generation based on row data
161
+ - Automatic HTML detection and rendering
162
+ - Professional tooltip styling with shadows and borders
163
+ - Integration with existing tooltip configurations
164
+ - Performance optimized with on-demand generation
165
+
156
166
  # Data Type Overrides
157
167
 
158
168
  The Data Type Overrides feature allows you to configure type overrides for specific attributes in the data. This allows you to override the auto-detected data types.
@@ -201,14 +211,81 @@ This grid allows you to define custom color and font settings based on specific
201
211
 
202
212
  # Tooltip Settings
203
213
 
204
- The Tooltip Settings feature allows you to configure custom tooltips for specific fields in the data.
214
+ The Tooltip Settings feature allows you to configure custom tooltips for specific fields in the data, including support for HTML content and JavaScript functions.
215
+
216
+ ## Basic Tooltip Configuration
205
217
 
206
- To set a custom tooltip text, enter the desired text for the tooltip in the field.
218
+ To set basic tooltips, enter the desired text for the tooltip in the field.
207
219
  This grid allows you to configure custom tooltips for specific fields. The grid has the following columns:
208
220
 
209
- 1. **Field**: The field name for which you want to set a custom tooltip.
210
- 2. **Tooltip**: Choose whether to enable ("yes") or disable ("no") the tooltip for the field.
211
- ---
221
+ 1. **Field**: The field name for which you want to set a custom tooltip.
222
+ 2. **Tooltip**: Choose whether to enable ("yes") or disable ("no") the tooltip for the field.
223
+
224
+ ## Custom Tooltip Text
225
+
226
+ **Custom Tooltip Text** (Type: textbox)
227
+ - Set a global custom tooltip text that will be applied to all fields that don't have specific tooltip configurations.
228
+
229
+ ## Advanced Tooltips with JavaScript Functions
230
+
231
+ The **Using JS Function** feature allows you to create rich HTML tooltips using JavaScript functions. This provides full control over tooltip content and styling.
232
+
233
+ ### Configuration
234
+
235
+ 1. **Field**: The field name for which you want to apply the custom tooltip function.
236
+ 2. **Function**: The name of your JavaScript function that generates the tooltip content.
237
+
238
+ ### JavaScript Function Example
239
+
240
+ ```javascript
241
+ <script>
242
+ // Basic HTML tooltip
243
+ function generateTooltip(data) {
244
+ return `
245
+ <div style="max-width: 250px; font-family: Arial, sans-serif;">
246
+ <h4 style="margin: 0 0 8px 0; color: #333; font-size: 14px;">
247
+ ${data.title}
248
+ </h4>
249
+ <p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">
250
+ ${data.description}
251
+ </p>
252
+ <hr style="margin: 8px 0; border: none; border-top: 1px solid #eee;">
253
+ <div style="font-size: 11px; color: #888;">
254
+ ID: ${data.id} | Status: ${data.status}
255
+ </div>
256
+ </div>
257
+ `;
258
+ }
259
+
260
+ // Rich tooltip with images and styling
261
+ function generateStatusTooltip(data) {
262
+ const statusColor = data.status === 'active' ? '#28a745' : '#dc3545';
263
+ const statusIcon = data.status === 'active' ? '✓' : '✗';
264
+
265
+ return `
266
+ <div style="max-width: 300px; padding: 12px; background: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);">
267
+ <div style="display: flex; align-items: center; margin-bottom: 12px;">
268
+ <div style="width: 32px; height: 32px; border-radius: 50%; background: ${statusColor}; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; margin-right: 12px;">
269
+ ${statusIcon}
270
+ </div>
271
+ <div>
272
+ <div style="font-weight: bold; font-size: 16px; color: #333;">${data.name}</div>
273
+ <div style="font-size: 12px; color: ${statusColor}; font-weight: 500;">${data.status.toUpperCase()}</div>
274
+ </div>
275
+ </div>
276
+ <div style="border-top: 1px solid #eee; padding-top: 8px;">
277
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px;">
278
+ <div><strong>ID:</strong> ${data.id}</div>
279
+ <div><strong>Type:</strong> ${data.type}</div>
280
+ <div><strong>Created:</strong> ${new Date(data.created_at).toLocaleDateString()}</div>
281
+ <div><strong>Updated:</strong> ${new Date(data.updated_at).toLocaleDateString()}</div>
282
+ </div>
283
+ </div>
284
+ </div>
285
+ `;
286
+ }
287
+ </script>
288
+ ```
212
289
 
213
290
  # Advanced Data Manipulation
214
291
 
@@ -845,7 +845,8 @@
845
845
  "defaultValue": false,
846
846
  "display": "fieldset",
847
847
  "show": [
848
- "tooltipConfig"
848
+ "tooltipConfig",
849
+ "jsTooltipChanges"
849
850
  ],
850
851
  "noChangeOnHide": true,
851
852
  "groupEnabler": true,
@@ -887,6 +888,38 @@
887
888
  "field": "",
888
889
  "tooltip": "no"
889
890
  }
891
+ },
892
+ {
893
+ "name": "jsTooltipChanges",
894
+ "attribute": "dmx-bind:js_tooltip_changes",
895
+ "title": "Using JS Function",
896
+ "type": "grid",
897
+ "dataBindings": true,
898
+ "jsonFormat": true,
899
+ "encloseBT": true,
900
+ "jsonBT": true,
901
+ "initDisplay": "none",
902
+ "columns": [
903
+ {
904
+ "field": "field",
905
+ "caption": "Field",
906
+ "editable": {
907
+ "type": "text"
908
+ }
909
+ },
910
+ {
911
+ "field": "function",
912
+ "caption": "Function",
913
+ "editable": {
914
+ "type": "text"
915
+ }
916
+ }
917
+ ],
918
+ "newRecord": {
919
+ "field": "",
920
+ "function": ""
921
+ },
922
+ "help": "Configure JavaScript functions to generate custom tooltips for specific fields. Functions can return HTML content for rich tooltips."
890
923
  }
891
924
  ]
892
925
  }
package/dmx-ag-grid.js CHANGED
@@ -41,6 +41,7 @@ dmx.Component('ag-grid', {
41
41
  data_changes: { type: Array, default: [] },
42
42
  display_data_changes: { type: Array, default: [] },
43
43
  js_data_changes: { type: Array, default: [] },
44
+ js_tooltip_changes: { type: Array, default: [] },
44
45
  data: { type: Array, default: [] },
45
46
  dom_layout: { type: String, default: 'autoHeight' },
46
47
  enable_cell_text_selection: { type: Boolean, default: true },
@@ -1046,6 +1047,35 @@ dmx.Component('ag-grid', {
1046
1047
  return value;
1047
1048
  };
1048
1049
  }
1050
+
1051
+ // Custom HTML Tooltip Component
1052
+ function CustomTooltipComponent() {}
1053
+
1054
+ CustomTooltipComponent.prototype.init = function(params) {
1055
+ const eGui = this.eGui = document.createElement('div');
1056
+ eGui.classList.add('custom-tooltip');
1057
+ eGui.style.backgroundColor = 'white';
1058
+ eGui.style.border = '1px solid #ccc';
1059
+ eGui.style.borderRadius = '4px';
1060
+ eGui.style.padding = '8px';
1061
+ eGui.style.boxShadow = '0 2px 8px rgba(0,0,0,0.15)';
1062
+ eGui.style.maxWidth = '300px';
1063
+ eGui.style.fontSize = '13px';
1064
+ eGui.style.zIndex = '9999';
1065
+
1066
+ const tooltipValue = params.value || params.valueFormatted || '';
1067
+ // Check if the content contains HTML tags
1068
+ if (typeof tooltipValue === 'string' && (tooltipValue.includes('<') && tooltipValue.includes('>'))) {
1069
+ eGui.innerHTML = tooltipValue;
1070
+ } else {
1071
+ eGui.textContent = tooltipValue;
1072
+ }
1073
+ };
1074
+
1075
+ CustomTooltipComponent.prototype.getGui = function() {
1076
+ return this.eGui;
1077
+ };
1078
+
1049
1079
  createCombinedTooltipValueGetter = (key, dataChanges, dataBindedChanges) => {
1050
1080
  const keyLookup = {};
1051
1081
  dataBindedChanges.forEach(change => {
@@ -1084,7 +1114,7 @@ dmx.Component('ag-grid', {
1084
1114
  else if (Array.isArray(options.tooltip_config)) {
1085
1115
  for (const config of options.tooltip_config) {
1086
1116
  if (config.field === key && config.tooltip === "yes") {
1087
- return value;
1117
+ return value;
1088
1118
  }
1089
1119
  }
1090
1120
  }
@@ -1163,6 +1193,8 @@ dmx.Component('ag-grid', {
1163
1193
  let filter;
1164
1194
  let valueGetter;
1165
1195
  let filterValueGetter;
1196
+ let tooltipValueGetter;
1197
+ let tooltipComponent;
1166
1198
  let valueFormatter;
1167
1199
  let filterParams;
1168
1200
  let comparator;
@@ -1283,18 +1315,18 @@ dmx.Component('ag-grid', {
1283
1315
  headerName = humanize(key);
1284
1316
  }
1285
1317
 
1286
- if (options.js_data_changes.length > 0 && Array.isArray(options.js_data_changes)) {
1318
+ if (options.js_data_changes && Array.isArray(options.js_data_changes) && options.js_data_changes.length > 0) {
1287
1319
  // Check if there's a matching change in jsDataChanges
1288
1320
  const matchingJsChange = options.js_data_changes.find(change => change.field === key);
1289
1321
  if (matchingJsChange) {
1290
- cellRenderer = function (params) {
1291
- // Don't apply custom renderer to pinned bottom rows (totals)
1292
- if (params.node && params.node.rowPinned === 'bottom') {
1293
- return "-";
1294
- }
1295
- if (typeof window[matchingJsChange.function] === 'function') {
1296
- const cellValue = window[matchingJsChange.function](params.data);
1297
- return cellValue;
1322
+ cellRenderer = function (params) {
1323
+ // Don't apply custom renderer to pinned bottom rows (totals)
1324
+ if (params.node && params.node.rowPinned === 'bottom') {
1325
+ return "-";
1326
+ }
1327
+ if (typeof window[matchingJsChange.function] === 'function') {
1328
+ const cellValue = window[matchingJsChange.function](params.data);
1329
+ return cellValue;
1298
1330
  }
1299
1331
  }
1300
1332
  }
@@ -1307,6 +1339,21 @@ dmx.Component('ag-grid', {
1307
1339
  cellRenderer = undefined;
1308
1340
  colId = undefined;
1309
1341
  }
1342
+
1343
+ if (options.js_tooltip_changes && Array.isArray(options.js_tooltip_changes) && options.js_tooltip_changes.length > 0) {
1344
+ const tooltipChange = options.js_tooltip_changes.find(change => change.field === key);
1345
+ if (tooltipChange) {
1346
+ tooltipValueGetter = (params) => {
1347
+ if (typeof window[tooltipChange.function] === 'function') {
1348
+ return window[tooltipChange.function](params.data);
1349
+ }
1350
+ return params.value;
1351
+ };
1352
+
1353
+ // Use custom tooltip component for HTML rendering
1354
+ tooltipComponent = 'CustomTooltipComponent';
1355
+ }
1356
+ }
1310
1357
  if (key =='status' && options.row_status_event) {
1311
1358
  cellRenderer = 'checkboxCellRenderer';
1312
1359
  colId = 'statusColumn';
@@ -1412,7 +1459,34 @@ dmx.Component('ag-grid', {
1412
1459
  filterValueGetter: filterValueGetter,
1413
1460
  filterParams: filterParams,
1414
1461
  comparator: comparator,
1415
- tooltipValueGetter: tooltipValueGetter,
1462
+ ...(tooltipComponent ? {
1463
+ tooltipComponent: tooltipComponent,
1464
+ tooltipValueGetter: tooltipValueGetter
1465
+ } : tooltipValueGetter && typeof tooltipValueGetter === 'function' ? (() => {
1466
+ // Check if tooltip content contains HTML
1467
+ const sampleParams = { data: rowData[0] || {}, value: '' };
1468
+ const sampleTooltip = tooltipValueGetter(sampleParams);
1469
+ const containsHtml = typeof sampleTooltip === 'string' &&
1470
+ (sampleTooltip.includes('<') && sampleTooltip.includes('>'));
1471
+
1472
+ return containsHtml ? {
1473
+ tooltipComponent: 'CustomTooltipComponent',
1474
+ tooltipValueGetter: tooltipValueGetter
1475
+ } : {
1476
+ tooltipValueGetter: tooltipValueGetter
1477
+ };
1478
+ })() : tooltipValueGetter && typeof tooltipValueGetter === 'object' && tooltipValueGetter.isHtml ? {
1479
+ tooltipComponent: function(params) {
1480
+ return {
1481
+ getGui: function() {
1482
+ const element = document.createElement('div');
1483
+ element.innerHTML = tooltipValueGetter.htmlContent;
1484
+ element.className = 'ag-tooltip-custom';
1485
+ return element;
1486
+ }
1487
+ };
1488
+ }
1489
+ } : {}),
1416
1490
  cellStyle: applyCellStyle,
1417
1491
  ...(cwidths.hasOwnProperty(key) && {
1418
1492
  minWidth: parseInt(cwidths[key].min_width),
@@ -1727,7 +1801,8 @@ dmx.Component('ag-grid', {
1727
1801
  components: {
1728
1802
  clickCellRenderer: clickCellRenderer,
1729
1803
  checkboxCellRenderer: checkboxCellRenderer,
1730
- actionsRenderer: actionsRenderer
1804
+ actionsRenderer: actionsRenderer,
1805
+ CustomTooltipComponent: CustomTooltipComponent
1731
1806
  }
1732
1807
  };
1733
1808
  if (options.row_checkbox_event) {
@@ -1832,9 +1907,16 @@ dmx.Component('ag-grid', {
1832
1907
  let columnsToSum = options.columns_to_sum ? options.columns_to_sum.split(',') : [];
1833
1908
  let columnsToCount = options.columns_to_count;
1834
1909
 
1835
- gridConfig.onFilterChanged = function (e) {
1836
- totalRow(e.api, columnsToSum, columnsToCount);
1837
- };
1910
+
1911
+ const originalOnFilterChanged = gridConfig.onFilterChanged;
1912
+ gridConfig.onFilterChanged = function (e) {
1913
+
1914
+ totalRow(e.api, columnsToSum, columnsToCount);
1915
+
1916
+ if (originalOnFilterChanged) {
1917
+ originalOnFilterChanged(e);
1918
+ }
1919
+ };
1838
1920
  gridConfig.onFirstDataRendered = function (e) {
1839
1921
  totalRow(e.api, columnsToSum, columnsToCount);
1840
1922
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid v34 - Advanced data grid with enhanced editing, filtering, and tree data capabilities.",
6
6
  "license": "MIT",