tailwind-variants 3.1.1 → 3.2.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/README.md CHANGED
@@ -58,12 +58,16 @@ npm i tailwind-merge
58
58
  pnpm add tailwind-merge
59
59
  ```
60
60
 
61
+ > **⚠️ Compatibility Note:** Supports Tailwind CSS v4.x (requires `tailwind-merge` v3.x). If you use Tailwind CSS v3.x, use tailwind-variants v0.x with [tailwind-merge v2.6.0](https://github.com/dcastil/tailwind-merge/tree/v2.6.0).
62
+
61
63
  > **💡 Lite mode (v3):** For smaller bundle size and faster runtime without conflict resolution, use the `/lite` import:
64
+ >
62
65
  > ```js
63
66
  > import {tv} from "tailwind-variants/lite";
64
67
  > ```
65
68
 
66
- > **⚠️ Upgrading?**
69
+ > **⚠️ Upgrading?**
70
+ >
67
71
  > - From v2 to v3: See the [v3 migration guide](./MIGRATION-V3.md)
68
72
  > - From v1 to v2: See the [v2 migration guide](./MIGRATION-V2.md)
69
73
 
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ // src/utils.js
4
+ var SPACE_REGEX = /\s+/g;
5
+ var removeExtraSpaces = (str) => {
6
+ if (typeof str !== "string" || !str) return str;
7
+ return str.replace(SPACE_REGEX, " ").trim();
8
+ };
9
+ var cx = (...classnames) => {
10
+ const classList = [];
11
+ const buildClassString = (input) => {
12
+ if (!input && input !== 0 && input !== 0n) return;
13
+ if (Array.isArray(input)) {
14
+ for (let i = 0, len = input.length; i < len; i++) buildClassString(input[i]);
15
+ return;
16
+ }
17
+ const type = typeof input;
18
+ if (type === "string" || type === "number" || type === "bigint") {
19
+ if (type === "number" && input !== input) return;
20
+ classList.push(String(input));
21
+ } else if (type === "object") {
22
+ const keys = Object.keys(input);
23
+ for (let i = 0, len = keys.length; i < len; i++) {
24
+ const key = keys[i];
25
+ if (input[key]) classList.push(key);
26
+ }
27
+ }
28
+ };
29
+ for (let i = 0, len = classnames.length; i < len; i++) {
30
+ const c = classnames[i];
31
+ if (c !== null && c !== void 0) buildClassString(c);
32
+ }
33
+ return classList.length > 0 ? removeExtraSpaces(classList.join(" ")) : void 0;
34
+ };
35
+ var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
36
+ var isEmptyObject = (obj) => {
37
+ if (!obj || typeof obj !== "object") return true;
38
+ for (const _ in obj) return false;
39
+ return true;
40
+ };
41
+ var isEqual = (obj1, obj2) => {
42
+ if (obj1 === obj2) return true;
43
+ if (!obj1 || !obj2) return false;
44
+ const keys1 = Object.keys(obj1);
45
+ const keys2 = Object.keys(obj2);
46
+ if (keys1.length !== keys2.length) return false;
47
+ for (let i = 0; i < keys1.length; i++) {
48
+ const key = keys1[i];
49
+ if (!keys2.includes(key)) return false;
50
+ if (obj1[key] !== obj2[key]) return false;
51
+ }
52
+ return true;
53
+ };
54
+ var isBoolean = (value) => value === true || value === false;
55
+ var joinObjects = (obj1, obj2) => {
56
+ for (const key in obj2) {
57
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
58
+ const val2 = obj2[key];
59
+ if (key in obj1) {
60
+ obj1[key] = cx(obj1[key], val2);
61
+ } else {
62
+ obj1[key] = val2;
63
+ }
64
+ }
65
+ }
66
+ return obj1;
67
+ };
68
+ var flat = (arr, target) => {
69
+ for (let i = 0; i < arr.length; i++) {
70
+ const el = arr[i];
71
+ if (Array.isArray(el)) flat(el, target);
72
+ else if (el) target.push(el);
73
+ }
74
+ };
75
+ function flatArray(arr) {
76
+ const flattened = [];
77
+ flat(arr, flattened);
78
+ return flattened;
79
+ }
80
+ var flatMergeArrays = (...arrays) => {
81
+ const result = [];
82
+ flat(arrays, result);
83
+ const filtered = [];
84
+ for (let i = 0; i < result.length; i++) {
85
+ if (result[i]) filtered.push(result[i]);
86
+ }
87
+ return filtered;
88
+ };
89
+ var mergeObjects = (obj1, obj2) => {
90
+ const result = {};
91
+ for (const key in obj1) {
92
+ const val1 = obj1[key];
93
+ if (key in obj2) {
94
+ const val2 = obj2[key];
95
+ if (Array.isArray(val1) || Array.isArray(val2)) {
96
+ result[key] = flatMergeArrays(val2, val1);
97
+ } else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
98
+ result[key] = mergeObjects(val1, val2);
99
+ } else {
100
+ result[key] = val2 + " " + val1;
101
+ }
102
+ } else {
103
+ result[key] = val1;
104
+ }
105
+ }
106
+ for (const key in obj2) {
107
+ if (!(key in obj1)) {
108
+ result[key] = obj2[key];
109
+ }
110
+ }
111
+ return result;
112
+ };
113
+
114
+ exports.cx = cx;
115
+ exports.falsyToString = falsyToString;
116
+ exports.flat = flat;
117
+ exports.flatArray = flatArray;
118
+ exports.flatMergeArrays = flatMergeArrays;
119
+ exports.isBoolean = isBoolean;
120
+ exports.isEmptyObject = isEmptyObject;
121
+ exports.isEqual = isEqual;
122
+ exports.joinObjects = joinObjects;
123
+ exports.mergeObjects = mergeObjects;
124
+ exports.removeExtraSpaces = removeExtraSpaces;
@@ -0,0 +1,273 @@
1
+ 'use strict';
2
+
3
+ var chunk2JY7EID6_cjs = require('./chunk-2JY7EID6.cjs');
4
+
5
+ // src/config.js
6
+ var defaultConfig = {
7
+ twMerge: true,
8
+ twMergeConfig: {}
9
+ };
10
+
11
+ // src/state.js
12
+ function createState() {
13
+ let cachedTwMerge = null;
14
+ let cachedTwMergeConfig = {};
15
+ let didTwMergeConfigChange = false;
16
+ return {
17
+ get cachedTwMerge() {
18
+ return cachedTwMerge;
19
+ },
20
+ set cachedTwMerge(value) {
21
+ cachedTwMerge = value;
22
+ },
23
+ get cachedTwMergeConfig() {
24
+ return cachedTwMergeConfig;
25
+ },
26
+ set cachedTwMergeConfig(value) {
27
+ cachedTwMergeConfig = value;
28
+ },
29
+ get didTwMergeConfigChange() {
30
+ return didTwMergeConfigChange;
31
+ },
32
+ set didTwMergeConfigChange(value) {
33
+ didTwMergeConfigChange = value;
34
+ },
35
+ reset() {
36
+ cachedTwMerge = null;
37
+ cachedTwMergeConfig = {};
38
+ didTwMergeConfigChange = false;
39
+ }
40
+ };
41
+ }
42
+ var state = createState();
43
+
44
+ // src/core.js
45
+ var getTailwindVariants = (cn) => {
46
+ const tv = (options, configProp) => {
47
+ const {
48
+ extend = null,
49
+ slots: slotProps = {},
50
+ variants: variantsProps = {},
51
+ compoundVariants: compoundVariantsProps = [],
52
+ compoundSlots = [],
53
+ defaultVariants: defaultVariantsProps = {}
54
+ } = options;
55
+ const config = { ...defaultConfig, ...configProp };
56
+ const base = extend?.base ? chunk2JY7EID6_cjs.cx(extend.base, options?.base) : options?.base;
57
+ const variants = extend?.variants && !chunk2JY7EID6_cjs.isEmptyObject(extend.variants) ? chunk2JY7EID6_cjs.mergeObjects(variantsProps, extend.variants) : variantsProps;
58
+ const defaultVariants = extend?.defaultVariants && !chunk2JY7EID6_cjs.isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
59
+ if (!chunk2JY7EID6_cjs.isEmptyObject(config.twMergeConfig) && !chunk2JY7EID6_cjs.isEqual(config.twMergeConfig, state.cachedTwMergeConfig)) {
60
+ state.didTwMergeConfigChange = true;
61
+ state.cachedTwMergeConfig = config.twMergeConfig;
62
+ }
63
+ const isExtendedSlotsEmpty = chunk2JY7EID6_cjs.isEmptyObject(extend?.slots);
64
+ const componentSlots = !chunk2JY7EID6_cjs.isEmptyObject(slotProps) ? {
65
+ // add "base" to the slots object
66
+ base: chunk2JY7EID6_cjs.cx(options?.base, isExtendedSlotsEmpty && extend?.base),
67
+ ...slotProps
68
+ } : {};
69
+ const slots = isExtendedSlotsEmpty ? componentSlots : chunk2JY7EID6_cjs.joinObjects(
70
+ { ...extend?.slots },
71
+ chunk2JY7EID6_cjs.isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
72
+ );
73
+ const compoundVariants = chunk2JY7EID6_cjs.isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : chunk2JY7EID6_cjs.flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
74
+ const component = (props) => {
75
+ if (chunk2JY7EID6_cjs.isEmptyObject(variants) && chunk2JY7EID6_cjs.isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
76
+ return cn(base, props?.class, props?.className)(config);
77
+ }
78
+ if (compoundVariants && !Array.isArray(compoundVariants)) {
79
+ throw new TypeError(
80
+ `The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
81
+ );
82
+ }
83
+ if (compoundSlots && !Array.isArray(compoundSlots)) {
84
+ throw new TypeError(
85
+ `The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
86
+ );
87
+ }
88
+ const getVariantValue = (variant, vrs = variants, _slotKey = null, slotProps2 = null) => {
89
+ const variantObj = vrs[variant];
90
+ if (!variantObj || chunk2JY7EID6_cjs.isEmptyObject(variantObj)) {
91
+ return null;
92
+ }
93
+ const variantProp = slotProps2?.[variant] ?? props?.[variant];
94
+ if (variantProp === null) return null;
95
+ const variantKey = chunk2JY7EID6_cjs.falsyToString(variantProp);
96
+ if (typeof variantKey === "object") {
97
+ return null;
98
+ }
99
+ const defaultVariantProp = defaultVariants?.[variant];
100
+ const key = variantKey != null ? variantKey : chunk2JY7EID6_cjs.falsyToString(defaultVariantProp);
101
+ const value = variantObj[key || "false"];
102
+ return value;
103
+ };
104
+ const getVariantClassNames = () => {
105
+ if (!variants) return null;
106
+ const keys = Object.keys(variants);
107
+ const result = [];
108
+ for (let i = 0; i < keys.length; i++) {
109
+ const value = getVariantValue(keys[i], variants);
110
+ if (value) result.push(value);
111
+ }
112
+ return result;
113
+ };
114
+ const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
115
+ if (!variants || typeof variants !== "object") return null;
116
+ const result = [];
117
+ for (const variant in variants) {
118
+ const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
119
+ const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
120
+ if (value) result.push(value);
121
+ }
122
+ return result;
123
+ };
124
+ const propsWithoutUndefined = {};
125
+ for (const prop in props) {
126
+ const value = props[prop];
127
+ if (value !== void 0) propsWithoutUndefined[prop] = value;
128
+ }
129
+ const getCompleteProps = (key, slotProps2) => {
130
+ const initialProp = typeof props?.[key] === "object" ? {
131
+ [key]: props[key]?.initial
132
+ } : {};
133
+ return {
134
+ ...defaultVariants,
135
+ ...propsWithoutUndefined,
136
+ ...initialProp,
137
+ ...slotProps2
138
+ };
139
+ };
140
+ const getCompoundVariantsValue = (cv = [], slotProps2) => {
141
+ const result = [];
142
+ const cvLength = cv.length;
143
+ for (let i = 0; i < cvLength; i++) {
144
+ const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
145
+ let isValid = true;
146
+ const completeProps = getCompleteProps(null, slotProps2);
147
+ for (const key in compoundVariantOptions) {
148
+ const value = compoundVariantOptions[key];
149
+ const completePropsValue = completeProps[key];
150
+ if (Array.isArray(value)) {
151
+ if (!value.includes(completePropsValue)) {
152
+ isValid = false;
153
+ break;
154
+ }
155
+ } else {
156
+ if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
157
+ continue;
158
+ if (completePropsValue !== value) {
159
+ isValid = false;
160
+ break;
161
+ }
162
+ }
163
+ }
164
+ if (isValid) {
165
+ if (tvClass) result.push(tvClass);
166
+ if (tvClassName) result.push(tvClassName);
167
+ }
168
+ }
169
+ return result;
170
+ };
171
+ const getCompoundVariantClassNamesBySlot = (slotProps2) => {
172
+ const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
173
+ if (!Array.isArray(compoundClassNames)) return compoundClassNames;
174
+ const result = {};
175
+ const cnFn = cn;
176
+ for (let i = 0; i < compoundClassNames.length; i++) {
177
+ const className = compoundClassNames[i];
178
+ if (typeof className === "string") {
179
+ result.base = cnFn(result.base, className)(config);
180
+ } else if (typeof className === "object") {
181
+ for (const slot in className) {
182
+ result[slot] = cnFn(result[slot], className[slot])(config);
183
+ }
184
+ }
185
+ }
186
+ return result;
187
+ };
188
+ const getCompoundSlotClassNameBySlot = (slotProps2) => {
189
+ if (compoundSlots.length < 1) return null;
190
+ const result = {};
191
+ const completeProps = getCompleteProps(null, slotProps2);
192
+ for (let i = 0; i < compoundSlots.length; i++) {
193
+ const {
194
+ slots: slots2 = [],
195
+ class: slotClass,
196
+ className: slotClassName,
197
+ ...slotVariants
198
+ } = compoundSlots[i];
199
+ if (!chunk2JY7EID6_cjs.isEmptyObject(slotVariants)) {
200
+ let isValid = true;
201
+ for (const key in slotVariants) {
202
+ const completePropsValue = completeProps[key];
203
+ const slotVariantValue = slotVariants[key];
204
+ if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
205
+ isValid = false;
206
+ break;
207
+ }
208
+ }
209
+ if (!isValid) continue;
210
+ }
211
+ for (let j = 0; j < slots2.length; j++) {
212
+ const slotName = slots2[j];
213
+ if (!result[slotName]) result[slotName] = [];
214
+ result[slotName].push([slotClass, slotClassName]);
215
+ }
216
+ }
217
+ return result;
218
+ };
219
+ if (!chunk2JY7EID6_cjs.isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
220
+ const slotsFns = {};
221
+ if (typeof slots === "object" && !chunk2JY7EID6_cjs.isEmptyObject(slots)) {
222
+ const cnFn = cn;
223
+ for (const slotKey in slots) {
224
+ slotsFns[slotKey] = (slotProps2) => {
225
+ const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
226
+ const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
227
+ return cnFn(
228
+ slots[slotKey],
229
+ getVariantClassNamesBySlotKey(slotKey, slotProps2),
230
+ compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
231
+ compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
232
+ slotProps2?.class,
233
+ slotProps2?.className
234
+ )(config);
235
+ };
236
+ }
237
+ }
238
+ return slotsFns;
239
+ }
240
+ return cn(
241
+ base,
242
+ getVariantClassNames(),
243
+ getCompoundVariantsValue(compoundVariants),
244
+ props?.class,
245
+ props?.className
246
+ )(config);
247
+ };
248
+ const getVariantKeys = () => {
249
+ if (!variants || typeof variants !== "object") return;
250
+ return Object.keys(variants);
251
+ };
252
+ component.variantKeys = getVariantKeys();
253
+ component.extend = extend;
254
+ component.base = base;
255
+ component.slots = slots;
256
+ component.variants = variants;
257
+ component.defaultVariants = defaultVariants;
258
+ component.compoundSlots = compoundSlots;
259
+ component.compoundVariants = compoundVariants;
260
+ return component;
261
+ };
262
+ const createTV = (configProp) => {
263
+ return (options, config) => tv(options, config ? chunk2JY7EID6_cjs.mergeObjects(configProp, config) : configProp);
264
+ };
265
+ return {
266
+ tv,
267
+ createTV
268
+ };
269
+ };
270
+
271
+ exports.defaultConfig = defaultConfig;
272
+ exports.getTailwindVariants = getTailwindVariants;
273
+ exports.state = state;
@@ -0,0 +1,112 @@
1
+ // src/utils.js
2
+ var SPACE_REGEX = /\s+/g;
3
+ var removeExtraSpaces = (str) => {
4
+ if (typeof str !== "string" || !str) return str;
5
+ return str.replace(SPACE_REGEX, " ").trim();
6
+ };
7
+ var cx = (...classnames) => {
8
+ const classList = [];
9
+ const buildClassString = (input) => {
10
+ if (!input && input !== 0 && input !== 0n) return;
11
+ if (Array.isArray(input)) {
12
+ for (let i = 0, len = input.length; i < len; i++) buildClassString(input[i]);
13
+ return;
14
+ }
15
+ const type = typeof input;
16
+ if (type === "string" || type === "number" || type === "bigint") {
17
+ if (type === "number" && input !== input) return;
18
+ classList.push(String(input));
19
+ } else if (type === "object") {
20
+ const keys = Object.keys(input);
21
+ for (let i = 0, len = keys.length; i < len; i++) {
22
+ const key = keys[i];
23
+ if (input[key]) classList.push(key);
24
+ }
25
+ }
26
+ };
27
+ for (let i = 0, len = classnames.length; i < len; i++) {
28
+ const c = classnames[i];
29
+ if (c !== null && c !== void 0) buildClassString(c);
30
+ }
31
+ return classList.length > 0 ? removeExtraSpaces(classList.join(" ")) : void 0;
32
+ };
33
+ var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
34
+ var isEmptyObject = (obj) => {
35
+ if (!obj || typeof obj !== "object") return true;
36
+ for (const _ in obj) return false;
37
+ return true;
38
+ };
39
+ var isEqual = (obj1, obj2) => {
40
+ if (obj1 === obj2) return true;
41
+ if (!obj1 || !obj2) return false;
42
+ const keys1 = Object.keys(obj1);
43
+ const keys2 = Object.keys(obj2);
44
+ if (keys1.length !== keys2.length) return false;
45
+ for (let i = 0; i < keys1.length; i++) {
46
+ const key = keys1[i];
47
+ if (!keys2.includes(key)) return false;
48
+ if (obj1[key] !== obj2[key]) return false;
49
+ }
50
+ return true;
51
+ };
52
+ var isBoolean = (value) => value === true || value === false;
53
+ var joinObjects = (obj1, obj2) => {
54
+ for (const key in obj2) {
55
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
56
+ const val2 = obj2[key];
57
+ if (key in obj1) {
58
+ obj1[key] = cx(obj1[key], val2);
59
+ } else {
60
+ obj1[key] = val2;
61
+ }
62
+ }
63
+ }
64
+ return obj1;
65
+ };
66
+ var flat = (arr, target) => {
67
+ for (let i = 0; i < arr.length; i++) {
68
+ const el = arr[i];
69
+ if (Array.isArray(el)) flat(el, target);
70
+ else if (el) target.push(el);
71
+ }
72
+ };
73
+ function flatArray(arr) {
74
+ const flattened = [];
75
+ flat(arr, flattened);
76
+ return flattened;
77
+ }
78
+ var flatMergeArrays = (...arrays) => {
79
+ const result = [];
80
+ flat(arrays, result);
81
+ const filtered = [];
82
+ for (let i = 0; i < result.length; i++) {
83
+ if (result[i]) filtered.push(result[i]);
84
+ }
85
+ return filtered;
86
+ };
87
+ var mergeObjects = (obj1, obj2) => {
88
+ const result = {};
89
+ for (const key in obj1) {
90
+ const val1 = obj1[key];
91
+ if (key in obj2) {
92
+ const val2 = obj2[key];
93
+ if (Array.isArray(val1) || Array.isArray(val2)) {
94
+ result[key] = flatMergeArrays(val2, val1);
95
+ } else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
96
+ result[key] = mergeObjects(val1, val2);
97
+ } else {
98
+ result[key] = val2 + " " + val1;
99
+ }
100
+ } else {
101
+ result[key] = val1;
102
+ }
103
+ }
104
+ for (const key in obj2) {
105
+ if (!(key in obj1)) {
106
+ result[key] = obj2[key];
107
+ }
108
+ }
109
+ return result;
110
+ };
111
+
112
+ export { cx, falsyToString, flat, flatArray, flatMergeArrays, isBoolean, isEmptyObject, isEqual, joinObjects, mergeObjects, removeExtraSpaces };
@@ -0,0 +1,269 @@
1
+ import { cx, isEmptyObject, mergeObjects, isEqual, joinObjects, flatMergeArrays, falsyToString } from './chunk-LQJYWU4O.js';
2
+
3
+ // src/config.js
4
+ var defaultConfig = {
5
+ twMerge: true,
6
+ twMergeConfig: {}
7
+ };
8
+
9
+ // src/state.js
10
+ function createState() {
11
+ let cachedTwMerge = null;
12
+ let cachedTwMergeConfig = {};
13
+ let didTwMergeConfigChange = false;
14
+ return {
15
+ get cachedTwMerge() {
16
+ return cachedTwMerge;
17
+ },
18
+ set cachedTwMerge(value) {
19
+ cachedTwMerge = value;
20
+ },
21
+ get cachedTwMergeConfig() {
22
+ return cachedTwMergeConfig;
23
+ },
24
+ set cachedTwMergeConfig(value) {
25
+ cachedTwMergeConfig = value;
26
+ },
27
+ get didTwMergeConfigChange() {
28
+ return didTwMergeConfigChange;
29
+ },
30
+ set didTwMergeConfigChange(value) {
31
+ didTwMergeConfigChange = value;
32
+ },
33
+ reset() {
34
+ cachedTwMerge = null;
35
+ cachedTwMergeConfig = {};
36
+ didTwMergeConfigChange = false;
37
+ }
38
+ };
39
+ }
40
+ var state = createState();
41
+
42
+ // src/core.js
43
+ var getTailwindVariants = (cn) => {
44
+ const tv = (options, configProp) => {
45
+ const {
46
+ extend = null,
47
+ slots: slotProps = {},
48
+ variants: variantsProps = {},
49
+ compoundVariants: compoundVariantsProps = [],
50
+ compoundSlots = [],
51
+ defaultVariants: defaultVariantsProps = {}
52
+ } = options;
53
+ const config = { ...defaultConfig, ...configProp };
54
+ const base = extend?.base ? cx(extend.base, options?.base) : options?.base;
55
+ const variants = extend?.variants && !isEmptyObject(extend.variants) ? mergeObjects(variantsProps, extend.variants) : variantsProps;
56
+ const defaultVariants = extend?.defaultVariants && !isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
57
+ if (!isEmptyObject(config.twMergeConfig) && !isEqual(config.twMergeConfig, state.cachedTwMergeConfig)) {
58
+ state.didTwMergeConfigChange = true;
59
+ state.cachedTwMergeConfig = config.twMergeConfig;
60
+ }
61
+ const isExtendedSlotsEmpty = isEmptyObject(extend?.slots);
62
+ const componentSlots = !isEmptyObject(slotProps) ? {
63
+ // add "base" to the slots object
64
+ base: cx(options?.base, isExtendedSlotsEmpty && extend?.base),
65
+ ...slotProps
66
+ } : {};
67
+ const slots = isExtendedSlotsEmpty ? componentSlots : joinObjects(
68
+ { ...extend?.slots },
69
+ isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
70
+ );
71
+ const compoundVariants = isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
72
+ const component = (props) => {
73
+ if (isEmptyObject(variants) && isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
74
+ return cn(base, props?.class, props?.className)(config);
75
+ }
76
+ if (compoundVariants && !Array.isArray(compoundVariants)) {
77
+ throw new TypeError(
78
+ `The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
79
+ );
80
+ }
81
+ if (compoundSlots && !Array.isArray(compoundSlots)) {
82
+ throw new TypeError(
83
+ `The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
84
+ );
85
+ }
86
+ const getVariantValue = (variant, vrs = variants, _slotKey = null, slotProps2 = null) => {
87
+ const variantObj = vrs[variant];
88
+ if (!variantObj || isEmptyObject(variantObj)) {
89
+ return null;
90
+ }
91
+ const variantProp = slotProps2?.[variant] ?? props?.[variant];
92
+ if (variantProp === null) return null;
93
+ const variantKey = falsyToString(variantProp);
94
+ if (typeof variantKey === "object") {
95
+ return null;
96
+ }
97
+ const defaultVariantProp = defaultVariants?.[variant];
98
+ const key = variantKey != null ? variantKey : falsyToString(defaultVariantProp);
99
+ const value = variantObj[key || "false"];
100
+ return value;
101
+ };
102
+ const getVariantClassNames = () => {
103
+ if (!variants) return null;
104
+ const keys = Object.keys(variants);
105
+ const result = [];
106
+ for (let i = 0; i < keys.length; i++) {
107
+ const value = getVariantValue(keys[i], variants);
108
+ if (value) result.push(value);
109
+ }
110
+ return result;
111
+ };
112
+ const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
113
+ if (!variants || typeof variants !== "object") return null;
114
+ const result = [];
115
+ for (const variant in variants) {
116
+ const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
117
+ const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
118
+ if (value) result.push(value);
119
+ }
120
+ return result;
121
+ };
122
+ const propsWithoutUndefined = {};
123
+ for (const prop in props) {
124
+ const value = props[prop];
125
+ if (value !== void 0) propsWithoutUndefined[prop] = value;
126
+ }
127
+ const getCompleteProps = (key, slotProps2) => {
128
+ const initialProp = typeof props?.[key] === "object" ? {
129
+ [key]: props[key]?.initial
130
+ } : {};
131
+ return {
132
+ ...defaultVariants,
133
+ ...propsWithoutUndefined,
134
+ ...initialProp,
135
+ ...slotProps2
136
+ };
137
+ };
138
+ const getCompoundVariantsValue = (cv = [], slotProps2) => {
139
+ const result = [];
140
+ const cvLength = cv.length;
141
+ for (let i = 0; i < cvLength; i++) {
142
+ const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
143
+ let isValid = true;
144
+ const completeProps = getCompleteProps(null, slotProps2);
145
+ for (const key in compoundVariantOptions) {
146
+ const value = compoundVariantOptions[key];
147
+ const completePropsValue = completeProps[key];
148
+ if (Array.isArray(value)) {
149
+ if (!value.includes(completePropsValue)) {
150
+ isValid = false;
151
+ break;
152
+ }
153
+ } else {
154
+ if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
155
+ continue;
156
+ if (completePropsValue !== value) {
157
+ isValid = false;
158
+ break;
159
+ }
160
+ }
161
+ }
162
+ if (isValid) {
163
+ if (tvClass) result.push(tvClass);
164
+ if (tvClassName) result.push(tvClassName);
165
+ }
166
+ }
167
+ return result;
168
+ };
169
+ const getCompoundVariantClassNamesBySlot = (slotProps2) => {
170
+ const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
171
+ if (!Array.isArray(compoundClassNames)) return compoundClassNames;
172
+ const result = {};
173
+ const cnFn = cn;
174
+ for (let i = 0; i < compoundClassNames.length; i++) {
175
+ const className = compoundClassNames[i];
176
+ if (typeof className === "string") {
177
+ result.base = cnFn(result.base, className)(config);
178
+ } else if (typeof className === "object") {
179
+ for (const slot in className) {
180
+ result[slot] = cnFn(result[slot], className[slot])(config);
181
+ }
182
+ }
183
+ }
184
+ return result;
185
+ };
186
+ const getCompoundSlotClassNameBySlot = (slotProps2) => {
187
+ if (compoundSlots.length < 1) return null;
188
+ const result = {};
189
+ const completeProps = getCompleteProps(null, slotProps2);
190
+ for (let i = 0; i < compoundSlots.length; i++) {
191
+ const {
192
+ slots: slots2 = [],
193
+ class: slotClass,
194
+ className: slotClassName,
195
+ ...slotVariants
196
+ } = compoundSlots[i];
197
+ if (!isEmptyObject(slotVariants)) {
198
+ let isValid = true;
199
+ for (const key in slotVariants) {
200
+ const completePropsValue = completeProps[key];
201
+ const slotVariantValue = slotVariants[key];
202
+ if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
203
+ isValid = false;
204
+ break;
205
+ }
206
+ }
207
+ if (!isValid) continue;
208
+ }
209
+ for (let j = 0; j < slots2.length; j++) {
210
+ const slotName = slots2[j];
211
+ if (!result[slotName]) result[slotName] = [];
212
+ result[slotName].push([slotClass, slotClassName]);
213
+ }
214
+ }
215
+ return result;
216
+ };
217
+ if (!isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
218
+ const slotsFns = {};
219
+ if (typeof slots === "object" && !isEmptyObject(slots)) {
220
+ const cnFn = cn;
221
+ for (const slotKey in slots) {
222
+ slotsFns[slotKey] = (slotProps2) => {
223
+ const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
224
+ const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
225
+ return cnFn(
226
+ slots[slotKey],
227
+ getVariantClassNamesBySlotKey(slotKey, slotProps2),
228
+ compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
229
+ compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
230
+ slotProps2?.class,
231
+ slotProps2?.className
232
+ )(config);
233
+ };
234
+ }
235
+ }
236
+ return slotsFns;
237
+ }
238
+ return cn(
239
+ base,
240
+ getVariantClassNames(),
241
+ getCompoundVariantsValue(compoundVariants),
242
+ props?.class,
243
+ props?.className
244
+ )(config);
245
+ };
246
+ const getVariantKeys = () => {
247
+ if (!variants || typeof variants !== "object") return;
248
+ return Object.keys(variants);
249
+ };
250
+ component.variantKeys = getVariantKeys();
251
+ component.extend = extend;
252
+ component.base = base;
253
+ component.slots = slots;
254
+ component.variants = variants;
255
+ component.defaultVariants = defaultVariants;
256
+ component.compoundSlots = compoundSlots;
257
+ component.compoundVariants = compoundVariants;
258
+ return component;
259
+ };
260
+ const createTV = (configProp) => {
261
+ return (options, config) => tv(options, config ? mergeObjects(configProp, config) : configProp);
262
+ };
263
+ return {
264
+ tv,
265
+ createTV
266
+ };
267
+ };
268
+
269
+ export { defaultConfig, getTailwindVariants, state };
package/dist/config.d.ts CHANGED
@@ -21,5 +21,3 @@ export type TWMConfig = {
21
21
  };
22
22
 
23
23
  export type TVConfig = TWMConfig;
24
-
25
- export declare const defaultConfig: TVConfig;
package/dist/index.cjs CHANGED
@@ -1 +1,68 @@
1
- 'use strict';var chunkWBJQ6REG_cjs=require('./chunk-WBJQ6REG.cjs'),chunk7L2KNZGU_cjs=require('./chunk-7L2KNZGU.cjs'),tailwindMerge=require('tailwind-merge');var f=e=>chunk7L2KNZGU_cjs.d(e)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge({...e,extend:{theme:e.theme,classGroups:e.classGroups,conflictingClassGroupModifiers:e.conflictingClassGroupModifiers,conflictingClassGroups:e.conflictingClassGroups,...e.extend}}),i=(...e)=>a=>{let t=chunk7L2KNZGU_cjs.b(e);return !t||!a.twMerge?t:((!chunkWBJQ6REG_cjs.b.cachedTwMerge||chunkWBJQ6REG_cjs.b.didTwMergeConfigChange)&&(chunkWBJQ6REG_cjs.b.didTwMergeConfigChange=false,chunkWBJQ6REG_cjs.b.cachedTwMerge=f(chunkWBJQ6REG_cjs.b.cachedTwMergeConfig)),chunkWBJQ6REG_cjs.b.cachedTwMerge(t)||void 0)};var {createTV:C,tv:T}=chunkWBJQ6REG_cjs.c(i);Object.defineProperty(exports,"defaultConfig",{enumerable:true,get:function(){return chunkWBJQ6REG_cjs.a}});Object.defineProperty(exports,"cnBase",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.b}});exports.cn=i;exports.createTV=C;exports.tv=T;
1
+ 'use strict';
2
+
3
+ var chunk52Z2HSI4_cjs = require('./chunk-52Z2HSI4.cjs');
4
+ var chunk2JY7EID6_cjs = require('./chunk-2JY7EID6.cjs');
5
+ var tailwindMerge = require('tailwind-merge');
6
+
7
+ var createTwMerge = (cachedTwMergeConfig) => {
8
+ return chunk2JY7EID6_cjs.isEmptyObject(cachedTwMergeConfig) ? tailwindMerge.twMerge : tailwindMerge.extendTailwindMerge({
9
+ ...cachedTwMergeConfig,
10
+ extend: {
11
+ theme: cachedTwMergeConfig.theme,
12
+ classGroups: cachedTwMergeConfig.classGroups,
13
+ conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
14
+ conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
15
+ ...cachedTwMergeConfig.extend
16
+ }
17
+ });
18
+ };
19
+ var cn = (...classnames) => {
20
+ const execute = (config) => {
21
+ const base = chunk2JY7EID6_cjs.cx(classnames);
22
+ if (!base || !(config?.twMerge ?? true)) return base;
23
+ if (!chunk52Z2HSI4_cjs.state.cachedTwMerge || chunk52Z2HSI4_cjs.state.didTwMergeConfigChange) {
24
+ chunk52Z2HSI4_cjs.state.didTwMergeConfigChange = false;
25
+ chunk52Z2HSI4_cjs.state.cachedTwMerge = createTwMerge(chunk52Z2HSI4_cjs.state.cachedTwMergeConfig);
26
+ }
27
+ return chunk52Z2HSI4_cjs.state.cachedTwMerge(base) || void 0;
28
+ };
29
+ const defaultResult = execute({});
30
+ const fn = (config) => execute(config);
31
+ return new Proxy(fn, {
32
+ apply(target, thisArg, args) {
33
+ return target(...args);
34
+ },
35
+ get(target, prop) {
36
+ if (prop === Symbol.toPrimitive) {
37
+ return (hint) => {
38
+ if (hint === "string" || hint === "default") {
39
+ return defaultResult ?? "";
40
+ }
41
+ return defaultResult;
42
+ };
43
+ }
44
+ if (prop === "valueOf") {
45
+ return () => defaultResult;
46
+ }
47
+ if (prop === "toString") {
48
+ return () => String(defaultResult ?? "");
49
+ }
50
+ return target[prop];
51
+ }
52
+ });
53
+ };
54
+
55
+ // src/index.js
56
+ var { createTV, tv } = chunk52Z2HSI4_cjs.getTailwindVariants(cn);
57
+
58
+ Object.defineProperty(exports, "defaultConfig", {
59
+ enumerable: true,
60
+ get: function () { return chunk52Z2HSI4_cjs.defaultConfig; }
61
+ });
62
+ Object.defineProperty(exports, "cx", {
63
+ enumerable: true,
64
+ get: function () { return chunk2JY7EID6_cjs.cx; }
65
+ });
66
+ exports.cn = cn;
67
+ exports.createTV = createTV;
68
+ exports.tv = tv;
package/dist/index.d.ts CHANGED
@@ -3,15 +3,131 @@ import type {CnOptions, CnReturn, TV} from "./types.d.ts";
3
3
 
4
4
  export type * from "./types.d.ts";
5
5
 
6
- // util function
7
- export declare const cnBase: <T extends CnOptions>(...classes: T) => CnReturn;
6
+ /**
7
+ * Combines class names into a single string. Similar to `clsx` - simple concatenation without merging conflicting classes.
8
+ * @param classes - Class names to combine. Accepts strings, numbers, arrays, objects, and nested structures.
9
+ * @returns A space-separated string of class names, or `undefined` if no valid classes are provided
10
+ * @example
11
+ * ```ts
12
+ * // Simple concatenation
13
+ * cx('text-xl', 'font-bold') // => 'text-xl font-bold'
14
+ *
15
+ * // Handles arrays and objects
16
+ * cx(['px-4', 'py-2'], { 'bg-blue-500': true, 'text-white': false }) // => 'px-4 py-2 bg-blue-500'
17
+ *
18
+ * // Ignores falsy values (except 0)
19
+ * cx('text-xl', false && 'font-bold', null, undefined) // => 'text-xl'
20
+ * ```
21
+ */
22
+ export declare const cx: <T extends CnOptions>(...classes: T) => CnReturn;
8
23
 
9
- export declare const cn: <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;
24
+ /**
25
+ * Type representing a callable function that can also be coerced to a string.
26
+ * This allows `cn` to work both as a function and directly in template literals.
27
+ */
28
+ type CnCallable = ((config?: TWMConfig) => CnReturn) & {
29
+ toString(): string;
30
+ valueOf(): CnReturn;
31
+ [Symbol.toPrimitive](hint: "string" | "number" | "default"): string | CnReturn;
32
+ } & string;
10
33
 
11
- // main function
34
+ /**
35
+ * Combines class names and merges conflicting Tailwind CSS classes using `tailwind-merge`.
36
+ * @param classes - Class names to combine (strings, arrays, objects, etc.)
37
+ * @returns A callable function that returns the merged class string. Works directly in template literals (coerces to string) or can be called with optional config.
38
+ * @example
39
+ * ```ts
40
+ * // twMerge defaults to true - works directly in template literals
41
+ * `${cn('bg-red-500', 'bg-blue-500')}` // => 'bg-blue-500'
42
+ * String(cn('bg-red-500', 'bg-blue-500')) // => 'bg-blue-500'
43
+ *
44
+ * // Can still be called with config for explicit control
45
+ * cn('bg-red-500', 'bg-blue-500')() // => 'bg-blue-500'
46
+ *
47
+ * // Note: If you need simple concatenation without merging, use `cx` instead:
48
+ * // Instead of: cn('bg-red-500', 'bg-blue-500')({ twMerge: false })
49
+ * // Use: cx('bg-red-500', 'bg-blue-500') // => 'bg-red-500 bg-blue-500'
50
+ * ```
51
+ */
52
+ export declare const cn: <T extends CnOptions>(...classes: T) => CnCallable;
53
+
54
+ /**
55
+ * Creates a variant-aware component function with Tailwind CSS classes.
56
+ * Supports variants, slots, compound variants, and component composition.
57
+ * @example
58
+ * ```ts
59
+ * const button = tv({
60
+ * base: "font-medium rounded-full",
61
+ * variants: {
62
+ * color: {
63
+ * primary: "bg-blue-500 text-white",
64
+ * secondary: "bg-purple-500 text-white",
65
+ * },
66
+ * size: {
67
+ * sm: "text-sm px-3 py-1",
68
+ * md: "text-base px-4 py-2",
69
+ * },
70
+ * },
71
+ * defaultVariants: {
72
+ * color: "primary",
73
+ * size: "md",
74
+ * },
75
+ * });
76
+ *
77
+ * button({ color: "secondary", size: "sm" }) // => 'font-medium rounded-full bg-purple-500 text-white text-sm px-3 py-1'
78
+ * ```
79
+ * @see https://www.tailwind-variants.org/docs/getting-started
80
+ */
12
81
  export declare const tv: TV;
13
82
 
83
+ /**
84
+ * Creates a configured `tv` instance with custom default configuration.
85
+ * Useful when you want to set default `twMerge` or `twMergeConfig` options for all components.
86
+ * @param config - Configuration object with default settings for `twMerge` and `twMergeConfig`
87
+ * @returns A configured `tv` function that uses the provided defaults
88
+ * @example
89
+ * ```ts
90
+ * // Create a tv instance with twMerge disabled by default
91
+ * const tv = createTV({ twMerge: false });
92
+ *
93
+ * const button = tv({
94
+ * base: "px-4 py-2",
95
+ * variants: {
96
+ * color: {
97
+ * primary: "bg-blue-500",
98
+ * },
99
+ * },
100
+ * });
101
+ *
102
+ * // Can still override config per component
103
+ * const buttonWithMerge = tv(
104
+ * {
105
+ * base: "px-4 py-2",
106
+ * variants: { color: { primary: "bg-blue-500" } },
107
+ * },
108
+ * { twMerge: true }
109
+ * );
110
+ * ```
111
+ */
14
112
  export declare function createTV(config: TVConfig): TV;
15
113
 
114
+ /**
115
+ * Default configuration object for tailwind-variants.
116
+ * Can be modified to set global defaults for all components.
117
+ * @example
118
+ * ```ts
119
+ * import { defaultConfig } from "tailwind-variants";
120
+ *
121
+ * defaultConfig.twMergeConfig = {
122
+ * extend: {
123
+ * theme: {
124
+ * spacing: ["medium", "large"],
125
+ * },
126
+ * },
127
+ * };
128
+ * ```
129
+ */
130
+ export declare const defaultConfig: TVConfig;
131
+
16
132
  // types
17
133
  export type {TVConfig, TWMConfig, TWMergeConfig};
package/dist/index.js CHANGED
@@ -1 +1,58 @@
1
- import {c,b as b$1}from'./chunk-IFWU2MEM.js';export{a as defaultConfig}from'./chunk-IFWU2MEM.js';import {b,d}from'./chunk-GQLG7IS2.js';export{b as cnBase}from'./chunk-GQLG7IS2.js';import {twMerge,extendTailwindMerge}from'tailwind-merge';var f=e=>d(e)?twMerge:extendTailwindMerge({...e,extend:{theme:e.theme,classGroups:e.classGroups,conflictingClassGroupModifiers:e.conflictingClassGroupModifiers,conflictingClassGroups:e.conflictingClassGroups,...e.extend}}),i=(...e)=>a=>{let t=b(e);return !t||!a.twMerge?t:((!b$1.cachedTwMerge||b$1.didTwMergeConfigChange)&&(b$1.didTwMergeConfigChange=false,b$1.cachedTwMerge=f(b$1.cachedTwMergeConfig)),b$1.cachedTwMerge(t)||void 0)};var {createTV:C,tv:T}=c(i);export{i as cn,C as createTV,T as tv};
1
+ import { getTailwindVariants, state } from './chunk-RZF76H2U.js';
2
+ export { defaultConfig } from './chunk-RZF76H2U.js';
3
+ import { cx, isEmptyObject } from './chunk-LQJYWU4O.js';
4
+ export { cx } from './chunk-LQJYWU4O.js';
5
+ import { twMerge, extendTailwindMerge } from 'tailwind-merge';
6
+
7
+ var createTwMerge = (cachedTwMergeConfig) => {
8
+ return isEmptyObject(cachedTwMergeConfig) ? twMerge : extendTailwindMerge({
9
+ ...cachedTwMergeConfig,
10
+ extend: {
11
+ theme: cachedTwMergeConfig.theme,
12
+ classGroups: cachedTwMergeConfig.classGroups,
13
+ conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
14
+ conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
15
+ ...cachedTwMergeConfig.extend
16
+ }
17
+ });
18
+ };
19
+ var cn = (...classnames) => {
20
+ const execute = (config) => {
21
+ const base = cx(classnames);
22
+ if (!base || !(config?.twMerge ?? true)) return base;
23
+ if (!state.cachedTwMerge || state.didTwMergeConfigChange) {
24
+ state.didTwMergeConfigChange = false;
25
+ state.cachedTwMerge = createTwMerge(state.cachedTwMergeConfig);
26
+ }
27
+ return state.cachedTwMerge(base) || void 0;
28
+ };
29
+ const defaultResult = execute({});
30
+ const fn = (config) => execute(config);
31
+ return new Proxy(fn, {
32
+ apply(target, thisArg, args) {
33
+ return target(...args);
34
+ },
35
+ get(target, prop) {
36
+ if (prop === Symbol.toPrimitive) {
37
+ return (hint) => {
38
+ if (hint === "string" || hint === "default") {
39
+ return defaultResult ?? "";
40
+ }
41
+ return defaultResult;
42
+ };
43
+ }
44
+ if (prop === "valueOf") {
45
+ return () => defaultResult;
46
+ }
47
+ if (prop === "toString") {
48
+ return () => String(defaultResult ?? "");
49
+ }
50
+ return target[prop];
51
+ }
52
+ });
53
+ };
54
+
55
+ // src/index.js
56
+ var { createTV, tv } = getTailwindVariants(cn);
57
+
58
+ export { cn, createTV, tv };
package/dist/lite.cjs CHANGED
@@ -1 +1,26 @@
1
- 'use strict';var chunkWBJQ6REG_cjs=require('./chunk-WBJQ6REG.cjs'),chunk7L2KNZGU_cjs=require('./chunk-7L2KNZGU.cjs');var o=(...e)=>a=>chunk7L2KNZGU_cjs.b(e)||void 0,{createTV:p,tv:m}=chunkWBJQ6REG_cjs.c(o);Object.defineProperty(exports,"defaultConfig",{enumerable:true,get:function(){return chunkWBJQ6REG_cjs.a}});Object.defineProperty(exports,"cn",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.b}});Object.defineProperty(exports,"cnBase",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.b}});exports.cnAdapter=o;exports.createTV=p;exports.tv=m;
1
+ 'use strict';
2
+
3
+ var chunk52Z2HSI4_cjs = require('./chunk-52Z2HSI4.cjs');
4
+ var chunk2JY7EID6_cjs = require('./chunk-2JY7EID6.cjs');
5
+
6
+ // src/lite.js
7
+ var cnAdapter = (...classnames) => {
8
+ return (_config) => {
9
+ const base = chunk2JY7EID6_cjs.cx(classnames);
10
+ return base || void 0;
11
+ };
12
+ };
13
+ var { createTV, tv } = chunk52Z2HSI4_cjs.getTailwindVariants(cnAdapter);
14
+
15
+ Object.defineProperty(exports, "defaultConfig", {
16
+ enumerable: true,
17
+ get: function () { return chunk52Z2HSI4_cjs.defaultConfig; }
18
+ });
19
+ Object.defineProperty(exports, "cx", {
20
+ enumerable: true,
21
+ get: function () { return chunk2JY7EID6_cjs.cx; }
22
+ });
23
+ exports.cn = cnAdapter;
24
+ exports.cnAdapter = cnAdapter;
25
+ exports.createTV = createTV;
26
+ exports.tv = tv;
package/dist/lite.d.ts CHANGED
@@ -3,9 +3,9 @@ import type {CnOptions, CnReturn, TVLite} from "./types.d.ts";
3
3
  export type * from "./types.d.ts";
4
4
 
5
5
  // util function
6
- export declare const cnBase: <T extends CnOptions>(...classes: T) => CnReturn;
6
+ export declare const cx: <T extends CnOptions>(...classes: T) => CnReturn;
7
7
 
8
- export declare const cn: <T extends CnOptions>(...classes: T) => CnReturn;
8
+ export declare const cn: <T extends CnOptions>(...classes: T) => (config?: any) => CnReturn;
9
9
 
10
10
  // main function
11
11
  export declare const tv: TVLite;
package/dist/lite.js CHANGED
@@ -1 +1,15 @@
1
- import {c}from'./chunk-IFWU2MEM.js';export{a as defaultConfig}from'./chunk-IFWU2MEM.js';import {b}from'./chunk-GQLG7IS2.js';export{b as cn,b as cnBase}from'./chunk-GQLG7IS2.js';var o=(...e)=>a=>b(e)||void 0,{createTV:p,tv:m}=c(o);export{o as cnAdapter,p as createTV,m as tv};
1
+ import { getTailwindVariants } from './chunk-RZF76H2U.js';
2
+ export { defaultConfig } from './chunk-RZF76H2U.js';
3
+ import { cx } from './chunk-LQJYWU4O.js';
4
+ export { cx } from './chunk-LQJYWU4O.js';
5
+
6
+ // src/lite.js
7
+ var cnAdapter = (...classnames) => {
8
+ return (_config) => {
9
+ const base = cx(classnames);
10
+ return base || void 0;
11
+ };
12
+ };
13
+ var { createTV, tv } = getTailwindVariants(cnAdapter);
14
+
15
+ export { cnAdapter as cn, cnAdapter, createTV, tv };
package/dist/types.d.ts CHANGED
@@ -331,8 +331,6 @@ export type TVLite = {
331
331
  }): TVReturnType<V, S, B, EV, ES, E>;
332
332
  };
333
333
 
334
- export declare const defaultConfig: TVConfig;
335
-
336
334
  export type VariantProps<Component extends (...args: any) => any> = Omit<
337
335
  OmitUndefined<Parameters<Component>[0]>,
338
336
  "class" | "className"
package/dist/utils.cjs CHANGED
@@ -1 +1,50 @@
1
- 'use strict';var chunk7L2KNZGU_cjs=require('./chunk-7L2KNZGU.cjs');Object.defineProperty(exports,"cn",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.b}});Object.defineProperty(exports,"falsyToString",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.c}});Object.defineProperty(exports,"flat",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.h}});Object.defineProperty(exports,"flatArray",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.i}});Object.defineProperty(exports,"flatMergeArrays",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.j}});Object.defineProperty(exports,"isBoolean",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.f}});Object.defineProperty(exports,"isEmptyObject",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.d}});Object.defineProperty(exports,"isEqual",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.e}});Object.defineProperty(exports,"joinObjects",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.g}});Object.defineProperty(exports,"mergeObjects",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.k}});Object.defineProperty(exports,"removeExtraSpaces",{enumerable:true,get:function(){return chunk7L2KNZGU_cjs.a}});
1
+ 'use strict';
2
+
3
+ var chunk2JY7EID6_cjs = require('./chunk-2JY7EID6.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "cx", {
8
+ enumerable: true,
9
+ get: function () { return chunk2JY7EID6_cjs.cx; }
10
+ });
11
+ Object.defineProperty(exports, "falsyToString", {
12
+ enumerable: true,
13
+ get: function () { return chunk2JY7EID6_cjs.falsyToString; }
14
+ });
15
+ Object.defineProperty(exports, "flat", {
16
+ enumerable: true,
17
+ get: function () { return chunk2JY7EID6_cjs.flat; }
18
+ });
19
+ Object.defineProperty(exports, "flatArray", {
20
+ enumerable: true,
21
+ get: function () { return chunk2JY7EID6_cjs.flatArray; }
22
+ });
23
+ Object.defineProperty(exports, "flatMergeArrays", {
24
+ enumerable: true,
25
+ get: function () { return chunk2JY7EID6_cjs.flatMergeArrays; }
26
+ });
27
+ Object.defineProperty(exports, "isBoolean", {
28
+ enumerable: true,
29
+ get: function () { return chunk2JY7EID6_cjs.isBoolean; }
30
+ });
31
+ Object.defineProperty(exports, "isEmptyObject", {
32
+ enumerable: true,
33
+ get: function () { return chunk2JY7EID6_cjs.isEmptyObject; }
34
+ });
35
+ Object.defineProperty(exports, "isEqual", {
36
+ enumerable: true,
37
+ get: function () { return chunk2JY7EID6_cjs.isEqual; }
38
+ });
39
+ Object.defineProperty(exports, "joinObjects", {
40
+ enumerable: true,
41
+ get: function () { return chunk2JY7EID6_cjs.joinObjects; }
42
+ });
43
+ Object.defineProperty(exports, "mergeObjects", {
44
+ enumerable: true,
45
+ get: function () { return chunk2JY7EID6_cjs.mergeObjects; }
46
+ });
47
+ Object.defineProperty(exports, "removeExtraSpaces", {
48
+ enumerable: true,
49
+ get: function () { return chunk2JY7EID6_cjs.removeExtraSpaces; }
50
+ });
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type {TWMConfig} from "./config.d.ts";
2
1
  import type {CnOptions, CnReturn} from "./types.d.ts";
3
2
 
4
3
  export declare const falsyToString: <T>(value: T) => T | string;
@@ -30,4 +29,4 @@ export declare const joinObjects: <
30
29
 
31
30
  export declare const flat: <T>(arr: unknown[], target: T[]) => void;
32
31
 
33
- export declare const cn: <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;
32
+ export declare const cx: <T extends CnOptions>(...classes: T) => CnReturn;
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export{b as cn,c as falsyToString,h as flat,i as flatArray,j as flatMergeArrays,f as isBoolean,d as isEmptyObject,e as isEqual,g as joinObjects,k as mergeObjects,a as removeExtraSpaces}from'./chunk-GQLG7IS2.js';
1
+ export { cx, falsyToString, flat, flatArray, flatMergeArrays, isBoolean, isEmptyObject, isEqual, joinObjects, mergeObjects, removeExtraSpaces } from './chunk-LQJYWU4O.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "keywords": [
6
6
  "tailwindcss",
@@ -1 +0,0 @@
1
- 'use strict';var y=/\s+/g,a=t=>typeof t!="string"||!t?t:t.replace(y," ").trim(),u=(...t)=>{let r=[],n=e=>{if(!e&&e!==0&&e!==0n)return;if(Array.isArray(e)){for(let s=0,o=e.length;s<o;s++)n(e[s]);return}let f=typeof e;if(f==="string"||f==="number"||f==="bigint"){if(f==="number"&&e!==e)return;r.push(String(e));}else if(f==="object"){let s=Object.keys(e);for(let o=0,i=s.length;o<i;o++){let l=s[o];e[l]&&r.push(l);}}};for(let e=0,f=t.length;e<f;e++){let s=t[e];s!=null&&n(s);}return r.length>0?a(r.join(" ")):void 0},h=t=>t===false?"false":t===true?"true":t===0?"0":t,x=t=>{if(!t||typeof t!="object")return true;for(let r in t)return false;return true},k=(t,r)=>{if(t===r)return true;if(!t||!r)return false;let n=Object.keys(t),e=Object.keys(r);if(n.length!==e.length)return false;for(let f=0;f<n.length;f++){let s=n[f];if(!e.includes(s)||t[s]!==r[s])return false}return true},A=t=>t===true||t===false,d=(t,r)=>{for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)){let e=r[n];n in t?t[n]=u(t[n],e):t[n]=e;}return t},c=(t,r)=>{for(let n=0;n<t.length;n++){let e=t[n];Array.isArray(e)?c(e,r):e&&r.push(e);}};function O(t){let r=[];return c(t,r),r}var g=(...t)=>{let r=[];c(t,r);let n=[];for(let e=0;e<r.length;e++)r[e]&&n.push(r[e]);return n},p=(t,r)=>{let n={};for(let e in t){let f=t[e];if(e in r){let s=r[e];Array.isArray(f)||Array.isArray(s)?n[e]=g(s,f):typeof f=="object"&&typeof s=="object"&&f&&s?n[e]=p(f,s):n[e]=s+" "+f;}else n[e]=f;}for(let e in r)e in t||(n[e]=r[e]);return n};exports.a=a;exports.b=u;exports.c=h;exports.d=x;exports.e=k;exports.f=A;exports.g=d;exports.h=c;exports.i=O;exports.j=g;exports.k=p;
@@ -1 +0,0 @@
1
- var y=/\s+/g,a=t=>typeof t!="string"||!t?t:t.replace(y," ").trim(),u=(...t)=>{let r=[],n=e=>{if(!e&&e!==0&&e!==0n)return;if(Array.isArray(e)){for(let s=0,o=e.length;s<o;s++)n(e[s]);return}let f=typeof e;if(f==="string"||f==="number"||f==="bigint"){if(f==="number"&&e!==e)return;r.push(String(e));}else if(f==="object"){let s=Object.keys(e);for(let o=0,i=s.length;o<i;o++){let l=s[o];e[l]&&r.push(l);}}};for(let e=0,f=t.length;e<f;e++){let s=t[e];s!=null&&n(s);}return r.length>0?a(r.join(" ")):void 0},h=t=>t===false?"false":t===true?"true":t===0?"0":t,x=t=>{if(!t||typeof t!="object")return true;for(let r in t)return false;return true},k=(t,r)=>{if(t===r)return true;if(!t||!r)return false;let n=Object.keys(t),e=Object.keys(r);if(n.length!==e.length)return false;for(let f=0;f<n.length;f++){let s=n[f];if(!e.includes(s)||t[s]!==r[s])return false}return true},A=t=>t===true||t===false,d=(t,r)=>{for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)){let e=r[n];n in t?t[n]=u(t[n],e):t[n]=e;}return t},c=(t,r)=>{for(let n=0;n<t.length;n++){let e=t[n];Array.isArray(e)?c(e,r):e&&r.push(e);}};function O(t){let r=[];return c(t,r),r}var g=(...t)=>{let r=[];c(t,r);let n=[];for(let e=0;e<r.length;e++)r[e]&&n.push(r[e]);return n},p=(t,r)=>{let n={};for(let e in t){let f=t[e];if(e in r){let s=r[e];Array.isArray(f)||Array.isArray(s)?n[e]=g(s,f):typeof f=="object"&&typeof s=="object"&&f&&s?n[e]=p(f,s):n[e]=s+" "+f;}else n[e]=f;}for(let e in r)e in t||(n[e]=r[e]);return n};export{a,u as b,h as c,x as d,k as e,A as f,d as g,c as h,O as i,g as j,p as k};
@@ -1 +0,0 @@
1
- import {k,b,d,e,g,j,c,a}from'./chunk-GQLG7IS2.js';var Q={twMerge:true,twMergeConfig:{},responsiveVariants:false};function ne(){let b=null,w={},A=false;return {get cachedTwMerge(){return b},set cachedTwMerge(u){b=u;},get cachedTwMergeConfig(){return w},set cachedTwMergeConfig(u){w=u;},get didTwMergeConfigChange(){return A},set didTwMergeConfigChange(u){A=u;},reset(){b=null,w={},A=false;}}}var S=ne();var le=b$1=>{let w=(u,$)=>{let{extend:c$1=null,slots:M={},variants:q={},compoundVariants:L=[],compoundSlots:v=[],defaultVariants:U={}}=u,d$1={...Q,...$},x=c$1?.base?b(c$1.base,u?.base):u?.base,p=c$1?.variants&&!d(c$1.variants)?k(q,c$1.variants):q,E=c$1?.defaultVariants&&!d(c$1.defaultVariants)?{...c$1.defaultVariants,...U}:U;!d(d$1.twMergeConfig)&&!e(d$1.twMergeConfig,S.cachedTwMergeConfig)&&(S.didTwMergeConfigChange=true,S.cachedTwMergeConfig=d$1.twMergeConfig);let N=d(c$1?.slots),O=d(M)?{}:{base:b(u?.base,N&&c$1?.base),...M},j$1=N?O:g({...c$1?.slots},d(O)?{base:u?.base}:O),T=d(c$1?.compoundVariants)?L:j(c$1?.compoundVariants,L),y=h=>{if(d(p)&&d(M)&&N)return b$1(x,h?.class,h?.className)(d$1);if(T&&!Array.isArray(T))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof T}`);if(v&&!Array.isArray(v))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof v}`);let Y=(t,e,n=[],a$1)=>{let r=n;if(typeof e=="string"){let i=a(e).split(" ");for(let l=0;l<i.length;l++)r.push(`${t}:${i[l]}`);}else if(Array.isArray(e))for(let s=0;s<e.length;s++)r.push(`${t}:${e[s]}`);else if(typeof e=="object"&&typeof a$1=="string"&&a$1 in e){let s=e[a$1];if(s&&typeof s=="string"){let l=a(s).split(" "),f=[];for(let o=0;o<l.length;o++)f.push(`${t}:${l[o]}`);r[a$1]=r[a$1]?r[a$1].concat(f):f;}else if(Array.isArray(s)&&s.length>0){let i=[];for(let l=0;l<s.length;l++)i.push(`${t}:${s[l]}`);r[a$1]=i;}}return r},W=(t,e=p,n=null,a=null)=>{let r=e[t];if(!r||d(r))return null;let s=a?.[t]??h?.[t];if(s===null)return null;let i=c(s),l=Array.isArray(d$1.responsiveVariants)&&d$1.responsiveVariants.length>0||d$1.responsiveVariants===true,f=E?.[t],o=[];if(typeof i=="object"&&l)for(let[C,H]of Object.entries(i)){let te=r[H];if(C==="initial"){f=H;continue}Array.isArray(d$1.responsiveVariants)&&!d$1.responsiveVariants.includes(C)||(o=Y(C,te,o,n));}let V=i!=null&&typeof i!="object"?i:c(f),m=r[V||"false"];return typeof o=="object"&&typeof n=="string"&&o[n]?g(o,m):o.length>0?(o.push(m),n==="base"?o.join(" "):o):m},Z=()=>{if(!p)return null;let t=Object.keys(p),e=[];for(let n=0;n<t.length;n++){let a=W(t[n],p);a&&e.push(a);}return e},_=(t,e)=>{if(!p||typeof p!="object")return null;let n=[];for(let a in p){let r=W(a,p,t,e),s=t==="base"&&typeof r=="string"?r:r&&r[t];s&&n.push(s);}return n},z={};for(let t in h){let e=h[t];e!==void 0&&(z[t]=e);}let D=(t,e)=>{let n=typeof h?.[t]=="object"?{[t]:h[t]?.initial}:{};return {...E,...z,...n,...e}},G=(t=[],e)=>{let n=[],a=t.length;for(let r=0;r<a;r++){let{class:s,className:i,...l}=t[r],f=true,o=D(null,e);for(let V in l){let m=l[V],C=o[V];if(Array.isArray(m)){if(!m.includes(C)){f=false;break}}else {if((m==null||m===false)&&(C==null||C===false))continue;if(C!==m){f=false;break}}}f&&(s&&n.push(s),i&&n.push(i));}return n},K=t=>{let e=G(T,t);if(!Array.isArray(e))return e;let n={},a=b$1;for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="string")n.base=a(n.base,s)(d$1);else if(typeof s=="object")for(let i in s)n[i]=a(n[i],s[i])(d$1);}return n},ee=t=>{if(v.length<1)return null;let e={},n=D(null,t);for(let a=0;a<v.length;a++){let{slots:r=[],class:s,className:i,...l}=v[a];if(!d(l)){let f=true;for(let o in l){let V=n[o],m=l[o];if(V===void 0||(Array.isArray(m)?!m.includes(V):m!==V)){f=false;break}}if(!f)continue}for(let f=0;f<r.length;f++){let o=r[f];e[o]||(e[o]=[]),e[o].push([s,i]);}}return e};if(!d(M)||!N){let t={};if(typeof j$1=="object"&&!d(j$1)){let e=b$1;for(let n in j$1)t[n]=a=>{let r=K(a),s=ee(a);return e(j$1[n],_(n,a),r?r[n]:void 0,s?s[n]:void 0,a?.class,a?.className)(d$1)};}return t}return b$1(x,Z(),G(T),h?.class,h?.className)(d$1)},X=()=>{if(!(!p||typeof p!="object"))return Object.keys(p)};return y.variantKeys=X(),y.extend=c$1,y.base=x,y.slots=j$1,y.variants=p,y.defaultVariants=E,y.compoundSlots=v,y.compoundVariants=T,y};return {tv:w,createTV:u=>($,c)=>w($,c?k(u,c):u)}};export{Q as a,S as b,le as c};
@@ -1 +0,0 @@
1
- 'use strict';var chunk7L2KNZGU_cjs=require('./chunk-7L2KNZGU.cjs');var Q={twMerge:true,twMergeConfig:{},responsiveVariants:false};function ne(){let b=null,w={},A=false;return {get cachedTwMerge(){return b},set cachedTwMerge(u){b=u;},get cachedTwMergeConfig(){return w},set cachedTwMergeConfig(u){w=u;},get didTwMergeConfigChange(){return A},set didTwMergeConfigChange(u){A=u;},reset(){b=null,w={},A=false;}}}var S=ne();var le=b=>{let w=(u,$)=>{let{extend:c=null,slots:M={},variants:q={},compoundVariants:L=[],compoundSlots:v=[],defaultVariants:U={}}=u,d={...Q,...$},x=c?.base?chunk7L2KNZGU_cjs.b(c.base,u?.base):u?.base,p=c?.variants&&!chunk7L2KNZGU_cjs.d(c.variants)?chunk7L2KNZGU_cjs.k(q,c.variants):q,E=c?.defaultVariants&&!chunk7L2KNZGU_cjs.d(c.defaultVariants)?{...c.defaultVariants,...U}:U;!chunk7L2KNZGU_cjs.d(d.twMergeConfig)&&!chunk7L2KNZGU_cjs.e(d.twMergeConfig,S.cachedTwMergeConfig)&&(S.didTwMergeConfigChange=true,S.cachedTwMergeConfig=d.twMergeConfig);let N=chunk7L2KNZGU_cjs.d(c?.slots),O=chunk7L2KNZGU_cjs.d(M)?{}:{base:chunk7L2KNZGU_cjs.b(u?.base,N&&c?.base),...M},j=N?O:chunk7L2KNZGU_cjs.g({...c?.slots},chunk7L2KNZGU_cjs.d(O)?{base:u?.base}:O),T=chunk7L2KNZGU_cjs.d(c?.compoundVariants)?L:chunk7L2KNZGU_cjs.j(c?.compoundVariants,L),y=h=>{if(chunk7L2KNZGU_cjs.d(p)&&chunk7L2KNZGU_cjs.d(M)&&N)return b(x,h?.class,h?.className)(d);if(T&&!Array.isArray(T))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof T}`);if(v&&!Array.isArray(v))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof v}`);let Y=(t,e,n=[],a)=>{let r=n;if(typeof e=="string"){let i=chunk7L2KNZGU_cjs.a(e).split(" ");for(let l=0;l<i.length;l++)r.push(`${t}:${i[l]}`);}else if(Array.isArray(e))for(let s=0;s<e.length;s++)r.push(`${t}:${e[s]}`);else if(typeof e=="object"&&typeof a=="string"&&a in e){let s=e[a];if(s&&typeof s=="string"){let l=chunk7L2KNZGU_cjs.a(s).split(" "),f=[];for(let o=0;o<l.length;o++)f.push(`${t}:${l[o]}`);r[a]=r[a]?r[a].concat(f):f;}else if(Array.isArray(s)&&s.length>0){let i=[];for(let l=0;l<s.length;l++)i.push(`${t}:${s[l]}`);r[a]=i;}}return r},W=(t,e=p,n=null,a=null)=>{let r=e[t];if(!r||chunk7L2KNZGU_cjs.d(r))return null;let s=a?.[t]??h?.[t];if(s===null)return null;let i=chunk7L2KNZGU_cjs.c(s),l=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===true,f=E?.[t],o=[];if(typeof i=="object"&&l)for(let[C,H]of Object.entries(i)){let te=r[H];if(C==="initial"){f=H;continue}Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(C)||(o=Y(C,te,o,n));}let V=i!=null&&typeof i!="object"?i:chunk7L2KNZGU_cjs.c(f),m=r[V||"false"];return typeof o=="object"&&typeof n=="string"&&o[n]?chunk7L2KNZGU_cjs.g(o,m):o.length>0?(o.push(m),n==="base"?o.join(" "):o):m},Z=()=>{if(!p)return null;let t=Object.keys(p),e=[];for(let n=0;n<t.length;n++){let a=W(t[n],p);a&&e.push(a);}return e},_=(t,e)=>{if(!p||typeof p!="object")return null;let n=[];for(let a in p){let r=W(a,p,t,e),s=t==="base"&&typeof r=="string"?r:r&&r[t];s&&n.push(s);}return n},z={};for(let t in h){let e=h[t];e!==void 0&&(z[t]=e);}let D=(t,e)=>{let n=typeof h?.[t]=="object"?{[t]:h[t]?.initial}:{};return {...E,...z,...n,...e}},G=(t=[],e)=>{let n=[],a=t.length;for(let r=0;r<a;r++){let{class:s,className:i,...l}=t[r],f=true,o=D(null,e);for(let V in l){let m=l[V],C=o[V];if(Array.isArray(m)){if(!m.includes(C)){f=false;break}}else {if((m==null||m===false)&&(C==null||C===false))continue;if(C!==m){f=false;break}}}f&&(s&&n.push(s),i&&n.push(i));}return n},K=t=>{let e=G(T,t);if(!Array.isArray(e))return e;let n={},a=b;for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="string")n.base=a(n.base,s)(d);else if(typeof s=="object")for(let i in s)n[i]=a(n[i],s[i])(d);}return n},ee=t=>{if(v.length<1)return null;let e={},n=D(null,t);for(let a=0;a<v.length;a++){let{slots:r=[],class:s,className:i,...l}=v[a];if(!chunk7L2KNZGU_cjs.d(l)){let f=true;for(let o in l){let V=n[o],m=l[o];if(V===void 0||(Array.isArray(m)?!m.includes(V):m!==V)){f=false;break}}if(!f)continue}for(let f=0;f<r.length;f++){let o=r[f];e[o]||(e[o]=[]),e[o].push([s,i]);}}return e};if(!chunk7L2KNZGU_cjs.d(M)||!N){let t={};if(typeof j=="object"&&!chunk7L2KNZGU_cjs.d(j)){let e=b;for(let n in j)t[n]=a=>{let r=K(a),s=ee(a);return e(j[n],_(n,a),r?r[n]:void 0,s?s[n]:void 0,a?.class,a?.className)(d)};}return t}return b(x,Z(),G(T),h?.class,h?.className)(d)},X=()=>{if(!(!p||typeof p!="object"))return Object.keys(p)};return y.variantKeys=X(),y.extend=c,y.base=x,y.slots=j,y.variants=p,y.defaultVariants=E,y.compoundSlots=v,y.compoundVariants=T,y};return {tv:w,createTV:u=>($,c)=>w($,c?chunk7L2KNZGU_cjs.k(u,c):u)}};exports.a=Q;exports.b=S;exports.c=le;