@vettvangur/design-system 2.0.68 → 2.0.69
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/dist/index.js +45 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3618,16 +3618,43 @@ function pickNumber(values, preferredMode) {
|
|
|
3618
3618
|
if (!values || typeof values !== 'object') {
|
|
3619
3619
|
return null;
|
|
3620
3620
|
}
|
|
3621
|
-
const
|
|
3622
|
-
|
|
3621
|
+
const parseNumberLike = v => {
|
|
3622
|
+
if (typeof v === 'number') {
|
|
3623
|
+
return Number.isFinite(v) ? v : null;
|
|
3624
|
+
}
|
|
3625
|
+
if (typeof v !== 'string') {
|
|
3626
|
+
return null;
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
// Accept numeric strings and common px strings from Figma variables.
|
|
3630
|
+
// Examples: "2", "2px", "0px".
|
|
3631
|
+
const s = v.trim();
|
|
3632
|
+
if (!s) {
|
|
3633
|
+
return null;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
// Radius/spacing/border tokens are expected to be integer pixel values.
|
|
3637
|
+
// If decimals are present, keep behavior explicit by rejecting them.
|
|
3638
|
+
const m = /^-?\d+(?:px)?$/i.exec(s);
|
|
3639
|
+
if (!m) {
|
|
3640
|
+
return null;
|
|
3641
|
+
}
|
|
3642
|
+
const n = Number.parseInt(s.replace(/px$/i, ''), 10);
|
|
3643
|
+
return Number.isFinite(n) ? n : null;
|
|
3644
|
+
};
|
|
3645
|
+
const direct = parseNumberLike(values[preferredMode]);
|
|
3646
|
+
if (direct != null) {
|
|
3623
3647
|
return direct;
|
|
3624
3648
|
}
|
|
3625
3649
|
const normalizedPreferred = modeKey(preferredMode) ;
|
|
3626
|
-
if (normalizedPreferred
|
|
3627
|
-
|
|
3650
|
+
if (normalizedPreferred) {
|
|
3651
|
+
const n = parseNumberLike(values[normalizedPreferred]);
|
|
3652
|
+
if (n != null) {
|
|
3653
|
+
return n;
|
|
3654
|
+
}
|
|
3628
3655
|
}
|
|
3629
3656
|
const first = Object.values(values)[0];
|
|
3630
|
-
return
|
|
3657
|
+
return parseNumberLike(first);
|
|
3631
3658
|
}
|
|
3632
3659
|
|
|
3633
3660
|
/**
|
|
@@ -3801,6 +3828,7 @@ function generateRadiusCss(scales) {
|
|
|
3801
3828
|
const map = new Map();
|
|
3802
3829
|
let skippedManual = 0;
|
|
3803
3830
|
let skippedNull = 0;
|
|
3831
|
+
const skippedNullSample = [];
|
|
3804
3832
|
for (const [tokenKey, token] of Object.entries(input)) {
|
|
3805
3833
|
const k = kebab$1(tokenKey);
|
|
3806
3834
|
|
|
@@ -3812,12 +3840,24 @@ function generateRadiusCss(scales) {
|
|
|
3812
3840
|
const v = pickNumber(token?.values, 'Mode 1');
|
|
3813
3841
|
if (v == null) {
|
|
3814
3842
|
skippedNull++;
|
|
3843
|
+
if (debug && skippedNullSample.length < 8) {
|
|
3844
|
+
const values = token?.values && typeof token.values === 'object' ? token.values : null;
|
|
3845
|
+
skippedNullSample.push({
|
|
3846
|
+
key: tokenKey,
|
|
3847
|
+
type: token?.type ?? null,
|
|
3848
|
+
modes: values ? Object.keys(values).slice(0, 10) : [],
|
|
3849
|
+
valuesSample: values ? Object.fromEntries(Object.entries(values).slice(0, 3)) : null
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3815
3852
|
continue;
|
|
3816
3853
|
}
|
|
3817
3854
|
addRem(map, `--radius-${k}`, v);
|
|
3818
3855
|
}
|
|
3819
3856
|
if (debug) {
|
|
3820
3857
|
console.log('[design-system] radius: emitted =', map.size, '| skipped(manual)=', skippedManual, '| skipped(null)=', skippedNull);
|
|
3858
|
+
if (skippedNullSample.length) {
|
|
3859
|
+
console.log('[design-system] radius: skipped(null) sample =', JSON.stringify(skippedNullSample, null, 2));
|
|
3860
|
+
}
|
|
3821
3861
|
}
|
|
3822
3862
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3823
3863
|
|