@massimo-cassandro/minimo 1.27.4 → 1.28.0

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.0",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -16,6 +16,7 @@ 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 {(() => boolean) | null} [options.preDelCallback=null] - Called when the row-remove button is pressed, before the row is removed; if it returns false, the removal is aborted. (default: null)
19
20
  * @param {(() => void) | null} [options.del_callback=null] - Called after a row is removed. (default: null)
20
21
  * @param {boolean} [options.insertAtTop=false] - When true, new rows are inserted at the top. (default: false)
21
22
  * @returns {void}
@@ -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,6 +76,10 @@ export function sf_macro({
74
76
  }
75
77
 
76
78
  } else {
79
+ if(preDelCallback && typeof preDelCallback === 'function' && preDelCallback() === false) {
80
+ return;
81
+ }
82
+
77
83
  target.closest(row_selector)?.remove();
78
84
 
79
85
  if(del_callback && typeof del_callback === 'function') {