UNPKG

birdpaper-ui

Version:

一个通用的 vue3 UI组件库。A common vue3 UI component library.

68 lines (67 loc) 2.26 kB
import { defineComponent, ref, reactive, watchEffect, resolveComponent, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createVNode } from "vue"; import { warn } from "../../../utils/util.js"; const _hoisted_1 = { key: 0, class: "page-text" }; const _hoisted_2 = { key: 1, class: "page-text" }; const __default__ = defineComponent({ name: "PaginationJumper" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { currentPage: { type: Number, default: 1 }, pages: { type: Number, default: 0 }, tmpString: { type: String, default: "前往{jumper}" } }, emits: ["change"], setup(__props, { emit: emits }) { const props = __props; const name = "bp-pagination"; const paramsStr = "{jumper}"; const val = ref(); const text = reactive({ prefix: "", suffix: "" }); const handleBlur = () => { let num = val.value ?? 1; num < 1 && (num = 1); num > props.pages && (num = props.pages); emits("change", num); }; watchEffect(() => { try { const str = props.tmpString.split(paramsStr); if (str.length > 1) { text.prefix = str[0]; text.suffix = str[1]; } } catch (error) { warn("Pagination", "Split jumper paramsStr failure"); } }); return (_ctx, _cache) => { const _component_bp_input_number = resolveComponent("bp-input-number"); return openBlock(), createElementBlock("li", { class: normalizeClass([`${name}-item`, `${name}-jumper`]) }, [ text.prefix ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(text.prefix), 1)) : createCommentVNode("", true), createVNode(_component_bp_input_number, { min: 1, precision: 0, "hide-button": "", modelValue: val.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => val.value = $event), size: "small", onBlur: handleBlur }, null, 8, ["modelValue"]), text.suffix ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(text.suffix), 1)) : createCommentVNode("", true) ], 2); }; } }); export { _sfc_main as default };