@searchcraft/react-sdk 0.9.7 → 0.10.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/README.md +1 -1
- package/dist/client/index.d.ts +292 -0
- package/dist/client/index.js +4534 -0
- package/dist/client/index.js.map +1 -0
- package/dist/server/index.d.ts +2601 -0
- package/dist/server/index.js +4581 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +14 -10
- package/dist/index.d.ts +0 -3544
- package/dist/index.js +0 -5139
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ The React SDK provides the following prebuilt components for use in your applica
|
|
|
28
28
|
<SearchcraftPopoverForm />
|
|
29
29
|
<SearchcraftFilterPanel />
|
|
30
30
|
<SearchcraftResultsInfo />
|
|
31
|
-
<
|
|
31
|
+
<SearchcraftSearchResults />
|
|
32
32
|
<SearchcraftPagination />
|
|
33
33
|
|
|
34
34
|
```
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { Components } from '@searchcraft/javascript-sdk';
|
|
2
|
+
import { defineCustomElements } from '@searchcraft/javascript-sdk';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { SearchcraftConfig } from '@searchcraft/javascript-sdk';
|
|
5
|
+
import { SearchcraftCore } from '@searchcraft/javascript-sdk';
|
|
6
|
+
|
|
7
|
+
export { defineCustomElements }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The consumer-facing Searchcraft class.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Searchcraft extends SearchcraftCore {
|
|
13
|
+
constructor(config: SearchcraftConfig);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A component that represents a filter panel UI view, allowing users to refine and control their search queries by applying various filter criteria.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import React from 'react';
|
|
22
|
+
* import { SearchcraftFilterPanel } from '@searchcraft/react-sdk';
|
|
23
|
+
* import filterItems from './filterItems';
|
|
24
|
+
*
|
|
25
|
+
* const MyFilterComponent = () => {
|
|
26
|
+
* return (
|
|
27
|
+
* <SearchcraftFilterPanel items={filterItems} />
|
|
28
|
+
* );
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* export default MyFilterComponent;
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const SearchcraftFilterPanel: FC<SearchcraftFilterPanelProps>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The props for the SearchcraftFilterPanel.
|
|
38
|
+
*/
|
|
39
|
+
export declare interface SearchcraftFilterPanelProps extends Components.SearchcraftFilterPanel {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A component that provides a user-friendly interface for querying an indexed dataset,
|
|
44
|
+
* enabling users to easily search large collections of data. It abstracts the complexities
|
|
45
|
+
* of index-based searching, making it accessible to users of all technical levels.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import React from 'react';
|
|
50
|
+
* import { SearchcraftInputForm } from '@searchcraft/react-sdk';
|
|
51
|
+
* import searchcraftConfig from './searchcraftConfig';
|
|
52
|
+
*
|
|
53
|
+
* const MySearchComponent = () => {
|
|
54
|
+
* const handleQuerySubmit = (event: CustomEvent<string>) => {
|
|
55
|
+
* console.log("Query submitted", event.detail);
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <SearchcraftInputForm
|
|
60
|
+
* config={searchcraftConfig}
|
|
61
|
+
* autoSearch={true}
|
|
62
|
+
* buttonPlacement="right"
|
|
63
|
+
* buttonLabel="Search"
|
|
64
|
+
* inputLabel="Search Database"
|
|
65
|
+
* customStyles={{ border: "1px solid gray", padding: "5px" }}
|
|
66
|
+
* placeholderValue="Search here..."
|
|
67
|
+
* searchTerm=""
|
|
68
|
+
* onQuerySubmit={handleQuerySubmit}
|
|
69
|
+
* onInputCleared={() => console.log("Input cleared")}
|
|
70
|
+
* onNoResultsReceived={() => console.log("No results found")}
|
|
71
|
+
* onInputFocus={() => console.log("Input focused")}
|
|
72
|
+
* onInputBlur={() => console.log("Input blurred")}
|
|
73
|
+
* onInputInit={() => console.log("Input initialized")}
|
|
74
|
+
* />
|
|
75
|
+
* );
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* export default MySearchComponent;
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const SearchcraftInputForm: FC<SearchcraftInputFormProps>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The props for the SearchcraftInputForm.
|
|
85
|
+
*/
|
|
86
|
+
export declare interface SearchcraftInputFormProps extends Components.SearchcraftInputForm {
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* This React component is designed to facilitate pagination of search results.
|
|
91
|
+
* Once a query is submitted, calculates the number for pages.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx
|
|
95
|
+
* import React from 'react';
|
|
96
|
+
* import { SearchcraftPagination } from '@searchcraft/react-sdk';
|
|
97
|
+
*
|
|
98
|
+
* const MyPaginationComponent = () => {
|
|
99
|
+
* return (
|
|
100
|
+
* // other searchcraft components
|
|
101
|
+
* <SearchcraftPagination />
|
|
102
|
+
* );
|
|
103
|
+
* };
|
|
104
|
+
*
|
|
105
|
+
* export default MyPaginationComponent;
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare const SearchcraftPagination: FC<SearchcraftPaginationProps>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The props for the SearchcraftPagination component.
|
|
112
|
+
*/
|
|
113
|
+
export declare interface SearchcraftPaginationProps extends Components.SearchcraftPagination {
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A button component that, when clicked, toggles the visibility of a popover.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* import React from 'react';
|
|
122
|
+
* import { SearchcraftPopoverButton } from '@searchcraft/react-sdk';
|
|
123
|
+
*
|
|
124
|
+
* const MyPopoverTrigger = () => {
|
|
125
|
+
* return (
|
|
126
|
+
* <SearchcraftPopoverButton>
|
|
127
|
+
* Open Popover
|
|
128
|
+
* </SearchcraftPopoverButton>
|
|
129
|
+
* );
|
|
130
|
+
* };
|
|
131
|
+
*
|
|
132
|
+
* export default MyPopoverTrigger;
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare const SearchcraftPopoverButton: FC<SearchcraftPopoverButtonProps>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The props for the SearchcraftPopoverButton.
|
|
139
|
+
*/
|
|
140
|
+
export declare interface SearchcraftPopoverButtonProps extends Components.SearchcraftPopoverButton {
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A component that displays search results in a popover container that dynamically appears
|
|
145
|
+
* when the user interacts with a search input field, or when a popover button is clicked.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* import React from 'react';
|
|
150
|
+
* import { SearchcraftPopoverForm } from '@searchcraft/react-sdk';
|
|
151
|
+
* import searchcraftConfig from './searchcraftConfig';
|
|
152
|
+
* import popoverResultMappings from './popoverResultMappings';
|
|
153
|
+
*
|
|
154
|
+
* const MyPopoverSearch = () => {
|
|
155
|
+
* return (
|
|
156
|
+
* <SearchcraftPopoverForm
|
|
157
|
+
* config={searchcraftConfig}
|
|
158
|
+
* type="fullscreen"
|
|
159
|
+
* popoverResultMappings={popoverResultMappings}
|
|
160
|
+
* hotkey="k"
|
|
161
|
+
* hotkeyModifier="meta"
|
|
162
|
+
* />
|
|
163
|
+
* );
|
|
164
|
+
* };
|
|
165
|
+
*
|
|
166
|
+
* export default MyPopoverSearch;
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare const SearchcraftPopoverForm: FC<SearchcraftPopoverFormProps>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The props for the SearchcraftPopoverForm component.
|
|
173
|
+
*/
|
|
174
|
+
export declare interface SearchcraftPopoverFormProps extends Components.SearchcraftPopoverForm {
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* This React component is designed to display the number of results returned from a search query.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* import React, { useEffect, useRef } from 'react';
|
|
183
|
+
* import { SearchcraftResultsInfo } from '@searchcraft/react-sdk';
|
|
184
|
+
*
|
|
185
|
+
* const MyResultsInfo = () => {
|
|
186
|
+
* const ref = useRef();
|
|
187
|
+
*
|
|
188
|
+
* useEffect(() => {
|
|
189
|
+
* ref.current.customFormatter = (range, count, responseTime) =>
|
|
190
|
+
* `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* return <SearchcraftResultsInfo ref={ref} />;
|
|
194
|
+
* };
|
|
195
|
+
*
|
|
196
|
+
* export default MyResultsInfo;
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export declare const SearchcraftResultsInfo: FC<SearchcraftResultsInfoProps>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The Props for the SearchcraftResultsInfo component.
|
|
203
|
+
*/
|
|
204
|
+
export declare interface SearchcraftResultsInfoProps extends Components.SearchcraftResultsInfo {
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A component that renders a list of search results with customizable styles, layout, and link behavior.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```tsx
|
|
212
|
+
* import React from 'react';
|
|
213
|
+
* import { SearchcraftSearchResults } from '@searchcraft/react-sdk';
|
|
214
|
+
* import searchResultMappings from './searchResultMappings';
|
|
215
|
+
*
|
|
216
|
+
* const MySearchComponent = () => {
|
|
217
|
+
* return (
|
|
218
|
+
* <SearchcraftSearchResults
|
|
219
|
+
* searchResultMappings={searchResultMappings}
|
|
220
|
+
* resultImagePlacement="left"
|
|
221
|
+
* buttonLabel="View More"
|
|
222
|
+
* buttonTarget="_blank"
|
|
223
|
+
* buttonRel="noopener"
|
|
224
|
+
* containerTarget="_self"
|
|
225
|
+
* containerRel="nofollow"
|
|
226
|
+
* onNoResults={() => console.log("No search results found")}
|
|
227
|
+
* />
|
|
228
|
+
* );
|
|
229
|
+
* };
|
|
230
|
+
*
|
|
231
|
+
* export default MySearchComponent;
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare const SearchcraftSearchResults: FC<SearchcraftSearchResultsProps>;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* This React component is designed to choose the number of search results displayed.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```tsx
|
|
241
|
+
* import React from 'react';
|
|
242
|
+
* import { SearchcraftSearchResultsPerPage } from '@searchcraft/react-sdk';
|
|
243
|
+
*
|
|
244
|
+
* const MyResultsPerPage = () => {
|
|
245
|
+
* return <SearchcraftSearchResultsPerPage increment={20} />;
|
|
246
|
+
* };
|
|
247
|
+
*
|
|
248
|
+
* export default MyResultsPerPage;
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export declare const SearchcraftSearchResultsPerPage: FC<SearchcraftSearchResultsPerPageProps>;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The Props for the SearchcraftSearchResultsPerPage component.
|
|
255
|
+
*/
|
|
256
|
+
export declare interface SearchcraftSearchResultsPerPageProps extends Components.SearchcraftSearchResultsPerPage {
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The props for the SearchcraftSearchResults component.
|
|
261
|
+
*/
|
|
262
|
+
export declare interface SearchcraftSearchResultsProps extends Components.SearchcraftSearchResults {
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A component that applies Searchcraft's built-in CSS theme to your page.
|
|
267
|
+
* It does not render anything visible—its only function is to manage the CSS styles on the page.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```tsx
|
|
271
|
+
* import React from 'react';
|
|
272
|
+
* import { SearchcraftTheme } from '@searchcraft/react-sdk';
|
|
273
|
+
*
|
|
274
|
+
* const MyThemeProvider = () => {
|
|
275
|
+
* return <SearchcraftTheme />;
|
|
276
|
+
* };
|
|
277
|
+
*
|
|
278
|
+
* export default MyThemeProvider;
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare const SearchcraftTheme: FC<SearchcraftThemeProps>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* The Props for the SearchcraftTheme component.
|
|
285
|
+
*/
|
|
286
|
+
export declare interface SearchcraftThemeProps extends Components.SearchcraftTheme {
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
export * from "@searchcraft/javascript-sdk";
|
|
291
|
+
|
|
292
|
+
export { }
|