@bifrostui/utils 1.4.6 → 1.4.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/directionLocationUtil.d.ts +27 -12
- package/dist/directionLocationUtil.js +101 -55
- package/dist/domUtils/index.d.ts +12 -0
- package/dist/domUtils/index.js +46 -0
- package/dist/domUtils/index.miniapp.d.ts +2 -0
- package/dist/domUtils/index.miniapp.js +86 -0
- package/dist/getBoundingClientRect/index.miniapp.d.ts +1 -2
- package/dist/getBoundingClientRect/index.miniapp.js +34 -5
- package/dist/getRootContainer/index.d.ts +2 -0
- package/dist/{getRootElement → getRootContainer}/index.js +8 -8
- package/dist/getRootContainer/index.miniapp.d.ts +3 -0
- package/dist/{getRootElement → getRootContainer}/index.miniapp.js +4 -4
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useTouchEmulator.d.ts +7 -1
- package/dist/hooks/useTouchEmulator.js +36 -10
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -3
- package/dist/isMini.d.ts +2 -1
- package/dist/isMini.js +3 -0
- package/es/directionLocationUtil.d.ts +27 -12
- package/es/directionLocationUtil.js +91 -55
- package/es/domUtils/index.d.ts +12 -0
- package/es/domUtils/index.js +22 -0
- package/es/domUtils/index.miniapp.d.ts +2 -0
- package/es/domUtils/index.miniapp.js +54 -0
- package/es/getBoundingClientRect/index.miniapp.d.ts +1 -2
- package/es/getBoundingClientRect/index.miniapp.js +34 -5
- package/es/getRootContainer/index.d.ts +2 -0
- package/es/getRootContainer/index.js +9 -0
- package/es/getRootContainer/index.miniapp.d.ts +3 -0
- package/es/{getRootElement → getRootContainer}/index.miniapp.js +4 -4
- package/es/hooks/index.d.ts +2 -2
- package/es/hooks/index.js +10 -1
- package/es/hooks/useTouchEmulator.d.ts +7 -1
- package/es/hooks/useTouchEmulator.js +29 -10
- package/es/index.d.ts +4 -3
- package/es/index.js +15 -2
- package/es/isMini.d.ts +2 -1
- package/es/isMini.js +2 -0
- package/package.json +1 -1
- package/dist/getRootElement/index.d.ts +0 -2
- package/dist/getRootElement/index.miniapp.d.ts +0 -3
- package/es/getRootElement/index.d.ts +0 -2
- package/es/getRootElement/index.js +0 -9
- package/es/getRootElement/index.miniapp.d.ts +0 -3
@@ -1,13 +1,13 @@
|
|
1
1
|
import Taro from "@tarojs/taro";
|
2
|
-
const
|
2
|
+
const getRootContainer = (rootCon, defaultCon) => {
|
3
3
|
const currentPages = Taro.getCurrentPages() || [];
|
4
4
|
const currentPage = currentPages[currentPages.length - 1];
|
5
5
|
const pageElement = currentPage == null ? void 0 : currentPage.$taroPath;
|
6
6
|
const defaultRootElement = document.getElementById(pageElement);
|
7
|
-
const rootElement = typeof
|
8
|
-
return rootElement || defaultRootElement;
|
7
|
+
const rootElement = typeof rootCon === "function" ? rootCon() : rootCon;
|
8
|
+
return rootElement || defaultCon || defaultRootElement;
|
9
9
|
};
|
10
|
-
var index_miniapp_default =
|
10
|
+
var index_miniapp_default = getRootContainer;
|
11
11
|
export {
|
12
12
|
index_miniapp_default as default
|
13
13
|
};
|
package/es/hooks/index.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import useDidMountEffect from './useDidMountEffect';
|
2
2
|
import useEventCallback from './useEventCallback';
|
3
3
|
import useForkRef from './useForkRef';
|
4
|
-
import useTouchEmulator from './useTouchEmulator';
|
4
|
+
import useTouchEmulator, { touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd } from './useTouchEmulator';
|
5
5
|
import useValue from './useValue';
|
6
6
|
import useDomReady from './useDomReady';
|
7
7
|
import useSize from './useSize';
|
8
8
|
import useDomCss from './useDomCss';
|
9
9
|
import useTouch from './useTouch';
|
10
10
|
import useUniqueId from './useUniqueId';
|
11
|
-
export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
|
11
|
+
export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
|
package/es/hooks/index.js
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
import useDidMountEffect from "./useDidMountEffect";
|
2
2
|
import useEventCallback from "./useEventCallback";
|
3
3
|
import useForkRef from "./useForkRef";
|
4
|
-
import useTouchEmulator
|
4
|
+
import useTouchEmulator, {
|
5
|
+
touchEmulator,
|
6
|
+
emulateTouchStart,
|
7
|
+
emulateTouchMove,
|
8
|
+
emulateTouchEnd
|
9
|
+
} from "./useTouchEmulator";
|
5
10
|
import useValue from "./useValue";
|
6
11
|
import useDomReady from "./useDomReady";
|
7
12
|
import useSize from "./useSize";
|
@@ -9,6 +14,10 @@ import useDomCss from "./useDomCss";
|
|
9
14
|
import useTouch from "./useTouch";
|
10
15
|
import useUniqueId from "./useUniqueId";
|
11
16
|
export {
|
17
|
+
emulateTouchEnd,
|
18
|
+
emulateTouchMove,
|
19
|
+
emulateTouchStart,
|
20
|
+
touchEmulator,
|
12
21
|
useDidMountEffect,
|
13
22
|
useDomCss,
|
14
23
|
useDomReady,
|
@@ -1 +1,7 @@
|
|
1
|
-
|
1
|
+
declare const emulateTouchStart: (ev: any) => void;
|
2
|
+
declare const emulateTouchMove: (ev: any) => void;
|
3
|
+
declare const emulateTouchEnd: (ev: any) => void;
|
4
|
+
declare function useTouchEmulator(dom?: HTMLElement | Window): void;
|
5
|
+
declare const touchEmulator: (dom?: HTMLElement | Window) => () => void;
|
6
|
+
export default useTouchEmulator;
|
7
|
+
export { touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd };
|
@@ -66,25 +66,44 @@ function getActiveTouches(mouseEv) {
|
|
66
66
|
}
|
67
67
|
return createTouchList(mouseEv);
|
68
68
|
}
|
69
|
+
const emulateTouchStart = onMouse("touchstart");
|
70
|
+
const emulateTouchMove = onMouse("touchmove");
|
71
|
+
const emulateTouchEnd = onMouse("touchend");
|
69
72
|
function useTouchEmulator(dom = window) {
|
70
|
-
const touchStart = onMouse("touchstart");
|
71
|
-
const touchMove = onMouse("touchmove");
|
72
|
-
const touchEnd = onMouse("touchend");
|
73
73
|
useEffect(() => {
|
74
74
|
if (dom) {
|
75
|
-
dom.addEventListener("mousedown",
|
76
|
-
dom.addEventListener("mousemove",
|
77
|
-
dom.addEventListener("mouseup",
|
75
|
+
dom.addEventListener("mousedown", emulateTouchStart, true);
|
76
|
+
dom.addEventListener("mousemove", emulateTouchMove, true);
|
77
|
+
dom.addEventListener("mouseup", emulateTouchEnd, true);
|
78
78
|
}
|
79
79
|
return () => {
|
80
80
|
if (dom) {
|
81
|
-
dom.removeEventListener("mousedown",
|
82
|
-
dom.removeEventListener("mousemove",
|
83
|
-
dom.removeEventListener("mouseup",
|
81
|
+
dom.removeEventListener("mousedown", emulateTouchStart, true);
|
82
|
+
dom.removeEventListener("mousemove", emulateTouchMove, true);
|
83
|
+
dom.removeEventListener("mouseup", emulateTouchEnd, true);
|
84
84
|
}
|
85
85
|
};
|
86
86
|
}, [dom]);
|
87
87
|
}
|
88
|
+
const touchEmulator = (dom = window) => {
|
89
|
+
if (dom) {
|
90
|
+
dom.addEventListener("mousedown", emulateTouchStart, true);
|
91
|
+
dom.addEventListener("mousemove", emulateTouchMove, true);
|
92
|
+
dom.addEventListener("mouseup", emulateTouchEnd, true);
|
93
|
+
}
|
94
|
+
return function() {
|
95
|
+
if (dom) {
|
96
|
+
dom.removeEventListener("mousedown", emulateTouchStart, true);
|
97
|
+
dom.removeEventListener("mousemove", emulateTouchMove, true);
|
98
|
+
dom.removeEventListener("mouseup", emulateTouchEnd, true);
|
99
|
+
}
|
100
|
+
};
|
101
|
+
};
|
102
|
+
var useTouchEmulator_default = useTouchEmulator;
|
88
103
|
export {
|
89
|
-
|
104
|
+
useTouchEmulator_default as default,
|
105
|
+
emulateTouchEnd,
|
106
|
+
emulateTouchMove,
|
107
|
+
emulateTouchStart,
|
108
|
+
touchEmulator
|
90
109
|
};
|
package/es/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { default as debounce } from './debounce';
|
2
|
-
export { getStylesAndLocation, triggerEventTransform, parsePlacement, } from './directionLocationUtil';
|
2
|
+
export { getStylesAndLocation, getNewDirectionLocation, triggerEventTransform, parsePlacement, } from './directionLocationUtil';
|
3
3
|
export { default as convertHexToRGBA } from './hex2rgba';
|
4
|
-
export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, useValue, useDomReady, useSize, useDomCss, useTouch, useUniqueId, } from './hooks';
|
4
|
+
export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd, useValue, useDomReady, useSize, useDomCss, useTouch, useUniqueId, } from './hooks';
|
5
5
|
export { default as isDev } from './isDev';
|
6
6
|
export { isMini, isWeapp, isAlipay, isMiniapp } from './isMini';
|
7
7
|
export { default as setRef } from './setRef';
|
@@ -9,7 +9,8 @@ export { default as throttle } from './throttle';
|
|
9
9
|
export { default as toArray } from './toArray';
|
10
10
|
export { default as blockTouch } from './touchBlocker';
|
11
11
|
export { easing, duration, getTransitionProps, createTransitions, } from './transitions';
|
12
|
-
export { default as
|
12
|
+
export { default as getRootContainer } from './getRootContainer';
|
13
13
|
export { default as getBoundingClientRect } from './getBoundingClientRect';
|
14
|
+
export { getScrollRect, getClientRect } from './domUtils';
|
14
15
|
export * from './isType';
|
15
16
|
export * from './render';
|
package/es/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { default as default2 } from "./debounce";
|
2
2
|
import {
|
3
3
|
getStylesAndLocation,
|
4
|
+
getNewDirectionLocation,
|
4
5
|
triggerEventTransform,
|
5
6
|
parsePlacement
|
6
7
|
} from "./directionLocationUtil";
|
@@ -10,6 +11,10 @@ import {
|
|
10
11
|
useEventCallback,
|
11
12
|
useForkRef,
|
12
13
|
useTouchEmulator,
|
14
|
+
touchEmulator,
|
15
|
+
emulateTouchStart,
|
16
|
+
emulateTouchMove,
|
17
|
+
emulateTouchEnd,
|
13
18
|
useValue,
|
14
19
|
useDomReady,
|
15
20
|
useSize,
|
@@ -29,8 +34,9 @@ import {
|
|
29
34
|
getTransitionProps,
|
30
35
|
createTransitions
|
31
36
|
} from "./transitions";
|
32
|
-
import { default as default9 } from "./
|
37
|
+
import { default as default9 } from "./getRootContainer";
|
33
38
|
import { default as default10 } from "./getBoundingClientRect";
|
39
|
+
import { getScrollRect, getClientRect } from "./domUtils";
|
34
40
|
export * from "./isType";
|
35
41
|
export * from "./render";
|
36
42
|
export {
|
@@ -40,8 +46,14 @@ export {
|
|
40
46
|
default2 as debounce,
|
41
47
|
duration,
|
42
48
|
easing,
|
49
|
+
emulateTouchEnd,
|
50
|
+
emulateTouchMove,
|
51
|
+
emulateTouchStart,
|
43
52
|
default10 as getBoundingClientRect,
|
44
|
-
|
53
|
+
getClientRect,
|
54
|
+
getNewDirectionLocation,
|
55
|
+
default9 as getRootContainer,
|
56
|
+
getScrollRect,
|
45
57
|
getStylesAndLocation,
|
46
58
|
getTransitionProps,
|
47
59
|
isAlipay,
|
@@ -53,6 +65,7 @@ export {
|
|
53
65
|
default5 as setRef,
|
54
66
|
default6 as throttle,
|
55
67
|
default7 as toArray,
|
68
|
+
touchEmulator,
|
56
69
|
triggerEventTransform,
|
57
70
|
useDidMountEffect,
|
58
71
|
useDomCss,
|
package/es/isMini.d.ts
CHANGED
package/es/isMini.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
const isMini = typeof process.env.TARO_ENV === "string";
|
2
2
|
const isWeapp = process.env.TARO_ENV === "weapp";
|
3
3
|
const isAlipay = process.env.TARO_ENV === "alipay";
|
4
|
+
const isTt = process.env.TARO_ENV === "tt";
|
4
5
|
const isMiniapp = () => {
|
5
6
|
return isMini;
|
6
7
|
};
|
@@ -8,5 +9,6 @@ export {
|
|
8
9
|
isAlipay,
|
9
10
|
isMini,
|
10
11
|
isMiniapp,
|
12
|
+
isTt,
|
11
13
|
isWeapp
|
12
14
|
};
|
package/package.json
CHANGED
@@ -1,9 +0,0 @@
|
|
1
|
-
const getRootElement = (rootEle) => {
|
2
|
-
const rootElement = typeof rootEle === "function" ? rootEle() : rootEle;
|
3
|
-
const defaultRootElement = document.body;
|
4
|
-
return rootElement || defaultRootElement;
|
5
|
-
};
|
6
|
-
var getRootElement_default = getRootElement;
|
7
|
-
export {
|
8
|
-
getRootElement_default as default
|
9
|
-
};
|