@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,37 +1,39 @@
1
- // build-tokens-src/token-rename-parser.mjs
2
- // Implements the `transform` feature end-to-end (see source-transforms.mjs):
3
- //
4
- // 1. A Style Dictionary PARSER that moves/renames token nodes within a
5
- // source file's own tree, according to the `transform` map registered for
6
- // that file, BEFORE Style Dictionary merges files together and resolves
7
- // {references}.
8
- // 2. A Style Dictionary PREPROCESSOR that, once every file has been parsed
9
- // and merged into a single tree (but still before {references} are
10
- // resolved), rewrites every {reference} in the WHOLE tree that points to
11
- // one of the renamed tokens' OLD path, to its NEW path — so a reference
12
- // doesn't have to be hunted down and updated by hand just because the
13
- // token it points to was moved (in the same file or a completely
14
- // different one; see getAllRenames() in source-transforms.mjs for why
15
- // this is safe to do tree-wide).
16
- //
17
- // Only the exact concrete files that declare a `transform` are matched by
18
- // the parser (the `pattern` built by transformedFilesPattern() in
19
- // source-transforms.mjs); every other file is untouched by it and falls
20
- // through to Style Dictionary's own built-in loader, or to the legacy bridge
21
- // parser (legacy-tokens-parser.mjs) for plain .json sources. The
22
- // preprocessor, instead, always runs over the entire merged tree once
23
- // registered — it just has nothing to rewrite where no reference matches a
24
- // renamed path.
25
- //
26
- // Style Dictionary's combineJSON always reads a source file's `contents` as
27
- // raw text and hands it to whichever parser(s) match, regardless of
28
- // extension (see node_modules/style-dictionary/lib/utils/combineJSON.js) — a
29
- // custom parser never receives an already-executed .mjs module or an
30
- // already-JSON5-parsed object. The parser therefore has to load the file
31
- // itself the same way Style Dictionary's own loader (loadFile.js) would:
32
- // dynamic `import()` for .mjs/.js, JSON5 for .jsonc/.json5, and the existing
33
- // legacy-or-DTCG bridge (parseLegacyFile, reused as-is so hybrid-node
34
- // handling stays consistent) for .json.
1
+ /*
2
+ build-tokens-src/token-rename-parser.mjs
3
+ Implementa la funzionalità `transform` end-to-end (vedi source-transforms.mjs):
4
+
5
+ 1. Un PARSER di Style Dictionary che sposta/rinomina i nodi dei token nell'albero
6
+ di un file sorgente, in base alla mappa `transform` registrata per
7
+ quel file, PRIMA che Style Dictionary unisca i file e risolva i
8
+ {riferimenti}.
9
+ 2. Un PREPROCESSOR di Style Dictionary che, una volta che ogni file è stato letto
10
+ e unito in un unico albero (ma sempre prima che i {riferimenti} vengano
11
+ risolti), riscrive ogni {riferimento} nell'INTERO albero che punta al
12
+ VECCHIO percorso di uno dei token rinominati, col suo NUOVO percorso — così che un riferimento
13
+ non debba essere cercato e aggiornato a mano solo perché il
14
+ token a cui punta è stato spostato (nello stesso file o in uno completamente
15
+ diverso; vedi getAllRenames() in source-transforms.mjs per capire perché
16
+ farlo su tutto l'albero è sicuro).
17
+
18
+ Il parser considera solo i file concreti esatti che dichiarano un `transform` (il
19
+ `pattern` costruito da transformedFilesPattern() in
20
+ source-transforms.mjs); ogni altro file non viene toccato e passa
21
+ al loader integrato di Style Dictionary, oppure al parser bridge legacy
22
+ (legacy-tokens-parser.mjs) per i semplici sorgenti .json. Il
23
+ preprocessor, invece, una volta registrato viene sempre eseguito sull'intero albero unito
24
+ — semplicemente non ha nulla da riscrivere dove nessun riferimento corrisponde a un
25
+ percorso rinominato.
26
+
27
+ combineJSON di Style Dictionary legge sempre il `contents` di un file sorgente come
28
+ testo grezzo e lo passa ai parser che corrispondono, indipendentemente dall'
29
+ estensione (vedi node_modules/style-dictionary/lib/utils/combineJSON.js) — un
30
+ parser personalizzato non riceve mai un modulo .mjs già eseguito né un oggetto
31
+ già letto come JSON5. Il parser deve quindi caricare il file da sé, nello stesso modo
32
+ del loader di Style Dictionary (loadFile.js):
33
+ `import()` dinamico per .mjs/.js, JSON5 per .jsonc/.json5, e il bridge
34
+ legacy-o-DTCG esistente (parseLegacyFile, riutilizzato così com'è perché la gestione dei
35
+ nodi ibridi resti coerente) per .json.
36
+ */
35
37
 
