@cdmx/wappler_ag_grid 2.0.2 → 2.0.4

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,86 @@ 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
+ ## Tooltip Show Delay
230
+
231
+ **Tooltip Show Delay** (Type: number, Default: 2000)
232
+ - Set the delay in milliseconds before tooltips appear when hovering over cells. This helps prevent tooltips from showing immediately and can improve user experience by avoiding accidental tooltip displays.
233
+
234
+ ## Advanced Tooltips with JavaScript Functions
235
+
236
+ The **Using JS Function** feature allows you to create rich HTML tooltips using JavaScript functions. This provides full control over tooltip content and styling.
237
+
238
+ ### Configuration
239
+
240
+ 1. **Field**: The field name for which you want to apply the custom tooltip function.
241
+ 2. **Function**: The name of your JavaScript function that generates the tooltip content.
242
+
243
+ ### JavaScript Function Example
244
+
245
+ ```javascript
246
+ <script>
247
+ // Basic HTML tooltip
248
+ function generateTooltip(data) {
249
+ return `
250
+ <div style="max-width: 250px; font-family: Arial, sans-serif;">
251
+ <h4 style="margin: 0 0 8px 0; color: #333; font-size: 14px;">
252
+ ${data.title}
253
+ </h4>
254
+ <p style="margin: 0 0 8px 0; font-size: 12px; color: #666;">
255
+ ${data.description}
256
+ </p>
257
+ <hr style="margin: 8px 0; border: none; border-top: 1px solid #eee;">
258
+ <div style="font-size: 11px; color: #888;">
259
+ ID: ${data.id} | Status: ${data.status}
260
+ </div>
261
+ </div>
262
+ `;
263
+ }
264
+
265
+ // Rich tooltip with images and styling
266
+ function generateStatusTooltip(data) {
267
+ const statusColor = data.status === 'active' ? '#28a745' : '#dc3545';
268
+ const statusIcon = data.status === 'active' ? '✓' : '✗';
269
+
270
+ return `
271
+ <div style="max-width: 300px; padding: 12px; background: white; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);">
272
+ <div style="display: flex; align-items: center; margin-bottom: 12px;">
273
+ <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;">
274
+ ${statusIcon}
275
+ </div>
276
+ <div>
277
+ <div style="font-weight: bold; font-size: 16px; color: #333;">${data.name}</div>
278
+ <div style="font-size: 12px; color: ${statusColor}; font-weight: 500;">${data.status.toUpperCase()}</div>
279
+ </div>
280
+ </div>
281
+ <div style="border-top: 1px solid #eee; padding-top: 8px;">
282
+ <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px;">
283
+ <div><strong>ID:</strong> ${data.id}</div>
284
+ <div><strong>Type:</strong> ${data.type}</div>
285
+ <div><strong>Created:</strong> ${new Date(data.created_at).toLocaleDateString()}</div>
286
+ <div><strong>Updated:</strong> ${new Date(data.updated_at).toLocaleDateString()}</div>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ `;
291
+ }
292
+ </script>
293
+ ```
212
294
 
213
295
  # Advanced Data Manipulation
214
296
 
@@ -6,7 +6,7 @@
6
6
  "groupTitle": "Components",
7
7
  "groupIcon": "fa fa-lg fa-cube",
8
8
  "title": "AG Grid: @@id@@",
9
- "icon": "fa fa-lg fa-table",
9
+ "icon": "fas fa-lg fa-table",
10
10
  "state": "opened",
11
11
  "anyParent": true,
12
12
  "template": "<dmx-ag-grid id=\"@@id@@\"></dmx-ag-grid>",
@@ -836,6 +836,14 @@
836
836
  "type": "text",
837
837
  "help": "Specify custom tooltip text"
838
838
  },
839
+ {
840
+ "name": "tooltipShowDelay",
841
+ "attribute": "tooltip_show_delay",
842
+ "title": "Tooltip Show Delay (ms)",
843
+ "type": "number",
844
+ "defaultValue": 2000,
845
+ "help": "Delay in milliseconds before showing tooltips (default: 2000ms)"
846
+ },
839
847
  {
840
848
  "name": "tooltipConfig",
841
849
  "title": "Configure Field Tooltips",
@@ -845,7 +853,8 @@
845
853
  "defaultValue": false,
846
854
  "display": "fieldset",
847
855
  "show": [
848
- "tooltipConfig"
856
+ "tooltipConfig",
857
+ "jsTooltipChanges"
849
858
  ],
850
859
  "noChangeOnHide": true,
851
860
  "groupEnabler": true,
@@ -887,6 +896,38 @@
887
896
  "field": "",
888
897
  "tooltip": "no"
889
898
  }
