8b3f849b2202d8b1e1b15067642de62d7660946ffe9abf43c0c2b1a83bbd2f719dbd63340714569365fc0ae3e672f689999a9ad5990ebdede76820efa323bc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var utils = require('../utils.js');
  5. var types = require('../../../../utils/types.js');
  6. var style = require('../../../../utils/dom/style.js');
  7. const useStyles = (props, {
  8. columnsTotalWidth,
  9. rowsHeight,
  10. fixedColumnsOnLeft,
  11. fixedColumnsOnRight
  12. }) => {
  13. const bodyWidth = vue.computed(() => {
  14. const { fixed, width, vScrollbarSize } = props;
  15. const ret = width - vScrollbarSize;
  16. return fixed ? Math.max(Math.round(vue.unref(columnsTotalWidth)), ret) : ret;
  17. });
  18. const mainTableHeight = vue.computed(() => {
  19. const { height = 0, maxHeight = 0, footerHeight: footerHeight2, hScrollbarSize } = props;
  20. if (maxHeight > 0) {
  21. const _fixedRowsHeight = vue.unref(fixedRowsHeight);
  22. const _rowsHeight = vue.unref(rowsHeight);
  23. const _headerHeight = vue.unref(headerHeight);
  24. const total = _headerHeight + _fixedRowsHeight + _rowsHeight + hScrollbarSize;
  25. return Math.min(total, maxHeight - footerHeight2);
  26. }
  27. return height - footerHeight2;
  28. });
  29. const fixedTableHeight = vue.computed(() => {
  30. const { maxHeight } = props;
  31. const tableHeight = vue.unref(mainTableHeight);
  32. if (types.isNumber(maxHeight) && maxHeight > 0)
  33. return tableHeight;
  34. const totalHeight = vue.unref(rowsHeight) + vue.unref(headerHeight) + vue.unref(fixedRowsHeight);
  35. return Math.min(tableHeight, totalHeight);
  36. });
  37. const mapColumn = (column) => column.width;
  38. const leftTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnLeft).map(mapColumn)));
  39. const rightTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnRight).map(mapColumn)));
  40. const headerHeight = vue.computed(() => utils.sum(props.headerHeight));
  41. const fixedRowsHeight = vue.computed(() => {
  42. var _a;
  43. return (((_a = props.fixedData) == null ? void 0 : _a.length) || 0) * props.rowHeight;
  44. });
  45. const windowHeight = vue.computed(() => {
  46. return vue.unref(mainTableHeight) - vue.unref(headerHeight) - vue.unref(fixedRowsHeight);
  47. });
  48. const rootStyle = vue.computed(() => {
  49. const { style = {}, height, width } = props;
  50. return utils.enforceUnit({
  51. ...style,
  52. height,
  53. width
  54. });
  55. });
  56. const footerHeight = vue.computed(() => utils.enforceUnit({ height: props.footerHeight }));
  57. const emptyStyle = vue.computed(() => ({
  58. top: style.addUnit(vue.unref(headerHeight)),
  59. bottom: style.addUnit(props.footerHeight),
  60. width: style.addUnit(props.width)
  61. }));
  62. return {
  63. bodyWidth,
  64. fixedTableHeight,
  65. mainTableHeight,
  66. leftTableWidth,
  67. rightTableWidth,
  68. windowHeight,
  69. footerHeight,
  70. emptyStyle,
  71. rootStyle,
  72. headerHeight
  73. };
  74. };
  75. exports.useStyles = useStyles;
  76. //# sourceMappingURL=use-styles.js.map