react-toolkits 0.2.16 → 0.2.18
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 +12 -0
- package/dist/index.d.mts +65 -50
- package/dist/index.esm.js +12 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -2,15 +2,15 @@ import * as react from 'react';
|
|
|
2
2
|
import { FC, ReactNode, PropsWithChildren } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as antd from 'antd';
|
|
5
|
-
import {
|
|
5
|
+
import { FormInstance, ModalProps, FormProps, ButtonProps } from 'antd';
|
|
6
6
|
import { DeepPartial, Merge } from 'ts-essentials';
|
|
7
7
|
import { TableProps } from 'antd/es/table';
|
|
8
|
+
import * as zustand from 'zustand';
|
|
8
9
|
import { MenuDividerType, MenuItemType, SubMenuType, MenuItemGroupType } from 'antd/es/menu/hooks/useItems';
|
|
9
|
-
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
10
10
|
import * as zustand_middleware from 'zustand/middleware';
|
|
11
|
-
import * as zustand from 'zustand';
|
|
12
11
|
import { MutatorCallback, MutatorOptions } from 'swr/_internal';
|
|
13
12
|
import { RouteObject } from 'react-router-dom';
|
|
13
|
+
import { StateStorage } from 'zustand/esm/middleware';
|
|
14
14
|
|
|
15
15
|
interface DynamicTagsProps {
|
|
16
16
|
initialTags?: string[];
|
|
@@ -21,15 +21,17 @@ interface DynamicTagsProps {
|
|
|
21
21
|
}
|
|
22
22
|
declare const DynamicTags: FC<DynamicTagsProps>;
|
|
23
23
|
|
|
24
|
-
interface FilterFormWrapperProps {
|
|
24
|
+
interface FilterFormWrapperProps<Values> {
|
|
25
|
+
form?: FormInstance<Values>;
|
|
25
26
|
confirmText?: ReactNode;
|
|
26
27
|
afterConfirm?: () => void | Promise<void>;
|
|
27
28
|
afterReset?: () => void | Promise<void>;
|
|
29
|
+
children?: (form: FormInstance<Values>) => ReactNode;
|
|
28
30
|
}
|
|
29
|
-
declare const FilterFormWrapper: (props:
|
|
31
|
+
declare const FilterFormWrapper: <Values = any>(props: FilterFormWrapperProps<Values>) => react_jsx_runtime.JSX.Element | null;
|
|
30
32
|
|
|
31
33
|
interface FormModalProps<Values> extends Omit<ModalProps, 'onCancel' | 'children' | 'destroyOnClose' | 'forceRender' | 'getContainer' | 'footer' | 'confirmLoading'> {
|
|
32
|
-
|
|
34
|
+
renderFooter?: (form: FormInstance<Values>) => ReactNode;
|
|
33
35
|
onCancel?: VoidFunction;
|
|
34
36
|
onConfirm?: (values: Values) => Promise<void>;
|
|
35
37
|
initialValues?: DeepPartial<Values>;
|
|
@@ -58,7 +60,7 @@ interface PermissionButtonProps extends Omit<ButtonProps, 'disabled'> {
|
|
|
58
60
|
}
|
|
59
61
|
declare const PermissionButton: FC<PropsWithChildren<PermissionButtonProps>>;
|
|
60
62
|
|
|
61
|
-
interface ListResponse<T> {
|
|
63
|
+
interface ListResponse<T = any> {
|
|
62
64
|
list: T[];
|
|
63
65
|
total: number;
|
|
64
66
|
}
|
|
@@ -67,23 +69,17 @@ declare enum QueryListAction {
|
|
|
67
69
|
Submit = "submit",
|
|
68
70
|
Reset = "reset"
|
|
69
71
|
}
|
|
70
|
-
interface QueryListProps<Item, Values, Response> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'>, Pick<FilterFormWrapperProps
|
|
72
|
+
interface QueryListProps<Item, Values, Response> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'>, Pick<FilterFormWrapperProps<Values>, 'confirmText'> {
|
|
71
73
|
url: string;
|
|
72
74
|
code?: string;
|
|
73
75
|
headers?: Record<string, string>;
|
|
76
|
+
form?: FormInstance<Values>;
|
|
77
|
+
renderForm?: (form: FormInstance<Values>) => ReactNode;
|
|
74
78
|
transformArg?: (page: number, size: number, values: Values) => unknown;
|
|
75
79
|
transformResponse?: (response: Response) => ListResponse<Item>;
|
|
76
80
|
afterSuccess?: (response: ListResponse<Item>, action?: QueryListAction) => void;
|
|
77
81
|
}
|
|
78
|
-
declare const QueryList: <Item extends object, Values extends object | undefined, Response_1 = ListResponse<Item>>(props:
|
|
79
|
-
|
|
80
|
-
interface GameType {
|
|
81
|
-
id: string;
|
|
82
|
-
name: string;
|
|
83
|
-
area: 'cn' | 'global';
|
|
84
|
-
Ctime: string;
|
|
85
|
-
}
|
|
86
|
-
declare const GameSelect: () => react_jsx_runtime.JSX.Element | null;
|
|
82
|
+
declare const QueryList: <Item extends object, Values extends object | undefined, Response_1 = ListResponse<Item>>(props: QueryListProps<Item, Values, Response_1>) => react_jsx_runtime.JSX.Element;
|
|
87
83
|
|
|
88
84
|
type MenuItemType2 = Merge<MenuItemType, {
|
|
89
85
|
code /** 权限编号 **/?: string;
|
|
@@ -98,27 +94,50 @@ type MenuItemGroupType2 = Merge<MenuItemGroupType, {
|
|
|
98
94
|
type ItemType2 = MenuItemType2 | SubMenuType2 | MenuItemGroupType2 | MenuDividerType | null;
|
|
99
95
|
declare const NavMenu: () => react_jsx_runtime.JSX.Element;
|
|
100
96
|
|
|
101
|
-
interface
|
|
97
|
+
interface ToolkitsContextState {
|
|
102
98
|
title: string;
|
|
103
|
-
isPermissionV2: boolean;
|
|
104
|
-
isGlobalNS: boolean;
|
|
105
|
-
game: GameType | null;
|
|
106
|
-
setGame: (game: GameType | null) => void;
|
|
107
|
-
openKeys: string[];
|
|
108
|
-
selectedKeys: string[];
|
|
109
|
-
setOpenKeys: (keys: string[]) => void;
|
|
110
|
-
setSelectedKeys: (keys: string[]) => void;
|
|
111
99
|
menuItems: ItemType2[];
|
|
100
|
+
usePermissionV2: boolean;
|
|
112
101
|
onlyDomesticGames: boolean;
|
|
113
102
|
}
|
|
114
|
-
declare
|
|
103
|
+
declare const toolkitContextStore: zustand.StoreApi<ToolkitsContextState>;
|
|
104
|
+
declare function useToolkitContextStore<T>(selector: (state: ToolkitsContextState) => T): T;
|
|
105
|
+
declare const ToolkitsContextProvider: FC<PropsWithChildren<Partial<ToolkitsContextState>>>;
|
|
106
|
+
|
|
107
|
+
interface Game {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
area: 'cn' | 'global';
|
|
111
|
+
Ctime: string;
|
|
112
|
+
}
|
|
113
|
+
interface GameState$1 {
|
|
114
|
+
game: Game | null;
|
|
115
|
+
setGame: (game: Game) => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare const GameSelect: () => react_jsx_runtime.JSX.Element;
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
interface GameState {
|
|
121
|
+
game: Game | null;
|
|
122
|
+
setGame: (game: Game) => void;
|
|
123
|
+
}
|
|
124
|
+
declare const useGameStore: zustand.UseBoundStore<Omit<zustand.StoreApi<GameState>, "persist"> & {
|
|
125
|
+
persist: {
|
|
126
|
+
setOptions: (options: Partial<zustand_middleware.PersistOptions<GameState, unknown>>) => void;
|
|
127
|
+
clearStorage: () => void;
|
|
128
|
+
rehydrate: () => void | Promise<void>;
|
|
129
|
+
hasHydrated: () => boolean;
|
|
130
|
+
onHydrate: (fn: (state: GameState) => void) => () => void;
|
|
131
|
+
onFinishHydration: (fn: (state: GameState) => void) => () => void;
|
|
132
|
+
getOptions: () => Partial<zustand_middleware.PersistOptions<GameState, unknown>>;
|
|
133
|
+
};
|
|
134
|
+
}>;
|
|
117
135
|
|
|
118
136
|
declare const UserWidget: FC;
|
|
119
137
|
|
|
120
138
|
interface LayoutProps extends PropsWithChildren {
|
|
121
139
|
extra?: react.ReactNode[];
|
|
140
|
+
isGlobalNS?: boolean;
|
|
122
141
|
}
|
|
123
142
|
declare const Layout: FC<LayoutProps>;
|
|
124
143
|
|
|
@@ -127,22 +146,6 @@ interface PermissionGuardProps {
|
|
|
127
146
|
}
|
|
128
147
|
declare const PermissionGuard: FC<PropsWithChildren<PermissionGuardProps>>;
|
|
129
148
|
|
|
130
|
-
type ShimmedAxiosInstance = Merge<AxiosInstance, {
|
|
131
|
-
request<T = unknown, D = unknown>(config: AxiosRequestConfig<D>): Promise<T>;
|
|
132
|
-
get<T = unknown, D = unknown>(url: string, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
133
|
-
delete<T = unknown, D = unknown>(url: string, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
134
|
-
head<T = unknown, D = unknown>(url: string, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
135
|
-
post<T = unknown, D = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
136
|
-
put<T = unknown, D = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
137
|
-
patch<T = unknown, D = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig<D>): Promise<T>;
|
|
138
|
-
}>;
|
|
139
|
-
declare class HttpClientError extends Error {
|
|
140
|
-
code?: number;
|
|
141
|
-
skip: boolean;
|
|
142
|
-
constructor(message: string, code?: number, skip?: boolean);
|
|
143
|
-
}
|
|
144
|
-
declare function useHttpClient(): ShimmedAxiosInstance;
|
|
145
|
-
|
|
146
149
|
interface PermissionCheckResult {
|
|
147
150
|
[k: string]: boolean;
|
|
148
151
|
}
|
|
@@ -150,7 +153,7 @@ declare function usePermissions(codes: string[], isGlobalNS?: boolean): {
|
|
|
150
153
|
data: Record<string, boolean>;
|
|
151
154
|
isLoading: false;
|
|
152
155
|
};
|
|
153
|
-
declare function usePermission(code: string): {
|
|
156
|
+
declare function usePermission(code: string | undefined, isGlobalNS?: boolean): {
|
|
154
157
|
accessible: boolean;
|
|
155
158
|
isValidating: boolean;
|
|
156
159
|
};
|
|
@@ -187,12 +190,12 @@ interface QueryListStoreValue {
|
|
|
187
190
|
formValues?: any;
|
|
188
191
|
}
|
|
189
192
|
interface QueryListState {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
params: Map<string, QueryListStoreValue>;
|
|
194
|
+
getParams: (key: string) => QueryListStoreValue;
|
|
195
|
+
setParams: (key: string, value?: Partial<QueryListStoreValue>) => void;
|
|
193
196
|
}
|
|
194
197
|
declare const useQueryListStore: zustand.UseBoundStore<zustand.StoreApi<QueryListState>>;
|
|
195
|
-
declare function useQueryListMutate(): <T>(key: string, data?: ListResponse<T> | Promise<ListResponse<T>> | MutatorCallback<ListResponse<T>> | undefined, opts?: boolean | MutatorOptions<ListResponse<T>> | undefined) => Promise<ListResponse<T> | undefined>;
|
|
198
|
+
declare function useQueryListMutate(): <T = any>(key: string, data?: ListResponse<T> | Promise<ListResponse<T>> | MutatorCallback<ListResponse<T>> | undefined, opts?: boolean | MutatorOptions<ListResponse<T>> | undefined) => Promise<ListResponse<T> | undefined>;
|
|
196
199
|
declare function useQueryListJump(): (key: string, page?: number) => void;
|
|
197
200
|
|
|
198
201
|
declare const routes$1: RouteObject;
|
|
@@ -201,4 +204,16 @@ declare const routes: RouteObject;
|
|
|
201
204
|
|
|
202
205
|
declare const SSO_URL = "https://idaas.ifunplus.cn/enduser/api/application/plugin_FunPlus/sso/v1";
|
|
203
206
|
|
|
204
|
-
|
|
207
|
+
declare class FetcherError extends Error {
|
|
208
|
+
code?: number;
|
|
209
|
+
skip: boolean;
|
|
210
|
+
constructor(message: string, code?: number, skip?: boolean);
|
|
211
|
+
}
|
|
212
|
+
interface InitConfig extends Omit<RequestInit, 'body'> {
|
|
213
|
+
body?: Record<string | number, any> | null;
|
|
214
|
+
}
|
|
215
|
+
declare function request<T = any>(input: RequestInfo | URL, init?: InitConfig, isGlobalNS?: boolean): Promise<T>;
|
|
216
|
+
|
|
217
|
+
declare const mixedStorage: StateStorage;
|
|
218
|
+
|
|
219
|
+
export { DynamicTags, DynamicTagsProps, FetcherError, FilterFormWrapper, FilterFormWrapperProps, FormModal, FormModalProps, Game, GameSelect, GameState$1 as GameState, Highlight, HighlightTextsProps, ItemType2, Layout, LayoutProps, NavMenu, PermissionButton, PermissionButtonProps, PermissionCheckResult, PermissionGuard, PermissionGuardProps, QueryList, QueryListAction, QueryListProps, QueryListState, QueryListStoreValue, SSO_URL, TokenState, ToolkitsContextProvider, ToolkitsContextState, UseFormModalProps, UserWidget, routes$1 as baseRoutes, mixedStorage, routes as permissionRoutes, request, toolkitContextStore, useFormModal, useGameStore, usePermission, usePermissions, useQueryListJump, useQueryListMutate, useQueryListStore, useTokenStore, useToolkitContextStore };
|