react-toolkits 2.13.4 → 2.13.6
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.js +42 -12
- package/lib/index.js.map +1 -1
- package/locale/hooks.js.map +1 -1
- package/locale/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -378,7 +378,7 @@ function useToolkitsStore(selector) {
|
|
|
378
378
|
if (!store) throw new Error("Missing ToolkitsProvider in the tree");
|
|
379
379
|
return useStore(store, selector);
|
|
380
380
|
}
|
|
381
|
-
var ToolkitsContext,
|
|
381
|
+
var ToolkitsContext, ToolkitsProvider, withContext, ToolkitsProvider_default;
|
|
382
382
|
var init_ToolkitsProvider = __esm({
|
|
383
383
|
"src/components/toolkitsProvider/ToolkitsProvider.tsx"() {
|
|
384
384
|
init_stores();
|
|
@@ -387,14 +387,14 @@ var init_ToolkitsProvider = __esm({
|
|
|
387
387
|
ToolkitsProvider = (props) => {
|
|
388
388
|
const { children, ...restProps } = props;
|
|
389
389
|
const storeRef = useRef();
|
|
390
|
+
const parentState = useContext(ToolkitsContext)?.getState();
|
|
390
391
|
if (!storeRef.current) {
|
|
391
392
|
storeRef.current = createToolkitsStore({
|
|
392
|
-
...
|
|
393
|
+
...parentState,
|
|
393
394
|
...restProps
|
|
394
395
|
});
|
|
395
396
|
}
|
|
396
|
-
|
|
397
|
-
if (!globalState.signInPath) {
|
|
397
|
+
if (!storeRef.current.getState().signInPath) {
|
|
398
398
|
throw new Error('ToolkitsProvider: \u8BF7\u914D\u7F6E "signInPath"');
|
|
399
399
|
}
|
|
400
400
|
return /* @__PURE__ */ jsx(ToolkitsContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsx(App, { children: /* @__PURE__ */ jsx(Interceptors_default, { children }) }) });
|
|
@@ -1868,7 +1868,7 @@ function useRemoveUser() {
|
|
|
1868
1868
|
}) => axios2.post(url4, arg)
|
|
1869
1869
|
);
|
|
1870
1870
|
}
|
|
1871
|
-
var Text2, useCreateRoleModal, useUpdateRoleModal, useCreateUserModal, useUpdateUserModal, GameSelect2, UserModalContentV2, useCreateUserModalV2, useUpdateUserModalV2;
|
|
1871
|
+
var Text2, useCreateRoleModal, useUpdateRoleModal, useCreateUserModal, useUpdateUserModal, GroupSelect, GameSelect2, UserModalContentV2, useCreateUserModalV2, useUpdateUserModalV2;
|
|
1872
1872
|
var init_hooks5 = __esm({
|
|
1873
1873
|
"src/features/permission/hooks/index.tsx"() {
|
|
1874
1874
|
init_locale();
|
|
@@ -1985,6 +1985,39 @@ var init_hooks5 = __esm({
|
|
|
1985
1985
|
}
|
|
1986
1986
|
});
|
|
1987
1987
|
};
|
|
1988
|
+
GroupSelect = (props) => {
|
|
1989
|
+
const { onChange, ...rest } = props;
|
|
1990
|
+
const { axios: axios2 } = useToolkitsStore((s) => s);
|
|
1991
|
+
const { data, isLoading } = useSWR5(
|
|
1992
|
+
"/api/enum/get?enum=game_group&type=all",
|
|
1993
|
+
(path) => axios2.get(path).then((response) => response.data.data)
|
|
1994
|
+
);
|
|
1995
|
+
const options = [{ label: "\u901A\u7528", value: WILDCARD }].concat(
|
|
1996
|
+
data?.map((group) => ({ label: group, value: group })) ?? []
|
|
1997
|
+
);
|
|
1998
|
+
const onValueChange = (value) => {
|
|
1999
|
+
if (last(value) === WILDCARD) {
|
|
2000
|
+
onChange?.([WILDCARD]);
|
|
2001
|
+
} else if (first(value) === WILDCARD) {
|
|
2002
|
+
onChange?.(value.slice(1));
|
|
2003
|
+
} else {
|
|
2004
|
+
onChange?.(value);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
return /* @__PURE__ */ jsx(
|
|
2008
|
+
Select,
|
|
2009
|
+
{
|
|
2010
|
+
...rest,
|
|
2011
|
+
allowClear: true,
|
|
2012
|
+
showSearch: true,
|
|
2013
|
+
mode: "tags",
|
|
2014
|
+
optionFilterProp: "label",
|
|
2015
|
+
loading: isLoading,
|
|
2016
|
+
options,
|
|
2017
|
+
onChange: onValueChange
|
|
2018
|
+
}
|
|
2019
|
+
);
|
|
2020
|
+
};
|
|
1988
2021
|
GameSelect2 = (props) => {
|
|
1989
2022
|
const { groups, onChange, ...rest } = props;
|
|
1990
2023
|
const { axios: axios2 } = useToolkitsStore((s) => s);
|
|
@@ -2024,6 +2057,9 @@ var init_hooks5 = __esm({
|
|
|
2024
2057
|
"/api/enum/get?enum=game_group&type=all",
|
|
2025
2058
|
(path) => axios2.get(path).then((response) => response.data.data)
|
|
2026
2059
|
);
|
|
2060
|
+
[{ label: "\u901A\u7528", value: WILDCARD }].concat(
|
|
2061
|
+
groups?.map((group) => ({ label: group, value: group })) ?? []
|
|
2062
|
+
);
|
|
2027
2063
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2028
2064
|
/* @__PURE__ */ jsx(Form.Item, { label: t("global.name"), name: "name", rules: [{ required: true }], children: /* @__PURE__ */ jsx(Input, { disabled: !isCreate }) }),
|
|
2029
2065
|
/* @__PURE__ */ jsx(Form.List, { name: "permissions", children: (fields, { add, remove }) => /* @__PURE__ */ jsxs(Row, { gutter: 8, children: [
|
|
@@ -2032,14 +2068,8 @@ var init_hooks5 = __esm({
|
|
|
2032
2068
|
/* @__PURE__ */ jsx(Col, { span: 6, className: "text-center mb-4", children: /* @__PURE__ */ jsx(Text2, { strong: true, children: t("global.role") }) }),
|
|
2033
2069
|
fields.map((field) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2034
2070
|
/* @__PURE__ */ jsx(Col, { span: 8, children: /* @__PURE__ */ jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: ({ setFieldValue }) => /* @__PURE__ */ jsx(Form.Item, { name: [field.name, "game_group"], children: /* @__PURE__ */ jsx(
|
|
2035
|
-
|
|
2071
|
+
GroupSelect,
|
|
2036
2072
|
{
|
|
2037
|
-
allowClear: true,
|
|
2038
|
-
showSearch: true,
|
|
2039
|
-
mode: "tags",
|
|
2040
|
-
optionFilterProp: "label",
|
|
2041
|
-
loading: isGroupsLoading,
|
|
2042
|
-
options: groups?.map((group) => ({ label: group, value: group })),
|
|
2043
2073
|
onChange: () => {
|
|
2044
2074
|
setFieldValue(["permissions", field.name, "game_ids"], []);
|
|
2045
2075
|
}
|