@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.js CHANGED
@@ -2761,9 +2761,23 @@ var init_typography = __esm({
2761
2761
  });
2762
2762
 
2763
2763
  // src/generator/layout.ts
2764
- function generateLayout(classes, _config) {
2764
+ function has2(obj, key) {
2765
+ return typeof obj[key] === "string";
2766
+ }
2767
+ function generateLayout(classes, config) {
2768
+ const { spacing } = config.theme;
2765
2769
  const rules = [];
2766
2770
  for (const cls of classes) {
2771
+ const spaceYMatch = cls.match(/^space-y-(.+)$/);
2772
+ if (spaceYMatch && has2(spacing, spaceYMatch[1])) {
2773
+ rules.push(`.${escapeSelector(cls)} > * + * { margin-top: ${spacing[spaceYMatch[1]]}; }`);
2774
+ continue;
2775
+ }
2776
+ const spaceXMatch = cls.match(/^space-x-(.+)$/);
2777
+ if (spaceXMatch && has2(spacing, spaceXMatch[1])) {
2778
+ rules.push(`.${escapeSelector(cls)} > * + * { margin-left: ${spacing[spaceXMatch[1]]}; }`);
2779
+ continue;
2780
+ }
2767
2781
  const generated = matchLayout(cls);
2768
2782
  if (generated) rules.push(generated);
2769
2783
  }
@@ -2806,6 +2820,10 @@ function matchLayout(cls) {
2806
2820
  if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
2807
2821
  if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
2808
2822
  if (cls === "flex-shrink-0") return `.${cls} { flex-shrink: 0; }`;
2823
+ if (cls === "grow") return `.${cls} { flex-grow: 1; }`;
2824
+ if (cls === "grow-0") return `.${cls} { flex-grow: 0; }`;
2825
+ if (cls === "shrink") return `.${cls} { flex-shrink: 1; }`;
2826
+ if (cls === "shrink-0") return `.${cls} { flex-shrink: 0; }`;
2809
2827
  if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
2810
2828
  if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
2811
2829
  if (cls === "items-center") return `.${cls} { align-items: center; }`;
@@ -2983,11 +3001,12 @@ function matchLayout(cls) {
2983
3001
  var init_layout = __esm({
2984
3002
  "src/generator/layout.ts"() {
2985
3003
  "use strict";
3004
+ init_utils();
2986
3005
  }
2987
3006
  });
2988
3007
 
2989
3008
  // src/generator/sizing.ts
2990
- function has2(obj, key) {
3009
+ function has3(obj, key) {
2991
3010
  return typeof obj[key] === "string";
2992
3011
  }
2993
3012
  function generateSizing(classes, config) {
@@ -3038,8 +3057,8 @@ function matchSizing(cls, spacing) {
3038
3057
  if (key === "min") return `.${cls} { width: min-content; }`;
3039
3058
  if (key === "max") return `.${cls} { width: max-content; }`;
3040
3059
  if (key === "fit") return `.${cls} { width: fit-content; }`;
3041
- if (has2(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
3042
- if (has2(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
3060
+ if (has3(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
3061
+ if (has3(spacing, key)) return `.${cls} { width: ${spacing[key]}; }`;
3043
3062
  }
3044
3063
  const minWMatch = cls.match(/^min-w-(.+)$/);
3045
3064
  if (minWMatch) {
@@ -3049,7 +3068,7 @@ function matchSizing(cls, spacing) {
3049
3068
  if (key === "min") return `.${cls} { min-width: min-content; }`;
3050
3069
  if (key === "max") return `.${cls} { min-width: max-content; }`;
3051
3070
  if (key === "fit") return `.${cls} { min-width: fit-content; }`;
3052
- if (has2(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3071
+ if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3053
3072
  }
3054
3073
  const maxWMap = {
3055
3074
  none: "none",
@@ -3076,7 +3095,7 @@ function matchSizing(cls, spacing) {
3076
3095
  "screen-2xl": "1536px"
3077
3096
  };
3078
3097
  const maxWMatch = cls.match(/^max-w-(.+)$/);
3079
- if (maxWMatch && has2(maxWMap, maxWMatch[1])) {
3098
+ if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
3080
3099
  return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
3081
3100
  }
3082
3101
  const hMatch = cls.match(/^h-(.+)$/);
@@ -3090,8 +3109,8 @@ function matchSizing(cls, spacing) {
3090
3109
  if (key === "min") return `.${cls} { height: min-content; }`;
3091
3110
  if (key === "max") return `.${cls} { height: max-content; }`;
3092
3111
  if (key === "fit") return `.${cls} { height: fit-content; }`;
3093
- if (has2(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
3094
- if (has2(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
3112
+ if (has3(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
3113
+ if (has3(spacing, key)) return `.${cls} { height: ${spacing[key]}; }`;
3095
3114
  }
3096
3115
  const minHMatch = cls.match(/^min-h-(.+)$/);
3097
3116
  if (minHMatch) {
@@ -3102,7 +3121,7 @@ function matchSizing(cls, spacing) {
3102
3121
  if (key === "svh") return `.${cls} { min-height: 100svh; }`;
3103
3122
  if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
3104
3123
  if (key === "fit") return `.${cls} { min-height: fit-content; }`;
3105
- if (has2(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3124
+ if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3106
3125
  }
3107
3126
  const maxHMatch = cls.match(/^max-h-(.+)$/);
3108
3127
  if (maxHMatch) {
@@ -3113,7 +3132,16 @@ function matchSizing(cls, spacing) {
3113
3132
  if (key === "svh") return `.${cls} { max-height: 100svh; }`;
3114
3133
  if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
3115
3134
  if (key === "fit") return `.${cls} { max-height: fit-content; }`;
3116
- if (has2(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
3135
+ if (has3(spacing, key)) return `.${cls} { max-height: ${spacing[key]}; }`;
3136
+ }
3137
+ const basisMatch = cls.match(/^basis-(.+)$/);
3138
+ if (basisMatch) {
3139
+ const key = basisMatch[1];
3140
+ if (key === "auto") return `.${cls} { flex-basis: auto; }`;
3141
+ if (key === "full") return `.${cls} { flex-basis: 100%; }`;
3142
+ if (key === "0") return `.${cls} { flex-basis: 0px; }`;
3143
+ if (has3(fractions, key)) return `.${cls} { flex-basis: ${fractions[key]}; }`;
3144
+ if (has3(spacing, key)) return `.${cls} { flex-basis: ${spacing[key]}; }`;
3117
3145
  }
3118
3146
  return null;
3119
3147
  }
@@ -3124,7 +3152,7 @@ var init_sizing = __esm({
3124
3152
  });
3125
3153
 
3126
3154
  // src/generator/effects.ts
3127
- function has3(obj, key) {
3155
+ function has4(obj, key) {
3128
3156
  return typeof obj[key] === "string";
3129
3157
  }
3130
3158
  function generateEffects(classes, config) {
@@ -3138,7 +3166,7 @@ function generateEffects(classes, config) {
3138
3166
  }
3139
3167
  function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3140
3168
  const opacityMatch = cls.match(/^opacity-(.+)$/);
3141
- if (opacityMatch && has3(opacity, opacityMatch[1])) {
3169
+ if (opacityMatch && has4(opacity, opacityMatch[1])) {
3142
3170
  return `.${cls} {
3143
3171
  opacity: ${opacity[opacityMatch[1]]};
3144
3172
  transition-property: opacity;
@@ -3147,47 +3175,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3147
3175
  }`;
3148
3176
  }
3149
3177
  const zMatch = cls.match(/^z-(.+)$/);
3150
- if (zMatch && has3(zIndex, zMatch[1])) {
3178
+ if (zMatch && has4(zIndex, zMatch[1])) {
3151
3179
  return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
3152
3180
  }
3153
3181
  const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
3154
3182
  if (shadowMatch) {
3155
3183
  const key = shadowMatch[1] ?? "DEFAULT";
3156
- if (has3(boxShadow, key)) {
3184
+ if (has4(boxShadow, key)) {
3157
3185
  return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
3158
3186
  }
3159
- if (!shadowMatch[1] && has3(boxShadow, "DEFAULT")) {
3187
+ if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
3160
3188
  return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
3161
3189
  }
3162
3190
  }
3163
3191
  const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
3164
3192
  if (roundedMatch) {
3165
3193
  const key = roundedMatch[1] ?? "DEFAULT";
3166
- if (has3(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
3167
- if (!roundedMatch[1] && has3(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
3194
+ if (has4(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
3195
+ if (!roundedMatch[1] && has4(borderRadius, "DEFAULT")) return `.${cls} { border-radius: ${borderRadius["DEFAULT"]}; }`;
3168
3196
  }
3169
3197
  const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
3170
3198
  if (roundedTMatch) {
3171
3199
  const rkey = roundedTMatch[1] ?? "DEFAULT";
3172
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3200
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3173
3201
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
3174
3202
  }
3175
3203
  const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
3176
3204
  if (roundedBMatch) {
3177
3205
  const rkey = roundedBMatch[1] ?? "DEFAULT";
3178
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3206
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3179
3207
  if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3180
3208
  }
3181
3209
  const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
3182
3210
  if (roundedLMatch) {
3183
3211
  const rkey = roundedLMatch[1] ?? "DEFAULT";
3184
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3212
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3185
3213
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
3186
3214
  }
3187
3215
  const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
3188
3216
  if (roundedRMatch) {
3189
3217
  const rkey = roundedRMatch[1] ?? "DEFAULT";
3190
- const val = has3(borderRadius, rkey) ? borderRadius[rkey] : has3(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3218
+ const val = has4(borderRadius, rkey) ? borderRadius[rkey] : has4(borderRadius, "DEFAULT") ? borderRadius["DEFAULT"] : null;
3191
3219
  if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3192
3220
  }
3193
3221
  if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
@@ -3241,15 +3269,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3241
3269
  "150": "1.5"
3242
3270
  };
3243
3271
  const scaleMatch = cls.match(/^scale-(\d+)$/);
3244
- if (scaleMatch && has3(scaleMap, scaleMatch[1])) {
3272
+ if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
3245
3273
  return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
3246
3274
  }
3247
3275
  const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
3248
- if (scaleXMatch && has3(scaleMap, scaleXMatch[1])) {
3276
+ if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
3249
3277
  return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
3250
3278
  }
3251
3279
  const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
3252
- if (scaleYMatch && has3(scaleMap, scaleYMatch[1])) {
3280
+ if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
3253
3281
  return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
3254
3282
  }
3255
3283
  const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
@@ -3292,7 +3320,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3292
3320
  "3xl": "64px"
3293
3321
  };
3294
3322
  const key = blurMatch[1] ?? "DEFAULT";
3295
- if (has3(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3323
+ if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3296
3324
  }
3297
3325
  const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
3298
3326
  if (backdropBlurMatch) {
@@ -3307,7 +3335,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3307
3335
  "3xl": "64px"
3308
3336
  };
3309
3337
  const key = backdropBlurMatch[1] ?? "DEFAULT";
3310
- if (has3(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3338
+ if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3311
3339
  }
3312
3340
  const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
3313
3341
  if (arbOpacityMatch) {
@@ -3849,14 +3877,23 @@ var init_src = __esm({
3849
3877
  postcssPlugin: "aliveui",
3850
3878
  async Once(root, { result, postcss }) {
3851
3879
  const classes = await scanContent(config);
3880
+ const hasAliveDirective = root.some((node) => node.type === "atrule" && node.name === "aliveui");
3881
+ if (hasAliveDirective) {
3882
+ const layerDecl = postcss.atRule({ name: "layer", params: "aliveui.base, aliveui.utilities" });
3883
+ root.prepend(layerDecl);
3884
+ }
3852
3885
  root.walkAtRules("aliveui", (atRule) => {
3853
3886
  const param = atRule.params.trim();
3854
3887
  if (param === "base") {
3855
- const css = generateBase(config);
3888
+ const css = `@layer aliveui.base {
3889
+ ${generateBase(config)}
3890
+ }`;
3856
3891
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3857
3892
  atRule.replaceWith(parsed.nodes);
3858
3893
  } else if (param === "utilities") {
3859
- const css = generateUtilities(classes, config);
3894
+ const css = `@layer aliveui.utilities {
3895
+ ${generateUtilities(classes, config)}
3896
+ }`;
3860
3897
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3861
3898
  atRule.replaceWith(parsed.nodes);
3862
3899
  } else {