import { Show } from "solid-js"; import { Progress } from "../Progress"; import { useClassList } from "../utils/useProps"; export interface WordCountProps { classList?: any; class?: string; style?: any; total: number; value: string; prefix?: any; prefixOverflow?: any; suffix?: any; suffixOverflow?: any; circle?: boolean; overflow?: boolean; radius?: number; } export function WordCount (props: WordCountProps) { const overflow = () => { const val = props.value ?? ''; return val.length > props.total; } const overNumber = () => { const val = props.value ?? ''; return props.overflow && overflow() ? val.length - props.total : val.length; } const percent = () => { const val = props.value ?? ''; return Math.min(val.length / props.total * 100, 100); } const radius = props.radius ?? 10; const classList = () => useClassList(props, 'cm-word-count'); return
{overflow() ? props.prefixOverflow : props.prefix} {overNumber()} / {props.total} {overflow() ? props.suffixOverflow : props.suffix} }>
}