UNPKG

yanzhen-design-vue

Version:

83 lines (82 loc) 2.98 kB
import { defineComponent, computed, useSlots, ref, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, mergeProps, unref, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps, createTextVNode } from "vue"; import { sectionName, sectionProps, sectionEmits, sectionOptions } from "./section.mjs"; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: sectionName }, __name: "section", props: sectionProps, emits: sectionEmits, setup(__props, { expose: __expose, emit: __emit }) { const { class: wrapClass } = sectionOptions; const props = __props; const emit = __emit; const valueArray = computed(() => { const { value } = props; return value && value.includes(",") ? value.split(",") : [props.defaultValue, props.defaultValue]; }); const emitUpdateValue = (value) => { emit("update:value", value); emit("change", value); }; const handleUpdateValue1 = (value) => { const vValue = `${value},${valueArray.value[1] ?? ""}`; emitUpdateValue(vValue); }; const handleUpdateValue2 = (value) => { const vValue = `${valueArray.value[0] ?? ""},${value}`; emitUpdateValue(vValue); }; const slots = useSlots(); const slotKeys = Object.keys(slots); const _ref1 = ref(); const _ref2 = ref(); __expose({ ref1: _ref1, ref2: _ref2 }); return (_ctx, _cache) => { const _component_a_input_number = resolveComponent("a-input-number"); return openBlock(), createElementBlock(Fragment, null, [ createVNode(_component_a_input_number, mergeProps({ ref_key: "_ref1", ref: _ref1, class: [unref(wrapClass)], placeholder: "请输入" }, _ctx.$attrs, { value: valueArray.value[0], onChange: handleUpdateValue1 }), createSlots({ _: 2 }, [ renderList(unref(slotKeys), (slot) => { return { name: slot, fn: withCtx((slotItem) => [ renderSlot(_ctx.$slots, slot, normalizeProps(guardReactiveProps(slotItem))) ]) }; }) ]), 1040, ["class", "value"]), _cache[0] || (_cache[0] = createTextVNode(" ~ ")), createVNode(_component_a_input_number, mergeProps({ ref_key: "_ref2", ref: _ref2, class: [unref(wrapClass)], placeholder: "请输入" }, _ctx.$attrs, { value: valueArray.value[1], onChange: handleUpdateValue2 }), createSlots({ _: 2 }, [ renderList(unref(slotKeys), (slot) => { return { name: slot, fn: withCtx((slotItem) => [ renderSlot(_ctx.$slots, slot, normalizeProps(guardReactiveProps(slotItem))) ]) }; }) ]), 1040, ["class", "value"]) ], 64); }; } }); export { _sfc_main as default };