@massimo-cassandro/minimo 1.41.3 → 1.41.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.css +10 -0
- 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/starter-install.sh +2 -2
- 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/index.js +1 -0
- package/package.json +3 -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 -9
- package/src/utilities/better-text-with-places.js +105 -105
- 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/readme.md +76 -110
- 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,37 +1,39 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
//
|
|
85
|
-
//
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
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
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
//
|
|
167
|
-
//
|
|
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
|
|
172
|
-
// Dictionary
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
// ──
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
*
|
|
203
|
-
* composite/shadow/gradient
|
|
204
|
-
* "from"
|
|
205
|
-
*
|
|
206
|
-
* "primary"
|
|
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
|
-
*
|
|
224
|
-
* Dictionary —
|
|
225
|
-
*
|
|
226
|
-
* `$value`
|
|
227
|
-
*
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
//
|
|
11
|
-
// non
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
//
|
|
91
|
-
//
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
//
|
|
114
|
-
//
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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',
|