Skip to content

Commit

Permalink
fix(react): update prop asChild to label
Browse files Browse the repository at this point in the history
  • Loading branch information
johancs.mm@gmail.com committed May 6, 2024
1 parent 7247eb2 commit 16837d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/components/react/label/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Label from './label'

export type { Props as LabelProps } from './label'
export type { Props as LabelProps, Comp as LabelComponent } from './label'
export { Label }
32 changes: 16 additions & 16 deletions packages/components/react/label/label.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React from 'react'
import type * as LabelPrimitive from '@radix-ui/react-label'
import { cn, label } from '@openui-org/theme'
import type { VariantProps } from '@openui-org/theme'
import { Slot } from '@radix-ui/react-slot'
import type { VariantProps } from '@openui-org/theme'
import { cn, label } from '@openui-org/theme'

interface Comp extends React.ElementRef<typeof LabelPrimitive.Root> {}
export interface Props extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,
VariantProps<typeof label> {
export interface Comp extends HTMLLabelElement {}
export interface Props extends React.LabelHTMLAttributes<HTMLLabelElement>, VariantProps<typeof label> {
asChild?: boolean
}

const Label = React.forwardRef<Comp, Props>(({ className, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'label'
return (
<Comp
className={cn(label({ size, className }))}
ref={ref}
{...props}
/>
)
})
const Label = React.forwardRef<Comp, Props>(
({ className, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'label'
return (
<Comp
className={cn(label({ size, className }))}
ref={ref}
{...props}
/>
)
},
)

Label.displayName = 'Label'

Expand Down

0 comments on commit 16837d7

Please sign in to comment.