@gmfe/react 2.14.29 → 2.14.30

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.
Files changed (67) hide show
  1. package/README.md +179 -0
  2. package/package.json +3 -3
  3. package/src/component/affix/README.md +54 -0
  4. package/src/component/box/README.md +142 -0
  5. package/src/component/button/README.md +90 -0
  6. package/src/component/calendar/README.md +98 -0
  7. package/src/component/carousel/README.md +51 -0
  8. package/src/component/cascader/README.md +139 -0
  9. package/src/component/checkbox/README.md +120 -0
  10. package/src/component/collapse/README.md +80 -0
  11. package/src/component/color_picker/README.md +50 -0
  12. package/src/component/date_picker/README.md +144 -0
  13. package/src/component/date_range_picker/README.md +126 -0
  14. package/src/component/dialog/README.md +149 -0
  15. package/src/component/divider/README.md +41 -0
  16. package/src/component/drawer/README.md +83 -0
  17. package/src/component/drop_down/README.md +105 -0
  18. package/src/component/drop_select/README.md +146 -0
  19. package/src/component/dropper/README.md +55 -0
  20. package/src/component/editable_text/README.md +68 -0
  21. package/src/component/filter_select/README.md +104 -0
  22. package/src/component/flex/README.md +88 -0
  23. package/src/component/flip_number/README.md +53 -0
  24. package/src/component/form/README.md +199 -0
  25. package/src/component/function_set/README.md +93 -0
  26. package/src/component/grid/README.md +93 -0
  27. package/src/component/icon_down_up/README.md +43 -0
  28. package/src/component/image_preview/README.md +57 -0
  29. package/src/component/img_uploader/README.md +91 -0
  30. package/src/component/input/README.md +49 -0
  31. package/src/component/input_number/README.md +93 -0
  32. package/src/component/layout_root/README.md +181 -0
  33. package/src/component/lazy_img/README.md +59 -0
  34. package/src/component/level_list/README.md +75 -0
  35. package/src/component/level_select/README.md +78 -0
  36. package/src/component/list/README.md +96 -0
  37. package/src/component/loading/README.md +116 -0
  38. package/src/component/mask/README.md +62 -0
  39. package/src/component/modal/README.md +155 -0
  40. package/src/component/more_select/README.md +185 -0
  41. package/src/component/nav/README.md +101 -0
  42. package/src/component/nprogress/README.md +135 -0
  43. package/src/component/pagination/README.md +87 -0
  44. package/src/component/picture_preview/README.md +50 -0
  45. package/src/component/popover/README.md +146 -0
  46. package/src/component/popup/README.md +121 -0
  47. package/src/component/price/README.md +72 -0
  48. package/src/component/progress/README.md +98 -0
  49. package/src/component/progress_circle/README.md +92 -0
  50. package/src/component/radio/README.md +101 -0
  51. package/src/component/recommend_input/README.md +75 -0
  52. package/src/component/select/README.md +120 -0
  53. package/src/component/selection/README.md +87 -0
  54. package/src/component/sheet/README.md +176 -0
  55. package/src/component/steps/README.md +55 -0
  56. package/src/component/storage/README.md +83 -0
  57. package/src/component/switch/README.md +85 -0
  58. package/src/component/table_select/README.md +92 -0
  59. package/src/component/tabs/README.md +85 -0
  60. package/src/component/time_span/README.md +112 -0
  61. package/src/component/tip/README.md +105 -0
  62. package/src/component/tool_tip/README.md +84 -0
  63. package/src/component/transfer/README.md +98 -0
  64. package/src/component/transfer_v2/README.md +85 -0
  65. package/src/component/tree/README.md +99 -0
  66. package/src/component/tree_v2/README.md +99 -0
  67. package/src/component/uploader/README.md +104 -0
