@rubixstudios/payload-typesense 1.1.7 → 1.2.0
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/dist/components/HeadlessSearchInput.d.ts +1 -2
- package/dist/components/HeadlessSearchInput.d.ts.map +1 -1
- package/dist/components/HeadlessSearchInput.js +33 -300
- package/dist/components/render/Header.d.ts +9 -0
- package/dist/components/render/Header.d.ts.map +1 -0
- package/dist/components/render/Header.js +39 -0
- package/dist/components/render/NoResults.d.ts +9 -0
- package/dist/components/render/NoResults.d.ts.map +1 -0
- package/dist/components/render/NoResults.js +45 -0
- package/dist/components/render/ResultError.d.ts +9 -0
- package/dist/components/render/ResultError.d.ts.map +1 -0
- package/dist/components/render/ResultError.js +38 -0
- package/dist/components/render/Results.d.ts +14 -0
- package/dist/components/render/Results.d.ts.map +1 -0
- package/dist/components/render/Results.js +143 -0
- package/dist/components/render/index.d.ts +5 -0
- package/dist/components/render/index.d.ts.map +1 -0
- package/dist/components/render/index.js +4 -0
- package/dist/components/themes/hooks.d.ts +1 -1
- package/dist/components/themes/hooks.d.ts.map +1 -1
- package/dist/components/themes/hooks.js +0 -1
- package/dist/components/themes/utils.d.ts +2 -10
- package/dist/components/themes/utils.d.ts.map +1 -1
- package/dist/components/themes/utils.js +13 -18
- package/dist/endpoints/handler/createAdvancedSearch.d.ts +1 -1
- package/dist/endpoints/handler/createCollections.d.ts +1 -1
- package/dist/endpoints/handler/createSearch.d.ts +1 -1
- package/dist/endpoints/handler/createSearch.d.ts.map +1 -1
- package/dist/endpoints/handler/createSuggest.d.ts +1 -1
- package/dist/endpoints/health.d.ts +1 -1
- package/dist/endpoints/health.d.ts.map +1 -1
- package/dist/endpoints/search.d.ts +1 -1
- package/dist/index.d.ts +3 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -29
- package/dist/lib/client.d.ts +1 -1
- package/dist/lib/headlessSearch.d.ts +1 -9
- package/dist/lib/headlessSearch.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/lib/initialization.d.ts +2 -2
- package/dist/lib/initialization.d.ts.map +1 -1
- package/dist/lib/initialization.js +47 -35
- package/dist/lib/schema-mapper.d.ts +1 -2
- package/dist/lib/schema-mapper.d.ts.map +1 -1
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/utils/getAllCollections.d.ts +1 -1
- package/dist/utils/getAllCollections.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type HeadlessSearchInputProps } from '../lib/headlessSearch.js';
|
|
3
|
-
declare
|
|
3
|
+
export declare function HeadlessSearchInput<T = Record<string, unknown>>(props: HeadlessSearchInputProps<T>): React.ReactElement;
|
|
4
4
|
export default HeadlessSearchInput;
|
|
5
|
-
export { HeadlessSearchInput };
|
|
6
5
|
//# sourceMappingURL=HeadlessSearchInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeadlessSearchInput.d.ts","sourceRoot":"","sources":["../../src/components/HeadlessSearchInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"HeadlessSearchInput.d.ts","sourceRoot":"","sources":["../../src/components/HeadlessSearchInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAaxE,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACjC,KAAK,CAAC,YAAY,CA8SpB;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -3,8 +3,10 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { handleKeyboard } from '../utils/keyboard.js';
|
|
4
4
|
import { useDebounce } from '../utils/useDebounce.js';
|
|
5
5
|
import { useSearch } from '../utils/useSearch.js';
|
|
6
|
+
import { RenderedHeader, RenderedNoResults, RenderedResult, RenderedResultError } from './render/index.js';
|
|
6
7
|
import { useThemeConfig } from './themes/hooks.js';
|
|
7
|
-
|
|
8
|
+
export function HeadlessSearchInput(props) {
|
|
9
|
+
const { baseUrl, className = '', collections, debounceMs = 300, enableSuggestions: _enableSuggestions = true, errorClassName = '', inputClassName = '', inputWrapperClassName = '', minQueryLength = 2, noResultsClassName = '', onResultClick, onResults, onSearch, perPage = 10, placeholder = 'Search...', renderDate = true, renderError, renderInput, renderNoResults, renderResult, renderResultsHeader, resultItemClassName = '', resultsClassName = '', resultsContainerClassName = '', resultsHeaderClassName = '', resultsListClassName = '', showLoading = true, showResultCount = true, theme = 'modern' } = props;
|
|
8
10
|
const [query, setQuery] = useState('');
|
|
9
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
10
12
|
const inputRef = useRef(null);
|
|
@@ -61,297 +63,8 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collections, debounceMs
|
|
|
61
63
|
resultsRef
|
|
62
64
|
});
|
|
63
65
|
};
|
|
64
|
-
// Default render functions
|
|
65
|
-
const defaultRenderResult = (result, _index)=>{
|
|
66
|
-
// Calculate relative percentage based on the highest score in current results
|
|
67
|
-
const maxScore = results?.hits?.reduce((max, hit)=>Math.max(max, hit.text_match || 0), 0) || 1;
|
|
68
|
-
const relativePercentage = Math.round((result.text_match || 0) / maxScore * 100);
|
|
69
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
70
|
-
className: `${resultsContainerClassName}`,
|
|
71
|
-
style: {
|
|
72
|
-
backgroundColor: themeConfig.theme.colors.resultBackground,
|
|
73
|
-
borderBottom: `1px solid ${themeConfig.theme.colors.resultBorder}`,
|
|
74
|
-
cursor: 'pointer',
|
|
75
|
-
padding: themeConfig.theme.spacing.itemPadding,
|
|
76
|
-
transition: themeConfig.config.enableAnimations !== false ? `all ${themeConfig.theme.animations.transitionFast} ${themeConfig.theme.animations.easeInOut}` : 'none'
|
|
77
|
-
}
|
|
78
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
79
|
-
className: `${themeConfig.classes.resultItem} ${resultItemClassName}`,
|
|
80
|
-
"data-result-item": true,
|
|
81
|
-
key: result.document?.id || result.id || _index,
|
|
82
|
-
onBlur: (e)=>{
|
|
83
|
-
e.currentTarget.style.backgroundColor = themeConfig.theme.colors.resultBackground;
|
|
84
|
-
},
|
|
85
|
-
onClick: ()=>handleResultClick(result),
|
|
86
|
-
onFocus: (e)=>{
|
|
87
|
-
e.currentTarget.style.backgroundColor = themeConfig.theme.colors.resultBackgroundFocus;
|
|
88
|
-
},
|
|
89
|
-
onKeyDown: (e)=>{
|
|
90
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
91
|
-
e.preventDefault();
|
|
92
|
-
handleResultClick(result);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
onMouseEnter: (e)=>{
|
|
96
|
-
e.currentTarget.style.backgroundColor = themeConfig.theme.colors.resultBackgroundHover;
|
|
97
|
-
},
|
|
98
|
-
onMouseLeave: (e)=>{
|
|
99
|
-
e.currentTarget.style.backgroundColor = themeConfig.theme.colors.resultBackground;
|
|
100
|
-
},
|
|
101
|
-
role: "button",
|
|
102
|
-
tabIndex: 0
|
|
103
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
104
|
-
style: {
|
|
105
|
-
alignItems: 'flex-start',
|
|
106
|
-
display: 'flex',
|
|
107
|
-
gap: '12px',
|
|
108
|
-
padding: '6px'
|
|
109
|
-
}
|
|
110
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
111
|
-
style: {
|
|
112
|
-
flexShrink: 0
|
|
113
|
-
}
|
|
114
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
115
|
-
style: {
|
|
116
|
-
alignItems: 'center',
|
|
117
|
-
backgroundColor: themeConfig.theme.colors.collectionBadge,
|
|
118
|
-
borderRadius: themeConfig.theme.spacing.inputBorderRadius,
|
|
119
|
-
color: themeConfig.theme.colors.collectionBadgeText,
|
|
120
|
-
display: 'flex',
|
|
121
|
-
fontSize: '14px',
|
|
122
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
123
|
-
height: '32px',
|
|
124
|
-
justifyContent: 'center',
|
|
125
|
-
width: '32px'
|
|
126
|
-
}
|
|
127
|
-
}, result.collection?.charAt(0).toUpperCase() || '📄')), /*#__PURE__*/ React.createElement("div", {
|
|
128
|
-
style: {
|
|
129
|
-
flex: 1,
|
|
130
|
-
minWidth: 0
|
|
131
|
-
}
|
|
132
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
133
|
-
style: {
|
|
134
|
-
alignItems: 'center',
|
|
135
|
-
display: 'flex',
|
|
136
|
-
justifyContent: 'space-between',
|
|
137
|
-
marginBottom: '8px'
|
|
138
|
-
}
|
|
139
|
-
}, /*#__PURE__*/ React.createElement("h3", {
|
|
140
|
-
style: {
|
|
141
|
-
color: themeConfig.theme.colors.titleText,
|
|
142
|
-
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
143
|
-
fontSize: themeConfig.theme.typography.fontSizeBase,
|
|
144
|
-
fontWeight: themeConfig.theme.typography.fontWeightSemibold,
|
|
145
|
-
lineHeight: themeConfig.theme.typography.lineHeightTight,
|
|
146
|
-
margin: 0,
|
|
147
|
-
overflow: 'hidden',
|
|
148
|
-
textOverflow: 'ellipsis',
|
|
149
|
-
whiteSpace: 'nowrap'
|
|
150
|
-
}
|
|
151
|
-
}, result.document?.title || result.document?.name || result.title || 'Untitled'), renderMatchPercentage && typeof result.text_match === 'number' && !isNaN(result.text_match) && /*#__PURE__*/ React.createElement("span", {
|
|
152
|
-
style: {
|
|
153
|
-
alignItems: 'center',
|
|
154
|
-
backgroundColor: themeConfig.theme.colors.scoreBadge,
|
|
155
|
-
borderRadius: '4px',
|
|
156
|
-
color: themeConfig.theme.colors.scoreBadgeText,
|
|
157
|
-
display: 'inline-flex',
|
|
158
|
-
fontSize: themeConfig.theme.typography.fontSizeXs,
|
|
159
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
160
|
-
marginLeft: '8px',
|
|
161
|
-
padding: '2px 6px'
|
|
162
|
-
}
|
|
163
|
-
}, relativePercentage, "%")), (result.highlight?.title?.snippet || result.highlight?.content?.snippet) && /*#__PURE__*/ React.createElement("div", {
|
|
164
|
-
dangerouslySetInnerHTML: {
|
|
165
|
-
__html: result.highlight?.title?.snippet || result.highlight?.content?.snippet || ''
|
|
166
|
-
},
|
|
167
|
-
style: {
|
|
168
|
-
color: themeConfig.theme.colors.descriptionText,
|
|
169
|
-
display: '-webkit-box',
|
|
170
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
171
|
-
fontWeight: themeConfig.theme.typography.fontWeightNormal,
|
|
172
|
-
lineHeight: themeConfig.theme.typography.lineHeightNormal,
|
|
173
|
-
marginTop: '4px',
|
|
174
|
-
overflow: 'hidden',
|
|
175
|
-
WebkitBoxOrient: 'vertical',
|
|
176
|
-
WebkitLineClamp: 2
|
|
177
|
-
}
|
|
178
|
-
}), /*#__PURE__*/ React.createElement("div", {
|
|
179
|
-
style: {
|
|
180
|
-
alignItems: 'center',
|
|
181
|
-
color: themeConfig.theme.colors.metaText,
|
|
182
|
-
display: 'flex',
|
|
183
|
-
fontSize: themeConfig.theme.typography.fontSizeXs,
|
|
184
|
-
gap: '12px',
|
|
185
|
-
marginTop: '8px'
|
|
186
|
-
}
|
|
187
|
-
}, result.collection && /*#__PURE__*/ React.createElement("span", {
|
|
188
|
-
style: {
|
|
189
|
-
alignItems: 'center',
|
|
190
|
-
display: 'inline-flex'
|
|
191
|
-
}
|
|
192
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
193
|
-
fill: "currentColor",
|
|
194
|
-
style: {
|
|
195
|
-
height: '12px',
|
|
196
|
-
marginRight: '4px',
|
|
197
|
-
width: '12px'
|
|
198
|
-
},
|
|
199
|
-
viewBox: "0 0 20 20"
|
|
200
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
201
|
-
clipRule: "evenodd",
|
|
202
|
-
d: "M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z",
|
|
203
|
-
fillRule: "evenodd"
|
|
204
|
-
})), result.collection), renderDate && (result.document?.updatedAt || result.updatedAt) && /*#__PURE__*/ React.createElement("span", {
|
|
205
|
-
style: {
|
|
206
|
-
alignItems: 'center',
|
|
207
|
-
display: 'inline-flex'
|
|
208
|
-
}
|
|
209
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
210
|
-
fill: "currentColor",
|
|
211
|
-
style: {
|
|
212
|
-
height: '12px',
|
|
213
|
-
marginRight: '4px',
|
|
214
|
-
width: '12px'
|
|
215
|
-
},
|
|
216
|
-
viewBox: "0 0 20 20"
|
|
217
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
218
|
-
clipRule: "evenodd",
|
|
219
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z",
|
|
220
|
-
fillRule: "evenodd"
|
|
221
|
-
})), new Date(result.document?.updatedAt || result.updatedAt).toLocaleDateString()))))));
|
|
222
|
-
};
|
|
223
|
-
const defaultRenderNoResults = (_query)=>/*#__PURE__*/ React.createElement("div", {
|
|
224
|
-
className: `${noResultsClassName}`,
|
|
225
|
-
style: {
|
|
226
|
-
color: themeConfig.theme.colors.noResultsText,
|
|
227
|
-
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
228
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
229
|
-
padding: '40px 20px',
|
|
230
|
-
textAlign: 'center'
|
|
231
|
-
}
|
|
232
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
233
|
-
style: {
|
|
234
|
-
alignItems: 'center',
|
|
235
|
-
display: 'flex',
|
|
236
|
-
flexDirection: 'column'
|
|
237
|
-
}
|
|
238
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
239
|
-
fill: "none",
|
|
240
|
-
stroke: "currentColor",
|
|
241
|
-
style: {
|
|
242
|
-
color: themeConfig.theme.colors.metaText,
|
|
243
|
-
height: '48px',
|
|
244
|
-
marginBottom: '12px',
|
|
245
|
-
width: '48px'
|
|
246
|
-
},
|
|
247
|
-
viewBox: "0 0 24 24"
|
|
248
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
249
|
-
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",
|
|
250
|
-
strokeLinecap: "round",
|
|
251
|
-
strokeLinejoin: "round",
|
|
252
|
-
strokeWidth: 1
|
|
253
|
-
})), /*#__PURE__*/ React.createElement("h3", {
|
|
254
|
-
style: {
|
|
255
|
-
color: themeConfig.theme.colors.titleText,
|
|
256
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
257
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
258
|
-
margin: 0,
|
|
259
|
-
marginBottom: '4px'
|
|
260
|
-
}
|
|
261
|
-
}, "No results found"), /*#__PURE__*/ React.createElement("p", {
|
|
262
|
-
style: {
|
|
263
|
-
color: themeConfig.theme.colors.descriptionText,
|
|
264
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
265
|
-
margin: 0
|
|
266
|
-
}
|
|
267
|
-
}, "Try searching for something else")));
|
|
268
|
-
const defaultRenderError = (error)=>/*#__PURE__*/ React.createElement("div", {
|
|
269
|
-
className: `${errorClassName}`,
|
|
270
|
-
style: {
|
|
271
|
-
alignItems: 'center',
|
|
272
|
-
backgroundColor: themeConfig.theme.colors.errorBackground,
|
|
273
|
-
borderBottom: `1px solid ${themeConfig.theme.colors.resultBorder}`,
|
|
274
|
-
color: themeConfig.theme.colors.errorText,
|
|
275
|
-
display: 'flex',
|
|
276
|
-
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
277
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
278
|
-
gap: '8px',
|
|
279
|
-
padding: '16px'
|
|
280
|
-
}
|
|
281
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
282
|
-
fill: "currentColor",
|
|
283
|
-
style: {
|
|
284
|
-
flexShrink: 0,
|
|
285
|
-
height: '20px',
|
|
286
|
-
width: '20px'
|
|
287
|
-
},
|
|
288
|
-
viewBox: "0 0 20 20"
|
|
289
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
290
|
-
clipRule: "evenodd",
|
|
291
|
-
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
|
|
292
|
-
fillRule: "evenodd"
|
|
293
|
-
})), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
294
|
-
style: {
|
|
295
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
296
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
297
|
-
margin: 0
|
|
298
|
-
}
|
|
299
|
-
}, "Search Error"), /*#__PURE__*/ React.createElement("p", {
|
|
300
|
-
style: {
|
|
301
|
-
color: themeConfig.theme.colors.errorText,
|
|
302
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
303
|
-
margin: 0
|
|
304
|
-
}
|
|
305
|
-
}, error)));
|
|
306
|
-
const defaultRenderResultsHeader = (found, searchTime)=>/*#__PURE__*/ React.createElement("div", {
|
|
307
|
-
className: `${resultsHeaderClassName}`,
|
|
308
|
-
style: {
|
|
309
|
-
alignItems: 'center',
|
|
310
|
-
backgroundColor: themeConfig.theme.colors.headerBackground,
|
|
311
|
-
borderBottom: `1px solid ${themeConfig.theme.colors.headerBorder}`,
|
|
312
|
-
color: themeConfig.theme.colors.headerText,
|
|
313
|
-
display: 'flex',
|
|
314
|
-
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
315
|
-
fontSize: themeConfig.theme.spacing.headerFontSize,
|
|
316
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
317
|
-
justifyContent: 'space-between',
|
|
318
|
-
padding: themeConfig.theme.spacing.headerPadding
|
|
319
|
-
}
|
|
320
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
321
|
-
style: {
|
|
322
|
-
alignItems: 'center',
|
|
323
|
-
display: 'flex',
|
|
324
|
-
gap: '8px'
|
|
325
|
-
}
|
|
326
|
-
}, /*#__PURE__*/ React.createElement("svg", {
|
|
327
|
-
fill: "currentColor",
|
|
328
|
-
style: {
|
|
329
|
-
color: themeConfig.theme.colors.metaText,
|
|
330
|
-
height: '16px',
|
|
331
|
-
width: '16px'
|
|
332
|
-
},
|
|
333
|
-
viewBox: "0 0 20 20"
|
|
334
|
-
}, /*#__PURE__*/ React.createElement("path", {
|
|
335
|
-
clipRule: "evenodd",
|
|
336
|
-
d: "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",
|
|
337
|
-
fillRule: "evenodd"
|
|
338
|
-
})), /*#__PURE__*/ React.createElement("span", {
|
|
339
|
-
style: {
|
|
340
|
-
color: themeConfig.theme.colors.headerText,
|
|
341
|
-
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
342
|
-
fontWeight: themeConfig.theme.typography.fontWeightMedium
|
|
343
|
-
}
|
|
344
|
-
}, found, " result", found !== 1 ? 's' : '', " found")), showSearchTime && /*#__PURE__*/ React.createElement("span", {
|
|
345
|
-
style: {
|
|
346
|
-
backgroundColor: themeConfig.theme.colors.inputBorder,
|
|
347
|
-
borderRadius: '12px',
|
|
348
|
-
color: themeConfig.theme.colors.metaText,
|
|
349
|
-
fontSize: themeConfig.theme.typography.fontSizeXs,
|
|
350
|
-
padding: '4px 8px'
|
|
351
|
-
}
|
|
352
|
-
}, searchTime, "ms"));
|
|
353
66
|
return /*#__PURE__*/ React.createElement("div", {
|
|
354
|
-
className:
|
|
67
|
+
className: className,
|
|
355
68
|
style: {
|
|
356
69
|
margin: '0 auto',
|
|
357
70
|
maxWidth: '600px',
|
|
@@ -359,13 +72,13 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collections, debounceMs
|
|
|
359
72
|
width: '100%'
|
|
360
73
|
}
|
|
361
74
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
362
|
-
className:
|
|
75
|
+
className: inputWrapperClassName,
|
|
363
76
|
style: {
|
|
364
77
|
position: 'relative',
|
|
365
78
|
width: '100%'
|
|
366
79
|
}
|
|
367
80
|
}, renderInput ? renderInput({
|
|
368
|
-
className:
|
|
81
|
+
className: inputClassName,
|
|
369
82
|
onBlur: handleInputBlur,
|
|
370
83
|
onChange: handleInputChange,
|
|
371
84
|
onFocus: handleInputFocus,
|
|
@@ -376,7 +89,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collections, debounceMs
|
|
|
376
89
|
}) : /*#__PURE__*/ React.createElement("input", {
|
|
377
90
|
"aria-label": "Search input",
|
|
378
91
|
autoComplete: "off",
|
|
379
|
-
className:
|
|
92
|
+
className: inputClassName,
|
|
380
93
|
onBlur: (e)=>{
|
|
381
94
|
e.target.style.borderColor = themeConfig.theme.colors.inputBorder;
|
|
382
95
|
e.target.style.boxShadow = 'none';
|
|
@@ -432,7 +145,7 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collections, debounceMs
|
|
|
432
145
|
width: '16px'
|
|
433
146
|
}
|
|
434
147
|
}))), isOpen && results && /*#__PURE__*/ React.createElement("div", {
|
|
435
|
-
className:
|
|
148
|
+
className: resultsContainerClassName,
|
|
436
149
|
ref: resultsRef,
|
|
437
150
|
style: {
|
|
438
151
|
backgroundColor: themeConfig.theme.colors.resultsBackground,
|
|
@@ -460,11 +173,31 @@ const HeadlessSearchInput = ({ baseUrl, className = '', collections, debounceMs
|
|
|
460
173
|
minHeight: 0,
|
|
461
174
|
overflowY: 'auto'
|
|
462
175
|
}
|
|
463
|
-
}, error && (renderError ? renderError(error) :
|
|
464
|
-
|
|
176
|
+
}, error && (renderError ? renderError(error) : /*#__PURE__*/ React.createElement(RenderedResultError, {
|
|
177
|
+
error: error,
|
|
178
|
+
errorClassName: errorClassName,
|
|
179
|
+
themeConfig: themeConfig
|
|
180
|
+
})), !error && results && /*#__PURE__*/ React.createElement(React.Fragment, null, showResultCount && (renderResultsHeader ? renderResultsHeader(results.found) : /*#__PURE__*/ React.createElement(RenderedHeader, {
|
|
181
|
+
found: results.hits.length,
|
|
182
|
+
resultsHeaderClassName: resultsHeaderClassName,
|
|
183
|
+
themeConfig: themeConfig
|
|
184
|
+
})), results.hits.length > 0 ? /*#__PURE__*/ React.createElement("div", {
|
|
185
|
+
className: resultsListClassName
|
|
465
186
|
}, results.hits.map((result, index)=>renderResult ? renderResult(result, index, {
|
|
466
187
|
onClick: handleResultClick
|
|
467
|
-
}) :
|
|
468
|
-
|
|
188
|
+
}) : /*#__PURE__*/ React.createElement(RenderedResult, {
|
|
189
|
+
index: index,
|
|
190
|
+
key: result.document?.id || result.id || index,
|
|
191
|
+
onResultClick: handleResultClick,
|
|
192
|
+
renderDate: renderDate,
|
|
193
|
+
result: result,
|
|
194
|
+
resultItemClassName: resultItemClassName,
|
|
195
|
+
resultsContainerClassName: resultsContainerClassName,
|
|
196
|
+
themeConfig: themeConfig
|
|
197
|
+
}))) : renderNoResults ? renderNoResults(query) : /*#__PURE__*/ React.createElement(RenderedNoResults, {
|
|
198
|
+
noResultsClassName: noResultsClassName,
|
|
199
|
+
query: query,
|
|
200
|
+
themeConfig: themeConfig
|
|
201
|
+
})))));
|
|
202
|
+
}
|
|
469
203
|
export default HeadlessSearchInput;
|
|
470
|
-
export { HeadlessSearchInput };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ThemeContextValue } from '../themes/types.js';
|
|
2
|
+
interface RenderedHeaderProps {
|
|
3
|
+
found: number;
|
|
4
|
+
resultsHeaderClassName?: string;
|
|
5
|
+
themeConfig: ThemeContextValue;
|
|
6
|
+
}
|
|
7
|
+
export declare const RenderedHeader: ({ found, resultsHeaderClassName, themeConfig, }: RenderedHeaderProps) => import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/render/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,WAAW,EAAE,iBAAiB,CAAA;CAC/B;AAED,eAAO,MAAM,cAAc,GAAI,iDAI5B,mBAAmB,gCAuCrB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const RenderedHeader = ({ found, resultsHeaderClassName = '', themeConfig })=>/*#__PURE__*/ React.createElement("div", {
|
|
2
|
+
className: resultsHeaderClassName,
|
|
3
|
+
style: {
|
|
4
|
+
alignItems: 'center',
|
|
5
|
+
backgroundColor: themeConfig.theme.colors.headerBackground,
|
|
6
|
+
borderBottom: `1px solid ${themeConfig.theme.colors.headerBorder}`,
|
|
7
|
+
color: themeConfig.theme.colors.headerText,
|
|
8
|
+
display: 'flex',
|
|
9
|
+
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
10
|
+
fontSize: themeConfig.theme.spacing.headerFontSize,
|
|
11
|
+
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
padding: themeConfig.theme.spacing.headerPadding
|
|
14
|
+
}
|
|
15
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
16
|
+
style: {
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
gap: '8px'
|
|
20
|
+
}
|
|
21
|
+
}, /*#__PURE__*/ React.createElement("svg", {
|
|
22
|
+
fill: "currentColor",
|
|
23
|
+
style: {
|
|
24
|
+
color: themeConfig.theme.colors.metaText,
|
|
25
|
+
height: '16px',
|
|
26
|
+
width: '16px'
|
|
27
|
+
},
|
|
28
|
+
viewBox: "0 0 20 20"
|
|
29
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
30
|
+
clipRule: "evenodd",
|
|
31
|
+
d: "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z",
|
|
32
|
+
fillRule: "evenodd"
|
|
33
|
+
})), /*#__PURE__*/ React.createElement("span", {
|
|
34
|
+
style: {
|
|
35
|
+
color: themeConfig.theme.colors.headerText,
|
|
36
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
37
|
+
fontWeight: themeConfig.theme.typography.fontWeightMedium
|
|
38
|
+
}
|
|
39
|
+
}, found, " result", found !== 1 ? 's' : '', " found")));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ThemeContextValue } from '../themes/types.js';
|
|
2
|
+
interface RenderedNoResultsProps {
|
|
3
|
+
noResultsClassName?: string;
|
|
4
|
+
query: string;
|
|
5
|
+
themeConfig: ThemeContextValue;
|
|
6
|
+
}
|
|
7
|
+
export declare const RenderedNoResults: ({ noResultsClassName, query: _query, themeConfig, }: RenderedNoResultsProps) => import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=NoResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoResults.d.ts","sourceRoot":"","sources":["../../../src/components/render/NoResults.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,UAAU,sBAAsB;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,iBAAiB,CAAA;CAC/B;AAED,eAAO,MAAM,iBAAiB,GAAI,qDAI/B,sBAAsB,gCAoDxB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const RenderedNoResults = ({ noResultsClassName = '', query: _query, themeConfig })=>/*#__PURE__*/ React.createElement("div", {
|
|
2
|
+
className: noResultsClassName,
|
|
3
|
+
style: {
|
|
4
|
+
color: themeConfig.theme.colors.noResultsText,
|
|
5
|
+
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
6
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
7
|
+
padding: '40px 20px',
|
|
8
|
+
textAlign: 'center'
|
|
9
|
+
}
|
|
10
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
11
|
+
style: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column'
|
|
15
|
+
}
|
|
16
|
+
}, /*#__PURE__*/ React.createElement("svg", {
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
style: {
|
|
20
|
+
color: themeConfig.theme.colors.metaText,
|
|
21
|
+
height: '48px',
|
|
22
|
+
marginBottom: '12px',
|
|
23
|
+
width: '48px'
|
|
24
|
+
},
|
|
25
|
+
viewBox: "0 0 24 24"
|
|
26
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
27
|
+
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",
|
|
28
|
+
strokeLinecap: "round",
|
|
29
|
+
strokeLinejoin: "round",
|
|
30
|
+
strokeWidth: 1
|
|
31
|
+
})), /*#__PURE__*/ React.createElement("h3", {
|
|
32
|
+
style: {
|
|
33
|
+
color: themeConfig.theme.colors.titleText,
|
|
34
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
35
|
+
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
36
|
+
margin: 0,
|
|
37
|
+
marginBottom: '4px'
|
|
38
|
+
}
|
|
39
|
+
}, "No results found"), /*#__PURE__*/ React.createElement("p", {
|
|
40
|
+
style: {
|
|
41
|
+
color: themeConfig.theme.colors.descriptionText,
|
|
42
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
43
|
+
margin: 0
|
|
44
|
+
}
|
|
45
|
+
}, "Try searching for something else")));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ThemeContextValue } from '../themes/types.js';
|
|
2
|
+
interface RenderedResultErrorProps {
|
|
3
|
+
error: string;
|
|
4
|
+
errorClassName?: string;
|
|
5
|
+
themeConfig: ThemeContextValue;
|
|
6
|
+
}
|
|
7
|
+
export declare const RenderedResultError: ({ error, errorClassName, themeConfig, }: RenderedResultErrorProps) => import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ResultError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultError.d.ts","sourceRoot":"","sources":["../../../src/components/render/ResultError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,UAAU,wBAAwB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,iBAAiB,CAAA;CAC/B;AAED,eAAO,MAAM,mBAAmB,GAAI,yCAIjC,wBAAwB,gCA+C1B,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const RenderedResultError = ({ error, errorClassName = '', themeConfig })=>/*#__PURE__*/ React.createElement("div", {
|
|
2
|
+
className: errorClassName,
|
|
3
|
+
style: {
|
|
4
|
+
alignItems: 'center',
|
|
5
|
+
backgroundColor: themeConfig.theme.colors.errorBackground,
|
|
6
|
+
borderBottom: `1px solid ${themeConfig.theme.colors.resultBorder}`,
|
|
7
|
+
color: themeConfig.theme.colors.errorText,
|
|
8
|
+
display: 'flex',
|
|
9
|
+
fontFamily: themeConfig.theme.typography.fontFamily,
|
|
10
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
11
|
+
gap: '8px',
|
|
12
|
+
padding: '16px'
|
|
13
|
+
}
|
|
14
|
+
}, /*#__PURE__*/ React.createElement("svg", {
|
|
15
|
+
fill: "currentColor",
|
|
16
|
+
style: {
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
height: '20px',
|
|
19
|
+
width: '20px'
|
|
20
|
+
},
|
|
21
|
+
viewBox: "0 0 20 20"
|
|
22
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
23
|
+
clipRule: "evenodd",
|
|
24
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
|
|
25
|
+
fillRule: "evenodd"
|
|
26
|
+
})), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h3", {
|
|
27
|
+
style: {
|
|
28
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
29
|
+
fontWeight: themeConfig.theme.typography.fontWeightMedium,
|
|
30
|
+
margin: 0
|
|
31
|
+
}
|
|
32
|
+
}, "Search Error"), /*#__PURE__*/ React.createElement("p", {
|
|
33
|
+
style: {
|
|
34
|
+
color: themeConfig.theme.colors.errorText,
|
|
35
|
+
fontSize: themeConfig.theme.typography.fontSizeSm,
|
|
36
|
+
margin: 0
|
|
37
|
+
}
|
|
38
|
+
}, error)));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SearchResult } from '../../types.js';
|
|
2
|
+
import { type ThemeContextValue } from '../themes/types.js';
|
|
3
|
+
interface RenderedResultProps {
|
|
4
|
+
index: number;
|
|
5
|
+
onResultClick: (result: SearchResult) => void;
|
|
6
|
+
renderDate?: boolean;
|
|
7
|
+
result: SearchResult;
|
|
8
|
+
resultItemClassName?: string;
|
|
9
|
+
resultsContainerClassName?: string;
|
|
10
|
+
themeConfig: ThemeContextValue;
|
|
11
|
+
}
|
|
12
|
+
export declare function RenderedResult({ index, onResultClick, renderDate, result, resultItemClassName, resultsContainerClassName, themeConfig, }: RenderedResultProps): import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=Results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Results.d.ts","sourceRoot":"","sources":["../../../src/components/render/Results.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,YAAY,CAAA;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC,WAAW,EAAE,iBAAiB,CAAA;CAC/B;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,aAAa,EACb,UAAiB,EACjB,MAAM,EACN,mBAAwB,EACxB,yBAA8B,EAC9B,WAAW,GACZ,EAAE,mBAAmB,+BA4JrB"}
|