ExpandedRow.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: function setup(props, _ref) {
  11. var slots = _ref.slots,
  12. attrs = _ref.attrs;
  13. var tableContext = useInjectTable();
  14. var expandedRowContext = useInjectExpandedRow();
  15. var fixHeader = expandedRowContext.fixHeader,
  16. fixColumn = expandedRowContext.fixColumn,
  17. componentWidth = expandedRowContext.componentWidth,
  18. horizonScroll = expandedRowContext.horizonScroll;
  19. return function () {
  20. var prefixCls = props.prefixCls,
  21. Component = props.component,
  22. cellComponent = props.cellComponent,
  23. expanded = props.expanded,
  24. colSpan = props.colSpan,
  25. isEmpty = props.isEmpty;
  26. return _createVNode(Component, {
  27. "class": attrs.class,
  28. "style": {
  29. display: expanded ? null : 'none'
  30. }
  31. }, {
  32. default: function _default() {
  33. return [_createVNode(Cell, {
  34. "component": cellComponent,
  35. "prefixCls": prefixCls,
  36. "colSpan": colSpan
  37. }, {
  38. default: function _default() {
  39. var _slots$default;
  40. var contentNode = (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
  41. if (isEmpty ? horizonScroll.value : fixColumn.value) {
  42. var _contentNode = function () {
  43. return contentNode;
  44. }();
  45. contentNode = _createVNode("div", {
  46. "style": {
  47. width: "".concat(componentWidth.value - (fixHeader.value ? tableContext.scrollbarSize : 0), "px"),
  48. position: 'sticky',
  49. left: 0,
  50. overflow: 'hidden'
  51. },
  52. "class": "".concat(prefixCls, "-expanded-row-fixed")
  53. }, [contentNode]);
  54. }
  55. return contentNode;
  56. }
  57. })];
  58. }
  59. });
  60. };
  61. }
  62. });