ColGroup.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
  3. var _excluded = ["columnType"];
  4. import { createVNode as _createVNode } from "vue";
  5. import { INTERNAL_COL_DEFINE } from './utils/legacyUtil';
  6. function ColGroup(_ref) {
  7. var colWidths = _ref.colWidths,
  8. columns = _ref.columns,
  9. columCount = _ref.columCount;
  10. var cols = [];
  11. var len = columCount || columns.length;
  12. // Only insert col with width & additional props
  13. // Skip if rest col do not have any useful info
  14. var mustInsert = false;
  15. for (var i = len - 1; i >= 0; i -= 1) {
  16. var width = colWidths[i];
  17. var column = columns && columns[i];
  18. var additionalProps = column && column[INTERNAL_COL_DEFINE];
  19. if (width || additionalProps || mustInsert) {
  20. var _ref2 = additionalProps || {},
  21. columnType = _ref2.columnType,
  22. restAdditionalProps = _objectWithoutProperties(_ref2, _excluded);
  23. cols.unshift(_createVNode("col", _objectSpread({
  24. "key": i,
  25. "style": {
  26. width: typeof width === 'number' ? "".concat(width, "px") : width
  27. }
  28. }, restAdditionalProps), null));
  29. mustInsert = true;
  30. }
  31. }
  32. return _createVNode("colgroup", null, [cols]);
  33. }
  34. export default ColGroup;