@cwcss/crosswind 0.1.6 → 0.2.0

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/rules.d.ts CHANGED
@@ -36,4 +36,4 @@ export declare const borderSideWidthRule: UtilityRule;
36
36
  export declare const borderRadiusRule: UtilityRule;
37
37
  // Export all rules (order matters - more specific rules first)
38
38
  export declare const builtInRules: UtilityRule[];
39
- export type UtilityRule = (parsed: ParsedClass, config: CrosswindConfig) => Record<string, string> | UtilityRuleResult | undefined
39
+ export type UtilityRule = (_parsed: ParsedClass, _config: CrosswindConfig) => Record<string, string> | UtilityRuleResult | undefined
@@ -41,6 +41,24 @@ var CSS_UNITS_REGEX = /^\d+(\.\d+)?(px|rem|em|vh|vw|dvh|dvw|svh|svw|lvh|lvw|ch|e
41
41
  function needsArbitraryBrackets(value) {
42
42
  return SPECIAL_CHARS_REGEX.test(value) || CSS_UNITS_REGEX.test(value);
43
43
  }
44
+ function convertArbitraryUnderscores(value) {
45
+ if (!value.includes("_"))
46
+ return value;
47
+ if (value.includes("(")) {
48
+ let result = "";
49
+ let depth = 0;
50
+ for (let i = 0;i < value.length; i++) {
51
+ const ch = value[i];
52
+ if (ch === "(")
53
+ depth++;
54
+ else if (ch === ")")
55
+ depth--;
56
+ result += ch === "_" && depth === 0 ? " " : ch;
57
+ }
58
+ return result;
59
+ }
60
+ return value.replace(/_/g, " ");
61
+ }
44
62
  function handleMinMaxPattern(prefix, parts) {
45
63
  if (parts.length !== 2)
46
64
  return null;
@@ -820,7 +838,7 @@ function parseClassImpl(className) {
820
838
  if (preArbitraryMatch) {
821
839
  const variantPart = preArbitraryMatch[1];
822
840
  const variants2 = variantPart ? variantPart.split(":").filter(Boolean) : [];
823
- let value = preArbitraryMatch[3];
841
+ let value = convertArbitraryUnderscores(preArbitraryMatch[3]);
824
842
  let typeHint;
825
843
  const typeHintMatch = value.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);
826
844
  if (typeHintMatch) {
@@ -870,7 +888,7 @@ function parseClassImpl(className) {
870
888
  }
871
889
  const arbitraryMatch = utility.match(/^([a-z-]+?)-\[(.+?)\]$/);
872
890
  if (arbitraryMatch) {
873
- let value = arbitraryMatch[2];
891
+ let value = convertArbitraryUnderscores(arbitraryMatch[2]);
874
892
  let typeHint;
875
893
  const typeHintMatch = value.match(/^(color|length|url|number|percentage|position|line-width|absolute-size|relative-size|image|angle|time|flex|string|family-name):(.*)/i);
876
894
  if (typeHintMatch) {
@@ -1065,7 +1083,7 @@ function parseClassImpl(className) {
1065
1083
  arbitrary: false
1066
1084
  };
1067
1085
  }
1068
- const opacityMatch = utility.match(/^([a-z]+(?:-[a-z]+)*?)-(.+?)\/(\d+)$/);
1086
+ const opacityMatch = utility.match(/^([a-z]+(?:-[a-z]+)*?)-(.+?)\/(\d+|\[\d*\.?\d+\])$/);
1069
1087
  if (opacityMatch && ["bg", "text", "border", "ring", "placeholder", "divide"].includes(opacityMatch[1])) {
1070
1088
  return {
1071
1089
  raw: className,
@@ -1839,10 +1857,18 @@ var shadowColorRule = (parsed, config) => {
1839
1857
  let opacity;
1840
1858
  if (slashIdx !== -1) {
1841
1859
  colorName = value.slice(0, slashIdx);
1842
- const opacityValue = Number.parseInt(value.slice(slashIdx + 1), 10);
1843
- if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100)
1844
- return;
1845
- opacity = opacityValue / 100;
1860
+ const opacityStr = value.slice(slashIdx + 1);
1861
+ if (opacityStr.charCodeAt(0) === 91 && opacityStr.charCodeAt(opacityStr.length - 1) === 93) {
1862
+ const arbitraryOpacity = Number.parseFloat(opacityStr.slice(1, -1));
1863
+ if (Number.isNaN(arbitraryOpacity) || arbitraryOpacity < 0 || arbitraryOpacity > 1)
1864
+ return;
1865
+ opacity = arbitraryOpacity;
1866
+ } else {
1867
+ const opacityValue = Number.parseInt(opacityStr, 10);
1868
+ if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100)
1869
+ return;
1870
+ opacity = opacityValue / 100;
1871
+ }
1846
1872
  } else {
1847
1873
  colorName = value;
1848
1874
  }
@@ -4183,11 +4209,20 @@ var colorRule = (parsed, config) => {
4183
4209
  let colorValue = value;
4184
4210
  if (slashIdx !== -1) {
4185
4211
  colorValue = value.slice(0, slashIdx);
4186
- const opacityValue = Number.parseInt(value.slice(slashIdx + 1), 10);
4187
- if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100) {
4188
- return;
4212
+ const opacityStr = value.slice(slashIdx + 1);
4213
+ if (opacityStr.charCodeAt(0) === 91 && opacityStr.charCodeAt(opacityStr.length - 1) === 93) {
4214
+ const arbitraryOpacity = Number.parseFloat(opacityStr.slice(1, -1));
4215
+ if (Number.isNaN(arbitraryOpacity) || arbitraryOpacity < 0 || arbitraryOpacity > 1) {
4216
+ return;
4217
+ }
4218
+ opacity = arbitraryOpacity;
4219
+ } else {
4220
+ const opacityValue = Number.parseInt(opacityStr, 10);
4221
+ if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100) {
4222
+ return;
4223
+ }
4224
+ opacity = opacityValue / 100;
4189
4225
  }
4190
- opacity = opacityValue / 100;
4191
4226
  const baseColor = flatColorCache.get(colorValue);
4192
4227
  if (baseColor) {
4193
4228
  return { [prop]: applyOpacity(baseColor, opacity) };
@@ -4258,10 +4293,19 @@ var placeholderColorRule = (parsed, config) => {
4258
4293
  }
4259
4294
  } else {
4260
4295
  const colorValue = value.slice(0, slashIdx);
4261
- const opacityValue = Number.parseInt(value.slice(slashIdx + 1), 10);
4262
- if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100)
4263
- return;
4264
- const opacity = opacityValue / 100;
4296
+ const opacityStr = value.slice(slashIdx + 1);
4297
+ let opacity;
4298
+ if (opacityStr.charCodeAt(0) === 91 && opacityStr.charCodeAt(opacityStr.length - 1) === 93) {
4299
+ const arbitraryOpacity = Number.parseFloat(opacityStr.slice(1, -1));
4300
+ if (Number.isNaN(arbitraryOpacity) || arbitraryOpacity < 0 || arbitraryOpacity > 1)
4301
+ return;
4302
+ opacity = arbitraryOpacity;
4303
+ } else {
4304
+ const opacityValue = Number.parseInt(opacityStr, 10);
4305
+ if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100)
4306
+ return;
4307
+ opacity = opacityValue / 100;
4308
+ }
4265
4309
  const baseColor = flatColorCache.get(colorValue);
4266
4310
  if (baseColor) {
4267
4311
  return {
@@ -4288,6 +4332,9 @@ var fontSizeRule = (parsed, config) => {
4288
4332
  }
4289
4333
  return { "font-size": parsed.value };
4290
4334
  }
4335
+ if (/^#|^rgb|^hsl|^hwb|^lab|^lch|^oklch|^oklab|^color\(|^var\(--/.test(parsed.value)) {
4336
+ return;
4337
+ }
4291
4338
  return { "font-size": parsed.value };
4292
4339
  }
4293
4340
  const fontSize = config.theme.fontSize[parsed.value];
@@ -4424,6 +4471,9 @@ var borderSideWidthRule = (parsed) => {
4424
4471
  };
4425
4472
  var borderRadiusRule = (parsed, config) => {
4426
4473
  if (parsed.utility === "rounded") {
4474
+ if (parsed.arbitrary && parsed.value) {
4475
+ return { "border-radius": parsed.value };
4476
+ }
4427
4477
  const value = parsed.value ? config.theme.borderRadius[parsed.value] : config.theme.borderRadius.DEFAULT;
4428
4478
  return value ? { "border-radius": value } : undefined;
4429
4479
  }
package/dist/types.d.ts CHANGED
@@ -121,7 +121,7 @@ export declare interface Preset {
121
121
  variants?: Partial<VariantConfig>
122
122
  preflights?: Preflight[]
123
123
  }
124
- export type CustomRule = [RegExp, (match: RegExpMatchArray) => Record<string, string> | undefined]
124
+ export type CustomRule = [RegExp, (_match: RegExpMatchArray) => Record<string, string> | undefined]
125
125
  declare type DeepPartial<T> = {
126
126
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
127
127
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cwcss/crosswind",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.2.0",
5
5
  "description": "A performant Utility-First CSS framework. Similar to Tailwind or UnoCSS.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "module": "./dist/index.js",
38
38
  "types": "./dist/index.d.ts",
39
39
  "bin": {
40
- "crosswind": "./dist/bin/cli.js"
40
+ "crosswind": "./dist/cli.js"
41
41
  },
42
42
  "files": [
43
43
  "README.md",
@@ -72,21 +72,7 @@
72
72
  "@stacksjs/clapp": "^0.2.0",
73
73
  "bunfig": "^0.15.0"
74
74
  },
75
- "overrides": {
76
- "unconfig": "0.3.10"
77
- },
78
75
  "lint-staged": {
79
76
  "*.{js,ts}": "bunx --bun pickier run --mode lint --fix"
80
- },
81
- "devDependencies": {
82
- "@tailwindcss/node": "^4.1.14",
83
- "@tailwindcss/postcss": "^4.1",
84
- "@tailwindcss/vite": "^4.1",
85
- "@unocss/core": "^66.5.4",
86
- "@unocss/preset-wind": "^66.5.4",
87
- "mitata": "^1.0.34",
88
- "postcss": "^8.5.6",
89
- "tailwindcss": "^3",
90
- "tailwindcss-v4": "npm:tailwindcss@^4"
91
77
  }
92
78
  }