| | |
| | | import type { ComponentProps, FC } from 'react' |
| | | import { type ComponentProps, type FC, forwardRef } from 'react' |
| | | import classNames from '@/utils/classnames' |
| | | |
| | | const baseStyle = 'py-[3px]' |
| | | |
| | | export type SliceContainerProps = ComponentProps<'span'> |
| | | |
| | | export const SliceContainer: FC<SliceContainerProps> = ( |
| | | { |
| | | ref, |
| | | ...props |
| | | }, |
| | | ) => { |
| | | export const SliceContainer: FC<SliceContainerProps> = forwardRef((props, ref) => { |
| | | const { className, ...rest } = props |
| | | return <span {...rest} ref={ref} className={classNames( |
| | | 'group align-bottom mr-1 select-none text-sm', |
| | | className, |
| | | )} /> |
| | | } |
| | | }) |
| | | SliceContainer.displayName = 'SliceContainer' |
| | | |
| | | export type SliceLabelProps = ComponentProps<'span'> & { labelInnerClassName?: string } |
| | | |
| | | export const SliceLabel: FC<SliceLabelProps> = ( |
| | | { |
| | | ref, |
| | | ...props |
| | | }, |
| | | ) => { |
| | | export const SliceLabel: FC<SliceLabelProps> = forwardRef((props, ref) => { |
| | | const { className, children, labelInnerClassName, ...rest } = props |
| | | return <span {...rest} ref={ref} className={classNames( |
| | | baseStyle, |
| | |
| | | {children} |
| | | </span> |
| | | </span> |
| | | } |
| | | }) |
| | | SliceLabel.displayName = 'SliceLabel' |
| | | |
| | | export type SliceContentProps = ComponentProps<'span'> |
| | | |
| | | export const SliceContent: FC<SliceContentProps> = ( |
| | | { |
| | | ref, |
| | | ...props |
| | | }, |
| | | ) => { |
| | | export const SliceContent: FC<SliceContentProps> = forwardRef((props, ref) => { |
| | | const { className, children, ...rest } = props |
| | | return <span {...rest} ref={ref} className={classNames( |
| | | baseStyle, |
| | |
| | | )}> |
| | | {children} |
| | | </span> |
| | | } |
| | | }) |
| | | SliceContent.displayName = 'SliceContent' |
| | | |
| | | export type SliceDividerProps = ComponentProps<'span'> |
| | | |
| | | export const SliceDivider: FC<SliceDividerProps> = ( |
| | | { |
| | | ref, |
| | | ...props |
| | | }, |
| | | ) => { |
| | | export const SliceDivider: FC<SliceDividerProps> = forwardRef((props, ref) => { |
| | | const { className, ...rest } = props |
| | | return <span {...rest} ref={ref} className={classNames( |
| | | baseStyle, |
| | |
| | | {/* use a zero-width space to make the hover area bigger */} |
| | | ​ |
| | | </span> |
| | | } |
| | | }) |
| | | SliceDivider.displayName = 'SliceDivider' |