@massimo-cassandro/minimo 1.41.4 → 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 (131) 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/{css/index.css → index.css} +2 -2
  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/stylelint-config/README.md +7 -7
  39. package/dev-tools/svg-icons-tools/README.md +32 -32
  40. package/dev-tools/svg-icons-tools/src/config-manager.mjs +1 -1
  41. package/dev-tools/svg-icons-tools/src/default-config.mjs +118 -118
  42. package/dev-tools/svg-icons-tools/src/jsx-icon-file-builder.mjs +24 -24
  43. package/dev-tools/svg-icons-tools/src/parse-svg-filename.mjs +3 -3
  44. package/dev-tools/svg-icons-tools/src/parse-svg-files.mjs +1 -1
  45. package/dev-tools/svg-icons-tools/src/parse-svg-markup.mjs +4 -4
  46. package/dev-tools/svg-icons-tools/src/svg-to-jsx.mjs +2 -2
  47. package/dev-tools/svg-icons-tools/src/svg-to-optimized.mjs +2 -2
  48. package/dev-tools/svg-icons-tools/src/svg-to-symbols.mjs +2 -2
  49. package/dev-tools/upd@m/README.md +1 -1
  50. package/dev-tools/upd@m/index.mjs +1 -1
  51. package/dev-tools/update-version/README.md +9 -9
  52. package/package.json +1 -1
  53. package/snippets/unsplash-browser-app/README.md +1 -1
  54. package/snippets/unsplash-browser-app/unsplash-utilities.js +9 -9
  55. package/src/components/autocomplete/README.md +3 -3
  56. package/src/components/autocomplete/autocomplete-engine.js +75 -63
  57. package/src/components/autocomplete/check-autocomplete.js +3 -3
  58. package/src/components/dismiss-alerts.js +3 -3
  59. package/src/components/form-reset-submit.js +6 -6
  60. package/src/components/inner-nav/inner-nav.js +2 -2
  61. package/src/components/modal-alert/modal-alert.js +67 -65
  62. package/src/components/modal-alert/modal-alert.minimo.tokens.mjs +1 -1
  63. package/src/components/modal-popup/modal-popup.js +56 -56
  64. package/src/components/overlay/overlay.js +3 -3
  65. package/src/components/sf-macro/readme.md +1 -1
  66. package/src/components/sf-macro/sf-macro.js +27 -23
  67. package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +83 -79
  68. package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +44 -44
  69. package/src/components/snackbar/snackbar.js +19 -19
  70. package/src/components/spinner/spinner.js +3 -3
  71. package/src/components/unsplash-page/README.md +8 -8
  72. package/src/components/unsplash-page/fetch-unsplash-data.js +3 -3
  73. package/src/components/unsplash-page/unsplash-page.js +33 -33
  74. package/src/components/unsplash-page/unsplash-page.module.css +1 -1
  75. package/src/css/alerts.css +2 -2
  76. package/src/css/forms/forms.css +4 -4
  77. package/src/css/forms/validation.css +1 -1
  78. package/src/css/margin-padding-media.css +4 -4
  79. package/src/css/margin-padding.css +4 -4
  80. package/src/css/reset.css +11 -11
  81. package/src/icons/read-me.md +1 -1
  82. package/src/minimo.css +3 -3
  83. package/src/utilities/better-text-with-places.js +22 -22
  84. package/src/utilities/better-text.js +42 -35
  85. package/src/utilities/classnames.js +8 -8
  86. package/src/utilities/cookies.js +6 -6
  87. package/src/utilities/create-id.js +3 -3
  88. package/src/utilities/disable-btns-on-submit.js +2 -2
  89. package/src/utilities/dom-builder/dom-builder.js +89 -86
  90. package/src/utilities/dom-builder/domBuilderBasicSetup.js +9 -9
  91. package/src/utilities/dom-builder/parseDomString.js +23 -23
  92. package/src/utilities/dom-builder-helpers/README.md +2 -2
  93. package/src/utilities/dom-builder-helpers/form-tags.js +100 -100
  94. package/src/utilities/dom-builder-helpers/picture-tag.js +39 -39
  95. package/src/utilities/enable-submit-btns.js +1 -1
  96. package/src/utilities/escape-html.js +2 -2
  97. package/src/utilities/generate-pwd.js +4 -4
  98. package/src/utilities/linked-dates.js +13 -13
  99. package/src/utilities/parse-file-size.js +6 -6
  100. package/src/utilities/random-id.js +3 -3
  101. package/src/utilities/relative-date.js +40 -40
  102. package/src/utilities/sentence-case.js +1 -1
  103. package/src/utilities/strip-tags.js +1 -1
  104. package/src/utilities/title-case.js +1 -1
  105. package/src/utilities/truncate-string.js +5 -5
  106. package/src/utilities/validation-error-class.js +12 -12
  107. package/src/web-components/json-table/json-table-component.js +123 -121
  108. package/src/web-components/json-table/json-table-component.module.css +6 -6
  109. package/src/web-components/json-table/json-table.minimo.tokens.mjs +6 -6
  110. package/src/web-components/json-table/readme.md +72 -108
  111. package/src/web-components/json-table/src/cell-content.js +25 -25
  112. package/src/web-components/json-table/src/content-utils.js +21 -21
  113. package/src/web-components/json-table/src/data-types.js +32 -32
  114. package/src/web-components/json-table/src/defaults.js +230 -191
  115. package/src/web-components/json-table/src/get-data.js +55 -38
  116. package/src/web-components/json-table/src/icons.js +17 -17
  117. package/src/web-components/json-table/src/info-section.js +18 -18
  118. package/src/web-components/json-table/src/main-builder.js +45 -45
  119. package/src/web-components/json-table/src/pagination.js +32 -32
  120. package/src/web-components/json-table/src/parse-cols.js +18 -18
  121. package/src/web-components/json-table/src/parse-rows.js +17 -17
  122. package/src/web-components/json-table/src/resolve-params.js +53 -41
  123. package/src/web-components/json-table/src/search.js +13 -13
  124. package/src/web-components/json-table/src/sorting.js +20 -20
  125. package/src/web-components/json-table/src/table-body.js +13 -13
  126. package/src/web-components/json-table/src/table-builder.js +34 -34
  127. package/src/web-components/json-table/src/table-tfoot.js +8 -8
  128. package/src/web-components/json-table/src/table-thead.js +21 -21
  129. package/src/web-components/json-table/src/update-info.js +11 -11
  130. package/types/classes.d.ts +2 -2
  131. package/types/global.d.ts +18 -12
