@dtjoy/dt-design 1.0.1 → 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.js +12 -11
- package/esm/blockHeader/style/index.d.ts +1 -1
- package/esm/blockHeader/style/index.js +1 -1
- package/esm/blockHeader/style/index.less +8 -7
- package/esm/button/style/index.less +60 -46
- 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 +9 -0
- package/esm/index.js +7 -5
- 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/mixins/index.less +0 -0
- package/esm/style/themes/index.less +2 -1
- 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.js +12 -12
- package/lib/blockHeader/style/index.d.ts +1 -1
- package/lib/blockHeader/style/index.js +1 -1
- package/lib/blockHeader/style/index.less +8 -7
- package/lib/button/style/index.less +60 -46
- 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 +9 -0
- package/lib/index.js +65 -0
- 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/mixins/index.less +0 -0
- package/lib/style/themes/index.less +2 -1
- package/lib/style/themes/variable.less +1 -0
- package/package.json +142 -141
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isPresetSize(size) {
|
|
2
|
+
return ['small', 'middle', 'large'].includes(size);
|
|
3
|
+
}
|
|
4
|
+
export function isValidGapNumber(size) {
|
|
5
|
+
if (!size) {
|
|
6
|
+
// The case of size = 0 is deliberately excluded here, because the default value of the gap attribute in CSS is 0, so if the user passes 0 in, we can directly ignore it.
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return typeof size === 'number' && !Number.isNaN(size);
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useOrientation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useOrientation";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
var isValidOrientation = function isValidOrientation(orientation) {
|
|
3
|
+
return orientation === 'horizontal' || orientation === 'vertical';
|
|
4
|
+
};
|
|
5
|
+
export var useOrientation = function useOrientation(orientation, vertical, legacyDirection) {
|
|
6
|
+
return useMemo(function () {
|
|
7
|
+
var validOrientation = isValidOrientation(orientation);
|
|
8
|
+
var mergedOrientation;
|
|
9
|
+
if (validOrientation) {
|
|
10
|
+
mergedOrientation = orientation || 'horizontal';
|
|
11
|
+
} else if (typeof vertical === 'boolean') {
|
|
12
|
+
mergedOrientation = vertical ? 'vertical' : 'horizontal';
|
|
13
|
+
} else {
|
|
14
|
+
var validLegacyDirection = isValidOrientation(legacyDirection);
|
|
15
|
+
mergedOrientation = validLegacyDirection ? legacyDirection || 'horizontal' : 'horizontal';
|
|
16
|
+
}
|
|
17
|
+
return [mergedOrientation, mergedOrientation === 'vertical'];
|
|
18
|
+
}, [legacyDirection, orientation, vertical]);
|
|
19
|
+
};
|
package/esm/_util/type.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2
3
|
/** https://github.com/Microsoft/TypeScript/issues/29729 */
|
|
3
|
-
export declare type LiteralUnion<T extends string> = T | (
|
|
4
|
+
export declare type LiteralUnion<T, U extends Primitive = string> = T | (U & Record<never, never>);
|
|
4
5
|
export declare type AnyObject = Record<string, any>;
|
|
5
6
|
export declare type CustomComponent<P = AnyObject> = React.ComponentType<P> | string;
|
|
6
7
|
/**
|
package/esm/blockHeader/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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); }
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -15,11 +16,9 @@ import { QuestionOutlined, UpOutlined } from '@dtinsight/react-icons';
|
|
|
15
16
|
import { Tooltip } from 'antd';
|
|
16
17
|
import { globalConfig } from 'antd/es/config-provider';
|
|
17
18
|
import classNames from 'classnames';
|
|
18
|
-
// import useLocale from '../locale/useLocale';
|
|
19
19
|
import "./style";
|
|
20
|
-
import stles from "./style/index.less";
|
|
21
|
-
console.log(stles);
|
|
22
20
|
import { toTooltipProps } from "../_util";
|
|
21
|
+
import Collapsible from "../collapsible";
|
|
23
22
|
function isControlled(props) {
|
|
24
23
|
return props.expand !== undefined;
|
|
25
24
|
}
|
|
@@ -59,15 +58,13 @@ var BlockHeader = function BlockHeader(props) {
|
|
|
59
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
60
59
|
internalExpand = _useState2[0],
|
|
61
60
|
setInternalExpand = _useState2[1];
|
|
62
|
-
// const locale = useLocale('BlockHeader');
|
|
63
|
-
|
|
64
61
|
var currentExpand = isControlled(props) ? expand : internalExpand;
|
|
65
62
|
|
|
66
63
|
// 只有在有了 children 并且设置了 expand/defaultExpand 的时候才能够展开收起
|
|
67
64
|
var showCollapse = (typeof expand === 'boolean' || typeof defaultExpand === 'boolean') && children;
|
|
68
65
|
var tooltipProps = toTooltipProps(tooltip);
|
|
69
66
|
var bottomStyle;
|
|
70
|
-
if (spaceBottom) bottomStyle = showCollapse && currentExpand ? {
|
|
67
|
+
if (spaceBottom) bottomStyle = showCollapse && !currentExpand ? {
|
|
71
68
|
marginBottom: 0
|
|
72
69
|
} : {
|
|
73
70
|
marginBottom: spaceBottom
|
|
@@ -94,7 +91,9 @@ var BlockHeader = function BlockHeader(props) {
|
|
|
94
91
|
className: "title__text"
|
|
95
92
|
}, title), tooltipProps !== null && tooltipProps !== void 0 && tooltipProps.title ? /*#__PURE__*/React.createElement("div", {
|
|
96
93
|
className: "title__tooltip"
|
|
97
|
-
}, /*#__PURE__*/React.createElement(Tooltip,
|
|
94
|
+
}, /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltipProps, {
|
|
95
|
+
className: classNames(tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className, 'anticon')
|
|
96
|
+
}), /*#__PURE__*/React.createElement(QuestionOutlined, null))) : null, description ? /*#__PURE__*/React.createElement("div", {
|
|
98
97
|
className: "title__description"
|
|
99
98
|
}, description) : null), addonAfter && /*#__PURE__*/React.createElement("div", {
|
|
100
99
|
className: "title__addon-after"
|
|
@@ -102,14 +101,16 @@ var BlockHeader = function BlockHeader(props) {
|
|
|
102
101
|
className: "title__collapse"
|
|
103
102
|
}, /*#__PURE__*/React.createElement("div", {
|
|
104
103
|
className: "collapse__text"
|
|
105
|
-
}), /*#__PURE__*/React.createElement(UpOutlined, {
|
|
106
|
-
className: classNames('collapse__icon', {
|
|
104
|
+
}, currentExpand ? '收起' : '展开'), /*#__PURE__*/React.createElement(UpOutlined, {
|
|
105
|
+
className: classNames('collapse__icon', 'anticon', {
|
|
107
106
|
'collapse__icon--up': currentExpand,
|
|
108
107
|
'collapse__icon--down': !currentExpand
|
|
109
108
|
})
|
|
110
|
-
}))),
|
|
109
|
+
}))), /*#__PURE__*/React.createElement(Collapsible, {
|
|
110
|
+
isOpen: !currentExpand
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
111
112
|
className: classNames("".concat(prefixCls, "__content"), contentClassName, _defineProperty({}, "".concat(prefixCls, "__content--active"), currentExpand || !showCollapse)),
|
|
112
113
|
style: contentStyle
|
|
113
|
-
}, children));
|
|
114
|
+
}, children)));
|
|
114
115
|
};
|
|
115
116
|
export default BlockHeader;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../../style
|
|
1
|
+
import '../../style';
|
|
2
2
|
import './index.less';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../../style
|
|
1
|
+
import "../../style";
|
|
2
2
|
import "./index.less";
|
|
@@ -129,14 +129,15 @@
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
&__content {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
padding: 16px 24px;
|
|
133
|
+
|
|
134
|
+
// opacity: 0;
|
|
135
|
+
// height: 0;
|
|
136
|
+
// overflow: hidden;
|
|
137
|
+
// transition: opacity 0.5s ease, height 0.5s ease;
|
|
136
138
|
&--active {
|
|
137
|
-
opacity: 1;
|
|
138
|
-
|
|
139
|
-
height: auto;
|
|
139
|
+
// opacity: 1;
|
|
140
|
+
// height: auto;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
}
|
|
@@ -1,120 +1,134 @@
|
|
|
1
1
|
@import '../../style/themes/index.less';
|
|
2
|
+
@import './mixin.less';
|
|
2
3
|
|
|
3
|
-
@prefix-cls: ~'@{ant-prefix}-btn';
|
|
4
|
+
@btn-prefix-cls: ~'@{ant-prefix}-btn';
|
|
4
5
|
|
|
5
|
-
.@{prefix-cls} {
|
|
6
|
+
.@{btn-prefix-cls} {
|
|
6
7
|
display: inline-flex;
|
|
7
8
|
align-items: center;
|
|
8
9
|
justify-content: center;
|
|
9
|
-
padding: 4px 16px;
|
|
10
10
|
|
|
11
|
+
// 引用中尺寸配置(核心:先调用混入,再取值)
|
|
12
|
+
.btn-size-middle();
|
|
13
|
+
padding: @padding;
|
|
14
|
+
|
|
15
|
+
// 图标样式
|
|
11
16
|
&__icon {
|
|
12
17
|
display: inline-flex;
|
|
13
18
|
align-items: center;
|
|
14
19
|
justify-content: center;
|
|
15
20
|
font-size: inherit;
|
|
16
21
|
line-height: 0;
|
|
17
|
-
|
|
22
|
+
|
|
18
23
|
.dtstack-icon {
|
|
19
24
|
font-size: inherit;
|
|
20
25
|
}
|
|
21
26
|
|
|
27
|
+
// 小尺寸图标
|
|
22
28
|
&--small {
|
|
23
|
-
|
|
29
|
+
.btn-size-small();
|
|
30
|
+
font-size: @icon-font-size;
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
// 中尺寸图标
|
|
26
33
|
&--middle {
|
|
27
|
-
|
|
34
|
+
.btn-size-middle();
|
|
35
|
+
font-size: @icon-font-size;
|
|
28
36
|
}
|
|
29
|
-
|
|
37
|
+
// 大尺寸图标
|
|
30
38
|
&--large {
|
|
31
|
-
|
|
39
|
+
.btn-size-large();
|
|
40
|
+
font-size: @icon-font-size;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
// 图标与文字间距
|
|
44
|
+
& + .@{btn-prefix-cls}__text {
|
|
35
45
|
&--small {
|
|
36
|
-
|
|
46
|
+
.btn-size-small();
|
|
47
|
+
margin-left: @icon-text-margin;
|
|
37
48
|
}
|
|
38
|
-
|
|
39
49
|
&--middle {
|
|
40
|
-
|
|
50
|
+
.btn-size-middle();
|
|
51
|
+
margin-left: @icon-text-margin;
|
|
41
52
|
}
|
|
42
|
-
|
|
43
53
|
&--large {
|
|
44
|
-
|
|
54
|
+
.btn-size-large();
|
|
55
|
+
margin-left: @icon-text-margin;
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
59
|
|
|
60
|
+
// 文字样式
|
|
49
61
|
&__text {
|
|
50
62
|
display: inline-block;
|
|
51
63
|
|
|
52
64
|
&--small {
|
|
53
|
-
|
|
65
|
+
.btn-size-small();
|
|
66
|
+
font-size: @text-font-size;
|
|
54
67
|
}
|
|
55
|
-
|
|
56
68
|
&--middle {
|
|
57
|
-
|
|
69
|
+
.btn-size-middle();
|
|
70
|
+
font-size: @text-font-size;
|
|
58
71
|
}
|
|
59
|
-
|
|
60
72
|
&--large {
|
|
61
|
-
|
|
73
|
+
.btn-size-large();
|
|
74
|
+
font-size: @text-font-size;
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
|
|
78
|
+
// 尺寸变体
|
|
65
79
|
&-sm {
|
|
66
|
-
|
|
80
|
+
.btn-size-small();
|
|
81
|
+
padding: @padding;
|
|
67
82
|
}
|
|
68
|
-
|
|
69
83
|
&-lg {
|
|
70
|
-
|
|
84
|
+
.btn-size-large();
|
|
85
|
+
padding: @padding;
|
|
71
86
|
}
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
&-primary
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
// 主要按钮
|
|
89
|
+
&-primary {
|
|
90
|
+
.btn-disabled-primary();
|
|
91
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
92
|
+
|
|
93
|
+
&:hover,
|
|
94
|
+
&:focus {
|
|
95
|
+
background-color: #225fdb;
|
|
96
|
+
}
|
|
78
97
|
}
|
|
79
98
|
|
|
99
|
+
// 次要按钮
|
|
80
100
|
&-secondary {
|
|
81
101
|
border-color: @primary-color;
|
|
82
102
|
color: @primary-color;
|
|
83
103
|
|
|
84
104
|
&:hover,
|
|
85
105
|
&:focus {
|
|
86
|
-
background-color: @
|
|
106
|
+
background-color: fade(@primary-color, 10%);
|
|
87
107
|
}
|
|
108
|
+
|
|
109
|
+
.btn-disabled-secondary-tertiary();
|
|
110
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
88
111
|
}
|
|
89
112
|
|
|
113
|
+
// 三级按钮
|
|
90
114
|
&-tertiary {
|
|
91
|
-
|
|
115
|
+
background-color: #f3f3f3;
|
|
92
116
|
border-color: @border-color-base;
|
|
93
117
|
|
|
94
118
|
&:hover,
|
|
95
119
|
&:focus {
|
|
96
|
-
background-color: @
|
|
120
|
+
background-color: fade(@primary-color, 10%);
|
|
97
121
|
border-color: @primary-color;
|
|
98
122
|
color: @primary-color;
|
|
99
123
|
}
|
|
100
|
-
}
|
|
101
124
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
&[disabled],
|
|
105
|
-
&[disabled]:hover {
|
|
106
|
-
background: #f3f3f3;
|
|
107
|
-
color: @disabled-color;
|
|
108
|
-
border-color: @border-color-base;
|
|
109
|
-
}
|
|
125
|
+
.btn-disabled-secondary-tertiary();
|
|
126
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
110
127
|
}
|
|
111
128
|
|
|
129
|
+
// 默认按钮
|
|
112
130
|
&-default {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
background: transparent;
|
|
116
|
-
color: @disabled-color;
|
|
117
|
-
border-color: @border-color-base;
|
|
118
|
-
}
|
|
131
|
+
.btn-disabled-default();
|
|
132
|
+
.generate-btn-disabled(@bg, @color, @border);
|
|
119
133
|
}
|
|
120
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;
|