tdesign-vue
Version:
925 lines (917 loc) • 41.7 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 tdesign
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helper = require('../_chunks/dep-4009cfe4.js');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var table_baseTableProps = require('./base-table-props.js');
var table_hooks_useTableHeader = require('./hooks/useTableHeader.js');
var table_hooks_useColumnResize = require('./hooks/useColumnResize.js');
var table_hooks_useFixed = require('./hooks/useFixed.js');
var table_hooks_usePagination = require('./hooks/usePagination.js');
var hooks_useVirtualScrollNew = require('../hooks/useVirtualScrollNew.js');
var table_hooks_useAffix = require('./hooks/useAffix.js');
var loading_index = require('../loading/index.js');
var table_tbody = require('./tbody.js');
var table_hooks_useStyle = require('./hooks/useStyle.js');
var table_hooks_useClassName = require('./hooks/useClassName.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
var table_hooks_useRowHighlight = require('./hooks/useRowHighlight.js');
var table_hooks_useHoverKeyboardEvent = require('./hooks/useHoverKeyboardEvent.js');
var affix_index = require('../affix/index.js');
var table_tr = require('./tr.js');
var table_thead = require('./thead.js');
var table_tfoot = require('./tfoot.js');
var _common_js_log_log = require('../_common/js/log/log.js');
var _common_js_utils_helper = require('../_common/js/utils/helper.js');
var table_utils = require('./utils.js');
var pick = require('../_chunks/dep-d250e942.js');
var isFunction = require('../_chunks/dep-8d206316.js');
var get = require('../_chunks/dep-a7198720.js');
var hooks_useElementLazyRender = require('../hooks/useElementLazyRender.js');
var utils_renderTnode = require('../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('./hooks/useMultiHeader.js');
require('./ellipsis.js');
require('../utils/dom.js');
require('vue');
require('raf');
require('../utils/easing.js');
require('../_chunks/dep-a2217d56.js');
require('../_chunks/dep-3b2292ce.js');
require('../_chunks/dep-10fcb46d.js');
require('../_chunks/dep-ba7f5924.js');
require('../tooltip/index.js');
require('../tooltip/tooltip.js');
require('../tooltip/props.js');
require('../popup/props.js');
require('../popup/popup.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@popperjs/core');
require('../utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../_chunks/dep-9c5b91d3.js');
require('../_chunks/dep-9a74c2be.js');
require('../_chunks/dep-689d381f.js');
require('../_chunks/dep-803744d9.js');
require('../_chunks/dep-84027b7f.js');
require('../_chunks/dep-49400b00.js');
require('../_chunks/dep-f1081d8e.js');
require('../_common/js/utils/setStyle.js');
require('../popup/container.js');
require('../config-provider/config-receiver.js');
require('../_chunks/dep-8eddb350.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-0c37520c.js');
require('../_chunks/dep-c13dcbfd.js');
require('dayjs');
require('../_chunks/dep-6f4e680e.js');
require('../_chunks/dep-bb0ececf.js');
require('../_chunks/dep-6eba4d23.js');
require('../_chunks/dep-010db548.js');
require('../_chunks/dep-f77d6ad5.js');
require('../_chunks/dep-9dae8101.js');
require('../_chunks/dep-7c84d9a0.js');
require('../_chunks/dep-733a2279.js');
require('../_chunks/dep-2bc87cc8.js');
require('../_chunks/dep-d844c9ed.js');
require('../_chunks/dep-c05a9033.js');
require('../_chunks/dep-efe55b82.js');
require('../_chunks/dep-7da70ee1.js');
require('../_chunks/dep-124386d4.js');
require('../_chunks/dep-f5b14344.js');
require('../_chunks/dep-36c2788b.js');
require('../_chunks/dep-fa353fbb.js');
require('../_chunks/dep-d66ab3a4.js');
require('../_chunks/dep-d4d8c513.js');
require('../_common/js/global-config/t.js');
require('../utils/mixins.js');
require('../utils/event.js');
require('../popup/utils.js');
require('../_chunks/dep-ee4e645f.js');
require('../_chunks/dep-0ea9f257.js');
require('../utils/map-props.js');
require('../utils/withInstall.js');
require('@babel/runtime/helpers/readOnlyError');
require('../_chunks/dep-2c592e99.js');
require('../_chunks/dep-268c68b1.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('../_chunks/dep-56f568d3.js');
require('../_chunks/dep-116aedc3.js');
require('../_chunks/dep-d7516e38.js');
require('../_chunks/dep-f020448d.js');
require('../_chunks/dep-a96e5563.js');
require('../_chunks/dep-4e96e31a.js');
require('../_chunks/dep-74be1050.js');
require('../_chunks/dep-da2ef9c3.js');
require('../pagination/index.js');
require('../pagination/pagination.js');
require('tdesign-icons-vue');
require('../input-number/index.js');
require('../input-number/input-number.js');
require('../button/index.js');
require('../button/button.js');
require('../button/props.js');
require('../utils/ripple.js');
require('../config.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../loading/loading.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../_chunks/dep-721fcdf6.js');
require('../_chunks/dep-591b87f1.js');
require('../_chunks/dep-97fef2be.js');
require('../_chunks/dep-0b47afa3.js');
require('../_chunks/dep-7fbd94e9.js');
require('../_chunks/dep-82ce56ef.js');
require('../_chunks/dep-17ce3e74.js');
require('../_chunks/dep-c9ce9427.js');
require('../_chunks/dep-1e173c2b.js');
require('../_chunks/dep-edb55477.js');
require('../input/index.js');
require('../input/input.js');
require('../input/props.js');
require('../input/input-group.js');
require('../input-number/props.js');
require('../input-number/useInputNumber.js');
require('../hooks/useCommonClassName.js');
require('../hooks/useVModel.js');
require('../_common/js/input-number/number.js');
require('../_common/js/input-number/large-number.js');
require('../hooks/useFormDisabled.js');
require('../hooks/useGlobalIcon.js');
require('../select/index.js');
require('../select/select.js');
require('../hooks/useDefaultValue.js');
require('../hooks/tnode.js');
require('../hooks/render-tnode.js');
require('../_chunks/dep-812bd25d.js');
require('../select/props.js');
require('../popup/index.js');
require('../popup/plugin.js');
require('../tag/index.js');
require('../tag/tag.js');
require('tinycolor2');
require('../tag/props.js');
require('../tag/check-tag.js');
require('../tag/check-tag-props.js');
require('../hooks/useConfig.js');
require('../_common/js/common.js');
require('../tag/check-tag-group.js');
require('../tag/check-tag-group-props.js');
require('../select-input/index.js');
require('../select-input/select-input.js');
require('../select-input/props.js');
require('../select-input/useSingle.js');
require('../select-input/useMultiple.js');
require('../tag-input/index.js');
require('../tag-input/tag-input.js');
require('../tag-input/props.js');
require('../tag-input/hooks/useTagScroll.js');
require('../tag-input/useTagList.js');
require('../tag-input/hooks/useHover.js');
require('../tag-input/hooks/useDragSorter.js');
require('../select-input/useOverlayInnerStyle.js');
require('../_chunks/dep-518e9c7b.js');
require('../common-components/fake-arrow.js');
require('../select/option.js');
require('../select/option-props.js');
require('../checkbox/index.js');
require('../checkbox/group.js');
require('../checkbox/checkbox.js');
require('../checkbox/props.js');
require('../checkbox/constants.js');
require('../checkbox/store.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('../checkbox/hooks/useKeyboardEvent.js');
require('../_common/js/utils/observe.js');
require('../checkbox/checkbox-group-props.js');
require('../_chunks/dep-993ef18d.js');
require('../hooks/slots.js');
require('../hooks/useLazyLoad.js');
require('../select/util.js');
require('../_chunks/dep-25a90d6f.js');
require('../_chunks/dep-594e0165.js');
require('../select/select-panel.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../hooks/useVirtualScroll.js');
require('../_chunks/dep-2c32d315.js');
require('../select/hooks/useSelectOptions.js');
require('../input-adornment/index.js');
require('../input-adornment/input-adornment.js');
require('../input-adornment/props.js');
require('../pagination/props.js');
require('../pagination/pagination-mini.js');
require('../pagination/pagination-mini-props.js');
require('../hooks/useResizeObserver.js');
require('./hooks/useRowspanAndColspan.js');
require('../affix/affix.js');
require('../affix/props.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var BASE_TABLE_EVENTS = ["page-change", "cell-click", "scroll", "scrollX", "scrollY", "column-resize-change"];
var BASE_TABLE_ALL_EVENTS = table_tr.ROW_LISTENERS.map(function (t) {
return "row-".concat(t);
}).concat(BASE_TABLE_EVENTS);
var _BaseTable = VueCompositionAPI.defineComponent({
name: "TBaseTable",
props: _objectSpread(_objectSpread({}, table_baseTableProps["default"]), {}, {
renderExpandedRow: Function,
onLeafColumnsChange: Function,
thDraggable: Boolean
}),
setup: function setup(props2, context) {
var _toRefs = VueCompositionAPI.toRefs(props2),
lazyLoad = _toRefs.lazyLoad;
var tableRef = VueCompositionAPI.ref();
var tableElmRef = VueCompositionAPI.ref();
var tableBodyRef = VueCompositionAPI.ref();
var bottomContentRef = VueCompositionAPI.ref();
var tableFootHeight = VueCompositionAPI.ref(0);
var _useClassName = table_hooks_useClassName["default"](),
classPrefix = _useClassName.classPrefix,
virtualScrollClasses = _useClassName.virtualScrollClasses,
tableLayoutClasses = _useClassName.tableLayoutClasses,
tableBaseClass = _useClassName.tableBaseClass,
tableColFixedClasses = _useClassName.tableColFixedClasses;
var _useStyle = table_hooks_useStyle["default"](props2),
tableClasses = _useStyle.tableClasses,
sizeClassNames = _useStyle.sizeClassNames,
tableContentStyles = _useStyle.tableContentStyles,
tableElementStyles = _useStyle.tableElementStyles;
var _useConfig = configProvider_useConfig.useConfig("table", props2.locale),
global = _useConfig.global;
var _useTableHeader = table_hooks_useTableHeader["default"](props2),
isMultipleHeader = _useTableHeader.isMultipleHeader,
spansAndLeafNodes = _useTableHeader.spansAndLeafNodes,
thList = _useTableHeader.thList;
var finalColumns = VueCompositionAPI.computed(function () {
var _spansAndLeafNodes$va;
return ((_spansAndLeafNodes$va = spansAndLeafNodes.value) === null || _spansAndLeafNodes$va === void 0 ? void 0 : _spansAndLeafNodes$va.leafColumns) || props2.columns;
});
var isIE = VueCompositionAPI.computed(function () {
return _common_js_utils_helper.getIEVersion() <= 11;
});
var tableSize = VueCompositionAPI.computed(function () {
var _props2$size;
return (_props2$size = props2.size) !== null && _props2$size !== void 0 ? _props2$size : global.value.size;
});
var paginationAffixRef = VueCompositionAPI.ref();
var horizontalScrollAffixRef = VueCompositionAPI.ref();
var headerTopAffixRef = VueCompositionAPI.ref();
var footerBottomAffixRef = VueCompositionAPI.ref();
var _useFixed = table_hooks_useFixed["default"](props2, context, finalColumns, {
paginationAffixRef: paginationAffixRef,
horizontalScrollAffixRef: horizontalScrollAffixRef,
headerTopAffixRef: headerTopAffixRef,
footerBottomAffixRef: footerBottomAffixRef
}),
scrollbarWidth = _useFixed.scrollbarWidth,
tableWidth = _useFixed.tableWidth,
tableElmWidth = _useFixed.tableElmWidth,
tableContentRef = _useFixed.tableContentRef,
isFixedHeader = _useFixed.isFixedHeader,
isWidthOverflow = _useFixed.isWidthOverflow,
isFixedColumn = _useFixed.isFixedColumn,
thWidthList = _useFixed.thWidthList,
showColumnShadow = _useFixed.showColumnShadow,
rowAndColFixedPosition = _useFixed.rowAndColFixedPosition,
setData = _useFixed.setData,
refreshTable = _useFixed.refreshTable,
setTableElmWidth = _useFixed.setTableElmWidth,
emitScrollEvent = _useFixed.emitScrollEvent,
setUseFixedTableElmRef = _useFixed.setUseFixedTableElmRef,
updateColumnFixedShadow = _useFixed.updateColumnFixedShadow,
getThWidthList = _useFixed.getThWidthList,
updateThWidthList = _useFixed.updateThWidthList,
addTableResizeObserver = _useFixed.addTableResizeObserver,
updateTableAfterColumnResize = _useFixed.updateTableAfterColumnResize;
var _useAffix = table_hooks_useAffix["default"](props2),
affixHeaderRef = _useAffix.affixHeaderRef,
affixFooterRef = _useAffix.affixFooterRef,
horizontalScrollbarRef = _useAffix.horizontalScrollbarRef,
paginationRef = _useAffix.paginationRef,
showAffixHeader = _useAffix.showAffixHeader,
showAffixFooter = _useAffix.showAffixFooter,
showAffixPagination = _useAffix.showAffixPagination,
onHorizontalScroll = _useAffix.onHorizontalScroll,
updateAffixHeaderOrFooter = _useAffix.updateAffixHeaderOrFooter,
setTableContentRef = _useAffix.setTableContentRef,
updateHorizontalScroll = _useAffix.updateHorizontalScroll;
var _useElementLazyRender = hooks_useElementLazyRender.useElementLazyRender(tableRef, lazyLoad),
showElement = _useElementLazyRender.showElement;
var _usePagination = table_hooks_usePagination["default"](props2, context, tableContentRef),
dataSource = _usePagination.dataSource,
innerPagination = _usePagination.innerPagination,
isPaginateData = _usePagination.isPaginateData,
renderPagination = _usePagination.renderPagination;
VueCompositionAPI.watch(innerPagination, function () {
if (showAffixHeader || showAffixFooter || showAffixPagination) {
updateHorizontalScroll();
}
});
var onInnerResizeChange = function onInnerResizeChange(p) {
var _props2$onColumnResiz;
(_props2$onColumnResiz = props2.onColumnResizeChange) === null || _props2$onColumnResiz === void 0 || _props2$onColumnResiz.call(props2, p);
context.emit("column-resize-change", p);
};
var columnResizeParams = table_hooks_useColumnResize["default"]({
isWidthOverflow: isWidthOverflow,
tableContentRef: tableContentRef,
showColumnShadow: showColumnShadow,
getThWidthList: getThWidthList,
updateThWidthList: updateThWidthList,
setTableElmWidth: setTableElmWidth,
updateTableAfterColumnResize: updateTableAfterColumnResize,
onColumnResizeChange: onInnerResizeChange
});
var resizeLineRef = columnResizeParams.resizeLineRef,
resizeLineStyle = columnResizeParams.resizeLineStyle,
setEffectColMap = columnResizeParams.setEffectColMap;
var dynamicBaseTableClasses = VueCompositionAPI.computed(function () {
return [tableClasses.value, _defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"]({}, tableBaseClass.headerFixed, isFixedHeader.value), tableBaseClass.columnFixed, isFixedColumn.value), tableBaseClass.widthOverflow, isWidthOverflow.value), tableBaseClass.multipleHeader, isMultipleHeader.value), tableColFixedClasses.leftShadow, showColumnShadow.left), tableColFixedClasses.rightShadow, showColumnShadow.right), tableBaseClass.columnResizableTable, props2.resizable), "".concat(classPrefix, "-table__row--active-").concat(props2.activeRowType), props2.activeRowType)];
});
var tableElmClasses = VueCompositionAPI.computed(function () {
return [[tableLayoutClasses[props2.tableLayout]]];
});
var showRightDivider = VueCompositionAPI.computed(function () {
return props2.bordered && isFixedHeader.value && (isMultipleHeader.value && isWidthOverflow.value || !isMultipleHeader.value);
});
var dividerBottom = VueCompositionAPI.computed(function () {
var _bottomContentRef$val, _paginationRef$value;
if (!props2.bordered) return 0;
var bottomRect = (_bottomContentRef$val = bottomContentRef.value) === null || _bottomContentRef$val === void 0 ? void 0 : _bottomContentRef$val.getBoundingClientRect();
var paginationRect = (_paginationRef$value = paginationRef.value) === null || _paginationRef$value === void 0 ? void 0 : _paginationRef$value.getBoundingClientRect();
return ((bottomRect === null || bottomRect === void 0 ? void 0 : bottomRect.height) || 0) + ((paginationRect === null || paginationRect === void 0 ? void 0 : paginationRect.height) || 0);
});
var columnResizable = VueCompositionAPI.computed(function () {
var _props2$allowResizeCo;
return (_props2$allowResizeCo = props2.allowResizeColumnWidth) !== null && _props2$allowResizeCo !== void 0 ? _props2$allowResizeCo : props2.resizable;
});
var _useRowHighlight = table_hooks_useRowHighlight.useRowHighlight(props2, tableRef),
tActiveRow = _useRowHighlight.tActiveRow,
onHighlightRow = _useRowHighlight.onHighlightRow,
addHighlightKeyboardListener = _useRowHighlight.addHighlightKeyboardListener,
removeHighlightKeyboardListener = _useRowHighlight.removeHighlightKeyboardListener;
var _useHoverKeyboardEven = table_hooks_useHoverKeyboardEvent.useHoverKeyboardEvent(props2, tableRef),
hoverRow = _useHoverKeyboardEven.hoverRow,
needKeyboardRowHover = _useHoverKeyboardEven.needKeyboardRowHover,
clearHoverRow = _useHoverKeyboardEven.clearHoverRow,
addRowHoverKeyboardListener = _useHoverKeyboardEven.addRowHoverKeyboardListener,
removeRowHoverKeyboardListener = _useHoverKeyboardEven.removeRowHoverKeyboardListener,
tableRefTabIndex = _useHoverKeyboardEven.tableRefTabIndex;
VueCompositionAPI.watch(tableElmRef, function () {
setUseFixedTableElmRef(tableElmRef.value);
});
VueCompositionAPI.watch(function () {
return [props2.data, dataSource, isPaginateData];
}, function () {
setData(isPaginateData.value ? dataSource.value : props2.data);
});
VueCompositionAPI.watch(spansAndLeafNodes, function () {
var _props2$onLeafColumns;
(_props2$onLeafColumns = props2.onLeafColumnsChange) === null || _props2$onLeafColumns === void 0 || _props2$onLeafColumns.call(props2, spansAndLeafNodes.value.leafColumns);
context.emit("LeafColumnsChange", spansAndLeafNodes.value.leafColumns);
setEffectColMap(spansAndLeafNodes.value.leafColumns, null);
}, {
immediate: true
});
var onFixedChange = function onFixedChange() {
VueCompositionAPI.nextTick(function () {
onHorizontalScroll();
updateAffixHeaderOrFooter();
});
};
var getListener = function getListener() {
var listener = {};
BASE_TABLE_ALL_EVENTS.forEach(function (key) {
listener[key] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
context.emit.apply(context, [key].concat(args));
};
});
return listener;
};
var virtualScrollParams = VueCompositionAPI.computed(function () {
return {
data: props2.data,
scroll: props2.scroll
};
});
var virtualConfig = hooks_useVirtualScrollNew["default"](tableContentRef, virtualScrollParams);
var lastScrollY = 0;
var onInnerVirtualScroll = function onInnerVirtualScroll(e) {
var target = e.target || e.srcElement;
var top = target.scrollTop;
if (lastScrollY !== top) {
virtualConfig.isVirtualScroll.value && virtualConfig.handleScroll();
} else {
lastScrollY = 0;
updateColumnFixedShadow(target);
}
lastScrollY = top;
emitScrollEvent(e);
};
var getTFootHeight = function getTFootHeight() {
var _tableElmRef$value$qu;
if (!tableElmRef.value) return;
tableFootHeight.value = (_tableElmRef$value$qu = tableElmRef.value.querySelector("tfoot")) === null || _tableElmRef$value$qu === void 0 ? void 0 : _tableElmRef$value$qu.getBoundingClientRect().height;
};
var scrollColumnIntoView = function scrollColumnIntoView(colKey) {
if (!tableContentRef.value) return;
var thDom = tableContentRef.value.querySelector("th[data-colkey=\"".concat(colKey, "\"]"));
var fixedThDom = tableContentRef.value.querySelectorAll("th.t-table__cell--fixed-left");
var totalWidth = 0;
for (var i = 0, len = fixedThDom.length; i < len; i++) {
totalWidth += fixedThDom[i].getBoundingClientRect().width;
}
var domRect = thDom.getBoundingClientRect();
var contentRect = tableContentRef.value.getBoundingClientRect();
var distance = domRect.left - contentRect.left - totalWidth;
tableContentRef.value.scrollTo({
left: distance,
behavior: "smooth"
});
};
VueCompositionAPI.watch(tableContentRef, function () {
setTableContentRef(tableContentRef.value);
});
VueCompositionAPI.watch(tableElmRef, getTFootHeight);
VueCompositionAPI.watch(tableRef, function (tableRef2) {
addTableResizeObserver(tableRef2);
});
VueCompositionAPI.onMounted(function () {
getTFootHeight();
setTableContentRef(tableContentRef.value);
addTableResizeObserver(tableRef.value);
});
var onTableFocus = function onTableFocus() {
props2.activeRowType && addHighlightKeyboardListener();
needKeyboardRowHover.value && addRowHoverKeyboardListener();
};
var onTableBlur = function onTableBlur() {
props2.activeRowType && removeHighlightKeyboardListener();
needKeyboardRowHover.value && removeRowHoverKeyboardListener();
};
var onInnerRowClick = function onInnerRowClick(ctx) {
var _props2$onRowClick;
(_props2$onRowClick = props2.onRowClick) === null || _props2$onRowClick === void 0 || _props2$onRowClick.call(props2, ctx);
props2.activeRowType && onHighlightRow(ctx);
needKeyboardRowHover.value && clearHoverRow();
};
var tableData = VueCompositionAPI.computed(function () {
return isPaginateData.value ? dataSource.value : props2.data;
});
var scrollToElement = function scrollToElement(params) {
var index = params.index;
if (!index && index !== 0) {
var _tableData$value;
if (!params.key) {
_common_js_log_log["default"].error("Table", "scrollToElement: one of `index` or `key` must exist.");
return;
}
index = (_tableData$value = tableData.value) === null || _tableData$value === void 0 ? void 0 : _tableData$value.findIndex(function (item) {
return get.get(item, props2.rowKey) === params.key;
});
if (index < 0) {
_common_js_log_log["default"].error("Table", "".concat(params.key, " does not exist in data, check `rowKey` or `data` please."));
}
}
virtualConfig.scrollToElement(_objectSpread(_objectSpread({}, params), {}, {
index: index
}));
};
VueCompositionAPI.watch([showElement], function (_ref2) {
var _ref3 = _slicedToArray__default["default"](_ref2, 1),
showElement2 = _ref3[0];
context.emit("show-element-change", showElement2);
}, {
immediate: true
});
return {
virtualConfig: virtualConfig,
scrollToElement: scrollToElement,
columnResizable: columnResizable,
thList: thList,
classPrefix: classPrefix,
innerPagination: innerPagination,
global: global,
tableSize: tableSize,
tableFootHeight: tableFootHeight,
tableWidth: tableWidth,
tableElmWidth: tableElmWidth,
tableRef: tableRef,
tableElmRef: tableElmRef,
sizeClassNames: sizeClassNames,
tableBaseClass: tableBaseClass,
spansAndLeafNodes: spansAndLeafNodes,
dynamicBaseTableClasses: dynamicBaseTableClasses,
tableContentStyles: tableContentStyles,
tableElementStyles: tableElementStyles,
virtualScrollClasses: virtualScrollClasses,
tableLayoutClasses: tableLayoutClasses,
tableElmClasses: tableElmClasses,
dividerBottom: dividerBottom,
tableContentRef: tableContentRef,
isFixedHeader: isFixedHeader,
isWidthOverflow: isWidthOverflow,
isFixedColumn: isFixedColumn,
rowAndColFixedPosition: rowAndColFixedPosition,
showColumnShadow: showColumnShadow,
thWidthList: thWidthList,
isPaginateData: isPaginateData,
dataSource: dataSource,
affixHeaderRef: affixHeaderRef,
affixFooterRef: affixFooterRef,
paginationRef: paginationRef,
bottomContentRef: bottomContentRef,
showAffixHeader: showAffixHeader,
showAffixFooter: showAffixFooter,
scrollbarWidth: scrollbarWidth,
isMultipleHeader: isMultipleHeader,
showRightDivider: showRightDivider,
resizeLineRef: resizeLineRef,
resizeLineStyle: resizeLineStyle,
columnResizeParams: columnResizeParams,
horizontalScrollbarRef: horizontalScrollbarRef,
tableBodyRef: tableBodyRef,
showAffixPagination: showAffixPagination,
tActiveRow: tActiveRow,
hoverRow: hoverRow,
showElement: showElement,
getListener: getListener,
renderPagination: renderPagination,
onFixedChange: onFixedChange,
onHorizontalScroll: onHorizontalScroll,
updateAffixHeaderOrFooter: updateAffixHeaderOrFooter,
refreshTable: refreshTable,
onInnerVirtualScroll: onInnerVirtualScroll,
scrollColumnIntoView: scrollColumnIntoView,
onTableFocus: onTableFocus,
onTableBlur: onTableBlur,
onInnerRowClick: onInnerRowClick,
paginationAffixRef: paginationAffixRef,
horizontalScrollAffixRef: horizontalScrollAffixRef,
headerTopAffixRef: headerTopAffixRef,
footerBottomAffixRef: footerBottomAffixRef,
isIE: isIE,
tableRefTabIndex: tableRefTabIndex
};
},
methods: {
renderColGroup: function renderColGroup(columns) {
var _this = this;
var isAffixHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var h = this.$createElement;
return h("colgroup", [columns.map(function (col) {
var style = {
width: table_hooks_useStyle.formatCSSUnit((isAffixHeader || _this.columnResizable ? _this.thWidthList[col.colKey] : void 0) || col.width)
};
if (col.minWidth) {
style.minWidth = table_hooks_useStyle.formatCSSUnit(col.minWidth);
}
if (!style.width && !col.minWidth && _this.tableLayout === "fixed") {
style.minWidth = "80px";
}
return h("col", {
"key": col.colKey,
"style": style
});
})]);
},
getHeadProps: function getHeadProps() {
var isAffixHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var headProps = {
isFixedHeader: this.isFixedHeader,
showColumnShadow: this.showColumnShadow,
thDraggable: this.thDraggable,
rowAndColFixedPosition: this.rowAndColFixedPosition,
isMultipleHeader: this.isMultipleHeader,
bordered: this.bordered,
maxHeight: this.maxHeight,
height: this.height,
spansAndLeafNodes: this.spansAndLeafNodes,
thList: this.thList,
thWidthList: isAffixHeader || this.columnResizable ? this.thWidthList : {},
resizable: this.resizable,
columnResizeParams: this.columnResizeParams,
classPrefix: this.classPrefix,
ellipsisOverlayClassName: this.tableSize !== "medium" ? this.sizeClassNames[this.tableSize] : "",
attach: this.attach
};
return headProps;
},
renderFixedHeader: function renderFixedHeader(columns) {
var _this$affixHeaderRef;
var h = this.$createElement;
if (!this.showHeader) return null;
var isVirtual = this.virtualConfig.isVirtualScroll.value;
var barWidth = this.isWidthOverflow ? this.scrollbarWidth : 0;
var IEHeaderWrap = this.isIE ? 4 : 0;
var affixHeaderHeight = (((_this$affixHeaderRef = this.affixHeaderRef) === null || _this$affixHeaderRef === void 0 ? void 0 : _this$affixHeaderRef.getBoundingClientRect().height) || 0) - IEHeaderWrap;
var affixHeaderWrapHeight = affixHeaderHeight - barWidth;
var headerOpacity = this.headerAffixedTop ? Number(this.showAffixHeader) : 1;
var affixHeaderWrapHeightStyle = {
width: "".concat(this.tableWidth, "px"),
height: "".concat(affixHeaderWrapHeight, "px"),
opacity: headerOpacity
};
var colgroup = this.renderColGroup(columns, true);
var affixedLeftBorder = this.bordered && !this.isIE ? 1 : 0;
var affixedHeader = Boolean((this.headerAffixedTop || isVirtual) && this.tableWidth) && h("div", {
"ref": "affixHeaderRef",
"style": {
width: "".concat(this.tableWidth - affixedLeftBorder, "px"),
opacity: headerOpacity
},
"class": ["scrollbar", _defineProperty__default["default"]({}, this.tableBaseClass.affixedHeaderElm, this.headerAffixedTop || isVirtual)]
}, [h("table", {
"class": this.tableElmClasses,
"style": _objectSpread(_objectSpread({}, this.tableElementStyles), {}, {
width: "".concat(this.tableElmWidth, "px")
})
}, [colgroup, h(table_thead["default"], helper.helper([{
"scopedSlots": this.$scopedSlots
}, {
"props": this.getHeadProps(true)
}]))])]);
var affixHeaderWithWrap = h("div", {
"class": this.tableBaseClass.affixedHeaderWrap,
"style": affixHeaderWrapHeightStyle
}, [affixedHeader]);
return affixHeaderWithWrap;
},
renderAffixedFooter: function renderAffixedFooter(columns) {
var _this$footData;
var h = this.$createElement;
var barWidth = this.isWidthOverflow ? this.scrollbarWidth : 0;
var affixedLeftBorder = this.bordered && !this.isIE ? 1 : 0;
var marginScrollbarWidth = barWidth;
if (this.bordered) {
marginScrollbarWidth += 1;
}
var isVirtual = this.virtualConfig.isVirtualScroll.value;
var affixedFooter = Boolean(this.footerAffixedBottom && ((_this$footData = this.footData) === null || _this$footData === void 0 ? void 0 : _this$footData.length) && this.tableWidth) && h(affix_index.Affix, helper.helper([{
"class": this.tableBaseClass.affixedFooterWrap,
"on": {
"fixedChange": this.onFixedChange
},
"attrs": {
"offsetBottom": marginScrollbarWidth || 0
}
}, {
"props": table_utils.getAffixProps(this.footerAffixedBottom, this.footerAffixProps)
}, {
"style": {
marginTop: "".concat(-1 * (this.tableFootHeight + marginScrollbarWidth), "px")
},
"ref": "footerBottomAffixRef"
}]), [h("div", {
"ref": "affixFooterRef",
"style": {
width: "".concat(this.tableWidth - affixedLeftBorder, "px"),
opacity: Number(this.showAffixFooter)
},
"class": ["scrollbar", _defineProperty__default["default"]({}, this.tableBaseClass.affixedFooterElm, this.footerAffixedBottom || isVirtual)]
}, [h("table", {
"class": this.tableElmClasses,
"style": _objectSpread(_objectSpread({}, this.tableElementStyles), {}, {
width: "".concat(this.tableElmWidth, "px")
})
}, [this.renderColGroup(columns, true), h(table_tfoot["default"], {
"attrs": {
"rowKey": this.rowKey,
"isFixedHeader": this.isFixedHeader,
"rowAndColFixedPosition": this.rowAndColFixedPosition,
"footData": this.footData,
"columns": columns,
"rowAttributes": this.rowAttributes,
"rowClassName": this.rowClassName,
"thWidthList": this.thWidthList,
"footerSummary": this.footerSummary,
"rowspanAndColspanInFooter": this.rowspanAndColspanInFooter
},
"scopedSlots": this.$scopedSlots
})])])]);
return affixedFooter;
},
renderAffixedHeader: function renderAffixedHeader(columns) {
var h = this.$createElement;
if (!table_baseTableProps["default"].showHeader) return null;
return !!(this.virtualConfig.isVirtualScroll.value || this.headerAffixedTop) && (this.headerAffixedTop ? h(affix_index.Affix, helper.helper([{
"attrs": {
"offsetTop": 0
}
}, {
"props": table_utils.getAffixProps(this.headerAffixedTop, this.headerAffixProps)
}, {
"on": {
"fixedChange": this.onFixedChange
},
"ref": "headerTopAffixRef"
}]), [this.renderFixedHeader(columns)]) : this.isFixedHeader && this.renderFixedHeader(columns));
}
},
render: function render(h) {
var _this$spansAndLeafNod,
_this2 = this,
_this$tableContentRef;
if (!this.showElement) {
return h("div", {
"ref": "tableRef"
});
}
var rowAndColFixedPosition = this.rowAndColFixedPosition;
var data = this.isPaginateData ? this.dataSource : this.data;
var columns = ((_this$spansAndLeafNod = this.spansAndLeafNodes) === null || _this$spansAndLeafNod === void 0 ? void 0 : _this$spansAndLeafNod.leafColumns) || this.columns;
if (this.allowResizeColumnWidth) {
_common_js_log_log["default"].warn("Table", "allowResizeColumnWidth is going to be deprecated, please use resizable instead.");
}
if (this.columnResizable && this.tableLayout === "auto") {
_common_js_log_log["default"].warn("Table", "table-layout can not be `auto`, cause you are using column resizable, set `table-layout: fixed` please.");
}
var translate = "translate(0, ".concat(this.virtualConfig.scrollHeight.value, "px)");
var virtualStyle = {
transform: translate,
"-ms-transform": translate,
"-moz-transform": translate,
"-webkit-transform": translate
};
var tableBodyProps = _objectSpread(_objectSpread({
rowAndColFixedPosition: rowAndColFixedPosition,
showColumnShadow: this.showColumnShadow,
thDraggable: this.thDraggable,
data: this.virtualConfig.isVirtualScroll.value ? this.virtualConfig.visibleData.value : data,
virtualConfig: this.virtualConfig,
columns: columns,
tableElm: this.tableRef,
tableContentElm: this.tableContentRef,
tableWidth: this.tableWidth,
isWidthOverflow: this.isWidthOverflow,
scroll: this.scroll,
cellEmptyContent: this.cellEmptyContent,
classPrefix: this.classPrefix,
handleRowMounted: this.virtualConfig.handleRowMounted,
renderExpandedRow: this.renderExpandedRow
}, pick.pick(this.$props, table_tbody.extendTableProps)), {}, {
pagination: this.innerPagination,
attach: this.attach,
hoverRow: this.hoverRow,
activeRow: this.tActiveRow,
onRowClick: this.onInnerRowClick
});
var tBodyListener = this.getListener();
var tableContent = h("div", helper.helper([{
"ref": "tableContentRef",
"key": "table-content",
"class": this.tableBaseClass.content,
"style": this.tableContentStyles
}, {
"on": {
scroll: this.onInnerVirtualScroll
}
}]), [this.virtualConfig.isVirtualScroll.value && h("div", {
"class": this.virtualScrollClasses.cursor,
"style": virtualStyle
}), h("table", {
"ref": "tableElmRef",
"class": this.tableElmClasses,
"style": _objectSpread(_objectSpread({}, this.tableElementStyles), {}, {
width: this.resizable && this.isWidthOverflow && this.tableElmWidth ? "".concat(this.tableElmWidth, "px") : this.tableElementStyles.width
})
}, [this.renderColGroup(columns, false), this.showHeader && h(table_thead["default"], helper.helper([{
"scopedSlots": this.$scopedSlots
}, {
"props": this.getHeadProps(false)
}])), h(table_tbody["default"], helper.helper([{
"ref": "tableBodyRef",
"scopedSlots": this.$scopedSlots
}, {
"props": tableBodyProps
}, {}, {
"on": tBodyListener
}])), h(table_tfoot["default"], {
"attrs": {
"rowKey": this.rowKey,
"isFixedHeader": this.isFixedHeader,
"rowAndColFixedPosition": rowAndColFixedPosition,
"footData": this.footData,
"columns": columns,
"rowAttributes": this.rowAttributes,
"rowClassName": this.rowClassName,
"footerSummary": this.footerSummary,
"rowspanAndColspanInFooter": this.rowspanAndColspanInFooter
},
"scopedSlots": this.$scopedSlots
})])]);
var getCustomLoadingText = isFunction.isFunction(this.loading) ? this.loading : this.$scopedSlots.loading;
var loadingContent = this.loading !== void 0 && h(loading_index.Loading, helper.helper([{
"key": "loading",
"attrs": {
"loading": !!this.loading,
"text": getCustomLoadingText,
"attach": this.tableRef ? function () {
return _this2.tableRef;
} : void 0,
"showOverlay": true
}
}, {
"props": _objectSpread({
size: "small"
}, this.loadingProps)
}]));
var topContent = utils_renderTnode.renderTNodeJSX(this, "topContent");
var bottomContent = utils_renderTnode.renderTNodeJSX(this, "bottomContent");
var paginationContent = this.innerPagination ? h("div", {
"ref": "paginationRef",
"class": this.tableBaseClass.paginationWrap,
"style": {
opacity: Number(this.showAffixPagination)
}
}, [this.renderPagination(h)]) : null;
var bottom = !!bottomContent && h("div", {
"ref": "bottomContentRef",
"class": this.tableBaseClass.bottomContent
}, [bottomContent]);
return h("div", {
"ref": "tableRef",
"attrs": {
"tabindex": this.tableRefTabIndex
},
"class": this.dynamicBaseTableClasses,
"on": {
"focus": this.onTableFocus,
"blur": this.onTableBlur
}
}, [!!topContent && h("div", {
"class": this.tableBaseClass.topContent
}, [topContent]), this.renderAffixedHeader(columns), tableContent, this.renderAffixedFooter(columns), loadingContent, bottom, this.showRightDivider && h("div", {
"key": "right-divider",
"class": this.tableBaseClass.scrollbarDivider,
"style": {
right: "".concat(this.scrollbarWidth, "px"),
bottom: this.dividerBottom ? "".concat(this.dividerBottom, "px") : void 0,
height: "".concat((_this$tableContentRef = this.tableContentRef) === null || _this$tableContentRef === void 0 ? void 0 : _this$tableContentRef.getBoundingClientRect().height, "px")
}
}), this.horizontalScrollAffixedBottom && h(affix_index.Affix, helper.helper([{
"attrs": {
"offsetBottom": 0
}
}, {
"props": table_utils.getAffixProps(this.horizontalScrollAffixedBottom)
}, {
"style": this.showAffixFooter ? {
marginTop: "-".concat(this.scrollbarWidth * 2, "px")
} : {
"float": "right",
visibility: "hidden"
},
"ref": "horizontalScrollAffixRef"
}]), [h("div", {
"ref": "horizontalScrollbarRef",
"class": ["scrollbar", this.tableBaseClass.obviousScrollbar],
"style": {
width: "".concat(this.tableWidth, "px"),
overflow: "auto",
opacity: Number(this.showAffixFooter)
}
}, [h("div", {
"style": {
width: "".concat(this.tableElmWidth, "px"),
height: "5px"
}
})])]), this.paginationAffixedBottom ? h(affix_index.Affix, helper.helper([{
"attrs": {
"offsetBottom": 0
}
}, {
"props": table_utils.getAffixProps(this.paginationAffixedBottom)
}, {
"ref": "paginationAffixRef"
}]), [paginationContent]) : paginationContent, h("div", {
"ref": "resizeLineRef",
"class": this.tableBaseClass.resizeLine,
"style": this.resizeLineStyle
})]);
}
});
exports.BASE_TABLE_ALL_EVENTS = BASE_TABLE_ALL_EVENTS;
exports.BASE_TABLE_EVENTS = BASE_TABLE_EVENTS;
exports["default"] = _BaseTable;
//# sourceMappingURL=base-table.js.map