@bridgeline-digital/hawksearch-handlebars-ui 1.0.0-beta.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/.eslintignore +2 -0
- package/.eslintrc.json +153 -0
- package/.husky/pre-commit +5 -0
- package/.lintstagedrc.json +4 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +19 -0
- package/.vscode/launch.json +15 -0
- package/custom1.html +52 -0
- package/custom2.html +44 -0
- package/gulpfile.js +73 -0
- package/index.html +39 -0
- package/package.json +57 -0
- package/src/assets/icons/chevron-back.svg +4 -0
- package/src/assets/icons/chevron-down.svg +3 -0
- package/src/assets/icons/chevron-forward.svg +4 -0
- package/src/assets/icons/chevron-left.svg +3 -0
- package/src/assets/icons/chevron-right.svg +3 -0
- package/src/assets/icons/chevron-up.svg +3 -0
- package/src/assets/icons/cross.svg +3 -0
- package/src/assets/icons/help.svg +4 -0
- package/src/assets/icons/minus.svg +3 -0
- package/src/assets/icons/plus.svg +7 -0
- package/src/assets/images/icons.svg +1 -0
- package/src/assets/images/placeholder.png +0 -0
- package/src/components/autocomplete/autocomplete.component.hbs +60 -0
- package/src/components/autocomplete/autocomplete.component.ts +124 -0
- package/src/components/base.component.ts +120 -0
- package/src/components/facet-types/base-facet.component.ts +114 -0
- package/src/components/facet-types/checkbox-list-facet/checkbox-list-facet.component.hbs +6 -0
- package/src/components/facet-types/checkbox-list-facet/checkbox-list-facet.component.ts +73 -0
- package/src/components/facet-types/checkbox-list-facet/checkbox-list.partial.hbs +42 -0
- package/src/components/facet-types/color-facet/color-facet.component.hbs +29 -0
- package/src/components/facet-types/color-facet/color-facet.component.ts +26 -0
- package/src/components/facet-types/index.ts +6 -0
- package/src/components/facet-types/linked-list-facet/link-list-facet.component.hbs +17 -0
- package/src/components/facet-types/linked-list-facet/link-list-facet.component.ts +32 -0
- package/src/components/facet-types/range-slider-facet/range-slider-facet.component.hbs +11 -0
- package/src/components/facet-types/range-slider-facet/range-slider-facet.component.ts +107 -0
- package/src/components/facet-types/search-within-facet/search-within-facet.component.hbs +3 -0
- package/src/components/facet-types/search-within-facet/search-within-facet.component.ts +33 -0
- package/src/components/facet-types/size-facet/size-facet.component.hbs +29 -0
- package/src/components/facet-types/size-facet/size-facet.component.ts +30 -0
- package/src/components/facet-wrapper/facet-wrapper.component.hbs +36 -0
- package/src/components/facet-wrapper/facet-wrapper.component.ts +62 -0
- package/src/components/facets-list/facets-list.component.hbs +11 -0
- package/src/components/facets-list/facets-list.component.ts +92 -0
- package/src/components/icon/icon.component.hbs +3 -0
- package/src/components/icon/icon.component.ts +40 -0
- package/src/components/index.ts +18 -0
- package/src/components/modified-query/modified-query.component.hbs +7 -0
- package/src/components/modified-query/modified-query.component.ts +38 -0
- package/src/components/page-size/page-size.component.hbs +7 -0
- package/src/components/page-size/page-size.component.ts +35 -0
- package/src/components/pagination/pagination.component.hbs +34 -0
- package/src/components/pagination/pagination.component.ts +85 -0
- package/src/components/query-suggestions/query-suggestions.component.hbs +3 -0
- package/src/components/query-suggestions/query-suggestions.component.ts +66 -0
- package/src/components/range-slider/range-slider.component.hbs +9 -0
- package/src/components/range-slider/range-slider.component.ts +190 -0
- package/src/components/search/search.component.hbs +4 -0
- package/src/components/search/search.component.ts +93 -0
- package/src/components/search-results/search-results.component.hbs +29 -0
- package/src/components/search-results/search-results.component.ts +17 -0
- package/src/components/search-results-item/search-results-item.component.hbs +23 -0
- package/src/components/search-results-item/search-results-item.component.ts +99 -0
- package/src/components/search-results-list/search-results-list.component.hbs +15 -0
- package/src/components/search-results-list/search-results-list.component.ts +24 -0
- package/src/components/selected-facets/selected-facets.component.hbs +11 -0
- package/src/components/selected-facets/selected-facets.component.ts +81 -0
- package/src/components/sorting/sorting.component.hbs +7 -0
- package/src/components/sorting/sorting.component.ts +33 -0
- package/src/components/tabs/tabs.component.hbs +7 -0
- package/src/components/tabs/tabs.component.ts +35 -0
- package/src/components/tooltip/tooltip.component.hbs +6 -0
- package/src/components/tooltip/tooltip.component.ts +48 -0
- package/src/helpers/formatters.ts +15 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +125 -0
- package/src/models/autocomplete.models.ts +71 -0
- package/src/models/component.models.ts +27 -0
- package/src/models/global.models.ts +78 -0
- package/src/models/index.ts +7 -0
- package/src/models/raw-autocomplete.models.ts +46 -0
- package/src/models/raw-search.models.ts +130 -0
- package/src/models/search.models.ts +144 -0
- package/src/models/tracking.models.ts +33 -0
- package/src/scss/components/_autocomplete.scss +55 -0
- package/src/scss/components/_facets.scss +287 -0
- package/src/scss/components/_icons.scss +17 -0
- package/src/scss/components/_modified-query.scss +11 -0
- package/src/scss/components/_page-size.scss +2 -0
- package/src/scss/components/_pagination.scss +23 -0
- package/src/scss/components/_query-suggestions.scss +7 -0
- package/src/scss/components/_range-slider.scss +50 -0
- package/src/scss/components/_search-results-item.scss +64 -0
- package/src/scss/components/_search.scss +4 -0
- package/src/scss/components/_selected-facets.scss +24 -0
- package/src/scss/components/_sorting.scss +2 -0
- package/src/scss/components/_tabs.scss +51 -0
- package/src/scss/components/_tooltips.scss +29 -0
- package/src/scss/general/_forms.scss +82 -0
- package/src/scss/general/_grid-layout.scss +44 -0
- package/src/scss/general/_images.scss +3 -0
- package/src/scss/general/_typography.scss +15 -0
- package/src/scss/hawksearch.scss +35 -0
- package/src/scss/includes/_breakpoints.scss +51 -0
- package/src/scss/includes/_components.scss +14 -0
- package/src/scss/includes/_general.scss +4 -0
- package/src/scss/includes/_reset.scss +203 -0
- package/src/scss/includes/_utility-classes.scss +85 -0
- package/src/services/autocomplete.service.ts +104 -0
- package/src/services/base.service.ts +93 -0
- package/src/services/index.ts +3 -0
- package/src/services/search.service.ts +754 -0
- package/src/services/tracking.service.ts +136 -0
- package/tsconfig.json +22 -0
- package/typings.d.ts +21 -0
- package/webpack.config.js +75 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { formatCurrency } from '@helpers';
|
|
2
|
+
import { SelectedFacet } from '@models';
|
|
3
|
+
import { searchService } from '@services';
|
|
4
|
+
import { BaseComponent } from '../base.component';
|
|
5
|
+
import defaultHtml from './selected-facets.component.hbs';
|
|
6
|
+
|
|
7
|
+
export class SelectedFacetsComponent extends BaseComponent<Array<SelectedFacet>> {
|
|
8
|
+
protected bindEvent = 'hawksearch:bind-selected-facets';
|
|
9
|
+
protected customTemplatePropertyName = 'selectedFacets';
|
|
10
|
+
protected defaultHtml = defaultHtml;
|
|
11
|
+
|
|
12
|
+
protected getContentHtml(template: HandlebarsTemplateDelegate): string {
|
|
13
|
+
if (!this.data?.length) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const selections: Array<{
|
|
18
|
+
field: string;
|
|
19
|
+
title: string;
|
|
20
|
+
selectionTitle: string;
|
|
21
|
+
selectionValue: string;
|
|
22
|
+
excluded: boolean;
|
|
23
|
+
}> = [];
|
|
24
|
+
|
|
25
|
+
this.data.forEach((facet) => {
|
|
26
|
+
facet.values.forEach((value) => {
|
|
27
|
+
let selectionTitle = value.title;
|
|
28
|
+
|
|
29
|
+
const priceRange = /^(?<min>\d+(?:\.\d+)),(?<max>\d+(?:\.\d+))$/.exec(value.value);
|
|
30
|
+
|
|
31
|
+
if (priceRange) {
|
|
32
|
+
const min = parseFloat(priceRange.groups!.min);
|
|
33
|
+
const max = parseFloat(priceRange.groups!.max);
|
|
34
|
+
|
|
35
|
+
selectionTitle = `${formatCurrency(min, 0)}-${formatCurrency(max, 0)}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
selections.push({
|
|
39
|
+
field: facet.field,
|
|
40
|
+
title: facet.title,
|
|
41
|
+
selectionTitle: selectionTitle,
|
|
42
|
+
selectionValue: value.value,
|
|
43
|
+
excluded: value.excluded
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
selections.sort((x, y) => {
|
|
49
|
+
if (x.field == y.field) {
|
|
50
|
+
return x.selectionTitle.localeCompare(y.selectionTitle);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return x.title.localeCompare(y.title);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const html = template({
|
|
57
|
+
facets: this.data,
|
|
58
|
+
selections: selections
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return html;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected bindChildElements(): void {
|
|
65
|
+
this.shadowRoot?.querySelectorAll('[hawksearch-facet-field][hawksearch-facet-value]').forEach((e) => {
|
|
66
|
+
e.addEventListener('click', (event: Event) => {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
|
|
69
|
+
const element = event.currentTarget as HTMLElement;
|
|
70
|
+
const field = element.getAttribute('hawksearch-facet-field');
|
|
71
|
+
const value = element.getAttribute('hawksearch-facet-value');
|
|
72
|
+
|
|
73
|
+
if (!(field && value)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
searchService.removeFacetValue(field, value);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Sorting } from '@models';
|
|
2
|
+
import { searchService } from '@services';
|
|
3
|
+
import { BaseComponent } from '../base.component';
|
|
4
|
+
import defaultHtml from './sorting.component.hbs';
|
|
5
|
+
|
|
6
|
+
export class SortingComponent extends BaseComponent<Sorting> {
|
|
7
|
+
protected bindEvent = 'hawksearch:bind-sorting';
|
|
8
|
+
protected customTemplatePropertyName = 'sorting';
|
|
9
|
+
protected defaultHtml = defaultHtml;
|
|
10
|
+
|
|
11
|
+
protected getContentHtml(template: HandlebarsTemplateDelegate): string {
|
|
12
|
+
if (!this.data?.options?.length) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const html = template(this.data);
|
|
17
|
+
|
|
18
|
+
return html;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected bindChildElements(): void {
|
|
22
|
+
this.shadowRoot?.querySelectorAll('[hawksearch-sort]').forEach((e) => {
|
|
23
|
+
e.addEventListener('change', (event: Event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
|
|
26
|
+
const element = event.currentTarget as HTMLSelectElement;
|
|
27
|
+
const value = element.value;
|
|
28
|
+
|
|
29
|
+
searchService.sort(value);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Facet } from '@models';
|
|
2
|
+
import { searchService } from '@services';
|
|
3
|
+
import { BaseComponent } from '../base.component';
|
|
4
|
+
import defaultHtml from './tabs.component.hbs';
|
|
5
|
+
|
|
6
|
+
export class TabsComponent extends BaseComponent<Facet> {
|
|
7
|
+
protected bindEvent = 'hawksearch:bind-tabs';
|
|
8
|
+
protected customTemplatePropertyName = 'tabs';
|
|
9
|
+
protected defaultHtml = defaultHtml;
|
|
10
|
+
|
|
11
|
+
protected getContentHtml(template: HandlebarsTemplateDelegate): string {
|
|
12
|
+
if (!this.data?.values?.length) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const html = template({
|
|
17
|
+
values: this.data.values
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return html;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected bindChildElements(): void {
|
|
24
|
+
this.shadowRoot?.querySelectorAll('[hawksearch-tab-value]').forEach((e) => {
|
|
25
|
+
e.addEventListener('click', (event: Event) => {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
|
|
28
|
+
const element = event.currentTarget as HTMLElement;
|
|
29
|
+
const value = element.getAttribute('hawksearch-tab-value');
|
|
30
|
+
|
|
31
|
+
searchService.selectTab(value ?? undefined);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaseComponent } from '../base.component';
|
|
2
|
+
import defaultHtml from './tooltip.component.hbs';
|
|
3
|
+
|
|
4
|
+
export class TooltipComponent extends BaseComponent<string> {
|
|
5
|
+
protected bindEvent = undefined;
|
|
6
|
+
protected customTemplatePropertyName = 'tooltip';
|
|
7
|
+
protected defaultHtml = defaultHtml;
|
|
8
|
+
|
|
9
|
+
protected getContentHtml(template: HandlebarsTemplateDelegate): string {
|
|
10
|
+
const text = this.getAttribute('text') as string | null;
|
|
11
|
+
|
|
12
|
+
if (!text) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const html = template({
|
|
17
|
+
text: text
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return html;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected bindChildElements(): void {
|
|
24
|
+
this.shadowRoot?.querySelector('[hawksearch-tooltip]')?.addEventListener('mouseover', (event: Event) => {
|
|
25
|
+
const element = event.currentTarget as HTMLElement;
|
|
26
|
+
const contentElement = this.shadowRoot?.querySelector('[hawksearch-tooltip-content]') as HTMLElement;
|
|
27
|
+
|
|
28
|
+
if (!contentElement) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
contentElement.style.removeProperty('top');
|
|
33
|
+
contentElement.style.removeProperty('right');
|
|
34
|
+
|
|
35
|
+
const windowWidth = window.innerWidth;
|
|
36
|
+
const boundingRect = element.getBoundingClientRect();
|
|
37
|
+
const rightPosition = boundingRect.x + boundingRect.width;
|
|
38
|
+
const maxWidth = 350;
|
|
39
|
+
const margin = 20;
|
|
40
|
+
|
|
41
|
+
contentElement.style.top = `${boundingRect.top}px`;
|
|
42
|
+
|
|
43
|
+
if (windowWidth - rightPosition < maxWidth + margin) {
|
|
44
|
+
contentElement.style.right = `${margin}px`;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HawksearchGlobal } from '@models';
|
|
2
|
+
|
|
3
|
+
declare let Hawksearch: HawksearchGlobal;
|
|
4
|
+
|
|
5
|
+
export function formatCurrency(value: number, decimals = 2): string {
|
|
6
|
+
const cultureIsoCode = Hawksearch.config.formatting?.cultureIsoCode || 'en-US';
|
|
7
|
+
const currencyIsoCode = Hawksearch.config.formatting?.currencyIsoCode?.toUpperCase() || 'USD';
|
|
8
|
+
|
|
9
|
+
return value.toLocaleString(cultureIsoCode, {
|
|
10
|
+
style: 'currency',
|
|
11
|
+
currency: currencyIsoCode,
|
|
12
|
+
minimumFractionDigits: decimals,
|
|
13
|
+
maximumFractionDigits: decimals
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatters';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as Handlebars from 'handlebars/dist/handlebars';
|
|
3
|
+
import {
|
|
4
|
+
AutocompleteComponent,
|
|
5
|
+
CheckboxListFacetComponent,
|
|
6
|
+
ColorFacetComponent,
|
|
7
|
+
FacetWrapperComponent,
|
|
8
|
+
FacetsListComponent,
|
|
9
|
+
IconComponent,
|
|
10
|
+
LinkListFacetComponent,
|
|
11
|
+
ModifiedQueryComponent,
|
|
12
|
+
PageSizeComponent,
|
|
13
|
+
PaginationComponent,
|
|
14
|
+
QuerySuggestionsComponent,
|
|
15
|
+
RangeSliderComponent,
|
|
16
|
+
RangeSliderFacetComponent,
|
|
17
|
+
SearchComponent,
|
|
18
|
+
SearchResultsComponent,
|
|
19
|
+
SearchResultsItemComponent,
|
|
20
|
+
SearchResultsListComponent,
|
|
21
|
+
SearchWithinFacetComponent,
|
|
22
|
+
SelectedFacetsComponent,
|
|
23
|
+
SizeFacetComponent,
|
|
24
|
+
SortingComponent,
|
|
25
|
+
TabsComponent,
|
|
26
|
+
TooltipComponent
|
|
27
|
+
} from './components';
|
|
28
|
+
import { HawksearchGlobal, HawksearchState, PageType } from './models';
|
|
29
|
+
import { searchService, trackingService } from './services';
|
|
30
|
+
|
|
31
|
+
declare let Hawksearch: HawksearchGlobal;
|
|
32
|
+
|
|
33
|
+
if (!Hawksearch) {
|
|
34
|
+
Hawksearch = {} as HawksearchGlobal;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Hawksearch.service = searchService;
|
|
38
|
+
Hawksearch.handlebars = Handlebars.noConflict();
|
|
39
|
+
|
|
40
|
+
Hawksearch.handlebars.registerHelper('add', function (value1: number, value2: number): number {
|
|
41
|
+
return value1 + value2;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
Hawksearch.handlebars.registerHelper('attribute', function (attribute: string, condition: any): string {
|
|
45
|
+
return condition ? attribute : '';
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
Hawksearch.handlebars.registerHelper('eq', function (value1: any, value2: any): boolean {
|
|
49
|
+
return value1 === value2;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
Hawksearch.handlebars.registerHelper('exclude', function (options): any {
|
|
53
|
+
return options.fn();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
Hawksearch.handlebars.registerHelper('html', function (html: string): Handlebars.SafeString {
|
|
57
|
+
return new Hawksearch.handlebars.SafeString(html);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
Hawksearch.handlebars.registerHelper('if-else', function (condition: any, trueValue: any, falseValue: any): any {
|
|
61
|
+
return condition ? trueValue : falseValue;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
Hawksearch.handlebars.registerHelper('lt', function (value1: any, value2: any): boolean {
|
|
65
|
+
return value1 < value2;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
Hawksearch.handlebars.registerHelper('lte', function (value1: any, value2: any): boolean {
|
|
69
|
+
return value1 <= value2;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
Hawksearch.handlebars.registerHelper('gt', function (value1: any, value2: any): boolean {
|
|
73
|
+
return value1 > value2;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
Hawksearch.handlebars.registerHelper('gte', function (value1: any, value2: any): boolean {
|
|
77
|
+
return value1 >= value2;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
Hawksearch.handlebars.registerHelper('or', function (...values: Array<any>): boolean {
|
|
81
|
+
return values.slice(0, -1).some((v) => !!v); // Omit last argument as that is Handlebars options which would always resolve to true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
Hawksearch.handlebars.registerHelper('subtract', function (value1: number, value2: number): number {
|
|
85
|
+
return value1 - value2;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
customElements.define('hawksearch-autocomplete', AutocompleteComponent);
|
|
89
|
+
customElements.define('hawksearch-checkbox-list-facet', CheckboxListFacetComponent);
|
|
90
|
+
customElements.define('hawksearch-color-facet', ColorFacetComponent);
|
|
91
|
+
customElements.define('hawksearch-facet-wrapper', FacetWrapperComponent);
|
|
92
|
+
customElements.define('hawksearch-facets-list', FacetsListComponent);
|
|
93
|
+
customElements.define('hawksearch-icon', IconComponent);
|
|
94
|
+
customElements.define('hawksearch-link-list-facet', LinkListFacetComponent);
|
|
95
|
+
customElements.define('hawksearch-modified-query', ModifiedQueryComponent);
|
|
96
|
+
customElements.define('hawksearch-page-size', PageSizeComponent);
|
|
97
|
+
customElements.define('hawksearch-pagination', PaginationComponent);
|
|
98
|
+
customElements.define('hawksearch-query-suggestions', QuerySuggestionsComponent);
|
|
99
|
+
customElements.define('hawksearch-results', SearchResultsComponent);
|
|
100
|
+
customElements.define('hawksearch-range-slider', RangeSliderComponent);
|
|
101
|
+
customElements.define('hawksearch-range-slider-facet', RangeSliderFacetComponent);
|
|
102
|
+
customElements.define('hawksearch-results-list', SearchResultsListComponent);
|
|
103
|
+
customElements.define('hawksearch-results-item', SearchResultsItemComponent);
|
|
104
|
+
customElements.define('hawksearch-search', SearchComponent);
|
|
105
|
+
customElements.define('hawksearch-search-within-facet', SearchWithinFacetComponent);
|
|
106
|
+
customElements.define('hawksearch-selected-facets', SelectedFacetsComponent);
|
|
107
|
+
customElements.define('hawksearch-size-facet', SizeFacetComponent);
|
|
108
|
+
customElements.define('hawksearch-sorting', SortingComponent);
|
|
109
|
+
customElements.define('hawksearch-tabs', TabsComponent);
|
|
110
|
+
customElements.define('hawksearch-tooltip', TooltipComponent);
|
|
111
|
+
|
|
112
|
+
addEventListener('popstate', (event) => {
|
|
113
|
+
const state: HawksearchState = event.state;
|
|
114
|
+
|
|
115
|
+
Hawksearch.searchRequest = state.searchRequest;
|
|
116
|
+
Hawksearch.searchResponse = state.searchResponse;
|
|
117
|
+
|
|
118
|
+
searchService.bindComponents(state.searchResponse);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
trackingService.trackPageLoad(PageType.Custom);
|
|
122
|
+
|
|
123
|
+
const searchRequest = searchService.getRequestFromUrl();
|
|
124
|
+
|
|
125
|
+
searchService.search(searchRequest);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface AutocompleteRequest {
|
|
2
|
+
query: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface AutocompleteCategory {
|
|
6
|
+
title: string;
|
|
7
|
+
field: string;
|
|
8
|
+
value: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AutocompleteCategories {
|
|
13
|
+
title: string;
|
|
14
|
+
results: Array<AutocompleteCategory>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AutocompleteContentResult {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
url: string;
|
|
21
|
+
pinned: boolean;
|
|
22
|
+
score: number;
|
|
23
|
+
attributes?: {
|
|
24
|
+
[key: string]: Array<string>;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AutocompleteContent {
|
|
29
|
+
title: string;
|
|
30
|
+
results: Array<AutocompleteContentResult>;
|
|
31
|
+
totalRecords: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AutocompleteQuery {
|
|
35
|
+
query: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AutocompleteQueries {
|
|
40
|
+
title: string;
|
|
41
|
+
results: Array<AutocompleteQuery>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AutocompleteProductResult {
|
|
45
|
+
id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
sku?: string;
|
|
48
|
+
imageUrl?: string;
|
|
49
|
+
url: string;
|
|
50
|
+
pinned: boolean;
|
|
51
|
+
score: number;
|
|
52
|
+
attributes?: {
|
|
53
|
+
[key: string]: Array<string>;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface AutocompleteProducts {
|
|
58
|
+
title: string;
|
|
59
|
+
results: Array<AutocompleteProductResult>;
|
|
60
|
+
totalRecords: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface AutocompleteResponse {
|
|
64
|
+
query: string;
|
|
65
|
+
categories: AutocompleteCategories;
|
|
66
|
+
content: AutocompleteContent;
|
|
67
|
+
products: AutocompleteProducts;
|
|
68
|
+
queries: AutocompleteQueries;
|
|
69
|
+
totalRecords: number;
|
|
70
|
+
viewAllText: string;
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type IconName =
|
|
2
|
+
| 'chevron-back'
|
|
3
|
+
| 'chevron-down'
|
|
4
|
+
| 'chevron-forward'
|
|
5
|
+
| 'chevron-left'
|
|
6
|
+
| 'chevron-right'
|
|
7
|
+
| 'chevron-up'
|
|
8
|
+
| 'cross'
|
|
9
|
+
| 'help'
|
|
10
|
+
| 'minus'
|
|
11
|
+
| 'plus';
|
|
12
|
+
|
|
13
|
+
export interface ModifiedQueryData {
|
|
14
|
+
display: boolean;
|
|
15
|
+
query?: string;
|
|
16
|
+
modifiedQuery?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface QuerySuggestionsData {
|
|
20
|
+
display: boolean;
|
|
21
|
+
querySuggestions?: Array<string>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RangeSliderEventData {
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as Handlebars from 'handlebars';
|
|
2
|
+
import { SearchService } from '../services';
|
|
3
|
+
import { SearchRequest, SearchResponse } from './search.models';
|
|
4
|
+
|
|
5
|
+
export interface HawksearchConfig {
|
|
6
|
+
clientId: string;
|
|
7
|
+
customCssUrl?: string;
|
|
8
|
+
defaultStyles?: boolean;
|
|
9
|
+
endpoints?: {
|
|
10
|
+
search: string;
|
|
11
|
+
tracking: string;
|
|
12
|
+
};
|
|
13
|
+
fieldMappings?: {
|
|
14
|
+
imageUrl?: string;
|
|
15
|
+
price?: string;
|
|
16
|
+
salePrice?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
};
|
|
21
|
+
formatting?: {
|
|
22
|
+
cultureIsoCode?: string;
|
|
23
|
+
currencyIsoCode?: string;
|
|
24
|
+
};
|
|
25
|
+
placeholderImageUrl?: string;
|
|
26
|
+
queryStringMappings?: {
|
|
27
|
+
disableSpellcheck?: string;
|
|
28
|
+
facet?: string;
|
|
29
|
+
page?: string;
|
|
30
|
+
pageSize?: string;
|
|
31
|
+
query?: string;
|
|
32
|
+
searchWithin?: string;
|
|
33
|
+
sort?: string;
|
|
34
|
+
};
|
|
35
|
+
trackingEnabled?: boolean;
|
|
36
|
+
urlPrefixes?: {
|
|
37
|
+
assets?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface HawksearchTemplates {
|
|
43
|
+
checkboxListFacet?: string;
|
|
44
|
+
colorFacet?: string;
|
|
45
|
+
facetsList?: string;
|
|
46
|
+
facetWrapper?: string;
|
|
47
|
+
icon?: string;
|
|
48
|
+
linkListFacet?: string;
|
|
49
|
+
modifiedQuery?: string;
|
|
50
|
+
pageSize?: string;
|
|
51
|
+
pagination?: string;
|
|
52
|
+
querySuggestions?: string;
|
|
53
|
+
rangeSlider?: string;
|
|
54
|
+
rangeSliderFacet?: string;
|
|
55
|
+
search?: string;
|
|
56
|
+
searchResults?: string;
|
|
57
|
+
searchResultsItem?: string;
|
|
58
|
+
searchResultsList?: string;
|
|
59
|
+
searchWithinFacet?: string;
|
|
60
|
+
selectedFacets?: string;
|
|
61
|
+
sorting?: string;
|
|
62
|
+
tabs?: string;
|
|
63
|
+
tooltip?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface HawksearchGlobal {
|
|
67
|
+
config: HawksearchConfig;
|
|
68
|
+
handlebars: typeof Handlebars;
|
|
69
|
+
searchRequest?: SearchRequest;
|
|
70
|
+
searchResponse?: SearchResponse;
|
|
71
|
+
service?: SearchService;
|
|
72
|
+
templates?: HawksearchTemplates;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface HawksearchState {
|
|
76
|
+
searchRequest?: SearchRequest;
|
|
77
|
+
searchResponse: SearchResponse;
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RawSearchResultsItem } from './raw-search.models';
|
|
2
|
+
|
|
3
|
+
export interface RawAutocompleteRequest {
|
|
4
|
+
ClientGuid: string;
|
|
5
|
+
Keyword: string;
|
|
6
|
+
DisplayFullResponse?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RawAutocompleteCategory {
|
|
10
|
+
Url: string;
|
|
11
|
+
Value: string;
|
|
12
|
+
FieldQSName: string;
|
|
13
|
+
FieldQSValue: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface RawAutocompleteContent {
|
|
17
|
+
Value: string;
|
|
18
|
+
Url: string;
|
|
19
|
+
Results: RawSearchResultsItem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RawAutocompleteProduct {
|
|
23
|
+
ProductName: string;
|
|
24
|
+
Sku: string;
|
|
25
|
+
Thumb?: {
|
|
26
|
+
AltText: string;
|
|
27
|
+
Url: string;
|
|
28
|
+
};
|
|
29
|
+
Url: string;
|
|
30
|
+
Results: RawSearchResultsItem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RawAutocompleteResponse {
|
|
34
|
+
Categories: Array<RawAutocompleteCategory>;
|
|
35
|
+
CategoryHeading: string;
|
|
36
|
+
Content: Array<RawAutocompleteContent>;
|
|
37
|
+
ContentCount: number;
|
|
38
|
+
ContentHeading: string;
|
|
39
|
+
Count: number;
|
|
40
|
+
Popular: Array<string>;
|
|
41
|
+
PopularHeading: string;
|
|
42
|
+
ProductHeading: string;
|
|
43
|
+
ProductCount: number;
|
|
44
|
+
Products: Array<RawAutocompleteProduct>;
|
|
45
|
+
ViewAllButtonLabel: string;
|
|
46
|
+
}
|