gatsby-core-theme 44.0.33 → 44.0.35
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 +17 -0
- package/package.json +1 -1
- package/src/components/organisms/search/index.js +55 -51
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [44.0.35](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.34...v44.0.35) (2025-05-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* search transaltion keys ([ab53ce9](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ab53ce9a22178518fbfe0c360c5d3b56e02b1808))
|
|
7
|
+
|
|
8
|
+
## [44.0.34](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.33...v44.0.34) (2025-05-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* search bug ([b0fb134](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b0fb134fbc34c502082e0e72bf1f6844c6e7c18d))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
* Merge branch 'search-bug' into 'master' ([baeacfc](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/baeacfc5e492a2e2782110ae475298eb39a346eb))
|
|
17
|
+
|
|
1
18
|
## [44.0.33](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.32...v44.0.33) (2025-05-06)
|
|
2
19
|
|
|
3
20
|
|
package/package.json
CHANGED
|
@@ -30,8 +30,8 @@ const SearchForm = ({
|
|
|
30
30
|
}) => {
|
|
31
31
|
const { market, template } = pageContext.page;
|
|
32
32
|
const recommendedCasinos = pageContext?.marketSections?.recommended_casinos?.modules[0]?.items
|
|
33
|
-
const topSearches = pageContext?.marketSections?.top_searches?.modules[0]?.items
|
|
34
|
-
|
|
33
|
+
const topSearches = pageContext?.marketSections?.top_searches?.modules[0]?.items
|
|
34
|
+
|
|
35
35
|
const [localSearch, setLocalSearch] = useState(false);
|
|
36
36
|
|
|
37
37
|
const loadedCounts = {
|
|
@@ -89,26 +89,33 @@ const SearchForm = ({
|
|
|
89
89
|
|
|
90
90
|
const autoCompleteHandler = async (event) => {
|
|
91
91
|
const query = event.target.value.trim();
|
|
92
|
-
|
|
92
|
+
const shouldShow = query.length >= startSearchAt;
|
|
93
|
+
setShowAutoComplete(shouldShow);
|
|
94
|
+
|
|
95
|
+
if (!shouldShow) {
|
|
96
|
+
setFilteredData(null);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
93
99
|
|
|
94
100
|
setAutoCompleteLoading(true);
|
|
95
101
|
|
|
96
102
|
try {
|
|
97
|
-
autoCompleteData.current = autoCompleteData.current || await loadSource(market, 'data-simple.json')
|
|
103
|
+
autoCompleteData.current = autoCompleteData.current || await loadSource(market, 'data-simple.json');
|
|
98
104
|
|
|
99
|
-
|
|
105
|
+
const filtered = autoCompleteData.current.filter(item =>
|
|
100
106
|
item.title.toLowerCase().includes(query.toLowerCase())
|
|
101
|
-
)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
setFilteredData(filtered.length > 0 ? filtered : null);
|
|
102
110
|
|
|
103
111
|
} catch (error) {
|
|
104
112
|
console.error("Error loading autocomplete data:", error);
|
|
113
|
+
setFilteredData(null);
|
|
105
114
|
} finally {
|
|
106
115
|
setAutoCompleteLoading(false);
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
|
|
110
|
-
|
|
111
|
-
|
|
112
119
|
useEffect(() => {
|
|
113
120
|
const handleClickOutside = (event) => {
|
|
114
121
|
if (localSearch && searchFormRef.current && !searchFormRef.current.contains(event.target)) {
|
|
@@ -128,13 +135,6 @@ const SearchForm = ({
|
|
|
128
135
|
if (localSearch) searchInputRef.current.focus();
|
|
129
136
|
}, [localSearch]);
|
|
130
137
|
|
|
131
|
-
// Group data by pageType
|
|
132
|
-
const groupedData = filteredData?.reduce((acc, item) => {
|
|
133
|
-
acc[item.pageType] = acc[item.pageType] || [];
|
|
134
|
-
acc[item.pageType].push(item);
|
|
135
|
-
return acc;
|
|
136
|
-
}, {});
|
|
137
|
-
|
|
138
138
|
return (
|
|
139
139
|
<div className={className || ''} ref={searchFormRef}>
|
|
140
140
|
<button
|
|
@@ -184,43 +184,47 @@ const SearchForm = ({
|
|
|
184
184
|
</div>
|
|
185
185
|
) : (
|
|
186
186
|
<div className={styles.autoCompleteInner}>
|
|
187
|
-
{filteredData
|
|
187
|
+
{filteredData ? (
|
|
188
188
|
<ul>
|
|
189
|
-
{Object.entries(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
189
|
+
{Object.entries(
|
|
190
|
+
filteredData.reduce((acc, item) => {
|
|
191
|
+
acc[item.pageType] = acc[item.pageType] || [];
|
|
192
|
+
acc[item.pageType].push(item);
|
|
193
|
+
return acc;
|
|
194
|
+
}, {})
|
|
195
|
+
).map(([type, items]) => (
|
|
196
|
+
items.length > 0 && (
|
|
197
|
+
<React.Fragment key={type}>
|
|
198
|
+
<div className={styles.autoCompleteTitle}>
|
|
199
|
+
{useTranslate(`search_${type}`, type)}
|
|
200
|
+
</div>
|
|
201
|
+
<div className={styles.autoCompleteList}>
|
|
202
|
+
{items.slice(0, loadedCounts[type]).map((value) => {
|
|
203
|
+
const PageTypeCard = getComponent(value.pageType);
|
|
204
|
+
return (
|
|
205
|
+
<Suspense fallback={<Loading single />} key={keygen()}>
|
|
206
|
+
<PageTypeCard item={value} icon={autoCompleteIcon} />
|
|
207
|
+
</Suspense>
|
|
208
|
+
);
|
|
209
|
+
})}
|
|
210
|
+
{loadedCounts[type] < items.length && (
|
|
211
|
+
<button
|
|
212
|
+
type='button'
|
|
213
|
+
className={styles.loadMoreBtn}
|
|
214
|
+
onClick={() => {
|
|
215
|
+
const inputValue = searchInputRef.current?.value.trim();
|
|
216
|
+
if (inputValue) {
|
|
217
|
+
const url = `/s${process.env.TRAILING_SLASH ? '/' : ''}?s=${encodeURIComponent(inputValue)}`;
|
|
218
|
+
window.location.href = url;
|
|
219
|
+
}
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
{useTranslate('autocomplete_see_all', 'View more')} {useTranslate(`search_${type}`, type)}
|
|
223
|
+
</button>
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
</React.Fragment>
|
|
227
|
+
)
|
|
224
228
|
))}
|
|
225
229
|
</ul>
|
|
226
230
|
) : (
|