@alivecss/aliveui 1.0.0 → 1.0.2
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 +7 -7
- package/dist/cli.js +89 -26
- package/dist/index.js +100 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -28
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +101 -28
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +101 -28
- package/dist/vite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -555,6 +555,42 @@ function generateBase(_config) {
|
|
|
555
555
|
box-sizing: border-box;
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
+
html {
|
|
559
|
+
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
|
|
560
|
+
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
|
|
561
|
+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
562
|
+
line-height: 1.5;
|
|
563
|
+
-webkit-text-size-adjust: 100%;
|
|
564
|
+
-moz-tab-size: 4;
|
|
565
|
+
tab-size: 4;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
body {
|
|
569
|
+
margin: 0;
|
|
570
|
+
line-height: inherit;
|
|
571
|
+
-webkit-font-smoothing: antialiased;
|
|
572
|
+
-moz-osx-font-smoothing: grayscale;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
button,
|
|
576
|
+
input,
|
|
577
|
+
optgroup,
|
|
578
|
+
select,
|
|
579
|
+
textarea {
|
|
580
|
+
font-family: inherit;
|
|
581
|
+
font-size: 100%;
|
|
582
|
+
font-weight: inherit;
|
|
583
|
+
line-height: inherit;
|
|
584
|
+
color: inherit;
|
|
585
|
+
margin: 0;
|
|
586
|
+
padding: 0;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
button,
|
|
590
|
+
select {
|
|
591
|
+
text-transform: none;
|
|
592
|
+
}
|
|
593
|
+
|
|
558
594
|
/* \u2500\u2500 Design tokens \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
559
595
|
:root {
|
|
560
596
|
/* Motion durations */
|
|
@@ -2640,9 +2676,23 @@ function matchTypography(cls, fontSize, fontWeight, lineHeight) {
|
|
|
2640
2676
|
}
|
|
2641
2677
|
|
|
2642
2678
|
// src/generator/layout.ts
|
|
2643
|
-
function
|
|
2679
|
+
function has2(obj, key) {
|
|
2680
|
+
return typeof obj[key] === "string";
|
|
2681
|
+
}
|
|
2682
|
+
function generateLayout(classes, config) {
|
|
2683
|
+
const { spacing } = config.theme;
|
|
2644
2684
|
const rules = [];
|
|
2645
2685
|
for (const cls of classes) {
|
|
2686
|
+
const spaceYMatch = cls.match(/^space-y-(.+)$/);
|
|
2687
|
+
if (spaceYMatch && has2(spacing, spaceYMatch[1])) {
|
|
2688
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-top: ${spacing[spaceYMatch[1]]}; }`);
|
|
2689
|
+
continue;
|
|
2690
|
+
}
|
|
2691
|
+
const spaceXMatch = cls.match(/^space-x-(.+)$/);
|
|
2692
|
+
if (spaceXMatch && has2(spacing, spaceXMatch[1])) {
|
|
2693
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-left: ${spacing[spaceXMatch[1]]}; }`);
|
|
2694
|
+
continue;
|
|
2695
|
+
}
|
|
2646
2696
|
const generated = matchLayout(cls);
|
|
2647
2697
|
if (generated) rules.push(generated);
|
|
2648
2698
|
}
|
|
@@ -2685,6 +2735,10 @@ function matchLayout(cls) {
|
|
|
2685
2735
|
if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2686
2736
|
if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2687
2737
|
if (cls === "flex-shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2738
|
+
if (cls === "grow") return `.${cls} { flex-grow: 1; }`;
|
|
2739
|
+
if (cls === "grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2740
|
+
if (cls === "shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2741
|
+
if (cls === "shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2688
2742
|
if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
|
|
2689
2743
|
if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
|
|
2690
2744
|
if (cls === "items-center") return `.${cls} { align-items: center; }`;
|
|
@@ -2861,7 +2915,7 @@ function matchLayout(cls) {
|
|
|
2861
2915
|
}
|
|
2862
2916
|
|
|
2863
2917
|
// src/generator/sizing.ts
|
|
2864
|
-
function
|
|
2918
|
+
function has3(obj, key) {
|
|
2865
2919
|
return typeof obj[key] === "string";
|
|
2866
2920
|
}
|
|
2867
2921
|
function generateSizing(classes, config) {
|
|
@@ -2912,8 +2966,8 @@ function matchSizing(cls, spacing) {
|
|
|
2912
2966
|
if (key === "min") return `.${cls} { width: min-content; }`;
|
|
2913
2967
|
if (key === "max") return `.${cls} { width: max-content; }`;
|
|
2914
2968
|
if (key === "fit") return `.${cls} { width: fit-content; }`;
|
|
2915
|
-
if (
|
|
2916
|
-
if (
|
|
2969
|
+
if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
|
|
2970
|
+
if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
|
|
2917
2971
|
}
|
|
2918
2972
|
const minWMatch = cls.match(/^min-w-(.+)$/);
|
|
2919
2973
|
if (minWMatch) {
|
|
@@ -2923,7 +2977,7 @@ function matchSizing(cls, spacing) {
|
|
|
2923
2977
|
if (key === "min") return `.${cls} { min-width: min-content; }`;
|
|
2924
2978
|
if (key === "max") return `.${cls} { min-width: max-content; }`;
|
|
2925
2979
|
if (key === "fit") return `.${cls} { min-width: fit-content; }`;
|
|
2926
|
-
if (
|
|
2980
|
+
if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
|
|
2927
2981
|
}
|
|
2928
2982
|
const maxWMap = {
|
|
2929
2983
|
none: "none",
|
|
@@ -2950,7 +3004,7 @@ function matchSizing(cls, spacing) {
|
|
|
2950
3004
|
"screen-2xl": "1536px"
|
|
2951
3005
|
};
|
|
2952
3006
|
const maxWMatch = cls.match(/^max-w-(.+)$/);
|
|
2953
|
-
if (maxWMatch &&
|
|
3007
|
+
if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
|
|
2954
3008
|
return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
|
|
2955
3009
|
}
|
|
2956
3010
|
const hMatch = cls.match(/^h-(.+)$/);
|
|
@@ -2964,8 +3018,8 @@ function matchSizing(cls, spacing) {
|
|
|
2964
3018
|
if (key === "min") return `.${cls} { height: min-content; }`;
|
|
2965
3019
|
if (key === "max") return `.${cls} { height: max-content; }`;
|
|
2966
3020
|
if (key === "fit") return `.${cls} { height: fit-content; }`;
|
|
2967
|
-
if (
|
|
2968
|
-
if (
|
|
3021
|
+
if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
|
|
3022
|
+
if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
|
|
2969
3023
|
}
|
|
2970
3024
|
const minHMatch = cls.match(/^min-h-(.+)$/);
|
|
2971
3025
|
if (minHMatch) {
|
|
@@ -2976,7 +3030,7 @@ function matchSizing(cls, spacing) {
|
|
|
2976
3030
|
if (key === "svh") return `.${cls} { min-height: 100svh; }`;
|
|
2977
3031
|
if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
|
|
2978
3032
|
if (key === "fit") return `.${cls} { min-height: fit-content; }`;
|
|
2979
|
-
if (
|
|
3033
|
+
if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
|
|
2980
3034
|
}
|
|
2981
3035
|
const maxHMatch = cls.match(/^max-h-(.+)$/);
|
|
2982
3036
|
if (maxHMatch) {
|
|
@@ -2987,13 +3041,22 @@ function matchSizing(cls, spacing) {
|
|
|
2987
3041
|
if (key === "svh") return `.${cls} { max-height: 100svh; }`;
|
|
2988
3042
|
if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
|
|
2989
3043
|
if (key === "fit") return `.${cls} { max-height: fit-content; }`;
|
|
2990
|
-
if (
|
|
3044
|
+
if (has3(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
|
|
3045
|
+
}
|
|
3046
|
+
const basisMatch = cls.match(/^basis-(.+)$/);
|
|
3047
|
+
if (basisMatch) {
|
|
3048
|
+
const key = basisMatch[1];
|
|
3049
|
+
if (key === "auto") return `.${cls} { flex-basis: auto; }`;
|
|
3050
|
+
if (key === "full") return `.${cls} { flex-basis: 100%; }`;
|
|
3051
|
+
if (key === "0") return `.${cls} { flex-basis: 0px; }`;
|
|
3052
|
+
if (has3(fractions, key)) return `.${cls} { flex-basis: ${fractions[key]}; }`;
|
|
3053
|
+
if (has3(spacing, key)) return `.${cls} { flex-basis: ${spacing[key]}; }`;
|
|
2991
3054
|
}
|
|
2992
3055
|
return null;
|
|
2993
3056
|
}
|
|
2994
3057
|
|
|
2995
3058
|
// src/generator/effects.ts
|
|
2996
|
-
function
|
|
3059
|
+
function has4(obj, key) {
|
|
2997
3060
|
return typeof obj[key] === "string";
|
|
2998
3061
|
}
|
|
2999
3062
|
function generateEffects(classes, config) {
|
|
@@ -3007,7 +3070,7 @@ function generateEffects(classes, config) {
|
|
|
3007
3070
|
}
|
|
3008
3071
|
function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
3009
3072
|
const opacityMatch = cls.match(/^opacity-(.+)$/);
|
|
3010
|
-
if (opacityMatch &&
|
|
3073
|
+
if (opacityMatch && has4(opacity, opacityMatch[1])) {
|
|
3011
3074
|
return `.${cls} {
|
|
3012
3075
|
opacity: ${opacity[opacityMatch[1]]};
|
|
3013
3076
|
transition-property: opacity;
|
|
@@ -3016,47 +3079,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3016
3079
|
}`;
|
|
3017
3080
|
}
|
|
3018
3081
|
const zMatch = cls.match(/^z-(.+)$/);
|
|
3019
|
-
if (zMatch &&
|
|
3082
|
+
if (zMatch && has4(zIndex, zMatch[1])) {
|
|
3020
3083
|
return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
|
|
3021
3084
|
}
|
|
3022
3085
|
const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
|
|
3023
3086
|
if (shadowMatch) {
|
|
3024
3087
|
const key = shadowMatch[1] ?? "DEFAULT";
|
|
3025
|
-
if (
|
|
3088
|
+
if (has4(boxShadow, key)) {
|
|
3026
3089
|
return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
|
|
3027
3090
|
}
|
|
3028
|
-
if (!shadowMatch[1] &&
|
|
3091
|
+
if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
|
|
3029
3092
|
return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
|
|
3030
3093
|
}
|
|
3031
3094
|
}
|
|
3032
3095
|
const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
|
|
3033
3096
|
if (roundedMatch) {
|
|
3034
3097
|
const key = roundedMatch[1] ?? "DEFAULT";
|
|
3035
|
-
if (
|
|
3036
|
-
if (!roundedMatch[1] &&
|
|
3098
|
+
if (has4(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
|
|
3099
|
+
if (!roundedMatch[1] && has4(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
|
|
3037
3100
|
}
|
|
3038
3101
|
const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
|
|
3039
3102
|
if (roundedTMatch) {
|
|
3040
3103
|
const rkey = roundedTMatch[1] ?? "DEFAULT";
|
|
3041
|
-
const val =
|
|
3104
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3042
3105
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
|
|
3043
3106
|
}
|
|
3044
3107
|
const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
|
|
3045
3108
|
if (roundedBMatch) {
|
|
3046
3109
|
const rkey = roundedBMatch[1] ?? "DEFAULT";
|
|
3047
|
-
const val =
|
|
3110
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3048
3111
|
if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3049
3112
|
}
|
|
3050
3113
|
const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
|
|
3051
3114
|
if (roundedLMatch) {
|
|
3052
3115
|
const rkey = roundedLMatch[1] ?? "DEFAULT";
|
|
3053
|
-
const val =
|
|
3116
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3054
3117
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
|
|
3055
3118
|
}
|
|
3056
3119
|
const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
|
|
3057
3120
|
if (roundedRMatch) {
|
|
3058
3121
|
const rkey = roundedRMatch[1] ?? "DEFAULT";
|
|
3059
|
-
const val =
|
|
3122
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3060
3123
|
if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3061
3124
|
}
|
|
3062
3125
|
if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
|
|
@@ -3110,15 +3173,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3110
3173
|
"150": "1.5"
|
|
3111
3174
|
};
|
|
3112
3175
|
const scaleMatch = cls.match(/^scale-(\d+)$/);
|
|
3113
|
-
if (scaleMatch &&
|
|
3176
|
+
if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
|
|
3114
3177
|
return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
|
|
3115
3178
|
}
|
|
3116
3179
|
const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
|
|
3117
|
-
if (scaleXMatch &&
|
|
3180
|
+
if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
|
|
3118
3181
|
return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
|
|
3119
3182
|
}
|
|
3120
3183
|
const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
|
|
3121
|
-
if (scaleYMatch &&
|
|
3184
|
+
if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
|
|
3122
3185
|
return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
|
|
3123
3186
|
}
|
|
3124
3187
|
const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
|
|
@@ -3161,7 +3224,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3161
3224
|
"3xl": "64px"
|
|
3162
3225
|
};
|
|
3163
3226
|
const key = blurMatch[1] ?? "DEFAULT";
|
|
3164
|
-
if (
|
|
3227
|
+
if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
|
|
3165
3228
|
}
|
|
3166
3229
|
const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
|
|
3167
3230
|
if (backdropBlurMatch) {
|
|
@@ -3176,7 +3239,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3176
3239
|
"3xl": "64px"
|
|
3177
3240
|
};
|
|
3178
3241
|
const key = backdropBlurMatch[1] ?? "DEFAULT";
|
|
3179
|
-
if (
|
|
3242
|
+
if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
|
|
3180
3243
|
}
|
|
3181
3244
|
const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
|
|
3182
3245
|
if (arbOpacityMatch) {
|
|
@@ -3681,14 +3744,23 @@ var aliveui = (userConfig = {}) => {
|
|
|
3681
3744
|
postcssPlugin: "aliveui",
|
|
3682
3745
|
async Once(root, { result, postcss }) {
|
|
3683
3746
|
const classes = await scanContent(config);
|
|
3747
|
+
const hasAliveDirective = root.some((node) => node.type === "atrule" && node.name === "aliveui");
|
|
3748
|
+
if (hasAliveDirective) {
|
|
3749
|
+
const layerDecl = postcss.atRule({ name: "layer", params: "aliveui.base, aliveui.utilities" });
|
|
3750
|
+
root.prepend(layerDecl);
|
|
3751
|
+
}
|
|
3684
3752
|
root.walkAtRules("aliveui", (atRule) => {
|
|
3685
3753
|
const param = atRule.params.trim();
|
|
3686
3754
|
if (param === "base") {
|
|
3687
|
-
const css =
|
|
3755
|
+
const css = `@layer aliveui.base {
|
|
3756
|
+
${generateBase(config)}
|
|
3757
|
+
}`;
|
|
3688
3758
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3689
3759
|
atRule.replaceWith(parsed.nodes);
|
|
3690
3760
|
} else if (param === "utilities") {
|
|
3691
|
-
const css =
|
|
3761
|
+
const css = `@layer aliveui.utilities {
|
|
3762
|
+
${generateUtilities(classes, config)}
|
|
3763
|
+
}`;
|
|
3692
3764
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3693
3765
|
atRule.replaceWith(parsed.nodes);
|
|
3694
3766
|
} else {
|