@bifrostui/utils 0.0.5

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/debounce.d.ts +1 -0
  4. package/dist/debounce.js +37 -0
  5. package/dist/domTarget.d.ts +7 -0
  6. package/dist/domTarget.js +42 -0
  7. package/dist/getBoundingClientRect/index.d.ts +1 -0
  8. package/dist/getBoundingClientRect/index.js +27 -0
  9. package/dist/getBoundingClientRect/index.miniapp.d.ts +2 -0
  10. package/dist/getBoundingClientRect/index.miniapp.js +43 -0
  11. package/dist/hex2rgba.d.ts +2 -0
  12. package/dist/hex2rgba.js +39 -0
  13. package/dist/hooks/index.d.ts +9 -0
  14. package/dist/hooks/index.js +60 -0
  15. package/dist/hooks/useDidMountEffect.d.ts +5 -0
  16. package/dist/hooks/useDidMountEffect.js +35 -0
  17. package/dist/hooks/useDomCss/index.d.ts +3 -0
  18. package/dist/hooks/useDomCss/index.js +48 -0
  19. package/dist/hooks/useDomCss/index.miniapp.d.ts +3 -0
  20. package/dist/hooks/useDomCss/index.miniapp.js +51 -0
  21. package/dist/hooks/useDomReady/index.d.ts +2 -0
  22. package/dist/hooks/useDomReady/index.js +41 -0
  23. package/dist/hooks/useDomReady/index.miniapp.d.ts +2 -0
  24. package/dist/hooks/useDomReady/index.miniapp.js +43 -0
  25. package/dist/hooks/useEventCallback.d.ts +6 -0
  26. package/dist/hooks/useEventCallback.js +42 -0
  27. package/dist/hooks/useForkRef.d.ts +2 -0
  28. package/dist/hooks/useForkRef.js +48 -0
  29. package/dist/hooks/useMemoizedFn.d.ts +3 -0
  30. package/dist/hooks/useMemoizedFn.js +55 -0
  31. package/dist/hooks/useSize.d.ts +7 -0
  32. package/dist/hooks/useSize.js +51 -0
  33. package/dist/hooks/useTouchEmulator.d.ts +1 -0
  34. package/dist/hooks/useTouchEmulator.js +111 -0
  35. package/dist/hooks/useValue.d.ts +12 -0
  36. package/dist/hooks/useValue.js +49 -0
  37. package/dist/index.d.ts +12 -0
  38. package/dist/index.js +96 -0
  39. package/dist/isDev.d.ts +2 -0
  40. package/dist/isDev.js +26 -0
  41. package/dist/isMini.d.ts +4 -0
  42. package/dist/isMini.js +35 -0
  43. package/dist/isType.d.ts +1 -0
  44. package/dist/isType.js +31 -0
  45. package/dist/setRef.d.ts +2 -0
  46. package/dist/setRef.js +31 -0
  47. package/dist/throttle.d.ts +6 -0
  48. package/dist/throttle.js +52 -0
  49. package/dist/toArray.d.ts +6 -0
  50. package/dist/toArray.js +52 -0
  51. package/dist/touchBlocker.d.ts +11 -0
  52. package/dist/touchBlocker.js +108 -0
  53. package/dist/transitions.d.ts +72 -0
  54. package/dist/transitions.js +91 -0
  55. package/es/debounce.d.ts +1 -0
  56. package/es/debounce.js +15 -0
  57. package/es/domTarget.d.ts +7 -0
  58. package/es/domTarget.js +14 -0
  59. package/es/getBoundingClientRect/index.d.ts +1 -0
  60. package/es/getBoundingClientRect/index.js +3 -0
  61. package/es/getBoundingClientRect/index.miniapp.d.ts +2 -0
  62. package/es/getBoundingClientRect/index.miniapp.js +17 -0
  63. package/es/hex2rgba.d.ts +2 -0
  64. package/es/hex2rgba.js +25 -0
  65. package/es/hooks/index.d.ts +9 -0
  66. package/es/hooks/index.js +9 -0
  67. package/es/hooks/useDidMountEffect.d.ts +5 -0
  68. package/es/hooks/useDidMountEffect.js +11 -0
  69. package/es/hooks/useDomCss/index.d.ts +3 -0
  70. package/es/hooks/useDomCss/index.js +14 -0
  71. package/es/hooks/useDomCss/index.miniapp.d.ts +3 -0
  72. package/es/hooks/useDomCss/index.miniapp.js +17 -0
  73. package/es/hooks/useDomReady/index.d.ts +2 -0
  74. package/es/hooks/useDomReady/index.js +7 -0
  75. package/es/hooks/useDomReady/index.miniapp.d.ts +2 -0
  76. package/es/hooks/useDomReady/index.miniapp.js +9 -0
  77. package/es/hooks/useEventCallback.d.ts +6 -0
  78. package/es/hooks/useEventCallback.js +18 -0
  79. package/es/hooks/useForkRef.d.ts +2 -0
  80. package/es/hooks/useForkRef.js +25 -0
  81. package/es/hooks/useMemoizedFn.d.ts +3 -0
  82. package/es/hooks/useMemoizedFn.js +25 -0
  83. package/es/hooks/useSize.d.ts +7 -0
  84. package/es/hooks/useSize.js +29 -0
  85. package/es/hooks/useTouchEmulator.d.ts +1 -0
  86. package/es/hooks/useTouchEmulator.js +146 -0
  87. package/es/hooks/useValue.d.ts +12 -0
  88. package/es/hooks/useValue.js +36 -0
  89. package/es/index.d.ts +12 -0
  90. package/es/index.js +12 -0
  91. package/es/isDev.d.ts +2 -0
  92. package/es/isDev.js +2 -0
  93. package/es/isMini.d.ts +4 -0
  94. package/es/isMini.js +4 -0
  95. package/es/isType.d.ts +1 -0
  96. package/es/isType.js +4 -0
  97. package/es/setRef.d.ts +2 -0
  98. package/es/setRef.js +7 -0
  99. package/es/throttle.d.ts +6 -0
  100. package/es/throttle.js +49 -0
  101. package/es/toArray.d.ts +6 -0
  102. package/es/toArray.js +19 -0
  103. package/es/touchBlocker.d.ts +11 -0
  104. package/es/touchBlocker.js +90 -0
  105. package/es/transitions.d.ts +72 -0
  106. package/es/transitions.js +65 -0
  107. package/package.json +32 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Alibaba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # `@bifrostui/utils`
