@massimo-cassandro/minimo 1.41.3 → 1.41.5

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.
Files changed (133) hide show
  1. package/README.md +12 -12
  2. package/charts/src/node-helpers/create-svg-canvas-node.mjs +2 -2
  3. package/charts/src/node-helpers/svg-text-to-path.js +9 -9
  4. package/charts/src/rating-display/index.js +1 -1
  5. package/charts/src/rating-display/ratindDisplayAnimation.js +3 -3
  6. package/design-tokens/README.md +2 -2
  7. package/design-tokens/_src/_readme.md +26 -26
  8. package/dev-tools/README.md +16 -16
  9. package/dev-tools/create-favicons/README.md +31 -31
  10. package/dev-tools/create-favicons/src/create-ico.mjs +2 -2
  11. package/dev-tools/create-favicons/src/default-params.mjs +1 -1
  12. package/dev-tools/create-favicons/src/init.mjs +1 -1
  13. package/dev-tools/design-tokens-builder/README.md +102 -102
  14. package/dev-tools/design-tokens-builder/build-tokens-src/build-source-modes.mjs +85 -73
  15. package/dev-tools/design-tokens-builder/build-tokens-src/config.mjs +109 -85
  16. package/dev-tools/design-tokens-builder/build-tokens-src/formats/css.mjs +113 -90
  17. package/dev-tools/design-tokens-builder/build-tokens-src/formats/json.mjs +107 -95
  18. package/dev-tools/design-tokens-builder/build-tokens-src/legacy-tokens-parser.mjs +71 -64
  19. package/dev-tools/design-tokens-builder/build-tokens-src/light-dark.mjs +75 -65
  20. package/dev-tools/design-tokens-builder/build-tokens-src/merge-css.mjs +113 -102
  21. package/dev-tools/design-tokens-builder/build-tokens-src/platforms.mjs +36 -30
  22. package/dev-tools/design-tokens-builder/build-tokens-src/resolve-source-paths.mjs +15 -13
  23. package/dev-tools/design-tokens-builder/build-tokens-src/source-prefixes.mjs +44 -42
  24. package/dev-tools/design-tokens-builder/build-tokens-src/source-transforms.mjs +89 -83
  25. package/dev-tools/design-tokens-builder/build-tokens-src/token-rename-parser.mjs +99 -86
  26. package/dev-tools/design-tokens-builder/build-tokens-src/transforms.mjs +64 -48
  27. package/dev-tools/design-tokens-builder/build-tokens.mjs +80 -68
  28. package/dev-tools/design-tokens-builder/check-unresolved-custom-props.mjs +103 -77
  29. package/dev-tools/design-tokens-builder/tokens-config-sample.mjs +275 -238
  30. package/dev-tools/find-orphan-css-classes/find-orphan-css-classes.mjs +2 -2
  31. package/dev-tools/starter-kit/source_files/app/CLAUDE.md +4 -2
  32. package/dev-tools/starter-kit/source_files/app/index.css +10 -0
  33. package/dev-tools/starter-kit/source_files/app/index.js +1 -1
  34. package/dev-tools/starter-kit/source_files/root/_sf/controller/ImgViewerController.php +3 -3
  35. package/dev-tools/starter-kit/source_files/root/_sf/controller/ViewerController.php +2 -2
  36. package/dev-tools/starter-kit/source_files/root/stylelint.config.mjs +1 -1
  37. package/dev-tools/starter-kit/source_files/root/webpack-config-modules/css-rules.mjs +1 -1
  38. package/dev-tools/starter-kit/starter-install.sh +2 -2
  39. package/dev-tools/stylelint-config/README.md +7 -7
  40. package/dev-tools/svg-icons-tools/README.md +32 -32
  41. package/dev-tools/svg-icons-tools/src/config-manager.mjs +1 -1
  42. package/dev-tools/svg-icons-tools/src/default-config.mjs +118 -118
  43. package/dev-tools/svg-icons-tools/src/jsx-icon-file-builder.mjs +24 -24
  44. package/dev-tools/svg-icons-tools/src/parse-svg-filename.mjs +3 -3
  45. package/dev-tools/svg-icons-tools/src/parse-svg-files.mjs +1 -1
  46. package/dev-tools/svg-icons-tools/src/parse-svg-markup.mjs +4 -4
  47. package/dev-tools/svg-icons-tools/src/svg-to-jsx.mjs +2 -2
  48. package/dev-tools/svg-icons-tools/src/svg-to-optimized.mjs +2 -2
  49. package/dev-tools/svg-icons-tools/src/svg-to-symbols.mjs +2 -2
  50. package/dev-tools/upd@m/README.md +1 -1
  51. package/dev-tools/upd@m/index.mjs +1 -1
  52. package/dev-tools/update-version/README.md +9 -9
  53. package/index.js +1 -0
  54. package/package.json +3 -1
  55. package/snippets/unsplash-browser-app/README.md +1 -1
  56. package/snippets/unsplash-browser-app/unsplash-utilities.js +9 -9
  57. package/src/components/autocomplete/README.md +3 -3
  58. package/src/components/autocomplete/autocomplete-engine.js +75 -63
  59. package/src/components/autocomplete/check-autocomplete.js +3 -3
  60. package/src/components/dismiss-alerts.js +3 -3
  61. package/src/components/form-reset-submit.js +6 -6
  62. package/src/components/inner-nav/inner-nav.js +2 -2
  63. package/src/components/modal-alert/modal-alert.js +67 -65
  64. package/src/components/modal-alert/modal-alert.minimo.tokens.mjs +1 -1
  65. package/src/components/modal-popup/modal-popup.js +56 -56
  66. package/src/components/overlay/overlay.js +3 -3
  67. package/src/components/sf-macro/readme.md +1 -1
  68. package/src/components/sf-macro/sf-macro.js +27 -23
  69. package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +83 -79
  70. package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +44 -44
  71. package/src/components/snackbar/snackbar.js +19 -19
  72. package/src/components/spinner/spinner.js +3 -3
  73. package/src/components/unsplash-page/README.md +8 -8
  74. package/src/components/unsplash-page/fetch-unsplash-data.js +3 -3
  75. package/src/components/unsplash-page/unsplash-page.js +33 -33
  76. package/src/components/unsplash-page/unsplash-page.module.css +1 -1
  77. package/src/css/alerts.css +2 -2
  78. package/src/css/forms/forms.css +4 -4
  79. package/src/css/forms/validation.css +1 -1
  80. package/src/css/margin-padding-media.css +4 -4
  81. package/src/css/margin-padding.css +4 -4
  82. package/src/css/reset.css +11 -11
  83. package/src/icons/read-me.md +1 -1
  84. package/src/minimo.css +3 -9
  85. package/src/utilities/better-text-with-places.js +105 -105
  86. package/src/utilities/better-text.js +42 -35
  87. package/src/utilities/classnames.js +8 -8
  88. package/src/utilities/cookies.js +6 -6
  89. package/src/utilities/create-id.js +3 -3
  90. package/src/utilities/disable-btns-on-submit.js +2 -2
  91. package/src/utilities/dom-builder/dom-builder.js +89 -86
  92. package/src/utilities/dom-builder/domBuilderBasicSetup.js +9 -9
  93. package/src/utilities/dom-builder/parseDomString.js +23 -23
  94. package/src/utilities/dom-builder-helpers/README.md +2 -2
  95. package/src/utilities/dom-builder-helpers/form-tags.js +100 -100
  96. package/src/utilities/dom-builder-helpers/picture-tag.js +39 -39
  97. package/src/utilities/enable-submit-btns.js +1 -1
  98. package/src/utilities/escape-html.js +2 -2
  99. package/src/utilities/generate-pwd.js +4 -4
  100. package/src/utilities/linked-dates.js +13 -13
  101. package/src/utilities/parse-file-size.js +6 -6
  102. package/src/utilities/random-id.js +3 -3
  103. package/src/utilities/relative-date.js +40 -40
  104. package/src/utilities/sentence-case.js +1 -1
  105. package/src/utilities/strip-tags.js +1 -1
  106. package/src/utilities/title-case.js +1 -1
  107. package/src/utilities/truncate-string.js +5 -5
  108. package/src/utilities/validation-error-class.js +12 -12
  109. package/src/web-components/json-table/json-table-component.js +123 -121
  110. package/src/web-components/json-table/json-table-component.module.css +6 -6
  111. package/src/web-components/json-table/json-table.minimo.tokens.mjs +6 -6
  112. package/src/web-components/json-table/readme.md +76 -110
  113. package/src/web-components/json-table/src/cell-content.js +25 -25
  114. package/src/web-components/json-table/src/content-utils.js +21 -21
  115. package/src/web-components/json-table/src/data-types.js +32 -32
  116. package/src/web-components/json-table/src/defaults.js +230 -191
  117. package/src/web-components/json-table/src/get-data.js +55 -38
  118. package/src/web-components/json-table/src/icons.js +17 -17
  119. package/src/web-components/json-table/src/info-section.js +18 -18
  120. package/src/web-components/json-table/src/main-builder.js +45 -45
  121. package/src/web-components/json-table/src/pagination.js +32 -32
  122. package/src/web-components/json-table/src/parse-cols.js +18 -18
  123. package/src/web-components/json-table/src/parse-rows.js +17 -17
  124. package/src/web-components/json-table/src/resolve-params.js +53 -41
  125. package/src/web-components/json-table/src/search.js +13 -13
  126. package/src/web-components/json-table/src/sorting.js +20 -20
  127. package/src/web-components/json-table/src/table-body.js +13 -13
  128. package/src/web-components/json-table/src/table-builder.js +34 -34
  129. package/src/web-components/json-table/src/table-tfoot.js +8 -8
  130. package/src/web-components/json-table/src/table-thead.js +21 -21
  131. package/src/web-components/json-table/src/update-info.js +11 -11
  132. package/types/classes.d.ts +2 -2
  133. package/types/global.d.ts +18 -12
