@lemon-fe/components 0.1.78 → 0.1.82

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 (115) hide show
  1. package/es/BaseTable/index.less +1 -1
  2. package/es/ColorPicker/index.less +47 -0
  3. package/es/MainFramework/components/Menu/index.less +0 -407
  4. package/es/Table/typings.d.ts +0 -1
  5. package/es/index.less +1 -0
  6. package/package.json +5 -2
  7. package/es/Actions/index.d.ts +0 -26
  8. package/es/Actions/index.js +0 -171
  9. package/es/BaseTable/Actions.d.ts +0 -8
  10. package/es/BaseTable/Actions.js +0 -136
  11. package/es/BaseTable/BaseTableContext.d.ts +0 -6
  12. package/es/BaseTable/BaseTableContext.js +0 -6
  13. package/es/BaseTable/ResizeHeaderCell.d.ts +0 -8
  14. package/es/BaseTable/ResizeHeaderCell.js +0 -126
  15. package/es/BaseTable/VirtualBody.d.ts +0 -8
  16. package/es/BaseTable/VirtualBody.js +0 -165
  17. package/es/BaseTable/index.d.ts +0 -7
  18. package/es/BaseTable/index.js +0 -465
  19. package/es/BaseTable/utils.d.ts +0 -4
  20. package/es/BaseTable/utils.js +0 -26
  21. package/es/Dropdown/index.d.ts +0 -14
  22. package/es/Dropdown/index.js +0 -53
  23. package/es/DurationPicker/index.d.ts +0 -25
  24. package/es/DurationPicker/index.js +0 -237
  25. package/es/EditableTable/EditableCell.d.ts +0 -11
  26. package/es/EditableTable/EditableCell.js +0 -37
  27. package/es/EditableTable/EditableTableFormItem.d.ts +0 -5
  28. package/es/EditableTable/EditableTableFormItem.js +0 -49
  29. package/es/EditableTable/Table.d.ts +0 -7
  30. package/es/EditableTable/Table.js +0 -363
  31. package/es/EditableTable/index.d.ts +0 -9
  32. package/es/EditableTable/index.js +0 -8
  33. package/es/EditableTable/util.d.ts +0 -25
  34. package/es/EditableTable/util.js +0 -387
  35. package/es/Filter/index.d.ts +0 -7
  36. package/es/Filter/index.js +0 -610
  37. package/es/FormHorizontal/index.d.ts +0 -6
  38. package/es/FormHorizontal/index.js +0 -35
  39. package/es/FormInline/index.d.ts +0 -15
  40. package/es/FormInline/index.js +0 -90
  41. package/es/FormLayout/index.d.ts +0 -32
  42. package/es/FormLayout/index.js +0 -41
  43. package/es/FormTable/index.d.ts +0 -6
  44. package/es/FormTable/index.js +0 -159
  45. package/es/Icons/BigTip/index.d.ts +0 -6
  46. package/es/Icons/BigTip/index.js +0 -50
  47. package/es/Icons/Calendar.d.ts +0 -5
  48. package/es/Icons/Calendar.js +0 -47
  49. package/es/Icons/CollapseUp.d.ts +0 -5
  50. package/es/Icons/CollapseUp.js +0 -31
  51. package/es/Icons/DarkSearch.d.ts +0 -5
  52. package/es/Icons/DarkSearch.js +0 -38
  53. package/es/Icons/Down.d.ts +0 -5
  54. package/es/Icons/Down.js +0 -35
  55. package/es/Icons/Empty.d.ts +0 -2
  56. package/es/Icons/Empty.js +0 -267
  57. package/es/Icons/LookUp.d.ts +0 -5
  58. package/es/Icons/LookUp.js +0 -74
  59. package/es/Icons/More.d.ts +0 -5
  60. package/es/Icons/More.js +0 -44
  61. package/es/Icons/Search.d.ts +0 -5
  62. package/es/Icons/Search.js +0 -35
  63. package/es/Icons/Tip.d.ts +0 -6
  64. package/es/Icons/Tip.js +0 -169
  65. package/es/Icons/index.d.ts +0 -22
  66. package/es/Icons/index.js +0 -23
  67. package/es/InputMaxLength/index.d.ts +0 -14
  68. package/es/InputMaxLength/index.js +0 -92
  69. package/es/Layout/index.d.ts +0 -41
  70. package/es/Layout/index.js +0 -175
  71. package/es/MainFramework/components/DropMenu/index.d.ts +0 -10
  72. package/es/MainFramework/components/DropMenu/index.js +0 -104
  73. package/es/MainFramework/components/Menu/index.d.ts +0 -9
  74. package/es/MainFramework/components/Menu/index.js +0 -656
  75. package/es/MainFramework/components/RefreshButton/index.d.ts +0 -5
  76. package/es/MainFramework/components/RefreshButton/index.js +0 -72
  77. package/es/MainFramework/components/RefreshButton/index.less +0 -30
  78. package/es/MainFramework/components/TabBar/index.d.ts +0 -9
  79. package/es/MainFramework/components/TabBar/index.js +0 -116
  80. package/es/MainFramework/index.d.ts +0 -24
  81. package/es/MainFramework/index.js +0 -66
  82. package/es/PageLoading/index.d.ts +0 -5
  83. package/es/PageLoading/index.js +0 -15
  84. package/es/Popup/index.d.ts +0 -37
  85. package/es/Popup/index.js +0 -198
  86. package/es/Portal/index.d.ts +0 -12
  87. package/es/Portal/index.js +0 -72
  88. package/es/Section/TabBar.d.ts +0 -12
  89. package/es/Section/TabBar.js +0 -48
  90. package/es/Section/index.d.ts +0 -54
  91. package/es/Section/index.js +0 -96
  92. package/es/SelectView/index.d.ts +0 -53
  93. package/es/SelectView/index.js +0 -257
  94. package/es/SiderTree/TreeNodeTitle.d.ts +0 -8
  95. package/es/SiderTree/TreeNodeTitle.js +0 -107
  96. package/es/SiderTree/index.d.ts +0 -37
  97. package/es/SiderTree/index.js +0 -221
  98. package/es/SymbolIcon/index.d.ts +0 -8
  99. package/es/SymbolIcon/index.js +0 -32
  100. package/es/TabBar/index.d.ts +0 -14
  101. package/es/TabBar/index.js +0 -52
  102. package/es/Table/index.d.ts +0 -2
  103. package/es/Table/index.js +0 -236
  104. package/es/Table/utils.d.ts +0 -2
  105. package/es/Table/utils.js +0 -3
  106. package/es/TipMark/index.d.ts +0 -10
  107. package/es/TipMark/index.js +0 -45
  108. package/es/constants.d.ts +0 -1
  109. package/es/constants.js +0 -1
  110. package/es/index.d.ts +0 -31
  111. package/es/index.js +0 -26
  112. package/es/init.d.ts +0 -3
  113. package/es/init.js +0 -135
  114. package/es/utils.d.ts +0 -2
  115. package/es/utils.js +0 -14
