@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/vite.mjs CHANGED
@@ -2750,9 +2750,23 @@ var init_typography = __esm({
2750
2750
  });
2751
2751
 
2752
2752
  // src/generator/layout.ts
2753
- function generateLayout(classes, _config) {
2753
+ function has2(obj, key) {
2754
+ return typeof obj[key] === "string";
2755
+ }
2756
+ function generateLayout(classes, config) {
2757
+ const { spacing } = config.theme;
2754
2758
  const rules = [];
2755
2759
  for (const cls of classes) {
2760
+ const spaceYMatch = cls.match(/^space-y-(.+)$/);
2761
+ if (spaceYMatch && has2(spacing, spaceYMatch[1])) {
2762
+ rules.push(`.${escapeSelector(cls)} > * + * { margin-top: ${spacing[spaceYMatch[1]]}; }`);
2763
+ continue;
2764
+ }
2765
+ const spaceXMatch = cls.match(/^space-x-(.+)$/);
2766
+ if (spaceXMatch && has2(spacing, spaceXMatch[1])) {
2767
+ rules.push(`.${escapeSelector(cls)} > * + * { margin-left: ${spacing[spaceXMatch[1]]}; }`);
2768
+ continue;
2769
+ }
2756
2770
  const generated = matchLayout(cls);
2757
2771
  if (generated) rules.push(generated);
2758
2772
  }
@@ -2795,6 +2809,10 @@ function matchLayout(cls) {
2795
2809
  if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
2796
2810
  if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
2797
2811
  if (cls === "flex-shrink-0") return `.${cls} { flex-shrink: 0; }`;
2812
+ if (cls === "grow") return `.${cls} { flex-grow: 1; }`;
2813
+ if (cls === "grow-0") return `.${cls} { flex-grow: 0; }`;
2814
+ if (cls === "shrink") return `.${cls} { flex-shrink: 1; }`;
2815
+ if (cls === "shrink-0") return `.${cls} { flex-shrink: 0; }`;
2798
2816
  if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
2799
2817
  if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
2800
2818
  if (cls === "items-center") return `.${cls} { align-items: center; }`;
@@ -2972,11 +2990,12 @@ function matchLayout(cls) {
2972
2990
  var init_layout = __esm({
2973
2991
  "src/generator/layout.ts"() {
2974
2992
  "use strict";
2993
+ init_utils();
2975
2994
  }
2976
2995
  });
2977
2996
 
2978
2997
  // src/generator/sizing.ts
2979
- function has2(obj, key) {
2998
+ function has3(obj, key) {
2980
2999
  return typeof obj[key] === "string";
2981
3000
  }
2982
3001
  function generateSizing(classes, config) {
@@ -3027,8 +3046,8 @@ function matchSizing(cls, spacing) {
3027
3046
  if (key === "min") return `.${cls} { width: min-content; }`;
3028
3047
  if (key === "max") return `.${cls} { width: max-content; }`;
3029
3048
  if (key === "fit") return `.${cls} { width: fit-content; }`;
3030
- if (has2(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
3031
- if (has2(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
3049
+ if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
3050
+ if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
3032
3051
  }
3033
3052
  const minWMatch = cls.match(/^min-w-(.+)$/);
3034
3053
  if (minWMatch) {
@@ -3038,7 +3057,7 @@ function matchSizing(cls, spacing) {
3038
3057
  if (key === "min") return `.${cls} { min-width: min-content; }`;
3039
3058
  if (key === "max") return `.${cls} { min-width: max-content; }`;
3040
3059
  if (key === "fit") return `.${cls} { min-width: fit-content; }`;
3041
- if (has2(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3060
+ if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3042
3061
  }
3043
3062
  const maxWMap = {
3044
3063
  none: "none",
@@ -3065,7 +3084,7 @@ function matchSizing(cls, spacing) {
3065
3084
  "screen-2xl": "1536px"
3066
3085
  };
3067
3086
  const maxWMatch = cls.match(/^max-w-(.+)$/);
3068
- if (maxWMatch && has2(maxWMap, maxWMatch[1])) {
3087
+ if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
3069
3088
  return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
3070
3089
  }
3071
3090
  const hMatch = cls.match(/^h-(.+)$/);
@@ -3079,8 +3098,8 @@ function matchSizing(cls, spacing) {
3079
3098
  if (key === "min") return `.${cls} { height: min-content; }`;
3080
3099
  if (key === "max") return `.${cls} { height: max-content; }`;
3081
3100
  if (key === "fit") return `.${cls} { height: fit-content; }`;
3082
- if (has2(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
3083
- if (has2(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
3101
+ if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
3102
+ if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
3084
3103
  }
3085
3104
  const minHMatch = cls.match(/^min-h-(.+)$/);
3086
3105
  if (minHMatch) {
@@ -3091,7 +3110,7 @@ function matchSizing(cls, spacing) {
3091
3110
  if (key === "svh") return `.${cls} { min-height: 100svh; }`;
3092
3111
  if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
3093
3112
  if (key === "fit") return `.${cls} { min-height: fit-content; }`;
3094
- if (has2(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3113
+ if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3095
3114
  }
3096
3115
  const maxHMatch = cls.match(/^max-h-(.+)$/);
3097
3116
  if (maxHMatch) {
@@ -3102,7 +3121,16 @@ function matchSizing(cls, spacing) {
3102
3121
  if (key === "svh") return `.${cls} { max-height: 100svh; }`;
3103
3122
  if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
3104
3123
  if (key === "fit") return `.${cls} { max-height: fit-content; }`;
3105
- if (has2(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
3124
+ if (has3(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
3125
+ }
3126
+ const basisMatch = cls.match(/^basis-(.+)$/);
3127
+ if (basisMatch) {
3128
+ const key = basisMatch[1];
3129
+ if (key === "auto") return `.${cls} { flex-basis: auto; }`;
3130
+ if (key === "full") return `.${cls} { flex-basis: 100%; }`;
3131
+ if (key === "0") return `.${cls} { flex-basis: 0px; }`;
3132
+ if (has3(fractions, key)) return `.${cls} { flex-basis: ${fractions[key]}; }`;
3133
+ if (has3(spacing, key)) return `.${cls} { flex-basis: ${spacing[key]}; }`;
3106
3134
  }
3107
3135
  return null;
3108
3136
  }
@@ -3113,7 +3141,7 @@ var init_sizing = __esm({
3113
3141
  });
3114
3142
 
3115
3143
  // src/generator/effects.ts
3116
- function has3(obj, key) {
3144
+ function has4(obj, key) {
3117
3145
  return typeof obj[key] === "string";
3118
3146
  }
3119
3147
  function generateEffects(classes, config) {
@@ -3127,7 +3155,7 @@ function generateEffects(classes, config) {
3127
3155
  }
3128
3156
  function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3129
3157
  const opacityMatch = cls.match(/^opacity-(.+)$/);
3130
- if (opacityMatch && has3(opacity, opacityMatch[1])) {
3158
+ if (opacityMatch && has4(opacity, opacityMatch[1])) {
3131
3159
  return `.${cls} {
3132
3160
  opacity: ${opacity[opacityMatch[1]]};
3133
3161
  transition-property: opacity;
@@ -3136,47 +3164,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3136
3164
  }`;
3137
3165
  }
3138
3166
  const zMatch = cls.match(/^z-(.+)$/);
3139
- if (zMatch && has3(zIndex, zMatch[1])) {
3167
+ if (zMatch && has4(zIndex, zMatch[1])) {
3140
3168
  return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
3141
3169
  }
3142
3170
  const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
3143
3171
  if (shadowMatch) {
3144
3172
  const key = shadowMatch[1] ?? "DEFAULT";
3145
- if (has3(boxShadow, key)) {
3173
+ if (has4(boxShadow, key)) {
3146
3174
  return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
3147
3175
  }
3148
- if (!shadowMatch[1] && has3(boxShadow, "DEFAULT")) {
3176
+ if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
3149
3177
  return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
3150
3178
  }
3151
3179
  }
3152
3180
  const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
3153
3181
  if (roundedMatch) {
3154
3182
  const key = roundedMatch[1] ?? "DEFAULT";
3155
- if (has3(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
3156
- if (!roundedMatch[1] && has3(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
3183
+ if (has4(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
3184
+ if (!roundedMatch[1] && has4(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
3157
3185
  }
3158
3186
  const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
3159
3187
  if (roundedTMatch) {
3160
3188
  const rkey = roundedTMatch[1] ?? "DEFAULT";
3161
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3189
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3162
3190
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
3163
3191
  }
3164
3192
  const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
3165
3193
  if (roundedBMatch) {
3166
3194
  const rkey = roundedBMatch[1] ?? "DEFAULT";
3167
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3195
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3168
3196
  if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3169
3197
  }
3170
3198
  const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
3171
3199
  if (roundedLMatch) {
3172
3200
  const rkey = roundedLMatch[1] ?? "DEFAULT";
3173
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3201
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3174
3202
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
3175
3203
  }
3176
3204
  const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
3177
3205
  if (roundedRMatch) {
3178
3206
  const rkey = roundedRMatch[1] ?? "DEFAULT";
3179
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3207
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3180
3208
  if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3181
3209
  }
3182
3210
  if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
@@ -3230,15 +3258,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3230
3258
  "150": "1.5"
3231
3259
  };
3232
3260
  const scaleMatch = cls.match(/^scale-(\d+)$/);
3233
- if (scaleMatch && has3(scaleMap, scaleMatch[1])) {
3261
+ if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
3234
3262
  return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
3235
3263
  }
3236
3264
  const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
3237
- if (scaleXMatch && has3(scaleMap, scaleXMatch[1])) {
3265
+ if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
3238
3266
  return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
3239
3267
  }
3240
3268
  const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
3241
- if (scaleYMatch && has3(scaleMap, scaleYMatch[1])) {
3269
+ if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
3242
3270
  return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
3243
3271
  }
3244
3272
  const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
@@ -3281,7 +3309,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3281
3309
  "3xl": "64px"
3282
3310
  };
3283
3311
  const key = blurMatch[1] ?? "DEFAULT";
3284
- if (has3(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3312
+ if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3285
3313
  }
3286
3314
  const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
3287
3315
  if (backdropBlurMatch) {
@@ -3296,7 +3324,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3296
3324
  "3xl": "64px"
3297
3325
  };
3298
3326
  const key = backdropBlurMatch[1] ?? "DEFAULT";
3299
- if (has3(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3327
+ if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3300
3328
  }
3301
3329
  const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
3302
3330
  if (arbOpacityMatch) {
@@ -3838,14 +3866,23 @@ var init_src = __esm({
3838
3866
  postcssPlugin: "aliveui",
3839
3867
  async Once(root, { result, postcss }) {
3840
3868
  const classes = await scanContent(config);
3869
+ const hasAliveDirective = root.some((node) => node.type === "atrule" && node.name === "aliveui");
3870
+ if (hasAliveDirective) {
3871
+ const layerDecl = postcss.atRule({ name: "layer", params: "aliveui.base, aliveui.utilities" });
3872
+ root.prepend(layerDecl);
3873
+ }
3841
3874
  root.walkAtRules("aliveui", (atRule) => {
3842
3875
  const param = atRule.params.trim();
3843
3876
  if (param === "base") {
3844
- const css = generateBase(config);
3877
+ const css = `@layer aliveui.base {
3878
+ ${generateBase(config)}
3879
+ }`;
3845
3880
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3846
3881
  atRule.replaceWith(parsed.nodes);
3847
3882
  } else if (param === "utilities") {
3848
- const css = generateUtilities(classes, config);
3883
+ const css = `@layer aliveui.utilities {
3884
+ ${generateUtilities(classes, config)}
3885
+ }`;
3849
3886
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3850
3887
  atRule.replaceWith(parsed.nodes);
3851
3888
  } else {