@@ -2,50 +2,51 @@
2
2
  import { domBuilderBasicSetup } from './domBuilderBasicSetup.js';
3
3
  import { parseDomString } from './parseDomString.js';
4
4
 
5
- // TODO multi-line string syntax where each line maps to an element
6
- // TODO same as above with optional nesting via indentation
5
+ // TODO sintassi stringa multi-riga in cui ogni riga corrisponde a un elemento
6
+ // TODO come sopra, con nidificazione opzionale tramite indentazione
7
7
 
8
8
  /**
9
9
  * @typedef {Object} DomBuilderItem
10
- * @property {string | string[]} [tag='div'] - HTML tag name or array of nested tags (each is parent of the next). Also `tagName`. (default: 'div')
11
- * @property {string | string[]} [tagName='div'] - Alias for `tag`. (default: 'div')
12
- * @property {string | string[]} [className] - CSS class(es): a single string or an array (falsy values filtered out).
13
- * @property {string | string[]} [class] - Alias for `className`.
14
- * @property {string | string[]} [classname] - Alias for `className`.
15
- * @property {string | null} [id] - Unique element ID.
16
- * @property {[string, *] | [string, *][] | Object<string, *>} [attrs] - Attributes: a `[name, value]` pair, array of pairs, or `{name: value}` object.
17
- * @property {string | number | Function | Node | DomBuilderItem[] | null} [content] - Element content.
18
- * A string or number is set as plain text (`textContent`) unless it contains `<`, in which case it is
19
- * treated as markup: sanitized and inserted via the native Sanitizer API (`Element.setHTML`) where
20
- * supported, falling back to raw `innerHTML` on browsers without it. A `Node` (an `Element`, a
21
- * `DocumentFragment`, ...) is appended as-is, either directly or returned from a function.
22
- * @property {string | number} [text] - Literal text node shorthand: inserts a plain `Text` node (never
23
- * parsed as markup) in place of an element, so it can sit as a sibling of tags within `children`/`content`
24
- * arrays. Mutually exclusive with `tag`/`content`/`children`: when set (and `tag` is absent), every other
25
- * property except `condition` and `callback` is ignored.
26
- * @property {boolean} [condition=true] - When false, the element (or text node) is skipped. (default: true)
27
- * @property {((el: HTMLElement|Text) => void) | null} [callback] - Callback invoked after the element (or text node) is created.
28
- * @property {Array<DomBuilderItem|string|Node>} [children] - Configuration array for child elements. Accepts strings (shorthand per `parseDomString`), configuration objects, and/or `Node`s (an `Element`, a `DocumentFragment`, ...) inserted as-is.
10
+ * @property {string | string[]} [tag='div'] - Nome del tag HTML o array di tag annidati (ciascuno è il genitore del successivo). Anche `tagName` (default: 'div')
11
+ * @property {string | string[]} [tagName='div'] - Alias di `tag` (default: 'div')
12
+ * @property {string | string[]} [className] - Classe/i CSS: una singola stringa o un array (i valori falsy vengono scartati).
13
+ * @property {string | string[]} [class] - Alias di `className`.
14
+ * @property {string | string[]} [classname] - Alias di `className`.
15
+ * @property {string | null} [id] - ID univoco dell'elemento.
16
+ * @property {[string, *] | [string, *][] | Object<string, *>} [attrs] - Attributi: una coppia `[name, value]`, un array di coppie o un oggetto `{name: value}`.
17
+ * @property {string | number | Function | Node | DomBuilderItem[] | null} [content] - Contenuto dell'elemento.
18
+ * Una stringa o un numero viene impostato come testo semplice (`textContent`), a meno che contenga `<`:
19
+ * in tal caso viene trattato come markup, sanificato e inserito tramite la Sanitizer API nativa
20
+ * (`Element.setHTML`) dove supportata, con ripiego su `innerHTML` grezzo nei browser che non la hanno.
21
+ * Un `Node` (un `Element`, un `DocumentFragment`, ...) viene aggiunto così com'è, direttamente o
22
+ * restituito da una funzione.
23
+ * @property {string | number} [text] - Scorciatoia per un nodo di testo letterale: inserisce un nodo `Text` semplice (mai
24
+ * interpretato come markup) al posto di un elemento, così da poter essere fratello dei tag negli array
25
+ * `children`/`content`. Mutuamente esclusivo con `tag`/`content`/`children`: quando è impostato (e `tag` è assente),
26
+ * ogni altra proprietà tranne `condition` e `callback` viene ignorata.
27
+ * @property {boolean} [condition=true] - Se false, l'elemento (o il nodo di testo) viene saltato (default: true)
28
+ * @property {((el: HTMLElement|Text) => void) | null} [callback] - Callback invocata dopo la creazione dell'elemento (o del nodo di testo).
29
+ * @property {Array<DomBuilderItem|string|Node>} [children] - Array di configurazione degli elementi figli. Accetta stringhe (scorciatoia secondo `parseDomString`), oggetti di configurazione e/o `Node` (un `Element`, un `DocumentFragment`, ...) inseriti così come sono.
29
30
  */
