@hi-ui/pop-confirm 4.1.0 → 4.2.1

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,33 @@
1
1
  # @hi-ui/pop-confirm
2
2
 
3
+ ## 4.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2672](https://github.com/XiaoMi/hiui/pull/2672) [`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e) Thanks [@zyprepare](https://github.com/zyprepare)! - build: 升级到 rollup3,重新构建发布组件
8
+
9
+ - [#2671](https://github.com/XiaoMi/hiui/pull/2671) [`6d7909444`](https://github.com/XiaoMi/hiui/commit/6d790944418f36689b34805f858a1268530864b9) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复组件参数类型错误
10
+
11
+ - Updated dependencies [[`1ebe27830`](https://github.com/XiaoMi/hiui/commit/1ebe2783098b3a8cd980bd10076d67635463800e)]:
12
+ - @hi-ui/core@4.0.6
13
+ - @hi-ui/use-latest@4.0.2
14
+ - @hi-ui/use-toggle@4.0.2
15
+ - @hi-ui/use-uncontrolled-state@4.0.2
16
+ - @hi-ui/icons@4.0.16
17
+ - @hi-ui/button@4.0.7
18
+ - @hi-ui/popper@4.1.1
19
+ - @hi-ui/classname@4.0.2
20
+ - @hi-ui/dom-utils@4.0.5
21
+ - @hi-ui/env@4.0.2
22
+ - @hi-ui/react-utils@4.0.2
23
+ - @hi-ui/type-assertion@4.0.2
24
+
25
+ ## 4.2.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [#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
30
+
3
31
  ## 4.1.0
4
32
 
5
33
  ### Minor Changes
@@ -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
- prefixCls = _a$prefixCls === void 0 ? POP_CONFIRM_PREFIX : _a$prefixCls,
58
- className = _a.className,
59
- children = _a.children,
60
- title = _a.title,
61
- _a$icon = _a.icon,
62
- icon = _a$icon === void 0 ? index.defaultTipIcon : _a$icon,
63
- cancelTextProp = _a.cancelText,
64
- confirmTextProp = _a.confirmText,
65
- footer = _a.footer,
66
- rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "title", "icon", "cancelText", "confirmText", "footer"]);
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
- rootProps = _usePopConfirm.rootProps,
74
- getPopperProps = _usePopConfirm.getPopperProps,
75
- getTriggerProps = _usePopConfirm.getTriggerProps,
76
- onCancel = _usePopConfirm.onCancel,
77
- onConfirm = _usePopConfirm.onConfirm;
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__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].isValidElement(children) ? /*#__PURE__*/React__default["default"].cloneElement(children, // @ts-ignore
84
- getTriggerProps(children.props, children.ref)) : null, /*#__PURE__*/React__default["default"].createElement(Popper__default["default"], Object.assign({}, getPopperProps()), /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
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__*/React__default["default"].createElement("section", {
57
+ }, rootProps), /*#__PURE__*/React.createElement("section", {
88
58
  className: prefixCls + "__content"
89
- }, icon ? /*#__PURE__*/React__default["default"].createElement("span", {
59
+ }, icon ? /*#__PURE__*/React.createElement("span", {
90
60
  className: prefixCls + "__content-icon"
91
- }, icon) : null, /*#__PURE__*/React__default["default"].createElement("div", {
61
+ }, icon) : null, /*#__PURE__*/React.createElement("div", {
92
62
  className: prefixCls + "__content-title"
93
- }, title)), hasFooter ? /*#__PURE__*/React__default["default"].createElement("footer", {
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__*/React__default["default"].createElement(Button__default["default"], {
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__*/React__default["default"].createElement(Button__default["default"], {
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;
@@ -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-4, 8px);color: var(--hi-v4-color-warning-500, var(--hi-v4-color-yellow-500, #fab007));font-size: var(--hi-v4-text-size-xxl, 1.5rem);}.hi-v4-pop-confirm__content-title {color: var(--hi-v4-color-gray-700, #1f2733);}.hi-v4-pop-confirm__footer {margin-top: var(--hi-v4-spacing-10, 20px);text-align: right;}";
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
- _a$closeOnCancel = _a.closeOnCancel,
33
- closeOnCancel = _a$closeOnCancel === void 0 ? true : _a$closeOnCancel,
34
- _a$closeOnConfirm = _a.closeOnConfirm,
35
- closeOnConfirm = _a$closeOnConfirm === void 0 ? true : _a$closeOnConfirm,
36
- onCancelProp = _a.onCancel,
37
- onConfirmProp = _a.onConfirm,
38
- onOpen = _a.onOpen,
39
- _onClose = _a.onClose,
40
- restProps = tslib.__rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]); // TODO: 移除 popper,使用 hook 重写
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
- popper = _omitPopperOverlayPro[0],
45
- rest = _omitPopperOverlayPro[1];
46
-
32
+ popper = _omitPopperOverlayPro[0],
33
+ rest = _omitPopperOverlayPro[1];
47
34
  var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
48
- defaultVisible: false,
49
- visible: visibleProp,
50
- onOpen: onOpen,
51
- onClose: function onClose() {
52
- _onClose === null || _onClose === void 0 ? void 0 : _onClose();
53
- onCancelProp === null || onCancelProp === void 0 ? void 0 : onCancelProp();
54
- }
55
- }),
56
- visible = _useUncontrolledToggl[0],
57
- visibleAction = _useUncontrolledToggl[1];
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
- targetEl = _useState[0],
75
- setTargetEl = _useState[1];
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;
@@ -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
- prefixCls = _a$prefixCls === void 0 ? POP_CONFIRM_PREFIX : _a$prefixCls,
28
- className = _a.className,
29
- children = _a.children,
30
- title = _a.title,
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", "icon", "cancelText", "confirmText", "footer"]);
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
- rootProps = _usePopConfirm.rootProps,
44
- getPopperProps = _usePopConfirm.getPopperProps,
45
- getTriggerProps = _usePopConfirm.getTriggerProps,
46
- onCancel = _usePopConfirm.onCancel,
47
- onConfirm = _usePopConfirm.onConfirm;
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, // @ts-ignore
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)), hasFooter ? /*#__PURE__*/React.createElement("footer", {
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-4, 8px);color: var(--hi-v4-color-warning-500, var(--hi-v4-color-yellow-500, #fab007));font-size: var(--hi-v4-text-size-xxl, 1.5rem);}.hi-v4-pop-confirm__content-title {color: var(--hi-v4-color-gray-700, #1f2733);}.hi-v4-pop-confirm__footer {margin-top: var(--hi-v4-spacing-10, 20px);text-align: right;}";
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
- _a$closeOnCancel = _a.closeOnCancel,
21
- closeOnCancel = _a$closeOnCancel === void 0 ? true : _a$closeOnCancel,
22
- _a$closeOnConfirm = _a.closeOnConfirm,
23
- closeOnConfirm = _a$closeOnConfirm === void 0 ? true : _a$closeOnConfirm,
24
- onCancelProp = _a.onCancel,
25
- onConfirmProp = _a.onConfirm,
26
- onOpen = _a.onOpen,
27
- _onClose = _a.onClose,
28
- restProps = __rest(_a, ["visible", "disabled", "closeOnCancel", "closeOnConfirm", "onCancel", "onConfirm", "onOpen", "onClose"]); // TODO: 移除 popper,使用 hook 重写
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
- popper = _omitPopperOverlayPro[0],
33
- rest = _omitPopperOverlayPro[1];
34
-
30
+ popper = _omitPopperOverlayPro[0],
31
+ rest = _omitPopperOverlayPro[1];
35
32
  var _useUncontrolledToggl = useUncontrolledToggle({
36
- defaultVisible: false,
37
- visible: visibleProp,
38
- onOpen: onOpen,
39
- onClose: function onClose() {
40
- _onClose === null || _onClose === void 0 ? void 0 : _onClose();
41
- onCancelProp === null || onCancelProp === void 0 ? void 0 : onCancelProp();
42
- }
43
- }),
44
- visible = _useUncontrolledToggl[0],
45
- visibleAction = _useUncontrolledToggl[1];
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
- targetEl = _useState[0],
63
- setTargetEl = _useState[1];
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 };
@@ -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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/pop-confirm",
3
- "version": "4.1.0",
3
+ "version": "4.2.1",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -43,26 +43,26 @@
43
43
  "url": "https://github.com/XiaoMi/hiui/issues"
44
44
  },
45
45
  "dependencies": {
46
- "@hi-ui/button": "^4.0.6",
47
- "@hi-ui/classname": "^4.0.1",
48
- "@hi-ui/dom-utils": "^4.0.4",
49
- "@hi-ui/env": "^4.0.1",
50
- "@hi-ui/icons": "^4.0.4",
51
- "@hi-ui/popper": "^4.0.4",
52
- "@hi-ui/react-utils": "^4.0.1",
53
- "@hi-ui/type-assertion": "^4.0.1",
54
- "@hi-ui/use-latest": "^4.0.1",
55
- "@hi-ui/use-toggle": "^4.0.1",
56
- "@hi-ui/use-uncontrolled-state": "^4.0.1"
46
+ "@hi-ui/button": "^4.0.7",
47
+ "@hi-ui/classname": "^4.0.2",
48
+ "@hi-ui/dom-utils": "^4.0.5",
49
+ "@hi-ui/env": "^4.0.2",
50
+ "@hi-ui/icons": "^4.0.16",
51
+ "@hi-ui/popper": "^4.1.1",
52
+ "@hi-ui/react-utils": "^4.0.2",
53
+ "@hi-ui/type-assertion": "^4.0.2",
54
+ "@hi-ui/use-latest": "^4.0.2",
55
+ "@hi-ui/use-toggle": "^4.0.2",
56
+ "@hi-ui/use-uncontrolled-state": "^4.0.2"
57
57
  },
58
58
  "peerDependencies": {
59
- "@hi-ui/core": ">=4.0.0",
59
+ "@hi-ui/core": ">=4.0.6",
60
60
  "react": ">=16.8.6",
61
61
  "react-dom": ">=16.8.6"
62
62
  },
63
63
  "devDependencies": {
64
- "@hi-ui/core": "^4.0.4",
65
- "@hi-ui/core-css": "^4.1.2",
64
+ "@hi-ui/core": "^4.0.6",
65
+ "@hi-ui/core-css": "^4.1.3",
66
66
  "react": "^17.0.1",
67
67
  "react-dom": "^17.0.1"
68
68
  }