vue-useurl
Advanced tools
Comparing version 1.0.32 to 1.0.33
@@ -10,23 +10,23 @@ import { Ref, UnwrapRef, ComputedRef } from 'vue-demi'; | ||
queryParams?: MaybeReactive<IQueryParams>; | ||
hash?: MaybeRef<string | number>; | ||
disableCSV?: MaybeRef<boolean>; | ||
hash?: MaybeRef<string | number>; | ||
} | ||
export interface IBuilderResult { | ||
path: Ref<string>; | ||
pathVariables: UnwrapRef<IPathVariables>; | ||
queryParams: UnwrapRef<IQueryParams>; | ||
hash: Ref<string | number>; | ||
queryParams: UnwrapRef<IQueryParams>; | ||
pathVariables: UnwrapRef<IPathVariables>; | ||
disableCSV: Ref<boolean>; | ||
url: ComputedRef<string>; | ||
disableCSV: Ref<boolean>; | ||
setUrl: (url: ComputedRef<string>) => void; | ||
} | ||
export declare class BuilderResult implements IBuilderResult { | ||
constructor(path: MaybeRef<string | number>, pathVariables: MaybeReactive<IPathVariables>, queryParams: MaybeReactive<IQueryParams>, hash: MaybeRef<string | number>, disableCSV: MaybeRef<boolean>); | ||
constructor(path: MaybeRef<string>, pathVariables: MaybeReactive<IPathVariables>, queryParams: MaybeReactive<IQueryParams>, hash: MaybeRef<string>, disableCSV: MaybeRef<boolean>); | ||
setUrl(url: ComputedRef<string>): void; | ||
path: Ref<string>; | ||
hash: Ref<string | number>; | ||
pathVariables: UnwrapRef<IPathVariables>; | ||
queryParams: UnwrapRef<IQueryParams>; | ||
pathVariables: UnwrapRef<IPathVariables>; | ||
hash: Ref<string>; | ||
disableCSV: Ref<boolean>; | ||
url: ComputedRef<string>; | ||
disableCSV: Ref<boolean>; | ||
} | ||
@@ -54,3 +54,3 @@ export declare class UrlBuilder { | ||
*/ | ||
declare const useUrl: (options: IUrlOptions | any, baseUrl?: string | undefined) => IBuilderResult; | ||
declare const useUrl: (options: IUrlOptions | any, baseUrl?: string) => IBuilderResult; | ||
/** | ||
@@ -60,3 +60,3 @@ * Create a new instance of useUrl() | ||
*/ | ||
declare const createUseUrlInstance: () => (options: IUrlOptions | any, baseUrl?: string | undefined) => IBuilderResult; | ||
declare const createUseUrlInstance: () => (options: IUrlOptions | any, baseUrl?: string) => IBuilderResult; | ||
export { useUrl, createUseUrlInstance }; |
import { ref, reactive, computed, isReactive } from 'vue-demi'; | ||
export class BuilderResult { | ||
constructor(path, pathVariables, queryParams, hash, disableCSV) { | ||
this.path = isReactive(path) ? path : ref(path.toString()); | ||
this.hash = isReactive(hash) ? hash : ref(hash.toString()); | ||
this.queryParams = isReactive(queryParams) ? queryParams : reactive(queryParams); | ||
this.pathVariables = isReactive(pathVariables) ? pathVariables : reactive(pathVariables); | ||
this.disableCSV = isReactive(disableCSV) ? disableCSV : ref(disableCSV); | ||
this.path = ref(path); | ||
this.pathVariables = reactive(pathVariables); | ||
this.queryParams = reactive(queryParams); | ||
this.hash = ref(hash); | ||
this.disableCSV = ref(disableCSV); | ||
this.url = computed(() => ''); | ||
@@ -72,3 +72,3 @@ } | ||
const useUrl = (options, baseUrl) => { | ||
const builderResult = new BuilderResult(options.path, options.pathVariables, options.queryParams, options.hash, options.disableCSV); | ||
const builderResult = new BuilderResult(options?.path ?? '', options?.pathVariables ?? {}, options?.queryParams ?? {}, options?.hash ?? '', options?.disableCSV ?? false); | ||
const { queryParams, pathVariables, path, hash, disableCSV } = builderResult; | ||
@@ -75,0 +75,0 @@ const builder = new UrlBuilder(baseUrl); |
{ | ||
"name": "vue-useurl", | ||
"version": "1.0.32", | ||
"version": "1.0.33", | ||
"description": "Reactive Url Builder Vue Composable", | ||
@@ -5,0 +5,0 @@ "type":"module", |
12809