( props: RoundedProps | Ref<RoundedValue>, name = getCurrentInstanceName(), )
| 27 | }, 'rounded') |
| 28 | |
| 29 | export function useRounded ( |
| 30 | props: RoundedProps | Ref<RoundedValue>, |
| 31 | name = getCurrentInstanceName(), |
| 32 | ): RoundedData { |
| 33 | const roundedClasses = computed(() => { |
| 34 | const rounded = isRef(props) ? props.value : props.rounded |
| 35 | const tile = isRef(props) ? false : props.tile |
| 36 | const classes: string[] = [] |
| 37 | |
| 38 | if (tile || rounded === false) { |
| 39 | classes.push('rounded-0') |
| 40 | } else if (rounded === true || rounded === '') { |
| 41 | classes.push(`${name}--rounded`) |
| 42 | } else if (rounded === 0 || (typeof rounded === 'string' && (rounded === '0' || !/[0-9%]/.test(rounded) || /\d*xl$/.test(rounded)))) { |
| 43 | for (const value of String(rounded).split(' ')) { |
| 44 | classes.push(`rounded-${value}`) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | return classes |
| 49 | }) |
| 50 | |
| 51 | const roundedStyles = computed<CSSProperties>(() => { |
| 52 | const rounded = isRef(props) ? props.value : props.rounded |
| 53 | const roundedText = String(rounded) |
| 54 | |
| 55 | if (!/[0-9]/.test(roundedText) || |
| 56 | roundedText.includes('xl') || |
| 57 | roundedText === '0' |
| 58 | ) { |
| 59 | return {} |
| 60 | } |
| 61 | |
| 62 | return { borderRadius: convertToUnit(roundedText) } |
| 63 | }) |
| 64 | |
| 65 | return { roundedClasses, roundedStyles } |
| 66 | } |
no test coverage detected
searching dependent graphs…