@hi-ui/pop-confirm 4.0.6 → 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 +18 -0
- package/lib/cjs/PopConfirm.js +28 -58
- package/lib/cjs/icons/index.js +1 -17
- package/lib/cjs/index.js +0 -3
- package/lib/cjs/styles/index.scss.js +2 -5
- package/lib/cjs/use-pop-confirm.js +24 -42
- package/lib/esm/PopConfirm.js +22 -24
- package/lib/esm/styles/index.scss.js +2 -4
- package/lib/esm/use-pop-confirm.js +24 -32
- package/lib/types/PopConfirm.d.ts +5 -1
- package/lib/types/use-pop-confirm.d.ts +4 -3
- package/package.json +4 -6
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# @hi-ui/pop-confirm
|
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
|
+
|
9
|
+
## 4.1.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- [#2643](https://github.com/XiaoMi/hiui/pull/2643) [`7742c022a`](https://github.com/XiaoMi/hiui/commit/7742c022a55f3908684d21e6e7d7bf07e3de1f5e) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: add placement api (透传 Popper 参数)
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- Updated dependencies [[`b477d91db`](https://github.com/XiaoMi/hiui/commit/b477d91db15bbc92c8712a9a771af5b332779315)]:
|
18
|
+
- @hi-ui/button@4.0.6
|
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;
|
16
|
-
|
17
|
-
var __styleInject__ = require('inject-head-style')["default"];
|
18
|
-
|
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;}";
|
16
|
+
var __styleInject__ = require('style-inject')["default"];
|
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
@@ -19,38 +19,36 @@ import { defaultTipIcon } from './icons/index.js';
|
|
19
19
|
import { isUndef } from '@hi-ui/type-assertion';
|
20
20
|
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 };
|
@@ -7,9 +7,7 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
import __styleInject__ from '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;
|
12
|
-
|
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-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 };
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import { HiBaseHTMLProps } from '@hi-ui/core';
|
3
3
|
import { UsePopConfirmProps } from './use-pop-confirm';
|
4
4
|
/**
|
5
|
-
*
|
5
|
+
* 气泡确认框
|
6
6
|
*/
|
7
7
|
export declare const PopConfirm: React.ForwardRefExoticComponent<PopConfirmProps & React.RefAttributes<HTMLDivElement | null>>;
|
8
8
|
export interface PopConfirmProps extends Omit<HiBaseHTMLProps<'div'>, 'title'>, UsePopConfirmProps {
|
@@ -10,6 +10,10 @@ export interface PopConfirmProps extends Omit<HiBaseHTMLProps<'div'>, 'title'>,
|
|
10
10
|
* 确认框标题
|
11
11
|
*/
|
12
12
|
title: React.ReactNode;
|
13
|
+
/**
|
14
|
+
* 确认框内容
|
15
|
+
*/
|
16
|
+
content: React.ReactNode;
|
13
17
|
/**
|
14
18
|
* 取消按钮文案
|
15
19
|
*/
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { PopperOverlayProps } from '@hi-ui/popper';
|
2
3
|
export declare const usePopConfirm: ({ visible: visibleProp, disabled, closeOnCancel, closeOnConfirm, onCancel: onCancelProp, onConfirm: onConfirmProp, onOpen, onClose, ...restProps }: UsePopConfirmProps) => {
|
3
4
|
rootProps: any;
|
4
5
|
getTriggerProps: (props: any, ref: any) => {
|
@@ -9,14 +10,14 @@ export declare const usePopConfirm: ({ visible: visibleProp, disabled, closeOnCa
|
|
9
10
|
visible: boolean;
|
10
11
|
attachEl: HTMLElement | null;
|
11
12
|
onClose: () => void;
|
12
|
-
gutterGap: any;
|
13
|
-
arrow: any;
|
14
13
|
placement: any;
|
14
|
+
arrow: any;
|
15
|
+
gutterGap: any;
|
15
16
|
};
|
16
17
|
onCancel: () => void;
|
17
18
|
onConfirm: () => void;
|
18
19
|
};
|
19
|
-
export interface UsePopConfirmProps {
|
20
|
+
export interface UsePopConfirmProps extends PopperOverlayProps {
|
20
21
|
/**
|
21
22
|
* 是否显示确认框
|
22
23
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/pop-confirm",
|
3
|
-
"version": "4.0
|
3
|
+
"version": "4.2.0",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@hi-ui/button": "^4.0.
|
46
|
+
"@hi-ui/button": "^4.0.6",
|
47
47
|
"@hi-ui/classname": "^4.0.1",
|
48
48
|
"@hi-ui/dom-utils": "^4.0.4",
|
49
49
|
"@hi-ui/env": "^4.0.1",
|
@@ -62,10 +62,8 @@
|
|
62
62
|
},
|
63
63
|
"devDependencies": {
|
64
64
|
"@hi-ui/core": "^4.0.4",
|
65
|
-
"@hi-ui/core-css": "^4.
|
66
|
-
"@hi-ui/hi-build": "^4.0.1",
|
65
|
+
"@hi-ui/core-css": "^4.1.2",
|
67
66
|
"react": "^17.0.1",
|
68
67
|
"react-dom": "^17.0.1"
|
69
|
-
}
|
70
|
-
"gitHead": "785078746d82c4082b1cf884f8e235166648ef98"
|
68
|
+
}
|
71
69
|
}
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018 Xiaomi
|
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.
|