feat(input): add asChild on InputFrame
This commit is contained in:
parent
ec574d3841
commit
80c7542803
@ -1,4 +1,4 @@
|
||||
import { type VariantProps, vcn } from "@pswui-lib";
|
||||
import { type AsChild, Slot, type VariantProps, vcn } from "@pswui-lib";
|
||||
import React from "react";
|
||||
|
||||
const inputColors = {
|
||||
@ -42,7 +42,8 @@ const [inputVariant, resolveInputVariantProps] = vcn({
|
||||
|
||||
interface InputFrameProps
|
||||
extends VariantProps<typeof inputVariant>,
|
||||
React.ComponentPropsWithoutRef<"label"> {
|
||||
React.ComponentPropsWithoutRef<"label">,
|
||||
AsChild {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
@ -50,16 +51,18 @@ const InputFrame = React.forwardRef<HTMLLabelElement, InputFrameProps>(
|
||||
(props, ref) => {
|
||||
const [variantProps, otherPropsCompressed] =
|
||||
resolveInputVariantProps(props);
|
||||
const { children, ...otherPropsExtracted } = otherPropsCompressed;
|
||||
const { children, asChild, ...otherPropsExtracted } = otherPropsCompressed;
|
||||
|
||||
const Comp = asChild ? Slot : "label";
|
||||
|
||||
return (
|
||||
<label
|
||||
<Comp
|
||||
ref={ref}
|
||||
className={`group/input-frame ${inputVariant(variantProps)}`}
|
||||
{...otherPropsExtracted}
|
||||
>
|
||||
{children}
|
||||
</label>
|
||||
</Comp>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user