@hi-ui/table 4.0.13 → 4.1.0-beta.1

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 (105) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/lib/cjs/BaseTable.js +7 -4
  3. package/lib/cjs/Table.js +19 -6
  4. package/lib/cjs/TableBody.js +83 -2
  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 +95 -15
  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 +5 -5
@@ -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 };