120 lines
4.4 KiB
JavaScript
120 lines
4.4 KiB
JavaScript
import { defineComponent, computed, mergeProps, unref, createSlots, withCtx, renderSlot, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderComponent, ssrRenderSlot } from 'vue/server-renderer';
|
|
import { u as usePrice } from './usePrice-_QzChhgO.mjs';
|
|
import { u as usePrefix } from './BasicIconOld-93vAWohq.mjs';
|
|
import { _ as __nuxt_component_0, I as Input } from './index-G65aBv4F.mjs';
|
|
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "BasicInput",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
title: {},
|
|
value: {},
|
|
size: {},
|
|
type: {},
|
|
isPassword: { type: Boolean, default: false },
|
|
inputmode: {},
|
|
disabled: { type: Boolean },
|
|
addonAfter: {},
|
|
addonBefore: {},
|
|
addonBgColor: {},
|
|
addonTextColor: {},
|
|
placeHolder: {}
|
|
},
|
|
emits: ["update:value", "onchange"],
|
|
setup(__props, { emit: __emit }) {
|
|
computed(() => props.addonBgColor);
|
|
computed(() => props.addonTextColor);
|
|
const localValue = computed({
|
|
set(value) {
|
|
props.type === "price" ? emits("update:value", value?.toString().replaceAll(",", "")) : emits("update:value", value);
|
|
},
|
|
get() {
|
|
let a = props.type === "price" ? props.value ? usePrice(props.value, true, "").trim() : "" : props.value;
|
|
return a;
|
|
}
|
|
});
|
|
const props = __props;
|
|
const emits = __emit;
|
|
const handlerChange = (e) => {
|
|
props.type === "price" ? emits("update:value", e.target.value?.toString().replaceAll(",", "")) : emits("update:value", e.target.value);
|
|
props.type === "price" ? emits("onchange", e.target.value?.toString().replaceAll(",", "")) : emits("onchange", e.target.value);
|
|
};
|
|
const { prefixCls } = usePrefix("input");
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _component_a_input_password = __nuxt_component_0;
|
|
const _component_a_input = Input;
|
|
_push(`<div${ssrRenderAttrs(mergeProps({
|
|
class: [unref(prefixCls)]
|
|
}, _attrs))}><div>${ssrInterpolate(props.title)}</div>`);
|
|
if (__props.isPassword) {
|
|
_push(ssrRenderComponent(_component_a_input_password, {
|
|
value: localValue.value,
|
|
"onUpdate:value": ($event) => localValue.value = $event,
|
|
"addon-after": props.addonAfter,
|
|
"addon-before": props.addonBefore,
|
|
disabled: props.disabled,
|
|
placeHolder: props.placeHolder,
|
|
size: props.size,
|
|
type: props.type,
|
|
class: "",
|
|
autocomplete: false,
|
|
onChange: handlerChange
|
|
}, null, _parent));
|
|
} else {
|
|
_push(ssrRenderComponent(_component_a_input, {
|
|
value: localValue.value,
|
|
"onUpdate:value": ($event) => localValue.value = $event,
|
|
"addon-after": props.addonAfter,
|
|
"addon-before": props.addonBefore,
|
|
disabled: props.disabled,
|
|
placeHolder: props.placeHolder,
|
|
size: props.size,
|
|
inputmode: props.inputmode,
|
|
autocomplete: false,
|
|
type: props.type === "price" ? "tel" : props.type,
|
|
class: "",
|
|
onChange: handlerChange
|
|
}, createSlots({ _: 2 }, [
|
|
_ctx.$slots.addonBefore ? {
|
|
name: "addonBefore",
|
|
fn: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
ssrRenderSlot(_ctx.$slots, "addonBefore", {}, null, _push2, _parent2, _scopeId);
|
|
} else {
|
|
return [
|
|
renderSlot(_ctx.$slots, "addonBefore")
|
|
];
|
|
}
|
|
}),
|
|
key: "0"
|
|
} : void 0,
|
|
_ctx.$slots.addonAfter ? {
|
|
name: "addonAfter",
|
|
fn: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
ssrRenderSlot(_ctx.$slots, "addonAfter", {}, null, _push2, _parent2, _scopeId);
|
|
} else {
|
|
return [
|
|
renderSlot(_ctx.$slots, "addonAfter")
|
|
];
|
|
}
|
|
}),
|
|
key: "1"
|
|
} : void 0
|
|
]), _parent));
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/BasicPacks/BasicInput.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
const BasicInput = Object.assign(_sfc_main, { __name: "BasicPacksBasicInput" });
|
|
|
|
export { BasicInput as B };
|