react-toolkits 2.13.9 → 2.13.11
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/lib/index.d.ts +27 -20
- package/lib/index.js +134 -96
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { FC, PropsWithChildren, Key, ReactNode, ReactElement, Ref, ComponentType
|
|
|
3
3
|
import { ParagraphProps } from 'antd/es/typography/Paragraph';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { FormInstance, MenuProps, ModalProps, FormProps, ButtonProps } from 'antd';
|
|
6
|
+
import { AnyObject } from 'antd/es/_util/type';
|
|
6
7
|
import { TableProps } from 'antd/es/table';
|
|
7
8
|
import { AxiosHeaderValue, AxiosRequestConfig, AxiosInstance, InternalAxiosRequestConfig, AxiosResponse, AxiosInterceptorOptions } from 'axios';
|
|
8
9
|
import * as swr from 'swr';
|
|
@@ -12,7 +13,6 @@ import { Merge } from 'ts-essentials';
|
|
|
12
13
|
import * as zustand_middleware from 'zustand/middleware';
|
|
13
14
|
import { StateStorage } from 'zustand/middleware';
|
|
14
15
|
import * as zustand from 'zustand';
|
|
15
|
-
import { AnyObject } from 'antd/es/_util/type';
|
|
16
16
|
|
|
17
17
|
interface DynamicTagsProps {
|
|
18
18
|
initialTags?: string[];
|
|
@@ -44,26 +44,31 @@ interface HighlightProps extends PropsWithChildren {
|
|
|
44
44
|
}
|
|
45
45
|
declare const Highlight: (props: HighlightProps) => react_jsx_runtime.JSX.Element;
|
|
46
46
|
|
|
47
|
-
interface
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
interface InfiniteListRef<Item extends AnyObject = AnyObject, Values = AnyObject, Data = any> {
|
|
48
|
+
data: Data[] | undefined;
|
|
49
|
+
dataSource: Item[] | undefined;
|
|
50
|
+
form: FormInstance<Values>;
|
|
50
51
|
}
|
|
51
|
-
interface InfiniteListProps<Item, Values,
|
|
52
|
+
interface InfiniteListProps<Item, Values, Data> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
|
|
52
53
|
url: string;
|
|
53
|
-
getRowKey: (response:
|
|
54
|
-
getDataSource: (data:
|
|
54
|
+
getRowKey: (response: Data | undefined) => any;
|
|
55
|
+
getDataSource: (data: Data[] | undefined) => Item[];
|
|
56
|
+
form?: FormInstance<Values>;
|
|
55
57
|
code?: string;
|
|
56
58
|
headers?: {
|
|
57
59
|
[key: string]: AxiosHeaderValue;
|
|
58
60
|
} | ((form: FormInstance<Values>) => {
|
|
59
61
|
[key: string]: AxiosHeaderValue;
|
|
60
62
|
});
|
|
61
|
-
renderForm?: (form: FormInstance<Values>) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
renderForm?: (form: FormInstance<Values>) => ReactElement;
|
|
64
|
+
params: (values: Values, rowKey?: string) => Record<any, any>;
|
|
65
|
+
getHasMore?: (data: Data | undefined) => boolean;
|
|
66
|
+
tableExtra?: ReactNode | ((form: FormInstance<Values>) => ReactNode);
|
|
67
|
+
footer?: (data: (Data | undefined)[] | undefined) => ReactNode;
|
|
65
68
|
}
|
|
66
|
-
declare const InfiniteList: <Item extends
|
|
69
|
+
declare const InfiniteList: <Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any>(props: InfiniteListProps<Item, Values, Data> & {
|
|
70
|
+
ref?: Ref<InfiniteListRef<Item, Data>>;
|
|
71
|
+
}) => ReactElement;
|
|
67
72
|
|
|
68
73
|
type Area = 'all' | 'cn' | 'global';
|
|
69
74
|
type ScreenOrientation = 0 | 1;
|
|
@@ -170,7 +175,7 @@ declare function useFormModal<Values extends AnyObject = AnyObject, ExtraValues
|
|
|
170
175
|
id: number;
|
|
171
176
|
show: (options?: {
|
|
172
177
|
initialValues?: RecursivePartial<Values>;
|
|
173
|
-
extraValues
|
|
178
|
+
extraValues?: ExtraValues;
|
|
174
179
|
}) => void;
|
|
175
180
|
hide: () => void;
|
|
176
181
|
modal: react_jsx_runtime.JSX.Element;
|
|
@@ -385,9 +390,13 @@ interface ContextSlice {
|
|
|
385
390
|
}
|
|
386
391
|
|
|
387
392
|
interface GameSlice {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
gameId?: string | number;
|
|
394
|
+
setGameId: (id?: string | number) => void;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
interface SignInSlice {
|
|
398
|
+
unregistered: boolean;
|
|
399
|
+
setUnregistered: () => void;
|
|
391
400
|
}
|
|
392
401
|
|
|
393
402
|
interface UserInfo {
|
|
@@ -400,10 +409,8 @@ interface TokenSlice {
|
|
|
400
409
|
setToken: (token: string) => void;
|
|
401
410
|
}
|
|
402
411
|
|
|
403
|
-
type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & {
|
|
404
|
-
unregistered: boolean;
|
|
412
|
+
type ToolkitsState = TokenSlice & GameSlice & ContextSlice & AxiosSlice & SignInSlice & {
|
|
405
413
|
clearToken: () => void;
|
|
406
|
-
setUnregistered: () => void;
|
|
407
414
|
};
|
|
408
415
|
|
|
409
416
|
declare function useToolkitsStore<T>(selector: (state: ToolkitsState) => T): T;
|
|
@@ -475,4 +482,4 @@ declare const SignIn: FC<SignInProps>;
|
|
|
475
482
|
|
|
476
483
|
declare const mixedStorage: StateStorage;
|
|
477
484
|
|
|
478
|
-
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 LayoutProps, type LayoutState, type MenuListItem, NavMenu, type NavMenuItem, NotFound, _default$1 as OperationLogList, type Permission, PermissionButton, type PermissionButtonProps, PermissionVersion, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, RequireGame, RequirePermission, type RequirePermissionProps, SSO_URL, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseFormModalProps, UserWidget, WILDCARD, _default$2 as menuRoutes, mixedStorage, _default as permissionRoutes, useFindGame, useFormModal, useGames, useLayoutStore, useMenuList, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useToolkitsStore, withContext };
|
|
485
|
+
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 InfiniteListRef, type JsonData, Layout, type LayoutProps, type LayoutState, type MenuListItem, NavMenu, type NavMenuItem, NotFound, _default$1 as OperationLogList, type Permission, PermissionButton, type PermissionButtonProps, PermissionVersion, QueryList, QueryListAction, type QueryListPayload, type QueryListProps, type QueryListRef, RequireGame, RequirePermission, type RequirePermissionProps, SSO_URL, SignIn, ToolkitsProvider, type ToolkitsProviderProps, type UseFormModalProps, UserWidget, WILDCARD, _default$2 as menuRoutes, mixedStorage, _default as permissionRoutes, useFindGame, useFormModal, useGames, useLayoutStore, useMenuList, useModal, useModalStore, usePermission, usePermissions, useQueryListStore, useToolkitsStore, withContext };
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,10 @@ import { jwtDecode } from 'jwt-decode';
|
|
|
3
3
|
import { useStore, create, createStore } from 'zustand';
|
|
4
4
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
5
5
|
import * as Antd2 from 'antd';
|
|
6
|
-
import { Modal, Form,
|
|
7
|
-
import { lazy, useContext, useMemo, useState,
|
|
6
|
+
import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, theme, Space, Tag, Typography, Alert, Divider, Menu, App, Switch, InputNumber, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip, Popconfirm, Collapse, Checkbox } from 'antd';
|
|
7
|
+
import { forwardRef, lazy, useContext, useMemo, useState, useEffect, useImperativeHandle, cloneElement, useRef, createContext, memo, useCallback, Fragment as Fragment$1, Suspense } from 'react';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
import { has, template, get, isEqual,
|
|
9
|
+
import { last, has, template, get, isEqual, first } from 'lodash-es';
|
|
10
10
|
import { flushSync } from 'react-dom';
|
|
11
11
|
import { createRoot } from 'react-dom/client';
|
|
12
12
|
import useSWR5, { mutate, unstable_serialize } from 'swr';
|
|
@@ -192,12 +192,22 @@ var init_context = __esm({
|
|
|
192
192
|
var createGameSlice;
|
|
193
193
|
var init_game = __esm({
|
|
194
194
|
"src/stores/game.ts"() {
|
|
195
|
-
createGameSlice = (set
|
|
196
|
-
|
|
197
|
-
set({
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
createGameSlice = (set) => ({
|
|
196
|
+
setGameId: (id2) => {
|
|
197
|
+
set({ gameId: id2 });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// src/stores/signIn.ts
|
|
204
|
+
var createSignInSlice;
|
|
205
|
+
var init_signIn = __esm({
|
|
206
|
+
"src/stores/signIn.ts"() {
|
|
207
|
+
createSignInSlice = (set) => ({
|
|
208
|
+
unregistered: false,
|
|
209
|
+
setUnregistered() {
|
|
210
|
+
set({ unregistered: true });
|
|
201
211
|
}
|
|
202
212
|
});
|
|
203
213
|
}
|
|
@@ -228,26 +238,24 @@ var init_stores = __esm({
|
|
|
228
238
|
init_axios();
|
|
229
239
|
init_context();
|
|
230
240
|
init_game();
|
|
241
|
+
init_signIn();
|
|
231
242
|
init_token();
|
|
232
243
|
createToolkitsStore = (initProps) => {
|
|
233
244
|
return createStore()(
|
|
234
245
|
persist(
|
|
235
246
|
(...args) => {
|
|
236
|
-
const [
|
|
247
|
+
const [_set, get2, store] = args;
|
|
237
248
|
return {
|
|
238
249
|
...createTokenSlice(...args),
|
|
239
250
|
...createGameSlice(...args),
|
|
240
251
|
...createContextSlice(...args),
|
|
241
252
|
...createAxiosSlice(...args),
|
|
242
|
-
...
|
|
243
|
-
unregistered: false,
|
|
253
|
+
...createSignInSlice(...args),
|
|
244
254
|
clearToken() {
|
|
245
255
|
get2().setToken("");
|
|
246
256
|
store.persist.clearStorage();
|
|
247
257
|
},
|
|
248
|
-
|
|
249
|
-
set({ unregistered: true });
|
|
250
|
-
}
|
|
258
|
+
...initProps
|
|
251
259
|
};
|
|
252
260
|
},
|
|
253
261
|
{
|
|
@@ -255,7 +263,7 @@ var init_stores = __esm({
|
|
|
255
263
|
storage: createJSONStorage(() => mixedStorage),
|
|
256
264
|
partialize: (state) => ({
|
|
257
265
|
token: state.token,
|
|
258
|
-
|
|
266
|
+
gameId: state.gameId
|
|
259
267
|
})
|
|
260
268
|
}
|
|
261
269
|
)
|
|
@@ -270,17 +278,7 @@ var init_Interceptors = __esm({
|
|
|
270
278
|
init_toolkitsProvider();
|
|
271
279
|
Interceptors = ({ children }) => {
|
|
272
280
|
const { notification } = App.useApp();
|
|
273
|
-
const {
|
|
274
|
-
axios: axios2,
|
|
275
|
-
interceptors,
|
|
276
|
-
token,
|
|
277
|
-
isGlobal,
|
|
278
|
-
signInPath,
|
|
279
|
-
clearToken,
|
|
280
|
-
setUnregistered,
|
|
281
|
-
getGameId,
|
|
282
|
-
permissionVersion
|
|
283
|
-
} = useToolkitsStore((s) => s);
|
|
281
|
+
const { axios: axios2, interceptors, token, isGlobal, signInPath, gameId, clearToken, setUnregistered, permissionVersion } = useToolkitsStore((s) => s);
|
|
284
282
|
let requestInterceptorId;
|
|
285
283
|
let responseInterceptorId;
|
|
286
284
|
if (interceptors?.request) {
|
|
@@ -293,7 +291,6 @@ var init_Interceptors = __esm({
|
|
|
293
291
|
headers.setAuthorization(`Bearer ${token}`);
|
|
294
292
|
}
|
|
295
293
|
if (!headers.has(APP_ID_HEADER) && permissionVersion !== "v1" /* V1 */) {
|
|
296
|
-
const gameId = getGameId();
|
|
297
294
|
if (isGlobal || !gameId) {
|
|
298
295
|
headers.set(APP_ID_HEADER, "global");
|
|
299
296
|
} else {
|
|
@@ -521,20 +518,16 @@ var init_highlight = __esm({
|
|
|
521
518
|
}
|
|
522
519
|
});
|
|
523
520
|
function useMenuList() {
|
|
524
|
-
const {
|
|
525
|
-
const gameId = getGameId();
|
|
521
|
+
const { signInPath, axios: axios2 } = useToolkitsStore((s) => s);
|
|
526
522
|
return useSWR5(
|
|
527
|
-
window.location.pathname !== signInPath ?
|
|
528
|
-
([url4]) => axios2(url4
|
|
529
|
-
headers: { Authorization: `Bearer ${token}`, [APP_ID_HEADER]: gameId }
|
|
530
|
-
}).then((response) => response.data.data)
|
|
523
|
+
window.location.pathname !== signInPath ? "/api/usystem/menu/navbar" : null,
|
|
524
|
+
([url4]) => axios2(url4).then((response) => response.data.data)
|
|
531
525
|
);
|
|
532
526
|
}
|
|
533
527
|
var usePermissions, usePermission;
|
|
534
528
|
var init_hooks2 = __esm({
|
|
535
529
|
"src/hooks/index.ts"() {
|
|
536
530
|
init_toolkitsProvider();
|
|
537
|
-
init_constants();
|
|
538
531
|
usePermissions = (codes = [], config) => {
|
|
539
532
|
const { axios: axios2, permissionVersion } = useToolkitsStore((s) => s);
|
|
540
533
|
const { data, ...rest } = useSWR5(
|
|
@@ -731,7 +724,7 @@ var init_RequireGame = __esm({
|
|
|
731
724
|
init_toolkitsProvider();
|
|
732
725
|
({ Spin: Spin3 } = Antd2);
|
|
733
726
|
RequireGame = ({ children }) => {
|
|
734
|
-
const { permissionVersion,
|
|
727
|
+
const { permissionVersion, gameId, isGlobal } = useToolkitsStore((s) => s);
|
|
735
728
|
const { isLoading } = useGames();
|
|
736
729
|
const { t } = useTranslation();
|
|
737
730
|
if (isLoading) {
|
|
@@ -751,10 +744,9 @@ var init_RequireGame = __esm({
|
|
|
751
744
|
if (permissionVersion === "v1" /* V1 */ || isGlobal) {
|
|
752
745
|
return children;
|
|
753
746
|
}
|
|
754
|
-
if (!
|
|
747
|
+
if (!gameId) {
|
|
755
748
|
return /* @__PURE__ */ jsx(Empty, { image: Empty.PRESENTED_IMAGE_SIMPLE, description: t("RequireGame.description") });
|
|
756
749
|
}
|
|
757
|
-
const gameId = getGameId();
|
|
758
750
|
return /* @__PURE__ */ jsx(Fragment$1, { children }, gameId);
|
|
759
751
|
};
|
|
760
752
|
RequireGame_default = RequireGame;
|
|
@@ -836,28 +828,24 @@ var init_GameSelect = __esm({
|
|
|
836
828
|
GameSelect = (props) => {
|
|
837
829
|
const { filter } = props;
|
|
838
830
|
const { t } = useTranslation();
|
|
839
|
-
const { gameApiV2,
|
|
831
|
+
const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
|
|
840
832
|
const { data, isLoading } = useGames();
|
|
841
|
-
const defaultValue = getGameId();
|
|
842
|
-
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
843
833
|
const options = data?.filter((item) => filter?.(item) ?? true)?.map((item) => ({
|
|
844
834
|
label: item.name,
|
|
845
835
|
value: gameApiV2 ? item.game_id : item.id
|
|
846
836
|
}));
|
|
847
|
-
const findGame = (value) => data?.find((item) => String(gameApiV2 ? item.game_id : item.id) === String(value));
|
|
848
837
|
const onChange = async (value) => {
|
|
849
|
-
|
|
850
|
-
setGame(game);
|
|
851
|
-
setInternalValue(value);
|
|
838
|
+
setGameId(value);
|
|
852
839
|
};
|
|
853
840
|
useEffect(() => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
const game = findGame(gameId);
|
|
858
|
-
setGame(game);
|
|
841
|
+
let id2 = gameId;
|
|
842
|
+
if (data?.every((item) => String(gameApiV2 ? item.game_id : item.id) !== String(id2))) {
|
|
843
|
+
id2 = gameApiV2 ? data?.[0]?.game_id : data?.[0]?.id;
|
|
859
844
|
}
|
|
860
|
-
|
|
845
|
+
if (id2 !== gameId) {
|
|
846
|
+
setGameId(id2);
|
|
847
|
+
}
|
|
848
|
+
}, [gameId, data, gameApiV2]);
|
|
861
849
|
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
862
850
|
/* @__PURE__ */ jsx(Text, { children: t("GameSelect.label") }),
|
|
863
851
|
/* @__PURE__ */ jsx(
|
|
@@ -865,7 +853,7 @@ var init_GameSelect = __esm({
|
|
|
865
853
|
{
|
|
866
854
|
showSearch: true,
|
|
867
855
|
optionFilterProp: "label",
|
|
868
|
-
value:
|
|
856
|
+
value: gameId,
|
|
869
857
|
placeholder: t("GameSelect.placeholder"),
|
|
870
858
|
loading: isLoading,
|
|
871
859
|
style: { width: "200px" },
|
|
@@ -2665,9 +2653,11 @@ var init_userDetail = __esm({
|
|
|
2665
2653
|
"src/pages/permission/userDetail/index.tsx"() {
|
|
2666
2654
|
init_layout();
|
|
2667
2655
|
init_locale();
|
|
2656
|
+
init_permissionButton();
|
|
2668
2657
|
init_toolkitsProvider();
|
|
2669
2658
|
init_constants();
|
|
2670
2659
|
init_permission();
|
|
2660
|
+
init_hooks2();
|
|
2671
2661
|
UserDetail = () => {
|
|
2672
2662
|
const { message } = App.useApp();
|
|
2673
2663
|
const params = useParams();
|
|
@@ -2678,6 +2668,7 @@ var init_userDetail = __esm({
|
|
|
2678
2668
|
(url4) => axios2.get(url4).then((res) => res.data.data)
|
|
2679
2669
|
);
|
|
2680
2670
|
const { data: games } = useGames();
|
|
2671
|
+
const { accessible: roleViewable } = usePermission("200005");
|
|
2681
2672
|
const { show, modal } = useUpdateUserModalV2({
|
|
2682
2673
|
onSuccess() {
|
|
2683
2674
|
mutate2();
|
|
@@ -2690,7 +2681,9 @@ var init_userDetail = __esm({
|
|
|
2690
2681
|
title: t("global.projectGroup"),
|
|
2691
2682
|
dataIndex: "game_group",
|
|
2692
2683
|
render(value) {
|
|
2693
|
-
return value.map((item) =>
|
|
2684
|
+
return value.map((item) => {
|
|
2685
|
+
return /* @__PURE__ */ jsx(Tag, { children: item === WILDCARD ? "\u901A\u7528" : item }, item);
|
|
2686
|
+
});
|
|
2694
2687
|
}
|
|
2695
2688
|
},
|
|
2696
2689
|
{
|
|
@@ -2709,7 +2702,7 @@ var init_userDetail = __esm({
|
|
|
2709
2702
|
title: t("global.role"),
|
|
2710
2703
|
dataIndex: "role",
|
|
2711
2704
|
render(value) {
|
|
2712
|
-
return /* @__PURE__ */ jsx(Link, { to: `../../role/${value}`, relative: "path", children: value });
|
|
2705
|
+
return roleViewable ? /* @__PURE__ */ jsx(Link, { to: `../../role/${value}`, relative: "path", children: value }) : value;
|
|
2713
2706
|
}
|
|
2714
2707
|
}
|
|
2715
2708
|
];
|
|
@@ -2736,8 +2729,9 @@ var init_userDetail = __esm({
|
|
|
2736
2729
|
title: "\u7528\u6237\u8BE6\u60C5",
|
|
2737
2730
|
loading: isLoading,
|
|
2738
2731
|
extra: /* @__PURE__ */ jsx(
|
|
2739
|
-
|
|
2732
|
+
PermissionButton_default,
|
|
2740
2733
|
{
|
|
2734
|
+
code: "100003",
|
|
2741
2735
|
onClick: () => {
|
|
2742
2736
|
show({
|
|
2743
2737
|
initialValues: {
|
|
@@ -2941,6 +2935,7 @@ var RoleDetail, roleDetail_default;
|
|
|
2941
2935
|
var init_roleDetail = __esm({
|
|
2942
2936
|
"src/pages/permission/roleDetail/index.tsx"() {
|
|
2943
2937
|
init_locale();
|
|
2938
|
+
init_permissionButton();
|
|
2944
2939
|
init_toolkitsProvider();
|
|
2945
2940
|
init_permission();
|
|
2946
2941
|
RoleDetail = () => {
|
|
@@ -2982,14 +2977,21 @@ var init_roleDetail = __esm({
|
|
|
2982
2977
|
]
|
|
2983
2978
|
}
|
|
2984
2979
|
),
|
|
2985
|
-
/* @__PURE__ */ jsx(
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
/* @__PURE__ */ jsx(
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2980
|
+
/* @__PURE__ */ jsx(
|
|
2981
|
+
Card,
|
|
2982
|
+
{
|
|
2983
|
+
title: t("RoleDetail.title"),
|
|
2984
|
+
extra: /* @__PURE__ */ jsx(PermissionButton_default, { code: "200003", onClick: handleUpdateBtnClick, children: t("global.update") }),
|
|
2985
|
+
children: /* @__PURE__ */ jsxs(Skeleton, { loading: isLoading, children: [
|
|
2986
|
+
/* @__PURE__ */ jsxs(Descriptions, { column: 2, layout: "vertical", className: "mb-6", children: [
|
|
2987
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: t("global.name"), children: data?.name }),
|
|
2988
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: "ID", children: data?.id }),
|
|
2989
|
+
/* @__PURE__ */ jsx(Descriptions.Item, { label: t("global.creationTime"), children: data?.ctime })
|
|
2990
|
+
] }),
|
|
2991
|
+
/* @__PURE__ */ jsx(permissionList_default, { readonly: true, value: data?.permissions })
|
|
2992
|
+
] })
|
|
2993
|
+
}
|
|
2994
|
+
),
|
|
2993
2995
|
modal
|
|
2994
2996
|
] });
|
|
2995
2997
|
};
|
|
@@ -3156,27 +3158,43 @@ init_hooks2();
|
|
|
3156
3158
|
init_filterFormWrapper();
|
|
3157
3159
|
init_locale();
|
|
3158
3160
|
init_toolkitsProvider();
|
|
3159
|
-
var
|
|
3160
|
-
const {
|
|
3161
|
+
var InternalInfiniteList = (props, ref) => {
|
|
3162
|
+
const {
|
|
3163
|
+
code,
|
|
3164
|
+
url: url4,
|
|
3165
|
+
tableExtra,
|
|
3166
|
+
headers,
|
|
3167
|
+
getRowKey,
|
|
3168
|
+
getDataSource,
|
|
3169
|
+
getHasMore,
|
|
3170
|
+
renderForm,
|
|
3171
|
+
params,
|
|
3172
|
+
footer,
|
|
3173
|
+
form,
|
|
3174
|
+
buttonsAlign,
|
|
3175
|
+
showReset,
|
|
3176
|
+
...tableProps
|
|
3177
|
+
} = props;
|
|
3161
3178
|
const { t } = useTranslation();
|
|
3162
|
-
const [
|
|
3179
|
+
const [_form] = Form.useForm(form);
|
|
3163
3180
|
const [isValid, setIsValid] = useState(false);
|
|
3164
3181
|
const [formValues, setFormValues] = useState();
|
|
3165
3182
|
const { axios: axios2 } = useToolkitsStore((s) => s);
|
|
3166
3183
|
const getKey = (pageIndex, previousPageData) => {
|
|
3167
3184
|
if (!isValid) return null;
|
|
3168
3185
|
const rowKey = pageIndex !== 0 ? getRowKey(previousPageData) : void 0;
|
|
3169
|
-
const args =
|
|
3186
|
+
const args = params(formValues, rowKey);
|
|
3170
3187
|
const queryString = qs.stringify(args);
|
|
3171
3188
|
return queryString ? `${url4}?${qs.stringify(args)}` : url4;
|
|
3172
3189
|
};
|
|
3173
|
-
const _headers = typeof headers === "function" ? headers(
|
|
3190
|
+
const _headers = typeof headers === "function" ? headers(_form) : headers;
|
|
3174
3191
|
const { accessible, isLoading } = usePermission(code);
|
|
3175
3192
|
const {
|
|
3176
3193
|
data,
|
|
3177
3194
|
size,
|
|
3178
3195
|
setSize,
|
|
3179
|
-
isValidating: isListValidating
|
|
3196
|
+
isValidating: isListValidating,
|
|
3197
|
+
mutate: mutate2
|
|
3180
3198
|
} = useSWRInfinite(
|
|
3181
3199
|
getKey,
|
|
3182
3200
|
async (arg) => {
|
|
@@ -3191,15 +3209,16 @@ var InfiniteList = (props) => {
|
|
|
3191
3209
|
);
|
|
3192
3210
|
const dataSource = getDataSource(data);
|
|
3193
3211
|
const isLoadingMore = isListValidating || size > 0 && data && typeof data[size - 1] === "undefined";
|
|
3194
|
-
const isReachingEnd = typeof
|
|
3212
|
+
const isReachingEnd = typeof getHasMore !== "undefined" ? !getHasMore(last(data)) : true;
|
|
3195
3213
|
const isEmpty = !dataSource || dataSource.length === 0;
|
|
3196
3214
|
const onConfirm = async () => {
|
|
3197
|
-
const values = await
|
|
3215
|
+
const values = await _form.getFieldsValue();
|
|
3198
3216
|
setFormValues(values);
|
|
3199
3217
|
try {
|
|
3200
|
-
await
|
|
3201
|
-
setSize(1);
|
|
3218
|
+
await _form.validateFields();
|
|
3202
3219
|
setIsValid(true);
|
|
3220
|
+
setSize(1);
|
|
3221
|
+
mutate2();
|
|
3203
3222
|
} catch (_) {
|
|
3204
3223
|
setSize(0);
|
|
3205
3224
|
setIsValid(false);
|
|
@@ -3210,23 +3229,30 @@ var InfiniteList = (props) => {
|
|
|
3210
3229
|
};
|
|
3211
3230
|
const onReset = async () => {
|
|
3212
3231
|
try {
|
|
3213
|
-
|
|
3214
|
-
await
|
|
3232
|
+
_form.resetFields();
|
|
3233
|
+
await _form.validateFields({ validateOnly: true });
|
|
3215
3234
|
setSize(1);
|
|
3216
3235
|
} catch (error) {
|
|
3217
3236
|
setSize(0);
|
|
3218
3237
|
}
|
|
3219
3238
|
};
|
|
3220
3239
|
useEffect(() => {
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3240
|
+
setTimeout(() => {
|
|
3241
|
+
if (accessible) {
|
|
3242
|
+
_form.validateFields({ validateOnly: true }).then((values) => {
|
|
3243
|
+
setFormValues(values);
|
|
3244
|
+
setIsValid(true);
|
|
3245
|
+
}).catch(() => {
|
|
3246
|
+
setIsValid(false);
|
|
3247
|
+
});
|
|
3248
|
+
}
|
|
3249
|
+
}, 300);
|
|
3229
3250
|
}, [accessible]);
|
|
3251
|
+
useImperativeHandle(ref, () => ({
|
|
3252
|
+
data,
|
|
3253
|
+
dataSource,
|
|
3254
|
+
form: _form
|
|
3255
|
+
}));
|
|
3230
3256
|
if (isLoading) {
|
|
3231
3257
|
return /* @__PURE__ */ jsx(
|
|
3232
3258
|
Spin,
|
|
@@ -3243,20 +3269,31 @@ var InfiniteList = (props) => {
|
|
|
3243
3269
|
if (!accessible) {
|
|
3244
3270
|
return /* @__PURE__ */ jsx(Result, { status: 403, subTitle: t("global.noEntitlement") });
|
|
3245
3271
|
}
|
|
3272
|
+
const renderFooter = footer && (() => footer(data));
|
|
3273
|
+
const formRenderer = typeof renderForm === "function" ? /* @__PURE__ */ jsx(
|
|
3274
|
+
FilterFormWrapper_default,
|
|
3275
|
+
{
|
|
3276
|
+
showReset,
|
|
3277
|
+
buttonsAlign,
|
|
3278
|
+
isConfirming: isListValidating,
|
|
3279
|
+
onReset,
|
|
3280
|
+
onConfirm,
|
|
3281
|
+
children: cloneElement(renderForm(_form), {
|
|
3282
|
+
onKeyUp: (e) => {
|
|
3283
|
+
if (e.key === "Enter") {
|
|
3284
|
+
onConfirm();
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
})
|
|
3288
|
+
}
|
|
3289
|
+
) : (
|
|
3290
|
+
// 屏蔽 Form 组件的警告(Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?)
|
|
3291
|
+
/* @__PURE__ */ jsx(Form, { form: _form })
|
|
3292
|
+
);
|
|
3246
3293
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
extras: extras?.map((extra) => ({
|
|
3251
|
-
key: extra.key,
|
|
3252
|
-
children: typeof extra.children === "function" ? extra.children(form) : extra.children
|
|
3253
|
-
})),
|
|
3254
|
-
onReset,
|
|
3255
|
-
onConfirm,
|
|
3256
|
-
children: renderForm(form)
|
|
3257
|
-
}
|
|
3258
|
-
) : /* @__PURE__ */ jsx(Form, { form }),
|
|
3259
|
-
/* @__PURE__ */ jsx(Table, { ...tableProps, dataSource, loading: isLoadingMore, pagination: false }),
|
|
3294
|
+
formRenderer,
|
|
3295
|
+
typeof tableExtra === "function" ? tableExtra(_form) : tableExtra,
|
|
3296
|
+
/* @__PURE__ */ jsx(Table, { ...tableProps, dataSource, loading: isLoadingMore, pagination: false, footer: renderFooter }),
|
|
3260
3297
|
!isEmpty && /* @__PURE__ */ jsx(
|
|
3261
3298
|
Button,
|
|
3262
3299
|
{
|
|
@@ -3271,6 +3308,7 @@ var InfiniteList = (props) => {
|
|
|
3271
3308
|
)
|
|
3272
3309
|
] });
|
|
3273
3310
|
};
|
|
3311
|
+
var InfiniteList = forwardRef(InternalInfiniteList);
|
|
3274
3312
|
var InfiniteList_default = InfiniteList;
|
|
3275
3313
|
|
|
3276
3314
|
// src/index.ts
|