ColGroup.js 1.8 KB

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