/**
* GnInput - Text input field with label, icon, state, and help text.
*
* @typedef {Object} GnInputProps
* @property {string|number} [modelValue=''] - Bound value
* @property {string} [label=''] - Label text
* @property {string} [type='text'] - input type attribute
* @property {string} [icon=''] - Phosphor icon name with ph- prefix (e.g. "ph-pencil-simple")
* @property {string} [state=''] - error | warning | success
* @property {string} [help=''] - Help or validation message
*
* @emits update:modelValue
*/
import { defineComponent, h } from "vue";
import { cx, eventValue, iconNode } from "../utils.js";
export default defineComponent({
name: "GnInput",
inheritAttrs: false,
props: {
modelValue: { type: [String, Number], default: "" },
label: { type: String, default: "" },
type: { type: String, default: "text" },
icon: { type: String, default: "" },
state: { type: String, default: "" },
help: { type: String, default: "" }
},
emits: ["update:modelValue"],
setup(props, { attrs, emit }) {
return () => h("div", { class: "form-group" }, [
h("label", { class: cx("label", props.state) }, [
props.label,
iconNode(props.icon),
h("input", {
...attrs,
type: props.type,
value: props.modelValue,
class: cx("input", attrs.class),
onInput: event => emit("update:modelValue", eventValue(event))
})
]),
props.help && h("div", { class: cx("input-info", props.state === "error" && "error") }, props.help)
]);
}
});