UNPKG

@opensig/opendesign

Version:

<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>

102 lines (101 loc) 3.38 kB
"use strict"; const vue = require("vue"); const icons = require("../_utils/icons.js"); const _hoisted_1 = { class: "o-input-number-btn-wrap" }; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "NumberControl", props: { type: {}, addable: { type: Boolean }, reducible: { type: Boolean } }, emits: ["plus", "minus"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const onControlClick = (type, e) => { if (type === "plus" && props.addable) { emits("plus", e); } else if (type === "minus" && props.reducible) { emits("minus", e); } }; const isDisabledWhenNotBoth = () => { if (props.type === "plus") { return !props.addable; } else if (props.type === "minus") { return !props.reducible; } }; return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ props.type === "both" ? (vue.openBlock(), vue.createElementBlock( vue.Fragment, { key: 0 }, [ vue.createElementVNode( "div", { class: vue.normalizeClass(["o-input-number-btn", [ { "is-disabled": !props.addable }, `type-${props.type}` ]]), tabindex: "-1", onClick: _cache[0] || (_cache[0] = (e) => onControlClick("plus", e)) }, [ vue.renderSlot(_ctx.$slots, "plus", {}, () => [ vue.createVNode(vue.unref(icons.IconChevronUp), { class: "o-input-number-icon-plus" }) ]) ], 2 /* CLASS */ ), vue.createElementVNode( "div", { class: vue.normalizeClass(["o-input-number-btn minus", { "is-disabled": !props.reducible }]), tabindex: "-1", onClick: _cache[1] || (_cache[1] = (e) => onControlClick("minus", e)) }, [ vue.renderSlot(_ctx.$slots, "minus", {}, () => [ vue.createVNode(vue.unref(icons.IconChevronDown), { class: "o-input-number-icon-minus" }) ]) ], 2 /* CLASS */ ) ], 64 /* STABLE_FRAGMENT */ )) : (vue.openBlock(), vue.createElementBlock( "div", { key: 1, class: vue.normalizeClass(["o-input-number-btn", { "is-disabled": isDisabledWhenNotBoth() }]), tabindex: "-1", onClick: _cache[2] || (_cache[2] = (e) => onControlClick(props.type, e)) }, [ props.type === "plus" ? vue.renderSlot(_ctx.$slots, "plus", { key: 0 }, () => [ vue.createVNode(vue.unref(icons.IconAdd)) ]) : vue.createCommentVNode("v-if", true), props.type === "minus" ? vue.renderSlot(_ctx.$slots, "minus", { key: 1 }, () => [ vue.createVNode(vue.unref(icons.IconMinus)) ]) : vue.createCommentVNode("v-if", true) ], 2 /* CLASS */ )) ]); }; } }); module.exports = _sfc_main;