vue-useurl
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "vue-useurl", | ||
"version": "1.0.5", | ||
"description": "Vue.js Composition API Hook Url Builder", | ||
"version": "1.0.6", | ||
"description": "Vue.js Composition AmPI Hook Url Builder", | ||
"main": "src/index.js", | ||
@@ -6,0 +6,0 @@ "types": "src/index.ts", |
@@ -0,1 +1,3 @@ | ||
<img src="https://raw.githubusercontent.com/rainxh11/vue-useurl/master/assets/logo.svg" width="300"> | ||
# vue-useurl ( Url Builder Vue Hook ) | ||
@@ -2,0 +4,0 @@ [![NPM version](https://img.shields.io/npm/v/vue-useurl.svg)](https://www.npmjs.com/package/vue-useurl) |
@@ -1,10 +0,13 @@ | ||
import { ref, reactive, computed } from 'vue-demi'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useUrl = exports.UrlBuilder = void 0; | ||
const vue_demi_1 = require("vue-demi"); | ||
class BuilderResult { | ||
constructor(path, pathVariables, queryParams, hash, disableCSV) { | ||
this.path = ref(path.toString()); | ||
this.hash = ref(hash.toString()); | ||
this.queryParams = reactive(queryParams); | ||
this.pathVariables = reactive(pathVariables); | ||
this.disableCSV = ref(disableCSV); | ||
this.url = computed(() => ''); | ||
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.url = (0, vue_demi_1.computed)(() => ''); | ||
} | ||
@@ -16,3 +19,3 @@ setUrl(url) { | ||
} | ||
export class UrlBuilder { | ||
class UrlBuilder { | ||
constructor(baseUrl) { | ||
@@ -60,2 +63,3 @@ this.baseUrl = baseUrl ?? ''; | ||
} | ||
exports.UrlBuilder = UrlBuilder; | ||
const useUrl = (options, baseUrl) => { | ||
@@ -65,3 +69,3 @@ const builderResult = new BuilderResult(options.path, options.pathVariables, options.queryParams, options.hash, options.disableCSV); | ||
const builder = new UrlBuilder(baseUrl); | ||
const computedUrl = computed(() => { | ||
const computedUrl = (0, vue_demi_1.computed)(() => { | ||
let tempUrl = (builder.baseUrl + path.value).replace('//', '/'); | ||
@@ -76,2 +80,2 @@ tempUrl = builder.buildPathVariables(tempUrl, pathVariables); | ||
}; | ||
export { useUrl }; | ||
exports.useUrl = useUrl; |
@@ -1,22 +0,20 @@ | ||
import { useUrl } from '../src/index'; | ||
const params = { | ||
search: 'ahmed', | ||
limit: 50, | ||
page: 12, | ||
sort: 'CreatedOn', | ||
types: ['Cancelled', 'OnGoing'] | ||
}; | ||
const { url, queryParams, pathVariables, hash, path, disableCSV } = useUrl({ | ||
path: '/api/v1/users/:id/search', | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const index_1 = require("../src/index"); | ||
const { url, queryParams, pathVariables, hash, path, disableCSV } = (0, index_1.useUrl)({ | ||
path: '/api/v1/entity/:id/subentity', | ||
pathVariables: { | ||
id: 451 | ||
id: 1001 | ||
}, | ||
queryParams: { | ||
...params | ||
search: 'query', | ||
sort: 'propery', | ||
limit: 100, | ||
page: 1, | ||
filters: ['filter1', 'filter2', 'filter3'] | ||
}, | ||
hash: 'hashtag', | ||
disableCSV: false | ||
}, 'http://api.com'); | ||
hash: 'someHash' | ||
}, 'https://somedomain.com'); | ||
console.log(url.value); | ||
hash.value = "newHashTag"; | ||
console.log(url.value); |
import { useUrl } from '../src/index' | ||
const params = { | ||
search: 'ahmed', | ||
limit: 50, | ||
page: 12, | ||
sort: 'CreatedOn', | ||
types: ['Cancelled', 'OnGoing'] | ||
} | ||
const { url, queryParams, pathVariables, hash, path, disableCSV } = useUrl({ | ||
path: '/api/v1/users/:id/search', | ||
path: '/api/v1/entity/:id/subentity', | ||
pathVariables: { | ||
id: 451 | ||
id: 1001 | ||
}, | ||
queryParams: { | ||
...params | ||
search: 'query', | ||
sort: 'propery', | ||
limit: 100, | ||
page: 1, | ||
filters: [ 'filter1', 'filter2', 'filter3' ] | ||
}, | ||
hash: 'hashtag', | ||
disableCSV: false | ||
hash: 'someHash' | ||
}, | ||
'http://api.com') | ||
'https://somedomain.com') | ||
@@ -24,0 +19,0 @@ console.log(url.value) |
{ | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"target": "ES2020", | ||
"jsx": "preserve", | ||
"strictFunctionTypes": true | ||
"strictFunctionTypes": true, | ||
"esModuleInterop": true, | ||
}, | ||
@@ -9,0 +10,0 @@ "exclude": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156479
9
120
233