@massimo-cassandro/minimo 1.27.2 → 1.27.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/package.json
CHANGED
|
@@ -284,8 +284,7 @@ export default function (params = {}) {
|
|
|
284
284
|
}
|
|
285
285
|
}); // end autoComplete
|
|
286
286
|
|
|
287
|
-
// TODO
|
|
288
|
-
// improve and make the callback invocation more efficient
|
|
287
|
+
// TODO improve and make the callback invocation more efficient
|
|
289
288
|
|
|
290
289
|
// reset hidden field when the autocomplete value is cleared or mismatched
|
|
291
290
|
const check_ac = () => {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/*! minimo - Symfony Macro Manager */
|
|
2
2
|
import './sf-macro.css';
|
|
3
3
|
|
|
4
|
+
// TODO[epic=v2] in una v. 2 di minimo, rinominare wrapper_selector e row_selector in
|
|
5
|
+
// wrapperClass e rowClass (NB: classi, non selettori, per uniformità con closeBtnClass/addBtnClass/containerClass
|
|
6
|
+
// aggiunti sotto) e rendere tutti i parametri camelCase.
|
|
7
|
+
// TODO[epic=v2] valutare se rendere opzionale, tramite parametro, l'importazione statica
|
|
8
|
+
// di sf-macro.css qui sopra (questione lasciata in sospeso).
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* Initialises Symfony macro collection fields (repeatable fieldsets).
|
|
6
12
|
* @param {Object} [options={}]
|
|
7
13
|
* @param {string} [options.wrapper_selector='.sf-macro-wrapper'] - Selector for the outer wrapper element.
|
|
8
14
|
* @param {string} [options.row_selector='.sf-macro-riga'] - Selector for each repeatable row.
|
|
15
|
+
* @param {string} [options.closeBtnClass='sf-macro-close-btn'] - Class name of the row-remove button.
|
|
16
|
+
* @param {string} [options.addBtnClass='sf-macro-riga-add'] - Class name of the row-add button.
|
|
17
|
+
* @param {string} [options.containerClass='sf-macro-container'] - Class name of the rows container.
|
|
9
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.
|
|
10
19
|
* @param {(() => void) | null} [options.del_callback=null] - Called after a row is removed.
|
|
11
20
|
* @param {boolean} [options.insertAtTop=false] - When true, new rows are inserted at the top.
|
|
@@ -14,6 +23,12 @@ import './sf-macro.css';
|
|
|
14
23
|
export function sf_macro({
|
|
15
24
|
wrapper_selector = '.sf-macro-wrapper',
|
|
16
25
|
row_selector = '.sf-macro-riga',
|
|
26
|
+
// Change closeBtnClass/addBtnClass/containerClass only if you don't want to use
|
|
27
|
+
// the default sf-macro.css: unused default classes are not stripped by this
|
|
28
|
+
// component, that cleanup is delegated to PurgeCSS (or equivalent) downstream.
|
|
29
|
+
closeBtnClass = 'sf-macro-close-btn',
|
|
30
|
+
addBtnClass = 'sf-macro-riga-add',
|
|
31
|
+
containerClass = 'sf-macro-container',
|
|
17
32
|
add_callback = null,
|
|
18
33
|
del_callback = null,
|
|
19
34
|
insertAtTop = false
|
|
@@ -30,17 +45,17 @@ export function sf_macro({
|
|
|
30
45
|
const target = /** @type {HTMLElement} */ (e.target);
|
|
31
46
|
|
|
32
47
|
const action_btn = /** @type {HTMLElement | null} */ (
|
|
33
|
-
target.closest(
|
|
48
|
+
target.closest(`.${addBtnClass}, .${closeBtnClass}`)
|
|
34
49
|
);
|
|
35
50
|
if (!action_btn) return;
|
|
36
51
|
|
|
37
52
|
const fset = /** @type {HTMLElement | null} */ (target.closest(wrapper_selector));
|
|
38
53
|
if (!fset) return;
|
|
39
54
|
|
|
40
|
-
const macro_container = /** @type {HTMLElement | null} */ (fset.querySelector(
|
|
55
|
+
const macro_container = /** @type {HTMLElement | null} */ (fset.querySelector(`.${containerClass}`));
|
|
41
56
|
if (!macro_container) return;
|
|
42
57
|
|
|
43
|
-
if(action_btn.matches(
|
|
58
|
+
if(action_btn.matches(`.${addBtnClass}`)) {
|
|
44
59
|
|
|
45
60
|
const macro_template = macro_container.dataset.template ?? '';
|
|
46
61
|
const righe_macro = macro_container.querySelectorAll(row_selector).length;
|