@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.
Files changed (155) hide show
  1. package/esm/_util/gapSize.d.ts +3 -0
  2. package/esm/_util/gapSize.js +10 -0
  3. package/esm/_util/hooks/index.d.ts +1 -0
  4. package/esm/_util/hooks/index.js +1 -0
  5. package/esm/_util/hooks/useOrientation.d.ts +2 -0
  6. package/esm/_util/hooks/useOrientation.js +19 -0
  7. package/esm/_util/isNonNullable.d.ts +2 -0
  8. package/esm/_util/isNonNullable.js +4 -0
  9. package/esm/_util/type.d.ts +2 -1
  10. package/esm/blockHeader/index.js +12 -11
  11. package/esm/blockHeader/style/index.d.ts +1 -1
  12. package/esm/blockHeader/style/index.js +1 -1
  13. package/esm/blockHeader/style/index.less +9 -8
  14. package/esm/button/style/index.less +60 -46
  15. package/esm/button/style/mixin.less +47 -0
  16. package/esm/collapsible/index.d.ts +97 -0
  17. package/esm/collapsible/index.js +234 -0
  18. package/esm/collapsible/style/index.d.ts +1 -0
  19. package/esm/collapsible/style/index.js +1 -0
  20. package/esm/collapsible/style/index.less +24 -0
  21. package/esm/collapsibleActionItems/index.d.ts +24 -0
  22. package/esm/collapsibleActionItems/index.js +74 -0
  23. package/esm/collapsibleActionItems/style/index.d.ts +2 -0
  24. package/esm/collapsibleActionItems/style/index.js +2 -0
  25. package/esm/collapsibleActionItems/style/index.less +7 -0
  26. package/esm/flex/index.d.ts +7 -0
  27. package/esm/flex/index.js +62 -0
  28. package/esm/flex/interface.d.ts +16 -0
  29. package/esm/flex/interface.js +1 -0
  30. package/esm/flex/style/index.d.ts +2 -0
  31. package/esm/flex/style/index.js +2 -0
  32. package/esm/flex/style/index.less +77 -0
  33. package/esm/flex/utils.d.ts +7 -0
  34. package/esm/flex/utils.js +33 -0
  35. package/esm/index.d.ts +10 -1
  36. package/esm/index.js +8 -6
  37. package/esm/overflowList/index.d.ts +39 -0
  38. package/esm/overflowList/index.js +165 -0
  39. package/esm/overflowList/style/index.d.ts +2 -0
  40. package/esm/overflowList/style/index.js +2 -0
  41. package/esm/overflowList/style/index.less +9 -0
  42. package/esm/resize/index.d.ts +8 -0
  43. package/esm/resize/index.js +29 -0
  44. package/esm/resizeObserver/index.d.ts +45 -0
  45. package/esm/resizeObserver/index.js +175 -0
  46. package/esm/splitter/Panel.d.ts +7 -0
  47. package/esm/splitter/Panel.js +38 -0
  48. package/esm/splitter/SplitBar.d.ts +24 -0
  49. package/esm/splitter/SplitBar.js +185 -0
  50. package/esm/splitter/Splitter.d.ts +5 -0
  51. package/esm/splitter/Splitter.js +197 -0
  52. package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
  53. package/esm/splitter/hooks/sizeUtil.js +63 -0
  54. package/esm/splitter/hooks/useItems.d.ts +14 -0
  55. package/esm/splitter/hooks/useItems.js +44 -0
  56. package/esm/splitter/hooks/useResizable.d.ts +10 -0
  57. package/esm/splitter/hooks/useResizable.js +73 -0
  58. package/esm/splitter/hooks/useResize.d.ts +6 -0
  59. package/esm/splitter/hooks/useResize.js +158 -0
  60. package/esm/splitter/hooks/useSizes.d.ts +4 -0
  61. package/esm/splitter/hooks/useSizes.js +80 -0
  62. package/esm/splitter/index.d.ts +8 -0
  63. package/esm/splitter/index.js +5 -0
  64. package/esm/splitter/interface.d.ts +68 -0
  65. package/esm/splitter/interface.js +1 -0
  66. package/esm/splitter/style/index.d.ts +2 -0
  67. package/esm/splitter/style/index.js +2 -0
  68. package/esm/splitter/style/index.less +312 -0
  69. package/esm/statusTag/index.d.ts +28 -0
  70. package/esm/statusTag/index.js +122 -0
  71. package/esm/statusTag/style/index.d.ts +2 -0
  72. package/esm/statusTag/style/index.js +2 -0
  73. package/esm/statusTag/style/index.less +70 -0
  74. package/esm/statusTag/style/mixin.less +39 -0
  75. package/esm/style/mixins/index.less +0 -0
  76. package/esm/style/themes/index.less +2 -1
  77. package/esm/style/themes/variable.less +1 -0
  78. package/lib/_util/gapSize.d.ts +3 -0
  79. package/lib/_util/gapSize.js +17 -0
  80. package/lib/_util/hooks/index.d.ts +1 -0
  81. package/lib/_util/hooks/index.js +16 -0
  82. package/lib/_util/hooks/useOrientation.d.ts +2 -0
  83. package/lib/_util/hooks/useOrientation.js +26 -0
  84. package/lib/_util/isNonNullable.d.ts +2 -0
  85. package/lib/_util/isNonNullable.js +10 -0
  86. package/lib/_util/type.d.ts +2 -1
  87. package/lib/blockHeader/index.js +12 -12
  88. package/lib/blockHeader/style/index.d.ts +1 -1
  89. package/lib/blockHeader/style/index.js +1 -1
  90. package/lib/blockHeader/style/index.less +9 -8
  91. package/lib/button/style/index.less +60 -46
  92. package/lib/button/style/mixin.less +47 -0
  93. package/lib/collapsible/index.d.ts +97 -0
  94. package/lib/collapsible/index.js +199 -0
  95. package/lib/collapsible/style/index.d.ts +1 -0
  96. package/lib/collapsible/style/index.js +3 -0
  97. package/lib/collapsible/style/index.less +24 -0
  98. package/lib/collapsibleActionItems/index.d.ts +24 -0
  99. package/lib/collapsibleActionItems/index.js +68 -0
  100. package/lib/collapsibleActionItems/style/index.d.ts +2 -0
  101. package/lib/collapsibleActionItems/style/index.js +4 -0
  102. package/lib/collapsibleActionItems/style/index.less +7 -0
  103. package/lib/flex/index.d.ts +7 -0
  104. package/lib/flex/index.js +60 -0
  105. package/lib/flex/interface.d.ts +16 -0
  106. package/lib/flex/interface.js +5 -0
  107. package/lib/flex/style/index.d.ts +2 -0
  108. package/lib/flex/style/index.js +4 -0
  109. package/lib/flex/style/index.less +77 -0
  110. package/lib/flex/utils.d.ts +7 -0
  111. package/lib/flex/utils.js +40 -0
  112. package/lib/index.d.ts +10 -1
  113. package/lib/index.js +73 -1
  114. package/lib/overflowList/index.d.ts +39 -0
  115. package/lib/overflowList/index.js +143 -0
  116. package/lib/overflowList/style/index.d.ts +2 -0
  117. package/lib/overflowList/style/index.js +4 -0
  118. package/lib/overflowList/style/index.less +9 -0
  119. package/lib/resize/index.d.ts +8 -0
  120. package/lib/resize/index.js +38 -0
  121. package/lib/resizeObserver/index.d.ts +45 -0
  122. package/lib/resizeObserver/index.js +136 -0
  123. package/lib/splitter/Panel.d.ts +7 -0
  124. package/lib/splitter/Panel.js +44 -0
  125. package/lib/splitter/SplitBar.d.ts +24 -0
  126. package/lib/splitter/SplitBar.js +179 -0
  127. package/lib/splitter/Splitter.d.ts +5 -0
  128. package/lib/splitter/Splitter.js +186 -0
  129. package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
  130. package/lib/splitter/hooks/sizeUtil.js +56 -0
  131. package/lib/splitter/hooks/useItems.d.ts +14 -0
  132. package/lib/splitter/hooks/useItems.js +46 -0
  133. package/lib/splitter/hooks/useResizable.d.ts +10 -0
  134. package/lib/splitter/hooks/useResizable.js +83 -0
  135. package/lib/splitter/hooks/useResize.d.ts +6 -0
  136. package/lib/splitter/hooks/useResize.js +142 -0
  137. package/lib/splitter/hooks/useSizes.d.ts +4 -0
  138. package/lib/splitter/hooks/useSizes.js +62 -0
  139. package/lib/splitter/index.d.ts +8 -0
  140. package/lib/splitter/index.js +12 -0
  141. package/lib/splitter/interface.d.ts +68 -0
  142. package/lib/splitter/interface.js +5 -0
  143. package/lib/splitter/style/index.d.ts +2 -0
  144. package/lib/splitter/style/index.js +4 -0
  145. package/lib/splitter/style/index.less +312 -0
  146. package/lib/statusTag/index.d.ts +28 -0
  147. package/lib/statusTag/index.js +125 -0
  148. package/lib/statusTag/style/index.d.ts +2 -0
  149. package/lib/statusTag/style/index.js +4 -0
  150. package/lib/statusTag/style/index.less +70 -0
  151. package/lib/statusTag/style/mixin.less +39 -0
  152. package/lib/style/mixins/index.less +0 -0
  153. package/lib/style/themes/index.less +2 -1
  154. package/lib/style/themes/variable.less +1 -0
  155. package/package.json +11 -19
