@searchcraft/javascript-sdk 0.7.0 → 0.7.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 +7 -1
- package/dist/cjs/{index-d4b4a45e.js → index-a81df4f0.js} +29 -113
- package/dist/{components/p-6cafd48d.js.map → cjs/index-a81df4f0.js.map} +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js +91 -44
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +74 -50
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-button_3.cjs.entry.js +37 -36
- package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +141 -119
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +11 -14
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +127 -92
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +2 -2
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js +3 -7
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js +81 -75
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js +29 -6
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-results-info.cjs.entry.js +9 -13
- package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-theme.cjs.entry.js +38 -0
- package/dist/cjs/searchcraft-theme.cjs.entry.js.map +1 -0
- package/dist/cjs/{store-abe47006.js → store-f6ba3dfb.js} +26 -10
- package/dist/cjs/{store-abe47006.js.map → store-f6ba3dfb.js.map} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +102 -62
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +77 -61
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
- package/dist/collection/components/searchcraft-button/searchcraft-button.js +26 -30
- package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +1 -1
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +6 -12
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +1 -1
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +59 -51
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +1 -1
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +9 -20
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +1 -1
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +109 -87
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +1 -1
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +10 -20
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +1 -11
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +81 -82
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +35 -17
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +17 -19
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js.map +1 -1
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +7 -19
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -1
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +57 -65
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -1
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +27 -0
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +1 -0
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +23 -26
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/provider/store.js +25 -9
- package/dist/collection/provider/store.js.map +1 -1
- package/dist/collection/utils/facets.js +5 -3
- package/dist/collection/utils/facets.js.map +1 -1
- package/dist/components/index.js +4 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-0ef4ab33.js +66 -0
- package/dist/components/p-0ef4ab33.js.map +1 -0
- package/dist/components/p-1234974c.js +72 -0
- package/dist/components/p-1234974c.js.map +1 -0
- package/dist/components/p-4b92ae26.js +109 -0
- package/dist/components/p-4b92ae26.js.map +1 -0
- package/dist/components/{p-e1cf5f9d.js → p-506cdac1.js} +18 -14
- package/dist/components/p-506cdac1.js.map +1 -0
- package/dist/components/p-521fe971.js +60 -0
- package/dist/components/p-521fe971.js.map +1 -0
- package/dist/components/{p-6cafd48d.js → p-5365011f.js} +30 -123
- package/dist/components/p-5365011f.js.map +1 -0
- package/dist/components/p-54998882.js +285 -0
- package/dist/components/p-54998882.js.map +1 -0
- package/dist/{esm/store-712f0586.js → components/p-936e2ed4.js} +26 -10
- package/dist/components/{p-01dc5b3b.js.map → p-936e2ed4.js.map} +1 -1
- package/dist/components/p-a75ef832.js +34 -0
- package/dist/components/p-a75ef832.js.map +1 -0
- package/dist/components/p-b4a8fcbe.js +144 -0
- package/dist/components/p-b4a8fcbe.js.map +1 -0
- package/dist/components/p-ca881e5c.js +37 -0
- package/dist/components/p-ca881e5c.js.map +1 -0
- package/dist/components/p-d95bc2a0.js +284 -0
- package/dist/components/p-d95bc2a0.js.map +1 -0
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +76 -52
- package/dist/components/searchcraft-base-search-results.js.map +1 -1
- package/dist/components/searchcraft-button.js +1 -1
- package/dist/components/searchcraft-error-message.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +14 -17
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-input-label.js +1 -1
- package/dist/components/searchcraft-popover-button.js +3 -7
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-form.js +87 -81
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +9 -13
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.d.ts +11 -0
- package/dist/components/searchcraft-theme.js +51 -0
- package/dist/components/searchcraft-theme.js.map +1 -0
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/esm/{index-56b713de.js → index-3608c57d.js} +29 -113
- package/dist/esm/index-3608c57d.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/searchcraft-base-search-result.entry.js +91 -44
- package/dist/esm/searchcraft-base-search-result.entry.js.map +1 -1
- package/dist/esm/searchcraft-base-search-results.entry.js +74 -50
- package/dist/esm/searchcraft-base-search-results.entry.js.map +1 -1
- package/dist/esm/searchcraft-button_3.entry.js +37 -36
- package/dist/esm/searchcraft-button_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-facet-list_3.entry.js +141 -119
- package/dist/esm/searchcraft-facet-list_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-filter-panel.entry.js +11 -14
- package/dist/esm/searchcraft-filter-panel.entry.js.map +1 -1
- package/dist/esm/searchcraft-input-form_2.entry.js +127 -92
- package/dist/esm/searchcraft-input-form_2.entry.js.map +1 -1
- package/dist/esm/searchcraft-javascript-sdk.js +3 -3
- package/dist/esm/searchcraft-popover-button.entry.js +3 -7
- package/dist/esm/searchcraft-popover-button.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-form.entry.js +81 -75
- package/dist/esm/searchcraft-popover-form.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-list-item.entry.js +29 -6
- package/dist/esm/searchcraft-popover-list-item.entry.js.map +1 -1
- package/dist/esm/searchcraft-results-info.entry.js +9 -13
- package/dist/esm/searchcraft-results-info.entry.js.map +1 -1
- package/dist/esm/searchcraft-theme.entry.js +34 -0
- package/dist/esm/searchcraft-theme.entry.js.map +1 -0
- package/dist/{components/p-01dc5b3b.js → esm/store-aa071d9c.js} +26 -10
- package/dist/esm/{store-712f0586.js.map → store-aa071d9c.js.map} +1 -1
- package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js +3 -0
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/{p-01dc5b3b.js → p-936e2ed4.js} +2 -2
- package/dist/searchcraft-javascript-sdk/{p-01dc5b3b.js.map → p-936e2ed4.js.map} +1 -1
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
- package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +1 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +2 -1
- package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +1 -0
- package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +1 -0
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +2 -1
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +1 -0
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +7 -10
- package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +2 -1
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +1 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +2 -1
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +2 -0
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +1 -0
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +1 -0
- package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +2 -1
- package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +5 -0
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +2 -1
- package/dist/types/components.d.ts +17 -4
- package/dist/types/index.d.ts +2 -1
- package/dist/types/provider/store.d.ts +1 -0
- package/dist/types/types/_shared.types.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/raw.d.ts +4 -0
- package/dist/types/types/searchcraft-base-search-results.types.d.ts +1 -0
- package/dist/types/types/searchcraft-filter-panel.types.d.ts +1 -0
- package/dist/types/types/searchcraft-popover-form.types.d.ts +1 -0
- package/dist/types/utils/facets.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/styles.d.ts +1 -0
- package/dist/types/utils/units.d.ts +1 -0
- package/package.json +5 -4
- package/dist/cjs/index-d4b4a45e.js.map +0 -1
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +0 -227
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.module.css +0 -179
- package/dist/collection/components/searchcraft-button/searchcraft-button.module.css +0 -174
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.module.css +0 -158
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.module.css +0 -266
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.module.css +0 -168
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.module.css +0 -293
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.module.css +0 -159
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.module.css +0 -0
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.module.css +0 -322
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.module.css +0 -209
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.module.css +0 -0
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.module.css +0 -169
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +0 -231
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +0 -207
- package/dist/components/p-1ae87308.js +0 -43
- package/dist/components/p-1ae87308.js.map +0 -1
- package/dist/components/p-649654b5.js +0 -268
- package/dist/components/p-649654b5.js.map +0 -1
- package/dist/components/p-662cb490.js +0 -67
- package/dist/components/p-662cb490.js.map +0 -1
- package/dist/components/p-87d1611b.js +0 -97
- package/dist/components/p-87d1611b.js.map +0 -1
- package/dist/components/p-c273e43d.js +0 -40
- package/dist/components/p-c273e43d.js.map +0 -1
- package/dist/components/p-cc9f8c61.js +0 -109
- package/dist/components/p-cc9f8c61.js.map +0 -1
- package/dist/components/p-cf096782.js +0 -56
- package/dist/components/p-cf096782.js.map +0 -1
- package/dist/components/p-da5b92ef.js +0 -253
- package/dist/components/p-da5b92ef.js.map +0 -1
- package/dist/components/p-e1cf5f9d.js.map +0 -1
- package/dist/components/p-f5a06210.js +0 -34
- package/dist/components/p-f5a06210.js.map +0 -1
- package/dist/esm/index-56b713de.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-117fcdd3.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-117fcdd3.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-129e6f2c.js +0 -3
- package/dist/searchcraft-javascript-sdk/p-129e6f2c.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-27cb401c.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-27cb401c.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-4df4a29e.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-4df4a29e.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-54248dd8.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-54248dd8.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-69430dbf.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-69430dbf.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-a460755d.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-a460755d.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-bc2c4259.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-bc2c4259.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-caecdcda.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-caecdcda.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-f8129731.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-f8129731.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-f839b682.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-f839b682.entry.js.map +0 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"components/searchcraft-popover-list-view/searchcraft-popover-list-view.js",
|
|
15
15
|
"components/searchcraft-results-info/searchcraft-results-info.js",
|
|
16
16
|
"components/searchcraft-slider/searchcraft-slider.js",
|
|
17
|
+
"components/searchcraft-theme/searchcraft-theme.js",
|
|
17
18
|
"components/searchcraft-toggle-button/searchcraft-toggle-button.js"
|
|
18
19
|
],
|
|
19
20
|
"compiler": {
|
package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js
CHANGED
|
@@ -6,47 +6,96 @@ import { Fragment, h } from "@stencil/core";
|
|
|
6
6
|
* It is consumed within the `searchcraft-base-search-results` component.
|
|
7
7
|
*/
|
|
8
8
|
export class SearchcraftBaseSearchResult {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The title content.
|
|
11
|
+
*/
|
|
12
|
+
titleContent;
|
|
13
|
+
/**
|
|
14
|
+
* The subtitle content.
|
|
15
|
+
*/
|
|
16
|
+
subtitleContent;
|
|
17
|
+
/**
|
|
18
|
+
* The body content.
|
|
19
|
+
*/
|
|
20
|
+
bodyContent;
|
|
21
|
+
/**
|
|
22
|
+
* The footer content.
|
|
23
|
+
*/
|
|
24
|
+
footerContent;
|
|
25
|
+
/**
|
|
26
|
+
* The label for the button rendered when containerHref is not present.
|
|
27
|
+
*/
|
|
28
|
+
buttonLabel;
|
|
29
|
+
/**
|
|
30
|
+
* The link for the button rendered when containerHref is not present.
|
|
31
|
+
*/
|
|
32
|
+
buttonHref;
|
|
33
|
+
/**
|
|
34
|
+
* Where to open the link for the button rendered when containerHref is not present.
|
|
35
|
+
*/
|
|
36
|
+
buttonTarget = '_blank';
|
|
37
|
+
/**
|
|
38
|
+
* The relationship between the current document and the link for the button rendered when containerHref is not present.
|
|
39
|
+
*/
|
|
40
|
+
buttonRel;
|
|
41
|
+
/**
|
|
42
|
+
* The link for the containing element.
|
|
43
|
+
*/
|
|
44
|
+
containerHref;
|
|
45
|
+
/**
|
|
46
|
+
* Where to open the link for the containing element.
|
|
47
|
+
*/
|
|
48
|
+
containerTarget = '_blank';
|
|
49
|
+
/**
|
|
50
|
+
* The relationship between the current document and the link for the containing element.
|
|
51
|
+
*/
|
|
52
|
+
containerRel;
|
|
53
|
+
/**
|
|
54
|
+
* The image source.
|
|
55
|
+
*/
|
|
56
|
+
imageSrc;
|
|
57
|
+
/**
|
|
58
|
+
* The image alternative text.
|
|
59
|
+
*/
|
|
60
|
+
imageAlt;
|
|
61
|
+
/**
|
|
62
|
+
* The placement of the image.
|
|
63
|
+
*/
|
|
64
|
+
imagePlacement = 'right';
|
|
65
|
+
/**
|
|
66
|
+
* A custom styles object.
|
|
67
|
+
*/
|
|
68
|
+
customStyles;
|
|
69
|
+
/**
|
|
70
|
+
* The position in the document. Used with the "document_clicked" measure event.
|
|
71
|
+
*/
|
|
72
|
+
documentPosition = 0;
|
|
73
|
+
searchcraftStore = useSearchcraftStore.getState();
|
|
74
|
+
recordMeasureEvent = () => {
|
|
75
|
+
const searchcraft = this.searchcraftStore.getSearchcraftInstance();
|
|
76
|
+
if (searchcraft) {
|
|
77
|
+
const document_position = this.documentPosition;
|
|
78
|
+
const search_term = this.searchcraftStore.query;
|
|
79
|
+
const number_of_documents = this.searchcraftStore.searchResults?.data?.hits?.length || 0;
|
|
80
|
+
searchcraft.sendMeasureEvent('document_clicked', {
|
|
81
|
+
document_position,
|
|
82
|
+
number_of_documents,
|
|
83
|
+
search_term,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
parseStyles = () => {
|
|
88
|
+
if (this.customStyles) {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(this.customStyles);
|
|
35
91
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
return JSON.parse(this.customStyles);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error('Error parsing custom styles:', error);
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
console.error('Error parsing custom styles:', error);
|
|
94
|
+
return {};
|
|
46
95
|
}
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
}
|
|
96
|
+
}
|
|
97
|
+
return {};
|
|
98
|
+
};
|
|
50
99
|
render() {
|
|
51
100
|
const styles = this.parseStyles();
|
|
52
101
|
const imageContainer = this.imageSrc && (h("img", { alt: this.imageAlt, class: 'searchcraft-search-result-image', src: this.imageSrc, style: styles.image || {} }));
|
|
@@ -59,16 +108,6 @@ export class SearchcraftBaseSearchResult {
|
|
|
59
108
|
return (h("div", { class: 'searchcraft-search-result-container', style: styles.container || {} }, contentContainer));
|
|
60
109
|
}
|
|
61
110
|
static get is() { return "searchcraft-base-search-result"; }
|
|
62
|
-
static get originalStyleUrls() {
|
|
63
|
-
return {
|
|
64
|
-
"$": ["searchcraft-base-search-result.module.scss"]
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
static get styleUrls() {
|
|
68
|
-
return {
|
|
69
|
-
"$": ["searchcraft-base-search-result.module.css"]
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
111
|
static get properties() {
|
|
73
112
|
return {
|
|
74
113
|
"titleContent": {
|
|
@@ -76,7 +115,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
76
115
|
"mutable": false,
|
|
77
116
|
"complexType": {
|
|
78
117
|
"original": "string | undefined",
|
|
79
|
-
"resolved": "string",
|
|
118
|
+
"resolved": "string | undefined",
|
|
80
119
|
"references": {}
|
|
81
120
|
},
|
|
82
121
|
"required": false,
|
|
@@ -95,7 +134,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
95
134
|
"mutable": false,
|
|
96
135
|
"complexType": {
|
|
97
136
|
"original": "string | undefined",
|
|
98
|
-
"resolved": "string",
|
|
137
|
+
"resolved": "string | undefined",
|
|
99
138
|
"references": {}
|
|
100
139
|
},
|
|
101
140
|
"required": false,
|
|
@@ -114,7 +153,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
114
153
|
"mutable": false,
|
|
115
154
|
"complexType": {
|
|
116
155
|
"original": "string | undefined",
|
|
117
|
-
"resolved": "string",
|
|
156
|
+
"resolved": "string | undefined",
|
|
118
157
|
"references": {}
|
|
119
158
|
},
|
|
120
159
|
"required": false,
|
|
@@ -133,7 +172,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
133
172
|
"mutable": false,
|
|
134
173
|
"complexType": {
|
|
135
174
|
"original": "string | undefined",
|
|
136
|
-
"resolved": "string",
|
|
175
|
+
"resolved": "string | undefined",
|
|
137
176
|
"references": {}
|
|
138
177
|
},
|
|
139
178
|
"required": false,
|
|
@@ -152,7 +191,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
152
191
|
"mutable": false,
|
|
153
192
|
"complexType": {
|
|
154
193
|
"original": "string | undefined",
|
|
155
|
-
"resolved": "string",
|
|
194
|
+
"resolved": "string | undefined",
|
|
156
195
|
"references": {}
|
|
157
196
|
},
|
|
158
197
|
"required": false,
|
|
@@ -171,7 +210,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
171
210
|
"mutable": false,
|
|
172
211
|
"complexType": {
|
|
173
212
|
"original": "string | undefined",
|
|
174
|
-
"resolved": "string",
|
|
213
|
+
"resolved": "string | undefined",
|
|
175
214
|
"references": {}
|
|
176
215
|
},
|
|
177
216
|
"required": false,
|
|
@@ -210,7 +249,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
210
249
|
"mutable": false,
|
|
211
250
|
"complexType": {
|
|
212
251
|
"original": "'noreferrer' | 'noopener' | 'nofollow' | undefined",
|
|
213
|
-
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\"",
|
|
252
|
+
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\" | undefined",
|
|
214
253
|
"references": {}
|
|
215
254
|
},
|
|
216
255
|
"required": false,
|
|
@@ -229,7 +268,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
229
268
|
"mutable": false,
|
|
230
269
|
"complexType": {
|
|
231
270
|
"original": "string | undefined",
|
|
232
|
-
"resolved": "string",
|
|
271
|
+
"resolved": "string | undefined",
|
|
233
272
|
"references": {}
|
|
234
273
|
},
|
|
235
274
|
"required": false,
|
|
@@ -268,7 +307,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
268
307
|
"mutable": false,
|
|
269
308
|
"complexType": {
|
|
270
309
|
"original": "'noreferrer' | 'noopener' | 'nofollow' | undefined",
|
|
271
|
-
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\"",
|
|
310
|
+
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\" | undefined",
|
|
272
311
|
"references": {}
|
|
273
312
|
},
|
|
274
313
|
"required": false,
|
|
@@ -287,7 +326,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
287
326
|
"mutable": false,
|
|
288
327
|
"complexType": {
|
|
289
328
|
"original": "string | undefined",
|
|
290
|
-
"resolved": "string",
|
|
329
|
+
"resolved": "string | undefined",
|
|
291
330
|
"references": {}
|
|
292
331
|
},
|
|
293
332
|
"required": false,
|
|
@@ -306,7 +345,7 @@ export class SearchcraftBaseSearchResult {
|
|
|
306
345
|
"mutable": false,
|
|
307
346
|
"complexType": {
|
|
308
347
|
"original": "string | undefined",
|
|
309
|
-
"resolved": "string",
|
|
348
|
+
"resolved": "string | undefined",
|
|
310
349
|
"references": {}
|
|
311
350
|
},
|
|
312
351
|
"required": false,
|
|
@@ -337,14 +376,15 @@ export class SearchcraftBaseSearchResult {
|
|
|
337
376
|
"getter": false,
|
|
338
377
|
"setter": false,
|
|
339
378
|
"attribute": "image-placement",
|
|
340
|
-
"reflect": false
|
|
379
|
+
"reflect": false,
|
|
380
|
+
"defaultValue": "'right'"
|
|
341
381
|
},
|
|
342
382
|
"customStyles": {
|
|
343
383
|
"type": "string",
|
|
344
384
|
"mutable": false,
|
|
345
385
|
"complexType": {
|
|
346
386
|
"original": "string | undefined",
|
|
347
|
-
"resolved": "string",
|
|
387
|
+
"resolved": "string | undefined",
|
|
348
388
|
"references": {}
|
|
349
389
|
},
|
|
350
390
|
"required": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-base-search-result.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-base-search-result/searchcraft-base-search-result.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"searchcraft-base-search-result.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-base-search-result/searchcraft-base-search-result.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;GAIG;AAKH,MAAM,OAAO,2BAA2B;IACtC;;OAEG;IACK,YAAY,CAAqB;IACzC;;OAEG;IACK,eAAe,CAAqB;IAC5C;;OAEG;IACK,WAAW,CAAqB;IACxC;;OAEG;IACK,aAAa,CAAqB;IAC1C;;OAEG;IACK,WAAW,CAAqB;IACxC;;OAEG;IACK,UAAU,CAAqB;IACvC;;OAEG;IACK,YAAY,GAA4C,QAAQ,CAAC;IACzE;;OAEG;IACK,SAAS,CAAqD;IACtE;;OAEG;IACK,aAAa,CAAqB;IAC1C;;OAEG;IACK,eAAe,GAA4C,QAAQ,CAAC;IAC5E;;OAEG;IACK,YAAY,CAAqD;IACzE;;OAEG;IACK,QAAQ,CAAqB;IACrC;;OAEG;IACK,QAAQ,CAAqB;IACrC;;OAEG;IACK,cAAc,GAAqB,OAAO,CAAC;IACnD;;OAEG;IACK,YAAY,CAAqB;IACzC;;OAEG;IACK,gBAAgB,GAAG,CAAC,CAAC;IAErB,gBAAgB,GAAG,mBAAm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AE,IAAI,CAAC,aAAa,EACxB,GAAG,EAAE,IAAI,CAAC,YAAY,EACtB,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,EAC7B,QAAQ,EAAC,GAAG,EACZ,MAAM,EAAE,IAAI,CAAC,eAAe,IAE3B,gBAAgB,CACf,CACL,CAAC;QACJ,CAAC;QAED,uCAAuC;QACvC,OAAO,CACL,WACE,KAAK,EAAC,qCAAqC,EAC3C,KAAK,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,IAE5B,gBAAgB,CACb,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport { Component, Fragment, h, Prop } from '@stencil/core';\n\n/**\n * This web component is designed to display detailed information for a single search result.\n * Once a query is submitted, the component formats and presents the result.\n * It is consumed within the `searchcraft-base-search-results` component.\n */\n@Component({\n tag: 'searchcraft-base-search-result',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResult {\n /**\n * The title content.\n */\n @Prop() titleContent: string | undefined;\n /**\n * The subtitle content.\n */\n @Prop() subtitleContent: string | undefined;\n /**\n * The body content.\n */\n @Prop() bodyContent: string | undefined;\n /**\n * The footer content.\n */\n @Prop() footerContent: string | undefined;\n /**\n * The label for the button rendered when containerHref is not present.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The link for the button rendered when containerHref is not present.\n */\n @Prop() buttonHref: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * The link for the containing element.\n */\n @Prop() containerHref: string | undefined;\n /**\n * Where to open the link for the containing element.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * The image source.\n */\n @Prop() imageSrc: string | undefined;\n /**\n * The image alternative text.\n */\n @Prop() imageAlt: string | undefined;\n /**\n * The placement of the image.\n */\n @Prop() imagePlacement: 'left' | 'right' = 'right';\n /**\n * A custom styles object.\n */\n @Prop() customStyles: string | undefined;\n /**\n * The position in the document. Used with the \"document_clicked\" measure event.\n */\n @Prop() documentPosition = 0;\n\n private searchcraftStore = useSearchcraftStore.getState();\n\n private recordMeasureEvent = () => {\n const searchcraft = this.searchcraftStore.getSearchcraftInstance();\n\n if (searchcraft) {\n const document_position = this.documentPosition;\n const search_term = this.searchcraftStore.query;\n const number_of_documents =\n this.searchcraftStore.searchResults?.data?.hits?.length || 0;\n\n searchcraft.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n private parseStyles = (): Record<string, { [key: string]: string }> => {\n if (this.customStyles) {\n try {\n return JSON.parse(this.customStyles);\n } catch (error) {\n console.error('Error parsing custom styles:', error);\n return {};\n }\n }\n return {};\n };\n\n render() {\n const styles = this.parseStyles();\n const imageContainer = this.imageSrc && (\n <img\n alt={this.imageAlt}\n class='searchcraft-search-result-image'\n src={this.imageSrc}\n style={styles.image || {}}\n />\n );\n\n const contentContainer = (\n <Fragment>\n {this.imageSrc && this.imagePlacement === 'left' && imageContainer}\n <div class='searchcraft-base-search-result-content-container'>\n {this.titleContent && (\n <h2\n class='searchcraft-base-search-result-title'\n style={styles.title || {}}\n >\n {this.titleContent}\n </h2>\n )}\n {this.subtitleContent && (\n <h3\n class='searchcraft-base-search-result-subtitle'\n style={styles.subtitle || {}}\n >\n {this.subtitleContent}\n </h3>\n )}\n {this.bodyContent && (\n <p\n class='searchcraft-base-search-result-body-content'\n style={styles.primaryContent || {}}\n >\n {this.bodyContent}\n </p>\n )}\n\n {this.footerContent && (\n <p\n class='searchcraft-base-search-result-footer-content'\n style={styles.secondaryContent || {}}\n >\n {this.footerContent}\n </p>\n )}\n {this.buttonHref && !this.containerHref && this.buttonLabel && (\n <a\n class='searchcraft-search-result-button'\n href={this.buttonHref}\n style={styles.button || {}}\n target={this.buttonTarget}\n rel={this.buttonRel}\n >\n {this.buttonLabel}\n </a>\n )}\n </div>\n {this.imageSrc && this.imagePlacement === 'right' && imageContainer}\n </Fragment>\n );\n\n /** Render as an anchor tag if the containerHref prop is present. */\n if (this.containerHref) {\n return (\n <a\n class='searchcraft-search-result-container'\n onClick={this.recordMeasureEvent}\n href={this.containerHref}\n rel={this.containerRel}\n style={styles.container || {}}\n tabindex='0'\n target={this.containerTarget}\n >\n {contentContainer}\n </a>\n );\n }\n\n /** Render as a div if no href prop. */\n return (\n <div\n class='searchcraft-search-result-container'\n style={styles.container || {}}\n >\n {contentContainer}\n </div>\n );\n }\n}\n"]}
|
|
@@ -34,35 +34,58 @@ import { getDocumentValueFromSearchResultMapping, serializeStyles, } from "../..
|
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
36
|
export class SearchcraftBaseSearchResults {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
/**
|
|
38
|
+
* How often ads are injected.
|
|
39
|
+
*/
|
|
40
|
+
adInterval = 4;
|
|
41
|
+
/**
|
|
42
|
+
* A custom styles object.
|
|
43
|
+
*/
|
|
44
|
+
customStylesForResults;
|
|
45
|
+
/**
|
|
46
|
+
* Formats the content rendered for each result.
|
|
47
|
+
*/
|
|
48
|
+
searchResultMappings;
|
|
49
|
+
/**
|
|
50
|
+
* Should an ad be placed at the end of the results.
|
|
51
|
+
*/
|
|
52
|
+
placeAdAtEnd = false;
|
|
53
|
+
/**
|
|
54
|
+
* Should an ad be placed at the start of the results.
|
|
55
|
+
*/
|
|
56
|
+
placeAdAtStart = true;
|
|
57
|
+
/**
|
|
58
|
+
* The placement of the image for each result.
|
|
59
|
+
*/
|
|
60
|
+
resultImagePlacement = 'right';
|
|
61
|
+
/**
|
|
62
|
+
* The label for the button rendered when containerHref is not present for each result.
|
|
63
|
+
*/
|
|
64
|
+
buttonLabel;
|
|
65
|
+
/**
|
|
66
|
+
* Where to open the link for the button rendered when containerHref is not present for each result.
|
|
67
|
+
*/
|
|
68
|
+
buttonTarget = '_blank';
|
|
69
|
+
/**
|
|
70
|
+
* The relationship between the current document and the link for the button rendered when containerHref is not present for each result.
|
|
71
|
+
*/
|
|
72
|
+
buttonRel;
|
|
73
|
+
/**
|
|
74
|
+
* Where to open the link for the containing element for each result.
|
|
75
|
+
*/
|
|
76
|
+
containerTarget = '_blank';
|
|
77
|
+
/**
|
|
78
|
+
* The relationship between the current document and the link for the containing element for each result.
|
|
79
|
+
*/
|
|
80
|
+
containerRel;
|
|
81
|
+
/**
|
|
82
|
+
* When no results are returned.
|
|
83
|
+
*/
|
|
84
|
+
noResults;
|
|
85
|
+
hasSearched = false;
|
|
86
|
+
query = '';
|
|
87
|
+
searchResults = null;
|
|
88
|
+
unsubscribe = () => { };
|
|
66
89
|
componentDidLoad() {
|
|
67
90
|
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
68
91
|
if (state.query.length > 0) {
|
|
@@ -71,7 +94,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
71
94
|
else {
|
|
72
95
|
this.hasSearched = false;
|
|
73
96
|
}
|
|
74
|
-
this.searchResults =
|
|
97
|
+
this.searchResults = { ...state.searchResults };
|
|
75
98
|
this.query = state.query;
|
|
76
99
|
});
|
|
77
100
|
const { searchResults, query } = useSearchcraftStore.getState();
|
|
@@ -87,27 +110,30 @@ export class SearchcraftBaseSearchResults {
|
|
|
87
110
|
/**
|
|
88
111
|
* Index field values -> Result container props mappings.
|
|
89
112
|
*/
|
|
90
|
-
const titleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
91
|
-
const subtitleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
92
|
-
const bodyContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
93
|
-
const containerHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
94
|
-
const buttonHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
95
|
-
const imageSource = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
96
|
-
const footerContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
113
|
+
const titleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.title);
|
|
114
|
+
const subtitleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.subtitle);
|
|
115
|
+
const bodyContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.body);
|
|
116
|
+
const containerHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.containerHref);
|
|
117
|
+
const buttonHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.buttonHref);
|
|
118
|
+
const imageSource = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.imageSource);
|
|
119
|
+
const footerContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.footer);
|
|
120
|
+
let serializedStyles = '';
|
|
121
|
+
if (this.customStylesForResults) {
|
|
122
|
+
serializedStyles =
|
|
123
|
+
typeof this.customStylesForResults === 'string'
|
|
124
|
+
? this.customStylesForResults
|
|
125
|
+
: serializeStyles(this.customStylesForResults);
|
|
126
|
+
}
|
|
100
127
|
return (h("searchcraft-base-search-result", { key: `${document.document_id}-${index}`, "custom-styles": serializedStyles, "image-placement": this.resultImagePlacement, "container-rel": this.containerRel, "container-target": this.containerTarget, "button-label": this.buttonLabel || 'View more', "button-rel": this.buttonRel, "button-target": this.buttonTarget, "document-position": index, "title-content": titleContent, "subtitle-content": subtitleContent, "body-content": bodyContent, "footer-content": footerContent, "container-href": containerHref, "button-href": buttonHref, "image-src": imageSource }));
|
|
101
128
|
}
|
|
102
129
|
render() {
|
|
103
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
104
130
|
if (this.query.trim() === '') {
|
|
105
131
|
return (h("div", { class: 'searchcraft-search-results-empty-state-container' }, h("slot", { name: 'empty-search' })));
|
|
106
132
|
}
|
|
107
|
-
if (!
|
|
133
|
+
if (!this.searchResults?.data) {
|
|
108
134
|
return;
|
|
109
135
|
}
|
|
110
|
-
const documents =
|
|
136
|
+
const documents = this.searchResults?.data?.hits?.map((data, _index) => {
|
|
111
137
|
const { doc: result } = data;
|
|
112
138
|
return result;
|
|
113
139
|
});
|
|
@@ -130,23 +156,13 @@ export class SearchcraftBaseSearchResults {
|
|
|
130
156
|
if (this.placeAdAtEnd) {
|
|
131
157
|
finalComponents.push(h("div", { key: 'ad-section-end', class: 'searchcraft-ad-section' }, h("p", null, "Ad Section")));
|
|
132
158
|
}
|
|
133
|
-
if (this.query.length > 0 &&
|
|
134
|
-
this.noResults
|
|
159
|
+
if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {
|
|
160
|
+
this.noResults?.emit();
|
|
135
161
|
}
|
|
136
162
|
return (h("div", { class: 'searchcraft-search-results-container' }, finalComponents, this.query.length > 0 &&
|
|
137
|
-
|
|
163
|
+
this.searchResults?.data?.hits?.length === 0 && (h("div", { class: 'searchcraft-search-results-error-message-container' }, h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` })))));
|
|
138
164
|
}
|
|
139
165
|
static get is() { return "searchcraft-base-search-results"; }
|
|
140
|
-
static get originalStyleUrls() {
|
|
141
|
-
return {
|
|
142
|
-
"$": ["searchcraft-base-search-results.module.scss"]
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
static get styleUrls() {
|
|
146
|
-
return {
|
|
147
|
-
"$": ["searchcraft-base-search-results.module.css"]
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
166
|
static get properties() {
|
|
151
167
|
return {
|
|
152
168
|
"adInterval": {
|
|
@@ -174,7 +190,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
174
190
|
"mutable": false,
|
|
175
191
|
"complexType": {
|
|
176
192
|
"original": "| string\n | Record<string, Record<string, string>>\n | undefined",
|
|
177
|
-
"resolved": "string | { [x: string]: Record<string, string>; }",
|
|
193
|
+
"resolved": "string | undefined | { [x: string]: Record<string, string>; }",
|
|
178
194
|
"references": {
|
|
179
195
|
"Record": {
|
|
180
196
|
"location": "global",
|
|
@@ -198,7 +214,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
198
214
|
"mutable": false,
|
|
199
215
|
"complexType": {
|
|
200
216
|
"original": "SearchResultMappings | undefined",
|
|
201
|
-
"resolved": "{ body?: SearchResultMapping; buttonHref?: SearchResultMapping; containerHref?: SearchResultMapping; footer?: SearchResultMapping; imageSource?: SearchResultMapping; subtitle?: SearchResultMapping; title?: SearchResultMapping; }",
|
|
217
|
+
"resolved": "undefined | { body?: SearchResultMapping | undefined; buttonHref?: SearchResultMapping | undefined; containerHref?: SearchResultMapping | undefined; footer?: SearchResultMapping | undefined; imageSource?: SearchResultMapping | undefined; subtitle?: SearchResultMapping | undefined; title?: SearchResultMapping | undefined; }",
|
|
202
218
|
"references": {
|
|
203
219
|
"SearchResultMappings": {
|
|
204
220
|
"location": "import",
|
|
@@ -281,7 +297,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
281
297
|
"mutable": false,
|
|
282
298
|
"complexType": {
|
|
283
299
|
"original": "string | undefined",
|
|
284
|
-
"resolved": "string",
|
|
300
|
+
"resolved": "string | undefined",
|
|
285
301
|
"references": {}
|
|
286
302
|
},
|
|
287
303
|
"required": false,
|
|
@@ -320,7 +336,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
320
336
|
"mutable": false,
|
|
321
337
|
"complexType": {
|
|
322
338
|
"original": "'noreferrer' | 'noopener' | 'nofollow' | undefined",
|
|
323
|
-
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\"",
|
|
339
|
+
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\" | undefined",
|
|
324
340
|
"references": {}
|
|
325
341
|
},
|
|
326
342
|
"required": false,
|
|
@@ -359,7 +375,7 @@ export class SearchcraftBaseSearchResults {
|
|
|
359
375
|
"mutable": false,
|
|
360
376
|
"complexType": {
|
|
361
377
|
"original": "'noreferrer' | 'noopener' | 'nofollow' | undefined",
|
|
362
|
-
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\"",
|
|
378
|
+
"resolved": "\"nofollow\" | \"noopener\" | \"noreferrer\" | undefined",
|
|
363
379
|
"references": {}
|
|
364
380
|
},
|
|
365
381
|
"required": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-base-search-results.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,KAAK,EACL,IAAI,EACJ,KAAK,GAEN,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils';\nimport type { SearchResultMappings } from 'types';\n\n/**\n * This web component is responsible for displaying the results of a search query.\n * Once a query is submitted, the component formats and presents an ordered list of the results.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-base-search-results\n * ad-interval=\"4\"\n * place-ad-at-start=\"false\"\n * result-image-placement=\"right\"\n * />\n * ```\n *\n * ```js\n * // index.js\n * const baseSearchResults = document.querySelector('searchcraft-base-search-results');\n *\n * baseSearchResults.searchResultMappings = containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n *\n * baseSearchResults.addEventListener('noResults', () => {\n * console.log('No search results found');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-base-search-results',\n styleUrl: 'searchcraft-base-search-results.module.scss',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n /**\n * How often ads are injected.\n */\n @Prop() adInterval = 4;\n /**\n * A custom styles object.\n */\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n /**\n * Formats the content rendered for each result.\n */\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n /**\n * Should an ad be placed at the end of the results.\n */\n @Prop() placeAdAtEnd = false;\n /**\n * Should an ad be placed at the start of the results.\n */\n @Prop() placeAdAtStart = true;\n /**\n * The placement of the image for each result.\n */\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n /**\n * The label for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * Where to open the link for the containing element for each result.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element for each result.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n /**\n * When no results are returned.\n */\n @Event() noResults: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void;\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults };\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.footer,\n );\n\n const serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n });\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"searchcraft-base-search-results.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,CAAC,EACD,KAAK,EACL,IAAI,EACJ,KAAK,GAEN,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EACL,uCAAuC,EACvC,eAAe,GAChB,MAAM,QAAQ,CAAC;AAIhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,MAAM,OAAO,4BAA4B;IACvC;;OAEG;IACK,UAAU,GAAG,CAAC,CAAC;IACvB;;OAEG;IACK,sBAAsB,CAGhB;IACd;;OAEG;IACK,oBAAoB,CAAmC;IAC/D;;OAEG;IACK,YAAY,GAAG,KAAK,CAAC;IAC7B;;OAEG;IACK,cAAc,GAAG,IAAI,CAAC;IAC9B;;OAEG;IACK,oBAAoB,GAAqB,OAAO,CAAC;IACzD;;OAEG;IACK,WAAW,CAAqB;IACxC;;OAEG;IACK,YAAY,GAA4C,QAAQ,CAAC;IACzE;;OAEG;IACK,SAAS,CAAqD;IACtE;;OAEG;IACK,eAAe,GAA4C,QAAQ,CAAC;IAC5E;;OAEG;IACK,YAAY,CAAqD;IAEzE;;OAEG;IACM,SAAS,CAAsB;IAE/B,WAAW,GAAG,KAAK,CAAC;IACpB,KAAK,GAAG,EAAE,CAAC;IACX,aAAa,GAA+B,IAAI,CAAC;IAElD,WAAW,GAAe,GAAG,EAAE,GAAE,CAAC,CAAC;IAE3C,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACzD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC3B,IAAI,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EAAE,CAAC;QACzB,CAAC;QAED,OAAO,CACL,WAAK,KAAK,EAAC,sCAAsC;YAC9C,eAAe;YACf,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBACpB,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,IAAI,CAC9C,WAAK,KAAK,EAAC,oDAAoD;gBAC7D,kDACiB,gCAAgC,IAAI,CAAC,KAAK,SAAS,GAClE,CACE,CACP,CACC,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils';\nimport type { SearchResultMappings } from 'types';\nimport type { JSX } from '@stencil/core/internal';\n\n/**\n * This web component is responsible for displaying the results of a search query.\n * Once a query is submitted, the component formats and presents an ordered list of the results.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-base-search-results\n * ad-interval=\"4\"\n * place-ad-at-start=\"false\"\n * result-image-placement=\"right\"\n * />\n * ```\n *\n * ```js\n * // index.js\n * const baseSearchResults = document.querySelector('searchcraft-base-search-results');\n *\n * baseSearchResults.searchResultMappings = containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n *\n * baseSearchResults.addEventListener('noResults', () => {\n * console.log('No search results found');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-base-search-results',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n /**\n * How often ads are injected.\n */\n @Prop() adInterval = 4;\n /**\n * A custom styles object.\n */\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n /**\n * Formats the content rendered for each result.\n */\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n /**\n * Should an ad be placed at the end of the results.\n */\n @Prop() placeAdAtEnd = false;\n /**\n * Should an ad be placed at the start of the results.\n */\n @Prop() placeAdAtStart = true;\n /**\n * The placement of the image for each result.\n */\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n /**\n * The label for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * Where to open the link for the containing element for each result.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element for each result.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n /**\n * When no results are returned.\n */\n @Event() noResults?: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void = () => {};\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults } as SearchcraftResponse;\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.footer,\n );\n\n let serializedStyles = '';\n if (this.customStylesForResults) {\n serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n }\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n }) as Record<string, unknown>[];\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults?.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"]}
|