RuralDatabase/packages/ui/lib/utils.ts

16 lines
447 B
TypeScript
Raw Permalink Normal View History

2024-06-30 21:39:37 +08:00
import { type ClassValue, clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
2024-07-05 02:07:18 +08:00
import type { Updater } from '@tanstack/vue-table'
import type { Ref } from 'vue'
2024-06-30 21:39:37 +08:00
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
2024-07-05 02:07:18 +08:00
export function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
ref.value
= typeof updaterOrValue === 'function'
? updaterOrValue(ref.value)
: updaterOrValue
}