Skip to content

Commit

Permalink
Merge pull request #1951 from adevinta/fix-chip-ts
Browse files Browse the repository at this point in the history
fix(chip): update TS related things for forthcoming @react/types update
  • Loading branch information
acd02 authored Mar 12, 2024
2 parents 2f5ea34 + bf5dd29 commit a032c2a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 4 additions & 10 deletions packages/components/chip/src/Chip.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, { ButtonHTMLAttributes, forwardRef, PropsWithChildren, Ref } from 'react'
import React, { ComponentPropsWithoutRef, forwardRef } from 'react'

import { chipStyles, type ChipStylesProps } from './Chip.styles'
import { ChipContext } from './useChipContext'
import { useChipElement } from './useChipElement'

export interface ChipProps
extends PropsWithChildren<
Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onClick' | 'disabled'>
>,
Omit<ChipStylesProps, 'hasClearButton'> {
type ChipPrimitiveProps = Omit<ComponentPropsWithoutRef<'button'>, 'onClick' | 'disabled' | 'type'>

export interface ChipProps extends ChipPrimitiveProps, Omit<ChipStylesProps, 'hasClearButton'> {
/**
* Configures a toggleButton aria-pressed initial value
*/
Expand All @@ -32,10 +30,6 @@ export interface ChipProps
* Clear chip handler
*/
onClear?: (event?: React.MouseEvent<HTMLButtonElement>) => void
/**
* Pass react ref from the outside
*/
ref?: Ref<HTMLButtonElement | HTMLDivElement>
}

export const Chip = forwardRef<HTMLButtonElement | HTMLDivElement, ChipProps>(
Expand Down
6 changes: 4 additions & 2 deletions packages/components/chip/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react'
import { ComponentProps, FC } from 'react'

import { Chip as Root, type ChipProps } from './Chip'
import { Chip as Root } from './Chip'
import { ChipClearButton } from './ChipClearButton'
import { ChipContent } from './ChipContent'
import { ChipLeadingIcon } from './ChipLeadingIcon'
Expand All @@ -11,6 +11,8 @@ export { type ChipContentProps } from './ChipContent'
export { type ChipLeadingIconProps } from './ChipLeadingIcon'
export { type ChipTrailingIconProps } from './ChipTrailingIcon'

type ChipProps = ComponentProps<typeof Root>

export const Chip: FC<ChipProps> & {
Content: typeof ChipContent
LeadingIcon: typeof ChipLeadingIcon
Expand Down

0 comments on commit a032c2a

Please sign in to comment.