Cell.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { createVNode as _createVNode } from "vue";
  2. function notEmpty(val) {
  3. return val !== undefined && val !== null;
  4. }
  5. const Cell = props => {
  6. const {
  7. itemPrefixCls,
  8. component,
  9. span,
  10. labelStyle,
  11. contentStyle,
  12. bordered,
  13. label,
  14. content,
  15. colon
  16. } = props;
  17. const Component = component;
  18. if (bordered) {
  19. return _createVNode(Component, {
  20. "class": [{
  21. [`${itemPrefixCls}-item-label`]: notEmpty(label),
  22. [`${itemPrefixCls}-item-content`]: notEmpty(content)
  23. }],
  24. "colSpan": span
  25. }, {
  26. default: () => [notEmpty(label) && _createVNode("span", {
  27. "style": labelStyle
  28. }, [label]), notEmpty(content) && _createVNode("span", {
  29. "style": contentStyle
  30. }, [content])]
  31. });
  32. }
  33. return _createVNode(Component, {
  34. "class": [`${itemPrefixCls}-item`],
  35. "colSpan": span
  36. }, {
  37. default: () => [_createVNode("div", {
  38. "class": `${itemPrefixCls}-item-container`
  39. }, [(label || label === 0) && _createVNode("span", {
  40. "class": [`${itemPrefixCls}-item-label`, {
  41. [`${itemPrefixCls}-item-no-colon`]: !colon
  42. }],
  43. "style": labelStyle
  44. }, [label]), (content || content === 0) && _createVNode("span", {
  45. "class": `${itemPrefixCls}-item-content`,
  46. "style": contentStyle
  47. }, [content])])]
  48. });
  49. };
  50. export default Cell;