fui-material 1.17.3 → 1.17.4

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.
@@ -9083,7 +9083,14 @@ const Ma = ({ doNotUseState: i = !1, defaultState: e = null, getValueByPath: t =
9083
9083
  a(!0), l(null);
9084
9084
  try {
9085
9085
  const f = await ke(v);
9086
- return i || n(f.data), t ? t.split(".").reduce((h, g) => h && h[g], f.data) : f.data;
9086
+ if (t) {
9087
+ let h = f.data;
9088
+ const g = t.split(".");
9089
+ for (const y of g)
9090
+ if (h = h == null ? void 0 : h[y], h === void 0) break;
9091
+ return i || n(f.data), h ?? null;
9092
+ } else
9093
+ return i || n(f.data), f.data;
9087
9094
  } catch (f) {
9088
9095
  const h = f, g = ((d = (b = h.response) == null ? void 0 : b.data) == null ? void 0 : d.message) || h.message || "Unknown error";
9089
9096
  return li({
@@ -6,10 +6,17 @@ export type IUseFApi<T> = {
6
6
  execute: (config: AxiosRequestConfig) => Promise<T | null>;
7
7
  reset: (newData: T | null) => void;
8
8
  };
9
+ type GetValueByPath<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? GetValueByPath<T[Key], Rest> : never : P extends keyof T ? T[P] : never;
9
10
  type IProps<T> = {
10
11
  doNotUseState?: boolean;
11
12
  defaultState?: T | null;
12
13
  getValueByPath?: string;
13
14
  };
14
- declare const useFApi: <T>({ doNotUseState, defaultState, getValueByPath }?: IProps<T>) => IUseFApi<T>;
15
+ declare const useFApi: <T>({ doNotUseState, defaultState, getValueByPath }?: IProps<T>) => {
16
+ data: T | null;
17
+ loading: boolean;
18
+ error: string | null;
19
+ execute: (config: AxiosRequestConfig) => Promise<typeof getValueByPath extends string ? GetValueByPath<T, typeof getValueByPath> : T | null>;
20
+ reset: (newData: T | null) => void;
21
+ };
15
22
  export default useFApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fui-material",
3
- "version": "1.17.3",
3
+ "version": "1.17.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"