@ludo.ninja/components 2.1.38 → 2.1.39

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.
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.SearchInputContainer = void 0;
30
30
  const jsx_runtime_1 = require("react/jsx-runtime");
31
31
  const react_1 = __importStar(require("react"));
32
- const router_1 = require("next/router");
32
+ // import { useRouter } from "next/router";
33
33
  const lodash_debounce_1 = __importDefault(require("lodash.debounce"));
34
34
  const styled_components_1 = __importStar(require("styled-components"));
35
35
  const colors_1 = require("@ludo.ninja/ui/build/styles/colors");
@@ -60,9 +60,10 @@ const SearchInputContainer = ({ onFocusHandler, isClearOnBlur, initializeInputCo
60
60
  }));
61
61
  const { isMobile } = (0, screen_1.useWindowDimensionsWithServerInitial)();
62
62
  const { load, topEntities, loading, clearTopEntitiesState } = (0, useFetchFindAllTopEntitiesByName_1.useFetchFindAllTopEntitiesByName)();
63
- const router = (0, router_1.useRouter)();
63
+ // const router = useRouter();
64
64
  (0, react_1.useEffect)(() => {
65
- const term = router.query?.term;
65
+ // const term = router.query?.term;
66
+ const term = new URLSearchParams(window.location.search).get("term");
66
67
  if (term) {
67
68
  setSearchValue(term);
68
69
  }
@@ -143,11 +144,19 @@ const SearchInputContainer = ({ onFocusHandler, isClearOnBlur, initializeInputCo
143
144
  const { value } = e.target;
144
145
  const newSearchValue = value.length ? searchValue : "";
145
146
  const searchDomain = ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["search"];
147
+ const currentPath = window.location.pathname;
146
148
  if (searchDomain === window.origin &&
147
- seacrhTabs_1.searchTabs.find((el) => router.pathname.includes(el.link))) {
148
- await router.replace({
149
- query: { ...router.query, term: newSearchValue },
150
- }, undefined, { shallow: true });
149
+ seacrhTabs_1.searchTabs.find((el) => currentPath.includes(el.link))) {
150
+ // await router.replace(
151
+ // {
152
+ // query: { ...router.query, term: newSearchValue },
153
+ // },
154
+ // undefined,
155
+ // { shallow: true },
156
+ // );
157
+ const newUrl = new URL(window.location.href);
158
+ newUrl.searchParams.set("term", newSearchValue);
159
+ window.history.replaceState({}, "", newUrl.toString());
151
160
  setSearchFocused(false);
152
161
  onFocusHandler?.(false);
153
162
  closeOverlay();
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const router_1 = require("next/router");
7
+ // import { useRouter } from 'next/router';
8
8
  const ScreenWidth_1 = require("../../../styles/ScreenWidth");
9
9
  const scale_1 = require("../../../utils/adaptive/scale");
10
10
  const screen_1 = require("../../../utils/screen");
@@ -41,15 +41,21 @@ const SearchCloseIconResize = () => {
41
41
  };
42
42
  // Components
43
43
  const SearchCloseMoreButtons = ({ isNeedToShow, position, clearSearchValue, }) => {
44
- const router = (0, router_1.useRouter)();
45
- const { term } = router.query;
44
+ // const router = useRouter();
45
+ // const { term } = router.query;
46
46
  return ((0, jsx_runtime_1.jsx)(StyledSearchCloseMoreButtons, { position: position, children: isNeedToShow ? ((0, jsx_runtime_1.jsx)(StyledCloseIcon, { onClick: () => {
47
+ const term = new URLSearchParams(window.location.search).get('term');
47
48
  if (term) {
48
- router
49
- .push({
50
- query: { ...router.query, term: [] },
51
- })
52
- .then(() => clearSearchValue(''));
49
+ // router
50
+ // .push({
51
+ // query: { ...router.query, term: [] },
52
+ // })
53
+ // .then(() => clearSearchValue(''));
54
+ const params = new URLSearchParams(window.location.search);
55
+ params.delete('term');
56
+ const newUrl = `${window.location.pathname}?${params.toString()}`;
57
+ window.history.pushState({}, '', newUrl);
58
+ clearSearchValue('');
53
59
  }
54
60
  clearSearchValue('');
55
61
  }, children: (0, jsx_runtime_1.jsx)(SearchCloseIconResize, {}) })) : null }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.1.38",
3
+ "version": "2.1.39",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",