@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/cli.js
CHANGED
|
@@ -2708,9 +2708,23 @@ function matchTypography(cls, fontSize, fontWeight, lineHeight) {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
|
|
2710
2710
|
// src/generator/layout.ts
|
|
2711
|
-
function
|
|
2711
|
+
function has2(obj, key) {
|
|
2712
|
+
return typeof obj[key] === "string";
|
|
2713
|
+
}
|
|
2714
|
+
function generateLayout(classes, config) {
|
|
2715
|
+
const { spacing } = config.theme;
|
|
2712
2716
|
const rules = [];
|
|
2713
2717
|
for (const cls of classes) {
|
|
2718
|
+
const spaceYMatch = cls.match(/^space-y-(.+)$/);
|
|
2719
|
+
if (spaceYMatch && has2(spacing, spaceYMatch[1])) {
|
|
2720
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-top: ${spacing[spaceYMatch[1]]}; }`);
|
|
2721
|
+
continue;
|
|
2722
|
+
}
|
|
2723
|
+
const spaceXMatch = cls.match(/^space-x-(.+)$/);
|
|
2724
|
+
if (spaceXMatch && has2(spacing, spaceXMatch[1])) {
|
|
2725
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-left: ${spacing[spaceXMatch[1]]}; }`);
|
|
2726
|
+
continue;
|
|
2727
|
+
}
|
|
2714
2728
|
const generated = matchLayout(cls);
|
|
2715
2729
|
if (generated) rules.push(generated);
|
|
2716
2730
|
}
|
|
@@ -2753,6 +2767,10 @@ function matchLayout(cls) {
|
|
|
2753
2767
|
if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2754
2768
|
if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2755
2769
|
if (cls === "flex-shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2770
|
+
if (cls === "grow") return `.${cls} { flex-grow: 1; }`;
|
|
2771
|
+
if (cls === "grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2772
|
+
if (cls === "shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2773
|
+
if (cls === "shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2756
2774
|
if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
|
|
2757
2775
|
if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
|
|
2758
2776
|
if (cls === "items-center") return `.${cls} { align-items: center; }`;
|
|
@@ -2929,7 +2947,7 @@ function matchLayout(cls) {
|
|
|
2929
2947
|
}
|
|
2930
2948
|
|
|
2931
2949
|
// src/generator/sizing.ts
|
|
2932
|
-
function
|
|
2950
|
+
function has3(obj, key) {
|
|
2933
2951
|
return typeof obj[key] === "string";
|
|
2934
2952
|
}
|
|
2935
2953
|
function generateSizing(classes, config) {
|
|
@@ -2980,8 +2998,8 @@ function matchSizing(cls, spacing) {
|
|
|
2980
2998
|
if (key === "min") return `.${cls} { width: min-content; }`;
|
|
2981
2999
|
if (key === "max") return `.${cls} { width: max-content; }`;
|
|
2982
3000
|
if (key === "fit") return `.${cls} { width: fit-content; }`;
|
|
2983
|
-
if (
|
|
2984
|
-
if (
|
|
3001
|
+
if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
|
|
3002
|
+
if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
|
|
2985
3003
|
}
|
|
2986
3004
|
const minWMatch = cls.match(/^min-w-(.+)$/);
|
|
2987
3005
|
if (minWMatch) {
|
|
@@ -2991,7 +3009,7 @@ function matchSizing(cls, spacing) {
|
|
|
2991
3009
|
if (key === "min") return `.${cls} { min-width: min-content; }`;
|
|
2992
3010
|
if (key === "max") return `.${cls} { min-width: max-content; }`;
|
|
2993
3011
|
if (key === "fit") return `.${cls} { min-width: fit-content; }`;
|
|
2994
|
-
if (
|
|
3012
|
+
if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
|
|
2995
3013
|
}
|
|
2996
3014
|
const maxWMap = {
|
|
2997
3015
|
none: "none",
|
|
@@ -3018,7 +3036,7 @@ function matchSizing(cls, spacing) {
|
|
|
3018
3036
|
"screen-2xl": "1536px"
|
|
3019
3037
|
};
|
|
3020
3038
|
const maxWMatch = cls.match(/^max-w-(.+)$/);
|
|
3021
|
-
if (maxWMatch &&
|
|
3039
|
+
if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
|
|
3022
3040
|
return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
|
|
3023
3041
|
}
|
|
3024
3042
|
const hMatch = cls.match(/^h-(.+)$/);
|
|
@@ -3032,8 +3050,8 @@ function matchSizing(cls, spacing) {
|
|
|
3032
3050
|
if (key === "min") return `.${cls} { height: min-content; }`;
|
|
3033
3051
|
if (key === "max") return `.${cls} { height: max-content; }`;
|
|
3034
3052
|
if (key === "fit") return `.${cls} { height: fit-content; }`;
|
|
3035
|
-
if (
|
|
3036
|
-
if (
|
|
3053
|
+
if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
|
|
3054
|
+
if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
|
|
3037
3055
|
}
|
|
3038
3056
|
const minHMatch = cls.match(/^min-h-(.+)$/);
|
|
3039
3057
|
if (minHMatch) {
|
|
@@ -3044,7 +3062,7 @@ function matchSizing(cls, spacing) {
|
|
|
3044
3062
|
if (key === "svh") return `.${cls} { min-height: 100svh; }`;
|
|
3045
3063
|
if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
|
|
3046
3064
|
if (key === "fit") return `.${cls} { min-height: fit-content; }`;
|
|
3047
|
-
if (
|
|
3065
|
+
if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
|
|
3048
3066
|
}
|
|
3049
3067
|
const maxHMatch = cls.match(/^max-h-(.+)$/);
|
|
3050
3068
|
if (maxHMatch) {
|
|
@@ -3055,13 +3073,22 @@ function matchSizing(cls, spacing) {
|
|
|
3055
3073
|
if (key === "svh") return `.${cls} { max-height: 100svh; }`;
|
|
3056
3074
|
if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
|
|
3057
3075
|
if (key === "fit") return `.${cls} { max-height: fit-content; }`;
|
|
3058
|
-
if (
|
|
3076
|
+
if (has3(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
|
|
3077
|
+
}
|
|
3078
|
+
const basisMatch = cls.match(/^basis-(.+)$/);
|
|
3079
|
+
if (basisMatch) {
|
|
3080
|
+
const key = basisMatch[1];
|
|
3081
|
+
if (key === "auto") return `.${cls} { flex-basis: auto; }`;
|
|
3082
|
+
if (key === "full") return `.${cls} { flex-basis: 100%; }`;
|
|
3083
|
+
if (key === "0") return `.${cls} { flex-basis: 0px; }`;
|
|
3084
|
+
if (has3(fractions, key)) return `.${cls} { flex-basis: ${fractions[key]}; }`;
|
|
3085
|
+
if (has3(spacing, key)) return `.${cls} { flex-basis: ${spacing[key]}; }`;
|
|
3059
3086
|
}
|
|
3060
3087
|
return null;
|
|
3061
3088
|
}
|
|
3062
3089
|
|
|
3063
3090
|
// src/generator/effects.ts
|
|
3064
|
-
function
|
|
3091
|
+
function has4(obj, key) {
|
|
3065
3092
|
return typeof obj[key] === "string";
|
|
3066
3093
|
}
|
|
3067
3094
|
function generateEffects(classes, config) {
|
|
@@ -3075,7 +3102,7 @@ function generateEffects(classes, config) {
|
|
|
3075
3102
|
}
|
|
3076
3103
|
function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
3077
3104
|
const opacityMatch = cls.match(/^opacity-(.+)$/);
|
|
3078
|
-
if (opacityMatch &&
|
|
3105
|
+
if (opacityMatch && has4(opacity, opacityMatch[1])) {
|
|
3079
3106
|
return `.${cls} {
|
|
3080
3107
|
opacity: ${opacity[opacityMatch[1]]};
|
|
3081
3108
|
transition-property: opacity;
|
|
@@ -3084,47 +3111,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3084
3111
|
}`;
|
|
3085
3112
|
}
|
|
3086
3113
|
const zMatch = cls.match(/^z-(.+)$/);
|
|
3087
|
-
if (zMatch &&
|
|
3114
|
+
if (zMatch && has4(zIndex, zMatch[1])) {
|
|
3088
3115
|
return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
|
|
3089
3116
|
}
|
|
3090
3117
|
const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
|
|
3091
3118
|
if (shadowMatch) {
|
|
3092
3119
|
const key = shadowMatch[1] ?? "DEFAULT";
|
|
3093
|
-
if (
|
|
3120
|
+
if (has4(boxShadow, key)) {
|
|
3094
3121
|
return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
|
|
3095
3122
|
}
|
|
3096
|
-
if (!shadowMatch[1] &&
|
|
3123
|
+
if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
|
|
3097
3124
|
return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
|
|
3098
3125
|
}
|
|
3099
3126
|
}
|
|
3100
3127
|
const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
|
|
3101
3128
|
if (roundedMatch) {
|
|
3102
3129
|
const key = roundedMatch[1] ?? "DEFAULT";
|
|
3103
|
-
if (
|
|
3104
|
-
if (!roundedMatch[1] &&
|
|
3130
|
+
if (has4(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
|
|
3131
|
+
if (!roundedMatch[1] && has4(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
|
|
3105
3132
|
}
|
|
3106
3133
|
const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
|
|
3107
3134
|
if (roundedTMatch) {
|
|
3108
3135
|
const rkey = roundedTMatch[1] ?? "DEFAULT";
|
|
3109
|
-
const val =
|
|
3136
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3110
3137
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
|
|
3111
3138
|
}
|
|
3112
3139
|
const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
|
|
3113
3140
|
if (roundedBMatch) {
|
|
3114
3141
|
const rkey = roundedBMatch[1] ?? "DEFAULT";
|
|
3115
|
-
const val =
|
|
3142
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3116
3143
|
if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3117
3144
|
}
|
|
3118
3145
|
const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
|
|
3119
3146
|
if (roundedLMatch) {
|
|
3120
3147
|
const rkey = roundedLMatch[1] ?? "DEFAULT";
|
|
3121
|
-
const val =
|
|
3148
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3122
3149
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
|
|
3123
3150
|
}
|
|
3124
3151
|
const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
|
|
3125
3152
|
if (roundedRMatch) {
|
|
3126
3153
|
const rkey = roundedRMatch[1] ?? "DEFAULT";
|
|
3127
|
-
const val =
|
|
3154
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3128
3155
|
if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3129
3156
|
}
|
|
3130
3157
|
if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
|
|
@@ -3178,15 +3205,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3178
3205
|
"150": "1.5"
|
|
3179
3206
|
};
|
|
3180
3207
|
const scaleMatch = cls.match(/^scale-(\d+)$/);
|
|
3181
|
-
if (scaleMatch &&
|
|
3208
|
+
if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
|
|
3182
3209
|
return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
|
|
3183
3210
|
}
|
|
3184
3211
|
const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
|
|
3185
|
-
if (scaleXMatch &&
|
|
3212
|
+
if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
|
|
3186
3213
|
return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
|
|
3187
3214
|
}
|
|
3188
3215
|
const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
|
|
3189
|
-
if (scaleYMatch &&
|
|
3216
|
+
if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
|
|
3190
3217
|
return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
|
|
3191
3218
|
}
|
|
3192
3219
|
const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
|
|
@@ -3229,7 +3256,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3229
3256
|
"3xl": "64px"
|
|
3230
3257
|
};
|
|
3231
3258
|
const key = blurMatch[1] ?? "DEFAULT";
|
|
3232
|
-
if (
|
|
3259
|
+
if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
|
|
3233
3260
|
}
|
|
3234
3261
|
const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
|
|
3235
3262
|
if (backdropBlurMatch) {
|
|
@@ -3244,7 +3271,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3244
3271
|
"3xl": "64px"
|
|
3245
3272
|
};
|
|
3246
3273
|
const key = backdropBlurMatch[1] ?? "DEFAULT";
|
|
3247
|
-
if (
|
|
3274
|
+
if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
|
|
3248
3275
|
}
|
|
3249
3276
|
const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
|
|
3250
3277
|
if (arbOpacityMatch) {
|
package/dist/index.js
CHANGED
|
@@ -2716,9 +2716,23 @@ function matchTypography(cls, fontSize, fontWeight, lineHeight) {
|
|
|
2716
2716
|
}
|
|
2717
2717
|
|
|
2718
2718
|
// src/generator/layout.ts
|
|
2719
|
-
function
|
|
2719
|
+
function has2(obj, key) {
|
|
2720
|
+
return typeof obj[key] === "string";
|
|
2721
|
+
}
|
|
2722
|
+
function generateLayout(classes, config) {
|
|
2723
|
+
const { spacing } = config.theme;
|
|
2720
2724
|
const rules = [];
|
|
2721
2725
|
for (const cls of classes) {
|
|
2726
|
+
const spaceYMatch = cls.match(/^space-y-(.+)$/);
|
|
2727
|
+
if (spaceYMatch && has2(spacing, spaceYMatch[1])) {
|
|
2728
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-top: ${spacing[spaceYMatch[1]]}; }`);
|
|
2729
|
+
continue;
|
|
2730
|
+
}
|
|
2731
|
+
const spaceXMatch = cls.match(/^space-x-(.+)$/);
|
|
2732
|
+
if (spaceXMatch && has2(spacing, spaceXMatch[1])) {
|
|
2733
|
+
rules.push(`.${escapeSelector(cls)} > * + * { margin-left: ${spacing[spaceXMatch[1]]}; }`);
|
|
2734
|
+
continue;
|
|
2735
|
+
}
|
|
2722
2736
|
const generated = matchLayout(cls);
|
|
2723
2737
|
if (generated) rules.push(generated);
|
|
2724
2738
|
}
|
|
@@ -2761,6 +2775,10 @@ function matchLayout(cls) {
|
|
|
2761
2775
|
if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2762
2776
|
if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2763
2777
|
if (cls === "flex-shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2778
|
+
if (cls === "grow") return `.${cls} { flex-grow: 1; }`;
|
|
2779
|
+
if (cls === "grow-0") return `.${cls} { flex-grow: 0; }`;
|
|
2780
|
+
if (cls === "shrink") return `.${cls} { flex-shrink: 1; }`;
|
|
2781
|
+
if (cls === "shrink-0") return `.${cls} { flex-shrink: 0; }`;
|
|
2764
2782
|
if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
|
|
2765
2783
|
if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
|
|
2766
2784
|
if (cls === "items-center") return `.${cls} { align-items: center; }`;
|
|
@@ -2937,7 +2955,7 @@ function matchLayout(cls) {
|
|
|
2937
2955
|
}
|
|
2938
2956
|
|
|
2939
2957
|
// src/generator/sizing.ts
|
|
2940
|
-
function
|
|
2958
|
+
function has3(obj, key) {
|
|
2941
2959
|
return typeof obj[key] === "string";
|
|
2942
2960
|
}
|
|
2943
2961
|
function generateSizing(classes, config) {
|
|
@@ -2988,8 +3006,8 @@ function matchSizing(cls, spacing) {
|
|
|
2988
3006
|
if (key === "min") return `.${cls} { width: min-content; }`;
|
|
2989
3007
|
if (key === "max") return `.${cls} { width: max-content; }`;
|
|
2990
3008
|
if (key === "fit") return `.${cls} { width: fit-content; }`;
|
|
2991
|
-
if (
|
|
2992
|
-
if (
|
|
3009
|
+
if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
|
|
3010
|
+
if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
|
|
2993
3011
|
}
|
|
2994
3012
|
const minWMatch = cls.match(/^min-w-(.+)$/);
|
|
2995
3013
|
if (minWMatch) {
|
|
@@ -2999,7 +3017,7 @@ function matchSizing(cls, spacing) {
|
|
|
2999
3017
|
if (key === "min") return `.${cls} { min-width: min-content; }`;
|
|
3000
3018
|
if (key === "max") return `.${cls} { min-width: max-content; }`;
|
|
3001
3019
|
if (key === "fit") return `.${cls} { min-width: fit-content; }`;
|
|
3002
|
-
if (
|
|
3020
|
+
if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
|
|
3003
3021
|
}
|
|
3004
3022
|
const maxWMap = {
|
|
3005
3023
|
none: "none",
|
|
@@ -3026,7 +3044,7 @@ function matchSizing(cls, spacing) {
|
|
|
3026
3044
|
"screen-2xl": "1536px"
|
|
3027
3045
|
};
|
|
3028
3046
|
const maxWMatch = cls.match(/^max-w-(.+)$/);
|
|
3029
|
-
if (maxWMatch &&
|
|
3047
|
+
if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
|
|
3030
3048
|
return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
|
|
3031
3049
|
}
|
|
3032
3050
|
const hMatch = cls.match(/^h-(.+)$/);
|
|
@@ -3040,8 +3058,8 @@ function matchSizing(cls, spacing) {
|
|
|
3040
3058
|
if (key === "min") return `.${cls} { height: min-content; }`;
|
|
3041
3059
|
if (key === "max") return `.${cls} { height: max-content; }`;
|
|
3042
3060
|
if (key === "fit") return `.${cls} { height: fit-content; }`;
|
|
3043
|
-
if (
|
|
3044
|
-
if (
|
|
3061
|
+
if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
|
|
3062
|
+
if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
|
|
3045
3063
|
}
|
|
3046
3064
|
const minHMatch = cls.match(/^min-h-(.+)$/);
|
|
3047
3065
|
if (minHMatch) {
|
|
@@ -3052,7 +3070,7 @@ function matchSizing(cls, spacing) {
|
|
|
3052
3070
|
if (key === "svh") return `.${cls} { min-height: 100svh; }`;
|
|
3053
3071
|
if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
|
|
3054
3072
|
if (key === "fit") return `.${cls} { min-height: fit-content; }`;
|
|
3055
|
-
if (
|
|
3073
|
+
if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
|
|
3056
3074
|
}
|
|
3057
3075
|
const maxHMatch = cls.match(/^max-h-(.+)$/);
|
|
3058
3076
|
if (maxHMatch) {
|
|
@@ -3063,13 +3081,22 @@ function matchSizing(cls, spacing) {
|
|
|
3063
3081
|
if (key === "svh") return `.${cls} { max-height: 100svh; }`;
|
|
3064
3082
|
if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
|
|
3065
3083
|
if (key === "fit") return `.${cls} { max-height: fit-content; }`;
|
|
3066
|
-
if (
|
|
3084
|
+
if (has3(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
|
|
3085
|
+
}
|
|
3086
|
+
const basisMatch = cls.match(/^basis-(.+)$/);
|
|
3087
|
+
if (basisMatch) {
|
|
3088
|
+
const key = basisMatch[1];
|
|
3089
|
+
if (key === "auto") return `.${cls} { flex-basis: auto; }`;
|
|
3090
|
+
if (key === "full") return `.${cls} { flex-basis: 100%; }`;
|
|
3091
|
+
if (key === "0") return `.${cls} { flex-basis: 0px; }`;
|
|
3092
|
+
if (has3(fractions, key)) return `.${cls} { flex-basis: ${fractions[key]}; }`;
|
|
3093
|
+
if (has3(spacing, key)) return `.${cls} { flex-basis: ${spacing[key]}; }`;
|
|
3067
3094
|
}
|
|
3068
3095
|
return null;
|
|
3069
3096
|
}
|
|
3070
3097
|
|
|
3071
3098
|
// src/generator/effects.ts
|
|
3072
|
-
function
|
|
3099
|
+
function has4(obj, key) {
|
|
3073
3100
|
return typeof obj[key] === "string";
|
|
3074
3101
|
}
|
|
3075
3102
|
function generateEffects(classes, config) {
|
|
@@ -3083,7 +3110,7 @@ function generateEffects(classes, config) {
|
|
|
3083
3110
|
}
|
|
3084
3111
|
function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
3085
3112
|
const opacityMatch = cls.match(/^opacity-(.+)$/);
|
|
3086
|
-
if (opacityMatch &&
|
|
3113
|
+
if (opacityMatch && has4(opacity, opacityMatch[1])) {
|
|
3087
3114
|
return `.${cls} {
|
|
3088
3115
|
opacity: ${opacity[opacityMatch[1]]};
|
|
3089
3116
|
transition-property: opacity;
|
|
@@ -3092,47 +3119,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3092
3119
|
}`;
|
|
3093
3120
|
}
|
|
3094
3121
|
const zMatch = cls.match(/^z-(.+)$/);
|
|
3095
|
-
if (zMatch &&
|
|
3122
|
+
if (zMatch && has4(zIndex, zMatch[1])) {
|
|
3096
3123
|
return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
|
|
3097
3124
|
}
|
|
3098
3125
|
const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
|
|
3099
3126
|
if (shadowMatch) {
|
|
3100
3127
|
const key = shadowMatch[1] ?? "DEFAULT";
|
|
3101
|
-
if (
|
|
3128
|
+
if (has4(boxShadow, key)) {
|
|
3102
3129
|
return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
|
|
3103
3130
|
}
|
|
3104
|
-
if (!shadowMatch[1] &&
|
|
3131
|
+
if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
|
|
3105
3132
|
return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
|
|
3106
3133
|
}
|
|
3107
3134
|
}
|
|
3108
3135
|
const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
|
|
3109
3136
|
if (roundedMatch) {
|
|
3110
3137
|
const key = roundedMatch[1] ?? "DEFAULT";
|
|
3111
|
-
if (
|
|
3112
|
-
if (!roundedMatch[1] &&
|
|
3138
|
+
if (has4(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
|
|
3139
|
+
if (!roundedMatch[1] && has4(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
|
|
3113
3140
|
}
|
|
3114
3141
|
const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
|
|
3115
3142
|
if (roundedTMatch) {
|
|
3116
3143
|
const rkey = roundedTMatch[1] ?? "DEFAULT";
|
|
3117
|
-
const val =
|
|
3144
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3118
3145
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
|
|
3119
3146
|
}
|
|
3120
3147
|
const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
|
|
3121
3148
|
if (roundedBMatch) {
|
|
3122
3149
|
const rkey = roundedBMatch[1] ?? "DEFAULT";
|
|
3123
|
-
const val =
|
|
3150
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3124
3151
|
if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3125
3152
|
}
|
|
3126
3153
|
const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
|
|
3127
3154
|
if (roundedLMatch) {
|
|
3128
3155
|
const rkey = roundedLMatch[1] ?? "DEFAULT";
|
|
3129
|
-
const val =
|
|
3156
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3130
3157
|
if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
|
|
3131
3158
|
}
|
|
3132
3159
|
const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
|
|
3133
3160
|
if (roundedRMatch) {
|
|
3134
3161
|
const rkey = roundedRMatch[1] ?? "DEFAULT";
|
|
3135
|
-
const val =
|
|
3162
|
+
const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
|
|
3136
3163
|
if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
|
|
3137
3164
|
}
|
|
3138
3165
|
if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
|
|
@@ -3186,15 +3213,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3186
3213
|
"150": "1.5"
|
|
3187
3214
|
};
|
|
3188
3215
|
const scaleMatch = cls.match(/^scale-(\d+)$/);
|
|
3189
|
-
if (scaleMatch &&
|
|
3216
|
+
if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
|
|
3190
3217
|
return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
|
|
3191
3218
|
}
|
|
3192
3219
|
const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
|
|
3193
|
-
if (scaleXMatch &&
|
|
3220
|
+
if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
|
|
3194
3221
|
return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
|
|
3195
3222
|
}
|
|
3196
3223
|
const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
|
|
3197
|
-
if (scaleYMatch &&
|
|
3224
|
+
if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
|
|
3198
3225
|
return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
|
|
3199
3226
|
}
|
|
3200
3227
|
const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
|
|
@@ -3237,7 +3264,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3237
3264
|
"3xl": "64px"
|
|
3238
3265
|
};
|
|
3239
3266
|
const key = blurMatch[1] ?? "DEFAULT";
|
|
3240
|
-
if (
|
|
3267
|
+
if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
|
|
3241
3268
|
}
|
|
3242
3269
|
const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
|
|
3243
3270
|
if (backdropBlurMatch) {
|
|
@@ -3252,7 +3279,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
|
|
|
3252
3279
|
"3xl": "64px"
|
|
3253
3280
|
};
|
|
3254
3281
|
const key = backdropBlurMatch[1] ?? "DEFAULT";
|
|
3255
|
-
if (
|
|
3282
|
+
if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
|
|
3256
3283
|
}
|
|
3257
3284
|
const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
|
|
3258
3285
|
if (arbOpacityMatch) {
|
|
@@ -3757,14 +3784,23 @@ var aliveui = (userConfig = {}) => {
|
|
|
3757
3784
|
postcssPlugin: "aliveui",
|
|
3758
3785
|
async Once(root, { result, postcss }) {
|
|
3759
3786
|
const classes = await scanContent(config);
|
|
3787
|
+
const hasAliveDirective = root.some((node) => node.type === "atrule" && node.name === "aliveui");
|
|
3788
|
+
if (hasAliveDirective) {
|
|
3789
|
+
const layerDecl = postcss.atRule({ name: "layer", params: "aliveui.base, aliveui.utilities" });
|
|
3790
|
+
root.prepend(layerDecl);
|
|
3791
|
+
}
|
|
3760
3792
|
root.walkAtRules("aliveui", (atRule) => {
|
|
3761
3793
|
const param = atRule.params.trim();
|
|
3762
3794
|
if (param === "base") {
|
|
3763
|
-
const css =
|
|
3795
|
+
const css = `@layer aliveui.base {
|
|
3796
|
+
${generateBase(config)}
|
|
3797
|
+
}`;
|
|
3764
3798
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3765
3799
|
atRule.replaceWith(parsed.nodes);
|
|
3766
3800
|
} else if (param === "utilities") {
|
|
3767
|
-
const css =
|
|
3801
|
+
const css = `@layer aliveui.utilities {
|
|
3802
|
+
${generateUtilities(classes, config)}
|
|
3803
|
+
}`;
|
|
3768
3804
|
const parsed = postcss.parse(css, { from: atRule.source?.input.file });
|
|
3769
3805
|
atRule.replaceWith(parsed.nodes);
|
|
3770
3806
|
} else {
|