@hi-ui/pop-confirm 4.2.4 → 4.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @hi-ui/pop-confirm
2
2
 
3
+ ## 4.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2813](https://github.com/XiaoMi/hiui/pull/2813) [`084600ea6`](https://github.com/XiaoMi/hiui/commit/084600ea6e4fdec7efde79a3cc90d8ef45ca602f) Thanks [@xiamiao1121](https://github.com/xiamiao1121)! - fix: 修复点击按钮会触发 onCancel 问题
8
+
9
+ - Updated dependencies [[`3afbf239e`](https://github.com/XiaoMi/hiui/commit/3afbf239e816ede48d6a85cbd99b6b099b8c8eb3)]:
10
+ - @hi-ui/env@4.0.7
11
+
3
12
  ## 4.2.4
4
13
 
5
14
  ### Patch Changes
@@ -28,7 +28,7 @@ var usePopConfirm = function usePopConfirm(_a) {
28
28
  onCancelProp = _a.onCancel,
29
29
  onConfirmProp = _a.onConfirm,
30
30
  onOpen = _a.onOpen,
31
- _onClose = _a.onClose,
31
+ onClose = _a.onClose,
32
32
  restProps = tslib.__rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]);
33
33
  // TODO: 移除 popper,使用 hook 重写
34
34
  var _omitPopperOverlayPro = Popper.omitPopperOverlayProps(restProps),
@@ -38,18 +38,17 @@ var usePopConfirm = function usePopConfirm(_a) {
38
38
  defaultVisible: false,
39
39
  visible: visibleProp,
40
40
  onOpen: onOpen,
41
- onClose: function onClose() {
42
- _onClose === null || _onClose === void 0 ? void 0 : _onClose();
43
- onCancelProp === null || onCancelProp === void 0 ? void 0 : onCancelProp();
44
- }
41
+ onClose: onClose
45
42
  }),
46
43
  visible = _useUncontrolledToggl[0],
47
44
  visibleAction = _useUncontrolledToggl[1];
45
+ var onCancelLatest = useLatest.useLatestCallback(onCancelProp);
48
46
  var onCancel = React.useCallback(function () {
47
+ onCancelLatest();
49
48
  if (closeOnCancel) {
50
49
  visibleAction.off();
51
50
  }
52
- }, [closeOnCancel, visibleAction]);
51
+ }, [closeOnCancel, visibleAction, onCancelLatest]);
53
52
  var onConfirmLatest = useLatest.useLatestCallback(onConfirmProp);
54
53
  var onConfirm = React.useCallback(function () {
55
54
  onConfirmLatest();
@@ -23,7 +23,7 @@ var usePopConfirm = function usePopConfirm(_a) {
23
23
  onCancelProp = _a.onCancel,
24
24
  onConfirmProp = _a.onConfirm,
25
25
  onOpen = _a.onOpen,
26
- _onClose = _a.onClose,
26
+ onClose = _a.onClose,
27
27
  restProps = __rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]);
28
28
  // TODO: 移除 popper,使用 hook 重写
29
29
  var _omitPopperOverlayPro = omitPopperOverlayProps(restProps),
@@ -33,18 +33,17 @@ var usePopConfirm = function usePopConfirm(_a) {
33
33
  defaultVisible: false,
34
34
  visible: visibleProp,
35
35
  onOpen: onOpen,
36
- onClose: function onClose() {
37
- _onClose === null || _onClose === void 0 ? void 0 : _onClose();
38
- onCancelProp === null || onCancelProp === void 0 ? void 0 : onCancelProp();
39
- }
36
+ onClose: onClose
40
37
  }),
41
38
  visible = _useUncontrolledToggl[0],
42
39
  visibleAction = _useUncontrolledToggl[1];
40
+ var onCancelLatest = useLatestCallback(onCancelProp);
43
41
  var onCancel = useCallback(function () {
42
+ onCancelLatest();
44
43
  if (closeOnCancel) {
45
44
  visibleAction.off();
46
45
  }
47
- }, [closeOnCancel, visibleAction]);
46
+ }, [closeOnCancel, visibleAction, onCancelLatest]);
48
47
  var onConfirmLatest = useLatestCallback(onConfirmProp);
49
48
  var onConfirm = useCallback(function () {
50
49
  onConfirmLatest();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/pop-confirm",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -46,7 +46,7 @@
46
46
  "@hi-ui/button": "^4.0.10",
47
47
  "@hi-ui/classname": "^4.0.5",
48
48
  "@hi-ui/dom-utils": "^4.0.7",
49
- "@hi-ui/env": "^4.0.5",
49
+ "@hi-ui/env": "^4.0.7",
50
50
  "@hi-ui/icons": "^4.0.19",
51
51
  "@hi-ui/popper": "^4.1.5",
52
52
  "@hi-ui/react-utils": "^4.0.4",