@fastkit/vue-utils
Advanced tools
Comparing version 0.6.19 to 0.6.20
@@ -266,2 +266,56 @@ 'use strict'; | ||
} | ||
function getMergedQuery(query, overrides) { | ||
const _query = JSON.parse(JSON.stringify(overrides)); | ||
Object.entries(query).forEach(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
const values = value.map((v) => { | ||
if (typeof v === 'number') | ||
v = String(v); | ||
return v; | ||
}); | ||
_query[key] = values; | ||
} | ||
else if (value === null) { | ||
delete _query[key]; | ||
} | ||
else { | ||
if (typeof value === 'number') | ||
value = String(value); | ||
_query[key] = value; | ||
} | ||
}); | ||
return _query; | ||
} | ||
function getQueryMergedLocation(query, route) { | ||
return { | ||
// name: route.name, | ||
path: route.path, | ||
// ...route, | ||
query: getMergedQuery(query, route.query), | ||
}; | ||
} | ||
function getRouteQuery(bucket, key, type = String, defaultValue) { | ||
const _value = bucket[key]; | ||
const value = Array.isArray(_value) ? _value[0] : _value; | ||
if (type === String) { | ||
return value != null ? value : defaultValue; | ||
} | ||
else if (type === Number) { | ||
if (value != null) { | ||
const parsed = Number(value); | ||
return isNaN(parsed) ? defaultValue : parsed; | ||
} | ||
return defaultValue; | ||
} | ||
else if (type === Boolean) { | ||
if (value != null) { | ||
const lower = String(value).toLowerCase().trim(); | ||
if (['1', 'true', 'on'].includes(lower)) | ||
return true; | ||
if (['0', '-1', 'false', 'off'].includes(lower)) | ||
return false; | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
@@ -652,3 +706,5 @@ const useKeybord = function useKeybord(settings, options = {}) { | ||
exports.findVNodeChild = findVNodeChild; | ||
exports.getQueryMergedLocation = getQueryMergedLocation; | ||
exports.getRouteMatchedComponents = getRouteMatchedComponents; | ||
exports.getRouteQuery = getRouteQuery; | ||
exports.navigationableEmits = navigationableEmits; | ||
@@ -655,0 +711,0 @@ exports.navigationableProps = navigationableProps; |
@@ -266,2 +266,56 @@ 'use strict'; | ||
} | ||
function getMergedQuery(query, overrides) { | ||
const _query = JSON.parse(JSON.stringify(overrides)); | ||
Object.entries(query).forEach(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
const values = value.map((v) => { | ||
if (typeof v === 'number') | ||
v = String(v); | ||
return v; | ||
}); | ||
_query[key] = values; | ||
} | ||
else if (value === null) { | ||
delete _query[key]; | ||
} | ||
else { | ||
if (typeof value === 'number') | ||
value = String(value); | ||
_query[key] = value; | ||
} | ||
}); | ||
return _query; | ||
} | ||
function getQueryMergedLocation(query, route) { | ||
return { | ||
// name: route.name, | ||
path: route.path, | ||
// ...route, | ||
query: getMergedQuery(query, route.query), | ||
}; | ||
} | ||
function getRouteQuery(bucket, key, type = String, defaultValue) { | ||
const _value = bucket[key]; | ||
const value = Array.isArray(_value) ? _value[0] : _value; | ||
if (type === String) { | ||
return value != null ? value : defaultValue; | ||
} | ||
else if (type === Number) { | ||
if (value != null) { | ||
const parsed = Number(value); | ||
return isNaN(parsed) ? defaultValue : parsed; | ||
} | ||
return defaultValue; | ||
} | ||
else if (type === Boolean) { | ||
if (value != null) { | ||
const lower = String(value).toLowerCase().trim(); | ||
if (['1', 'true', 'on'].includes(lower)) | ||
return true; | ||
if (['0', '-1', 'false', 'off'].includes(lower)) | ||
return false; | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
@@ -652,3 +706,5 @@ const useKeybord = function useKeybord(settings, options = {}) { | ||
exports.findVNodeChild = findVNodeChild; | ||
exports.getQueryMergedLocation = getQueryMergedLocation; | ||
exports.getRouteMatchedComponents = getRouteMatchedComponents; | ||
exports.getRouteQuery = getRouteQuery; | ||
exports.navigationableEmits = navigationableEmits; | ||
@@ -655,0 +711,0 @@ exports.navigationableProps = navigationableProps; |
@@ -17,2 +17,3 @@ import { BaseTransitionProps } from 'vue'; | ||
import { Key } from '@fastkit/keybord'; | ||
import type { LocationQueryRaw } from 'vue-router'; | ||
import { ObjectDirective } from 'vue'; | ||
@@ -25,2 +26,3 @@ import { Prop } from '@vue/runtime-core'; | ||
import type { RouteLocationNormalized } from 'vue-router'; | ||
import type { RouteLocationNormalizedLoaded } from 'vue-router'; | ||
import { RouteLocationRaw } from 'vue-router'; | ||
@@ -116,4 +118,25 @@ import type { RouteRecordNormalized } from 'vue-router'; | ||
export declare function getQueryMergedLocation(query: LocationQueryRaw, route: RouteLocationNormalizedLoaded): { | ||
path: string; | ||
query: LocationQueryRaw; | ||
}; | ||
export declare function getRouteMatchedComponents<P extends 'components' = 'components'>(route: RouteLocationNormalized, matches?: false | number[], prop?: P): (RouteComponent | (() => Promise<RouteComponent>))[]; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string): string | undefined; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: undefined, defaultValue: string): string; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: StringConstructor): string | undefined; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: StringConstructor, defaultValue: string): string; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: NumberConstructor): number | undefined; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: NumberConstructor, defaultValue: number): number; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: BooleanConstructor): boolean; | ||
export declare function getRouteQuery(bucket: LocationQueryRaw, key: string, type: BooleanConstructor, defaultValue: boolean): boolean; | ||
declare type InferPropType<T> = [T] extends [null] ? any : [T] extends [ | ||
@@ -120,0 +143,0 @@ { |
@@ -262,2 +262,56 @@ import { Comment, Text, computed, BaseTransition, h, Transition, onBeforeMount, onBeforeUnmount, reactive } from 'vue'; | ||
} | ||
function getMergedQuery(query, overrides) { | ||
const _query = JSON.parse(JSON.stringify(overrides)); | ||
Object.entries(query).forEach(([key, value]) => { | ||
if (Array.isArray(value)) { | ||
const values = value.map((v) => { | ||
if (typeof v === 'number') | ||
v = String(v); | ||
return v; | ||
}); | ||
_query[key] = values; | ||
} | ||
else if (value === null) { | ||
delete _query[key]; | ||
} | ||
else { | ||
if (typeof value === 'number') | ||
value = String(value); | ||
_query[key] = value; | ||
} | ||
}); | ||
return _query; | ||
} | ||
function getQueryMergedLocation(query, route) { | ||
return { | ||
// name: route.name, | ||
path: route.path, | ||
// ...route, | ||
query: getMergedQuery(query, route.query), | ||
}; | ||
} | ||
function getRouteQuery(bucket, key, type = String, defaultValue) { | ||
const _value = bucket[key]; | ||
const value = Array.isArray(_value) ? _value[0] : _value; | ||
if (type === String) { | ||
return value != null ? value : defaultValue; | ||
} | ||
else if (type === Number) { | ||
if (value != null) { | ||
const parsed = Number(value); | ||
return isNaN(parsed) ? defaultValue : parsed; | ||
} | ||
return defaultValue; | ||
} | ||
else if (type === Boolean) { | ||
if (value != null) { | ||
const lower = String(value).toLowerCase().trim(); | ||
if (['1', 'true', 'on'].includes(lower)) | ||
return true; | ||
if (['0', '-1', 'false', 'off'].includes(lower)) | ||
return false; | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
@@ -632,2 +686,2 @@ const useKeybord = function useKeybord(settings, options = {}) { | ||
export { BODY_SCROLL_LOCK_ATTRIBUTE, BODY_SCROLL_LOCK_SCROLLER_ATTRIBUTE, BooleanishPropOption, ClickOutsideDirectiveElementSymbol, NumberishPropOption, VExpandTransition, bodyScrollLockDirective, bodyScrollLockDirectiveArgument, cleanupEmptyVNodeChild, clickOutsideDirective, clickOutsideDirectiveArgument, createJavaScriptTransition, createPropsOptions, defineSlotsProps, extractRouteMatchedItems, findVNodeChild, getRouteMatchedComponents, navigationableEmits, navigationableProps, rawNumberProp, rawNumberPropType, renderSlotOrEmpty, resizeDirective, resizeDirectiveArgument, resolveBooleanish, resolveNumberish, resolveVNodeChildOrSlot, resolveVNodeChildOrSlots, state$1 as state, useKeybord, useNavigationable, useVisibility, useWindow }; | ||
export { BODY_SCROLL_LOCK_ATTRIBUTE, BODY_SCROLL_LOCK_SCROLLER_ATTRIBUTE, BooleanishPropOption, ClickOutsideDirectiveElementSymbol, NumberishPropOption, VExpandTransition, bodyScrollLockDirective, bodyScrollLockDirectiveArgument, cleanupEmptyVNodeChild, clickOutsideDirective, clickOutsideDirectiveArgument, createJavaScriptTransition, createPropsOptions, defineSlotsProps, extractRouteMatchedItems, findVNodeChild, getQueryMergedLocation, getRouteMatchedComponents, getRouteQuery, navigationableEmits, navigationableProps, rawNumberProp, rawNumberPropType, renderSlotOrEmpty, resizeDirective, resizeDirectiveArgument, resolveBooleanish, resolveNumberish, resolveVNodeChildOrSlot, resolveVNodeChildOrSlots, state$1 as state, useKeybord, useNavigationable, useVisibility, useWindow }; |
{ | ||
"name": "@fastkit/vue-utils", | ||
"version": "0.6.19", | ||
"version": "0.6.20", | ||
"description": "@fastkit/vue-utils", | ||
@@ -34,7 +34,7 @@ "buildOptions": { | ||
"dependencies": { | ||
"@fastkit/body-scroll-lock": "0.6.19", | ||
"@fastkit/visibility": "0.6.19", | ||
"@fastkit/keybord": "0.6.19", | ||
"@fastkit/helpers": "0.6.19" | ||
"@fastkit/body-scroll-lock": "0.6.20", | ||
"@fastkit/visibility": "0.6.20", | ||
"@fastkit/keybord": "0.6.20", | ||
"@fastkit/helpers": "0.6.20" | ||
} | ||
} |
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
85559
2413
+ Added@fastkit/body-scroll-lock@0.6.20(transitive)
+ Added@fastkit/helpers@0.6.20(transitive)
+ Added@fastkit/keybord@0.6.20(transitive)
+ Added@fastkit/tiny-logger@0.6.20(transitive)
+ Added@fastkit/visibility@0.6.20(transitive)
- Removed@fastkit/body-scroll-lock@0.6.19(transitive)
- Removed@fastkit/helpers@0.6.19(transitive)
- Removed@fastkit/keybord@0.6.19(transitive)
- Removed@fastkit/tiny-logger@0.6.19(transitive)
- Removed@fastkit/visibility@0.6.19(transitive)
Updated@fastkit/helpers@0.6.20
Updated@fastkit/keybord@0.6.20
Updated@fastkit/visibility@0.6.20