899
+ },
900
+ {
901
+ "name": "jsTooltipChanges",
902
+ "attribute": "dmx-bind:js_tooltip_changes",
903
+ "title": "Using JS Function",
904
+ "type": "grid",
905
+ "dataBindings": true,
906
+ "jsonFormat": true,
907
+ "encloseBT": true,
908
+ "jsonBT": true,
909
+ "initDisplay": "none",
910
+ "columns": [
911
+ {
912
+ "field": "field",
913
+ "caption": "Field",
914
+ "editable": {
915
+ "type": "text"
916
+ }
917
+ },
918
+ {
919
+ "field": "function",
920
+ "caption": "Function",
921
+ "editable": {
922
+ "type": "text"
923
+ }
924
+ }
925
+ ],
926
+ "newRecord": {
927
+ "field": "",
928
+ "function": ""
929
+ },
930
+ "help": "Configure JavaScript functions to generate custom tooltips for specific fields. Functions can return HTML content for rich tooltips."
890
931
  }
891
932
  ]
892
933
  }
package/dmx-ag-grid.js CHANGED
@@ -41,6 +41,8 @@ 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: [] },
45
+ tooltip_show_delay: { type: Number, default: 2000 },
44
46
  data: { type: Array, default: [] },
45
47
  dom_layout: { type: String, default: 'autoHeight' },
46
48
  enable_cell_text_selection: { type: Boolean, default: true },
@@ -1046,6 +1048,48 @@ dmx.Component('ag-grid', {
1046
1048
  return value;
1047
1049
  };
1048
1050
  }
