@hi-ui/table 4.0.12 → 4.1.0-beta.0

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 (106) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/lib/cjs/BaseTable.js +7 -4
  3. package/lib/cjs/Table.js +19 -6
  4. package/lib/cjs/TableBody.js +88 -8
  5. package/lib/cjs/TableCell.js +42 -1
  6. package/lib/cjs/TableRow.js +42 -2
  7. package/lib/cjs/_virtual/index.js +18 -0
  8. package/lib/cjs/_virtual/index2.js +18 -0
  9. package/lib/cjs/_virtual/react-is.development.js +16 -0
  10. package/lib/cjs/_virtual/react-is.production.min.js +16 -0
  11. package/lib/cjs/hooks/use-check.js +28 -4
  12. package/lib/cjs/hooks/use-col-width.js +37 -8
  13. package/lib/cjs/hooks/use-pagination.js +51 -9
  14. package/lib/cjs/node_modules/classnames/index.js +76 -0
  15. package/lib/cjs/node_modules/rc-resize-observer/es/index.js +236 -0
  16. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +51 -0
  17. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +40 -0
  18. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +77 -0
  19. package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +42 -0
  20. package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +20 -0
  21. package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +40 -0
  22. package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +49 -0
  23. package/lib/cjs/node_modules/rc-util/es/raf.js +72 -0
  24. package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +135 -0
  25. package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +53 -0
  26. package/lib/cjs/node_modules/rc-virtual-list/es/List.js +550 -0
  27. package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +431 -0
  28. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +60 -0
  29. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +129 -0
  30. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +64 -0
  31. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +182 -0
  32. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +93 -0
  33. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +56 -0
  34. package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +154 -0
  35. package/lib/cjs/node_modules/rc-virtual-list/es/index.js +18 -0
  36. package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +65 -0
  37. package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +85 -0
  38. package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +27 -0
  39. package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +208 -0
  40. package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +158 -0
  41. package/lib/cjs/node_modules/react-is/index.js +26 -0
  42. package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +1127 -0
  43. package/lib/cjs/styles/index.scss.js +1 -1
  44. package/lib/cjs/use-table.js +4 -2
  45. package/lib/esm/BaseTable.js +24 -21
  46. package/lib/esm/Table.js +28 -15
  47. package/lib/esm/TableAdvancedFilter.js +13 -13
  48. package/lib/esm/TableBody.js +100 -21
  49. package/lib/esm/TableCell.js +50 -9
  50. package/lib/esm/TableColumnMenu.js +16 -16
  51. package/lib/esm/TableEmbedRow.js +4 -4
  52. package/lib/esm/TableHeader.js +10 -10
  53. package/lib/esm/TableRow.js +53 -13
  54. package/lib/esm/TableSettingMenu.js +14 -14
  55. package/lib/esm/_virtual/index.js +13 -0
  56. package/lib/esm/_virtual/index2.js +13 -0
  57. package/lib/esm/_virtual/react-is.development.js +11 -0
  58. package/lib/esm/_virtual/react-is.production.min.js +11 -0
  59. package/lib/esm/hooks/use-check.js +32 -8
  60. package/lib/esm/hooks/use-col-width.js +44 -15
  61. package/lib/esm/hooks/use-colgroup.js +4 -4
  62. package/lib/esm/hooks/use-drag.js +2 -2
  63. package/lib/esm/hooks/use-embed-expand.js +2 -2
  64. package/lib/esm/hooks/use-pagination.js +51 -10
  65. package/lib/esm/icons/index.js +5 -5
  66. package/lib/esm/node_modules/classnames/index.js +69 -0
  67. package/lib/esm/node_modules/rc-resize-observer/es/index.js +177 -0
  68. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +33 -0
  69. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +23 -0
  70. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +57 -0
  71. package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +34 -0
  72. package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +14 -0
  73. package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +23 -0
  74. package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +17 -0
  75. package/lib/esm/node_modules/rc-util/es/raf.js +66 -0
  76. package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +103 -0
  77. package/lib/esm/node_modules/rc-virtual-list/es/Item.js +23 -0
  78. package/lib/esm/node_modules/rc-virtual-list/es/List.js +508 -0
  79. package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +399 -0
  80. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +29 -0
  81. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +98 -0
  82. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +55 -0
  83. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +150 -0
  84. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +85 -0
  85. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +50 -0
  86. package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +123 -0
  87. package/lib/esm/node_modules/rc-virtual-list/es/index.js +11 -0
  88. package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +59 -0
  89. package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +80 -0
  90. package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +21 -0
  91. package/lib/esm/node_modules/react-is/cjs/react-is.development.js +200 -0
  92. package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +151 -0
  93. package/lib/esm/node_modules/react-is/index.js +20 -0
  94. package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +1122 -0
  95. package/lib/esm/styles/index.scss.js +1 -1
  96. package/lib/esm/use-table.js +12 -10
  97. package/lib/types/Table.d.ts +1 -1
  98. package/lib/types/TableCell.d.ts +4 -0
  99. package/lib/types/context.d.ts +2 -0
  100. package/lib/types/hooks/use-check.d.ts +1 -1
  101. package/lib/types/hooks/use-col-width.d.ts +2 -1
  102. package/lib/types/hooks/use-pagination.d.ts +7 -2
  103. package/lib/types/types.d.ts +7 -3
  104. package/lib/types/use-table.d.ts +14 -1
  105. package/package.json +6 -7
  106. package/LICENSE +0 -21
