@sheinx/hooks 3.2.5-beta.1 → 3.2.5
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-position-style/index.js +1 -1
- package/cjs/components/use-button/use-button.d.ts +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/cjs/components/use-image/use-image.d.ts +1 -1
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +3 -14
- package/esm/common/use-position-style/index.js +1 -1
- package/esm/components/use-button/use-button.d.ts +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/esm/components/use-image/use-image.d.ts +1 -1
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +3 -14
- package/package.json +1 -1
@@ -258,7 +258,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
258
258
|
setStyle(newStyle);
|
259
259
|
}
|
260
260
|
});
|
261
|
-
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey]);
|
261
|
+
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth]);
|
262
262
|
return style;
|
263
263
|
};
|
264
264
|
var _default = exports.default = usePositionStyle;
|
@@ -28,7 +28,7 @@ declare const useButton: (props?: BaseButtonProps) => {
|
|
28
28
|
buttonRef?: React.Ref<HTMLButtonElement> | undefined;
|
29
29
|
} & TOther_1 & {
|
30
30
|
disabled: boolean | undefined;
|
31
|
-
htmlType: "button" | "
|
31
|
+
htmlType: "button" | "reset" | "submit" | undefined;
|
32
32
|
onClick: (event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>) => void;
|
33
33
|
};
|
34
34
|
getSpaceChildren: (children: React.ReactNode, space?: boolean, className?: string) => React.ReactNode;
|
@@ -4,7 +4,7 @@ declare const useDatePickerFormat: <Value extends DatePickerValueType>(props: Us
|
|
4
4
|
resultArr: (string | undefined)[];
|
5
5
|
targetResultArr: (string | undefined)[];
|
6
6
|
dateArr: (Date | undefined)[];
|
7
|
-
disabledStatus: "
|
7
|
+
disabledStatus: "all" | "left" | "right" | undefined;
|
8
8
|
currentArr: Date[];
|
9
9
|
mode: DatePickerModeType[];
|
10
10
|
isEmpty: boolean;
|
@@ -10,7 +10,7 @@ declare const useImage: (props?: BaseImageProps) => {
|
|
10
10
|
getRootProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => {
|
11
11
|
[x: string]: (event: any) => void;
|
12
12
|
} & TOther & {
|
13
|
-
ref: React.RefObject<
|
13
|
+
ref: React.RefObject<HTMLDivElement | HTMLAnchorElement>;
|
14
14
|
onClick: (event: React.MouseEvent<HTMLImageElement | HTMLDivElement>) => void;
|
15
15
|
};
|
16
16
|
getImageProps: <TOther_1 extends ObjectType = ObjectType>(externalProps?: TOther_1) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAIA,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;CACjB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBA6GpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BApEuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAgInB,MAAM;CAwDlD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
var _usePrevious = require("../.../../../common/use-previous");
|
7
8
|
var _usePersistFn = require("../../common/use-persist-fn");
|
8
9
|
var _react = require("react");
|
9
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
@@ -33,6 +34,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
33
34
|
_useState8 = _slicedToArray(_useState7, 2),
|
34
35
|
startIndex = _useState8[0],
|
35
36
|
setStartIndex = _useState8[1];
|
37
|
+
var preIndex = (0, _usePrevious.usePrevious)(startIndex);
|
36
38
|
var _useState9 = (0, _react.useState)(0),
|
37
39
|
_useState10 = _slicedToArray(_useState9, 2),
|
38
40
|
offsetY = _useState10[0],
|
@@ -45,8 +47,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
45
47
|
rateTimer: null,
|
46
48
|
topTimer: null,
|
47
49
|
controlScrollRate: null,
|
48
|
-
heightCallback: null
|
49
|
-
preIndex: null
|
50
|
+
heightCallback: null
|
50
51
|
}),
|
51
52
|
context = _useRef.current;
|
52
53
|
var getTranslate = (0, _usePersistFn.usePersistFn)(function (left, top) {
|
@@ -79,8 +80,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
79
80
|
if (context.shouldUpdateHeight) {
|
80
81
|
setHeight(getContentHeight(props.data.length - 1));
|
81
82
|
}
|
82
|
-
var preIndex = context.preIndex;
|
83
|
-
// 解决: 从下往上滚 由于高度变化会导致滚动条跳动
|
84
83
|
if (preIndex && preIndex > startIndex && startIndex === index) {
|
85
84
|
// 发生在顶部
|
86
85
|
if (context.heightCallback) return;
|
@@ -185,16 +184,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
185
184
|
props.scrollRef.current.scrollTop = beforeHeight;
|
186
185
|
}
|
187
186
|
});
|
188
|
-
(0, _react.useEffect)(function () {
|
189
|
-
// 记录preIndex
|
190
|
-
context.preIndex = startIndex;
|
191
|
-
}, [startIndex]);
|
192
|
-
(0, _react.useEffect)(function () {
|
193
|
-
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
194
|
-
return function () {
|
195
|
-
context.preIndex = null;
|
196
|
-
};
|
197
|
-
}, [props.data]);
|
198
187
|
(0, _react.useEffect)(function () {
|
199
188
|
if (props.disabled) return;
|
200
189
|
if (offsetY) {
|
@@ -248,7 +248,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
248
248
|
setStyle(newStyle);
|
249
249
|
}
|
250
250
|
});
|
251
|
-
useEffect(updateStyle, [show, position, absolute, updateKey]);
|
251
|
+
useEffect(updateStyle, [show, position, absolute, updateKey, fixedWidth]);
|
252
252
|
return style;
|
253
253
|
};
|
254
254
|
export default usePositionStyle;
|
@@ -28,7 +28,7 @@ declare const useButton: (props?: BaseButtonProps) => {
|
|
28
28
|
buttonRef?: React.Ref<HTMLButtonElement> | undefined;
|
29
29
|
} & TOther_1 & {
|
30
30
|
disabled: boolean | undefined;
|
31
|
-
htmlType: "button" | "
|
31
|
+
htmlType: "button" | "reset" | "submit" | undefined;
|
32
32
|
onClick: (event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>) => void;
|
33
33
|
};
|
34
34
|
getSpaceChildren: (children: React.ReactNode, space?: boolean, className?: string) => React.ReactNode;
|
@@ -4,7 +4,7 @@ declare const useDatePickerFormat: <Value extends DatePickerValueType>(props: Us
|
|
4
4
|
resultArr: (string | undefined)[];
|
5
5
|
targetResultArr: (string | undefined)[];
|
6
6
|
dateArr: (Date | undefined)[];
|
7
|
-
disabledStatus: "
|
7
|
+
disabledStatus: "all" | "left" | "right" | undefined;
|
8
8
|
currentArr: Date[];
|
9
9
|
mode: DatePickerModeType[];
|
10
10
|
isEmpty: boolean;
|
@@ -10,7 +10,7 @@ declare const useImage: (props?: BaseImageProps) => {
|
|
10
10
|
getRootProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => {
|
11
11
|
[x: string]: (event: any) => void;
|
12
12
|
} & TOther & {
|
13
|
-
ref: React.RefObject<
|
13
|
+
ref: React.RefObject<HTMLDivElement | HTMLAnchorElement>;
|
14
14
|
onClick: (event: React.MouseEvent<HTMLImageElement | HTMLDivElement>) => void;
|
15
15
|
};
|
16
16
|
getImageProps: <TOther_1 extends ObjectType = ObjectType>(externalProps?: TOther_1) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAIA,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;CACjB;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBA6GpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BApEuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAgInB,MAAM;CAwDlD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -8,6 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
8
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
|
+
import { usePrevious } from "../.../../../common/use-previous";
|
11
12
|
import { usePersistFn } from "../../common/use-persist-fn";
|
12
13
|
import { useState, useRef, useEffect } from 'react';
|
13
14
|
var useTableVirtual = function useTableVirtual(props) {
|
@@ -27,6 +28,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
27
28
|
_useState8 = _slicedToArray(_useState7, 2),
|
28
29
|
startIndex = _useState8[0],
|
29
30
|
setStartIndex = _useState8[1];
|
31
|
+
var preIndex = usePrevious(startIndex);
|
30
32
|
var _useState9 = useState(0),
|
31
33
|
_useState10 = _slicedToArray(_useState9, 2),
|
32
34
|
offsetY = _useState10[0],
|
@@ -39,8 +41,7 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
39
41
|
rateTimer: null,
|
40
42
|
topTimer: null,
|
41
43
|
controlScrollRate: null,
|
42
|
-
heightCallback: null
|
43
|
-
preIndex: null
|
44
|
+
heightCallback: null
|
44
45
|
}),
|
45
46
|
context = _useRef.current;
|
46
47
|
var getTranslate = usePersistFn(function (left, top) {
|
@@ -73,8 +74,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
73
74
|
if (context.shouldUpdateHeight) {
|
74
75
|
setHeight(getContentHeight(props.data.length - 1));
|
75
76
|
}
|
76
|
-
var preIndex = context.preIndex;
|
77
|
-
// 解决: 从下往上滚 由于高度变化会导致滚动条跳动
|
78
77
|
if (preIndex && preIndex > startIndex && startIndex === index) {
|
79
78
|
// 发生在顶部
|
80
79
|
if (context.heightCallback) return;
|
@@ -179,16 +178,6 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
179
178
|
props.scrollRef.current.scrollTop = beforeHeight;
|
180
179
|
}
|
181
180
|
});
|
182
|
-
useEffect(function () {
|
183
|
-
// 记录preIndex
|
184
|
-
context.preIndex = startIndex;
|
185
|
-
}, [startIndex]);
|
186
|
-
useEffect(function () {
|
187
|
-
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
188
|
-
return function () {
|
189
|
-
context.preIndex = null;
|
190
|
-
};
|
191
|
-
}, [props.data]);
|
192
181
|
useEffect(function () {
|
193
182
|
if (props.disabled) return;
|
194
183
|
if (offsetY) {
|