mirror of
https://github.com/directus/directus.git
synced 2026-02-15 05:05:06 -05:00
* Fix unexpected camera update and unavailable clustering option in map layout. * lint warning * Use defaultSort ref instead of value. Co-authored-by: Azri Kahar <azrikahar@outlook.com>
13 lines
346 B
TypeScript
13 lines
346 B
TypeScript
import { computed, Ref, unref } from 'vue';
|
|
|
|
export function syncRefProperty<R, T extends keyof R>(ref: Ref<R>, key: T, defaultValue: R[T] | Ref<R[T]>) {
|
|
return computed<R[T]>({
|
|
get() {
|
|
return ref.value?.[key] ?? unref(defaultValue);
|
|
},
|
|
set(value: R[T]) {
|
|
ref.value = Object.assign({}, ref.value, { [key]: value }) as R;
|
|
},
|
|
});
|
|
}
|