@hi-ui/pop-confirm 4.1.0 → 4.2.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/CHANGELOG.md +6 -0
- package/lib/cjs/PopConfirm.js +27 -57
- package/lib/cjs/icons/index.js +1 -17
- package/lib/cjs/index.js +0 -3
- package/lib/cjs/styles/index.scss.js +1 -4
- package/lib/cjs/use-pop-confirm.js +24 -42
- package/lib/esm/PopConfirm.js +21 -23
- package/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/use-pop-confirm.js +24 -32
- package/lib/types/PopConfirm.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# @hi-ui/pop-confirm
|
2
2
|
|
3
|
+
## 4.2.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [#2667](https://github.com/XiaoMi/hiui/pull/2667) [`3e2e9c389`](https://github.com/XiaoMi/hiui/commit/3e2e9c389c15908b6dc70ad224253d8287273eea) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: add content api
|
8
|
+
|
3
9
|
## 4.1.0
|
4
10
|
|
5
11
|
### Minor Changes
|
package/lib/cjs/PopConfirm.js
CHANGED
@@ -9,96 +9,68 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
13
|
-
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
15
|
-
value: true
|
16
|
-
});
|
17
|
-
|
18
12
|
var tslib = require('tslib');
|
19
|
-
|
20
13
|
var React = require('react');
|
21
|
-
|
22
14
|
var classname = require('@hi-ui/classname');
|
23
|
-
|
24
15
|
var env = require('@hi-ui/env');
|
25
|
-
|
26
16
|
var core = require('@hi-ui/core');
|
27
|
-
|
28
17
|
var usePopConfirm = require('./use-pop-confirm.js');
|
29
|
-
|
30
18
|
var Button = require('@hi-ui/button');
|
31
|
-
|
32
19
|
var Popper = require('@hi-ui/popper');
|
33
|
-
|
34
20
|
var index = require('./icons/index.js');
|
35
|
-
|
36
21
|
var typeAssertion = require('@hi-ui/type-assertion');
|
37
|
-
|
38
|
-
function _interopDefaultLegacy(e) {
|
39
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
40
|
-
'default': e
|
41
|
-
};
|
42
|
-
}
|
43
|
-
|
44
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
45
|
-
|
46
|
-
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
47
|
-
|
48
|
-
var Popper__default = /*#__PURE__*/_interopDefaultLegacy(Popper);
|
49
|
-
|
50
22
|
var POP_CONFIRM_PREFIX = classname.getPrefixCls('pop-confirm');
|
51
23
|
/**
|
52
24
|
* 气泡确认框
|
53
25
|
*/
|
54
|
-
|
55
26
|
var PopConfirm = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
56
27
|
var _a$prefixCls = _a.prefixCls,
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
28
|
+
prefixCls = _a$prefixCls === void 0 ? POP_CONFIRM_PREFIX : _a$prefixCls,
|
29
|
+
className = _a.className,
|
30
|
+
children = _a.children,
|
31
|
+
title = _a.title,
|
32
|
+
content = _a.content,
|
33
|
+
_a$icon = _a.icon,
|
34
|
+
icon = _a$icon === void 0 ? index.defaultTipIcon : _a$icon,
|
35
|
+
cancelTextProp = _a.cancelText,
|
36
|
+
confirmTextProp = _a.confirmText,
|
37
|
+
footer = _a.footer,
|
38
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "title", "content", "icon", "cancelText", "confirmText", "footer"]);
|
68
39
|
var i18n = core.useLocaleContext();
|
69
40
|
var cancelText = typeAssertion.isUndef(cancelTextProp) ? i18n.get('popConfirm.cancelText') : cancelTextProp;
|
70
41
|
var confirmText = typeAssertion.isUndef(confirmTextProp) ? i18n.get('popConfirm.confirmText') : confirmTextProp;
|
71
|
-
|
72
42
|
var _usePopConfirm = usePopConfirm.usePopConfirm(rest),
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
43
|
+
rootProps = _usePopConfirm.rootProps,
|
44
|
+
getPopperProps = _usePopConfirm.getPopperProps,
|
45
|
+
getTriggerProps = _usePopConfirm.getTriggerProps,
|
46
|
+
onCancel = _usePopConfirm.onCancel,
|
47
|
+
onConfirm = _usePopConfirm.onConfirm;
|
79
48
|
var cls = classname.cx(prefixCls, className);
|
80
49
|
var hasConfirm = confirmText !== null;
|
81
50
|
var hasCancel = cancelText !== null;
|
82
51
|
var hasFooter = hasConfirm || hasCancel || footer !== null;
|
83
|
-
return /*#__PURE__*/
|
84
|
-
|
52
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children,
|
53
|
+
// @ts-ignore
|
54
|
+
getTriggerProps(children.props, children.ref)) : null, /*#__PURE__*/React.createElement(Popper, Object.assign({}, getPopperProps()), /*#__PURE__*/React.createElement("div", Object.assign({
|
85
55
|
ref: ref,
|
86
56
|
className: cls
|
87
|
-
}, rootProps), /*#__PURE__*/
|
57
|
+
}, rootProps), /*#__PURE__*/React.createElement("section", {
|
88
58
|
className: prefixCls + "__content"
|
89
|
-
}, icon ? /*#__PURE__*/
|
59
|
+
}, icon ? /*#__PURE__*/React.createElement("span", {
|
90
60
|
className: prefixCls + "__content-icon"
|
91
|
-
}, icon) : null, /*#__PURE__*/
|
61
|
+
}, icon) : null, /*#__PURE__*/React.createElement("div", {
|
92
62
|
className: prefixCls + "__content-title"
|
93
|
-
}, title)),
|
63
|
+
}, title)), content ? /*#__PURE__*/React.createElement("div", {
|
64
|
+
className: prefixCls + "__body"
|
65
|
+
}, content) : null, hasFooter ? /*#__PURE__*/React.createElement("footer", {
|
94
66
|
className: prefixCls + "__footer"
|
95
|
-
}, footer === undefined ? [hasCancel ? /*#__PURE__*/
|
67
|
+
}, footer === undefined ? [hasCancel ? /*#__PURE__*/React.createElement(Button, {
|
96
68
|
key: "1",
|
97
69
|
className: prefixCls + "__btn-cancel",
|
98
70
|
type: "default",
|
99
71
|
size: "md",
|
100
72
|
onClick: onCancel
|
101
|
-
}, cancelText) : null, hasConfirm ? /*#__PURE__*/
|
73
|
+
}, cancelText) : null, hasConfirm ? /*#__PURE__*/React.createElement(Button, {
|
102
74
|
key: "2",
|
103
75
|
className: prefixCls + "__btn-confirm",
|
104
76
|
type: "primary",
|
@@ -106,9 +78,7 @@ var PopConfirm = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
106
78
|
onClick: onConfirm
|
107
79
|
}, confirmText) : null] : footer) : null)));
|
108
80
|
});
|
109
|
-
|
110
81
|
if (env.__DEV__) {
|
111
82
|
PopConfirm.displayName = 'PopConfirm';
|
112
83
|
}
|
113
|
-
|
114
84
|
exports.PopConfirm = PopConfirm;
|
package/lib/cjs/icons/index.js
CHANGED
@@ -9,23 +9,7 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
13
|
-
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
15
|
-
value: true
|
16
|
-
});
|
17
|
-
|
18
12
|
var React = require('react');
|
19
|
-
|
20
13
|
var icons = require('@hi-ui/icons');
|
21
|
-
|
22
|
-
function _interopDefaultLegacy(e) {
|
23
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
24
|
-
'default': e
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
29
|
-
|
30
|
-
var defaultTipIcon = /*#__PURE__*/React__default["default"].createElement(icons.ExclamationCircleFilled, null);
|
14
|
+
var defaultTipIcon = /*#__PURE__*/React.createElement(icons.ExclamationCircleFilled, null);
|
31
15
|
exports.defaultTipIcon = defaultTipIcon;
|
package/lib/cjs/index.js
CHANGED
@@ -12,10 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
|
16
15
|
require('./styles/index.scss.js');
|
17
|
-
|
18
16
|
var PopConfirm = require('./PopConfirm.js');
|
19
|
-
|
20
17
|
exports.PopConfirm = PopConfirm.PopConfirm;
|
21
18
|
exports["default"] = PopConfirm.PopConfirm;
|
@@ -12,10 +12,7 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
var css_248z = ".hi-v4-pop-confirm {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;background: var(--hi-v4-color-static-white, #fff);white-space: nowrap;border-radius: var(--hi-v4-border-radius-lg, 6px);padding: var(--hi-v4-spacing-10, 20px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-pop-confirm__content {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-pop-confirm__content-icon {margin-right: var(--hi-v4-spacing-
|
16
|
-
|
15
|
+
var css_248z = ".hi-v4-pop-confirm {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;background: var(--hi-v4-color-static-white, #fff);white-space: nowrap;border-radius: var(--hi-v4-border-radius-lg, 6px);padding: var(--hi-v4-spacing-10, 20px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-pop-confirm__content {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-pop-confirm__content-icon {margin-right: var(--hi-v4-spacing-5, 10px);color: var(--hi-v4-color-warning-500, var(--hi-v4-color-yellow-500, #fab007));font-size: var(--hi-v4-text-size-xl, 1.125rem);}.hi-v4-pop-confirm__content-title {color: var(--hi-v4-color-gray-700, #1f2733);font-weight: var(--hi-v4-text-weight-semibold, 600);}.hi-v4-pop-confirm__body {margin: var(--hi-v4-spacing-5, 10px) 0 0 var(--hi-v4-spacing-14, 28px);white-space: normal;color: var(--hi-v4-color-gray-600, #5f6a7a);}.hi-v4-pop-confirm__footer {margin-top: var(--hi-v4-spacing-10, 20px);text-align: right;}";
|
17
16
|
var __styleInject__ = require('style-inject')["default"];
|
18
|
-
|
19
17
|
__styleInject__(css_248z);
|
20
|
-
|
21
18
|
exports["default"] = css_248z;
|
@@ -9,53 +9,39 @@
|
|
9
9
|
*/
|
10
10
|
'use strict';
|
11
11
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
12
|
var tslib = require('tslib');
|
17
|
-
|
18
13
|
var React = require('react');
|
19
|
-
|
20
14
|
var useLatest = require('@hi-ui/use-latest');
|
21
|
-
|
22
15
|
var domUtils = require('@hi-ui/dom-utils');
|
23
|
-
|
24
16
|
var reactUtils = require('@hi-ui/react-utils');
|
25
|
-
|
26
17
|
var Popper = require('@hi-ui/popper');
|
27
|
-
|
28
18
|
var useToggle = require('@hi-ui/use-toggle');
|
29
|
-
|
30
19
|
var usePopConfirm = function usePopConfirm(_a) {
|
31
20
|
var visibleProp = _a.visible,
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
_a$closeOnCancel = _a.closeOnCancel,
|
22
|
+
closeOnCancel = _a$closeOnCancel === void 0 ? true : _a$closeOnCancel,
|
23
|
+
_a$closeOnConfirm = _a.closeOnConfirm,
|
24
|
+
closeOnConfirm = _a$closeOnConfirm === void 0 ? true : _a$closeOnConfirm,
|
25
|
+
onCancelProp = _a.onCancel,
|
26
|
+
onConfirmProp = _a.onConfirm,
|
27
|
+
onOpen = _a.onOpen,
|
28
|
+
_onClose = _a.onClose,
|
29
|
+
restProps = tslib.__rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]);
|
30
|
+
// TODO: 移除 popper,使用 hook 重写
|
43
31
|
var _omitPopperOverlayPro = Popper.omitPopperOverlayProps(restProps),
|
44
|
-
|
45
|
-
|
46
|
-
|
32
|
+
popper = _omitPopperOverlayPro[0],
|
33
|
+
rest = _omitPopperOverlayPro[1];
|
47
34
|
var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
35
|
+
defaultVisible: false,
|
36
|
+
visible: visibleProp,
|
37
|
+
onOpen: onOpen,
|
38
|
+
onClose: function onClose() {
|
39
|
+
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
40
|
+
onCancelProp === null || onCancelProp === void 0 ? void 0 : onCancelProp();
|
41
|
+
}
|
42
|
+
}),
|
43
|
+
visible = _useUncontrolledToggl[0],
|
44
|
+
visibleAction = _useUncontrolledToggl[1];
|
59
45
|
var onCancel = React.useCallback(function () {
|
60
46
|
if (closeOnCancel) {
|
61
47
|
visibleAction.off();
|
@@ -64,16 +50,13 @@ var usePopConfirm = function usePopConfirm(_a) {
|
|
64
50
|
var onConfirmLatest = useLatest.useLatestCallback(onConfirmProp);
|
65
51
|
var onConfirm = React.useCallback(function () {
|
66
52
|
onConfirmLatest();
|
67
|
-
|
68
53
|
if (closeOnConfirm) {
|
69
54
|
visibleAction.off();
|
70
55
|
}
|
71
56
|
}, [closeOnConfirm, visibleAction, onConfirmLatest]);
|
72
|
-
|
73
57
|
var _useState = React.useState(null),
|
74
|
-
|
75
|
-
|
76
|
-
|
58
|
+
targetEl = _useState[0],
|
59
|
+
setTargetEl = _useState[1];
|
77
60
|
var getTriggerProps = React.useCallback(function (props, ref) {
|
78
61
|
return {
|
79
62
|
ref: reactUtils.mergeRefs(setTargetEl, ref),
|
@@ -104,5 +87,4 @@ var usePopConfirm = function usePopConfirm(_a) {
|
|
104
87
|
onConfirm: onConfirm
|
105
88
|
};
|
106
89
|
};
|
107
|
-
|
108
90
|
exports.usePopConfirm = usePopConfirm;
|
package/lib/esm/PopConfirm.js
CHANGED
@@ -21,36 +21,34 @@ var POP_CONFIRM_PREFIX = getPrefixCls('pop-confirm');
|
|
21
21
|
/**
|
22
22
|
* 气泡确认框
|
23
23
|
*/
|
24
|
-
|
25
24
|
var PopConfirm = /*#__PURE__*/forwardRef(function (_a, ref) {
|
26
25
|
var _a$prefixCls = _a.prefixCls,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
prefixCls = _a$prefixCls === void 0 ? POP_CONFIRM_PREFIX : _a$prefixCls,
|
27
|
+
className = _a.className,
|
28
|
+
children = _a.children,
|
29
|
+
title = _a.title,
|
30
|
+
content = _a.content,
|
31
|
+
_a$icon = _a.icon,
|
32
|
+
icon = _a$icon === void 0 ? defaultTipIcon : _a$icon,
|
33
|
+
cancelTextProp = _a.cancelText,
|
34
|
+
confirmTextProp = _a.confirmText,
|
35
|
+
footer = _a.footer,
|
36
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "children", "title", "content", "icon", "cancelText", "confirmText", "footer"]);
|
38
37
|
var i18n = useLocaleContext();
|
39
38
|
var cancelText = isUndef(cancelTextProp) ? i18n.get('popConfirm.cancelText') : cancelTextProp;
|
40
39
|
var confirmText = isUndef(confirmTextProp) ? i18n.get('popConfirm.confirmText') : confirmTextProp;
|
41
|
-
|
42
40
|
var _usePopConfirm = usePopConfirm(rest),
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
rootProps = _usePopConfirm.rootProps,
|
42
|
+
getPopperProps = _usePopConfirm.getPopperProps,
|
43
|
+
getTriggerProps = _usePopConfirm.getTriggerProps,
|
44
|
+
onCancel = _usePopConfirm.onCancel,
|
45
|
+
onConfirm = _usePopConfirm.onConfirm;
|
49
46
|
var cls = cx(prefixCls, className);
|
50
47
|
var hasConfirm = confirmText !== null;
|
51
48
|
var hasCancel = cancelText !== null;
|
52
49
|
var hasFooter = hasConfirm || hasCancel || footer !== null;
|
53
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children,
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children,
|
51
|
+
// @ts-ignore
|
54
52
|
getTriggerProps(children.props, children.ref)) : null, /*#__PURE__*/React.createElement(Popper, Object.assign({}, getPopperProps()), /*#__PURE__*/React.createElement("div", Object.assign({
|
55
53
|
ref: ref,
|
56
54
|
className: cls
|
@@ -60,7 +58,9 @@ var PopConfirm = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
60
58
|
className: prefixCls + "__content-icon"
|
61
59
|
}, icon) : null, /*#__PURE__*/React.createElement("div", {
|
62
60
|
className: prefixCls + "__content-title"
|
63
|
-
}, title)),
|
61
|
+
}, title)), content ? /*#__PURE__*/React.createElement("div", {
|
62
|
+
className: prefixCls + "__body"
|
63
|
+
}, content) : null, hasFooter ? /*#__PURE__*/React.createElement("footer", {
|
64
64
|
className: prefixCls + "__footer"
|
65
65
|
}, footer === undefined ? [hasCancel ? /*#__PURE__*/React.createElement(Button, {
|
66
66
|
key: "1",
|
@@ -76,9 +76,7 @@ var PopConfirm = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
76
76
|
onClick: onConfirm
|
77
77
|
}, confirmText) : null] : footer) : null)));
|
78
78
|
});
|
79
|
-
|
80
79
|
if (__DEV__) {
|
81
80
|
PopConfirm.displayName = 'PopConfirm';
|
82
81
|
}
|
83
|
-
|
84
82
|
export { PopConfirm };
|
@@ -8,8 +8,6 @@
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import __styleInject__ from 'style-inject';
|
11
|
-
var css_248z = ".hi-v4-pop-confirm {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;background: var(--hi-v4-color-static-white, #fff);white-space: nowrap;border-radius: var(--hi-v4-border-radius-lg, 6px);padding: var(--hi-v4-spacing-10, 20px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-pop-confirm__content {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-pop-confirm__content-icon {margin-right: var(--hi-v4-spacing-
|
12
|
-
|
11
|
+
var css_248z = ".hi-v4-pop-confirm {overflow-wrap: break-word;font-size: var(--hi-v4-text-size-md, 0.875rem);line-height: var(--hi-v4-text-lineheight-md, 1.375rem);position: relative;background: var(--hi-v4-color-static-white, #fff);white-space: nowrap;border-radius: var(--hi-v4-border-radius-lg, 6px);padding: var(--hi-v4-spacing-10, 20px);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;}.hi-v4-pop-confirm__content {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}.hi-v4-pop-confirm__content-icon {margin-right: var(--hi-v4-spacing-5, 10px);color: var(--hi-v4-color-warning-500, var(--hi-v4-color-yellow-500, #fab007));font-size: var(--hi-v4-text-size-xl, 1.125rem);}.hi-v4-pop-confirm__content-title {color: var(--hi-v4-color-gray-700, #1f2733);font-weight: var(--hi-v4-text-weight-semibold, 600);}.hi-v4-pop-confirm__body {margin: var(--hi-v4-spacing-5, 10px) 0 0 var(--hi-v4-spacing-14, 28px);white-space: normal;color: var(--hi-v4-color-gray-600, #5f6a7a);}.hi-v4-pop-confirm__footer {margin-top: var(--hi-v4-spacing-10, 20px);text-align: right;}";
|
13
12
|
__styleInject__(css_248z);
|
14
|
-
|
15
13
|
export { css_248z as default };
|
@@ -14,36 +14,32 @@ import { mockDefaultHandlers } from '@hi-ui/dom-utils';
|
|
14
14
|
import { mergeRefs, withDefaultProps } from '@hi-ui/react-utils';
|
15
15
|
import { omitPopperOverlayProps } from '@hi-ui/popper';
|
16
16
|
import { useUncontrolledToggle } from '@hi-ui/use-toggle';
|
17
|
-
|
18
17
|
var usePopConfirm = function usePopConfirm(_a) {
|
19
18
|
var visibleProp = _a.visible,
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
_a$closeOnCancel = _a.closeOnCancel,
|
20
|
+
closeOnCancel = _a$closeOnCancel === void 0 ? true : _a$closeOnCancel,
|
21
|
+
_a$closeOnConfirm = _a.closeOnConfirm,
|
22
|
+
closeOnConfirm = _a$closeOnConfirm === void 0 ? true : _a$closeOnConfirm,
|
23
|
+
onCancelProp = _a.onCancel,
|
24
|
+
onConfirmProp = _a.onConfirm,
|
25
|
+
onOpen = _a.onOpen,
|
26
|
+
_onClose = _a.onClose,
|
27
|
+
restProps = __rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]);
|
28
|
+
// TODO: 移除 popper,使用 hook 重写
|
31
29
|
var _omitPopperOverlayPro = omitPopperOverlayProps(restProps),
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
popper = _omitPopperOverlayPro[0],
|
31
|
+
rest = _omitPopperOverlayPro[1];
|
35
32
|
var _useUncontrolledToggl = useUncontrolledToggle({
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
defaultVisible: false,
|
34
|
+
visible: visibleProp,
|
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
|
+
}
|
40
|
+
}),
|
41
|
+
visible = _useUncontrolledToggl[0],
|
42
|
+
visibleAction = _useUncontrolledToggl[1];
|
47
43
|
var onCancel = useCallback(function () {
|
48
44
|
if (closeOnCancel) {
|
49
45
|
visibleAction.off();
|
@@ -52,16 +48,13 @@ var usePopConfirm = function usePopConfirm(_a) {
|
|
52
48
|
var onConfirmLatest = useLatestCallback(onConfirmProp);
|
53
49
|
var onConfirm = useCallback(function () {
|
54
50
|
onConfirmLatest();
|
55
|
-
|
56
51
|
if (closeOnConfirm) {
|
57
52
|
visibleAction.off();
|
58
53
|
}
|
59
54
|
}, [closeOnConfirm, visibleAction, onConfirmLatest]);
|
60
|
-
|
61
55
|
var _useState = useState(null),
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
targetEl = _useState[0],
|
57
|
+
setTargetEl = _useState[1];
|
65
58
|
var getTriggerProps = useCallback(function (props, ref) {
|
66
59
|
return {
|
67
60
|
ref: mergeRefs(setTargetEl, ref),
|
@@ -92,5 +85,4 @@ var usePopConfirm = function usePopConfirm(_a) {
|
|
92
85
|
onConfirm: onConfirm
|
93
86
|
};
|
94
87
|
};
|
95
|
-
|
96
88
|
export { usePopConfirm };
|