@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,72 @@
1
+ # Price
2
+
3
+ ## 简介
4
+ 价格显示组件 - 带货币符号的价格格式化组件,支持千分符、精度控制、多币种和分单位
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Price } from '@gmfe/react'
12
+
13
+ <Price value={10839} />
14
+ ```
15
+
16
+ ## API
17
+
18
+ ### Props
19
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
20
+ |------|------|------|--------|------|
21
+ | value | 价格数值(负数会自动显示负号) | `number` | - | 是 |
22
+ | precision | 保留几位小数 | `number` | `2` | 否 |
23
+ | useGrouping | 是否使用千分符 | `bool` | `true` | 否 |
24
+ | currencyScale | 货币符号的缩放大小(em 单位),大于 1 时按 1em 显示 | `number` | `0.85` | 否 |
25
+ | keepZero | 是否保留小数点后无效的零 | `bool` | `true` | 否 |
26
+ | isFenUnit | value 是否为分单位(会自动除以 100) | `bool` | `false` | 否 |
27
+ | feeType | 多币种类型标识 | `string` | `''` | 否 |
28
+
29
+ ### 静态方法
30
+ | 方法 | 说明 |
31
+ |------|------|
32
+ | `Price.setCurrency(symbol)` | 设置货币符号 |
33
+ | `Price.getCurrency(type?)` | 获取货币符号 |
34
+ | `Price.setUnit(unit)` | 设置货币单位 |
35
+ | `Price.getUnit(type?)` | 获取货币单位 |
36
+ | `Price.setCurrencyList(list)` | 设置多币种列表,格式:`[{symbol, type, unit}]` |
37
+
38
+ ## 示例
39
+
40
+ ### 基础用法
41
+ ```jsx
42
+ <Price value={10839} /> // ¥10,839.00
43
+ <Price value={-10} /> // -¥10.00
44
+ <Price value={10000000} /> // ¥10,000,000.00
45
+ ```
46
+
47
+ ### 分单位
48
+ ```jsx
49
+ <Price isFenUnit value={1234} /> // ¥12.34
50
+ ```
51
+
52
+ ### 自定义货币符号缩放
53
+ ```jsx
54
+ <Price value={40002288} currencyScale={0.8} />
55
+ ```
56
+
57
+ ### 多币种
58
+ ```jsx
59
+ // 先设置币种列表
60
+ Price.setCurrencyList([
61
+ { symbol: '¥', type: 'CNY', unit: '元' },
62
+ { symbol: '$', type: 'USD', unit: 'dollar' }
63
+ ])
64
+
65
+ // 使用
66
+ <Price value={100} feeType="USD" /> // $100.00
67
+ ```
68
+
69
+ ## 注意事项
70
+ - 货币符号通过 `Price.setCurrency()` 设置后会持久化到 localStorage
71
+ - 货币符号变化时会自动刷新所有 Price 组件
72
+ - `feeType` 和静态方法配合使用可实现多币种切换
@@ -0,0 +1,98 @@
1
+ # Progress
2
+
3
+ ## 简介
4
+ 进度条组件 - 用于展示操作进度的线性进度条,支持自定义颜色、粗细、文字显示位置和状态
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Progress } from '@gmfe/react'
12
+ ```
13
+
14
+ ## API
15
+
16
+ ### Props
17
+
18
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
19
+ |------|------|------|--------|------|
20
+ | percentage | 进度百分比,取值范围 0~100 | `number` | - | 是 |
21
+ | text | 自定义显示文字,不传则显示百分比 | `string` | - | 否 |
22
+ | status | 进度条状态 | `'success' \| 'exception'` | - | 否 |
23
+ | strokeWidth | 进度条高度(像素) | `number` | - | 否 |
24
+ | textInside | 是否将文字显示在进度条内部 | `bool` | `false` | 否 |
25
+ | textInsideFix | 文字在进度条内部的对齐方式(需配合 `textInside` 使用) | `'left' \| 'right' \| 'center'` | - | 否 |
26
+ | showText | 是否显示文字 | `bool` | `true` | 否 |
27
+ | className | 自定义类名 | `string` | - | 否 |
28
+ | textColor | 文字颜色 | `string` | - | 否 |
29
+ | strokeColor | 进度条颜色 | `string` | - | 否 |
30
+ | bgColor | 进度条背景颜色 | `string` | - | 否 |
31
+
32
+ ## 示例
33
+
34
+ ### 基础用法
35
+
36
+ ```jsx
37
+ <Progress percentage={30} />
38
+ <Progress percentage={70} />
39
+ <Progress percentage={100} />
40
+ ```
41
+
42
+ ### 不显示文字
43
+
44
+ ```jsx
45
+ <Progress percentage={50} showText={false} />
46
+ ```
47
+
48
+ ### 自定义文字
49
+
50
+ ```jsx
51
+ <Progress percentage={20} text='20斤/100斤' strokeWidth={18} />
52
+ ```
53
+
54
+ ### 文字内置
55
+
56
+ ```jsx
57
+ // 文字显示在进度条内部
58
+ <Progress percentage={70} textInside strokeWidth={18} />
59
+ ```
60
+
61
+ ### 文字内对齐方式
62
+
63
+ ```jsx
64
+ <Progress percentage={70} textInside textInsideFix='center' strokeWidth={18} />
65
+ <Progress percentage={70} textInside textInsideFix='left' strokeWidth={18} />
66
+ <Progress percentage={70} textInside textInsideFix='right' strokeWidth={18} />
67
+ ```
68
+
69
+ ### 自定义颜色
70
+
71
+ ```jsx
72
+ <Progress
73
+ percentage={70}
74
+ textInside
75
+ textInsideFix='center'
76
+ strokeWidth={18}
77
+ textColor='black'
78
+ strokeColor='orange'
79
+ bgColor='lightgray'
80
+ />
81
+ ```
82
+
83
+ ### 状态展示
84
+
85
+ ```jsx
86
+ // 成功状态 - 显示绿色和对勾图标
87
+ <Progress percentage={100} status='success' />
88
+
89
+ // 异常状态 - 显示红色和错误图标
90
+ <Progress percentage={50} status='exception' />
91
+ ```
92
+
93
+ ## 注意事项
94
+
95
+ - `percentage` 为必填属性,取值范围 0~100。
96
+ - 设置 `status='success'` 时进度条变为绿色并显示对勾图标,`status='exception'` 时进度条变为红色并显示错误图标。状态图标仅在文字显示在进度条外部(`textInside=false`)时可见。
97
+ - `textInsideFix` 仅在 `textInside` 为 `true` 时生效,可控制文字在进度条内部的对齐方向。
98
+ - `textInside` 设为 `true` 时建议同时设置 `strokeWidth` 以确保进度条有足够的高度容纳文字。
@@ -0,0 +1,92 @@
1
+ # ProgressCircle
2
+
3
+ ## 简介
4
+ 环形进度条组件 - 使用 SVG 绘制的圆环进度指示器,支持自定义大小、颜色、线宽和文字位置
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { ProgressCircle } from '@gmfe/react'
12
+ ```
13
+
14
+ ## API
15
+
16
+ ### Props
17
+
18
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
19
+ |------|------|------|--------|------|
20
+ | percentage | 进度百分比,取值范围 0~100 | `number` | `0` | 否 |
21
+ | text | 自定义显示文字,不传则显示百分比 | `string` | - | 否 |
22
+ | showText | 是否显示文字 | `bool` | `true` | 否 |
23
+ | textPosition | 文字显示位置 | `'left' \| 'center' \| 'right'` | `'center'` | 否 |
24
+ | status | 进度条状态 | `'success' \| 'exception'` | `'success'` | 否 |
25
+ | size | 圆环整体尺寸(像素) | `string \| number` | `'40'` | 否 |
26
+ | lineWidth | 圆环线条宽度 | `string \| number` | `'60'` | 否 |
27
+ | progressColor | 进度条颜色 | `string` | - | 否 |
28
+ | bgColor | 背景圆环颜色 | `string` | `'#e4e8f1'` | 否 |
29
+
30
+ ## 示例
31
+
32
+ ### 基础用法
33
+
34
+ ```jsx
35
+ <ProgressCircle percentage={60} />
36
+ <ProgressCircle percentage={80} status='exception' />
37
+ ```
38
+
39
+ ### 不显示文字
40
+
41
+ ```jsx
42
+ <ProgressCircle percentage={50} showText={false} />
43
+ <ProgressCircle percentage={80} status='exception' showText={false} />
44
+ ```
45
+
46
+ ### 自定义文字和位置
47
+
48
+ ```jsx
49
+ // 文字在右侧
50
+ <ProgressCircle percentage={75} textPosition='right' />
51
+
52
+ // 文字在左侧,自定义文字
53
+ <ProgressCircle percentage={60} textPosition='left' text='60/100' />
54
+ ```
55
+
56
+ ### 自定义大小和线宽
57
+
58
+ ```jsx
59
+ // 大尺寸
60
+ <ProgressCircle percentage={80} size='100' />
61
+
62
+ // 细线条
63
+ <ProgressCircle percentage={80} size='100' lineWidth={20} />
64
+ ```
65
+
66
+ ### 自定义颜色
67
+
68
+ ```jsx
69
+ <ProgressCircle
70
+ percentage={80}
71
+ size='100'
72
+ lineWidth={20}
73
+ progressColor='orange'
74
+ />
75
+
76
+ <ProgressCircle
77
+ percentage={80}
78
+ size='100'
79
+ lineWidth={20}
80
+ progressColor='orange'
81
+ bgColor='gray'
82
+ />
83
+ ```
84
+
85
+ ## 注意事项
86
+
87
+ - ProgressCircle 使用 SVG 绘制,内部固定 viewBox 为 `300x300`,通过 `size` 属性控制实际渲染尺寸。
88
+ - 默认状态为 `success`(绿色),可设为 `exception`(红色)来表示异常状态。
89
+ - `textPosition='center'` 时文字渲染在圆环中央(SVG text 元素),`left` 和 `right` 时文字显示在圆环外侧。
90
+ - `lineWidth` 控制圆环线条的粗细,值越大圆环越粗。当线条较粗时,建议使用较小的值以避免线条溢出。
91
+ - `size` 和 `lineWidth` 支持 `string` 和 `number` 类型。
92
+ - 百分比超过 100 时会被自动限制为 100。
@@ -0,0 +1,101 @@
1
+ # Radio
2
+
3
+ ## 简介
4
+ 单选框组件 - 用于单选场景,支持单个使用和分组使用(RadioGroup)。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Radio, RadioGroup } from '@gmfe/react'
12
+
13
+ // 单个使用
14
+ <Radio checked onChange={onChange}>选项</Radio>
15
+
16
+ // 分组使用
17
+ <RadioGroup name='city' value={value} onChange={setValue}>
18
+ <Radio value={1}>广州</Radio>
19
+ <Radio value={2}>深圳</Radio>
20
+ <Radio value={3}>成都</Radio>
21
+ </RadioGroup>
22
+ ```
23
+
24
+ ## API
25
+
26
+ ### Radio Props
27
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
28
+ |------|------|------|--------|------|
29
+ | checked | 是否选中 | `bool` | - | 否 |
30
+ | onChange | 变化回调 | `func` | `_.noop` | 否 |
31
+ | onClick | 点击回调 | `func` | `_.noop` | 否 |
32
+ | value | 选项值,配合 RadioGroup 使用 | `any` | - | 否 |
33
+ | children | 显示文本 | `any` | - | 否 |
34
+ | disabled | 是否禁用 | `bool` | - | 否 |
35
+ | inline | 是否行内显示 | `bool` | - | 否 |
36
+ | block | 是否整行可点击 | `bool` | - | 否 |
37
+ | name | input name 属性 | `string` | - | 否 |
38
+ | className | 自定义类名 | `string` | - | 否 |
39
+ | style | 自定义样式 | `object` | - | 否 |
40
+
41
+ ### RadioGroup Props
42
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
43
+ |------|------|------|--------|------|
44
+ | name | 表单名称,必填 | `string` | - | 是 |
45
+ | value | 当前选中的值 | `any` | - | 否 |
46
+ | onChange | 变化回调,参数为选中的 value | `func` | `_.noop` | 否 |
47
+ | inline | 是否行内显示 | `bool` | - | 否 |
48
+ | children | Radio 子组件 | `any` | - | 否 |
49
+ | className | 自定义类名 | `string` | - | 否 |
50
+ | style | 自定义样式 | `object` | - | 否 |
51
+
52
+ ## 示例
53
+
54
+ ### 基础用法
55
+ ```jsx
56
+ <Radio checked>选中状态</Radio>
57
+ <Radio>未选中状态</Radio>
58
+ ```
59
+
60
+ ### 禁用状态
61
+ ```jsx
62
+ <Radio checked disabled>选中禁用</Radio>
63
+ <Radio disabled>未选中禁用</Radio>
64
+ ```
65
+
66
+ ### 行内显示
67
+ ```jsx
68
+ <Radio checked inline>选项1</Radio>
69
+ <Radio inline>选项2</Radio>
70
+ ```
71
+
72
+ ### 整行可点击
73
+ ```jsx
74
+ <Radio
75
+ block
76
+ checked={checked}
77
+ onChange={() => setChecked(!checked)}
78
+ >
79
+ 整行都可以点击
80
+ </Radio>
81
+ ```
82
+
83
+ ### 分组使用
84
+ ```jsx
85
+ <RadioGroup
86
+ name='city'
87
+ value={value}
88
+ onChange={value => console.log(value)}
89
+ >
90
+ <Radio value={1}>广州</Radio>
91
+ <Radio value={2}>深圳</Radio>
92
+ <Radio value={3} disabled>成都</Radio>
93
+ </RadioGroup>
94
+ ```
95
+
96
+ ## 注意事项
97
+ - `RadioGroup` 的 `name` 属性为必填项
98
+ - `RadioGroup` 内部会自动管理选中状态,通过 `value` 和 `onChange` 控制受控模式
99
+ - `block` 模式下整行都可以触发选中操作
100
+ - 非行内模式下,每个 Radio 独占一行
101
+ - `RadioGroup` 的 `onChange` 回调参数为选中项的 `value` 值
@@ -0,0 +1,75 @@
1
+ # RecommendInput
2
+
3
+ ## 简介
4
+ 推荐输入组件 - 输入时展示推荐列表的下拉输入框,支持拼音搜索过滤
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { RecommendInput } from '@gmfe/react'
12
+
13
+ <RecommendInput
14
+ data={[{ text: '选项1' }, { text: '选项2' }]}
15
+ value={value}
16
+ onChange={value => setValue(value)}
17
+ placeholder="请输入"
18
+ />
19
+ ```
20
+
21
+ ## API
22
+
23
+ ### Props
24
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
25
+ |------|------|------|--------|------|
26
+ | data | 推荐列表的数据,格式:`[{ text: 'text1' }, { text: 'text2' }, ...]` | `array` | - | 是 |
27
+ | value | 输入框的值 | `string` | - | 是 |
28
+ | onChange | 值变化回调,参数为 `value` | `function` | - | 是 |
29
+ | disabled | 是否禁用 | `bool` | - | 否 |
30
+ | listHeight | 推荐列表高度 | `string` | `'180px'` | 否 |
31
+ | inputMaxLength | 输入框最大字符数 | `number` | - | 否 |
32
+ | placeholder | 占位文本 | `string` | - | 否 |
33
+ | className | 自定义类名 | `string` | - | 否 |
34
+
35
+ ## 示例
36
+
37
+ ### 基础用法
38
+ ```jsx
39
+ <RecommendInput
40
+ data={[
41
+ { text: '选项1' },
42
+ { text: '选项2' },
43
+ { text: '选项3' }
44
+ ]}
45
+ value={value}
46
+ onChange={value => setValue(value)}
47
+ placeholder="请输入"
48
+ />
49
+ ```
50
+
51
+ ### 禁用状态
52
+ ```jsx
53
+ <RecommendInput
54
+ data={data}
55
+ value={value}
56
+ onChange={value => setValue(value)}
57
+ disabled
58
+ />
59
+ ```
60
+
61
+ ### 限制输入长度
62
+ ```jsx
63
+ <RecommendInput
64
+ data={data}
65
+ value={value}
66
+ onChange={value => setValue(value)}
67
+ inputMaxLength={15}
68
+ />
69
+ ```
70
+
71
+ ## 注意事项
72
+ - 输入时支持拼音搜索过滤推荐列表
73
+ - 选择推荐项后会自动关闭下拉列表
74
+ - 输入框右侧有清除按钮,点击可清空输入内容
75
+ - 弹出框使用 `realFocus` 触发模式,输入框获取焦点时自动展示
@@ -0,0 +1,120 @@
1
+ # Select
2
+
3
+ ## 简介
4
+ 下拉选择组件 - 通过弹出层展示选项列表,支持键盘上下键选择、禁用选项和清除功能。
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Select } from '@gmfe/react'
12
+
13
+ const list = [
14
+ { value: 0, text: '南山' },
15
+ { value: 1, text: '福田' },
16
+ { value: 2, text: '宝安' },
17
+ { value: 3, text: '宝安不可用', disabled: true },
18
+ { value: 4, text: '罗湖' }
19
+ ]
20
+
21
+ <Select
22
+ data={list}
23
+ value={value}
24
+ onChange={setValue}
25
+ />
26
+ ```
27
+
28
+ ## API
29
+
30
+ ### Select Props
31
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
32
+ |------|------|------|--------|------|
33
+ | data | 选项数据,每项包含 text、value、disabled | `array` | - | 是 |
34
+ | value | 当前选中的值 | `any` | - | 是 |
35
+ | onChange | 选择变化回调,参数为选中的 value | `func` | - | 是 |
36
+ | disabled | 是否禁用 | `bool` | - | 否 |
37
+ | canShowClose | 是否显示清除按钮 | `bool` | `false` | 否 |
38
+ | clean | 清洁模式 | `bool` | - | 否 |
39
+ | listProps | 传递给列表组件的属性 | `object` | - | 否 |
40
+ | popoverType | 弹出层触发方式 | `'focus' \| 'realFocus'` | - | 否 |
41
+ | isInPopup | 是否在弹出层中 | `bool` | - | 否 |
42
+ | onKeyDown | 键盘事件回调 | `func` | `_.noop` | 否 |
43
+ | className | 自定义类名 | `string` | - | 否 |
44
+ | style | 自定义样式 | `object` | - | 否 |
45
+ | children | 兼容旧用法,使用 Option 子组件 | `any` | - | 否 |
46
+
47
+ ### Option Props(已废弃)
48
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
49
+ |------|------|------|--------|------|
50
+ | value | 选项值 | `any` | - | 否 |
51
+ | disabled | 是否禁用 | `bool` | - | 否 |
52
+ | children | 选项显示文本 | `any` | - | 否 |
53
+ | className | 自定义类名 | `string` | - | 否 |
54
+ | style | 自定义样式 | `object` | - | 否 |
55
+
56
+ ### 方法(通过 ref 调用)
57
+ | 方法 | 说明 |
58
+ |------|------|
59
+ | apiDoFocus | 聚焦到选择框 |
60
+ | apiDoSelectWillActive | 选择键盘高亮的当前项 |
61
+
62
+ ## 示例
63
+
64
+ ### 基础用法
65
+ ```jsx
66
+ const list = [
67
+ { value: 0, text: '南山' },
68
+ { value: 1, text: '福田' },
69
+ { value: 2, text: '宝安' }
70
+ ]
71
+
72
+ <Select
73
+ data={list}
74
+ value={value}
75
+ onChange={setValue}
76
+ />
77
+ ```
78
+
79
+ ### 禁用选项
80
+ ```jsx
81
+ const list = [
82
+ { value: 0, text: '南山' },
83
+ { value: 1, text: '福田' },
84
+ { value: 2, text: '宝安', disabled: true }
85
+ ]
86
+
87
+ <Select
88
+ data={list}
89
+ value={value}
90
+ onChange={setValue}
91
+ />
92
+ ```
93
+
94
+ ### 可清除
95
+ ```jsx
96
+ <Select
97
+ data={list}
98
+ value={value}
99
+ onChange={setValue}
100
+ canShowClose
101
+ />
102
+ ```
103
+
104
+ ### 清洁模式
105
+ ```jsx
106
+ <Select
107
+ clean
108
+ data={list}
109
+ value={value}
110
+ onChange={setValue}
111
+ />
112
+ ```
113
+
114
+ ## 注意事项
115
+ - 推荐使用 `data` 属性传入选项数据,`Option` 子组件方式已废弃
116
+ - 选项数据格式为 `[{ value, text, disabled }]`,其中 `disabled` 可选
117
+ - `canShowClose` 属性允许用户清除已选值
118
+ - 支持键盘上下键切换选项
119
+ - 列表最大高度为 `250px`,超出部分可滚动
120
+ - 弹出层默认使用 Popover 组件
@@ -0,0 +1,87 @@
1
+ # Selection
2
+
3
+ ## 简介
4
+ 选择器基础组件 - 可作为输入框形式的选择器,支持清除、干净模式等多种形态
5
+
6
+ ## 安装
7
+ 已包含在 `@gmfe/react` 中,无需额外安装。
8
+
9
+ ## 使用
10
+ ```jsx
11
+ import { Selection } from '@gmfe/react'
12
+
13
+ <Selection
14
+ selected={selected}
15
+ onSelect={selected => setSelected(selected)}
16
+ placeholder="请选择"
17
+ />
18
+ ```
19
+
20
+ ## API
21
+
22
+ ### Props
23
+ | 属性 | 说明 | 类型 | 默认值 | 必填 |
24
+ |------|------|------|--------|------|
25
+ | selected | 单选情况为 `null` 或 `{value, text}` 对象 | `any` | - | 否 |
26
+ | onSelect | 选中回调 | `function` | - | 是 |
27
+ | disabled | 是否禁用 | `bool` | - | 否 |
28
+ | renderSelected | 自定义选中项的展示,参数为 `selected` | `function` | `(item) => item.text` | 否 |
29
+ | placeholder | 占位文本 | `string` | - | 否 |
30
+ | funIcon | 代替默认的箭头图标 | `element` | - | 否 |
31
+ | clean | 干净模式,隐藏右侧图标和关闭按钮 | `bool` | `false` | 否 |
32
+ | disabledClose | 禁用关闭(x)按钮 | `bool` | `false` | 否 |
33
+ | onKeyDown | 键盘事件回调 | `function` | - | 否 |
34
+ | className | 自定义类名 | `string` | - | 否 |
35
+ | style | 自定义样式 | `object` | - | 否 |
36
+ | isForSelect | 给 Select 定制的标记,使用 div 代替 input | `bool` | `false` | 否 |
37
+
38
+ ## 示例
39
+
40
+ ### 基础用法
41
+ ```jsx
42
+ <Selection
43
+ onSelect={selected => console.log(selected)}
44
+ placeholder="请选择"
45
+ />
46
+ ```
47
+
48
+ ### 已选中状态
49
+ ```jsx
50
+ <Selection
51
+ selected={{ value: 0, text: '选中项' }}
52
+ onSelect={selected => console.log(selected)}
53
+ />
54
+ ```
55
+
56
+ ### 自定义选中项展示
57
+ ```jsx
58
+ <Selection
59
+ selected={{ value: 0, text: '选中项' }}
60
+ onSelect={selected => console.log(selected)}
61
+ renderSelected={item => item.text + 'lalala'}
62
+ />
63
+ ```
64
+
65
+ ### 干净模式
66
+ ```jsx
67
+ <Selection
68
+ clean
69
+ selected={{ value: 0, text: '选中项' }}
70
+ onSelect={selected => console.log(selected)}
71
+ placeholder="请选择"
72
+ />
73
+ ```
74
+
75
+ ### 禁用关闭按钮
76
+ ```jsx
77
+ <Selection
78
+ disabledClose
79
+ selected={{ value: 0, text: '选中项' }}
80
+ onSelect={selected => console.log(selected)}
81
+ />
82
+ ```
83
+
84
+ ## 注意事项
85
+ - 这是基础组件,通常不单独使用,而是作为 `LevelSelect`、`TimeSpanPicker` 等组件的内部组件
86
+ - 选中后显示关闭按钮(x),点击可清除选中状态
87
+ - 默认右侧有上下箭头图标,选中状态下箭头图标会左移