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

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
@@ -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
 
@@ -0,0 +1,158 @@
1
+ // Generated by dts-bundle-generator v7.1.0
2
+
3
+ export interface ISearchstaxParsedResult {
4
+ custom?: any;
5
+ ribbon: string | null;
6
+ paths: string | null;
7
+ url: string | null;
8
+ title: string | null;
9
+ promoted: boolean | null;
10
+ thumbnail: string | null;
11
+ date: string | null;
12
+ snippet: string | null;
13
+ description: string | null;
14
+ uniqueId: string;
15
+ position: number;
16
+ unmappedFields: {
17
+ key: string;
18
+ value: string | string[] | boolean;
19
+ isImage?: boolean;
20
+ }[];
21
+ allFields: {
22
+ key: string;
23
+ value: string | string[] | boolean;
24
+ }[];
25
+ }
26
+ export interface ISearchstaxSearchMetadata {
27
+ recordsPerPageValue: number;
28
+ startDocVal: number;
29
+ totalResultsValue: number;
30
+ latency: number;
31
+ endDocValue: number;
32
+ spellingSuggestion: string;
33
+ }
34
+ export interface ISearchstaxSuggestResponseHeader {
35
+ zkConnected: boolean;
36
+ status: number;
37
+ qTime: number;
38
+ }
39
+ export interface ISearchstaxSuggestion {
40
+ term: string;
41
+ weight: number;
42
+ payload: string;
43
+ }
44
+ export interface ISearchstaxSEARCHTERM {
45
+ numFound: number;
46
+ suggestions: ISearchstaxSuggestion[];
47
+ }
48
+ export interface ISearchstaxStudio_suggestor_LANG {
49
+ [key: string]: ISearchstaxSEARCHTERM;
50
+ }
51
+ export interface ISearchstaxSuggest {
52
+ [key: string]: ISearchstaxStudio_suggestor_LANG;
53
+ }
54
+ export interface ISearchstaxSuggestResponse {
55
+ responseHeader: ISearchstaxSuggestResponseHeader;
56
+ suggest: ISearchstaxSuggest;
57
+ }
58
+ declare class Observable {
59
+ value: any;
60
+ observers: Function[];
61
+ constructor(value: any);
62
+ subscribe(observer: (data: any) => void): void;
63
+ unsubscribe(observer: (data: any) => void): void;
64
+ setValue(value: any): void;
65
+ getValue(): any;
66
+ notify(): void;
67
+ }
68
+ declare class DataLAyer {
69
+ searchTermChangeObservable: Observable;
70
+ loadingChangeObservable: Observable;
71
+ searchResultsObservable: Observable;
72
+ searchResultsMetadataObservable: Observable;
73
+ searchAutosuggestObservable: Observable;
74
+ private currentPage;
75
+ private renderingEngine;
76
+ setSearchTerm(value: string): void;
77
+ setRenderingEngine(value: "mustache" | "vue" | "react"): void;
78
+ setCurrentPage(value: number): void;
79
+ setLoading(value: boolean): void;
80
+ setSearchResults(value: ISearchstaxParsedResult[]): void;
81
+ setSearchResultsMetadata(value: ISearchstaxSearchMetadata): void;
82
+ setSearchAutosuggest(value: ISearchstaxSuggestResponse): void;
83
+ get searchResultsValue(): ISearchstaxParsedResult[] | null;
84
+ get searchTermValue(): string;
85
+ get loadingValue(): boolean;
86
+ get searchAutosuggestValue(): ISearchstaxSuggestResponse | null;
87
+ get searchResultsMetadataValue(): ISearchstaxSearchMetadata | null;
88
+ get currentPageValue(): number;
89
+ get renderingEngineValue(): "mustache" | "vue" | "react";
90
+ }
91
+ export interface ISearchstaxConfig {
92
+ language: string;
93
+ searchURL: string;
94
+ suggesterURL: string;
95
+ trackApiKey: string;
96
+ searchAuth: string;
97
+ authType: "token" | "basic";
98
+ }
99
+ export interface ISearchstaxSearchProps {
100
+ term: string;
101
+ queryParams: string[];
102
+ }
103
+ export interface ISearchstaxSuggestProps {
104
+ term: string;
105
+ queryParams: string[];
106
+ }
107
+ export interface ISearchstaxSearchInputConfig {
108
+ suggestAfterMinChars: number;
109
+ templates?: {
110
+ mainTemplate?: string;
111
+ searchInputId?: string;
112
+ autosuggestItemTemplate?: string;
113
+ };
114
+ hooks?: {
115
+ beforeSearch?: (props: ISearchstaxSearchProps) => ISearchstaxSearchProps | null;
116
+ afterSearch?: (results: ISearchstaxParsedResult[]) => ISearchstaxParsedResult[];
117
+ beforeAutosuggest?: (props: ISearchstaxSuggestProps) => ISearchstaxSuggestProps | null;
118
+ afterAutosuggest?: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse;
119
+ };
120
+ }
121
+ export interface ISearchstaxSearcResultsConfig {
122
+ searchResultsContainerId?: string;
123
+ searchResultUniqueIdAttribute?: string;
124
+ templates?: {
125
+ mainTemplate?: string;
126
+ searchResultTemplate?: string;
127
+ noSearchResultTemplate?: string;
128
+ };
129
+ hooks?: {
130
+ afterLinkClick?: (resultClicked: ISearchstaxParsedResult) => ISearchstaxParsedResult | null;
131
+ };
132
+ }
133
+ export declare class Searchstax {
134
+ private sessionId;
135
+ private searchstaxConfig?;
136
+ private searchHelper?;
137
+ private searchInputConfig?;
138
+ private searchResultsConfig?;
139
+ private searchInputWidget?;
140
+ private searchResultsWidget?;
141
+ dataLayer: DataLAyer;
142
+ constructor(renderEngine?: "mustache" | "vue" | "react");
143
+ setRenderingEngine(engine?: "mustache" | "vue" | "react"): void;
144
+ private handleHooks;
145
+ initialize(config: ISearchstaxConfig): void;
146
+ search(term: string, queryParams: string[]): void;
147
+ private parseSearchResultsResponse;
148
+ private parseSuggestSuggestResponse;
149
+ suggest(term: string, queryParams: string[]): void;
150
+ changeLanguage(language: string): void;
151
+ addSearchInputWidget(containerId: string, config: ISearchstaxSearchInputConfig): void;
152
+ addSearchResultsWidget(containerId: string, config: ISearchstaxSearcResultsConfig): void;
153
+ private executeSearch;
154
+ private executeSuggest;
155
+ executeLinkClick(uniqueId: string): void;
156
+ }
157
+
158
+ export {};
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.9",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "dev": "vite --host",
19
- "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && npm run sass && npm run makeDirectories && npm run compile:sass",
19
+ "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && npm run sass && npm run makeDirectories && npm run compile:sass && cp ./dist/@searchstax-inc/searchstudio-ux-js.d.ts ./dist/@searchstax-inc/searchstudio-ux-js.d.mts",
20
20
  "test": "vitest",
21
21
  "sass": "node-sass ./src/style.scss ./dist/styles/mainTheme.css",
22
22
  "test:coverage": "vitest --coverage",
@@ -43,6 +43,7 @@
43
43
  "eslint-plugin-prettier": "^4.2.1",
44
44
  "husky": "^8.0.3",
45
45
  "lint-staged": "^13.1.0",
46
+ "node-sass": "^8.0.0",
46
47
  "postcss": "^8.4.21",
47
48
  "postcss-scss": "^4.0.6",
48
49
  "prettier": "^2.8.3",
package/CHANGELOG.md DELETED
@@ -1,15 +0,0 @@
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