linkmore-design 1.1.13-alpha.1 → 1.1.14

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 (107) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/Form/demos/disabled.d.ts +2 -0
  3. package/dist/LmEditTable/DndContainer.d.ts +3 -4
  4. package/dist/LmEditTable/EditTable.d.ts +0 -2
  5. package/dist/LmEditTable/sortableItem.d.ts +2 -3
  6. package/dist/LmEditTable/util.d.ts +0 -2
  7. package/dist/LmFilter/LmFilter.d.ts +2 -6
  8. package/dist/LmTable/expression.d.ts +1 -0
  9. package/dist/LmTable/hooks/useGroupDataSource.d.ts +7 -0
  10. package/dist/index.umd.js +364 -517
  11. package/dist/index.umd.min.js +17 -17
  12. package/dist/variables.css +3 -29
  13. package/es/Cascader/index.js +16 -2
  14. package/es/Form/style/index.css +3 -0
  15. package/es/Form/style/variables.css +3 -0
  16. package/es/IconFont/index.js +1 -1
  17. package/es/Input/index.js +20 -4
  18. package/es/InputNumber/index.js +9 -2
  19. package/es/LmEditTable/DndContainer.d.ts +3 -4
  20. package/es/LmEditTable/DndContainer.js +2 -2
  21. package/es/LmEditTable/EditTable.d.ts +0 -2
  22. package/es/LmEditTable/EditTable.js +150 -139
  23. package/es/LmEditTable/sortableItem.d.ts +2 -3
  24. package/es/LmEditTable/sortableItem.js +4 -15
  25. package/es/LmEditTable/style/index.css +0 -29
  26. package/es/LmEditTable/style/variables.css +0 -29
  27. package/es/LmEditTable/util.d.ts +0 -2
  28. package/es/LmEditTable/util.js +1 -47
  29. package/es/LmFilter/LmFilter.js +6 -6
  30. package/es/LmFilter/components/DropdownFIlter.js +5 -2
  31. package/es/LmFilter/index.js +0 -3
  32. package/es/LmTable/Table.js +10 -7
  33. package/es/LmTable/expression.d.ts +1 -0
  34. package/es/LmTable/expression.js +31 -0
  35. package/es/LmTable/hooks/useGroupDataSource.js +50 -0
  36. package/es/LmUpload/fns/index.js +8 -3
  37. package/es/Select/index.js +17 -7
  38. package/es/hooks/useEvent/index.js +1 -1
  39. package/es/styles/variables.css +3 -29
  40. package/lib/Cascader/index.js +16 -2
  41. package/lib/Form/style/index.css +3 -0
  42. package/lib/Form/style/variables.css +3 -0
  43. package/lib/IconFont/index.js +1 -1
  44. package/lib/Input/index.js +22 -4
  45. package/lib/InputNumber/index.js +11 -2
  46. package/lib/LmEditTable/DndContainer.d.ts +3 -4
  47. package/lib/LmEditTable/DndContainer.js +3 -4
  48. package/lib/LmEditTable/EditTable.d.ts +0 -2
  49. package/lib/LmEditTable/EditTable.js +146 -135
  50. package/lib/LmEditTable/sortableItem.d.ts +2 -3
  51. package/lib/LmEditTable/sortableItem.js +5 -18
  52. package/lib/LmEditTable/style/index.css +0 -29
  53. package/lib/LmEditTable/style/variables.css +0 -29
  54. package/lib/LmEditTable/util.d.ts +0 -2
  55. package/lib/LmEditTable/util.js +0 -50
  56. package/lib/LmFilter/LmFilter.js +6 -6
  57. package/lib/LmFilter/components/DropdownFIlter.js +5 -2
  58. package/lib/LmFilter/index.js +0 -3
  59. package/lib/LmTable/Table.js +10 -7
  60. package/lib/LmTable/expression.d.ts +1 -0
  61. package/lib/LmTable/expression.js +41 -0
  62. package/lib/LmTable/hooks/useGroupDataSource.js +50 -0
  63. package/lib/LmUpload/fns/index.js +8 -3
  64. package/lib/Select/index.js +19 -7
  65. package/lib/hooks/useEvent/index.js +1 -1
  66. package/lib/styles/variables.css +3 -29
  67. package/package.json +1 -1
  68. package/dist/LmEditTable/components/DraggableContainer.d.ts +0 -7
  69. package/dist/LmEditTable/components/index.d.ts +0 -11
  70. package/dist/LmEditTable/virtual/VirtualRow.d.ts +0 -6
  71. package/dist/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
  72. package/dist/LmEditTable/virtual/VirtualTable.d.ts +0 -3
  73. package/dist/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
  74. package/dist/LmEditTable/virtual/context.d.ts +0 -13
  75. package/dist/LmEditTable/virtual/index.d.ts +0 -4
  76. package/es/LmEditTable/components/DraggableContainer.d.ts +0 -7
  77. package/es/LmEditTable/components/DraggableContainer.js +0 -32
  78. package/es/LmEditTable/components/index.d.ts +0 -11
  79. package/es/LmEditTable/components/index.js +0 -5
  80. package/es/LmEditTable/virtual/VirtualRow.d.ts +0 -6
  81. package/es/LmEditTable/virtual/VirtualRow.js +0 -60
  82. package/es/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
  83. package/es/LmEditTable/virtual/VirtualRowBack.js +0 -102
  84. package/es/LmEditTable/virtual/VirtualTable.d.ts +0 -3
  85. package/es/LmEditTable/virtual/VirtualTable.js +0 -54
  86. package/es/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
  87. package/es/LmEditTable/virtual/VirtualWrapper.js +0 -60
  88. package/es/LmEditTable/virtual/context.d.ts +0 -13
  89. package/es/LmEditTable/virtual/context.js +0 -54
  90. package/es/LmEditTable/virtual/index.d.ts +0 -4
  91. package/es/LmEditTable/virtual/index.js +0 -4
  92. package/lib/LmEditTable/components/DraggableContainer.d.ts +0 -7
  93. package/lib/LmEditTable/components/DraggableContainer.js +0 -45
  94. package/lib/LmEditTable/components/index.d.ts +0 -11
  95. package/lib/LmEditTable/components/index.js +0 -21
  96. package/lib/LmEditTable/virtual/VirtualRow.d.ts +0 -6
  97. package/lib/LmEditTable/virtual/VirtualRow.js +0 -73
  98. package/lib/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
  99. package/lib/LmEditTable/virtual/VirtualRowBack.js +0 -115
  100. package/lib/LmEditTable/virtual/VirtualTable.d.ts +0 -3
  101. package/lib/LmEditTable/virtual/VirtualTable.js +0 -71
  102. package/lib/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
  103. package/lib/LmEditTable/virtual/VirtualWrapper.js +0 -73
  104. package/lib/LmEditTable/virtual/context.d.ts +0 -13
  105. package/lib/LmEditTable/virtual/context.js +0 -64
  106. package/lib/LmEditTable/virtual/index.d.ts +0 -4
  107. package/lib/LmEditTable/virtual/index.js +0 -31
