@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/dist/vite.mjs CHANGED
@@ -601,6 +601,42 @@ function generateBase(_config) {
601
601
  box-sizing: border-box;
602
602
  }
603
603
 
604
+ html {
605
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
606
+ "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
607
+ "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
608
+ line-height: 1.5;
609
+ -webkit-text-size-adjust: 100%;
610
+ -moz-tab-size: 4;
611
+ tab-size: 4;
612
+ }
613
+
614
+ body {
615
+ margin: 0;
616
+ line-height: inherit;
617
+ -webkit-font-smoothing: antialiased;
618
+ -moz-osx-font-smoothing: grayscale;
619
+ }
620
+
621
+ button,
622
+ input,
623
+ optgroup,
624
+ select,
625
+ textarea {
626
+ font-family: inherit;
627
+ font-size: 100%;
628
+ font-weight: inherit;
629
+ line-height: inherit;
630
+ color: inherit;
631
+ margin: 0;
632
+ padding: 0;
633
+ }
634
+
635
+ button,
636
+ select {
637
+ text-transform: none;
638
+ }
639
+
604
640
  /* \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 */
605
641
  :root {
606
642
  /* Motion durations */
@@ -2714,9 +2750,23 @@ var init_typography = __esm({
2714
2750
  });
2715
2751
 
2716
2752
  // src/generator/layout.ts
2717
- 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;
2718
2758
  const rules = [];
2719
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
+ }
2720
2770
  const generated = matchLayout(cls);
2721
2771
  if (generated) rules.push(generated);
2722
2772
  }
@@ -2759,6 +2809,10 @@ function matchLayout(cls) {
2759
2809
  if (cls === "flex-grow-0") return `.${cls} { flex-grow: 0; }`;
2760
2810
  if (cls === "flex-shrink") return `.${cls} { flex-shrink: 1; }`;
2761
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; }`;
2762
2816
  if (cls === "items-start") return `.${cls} { align-items: flex-start; }`;
2763
2817
  if (cls === "items-end") return `.${cls} { align-items: flex-end; }`;
2764
2818
  if (cls === "items-center") return `.${cls} { align-items: center; }`;
@@ -2936,11 +2990,12 @@ function matchLayout(cls) {
2936
2990
  var init_layout = __esm({
2937
2991
  "src/generator/layout.ts"() {
2938
2992
  "use strict";
2993
+ init_utils();
2939
2994
  }
2940
2995
  });
2941
2996
 
2942
2997
  // src/generator/sizing.ts
2943
- function has2(obj, key) {
2998
+ function has3(obj, key) {
2944
2999
  return typeof obj[key] === "string";
2945
3000
  }
2946
3001
  function generateSizing(classes, config) {
@@ -2991,8 +3046,8 @@ function matchSizing(cls, spacing) {
2991
3046
  if (key === "min") return `.${cls} { width: min-content; }`;
2992
3047
  if (key === "max") return `.${cls} { width: max-content; }`;
2993
3048
  if (key === "fit") return `.${cls} { width: fit-content; }`;
2994
- if (has2(fractions, key)) return `.${cls} { width: ${fractions[key]}; }`;
2995
- 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]}; }`;
2996
3051
  }
2997
3052
  const minWMatch = cls.match(/^min-w-(.+)$/);
