@dtjoy/dt-design 1.0.1 → 1.0.3
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 +9 -8
- 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 +10 -1
- package/esm/index.js +8 -6
- package/esm/overflowList/index.d.ts +39 -0
- package/esm/overflowList/index.js +165 -0
- package/esm/overflowList/style/index.d.ts +2 -0
- package/esm/overflowList/style/index.js +2 -0
- package/esm/overflowList/style/index.less +9 -0
- package/esm/resize/index.d.ts +8 -0
- package/esm/resize/index.js +29 -0
- package/esm/resizeObserver/index.d.ts +45 -0
- package/esm/resizeObserver/index.js +175 -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 +197 -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 +9 -8
- 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 +40 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +73 -1
- package/lib/overflowList/index.d.ts +39 -0
- package/lib/overflowList/index.js +143 -0
- package/lib/overflowList/style/index.d.ts +2 -0
- package/lib/overflowList/style/index.js +4 -0
- package/lib/overflowList/style/index.less +9 -0
- package/lib/resize/index.d.ts +8 -0
- package/lib/resize/index.js +38 -0
- package/lib/resizeObserver/index.d.ts +45 -0
- package/lib/resizeObserver/index.js +136 -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 +186 -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 +11 -19
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var _excluded = ["className", "type", "icon", "color", "loading", "rounded", "background", "style", "children"];
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
|
+
import React, { useMemo } from 'react';
|
|
12
|
+
import { LoadingOutlined } from '@ant-design/icons';
|
|
13
|
+
import { Spin } from 'antd';
|
|
14
|
+
import { globalConfig } from 'antd/es/config-provider';
|
|
15
|
+
import classNames from 'classnames';
|
|
16
|
+
import "./style";
|
|
17
|
+
export var PRESET_COLOR_TYPES = Object.freeze(['blue', 'yellow', 'green', 'gray', 'red', 'purple', 'cyan', 'pink']);
|
|
18
|
+
export var STATUS_TAG_TYPES = Object.freeze(['default', 'outline', 'fill']);
|
|
19
|
+
var DEFAULT_OPACITY = 0.15;
|
|
20
|
+
/**
|
|
21
|
+
* 校验是否为预设颜色
|
|
22
|
+
* @param color 待校验颜色值
|
|
23
|
+
*/
|
|
24
|
+
function isPresetColor(color) {
|
|
25
|
+
if (!color || typeof color !== 'string') return false;
|
|
26
|
+
return PRESET_COLOR_TYPES.includes(color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 计算颜色的透明版本
|
|
31
|
+
* @param color 原始颜色(支持hex/rgb/rgba)
|
|
32
|
+
* @param opacity 透明度(默认0.15)
|
|
33
|
+
*/
|
|
34
|
+
function calculateTransparentColor(color) {
|
|
35
|
+
var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPACITY;
|
|
36
|
+
if (!color) return 'rgba(0, 0, 0, 0.15)';
|
|
37
|
+
if (color.startsWith('rgb')) {
|
|
38
|
+
if (color.startsWith('rgba')) return color.replace(/,\s*[\d.]+(?=\))/, ",".concat(opacity));
|
|
39
|
+
return "".concat(color.slice(0, -1), ",").concat(opacity, ")");
|
|
40
|
+
}
|
|
41
|
+
var hex = color.trim().replace(/^#/, '');
|
|
42
|
+
if (hex.length === 3) {
|
|
43
|
+
hex = hex.split('').map(function (char) {
|
|
44
|
+
return char + char;
|
|
45
|
+
}).join('');
|
|
46
|
+
}
|
|
47
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(hex)) return 'rgba(0, 0, 0, 0.15)';
|
|
48
|
+
var r = parseInt(hex.substring(0, 2), 16);
|
|
49
|
+
var g = parseInt(hex.substring(2, 4), 16);
|
|
50
|
+
var b = parseInt(hex.substring(4, 6), 16);
|
|
51
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
52
|
+
}
|
|
53
|
+
var StatusTag = /*#__PURE__*/React.memo(function (props) {
|
|
54
|
+
var className = props.className,
|
|
55
|
+
_props$type = props.type,
|
|
56
|
+
type = _props$type === void 0 ? 'default' : _props$type,
|
|
57
|
+
icon = props.icon,
|
|
58
|
+
_props$color = props.color,
|
|
59
|
+
color = _props$color === void 0 ? 'green' : _props$color,
|
|
60
|
+
_props$loading = props.loading,
|
|
61
|
+
loading = _props$loading === void 0 ? false : _props$loading,
|
|
62
|
+
_props$rounded = props.rounded,
|
|
63
|
+
rounded = _props$rounded === void 0 ? false : _props$rounded,
|
|
64
|
+
background = props.background,
|
|
65
|
+
style = props.style,
|
|
66
|
+
children = props.children,
|
|
67
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
68
|
+
var prefixCls = globalConfig().getPrefixCls('status-tag');
|
|
69
|
+
var showDefaultIcon = useMemo(function () {
|
|
70
|
+
return icon === undefined;
|
|
71
|
+
}, [icon]);
|
|
72
|
+
var containerClasses = useMemo(function () {
|
|
73
|
+
return classNames(prefixCls, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "--border"), type === 'outline'), "".concat(prefixCls, "--fill"), type === 'fill'), "".concat(prefixCls, "--rounded"), rounded), "".concat(prefixCls, "__").concat(color, "--fill"), type === 'fill' && isPresetColor(color)));
|
|
74
|
+
}, [className, type, color, rounded, prefixCls]);
|
|
75
|
+
var customColorStyle = useMemo(function () {
|
|
76
|
+
if (type !== 'fill' || isPresetColor(color)) return {};
|
|
77
|
+
return {
|
|
78
|
+
color: color,
|
|
79
|
+
background: background || calculateTransparentColor(color)
|
|
80
|
+
};
|
|
81
|
+
}, [type, color, background]);
|
|
82
|
+
var iconStyleConfig = useMemo(function () {
|
|
83
|
+
if (isPresetColor(color)) {
|
|
84
|
+
return {
|
|
85
|
+
className: classNames('anticon', _defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "__").concat(color, "--icon"), true), "".concat(prefixCls, "__icon--default"), !icon), "".concat(prefixCls, "__").concat(color, "--iconBg"), !icon)),
|
|
86
|
+
style: {}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
className: classNames('anticon', _defineProperty({}, "".concat(prefixCls, "__icon--default"), !icon)),
|
|
91
|
+
style: {
|
|
92
|
+
color: icon ? color : undefined,
|
|
93
|
+
background: !icon ? color : undefined
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}, [color, icon, prefixCls]);
|
|
97
|
+
var loadingIndicator = useMemo(function () {
|
|
98
|
+
return /*#__PURE__*/React.createElement(LoadingOutlined, {
|
|
99
|
+
className: "".concat(prefixCls, "__icon ").concat(prefixCls, "__icon--loading")
|
|
100
|
+
});
|
|
101
|
+
}, [prefixCls]);
|
|
102
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, restProps, {
|
|
103
|
+
className: containerClasses,
|
|
104
|
+
style: _objectSpread(_objectSpread({}, customColorStyle), style),
|
|
105
|
+
"aria-busy": loading
|
|
106
|
+
}), loading ? /*#__PURE__*/React.createElement(Spin, {
|
|
107
|
+
spinning: true,
|
|
108
|
+
indicator: loadingIndicator,
|
|
109
|
+
size: "small"
|
|
110
|
+
}) : (icon || showDefaultIcon) && /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: "".concat(prefixCls, "__icon")
|
|
112
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
113
|
+
className: iconStyleConfig.className,
|
|
114
|
+
style: iconStyleConfig.style
|
|
115
|
+
}, icon !== null && icon !== void 0 ? icon : null)), children && /*#__PURE__*/React.createElement("span", {
|
|
116
|
+
className: "".concat(prefixCls, "__text")
|
|
117
|
+
}, children));
|
|
118
|
+
});
|
|
119
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
120
|
+
StatusTag.displayName = 'StatusTag';
|
|
121
|
+
}
|
|
122
|
+
export default StatusTag;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import '../../style/themes/index.less';
|
|
2
|
+
@import './mixin.less';
|
|
3
|
+
@import './mixin.less';
|
|
4
|
+
|
|
5
|
+
@status-tag-prefix-cls: ~'@{ant-prefix}-status-tag';
|
|
6
|
+
|
|
7
|
+
@keyframes spin {
|
|
8
|
+
from {
|
|
9
|
+
transform: rotate(0deg);
|
|
10
|
+
}
|
|
11
|
+
to {
|
|
12
|
+
transform: rotate(360deg);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 主选择器
|
|
17
|
+
.@{status-tag-prefix-cls} {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
width: fit-content;
|
|
21
|
+
height: 24px;
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
color: #3d446e;
|
|
24
|
+
|
|
25
|
+
.ant-spin {
|
|
26
|
+
font-size: 14px; // 修复 antd 字体居中问题
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&--border {
|
|
30
|
+
padding: 2px 12px;
|
|
31
|
+
border: 1px solid #d8dae2;
|
|
32
|
+
background-color: #fff;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&--fill {
|
|
36
|
+
padding: 2px 12px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&--rounded {
|
|
40
|
+
border-radius: 14px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&__icon {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
font-size: 16px;
|
|
47
|
+
margin-right: 8px;
|
|
48
|
+
|
|
49
|
+
&--default {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
width: 6px;
|
|
52
|
+
height: 6px;
|
|
53
|
+
border-radius: 50%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&--loading {
|
|
57
|
+
animation: spin 1s linear infinite;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__text {
|
|
62
|
+
font-size: 12px;
|
|
63
|
+
font-weight: 400;
|
|
64
|
+
line-height: 22px;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 调用颜色映射 Mixin,生成所有颜色的样式
|
|
69
|
+
.color-map();
|
|
70
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.status-color(@color, @bg) {
|
|
2
|
+
&--icon {
|
|
3
|
+
color: @color;
|
|
4
|
+
}
|
|
5
|
+
&--fill {
|
|
6
|
+
color: @color;
|
|
7
|
+
background-color: @bg;
|
|
8
|
+
}
|
|
9
|
+
&--iconBg {
|
|
10
|
+
background: @color;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.color-map() {
|
|
15
|
+
&__yellow {
|
|
16
|
+
.status-color(#FBB310, #FFF4D9);
|
|
17
|
+
}
|
|
18
|
+
&__blue {
|
|
19
|
+
.status-color(#1d78ff, #E8F1FF);
|
|
20
|
+
}
|
|
21
|
+
&__green {
|
|
22
|
+
.status-color(#11d782, #E7FBF7);
|
|
23
|
+
}
|
|
24
|
+
&__gray {
|
|
25
|
+
.status-color(#B1B4C5, #F5F5F8);
|
|
26
|
+
}
|
|
27
|
+
&__red {
|
|
28
|
+
.status-color(#F96C5B, #FDE9E7);
|
|
29
|
+
}
|
|
30
|
+
&__purple {
|
|
31
|
+
.status-color(#AC9DFF, #EAE6FF);
|
|
32
|
+
}
|
|
33
|
+
&__cyan {
|
|
34
|
+
.status-color(#2cccdf, #E7F8FA);
|
|
35
|
+
}
|
|
36
|
+
&__pink {
|
|
37
|
+
.status-color(#FF82AE, #FFE6EF);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
File without changes
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import '~antd/es/style/themes/default.less';
|
|
2
|
+
@import './variable.less';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@primary-color-disabled: #f3f3f3;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isPresetSize = isPresetSize;
|
|
7
|
+
exports.isValidGapNumber = isValidGapNumber;
|
|
8
|
+
function isPresetSize(size) {
|
|
9
|
+
return ['small', 'middle', 'large'].includes(size);
|
|
10
|
+
}
|
|
11
|
+
function isValidGapNumber(size) {
|
|
12
|
+
if (!size) {
|
|
13
|
+
// 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.
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return typeof size === 'number' && !Number.isNaN(size);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useOrientation';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _useOrientation = require("./useOrientation");
|
|
7
|
+
Object.keys(_useOrientation).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _useOrientation[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _useOrientation[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useOrientation = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
const isValidOrientation = orientation => {
|
|
9
|
+
return orientation === 'horizontal' || orientation === 'vertical';
|
|
10
|
+
};
|
|
11
|
+
const useOrientation = (orientation, vertical, legacyDirection) => {
|
|
12
|
+
return (0, _react.useMemo)(() => {
|
|
13
|
+
const validOrientation = isValidOrientation(orientation);
|
|
14
|
+
let mergedOrientation;
|
|
15
|
+
if (validOrientation) {
|
|
16
|
+
mergedOrientation = orientation || 'horizontal';
|
|
17
|
+
} else if (typeof vertical === 'boolean') {
|
|
18
|
+
mergedOrientation = vertical ? 'vertical' : 'horizontal';
|
|
19
|
+
} else {
|
|
20
|
+
const validLegacyDirection = isValidOrientation(legacyDirection);
|
|
21
|
+
mergedOrientation = validLegacyDirection ? legacyDirection || 'horizontal' : 'horizontal';
|
|
22
|
+
}
|
|
23
|
+
return [mergedOrientation, mergedOrientation === 'vertical'];
|
|
24
|
+
}, [legacyDirection, orientation, vertical]);
|
|
25
|
+
};
|
|
26
|
+
exports.useOrientation = useOrientation;
|
package/lib/_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/lib/blockHeader/index.js
CHANGED
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _icons = require("@ant-design/icons");
|
|
9
9
|
var _antd = require("antd");
|
|
10
10
|
var _configProvider = require("antd/es/config-provider");
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
require("./style");
|
|
13
|
-
var _index = _interopRequireDefault(require("./style/index.less"));
|
|
14
13
|
var _util = require("../_util");
|
|
14
|
+
var _collapsible = _interopRequireDefault(require("../collapsible"));
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log(_index.default);
|
|
18
|
+
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); }
|
|
21
19
|
function isControlled(props) {
|
|
22
20
|
return props.expand !== undefined;
|
|
23
21
|
}
|
|
@@ -46,15 +44,13 @@ const BlockHeader = function (props) {
|
|
|
46
44
|
titleStyle
|
|
47
45
|
} = props;
|
|
48
46
|
const [internalExpand, setInternalExpand] = (0, _react.useState)(defaultExpand);
|
|
49
|
-
// const locale = useLocale('BlockHeader');
|
|
50
|
-
|
|
51
47
|
const currentExpand = isControlled(props) ? expand : internalExpand;
|
|
52
48
|
|
|
53
49
|
// 只有在有了 children 并且设置了 expand/defaultExpand 的时候才能够展开收起
|
|
54
50
|
const showCollapse = (typeof expand === 'boolean' || typeof defaultExpand === 'boolean') && children;
|
|
55
51
|
const tooltipProps = (0, _util.toTooltipProps)(tooltip);
|
|
56
52
|
let bottomStyle;
|
|
57
|
-
if (spaceBottom) bottomStyle = showCollapse && currentExpand ? {
|
|
53
|
+
if (spaceBottom) bottomStyle = showCollapse && !currentExpand ? {
|
|
58
54
|
marginBottom: 0
|
|
59
55
|
} : {
|
|
60
56
|
marginBottom: spaceBottom
|
|
@@ -85,7 +81,9 @@ const BlockHeader = function (props) {
|
|
|
85
81
|
className: "title__text"
|
|
86
82
|
}, title), tooltipProps?.title ? /*#__PURE__*/_react.default.createElement("div", {
|
|
87
83
|
className: `title__tooltip`
|
|
88
|
-
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip,
|
|
84
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, _extends({}, tooltipProps, {
|
|
85
|
+
className: (0, _classnames.default)(tooltipProps?.className)
|
|
86
|
+
}), /*#__PURE__*/_react.default.createElement(_icons.QuestionCircleOutlined, null))) : null, description ? /*#__PURE__*/_react.default.createElement("div", {
|
|
89
87
|
className: `title__description`
|
|
90
88
|
}, description) : null), addonAfter && /*#__PURE__*/_react.default.createElement("div", {
|
|
91
89
|
className: `title__addon-after`
|
|
@@ -93,16 +91,18 @@ const BlockHeader = function (props) {
|
|
|
93
91
|
className: `title__collapse`
|
|
94
92
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
95
93
|
className: "collapse__text"
|
|
96
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
94
|
+
}, currentExpand ? '收起' : '展开'), /*#__PURE__*/_react.default.createElement(_icons.UpOutlined, {
|
|
97
95
|
className: (0, _classnames.default)('collapse__icon', {
|
|
98
96
|
'collapse__icon--up': currentExpand,
|
|
99
97
|
'collapse__icon--down': !currentExpand
|
|
100
98
|
})
|
|
101
|
-
}))),
|
|
99
|
+
}))), /*#__PURE__*/_react.default.createElement(_collapsible.default, {
|
|
100
|
+
isOpen: !currentExpand
|
|
101
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
102
102
|
className: (0, _classnames.default)(`${prefixCls}__content`, contentClassName, {
|
|
103
103
|
[`${prefixCls}__content--active`]: currentExpand || !showCollapse
|
|
104
104
|
}),
|
|
105
105
|
style: contentStyle
|
|
106
|
-
}, children));
|
|
106
|
+
}, children)));
|
|
107
107
|
};
|
|
108
108
|
var _default = exports.default = BlockHeader;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../../style
|
|
1
|
+
import '../../style';
|
|
2
2
|
import './index.less';
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
&__tooltip {
|
|
86
86
|
display: flex;
|
|
87
87
|
margin-right: 4px;
|
|
88
|
-
font-size:
|
|
88
|
+
font-size: 14px;
|
|
89
89
|
color: #b1b4c5;
|
|
90
90
|
cursor: pointer;
|
|
91
91
|
}
|
|
@@ -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
|
}
|