tav-ui
Version:
92 lines (89 loc) • 3.7 kB
JavaScript
import { defineComponent, reactive, computed, watch, toRefs, resolveComponent, openBlock, createElementBlock, normalizeClass, createVNode, withCtx, mergeProps, createElementVNode, toDisplayString } from 'vue';
import { FormItem, InputNumber } from 'ant-design-vue';
import { useMessage } from '../../../hooks/web/useMessage2.mjs';
import { inputNumberRangeProps, inputNumberRangeEmits } from './types2.mjs';
import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs';
const { createMessage } = useMessage();
const _sfc_main = defineComponent({
name: "TaInputNumberRange",
components: {
FormItem,
InputNumber
},
props: inputNumberRangeProps,
emits: inputNumberRangeEmits,
setup(props, { emit }) {
const initPropsValue = props.value ? props.value.slice(0) : [];
const state = reactive({
min: initPropsValue[0],
max: initPropsValue[1]
});
const minCompProps = computed(() => ({
...props.minProps,
min: props.min ? props.min : props.minProps.min,
max: props.max ? props.max : props.minProps.max || Infinity,
placeholder: props.minPlaceHolder ? props.minPlaceHolder : props.minProps.placeholder
}));
const maxCompProps = computed(() => ({
...props.maxProps,
min: props.min ? props.min : props.maxProps.min,
max: props.max ? props.max : props.maxProps.max || Infinity,
placeholder: props.maxPlaceHolder ? props.maxPlaceHolder : props.maxProps.placeholder
}));
const changeHandle = (value) => {
emit("change", [state.min, state.max]);
};
watch(() => props.value, (newValue) => {
const nextValue = newValue ? newValue.slice(0) : [];
state.min = nextValue[0];
state.max = nextValue[1];
}, {
deep: true
});
return {
minCompProps,
maxCompProps,
changeHandle,
...toRefs(state)
};
}
});
const _hoisted_1 = { class: "ta-input-number-range-prefix" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_InputNumber = resolveComponent("InputNumber");
const _component_FormItem = resolveComponent("FormItem");
return openBlock(), createElementBlock("div", {
class: normalizeClass(["ta-input-number-range", { disabled: _ctx.disabled }])
}, [
createVNode(_component_FormItem, null, {
default: withCtx(() => [
createVNode(_component_InputNumber, mergeProps({ ..._ctx.minCompProps }, {
value: _ctx.min,
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.min = $event),
size: _ctx.size,
disabled: _ctx.disabled,
precision: _ctx.precision,
onChange: _ctx.changeHandle
}), null, 16, ["value", "size", "disabled", "precision", "onChange"])
]),
_: 1
}),
createElementVNode("span", _hoisted_1, toDisplayString(_ctx.prefixCenter), 1),
createVNode(_component_FormItem, null, {
default: withCtx(() => [
createVNode(_component_InputNumber, mergeProps({ ..._ctx.maxCompProps }, {
value: _ctx.max,
"onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.max = $event),
size: _ctx.size,
disabled: _ctx.disabled,
precision: _ctx.precision,
onChange: _ctx.changeHandle
}), null, 16, ["value", "size", "disabled", "precision", "onChange"])
]),
_: 1
})
], 2);
}
var InputNumberRange = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/input-number-range/src/input-number-range.vue"]]);
export { InputNumberRange as default };
//# sourceMappingURL=input-number-range2.mjs.map