2998
3053
  if (minWMatch) {
@@ -3002,7 +3057,7 @@ function matchSizing(cls, spacing) {
3002
3057
  if (key === "min") return `.${cls} { min-width: min-content; }`;
3003
3058
  if (key === "max") return `.${cls} { min-width: max-content; }`;
3004
3059
  if (key === "fit") return `.${cls} { min-width: fit-content; }`;
3005
- if (has2(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3060
+ if (has3(spacing, key)) return `.${cls} { min-width: ${spacing[key]}; }`;
3006
3061
  }
3007
3062
  const maxWMap = {
3008
3063
  none: "none",
@@ -3029,7 +3084,7 @@ function matchSizing(cls, spacing) {
3029
3084
  "screen-2xl": "1536px"
3030
3085
  };
3031
3086
  const maxWMatch = cls.match(/^max-w-(.+)$/);
3032
- if (maxWMatch && has2(maxWMap, maxWMatch[1])) {
3087
+ if (maxWMatch && has3(maxWMap, maxWMatch[1])) {
3033
3088
  return `.${cls} { max-width: ${maxWMap[maxWMatch[1]]}; }`;
3034
3089
  }
3035
3090
  const hMatch = cls.match(/^h-(.+)$/);
@@ -3043,8 +3098,8 @@ function matchSizing(cls, spacing) {
3043
3098
  if (key === "min") return `.${cls} { height: min-content; }`;
3044
3099
  if (key === "max") return `.${cls} { height: max-content; }`;
3045
3100
  if (key === "fit") return `.${cls} { height: fit-content; }`;
3046
- if (has2(fractions, key)) return `.${cls} { height: ${fractions[key]}; }`;
3047
- 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]}; }`;
3048
3103
  }
3049
3104
  const minHMatch = cls.match(/^min-h-(.+)$/);
3050
3105
  if (minHMatch) {
@@ -3055,7 +3110,7 @@ function matchSizing(cls, spacing) {
3055
3110
  if (key === "svh") return `.${cls} { min-height: 100svh; }`;
3056
3111
  if (key === "dvh") return `.${cls} { min-height: 100dvh; }`;
3057
3112
  if (key === "fit") return `.${cls} { min-height: fit-content; }`;
3058
- if (has2(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3113
+ if (has3(spacing, key)) return `.${cls} { min-height: ${spacing[key]}; }`;
3059
3114
  }
3060
3115
  const maxHMatch = cls.match(/^max-h-(.+)$/);
3061
3116
  if (maxHMatch) {
@@ -3066,7 +3121,16 @@ function matchSizing(cls, spacing) {
3066
3121
  if (key === "svh") return `.${cls} { max-height: 100svh; }`;
3067
3122
  if (key === "dvh") return `.${cls} { max-height: 100dvh; }`;
3068
3123
  if (key === "fit") return `.${cls} { max-height: fit-content; }`;
3069
- 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]}; }`;
3070
3134
  }
3071
3135
  return null;
3072
3136
  }
@@ -3077,7 +3141,7 @@ var init_sizing = __esm({
3077
3141
  });
3078
3142
 
3079
3143
  // src/generator/effects.ts
3080
- function has3(obj, key) {
3144
+ function has4(obj, key) {
3081
3145
  return typeof obj[key] === "string";
3082
3146
  }
3083
3147
  function generateEffects(classes, config) {
@@ -3091,7 +3155,7 @@ function generateEffects(classes, config) {
3091
3155
  }
3092
3156
  function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3093
3157
  const opacityMatch = cls.match(/^opacity-(.+)$/);
3094
- if (opacityMatch && has3(opacity, opacityMatch[1])) {
3158
+ if (opacityMatch && has4(opacity, opacityMatch[1])) {
3095
3159
  return `.${cls} {
3096
3160
  opacity: ${opacity[opacityMatch[1]]};
3097
3161
  transition-property: opacity;
@@ -3100,47 +3164,47 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3100
3164
  }`;
3101
3165
  }
3102
3166
  const zMatch = cls.match(/^z-(.+)$/);
3103
- if (zMatch && has3(zIndex, zMatch[1])) {
3167
+ if (zMatch && has4(zIndex, zMatch[1])) {
3104
3168
  return `.${cls} { z-index: ${zIndex[zMatch[1]]}; }`;
3105
3169
  }
3106
3170
  const shadowMatch = cls.match(/^shadow(?:-(.+))?$/);
3107
3171
  if (shadowMatch) {
3108
3172
  const key = shadowMatch[1] ?? "DEFAULT";
3109
- if (has3(boxShadow, key)) {
3173
+ if (has4(boxShadow, key)) {
3110
3174
  return `.${cls} { box-shadow: ${boxShadow[key]}; }`;
3111
3175
  }
3112
- if (!shadowMatch[1] && has3(boxShadow, "DEFAULT")) {
3176
+ if (!shadowMatch[1] && has4(boxShadow, "DEFAULT")) {
3113
3177
  return `.${cls} { box-shadow: ${boxShadow["DEFAULT"]}; }`;
3114
3178
  }
3115
3179
  }
3116
3180
  const roundedMatch = cls.match(/^rounded(?:-(.+))?$/);
3117
3181
  if (roundedMatch) {
3118
3182
  const key = roundedMatch[1] ?? "DEFAULT";
3119
- if (has3(borderRadius, key)) return `.${cls} { border-radius: ${borderRadius[key]}; }`;
3120
- 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"]}; }`;
3121
3185
  }
3122
3186
  const roundedTMatch = cls.match(/^rounded-t(?:-(.+))?$/);
3123
3187
  if (roundedTMatch) {
3124
3188
  const rkey = roundedTMatch[1] ?? "DEFAULT";
3125
- 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;
3126
3190
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-top-right-radius: ${val}; }`;
3127
3191
  }
3128
3192
  const roundedBMatch = cls.match(/^rounded-b(?:-(.+))?$/);
3129
3193
  if (roundedBMatch) {
3130
3194
  const rkey = roundedBMatch[1] ?? "DEFAULT";
3131
- 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;
3132
3196
  if (val) return `.${cls} { border-bottom-left-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3133
3197
  }
3134
3198
  const roundedLMatch = cls.match(/^rounded-l(?:-(.+))?$/);
3135
3199
  if (roundedLMatch) {
3136
3200
  const rkey = roundedLMatch[1] ?? "DEFAULT";
3137
- 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;
3138
3202
  if (val) return `.${cls} { border-top-left-radius: ${val}; border-bottom-left-radius: ${val}; }`;
3139
3203
  }
3140
3204
  const roundedRMatch = cls.match(/^rounded-r(?:-(.+))?$/);
3141
3205
  if (roundedRMatch) {
3142
3206
  const rkey = roundedRMatch[1] ?? "DEFAULT";
3143
- 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;
3144
3208
  if (val) return `.${cls} { border-top-right-radius: ${val}; border-bottom-right-radius: ${val}; }`;
3145
3209
  }
3146
3210
  if (cls === "border") return `.${cls} { border-width: 1px; border-style: solid; }`;
@@ -3194,15 +3258,15 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3194
3258
  "150": "1.5"
3195
3259
  };
3196
3260
  const scaleMatch = cls.match(/^scale-(\d+)$/);
3197
- if (scaleMatch && has3(scaleMap, scaleMatch[1])) {
3261
+ if (scaleMatch && has4(scaleMap, scaleMatch[1])) {
3198
3262
  return `.${cls} { transform: scale(${scaleMap[scaleMatch[1]]}); }`;
3199
3263
  }
3200
3264
  const scaleXMatch = cls.match(/^scale-x-(\d+)$/);
3201
- if (scaleXMatch && has3(scaleMap, scaleXMatch[1])) {
3265
+ if (scaleXMatch && has4(scaleMap, scaleXMatch[1])) {
3202
3266
  return `.${cls} { transform: scaleX(${scaleMap[scaleXMatch[1]]}); }`;
3203
3267
  }
3204
3268
  const scaleYMatch = cls.match(/^scale-y-(\d+)$/);
3205
- if (scaleYMatch && has3(scaleMap, scaleYMatch[1])) {
3269
+ if (scaleYMatch && has4(scaleMap, scaleYMatch[1])) {
3206
3270
  return `.${cls} { transform: scaleY(${scaleMap[scaleYMatch[1]]}); }`;
3207
3271
  }
3208
3272
  const rotateMatch = cls.match(/^-?rotate-(\d+)$/);
@@ -3245,7 +3309,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3245
3309
  "3xl": "64px"
3246
3310
  };
3247
3311
  const key = blurMatch[1] ?? "DEFAULT";
3248
- if (has3(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3312
+ if (has4(blurMap, key)) return `.${cls} { filter: blur(${blurMap[key]}); }`;
3249
3313
  }
3250
3314
  const backdropBlurMatch = cls.match(/^backdrop-blur(?:-(.+))?$/);
3251
3315
  if (backdropBlurMatch) {
@@ -3260,7 +3324,7 @@ function matchEffects(cls, opacity, zIndex, boxShadow, borderRadius) {
3260
3324
  "3xl": "64px"
3261
3325
  };
3262
3326
  const key = backdropBlurMatch[1] ?? "DEFAULT";
3263
- if (has3(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3327
+ if (has4(blurMap, key)) return `.${cls} { backdrop-filter: blur(${blurMap[key]}); }`;
3264
3328
  }
3265
3329
  const arbOpacityMatch = cls.match(/^opacity-\[(.+)\]$/);
3266
3330
  if (arbOpacityMatch) {
@@ -3802,14 +3866,23 @@ var init_src = __esm({
3802
3866
  postcssPlugin: "aliveui",
3803
3867
  async Once(root, { result, postcss }) {
3804
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
+ }
3805
3874
  root.walkAtRules("aliveui", (atRule) => {
3806
3875
  const param = atRule.params.trim();
3807
3876
  if (param === "base") {
3808
- const css = generateBase(config);
3877
+ const css = `@layer aliveui.base {
3878
+ ${generateBase(config)}
3879
+ }`;
3809
3880
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3810
3881
  atRule.replaceWith(parsed.nodes);
3811
3882
  } else if (param === "utilities") {
3812
- const css = generateUtilities(classes, config);
3883
+ const css = `@layer aliveui.utilities {
3884
+ ${generateUtilities(classes, config)}
3885
+ }`;
3813
3886
  const parsed = postcss.parse(css, { from: atRule.source?.input.file });
3814
3887
  atRule.replaceWith(parsed.nodes);
3815
3888
  } else {