diff --git a/.gitignore b/.gitignore
index caef309..9078792 100644
--- a/.gitignore
+++ b/.gitignore
@@ -130,3 +130,4 @@ build
pnpm-lock.yaml
package-lock.json
example
+prompts
\ No newline at end of file
diff --git a/README.md b/README.md
index 4d47261..0632631 100644
--- a/README.md
+++ b/README.md
@@ -29,78 +29,49 @@ column-split 是一个轻量级的 React 组件,用于通过拖动分隔条动
#### 示例代码
- 基础示例
-- 展示 column-split 组件的基本用法,包括正常状态、只读状态和禁用状态。
-- _ColumnSplit(@kne/current-lib_column-split)[import * as _ColumnSplit from "@kne/column-split"],(@kne/current-lib_column-split/dist/index.css)
+- 展示 ColumnSplit 组件的基本用法,包括正常、只读、禁用三种状态。
+- _ColumnSplit(@kne/current-lib_column-split)[import * as _ColumnSplit from "@kne/column-split"],(@kne/current-lib_column-split/dist/index.css),antd(antd)
```jsx
const { default: ColumnSplit } = _ColumnSplit;
+const { Flex, Divider } = antd;
const BaseExample = () => {
+ const columns = [
+ {
+ name: 'frontend',
+ title: '前端开发',
+ color: '#5386FA'
+ },
+ {
+ name: 'backend',
+ title: '后端开发',
+ color: '#8B5CF6'
+ },
+ {
+ name: 'testing',
+ title: '测试',
+ color: '#FCD34D'
+ }
+ ];
+
return (
-
-
正常状态:
-
-
只读状态:
-
-
禁用状态:
-
-
+
+
+ 正常状态
+
+
+
+
+ 只读状态
+
+
+
+
+ 禁用状态
+
+
+
);
};
@@ -108,29 +79,275 @@ render();
```
+- 受控模式
+- 展示 ColumnSplit 的受控模式用法,通过 value 和 onChange 控制列宽分配。
+- _ColumnSplit(@kne/current-lib_column-split)[import * as _ColumnSplit from "@kne/column-split"],(@kne/current-lib_column-split/dist/index.css),antd(antd)
+
+```jsx
+const { default: ColumnSplit } = _ColumnSplit;
+const { Flex, Divider, Button, Space } = antd;
+const { useState } = React;
+
+const ControlledExample = () => {
+ const columns = [
+ {
+ name: 'must',
+ title: '必修课',
+ color: '#EF4444'
+ },
+ {
+ name: 'elective',
+ title: '选修课',
+ color: '#3B82F6'
+ },
+ {
+ name: 'practice',
+ title: '实践课',
+ color: '#10B981'
+ }
+ ];
+
+ const [value, setValue] = useState({
+ must: 0.5,
+ elective: 0.3,
+ practice: 0.2
+ });
+
+ const handleReset = () => {
+ setValue({
+ must: 1 / 3,
+ elective: 1 / 3,
+ practice: 1 / 3
+ });
+ };
+
+ const handleEqualDistribution = () => {
+ setValue({
+ must: 0.4,
+ elective: 0.4,
+ practice: 0.2
+ });
+ };
+
+ return (
+
+ 受控模式 - 课程学分占比分配
+
+
+
+
+
+
+
+
+
+ 当前值:
+
+ {JSON.stringify(value, null, 2)}
+
+
+
+ );
+};
+
+render();
+
+```
+
+- 高级功能
+- 展示 ColumnSplit 的高级功能,包括最小/最大占比限制、自定义渲染、allowZero 等特性。
+- _ColumnSplit(@kne/current-lib_column-split)[import * as _ColumnSplit from "@kne/column-split"],(@kne/current-lib_column-split/dist/index.css),antd(antd)
+
+```jsx
+const { default: ColumnSplit } = _ColumnSplit;
+const { Flex, Divider, Space, Switch, Typography } = antd;
+const { useState } = React;
+
+const AdvancedExample = () => {
+ const [allowZero, setAllowZero] = useState(false);
+
+ // 带最小/最大占比限制的列配置
+ const columnsWithLimits = [
+ {
+ name: 'core',
+ title: '核心业务',
+ color: '#EF4444',
+ min: 0.3,
+ max: 0.7,
+ render: ({ value }) => `${Math.round(value * 100)}% (核心)`
+ },
+ {
+ name: 'growth',
+ title: '增长业务',
+ color: '#3B82F6',
+ min: 0.2,
+ max: 0.5
+ },
+ {
+ name: 'exploration',
+ title: '探索业务',
+ color: '#10B981',
+ min: 0.1,
+ max: 0.3
+ }
+ ];
+
+ // 点击隐藏列示例 - 更多列便于演示
+ const columnsForAllowZero = [
+ {
+ name: 'frontend',
+ title: '前端',
+ color: '#3B82F6'
+ },
+ {
+ name: 'backend',
+ title: '后端',
+ color: '#8B5CF6'
+ },
+ {
+ name: 'testing',
+ title: '测试',
+ color: '#10B981'
+ },
+ {
+ name: 'devops',
+ title: '运维',
+ color: '#F59E0B'
+ },
+ {
+ name: 'design',
+ title: '设计',
+ color: '#EC4899'
+ }
+ ];
+
+ // 自定义渲染列内容的示例
+ const columnsWithRenderItem = [
+ {
+ name: 'revenue',
+ title: '营收',
+ color: '#8B5CF6'
+ },
+ {
+ name: 'profit',
+ title: '利润',
+ color: '#F59E0B'
+ }
+ ];
+
+ return (
+
+
+ 最小/最大占比限制
+
+ 核心业务:30%-70% | 增长业务:20%-50% | 探索业务:10%-30%
+
+
+
+
+
+ 自定义 render 函数
+
+ 核心业务列使用自定义 render 显示格式化文本
+
+
+
+
+
+ allowZero - 点击隐藏列
+
+ 允许隐藏列:
+
+
+
+ 开启后可点击列将其隐藏(占比变为0),隐藏的列会显示在底部,点击可恢复。拖动调整占比始终可用。
+
+
+
+
+
+ 自定义 renderItem
+
+ 使用 renderItem 完全自定义列内容渲染
+
+ (
+
+ {item.title}
+
+ {valueStr}
+
+
+ 序号:{index + 1}
+
+
+ )}
+ />
+
+
+ );
+};
+
+render();
+
+```
+
### API
-### API 文档
-
-| 属性 | 类型 | 默认值 | 说明 |
-|----------------|-----------------|--------------------------------------------------------|----|
-| `columns` | `Array