birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
67 lines (66 loc) • 2.19 kB
JavaScript
;
const vue = require("vue");
const util = require("../../../utils/util.js");
const _hoisted_1 = {
key: 0,
class: "page-text"
};
const _hoisted_2 = {
key: 1,
class: "page-text"
};
const __default__ = vue.defineComponent({
name: "PaginationJumper"
});
const _sfc_main = /* @__PURE__ */ vue.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 = vue.ref();
const text = vue.reactive({ prefix: "", suffix: "" });
const handleBlur = () => {
let num = val.value ?? 1;
num < 1 && (num = 1);
num > props.pages && (num = props.pages);
emits("change", num);
};
vue.watchEffect(() => {
try {
const str = props.tmpString.split(paramsStr);
if (str.length > 1) {
text.prefix = str[0];
text.suffix = str[1];
}
} catch (error) {
util.warn("Pagination", "Split jumper paramsStr failure");
}
});
return (_ctx, _cache) => {
const _component_bp_input_number = vue.resolveComponent("bp-input-number");
return vue.openBlock(), vue.createElementBlock("li", {
class: vue.normalizeClass([`${name}-item`, `${name}-jumper`])
}, [
text.prefix ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(text.prefix), 1)) : vue.createCommentVNode("", true),
vue.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 ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_2, vue.toDisplayString(text.suffix), 1)) : vue.createCommentVNode("", true)
], 2);
};
}
});
module.exports = _sfc_main;