144 lines
3.1 KiB
Vue
144 lines
3.1 KiB
Vue
<template>
|
|
<div class="aksrt-field-group">
|
|
<div v-if="title" class="aksrt-field-group__header">
|
|
<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 v-if="$slots.actions" class="aksrt-field-group__actions">
|
|
<slot name="actions" />
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="collapsible" class="aksrt-field-group__toggle" @click="toggleCollapse">
|
|
<FaIcon
|
|
:icon="collapsed ? 'fas fa-chevron-right' : 'fas fa-chevron-down'"
|
|
:size="12"
|
|
class="aksrt-field-group__chevron"
|
|
/>
|
|
<span class="aksrt-field-group__toggle-text">
|
|
{{ collapsed ? '展开' : '收起' }}{{ title ? ` ${title}` : '' }}
|
|
</span>
|
|
</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.
|
|
*/
|
|
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() {
|
|
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;
|
|
}
|
|
|
|
.aksrt-field-group__header-left {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
}
|
|
|
|
.aksrt-field-group__icon {
|
|
color: #1890ff;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.aksrt-field-group__title {
|
|
margin: 0;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: #1a1a2e;
|
|
}
|
|
|
|
.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__toggle {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 20px;
|
|
cursor: pointer;
|
|
color: #8a909c;
|
|
font-size: 12px;
|
|
user-select: none;
|
|
transition: color 0.15s;
|
|
}
|
|
|
|
.aksrt-field-group__toggle:hover {
|
|
color: #1890ff;
|
|
}
|
|
|
|
.aksrt-field-group__chevron {
|
|
transition: transform 0.2s;
|
|
}
|
|
|
|
.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>
|