ItemMeta.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { createVNode as _createVNode } from "vue";
  2. import { defineComponent } from 'vue';
  3. import useConfigInject from '../config-provider/hooks/useConfigInject';
  4. import PropTypes from '../_util/vue-types';
  5. export const listItemMetaProps = () => ({
  6. avatar: PropTypes.any,
  7. description: PropTypes.any,
  8. prefixCls: String,
  9. title: PropTypes.any
  10. });
  11. export default defineComponent({
  12. compatConfig: {
  13. MODE: 3
  14. },
  15. name: 'AListItemMeta',
  16. props: listItemMetaProps(),
  17. displayName: 'AListItemMeta',
  18. __ANT_LIST_ITEM_META: true,
  19. slots: Object,
  20. setup(props, _ref) {
  21. let {
  22. slots
  23. } = _ref;
  24. const {
  25. prefixCls
  26. } = useConfigInject('list', props);
  27. return () => {
  28. var _a, _b, _c, _d, _e, _f;
  29. const classString = `${prefixCls.value}-item-meta`;
  30. const title = (_a = props.title) !== null && _a !== void 0 ? _a : (_b = slots.title) === null || _b === void 0 ? void 0 : _b.call(slots);
  31. const description = (_c = props.description) !== null && _c !== void 0 ? _c : (_d = slots.description) === null || _d === void 0 ? void 0 : _d.call(slots);
  32. const avatar = (_e = props.avatar) !== null && _e !== void 0 ? _e : (_f = slots.avatar) === null || _f === void 0 ? void 0 : _f.call(slots);
  33. const content = _createVNode("div", {
  34. "class": `${prefixCls.value}-item-meta-content`
  35. }, [title && _createVNode("h4", {
  36. "class": `${prefixCls.value}-item-meta-title`
  37. }, [title]), description && _createVNode("div", {
  38. "class": `${prefixCls.value}-item-meta-description`
  39. }, [description])]);
  40. return _createVNode("div", {
  41. "class": classString
  42. }, [avatar && _createVNode("div", {
  43. "class": `${prefixCls.value}-item-meta-avatar`
  44. }, [avatar]), (title || description) && content]);
  45. };
  46. }
  47. });