@sheinx/hooks 3.9.0-beta.3 → 3.9.0-beta.31
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/cjs/common/use-filter/use-filter.type.d.ts +1 -1
- package/cjs/common/use-filter/use-filter.type.d.ts.map +1 -1
- package/cjs/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/cjs/common/use-input-able/use-Input-able.js +6 -7
- package/cjs/components/use-button/use-button.d.ts +2 -2
- package/cjs/components/use-carousel/use-carousel.d.ts +12 -0
- package/cjs/components/use-carousel/use-carousel.d.ts.map +1 -1
- package/cjs/components/use-carousel/use-carousel.js +67 -17
- package/cjs/components/use-datepicker/use-date.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-date.js +7 -7
- package/cjs/components/use-datepicker/use-date.type.d.ts +2 -1
- package/cjs/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts +2 -2
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.js +7 -16
- package/cjs/components/use-datepicker/use-month.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-month.js +5 -5
- package/cjs/components/use-datepicker/use-month.type.d.ts +2 -1
- package/cjs/components/use-datepicker/use-month.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-quarter.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-quarter.js +5 -5
- package/cjs/components/use-datepicker/use-year.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-year.js +5 -5
- package/cjs/components/use-datepicker/use-year.type.d.ts +2 -1
- package/cjs/components/use-datepicker/use-year.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.type.d.ts +1 -1
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-format.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.d.ts +1 -1
- package/cjs/components/use-table/use-table-columns.d.ts +8 -1
- package/cjs/components/use-table/use-table-columns.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-columns.js +90 -1
- package/cjs/components/use-table/use-table-filter.d.ts +2 -2
- package/cjs/components/use-table/use-table-filter.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-filter.js +11 -5
- package/cjs/components/use-table/use-table-layout.js +1 -1
- package/cjs/components/use-table/use-table-virtual.d.ts +2 -0
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +44 -10
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +3 -0
- package/cjs/utils/dom/get-dataset.d.ts +4 -0
- package/cjs/utils/dom/get-dataset.d.ts.map +1 -0
- package/cjs/utils/dom/get-dataset.js +18 -0
- package/cjs/utils/dom/index.d.ts +1 -0
- package/cjs/utils/dom/index.d.ts.map +1 -1
- package/cjs/utils/dom/index.js +12 -0
- package/cjs/utils/rule/regexp.d.ts +1 -1
- package/cjs/utils/rule/required.d.ts.map +1 -1
- package/cjs/utils/rule/required.js +3 -1
- package/cjs/utils/validate/get-rule.js +1 -1
- package/esm/common/use-filter/use-filter.type.d.ts +1 -1
- package/esm/common/use-filter/use-filter.type.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.js +7 -8
- package/esm/components/use-button/use-button.d.ts +2 -2
- package/esm/components/use-carousel/use-carousel.d.ts +12 -0
- package/esm/components/use-carousel/use-carousel.d.ts.map +1 -1
- package/esm/components/use-carousel/use-carousel.js +67 -17
- package/esm/components/use-datepicker/use-date.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-date.js +7 -7
- package/esm/components/use-datepicker/use-date.type.d.ts +2 -1
- package/esm/components/use-datepicker/use-date.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.d.ts +2 -2
- package/esm/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.js +7 -16
- package/esm/components/use-datepicker/use-month.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-month.js +5 -5
- package/esm/components/use-datepicker/use-month.type.d.ts +2 -1
- package/esm/components/use-datepicker/use-month.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-quarter.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-quarter.js +5 -5
- package/esm/components/use-datepicker/use-year.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-year.js +5 -5
- package/esm/components/use-datepicker/use-year.type.d.ts +2 -1
- package/esm/components/use-datepicker/use-year.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form.type.d.ts +1 -1
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-format.d.ts +1 -1
- package/esm/components/use-input/use-input-number.d.ts +1 -1
- package/esm/components/use-table/use-table-columns.d.ts +8 -1
- package/esm/components/use-table/use-table-columns.d.ts.map +1 -1
- package/esm/components/use-table/use-table-columns.js +91 -2
- package/esm/components/use-table/use-table-filter.d.ts +2 -2
- package/esm/components/use-table/use-table-filter.d.ts.map +1 -1
- package/esm/components/use-table/use-table-filter.js +11 -5
- package/esm/components/use-table/use-table-layout.js +1 -1
- package/esm/components/use-table/use-table-virtual.d.ts +2 -0
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +44 -10
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +3 -0
- package/esm/utils/dom/get-dataset.d.ts +4 -0
- package/esm/utils/dom/get-dataset.d.ts.map +1 -0
- package/esm/utils/dom/get-dataset.js +12 -0
- package/esm/utils/dom/index.d.ts +1 -0
- package/esm/utils/dom/index.d.ts.map +1 -1
- package/esm/utils/dom/index.js +1 -0
- package/esm/utils/rule/regexp.d.ts +1 -1
- package/esm/utils/rule/required.d.ts.map +1 -1
- package/esm/utils/rule/required.js +3 -1
- package/esm/utils/validate/get-rule.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableColumnItem, BaseTableProps } from './use-table.type';
|
|
3
3
|
import { KeygenResult } from '../../common/type';
|
|
4
|
-
export interface UseTableFilterProps<Item = any> extends Pick<BaseTableProps<Item>, 'onSortCancel' | 'sorter' | 'data'> {
|
|
4
|
+
export interface UseTableFilterProps<Item = any> extends Pick<BaseTableProps<Item>, 'onSortCancel' | 'sorter' | 'data' | 'keygen'> {
|
|
5
5
|
columns?: TableColumnItem<Item>[];
|
|
6
6
|
}
|
|
7
7
|
export interface FilterInfo<T> {
|
|
@@ -12,7 +12,7 @@ export type FilterMap<T> = Map<KeygenResult, FilterInfo<T>>;
|
|
|
12
12
|
declare const useTableFilter: <Item = any>(props: UseTableFilterProps<Item>) => {
|
|
13
13
|
filterInfo: FilterMap<Item>;
|
|
14
14
|
setFilterInfo: import("react").Dispatch<import("react").SetStateAction<FilterMap<Item>>>;
|
|
15
|
-
filteredData: Item[]
|
|
15
|
+
filteredData: Item[];
|
|
16
16
|
onFilterChange: (columnKey: KeygenResult, value: any) => void;
|
|
17
17
|
};
|
|
18
18
|
export default useTableFilter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-filter.d.ts","sourceRoot":"","sources":["use-table-filter.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-table-filter.d.ts","sourceRoot":"","sources":["use-table-filter.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,mBAAmB,CAAC,IAAI,GAAG,GAAG,CAC7C,SAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IACjF,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;CACnC;AACD,MAAM,WAAW,UAAU,CAAC,CAAC;IAE3B,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAC5C;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5D,QAAA,MAAM,cAAc;;;;gCA+BH,YAAY,SAAS,GAAG;CAyDxC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -13,6 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import { useState, useMemo, useEffect } from 'react';
|
|
14
14
|
import usePersistFn from "../../common/use-persist-fn";
|
|
15
15
|
import { isFunc } from "../../utils/is";
|
|
16
|
+
import { getFilterTree, getKey } from "../../utils";
|
|
16
17
|
var useTableFilter = function useTableFilter(props) {
|
|
17
18
|
var _useState = useState(new Map()),
|
|
18
19
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -25,10 +26,13 @@ var useTableFilter = function useTableFilter(props) {
|
|
|
25
26
|
});
|
|
26
27
|
}, [filterInfo]);
|
|
27
28
|
var filteredData = useMemo(function () {
|
|
28
|
-
var _props$
|
|
29
|
+
var _props$columns;
|
|
29
30
|
// why use slice: props.data引用不改变会导致后续的useMemo无法重新计算
|
|
30
31
|
if (activeFilters.length === 0) return (props.data || []).slice();
|
|
31
|
-
|
|
32
|
+
var columnHasChildren = (_props$columns = props.columns) === null || _props$columns === void 0 ? void 0 : _props$columns.find(function (col) {
|
|
33
|
+
return col.treeColumnsName;
|
|
34
|
+
});
|
|
35
|
+
return getFilterTree(props.data, function (item) {
|
|
32
36
|
return activeFilters.every(function (key) {
|
|
33
37
|
var filter = filterInfo.get(key);
|
|
34
38
|
if ((filter === null || filter === void 0 ? void 0 : filter.value) === undefined) return true;
|
|
@@ -38,7 +42,9 @@ var useTableFilter = function useTableFilter(props) {
|
|
|
38
42
|
}
|
|
39
43
|
return true;
|
|
40
44
|
});
|
|
41
|
-
})
|
|
45
|
+
}, undefined, function (node) {
|
|
46
|
+
return getKey(props.keygen, node);
|
|
47
|
+
}, columnHasChildren === null || columnHasChildren === void 0 ? void 0 : columnHasChildren.treeColumnsName, false);
|
|
42
48
|
}, [activeFilters, props.data]);
|
|
43
49
|
var onFilterChange = usePersistFn(function (columnKey, value) {
|
|
44
50
|
// TODO: 暂未开放reset全部筛选条件
|
|
@@ -68,8 +74,8 @@ var useTableFilter = function useTableFilter(props) {
|
|
|
68
74
|
// 根据columns生成filterInfo
|
|
69
75
|
useEffect(function () {
|
|
70
76
|
setFilterInfo(function (prev) {
|
|
71
|
-
var _props$
|
|
72
|
-
var _filterInfo = props === null || props === void 0 || (_props$
|
|
77
|
+
var _props$columns2;
|
|
78
|
+
var _filterInfo = props === null || props === void 0 || (_props$columns2 = props.columns) === null || _props$columns2 === void 0 ? void 0 : _props$columns2.reduce(function (acc, column, index) {
|
|
73
79
|
var _prev$get2, _column$filter;
|
|
74
80
|
if (!column.filter) return acc;
|
|
75
81
|
var columnKey = typeof column.render === 'string' ? column.render : String(index);
|
|
@@ -289,7 +289,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
|
289
289
|
});
|
|
290
290
|
var checkFloat = usePersistFn(function () {
|
|
291
291
|
var scrollEl = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current;
|
|
292
|
-
if (!scrollEl) return;
|
|
292
|
+
if (!scrollEl || !(scrollEl !== null && scrollEl !== void 0 && scrollEl.offsetParent)) return;
|
|
293
293
|
var max = scrollEl.scrollWidth - scrollEl.clientWidth;
|
|
294
294
|
var min = 0;
|
|
295
295
|
var left = scrollEl.scrollLeft;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableFormatColumn } from './use-table.type';
|
|
3
3
|
interface UseTableVirtualProps {
|
|
4
|
+
virtual?: boolean | 'lazy';
|
|
4
5
|
data: any[];
|
|
5
6
|
rowsInView: number;
|
|
6
7
|
rowHeight: number;
|
|
8
|
+
strictRowHeight?: number;
|
|
7
9
|
scrollRef: React.RefObject<HTMLDivElement>;
|
|
8
10
|
innerRef: React.RefObject<HTMLDivElement>;
|
|
9
11
|
scrollLeft?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;
|
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAWrD,UAAU,oBAAoB;IAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;oBAoNpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BArHuB,MAAM,UAAU,MAAM;2BAwJrB,MAAM,aAAa,MAAM,IAAI;qCAoBnB,MAAM;mCAUR,MAAM,GAAG,MAAM;;;;;CA4GnE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -29,11 +29,14 @@ function getMaxRowSpanLength(input) {
|
|
|
29
29
|
return Math.max.apply(Math, _toConsumableArray(Array.from(map.values())));
|
|
30
30
|
}
|
|
31
31
|
var useTableVirtual = function useTableVirtual(props) {
|
|
32
|
+
var _props$scrollRef$curr;
|
|
32
33
|
var _useState = useState(0),
|
|
33
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
35
|
innerTop = _useState2[0],
|
|
35
36
|
setTop = _useState2[1];
|
|
36
|
-
var
|
|
37
|
+
var strictRowHeight = props.strictRowHeight ? props.strictRowHeight : 0;
|
|
38
|
+
var defaultScrollHeight = strictRowHeight ? props.data.length * strictRowHeight : props.data.length * props.rowHeight;
|
|
39
|
+
var _useState3 = useState(defaultScrollHeight),
|
|
37
40
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
41
|
scrollHeight = _useState4[0],
|
|
39
42
|
setHeight = _useState4[1];
|
|
@@ -45,6 +48,15 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
45
48
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
46
49
|
offsetY = _useState8[0],
|
|
47
50
|
setOffsetY = _useState8[1];
|
|
51
|
+
|
|
52
|
+
// TODO: 尝试垂直滚动采用延迟销毁 + 操作dom transform方案提升性能?
|
|
53
|
+
// const setTop = (v: number) => {
|
|
54
|
+
// if (props.virtual === 'lazy') {
|
|
55
|
+
// props.innerRef.current && (props.innerRef.current.style.transform = `translate3d(0, ${-v}px, 0)`);
|
|
56
|
+
// } else {
|
|
57
|
+
// }
|
|
58
|
+
// _setTop(v);
|
|
59
|
+
// }
|
|
48
60
|
var rowsInView = props.rowsInView === 0 ? props.data.length : props.rowsInView;
|
|
49
61
|
var rowSpanInfo = useMemo(function () {
|
|
50
62
|
var rowSpanColumns = props.columns.filter(function (col) {
|
|
@@ -119,6 +131,9 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
119
131
|
context = _useRef.current;
|
|
120
132
|
var getContentHeight = function getContentHeight(index) {
|
|
121
133
|
if (props.disabled) return 0;
|
|
134
|
+
if (strictRowHeight) {
|
|
135
|
+
return strictRowHeight * (index + 1) + props.theadHeight + props.tfootHeight;
|
|
136
|
+
}
|
|
122
137
|
var sum = 0;
|
|
123
138
|
for (var i = 0; i <= index; i++) {
|
|
124
139
|
sum += context.cachedHeight[i] || props.rowHeight;
|
|
@@ -144,17 +159,26 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
144
159
|
});
|
|
145
160
|
}
|
|
146
161
|
});
|
|
162
|
+
|
|
163
|
+
// const setStartIndex2 = (index:number) => {
|
|
164
|
+
// let sum = 0;
|
|
165
|
+
// for (let i = 0; i < index; i++) {
|
|
166
|
+
// sum += context.cachedHeight[i] || props.rowHeight;
|
|
167
|
+
// }
|
|
168
|
+
// props.innerRef.current && (props.innerRef.current.style.transform = `translate3d(0, ${-innerTop + sum}px, 0)`);
|
|
169
|
+
// setStartIndex(index);
|
|
170
|
+
// }
|
|
171
|
+
|
|
172
|
+
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
|
173
|
+
var scrollContainerHeight = Math.max(((_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.clientHeight) || 0, 200);
|
|
147
174
|
var updateIndexAndTopFromTop = function updateIndexAndTopFromTop(scrollTop, fromDrag) {
|
|
148
|
-
var _props$scrollRef$curr;
|
|
149
175
|
if (props.disabled) return;
|
|
150
176
|
var sum = 0;
|
|
151
177
|
var currentIndex = 0;
|
|
152
178
|
var top = 0;
|
|
153
|
-
var maxIndex = Math.max(props.data.length - rowsInView, 0);
|
|
154
|
-
var scrollContainerHeight = Math.max(((_props$scrollRef$curr = props.scrollRef.current) === null || _props$scrollRef$curr === void 0 ? void 0 : _props$scrollRef$curr.clientHeight) || 0, 200);
|
|
155
179
|
for (var i = 0; i <= maxIndex; i++) {
|
|
156
180
|
context.rowSpanRows = 0;
|
|
157
|
-
var currentRowHeight = context.cachedHeight[i] || props.rowHeight;
|
|
181
|
+
var currentRowHeight = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
|
|
158
182
|
sum += currentRowHeight;
|
|
159
183
|
var rowSpanHeight = 0;
|
|
160
184
|
if (rowSpanInfo) {
|
|
@@ -169,17 +193,26 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
169
193
|
if (rowSpanHeight < scrollContainerHeight) {
|
|
170
194
|
var index = siblingsIndexs[j];
|
|
171
195
|
context.rowSpanRows += 1;
|
|
172
|
-
rowSpanHeight += context.cachedHeight[index] || props.rowHeight;
|
|
196
|
+
rowSpanHeight += strictRowHeight || context.cachedHeight[index] || props.rowHeight;
|
|
173
197
|
}
|
|
174
198
|
}
|
|
175
199
|
}
|
|
176
200
|
if (scrollTop < sum + rowSpanHeight || i === maxIndex) {
|
|
177
201
|
currentIndex = i;
|
|
178
|
-
var beforeHeight = i === 0 ? 0 : sum - (context.cachedHeight[i] || props.rowHeight);
|
|
202
|
+
var beforeHeight = i === 0 ? 0 : sum - (strictRowHeight || context.cachedHeight[i] || props.rowHeight);
|
|
179
203
|
top = scrollTop - beforeHeight;
|
|
180
204
|
break;
|
|
181
205
|
}
|
|
182
206
|
}
|
|
207
|
+
// if (props.virtual === 'lazy') {
|
|
208
|
+
// setTop(scrollTop);
|
|
209
|
+
// context.autoAddRows = currentIndex
|
|
210
|
+
// setTimeout(() => {
|
|
211
|
+
// setStartIndex2(currentIndex);
|
|
212
|
+
// context.autoAddRows = 0
|
|
213
|
+
// }, 300);
|
|
214
|
+
// return;
|
|
215
|
+
// }
|
|
183
216
|
if (currentIndex !== startIndex) {
|
|
184
217
|
setStartIndex(currentIndex);
|
|
185
218
|
|
|
@@ -308,16 +341,16 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
308
341
|
var addonHeight = 0;
|
|
309
342
|
var addonCount = 0;
|
|
310
343
|
for (var i = startIndex + rowsInView; i < props.data.length; i++) {
|
|
311
|
-
var height = context.cachedHeight[i] || props.rowHeight;
|
|
344
|
+
var height = strictRowHeight || context.cachedHeight[i] || props.rowHeight;
|
|
312
345
|
addonHeight += height;
|
|
313
346
|
addonCount += 1;
|
|
314
|
-
if (addonHeight >= remainHeight + context.cachedHeight[0]) break;
|
|
347
|
+
if (addonHeight >= remainHeight + (strictRowHeight || context.cachedHeight[0])) break;
|
|
315
348
|
}
|
|
316
349
|
if (addonCount > 0) {
|
|
317
350
|
context.autoAddRows = addonCount;
|
|
318
351
|
}
|
|
319
352
|
}
|
|
320
|
-
}, []);
|
|
353
|
+
}, [props.data.length]);
|
|
321
354
|
useEffect(function () {
|
|
322
355
|
// 记录preIndex
|
|
323
356
|
context.preIndex = startIndex;
|
|
@@ -360,6 +393,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
|
360
393
|
return _toConsumableArray(props.data).slice(startIndex, startIndex + finalRowsInView);
|
|
361
394
|
}, [props.data, props.disabled, startIndex, finalRowsInView]);
|
|
362
395
|
var translateStyle = useMemo(function () {
|
|
396
|
+
// if (props.virtual === 'lazy') return 'translate3d(0, 0, 0)';
|
|
363
397
|
var t = innerTop + offsetY;
|
|
364
398
|
if (t < 0) {
|
|
365
399
|
t = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;gBA+Cb,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,kBAmBxF;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,WAW3C;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAqBzF;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,EACrC,SAAS,GAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,EAA0B,sBAuBrE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,mBAAmB,EAAE,KAAK,EAAE,MAAM,WAYxE;AAED,eAAO,MAAM,eAAe,QAAS,MAAM,WAAwC,CAAC;AAEpF,eAAO,MAAM,UAAU,UAAW,MAAM,aAAa,MAAM,uBAG1D,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,MAAM,aAAa,MAAM,WAG9D,CAAC"}
|
package/esm/utils/dom/element.js
CHANGED
|
@@ -61,6 +61,9 @@ export var addResizeObserver = function addResizeObserver(el, handler) {
|
|
|
61
61
|
lastWidth = el.clientWidth;
|
|
62
62
|
lastHeight = el.clientHeight;
|
|
63
63
|
h = function h(entry) {
|
|
64
|
+
if ((el === null || el === void 0 ? void 0 : el.offsetParent) === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
64
67
|
var _entry$0$contentRect = entry[0].contentRect,
|
|
65
68
|
width = _entry$0$contentRect.width,
|
|
66
69
|
height = _entry$0$contentRect.height;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dataset.d.ts","sourceRoot":"","sources":["get-dataset.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;CAWtB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var getDataset = function getDataset(props) {
|
|
2
|
+
if (!props) return {};
|
|
3
|
+
var dataset = {};
|
|
4
|
+
var keys = Object.keys(props);
|
|
5
|
+
for (var i = 0; i < keys.length; i++) {
|
|
6
|
+
var _key = keys[i];
|
|
7
|
+
if (_key.startsWith('data-')) {
|
|
8
|
+
dataset[_key] = props[keys[i]];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return dataset;
|
|
12
|
+
};
|
package/esm/utils/dom/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { OldWheelEvent } from './normalize-wheel.type';
|
|
|
4
4
|
export * from './ready';
|
|
5
5
|
export * from './element';
|
|
6
6
|
export * from './document';
|
|
7
|
+
export * from './get-dataset';
|
|
7
8
|
export { default as ResponsiveObserve } from './responsiveObserve';
|
|
8
9
|
export type { Breakpoint, ScreenMap } from './responsiveObserve.type';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
|
package/esm/utils/dom/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageType } from './rule.type';
|
|
2
2
|
declare const _default: ({ message }?: {
|
|
3
3
|
message?: MessageType | undefined;
|
|
4
|
-
}) => (regExp: string | RegExp, msg?: MessageType) => import("
|
|
4
|
+
}) => (regExp: string | RegExp, msg?: MessageType) => import("@sheinx/base").ObjectType | null;
|
|
5
5
|
export default _default;
|
|
6
6
|
//# sourceMappingURL=regexp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required.d.ts","sourceRoot":"","sources":["required.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"required.d.ts","sourceRoot":"","sources":["required.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,eAAO,MAAM,eAAe,UAAW,UAAU,WAGhD,CAAC;;;YAEM,WAAW;AADnB,wBASM"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { getLocale, config } from '@sheinx/base';
|
|
1
2
|
import { deepMerge } from "../object";
|
|
3
|
+
import { substitute } from "../string";
|
|
2
4
|
var options = {
|
|
3
5
|
skipUndefined: true
|
|
4
6
|
};
|
|
5
7
|
export var requiredMessage = function requiredMessage(props) {
|
|
6
8
|
var type = props.type === 'array' ? 'array' : 'string';
|
|
7
|
-
return "
|
|
9
|
+
return substitute(getLocale(config.locale, "rules.required.".concat(type)), props);
|
|
8
10
|
};
|
|
9
11
|
export default (function () {
|
|
10
12
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/hooks",
|
|
3
|
-
"version": "3.9.0-beta.
|
|
3
|
+
"version": "3.9.0-beta.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"date-fns": "2.30.0",
|
|
15
15
|
"dayjs": "^1.11.9",
|
|
16
16
|
"react-fast-compare": "^3.2.2",
|
|
17
|
-
"@shined/reactive": "^0.
|
|
17
|
+
"@shined/reactive": "^0.3.3",
|
|
18
18
|
"immer": "10.0.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|