@opentiny/vue-hooks
Advanced tools
Comparing version
export declare const useTouch: (ref: any) => () => { | ||
move: (event: any) => void; | ||
start: (event: any) => void; | ||
move: (event: TouchEvent) => void; | ||
start: (event: TouchEvent) => void; | ||
reset: () => void; | ||
@@ -5,0 +5,0 @@ isVertical: () => boolean; |
@@ -13,5 +13,5 @@ /** | ||
declare const _default: (vm: any) => { | ||
dispatch(componentName: any, eventName: any, params: any): void; | ||
broadcast(componentName: any, eventName: any, params: any): void; | ||
dispatch(componentName: string, eventName: string, params: any): void; | ||
broadcast(componentName: string, eventName: string, params: any): void; | ||
}; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import { ISharedRenderlessFunctionParams } from 'types/shared.type'; | ||
import { ISharedRenderlessFunctionParams } from '../types/shared.type'; | ||
export interface IPopupState { | ||
@@ -3,0 +3,0 @@ opened: boolean; |
{ | ||
"name": "@opentiny/vue-hooks", | ||
"version": "3.22.0", | ||
"version": "3.23.0", | ||
"description": "", | ||
@@ -14,3 +14,3 @@ "author": "", | ||
"@floating-ui/dom": "^1.6.9", | ||
"@opentiny/utils": "~3.22.0" | ||
"@opentiny/utils": "~3.23.0" | ||
}, | ||
@@ -17,0 +17,0 @@ "devDependencies": { |
@@ -1,3 +0,3 @@ | ||
const isWindow = (val) => val === window | ||
const makeDOMRect = (width, height) => ({ | ||
const isWindow = (val: any) => val === window | ||
const makeDOMRect = (width: number, height: number) => ({ | ||
top: 0, | ||
@@ -11,3 +11,3 @@ left: 0, | ||
export const useRect = (unref) => (elOrRef) => { | ||
export const useRect = (unref: any) => (elOrRef: any) => { | ||
const el = unref(elOrRef) | ||
@@ -14,0 +14,0 @@ |
const TAP_OFFSET = 5 | ||
const getDirection = (x, y) => { | ||
const getDirection = (x: number, y: number) => { | ||
if (x > y) return 'horizontal' | ||
@@ -9,5 +9,5 @@ if (y > x) return 'vertical' | ||
const touchEvent = (event) => event.touches[0] | ||
const touchEvent = (event: TouchEvent) => event.touches[0] | ||
export const useTouch = (ref) => () => { | ||
export const useTouch = (ref: any) => () => { | ||
const startX = ref(0) | ||
@@ -34,3 +34,3 @@ const startY = ref(0) | ||
const start = (event) => { | ||
const start = (event: TouchEvent) => { | ||
reset() | ||
@@ -42,3 +42,3 @@ const touch = touchEvent(event) | ||
const move = (event) => { | ||
const move = (event: TouchEvent) => { | ||
const touch = touchEvent(event) | ||
@@ -45,0 +45,0 @@ // safari back will set clientX to negative number |
@@ -15,5 +15,5 @@ /* eslint-disable prefer-spread */ | ||
// 全局未引用 ,待移除 | ||
export default (vm) => { | ||
const broadcast = (vm, componentName, eventName, params) => { | ||
vm.$children.forEach((child) => { | ||
export default (vm: any) => { | ||
const broadcast = (vm: any, componentName: string, eventName: string, params: any) => { | ||
vm.$children.forEach((child: any) => { | ||
const name = child.$options.componentName | ||
@@ -30,3 +30,3 @@ | ||
return { | ||
dispatch(componentName, eventName, params) { | ||
dispatch(componentName: string, eventName: string, params: any) { | ||
let parent = vm.$parent || vm.$root | ||
@@ -47,3 +47,3 @@ let name = parent.$options.componentName | ||
}, | ||
broadcast(componentName, eventName, params) { | ||
broadcast(componentName: string, eventName: string, params: any) { | ||
broadcast(vm, componentName, eventName, params) | ||
@@ -50,0 +50,0 @@ } |
@@ -14,10 +14,7 @@ /** | ||
import { PopupManager, PopperJS, on, off, isDisplayNone } from '@opentiny/utils' | ||
// todo | ||
import type { ISharedRenderlessFunctionParams } from 'types/shared.type' | ||
import type { ISharedRenderlessFunctionParams } from '../types/shared.type' | ||
import { isServer } from '@opentiny/utils' | ||
export interface IPopperState { | ||
popperJS: Popper | ||
popperJS: PopperJS | null | ||
appended: boolean | ||
@@ -52,6 +49,6 @@ popperElm: HTMLElement | ||
const getReferMaxZIndex = (reference) => { | ||
const getReferMaxZIndex = (reference: HTMLElement) => { | ||
if (!reference || !reference.nodeType) return | ||
let getZIndex = (dom) => parseInt(window.getComputedStyle(dom).zIndex, 10) || 0 | ||
let getZIndex = (dom: HTMLElement) => parseInt(window.getComputedStyle(dom).zIndex, 10) || 0 | ||
let max = getZIndex(reference) | ||
@@ -95,3 +92,3 @@ let z | ||
} = options | ||
const state = reactive<IPopperState>({ | ||
const state = reactive({ | ||
popperJS: null as any, | ||
@@ -103,3 +100,3 @@ appended: false, // arrow 是否添加 | ||
currentPlacement: '' | ||
}) | ||
}) as IPopperState | ||
@@ -130,7 +127,7 @@ /** 创建箭头函数 */ | ||
const nextZIndex = (reference) => { | ||
const nextZIndex = (reference: HTMLElement) => { | ||
return props.zIndex === 'relative' ? getReferMaxZIndex(reference) : PopupManager.nextZIndex() | ||
} | ||
const createPopper = (dom) => { | ||
const createPopper = (dom: HTMLElement) => { | ||
if (isServer) { | ||
@@ -191,3 +188,3 @@ return | ||
*/ | ||
const updatePopper = (popperElmOrTrue?: HTMLElement) => { | ||
const updatePopper = (popperElmOrTrue?: HTMLElement | boolean) => { | ||
if (popperElmOrTrue && popperElmOrTrue !== true) { | ||
@@ -239,3 +236,3 @@ state.popperElm = popperElmOrTrue | ||
() => state.showPopper, | ||
(val) => { | ||
(val: boolean) => { | ||
if (props.disabled) { | ||
@@ -242,0 +239,0 @@ return |
@@ -16,3 +16,3 @@ /** | ||
// todo | ||
import type { ISharedRenderlessFunctionParams } from 'types/shared.type' | ||
import type { ISharedRenderlessFunctionParams } from '../types/shared.type' | ||
import { isServer } from '@opentiny/utils' | ||
@@ -57,3 +57,3 @@ | ||
() => props.visible, | ||
(val) => { | ||
(val: boolean) => { | ||
if (val) { | ||
@@ -187,6 +187,6 @@ if (vm._opening) { | ||
const { api, nextTick, onBeforeUnmount, onMounted, props, reactive, toRefs, vm, watch } = options | ||
const state = reactive<IPopupState>({ | ||
const state = reactive({ | ||
opened: false, | ||
rendered: false | ||
}) | ||
}) as IPopupState | ||
@@ -193,0 +193,0 @@ setWatchFn({ onMounted, onBeforeUnmount, watch, vm, api, props, state, nextTick }) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
74603
1.58%46
4.55%1982
1.75%0
-100%+ Added
- Removed
Updated