@massimo-cassandro/minimo 1.41.4 → 1.41.6
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.
- package/README.md +12 -12
- package/charts/src/node-helpers/create-svg-canvas-node.mjs +2 -2
- package/charts/src/node-helpers/svg-text-to-path.js +9 -9
- package/charts/src/rating-display/index.js +1 -1
- package/charts/src/rating-display/ratindDisplayAnimation.js +3 -3
- package/design-tokens/README.md +2 -2
- package/design-tokens/_src/_readme.md +26 -26
- package/dev-tools/README.md +16 -16
- package/dev-tools/create-favicons/README.md +31 -31
- package/dev-tools/create-favicons/src/create-ico.mjs +2 -2
- package/dev-tools/create-favicons/src/default-params.mjs +1 -1
- package/dev-tools/create-favicons/src/init.mjs +1 -1
- package/dev-tools/design-tokens-builder/README.md +102 -102
- package/dev-tools/design-tokens-builder/build-tokens-src/build-source-modes.mjs +85 -73
- package/dev-tools/design-tokens-builder/build-tokens-src/config.mjs +109 -85
- package/dev-tools/design-tokens-builder/build-tokens-src/formats/css.mjs +113 -90
- package/dev-tools/design-tokens-builder/build-tokens-src/formats/json.mjs +107 -95
- package/dev-tools/design-tokens-builder/build-tokens-src/legacy-tokens-parser.mjs +71 -64
- package/dev-tools/design-tokens-builder/build-tokens-src/light-dark.mjs +75 -65
- package/dev-tools/design-tokens-builder/build-tokens-src/merge-css.mjs +113 -102
- package/dev-tools/design-tokens-builder/build-tokens-src/platforms.mjs +36 -30
- package/dev-tools/design-tokens-builder/build-tokens-src/resolve-source-paths.mjs +15 -13
- package/dev-tools/design-tokens-builder/build-tokens-src/source-prefixes.mjs +44 -42
- package/dev-tools/design-tokens-builder/build-tokens-src/source-transforms.mjs +89 -83
- package/dev-tools/design-tokens-builder/build-tokens-src/token-rename-parser.mjs +99 -86
- package/dev-tools/design-tokens-builder/build-tokens-src/transforms.mjs +64 -48
- package/dev-tools/design-tokens-builder/build-tokens.mjs +80 -68
- package/dev-tools/design-tokens-builder/check-unresolved-custom-props.mjs +103 -77
- package/dev-tools/design-tokens-builder/tokens-config-sample.mjs +275 -238
- package/dev-tools/find-orphan-css-classes/find-orphan-css-classes.mjs +2 -2
- package/dev-tools/starter-kit/source_files/app/CLAUDE.md +4 -2
- package/dev-tools/starter-kit/source_files/app/{css/index.css → index.css} +2 -2
- package/dev-tools/starter-kit/source_files/app/index.js +1 -1
- package/dev-tools/starter-kit/source_files/root/_sf/controller/ImgViewerController.php +3 -3
- package/dev-tools/starter-kit/source_files/root/_sf/controller/ViewerController.php +2 -2
- package/dev-tools/starter-kit/source_files/root/stylelint.config.mjs +1 -1
- package/dev-tools/starter-kit/source_files/root/webpack-config-modules/css-rules.mjs +1 -1
- package/dev-tools/starter-kit/source_files/root/webpack.config.mjs +15 -1
- package/dev-tools/starter-kit/webpack-config-upg.md +12 -0
- package/dev-tools/stylelint-config/README.md +7 -7
- package/dev-tools/svg-icons-tools/README.md +32 -32
- package/dev-tools/svg-icons-tools/src/config-manager.mjs +1 -1
- package/dev-tools/svg-icons-tools/src/default-config.mjs +118 -118
- package/dev-tools/svg-icons-tools/src/jsx-icon-file-builder.mjs +24 -24
- package/dev-tools/svg-icons-tools/src/parse-svg-filename.mjs +3 -3
- package/dev-tools/svg-icons-tools/src/parse-svg-files.mjs +1 -1
- package/dev-tools/svg-icons-tools/src/parse-svg-markup.mjs +4 -4
- package/dev-tools/svg-icons-tools/src/svg-to-jsx.mjs +2 -2
- package/dev-tools/svg-icons-tools/src/svg-to-optimized.mjs +2 -2
- package/dev-tools/svg-icons-tools/src/svg-to-symbols.mjs +2 -2
- package/dev-tools/upd@m/README.md +1 -1
- package/dev-tools/upd@m/index.mjs +1 -1
- package/dev-tools/update-version/README.md +9 -9
- package/package.json +1 -1
- package/snippets/unsplash-browser-app/README.md +1 -1
- package/snippets/unsplash-browser-app/unsplash-utilities.js +9 -9
- package/src/components/autocomplete/README.md +3 -3
- package/src/components/autocomplete/autocomplete-engine.js +75 -63
- package/src/components/autocomplete/check-autocomplete.js +3 -3
- package/src/components/dismiss-alerts.js +3 -3
- package/src/components/form-reset-submit.js +6 -6
- package/src/components/inner-nav/inner-nav.js +2 -2
- package/src/components/modal-alert/modal-alert.js +67 -65
- package/src/components/modal-alert/modal-alert.minimo.tokens.mjs +1 -1
- package/src/components/modal-popup/modal-popup.js +56 -56
- package/src/components/overlay/overlay.js +3 -3
- package/src/components/sf-macro/readme.md +1 -1
- package/src/components/sf-macro/sf-macro.js +27 -23
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +83 -79
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +44 -44
- package/src/components/snackbar/snackbar.js +19 -19
- package/src/components/spinner/spinner.js +3 -3
- package/src/components/unsplash-page/README.md +8 -8
- package/src/components/unsplash-page/fetch-unsplash-data.js +3 -3
- package/src/components/unsplash-page/unsplash-page.js +33 -33
- package/src/components/unsplash-page/unsplash-page.module.css +1 -1
- package/src/css/alerts.css +2 -2
- package/src/css/forms/forms.css +4 -4
- package/src/css/forms/validation.css +1 -1
- package/src/css/margin-padding-media.css +4 -4
- package/src/css/margin-padding.css +4 -4
- package/src/css/reset.css +11 -11
- package/src/icons/read-me.md +1 -1
- package/src/minimo.css +3 -3
- package/src/utilities/better-text-with-places.js +22 -22
- package/src/utilities/better-text.js +42 -35
- package/src/utilities/classnames.js +8 -8
- package/src/utilities/cookies.js +6 -6
- package/src/utilities/create-id.js +3 -3
- package/src/utilities/disable-btns-on-submit.js +2 -2
- package/src/utilities/dom-builder/dom-builder.js +89 -86
- package/src/utilities/dom-builder/domBuilderBasicSetup.js +9 -9
- package/src/utilities/dom-builder/parseDomString.js +23 -23
- package/src/utilities/dom-builder-helpers/README.md +2 -2
- package/src/utilities/dom-builder-helpers/form-tags.js +100 -100
- package/src/utilities/dom-builder-helpers/picture-tag.js +39 -39
- package/src/utilities/enable-submit-btns.js +1 -1
- package/src/utilities/escape-html.js +2 -2
- package/src/utilities/generate-pwd.js +4 -4
- package/src/utilities/linked-dates.js +13 -13
- package/src/utilities/parse-file-size.js +6 -6
- package/src/utilities/random-id.js +3 -3
- package/src/utilities/relative-date.js +40 -40
- package/src/utilities/sentence-case.js +1 -1
- package/src/utilities/strip-tags.js +1 -1
- package/src/utilities/title-case.js +1 -1
- package/src/utilities/truncate-string.js +5 -5
- package/src/utilities/validation-error-class.js +12 -12
- package/src/web-components/json-table/json-table-component.js +123 -121
- package/src/web-components/json-table/json-table-component.module.css +6 -6
- package/src/web-components/json-table/json-table.minimo.tokens.mjs +6 -6
- package/src/web-components/json-table/jt-docs/parametri.md +124 -0
- package/src/web-components/json-table/jt-docs.md +622 -0
- package/src/web-components/json-table/readme.md +3 -763
- package/src/web-components/json-table/src/cell-content.js +25 -25
- package/src/web-components/json-table/src/content-utils.js +21 -21
- package/src/web-components/json-table/src/data-types.js +32 -32
- package/src/web-components/json-table/src/defaults.js +230 -191
- package/src/web-components/json-table/src/get-data.js +55 -38
- package/src/web-components/json-table/src/icons.js +17 -17
- package/src/web-components/json-table/src/info-section.js +18 -18
- package/src/web-components/json-table/src/main-builder.js +45 -45
- package/src/web-components/json-table/src/pagination.js +32 -32
- package/src/web-components/json-table/src/parse-cols.js +18 -18
- package/src/web-components/json-table/src/parse-rows.js +17 -17
- package/src/web-components/json-table/src/resolve-params.js +53 -41
- package/src/web-components/json-table/src/search.js +13 -13
- package/src/web-components/json-table/src/sorting.js +20 -20
- package/src/web-components/json-table/src/table-body.js +13 -13
- package/src/web-components/json-table/src/table-builder.js +34 -34
- package/src/web-components/json-table/src/table-tfoot.js +8 -8
- package/src/web-components/json-table/src/table-thead.js +21 -21
- package/src/web-components/json-table/src/update-info.js +11 -11
- package/types/classes.d.ts +2 -2
- package/types/global.d.ts +18 -12
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
44
|
-
* @param {string} opts.destFile CSS output
|
|
45
|
-
* @param {string|null} opts.jsonBuildPath
|
|
46
|
-
* @param {string|null} opts.jsonDestFile
|
|
47
|
-
* @param {'json'|'jsonc'} opts.jsonFormat
|
|
48
|
-
* @param {string[]} opts.concreteFilePaths
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @param {'keep'|'calc'|'resolve'} opts.jsonExpression
|
|
52
|
-
* @param {{name: string, prefixes: string[]}[]} opts.customPropsGroups
|
|
53
|
-
* @param {boolean} opts.pxToRem
|
|
54
|
-
* @param {string|null} opts.addLayer
|
|
55
|
-
* @param {string} opts.selector CSS
|
|
56
|
-
* @returns {Record<string, PlatformConfig>} platforms
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
33
|
+
// Percorso relativo concreto: risoluzione canonica
|
|
32
34
|
return path.resolve(baseDir, s).split(path.sep).join('/');
|
|
33
35
|
});
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
37
|
-
* @property {string} prefix
|
|
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
|
-
*
|
|
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}
|
|
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
|
|
60
|
-
* @property {Record<string,string>} transform
|
|
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
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
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}
|
|
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}
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
*
|
|
78
|
-
* Style
|
|
79
|
-
*
|
|
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}
|
|
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
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
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}
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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>}
|
|
170
|
-
* {
|
|
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}
|
|
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
|
|
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
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* token-rename-parser.mjs).
|
|
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 = () => {
|