cva 1.0.0-beta.2 → 1.0.0-beta.4
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/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined;
|
|
2
|
-
type ClassDictionary = Record<string, any>;
|
|
3
|
-
type ClassArray = ClassValue[];
|
|
1
|
+
export type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined;
|
|
2
|
+
export type ClassDictionary = Record<string, any>;
|
|
3
|
+
export type ClassArray = ClassValue[];
|
|
4
4
|
type OmitUndefined<T> = T extends undefined ? never : T;
|
|
5
5
|
type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
|
|
6
6
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;CAcC;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;CAcC;;;;;;;;;;;IAiPc,OAAO;eAAP;;IAAS,GAAG;eAAH;;IAAK,EAAE;eAAF;;IAzFhB,YAAY;eAAZ;;;sBAvJQ;AAiJrB;+CAC+C,GAE/C,MAAM,gBAAgB,CAAoB,QACxC,OAAO,UAAU,YAAY,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,IAAI,MAAM;AAEzD,MAAM,eAA6B,CAAC;IACzC,MAAM,KAAS;yCAAI;YAAA;;YACN,gBAGA;QAHX,IAAI,QAAO,oBAAA,+BAAA,iBAAA,QAAS,KAAK,cAAd,qCAAA,cAAgB,CAAC,UA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,CAAC,UAAU,KAAK,CAAC;wBAAC,CAAC,OAAO,WAAW;oBACjD,MAAM,WACJ,gBAAgB,CAAC,MAAuC;oBAE1D,OAAO,MAAM,OAAO,CAAC,cACjB,WAAW,QAAQ,CAAC,YACpB,aAAa;gBACnB,KACI;uBAAI;oBAAK;oBAAS;iBAAY,GAC9B;eACN,EAAE;YAGJ,OAAO,GACL,mBAAA,6BAAA,OAAQ,IAAI,EACZ,sBACA,8BACA,kBAAA,4BAAA,MAAO,KAAK,EACZ,kBAAA,4BAAA,MAAO,SAAS;QAEpB;IAEA,MAAM,UACJ;yCAAI;YAAA;;eACJ,CAAC;YACC,MAAM,oBAAoB,OAAO,WAAW,CAC1C,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAChC;oBAAC,CAAC,IAAI;uBAAK,CAAC;oBAAC;oBAAS;iBAAY,CAAC,QAAQ,CAAC;;YAIhD,OAAO,GACL,WAAW,GAAG,CAAC,CAAC,YAAc,UAAU,qBACxC,kBAAA,4BAAA,MAAO,KAAK,EACZ,kBAAA,4BAAA,MAAO,SAAS;QAEpB;;IAEF,OAAO;QACL;QACA;QACA;IACF;AACF;AAEO,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG","file":"index.js","sourcesContent":["/**\n * Copyright 2022 Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\n\n/* Types\n ============================================ */\n\n/* clsx\n ---------------------------------- */\n\n// When compiling with `declaration: true`, many projects experience the dreaded\n// TS2742 error. To combat this, we copy clsx's types manually.\n// Should this project move to JSDoc, this workaround would no longer be needed.\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype StringToBoolean<T> = T extends \"true\" | \"false\" ? boolean : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\"\n>;\n\n/* compose\n ---------------------------------- */\n\nexport interface Compose {\n <T extends ReturnType<CVA>[]>(\n ...components: [...T]\n ): (\n props?: (\n | UnionToIntersection<\n {\n [K in keyof T]: VariantProps<T[K]>;\n }[number]\n >\n | undefined\n ) &\n CVAClassProp,\n ) => string;\n}\n\n/* cx\n ---------------------------------- */\n\nexport interface CX {\n (...inputs: ClassValue[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\ntype CVAConfigBase = { base?: ClassValue };\ntype CVAVariantShape = Record<string, Record<string, ClassValue>>;\ntype CVAVariantSchema<V extends CVAVariantShape> = {\n [Variant in keyof V]?: StringToBoolean<keyof V[Variant]> | undefined;\n};\ntype CVAClassProp =\n | {\n class?: ClassValue;\n className?: never;\n }\n | {\n class?: never;\n className?: ClassValue;\n };\n\nexport interface CVA {\n <\n _ extends \"cva's generic parameters are restricted to internal use only.\",\n V,\n >(\n config: V extends CVAVariantShape\n ? CVAConfigBase & {\n variants?: V;\n compoundVariants?: (V extends CVAVariantShape\n ? (\n | CVAVariantSchema<V>\n | {\n [Variant in keyof V]?:\n | StringToBoolean<keyof V[Variant]>\n | StringToBoolean<keyof V[Variant]>[]\n | undefined;\n }\n ) &\n CVAClassProp\n : CVAClassProp)[];\n defaultVariants?: CVAVariantSchema<V>;\n }\n : CVAConfigBase & {\n variants?: never;\n compoundVariants?: never;\n defaultVariants?: never;\n },\n ): (\n props?: V extends CVAVariantShape\n ? CVAVariantSchema<V> & CVAClassProp\n : CVAClassProp,\n ) => string;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions {\n hooks?: {\n /**\n * @deprecated please use `onComplete`\n */\n \"cx:done\"?: (className: string) => string;\n /**\n * Returns the completed string of concatenated classes/classNames.\n */\n onComplete?: (className: string) => string;\n };\n}\n\nexport interface DefineConfig {\n (options?: DefineConfigOptions): {\n compose: Compose;\n cx: CX;\n cva: CVA;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\nexport const defineConfig: DefineConfig = (options) => {\n const cx: CX = (...inputs) => {\n if (typeof options?.hooks?.[\"cx:done\"] !== \"undefined\")\n return options?.hooks[\"cx:done\"](clsx(inputs));\n\n if (typeof options?.hooks?.onComplete !== \"undefined\")\n return options?.hooks.onComplete(clsx(inputs));\n\n return clsx(inputs);\n };\n\n const cva: CVA = (config) => (props) => {\n if (config?.variants == null)\n return cx(config?.base, props?.class, props?.className);\n\n const { variants, defaultVariants } = config;\n\n const getVariantClassNames = Object.keys(variants).map(\n (variant: keyof typeof variants) => {\n const variantProp = props?.[variant as keyof typeof props];\n const defaultVariantProp = defaultVariants?.[variant];\n\n const variantKey = (falsyToString(variantProp) ||\n falsyToString(\n defaultVariantProp,\n )) as keyof (typeof variants)[typeof variant];\n\n return variants[variant][variantKey];\n },\n );\n\n const defaultsAndProps = {\n ...defaultVariants,\n // remove `undefined` props\n ...(props &&\n Object.entries(props).reduce<typeof props>(\n (acc, [key, value]) =>\n typeof value === \"undefined\" ? acc : { ...acc, [key]: value },\n {} as typeof props,\n )),\n };\n\n const getCompoundVariantClassNames = config?.compoundVariants?.reduce(\n (acc, { class: cvClass, className: cvClassName, ...cvConfig }) =>\n Object.entries(cvConfig).every(([cvKey, cvSelector]) => {\n const selector =\n defaultsAndProps[cvKey as keyof typeof defaultsAndProps];\n\n return Array.isArray(cvSelector)\n ? cvSelector.includes(selector)\n : selector === cvSelector;\n })\n ? [...acc, cvClass, cvClassName]\n : acc,\n [] as ClassValue[],\n );\n\n return cx(\n config?.base,\n getVariantClassNames,\n getCompoundVariantClassNames,\n props?.class,\n props?.className,\n );\n };\n\n const compose: Compose =\n (...components) =>\n (props) => {\n const propsWithoutClass = Object.fromEntries(\n Object.entries(props || {}).filter(\n ([key]) => ![\"class\", \"className\"].includes(key),\n ),\n );\n\n return cx(\n components.map((component) => component(propsWithoutClass)),\n props?.class,\n props?.className,\n );\n };\n\n return {\n compose,\n cva,\n cx,\n };\n};\n\nexport const { compose, cva, cx } = defineConfig();\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GACD,SAAS,IAAI,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GACD,SAAS,IAAI,QAAQ,OAAO;AAiJ5B;+CAC+C,GAE/C,MAAM,gBAAgB,CAAoB,QACxC,OAAO,UAAU,YAAY,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,IAAI,MAAM;AAEhE,OAAO,MAAM,eAA6B,CAAC;IACzC,MAAM,KAAS;yCAAI;YAAA;;YACN,gBAGA;QAHX,IAAI,QAAO,oBAAA,+BAAA,iBAAA,QAAS,KAAK,cAAd,qCAAA,cAAgB,CAAC,UAAU,MAAK,aACzC,OAAO,oBAAA,8BAAA,QAAS,KAAK,CAAC,UAAU,CAAC,KAAK;QAExC,IAAI,QAAO,oBAAA,+BAAA,kBAAA,QAAS,KAAK,cAAd,sCAAA,gBAAgB,UAAU,MAAK,aACxC,OAAO,oBAAA,8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EAAE;YAGJ,OAAO,GACL,mBAAA,6BAAA,OAAQ,IAAI,EACZ,sBACA,8BACA,kBAAA,4BAAA,MAAO,KAAK,EACZ,kBAAA,4BAAA,MAAO,SAAS;QAEpB;IAEA,MAAM,UACJ;yCAAI;YAAA;;eACJ,CAAC;YACC,MAAM,oBAAoB,OAAO,WAAW,CAC1C,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAChC;oBAAC,CAAC,IAAI;uBAAK,CAAC;oBAAC;oBAAS;iBAAY,CAAC,QAAQ,CAAC;;YAIhD,OAAO,GACL,WAAW,GAAG,CAAC,CAAC,YAAc,UAAU,qBACxC,kBAAA,4BAAA,MAAO,KAAK,EACZ,kBAAA,4BAAA,MAAO,SAAS;QAEpB;;IAEF,OAAO;QACL;QACA;QACA;IACF;AACF,EAAE;AAEF,OAAO,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,eAAe","file":"index.mjs","sourcesContent":["/**\n * Copyright 2022 Joe Bell. All rights reserved.\n *\n * This file is licensed to you under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with the\n * License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\nimport { clsx } from \"clsx\";\n\n/* Types\n ============================================ */\n\n/* clsx\n ---------------------------------- */\n\n// When compiling with `declaration: true`, many projects experience the dreaded\n// TS2742 error. To combat this, we copy clsx's types manually.\n// Should this project move to JSDoc, this workaround would no longer be needed.\n\nexport type ClassValue =\n | ClassArray\n | ClassDictionary\n | string\n | number\n | bigint\n | null\n | boolean\n | undefined;\nexport type ClassDictionary = Record<string, any>;\nexport type ClassArray = ClassValue[];\n\n/* Utils\n ---------------------------------- */\n\ntype OmitUndefined<T> = T extends undefined ? never : T;\ntype StringToBoolean<T> = T extends \"true\" | \"false\" ? boolean : T;\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\nexport type VariantProps<Component extends (...args: any) => any> = Omit<\n OmitUndefined<Parameters<Component>[0]>,\n \"class\" | \"className\"\n>;\n\n/* compose\n ---------------------------------- */\n\nexport interface Compose {\n <T extends ReturnType<CVA>[]>(\n ...components: [...T]\n ): (\n props?: (\n | UnionToIntersection<\n {\n [K in keyof T]: VariantProps<T[K]>;\n }[number]\n >\n | undefined\n ) &\n CVAClassProp,\n ) => string;\n}\n\n/* cx\n ---------------------------------- */\n\nexport interface CX {\n (...inputs: ClassValue[]): string;\n}\n\nexport type CXOptions = Parameters<CX>;\nexport type CXReturn = ReturnType<CX>;\n\n/* cva\n ============================================ */\n\ntype CVAConfigBase = { base?: ClassValue };\ntype CVAVariantShape = Record<string, Record<string, ClassValue>>;\ntype CVAVariantSchema<V extends CVAVariantShape> = {\n [Variant in keyof V]?: StringToBoolean<keyof V[Variant]> | undefined;\n};\ntype CVAClassProp =\n | {\n class?: ClassValue;\n className?: never;\n }\n | {\n class?: never;\n className?: ClassValue;\n };\n\nexport interface CVA {\n <\n _ extends \"cva's generic parameters are restricted to internal use only.\",\n V,\n >(\n config: V extends CVAVariantShape\n ? CVAConfigBase & {\n variants?: V;\n compoundVariants?: (V extends CVAVariantShape\n ? (\n | CVAVariantSchema<V>\n | {\n [Variant in keyof V]?:\n | StringToBoolean<keyof V[Variant]>\n | StringToBoolean<keyof V[Variant]>[]\n | undefined;\n }\n ) &\n CVAClassProp\n : CVAClassProp)[];\n defaultVariants?: CVAVariantSchema<V>;\n }\n : CVAConfigBase & {\n variants?: never;\n compoundVariants?: never;\n defaultVariants?: never;\n },\n ): (\n props?: V extends CVAVariantShape\n ? CVAVariantSchema<V> & CVAClassProp\n : CVAClassProp,\n ) => string;\n}\n\n/* defineConfig\n ---------------------------------- */\n\nexport interface DefineConfigOptions {\n hooks?: {\n /**\n * @deprecated please use `onComplete`\n */\n \"cx:done\"?: (className: string) => string;\n /**\n * Returns the completed string of concatenated classes/classNames.\n */\n onComplete?: (className: string) => string;\n };\n}\n\nexport interface DefineConfig {\n (options?: DefineConfigOptions): {\n compose: Compose;\n cx: CX;\n cva: CVA;\n };\n}\n\n/* Exports\n ============================================ */\n\nconst falsyToString = <T extends unknown>(value: T) =>\n typeof value === \"boolean\" ? `${value}` : value === 0 ? \"0\" : value;\n\nexport const defineConfig: DefineConfig = (options) => {\n const cx: CX = (...inputs) => {\n if (typeof options?.hooks?.[\"cx:done\"] !== \"undefined\")\n return options?.hooks[\"cx:done\"](clsx(inputs));\n\n if (typeof options?.hooks?.onComplete !== \"undefined\")\n return options?.hooks.onComplete(clsx(inputs));\n\n return clsx(inputs);\n };\n\n const cva: CVA = (config) => (props) => {\n if (config?.variants == null)\n return cx(config?.base, props?.class, props?.className);\n\n const { variants, defaultVariants } = config;\n\n const getVariantClassNames = Object.keys(variants).map(\n (variant: keyof typeof variants) => {\n const variantProp = props?.[variant as keyof typeof props];\n const defaultVariantProp = defaultVariants?.[variant];\n\n const variantKey = (falsyToString(variantProp) ||\n falsyToString(\n defaultVariantProp,\n )) as keyof (typeof variants)[typeof variant];\n\n return variants[variant][variantKey];\n },\n );\n\n const defaultsAndProps = {\n ...defaultVariants,\n // remove `undefined` props\n ...(props &&\n Object.entries(props).reduce<typeof props>(\n (acc, [key, value]) =>\n typeof value === \"undefined\" ? acc : { ...acc, [key]: value },\n {} as typeof props,\n )),\n };\n\n const getCompoundVariantClassNames = config?.compoundVariants?.reduce(\n (acc, { class: cvClass, className: cvClassName, ...cvConfig }) =>\n Object.entries(cvConfig).every(([cvKey, cvSelector]) => {\n const selector =\n defaultsAndProps[cvKey as keyof typeof defaultsAndProps];\n\n return Array.isArray(cvSelector)\n ? cvSelector.includes(selector)\n : selector === cvSelector;\n })\n ? [...acc, cvClass, cvClassName]\n : acc,\n [] as ClassValue[],\n );\n\n return cx(\n config?.base,\n getVariantClassNames,\n getCompoundVariantClassNames,\n props?.class,\n props?.className,\n );\n };\n\n const compose: Compose =\n (...components) =>\n (props) => {\n const propsWithoutClass = Object.fromEntries(\n Object.entries(props || {}).filter(\n ([key]) => ![\"class\", \"className\"].includes(key),\n ),\n );\n\n return cx(\n components.map((component) => component(propsWithoutClass)),\n props?.class,\n props?.className,\n );\n };\n\n return {\n compose,\n cva,\n cx,\n };\n};\n\nexport const { compose, cva, cx } = defineConfig();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cva",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
4
|
"description": "Class Variance Authority 🧬",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Class Variance Authority",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"author": "Joe Bell (https://joebell.co.uk)",
|
|
23
23
|
"exports": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
24
25
|
"import": "./dist/index.mjs",
|
|
25
|
-
"require": "./dist/index.js"
|
|
26
|
-
"types": "./dist/index.d.ts"
|
|
26
|
+
"require": "./dist/index.js"
|
|
27
27
|
},
|
|
28
28
|
"main": "dist/index.js",
|
|
29
29
|
"module": "dist/index.mjs",
|
|
@@ -35,20 +35,20 @@
|
|
|
35
35
|
"clsx": "^2.1.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
+
"@arethetypeswrong/cli": "0.17.3",
|
|
38
39
|
"@swc/cli": "0.3.12",
|
|
39
40
|
"@swc/core": "1.4.16",
|
|
40
41
|
"@types/node": "20.12.7",
|
|
41
42
|
"@types/react": "18.2.79",
|
|
42
43
|
"@types/react-dom": "18.2.25",
|
|
43
44
|
"bundlesize": "0.18.2",
|
|
44
|
-
"npm-run-all": "4.1.5",
|
|
45
45
|
"react": "18.2.0",
|
|
46
46
|
"react-dom": "18.2.0",
|
|
47
47
|
"ts-node": "10.9.2",
|
|
48
|
-
"typescript": "5.
|
|
48
|
+
"typescript": "5.7.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"typescript": ">= 4.5.5
|
|
51
|
+
"typescript": ">= 4.5.5"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"typescript": {
|
|
@@ -56,12 +56,14 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
|
-
"build": "run
|
|
59
|
+
"build": "pnpm run '/^build:.*/'",
|
|
60
60
|
"build:cjs": "swc ./src/index.ts --config-file ./.config/.swcrc -o dist/index.js -C module.type=commonjs",
|
|
61
61
|
"build:esm": "swc ./src/index.ts --config-file ./.config/.swcrc -o dist/index.mjs -C module.type=es6 ",
|
|
62
62
|
"build:tsc": "tsc --project .config/tsconfig.build.json",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
63
|
+
"bundlesize": "pnpm build && bundlesize -f 'dist/*.js' -s 1.6KB",
|
|
64
|
+
"check": "pnpm run '/^check:.*/'",
|
|
65
|
+
"check:exports": "attw --pack .",
|
|
66
|
+
"check:tsc": "tsc --project tsconfig.json --noEmit",
|
|
67
|
+
"dev": "jest --config .config/jest.config.ts --watch"
|
|
66
68
|
}
|
|
67
69
|
}
|