UNPKG

tdesign-vue

Version:
543 lines (535 loc) 20.5 kB
/** * 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 _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-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-3b2292ce.js'); require('../_chunks/dep-ba7f5924.js'); require('../_chunks/dep-10fcb46d.js'); require('../_chunks/dep-6eba4d23.js'); require('../_chunks/dep-010db548.js'); require('../_chunks/dep-8d206316.js'); require('../_chunks/dep-2bc87cc8.js'); require('../_chunks/dep-f77d6ad5.js'); require('../_chunks/dep-9dae8101.js'); require('../_chunks/dep-7c84d9a0.js'); require('../_chunks/dep-733a2279.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('@babel/runtime/helpers/slicedToArray'); require('../_chunks/dep-a2217d56.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('../utils/transfer-dom.js'); require('../loading/props.js'); require('../config.js'); require('@babel/runtime/helpers/toConsumableArray'); require('@babel/runtime/helpers/objectWithoutProperties'); require('../_chunks/dep-721fcdf6.js'); require('../_chunks/dep-591b87f1.js'); require('../_chunks/dep-268c68b1.js'); require('@babel/runtime/helpers/readOnlyError'); 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('../_chunks/dep-2c592e99.js'); require('../_chunks/dep-97fef2be.js'); require('../_chunks/dep-0b47afa3.js'); require('../_chunks/dep-d7516e38.js'); require('../_chunks/dep-74be1050.js'); require('../_chunks/dep-7fbd94e9.js'); require('../_chunks/dep-56f568d3.js'); require('../_chunks/dep-82ce56ef.js'); require('../_chunks/dep-4e96e31a.js'); require('../_chunks/dep-17ce3e74.js'); require('../_chunks/dep-a7198720.js'); require('../_chunks/dep-1e173c2b.js'); require('../_chunks/dep-c9ce9427.js'); require('../_chunks/dep-edb55477.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-812bd25d.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-ee4e645f.js'); require('../_chunks/dep-0ea9f257.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-d250e942.js'); require('../_chunks/dep-518e9c7b.js'); require('../_chunks/dep-a96e5563.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-993ef18d.js'); require('../_chunks/dep-f020448d.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('../_chunks/dep-da2ef9c3.js'); require('../select/hooks/useSelectOptions.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, 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); } } }, [h(PageFirstIcon)]) : null, this.showPreviousAndNextBtn ? h("div", { "class": this.preBtnClass, "on": { "click": this.prevPage } }, [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 } }, [h(ChevronRightIcon)]) : null, this.showFirstAndLastPageBtn ? h("div", { "class": this.nextBtnClass, "on": { "click": function click() { return _this2.toPage(_this2.pageCount); } } }, [h(PageLastIcon)]) : null, this.theme === "default" && this.showJumper && Jumper]); } }); exports["default"] = PaginationBase; //# sourceMappingURL=pagination.js.map