vue-useurl
Advanced tools
Comparing version 1.0.25 to 1.0.26
import { Ref, UnwrapRef, ComputedRef } from 'vue-demi'; | ||
export declare type MaybeRef<T> = T | Ref<T>; | ||
export declare type MaybeReactive<T> = T | UnwrapRef<T>; | ||
export declare type IQueryParams = Record<string, null | undefined | string | number | string[] | (string | number)[] | Ref<any> | UnwrapRef<any>>; | ||
export declare type IPathVariables = Record<string, string | number | Ref<any>>; | ||
export interface IUrlOptions { | ||
path?: string | number; | ||
queryParams?: IQueryParams; | ||
disableCSV?: boolean; | ||
hash?: string | number; | ||
pathVariables?: IPathVariables; | ||
path?: MaybeRef<string | number>; | ||
pathVariables?: MaybeReactive<IPathVariables>; | ||
queryParams?: MaybeReactive<IQueryParams>; | ||
disableCSV?: MaybeRef<boolean>; | ||
hash?: MaybeRef<string | number>; | ||
} | ||
@@ -21,3 +23,3 @@ export interface IBuilderResult { | ||
export declare class BuilderResult implements IBuilderResult { | ||
constructor(path: string | number, pathVariables: IPathVariables, queryParams: IQueryParams, hash: string | number, disableCSV: boolean); | ||
constructor(path: MaybeRef<string | number>, pathVariables: MaybeReactive<IPathVariables>, queryParams: MaybeReactive<IQueryParams>, hash: MaybeRef<string | number>, disableCSV: MaybeRef<boolean>); | ||
setUrl(url: ComputedRef<string>): void; | ||
@@ -24,0 +26,0 @@ path: Ref<string>; |
@@ -8,7 +8,7 @@ "use strict"; | ||
constructor(path, pathVariables, queryParams, hash, disableCSV) { | ||
this.path = (0, vue_demi_1.ref)(path.toString()); | ||
this.hash = (0, vue_demi_1.ref)(hash.toString()); | ||
this.queryParams = (0, vue_demi_1.reactive)(queryParams); | ||
this.pathVariables = (0, vue_demi_1.reactive)(pathVariables); | ||
this.disableCSV = (0, vue_demi_1.ref)(disableCSV); | ||
this.path = (0, vue_demi_1.isReactive)(path) ? path : (0, vue_demi_1.ref)(path.toString()); | ||
this.hash = (0, vue_demi_1.isReactive)(hash) ? hash : (0, vue_demi_1.ref)(hash.toString()); | ||
this.queryParams = (0, vue_demi_1.isReactive)(queryParams) ? queryParams : (0, vue_demi_1.reactive)(queryParams); | ||
this.pathVariables = (0, vue_demi_1.isReactive)(pathVariables) ? pathVariables : (0, vue_demi_1.reactive)(pathVariables); | ||
this.disableCSV = (0, vue_demi_1.isReactive)(disableCSV) ? disableCSV : (0, vue_demi_1.ref)(disableCSV); | ||
this.url = (0, vue_demi_1.computed)(() => ''); | ||
@@ -31,3 +31,3 @@ } | ||
buildPathVariables(url, pathVariables) { | ||
for (const key of Object.keys(pathVariables)) { | ||
for (const key in Object.keys(pathVariables)) { | ||
url = url.replace(/:([^\/]+)/gi, key); | ||
@@ -34,0 +34,0 @@ } |
{ | ||
"name": "vue-useurl", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "Reactive Url Builder Hook for Vue.js Composition API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
13162
158