@aloudata/aloudata-design 0.1.0-beta1 → 0.1.1
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 +22 -13
- package/es/Button/demo/Icon/index.d.ts +3 -0
- package/es/Button/demo/Icon/index.js +67 -0
- package/{src → es}/Button/demo/Icon/index.less +0 -0
- package/es/Button/demo/basic/index.d.ts +4 -0
- package/es/Button/demo/basic/index.js +57 -0
- package/{src → es}/Button/demo/basic/index.less +0 -1
- package/es/Button/demo/disable/index.d.ts +3 -0
- package/es/Button/demo/disable/index.js +23 -0
- package/{src → es}/Button/demo/disable/index.less +0 -0
- package/es/Button/demo/href/index.d.ts +2 -0
- package/es/Button/demo/href/index.js +17 -0
- package/es/Button/demo/loading/index.d.ts +3 -0
- package/es/Button/demo/loading/index.js +37 -0
- package/{src → es}/Button/demo/loading/index.less +0 -0
- package/es/Button/index.d.ts +50 -0
- package/es/Button/index.js +108 -0
- package/es/Button/style/index.d.ts +2 -0
- package/es/Button/style/index.js +2 -0
- package/{src → es}/Button/style/index.less +5 -5
- package/es/Dropdown/Button.d.ts +69 -0
- package/es/Dropdown/Button.js +39 -0
- package/es/Dropdown/demo/basic/index.d.ts +4 -0
- package/es/Dropdown/demo/basic/index.js +18 -0
- package/es/Dropdown/demo/button/index.d.ts +3 -0
- package/es/Dropdown/demo/button/index.js +159 -0
- package/{src → es}/Dropdown/demo/button/index.less +0 -0
- package/es/Dropdown/demo/placement/index.d.ts +2 -0
- package/es/Dropdown/demo/placement/index.js +40 -0
- package/es/Dropdown/demo/subMenu/index.d.ts +2 -0
- package/es/Dropdown/demo/subMenu/index.js +42 -0
- package/es/Dropdown/demo/trigger/index.d.ts +2 -0
- package/es/Dropdown/demo/trigger/index.js +17 -0
- package/es/Dropdown/index.d.ts +59 -0
- package/es/Dropdown/index.js +33 -0
- package/es/Dropdown/style/index.d.ts +2 -0
- package/es/Dropdown/style/index.js +2 -0
- package/{src → es}/Dropdown/style/index.less +0 -0
- package/{src → es}/Icon/iconfont/demo.css +0 -0
- package/{src → es}/Icon/iconfont/demo_index.html +49 -3
- package/es/Icon/iconfont/iconfont.css +101 -0
- package/es/Icon/iconfont/iconfont.js +46 -0
- package/{src → es}/Icon/iconfont/iconfont.json +14 -0
- package/es/Icon/iconfont/iconfont.ttf +0 -0
- package/es/Icon/iconfont/iconfont.woff +0 -0
- package/es/Icon/iconfont/iconfont.woff2 +0 -0
- package/es/Icon/index.d.ts +11 -0
- package/es/Icon/index.js +42 -0
- package/{src → es}/Icon/index.less +3 -3
- package/es/Input/components/Group/index.d.ts +15 -0
- package/es/Input/components/Group/index.js +12 -0
- package/es/Input/components/Password/index.d.ts +10 -0
- package/es/Input/components/Password/index.js +20 -0
- package/es/Input/components/TextArea/index.d.ts +52 -0
- package/es/Input/components/TextArea/index.js +14 -0
- package/es/Input/demo/allowClear/index.d.ts +3 -0
- package/es/Input/demo/allowClear/index.js +11 -0
- package/{src → es}/Input/demo/allowClear/index.less +0 -0
- package/es/Input/demo/basic/index.d.ts +4 -0
- package/es/Input/demo/basic/index.js +65 -0
- package/{src → es}/Input/demo/basic/index.less +1 -1
- package/es/Input/demo/gourp/index.d.ts +2 -0
- package/es/Input/demo/gourp/index.js +67 -0
- package/es/Input/demo/password/index.d.ts +3 -0
- package/es/Input/demo/password/index.js +21 -0
- package/{src → es}/Input/demo/password/index.less +0 -0
- package/es/Input/demo/prefix/index.d.ts +3 -0
- package/es/Input/demo/prefix/index.js +17 -0
- package/{src → es}/Input/demo/prefix/index.less +0 -0
- package/es/Input/demo/showCount/index.d.ts +3 -0
- package/es/Input/demo/showCount/index.js +17 -0
- package/{src → es}/Input/demo/showCount/index.less +0 -0
- package/es/Input/demo/textArea/autoSize.d.ts +2 -0
- package/es/Input/demo/textArea/autoSize.js +50 -0
- package/es/Input/index.d.ts +65 -0
- package/es/Input/index.js +46 -0
- package/es/Input/style/index.d.ts +2 -0
- package/es/Input/style/index.js +2 -0
- package/{src → es}/Input/style/index.less +4 -1
- package/es/Menu/Divider.d.ts +5 -0
- package/es/Menu/Divider.js +15 -0
- package/es/Menu/MenuItem.d.ts +17 -0
- package/es/Menu/MenuItem.js +15 -0
- package/es/Menu/SubMenu.d.ts +26 -0
- package/es/Menu/SubMenu.js +29 -0
- package/es/Menu/index.d.ts +20 -0
- package/es/Menu/index.js +31 -0
- package/es/Menu/style/index.d.ts +2 -0
- package/es/Menu/style/index.js +2 -0
- package/{src → es}/Menu/style/index.less +0 -0
- package/es/Select/BaseSelect.d.ts +5 -0
- package/es/Select/BaseSelect.js +400 -0
- package/{src/Select/OptionsList/OptGroup.tsx → es/Select/OptionsList/OptGroup.d.ts} +2 -4
- package/es/Select/OptionsList/OptGroup.js +6 -0
- package/es/Select/OptionsList/OptionItem/RenderGroup.d.ts +9 -0
- package/es/Select/OptionsList/OptionItem/RenderGroup.js +16 -0
- package/es/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +8 -0
- package/es/Select/OptionsList/OptionItem/RenderLabelIcon.js +44 -0
- package/es/Select/OptionsList/OptionItem/RenderOption.d.ts +16 -0
- package/es/Select/OptionsList/OptionItem/RenderOption.js +79 -0
- package/es/Select/OptionsList/OptionItem/RenderTooltip.d.ts +8 -0
- package/es/Select/OptionsList/OptionItem/RenderTooltip.js +25 -0
- package/es/Select/OptionsList/OptionItem.d.ts +4 -0
- package/es/Select/OptionsList/OptionItem.js +4 -0
- package/es/Select/OptionsList/Options.d.ts +7 -0
- package/es/Select/OptionsList/Options.js +6 -0
- package/es/Select/OptionsList/index.d.ts +4 -0
- package/es/Select/OptionsList/index.js +187 -0
- package/es/Select/Selector/index.d.ts +4 -0
- package/es/Select/Selector/index.js +252 -0
- package/es/Select/VirtualList.d.ts +5 -0
- package/es/Select/VirtualList.js +29 -0
- package/es/Select/demo/disabled/index.d.ts +2 -0
- package/es/Select/demo/disabled/index.js +50 -0
- package/es/Select/demo/multiple/index.d.ts +2 -0
- package/es/Select/demo/multiple/index.js +140 -0
- package/es/Select/demo/options/index.d.ts +2 -0
- package/es/Select/demo/options/index.js +55 -0
- package/es/Select/demo/single/index.d.ts +3 -0
- package/es/Select/demo/single/index.js +89 -0
- package/es/Select/demo/single/index.less +5 -0
- package/es/Select/hooks/useCacheOption.d.ts +9 -0
- package/es/Select/hooks/useCacheOption.js +107 -0
- package/es/Select/index.d.ts +12 -0
- package/es/Select/index.js +9 -0
- package/es/Select/interface.d.ts +227 -0
- package/es/Select/interface.js +1 -0
- package/es/Select/style/index.d.ts +2 -0
- package/es/Select/style/index.js +2 -0
- package/{src → es}/Select/style/index.less +3 -10
- package/es/Select/utils.d.ts +21 -0
- package/es/Select/utils.js +193 -0
- package/es/Tabs/TabPane.d.ts +21 -0
- package/es/Tabs/TabPane.js +12 -0
- package/es/Tabs/demo/adaptHeight/index.d.ts +3 -0
- package/es/Tabs/demo/adaptHeight/index.js +19 -0
- package/{src → es}/Tabs/demo/adaptHeight/index.less +0 -0
- package/es/Tabs/demo/basic/index.d.ts +4 -0
- package/es/Tabs/demo/basic/index.js +44 -0
- package/{src → es}/Tabs/demo/basic/index.less +0 -0
- package/es/Tabs/demo/horizontalScroll/index.d.ts +3 -0
- package/es/Tabs/demo/horizontalScroll/index.js +30 -0
- package/{src → es}/Tabs/demo/horizontalScroll/index.less +0 -0
- package/es/Tabs/index.d.ts +41 -0
- package/es/Tabs/index.js +42 -0
- package/es/Tabs/style/index.d.ts +2 -0
- package/es/Tabs/style/index.js +2 -0
- package/{src → es}/Tabs/style/index.less +0 -0
- package/es/Tooltip/demo/basic/index.d.ts +2 -0
- package/es/Tooltip/demo/basic/index.js +7 -0
- package/es/Tooltip/demo/overflow/index.d.ts +2 -0
- package/es/Tooltip/demo/overflow/index.js +7 -0
- package/es/Tooltip/demo/placement/index.d.ts +6 -0
- package/es/Tooltip/demo/placement/index.js +70 -0
- package/{src → es}/Tooltip/demo/placement/index.less +0 -0
- package/es/Tooltip/demo/trigger/index.d.ts +3 -0
- package/es/Tooltip/demo/trigger/index.js +20 -0
- package/{src → es}/Tooltip/demo/trigger/index.less +0 -0
- package/es/Tooltip/index.d.ts +64 -0
- package/es/Tooltip/index.js +33 -0
- package/es/Tooltip/style/index.d.ts +2 -0
- package/es/Tooltip/style/index.js +2 -0
- package/{src → es}/Tooltip/style/index.less +0 -0
- package/es/_utils/hooks/useControlledState.d.ts +2 -0
- package/es/_utils/hooks/useControlledState.js +54 -0
- package/es/_utils/hooks/usePrefixCls.d.ts +2 -0
- package/es/_utils/hooks/usePrefixCls.js +14 -0
- package/es/index.d.ts +8 -0
- package/{src/index.ts → es/index.js} +0 -0
- package/es/style/index.d.ts +2 -0
- package/{src/style/index.ts → es/style/index.js} +0 -0
- package/{src → es}/style/index.less +0 -0
- package/{src → es}/style/mixins/index.less +0 -0
- package/{src → es}/style/themes/default/index.less +1 -1
- package/{lib/style/themes/default/themeColor.less → es/style/themes/default/themeColor.module.less} +0 -0
- package/es/style/themes/default/themeColor.module.less.d.ts +108 -0
- package/lib/Button/demo/basic/index.less +0 -1
- package/lib/Button/index.js +2 -2
- package/lib/Button/style/index.less +5 -5
- package/lib/Dropdown/demo/button/index.js +1 -1
- package/lib/Icon/iconfont/demo_index.html +49 -3
- package/lib/Icon/iconfont/iconfont.css +11 -3
- package/lib/Icon/iconfont/iconfont.js +1 -1
- package/lib/Icon/iconfont/iconfont.json +14 -0
- package/lib/Icon/iconfont/iconfont.ttf +0 -0
- package/lib/Icon/iconfont/iconfont.woff +0 -0
- package/lib/Icon/iconfont/iconfont.woff2 +0 -0
- package/lib/Icon/index.less +3 -3
- package/lib/Input/demo/basic/index.less +1 -1
- package/lib/Input/style/index.less +4 -1
- package/lib/Select/OptionsList/OptionItem/RenderGroup.d.ts +9 -0
- package/lib/Select/OptionsList/OptionItem/RenderGroup.js +27 -0
- package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.d.ts +8 -0
- package/lib/Select/OptionsList/OptionItem/RenderLabelIcon.js +58 -0
- package/lib/Select/OptionsList/OptionItem/RenderOption.d.ts +16 -0
- package/lib/Select/OptionsList/OptionItem/RenderOption.js +94 -0
- package/lib/Select/OptionsList/OptionItem/RenderTooltip.d.ts +8 -0
- package/lib/Select/OptionsList/OptionItem/RenderTooltip.js +37 -0
- package/lib/Select/OptionsList/OptionItem.d.ts +4 -35
- package/lib/Select/OptionsList/OptionItem.js +26 -172
- package/lib/Select/OptionsList/Options.d.ts +2 -2
- package/lib/Select/OptionsList/index.js +1 -1
- package/lib/Select/Selector/index.d.ts +2 -2
- package/lib/Select/Selector/index.js +13 -10
- package/lib/Select/demo/single/index.d.ts +1 -0
- package/lib/Select/demo/single/index.js +5 -1
- package/lib/Select/demo/single/index.less +5 -0
- package/lib/Select/interface.d.ts +8 -2
- package/lib/Select/style/index.less +3 -10
- package/lib/Tooltip/index.d.ts +1 -0
- package/lib/Tooltip/index.js +3 -1
- package/lib/style/themes/default/index.less +1 -1
- package/{src/style/themes/default/themeColor.less → lib/style/themes/default/themeColor.module.less} +0 -0
- package/lib/style/themes/default/themeColor.module.less.d.ts +108 -0
- package/package.json +17 -7
- package/.editorconfig +0 -16
- package/.eslintrc.js +0 -43
- package/.fatherrc.ts +0 -16
- package/.prettierignore +0 -7
- package/.prettierrc.js +0 -1
- package/.stylelintrc.json +0 -36
- package/.umirc.ts +0 -15
- package/commitlint.config.js +0 -21
- package/docs/index.md +0 -21
- package/jest/setupTests.js +0 -1
- package/public/favicon.ico +0 -0
- package/src/Button/demo/Icon/index.tsx +0 -41
- package/src/Button/demo/basic/index.tsx +0 -26
- package/src/Button/demo/disable/index.tsx +0 -16
- package/src/Button/demo/href/index.tsx +0 -14
- package/src/Button/demo/loading/index.tsx +0 -21
- package/src/Button/index.md +0 -25
- package/src/Button/index.test.tsx +0 -58
- package/src/Button/index.tsx +0 -136
- package/src/Button/style/index.ts +0 -2
- package/src/Dropdown/Button.tsx +0 -93
- package/src/Dropdown/demo/basic/index.tsx +0 -20
- package/src/Dropdown/demo/button/index.tsx +0 -98
- package/src/Dropdown/demo/placement/index.tsx +0 -47
- package/src/Dropdown/demo/subMenu/index.tsx +0 -35
- package/src/Dropdown/demo/trigger/index.tsx +0 -19
- package/src/Dropdown/index.md +0 -35
- package/src/Dropdown/index.test.tsx +0 -185
- package/src/Dropdown/index.tsx +0 -71
- package/src/Dropdown/style/index.ts +0 -2
- package/src/Icon/iconfont/iconfont.css +0 -93
- package/src/Icon/iconfont/iconfont.js +0 -1
- package/src/Icon/iconfont/iconfont.ttf +0 -0
- package/src/Icon/iconfont/iconfont.woff +0 -0
- package/src/Icon/iconfont/iconfont.woff2 +0 -0
- package/src/Icon/index.tsx +0 -38
- package/src/Input/components/Group/index.tsx +0 -21
- package/src/Input/components/Password/index.tsx +0 -23
- package/src/Input/components/TextArea/index.tsx +0 -57
- package/src/Input/demo/allowClear/index.tsx +0 -10
- package/src/Input/demo/basic/index.tsx +0 -25
- package/src/Input/demo/gourp/index.tsx +0 -30
- package/src/Input/demo/password/index.tsx +0 -11
- package/src/Input/demo/prefix/index.tsx +0 -13
- package/src/Input/demo/showCount/index.tsx +0 -16
- package/src/Input/demo/textArea/autoSize.tsx +0 -21
- package/src/Input/index.md +0 -37
- package/src/Input/index.test.tsx +0 -78
- package/src/Input/index.tsx +0 -91
- package/src/Input/style/index.ts +0 -2
- package/src/Menu/Divider.tsx +0 -12
- package/src/Menu/MenuItem.tsx +0 -24
- package/src/Menu/SubMenu.tsx +0 -37
- package/src/Menu/index.md +0 -36
- package/src/Menu/index.test.tsx +0 -144
- package/src/Menu/index.tsx +0 -27
- package/src/Menu/style/index.ts +0 -2
- package/src/Select/BaseSelect.tsx +0 -321
- package/src/Select/OptionsList/OptionItem.tsx +0 -151
- package/src/Select/OptionsList/Options.tsx +0 -11
- package/src/Select/OptionsList/index.tsx +0 -169
- package/src/Select/Selector/index.tsx +0 -211
- package/src/Select/VirtualList.tsx +0 -36
- package/src/Select/demo/disabled/index.tsx +0 -44
- package/src/Select/demo/multiple/index.tsx +0 -77
- package/src/Select/demo/options/index.tsx +0 -63
- package/src/Select/demo/single/index.tsx +0 -50
- package/src/Select/hooks/useCacheOption.ts +0 -67
- package/src/Select/index.md +0 -72
- package/src/Select/index.tsx +0 -23
- package/src/Select/interface.ts +0 -231
- package/src/Select/style/index.ts +0 -2
- package/src/Select/utils.tsx +0 -133
- package/src/Tabs/TabPane.tsx +0 -28
- package/src/Tabs/demo/adaptHeight/index.tsx +0 -33
- package/src/Tabs/demo/basic/index.tsx +0 -30
- package/src/Tabs/demo/horizontalScroll/index.tsx +0 -36
- package/src/Tabs/index.md +0 -30
- package/src/Tabs/index.test.tsx +0 -100
- package/src/Tabs/index.tsx +0 -64
- package/src/Tabs/style/index.ts +0 -2
- package/src/Tooltip/demo/basic/index.tsx +0 -10
- package/src/Tooltip/demo/overflow/index.tsx +0 -10
- package/src/Tooltip/demo/placement/index.tsx +0 -60
- package/src/Tooltip/demo/trigger/index.tsx +0 -22
- package/src/Tooltip/index.md +0 -28
- package/src/Tooltip/index.test.tsx +0 -152
- package/src/Tooltip/index.tsx +0 -113
- package/src/Tooltip/style/index.ts +0 -2
- package/src/_utils/hooks/useControlledState.ts +0 -39
- package/src/_utils/hooks/usePrefixCls.ts +0 -11
- package/tsconfig.json +0 -13
- package/typings.d.ts +0 -3
package/src/Select/interface.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
type TSize = 'small' | 'default' | 'large';
|
|
5
|
-
|
|
6
|
-
export type TMaybeArray<T> = T | T[];
|
|
7
|
-
|
|
8
|
-
export type modeType = 'string' | 'tags' | undefined;
|
|
9
|
-
export type searchType = 'normal' | 'inner' | 'no-search';
|
|
10
|
-
export interface IOption {
|
|
11
|
-
/**
|
|
12
|
-
列表单项主要文字
|
|
13
|
-
*/
|
|
14
|
-
label: string | React.ReactNode;
|
|
15
|
-
/**
|
|
16
|
-
作为列表的 `key` 来使用
|
|
17
|
-
*/
|
|
18
|
-
value: string | number;
|
|
19
|
-
/**
|
|
20
|
-
列表次要文字
|
|
21
|
-
*/
|
|
22
|
-
description?: string;
|
|
23
|
-
/**
|
|
24
|
-
是否禁用
|
|
25
|
-
*/
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* 选中该 Option 后,Select 的 title
|
|
29
|
-
*/
|
|
30
|
-
title?: string;
|
|
31
|
-
/**
|
|
32
|
-
`tooltip` 描述
|
|
33
|
-
*/
|
|
34
|
-
tooltip?: string;
|
|
35
|
-
/**
|
|
36
|
-
分组的 `key` ,与 `groupLabel` 一起使用
|
|
37
|
-
*/
|
|
38
|
-
groupValue?: string;
|
|
39
|
-
/**
|
|
40
|
-
分组的标题
|
|
41
|
-
*/
|
|
42
|
-
groupLabel?: string;
|
|
43
|
-
|
|
44
|
-
options?: Map<string | number, IOption>;
|
|
45
|
-
isSelectOptGroup?: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface IOptGroupProps {
|
|
49
|
-
children?: React.ReactNode;
|
|
50
|
-
label: string | React.ReactNode;
|
|
51
|
-
value: string | number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface IOptionProps {
|
|
55
|
-
children?: React.ReactNode;
|
|
56
|
-
value: string | number;
|
|
57
|
-
disabled?: boolean;
|
|
58
|
-
title?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface ISelectProps {
|
|
62
|
-
/**
|
|
63
|
-
* @description 输入框尺寸
|
|
64
|
-
* @default default
|
|
65
|
-
* @type 'small' | 'default' | 'large';
|
|
66
|
-
*/
|
|
67
|
-
size?: TSize;
|
|
68
|
-
customizePrefixCls?: string;
|
|
69
|
-
/**
|
|
70
|
-
* @description 多选模式
|
|
71
|
-
* @default false
|
|
72
|
-
*/
|
|
73
|
-
multiple?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* @description 选择框默认文本
|
|
76
|
-
*/
|
|
77
|
-
placeholder?: string;
|
|
78
|
-
/**
|
|
79
|
-
* @description 是否禁用
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
disabled?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* @description 是否默认展开下拉菜单
|
|
85
|
-
* @default false
|
|
86
|
-
*/
|
|
87
|
-
defaultOpen?: boolean;
|
|
88
|
-
className?: string;
|
|
89
|
-
/**
|
|
90
|
-
* @description 下拉菜单的 className 属性
|
|
91
|
-
*/
|
|
92
|
-
dropDownClassName?: string;
|
|
93
|
-
style?: React.CSSProperties;
|
|
94
|
-
groupStyle?: React.CSSProperties;
|
|
95
|
-
optionStyle?: React.CSSProperties;
|
|
96
|
-
/**
|
|
97
|
-
* @description 下拉菜单的 style 属性
|
|
98
|
-
*/
|
|
99
|
-
dropDownStyle?: React.CSSProperties;
|
|
100
|
-
/**
|
|
101
|
-
* @description 指定默认选中的条目
|
|
102
|
-
*/
|
|
103
|
-
defaultValue?: TMaybeArray<string | number> | null;
|
|
104
|
-
/**
|
|
105
|
-
* @description 指定当前选中的条目,多选时为一个数组。
|
|
106
|
-
*/
|
|
107
|
-
value?: TMaybeArray<string | number> | null;
|
|
108
|
-
/**
|
|
109
|
-
* @description 数据化配置选项内容,相比 jsx 定义会获得更好的渲染性能
|
|
110
|
-
*/
|
|
111
|
-
options?: IOption[];
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @description 设置弹窗滚动高度
|
|
115
|
-
* @default 256
|
|
116
|
-
*/
|
|
117
|
-
listHeight?: number;
|
|
118
|
-
listRowHeight?: number;
|
|
119
|
-
labelRenderer?: (input: string) => (option: IOption, isGroup: boolean) => React.ReactNode;
|
|
120
|
-
searchPredicate?: (input: string) => _.ListIterateeCustom<IOption, boolean>;
|
|
121
|
-
matchPredicate?: (input: string) => _.ListIterateeCustom<IOption, boolean>;
|
|
122
|
-
optionLabelRenderer?: (value: string | number, option?: IOption) => React.ReactNode;
|
|
123
|
-
/**
|
|
124
|
-
* @description 选中值改变时的回调
|
|
125
|
-
*/
|
|
126
|
-
onChange?: (value: TMaybeArray<string | number> | null, options?: TMaybeArray<IOption> | null) => void;
|
|
127
|
-
/**
|
|
128
|
-
* @description 被选中时调用,参数为选中项的 value
|
|
129
|
-
*/
|
|
130
|
-
onSelect?: (value: string | number, option: IOption) => void;
|
|
131
|
-
/**
|
|
132
|
-
* @description 开启清除功能
|
|
133
|
-
*/
|
|
134
|
-
allowClear?: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* @description 清除的回调
|
|
137
|
-
*/
|
|
138
|
-
onClear?: () => void;
|
|
139
|
-
/**
|
|
140
|
-
* 浮层渲染父节点,默认渲染到 body 上
|
|
141
|
-
*/
|
|
142
|
-
getContainer?: (node: HTMLElement) => HTMLElement;
|
|
143
|
-
/**
|
|
144
|
-
* @description 是否展开下拉菜单
|
|
145
|
-
*/
|
|
146
|
-
open?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* dropdown visible 值改变时的回调
|
|
149
|
-
*/
|
|
150
|
-
onDropDownVisibleChange?: (visible: boolean) => void;
|
|
151
|
-
/** *
|
|
152
|
-
* @description 下拉菜单和选择器同宽
|
|
153
|
-
* @default true
|
|
154
|
-
*/
|
|
155
|
-
dropdownMatchSelectWidth?: boolean
|
|
156
|
-
/**
|
|
157
|
-
* @description 下拉菜单内置标签
|
|
158
|
-
*/
|
|
159
|
-
label?: React.ReactNode;
|
|
160
|
-
children?: React.ReactNode[] | React.ReactNode;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export interface ISelectorProps {
|
|
164
|
-
input: string;
|
|
165
|
-
disabled: boolean;
|
|
166
|
-
prefix: string;
|
|
167
|
-
size: 'small' | 'default' | 'large';
|
|
168
|
-
multiple: boolean;
|
|
169
|
-
bordered: boolean;
|
|
170
|
-
isFocused: boolean;
|
|
171
|
-
className?: string | undefined;
|
|
172
|
-
visible: boolean;
|
|
173
|
-
style?: React.CSSProperties | undefined;
|
|
174
|
-
allowClear: boolean;
|
|
175
|
-
mode?: modeType;
|
|
176
|
-
label?: React.ReactNode;
|
|
177
|
-
value?: TMaybeArray<string | number> | undefined | null;
|
|
178
|
-
filteredOptions: IOption[];
|
|
179
|
-
searchType: searchType;
|
|
180
|
-
placeholder?: string;
|
|
181
|
-
optionLabelRenderer: (value: string | number, option?: IOption) => React.ReactNode;
|
|
182
|
-
getOptionByValue: (optValue: string | number) => IOption;
|
|
183
|
-
onInputChange: (value: string) => void;
|
|
184
|
-
onAllowClear: () => void;
|
|
185
|
-
deleteValue: (value: React.ReactText[], v: string | number) => void;
|
|
186
|
-
arrowComponent?: React.ReactElement | undefined;
|
|
187
|
-
closeComponent?: React.ReactElement | undefined;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface IVirtualListProps {
|
|
191
|
-
itemHeight?: number;
|
|
192
|
-
height?: number;
|
|
193
|
-
prefixCls?: string;
|
|
194
|
-
children: React.ReactNode;
|
|
195
|
-
data: IOption[];
|
|
196
|
-
virtual?: boolean;
|
|
197
|
-
itemKey: string | number | ((item: never) => React.ReactText);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface IOptionsListProps {
|
|
201
|
-
style?: React.CSSProperties;
|
|
202
|
-
input: string;
|
|
203
|
-
prefixCls: string;
|
|
204
|
-
groupStyle?: React.CSSProperties;
|
|
205
|
-
optionStyle?: React.CSSProperties;
|
|
206
|
-
selected?: TMaybeArray<React.ReactText> | null;
|
|
207
|
-
multiple: boolean;
|
|
208
|
-
isMode?: boolean;
|
|
209
|
-
optionChecked?: TMaybeArray<React.ReactText>;
|
|
210
|
-
visible?: boolean;
|
|
211
|
-
isUseAll?: boolean;
|
|
212
|
-
data: IOption[];
|
|
213
|
-
hasGroup: boolean;
|
|
214
|
-
searchType: searchType;
|
|
215
|
-
placeholder?: string;
|
|
216
|
-
notFoundContent?: React.ReactElement;
|
|
217
|
-
onTempValueChange: (tempValue: React.ReactText[]) => void;
|
|
218
|
-
setTempValue: (values: React.ReactText[]) => void;
|
|
219
|
-
value?: TMaybeArray<React.ReactText> | null;
|
|
220
|
-
tempValue: React.ReactText[];
|
|
221
|
-
isFooter?: boolean;
|
|
222
|
-
labelRenderer: (option: IOption, isGruop: false) => React.ReactNode;
|
|
223
|
-
onOptionClick: (selectedValue: string | number) => void;
|
|
224
|
-
getContainer?: (node: HTMLElement) => HTMLElement;
|
|
225
|
-
onValueChange?: (optionValues: TMaybeArray<string | number> | null) => void;
|
|
226
|
-
onInputChange: (value: string) => void;
|
|
227
|
-
height?: number | undefined;
|
|
228
|
-
itemHeight?: number | undefined;
|
|
229
|
-
activeIndex: number;
|
|
230
|
-
setActiveIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
231
|
-
}
|
package/src/Select/utils.tsx
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { concat, uniqueId } from 'lodash';
|
|
3
|
-
import { IOption, IOptionProps } from './interface';
|
|
4
|
-
|
|
5
|
-
const ZERO_INDEX = 0;
|
|
6
|
-
|
|
7
|
-
interface IGroup {
|
|
8
|
-
groupLabel?: string;
|
|
9
|
-
groupValue?: string | number;
|
|
10
|
-
}
|
|
11
|
-
const ungroupedOptionKeyPrefix = 'select_isungrouped_option_';
|
|
12
|
-
const ungroupedOptionKey = uniqueId(ungroupedOptionKeyPrefix);
|
|
13
|
-
const ungroupedOptionLabel = '未分组';
|
|
14
|
-
export const customOptionKeyPrefix = 'select_custom_option_';
|
|
15
|
-
export const customOptionKey = uniqueId(customOptionKeyPrefix);
|
|
16
|
-
|
|
17
|
-
// ReactNode To Options
|
|
18
|
-
export function convertNodeToOption(node: React.ReactElement, group: IGroup): IOption {
|
|
19
|
-
const {
|
|
20
|
-
props: { value, children, ...restProps },
|
|
21
|
-
} = node as React.ReactElement & { props: IOptionProps };
|
|
22
|
-
const { groupValue, groupLabel } = group;
|
|
23
|
-
if (groupLabel && groupLabel) {
|
|
24
|
-
return { value, label: children !== undefined ? children : value, groupValue, groupLabel, ...restProps };
|
|
25
|
-
}
|
|
26
|
-
return { value, label: children !== undefined ? children : value, ...restProps };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const getFlattenOptions = (data: IOption[], hasGroup: boolean) => {
|
|
30
|
-
const groupMap = new Map();
|
|
31
|
-
if (!hasGroup) { return data; }
|
|
32
|
-
data?.map((cur: IOption) => {
|
|
33
|
-
const gValue = groupMap.get(cur.groupValue);
|
|
34
|
-
if (gValue) {
|
|
35
|
-
const { options, ...rest } = gValue;
|
|
36
|
-
return groupMap.set(cur.groupValue, {
|
|
37
|
-
options: [...options, cur],
|
|
38
|
-
...rest,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return groupMap.set(cur.groupValue, {
|
|
42
|
-
label: cur.groupLabel,
|
|
43
|
-
value: cur.groupValue,
|
|
44
|
-
isSelectOptGroup: true,
|
|
45
|
-
options: [cur],
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
const flattenOption: IOption[] = [];
|
|
49
|
-
groupMap.forEach((value: IOption) => {
|
|
50
|
-
flattenOption.push(value);
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
flattenOption.push(...value.options);
|
|
53
|
-
});
|
|
54
|
-
return flattenOption;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export function convertChildrenToData(nodes: React.ReactElement[], group = {}): IOption[] {
|
|
58
|
-
let nodeOptions: IOption[] = [];
|
|
59
|
-
React.Children.forEach(nodes, (node: React.ReactElement) => {
|
|
60
|
-
if (!React.isValidElement(node)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const {
|
|
64
|
-
type: { isSelectOptGroup },
|
|
65
|
-
props: { children, label, value },
|
|
66
|
-
} = node as React.ReactElement & { type: { isSelectOptGroup?: boolean }; props: IOptionProps }; // 联合类型
|
|
67
|
-
if (!isSelectOptGroup) {
|
|
68
|
-
// option
|
|
69
|
-
nodeOptions.push(convertNodeToOption(node, group));
|
|
70
|
-
} else {
|
|
71
|
-
// Group
|
|
72
|
-
nodeOptions = concat(nodeOptions, convertChildrenToData(children, { groupLabel: label, groupValue: value }));
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return nodeOptions;
|
|
76
|
-
}
|
|
77
|
-
// optionsMap flattenOptions
|
|
78
|
-
export function handleOptions(
|
|
79
|
-
mergedOptions: IOption[],
|
|
80
|
-
setCacheOptions: (options: IOption[]) => void,
|
|
81
|
-
updateGroup: (value: boolean) => void
|
|
82
|
-
) {
|
|
83
|
-
const isGroup = !!mergedOptions.find((v) => Object.prototype.hasOwnProperty.call(v, 'groupValue'));
|
|
84
|
-
const flattenOptions: IOption[] = [];
|
|
85
|
-
|
|
86
|
-
mergedOptions.forEach((option: IOption) => {
|
|
87
|
-
const { groupLabel: optionGroupLabel, groupValue: optionGroupValue } = option;
|
|
88
|
-
if (isGroup && !optionGroupValue && !optionGroupLabel) {
|
|
89
|
-
const ungroupedOption = {
|
|
90
|
-
...option,
|
|
91
|
-
groupLabel: ungroupedOptionLabel,
|
|
92
|
-
groupValue: ungroupedOptionKey,
|
|
93
|
-
};
|
|
94
|
-
flattenOptions.push(ungroupedOption);
|
|
95
|
-
} else {
|
|
96
|
-
flattenOptions.push(option);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
updateGroup(isGroup);
|
|
100
|
-
setCacheOptions(flattenOptions);
|
|
101
|
-
return {
|
|
102
|
-
flattenOptions,
|
|
103
|
-
isGroup,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// provide search matching hightlight;
|
|
107
|
-
export const defaultLabelRenderer = (input: string, prefix: string) => (option: IOption, isGroup: boolean): React.ReactNode => {
|
|
108
|
-
const { title, label } = option;
|
|
109
|
-
if (isGroup || typeof label !== 'string') { return title || label; }
|
|
110
|
-
const index = label.indexOf(input);
|
|
111
|
-
return (
|
|
112
|
-
<div style={{ display: 'inline-block', lineHeight: '40px' }}>
|
|
113
|
-
{label.slice(ZERO_INDEX, index)}
|
|
114
|
-
<span className={`${prefix}-search-highlight`}>{label.slice(index, index + input.length)}</span>
|
|
115
|
-
{label.slice(index + input.length)}
|
|
116
|
-
</div>
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
export const defaultOptionLabelRenderer = (value: string | number, option?: IOption) => option?.title || option?.label || value;
|
|
120
|
-
export const defaultSearchPredicate = (input: string) => (o: IOption) => (typeof o.label === 'string' ? o.label.includes(input) : true);
|
|
121
|
-
export const defaultMatchPredicate = (input: string) => (o: IOption) => o.label === input;
|
|
122
|
-
|
|
123
|
-
export const CustomOption = (value: string | number, withGroup = false, id = customOptionKeyPrefix): IOption => (withGroup
|
|
124
|
-
? {
|
|
125
|
-
value,
|
|
126
|
-
label: value.toString(),
|
|
127
|
-
groupValue: id,
|
|
128
|
-
groupLabel: '自由输入',
|
|
129
|
-
}
|
|
130
|
-
: {
|
|
131
|
-
value,
|
|
132
|
-
label: value.toString(),
|
|
133
|
-
});
|
package/src/Tabs/TabPane.tsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import AntdTabs from 'antd/lib/tabs';
|
|
3
|
-
|
|
4
|
-
const AntdTabPane = AntdTabs.TabPane;
|
|
5
|
-
|
|
6
|
-
export interface ITabPaneProps {
|
|
7
|
-
/**
|
|
8
|
-
* @description 被隐藏时是否渲染 DOM 结构
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
forceRender?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* @description 对应 activeKey
|
|
14
|
-
* @default -
|
|
15
|
-
*/
|
|
16
|
-
key?: string;
|
|
17
|
-
/**
|
|
18
|
-
* @description 选项卡头显示的内容
|
|
19
|
-
* @default -
|
|
20
|
-
*/
|
|
21
|
-
tab: ReactNode;
|
|
22
|
-
className?: string;
|
|
23
|
-
children?: ReactNode;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function TabPane(props: ITabPaneProps) {
|
|
27
|
-
return <AntdTabPane {...props} />;
|
|
28
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './index.less';
|
|
3
|
-
|
|
4
|
-
import { Tabs } from '@aloudata/aloudata-design';
|
|
5
|
-
|
|
6
|
-
const { TabPane } = Tabs;
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
return (
|
|
10
|
-
<div className="demo-adapt-height">
|
|
11
|
-
<Tabs adaptHeight>
|
|
12
|
-
<TabPane tab="Tab 1" key="1" className="demo-tabpane">
|
|
13
|
-
Content of Tab Pane 1
|
|
14
|
-
</TabPane>
|
|
15
|
-
<TabPane tab="Tab 2" key="2" className="demo-tabpane">
|
|
16
|
-
<>
|
|
17
|
-
<div>Content of Tab Pane 2</div>
|
|
18
|
-
<div>Content of Tab Pane 2</div>
|
|
19
|
-
<div>Content of Tab Pane 2</div>
|
|
20
|
-
<div>Content of Tab Pane 2</div>
|
|
21
|
-
<div>Content of Tab Pane 2</div>
|
|
22
|
-
<div>Content of Tab Pane 2</div>
|
|
23
|
-
<div>Content of Tab Pane 2</div>
|
|
24
|
-
<div>Content of Tab Pane 2</div>
|
|
25
|
-
<div>Content of Tab Pane 2</div>
|
|
26
|
-
<div>Content of Tab Pane 2</div>
|
|
27
|
-
<div>Content of Tab Pane 2</div>
|
|
28
|
-
</>
|
|
29
|
-
</TabPane>
|
|
30
|
-
</Tabs>
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import Switch from 'antd/lib/switch';
|
|
3
|
-
import 'antd/lib//switch/style/index.less';
|
|
4
|
-
import './index.less';
|
|
5
|
-
|
|
6
|
-
import { Tabs } from '@aloudata/aloudata-design';
|
|
7
|
-
|
|
8
|
-
const { TabPane } = Tabs;
|
|
9
|
-
|
|
10
|
-
export default () => {
|
|
11
|
-
const [size, setSize] = useState('default');
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div className="demo-basic">
|
|
15
|
-
<div>
|
|
16
|
-
large size: <Switch checked={size === 'large'} onChange={(checked) => setSize(checked ? 'large' : 'default')} />
|
|
17
|
-
</div>
|
|
18
|
-
<div className="tabs-container">
|
|
19
|
-
<Tabs size={size} destroyInactiveTabPane>
|
|
20
|
-
<TabPane tab="Tab 1" key="1">
|
|
21
|
-
Content of Tab Pane 1
|
|
22
|
-
</TabPane>
|
|
23
|
-
<TabPane tab="Tab 2" key="2">
|
|
24
|
-
Content of Tab Pane 2
|
|
25
|
-
</TabPane>
|
|
26
|
-
</Tabs>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './index.less';
|
|
3
|
-
|
|
4
|
-
import { Tabs } from '@aloudata/aloudata-design';
|
|
5
|
-
|
|
6
|
-
const { TabPane } = Tabs;
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
return (
|
|
10
|
-
<div className="demo-horizontal-scroll">
|
|
11
|
-
<Tabs>
|
|
12
|
-
<TabPane tab="Tab 1" key="1">
|
|
13
|
-
Content of Tab Pane 1
|
|
14
|
-
</TabPane>
|
|
15
|
-
<TabPane tab="Tab 2" key="2">
|
|
16
|
-
Content of Tab Pane 2
|
|
17
|
-
</TabPane>
|
|
18
|
-
<TabPane tab="Tab 3" key="3">
|
|
19
|
-
Content of Tab Pane 3
|
|
20
|
-
</TabPane>
|
|
21
|
-
<TabPane tab="Tab 4" key="4">
|
|
22
|
-
Content of Tab Pane 4
|
|
23
|
-
</TabPane>
|
|
24
|
-
<TabPane tab="Tab 5" key="5">
|
|
25
|
-
Content of Tab Pane 5
|
|
26
|
-
</TabPane>
|
|
27
|
-
<TabPane tab="Tab 6" key="6">
|
|
28
|
-
Content of Tab Pane 6
|
|
29
|
-
</TabPane>
|
|
30
|
-
<TabPane tab="Tab 7" key="7">
|
|
31
|
-
Content of Tab Pane 7
|
|
32
|
-
</TabPane>
|
|
33
|
-
</Tabs>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
};
|
package/src/Tabs/index.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
# nav:
|
|
3
|
-
# title: 组件
|
|
4
|
-
# path: /components
|
|
5
|
-
title: Tabs 标签页
|
|
6
|
-
group:
|
|
7
|
-
title: 组件
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Tabs 标签页
|
|
11
|
-
|
|
12
|
-
选项卡切换组件
|
|
13
|
-
|
|
14
|
-
## 代码演示
|
|
15
|
-
|
|
16
|
-
<code src="./demo/basic" title="基本" description="默认选中第一项">
|
|
17
|
-
|
|
18
|
-
<code src="./demo/adaptHeight" title="自适应高度" description="自动撑满容器高度,body 内容超出时出现纵向滚动条">
|
|
19
|
-
|
|
20
|
-
<code src="./demo/horizontalScroll" title="滑动" description="可以左右滑动,容纳更多标签">
|
|
21
|
-
|
|
22
|
-
## API
|
|
23
|
-
|
|
24
|
-
### Tabs
|
|
25
|
-
|
|
26
|
-
<API exports='["default"]' hideTitle />
|
|
27
|
-
|
|
28
|
-
### Tabs.TabPane
|
|
29
|
-
|
|
30
|
-
<API exports='["default.TabPane"]' hideTitle />
|
package/src/Tabs/index.test.tsx
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
-
import Tabs from './index';
|
|
5
|
-
import { act } from 'react-dom/test-utils';
|
|
6
|
-
|
|
7
|
-
const { TabPane } = Tabs;
|
|
8
|
-
|
|
9
|
-
describe('Tabs', () => {
|
|
10
|
-
it('activeKey', () => {
|
|
11
|
-
render(
|
|
12
|
-
<div className="activeKey">
|
|
13
|
-
<Tabs activeKey="2">
|
|
14
|
-
<TabPane tab="tab1" key="1">1</TabPane>
|
|
15
|
-
<TabPane tab="tab2" key="2">2</TabPane>
|
|
16
|
-
<TabPane tab="tab3" key="3">3</TabPane>
|
|
17
|
-
</Tabs>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const activeText = document.querySelector('.activeKey .ant-tabs-tabpane-active')?.textContent;
|
|
22
|
-
expect(activeText).toBe('2');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('defaultActiveKey', () => {
|
|
26
|
-
render(
|
|
27
|
-
<div className="defaultActiveKey">
|
|
28
|
-
<Tabs defaultActiveKey="2">
|
|
29
|
-
<TabPane tab="tab1" key="1">1</TabPane>
|
|
30
|
-
<TabPane tab="tab2" key="2">2</TabPane>
|
|
31
|
-
<TabPane tab="tab3" key="3">3</TabPane>
|
|
32
|
-
</Tabs>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const activeText = document.querySelector('.defaultActiveKey .ant-tabs-tabpane-active')?.textContent;
|
|
37
|
-
expect(activeText).toBe('2');
|
|
38
|
-
|
|
39
|
-
act(() => {
|
|
40
|
-
fireEvent.click(screen.getByText('tab3'));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(document.querySelector('.defaultActiveKey .ant-tabs-tabpane-active')?.textContent).toBe('3');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('onChange', () => {
|
|
47
|
-
let activeKey = '2';
|
|
48
|
-
render(
|
|
49
|
-
<div className="onChange">
|
|
50
|
-
<Tabs activeKey="2" onChange={(key) => { activeKey = key; }}>
|
|
51
|
-
<TabPane tab="tab1" key="1">1</TabPane>
|
|
52
|
-
<TabPane tab="tab2" key="2">2</TabPane>
|
|
53
|
-
<TabPane tab="tab3" key="3">3</TabPane>
|
|
54
|
-
</Tabs>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
act(() => {
|
|
59
|
-
fireEvent.click(screen.getByText('tab3'));
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
expect(activeKey).toBe('3');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('destroyInactiveTabPane', () => {
|
|
66
|
-
render(
|
|
67
|
-
<div className="destroyInactiveTabPane">
|
|
68
|
-
<Tabs defaultActiveKey="2" destroyInactiveTabPane>
|
|
69
|
-
<TabPane tab="tab1" key="1">1</TabPane>
|
|
70
|
-
<TabPane tab="tab2" key="2">
|
|
71
|
-
<div className="tabpane2">2</div>
|
|
72
|
-
</TabPane>
|
|
73
|
-
<TabPane tab="tab3" key="3">3</TabPane>
|
|
74
|
-
</Tabs>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
expect(document.querySelector('.destroyInactiveTabPane .tabpane2')).not.toBeNull();
|
|
79
|
-
|
|
80
|
-
act(() => {
|
|
81
|
-
fireEvent.click(screen.getByText('tab3'));
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expect(document.querySelector('.destroyInactiveTabPane .tabpane2')).toBeNull();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('TabPane forceRender', () => {
|
|
88
|
-
render(
|
|
89
|
-
<div className="activeKey">
|
|
90
|
-
<Tabs activeKey="2">
|
|
91
|
-
<TabPane tab="tab1" key="1">1</TabPane>
|
|
92
|
-
<TabPane tab="tab2" key="2">2</TabPane>
|
|
93
|
-
<TabPane tab="tab3" key="3" forceRender>Content3</TabPane>
|
|
94
|
-
</Tabs>
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(screen.getByText('Content3')).toBeInTheDocument();
|
|
99
|
-
});
|
|
100
|
-
});
|
package/src/Tabs/index.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import AntdTabs, { TabsProps } from 'antd/lib/tabs';
|
|
3
|
-
import Icon from '../Icon';
|
|
4
|
-
import TabPane from './TabPane';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import './style';
|
|
7
|
-
|
|
8
|
-
export interface ITabsProps {
|
|
9
|
-
/**
|
|
10
|
-
* @description 大小
|
|
11
|
-
* @default default
|
|
12
|
-
*/
|
|
13
|
-
size?: 'large' | 'default';
|
|
14
|
-
/**
|
|
15
|
-
* @description 当前激活 tab 面板的 key
|
|
16
|
-
* @default -
|
|
17
|
-
*/
|
|
18
|
-
activeKey?: string;
|
|
19
|
-
/**
|
|
20
|
-
* @description 初始化选中面板的 key,如果没有设置 activeKey
|
|
21
|
-
* @default 第一个面板的 key
|
|
22
|
-
*/
|
|
23
|
-
defaultActiveKey?: string;
|
|
24
|
-
/**
|
|
25
|
-
* @description 切换面板的回调
|
|
26
|
-
* @default -
|
|
27
|
-
*/
|
|
28
|
-
onChange?: (activeKey: string) => void;
|
|
29
|
-
/**
|
|
30
|
-
* @description 被隐藏时是否销毁 DOM 结构
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
destroyInactiveTabPane?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* @description 撑满容器的高度
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
|
-
adaptHeight?: boolean;
|
|
39
|
-
className?: string;
|
|
40
|
-
children?: React.ReactNode;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default function Tabs(props: ITabsProps) {
|
|
44
|
-
const { size, className, adaptHeight, ...otherProps } = props;
|
|
45
|
-
|
|
46
|
-
const tabsProps: TabsProps = {
|
|
47
|
-
...otherProps,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (size === 'large') {
|
|
51
|
-
tabsProps.size = size;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<AntdTabs
|
|
56
|
-
moreIcon={<Icon type="more_vert" size={18} />}
|
|
57
|
-
tabBarGutter={24}
|
|
58
|
-
className={classNames('ald-tabs', className, { 'ald-adapt-height': adaptHeight })}
|
|
59
|
-
{...tabsProps}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Tabs.TabPane = TabPane;
|
package/src/Tabs/style/index.ts
DELETED