best-unit 0.0.35 → 0.0.37

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.
@@ -4,17 +4,17 @@ export declare function printCurrentTime(): void;
4
4
 
5
5
  export declare function initFundUnit(params: {
6
6
  token: string;
7
- merchant_id: string;
8
- biz_type: string;
9
- user_id: string;
7
+ merchant_id?: string;
8
+ biz_type?: string;
9
+ fund_balance_id?: string;
10
10
  theme?: string;
11
11
  locale?: "zh" | "en";
12
12
  }): {
13
13
  token: string;
14
- merchantId: string;
15
- bizType: string;
14
+ merchantId?: string;
15
+ bizType?: string;
16
+ fundBalanceId?: string;
16
17
  theme?: string;
17
- userId: string;
18
18
  locale: "zh" | "en";
19
19
  };
20
20
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "0.0.35",
4
+ "version": "0.0.37",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
package/src/api/index.ts CHANGED
@@ -10,6 +10,7 @@ export function getBalance() {
10
10
  params: {
11
11
  merchant_id: fundUnitParams.merchantId,
12
12
  biz_type: fundUnitParams.bizType,
13
+ fund_balance_id: fundUnitParams.fundBalanceId,
13
14
  },
14
15
  })
15
16
  .then((res) => {
@@ -29,8 +29,13 @@ const HoverPopover: FunctionalComponent<HoverPopoverProps> = ({
29
29
  "top" | "bottom" | "leftTop" | "rightTop"
30
30
  >(popoverPosition);
31
31
  const ref = useRef<HTMLDivElement>(null);
32
+ const timerRef = useRef<number | null>(null);
32
33
 
33
34
  const handleMouseEnter = () => {
35
+ if (timerRef.current) {
36
+ clearTimeout(timerRef.current);
37
+ timerRef.current = null;
38
+ }
34
39
  if (popoverPosition === "top" || popoverPosition === "bottom") {
35
40
  if (ref.current) {
36
41
  const rect = ref.current.getBoundingClientRect();
@@ -53,6 +58,13 @@ const HoverPopover: FunctionalComponent<HoverPopoverProps> = ({
53
58
  setShow(true);
54
59
  };
55
60
 
61
+ const handleMouseLeave = () => {
62
+ // 延迟关闭,防止鼠标快速移动到弹窗内容时闪烁
63
+ timerRef.current = window.setTimeout(() => {
64
+ setShow(false);
65
+ }, 120);
66
+ };
67
+
56
68
  // 弹层定位样式
57
69
  let popoverStyle: any = {
58
70
  position: "absolute",
@@ -148,11 +160,15 @@ const HoverPopover: FunctionalComponent<HoverPopoverProps> = ({
148
160
  ref={ref}
149
161
  style={{ position: "relative", display: "inline-block" }}
150
162
  onMouseEnter={handleMouseEnter}
151
- onMouseLeave={() => setShow(false)}
163
+ onMouseLeave={handleMouseLeave}
152
164
  >
153
165
  {children}
154
166
  {show && (
155
- <div style={popoverStyle}>
167
+ <div
168
+ style={popoverStyle}
169
+ onMouseEnter={handleMouseEnter}
170
+ onMouseLeave={handleMouseLeave}
171
+ >
156
172
  {popover}
157
173
  <div style={arrowStyle} />
158
174
  </div>
package/src/demo/App.tsx CHANGED
@@ -14,7 +14,6 @@ export default function DemoApp() {
14
14
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTM0MTM1MjksIm1lcmNoYW50X2lkIjoxMTI4LCJ0aW1lc3RhbXAiOjE3NTMxNTQzMjl9.UAvzq0P4HCnbJR1Ga3CgF6q3vk2RHiZRvnAFohBTHpw",
15
15
  merchant_id: "1128",
16
16
  biz_type: "ad",
17
- user_id: "123",
18
17
  locale: locale,
19
18
  });
20
19
  };
@@ -97,7 +96,7 @@ export default function DemoApp() {
97
96
  </button>
98
97
  <button onClick={printCurrentTime}>调用 printCurrentTime()</button>
99
98
  </div>
100
- <div>
99
+ <div style={{ textAlign: "center" }}>
101
100
  <h3>余额卡片组件演示:</h3>
102
101
  <StatisticalBalance />
103
102
  </div>
@@ -4,17 +4,17 @@ export declare function printCurrentTime(): void;
4
4
 
5
5
  export declare function initFundUnit(params: {
6
6
  token: string;
7
- merchant_id: string;
8
- biz_type: string;
9
- user_id: string;
7
+ merchant_id?: string;
8
+ biz_type?: string;
9
+ fund_balance_id?: string;
10
10
  theme?: string;
11
11
  locale?: "zh" | "en";
12
12
  }): {
13
13
  token: string;
14
- merchantId: string;
15
- bizType: string;
14
+ merchantId?: string;
15
+ bizType?: string;
16
+ fundBalanceId?: string;
16
17
  theme?: string;
17
- userId: string;
18
18
  locale: "zh" | "en";
19
19
  };
20
20
 
@@ -1,19 +1,25 @@
1
1
  export function initFundUnit(params: {
2
2
  token: string;
3
- merchant_id: string;
4
- biz_type: string;
5
- user_id: string;
3
+ merchant_id?: string;
4
+ biz_type?: string;
5
+ fund_balance_id?: string;
6
6
  theme?: string;
7
7
  locale?: "zh" | "en";
8
8
  }) {
9
- const { merchant_id, biz_type, theme, user_id, locale = "zh" } = params;
9
+ const {
10
+ merchant_id,
11
+ biz_type,
12
+ fund_balance_id,
13
+ theme,
14
+ locale = "zh",
15
+ } = params;
10
16
  const token = "Bearer " + params.token;
11
17
  sessionStorage.setItem(
12
18
  "fund_unit_params",
13
19
  JSON.stringify({
14
20
  merchantId: merchant_id,
15
21
  bizType: biz_type,
16
- userId: user_id,
22
+ fundBalanceId: fund_balance_id,
17
23
  token,
18
24
  theme,
19
25
  locale,
@@ -23,8 +29,8 @@ export function initFundUnit(params: {
23
29
  token,
24
30
  merchantId: merchant_id,
25
31
  bizType: biz_type,
32
+ fundBalanceId: fund_balance_id,
26
33
  theme,
27
- userId: user_id,
28
34
  locale,
29
35
  };
30
36
  }