36
38
  import StyleDictionary from 'style-dictionary';
37
39
  import JSON5 from 'json5';
@@ -53,9 +55,11 @@ const getAtPath = (tree, pathSegments) => pathSegments.reduce(
53
55
  tree
54
56
  );
55
57
 
56
- // Removes the node at pathSegments (mutates tree), pruning parent groups left
57
- // empty by the removal (innermost first), so a fully-emptied group doesn't
58
- // linger as `{}` in the output tree.
58
+ /*
59
+ Rimuove il nodo in pathSegments (modifica tree), potando i gruppi padre rimasti
60
+ vuoti dopo la rimozione (dal più interno), così che un gruppo svuotato del tutto non
61
+ resti come `{}` nell'albero di output.
62
+ */
59
63
  /** @param {Record<string, unknown>} tree @param {string[]} pathSegments */
60
64
  const deleteAtPath = (tree, pathSegments) => {
61
65
  if (pathSegments.length === 0) return;
@@ -81,8 +85,8 @@ const deleteAtPath = (tree, pathSegments) => {
81
85
  }
82
86
  };
83
87
 
84
- // Inserts `value` at pathSegments (mutates tree), creating intermediate
85
- // group objects as needed.
88
+ // Inserisce `value` in pathSegments (modifica tree), creando i gruppi
89
+ // intermedi necessari.
86
90
  /** @param {Record<string, unknown>} tree @param {string[]} pathSegments @param {unknown} value */
