react-toolkits 2.13.36 → 2.14.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 +12 -0
- package/lib/index.d.ts +4 -4
- package/lib/index.js +53 -45
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# react-toolkits
|
|
2
2
|
|
|
3
|
+
## 2.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 751ca52: fix: cancel games fetching when current permission is V1
|
|
8
|
+
|
|
9
|
+
## 2.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 17b672d: feat: refactor InifinitList
|
|
14
|
+
|
|
3
15
|
## 2.13.36
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ interface InfiniteListRef<Item = any, Values = any, Data = any> {
|
|
|
60
60
|
}
|
|
61
61
|
interface InfiniteListProps<Item, Values, Data> extends Pick<TableProps<Item>, 'columns' | 'rowKey' | 'tableLayout' | 'expandable' | 'rowSelection' | 'bordered'>, Pick<FilterFormWrapperProps, 'buttonsAlign' | 'showReset'> {
|
|
62
62
|
url: string;
|
|
63
|
-
getRowKey
|
|
63
|
+
getRowKey?: (response: Data | undefined, pageIndex: number) => any;
|
|
64
64
|
getDataSource: (data: Data[] | undefined) => Item[];
|
|
65
65
|
form?: FormInstance<Values>;
|
|
66
66
|
code?: string;
|
|
@@ -70,10 +70,10 @@ interface InfiniteListProps<Item, Values, Data> extends Pick<TableProps<Item>, '
|
|
|
70
70
|
[key: string]: AxiosHeaderValue;
|
|
71
71
|
});
|
|
72
72
|
renderForm?: (form: FormInstance<Values>) => ReactElement;
|
|
73
|
-
params: (values: Values, rowKey?: string) => Record<any, any>;
|
|
73
|
+
params: (values: Values, pageIndex: number, rowKey?: string) => Record<any, any>;
|
|
74
74
|
getHasMore?: (data: Data | undefined) => boolean;
|
|
75
|
-
tableExtra?: ReactNode | ((form: FormInstance<Values
|
|
76
|
-
footer?: (data:
|
|
75
|
+
tableExtra?: ReactNode | ((form: FormInstance<Values>, data?: Item[]) => ReactNode);
|
|
76
|
+
footer?: (data: Data[] | undefined) => ReactNode;
|
|
77
77
|
}
|
|
78
78
|
declare const InfiniteList: <Item extends AnyObject = AnyObject, Values extends object | undefined = undefined, Data = any>(props: InfiniteListProps<Item, Values, Data> & {
|
|
79
79
|
ref?: Ref<InfiniteListRef<Item, Data>>;
|
package/lib/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import { persist, createJSONStorage } from 'zustand/middleware';
|
|
|
5
5
|
import logoUrl from './logo-L6MFCL6M.png';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import * as Antd2 from 'antd';
|
|
8
|
-
import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, App, Switch, InputNumber, theme, Space, Tag, Typography, Alert, Divider, Menu, Popconfirm, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip,
|
|
8
|
+
import { Modal, Form, Spin, Result, Table, Button, Card, Input, Select, App, Switch, InputNumber, theme, Space, Tag, Typography, Alert, Divider, Menu, Popconfirm, Row, Col, Breadcrumb, Descriptions, Skeleton, Empty, Dropdown, Tooltip, Checkbox, Collapse } from 'antd';
|
|
9
9
|
import { Routes, Route, Navigate, useNavigate, useParams, useLocation, Link } from 'react-router-dom';
|
|
10
10
|
import useSWR6, { mutate, unstable_serialize, useSWRConfig } from 'swr';
|
|
11
|
-
import { forwardRef, lazy, useContext, useMemo, useState, useEffect, useImperativeHandle, cloneElement, useRef, createContext, memo, useCallback, Fragment as Fragment$1, Suspense } from 'react';
|
|
11
|
+
import { forwardRef, lazy, useContext, useMemo, useState, useEffect, useImperativeHandle, cloneElement, useRef, createContext, memo, useCallback, Fragment as Fragment$1, Suspense, useTransition } from 'react';
|
|
12
12
|
import { last, has, template, get, isEqual, first } from 'lodash-es';
|
|
13
13
|
import { flushSync } from 'react-dom';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
@@ -665,16 +665,19 @@ var init_hooks3 = __esm({
|
|
|
665
665
|
"src/components/layout/hooks.ts"() {
|
|
666
666
|
init_toolkitsProvider();
|
|
667
667
|
useGames = () => {
|
|
668
|
-
const { axios: axios2, gameApiV2 } = useToolkitsStore((s) => s);
|
|
669
|
-
return useSWR6(
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
668
|
+
const { axios: axios2, gameApiV2, permissionVersion } = useToolkitsStore((s) => s);
|
|
669
|
+
return useSWR6(
|
|
670
|
+
permissionVersion !== "v1" /* V1 */ ? gameApiV2 ? "/api/game/list" : "/api/usystem/game/all" : null,
|
|
671
|
+
async (url4) => {
|
|
672
|
+
if (gameApiV2) {
|
|
673
|
+
const response = await axios2(url4);
|
|
674
|
+
return response.data.data.list ?? [];
|
|
675
|
+
} else {
|
|
676
|
+
const response = await axios2(url4);
|
|
677
|
+
return response.data.data ?? [];
|
|
678
|
+
}
|
|
676
679
|
}
|
|
677
|
-
|
|
680
|
+
);
|
|
678
681
|
};
|
|
679
682
|
useFindGame = (id2) => {
|
|
680
683
|
const { data } = useGames();
|
|
@@ -2288,6 +2291,7 @@ var init_permissionCollapse = __esm({
|
|
|
2288
2291
|
const [checkedMap, setCheckedMap] = useState({});
|
|
2289
2292
|
const [internalValue, setInternalValue] = useState(value ?? []);
|
|
2290
2293
|
const { t } = useTranslation();
|
|
2294
|
+
const [, startTransition] = useTransition();
|
|
2291
2295
|
const onCollapseChange = useCallback((key) => {
|
|
2292
2296
|
setActiveKey(key);
|
|
2293
2297
|
}, []);
|
|
@@ -2316,9 +2320,11 @@ var init_permissionCollapse = __esm({
|
|
|
2316
2320
|
}, [value]);
|
|
2317
2321
|
useEffect(() => {
|
|
2318
2322
|
if (expand) {
|
|
2319
|
-
|
|
2323
|
+
startTransition(() => {
|
|
2324
|
+
setActiveKey((permissions ?? []).map(({ category }) => category));
|
|
2325
|
+
});
|
|
2320
2326
|
}
|
|
2321
|
-
}, [
|
|
2327
|
+
}, []);
|
|
2322
2328
|
useEffect(() => {
|
|
2323
2329
|
const checkedValue = (permissions ?? []).reduce(
|
|
2324
2330
|
(acc, curr) => {
|
|
@@ -2329,39 +2335,40 @@ var init_permissionCollapse = __esm({
|
|
|
2329
2335
|
);
|
|
2330
2336
|
setCheckedMap(checkedValue);
|
|
2331
2337
|
}, [internalValue, permissions]);
|
|
2338
|
+
const items = (permissions ?? []).map((item) => ({
|
|
2339
|
+
key: item.category,
|
|
2340
|
+
label: item.category,
|
|
2341
|
+
extra: !readonly && /* @__PURE__ */ jsx(
|
|
2342
|
+
Checkbox,
|
|
2343
|
+
{
|
|
2344
|
+
checked: checkedMap[item.category],
|
|
2345
|
+
onChange: (e) => {
|
|
2346
|
+
onCheckChange(
|
|
2347
|
+
e,
|
|
2348
|
+
item.permissions?.map((permission) => permission.value)
|
|
2349
|
+
);
|
|
2350
|
+
},
|
|
2351
|
+
children: t("global.selectAll")
|
|
2352
|
+
}
|
|
2353
|
+
),
|
|
2354
|
+
children: /* @__PURE__ */ jsx(Checkbox.Group, { style: { width: "100%" }, value: internalValue, disabled: readonly, children: /* @__PURE__ */ jsx(Row, { gutter: [10, 10], style: { width: "100%" }, children: item.permissions?.map((permission) => /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsx(
|
|
2355
|
+
Checkbox,
|
|
2356
|
+
{
|
|
2357
|
+
value: permission.value,
|
|
2358
|
+
onChange: (e) => {
|
|
2359
|
+
onCheckChange(e, [permission.value]);
|
|
2360
|
+
},
|
|
2361
|
+
children: permission.label
|
|
2362
|
+
}
|
|
2363
|
+
) }, permission.value)) }) })
|
|
2364
|
+
}));
|
|
2332
2365
|
return /* @__PURE__ */ jsx(
|
|
2333
2366
|
Collapse,
|
|
2334
2367
|
{
|
|
2335
2368
|
style: { width: "100%" },
|
|
2336
2369
|
collapsible: "header",
|
|
2337
2370
|
activeKey,
|
|
2338
|
-
items
|
|
2339
|
-
key: item.category,
|
|
2340
|
-
label: item.category,
|
|
2341
|
-
extra: !readonly && /* @__PURE__ */ jsx(
|
|
2342
|
-
Checkbox,
|
|
2343
|
-
{
|
|
2344
|
-
checked: checkedMap[item.category],
|
|
2345
|
-
onChange: (e) => {
|
|
2346
|
-
onCheckChange(
|
|
2347
|
-
e,
|
|
2348
|
-
item.permissions?.map((permission) => permission.value)
|
|
2349
|
-
);
|
|
2350
|
-
},
|
|
2351
|
-
children: t("global.selectAll")
|
|
2352
|
-
}
|
|
2353
|
-
),
|
|
2354
|
-
children: /* @__PURE__ */ jsx(Checkbox.Group, { style: { width: "100%" }, value: internalValue, disabled: readonly, children: /* @__PURE__ */ jsx(Row, { gutter: [10, 10], style: { width: "100%" }, children: item.permissions?.map((permission) => /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsx(
|
|
2355
|
-
Checkbox,
|
|
2356
|
-
{
|
|
2357
|
-
value: permission.value,
|
|
2358
|
-
onChange: (e) => {
|
|
2359
|
-
onCheckChange(e, [permission.value]);
|
|
2360
|
-
},
|
|
2361
|
-
children: permission.label
|
|
2362
|
-
}
|
|
2363
|
-
) }, permission.value)) }) })
|
|
2364
|
-
})),
|
|
2371
|
+
items,
|
|
2365
2372
|
onChange: onCollapseChange
|
|
2366
2373
|
}
|
|
2367
2374
|
);
|
|
@@ -2572,6 +2579,7 @@ var init_userList = __esm({
|
|
|
2572
2579
|
const remove = useRemoveUser();
|
|
2573
2580
|
const { mutate: mutate2, refetch } = useQueryListStore();
|
|
2574
2581
|
const { permissionVersion } = useToolkitsStore((s) => s);
|
|
2582
|
+
const isV1 = permissionVersion === "v1" /* V1 */;
|
|
2575
2583
|
const isV3 = permissionVersion === "v3" /* V3 */;
|
|
2576
2584
|
const { show: showCreateModal, modal: createModal } = useCreateUserModal({
|
|
2577
2585
|
onSuccess() {
|
|
@@ -2614,7 +2622,7 @@ var init_userList = __esm({
|
|
|
2614
2622
|
dataIndex: "id",
|
|
2615
2623
|
key: "id"
|
|
2616
2624
|
},
|
|
2617
|
-
isV3 && {
|
|
2625
|
+
(isV1 || isV3) && {
|
|
2618
2626
|
title: t("global.role"),
|
|
2619
2627
|
dataIndex: "roles",
|
|
2620
2628
|
key: "roles",
|
|
@@ -3286,8 +3294,8 @@ var InternalInfiniteList = (props, ref) => {
|
|
|
3286
3294
|
const { axios: axios2 } = useToolkitsStore((s) => s);
|
|
3287
3295
|
const getKey = (pageIndex, previousPageData) => {
|
|
3288
3296
|
if (!isValid) return null;
|
|
3289
|
-
const rowKey =
|
|
3290
|
-
const args = params(formValues, rowKey);
|
|
3297
|
+
const rowKey = getRowKey?.(previousPageData, pageIndex);
|
|
3298
|
+
const args = params(formValues, pageIndex, rowKey);
|
|
3291
3299
|
const queryString = qs.stringify(args);
|
|
3292
3300
|
return queryString ? `${url4}?${qs.stringify(args)}` : url4;
|
|
3293
3301
|
};
|
|
@@ -3313,7 +3321,7 @@ var InternalInfiniteList = (props, ref) => {
|
|
|
3313
3321
|
);
|
|
3314
3322
|
const dataSource = getDataSource(data);
|
|
3315
3323
|
const isLoadingMore = isListValidating || size > 0 && data && typeof data[size - 1] === "undefined";
|
|
3316
|
-
const isReachingEnd = typeof getHasMore !== "undefined" ? !getHasMore(last(data)) :
|
|
3324
|
+
const isReachingEnd = typeof getHasMore !== "undefined" ? !getHasMore(last(data)) : false;
|
|
3317
3325
|
const isEmpty = !dataSource || dataSource.length === 0;
|
|
3318
3326
|
const onConfirm = async () => {
|
|
3319
3327
|
const values = await _form.getFieldsValue();
|
|
@@ -3398,7 +3406,7 @@ var InternalInfiniteList = (props, ref) => {
|
|
|
3398
3406
|
);
|
|
3399
3407
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3400
3408
|
formRenderer,
|
|
3401
|
-
typeof tableExtra === "function" ? tableExtra(_form) : tableExtra,
|
|
3409
|
+
typeof tableExtra === "function" ? tableExtra(_form, dataSource) : tableExtra,
|
|
3402
3410
|
/* @__PURE__ */ jsx(Table, { ...tableProps, dataSource, loading: isLoadingMore, pagination: false, footer: renderFooter }),
|
|
3403
3411
|
!isEmpty && /* @__PURE__ */ jsx(
|
|
3404
3412
|
Button,
|