@bifrostui/utils 1.1.11-beta.0 → 1.1.11-beta.4

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 (57) hide show
  1. package/README.md +3 -0
  2. package/dist/debounce.js +4 -4
  3. package/dist/domTarget.js +0 -2
  4. package/dist/getBoundingClientRect/index.js +0 -2
  5. package/dist/getBoundingClientRect/index.miniapp.js +0 -2
  6. package/dist/hex2rgba.js +1 -3
  7. package/dist/hooks/index.js +0 -2
  8. package/dist/hooks/useDidMountEffect.js +5 -5
  9. package/dist/hooks/useDomCss/index.js +0 -2
  10. package/dist/hooks/useDomCss/index.miniapp.js +0 -2
  11. package/dist/hooks/useDomReady/index.js +0 -2
  12. package/dist/hooks/useDomReady/index.miniapp.js +0 -2
  13. package/dist/hooks/useEventCallback.js +0 -2
  14. package/dist/hooks/useForkRef.js +0 -2
  15. package/dist/hooks/useMemoizedFn.js +0 -2
  16. package/dist/hooks/useSize.js +0 -2
  17. package/dist/hooks/useTouch.js +4 -5
  18. package/dist/hooks/useTouchEmulator.js +3 -5
  19. package/dist/hooks/useValue.js +0 -2
  20. package/dist/index.js +0 -2
  21. package/dist/isDev.js +1 -3
  22. package/dist/isMini.js +4 -6
  23. package/dist/isType.js +1 -3
  24. package/dist/setRef.js +0 -2
  25. package/dist/throttle.js +2 -3
  26. package/dist/toArray.js +0 -2
  27. package/dist/touchBlocker.js +6 -5
  28. package/dist/transitions.js +29 -19
  29. package/es/debounce.js +12 -11
  30. package/es/domTarget.js +8 -5
  31. package/es/getBoundingClientRect/index.js +5 -2
  32. package/es/getBoundingClientRect/index.miniapp.js +9 -14
  33. package/es/hex2rgba.js +12 -19
  34. package/es/hooks/index.js +11 -1
  35. package/es/hooks/useDidMountEffect.js +12 -9
  36. package/es/hooks/useDomCss/index.js +11 -8
  37. package/es/hooks/useDomCss/index.miniapp.js +12 -9
  38. package/es/hooks/useDomReady/index.js +7 -4
  39. package/es/hooks/useDomReady/index.miniapp.js +8 -5
  40. package/es/hooks/useEventCallback.js +9 -16
  41. package/es/hooks/useForkRef.js +10 -18
  42. package/es/hooks/useMemoizedFn.js +13 -14
  43. package/es/hooks/useSize.js +10 -19
  44. package/es/hooks/useTouch.js +47 -47
  45. package/es/hooks/useTouchEmulator.js +34 -90
  46. package/es/hooks/useValue.js +24 -32
  47. package/es/index.js +54 -12
  48. package/es/isDev.js +5 -2
  49. package/es/isMini.js +11 -6
  50. package/es/isType.js +6 -4
  51. package/es/setRef.js +6 -3
  52. package/es/throttle.js +16 -34
  53. package/es/toArray.js +10 -8
  54. package/es/touchBlocker.js +59 -62
  55. package/es/transitions.js +57 -45
  56. package/package.json +13 -7
  57. package/src/index.ts +27 -0
package/README.md CHANGED
@@ -10,4 +10,7 @@ npm install @bifrostui/utils
10
10
 
11
11
  // with yarn
12
12
  yarn add @bifrostui/utils