87
91
  const setAtPath = (tree, pathSegments, value) => {
88
92
  let node = tree;
@@ -94,25 +98,27 @@ const setAtPath = (tree, pathSegments, value) => {
94
98
  node[pathSegments[pathSegments.length - 1]] = value;
95
99
  };
96
100
 
97
- // A build can create several StyleDictionary instances over the same source
98
- // file (e.g. one throwaway pass to enumerate concrete file paths, one for the
99
- // real build — see build-tokens.mjs), each re-running this parser. Tracked so
100
- // a missing source key is only ever warned about once per process, instead of
101
- // once per pass.
101
+ /*
102
+ Una build può creare più istanze di StyleDictionary sullo stesso file
103
+ sorgente (ad es. un passaggio usa e getta per enumerare i percorsi concreti dei file, uno per la
104
+ build vera — vedi build-tokens.mjs), ognuna delle quali riesegue questo parser. Viene tracciato
105
+ così che una chiave sorgente mancante venga segnalata una sola volta per processo, invece che
106
+ una volta per passaggio.
107
+ */
102
108
  /** @type {Set<string>} */
103
109
  const warnedMissingKeys = new Set();
104
110
 
105
111
  /**
106
- * Applies a rename map to a parsed DTCG tree: moves each mapped source path's
107
- * node to its destination path. Two phases (collect+delete, then insert) so
108
- * that a destination path used by one entry and a source path used by
109
- * another never interfere with each other depending on map order. A source
110
- * key not found in the tree only produces a console warning — it does not
111
- * fail the build, since a project config may target a key that's only
112
- * sometimes present.
112
+ * Applica una mappa di rinomina a un albero DTCG già letto: sposta il nodo di ogni percorso
113
+ * sorgente mappato verso il suo percorso di destinazione. Due fasi (raccolta+eliminazione, poi
114
+ * inserimento) così che un percorso di destinazione usato da una voce e un percorso
115
+ * sorgente usato da un'altra non interferiscano mai tra loro in base all'ordine della mappa. Una chiave
116
+ * sorgente non trovata nell'albero produce solo un warning in console — non
117
+ * fa fallire la build, dato che la config di un progetto può puntare a una chiave presente
118
+ * solo a volte.
113
119
  * @param {unknown} tree
114
120
  * @param {Record<string,string>} renameMap dot-path -> dot-path
115
- * @param {string} filePath only used for the warning message
121
+ * @param {string} filePath usato solo per il messaggio di warning
116
122
  * @returns {unknown}
117
123
  */
118
124
  export const applyTokenRenameMap = (tree, renameMap, filePath) => {
@@ -153,9 +159,11 @@ const loadTree = async (filePath) => {
153
159
  try {
154
160
  return structuredClone(mod.default);
155
161
  } catch {
156
- // Cloning may fail for content with non-cloneable values (e.g.
157
- // functions) — fall back to the live module object, same as Style
158
- // Dictionary's own loadFile.js.
162
+ /*
163
+ La clonazione può fallire per contenuti con valori non clonabili (ad es.
164
+ funzioni) — ripiega sull'oggetto modulo attivo, come il loadFile.js
165
+ di Style Dictionary.
166
+ */
159
167
  return mod.default;
160
168
  }
161
169
  }
@@ -163,21 +171,23 @@ const loadTree = async (filePath) => {
163
171
  const contents = await readFile(filePath, 'utf-8');
164
172
 
165
173
  if (ext === '.json') {
166
- // Reuses the legacy-or-DTCG bridge so hybrid-node conversion stays
167
- // consistent with every other .json source in the project.
174
+ // Riutilizza il bridge legacy-o-DTCG così che la conversione dei nodi ibridi resti
175
+ // coerente con ogni altra sorgente .json del progetto.
168
176
  return parseLegacyFile(contents, filePath);
169
177
  }
170
178
 
171
- // .jsonc, .json5, or anything else: the same JSON5 parsing Style
172
- // Dictionary's own built-in loader uses for these extensions.
179
+ // .jsonc, .json5 o qualsiasi altro: lo stesso parsing JSON5 che il loader integrato di
180
+ // Style Dictionary usa per queste estensioni.
173
181
  return JSON5.parse(contents);
174
182
  };
175
183
 
176
- // Registers the parser globally on the StyleDictionary class. To actually
177
- // run it, a Style Dictionary instance must also opt in via
178
- // `parsers: [..., TOKEN_RENAME_PARSER_NAME]` (see build-tokens.mjs,
179
- // build-source-modes.mjs, check-unresolved-custom-props.mjs) — same
180
- // activation model as the legacy bridge parser.
184
+ /*
185
+ Registra il parser globalmente sulla classe StyleDictionary. Per eseguirlo
186
+ effettivamente, un'istanza di Style Dictionary deve anche aderire tramite
187
+ `parsers: [..., TOKEN_RENAME_PARSER_NAME]` (vedi build-tokens.mjs,
188
+ build-source-modes.mjs, check-unresolved-custom-props.mjs) — stesso
189
+ modello di attivazione del parser bridge legacy.
190
+ */
181
191
  /** @param {RegExp} pattern from transformedFilesPattern() in source-transforms.mjs */
182
192
  export const registerTokenRenameParser = (pattern) => {
183
193
  StyleDictionary.registerParser({
@@ -191,19 +201,20 @@ export const registerTokenRenameParser = (pattern) => {
191
201
  });
192
202
  };
193
203
 
194
- // ── Reference rewriting (preprocessor) ──────────────────────────────────────
195
- //
196
- // Matches a bare {reference} (not a CSS function containing one, e.g.
197
- // "color-mix(in srgb, {primary} 60%, #000)" still matches the {primary} part
198
- // only) — same pattern style as LEGACY_REF in legacy-tokens-parser.mjs.
204
+ // ── Riscrittura dei riferimenti (preprocessor) ──────────────────────────────────────
205
+ /*
206
+ Corrisponde a un semplice {riferimento} (non a una funzione CSS che ne contiene uno, ad es.
207
+ "color-mix(in srgb, {primary} 60%, #000)" corrisponde comunque solo alla parte {primary}) —
208
+ stesso stile di pattern di LEGACY_REF in legacy-tokens-parser.mjs.
209
+ */
199
210
  const REF = /\{([^}]+)\}/g;
200
211
 
201
212
  /**
202
- * Replaces every {reference} in `value` (a token's $value, possibly nested —
203
- * composite/shadow/gradient objects, arrays) whose dot-path exactly matches a
204
- * "from" key of `renames`, with `{<to>}`. References that don't match any
205
- * renamed key (including partial/longer paths, e.g. {primary.200} when only
206
- * "primary" was renamed) are left untouched.
213
+ * Sostituisce ogni {riferimento} in `value` (il $value di un token, eventualmente annidato —
214
+ * oggetti/array composite/shadow/gradient) il cui dot-path corrisponde esattamente a una
215
+ * chiave "from" di `renames`, con `{<to>}`. I riferimenti che non corrispondono a nessuna
216
+ * chiave rinominata (inclusi i percorsi parziali/più lunghi, ad es. {primary.200} quando è stata
217
+ * rinominata solo "primary") restano intatti.
207
218
  * @param {unknown} value
208
219
  * @param {Map<string,string>} renames
209
220
  * @returns {unknown}
@@ -220,11 +231,11 @@ const rewriteRefs = (value, renames) => {
220
231
  };
221
232
 
222
233
  /**
223
- * Walks the merged token tree (every source file, already combined by Style
224
- * Dictionary — see StyleDictionary.js's `preprocess()` call site) and, for
225
- * every leaf token (a node with `$value`), rewrites {references} in its
226
- * `$value` only — never touching `$type`, `filePath`, `isSource` or any other
227
- * metadata Style Dictionary attaches to the node.
234
+ * Percorre l'albero di token unito (ogni file sorgente, già combinato da Style
235
+ * Dictionary — vedi il punto di chiamata di `preprocess()` in StyleDictionary.js) e, per
236
+ * ogni token foglia (un nodo con `$value`), riscrive i {riferimenti} nel suo
237
+ * solo `$value` — senza mai toccare `$type`, `filePath`, `isSource` o qualsiasi altro
238
+ * metadato che Style Dictionary attacca al nodo.
228
239
  * @param {unknown} node
229
240
  * @param {Map<string,string>} renames
230
241
  * @returns {unknown}
@@ -239,13 +250,15 @@ const rewriteTreeRefs = (node, renames) => {
239
250
  );
240
251
  };
241
252
 
242
- // Registers the preprocessor globally. To actually run it, a Style
243
- // Dictionary instance must also opt in via
244
- // `preprocessors: [TOKEN_RENAME_PREPROCESSOR_NAME]` (see build-tokens.mjs,
245
- // build-source-modes.mjs, check-unresolved-custom-props.mjs). A no-op
246
- // (returns the tree unchanged) when getAllRenames() is empty — e.g. every
247
- // registered transform turned out to be file-ambiguous (see
248
- // registerSourceTransforms() in source-transforms.mjs).
253
+ /*
254
+ Registra il preprocessor globalmente. Per eseguirlo effettivamente, un'istanza di
255
+ Style Dictionary deve anche aderire tramite
256
+ `preprocessors: [TOKEN_RENAME_PREPROCESSOR_NAME]` (vedi build-tokens.mjs,
257
+ build-source-modes.mjs, check-unresolved-custom-props.mjs). È un no-op
258
+ (restituisce l'albero invariato) quando getAllRenames() è vuoto — ad es. quando ogni
259
+ transform registrata si è rivelata ambigua tra file (vedi
260
+ registerSourceTransforms() in source-transforms.mjs).
261
+ */
249
262
  export const registerTokenRenamePreprocessor = () => {
250
263
  StyleDictionary.registerPreprocessor({
251
264
  name: TOKEN_RENAME_PREPROCESSOR_NAME,
@@ -1,14 +1,16 @@
1
- // build-tokens-src/transforms.mjs
2
- // Registers all custom Style Dictionary transforms.
3
- // Imported once by build-tokens.mjs before buildAllPlatforms() is called.
1
+ /*
2
+ build-tokens-src/transforms.mjs
3
+ Registra tutte le transform personalizzate di Style Dictionary.
4
+ Importato una sola volta da build-tokens.mjs prima di chiamare buildAllPlatforms().
5
+ */
4
6
 
5
7
  import StyleDictionary from 'style-dictionary';
6
8
  import { getSourcePrefix } from './source-prefixes.mjs';
7
9
 
8
10
  const BASE_FONT_SIZE = 16;
9
11
 
10
- // Converts a px value to rem. Returns the original string unchanged for
11
- // non-px values, and '0' for zero values regardless of unit.
12
+ // Converte un valore px in rem. Restituisce invariata la stringa originale per i
13
+ // valori non px, e '0' per i valori zero indipendentemente dall'unità.
12
14
  const toRem = (val) => {
13
15
  if (val === undefined || val === null) return '0';
14
16
  const str = String(val).trim();
@@ -19,11 +21,13 @@ const toRem = (val) => {
19
21
  return str;
20
22
  };
21
23
 
22
- // ---------------------------------------------------------------------------
23
- // 1. Shadow
24
- // Converts shadow token objects (single or array) to a CSS box-shadow string.
25
- // px values are converted to rem. Alias references are resolved transitively.
26
- // ---------------------------------------------------------------------------
24
+ /*
25
+ ---------------------------------------------------------------------------
26
+ 1. Shadow
27
+ Converte gli oggetti token shadow (singoli o array) in una stringa CSS box-shadow.
28
+ I valori px vengono convertiti in rem. I riferimenti alias vengono risolti in modo transitivo.
29
+ ---------------------------------------------------------------------------
30
+ */
27
31
  StyleDictionary.registerTransform({
28
32
  name: 'shadow/css',
29
33
  type: 'value',
@@ -38,7 +42,7 @@ StyleDictionary.registerTransform({
38
42
 
39
43
  const shadows = Array.isArray(value) ? value : [value];
40
44
 
41
- // Already a resolved CSS string (e.g. from an alias)
45
+ // È già una stringa CSS risolta (ad es. da un alias)
42
46
  if (shadows.length === 1 && typeof shadows[0] === 'string') return shadows[0];
43
47
 
44
48
  return shadows
@@ -55,9 +59,11 @@ StyleDictionary.registerTransform({
55
59
  },
56
60
  });
57
61
 
58
- // ---------------------------------------------------------------------------
59
- // 2. px → rem (dimension tokens only, skips values already in rem, %, em, ...)
60
- // ---------------------------------------------------------------------------
62
+ /*
63
+ ---------------------------------------------------------------------------
64
+ 2. px → rem (solo token dimension, salta i valori già in rem, %, em, ...)
65
+ ---------------------------------------------------------------------------
66
+ */
61
67
  StyleDictionary.registerTransform({
62
68
  name: 'size/pxToRem-smart',
63
69
  type: 'value',
@@ -75,11 +81,13 @@ StyleDictionary.registerTransform({
75
81
  },
76
82
  });
77
83
 
78
- // ---------------------------------------------------------------------------
79
- // 3. Color passthrough
80
- // Ensures the resolved value is returned as-is, supporting both $value and
81
- // legacy value fields and transitive alias resolution.
82
- // ---------------------------------------------------------------------------
84
+ /*
85
+ ---------------------------------------------------------------------------
86
+ 3. Passthrough dei colori
87
+ Garantisce che il valore risolto venga restituito così com'è, supportando sia i campi $value sia
88
+ i campi value legacy e la risoluzione transitiva degli alias.
89
+ ---------------------------------------------------------------------------
90
+ */
83
91
  StyleDictionary.registerTransform({
84
92
  name: 'color/css-modern',
85
93
  type: 'value',
@@ -87,8 +95,8 @@ StyleDictionary.registerTransform({
87
95
  filter: (token) => token.$type === 'color' || token.type === 'color',
88
96
  transform: (token) => {
89
97
  const original = token.original?.$value ?? token.original?.value;
90
- // If the original value is a CSS function containing {references},
91
- // return it untouched so the css format can resolve refs to var(--...)
98
+ // Se il valore originale è una funzione CSS che contiene {riferimenti},
99
+ // lo restituisce intatto così che il format css possa risolvere i riferimenti in var(--...)
92
100
  if (typeof original === 'string' && original.includes('{') && !original.startsWith('{')) {
93
101
  return original;
94
102
  }
@@ -96,12 +104,14 @@ StyleDictionary.registerTransform({
96
104
  },
97
105
  });
98
106
 
99
- // ---------------------------------------------------------------------------
100
- // 4. Gradient
101
- // Converts gradient token objects to CSS gradient functions.
102
- // Supports linear, radial and conic types. Alias references are resolved
103
- // transitively; already-resolved strings are returned unchanged.
104
- // ---------------------------------------------------------------------------
107
+ /*
108
+ ---------------------------------------------------------------------------
109
+ 4. Gradient
110
+ Converte gli oggetti token gradient in funzioni CSS gradient.
111
+ Supporta i tipi linear, radial e conic. I riferimenti alias vengono risolti
112
+ in modo transitivo; le stringhe già risolte vengono restituite invariate.
113
+ ---------------------------------------------------------------------------
114
+ */
105
115
  StyleDictionary.registerTransform({
106
116
  name: 'gradient/css',
107
117
  type: 'value',
@@ -110,8 +120,8 @@ StyleDictionary.registerTransform({
110
120
  transform: (token) => {
111
121
  const original = token.original?.$value ?? token.original?.value;
112
122
 
113
- // If the original is a CSS function containing {references}, return it
114
- // untouched so the css format can resolve refs to var(--...).
123
+ // Se l'originale è una funzione CSS che contiene {riferimenti}, lo restituisce
124
+ // intatto così che il format css possa risolvere i riferimenti in var(--...).
115
125
  if (typeof original === 'string' && original.includes('{') && !original.startsWith('{')) {
116
126
  return original;
117
127
  }
@@ -143,11 +153,13 @@ StyleDictionary.registerTransform({
143
153
  },
144
154
  });
145
155
 
146
- // ---------------------------------------------------------------------------
147
- // 5. Composite (border, outline, transition, animation)
148
- // Converts composite token objects to their CSS shorthand equivalents.
149
- // Only applied to object values; strings pass through unchanged.
150
- // ---------------------------------------------------------------------------
156
+ /*
157
+ ---------------------------------------------------------------------------
158
+ 5. Composite (border, outline, transition, animation)
159
+ Converte gli oggetti token composite nei corrispondenti shorthand CSS.
160
+ Applicata solo ai valori oggetto; le stringhe passano invariate.
161
+ ---------------------------------------------------------------------------
162
+ */
151
163
  StyleDictionary.registerTransform({
152
164
  name: 'composite/css',
153
165
  type: 'value',
@@ -201,11 +213,13 @@ StyleDictionary.registerTransform({
201
213
  },
202
214
  });
203
215
 
204
- // ---------------------------------------------------------------------------
205
- // 6. Typography passthrough
206
- // Returns the token value as-is. The css/variables-sorted format is
207
- // responsible for exploding typography tokens into individual CSS properties.
208
- // ---------------------------------------------------------------------------
216
+ /*
217
+ ---------------------------------------------------------------------------
218
+ 6. Passthrough della tipografia
219
+ Restituisce il valore del token così com'è. Il format css/variables-sorted
220
+ si occupa di scomporre i token tipografici nelle singole proprietà CSS.
221
+ ---------------------------------------------------------------------------
222
+ */
209
223
  StyleDictionary.registerTransform({
210
224
  name: 'typography/css',
211
225
  type: 'value',
@@ -214,15 +228,17 @@ StyleDictionary.registerTransform({
214
228
  transform: (token) => token.$value ?? token.value,
215
229
  });
216
230
 
217
- // ---------------------------------------------------------------------------
218
- // 7. Kebab-case name with per-source prefix
219
- // Same as the built-in name/kebab, but prepends the prefix registered for the
220
- // token's source file (`{ src, prefix }` entries of `source`/`sourceModes`, see
221
- // source-prefixes.mjs), e.g. Open Props' gray.0 with prefix 'op' -> op-gray-0.
222
- // Only the name changes: the token path is untouched, so {references} keep
223
- // resolving and are rendered as var(--<prefixed-name>). Files without a
224
- // prefix get exactly the built-in name/kebab result.
225
- // ---------------------------------------------------------------------------
231
+ /*
232
+ ---------------------------------------------------------------------------
233
+ 7. Nome in kebab-case con prefisso per sorgente
234
+ Come il name/kebab predefinito, ma antepone il prefisso registrato per il
235
+ file sorgente del token (voci `{ src, prefix }` di `source`/`sourceModes`, vedi
236
+ source-prefixes.mjs), ad es. gray.0 di Open Props con prefisso 'op' -> op-gray-0.
237
+ Cambia solo il nome: il percorso del token resta intatto, quindi i {riferimenti} continuano a
238
+ essere risolti e vengono resi come var(--<nome-prefissato>). I file senza
239
+ prefisso ottengono esattamente il risultato del name/kebab predefinito.
240
+ ---------------------------------------------------------------------------
241
+ */
226
242
  StyleDictionary.registerTransform({
227
243
  name: 'name/kebab-prefixed',
228
244
  type: 'name',