@codefast/tailwind-variants 0.3.7-canary.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.
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var r in a)__webpack_require__.o(a,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:a[r]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{mergeVariantGroups:()=>mergeVariantGroups,mergeConfigurationSchemas:()=>mergeConfigurationSchemas});const utils_cjs_namespaceObject=require("../utilities/utils.cjs"),mergeVariantGroups=(e,a)=>{let r={...e};for(let e of Object.keys(a)){let t=a[e],_=r[e];void 0===_?r[e]=t:r[e]=(0,utils_cjs_namespaceObject.isSlotObjectType)(_)&&(0,utils_cjs_namespaceObject.isSlotObjectType)(t)?{..._,...t}:t}return r},mergeConfigurationSchemas=(e,a)=>{let r=(0,utils_cjs_namespaceObject.hasExtensionConfiguration)(e)&&e.extend?mergeConfigurationSchemas(e.extend.config,e):e,t=a.base?r.base?(0,utils_cjs_namespaceObject.cx)(r.base,a.base):a.base:r.base,_={...r.variants};if(a.variants)for(let e of Object.keys(a.variants)){let r=a.variants[e];_[e]=e in _?mergeVariantGroups(_[e],r):r}let s=(0,utils_cjs_namespaceObject.hasSlotConfiguration)(r)?r.slots:{},o=(0,utils_cjs_namespaceObject.hasSlotConfiguration)(a)?a.slots:{},n={...s,...o};return Object.keys(n).length>0?{base:t,compoundSlots:[...(0,utils_cjs_namespaceObject.hasSlotConfiguration)(r)&&Array.isArray(r.compoundSlots)?r.compoundSlots:[],...(0,utils_cjs_namespaceObject.hasSlotConfiguration)(a)&&Array.isArray(a.compoundSlots)?a.compoundSlots:[]],compoundVariants:[...r.compoundVariants??[],...a.compoundVariants??[]],defaultVariants:{...r.defaultVariants,...a.defaultVariants},slots:n,variants:_}:{base:t,compoundVariants:[...r.compoundVariants??[],...a.compoundVariants??[]],defaultVariants:{...r.defaultVariants,...a.defaultVariants},variants:_}};for(var __webpack_i__ in exports.mergeConfigurationSchemas=__webpack_exports__.mergeConfigurationSchemas,exports.mergeVariantGroups=__webpack_exports__.mergeVariantGroups,__webpack_exports__)-1===["mergeConfigurationSchemas","mergeVariantGroups"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Configuration Management Module
3
+ *
4
+ * This module handles the merging and processing of variant configurations.
5
+ * It provides utilities for combining base configurations with extensions,
6
+ * merging variant groups, and handling slot configurations.
7
+ */
8
+ import type { ClassValue, Configuration, ConfigurationSchema, ConfigurationWithSlots, ExtendedConfiguration, SlotConfigurationSchema } from "../types/types";
9
+ /**
10
+ * Merge two variant groups.
11
+ *
12
+ * This function combines variant groups from base and extension configurations.
13
+ * It handles slot object merging for complex variant definitions.
14
+ *
15
+ * @param baseVariantGroup - The base variant group to merge into
16
+ * @param extensionVariantGroup - The extension variant group to merge
17
+ * @returns The merged variant group
18
+ */
19
+ export declare const mergeVariantGroups: (baseVariantGroup: Record<string, ClassValue>, extensionVariantGroup: Record<string, ClassValue>) => Record<string, ClassValue>;
20
+ /**
21
+ * Merge configuration schemas.
22
+ *
23
+ * This function combines base and extension configurations, handling
24
+ * recursive extension resolution, variant merging, slot merging,
25
+ * and compound variant/slot combination.
26
+ *
27
+ * @param baseConfiguration - The base configuration to merge into
28
+ * @param extensionConfiguration - The extension configuration to merge
29
+ * @returns The merged configuration schema
30
+ */
31
+ export declare const mergeConfigurationSchemas: (baseConfiguration: Configuration<ConfigurationSchema> | ConfigurationWithSlots<ConfigurationSchema, SlotConfigurationSchema>, extensionConfiguration: Configuration<ConfigurationSchema> | ConfigurationWithSlots<ConfigurationSchema, SlotConfigurationSchema> | ExtendedConfiguration<ConfigurationSchema, ConfigurationSchema, SlotConfigurationSchema, SlotConfigurationSchema>) => Configuration<ConfigurationSchema> | ConfigurationWithSlots<ConfigurationSchema, SlotConfigurationSchema>;
@@ -0,0 +1 @@
1
+ import{cx as a,hasExtensionConfiguration as t,hasSlotConfiguration as s,isSlotObjectType as e}from"../utilities/utils.js";let o=(a,t)=>{let s={...a};for(let a of Object.keys(t)){let o=t[a],r=s[a];void 0===r?s[a]=o:s[a]=e(r)&&e(o)?{...r,...o}:o}return s},r=(e,n)=>{let i=t(e)&&e.extend?r(e.extend.config,e):e,l=n.base?i.base?a(i.base,n.base):n.base:i.base,u={...i.variants};if(n.variants)for(let a of Object.keys(n.variants)){let t=n.variants[a];u[a]=a in u?o(u[a],t):t}let d=s(i)?i.slots:{},c=s(n)?n.slots:{},m={...d,...c};return Object.keys(m).length>0?{base:l,compoundSlots:[...s(i)&&Array.isArray(i.compoundSlots)?i.compoundSlots:[],...s(n)&&Array.isArray(n.compoundSlots)?n.compoundSlots:[]],compoundVariants:[...i.compoundVariants??[],...n.compoundVariants??[]],defaultVariants:{...i.defaultVariants,...n.defaultVariants},slots:m,variants:u}:{base:l,compoundVariants:[...i.compoundVariants??[],...n.compoundVariants??[]],defaultVariants:{...i.defaultVariants,...n.defaultVariants},variants:u}};export{r as mergeConfigurationSchemas,o as mergeVariantGroups};
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{createTV:()=>createTV,tv:()=>tv});const external_config_cjs_namespaceObject=require("./config.cjs"),compound_cjs_namespaceObject=require("../processing/compound.cjs"),slots_cjs_namespaceObject=require("../processing/slots.cjs"),utils_cjs_namespaceObject=require("../utilities/utils.cjs"),handleRegularVariantResolution=(e,t,r,_,a,c,s,n)=>{let o=[];for(let _ of(e&&o.push(e),Object.keys(t))){let e,c=t[_],s=a[_];if(void 0===s){let t=r[_];void 0!==t?e="string"==typeof t?t:String(t):(0,utils_cjs_namespaceObject.isBooleanVariantType)(c)&&(e="false")}else e="string"==typeof s?s:String(s);void 0!==e&&e in c&&o.push(c[e])}if(_){let e=(0,compound_cjs_namespaceObject.applyCompoundVariantClasses)(_,a,r);o.push(...e)}if(c&&o.push(c),0===o.length)return;let i=(0,utils_cjs_namespaceObject.cx)(...o);return s?n(i):i||void 0};function tv(e,t={}){let{twMerge:r=!0,twMergeConfig:_}=t,a=(0,utils_cjs_namespaceObject.createTailwindMergeService)(_),c=(0,utils_cjs_namespaceObject.hasExtensionConfiguration)(e)&&e.extend?(0,external_config_cjs_namespaceObject.mergeConfigurationSchemas)(e.extend.config,e):e,s=c.base,n=(0,utils_cjs_namespaceObject.hasSlotConfiguration)(c)?c.slots:void 0,o=c.variants??{},i=c.defaultVariants??{},p=c.compoundVariants,u=(e={})=>{let t=e.class,_=e.className;if(c.compoundVariants&&!Array.isArray(c.compoundVariants))throw Error("compoundVariants must be an array");if(!n)return handleRegularVariantResolution(s,o,i,p,e,_??t,r,a);{let t=(0,compound_cjs_namespaceObject.applyCompoundSlotClasses)((0,utils_cjs_namespaceObject.hasSlotConfiguration)(c)?c.compoundSlots:void 0,e,i);return(0,slots_cjs_namespaceObject.createSlotFunctionFactory)(n,s,o,i,p,t,e,r,a)}};return Object.defineProperty(u,"config",{configurable:!1,enumerable:!1,value:c,writable:!1}),u}function createTV(e={}){let{twMerge:t=!0,twMergeConfig:r}=e,_=(0,utils_cjs_namespaceObject.createTailwindMergeService)(r);return{cn:(...e)=>t?_((0,utils_cjs_namespaceObject.cx)(...e)):(0,utils_cjs_namespaceObject.cx)(...e),tv:function(t,r){return tv(t,{...e,...r})}}}for(var __webpack_i__ in exports.createTV=__webpack_exports__.createTV,exports.tv=__webpack_exports__.tv,__webpack_exports__)-1===["createTV","tv"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Tailwind Variants Core Implementation
3
+ *
4
+ * This module contains the main implementation of the Tailwind Variants system.
5
+ * It provides functions to create variant-based styling functions with support
6
+ * for slots, compound variants, and configuration merging.
7
+ */
8
+ import type { Configuration, ConfigurationSchema, ConfigurationWithSlots, ExtendedConfiguration, MergedSchemas, MergedSlotSchemas, SlotConfigurationSchema, TailwindVariantsConfiguration, TailwindVariantsFactoryResult, VariantFunctionType } from "../types/types";
9
+ /**
10
+ * Create a Tailwind Variants function for regular components.
11
+ *
12
+ * This function creates a variant-based styling function for components
13
+ * that don't use slots. It provides type-safe variant handling with
14
+ * support for compound variants and configuration merging.
15
+ *
16
+ * @param config - The variant configuration object
17
+ * @param tvConfig - Optional Tailwind Variants configuration
18
+ * @returns A variant function for the component
19
+ */
20
+ export declare function tv<T extends ConfigurationSchema>(config: Configuration<T>, tvConfig?: TailwindVariantsConfiguration): VariantFunctionType<T, Record<string, never>>;
21
+ /**
22
+ * Create a Tailwind Variants function for slot-based components.
23
+ *
24
+ * This overload creates a variant function for components that use slots
25
+ * but don't have regular variants. It provides type-safe slot handling.
26
+ *
27
+ * @param config - The slot configuration object
28
+ * @param tvConfig - Optional Tailwind Variants configuration
29
+ * @returns A variant function with slot support
30
+ */
31
+ export declare function tv<S extends SlotConfigurationSchema>(config: ConfigurationWithSlots<Record<string, never>, S>, tvConfig?: TailwindVariantsConfiguration): VariantFunctionType<Record<string, never>, S>;
32
+ /**
33
+ * Create a Tailwind Variants function for components with both variants and slots.
34
+ *
35
+ * This overload creates a variant function for components that have both
36
+ * regular variants and slots. It provides full type safety for both systems.
37
+ *
38
+ * @param config - The configuration object with variants and slots
39
+ * @param tvConfig - Optional Tailwind Variants configuration
40
+ * @returns A variant function with full variant and slot support
41
+ */
42
+ export declare function tv<T extends ConfigurationSchema, S extends SlotConfigurationSchema>(config: ConfigurationWithSlots<T, S>, tvConfig?: TailwindVariantsConfiguration): VariantFunctionType<T, S>;
43
+ /**
44
+ * Create a Tailwind Variants function with configuration extension.
45
+ *
46
+ * This overload creates a variant function that extends an existing
47
+ * configuration with additional variants and slots. It merges the
48
+ * base and extension configurations automatically.
49
+ *
50
+ * @param config - The extended configuration object
51
+ * @param tvConfig - Optional Tailwind Variants configuration
52
+ * @returns A variant function with merged configurations
53
+ */
54
+ export declare function tv<TBase extends ConfigurationSchema, TExtension extends ConfigurationSchema, SBase extends SlotConfigurationSchema, SExtension extends SlotConfigurationSchema>(config: ExtendedConfiguration<TBase, TExtension, SBase, SExtension>, tvConfig?: TailwindVariantsConfiguration): VariantFunctionType<MergedSchemas<TBase, TExtension>, MergedSlotSchemas<SBase, SExtension>>;
55
+ /**
56
+ * Create a Tailwind Variants factory with global configuration.
57
+ *
58
+ * This function creates a factory that can be used to create variant functions
59
+ * with a shared global configuration. It's useful for setting up consistent
60
+ * behavior across multiple components.
61
+ *
62
+ * @param globalConfiguration - The global configuration to apply
63
+ * @returns A factory object with `tv` and `cn` functions
64
+ */
65
+ export declare function createTV(globalConfiguration?: TailwindVariantsConfiguration): TailwindVariantsFactoryResult;
@@ -0,0 +1 @@
1
+ import{mergeConfigurationSchemas as t}from"./config.js";import{applyCompoundSlotClasses as r,applyCompoundVariantClasses as e}from"../processing/compound.js";import{createSlotFunctionFactory as o}from"../processing/slots.js";import{createTailwindMergeService as n,cx as i,hasExtensionConfiguration as s,hasSlotConfiguration as a,isBooleanVariantType as u}from"../utilities/utils.js";function l(f,c={}){let{twMerge:p=!0,twMergeConfig:m}=c,d=n(m),g=s(f)&&f.extend?t(f.extend.config,f):f,v=g.base,b=a(g)?g.slots:void 0,y=g.variants??{},h=g.defaultVariants??{},j=g.compoundVariants,V=(t={})=>{let n=t.class,s=t.className;if(g.compoundVariants&&!Array.isArray(g.compoundVariants))throw Error("compoundVariants must be an array");if(!b)return((t,r,o,n,s,a,l,f)=>{let c=[];for(let e of(t&&c.push(t),Object.keys(r))){let t,n=r[e],i=s[e];if(void 0===i){let r=o[e];void 0!==r?t="string"==typeof r?r:String(r):u(n)&&(t="false")}else t="string"==typeof i?i:String(i);void 0!==t&&t in n&&c.push(n[t])}if(n){let t=e(n,s,o);c.push(...t)}if(a&&c.push(a),0===c.length)return;let p=i(...c);return l?f(p):p||void 0})(v,y,h,j,t,s??n,p,d);{let e=r(a(g)?g.compoundSlots:void 0,t,h);return o(b,v,y,h,j,e,t,p,d)}};return Object.defineProperty(V,"config",{configurable:!1,enumerable:!1,value:g,writable:!1}),V}function f(t={}){let{twMerge:r=!0,twMergeConfig:e}=t,o=n(e);return{cn:(...t)=>r?o(i(...t)):i(...t),tv:function(r,e){return l(r,{...t,...e})}}}export{f as createTV,l as tv};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_)=>{for(var r in _)__webpack_require__.o(_,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:_[r]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{cx:()=>utils_cjs_namespaceObject.cx,cn:()=>utils_cjs_namespaceObject.cn,tv:()=>tv_cjs_namespaceObject.tv,createTV:()=>tv_cjs_namespaceObject.createTV});const tv_cjs_namespaceObject=require("./core/tv.cjs"),utils_cjs_namespaceObject=require("./utilities/utils.cjs");for(var __webpack_i__ in exports.cn=__webpack_exports__.cn,exports.createTV=__webpack_exports__.createTV,exports.cx=__webpack_exports__.cx,exports.tv=__webpack_exports__.tv,__webpack_exports__)-1===["cn","createTV","cx","tv"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Tailwind Variants Package
3
+ *
4
+ * This package provides a powerful utility for creating variant-based component styling
5
+ * with Tailwind CSS. It allows you to define component variants, slots, and compound
6
+ * variants in a type-safe manner.
7
+ */
8
+ /**
9
+ * Export the main Tailwind Variants factory functions.
10
+ *
11
+ * These functions allow you to create variant-based styling functions
12
+ * for your components with full TypeScript support.
13
+ */
14
+ export { createTV, tv } from "./core/tv";
15
+ /**
16
+ * Export utility functions for class name manipulation.
17
+ *
18
+ * These utilities help with merging and combining CSS classes
19
+ * in a consistent and type-safe way.
20
+ */
21
+ export { cn, cx } from "./utilities/utils";
22
+ /**
23
+ * Export TypeScript type definitions.
24
+ *
25
+ * These types provide full type safety for variant configurations,
26
+ * component props, and class value handling.
27
+ */
28
+ export type { BooleanVariantChecker, ClassValue, CompoundSlotType, CompoundVariantType, CompoundVariantWithSlotsType, Configuration, ConfigurationSchema, ConfigurationVariants, ConfigurationWithSlots, ExtendedConfiguration, MergedSchemas, MergedSlotSchemas, SlotConfigurationSchema, SlotFunctionProperties, SlotFunctionType, SlotProperties, StringToBooleanType, TailwindVariantsConfiguration, TailwindVariantsFactory, TailwindVariantsFactoryResult, TailwindVariantsReturnType, VariantFunctionType, VariantProps, } from "./types/types";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{createTV as t,tv as r}from"./core/tv.js";import{cn as i,cx as o}from"./utilities/utils.js";export{i as cn,t as createTV,o as cx,r as tv};
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,_)=>{for(var s in _)__webpack_require__.o(_,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:_[s]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{applyCompoundVariantClasses:()=>applyCompoundVariantClasses,applyCompoundSlotClasses:()=>applyCompoundSlotClasses});const utils_cjs_namespaceObject=require("../utilities/utils.cjs"),applyCompoundVariantClasses=(e,_,s)=>{let a=Object.keys(s).length>0,r=Object.keys(_).length>0,t=[];for(let o of e){let e=!0;for(let t of Object.keys(o)){let l;if("className"===t||"class"===t)continue;l=r&&void 0!==_[t]?_[t]:a&&void 0!==s[t]?s[t]:void 0;let p=o[t];if((0,utils_cjs_namespaceObject.isBooleanValueType)(p)){if((l??!1)!==p){e=!1;break}}else if(Array.isArray(p)){if(!p.includes(l)){e=!1;break}}else if(l!==p){e=!1;break}}e&&t.push(o.className??o.class)}return t},applyCompoundSlotClasses=(e,_,s)=>{if(!e?.length)return{};let a={...s,..._},r={};for(let _ of e){let e=!0;for(let[s,r]of Object.entries(_).filter(([e])=>"className"!==e&&"class"!==e&&"slots"!==e)){let _=a[s];if((0,utils_cjs_namespaceObject.isBooleanValueType)(r)){if((_??!1)!==r){e=!1;break}}else if(Array.isArray(r)){if(!r.includes(_)){e=!1;break}}else if(_!==r){e=!1;break}}if(e)for(let e of _.slots)(r[e]??=[]).push(_.className??_.class)}return r};for(var __webpack_i__ in exports.applyCompoundSlotClasses=__webpack_exports__.applyCompoundSlotClasses,exports.applyCompoundVariantClasses=__webpack_exports__.applyCompoundVariantClasses,__webpack_exports__)-1===["applyCompoundSlotClasses","applyCompoundVariantClasses"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Compound Variants Processing Module
3
+ *
4
+ * This module handles the processing of compound variants and compound slots.
5
+ * It provides functions to apply compound variant classes based on
6
+ * multiple variant conditions being met simultaneously.
7
+ */
8
+ import type { ClassValue, CompoundSlotType, CompoundVariantType, ConfigurationSchema, ConfigurationVariants, SlotConfigurationSchema } from "../types/types";
9
+ /**
10
+ * Apply compound variant classes based on variant conditions.
11
+ *
12
+ * This function processes compound variants and applies their classes when
13
+ * all specified variant conditions are met. It merges by default and provides
14
+ * variant props to determine which compound variants should be applied.
15
+ *
16
+ * @param compoundVariantGroups - Array of compound variant definitions
17
+ * @param variantProps - Variant properties passed to the component
18
+ * @param defaultVariantProps - Default variant properties from configuration
19
+ * @returns Array of CSS classes from matching compound variants
20
+ */
21
+ export declare const applyCompoundVariantClasses: <T extends ConfigurationSchema>(compoundVariantGroups: readonly CompoundVariantType<T>[], variantProps: ConfigurationVariants<T>, defaultVariantProps: ConfigurationVariants<T>) => ClassValue[];
22
+ /**
23
+ * Apply compound slot classes based on variant conditions.
24
+ *
25
+ * This function processes compound slots and applies their classes to
26
+ * specific slots when all specified variant conditions are met.
27
+ * It returns a mapping of slot names to their applied classes.
28
+ *
29
+ * @param compoundSlotDefinitions - Array of compound slot definitions
30
+ * @param variantProps - Variant properties passed to the component
31
+ * @param defaultVariantProps - Default variant properties from configuration
32
+ * @returns Object mapping slot names to arrays of CSS classes
33
+ */
34
+ export declare const applyCompoundSlotClasses: <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(compoundSlotDefinitions: readonly CompoundSlotType<T, S>[] | undefined, variantProps: ConfigurationVariants<T>, defaultVariantProps: ConfigurationVariants<T>) => Partial<Record<keyof S, ClassValue[]>>;
@@ -0,0 +1 @@
1
+ import{isBooleanValueType as e}from"../utilities/utils.js";let s=(s,l,t)=>{let r=Object.keys(t).length>0,i=Object.keys(l).length>0,a=[];for(let f of s){let s=!0;for(let a of Object.keys(f)){let o;if("className"===a||"class"===a)continue;o=i&&void 0!==l[a]?l[a]:r&&void 0!==t[a]?t[a]:void 0;let c=f[a];if(e(c)){if((o??!1)!==c){s=!1;break}}else if(Array.isArray(c)){if(!c.includes(o)){s=!1;break}}else if(o!==c){s=!1;break}}s&&a.push(f.className??f.class)}return a},l=(s,l,t)=>{if(!s?.length)return{};let r={...t,...l},i={};for(let l of s){let s=!0;for(let[t,i]of Object.entries(l).filter(([e])=>"className"!==e&&"class"!==e&&"slots"!==e)){let l=r[t];if(e(i)){if((l??!1)!==i){s=!1;break}}else if(Array.isArray(i)){if(!i.includes(l)){s=!1;break}}else if(l!==i){s=!1;break}}if(s)for(let e of l.slots)(i[e]??=[]).push(l.className??l.class)}return i};export{l as applyCompoundSlotClasses,s as applyCompoundVariantClasses};
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var _ in t)__webpack_require__.o(t,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:t[_]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{createSlotFunctionFactory:()=>createSlotFunctionFactory,resolveSlotClasses:()=>resolveSlotClasses});const utils_cjs_namespaceObject=require("../utilities/utils.cjs"),resolveSlotClasses=(e,t,_,s,r,o,a)=>{let l=[t],c={...r,...s};if(_)for(let t of Object.keys(_)){let s,o=_[t],a=c[t];if(void 0!==a?s=String(a):void 0!==r[t]?s=String(r[t]):(0,utils_cjs_namespaceObject.isBooleanVariantType)(o)&&(s="false"),s&&s in o){let t=o[s];if(t)if((0,utils_cjs_namespaceObject.isSlotObjectType)(t)){let _=t[e];void 0!==_&&l.push(_)}else"base"===e&&l.push(t)}}if(o?.length)for(let t of o){let _=!0;for(let e of Object.keys(t))if("className"!==e&&"class"!==e&&c[e]!==t[e]){_=!1;break}if(_){let _=t.className??t.class;if((0,utils_cjs_namespaceObject.isSlotObjectType)(_)){let t=_[e];void 0!==t&&l.push(t)}else"base"===e&&l.push(_)}}return l.push(...a),l},createSlotFunctionFactory=(e,t,_,s,r,o,a,l,c)=>{let i={};for(let n of(i.base=(i={})=>{let n=[...resolveSlotClasses("base",e.base??t,_,{...a,...i},s,r,o.base??[]),i.className,i.class].filter(Boolean);if(0===n.length)return;let p=(0,utils_cjs_namespaceObject.cx)(...n);return l?c(p):p||void 0},Object.keys(e)))"base"!==n&&(i[n]=(t={})=>{let i=[...resolveSlotClasses(n,e[n],_,{...a,...t},s,r,o[n]??[]),t.className,t.class].filter(Boolean);if(0===i.length)return;let p=(0,utils_cjs_namespaceObject.cx)(...i);return l?c(p):p||void 0});return i};for(var __webpack_i__ in exports.createSlotFunctionFactory=__webpack_exports__.createSlotFunctionFactory,exports.resolveSlotClasses=__webpack_exports__.resolveSlotClasses,__webpack_exports__)-1===["createSlotFunctionFactory","resolveSlotClasses"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Slot Functions Module
3
+ *
4
+ * This module handles the creation and processing of slot-based component functions.
5
+ * It provides utilities for resolving slot classes, creating slot function factories,
6
+ * and handling slot-specific variant processing.
7
+ */
8
+ import type { ClassValue, CompoundVariantWithSlotsType, ConfigurationSchema, ConfigurationVariants, SlotConfigurationSchema, SlotFunctionType } from "../types/types";
9
+ /**
10
+ * Resolve CSS classes for a specific slot.
11
+ *
12
+ * This function processes variant configurations and resolves the appropriate
13
+ * CSS classes for a specific slot, including base classes, variant classes,
14
+ * compound variant classes, and compound slot classes.
15
+ *
16
+ * @param targetSlotKey - The slot key to resolve classes for
17
+ * @param baseSlotClasses - Base CSS classes for the slot
18
+ * @param variantGroups - Variant group configurations
19
+ * @param variantProps - Variant properties passed to the component
20
+ * @param defaultVariantProps - Default variant properties from configuration
21
+ * @param compoundVariantGroups - Compound variant configurations with slots
22
+ * @param compoundSlotClasses - Pre-computed compound slot classes
23
+ * @returns Array of resolved CSS classes for the slot
24
+ */
25
+ export declare const resolveSlotClasses: <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(targetSlotKey: keyof S, baseSlotClasses: ClassValue, variantGroups: T | undefined, variantProps: ConfigurationVariants<T>, defaultVariantProps: ConfigurationVariants<T>, compoundVariantGroups: readonly CompoundVariantWithSlotsType<T, S>[] | undefined, compoundSlotClasses: ClassValue[]) => ClassValue[];
26
+ /**
27
+ * Create a factory for slot functions.
28
+ *
29
+ * This function creates individual slot functions that can generate CSS classes
30
+ * for each slot in a component. It handles base slots and named slots,
31
+ * processing variants, compound variants, and compound slots.
32
+ *
33
+ * @param mergedSlotDefinitions - The merged slot definitions
34
+ * @param mergedBaseClasses - Base CSS classes for the component
35
+ * @param mergedVariantGroups - Merged variant group configurations
36
+ * @param mergedDefaultVariantProps - Merged default variant properties
37
+ * @param mergedCompoundVariantGroups - Merged compound variant configurations
38
+ * @param compoundSlotClasses - Pre-computed compound slot classes
39
+ * @param variantProps - Variant properties passed to the component
40
+ * @param shouldMergeClasses - Whether to merge conflicting classes
41
+ * @param tailwindMergeService - The Tailwind merge service function
42
+ * @returns Object containing slot functions for each slot
43
+ */
44
+ export declare const createSlotFunctionFactory: <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(mergedSlotDefinitions: S, mergedBaseClasses: ClassValue | undefined, mergedVariantGroups: T, mergedDefaultVariantProps: ConfigurationVariants<T>, mergedCompoundVariantGroups: readonly CompoundVariantWithSlotsType<T, S>[] | undefined, compoundSlotClasses: Partial<Record<keyof S, ClassValue[]>>, variantProps: ConfigurationVariants<T>, shouldMergeClasses: boolean, tailwindMergeService: (classes: string) => string) => Record<keyof S, SlotFunctionType<T>> & {
45
+ base: SlotFunctionType<T>;
46
+ };
@@ -0,0 +1 @@
1
+ import{cx as e,isBooleanVariantType as t,isSlotObjectType as l}from"../utilities/utils.js";let s=(e,s,i,r,a,o,f)=>{let n=[s],c={...a,...r};if(i)for(let s of Object.keys(i)){let r,o=i[s],f=c[s];if(void 0!==f?r=String(f):void 0!==a[s]?r=String(a[s]):t(o)&&(r="false"),r&&r in o){let t=o[r];if(t)if(l(t)){let l=t[e];void 0!==l&&n.push(l)}else"base"===e&&n.push(t)}}if(o?.length)for(let t of o){let s=!0;for(let e of Object.keys(t))if("className"!==e&&"class"!==e&&c[e]!==t[e]){s=!1;break}if(s){let s=t.className??t.class;if(l(s)){let t=s[e];void 0!==t&&n.push(t)}else"base"===e&&n.push(s)}}return n.push(...f),n},i=(t,l,i,r,a,o,f,n,c)=>{let u={};for(let b of(u.base=(u={})=>{let b=[...s("base",t.base??l,i,{...f,...u},r,a,o.base??[]),u.className,u.class].filter(Boolean);if(0===b.length)return;let h=e(...b);return n?c(h):h||void 0},Object.keys(t)))"base"!==b&&(u[b]=(l={})=>{let u=[...s(b,t[b],i,{...f,...l},r,a,o[b]??[]),l.className,l.class].filter(Boolean);if(0===u.length)return;let h=e(...u);return n?c(h):h||void 0});return u};export{i as createSlotFunctionFactory,s as resolveSlotClasses};
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __webpack_i__ in __webpack_require__.r(__webpack_exports__),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Tailwind Variants Type Definitions
3
+ *
4
+ * This module contains all TypeScript type definitions for the Tailwind Variants system.
5
+ * It provides comprehensive type safety for variant configurations, component props,
6
+ * and class value handling throughout the package.
7
+ */
8
+ import type { ClassValue } from "clsx";
9
+ import type { ConfigExtension } from "tailwind-merge";
10
+ /**
11
+ * Convert string boolean values to actual boolean types.
12
+ *
13
+ * This utility type converts string representations of booleans ("true", "false")
14
+ * to actual boolean types, while preserving existing boolean types.
15
+ */
16
+ export type StringToBooleanType<T> = T extends "false" | "true" ? boolean : T extends boolean ? T : T;
17
+ /**
18
+ * Check if a variant group supports boolean values.
19
+ *
20
+ * This utility type determines whether a variant group has boolean keys
21
+ * ("true" or "false"), indicating it supports boolean variant values.
22
+ */
23
+ export type BooleanVariantChecker<T extends Record<string, unknown>> = "true" extends keyof T ? true : "false" extends keyof T ? true : false;
24
+ /**
25
+ * Extract variant props from a component or variant function.
26
+ *
27
+ * This utility type extracts the variant properties from a component or
28
+ * variant function, including className and class properties, while
29
+ * allowing for specific keys to be omitted.
30
+ */
31
+ export type VariantProps<Component> = Component extends VariantFunctionType<infer T> ? T extends Record<string, never> ? object : Omit<ConfigurationVariants<T>, "class" | "className"> : never;
32
+ /**
33
+ * Base configuration schema for variant groups.
34
+ *
35
+ * This type defines the structure of variant configurations where each
36
+ * variant group maps variant values to CSS class values.
37
+ */
38
+ export type ConfigurationSchema = Record<string, Record<string, ClassValue>>;
39
+ /**
40
+ * Configuration schema for component slots.
41
+ *
42
+ * This type defines the structure of slot configurations where each
43
+ * slot name maps to CSS class values.
44
+ */
45
+ export type SlotConfigurationSchema = Record<string, ClassValue>;
46
+ /**
47
+ * Variant properties for a configuration schema.
48
+ *
49
+ * This type defines the properties that can be passed to variant functions,
50
+ * including variant values and optional className/class properties.
51
+ */
52
+ export type ConfigurationVariants<T extends ConfigurationSchema> = {
53
+ readonly [Variant in keyof T]?: BooleanVariantChecker<T[Variant]> extends true ? boolean | StringToBooleanType<keyof T[Variant]> : StringToBooleanType<keyof T[Variant]>;
54
+ } & {
55
+ className?: ClassValue;
56
+ class?: ClassValue;
57
+ };
58
+ /**
59
+ * Properties for slot-based components.
60
+ *
61
+ * This type defines the properties that can be passed to slot functions,
62
+ * allowing each slot to receive custom CSS classes.
63
+ */
64
+ export type SlotProperties<S extends SlotConfigurationSchema> = {
65
+ readonly [Slot in keyof S]?: ClassValue;
66
+ };
67
+ /**
68
+ * Type for compound variant definitions.
69
+ *
70
+ * This type defines the structure of compound variants, which apply
71
+ * additional classes when multiple variant conditions are met.
72
+ */
73
+ export type CompoundVariantType<T extends ConfigurationSchema> = Partial<{
74
+ readonly [Variant in keyof T]: BooleanVariantChecker<T[Variant]> extends true ? boolean | readonly (boolean | StringToBooleanType<keyof T[Variant]>)[] | StringToBooleanType<keyof T[Variant]> : readonly StringToBooleanType<keyof T[Variant]>[] | StringToBooleanType<keyof T[Variant]>;
75
+ }> & {
76
+ className?: ClassValue;
77
+ class?: ClassValue;
78
+ };
79
+ /**
80
+ * Type for compound variants that support slots.
81
+ *
82
+ * This type extends compound variants to support slot-based class definitions,
83
+ * allowing different classes to be applied to different slots.
84
+ */
85
+ export type CompoundVariantWithSlotsType<T extends ConfigurationSchema, S extends SlotConfigurationSchema> = Partial<{
86
+ readonly [Variant in keyof T]: BooleanVariantChecker<T[Variant]> extends true ? boolean | readonly (boolean | StringToBooleanType<keyof T[Variant]>)[] | StringToBooleanType<keyof T[Variant]> : readonly StringToBooleanType<keyof T[Variant]>[] | StringToBooleanType<keyof T[Variant]>;
87
+ }> & {
88
+ className?: ClassValue | SlotProperties<S>;
89
+ class?: ClassValue | SlotProperties<S>;
90
+ };
91
+ /**
92
+ * Type for compound slot definitions.
93
+ *
94
+ * This type defines compound slots that apply classes to specific slots
95
+ * when certain variant conditions are met.
96
+ */
97
+ export type CompoundSlotType<T extends ConfigurationSchema, S extends SlotConfigurationSchema> = T extends Record<string, never> ? {
98
+ readonly slots: readonly (keyof S)[];
99
+ className?: ClassValue;
100
+ class?: ClassValue;
101
+ } : {
102
+ readonly slots: readonly (keyof S)[];
103
+ className?: ClassValue;
104
+ class?: ClassValue;
105
+ } & {
106
+ readonly [K in keyof T]?: BooleanVariantChecker<T[K]> extends true ? boolean | StringToBooleanType<keyof T[K]> : StringToBooleanType<keyof T[K]>;
107
+ };
108
+ /**
109
+ * Base configuration interface for variant functions.
110
+ *
111
+ * This interface defines the structure of variant configurations,
112
+ * including base classes, variants, default values, and compound variants.
113
+ */
114
+ export interface Configuration<T extends ConfigurationSchema> {
115
+ readonly base?: ClassValue;
116
+ readonly compoundVariants?: readonly CompoundVariantType<T>[];
117
+ readonly defaultVariants?: ConfigurationVariants<T>;
118
+ readonly variants?: T;
119
+ }
120
+ /**
121
+ * Configuration interface for slot-based components.
122
+ *
123
+ * This interface extends the base configuration to include slot definitions
124
+ * and slot-specific compound variants.
125
+ */
126
+ export interface ConfigurationWithSlots<T extends ConfigurationSchema, S extends SlotConfigurationSchema> {
127
+ readonly base?: ClassValue;
128
+ readonly compoundSlots?: readonly CompoundSlotType<T, S>[];
129
+ readonly compoundVariants?: readonly CompoundVariantWithSlotsType<T, S>[];
130
+ readonly defaultVariants?: ConfigurationVariants<T>;
131
+ readonly slots?: S;
132
+ readonly variants?: T;
133
+ }
134
+ /**
135
+ * Configuration options for Tailwind Variants.
136
+ *
137
+ * This interface defines global configuration options that affect
138
+ * how Tailwind Variants processes and merges CSS classes.
139
+ */
140
+ export interface TailwindVariantsConfiguration {
141
+ readonly twMerge?: boolean;
142
+ readonly twMergeConfig?: ConfigExtension<string, string>;
143
+ }
144
+ /**
145
+ * Type for individual slot functions.
146
+ *
147
+ * This type defines the signature of functions that generate CSS classes
148
+ * for individual component slots.
149
+ */
150
+ export type SlotFunctionType<T extends ConfigurationSchema> = (props?: SlotFunctionProperties<T>) => string | undefined;
151
+ /**
152
+ * Properties that can be passed to slot functions.
153
+ *
154
+ * This type defines the properties that can be passed to individual
155
+ * slot functions, including variant props and class properties.
156
+ */
157
+ export type SlotFunctionProperties<T extends ConfigurationSchema> = T extends Record<string, never> ? {
158
+ className?: ClassValue;
159
+ class?: ClassValue;
160
+ } : {
161
+ readonly [K in keyof ConfigurationVariants<T>]?: ConfigurationVariants<T>[K];
162
+ } & {
163
+ className?: ClassValue;
164
+ class?: ClassValue;
165
+ };
166
+ /**
167
+ * Return type for variant functions.
168
+ *
169
+ * This type defines the return type of variant functions, which can be
170
+ * either a single function (for non-slot components) or an object with
171
+ * slot functions (for slot-based components).
172
+ */
173
+ export type TailwindVariantsReturnType<T extends ConfigurationSchema, S extends SlotConfigurationSchema> = keyof S extends never ? SlotFunctionType<T> : {
174
+ readonly [K in keyof S]: SlotFunctionType<T>;
175
+ } & {
176
+ readonly base: SlotFunctionType<T>;
177
+ };
178
+ /**
179
+ * Main variant function type.
180
+ *
181
+ * This interface defines the structure of variant functions created by the tv function.
182
+ * It includes the configuration and the function signature for generating CSS classes.
183
+ */
184
+ export interface VariantFunctionType<T extends ConfigurationSchema, S extends SlotConfigurationSchema = SlotConfigurationSchema> {
185
+ config: Configuration<T> | ConfigurationWithSlots<T, S>;
186
+ (props?: ConfigurationVariants<T>): S extends Record<string, never> ? string | undefined : TailwindVariantsReturnType<T, S>;
187
+ }
188
+ /**
189
+ * Factory function interface for creating variant functions.
190
+ *
191
+ * This interface defines the overloaded factory function that can create
192
+ * variant functions with different configuration types and options.
193
+ */
194
+ export interface TailwindVariantsFactory {
195
+ <T extends ConfigurationSchema>(config: Configuration<T>, localConfig?: TailwindVariantsConfiguration): VariantFunctionType<T, Record<string, never>>;
196
+ <S extends SlotConfigurationSchema>(config: ConfigurationWithSlots<Record<string, never>, S>, localConfig?: TailwindVariantsConfiguration): VariantFunctionType<Record<string, never>, S>;
197
+ <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(config: ConfigurationWithSlots<T, S>, localConfig?: TailwindVariantsConfiguration): VariantFunctionType<T, S>;
198
+ <TBase extends ConfigurationSchema, TExtension extends ConfigurationSchema, SBase extends SlotConfigurationSchema, SExtension extends SlotConfigurationSchema>(config: ExtendedConfiguration<TBase, TExtension, SBase, SExtension>, localConfig?: TailwindVariantsConfiguration): VariantFunctionType<MergedSchemas<TBase, TExtension>, MergedSlotSchemas<SBase, SExtension>>;
199
+ }
200
+ /**
201
+ * Result interface for the createTV factory function.
202
+ *
203
+ * This interface defines the object returned by createTV, which includes
204
+ * both the tv factory function and the cn utility function.
205
+ */
206
+ export interface TailwindVariantsFactoryResult {
207
+ cn: (...classes: ClassValue[]) => string;
208
+ tv: TailwindVariantsFactory;
209
+ }
210
+ /**
211
+ * Type for merged configuration schemas.
212
+ *
213
+ * This utility type merges two configuration schemas into a single type,
214
+ * combining all variant groups from both schemas.
215
+ */
216
+ export type MergedSchemas<TBase extends ConfigurationSchema, TExtension extends ConfigurationSchema> = TBase & TExtension;
217
+ /**
218
+ * Type for merged slot configuration schemas.
219
+ *
220
+ * This utility type merges two slot configuration schemas into a single type,
221
+ * combining all slot definitions from both schemas.
222
+ */
223
+ export type MergedSlotSchemas<SBase extends SlotConfigurationSchema, SExtension extends SlotConfigurationSchema> = SBase & SExtension;
224
+ /**
225
+ * Configuration interface for extending existing configurations.
226
+ *
227
+ * This interface allows extending an existing variant configuration with
228
+ * additional variants and slots, while maintaining type safety.
229
+ */
230
+ export interface ExtendedConfiguration<TBase extends ConfigurationSchema, TExtension extends ConfigurationSchema, SBase extends SlotConfigurationSchema, SExtension extends SlotConfigurationSchema> {
231
+ readonly base?: ClassValue;
232
+ readonly compoundSlots?: readonly CompoundSlotType<MergedSchemas<TBase, TExtension>, MergedSlotSchemas<SBase, SExtension>>[];
233
+ readonly compoundVariants?: readonly CompoundVariantWithSlotsType<MergedSchemas<TBase, TExtension>, MergedSlotSchemas<SBase, SExtension>>[];
234
+ readonly defaultVariants?: ConfigurationVariants<MergedSchemas<TBase, TExtension>>;
235
+ readonly extend?: VariantFunctionType<TBase, SBase>;
236
+ readonly slots?: SExtension;
237
+ readonly variants?: TExtension;
238
+ }
239
+ /**
240
+ * Re-export ClassValue type from clsx for convenience.
241
+ *
242
+ * This type represents any value that can be converted to a CSS class string.
243
+ */
244
+ export type { ClassValue } from "clsx";
File without changes
@@ -0,0 +1 @@
1
+ "use strict";const __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:r[_]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{isBooleanValueType:()=>isBooleanValueType,hasSlotConfiguration:()=>hasSlotConfiguration,cx:()=>cx,cn:()=>cn,hasExtensionConfiguration:()=>hasExtensionConfiguration,createTailwindMergeService:()=>createTailwindMergeService,isBooleanVariantType:()=>isBooleanVariantType,isSlotObjectType:()=>isSlotObjectType});const external_clsx_namespaceObject=require("clsx"),external_tailwind_merge_namespaceObject=require("tailwind-merge"),cx=(...e)=>{if(0===e.length)return"";if(1===e.length){let r=e[0];if("string"==typeof r)return r;if(!r)return""}return(0,external_clsx_namespaceObject.clsx)(e)},cn=(...e)=>{if(0===e.length)return"";if(1===e.length){let r=e[0];if("string"==typeof r)return(0,external_tailwind_merge_namespaceObject.twMerge)(r);if(!r)return""}return(0,external_tailwind_merge_namespaceObject.twMerge)((0,external_clsx_namespaceObject.clsx)(e))},createTailwindMergeService=e=>e?(0,external_tailwind_merge_namespaceObject.extendTailwindMerge)(e):external_tailwind_merge_namespaceObject.twMerge,isSlotObjectType=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),isBooleanVariantType=e=>"true"in e||"false"in e,isBooleanValueType=e=>"boolean"==typeof e,hasSlotConfiguration=e=>"slots"in e&&void 0!==e.slots,hasExtensionConfiguration=e=>"extend"in e&&void 0!==e.extend;for(var __webpack_i__ in exports.cn=__webpack_exports__.cn,exports.createTailwindMergeService=__webpack_exports__.createTailwindMergeService,exports.cx=__webpack_exports__.cx,exports.hasExtensionConfiguration=__webpack_exports__.hasExtensionConfiguration,exports.hasSlotConfiguration=__webpack_exports__.hasSlotConfiguration,exports.isBooleanValueType=__webpack_exports__.isBooleanValueType,exports.isBooleanVariantType=__webpack_exports__.isBooleanVariantType,exports.isSlotObjectType=__webpack_exports__.isSlotObjectType,__webpack_exports__)-1===["cn","createTailwindMergeService","cx","hasExtensionConfiguration","hasSlotConfiguration","isBooleanValueType","isBooleanVariantType","isSlotObjectType"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Utility Functions Module
3
+ *
4
+ * This module provides utility functions for class name manipulation,
5
+ * type checking, and Tailwind merge configuration. It serves as the
6
+ * foundation for CSS class processing throughout the package.
7
+ */
8
+ import type { ConfigExtension } from "tailwind-merge";
9
+ import type { ClassValue, Configuration, ConfigurationSchema, ConfigurationWithSlots, ExtendedConfiguration, SlotConfigurationSchema } from "../types/types";
10
+ /**
11
+ * Combine CSS classes using clsx.
12
+ *
13
+ * This function provides a simple interface for combining CSS classes
14
+ * using the clsx library, which handles conditional classes and arrays.
15
+ *
16
+ * @param classes - CSS classes to combine
17
+ * @returns Combined CSS class string
18
+ */
19
+ export declare const cx: (...classes: ClassValue[]) => string;
20
+ /**
21
+ * Combine and merge CSS classes using Tailwind merge.
22
+ *
23
+ * This function combines CSS classes and then merges them using
24
+ * tailwind-merge to resolve conflicts and remove duplicates.
25
+ *
26
+ * @param classes - CSS classes to combine and merge
27
+ * @returns Merged CSS class string
28
+ */
29
+ export declare const cn: (...classes: ClassValue[]) => string;
30
+ /**
31
+ * Create a Tailwind merge service with optional configuration.
32
+ *
33
+ * This function creates a Tailwind merge service that can be configured
34
+ * with custom extensions for handling additional class patterns.
35
+ *
36
+ * @param configuration - Optional Tailwind merge configuration
37
+ * @returns Configured Tailwind merge function
38
+ */
39
+ export declare const createTailwindMergeService: (configuration?: ConfigExtension<string, string>) => ((classes: string) => string);
40
+ /**
41
+ * Check if a value is a slot object type.
42
+ *
43
+ * This function determines whether a ClassValue is an object that can
44
+ * contain slot-specific class definitions.
45
+ *
46
+ * @param value - The value to check
47
+ * @returns True if the value is a slot object
48
+ */
49
+ export declare const isSlotObjectType: (value: ClassValue) => value is Record<string, ClassValue>;
50
+ /**
51
+ * Check if a variant group supports boolean values.
52
+ *
53
+ * This function determines whether a variant group has boolean keys
54
+ * ("true" or "false"), indicating it can accept boolean variant values.
55
+ *
56
+ * @param variantGroup - The variant group to check
57
+ * @returns True if the variant group supports boolean values
58
+ */
59
+ export declare const isBooleanVariantType: <T extends Record<string, unknown>>(variantGroup: T) => variantGroup is T & (Record<"false", unknown> | Record<"true", unknown>);
60
+ /**
61
+ * Check if a value is a boolean type.
62
+ *
63
+ * This function provides a type guard to determine if a value
64
+ * is specifically a boolean type.
65
+ *
66
+ * @param value - The value to check
67
+ * @returns True if the value is a boolean
68
+ */
69
+ export declare const isBooleanValueType: (value: unknown) => value is boolean;
70
+ /**
71
+ * Check if a configuration has slot definitions.
72
+ *
73
+ * This function provides a type guard to determine if a configuration
74
+ * object includes slot definitions, enabling type-safe slot handling.
75
+ *
76
+ * @param configuration - The configuration to check
77
+ * @returns True if the configuration has slots
78
+ */
79
+ export declare const hasSlotConfiguration: <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(configuration: Configuration<T> | ConfigurationWithSlots<T, S>) => configuration is ConfigurationWithSlots<T, S>;
80
+ /**
81
+ * Check if a configuration has extension definitions.
82
+ *
83
+ * This function provides a type guard to determine if a configuration
84
+ * object includes extension definitions, enabling type-safe configuration
85
+ * merging and inheritance.
86
+ *
87
+ * @param configuration - The configuration to check
88
+ * @returns True if the configuration has extensions
89
+ */
90
+ export declare const hasExtensionConfiguration: <T extends ConfigurationSchema, S extends SlotConfigurationSchema>(configuration: Configuration<T> | ConfigurationWithSlots<T, S> | ExtendedConfiguration<ConfigurationSchema, T, SlotConfigurationSchema, S>) => configuration is ExtendedConfiguration<ConfigurationSchema, T, SlotConfigurationSchema, S>;
@@ -0,0 +1 @@
1
+ import{clsx as e}from"clsx";import{extendTailwindMerge as t,twMerge as r}from"tailwind-merge";let n=(...t)=>{if(0===t.length)return"";if(1===t.length){let e=t[0];if("string"==typeof e)return e;if(!e)return""}return e(t)},i=(...t)=>{if(0===t.length)return"";if(1===t.length){let e=t[0];if("string"==typeof e)return r(e);if(!e)return""}return r(e(t))},o=e=>e?t(e):r,l=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),f=e=>"true"in e||"false"in e,a=e=>"boolean"==typeof e,s=e=>"slots"in e&&void 0!==e.slots,u=e=>"extend"in e&&void 0!==e.extend;export{i as cn,o as createTailwindMergeService,n as cx,u as hasExtensionConfiguration,s as hasSlotConfiguration,a as isBooleanValueType,f as isBooleanVariantType,l as isSlotObjectType};