@searchstax-inc/searchstudio-ux-js 0.0.9 → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Change Log
2
+
3
+ All notable changes to the "vite-vanilla-ts-lib-starter" project will be documented in this file.
4
+
5
+ ## [0.0.1] - 2023-01-18
6
+
7
+ - Update all packages to the latest versions (update to vite 4.x)
8
+
9
+ ## [0.0.1] - 2022-09-08
10
+
11
+ - Update all packages to the latest versions (update to vite 3.x)
12
+
13
+ ## [0.0.0] - 2022-03-28
14
+
15
+ - Initial release
package/README.md CHANGED
@@ -59,6 +59,32 @@ searchstax.initialize({
59
59
  });
60
60
  ```
61
61
 
62
+ ## Initial layout
63
+ Our base theme is designed with this layout in mind but it is optional as all widgets have id parameters and can be attached to any element.
64
+ ```
65
+ <div class="searchstax-page-layout-container">
66
+ <div id="searchstax-input-container"></div>
67
+
68
+ <div class="search-details-container">
69
+ <div id="search-feedback-container"></div>
70
+ <div id="search-sorting-container"></div>
71
+ </div>
72
+
73
+ <div class="searchstax-page-layout-facet-result-container">
74
+ <div class="searchstax-page-layout-facet-container">
75
+ <div id="searchstax-facets-container"></div>
76
+ </div>
77
+
78
+ <div class="searchstax-page-layout-result-container">
79
+ <div id="searchstax-external-promotions-layout-container"></div>
80
+ <div id="searchstax-results-container"></div>
81
+ <div id="searchstax-related-searches-container"></div>
82
+ <div id="searchstax-pagination-container"></div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ ```
87
+
62
88
  ## Input widget
63
89
  Initialization properties
64
90
 
@@ -70,17 +96,19 @@ b. {
70
96
 
71
97
  `templates?: {` - optional object that defines template override options
72
98
 
73
- `mainTemplate?: string;` - main template in Mustache templating language
74
-
75
- `searchInputId?: string;` - id of search input within the mainTemplate
76
-
77
- `autosuggestItemTemplate?: string;` - autosuggest item template in Mustache
99
+ `mainTemplate?: {` - optional object for overriding main template
100
+ `template: string;` - main template in Mustache templating language
101
+ `searchInputId: string;` - id of search input within the mainTemplate
102
+ `};`
78
103
 
104
+ `autosuggestItemTemplate?: {` - autosuggest item template in Mustache
105
+ `template: string;` - autosuggest template in Mustache templating language
106
+ `};`
79
107
  `};`
80
108
 
81
109
  `hooks?: {` - optional object that provides various hook options
82
110
 
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.
111
+ `beforeSearch?: (props: ISearchObject) => ISearchObject | 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
112
 
85
113
  `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
114
 
@@ -93,12 +121,20 @@ b. {
93
121
  }
94
122
 
95
123
 
124
+ example of input widget initialization with minimum options
125
+ ```
126
+ searchstax.addSearchInputWidget("searchstax-input-container", {
127
+ suggestAfterMinChars: 3,
128
+ });
129
+ ```
130
+
131
+
96
132
  example of input widget initialization with various options
97
133
  ```
98
134
  searchstax.addSearchInputWidget("searchstax-input-container", {
99
135
  suggestAfterMinChars: 3,
100
136
  hooks: {
101
- beforeSearch: function (props: ISearchstaxSearchProps) {
137
+ beforeSearch: function (props: ISearchObject) {
102
138
  const propsCopy = { ...props };
103
139
  return propsCopy;
104
140
  },
@@ -109,7 +145,6 @@ example of input widget initialization with various options
109
145
  },
110
146
  afterAutosuggest: function (result: ISearchstaxSuggestResponse) {
111
147
  const copy = { ...result };
112
- console.log("copy", copy);
113
148
  return copy;
114
149
  },
115
150
  beforeAutosuggest: function (props: ISearchstaxSuggestProps) {
@@ -121,14 +156,22 @@ example of input widget initialization with various options
121
156
  },
122
157
  },
123
158
  templates: {
124
- mainTemplate: `<div class="searchstax-search-input-container">
125
- <div class="searchstax-search-input-wrapper">
126
- <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
127
- <button class="searchstax-spinner-icon" id="searchstax-search-input-action-button"></button>
128
- </div>
129
- </div>`,
130
- searchInputId: "searchstax-input-container",
131
- autosuggestItemTemplate: `<div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>`,
159
+ mainTemplate: {
160
+ template: `
161
+ <div class="searchstax-search-input-container">
162
+ <div class="searchstax-search-input-wrapper">
163
+ <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
164
+ <button class="searchstax-spinner-icon" id="searchstax-search-input-action-button"></button>
165
+ </div>
166
+ </div>
167
+ `,
168
+ searchInputId: "searchstax-search-input"
169
+ }
170
+ autosuggestItemTemplate: {
171
+ template: `
172
+ <div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>
173
+ `,
174
+ }
132
175
  },
133
176
  });
134
177
  ```
@@ -139,17 +182,23 @@ a. id of container where widget will be rendered
139
182
 
140
183
  b. {
141
184
 
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
-
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
185
+ `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
186
 
146
187
  `templates?: {` - optional object that defines template override options
147
188
 
148
- `mainTemplate?: string;` - main template in Mustache templating language.
189
+ `mainTemplate?: {`
190
+ template: string; - main template in Mustache templating language.,
191
+ searchResultsContainerId: string;` - this is needed only if mainTemplate is overridden. It points to an element in the template where results need to be rendered
192
+ }
149
193
 
150
- `searchResultTemplate?: string;` - result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering
194
+ `searchResultTemplate?: {`
195
+ template: string - result template using Mustache. ISearchstaxParsedResult is passed to the template and all its properties are available to be used when rendering;
196
+ 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="niqueId". see example below on how it is used
197
+ }
151
198
 
152
- `noSearchResultTemplate?: string;` - Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
199
+ `noSearchResultTemplate?: {`
200
+ template: string - Mustache template for no results section override. spellingSuggestion and searchTerm are values available in the template
201
+ }
153
202
 
154
203
  `};`
155
204
 
@@ -160,57 +209,90 @@ b. {
160
209
  `};`
161
210
  }
162
211
 
212
+ example of results widget initialization with minimum options
213
+ ```
214
+ searchstax.addSearchResultsWidget("searchstax-results-container", {});
215
+ ```
216
+
163
217
  example of result widget initialization with various options
164
218
  ```
165
219
  searchstax.addSearchResultsWidget("searchstax-results-container", {
166
- // searchResultUniqueIdAttribute: ' data-searchstax-unique-result-id', if custom result template is used
167
- // points to an attribute that will be used to identify a result
168
- searchResultsContainerId: "searchstax-result-container", // if main template is over ridden this points to an
169
- // id in the main element where results need to be rendered
170
220
  templates: {
171
- mainTemplate: `
172
- <div class="searchstax-search-results-container">
173
- <div id="searchstax-result-container"></div>
174
- </div>
175
- `,
176
- searchResultTemplate: `<div class="searchstax-search-result">
177
- {{#url}}
178
- <a href="{{url}}" data-searchstax-unique-result-id="{{uniqueId}}" class="searchstax-result-item-link"></a>
179
- {{/url}}
180
- {{#ribbon}}
181
- <div class="searchstax-search-result-ribbon">
182
- {{ribbon}}
183
- </div>
184
- {{/ribbon}}
185
- {{#thumbnail}}
186
- <img :src="thumbnail" class="searchstax-thumbnail">
187
- {{/thumbnail}}
188
- <div class="searchstax-search-result-title-container">
189
- <span class="searchstax-search-result-title">{{title}}</span>
190
- </div>
191
- {{#paths}}
192
- <p class="searchstax-search-result-common">
193
- {{paths}}
194
- </p>
195
- {{/paths}}
196
- {{#description}}
197
- <p class="searchstax-search-result-description searchstax-search-result-common">
198
- {{description}}
199
- </p>
200
- {{/description}}
201
- {{#unmappedFields}}
202
- {{#isImage}}
203
- <div class="searchstax-search-result-image-container">
204
- <img :src="result[value]" class="searchstax-result-image">
205
- </div>
206
- {{/isImage}}
207
- {{^isImage}}
208
- <p class="searchstax-search-result-common">
209
- {{value}}
210
- </p>
211
- {{/isImage}}
212
- {{/unmappedFields}}
213
- </div>`,
221
+ mainTemplate: {
222
+ template: `
223
+ <div class="searchstax-search-results-container">
224
+ <div class="searchstax-search-results" id="searchstax-search-results"></div>
225
+ </div>
226
+ `,
227
+ searchResultsContainerId: "searchstax-search-results",
228
+ },
229
+ searchResultTemplate: {
230
+ template: `
231
+ <div class="searchstax-search-result {{#thumbnail}} has-thumbnail {{/thumbnail}}">
232
+ {{#promoted}}
233
+ <div class="searchstax-search-result-promoted"></div>
234
+ {{/promoted}}
235
+
236
+ {{#url}}
237
+ <a href="{{url}}" data-searchstax-unique-result-id="{{uniqueId}}" class="searchstax-result-item-link"></a>
238
+ {{/url}}
239
+
240
+ {{#ribbon}}
241
+ <div class="searchstax-search-result-ribbon">
242
+ {{ribbon}}
243
+ </div>
244
+ {{/ribbon}}
245
+
246
+ {{#thumbnail}}
247
+ <img src="{{thumbnail}}" class="searchstax-thumbnail">
248
+ {{/thumbnail}}
249
+ <div class="searchstax-search-result-title-container">
250
+ <span class="searchstax-search-result-title">{{title}}</span>
251
+ </div>
252
+
253
+ {{#paths}}
254
+ <p class="searchstax-search-result-common">
255
+ {{paths}}
256
+ </p>
257
+ {{/paths}}
258
+
259
+ {{#description}}
260
+ <p class="searchstax-search-result-description searchstax-search-result-common">
261
+ {{description}}
262
+ </p>
263
+ {{/description}}
264
+
265
+ {{#unmappedFields}}
266
+ {{#isImage}}
267
+ <div class="searchstax-search-result-image-container">
268
+ <img src="{{value}}" class="searchstax-result-image">
269
+ </div>
270
+ {{/isImage}}
271
+ {{^isImage}}
272
+ <p class="searchstax-search-result-common">
273
+ {{value}}
274
+ </p>
275
+ {{/isImage}}
276
+ {{/unmappedFields}}
277
+ </div>
278
+ `,
279
+ searchResultUniqueIdAttribute: "data-searchstax-unique-result-id"
280
+ },
281
+ noSearchResultTemplate: {
282
+ template: `
283
+ <div class="searchstax-no-results">
284
+ Showing <strong>no results</strong> for <strong>"{{ searchTerm }}"</strong>
285
+ <br>
286
+ {{#spellingSuggestion}}
287
+ <span>&nbsp;Did you mean <a href="#" class="searchstax-suggestion-term">{{ spellingSuggestion }}</a>?</span>
288
+ {{/spellingSuggestion}}
289
+ </div>
290
+ <div>
291
+ <p>Try searching for search related terms or topics. We offer a wide variety of content to help you get the information you need.</p>
292
+ <p>Lost? Click on the ‘X” in the Search Box to reset your search.</p>
293
+ </div>
294
+ `
295
+ }
214
296
  },
215
297
  hooks: {
216
298
  afterLinkClick: function (result: ISearchstaxParsedResult) {
@@ -223,6 +305,235 @@ example of result widget initialization with various options
223
305
  });
224
306
  ```
225
307
 
308
+ ## Pagination widget
309
+ Initialization properties
310
+
311
+ a. id of container where widget will be rendered
312
+
313
+ b. {
314
+
315
+ `templates?: {` - optional object that defines template override options
316
+
317
+ `mainTemplate?: {` - optional object for overriding main template
318
+ `template: string;` - main template in Mustache templating language
319
+ `previousButtonClass: string;` - class of previous page link within template,
320
+ `nextButtonClass: string;` - class of next page link within template,
321
+ `};`
322
+ `};`
323
+
324
+ }
325
+
326
+ example of pagination widget initialization with minimum options
327
+ ```
328
+ searchstax.addPaginationWidget("searchstax-pagination-container", {});
329
+ ```
330
+
331
+ example of pagination widget initialization with various options
332
+ ```
333
+ searchstax.addPaginationWidget("searchstax-pagination-container", {
334
+ templates: {
335
+ mainTemplate: {
336
+ template: `
337
+ {{#results.length}}
338
+ <div class="searchstax-pagination-container">
339
+ <div class="searchstax-pagination-content">
340
+ <a class="searchstax-pagination-previous {{#isFirstPage}}disabled{{/isFirstPage}}" id="searchstax-pagination-previous">< Previous</a>
341
+ <div class="searchstax-pagination-details">
342
+ {{startResultIndex}} - {{endResultIndex}} of {{totalResults}}
343
+ </div>
344
+ <a class="searchstax-pagination-next {{#isLastPage}}disabled{{/isLastPage}}" id="searchstax-pagination-next">Next ></a>
345
+ </div>
346
+ </div>
347
+ {{/results.length}}
348
+ `,
349
+ previousButtonClass: "searchstax-pagination-previous",
350
+ nextButtonClass: "searchstax-pagination-next"
351
+ }
352
+ },
353
+ });
354
+ ```
355
+
356
+ ## Facets widget
357
+ Initialization properties
358
+
359
+ a. id of container where widget will be rendered
360
+
361
+ b. {
362
+
363
+ `facetingType`: "and" | "or" | "showUnavailable" - type that determines how facets will behave,
364
+
365
+ `itemsPerPageDesktop`: number - default expanded facets for desktop,
366
+
367
+ `itemsPerPageMobile`: number - default expanded facets for mobile,
368
+
369
+ `templates?: {` - optional object that defines template override options
370
+
371
+ `mainTemplateDesktop?: {` - optional object for overriding main template
372
+ `template: string;` - main template in Mustache templating language
373
+ `facetsContainerClass: string;` - class of container where facets will be placed
374
+ `},`
375
+
376
+ `mainTemplateMobile?: {` - optional object for overriding main mobile template
377
+ `template: string;` - main template in Mustache templating language
378
+ `facetsContainerId: string;` - id of container where facets will be placed
379
+ `closeOverlayTriggerClasses: string[];` - class list of all elements that should trigger mobile overlay close action
380
+ `filterByContainerId: string` - id of container where "Filter By" button will be rendered
381
+ 'selectedFacetsContainerId: string' - id of container where selected facets will be listed
382
+ `},`
383
+
384
+ `showMoreButtonContainerTemplate?: {` - optional object for overriding facet section show more/less template
385
+ `template: string;` - main template in Mustache templating language
386
+ `showMoreButtonClass: string;` - class of container where show more/less button will be placed
387
+ `},`
388
+
389
+ `facetItemContainerTemplate?: {` - optional object for overriding facet container template
390
+ `template: string;` - main template in Mustache templating language
391
+ 'facetListTitleContainerClass: string;' - container class where facet category title will be rendered within template
392
+ `facetListContainerClass: string;` - container class where facet items will be listed
393
+ `},`
394
+
395
+ `clearFacetsTemplate?: {` - optional object for overriding clear facets container template
396
+ `template: string;` - main template in Mustache templating language
397
+ 'containerId: string;' - container id where clear facets button will be rendered
398
+ `},`
399
+
400
+ `facetItemTemplate?: {` - optional object for overriding clear facet item template
401
+ `template: string;` - main template in Mustache templating language
402
+ 'inputCheckboxClass: string;' - class of checkboxes
403
+ 'checkTriggerClasses: string[];' - class list of elements that trigger facet select/unselect action
404
+ `},`
405
+
406
+ `filterByTemplate?: {` - optional object for overriding filter by button template
407
+ `template: string;` - main template in Mustache templating language
408
+ 'containerId: string;' - id where button will be placed within the template
409
+ `},`
410
+
411
+ `selectedFacetsTemplate?: {` - optional object for overriding selected facets template
412
+ `template: string;` - main template in Mustache templating language
413
+ 'containerId: string;' - id where selected facets will be placed within the template
414
+ `},`
415
+ `};`
416
+
417
+ }
418
+
419
+ example of facets widget initialization with minimum options
420
+ ```
421
+ searchstax.addFacetsWidget("searchstax-facets-container", {
422
+ facetingType: "and",
423
+ itemsPerPageDesktop: 3,
424
+ itemsPerPageMobile: 99,
425
+ });
426
+ ```
427
+
428
+
429
+ example of facets widget initialization with various options
430
+ ```
431
+ searchstax.addFacetsWidget("searchstax-facets-container", {
432
+ facetingType: "and",
433
+ itemsPerPageDesktop: 3,
434
+ itemsPerPageMobile: 99,
435
+ templates: {
436
+ mainTemplateDesktop: {
437
+ template: `
438
+ {{#hasResultsOrExternalPromotions}}
439
+ <div class="searchstax-facets-container-desktop"></div>
440
+ {{/hasResultsOrExternalPromotions}}
441
+ `,
442
+ facetsContainerId: "",
443
+ },
444
+ mainTemplateMobile: {
445
+ template: `
446
+ <div class="searchstax-facets-pills-container">
447
+ <div class="searchstax-facets-pills-selected">
448
+ </div>
449
+ </div>
450
+
451
+ <div class="searchstax-facets-mobile-overlay {{#overlayOpened}} searchstax-show{{/overlayOpened}}" >
452
+ <div class="searchstax-facets-mobile-overlay-header">
453
+ <div class="searchstax-facets-mobile-overlay-header-title">Filter By</div>
454
+ <div class="searchstax-search-close"></div>
455
+ </div>
456
+ <div class="searchstax-facets-container-mobile"></div>
457
+ <button class="searchstax-facets-mobile-overlay-done">Done</button>
458
+ </div>
459
+ </div>
460
+ `,
461
+ facetsContainerId: ``,
462
+ closeOverlayTriggerClasses: ["searchstax-facets-mobile-overlay-done","searchstax-search-close",],
463
+ filterByContainerId: ``,
464
+ selectedFacetsContainerId: ``,
465
+ },
466
+ showMoreButtonContainerTemplate: {
467
+ template: `
468
+ <div class="searchstax-facet-show-more-container">
469
+ {{#showingAllFacets}}
470
+ <div class="searchstax-facet-show-less-button searchstax-facet-show-button">less</div>
471
+ {{/showingAllFacets}}
472
+ {{^showingAllFacets}}
473
+ <div class="searchstax-facet-show-more-button searchstax-facet-show-button">more {{onShowMoreLessClick}}</div>
474
+ {{/showingAllFacets}}
475
+ </div>
476
+ `,
477
+ showMoreButtonClass: `searchstax-facet-show-more-container`,
478
+ },
479
+ facetItemContainerTemplate: {
480
+ template: `
481
+ <div>
482
+ <div class="searchstax-facet-title-container">
483
+ <div class="searchstax-facet-title">
484
+ {{label}}
485
+ </div>
486
+ <div class="searchstax-facet-title-arrow active"></div>
487
+ </div>
488
+ <div class="searchstax-facet-values-container"></div>
489
+ </div>
490
+ `,
491
+ facetListTitleContainerClass: `searchstax-facet-title-container`,
492
+ facetListContainerClass: `searchstax-facet-values-container`,
493
+ },
494
+ clearFacetsTemplate: {
495
+ template: `
496
+ {{#shouldShow}}}
497
+ <div class="searchstax-facets-pill searchstax-clear-filters searchstax-facets-pill-clear-all">
498
+ <div class="searchstax-facets-pill-label">Clear Filters</div>
499
+ </div>
500
+ {{/shouldShow}}
501
+ `,
502
+ containerId: ``,
503
+ },
504
+ facetItemTemplate: {
505
+ template: `
506
+ <div class="searchstax-facet-input">
507
+ <input type="checkbox" class="searchstax-facet-input-checkbox" {{#disabled}}disabled{{/disabled}} {{#isChecked}}checked{{/isChecked}}/>
508
+ </div>
509
+ <div class="searchstax-facet-value-label">{{value}}</div>
510
+ <div class="searchstax-facet-value-count">({{count}})</div>
511
+ `,
512
+ inputCheckboxClass: `searchstax-facet-input-checkbox`,
513
+ checkTriggerClasses: ["searchstax-facet-value-label","searchstax-facet-value-count",],
514
+ },
515
+ filterByTemplate: {
516
+ template: `
517
+ <div class="searchstax-facets-pill searchstax-facets-pill-filter-by">
518
+ <div class="searchstax-facets-pill-label">Filter By</div>
519
+ </div>
520
+ `,
521
+ containerId: ``,
522
+ },
523
+ selectedFacetsTemplate: {
524
+ template: `
525
+ <div class="searchstax-facets-pill searchstax-facets-pill-facets">
526
+ <div class="searchstax-facets-pill-label">{{value}} ({{count}})</div>
527
+ <div class="searchstax-facets-pill-icon-close"></div>
528
+ </div>
529
+ `,
530
+ containerId: ``,
531
+ },
532
+
533
+ },
534
+ });
535
+ ```
536
+
226
537
  ## Template overrides
227
538
  Templates use mustache templating. For more info see https://github.com/janl/mustache.js
228
539