@dtjoy/dt-design 1.0.6 → 1.0.7

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 (188) hide show
  1. package/esm/_util/easings.js +9 -0
  2. package/esm/_util/extendsObject.js +17 -0
  3. package/esm/_util/getScroll.js +32 -0
  4. package/esm/_util/hooks/index.js +4 -1
  5. package/esm/_util/hooks/useForceUpdate.js +6 -0
  6. package/esm/_util/hooks/useProxyImperativeHandle.js +31 -0
  7. package/esm/_util/hooks/useSyncState.js +20 -0
  8. package/esm/_util/scrollTo.js +38 -0
  9. package/esm/_util/warning.js +5 -5
  10. package/esm/blockHeader/index.js +13 -15
  11. package/esm/blockHeader/style/index.less +143 -143
  12. package/esm/button/index.js +2 -2
  13. package/esm/collapsible/index.js +53 -55
  14. package/esm/collapsibleActionItems/index.js +2 -2
  15. package/esm/flex/index.js +1 -1
  16. package/esm/flex/style/index.less +76 -76
  17. package/esm/flex/utils.js +1 -1
  18. package/esm/formList/index.js +13 -11
  19. package/esm/formList/style/index.less +45 -45
  20. package/esm/index.js +3 -1
  21. package/esm/overflowList/index.js +4 -3
  22. package/esm/resize/index.js +1 -1
  23. package/esm/resizeObserver/index.js +3 -2
  24. package/esm/splitter/Panel.js +3 -3
  25. package/esm/splitter/SplitBar.js +8 -7
  26. package/esm/splitter/Splitter.js +5 -4
  27. package/esm/splitter/hooks/useItems.js +2 -2
  28. package/esm/splitter/hooks/useResize.js +5 -5
  29. package/esm/statusTag/index.js +8 -8
  30. package/esm/style/index.less +1 -1
  31. package/esm/style/themes/index.less +2 -2
  32. package/esm/style/themes/variable.less +4 -0
  33. package/esm/table/InternalTable.js +429 -0
  34. package/esm/table/RcTable/VirtualTable.js +9 -0
  35. package/esm/table/RcTable/index.js +9 -0
  36. package/esm/table/Table.js +28 -0
  37. package/esm/table/TableMeasureRowContext.js +3 -0
  38. package/esm/table/hooks/useContainerWidth.js +14 -0
  39. package/esm/table/index.js +2 -0
  40. package/esm/table/interface.js +4 -0
  41. package/esm/table/style/bordered.less +141 -0
  42. package/esm/table/style/fixed.less +88 -0
  43. package/esm/table/style/index.js +2 -0
  44. package/esm/table/style/index.less +150 -0
  45. package/esm/table/style/selection.less +90 -0
  46. package/esm/table/style/sticky.less +55 -0
  47. package/esm/table/style/virtual.less +65 -0
  48. package/esm/table/util.js +33 -0
  49. package/lib/_util/easings.js +15 -0
  50. package/lib/_util/extendsObject.js +20 -0
  51. package/lib/_util/getScroll.js +39 -0
  52. package/lib/_util/hooks/index.js +33 -0
  53. package/lib/_util/hooks/useForceUpdate.js +12 -0
  54. package/lib/_util/hooks/useProxyImperativeHandle.js +40 -0
  55. package/lib/_util/hooks/useSyncState.js +19 -0
  56. package/lib/_util/scrollTo.js +44 -0
  57. package/lib/_util/warning.js +7 -8
  58. package/lib/blockHeader/index.js +13 -12
  59. package/lib/blockHeader/style/index.less +143 -143
  60. package/lib/button/index.js +2 -2
  61. package/lib/collapsible/index.js +49 -49
  62. package/lib/collapsibleActionItems/index.js +2 -2
  63. package/lib/flex/index.js +2 -2
  64. package/lib/flex/style/index.less +76 -76
  65. package/lib/flex/utils.js +2 -2
  66. package/lib/formList/index.js +10 -10
  67. package/lib/formList/style/index.less +45 -45
  68. package/lib/index.js +21 -2
  69. package/lib/overflowList/index.js +4 -3
  70. package/lib/resize/index.js +1 -1
  71. package/lib/resizeObserver/index.js +3 -2
  72. package/lib/splitter/Panel.js +3 -3
  73. package/lib/splitter/SplitBar.js +8 -7
  74. package/lib/splitter/Splitter.js +5 -4
  75. package/lib/splitter/hooks/useItems.js +2 -2
  76. package/lib/splitter/hooks/useResize.js +5 -5
  77. package/lib/statusTag/index.js +8 -8
  78. package/lib/style/index.less +1 -1
  79. package/lib/style/themes/index.less +2 -2
  80. package/lib/style/themes/variable.less +4 -0
  81. package/lib/table/InternalTable.js +395 -0
  82. package/lib/table/RcTable/VirtualTable.js +17 -0
  83. package/lib/table/RcTable/index.js +17 -0
  84. package/lib/table/Table.js +37 -0
  85. package/lib/{_util/zindexContext.js → table/TableMeasureRowContext.js} +2 -5
  86. package/lib/table/hooks/useContainerWidth.js +20 -0
  87. package/lib/table/index.js +9 -0
  88. package/lib/table/interface.js +8 -0
  89. package/lib/table/style/bordered.less +141 -0
  90. package/lib/table/style/fixed.less +88 -0
  91. package/lib/table/style/index.js +4 -0
  92. package/lib/table/style/index.less +150 -0
  93. package/lib/table/style/selection.less +90 -0
  94. package/lib/table/style/sticky.less +55 -0
  95. package/lib/table/style/virtual.less +65 -0
  96. package/lib/table/util.js +44 -0
  97. package/package.json +82 -66
  98. package/esm/_util/convertToTooltipProps.d.ts +0 -4
  99. package/esm/_util/convertToTooltipProps.js +0 -15
  100. package/esm/_util/gapSize.d.ts +0 -3
  101. package/esm/_util/hooks/index.d.ts +0 -1
  102. package/esm/_util/hooks/useOrientation.d.ts +0 -2
  103. package/esm/_util/hooks/useZIndex.d.ts +0 -8
  104. package/esm/_util/hooks/useZIndex.js +0 -51
  105. package/esm/_util/index.d.ts +0 -3
  106. package/esm/_util/isNonNullable.d.ts +0 -2
  107. package/esm/_util/type.d.ts +0 -52
  108. package/esm/_util/warning.d.ts +0 -31
  109. package/esm/_util/zindexContext.d.ts +0 -3
  110. package/esm/_util/zindexContext.js +0 -6
  111. package/esm/blockHeader/index.d.ts +0 -48
  112. package/esm/blockHeader/style/index.d.ts +0 -2
  113. package/esm/button/index.d.ts +0 -10
  114. package/esm/button/style/index.d.ts +0 -2
  115. package/esm/collapsible/index.d.ts +0 -97
  116. package/esm/collapsible/style/index.d.ts +0 -1
  117. package/esm/collapsibleActionItems/index.d.ts +0 -24
  118. package/esm/collapsibleActionItems/style/index.d.ts +0 -2
  119. package/esm/flex/index.d.ts +0 -7
  120. package/esm/flex/interface.d.ts +0 -16
  121. package/esm/flex/style/index.d.ts +0 -2
  122. package/esm/flex/utils.d.ts +0 -7
  123. package/esm/formList/index.d.ts +0 -77
  124. package/esm/formList/style/index.d.ts +0 -2
  125. package/esm/index.d.ts +0 -14
  126. package/esm/overflowList/index.d.ts +0 -39
  127. package/esm/overflowList/style/index.d.ts +0 -2
  128. package/esm/resize/index.d.ts +0 -8
  129. package/esm/resizeObserver/index.d.ts +0 -45
  130. package/esm/splitter/Panel.d.ts +0 -7
  131. package/esm/splitter/SplitBar.d.ts +0 -24
  132. package/esm/splitter/Splitter.d.ts +0 -5
  133. package/esm/splitter/hooks/sizeUtil.d.ts +0 -3
  134. package/esm/splitter/hooks/useItems.d.ts +0 -14
  135. package/esm/splitter/hooks/useResizable.d.ts +0 -10
  136. package/esm/splitter/hooks/useResize.d.ts +0 -6
  137. package/esm/splitter/hooks/useSizes.d.ts +0 -4
  138. package/esm/splitter/index.d.ts +0 -8
  139. package/esm/splitter/interface.d.ts +0 -69
  140. package/esm/splitter/style/index.d.ts +0 -2
  141. package/esm/statusTag/index.d.ts +0 -28
  142. package/esm/statusTag/style/index.d.ts +0 -2
  143. package/esm/style/index.d.ts +0 -1
  144. package/lib/_util/convertToTooltipProps.d.ts +0 -4
  145. package/lib/_util/convertToTooltipProps.js +0 -21
  146. package/lib/_util/gapSize.d.ts +0 -3
  147. package/lib/_util/hooks/index.d.ts +0 -1
  148. package/lib/_util/hooks/useOrientation.d.ts +0 -2
  149. package/lib/_util/hooks/useZIndex.d.ts +0 -8
  150. package/lib/_util/hooks/useZIndex.js +0 -59
  151. package/lib/_util/index.d.ts +0 -3
  152. package/lib/_util/isNonNullable.d.ts +0 -2
  153. package/lib/_util/type.d.ts +0 -52
  154. package/lib/_util/warning.d.ts +0 -31
  155. package/lib/_util/zindexContext.d.ts +0 -3
  156. package/lib/blockHeader/index.d.ts +0 -48
  157. package/lib/blockHeader/style/index.d.ts +0 -2
  158. package/lib/button/index.d.ts +0 -10
  159. package/lib/button/style/index.d.ts +0 -2
  160. package/lib/collapsible/index.d.ts +0 -97
  161. package/lib/collapsible/style/index.d.ts +0 -1
  162. package/lib/collapsibleActionItems/index.d.ts +0 -24
  163. package/lib/collapsibleActionItems/style/index.d.ts +0 -2
  164. package/lib/flex/index.d.ts +0 -7
  165. package/lib/flex/interface.d.ts +0 -16
  166. package/lib/flex/style/index.d.ts +0 -2
  167. package/lib/flex/utils.d.ts +0 -7
  168. package/lib/formList/index.d.ts +0 -77
  169. package/lib/formList/style/index.d.ts +0 -2
  170. package/lib/index.d.ts +0 -14
  171. package/lib/overflowList/index.d.ts +0 -39
  172. package/lib/overflowList/style/index.d.ts +0 -2
  173. package/lib/resize/index.d.ts +0 -8
  174. package/lib/resizeObserver/index.d.ts +0 -45
  175. package/lib/splitter/Panel.d.ts +0 -7
  176. package/lib/splitter/SplitBar.d.ts +0 -24
  177. package/lib/splitter/Splitter.d.ts +0 -5
  178. package/lib/splitter/hooks/sizeUtil.d.ts +0 -3
  179. package/lib/splitter/hooks/useItems.d.ts +0 -14
  180. package/lib/splitter/hooks/useResizable.d.ts +0 -10
  181. package/lib/splitter/hooks/useResize.d.ts +0 -6
  182. package/lib/splitter/hooks/useSizes.d.ts +0 -4
  183. package/lib/splitter/index.d.ts +0 -8
  184. package/lib/splitter/interface.d.ts +0 -69
  185. package/lib/splitter/style/index.d.ts +0 -2
  186. package/lib/statusTag/index.d.ts +0 -28
  187. package/lib/statusTag/style/index.d.ts +0 -2
  188. package/lib/style/index.d.ts +0 -1