30
31
 
31
32
  /**
32
33
  * domBuilder
33
- * Builds a DOM structure from a configuration array.
34
+ * Costruisce una struttura DOM a partire da un array di configurazione.
34
35
  *
35
- * Parses an array of configuration objects to create HTML elements.
36
+ * Analizza un array di oggetti di configurazione per creare elementi HTML.
36
37
  *
37
- * **Configuration structure format (structureArray):**
38
+ * **Formato della struttura di configurazione (structureArray):**
38
39
  *
39
40
  * ```javascript
40
41
  * structure = [
41
42
  * '#mainContainer.container',
42
43
  * 'p#main-info.info.active{data-id:123,role=button} Lorem ipsum',
43
44
  * {
44
- * tag: 'div' | ['.divClass', 'h2#id', 'table.class1', 'thead', 'tr.class2.class3(attr1: attrValue)'], // also tagName
45
- * className: 'xxx' | ['class1', 'class2'], // also `class`
45
+ * tag: 'div' | ['.divClass', 'h2#id', 'table.class1', 'thead', 'tr.class2.class3(attr1: attrValue)'], // anche tagName
46
+ * className: 'xxx' | ['class1', 'class2'], // anche `class`
46
47
  * id: 'element-id',
47
48
  * attrs: [attr_name, attr_value] | [[...], [...]] | {name: value},
48
- * content: 'xxx' | 'xxx <strong>yyy</strong>' | 123 | domBuilder Array | function | Node, // see DomBuilderItem.content above
49
+ * content: 'xxx' | 'xxx <strong>yyy</strong>' | 123 | domBuilder Array | function | Node, // vedi DomBuilderItem.content sopra
49
50
  * condition: true | false,
50
51
  * callback: el => ...,
51
52
  * children: [...]
@@ -58,9 +59,9 @@ import { parseDomString } from './parseDomString.js';
58
59
  * ]
59
60
  * ```
60
61
  *
61
- * To mix literal text and tags as siblings within the same element (e.g. `Lorem <strong>ipsum</strong> dolor`),
62
- * use the `text` shorthand in `children`/`content`, since a plain string item is always parsed as a tag
63
- * (see `parseDomString`), never as a text node:
62
+ * Per mescolare testo letterale e tag come fratelli nello stesso elemento (es. `Lorem <strong>ipsum</strong> dolor`),
63
+ * usare la scorciatoia `text` in `children`/`content`, dato che una semplice stringa viene sempre interpretata come tag
64
+ * (vedi `parseDomString`), mai come nodo di testo:
64
65
  *
65
66
  * ```javascript
66
67
  * children: [
@@ -70,39 +71,39 @@ import { parseDomString } from './parseDomString.js';
70
71
  * ]
71
72
  * ```
72
73
  *
73
- * IDs and classes can be specified either as top-level object keys or inside the `attrs` object.
74
- * When both are present, top-level properties take precedence.
74
+ * ID e classi possono essere indicati come chiavi di primo livello dell'oggetto oppure dentro l'oggetto `attrs`.
75
+ * Quando sono presenti entrambi, le proprietà di primo livello hanno la precedenza.
75
76
  *
76
- * A shorthand string syntax is also available, built according to `parseDomString` conventions.
77
- * See `parseDomString` for details.
77
+ * È disponibile anche una sintassi abbreviata a stringa, costruita secondo le convenzioni di `parseDomString`.
78
+ * Vedi `parseDomString` per i dettagli.
78
79
  *
79
- * The shorthand syntax does not support `content`, `callback`, `condition`, or `children`; use the object syntax for those.
80
+ * La sintassi abbreviata non supporta `content`, `callback`, `condition` o `children`; per questi usare la sintassi a oggetto.
80
81
  *
81
- * The shorthand can also be used for the `tag` property in object syntax.
82
- * When `tag` is an array, each element becomes the parent of the next one. Any other object properties
83
- * (className, callback, etc.) are applied only to the last element in the array.
84
- * When shorthand string and object-level properties conflict (classes, id, or attributes),
85
- * object-level properties take precedence.
82
+ * La sintassi abbreviata può essere usata anche per la proprietà `tag` nella sintassi a oggetto.
83
+ * Quando `tag` è un array, ogni elemento diventa il genitore del successivo. Tutte le altre proprietà dell'oggetto
84
+ * (className, callback, ecc.) vengono applicate solo all'ultimo elemento dell'array.
85
+ * Quando la stringa abbreviata e le proprietà a livello di oggetto sono in conflitto (classi, id o attributi),
86
+ * le proprietà a livello di oggetto hanno la precedenza.
86
87
  *
87
88
  * @function domBuilder
88
- * @param {Array<DomBuilderItem|string|Node>} [structureArray=[]] - Configuration array. Accepts strings (shorthand per `parseDomString`), configuration objects, and/or `Node`s (an `Element`, a `DocumentFragment`, ...) inserted as-is; each configuration object supports:
89
- * - `tag` / `tagName` {string | string[]} - HTML tag name, or array of nested tags (each is parent of the next). Default `'div'`.
90
- * - `className` / `class` / `classname` {string | string[]} - CSS class(es): a single string or an array (falsy values filtered out).
91
- * - `id` {string | null} - Unique element ID.
92
- * - `attrs` {[string, *] | [string, *][] | Object<string, *>} - Attributes: a `[name, value]` pair, array of pairs, or `{name: value}` object.
93
- * - `content` {string | number | Function | Node | DomBuilderItem[] | null} - Element content. A string/number is set as `textContent` unless it contains `<`, in which case it's sanitized and inserted as markup (`Element.setHTML`, falling back to `innerHTML`). A `Node` (`Element`, `DocumentFragment`, ...), passed directly or returned from a function, is appended as-is.
94
- * - `text` {string | number} - Literal text node shorthand: inserts a plain `Text` node (never parsed as markup) as a sibling of other items, in place of an element. Mutually exclusive with `tag`/`content`/`children`.
95
- * - `condition` {boolean} - When false, the element (or text node) is skipped. Default `true`.
96
- * - `callback` {(function(HTMLElement|Text): void) | null} - Invoked after the element (or text node) is created.
97
- * - `children` {Array<DomBuilderItem|string|Node>} - Configuration array for child elements (same format, nested; also accepts `Node`s inserted as-is).
89
+ * @param {Array<DomBuilderItem|string|Node>} [structureArray=[]] - Array di configurazione. Accetta stringhe (scorciatoia secondo `parseDomString`), oggetti di configurazione e/o `Node` (un `Element`, un `DocumentFragment`, ...) inseriti così come sono; ogni oggetto di configurazione supporta:
90
+ * - `tag` / `tagName` {string | string[]} - Nome del tag HTML, o array di tag annidati (ciascuno è il genitore del successivo). Default `'div'`.
91
+ * - `className` / `class` / `classname` {string | string[]} - Classe/i CSS: una singola stringa o un array (i valori falsy vengono scartati).
92
+ * - `id` {string | null} - ID univoco dell'elemento.
93
+ * - `attrs` {[string, *] | [string, *][] | Object<string, *>} - Attributi: una coppia `[name, value]`, un array di coppie o un oggetto `{name: value}`.
94
+ * - `content` {string | number | Function | Node | DomBuilderItem[] | null} - Contenuto dell'elemento. Una stringa/numero viene impostato come `textContent`, a meno che contenga `<`: in tal caso viene sanificato e inserito come markup (`Element.setHTML`, con ripiego su `innerHTML`). Un `Node` (`Element`, `DocumentFragment`, ...), passato direttamente o restituito da una funzione, viene aggiunto così com'è.
95
+ * - `text` {string | number} - Scorciatoia per un nodo di testo letterale: inserisce un nodo `Text` semplice (mai interpretato come markup) come fratello degli altri elementi, al posto di un elemento. Mutuamente esclusivo con `tag`/`content`/`children`.
96
+ * - `condition` {boolean} - Se false, l'elemento (o il nodo di testo) viene saltato. Default `true`.
97
+ * - `callback` {(function(HTMLElement|Text): void) | null} - Invocata dopo la creazione dell'elemento (o del nodo di testo).
98
+ * - `children` {Array<DomBuilderItem|string|Node>} - Array di configurazione degli elementi figli (stesso formato, annidato; accetta anche `Node` inseriti così come sono).
98
99
  *
99
- * IDs and classes can be specified either as top-level object keys or inside `attrs`; top-level properties take precedence. (default: [])
100
- * @param {HTMLElement} [parent] - Parent element the structure is attached to (see `options.insertMode`).
101
- * @param {Object} [options={}] - Configuration options. (default: {})
102
- * @param {boolean} [options.emptyParent=false] - When true, the parent element is emptied before building. (default: false)
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
- * @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
- * @returns {HTMLElement|null} The first created element, or null if nothing was created.
100
+ * ID e classi possono essere indicati come chiavi di primo livello dell'oggetto o dentro `attrs`; le proprietà di primo livello hanno la precedenza (default: [])
101
+ * @param {HTMLElement} [parent] - Elemento genitore a cui viene agganciata la struttura (vedi `options.insertMode`).
102
+ * @param {Object} [options={}] - Opzioni di configurazione (default: {})
103
+ * @param {boolean} [options.emptyParent=false] - Se true, l'elemento genitore viene svuotato prima della costruzione (default: false)
104
+ * @param {'append'|'prepend'|'before'|'after'} [options.insertMode='append'] - Come ogni elemento radice di `structureArray` viene agganciato a `parent`: `append` lo inserisce come ultimo figlio (default), `prepend` come primo figlio, `before`/`after` lo inseriscono come fratello precedente/successivo di `parent`. In ogni modalità l'ordine di `structureArray` viene mantenuto. Si applica solo agli elementi prodotti da questa chiamata — le chiamate annidate a `domBuilder` (`content`, `children`) fanno sempre append (default: 'append')
105
+ * @param {boolean} [options.debug=false] - Se true, scrive `structureArray` in console dopo che ogni elemento stringa è stato analizzato con `parseDomString` (cioè l'array elaborato effettivamente usato per costruire il DOM) (default: false)
106
+ * @returns {HTMLElement|null} Il primo elemento creato, oppure null se non è stato creato nulla.
106
107
  */
