@searchcraft/javascript-sdk 0.8.2 → 0.9.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/README.md +25 -37
- package/dist/components/defineCustomElements.d.ts +1 -0
- package/dist/components/defineCustomElements.js +46 -0
- package/dist/components/index.d.ts +44 -11
- package/dist/components/index.js +104 -53
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-05872320.js +1462 -0
- package/dist/components/p-05872320.js.map +1 -0
- package/dist/components/{p-433f974c.js → p-11b05b94.js} +5 -5
- package/dist/components/p-11b05b94.js.map +1 -0
- package/dist/components/{p-6e2eef88.js → p-3026f7d3.js} +17 -126
- package/dist/components/p-3026f7d3.js.map +1 -0
- package/dist/components/{p-ec0d230e.js → p-3568414f.js} +4 -4
- package/dist/components/p-3568414f.js.map +1 -0
- package/dist/{cjs/SearchcraftStore-75fac5e0.js → components/p-6d8b0ead.js} +1408 -1350
- package/dist/components/p-6d8b0ead.js.map +1 -0
- package/dist/components/{p-fc7cda96.js → p-7777d986.js} +4 -4
- package/dist/components/{p-fc7cda96.js.map → p-7777d986.js.map} +1 -1
- package/dist/components/p-b0bc5cee.js +102 -0
- package/dist/components/p-b0bc5cee.js.map +1 -0
- package/dist/components/{p-4e9cd62e.js → p-bb12ab5a.js} +3 -3
- package/dist/components/{p-4e9cd62e.js.map → p-bb12ab5a.js.map} +1 -1
- package/dist/components/{p-97332d3e.js → p-cd9ba361.js} +3 -3
- package/dist/components/p-cd9ba361.js.map +1 -0
- package/dist/components/searchcraft-ad.d.ts +11 -0
- package/dist/components/searchcraft-ad.js +8 -0
- package/dist/components/searchcraft-ad.js.map +1 -0
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +79 -29
- package/dist/components/searchcraft-base-search-results.js.map +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +7 -7
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-pagination.js +2 -2
- package/dist/components/searchcraft-pagination.js.map +1 -1
- package/dist/components/searchcraft-popover-button.js +3 -3
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-form.js +28 -35
- 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 +2 -2
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +3 -3
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.js +1 -1
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +19 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +10 -7
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +1 -1
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +4 -29
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +1 -11
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +4 -0
- package/dist/types/components.d.ts +33 -158
- package/dist/types/index.d.ts +10 -1
- package/dist/types/store/SearchcraftStore.d.ts +4 -0
- package/dist/types/{provider → store}/SearchcraftStore.types.d.ts +2 -1
- package/dist/{collection/provider/store.js → types/store/index.d.ts} +2 -2
- package/package.json +8 -17
- package/dist/cjs/SearchcraftStore-75fac5e0.js.map +0 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -7
- package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
- package/dist/cjs/index-5b0b9d4c.js +0 -84
- package/dist/cjs/index-5b0b9d4c.js.map +0 -1
- package/dist/cjs/index-a81df4f0.js +0 -1577
- package/dist/cjs/index-a81df4f0.js.map +0 -1
- package/dist/cjs/index.cjs.js +0 -14
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/loader.cjs.js +0 -17
- package/dist/cjs/loader.cjs.js.map +0 -1
- package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js +0 -152
- package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +0 -97
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-button_3.cjs.entry.js +0 -88
- package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +0 -393
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +0 -113
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +0 -260
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +0 -27
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js.map +0 -1
- package/dist/cjs/searchcraft-pagination.cjs.entry.js +0 -106
- package/dist/cjs/searchcraft-pagination.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js +0 -22
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js +0 -234
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js +0 -101
- package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-results-info.cjs.entry.js +0 -80
- package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js +0 -75
- package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-select.cjs.entry.js +0 -70
- package/dist/cjs/searchcraft-select.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-theme.cjs.entry.js +0 -56
- package/dist/cjs/searchcraft-theme.cjs.entry.js.map +0 -1
- package/dist/cjs/styles-7b2d06f2.js +0 -28
- package/dist/cjs/styles-7b2d06f2.js.map +0 -1
- package/dist/cjs/units-fe4d8083.js +0 -88
- package/dist/cjs/units-fe4d8083.js.map +0 -1
- package/dist/collection/collection-manifest.json +0 -32
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +0 -302
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +0 -1
- package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js +0 -73
- package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js.map +0 -1
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +0 -313
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +0 -1
- package/dist/collection/components/searchcraft-button/searchcraft-button.js +0 -217
- package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +0 -1
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +0 -44
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +0 -1
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +0 -200
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +0 -1
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +0 -149
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +0 -1
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +0 -443
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +0 -1
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +0 -67
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +0 -1
- package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js +0 -141
- package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +0 -15
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +0 -381
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +0 -128
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js +0 -73
- package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +0 -141
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js.map +0 -1
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +0 -138
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +0 -1
- package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js +0 -129
- package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js.map +0 -1
- package/dist/collection/components/searchcraft-select/searchcraft-select.js +0 -261
- package/dist/collection/components/searchcraft-select/searchcraft-select.js.map +0 -1
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +0 -194
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +0 -1
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +0 -97
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +0 -1
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +0 -118
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +0 -1
- package/dist/collection/index.js +0 -3
- package/dist/collection/index.js.map +0 -1
- package/dist/collection/provider/SearchcraftStore.js +0 -160
- package/dist/collection/provider/SearchcraftStore.js.map +0 -1
- package/dist/collection/provider/SearchcraftStore.types.js +0 -2
- package/dist/collection/provider/SearchcraftStore.types.js.map +0 -1
- package/dist/collection/provider/store.js.map +0 -1
- package/dist/collection/utils/facets.js +0 -128
- package/dist/collection/utils/facets.js.map +0 -1
- package/dist/collection/utils/index.js +0 -4
- package/dist/collection/utils/index.js.map +0 -1
- package/dist/collection/utils/styles.js +0 -22
- package/dist/collection/utils/styles.js.map +0 -1
- package/dist/collection/utils/units.js +0 -83
- package/dist/collection/utils/units.js.map +0 -1
- package/dist/components/p-25ee7496.js +0 -58
- package/dist/components/p-25ee7496.js.map +0 -1
- package/dist/components/p-38419178.js +0 -1625
- package/dist/components/p-38419178.js.map +0 -1
- package/dist/components/p-433f974c.js.map +0 -1
- package/dist/components/p-6e2eef88.js.map +0 -1
- package/dist/components/p-97332d3e.js.map +0 -1
- package/dist/components/p-bff4d3fc.js +0 -65
- package/dist/components/p-bff4d3fc.js.map +0 -1
- package/dist/components/p-de4a48b1.js +0 -65
- package/dist/components/p-de4a48b1.js.map +0 -1
- package/dist/components/p-ec0d230e.js.map +0 -1
- package/dist/components/searchcraft-base-search-result-ad.d.ts +0 -11
- package/dist/components/searchcraft-base-search-result-ad.js +0 -8
- package/dist/components/searchcraft-base-search-result-ad.js.map +0 -1
- package/dist/components/searchcraft-popover-list-item-ad.d.ts +0 -11
- package/dist/components/searchcraft-popover-list-item-ad.js +0 -8
- package/dist/components/searchcraft-popover-list-item-ad.js.map +0 -1
- package/dist/esm/SearchcraftStore-3cfd565a.js +0 -1625
- package/dist/esm/SearchcraftStore-3cfd565a.js.map +0 -1
- package/dist/esm/app-globals-0f993ce5.js +0 -5
- package/dist/esm/app-globals-0f993ce5.js.map +0 -1
- package/dist/esm/index-3608c57d.js +0 -1548
- package/dist/esm/index-3608c57d.js.map +0 -1
- package/dist/esm/index-72ac5051.js +0 -82
- package/dist/esm/index-72ac5051.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/loader.js +0 -13
- package/dist/esm/loader.js.map +0 -1
- package/dist/esm/searchcraft-base-search-result_2.entry.js +0 -147
- package/dist/esm/searchcraft-base-search-result_2.entry.js.map +0 -1
- package/dist/esm/searchcraft-base-search-results.entry.js +0 -93
- package/dist/esm/searchcraft-base-search-results.entry.js.map +0 -1
- package/dist/esm/searchcraft-button_3.entry.js +0 -82
- package/dist/esm/searchcraft-button_3.entry.js.map +0 -1
- package/dist/esm/searchcraft-facet-list_3.entry.js +0 -387
- package/dist/esm/searchcraft-facet-list_3.entry.js.map +0 -1
- package/dist/esm/searchcraft-filter-panel.entry.js +0 -109
- package/dist/esm/searchcraft-filter-panel.entry.js.map +0 -1
- package/dist/esm/searchcraft-input-form_2.entry.js +0 -255
- package/dist/esm/searchcraft-input-form_2.entry.js.map +0 -1
- package/dist/esm/searchcraft-javascript-sdk.js +0 -22
- package/dist/esm/searchcraft-javascript-sdk.js.map +0 -1
- package/dist/esm/searchcraft-pagination.entry.js +0 -102
- package/dist/esm/searchcraft-pagination.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-button.entry.js +0 -18
- package/dist/esm/searchcraft-popover-button.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-form.entry.js +0 -230
- package/dist/esm/searchcraft-popover-form.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-list-item_2.entry.js +0 -96
- package/dist/esm/searchcraft-popover-list-item_2.entry.js.map +0 -1
- package/dist/esm/searchcraft-results-info.entry.js +0 -76
- package/dist/esm/searchcraft-results-info.entry.js.map +0 -1
- package/dist/esm/searchcraft-search-results-per-page.entry.js +0 -71
- package/dist/esm/searchcraft-search-results-per-page.entry.js.map +0 -1
- package/dist/esm/searchcraft-select.entry.js +0 -66
- package/dist/esm/searchcraft-select.entry.js.map +0 -1
- package/dist/esm/searchcraft-theme.entry.js +0 -52
- package/dist/esm/searchcraft-theme.entry.js.map +0 -1
- package/dist/esm/styles-961644ef.js +0 -25
- package/dist/esm/styles-961644ef.js.map +0 -1
- package/dist/esm/units-daaf96f5.js +0 -84
- package/dist/esm/units-daaf96f5.js.map +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/loader/cdn.js +0 -1
- package/dist/loader/index.cjs.js +0 -1
- package/dist/loader/index.d.ts +0 -24
- package/dist/loader/index.es2017.js +0 -1
- package/dist/loader/index.js +0 -2
- package/dist/loader/package.json +0 -11
- package/dist/searchcraft-javascript-sdk/index.esm.js +0 -2
- package/dist/searchcraft-javascript-sdk/index.esm.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-37842dee.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-37842dee.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-38419178.js +0 -11
- package/dist/searchcraft-javascript-sdk/p-38419178.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-3be70f20.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-3be70f20.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-5cdc6210.js +0 -7
- package/dist/searchcraft-javascript-sdk/p-5cdc6210.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-6104fe5d.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-6104fe5d.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-7813f3cc.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-7813f3cc.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js +0 -3
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-7f4dd50c.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-7f4dd50c.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-d9551738.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-d9551738.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-e1255160.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-e1255160.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +0 -2
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +0 -1
- package/dist/types/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.d.ts +0 -14
- package/dist/types/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.d.ts +0 -14
- package/dist/types/provider/SearchcraftStore.d.ts +0 -4
- package/dist/types/provider/store.d.ts +0 -3
package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { useSearchcraftStore } from "../../provider/store";
|
|
2
|
-
import { h } from "@stencil/core";
|
|
3
|
-
import { getDocumentValueFromSearchResultMapping } from "../../utils/index";
|
|
4
|
-
/**
|
|
5
|
-
* A single list item rendered in a searchcraft-popover-list-view.
|
|
6
|
-
*/
|
|
7
|
-
export class SearchcraftPopoverListItem {
|
|
8
|
-
item;
|
|
9
|
-
popoverResultMappings;
|
|
10
|
-
/** The document position relative to the search results (For Measure) */
|
|
11
|
-
documentPosition = 0;
|
|
12
|
-
href;
|
|
13
|
-
imageSrc;
|
|
14
|
-
imageAlt;
|
|
15
|
-
titleContent;
|
|
16
|
-
subtitleContent;
|
|
17
|
-
mapValuesFromDocument(document) {
|
|
18
|
-
this.titleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.title);
|
|
19
|
-
this.subtitleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.subtitle);
|
|
20
|
-
this.href = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.href);
|
|
21
|
-
this.imageSrc = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageSource);
|
|
22
|
-
this.imageAlt = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageAlt);
|
|
23
|
-
}
|
|
24
|
-
connectedCallback() {
|
|
25
|
-
if (this.item) {
|
|
26
|
-
this.mapValuesFromDocument(this.item.document);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
disconnectedCallback() { }
|
|
30
|
-
handleLinkClick = () => {
|
|
31
|
-
const state = useSearchcraftStore.getState();
|
|
32
|
-
const searchcraft = state.getSearchcraftInstance();
|
|
33
|
-
if (searchcraft) {
|
|
34
|
-
const document_position = this.documentPosition;
|
|
35
|
-
const search_term = state.searchTerm;
|
|
36
|
-
const number_of_documents = state.searchClientResponseItems.length || 0;
|
|
37
|
-
searchcraft.measureClient?.sendMeasureEvent('document_clicked', {
|
|
38
|
-
document_position,
|
|
39
|
-
number_of_documents,
|
|
40
|
-
search_term,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
render() {
|
|
45
|
-
return (h("a", { key: '77e0a59f0441c7ed717ffc0de7f335e76b7b5f5e', class: 'searchcraft-popover-list-item', href: this.href, onClick: this.handleLinkClick.bind(this) }, this.imageSrc && (h("div", { key: '70fe7167cd9baa5029b1482ac6e71bd46c3171a7', class: 'searchcraft-popover-list-item-image-wrapper' }, h("img", { key: '768f651b06005ecefb9818268664334c6bf0d333', alt: this.imageAlt, src: this.imageSrc, class: 'searchcraft-popover-list-item-image' }))), h("div", { key: 'a34b31b92d232193e9d43c5871ecad0d4ee3f59a', class: 'searchcraft-popover-list-item-info-wrapper' }, h("p", { key: 'f2bd9dab4008d200b4528fde35950be90503d66c', class: 'searchcraft-popover-list-item-title' }, this.titleContent), h("p", { key: '4231966d7c4c48dfaaf4925ad18db3428219edad', class: 'searchcraft-popover-list-item-subtitle' }, this.subtitleContent))));
|
|
46
|
-
}
|
|
47
|
-
static get is() { return "searchcraft-popover-list-item"; }
|
|
48
|
-
static get properties() {
|
|
49
|
-
return {
|
|
50
|
-
"item": {
|
|
51
|
-
"type": "unknown",
|
|
52
|
-
"mutable": false,
|
|
53
|
-
"complexType": {
|
|
54
|
-
"original": "SearchClientResponseItem | undefined",
|
|
55
|
-
"resolved": "SearchClientResponseItem | undefined",
|
|
56
|
-
"references": {
|
|
57
|
-
"SearchClientResponseItem": {
|
|
58
|
-
"location": "import",
|
|
59
|
-
"path": "@searchcraft/core",
|
|
60
|
-
"id": "../core-sdk/dist/index.d.ts::SearchClientResponseItem"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"required": false,
|
|
65
|
-
"optional": false,
|
|
66
|
-
"docs": {
|
|
67
|
-
"tags": [],
|
|
68
|
-
"text": ""
|
|
69
|
-
},
|
|
70
|
-
"getter": false,
|
|
71
|
-
"setter": false
|
|
72
|
-
},
|
|
73
|
-
"popoverResultMappings": {
|
|
74
|
-
"type": "unknown",
|
|
75
|
-
"mutable": false,
|
|
76
|
-
"complexType": {
|
|
77
|
-
"original": "PopoverResultMappings | undefined",
|
|
78
|
-
"resolved": "undefined | { title?: SearchResultMapping | undefined; subtitle?: SearchResultMapping | undefined; imageSource?: SearchResultMapping | undefined; imageAlt?: SearchResultMapping | undefined; href?: SearchResultMapping | undefined; }",
|
|
79
|
-
"references": {
|
|
80
|
-
"PopoverResultMappings": {
|
|
81
|
-
"location": "import",
|
|
82
|
-
"path": "@searchcraft/core",
|
|
83
|
-
"id": "../core-sdk/dist/index.d.ts::PopoverResultMappings"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"required": false,
|
|
88
|
-
"optional": false,
|
|
89
|
-
"docs": {
|
|
90
|
-
"tags": [],
|
|
91
|
-
"text": ""
|
|
92
|
-
},
|
|
93
|
-
"getter": false,
|
|
94
|
-
"setter": false
|
|
95
|
-
},
|
|
96
|
-
"documentPosition": {
|
|
97
|
-
"type": "number",
|
|
98
|
-
"mutable": false,
|
|
99
|
-
"complexType": {
|
|
100
|
-
"original": "number",
|
|
101
|
-
"resolved": "number",
|
|
102
|
-
"references": {}
|
|
103
|
-
},
|
|
104
|
-
"required": false,
|
|
105
|
-
"optional": false,
|
|
106
|
-
"docs": {
|
|
107
|
-
"tags": [],
|
|
108
|
-
"text": "The document position relative to the search results (For Measure)"
|
|
109
|
-
},
|
|
110
|
-
"getter": false,
|
|
111
|
-
"setter": false,
|
|
112
|
-
"attribute": "document-position",
|
|
113
|
-
"reflect": false,
|
|
114
|
-
"defaultValue": "0"
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
static get states() {
|
|
119
|
-
return {
|
|
120
|
-
"href": {},
|
|
121
|
-
"imageSrc": {},
|
|
122
|
-
"imageAlt": {},
|
|
123
|
-
"titleContent": {},
|
|
124
|
-
"subtitleContent": {}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=searchcraft-popover-list-item.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-popover-list-item.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtD,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,uCAAuC,EAAE,MAAM,QAAQ,CAAC;AAEjE;;GAEG;AAKH,MAAM,OAAO,0BAA0B;IAC7B,IAAI,CAAuC;IAC3C,qBAAqB,CAAoC;IACjE,yEAAyE;IACjE,gBAAgB,GAAG,CAAC,CAAC;IAEpB,IAAI,CAAU;IACd,QAAQ,CAAU;IAClB,QAAQ,CAAU;IAClB,YAAY,CAAU;IACtB,eAAe,CAAU;IAElC,qBAAqB,CAAC,QAAwB;QAC5C,IAAI,CAAC,YAAY,GAAG,uCAAuC,CACzD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAClC,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,uCAAuC,CAC5D,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CACrC,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uCAAuC,CACjD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,IAAI,CACjC,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,uCAAuC,CACrD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,WAAW,CACxC,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,uCAAuC,CACrD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CACrC,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,oBAAoB,KAAI,CAAC;IAEzB,eAAe,GAAG,GAAG,EAAE;QACrB,MAAM,KAAK,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,sBAAsB,EAAE,CAAC;QAEnD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,CAAC;YAChD,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC;YACrC,MAAM,mBAAmB,GAAG,KAAK,CAAC,yBAAyB,CAAC,MAAM,IAAI,CAAC,CAAC;YAExE,WAAW,CAAC,aAAa,EAAE,gBAAgB,CAAC,kBAAkB,EAAE;gBAC9D,iBAAiB;gBACjB,mBAAmB;gBACnB,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,MAAM;QACJ,OAAO,CACL,0DACE,KAAK,EAAC,+BAA+B,EACrC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;YAEvC,IAAI,CAAC,QAAQ,IAAI,CAChB,4DAAK,KAAK,EAAC,6CAA6C;gBACtD,4DACE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,KAAK,EAAC,qCAAqC,GAC3C,CACE,CACP;YACD,4DAAK,KAAK,EAAC,4CAA4C;gBACrD,0DAAG,KAAK,EAAC,qCAAqC,IAAE,IAAI,CAAC,YAAY,CAAK;gBACtE,0DAAG,KAAK,EAAC,wCAAwC,IAC9C,IAAI,CAAC,eAAe,CACnB,CACA,CACJ,CACL,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport type {\n SearchDocument,\n SearchClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\nimport { Component, h, Prop, State } from '@stencil/core';\nimport { getDocumentValueFromSearchResultMapping } from '@utils';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n */\n@Component({\n tag: 'searchcraft-popover-list-item',\n shadow: false,\n})\nexport class SearchcraftPopoverListItem {\n @Prop() item: SearchClientResponseItem | undefined;\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /** The document position relative to the search results (For Measure) */\n @Prop() documentPosition = 0;\n\n @State() href?: string;\n @State() imageSrc?: string;\n @State() imageAlt?: string;\n @State() titleContent?: string;\n @State() subtitleContent?: string;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSrc = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n this.imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n }\n\n connectedCallback() {\n if (this.item) {\n this.mapValuesFromDocument(this.item.document);\n }\n }\n\n disconnectedCallback() {}\n\n handleLinkClick = () => {\n const state = useSearchcraftStore.getState();\n const searchcraft = state.getSearchcraftInstance();\n\n if (searchcraft) {\n const document_position = this.documentPosition;\n const search_term = state.searchTerm;\n const number_of_documents = state.searchClientResponseItems.length || 0;\n\n searchcraft.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n render() {\n return (\n <a\n class='searchcraft-popover-list-item'\n href={this.href}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSrc && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSrc}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-info-wrapper'>\n <p class='searchcraft-popover-list-item-title'>{this.titleContent}</p>\n <p class='searchcraft-popover-list-item-subtitle'>\n {this.subtitleContent}\n </p>\n </div>\n </a>\n );\n }\n}\n"]}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { h } from "@stencil/core";
|
|
2
|
-
/**
|
|
3
|
-
* A single list item rendered in a searchcraft-popover-list-view.
|
|
4
|
-
*/
|
|
5
|
-
export class SearchcraftPopoverListItemAd {
|
|
6
|
-
adClientResponseItem;
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
if (this.adClientResponseItem?.admAd?.impression_url) {
|
|
9
|
-
fetch(this.adClientResponseItem?.admAd?.impression_url);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
renderADMProductAd() {
|
|
13
|
-
const ad = this.adClientResponseItem?.admAd;
|
|
14
|
-
if (!ad) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
return (h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term), h("p", { class: 'searchcraft-popover-list-item-ad-subtitle' }, ad.price))));
|
|
18
|
-
}
|
|
19
|
-
renderADMTextAd() {
|
|
20
|
-
const ad = this.adClientResponseItem?.admAd;
|
|
21
|
-
if (!ad) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
return (h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term))));
|
|
25
|
-
}
|
|
26
|
-
renderNativoAd() { }
|
|
27
|
-
renderAdPlaceholder() {
|
|
28
|
-
return h("p", null, "Ad placeholder");
|
|
29
|
-
// return;
|
|
30
|
-
}
|
|
31
|
-
render() {
|
|
32
|
-
if (!this.adClientResponseItem) {
|
|
33
|
-
return this.renderAdPlaceholder();
|
|
34
|
-
}
|
|
35
|
-
switch (this.adClientResponseItem.type) {
|
|
36
|
-
case 'adm-product-ad':
|
|
37
|
-
return this.renderADMProductAd();
|
|
38
|
-
case 'adm-text-ad':
|
|
39
|
-
return this.renderADMTextAd();
|
|
40
|
-
case 'nativo-ad':
|
|
41
|
-
return this.renderNativoAd();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
static get is() { return "searchcraft-popover-list-item-ad"; }
|
|
45
|
-
static get properties() {
|
|
46
|
-
return {
|
|
47
|
-
"adClientResponseItem": {
|
|
48
|
-
"type": "unknown",
|
|
49
|
-
"mutable": false,
|
|
50
|
-
"complexType": {
|
|
51
|
-
"original": "AdClientResponseItem",
|
|
52
|
-
"resolved": "AdClientResponseItem | undefined",
|
|
53
|
-
"references": {
|
|
54
|
-
"AdClientResponseItem": {
|
|
55
|
-
"location": "import",
|
|
56
|
-
"path": "@searchcraft/core",
|
|
57
|
-
"id": "../core-sdk/dist/index.d.ts::AdClientResponseItem"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"required": false,
|
|
62
|
-
"optional": true,
|
|
63
|
-
"docs": {
|
|
64
|
-
"tags": [],
|
|
65
|
-
"text": ""
|
|
66
|
-
},
|
|
67
|
-
"getter": false,
|
|
68
|
-
"setter": false
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=searchcraft-popover-list-item-ad.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-popover-list-item-ad.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AAKH,MAAM,OAAO,4BAA4B;IAC/B,oBAAoB,CAAwB;IAEpD,iBAAiB;QACf,IAAI,IAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;YACrD,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,kBAAkB;QAChB,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAqB,CAAC;QAC5D,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO;QACT,CAAC;QAED,OAAO,CACL,SAAG,KAAK,EAAC,kCAAkC,EAAC,IAAI,EAAE,EAAE,CAAC,SAAS;YAC3D,EAAE,CAAC,SAAS,IAAI,CACf,WAAK,KAAK,EAAC,gDAAgD;gBACzD,WACE,GAAG,EAAE,EAAE,CAAC,IAAI,EACZ,GAAG,EAAE,EAAE,CAAC,SAAS,EACjB,KAAK,EAAC,wCAAwC,GAC9C,CACE,CACP;YACD,WAAK,KAAK,EAAC,+CAA+C;gBACxD,SAAG,KAAK,EAAC,wCAAwC,IAAE,EAAE,CAAC,IAAI,CAAK;gBAC/D,SAAG,KAAK,EAAC,2CAA2C,IAAE,EAAE,CAAC,KAAK,CAAK,CAC/D,CACJ,CACL,CAAC;IACJ,CAAC;IAED,eAAe;QACb,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,KAAkB,CAAC;QACzD,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAO;QACT,CAAC;QAED,OAAO,CACL,SAAG,KAAK,EAAC,kCAAkC,EAAC,IAAI,EAAE,EAAE,CAAC,SAAS;YAC3D,EAAE,CAAC,SAAS,IAAI,CACf,WAAK,KAAK,EAAC,gDAAgD;gBACzD,WACE,GAAG,EAAE,EAAE,CAAC,IAAI,EACZ,GAAG,EAAE,EAAE,CAAC,SAAS,EACjB,KAAK,EAAC,wCAAwC,GAC9C,CACE,CACP;YACD,WAAK,KAAK,EAAC,+CAA+C;gBACxD,SAAG,KAAK,EAAC,wCAAwC,IAAE,EAAE,CAAC,IAAI,CAAK,CAC3D,CACJ,CACL,CAAC;IACJ,CAAC;IAED,cAAc,KAAI,CAAC;IAEnB,mBAAmB;QACjB,OAAO,8BAAqB,CAAC;QAC7B,UAAU;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpC,CAAC;QAED,QAAQ,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;YACvC,KAAK,gBAAgB;gBACnB,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;YAChC,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import type {\n AdClientResponseItem,\n ADMProductAd,\n ADMTextAd,\n} from '@searchcraft/core';\nimport { Component, h, Prop } from '@stencil/core';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n */\n@Component({\n tag: 'searchcraft-popover-list-item-ad',\n shadow: false,\n})\nexport class SearchcraftPopoverListItemAd {\n @Prop() adClientResponseItem?: AdClientResponseItem;\n\n connectedCallback() {\n if (this.adClientResponseItem?.admAd?.impression_url) {\n fetch(this.adClientResponseItem?.admAd?.impression_url);\n }\n }\n\n renderADMProductAd() {\n const ad = this.adClientResponseItem?.admAd as ADMProductAd;\n if (!ad) {\n return;\n }\n\n return (\n <a class='searchcraft-popover-list-item-ad' href={ad.click_url}>\n {ad.image_url && (\n <div class='searchcraft-popover-list-item-ad-image-wrapper'>\n <img\n alt={ad.term}\n src={ad.image_url}\n class='searchcraft-popover-list-item-ad-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-ad-info-wrapper'>\n <p class='searchcraft-popover-list-item-ad-title'>{ad.term}</p>\n <p class='searchcraft-popover-list-item-ad-subtitle'>{ad.price}</p>\n </div>\n </a>\n );\n }\n\n renderADMTextAd() {\n const ad = this.adClientResponseItem?.admAd as ADMTextAd;\n if (!ad) {\n return;\n }\n\n return (\n <a class='searchcraft-popover-list-item-ad' href={ad.click_url}>\n {ad.image_url && (\n <div class='searchcraft-popover-list-item-ad-image-wrapper'>\n <img\n alt={ad.term}\n src={ad.image_url}\n class='searchcraft-popover-list-item-ad-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-ad-info-wrapper'>\n <p class='searchcraft-popover-list-item-ad-title'>{ad.term}</p>\n </div>\n </a>\n );\n }\n\n renderNativoAd() {}\n\n renderAdPlaceholder() {\n return <p>Ad placeholder</p>;\n // return;\n }\n\n render() {\n if (!this.adClientResponseItem) {\n return this.renderAdPlaceholder();\n }\n\n switch (this.adClientResponseItem.type) {\n case 'adm-product-ad':\n return this.renderADMProductAd();\n case 'adm-text-ad':\n return this.renderADMTextAd();\n case 'nativo-ad':\n return this.renderNativoAd();\n }\n }\n}\n"]}
|
package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { h } from "@stencil/core";
|
|
2
|
-
/**
|
|
3
|
-
* This web component is designed to display a list of results within a popover interface.
|
|
4
|
-
* It is consumed within the `searchcraft-popover-form` component.
|
|
5
|
-
*
|
|
6
|
-
* ## Usage
|
|
7
|
-
* ```html
|
|
8
|
-
* <!-- index.html -->
|
|
9
|
-
* <searchcraft-popover-list-view />
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export class SearchcraftPopoverListView {
|
|
13
|
-
/**
|
|
14
|
-
* The mappings that define how the data in the documents are mapped to the
|
|
15
|
-
* list-view-item elements.
|
|
16
|
-
*/
|
|
17
|
-
popoverResultMappings;
|
|
18
|
-
/**
|
|
19
|
-
* The items to render in the list view.
|
|
20
|
-
*/
|
|
21
|
-
searchClientResponseItems;
|
|
22
|
-
adClientResponseItems;
|
|
23
|
-
searchResultsPage;
|
|
24
|
-
searchResultsPerPage;
|
|
25
|
-
render() {
|
|
26
|
-
return (h("div", { key: 'a869d98e96f6fbbc80ecb79058c4753b4a3a8b1d', class: 'searchcraft-popover-list-view' }, this.adClientResponseItems?.map((item) => (h("searchcraft-popover-list-item-ad", { adClientResponseItem: item, key: item.adId }))), this.searchClientResponseItems?.map((item, index) => (h("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index })))));
|
|
27
|
-
}
|
|
28
|
-
static get is() { return "searchcraft-popover-list-view"; }
|
|
29
|
-
static get properties() {
|
|
30
|
-
return {
|
|
31
|
-
"popoverResultMappings": {
|
|
32
|
-
"type": "unknown",
|
|
33
|
-
"mutable": false,
|
|
34
|
-
"complexType": {
|
|
35
|
-
"original": "PopoverResultMappings | undefined",
|
|
36
|
-
"resolved": "undefined | { title?: SearchResultMapping | undefined; subtitle?: SearchResultMapping | undefined; imageSource?: SearchResultMapping | undefined; imageAlt?: SearchResultMapping | undefined; href?: SearchResultMapping | undefined; }",
|
|
37
|
-
"references": {
|
|
38
|
-
"PopoverResultMappings": {
|
|
39
|
-
"location": "import",
|
|
40
|
-
"path": "@searchcraft/core",
|
|
41
|
-
"id": "../core-sdk/dist/index.d.ts::PopoverResultMappings"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"required": false,
|
|
46
|
-
"optional": false,
|
|
47
|
-
"docs": {
|
|
48
|
-
"tags": [],
|
|
49
|
-
"text": "The mappings that define how the data in the documents are mapped to the\nlist-view-item elements."
|
|
50
|
-
},
|
|
51
|
-
"getter": false,
|
|
52
|
-
"setter": false
|
|
53
|
-
},
|
|
54
|
-
"searchClientResponseItems": {
|
|
55
|
-
"type": "unknown",
|
|
56
|
-
"mutable": false,
|
|
57
|
-
"complexType": {
|
|
58
|
-
"original": "SearchClientResponseItem[] | undefined",
|
|
59
|
-
"resolved": "SearchClientResponseItem[] | undefined",
|
|
60
|
-
"references": {
|
|
61
|
-
"SearchClientResponseItem": {
|
|
62
|
-
"location": "import",
|
|
63
|
-
"path": "@searchcraft/core",
|
|
64
|
-
"id": "../core-sdk/dist/index.d.ts::SearchClientResponseItem"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"required": false,
|
|
69
|
-
"optional": false,
|
|
70
|
-
"docs": {
|
|
71
|
-
"tags": [],
|
|
72
|
-
"text": "The items to render in the list view."
|
|
73
|
-
},
|
|
74
|
-
"getter": false,
|
|
75
|
-
"setter": false
|
|
76
|
-
},
|
|
77
|
-
"adClientResponseItems": {
|
|
78
|
-
"type": "unknown",
|
|
79
|
-
"mutable": false,
|
|
80
|
-
"complexType": {
|
|
81
|
-
"original": "AdClientResponseItem[] | undefined",
|
|
82
|
-
"resolved": "AdClientResponseItem[] | undefined",
|
|
83
|
-
"references": {
|
|
84
|
-
"AdClientResponseItem": {
|
|
85
|
-
"location": "import",
|
|
86
|
-
"path": "@searchcraft/core",
|
|
87
|
-
"id": "../core-sdk/dist/index.d.ts::AdClientResponseItem"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"required": false,
|
|
92
|
-
"optional": false,
|
|
93
|
-
"docs": {
|
|
94
|
-
"tags": [],
|
|
95
|
-
"text": ""
|
|
96
|
-
},
|
|
97
|
-
"getter": false,
|
|
98
|
-
"setter": false
|
|
99
|
-
},
|
|
100
|
-
"searchResultsPage": {
|
|
101
|
-
"type": "number",
|
|
102
|
-
"mutable": false,
|
|
103
|
-
"complexType": {
|
|
104
|
-
"original": "number",
|
|
105
|
-
"resolved": "number",
|
|
106
|
-
"references": {}
|
|
107
|
-
},
|
|
108
|
-
"required": true,
|
|
109
|
-
"optional": false,
|
|
110
|
-
"docs": {
|
|
111
|
-
"tags": [],
|
|
112
|
-
"text": ""
|
|
113
|
-
},
|
|
114
|
-
"getter": false,
|
|
115
|
-
"setter": false,
|
|
116
|
-
"attribute": "search-results-page",
|
|
117
|
-
"reflect": false
|
|
118
|
-
},
|
|
119
|
-
"searchResultsPerPage": {
|
|
120
|
-
"type": "number",
|
|
121
|
-
"mutable": false,
|
|
122
|
-
"complexType": {
|
|
123
|
-
"original": "number",
|
|
124
|
-
"resolved": "number",
|
|
125
|
-
"references": {}
|
|
126
|
-
},
|
|
127
|
-
"required": true,
|
|
128
|
-
"optional": false,
|
|
129
|
-
"docs": {
|
|
130
|
-
"tags": [],
|
|
131
|
-
"text": ""
|
|
132
|
-
},
|
|
133
|
-
"getter": false,
|
|
134
|
-
"setter": false,
|
|
135
|
-
"attribute": "search-results-per-page",
|
|
136
|
-
"reflect": false
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=searchcraft-popover-list-view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-popover-list-view.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAInD;;;;;;;;;GASG;AAKH,MAAM,OAAO,0BAA0B;IACrC;;;OAGG;IACK,qBAAqB,CAAoC;IACjE;;OAEG;IACK,yBAAyB,CAAyC;IAClE,qBAAqB,CAAqC;IAC1D,iBAAiB,CAAU;IAC3B,oBAAoB,CAAU;IAEtC,MAAM;QACJ,OAAO,CACL,4DAAK,KAAK,EAAC,+BAA+B;YACvC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACzC,wCACE,oBAAoB,EAAE,IAAI,EAC1B,GAAG,EAAE,IAAI,CAAC,IAAI,GACd,CACH,CAAC;YACD,IAAI,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CACpD,qCACE,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,gBAAgB,EACd,IAAI,CAAC,oBAAoB,GAAG,CAAC,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,KAAK,GAElE,CACH,CAAC,CACE,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import type {\n AdClientResponseItem,\n SearchClientResponseItem,\n} from '@searchcraft/core';\nimport { Component, h, Prop } from '@stencil/core';\n\nimport type { PopoverResultMappings } from '@searchcraft/core';\n\n/**\n * This web component is designed to display a list of results within a popover interface.\n * It is consumed within the `searchcraft-popover-form` component.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-list-view />\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-list-view',\n shadow: false,\n})\nexport class SearchcraftPopoverListView {\n /**\n * The mappings that define how the data in the documents are mapped to the\n * list-view-item elements.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The items to render in the list view.\n */\n @Prop() searchClientResponseItems: SearchClientResponseItem[] | undefined;\n @Prop() adClientResponseItems: AdClientResponseItem[] | undefined;\n @Prop() searchResultsPage!: number;\n @Prop() searchResultsPerPage!: number;\n\n render() {\n return (\n <div class='searchcraft-popover-list-view'>\n {this.adClientResponseItems?.map((item) => (\n <searchcraft-popover-list-item-ad\n adClientResponseItem={item}\n key={item.adId}\n />\n ))}\n {this.searchClientResponseItems?.map((item, index) => (\n <searchcraft-popover-list-item\n item={item}\n key={item.id}\n popoverResultMappings={this.popoverResultMappings}\n documentPosition={\n this.searchResultsPerPage * (this.searchResultsPage - 1) + index\n }\n />\n ))}\n </div>\n );\n }\n}\n"]}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { h } from "@stencil/core";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { useSearchcraftStore } from "../../provider/store";
|
|
4
|
-
import { formatNumberWithCommas, parseCustomStyles } from "../../utils/index";
|
|
5
|
-
/**
|
|
6
|
-
* This web component is designed to display the number of results returned from a search query.
|
|
7
|
-
*
|
|
8
|
-
* ## Usage
|
|
9
|
-
* ```html
|
|
10
|
-
* <!-- index.html -->
|
|
11
|
-
* <script>
|
|
12
|
-
* const resultsInfo = document.querySelector('searchcraft-results-info');
|
|
13
|
-
* resultsInfo.customFormatter = (range, count, responseTime) =>
|
|
14
|
-
* `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
|
|
15
|
-
* </script>
|
|
16
|
-
*
|
|
17
|
-
* <searchcraft-results-info />
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class SearchcraftResultsInfo {
|
|
21
|
-
/**
|
|
22
|
-
* The custom formatter for the resulting string.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* resultsInfo.customFormatter = (range, count, responseTime) =>
|
|
27
|
-
* `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
customFormatter;
|
|
31
|
-
/**
|
|
32
|
-
* The custom styles object.
|
|
33
|
-
*/
|
|
34
|
-
customStyles;
|
|
35
|
-
// store vars
|
|
36
|
-
searchTerm;
|
|
37
|
-
searchResultsPage;
|
|
38
|
-
searchResultsPerPage;
|
|
39
|
-
searchResultsCount;
|
|
40
|
-
// local vars
|
|
41
|
-
count = 0;
|
|
42
|
-
range = [0, 0];
|
|
43
|
-
responseTime = '0';
|
|
44
|
-
unsubscribe = () => { };
|
|
45
|
-
connectedCallback() {
|
|
46
|
-
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
47
|
-
// store vars
|
|
48
|
-
this.searchTerm = state.searchTerm;
|
|
49
|
-
this.searchResultsPage = state.searchResultsPage;
|
|
50
|
-
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
51
|
-
this.searchResultsCount = state.searchResultsCount;
|
|
52
|
-
// local vars
|
|
53
|
-
this.count = this.searchResultsCount;
|
|
54
|
-
this.range[0] =
|
|
55
|
-
this.searchResultsPage <= 1
|
|
56
|
-
? 1
|
|
57
|
-
: this.searchResultsPerPage * (this.searchResultsPage - 1);
|
|
58
|
-
this.range[1] = this.searchResultsPerPage * this.searchResultsPage;
|
|
59
|
-
this.range[1] =
|
|
60
|
-
this.range[1] > this.searchResultsCount
|
|
61
|
-
? this.searchResultsCount
|
|
62
|
-
: this.range[1];
|
|
63
|
-
this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(2);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
disconnectedCallback() {
|
|
67
|
-
if (this.unsubscribe) {
|
|
68
|
-
this.unsubscribe();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
render() {
|
|
72
|
-
if (!this.searchTerm || this.searchResultsCount === 0) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return (h("p", { class: classNames('searchcraft-results-info', parseCustomStyles(this.customStyles || {})) }, this.customFormatter
|
|
76
|
-
? this.customFormatter([
|
|
77
|
-
formatNumberWithCommas(this.range[0]),
|
|
78
|
-
formatNumberWithCommas(this.range[1]),
|
|
79
|
-
], formatNumberWithCommas(this.count), this.responseTime)
|
|
80
|
-
: `${this.count} results found in ${this.responseTime}ms`));
|
|
81
|
-
}
|
|
82
|
-
static get is() { return "searchcraft-results-info"; }
|
|
83
|
-
static get properties() {
|
|
84
|
-
return {
|
|
85
|
-
"customFormatter": {
|
|
86
|
-
"type": "unknown",
|
|
87
|
-
"mutable": false,
|
|
88
|
-
"complexType": {
|
|
89
|
-
"original": "(\n range: [string, string],\n count: string,\n responseTime: string,\n ) => void",
|
|
90
|
-
"resolved": "((range: [string, string], count: string, responseTime: string) => void) | undefined",
|
|
91
|
-
"references": {}
|
|
92
|
-
},
|
|
93
|
-
"required": false,
|
|
94
|
-
"optional": true,
|
|
95
|
-
"docs": {
|
|
96
|
-
"tags": [{
|
|
97
|
-
"name": "example",
|
|
98
|
-
"text": "```ts\n resultsInfo.customFormatter = (range, count, responseTime) =>\n `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n```"
|
|
99
|
-
}],
|
|
100
|
-
"text": "The custom formatter for the resulting string."
|
|
101
|
-
},
|
|
102
|
-
"getter": false,
|
|
103
|
-
"setter": false
|
|
104
|
-
},
|
|
105
|
-
"customStyles": {
|
|
106
|
-
"type": "string",
|
|
107
|
-
"mutable": false,
|
|
108
|
-
"complexType": {
|
|
109
|
-
"original": "string",
|
|
110
|
-
"resolved": "string | undefined",
|
|
111
|
-
"references": {}
|
|
112
|
-
},
|
|
113
|
-
"required": false,
|
|
114
|
-
"optional": true,
|
|
115
|
-
"docs": {
|
|
116
|
-
"tags": [],
|
|
117
|
-
"text": "The custom styles object."
|
|
118
|
-
},
|
|
119
|
-
"getter": false,
|
|
120
|
-
"setter": false,
|
|
121
|
-
"attribute": "custom-styles",
|
|
122
|
-
"reflect": false
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
static get states() {
|
|
127
|
-
return {
|
|
128
|
-
"searchTerm": {},
|
|
129
|
-
"searchResultsPage": {},
|
|
130
|
-
"searchResultsPerPage": {},
|
|
131
|
-
"searchResultsCount": {},
|
|
132
|
-
"count": {},
|
|
133
|
-
"range": {},
|
|
134
|
-
"responseTime": {}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=searchcraft-results-info.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchcraft-results-info.js","sourceRoot":"","sources":["../../../../src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEnE;;;;;;;;;;;;;;GAcG;AAKH,MAAM,OAAO,sBAAsB;IACjC;;;;;;;;OAQG;IACK,eAAe,CAIb;IACV;;OAEG;IACK,YAAY,CAAU;IAE9B,aAAa;IACJ,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;IAE5B,aAAa;IACJ,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB,YAAY,GAAG,GAAG,CAAC;IAE5B,WAAW,GAAe,GAAG,EAAE,GAAE,CAAC,CAAC;IAEnC,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACzD,aAAa;YACb,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YACnC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;YACjD,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,oBAAoB,CAAC;YACvD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;YAEnD,aAAa;YACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,iBAAiB,IAAI,CAAC;oBACzB,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,IAAI,CAAC,oBAAoB,GAAG,CAAC,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC;YAC/D,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,kBAAkB;oBACrC,CAAC,CAAC,IAAI,CAAC,kBAAkB;oBACzB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CACvE,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,kBAAkB,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CACL,SACE,KAAK,EAAE,UAAU,CACf,0BAA0B,EAC1B,iBAAiB,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAC3C,IAEA,IAAI,CAAC,eAAe;YACnB,CAAC,CAAC,IAAI,CAAC,eAAe,CAClB;gBACE,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtC,EACD,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAClC,IAAI,CAAC,YAAY,CAClB;YACH,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,qBAAqB,IAAI,CAAC,YAAY,IAAI,CACzD,CACL,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, State, Prop } from '@stencil/core';\nimport classNames from 'classnames';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport { formatNumberWithCommas, parseCustomStyles } from '@utils';\n\n/**\n * This web component is designed to display the number of results returned from a search query.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <script>\n * const resultsInfo = document.querySelector('searchcraft-results-info');\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * </script>\n *\n * <searchcraft-results-info />\n * ```\n */\n@Component({\n tag: 'searchcraft-results-info',\n shadow: false,\n})\nexport class SearchcraftResultsInfo {\n /**\n * The custom formatter for the resulting string.\n *\n * @example\n * ```ts\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * ```\n */\n @Prop() customFormatter?: (\n range: [string, string],\n count: string,\n responseTime: string,\n ) => void;\n /**\n * The custom styles object.\n */\n @Prop() customStyles?: string;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n @State() searchResultsCount;\n\n // local vars\n @State() count = 0;\n @State() range: number[] = [0, 0];\n @State() responseTime = '0';\n\n unsubscribe: () => void = () => {};\n\n connectedCallback() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.count = this.searchResultsCount;\n this.range[0] =\n this.searchResultsPage <= 1\n ? 1\n : this.searchResultsPerPage * (this.searchResultsPage - 1);\n this.range[1] = this.searchResultsPerPage * this.searchResultsPage;\n this.range[1] =\n this.range[1] > this.searchResultsCount\n ? this.searchResultsCount\n : this.range[1];\n this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(\n 2,\n );\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n render() {\n if (!this.searchTerm || this.searchResultsCount === 0) {\n return null;\n }\n\n return (\n <p\n class={classNames(\n 'searchcraft-results-info',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n {this.customFormatter\n ? this.customFormatter(\n [\n formatNumberWithCommas(this.range[0]),\n formatNumberWithCommas(this.range[1]),\n ],\n formatNumberWithCommas(this.count),\n this.responseTime,\n )\n : `${this.count} results found in ${this.responseTime}ms`}\n </p>\n );\n }\n}\n"]}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { useSearchcraftStore } from "../../provider/store";
|
|
2
|
-
import { h } from "@stencil/core";
|
|
3
|
-
import classNames from "classnames";
|
|
4
|
-
import { parseCustomStyles } from "../../utils/index";
|
|
5
|
-
/**
|
|
6
|
-
* This web component is designed to choose the number of search results displayed.
|
|
7
|
-
*
|
|
8
|
-
* ## Usage
|
|
9
|
-
* ```html
|
|
10
|
-
* <!-- index.html -->
|
|
11
|
-
* <searchcraft-search-results-per-page increment="20" />
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export class SearchcraftSearchResultsPerPage {
|
|
15
|
-
/**
|
|
16
|
-
* The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).
|
|
17
|
-
* The base value is defined by the `searchResultsPerPage` option in the configuration.
|
|
18
|
-
*/
|
|
19
|
-
increment = 20;
|
|
20
|
-
/**
|
|
21
|
-
* The custom styles object.
|
|
22
|
-
*/
|
|
23
|
-
customStyles;
|
|
24
|
-
// store vars
|
|
25
|
-
searchTerm;
|
|
26
|
-
searchResultsPage;
|
|
27
|
-
searchResultsPerPage;
|
|
28
|
-
searchResultsCount;
|
|
29
|
-
searchResultsPagesCount;
|
|
30
|
-
// local vars
|
|
31
|
-
initialSearchResultsPerPage;
|
|
32
|
-
// store functions
|
|
33
|
-
setSearchResultsPerPage = () => { };
|
|
34
|
-
setSearchResultsPage = () => { };
|
|
35
|
-
unsubscribe = () => { };
|
|
36
|
-
componentDidLoad() {
|
|
37
|
-
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
38
|
-
// store vars
|
|
39
|
-
this.searchTerm = state.searchTerm;
|
|
40
|
-
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
41
|
-
this.searchResultsPage = state.searchResultsPage;
|
|
42
|
-
this.searchResultsCount = state.searchResultsCount;
|
|
43
|
-
// local vars
|
|
44
|
-
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
45
|
-
// store functions
|
|
46
|
-
this.setSearchResultsPage = state.setSearchResultsPage;
|
|
47
|
-
this.setSearchResultsPerPage = state.setSearchResultsPerPage;
|
|
48
|
-
});
|
|
49
|
-
this.initialSearchResultsPerPage =
|
|
50
|
-
useSearchcraftStore.getState().searchResultsPerPage;
|
|
51
|
-
}
|
|
52
|
-
disconnectedCallback() {
|
|
53
|
-
this.unsubscribe?.();
|
|
54
|
-
}
|
|
55
|
-
render() {
|
|
56
|
-
// early return if there isn't a searchTerm or there is 1 or fewer pages of results
|
|
57
|
-
if (!this.searchTerm || this.searchResultsPagesCount <= 1) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
return (h("div", { class: classNames('searchcraft-search-results-per-page', parseCustomStyles(this.customStyles || {})) }, h("div", { class: 'searchcraft-search-results-per-page-select' }, h("label", { class: 'searchcraft-search-results-per-page-select-label', htmlFor: 'searchcraft-search-results-per-page-select-input' }, "Results Per Page"), h("div", { class: 'searchcraft-search-results-per-page-select-input' }, h("searchcraft-select", { inputId: 'searchcraft-search-results-per-page-select-input', name: 'results-per-page', options: [...Array(5)].map((_, index) => {
|
|
61
|
-
const value = this.initialSearchResultsPerPage +
|
|
62
|
-
Number(this.increment) * index;
|
|
63
|
-
return {
|
|
64
|
-
label: `${value}`,
|
|
65
|
-
value,
|
|
66
|
-
};
|
|
67
|
-
}), onSelectChange: (event) => {
|
|
68
|
-
this.setSearchResultsPerPage(Number(event.detail));
|
|
69
|
-
this.setSearchResultsPage(1);
|
|
70
|
-
} })))));
|
|
71
|
-
}
|
|
72
|
-
static get is() { return "searchcraft-search-results-per-page"; }
|
|
73
|
-
static get properties() {
|
|
74
|
-
return {
|
|
75
|
-
"increment": {
|
|
76
|
-
"type": "any",
|
|
77
|
-
"mutable": false,
|
|
78
|
-
"complexType": {
|
|
79
|
-
"original": "string | number",
|
|
80
|
-
"resolved": "number | string",
|
|
81
|
-
"references": {}
|
|
82
|
-
},
|
|
83
|
-
"required": false,
|
|
84
|
-
"optional": false,
|
|
85
|
-
"docs": {
|
|
86
|
-
"tags": [],
|
|
87
|
-
"text": "The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).\nThe base value is defined by the `searchResultsPerPage` option in the configuration."
|
|
88
|
-
},
|
|
89
|
-
"getter": false,
|
|
90
|
-
"setter": false,
|
|
91
|
-
"attribute": "increment",
|
|
92
|
-
"reflect": false,
|
|
93
|
-
"defaultValue": "20"
|
|
94
|
-
},
|
|
95
|
-
"customStyles": {
|
|
96
|
-
"type": "string",
|
|
97
|
-
"mutable": false,
|
|
98
|
-
"complexType": {
|
|
99
|
-
"original": "string",
|
|
100
|
-
"resolved": "string | undefined",
|
|
101
|
-
"references": {}
|
|
102
|
-
},
|
|
103
|
-
"required": false,
|
|
104
|
-
"optional": true,
|
|
105
|
-
"docs": {
|
|
106
|
-
"tags": [],
|
|
107
|
-
"text": "The custom styles object."
|
|
108
|
-
},
|
|
109
|
-
"getter": false,
|
|
110
|
-
"setter": false,
|
|
111
|
-
"attribute": "custom-styles",
|
|
112
|
-
"reflect": false
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
static get states() {
|
|
117
|
-
return {
|
|
118
|
-
"searchTerm": {},
|
|
119
|
-
"searchResultsPage": {},
|
|
120
|
-
"searchResultsPerPage": {},
|
|
121
|
-
"searchResultsCount": {},
|
|
122
|
-
"searchResultsPagesCount": {},
|
|
123
|
-
"initialSearchResultsPerPage": {},
|
|
124
|
-
"setSearchResultsPerPage": {},
|
|
125
|
-
"setSearchResultsPage": {}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=searchcraft-search-results-per-page.js.map
|