@dtjoy/dt-design 1.0.0 → 1.0.2
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/esm/_util/gapSize.d.ts +3 -0
- package/esm/_util/gapSize.js +10 -0
- package/esm/_util/hooks/index.d.ts +1 -0
- package/esm/_util/hooks/index.js +1 -0
- package/esm/_util/hooks/useOrientation.d.ts +2 -0
- package/esm/_util/hooks/useOrientation.js +19 -0
- package/esm/_util/isNonNullable.d.ts +2 -0
- package/esm/_util/isNonNullable.js +4 -0
- package/esm/_util/type.d.ts +2 -1
- package/esm/blockHeader/index.d.ts +1 -1
- package/esm/blockHeader/index.js +13 -10
- package/esm/blockHeader/style/index.d.ts +2 -0
- package/esm/blockHeader/style/index.js +2 -0
- package/esm/blockHeader/{style.less → style/index.less} +143 -141
- package/esm/button/index.d.ts +10 -0
- package/esm/button/index.js +29 -0
- package/esm/button/style/index.d.ts +2 -0
- package/esm/button/style/index.js +2 -0
- package/esm/button/style/index.less +134 -0
- package/esm/button/style/mixin.less +47 -0
- package/esm/collapsible/index.d.ts +97 -0
- package/esm/collapsible/index.js +234 -0
- package/esm/collapsible/style/index.d.ts +1 -0
- package/esm/collapsible/style/index.js +1 -0
- package/esm/collapsible/style/index.less +24 -0
- package/esm/collapsibleActionItems/index.d.ts +24 -0
- package/esm/collapsibleActionItems/index.js +74 -0
- package/esm/collapsibleActionItems/style/index.d.ts +2 -0
- package/esm/collapsibleActionItems/style/index.js +2 -0
- package/esm/collapsibleActionItems/style/index.less +7 -0
- package/esm/flex/index.d.ts +7 -0
- package/esm/flex/index.js +62 -0
- package/esm/flex/interface.d.ts +16 -0
- package/esm/flex/interface.js +1 -0
- package/esm/flex/style/index.d.ts +2 -0
- package/esm/flex/style/index.js +2 -0
- package/esm/flex/style/index.less +77 -0
- package/esm/flex/utils.d.ts +7 -0
- package/esm/flex/utils.js +33 -0
- package/esm/index.d.ts +10 -1
- package/esm/index.js +8 -7
- package/esm/resize/index.d.ts +8 -0
- package/esm/resize/index.js +29 -0
- package/esm/splitter/Panel.d.ts +7 -0
- package/esm/splitter/Panel.js +38 -0
- package/esm/splitter/SplitBar.d.ts +24 -0
- package/esm/splitter/SplitBar.js +185 -0
- package/esm/splitter/Splitter.d.ts +5 -0
- package/esm/splitter/Splitter.js +215 -0
- package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
- package/esm/splitter/hooks/sizeUtil.js +63 -0
- package/esm/splitter/hooks/useItems.d.ts +14 -0
- package/esm/splitter/hooks/useItems.js +44 -0
- package/esm/splitter/hooks/useResizable.d.ts +10 -0
- package/esm/splitter/hooks/useResizable.js +73 -0
- package/esm/splitter/hooks/useResize.d.ts +6 -0
- package/esm/splitter/hooks/useResize.js +158 -0
- package/esm/splitter/hooks/useSizes.d.ts +4 -0
- package/esm/splitter/hooks/useSizes.js +80 -0
- package/esm/splitter/index.d.ts +8 -0
- package/esm/splitter/index.js +5 -0
- package/esm/splitter/interface.d.ts +68 -0
- package/esm/splitter/interface.js +1 -0
- package/esm/splitter/style/index.d.ts +2 -0
- package/esm/splitter/style/index.js +2 -0
- package/esm/splitter/style/index.less +312 -0
- package/esm/statusTag/index.d.ts +28 -0
- package/esm/statusTag/index.js +122 -0
- package/esm/statusTag/style/index.d.ts +2 -0
- package/esm/statusTag/style/index.js +2 -0
- package/esm/statusTag/style/index.less +70 -0
- package/esm/statusTag/style/mixin.less +39 -0
- package/esm/style/index.d.ts +1 -0
- package/esm/style/index.js +1 -0
- package/esm/style/index.less +1 -0
- package/esm/style/mixins/index.less +0 -0
- package/esm/style/themes/index.less +2 -0
- package/esm/style/themes/variable.less +1 -0
- package/lib/_util/gapSize.d.ts +3 -0
- package/lib/_util/gapSize.js +17 -0
- package/lib/_util/hooks/index.d.ts +1 -0
- package/lib/_util/hooks/index.js +16 -0
- package/lib/_util/hooks/useOrientation.d.ts +2 -0
- package/lib/_util/hooks/useOrientation.js +26 -0
- package/lib/_util/isNonNullable.d.ts +2 -0
- package/lib/_util/isNonNullable.js +10 -0
- package/lib/_util/type.d.ts +2 -1
- package/lib/blockHeader/index.d.ts +1 -1
- package/lib/blockHeader/index.js +13 -11
- package/lib/blockHeader/style/index.d.ts +2 -0
- package/lib/blockHeader/style/index.js +4 -0
- package/lib/blockHeader/{style.less → style/index.less} +143 -141
- package/lib/button/index.d.ts +10 -0
- package/lib/button/index.js +33 -0
- package/lib/button/style/index.d.ts +2 -0
- package/lib/button/style/index.js +4 -0
- package/lib/button/style/index.less +134 -0
- package/lib/button/style/mixin.less +47 -0
- package/lib/collapsible/index.d.ts +97 -0
- package/lib/collapsible/index.js +199 -0
- package/lib/collapsible/style/index.d.ts +1 -0
- package/lib/collapsible/style/index.js +3 -0
- package/lib/collapsible/style/index.less +24 -0
- package/lib/collapsibleActionItems/index.d.ts +24 -0
- package/lib/collapsibleActionItems/index.js +68 -0
- package/lib/collapsibleActionItems/style/index.d.ts +2 -0
- package/lib/collapsibleActionItems/style/index.js +4 -0
- package/lib/collapsibleActionItems/style/index.less +7 -0
- package/lib/flex/index.d.ts +7 -0
- package/lib/flex/index.js +60 -0
- package/lib/flex/interface.d.ts +16 -0
- package/lib/flex/interface.js +5 -0
- package/lib/flex/style/index.d.ts +2 -0
- package/lib/flex/style/index.js +4 -0
- package/lib/flex/style/index.less +77 -0
- package/lib/flex/utils.d.ts +7 -0
- package/lib/flex/utils.js +39 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +72 -1
- package/lib/resize/index.d.ts +8 -0
- package/lib/resize/index.js +38 -0
- package/lib/splitter/Panel.d.ts +7 -0
- package/lib/splitter/Panel.js +44 -0
- package/lib/splitter/SplitBar.d.ts +24 -0
- package/lib/splitter/SplitBar.js +179 -0
- package/lib/splitter/Splitter.d.ts +5 -0
- package/lib/splitter/Splitter.js +202 -0
- package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
- package/lib/splitter/hooks/sizeUtil.js +56 -0
- package/lib/splitter/hooks/useItems.d.ts +14 -0
- package/lib/splitter/hooks/useItems.js +46 -0
- package/lib/splitter/hooks/useResizable.d.ts +10 -0
- package/lib/splitter/hooks/useResizable.js +83 -0
- package/lib/splitter/hooks/useResize.d.ts +6 -0
- package/lib/splitter/hooks/useResize.js +142 -0
- package/lib/splitter/hooks/useSizes.d.ts +4 -0
- package/lib/splitter/hooks/useSizes.js +62 -0
- package/lib/splitter/index.d.ts +8 -0
- package/lib/splitter/index.js +12 -0
- package/lib/splitter/interface.d.ts +68 -0
- package/lib/splitter/interface.js +5 -0
- package/lib/splitter/style/index.d.ts +2 -0
- package/lib/splitter/style/index.js +4 -0
- package/lib/splitter/style/index.less +312 -0
- package/lib/statusTag/index.d.ts +28 -0
- package/lib/statusTag/index.js +125 -0
- package/lib/statusTag/style/index.d.ts +2 -0
- package/lib/statusTag/style/index.js +4 -0
- package/lib/statusTag/style/index.less +70 -0
- package/lib/statusTag/style/mixin.less +39 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +3 -0
- package/lib/style/index.less +1 -0
- package/lib/style/mixins/index.less +0 -0
- package/lib/style/themes/index.less +2 -0
- package/lib/style/themes/variable.less +1 -0
- package/package.json +142 -141
- package/esm/styles/entry.less +0 -6
- package/esm/styles/variables.less +0 -1
- package/lib/styles/entry.less +0 -6
- package/lib/styles/variables.less +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
@import './mixin.less';
|
|
3
|
+
|
|
4
|
+
@btn-prefix-cls: ~'@{ant-prefix}-btn';
|
|
5
|
+
|
|
6
|
+
.@{btn-prefix-cls} {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
|
|
11
|
+
// 引用中尺寸配置(核心:先调用混入,再取值)
|
|
12
|
+
.btn-size-middle();
|
|
13
|
+
padding: @padding;
|
|
14
|
+
|
|
15
|
+
// 图标样式
|
|
16
|
+
&__icon {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
font-size: inherit;
|
|
21
|
+
line-height: 0;
|
|
22
|
+
|
|
23
|
+
.dtstack-icon {
|
|
24
|
+
font-size: inherit;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 小尺寸图标
|
|
28
|
+
&--small {
|
|
29
|
+
.btn-size-small();
|
|
30
|
+
font-size: @icon-font-size;
|
|
31
|
+
}
|
|
32
|
+
// 中尺寸图标
|
|
33
|
+
&--middle {
|
|
34
|
+
.btn-size-middle();
|
|
35
|
+
font-size: @icon-font-size;
|
|
36
|
+
}
|
|
37
|
+
// 大尺寸图标
|
|
38
|
+
&--large {
|
|
39
|
+
.btn-size-large();
|
|
40
|
+
font-size: @icon-font-size;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 图标与文字间距
|
|
44
|
+
& + .@{btn-prefix-cls}__text {
|
|
45
|
+
&--small {
|
|
46
|
+
.btn-size-small();
|
|
47
|
+
margin-left: @icon-text-margin;
|
|
48
|
+
}
|
|
49
|
+
&--middle {
|
|
50
|
+
.btn-size-middle();
|
|
51
|
+
margin-left: @icon-text-margin;
|
|
52
|
+
}
|
|
53
|
+
&--large {
|
|
54
|
+
.btn-size-large();
|
|
55
|
+
margin-left: @icon-text-margin;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 文字样式
|
|
61
|
+
&__text {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
|
|
64
|
+
&--small {
|
|
65
|
+
.btn-size-small();
|
|
66
|
+
font-size: @text-font-size;
|
|
67
|
+
}
|
|
68
|
+
&--middle {
|
|
69
|
+
.btn-size-middle();
|
|
70
|
+
font-size: @text-font-size;
|
|
71
|
+
}
|
|
72
|
+
&--large {
|
|
73
|
+
.btn-size-large();
|
|
74
|
+
font-size: @text-font-size;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 尺寸变体
|
|
79
|
+
&-sm {
|
|
80
|
+
.btn-size-small();
|
|
81
|
+
padding: @padding;
|
|
82
|
+
}
|
|
83
|
+
&-lg {
|
|
84
|
+
.btn-size-large();
|
|
85
|
+
padding: @padding;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 主要按钮
|
|
89
|
+
&-primary {
|
|
90
|
+
.btn-disabled-primary();
|
|
91
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
92
|
+
|
|
93
|
+
&:hover,
|
|
94
|
+
&:focus {
|
|
95
|
+
background-color: #225fdb;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 次要按钮
|
|
100
|
+
&-secondary {
|
|
101
|
+
border-color: @primary-color;
|
|
102
|
+
color: @primary-color;
|
|
103
|
+
|
|
104
|
+
&:hover,
|
|
105
|
+
&:focus {
|
|
106
|
+
background-color: fade(@primary-color, 10%);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.btn-disabled-secondary-tertiary();
|
|
110
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 三级按钮
|
|
114
|
+
&-tertiary {
|
|
115
|
+
background-color: #f3f3f3;
|
|
116
|
+
border-color: @border-color-base;
|
|
117
|
+
|
|
118
|
+
&:hover,
|
|
119
|
+
&:focus {
|
|
120
|
+
background-color: fade(@primary-color, 10%);
|
|
121
|
+
border-color: @primary-color;
|
|
122
|
+
color: @primary-color;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.btn-disabled-secondary-tertiary();
|
|
126
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 默认按钮
|
|
130
|
+
&-default {
|
|
131
|
+
.btn-disabled-default();
|
|
132
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.btn-size-small() {
|
|
2
|
+
@padding: 2px 12px;
|
|
3
|
+
@icon-font-size: 12px;
|
|
4
|
+
@text-font-size: 12px;
|
|
5
|
+
@icon-text-margin: 2px;
|
|
6
|
+
}
|
|
7
|
+
.btn-size-middle() {
|
|
8
|
+
@padding: 4px 16px;
|
|
9
|
+
@icon-font-size: 16px;
|
|
10
|
+
@text-font-size: 14px;
|
|
11
|
+
@icon-text-margin: 8px;
|
|
12
|
+
}
|
|
13
|
+
.btn-size-large() {
|
|
14
|
+
@padding: 3px 40px;
|
|
15
|
+
@icon-font-size: 18px;
|
|
16
|
+
@text-font-size: 14px;
|
|
17
|
+
@icon-text-margin: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 禁用状态配置(同样用混入)
|
|
21
|
+
.btn-disabled-primary() {
|
|
22
|
+
@bg: @disabled-color;
|
|
23
|
+
@color: #F9F9F9;
|
|
24
|
+
@border: @disabled-color;
|
|
25
|
+
}
|
|
26
|
+
.btn-disabled-secondary-tertiary() {
|
|
27
|
+
@bg: @primary-color-disabled;
|
|
28
|
+
@color: @disabled-color;
|
|
29
|
+
@border: @border-color-base;
|
|
30
|
+
}
|
|
31
|
+
.btn-disabled-default() {
|
|
32
|
+
@bg: transparent;
|
|
33
|
+
@color: @disabled-color;
|
|
34
|
+
@border: @border-color-base;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ===================== 工具混入 =====================
|
|
38
|
+
.generate-btn-disabled(@bg, @color, @border) {
|
|
39
|
+
&[disabled],
|
|
40
|
+
&[disabled]:hover {
|
|
41
|
+
background: @bg;
|
|
42
|
+
color: @color;
|
|
43
|
+
border-color: @border;
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
opacity: 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style';
|
|
3
|
+
interface BaseComponentProps {
|
|
4
|
+
/**
|
|
5
|
+
* 类名
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 样式
|
|
10
|
+
*/
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
/**
|
|
13
|
+
* id
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
16
|
+
'data-*'?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CollapsibleProps extends BaseComponentProps {
|
|
19
|
+
/**
|
|
20
|
+
* 是否开启动画
|
|
21
|
+
*/
|
|
22
|
+
motion?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 子元素
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* 是否展开内容区域
|
|
29
|
+
*/
|
|
30
|
+
isOpen?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 动画执行的时间
|
|
33
|
+
*/
|
|
34
|
+
duration?: number;
|
|
35
|
+
/**
|
|
36
|
+
* 是否保留隐藏的面板 DOM 树,默认销毁
|
|
37
|
+
*/
|
|
38
|
+
keepDOM?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 配合 keepDOM 使用,为 true 时挂载时不会渲染组件
|
|
41
|
+
*/
|
|
42
|
+
lazyRender?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 折叠高度
|
|
45
|
+
*/
|
|
46
|
+
collapseHeight?: number;
|
|
47
|
+
/**
|
|
48
|
+
* 当 reCalcKey 改变时,将重新计算子节点的高度,用于优化动态渲染时的计算
|
|
49
|
+
*/
|
|
50
|
+
reCalcKey?: number | string;
|
|
51
|
+
/**
|
|
52
|
+
* 动画结束的回调
|
|
53
|
+
*/
|
|
54
|
+
onMotionEnd?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* 是否开启淡入淡出
|
|
57
|
+
*/
|
|
58
|
+
fade?: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface CollapsibleState {
|
|
61
|
+
domInRenderTree: boolean;
|
|
62
|
+
domHeight: number;
|
|
63
|
+
visible: boolean;
|
|
64
|
+
isTransitioning: boolean;
|
|
65
|
+
cacheIsOpen: boolean;
|
|
66
|
+
}
|
|
67
|
+
declare class Collapsible extends React.Component<CollapsibleProps, CollapsibleState> {
|
|
68
|
+
static defaultProps: {
|
|
69
|
+
isOpen: boolean;
|
|
70
|
+
duration: number;
|
|
71
|
+
motion: boolean;
|
|
72
|
+
keepDOM: boolean;
|
|
73
|
+
lazyRender: boolean;
|
|
74
|
+
collapseHeight: number;
|
|
75
|
+
fade: boolean;
|
|
76
|
+
};
|
|
77
|
+
prefixCls: string;
|
|
78
|
+
foundation: any;
|
|
79
|
+
private domRef;
|
|
80
|
+
private resizeObserver;
|
|
81
|
+
private hasBeenRendered;
|
|
82
|
+
static displayName: string;
|
|
83
|
+
constructor(props: CollapsibleProps);
|
|
84
|
+
private handleResize;
|
|
85
|
+
private isChildrenInRenderTree;
|
|
86
|
+
static getEntryInfo: (entry: ResizeObserverEntry) => {
|
|
87
|
+
isShown: boolean;
|
|
88
|
+
height: number;
|
|
89
|
+
};
|
|
90
|
+
private getDataAttr;
|
|
91
|
+
componentDidMount(): void;
|
|
92
|
+
static getDerivedStateFromProps(props: CollapsibleProps, prevState: CollapsibleState): Partial<CollapsibleState>;
|
|
93
|
+
componentDidUpdate(prevProps: Readonly<CollapsibleProps>, prevState: Readonly<CollapsibleState>): void;
|
|
94
|
+
componentWillUnmount(): void;
|
|
95
|
+
render(): React.JSX.Element;
|
|
96
|
+
}
|
|
97
|
+
export default Collapsible;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _configProvider = require("antd/es/config-provider");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
require("./style");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
14
|
+
class Collapsible extends _react.default.Component {
|
|
15
|
+
static defaultProps = {
|
|
16
|
+
isOpen: false,
|
|
17
|
+
duration: 250,
|
|
18
|
+
motion: true,
|
|
19
|
+
keepDOM: false,
|
|
20
|
+
lazyRender: false,
|
|
21
|
+
collapseHeight: 0,
|
|
22
|
+
fade: false
|
|
23
|
+
};
|
|
24
|
+
prefixCls = 'collapsible';
|
|
25
|
+
foundation;
|
|
26
|
+
domRef = /*#__PURE__*/_react.default.createRef();
|
|
27
|
+
resizeObserver = null;
|
|
28
|
+
hasBeenRendered = false;
|
|
29
|
+
static displayName;
|
|
30
|
+
// public cssClasses = {
|
|
31
|
+
// PREFIX: 'ant-collapsible',
|
|
32
|
+
// TRANSITION: 'ant-collapsible-transition',
|
|
33
|
+
// WRAPPER: 'ant-collapsible-wrapper',
|
|
34
|
+
// };
|
|
35
|
+
|
|
36
|
+
constructor(props) {
|
|
37
|
+
super(props);
|
|
38
|
+
this.state = {
|
|
39
|
+
domInRenderTree: false,
|
|
40
|
+
domHeight: 0,
|
|
41
|
+
visible: this.props.isOpen || false,
|
|
42
|
+
isTransitioning: false,
|
|
43
|
+
cacheIsOpen: this.props.isOpen || false
|
|
44
|
+
};
|
|
45
|
+
this.prefixCls = `${(0, _configProvider.globalConfig)().getPrefixCls(this.prefixCls)}`;
|
|
46
|
+
this.foundation = {
|
|
47
|
+
updateDOMInRenderTree: val => this.setState({
|
|
48
|
+
domInRenderTree: val
|
|
49
|
+
}),
|
|
50
|
+
updateDOMHeight: val => this.setState({
|
|
51
|
+
domHeight: val
|
|
52
|
+
}),
|
|
53
|
+
updateVisible: val => this.setState({
|
|
54
|
+
visible: val
|
|
55
|
+
}),
|
|
56
|
+
updateIsTransitioning: val => this.setState({
|
|
57
|
+
isTransitioning: val
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
handleResize = entryList => {
|
|
62
|
+
const entry = entryList[0];
|
|
63
|
+
if (entry) {
|
|
64
|
+
const entryInfo = Collapsible.getEntryInfo(entry);
|
|
65
|
+
this.foundation.updateDOMHeight(entryInfo.height);
|
|
66
|
+
this.foundation.updateDOMInRenderTree(entryInfo.isShown);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
isChildrenInRenderTree = () => {
|
|
70
|
+
if (this.domRef.current) {
|
|
71
|
+
return this.domRef.current.offsetHeight > 0;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
};
|
|
75
|
+
static getEntryInfo = entry => {
|
|
76
|
+
let inRenderTree;
|
|
77
|
+
if (entry.borderBoxSize) {
|
|
78
|
+
inRenderTree = !(entry.borderBoxSize[0].blockSize === 0 && entry.borderBoxSize[0].inlineSize === 0);
|
|
79
|
+
} else {
|
|
80
|
+
inRenderTree = !(entry.contentRect.height === 0 && entry.contentRect.width === 0);
|
|
81
|
+
}
|
|
82
|
+
let height = 0;
|
|
83
|
+
if (entry.borderBoxSize) {
|
|
84
|
+
height = Math.ceil(entry.borderBoxSize[0].blockSize);
|
|
85
|
+
} else {
|
|
86
|
+
const target = entry.target;
|
|
87
|
+
height = target.clientHeight;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
isShown: inRenderTree,
|
|
91
|
+
height
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
getDataAttr = props => {
|
|
95
|
+
const dataAttrs = {};
|
|
96
|
+
Object.keys(props).forEach(key => {
|
|
97
|
+
if (key.startsWith('data-')) {
|
|
98
|
+
dataAttrs[key] = String(props[key]);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return dataAttrs;
|
|
102
|
+
};
|
|
103
|
+
componentDidMount() {
|
|
104
|
+
this.resizeObserver = new ResizeObserver(this.handleResize);
|
|
105
|
+
if (this.domRef.current) {
|
|
106
|
+
this.resizeObserver.observe(this.domRef.current);
|
|
107
|
+
}
|
|
108
|
+
const domInRenderTree = this.isChildrenInRenderTree();
|
|
109
|
+
this.foundation.updateDOMInRenderTree(domInRenderTree);
|
|
110
|
+
if (domInRenderTree && this.domRef.current) {
|
|
111
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
static getDerivedStateFromProps(props, prevState) {
|
|
115
|
+
const newState = {};
|
|
116
|
+
const isOpenChanged = props.isOpen !== prevState.cacheIsOpen;
|
|
117
|
+
if (isOpenChanged) {
|
|
118
|
+
if (props.isOpen || !props.motion) {
|
|
119
|
+
newState.visible = props.isOpen;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (props.motion && isOpenChanged) {
|
|
123
|
+
newState.isTransitioning = true;
|
|
124
|
+
}
|
|
125
|
+
newState.cacheIsOpen = props.isOpen;
|
|
126
|
+
return newState;
|
|
127
|
+
}
|
|
128
|
+
componentDidUpdate(prevProps, prevState) {
|
|
129
|
+
const changedPropKeys = Object.keys((0, _lodash.pick)(this.props, ['reCalcKey'])).filter(key => !(0, _lodash.isEqual)(this.props[key], prevProps[key]));
|
|
130
|
+
const changedStateKeys = Object.keys((0, _lodash.pick)(this.state, ['domInRenderTree'])).filter(key => !(0, _lodash.isEqual)(this.state[key], prevState[key]));
|
|
131
|
+
if (changedPropKeys.includes('reCalcKey') && this.domRef.current) {
|
|
132
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
133
|
+
}
|
|
134
|
+
if (changedStateKeys.includes('domInRenderTree') && this.state.domInRenderTree && this.domRef.current) {
|
|
135
|
+
this.foundation.updateDOMHeight(this.domRef.current.scrollHeight);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
componentWillUnmount() {
|
|
139
|
+
if (this.resizeObserver) {
|
|
140
|
+
this.resizeObserver.disconnect();
|
|
141
|
+
this.resizeObserver = null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
const {
|
|
146
|
+
isOpen,
|
|
147
|
+
collapseHeight,
|
|
148
|
+
fade,
|
|
149
|
+
motion,
|
|
150
|
+
duration,
|
|
151
|
+
style,
|
|
152
|
+
className,
|
|
153
|
+
id,
|
|
154
|
+
keepDOM,
|
|
155
|
+
lazyRender,
|
|
156
|
+
onMotionEnd
|
|
157
|
+
} = this.props;
|
|
158
|
+
const {
|
|
159
|
+
domHeight,
|
|
160
|
+
isTransitioning,
|
|
161
|
+
visible
|
|
162
|
+
} = this.state;
|
|
163
|
+
const wrapperStyle = {
|
|
164
|
+
overflow: 'hidden',
|
|
165
|
+
height: isOpen ? domHeight : collapseHeight,
|
|
166
|
+
opacity: isOpen || !fade || collapseHeight !== 0 ? 1 : 0,
|
|
167
|
+
transitionDuration: `${motion && isTransitioning ? duration : 0}ms`,
|
|
168
|
+
...style
|
|
169
|
+
};
|
|
170
|
+
const wrapperCls = (0, _classnames.default)(`${this.prefixCls}-wrapper`, {
|
|
171
|
+
[`${this.prefixCls}-transition`]: motion && isTransitioning
|
|
172
|
+
}, className);
|
|
173
|
+
const shouldRender = keepDOM && (lazyRender ? this.hasBeenRendered : true) || collapseHeight !== 0 || visible || isOpen;
|
|
174
|
+
if (shouldRender && !this.hasBeenRendered) {
|
|
175
|
+
this.hasBeenRendered = true;
|
|
176
|
+
}
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
178
|
+
className: wrapperCls,
|
|
179
|
+
style: wrapperStyle,
|
|
180
|
+
onTransitionEnd: () => {
|
|
181
|
+
if (!isOpen) {
|
|
182
|
+
this.foundation.updateVisible(false);
|
|
183
|
+
}
|
|
184
|
+
this.foundation.updateIsTransitioning(false);
|
|
185
|
+
onMotionEnd?.();
|
|
186
|
+
}
|
|
187
|
+
}, this.getDataAttr(this.props)), /*#__PURE__*/_react.default.createElement("div", {
|
|
188
|
+
ref: this.domRef,
|
|
189
|
+
style: {
|
|
190
|
+
overflow: 'hidden'
|
|
191
|
+
},
|
|
192
|
+
id: id
|
|
193
|
+
}, shouldRender && this.props.children));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
197
|
+
Collapsible.displayName = 'Collapsible';
|
|
198
|
+
}
|
|
199
|
+
var _default = exports.default = Collapsible;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.less';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
|
|
3
|
+
@collapsible-prefix-cls: ~'@{ant-prefix}-collapsible';
|
|
4
|
+
|
|
5
|
+
@transition-duration-collapsible-height: 250ms;
|
|
6
|
+
@transition-function-collapsible-height: cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
7
|
+
@transition-delay-collapsible-height: 0ms;
|
|
8
|
+
|
|
9
|
+
@transition-duration-collapsible-opacity: 250ms;
|
|
10
|
+
@transition-function-collapsible-opacity: @ease-in;
|
|
11
|
+
@transition-delay-collapsible-opacity: 0ms;
|
|
12
|
+
|
|
13
|
+
// 容器基础样式
|
|
14
|
+
.@{collapsible-prefix-cls}-wrapper {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 过渡动画样式
|
|
19
|
+
.@{collapsible-prefix-cls}-transition {
|
|
20
|
+
transition: height @transition-duration-collapsible-height
|
|
21
|
+
@transition-function-collapsible-height @transition-delay-collapsible-height,
|
|
22
|
+
opacity @transition-duration-collapsible-opacity @transition-function-collapsible-opacity
|
|
23
|
+
@transition-delay-collapsible-opacity;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ButtonProps } from "..";
|
|
4
|
+
import type { DropDownProps } from 'antd';
|
|
5
|
+
import './style';
|
|
6
|
+
export declare type ActionItem = {
|
|
7
|
+
key: React.Key;
|
|
8
|
+
name: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
render?: () => ReactNode;
|
|
11
|
+
};
|
|
12
|
+
interface ICollapsibleActionItems {
|
|
13
|
+
maxCount?: number;
|
|
14
|
+
actionItems: ActionItem[];
|
|
15
|
+
className?: string;
|
|
16
|
+
divider?: ReactNode;
|
|
17
|
+
collapseIcon?: ReactNode;
|
|
18
|
+
dropdownProps?: Partial<DropDownProps>;
|
|
19
|
+
buttonProps?: Partial<ButtonProps>;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
onItemClick?: (key: React.Key) => void;
|
|
22
|
+
}
|
|
23
|
+
declare const CollapsibleActionItems: React.FC<ICollapsibleActionItems>;
|
|
24
|
+
export default CollapsibleActionItems;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _icons = require("@ant-design/icons");
|
|
9
|
+
var _ = require("./..");
|
|
10
|
+
var _antd = require("antd");
|
|
11
|
+
var _configProvider = require("antd/es/config-provider");
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
require("./style");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
|
+
const CollapsibleActionItems = props => {
|
|
17
|
+
const {
|
|
18
|
+
actionItems,
|
|
19
|
+
maxCount = 3,
|
|
20
|
+
className,
|
|
21
|
+
divider = /*#__PURE__*/_react.default.createElement(_antd.Divider, {
|
|
22
|
+
type: "vertical"
|
|
23
|
+
}),
|
|
24
|
+
collapseIcon = /*#__PURE__*/_react.default.createElement(_icons.EllipsisOutlined, null),
|
|
25
|
+
dropdownProps,
|
|
26
|
+
buttonProps,
|
|
27
|
+
style,
|
|
28
|
+
onItemClick
|
|
29
|
+
} = props;
|
|
30
|
+
const isOverMaxCount = actionItems.length > maxCount;
|
|
31
|
+
const prefixCls = (0, _configProvider.globalConfig)().getPrefixCls('collapsible-action-items');
|
|
32
|
+
const getActionItemNode = (item, isCollapse = false) => {
|
|
33
|
+
const customRender = item.render ? item.render() : null;
|
|
34
|
+
if (!isCollapse) return /*#__PURE__*/_react.default.createElement("span", {
|
|
35
|
+
className: `${prefixCls}__btn`,
|
|
36
|
+
key: item.key,
|
|
37
|
+
onClick: () => !item.disabled && onItemClick?.(item.key)
|
|
38
|
+
}, customRender || /*#__PURE__*/_react.default.createElement(_.Button, _extends({
|
|
39
|
+
type: "link",
|
|
40
|
+
disabled: item.disabled
|
|
41
|
+
}, buttonProps), item.name));
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_antd.Menu.Item, {
|
|
43
|
+
key: item.key,
|
|
44
|
+
disabled: item.disabled
|
|
45
|
+
}, customRender || item.name);
|
|
46
|
+
};
|
|
47
|
+
const displayAction = actionItems.slice(0, isOverMaxCount ? maxCount - 1 : maxCount).map(item => getActionItemNode(item, false));
|
|
48
|
+
const dropdownMenu = isOverMaxCount ? /*#__PURE__*/_react.default.createElement(_antd.Menu, {
|
|
49
|
+
"data-testid": "action-dropdown-menu",
|
|
50
|
+
onClick: info => onItemClick?.(info.key)
|
|
51
|
+
}, actionItems.slice(maxCount - 1).map(item => getActionItemNode(item, true))) : null;
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
53
|
+
className: (0, _classnames.default)(prefixCls, className),
|
|
54
|
+
style: style
|
|
55
|
+
}, displayAction.map((actionItem, index) => {
|
|
56
|
+
const showDivider = index < actionItems.length - 1;
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
58
|
+
key: actionItem.key
|
|
59
|
+
}, actionItem, showDivider && divider);
|
|
60
|
+
}), dropdownMenu && /*#__PURE__*/_react.default.createElement(_antd.Dropdown, _extends({
|
|
61
|
+
placement: 'bottomRight',
|
|
62
|
+
overlay: dropdownMenu,
|
|
63
|
+
getPopupContainer: triggerNode => triggerNode.parentElement ?? document.body
|
|
64
|
+
}, dropdownProps), /*#__PURE__*/_react.default.createElement("a", {
|
|
65
|
+
className: `${prefixCls}__icon`
|
|
66
|
+
}, collapseIcon)));
|
|
67
|
+
};
|
|
68
|
+
var _default = exports.default = CollapsibleActionItems;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './style';
|
|
3
|
+
import type { FlexProps } from './interface';
|
|
4
|
+
declare const Flex: React.ForwardRefExoticComponent<FlexProps<import("../_util/type").AnyObject> & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
} & React.RefAttributes<HTMLElement>>;
|
|
7
|
+
export default Flex;
|