@bifrostui/utils 1.5.0 → 2.0.0-alpha.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 +12 -27
- package/dist/directionLocationUtil.js +55 -101
- package/dist/getBoundingClientRect/index.miniapp.d.ts +2 -1
- package/dist/getBoundingClientRect/index.miniapp.js +5 -34
- package/dist/getRootElement/index.d.ts +2 -0
- package/dist/{getRootContainer → getRootElement}/index.js +8 -8
- package/dist/getRootElement/index.miniapp.d.ts +3 -0
- package/dist/{getRootContainer → getRootElement}/index.miniapp.js +4 -4
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +0 -8
- package/dist/hooks/useDidMountEffect.d.ts +1 -1
- package/dist/hooks/useTouchEmulator.d.ts +1 -7
- package/dist/hooks/useTouchEmulator.js +10 -36
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -19
- package/dist/isMini.d.ts +1 -2
- package/dist/isMini.js +0 -3
- package/dist/themeCreator/createTheme.d.ts +10 -0
- package/dist/themeCreator/createTheme.js +61 -0
- package/dist/themeCreator/cssVarToValue.d.ts +5 -0
- package/dist/themeCreator/cssVarToValue.js +52 -0
- package/dist/themeCreator/index.d.ts +3 -0
- package/dist/themeCreator/index.js +25 -0
- package/dist/themeCreator/index.types.d.ts +37 -0
- package/dist/themeCreator/index.types.js +15 -0
- package/es/directionLocationUtil.d.ts +12 -27
- package/es/directionLocationUtil.js +55 -91
- package/es/getBoundingClientRect/index.miniapp.d.ts +2 -1
- package/es/getBoundingClientRect/index.miniapp.js +5 -34
- package/es/getRootElement/index.d.ts +2 -0
- package/es/getRootElement/index.js +9 -0
- package/es/getRootElement/index.miniapp.d.ts +3 -0
- package/es/{getRootContainer → getRootElement}/index.miniapp.js +4 -4
- package/es/hooks/index.d.ts +2 -2
- package/es/hooks/index.js +1 -10
- package/es/hooks/useDidMountEffect.d.ts +1 -1
- package/es/hooks/useTouchEmulator.d.ts +1 -7
- package/es/hooks/useTouchEmulator.js +10 -29
- package/es/index.d.ts +4 -4
- package/es/index.js +3 -15
- package/es/isMini.d.ts +1 -2
- package/es/isMini.js +0 -2
- package/es/themeCreator/createTheme.d.ts +10 -0
- package/es/themeCreator/createTheme.js +37 -0
- package/es/themeCreator/cssVarToValue.d.ts +5 -0
- package/es/themeCreator/cssVarToValue.js +29 -0
- package/es/themeCreator/index.d.ts +3 -0
- package/es/themeCreator/index.js +3 -0
- package/es/themeCreator/index.types.d.ts +37 -0
- package/es/themeCreator/index.types.js +1 -0
- package/package.json +3 -2
- package/dist/domUtils/index.d.ts +0 -12
- package/dist/domUtils/index.js +0 -46
- package/dist/domUtils/index.miniapp.d.ts +0 -2
- package/dist/domUtils/index.miniapp.js +0 -86
- package/dist/getRootContainer/index.d.ts +0 -2
- package/dist/getRootContainer/index.miniapp.d.ts +0 -3
- package/es/domUtils/index.d.ts +0 -12
- package/es/domUtils/index.js +0 -22
- package/es/domUtils/index.miniapp.d.ts +0 -2
- package/es/domUtils/index.miniapp.js +0 -54
- package/es/getRootContainer/index.d.ts +0 -2
- package/es/getRootContainer/index.js +0 -9
- package/es/getRootContainer/index.miniapp.d.ts +0 -3
@@ -22,41 +22,26 @@ export declare const getDirectionLocationStyle: ({ childrenOffset, arrowDirectio
|
|
22
22
|
tipOffset: any;
|
23
23
|
arrowLocation: any;
|
24
24
|
offsetSpacing: any;
|
25
|
-
}) =>
|
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,
|
32
|
+
export declare const getStylesAndLocation: ({ scrollRoot, childrenRef, arrowDirection, arrowLocation, offsetSpacing, selector, }: {
|
38
33
|
scrollRoot?: Element;
|
39
|
-
childrenRef
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}) =>
|
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,8 +1,6 @@
|
|
1
|
-
var __create = Object.create;
|
2
1
|
var __defProp = Object.defineProperty;
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
5
|
var __export = (target, all) => {
|
8
6
|
for (var name in all)
|
@@ -16,35 +14,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
16
14
|
}
|
17
15
|
return to;
|
18
16
|
};
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25
|
-
mod
|
26
|
-
));
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
29
|
-
return new Promise((resolve, reject) => {
|
30
|
-
var fulfilled = (value) => {
|
31
|
-
try {
|
32
|
-
step(generator.next(value));
|
33
|
-
} catch (e) {
|
34
|
-
reject(e);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
var rejected = (value) => {
|
38
|
-
try {
|
39
|
-
step(generator.throw(value));
|
40
|
-
} catch (e) {
|
41
|
-
reject(e);
|
42
|
-
}
|
43
|
-
};
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
46
|
-
});
|
47
|
-
};
|
48
18
|
var directionLocationUtil_exports = {};
|
49
19
|
__export(directionLocationUtil_exports, {
|
50
20
|
getDirectionLocationStyle: () => getDirectionLocationStyle,
|
@@ -54,14 +24,15 @@ __export(directionLocationUtil_exports, {
|
|
54
24
|
triggerEventTransform: () => triggerEventTransform
|
55
25
|
});
|
56
26
|
module.exports = __toCommonJS(directionLocationUtil_exports);
|
57
|
-
var import_domUtils = require("./domUtils");
|
58
|
-
var import_getBoundingClientRect = __toESM(require("./getBoundingClientRect"));
|
59
27
|
const directionCssMap = {
|
60
28
|
left: "right",
|
61
29
|
right: "left",
|
62
30
|
top: "bottom",
|
63
31
|
bottom: "top"
|
64
32
|
};
|
33
|
+
const isBodyScroll = (scrollRoot) => {
|
34
|
+
return scrollRoot === document.body;
|
35
|
+
};
|
65
36
|
const getNewDirectionLocation = ({
|
66
37
|
scrollRoot,
|
67
38
|
scrollRootOffset,
|
@@ -84,15 +55,14 @@ const getNewDirectionLocation = ({
|
|
84
55
|
top: sTop,
|
85
56
|
bottom: sBottom,
|
86
57
|
left: sLeft,
|
87
|
-
right: sRight
|
88
|
-
width: pageWidth,
|
89
|
-
height: pageHeight
|
58
|
+
right: sRight
|
90
59
|
} = scrollRootOffset;
|
91
|
-
const
|
92
|
-
const
|
93
|
-
const
|
94
|
-
const
|
95
|
-
const
|
60
|
+
const pageWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
61
|
+
const pageHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
62
|
+
const maxTop = isBodyScroll(scrollRoot) ? 0 : sTop;
|
63
|
+
const maxBottom = isBodyScroll(scrollRoot) ? pageHeight : sBottom;
|
64
|
+
const maxLeft = isBodyScroll(scrollRoot) ? 0 : sLeft;
|
65
|
+
const maxRight = isBodyScroll(scrollRoot) ? pageWidth : sRight;
|
96
66
|
let newArrowDirection = arrowDirection;
|
97
67
|
let newArrowLocation = arrowLocation;
|
98
68
|
const isDirectionTop = arrowDirection === "top";
|
@@ -127,14 +97,16 @@ const getNewDirectionLocation = ({
|
|
127
97
|
newArrowLocation
|
128
98
|
};
|
129
99
|
};
|
130
|
-
const getDirectionLocationStyle = (
|
100
|
+
const getDirectionLocationStyle = ({
|
131
101
|
childrenOffset,
|
132
102
|
arrowDirection,
|
133
103
|
tipOffset,
|
134
104
|
arrowLocation,
|
135
105
|
offsetSpacing
|
136
|
-
}) {
|
137
|
-
const
|
106
|
+
}) => {
|
107
|
+
const scrollTop = window.scrollY >= 0 && window.scrollY || document.documentElement.scrollTop;
|
108
|
+
const scrollLeft = window.scrollX >= 0 && window.scrollX || document.documentElement.scrollLeft;
|
109
|
+
const styles = {};
|
138
110
|
const {
|
139
111
|
width: cWidth,
|
140
112
|
height: cHeight,
|
@@ -148,125 +120,107 @@ const getDirectionLocationStyle = (_0) => __async(void 0, [_0], function* ({
|
|
148
120
|
childrenStyle = { width: `${cWidth}px`, height: `${cHeight}px` };
|
149
121
|
}
|
150
122
|
const { width, height } = tipOffset;
|
151
|
-
let styleTop;
|
152
|
-
let styleLeft;
|
153
123
|
if (arrowDirection === "top") {
|
154
|
-
|
124
|
+
styles.top = cTop - offsetSpacing - height;
|
155
125
|
switch (arrowLocation) {
|
156
126
|
case "left":
|
157
|
-
|
127
|
+
styles.left = cLeft;
|
158
128
|
break;
|
159
129
|
case "center":
|
160
|
-
|
130
|
+
styles.left = cLeft + (cWidth - width) / 2;
|
161
131
|
break;
|
162
132
|
case "right":
|
163
|
-
|
133
|
+
styles.left = cRight - width;
|
164
134
|
break;
|
165
135
|
case "none":
|
166
|
-
|
136
|
+
styles.left = cLeft;
|
167
137
|
break;
|
168
138
|
default:
|
169
139
|
break;
|
170
140
|
}
|
171
141
|
} else if (arrowDirection === "bottom") {
|
172
|
-
|
142
|
+
styles.top = cBottom + offsetSpacing;
|
173
143
|
switch (arrowLocation) {
|
174
144
|
case "left":
|
175
|
-
|
145
|
+
styles.left = cLeft;
|
176
146
|
break;
|
177
147
|
case "center":
|
178
|
-
|
148
|
+
styles.left = cLeft + (cWidth - width) / 2;
|
179
149
|
break;
|
180
150
|
case "right":
|
181
|
-
|
151
|
+
styles.left = cRight - width;
|
182
152
|
break;
|
183
153
|
case "none":
|
184
|
-
|
154
|
+
styles.left = cLeft;
|
185
155
|
break;
|
186
156
|
default:
|
187
157
|
break;
|
188
158
|
}
|
189
159
|
} else if (arrowDirection === "left") {
|
190
|
-
|
160
|
+
styles.left = cLeft - offsetSpacing - width;
|
191
161
|
switch (arrowLocation) {
|
192
162
|
case "top":
|
193
|
-
|
163
|
+
styles.top = cTop;
|
194
164
|
break;
|
195
165
|
case "center":
|
196
|
-
|
166
|
+
styles.top = cTop + (cHeight - height) / 2;
|
197
167
|
break;
|
198
168
|
case "bottom":
|
199
|
-
|
169
|
+
styles.top = cBottom - height;
|
200
170
|
break;
|
201
171
|
case "none":
|
202
|
-
|
172
|
+
styles.top = cTop;
|
203
173
|
break;
|
204
174
|
default:
|
205
175
|
break;
|
206
176
|
}
|
207
177
|
} else if (arrowDirection === "right") {
|
208
|
-
|
178
|
+
styles.left = cRight + offsetSpacing;
|
209
179
|
switch (arrowLocation) {
|
210
180
|
case "top":
|
211
|
-
|
181
|
+
styles.top = cTop;
|
212
182
|
break;
|
213
183
|
case "center":
|
214
|
-
|
184
|
+
styles.top = cTop + (cHeight - height) / 2;
|
215
185
|
break;
|
216
186
|
case "bottom":
|
217
|
-
|
187
|
+
styles.top = cBottom - height;
|
218
188
|
break;
|
219
189
|
case "none":
|
220
|
-
|
190
|
+
styles.top = cTop;
|
221
191
|
break;
|
222
192
|
default:
|
223
193
|
break;
|
224
194
|
}
|
225
195
|
}
|
226
|
-
if (
|
227
|
-
|
196
|
+
if (styles.top) {
|
197
|
+
styles.top = `${styles.top + scrollTop}px`;
|
228
198
|
}
|
229
|
-
if (
|
230
|
-
|
199
|
+
if (styles.left) {
|
200
|
+
styles.left = `${styles.left + scrollLeft}px`;
|
231
201
|
}
|
232
|
-
const styles = {
|
233
|
-
top: 0,
|
234
|
-
left: 0,
|
235
|
-
transform: `translate3d(${styleLeft}, ${styleTop}, 0)`,
|
236
|
-
visibility: ""
|
237
|
-
};
|
238
202
|
return { styles, childrenStyle };
|
239
|
-
}
|
240
|
-
const getStylesAndLocation = (
|
241
|
-
scrollRoot,
|
203
|
+
};
|
204
|
+
const getStylesAndLocation = ({
|
205
|
+
scrollRoot = document.body,
|
242
206
|
childrenRef,
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
}) {
|
207
|
+
arrowDirection,
|
208
|
+
arrowLocation,
|
209
|
+
offsetSpacing,
|
210
|
+
selector
|
211
|
+
}) => {
|
248
212
|
if (!(childrenRef == null ? void 0 : childrenRef.current)) {
|
249
213
|
console.error(
|
250
214
|
"\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"
|
251
215
|
);
|
252
216
|
return null;
|
253
217
|
}
|
254
|
-
const childrenOffset =
|
255
|
-
const
|
256
|
-
if (
|
257
|
-
return
|
258
|
-
|
259
|
-
|
260
|
-
newArrowDirection: arrowDirection,
|
261
|
-
newArrowLocation: arrowLocation
|
262
|
-
};
|
263
|
-
}
|
264
|
-
let scrollRootOffset;
|
265
|
-
if (scrollRoot) {
|
266
|
-
scrollRootOffset = yield (0, import_getBoundingClientRect.default)(scrollRoot);
|
267
|
-
} else {
|
268
|
-
scrollRootOffset = yield (0, import_domUtils.getClientRect)();
|
269
|
-
}
|
218
|
+
const childrenOffset = childrenRef.current.getBoundingClientRect();
|
219
|
+
const $rtDom = document.querySelector(selector);
|
220
|
+
if (!$rtDom)
|
221
|
+
return null;
|
222
|
+
const tipOffset = $rtDom.getBoundingClientRect();
|
223
|
+
const scrollRootOffset = scrollRoot.getBoundingClientRect();
|
270
224
|
const { newArrowDirection, newArrowLocation } = getNewDirectionLocation({
|
271
225
|
scrollRoot,
|
272
226
|
scrollRootOffset,
|
@@ -276,7 +230,7 @@ const getStylesAndLocation = (_0) => __async(void 0, [_0], function* ({
|
|
276
230
|
arrowLocation,
|
277
231
|
offsetSpacing
|
278
232
|
});
|
279
|
-
const { styles, childrenStyle } =
|
233
|
+
const { styles, childrenStyle } = getDirectionLocationStyle({
|
280
234
|
childrenOffset,
|
281
235
|
arrowDirection: newArrowDirection,
|
282
236
|
tipOffset,
|
@@ -290,7 +244,7 @@ const getStylesAndLocation = (_0) => __async(void 0, [_0], function* ({
|
|
290
244
|
newArrowDirection,
|
291
245
|
newArrowLocation
|
292
246
|
};
|
293
|
-
}
|
247
|
+
};
|
294
248
|
const onMouseEnter = "onMouseEnter";
|
295
249
|
const onMouseLeave = "onMouseLeave";
|
296
250
|
const onClick = "onClick";
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import type { TaroElement } from '@tarojs/runtime';
|
2
|
+
export default function getBoundingClientRect(ele: TaroElement): Promise<DOMRect>;
|
@@ -25,46 +25,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
25
|
mod
|
26
26
|
));
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
|
-
var __async = (__this, __arguments, generator) => {
|
29
|
-
return new Promise((resolve, reject) => {
|
30
|
-
var fulfilled = (value) => {
|
31
|
-
try {
|
32
|
-
step(generator.next(value));
|
33
|
-
} catch (e) {
|
34
|
-
reject(e);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
var rejected = (value) => {
|
38
|
-
try {
|
39
|
-
step(generator.throw(value));
|
40
|
-
} catch (e) {
|
41
|
-
reject(e);
|
42
|
-
}
|
43
|
-
};
|
44
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
45
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
46
|
-
});
|
47
|
-
};
|
48
28
|
var index_miniapp_exports = {};
|
49
29
|
__export(index_miniapp_exports, {
|
50
30
|
default: () => getBoundingClientRect
|
51
31
|
});
|
52
32
|
module.exports = __toCommonJS(index_miniapp_exports);
|
53
33
|
var import_taro = __toESM(require("@tarojs/taro"));
|
54
|
-
var import_isMini = require("../isMini");
|
55
34
|
function getBoundingClientRect(ele) {
|
56
|
-
return
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
}
|
61
|
-
const query = import_taro.default.createSelectorQuery();
|
62
|
-
result = yield new Promise((resolve) => {
|
63
|
-
query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
|
64
|
-
resolve(res);
|
65
|
-
});
|
66
|
-
});
|
67
|
-
}
|
68
|
-
return result;
|
35
|
+
return new Promise((resolve) => {
|
36
|
+
const query = import_taro.default.createSelectorQuery();
|
37
|
+
query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
|
38
|
+
resolve(res);
|
39
|
+
});
|
69
40
|
});
|
70
41
|
}
|
@@ -15,14 +15,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
return to;
|
16
16
|
};
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var
|
19
|
-
__export(
|
20
|
-
default: () =>
|
18
|
+
var getRootElement_exports = {};
|
19
|
+
__export(getRootElement_exports, {
|
20
|
+
default: () => getRootElement_default
|
21
21
|
});
|
22
|
-
module.exports = __toCommonJS(
|
23
|
-
const
|
24
|
-
const rootElement = typeof
|
22
|
+
module.exports = __toCommonJS(getRootElement_exports);
|
23
|
+
const getRootElement = (rootEle) => {
|
24
|
+
const rootElement = typeof rootEle === "function" ? rootEle() : rootEle;
|
25
25
|
const defaultRootElement = document.body;
|
26
|
-
return rootElement ||
|
26
|
+
return rootElement || defaultRootElement;
|
27
27
|
};
|
28
|
-
var
|
28
|
+
var getRootElement_default = getRootElement;
|
@@ -31,12 +31,12 @@ __export(index_miniapp_exports, {
|
|
31
31
|
});
|
32
32
|
module.exports = __toCommonJS(index_miniapp_exports);
|
33
33
|
var import_taro = __toESM(require("@tarojs/taro"));
|
34
|
-
const
|
34
|
+
const getRootElement = (rootEle) => {
|
35
35
|
const currentPages = import_taro.default.getCurrentPages() || [];
|
36
36
|
const currentPage = currentPages[currentPages.length - 1];
|
37
37
|
const pageElement = currentPage == null ? void 0 : currentPage.$taroPath;
|
38
38
|
const defaultRootElement = document.getElementById(pageElement);
|
39
|
-
const rootElement = typeof
|
40
|
-
return rootElement ||
|
39
|
+
const rootElement = typeof rootEle === "function" ? rootEle() : rootEle;
|
40
|
+
return rootElement || defaultRootElement;
|
41
41
|
};
|
42
|
-
var index_miniapp_default =
|
42
|
+
var index_miniapp_default = getRootElement;
|
package/dist/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
|
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,
|
11
|
+
export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, useTouch, useUniqueId, };
|
package/dist/hooks/index.js
CHANGED
@@ -27,10 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28
28
|
var hooks_exports = {};
|
29
29
|
__export(hooks_exports, {
|
30
|
-
emulateTouchEnd: () => import_useTouchEmulator.emulateTouchEnd,
|
31
|
-
emulateTouchMove: () => import_useTouchEmulator.emulateTouchMove,
|
32
|
-
emulateTouchStart: () => import_useTouchEmulator.emulateTouchStart,
|
33
|
-
touchEmulator: () => import_useTouchEmulator.touchEmulator,
|
34
30
|
useDidMountEffect: () => import_useDidMountEffect.default,
|
35
31
|
useDomCss: () => import_useDomCss.default,
|
36
32
|
useDomReady: () => import_useDomReady.default,
|
@@ -55,10 +51,6 @@ var import_useTouch = __toESM(require("./useTouch"));
|
|
55
51
|
var import_useUniqueId = __toESM(require("./useUniqueId"));
|
56
52
|
// Annotate the CommonJS export names for ESM import in node:
|
57
53
|
0 && (module.exports = {
|
58
|
-
emulateTouchEnd,
|
59
|
-
emulateTouchMove,
|
60
|
-
emulateTouchStart,
|
61
|
-
touchEmulator,
|
62
54
|
useDidMountEffect,
|
63
55
|
useDomCss,
|
64
56
|
useDomReady,
|
@@ -1,7 +1 @@
|
|
1
|
-
|
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;
|
@@ -17,11 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
18
|
var useTouchEmulator_exports = {};
|
19
19
|
__export(useTouchEmulator_exports, {
|
20
|
-
default: () =>
|
21
|
-
emulateTouchEnd: () => emulateTouchEnd,
|
22
|
-
emulateTouchMove: () => emulateTouchMove,
|
23
|
-
emulateTouchStart: () => emulateTouchStart,
|
24
|
-
touchEmulator: () => touchEmulator
|
20
|
+
default: () => useTouchEmulator
|
25
21
|
});
|
26
22
|
module.exports = __toCommonJS(useTouchEmulator_exports);
|
27
23
|
var import_react = require("react");
|
@@ -92,44 +88,22 @@ function getActiveTouches(mouseEv) {
|
|
92
88
|
}
|
93
89
|
return createTouchList(mouseEv);
|
94
90
|
}
|
95
|
-
const emulateTouchStart = onMouse("touchstart");
|
96
|
-
const emulateTouchMove = onMouse("touchmove");
|
97
|
-
const emulateTouchEnd = onMouse("touchend");
|
98
91
|
function useTouchEmulator(dom = window) {
|
92
|
+
const touchStart = onMouse("touchstart");
|
93
|
+
const touchMove = onMouse("touchmove");
|
94
|
+
const touchEnd = onMouse("touchend");
|
99
95
|
(0, import_react.useEffect)(() => {
|
100
96
|
if (dom) {
|
101
|
-
dom.addEventListener("mousedown",
|
102
|
-
dom.addEventListener("mousemove",
|
103
|
-
dom.addEventListener("mouseup",
|
97
|
+
dom.addEventListener("mousedown", touchStart, true);
|
98
|
+
dom.addEventListener("mousemove", touchMove, true);
|
99
|
+
dom.addEventListener("mouseup", touchEnd, true);
|
104
100
|
}
|
105
101
|
return () => {
|
106
102
|
if (dom) {
|
107
|
-
dom.removeEventListener("mousedown",
|
108
|
-
dom.removeEventListener("mousemove",
|
109
|
-
dom.removeEventListener("mouseup",
|
103
|
+
dom.removeEventListener("mousedown", touchStart, true);
|
104
|
+
dom.removeEventListener("mousemove", touchMove, true);
|
105
|
+
dom.removeEventListener("mouseup", touchEnd, true);
|
110
106
|
}
|
111
107
|
};
|
112
108
|
}, [dom]);
|
113
109
|
}
|
114
|
-
const touchEmulator = (dom = window) => {
|
115
|
-
if (dom) {
|
116
|
-
dom.addEventListener("mousedown", emulateTouchStart, true);
|
117
|
-
dom.addEventListener("mousemove", emulateTouchMove, true);
|
118
|
-
dom.addEventListener("mouseup", emulateTouchEnd, true);
|
119
|
-
}
|
120
|
-
return function() {
|
121
|
-
if (dom) {
|
122
|
-
dom.removeEventListener("mousedown", emulateTouchStart, true);
|
123
|
-
dom.removeEventListener("mousemove", emulateTouchMove, true);
|
124
|
-
dom.removeEventListener("mouseup", emulateTouchEnd, true);
|
125
|
-
}
|
126
|
-
};
|
127
|
-
};
|
128
|
-
var useTouchEmulator_default = useTouchEmulator;
|
129
|
-
// Annotate the CommonJS export names for ESM import in node:
|
130
|
-
0 && (module.exports = {
|
131
|
-
emulateTouchEnd,
|
132
|
-
emulateTouchMove,
|
133
|
-
emulateTouchStart,
|
134
|
-
touchEmulator
|
135
|
-
});
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { default as debounce } from './debounce';
|
2
|
-
export { getStylesAndLocation,
|
2
|
+
export { getStylesAndLocation, triggerEventTransform, parsePlacement, } from './directionLocationUtil';
|
3
3
|
export { default as convertHexToRGBA } from './hex2rgba';
|
4
|
-
export { useDidMountEffect, useEventCallback, useForkRef, useTouchEmulator,
|
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,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 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';
|
16
|
+
export * from './themeCreator';
|
package/dist/index.js
CHANGED
@@ -34,14 +34,8 @@ __export(src_exports, {
|
|
34
34
|
debounce: () => import_debounce.default,
|
35
35
|
duration: () => import_transitions.duration,
|
36
36
|
easing: () => import_transitions.easing,
|
37
|
-
emulateTouchEnd: () => import_hooks.emulateTouchEnd,
|
38
|
-
emulateTouchMove: () => import_hooks.emulateTouchMove,
|
39
|
-
emulateTouchStart: () => import_hooks.emulateTouchStart,
|
40
37
|
getBoundingClientRect: () => import_getBoundingClientRect.default,
|
41
|
-
|
42
|
-
getNewDirectionLocation: () => import_directionLocationUtil.getNewDirectionLocation,
|
43
|
-
getRootContainer: () => import_getRootContainer.default,
|
44
|
-
getScrollRect: () => import_domUtils.getScrollRect,
|
38
|
+
getRootElement: () => import_getRootElement.default,
|
45
39
|
getStylesAndLocation: () => import_directionLocationUtil.getStylesAndLocation,
|
46
40
|
getTransitionProps: () => import_transitions.getTransitionProps,
|
47
41
|
isAlipay: () => import_isMini.isAlipay,
|
@@ -53,7 +47,6 @@ __export(src_exports, {
|
|
53
47
|
setRef: () => import_setRef.default,
|
54
48
|
throttle: () => import_throttle.default,
|
55
49
|
toArray: () => import_toArray.default,
|
56
|
-
touchEmulator: () => import_hooks.touchEmulator,
|
57
50
|
triggerEventTransform: () => import_directionLocationUtil.triggerEventTransform,
|
58
51
|
useDidMountEffect: () => import_hooks.useDidMountEffect,
|
59
52
|
useDomCss: () => import_hooks.useDomCss,
|
@@ -78,11 +71,11 @@ var import_throttle = __toESM(require("./throttle"));
|
|
78
71
|
var import_toArray = __toESM(require("./toArray"));
|
79
72
|
var import_touchBlocker = __toESM(require("./touchBlocker"));
|
80
73
|
var import_transitions = require("./transitions");
|
81
|
-
var
|
74
|
+
var import_getRootElement = __toESM(require("./getRootElement"));
|
82
75
|
var import_getBoundingClientRect = __toESM(require("./getBoundingClientRect"));
|
83
|
-
var import_domUtils = require("./domUtils");
|
84
76
|
__reExport(src_exports, require("./isType"), module.exports);
|
85
77
|
__reExport(src_exports, require("./render"), module.exports);
|
78
|
+
__reExport(src_exports, require("./themeCreator"), module.exports);
|
86
79
|
// Annotate the CommonJS export names for ESM import in node:
|
87
80
|
0 && (module.exports = {
|
88
81
|
blockTouch,
|
@@ -91,14 +84,8 @@ __reExport(src_exports, require("./render"), module.exports);
|
|
91
84
|
debounce,
|
92
85
|
duration,
|
93
86
|
easing,
|
94
|
-
emulateTouchEnd,
|
95
|
-
emulateTouchMove,
|
96
|
-
emulateTouchStart,
|
97
87
|
getBoundingClientRect,
|
98
|
-
|
99
|
-
getNewDirectionLocation,
|
100
|
-
getRootContainer,
|
101
|
-
getScrollRect,
|
88
|
+
getRootElement,
|
102
89
|
getStylesAndLocation,
|
103
90
|
getTransitionProps,
|
104
91
|
isAlipay,
|
@@ -110,7 +97,6 @@ __reExport(src_exports, require("./render"), module.exports);
|
|
110
97
|
setRef,
|
111
98
|
throttle,
|
112
99
|
toArray,
|
113
|
-
touchEmulator,
|
114
100
|
triggerEventTransform,
|
115
101
|
useDidMountEffect,
|
116
102
|
useDomCss,
|
@@ -123,5 +109,6 @@ __reExport(src_exports, require("./render"), module.exports);
|
|
123
109
|
useUniqueId,
|
124
110
|
useValue,
|
125
111
|
...require("./isType"),
|
126
|
-
...require("./render")
|
112
|
+
...require("./render"),
|
113
|
+
...require("./themeCreator")
|
127
114
|
});
|