@massimo-cassandro/minimo 1.27.0 → 1.27.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": "1.27.0",
3
+ "version": "1.27.2",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -19,41 +19,52 @@ export function sf_macro({
19
19
  insertAtTop = false
20
20
  }={}) {
21
21
 
22
- document.querySelectorAll(wrapper_selector).forEach(fset => {
22
+ // Single delegated listener: resolves the nearest wrapper_selector ancestor
23
+ // of the click target at click time, instead of binding one listener per
24
+ // wrapper found at init time. This is required for wrapper_selector to be
25
+ // shared by nested wrapper instances (the nearest one always wins, with no
26
+ // propagation to outer ones) and to work on wrappers created dynamically
27
+ // after this call (e.g. a nested wrapper inside a newly added row), which
28
+ // would otherwise never get their own listener.
29
+ document.addEventListener('click', e => {
30
+ const target = /** @type {HTMLElement} */ (e.target);
31
+
32
+ const action_btn = /** @type {HTMLElement | null} */ (
33
+ target.closest('.sf-macro-riga-add, .sf-macro-close-btn')
34
+ );
35
+ if (!action_btn) return;
36
+
37
+ const fset = /** @type {HTMLElement | null} */ (target.closest(wrapper_selector));
38
+ if (!fset) return;
39
+
23
40
  const macro_container = /** @type {HTMLElement | null} */ (fset.querySelector('.sf-macro-container'));
24
41
  if (!macro_container) return;
25
- const macro_template = macro_container.dataset.template ?? '';
26
42
 
27
- // event listeners
28
- fset.addEventListener('click', e => {
29
- const target = /** @type {HTMLElement} */ (e.target);
43
+ if(action_btn.matches('.sf-macro-riga-add')) {
30
44
 
31
- if(target.closest('.sf-macro-riga-add')) {
45
+ const macro_template = macro_container.dataset.template ?? '';
46
+ const righe_macro = macro_container.querySelectorAll(row_selector).length;
32
47
 
33
- const righe_macro = macro_container.querySelectorAll(row_selector).length;
48
+ macro_container.insertAdjacentHTML(insertAtTop? 'afterbegin' : 'beforeend',
49
+ macro_template.replace(/__indice\d?__/g, String(righe_macro + 1))
50
+ );
34
51
 
35
- macro_container.insertAdjacentHTML(insertAtTop? 'afterbegin' : 'beforeend',
36
- macro_template.replace(/__indice\d?__/g, String(righe_macro + 1))
52
+ if(add_callback && typeof add_callback === 'function') {
53
+ add_callback(
54
+ insertAtTop
55
+ ? macro_container.querySelector(`${row_selector}:first-child`)
56
+ : macro_container.querySelector(`${row_selector}:last-child`),
57
+ action_btn
37
58
  );
59
+ }
38
60
 
39
- if(add_callback && typeof add_callback === 'function') {
40
- add_callback(
41
- insertAtTop
42
- ? macro_container.querySelector('.sf-macro-riga:first-child')
43
- : macro_container.querySelector('.sf-macro-riga:last-child'),
44
- target.closest('.sf-macro-riga-add')
45
- );
46
- }
47
-
48
-
49
- } else if(target.closest('.sf-macro-close-btn')) {
50
- target.closest(row_selector)?.remove();
61
+ } else {
62
+ target.closest(row_selector)?.remove();
51
63
 
52
- if(del_callback && typeof del_callback === 'function') {
53
- del_callback();
54
- }
64
+ if(del_callback && typeof del_callback === 'function') {
65
+ del_callback();
55
66
  }
67
+ }
56
68
 
57
- }, false);
58
- });
69
+ }, false);
59
70
  }
@@ -409,7 +409,6 @@ export function buildFakeField({
409
409
  * domBuilder items is passed, it is rendered via `children` instead of `content`.
410
410
  * @param {string} [args.type=button] - button type.
411
411
  * @param {string | null} args.id - `id` attribute.
412
- * @param {string | number | null} [args.value=null] - button `value` attribute.
413
412
  * @param {string | null} [args.class=null] - optional class to be added to the button element.
414
413
  * @param {string | null} [args.classname=null] - Alias for `class`.
415
414
  * @param {string | null} [args.className=null] - Alias for `class`.
@@ -422,7 +421,6 @@ export function buildButton({
422
421
  content,
423
422
  type = 'button',
424
423
  id = null,
425
- value = null,
426
424
  class: classArg = null,
427
425
  classname: classnameArg = null,
428
426
  className: classNameArg = null,
@@ -440,8 +438,7 @@ export function buildButton({
440
438
  id: id,
441
439
  attrs: {
442
440
  ...(attrs??{}),
443
- type: type,
444
- value: value
441
+ type: type
445
442
  },
446
443
  ...(Array.isArray(content)
447
444
  ? { children: content }