@atoms-studio/composables
Advanced tools
Comparing version 0.0.0-0e94f99 to 0.0.0-2986c85
@@ -1,2 +0,18 @@ | ||
import { computed } from "vue"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
import { computed, inject } from "vue"; | ||
const useURL = (to, base) => { | ||
@@ -32,2 +48,74 @@ if (!base) { | ||
}; | ||
export { useURL }; | ||
/*! | ||
* vue-router v4.0.13 | ||
* (c) 2022 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
const hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol"; | ||
const PolySymbol = (name) => hasSymbol ? Symbol(name) : "_vr_" + name; | ||
const routerKey = /* @__PURE__ */ PolySymbol("r"); | ||
const routeLocationKey = /* @__PURE__ */ PolySymbol("rl"); | ||
var NavigationType; | ||
(function(NavigationType2) { | ||
NavigationType2["pop"] = "pop"; | ||
NavigationType2["push"] = "push"; | ||
})(NavigationType || (NavigationType = {})); | ||
var NavigationDirection; | ||
(function(NavigationDirection2) { | ||
NavigationDirection2["back"] = "back"; | ||
NavigationDirection2["forward"] = "forward"; | ||
NavigationDirection2["unknown"] = ""; | ||
})(NavigationDirection || (NavigationDirection = {})); | ||
var NavigationFailureType; | ||
(function(NavigationFailureType2) { | ||
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted"; | ||
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled"; | ||
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated"; | ||
})(NavigationFailureType || (NavigationFailureType = {})); | ||
function useRouter() { | ||
return inject(routerKey); | ||
} | ||
function useRoute() { | ||
return inject(routeLocationKey); | ||
} | ||
const useRouteState = (configOrKeys, method = "replace") => { | ||
const route = useRoute(); | ||
const router = useRouter(); | ||
let config; | ||
if (Array.isArray(configOrKeys)) { | ||
config = configOrKeys.reduce((acc, key) => { | ||
acc[key] = { | ||
get: (value) => value, | ||
set: (value) => value | ||
}; | ||
return acc; | ||
}, {}); | ||
} else { | ||
config = configOrKeys; | ||
} | ||
const stateKeys = Object.keys(config); | ||
const state = computed(() => { | ||
const result = {}; | ||
for (const stateKey of stateKeys) { | ||
const queryValue = route.query[stateKey]; | ||
const stateValue = config[stateKey].get(queryValue); | ||
result[stateKey] = stateValue; | ||
} | ||
return result; | ||
}); | ||
const updateState = (partialState) => { | ||
const newState = __spreadValues(__spreadValues({}, state.value), partialState); | ||
const newQuery = {}; | ||
for (const stateKey of stateKeys) { | ||
const stateValue = newState[stateKey]; | ||
const queryValue = config[stateKey].set(stateValue); | ||
newQuery[stateKey] = queryValue; | ||
} | ||
return router[method]({ query: __spreadValues(__spreadValues({}, route.query), newQuery) }); | ||
}; | ||
return { | ||
state, | ||
updateState | ||
}; | ||
}; | ||
export { useRouteState, useURL }; |
@@ -1,1 +0,5 @@ | ||
(function(u,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis!="undefined"?globalThis:u||self,e(u.MyLib={},u.Vue))})(this,function(u,e){"use strict";const s=(i,o)=>{if(!o)throw new Error("Base is required");const r=e.computed(()=>i.value==="#"),t=e.computed(()=>typeof i.value=="string"?new URL(i.value,o):null),l=e.computed(()=>{var n;return((n=t.value)==null?void 0:n.origin)||""}),d=e.computed(()=>{var n;return r.value?"#":((n=t.value)==null?void 0:n.pathname)||""}),c=e.computed(()=>r.value||t.value!==null&&l.value!==o);return{url:t,origin:l,path:d,isExternal:c,isDummy:r}};u.useURL=s,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module"}); | ||
var U=Object.defineProperty;var q=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var R=(o,t,n)=>t in o?U(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,y=(o,t)=>{for(var n in t||(t={}))g.call(t,n)&&R(o,n,t[n]);if(q)for(var n of q(t))A.call(t,n)&&R(o,n,t[n]);return o};(function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o.MyLib={},o.Vue))})(this,function(o,t){"use strict";const n=(e,f)=>{if(!f)throw new Error("Base is required");const l=t.computed(()=>e.value==="#"),a=t.computed(()=>typeof e.value=="string"?new URL(e.value,f):null),u=t.computed(()=>{var d;return((d=a.value)==null?void 0:d.origin)||""}),p=t.computed(()=>{var d;return l.value?"#":((d=a.value)==null?void 0:d.pathname)||""}),m=t.computed(()=>l.value||a.value!==null&&u.value!==f);return{url:a,origin:u,path:p,isExternal:m,isDummy:l}};/*! | ||
* vue-router v4.0.13 | ||
* (c) 2022 Eduardo San Martin Morote | ||
* @license MIT | ||
*/const j=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",S=e=>j?Symbol(e):"_vr_"+e,v=S("r"),L=S("rl");var b;(function(e){e.pop="pop",e.push="push"})(b||(b={}));var h;(function(e){e.back="back",e.forward="forward",e.unknown=""})(h||(h={}));var w;(function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"})(w||(w={}));function V(){return t.inject(v)}function k(){return t.inject(L)}const _=(e,f="replace")=>{const l=k(),a=V();let u;Array.isArray(e)?u=e.reduce((s,c)=>(s[c]={get:r=>r,set:r=>r},s),{}):u=e;const p=Object.keys(u),m=t.computed(()=>{const s={};for(const c of p){const r=l.query[c],i=u[c].get(r);s[c]=i}return s});return{state:m,updateState:s=>{const c=y(y({},m.value),s),r={};for(const i of p){const K=c[i],M=u[i].set(K);r[i]=M}return a[f]({query:y(y({},l.query),r)})}}};o.useRouteState=_,o.useURL=n,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"}); |
export { useURL } from './useURL'; | ||
export { useRouteState } from './useRouteState'; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.0-0e94f99", | ||
"version": "0.0.0-2986c85", | ||
"license": "MIT", | ||
@@ -42,4 +42,5 @@ "files": [ | ||
"dependencies": { | ||
"@atoms-studio/nuxt-components": "0.0.0-2986c85", | ||
"mkdirp": "^0.5.5" | ||
} | ||
} |
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
9466
7
163
3
+ Added@atoms-studio/nuxt-components@0.0.0-2986c85(transitive)
+ Added@vue/devtools-api@6.6.4(transitive)
+ Addedvue-router@4.5.0(transitive)