UNPKG

6.22 kBJavaScriptView Raw
1import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3import { createVNode as _createVNode } from "vue";
4import classNames from '../_util/classNames';
5import Dialog from './Modal';
6import ActionButton from '../_util/ActionButton';
7import { defineComponent } from 'vue';
8import { useLocaleReceiver } from '../locale-provider/LocaleReceiver';
9import { getTransitionName } from '../_util/transition';
10
11function renderSomeContent(someContent) {
12 if (typeof someContent === 'function') {
13 return someContent();
14 }
15
16 return someContent;
17}
18
19export default defineComponent({
20 name: 'ConfirmDialog',
21 inheritAttrs: false,
22 props: ['icon', 'onCancel', 'onOk', 'close', 'closable', 'zIndex', 'afterClose', 'visible', 'keyboard', 'centered', 'getContainer', 'maskStyle', 'okButtonProps', 'cancelButtonProps', 'okType', 'prefixCls', 'okCancel', 'width', 'mask', 'maskClosable', 'okText', 'cancelText', 'autoFocusButton', 'transitionName', 'maskTransitionName', 'type', 'title', 'content', 'direction', 'rootPrefixCls', 'bodyStyle', 'closeIcon', 'modalRender', 'focusTriggerAfterClose'],
23 setup: function setup(props, _ref) {
24 var attrs = _ref.attrs;
25
26 var _useLocaleReceiver = useLocaleReceiver('Modal'),
27 _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
28 locale = _useLocaleReceiver2[0];
29
30 return function () {
31 var icon = props.icon,
32 onCancel = props.onCancel,
33 onOk = props.onOk,
34 close = props.close,
35 _props$closable = props.closable,
36 closable = _props$closable === void 0 ? false : _props$closable,
37 zIndex = props.zIndex,
38 afterClose = props.afterClose,
39 visible = props.visible,
40 keyboard = props.keyboard,
41 centered = props.centered,
42 getContainer = props.getContainer,
43 maskStyle = props.maskStyle,
44 okButtonProps = props.okButtonProps,
45 cancelButtonProps = props.cancelButtonProps,
46 _props$okCancel = props.okCancel,
47 okCancel = _props$okCancel === void 0 ? true : _props$okCancel,
48 _props$width = props.width,
49 width = _props$width === void 0 ? 416 : _props$width,
50 _props$mask = props.mask,
51 mask = _props$mask === void 0 ? true : _props$mask,
52 _props$maskClosable = props.maskClosable,
53 maskClosable = _props$maskClosable === void 0 ? false : _props$maskClosable,
54 type = props.type,
55 title = props.title,
56 content = props.content,
57 direction = props.direction,
58 closeIcon = props.closeIcon,
59 modalRender = props.modalRender,
60 focusTriggerAfterClose = props.focusTriggerAfterClose,
61 rootPrefixCls = props.rootPrefixCls,
62 bodyStyle = props.bodyStyle,
63 wrapClassName = props.wrapClassName;
64 var okType = props.okType || 'primary';
65 var prefixCls = props.prefixCls || 'ant-modal';
66 var contentPrefixCls = "".concat(prefixCls, "-confirm");
67 var style = attrs.style || {};
68 var okText = renderSomeContent(props.okText) || (okCancel ? locale.value.okText : locale.value.justOkText);
69 var cancelText = renderSomeContent(props.cancelText) || locale.value.cancelText;
70 var autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || 'ok';
71 var classString = classNames(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(type), "".concat(prefixCls, "-").concat(type), _defineProperty({}, "".concat(contentPrefixCls, "-rtl"), direction === 'rtl'), attrs.class);
72
73 var cancelButton = okCancel && _createVNode(ActionButton, {
74 "actionFn": onCancel,
75 "close": close,
76 "autofocus": autoFocusButton === 'cancel',
77 "buttonProps": cancelButtonProps,
78 "prefixCls": "".concat(rootPrefixCls, "-btn")
79 }, {
80 default: function _default() {
81 return [cancelText];
82 }
83 });
84
85 return _createVNode(Dialog, {
86 "prefixCls": prefixCls,
87 "class": classString,
88 "wrapClassName": classNames(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!centered), wrapClassName),
89 "onCancel": function onCancel(e) {
90 return close({
91 triggerCancel: true
92 }, e);
93 },
94 "visible": visible,
95 "title": "",
96 "footer": "",
97 "transitionName": getTransitionName(rootPrefixCls, 'zoom', props.transitionName),
98 "maskTransitionName": getTransitionName(rootPrefixCls, 'fade', props.maskTransitionName),
99 "mask": mask,
100 "maskClosable": maskClosable,
101 "maskStyle": maskStyle,
102 "style": style,
103 "bodyStyle": bodyStyle,
104 "width": width,
105 "zIndex": zIndex,
106 "afterClose": afterClose,
107 "keyboard": keyboard,
108 "centered": centered,
109 "getContainer": getContainer,
110 "closable": closable,
111 "closeIcon": closeIcon,
112 "modalRender": modalRender,
113 "focusTriggerAfterClose": focusTriggerAfterClose
114 }, {
115 default: function _default() {
116 return [_createVNode("div", {
117 "class": "".concat(contentPrefixCls, "-body-wrapper")
118 }, [_createVNode("div", {
119 "class": "".concat(contentPrefixCls, "-body")
120 }, [renderSomeContent(icon), title === undefined ? null : _createVNode("span", {
121 "class": "".concat(contentPrefixCls, "-title")
122 }, [renderSomeContent(title)]), _createVNode("div", {
123 "class": "".concat(contentPrefixCls, "-content")
124 }, [renderSomeContent(content)])]), _createVNode("div", {
125 "class": "".concat(contentPrefixCls, "-btns")
126 }, [cancelButton, _createVNode(ActionButton, {
127 "type": okType,
128 "actionFn": onOk,
129 "close": close,
130 "autofocus": autoFocusButton === 'ok',
131 "buttonProps": okButtonProps,
132 "prefixCls": "".concat(rootPrefixCls, "-btn")
133 }, {
134 default: function _default() {
135 return [okText];
136 }
137 })])])];
138 }
139 });
140 };
141 }
142});
\No newline at end of file