react-toolkits 2.13.32 → 2.13.33

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,11 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.33
4
+
5
+ ### Patch Changes
6
+
7
+ - ca6cb9d: feat: some changes
8
+
3
9
  ## 2.13.32
4
10
 
5
11
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -120,7 +120,7 @@ declare const NavMenu: react.NamedExoticComponent<NavMenuProps>;
120
120
 
121
121
  interface GameSelectProps {
122
122
  filter?: (game: Game) => boolean;
123
- getOptions?: (data?: Game[]) => SelectProps['options'];
123
+ options?: (data?: Game[]) => SelectProps['options'];
124
124
  }
125
125
 
126
126
  type HeaderExtra = {
@@ -133,7 +133,7 @@ interface LayoutProps extends Pick<GameSelectProps, 'filter'> {
133
133
  items?: NavMenuItem[];
134
134
  hideGameSelect?: boolean;
135
135
  navWidth?: string | number;
136
- getGameSelectOptions?: GameSelectProps['getOptions'];
136
+ gameSelectOptions?: GameSelectProps['options'];
137
137
  headerExtra?: {
138
138
  left?: HeaderExtra[];
139
139
  right?: HeaderExtra[];
package/lib/index.js CHANGED
@@ -909,13 +909,13 @@ var init_GameSelect = __esm({
909
909
  init_hooks3();
910
910
  ({ Text } = Typography);
911
911
  GameSelect = (props) => {
912
- const { filter, getOptions } = props;
912
+ const { filter, options } = props;
913
913
  const { t } = useTranslation();
914
914
  const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
915
915
  const { data, isLoading } = useGames();
916
916
  const { mutate: mutate2 } = useSWRConfig();
917
917
  const filteredData = data?.filter((item) => filter?.(item) ?? true);
918
- const options = typeof getOptions === "function" ? getOptions(filteredData) : filteredData?.map((item) => ({
918
+ const _options = typeof options === "function" ? options(filteredData) : filteredData?.map((item) => ({
919
919
  label: item.name,
920
920
  value: gameApiV2 ? item.game_id : item.id
921
921
  }));
@@ -924,14 +924,13 @@ var init_GameSelect = __esm({
924
924
  setGameId(value);
925
925
  };
926
926
  useEffect(() => {
927
- let id2 = gameId;
928
- if (data?.every((item) => String(gameApiV2 ? item.game_id : item.id) !== String(id2))) {
929
- id2 = gameApiV2 ? data?.[0]?.game_id : data?.[0]?.id;
930
- }
931
- if (id2 !== gameId) {
932
- setGameId(id2);
927
+ if (data && data.length > 0) {
928
+ const firstId = gameApiV2 ? data[0].game_id : data[0].id;
929
+ if (data.every((item) => String(item.game_id || item.id) !== String(gameId))) {
930
+ setGameId(firstId);
931
+ }
933
932
  }
934
- }, [gameId, data, gameApiV2]);
933
+ }, [data]);
935
934
  return /* @__PURE__ */ jsxs(Space, { children: [
936
935
  /* @__PURE__ */ jsx(Text, { children: t("GameSelect.label") }),
937
936
  /* @__PURE__ */ jsx(
@@ -943,7 +942,7 @@ var init_GameSelect = __esm({
943
942
  placeholder: t("GameSelect.placeholder"),
944
943
  loading: isLoading,
945
944
  style: { width: "200px" },
946
- options,
945
+ options: _options,
947
946
  onChange
948
947
  }
949
948
  )
@@ -973,7 +972,7 @@ var init_Layout = __esm({
973
972
  navWidth,
974
973
  hideGameSelect,
975
974
  filter,
976
- getGameSelectOptions
975
+ gameSelectOptions
977
976
  } = props;
978
977
  const {
979
978
  token: { colorBgContainer, colorBorder }
@@ -1045,7 +1044,7 @@ var init_Layout = __esm({
1045
1044
  onClick: onCollapse
1046
1045
  }
1047
1046
  ),
1048
- permissionVersion !== "v1" /* V1 */ && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, getOptions: getGameSelectOptions }),
1047
+ permissionVersion !== "v1" /* V1 */ && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, options: gameSelectOptions }),
1049
1048
  headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
1050
1049
  ] }),
1051
1050
  /* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [