@aloudata/aloudata-design 1.5.4 → 1.6.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.
- package/dist/Button/index.js +17 -6
- package/dist/Button/style/index.less +60 -114
- package/dist/Button/style/variables.less +0 -1
- package/dist/ColorPicker/style/index.less +2 -2
- package/dist/ConfigProvider/index.d.ts +2 -1
- package/dist/ConfigProvider/index.js +1 -0
- package/dist/DataPreviewTable/components/Body/SkeletonBody.js +2 -2
- package/dist/DataPreviewTable/components/Body/index.js +2 -1
- package/dist/DataPreviewTable/components/Header/index.d.ts +2 -2
- package/dist/DataPreviewTable/components/Header/index.js +11 -19
- package/dist/DataPreviewTable/hooks/useDirection.d.ts +4 -21
- package/dist/DataPreviewTable/hooks/useDirection.js +109 -146
- package/dist/DataPreviewTable/index.js +25 -16
- package/dist/DataPreviewTable/interface.d.ts +18 -0
- package/dist/DataPreviewTable/interface.js +13 -1
- package/dist/DataPreviewTable/utils/getColumnOffsetsFromWidths.d.ts +1 -0
- package/dist/DataPreviewTable/utils/getColumnOffsetsFromWidths.js +8 -0
- package/dist/DataPreviewTable/utils/getColumnRange.d.ts +8 -0
- package/dist/DataPreviewTable/utils/getColumnRange.js +25 -0
- package/dist/DataPreviewTable/utils/getRowRange.d.ts +7 -0
- package/dist/DataPreviewTable/utils/getRowRange.js +28 -0
- package/dist/DataPreviewTable/utils/getTableLayout.d.ts +3 -0
- package/dist/DataPreviewTable/utils/getTableLayout.js +18 -0
- package/dist/DatePicker/index.d.ts +20 -11
- package/dist/DatePicker/index.js +216 -13
- package/dist/DatePicker/style/index.less +13 -0
- package/dist/Dropdown/style/index.less +3 -0
- package/dist/Empty/style/index.less +11 -13
- package/dist/Input/components/Input/index.js +16 -3
- package/dist/Input/style/index.less +11 -10
- package/dist/MemberPicker/components/MultipleOption.js +5 -1
- package/dist/MemberPicker/components/NickLabel.js +1 -2
- package/dist/MemberPicker/components/SelectedMemberTags.js +5 -1
- package/dist/MemberPicker/components/SingleOption.js +5 -1
- package/dist/MemberPicker/index.js +9 -3
- package/dist/MemberPicker/interface.d.ts +3 -3
- package/dist/MemberPicker/style/index.less +11 -3
- package/dist/Modal/style/index.less +2 -5
- package/dist/Select/components/SingleOption.js +3 -9
- package/dist/Select/index.js +34 -15
- package/dist/Select/style/single.less +11 -7
- package/dist/Select/style/size.less +19 -0
- package/dist/Select/style/status.less +2 -1
- package/dist/Table/style/index.less +2 -2
- package/dist/Table/style/variable.less +0 -1
- package/dist/Tabs/index.d.ts +5 -0
- package/dist/Tabs/index.js +4 -2
- package/dist/Tabs/style/index.less +6 -0
- package/dist/message/style/index.less +8 -7
- package/dist/style/mixins/index.less +4 -3
- package/dist/style/themes/default/scrollBar.less +3 -2
- package/package.json +10 -3
|
@@ -12,23 +12,13 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
12
12
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
|
|
15
|
-
import { useCallback, useEffect,
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
EScrollHorizontalDirection["SCROLL_TO_RIGHT"] = "toRight";
|
|
23
|
-
})(EScrollHorizontalDirection || (EScrollHorizontalDirection = {}));
|
|
24
|
-
|
|
25
|
-
export var EScrollVerticalDirection;
|
|
26
|
-
|
|
27
|
-
(function (EScrollVerticalDirection) {
|
|
28
|
-
EScrollVerticalDirection["SCROLL_TO_TOP"] = "toTop";
|
|
29
|
-
EScrollVerticalDirection["SCROLL_TO_BOTTOM"] = "toBottom";
|
|
30
|
-
})(EScrollVerticalDirection || (EScrollVerticalDirection = {}));
|
|
31
|
-
|
|
15
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { DEFAULT_COLUMN_WIDTH } from "../constant";
|
|
17
|
+
import { EScrollHorizontalDirection, EScrollVerticalDirection } from "../interface";
|
|
18
|
+
import getColumnOffsetsFromWidths from "../utils/getColumnOffsetsFromWidths";
|
|
19
|
+
import getColumnRange from "../utils/getColumnRange";
|
|
20
|
+
import getRowRange from "../utils/getRowRange";
|
|
21
|
+
import getTableLayout from "../utils/getTableLayout";
|
|
32
22
|
export default function useDirection(columns, wrapRef) {
|
|
33
23
|
var prevScrollData = useRef({
|
|
34
24
|
scrollTop: 0,
|
|
@@ -40,21 +30,27 @@ export default function useDirection(columns, wrapRef) {
|
|
|
40
30
|
}
|
|
41
31
|
});
|
|
42
32
|
|
|
43
|
-
var _useState = useState([]),
|
|
33
|
+
var _useState = useState([0, 0]),
|
|
44
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
columnRange = _useState2[0],
|
|
36
|
+
setColumnRange = _useState2[1];
|
|
47
37
|
|
|
48
38
|
var _useState3 = useState([0, 0]),
|
|
49
39
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
rowRange = _useState4[0],
|
|
41
|
+
setRowRange = _useState4[1];
|
|
52
42
|
|
|
53
|
-
var _useState5 = useState([
|
|
43
|
+
var _useState5 = useState([]),
|
|
54
44
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
tableColumns = _useState6[0],
|
|
46
|
+
setTableColumns = _useState6[1];
|
|
47
|
+
|
|
48
|
+
var _useState7 = useState(0),
|
|
49
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
50
|
+
contentWidth = _useState8[0],
|
|
51
|
+
setContentWidth = _useState8[1];
|
|
57
52
|
|
|
53
|
+
var columnWidthRef = useRef({});
|
|
58
54
|
var getScrollDirection = useCallback(function (currentScrollTop, currentScrollLeft) {
|
|
59
55
|
var _prevScrollData$curre = prevScrollData.current,
|
|
60
56
|
preScrollTop = _prevScrollData$curre.scrollTop,
|
|
@@ -112,136 +108,101 @@ export default function useDirection(columns, wrapRef) {
|
|
|
112
108
|
return prevScrollData.current.direction;
|
|
113
109
|
}
|
|
114
110
|
}, []);
|
|
115
|
-
var columnsOffsets = useMemo(function () {
|
|
116
|
-
var offset = 0;
|
|
117
|
-
return columnsWidth.map(function (width) {
|
|
118
|
-
var currentOffset = offset;
|
|
119
|
-
offset += width;
|
|
120
|
-
return currentOffset;
|
|
121
|
-
});
|
|
122
|
-
}, [columnsWidth]);
|
|
123
|
-
var setRange = useCallback(function (scrollTop, scrollLeft) {
|
|
124
|
-
var direction = getScrollDirection(scrollTop, scrollLeft);
|
|
125
|
-
var current = direction.current;
|
|
126
|
-
|
|
127
|
-
if (current === EScrollHorizontalDirection.SCROLL_TO_LEFT) {
|
|
128
|
-
var _wrapRef$current;
|
|
129
111
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
start = _prev[0],
|
|
135
|
-
end = _prev[1];
|
|
112
|
+
var _useState9 = useState([]),
|
|
113
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
114
|
+
columnsOffsets = _useState10[0],
|
|
115
|
+
setColumnsOffsets = _useState10[1];
|
|
136
116
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (firstIndex === start && lastIndex === end) {
|
|
141
|
-
return prev;
|
|
142
|
-
}
|
|
117
|
+
var setRange = useCallback(function (columnsOffsets) {
|
|
118
|
+
var _wrapRef$current, _wrapRef$current2, _wrapRef$current3, _wrapRef$current4;
|
|
143
119
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
setColumnRange(function (prev) {
|
|
155
|
-
var _prev2 = _slicedToArray(prev, 2),
|
|
156
|
-
start = _prev2[0],
|
|
157
|
-
end = _prev2[1];
|
|
158
|
-
|
|
159
|
-
var firstIndex = findFirstIndex(columnsOffsets, scrollLeft);
|
|
160
|
-
var lastIndex = findFirstIndex(columnsOffsets, scrollLeft + PRE_RENDER_RANGE + _wrapWidth);
|
|
161
|
-
|
|
162
|
-
if (firstIndex === start && lastIndex === end) {
|
|
163
|
-
return prev;
|
|
164
|
-
}
|
|
120
|
+
console.log(columnsOffsets, 'columnsOffsets');
|
|
121
|
+
var scrollTop = ((_wrapRef$current = wrapRef.current) === null || _wrapRef$current === void 0 ? void 0 : _wrapRef$current.scrollTop) || 0;
|
|
122
|
+
var scrollLeft = ((_wrapRef$current2 = wrapRef.current) === null || _wrapRef$current2 === void 0 ? void 0 : _wrapRef$current2.scrollLeft) || 0;
|
|
123
|
+
var direction = getScrollDirection(scrollTop, scrollLeft);
|
|
124
|
+
var columnRange = getColumnRange({
|
|
125
|
+
direction: direction.horizontal,
|
|
126
|
+
wrapWidth: ((_wrapRef$current3 = wrapRef.current) === null || _wrapRef$current3 === void 0 ? void 0 : _wrapRef$current3.clientWidth) || 0,
|
|
127
|
+
scrollLeft: scrollLeft,
|
|
128
|
+
columnsOffsets: columnsOffsets
|
|
129
|
+
});
|
|
165
130
|
|
|
166
|
-
|
|
167
|
-
|
|
131
|
+
if (columnRange) {
|
|
132
|
+
setColumnRange(columnRange);
|
|
168
133
|
}
|
|
169
134
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var firstIndex = Math.floor((scrollTop - PRE_RENDER_RANGE) / CELL_HEIGHT);
|
|
176
|
-
|
|
177
|
-
if (firstIndex < 0) {
|
|
178
|
-
firstIndex = 0;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var lastIndex = Math.ceil((scrollTop + wrapHeight) / CELL_HEIGHT) + 1;
|
|
182
|
-
setRowRange(function (prev) {
|
|
183
|
-
var _prev3 = _slicedToArray(prev, 2),
|
|
184
|
-
start = _prev3[0],
|
|
185
|
-
end = _prev3[1];
|
|
186
|
-
|
|
187
|
-
if (firstIndex === start && lastIndex === end) {
|
|
188
|
-
return prev;
|
|
189
|
-
}
|
|
135
|
+
var rowRange = getRowRange({
|
|
136
|
+
direction: direction.vertical,
|
|
137
|
+
wrapHeight: ((_wrapRef$current4 = wrapRef.current) === null || _wrapRef$current4 === void 0 ? void 0 : _wrapRef$current4.clientHeight) || 0,
|
|
138
|
+
scrollTop: scrollTop
|
|
139
|
+
});
|
|
190
140
|
|
|
191
|
-
|
|
192
|
-
|
|
141
|
+
if (rowRange) {
|
|
142
|
+
setRowRange(rowRange);
|
|
193
143
|
}
|
|
144
|
+
}, [getScrollDirection, wrapRef]);
|
|
194
145
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var _wrapHeight = ((_wrapRef$current4 = wrapRef.current) === null || _wrapRef$current4 === void 0 ? void 0 : _wrapRef$current4.clientHeight) || 0;
|
|
200
|
-
|
|
201
|
-
var _firstIndex = Math.floor(scrollTop / CELL_HEIGHT);
|
|
202
|
-
|
|
203
|
-
var _lastIndex = Math.ceil((scrollTop + _wrapHeight + PRE_RENDER_RANGE) / CELL_HEIGHT) + 1;
|
|
146
|
+
var _useState11 = useState({}),
|
|
147
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
148
|
+
columnLayout = _useState12[0],
|
|
149
|
+
setColumnLayout = _useState12[1];
|
|
204
150
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
151
|
+
var onScroll = function onScroll() {
|
|
152
|
+
console.log(111);
|
|
153
|
+
setRange(columnsOffsets);
|
|
154
|
+
};
|
|
209
155
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
if (columns.length > 0) {
|
|
158
|
+
// 存在有效的列
|
|
159
|
+
// 计算列宽
|
|
160
|
+
var columnWidths = columns.map(function (_ref) {
|
|
161
|
+
var defaultWidth = _ref.defaultWidth,
|
|
162
|
+
id = _ref.id;
|
|
163
|
+
var width = columnWidthRef.current[id] || defaultWidth || DEFAULT_COLUMN_WIDTH;
|
|
164
|
+
columnWidthRef.current[id] = width;
|
|
165
|
+
return width;
|
|
166
|
+
}); // 计算contentWidth
|
|
167
|
+
|
|
168
|
+
var _contentWidth = columnWidths.reduce(function (sum, width) {
|
|
169
|
+
return sum + width;
|
|
170
|
+
}, 0); // 计算columnsOffsets
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
var offsets = getColumnOffsetsFromWidths(columnWidths); // 计算columnLayout
|
|
174
|
+
|
|
175
|
+
var _columnLayout = getTableLayout(columns, columnWidths);
|
|
176
|
+
|
|
177
|
+
setContentWidth(_contentWidth);
|
|
178
|
+
setColumnsOffsets(offsets);
|
|
179
|
+
setColumnLayout(_columnLayout);
|
|
180
|
+
setRange(offsets);
|
|
181
|
+
setTableColumns(columns);
|
|
182
|
+
} else {
|
|
183
|
+
// 没有有效的列
|
|
184
|
+
setContentWidth(0);
|
|
185
|
+
setColumnsOffsets([]);
|
|
186
|
+
setColumnLayout({}); // setRange();
|
|
213
187
|
|
|
214
|
-
|
|
215
|
-
});
|
|
188
|
+
setTableColumns([]);
|
|
216
189
|
}
|
|
217
|
-
}, [
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
columnLayout[column.id] = {
|
|
224
|
-
width: columnWidth,
|
|
225
|
-
left: left
|
|
226
|
-
};
|
|
227
|
-
left += columnWidth;
|
|
190
|
+
}, [columns, setRange]);
|
|
191
|
+
var setColumnsWidth = useCallback(function (columnId, width) {
|
|
192
|
+
columnWidthRef.current[columnId] = width;
|
|
193
|
+
var columnWidths = columns.map(function (_ref2) {
|
|
194
|
+
var id = _ref2.id;
|
|
195
|
+
return columnWidthRef.current[id];
|
|
228
196
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
}, [columns, columnsWidth]);
|
|
240
|
-
useEffect(function () {
|
|
241
|
-
var _wrapRef$current5, _wrapRef$current6;
|
|
242
|
-
|
|
243
|
-
setRange(((_wrapRef$current5 = wrapRef.current) === null || _wrapRef$current5 === void 0 ? void 0 : _wrapRef$current5.scrollTop) || 0, ((_wrapRef$current6 = wrapRef.current) === null || _wrapRef$current6 === void 0 ? void 0 : _wrapRef$current6.scrollLeft) || 0); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
|
-
}, [columnLayout, wrapRef]);
|
|
197
|
+
var offsets = getColumnOffsetsFromWidths(columnWidths);
|
|
198
|
+
var columnLayout = getTableLayout(columns, columnWidths);
|
|
199
|
+
setContentWidth(columnWidths.reduce(function (sum, width) {
|
|
200
|
+
return sum + width;
|
|
201
|
+
}, 0));
|
|
202
|
+
setColumnsOffsets(offsets);
|
|
203
|
+
setColumnLayout(columnLayout);
|
|
204
|
+
setRange(offsets);
|
|
205
|
+
}, [columns, setRange]);
|
|
245
206
|
useEffect(function () {
|
|
246
207
|
var wrap = wrapRef.current;
|
|
247
208
|
var resizeObserver = new ResizeObserver(function (entries) {
|
|
@@ -253,9 +214,9 @@ export default function useDirection(columns, wrapRef) {
|
|
|
253
214
|
var entry = _step.value;
|
|
254
215
|
|
|
255
216
|
if (entry.contentRect) {
|
|
256
|
-
setRange(
|
|
217
|
+
setRange(columnsOffsets);
|
|
257
218
|
} else if (entry.contentBoxSize) {
|
|
258
|
-
setRange(
|
|
219
|
+
setRange(columnsOffsets);
|
|
259
220
|
}
|
|
260
221
|
}
|
|
261
222
|
} catch (err) {
|
|
@@ -269,13 +230,15 @@ export default function useDirection(columns, wrapRef) {
|
|
|
269
230
|
resizeObserver.unobserve(wrap);
|
|
270
231
|
resizeObserver.disconnect();
|
|
271
232
|
};
|
|
272
|
-
}, [wrapRef, setRange]);
|
|
233
|
+
}, [wrapRef, setRange, columnsOffsets]);
|
|
234
|
+
console.log(columnLayout, 'columnLayout,useDirection', columnRange);
|
|
273
235
|
return {
|
|
274
|
-
setRange: setRange,
|
|
275
236
|
columnRange: columnRange,
|
|
276
237
|
rowRange: rowRange,
|
|
277
238
|
setColumnsWidth: setColumnsWidth,
|
|
278
239
|
columnLayout: columnLayout,
|
|
279
|
-
|
|
240
|
+
contentWidth: contentWidth,
|
|
241
|
+
tableColumns: tableColumns,
|
|
242
|
+
onScroll: onScroll
|
|
280
243
|
};
|
|
281
244
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import { useWhyDidYouUpdate } from 'ahooks';
|
|
1
8
|
import classNames from 'classnames';
|
|
2
9
|
import React, { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
3
10
|
import Progress from "../Progress";
|
|
@@ -30,16 +37,19 @@ function DataPreviewTable(props, ref) {
|
|
|
30
37
|
var _useDirection = useDirection(columns, wrapRef),
|
|
31
38
|
columnRange = _useDirection.columnRange,
|
|
32
39
|
rowRange = _useDirection.rowRange,
|
|
33
|
-
|
|
34
|
-
setRange = _useDirection.setRange,
|
|
40
|
+
onScroll = _useDirection.onScroll,
|
|
35
41
|
columnLayout = _useDirection.columnLayout,
|
|
36
|
-
setColumnsWidth = _useDirection.setColumnsWidth
|
|
42
|
+
setColumnsWidth = _useDirection.setColumnsWidth,
|
|
43
|
+
contentWidth = _useDirection.contentWidth,
|
|
44
|
+
tableColumns = _useDirection.tableColumns;
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
useWhyDidYouUpdate('DataPreviewTable', _objectSpread({
|
|
47
|
+
columnRange: columnRange,
|
|
48
|
+
rowRange: rowRange,
|
|
49
|
+
onScroll: onScroll,
|
|
50
|
+
columnLayout: columnLayout,
|
|
51
|
+
setColumnsWidth: setColumnsWidth
|
|
52
|
+
}, props));
|
|
43
53
|
useEffect(function () {
|
|
44
54
|
if (ref) {
|
|
45
55
|
if (typeof ref === 'function') {
|
|
@@ -53,6 +63,7 @@ function DataPreviewTable(props, ref) {
|
|
|
53
63
|
var rows = Math.ceil((((_wrapRef$current = wrapRef.current) === null || _wrapRef$current === void 0 ? void 0 : _wrapRef$current.clientHeight) || 0 - HEADER_HEIGHT) / CELL_HEIGHT);
|
|
54
64
|
return rows - 1 < 0 ? 0 : rows - 1; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
65
|
}, [wrapRef.current]);
|
|
66
|
+
console.log(columnLayout, 'columnLayout');
|
|
56
67
|
return /*#__PURE__*/React.createElement(ScrollArea, {
|
|
57
68
|
ref: wrapRef,
|
|
58
69
|
style: {
|
|
@@ -60,11 +71,9 @@ function DataPreviewTable(props, ref) {
|
|
|
60
71
|
height: height,
|
|
61
72
|
willChange: 'transform'
|
|
62
73
|
},
|
|
63
|
-
onViewportScroll: function onViewportScroll(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
scrollLeft = _ref.scrollLeft;
|
|
67
|
-
setRange(scrollTop, scrollLeft);
|
|
74
|
+
onViewportScroll: function onViewportScroll() {
|
|
75
|
+
// const { scrollTop, scrollLeft } = e.target as HTMLDivElement;
|
|
76
|
+
onScroll();
|
|
68
77
|
},
|
|
69
78
|
className: classNames(props.className, 'ald-data-preview-table', {
|
|
70
79
|
'ald-data-preview-table-show-skeleton': dataStatus === 'pending'
|
|
@@ -79,18 +88,18 @@ function DataPreviewTable(props, ref) {
|
|
|
79
88
|
position: 'relative'
|
|
80
89
|
}
|
|
81
90
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
82
|
-
columns:
|
|
91
|
+
columns: tableColumns,
|
|
83
92
|
columnLayout: columnLayout,
|
|
84
93
|
setWidth: setColumnsWidth,
|
|
85
94
|
columnRange: columnRange
|
|
86
95
|
}), dataStatus === 'pending' && /*#__PURE__*/React.createElement(SkeletonBody, {
|
|
87
|
-
columns:
|
|
96
|
+
columns: tableColumns,
|
|
88
97
|
columnRange: columnRange,
|
|
89
98
|
columnLayout: columnLayout,
|
|
90
99
|
rowRange: rowRange,
|
|
91
100
|
rows: skeletonRows
|
|
92
101
|
}), dataStatus === 'success' && /*#__PURE__*/React.createElement(Body, {
|
|
93
|
-
columns:
|
|
102
|
+
columns: tableColumns,
|
|
94
103
|
columnRange: columnRange,
|
|
95
104
|
columnLayout: columnLayout,
|
|
96
105
|
datasource: datasource,
|
|
@@ -25,3 +25,21 @@ export interface IColumnLayout {
|
|
|
25
25
|
left: number;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
export interface IScrollData {
|
|
29
|
+
scrollLeft: number;
|
|
30
|
+
scrollTop: number;
|
|
31
|
+
direction: IScrollDirection;
|
|
32
|
+
}
|
|
33
|
+
export interface IScrollDirection {
|
|
34
|
+
horizontal: EScrollHorizontalDirection;
|
|
35
|
+
vertical: EScrollVerticalDirection;
|
|
36
|
+
current: EScrollHorizontalDirection | EScrollVerticalDirection | 'init';
|
|
37
|
+
}
|
|
38
|
+
export declare enum EScrollHorizontalDirection {
|
|
39
|
+
SCROLL_TO_LEFT = "toLeft",
|
|
40
|
+
SCROLL_TO_RIGHT = "toRight"
|
|
41
|
+
}
|
|
42
|
+
export declare enum EScrollVerticalDirection {
|
|
43
|
+
SCROLL_TO_TOP = "toTop",
|
|
44
|
+
SCROLL_TO_BOTTOM = "toBottom"
|
|
45
|
+
}
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var EScrollHorizontalDirection;
|
|
2
|
+
|
|
3
|
+
(function (EScrollHorizontalDirection) {
|
|
4
|
+
EScrollHorizontalDirection["SCROLL_TO_LEFT"] = "toLeft";
|
|
5
|
+
EScrollHorizontalDirection["SCROLL_TO_RIGHT"] = "toRight";
|
|
6
|
+
})(EScrollHorizontalDirection || (EScrollHorizontalDirection = {}));
|
|
7
|
+
|
|
8
|
+
export var EScrollVerticalDirection;
|
|
9
|
+
|
|
10
|
+
(function (EScrollVerticalDirection) {
|
|
11
|
+
EScrollVerticalDirection["SCROLL_TO_TOP"] = "toTop";
|
|
12
|
+
EScrollVerticalDirection["SCROLL_TO_BOTTOM"] = "toBottom";
|
|
13
|
+
})(EScrollVerticalDirection || (EScrollVerticalDirection = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (columnsWidth: number[]): number[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IScrollDirection } from '../interface';
|
|
2
|
+
declare const _default: ({ direction, wrapWidth, scrollLeft, columnsOffsets, }: {
|
|
3
|
+
direction: IScrollDirection['current'];
|
|
4
|
+
wrapWidth: number;
|
|
5
|
+
scrollLeft: number;
|
|
6
|
+
columnsOffsets: number[];
|
|
7
|
+
}) => [number, number] | undefined;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PRE_RENDER_RANGE } from "../constant";
|
|
2
|
+
import { EScrollHorizontalDirection } from "../interface";
|
|
3
|
+
import { findFirstIndex, findLastIndex } from "./findRange";
|
|
4
|
+
export default (function (_ref) {
|
|
5
|
+
var direction = _ref.direction,
|
|
6
|
+
wrapWidth = _ref.wrapWidth,
|
|
7
|
+
scrollLeft = _ref.scrollLeft,
|
|
8
|
+
columnsOffsets = _ref.columnsOffsets;
|
|
9
|
+
|
|
10
|
+
if (direction === EScrollHorizontalDirection.SCROLL_TO_LEFT) {
|
|
11
|
+
// 往左滚动
|
|
12
|
+
var firstIndex = findFirstIndex(columnsOffsets, scrollLeft - PRE_RENDER_RANGE);
|
|
13
|
+
var lastIndex = findLastIndex(columnsOffsets, scrollLeft + wrapWidth);
|
|
14
|
+
return [firstIndex, lastIndex];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (direction === EScrollHorizontalDirection.SCROLL_TO_RIGHT || direction === 'init') {
|
|
18
|
+
// 往右滚动
|
|
19
|
+
var _firstIndex = findFirstIndex(columnsOffsets, scrollLeft);
|
|
20
|
+
|
|
21
|
+
var _lastIndex = findLastIndex(columnsOffsets, scrollLeft + PRE_RENDER_RANGE + wrapWidth);
|
|
22
|
+
|
|
23
|
+
return [_firstIndex, _lastIndex];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CELL_HEIGHT, PRE_RENDER_RANGE } from "../constant";
|
|
2
|
+
import { EScrollVerticalDirection } from "../interface";
|
|
3
|
+
export default (function (_ref) {
|
|
4
|
+
var direction = _ref.direction,
|
|
5
|
+
wrapHeight = _ref.wrapHeight,
|
|
6
|
+
scrollTop = _ref.scrollTop;
|
|
7
|
+
|
|
8
|
+
if (direction === EScrollVerticalDirection.SCROLL_TO_TOP) {
|
|
9
|
+
// 往上滚动
|
|
10
|
+
var firstIndex = Math.floor((scrollTop - PRE_RENDER_RANGE) / CELL_HEIGHT);
|
|
11
|
+
|
|
12
|
+
if (firstIndex < 0) {
|
|
13
|
+
firstIndex = 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var lastIndex = Math.ceil((scrollTop + wrapHeight) / CELL_HEIGHT) + 1;
|
|
17
|
+
return [firstIndex, lastIndex];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (direction === EScrollVerticalDirection.SCROLL_TO_BOTTOM || direction === 'init') {
|
|
21
|
+
// 往下滚动
|
|
22
|
+
var _firstIndex = Math.floor(scrollTop / CELL_HEIGHT);
|
|
23
|
+
|
|
24
|
+
var _lastIndex = Math.ceil((scrollTop + wrapHeight + PRE_RENDER_RANGE) / CELL_HEIGHT) + 1;
|
|
25
|
+
|
|
26
|
+
return [_firstIndex, _lastIndex];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DEFAULT_COLUMN_WIDTH } from "../constant";
|
|
2
|
+
export default (function (tableColumns, columnsWidth) {
|
|
3
|
+
if (columnsWidth.length !== tableColumns.length) {
|
|
4
|
+
throw new Error('columnsWidth.length !== tableColumns.length');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var columnLayout = {};
|
|
8
|
+
var left = 0;
|
|
9
|
+
tableColumns.forEach(function (column, index) {
|
|
10
|
+
var columnWidth = columnsWidth[index] || column.defaultWidth || DEFAULT_COLUMN_WIDTH;
|
|
11
|
+
columnLayout[column.id] = {
|
|
12
|
+
width: columnWidth,
|
|
13
|
+
left: left
|
|
14
|
+
};
|
|
15
|
+
left += columnWidth;
|
|
16
|
+
});
|
|
17
|
+
return columnLayout;
|
|
18
|
+
});
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import { DatePickerProps } from 'antd';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const _default: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<import("antd/es/date-picker/generatePicker").PickerProps<import("dayjs").Dayjs> & {
|
|
1
|
+
import { DatePicker as AntdDatePicker, DatePickerProps as AntdDatePickerProps } from 'antd';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
declare const DatePicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<import("antd/es/date-picker/generatePicker").PickerProps<Dayjs> & {
|
|
5
4
|
status?: "" | "warning" | "error" | undefined;
|
|
6
5
|
hashId?: string | undefined;
|
|
7
6
|
popupClassName?: string | undefined;
|
|
8
7
|
rootClassName?: string | undefined;
|
|
9
8
|
}, unknown> & {
|
|
10
|
-
WeekPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<
|
|
9
|
+
WeekPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<Dayjs> & {
|
|
11
10
|
status?: "" | "warning" | "error" | undefined;
|
|
12
11
|
hashId?: string | undefined;
|
|
13
12
|
popupClassName?: string | undefined;
|
|
14
13
|
rootClassName?: string | undefined;
|
|
15
14
|
}, "picker">, unknown>;
|
|
16
|
-
MonthPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<
|
|
15
|
+
MonthPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<Dayjs> & {
|
|
17
16
|
status?: "" | "warning" | "error" | undefined;
|
|
18
17
|
hashId?: string | undefined;
|
|
19
18
|
popupClassName?: string | undefined;
|
|
20
19
|
rootClassName?: string | undefined;
|
|
21
20
|
}, "picker">, unknown>;
|
|
22
|
-
YearPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<
|
|
21
|
+
YearPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<import("antd/es/date-picker/generatePicker").PickerProps<Dayjs> & {
|
|
23
22
|
status?: "" | "warning" | "error" | undefined;
|
|
24
23
|
hashId?: string | undefined;
|
|
25
24
|
popupClassName?: string | undefined;
|
|
26
25
|
rootClassName?: string | undefined;
|
|
27
26
|
}, "picker">, unknown>;
|
|
28
|
-
RangePicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<import("antd/es/date-picker/generatePicker").RangePickerProps<
|
|
27
|
+
RangePicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<import("antd/es/date-picker/generatePicker").RangePickerProps<Dayjs> & {
|
|
29
28
|
dropdownClassName?: string | undefined;
|
|
30
29
|
popupClassName?: string | undefined;
|
|
31
30
|
}, unknown>;
|
|
32
|
-
TimePicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<Omit<import("rc-picker/lib/Picker").PickerTimeProps<
|
|
31
|
+
TimePicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<Omit<import("rc-picker/lib/Picker").PickerTimeProps<Dayjs>, "locale" | "generateConfig" | "hideHeader" | "components"> & {
|
|
33
32
|
locale?: import("antd/es/date-picker/generatePicker").PickerLocale | undefined;
|
|
34
33
|
size?: import("antd/es/button").ButtonSize;
|
|
35
34
|
placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight" | undefined;
|
|
@@ -41,7 +40,7 @@ declare const _default: import("antd/es/date-picker/generatePicker/interface").P
|
|
|
41
40
|
popupClassName?: string | undefined;
|
|
42
41
|
rootClassName?: string | undefined;
|
|
43
42
|
}, "picker">, unknown>;
|
|
44
|
-
QuarterPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<Omit<import("rc-picker/lib/Picker").PickerTimeProps<
|
|
43
|
+
QuarterPicker: import("antd/es/date-picker/generatePicker/interface").PickerComponentClass<Omit<Omit<import("rc-picker/lib/Picker").PickerTimeProps<Dayjs>, "locale" | "generateConfig" | "hideHeader" | "components"> & {
|
|
45
44
|
locale?: import("antd/es/date-picker/generatePicker").PickerLocale | undefined;
|
|
46
45
|
size?: import("antd/es/button").ButtonSize;
|
|
47
46
|
placement?: "bottomLeft" | "bottomRight" | "topLeft" | "topRight" | undefined;
|
|
@@ -56,5 +55,15 @@ declare const _default: import("antd/es/date-picker/generatePicker/interface").P
|
|
|
56
55
|
} & {
|
|
57
56
|
_InternalPanelDoNotUseOrYouWillBeFired: any;
|
|
58
57
|
_InternalRangePanelDoNotUseOrYouWillBeFired: any;
|
|
58
|
+
} & {
|
|
59
|
+
WeekPicker: typeof AntdDatePicker.WeekPicker;
|
|
60
|
+
MonthPicker: typeof AntdDatePicker.MonthPicker;
|
|
61
|
+
YearPicker: typeof AntdDatePicker.YearPicker;
|
|
62
|
+
RangePicker: typeof AntdDatePicker.RangePicker;
|
|
63
|
+
TimePicker: typeof AntdDatePicker.TimePicker;
|
|
64
|
+
QuarterPicker: typeof AntdDatePicker.QuarterPicker;
|
|
59
65
|
};
|
|
60
|
-
export
|
|
66
|
+
export declare type DatePickerProps = AntdDatePickerProps;
|
|
67
|
+
export declare type YearPickerProps = typeof AntdDatePicker.YearPicker;
|
|
68
|
+
export declare type QuarterPickerProps = typeof AntdDatePicker.QuarterPicker;
|
|
69
|
+
export default DatePicker;
|