import { makeComponentProps } from '@/composables/component' import { makeTagProps } from '@/composables/tag' import { genericComponent, propsFactory } from '@/utils' import { ref, computed, PropType, ExtractPropTypes } from 'vue' import { UTableHeaderText, UCheckbox } from '@/components' import Sizes from '../../types/sizes' export const makeUTableHeaderCellProps = propsFactory( { color: { type: String, default: 'white', required: false, }, isChecked: { type: [Boolean, undefined] as PropType, default: undefined, required: false, }, isDisabled: { type: Boolean, required: false, }, text: { type: String, default: '', required: false, }, prependIcon: { type: [String, undefined] as PropType, default: undefined, required: false, }, appendIcon: { type: [String, undefined] as PropType, default: undefined, required: false, }, align: { type: String, required: false, }, width: { type: String, required: false, }, height: { type: String, default: '44', required: false, }, ...makeComponentProps(), ...makeTagProps(), }, 'UTableHeaderCell' ) export type UTableHeaderCellProps = ExtractPropTypes< typeof makeUTableHeaderCellProps > export type UTableHeaderCellSlots = { default: never } export const UTableHeaderCell = genericComponent()({ name: 'UTableHeaderCell', props: makeUTableHeaderCellProps(), emits: { change: (value: boolean) => true, }, setup(props, { emit, slots }) { const isHovered = ref(false) const alignClasses = computed(() => { let classes = '' if (props.align === 'left') { classes = 'justify-start' } else if (props.align === 'center') { classes = 'justify-center' } else { classes = 'justify-end' } return classes }) const containerClasses = computed(() => ({ [`flex ${alignClasses.value} items-center`]: true, })) const switchCheckbox = (newValue: boolean) => { emit('change', newValue) } return () => (
(isHovered.value = true)} onMouseleave={() => (isHovered.value = false)} > {props.isChecked !== undefined ? ( ) : null} {props.text ? ( {props.text} ) : null}
) }, }) export type UTableHeaderCell = InstanceType