react-toolkits 0.6.4 → 0.7.0

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/lib/index.d.ts CHANGED
@@ -11,7 +11,6 @@ import type { ModalFuncProps } from 'antd';
11
11
  import type { MutatorCallback } from 'swr/_internal';
12
12
  import type { MutatorOptions } from 'swr/_internal';
13
13
  import { NamedExoticComponent } from 'react';
14
- import type { NamePath } from 'antd/es/form/interface';
15
14
  import { PersistOptions } from 'zustand/middleware';
16
15
  import type { PropsWithChildren } from 'react';
17
16
  import type { ReactElement } from 'react';
@@ -20,6 +19,7 @@ import type { Ref } from 'react';
20
19
  import type { StateStorage } from 'zustand/middleware';
21
20
  import { StoreApi } from 'zustand';
22
21
  import type { SubMenuType } from 'antd/es/menu/hooks/useItems';
22
+ import type { SWRConfiguration } from 'swr';
23
23
  import type { TableProps } from 'antd/es/table';
24
24
  import { UseBoundStore } from 'zustand';
25
25
 
@@ -50,13 +50,13 @@ export declare interface DynamicTagsProps {
50
50
  export declare const FilterFormWrapper: (props: FilterFormWrapperProps) => JSX_2.Element;
51
51
 
52
52
  export declare interface FilterFormWrapperProps extends PropsWithChildren {
53
- confirmText?: ReactNode;
54
53
  onConfirm?: () => void | Promise<void>;
55
54
  onReset?: () => void;
56
55
  extras?: {
57
56
  key: Key;
58
57
  children: ReactNode;
59
58
  }[];
59
+ isConfirming?: boolean;
60
60
  }
61
61
 
62
62
  export declare interface Game {
@@ -112,7 +112,7 @@ export declare interface LayoutProps extends PropsWithChildren {
112
112
 
113
113
  declare interface ListResponse<T = any> {
114
114
  list: T[];
115
- total: number;
115
+ total?: number;
116
116
  }
117
117
 
118
118
  export declare type Locale = {
@@ -238,7 +238,7 @@ export declare interface PermissionGuardProps {
238
238
  }
239
239
 
240
240
  export declare const QueryList: <Item extends object, Values extends object | undefined, Response_1 = ListResponse<Item>>(props: QueryListProps<Item, Values, Response_1> & {
241
- ref?: Ref<QueryListRef<Values>> | undefined;
241
+ ref?: Ref<QueryListRef<Item, Values>> | undefined;
242
242
  }) => ReactElement;
243
243
 
244
244
  export declare enum QueryListAction {
@@ -248,49 +248,53 @@ export declare enum QueryListAction {
248
248
  Init = "init"
249
249
  }
250
250
 
251
- declare type QueryListMutator = <T = any>(key: string, payload?: Partial<{
252
- page: number;
253
- size: number;
254
- }>, data?: ListResponse<T> | Promise<ListResponse<T>> | MutatorCallback<ListResponse<T>>, opts?: MutatorOptions<ListResponse<T>>) => void;
251
+ declare interface QueryListDataType<Item> {
252
+ dataSource: Item[];
253
+ total: number;
254
+ }
255
+
256
+ declare type QueryListMutator = <T = any>(key: string, data?: ListResponse<T> | Promise<ListResponse<T>> | MutatorCallback<ListResponse<T>>, opts?: MutatorOptions<ListResponse<T>>) => void;
257
+
258
+ declare interface QueryListPayload {
259
+ page?: number;
260
+ size?: number;
261
+ arg?: object;
262
+ }
255
263
 
256
264
  export declare interface QueryListProps<Item = any, Values = any, Response = any> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'> {
257
- action: string;
258
265
  renderForm?: (form: FormInstance<Values>) => ReactNode;
259
266
  code?: string;
260
267
  isGlobalNS?: boolean;
261
- headers?: Record<string, string> | ((form: FormInstance<Values>) => Record<string, string>);
262
- transformArg?: (page: number, size: number, values: Values | undefined) => unknown;
263
- transformResponse?: (response: Response) => ListResponse<Item>;
264
- afterSuccess?: (response: ListResponse<Item>, action?: QueryListAction) => void;
265
- confirmText?: ReactNode;
266
- noPagination?: boolean;
267
- extra?: (response: Response | undefined, form: FormInstance<Values>) => ReactNode;
268
+ extra?: (form: FormInstance<Values>) => ReactNode;
268
269
  onTableChange?: TableProps<Item>['onChange'];
270
+ action: string;
271
+ method?: string;
272
+ headers?: RequestOptions['headers'] | ((payload: QueryListPayload) => RequestOptions['headers']);
273
+ body?: RequestOptions['body'] | ((payload: QueryListPayload) => RequestOptions['body']);
274
+ params?: RequestOptions['params'] | ((payload: QueryListPayload) => RequestOptions['params']);
275
+ afterSuccess?: (action: QueryListAction, data: QueryListDataType<Item>) => void;
276
+ onePage?: boolean;
277
+ defaultSize?: number;
278
+ getTotal?: (response: Response) => number;
279
+ getDataSource?: (response: Response) => Item[];
269
280
  }
270
281
 
271
- export declare interface QueryListRef<Values = any> {
282
+ export declare interface QueryListRef<Item = any, Values = any> {
283
+ data: QueryListDataType<Item>;
272
284
  form: FormInstance<Values>;
273
- setFieldValue: (name: NamePath, value: any) => void;
274
- setFieldsValue: (values: RecursivePartial_2<Values>) => void;
275
285
  }
276
286
 
277
287
  declare interface QueryListState {
278
288
  keyMap: Map<string, string | null>;
279
- paginationMap: Map<string, {
280
- page: number;
281
- size: number;
282
- }>;
289
+ payloadMap: Map<string, QueryListPayload>;
283
290
  mutate: QueryListMutator;
291
+ setPayload(key: string, payload: QueryListPayload, triggerUpdate?: boolean): void;
284
292
  }
285
293
 
286
294
  declare type RecursivePartial<T> = NonNullable<T> extends object ? {
287
295
  [P in keyof T]?: NonNullable<T[P]> extends (infer U)[] ? RecursivePartial<U>[] : NonNullable<T[P]> extends object ? RecursivePartial<T[P]> : T[P];
288
296
  } : T;
289
297
 
290
- declare type RecursivePartial_2<T> = NonNullable<T> extends object ? {
291
- [P in keyof T]?: NonNullable<T[P]> extends (infer U)[] ? RecursivePartial_2<U>[] : NonNullable<T[P]> extends object ? RecursivePartial_2<T[P]> : T[P];
292
- } : T;
293
-
294
298
  export declare function request<T = any>(url: string, opts?: RequestOptions): Promise<RequestResponse<T>>;
295
299
 
296
300
  export declare class RequestError extends Error {
@@ -357,19 +361,13 @@ export declare const useGameStore: UseBoundStore<Omit<StoreApi<GameState>, "pers
357
361
  };
358
362
  }>;
359
363
 
360
- export declare function usePermission(code: string | undefined, opts?: {
361
- isGlobalNS?: boolean;
362
- suspense?: boolean;
363
- }): {
364
+ export declare function usePermission(code: string | undefined, isGlobalNS?: boolean, config?: SWRConfiguration): {
364
365
  accessible: boolean;
365
366
  isValidating: boolean;
366
367
  isLoading: boolean;
367
368
  };
368
369
 
369
- export declare function usePermissions(codes: string[], opts?: {
370
- isGlobalNS?: boolean;
371
- suspense?: boolean;
372
- }): {
370
+ export declare function usePermissions(codes: string[], isGlobalNS?: boolean, config?: SWRConfiguration): {
373
371
  data: Record<string, boolean> | undefined;
374
372
  isValidating: boolean;
375
373
  isLoading: boolean;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as i, D as u, F as n, G as m, H as p, q as l, L as d, N as x, P as y, v as L, Q as P, p as S, K as g, R as G, y as T, x as c, B as h, r as q, h as F, t as Q, e as R, z as f, f as k, a as v, b as B, u as C, E as D, J as E } from "./index-iX5ff45w.chunk.js";
1
+ import { C as i, D as u, F as n, G as m, H as p, q as l, L as d, N as x, P as y, v as L, Q as P, p as S, K as g, R as G, y as T, x as c, B as h, r as q, h as F, t as Q, e as R, z as f, f as k, a as v, b as B, u as C, E as D, J as E } from "./index-JEVes6q2.chunk.js";
2
2
  import "react";
3
3
  import "antd";
4
4
  import "react-dom";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-toolkits",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "packageManager": "^pnpm@8.7.5",
5
5
  "sideEffects": [
6
6
  "**/*.css"