@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
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,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;
|
@@ -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",
|
76
|
-
dom.addEventListener("mousemove",
|
77
|
-
dom.addEventListener("mouseup",
|
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",
|
82
|
-
dom.removeEventListener("mousemove",
|
83
|
-
dom.removeEventListener("mouseup",
|
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
|
-
|
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,
|
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/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,11 +29,11 @@ import {
|
|
34
29
|
getTransitionProps,
|
35
30
|
createTransitions
|
36
31
|
} from "./transitions";
|
37
|
-
import { default as default9 } from "./
|
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";
|
36
|
+
export * from "./themeCreator";
|
42
37
|
export {
|
43
38
|
default8 as blockTouch,
|
44
39
|
default3 as convertHexToRGBA,
|
@@ -46,14 +41,8 @@ export {
|
|
46
41
|
default2 as debounce,
|
47
42
|
duration,
|
48
43
|
easing,
|
49
|
-
emulateTouchEnd,
|
50
|
-
emulateTouchMove,
|
51
|
-
emulateTouchStart,
|
52
44
|
default10 as getBoundingClientRect,
|
53
|
-
|
54
|
-
getNewDirectionLocation,
|
55
|
-
default9 as getRootContainer,
|
56
|
-
getScrollRect,
|
45
|
+
default9 as getRootElement,
|
57
46
|
getStylesAndLocation,
|
58
47
|
getTransitionProps,
|
59
48
|
isAlipay,
|
@@ -65,7 +54,6 @@ export {
|
|
65
54
|
default5 as setRef,
|
66
55
|
default6 as throttle,
|
67
56
|
default7 as toArray,
|
68
|
-
touchEmulator,
|
69
57
|
triggerEventTransform,
|
70
58
|
useDidMountEffect,
|
71
59
|
useDomCss,
|
package/es/isMini.d.ts
CHANGED
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
|
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { MountThemeVarsOptions, ThemeCreatorOptions } from './index.types';
|
2
|
+
/**
|
3
|
+
* 挂载自定义主题
|
4
|
+
*/
|
5
|
+
declare const mountThemeVars: (options: MountThemeVarsOptions) => void;
|
6
|
+
/**
|
7
|
+
* 创建主题
|
8
|
+
*/
|
9
|
+
declare const createTheme: (options: ThemeCreatorOptions) => string;
|
10
|
+
export { createTheme, mountThemeVars };
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const convertToCss = (styles) => {
|
2
|
+
let result = "";
|
3
|
+
const cssVarKeys = Object.keys(styles);
|
4
|
+
cssVarKeys.forEach((key, index) => {
|
5
|
+
const value = styles[key];
|
6
|
+
if (value.includes("PX")) {
|
7
|
+
result += "/* prettier-ignore */\n ";
|
8
|
+
}
|
9
|
+
result += `${key}: ${value};
|
10
|
+
${index === cssVarKeys.length - 1 ? "" : " "}`;
|
11
|
+
});
|
12
|
+
return result;
|
13
|
+
};
|
14
|
+
const mountThemeVars = (options) => {
|
15
|
+
const { theme = "", container } = options || {};
|
16
|
+
const style = document.createElement("style");
|
17
|
+
style.type = "text/css";
|
18
|
+
style.appendChild(document.createTextNode(theme));
|
19
|
+
if (!container) {
|
20
|
+
document.head.appendChild(style);
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
container.appendChild(style);
|
24
|
+
};
|
25
|
+
const createTheme = (options) => {
|
26
|
+
const {
|
27
|
+
rootSelector = ":root, [data-color-mode='light'][data-theme]",
|
28
|
+
cssVars = {}
|
29
|
+
} = options || {};
|
30
|
+
const rootContent = `${rootSelector} {
|
31
|
+
${convertToCss(cssVars)} }`;
|
32
|
+
return rootContent;
|
33
|
+
};
|
34
|
+
export {
|
35
|
+
createTheme,
|
36
|
+
mountThemeVars
|
37
|
+
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { defaultLight } from "@bifrostui/styles/registry";
|
2
|
+
const cssVarToValue = (options) => {
|
3
|
+
var _a;
|
4
|
+
const {
|
5
|
+
cssVar,
|
6
|
+
themeVars = (_a = defaultLight) == null ? void 0 : _a.cssVars,
|
7
|
+
_visitedKeys = /* @__PURE__ */ new Set()
|
8
|
+
} = options || {};
|
9
|
+
if (!cssVar)
|
10
|
+
return "";
|
11
|
+
const variableKey = cssVar.replace(/^var\(/, "").replace(/\)$/, "");
|
12
|
+
const variableValue = themeVars == null ? void 0 : themeVars[variableKey];
|
13
|
+
if (_visitedKeys.has(variableKey)) {
|
14
|
+
console.warn(`\u68C0\u6D4B\u5230CSS\u53D8\u91CF\u5FAA\u73AF\u5F15\u7528: ${variableKey}`);
|
15
|
+
return variableValue;
|
16
|
+
}
|
17
|
+
const nextVisited = new Set(_visitedKeys).add(variableKey);
|
18
|
+
if (variableValue && variableValue.startsWith("var(")) {
|
19
|
+
return cssVarToValue({
|
20
|
+
cssVar: variableValue,
|
21
|
+
themeVars,
|
22
|
+
_visitedKeys: nextVisited
|
23
|
+
});
|
24
|
+
}
|
25
|
+
return variableValue;
|
26
|
+
};
|
27
|
+
export {
|
28
|
+
cssVarToValue
|
29
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* 挂载自定义主题选项
|
3
|
+
*/
|
4
|
+
export interface MountThemeVarsOptions {
|
5
|
+
theme: string;
|
6
|
+
container?: HTMLElement;
|
7
|
+
}
|
8
|
+
export interface ThemeCreatorOptions {
|
9
|
+
/**
|
10
|
+
* 主题所挂在的根选择器
|
11
|
+
* @default `:root, [data-color-mode='light'][data-theme]`
|
12
|
+
*/
|
13
|
+
rootSelector?: string;
|
14
|
+
/**
|
15
|
+
* 主题全局变量
|
16
|
+
*/
|
17
|
+
cssVars: Record<string, string>;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* css变量转值
|
21
|
+
*/
|
22
|
+
export interface CssVarToValueOptions {
|
23
|
+
/**
|
24
|
+
* 当前主题
|
25
|
+
*/
|
26
|
+
cssVar: string;
|
27
|
+
/**
|
28
|
+
* 当前主题模式
|
29
|
+
* @default defaultLight
|
30
|
+
*/
|
31
|
+
themeVars?: Record<string, string>;
|
32
|
+
/**
|
33
|
+
* 记录已解析的变量路径
|
34
|
+
* 函数内部使用参数
|
35
|
+
*/
|
36
|
+
_visitedKeys?: Set<string>;
|
37
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bifrostui/utils",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-alpha.0",
|
4
4
|
"description": "BUI React utilities for building components.",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -16,7 +16,8 @@
|
|
16
16
|
"glob": "11.0.0"
|
17
17
|
},
|
18
18
|
"dependencies": {
|
19
|
-
"react-is": "^18.0.0"
|
19
|
+
"react-is": "^18.0.0",
|
20
|
+
"@bifrostui/styles": "2.0.0-alpha.0"
|
20
21
|
},
|
21
22
|
"peerDependencies": {
|
22
23
|
"@tarojs/runtime": "^3.0.0",
|
package/dist/domUtils/index.d.ts
DELETED
package/dist/domUtils/index.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
-
var __export = (target, all) => {
|
6
|
-
for (var name in all)
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
-
};
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var domUtils_exports = {};
|
19
|
-
__export(domUtils_exports, {
|
20
|
-
getClientRect: () => getClientRect,
|
21
|
-
getScrollRect: () => getScrollRect
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(domUtils_exports);
|
24
|
-
const getClientRect = () => {
|
25
|
-
const width = window.innerWidth || document.documentElement.clientWidth;
|
26
|
-
const height = window.innerHeight || document.documentElement.clientHeight;
|
27
|
-
return Promise.resolve({
|
28
|
-
width,
|
29
|
-
height,
|
30
|
-
left: 0,
|
31
|
-
top: 0,
|
32
|
-
right: width,
|
33
|
-
bottom: height
|
34
|
-
});
|
35
|
-
};
|
36
|
-
const getScrollRect = () => {
|
37
|
-
return Promise.resolve({
|
38
|
-
top: window.scrollY >= 0 && window.scrollY || document.documentElement.scrollTop,
|
39
|
-
left: window.scrollX >= 0 && window.scrollX || document.documentElement.scrollLeft
|
40
|
-
});
|
41
|
-
};
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
43
|
-
0 && (module.exports = {
|
44
|
-
getClientRect,
|
45
|
-
getScrollRect
|
46
|
-
});
|
@@ -1,86 +0,0 @@
|
|
1
|
-
var __create = Object.create;
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __defProps = Object.defineProperties;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
-
var __spreadValues = (a, b) => {
|
13
|
-
for (var prop in b || (b = {}))
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
16
|
-
if (__getOwnPropSymbols)
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
-
if (__propIsEnum.call(b, prop))
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
20
|
-
}
|
21
|
-
return a;
|
22
|
-
};
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
|
-
var __export = (target, all) => {
|
25
|
-
for (var name in all)
|
26
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
27
|
-
};
|
28
|
-
var __copyProps = (to, from, except, desc) => {
|
29
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
30
|
-
for (let key of __getOwnPropNames(from))
|
31
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
32
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
33
|
-
}
|
34
|
-
return to;
|
35
|
-
};
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
37
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
38
|
-
// file that has been converted to a CommonJS file using a Babel-
|
39
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
40
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
42
|
-
mod
|
43
|
-
));
|
44
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
45
|
-
var index_miniapp_exports = {};
|
46
|
-
__export(index_miniapp_exports, {
|
47
|
-
getClientRect: () => getClientRect,
|
48
|
-
getScrollRect: () => getScrollRect
|
49
|
-
});
|
50
|
-
module.exports = __toCommonJS(index_miniapp_exports);
|
51
|
-
var import_taro = __toESM(require("@tarojs/taro"));
|
52
|
-
const getClientRect = () => {
|
53
|
-
return new Promise((resolve, reject) => {
|
54
|
-
try {
|
55
|
-
const res = import_taro.default.getSystemInfoSync();
|
56
|
-
const width = res.windowWidth;
|
57
|
-
const height = res.windowHeight;
|
58
|
-
const clientInfo = __spreadProps(__spreadValues({}, res), {
|
59
|
-
width,
|
60
|
-
height,
|
61
|
-
left: 0,
|
62
|
-
top: 0,
|
63
|
-
right: width,
|
64
|
-
bottom: height
|
65
|
-
});
|
66
|
-
resolve(clientInfo);
|
67
|
-
} catch (error) {
|
68
|
-
reject(error);
|
69
|
-
}
|
70
|
-
});
|
71
|
-
};
|
72
|
-
const getScrollRect = () => {
|
73
|
-
return new Promise((resolve) => {
|
74
|
-
import_taro.default.createSelectorQuery().selectViewport().scrollOffset().exec((res) => {
|
75
|
-
resolve({
|
76
|
-
top: res[0].scrollTop,
|
77
|
-
left: res[0].scrollLeft
|
78
|
-
});
|
79
|
-
});
|
80
|
-
});
|
81
|
-
};
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
83
|
-
0 && (module.exports = {
|
84
|
-
getClientRect,
|
85
|
-
getScrollRect
|
86
|
-
});
|
package/es/domUtils/index.d.ts
DELETED
package/es/domUtils/index.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
const getClientRect = () => {
|
2
|
-
const width = window.innerWidth || document.documentElement.clientWidth;
|
3
|
-
const height = window.innerHeight || document.documentElement.clientHeight;
|
4
|
-
return Promise.resolve({
|
5
|
-
width,
|
6
|
-
height,
|
7
|
-
left: 0,
|
8
|
-
top: 0,
|
9
|
-
right: width,
|
10
|
-
bottom: height
|
11
|
-
});
|
12
|
-
};
|
13
|
-
const getScrollRect = () => {
|
14
|
-
return Promise.resolve({
|
15
|
-
top: window.scrollY >= 0 && window.scrollY || document.documentElement.scrollTop,
|
16
|
-
left: window.scrollX >= 0 && window.scrollX || document.documentElement.scrollLeft
|
17
|
-
});
|
18
|
-
};
|
19
|
-
export {
|
20
|
-
getClientRect,
|
21
|
-
getScrollRect
|
22
|
-
};
|
@@ -1,54 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __defProps = Object.defineProperties;
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
-
var __spreadValues = (a, b) => {
|
9
|
-
for (var prop in b || (b = {}))
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
12
|
-
if (__getOwnPropSymbols)
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
-
if (__propIsEnum.call(b, prop))
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
16
|
-
}
|
17
|
-
return a;
|
18
|
-
};
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
-
import Taro from "@tarojs/taro";
|
21
|
-
const getClientRect = () => {
|
22
|
-
return new Promise((resolve, reject) => {
|
23
|
-
try {
|
24
|
-
const res = Taro.getSystemInfoSync();
|
25
|
-
const width = res.windowWidth;
|
26
|
-
const height = res.windowHeight;
|
27
|
-
const clientInfo = __spreadProps(__spreadValues({}, res), {
|
28
|
-
width,
|
29
|
-
height,
|
30
|
-
left: 0,
|
31
|
-
top: 0,
|
32
|
-
right: width,
|
33
|
-
bottom: height
|
34
|
-
});
|
35
|
-
resolve(clientInfo);
|
36
|
-
} catch (error) {
|
37
|
-
reject(error);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
};
|
41
|
-
const getScrollRect = () => {
|
42
|
-
return new Promise((resolve) => {
|
43
|
-
Taro.createSelectorQuery().selectViewport().scrollOffset().exec((res) => {
|
44
|
-
resolve({
|
45
|
-
top: res[0].scrollTop,
|
46
|
-
left: res[0].scrollLeft
|
47
|
-
});
|
48
|
-
});
|
49
|
-
});
|
50
|
-
};
|
51
|
-
export {
|
52
|
-
getClientRect,
|
53
|
-
getScrollRect
|
54
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
const getRootContainer = (rootCon, defaultCon) => {
|
2
|
-
const rootElement = typeof rootCon === "function" ? rootCon() : rootCon;
|
3
|
-
const defaultRootElement = document.body;
|
4
|
-
return rootElement || defaultCon || defaultRootElement;
|
5
|
-
};
|
6
|
-
var getRootContainer_default = getRootContainer;
|
7
|
-
export {
|
8
|
-
getRootContainer_default as default
|
9
|
-
};
|