@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,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/*
|
|
2
|
+
build-tokens-src/formats/css.mjs
|
|
3
|
+
Registra il format 'css/variables-sorted'.
|
|
4
|
+
Genera un blocco :root { ... } con le custom properties ordinate alfabeticamente.
|
|
5
|
+
I token tipografici vengono scomposti in più proprietà CSS:
|
|
6
|
+
- una shorthand `font` (quando sono presenti sia fontSize sia fontFamily)
|
|
7
|
+
- proprietà singole per letterSpacing, textTransform, textDecoration
|
|
8
|
+
*/
|
|
7
9
|
|
|
8
10
|
import StyleDictionary from 'style-dictionary';
|
|
9
11
|
import { mergeCustomProps, parseCustomProps } from '../merge-css.mjs';
|
|
10
12
|
|
|
11
13
|
const BASE_FONT_SIZE = 16;
|
|
12
14
|
|
|
13
|
-
//
|
|
15
|
+
// Converte un valore px in rem. Restituisce la stringa originale per i valori non px.
|
|
14
16
|
const toRem = (val) => {
|
|
15
17
|
if (val === undefined || val === null) return '0';
|
|
16
18
|
const str = String(val).trim();
|
|
@@ -20,14 +22,14 @@ const toRem = (val) => {
|
|
|
20
22
|
return str;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
//
|
|
25
|
+
// Sostituisce i riferimenti {a.b.c} con var(--token-name) usando la mappa tokenByPath.
|
|
24
26
|
const makeResolveRefs = (tokenByPath) => (str) =>
|
|
25
27
|
String(str).replace(/\{([^}]+)\}/g, (_, p) => {
|
|
26
28
|
const ref = tokenByPath[p];
|
|
27
29
|
return ref ? `var(--${ref.name})` : `{${p}}`;
|
|
28
30
|
});
|
|
29
31
|
|
|
30
|
-
// ──
|
|
32
|
+
// ── Builder dei tipi complessi ───────────────────────────────────────────────
|
|
31
33
|
|
|
32
34
|
const buildShadow = (original, resolveRefs) => {
|
|
33
35
|
const shadows = Array.isArray(original) ? original : [original];
|
|
@@ -85,9 +87,11 @@ const buildAnimation = (original, resolveRefs) => [
|
|
|
85
87
|
resolveRefs(String(original.name ?? 'none')),
|
|
86
88
|
].join(' ');
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
/*
|
|
91
|
+
Costruisce le custom properties CSS per un token tipografico.
|
|
92
|
+
Produce una shorthand `font` quando sono presenti sia fontSize sia fontFamily,
|
|
93
|
+
più proprietà separate per letterSpacing, textTransform e textDecoration.
|
|
94
|
+
*/
|
|
91
95
|
const buildTypography = (tokenName, original, resolveRefs) => {
|
|
92
96
|
const {
|
|
93
97
|
fontStyle, fontVariant, fontWeight, fontStretch,
|
|
@@ -117,7 +121,7 @@ const buildTypography = (tokenName, original, resolveRefs) => {
|
|
|
117
121
|
letterSpacing: ['letter-spacing', letterSpacing],
|
|
118
122
|
textTransform: ['text-transform', textTransform],
|
|
119
123
|
textDecoration: ['text-decoration', textDecoration],
|
|
120
|
-
// Fallback:
|
|
124
|
+
// Fallback: espone size/family singolarmente se non è stato possibile costruire la shorthand
|
|
121
125
|
...(!fontSize ? { fontSize: ['font-size', original.fontSize] } : {}),
|
|
122
126
|
...(!fontFamily ? { fontFamily: ['font-family', original.fontFamily] } : {}),
|
|
123
127
|
};
|
|
@@ -131,48 +135,52 @@ const buildTypography = (tokenName, original, resolveRefs) => {
|
|
|
131
135
|
return lines.join('\n');
|
|
132
136
|
};
|
|
133
137
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
/*
|
|
139
|
+
Costruisce un commento CSS finale (stile slash-asterisco) dal $description di un token, da
|
|
140
|
+
accodare alla fine della sua dichiarazione di custom prop generata (sulla stessa riga).
|
|
141
|
+
I a capo vengono compattati (le dichiarazioni sono lette una riga alla volta, vedi
|
|
142
|
+
parseCustomProps in ../merge-css.mjs) e la sequenza di chiusura del commento viene sottoposta a escape perché il commento
|
|
143
|
+
non possa essere chiuso prematuramente dal proprio contenuto.
|
|
144
|
+
*/
|
|
139
145
|
const buildDescriptionComment = (description) => {
|
|
140
146
|
if (!description) return '';
|
|
141
147
|
const flat = String(description).replace(/\s*\n\s*/g, ' ').trim().replace(/\*\//g, '* /');
|
|
142
148
|
return flat ? ` /* ${flat} */` : '';
|
|
143
149
|
};
|
|
144
150
|
|
|
145
|
-
//
|
|
151
|
+
// Costruisce il commento di titolo di un customPropsGroups, ad es.:
|
|
146
152
|
// /* ****** LAYOUT ****** */
|
|
147
|
-
//
|
|
153
|
+
// Gli asterischi riempiono una larghezza totale fissa così che i titoli siano allineati a prescindere dalla lunghezza del nome.
|
|
148
154
|
const DECORATOR_LENGHT = 6;
|
|
149
155
|
const buildGroupTitle = (name) => {
|
|
150
156
|
return ` /** ${'*'.repeat(DECORATOR_LENGHT)} ${name} ${'*'.repeat(DECORATOR_LENGHT)} **/`;
|
|
151
157
|
};
|
|
152
158
|
|
|
153
|
-
// ──
|
|
159
|
+
// ── Registrazione del format ─────────────────────────────────────────────────
|
|
154
160
|
|
|
155
|
-
//
|
|
161
|
+
// Contatore esportato — letto da build-tokens.mjs per la riga finale del log
|
|
156
162
|
export let customPropsCount = 0;
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
/*
|
|
165
|
+
Live binding esportato che contiene la mappa nome → coda della dichiarazione calcolata per ultima
|
|
166
|
+
da computeFinalProps() (vedi sotto), cioè il risultato strutturato della
|
|
167
|
+
chiamata più recente al format 'css/variables-sorted'. Letto da
|
|
168
|
+
build-tokens-src/build-source-modes.mjs subito dopo ogni chiamata per modalità a
|
|
169
|
+
sd.formatPlatform('css') (sincrono, stesso schema di
|
|
170
|
+
customPropsCount) — serve a build-tokens-src/light-dark.mjs per riconciliare
|
|
171
|
+
le proprietà light/dark condivise in chiamate light-dark(), lavorando sulle
|
|
172
|
+
props strutturate invece che sul testo CSS già reso.
|
|
173
|
+
*/
|
|
166
174
|
export let lastFinalProps = {};
|
|
167
175
|
|
|
168
176
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* (
|
|
173
|
-
* @param {object} dictionary
|
|
174
|
-
* @param {object} options
|
|
175
|
-
* @returns {Record<string,string>}
|
|
177
|
+
* Calcola la mappa finale `nome -> coda della dichiarazione` per un dizionario di token:
|
|
178
|
+
* risolve il valore CSS di ogni token (inclusi i builder dei tipi complessi qui sopra),
|
|
179
|
+
* poi vi unisce le eventuali custom properties preesistenti tramite mergeCustomProps()
|
|
180
|
+
* (vedi ../merge-css.mjs e l'opzione di config `mergeCustomProps`).
|
|
181
|
+
* @param {object} dictionary dizionario dei token risolto di Style Dictionary (argomento `dictionary` di format())
|
|
182
|
+
* @param {object} options argomento `options` di format() — qui vengono lette solo `outputReferences` e `mode`
|
|
183
|
+
* @returns {Record<string,string>} nome → coda della dichiarazione (valore + `;` finale + eventuale commento finale)
|
|
176
184
|
*/
|
|
177
185
|
export const computeFinalProps = (dictionary, options) => {
|
|
178
186
|
const tokenByPath = {};
|
|
@@ -204,13 +212,14 @@ export const computeFinalProps = (dictionary, options) => {
|
|
|
204
212
|
return a.name.localeCompare(b.name, 'en', { numeric: true, sensitivity: 'base' });
|
|
205
213
|
};
|
|
206
214
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
/*
|
|
216
|
+
I token caricati tramite `include` (sourceModes: token della modalità base resi
|
|
217
|
+
disponibili alle altre modalità) restano in tokenByPath, quindi i riferimenti a essi
|
|
218
|
+
si risolvono in var(--name), ma non vengono dichiarati nel blocco di questa modalità.
|
|
219
|
+
nome della proprietà → file sorgente del token, usato da mergeCustomProps quando il
|
|
220
|
+
merge è limitato ad alcuni file sorgente (un token può generare più
|
|
221
|
+
proprietà, ad es. la tipografia)
|
|
222
|
+
*/
|
|
214
223
|
const sourceFileMap = {};
|
|
215
224
|
const trackSource = (token, tokenLines) => {
|
|
216
225
|
for (const name of Object.keys(parseCustomProps(tokenLines.join('\n')))) {
|
|
@@ -260,13 +269,17 @@ export const computeFinalProps = (dictionary, options) => {
|
|
|
260
269
|
? resolveRefs(orig) : buildAnimation(orig, resolveRefs);
|
|
261
270
|
|
|
262
271
|
} else if (options.outputReferences && typeof orig === 'string' && orig.includes('{')) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
/*
|
|
273
|
+
Copre sia i semplici alias sia le funzioni CSS che contengono {riferimenti}
|
|
274
|
+
ad es. color-mix(in srgb, {btn.secondary.background.color} 60%, #000)
|
|
275
|
+
I {riferimenti} vengono sostituiti con var(--name); le operazioni aritmetiche ottengono calc().
|
|
276
|
+
*/
|
|
266
277
|
const resolved = resolveRefs(orig);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
278
|
+
/*
|
|
279
|
+
Rimuove var(...) e le chiamate a funzioni CSS (caratteri di parola + trattini seguiti da '(')
|
|
280
|
+
prima di cercare gli operatori aritmetici, così che i trattini in nomi come
|
|
281
|
+
"color-mix" o "linear-gradient" non attivino un calc() spurio.
|
|
282
|
+
*/
|
|
270
283
|
const stripped = resolved
|
|
271
284
|
.replace(/var\([^)]+\)/g, '0')
|
|
272
285
|
.replace(/[\w-]+\(/g, '(');
|
|
@@ -277,10 +290,12 @@ export const computeFinalProps = (dictionary, options) => {
|
|
|
277
290
|
value = String(token.$value ?? token.value);
|
|
278
291
|
}
|
|
279
292
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
293
|
+
/*
|
|
294
|
+
I valori su più righe (ad es. gli easing linear() di Open Props) vengono compattati
|
|
295
|
+
su una sola riga: le dichiarazioni sono lette una riga alla volta (vedi
|
|
296
|
+
parseCustomProps in ../merge-css.mjs), quindi un valore su più righe
|
|
297
|
+
verrebbe troncato alla prima riga.
|
|
298
|
+
*/
|
|
284
299
|
value = String(value)
|
|
285
300
|
.replace(/\s*\n\s*/g, ' ')
|
|
286
301
|
.replace(/\(\s+/g, '(')
|
|
@@ -289,42 +304,44 @@ export const computeFinalProps = (dictionary, options) => {
|
|
|
289
304
|
return trackSource(token, [` --${token.name}: ${value};${commentSuffix}`]);
|
|
290
305
|
});
|
|
291
306
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
307
|
+
/*
|
|
308
|
+
Costruisce una mappa nome → coda della dichiarazione dalle dichiarazioni generate
|
|
309
|
+
qui sopra, poi la unisce alle eventuali custom properties preesistenti caricate tramite
|
|
310
|
+
loadExistingCustomProps() / loadExistingCustomPropsScoped() (vedi
|
|
311
|
+
../merge-css.mjs). I valori preesistenti (inclusi i commenti finali)
|
|
312
|
+
hanno priorità quando esistono entrambi; le proprietà presenti solo nel preesistente vengono mantenute.
|
|
313
|
+
options.mode (solo build sourceModes, vedi ../build-source-modes.mjs)
|
|
314
|
+
limita il merge a quella modalità, così che proprietà con lo stesso nome ma valori
|
|
315
|
+
diversi tra le modalità non vengano mai confuse.
|
|
316
|
+
*/
|
|
300
317
|
const generatedProps = parseCustomProps(lines.join('\n'));
|
|
301
318
|
return mergeCustomProps(generatedProps, options.mode ?? null, sourceFileMap);
|
|
302
319
|
};
|
|
303
320
|
|
|
304
321
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
322
|
+
* Costruisce il testo finale del blocco CSS (`<selector> { ... }`) a partire da una mappa
|
|
323
|
+
* nome → coda della dichiarazione già calcolata (vedi computeFinalProps() qui sopra):
|
|
324
|
+
* ordina le proprietà alfabeticamente, estrae i customPropsGroups, antepone una
|
|
325
|
+
* dichiarazione `color-scheme` opzionale e, se richiesto, racchiude il risultato in
|
|
309
326
|
* `@layer <addLayer> { ... }`.
|
|
310
327
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* props
|
|
314
|
-
*
|
|
315
|
-
*
|
|
328
|
+
* Estratta come funzione a sé (invece che inline nella chiamata a format()
|
|
329
|
+
* più sotto) così che build-tokens-src/light-dark.mjs possa rieseguirla su una mappa
|
|
330
|
+
* di props modificata — ad es. dopo aver spostato le proprietà condivise da `light` e `dark` in
|
|
331
|
+
* un'unica dichiarazione `light-dark()` — e ottenere un blocco correttamente ordinato e
|
|
332
|
+
* raggruppato, invece di accodare testo grezzo a posteriori.
|
|
316
333
|
* @param {object} opts
|
|
317
|
-
* @param {Record<string,string>} opts.finalProps
|
|
318
|
-
* @param {string} [opts.selector] CSS
|
|
319
|
-
* @param {string} [opts.colorScheme]
|
|
320
|
-
* @param {{name:string,prefixes:string[]}[]} [opts.customPropsGroups]
|
|
321
|
-
* @param {string|null} [opts.addLayer]
|
|
334
|
+
* @param {Record<string,string>} opts.finalProps nome → coda della dichiarazione, come restituito da computeFinalProps()
|
|
335
|
+
* @param {string} [opts.selector] selettore CSS che racchiude il blocco (default: ':root')
|
|
336
|
+
* @param {string} [opts.colorScheme] valore opzionale per una dichiarazione `color-scheme: <valore>;` anteposta al blocco
|
|
337
|
+
* @param {{name:string,prefixes:string[]}[]} [opts.customPropsGroups] gruppi nominati di prefissi di nome, spostati in cima al blocco nell'ordine dell'elenco (default: [])
|
|
338
|
+
* @param {string|null} [opts.addLayer] racchiude il blocco in `@layer <addLayer> { ... }` (default: null — nessun layer)
|
|
322
339
|
* @returns {string}
|
|
323
340
|
* @example
|
|
324
341
|
* buildCssBlock({
|
|
325
342
|
* finalProps: { 'accent-color': '#123;' },
|
|
326
343
|
* selector: ':root', // default: ':root'
|
|
327
|
-
* colorScheme: 'light dark', // default: undefined —
|
|
344
|
+
* colorScheme: 'light dark', // default: undefined — nessuna riga color-scheme
|
|
328
345
|
* customPropsGroups: [], // default: []
|
|
329
346
|
* addLayer: null, // default: null
|
|
330
347
|
* });
|
|
@@ -336,17 +353,21 @@ export const buildCssBlock = ({
|
|
|
336
353
|
customPropsGroups = [],
|
|
337
354
|
addLayer = null,
|
|
338
355
|
}) => {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
356
|
+
/*
|
|
357
|
+
L'output finale è sempre ordinato alfabeticamente in modo crescente per nome della
|
|
358
|
+
proprietà, a prescindere dal merge — questo mantiene in ordine anche le proprietà
|
|
359
|
+
presenti solo nel preesistente (da merge-css.mjs) invece di accodarle alla fine.
|
|
360
|
+
*/
|
|
342
361
|
const sortedProps = Object.entries(finalProps)
|
|
343
362
|
.sort(([a], [b]) => a.localeCompare(b, 'en', { numeric: true, sensitivity: 'base' }));
|
|
344
363
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
364
|
+
/*
|
|
365
|
+
customPropsGroups: le proprietà il cui primo segmento del nome (separato da trattini)
|
|
366
|
+
corrisponde a uno dei prefissi di un gruppo vengono estratte, etichettate con il
|
|
367
|
+
nome di quel gruppo e collocate, nell'ordine dell'elenco dei gruppi, all'inizio del
|
|
368
|
+
file di output. Una proprietà corrisponde al primo gruppo (in ordine di elenco) i cui
|
|
369
|
+
prefissi la includono.
|
|
370
|
+
*/
|
|
350
371
|
const groupedProps = customPropsGroups.map(() => []);
|
|
351
372
|
const restProps = [];
|
|
352
373
|
for (const entry of sortedProps) {
|
|
@@ -368,9 +389,11 @@ export const buildCssBlock = ({
|
|
|
368
389
|
});
|
|
369
390
|
});
|
|
370
391
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
392
|
+
/*
|
|
393
|
+
Viene inserita una riga vuota tra i blocchi di proprietà che condividono lo stesso
|
|
394
|
+
primo segmento separato da trattini (ad es. tutte le `btn-*` insieme), per raggruppare
|
|
395
|
+
visivamente le custom properties correlate nel file generato.
|
|
396
|
+
*/
|
|
374
397
|
const outLines = [];
|
|
375
398
|
|
|
376
399
|
if (colorScheme) {
|
|
@@ -407,8 +430,8 @@ export const buildCssBlock = ({
|
|
|
407
430
|
|
|
408
431
|
const block = `${selector} {\n${outLines.join('\n')}\n}\n`;
|
|
409
432
|
|
|
410
|
-
// addLayer:
|
|
411
|
-
//
|
|
433
|
+
// addLayer: racchiude l'intero blocco in `@layer <name> { ... }`.
|
|
434
|
+
// L'indentazione è lasciata al passaggio di fix di stylelint (eseguito subito dopo la build).
|
|
412
435
|
return addLayer
|
|
413
436
|
? `@layer ${addLayer} {\n\n${block}}\n`
|
|
414
437
|
: block;
|