@vettvangur/design-system 2.0.67 → 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 +200 -140
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3555,112 +3555,139 @@ async function generateTypography$1(fontSizes, lineHeights, config) {
|
|
|
3555
3555
|
message(`finished generating typography`);
|
|
3556
3556
|
}
|
|
3557
3557
|
|
|
3558
|
-
/**
|
|
3559
|
-
* design-system :: src/generators/tailwind/scales.mjs.
|
|
3560
|
-
*
|
|
3561
|
-
* Design token tooling: pulls from Figma and generates platform outputs (Razor/Astro/Tailwind).
|
|
3562
|
-
*
|
|
3563
|
-
* These docs are generated from inline JSDoc in the repo and are intended for contributors.
|
|
3564
|
-
*
|
|
3565
|
-
* @generated
|
|
3566
|
-
* @module design-system
|
|
3558
|
+
/**
|
|
3559
|
+
* design-system :: src/generators/tailwind/scales.mjs.
|
|
3560
|
+
*
|
|
3561
|
+
* Design token tooling: pulls from Figma and generates platform outputs (Razor/Astro/Tailwind).
|
|
3562
|
+
*
|
|
3563
|
+
* These docs are generated from inline JSDoc in the repo and are intended for contributors.
|
|
3564
|
+
*
|
|
3565
|
+
* @generated
|
|
3566
|
+
* @module design-system
|
|
3567
3567
|
*/
|
|
3568
3568
|
|
|
3569
|
-
/**
|
|
3570
|
-
* Kebab.
|
|
3571
|
-
*
|
|
3572
|
-
* @param s - Value.
|
|
3573
|
-
* @returns Result of the operation.
|
|
3574
|
-
*
|
|
3575
|
-
* @generated
|
|
3576
|
-
* @example
|
|
3577
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3578
|
-
* // import { kebab } from '@vettvangur/design-system'
|
|
3579
|
-
*
|
|
3580
|
-
* kebab(s)
|
|
3569
|
+
/**
|
|
3570
|
+
* Kebab.
|
|
3571
|
+
*
|
|
3572
|
+
* @param s - Value.
|
|
3573
|
+
* @returns Result of the operation.
|
|
3574
|
+
*
|
|
3575
|
+
* @generated
|
|
3576
|
+
* @example
|
|
3577
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3578
|
+
* // import { kebab } from '@vettvangur/design-system'
|
|
3579
|
+
*
|
|
3580
|
+
* kebab(s)
|
|
3581
3581
|
*/
|
|
3582
3582
|
function kebab$1(s) {
|
|
3583
3583
|
return String(s).trim().toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '');
|
|
3584
3584
|
}
|
|
3585
3585
|
|
|
3586
|
-
/**
|
|
3587
|
-
* Mode key.
|
|
3588
|
-
*
|
|
3589
|
-
* @param raw - Value.
|
|
3590
|
-
* @returns Result of the operation.
|
|
3591
|
-
*
|
|
3592
|
-
* @generated
|
|
3593
|
-
* @example
|
|
3594
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3595
|
-
* // import { modeKey } from '@vettvangur/design-system'
|
|
3596
|
-
*
|
|
3597
|
-
* modeKey(raw)
|
|
3586
|
+
/**
|
|
3587
|
+
* Mode key.
|
|
3588
|
+
*
|
|
3589
|
+
* @param raw - Value.
|
|
3590
|
+
* @returns Result of the operation.
|
|
3591
|
+
*
|
|
3592
|
+
* @generated
|
|
3593
|
+
* @example
|
|
3594
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3595
|
+
* // import { modeKey } from '@vettvangur/design-system'
|
|
3596
|
+
*
|
|
3597
|
+
* modeKey(raw)
|
|
3598
3598
|
*/
|
|
3599
3599
|
function modeKey(raw) {
|
|
3600
3600
|
return kebab$1(raw);
|
|
3601
3601
|
}
|
|
3602
3602
|
|
|
3603
|
-
/**
|
|
3604
|
-
* Pick number.
|
|
3605
|
-
*
|
|
3606
|
-
* @param values - Value.
|
|
3607
|
-
* @param preferredMode - Value.
|
|
3608
|
-
* @returns Result of the operation.
|
|
3609
|
-
*
|
|
3610
|
-
* @generated
|
|
3611
|
-
* @example
|
|
3612
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3613
|
-
* // import { pickNumber } from '@vettvangur/design-system'
|
|
3614
|
-
*
|
|
3615
|
-
* pickNumber(values, preferredMode)
|
|
3603
|
+
/**
|
|
3604
|
+
* Pick number.
|
|
3605
|
+
*
|
|
3606
|
+
* @param values - Value.
|
|
3607
|
+
* @param preferredMode - Value.
|
|
3608
|
+
* @returns Result of the operation.
|
|
3609
|
+
*
|
|
3610
|
+
* @generated
|
|
3611
|
+
* @example
|
|
3612
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3613
|
+
* // import { pickNumber } from '@vettvangur/design-system'
|
|
3614
|
+
*
|
|
3615
|
+
* pickNumber(values, preferredMode)
|
|
3616
3616
|
*/
|
|
3617
3617
|
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
|
-
/**
|
|
3634
|
-
* Render theme.
|
|
3635
|
-
*
|
|
3636
|
-
* @param lines - Value.
|
|
3637
|
-
* @returns String result.
|
|
3638
|
-
*
|
|
3639
|
-
* @generated
|
|
3640
|
-
* @example
|
|
3641
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3642
|
-
* // import { renderTheme } from '@vettvangur/design-system'
|
|
3643
|
-
*
|
|
3644
|
-
* renderTheme(lines)
|
|
3660
|
+
/**
|
|
3661
|
+
* Render theme.
|
|
3662
|
+
*
|
|
3663
|
+
* @param lines - Value.
|
|
3664
|
+
* @returns String result.
|
|
3665
|
+
*
|
|
3666
|
+
* @generated
|
|
3667
|
+
* @example
|
|
3668
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3669
|
+
* // import { renderTheme } from '@vettvangur/design-system'
|
|
3670
|
+
*
|
|
3671
|
+
* renderTheme(lines)
|
|
3645
3672
|
*/
|
|
3646
3673
|
function renderTheme$1(lines) {
|
|
3647
3674
|
return `@theme {\n${lines.join('\n')}\n}\n`;
|
|
3648
3675
|
}
|
|
3649
3676
|
|
|
3650
|
-
/**
|
|
3651
|
-
* Ensure var.
|
|
3652
|
-
*
|
|
3653
|
-
* @param lines - Value.
|
|
3654
|
-
* @param varName - Value.
|
|
3655
|
-
* @param value - Value.
|
|
3656
|
-
* @returns Nothing.
|
|
3657
|
-
*
|
|
3658
|
-
* @generated
|
|
3659
|
-
* @example
|
|
3660
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3661
|
-
* // import { ensureVar } from '@vettvangur/design-system'
|
|
3662
|
-
*
|
|
3663
|
-
* ensureVar(lines, varName, value)
|
|
3677
|
+
/**
|
|
3678
|
+
* Ensure var.
|
|
3679
|
+
*
|
|
3680
|
+
* @param lines - Value.
|
|
3681
|
+
* @param varName - Value.
|
|
3682
|
+
* @param value - Value.
|
|
3683
|
+
* @returns Nothing.
|
|
3684
|
+
*
|
|
3685
|
+
* @generated
|
|
3686
|
+
* @example
|
|
3687
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3688
|
+
* // import { ensureVar } from '@vettvangur/design-system'
|
|
3689
|
+
*
|
|
3690
|
+
* ensureVar(lines, varName, value)
|
|
3664
3691
|
*/
|
|
3665
3692
|
function ensureVar(lines, varName, value) {
|
|
3666
3693
|
const exists = lines.some(l => l.startsWith(` ${varName}:`));
|
|
@@ -3670,20 +3697,20 @@ function ensureVar(lines, varName, value) {
|
|
|
3670
3697
|
}
|
|
3671
3698
|
|
|
3672
3699
|
// Hoisted: unit policy lives here
|
|
3673
|
-
/**
|
|
3674
|
-
* Add rem.
|
|
3675
|
-
*
|
|
3676
|
-
* @param map - Value.
|
|
3677
|
-
* @param name - Name or identifier.
|
|
3678
|
-
* @param n - Value.
|
|
3679
|
-
* @returns Nothing.
|
|
3680
|
-
*
|
|
3681
|
-
* @generated
|
|
3682
|
-
* @example
|
|
3683
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3684
|
-
* // import { addRem } from '@vettvangur/design-system'
|
|
3685
|
-
*
|
|
3686
|
-
* addRem(map, name, n)
|
|
3700
|
+
/**
|
|
3701
|
+
* Add rem.
|
|
3702
|
+
*
|
|
3703
|
+
* @param map - Value.
|
|
3704
|
+
* @param name - Name or identifier.
|
|
3705
|
+
* @param n - Value.
|
|
3706
|
+
* @returns Nothing.
|
|
3707
|
+
*
|
|
3708
|
+
* @generated
|
|
3709
|
+
* @example
|
|
3710
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3711
|
+
* // import { addRem } from '@vettvangur/design-system'
|
|
3712
|
+
*
|
|
3713
|
+
* addRem(map, name, n)
|
|
3687
3714
|
*/
|
|
3688
3715
|
function addRem(map, name, n) {
|
|
3689
3716
|
if (n == null) {
|
|
@@ -3695,18 +3722,18 @@ function addRem(map, name, n) {
|
|
|
3695
3722
|
map.set(name, n === 0 ? '0' : rem(n));
|
|
3696
3723
|
}
|
|
3697
3724
|
|
|
3698
|
-
/**
|
|
3699
|
-
* Generate spacing css.
|
|
3700
|
-
*
|
|
3701
|
-
* @param scales - Value.
|
|
3702
|
-
* @returns String result.
|
|
3703
|
-
*
|
|
3704
|
-
* @generated
|
|
3705
|
-
* @example
|
|
3706
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3707
|
-
* // import { generateSpacingCss } from '@vettvangur/design-system'
|
|
3708
|
-
*
|
|
3709
|
-
* generateSpacingCss(scales)
|
|
3725
|
+
/**
|
|
3726
|
+
* Generate spacing css.
|
|
3727
|
+
*
|
|
3728
|
+
* @param scales - Value.
|
|
3729
|
+
* @returns String result.
|
|
3730
|
+
*
|
|
3731
|
+
* @generated
|
|
3732
|
+
* @example
|
|
3733
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3734
|
+
* // import { generateSpacingCss } from '@vettvangur/design-system'
|
|
3735
|
+
*
|
|
3736
|
+
* generateSpacingCss(scales)
|
|
3710
3737
|
*/
|
|
3711
3738
|
function generateSpacingCss(scales) {
|
|
3712
3739
|
const map = new Map();
|
|
@@ -3746,18 +3773,18 @@ function generateSpacingCss(scales) {
|
|
|
3746
3773
|
return `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n${renderTheme$1(lines)}`;
|
|
3747
3774
|
}
|
|
3748
3775
|
|
|
3749
|
-
/**
|
|
3750
|
-
* Generate border css.
|
|
3751
|
-
*
|
|
3752
|
-
* @param scales - Value.
|
|
3753
|
-
* @returns String result.
|
|
3754
|
-
*
|
|
3755
|
-
* @generated
|
|
3756
|
-
* @example
|
|
3757
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3758
|
-
* // import { generateBorderCss } from '@vettvangur/design-system'
|
|
3759
|
-
*
|
|
3760
|
-
* generateBorderCss(scales)
|
|
3776
|
+
/**
|
|
3777
|
+
* Generate border css.
|
|
3778
|
+
*
|
|
3779
|
+
* @param scales - Value.
|
|
3780
|
+
* @returns String result.
|
|
3781
|
+
*
|
|
3782
|
+
* @generated
|
|
3783
|
+
* @example
|
|
3784
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3785
|
+
* // import { generateBorderCss } from '@vettvangur/design-system'
|
|
3786
|
+
*
|
|
3787
|
+
* generateBorderCss(scales)
|
|
3761
3788
|
*/
|
|
3762
3789
|
function generateBorderCss(scales) {
|
|
3763
3790
|
const map = new Map();
|
|
@@ -3775,34 +3802,63 @@ function generateBorderCss(scales) {
|
|
|
3775
3802
|
return `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n${renderTheme$1(lines)}`;
|
|
3776
3803
|
}
|
|
3777
3804
|
|
|
3778
|
-
/**
|
|
3779
|
-
* Generate radius css.
|
|
3780
|
-
*
|
|
3781
|
-
* @param scales - Value.
|
|
3782
|
-
* @returns String result.
|
|
3783
|
-
*
|
|
3784
|
-
* @generated
|
|
3785
|
-
* @example
|
|
3786
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3787
|
-
* // import { generateRadiusCss } from '@vettvangur/design-system'
|
|
3788
|
-
*
|
|
3789
|
-
* generateRadiusCss(scales)
|
|
3805
|
+
/**
|
|
3806
|
+
* Generate radius css.
|
|
3807
|
+
*
|
|
3808
|
+
* @param scales - Value.
|
|
3809
|
+
* @returns String result.
|
|
3810
|
+
*
|
|
3811
|
+
* @generated
|
|
3812
|
+
* @example
|
|
3813
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3814
|
+
* // import { generateRadiusCss } from '@vettvangur/design-system'
|
|
3815
|
+
*
|
|
3816
|
+
* generateRadiusCss(scales)
|
|
3790
3817
|
*/
|
|
3791
3818
|
function generateRadiusCss(scales) {
|
|
3819
|
+
const debug = !!process$1.env.DS_DEBUG;
|
|
3820
|
+
const input = scales?.radius || {};
|
|
3821
|
+
const inputKeys = Object.keys(input);
|
|
3822
|
+
if (debug) {
|
|
3823
|
+
console.log('[design-system] radius: token count =', inputKeys.length);
|
|
3824
|
+
if (inputKeys.length) {
|
|
3825
|
+
console.log('[design-system] radius: token key sample =', inputKeys.slice(0, 25).join(', '));
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3792
3828
|
const map = new Map();
|
|
3793
|
-
|
|
3829
|
+
let skippedManual = 0;
|
|
3830
|
+
let skippedNull = 0;
|
|
3831
|
+
const skippedNullSample = [];
|
|
3832
|
+
for (const [tokenKey, token] of Object.entries(input)) {
|
|
3794
3833
|
const k = kebab$1(tokenKey);
|
|
3795
3834
|
|
|
3796
3835
|
// skip these entirely (manual vars below)
|
|
3797
3836
|
if (k === 'round' || k === 'circle') {
|
|
3837
|
+
skippedManual++;
|
|
3798
3838
|
continue;
|
|
3799
3839
|
}
|
|
3800
3840
|
const v = pickNumber(token?.values, 'Mode 1');
|
|
3801
3841
|
if (v == null) {
|
|
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
|
+
}
|
|
3802
3852
|
continue;
|
|
3803
3853
|
}
|
|
3804
3854
|
addRem(map, `--radius-${k}`, v);
|
|
3805
3855
|
}
|
|
3856
|
+
if (debug) {
|
|
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
|
+
}
|
|
3861
|
+
}
|
|
3806
3862
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3807
3863
|
|
|
3808
3864
|
// manual required defaults
|
|
@@ -3812,18 +3868,18 @@ function generateRadiusCss(scales) {
|
|
|
3812
3868
|
return `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n${renderTheme$1(lines)}`;
|
|
3813
3869
|
}
|
|
3814
3870
|
|
|
3815
|
-
/**
|
|
3816
|
-
* Generate scales.
|
|
3817
|
-
*
|
|
3818
|
-
* @param variableSet - Value.
|
|
3819
|
-
* @param config - Configuration object.
|
|
3820
|
-
* @returns Nothing.
|
|
3821
|
-
*
|
|
3822
|
-
* @example
|
|
3823
|
-
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3824
|
-
* // import { generateScales } from '@vettvangur/design-system'
|
|
3825
|
-
*
|
|
3826
|
-
* await generateScales(variableSet, {})
|
|
3871
|
+
/**
|
|
3872
|
+
* Generate scales.
|
|
3873
|
+
*
|
|
3874
|
+
* @param variableSet - Value.
|
|
3875
|
+
* @param config - Configuration object.
|
|
3876
|
+
* @returns Nothing.
|
|
3877
|
+
*
|
|
3878
|
+
* @example
|
|
3879
|
+
* // design-system (src/tools/javascript/design-system/src/generators/tailwind/scales.mjs)
|
|
3880
|
+
* // import { generateScales } from '@vettvangur/design-system'
|
|
3881
|
+
*
|
|
3882
|
+
* await generateScales(variableSet, {})
|
|
3827
3883
|
*/
|
|
3828
3884
|
async function generateScales(variableSet, config) {
|
|
3829
3885
|
message('generating spacing/border/radius theme variables');
|
|
@@ -3834,6 +3890,10 @@ async function generateScales(variableSet, config) {
|
|
|
3834
3890
|
const spacingCss = generateSpacingCss(variableSet);
|
|
3835
3891
|
const borderCss = generateBorderCss(variableSet);
|
|
3836
3892
|
const radiusCss = generateRadiusCss(variableSet);
|
|
3893
|
+
if (process$1.env.DS_DEBUG) {
|
|
3894
|
+
const outPath = path.join(outDir, 'radius.css');
|
|
3895
|
+
console.log('[design-system] radius: writing', outPath);
|
|
3896
|
+
}
|
|
3837
3897
|
await fs$1.writeFile(path.join(outDir, 'spacing.css'), spacingCss, 'utf8');
|
|
3838
3898
|
await fs$1.writeFile(path.join(outDir, 'border.css'), borderCss, 'utf8');
|
|
3839
3899
|
await fs$1.writeFile(path.join(outDir, 'radius.css'), radiusCss, 'utf8');
|