@@ -1,102 +0,0 @@
1
- var __rest = this && this.__rest || function (s, e) {
2
- var t = {};
3
-
4
- for (var p in s) {
5
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
- }
7
-
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
-
14
- import React, { useRef, useMemo, useEffect } from 'react';
15
- import { useStore } from './context';
16
- var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
17
- var children = _a.children,
18
- resetProps = __rest(_a, ["children"]);
19
-
20
- var _useStore = useStore(),
21
- state = _useStore.state,
22
- dispatch = _useStore.dispatch,
23
- instance = _useStore.instance;
24
-
25
- var rowHeight = state.rowHeight,
26
- totalLen = state.totalLen;
27
- var virtualItems = instance.columnVirtual.virtualItems;
28
- var trRef = useRef(null); // 列长度
29
-
30
- var columnsLen = useMemo(function () {
31
- var _a;
32
-
33
- return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
34
- }, [children]);
35
- useEffect(function () {
36
- if (state.columnsLen !== columnsLen) {
37
- dispatch({
38
- type: 'changeColumnsLen',
39
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
40
- });
41
- }
42
- }, [columnsLen, dispatch, state.columnsLen]);
43
- useEffect(function () {
44
- var initHeight = function initHeight(tempRef) {
45
- var _a, _b, _c;
46
-
47
- if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
48
- var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
49
- dispatch({
50
- type: 'initHeight',
51
- rowHeight: tempRowHeight
52
- });
53
- }
54
- };
55
-
56
- initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
57
- }, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
58
-
59
- var fixedColumns = useMemo(function () {
60
- return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
61
- var _a, _b;
62
-
63
- if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
64
- pre.fixedLeft.push(cur);
65
- return pre;
66
- }
67
-
68
- if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
69
- pre.fixedRight.push(cur);
70
- return pre;
71
- }
72
-
73
- pre.columns.push(cur);
74
- return pre;
75
- }, {
76
- fixedLeft: [],
77
- fixedRight: [],
78
- columns: []
79
- });
80
- }, [children]); // 截取非固定列
81
-
82
- var resetVirtualItems = useMemo(function () {
83
- var fixedLeft = fixedColumns.fixedLeft,
84
- columns = fixedColumns.columns;
85
- return virtualItems.slice(fixedLeft.length, fixedLeft.length + columns.length);
86
- }, [fixedColumns, virtualItems]); // 横向单元格合并
87
-
88
- var colSpan = useMemo(function () {
89
- var _a;
90
-
91
- var startIndex = ((_a = resetVirtualItems === null || resetVirtualItems === void 0 ? void 0 : resetVirtualItems[0]) === null || _a === void 0 ? void 0 : _a.index) || 0;
92
- return startIndex ? startIndex - fixedColumns.fixedLeft.length : startIndex;
93
- }, [fixedColumns, resetVirtualItems]);
94
- return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
95
- ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
96
- }), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/React.createElement("td", {
97
- colSpan: colSpan
98
- }), resetVirtualItems.map(function (virtualCol) {
99
- return children[virtualCol.index];
100
- }), fixedColumns.fixedRight);
101
- });
102
- export default VirtualRow;
@@ -1,3 +0,0 @@
1
- import React, { PropsWithChildren } from 'react';
2
- declare const VirtualTable: React.MemoExoticComponent<(tableProps: PropsWithChildren<any>) => JSX.Element>;
3
- export default VirtualTable;
@@ -1,54 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React, { useRef } from 'react';
3
- import { useVirtual } from 'react-virtual';
4
- import { TableContext, useRealive } from './context';
5
- var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
6
- var _a, _b, _c, _d;
7
-
8
- var bodyRef = useRef(null);
9
-
10
- var _useRealive = useRealive(),
11
- _useRealive2 = _slicedToArray(_useRealive, 2),
12
- state = _useRealive2[0],
13
- dispatch = _useRealive2[1]; // { totalSize, virtualItems }
14
-
15
-
16
- var rowVirtual = useVirtual({
17
- size: state.totalLen,
18
- // 绑定父节点
19
- parentRef: {
20
- current: (_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _a === void 0 ? void 0 : _a.parentNode
21
- },
22
- estimateSize: React.useCallback(function () {
23
- return state.rowHeight;
24
- }, [state.rowHeight]),
25
- overscan: 5
26
- });
27
- var columnVirtual = useVirtual({
28
- horizontal: true,
29
- size: state.columnsLen,
30
- parentRef: {
31
- current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
32
- },
33
- estimateSize: React.useCallback(function (i) {
34
- var _a, _b;
35
-
36
- return (_b = (_a = tableProps === null || tableProps === void 0 ? void 0 : tableProps.children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.colWidths[i];
37
- }, [(_d = (_c = tableProps.children[0]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.colWidths]),
38
- overscan: 5
39
- });
40
- var instance = {
41
- rowVirtual: rowVirtual,
42
- columnVirtual: columnVirtual
43
- };
44
- return /*#__PURE__*/React.createElement(TableContext.Provider, {
45
- value: {
46
- state: state,
47
- dispatch: dispatch,
48
- instance: instance
49
- }
50
- }, /*#__PURE__*/React.createElement("table", Object.assign({
51
- ref: bodyRef
52
- }, tableProps)));
53
- });
54
- export default VirtualTable;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const VirtualWrapper: React.MemoExoticComponent<(wrapperProps: React.PropsWithChildren<any>) => JSX.Element>;
3
- export default VirtualWrapper;
@@ -1,60 +0,0 @@
1
- var __rest = this && this.__rest || function (s, e) {
2
- var t = {};
3
-
4
- for (var p in s) {
5
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
- }
7
-
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
-
14
- import React, { useEffect, useMemo } from 'react';
15
- import { useStore } from './context';
16
- var VirtualWrapper = /*#__PURE__*/React.memo(function (wrapperProps) {
17
- var _a, _b;
18
-
19
- var children = wrapperProps.children,
20
- resetProps = __rest(wrapperProps, ["children"]);
21
-
22
- var _useStore = useStore(),
23
- state = _useStore.state,
24
- dispatch = _useStore.dispatch,
25
- instance = _useStore.instance;
26
-
27
- var _instance$rowVirtual = instance.rowVirtual,
28
- virtualItems = _instance$rowVirtual.virtualItems,
29
- totalSize = _instance$rowVirtual.totalSize;
30
- var contents = useMemo(function () {
31
- return children[1];
32
- }, [children]);
33
- var contentsLen = useMemo(function () {
34
- var _a;
35
-
36
- return (_a = contents === null || contents === void 0 ? void 0 : contents.length) !== null && _a !== void 0 ? _a : 0;
37
- }, [contents]);
38
- useEffect(function () {
39
- if (state.totalLen !== contentsLen) {
40
- dispatch({
41
- type: 'changeTotalLen',
42
- totalLen: contentsLen !== null && contentsLen !== void 0 ? contentsLen : 0
43
- });
44
- }
45
- }, [contentsLen, dispatch, state.totalLen]);
46
- var paddingTop = virtualItems.length > 0 ? ((_a = virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems[0]) === null || _a === void 0 ? void 0 : _a.start) || 0 : 0;
47
- var paddingBottom = virtualItems.length > 0 ? totalSize - (((_b = virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems[virtualItems.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0) : 0;
48
- return /*#__PURE__*/React.createElement("tbody", Object.assign({}, resetProps), paddingTop > 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
49
- style: {
50
- height: "".concat(paddingTop, "px")
51
- }
52
- })), children[0], virtualItems.map(function (virtualRow) {
53
- return contents[virtualRow.index];
54
- }), paddingBottom > 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
55
- style: {
56
- height: "".concat(paddingBottom, "px")
57
- }
58
- })));
59
- });
60
- export default VirtualWrapper;
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- declare const TableContext: import("react").Context<{
3
- state: any;
4
- dispatch: any;
5
- instance: any;
6
- }>;
7
- declare const useStore: () => {
8
- state: any;
9
- dispatch: any;
10
- instance: any;
11
- };
12
- declare const useRealive: () => [any, import("react").Dispatch<any>];
13
- export { TableContext, useStore, useRealive };
@@ -1,54 +0,0 @@
1
- import { createContext, useContext, useReducer } from 'react'; // =============== context ============== //
2
-
3
- var TableContext = /*#__PURE__*/createContext({
4
- state: null,
5
- dispatch: null,
6
- instance: {}
7
- });
8
-
9
- var useStore = function useStore() {
10
- return useContext(TableContext);
11
- };
12
-
13
- var initialState = {
14
- // 行高度
15
- rowHeight: 0,
16
- columnsLen: 0,
17
- // 总行数
18
- totalLen: 0
19
- };
20
-
21
- var reducer = function reducer(state, action) {
22
- var totalLen = action.totalLen,
23
- columnsLen = action.columnsLen,
24
- rowHeight = action.rowHeight;
25
-
26
- switch (action.type) {
27
- // 数据数量
28
- case 'changeTotalLen':
29
- return Object.assign(Object.assign({}, state), {
30
- totalLen: totalLen
31
- });
32
- // 列数量
33
-
34
- case 'changeColumnsLen':
35
- return Object.assign(Object.assign({}, state), {
36
- columnsLen: columnsLen
37
- });
38
- // 初始化行高度
39
-
40
- case 'initHeight':
41
- return Object.assign(Object.assign({}, state), {
42
- rowHeight: rowHeight
43
- });
44
-
45
- default:
46
- throw new Error();
47
- }
48
- };
49
-
50
- var useRealive = function useRealive() {
51
- return useReducer(reducer, initialState);
52
- };
53
-
54
- export { TableContext, useStore, useRealive };
@@ -1,4 +0,0 @@
1
- import VirtualTable from './VirtualTable';
2
- import VirtualWrapper from './VirtualWrapper';
3
- import VirtualRow from './VirtualRow';
4
- export { VirtualTable, VirtualWrapper, VirtualRow };
@@ -1,4 +0,0 @@
1
- import VirtualTable from './VirtualTable';
2
- import VirtualWrapper from './VirtualWrapper';
3
- import VirtualRow from './VirtualRow';
4
- export { VirtualTable, VirtualWrapper, VirtualRow };
@@ -1,7 +0,0 @@
1
- declare const DraggableContainer: ({ keys, onSortEnd, virtual, ...props }: {
2
- [x: string]: any;
3
- keys: any;
4
- onSortEnd: any;
5
- virtual: any;
6
- }) => JSX.Element;
7
- export default DraggableContainer;
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _DndContainer = _interopRequireDefault(require("../DndContainer"));
13
-
14
- var _sortableBox = _interopRequireDefault(require("../sortableBox"));
15
-
16
- var _virtual = require("../virtual");
17
-
18
- var __rest = void 0 && (void 0).__rest || function (s, e) {
19
- var t = {};
20
-
21
- for (var p in s) {
22
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
23
- }
24
-
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
27
- }
28
- return t;
29
- };
30
-
31
- var DraggableContainer = function DraggableContainer(_a) {
32
- var keys = _a.keys,
33
- onSortEnd = _a.onSortEnd,
34
- virtual = _a.virtual,
35
- props = __rest(_a, ["keys", "onSortEnd", "virtual"]);
36
-
37
- return /*#__PURE__*/_react.default.createElement(_DndContainer.default, {
38
- move: onSortEnd
39
- }, /*#__PURE__*/_react.default.createElement(_sortableBox.default, {
40
- items: keys
41
- }, virtual ? /*#__PURE__*/_react.default.createElement(_virtual.VirtualWrapper, Object.assign({}, props)) : /*#__PURE__*/_react.default.createElement("tbody", Object.assign({}, props))));
42
- };
43
-
44
- var _default = DraggableContainer;
45
- exports.default = _default;
@@ -1,11 +0,0 @@
1
- import DraggableContainer from './DraggableContainer';
2
- export { DraggableContainer };
3
- declare const _default: {
4
- DraggableContainer: ({ keys, onSortEnd, virtual, ...props }: {
5
- [x: string]: any;
6
- keys: any;
7
- onSortEnd: any;
8
- virtual: any;
9
- }) => JSX.Element;
10
- };
11
- export default _default;
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "DraggableContainer", {
9
- enumerable: true,
10
- get: function get() {
11
- return _DraggableContainer.default;
12
- }
13
- });
14
- exports.default = void 0;
15
-
16
- var _DraggableContainer = _interopRequireDefault(require("./DraggableContainer"));
17
-
18
- var _default = {
19
- DraggableContainer: _DraggableContainer.default
20
- };
21
- exports.default = _default;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- interface rowProps {
3
- children?: any;
4
- }
5
- declare const VirtualRow: React.NamedExoticComponent<rowProps>;
6
- export default VirtualRow;
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _context = require("./context");
13
-
14
- var __rest = void 0 && (void 0).__rest || function (s, e) {
15
- var t = {};
16
-
17
- for (var p in s) {
18
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
19
- }
20
-
21
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
23
- }
24
- return t;
25
- };
26
-
27
- var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
28
- var children = _a.children,
29
- resetProps = __rest(_a, ["children"]);
30
-
31
- var _useStore = (0, _context.useStore)(),
32
- state = _useStore.state,
33
- dispatch = _useStore.dispatch;
34
-
35
- var rowHeight = state.rowHeight,
36
- totalLen = state.totalLen;
37
- var trRef = (0, _react.useRef)(null); // 列长度
38
-
39
- var columnsLen = (0, _react.useMemo)(function () {
40
- var _a;
41
-
42
- return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
43
- }, [children]);
44
- (0, _react.useEffect)(function () {
45
- if (state.columnsLen !== columnsLen) {
46
- dispatch({
47
- type: 'changeColumnsLen',
48
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
49
- });
50
- }
51
- }, [columnsLen, dispatch, state.columnsLen]);
52
- (0, _react.useEffect)(function () {
53
- var initHeight = function initHeight(tempRef) {
54
- var _a, _b, _c;
55
-
56
- if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
57
- var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
58
- dispatch({
59
- type: 'initHeight',
60
- rowHeight: tempRowHeight
61
- });
62
- }
63
- };
64
-
65
- initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
66
- }, [trRef, dispatch, rowHeight, totalLen, ref]);
67
- return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
68
- ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
69
- }), children);
70
- });
71
-
72
- var _default = VirtualRow;
73
- exports.default = _default;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- interface rowProps {
3
- children?: any;
4
- }
5
- declare const VirtualRow: React.NamedExoticComponent<rowProps>;
6
- export default VirtualRow;
@@ -1,115 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _react = _interopRequireWildcard(require("react"));
11
-
12
- var _context = require("./context");
13
-
14
- var __rest = void 0 && (void 0).__rest || function (s, e) {
15
- var t = {};
16
-
17
- for (var p in s) {
18
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
19
- }
20
-
21
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
23
- }
24
- return t;
25
- };
26
-
27
- var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
28
- var children = _a.children,
29
- resetProps = __rest(_a, ["children"]);
30
-
31
- var _useStore = (0, _context.useStore)(),
32
- state = _useStore.state,
33
- dispatch = _useStore.dispatch,
34
- instance = _useStore.instance;
35
-
36
- var rowHeight = state.rowHeight,
37
- totalLen = state.totalLen;
38
- var virtualItems = instance.columnVirtual.virtualItems;
39
- var trRef = (0, _react.useRef)(null); // 列长度
40
-
41
- var columnsLen = (0, _react.useMemo)(function () {
42
- var _a;
43
-
44
- return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
45
- }, [children]);
46
- (0, _react.useEffect)(function () {
47
- if (state.columnsLen !== columnsLen) {
48
- dispatch({
49
- type: 'changeColumnsLen',
50
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
51
- });
52
- }
53
- }, [columnsLen, dispatch, state.columnsLen]);
54
- (0, _react.useEffect)(function () {
55
- var initHeight = function initHeight(tempRef) {
56
- var _a, _b, _c;
57
-
58
- if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
59
- var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
60
- dispatch({
61
- type: 'initHeight',
62
- rowHeight: tempRowHeight
63
- });
64
- }
65
- };
66
-
67
- initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
68
- }, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
69
-
70
- var fixedColumns = (0, _react.useMemo)(function () {
71
- return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
72
- var _a, _b;
73
-
74
- if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
75
- pre.fixedLeft.push(cur);
76
- return pre;
77
- }
78
-
79
- if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
80
- pre.fixedRight.push(cur);
81
- return pre;
82
- }
83
-
84
- pre.columns.push(cur);
85
- return pre;
86
- }, {
87
- fixedLeft: [],
88
- fixedRight: [],
89
- columns: []
90
- });
91
- }, [children]); // 截取非固定列
92
-
93
- var resetVirtualItems = (0, _react.useMemo)(function () {
94
- var fixedLeft = fixedColumns.fixedLeft,
95
- columns = fixedColumns.columns;
96
- return virtualItems.slice(fixedLeft.length, fixedLeft.length + columns.length);
97
- }, [fixedColumns, virtualItems]); // 横向单元格合并
98
-
99
- var colSpan = (0, _react.useMemo)(function () {
100
- var _a;
101
-
102
- var startIndex = ((_a = resetVirtualItems === null || resetVirtualItems === void 0 ? void 0 : resetVirtualItems[0]) === null || _a === void 0 ? void 0 : _a.index) || 0;
103
- return startIndex ? startIndex - fixedColumns.fixedLeft.length : startIndex;
104
- }, [fixedColumns, resetVirtualItems]);
105
- return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
106
- ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
107
- }), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/_react.default.createElement("td", {
108
- colSpan: colSpan
109
- }), resetVirtualItems.map(function (virtualCol) {
110
- return children[virtualCol.index];
111
- }), fixedColumns.fixedRight);
112
- });
113
-
114
- var _default = VirtualRow;
115
- exports.default = _default;
@@ -1,3 +0,0 @@
1
- import React, { PropsWithChildren } from 'react';
2
- declare const VirtualTable: React.MemoExoticComponent<(tableProps: PropsWithChildren<any>) => JSX.Element>;
3
- export default VirtualTable;
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.default = void 0;
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _react = _interopRequireWildcard(require("react"));
15
-
16
- var _reactVirtual = require("react-virtual");
17
-
18
- var _context = require("./context");
19
-
20
- var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
21
- var _a, _b, _c, _d;
22
-
23
- var bodyRef = (0, _react.useRef)(null);
24
-
25
- var _useRealive = (0, _context.useRealive)(),
26
- _useRealive2 = (0, _slicedToArray2.default)(_useRealive, 2),
27
- state = _useRealive2[0],
28
- dispatch = _useRealive2[1]; // { totalSize, virtualItems }
29
-
30
-
31
- var rowVirtual = (0, _reactVirtual.useVirtual)({
32
- size: state.totalLen,
33
- // 绑定父节点
34
- parentRef: {
35
- current: (_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _a === void 0 ? void 0 : _a.parentNode
36
- },
37
- estimateSize: _react.default.useCallback(function () {
38
- return state.rowHeight;
39
- }, [state.rowHeight]),
40
- overscan: 5
41
- });
42
- var columnVirtual = (0, _reactVirtual.useVirtual)({
43
- horizontal: true,
44
- size: state.columnsLen,
45
- parentRef: {
46
- current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
47
- },
48
- estimateSize: _react.default.useCallback(function (i) {
49
- var _a, _b;
50
-
51
- return (_b = (_a = tableProps === null || tableProps === void 0 ? void 0 : tableProps.children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.colWidths[i];
52
- }, [(_d = (_c = tableProps.children[0]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.colWidths]),
53
- overscan: 5
54
- });
55
- var instance = {
56
- rowVirtual: rowVirtual,
57
- columnVirtual: columnVirtual
58
- };
59
- return /*#__PURE__*/_react.default.createElement(_context.TableContext.Provider, {
60
- value: {
61
- state: state,
62
- dispatch: dispatch,
63
- instance: instance
64
- }
65
- }, /*#__PURE__*/_react.default.createElement("table", Object.assign({
66
- ref: bodyRef
67
- }, tableProps)));
68
- });
69
-
70
- var _default = VirtualTable;
71
- exports.default = _default;