107
108
 
108
109
 
@@ -119,17 +120,19 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
119
120
  parent.innerHTML = '';
120
121
  }
121
122
 
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
- // the real, live parent node throughout the loop for anchor resolution (see afterAnchors
126
- // below), so batching is skipped for those.
123
+ /*
124
+ Per le modalità di inserimento 'append'/'prepend', i fratelli di primo livello vengono accumulati in un
125
+ DocumentFragment e agganciati a `parent` con un solo appendChild/insertBefore alla
126
+ fine, invece di una chiamata per fratello. Le modalità 'before'/'after' richiedono che `target` resti
127
+ il vero nodo genitore attivo per tutto il ciclo per la risoluzione dell'ancora (vedi afterAnchors
128
+ più sotto), quindi per queste il raggruppamento viene saltato.
129
+ */
127
130
  const useFragment = !!parent && (options.insertMode === 'append' || options.insertMode === 'prepend');
128
131
 
129
132
  /** @type {HTMLElement | DocumentFragment | null} */
130
133
  let target = useFragment ? document.createDocumentFragment() : (parent ?? null);
131
134
 
132
- /** @type {Map<HTMLElement | DocumentFragment, Node>} tracks, for `insertMode: 'after'`, the last inserted sibling per parent node */
135
+ /** @type {Map<HTMLElement | DocumentFragment, Node>} tiene traccia, per `insertMode: 'after'`, dell'ultimo fratello inserito per ogni nodo genitore */
133
136
  const afterAnchors = new Map();