@@ -1,33 +1,35 @@
1
- // build-tokens-src/build-source-modes.mjs
2
- // Alternative build path used when the project config sets `sourceModes`
3
- // (see config.mjs) instead of a single `source` array — typically for a
4
- // light/dark custom-properties split.
5
- //
6
- // For each mode, a separate StyleDictionary instance is built from that
7
- // mode's own `source` array. The generated `<selector> { ... }` CSS blocks
8
- // (selector: customPropsSelector, default ':root' — see config.mjs) are then
9
- // composed into a single destFile:
10
- // - the base mode's block stays as a plain `<selector> { ... }` rule, with
11
- // a `color-scheme: <all modes joined>;` declaration prepended (e.g.
12
- // "light dark")
13
- // - every other mode's block is wrapped in
14
- // `@media (prefers-color-scheme: <mode>) { <selector> { ... } }`, with a
15
- // `color-scheme: <mode>;` declaration prepended
16
- // customPropsGroups, mergeCustomProps and pxToRem apply per mode, exactly as
17
- // in the single-source build. addLayer (if set) wraps the whole composed
18
- // result in a single `@layer`, rather than one per mode.
19
- //
20
- // When sourceModes defines both a `light` and a `dark` key and
21
- // useLightDarkFunc is true (default), custom properties shared by both are
22
- // reconciled into a single `light-dark()` declaration instead of being split
23
- // across the base block and a `@media (prefers-color-scheme: dark)` rule —
24
- // see light-dark.mjs.
25
- //
26
- // JSON tokens (if jsonBuildPath is set) are produced per mode: one set of
27
- // files per mode, with `-<mode>` appended to each filename (see
28
- // buildJsonFiles() in formats/json.mjs), e.g. "tokens-light.jsonc" /
29
- // "tokens-dark.jsonc", or "size-light.jsonc" / "size-dark.jsonc" in
30
- // multi-file mode (jsonDestFile: null).
1
+ /*
2
+ build-tokens-src/build-source-modes.mjs
3
+ Percorso di build alternativo usato quando la config del progetto imposta `sourceModes`
4
+ (vedi config.mjs) al posto di un singolo array `source` — tipicamente per una
5
+ suddivisione light/dark delle custom properties.
6
+
7
+ Per ogni modalità viene costruita un'istanza separata di StyleDictionary a partire
8
+ dall'array `source` di quella modalità. I blocchi CSS generati `<selector> { ... }`
9
+ (selector: customPropsSelector, default ':root' — vedi config.mjs) vengono poi
10
+ composti in un unico destFile:
11
+ - il blocco della modalità base resta una semplice regola `<selector> { ... }`, con
12
+ una dichiarazione `color-scheme: <tutte le modalità unite>;` anteposta (ad es.
13
+ "light dark")
14
+ - il blocco di ogni altra modalità viene racchiuso in
15
+ `@media (prefers-color-scheme: <modalità>) { <selector> { ... } }`, con una
16
+ dichiarazione `color-scheme: <modalità>;` anteposta
17
+ customPropsGroups, mergeCustomProps e pxToRem si applicano per modalità, esattamente come
18
+ nella build a sorgente singola. addLayer (se impostato) racchiude l'intero risultato
19
+ composto in un unico `@layer`, anziché uno per modalità.
20
+
21
+ Quando sourceModes definisce sia una chiave `light` sia una `dark` e
22
+ useLightDarkFunc è true (default), le custom properties condivise da entrambe vengono
23
+ riconciliate in un'unica dichiarazione `light-dark()` invece di essere divise
24
+ tra il blocco base e una regola `@media (prefers-color-scheme: dark)` —
25
+ vedi light-dark.mjs.
26
+
27
+ I token JSON (se jsonBuildPath è impostato) vengono prodotti per modalità: un set di
28
+ file per modalità, con `-<modalità>` aggiunto a ogni nome di file (vedi
29
+ buildJsonFiles() in formats/json.mjs), ad es. "tokens-light.jsonc" /
30
+ "tokens-dark.jsonc", oppure "size-light.jsonc" / "size-dark.jsonc" in
31
+ modalità multi-file (jsonDestFile: null).
32
+ */
31
33
 
