react-toolkits 2.11.19 → 2.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 36eaf3d: Release
8
+
9
+ ## 2.12.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 66def58: refactor: some new apis
14
+
3
15
  ## 2.11.19
4
16
 
5
17
  ### 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
+ hideGameSelect?: boolean;
118
+ layoutTitle?: ReactNode;
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,18 @@ 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[];
118
178
  navWidth?: string | number;
119
- hideGame?: boolean;
120
179
  headerExtra?: {
121
180
  left?: HeaderExtra[];
122
181
  right?: HeaderExtra[];
@@ -140,6 +199,88 @@ declare const useLayoutStore: zustand.UseBoundStore<Omit<zustand.StoreApi<Layout
140
199
  };
141
200
  }>;
142
201
 
202
+ interface UserInfo {
203
+ authorityId: string;
204
+ exp: number;
205
+ }
206
+ interface TokenSlice {
207
+ token?: string;
208
+ getUser: () => UserInfo | null;
209
+ setToken: (token: string) => void;
210
+ }
211
+
212
+ interface GameSlice {
213
+ game?: Game;
214
+ games: Game[];
215
+ selectedGame?: string | number;
216
+ isGamesLoading: boolean;
217
+ setGame: (value?: string | number) => void;
218
+ setGames: (games: Game[]) => void;
219
+ setSelectedGame: (value: string | number) => void;
220
+ setIsGamesLoading: (loading: boolean) => void;
221
+ }
222
+
223
+ type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & {
224
+ clearToken: () => void;
225
+ setUnregistered: () => void;
226
+ };
227
+
228
+ declare function useContextStore<T>(selector: (state: ToolkitsState) => T): T;
229
+ type ContextProviderProps = PropsWithChildren<Partial<ContextSlice>>;
230
+ declare const Contextrovider: FC<ContextProviderProps>;
231
+ declare const withContext: (Component: ComponentType, providerProps: Omit<ContextProviderProps, "children">) => (props: any) => react_jsx_runtime.JSX.Element;
232
+
233
+ interface DynamicTagsProps {
234
+ initialTags?: string[];
235
+ addable?: boolean;
236
+ removable?: boolean;
237
+ addCallback?: (addedTag: string) => Promise<boolean>;
238
+ removeCallback?: (removedTag: string) => Promise<boolean>;
239
+ }
240
+ declare const DynamicTags: FC<DynamicTagsProps>;
241
+
242
+ type ExpandableParagraphProps = Omit<ParagraphProps, 'ellipsis' | 'className'>;
243
+ declare const ExpandableParagraph: FC<ExpandableParagraphProps>;
244
+
245
+ interface FilterFormWrapperProps extends PropsWithChildren {
246
+ onConfirm?: () => void | Promise<void>;
247
+ onReset?: () => void;
248
+ extras?: {
249
+ key: Key;
250
+ children: ReactNode;
251
+ }[];
252
+ isConfirming?: boolean;
253
+ buttonsAlign?: 'left' | 'right' | 'bottom';
254
+ showReset?: boolean;
255
+ }
256
+ declare const FilterFormWrapper: (props: FilterFormWrapperProps) => react_jsx_runtime.JSX.Element;
257
+
258
+ interface HighlightProps extends PropsWithChildren {
259
+ texts: Array<string | number>;
260
+ }
261
+ declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
262
+
263
+ interface InfiniteListExtra<Values> {
264
+ key: Key;
265
+ children: ReactNode | ((form: FormInstance<Values>) => ReactNode);
266
+ }
267
+ interface InfiniteListProps<Item, Values, Response> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'> {
268
+ url: string;
269
+ getRowKey: (response: Response) => any;
270
+ getDataSource: (data: (Response | undefined)[] | undefined) => Item[];
271
+ code?: string;
272
+ headers?: {
273
+ [key: string]: AxiosHeaderValue;
274
+ } | ((form: FormInstance<Values>) => {
275
+ [key: string]: AxiosHeaderValue;
276
+ });
277
+ renderForm?: (form: FormInstance<Values>) => ReactNode;
278
+ transformArg: (values: Values, rowKey?: string) => Record<any, any>;
279
+ hasMore?: (data: (Response | undefined)[] | undefined) => boolean;
280
+ extras?: InfiniteListExtra<Values>[];
281
+ }
282
+ declare const InfiniteList: <Item extends object, Values extends object | undefined = undefined, Response = any>(props: InfiniteListProps<Item, Values, Response>) => react_jsx_runtime.JSX.Element;
283
+
143
284
  interface UseModalOperation {
144
285
  hide: () => void;
145
286
  }
@@ -239,168 +380,13 @@ interface QueryListState {
239
380
  }
240
381
  declare const useQueryListStore: zustand.UseBoundStore<zustand.StoreApi<QueryListState>>;
241
382
 
383
+ declare const RequireGame: FC<PropsWithChildren>;
384
+
242
385
  interface RequirePermissionProps {
243
386
  code: string;
244
387
  }
245
388
  declare const RequirePermission: FC<PropsWithChildren<RequirePermissionProps>>;
246
389
 
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
390
  declare const UserWidget: FC;
405
391
 
406
392
  declare const SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
@@ -473,4 +459,4 @@ type JsonData<T = any> = {
473
459
 
474
460
  declare const mixedStorage: StateStorage;
475
461
 
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 };
462
+ 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 };