@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.
@@ -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: any;
17
+ dateRange: [dayjs.Dayjs, dayjs.Dayjs];
18
18
  onChange: (dateRange?: any) => void;
19
19
  onClickPrev: () => void;
20
20
  onClickNext: () => void;
@@ -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: any;
11
- setFormValues: any;
12
- formParams: any;
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: any;
5
+ pageParams: {
6
+ pageNum: number;
7
+ pageSize: number;
8
+ };
6
9
  };
@@ -9,7 +9,7 @@ interface Option {
9
9
  onChangeAfter?: () => void;
10
10
  }
11
11
  export declare const useStep: (option: Option) => {
12
- current: any;
12
+ current: number;
13
13
  onPrev: () => void;
14
14
  onNext: () => void;
15
15
  };
@@ -1 +1,2 @@
1
- export declare const useControlState: <T>(state: T) => [T, React.Dispatch<React.SetStateAction<T>>];
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
- export declare const useMergeState: <T extends StateType>(initialState: T) => [T, (partialState: Partial<T>) => void];
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 _ from 'lodash';
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) => _.merge({}, prevState, partialState));
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
- export declare const useOnceEffect: (effect: () => boolean, deps: React.DependencyList) => void;
1
+ import { DependencyList } from 'react';
2
+ export declare const useOnceEffect: (effect: () => boolean, deps: DependencyList) => void;
@@ -1,4 +1,5 @@
1
+ import { type CSSProperties } from 'react';
1
2
  export declare const useElement: () => {
2
- elementRef: any;
3
- elementStyles: any;
3
+ elementRef: import("react").RefObject<HTMLDivElement>;
4
+ elementStyles: CSSProperties;
4
5
  };
@@ -1,5 +1,5 @@
1
1
  export declare const useElementScrollVisible: (scroll: any, target: any) => {
2
- visible: any;
3
- direction: any;
4
- rect: any;
2
+ visible: boolean;
3
+ direction: string;
4
+ rect: string;
5
5
  };
package/dist/web.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  export * from 'ahooks';
2
- export { useCopyToClipboard, useCookie, useUpdate } from 'react-use';
3
- export { default as useUrlState } from '@ahooksjs/use-url-state';
4
2
  export * from './common';
5
3
  export * from './antd';
6
4
  export * from './dom';
package/dist/web.js CHANGED
@@ -1,6 +1,4 @@
1
1
  export * from 'ahooks';
2
- export { useCopyToClipboard, useCookie, useUpdate } from 'react-use';
3
- export { default as useUrlState } from '@ahooksjs/use-url-state';
4
2
  export * from './common';
5
3
  export * from './antd';
6
4
  export * from './dom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/hooks",
3
- "version": "0.3.29",
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": "^5.24.3",
42
+ "antd": "^6.3.1",
45
43
  "react": "^19.1.0"
46
44
  },
47
45
  "devDependencies": {
48
- "antd": "^5.24.3",
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": "a78702bb9367a10779eaa376ed70834d8b42b5a8"
54
+ "gitHead": "896e51ffcc433e65605c351be0595918bc32573e"
55
55
  }