@@ -1,8 +0,0 @@
1
- import type { RowAction } from './typings';
2
- interface Props<T> {
3
- actions: (RowAction<T> | null)[] | ((record: T, index: number) => (RowAction<T> | null)[]);
4
- row: T;
5
- index: number;
6
- }
7
- export default function Actions<T>(props: Props<T>): JSX.Element;
8
- export {};
@@ -1,136 +0,0 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
-
5
- 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."); }
6
-
7
- 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); }
8
-
9
- 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; }
10
-
11
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
-
13
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
-
15
- import React, { useRef, useState } from 'react';
16
- import classNames from 'classnames';
17
- import { createPortal } from 'react-dom';
18
- import { PREFIX_CLS } from '../constants';
19
- import Icons from '../Icons';
20
- export default function Actions(props) {
21
- var actionsProp = props.actions,
22
- row = props.row,
23
- index = props.index;
24
-
25
- var _useState = useState(null),
26
- _useState2 = _slicedToArray(_useState, 2),
27
- pop = _useState2[0],
28
- setPop = _useState2[1];
29
-
30
- var _useState3 = useState(false),
31
- _useState4 = _slicedToArray(_useState3, 2),
32
- visible = _useState4[0],
33
- setVisible = _useState4[1];
34
-
35
- var prefixCls = "".concat(PREFIX_CLS, "-table-operator");
36
- var ref = useRef(null);
37
-
38
- var openPop = function openPop(data) {
39
- setPop(data);
40
- setTimeout(function () {
41
- setVisible(true);
42
- }, 16);
43
- };
44
-
45
- var closePop = function closePop() {
46
- if (visible === false) {
47
- setPop(null);
48
- return;
49
- }
50
-
51
- if (ref.current !== null) {
52
- var node = ref.current;
53
- setVisible(false);
54
-
55
- var handler = function handler() {
56
- node.removeEventListener('transitionend', handler);
57
- setPop(null);
58
- };
59
-
60
- node.addEventListener('transitionend', handler);
61
- }
62
- };
63
-
64
- var actions = typeof actionsProp === 'function' ? actionsProp(row, index) : actionsProp;
65
-
66
- var getKey = function getKey(item, idx) {
67
- var key = item.key || (typeof item.text === 'string' ? item.text : idx);
68
- return key;
69
- };
70
-
71
- return /*#__PURE__*/React.createElement("div", {
72
- className: prefixCls,
73
- onMouseLeave: closePop
74
- }, actions.map(function (item, idx) {
75
- if (item === null) {
76
- return null;
77
- }
78
-
79
- var key = getKey(item, idx);
80
- var dropDown = item.dropDown ? item.dropDown.filter(function (item) {
81
- return item !== null;
82
- }) : [];
83
- return /*#__PURE__*/React.createElement("div", {
84
- className: classNames("".concat(prefixCls, "-item"), _defineProperty({}, "".concat(prefixCls, "-item-disabled"), item.disabled)),
85
- key: key,
86
- onMouseEnter: function onMouseEnter() {
87
- if (pop !== null && pop.key !== key) {
88
- closePop();
89
- }
90
- },
91
- onClick: function onClick(e) {
92
- if (item.disabled) {
93
- return;
94
- }
95
-
96
- if (dropDown.length > 0) {
97
- var rect = e.target.getBoundingClientRect();
98
- openPop({
99
- key: key,
100
- top: rect.top + rect.height,
101
- right: document.body.clientWidth - rect.right,
102
- items: dropDown
103
- });
104
- } else {
105
- var _item$onClick;
106
-
107
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, row, index);
108
- }
109
- }
110
- }, item.text, dropDown.length > 0 && /*#__PURE__*/React.createElement(Icons.Down, null));
111
- }), pop !== null && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
112
- className: "".concat(prefixCls, "-popover"),
113
- style: {
114
- top: pop.top,
115
- right: pop.right
116
- }
117
- }, /*#__PURE__*/React.createElement("div", {
118
- ref: ref,
119
- className: classNames("".concat(prefixCls, "-popover-items"), {
120
- animated: visible
121
- })
122
- }, pop.items.map(function (item, idx) {
123
- return /*#__PURE__*/React.createElement("div", {
124
- className: classNames("".concat(prefixCls, "-popover-item"), _defineProperty({}, "".concat(prefixCls, "-popover-item-disabled"), item.disabled)),
125
- key: getKey(item, idx),
126
- onClick: function onClick() {
127
- if (!item.disabled) {
128
- var _item$onClick2;
129
-
130
- closePop();
131
- (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item, row, index);
132
- }
133
- }
134
- }, item.text);
135
- }))), document.body));
136
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare const BaseTableContext: import("react").Context<{
3
- scrollY?: string | number | undefined;
4
- rowHeight?: number | undefined;
5
- }>;
6
- export default BaseTableContext;
@@ -1,6 +0,0 @@
1
- import { createContext } from 'react';
2
- var BaseTableContext = /*#__PURE__*/createContext({
3
- scrollY: 0,
4
- rowHeight: 37
5
- });
6
- export default BaseTableContext;
@@ -1,8 +0,0 @@
1
- import type { ReactElement, RefObject } from 'react';
2
- export default function ResizeHeaderCell(props: {
3
- children?: ReactElement;
4
- fullTableRef: RefObject<HTMLDivElement>;
5
- width: number;
6
- prefixCls?: string;
7
- onChange?: (width: number) => void;
8
- }): JSX.Element;
@@ -1,126 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- 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."); }
4
-
5
- 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); }
6
-
7
- 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; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
- import React, { useState, useRef, useEffect } from 'react';
14
- import { Resizable } from 'react-resizable';
15
- export default function ResizeHeaderCell(props) {
16
- var children = props.children,
17
- prefixCls = props.prefixCls,
18
- fullTableRef = props.fullTableRef,
19
- width = props.width,
20
- onChange = props.onChange;
21
-
22
- var _useState = useState(width),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- size = _useState2[0],
25
- setSize = _useState2[1];
26
-
27
- var indicator = useRef();
28
- var handle = useRef(null);
29
-
30
- var _useState3 = useState(0),
31
- _useState4 = _slicedToArray(_useState3, 2),
32
- offset = _useState4[0],
33
- setOffset = _useState4[1];
34
-
35
- useEffect(function () {
36
- setSize(width);
37
- }, [width]);
38
-
39
- var getTable = function getTable() {
40
- if (fullTableRef.current === null) {
41
- return null;
42
- }
43
-
44
- return fullTableRef.current.querySelector('.ant-table');
45
- };
46
-
47
- var handleResizeStart = function handleResizeStart() {
48
- var table = getTable();
49
-
50
- if (table === null) {
51
- return;
52
- }
53
-
54
- var elm = document.createElement('div');
55
- elm.style.height = "".concat(table.offsetHeight || 0, "px");
56
- elm.classList.add("".concat(prefixCls, "-resizable-indicator"));
57
-
58
- if (table) {
59
- table.appendChild(elm);
60
- table.classList.add("".concat(prefixCls, "-resizing-col"));
61
- indicator.current = elm;
62
-
63
- if (handle.current !== null) {
64
- var _handle$current = handle.current,
65
- parent = _handle$current.offsetParent,
66
- left = _handle$current.offsetLeft;
67
- var node = handle.current.parentNode;
68
-
69
- while (node !== null && node !== table) {
70
- left -= node.scrollLeft;
71
-
72
- if (node === parent) {
73
- left += node.offsetLeft;
74
- parent = node.offsetParent;
75
- }
76
-
77
- node = node.parentNode;
78
- }
79
-
80
- setOffset(left - size);
81
- indicator.current.style.left = "".concat(left, "px");
82
- }
83
- }
84
- };
85
-
86
- var handleResizeStop = function handleResizeStop() {
87
- var table = getTable();
88
-
89
- if (table !== null && indicator.current !== undefined) {
90
- table.removeChild(indicator.current);
91
- table.classList.remove("".concat(prefixCls, "-resizing-col"));
92
-
93
- if (onChange) {
94
- onChange(size);
95
- }
96
- }
97
- };
98
-
99
- var handleResize = function handleResize(e, data) {
100
- e.preventDefault();
101
-
102
- if (indicator.current) {
103
- setSize(data.size.width);
104
- indicator.current.style.left = "".concat(offset + data.size.width, "px");
105
- }
106
- };
107
-
108
- return /*#__PURE__*/React.createElement(Resizable, {
109
- width: size,
110
- height: 0,
111
- handle: /*#__PURE__*/React.createElement("div", {
112
- className: "".concat(prefixCls, "-resizable-handle"),
113
- onClick: function onClick(e) {
114
- e.stopPropagation();
115
- }
116
- }, /*#__PURE__*/React.createElement("div", {
117
- ref: handle
118
- })),
119
- onResizeStart: handleResizeStart,
120
- onResizeStop: handleResizeStop,
121
- onResize: handleResize,
122
- draggableOpts: {
123
- enableUserSelectHack: false
124
- }
125
- }, children);
126
- }
@@ -1,8 +0,0 @@
1
- import type { ReactNode, CSSProperties } from 'react';
2
- interface Props {
3
- children?: ReactNode;
4
- className?: string;
5
- style?: CSSProperties;
6
- }
7
- export default function VirtualList(props: Props): JSX.Element;
8
- export {};
@@ -1,165 +0,0 @@
1
- var _excluded = ["children"];
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
- 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."); }
12
-
13
- 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); }
14
-
15
- 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; }
16
-
17
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
-
19
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
- 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; }
22
-
23
- 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; }
24
-
25
- import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
26
- import { useThrottle } from '@lemon-fe/hooks';
27
- import { get } from 'lodash';
28
- import BaseTableContext from './BaseTableContext';
29
- import { PREFIX_CLS } from '../constants';
30
- export default function VirtualList(props) {
31
- var children = props.children,
32
- restProps = _objectWithoutProperties(props, _excluded);
33
-
34
- var ref = useRef(null);
35
-
36
- var _useContext = useContext(BaseTableContext),
37
- scrollY = _useContext.scrollY,
38
- _useContext$rowHeight = _useContext.rowHeight,
39
- rowHeight = _useContext$rowHeight === void 0 ? 37 : _useContext$rowHeight;
40
-
41
- var _useState = useState(null),
42
- _useState2 = _slicedToArray(_useState, 2),
43
- range = _useState2[0],
44
- setRange = _useState2[1];
45
-
46
- var getRange = function getRange() {
47
- var height = Number(scrollY);
48
-
49
- if (isNaN(height)) {
50
- return null;
51
- }
52
-
53
- var body = ref.current;
54
-
55
- if (body === null) {
56
- return null;
57
- }
58
-
59
- var scroller = body.closest('.ant-table-body');
60
-
61
- if (scroller === null) {
62
- return null;
63
- }
64
-
65
- var pageSize = Math.ceil(height / rowHeight);
66
- var offset = Math.round(scroller.scrollTop / rowHeight);
67
- var start = offset - Math.floor(pageSize / 2);
68
-
69
- if (start < 0) {
70
- start = 0;
71
- }
72
-
73
- var end = offset + pageSize + Math.ceil(pageSize / 2) - 1;
74
- var bufferSpace = height * 0.3;
75
- return {
76
- start: start,
77
- end: end,
78
- isTop: scroller.scrollTop - body.offsetTop <= bufferSpace,
79
- isBottom: body.offsetHeight + body.offsetTop - (scroller.scrollTop + height) <= bufferSpace
80
- };
81
- };
82
-
83
- var handleScroll = useThrottle(function () {
84
- var mRange = getRange();
85
-
86
- if (mRange === null) {
87
- return;
88
- }
89
-
90
- var isTop = mRange.isTop,
91
- isBottom = mRange.isBottom;
92
-
93
- if (!isTop && !isBottom) {
94
- return;
95
- }
96
-
97
- setRange(mRange);
98
- }, 300, {
99
- trailing: true
100
- });
101
- useEffect(function () {
102
- setRange(getRange());
103
- }, [get(children, ['1', 'length']), rowHeight, scrollY]);
104
- var render = useMemo(function () {
105
- var _children = _slicedToArray(children, 2),
106
- measureRow = _children[0],
107
- rows = _children[1];
108
-
109
- if (!Array.isArray(rows)) {
110
- return [children, 0, 0];
111
- }
112
-
113
- if (range === null) {
114
- return [measureRow, 0, 0];
115
- }
116
-
117
- var list = [];
118
- var max = rows.length - 1;
119
- var start = range.start,
120
- end = range.end;
121
-
122
- if (end > max) {
123
- end = max;
124
- }
125
-
126
- for (var i = start; i <= end; i += 1) {
127
- list.push(rows[i]);
128
- }
129
-
130
- return [[measureRow, list], start * rowHeight, (max - end) * rowHeight];
131
- }, [children, range]);
132
- useEffect(function () {
133
- var _ref$current;
134
-
135
- if (ref.current === null) {
136
- return;
137
- }
138
-
139
- var tableBody = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.closest('.ant-table-body');
140
-
141
- if (tableBody === null) {
142
- return;
143
- }
144
-
145
- tableBody.addEventListener('scroll', handleScroll);
146
- return function () {
147
- tableBody.removeEventListener('scroll', handleScroll);
148
- };
149
- }, []);
150
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tbody", {
151
- className: "".concat(PREFIX_CLS, "-table-append-before"),
152
- style: {
153
- display: 'block',
154
- height: render[1]
155
- }
156
- }), /*#__PURE__*/React.createElement("tbody", _objectSpread(_objectSpread({}, restProps), {}, {
157
- ref: ref
158
- }), render[0]), /*#__PURE__*/React.createElement("tbody", {
159
- className: "".concat(PREFIX_CLS, "-table-append-after"),
160
- style: {
161
- display: 'block',
162
- height: render[2]
163
- }
164
- }));
165
- }
@@ -1,7 +0,0 @@
1
- /// <reference path="../../typings.d.ts" />
2
- import type { BaseTableProps as Props } from './typings';
3
- declare function BaseTable<T extends Record<string, any>>(props: Props<T>): JSX.Element;
4
- declare namespace BaseTable {
5
- var Summary: typeof import("rc-table/lib/Footer/Summary").default;
6
- }
7
- export default BaseTable;