<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import ctxRef from "@/utils/ctx_ref.js"
import Context from "./index.js"
import Menu from "./@menu.vue"
import PostForm from "@/components/form/PostForm.vue";
import TTextarea from "@/components/ui/TTextarea.vue";
import NSDomainGroupSelector from "@/components/ns/NSDomainGroupSelector.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import {ref} from "vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const namesInput = ref()
const groupSelector = ref()
const ctx = ctxRef(new Context(), {
	refs: {namesInput, groupSelector}
})

</script>

<template>
	<Menu :ctx="ctx"></Menu>

	<PostForm action="$" @success="ctx.success">
		<DefinitionTable>
			<tbody>
			<tr>
				<td class="title">域名 *</td>
				<td>
					<TTextarea rows="15" name="names" placeholder="每行一个域名" ref="namesInput" class="w-full"></TTextarea>
				</td>
			</tr>
			<tr v-if="ctx.hasGroups">
				<td>所属分组</td>
				<td>
					<NSDomainGroupSelector ref="groupSelector"></NSDomainGroupSelector>
				</td>
			</tr>
			</tbody>
		</DefinitionTable>
		<SubmitButton></SubmitButton>
	</PostForm>
</template>

<style lang="postcss" scoped>
</style>