react-toolkits 2.13.32 → 2.13.34

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,17 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.34
4
+
5
+ ### Patch Changes
6
+
7
+ - ca6e5e1: feat: add skipRequestInterceptor and skipResponseInterceptor in AxiosRequestConfig
8
+
9
+ ## 2.13.33
10
+
11
+ ### Patch Changes
12
+
13
+ - ca6cb9d: feat: some changes
14
+
3
15
  ## 2.13.32
4
16
 
5
17
  ### 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
@@ -389,6 +389,9 @@ var init_Interceptors = __esm({
389
389
  requestInterceptorId = axios2.interceptors.request.use(...interceptors.request);
390
390
  } else {
391
391
  requestInterceptorId = axios2.interceptors.request.use((config) => {
392
+ if (config.skipRequestInterceptor) {
393
+ return config;
394
+ }
392
395
  const headers = new AxiosHeaders(config.headers);
393
396
  config.responseType = config.responseType || "json";
394
397
  if (token) {
@@ -411,6 +414,9 @@ var init_Interceptors = __esm({
411
414
  } else {
412
415
  responseInterceptorId = axios2.interceptors.response.use(
413
416
  (response) => {
417
+ if (response.config.skipResponseInterceptor) {
418
+ return response;
419
+ }
414
420
  const responseType = response.request.responseType || "json";
415
421
  if (responseType === "json") {
416
422
  const data = response.data;
@@ -909,13 +915,13 @@ var init_GameSelect = __esm({
909
915
  init_hooks3();
910
916
  ({ Text } = Typography);
911
917
  GameSelect = (props) => {
912
- const { filter, getOptions } = props;
918
+ const { filter, options } = props;
913
919
  const { t } = useTranslation();
914
920
  const { gameApiV2, gameId, setGameId } = useToolkitsStore((s) => s);
915
921
  const { data, isLoading } = useGames();
916
922
  const { mutate: mutate2 } = useSWRConfig();
917
923
  const filteredData = data?.filter((item) => filter?.(item) ?? true);
918
- const options = typeof getOptions === "function" ? getOptions(filteredData) : filteredData?.map((item) => ({
924
+ const _options = typeof options === "function" ? options(filteredData) : filteredData?.map((item) => ({
919
925
  label: item.name,
920
926
  value: gameApiV2 ? item.game_id : item.id
921
927
  }));
@@ -924,14 +930,13 @@ var init_GameSelect = __esm({
924
930
  setGameId(value);
925
931
  };
926
932
  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);
933
+ if (data && data.length > 0) {
934
+ const firstId = gameApiV2 ? data[0].game_id : data[0].id;
935
+ if (data.every((item) => String(item.game_id || item.id) !== String(gameId))) {
936
+ setGameId(firstId);
937
+ }
933
938
  }
934
- }, [gameId, data, gameApiV2]);
939
+ }, [data]);
935
940
  return /* @__PURE__ */ jsxs(Space, { children: [
936
941
  /* @__PURE__ */ jsx(Text, { children: t("GameSelect.label") }),
937
942
  /* @__PURE__ */ jsx(
@@ -943,7 +948,7 @@ var init_GameSelect = __esm({
943
948
  placeholder: t("GameSelect.placeholder"),
944
949
  loading: isLoading,
945
950
  style: { width: "200px" },
946
- options,
951
+ options: _options,
947
952
  onChange
948
953
  }
949
954
  )
@@ -973,7 +978,7 @@ var init_Layout = __esm({
973
978
  navWidth,
974
979
  hideGameSelect,
975
980
  filter,
976
- getGameSelectOptions
981
+ gameSelectOptions
977
982
  } = props;
978
983
  const {
979
984
  token: { colorBgContainer, colorBorder }
@@ -1045,7 +1050,7 @@ var init_Layout = __esm({
1045
1050
  onClick: onCollapse
1046
1051
  }
1047
1052
  ),
1048
- permissionVersion !== "v1" /* V1 */ && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, getOptions: getGameSelectOptions }),
1053
+ permissionVersion !== "v1" /* V1 */ && !hideGameSelect && /* @__PURE__ */ jsx(GameSelect_default, { filter, options: gameSelectOptions }),
1049
1054
  headerExtra?.left?.map((extra) => /* @__PURE__ */ jsx("span", { children: extra.children }, extra.key))
1050
1055
  ] }),
1051
1056
  /* @__PURE__ */ jsxs(Space, { size: "small", split: /* @__PURE__ */ jsx(Divider, { type: "vertical" }), children: [