2022-11-14 03:59:26 +00:00
|
|
|
import { w as withInstall } from "../badge/index2.js";
|
|
|
|
import { defineComponent, ref, watch, computed, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, isRef } from "vue";
|
|
|
|
import { _ as _sfc_main$2 } from "../input/index2.js";
|
2023-11-03 03:48:11 +00:00
|
|
|
import { _ as _sfc_main$2W } from "../_chunks/@layui/index.js";
|
2022-11-14 03:59:26 +00:00
|
|
|
import { _ as _sfc_main$1 } from "../button/index2.js";
|
|
|
|
import "../dropdownMenu/index2.js";
|
|
|
|
var index = /* @__PURE__ */ (() => ":root{--button-primary-text-color: #fff;--button-primary-background-color: var(--global-primary-color);--button-primary-border-color: var(--global-primary-color);--button-normal-text-color: #fff;--button-normal-background-color: var(--global-normal-color);--button-normal-border-color: var(--global-normal-color);--button-warm-text-color: #fff;--button-warm-background-color: var(--global-warm-color);--button-warm-border-color: var(--global-warm-color);--button-danger-text-color: #fff;--button-danger-background-color: var(--global-danger-color);--button-danger-border-color: var(--global-danger-color);--button-border-radius: var(--global-border-radius);--button-border-color: var(--global-neutral-color-6);--button-background-color: 0 0;--button-text-color: #666}.layui-btn{height:38px;line-height:36px;padding:0 18px;font-size:14px;text-align:center;white-space:nowrap;color:var(--button-text-color);background:var(--button-background-color);border-radius:var(--button-border-radius);border-color:var(--button-border-color);border-width:1px;border-style:solid;cursor:pointer}.layui-btn-primary{color:var(--button-primary-text-color);background-color:var(--button-primary-background-color);border-color:var(--button-primary-border-color)}.layui-btn-normal{color:var(--button-normal-text-color);background-color:var(--button-normal-background-color);border-color:var(--button-normal-border-color)}.layui-btn-warm{color:var(--button-warm-text-color);background-color:var(--button-warm-background-color);border-color:var(--button-warm-border-color)}.layui-btn-danger{color:var(--button-danger-text-color);background-color:var(--button-danger-background-color);border-color:var(--button-danger-border-color)}.layui-btn:hover{opacity:.8;filter:alpha(opacity=80)}.layui-btn:active{opacity:1;filter:alpha(opacity=100)}.layui-btn-lg{height:44px;line-height:44px;padding:0 25px;font-size:16px}.layui-btn-sm{height:30px;line-height:30px;padding:0 10px;font-size:12px}.layui-btn-xs{height:22px;line-height:22px;padding:0 5px;font-size:12px}.layui-btn-xs i{font-size:12px!important}.layui-btn-fluid{width:100%}.layui-btn-radius{border-radius:100px}.layui-btn-disabled,.layui-btn-disabled:active,.layui-btn-disabled:hover{border-color:#eee!important;background-color:#fbfbfb!important;color:#d2d2d2!important;cursor:not-allowed!important;opacity:1}.layui-btn+.layui-btn{margin-left:10px}.layui-btn .layui-icon{padding:0 2px;vertical-align:middle\\ ;vertical-align:bottom}:root{--input-border-radius: var(--global-border-radius);--input-border-color: var(--global-neutral-color-3)}.layui-input{width:100%;height:38px;line-height:38px;border-width:1px;border-style:solid;border-color:var(--input-border-color);border-radius:var(--input-border-radius);display:inline-flex}.layui-input input{height:38px;line-height:38px;background-color:#fff;color:#000000d9;padding-left:10px;display:inline-block;border:none;height:100%;width:100%}.layui-input-append{background-color:#fafafa;border-left:1px solid var(--input-border-color);display:flex;padding:0 15px;flex:none;align-items:center}.layui-input-prepend{background-color:#fafafa;border-right:1px solid var(--input-border-color);display:flex;padding:0 15px;flex:none;align-items:center}.layui-input-wrapper{width:100%;display:inline-flex;border:none}.layui-input:hover,.layui-input:focus-within{border-color:#d2d2d2}.layui-input-clear,.layui-input-prefix,.layui-input-suffix,.layui-input-password{background-color:#fff}.layui-input-clear,.layui-input-password,.layui-input-prefix,.layui-input-suffix{display:flex;flex:none;align-items:center;padding:0 10px}.layui-input-has-prefix input{padding:0}.layui-input-clear,.layui-input-password{color:#00000073}.layui-input-clear:hover{opacity:.6}.layui-input input::-webkit-input-placeholder{line-height:1.3}.layui-input input::-ms-reveal{display:none}.layui-input-disabled{border-color:var(--input-border-color)!important}.layui-input-disabled{opacity:.6}.layui-input-disabled,.layui-input-disabled *{cursor:not-allowed!important}.layui-input[size=lg]{height:44px}.layui-input[s
|
|
|
|
function add(arg1, arg2) {
|
|
|
|
var r1, r2, m, c;
|
|
|
|
try {
|
|
|
|
r1 = arg1.toString().split(".")[1].length;
|
|
|
|
} catch (e) {
|
|
|
|
r1 = 0;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
r2 = arg2.toString().split(".")[1].length;
|
|
|
|
} catch (e) {
|
|
|
|
r2 = 0;
|
|
|
|
}
|
|
|
|
c = Math.abs(r1 - r2);
|
|
|
|
m = Math.pow(10, Math.max(r1, r2));
|
|
|
|
if (c > 0) {
|
|
|
|
var cm = Math.pow(10, c);
|
|
|
|
if (r1 > r2) {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
|
arg2 = Number(arg2.toString().replace(".", "")) * cm;
|
|
|
|
} else {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", "")) * cm;
|
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
|
}
|
|
|
|
return (arg1 + arg2) / m;
|
|
|
|
}
|
|
|
|
function sub(arg1, arg2) {
|
|
|
|
var r1, r2, m, c;
|
|
|
|
try {
|
|
|
|
r1 = arg1.toString().split(".")[1].length;
|
|
|
|
} catch (e) {
|
|
|
|
r1 = 0;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
r2 = arg2.toString().split(".")[1].length;
|
|
|
|
} catch (e) {
|
|
|
|
r2 = 0;
|
|
|
|
}
|
|
|
|
c = Math.abs(r1 - r2);
|
|
|
|
m = Math.pow(10, Math.max(r1, r2));
|
|
|
|
if (c > 0) {
|
|
|
|
var cm = Math.pow(10, c);
|
|
|
|
if (r1 > r2) {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
|
arg2 = Number(arg2.toString().replace(".", "")) * cm;
|
|
|
|
} else {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", "")) * cm;
|
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
|
}
|
|
|
|
return (arg1 - arg2) / m;
|
|
|
|
}
|
|
|
|
const _hoisted_1 = ["position", "size"];
|
|
|
|
const _hoisted_2 = { class: "layui-input-number-input" };
|
|
|
|
const __default__ = {
|
|
|
|
name: "LayInputNumber"
|
|
|
|
};
|
|
|
|
const _sfc_main = defineComponent({
|
|
|
|
...__default__,
|
|
|
|
props: {
|
|
|
|
modelValue: { default: 0 },
|
|
|
|
name: null,
|
|
|
|
disabled: { type: Boolean, default: false },
|
|
|
|
disabledInput: { type: Boolean, default: false },
|
|
|
|
size: { default: "md" },
|
|
|
|
step: { default: 1 },
|
|
|
|
position: null,
|
|
|
|
min: { default: -Infinity },
|
|
|
|
max: { default: Infinity }
|
|
|
|
},
|
|
|
|
emits: ["update:modelValue", "change"],
|
|
|
|
setup(__props, { emit }) {
|
|
|
|
const props = __props;
|
|
|
|
let num = ref(props.modelValue);
|
|
|
|
watch(num, (val) => {
|
|
|
|
if (props.max !== Infinity && val > props.max) {
|
|
|
|
num.value = props.max;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (props.min !== -Infinity && val < props.min) {
|
|
|
|
num.value = props.min;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isNumber(num.value)) {
|
|
|
|
tempValue.value = Number(num.value);
|
|
|
|
emit("update:modelValue", tempValue.value);
|
|
|
|
emit("change", tempValue.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
watch(() => props.modelValue, (val) => {
|
|
|
|
if (val !== num.value) {
|
|
|
|
num.value = props.modelValue;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
let timer = 0;
|
|
|
|
const tempValue = ref(0);
|
|
|
|
const minControl = computed(() => {
|
|
|
|
if (props.disabled) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (props.min !== -Infinity) {
|
|
|
|
return Number(props.min) >= num.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const maxControl = computed(() => {
|
|
|
|
if (props.disabled) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (props.max !== Infinity) {
|
|
|
|
return Number(props.max) <= num.value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const addition = function() {
|
|
|
|
num.value = add(num.value, props.step);
|
|
|
|
};
|
|
|
|
const subtraction = function() {
|
|
|
|
num.value = sub(num.value, props.step);
|
|
|
|
};
|
|
|
|
const longDown = function(fn) {
|
|
|
|
cancelLongDown();
|
|
|
|
if (props.disabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
timer = setInterval(() => fn.call(timer), 150);
|
|
|
|
fn.call(timer);
|
|
|
|
};
|
|
|
|
const cancelLongDown = function() {
|
|
|
|
clearInterval(timer);
|
|
|
|
};
|
|
|
|
const inputChange = function() {
|
|
|
|
if (isNumber(num.value)) {
|
|
|
|
tempValue.value = Number(num.value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
num.value = tempValue.value;
|
|
|
|
};
|
|
|
|
const isNumber = function(num2) {
|
|
|
|
return !isNaN(num2);
|
|
|
|
};
|
|
|
|
return (_ctx, _cache) => {
|
|
|
|
return openBlock(), createElementBlock("div", {
|
|
|
|
class: "layui-input-number",
|
|
|
|
position: __props.position,
|
|
|
|
size: __props.size
|
|
|
|
}, [
|
|
|
|
createVNode(_sfc_main$1, {
|
|
|
|
size: "lg",
|
|
|
|
onMouseup: cancelLongDown,
|
|
|
|
onMousedown: _cache[0] || (_cache[0] = ($event) => longDown(subtraction)),
|
|
|
|
onBlur: cancelLongDown,
|
|
|
|
disabled: unref(minControl),
|
|
|
|
class: "layui-control-btn layui-subtraction-btn"
|
|
|
|
}, {
|
|
|
|
default: withCtx(() => [
|
2023-11-03 03:48:11 +00:00
|
|
|
createVNode(unref(_sfc_main$2W), {
|
2022-11-14 03:59:26 +00:00
|
|
|
type: __props.position === "right" ? "layui-icon-down" : "layui-icon-subtraction"
|
|
|
|
}, null, 8, ["type"])
|
|
|
|
]),
|
|
|
|
_: 1
|
|
|
|
}, 8, ["disabled"]),
|
|
|
|
createElementVNode("div", _hoisted_2, [
|
|
|
|
createVNode(_sfc_main$2, {
|
|
|
|
max: __props.max,
|
|
|
|
min: __props.min,
|
|
|
|
name: __props.name,
|
|
|
|
modelValue: unref(num),
|
|
|
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(num) ? num.value = $event : num = $event),
|
|
|
|
readonly: __props.disabledInput || __props.disabled,
|
|
|
|
disabled: __props.disabledInput || __props.disabled,
|
|
|
|
onInput: inputChange,
|
|
|
|
type: "number"
|
|
|
|
}, null, 8, ["max", "min", "name", "modelValue", "readonly", "disabled"])
|
|
|
|
]),
|
|
|
|
createVNode(_sfc_main$1, {
|
|
|
|
size: "lg",
|
|
|
|
onMouseup: cancelLongDown,
|
|
|
|
onMousedown: _cache[2] || (_cache[2] = ($event) => longDown(addition)),
|
|
|
|
onBlur: cancelLongDown,
|
|
|
|
disabled: unref(maxControl),
|
|
|
|
class: "layui-control-btn layui-addition-btn"
|
|
|
|
}, {
|
|
|
|
default: withCtx(() => [
|
2023-11-03 03:48:11 +00:00
|
|
|
createVNode(unref(_sfc_main$2W), {
|
2022-11-14 03:59:26 +00:00
|
|
|
type: __props.position === "right" ? "layui-icon-up" : "layui-icon-addition"
|
|
|
|
}, null, 8, ["type"])
|
|
|
|
]),
|
|
|
|
_: 1
|
|
|
|
}, 8, ["disabled"])
|
|
|
|
], 8, _hoisted_1);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const component = withInstall(_sfc_main);
|
|
|
|
export { component as default };
|