UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

171 lines (148 loc) 7.72 kB
import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; var _excluded = ["children", "type", "onOk", "onCancel", "onClose", "iconType", "border", "okCancel", "title"]; import _regeneratorRuntime from "@babel/runtime/regenerator"; import React from 'react'; import noop from 'lodash/noop'; import ModalManager from '../modal-manager'; import { getContainer, open } from '../modal-container/ModalContainer'; import Icon from '../icon'; import { normalizeProps } from './utils'; export default function confirm(_x) { return _confirm.apply(this, arguments); } function _confirm() { _confirm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(props) { var container, _normalizeProps, children, _normalizeProps$type, type, _normalizeProps$onOk, _onOk, _normalizeProps$onCan, _onCancel, _normalizeProps$onClo, _onClose, iconType, _normalizeProps$borde, border, _normalizeProps$okCan, okCancel, title, otherProps, prefixCls, titleNode, contentNode, iconNode; return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return getContainer(); case 2: container = _context4.sent; _normalizeProps = normalizeProps(props), children = _normalizeProps.children, _normalizeProps$type = _normalizeProps.type, type = _normalizeProps$type === void 0 ? 'confirm' : _normalizeProps$type, _normalizeProps$onOk = _normalizeProps.onOk, _onOk = _normalizeProps$onOk === void 0 ? noop : _normalizeProps$onOk, _normalizeProps$onCan = _normalizeProps.onCancel, _onCancel = _normalizeProps$onCan === void 0 ? noop : _normalizeProps$onCan, _normalizeProps$onClo = _normalizeProps.onClose, _onClose = _normalizeProps$onClo === void 0 ? noop : _normalizeProps$onClo, iconType = _normalizeProps.iconType, _normalizeProps$borde = _normalizeProps.border, border = _normalizeProps$borde === void 0 ? false : _normalizeProps$borde, _normalizeProps$okCan = _normalizeProps.okCancel, okCancel = _normalizeProps$okCan === void 0 ? true : _normalizeProps$okCan, title = _normalizeProps.title, otherProps = _objectWithoutProperties(_normalizeProps, _excluded); prefixCls = container.context.getProPrefixCls('confirm'); titleNode = title && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-title") }, title); contentNode = children && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-content") }, children); iconNode = iconType && /*#__PURE__*/React.createElement("td", { className: "".concat(prefixCls, "-icon ").concat(prefixCls, "-").concat(type) }, /*#__PURE__*/React.createElement(Icon, { type: iconType })); return _context4.abrupt("return", new Promise(function (resolve) { open(_objectSpread(_objectSpread({ key: ModalManager.getKey(), className: "".concat(prefixCls, "-wrapper"), border: border, destroyOnClose: true, okCancel: okCancel, closable: false, movable: false, style: { width: '4.16rem' }, children: /*#__PURE__*/React.createElement("table", { className: prefixCls }, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, iconNode, /*#__PURE__*/React.createElement("td", null, titleNode, contentNode)))), onOk: function () { var _onOk2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var result; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return _onOk(); case 2: result = _context.sent; if (result !== false) { resolve('ok'); } return _context.abrupt("return", result); case 5: case "end": return _context.stop(); } } }, _callee); })); function onOk() { return _onOk2.apply(this, arguments); } return onOk; }(), onCancel: function () { var _onCancel2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { var result; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return _onCancel(); case 2: result = _context2.sent; if (result !== false) { resolve('cancel'); } return _context2.abrupt("return", result); case 5: case "end": return _context2.stop(); } } }, _callee2); })); function onCancel() { return _onCancel2.apply(this, arguments); } return onCancel; }(), onClose: function () { var _onClose2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { var result; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return _onClose(); case 2: result = _context3.sent; if (result !== false) { resolve('cancel'); } return _context3.abrupt("return", result); case 5: case "end": return _context3.stop(); } } }, _callee3); })); function onClose() { return _onClose2.apply(this, arguments); } return onClose; }() }, otherProps), {}, { resizable: false })); })); case 9: case "end": return _context4.stop(); } } }, _callee4); })); return _confirm.apply(this, arguments); } //# sourceMappingURL=confirm.js.map