﻿# nf-resizable-panels {#resizable-panels}

可拖拽分隔面板，支持水平／垂直布局、最小尺寸和本地缓存。

导入组件后使用；单包安装方式见本包 README。

## 示例 {#examples}

### 基础用法 {#example-1}

### 基础用法
```vue
<script setup>
import { ref } from 'vue'
import { NfConfigProvider, NfResizablePanels } from '@94ai-plus/common-ui'
const resizes = ref(0)
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfResizablePanels cached unique="docs-row" :resize-min-width="80" style="height:160px" @resize="resizes++">
      <section style="flex:1">Left</section>
      <section style="flex:2">Right</section>
    </NfResizablePanels>
    <output>resize: {{ resizes }}</output>
  </NfConfigProvider>
</template>

<style scoped lang="scss">
.nf-resizable-panels section { padding: 16px; background: var(--el-fill-color-light); }
</style>
```

### 更多用法 2 {#example-2}

### 更多用法 2
```vue
<script setup>
import { NfConfigProvider, NfResizablePanels } from '@94ai-plus/common-ui'
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfResizablePanels drag-direction="column" symbol-mode="border" fill-seperator seperator-position="center" :seperator-size="8" :resize-min-width="40" divide-type="flex" style="height:240px">
      <section class="demo-panel" style="flex:1">Top</section>
      <section class="demo-panel demo-panel--accent" style="flex:1">Bottom</section>
      <template #seperator-symbol><span aria-hidden="true">⠿</span></template>
    </NfResizablePanels>
  </NfConfigProvider>
</template>

<style scoped>
.demo-panel {
  padding: 16px;
  background: var(--el-fill-color-light);
}
.demo-panel--accent {
  background: var(--el-color-primary-light-9);
}
</style>
```

### 更多用法 3 {#example-3}

### 更多用法 3
```vue
<script setup>
import { ref } from 'vue'
import { NfConfigProvider, NfResizablePanels, NfButton } from '@94ai-plus/common-ui'
const extra = ref(true)
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfButton @click="extra = !extra">Toggle panel</NfButton>
    <NfResizablePanels style="height:180px" :resize-min-width="40">
      <section class="demo-panel" style="flex:1">A</section>
      <NfResizablePanels drag-direction="column" style="flex:1">
        <section class="demo-panel demo-panel--accent" style="flex:1">B</section>
        <section class="demo-panel" style="flex:1">C</section>
      </NfResizablePanels>
      <section v-if="extra" class="demo-panel demo-panel--accent" style="flex:1">D</section>
    </NfResizablePanels>
  </NfConfigProvider>
</template>

<style scoped>
.demo-panel {
  padding: 16px;
  background: var(--el-fill-color-light);
}
.demo-panel--accent {
  background: var(--el-color-primary-light-9);
}
</style>
```

## 属性 {#props}

文案属性未传时跟随组件库当前语言；下表列出本语言的默认文案。

| 参数 | 说明 | 类型 | 可选值 | 默认值 |
| --- | --- | --- | --- | --- |
| `resizablePanelsContainerTag` | 指定容器标签类型。 | `string` | — | `'div'` |
| `seperatorSize` | 分割符号宽度，单位 px；0 使用主题默认尺寸。 | `number` | — | `0` |
| `fillSeperator` | 是否填充分割符，border 模式下悬停时显示。 | `boolean` | — | `false` |
| `dragDirection` | 拖拽方向，row 为水平，column 为垂直。 | `string` | row / column | `'row'` |
| `resizeMinWidth` | 允许调整的最小尺寸；row 为宽度，column 为高度。 | `number` | — | `0` |
| `symbolMode` | 是否采用分隔符号模式，或边框模式。 | `string` | symbol / border | `'symbol'` |
| `seperatorPosition` | 分割线位置。 | `string` | start / end / center | `'start'` |
| `unique` | 缓存标识；不同布局应使用不同值。 | `string` | — | `'resiable-panel-child'` |
| `divideType` | 调整面板尺寸的方式，使用 flex-basis 或 width/height。 | `string` | flex / calc | `'calc'` |
| `cached` | 是否缓存拖拽完成后的面板尺寸。 | `boolean` | — | `false` |

## 事件 {#events}

| 事件名称 | 说明 | 回调参数 |
| --- | --- | --- |
| `resize` | 松开拖拽后触发；键盘调整后也会触发。 | — |

## 插槽 {#slots}

| 参数 | 说明 | 回调参数 |
| --- | --- | --- |
| `default` | 直接子面板内容，需指定初始尺寸或 flex。 | — |
| `seperator-symbol` | 定制分割符号。 | — |

## 方法 {#methods}

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `refresh()` | `void` | Recollect panels and read compatible cache. |

## 迁移说明 {#migration}

保留旧版 `seperator*` 拼写和缓存键 `nf-resizable-panels-${unique}`。仅恢复数量一致、总尺寸误差不超过 4px 的缓存。方向键调整 10px，Shift＋方向键调整 1px；拖拽结束／卸载时清理监听器。