2
+
3
+ Common utils function for BUI
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ // with npm
9
+ npm install @bifrostui/utils
10
+
11
+ // with yarn
12
+ yarn add @bifrostui/utils
13
+ ```
@@ -0,0 +1 @@
1
+ export default function debounce(func: any, wait: number, immediate?: boolean): (...args: any[]) => void;
@@ -0,0 +1,37 @@
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
+
19
+ // src/debounce.ts
20
+ var debounce_exports = {};
21
+ __export(debounce_exports, {
22
+ default: () => debounce
23
+ });
24
+ module.exports = __toCommonJS(debounce_exports);
25
+ function debounce(func, wait, immediate) {
26
+ let timeout;
27
+ return function(...args) {
28
+ if (immediate && !timeout)
29
+ func.apply(this, args);
30
+ clearTimeout(timeout);
31
+ timeout = setTimeout(() => {
32
+ timeout = null;
33
+ if (!immediate)
34
+ func.apply(this, args);
35
+ }, wait);
36
+ };
37
+ }
@@ -0,0 +1,7 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import type { TaroElement } from '@tarojs/runtime';
3
+ type TargetValue<T> = T | undefined | null;
4
+ type TargetType = HTMLElement | Element | TaroElement | Window | Document;
5
+ export type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
6
+ export declare function getTargetElement<T extends TargetType>(target: BasicTarget<T>, defaultElement?: T): T;
7
+ export {};
@@ -0,0 +1,42 @@
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
+
19
+ // src/domTarget.ts
20
+ var domTarget_exports = {};
21
+ __export(domTarget_exports, {
22
+ getTargetElement: () => getTargetElement
23
+ });
24
+ module.exports = __toCommonJS(domTarget_exports);
25
+ function getTargetElement(target, defaultElement) {
26
+ if (!target) {
27
+ return defaultElement;
28
+ }
29
+ let targetElement;
30
+ if (typeof target === "function") {
31
+ targetElement = target();
32
+ } else if ("current" in target) {
33
+ targetElement = target.current;
34
+ } else {
35
+ targetElement = target;
36
+ }
37
+ return targetElement;
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getTargetElement
42
+ });
@@ -0,0 +1 @@
1
+ export default function getBoundingClientRect(ele: Element): Promise<DOMRect>;
@@ -0,0 +1,27 @@
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
+
19
+ // src/getBoundingClientRect/index.ts
20
+ var getBoundingClientRect_exports = {};
21
+ __export(getBoundingClientRect_exports, {
22
+ default: () => getBoundingClientRect
23
+ });
24
+ module.exports = __toCommonJS(getBoundingClientRect_exports);
25
+ function getBoundingClientRect(ele) {
26
+ return Promise.resolve(ele.getBoundingClientRect());
27
+ }
@@ -0,0 +1,2 @@
1
+ import type { TaroElement } from '@tarojs/runtime';
2
+ export default function getBoundingClientRect(ele: TaroElement): Promise<DOMRect>;
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/getBoundingClientRect/index.miniapp.ts
30
+ var index_miniapp_exports = {};
31
+ __export(index_miniapp_exports, {
32
+ default: () => getBoundingClientRect
33
+ });
34
+ module.exports = __toCommonJS(index_miniapp_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ function getBoundingClientRect(ele) {
37
+ return new Promise((resolve) => {
38
+ const query = import_taro.default.createSelectorQuery();
39
+ query.select(`#${ele.uid}`).boundingClientRect().exec(([res]) => {
40
+ resolve(res);
41
+ });
42
+ });
43
+ }
@@ -0,0 +1,2 @@
1
+ declare const convertHexToRGBA: (hexCode: string, opacity?: number) => string;
2
+ export default convertHexToRGBA;
@@ -0,0 +1,39 @@
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
+
19
+ // src/hex2rgba.ts
20
+ var hex2rgba_exports = {};
21
+ __export(hex2rgba_exports, {
22
+ default: () => hex2rgba_default
23
+ });
24
+ module.exports = __toCommonJS(hex2rgba_exports);
25
+ var convertHexToRGBA = (hexCode, opacity = 1) => {
26
+ let hex = hexCode.replace("#", "");
27
+ if (hex.length === 3) {
28
+ hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
29
+ }
30
+ const r = parseInt(hex.substring(0, 2), 16);
31
+ const g = parseInt(hex.substring(2, 4), 16);
32
+ const b = parseInt(hex.substring(4, 6), 16);
33
+ let a = opacity;
34
+ if (opacity > 1 && opacity <= 100) {
35
+ a = opacity / 100;
36
+ }
37
+ return `rgba(${r},${g},${b},${a})`;
38
+ };
39
+ var hex2rgba_default = convertHexToRGBA;
@@ -0,0 +1,9 @@
1
+ import useDidMountEffect from './useDidMountEffect';
2
+ import useEventCallback from './useEventCallback';
3
+ import useForkRef from './useForkRef';
4
+ import useTouchEmulator from './useTouchEmulator';
5
+ import useValue from './useValue';
6
+ import useDomReady from './useDomReady';
7
+ import useSize from './useSize';
8
+ import useDomCss from './useDomCss';
9
+ export { useValue, useForkRef, useEventCallback, useDidMountEffect, useTouchEmulator, useDomReady, useSize, useDomCss, };
@@ -0,0 +1,60 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/index.ts
30
+ var hooks_exports = {};
31
+ __export(hooks_exports, {
32
+ useDidMountEffect: () => import_useDidMountEffect.default,
33
+ useDomCss: () => import_useDomCss.default,
34
+ useDomReady: () => import_useDomReady.default,
35
+ useEventCallback: () => import_useEventCallback.default,
36
+ useForkRef: () => import_useForkRef.default,
37
+ useSize: () => import_useSize.default,
38
+ useTouchEmulator: () => import_useTouchEmulator.default,
39
+ useValue: () => import_useValue.default
40
+ });
41
+ module.exports = __toCommonJS(hooks_exports);
42
+ var import_useDidMountEffect = __toESM(require("./useDidMountEffect"));
43
+ var import_useEventCallback = __toESM(require("./useEventCallback"));
44
+ var import_useForkRef = __toESM(require("./useForkRef"));
45
+ var import_useTouchEmulator = __toESM(require("./useTouchEmulator"));
46
+ var import_useValue = __toESM(require("./useValue"));
47
+ var import_useDomReady = __toESM(require("./useDomReady"));
48
+ var import_useSize = __toESM(require("./useSize"));
49
+ var import_useDomCss = __toESM(require("./useDomCss"));
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ useDidMountEffect,
53
+ useDomCss,
54
+ useDomReady,
55
+ useEventCallback,
56
+ useForkRef,
57
+ useSize,
58
+ useTouchEmulator,
59
+ useValue
60
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * skip inital run useEffect
3
+ */
4
+ declare const useDidMountEffect: (func: any, deps: any) => void;
5
+ export default useDidMountEffect;
@@ -0,0 +1,35 @@
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
+
19
+ // src/hooks/useDidMountEffect.ts
20
+ var useDidMountEffect_exports = {};
21
+ __export(useDidMountEffect_exports, {
22
+ default: () => useDidMountEffect_default
23
+ });
24
+ module.exports = __toCommonJS(useDidMountEffect_exports);
25
+ var import_react = require("react");
26
+ var useDidMountEffect = (func, deps) => {
27
+ const didMount = (0, import_react.useRef)(false);
28
+ (0, import_react.useEffect)(() => {
29
+ if (didMount.current)
30
+ func();
31
+ else
32
+ didMount.current = true;
33
+ }, deps);
34
+ };
35
+ var useDidMountEffect_default = useDidMountEffect;
@@ -0,0 +1,3 @@
1
+ import type { BasicTarget } from '../../domTarget';
2
+ declare function useDomCss(target: BasicTarget, computedStyle: string[], cb: (res: Record<string, any>) => void): void;
3
+ export default useDomCss;
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useDomCss/index.ts
30
+ var useDomCss_exports = {};
31
+ __export(useDomCss_exports, {
32
+ default: () => useDomCss_default
33
+ });
34
+ module.exports = __toCommonJS(useDomCss_exports);
35
+ var import_useDomReady = __toESM(require("../useDomReady"));
36
+ var import_domTarget = require("../../domTarget");
37
+ function useDomCss(target, computedStyle, cb) {
38
+ (0, import_useDomReady.default)(() => {
39
+ const ele = (0, import_domTarget.getTargetElement)(target);
40
+ const style = window.getComputedStyle(ele, null);
41
+ const res = {};
42
+ computedStyle.forEach((key) => {
43
+ res[key] = style == null ? void 0 : style[key];
44
+ });
45
+ cb == null ? void 0 : cb(res);
46
+ });
47
+ }
48
+ var useDomCss_default = useDomCss;
@@ -0,0 +1,3 @@
1
+ import type { TaroElement } from '@tarojs/runtime';
2
+ declare function useDomCss(target: TaroElement, computedStyle: string[], cb: (res: Record<string, any>) => void): void;
3
+ export default useDomCss;
@@ -0,0 +1,51 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useDomCss/index.miniapp.ts
30
+ var index_miniapp_exports = {};
31
+ __export(index_miniapp_exports, {
32
+ default: () => index_miniapp_default
33
+ });
34
+ module.exports = __toCommonJS(index_miniapp_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ var import_useDomReady = __toESM(require("../useDomReady"));
37
+ var import_domTarget = require("../../domTarget");
38
+ function useDomCss(target, computedStyle, cb) {
39
+ (0, import_useDomReady.default)(() => {
40
+ const ele = (0, import_domTarget.getTargetElement)(target);
41
+ if (ele) {
42
+ const query = import_taro.default.createSelectorQuery();
43
+ query.select(`#${ele == null ? void 0 : ele.uid}`).fields({
44
+ computedStyle
45
+ }).exec((res) => {
46
+ cb == null ? void 0 : cb(res == null ? void 0 : res[0]);
47
+ });
48
+ }
49
+ });
50
+ }
51
+ var index_miniapp_default = useDomCss;
@@ -0,0 +1,2 @@
1
+ declare function useDomReady(cb: () => void): void;
2
+ export default useDomReady;
@@ -0,0 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useDomReady/index.ts
30
+ var useDomReady_exports = {};
31
+ __export(useDomReady_exports, {
32
+ default: () => useDomReady_default
33
+ });
34
+ module.exports = __toCommonJS(useDomReady_exports);
35
+ var import_react = __toESM(require("react"));
36
+ function useDomReady(cb) {
37
+ import_react.default.useEffect(() => {
38
+ cb == null ? void 0 : cb();
39
+ }, []);
40
+ }
41
+ var useDomReady_default = useDomReady;
@@ -0,0 +1,2 @@
1
+ declare function useDomReady(cb: () => void): void;
2
+ export default useDomReady;
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useDomReady/index.miniapp.ts
30
+ var index_miniapp_exports = {};
31
+ __export(index_miniapp_exports, {
32
+ default: () => index_miniapp_default
33
+ });
34
+ module.exports = __toCommonJS(index_miniapp_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ function useDomReady(cb) {
37
+ import_taro.default.useReady(() => {
38
+ import_taro.default.nextTick(() => {
39
+ cb == null ? void 0 : cb();
40
+ });
41
+ });
42
+ }
43
+ var index_miniapp_default = useDomReady;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * https://github.com/facebook/react/issues/14099#issuecomment-440013892
3
+ *
4
+ * @param {function} fn
5
+ */
6
+ export default function useEventCallback(fn: any): (...args: any[]) => any;
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useEventCallback.ts
30
+ var useEventCallback_exports = {};
31
+ __export(useEventCallback_exports, {
32
+ default: () => useEventCallback
33
+ });
34
+ module.exports = __toCommonJS(useEventCallback_exports);
35
+ var import_react = __toESM(require("react"));
36
+ function useEventCallback(fn) {
37
+ const ref = import_react.default.useRef(fn);
38
+ (0, import_react.useLayoutEffect)(() => {
39
+ ref.current = fn;
40
+ });
41
+ return import_react.default.useCallback((...args) => (0, ref.current)(...args), []);
42
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export default function useForkRef<Instance>(...refs: Array<React.Ref<Instance> | undefined>): React.RefCallback<Instance> | null;