@tw-classed/core
Advanced tools
Comparing version 1.6.0 to 1.7.0-canary.0
@@ -27,3 +27,3 @@ /** Narrowed function. */ | ||
}>; | ||
compoundVariants: Record<string, any>[]; | ||
compoundVariants?: Record<string, any>[]; | ||
dataAttributes?: string[]; | ||
@@ -42,3 +42,3 @@ defaultProps?: Record<string, unknown>; | ||
type InferVariantProps<V extends Variants | unknown | undefined = undefined> = V extends Variants ? Partial<{ | ||
[K in keyof V]: Widen<keyof V[K]>; | ||
[K in keyof V]: Widen<keyof V[K]> | undefined; | ||
}> : {}; | ||
@@ -105,2 +105,5 @@ interface PropsWithClass { | ||
declare const classed: ClassedCoreFunctionType; | ||
declare function getVariantConfig<T extends { | ||
[$$ClassedVariants]: {}; | ||
}>(component: T): T[typeof $$ClassedVariants]; | ||
@@ -134,2 +137,2 @@ declare const parseClassNames: <TVariants extends Variants>(classNames: any[]) => { | ||
export { $$ClassedProps, $$ClassedVariants, type BooleanVariant, type ClassNamesAndVariant, type ClassedCoreConfig, type ClassedCoreFunctionType, type ClassedProducer, type ClassedProps, type ClassedType, type ClassedVariants, type CreateClassedCoreType, type InferVariantProps, TW_VARS, type Variant, type VariantConfig, type VariantProps, type Variants, classed, createClassed, getCompoundVariantClasses, getDataAttributes, getVariantSelector, mapPropsToVariantClass, parseClassNames }; | ||
export { $$ClassedProps, $$ClassedVariants, type BooleanVariant, type ClassNamesAndVariant, type ClassedCoreConfig, type ClassedCoreFunctionType, type ClassedProducer, type ClassedProps, type ClassedType, type ClassedVariants, type CreateClassedCoreType, type InferVariantProps, TW_VARS, type Variant, type VariantConfig, type VariantProps, type Variants, classed, createClassed, getCompoundVariantClasses, getDataAttributes, getVariantConfig, getVariantSelector, mapPropsToVariantClass, parseClassNames }; |
@@ -141,3 +141,27 @@ /** | ||
const classed = createClassed().classed; | ||
/** | ||
* @param component - The component to get the variant configuration for. | ||
* @returns The variant configuration for the given component. | ||
* @example | ||
* const button = classed("button", { | ||
* variants: { | ||
* size: { | ||
* sm: "text-sm", | ||
* md: "text-md", | ||
* }, | ||
* }, | ||
* }); | ||
* | ||
* const { variants } = getVariantConfig(button); | ||
* | ||
* expect(variants).toEqual({ | ||
* size: { | ||
* sm: "text-sm", | ||
* md: "text-md", | ||
* }, | ||
* }); | ||
*/ function getVariantConfig(component) { | ||
return Reflect.get(component, TW_VARS); | ||
} | ||
export { TW_VARS, classed, createClassed, getCompoundVariantClasses, getDataAttributes, getVariantSelector, mapPropsToVariantClass, parseClassNames }; | ||
export { TW_VARS, classed, createClassed, getCompoundVariantClasses, getDataAttributes, getVariantConfig, getVariantSelector, mapPropsToVariantClass, parseClassNames }; |
{ | ||
"name": "@tw-classed/core", | ||
"version": "1.6.0", | ||
"version": "1.7.0-canary.0", | ||
"description": "A Stitches & Styled-Components inspired library to create reusable Tailwind react components", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42487
623
1