13
+
14
+ // with pnpm
15
+ pnpm add @bifrostui/utils
13
16
  ```
package/dist/debounce.js CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/debounce.ts
20
18
  var debounce_exports = {};
21
19
  __export(debounce_exports, {
22
20
  default: () => debounce
@@ -25,11 +23,13 @@ module.exports = __toCommonJS(debounce_exports);
25
23
  function debounce(func, wait, immediate) {
26
24
  let timeout;
27
25
  return function(...args) {
28
- if (immediate && !timeout) func.apply(this, args);
26
+ if (immediate && !timeout)
27
+ func.apply(this, args);
29
28
  clearTimeout(timeout);
30
29
  timeout = setTimeout(() => {
31
30
  timeout = null;
32
- if (!immediate) func.apply(this, args);
31
+ if (!immediate)
32
+ func.apply(this, args);
33
33
  }, wait);
34
34
  };
35
35
  }
package/dist/domTarget.js CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/domTarget.ts
20
18
  var domTarget_exports = {};
21
19
  __export(domTarget_exports, {
22
20
  getTargetElement: () => getTargetElement
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/getBoundingClientRect/index.ts
20
18
  var getBoundingClientRect_exports = {};
21
19
  __export(getBoundingClientRect_exports, {
22
20
  default: () => getBoundingClientRect
@@ -25,8 +25,6 @@ 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
-
29
- // src/getBoundingClientRect/index.miniapp.ts
30
28
  var index_miniapp_exports = {};
31
29
  __export(index_miniapp_exports, {
32
30
  default: () => getBoundingClientRect
package/dist/hex2rgba.js CHANGED
@@ -15,14 +15,12 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/hex2rgba.ts
20
18
  var hex2rgba_exports = {};
21
19
  __export(hex2rgba_exports, {
22
20
  default: () => hex2rgba_default
23
21
  });
24
22
  module.exports = __toCommonJS(hex2rgba_exports);
25
- var convertHexToRGBA = (hexCode, opacity = 1) => {
23
+ const convertHexToRGBA = (hexCode, opacity = 1) => {
26
24
  let hex = hexCode.replace("#", "");
27
25
  if (hex.length === 3) {
28
26
  hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/index.ts
30
28
  var hooks_exports = {};
31
29
  __export(hooks_exports, {
32
30
  useDidMountEffect: () => import_useDidMountEffect.default,
@@ -15,19 +15,19 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/hooks/useDidMountEffect.ts
20
18
  var useDidMountEffect_exports = {};
21
19
  __export(useDidMountEffect_exports, {
22
20
  default: () => useDidMountEffect_default
23
21
  });
24
22
  module.exports = __toCommonJS(useDidMountEffect_exports);
25
23
  var import_react = require("react");
26
- var useDidMountEffect = (func, deps) => {
24
+ const useDidMountEffect = (func, deps) => {
27
25
  const didMount = (0, import_react.useRef)(false);
28
26
  (0, import_react.useEffect)(() => {
29
- if (didMount.current) func();
30
- else didMount.current = true;
27
+ if (didMount.current)
28
+ func();
29
+ else
30
+ didMount.current = true;
31
31
  }, deps);
32
32
  };
33
33
  var useDidMountEffect_default = useDidMountEffect;
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useDomCss/index.ts
30
28
  var useDomCss_exports = {};
31
29
  __export(useDomCss_exports, {
32
30
  default: () => useDomCss_default
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useDomCss/index.miniapp.ts
30
28
  var index_miniapp_exports = {};
31
29
  __export(index_miniapp_exports, {
32
30
  default: () => index_miniapp_default
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useDomReady/index.ts
30
28
  var useDomReady_exports = {};
31
29
  __export(useDomReady_exports, {
32
30
  default: () => useDomReady_default
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useDomReady/index.miniapp.ts
30
28
  var index_miniapp_exports = {};
31
29
  __export(index_miniapp_exports, {
32
30
  default: () => index_miniapp_default
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useEventCallback.ts
30
28
  var useEventCallback_exports = {};
31
29
  __export(useEventCallback_exports, {
32
30
  default: () => useEventCallback
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useForkRef.ts
30
28
  var useForkRef_exports = {};
31
29
  __export(useForkRef_exports, {
32
30
  default: () => useForkRef
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useMemoizedFn.ts
30
28
  var useMemoizedFn_exports = {};
31
29
  __export(useMemoizedFn_exports, {
32
30
  default: () => useMemoizedFn
@@ -25,8 +25,6 @@ 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
-
29
- // src/hooks/useSize.ts
30
28
  var useSize_exports = {};
31
29
  __export(useSize_exports, {
32
30
  default: () => useSize_default
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __pow = Math.pow;
5
6
  var __export = (target, all) => {
6
7
  for (var name in all)
7
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,15 +16,13 @@ var __copyProps = (to, from, except, desc) => {
15
16
  return to;
16
17
  };
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/hooks/useTouch.ts
20
19
  var useTouch_exports = {};
21
20
  __export(useTouch_exports, {
22
21
  default: () => useTouch_default
23
22
  });
24
23
  module.exports = __toCommonJS(useTouch_exports);
25
24
  var import_react = require("react");
26
- var MIN_DISTANCE = 10;
25
+ const MIN_DISTANCE = 10;
27
26
  function getDirection(x, y) {
28
27
  if (x > y && x > MIN_DISTANCE) {
29
28
  return "horizontal";
@@ -33,7 +32,7 @@ function getDirection(x, y) {
33
32
  }
34
33
  return "";
35
34
  }
36
- var useTouch = () => {
35
+ const useTouch = () => {
37
36
  const startX = (0, import_react.useRef)(0);
38
37
  const startY = (0, import_react.useRef)(0);
39
38
  const deltaX = (0, import_react.useRef)(0);
@@ -76,7 +75,7 @@ var useTouch = () => {
76
75
  };
77
76
  const end = () => {
78
77
  last.current = true;
79
- velocity.current = Math.sqrt(deltaX.current ** 2 + deltaY.current ** 2) / (Date.now() - touchTime.current);
78
+ velocity.current = Math.sqrt(__pow(deltaX.current, 2) + __pow(deltaY.current, 2)) / (Date.now() - touchTime.current);
80
79
  };
81
80
  return {
82
81
  end,
@@ -15,16 +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
-
19
- // src/hooks/useTouchEmulator.ts
20
18
  var useTouchEmulator_exports = {};
21
19
  __export(useTouchEmulator_exports, {
22
20
  default: () => useTouchEmulator
23
21
  });
24
22
  module.exports = __toCommonJS(useTouchEmulator_exports);
25
23
  var import_react = require("react");
26
- var eventTarget;
27
- var Touch = function Touch2(target, identifier, pos, deltaX, deltaY) {
24
+ let eventTarget;
25
+ const Touch = function Touch2(target, identifier, pos, deltaX, deltaY) {
28
26
  deltaX = deltaX || 0;
29
27
  deltaY = deltaY || 0;
30
28
  this.identifier = identifier;
@@ -46,7 +44,7 @@ function TouchList() {
46
44
  };
47
45
  return touchList;
48
46
  }
49
- var initiated = false;
47
+ let initiated = false;
50
48
  function onMouse(touchType) {
51
49
  return function(ev) {
52
50
  if (ev.type === "mousedown") {
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/hooks/useValue.ts
20
18
  var useValue_exports = {};
21
19
  __export(useValue_exports, {
22
20
  default: () => useValue
package/dist/index.js CHANGED
@@ -26,8 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
29
  var src_exports = {};
32
30
  __export(src_exports, {
33
31
  blockTouch: () => import_touchBlocker.default,
package/dist/isDev.js CHANGED
@@ -15,12 +15,10 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/isDev.ts
20
18
  var isDev_exports = {};
21
19
  __export(isDev_exports, {
22
20
  default: () => isDev_default
23
21
  });
24
22
  module.exports = __toCommonJS(isDev_exports);
25
- var isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
23
+ const isDev = process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
26
24
  var isDev_default = isDev;
package/dist/isMini.js CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/isMini.ts
20
18
  var isMini_exports = {};
21
19
  __export(isMini_exports, {
22
20
  isAlipay: () => isAlipay,
@@ -25,10 +23,10 @@ __export(isMini_exports, {
25
23
  isWeapp: () => isWeapp
26
24
  });
27
25
  module.exports = __toCommonJS(isMini_exports);
28
- var isMini = typeof process.env.TARO_ENV === "string";
29
- var isWeapp = process.env.TARO_ENV === "weapp";
30
- var isAlipay = process.env.TARO_ENV === "alipay";
31
- var isMiniapp = () => {
26
+ const isMini = typeof process.env.TARO_ENV === "string";
27
+ const isWeapp = process.env.TARO_ENV === "weapp";
28
+ const isAlipay = process.env.TARO_ENV === "alipay";
29
+ const isMiniapp = () => {
32
30
  return isMini;
33
31
  };
34
32
  // Annotate the CommonJS export names for ESM import in node:
package/dist/isType.js CHANGED
@@ -15,14 +15,12 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/isType.ts
20
18
  var isType_exports = {};
21
19
  __export(isType_exports, {
22
20
  isFunction: () => isFunction
23
21
  });
24
22
  module.exports = __toCommonJS(isType_exports);
25
- var isFunction = (fn) => {
23
+ const isFunction = (fn) => {
26
24
  return fn && {}.toString.call(fn) === "[object Function]";
27
25
  };
28
26
  // Annotate the CommonJS export names for ESM import in node:
package/dist/setRef.js CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/setRef.ts
20
18
  var setRef_exports = {};
21
19
  __export(setRef_exports, {
22
20
  default: () => setRef
package/dist/throttle.js CHANGED
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/throttle.ts
20
18
  var throttle_exports = {};
21
19
  __export(throttle_exports, {
22
20
  default: () => throttle
@@ -28,7 +26,8 @@ function throttle(fn, interval = 200, options = { leading: true, trailing: false
28
26
  let timer = null;
29
27
  const _throttle = function(...args) {
30
28
  const nowTime = (/* @__PURE__ */ new Date()).getTime();
31
- if (!lastTime && !leading) lastTime = nowTime;
29
+ if (!lastTime && !leading)
30
+ lastTime = nowTime;
32
31
  const remainTime = interval - (nowTime - lastTime);
33
32
  if (remainTime <= 0) {
34
33
  if (timer) {
package/dist/toArray.js CHANGED
@@ -25,8 +25,6 @@ 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
-
29
- // src/toArray.ts
30
28
  var toArray_exports = {};
31
29
  __export(toArray_exports, {
32
30
  default: () => toArray
@@ -15,8 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/touchBlocker.ts
20
18
  var touchBlocker_exports = {};
21
19
  __export(touchBlocker_exports, {
22
20
  default: () => blockTouch
@@ -36,7 +34,8 @@ function blockTouch(root) {
36
34
  const { overflowY, overflowX } = window.getComputedStyle(el);
37
35
  if (axis === "y" && (overflowY === "scroll" || overflowY === "auto")) {
38
36
  const dir = moveDirection || delta;
39
- if (moveDirection === void 0) moveDirection = dir;
37
+ if (moveDirection === void 0)
38
+ moveDirection = dir;
40
39
  if (el.scrollTop !== 0 && dir < 0) {
41
40
  needPrevent = false;
42
41
  break;
@@ -48,7 +47,8 @@ function blockTouch(root) {
48
47
  }
49
48
  if (axis === "x" && (overflowX === "scroll" || overflowX === "auto")) {
50
49
  const dir = moveDirection || delta;
51
- if (moveDirection === void 0) moveDirection = dir;
50
+ if (moveDirection === void 0)
51
+ moveDirection = dir;
52
52
  if (el.scrollLeft !== 0 && dir < 0) {
53
53
  needPrevent = false;
54
54
  break;
@@ -58,7 +58,8 @@ function blockTouch(root) {
58
58
  break;
59
59
  }
60
60
  }
61
- if (el === root) break;
61
+ if (el === root)
62
+ break;
62
63
  el = el.parentNode;
63
64
  }
64
65
  return needPrevent;
@@ -1,7 +1,24 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
3
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5
22
  var __export = (target, all) => {
6
23
  for (var name in all)
7
24
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,8 +32,6 @@ var __copyProps = (to, from, except, desc) => {
15
32
  return to;
16
33
  };
17
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/transitions.ts
20
35
  var transitions_exports = {};
21
36
  __export(transitions_exports, {
22
37
  createTransitions: () => createTransitions,
@@ -25,13 +40,13 @@ __export(transitions_exports, {
25
40
  getTransitionProps: () => getTransitionProps
26
41
  });
27
42
  module.exports = __toCommonJS(transitions_exports);
28
- var easing = {
43
+ const easing = {
29
44
  easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
30
45
  easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
31
46
  easeIn: "cubic-bezier(0.4, 0, 1, 1)",
32
47
  sharp: "cubic-bezier(0.4, 0, 0.6, 1)"
33
48
  };
34
- var duration = {
49
+ const duration = {
35
50
  shortest: 150,
36
51
  shorter: 200,
37
52
  short: 250,
@@ -43,28 +58,23 @@ var duration = {
43
58
  leavingScreen: 195
44
59
  };
45
60
  function getTransitionProps(props, options) {
61
+ var _a, _b, _c;
46
62
  const { timeout, easing: easingProps, style = {}, delay } = props;
47
63
  let { mode } = options;
48
64
  if (mode !== "enter" && mode !== "exit")
49
65
  mode = mode === "entering" || mode === "entered" ? "enter" : "exit";
50
66
  return {
51
- duration: style.transitionDuration ?? (typeof timeout === "number" ? timeout : timeout[mode] || 0),
52
- easing: style.transitionTimingFunction ?? (typeof easingProps === "object" ? easingProps[mode] : easingProps),
53
- delay: style.transitionDelay ?? (typeof delay === "number" ? delay : delay[mode] || 0)
67
+ duration: (_a = style.transitionDuration) != null ? _a : typeof timeout === "number" ? timeout : timeout[mode] || 0,
68
+ easing: (_b = style.transitionTimingFunction) != null ? _b : typeof easingProps === "object" ? easingProps[mode] : easingProps,
69
+ delay: (_c = style.transitionDelay) != null ? _c : typeof delay === "number" ? delay : delay[mode] || 0
54
70
  };
55
71
  }
56
72
  function formatMs(milliseconds) {
57
73
  return `${Math.round(milliseconds)}ms`;
58
74
  }
59
75
  function createTransitions(inputTransitions = {}) {
60
- const mergedEasing = {
61
- ...easing,
62
- ...inputTransitions.easing
63
- };
64
- const mergedDuration = {
65
- ...duration,
66
- ...inputTransitions.duration
67
- };
76
+ const mergedEasing = __spreadValues(__spreadValues({}, easing), inputTransitions.easing);
77
+ const mergedDuration = __spreadValues(__spreadValues({}, duration), inputTransitions.duration);
68
78
  const create = (props = ["all"], options) => {
69
79
  const {
70
80
  duration: durationOption = mergedDuration.standard,
@@ -75,12 +85,12 @@ function createTransitions(inputTransitions = {}) {
75
85
  (animatedProp) => `${animatedProp} ${typeof durationOption === "string" ? durationOption : formatMs(durationOption)} ${easingOption} ${typeof delay === "string" ? delay : formatMs(delay)}`
76
86
  ).join(",");
77
87
  };
78
- return {
79
- create,
80
- ...inputTransitions,
88
+ return __spreadProps(__spreadValues({
89
+ create
90
+ }, inputTransitions), {
81
91
  easing: mergedEasing,
82
92
  duration: mergedDuration
83
- };
93
+ });
84
94
  }
85
95
  // Annotate the CommonJS export names for ESM import in node:
86
96
  0 && (module.exports = {
package/es/debounce.js CHANGED
@@ -1,15 +1,16 @@
1
- export default function debounce(func, wait, immediate) {
2
- var timeout;
3
- return function () {
4
- var _this = this;
5
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6
- args[_key] = arguments[_key];
7
- }
8
- if (immediate && !timeout) func.apply(this, args);
1
+ function debounce(func, wait, immediate) {
2
+ let timeout;
3
+ return function(...args) {
4
+ if (immediate && !timeout)
5
+ func.apply(this, args);
9
6
  clearTimeout(timeout);
10
- timeout = setTimeout(function () {
7
+ timeout = setTimeout(() => {
11
8
  timeout = null;
12
- if (!immediate) func.apply(_this, args);
9
+ if (!immediate)
10
+ func.apply(this, args);
13
11
  }, wait);
14
12
  };
15
- }
13
+ }
14
+ export {
15
+ debounce as default
16
+ };
package/es/domTarget.js CHANGED
@@ -1,14 +1,17 @@
1
- export function getTargetElement(target, defaultElement) {
1
+ function getTargetElement(target, defaultElement) {
2
2
  if (!target) {
3
3
  return defaultElement;
4
4
  }
5
- var targetElement;
6
- if (typeof target === 'function') {
5
+ let targetElement;
6
+ if (typeof target === "function") {
7
7
  targetElement = target();
8
- } else if ('current' in target) {
8
+ } else if ("current" in target) {
9
9
  targetElement = target.current;
10
10
  } else {
11
11
  targetElement = target;
12
12
  }
13
13
  return targetElement;
14
- }
14
+ }
15
+ export {
16
+ getTargetElement
17
+ };
@@ -1,3 +1,6 @@
1
- export default function getBoundingClientRect(ele) {
1
+ function getBoundingClientRect(ele) {
2
2
  return Promise.resolve(ele.getBoundingClientRect());
3
- }
3
+ }
4
+ export {
5
+ getBoundingClientRect as default
6
+ };
@@ -1,17 +1,12 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import Taro from '@tarojs/taro';
8
- export default function getBoundingClientRect(ele) {
9
- return new Promise(function (resolve) {
10
- var query = Taro.createSelectorQuery();
11
- query.select("#".concat(ele.uid)).boundingClientRect().exec(function (_ref) {
12
- var _ref2 = _slicedToArray(_ref, 1),
13
- res = _ref2[0];
1
+ import Taro from "@tarojs/taro";
2
+ function getBoundingClientRect(ele) {
3
+ return new Promise((resolve) => {
4
+ const query = Taro.createSelectorQuery();
5
+ query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
14
6
  resolve(res);
15
7
  });
16
8
  });
17
- }
9
+ }
10
+ export {
11
+ getBoundingClientRect as default
12
+ };
package/es/hex2rgba.js CHANGED
@@ -1,25 +1,18 @@
1
- /*
2
- * @Author: @跃知
3
- * @Date: 2021-12-30 20:30:48
4
- * @LastEditors: @跃知
5
- * @LastEditTime: 2021-12-30 20:35:26
6
- * @Description: 颜色处理
7
- */
8
- var convertHexToRGBA = function convertHexToRGBA(hexCode) {
9
- var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10
- var hex = hexCode.replace('#', '');
1
+ const convertHexToRGBA = (hexCode, opacity = 1) => {
2
+ let hex = hexCode.replace("#", "");
11
3
  if (hex.length === 3) {
12
- hex = "".concat(hex[0]).concat(hex[0]).concat(hex[1]).concat(hex[1]).concat(hex[2]).concat(hex[2]);
4
+ hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
13
5
  }
14
- var r = parseInt(hex.substring(0, 2), 16);
15
- var g = parseInt(hex.substring(2, 4), 16);
16
- var b = parseInt(hex.substring(4, 6), 16);
17
- var a = opacity;
18
-
19
- /* Backward compatibility for whole number based opacity values. */
6
+ const r = parseInt(hex.substring(0, 2), 16);
7
+ const g = parseInt(hex.substring(2, 4), 16);
8
+ const b = parseInt(hex.substring(4, 6), 16);
9
+ let a = opacity;
20
10
  if (opacity > 1 && opacity <= 100) {
21
11
  a = opacity / 100;
22
12
  }
23
- return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
13
+ return `rgba(${r},${g},${b},${a})`;
14
+ };
15
+ var hex2rgba_default = convertHexToRGBA;
16
+ export {
17
+ hex2rgba_default as default
24
18
  };
25
- export default convertHexToRGBA;