@gmfe/react 2.14.30-alpha.0 → 2.14.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +295 -0
- package/package.json +4 -4
- package/src/component/affix/README.md +54 -0
- package/src/component/box/README.md +142 -0
- package/src/component/box/box_table.js +11 -18
- package/src/component/button/README.md +90 -0
- package/src/component/calendar/README.md +98 -0
- package/src/component/carousel/README.md +51 -0
- package/src/component/cascader/README.md +139 -0
- package/src/component/checkbox/README.md +120 -0
- package/src/component/collapse/README.md +80 -0
- package/src/component/color_picker/README.md +50 -0
- package/src/component/date_picker/README.md +144 -0
- package/src/component/date_range_picker/README.md +126 -0
- package/src/component/dialog/README.md +149 -0
- package/src/component/divider/README.md +41 -0
- package/src/component/drawer/README.md +83 -0
- package/src/component/drop_down/README.md +105 -0
- package/src/component/drop_select/README.md +146 -0
- package/src/component/dropper/README.md +55 -0
- package/src/component/editable_text/README.md +68 -0
- package/src/component/filter_select/README.md +104 -0
- package/src/component/flex/README.md +88 -0
- package/src/component/flip_number/README.md +53 -0
- package/src/component/form/README.md +199 -0
- package/src/component/function_set/README.md +93 -0
- package/src/component/grid/README.md +93 -0
- package/src/component/icon_down_up/README.md +43 -0
- package/src/component/image_preview/README.md +57 -0
- package/src/component/img_uploader/README.md +91 -0
- package/src/component/input/README.md +49 -0
- package/src/component/input_number/README.md +93 -0
- package/src/component/layout_root/README.md +181 -0
- package/src/component/lazy_img/README.md +59 -0
- package/src/component/level_list/README.md +75 -0
- package/src/component/level_select/README.md +78 -0
- package/src/component/list/README.md +96 -0
- package/src/component/loading/README.md +116 -0
- package/src/component/mask/README.md +62 -0
- package/src/component/modal/README.md +155 -0
- package/src/component/more_select/README.md +185 -0
- package/src/component/nav/README.md +101 -0
- package/src/component/nprogress/README.md +135 -0
- package/src/component/pagination/README.md +87 -0
- package/src/component/picture_preview/README.md +50 -0
- package/src/component/popover/README.md +146 -0
- package/src/component/popup/README.md +121 -0
- package/src/component/price/README.md +72 -0
- package/src/component/progress/README.md +98 -0
- package/src/component/progress_circle/README.md +92 -0
- package/src/component/radio/README.md +101 -0
- package/src/component/recommend_input/README.md +75 -0
- package/src/component/select/README.md +120 -0
- package/src/component/selection/README.md +87 -0
- package/src/component/sheet/README.md +176 -0
- package/src/component/steps/README.md +55 -0
- package/src/component/storage/README.md +83 -0
- package/src/component/switch/README.md +85 -0
- package/src/component/table_select/README.md +92 -0
- package/src/component/tabs/README.md +85 -0
- package/src/component/time_span/README.md +112 -0
- package/src/component/tip/README.md +105 -0
- package/src/component/tool_tip/README.md +84 -0
- package/src/component/transfer/README.md +98 -0
- package/src/component/transfer_v2/README.md +85 -0
- package/src/component/tree/README.md +99 -0
- package/src/component/tree/index.js +1 -1
- package/src/component/tree_v2/README.md +99 -0
- package/src/component/uploader/README.md +104 -0
- package/src/index.js +1 -3
- package/LICENSE +0 -16
- package/src/hoc/sticky_layout.js +0 -157
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# EditableText
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
可编辑文本组件 - 点击文本切换为编辑模式,支持确认和取消操作
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import { EditableText } from '@gmfe/react'
|
|
12
|
+
|
|
13
|
+
<EditableText
|
|
14
|
+
content="可编辑的文本"
|
|
15
|
+
onOk={value => console.log('确认:', value)}
|
|
16
|
+
onCancel={() => console.log('取消')}
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
### Props
|
|
23
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
24
|
+
|------|------|------|--------|------|
|
|
25
|
+
| content | 组件显示的文本内容 | `string` | - | 是 |
|
|
26
|
+
| onOk | 确认回调,参数为编辑后的文本值 | `function` | - | 否 |
|
|
27
|
+
| onCancel | 取消回调 | `function` | - | 否 |
|
|
28
|
+
| disabled | 是否禁用编辑 | `bool` | - | 否 |
|
|
29
|
+
| children | 自定义显示内容,优先级高于 `content` | `any` | - | 否 |
|
|
30
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
31
|
+
|
|
32
|
+
## 示例
|
|
33
|
+
|
|
34
|
+
### 基础用法
|
|
35
|
+
```jsx
|
|
36
|
+
<EditableText
|
|
37
|
+
content="可编辑的文本"
|
|
38
|
+
onOk={value => setContent(value)}
|
|
39
|
+
/>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 禁用编辑
|
|
43
|
+
```jsx
|
|
44
|
+
<EditableText
|
|
45
|
+
content="不可编辑"
|
|
46
|
+
onOk={value => setContent(value)}
|
|
47
|
+
disabled
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 自定义显示内容
|
|
52
|
+
```jsx
|
|
53
|
+
<EditableText onOk={value => setContent(value)} content={content}>
|
|
54
|
+
<Popover
|
|
55
|
+
showArrow
|
|
56
|
+
top
|
|
57
|
+
type="hover"
|
|
58
|
+
popup={<div className="gm-border gm-padding-5">来源:{content}</div>}
|
|
59
|
+
>
|
|
60
|
+
<div className="gm-inline-block">{content}</div>
|
|
61
|
+
</Popover>
|
|
62
|
+
</EditableText>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 注意事项
|
|
66
|
+
- 按回车键可确认编辑
|
|
67
|
+
- 点击确认按钮或输入框失焦时触发取消操作(失焦有 300ms 延迟以避免与按钮点击冲突)
|
|
68
|
+
- 禁用状态下不会显示编辑图标
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# FilterSelect
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
过滤选择组件 - 支持搜索过滤的下拉选择器,提供单选和多选两个版本
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import { FilterSelect, MultipleFilterSelect } from '@gmfe/react'
|
|
12
|
+
|
|
13
|
+
// 单选
|
|
14
|
+
<FilterSelect
|
|
15
|
+
id="filter-1"
|
|
16
|
+
list={list}
|
|
17
|
+
selected={selected}
|
|
18
|
+
onSelect={selected => setSelected(selected)}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
// 多选
|
|
22
|
+
<MultipleFilterSelect
|
|
23
|
+
id="filter-2"
|
|
24
|
+
list={list}
|
|
25
|
+
selected={selectedList}
|
|
26
|
+
onSelect={selectedList => setSelectedList(selectedList)}
|
|
27
|
+
/>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API
|
|
31
|
+
|
|
32
|
+
### FilterSelect Props
|
|
33
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
34
|
+
|------|------|------|--------|------|
|
|
35
|
+
| id | 唯一标识 | `string` | - | 是 |
|
|
36
|
+
| list | 数据源数组 | `array` | - | 是 |
|
|
37
|
+
| selected | 当前选中项 | `any` | - | 否 |
|
|
38
|
+
| onSelect | 选中回调 | `function` | - | 是 |
|
|
39
|
+
| disabled | 是否禁用 | `bool` | `false` | 否 |
|
|
40
|
+
| isGroupList | 数据是否为分组格式 | `bool` | `false` | 否 |
|
|
41
|
+
| onSearch | 搜索回调,参数为 `query` | `function` | `_.noop` | 否 |
|
|
42
|
+
| withFilter | 过滤函数,参数为 `(list, query)` | `function` | `(v) => v` | 否 |
|
|
43
|
+
| delay | 搜索防抖延迟(毫秒) | `number` | `500` | 否 |
|
|
44
|
+
| listMaxHeight | 列表最大高度 | `string` | `'250px'` | 否 |
|
|
45
|
+
| placeholder | 搜索框占位文本 | `string` | `''` | 否 |
|
|
46
|
+
| isScrollToSelected | 是否滚动到选中项 | `bool` | `false` | 否 |
|
|
47
|
+
| onInputFocus | 搜索框获取焦点回调 | `function` | `_.noop` | 否 |
|
|
48
|
+
| disableSearch | 是否禁用搜索 | `bool` | `false` | 否 |
|
|
49
|
+
| renderItemName | 自定义列表项渲染 | `function` | `(v) => v.name` | 否 |
|
|
50
|
+
| showClear | 是否显示清除按钮 | `bool` | `false` | 否 |
|
|
51
|
+
| className | 外层自定义类名 | `string` | - | 否 |
|
|
52
|
+
| inputClassName | 列表项自定义类名 | `string` | - | 否 |
|
|
53
|
+
|
|
54
|
+
### MultipleFilterSelect Props
|
|
55
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
56
|
+
|------|------|------|--------|------|
|
|
57
|
+
| id | 唯一标识 | `string` | - | 是 |
|
|
58
|
+
| list | 数据源数组 | `array` | - | 是 |
|
|
59
|
+
| selected | 已选中的项数组 | `array` | - | 是 |
|
|
60
|
+
| onSelect | 选中回调 | `function` | - | 是 |
|
|
61
|
+
| disabled | 是否禁用 | `bool` | `false` | 否 |
|
|
62
|
+
| isGroupList | 数据是否为分组格式 | `bool` | `false` | 否 |
|
|
63
|
+
| onSearch | 搜索回调,参数为 `query` | `function` | `_.noop` | 否 |
|
|
64
|
+
| withFilter | 过滤函数,参数为 `(list, query)` | `function` | `(v) => v` | 否 |
|
|
65
|
+
| delay | 搜索防抖延迟(毫秒) | `number` | `500` | 否 |
|
|
66
|
+
| listMaxHeight | 列表最大高度 | `string` | `'250px'` | 否 |
|
|
67
|
+
| placeholder | 搜索框占位文本 | `string` | `''` | 否 |
|
|
68
|
+
| isScrollToSelected | 是否滚动到选中项 | `bool` | `false` | 否 |
|
|
69
|
+
| onInputFocus | 搜索框获取焦点回调 | `function` | `_.noop` | 否 |
|
|
70
|
+
| disableSearch | 是否禁用搜索 | `bool` | `false` | 否 |
|
|
71
|
+
| renderItemName | 自定义列表项渲染 | `function` | `(v) => v.name` | 否 |
|
|
72
|
+
| className | 外层自定义类名 | `string` | - | 否 |
|
|
73
|
+
| inputClassName | 列表项自定义类名 | `string` | - | 否 |
|
|
74
|
+
|
|
75
|
+
## 示例
|
|
76
|
+
|
|
77
|
+
### 单选
|
|
78
|
+
```jsx
|
|
79
|
+
<FilterSelect
|
|
80
|
+
id="my-filter"
|
|
81
|
+
list={[{ value: 1, name: '选项1' }, { value: 2, name: '选项2' }]}
|
|
82
|
+
selected={selected}
|
|
83
|
+
onSelect={selected => setSelected(selected)}
|
|
84
|
+
placeholder="请选择"
|
|
85
|
+
/>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 多选
|
|
89
|
+
```jsx
|
|
90
|
+
<MultipleFilterSelect
|
|
91
|
+
id="my-multi-filter"
|
|
92
|
+
list={[{ value: 1, name: '选项1' }, { value: 2, name: '选项2' }]}
|
|
93
|
+
selected={selectedList}
|
|
94
|
+
onSelect={selectedList => setSelectedList(selectedList)}
|
|
95
|
+
placeholder="请选择"
|
|
96
|
+
/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 注意事项
|
|
100
|
+
- 必须提供 `id` 属性,否则会在控制台输出警告
|
|
101
|
+
- 单选选中后会自动关闭弹出框
|
|
102
|
+
- 多选模式下已选项会以标签形式展示,可单独关闭
|
|
103
|
+
- 支持键盘上下键导航和回车键选中
|
|
104
|
+
- `onSearch` 返回 Promise 时,搜索期间会显示 Loading 状态
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Flex
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
弹性布局组件 - 对 CSS Flexbox 布局的简单封装,提供兼容性良好的布尔值属性来控制 flex 容器的各种行为。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import Flex from '@gmfe/react/lib/flex'
|
|
12
|
+
|
|
13
|
+
// 水平居中布局
|
|
14
|
+
<Flex justifyCenter alignCenter>
|
|
15
|
+
<div>内容1</div>
|
|
16
|
+
<div>内容2</div>
|
|
17
|
+
</Flex>
|
|
18
|
+
|
|
19
|
+
// 垂直布局
|
|
20
|
+
<Flex column>
|
|
21
|
+
<div>上</div>
|
|
22
|
+
<div>下</div>
|
|
23
|
+
</Flex>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
### Props
|
|
29
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
30
|
+
|------|------|------|--------|------|
|
|
31
|
+
| flex | flex 值,传入数字时作为 flex 属性值,传入 true 时等同于 1 | `number \| bool` | - | 否 |
|
|
32
|
+
| auto | 设置 flex: auto | `bool` | - | 否 |
|
|
33
|
+
| none | 设置 flex: none | `bool` | - | 否 |
|
|
34
|
+
| width | 设置宽度(设置后自动添加 none 效果) | `string` | - | 否 |
|
|
35
|
+
| height | 设置高度(设置后自动添加 none 效果) | `string` | - | 否 |
|
|
36
|
+
| row | 水平排列(主轴为水平方向) | `bool` | - | 否 |
|
|
37
|
+
| column | 垂直排列(主轴为垂直方向) | `bool` | - | 否 |
|
|
38
|
+
| wrap | 允许换行 | `bool` | - | 否 |
|
|
39
|
+
| nowrap | 不允许换行 | `bool` | - | 否 |
|
|
40
|
+
| justifyStart | 主轴起始对齐 | `bool` | - | 否 |
|
|
41
|
+
| justifyEnd | 主轴末尾对齐 | `bool` | - | 否 |
|
|
42
|
+
| justifyCenter | 主轴居中对齐 | `bool` | - | 否 |
|
|
43
|
+
| justifyBetween | 主轴两端对齐,中间等距分布 | `bool` | - | 否 |
|
|
44
|
+
| justifyAround | 主轴周围等距分布 | `bool` | - | 否 |
|
|
45
|
+
| alignStart | 交叉轴起始对齐 | `bool` | - | 否 |
|
|
46
|
+
| alignEnd | 交叉轴末尾对齐 | `bool` | - | 否 |
|
|
47
|
+
| alignCenter | 交叉轴居中对齐 | `bool` | - | 否 |
|
|
48
|
+
| alignBaseline | 交叉轴基线对齐 | `bool` | - | 否 |
|
|
49
|
+
| alignStretch | 交叉轴拉伸对齐 | `bool` | - | 否 |
|
|
50
|
+
| alignContentStart | 多行交叉轴起始对齐 | `bool` | - | 否 |
|
|
51
|
+
| alignContentEnd | 多行交叉轴末尾对齐 | `bool` | - | 否 |
|
|
52
|
+
| alignContentCenter | 多行交叉轴居中对齐 | `bool` | - | 否 |
|
|
53
|
+
| alignContentBetween | 多行交叉轴两端对齐 | `bool` | - | 否 |
|
|
54
|
+
| alignContentAround | 多行交叉轴周围等距分布 | `bool` | - | 否 |
|
|
55
|
+
| alignContentStretch | 多行交叉轴拉伸对齐 | `bool` | - | 否 |
|
|
56
|
+
| children | 子元素 | `any` | - | 否 |
|
|
57
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
58
|
+
| style | 自定义样式 | `object` | - | 否 |
|
|
59
|
+
|
|
60
|
+
## 示例
|
|
61
|
+
|
|
62
|
+
### 基础用法
|
|
63
|
+
```jsx
|
|
64
|
+
// 水平布局,两端对齐
|
|
65
|
+
<Flex row justifyBetween>
|
|
66
|
+
<div>左侧</div>
|
|
67
|
+
<div>右侧</div>
|
|
68
|
+
</Flex>
|
|
69
|
+
|
|
70
|
+
// 垂直居中
|
|
71
|
+
<Flex column alignCenter>
|
|
72
|
+
<div>项目1</div>
|
|
73
|
+
<div>项目2</div>
|
|
74
|
+
</Flex>
|
|
75
|
+
|
|
76
|
+
// 设置固定宽度
|
|
77
|
+
<Flex width='200px'>
|
|
78
|
+
固定宽度内容
|
|
79
|
+
</Flex>
|
|
80
|
+
|
|
81
|
+
// flex 自适应填充
|
|
82
|
+
<Flex flex>自动填充</Flex>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 注意事项
|
|
86
|
+
- Flex 布局语法参考 [Flex 布局教程](http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html)
|
|
87
|
+
- 设置 `width` 或 `height` 属性后,组件会自动添加 `none` 效果(即 `flex: none`)
|
|
88
|
+
- `flex` 属性传入 `true` 时等同于 `flex: 1`,传入数字时直接作为 flex 值
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# FlipNumber
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
数字翻滚动画组件 - 以滚动方式从起始数字过渡到目标数字,支持小数、千分符和自定义缓动函数
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import { FlipNumber } from '@gmfe/react'
|
|
12
|
+
|
|
13
|
+
<FlipNumber to={12345} />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
### Props
|
|
19
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
20
|
+
|------|------|------|--------|------|
|
|
21
|
+
| to | 最终要显示的数字 | `number` | - | 是 |
|
|
22
|
+
| from | 滚动的起始数字 | `number` | `0` | 否 |
|
|
23
|
+
| delay | 延迟开始时间(毫秒) | `number` | `0` | 否 |
|
|
24
|
+
| duration | 滚动动画时长(毫秒) | `number` | `1500` | 否 |
|
|
25
|
+
| easeFn | 缓动函数,控制滚动的加速度 | `function` | 默认起末慢、中间快的三次方缓动 | 否 |
|
|
26
|
+
| individually | 是否逐个数字滚动 | `bool` | `true` | 否 |
|
|
27
|
+
| decimal | 小数点后保留位数 | `number` | `0` | 否 |
|
|
28
|
+
| useGroup | 是否启用大数逗号分组(千分符) | `bool` | `false` | 否 |
|
|
29
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
30
|
+
|
|
31
|
+
## 示例
|
|
32
|
+
|
|
33
|
+
### 基础用法
|
|
34
|
+
```jsx
|
|
35
|
+
<FlipNumber to={12345} />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 带小数和千分符
|
|
39
|
+
```jsx
|
|
40
|
+
<FlipNumber
|
|
41
|
+
to={709394}
|
|
42
|
+
from={234.23}
|
|
43
|
+
decimal={2}
|
|
44
|
+
useGroup
|
|
45
|
+
delay={1000}
|
|
46
|
+
className="gm-text-20"
|
|
47
|
+
/>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 注意事项
|
|
51
|
+
- 动画使用 `requestAnimationFrame` 实现,性能良好
|
|
52
|
+
- 支持负数显示
|
|
53
|
+
- 自定义缓动函数可参考 [easing-js](https://github.com/danro/easing-js) 库
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Form
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
表单组件 - 提供完整的表单布局能力,包含 Form、FormItem、FormButton、FormBlock、FormGroup、FormPanel 等子组件,支持单栏/多栏布局、表单验证、按钮位置控制等功能。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import {
|
|
12
|
+
Form,
|
|
13
|
+
FormItem,
|
|
14
|
+
FormButton,
|
|
15
|
+
FormBlock,
|
|
16
|
+
FormGroup,
|
|
17
|
+
FormPanel
|
|
18
|
+
} from '@gmfe/react'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Form Props
|
|
24
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
25
|
+
|------|------|------|--------|------|
|
|
26
|
+
| onSubmit | 表单提交回调(已内置 event.preventDefault) | `func` | - | 否 |
|
|
27
|
+
| onSubmitValidated | 所有验证通过后调用 | `func` | - | 否 |
|
|
28
|
+
| inline | 行内模式,一般用不到,BoxForm 内部自动使用 | `bool` | - | 否 |
|
|
29
|
+
| disabledCol | 禁用列宽限制,让表单撑满页面 | `bool` | - | 否 |
|
|
30
|
+
| colWidth | 自定义列宽 | `string` | - | 否 |
|
|
31
|
+
| labelWidth | label 宽度 | `string` | - | 否 |
|
|
32
|
+
| hasButtonInGroup | 仅在 FormGroup 下使用,添加隐藏按钮响应 Enter | `bool` | - | 否 |
|
|
33
|
+
| btnPosition | 按钮位置 | `'center' \| 'left' \| 'right'` | - | 否 |
|
|
34
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
35
|
+
| style | 自定义样式 | `object` | - | 否 |
|
|
36
|
+
|
|
37
|
+
### Form 方法(通过 ref 调用)
|
|
38
|
+
| 方法 | 说明 |
|
|
39
|
+
|------|------|
|
|
40
|
+
| apiDoValidate | 手动触发验证,返回 boolean |
|
|
41
|
+
|
|
42
|
+
### FormItem Props
|
|
43
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
44
|
+
|------|------|------|--------|------|
|
|
45
|
+
| col | 占用栏数 | `1 \| 2 \| 3` | `1` | 否 |
|
|
46
|
+
| disabledCol | 禁用列宽限制 | `bool` | - | 否 |
|
|
47
|
+
| label | 标签文本(请不要包含 `:`) | `string \| element` | - | 否 |
|
|
48
|
+
| toolTip | 提示信息 | `element` | - | 否 |
|
|
49
|
+
| toolTipLeft | 提示信息位置左移 | `bool` | - | 否 |
|
|
50
|
+
| required | 是否必填 | `bool` | - | 否 |
|
|
51
|
+
| unLabelTop | 去掉 label 的上边距 | `bool` | - | 否 |
|
|
52
|
+
| validate | 验证函数(配合 Validator 使用) | `func` | - | 否 |
|
|
53
|
+
| error | 手动设置错误状态 | `bool` | - | 否 |
|
|
54
|
+
| help | 手动设置帮助文本 | `string` | - | 否 |
|
|
55
|
+
| labelWidth | label 宽度(一般由 Form 传入) | `string` | - | 否 |
|
|
56
|
+
| colWidth | 列宽(一般由 Form 传入) | `string` | - | 否 |
|
|
57
|
+
| canValidate | 是否可验证(由 Form 内部控制) | `bool` | - | 否 |
|
|
58
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
59
|
+
| style | 自定义样式 | `object` | - | 否 |
|
|
60
|
+
|
|
61
|
+
### FormBlock Props
|
|
62
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
63
|
+
|------|------|------|--------|------|
|
|
64
|
+
| col | 占用栏数 | `1 \| 2 \| 3` | `1` | 否 |
|
|
65
|
+
| disabledCol | 禁用列宽限制(Form 传入,不要手动设置) | `bool` | - | 否 |
|
|
66
|
+
| inline | 行内模式(Form 传入,不要手动设置) | `bool` | - | 否 |
|
|
67
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
68
|
+
| style | 自定义样式 | `object` | - | 否 |
|
|
69
|
+
|
|
70
|
+
### FormButton Props
|
|
71
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
72
|
+
|------|------|------|--------|------|
|
|
73
|
+
| labelWidth | label 宽度(由 Form 传入) | `string` | - | 否 |
|
|
74
|
+
| btnPosition | 按钮位置 | `'center' \| 'left' \| 'right'` | - | 否 |
|
|
75
|
+
|
|
76
|
+
### FormGroup Props
|
|
77
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
78
|
+
|------|------|------|--------|------|
|
|
79
|
+
| formRefs | 所有 Form 的 ref 数组 | `array` | - | 是 |
|
|
80
|
+
| onSubmit | 提交回调 | `func` | - | 否 |
|
|
81
|
+
| onSubmitValidated | 验证通过后回调 | `func` | - | 否 |
|
|
82
|
+
| onCancel | 取消回调 | `func` | - | 否 |
|
|
83
|
+
| disabled | 是否禁用提交按钮 | `bool` | - | 否 |
|
|
84
|
+
| saveText | 保存按钮文案 | `string` | `'保存'` | 否 |
|
|
85
|
+
| actions | 额外操作按钮 | `element` | - | 否 |
|
|
86
|
+
|
|
87
|
+
### FormPanel Props
|
|
88
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
89
|
+
|------|------|------|--------|------|
|
|
90
|
+
| title | 面板标题 | `string` | - | 否 |
|
|
91
|
+
| left | 标题左侧自定义元素 | `element` | - | 否 |
|
|
92
|
+
| right | 标题右侧自定义元素 | `element` | - | 否 |
|
|
93
|
+
| showBorder | 是否显示分割线 | `bool` | `true` | 否 |
|
|
94
|
+
|
|
95
|
+
### FormPanel.More Props
|
|
96
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
97
|
+
|------|------|------|--------|------|
|
|
98
|
+
| children | 展开更多时显示的内容 | `any` | - | 否 |
|
|
99
|
+
|
|
100
|
+
## 示例
|
|
101
|
+
|
|
102
|
+
### 单栏表单
|
|
103
|
+
```jsx
|
|
104
|
+
<Form disabledCol labelWidth='100px' onSubmit={() => console.log('submit')}>
|
|
105
|
+
<FormItem label='名字' required>
|
|
106
|
+
<input
|
|
107
|
+
type='text'
|
|
108
|
+
value={name}
|
|
109
|
+
onChange={e => setName(e.target.value)}
|
|
110
|
+
/>
|
|
111
|
+
</FormItem>
|
|
112
|
+
<FormItem label='地区'>
|
|
113
|
+
<Select data={area} value={areaValue} onChange={setAreaValue} />
|
|
114
|
+
</FormItem>
|
|
115
|
+
<FormButton>
|
|
116
|
+
<Button type='primary' htmlType='submit'>提交</Button>
|
|
117
|
+
</FormButton>
|
|
118
|
+
</Form>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 多栏表单
|
|
122
|
+
```jsx
|
|
123
|
+
<Form labelWidth='100px' onSubmit={() => console.log('submit')}>
|
|
124
|
+
<FormBlock col={2}>
|
|
125
|
+
<FormItem label='名字' required>
|
|
126
|
+
<input type='text' value={name} onChange={e => setName(e.target.value)} />
|
|
127
|
+
</FormItem>
|
|
128
|
+
<FormItem label='地区'>
|
|
129
|
+
<Select data={area} value={areaValue} onChange={setAreaValue} />
|
|
130
|
+
</FormItem>
|
|
131
|
+
</FormBlock>
|
|
132
|
+
<FormButton>
|
|
133
|
+
<Button type='primary' htmlType='submit'>提交</Button>
|
|
134
|
+
</FormButton>
|
|
135
|
+
</Form>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 表单验证
|
|
139
|
+
```jsx
|
|
140
|
+
import { Validator } from '@gmfe/react'
|
|
141
|
+
|
|
142
|
+
<FormItem
|
|
143
|
+
label='描述'
|
|
144
|
+
required
|
|
145
|
+
validate={Validator.create([], description)}
|
|
146
|
+
>
|
|
147
|
+
<textarea value={desc} onChange={e => setDesc(e.target.value)} />
|
|
148
|
+
</FormItem>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 多表单聚合
|
|
152
|
+
```jsx
|
|
153
|
+
const form1 = useRef(null)
|
|
154
|
+
const form2 = useRef(null)
|
|
155
|
+
|
|
156
|
+
<FormGroup
|
|
157
|
+
formRefs={[form1, form2]}
|
|
158
|
+
onCancel={() => console.log('Cancel')}
|
|
159
|
+
onSubmitValidated={() => console.log('onSubmitValidated')}
|
|
160
|
+
>
|
|
161
|
+
<Form ref={form1} labelWidth='100px' hasButtonInGroup>
|
|
162
|
+
<FormItem label='名字' required>
|
|
163
|
+
<input type='text' value={name} onChange={e => setName(e.target.value)} />
|
|
164
|
+
</FormItem>
|
|
165
|
+
</Form>
|
|
166
|
+
<Form ref={form2} labelWidth='100px' hasButtonInGroup>
|
|
167
|
+
<FormItem label='描述' required validate={Validator.create([], desc)}>
|
|
168
|
+
<textarea value={desc} onChange={e => setDesc(e.target.value)} />
|
|
169
|
+
</FormItem>
|
|
170
|
+
</Form>
|
|
171
|
+
</FormGroup>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### FormPanel 面板
|
|
175
|
+
```jsx
|
|
176
|
+
<FormPanel title='店铺设置' left={<Button onClick={handleSearch}>搜索</Button>}>
|
|
177
|
+
<Form colWidth='400px' ref={formRef} labelWidth='160px' hasButtonInGroup>
|
|
178
|
+
<FormItem label='名字' required>
|
|
179
|
+
<input type='text' value={name} onChange={e => setName(e.target.value)} />
|
|
180
|
+
</FormItem>
|
|
181
|
+
<FormPanel.More>
|
|
182
|
+
<FormBlock col={2}>
|
|
183
|
+
<FormItem label='邀请码' required>
|
|
184
|
+
<input type='text' value={code} onChange={e => setCode(e.target.value)} />
|
|
185
|
+
</FormItem>
|
|
186
|
+
</FormBlock>
|
|
187
|
+
</FormPanel.More>
|
|
188
|
+
</Form>
|
|
189
|
+
</FormPanel>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 注意事项
|
|
193
|
+
- Form 的 `onSubmit` 已内置 `event.preventDefault()`,无需手动调用
|
|
194
|
+
- 单栏表单需要设置 `disabledCol` 属性,否则 FormItem 会被限制在默认宽度内
|
|
195
|
+
- `FormItem` 会自动识别常用的表单元素(input、textarea、select、InputNumber、InputNumberV2)并添加 `form-control` 类名
|
|
196
|
+
- `FormGroup` 中 `onSubmit` 和 `onSubmitValidated` 只需提供一个,不要同时使用
|
|
197
|
+
- `label` 属性不要包含冒号(`:` 或 `:`),组件会自动添加
|
|
198
|
+
- 默认列宽为 320px,FormPanel 中默认为 400px,可通过 `colWidth` 自定义
|
|
199
|
+
- `FormGroup` 会在内容超出屏幕高度时自动吸底按钮区域
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# FunctionSet
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
功能集组件 - 以弹出菜单形式展示多个功能操作,支持多级嵌套子菜单
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import { FunctionSet } from '@gmfe/react'
|
|
12
|
+
|
|
13
|
+
<FunctionSet
|
|
14
|
+
data={[
|
|
15
|
+
{ text: '功能1', onClick: () => console.log('功能1') },
|
|
16
|
+
{ text: '功能2', onClick: () => console.log('功能2') }
|
|
17
|
+
]}
|
|
18
|
+
/>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Props
|
|
24
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
25
|
+
|------|------|------|--------|------|
|
|
26
|
+
| data | 功能项数据,格式:`[{text, disabled, show, onClick, children}]`,支持 `children` 嵌套子菜单 | `array` | - | 是 |
|
|
27
|
+
| right | 弹出层是否右对齐 | `bool` | `false` | 否 |
|
|
28
|
+
| disabled | 是否禁用整个功能集 | `bool` | `false` | 否 |
|
|
29
|
+
| showArrow | 是否显示三角箭头 | `bool` | `false` | 否 |
|
|
30
|
+
| children | 自定义触发器元素 | `any` | - | 否 |
|
|
31
|
+
|
|
32
|
+
### data 项配置
|
|
33
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
34
|
+
|------|------|------|--------|------|
|
|
35
|
+
| text | 功能项文本 | `string` | - | 是 |
|
|
36
|
+
| onClick | 点击回调 | `function` | - | 否 |
|
|
37
|
+
| disabled | 是否禁用该项 | `bool` | `false` | 否 |
|
|
38
|
+
| show | 是否显示该项 | `bool` | `true` | 否 |
|
|
39
|
+
| children | 子菜单数据,格式与 `data` 相同 | `array` | - | 否 |
|
|
40
|
+
|
|
41
|
+
## 示例
|
|
42
|
+
|
|
43
|
+
### 基础用法
|
|
44
|
+
```jsx
|
|
45
|
+
<FunctionSet
|
|
46
|
+
data={[
|
|
47
|
+
{ text: '功能1', onClick: () => alert('功能1') },
|
|
48
|
+
{ text: '功能2', onClick: () => alert('功能2') },
|
|
49
|
+
{ text: '功能3(不可用)', disabled: true },
|
|
50
|
+
{ text: '功能4(不显示)', show: false }
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 多级子菜单
|
|
56
|
+
```jsx
|
|
57
|
+
<FunctionSet
|
|
58
|
+
data={[
|
|
59
|
+
{
|
|
60
|
+
text: '新建',
|
|
61
|
+
children: [
|
|
62
|
+
{
|
|
63
|
+
text: '商品新建',
|
|
64
|
+
children: [
|
|
65
|
+
{ text: '商品新建1', onClick: () => alert('商品新建1') },
|
|
66
|
+
{ text: '商品新建2', onClick: () => alert('商品新建2') }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 自定义触发器
|
|
76
|
+
```jsx
|
|
77
|
+
<FunctionSet data={data}>
|
|
78
|
+
<span className="gm-cursor">更多</span>
|
|
79
|
+
</FunctionSet>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 三角箭头样式
|
|
83
|
+
```jsx
|
|
84
|
+
<FunctionSet showArrow data={data}>
|
|
85
|
+
<span className="gm-cursor">...</span>
|
|
86
|
+
</FunctionSet>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 注意事项
|
|
90
|
+
- 当 `data` 为空数组时,组件不会渲染任何内容
|
|
91
|
+
- 功能项必须配置 `onClick` 才能响应点击
|
|
92
|
+
- 子菜单使用 `LevelList` 组件渲染,支持多级嵌套
|
|
93
|
+
- 弹出层默认使用 `hover` 触发模式
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Grid
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
栅格布局组件 - 基于 24 栅格系统的响应式布局组件,包含 Row 和 Col 两个子组件。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
已包含在 `@gmfe/react` 中,无需额外安装。
|
|
8
|
+
|
|
9
|
+
## 使用
|
|
10
|
+
```jsx
|
|
11
|
+
import { Row, Col } from '@gmfe/react/lib/grid'
|
|
12
|
+
|
|
13
|
+
<Row>
|
|
14
|
+
<Col span={12}>左侧</Col>
|
|
15
|
+
<Col span={12}>右侧</Col>
|
|
16
|
+
</Row>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
### Row Props
|
|
22
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
23
|
+
|------|------|------|--------|------|
|
|
24
|
+
| gutter | 栅格间隔,可传入像素值或响应式对象 `{ xs: 8, sm: 16, md: 24 }` | `number \| object` | `0` | 否 |
|
|
25
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
26
|
+
| style | 自定义样式 | `object` | - | 否 |
|
|
27
|
+
|
|
28
|
+
Row 组件继承 Flex 组件的所有属性(`row` 和 `wrap` 已默认开启)。
|
|
29
|
+
|
|
30
|
+
### Col Props
|
|
31
|
+
| 属性 | 说明 | 类型 | 默认值 | 必填 |
|
|
32
|
+
|------|------|------|--------|------|
|
|
33
|
+
| span | 栅格占位格数,为 0 时相当于 `display: none` | `number` | - | 否 |
|
|
34
|
+
| offset | 栅格左侧的间隔格数 | `number` | - | 否 |
|
|
35
|
+
| sm | 768px 响应式栅格,可为栅格数或包含 span/offset 的对象 | `number \| {span, offset}` | - | 否 |
|
|
36
|
+
| md | 992px 响应式栅格,可为栅格数或包含 span/offset 的对象 | `number \| {span, offset}` | - | 否 |
|
|
37
|
+
| lg | 1200px 响应式栅格,可为栅格数或包含 span/offset 的对象 | `number \| {span, offset}` | - | 否 |
|
|
38
|
+
| xl | 1920px 响应式栅格,可为栅格数或包含 span/offset 的对象 | `number \| {span, offset}` | - | 否 |
|
|
39
|
+
| className | 自定义类名 | `string` | - | 否 |
|
|
40
|
+
|
|
41
|
+
## 示例
|
|
42
|
+
|
|
43
|
+
### 基础用法
|
|
44
|
+
```jsx
|
|
45
|
+
// 占满 24 栅格
|
|
46
|
+
<Row>
|
|
47
|
+
<Col span={24}>Col 24</Col>
|
|
48
|
+
</Row>
|
|
49
|
+
|
|
50
|
+
// 三等分
|
|
51
|
+
<Row>
|
|
52
|
+
<Col span={8}>Col 8</Col>
|
|
53
|
+
<Col span={8}>Col 8</Col>
|
|
54
|
+
<Col span={8}>Col 8</Col>
|
|
55
|
+
</Row>
|
|
56
|
+
|
|
57
|
+
// 左偏移
|
|
58
|
+
<Row>
|
|
59
|
+
<Col span={8}>Col 8</Col>
|
|
60
|
+
<Col span={8} offset={8}>Col 8, Offset 8</Col>
|
|
61
|
+
</Row>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 响应式布局
|
|
65
|
+
```jsx
|
|
66
|
+
<Row>
|
|
67
|
+
<Col sm={{ span: 4, offset: 4 }} md={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }} xl={8}>
|
|
68
|
+
Col
|
|
69
|
+
</Col>
|
|
70
|
+
<Col sm={{ span: 4, offset: 4 }} md={{ span: 11, offset: 1 }} lg={{ span: 6, offset: 2 }} xl={8}>
|
|
71
|
+
Col
|
|
72
|
+
</Col>
|
|
73
|
+
<Col sm={{ span: 4, offset: 4 }} md={{ span: 5, offset: 1 }} lg={{ span: 6, offset: 2 }} xl={8}>
|
|
74
|
+
Col
|
|
75
|
+
</Col>
|
|
76
|
+
</Row>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 间隔设置
|
|
80
|
+
```jsx
|
|
81
|
+
<Row gutter={8}>
|
|
82
|
+
<Col span={8}>Col 8</Col>
|
|
83
|
+
<Col span={8}>Col 8</Col>
|
|
84
|
+
<Col span={8}>Col 8</Col>
|
|
85
|
+
</Row>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 注意事项
|
|
89
|
+
- 栅格系统基于 24 格
|
|
90
|
+
- Row 组件默认开启了 `row`(水平排列)和 `wrap`(自动换行)属性
|
|
91
|
+
- 响应式断点:`sm` = 768px, `md` = 992px, `lg` = 1200px, `xl` = 1920px
|
|
92
|
+
- `span` 设为 0 时,该列不会显示(相当于 `display: none`)
|
|
93
|
+
- 设置 `gutter` 后,Col 会自动添加左右内边距
|