@@ -0,0 +1,177 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
11
+ import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
12
+ import _createClass from '@babel/runtime/helpers/esm/createClass';
13
+ import _inherits from '@babel/runtime/helpers/esm/inherits';
14
+ import _createSuper from '@babel/runtime/helpers/esm/createSuper';
15
+ import * as React from 'react';
16
+ import findDOMNode from '../node_modules/rc-util/es/Dom/findDOMNode.js';
17
+ import toArray from '../node_modules/rc-util/es/Children/toArray.js';
18
+ import { warningOnce } from '../node_modules/rc-util/es/warning.js';
19
+ import { supportRef, composeRef } from '../node_modules/rc-util/es/ref.js';
20
+ import index from '../../resize-observer-polyfill/dist/ResizeObserver.es.js';
21
+ var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here
22
+
23
+ var ReactResizeObserver = /*#__PURE__*/function (_React$Component) {
24
+ _inherits(ReactResizeObserver, _React$Component);
25
+
26
+ var _super = _createSuper(ReactResizeObserver);
27
+
28
+ function ReactResizeObserver() {
29
+ var _this;
30
+
31
+ _classCallCheck(this, ReactResizeObserver);
32
+
33
+ _this = _super.apply(this, arguments);
34
+ _this.resizeObserver = null;
35
+ _this.childNode = null;
36
+ _this.currentElement = null;
37
+ _this.state = {
38
+ width: 0,
39
+ height: 0,
40
+ offsetHeight: 0,
41
+ offsetWidth: 0
42
+ };
43
+
44
+ _this.onResize = function (entries) {
45
+ var onResize = _this.props.onResize;
46
+ var target = entries[0].target;
47
+
48
+ var _target$getBoundingCl = target.getBoundingClientRect(),
49
+ width = _target$getBoundingCl.width,
50
+ height = _target$getBoundingCl.height;
51
+
52
+ var offsetWidth = target.offsetWidth,
53
+ offsetHeight = target.offsetHeight;
54
+ /**
55
+ * Resize observer trigger when content size changed.
56
+ * In most case we just care about element size,
57
+ * let's use `boundary` instead of `contentRect` here to avoid shaking.
58
+ */
59
+
60
+ var fixedWidth = Math.floor(width);
61
+ var fixedHeight = Math.floor(height);
62
+
63
+ if (_this.state.width !== fixedWidth || _this.state.height !== fixedHeight || _this.state.offsetWidth !== offsetWidth || _this.state.offsetHeight !== offsetHeight) {
64
+ var size = {
65
+ width: fixedWidth,
66
+ height: fixedHeight,
67
+ offsetWidth: offsetWidth,
68
+ offsetHeight: offsetHeight
69
+ };
70
+
71
+ _this.setState(size);
72
+
73
+ if (onResize) {
74
+ // defer the callback but not defer to next frame
75
+ Promise.resolve().then(function () {
76
+ onResize(_objectSpread(_objectSpread({}, size), {}, {
77
+ offsetWidth: offsetWidth,
78
+ offsetHeight: offsetHeight
79
+ }), target);
80
+ });
81
+ }
82
+ }
83
+ };
84
+
85
+ _this.setChildNode = function (node) {
86
+ _this.childNode = node;
87
+ };
88
+
89
+ return _this;
90
+ }
91
+
92
+ _createClass(ReactResizeObserver, [{
93
+ key: "componentDidMount",
94
+ value: function componentDidMount() {
95
+ this.onComponentUpdated();
96
+ }
97
+ }, {
98
+ key: "componentDidUpdate",
99
+ value: function componentDidUpdate() {
100
+ this.onComponentUpdated();
101
+ }
102
+ }, {
103
+ key: "componentWillUnmount",
104
+ value: function componentWillUnmount() {
105
+ this.destroyObserver();
106
+ }
107
+ }, {
108
+ key: "onComponentUpdated",
109
+ value: function onComponentUpdated() {
110
+ var disabled = this.props.disabled; // Unregister if disabled
111
+
112
+ if (disabled) {
113
+ this.destroyObserver();
114
+ return;
115
+ } // Unregister if element changed
116
+
117
+
118
+ var element = findDOMNode(this.childNode || this);
119
+ var elementChanged = element !== this.currentElement;
120
+
121
+ if (elementChanged) {
122
+ this.destroyObserver();
123
+ this.currentElement = element;
124
+ }
125
+
126
+ if (!this.resizeObserver && element) {
127
+ this.resizeObserver = new index(this.onResize);
128
+ this.resizeObserver.observe(element);
129
+ }
130
+ }
131
+ }, {
132
+ key: "destroyObserver",
133
+ value: function destroyObserver() {
134
+ if (this.resizeObserver) {
135
+ this.resizeObserver.disconnect();
136
+ this.resizeObserver = null;
137
+ }
138
+ }
139
+ }, {
140
+ key: "render",
141
+ value: function render() {
142
+ var children = this.props.children;
143
+ var childNodes = toArray(children);
144
+
145
+ if (childNodes.length > 1) {
146
+ warningOnce(false, 'Find more than one child node with `children` in ResizeObserver. Will only observe first one.');
147
+ } else if (childNodes.length === 0) {
148
+ warningOnce(false, '`children` of ResizeObserver is empty. Nothing is in observe.');
149
+ return null;
150
+ }
151
+
152
+ var childNode = childNodes[0];
153
+
154
+ if ( /*#__PURE__*/React.isValidElement(childNode) && supportRef(childNode)) {
155
+ var ref = childNode.ref;
156
+ childNodes[0] = /*#__PURE__*/React.cloneElement(childNode, {
157
+ ref: composeRef(ref, this.setChildNode)
158
+ });
159
+ }
160
+
161
+ return childNodes.length === 1 ? childNodes[0] : childNodes.map(function (node, index) {
162
+ if (! /*#__PURE__*/React.isValidElement(node) || 'key' in node && node.key !== null) {
163
+ return node;
164
+ }
165
+
166
+ return /*#__PURE__*/React.cloneElement(node, {
167
+ key: "".concat(INTERNAL_PREFIX_KEY, "-").concat(index)
168
+ });
169
+ });
170
+ }
171
+ }]);
172
+
173
+ return ReactResizeObserver;
174
+ }(React.Component);
175
+
176
+ ReactResizeObserver.displayName = 'ResizeObserver';
177
+ export { ReactResizeObserver as default };
@@ -0,0 +1,33 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import React__default from 'react';
11
+ import '../../../../../react-is/index.js';
12
+ import { r as reactIs } from '../../../../../../_virtual/index2.js';
13
+
14
+ function toArray(children) {
15
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16
+ var ret = [];
17
+ React__default.Children.forEach(children, function (child) {
18
+ if ((child === undefined || child === null) && !option.keepEmpty) {
19
+ return;
20
+ }
21
+
22
+ if (Array.isArray(child)) {
23
+ ret = ret.concat(toArray(child));
24
+ } else if (reactIs.exports.isFragment(child) && child.props) {
25
+ ret = ret.concat(toArray(child.props.children, option));
26
+ } else {
27
+ ret.push(child);
28
+ }
29
+ });
30
+ return ret;
31
+ }
32
+
33
+ export { toArray as default };
@@ -0,0 +1,23 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import ReactDOM from 'react-dom';
11
+ /**
12
+ * Return if a node is a DOM node. Else will return by `findDOMNode`
13
+ */
14
+
15
+ function findDOMNode(node) {
16
+ if (node instanceof HTMLElement) {
17
+ return node;
18
+ }
19
+
20
+ return ReactDOM.findDOMNode(node);
21
+ }
22
+
23
+ export { findDOMNode as default };
@@ -0,0 +1,57 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import _typeof from '@babel/runtime/helpers/esm/typeof';
11
+ import '../../../../react-is/index.js';
12
+ import { r as reactIs } from '../../../../../_virtual/index2.js';
13
+
14
+ function fillRef(ref, node) {
15
+ if (typeof ref === 'function') {
16
+ ref(node);
17
+ } else if (_typeof(ref) === 'object' && ref && 'current' in ref) {
18
+ ref.current = node;
19
+ }
20
+ }
21
+ /**
22
+ * Merge refs into one ref function to support ref passing.
23
+ */
24
+
25
+
26
+ function composeRef() {
27
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ refs[_key] = arguments[_key];
29
+ }
30
+
31
+ return function (node) {
32
+ refs.forEach(function (ref) {
33
+ fillRef(ref, node);
34
+ });
35
+ };
36
+ }
37
+
38
+ function supportRef(nodeOrComponent) {
39
+ var _type$prototype, _nodeOrComponent$prot;
40
+
41
+ var type = reactIs.exports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type; // Function component node
42
+
43
+ if (typeof type === 'function' && !((_type$prototype = type.prototype) === null || _type$prototype === void 0 ? void 0 : _type$prototype.render)) {
44
+ return false;
45
+ } // Class component
46
+
47
+
48
+ if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) === null || _nodeOrComponent$prot === void 0 ? void 0 : _nodeOrComponent$prot.render)) {
49
+ return false;
50
+ }
51
+
52
+ return true;
53
+ }
54
+ /* eslint-enable */
55
+
56
+
57
+ export { composeRef, fillRef, supportRef };
@@ -0,0 +1,34 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /* eslint-disable no-console */
12
+ var warned = {};
13
+
14
+ function warning(valid, message) {
15
+ // Support uglify
16
+ if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
17
+ console.error("Warning: ".concat(message));
18
+ }
19
+ }
20
+
21
+ function call(method, valid, message) {
22
+ if (!valid && !warned[message]) {
23
+ method(false, message);
24
+ warned[message] = true;
25
+ }
26
+ }
27
+
28
+ function warningOnce(valid, message) {
29
+ call(warning, valid, message);
30
+ }
31
+ /* eslint-enable */
32
+
33
+
34
+ export { call, warningOnce as default, warning, warningOnce };
@@ -0,0 +1,14 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ function canUseDom() {
11
+ return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
12
+ }
13
+
14
+ export { canUseDom as default };
@@ -0,0 +1,23 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import ReactDOM from 'react-dom';
11
+ /**
12
+ * Return if a node is a DOM node. Else will return by `findDOMNode`
13
+ */
14
+
15
+ function findDOMNode(node) {
16
+ if (node instanceof HTMLElement) {
17
+ return node;
18
+ }
19
+
20
+ return ReactDOM.findDOMNode(node);
21
+ }
22
+
23
+ export { findDOMNode as default };
@@ -0,0 +1,17 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import * as React from 'react';
11
+ import canUseDom from '../Dom/canUseDom.js';
12
+ /**
13
+ * Wrap `React.useLayoutEffect` which will not throw warning message in test env
14
+ */
15
+
16
+ var useLayoutEffect = process.env.NODE_ENV !== 'test' && canUseDom() ? React.useLayoutEffect : React.useEffect;
17
+ export { useLayoutEffect as default };
@@ -0,0 +1,66 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ var raf = function raf(callback) {
11
+ return +setTimeout(callback, 16);
12
+ };
13
+
14
+ var caf = function caf(num) {
15
+ return clearTimeout(num);
16
+ };
17
+
18
+ if (typeof window !== 'undefined' && 'requestAnimationFrame' in window) {
19
+ raf = function raf(callback) {
20
+ return window.requestAnimationFrame(callback);
21
+ };
22
+
23
+ caf = function caf(handle) {
24
+ return window.cancelAnimationFrame(handle);
25
+ };
26
+ }
27
+
28
+ var rafUUID = 0;
29
+ var rafIds = new Map();
30
+
31
+ function cleanup(id) {
32
+ rafIds["delete"](id);
33
+ }
34
+
35
+ function wrapperRaf(callback) {
36
+ var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
37
+ rafUUID += 1;
38
+ var id = rafUUID;
39
+
40
+ function callRef(leftTimes) {
41
+ if (leftTimes === 0) {
42
+ // Clean up
43
+ cleanup(id); // Trigger
44
+
45
+ callback();
46
+ } else {
47
+ // Next raf
48
+ var realId = raf(function () {
49
+ callRef(leftTimes - 1);
50
+ }); // Bind real raf id
51
+
52
+ rafIds.set(id, realId);
53
+ }
54
+ }
55
+
56
+ callRef(times);
57
+ return id;
58
+ }
59
+
60
+ wrapperRaf.cancel = function (id) {
61
+ var realId = rafIds.get(id);
62
+ cleanup(realId);
63
+ return caf(realId);
64
+ };
65
+
66
+ export { wrapperRaf as default };
@@ -0,0 +1,103 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import * as React from 'react';
11
+ import ReactResizeObserver from '../../rc-resize-observer/es/index.js';
12
+ import classNames from '../../classnames/index.js';
13
+
14
+ function ownKeys(object, enumerableOnly) {
15
+ var keys = Object.keys(object);
16
+
17
+ if (Object.getOwnPropertySymbols) {
18
+ var symbols = Object.getOwnPropertySymbols(object);
19
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
20
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
21
+ })), keys.push.apply(keys, symbols);
22
+ }
23
+
24
+ return keys;
25
+ }
26
+
27
+ function _objectSpread(target) {
28
+ for (var i = 1; i < arguments.length; i++) {
29
+ var source = null != arguments[i] ? arguments[i] : {};
30
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
31
+ _defineProperty(target, key, source[key]);
32
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
33
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
34
+ });
35
+ }
36
+
37
+ return target;
38
+ }
39
+
40
+ function _defineProperty(obj, key, value) {
41
+ if (key in obj) {
42
+ Object.defineProperty(obj, key, {
43
+ value: value,
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true
47
+ });
48
+ } else {
49
+ obj[key] = value;
50
+ }
51
+
52
+ return obj;
53
+ }
54
+ /**
55
+ * Fill component to provided the scroll content real height.
56
+ */
57
+
58
+
59
+ var Filler = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
60
+ var height = _ref.height,
61
+ offset = _ref.offset,
62
+ children = _ref.children,
63
+ prefixCls = _ref.prefixCls,
64
+ onInnerResize = _ref.onInnerResize;
65
+ var outerStyle = {};
66
+ var innerStyle = {
67
+ display: 'flex',
68
+ flexDirection: 'column'
69
+ };
70
+
71
+ if (offset !== undefined) {
72
+ outerStyle = {
73
+ height: height,
74
+ position: 'relative',
75
+ overflow: 'hidden'
76
+ };
77
+ innerStyle = _objectSpread(_objectSpread({}, innerStyle), {}, {
78
+ transform: "translateY(".concat(offset, "px)"),
79
+ position: 'absolute',
80
+ left: 0,
81
+ right: 0,
82
+ top: 0
83
+ });
84
+ }
85
+
86
+ return /*#__PURE__*/React.createElement("div", {
87
+ style: outerStyle
88
+ }, /*#__PURE__*/React.createElement(ReactResizeObserver, {
89
+ onResize: function onResize(_ref2) {
90
+ var offsetHeight = _ref2.offsetHeight;
91
+
92
+ if (offsetHeight && onInnerResize) {
93
+ onInnerResize();
94
+ }
95
+ }
96
+ }, /*#__PURE__*/React.createElement("div", {
97
+ style: innerStyle,
98
+ className: classNames(_defineProperty({}, "".concat(prefixCls, "-holder-inner"), prefixCls)),
99
+ ref: ref
100
+ }, children)));
101
+ });
102
+ Filler.displayName = 'Filler';
103
+ export { Filler as default };
@@ -0,0 +1,23 @@
1
+ /** @LICENSE
2
+ * @hi-ui/table
3
+ * https://github.com/XiaoMi/hiui/tree/master/packages/ui/table#readme
4
+ *
5
+ * Copyright (c) HiUI <mi-hiui@xiaomi.com>.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ import * as React from 'react';
11
+
12
+ function Item(_ref) {
13
+ var children = _ref.children,
14
+ setRef = _ref.setRef;
15
+ var refFunc = React.useCallback(function (node) {
16
+ setRef(node);
17
+ }, []);
18
+ return /*#__PURE__*/React.cloneElement(children, {
19
+ ref: refFunc
20
+ });
21
+ }
22
+
23
+ export { Item };