@@ -0,0 +1,57 @@
1
+ # ImagePreview
2
+
3
+ ## 简介
4
+ 图片预览组件 - 全屏模态框展示大图,支持左右切换、缩略图导航和键盘操作
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { ImagePreview } from '@gmfe/react'
12
+
13
+ // 点击按钮触发预览
14
+ <button onClick={() => {
15
+ ImagePreview({
16
+ images: ['url1.jpg', 'url2.jpg', 'url3.jpg'],
17
+ thumbnails: ['thumb1.jpg', 'thumb2.jpg', 'thumb3.jpg'],
18
+ index: 0
19
+ })
20
+ }}>
21
+ 预览图片
22
+ </button>
23
+ ```
24
+
25
+ ## API
26
+
27
+ ### 参数
28
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
29
+ |------|------|------|--------|------|
30
+ | images | 图片 URL 数组 | `array` | - | 是 |
31
+ | thumbnails | 缩略图 URL 数组,底部展示缩略图列表 | `array` | - | 否 |
32
+ | index | 初始展示的图片索引 | `number` | - | 是 |
33
+
34
+ ## 示例
35
+
36
+ ### 基础用法
37
+ ```jsx
38
+ ImagePreview({
39
+ images: ['img1.jpg', 'img2.jpg', 'img3.jpg'],
40
+ index: 0
41
+ })
42
+ ```
43
+
44
+ ### 带缩略图
45
+ ```jsx
46
+ ImagePreview({
47
+ images: ['img1.jpg', 'img2.jpg', 'img3.jpg'],
48
+ thumbnails: ['thumb1.jpg', 'thumb2.jpg', 'thumb3.jpg'],
49
+ index: 1
50
+ })
51
+ ```
52
+
53
+ ## 注意事项
54
+ - `ImagePreview` 不是 React 组件,而是一个函数调用,内部使用 `CleanModal` 渲染全屏模态框
55
+ - 支持键盘左右箭头键切换图片
56
+ - 缩略图多于一行时,会自动显示左右滚动按钮
57
+ - 点击模态框右上角的关闭按钮可关闭预览
@@ -0,0 +1,91 @@
1
+ # ImgUploader
2
+
3
+ ## 简介
4
+ 图片上传组件 - 支持多图上传、预览、删除和替换,提供统一的图片上传管理能力。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { ImgUploader } from '@gmfe/react'
12
+
13
+ const handleUpload = files => {
14
+ // 调用上传接口
15
+ return Promise.resolve(['https://example.com/image.png'])
16
+ }
17
+
18
+ <ImgUploader
19
+ data={['https://example.com/image1.png']}
20
+ onChange={data => setImageData(data)}
21
+ onUpload={handleUpload}
22
+ />
23
+ ```
24
+
25
+ ## API
26
+
27
+ ### Props
28
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
29
+ |------|------|------|--------|------|
30
+ | data | 图片 URL 数组 | `array` | - | 是 |
31
+ | onChange | 图片列表变化回调,参数为新的 URL 数组 | `func` | - | 是 |
32
+ | onUpload | 上传回调,参数为 files,需返回 Promise resolve 回 [url] | `func` | - | 是 |
33
+ | disabled | 是否禁用 | `bool` | - | 否 |
34
+ | accept | 接受的图片类型 | `string` | `'image/*'` | 否 |
35
+ | multiple | 添加按钮是否支持多图选择 | `bool` | - | 否 |
36
+ | contentSize | 图片尺寸配置 | `shape` | - | 否 |
37
+ | contentSize.width | 图片宽度 | `string` | `'64px'` | 否 |
38
+ | contentSize.height | 图片高度 | `string` | `'64px'` | 否 |
39
+ | desc | 描述文本 | `string` | - | 否 |
40
+ | imgRender | 自定义图片渲染,参数为图片 URL,返回 ReactElement | `func` | - | 否 |
41
+ | className | 自定义类名 | `string` | - | 否 |
42
+ | style | 自定义样式 | `object` | - | 否 |
43
+
44
+ ## 示例
45
+
46
+ ### 基础用法
47
+ ```jsx
48
+ const handleUpload = files => {
49
+ return Promise.resolve([
50
+ 'https://example.com/image.png'
51
+ ])
52
+ }
53
+
54
+ <ImgUploader
55
+ data={imageList}
56
+ onUpload={handleUpload}
57
+ onChange={data => setImageList(data)}
58
+ accept='image/*'
59
+ desc='图片尺寸720*720像素,大小小于1M'
60
+ multiple
61
+ />
62
+ ```
63
+
64
+ ### 禁用状态
65
+ ```jsx
66
+ <ImgUploader
67
+ disabled
68
+ data={imageList}
69
+ onUpload={handleUpload}
70
+ onChange={data => setImageList(data)}
71
+ />
72
+ ```
73
+
74
+ ### 自定义图片尺寸
75
+ ```jsx
76
+ <ImgUploader
77
+ data={imageList}
78
+ onUpload={handleUpload}
79
+ onChange={data => setImageList(data)}
80
+ contentSize={{ width: '100px', height: '100px' }}
81
+ />
82
+ ```
83
+
84
+ ## 注意事项
85
+ - `onUpload` 回调必须返回一个 `Promise`,`resolve` 的结果为上传后的 URL 数组
86
+ - `data` 属性存储的是图片 URL 数组,不是 File 对象
87
+ - 点击已有图片可替换该图片
88
+ - 每张图片右上角有关闭按钮,点击可删除(禁用状态下不显示)
89
+ - `multiple` 属性仅控制"添加"按钮是否支持多选,不影响已有图片
90
+ - 默认图片尺寸为 64px x 64px
91
+ - 图片尺寸和文件大小的验证需在使用时自行处理
@@ -0,0 +1,49 @@
1
+ # Input
2
+
3
+ ## 简介
4
+ 输入框组件 - 基于原生 input 封装,添加了 `gm-input` 类名以配合 UI 库的样式。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Input } from '@gmfe/react'
12
+
13
+ <Input type='text' placeholder='请输入' />
14
+ ```
15
+
16
+ ## API
17
+
18
+ ### Props
19
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
20
+ |------|------|------|--------|------|
21
+ | className | 自定义类名 | `string` | - | 否 |
22
+
23
+ 除上述属性外,支持原生 input 的所有属性(如 `value`、`onChange`、`placeholder`、`type`、`disabled` 等),会直接透传到原生 input 元素上。
24
+
25
+ ## 示例
26
+
27
+ ### 基础用法
28
+ ```jsx
29
+ <Input type='text' placeholder='请输入用户名' />
30
+ ```
31
+
32
+ ### 配合 Form 使用
33
+ ```jsx
34
+ <FormItem label='名字' required>
35
+ <Input type='text' value={name} onChange={e => setName(e.target.value)} />
36
+ </FormItem>
37
+ ```
38
+
39
+ ### 自定义类名
40
+ ```jsx
41
+ <Input className='my-custom-input' placeholder='自定义样式' />
42
+ ```
43
+
44
+ ## 注意事项
45
+ - 该组件是对原生 `<input>` 的轻量封装,主要添加了 `gm-input` CSS 类名
46
+ - 所有原生 input 属性均可直接使用
47
+ - 支持 `forwardRef`,可通过 ref 获取原生 input DOM 元素
48
+ - 组件本身不包含样式,需要配合 `@gmfe/react` 的样式体系使用
49
+ - 在 Form 中使用时,FormItem 会自动为 input 添加 `form-control` 类名
@@ -0,0 +1,93 @@
1
+ # InputNumber
2
+
3
+ ## 简介
4
+ 数字输入框组件 - 限制用户只能输入合法数字,支持精度控制、最大最小值限制和负数输入。提供 `InputNumber`(旧版)和 `InputNumberV2`(推荐)两个版本。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { InputNumberV2 } from '@gmfe/react'
12
+
13
+ <InputNumberV2
14
+ value={value}
15
+ onChange={setValue}
16
+ />
17
+ ```
18
+
19
+ ## API
20
+
21
+ ### InputNumberV2(推荐)
22
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
23
+ |------|------|------|--------|------|
24
+ | value | 当前值 | `number` | `null` | 否 |
25
+ | onChange | 值变化回调 | `func` | 是 | 是 |
26
+ | max | 最大值 | `number` | - | 否 |
27
+ | min | 最小值 | `number` | - | 否 |
28
+ | precision | 精确度,保留几位小数 | `number` | `2` | 否 |
29
+ | placeholder | 占位文字 | `string` | - | 否 |
30
+ | forceInnerValue | 修复场景:删除 1.09 会将 .0 一起删除的问题 | `bool` | `false` | 否 |
31
+ | className | 自定义类名 | `string` | - | 否 |
32
+ | style | 自定义样式 | `object` | - | 否 |
33
+
34
+ ### InputNumber(旧版)
35
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
36
+ |------|------|------|--------|------|
37
+ | value | 当前值 | `number \| string` | - | 否 |
38
+ | onChange | 值变化回调 | `func` | 是 | 是 |
39
+ | max | 最大值 | `number` | - | 否 |
40
+ | min | 最小值 | `number` | - | 否 |
41
+ | precision | 精确度,保留几位小数 | `number` | `2` | 否 |
42
+ | minus | 是否支持输入负数 | `bool` | `false` | 否 |
43
+ | placeholder | 占位文字 | `string` | - | 否 |
44
+ | className | 自定义类名 | `string` | - | 否 |
45
+ | style | 自定义样式 | `object` | - | 否 |
46
+
47
+ ## 示例
48
+
49
+ ### 基础用法
50
+ ```jsx
51
+ <InputNumberV2
52
+ value={value}
53
+ onChange={setValue}
54
+ />
55
+ ```
56
+
57
+ ### 设置精度
58
+ ```jsx
59
+ <InputNumberV2
60
+ value={value}
61
+ onChange={setValue}
62
+ precision={3}
63
+ />
64
+ ```
65
+
66
+ ### 设置最大最小值
67
+ ```jsx
68
+ <InputNumberV2
69
+ value={value}
70
+ onChange={setValue}
71
+ min={0}
72
+ max={100}
73
+ />
74
+ ```
75
+
76
+ ### 旧版支持负数
77
+ ```jsx
78
+ import { InputNumber } from '@gmfe/react'
79
+
80
+ <InputNumber
81
+ value={value}
82
+ onChange={setValue}
83
+ minus
84
+ />
85
+ ```
86
+
87
+ ## 注意事项
88
+ - 推荐使用 `InputNumberV2`,它有更好的状态管理和精度处理
89
+ - `InputNumberV2` 的 `onChange` 回调参数为 `number` 类型(空值时为 `null`)
90
+ - `InputNumber`(旧版)的 `onChange` 回调参数可能是 `string` 或 `number`
91
+ - 两个版本都使用中文句号(`。`)自动转换为小数点(`.`)
92
+ - 在 Form 中使用时,FormItem 会自动为其添加 `form-control` 类名
93
+ - `forceInnerValue` 属性用于修复输入过程中删除字符时的边界情况,如有异常输入行为可尝试开启
@@ -0,0 +1,181 @@
1
+ # LayoutRoot
2
+
3
+ ## 简介
4
+ 层级根容器组件 - 管理应用中的弹出层(Popup)、抽屉(Drawer)、模态框(Modal)、提示(Tip)、全屏加载(FullLoading)和顶部进度条(NProgress)等层级组件的统一挂载容器。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import LayoutRoot from '@gmfe/react/lib/layout_root'
12
+
13
+ // 在应用根节点渲染
14
+ class App extends React.Component {
15
+ render() {
16
+ return (
17
+ <div>
18
+ {/* 页面内容 */}
19
+ <LayoutRoot />
20
+ </div>
21
+ )
22
+ }
23
+ }
24
+
25
+ // 在其他组件中弹出层
26
+ LayoutRoot.setComponent(LayoutRoot.TYPE.DRAWER, <Drawer>内容</Drawer>)
27
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.DRAWER)
28
+ ```
29
+
30
+ ## API
31
+
32
+ ### 静态方法
33
+
34
+ #### `LayoutRoot.setComponent(type, component)`
35
+ 设置单例层级组件。
36
+
37
+ | 参数 | 说明 | 类型 | 必填 |
38
+ |------|------|------|------|
39
+ | type | 组件类型 | `TYPE` 枚举值 | 是 |
40
+ | component | React 元素 | `ReactElement` | 是 |
41
+
42
+ #### `LayoutRoot.removeComponent(type)`
43
+ 移除单例层级组件。
44
+
45
+ | 参数 | 说明 | 类型 | 必填 |
46
+ |------|------|------|------|
47
+ | type | 组件类型 | `TYPE` 枚举值 | 是 |
48
+
49
+ #### `LayoutRoot._setComponentPopup(id, component)`
50
+ 添加 Popup 弹出层组件(支持多个同时存在)。
51
+
52
+ #### `LayoutRoot._removeComponentPopup(id)`
53
+ 移除指定 id 的 Popup 弹出层组件。
54
+
55
+ #### `LayoutRoot._setComponentTip(id, component)`
56
+ 添加 Tip 提示组件(支持多个同时存在)。
57
+
58
+ #### `LayoutRoot._removeComponentTip(id)`
59
+ 移除指定 id 的 Tip 提示组件。
60
+
61
+ #### `LayoutRoot._removeComponentTipAll()`
62
+ 移除所有 Tip 提示组件。
63
+
64
+ ### TYPE 枚举
65
+
66
+ | 值 | 说明 |
67
+ |------|------|
68
+ | `DRAWER` | 抽屉 |
69
+ | `_POPUP` | 弹出层(内部使用) |
70
+ | `MODAL` | 模态框 |
71
+ | `_TIP` | 提示信息(内部使用) |
72
+ | `FULLLOADING` | 全屏加载 |
73
+ | `NPROGRESS` | 顶部进度条 |
74
+
75
+ ## 示例
76
+
77
+ ### 基础用法 —— 在应用入口挂载
78
+
79
+ ```jsx
80
+ import React from 'react'
81
+ import { render } from 'react-dom'
82
+ import LayoutRoot from '@gmfe/react/lib/layout_root'
83
+ import App from './App'
84
+
85
+ render(
86
+ <div>
87
+ <App />
88
+ <LayoutRoot />
89
+ </div>,
90
+ document.getElementById('root')
91
+ )
92
+ ```
93
+
94
+ ### 显示全屏加载
95
+
96
+ ```jsx
97
+ import { LayoutRoot, LoadingFullScreen } from '@gmfe/react'
98
+
99
+ // 显示全屏加载
100
+ LayoutRoot.setComponent(LayoutRoot.TYPE.FULLLOADING, <LoadingFullScreen />)
101
+
102
+ // 关闭全屏加载
103
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.FULLLOADING)
104
+ ```
105
+
106
+ ### 配合异步操作使用
107
+
108
+ ```jsx
109
+ import React from 'react'
110
+ import { LayoutRoot, LoadingFullScreen } from '@gmfe/react'
111
+
112
+ function SaveButton() {
113
+ const handleSave = async () => {
114
+ LayoutRoot.setComponent(LayoutRoot.TYPE.FULLLOADING, <LoadingFullScreen />)
115
+ try {
116
+ await api.saveData(formData)
117
+ Tip.show('保存成功')
118
+ } catch (e) {
119
+ Tip.show('保存失败')
120
+ } finally {
121
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.FULLLOADING)
122
+ }
123
+ }
124
+
125
+ return <button onClick={handleSave}>保存</button>
126
+ }
127
+ ```
128
+
129
+ ### 使用自定义弹窗内容
130
+
131
+ ```jsx
132
+ // 使用 LayoutRoot 弹出自定义模态框
133
+ LayoutRoot.setComponent(LayoutRoot.TYPE.MODAL, (
134
+ <Modal
135
+ title="确认操作"
136
+ onOK={() => {
137
+ // 处理逻辑
138
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.MODAL)
139
+ }}
140
+ onHide={() => {
141
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.MODAL)
142
+ }}
143
+ >
144
+ <div>确定要执行此操作吗?</div>
145
+ </Modal>
146
+ ))
147
+
148
+ // 关闭模态框
149
+ LayoutRoot.removeComponent(LayoutRoot.TYPE.MODAL)
150
+ ```
151
+
152
+ ### 使用 Popup 多实例
153
+
154
+ ```jsx
155
+ // 添加多个 Popup(支持同时存在)
156
+ LayoutRoot._setComponentPopup('popup-1', <Popover target={ref1}>内容1</Popover>)
157
+ LayoutRoot._setComponentPopup('popup-2', <Popover target={ref2}>内容2</Popover>)
158
+
159
+ // 移除指定 Popup
160
+ LayoutRoot._removeComponentPopup('popup-1')
161
+ ```
162
+
163
+ ### 使用 Tip 多实例
164
+
165
+ ```jsx
166
+ // 添加多个 Tip
167
+ LayoutRoot._setComponentTip('tip-1', <Tip>操作成功</Tip>)
168
+ LayoutRoot._setComponentTip('tip-2', <Tip>数据已更新</Tip>)
169
+
170
+ // 移除指定 Tip
171
+ LayoutRoot._removeComponentTip('tip-1')
172
+
173
+ // 移除所有 Tip
174
+ LayoutRoot._removeComponentTipAll()
175
+ ```
176
+
177
+ ## 注意事项
178
+ - LayoutRoot 必须在应用初始化时挂载,否则调用静态方法时会输出警告:`LayerRoot is uninitialized`
179
+ - 组件有层级关系,从上到下依次为:Popup > Drawer > Modal > Tip > FullLoading > NProgress
180
+ - Popup 和 Tip 支持多个同时存在,Drawer、Modal、FullLoading、NProgress 为单例模式
181
+ - 下划线开头的类型(`_POPUP`、`_TIP`)为内部使用,一般不应直接调用
@@ -0,0 +1,59 @@
1
+ # LazyImg
2
+
3
+ ## 简介
4
+ 懒加载图片组件 - 监听指定容器的滚动事件,当图片进入可视区域时才加载真实图片
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { LazyImg } from '@gmfe/react'
12
+
13
+ <div id="scroll-container" style={{ height: '500px', overflowY: 'auto' }}>
14
+ <LazyImg
15
+ src="real-image.jpg"
16
+ placeholder="placeholder.jpg"
17
+ targetId="scroll-container"
18
+ />
19
+ </div>
20
+ ```
21
+
22
+ ## API
23
+
24
+ ### Props
25
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
26
+ |------|------|------|--------|------|
27
+ | src | 真实图片地址 | `string` | - | 否 |
28
+ | placeholder | 占位图片地址,图片未加载时显示 | `string` | - | 否 |
29
+ | targetId | 指定监听滚动的 DOM 元素的 ID | `string` | - | 是 |
30
+ | delay | 滚动事件防抖延迟时间(毫秒) | `number` | `100` | 否 |
31
+ | className | 自定义类名 | `string` | - | 否 |
32
+
33
+ ## 示例
34
+
35
+ ### 基础用法
36
+ ```jsx
37
+ <div id="scroll-area" style={{ height: '500px', overflowY: 'auto' }}>
38
+ <LazyImg
39
+ src="https://example.com/large-image.jpg"
40
+ placeholder="https://example.com/placeholder.jpg"
41
+ targetId="scroll-area"
42
+ />
43
+ </div>
44
+ ```
45
+
46
+ ### 自定义防抖延迟
47
+ ```jsx
48
+ <LazyImg
49
+ src="image.jpg"
50
+ placeholder="placeholder.jpg"
51
+ targetId="scroll-container"
52
+ delay={200}
53
+ />
54
+ ```
55
+
56
+ ## 注意事项
57
+ - 必须提供 `targetId`,对应一个存在的 DOM 元素的 ID
58
+ - 如果找不到指定 ID 的 DOM 元素,会在控制台输出错误信息
59
+ - 图片加载完成后会自动移除滚动事件监听,避免内存泄漏
@@ -0,0 +1,75 @@
1
+ # LevelList
2
+
3
+ ## 简介
4
+ 级联列表组件 - 用于展示多级联动列表,支持鼠标悬浮自动展开和反向排列
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { LevelList } from '@gmfe/react'
12
+
13
+ <LevelList
14
+ data={data}
15
+ selected={selected}
16
+ onSelect={selected => setSelected(selected)}
17
+ willActiveSelected={willActiveSelected}
18
+ onWillActiveSelect={willActiveSelected => setWillActiveSelected(willActiveSelected)}
19
+ />
20
+ ```
21
+
22
+ ## API
23
+
24
+ ### Props
25
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
26
+ |------|------|------|--------|------|
27
+ | data | 数据源,格式:`[{value, text, children}]`,支持多级嵌套 | `array` | - | 是 |
28
+ | selected | 已选中的 value 数组 | `array` | - | 是 |
29
+ | onSelect | 选中回调 | `function` | - | 是 |
30
+ | willActiveSelected | 预激活的 value 数组,用于鼠标悬浮预选 | `array` | - | 是 |
31
+ | onWillActiveSelect | 预激活值变化回调 | `function` | - | 是 |
32
+ | titles | 各级列的标题数组 | `array` | `[]` | 否 |
33
+ | onlySelectLeaf | 是否仅能选择叶子节点(TODO) | `bool` | - | 否 |
34
+ | isReverse | 是否反向排列(从右向左) | `bool` | `false` | 否 |
35
+ | className | 自定义类名 | `string` | - | 否 |
36
+ | style | 自定义样式 | `object` | - | 否 |
37
+ | isForFunctionSet | 内部使用,用于 FunctionSet 组件 | `bool` | `false` | 否 |
38
+
39
+ ## 示例
40
+
41
+ ### 基础用法
42
+ ```jsx
43
+ <LevelList
44
+ data={[
45
+ {
46
+ value: '1',
47
+ text: '南山',
48
+ children: [
49
+ { value: '11', text: '科技园' },
50
+ { value: '12', text: '西丽' }
51
+ ]
52
+ }
53
+ ]}
54
+ selected={selected}
55
+ onSelect={selected => setSelected(selected)}
56
+ willActiveSelected={willActiveSelected}
57
+ onWillActiveSelect={willActiveSelected => setWillActiveSelected(willActiveSelected)}
58
+ />
59
+ ```
60
+
61
+ ### 反向排列
62
+ ```jsx
63
+ <LevelList
64
+ data={data}
65
+ selected={selected}
66
+ onSelect={selected => setSelected(selected)}
67
+ willActiveSelected={willActiveSelected}
68
+ onWillActiveSelect={willActiveSelected => setWillActiveSelected(willActiveSelected)}
69
+ isReverse
70
+ />
71
+ ```
72
+
73
+ ## 注意事项
74
+ - `willActiveSelected` 和 `onWillActiveSelect` 需要配合使用,实现鼠标悬浮预选效果
75
+ - `isReverse` 适用于右对齐的场景
@@ -0,0 +1,78 @@
1
+ # LevelSelect
2
+
3
+ ## 简介
4
+ 级联选择器组件 - 下拉面板式多级联动选择器,支持键盘方向键导航和自定义渲染
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { LevelSelect } from '@gmfe/react'
12
+
13
+ <LevelSelect
14
+ data={data}
15
+ selected={selected}
16
+ onSelect={value => setSelected(value)}
17
+ />
18
+ ```
19
+
20
+ ## API
21
+
22
+ ### Props
23
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
24
+ |------|------|------|--------|------|
25
+ | data | 数据源,格式:`[{value, text, children}]`,支持多级嵌套 | `array` | - | 是 |
26
+ | selected | 已选中的 value 数组 | `array` | - | 是 |
27
+ | onSelect | 选中回调 | `function` | - | 是 |
28
+ | titles | 各级列的标题数组 | `array` | - | 否 |
29
+ | disabled | 是否禁用 | `bool` | - | 否 |
30
+ | renderSelected | 自定义已选区域的展示,参数为选中的 item 数组 | `function` | `(items) => items.map(v => v.text).join(',')` | 否 |
31
+ | onlySelectLeaf | 是否仅能选择叶子节点 | `bool` | - | 否 |
32
+ | popoverType | 弹出框触发方式 | `'focus' \| 'realFocus'` | - | 否 |
33
+ | right | 下拉面板是否右对齐 | `bool` | `false` | 否 |
34
+ | onKeyDown | 键盘事件回调 | `function` | `_.noop` | 否 |
35
+ | placeholder | 占位文本 | `string` | - | 否 |
36
+
37
+ ## 示例
38
+
39
+ ### 基础用法
40
+ ```jsx
41
+ <LevelSelect
42
+ data={[
43
+ {
44
+ value: 'A',
45
+ text: '广州',
46
+ children: [
47
+ { value: 1, text: '越秀' },
48
+ { value: 2, text: '天河' }
49
+ ]
50
+ },
51
+ {
52
+ value: 'B',
53
+ text: '深圳',
54
+ children: [
55
+ { value: 1, text: '福田' },
56
+ { value: 2, text: '南山' }
57
+ ]
58
+ }
59
+ ]}
60
+ selected={selected}
61
+ onSelect={value => setSelected(value)}
62
+ />
63
+ ```
64
+
65
+ ### 右对齐
66
+ ```jsx
67
+ <LevelSelect
68
+ data={data}
69
+ selected={selected}
70
+ onSelect={value => setSelected(value)}
71
+ right
72
+ />
73
+ ```
74
+
75
+ ## 注意事项
76
+ - 支持键盘方向键导航:上下键切换选项,左右键切换级别
77
+ - 内部使用 `Popover` 和 `LevelList` 组件
78
+ - 选中项会以逗号分隔展示