@wzyjs/hooks 0.3.29 → 0.3.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/dist/antd/useDateRange.d.ts +2 -2
- package/dist/antd/useForm.d.ts +3 -3
- package/dist/antd/usePaginationState.d.ts +4 -1
- package/dist/antd/useStep.d.ts +1 -1
- package/dist/common/useControlState.d.ts +2 -1
- package/dist/common/useMergeState.d.ts +2 -1
- package/dist/common/useMergeState.js +11 -3
- package/dist/common/useOnceEffect.d.ts +2 -1
- package/dist/dom/useElement.d.ts +3 -2
- package/dist/dom/useElementScrollVisible.d.ts +3 -3
- package/dist/web.d.ts +0 -2
- package/dist/web.js +0 -2
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dayjs } from 'dayjs';
|
|
1
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
export declare enum PresetType {
|
|
3
3
|
TODAY = "\u4ECA\u5929",
|
|
4
4
|
THIS_WEEK = "\u672C\u5468",
|
|
@@ -14,7 +14,7 @@ interface Config {
|
|
|
14
14
|
defaultDateRange?: PresetType | [Dayjs, Dayjs];
|
|
15
15
|
}
|
|
16
16
|
export declare const useDateRange: (config: Config) => {
|
|
17
|
-
dateRange:
|
|
17
|
+
dateRange: [dayjs.Dayjs, dayjs.Dayjs];
|
|
18
18
|
onChange: (dateRange?: any) => void;
|
|
19
19
|
onClickPrev: () => void;
|
|
20
20
|
onClickNext: () => void;
|
package/dist/antd/useForm.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ interface Options<P, V> {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const useForm: <P = any, V = P>(options?: Options<P, V>) => {
|
|
9
9
|
form: import("antd").FormInstance<any>;
|
|
10
|
-
formValues:
|
|
11
|
-
setFormValues:
|
|
12
|
-
formParams:
|
|
10
|
+
formValues: V;
|
|
11
|
+
setFormValues: import("react").Dispatch<import("react").SetStateAction<V>>;
|
|
12
|
+
formParams: P;
|
|
13
13
|
clearFieldsValues: () => void;
|
|
14
14
|
setFieldsValues: (values: V) => void;
|
|
15
15
|
onQuery: () => Promise<void>;
|
|
@@ -2,5 +2,8 @@ import { type PaginationProps } from 'antd';
|
|
|
2
2
|
export declare const usePaginationState: (paginationProps?: PaginationProps) => {
|
|
3
3
|
resetPage: () => void;
|
|
4
4
|
pagination: PaginationProps;
|
|
5
|
-
pageParams:
|
|
5
|
+
pageParams: {
|
|
6
|
+
pageNum: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
};
|
|
6
9
|
};
|
package/dist/antd/useStep.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { SetStateAction, Dispatch } from 'react';
|
|
2
|
+
export declare const useControlState: <T>(state: T) => [T, Dispatch<SetStateAction<T>>];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
type StateType = Record<string, any>;
|
|
2
|
-
|
|
2
|
+
type MergeMode = 'deep' | 'shallow';
|
|
3
|
+
export declare const useMergeState: <T extends StateType>(initialState: T, mergeMode?: MergeMode) => [T, (partialState: Partial<T>) => void];
|
|
3
4
|
export {};
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
3
|
// 功能:管理对象 state,并用 lodash.merge 对局部更新做深度合并。
|
|
4
4
|
// 与 ahooks/useSetState 区别:这里是深度合并,ahooks/useSetState 是浅合并。
|
|
5
|
-
export const useMergeState = (initialState) => {
|
|
5
|
+
export const useMergeState = (initialState, mergeMode = 'deep') => {
|
|
6
6
|
const [state, setState] = useState(initialState);
|
|
7
7
|
const mergeState = (partialState) => {
|
|
8
8
|
if (typeof partialState !== 'object' || partialState === null) {
|
|
9
9
|
throw new Error('mergeState must be called with an object');
|
|
10
10
|
}
|
|
11
|
-
setState((prevState) =>
|
|
11
|
+
setState((prevState) => {
|
|
12
|
+
if (mergeMode === 'shallow') {
|
|
13
|
+
return {
|
|
14
|
+
...prevState,
|
|
15
|
+
...partialState,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return merge({}, prevState, partialState);
|
|
19
|
+
});
|
|
12
20
|
};
|
|
13
21
|
return [state, mergeState];
|
|
14
22
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
export declare const useOnceEffect: (effect: () => boolean, deps: DependencyList) => void;
|
package/dist/dom/useElement.d.ts
CHANGED
package/dist/web.d.ts
CHANGED
package/dist/web.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/hooks",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.31",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"type": "module",
|
|
@@ -34,22 +34,22 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ahooksjs/use-url-state": "^3.5.1",
|
|
38
37
|
"ahooks": "^3.8.4",
|
|
39
38
|
"dayjs": "^1.11.12",
|
|
40
|
-
"lodash": "^4.17.21"
|
|
41
|
-
"react-use": "^17.4.0"
|
|
39
|
+
"lodash-es": "^4.17.21"
|
|
42
40
|
},
|
|
43
41
|
"peerDependencies": {
|
|
44
|
-
"antd": "^
|
|
42
|
+
"antd": "^6.3.1",
|
|
45
43
|
"react": "^19.1.0"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"
|
|
46
|
+
"@types/lodash-es": "^4.17.12",
|
|
47
|
+
"@types/react": "^19.1.10",
|
|
48
|
+
"antd": "^6.3.1",
|
|
49
49
|
"react": "^19.1.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "896e51ffcc433e65605c351be0595918bc32573e"
|
|
55
55
|
}
|