32
34
  import StyleDictionary from 'style-dictionary';
33
35
  import * as path from 'node:path';
@@ -40,22 +42,22 @@ import { applyLightDarkFunc } from './light-dark.mjs';
40
42
 
41
43
  /**
42
44
  * @param {object} opts
43
- * @param {Record<string,string[]>} opts.sourceModes Resolved source paths per mode (see config.mjs)
44
- * @param {string} opts.baseMode Mode whose block stays a top-level `<selector> { ... }` rule
45
- * @param {string} opts.buildPath Absolute path for CSS output directory
46
- * @param {string} opts.destFile CSS output filename
47
- * @param {string|null} opts.jsonBuildPath Absolute path for JSON output (null = disabled)
48
- * @param {string|null} opts.jsonDestFile Base name for aggregated JSON file; null = one file per source
49
- * @param {'json'|'jsonc'} opts.jsonFormat Output format for JSON files
50
- * @param {'keep'|'calc'|'resolve'} opts.jsonExpression How to handle math expressions in dimension tokens
45
+ * @param {Record<string,string[]>} opts.sourceModes Percorsi sorgente risolti per modalità (vedi config.mjs)
46
+ * @param {string} opts.baseMode Modalità il cui blocco resta una regola `<selector> { ... }` di primo livello
47
+ * @param {string} opts.buildPath Percorso assoluto della directory di output CSS
48
+ * @param {string} opts.destFile Nome del file CSS di output
49
+ * @param {string|null} opts.jsonBuildPath Percorso assoluto dell'output JSON (null = disattivato)
50
+ * @param {string|null} opts.jsonDestFile Nome base del file JSON aggregato; null = un file per sorgente
51
+ * @param {'json'|'jsonc'} opts.jsonFormat Formato di output dei file JSON
52
+ * @param {'keep'|'calc'|'resolve'} opts.jsonExpression Come gestire le espressioni matematiche nei token dimension
51
53
  * @param {{name:string,prefixes:string[]}[]} opts.customPropsGroups
52
54
  * @param {boolean} opts.pxToRem
53
55
  * @param {string|null} opts.addLayer
54
- * @param {boolean|(string|RegExp)[]} opts.mergeCustomProps true = merge all sources, array = only the matching token source files
55
- * @param {boolean} opts.useLightDarkFunc reconcile shared `light`/`dark` properties into `light-dark()` calls (default: true — see config.mjs and light-dark.mjs). Ignored unless sourceModes defines both a `light` and a `dark` key.
56
- * @param {string} opts.customPropsSelector CSS selector wrapping the generated block(s) (default: ':root' — see config.mjs)
57
- * @param {string[]} opts.parserNames Style Dictionary parser names to opt every instance into (legacy bridge, plus the token-rename parser when at least one source has a `transform` — see build-tokens.mjs)
58
- * @param {string[]} opts.preprocessorNames Style Dictionary preprocessor names to opt every instance into (the token-rename reference rewriter, when at least one source has a `transform` — see build-tokens.mjs)
56
+ * @param {boolean|(string|RegExp)[]} opts.mergeCustomProps true = unisce tutte le sorgenti, array = solo i file token sorgente corrispondenti
57
+ * @param {boolean} opts.useLightDarkFunc riconcilia le proprietà `light`/`dark` condivise in chiamate `light-dark()` (default: true — vedi config.mjs e light-dark.mjs). Ignorato a meno che sourceModes definisca sia una chiave `light` sia una `dark`.
58
+ * @param {string} opts.customPropsSelector selettore CSS che racchiude i blocchi generati (default: ':root' — vedi config.mjs)
59
+ * @param {string[]} opts.parserNames nomi dei parser di Style Dictionary a cui far aderire ogni istanza (bridge legacy, più il parser di rinomina dei token quando almeno una sorgente ha un `transform` — vedi build-tokens.mjs)
60
+ * @param {string[]} opts.preprocessorNames nomi dei preprocessor di Style Dictionary a cui far aderire ogni istanza (il riscrittore dei riferimenti di rinomina dei token, quando almeno una sorgente ha un `transform` — vedi build-tokens.mjs)
59
61
  * @returns {Promise<{cssDestPath: string, totalCustomProps: number, jsonFilesByMode: Record<string, object[]>}>}
60
62
  */
