<script setup>

import {onMounted, ref} from "vue"
import TInputText from "@/components/ui/TInputText.vue";
import CodeLabel from "@/components/common/CodeLabel.vue";

const props = defineProps(["v-cond"])

const valueInputRef = ref()
const {cond} = (function () {
	let cond = {
		isRequest: true,
		param: "${requestPath}",
		operator: "eq",
		value: "",
		isCaseInsensitive: false
	}
	if (props.vCond != null && typeof props.vCond.value == "string") {
		cond.value = props.vCond.value
	}
	return {
		cond: ref(cond)
	}
})()

const changeCaseInsensitive = function (isCaseInsensitive) {
	cond.value.isCaseInsensitive = isCaseInsensitive
}

onMounted(() => {
	valueInputRef.value.focus()
})

defineExpose({
	changeCaseInsensitive
})

</script>

<template>
	<div>
		<input type="hidden" name="condJSON" :value="JSON.stringify(cond)"/>
		<TInputText type="text" v-model="cond.value" ref="valueInputRef" class="w-full"/>
		<p class="comment">完整的URL路径，通常以
			<CodeLabel>/</CodeLabel>
			开头，比如
			<CodeLabel>/static/ui.js</CodeLabel>
			，不需要带域名。
		</p>
	</div>
</template>

<style scoped>
</style>