@@ -0,0 +1,9 @@
1
+ export function easeInOutCubic(t, b, c, d) {
2
+ var cc = c - b;
3
+ t /= d / 2;
4
+ if (t < 1) {
5
+ return cc / 2 * t * t * t + b;
6
+ }
7
+ // biome-ignore lint: it is a common easing function
8
+ return cc / 2 * ((t -= 2) * t * t + 2) + b;
9
+ }
@@ -0,0 +1,17 @@
1
+ function mergeProps() {
2
+ var ret = {};
3
+ for (var _len = arguments.length, items = new Array(_len), _key = 0; _key < _len; _key++) {
4
+ items[_key] = arguments[_key];
5
+ }
6
+ items.forEach(function (item) {
7
+ if (item) {
8
+ Object.keys(item).forEach(function (key) {
9
+ if (item[key] !== undefined) {
10
+ ret[key] = item[key];
11
+ }
12
+ });
13
+ }
14
+ });
15
+ return ret;
16
+ }
17
+ export default mergeProps;
@@ -0,0 +1,32 @@
1
+ import isNonNullable from "./isNonNullable";
2
+ export function isWindow(obj) {
3
+ return isNonNullable(obj) && obj === obj.window;
4
+ }
5
+ var getScroll = function getScroll(target) {
6
+ if (typeof window === 'undefined') {
7
+ /* istanbul ignore next */
8
+ return 0;
9
+ }
10
+ var result = 0;
11
+ if (isWindow(target)) {
12
+ result = target.pageYOffset;
13
+ } else if (target instanceof Document) {
14
+ result = target.documentElement.scrollTop;
15
+ } else if (target instanceof HTMLElement) {
16
+ result = target.scrollTop;
17
+ } else if (target) {
18
+ // According to the type inference, the `target` is `never` type.
19
+ // Since we configured the loose mode type checking, and supports mocking the target with such shape below::
20
+ // `{ documentElement: { scrollLeft: 200, scrollTop: 400 } }`,
21
+ // the program may falls into this branch.
22
+ // Check the corresponding tests for details. Don't sure what is the real scenario this happens.
23
+ /* biome-ignore lint/complexity/useLiteralKeys: target is a never type */ /* eslint-disable-next-line dot-notation */
24
+ result = target['scrollTop'];
25
+ }
26
+ if (target && !isWindow(target) && typeof result !== 'number') {
27
+ var _documentElement, _target$ownerDocument;
28
+ result = (_documentElement = ((_target$ownerDocument = target.ownerDocument) !== null && _target$ownerDocument !== void 0 ? _target$ownerDocument : target).documentElement) === null || _documentElement === void 0 ? void 0 : _documentElement.scrollTop;
29
+ }
30
+ return result;
31
+ };
32
+ export default getScroll;
@@ -1 +1,4 @@
1
- export * from "./useOrientation";
1
+ export * from "./useForceUpdate";
2
+ export * from "./useOrientation";
3
+ export * from "./useProxyImperativeHandle";
4
+ export * from "./useSyncState";
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export var useForceUpdate = function useForceUpdate() {
3
+ return React.useReducer(function (ori) {
4
+ return ori + 1;
5
+ }, 0);
6
+ };
@@ -0,0 +1,31 @@
1
+ import { useImperativeHandle } from 'react';
2
+ var fillProxy = function fillProxy(element, handler) {
3
+ element._dtProxy = element._dtProxy || {};
4
+ Object.keys(handler).forEach(function (key) {
5
+ if (!(key in element._dtProxy)) {
6
+ var ori = element[key];
7
+ element._dtProxy[key] = ori;
8
+ element[key] = handler[key];
9
+ }
10
+ });
11
+ return element;
12
+ };
13
+ export var useProxyImperativeHandle = function useProxyImperativeHandle(ref, init) {
14
+ return useImperativeHandle(ref, function () {
15
+ var refObj = init();
16
+ var nativeElement = refObj.nativeElement;
17
+ if (typeof Proxy !== 'undefined') {
18
+ return new Proxy(nativeElement, {
19
+ get: function get(obj, prop) {
20
+ if (refObj[prop]) {
21
+ return refObj[prop];
22
+ }
23
+ return Reflect.get(obj, prop);
24
+ }
25
+ });
26
+ }
27
+
28
+ // Fallback of IE
29
+ return fillProxy(nativeElement, refObj);
30
+ });
31
+ };
@@ -0,0 +1,20 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import * as React from 'react';
8
+ import { useForceUpdate } from "./useForceUpdate";
9
+ export var useSyncState = function useSyncState(initialValue) {
10
+ var ref = React.useRef(initialValue);
11
+ var _useForceUpdate = useForceUpdate(),
12
+ _useForceUpdate2 = _slicedToArray(_useForceUpdate, 2),
13
+ forceUpdate = _useForceUpdate2[1];
14
+ return [function () {
15
+ return ref.current;
16
+ }, function (newValue) {
17
+ ref.current = newValue;
18
+ forceUpdate();
19
+ }];
20
+ };
@@ -0,0 +1,38 @@
1
+ import raf from '@rc-component/util/lib/raf';
2
+ import { easeInOutCubic } from "./easings";
3
+ import getScroll, { isWindow } from "./getScroll";
4
+ export default function scrollTo(y) {
5
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6
+ var _options$getContainer = options.getContainer,
7
+ getContainer = _options$getContainer === void 0 ? function () {
8
+ return window;
9
+ } : _options$getContainer,
10
+ callback = options.callback,
11
+ _options$duration = options.duration,
12
+ duration = _options$duration === void 0 ? 450 : _options$duration;
13
+ var container = getContainer();
14
+ var scrollTop = getScroll(container);
15
+ var startTime = Date.now();
16
+ var rafId;
17
+ var frameFunc = function frameFunc() {
18
+ var timestamp = Date.now();
19
+ var time = timestamp - startTime;
20
+ var nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
21
+ if (isWindow(container)) {
22
+ container.scrollTo(window.pageXOffset, nextScrollTop);
23
+ } else if (container instanceof Document || container.constructor.name === 'HTMLDocument') {
24
+ container.documentElement.scrollTop = nextScrollTop;
25
+ } else {
26
+ container.scrollTop = nextScrollTop;
27
+ }
28
+ if (time < duration) {
29
+ rafId = raf(frameFunc);
30
+ } else if (typeof callback === 'function') {
31
+ callback();
32
+ }
33
+ };
34
+ rafId = raf(frameFunc);
35
+ return function () {
36
+ raf.cancel(rafId);
37
+ };
38
+ }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import rcWarning from 'rc-util/lib/warning';
2
+ import { warning as rcWarning } from '@rc-component/util';
3
3
  export function noop() {}