61
63
  export const buildSourceModes = async ({
@@ -78,8 +80,8 @@ export const buildSourceModes = async ({
78
80
  }) => {
79
81
  const modeNames = Object.keys(sourceModes);
80
82
 
81
- // Read the pre-existing destFile (if any) BEFORE any Style Dictionary
82
- // instance runs, since the first one to write would overwrite it.
83
+ // Legge il destFile preesistente (se c'è) PRIMA che venga eseguita qualsiasi istanza
84
+ // di Style Dictionary, dato che la prima a scrivere lo sovrascriverebbe.
83
85
  if (mergeCustomProps) {
84
86
  loadExistingCustomPropsScoped(path.join(buildPath, destFile), baseMode, mergeCustomProps, customPropsSelector);
85
87
  }
@@ -90,12 +92,14 @@ export const buildSourceModes = async ({
90
92
 
91
93
  /** @type {Record<string,string>} */
92
94
  const modeBlocks = {};
93
- // Per-mode custom-prop count and structured (name -> tail) props map,
94
- // captured right after each per-mode format call (customPropsCount and
95
- // lastFinalProps are live bindings, updated synchronously by the format
96
- // function — see formats/css.mjs). Kept per mode (rather than summed on
97
- // the fly) so applyLightDarkFunc() can later overwrite just the entries it
98
- // actually touches (light, dark, and the base mode).
95
+ /*
96
+ Conteggio delle custom props per modalità e mappa strutturata delle props (nome -> coda),
97
+ catturati subito dopo ogni chiamata al format per modalità (customPropsCount e
98
+ lastFinalProps sono live binding, aggiornati in modo sincrono dalla funzione
99
+ format — vedi formats/css.mjs). Conservati per modalità (invece di sommarli
100
+ al volo) così che applyLightDarkFunc() possa poi sovrascrivere solo le voci che
101
+ tocca davvero (light, dark e la modalità base).
102
+ */
99
103
  /** @type {Record<string,number>} */
100
104
  const modeCounts = {};
101
105
  /** @type {Record<string, Record<string,string>>} */
@@ -104,12 +108,14 @@ export const buildSourceModes = async ({
104
108
  const jsonFilesByMode = {};
105
109
 
106
110
  for (const mode of modeNames) {
107
- // Non-base modes may reference base-mode tokens (always defined, since
108
- // the base block is the unconditional top-level `<selector>`). The base
109
- // sources are passed as `include`: available for reference resolution
110
- // but flagged isSource: false, and skipped by the css/json formats.
111
- // Base-mode-only on purpose: a reference to a token that exists only in
112
- // another `@media` block would build fine but be undefined at runtime.
111
+ /*
112
+ Le modalità non base possono referenziare i token della modalità base (sempre definiti, dato che
113
+ il blocco base è il `<selector>` di primo livello incondizionato). Le sorgenti
114
+ base vengono passate come `include`: disponibili per la risoluzione dei riferimenti
115
+ ma contrassegnate isSource: false, e saltate dai format css/json.
116
+ Solo la modalità base, volutamente: un riferimento a un token che esiste solo in
117
+ un altro blocco `@media` verrebbe compilato senza errori ma risulterebbe non definito a runtime.
118
+ */
113
119
  const include = mode === baseMode ? [] : sourceModes[baseMode];
114
120
 
115
121
  const sd = new StyleDictionary({
@@ -138,12 +144,12 @@ export const buildSourceModes = async ({
138
144
  },
139
145
  });
140
146
 
141
- // formatPlatform() runs the format function without writing to disk —
142
- // the composed multi-mode file is written once, at the end, below.
147
+ // formatPlatform() esegue la funzione format senza scrivere su disco —
148
+ // il file composto multi-modalità viene scritto una sola volta, alla fine, qui sotto.
143
149
  const [formatted] = await sd.formatPlatform('css');
144
150
  modeBlocks[mode] = /** @type {string} */ (formatted.output);
145
- // customPropsCount / lastFinalProps are live bindings, updated
146
- // synchronously by the format function called above (see formats/css.mjs).
151
+ // customPropsCount / lastFinalProps sono live binding, aggiornati in modo
152
+ // sincrono dalla funzione format chiamata qui sopra (vedi formats/css.mjs).
147
153
  modeCounts[mode] = customPropsCount;
148
154
  modeFinalProps[mode] = lastFinalProps;
149
155
 
@@ -170,10 +176,12 @@ export const buildSourceModes = async ({
170
176
  }
171
177
  }
172
178
 
173
- // ── light-dark() reconciliation (light/dark modes only) ──────────────────
174
- // Rebuilds just the `light`, `dark` and base-mode blocks from the adjusted
175
- // props maps — see light-dark.mjs. No-op (returns null) unless sourceModes
176
- // defines both a `light` and a `dark` key.
179
+ // ── Riconciliazione light-dark() (solo modalità light/dark) ──────────────────
180
+ /*
181
+ Ricostruisce solo i blocchi `light`, `dark` e della modalità base a partire dalle mappe
182
+ di props modificate — vedi light-dark.mjs. Non fa nulla (restituisce null) a meno che sourceModes
183
+ definisca sia una chiave `light` sia una `dark`.
184
+ */
177
185
  if (useLightDarkFunc) {
178
186
  const reconciled = applyLightDarkFunc({
179
187
  modeFinalProps,
@@ -190,11 +198,13 @@ export const buildSourceModes = async ({
190
198
 
191
199
  const totalCustomProps = Object.values(modeCounts).reduce((sum, n) => sum + n, 0);
192
200
 
193
- // ── Compose the final CSS ────────────────────────────────────────────────
194
- // A mode left with zero custom properties — typically a `light`/`dark`
195
- // mode fully absorbed by applyLightDarkFunc() into the base mode's
196
- // light-dark() declarations — gets no `@media` block at all, rather than
197
- // an empty (but harmless) one.
201
+ // ── Composizione del CSS finale ────────────────────────────────────────────────
202
+ /*
203
+ Una modalità rimasta senza alcuna custom property — tipicamente una modalità `light`/`dark`
204
+ completamente assorbita da applyLightDarkFunc() nelle dichiarazioni light-dark()
205
+ della modalità base — non ottiene alcun blocco `@media`, invece di
206
+ un blocco vuoto (ma innocuo).
207
+ */
198
208
  const otherModes = modeNames.filter((mode) => mode !== baseMode && modeCounts[mode] > 0);
199
209
 
200
210
  let composed = modeBlocks[baseMode];
@@ -202,9 +212,11 @@ export const buildSourceModes = async ({
202
212
  composed += `\n@media (prefers-color-scheme: ${mode}) {\n${modeBlocks[mode]}}\n`;
203
213
  }
204
214
 
205
- // addLayer wraps the whole composed result once, rather than once per
206
- // mode. Indentation is left to stylelint's fix step (run right after the
207
- // build), same as the single-source build.
215
+ /*
216
+ addLayer racchiude l'intero risultato composto una sola volta, anziché una volta per
217
+ modalità. L'indentazione è lasciata al passaggio di fix di stylelint (eseguito subito dopo la
218
+ build), come nella build a sorgente singola.
219
+ */
208
220
  const finalCss = addLayer
209
221
  ? `@layer ${addLayer} {\n\n${composed}}\n`
210
222
  : composed;
@@ -1,10 +1,12 @@
1
1
  /// <reference types="node" />
2
- // build-tokens-src/config.mjs
3
- // Reads the --config flag from argv, imports the project config file,
4
- // resolves all paths and exports them for build-tokens.mjs.
5
- //
6
- // Keeping this logic separate from the entry point makes it easier to test
7
- // and reuse in other scripts.
2
+ /*
3
+ build-tokens-src/config.mjs
4
+ Legge il flag --config da argv, importa il file di configurazione del progetto,
5
+ risolve tutti i percorsi e li esporta per build-tokens.mjs.
6
+
7
+ Tenere questa logica separata dal punto di ingresso ne facilita il test
8
+ e il riutilizzo in altri script.
9
+ */
8
10
 
9
11
  /* globals process */
10
12
 
@@ -13,7 +15,7 @@ import { pathToFileURL } from 'node:url';
13
15
  import { splitSourceEntries } from './source-prefixes.mjs';
14
16
 
15
17
  // ---------------------------------------------------------------------------
16
- // Read the --config flag
18
+ // Legge il flag --config
17
19
  // ---------------------------------------------------------------------------
18
20
  const args = process.argv.slice(2);
19
21
  const configFlagIndex = args.indexOf('--config');
@@ -31,64 +33,74 @@ export const configAbsPath = path.resolve(process.cwd(), configArgPath);
31
33
  export const configDir = path.dirname(configAbsPath);
32
34
 
33
35
  // ---------------------------------------------------------------------------
34
- // Import the project config
36
+ // Importa la config del progetto
35
37
  // ---------------------------------------------------------------------------
36
38
  const buildConfig = (await import(pathToFileURL(configAbsPath).href)).default;
37
39
 
38
- // Helper: resolves a path relative to the config directory.
39
- // Leaves already-absolute paths untouched.
40
+ // Helper: risolve un percorso relativo alla directory della config.
41
+ // Lascia invariati i percorsi già assoluti.
40
42
  /** @param {string} p */
41
43
  const resolveFromConfig = (p) => path.resolve(configDir, p);
42
44
 
43
45
  // ---------------------------------------------------------------------------
44
- // Path resolution
46
+ // Risoluzione dei percorsi
45
47
  // ---------------------------------------------------------------------------
46
48
 
47
- // CSS output
49
+ // Output CSS
48
50
  export const buildPath = resolveFromConfig(buildConfig.buildPath);
49
51
  export const destFile = buildConfig.destFile;
50
52
 
51
53
  // Stylelint
52
54
  export const stylelintConfigPath = resolveFromConfig(buildConfig.stylelintConfigPath);
53
55
 
54
- // JSON — platform is active only if jsonBuildPath is set in the config
56
+ // JSON — la platform è attiva solo se jsonBuildPath è impostato nella config
55
57
  const jsonBuildPathRaw = buildConfig.jsonBuildPath ?? null;
56
58
  export const jsonBuildPath = jsonBuildPathRaw ? resolveFromConfig(jsonBuildPathRaw) : null;
57
59
 
58
- // jsonDestFile: base name (no extension) for the aggregated output file.
59
- // null → one file per source (mirrors the source structure)
60
- // string → single aggregated file (e.g. 'tokens' → 'tokens.jsonc')
61
- // The extension is added automatically based on jsonFormat.
60
+ /*
61
+ jsonDestFile: nome base (senza estensione) del file aggregato di output.
62
+ null → un file per sorgente (replica la struttura dei sorgenti)
63
+ string → singolo file aggregato (ad es. 'tokens' → 'tokens.jsonc')
64
+ L'estensione viene aggiunta automaticamente in base a jsonFormat.
65
+ */
62
66
  export const jsonDestFile = buildConfig.jsonDestFile ?? null;
63
67
 
64
- // jsonFormat: controls output format for the generated JSON token files.
65
- // 'jsonc' → .jsonc extension + generated-file disclaimer header
66
- // 'json' → plain .json, no disclaimer
67
- // Any value other than 'jsonc' is normalised to 'json'.
68
+ /*
69
+ jsonFormat: controlla il formato di output dei file JSON dei token generati.
70
+ 'jsonc' → estensione .jsonc + intestazione che segnala il file generato
71
+ 'json' → .json semplice, senza intestazione
72
+ Qualsiasi valore diverso da 'jsonc' viene normalizzato a 'json'.
73
+ */
68
74
  export const jsonFormat = buildConfig.jsonFormat === 'jsonc' ? 'jsonc' : 'json';
69
75
 
70
- // jsonExpression: controls how math expressions in dimension token values are handled.
71
- // 'keep' (default) — write the expression as-is
72
- // 'calc' — wrap in CSS calc()
73
- // 'resolve' — evaluate numerically; unit inherited from the first referenced token
76
+ /*
77
+ jsonExpression: controlla come vengono gestite le espressioni matematiche nei valori dei token dimension.
78
+ 'keep' (default) — scrive l'espressione così com'è
79
+ 'calc' — la racchiude in calc() CSS
80
+ 'resolve' — la valuta numericamente; unità ereditata dal primo token referenziato
81
+ */
74
82
  const VALID_EXPR_MODES = ['keep', 'calc', 'resolve'];
75
83
  export const jsonExpression = VALID_EXPR_MODES.includes(buildConfig.jsonExpression)
76
84
  ? buildConfig.jsonExpression
77
85
  : 'resolve';
78
86
 
79
- // pxToRem: if true (default), dimension token values expressed in px are
80
- // converted to rem in the generated CSS (see the size/pxToRem-smart
81
- // transform in build-tokens-src/transforms.mjs). Values in other units
82
- // (em, %, vh, dvw, ...) are never touched regardless of this option.
87
+ /*
88
+ pxToRem: se true (default), i valori dei token dimension espressi in px vengono
89
+ convertiti in rem nel CSS generato (vedi la transform size/pxToRem-smart
90
+ in build-tokens-src/transforms.mjs). I valori in altre unità
91
+ (em, %, vh, dvw, ...) non vengono mai toccati, indipendentemente da questa opzione.
92
+ */
83
93
  export const pxToRem = buildConfig.pxToRem !== false;
84
94
 
85
- // mergeCustomProps: if true, custom properties already present in the CSS
86
- // destination file take priority over the ones generated by this build (see
87
- // build-tokens-src/merge-css.mjs). It can also be an array of strings/RegExps:
88
- // only the properties generated by the token source files matching one of its
89
- // entries are merged. An empty or invalid array means false. Explicit false
90
- // disables the merge entirely (the destination file is fully regenerated).
91
- // Default: true (i.e. when the key is left unset).
95
+ /*
96
+ mergeCustomProps: se true, le custom properties già presenti nel file CSS di
97
+ destinazione hanno priorità su quelle generate da questa build (vedi
98
+ build-tokens-src/merge-css.mjs). Può essere anche un array di stringhe/RegExp:
99
+ vengono unite solo le proprietà generate dai file token sorgente che corrispondono a una
100
+ delle sue voci. Un array vuoto o non valido equivale a false. false esplicito
101
+ disattiva del tutto il merge (il file di destinazione viene rigenerato completamente).
102
+ Default: true (cioè quando la chiave non è impostata).
103
+ */
92
104
  /** @type {boolean|(string|RegExp)[]} */
93
105
  export const mergeCustomProps = (() => {
94
106
  const value = buildConfig.mergeCustomProps;
@@ -101,63 +113,73 @@ export const mergeCustomProps = (() => {
101
113
  return false;
102
114
  })();
103
115
 
104
- // addLayer: wraps the generated custom properties inside a CSS `@layer`
105
- // at-rule (see formats/css.mjs), e.g. `@layer project { :root { ... } }`.
106
- // Set to null, undefined or false (default) to emit no layer.
116
+ /*
117
+ addLayer: racchiude le custom properties generate in una at-rule CSS `@layer`
118
+ (vedi formats/css.mjs), ad es. `@layer project { :root { ... } }`.
119
+ Impostare a null, undefined o false (default) per non emettere alcun layer.
120
+ */
107
121
  export const addLayer = buildConfig.addLayer ? String(buildConfig.addLayer).trim() : null;
108
122
 
109
- // customPropsSelector: CSS selector wrapping the generated custom properties
110
- // block(s) (see formats/css.mjs buildCssBlock()), instead of the default
111
- // `:root`. Applies uniformly to a single-source build and to a sourceModes
112
- // build (the base mode's top-level block and every other mode's block
113
- // nested under its own `@media (prefers-color-scheme: <mode>)` rule all use
114
- // the same selector). Falsy or blank values fall back to ':root'.
123
+ /*
124
+ customPropsSelector: selettore CSS che racchiude i blocchi di custom properties
125
+ generati (vedi formats/css.mjs buildCssBlock()), al posto del default
126
+ `:root`. Si applica in modo uniforme a una build a sorgente singola e a una build
127
+ con sourceModes (il blocco di primo livello della modalità base e il blocco di ogni altra modalità,
128
+ annidato nella propria regola `@media (prefers-color-scheme: <modalità>)`, usano
129
+ lo stesso selettore). Valori falsy o vuoti ripiegano su ':root'.
130
+ */
115
131
  export const customPropsSelector = typeof buildConfig.customPropsSelector === 'string'
116
132
  && buildConfig.customPropsSelector.trim()
117
133
  ? buildConfig.customPropsSelector.trim()
118
134
  : ':root';
119
135
 
120
- // useLightDarkFunc: with sourceModes set (see below) and defining both a
121
- // `light` and a `dark` key, custom properties present in both are written
122
- // once as `--name: light-dark(<light>, <dark>);` instead of being split
123
- // across the base mode's block and a
124
- // `@media (prefers-color-scheme: dark) { ... }` rule (see light-dark.mjs).
125
- // Ignored when sourceModes is not set, or does not define both a light and a
126
- // dark mode. Default: true.
136
+ /*
137
+ useLightDarkFunc: con sourceModes impostato (vedi sotto) e che definisce sia una
138
+ chiave `light` sia una `dark`, le custom properties presenti in entrambe vengono scritte
139
+ una sola volta come `--name: light-dark(<light>, <dark>);` invece di essere divise
140
+ tra il blocco della modalità base e una regola
141
+ `@media (prefers-color-scheme: dark) { ... }` (vedi light-dark.mjs).
142
+ Ignorata quando sourceModes non è impostato o non definisce sia una modalità light sia una
143
+ dark. Default: true.
144
+ */
127
145
  export const useLightDarkFunc = buildConfig.useLightDarkFunc !== false;
128
146
 
129
- // customPropsGroups: custom properties whose first hyphen-separated name
130
- // segment matches one of a group's prefixes are pulled out, labelled with
131
- // that group's name and moved to the beginning of the generated CSS file, in
132
- // group-list order (see formats/css.mjs). Each entry: { name, prefixes }.
133
- // Default: [].
147
+ /*
148
+ customPropsGroups: le custom properties il cui primo segmento del nome (separato
149
+ da trattini) corrisponde a uno dei prefissi di un gruppo vengono estratte, etichettate con
150
+ il nome del gruppo e spostate all'inizio del file CSS generato, nell'ordine
151
+ dell'elenco dei gruppi (vedi formats/css.mjs). Ogni voce: { name, prefixes }.
152
+ Default: [].
153
+ */
134
154
  export const customPropsGroups = Array.isArray(buildConfig.customPropsGroups)
135
155
  ? buildConfig.customPropsGroups
136
156
  : [];
137
157
 
138
- // ---------------------------------------------------------------------------
139
- // Source: resolve patterns relative to the config directory and normalise to
140
- // forward-slash absolute paths (fast-glob, used internally by Style Dictionary,
141
- // requires forward slashes even on Windows). See resolve-source-paths.mjs.
142
- //
143
- // WARNING: in the project config file, avoid building glob patterns with
144
- // path.join() — it may corrupt the pattern syntax. Use template literals:
145
- // OK: `${minimo_path}/**/*.{json,mjs}`
146
- // NO: path.join(minimo_path, '/**/*.{json,mjs}')
147
- //
148
- // sourceModes: alternative to `source`, for a light/dark (or other) custom
149
- // properties split — see build-tokens-src/build-source-modes.mjs. When set
150
- // (buildConfig.sourceModes is a non-null object), `source` is ignored and
151
- // each mode's own array of source patterns is resolved the same way.
152
- //
153
- // Entries of `source` / of each mode can also be `{ src, prefix, transform }`
154
- // objects, to render the custom properties of those files with a prefix
155
- // (see source-prefixes.mjs) and/or to rename token nodes within those files
156
- // (see source-transforms.mjs). They are flattened here into plain patterns
157
- // for Style Dictionary; the prefixed/transformed ones are also collected in
158
- // `prefixedSources`/`transformedSources`, to be registered by
159
- // build-tokens.mjs.
160
- // ---------------------------------------------------------------------------
158
+ /*
159
+ ---------------------------------------------------------------------------
160
+ Source: risolve i pattern relativi alla directory della config e li normalizza in
161
+ percorsi assoluti con forward slash (fast-glob, usato internamente da Style Dictionary,
162
+ richiede i forward slash anche su Windows). Vedi resolve-source-paths.mjs.
163
+
164
+ ATTENZIONE: nel file di configurazione del progetto, evitare di costruire i pattern glob con
165
+ path.join() — può corrompere la sintassi del pattern. Usare i template literal:
166
+ OK: `${minimo_path}/**\/*.{json,mjs}`
167
+ NO: path.join(minimo_path, '/**\/*.{json,mjs}')
168
+
169
+ sourceModes: alternativa a `source`, per una suddivisione light/dark (o altra) delle
170
+ custom properties — vedi build-tokens-src/build-source-modes.mjs. Quando è impostato
171
+ (buildConfig.sourceModes è un oggetto non null), `source` viene ignorato e
172
+ l'array di pattern sorgente di ogni modalità viene risolto allo stesso modo.
173
+
174
+ Le voci di `source` / di ogni modalità possono essere anche oggetti `{ src, prefix, transform }`,
175
+ per rendere le custom properties di quei file con un prefisso
176
+ (vedi source-prefixes.mjs) e/o per rinominare i nodi dei token al loro interno
177
+ (vedi source-transforms.mjs). Qui vengono appiattite in semplici pattern
178
+ per Style Dictionary; quelle con prefisso/transform vengono raccolte anche in
179
+ `prefixedSources`/`transformedSources`, da registrare in
180
+ build-tokens.mjs.
181
+ ---------------------------------------------------------------------------
182
+ */
161
183
  const sourceModesRaw = buildConfig.sourceModes ?? null;
162
184
 
163
185
  /** @type {import('./source-prefixes.mjs').PrefixedSource[]} */
@@ -186,11 +208,13 @@ export const sourceModes = sourceModesRaw
186
208
  )
187
209
  : null;
188
210
 
189
- // sourceModesBase: the mode whose declarations are written to the top-level
190
- // `:root { ... }` block (the others are nested under
191
- // `@media (prefers-color-scheme: <mode>) { ... }`). Default: the first key
192
- // of sourceModes (insertion order), e.g. 'light'. Ignored when sourceModes
193
- // is not set.
211
+ /*
212
+ sourceModesBase: la modalità le cui dichiarazioni vengono scritte nel blocco
213
+ `:root { ... }` di primo livello (le altre sono annidate in
214
+ `@media (prefers-color-scheme: <modalità>) { ... }`). Default: la prima chiave
215
+ di sourceModes (ordine di inserimento), ad es. 'light'. Ignorata quando sourceModes
216
+ non è impostato.
217
+ */
194
218
  export const sourceModesBase = sourceModes
195
219
  ? (Object.prototype.hasOwnProperty.call(sourceModes, buildConfig.sourceModesBase)
196
220
  ? buildConfig.sourceModesBase