@searchcraft/javascript-sdk 0.8.1 → 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-ae78be68.js → p-3026f7d3.js} +18 -127
- 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-d19bf6ff.js → p-71cc28c1.js} +2 -2
- package/dist/components/p-71cc28c1.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-button.js +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 +5 -5
- 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-97332d3e.js.map +0 -1
- package/dist/components/p-ae78be68.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-d19bf6ff.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-38419178.js +0 -11
- package/dist/searchcraft-javascript-sdk/p-38419178.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-69da4e58.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-69da4e58.entry.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-75779e4b.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-75779e4b.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-d2fffca9.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-d2fffca9.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
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const index$1 = require('./index-5b0b9d4c.js');
|
|
7
|
-
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
8
|
-
|
|
9
|
-
const SearchcraftPopoverForm = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The Searchcraft config object.
|
|
15
|
-
*/
|
|
16
|
-
config;
|
|
17
|
-
/**
|
|
18
|
-
* The type of popover form to render.
|
|
19
|
-
*
|
|
20
|
-
* - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.
|
|
21
|
-
* - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.
|
|
22
|
-
* - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.
|
|
23
|
-
*/
|
|
24
|
-
type = 'inline';
|
|
25
|
-
/**
|
|
26
|
-
* Formats the content rendered for each result.
|
|
27
|
-
*/
|
|
28
|
-
popoverResultMappings;
|
|
29
|
-
/**
|
|
30
|
-
* The hotkey that activates the popover.
|
|
31
|
-
*/
|
|
32
|
-
hotkey = 'k';
|
|
33
|
-
/**
|
|
34
|
-
* The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
|
|
35
|
-
*/
|
|
36
|
-
hotkeyModifier = 'meta';
|
|
37
|
-
isPopoverVisibleInState = false;
|
|
38
|
-
unsubscribe;
|
|
39
|
-
searchClientResponseItems = [];
|
|
40
|
-
adClientResponseItems = [];
|
|
41
|
-
searchTerm;
|
|
42
|
-
isFocused = false;
|
|
43
|
-
breakpointSm = 576;
|
|
44
|
-
breakpointMd = 768;
|
|
45
|
-
breakpointLg = 992;
|
|
46
|
-
searchResultsPage;
|
|
47
|
-
searchResultsPerPage;
|
|
48
|
-
modalElement;
|
|
49
|
-
get hostElement() { return index.getElement(this); }
|
|
50
|
-
componentDidLoad() {
|
|
51
|
-
// Loads the breakpoint values into state
|
|
52
|
-
const computedStyle = getComputedStyle(document.documentElement);
|
|
53
|
-
this.breakpointSm = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-sm').trim());
|
|
54
|
-
this.breakpointMd = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-md').trim());
|
|
55
|
-
this.breakpointLg = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-lg').trim());
|
|
56
|
-
// Set popover visiblity in state
|
|
57
|
-
this.isPopoverVisibleInState =
|
|
58
|
-
SearchcraftStore.useSearchcraftStore.getState().isPopoverVisible;
|
|
59
|
-
// Add event listeners
|
|
60
|
-
document.addEventListener('click', this.handleDocumentClick);
|
|
61
|
-
document.addEventListener('keydown', this.handleDocumentKeyDown);
|
|
62
|
-
// Subscribe to state events
|
|
63
|
-
this.unsubscribe = SearchcraftStore.useSearchcraftStore.subscribe((state) => {
|
|
64
|
-
if (this.isPopoverVisibleInState !== state.isPopoverVisible) {
|
|
65
|
-
this.handlePopoverVisibilityChange(state.isPopoverVisible);
|
|
66
|
-
}
|
|
67
|
-
this.searchClientResponseItems = [...state.searchClientResponseItems];
|
|
68
|
-
this.adClientResponseItems = [...state.adClientResponseItems];
|
|
69
|
-
this.searchTerm = state.searchTerm;
|
|
70
|
-
this.searchResultsPage = state.searchResultsPage;
|
|
71
|
-
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
disconnectedCallback() {
|
|
75
|
-
this.unsubscribe?.();
|
|
76
|
-
document.removeEventListener('click', this.handleDocumentClick);
|
|
77
|
-
document.removeEventListener('keydown', this.handleDocumentKeyDown);
|
|
78
|
-
}
|
|
79
|
-
handleDocumentClick = (event) => {
|
|
80
|
-
if (!this.hostElement.contains(event.target)) {
|
|
81
|
-
this.isFocused = false;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Handles when popover visibility is changed in state
|
|
86
|
-
*/
|
|
87
|
-
handlePopoverVisibilityChange(isVisible) {
|
|
88
|
-
this.isPopoverVisibleInState = isVisible;
|
|
89
|
-
document.body.style.overflow = isVisible ? 'hidden' : 'auto';
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Actions to perform when various keys are pressed within the popover form.
|
|
93
|
-
*/
|
|
94
|
-
handleDocumentKeyDown = (event) => {
|
|
95
|
-
// Document-scoped actions
|
|
96
|
-
if (event.key === this.hotkey) {
|
|
97
|
-
this.handleHotkeyPressed(event);
|
|
98
|
-
}
|
|
99
|
-
// Document-scoped -> Popover-scoped keyboard event boundary
|
|
100
|
-
if (!this.hostElement.contains(document.activeElement)) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
// Popover-scoped actions
|
|
104
|
-
switch (event.key) {
|
|
105
|
-
case 'ArrowDown':
|
|
106
|
-
case 'ArrowUp':
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
this.focusOnNextListItem(event.key);
|
|
109
|
-
break;
|
|
110
|
-
case 'Escape':
|
|
111
|
-
SearchcraftStore.useSearchcraftStore.getState().setPopoverVisibility(false);
|
|
112
|
-
break;
|
|
113
|
-
default:
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
handleInputInit = () => {
|
|
118
|
-
const input = this.hostElement.querySelector('.searchcraft-input');
|
|
119
|
-
input?.focus();
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* When popover is `inline` and the viewport is at the smallest breakpoint,
|
|
123
|
-
* focusing on the input will open a modal version of the popover form.
|
|
124
|
-
*/
|
|
125
|
-
handleInputFocus() {
|
|
126
|
-
this.isFocused = true;
|
|
127
|
-
if (this.type === 'inline' &&
|
|
128
|
-
window.visualViewport &&
|
|
129
|
-
window.visualViewport.width < this.breakpointSm) {
|
|
130
|
-
SearchcraftStore.useSearchcraftStore.getState().setPopoverVisibility(true);
|
|
131
|
-
// Appends a popover form of type=`modal` to the body
|
|
132
|
-
if (!this.modalElement) {
|
|
133
|
-
this.modalElement = document.createElement('searchcraft-popover-form');
|
|
134
|
-
this.modalElement.config = this.config;
|
|
135
|
-
this.modalElement.popoverResultMappings = this.popoverResultMappings;
|
|
136
|
-
this.modalElement.setAttribute('type', 'fullscreen');
|
|
137
|
-
document.body.appendChild(this.modalElement);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
handleModalBackdropClick(_event) {
|
|
142
|
-
SearchcraftStore.useSearchcraftStore.getState().setPopoverVisibility(false);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* When a hotkey is pressed, tests if the modifiers also match.
|
|
146
|
-
* If modifiers match, toggles visibility of the popover modal.
|
|
147
|
-
*/
|
|
148
|
-
handleHotkeyPressed(event) {
|
|
149
|
-
if ((event.ctrlKey && this.hotkeyModifier === 'ctrl') ||
|
|
150
|
-
(event.altKey && this.hotkeyModifier === 'alt') ||
|
|
151
|
-
(event.metaKey && this.hotkeyModifier === 'meta')) {
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
if (this.type === 'inline' && !this.isPopoverVisibleInState) {
|
|
154
|
-
const hostElementInput = this.hostElement.querySelector('.searchcraft-input');
|
|
155
|
-
hostElementInput?.focus();
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
SearchcraftStore.useSearchcraftStore
|
|
159
|
-
.getState()
|
|
160
|
-
.setPopoverVisibility(!this.isPopoverVisibleInState);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
handleCancelButtonClick() {
|
|
165
|
-
SearchcraftStore.useSearchcraftStore.getState().setPopoverVisibility(false);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Moves focus to the next/previous list item in the list view. If you are at the top
|
|
169
|
-
* of the list view, it moves focus back to the input.
|
|
170
|
-
*
|
|
171
|
-
* @param direction
|
|
172
|
-
*/
|
|
173
|
-
focusOnNextListItem(direction) {
|
|
174
|
-
const listItems = Array.from(document.querySelectorAll('a.searchcraft-popover-list-item')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
|
|
175
|
-
const currentIndex = listItems.indexOf(document.activeElement);
|
|
176
|
-
if (direction === 'ArrowDown') {
|
|
177
|
-
listItems[(currentIndex + 1) % listItems.length]?.focus();
|
|
178
|
-
}
|
|
179
|
-
else if (direction === 'ArrowUp') {
|
|
180
|
-
if (currentIndex >= 1) {
|
|
181
|
-
listItems[currentIndex - 1]?.focus();
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
const input = document.querySelector('.searchcraft-input');
|
|
185
|
-
if (input) {
|
|
186
|
-
input.focus();
|
|
187
|
-
requestAnimationFrame(() => {
|
|
188
|
-
input.selectionEnd = input.value.length;
|
|
189
|
-
input.selectionStart = input.value.length;
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
get hasResultsToShow() {
|
|
196
|
-
return (this.searchTerm &&
|
|
197
|
-
this.searchTerm?.trim()?.length > 0 &&
|
|
198
|
-
this.searchClientResponseItems.length > 0);
|
|
199
|
-
}
|
|
200
|
-
renderInlinePopover() {
|
|
201
|
-
const isListViewVisible = this.hasResultsToShow && this.isFocused;
|
|
202
|
-
const popoverFormClassNames = index$1.classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
|
|
203
|
-
'searchcraft-popover-form-active': isListViewVisible,
|
|
204
|
-
});
|
|
205
|
-
return (index.h("div", { class: popoverFormClassNames }, index.h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this) }), isListViewVisible && (index.h("div", { class: 'searchcraft-popover-inline-wrapper-outer' }, index.h("div", { class: 'searchcraft-popover-inline-wrapper-inner' }, index.h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
|
|
206
|
-
}
|
|
207
|
-
renderModalPopover() {
|
|
208
|
-
if (this.isPopoverVisibleInState) {
|
|
209
|
-
const popoverFormClassNames = index$1.classNames('searchcraft-popover-form', {
|
|
210
|
-
'searchcraft-popover-form-active': this.hasResultsToShow,
|
|
211
|
-
});
|
|
212
|
-
return (index.h("div", { class: 'searchcraft-popover-form-modal' }, index.h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), index.h("div", { class: 'searchcraft-popover-form-modal-inner' }, index.h("div", { class: popoverFormClassNames }, index.h("div", { class: 'searchcraft-popover-form-input-wrapper' }, index.h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), index.h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (index.h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
renderFullscreenPopover() {
|
|
216
|
-
if (this.isPopoverVisibleInState) {
|
|
217
|
-
return (index.h("div", { class: 'searchcraft-popover-form-fullscreen' }, index.h("div", { class: 'searchcraft-popover-form' }, index.h("div", { class: 'searchcraft-popover-form-input-wrapper' }, index.h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), index.h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (index.h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage })))));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
render() {
|
|
221
|
-
switch (this.type) {
|
|
222
|
-
case 'inline':
|
|
223
|
-
return this.renderInlinePopover();
|
|
224
|
-
case 'modal':
|
|
225
|
-
return this.renderModalPopover();
|
|
226
|
-
case 'fullscreen':
|
|
227
|
-
return this.renderFullscreenPopover();
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
exports.searchcraft_popover_form = SearchcraftPopoverForm;
|
|
233
|
-
|
|
234
|
-
//# sourceMappingURL=searchcraft-popover-form.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"searchcraft-popover-form.entry.cjs.js","mappings":";;;;;;;;MA6Ca,sBAAsB;;;;;;;IAIzB,MAAM,CAAgC;;;;;;;;IAQtC,IAAI,GAAsC,QAAQ,CAAC;;;;IAInD,qBAAqB,CAAoC;;;;IAIzD,MAAM,GAAG,GAAG,CAAC;;;;IAIb,cAAc,GAAuC,MAAM,CAAC;IAE3D,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,CAA2B;IACtC,yBAAyB,GAA+B,EAAE,CAAC;IAC3D,qBAAqB,GAA2B,EAAE,CAAC;IACnD,UAAU,CAAqB;IAC/B,SAAS,GAAG,KAAK,CAAC;IAClB,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ACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,wCAAwC,EAC9C,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,aAGzC,CACL,EACL,IAAI,CAAC,gBAAgB,KACpBA,2CACE,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EACzD,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,GAC/C,CACH,CACG,CACF,EACN;SACH;KACF;IAED,MAAM;QACJ,QAAQ,IAAI,CAAC,IAAI;YACf,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;SACzC;KACF;;;;;","names":["useSearchcraftStore","classNames","h"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type {\n SearchcraftConfig,\n SearchClientResponseItem,\n AdClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field, or when a popover-button is pressed.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"fullscreen\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.config = {\n * index: [index_name_from_vektron],\n * readKey: 'read_key_from_vektron',\n * endpointUrl: 'enpoint_url_from_vektron',\n * };\n *\n * popoverForm.popoverResultMappings = {\n * containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * The type of popover form to render.\n *\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchClientResponseItems: SearchClientResponseItem[] = [];\n @State() adClientResponseItems: AdClientResponseItem[] = [];\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState =\n useSearchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchClientResponseItems = [...state.searchClientResponseItems];\n this.adClientResponseItems = [...state.adClientResponseItems];\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n useSearchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport &&\n window.visualViewport.width < this.breakpointSm\n ) {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.config = this.config;\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n useSearchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n 'a.searchcraft-popover-list-item',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm &&\n this.searchTerm?.trim()?.length > 0 &&\n this.searchClientResponseItems.length > 0\n );\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n const popoverFormClassNames = classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n );\n\n return (\n <div class={popoverFormClassNames}>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n {isListViewVisible && (\n <div class='searchcraft-popover-inline-wrapper-outer'>\n <div class='searchcraft-popover-inline-wrapper-inner'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n const popoverFormClassNames = classNames('searchcraft-popover-form', {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n });\n\n return (\n <div class='searchcraft-popover-form-modal'>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-inner'>\n <div class={popoverFormClassNames}>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div class='searchcraft-popover-form-fullscreen'>\n <div class='searchcraft-popover-form'>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n );\n }\n }\n\n render() {\n switch (this.type) {\n case 'inline':\n return this.renderInlinePopover();\n case 'modal':\n return this.renderModalPopover();\n case 'fullscreen':\n return this.renderFullscreenPopover();\n }\n }\n}\n"],"version":3}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
7
|
-
const units = require('./units-fe4d8083.js');
|
|
8
|
-
|
|
9
|
-
const SearchcraftPopoverListItem = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
}
|
|
13
|
-
item;
|
|
14
|
-
popoverResultMappings;
|
|
15
|
-
/** The document position relative to the search results (For Measure) */
|
|
16
|
-
documentPosition = 0;
|
|
17
|
-
href;
|
|
18
|
-
imageSrc;
|
|
19
|
-
imageAlt;
|
|
20
|
-
titleContent;
|
|
21
|
-
subtitleContent;
|
|
22
|
-
mapValuesFromDocument(document) {
|
|
23
|
-
this.titleContent = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.title);
|
|
24
|
-
this.subtitleContent = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.subtitle);
|
|
25
|
-
this.href = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.href);
|
|
26
|
-
this.imageSrc = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageSource);
|
|
27
|
-
this.imageAlt = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageAlt);
|
|
28
|
-
}
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
if (this.item) {
|
|
31
|
-
this.mapValuesFromDocument(this.item.document);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
disconnectedCallback() { }
|
|
35
|
-
handleLinkClick = () => {
|
|
36
|
-
const state = SearchcraftStore.useSearchcraftStore.getState();
|
|
37
|
-
const searchcraft = state.getSearchcraftInstance();
|
|
38
|
-
if (searchcraft) {
|
|
39
|
-
const document_position = this.documentPosition;
|
|
40
|
-
const search_term = state.searchTerm;
|
|
41
|
-
const number_of_documents = state.searchClientResponseItems.length || 0;
|
|
42
|
-
searchcraft.measureClient?.sendMeasureEvent('document_clicked', {
|
|
43
|
-
document_position,
|
|
44
|
-
number_of_documents,
|
|
45
|
-
search_term,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
render() {
|
|
50
|
-
return (index.h("a", { key: '77e0a59f0441c7ed717ffc0de7f335e76b7b5f5e', class: 'searchcraft-popover-list-item', href: this.href, onClick: this.handleLinkClick.bind(this) }, this.imageSrc && (index.h("div", { key: '70fe7167cd9baa5029b1482ac6e71bd46c3171a7', class: 'searchcraft-popover-list-item-image-wrapper' }, index.h("img", { key: '768f651b06005ecefb9818268664334c6bf0d333', alt: this.imageAlt, src: this.imageSrc, class: 'searchcraft-popover-list-item-image' }))), index.h("div", { key: 'a34b31b92d232193e9d43c5871ecad0d4ee3f59a', class: 'searchcraft-popover-list-item-info-wrapper' }, index.h("p", { key: 'f2bd9dab4008d200b4528fde35950be90503d66c', class: 'searchcraft-popover-list-item-title' }, this.titleContent), index.h("p", { key: '4231966d7c4c48dfaaf4925ad18db3428219edad', class: 'searchcraft-popover-list-item-subtitle' }, this.subtitleContent))));
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const SearchcraftPopoverListItemAd = class {
|
|
55
|
-
constructor(hostRef) {
|
|
56
|
-
index.registerInstance(this, hostRef);
|
|
57
|
-
}
|
|
58
|
-
adClientResponseItem;
|
|
59
|
-
connectedCallback() {
|
|
60
|
-
if (this.adClientResponseItem?.admAd?.impression_url) {
|
|
61
|
-
fetch(this.adClientResponseItem?.admAd?.impression_url);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
renderADMProductAd() {
|
|
65
|
-
const ad = this.adClientResponseItem?.admAd;
|
|
66
|
-
if (!ad) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
return (index.h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (index.h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, index.h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), index.h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, index.h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term), index.h("p", { class: 'searchcraft-popover-list-item-ad-subtitle' }, ad.price))));
|
|
70
|
-
}
|
|
71
|
-
renderADMTextAd() {
|
|
72
|
-
const ad = this.adClientResponseItem?.admAd;
|
|
73
|
-
if (!ad) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
return (index.h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (index.h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, index.h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), index.h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, index.h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term))));
|
|
77
|
-
}
|
|
78
|
-
renderNativoAd() { }
|
|
79
|
-
renderAdPlaceholder() {
|
|
80
|
-
return index.h("p", null, "Ad placeholder");
|
|
81
|
-
// return;
|
|
82
|
-
}
|
|
83
|
-
render() {
|
|
84
|
-
if (!this.adClientResponseItem) {
|
|
85
|
-
return this.renderAdPlaceholder();
|
|
86
|
-
}
|
|
87
|
-
switch (this.adClientResponseItem.type) {
|
|
88
|
-
case 'adm-product-ad':
|
|
89
|
-
return this.renderADMProductAd();
|
|
90
|
-
case 'adm-text-ad':
|
|
91
|
-
return this.renderADMTextAd();
|
|
92
|
-
case 'nativo-ad':
|
|
93
|
-
return this.renderNativoAd();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
exports.searchcraft_popover_list_item = SearchcraftPopoverListItem;
|
|
99
|
-
exports.searchcraft_popover_list_item_ad = SearchcraftPopoverListItemAd;
|
|
100
|
-
|
|
101
|
-
//# sourceMappingURL=searchcraft-popover-list-item_2.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"searchcraft-popover-list-item.searchcraft-popover-list-item-ad.entry.cjs.js","mappings":";;;;;;;;MAgBa,0BAA0B;;;;IAC7B,IAAI,CAAuC;IAC3C,qBAAqB,CAAoC;;IAEzD,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,GAAGA,6CAAuC,CACzD,QAAQ,EAC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zD,IAAI,CAAC,EAAE,EAAE;YACP,OAAO;SACR;QAED,QACEA,eAAG,KAAK,EAAC,kCAAkC,EAAC,IAAI,EAAE,EAAE,CAAC,SAAS,IAC3D,EAAE,CAAC,SAAS,KACXA,iBAAK,KAAK,EAAC,gDAAgD,IACzDA,iBACE,GAAG,EAAE,EAAE,CAAC,IAAI,EACZ,GAAG,EAAE,EAAE,CAAC,SAAS,EACjB,KAAK,EAAC,wCAAwC,GAC9C,CACE,CACP,EACDA,iBAAK,KAAK,EAAC,+CAA+C,IACxDA,eAAG,KAAK,EAAC,wCAAwC,IAAE,EAAE,CAAC,IAAI,CAAK,CAC3D,CACJ,EACJ;KACH;IAED,cAAc,MAAK;IAEnB,mBAAmB;QACjB,OAAOA,oCAAqB,CAAC;;KAE9B;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;SACnC;QAED,QAAQ,IAAI,CAAC,oBAAoB,CAAC,IAAI;YACpC,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;SAChC;KACF;;;;;;","names":["getDocumentValueFromSearchResultMapping","useSearchcraftStore","h"],"sources":["src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx","src/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.tsx"],"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","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"],"version":3}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const index$1 = require('./index-5b0b9d4c.js');
|
|
7
|
-
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
8
|
-
const units = require('./units-fe4d8083.js');
|
|
9
|
-
const styles = require('./styles-7b2d06f2.js');
|
|
10
|
-
|
|
11
|
-
const SearchcraftResultsInfo = class {
|
|
12
|
-
constructor(hostRef) {
|
|
13
|
-
index.registerInstance(this, hostRef);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The custom formatter for the resulting string.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* resultsInfo.customFormatter = (range, count, responseTime) =>
|
|
21
|
-
* `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
customFormatter;
|
|
25
|
-
/**
|
|
26
|
-
* The custom styles object.
|
|
27
|
-
*/
|
|
28
|
-
customStyles;
|
|
29
|
-
// store vars
|
|
30
|
-
searchTerm;
|
|
31
|
-
searchResultsPage;
|
|
32
|
-
searchResultsPerPage;
|
|
33
|
-
searchResultsCount;
|
|
34
|
-
// local vars
|
|
35
|
-
count = 0;
|
|
36
|
-
range = [0, 0];
|
|
37
|
-
responseTime = '0';
|
|
38
|
-
unsubscribe = () => { };
|
|
39
|
-
connectedCallback() {
|
|
40
|
-
this.unsubscribe = SearchcraftStore.useSearchcraftStore.subscribe((state) => {
|
|
41
|
-
// store vars
|
|
42
|
-
this.searchTerm = state.searchTerm;
|
|
43
|
-
this.searchResultsPage = state.searchResultsPage;
|
|
44
|
-
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
45
|
-
this.searchResultsCount = state.searchResultsCount;
|
|
46
|
-
// local vars
|
|
47
|
-
this.count = this.searchResultsCount;
|
|
48
|
-
this.range[0] =
|
|
49
|
-
this.searchResultsPage <= 1
|
|
50
|
-
? 1
|
|
51
|
-
: this.searchResultsPerPage * (this.searchResultsPage - 1);
|
|
52
|
-
this.range[1] = this.searchResultsPerPage * this.searchResultsPage;
|
|
53
|
-
this.range[1] =
|
|
54
|
-
this.range[1] > this.searchResultsCount
|
|
55
|
-
? this.searchResultsCount
|
|
56
|
-
: this.range[1];
|
|
57
|
-
this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(2);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
disconnectedCallback() {
|
|
61
|
-
if (this.unsubscribe) {
|
|
62
|
-
this.unsubscribe();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
render() {
|
|
66
|
-
if (!this.searchTerm || this.searchResultsCount === 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return (index.h("p", { class: index$1.classNames('searchcraft-results-info', styles.parseCustomStyles(this.customStyles || {})) }, this.customFormatter
|
|
70
|
-
? this.customFormatter([
|
|
71
|
-
units.formatNumberWithCommas(this.range[0]),
|
|
72
|
-
units.formatNumberWithCommas(this.range[1]),
|
|
73
|
-
], units.formatNumberWithCommas(this.count), this.responseTime)
|
|
74
|
-
: `${this.count} results found in ${this.responseTime}ms`));
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.searchcraft_results_info = SearchcraftResultsInfo;
|
|
79
|
-
|
|
80
|
-
//# sourceMappingURL=searchcraft-results-info.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"searchcraft-results-info.entry.cjs.js","mappings":";;;;;;;;;;MA0Ba,sBAAsB;;;;;;;;;;;;;IAUzB,eAAe,CAIb;;;;IAIF,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oB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W,EAAE,CAAC;SACpB;KACF;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,kBAAkB,KAAK,CAAC,EAAE;YACrD,OAAO,IAAI,CAAC;SACb;QAED,QACEC,eACE,KAAK,EAAEC,kBAAU,CACf,0BAA0B,EAC1BC,wBAAiB,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAC3C,IAEA,IAAI,CAAC,eAAe;cACjB,IAAI,CAAC,eAAe,CAClB;gBACEC,4BAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrCA,4BAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtC,EACDA,4BAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAClC,IAAI,CAAC,YAAY,CAClB;cACD,GAAG,IAAI,CAAC,KAAK,qBAAqB,IAAI,CAAC,YAAY,IAAI,CACzD,EACJ;KACH;;;;;","names":["useSearchcraftStore","h","classNames","parseCustomStyles","formatNumberWithCommas"],"sources":["src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"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"],"version":3}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
7
|
-
const index$1 = require('./index-5b0b9d4c.js');
|
|
8
|
-
const styles = require('./styles-7b2d06f2.js');
|
|
9
|
-
|
|
10
|
-
const SearchcraftSearchResultsPerPage = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).
|
|
16
|
-
* The base value is defined by the `searchResultsPerPage` option in the configuration.
|
|
17
|
-
*/
|
|
18
|
-
increment = 20;
|
|
19
|
-
/**
|
|
20
|
-
* The custom styles object.
|
|
21
|
-
*/
|
|
22
|
-
customStyles;
|
|
23
|
-
// store vars
|
|
24
|
-
searchTerm;
|
|
25
|
-
searchResultsPage;
|
|
26
|
-
searchResultsPerPage;
|
|
27
|
-
searchResultsCount;
|
|
28
|
-
searchResultsPagesCount;
|
|
29
|
-
// local vars
|
|
30
|
-
initialSearchResultsPerPage;
|
|
31
|
-
// store functions
|
|
32
|
-
setSearchResultsPerPage = () => { };
|
|
33
|
-
setSearchResultsPage = () => { };
|
|
34
|
-
unsubscribe = () => { };
|
|
35
|
-
componentDidLoad() {
|
|
36
|
-
this.unsubscribe = SearchcraftStore.useSearchcraftStore.subscribe((state) => {
|
|
37
|
-
// store vars
|
|
38
|
-
this.searchTerm = state.searchTerm;
|
|
39
|
-
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
40
|
-
this.searchResultsPage = state.searchResultsPage;
|
|
41
|
-
this.searchResultsCount = state.searchResultsCount;
|
|
42
|
-
// local vars
|
|
43
|
-
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
44
|
-
// store functions
|
|
45
|
-
this.setSearchResultsPage = state.setSearchResultsPage;
|
|
46
|
-
this.setSearchResultsPerPage = state.setSearchResultsPerPage;
|
|
47
|
-
});
|
|
48
|
-
this.initialSearchResultsPerPage =
|
|
49
|
-
SearchcraftStore.useSearchcraftStore.getState().searchResultsPerPage;
|
|
50
|
-
}
|
|
51
|
-
disconnectedCallback() {
|
|
52
|
-
this.unsubscribe?.();
|
|
53
|
-
}
|
|
54
|
-
render() {
|
|
55
|
-
// early return if there isn't a searchTerm or there is 1 or fewer pages of results
|
|
56
|
-
if (!this.searchTerm || this.searchResultsPagesCount <= 1) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
return (index.h("div", { class: index$1.classNames('searchcraft-search-results-per-page', styles.parseCustomStyles(this.customStyles || {})) }, index.h("div", { class: 'searchcraft-search-results-per-page-select' }, index.h("label", { class: 'searchcraft-search-results-per-page-select-label', htmlFor: 'searchcraft-search-results-per-page-select-input' }, "Results Per Page"), index.h("div", { class: 'searchcraft-search-results-per-page-select-input' }, index.h("searchcraft-select", { inputId: 'searchcraft-search-results-per-page-select-input', name: 'results-per-page', options: [...Array(5)].map((_, index) => {
|
|
60
|
-
const value = this.initialSearchResultsPerPage +
|
|
61
|
-
Number(this.increment) * index;
|
|
62
|
-
return {
|
|
63
|
-
label: `${value}`,
|
|
64
|
-
value,
|
|
65
|
-
};
|
|
66
|
-
}), onSelectChange: (event) => {
|
|
67
|
-
this.setSearchResultsPerPage(Number(event.detail));
|
|
68
|
-
this.setSearchResultsPage(1);
|
|
69
|
-
} })))));
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
exports.searchcraft_search_results_per_page = SearchcraftSearchResultsPerPage;
|
|
74
|
-
|
|
75
|
-
//# sourceMappingURL=searchcraft-search-results-per-page.cjs.entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"file":"searchcraft-search-results-per-page.entry.cjs.js","mappings":";;;;;;;;;MAmBa,+BAA+B;;;;;;;;IAKlC,SAAS,GAAoB,EAAE,CAAC;;;;IAIhC,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;IACnB,uBAAuB,CAAC;;IAGxB,2BAA2B,C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,IAAI,EAAC,kBAAkB,EACvB,OAAO,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK;gBAClC,MAAM,KAAK,GACT,IAAI,CAAC,2BAA2B;oBAChC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;gBACjC,OAAO;oBACL,KAAK,EAAE,GAAG,KAAK,EAAE;oBACjB,KAAK;iBACN,CAAC;aACH,CAAC,EACF,cAAc,EAAE,CAAC,KAAK;gBACpB,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBACnD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;aAC9B,GACD,CACE,CACF,CACF,EACN;KACH;;;;;","names":["useSearchcraftStore","h","classNames","parseCustomStyles"],"sources":["src/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.tsx"],"sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport { Component, h, State, Prop } from '@stencil/core';\nimport classNames from 'classnames';\n\nimport { parseCustomStyles } from '@utils';\n\n/**\n * This web component is designed to choose the number of search results displayed.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-search-results-per-page increment=\"20\" />\n * ```\n */\n@Component({\n tag: 'searchcraft-search-results-per-page',\n shadow: false,\n})\nexport class SearchcraftSearchResultsPerPage {\n /**\n * The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).\n * The base value is defined by the `searchResultsPerPage` option in the configuration.\n */\n @Prop() increment: string | number = 20;\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 @State() searchResultsPagesCount;\n\n // local vars\n @State() initialSearchResultsPerPage;\n\n // store functions\n @State() setSearchResultsPerPage: (perPage: number) => void = () => {};\n @State() setSearchResultsPage: (page: number) => void = () => {};\n\n private unsubscribe: () => void = () => {};\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.searchResultsPagesCount = Math.ceil(\n this.searchResultsCount / this.searchResultsPerPage,\n );\n\n // store functions\n this.setSearchResultsPage = state.setSearchResultsPage;\n this.setSearchResultsPerPage = state.setSearchResultsPerPage;\n });\n\n this.initialSearchResultsPerPage =\n useSearchcraftStore.getState().searchResultsPerPage;\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n render() {\n // early return if there isn't a searchTerm or there is 1 or fewer pages of results\n if (!this.searchTerm || this.searchResultsPagesCount <= 1) {\n return;\n }\n\n return (\n <div\n class={classNames(\n 'searchcraft-search-results-per-page',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n <div class='searchcraft-search-results-per-page-select'>\n <label\n class='searchcraft-search-results-per-page-select-label'\n htmlFor='searchcraft-search-results-per-page-select-input'\n >\n Results Per Page\n </label>\n <div class='searchcraft-search-results-per-page-select-input'>\n <searchcraft-select\n inputId='searchcraft-search-results-per-page-select-input'\n name='results-per-page'\n options={[...Array(5)].map((_, index) => {\n const value =\n this.initialSearchResultsPerPage +\n Number(this.increment) * index;\n return {\n label: `${value}`,\n value,\n };\n })}\n onSelectChange={(event) => {\n this.setSearchResultsPerPage(Number(event.detail));\n this.setSearchResultsPage(1);\n }}\n />\n </div>\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|