@searchstax-inc/searchstudio-ux-js 0.0.7 → 0.0.8

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.
Files changed (2) hide show
  1. package/README.md +36 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -29,14 +29,23 @@ After importing Searchstax class a new instance needs to be created:
29
29
 
30
30
  ## Initialization
31
31
  Initialization object
32
+
32
33
  {
34
+
33
35
  `language: string;` - language code. Example: 'en'
36
+
34
37
  `searchURL: string;` - SeachStudio select endpoint
38
+
35
39
  `suggesterURL: string;` - SeachStudio suggest endpoint
40
+
36
41
  `trackApiKey: string;` - Api key used for tracking events
42
+
37
43
  `searchAuth: string;` - Authentication value. based on authType it's either a token value or basic auth value
44
+
38
45
  `authType: 'token' | 'basic';` - Type of authentication
46
+
39
47
  }
48
+
40
49
  Initialization example
41
50
  ```
42
51
  searchstax.initialize({
@@ -52,20 +61,35 @@ searchstax.initialize({
52
61
 
53
62
  ## Input widget
54
63
  Initialization properties
64
+
55
65
  a. id of container where widget will be rendered
66
+
56
67
  b. {
68
+
57
69
  `suggestAfterMinChars: number;` - controls how many characters the UI should accept at the minimum before showing suggestions
70
+
58
71
  `templates?: {` - optional object that defines template override options
72
+
59
73
  `mainTemplate?: string;` - main template in Mustache templating language
74
+
60
75
  `searchInputId?: string;` - id of search input within the mainTemplate
76
+
61
77
  `autosuggestItemTemplate?: string;` - autosuggest item template in Mustache
78
+
62
79
  `};`
80
+
63
81
  `hooks?: {` - optional object that provides various hook options
82
+
64
83
  `beforeSearch?: (props: ISearchstaxSearchProps) => ISearchstaxSearchProps | null;` - this function gets called before firing search. searchProps are being passed as a property and can be modified, if passed along further search will execute with modified properties, if null is returned then event gets canceled and search never fires.
84
+
65
85
  `afterSearch?: (results: ISearchstaxParsedResult[]) => ISearchstaxParsedResult[];` - this function gets called after firing search and before rendering. It needs to return array of results that are either modified or untouched.
86
+
66
87
  `beforeAutosuggest?: (props: ISearchstaxSuggestProps) => ISearchstaxSuggestProps | null;` - this function gets called before firing autosuggest. autosuggestProps are being passed as a property and can be modified, if passed along further search will execute with modified properties, if null is returned then event gets canceled and search never fires.
88
+
67
89
  `afterAutosuggest?: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse;`- this function gets called after autosuggest has values but before rendering. It needs to return same type of data but it can be modified.
90
+
68
91
  `};`
92
+
69
93
  }
70
94
 
71
95
 
@@ -110,17 +134,29 @@ example of input widget initialization with various options
110
134
  ```
111
135
  ## Result widget
112
136
  Initialization properties
137
+
113
138
  a. id of container where widget will be rendered
139
+
114
140
  b. {
141
+
115
142
  `searchResultsContainerId?: string;` - this is needed only if mainTemplate is overridden. It points to an element in the template where results need to be rendered
143
+
116
144
  `searchResultUniqueIdAttribute?: string;` - this is needed only if searchResultTemplate is overridden. searchResultTemplate needs to have unique result id property. Default is data-searchstax-unique-result-id="{{uniqueId}}". see example below on how it is used
145
+
117
146
  `templates?: {` - optional object that defines template override options
147
+
118
148
  `mainTemplate?: string;` - main template in Mustache templating language.
149
+
119
150
  `searchResultTemplate?: string;` - result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering
151
+
120
152
  `noSearchResultTemplate?: string;` - Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
153
+
121
154
  `};`
155
+
122
156
  `hooks?: {` - optional object that provides various hook options
157
+
123
158
  `afterLinkClick?: (resultClicked: ISearchstaxParsedResult) => ISearchstaxParsedResult | null;` - function is called after user clicks result and passes that result as a property. when result is passed along tracking will execute and user will be navigated if null is returned events are canceled and nothing happens.
159
+
124
160
  `};`
125
161
  }
126
162
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchstax-inc/searchstudio-ux-js",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "files": [
6
6
  "dist"
7
7
  ],