@nextui-org/system-rsc
Advanced tools
Comparing version 0.0.0-dev-v2-20231106112951 to 0.0.0-dev-v2-20231108142354
@@ -71,4 +71,33 @@ "use strict"; | ||
} | ||
function getClassNamesWithProps({ props, defaultVariants, customTv, hasSlots }) { | ||
var _a; | ||
function getClassNamesWithProps({ | ||
props = {}, | ||
variants, | ||
slots, | ||
defaultVariants, | ||
compoundVariants, | ||
hasSlots, | ||
opts | ||
}) { | ||
var _a, _b, _c; | ||
if (defaultVariants && typeof defaultVariants === "object") { | ||
for (const key in defaultVariants) { | ||
const value = defaultVariants[key]; | ||
const propValue = props == null ? void 0 : props[key]; | ||
if (propValue && propValue !== value) { | ||
delete defaultVariants[key]; | ||
} | ||
} | ||
} | ||
const customTv = (0, import_theme.tv)( | ||
{ | ||
variants, | ||
defaultVariants, | ||
compoundVariants, | ||
...hasSlots && { slots } | ||
}, | ||
{ | ||
twMerge: (_a = opts.twMerge) != null ? _a : true, | ||
twMergeConfig: (_b = opts.twMergeConfig) != null ? _b : {} | ||
} | ||
); | ||
const [baseProps, variantProps] = mapPropsVariants(props, customTv.variantKeys, false); | ||
@@ -87,3 +116,3 @@ const newProps = { ...defaultVariants, ...baseProps }; | ||
}); | ||
Object.entries((_a = props.classNames) != null ? _a : {}).forEach(([key, value]) => { | ||
Object.entries((_c = props.classNames) != null ? _c : {}).forEach(([key, value]) => { | ||
classNames[key] = cn(classNames[key], value); | ||
@@ -98,25 +127,20 @@ }); | ||
function extendVariants(BaseComponent, styles = {}, opts = {}) { | ||
var _a, _b; | ||
const { variants, defaultVariants, compoundVariants } = styles || {}; | ||
const slots = getSlots(variants); | ||
const hasSlots = typeof slots === "object" && Object.keys(slots).length !== 0; | ||
const customTv = (0, import_theme.tv)( | ||
{ | ||
variants, | ||
defaultVariants, | ||
compoundVariants, | ||
...hasSlots && { slots } | ||
}, | ||
{ | ||
twMerge: (_a = opts.twMerge) != null ? _a : true, | ||
twMergeConfig: (_b = opts.twMergeConfig) != null ? _b : {} | ||
} | ||
); | ||
const ForwardedComponent = React.forwardRef((originalProps = {}, ref) => { | ||
const newProps = getClassNamesWithProps({ | ||
props: originalProps, | ||
defaultVariants, | ||
customTv, | ||
hasSlots | ||
}); | ||
const newProps = React.useMemo( | ||
() => getClassNamesWithProps( | ||
{ | ||
slots, | ||
variants, | ||
compoundVariants, | ||
props: originalProps, | ||
defaultVariants, | ||
hasSlots, | ||
opts | ||
}, | ||
[originalProps] | ||
) | ||
); | ||
return React.createElement(BaseComponent, { ...originalProps, ...newProps, ref }); | ||
@@ -127,6 +151,9 @@ }); | ||
const newProps = getClassNamesWithProps({ | ||
slots, | ||
variants, | ||
compoundVariants, | ||
props: itemProps, | ||
defaultVariants, | ||
customTv, | ||
hasSlots | ||
hasSlots, | ||
opts | ||
}); | ||
@@ -133,0 +160,0 @@ return BaseComponent.getCollectionNode({ ...itemProps, ...newProps }); |
@@ -107,4 +107,33 @@ "use strict"; | ||
} | ||
function getClassNamesWithProps({ props, defaultVariants, customTv, hasSlots }) { | ||
var _a; | ||
function getClassNamesWithProps({ | ||
props = {}, | ||
variants, | ||
slots, | ||
defaultVariants, | ||
compoundVariants, | ||
hasSlots, | ||
opts | ||
}) { | ||
var _a, _b, _c; | ||
if (defaultVariants && typeof defaultVariants === "object") { | ||
for (const key in defaultVariants) { | ||
const value = defaultVariants[key]; | ||
const propValue = props == null ? void 0 : props[key]; | ||
if (propValue && propValue !== value) { | ||
delete defaultVariants[key]; | ||
} | ||
} | ||
} | ||
const customTv = (0, import_theme.tv)( | ||
{ | ||
variants, | ||
defaultVariants, | ||
compoundVariants, | ||
...hasSlots && { slots } | ||
}, | ||
{ | ||
twMerge: (_a = opts.twMerge) != null ? _a : true, | ||
twMergeConfig: (_b = opts.twMergeConfig) != null ? _b : {} | ||
} | ||
); | ||
const [baseProps, variantProps] = mapPropsVariants(props, customTv.variantKeys, false); | ||
@@ -123,3 +152,3 @@ const newProps = { ...defaultVariants, ...baseProps }; | ||
}); | ||
Object.entries((_a = props.classNames) != null ? _a : {}).forEach(([key, value]) => { | ||
Object.entries((_c = props.classNames) != null ? _c : {}).forEach(([key, value]) => { | ||
classNames[key] = cn(classNames[key], value); | ||
@@ -134,25 +163,20 @@ }); | ||
function extendVariants(BaseComponent, styles = {}, opts = {}) { | ||
var _a, _b; | ||
const { variants, defaultVariants, compoundVariants } = styles || {}; | ||
const slots = getSlots(variants); | ||
const hasSlots = typeof slots === "object" && Object.keys(slots).length !== 0; | ||
const customTv = (0, import_theme.tv)( | ||
{ | ||
variants, | ||
defaultVariants, | ||
compoundVariants, | ||
...hasSlots && { slots } | ||
}, | ||
{ | ||
twMerge: (_a = opts.twMerge) != null ? _a : true, | ||
twMergeConfig: (_b = opts.twMergeConfig) != null ? _b : {} | ||
} | ||
); | ||
const ForwardedComponent = React.forwardRef((originalProps = {}, ref) => { | ||
const newProps = getClassNamesWithProps({ | ||
props: originalProps, | ||
defaultVariants, | ||
customTv, | ||
hasSlots | ||
}); | ||
const newProps = React.useMemo( | ||
() => getClassNamesWithProps( | ||
{ | ||
slots, | ||
variants, | ||
compoundVariants, | ||
props: originalProps, | ||
defaultVariants, | ||
hasSlots, | ||
opts | ||
}, | ||
[originalProps] | ||
) | ||
); | ||
return React.createElement(BaseComponent, { ...originalProps, ...newProps, ref }); | ||
@@ -163,6 +187,9 @@ }); | ||
const newProps = getClassNamesWithProps({ | ||
slots, | ||
variants, | ||
compoundVariants, | ||
props: itemProps, | ||
defaultVariants, | ||
customTv, | ||
hasSlots | ||
hasSlots, | ||
opts | ||
}); | ||
@@ -169,0 +196,0 @@ return BaseComponent.getCollectionNode({ ...itemProps, ...newProps }); |
{ | ||
"name": "@nextui-org/system-rsc", | ||
"version": "0.0.0-dev-v2-20231106112951", | ||
"version": "0.0.0-dev-v2-20231108142354", | ||
"description": "NextUI system primitives compatibles with RSC imports", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"react": ">=18", | ||
"@nextui-org/theme": "0.0.0-dev-v2-20231106112951", | ||
"@nextui-org/theme": "0.0.0-dev-v2-20231108142354", | ||
"tailwind-variants": ">=0.1.13" | ||
@@ -32,0 +32,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35626
944