You've already forked AstralRinth
Replace useAutoRef with Vue's toRef (#1332)
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
export type AutoRef<T> = [T] extends [(...args: any[]) => any]
|
||||
? Ref<T> | (() => T)
|
||||
: T | Ref<T> | (() => T);
|
||||
|
||||
/**
|
||||
* Accepts a value directly, a ref with the value or a getter function and returns a Vue ref.
|
||||
* @param value The value to use.
|
||||
* @returns Either the original or newly created ref.
|
||||
*/
|
||||
export function useAutoRef<T>(value: AutoRef<T>): Ref<T> {
|
||||
if (typeof value === "function") return computed(() => value());
|
||||
return isRef(value) ? value : ref(value as any);
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { useAutoRef, type AutoRef } from "./auto-ref.ts";
|
||||
|
||||
const safeTags = new Map<string, string>();
|
||||
|
||||
function safeTagFor(locale: string) {
|
||||
@@ -81,11 +79,14 @@ export function createDisplayNames(
|
||||
}
|
||||
|
||||
export function useDisplayNames(
|
||||
locale: AutoRef<string>,
|
||||
options?: AutoRef<Intl.DisplayNamesOptions | undefined>,
|
||||
locale: string | (() => string) | Ref<string>,
|
||||
options?:
|
||||
| (Intl.DisplayNamesOptions | undefined)
|
||||
| (() => Intl.DisplayNamesOptions | undefined)
|
||||
| Ref<Intl.DisplayNamesOptions | undefined>,
|
||||
) {
|
||||
const $locale = useAutoRef(locale);
|
||||
const $options = useAutoRef(options);
|
||||
const $locale = toRef(locale);
|
||||
const $options = toRef(options);
|
||||
|
||||
return computed(() => createDisplayNames($locale.value, $options.value));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user