PurePanel.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { createVNode as _createVNode } from "vue";
  3. import Notice from '../vc-notification/Notice';
  4. import useStyle from './style';
  5. import LoadingOutlined from "@ant-design/icons-vue/es/icons/LoadingOutlined";
  6. import ExclamationCircleFilled from "@ant-design/icons-vue/es/icons/ExclamationCircleFilled";
  7. import CloseCircleFilled from "@ant-design/icons-vue/es/icons/CloseCircleFilled";
  8. import CheckCircleFilled from "@ant-design/icons-vue/es/icons/CheckCircleFilled";
  9. import InfoCircleFilled from "@ant-design/icons-vue/es/icons/InfoCircleFilled";
  10. import classNames from '../_util/classNames';
  11. import { useConfigContextInject } from '../config-provider/context';
  12. import { computed, defineComponent } from 'vue';
  13. export const TypeIcon = {
  14. info: _createVNode(InfoCircleFilled, null, null),
  15. success: _createVNode(CheckCircleFilled, null, null),
  16. error: _createVNode(CloseCircleFilled, null, null),
  17. warning: _createVNode(ExclamationCircleFilled, null, null),
  18. loading: _createVNode(LoadingOutlined, null, null)
  19. };
  20. export const PureContent = defineComponent({
  21. name: 'PureContent',
  22. inheritAttrs: false,
  23. props: ['prefixCls', 'type', 'icon'],
  24. setup(props, _ref) {
  25. let {
  26. slots
  27. } = _ref;
  28. return () => {
  29. var _a;
  30. return _createVNode("div", {
  31. "class": classNames(`${props.prefixCls}-custom-content`, `${props.prefixCls}-${props.type}`)
  32. }, [props.icon || TypeIcon[props.type], _createVNode("span", null, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)])]);
  33. };
  34. }
  35. });
  36. /** @private Internal Component. Do not use in your production. */
  37. export default defineComponent({
  38. name: 'PurePanel',
  39. inheritAttrs: false,
  40. props: ['prefixCls', 'class', 'type', 'icon', 'content'],
  41. setup(props, _ref2) {
  42. let {
  43. slots,
  44. attrs
  45. } = _ref2;
  46. var _a;
  47. const {
  48. getPrefixCls
  49. } = useConfigContextInject();
  50. const prefixCls = computed(() => props.prefixCls || getPrefixCls('message'));
  51. const [, hashId] = useStyle(prefixCls);
  52. return _createVNode(Notice, _objectSpread(_objectSpread({}, attrs), {}, {
  53. "prefixCls": prefixCls.value,
  54. "class": classNames(hashId.value, `${prefixCls.value}-notice-pure-panel`),
  55. "noticeKey": "pure",
  56. "duration": null
  57. }), {
  58. default: () => [_createVNode(PureContent, {
  59. "prefixCls": prefixCls.value,
  60. "type": props.type,
  61. "icon": props.icon
  62. }, {
  63. default: () => [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]
  64. })]
  65. });
  66. }
  67. });