@searchcraft/react-sdk 0.8.2 → 0.9.1

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 CHANGED
@@ -24,29 +24,37 @@ The React SDK provides the following prebuilt components for use in your applica
24
24
 
25
25
  ```jsx
26
26
 
27
- <SearchInputForm />
28
- <SearchPopoverForm />
29
- <FilterPanel />
30
- <ResultsInfo />
31
- <BaseSearchResults />
27
+ <SearchcraftInputForm />
28
+ <SearchcraftPopoverForm />
29
+ <SearchcraftFilterPanel />
30
+ <SearchcraftResultsInfo />
31
+ <SearchcraftBaseSearchResults />
32
+ <SearchcraftPagination />
32
33
 
33
34
  ```
34
35
 
35
36
  These components can be rendered directly in your app and customized with configurations as needed.
36
37
 
37
- Example Setup
38
+ #### Example Setup
38
39
 
40
+ As early as possible in the app lifecycle, initialize the Searchcraft object:
39
41
  ```jsx
42
+ import { Searchcraft } from '@searchcraft/react-sdk';
40
43
 
41
- import React from 'react';
42
- import { SearchInputForm, FilterPanel, BaseSearchResults } from '@searchcraft/react-sdk/components';
43
-
44
- const config = {
44
+ const searchcraft = new Searchcraft({
45
45
  index: ['your_index_from_vektron'],
46
46
  readKey: 'your_read_key_from_vektron',
47
47
  endpointURL: 'your_searchcraft_endpoint_url',
48
- searchDebounceDelay: 50, // Optional debounce delay in milliseconds
49
- };
48
+ })
49
+
50
+ ```
51
+
52
+ Add components to your application:
53
+
54
+ ```jsx
55
+
56
+ import React from 'react';
57
+ import { SearchInputForm, FilterPanel, BaseSearchResults } from '@searchcraft/react-sdk';
50
58
 
51
59
  const filterPanelItems = [
52
60
  {
@@ -68,7 +76,7 @@ const filterPanelItems = [
68
76
  const App = () => {
69
77
  return (
70
78
  <>
71
- <SearchInputForm config={config} />
79
+ <SearchInputForm />
72
80
  <FilterPanel items={filterPanelItems} />
73
81
  <BaseSearchResults />
74
82
  </>
@@ -173,32 +181,30 @@ export const searchResultMappings = {
173
181
 
174
182
  ```
175
183
 
176
- Event Handling
177
-
178
- The React SDK components support event handling for common actions such as query submission, input focus, or search results.
184
+ #### Event Handling
185
+ You can subscribe to various events within Searchcraft:
179
186
 
180
187
  ```jsx
181
188
 
182
- <SearchInputForm
183
- onQuerySubmit={(event) => {
184
- console.log('Query submitted:', event.detail);
185
- }}
186
- onInputFocus={() => {
187
- console.log('Input focused');
188
- }}
189
- onInputBlur={() => {
190
- console.log('Input blurred');
191
- }}
192
- />
193
-
194
- <BaseSearchResults
195
- onNoResults={() => {
196
- console.log('No results found');
197
- }}
198
- />
189
+ const searchcraft = new Searchcraft({
190
+ index: ['your_index_from_vektron'],
191
+ readKey: 'your_read_key_from_vektron',
192
+ endpointURL: 'your_searchcraft_endpoint_url',
193
+ searchDebounceDelay: 50, // The amount of debounce, in millis, to add to search requests (optional)
194
+ });
199
195
 
196
+ const unsubscribeCallback = searchcraft.subscribe('query_submitted', (event) => {
197
+ // Do something in your application when a query has been submitted
198
+ });
199
+
200
+
201
+ const unsubscribeCallback = searchcraft.subscribe('ad_container_rendered', (event) => {
202
+ // Do something when a new ad container has been rendered
203
+ });
200
204
  ```
201
205
 
206
+ For a complete listing of event subscriptions, refer to the api reference.
207
+
202
208
  Additional Information
203
209
 
204
210
  For more advanced use cases and component-specific documentation, refer to the official [Searchcraft React SDK documentation](https://docs.searchcraft.io/).
package/dist/index.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import { Components } from '@searchcraft/javascript-sdk';
2
2
  import { FC } from 'react';
3
+ import { SearchcraftConfig } from '@searchcraft/core';
4
+ import { SearchcraftCore } from '@searchcraft/core';
5
+
6
+ /**
7
+ * The consumer-facing Searchcraft class.
8
+ */
9
+ export declare class Searchcraft extends SearchcraftCore {
10
+ constructor(config: SearchcraftConfig);
11
+ }
3
12
 
4
13
  /**
5
14
  * A component that renders a list of search results with customizable styles, layout, and link behavior.
@@ -274,4 +283,7 @@ export declare const SearchcraftTheme: FC<SearchcraftThemeProps>;
274
283
  export declare interface SearchcraftThemeProps extends Components.SearchcraftTheme {
275
284
  }
276
285
 
286
+
287
+ export * from "@searchcraft/core/dist/types/sdk-types";
288
+
277
289
  export { }