daisy-data-components
Version:
The "daisy-data-components" NPM package transforms general UI components from daisyUI into specialized "data components", such as Data Tables and Data Date Pickers, optimized for working with data-centric applications. It provides powerful functionality t
13 lines (11 loc) • 408 B
text/typescript
import {computed} from "vue";
import type {Ref, UnwrapRef} from "vue";
export function defineModel<T>(props: any, emits: any, name: string = 'modelValue'): Ref<UnwrapRef<T>> {
if (!props.hasOwnProperty(name)) {
throw new Error(`There is no property for key='${name}'`);
}
return computed({
get: () => props[name],
set: (value) => emits(`update:${name}`, value)
});
}