@kbach/react 1.0.0-beta.2 → 1.0.0-beta.21

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/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.21",
4
4
  "description": "A utility-first styling engine for React, powered by a real Rust/WASM core — Tailwind CSS v4 feature parity with Kbach's own color palette.",
5
- "keywords": ["css", "react", "tailwind", "utility-first", "wasm", "styling"],
5
+ "keywords": [
6
+ "css",
7
+ "react",
8
+ "tailwind",
9
+ "utility-first",
10
+ "wasm",
11
+ "styling"
12
+ ],
6
13
  "license": "MIT",
7
14
  "author": "semsakadanupol",
8
15
  "repository": {
@@ -17,7 +24,9 @@
17
24
  "publishConfig": {
18
25
  "access": "public"
19
26
  },
20
- "files": ["dist"],
27
+ "files": [
28
+ "dist"
29
+ ],
21
30
  "source": "./src/index.ts",
22
31
  "main": "./dist/index.js",
23
32
  "module": "./dist/index.mjs",
@@ -46,31 +55,44 @@
46
55
  "source": "./src/vite-plugin/index.ts",
47
56
  "import": "./dist/vite-plugin.mjs",
48
57
  "require": "./dist/vite-plugin.js"
58
+ },
59
+ "./postcss": {
60
+ "types": "./dist/postcss-plugin.d.ts",
61
+ "source": "./src/postcss-plugin/index.ts",
62
+ "import": "./dist/postcss-plugin.mjs",
63
+ "require": "./dist/postcss-plugin.js"
49
64
  }
50
65
  },
51
66
  "scripts": {
52
67
  "build": "tsup",
53
68
  "dev": "tsup --watch",
54
69
  "test": "vitest run --passWithNoTests",
70
+ "test:coverage": "vitest run --coverage --passWithNoTests",
55
71
  "lint": "tsc --noEmit",
56
72
  "generate:colors": "node ../core-engine/scripts/generate-palette.mjs src/generatedPalette.ts"
57
73
  },
58
74
  "dependencies": {
59
- "@kbach/core-engine": "1.0.0-beta.3"
75
+ "@kbach/core-engine": "1.0.0-beta.12"
60
76
  },
61
77
  "devDependencies": {
62
78
  "@types/react": "^19.2.0",
79
+ "@vitest/coverage-v8": "^1.6.1",
63
80
  "jsdom": "^30.0.1",
81
+ "postcss": "^8.4.0",
64
82
  "tsup": "^8.0.0",
65
83
  "typescript": "^6.0.0",
66
84
  "vite": "^5.4.21",
67
85
  "vitest": "^1.0.0"
68
86
  },
69
87
  "peerDependencies": {
88
+ "postcss": "^8.0.0",
70
89
  "react": ">=18.0.0",
71
90
  "vite": ">=4.0.0"
72
91
  },
73
92
  "peerDependenciesMeta": {
93
+ "postcss": {
94
+ "optional": true
95
+ },
74
96
  "vite": {
75
97
  "optional": true
76
98
  }
@@ -1,115 +0,0 @@
1
- import {
2
- defaultTheme,
3
- setTheme
4
- } from "./chunk-N5HCQIBB.mjs";
5
-
6
- // src/colorVariables.ts
7
- function parseHexRgb(hex) {
8
- const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
9
- if (!m) return null;
10
- let h = m[1];
11
- if (h.length === 3) h = h.split("").map((c) => c + c).join("");
12
- const n = parseInt(h, 16);
13
- return [n >> 16 & 255, n >> 8 & 255, n & 255];
14
- }
15
- function wrapDarkDecls(strategy, decls) {
16
- switch (strategy) {
17
- case "class":
18
- return `.dark { ${decls} }`;
19
- case "media":
20
- return `@media (prefers-color-scheme: dark) { :root { ${decls} } }`;
21
- case "attribute":
22
- default:
23
- return `[data-theme="dark"] { ${decls} }`;
24
- }
25
- }
26
- var STYLE_ID = "kbach-colors";
27
- var injectedForTheme = null;
28
- function ensureColorVariablesInjected(theme) {
29
- if (typeof document === "undefined") return;
30
- if (injectedForTheme === theme) return;
31
- injectedForTheme = theme;
32
- const lightDecls = [];
33
- const darkDecls = [];
34
- for (const [name, value] of Object.entries(theme.colors)) {
35
- if (typeof value === "string") continue;
36
- const light = parseHexRgb(value.light);
37
- const dark = parseHexRgb(value.dark);
38
- if (!light || !dark) continue;
39
- lightDecls.push(`--kb-color-${name}: ${light.join(",")};`);
40
- darkDecls.push(`--kb-color-${name}: ${dark.join(",")};`);
41
- }
42
- let el = document.getElementById(STYLE_ID);
43
- if (lightDecls.length === 0) {
44
- el?.remove();
45
- return;
46
- }
47
- if (!el) {
48
- el = document.createElement("style");
49
- el.id = STYLE_ID;
50
- document.head.insertBefore(el, document.head.firstChild);
51
- }
52
- el.textContent = `:root { ${lightDecls.join(" ")} }
53
- ${wrapDarkDecls(theme.darkMode, darkDecls.join(" "))}`;
54
- }
55
-
56
- // src/config.ts
57
- function applyOpacityToHex(hex, opacityText) {
58
- const rgb = parseHexRgb(hex);
59
- if (!rgb) return hex;
60
- const a = Number(opacityText) / 100;
61
- const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
62
- return `rgba(${rgb.join(",")},${clamped})`;
63
- }
64
- function resolveColorEntry(value, lookup) {
65
- if (typeof value !== "string") return value;
66
- const slash = value.indexOf("/");
67
- const name = slash === -1 ? value : value.slice(0, slash);
68
- const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
69
- const base = lookup(name);
70
- if (base === void 0) return value;
71
- if (opacity === void 0) return base;
72
- return typeof base === "string" ? applyOpacityToHex(base, opacity) : { light: applyOpacityToHex(base.light, opacity), dark: applyOpacityToHex(base.dark, opacity) };
73
- }
74
- function resolveColors(extend, existing) {
75
- const resolved = {};
76
- const lookup = (name) => resolved[name] ?? existing[name];
77
- for (const [name, value] of Object.entries(extend)) {
78
- resolved[name] = resolveColorEntry(value, lookup);
79
- }
80
- return resolved;
81
- }
82
- function resolveKbachConfig(config) {
83
- let theme = { ...defaultTheme, ...config.theme };
84
- if (config.extend?.colors) {
85
- theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
86
- }
87
- if (config.extend?.spacing) {
88
- theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
89
- }
90
- if (config.extend?.screens) {
91
- theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
92
- }
93
- if (config.extend?.fontFamily) {
94
- theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
95
- }
96
- if (config.extend?.container) {
97
- theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
98
- }
99
- if (config.darkMode) {
100
- theme = { ...theme, darkMode: config.darkMode };
101
- }
102
- return theme;
103
- }
104
- function applyKbachConfig(config) {
105
- const theme = resolveKbachConfig(config);
106
- setTheme(theme);
107
- return theme;
108
- }
109
-
110
- export {
111
- parseHexRgb,
112
- ensureColorVariablesInjected,
113
- resolveKbachConfig,
114
- applyKbachConfig
115
- };