@massimo-cassandro/minimo 0.12.0 → 0.12.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/massimo-cassandro/minimo#readme",
@@ -88,7 +88,7 @@ import caretRightIcon from '../../icons/caret-right.svg?inline';
88
88
  * getNestedValue(row, 'ciclo.ciclo') → row.ciclo.ciclo
89
89
  */
90
90
  function getNestedValue(obj, path) {
91
- return path.split('.').reduce((acc, key) => acc?.[key], obj);
91
+ return path?.split('.')?.reduce((acc, key) => acc?.[key], obj) ?? null;
92
92
  }
93
93
 
94
94
 
@@ -369,27 +369,38 @@ class SimpleDatatableAdapter extends HTMLElement {
369
369
  : (getNestedValue(row, col_item._sortValue) ?? '')
370
370
  : null;
371
371
 
372
+
373
+ // _renderTpl: template per il rendering del valore
374
+ // se stringa contiene le chiavi da renderizzare in formato mustache-like ([[key]])
375
+ // se funzione ha come argomento la riga dati
372
376
  if (col_item._renderTpl) {
373
- value = decodeURIComponent(col_item._renderTpl).replace(
374
- /\[\[(.*?)\]\]/g,
375
- (match, key) => {
376
- const resolved = getNestedValue(row, key);
377
- const pathParts = key.split('.');
378
- const parentObj = pathParts.length > 1
379
- ? getNestedValue(row, pathParts.slice(0, -1).join('.'))
380
- : row;
381
-
382
- // Segnala solo se il padre esiste ma la chiave foglia manca
383
- // (errore di configurazione). Se il padre è null il dato è
384
- // semplicemente assente (es. Symfony restituisce owner: null).
385
- if (parentObj != null && !Object.prototype.hasOwnProperty.call(parentObj, pathParts.at(-1))) {
386
- // eslint-disable-next-line no-console
387
- console.error(`[s-datatable] Chiave "${key}" non trovata nella struttura dati (colonna ${col_idx})`);
377
+ if(typeof col_item._renderTpl === 'string') {
378
+
379
+ value = decodeURIComponent(col_item._renderTpl).replace(
380
+ /\[\[(.*?)\]\]/g,
381
+ (match, key) => {
382
+ const resolved = getNestedValue(row, key);
383
+ const pathParts = key.split('.');
384
+ const parentObj = pathParts.length > 1
385
+ ? getNestedValue(row, pathParts.slice(0, -1).join('.'))
386
+ : row;
387
+
388
+ // Segnala solo se il padre esiste ma la chiave foglia manca
389
+ // (errore di configurazione). Se il padre è null il dato è
390
+ // semplicemente assente (es. Symfony restituisce owner: null).
391
+ if (parentObj != null && !Object.prototype.hasOwnProperty.call(parentObj, pathParts.at(-1))) {
392
+ // eslint-disable-next-line no-console
393
+ console.error(`[s-datatable] Chiave "${key}" non trovata nella struttura dati (colonna ${col_idx})`);
394
+ }
395
+
396
+ return resolved ?? nullAs;
388
397
  }
398
+ );
399
+
400
+ } else if (typeof col_item._renderTpl === 'function') {
401
+ value = col_item._renderTpl(row);
402
+ }
389
403
 
390
- return resolved ?? nullAs;
391
- }
392
- );
393
404
  } else if (col_item._renderMode === 'sf_datetime' && value != null) {
394
405
  value = value.date.replace(' ', 'T') +
395
406
  (value.timezone === 'UTC' ? 'Z' : '');