4eb7d351c2c4bc64ae58a86832e8813bfdd14ab45f514c4fc1ce654cff988e76a42353d7f8868c6bd69d0733d4676b86bb437c7430120c229f81e9777bb68f 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var lodashUnified = require('lodash-unified');
  5. var constants = require('../constants.js');
  6. var _private = require('../private.js');
  7. var utils = require('../utils.js');
  8. var cell = require('../components/cell.js');
  9. var expandIcon = require('../components/expand-icon.js');
  10. var shared = require('@vue/shared');
  11. const CellRenderer = ({
  12. columns,
  13. column,
  14. columnIndex,
  15. depth,
  16. expandIconProps,
  17. isScrolling,
  18. rowData,
  19. rowIndex,
  20. style,
  21. expandedRowKeys,
  22. ns,
  23. cellProps: _cellProps,
  24. expandColumnKey,
  25. indentSize,
  26. iconSize,
  27. rowKey
  28. }, {
  29. slots
  30. }) => {
  31. const cellStyle = utils.enforceUnit(style);
  32. if (column.placeholderSign === _private.placeholderSign) {
  33. return vue.createVNode("div", {
  34. "class": ns.em("row-cell", "placeholder"),
  35. "style": cellStyle
  36. }, null);
  37. }
  38. const {
  39. cellRenderer,
  40. dataKey,
  41. dataGetter
  42. } = column;
  43. const cellData = shared.isFunction(dataGetter) ? dataGetter({
  44. columns,
  45. column,
  46. columnIndex,
  47. rowData,
  48. rowIndex
  49. }) : lodashUnified.get(rowData, dataKey != null ? dataKey : "");
  50. const extraCellProps = utils.tryCall(_cellProps, {
  51. cellData,
  52. columns,
  53. column,
  54. columnIndex,
  55. rowIndex,
  56. rowData
  57. });
  58. const cellProps = {
  59. class: ns.e("cell-text"),
  60. columns,
  61. column,
  62. columnIndex,
  63. cellData,
  64. isScrolling,
  65. rowData,
  66. rowIndex
  67. };
  68. const columnCellRenderer = utils.componentToSlot(cellRenderer);
  69. const Cell = columnCellRenderer ? columnCellRenderer(cellProps) : vue.renderSlot(slots, "default", cellProps, () => [vue.createVNode(cell["default"], cellProps, null)]);
  70. const kls = [ns.e("row-cell"), column.class, column.align === constants.Alignment.CENTER && ns.is("align-center"), column.align === constants.Alignment.RIGHT && ns.is("align-right")];
  71. const expandable = rowIndex >= 0 && expandColumnKey && column.key === expandColumnKey;
  72. const expanded = rowIndex >= 0 && expandedRowKeys.includes(rowData[rowKey]);
  73. let IconOrPlaceholder;
  74. const iconStyle = `margin-inline-start: ${depth * indentSize}px;`;
  75. if (expandable) {
  76. if (shared.isObject(expandIconProps)) {
  77. IconOrPlaceholder = vue.createVNode(expandIcon["default"], vue.mergeProps(expandIconProps, {
  78. "class": [ns.e("expand-icon"), ns.is("expanded", expanded)],
  79. "size": iconSize,
  80. "expanded": expanded,
  81. "style": iconStyle,
  82. "expandable": true
  83. }), null);
  84. } else {
  85. IconOrPlaceholder = vue.createVNode("div", {
  86. "style": [iconStyle, `width: ${iconSize}px; height: ${iconSize}px;`].join(" ")
  87. }, null);
  88. }
  89. }
  90. return vue.createVNode("div", vue.mergeProps({
  91. "class": kls,
  92. "style": cellStyle
  93. }, extraCellProps, {
  94. "role": "cell"
  95. }), [IconOrPlaceholder, Cell]);
  96. };
  97. CellRenderer.inheritAttrs = false;
  98. var Cell = CellRenderer;
  99. exports["default"] = Cell;
  100. //# sourceMappingURL=cell.js.map