'use client'; import * as React from 'react'; import { Icon20CheckBoxOff, Icon20CheckBoxOn, Icon20CheckCircleOff, Icon20CheckCircleOn, Icon24CheckBoxOff, Icon24CheckBoxOn, Icon24CheckCircleOff, Icon24CheckCircleOn, } from '@vkontakte/icons'; import { classNames } from '@vkontakte/vkjs'; import { usePlatform } from '../../../hooks/usePlatform'; import type { HasRef, HasRootRef } from '../../../types'; import { AdaptiveIconRenderer } from '../../AdaptiveIconRenderer/AdaptiveIconRenderer'; import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden'; import type { CellProps } from '../Cell'; import styles from './CellCheckbox.module.css'; const CheckBoxOn = () => ( ); const CheckBoxOff = () => ( ); const CheckCircleOn = () => ( ); const CheckCircleOff = () => ( ); function useTypeIcon(type: NonNullable) { const platform = usePlatform(); if (type !== 'auto') { return type; } if (platform === 'ios' || platform === 'vkcom') { return 'circle'; } return 'square'; } export interface CellCheckboxProps extends Pick, React.InputHTMLAttributes, HasRootRef, HasRef { /** * Вид чекбокса. Если auto, то зависит от платформы. */ type?: 'auto' | 'circle' | 'square'; } export const CellCheckbox = ({ getRootRef, getRef, className, style, type = 'auto', ...restProps }: CellCheckboxProps): React.ReactNode => { const typeIcon = useTypeIcon(type); const IconOff = typeIcon === 'circle' ? CheckCircleOff : CheckBoxOff; const IconOn = typeIcon === 'circle' ? CheckCircleOn : CheckBoxOn; return ( ); };