tailwind-variants 3.2.2 → 3.3.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.
- package/README.md +91 -80
- package/dist/chunk-2BFDQGZN.cjs +160 -0
- package/dist/chunk-AUQ4UGQK.js +673 -0
- package/dist/chunk-ICHZ2N3R.cjs +677 -0
- package/dist/chunk-OYFAXDFZ.js +147 -0
- package/dist/config-bO3A8WhU.d.cts +112 -0
- package/dist/config-bO3A8WhU.d.ts +112 -0
- package/dist/config.cjs +2 -0
- package/dist/config.d.cts +1 -0
- package/dist/config.d.ts +1 -23
- package/dist/config.js +1 -0
- package/dist/index.cjs +3312 -32
- package/dist/index.d.cts +35 -0
- package/dist/index.d.ts +17 -121
- package/dist/index.js +3309 -25
- package/dist/lite.cjs +17 -12
- package/dist/lite.d.cts +10 -0
- package/dist/lite.d.ts +8 -11
- package/dist/lite.js +15 -8
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +168 -0
- package/dist/types.d.ts +122 -291
- package/dist/types.js +1 -0
- package/dist/utils.cjs +12 -12
- package/dist/utils.d.cts +16 -0
- package/dist/utils.d.ts +16 -32
- package/dist/utils.js +1 -1
- package/package.json +62 -66
- package/dist/chunk-2JY7EID6.cjs +0 -124
- package/dist/chunk-52Z2HSI4.cjs +0 -273
- package/dist/chunk-LQJYWU4O.js +0 -112
- package/dist/chunk-RZF76H2U.js +0 -269
package/dist/lite.cjs
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkICHZ2N3R_cjs = require('./chunk-ICHZ2N3R.cjs');
|
|
4
|
+
var chunk2BFDQGZN_cjs = require('./chunk-2BFDQGZN.cjs');
|
|
5
5
|
|
|
6
|
-
// src/lite.
|
|
7
|
-
var
|
|
6
|
+
// src/lite.ts
|
|
7
|
+
var cn = (...classnames) => {
|
|
8
8
|
return (_config) => {
|
|
9
|
-
const base =
|
|
9
|
+
const base = chunk2BFDQGZN_cjs.cx(classnames);
|
|
10
10
|
return base || void 0;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
var
|
|
13
|
+
var cnAdapter = cn;
|
|
14
|
+
var classAdapter = (_config, ...classnames) => {
|
|
15
|
+
const result = chunk2BFDQGZN_cjs.cx(classnames);
|
|
16
|
+
return result || void 0;
|
|
17
|
+
};
|
|
18
|
+
var runtime = chunkICHZ2N3R_cjs.getTailwindVariants(classAdapter);
|
|
19
|
+
var tv = runtime.tv;
|
|
20
|
+
var createTV = runtime.createTV;
|
|
21
|
+
var defaultConfig2 = chunkICHZ2N3R_cjs.defaultConfig;
|
|
14
22
|
|
|
15
|
-
Object.defineProperty(exports, "defaultConfig", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return chunk52Z2HSI4_cjs.defaultConfig; }
|
|
18
|
-
});
|
|
19
23
|
Object.defineProperty(exports, "cx", {
|
|
20
24
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk2BFDQGZN_cjs.cx; }
|
|
22
26
|
});
|
|
23
|
-
exports.cn =
|
|
27
|
+
exports.cn = cn;
|
|
24
28
|
exports.cnAdapter = cnAdapter;
|
|
25
29
|
exports.createTV = createTV;
|
|
30
|
+
exports.defaultConfig = defaultConfig2;
|
|
26
31
|
exports.tv = tv;
|
package/dist/lite.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CnOptions, CnReturn, TVLite } from './types.cjs';
|
|
2
|
+
export { ClassProp, OmitUndefined, StringToBoolean, TV, TVCompoundSlots, TVCompoundVariants, TVDefaultVariants, TVProps, TVReturnProps, TVReturnType, TVReturnTypeLike, TVScreenPropsValue, TVVariantKeys, TVVariants, VariantProps, WithInitialScreen, isTrueOrArray } from './types.cjs';
|
|
3
|
+
export { cx } from './utils.cjs';
|
|
4
|
+
export { C as ClassValue } from './config-bO3A8WhU.cjs';
|
|
5
|
+
|
|
6
|
+
declare const cn: <T extends CnOptions>(...classnames: T) => ((config?: any) => CnReturn);
|
|
7
|
+
declare const tv: TVLite;
|
|
8
|
+
declare const createTV: () => TVLite;
|
|
9
|
+
|
|
10
|
+
export { CnOptions, CnReturn, TVLite, cn, createTV, tv };
|
package/dist/lite.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CnOptions, CnReturn, TVLite } from './types.js';
|
|
2
|
+
export { ClassProp, OmitUndefined, StringToBoolean, TV, TVCompoundSlots, TVCompoundVariants, TVDefaultVariants, TVProps, TVReturnProps, TVReturnType, TVReturnTypeLike, TVScreenPropsValue, TVVariantKeys, TVVariants, VariantProps, WithInitialScreen, isTrueOrArray } from './types.js';
|
|
3
|
+
export { cx } from './utils.js';
|
|
4
|
+
export { C as ClassValue } from './config-bO3A8WhU.js';
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
declare const cn: <T extends CnOptions>(...classnames: T) => ((config?: any) => CnReturn);
|
|
7
|
+
declare const tv: TVLite;
|
|
8
|
+
declare const createTV: () => TVLite;
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
export declare const cx: <T extends CnOptions>(...classes: T) => CnReturn;
|
|
7
|
-
|
|
8
|
-
export declare const cn: <T extends CnOptions>(...classes: T) => (config?: any) => CnReturn;
|
|
9
|
-
|
|
10
|
-
// main function
|
|
11
|
-
export declare const tv: TVLite;
|
|
12
|
-
|
|
13
|
-
export declare function createTV(): TVLite;
|
|
10
|
+
export { CnOptions, CnReturn, TVLite, cn, createTV, tv };
|
package/dist/lite.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { getTailwindVariants } from './chunk-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { cx } from './chunk-LQJYWU4O.js';
|
|
1
|
+
import { getTailwindVariants, defaultConfig } from './chunk-AUQ4UGQK.js';
|
|
2
|
+
import { cx } from './chunk-OYFAXDFZ.js';
|
|
3
|
+
export { cx } from './chunk-OYFAXDFZ.js';
|
|
5
4
|
|
|
6
|
-
// src/lite.
|
|
7
|
-
var
|
|
5
|
+
// src/lite.ts
|
|
6
|
+
var cn = (...classnames) => {
|
|
8
7
|
return (_config) => {
|
|
9
8
|
const base = cx(classnames);
|
|
10
9
|
return base || void 0;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
var
|
|
12
|
+
var cnAdapter = cn;
|
|
13
|
+
var classAdapter = (_config, ...classnames) => {
|
|
14
|
+
const result = cx(classnames);
|
|
15
|
+
return result || void 0;
|
|
16
|
+
};
|
|
17
|
+
var runtime = getTailwindVariants(classAdapter);
|
|
18
|
+
var tv = runtime.tv;
|
|
19
|
+
var createTV = runtime.createTV;
|
|
20
|
+
var defaultConfig2 = defaultConfig;
|
|
14
21
|
|
|
15
|
-
export {
|
|
22
|
+
export { cn, cnAdapter, createTV, defaultConfig2 as defaultConfig, tv };
|
package/dist/types.cjs
ADDED
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { C as ClassNameValue, a as TVConfig } from './config-bO3A8WhU.cjs';
|
|
2
|
+
|
|
3
|
+
type ClassProp<V = ClassNameValue> = {
|
|
4
|
+
class?: V;
|
|
5
|
+
className?: never;
|
|
6
|
+
} | {
|
|
7
|
+
class?: never;
|
|
8
|
+
className?: V;
|
|
9
|
+
};
|
|
10
|
+
type TVBaseName = "base";
|
|
11
|
+
type TVScreens = "initial";
|
|
12
|
+
type TVSlots = Record<string, ClassNameValue> | undefined;
|
|
13
|
+
type TVVariantsShape = Record<string, Record<string, unknown>> | undefined;
|
|
14
|
+
interface TVReturnTypeLike<V extends TVVariantsShape, S extends TVSlots> {
|
|
15
|
+
(...args: any[]): any;
|
|
16
|
+
variants: V;
|
|
17
|
+
slots: S;
|
|
18
|
+
}
|
|
19
|
+
type OmitUndefined<T> = T extends undefined ? never : T;
|
|
20
|
+
type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
|
|
21
|
+
type VariantValue<V, K> = K extends keyof V ? StringToBoolean<keyof V[K]> : never;
|
|
22
|
+
type VariantValueWithBooleanUndefined<V, K> = VariantValue<V, K> | (boolean extends VariantValue<V, K> ? undefined : never);
|
|
23
|
+
type CnClassValue = string | number | bigint | boolean | null | undefined | CnClassDictionary | CnClassArray;
|
|
24
|
+
interface CnClassDictionary {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
interface CnClassArray extends Array<CnClassValue> {
|
|
28
|
+
}
|
|
29
|
+
type CnOptions = CnClassValue[];
|
|
30
|
+
type CnReturn = string | undefined;
|
|
31
|
+
type isTrueOrArray<T> = T extends true | unknown[] ? true : false;
|
|
32
|
+
type WithInitialScreen<T extends Array<string>> = ["initial", ...T];
|
|
33
|
+
type TVSlotsWithBase<S extends TVSlots, B extends ClassNameValue> = keyof S | (B extends undefined ? never : TVBaseName);
|
|
34
|
+
type SlotsClassValue<S extends TVSlots, B extends ClassNameValue> = {
|
|
35
|
+
[K in TVSlotsWithBase<S, B>]?: ClassNameValue;
|
|
36
|
+
};
|
|
37
|
+
type TVVariantsDefault<S extends TVSlots, B extends ClassNameValue> = S extends undefined ? {} : {
|
|
38
|
+
[key: string]: {
|
|
39
|
+
[key: string]: S extends TVSlots ? SlotsClassValue<S, B> | ClassNameValue : ClassNameValue;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type TVVariants<S extends TVSlots | undefined, B extends ClassNameValue | undefined = undefined, EV extends TVVariantsShape = undefined, _ES extends TVSlots | undefined = undefined> = EV extends undefined ? TVVariantsDefault<S, B> : {
|
|
43
|
+
[K in keyof EV]: {
|
|
44
|
+
[K2 in keyof EV[K]]: S extends TVSlots ? SlotsClassValue<S, B> | ClassNameValue : ClassNameValue;
|
|
45
|
+
};
|
|
46
|
+
} | TVVariantsDefault<S, B>;
|
|
47
|
+
type TVCompoundVariants<V extends TVVariantsShape, S extends TVSlots, B extends ClassNameValue, EV extends TVVariantsShape, _ES extends TVSlots> = Array<{
|
|
48
|
+
[K in keyof V | keyof EV]?: VariantValueWithBooleanUndefined<V, K> | VariantValueWithBooleanUndefined<EV, K> | (K extends keyof V ? VariantValueWithBooleanUndefined<V, K>[] : never);
|
|
49
|
+
} & ClassProp<SlotsClassValue<S, B> | ClassNameValue>>;
|
|
50
|
+
type TVCompoundSlots<V extends TVVariantsShape, S extends TVSlots, B extends ClassNameValue> = Array<{
|
|
51
|
+
slots: Array<TVSlotsWithBase<S, B>>;
|
|
52
|
+
} & {
|
|
53
|
+
[K in keyof V]?: VariantValueWithBooleanUndefined<V, K> | VariantValueWithBooleanUndefined<V, K>[];
|
|
54
|
+
} & ClassProp>;
|
|
55
|
+
type TVDefaultVariants<V extends TVVariantsShape, _S extends TVSlots, EV extends TVVariantsShape, _ES extends TVSlots> = {
|
|
56
|
+
[K in keyof V | keyof EV]?: VariantValue<V, K> | VariantValue<EV, K>;
|
|
57
|
+
};
|
|
58
|
+
type TVScreenPropsValue<V extends TVVariantsShape, _S extends TVSlots, K extends keyof V> = {
|
|
59
|
+
[Screen in TVScreens]?: StringToBoolean<keyof V[K]>;
|
|
60
|
+
};
|
|
61
|
+
type TVProps<V extends TVVariantsShape, _S extends TVSlots, EV extends TVVariantsShape, _ES extends TVSlots> = EV extends undefined ? V extends undefined ? ClassProp<ClassNameValue> : {
|
|
62
|
+
[K in keyof V]?: VariantValue<V, K> | undefined;
|
|
63
|
+
} & ClassProp<ClassNameValue> : V extends undefined ? {
|
|
64
|
+
[K in keyof EV]?: VariantValue<EV, K> | undefined;
|
|
65
|
+
} & ClassProp<ClassNameValue> : {
|
|
66
|
+
[K in keyof V | keyof EV]?: VariantValue<V, K> | VariantValue<EV, K> | undefined;
|
|
67
|
+
} & ClassProp<ClassNameValue>;
|
|
68
|
+
type TVVariantKeys<V extends TVVariantsShape, _S extends TVSlots> = V extends undefined ? undefined : Array<keyof V>;
|
|
69
|
+
type TVMergedVariants<V extends TVVariantsShape, EV extends TVVariantsShape> = V extends undefined ? EV : EV extends undefined ? V : V & EV;
|
|
70
|
+
type TVMergedSlots<S extends TVSlots, ES extends TVSlots> = S extends undefined ? ES : ES extends undefined ? S : S & ES;
|
|
71
|
+
interface TVReturnProps<V extends TVVariantsShape, S extends TVSlots, B extends ClassNameValue, EV extends TVVariantsShape, ES extends TVSlots, E extends TVReturnTypeLike<any, any> | undefined = undefined> {
|
|
72
|
+
extend: E;
|
|
73
|
+
base: B;
|
|
74
|
+
slots: TVMergedSlots<S, ES>;
|
|
75
|
+
variants: TVMergedVariants<V, EV>;
|
|
76
|
+
defaultVariants: TVDefaultVariants<V, S, EV, ES>;
|
|
77
|
+
compoundVariants: TVCompoundVariants<V, S, B, EV, ES>;
|
|
78
|
+
compoundSlots: TVCompoundSlots<V, S, B>;
|
|
79
|
+
variantKeys: TVVariantKeys<TVMergedVariants<V, EV>, TVMergedSlots<S, ES>>;
|
|
80
|
+
}
|
|
81
|
+
type HasSlots<S extends TVSlots, ES extends TVSlots> = S extends undefined ? ES extends undefined ? false : true : true;
|
|
82
|
+
interface TVReturnType<V extends TVVariantsShape, S extends TVSlots, B extends ClassNameValue, EV extends TVVariantsShape, ES extends TVSlots, E extends TVReturnTypeLike<any, any> | undefined = undefined> extends TVReturnProps<V, S, B, EV, ES, E> {
|
|
83
|
+
(props?: TVProps<V, S, EV, ES>): HasSlots<S, ES> extends true ? {
|
|
84
|
+
[K in keyof (ES extends undefined ? {} : ES)]: (slotProps?: TVProps<V, S, EV, ES>) => string;
|
|
85
|
+
} & {
|
|
86
|
+
[K in keyof (S extends undefined ? {} : S)]: (slotProps?: TVProps<V, S, EV, ES>) => string;
|
|
87
|
+
} & {
|
|
88
|
+
[K in TVBaseName]: (slotProps?: TVProps<V, S, EV, ES>) => string;
|
|
89
|
+
} : string;
|
|
90
|
+
}
|
|
91
|
+
type TV = <V extends TVVariants<S, B, EV>, CV extends TVCompoundVariants<V, S, B, EV, ES>, DV extends TVDefaultVariants<V, S, EV, ES>, B extends ClassNameValue = undefined, S extends TVSlots = undefined, E extends TVReturnTypeLike<any, any> = TVReturnTypeLike<V, S>, EV extends TVVariants<ES, B, E["variants"], ES> = E["variants"], ES extends TVSlots = E["slots"] extends TVSlots ? E["slots"] : undefined>(options: {
|
|
92
|
+
/**
|
|
93
|
+
* Extend allows for easy composition of components.
|
|
94
|
+
* @see https://www.tailwind-variants.org/docs/composing-components
|
|
95
|
+
*/
|
|
96
|
+
extend?: E;
|
|
97
|
+
/**
|
|
98
|
+
* Base allows you to set a base class for a component.
|
|
99
|
+
*/
|
|
100
|
+
base?: B;
|
|
101
|
+
/**
|
|
102
|
+
* Slots allow you to separate a component into multiple parts.
|
|
103
|
+
* @see https://www.tailwind-variants.org/docs/slots
|
|
104
|
+
*/
|
|
105
|
+
slots?: S;
|
|
106
|
+
/**
|
|
107
|
+
* Variants allow you to create multiple versions of the same component.
|
|
108
|
+
* @see https://www.tailwind-variants.org/docs/variants#adding-variants
|
|
109
|
+
*/
|
|
110
|
+
variants?: V;
|
|
111
|
+
/**
|
|
112
|
+
* Compound variants allow you to apply classes to multiple variants at once.
|
|
113
|
+
* @see https://www.tailwind-variants.org/docs/variants#compound-variants
|
|
114
|
+
*/
|
|
115
|
+
compoundVariants?: CV;
|
|
116
|
+
/**
|
|
117
|
+
* Compound slots allow you to apply classes to multiple slots at once.
|
|
118
|
+
*/
|
|
119
|
+
compoundSlots?: TVCompoundSlots<V, S, B>;
|
|
120
|
+
/**
|
|
121
|
+
* Default variants allow you to set default variants for a component.
|
|
122
|
+
* @see https://www.tailwind-variants.org/docs/variants#default-variants
|
|
123
|
+
*/
|
|
124
|
+
defaultVariants?: DV;
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* The config object allows you to modify the default configuration.
|
|
128
|
+
* @see https://www.tailwind-variants.org/docs/api-reference#config-optional
|
|
129
|
+
*/
|
|
130
|
+
config?: TVConfig) => TVReturnType<V, S, B, EV, ES, E>;
|
|
131
|
+
type TVLite = <V extends TVVariants<S, B, EV>, CV extends TVCompoundVariants<V, S, B, EV, ES>, DV extends TVDefaultVariants<V, S, EV, ES>, B extends ClassNameValue = undefined, S extends TVSlots = undefined, E extends TVReturnTypeLike<any, any> = TVReturnTypeLike<V, S>, EV extends TVVariants<ES, B, E["variants"], ES> = E["variants"], ES extends TVSlots = E["slots"] extends TVSlots ? E["slots"] : undefined>(options: {
|
|
132
|
+
/**
|
|
133
|
+
* Extend allows for easy composition of components.
|
|
134
|
+
* @see https://www.tailwind-variants.org/docs/composing-components
|
|
135
|
+
*/
|
|
136
|
+
extend?: E;
|
|
137
|
+
/**
|
|
138
|
+
* Base allows you to set a base class for a component.
|
|
139
|
+
*/
|
|
140
|
+
base?: B;
|
|
141
|
+
/**
|
|
142
|
+
* Slots allow you to separate a component into multiple parts.
|
|
143
|
+
* @see https://www.tailwind-variants.org/docs/slots
|
|
144
|
+
*/
|
|
145
|
+
slots?: S;
|
|
146
|
+
/**
|
|
147
|
+
* Variants allow you to create multiple versions of the same component.
|
|
148
|
+
* @see https://www.tailwind-variants.org/docs/variants#adding-variants
|
|
149
|
+
*/
|
|
150
|
+
variants?: V;
|
|
151
|
+
/**
|
|
152
|
+
* Compound variants allow you to apply classes to multiple variants at once.
|
|
153
|
+
* @see https://www.tailwind-variants.org/docs/variants#compound-variants
|
|
154
|
+
*/
|
|
155
|
+
compoundVariants?: CV;
|
|
156
|
+
/**
|
|
157
|
+
* Compound slots allow you to apply classes to multiple slots at once.
|
|
158
|
+
*/
|
|
159
|
+
compoundSlots?: TVCompoundSlots<V, S, B>;
|
|
160
|
+
/**
|
|
161
|
+
* Default variants allow you to set default variants for a component.
|
|
162
|
+
* @see https://www.tailwind-variants.org/docs/variants#default-variants
|
|
163
|
+
*/
|
|
164
|
+
defaultVariants?: DV;
|
|
165
|
+
}) => TVReturnType<V, S, B, EV, ES, E>;
|
|
166
|
+
type VariantProps<Component extends (...args: any) => any> = Omit<OmitUndefined<Parameters<Component>[0]>, "class" | "className">;
|
|
167
|
+
|
|
168
|
+
export { type ClassProp, ClassNameValue as ClassValue, type CnOptions, type CnReturn, type OmitUndefined, type StringToBoolean, type TV, type TVCompoundSlots, type TVCompoundVariants, type TVDefaultVariants, type TVLite, type TVProps, type TVReturnProps, type TVReturnType, type TVReturnTypeLike, type TVScreenPropsValue, type TVVariantKeys, type TVVariants, type VariantProps, type WithInitialScreen, type isTrueOrArray };
|