<script setup>
import StepPanel from "primevue/steppanel";
import {inject, onMounted, ref} from "vue";

const props = defineProps(["code"])

const numberValue = ref(0)

if (typeof props.code !== "string") {
	console.error("invalid or missing step panel code '" + props.code + "'")
}

onMounted(() => {
	const stepView = inject("$stepView")
	if (stepView != null) {
		const codeValue = stepView.exposed.getStepValue(props.code)
		if (typeof codeValue !== "number") {
			console.error("invalid or missing step panel code '" + props.code + "'")
			return
		}
		numberValue.value = codeValue
	}
})
</script>

<template>
	<StepPanel :value="numberValue.toString()">
		<slot></slot>
	</StepPanel>
</template>

<style scoped>

</style>