UNPKG

tdesign-vue-next

Version:
131 lines (123 loc) 5.22 kB
/** * tdesign v1.20.2 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _typeof = require('@babel/runtime/helpers/typeof'); var isFunction = require('../../_chunks/dep-80827572.js'); var isObject = require('../../_chunks/dep-2c7a67b8.js'); var get = require('../../_chunks/dep-9b549c85.js'); require('../../_chunks/dep-2610df9f.js'); require('../../_chunks/dep-e25ae470.js'); require('../../_chunks/dep-959f4847.js'); require('../../_chunks/dep-5090b515.js'); require('../../_chunks/dep-6e64ef0e.js'); require('../../_chunks/dep-db6459dd.js'); require('../../_chunks/dep-4896d30f.js'); require('../../_chunks/dep-0a17438d.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof); function toString(obj) { return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); } function debounce(fn) { var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200; var timer; return function newFn() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var context = this; clearTimeout(timer); timer = setTimeout(function () { fn.apply(context, args); }, delay); }; } function formatRowAttributes(attributes, params) { if (!attributes) return void 0; var attrList = attributes instanceof Array ? attributes : [attributes]; var result = {}; for (var i = 0; i < attrList.length; i++) { var attrItem = attrList[i]; if (!attrItem) continue; var attrProperty = isFunction.isFunction(attrItem) ? attrItem(params) : attrItem; result = attrProperty instanceof Array ? formatRowAttributes(attrProperty, params) : Object.assign(result, attrProperty); } return result; } function formatRowClassNames(rowClassNames, params, rowKey) { var rowClassList = rowClassNames instanceof Array ? rowClassNames : [rowClassNames]; var row = params.row, rowIndex = params.rowIndex; var customClasses = []; for (var i = 0, len = rowClassList.length; i < len; i++) { var rName = rowClassList[i]; var tClass = isFunction.isFunction(rName) ? rName(params) : rName; if (isObject.isObject(tClass) && !(tClass instanceof Array)) { tClass[rowIndex] && (tClass = tClass[rowIndex]); var rowId = get.get(row, rowKey || "id"); tClass[rowId] && (tClass = tClass[rowId]); } else if (tClass instanceof Array) { tClass = formatRowClassNames(tClass, params, rowKey); } customClasses = customClasses.concat(tClass); } return customClasses; } function formatClassNames(classNames, params) { var classes = classNames instanceof Array ? classNames : [classNames]; var arr = []; for (var i = 0, len = classes.length; i < len; i++) { var cls = classes[i]; if (isFunction.isFunction(cls)) { arr.push(cls(params)); } else { arr.push(cls); } } return arr; } var INNER_PRE_NAME = "@@inner-"; function getCurrentRowByKey(columns, key) { if (!columns || !key) return; var col = columns === null || columns === void 0 ? void 0 : columns.find(function (t) { return t.colKey === key; }); if (col) return col; for (var i = 0, len = columns.length; i < len; i++) { var _columns$i; if ((_columns$i = columns[i]) !== null && _columns$i !== void 0 && (_columns$i = _columns$i.children) !== null && _columns$i !== void 0 && _columns$i.length) { var _columns$i2; return getCurrentRowByKey((_columns$i2 = columns[i]) === null || _columns$i2 === void 0 ? void 0 : _columns$i2.children, key); } } } function getLocalPaginationPageData(data, pagination, disableDataPage) { var _ref, _pagination$current, _ref2, _pagination$pageSize; if (!pagination) return data; var current = (_ref = (_pagination$current = pagination.current) !== null && _pagination$current !== void 0 ? _pagination$current : pagination.defaultCurrent) !== null && _ref !== void 0 ? _ref : 1; var pageSize = (_ref2 = (_pagination$pageSize = pagination.pageSize) !== null && _pagination$pageSize !== void 0 ? _pagination$pageSize : pagination.defaultPageSize) !== null && _ref2 !== void 0 ? _ref2 : 10; var shouldPaginate = !disableDataPage && data.length > pageSize; if (!shouldPaginate) return data; var start = (current - 1) * pageSize; var end = current * pageSize; return data.slice(start, end); } function getAffixProps(mainAffixProps, subAffixProps) { if (_typeof__default["default"](mainAffixProps) === "object") return mainAffixProps; if (_typeof__default["default"](subAffixProps) === "object") return subAffixProps; return {}; } exports.INNER_PRE_NAME = INNER_PRE_NAME; exports.debounce = debounce; exports.formatClassNames = formatClassNames; exports.formatRowAttributes = formatRowAttributes; exports.formatRowClassNames = formatRowClassNames; exports.getAffixProps = getAffixProps; exports.getCurrentRowByKey = getCurrentRowByKey; exports.getLocalPaginationPageData = getLocalPaginationPageData; exports.toString = toString; //# sourceMappingURL=index.js.map