@massimo-cassandro/minimo 1.28.2 → 1.28.4

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.
@@ -7,7 +7,7 @@
7
7
  ## Stile di lavoro
8
8
 
9
9
  - Conferma la comprensione prima di agire su richieste ambigue
10
- - Il progetto usa ES modules (import/export), evitare sioluzioni che utilizzano commonJs
11
- - In linea di massima non proporre soluzioni che richiedano modifiche alla parte back-end, a meno che non sia esplicitamente richiesto
12
- - nella chat evitare neologismi come parsare, committare ecc., usare i termini corrispondi in italiano o il termine originale in inglese dove non sia possibile un equivalente in italiano
10
+ - Il progetto usa ES modules (import/export), evitare soluzioni che utilizzano commonJs
11
+ - In linea di massima non proporre soluzioni che richiedano modifiche alla parte back-end, se presente, a meno che non sia esplicitamente richiesto
12
+ - nella chat evitare neologismi come parsare, committare ecc., usare i termini corrispondenti in italiano o il termine originale in inglese dove non sia possibile un equivalente in italiano. Non coniugare mai secondo le regole dell'italiano verbi di altre lingue
13
13
  - nei commenti su più righe preferire `/* ... */` piuttosto che ripetere `//` ad igni inizio riga
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "1.28.2",
3
+ "version": "1.28.4",
4
4
  "description": "Light css framework & utilities",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -24,7 +24,7 @@
24
24
  }
25
25
  }
26
26
 
27
- /* single checkbozes and radios are centered */
27
+ /* single checkboxes and radios are vertically centered */
28
28
  .form-group:not(.form-collection-fset):has(.form-check:not(.form-check-top-label)) {
29
29
  align-self: center;
30
30
  .form-check {
@@ -39,6 +39,21 @@
39
39
  color: var(--form-label-color);
40
40
  }
41
41
 
42
+ /*
43
+ with implicit label, without id and for.
44
+ Example:
45
+
46
+ <div class="form-group">
47
+ <label>
48
+ <span class="form-label">...</span>
49
+ <select class="form-control">...</select>
50
+ </label>
51
+ </div>
52
+ */
53
+ label:has(.form-control) {
54
+ display: block;
55
+ width: 100%;
56
+ }
42
57
 
43
58
  .form-control, .form-control-static {
44
59
  display: block;
@@ -100,7 +100,7 @@ import { parseDomString } from './parseDomString.js';
100
100
  * @param {HTMLElement} [parent] - Parent element the structure is attached to (see `options.insertMode`).
101
101
  * @param {Object} [options={}] - Configuration options. (default: {})
102
102
  * @param {boolean} [options.emptyParent=false] - When true, the parent element is emptied before building. (default: false)
103
- * @param {'append'|'before'|'after'} [options.insertMode='append'] - How each root element of `structureArray` is attached to `parent`: `append` inserts it as a child (default), `before`/`after` insert it as a previous/next sibling of `parent`, preserving `structureArray` order. Only applies to the elements produced by this call — nested `domBuilder` calls (`content`, `children`) always append. (default: 'append')
103
+ * @param {'append'|'prepend'|'before'|'after'} [options.insertMode='append'] - How each root element of `structureArray` is attached to `parent`: `append` inserts it as the last child (default), `prepend` as the first child, `before`/`after` insert it as a previous/next sibling of `parent`. In every mode, `structureArray` order is preserved. Only applies to the elements produced by this call — nested `domBuilder` calls (`content`, `children`) always append. (default: 'append')
104
104
  * @param {boolean} [options.debug=false] - When true, logs `structureArray` to the console after each string item has been parsed via `parseDomString` (i.e. the elaborated array actually used to build the DOM). (default: false)
105
105
  * @returns {HTMLElement|null} The first created element, or null if nothing was created.
106
106
  */
@@ -119,12 +119,12 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
119
119
  parent.innerHTML = '';
120
120
  }
121
121
 
122
- // For the default 'append' insert mode, root-level siblings are accumulated into a
123
- // DocumentFragment and attached to `parent` with a single appendChild at the end,
124
- // instead of one appendChild per sibling. 'before'/'after' modes need `target` to stay
122
+ // For the 'append'/'prepend' insert modes, root-level siblings are accumulated into a
123
+ // DocumentFragment and attached to `parent` with a single appendChild/insertBefore at
124
+ // the end, instead of one call per sibling. 'before'/'after' modes need `target` to stay
125
125
  // the real, live parent node throughout the loop for anchor resolution (see afterAnchors
126
126
  // below), so batching is skipped for those.
127
- const useFragment = !!parent && options.insertMode === 'append';
127
+ const useFragment = !!parent && (options.insertMode === 'append' || options.insertMode === 'prepend');
128
128
 
129
129
  /** @type {HTMLElement | DocumentFragment | null} */
130
130
  let target = useFragment ? document.createDocumentFragment() : (parent ?? null);
@@ -345,7 +345,11 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
345
345
  }
346
346
 
347
347
  if (useFragment && parent && target) {
348
- parent.appendChild(target);
348
+ if (options.insertMode === 'prepend') {
349
+ parent.insertBefore(target, parent.firstChild);
350
+ } else {
351
+ parent.appendChild(target);
352
+ }
349
353
  }
350
354
 
351
355
  return mainElement;