/
kaws
/
ui-kit-ce
Обзор
Документация
Войти
/
kaws
/
ui-kit-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/card/src/utils.ts
57 строк
1 KB
Урядышев Павел Александрович
chore: устранены предупреждения eslint
25 июл 2025, 14:03
25 июл 2025, 14:03
1bad2f7
Код
Авторство
О чём код?
import { ButtonAriaActionEventHandler } from '@v-uik/hooks' import { CardKindProps, CardSelectableProps, CardClickableProps } from './types' import type { ComponentPropsWithRefFix } from '@v-uik/common' import { CardKind } from './constants' export const isSelectable = ( value: CardKindProps ): value is CardSelectableProps => value.kind === CardKind.selectable export const isClickable = ( value: CardKindProps ): value is CardClickableProps => value.kind === CardKind.clickable export const getInputProps = ( props: CardKindProps ): ComponentPropsWithRefFix<'input'> | undefined => { if (!isSelectable(props)) { return undefined } return { checked: props.checked, onChange: props?.onChange, name: props.name, ...(props?.inputProps ?? {}), } } export const getClickableProps = ( props: CardKindProps ): | (Omit<ComponentPropsWithRefFix<'div'>, 'onClick'> & { /** * */ onClick?: ButtonAriaActionEventHandler<HTMLDivElement> }) | undefined => { if (!isClickable(props)) { return undefined } return { ...props.buttonProps, onClick: props?.onClick, } } export const getOmittedParams = (props: CardKindProps): string[] => { if (isSelectable(props)) { return ['checked', 'onChange', 'inputProps', 'kind', 'disabled'] } else if (isClickable(props)) { return ['kind', 'buttonProps', 'onClick', 'disabled'] } return ['kind'] }