@@ -0,0 +1,3 @@
1
+ import { SizeType } from 'antd/es/config-provider/SizeContext';
2
+ export declare function isPresetSize(size?: SizeType | string | number): size is SizeType;
3
+ export declare function isValidGapNumber(size?: SizeType | string | number): size is number;
@@ -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,2 @@
1
+ export declare type Orientation = 'horizontal' | 'vertical';
2
+ export declare const useOrientation: (orientation?: Orientation, vertical?: boolean, legacyDirection?: Orientation) => [Orientation, boolean];
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ declare const isNonNullable: <T>(val: T) => val is NonNullable<T>;
2
+ export default isNonNullable;
@@ -0,0 +1,4 @@
1
+ var isNonNullable = function isNonNullable(val) {
2
+ return val !== undefined && val !== null;
3
+ };
4
+ export default isNonNullable;
@@ -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 | (string & {});
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
  /**
@@ -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; }
@@ -11,15 +12,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
12
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
14
  import React, { useState } from 'react';
14
- import { QuestionOutlined, UpOutlined } from '@dtinsight/react-icons';
15
+ import { QuestionCircleOutlined, UpOutlined } from '@ant-design/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, tooltipProps, /*#__PURE__*/React.createElement(QuestionOutlined, null))) : null, description ? /*#__PURE__*/React.createElement("div", {
94
+ }, /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltipProps, {
95
+ className: classNames(tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className)
96
+ }), /*#__PURE__*/React.createElement(QuestionCircleOutlined, 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, {
104
+ }, currentExpand ? '收起' : '展开'), /*#__PURE__*/React.createElement(UpOutlined, {
106
105
  className: classNames('collapse__icon', {
107
106
  'collapse__icon--up': currentExpand,
108
107
  'collapse__icon--down': !currentExpand
109
108
  })
110
- }))), children && /*#__PURE__*/React.createElement("div", {
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/index.less';
1
+ import '../../style';
2
2
  import './index.less';
@@ -1,2 +1,2 @@
1
- import "../../style/index.less";
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: 16px;
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
- opacity: 0;
133
- height: 0;
134
- overflow: hidden;
135
- transition: opacity 0.5s ease, height 0.5s ease;
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
- padding: 16px 24px;
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
- // 因为 dtstack-icon 组件的 font-size 是 16px,现在需要继承 Button 组件的 font-size
22
+
18
23
  .dtstack-icon {
19
24
  font-size: inherit;
20
25
  }
21
26
 
27
+ // 小尺寸图标
22
28
  &--small {
23
- font-size: 12px;
29
+ .btn-size-small();
30
+ font-size: @icon-font-size;
24
31
  }
25
-
32
+ // 中尺寸图标
26
33
  &--middle {
27
- font-size: 16px;
34
+ .btn-size-middle();
35
+ font-size: @icon-font-size;
28
36
  }
29
-
37
+ // 大尺寸图标
30
38
  &--large {
31
- font-size: 18px;
39
+ .btn-size-large();
40
+ font-size: @icon-font-size;
32
41
  }
33
42
 
34
- & + .@{prefix-cls}__text {
43
+ // 图标与文字间距
44
+ & + .@{btn-prefix-cls}__text {
35
45
  &--small {
36
- margin-left: 2px;
46
+ .btn-size-small();
47
+ margin-left: @icon-text-margin;
37
48
  }
38
-
39
49
  &--middle {
40
- margin-left: 8px;
50
+ .btn-size-middle();
51
+ margin-left: @icon-text-margin;
41
52
  }
42
-
43
53
  &--large {
44
- margin-left: 8px;
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
- font-size: 12px;
65
+ .btn-size-small();
66
+ font-size: @text-font-size;
54
67
  }
55
-
56
68
  &--middle {
57
- font-size: 14px;
69
+ .btn-size-middle();
70
+ font-size: @text-font-size;
58
71
  }
59
-
60
72
  &--large {
61
- font-size: 14px;
73
+ .btn-size-large();
74
+ font-size: @text-font-size;
62
75
  }
63
76
  }
64
77
 
78
+ // 尺寸变体
65
79
  &-sm {
66
- padding: 2px 12px;
80
+ .btn-size-small();
81
+ padding: @padding;
67
82
  }
68
-
69
83
  &-lg {
70
- padding: 3px 40px;
84
+ .btn-size-large();
85
+ padding: @padding;
71
86
  }
72
87
 
73
- &-primary[disabled],
74
- &-primary[disabled]:hover {
75
- // color: @primary-color-disabled;
76
- background: @disabled-color;
77
- border-color: @disabled-color;
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: @item-hover-bg;
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
- // background-color: @table-title-fill-bg;
115
+ background-color: #f3f3f3;
92
116
  border-color: @border-color-base;
93
117
 
94
118
  &:hover,
95
119
  &:focus {
96
- background-color: @item-hover-bg;
120
+ background-color: fade(@primary-color, 10%);
97
121
  border-color: @primary-color;
98
122
  color: @primary-color;
99
123
  }
100
- }
101
124
 
102
- &-secondary,
103
- &-tertiary {
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
- &[disabled],
114
- &[disabled]:hover {
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;