4
4
  var rcResetWarned = rcWarning.resetWarned;
5
5
  var deprecatedWarnList = null;
@@ -21,10 +21,10 @@ if (process.env.NODE_ENV !== 'production') {
21
21
  var warning = _warning;
22
22
  export var WarningContext = /*#__PURE__*/React.createContext({});
23
23
 
24
- /**
25
- * This is a hook but we not named as `useWarning`
26
- * since this is only used in development.
27
- * We should always wrap this in `if (process.env.NODE_ENV !== 'production')` condition
24
+ /**
25
+ * This is a hook but we not named as `useWarning`
26
+ * since this is only used in development.
27
+ * We should always wrap this in `if (process.env.NODE_ENV !== 'production')` condition
28
28
  */
29
29
  export var devUseWarning = process.env.NODE_ENV !== 'production' ? function (component) {
30
30
  var _React$useContext = React.useContext(WarningContext),
@@ -1,5 +1,4 @@
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
- var _excluded = ["title", "description", "tooltip", "size", "spaceBottom", "className", "contentClassName", "style", "contentStyle", "background", "defaultExpand", "addonAfter", "expand", "children", "addonBefore", "onExpand", "titleStyle"];
3
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); }
4
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; }
5
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; }
@@ -12,13 +11,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
12
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
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; } }
14
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
- 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; }
16
- 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; }
17
14
  import React, { useState } from 'react';