1051
+
1052
+ // Custom HTML Tooltip Component
1053
+ function CustomTooltipComponent() {}
1054
+
1055
+ CustomTooltipComponent.prototype.init = function(params) {
1056
+ const eGui = this.eGui = document.createElement('div');
1057
+ eGui.classList.add('custom-tooltip');
1058
+
1059
+ // Use the dark_mode option from grid configuration
1060
+ const isDarkMode = params.context && params.context.dark_mode ? params.context.dark_mode : false;
1061
+
1062
+ // Apply theme-aware styling
1063
+ if (isDarkMode) {
1064
+ eGui.style.backgroundColor = '#2d3748';
1065
+ eGui.style.border = '1px solid #4a5568';
1066
+ eGui.style.color = '#e2e8f0';
1067
+ } else {
1068
+ eGui.style.backgroundColor = 'white';
1069
+ eGui.style.border = '1px solid #ccc';
1070
+ eGui.style.color = '#333';
1071
+ }
1072
+
1073
+ eGui.style.borderRadius = '4px';
1074
+ eGui.style.padding = '8px';
1075
+ eGui.style.boxShadow = '0 2px 8px rgba(0,0,0,0.15)';
1076
+ eGui.style.maxWidth = '300px';
1077
+ eGui.style.fontSize = '13px';
1078
+ eGui.style.zIndex = '9999';
1079
+
1080
+ const tooltipValue = params.value || params.valueFormatted || '';
1081
+ // Check if the content contains HTML tags
1082
+ if (typeof tooltipValue === 'string' && (tooltipValue.includes('<') && tooltipValue.includes('>'))) {
1083
+ eGui.innerHTML = tooltipValue;
1084
+ } else {
1085
+ eGui.textContent = tooltipValue;
1086
+ }
1087
+ };
1088
+
1089
+ CustomTooltipComponent.prototype.getGui = function() {
1090
+ return this.eGui;
1091
+ };
1092
+
1049
1093
  createCombinedTooltipValueGetter = (key, dataChanges, dataBindedChanges) => {
1050
1094
  const keyLookup = {};
1051
1095
  dataBindedChanges.forEach(change => {
@@ -1084,7 +1128,7 @@ dmx.Component('ag-grid', {
1084
1128
  else if (Array.isArray(options.tooltip_config)) {
1085
1129
  for (const config of options.tooltip_config) {
1086
1130
  if (config.field === key && config.tooltip === "yes") {
1087
- return value;
1131
+ return value;
1088
1132
  }
1089
1133
  }
1090
1134
  }
@@ -1163,6 +1207,8 @@ dmx.Component('ag-grid', {
1163
1207
  let filter;
1164
1208
  let valueGetter;
1165
1209
  let filterValueGetter;
1210
+ let tooltipValueGetter;
1211
+ let tooltipComponent;
1166
1212
  let valueFormatter;
1167
1213
  let filterParams;
1168
1214
  let comparator;
@@ -1283,18 +1329,18 @@ dmx.Component('ag-grid', {
1283
1329
  headerName = humanize(key);
1284
1330
  }
1285
1331
 
1286
- if (options.js_data_changes.length > 0 && Array.isArray(options.js_data_changes)) {
1332
+ if (options.js_data_changes && Array.isArray(options.js_data_changes) && options.js_data_changes.length > 0) {
1287
1333
  // Check if there's a matching change in jsDataChanges
1288
1334
  const matchingJsChange = options.js_data_changes.find(change => change.field === key);
1289
1335
  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;
1336
+ cellRenderer = function (params) {
1337
+ // Don't apply custom renderer to pinned bottom rows (totals)
1338
+ if (params.node && params.node.rowPinned === 'bottom') {
1339
+ return "-";
1340
+ }
1341
+ if (typeof window[matchingJsChange.function] === 'function') {
1342
+ const cellValue = window[matchingJsChange.function](params.data);
1343
+ return cellValue;
1298
1344
  }
1299
1345
  }
1300
1346
  }
@@ -1307,6 +1353,22 @@ dmx.Component('ag-grid', {
1307
1353
  cellRenderer = undefined;
1308
1354
  colId = undefined;
1309
1355
  }
1356
+
1357
+ // Handle JS tooltip changes
1358
+ if (options.js_tooltip_changes && Array.isArray(options.js_tooltip_changes) && options.js_tooltip_changes.length > 0) {
1359
+ const tooltipChange = options.js_tooltip_changes.find(change => change.field === key);
1360
+ if (tooltipChange) {
1361
+ tooltipValueGetter = (params) => {
1362
+ if (typeof window[tooltipChange.function] === 'function') {
1363
+ return window[tooltipChange.function](params.data);
1364
+ }
1365
+ return params.value;
1366
+ };
1367
+
1368
+ // Use custom tooltip component for HTML rendering
1369
+ tooltipComponent = 'CustomTooltipComponent';
1370
+ }
1371
+ }
1310
1372
  if (key =='status' && options.row_status_event) {
1311
1373
  cellRenderer = 'checkboxCellRenderer';
1312
1374
  colId = 'statusColumn';
@@ -1412,7 +1474,34 @@ dmx.Component('ag-grid', {
1412
1474
  filterValueGetter: filterValueGetter,
1413
1475
  filterParams: filterParams,
1414
1476
  comparator: comparator,
1415
- tooltipValueGetter: tooltipValueGetter,
1477
+ ...(tooltipComponent ? {
1478
+ tooltipComponent: tooltipComponent,
1479
+ tooltipValueGetter: tooltipValueGetter
1480
+ } : tooltipValueGetter && typeof tooltipValueGetter === 'function' ? (() => {
1481
+ // Check if tooltip content contains HTML
1482
+ const sampleParams = { data: rowData[0] || {}, value: '' };
1483
+ const sampleTooltip = tooltipValueGetter(sampleParams);
1484
+ const containsHtml = typeof sampleTooltip === 'string' &&
1485
+ (sampleTooltip.includes('<') && sampleTooltip.includes('>'));
1486
+
1487
+ return containsHtml ? {
1488
+ tooltipComponent: 'CustomTooltipComponent',
1489
+ tooltipValueGetter: tooltipValueGetter
1490
+ } : {
1491
+ tooltipValueGetter: tooltipValueGetter
1492
+ };
1493
+ })() : tooltipValueGetter && typeof tooltipValueGetter === 'object' && tooltipValueGetter.isHtml ? {
1494
+ tooltipComponent: function(params) {
1495
+ return {
1496
+ getGui: function() {
1497
+ const element = document.createElement('div');
1498
+ element.innerHTML = tooltipValueGetter.htmlContent;
1499
+ element.className = 'ag-tooltip-custom';
1500
+ return element;
1501
+ }
1502
+ };
1503
+ }
1504
+ } : {}),
1416
1505
  cellStyle: applyCellStyle,
1417
1506
  ...(cwidths.hasOwnProperty(key) && {
1418
1507
  minWidth: parseInt(cwidths[key].min_width),
@@ -1570,6 +1659,9 @@ dmx.Component('ag-grid', {
1570
1659
  getRowStyle: options.rstyles ? createRowStyleFunction(options.rstyles): undefined,
1571
1660
  localeText: localeText,
1572
1661
  enableRtl: options.enable_rtl,
1662
+ context: {
1663
+ dark_mode: options.dark_mode
1664
+ },
1573
1665
  onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
1574
1666
  onRowDoubleClicked: enableRowDoubleClickEvent ? onRowDoubleClicked : undefined,
1575
1667
  onCellClicked: enableCellClickEvent ? onCellClicked : undefined,
@@ -1612,6 +1704,7 @@ dmx.Component('ag-grid', {
1612
1704
  suppressClipboardPaste: this.props.suppress_clipboard_paste,
1613
1705
  suppressScrollOnNewData: this.props.suppress_scroll_on_new_data,
1614
1706
  columnHoverHighlight: this.props.column_hover_highlight,
1707
+ tooltipShowDelay: options.tooltip_show_delay,
1615
1708
  onFilterModified: function (params) {
1616
1709
  const columnApi = params.api;
1617
1710
  const rowCount = columnApi.getDisplayedRowCount();
@@ -1727,7 +1820,8 @@ dmx.Component('ag-grid', {
1727
1820
  components: {
1728
1821
  clickCellRenderer: clickCellRenderer,
1729
1822
  checkboxCellRenderer: checkboxCellRenderer,
1730
- actionsRenderer: actionsRenderer
1823
+ actionsRenderer: actionsRenderer,
1824
+ CustomTooltipComponent: CustomTooltipComponent
1731
1825
  }
1732
1826
  };
1733
1827
  if (options.row_checkbox_event) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
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",
7
7
  "author": {
8
- "name": "cdmx1",
9
- "url": "https://github.com/cdmx1"
8
+ "name": "cdmx-in",
9
+ "url": "https://github.com/cdmx-in"
10
10
  },
11
11
  "keywords": [
12
12
  "wappler-extension",