Hide channel config cards until enabled; open expanded on enable and allow manual collapse via group header.
181 lines
4.2 KiB
Vue
181 lines
4.2 KiB
Vue
<template>
|
|
<div class="aksrt-field-group" :class="{ 'is-collapsible': collapsible, 'is-collapsed': collapsible && collapsed }">
|
|
<div
|
|
v-if="title"
|
|
class="aksrt-field-group__header"
|
|
:class="{ 'is-clickable': collapsible }"
|
|
@click="collapsible ? toggleCollapse() : undefined"
|
|
>
|
|
<div class="aksrt-field-group__header-left">
|
|
<FaIcon v-if="icon" :icon="icon" :size="16" class="aksrt-field-group__icon" />
|
|
<div>
|
|
<h3 class="aksrt-field-group__title">{{ title }}</h3>
|
|
<p v-if="description" class="aksrt-field-group__desc">{{ description }}</p>
|
|
</div>
|
|
</div>
|
|
<div class="aksrt-field-group__header-right">
|
|
<div v-if="$slots.actions" class="aksrt-field-group__actions" @click.stop>
|
|
<slot name="actions" />
|
|
</div>
|
|
<button
|
|
v-if="collapsible"
|
|
type="button"
|
|
class="aksrt-field-group__collapse-btn"
|
|
:aria-expanded="(!collapsed).toString()"
|
|
:title="collapsed ? '展开配置' : '收起配置'"
|
|
@click.stop="toggleCollapse"
|
|
>
|
|
<FaIcon
|
|
:icon="collapsed ? 'fas fa-chevron-right' : 'fas fa-chevron-down'"
|
|
:size="12"
|
|
/>
|
|
<span>{{ collapsed ? '展开' : '收起' }}</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<transition name="aksrt-collapse">
|
|
<div v-show="!collapsed" class="aksrt-field-group__body">
|
|
<slot />
|
|
</div>
|
|
</transition>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
/**
|
|
* AksFieldGroup — card-style container for grouping related form fields.
|
|
* Supports collapsible sections, icon headers, and description text.
|
|
*
|
|
* defaultCollapsed only seeds initial state. Parent should remount the group
|
|
* (e.g. via :key when a channel turns on) if it wants to force expand again.
|
|
*/
|
|
import { ref } from 'vue'
|
|
import FaIcon from './FaIcon.vue'
|
|
|
|
const props = defineProps({
|
|
title: { type: String, default: '' },
|
|
description: { type: String, default: '' },
|
|
icon: { type: String, default: '' },
|
|
collapsible: { type: Boolean, default: false },
|
|
defaultCollapsed: { type: Boolean, default: false },
|
|
})
|
|
|
|
const collapsed = ref(!!props.defaultCollapsed)
|
|
|
|
function toggleCollapse() {
|
|
if (!props.collapsible) return
|
|
collapsed.value = !collapsed.value
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.aksrt-field-group {
|
|
margin-bottom: 20px;
|
|
border: 1px solid #eef1f6;
|
|
border-radius: 12px;
|
|
background: #fff;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.aksrt-field-group__header {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
justify-content: space-between;
|
|
padding: 18px 20px 0;
|
|
gap: 12px;
|
|
}
|
|
|
|
.aksrt-field-group__header.is-clickable {
|
|
cursor: pointer;
|
|
user-select: none;
|
|
}
|
|
|
|
.aksrt-field-group__header.is-clickable:hover .aksrt-field-group__title {
|
|
color: #1890ff;
|
|
}
|
|
|
|
.aksrt-field-group.is-collapsed .aksrt-field-group__header {
|
|
padding-bottom: 18px;
|
|
}
|
|
|
|
.aksrt-field-group__header-left {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.aksrt-field-group__header-right {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.aksrt-field-group__icon {
|
|
color: #1890ff;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.aksrt-field-group__title {
|
|
margin: 0;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: #1a1a2e;
|
|
transition: color 0.15s;
|
|
}
|
|
|
|
.aksrt-field-group__desc {
|
|
margin: 4px 0 0;
|
|
font-size: 12px;
|
|
color: #8a909c;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.aksrt-field-group__actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.aksrt-field-group__collapse-btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
border: 1px solid #e8ecf2;
|
|
background: #f7f9fc;
|
|
color: #5c6370;
|
|
border-radius: 999px;
|
|
padding: 4px 10px;
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
transition: color 0.15s, border-color 0.15s, background 0.15s;
|
|
}
|
|
|
|
.aksrt-field-group__collapse-btn:hover {
|
|
color: #1890ff;
|
|
border-color: #91caff;
|
|
background: #f0f7ff;
|
|
}
|
|
|
|
.aksrt-field-group__body {
|
|
padding: 16px 20px 20px;
|
|
}
|
|
|
|
/* Collapse transition */
|
|
.aksrt-collapse-enter-active,
|
|
.aksrt-collapse-leave-active {
|
|
transition: all 0.2s ease;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.aksrt-collapse-enter-from,
|
|
.aksrt-collapse-leave-to {
|
|
opacity: 0;
|
|
max-height: 0;
|
|
padding-top: 0;
|
|
padding-bottom: 0;
|
|
}
|
|
</style>
|