import { defineComponent, h } from "vue";
import { eventValue } from "../utils.js";

export default defineComponent({
	name: "GnRange",
	inheritAttrs: false,
	props: {
		modelValue: { type: [Number, String], default: 0 },
		label: { type: String, default: "" },
		min: { type: [Number, String], default: 0 },
		max: { type: [Number, String], default: 100 },
		step: { type: [Number, String], default: 1 }
	},
	emits: ["update:modelValue"],
	setup(props, { attrs, emit }) {
		return () => h("div", { class: "range" }, [
			h("label", { class: "label" }, [
				props.label,
				h("input", {
					...attrs,
					type: "range",
					value: props.modelValue,
					min: props.min,
					max: props.max,
					step: props.step,
					onInput: event => emit("update:modelValue", eventValue(event))
				})
			])
		]);
	}
});
