tailwind-variants 0.0.9 → 0.0.11
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.cjs +2 -2
- package/dist/index.d.ts +16 -10
- package/dist/index.js +2 -2
- package/dist/utils.d.ts +0 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
var classVarianceAuthority = require('class-variance-authority');
|
|
4
4
|
var tailwindMerge = require('tailwind-merge');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var j=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>e&&Object.keys(e).length>0,i=(...e)=>(f={})=>f.twMerge?(g(f.twMergeConfig)?tailwindMerge.extendTailwindMerge(f.twMergeConfig):tailwindMerge.twMerge)(classVarianceAuthority.cx(e)):classVarianceAuthority.cx(e);var F=(e,f={twMerge:!0,twMergeConfig:{}})=>n=>{var C;let{slots:l={},variants:b={},defaultVariants:m={},compoundVariants:y=[]}=e;if(b==null&&!g(l))return i(e==null?void 0:e.base,n==null?void 0:n.class,n==null?void 0:n.className)(f);if(y&&!Array.isArray(y))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof y}`);let d={base:e==null?void 0:e.base,...l},w=t=>{let a=n==null?void 0:n[t],r=m==null?void 0:m[t];if(a===null)return null;let u=j(a)||j(r);return b[t][u]},N=b?Object.keys(b).map(w):null,V=t=>!b||typeof b!="object"?null:Object.keys(b).map(a=>{let r=w(a);return t==="base"&&typeof r=="string"?r:!r||typeof r!="object"?null:r[t]}),M=n&&Object.entries(n).reduce((t,[a,r])=>(r===void 0||(t[a]=r),t),{}),x=y==null?void 0:y.reduce((t,{class:a,className:r,...u})=>Object.entries(u).every(([c,s])=>Array.isArray(s)?s.includes({...m,...M}[c]):{...m,...M}[c]===s)?[...t,a,r]:t,[]),A=()=>{let t=x;return Array.isArray(t)?t.reduce((a,r)=>(typeof r=="string"&&(a.base=i(a.base,r)(f)),typeof r=="object"&&Object.entries(r).forEach(([u,c])=>{a[u]=i(a[u],c)(f);}),a),{}):t};if(g(l)){let t=(C=A())!=null?C:[];return {...typeof d=="object"&&g(d)?Object.keys(d).reduce((r,u)=>(r[u]=c=>i(u==="base"?e==null?void 0:e.base:[],d[u],V(u),t==null?void 0:t[u],c==null?void 0:c.class,c==null?void 0:c.className)(f),r),{}):{}}}return i(e==null?void 0:e.base,N,x,n==null?void 0:n.class,n==null?void 0:n.className)(f)};
|
|
7
7
|
|
|
8
|
-
exports.tv =
|
|
8
|
+
exports.tv = F;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,20 +5,28 @@ type TVBaseName = "base";
|
|
|
5
5
|
|
|
6
6
|
type TVSlots = Record<string, ClassValue> | undefined;
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
|
|
8
|
+
type TVSlotsWithBase<S extends TVSlots, B extends ClassValue> = B extends undefined
|
|
9
|
+
? keyof S
|
|
10
|
+
: keyof S | TVBaseName;
|
|
11
|
+
|
|
12
|
+
type SlotsClassValue<S extends TVSlots, B extends ClassValue> = {
|
|
13
|
+
[K in TVSlotsWithBase<S, B>]?: ClassValue;
|
|
10
14
|
};
|
|
11
15
|
|
|
12
|
-
export type TVVariants<S extends TVSlots> = {
|
|
16
|
+
export type TVVariants<S extends TVSlots, B extends ClassValue> = {
|
|
13
17
|
[key: string]: {
|
|
14
|
-
[key: string]: S extends TVSlots ? SlotsClassValue<S> | ClassValue : ClassValue;
|
|
18
|
+
[key: string]: S extends TVSlots ? SlotsClassValue<S, B> | ClassValue : ClassValue;
|
|
15
19
|
};
|
|
16
20
|
};
|
|
17
21
|
|
|
18
|
-
export type TVCompoundVariants<
|
|
22
|
+
export type TVCompoundVariants<
|
|
23
|
+
V extends TVVariants<S>,
|
|
24
|
+
S extends TVSlots,
|
|
25
|
+
B extends ClassValue,
|
|
26
|
+
> = Array<
|
|
19
27
|
{
|
|
20
28
|
[K in keyof V]?: StringToBoolean<keyof V[K]> | StringToBoolean<keyof V[K]>[];
|
|
21
|
-
} & ClassProp<SlotsClassValue<S> | ClassValue>
|
|
29
|
+
} & ClassProp<SlotsClassValue<S, B> | ClassValue>
|
|
22
30
|
>;
|
|
23
31
|
|
|
24
32
|
export type TVDefaultVariants<V extends TVVariants<S>, S extends TVSlots> = {
|
|
@@ -34,14 +42,12 @@ export type TVReturnType<V extends TVVariants<S>, S extends TVSlots, B extends C
|
|
|
34
42
|
) => S extends undefined
|
|
35
43
|
? string
|
|
36
44
|
: {
|
|
37
|
-
[K in
|
|
38
|
-
slotProps?: ClassProp,
|
|
39
|
-
) => string;
|
|
45
|
+
[K in TVSlotsWithBase<S, B>]: (slotProps?: ClassProp) => string;
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
export function tv<
|
|
43
49
|
DV extends TVDefaultVariants<V, S>,
|
|
44
|
-
CV extends TVCompoundVariants<V, S>,
|
|
50
|
+
CV extends TVCompoundVariants<V, S, B>,
|
|
45
51
|
C extends TVConfig,
|
|
46
52
|
V extends TVVariants<S>,
|
|
47
53
|
B extends ClassValue = undefined,
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cx } from 'class-variance-authority';
|
|
2
2
|
import { extendTailwindMerge, twMerge } from 'tailwind-merge';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var j=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>e&&Object.keys(e).length>0,i=(...e)=>(f={})=>f.twMerge?(g(f.twMergeConfig)?extendTailwindMerge(f.twMergeConfig):twMerge)(cx(e)):cx(e);var F=(e,f={twMerge:!0,twMergeConfig:{}})=>n=>{var C;let{slots:l={},variants:b={},defaultVariants:m={},compoundVariants:y=[]}=e;if(b==null&&!g(l))return i(e==null?void 0:e.base,n==null?void 0:n.class,n==null?void 0:n.className)(f);if(y&&!Array.isArray(y))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof y}`);let d={base:e==null?void 0:e.base,...l},w=t=>{let a=n==null?void 0:n[t],r=m==null?void 0:m[t];if(a===null)return null;let u=j(a)||j(r);return b[t][u]},N=b?Object.keys(b).map(w):null,V=t=>!b||typeof b!="object"?null:Object.keys(b).map(a=>{let r=w(a);return t==="base"&&typeof r=="string"?r:!r||typeof r!="object"?null:r[t]}),M=n&&Object.entries(n).reduce((t,[a,r])=>(r===void 0||(t[a]=r),t),{}),x=y==null?void 0:y.reduce((t,{class:a,className:r,...u})=>Object.entries(u).every(([c,s])=>Array.isArray(s)?s.includes({...m,...M}[c]):{...m,...M}[c]===s)?[...t,a,r]:t,[]),A=()=>{let t=x;return Array.isArray(t)?t.reduce((a,r)=>(typeof r=="string"&&(a.base=i(a.base,r)(f)),typeof r=="object"&&Object.entries(r).forEach(([u,c])=>{a[u]=i(a[u],c)(f);}),a),{}):t};if(g(l)){let t=(C=A())!=null?C:[];return {...typeof d=="object"&&g(d)?Object.keys(d).reduce((r,u)=>(r[u]=c=>i(u==="base"?e==null?void 0:e.base:[],d[u],V(u),t==null?void 0:t[u],c==null?void 0:c.class,c==null?void 0:c.className)(f),r),{}):{}}}return i(e==null?void 0:e.base,N,x,n==null?void 0:n.class,n==null?void 0:n.className)(f)};
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { F as tv };
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import {CxOptions, CxReturn} from "class-variance-authority";
|
|
|
2
2
|
|
|
3
3
|
import {TVConfig} from "./config";
|
|
4
4
|
|
|
5
|
-
export declare const cleanArray: (array: string[]) => string[] | undefined;
|
|
6
|
-
|
|
7
5
|
export declare const falsyToString: <T extends unknown>(value: T) => string | T;
|
|
8
6
|
|
|
9
7
|
export declare const isNotEmptyObject: (obj: object) => boolean;
|