react-toolkits 2.11.19 → 2.13.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d26e60b: fix: some issues
8
+
9
+ ## 2.13.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 36eaf3d: Release
14
+
15
+ ## 2.12.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 66def58: refactor: some new apis
20
+
3
21
  ## 2.11.19
4
22
 
5
23
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as react from 'react';
2
- import { FC, PropsWithChildren, Key, ReactNode, ReactElement, Ref, ComponentType } from 'react';
3
+ import { ReactNode, FC, PropsWithChildren, Key, ComponentType, ReactElement, Ref } from 'react';
4
+ import { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse, AxiosInterceptorOptions, AxiosHeaderValue } from 'axios';
3
5
  import { ParagraphProps } from 'antd/es/typography/Paragraph';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { FormInstance, MenuProps, ModalProps, FormProps, ButtonProps } from 'antd';
6
+ import { MenuProps, FormInstance, ModalProps, FormProps, ButtonProps } from 'antd';
6
7
  import { TableProps } from 'antd/es/table';
7
- import { AxiosHeaderValue, AxiosInstance, InternalAxiosRequestConfig, AxiosResponse, AxiosInterceptorOptions } from 'axios';
8
8
  import { ItemType, SubMenuType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface';
9
9
  import { Merge } from 'ts-essentials';
10
10
  import * as zustand_middleware from 'zustand/middleware';
@@ -14,56 +14,117 @@ import { AnyObject } from 'antd/es/_util/type';
14
14
  import * as swr from 'swr';
15
15
  import { MutatorCallback, MutatorOptions } from 'swr';
16
16
 
17
- interface DynamicTagsProps {
18
- initialTags?: string[];
19
- addable?: boolean;
20
- removable?: boolean;
21
- addCallback?: (addedTag: string) => Promise<boolean>;
22
- removeCallback?: (removedTag: string) => Promise<boolean>;
23
- }
24
- declare const DynamicTags: FC<DynamicTagsProps>;
25
-
26
- type ExpandableParagraphProps = Omit<ParagraphProps, 'ellipsis' | 'className'>;
27
- declare const ExpandableParagraph: FC<ExpandableParagraphProps>;
28
-
29
- interface FilterFormWrapperProps extends PropsWithChildren {
30
- onConfirm?: () => void | Promise<void>;
31
- onReset?: () => void;
32
- extras?: {
33
- key: Key;
34
- children: ReactNode;
35
- }[];
36
- isConfirming?: boolean;
37
- buttonsAlign?: 'left' | 'right' | 'bottom';
38
- showReset?: boolean;
17
+ interface AxiosSlice {
18
+ axios: AxiosInstance;
39
19
  }
40
- declare const FilterFormWrapper: (props: FilterFormWrapperProps) => react_jsx_runtime.JSX.Element;
41
20
 
42
- interface HighlightProps extends PropsWithChildren {
43
- texts: Array<string | number>;
44
- }
45
- declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
21
+ type Locale = {
22
+ global: {
23
+ noEntitlement: string;
24
+ name: string;
25
+ creationTime: string;
26
+ operation: string;
27
+ update: string;
28
+ edit: string;
29
+ delete: string;
30
+ selectAll: string;
31
+ game: string;
32
+ user: string;
33
+ role: string;
34
+ username: string;
35
+ password: string;
36
+ label: string;
37
+ method: string;
38
+ route: string;
39
+ request: string;
40
+ response: string;
41
+ add: string;
42
+ signIn: string;
43
+ };
44
+ SignIn: {
45
+ title: string;
46
+ thirdParty: string;
47
+ signInWithIDass: string;
48
+ unregistered: string;
49
+ welcome: string;
50
+ };
51
+ NotFound: {
52
+ subTitle: string;
53
+ buttonText: string;
54
+ };
55
+ FilterFormWrapper: {
56
+ confirmText: string;
57
+ resetText: string;
58
+ };
59
+ FormModal: {
60
+ confirmText: string;
61
+ cancelText: string;
62
+ };
63
+ GameSelect: {
64
+ label: string;
65
+ placeholder: string;
66
+ };
67
+ RequireGame: {
68
+ description: string;
69
+ };
70
+ UserWidget: {
71
+ signOutText: string;
72
+ };
73
+ UserList: {
74
+ createTitle: string;
75
+ createSuccessfully: string;
76
+ updateTitle: string;
77
+ updateSuccessfully: string;
78
+ deleteTitle: string;
79
+ deleteContent: string;
80
+ deleteSuccessfully: string;
81
+ };
82
+ RoleList: {
83
+ createTitle: string;
84
+ createSuccessfully: string;
85
+ updateTitle: string;
86
+ updateSuccessfully: string;
87
+ deleteTitle: string;
88
+ deleteContent: string;
89
+ deleteSuccessfully: string;
90
+ };
91
+ PermissionList: {
92
+ failedDescription: string;
93
+ baseSectionTitle: string;
94
+ gameSectionTitle: string;
95
+ gameSectionDescription: string;
96
+ gameSelectPlaceholder: string;
97
+ removeText: string;
98
+ addText: string;
99
+ };
100
+ RoleDetail: {
101
+ title: string;
102
+ };
103
+ InfiniteList: {
104
+ loadingText: string;
105
+ reachEndText: string;
106
+ loadMoreText: string;
107
+ };
108
+ };
46
109
 
47
- interface InfiniteListExtra<Values> {
48
- key: Key;
49
- children: ReactNode | ((form: FormInstance<Values>) => ReactNode);
50
- }
51
- interface InfiniteListProps<Item, Values, Response> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'> {
52
- url: string;
53
- getRowKey: (response: Response) => any;
54
- getDataSource: (data: (Response | undefined)[] | undefined) => Item[];
55
- code?: string;
56
- headers?: {
57
- [key: string]: AxiosHeaderValue;
58
- } | ((form: FormInstance<Values>) => {
59
- [key: string]: AxiosHeaderValue;
60
- });
61
- renderForm?: (form: FormInstance<Values>) => ReactNode;
62
- transformArg: (values: Values, rowKey?: string) => Record<any, any>;
63
- hasMore?: (data: (Response | undefined)[] | undefined) => boolean;
64
- extras?: InfiniteListExtra<Values>[];
110
+ interface ContextSlice {
111
+ locale: Locale;
112
+ isPermissionApiV2: boolean;
113
+ gameApiV2: boolean;
114
+ signInPath: string;
115
+ isGlobal: boolean;
116
+ unregistered?: boolean;
117
+ layoutTitle?: ReactNode;
118
+ navWidth?: number;
119
+ interceptors?: {
120
+ request?: [(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>];
121
+ response?: [
122
+ (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>,
123
+ ((error: any) => any) | null,
124
+ options?: AxiosInterceptorOptions
125
+ ];
126
+ };
65
127
  }
66
- declare const InfiniteList: <Item extends object, Values extends object | undefined = undefined, Response = any>(props: InfiniteListProps<Item, Values, Response>) => react_jsx_runtime.JSX.Element;
67
128
 
68
129
  type MenuItemType2 = Merge<MenuItemType, {
69
130
  route?: string;
@@ -103,20 +164,19 @@ interface Game {
103
164
 
104
165
  interface GameSelectProps {
105
166
  filter?: (game: Game) => boolean;
106
- onGameChange?: (game: Game) => void;
107
167
  }
108
168
 
109
169
  type HeaderExtra = {
110
170
  key: Key;
111
171
  children: ReactNode;
112
172
  };
113
- interface LayoutProps extends Pick<GameSelectProps, 'filter' | 'onGameChange'> {
173
+ interface LayoutProps extends Pick<GameSelectProps, 'filter'> {
114
174
  menuCollapsible?: boolean;
115
175
  isMenuLoading?: boolean;
116
176
  title?: ReactNode;
117
177
  items?: NavMenuItem[];
178
+ hideGameSelect?: boolean;
118
179
  navWidth?: string | number;
119
- hideGame?: boolean;
120
180
  headerExtra?: {
121
181
  left?: HeaderExtra[];
122
182
  right?: HeaderExtra[];
@@ -140,6 +200,88 @@ declare const useLayoutStore: zustand.UseBoundStore<Omit<zustand.StoreApi<Layout
140
200
  };
141
201
  }>;
142
202
 
203
+ interface UserInfo {
204
+ authorityId: string;
205
+ exp: number;
206
+ }
207
+ interface TokenSlice {
208
+ token?: string;
209
+ getUser: () => UserInfo | null;
210
+ setToken: (token: string) => void;
211
+ }
212
+
213
+ interface GameSlice {
214
+ game?: Game;
215
+ games: Game[];
216
+ selectedGame?: string | number;
217
+ isGamesLoading: boolean;
218
+ setGame: (value?: string | number) => void;
219
+ setGames: (games: Game[]) => void;
220
+ setSelectedGame: (value: string | number) => void;
221
+ setIsGamesLoading: (loading: boolean) => void;
222
+ }
223
+
224
+ type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & {
225
+ clearToken: () => void;
226
+ setUnregistered: () => void;
227
+ };
228
+
229
+ declare function useContextStore<T>(selector: (state: ToolkitsState) => T): T;
230
+ type ContextProviderProps = PropsWithChildren<Partial<ContextSlice>>;
231
+ declare const Contextrovider: FC<ContextProviderProps>;
232
+ declare const withContext: (Component: ComponentType, providerProps: Omit<ContextProviderProps, "children">) => (props: any) => react_jsx_runtime.JSX.Element;
233
+
234
+ interface DynamicTagsProps {
235
+ initialTags?: string[];
236
+ addable?: boolean;
237
+ removable?: boolean;
238
+ addCallback?: (addedTag: string) => Promise<boolean>;
239
+ removeCallback?: (removedTag: string) => Promise<boolean>;
240
+ }
241
+ declare const DynamicTags: FC<DynamicTagsProps>;
242
+
243
+ type ExpandableParagraphProps = Omit<ParagraphProps, 'ellipsis' | 'className'>;
244
+ declare const ExpandableParagraph: FC<ExpandableParagraphProps>;
245
+
246
+ interface FilterFormWrapperProps extends PropsWithChildren {
247
+ onConfirm?: () => void | Promise<void>;
248
+ onReset?: () => void;
249
+ extras?: {
250
+ key: Key;
251
+ children: ReactNode;
252
+ }[];
253
+ isConfirming?: boolean;
254
+ buttonsAlign?: 'left' | 'right' | 'bottom';
255
+ showReset?: boolean;
256
+ }
257
+ declare const FilterFormWrapper: (props: FilterFormWrapperProps) => react_jsx_runtime.JSX.Element;
258
+
259
+ interface HighlightProps extends PropsWithChildren {
260
+ texts: Array<string | number>;
261
+ }
262
+ declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
263
+
264
+ interface InfiniteListExtra<Values> {
265
+ key: Key;
266
+ children: ReactNode | ((form: FormInstance<Values>) => ReactNode);
267
+ }
268
+ interface InfiniteListProps<Item, Values, Response> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'> {
269
+ url: string;
270
+ getRowKey: (response: Response) => any;
271
+ getDataSource: (data: (Response | undefined)[] | undefined) => Item[];
272
+ code?: string;
273
+ headers?: {
274
+ [key: string]: AxiosHeaderValue;
275
+ } | ((form: FormInstance<Values>) => {
276
+ [key: string]: AxiosHeaderValue;
277
+ });
278
+ renderForm?: (form: FormInstance<Values>) => ReactNode;
279
+ transformArg: (values: Values, rowKey?: string) => Record<any, any>;
280
+ hasMore?: (data: (Response | undefined)[] | undefined) => boolean;
281
+ extras?: InfiniteListExtra<Values>[];
282
+ }
283
+ declare const InfiniteList: <Item extends object, Values extends object | undefined = undefined, Response = any>(props: InfiniteListProps<Item, Values, Response>) => react_jsx_runtime.JSX.Element;
284
+
143
285
  interface UseModalOperation {
144
286
  hide: () => void;
145
287
  }
@@ -239,168 +381,13 @@ interface QueryListState {
239
381
  }
240
382
  declare const useQueryListStore: zustand.UseBoundStore<zustand.StoreApi<QueryListState>>;
241
383
 
384
+ declare const RequireGame: FC<PropsWithChildren>;
385
+
242
386
  interface RequirePermissionProps {
243
387
  code: string;
244
388
  }
245
389
  declare const RequirePermission: FC<PropsWithChildren<RequirePermissionProps>>;
246
390
 
247
- interface AxiosSlice {
248
- axios: AxiosInstance;
249
- }
250
-
251
- type Locale = {
252
- global: {
253
- noEntitlement: string;
254
- name: string;
255
- creationTime: string;
256
- operation: string;
257
- update: string;
258
- edit: string;
259
- delete: string;
260
- selectAll: string;
261
- game: string;
262
- user: string;
263
- role: string;
264
- username: string;
265
- password: string;
266
- label: string;
267
- method: string;
268
- route: string;
269
- request: string;
270
- response: string;
271
- add: string;
272
- signIn: string;
273
- };
274
- SignIn: {
275
- title: string;
276
- thirdParty: string;
277
- signInWithIDass: string;
278
- unregistered: string;
279
- welcome: string;
280
- };
281
- NotFound: {
282
- subTitle: string;
283
- buttonText: string;
284
- };
285
- FilterFormWrapper: {
286
- confirmText: string;
287
- resetText: string;
288
- };
289
- FormModal: {
290
- confirmText: string;
291
- cancelText: string;
292
- };
293
- GameSelect: {
294
- label: string;
295
- placeholder: string;
296
- };
297
- RequireGame: {
298
- description: string;
299
- };
300
- UserWidget: {
301
- signOutText: string;
302
- };
303
- UserList: {
304
- createTitle: string;
305
- createSuccessfully: string;
306
- updateTitle: string;
307
- updateSuccessfully: string;
308
- deleteTitle: string;
309
- deleteContent: string;
310
- deleteSuccessfully: string;
311
- };
312
- RoleList: {
313
- createTitle: string;
314
- createSuccessfully: string;
315
- updateTitle: string;
316
- updateSuccessfully: string;
317
- deleteTitle: string;
318
- deleteContent: string;
319
- deleteSuccessfully: string;
320
- };
321
- PermissionList: {
322
- failedDescription: string;
323
- baseSectionTitle: string;
324
- gameSectionTitle: string;
325
- gameSectionDescription: string;
326
- gameSelectPlaceholder: string;
327
- removeText: string;
328
- addText: string;
329
- };
330
- RoleDetail: {
331
- title: string;
332
- };
333
- InfiniteList: {
334
- loadingText: string;
335
- reachEndText: string;
336
- loadMoreText: string;
337
- };
338
- };
339
-
340
- interface ContextSlice {
341
- locale: Locale;
342
- usePermissionApiV2: boolean;
343
- gameApiV2: boolean;
344
- signInPath: string;
345
- isGlobal: boolean;
346
- unregistered?: boolean;
347
- hideGame?: boolean;
348
- interceptors?: {
349
- request?: [(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>];
350
- response?: [
351
- (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>,
352
- ((error: any) => any) | null,
353
- options?: AxiosInterceptorOptions
354
- ];
355
- };
356
- }
357
-
358
- interface UserInfo {
359
- authorityId: string;
360
- exp: number;
361
- }
362
- interface TokenSlice {
363
- token?: string;
364
- getUser: () => UserInfo | null;
365
- setToken: (token: string) => void;
366
- }
367
-
368
- interface GameSlice {
369
- initialized: boolean;
370
- game?: Game;
371
- games: Game[];
372
- isLoading: boolean;
373
- setGame(game: Game): void;
374
- fetchGames: (options?: {
375
- apiV2?: boolean;
376
- forceUpdate?: boolean;
377
- }) => Promise<Game[] | undefined>;
378
- }
379
-
380
- type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & {
381
- setContext: (props: Partial<ContextSlice>) => void;
382
- clearToken: () => void;
383
- setUnregistered: () => void;
384
- };
385
- declare const createToolkitsStore: (initProps?: Partial<ContextSlice>) => Omit<zustand.StoreApi<ToolkitsState>, "persist"> & {
386
- persist: {
387
- setOptions: (options: Partial<zustand_middleware.PersistOptions<ToolkitsState, unknown>>) => void;
388
- clearStorage: () => void;
389
- rehydrate: () => Promise<void> | void;
390
- hasHydrated: () => boolean;
391
- onHydrate: (fn: (state: ToolkitsState) => void) => () => void;
392
- onFinishHydration: (fn: (state: ToolkitsState) => void) => () => void;
393
- getOptions: () => Partial<zustand_middleware.PersistOptions<ToolkitsState, unknown>>;
394
- };
395
- };
396
-
397
- type ToolkitsStore = ReturnType<typeof createToolkitsStore>;
398
- declare function useToolkitsStore<T>(selector: (state: ToolkitsState) => T): T;
399
- type ToolkitsProviderProps = PropsWithChildren<Partial<ContextSlice>>;
400
- declare let toolkitsStore: ToolkitsStore;
401
- declare const ToolkitsProvider: FC<ToolkitsProviderProps>;
402
- declare const withContext: (Component: ComponentType, providerProps: Omit<ToolkitsProviderProps, "children">) => (props: any) => react_jsx_runtime.JSX.Element;
403
-
404
391
  declare const UserWidget: FC;
405
392
 
406
393
  declare const SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
@@ -473,4 +460,4 @@ type JsonData<T = any> = {
473
460
 
474
461
  declare const mixedStorage: StateStorage;
475
462
 
476
- export { APP_ID_HEADER, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, Highlight, type HighlightProps, InfiniteList, type InfiniteListProps, type JsonData, Layout, type LayoutState, NavMenu, type NavMenuItem, NotFound, _default$1 as OperationLogList, PermissionButton, type PermissionButtonProps, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, RequirePermission, type RequirePermissionProps, SSO_URL, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseFormModalProps, UserWidget, _default$2 as menuRoutes, mixedStorage, _default as permissionRoutes, toolkitsStore, useFormModal, useLayoutStore, useMenuList, useModal, usePermission, usePermissions, useQueryListStore, useToolkitsStore, withContext };
463
+ export { APP_ID_HEADER, Contextrovider as ContextProvider, type ContextProviderProps, DynamicTags, type DynamicTagsProps, ExpandableParagraph, type ExpandableParagraphProps, FRONTEND_ROUTE_PREFIX, FilterFormWrapper, type FilterFormWrapperProps, type Game, Highlight, type HighlightProps, InfiniteList, type InfiniteListProps, type JsonData, Layout, type LayoutProps, type LayoutState, NavMenu, type NavMenuItem, NotFound, _default$1 as OperationLogList, PermissionButton, type PermissionButtonProps, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, RequireGame, RequirePermission, type RequirePermissionProps, SSO_URL, SignIn, type UseFormModalProps, UserWidget, _default$2 as menuRoutes, mixedStorage, _default as permissionRoutes, useContextStore, useFormModal, useLayoutStore, useMenuList, useModal, usePermission, usePermissions, useQueryListStore, withContext };