Newer
Older
vmk-ui-kit / src / vue / components / GnTextarea.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 2 days ago 1 KB Add Select, Textarea, and Card components
import { defineComponent, h } from "vue";
import { cx, eventValue, iconNode, normalizeInputState } from "../utils.js";

export default defineComponent({
	name: "GnTextarea",
	inheritAttrs: false,
	props: {
		modelValue: { type: String, default: "" },
		label: { type: String, default: "" },
		icon: { type: String, default: "" },
		state: { type: String, default: "" },
		help: { type: String, default: "" }
	},
	emits: ["update:modelValue"],
	setup(props, { attrs, emit }) {
		const state = normalizeInputState(props.state);

		return () => h("div", { class: cx("form-group", state) }, [
			props.label && h("label", { class: "label" }, [
				props.label,
				iconNode(props.icon),
				h("textarea", {
					...attrs,
					value: props.modelValue,
					class: cx("input", { "input-icon-left": props.icon }, attrs.class),
					onInput: event => emit("update:modelValue", eventValue(event))
				})
			]),
			!props.label && h("textarea", {
				...attrs,
				value: props.modelValue,
				class: cx("input", attrs.class),
				onInput: event => emit("update:modelValue", eventValue(event))
			}),
			props.help && h("p", { class: cx("input-help", state && `is-${state}`) }, props.help)
		]);
	}
});