p-sw 76ec211d81 refactor: update import statements in react components
Updated the import statements in multiple react components to use the new `@pswui-lib` package instead of the deprecated `@pswui-lib/shared@1.0.0`. This makes the code cleaner and easier
2024-06-11 17:51:26 +09:00

34 lines
904 B
TypeScript

import React from "react";
import { VariantProps, vcn } from "@pswui-lib";
const [labelVariant, resolveLabelVariantProps] = vcn({
base: "has-[input[disabled]]:brightness-75 has-[input[disabled]]:cursor-not-allowed has-[input:invalid]:text-red-500",
variants: {
direction: {
vertical: "flex flex-col gap-2 justify-center items-start",
horizontal: "flex flex-row gap-2 justify-start items-center",
},
},
defaults: {
direction: "vertical",
},
});
interface LabelProps
extends VariantProps<typeof labelVariant>,
React.ComponentPropsWithoutRef<"label"> {}
const Label = React.forwardRef<HTMLLabelElement, LabelProps>((props, ref) => {
const [variantProps, otherPropsCompressed] = resolveLabelVariantProps(props);
return (
<label
ref={ref}
{...otherPropsCompressed}
className={labelVariant(variantProps)}
/>
);
});
export { Label };