@massimo-cassandro/minimo 1.27.4 → 1.28.1

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": "1.27.4",
3
+ "version": "1.28.1",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -16,7 +16,8 @@ import './sf-macro.css';
16
16
  * @param {string} [options.addBtnClass='sf-macro-riga-add'] - Class name of the row-add button. (default: 'sf-macro-riga-add')
17
17
  * @param {string} [options.containerClass='sf-macro-container'] - Class name of the rows container. (default: 'sf-macro-container')
18
18
  * @param {((newRow: Element | null, addBtn: Element | null) => void) | null} [options.add_callback=null] - Called after a row is added; receives the new row and the add button. (default: null)
19
- * @param {(() => void) | null} [options.del_callback=null] - Called after a row is removed. (default: null)
19
+ * @param {((row: Element | null, closeBtn: Element | null) => boolean) | null} [options.preDelCallback=null] - Called when the row-remove button is pressed, before the row is removed; receives the row and the close button; if it returns false, the removal is aborted. (default: null)
20
+ * @param {((row: Element | null, closeBtn: Element | null) => void) | null} [options.del_callback=null] - Called after a row is removed; receives the removed row (now detached) and the close button. (default: null)
20
21
  * @param {boolean} [options.insertAtTop=false] - When true, new rows are inserted at the top. (default: false)
21
22
  * @returns {void}
22
23
  */
@@ -30,6 +31,7 @@ export function sf_macro({
30
31
  addBtnClass = 'sf-macro-riga-add',
31
32
  containerClass = 'sf-macro-container',
32
33
  add_callback = null,
34
+ preDelCallback = null,
33
35
  del_callback = null,
34
36
  insertAtTop = false
35
37
  }={}) {
@@ -74,10 +76,16 @@ export function sf_macro({
74
76
  }
75
77
 
76
78
  } else {
77
- target.closest(row_selector)?.remove();
79
+ const riga = target.closest(row_selector);
80
+
81
+ if(preDelCallback && typeof preDelCallback === 'function' && preDelCallback(riga, action_btn) === false) {
82
+ return;
83
+ }
84
+
85
+ riga?.remove();
78
86
 
79
87
  if(del_callback && typeof del_callback === 'function') {
80
- del_callback();
88
+ del_callback(riga, action_btn);
81
89
  }
82
90
  }
83
91