@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,17 +1,21 @@
1
- // build-tokens-src/platforms.mjs
2
- // Builds and returns the `platforms` object for the Style Dictionary config.
3
- //
4
- // The `json` platform is included only if jsonBuildPath is set.
5
- // Output format (json/jsonc) and file splitting are delegated to buildJsonFiles().
1
+ /*
2
+ build-tokens-src/platforms.mjs
3
+ Costruisce e restituisce l'oggetto `platforms` per la config di Style Dictionary.
4
+
5
+ La platform `json` è inclusa solo se jsonBuildPath è impostato.
6
+ Il formato di output (json/jsonc) e la suddivisione in file sono delegati a buildJsonFiles().
7
+ */
6
8
 
7
9
  import { buildJsonFiles } from './formats/json.mjs';
8
10
 
9
11
  /** @typedef {import('style-dictionary/types').PlatformConfig} PlatformConfig */
10
12
 
11
- // Transforms applied to the CSS platform.
12
- // Exported so other scripts (e.g. check-unresolved-custom-props.mjs) can
13
- // build a Style Dictionary instance with matching transformed token names.
14
- // name/kebab-prefixed = name/kebab + per-source prefix (see source-prefixes.mjs).
13
+ /*
14
+ Transform applicate alla platform CSS.
15
+ Esportate così che altri script (ad es. check-unresolved-custom-props.mjs) possano
16
+ costruire un'istanza di Style Dictionary con nomi dei token trasformati in modo coerente.
17
+ name/kebab-prefixed = name/kebab + prefisso per sorgente (vedi source-prefixes.mjs).
18
+ */
15
19
  export const CSS_TRANSFORMS = [
16
20
  'attribute/cti',
17
21
  'name/kebab-prefixed',
@@ -25,13 +29,15 @@ export const CSS_TRANSFORMS = [
25
29
  'typography/css',
26
30
  ];
27
31
 
28
- // Transforms applied to the JSON platform.
29
- // Kept minimal on purpose: consuming tools expect original values (e.g. "16px"
30
- // not "1rem") and alias references ({...}) must be preserved to maintain
31
- // token links. Source prefixes are not applied here (plain name/kebab): the
32
- // JSON output keeps the original token tree.
33
- // Exported so build-source-modes.mjs can build a matching json platform per
34
- // sourceModes mode.
32
+ /*
33
+ Transform applicate alla platform JSON.
34
+ Volutamente minimali: gli strumenti che le usano si aspettano i valori originali (es. "16px"
35
+ e non "1rem") e i riferimenti alias ({...}) devono essere conservati per mantenere
36
+ i collegamenti tra token. I prefissi delle sorgenti non vengono applicati qui (name/kebab semplice): l'output
37
+ JSON mantiene l'albero dei token originale.
38
+ Esportate così che build-source-modes.mjs possa costruire una platform json corrispondente per ogni
39
+ modalità di sourceModes.
40
+ */
35
41
  export const JSON_TRANSFORMS = [
36
42
  'attribute/cti',
37
43
  'name/kebab',
@@ -40,20 +46,20 @@ export const JSON_TRANSFORMS = [
40
46
 
41
47
  /**
42
48
  * @param {object} opts
43
- * @param {string} opts.buildPath Absolute path for CSS output directory
44
- * @param {string} opts.destFile CSS output filename (e.g. "tokens.css")
45
- * @param {string|null} opts.jsonBuildPath Absolute path for JSON output (null = disabled)
46
- * @param {string|null} opts.jsonDestFile Base name for aggregated file; null = one file per source
47
- * @param {'json'|'jsonc'} opts.jsonFormat Output format for JSON files
48
- * @param {string[]} opts.concreteFilePaths Concrete (expanded) source file paths for multi-file mode.
49
- * Collected from sd.allTokens after SD initialisation.
50
- * Ignored when jsonDestFile is set.
51
- * @param {'keep'|'calc'|'resolve'} opts.jsonExpression How to handle math expressions in dimension tokens.
52
- * @param {{name: string, prefixes: string[]}[]} opts.customPropsGroups Named groups of name prefixes, moved to the top of the CSS output in list order.
53
- * @param {boolean} opts.pxToRem If false, skips the px→rem transform on the CSS platform. Default: true.
54
- * @param {string|null} opts.addLayer Wraps the generated custom properties inside `@layer <addLayer> { ... }`. null = no layer.
55
- * @param {string} opts.selector CSS selector wrapping the generated block (default: ':root').
56
- * @returns {Record<string, PlatformConfig>} platforms object ready for Style Dictionary config
49
+ * @param {string} opts.buildPath Percorso assoluto della directory di output CSS
50
+ * @param {string} opts.destFile Nome del file CSS di output (es. "tokens.css")
51
+ * @param {string|null} opts.jsonBuildPath Percorso assoluto dell'output JSON (null = disattivato)
52
+ * @param {string|null} opts.jsonDestFile Nome base del file aggregato; null = un file per sorgente
53
+ * @param {'json'|'jsonc'} opts.jsonFormat Formato di output dei file JSON
54
+ * @param {string[]} opts.concreteFilePaths Percorsi concreti (espansi) dei file sorgente per la modalità multi-file.
55
+ * Raccolti da sd.allTokens dopo l'inizializzazione di SD.
56
+ * Ignorato quando jsonDestFile è impostato.
57
+ * @param {'keep'|'calc'|'resolve'} opts.jsonExpression Come gestire le espressioni matematiche nei token dimension.
58
+ * @param {{name: string, prefixes: string[]}[]} opts.customPropsGroups Gruppi nominati di prefissi di nome, spostati in cima all'output CSS nell'ordine dell'elenco.
59
+ * @param {boolean} opts.pxToRem Se false, salta la transform px→rem sulla platform CSS (default: true).
60
+ * @param {string|null} opts.addLayer Racchiude le custom properties generate in `@layer <addLayer> { ... }`. null = nessun layer.
61
+ * @param {string} opts.selector Selettore CSS che racchiude il blocco generato (default: ':root').
62
+ * @returns {Record<string, PlatformConfig>} oggetto platforms pronto per la config di Style Dictionary
57
63
  */
58
64
  export const buildPlatforms = ({
59
65
  buildPath,
@@ -1,13 +1,15 @@
1
- // build-tokens-src/resolve-source-paths.mjs
2
- // Pure helper: resolves Style Dictionary `source` glob patterns relative to a
3
- // base directory, without touching glob syntax.
4
- // Shared by config.mjs (build-tokens.mjs) and check-unresolved-custom-props.mjs.
5
- //
6
- // Glob patterns (containing *, ?, {, [) are NOT passed through path.join,
7
- // because path.join can normalise/collapse sequences that carry syntactic
8
- // meaning in a glob (e.g. "**"). They are only prefixed with baseDir and
9
- // converted to forward slashes.
10
- // Concrete paths (no glob characters) are resolved canonically with path.resolve.
1
+ /*
2
+ build-tokens-src/resolve-source-paths.mjs
3
+ Helper puro: risolve i pattern glob `source` di Style Dictionary rispetto a una
4
+ directory base, senza toccare la sintassi glob.
5
+ Condiviso da config.mjs (build-tokens.mjs) e da check-unresolved-custom-props.mjs.
6
+
7
+ I pattern glob (che contengono *, ?, {, [) NON vengono passati a path.join,
8
+ perché path.join può normalizzare/comprimere sequenze che in un glob hanno un
9
+ significato sintattico (ad es. "**"). Vengono solo preceduti da baseDir e
10
+ convertiti con forward slash.
11
+ I percorsi concreti (senza caratteri glob) vengono risolti in modo canonico con path.resolve.
12
+ */
11
13
 
12
14
  import * as path from 'node:path';
13
15
 
@@ -20,14 +22,14 @@ const GLOB_CHARS = /[*?{[]/;
20
22
  */
21
23
  export const resolveSourcePaths = (source, baseDir) => source.map((s) => {
22
24
  if (path.isAbsolute(s)) {
23
- // Already absolute: only normalise separators (needed on Windows)
25
+ // Già assoluto: normalizza solo i separatori (necessario su Windows)
24
26
  return s.split(path.sep).join('/');
25
27
  }
26
28
  if (GLOB_CHARS.test(s)) {
27
- // Glob pattern: prefix with baseDir without touching the pattern
29
+ // Pattern glob: antepone baseDir senza toccare il pattern
28
30
  const prefix = baseDir.split(path.sep).join('/');
29
31
  return `${prefix}/${s}`;
30
32
  }
31
- // Concrete relative path: canonical resolution
33
+ // Percorso relativo concreto: risoluzione canonica
32
34
  return path.resolve(baseDir, s).split(path.sep).join('/');
33
35
  });
@@ -1,29 +1,31 @@
1
- // build-tokens-src/source-prefixes.mjs
2
- // Supports per-source custom property prefixes: an entry of `source` (or of a
3
- // `sourceModes` mode) can be an object `{ src, prefix }` instead of a plain
4
- // string, e.g.
5
- //
6
- // { src: 'node_modules/open-props/open-props.style-dictionary-tokens.json', prefix: 'op' }
7
- //
8
- // so that every token defined by those files is rendered as `--op-<name>`.
9
- //
10
- // How it works: the prefix is applied to the token NAME only (see the
11
- // name/kebab-prefixed transform in transforms.mjs), never to its path.
12
- // {references} are resolved through the token path and rendered with the
13
- // already-prefixed name, so a token of another source referencing e.g.
14
- // {gray.5} becomes `var(--op-gray-5)` with no change to the token files. The
15
- // JSON output keeps the original (unprefixed) tree structure.
16
- //
17
- // The name transform only knows the concrete file a token comes from
18
- // (token.filePath), while `src` may contain glob patterns: registerSourcePrefixes()
19
- // expands them (through Style Dictionary itself, so the result matches
20
- // token.filePath exactly) into a file path -> prefix map.
21
- //
22
- // The same entry object can also carry a `transform` map (renaming/moving
23
- // token nodes within the file's tree, e.g. { primary: 'primary.100' }) — see
24
- // source-transforms.mjs / token-rename-parser.mjs. splitSourceEntries() below
25
- // extracts both `prefix` and `transform` from the same `{ src, ... }` shape,
26
- // since they share the same source-matching syntax.
1
+ /*
2
+ build-tokens-src/source-prefixes.mjs
3
+ Supporta i prefissi delle custom properties per sorgente: una voce di `source` (o di una
4
+ modalità di `sourceModes`) può essere un oggetto `{ src, prefix }` invece di una semplice
5
+ stringa, ad es.
6
+
7
+ { src: 'node_modules/open-props/open-props.style-dictionary-tokens.json', prefix: 'op' }
8
+
9
+ in modo che ogni token definito da quei file venga reso come `--op-<nome>`.
10
+
11
+ Come funziona: il prefisso viene applicato solo al NOME del token (vedi la
12
+ transform name/kebab-prefixed in transforms.mjs), mai al suo percorso.
13
+ I {riferimenti} vengono risolti tramite il percorso del token e resi con il nome
14
+ già prefissato, quindi un token di un'altra sorgente che referenzia ad es.
15
+ {gray.5} diventa `var(--op-gray-5)` senza modificare i file dei token. L'output
16
+ JSON mantiene la struttura ad albero originale (senza prefisso).
17
+
18
+ La transform del nome conosce solo il file concreto da cui proviene un token
19
+ (token.filePath), mentre `src` può contenere pattern glob: registerSourcePrefixes()
20
+ li espande (tramite lo stesso Style Dictionary, così che il risultato corrisponda
21
+ esattamente a token.filePath) in una mappa percorso file -> prefisso.
22
+
23
+ La stessa voce può anche avere una mappa `transform` (che rinomina/sposta i
24
+ nodi dei token nell'albero del file, ad es. { primary: 'primary.100' }) — vedi
25
+ source-transforms.mjs / token-rename-parser.mjs. splitSourceEntries() più sotto
26
+ estrae sia `prefix` sia `transform` dalla stessa forma `{ src, ... }`,
27
+ dato che condividono la stessa sintassi di individuazione dei sorgenti.
28
+ */
27
29
 
28
30
  import StyleDictionary from 'style-dictionary';
29
31
  import { LEGACY_TOKENS_PARSER_NAME } from './legacy-tokens-parser.mjs';
@@ -33,18 +35,18 @@ import { normalizeTransformMap } from './source-transforms.mjs';
33
35
 
34
36
  /**
35
37
  * @typedef {object} PrefixedSource
36
- * @property {string[]} src Source paths/globs, already resolved (see resolveSourcePaths)
37
- * @property {string} prefix Normalised prefix, without leading `--` or trailing `-`
38
+ * @property {string[]} src Percorsi/glob sorgente, già risolti (vedi resolveSourcePaths)
39
+ * @property {string} prefix Prefisso normalizzato, senza `--` iniziale né `-` finale
38
40
  */
39
41
 
40
42
  /** @type {Map<string, string>} */
41
43
  let prefixByFile = new Map();
42
44
 
43
45
  /**
44
- * Normalises a user-provided prefix: 'op', 'op-' and '--op-' all become 'op'.
46
+ * Normalizza un prefisso fornito dall'utente: 'op', 'op-' e '--op-' diventano tutti 'op'.
45
47
  * @param {unknown} prefix
46
48
  * @returns {string}
47
- * @throws {Error} if the result is not a valid custom property name segment
49
+ * @throws {Error} se il risultato non è un segmento valido di nome di custom property
48
50
  */
49
51
  export const normalizePrefix = (prefix) => {
50
52
  const value = String(prefix).trim().replace(/^-+/, '').replace(/-+$/, '');
@@ -56,16 +58,16 @@ export const normalizePrefix = (prefix) => {
56
58
 
57
59
  /**
58
60
  * @typedef {object} TransformedSource
59
- * @property {string[]} src Source paths/globs, already resolved
60
- * @property {Record<string,string>} transform Validated rename map (see source-transforms.mjs)
61
+ * @property {string[]} src Percorsi/glob sorgente, già risolti
62
+ * @property {Record<string,string>} transform Mappa di rinomina validata (vedi source-transforms.mjs)
61
63
  */
62
64
 
63
65
  /**
64
- * Splits a `source` (or `sourceModes[mode]`) array, whose entries can be
65
- * strings or `{ src, prefix, transform }` objects, into the flat list of
66
- * patterns to pass to Style Dictionary, the list of the prefixed entries and
67
- * the list of the transformed (renamed) entries. Patterns are resolved
68
- * relative to baseDir (see resolveSourcePaths).
66
+ * Suddivide un array `source` (o `sourceModes[mode]`), le cui voci possono essere
67
+ * stringhe od oggetti `{ src, prefix, transform }`, nell'elenco piatto di
68
+ * pattern da passare a Style Dictionary, nell'elenco delle voci con prefisso e
69
+ * nell'elenco delle voci trasformate (rinominate). I pattern vengono risolti
70
+ * rispetto a baseDir (vedi resolveSourcePaths).
69
71
  * @param {(string|{src: string|string[], prefix?: string, transform?: Record<string,string>})[]} entries
70
72
  * @param {string} baseDir
71
73
  * @returns {{patterns: string[], prefixed: PrefixedSource[], transformed: TransformedSource[]}}
@@ -109,12 +111,12 @@ export const splitSourceEntries = (entries, baseDir) => {
109
111
  };
110
112
 
111
113
  /**
112
- * Expands the `src` patterns of every prefixed entry into concrete file paths
113
- * and stores the file path -> prefix map used by getSourcePrefix().
114
- * Must be called after registerLegacyTokensParser() and before any build.
114
+ * Espande i pattern `src` di ogni voce con prefisso in percorsi di file concreti
115
+ * e memorizza la mappa percorso file -> prefisso usata da getSourcePrefix().
116
+ * Va chiamata dopo registerLegacyTokensParser() e prima di qualsiasi build.
115
117
  * @param {PrefixedSource[]} prefixedSources
116
118
  * @returns {Promise<void>}
117
- * @throws {Error} if the same file is given two different prefixes
119
+ * @throws {Error} se allo stesso file vengono assegnati due prefissi diversi
118
120
  */
119
121
  export const registerSourcePrefixes = async (prefixedSources) => {
120
122
  /** @type {Map<string, string>} */
@@ -144,6 +146,6 @@ export const registerSourcePrefixes = async (prefixedSources) => {
144
146
 
145
147
  /**
146
148
  * @param {string|undefined} filePath token.filePath
147
- * @returns {string|undefined} the prefix registered for that file, if any
149
+ * @returns {string|undefined} il prefisso registrato per quel file, se presente
148
150
  */
149
151
  export const getSourcePrefix = (filePath) => (filePath ? prefixByFile.get(filePath) : undefined);
@@ -1,55 +1,57 @@
1
- // build-tokens-src/source-transforms.mjs
2
- // Supports per-source token renaming: an entry of `source` (or of a
3
- // `sourceModes` mode) can carry a `transform` object next to (or instead of)
4
- // `prefix` — see splitSourceEntries() in source-prefixes.mjs — e.g.
5
- //
6
- // { src: './project-tokens/*.jsonc', transform: { primary: 'primary.100' } }
7
- //
8
- // so that the token found at dot-path `primary` in those files is moved to
9
- // dot-path `primary.100` before Style Dictionary ever sees it, i.e. before
10
- // {references} are resolved and before the CSS/JSON output is built.
11
- //
12
- // Typical use case: a preexisting project defines its tokens (e.g. exported
13
- // from Figma/Penpot) under names that don't match minimo's own naming (e.g.
14
- // the project's base color is `primary`, minimo's equivalent is
15
- // `primary.100`). Without this feature every custom property generated from
16
- // the project's tokens would have to be renamed by hand after each build, or
17
- // every minimo reference to `{primary.100}` would have to be tracked down and
18
- // changed instead. `transform` fixes the token's OWN path once, in config.
19
- //
20
- // Notation: both sides of the map use Style Dictionary's own dot-path
21
- // notation (e.g. 'primary.100'), NOT the hyphen-joined custom-property
22
- // notation (e.g. 'primary-100'). Token name segments in this project can
23
- // themselves contain hyphens (e.g. btn-close, status-buttons), so a hyphen
24
- // can't reliably tell a path separator from a literal part of a segment name;
25
- // a dot can, since Style Dictionary already reserves it as the path
26
- // separator in {references} and never allows it inside a single segment
27
- // name.
28
- //
29
- // Moving a node would otherwise leave every {reference} to its OLD path
30
- // dangling (in the same file or a completely different one) — so this module
31
- // also collects a flat, file-independent from -> to map (getAllRenames()),
32
- // used by the token-rename PREPROCESSOR (see token-rename-parser.mjs) to
33
- // rewrite every such {reference} tree-wide, once all files are merged. This
34
- // is safe to do because Style Dictionary resolves {references} against the
35
- // single merged token tree by absolute path: if `primary` existed exactly
36
- // once before the rename, every {primary} anywhere in the build
37
- // unambiguously pointed at that one node, so every one of them must now
38
- // become {primary.100} — there is no risk of rewriting an unrelated
39
- // reference. The one case this can't disambiguate is the same "from" key
40
- // renamed to a DIFFERENT destination in a different file (each valid on its
41
- // own, per-file); see registerSourceTransforms() below — that key is
42
- // excluded from the tree-wide rewrite (with a console warning), and its
43
- // {references} are left for the user to fix by hand.
44
- //
45
- // How it works: unlike `prefix` (a purely cosmetic CSS name transform, see
46
- // source-prefixes.mjs, which never touches the token tree), `transform`
47
- // restructures the actual parsed token tree of the source file, via a
48
- // dedicated Style Dictionary parser (see token-rename-parser.mjs) that runs
49
- // at parse time, before files are merged and before reference resolution.
50
- // Since both the CSS and JSON output formats rebuild their tree from
51
- // token.path (by then already renamed), no separate handling is needed to
52
- // make the JSON output reflect the renamed structure too.
1
+ /*
2
+ build-tokens-src/source-transforms.mjs
3
+ Supporta la rinomina dei token per sorgente: una voce di `source` (o di una
4
+ modalità di `sourceModes`) può avere un oggetto `transform` accanto a (o al posto di)
5
+ `prefix` — vedi splitSourceEntries() in source-prefixes.mjs — ad es.
6
+
7
+ { src: './project-tokens/*.jsonc', transform: { primary: 'primary.100' } }
8
+
9
+ in modo che il token trovato al dot-path `primary` in quei file venga spostato al
10
+ dot-path `primary.100` prima ancora che Style Dictionary lo veda, cioè prima che
11
+ i {riferimenti} vengano risolti e prima che venga costruito l'output CSS/JSON.
12
+
13
+ Caso d'uso tipico: un progetto preesistente definisce i propri token (ad es. esportati
14
+ da Figma/Penpot) con nomi che non corrispondono alla nomenclatura di minimo (ad es.
15
+ il colore base del progetto è `primary`, l'equivalente di minimo è
16
+ `primary.100`). Senza questa funzionalità ogni custom property generata dai token
17
+ del progetto andrebbe rinominata a mano dopo ogni build, oppure ogni riferimento di minimo
18
+ a `{primary.100}` andrebbe cercato e modificato. `transform` corregge una volta
19
+ sola il percorso PROPRIO del token, nella config.
20
+
21
+ Notazione: entrambi i lati della mappa usano la notazione dot-path di Style Dictionary
22
+ (ad es. 'primary.100'), NON la notazione delle custom properties con trattini
23
+ (ad es. 'primary-100'). I segmenti dei nomi dei token in questo progetto possono
24
+ contenere trattini (ad es. btn-close, status-buttons), quindi un trattino
25
+ non permette di distinguere in modo affidabile un separatore di percorso da una parte letterale
26
+ del nome di un segmento; un punto sì, dato che Style Dictionary lo riserva già come
27
+ separatore di percorso nei {riferimenti} e non lo ammette mai dentro il nome
28
+ di un singolo segmento.
29
+
30
+ Spostare un nodo lascerebbe altrimenti ogni {riferimento} al suo VECCHIO percorso
31
+ pendente (nello stesso file o in uno completamente diverso) — quindi questo modulo
32
+ raccoglie anche una mappa piatta from -> to, indipendente dal file (getAllRenames()),
33
+ usata dal PREPROCESSOR di rinomina dei token (vedi token-rename-parser.mjs) per
34
+ riscrivere ogni {riferimento} di questo tipo in tutto l'albero, una volta uniti tutti i file. Si
35
+ può fare in sicurezza perché Style Dictionary risolve i {riferimenti} sull'unico
36
+ albero di token unito, tramite percorso assoluto: se `primary` esisteva una sola
37
+ volta prima della rinomina, ogni {primary} in qualsiasi punto della build
38
+ puntava senza ambiguità a quell'unico nodo, quindi ognuno deve ora
39
+ diventare {primary.100} — non c'è rischio di riscrivere un riferimento non correlato. L'unico
40
+ caso che non si può disambiguare è la stessa chiave "from" rinominata con una
41
+ destinazione DIVERSA in un file diverso (ciascuna valida per conto proprio, per
42
+ file); vedi registerSourceTransforms() più sotto — quella chiave viene
43
+ esclusa dalla riscrittura su tutto l'albero (con un warning in console) e i suoi
44
+ {riferimenti} restano da correggere a mano.
45
+
46
+ Come funziona: a differenza di `prefix` (una trasformazione puramente estetica del nome CSS, vedi
47
+ source-prefixes.mjs, che non tocca mai l'albero dei token), `transform`
48
+ ristruttura il vero albero dei token letto dal file sorgente, tramite un
49
+ parser dedicato di Style Dictionary (vedi token-rename-parser.mjs) che viene eseguito
50
+ in fase di parsing, prima dell'unione dei file e della risoluzione dei riferimenti.
51
+ Poiché sia l'output CSS sia quello JSON ricostruiscono il proprio albero da
52
+ token.path (ormai già rinominato), non serve una gestione separata perché
53
+ anche l'output JSON rifletta la struttura rinominata.
54
+ */
53
55
 
54
56
  import StyleDictionary from 'style-dictionary';
55
57
  import { collectConcreteFilePaths } from './formats/json.mjs';
@@ -58,29 +60,31 @@ import { LEGACY_TOKENS_PARSER_NAME } from './legacy-tokens-parser.mjs';
58
60
  /** @type {Map<string, Record<string,string>>} */
59
61
  let transformByFile = new Map();
60
62
 
61
- // Flat, file-independent from -> to map, used by the token-rename
62
- // preprocessor (see token-rename-parser.mjs) to rewrite any {reference}
63
- // pointing to a renamed token's OLD path, anywhere in the build (same file or
64
- // another one) — references are resolved by Style Dictionary against the
65
- // single merged token tree, by absolute path, so a bare dot-path is
66
- // unambiguous UNLESS the same "from" key was given a different destination
67
- // in a different file (each valid on its own — see registerSourceTransforms
68
- // below), in which case that key is excluded here (with a warning) and its
69
- // {references} are left for the user to fix by hand, same as before this
70
- // preprocessor existed.
63
+ /*
64
+ Mappa piatta from -> to, indipendente dal file, usata dal preprocessor di
65
+ rinomina dei token (vedi token-rename-parser.mjs) per riscrivere ogni {riferimento}
66
+ che punta al VECCHIO percorso di un token rinominato, in qualsiasi punto della build (stesso file o
67
+ un altro) — i riferimenti vengono risolti da Style Dictionary sull'unico albero di
68
+ token unito, tramite percorso assoluto, quindi un semplice dot-path non è
69
+ ambiguo A MENO CHE la stessa chiave "from" non abbia ricevuto una destinazione diversa
70
+ in un file diverso (ciascuna valida per conto proprio — vedi registerSourceTransforms
71
+ più sotto), nel qual caso quella chiave viene esclusa qui (con un warning) e i suoi
72
+ {riferimenti} restano da correggere a mano, come prima dell'esistenza di questo
73
+ preprocessor.
74
+ */
71
75
  /** @type {Map<string, string>} */
72
76
  let globalRenames = new Map();
73
77
 
74
78
  const DOT_PATH = /^[^.\s][\w-]*(\.[^.\s][\w-]*)*$/;
75
79
 
76
80
  /**
77
- * Validates a `transform` map: every key/value must be a non-empty
78
- * Style-Dictionary dot-path string (e.g. 'primary.100'), not a
79
- * hyphen-joined custom-property name (e.g. 'primary-100') — see the notation
81
+ * Valida una mappa `transform`: ogni chiave/valore deve essere una stringa dot-path
82
+ * di Style Dictionary non vuota (ad es. 'primary.100'), non un nome di custom property
83
+ * con trattini (ad es. 'primary-100') — vedi la motivazione della notazione qui sopra.
80
84
  * rationale above.
81
85
  * @param {unknown} map
82
86
  * @returns {Record<string,string>}
83
- * @throws {Error} if the map is not a plain object, or a key/value is invalid
87
+ * @throws {Error} se la mappa non è un oggetto semplice o una chiave/valore non è valido
84
88
  */
85
89
  export const normalizeTransformMap = (map) => {
86
90
  if (map === null || typeof map !== 'object' || Array.isArray(map)) {
@@ -102,22 +106,24 @@ export const normalizeTransformMap = (map) => {
102
106
  };
103
107
 
104
108
  /**
105
- * Expands the `transform` entries' `src` patterns into concrete file paths
106
- * and stores the file path -> rename map used by getSourceTransform(). Must
107
- * be called after registerLegacyTokensParser() and before any real build.
108
- * Maps from different entries touching the same file are merged; the build
109
- * fails only if two entries disagree on the destination of the same source
110
- * key.
109
+ * Espande i pattern `src` delle voci `transform` in percorsi di file concreti
110
+ * e memorizza la mappa percorso file -> mappa di rinomina usata da getSourceTransform().
111
+ * Va chiamata dopo registerLegacyTokensParser() e prima di qualsiasi build reale.
112
+ * Le mappe di voci diverse che toccano lo stesso file vengono unite; la build
113
+ * fallisce solo se due voci non concordano sulla destinazione della stessa chiave
114
+ * sorgente.
111
115
  * @param {import('./source-prefixes.mjs').TransformedSource[]} transformedSources
112
116
  * @returns {Promise<void>}
113
- * @throws {Error} if the same file gets two conflicting destinations for the same key
117
+ * @throws {Error} se lo stesso file riceve due destinazioni in conflitto per la stessa chiave
114
118
  */
115
119
  export const registerSourceTransforms = async (transformedSources) => {
116
120
  /** @type {Map<string, Record<string,string>>} */
117
121
  const map = new Map();
118
- // Every destination seen for a given "from" key, across all files — used
119
- // below to build globalRenames, and to detect the cross-file ambiguous
120
- // case (same "from" key, different destination in a different file).
122
+ /*
123
+ Ogni destinazione vista per una data chiave "from", in tutti i file — usata
124
+ più sotto per costruire globalRenames e per rilevare il caso ambiguo tra file
125
+ (stessa chiave "from", destinazione diversa in un file diverso).
126
+ */
121
127
  /** @type {Map<string, Set<string>>} */
122
128
  const destinationsByFrom = new Map();
123
129
 
@@ -166,24 +172,24 @@ export const registerSourceTransforms = async (transformedSources) => {
166
172
  };
167
173
 
168
174
  /**
169
- * @returns {Map<string, string>} the flat from -> to map used to rewrite
170
- * {references} across the whole build (see token-rename-parser.mjs)
175
+ * @returns {Map<string, string>} la mappa piatta from -> to usata per riscrivere
176
+ * i {riferimenti} in tutta la build (vedi token-rename-parser.mjs)
171
177
  */
172
178
  export const getAllRenames = () => globalRenames;
173
179
 
174
180
  /**
175
181
  * @param {string|undefined} filePath token.filePath
176
- * @returns {Record<string,string>|undefined} the rename map registered for that file, if any
182
+ * @returns {Record<string,string>|undefined} la mappa di rinomina registrata per quel file, se presente
177
183
  */
178
184
  export const getSourceTransform = (filePath) => (filePath ? transformByFile.get(filePath) : undefined);
179
185
 
180
- /** @returns {boolean} true if at least one file has a registered transform */
186
+ /** @returns {boolean} true se almeno un file ha una transform registrata */
181
187
  export const hasRegisteredTransforms = () => transformByFile.size > 0;
182
188
 
183
189
  /**
184
- * Builds the RegExp matching exactly the concrete files that have a
185
- * registered transform, for the Style Dictionary parser `pattern` (see
186
- * token-rename-parser.mjs). Returns null if no file has one.
190
+ * Costruisce la RegExp che corrisponde esattamente ai file concreti che hanno una
191
+ * transform registrata, per il `pattern` del parser di Style Dictionary (vedi
192
+ * token-rename-parser.mjs). Restituisce null se nessun file ne ha una.
187
193
  * @returns {RegExp|null}
188
194
  */
189
195
  export const transformedFilesPattern = () => {