@bifrostui/utils 1.4.8-beta.0 → 2.0.0-beta.1

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.
Files changed (48) hide show
  1. package/dist/directionLocationUtil.d.ts +12 -27
  2. package/dist/directionLocationUtil.js +55 -101
  3. package/dist/getBoundingClientRect/index.miniapp.d.ts +2 -1
  4. package/dist/getBoundingClientRect/index.miniapp.js +5 -34
  5. package/dist/getRootElement/index.d.ts +2 -0
  6. package/dist/{getRootContainer → getRootElement}/index.js +8 -8
  7. package/dist/getRootElement/index.miniapp.d.ts +3 -0
  8. package/dist/{getRootContainer → getRootElement}/index.miniapp.js +4 -4
  9. package/dist/hooks/index.d.ts +2 -2
  10. package/dist/hooks/index.js +0 -8
  11. package/dist/hooks/useDidMountEffect.d.ts +1 -1
  12. package/dist/hooks/useTouchEmulator.d.ts +1 -7
  13. package/dist/hooks/useTouchEmulator.js +10 -36
  14. package/dist/index.d.ts +3 -4
  15. package/dist/index.js +3 -18
  16. package/dist/isMini.d.ts +1 -2
  17. package/dist/isMini.js +0 -3
  18. package/es/directionLocationUtil.d.ts +12 -27
  19. package/es/directionLocationUtil.js +55 -91
  20. package/es/getBoundingClientRect/index.miniapp.d.ts +2 -1
  21. package/es/getBoundingClientRect/index.miniapp.js +5 -34
  22. package/es/getRootElement/index.d.ts +2 -0
  23. package/es/getRootElement/index.js +9 -0
  24. package/es/getRootElement/index.miniapp.d.ts +3 -0
  25. package/es/{getRootContainer → getRootElement}/index.miniapp.js +4 -4
  26. package/es/hooks/index.d.ts +2 -2
  27. package/es/hooks/index.js +1 -10
  28. package/es/hooks/useDidMountEffect.d.ts +1 -1
  29. package/es/hooks/useTouchEmulator.d.ts +1 -7
  30. package/es/hooks/useTouchEmulator.js +10 -29
  31. package/es/index.d.ts +3 -4
  32. package/es/index.js +2 -15
  33. package/es/isMini.d.ts +1 -2
  34. package/es/isMini.js +0 -2
  35. package/package.json +1 -1
  36. package/dist/domUtils/index.d.ts +0 -12
  37. package/dist/domUtils/index.js +0 -46
  38. package/dist/domUtils/index.miniapp.d.ts +0 -2
  39. package/dist/domUtils/index.miniapp.js +0 -86
  40. package/dist/getRootContainer/index.d.ts +0 -2
  41. package/dist/getRootContainer/index.miniapp.d.ts +0 -3
  42. package/es/domUtils/index.d.ts +0 -12
  43. package/es/domUtils/index.js +0 -22
  44. package/es/domUtils/index.miniapp.d.ts +0 -2
  45. package/es/domUtils/index.miniapp.js +0 -54
  46. package/es/getRootContainer/index.d.ts +0 -2
  47. package/es/getRootContainer/index.js +0 -9
  48. package/es/getRootContainer/index.miniapp.d.ts +0 -3
package/dist/isMini.js CHANGED
@@ -20,14 +20,12 @@ __export(isMini_exports, {
20
20
  isAlipay: () => isAlipay,
21
21
  isMini: () => isMini,
22
22
  isMiniapp: () => isMiniapp,
23
- isTt: () => isTt,
24
23
  isWeapp: () => isWeapp
25
24
  });
26
25
  module.exports = __toCommonJS(isMini_exports);
27
26
  const isMini = typeof process.env.TARO_ENV === "string";
28
27
  const isWeapp = process.env.TARO_ENV === "weapp";
29
28
  const isAlipay = process.env.TARO_ENV === "alipay";
30
- const isTt = process.env.TARO_ENV === "tt";
31
29
  const isMiniapp = () => {
32
30
  return isMini;
33
31
  };
@@ -36,6 +34,5 @@ const isMiniapp = () => {
36
34
  isAlipay,
37
35
  isMini,
38
36
  isMiniapp,
39
- isTt,
40
37
  isWeapp
41
38
  });
