@alivecss/aliveui 1.0.1 → 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/dist/cli.js +53 -26
- package/dist/index.js +64 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -28
- package/dist/index.mjs.map +1 -1
- package/dist/vite.js +65 -28
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +65 -28
- package/dist/vite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2676,9 +2676,23 @@ function matchTypography(cls, fontSize, fontWeight, lineHeight) {
|
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
2678
2678
|
// src/generator/layout.ts
|
|
2679
|
-
function
|
|
2679
|
+
function has2(obj, key) {
|
|
2680
|
+
return typeof obj[key] === "string";
|
|
2681
|
+
}
|
|
2682
|
+
function generateLayout(classes, config) {
|
|
2683
|
+
const { spacing } = config.theme;
|
|
2680
2684
|
const rules = [];
|
|
2681
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
|
+
}
|
|
2682
2696
|
const generated = matchLayout(cls);
|
|
2683
2697
|
if (generated) rules.push(generated);
|
|
2684
2698
|
}
|
|
@@ -2721,6 +2735,10 @@ function matchLayout(cls) {
|
|
|
2721
2735
|
if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2722
2736
|
if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2723
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; }`;
|
|
2724
2742
|
if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
|
|
2725
2743
|
if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
|
|
2726
2744
|
if (cls === "items-center") return `.${cls} { align-items: center; }`;
|
|
@@ -2897,7 +2915,7 @@ function matchLayout(cls) {
|
|
|
2897
2915
|
}
|
|
2898
2916
|
|
|
2899
2917
|
// src/generator/sizing.ts
|
|
2900
|
-
function
|
|
2918
|
+
function has3(obj, key) {
|
|
2901
2919
|
return typeof obj[key] === "string";
|
|
2902
2920
|
}
|
|
2903
2921
|
function generateSizing(classes, config) {
|
|
@@ -2948,8 +2966,8 @@ function matchSizing(cls, spacing) {
|
|
|
2948
2966
|
if (key === "min") return `.${cls} { width: min-content; }`;
|
|
2949
2967
|
if (key === "max") return `.${cls} { width: max-content; }`;
|
|
2950
2968
|
if (key === "fit") return `.${cls} { width: fit-content; }`;
|
|
2951
|
-
if (
|
|
2952
|
-
if (
|
|
2969
|
+
if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
|
|
2970
|
+
if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
|
|
2953
2971
|
}
|
|
2954
2972
|
const minWMatch = cls.match(/^min-w-(.+)$/);
|
|
2955
2973
|
if (minWMatch) {
|
|
@@ -2959,7 +2977,7 @@ function matchSizing(cls, spacing) {
|
|
|
2959
2977
|
if (key === "min") return `.${cls} { min-width: min-content; }`;
|
|
2960
2978
|
if (key === "max") return `.${cls} { min-width: max-content; }`;
|
|
2961
2979
|
if (key === "fit") return `.${cls} { min-width: fit-content; }`;
|
|
2962
|
-
if (
|
|
2980
|
+
if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
|
|
2963
2981
|
}
|
|
2964
2982
|
const maxWMap = {
|
|
2965
2983
|
none: "none",
|
|
@@ -2986,7 +3004,7 @@ function matchSizing(cls, spacing) {
|
|
|
2986
3004
|
"screen-2xl": "1536px"
|
|
2987
3005
|
};
|
|
2988
3006
|
const maxWMatch = cls.match(/^max-w-(.+)$/);
|
|
2989
|
-
if (maxWMatch &&
|
|
3007
|
+
if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
|
|
2990
3008
|
return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
|
|
2991
3009
|
}
|
|
2992
3010
|
const hMatch = cls.match(/^h-(.+)$/);
|
|
@@ -3000,8 +3018,8 @@ function matchSizing(cls, spacing) {
|
|
|
3000
3018
|
if (key === "min") return `.${cls} { height: min-content; }`;
|
|
3001
3019
|
if (key === "max") return `.${cls} { height: max-content; }`;
|
|
3002
3020
|
if (key === "fit") return `.${cls} { height: fit-content; }`;
|
|
3003
|
-
if (
|
|
3004
|
-
if (
|
|
3021
|
+
if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
|
|
3022
|
+
if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
|
|
3005
3023
|
}
|
|
3006
3024
|
const minHMatch = cls.match(/^min-h-(.+)$/);
|
|
3007
3025
|
if (minHMatch) {
|
|
@@ -3012,7 +3030,7 @@ function matchSizing(cls, spacing) {
|
|
|
3012
3030
|
if (key === "svh") return `.${cls} { min-height: 100svh; }`;
|
|
3013
3031
|
if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
|
|
3014
3032
|
if (key === "fit") return `.${cls} { min-height: fit-content; }`;
|
|
3015
|
-
if (
|
|
3033
|
+
if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
|
|
3016
3034
|
}
|
|
3017
3035
|
const maxHMatch = cls.match(/^max-h-(.+)$/);
|
|
3018
3036
|
if (maxHMatch) {
|
|
@@ -3023,13 +3041,22 @@ function matchSizing(cls, spacing) {
|
|
|
3023
3041
|
if (key === "svh") return `.${cls} { max-height: 100svh; }`;
|
|
3024
3042
|
if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
|
|
3025
3043
|
if (key === "fit") return `.${cls} { max-height: fit-content; }`;
|
|
3026
|
-
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]}; }`;
|
|
3027
3054
|
}
|
|
3028
3055
|
return null;
|
|
3029
3056
|
}
|
|
3030
3057
|
|
|
3031
3058
|
// src/generator/effects.ts
|
|
3032
|
-
function
|
|
3059
|
+
function has4(obj, key) {
|
|
3033
3060
|
return typeof obj[key] === "string";
|
|
3034
3061
|
}
|
|
3035
3062
|
function generateEffects(classes, config) {
|
|
@@ -3043,7 +3070,7 @@ function generateEffects(classes, config) {
|
|
|
3043
3070
|
}
|
|
3044
3071
|
function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
3045
3072
|
const opacityMatch = cls.match(/^opacity-(.+)$/);
|
|
3046
|
-
if (opacityMatch &&
|
|
3073
|
+
if (opacityMatch && has4(opacity, opacityMatch[1])) {
|
|
3047
3074
|
return `.${cls} {
|
|
3048
3075
|
opacity: ${opacity[opacityMatch[1]]};
|
|
3049
3076
|
transition-property: opacity;
|
|
@@ -3052,47 +3079,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3052
3079
|
}`;
|
|
3053
3080
|
}
|
|
3054
3081
|
const zMatch = cls.match(/^z-(.+)$/);
|
|
3055
|
-
if (zMatch &&
|
|
3082
|
+
if (zMatch && has4(zIndex, zMatch[1])) {
|
|
3056
3083
|
return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
|
|
3057
3084
|
}
|
|
3058
3085
|
const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
|
|
3059
3086
|
if (shadowMatch) {
|
|
3060
3087
|
const key = shadowMatch[1] ?? "DEFAULT";
|
|
3061
|
-
if (
|
|
3088
|
+
if (has4(boxShadow, key)) {
|
|
3062
3089
|
return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
|
|
3063
3090
|
}
|
|
3064
|
-
if (!shadowMatch[1] &&
|
|
3091
|
+
if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
|
|
3065
3092
|
return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
|
|
3066
3093
|
}
|
|
3067
3094
|
}
|
|
3068
3095
|
const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
|
|
3069
3096
|
if (roundedMatch) {
|
|
3070
3097
|
const key = roundedMatch[1] ?? "DEFAULT";
|
|
3071
|
-
if (
|
|
3072
|
-
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"]}; }`;
|
|
3073
3100
|
}
|
|
3074
3101
|
const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
|
|
3075
3102
|
if (roundedTMatch) {
|
|
3076
3103
|
const rkey = roundedTMatch[1] ?? "DEFAULT";
|
|
3077
|
-
const val =
|
|
3104
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3078
3105
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
|
|
3079
3106
|
}
|
|
3080
3107
|
const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
|
|
3081
3108
|
if (roundedBMatch) {
|
|
3082
3109
|
const rkey = roundedBMatch[1] ?? "DEFAULT";
|
|
3083
|
-
const val =
|
|
3110
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3084
3111
|
if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3085
3112
|
}
|
|
3086
3113
|
const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
|
|
3087
3114
|
if (roundedLMatch) {
|
|
3088
3115
|
const rkey = roundedLMatch[1] ?? "DEFAULT";
|
|
3089
|
-
const val =
|
|
3116
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3090
3117
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
|
|
3091
3118
|
}
|
|
3092
3119
|
const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
|
|
3093
3120
|
if (roundedRMatch) {
|
|
3094
3121
|
const rkey = roundedRMatch[1] ?? "DEFAULT";
|
|
3095
|
-
const val =
|
|
3122
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3096
3123
|
if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3097
3124
|
}
|
|
3098
3125
|
if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
|
|
@@ -3146,15 +3173,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3146
3173
|
"150": "1.5"
|
|
3147
3174
|
};
|
|
3148
3175
|
const scaleMatch = cls.match(/^scale-(\d+)$/);
|
|
3149
|
-
if (scaleMatch &&
|
|
3176
|
+
if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
|
|
3150
3177
|
return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
|
|
3151
3178
|
}
|
|
3152
3179
|
const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
|
|
3153
|
-
if (scaleXMatch &&
|
|
3180
|
+
if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
|
|
3154
3181
|
return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
|
|
3155
3182
|
}
|
|
3156
3183
|
const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
|
|
3157
|
-
if (scaleYMatch &&
|
|
3184
|
+
if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
|
|
3158
3185
|
return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
|
|
3159
3186
|
}
|
|
3160
3187
|
const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
|
|
@@ -3197,7 +3224,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3197
3224
|
"3xl": "64px"
|
|
3198
3225
|
};
|
|
3199
3226
|
const key = blurMatch[1] ?? "DEFAULT";
|
|
3200
|
-
if (
|
|
3227
|
+
if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
|
|
3201
3228
|
}
|
|
3202
3229
|
const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
|
|
3203
3230
|
if (backdropBlurMatch) {
|
|
@@ -3212,7 +3239,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3212
3239
|
"3xl": "64px"
|
|
3213
3240
|
};
|
|
3214
3241
|
const key = backdropBlurMatch[1] ?? "DEFAULT";
|
|
3215
|
-
if (
|
|
3242
|
+
if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
|
|
3216
3243
|
}
|
|
3217
3244
|
const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
|
|
3218
3245
|
if (arbOpacityMatch) {
|
|
@@ -3717,14 +3744,23 @@ var aliveui = (userConfig = {}) => {
|
|
|
3717
3744
|
postcssPlugin: "aliveui",
|
|
3718
3745
|
async Once(root, { result, postcss }) {
|
|
3719
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
|
+
}
|
|
3720
3752
|
root.walkAtRules("aliveui", (atRule) => {
|
|
3721
3753
|
const param = atRule.params.trim();
|
|
3722
3754
|
if (param === "base") {
|
|
3723
|
-
const css =
|
|
3755
|
+
const css = `@layer aliveui.base {
|
|
3756
|
+
${generateBase(config)}
|
|
3757
|
+
}`;
|
|
3724
3758
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3725
3759
|
atRule.replaceWith(parsed.nodes);
|
|
3726
3760
|
} else if (param === "utilities") {
|
|
3727
|
-
const css =
|
|
3761
|
+
const css = `@layer aliveui.utilities {
|
|
3762
|
+
${generateUtilities(classes, config)}
|
|
3763
|
+
}`;
|
|
3728
3764
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3729
3765
|
atRule.replaceWith(parsed.nodes);
|
|
3730
3766
|
} else {
|