import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { t as Input_default } from "./input-CwDp-vE8.js";
import { t as FieldFrame_default } from "./field-frame-DhCOWcMP.js";
import { createBlock, createVNode, defineComponent, mergeModels, normalizeClass, onMounted, openBlock, unref, useModel, useTemplateRef, withCtx } from "vue";
//#region src/components/compositions/elements/input/NumberInput.vue?vue&type=script&setup=true&lang.ts
var NumberInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "NumberInput",
	props: /* @__PURE__ */ mergeModels({
		modelValue: {},
		id: {},
		name: {},
		label: {},
		hideLabel: { type: Boolean },
		placeholder: {},
		required: { type: Boolean },
		readonly: { type: Boolean },
		disabled: { type: Boolean },
		min: {},
		max: {},
		step: {},
		helpText: {},
		errors: { default: () => [] },
		autoFocus: { type: Boolean }
	}, {
		"modelValue": {},
		"modelModifiers": {}
	}),
	emits: ["update:modelValue"],
	setup(__props) {
		/**
		* Props-driven number input composition. Composes the shadcn `Input`
		* primitive (with `type="number"`) and `FieldFrame` chrome.
		*
		* Self-contained — usable directly in any Vue app:
		*
		*   <NumberInput v-model="age" label="Age" :min="0" :max="120" />
		*
		* The JSON-driven engine renders this via `ElementRenderer`, which
		* binds `modelValue` / `errors` to the form-data store automatically.
		*/
		const props = __props;
		const model = useModel(__props, "modelValue");
		const inputRef = useTemplateRef("inputRef");
		onMounted(() => {
			if (props.autoFocus) inputRef.value?.focus();
		});
		function onUpdate(raw) {
			if (raw === void 0 || raw === "" || raw === null) {
				model.value = null;
				return;
			}
			const num = typeof raw === "number" ? raw : Number(raw);
			model.value = Number.isFinite(num) ? num : null;
		}
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(FieldFrame_default), {
				label: __props.label,
				required: __props.required,
				"hide-label": __props.hideLabel,
				for: __props.id,
				"help-text": __props.helpText,
				errors: __props.errors
			}, {
				default: withCtx(() => [createVNode(unref(Input_default), {
					ref_key: "inputRef",
					ref: inputRef,
					"model-value": model.value ?? void 0,
					id: __props.id,
					name: __props.name ?? void 0,
					type: "number",
					placeholder: __props.placeholder ?? "",
					readonly: __props.readonly,
					disabled: __props.disabled,
					required: __props.required,
					min: __props.min,
					max: __props.max,
					step: __props.step,
					"data-element-name": __props.name ?? void 0,
					class: normalizeClass(__props.errors.length ? "border-destructive ring-destructive" : ""),
					"onUpdate:modelValue": onUpdate
				}, null, 8, [
					"model-value",
					"id",
					"name",
					"placeholder",
					"readonly",
					"disabled",
					"required",
					"min",
					"max",
					"step",
					"data-element-name",
					"class"
				])]),
				_: 1
			}, 8, [
				"label",
				"required",
				"hide-label",
				"for",
				"help-text",
				"errors"
			]);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/input/NumberInput.vue
var NumberInput_exports = /* @__PURE__ */ __exportAll({ default: () => NumberInput_default });
var NumberInput_default = NumberInput_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { NumberInput_exports as n, NumberInput_default as t };

//# sourceMappingURL=NumberInput-DMnysGiT.js.map