ExpandedRow.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { resolveDirective as _resolveDirective, createVNode as _createVNode } from "vue";
  2. import Cell from '../Cell';
  3. import { defineComponent } from 'vue';
  4. import { useInjectTable } from '../context/TableContext';
  5. import { useInjectExpandedRow } from '../context/ExpandedRowContext';
  6. export default defineComponent({
  7. name: 'ExpandedRow',
  8. inheritAttrs: false,
  9. props: ['prefixCls', 'component', 'cellComponent', 'expanded', 'colSpan', 'isEmpty'],
  10. setup(props, _ref) {
  11. let {
  12. slots,
  13. attrs
  14. } = _ref;
  15. const tableContext = useInjectTable();
  16. const expandedRowContext = useInjectExpandedRow();
  17. const {
  18. fixHeader,
  19. fixColumn,
  20. componentWidth,
  21. horizonScroll
  22. } = expandedRowContext;
  23. return () => {
  24. const {
  25. prefixCls,
  26. component: Component,
  27. cellComponent,
  28. expanded,
  29. colSpan,
  30. isEmpty
  31. } = props;
  32. return _createVNode(Component, {
  33. "class": attrs.class,
  34. "style": {
  35. display: expanded ? null : 'none'
  36. }
  37. }, {
  38. default: () => [_createVNode(Cell, {
  39. "component": cellComponent,
  40. "prefixCls": prefixCls,
  41. "colSpan": colSpan
  42. }, {
  43. default: () => {
  44. var _a;
  45. let contentNode = (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots);
  46. if (isEmpty ? horizonScroll.value : fixColumn.value) {
  47. const _contentNode = function () {
  48. return contentNode;
  49. }();
  50. contentNode = _createVNode("div", {
  51. "style": {
  52. width: `${componentWidth.value - (fixHeader.value ? tableContext.scrollbarSize : 0)}px`,
  53. position: 'sticky',
  54. left: 0,
  55. overflow: 'hidden'
  56. },
  57. "class": `${prefixCls}-expanded-row-fixed`
  58. }, [contentNode]);
  59. }
  60. return contentNode;
  61. }
  62. })]
  63. });
  64. };
  65. }
  66. });