18
15
  import { QuestionCircleOutlined, UpOutlined } from '@ant-design/icons';
19
16
  import { Tooltip } from 'antd';
20
17
  import { globalConfig } from 'antd/es/config-provider';
21
- import classNames from 'classnames';
18
+ import clsx from 'clsx';
22
19
  import "./style";
23
20
  import { toTooltipProps } from "../_util";
24
21
  import Collapsible from "../collapsible";
@@ -28,7 +25,8 @@ function isControlled(props) {
28
25
  var prefixCls = globalConfig().getPrefixCls('block-header');
29
26
  var preTitleRowCls = "".concat(prefixCls, "__title");
30
27
  var BlockHeader = function BlockHeader(props) {
31
- var title = props.title,
28
+ var id = props.id,
29
+ title = props.title,
32
30
  _props$description = props.description,
33
31
  description = _props$description === void 0 ? '' : _props$description,
34
32
  tooltip = props.tooltip,
@@ -56,8 +54,7 @@ var BlockHeader = function BlockHeader(props) {
56
54
  className: "addon-before--default"
57
55
  }) : _props$addonBefore,
58
56
  onExpand = props.onExpand,
59
- titleStyle = props.titleStyle,
60
- rest = _objectWithoutProperties(props, _excluded);
57
+ titleStyle = props.titleStyle;
61
58
  var _useState = useState(defaultExpand),
62
59
  _useState2 = _slicedToArray(_useState, 2),
63
60
  internalExpand = _useState2[0],
@@ -67,7 +64,7 @@ var BlockHeader = function BlockHeader(props) {
67
64
  // 只有在有了 children 并且设置了 expand/defaultExpand 的时候才能够展开收起
68
65
  var showCollapse = (typeof expand === 'boolean' || typeof defaultExpand === 'boolean') && children;
69
66
  var tooltipProps = toTooltipProps(tooltip);
70
- var bottomStyle;
67
+ var bottomStyle = {};
71
68
  if (spaceBottom) bottomStyle = showCollapse && !currentExpand ? {
72
69
  marginBottom: 0
73
70
  } : {
@@ -79,10 +76,11 @@ var BlockHeader = function BlockHeader(props) {
79
76
  onExpand === null || onExpand === void 0 || onExpand(expand);
80
77
  };
81
78
  return /*#__PURE__*/React.createElement("div", {
82
- className: classNames("".concat(prefixCls), className),
79
+ id: id,
80
+ className: clsx("".concat(prefixCls), className),
83
81
  style: _objectSpread(_objectSpread({}, bottomStyle), style)
84
82
  }, /*#__PURE__*/React.createElement("div", {
85
- className: classNames(preTitleRowCls, "".concat(preTitleRowCls, "--").concat(size), _defineProperty(_defineProperty({}, "".concat(preTitleRowCls, "--background"), background), "".concat(preTitleRowCls, "--pointer"), showCollapse)),
83
+ className: clsx(preTitleRowCls, "".concat(preTitleRowCls, "--").concat(size), _defineProperty(_defineProperty({}, "".concat(preTitleRowCls, "--background"), background), "".concat(preTitleRowCls, "--pointer"), showCollapse)),
86
84
  style: titleStyle,
87
85
  onClick: function onClick() {
88
86
  return showCollapse && handleExpand(!currentExpand);
@@ -96,7 +94,7 @@ var BlockHeader = function BlockHeader(props) {
96
94
  }, title), tooltipProps !== null && tooltipProps !== void 0 && tooltipProps.title ? /*#__PURE__*/React.createElement("div", {
97
95
  className: "title__tooltip"
98
96
  }, /*#__PURE__*/React.createElement(Tooltip, _extends({}, tooltipProps, {
99
- className: classNames(tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className)
97
+ className: clsx(tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className)
100
98
  }), /*#__PURE__*/React.createElement(QuestionCircleOutlined, null))) : null, description ? /*#__PURE__*/React.createElement("div", {
101
99
  className: "title__description"
102
100
  }, description) : null), addonAfter && /*#__PURE__*/React.createElement("div", {
@@ -106,14 +104,14 @@ var BlockHeader = function BlockHeader(props) {
106
104
  }, /*#__PURE__*/React.createElement("div", {
107
105
  className: "collapse__text"
108
106
  }, currentExpand ? '收起' : '展开'), /*#__PURE__*/React.createElement(UpOutlined, {
109
- className: classNames('collapse__icon', {
107
+ className: clsx('collapse__icon', {
110
108
  'collapse__icon--up': currentExpand,
111
109
  'collapse__icon--down': !currentExpand
112
110
  })
113
- }))), /*#__PURE__*/React.createElement(Collapsible, _extends({
111
+ }))), /*#__PURE__*/React.createElement(Collapsible, {
114
112
  isOpen: !currentExpand
115
- }, rest), /*#__PURE__*/React.createElement("div", {
116
- className: classNames("".concat(prefixCls, "__content"), contentClassName, _defineProperty({}, "".concat(prefixCls, "__content--active"), currentExpand || !showCollapse)),
113
+ }, /*#__PURE__*/React.createElement("div", {
114
+ className: clsx("".concat(prefixCls, "__content"), contentClassName, _defineProperty({}, "".concat(prefixCls, "__content--active"), currentExpand || !showCollapse)),
117
115
  style: contentStyle
118
116
  }, children)));
119
117
  };
@@ -1,143 +1,143 @@
1
- @import '../../style/themes/index.less';
2
-
3
- @card_prefix: ~'@{ant-prefix}-block-header';
4
-
5
- .@{card_prefix} {
6
- &__title {
7
- border-radius: 4px;
8
- display: flex;
9
- align-items: center;
10
- justify-content: space-between;
11
- &--large {
12
- .title__box {
13
- line-height: 24px;
14
- .title__text {
15
- font-size: 16px;
16
- }
17
- }
18
- }
19
- &--middle {
20
- .title__box {
21
- line-height: 22px;
22
- .title__text {
23
- font-size: 14px;
24
- }
25
- }
26
- }
27
- &--small {
28
- .title__box {
29
- line-height: 20px;
30
- .title__text {
31
- font-size: 12px;
32
- }
33
- }
34
- }
35
- &--background {
36
- padding: 0 12px;
37
- background-color: #f9f9fa;
38
- &.@{card_prefix}__title {
39
- &--middle,
40
- &--large {
41
- height: 40px;
42
- }
43
- &--small {
44
- height: 32px;
45
- }
46
- }
47
- }
48
- &--pointer {
49
- cursor: pointer;
50
- }
51
- .title {
52
- &__box {
53
- flex: 1;
54
- display: flex;
55
- align-items: center;
56
- }
57
- &__addon-before {
58
- margin-right: 8px;
59
- color: @primary-color;
60
- &--middle {
61
- .addon-before--default {
62
- width: 4px;
63
- height: 16px;
64
- background-color: @primary-color;
65
- }
66
- font-size: 20px;
67
- }
68
- &--small {
69
- .addon-before--default {
70
- width: 4px;
71
- height: 16px;
72
- background-color: @primary-color;
73
- }
74
- font-size: 16px;
75
- }
76
- &--large {
77
- .addon-before--default {
78
- width: 4px;
79
- height: 20px;
80
- background-color: @primary-color;
81
- }
82
- font-size: 24px;
83
- }
84
- }
85
- &__tooltip {
86
- display: flex;
87
- margin-right: 4px;
88
- font-size: 14px;
89
- color: #b1b4c5;
90
- cursor: pointer;
91
- }
92
- &__text {
93
- color: @text-color;
94
- font-weight: 500;
95
- margin-right: 4px;
96
- }
97
- &__description {
98
- display: flex;
99
- align-items: center;
100
- color: @label-color;
101
- font-size: 12px;
102
- }
103
- &__addon-after {
104
- color: @label-color;
105
- }
106
- &__collapse {
107
- color: @label-color;
108
- display: flex;
109
- align-items: center;
110
- cursor: pointer;
111
- user-select: none;
112
- .collapse {
113
- &__text {
114
- font-size: 12px;
115
- margin: 0 4px;
116
- }
117
- &__icon {
118
- font-size: 16px;
119
- transition: transform 0.4s;
120
- &--down {
121
- transform: rotate(-180deg);
122
- }
123
- &--up {
124
- transform: rotate(0deg);
125
- }
126
- }
127
- }
128
- }
129
- }
130
- }
131
- &__content {
132
- padding: 16px 24px;
133
-
134
- // opacity: 0;
135
- // height: 0;
136
- // overflow: hidden;
137
- // transition: opacity 0.5s ease, height 0.5s ease;
138
- &--active {
139
- // opacity: 1;
140
- // height: auto;
141
- }
142
- }
143
- }
1
+ @import '../../style/themes/index.less';
2
+
3
+ @card_prefix: ~'@{ant-prefix}-block-header';
4
+
5
+ .@{card_prefix} {
6
+ &__title {
7
+ border-radius: 4px;
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: space-between;
11
+ &--large {
12
+ .title__box {
13
+ line-height: 24px;
14
+ .title__text {
15
+ font-size: 16px;
16
+ }
17
+ }
18
+ }
19
+ &--middle {
20
+ .title__box {
21
+ line-height: 22px;
22
+ .title__text {
23
+ font-size: 14px;
24
+ }
25
+ }
26
+ }
27
+ &--small {
28
+ .title__box {
29
+ line-height: 20px;
30
+ .title__text {
31
+ font-size: 12px;
32
+ }
33
+ }
34
+ }
35
+ &--background {
36
+ padding: 0 12px;
37
+ background-color: #f9f9fa;
38
+ &.@{card_prefix}__title {
39
+ &--middle,
40
+ &--large {
41
+ height: 40px;
42
+ }
43
+ &--small {
44
+ height: 32px;
45
+ }
46
+ }
47
+ }
48
+ &--pointer {
49
+ cursor: pointer;
50
+ }
51
+ .title {
52
+ &__box {
53
+ flex: 1;
54
+ display: flex;
55
+ align-items: center;
56
+ }
57
+ &__addon-before {
58
+ margin-right: 8px;
59
+ color: @primary-color;
60
+ &--middle {
61
+ .addon-before--default {
62
+ width: 4px;
63
+ height: 16px;
64
+ background-color: @primary-color;
65
+ }
66
+ font-size: 20px;
67
+ }
68
+ &--small {
69
+ .addon-before--default {
70
+ width: 4px;
71
+ height: 16px;
72
+ background-color: @primary-color;
73
+ }
74
+ font-size: 16px;
75
+ }
76
+ &--large {
77
+ .addon-before--default {
78
+ width: 4px;
79
+ height: 20px;
80
+ background-color: @primary-color;
81
+ }
82
+ font-size: 24px;
83
+ }
84
+ }
85
+ &__tooltip {
86
+ display: flex;
87
+ margin-right: 4px;
88
+ font-size: 14px;
89
+ color: #b1b4c5;
90
+ cursor: pointer;
91
+ }
92
+ &__text {
93
+ color: @text-color;
94
+ font-weight: 500;
95
+ margin-right: 4px;
96
+ }
97
+ &__description {
98
+ display: flex;
99
+ align-items: center;
100
+ color: @label-color;
101
+ font-size: 12px;
102
+ }
103
+ &__addon-after {
104
+ color: @label-color;
105
+ }
106
+ &__collapse {
107
+ color: @label-color;
108
+ display: flex;
109
+ align-items: center;
110
+ cursor: pointer;
111
+ user-select: none;
112
+ .collapse {
113
+ &__text {
114
+ font-size: 12px;
115
+ margin: 0 4px;
116
+ }
117
+ &__icon {
118
+ font-size: 16px;
119
+ transition: transform 0.4s;
120
+ &--down {
121
+ transform: rotate(-180deg);
122
+ }
123
+ &--up {
124
+ transform: rotate(0deg);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ &__content {
132
+ padding: 16px 24px;
133
+
134
+ // opacity: 0;
135
+ // height: 0;
136
+ // overflow: hidden;
137
+ // transition: opacity 0.5s ease, height 0.5s ease;
138
+ &--active {
139
+ // opacity: 1;
140
+ // height: auto;
141
+ }
142
+ }
143
+ }
@@ -4,7 +4,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
4
4
  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; }
5
5
  import React from 'react';
6
6
  import { Button as AntdButton } from 'antd';
7
- import classNames from 'classnames';
7
+ import clsx from 'clsx';
8
8
  import "./style";
9
9
  function Button(_ref) {
10
10
  var className = _ref.className,
@@ -13,7 +13,7 @@ function Button(_ref) {
13
13
  type = _ref.type,
14
14
  rest = _objectWithoutProperties(_ref, _excluded);
15
15
  return /*#__PURE__*/React.createElement(AntdButton, _extends({
16
- className: classNames(className),
16
+ className: clsx(className),
17
17
  size: size,
18
18
  type: type
19
19
  }, rest));