UNPKG

sci-pro

Version:
99 lines (98 loc) 3.58 kB
import { defineComponent as u, openBlock as t, createElementBlock as d, normalizeClass as y, renderSlot as r, createCommentVNode as s, createElementVNode as n } from "vue"; import "./style/index.css"; const f = { key: 0, class: "prepend" }, b = ["type", "value", "placeholder", "disabled", "readonly"], v = ["value", "placeholder", "disabled", "readonly", "rows"], g = /* @__PURE__ */ n("svg", { viewBox: "64 64 896 896", focusable: "false", fill: "currentColor", width: "1em", height: "1em", "data-icon": "close-circle", "aria-hidden": "true" }, [ /* @__PURE__ */ n("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" }) ], -1), $ = [ g ], V = { key: 4, class: "append" }, k = u({ name: "sci-input" }), w = /* @__PURE__ */ u({ ...k, props: { modelValue: {}, type: { default: "text" }, placeholder: { default: "Please input" }, disabled: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 }, clearable: { type: Boolean, default: !1 }, rows: { default: 1 } }, emits: ["update:modelValue", "change", "blur", "focus", "clear"], setup(h, { emit: p }) { const i = p, m = () => { i("update:modelValue", ""); }; return (e, l) => (t(), d("div", { class: y(["sci-input-wrapper", { "disabled-background": e.disabled, "sci-textarea": e.type == "textarea" }]), tabindex: "0" }, [ e.$slots.prepend && e.type != "textarea" ? (t(), d("div", f, [ r(e.$slots, "prepend") ])) : s("", !0), e.type != "textarea" ? (t(), d("input", { key: 1, class: "sci-input", type: e.type, value: e.modelValue, placeholder: e.placeholder, disabled: e.disabled, readonly: e.readonly, onInput: l[0] || (l[0] = (a) => { var o; return e.$emit("update:modelValue", (o = a.target) == null ? void 0 : o.value); }), onChange: l[1] || (l[1] = (a) => { var o; return e.$emit("change", (o = a.target) == null ? void 0 : o.value); }), onBlur: l[2] || (l[2] = (a) => e.$emit("blur", a)), onFocus: l[3] || (l[3] = (a) => e.$emit("focus", a)) }, null, 40, b)) : s("", !0), e.type == "textarea" ? (t(), d("textarea", { key: 2, value: e.modelValue, placeholder: e.placeholder, disabled: e.disabled, readonly: e.readonly, onInput: l[4] || (l[4] = (a) => { var o; return e.$emit("update:modelValue", (o = a.target) == null ? void 0 : o.value); }), onChange: l[5] || (l[5] = (a) => { var o; return e.$emit("change", (o = a.target) == null ? void 0 : o.value); }), onBlur: l[6] || (l[6] = (a) => e.$emit("blur", a)), onFocus: l[7] || (l[7] = (a) => e.$emit("focus", a)), rows: e.rows }, ` `, 40, v)) : s("", !0), e.modelValue && e.clearable && e.type != "textarea" ? (t(), d("i", { key: 3, class: "clear-icon", onClick: m }, $)) : s("", !0), e.$slots.append && e.type != "textarea" ? (t(), d("div", V, [ r(e.$slots, "append") ])) : s("", !0) ], 2)); } }); export { w as default };