tdesign-react
Version:
TDesign Component for React
186 lines (182 loc) • 7.42 kB
JavaScript
/**
* tdesign v1.13.2
* (c) 2025 tdesign
* @license MIT
*/
import { _ as _typeof } from '../_chunks/dep-c37cc2fd.js';
import { _ as _defineProperty } from '../_chunks/dep-8618a2f1.js';
import React from 'react';
import { isString } from 'lodash-es';
import classNames from 'classnames';
import { InfoCircleFilledIcon } from 'tdesign-icons-react';
import { Button } from '../button/index.js';
import noop from '../_util/noop.js';
import useConfig from '../hooks/useConfig.js';
import useGlobalIcon from '../hooks/useGlobalIcon.js';
import '../button/Button.js';
import '../_chunks/dep-118954e6.js';
import '../_chunks/dep-61f5e3d1.js';
import '../_chunks/dep-30ed04a0.js';
import '../hooks/useDomRefCallback.js';
import '../hooks/useRipple.js';
import '../_chunks/dep-fab491d8.js';
import '../hooks/useAnimation.js';
import '../config-provider/ConfigContext.js';
import '../locale/zh_CN.js';
import '../_chunks/dep-ab140eb0.js';
import 'dayjs';
import '../_chunks/dep-95bd7102.js';
import '../_chunks/dep-82b8abc2.js';
import '../loading/index.js';
import '../loading/Loading.js';
import '../common/Portal.js';
import 'react-dom';
import '../hooks/useLayoutEffect.js';
import '../loading/gradient.js';
import '../_chunks/dep-f213e3a9.js';
import '../_chunks/dep-132961ab.js';
import '../loading/defaultProps.js';
import '../hooks/useDefaultProps.js';
import '../loading/plugin.js';
import '../_util/react-render.js';
import '../_chunks/dep-1aea5672.js';
import '../common/PluginContainer.js';
import '../config-provider/index.js';
import '../config-provider/ConfigProvider.js';
import '../config-provider/type.js';
import '../loading/style/index.js';
import '../loading/type.js';
import '../button/defaultProps.js';
import '../_util/parseTNode.js';
import '../_chunks/dep-4e5b1475.js';
import '../_chunks/dep-d104053f.js';
import '../button/style/index.js';
import '../button/type.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Popcontent = function Popcontent(props) {
var content = props.content,
cancelBtn = props.cancelBtn,
confirmBtn = props.confirmBtn,
icon = props.icon,
theme = props.theme,
_props$onCancel = props.onCancel,
onCancel = _props$onCancel === void 0 ? noop : _props$onCancel,
_props$onConfirm = props.onConfirm,
onConfirm = _props$onConfirm === void 0 ? noop : _props$onConfirm,
_props$onClose = props.onClose,
onClose = _props$onClose === void 0 ? noop : _props$onClose;
var _useConfig = useConfig(),
classPrefix = _useConfig.classPrefix;
var _useGlobalIcon = useGlobalIcon({
InfoCircleFilledIcon: InfoCircleFilledIcon
}),
InfoCircleFilledIcon$1 = _useGlobalIcon.InfoCircleFilledIcon;
var hideCancel = cancelBtn === null || cancelBtn === void 0;
var hideConfirm = confirmBtn === null || confirmBtn === void 0;
function renderIcon() {
var color = "#0052D9";
var defaultIcon = /* @__PURE__ */React.createElement(InfoCircleFilledIcon$1, null);
switch (theme) {
case "warning":
color = "#FFAA00";
break;
case "danger":
color = "#FF3E00";
break;
}
var iconComponent = null;
if (/*#__PURE__*/React.isValidElement(icon)) {
iconComponent = /*#__PURE__*/React.cloneElement(icon, _objectSpread({
style: {
color: color
}
}, icon.props));
} else if (defaultIcon) {
iconComponent = /*#__PURE__*/React.cloneElement(defaultIcon, {
style: {
color: color
}
});
}
return iconComponent;
}
function renderCancel() {
if (/*#__PURE__*/React.isValidElement(cancelBtn)) {
return /*#__PURE__*/React.cloneElement(cancelBtn, {
onClick: function onClick(e) {
var _cancelBtn$props, _cancelBtn$props$onCl;
onClose({
e: e,
trigger: "cancel"
});
(_cancelBtn$props = cancelBtn.props) === null || _cancelBtn$props === void 0 || (_cancelBtn$props$onCl = _cancelBtn$props.onClick) === null || _cancelBtn$props$onCl === void 0 || _cancelBtn$props$onCl.call(_cancelBtn$props, e);
}
});
}
if (hideCancel) {
return null;
}
return /* @__PURE__ */React.createElement(Button, _objectSpread({
size: "small",
theme: "default",
variant: "base",
onClick: function onClick(e) {
onClose({
e: e,
trigger: "cancel"
});
onCancel({
e: e
});
}
}, _typeof(cancelBtn) === "object" ? _objectSpread({}, cancelBtn) : {}), _typeof(cancelBtn) === "object" ? cancelBtn === null || cancelBtn === void 0 ? void 0 : cancelBtn.children : isString(cancelBtn) && cancelBtn);
}
function renderConfirm() {
if (/*#__PURE__*/React.isValidElement(confirmBtn)) {
return /*#__PURE__*/React.cloneElement(confirmBtn, {
onClick: function onClick(e) {
var _confirmBtn$props, _confirmBtn$props$onC;
onClose({
e: e,
trigger: "confirm"
});
(_confirmBtn$props = confirmBtn.props) === null || _confirmBtn$props === void 0 || (_confirmBtn$props$onC = _confirmBtn$props.onClick) === null || _confirmBtn$props$onC === void 0 || _confirmBtn$props$onC.call(_confirmBtn$props, e);
}
});
}
if (hideConfirm) {
return null;
}
return /* @__PURE__ */React.createElement(Button, _objectSpread({
size: "small",
theme: "primary",
onClick: function onClick(e) {
onClose({
e: e,
trigger: "confirm"
});
onConfirm({
e: e
});
}
}, _typeof(confirmBtn) === "object" ? _objectSpread({}, confirmBtn) : {}), _typeof(confirmBtn) === "object" ? confirmBtn === null || confirmBtn === void 0 ? void 0 : confirmBtn.children : isString(confirmBtn) && confirmBtn);
}
return /* @__PURE__ */React.createElement("div", {
className: "".concat(classPrefix, "-popconfirm__content ").concat(props.className),
style: props.style
}, /* @__PURE__ */React.createElement("div", {
className: "".concat(classPrefix, "-popconfirm__body")
}, renderIcon(), /* @__PURE__ */React.createElement("div", {
className: "".concat(classPrefix, "-popconfirm__inner")
}, content)), /* @__PURE__ */React.createElement("div", {
className: "".concat(classPrefix, "-popconfirm__buttons")
}, /* @__PURE__ */React.createElement("span", {
className: classNames("".concat(classPrefix, "-popconfirm__cancel"))
}, renderCancel()), /* @__PURE__ */React.createElement("span", {
className: classNames("".concat(classPrefix, "-popconfirm__confirm"))
}, renderConfirm())));
};
Popcontent.displayName = "Popcontent";
export { Popcontent as default };
//# sourceMappingURL=Popcontent.js.map