134
137
 
135
138
  /** @type {HTMLElement | null} */
@@ -144,8 +147,8 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
144
147
 
145
148
  structureArray.forEach(inputItem => {
146
149
 
147
- // A DOM Node (Element, DocumentFragment, ...) passed directly: inserted as-is,
148
- // bypassing element creation and config parsing entirely.
150
+ // Un Node DOM (Element, DocumentFragment, ...) passato direttamente: inserito così com'è,
151
+ // saltando del tutto la creazione dell'elemento e l'analisi della configurazione.
149
152
  if (inputItem instanceof Node) {
150
153
 
151
154
  elaboratedStructureArray.push(/** @type {DomBuilderItem} */ (/** @type {unknown} */ (inputItem)));
@@ -184,10 +187,10 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
184
187
 
185
188
  if (item != null && (item.condition ?? true)) {
186
189
 
187
- const safeItem = item; // const binding so TypeScript tracks non-null type in nested closures
190
+ const safeItem = item; // binding const così che TypeScript tracci il tipo non nullo nelle closure annidate
188
191
 
189
- // `{ text: '...' }` shorthand: a literal Text node, never parsed as markup, inserted in
190
- // place of an element so it can sit as a sibling of tags within `children`/`content` arrays
192
+ // scorciatoia `{ text: '...' }`: un nodo Text letterale, mai interpretato come markup, inserito
193
+ // al posto di un elemento così da poter essere fratello dei tag negli array `children`/`content`
191
194
  if (safeItem.tag == null && (typeof safeItem.text === 'string' || typeof safeItem.text === 'number')) {
192
195
 
193
196
  const textNode = document.createTextNode(String(safeItem.text));
@@ -214,8 +217,8 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
214
217
  return;
215
218
  }
216
219
 
217
- // when tag is an array, create a series of nested elements;
218
- // the last one receives the remaining object properties
220
+ // quando tag è un array, crea una serie di elementi annidati;
221
+ // l'ultimo riceve le restanti proprietà dell'oggetto
219
222
  if (Array.isArray(safeItem.tag)) {
220
223
 
221
224
  grand_parent = target;
@@ -226,7 +229,7 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
226
229
  const isLast = idx === tags.length - 1;
227
230
  const parsedItem = parseDomString(tagItem) ?? { tag: 'div', id: undefined, className: '', attrs: {}, content: undefined };
228
231
 
229
- // for the last element, merge with the object's own options; object-level properties take precedence
232
+ // per l'ultimo elemento, unisce con le opzioni proprie dell'oggetto; le proprietà a livello di oggetto hanno la precedenza
230
233
  if(isLast) {
231
234
  safeItem.attrs = {...parsedItem.attrs ?? {}, ...safeItem.attrs ?? {}};
232
235
  }
@@ -235,7 +238,7 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
235
238
  {...parsedItem, ...(isLast ? safeItem : {})}
236
239
  );
237
240
 
238
- if (!isLast) { // the last element is handled by the standard path below
241
+ if (!isLast) { // l'ultimo elemento viene gestito dal percorso standard qui sotto
239
242
  if (target) {
240
243
  target.appendChild(el);
241
244
  }
@@ -255,8 +258,8 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
255
258
  if (safeItem.content != null) {
256
259
 
257
260
  if (Array.isArray(safeItem.content)) {
258
- // build directly into `el` (instead of passing no parent) so that every item of
259
- // the array is actually inserted, not just the first one returned as `mainElement`
261
+ // costruisce direttamente dentro `el` (invece di non passare alcun genitore) così che ogni elemento
262
+ // dell'array venga effettivamente inserito, non solo il primo restituito come `mainElement`
260
263
  domBuilder(safeItem.content, el);
261
264
 
262
265
  } else {
@@ -274,29 +277,29 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
274
277
  }
275
278
 
276
279
  if (content instanceof Node) {
277
- // Element, DocumentFragment, Text, ... appended as-is (a DocumentFragment's
278
- // children are moved into `el`, emptying the fragment, per native DOM behavior)
280
+ // Element, DocumentFragment, Text, ... aggiunti così come sono (i figli di un
281
+ // DocumentFragment vengono spostati dentro `el`, svuotando il fragment, come da comportamento nativo del DOM)
279
282
  el.appendChild(content);
280
283
 
281
284
  } else if (content != null) {
282
285
 
283
286
  if (!content.includes('<')) {
284
- // plain text: no HTML parsing needed, textContent is faster and safe by construction
287
+ // testo semplice: non serve il parsing HTML, textContent è più veloce e sicuro per costruzione
285
288
  el.textContent = content;
286
289
 
287
290
  } else if (typeof el.setHTML === 'function') {
288
- /* markup: sanitize via the native Sanitizer API, stripping <script>, event handler
289
- attributes, javascript: URLs, etc. while still allowing harmless formatting tags
291
+ /* markup: sanifica tramite la Sanitizer API nativa, eliminando <script>, attributi
292
+ di gestione eventi, URL javascript:, ecc. pur consentendo i tag di formattazione innocui
290
293
  (<strong>, <em>, <a>, ...).
291
- The empty sanitizer config keeps every element/attribute not in the built-in unsafe
292
- baseline: without it the browser default configuration also removes `class`, `id`,
293
- `style` and `data-*` attributes (observed in Chrome 152), breaking any markup string
294
- that relies on CSS classes */
294
+ La configurazione vuota del sanitizer mantiene ogni elemento/attributo che non rientra nella
295
+ baseline non sicura integrata: senza di essa la configurazione predefinita del browser rimuove anche
296
+ gli attributi `class`, `id`, `style` e `data-*` (osservato in Chrome 152), rompendo qualsiasi
297
+ stringa di markup che si affidi alle classi CSS */
295
298
  el.setHTML(content, { sanitizer: {} });
296
299
 
297
300
  } else {
298
- // Sanitizer API not supported by this browser: fall back to the historical,
299
- // unsanitized behavior
301
+ // Sanitizer API non supportata da questo browser: ripiega sul comportamento storico,
302
+ // non sanificato
300
303
  el.innerHTML = content;
301
304
  }
302
305
  }
@@ -331,7 +334,7 @@ export function domBuilder(/** @type {Array<DomBuilderItem|string|Node>} */ stru
331
334
  }
332
335
  }
333
336
 
334
- // TODO callbacks that act on the element's children may not run when no parent is set
337
+ // TODO le callback che agiscono sui figli dell'elemento potrebbero non essere eseguite quando non è impostato alcun parent
335
338
  if (safeItem.callback && typeof safeItem.callback === 'function') {
336
339
  safeItem.callback(el);
337
340
  }
@@ -1,6 +1,6 @@
1
1
 
2
- // boolean attributes are omitted when their value is explicitly false;
3
- // declared once at module level (Set for O(1) lookup) since the list never changes between calls
2
+ // gli attributi booleani vengono omessi quando il loro valore è esplicitamente false;
3
+ // dichiarati una sola volta a livello di modulo (Set per lookup O(1)) dato che l'elenco non cambia tra le chiamate
4
4
  const boolAttrs = new Set([
5
5
  'allowfullscreen',
6
6
  'async',
@@ -33,14 +33,14 @@ const boolAttrs = new Set([
33
33
  ]);
34
34
 
35
35
  /**
36
- * Applies basic domBuilder configuration to an element: classes, id, and attributes.
37
- * @param {HTMLElement} element - The element to configure.
38
- * @param {DomBuilderItem} domBuilderItem - The domBuilder configuration object.
36
+ * Applica a un elemento la configurazione di base di domBuilder: classi, id e attributi.
37
+ * @param {HTMLElement} element - L'elemento da configurare.
38
+ * @param {DomBuilderItem} domBuilderItem - L'oggetto di configurazione di domBuilder.
39
39
  * @returns {HTMLElement}
40
40
  */
41
41
  export function domBuilderBasicSetup (element, domBuilderItem) {
42
42
 
43
- // class aliases: accept `class` and `classname`; `className` takes precedence over both
43
+ // alias delle classi: accetta `class` e `classname`; `className` ha la precedenza su entrambi
44
44
  if (domBuilderItem.class && !domBuilderItem.className) {
45
45
  domBuilderItem.className = domBuilderItem.class;
46
46
  }
@@ -48,11 +48,11 @@ export function domBuilderBasicSetup (element, domBuilderItem) {
48
48
  domBuilderItem.className = domBuilderItem.classname;
49
49
  }
50
50
 
51
- // normalize attrs: a single flat array is treated as a single [name, value] pair
51
+ // normalizza attrs: un singolo array piatto viene trattato come una singola coppia [name, value]
52
52
  if (domBuilderItem.attrs && Array.isArray(domBuilderItem.attrs) && !Array.isArray(domBuilderItem.attrs[0])) {
53
53
  domBuilderItem.attrs = [ domBuilderItem.attrs ];
54
54
 
55
- // attrs can also be a plain object: {attr_name: attr_value}
55
+ // attrs può essere anche un oggetto semplice: {attr_name: attr_value}
56
56
  } else if (typeof domBuilderItem.attrs === 'object' && !Array.isArray(domBuilderItem.attrs) && domBuilderItem.attrs !== null) {
57
57
  domBuilderItem.attrs = Object.entries(domBuilderItem.attrs);
58
58
  }
@@ -63,7 +63,7 @@ export function domBuilderBasicSetup (element, domBuilderItem) {
63
63
  }
64
64
  });
65
65
 
66
- // assign classes and id after attrs so object-level properties take precedence
66
+ // assegna classi e id dopo attrs così che le proprietà a livello di oggetto abbiano la precedenza
67
67
  if(domBuilderItem.className) {
68
68
  element.className = Array.isArray(domBuilderItem.className)
69
69
  ? domBuilderItem.className.filter(Boolean).join(' ')
@@ -1,35 +1,35 @@
1
- // compiled once at module load, since the pattern never changes between calls
1
+ // compilato una sola volta al caricamento del modulo, dato che il pattern non cambia tra le chiamate
2
2
  const DOM_STRING_REGEX = new RegExp(
3
- /^([a-zA-Z][a-zA-Z0-9-]*)?/.source + // tag (also accepts web component names)
4
- /((?:[#.][a-zA-Z0-9_-]+)*)?/.source + // id and classes, in any order
5
- /([([{].*?[)\]}])?/.source + // attrs
6
- /(?: +(.*))?$/.source // content
3
+ /^([a-zA-Z][a-zA-Z0-9-]*)?/.source + // tag (accetta anche i nomi dei web component)
4
+ /((?:[#.][a-zA-Z0-9_-]+)*)?/.source + // id e classi, in qualsiasi ordine
5
+ /([([{].*?[)\]}])?/.source + // attributi
6
+ /(?: +(.*))?$/.source // contenuto
7
7
  );
8
8
 
9
9
  /**
10
- * Parses a string to extract tag name, ID, classes, and attributes.
10
+ * Analizza una stringa per estrarne nome del tag, ID, classi e attributi.
11
11
  *
12
- * Expected string format:
12
+ * Formato atteso della stringa:
13
13
  *
14
14
  * `tag#id.class1.class2.classN(attr1: val1, attr2=val2) text content`
15
15
  *
16
- * Where:
17
- * * `tag` is the element name; defaults to `div` if omitted
18
- * * `#id` is the optional element id, preceded by `#`
19
- * * `.class1, .class2...` are optional CSS classes, each preceded by `.`
20
- * * `#id` and `.class` tokens can appear in any order and interleaved (e.g. `.class1#id.class2`)
21
- * * `(...)` is the optional attribute block; can also use `[...]` or `{...}`.
22
- * Each name–value pair is separated by `:` or `=`. A bare name (no value) defaults to `true`.
23
- * * Text content follows after a space
16
+ * Dove:
17
+ * * `tag` è il nome dell'elemento; se omesso vale `div`
18
+ * * `#id` è l'id opzionale dell'elemento, preceduto da `#`
19
+ * * `.class1, .class2...` sono classi CSS opzionali, ciascuna preceduta da `.`
20
+ * * i token `#id` e `.class` possono comparire in qualsiasi ordine e alternati (es. `.class1#id.class2`)
21
+ * * `(...)` è il blocco opzionale degli attributi; si possono usare anche `[...]` o `{...}`.
22
+ * Ogni coppia nome–valore è separata da `:` o `=`. Un nome senza valore vale `true`.
23
+ * * Il contenuto testuale segue dopo uno spazio
24
24
  *
25
- * Returns a domBuilder child object.
25
+ * Restituisce un oggetto figlio di domBuilder.
26
26
  *
27
- * Examples:
27
+ * Esempi:
28
28
  * > p#main-info.info.active{data-id:123,role=button} text content
29
29
  *
30
30
  * > input#search-field[type=text,disabled]
31
31
  *
32
- * @param {string} domString - The domBuilder string to parse.
32
+ * @param {string} domString - La stringa domBuilder da analizzare.
33
33
  * @returns {{tag: string, id: string|null, className: string, attrs: Object<string, string|true>, content: string|null}|null}
34
34
  */
35
35
  export function parseDomString(domString) {
@@ -41,12 +41,12 @@ export function parseDomString(domString) {
41
41
  return null;
42
42
  }
43
43
 
44
- // Capture group indexes:
45
- // [0]: full match
44
+ // Indici dei gruppi di cattura:
45
+ // [0]: corrispondenza completa
46
46
  // [1]: tag
47
- // [2]: id and classes (e.g. "#id.class1.class2" or ".class1#id.class2")
48
- // [3]: raw attributes
49
- // [4]: content
47
+ // [2]: id e classi (es. "#id.class1.class2" oppure ".class1#id.class2")
48
+ // [3]: attributi grezzi
49
+ // [4]: contenuto
50
50
 
51
51
  const idAndClasses = matches[2] || '',
52
52
  idMatch = idAndClasses.match(/#([a-zA-Z0-9_-]+)/),
@@ -1,2 +1,2 @@
1
- collection of helpers to build basic tags.
2
- All functions return a domBuilder array/object
1
+ Raccolta di helper per costruire tag di base.
2
+ Tutte le funzioni restituiscono un array/oggetto domBuilder