tdesign-vue
Version:
555 lines (547 loc) • 20.8 kB
JavaScript
/**
* tdesign v1.11.2
* (c) 2025 tdesign
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helper = require('../_chunks/dep-ece3c062.js');
var _typeof = require('@babel/runtime/helpers/typeof');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var tdesignIconsVue = require('tdesign-icons-vue');
var utils_mixins = require('../utils/mixins.js');
var configProvider_configReceiver = require('../config-provider/config-receiver.js');
var inputNumber_index = require('../input-number/index.js');
var select_index = require('../select/index.js');
var inputAdornment_index = require('../input-adornment/index.js');
var utils_renderTnode = require('../utils/render-tnode.js');
var pagination_props = require('./props.js');
var utils_event = require('../utils/event.js');
var _common_js_utils_helper = require('../_common/js/utils/helper.js');
require('vue');
require('../_chunks/dep-07fb8c0e.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-a4a18104.js');
require('../_chunks/dep-27dd8cc6.js');
require('dayjs');
require('../_chunks/dep-87c765cc.js');
require('../_chunks/dep-75cd6d52.js');
require('../_chunks/dep-b1a02818.js');
require('../_chunks/dep-3d8ab37d.js');
require('../_chunks/dep-ecccff93.js');
require('../_chunks/dep-a4308f57.js');
require('../_chunks/dep-a4cecac4.js');
require('../_chunks/dep-ab142eaf.js');
require('../_chunks/dep-6ad3de7c.js');
require('../_chunks/dep-e4278c54.js');
require('../_chunks/dep-fcf0662d.js');
require('../_chunks/dep-8b1e056e.js');
require('../_chunks/dep-5db8defc.js');
require('../_chunks/dep-6e4c473c.js');
require('../_chunks/dep-234b7c02.js');
require('../_chunks/dep-a4747856.js');
require('../_chunks/dep-932dd69e.js');
require('../_chunks/dep-9f4caea4.js');
require('../_chunks/dep-dbd838d6.js');
require('../_chunks/dep-b3120c1b.js');
require('../_chunks/dep-68ba2357.js');
require('../_chunks/dep-173eb46c.js');
require('@vue/composition-api');
require('../input-number/input-number.js');
require('../button/index.js');
require('../button/button.js');
require('../loading/index.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('../_common/js/utils/setStyle.js');
require('../utils/dom.js');
require('raf');
require('../utils/easing.js');
require('../_chunks/dep-738b4f21.js');
require('../utils/transfer-dom.js');
require('../loading/props.js');
require('../config.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-62de1188.js');
require('../_chunks/dep-867c284e.js');
require('../_chunks/dep-aa0a4aac.js');
require('@babel/runtime/helpers/readOnlyError');
require('../_chunks/dep-7c854ec6.js');
require('../_chunks/dep-eceed11d.js');
require('../_chunks/dep-201f7798.js');
require('../_chunks/dep-d3015b4c.js');
require('../_chunks/dep-f8a85d6a.js');
require('../_chunks/dep-5b117689.js');
require('../_chunks/dep-6478392e.js');
require('../_chunks/dep-47bca35e.js');
require('../_chunks/dep-013a3403.js');
require('../_chunks/dep-8cb0d589.js');
require('../_chunks/dep-d23147db.js');
require('../_chunks/dep-de60f5aa.js');
require('../_chunks/dep-63b02f7b.js');
require('../_chunks/dep-bebcd284.js');
require('../_chunks/dep-3eec664c.js');
require('../_chunks/dep-eeb2e214.js');
require('../_chunks/dep-315a67f0.js');
require('../_chunks/dep-f84d1ea5.js');
require('../_chunks/dep-362bc4d7.js');
require('../_chunks/dep-2e32c1f2.js');
require('../_chunks/dep-f14aac54.js');
require('../utils/withInstall.js');
require('../button/props.js');
require('../utils/ripple.js');
require('../input/index.js');
require('../input/input.js');
require('../utils/helper.js');
require('../input/props.js');
require('../_common/js/log/log.js');
require('../input/input-group.js');
require('../utils/map-props.js');
require('../input-number/props.js');
require('../input-number/useInputNumber.js');
require('../hooks/useCommonClassName.js');
require('../config-provider/useConfig.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/select.js');
require('../hooks/useDefaultValue.js');
require('../hooks/tnode.js');
require('../hooks/render-tnode.js');
require('../_chunks/dep-a6490a32.js');
require('../select/props.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../popup/props.js');
require('../popup/container.js');
require('../popup/utils.js');
require('../_chunks/dep-f3761329.js');
require('../_chunks/dep-848a5a32.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('../_chunks/dep-71fa6788.js');
require('../_chunks/dep-73fb598e.js');
require('../_chunks/dep-a9e7deb2.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('../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('../hooks/useElementLazyRender.js');
require('../_common/js/utils/observe.js');
require('../checkbox/checkbox-group-props.js');
require('../_chunks/dep-e83685df.js');
require('../_chunks/dep-502c56be.js');
require('../hooks/slots.js');
require('../hooks/useLazyLoad.js');
require('../select/util.js');
require('../_chunks/dep-f45125c9.js');
require('../_chunks/dep-f33eb57d.js');
require('../select/select-panel.js');
require('../select/optionGroup.js');
require('../select/option-group-props.js');
require('../hooks/useVirtualScroll.js');
require('../select/hooks/useSelectOptions.js');
require('../_chunks/dep-6dc0a916.js');
require('../_chunks/dep-b5c96567.js');
require('../input-adornment/input-adornment.js');
require('../input-adornment/props.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
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 min = 1;
var PaginationBase = utils_mixins["default"](configProvider_configReceiver["default"]("pagination"), configProvider_configReceiver.getGlobalIconMixins()).extend({
name: "TPagination",
components: {
TInputNumber: inputNumber_index.InputNumber,
TInputAdornment: inputAdornment_index.InputAdornment,
TSelect: select_index.Select,
TOption: select_index.Option
},
props: _objectSpread(_objectSpread({}, pagination_props["default"]), {}, {
current: {
type: Number,
"default": 1,
validator: function validator(v) {
return v > 0;
}
},
pageSize: {
type: Number,
"default": 10,
validator: function validator(v) {
return v > 0;
}
}
}),
data: function data() {
return {
prevMore: false,
nextMore: false,
jumpIndex: this.current
};
},
watch: {
current: function current(val) {
this.jumpIndex = val;
}
},
computed: {
paginationClass: function paginationClass() {
return ["".concat(this.componentName), this.commonSizeClassName[this.size], _defineProperty__default["default"](_defineProperty__default["default"]({}, this.commonStatusClassName.disabled, this.disabled), "".concat(this.componentName, "-ie"), _common_js_utils_helper.getIEVersion() < 11)];
},
totalClass: function totalClass() {
return ["".concat(this.componentName, "__total")];
},
sizerClass: function sizerClass() {
return ["".concat(this.componentName, "__select")];
},
preBtnClass: function preBtnClass() {
return ["".concat(this.componentName, "__btn"), "".concat(this.componentName, "__btn-prev"), _defineProperty__default["default"]({}, this.commonStatusClassName.disabled, this.disabled || this.current === 1)];
},
nextBtnClass: function nextBtnClass() {
return ["".concat(this.componentName, "__btn"), "".concat(this.componentName, "__btn-next"), _defineProperty__default["default"]({}, this.commonStatusClassName.disabled, this.disabled || this.current === this.pageCount)];
},
btnWrapClass: function btnWrapClass() {
return ["".concat(this.componentName, "__pager")];
},
btnMoreClass: function btnMoreClass() {
return ["".concat(this.componentName, "__number"), "".concat(this.componentName, "__number--more"), _defineProperty__default["default"]({}, this.commonStatusClassName.disabled, this.disabled)];
},
jumperClass: function jumperClass() {
return ["".concat(this.componentName, "__jump")];
},
jumperInputClass: function jumperInputClass() {
return ["".concat(this.componentName, "__input")];
},
pageCount: function pageCount() {
var c = Math.ceil(this.total / this.pageSize);
return c > 0 ? c : 1;
},
sizeOptions: function sizeOptions() {
var _this = this;
var options = this.pageSizeOptions.map(function (option) {
return _typeof__default["default"](option) === "object" ? option : {
label: _this.t(_this.global.itemsPerPage, {
size: option
}),
value: Number(option)
};
});
return options.sort(function (a, b) {
return a.value - b.value;
});
},
curPageLeftCount: function curPageLeftCount() {
return Math.ceil((this.foldedMaxPageBtn - 1) / 2);
},
curPageRightCount: function curPageRightCount() {
return Math.ceil((this.foldedMaxPageBtn - 1) / 2);
},
isPrevMoreShow: function isPrevMoreShow() {
return 2 + this.curPageLeftCount < this.current;
},
isNextMoreShow: function isNextMoreShow() {
return this.pageCount - 1 - this.curPageRightCount > this.current;
},
pages: function pages() {
var array = [];
var start;
var end;
if (this.isFolded) {
if (this.isPrevMoreShow && this.isNextMoreShow) {
start = this.current - this.curPageLeftCount;
end = this.current + this.curPageRightCount;
} else {
var foldedStart = this.isMidEllipsis ? 2 : 1;
var foldedEnd = this.isMidEllipsis ? this.pageCount - 1 : this.pageCount;
start = this.isPrevMoreShow ? this.pageCount - this.foldedMaxPageBtn + 1 : foldedStart;
end = this.isPrevMoreShow ? foldedEnd : this.foldedMaxPageBtn;
}
} else {
start = 1;
end = this.pageCount;
}
for (var i = start; i <= end; i++) {
array.push(i);
}
return array;
},
isFolded: function isFolded() {
return this.pageCount > this.maxPageBtn;
},
isMidEllipsis: function isMidEllipsis() {
return this.pageEllipsisMode === "mid";
}
},
methods: {
toPage: function toPage(pageIndex, isTriggerChange) {
if (this.disabled) {
return;
}
var current = pageIndex;
if (pageIndex < min) {
current = min;
} else if (pageIndex > this.pageCount) {
current = this.pageCount;
}
if (this.current !== current) {
var prev = this.current;
var pageInfo = {
current: current,
previous: prev,
pageSize: this.pageSize
};
utils_event.emitEvent(this, "current-change", current, pageInfo);
if (isTriggerChange !== false) {
utils_event.emitEvent(this, "change", pageInfo);
}
}
},
prevPage: function prevPage() {
this.toPage(this.current - 1);
},
nextPage: function nextPage() {
this.toPage(this.current + 1);
},
prevMorePage: function prevMorePage() {
this.toPage(this.current - this.foldedMaxPageBtn);
},
nextMorePage: function nextMorePage() {
this.toPage(this.current + this.foldedMaxPageBtn);
},
getButtonClass: function getButtonClass(index) {
return ["".concat(this.componentName, "__number"), _defineProperty__default["default"](_defineProperty__default["default"]({}, this.commonStatusClassName.disabled, this.disabled), this.commonStatusClassName.current, this.current === index)];
},
onSelectorChange: function onSelectorChange(e) {
if (this.disabled) {
return;
}
var pageSize = parseInt(e, 10);
var pageCount = 1;
if (pageSize > 0 && this.total > 0) {
pageCount = Math.ceil(this.total / pageSize);
}
var isIndexChange = false;
if (this.current > pageCount) {
isIndexChange = true;
}
var pageInfo = {
current: isIndexChange ? pageCount : this.current,
previous: this.current,
pageSize: pageSize
};
this.$emit("update:pageSize", pageSize, pageInfo);
utils_event.emitEvent(this, "page-size-change", pageSize, pageInfo);
utils_event.emitEvent(this, "change", pageInfo);
if (isIndexChange) {
this.toPage(pageCount, false);
}
},
onJumperChange: function onJumperChange(val) {
var currentIndex = Number(val);
if (isNaN(currentIndex)) return;
this.toPage(currentIndex);
}
},
render: function render() {
var _this2 = this;
var h = arguments[0];
var _this$useGlobalIcon = this.useGlobalIcon({
PageFirstIcon: tdesignIconsVue.PageFirstIcon,
PageLastIcon: tdesignIconsVue.PageLastIcon,
ChevronLeftIcon: tdesignIconsVue.ChevronLeftIcon,
ChevronRightIcon: tdesignIconsVue.ChevronRightIcon,
ChevronLeftDoubleIcon: tdesignIconsVue.ChevronLeftDoubleIcon,
ChevronRightDoubleIcon: tdesignIconsVue.ChevronRightDoubleIcon,
EllipsisIcon: tdesignIconsVue.EllipsisIcon
}),
PageFirstIcon = _this$useGlobalIcon.PageFirstIcon,
PageLastIcon = _this$useGlobalIcon.PageLastIcon,
ChevronLeftIcon = _this$useGlobalIcon.ChevronLeftIcon,
ChevronRightIcon = _this$useGlobalIcon.ChevronRightIcon,
ChevronLeftDoubleIcon = _this$useGlobalIcon.ChevronLeftDoubleIcon,
ChevronRightDoubleIcon = _this$useGlobalIcon.ChevronRightDoubleIcon,
EllipsisIcon = _this$useGlobalIcon.EllipsisIcon;
var Jumper = h("div", {
"class": this.jumperClass
}, [this.t(this.global.jumpTo), h("t-input-adornment", {
"attrs": {
"append": "/ ".concat(this.pageCount, " ").concat(this.t(this.global.page))
}
}, [h("t-input-number", {
"class": this.jumperInputClass,
"on": {
"blur": this.onJumperChange,
"enter": this.onJumperChange
},
"attrs": {
"max": this.pageCount,
"min": min,
"size": this.size,
"theme": "normal",
"placeholder": ""
},
"model": {
value: _this2.jumpIndex,
callback: function callback($$v) {
_this2.jumpIndex = $$v;
}
}
})])]);
return h("div", {
"class": this.paginationClass
}, [utils_renderTnode.renderTNodeJSX(this, "totalContent", h("div", {
"class": this.totalClass
}, [this.t(this.global.total, {
total: this.total
})])), this.showPageSize && this.pageSizeOptions.length ? h("t-select", helper.helper([{
"attrs": {
"size": this.size,
"value": this.pageSize,
"disabled": this.disabled,
"autoWidth": true
},
"class": this.sizerClass,
"on": {
"change": this.onSelectorChange
}
}, {
"props": this.selectProps || {}
}]), [this.sizeOptions.map(function (item, index) {
return h("t-option", {
"attrs": {
"value": item.value,
"label": item.label
},
"key": index
});
})]) : null, this.showFirstAndLastPageBtn ? h("div", {
"class": this.preBtnClass,
"on": {
"click": function click() {
return _this2.toPage(1);
}
},
"attrs": {
"disabled": this.disabled || this.current === min
}
}, [h(PageFirstIcon)]) : null, this.showPreviousAndNextBtn ? h("div", {
"class": this.preBtnClass,
"on": {
"click": this.prevPage
},
"attrs": {
"disabled": this.disabled || this.current === min
}
}, [h(ChevronLeftIcon)]) : null, this.showPageNumber && this.theme === "default" ? h("ul", {
"class": this.btnWrapClass
}, [this.isFolded && this.isMidEllipsis ? h("li", {
"class": this.getButtonClass(1),
"on": {
"click": function click() {
return _this2.toPage(min);
}
}
}, [min]) : null, this.isFolded && this.isPrevMoreShow && this.isMidEllipsis ? h("li", {
"class": this.btnMoreClass,
"on": {
"click": this.prevMorePage,
"mouseenter": function mouseenter() {
return _this2.prevMore = true;
},
"mouseleave": function mouseleave() {
return _this2.prevMore = false;
}
}
}, [this.prevMore ? h(ChevronLeftDoubleIcon) : h(EllipsisIcon)]) : null, this.pages.map(function (i) {
return h("li", {
"class": _this2.getButtonClass(i),
"key": i,
"on": {
"click": function click() {
return _this2.toPage(i);
}
}
}, [i]);
}), this.isFolded && this.isNextMoreShow && this.isMidEllipsis ? h("li", {
"class": this.btnMoreClass,
"on": {
"click": this.nextMorePage,
"mouseenter": function mouseenter() {
return _this2.nextMore = true;
},
"mouseleave": function mouseleave() {
return _this2.nextMore = false;
}
}
}, [this.nextMore ? h(ChevronRightDoubleIcon) : h(EllipsisIcon)]) : null, this.isFolded && this.isMidEllipsis ? h("li", {
"class": this.getButtonClass(this.pageCount),
"on": {
"click": function click() {
return _this2.toPage(_this2.pageCount);
}
}
}, [this.pageCount]) : null]) : null, this.theme === "simple" && Jumper, this.showPreviousAndNextBtn ? h("div", {
"class": this.nextBtnClass,
"on": {
"click": this.nextPage
},
"attrs": {
"disabled": this.disabled || this.current === this.pageCount
}
}, [h(ChevronRightIcon)]) : null, this.showFirstAndLastPageBtn ? h("div", {
"class": this.nextBtnClass,
"on": {
"click": function click() {
return _this2.toPage(_this2.pageCount);
}
},
"attrs": {
"disabled": this.disabled || this.current === this.pageCount
}
}, [h(PageLastIcon)]) : null, this.theme === "default" && this.showJumper && Jumper]);
}
});
exports["default"] = PaginationBase;
//# sourceMappingURL=pagination.js.map