ColGroup.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { createVNode as _createVNode } from "vue";
  3. var __rest = this && this.__rest || function (s, e) {
  4. var t = {};
  5. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  8. }
  9. return t;
  10. };
  11. import { INTERNAL_COL_DEFINE } from './utils/legacyUtil';
  12. function ColGroup(_ref) {
  13. let {
  14. colWidths,
  15. columns,
  16. columCount
  17. } = _ref;
  18. const cols = [];
  19. const len = columCount || columns.length;
  20. // Only insert col with width & additional props
  21. // Skip if rest col do not have any useful info
  22. let mustInsert = false;
  23. for (let i = len - 1; i >= 0; i -= 1) {
  24. const width = colWidths[i];
  25. const column = columns && columns[i];
  26. const additionalProps = column && column[INTERNAL_COL_DEFINE];
  27. if (width || additionalProps || mustInsert) {
  28. const _a = additionalProps || {},
  29. {
  30. columnType
  31. } = _a,
  32. restAdditionalProps = __rest(_a, ["columnType"]);
  33. cols.unshift(_createVNode("col", _objectSpread({
  34. "key": i,
  35. "style": {
  36. width: typeof width === 'number' ? `${width}px` : width
  37. }
  38. }, restAdditionalProps), null));
  39. mustInsert = true;
  40. }
  41. }
  42. return _createVNode("colgroup", null, [cols]);
  43. }
  44. export default ColGroup;