@stylex-variants/core 0.0.1
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/LICENSE +21 -0
- package/dist/babel/index.d.ts +8 -0
- package/dist/babel.js +5060 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/sxv.d.ts +8 -0
- package/dist/types.d.ts +15 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/sxv.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompoundVariant, SXVResult, StyleXCreateStyle, VariantDefinition, VariantSelection } from "./types.js";
|
|
2
|
+
export type SXVConfig<T extends VariantDefinition> = {
|
|
3
|
+
base?: StyleXCreateStyle;
|
|
4
|
+
variants?: T;
|
|
5
|
+
defaultVariants?: VariantSelection<T>;
|
|
6
|
+
compoundVariants?: CompoundVariant<T>[];
|
|
7
|
+
};
|
|
8
|
+
export declare function sxv<const T extends VariantDefinition>(_config: SXVConfig<T>): SXVResult<T>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as stylex from "@stylexjs/stylex";
|
|
2
|
+
type StyleXCreateInput = Parameters<typeof stylex.create>[0];
|
|
3
|
+
export type StyleXCreateStyle = Exclude<StyleXCreateInput[string], (...args: never[]) => unknown>;
|
|
4
|
+
export type VariantDefinition = Record<string, Record<string, StyleXCreateStyle>>;
|
|
5
|
+
type VariantValue<T> = keyof T extends "true" | "false" ? boolean : keyof T;
|
|
6
|
+
export type VariantSelection<T extends VariantDefinition> = {
|
|
7
|
+
-readonly [K in keyof T]?: VariantValue<T[K]>;
|
|
8
|
+
};
|
|
9
|
+
export type SXVProps<T extends VariantDefinition> = VariantSelection<T> & Partial<Pick<ReturnType<typeof stylex.props>, "className" | "style">>;
|
|
10
|
+
export type CompoundVariant<T extends VariantDefinition> = VariantSelection<T> & {
|
|
11
|
+
style: StyleXCreateStyle;
|
|
12
|
+
};
|
|
13
|
+
export type SXVResult<T extends VariantDefinition> = (props?: SXVProps<T>) => ReturnType<typeof stylex.props>;
|
|
14
|
+
export type VariantProps<T> = T extends (props?: infer Props) => ReturnType<typeof stylex.props> ? Props : never;
|
|
15
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stylex-variants/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Typed, compile-time style variants for StyleX.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"babel",
|
|
8
|
+
"stylex",
|
|
9
|
+
"typescript",
|
|
10
|
+
"variants"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/corvallo/stylex-variants#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/corvallo/stylex-variants/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/corvallo/stylex-variants.git",
|
|
19
|
+
"directory": "packages/core"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./babel": {
|
|
32
|
+
"types": "./dist/babel/index.d.ts",
|
|
33
|
+
"import": "./dist/babel.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@stylexjs/stylex": "^0.19.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@babel/core": "^8.0.6",
|
|
44
|
+
"@babel/types": "^8.0.6",
|
|
45
|
+
"@types/babel__core": "^7.20.5",
|
|
46
|
+
"@types/node": "^24.13.3",
|
|
47
|
+
"oxlint": "^1.81.0",
|
|
48
|
+
"typescript": "~6.0.2",
|
|
49
|
+
"vite": "^8.3.0",
|
|
50
|
+
"vitest": "^5.0.3"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@babel/core": "^8.0.6"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"dev": "vite build --watch",
|
|
57
|
+
"build": "tsc -b && vite build && tsc -p tsconfig.build.json",
|
|
58
|
+
"lint": "oxlint",
|
|
59
|
+
"test": "vitest",
|
|
60
|
+
"test:run": "tsc -b && vitest run",
|
|
61
|
+
"check-types": "tsc -b",
|
|
62
|
+
"test:package": "node scripts/test-package.mjs"
|
|
63
|
+
}
|
|
64
|
+
}
|