@hulla/style 0.0.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.
@@ -0,0 +1,36 @@
1
+ type Variants = Record<string, string>;
2
+ type Compose = <const CS extends any[] = ClassName[]>(...classes: CS) => string;
3
+ type Fn = (...args: any[]) => any;
4
+ type ClassName = string | null | undefined | false | 0 | 0n | typeof NaN;
5
+ type Config<V extends Variants, DV extends keyof V, B extends string, C extends Compose> = {
6
+ variants?: V;
7
+ defaultVariant?: DV;
8
+ base?: B;
9
+ compose?: C;
10
+ transform?: Transform;
11
+ };
12
+ type Props<V extends Variants> = {
13
+ variant?: keyof V;
14
+ class?: string;
15
+ className?: string;
16
+ "class:list"?: string[];
17
+ };
18
+ type Incorrect<S extends string = "[@hulla/style]: Invalid style configuration passed. Refer to https://hulla.dev/docs/style for help"> = S;
19
+ type VariantProps<S> = S extends Fn ? Parameters<S>[0] extends Props<infer V> ? {
20
+ variant?: keyof V;
21
+ } : Incorrect : Incorrect;
22
+ type Variant<S> = S extends Fn ? (Parameters<S>[0] extends Props<infer V> ? keyof V : Incorrect) : Incorrect;
23
+ type Transform = (css: string) => string;
24
+ type Setup<C extends Compose> = {
25
+ compose?: C;
26
+ transform?: (css: string) => string;
27
+ };
28
+ type StyleFunctions = {
29
+ cn: Compose;
30
+ vn: <V extends Variants, DV extends keyof V, B extends string>(config: Config<V, DV, B, Compose>) => (props: Props<V>) => string;
31
+ };
32
+
33
+ declare function style(): StyleFunctions;
34
+ declare function style<C extends Compose>(setup: Setup<C>): StyleFunctions;
35
+
36
+ export { type ClassName, type Compose, type Config, type Props, type Setup, type StyleFunctions, type Transform, type Variant, type VariantProps, type Variants, style };
@@ -0,0 +1 @@
1
+ function t(...a){let r=[];for(let t of a.filter(Boolean))for(let a of t.split(" "))r.push(a);return Array.from(new Set(r).values()).join(" ")}exports.style=function(a){let{compose:r=t,transform:e}=a??{};return{vn:t=>a=>{let n=a.variant?t.variants?.[a.variant]:t.defaultVariant?t.variants?.[t.defaultVariant]:void 0,s=[a.class,a.className,...a["class:list"]??[]],l=(t.compose??r)(t.base,n,...s),o=e??t.transform;return o?o(l):l},cn:e?(...t)=>e(r(...t)):r}};
@@ -0,0 +1,36 @@
1
+ type Variants = Record<string, string>;
2
+ type Compose = <const CS extends any[] = ClassName[]>(...classes: CS) => string;
3
+ type Fn = (...args: any[]) => any;
4
+ type ClassName = string | null | undefined | false | 0 | 0n | typeof NaN;
5
+ type Config<V extends Variants, DV extends keyof V, B extends string, C extends Compose> = {
6
+ variants?: V;
7
+ defaultVariant?: DV;
8
+ base?: B;
9
+ compose?: C;
10
+ transform?: Transform;
11
+ };
12
+ type Props<V extends Variants> = {
13
+ variant?: keyof V;
14
+ class?: string;
15
+ className?: string;
16
+ "class:list"?: string[];
17
+ };
18
+ type Incorrect<S extends string = "[@hulla/style]: Invalid style configuration passed. Refer to https://hulla.dev/docs/style for help"> = S;
19
+ type VariantProps<S> = S extends Fn ? Parameters<S>[0] extends Props<infer V> ? {
20
+ variant?: keyof V;
21
+ } : Incorrect : Incorrect;
22
+ type Variant<S> = S extends Fn ? (Parameters<S>[0] extends Props<infer V> ? keyof V : Incorrect) : Incorrect;
23
+ type Transform = (css: string) => string;
24
+ type Setup<C extends Compose> = {
25
+ compose?: C;
26
+ transform?: (css: string) => string;
27
+ };
28
+ type StyleFunctions = {
29
+ cn: Compose;
30
+ vn: <V extends Variants, DV extends keyof V, B extends string>(config: Config<V, DV, B, Compose>) => (props: Props<V>) => string;
31
+ };
32
+
33
+ declare function style(): StyleFunctions;
34
+ declare function style<C extends Compose>(setup: Setup<C>): StyleFunctions;
35
+
36
+ export { type ClassName, type Compose, type Config, type Props, type Setup, type StyleFunctions, type Transform, type Variant, type VariantProps, type Variants, style };
@@ -0,0 +1 @@
1
+ function t(...a){let r=[];for(let t of a.filter(Boolean))for(let a of t.split(" "))r.push(a);return Array.from(new Set(r).values()).join(" ")}function a(a){let{compose:r=t,transform:e}=a??{};return{vn:t=>a=>{let n=a.variant?t.variants?.[a.variant]:t.defaultVariant?t.variants?.[t.defaultVariant]:void 0,l=[a.class,a.className,...a["class:list"]??[]],s=(t.compose??r)(t.base,n,...l),o=e??t.transform;return o?o(s):s},cn:e?(...t)=>e(r(...t)):r}}export{a as style};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@hulla/style",
3
+ "version": "0.0.0",
4
+ "description": "Styling made easy 🎨",
5
+ "author": {
6
+ "name": "Samuel Hulla",
7
+ "email": "hulla@hulla.dev",
8
+ "url": "https://hulla.dev"
9
+ },
10
+ "maintainers": [
11
+ "Samuel Hulla <hulla@hulla.dev>"
12
+ ],
13
+ "homepage": "https://hulla.dev/projects/style",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/hulladev/style.git",
17
+ "directory": "packages/style"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "exports": {
23
+ "import": {
24
+ "types": "./dist/es/index.d.mts",
25
+ "default": "./dist/es/index.mjs"
26
+ },
27
+ "require": {
28
+ "types": "./dist/cjs/index.d.ts",
29
+ "default": "./dist/cjs/index.js"
30
+ }
31
+ },
32
+ "devDependencies": {
33
+ "bunchee": "^5.2.1",
34
+ "clsx": "^2.1.1",
35
+ "tailwind-merge": "^2.3.0",
36
+ "vitest": "^1.6.0"
37
+ },
38
+ "scripts": {
39
+ "lint": "eslint . --fix",
40
+ "build": "bunchee -m",
41
+ "test": "vitest run"
42
+ }
43
+ }