@@ -22,41 +22,26 @@ export declare const getDirectionLocationStyle: ({ childrenOffset, arrowDirectio
22
22
  tipOffset: any;
23
23
  arrowLocation: any;
24
24
  offsetSpacing: any;
25
- }) => Promise<{
26
- styles: {
27
- top: number;
28
- left: number;
29
- transform: string;
30
- visibility: string;
31
- };
25
+ }) => {
26
+ styles: any;
32
27
  childrenStyle: any;
33
- }>;
28
+ };
34
29
  /**
35
30
  * 获取气泡位置和箭头位置
36
31
  */
37
- export declare const getStylesAndLocation: ({ scrollRoot, childrenRef, tipRef, arrowDirection, arrowLocation, offsetSpacing, }: {
32
+ export declare const getStylesAndLocation: ({ scrollRoot, childrenRef, arrowDirection, arrowLocation, offsetSpacing, selector, }: {
38
33
  scrollRoot?: Element;
39
- childrenRef?: React.RefObject<any>;
40
- tipRef?: React.RefObject<any>;
41
- arrowDirection: string;
42
- arrowLocation: string;
43
- offsetSpacing?: number;
44
- }) => Promise<{
45
- styles: {};
46
- childrenStyle: {};
47
- newArrowDirection: string;
48
- newArrowLocation: string;
49
- } | {
50
- styles: {
51
- top: number;
52
- left: number;
53
- transform: string;
54
- visibility: string;
55
- };
34
+ childrenRef: any;
35
+ arrowDirection: any;
36
+ arrowLocation: any;
37
+ offsetSpacing: any;
38
+ selector: any;
39
+ }) => {
40
+ styles: any;
56
41
  childrenStyle: any;
57
42
  newArrowDirection: any;
58
43
  newArrowLocation: any;
59
- }>;
44
+ };
60
45
  export declare const triggerEventTransform: ({ trigger, click, show, hide }: {
61
46
  trigger: any;
62
47
  click: any;
@@ -1,31 +1,12 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
- import { getScrollRect, getClientRect } from "./domUtils";
22
- import getBoundingClientRect from "./getBoundingClientRect";
23
1
  const directionCssMap = {
24
2
  left: "right",
25
3
  right: "left",
26
4
  top: "bottom",
27
5
  bottom: "top"
28
6
  };
7
+ const isBodyScroll = (scrollRoot) => {
8
+ return scrollRoot === document.body;
9
+ };
29
10
  const getNewDirectionLocation = ({
30
11
  scrollRoot,
31
12
  scrollRootOffset,
@@ -48,15 +29,14 @@ const getNewDirectionLocation = ({
48
29
  top: sTop,
49
30
  bottom: sBottom,
50
31
  left: sLeft,
51
- right: sRight,
52
- width: pageWidth,
53
- height: pageHeight
32
+ right: sRight
54
33
  } = scrollRootOffset;
55
- const isBodyRoot = !scrollRoot;
56
- const maxTop = isBodyRoot ? 0 : sTop;
57
- const maxBottom = isBodyRoot ? pageHeight : sBottom;
58
- const maxLeft = isBodyRoot ? 0 : sLeft;
59
- const maxRight = isBodyRoot ? pageWidth : sRight;
34
+ const pageWidth = document.documentElement.clientWidth || document.body.clientWidth;
35
+ const pageHeight = document.documentElement.clientHeight || document.body.clientHeight;
36
+ const maxTop = isBodyScroll(scrollRoot) ? 0 : sTop;
37
+ const maxBottom = isBodyScroll(scrollRoot) ? pageHeight : sBottom;
38
+ const maxLeft = isBodyScroll(scrollRoot) ? 0 : sLeft;
39
+ const maxRight = isBodyScroll(scrollRoot) ? pageWidth : sRight;
60
40
  let newArrowDirection = arrowDirection;
61
41
  let newArrowLocation = arrowLocation;
62
42
  const isDirectionTop = arrowDirection === "top";
@@ -91,14 +71,16 @@ const getNewDirectionLocation = ({
91
71
  newArrowLocation
92
72
  };
93
73
  };
94
- const getDirectionLocationStyle = (_0) => __async(void 0, [_0], function* ({
74
+ const getDirectionLocationStyle = ({
95
75
  childrenOffset,
96
76
  arrowDirection,
97
77
  tipOffset,
98
78
  arrowLocation,
99
79
  offsetSpacing
100
- }) {
101
- const { top: scrollTop, left: scrollLeft } = yield getScrollRect();
80
+ }) => {
81
+ const scrollTop = window.scrollY >= 0 && window.scrollY || document.documentElement.scrollTop;
82
+ const scrollLeft = window.scrollX >= 0 && window.scrollX || document.documentElement.scrollLeft;
83
+ const styles = {};
102
84
  const {
103
85
  width: cWidth,
104
86
  height: cHeight,
@@ -112,125 +94,107 @@ const getDirectionLocationStyle = (_0) => __async(void 0, [_0], function* ({
112
94
  childrenStyle = { width: `${cWidth}px`, height: `${cHeight}px` };
113
95
  }
114
96
  const { width, height } = tipOffset;
115
- let styleTop;
116
- let styleLeft;
117
97
  if (arrowDirection === "top") {
118
- styleTop = cTop - offsetSpacing - height;
98
+ styles.top = cTop - offsetSpacing - height;
119
99
  switch (arrowLocation) {
120
100
  case "left":
121
- styleLeft = cLeft;
101
+ styles.left = cLeft;
122
102
  break;
123
103
  case "center":
124
- styleLeft = cLeft + (cWidth - width) / 2;
104
+ styles.left = cLeft + (cWidth - width) / 2;
125
105
  break;
126
106
  case "right":
127
- styleLeft = cRight - width;
107
+ styles.left = cRight - width;
128
108
  break;
129
109
  case "none":
130
- styleLeft = cLeft;
110
+ styles.left = cLeft;
131
111
  break;
132
112
  default:
133
113
  break;
134
114
  }
135
115
  } else if (arrowDirection === "bottom") {
136
- styleTop = cBottom + offsetSpacing;
116
+ styles.top = cBottom + offsetSpacing;
137
117
  switch (arrowLocation) {
138
118
  case "left":
139
- styleLeft = cLeft;
119
+ styles.left = cLeft;
140
120
  break;
141
121
  case "center":
142
- styleLeft = cLeft + (cWidth - width) / 2;
122
+ styles.left = cLeft + (cWidth - width) / 2;
143
123
  break;
144
124
  case "right":
145
- styleLeft = cRight - width;
125
+ styles.left = cRight - width;
146
126
  break;
147
127
  case "none":
148
- styleLeft = cLeft;
128
+ styles.left = cLeft;
149
129
  break;
150
130
  default:
151
131
  break;
152
132
  }
153
133
  } else if (arrowDirection === "left") {
154
- styleLeft = cLeft - offsetSpacing - width;
134
+ styles.left = cLeft - offsetSpacing - width;
155
135
  switch (arrowLocation) {
156
136
  case "top":
157
- styleTop = cTop;
137
+ styles.top = cTop;
158
138
  break;
159
139
  case "center":
160
- styleTop = cTop + (cHeight - height) / 2;
140
+ styles.top = cTop + (cHeight - height) / 2;
161
141
  break;
162
142
  case "bottom":
163
- styleTop = cBottom - height;
143
+ styles.top = cBottom - height;
164
144
  break;
165
145
  case "none":
166
- styleTop = cTop;
146
+ styles.top = cTop;
167
147
  break;
168
148
  default:
169
149
  break;
170
150
  }
171
151
  } else if (arrowDirection === "right") {
172
- styleLeft = cRight + offsetSpacing;
152
+ styles.left = cRight + offsetSpacing;
173
153
  switch (arrowLocation) {
174
154
  case "top":
175
- styleTop = cTop;
155
+ styles.top = cTop;
176
156
  break;
177
157
  case "center":
178
- styleTop = cTop + (cHeight - height) / 2;
158
+ styles.top = cTop + (cHeight - height) / 2;
179
159
  break;
180
160
  case "bottom":
181
- styleTop = cBottom - height;
161
+ styles.top = cBottom - height;
182
162
  break;
183
163
  case "none":
184
- styleTop = cTop;
164
+ styles.top = cTop;
185
165
  break;
186
166
  default:
187
167
  break;
188
168
  }
189
169
  }
190
- if (styleTop) {
191
- styleTop = `${styleTop + scrollTop}px`;
170
+ if (styles.top) {
171
+ styles.top = `${styles.top + scrollTop}px`;
192
172
  }
193
- if (styleLeft) {
194
- styleLeft = `${styleLeft + scrollLeft}px`;
173
+ if (styles.left) {
174
+ styles.left = `${styles.left + scrollLeft}px`;
195
175
  }
196
- const styles = {
197
- top: 0,
198
- left: 0,
199
- transform: `translate3d(${styleLeft}, ${styleTop}, 0)`,
200
- visibility: ""
201
- };
202
176
  return { styles, childrenStyle };
203
- });
204
- const getStylesAndLocation = (_0) => __async(void 0, [_0], function* ({
205
- scrollRoot,
177
+ };
178
+ const getStylesAndLocation = ({
179
+ scrollRoot = document.body,
206
180
  childrenRef,
207
- tipRef,
208
- arrowDirection = "top",
209
- arrowLocation = "center",
210
- offsetSpacing = 0
211
- }) {
181
+ arrowDirection,
182
+ arrowLocation,
183
+ offsetSpacing,
184
+ selector
185
+ }) => {
212
186
  if (!(childrenRef == null ? void 0 : childrenRef.current)) {
213
187
  console.error(
214
188
  "\u7EC4\u4EF6\u5305\u88F9\u7684children\u53EF\u80FD\u662F\u4E00\u4E2A\u7EC4\u4EF6\uFF0C\u60A8\u7684\u5F53\u524D\u5199\u6CD5\u53EF\u80FD\u5BFC\u81F4ref\u6CA1\u6709\u7ED1\u5B9A\u5230children\u4E0A\uFF0C\u8BF7\u5C1D\u8BD5\u5BF9children\u5BF9\u5E94\u7684\u7EC4\u4EF6\u4F7F\u7528/* @__PURE__ */ React.forwardRef\u6765\u89E3\u51B3"
215
189
  );
216
190
  return null;
217
191
  }
218
- const childrenOffset = yield getBoundingClientRect(childrenRef.current);
219
- const tipOffset = yield getBoundingClientRect(tipRef.current);
220
- if (!tipOffset || !childrenOffset) {
221
- return {
222
- styles: {},
223
- childrenStyle: {},
224
- newArrowDirection: arrowDirection,
225
- newArrowLocation: arrowLocation
226
- };
227
- }
228
- let scrollRootOffset;
229
- if (scrollRoot) {
230
- scrollRootOffset = yield getBoundingClientRect(scrollRoot);
231
- } else {
232
- scrollRootOffset = yield getClientRect();
233
- }
192
+ const childrenOffset = childrenRef.current.getBoundingClientRect();
193
+ const $rtDom = document.querySelector(selector);
194
+ if (!$rtDom)
195
+ return null;
196
+ const tipOffset = $rtDom.getBoundingClientRect();
197
+ const scrollRootOffset = scrollRoot.getBoundingClientRect();
234
198
  const { newArrowDirection, newArrowLocation } = getNewDirectionLocation({
235
199
  scrollRoot,
236
200
  scrollRootOffset,
@@ -240,7 +204,7 @@ const getStylesAndLocation = (_0) => __async(void 0, [_0], function* ({
240
204
  arrowLocation,
241
205
  offsetSpacing
242
206
  });
243
- const { styles, childrenStyle } = yield getDirectionLocationStyle({
207
+ const { styles, childrenStyle } = getDirectionLocationStyle({
244
208
  childrenOffset,
245
209
  arrowDirection: newArrowDirection,
246
210
  tipOffset,
@@ -254,7 +218,7 @@ const getStylesAndLocation = (_0) => __async(void 0, [_0], function* ({
254
218
  newArrowDirection,
255
219
  newArrowLocation
256
220
  };
257
- });
221
+ };
258
222
  const onMouseEnter = "onMouseEnter";
259
223
  const onMouseLeave = "onMouseLeave";
260
224
  const onClick = "onClick";
@@ -1 +1,2 @@
1
- export default function getBoundingClientRect(ele: any): Promise<DOMRect>;
1
+ import type { TaroElement } from '@tarojs/runtime';
2
+ export default function getBoundingClientRect(ele: TaroElement): Promise<DOMRect>;
@@ -1,39 +1,10 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e) {
7
- reject(e);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e) {
14
- reject(e);
15
- }
16
- };
17
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
1
  import Taro from "@tarojs/taro";
22
- import { isTt, isWeapp } from "../isMini";
23
2
  function getBoundingClientRect(ele) {
24
- return __async(this, null, function* () {
25
- let result;
26
- if (isWeapp || isTt) {
27
- result = yield ele.getBoundingClientRect();
28
- } else {
29
- const query = Taro.createSelectorQuery();
30
- result = yield new Promise((resolve) => {
31
- query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
32
- resolve(res);
33
- });
34
- });
35
- }
36
- return result;
3
+ return new Promise((resolve) => {
4
+ const query = Taro.createSelectorQuery();
5
+ query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
6
+ resolve(res);
7
+ });
37
8
  });
38
9
  }
39
10
  export {
@@ -0,0 +1,2 @@
1
+ declare const getRootElement: (rootEle?: HTMLElement | (() => HTMLElement)) => HTMLElement;
2
+ export default getRootElement;
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ import type { TaroElement } from '@tarojs/runtime';
2
+ declare const getRootElement: (rootEle?: TaroElement | (() => TaroElement)) => HTMLElement | TaroElement;
3
+ export default getRootElement;
@@ -1,13 +1,13 @@
1
1
  import Taro from "@tarojs/taro";
2
- const getRootContainer = (rootCon, defaultCon) => {
2
+ const getRootElement = (rootEle) => {
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 rootCon === "function" ? rootCon() : rootCon;
8
- return rootElement || defaultCon || defaultRootElement;
7
+ const rootElement = typeof rootEle === "function" ? rootEle() : rootEle;
8
+ return rootElement || defaultRootElement;
9
9
  };
10
- var index_miniapp_default = getRootContainer;
10
+ var index_miniapp_default = getRootElement;
11
11
  export {
12
12
  index_miniapp_default as default
13
13
  };
@@ -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, { touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd } from './useTouchEmulator';
4
+ import useTouchEmulator 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, touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
11
+ export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
package/es/hooks/index.js CHANGED
@@ -1,12 +1,7 @@
1
1
  import useDidMountEffect from "./useDidMountEffect";
2
2
  import useEventCallback from "./useEventCallback";
3
3
  import useForkRef from "./useForkRef";
4
- import useTouchEmulator, {
5
- touchEmulator,
6
- emulateTouchStart,
7
- emulateTouchMove,
8
- emulateTouchEnd
9
- } from "./useTouchEmulator";
4
+ import useTouchEmulator from "./useTouchEmulator";
10
5
  import useValue from "./useValue";
11
6
  import useDomReady from "./useDomReady";
12
7
  import useSize from "./useSize";
@@ -14,10 +9,6 @@ import useDomCss from "./useDomCss";
14
9
  import useTouch from "./useTouch";
15
10
  import useUniqueId from "./useUniqueId";
16
11
  export {
17
- emulateTouchEnd,
18
- emulateTouchMove,
19
- emulateTouchStart,
20
- touchEmulator,
21
12
  useDidMountEffect,
22
13
  useDomCss,
23
14
  useDomReady,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * skip inital run useEffect
2
+ * skip initial run useEffect
3
3
  */
4
4
  declare const useDidMountEffect: (func: any, deps: any) => void;
5
5
  export default useDidMountEffect;
@@ -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 };
1
+ export default function useTouchEmulator(dom?: HTMLElement | Window): void;
@@ -66,44 +66,25 @@ 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");
72
69
  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", emulateTouchStart, true);
76
- dom.addEventListener("mousemove", emulateTouchMove, true);
77
- dom.addEventListener("mouseup", emulateTouchEnd, true);
75
+ dom.addEventListener("mousedown", touchStart, true);
76
+ dom.addEventListener("mousemove", touchMove, true);
77
+ dom.addEventListener("mouseup", touchEnd, true);
78
78
  }
79
79
  return () => {
80
80
  if (dom) {
81
- dom.removeEventListener("mousedown", emulateTouchStart, true);
82
- dom.removeEventListener("mousemove", emulateTouchMove, true);
83
- dom.removeEventListener("mouseup", emulateTouchEnd, true);
81
+ dom.removeEventListener("mousedown", touchStart, true);
82
+ dom.removeEventListener("mousemove", touchMove, true);
83
+ dom.removeEventListener("mouseup", touchEnd, 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;
103
88
  export {
104
- useTouchEmulator_default as default,
105
- emulateTouchEnd,
106
- emulateTouchMove,
107
- emulateTouchStart,
108
- touchEmulator
89
+ useTouchEmulator as default
109
90
  };
package/es/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as debounce } from './debounce';
2
- export { getStylesAndLocation, getNewDirectionLocation, triggerEventTransform, parsePlacement, } from './directionLocationUtil';
2
+ export { getStylesAndLocation, triggerEventTransform, parsePlacement, } from './directionLocationUtil';
3
3
  export { default as convertHexToRGBA } from './hex2rgba';
4
- export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, touchEmulator, emulateTouchStart, emulateTouchMove, emulateTouchEnd, useValue, useDomReady, useSize, useDomCss, useTouch, useUniqueId, } from './hooks';
4
+ export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator, 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,8 +9,7 @@ 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 getRootContainer } from './getRootContainer';
12
+ export { default as getRootElement } from './getRootElement';
13
13
  export { default as getBoundingClientRect } from './getBoundingClientRect';
14
- export { getScrollRect, getClientRect } from './domUtils';
15
14
  export * from './isType';
16
15
  export * from './render';
package/es/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { default as default2 } from "./debounce";
2
2
  import {
3
3
  getStylesAndLocation,
4
- getNewDirectionLocation,
5
4
  triggerEventTransform,
6
5
  parsePlacement
7
6
  } from "./directionLocationUtil";
@@ -11,10 +10,6 @@ import {
11
10
  useEventCallback,
12
11
  useForkRef,
13
12
  useTouchEmulator,
14
- touchEmulator,
15
- emulateTouchStart,
16
- emulateTouchMove,
17
- emulateTouchEnd,
18
13
  useValue,
19
14
  useDomReady,
20
15
  useSize,
@@ -34,9 +29,8 @@ import {
34
29
  getTransitionProps,
35
30
  createTransitions
36
31
  } from "./transitions";
37
- import { default as default9 } from "./getRootContainer";
32
+ import { default as default9 } from "./getRootElement";
38
33
  import { default as default10 } from "./getBoundingClientRect";
39
- import { getScrollRect, getClientRect } from "./domUtils";
40
34
  export * from "./isType";
41
35
  export * from "./render";
42
36
  export {
@@ -46,14 +40,8 @@ export {
46
40
  default2 as debounce,
47
41
  duration,
48
42
  easing,
49
- emulateTouchEnd,
50
- emulateTouchMove,
51
- emulateTouchStart,
52
43
  default10 as getBoundingClientRect,
53
- getClientRect,
54
- getNewDirectionLocation,
55
- default9 as getRootContainer,
56
- getScrollRect,
44
+ default9 as getRootElement,
57
45
  getStylesAndLocation,
58
46
  getTransitionProps,
59
47
  isAlipay,
@@ -65,7 +53,6 @@ export {
65
53
  default5 as setRef,
66
54
  default6 as throttle,
67
55
  default7 as toArray,
68
- touchEmulator,
69
56
  triggerEventTransform,
70
57
  useDidMountEffect,
71
58
  useDomCss,
package/es/isMini.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  declare const isMini: boolean;
2
2
  declare const isWeapp: boolean;
3
3
  declare const isAlipay: boolean;
4
- declare const isTt: boolean;
5
- export { isMini, isWeapp, isAlipay, isTt };
4
+ export { isMini, isWeapp, isAlipay };
6
5
  export declare const isMiniapp: () => boolean;
package/es/isMini.js CHANGED
@@ -1,7 +1,6 @@
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";
5
4
  const isMiniapp = () => {
6
5
  return isMini;
7
6
  };
@@ -9,6 +8,5 @@ export {
9
8
  isAlipay,
10
9
  isMini,
11
10
  isMiniapp,
12
- isTt,
13
11
  isWeapp
14
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifrostui/utils",
3
- "version": "1.4.8-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "BUI React utilities for building components.",
5
5
  "main": "dist/index.js",
6
6
  "module": "es/index.js",
@@ -1,12 +0,0 @@
1
- export declare const getClientRect: () => Promise<{
2
- width: number;
3
- height: number;
4
- left: number;
5
- top: number;
6
- right: number;
7
- bottom: number;
8
- }>;
9
- export declare const getScrollRect: () => Promise<{
10
- top: number;
11
- left: number;
12
- }>;