@searchcraft/javascript-sdk 0.7.2 → 0.8.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/dist/cjs/{store-f6ba3dfb.js → SearchcraftStore-75fac5e0.js} +576 -443
- package/dist/cjs/SearchcraftStore-75fac5e0.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -3
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js +152 -0
- package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +30 -80
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-button_3.cjs.entry.js +22 -7
- package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +19 -18
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +6 -6
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +20 -33
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +1 -1
- package/dist/cjs/searchcraft-pagination.cjs.entry.js +106 -0
- package/dist/cjs/searchcraft-pagination.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js +3 -3
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js +27 -25
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js +101 -0
- package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-results-info.cjs.entry.js +51 -13
- package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js +75 -0
- package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-select.cjs.entry.js +70 -0
- package/dist/cjs/searchcraft-select.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-theme.cjs.entry.js +29 -11
- package/dist/cjs/searchcraft-theme.cjs.entry.js.map +1 -1
- package/dist/cjs/units-fe4d8083.js.map +1 -1
- package/dist/collection/collection-manifest.json +5 -0
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +86 -208
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js +73 -0
- package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js.map +1 -0
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +37 -144
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
- package/dist/collection/components/searchcraft-button/searchcraft-button.js +87 -17
- package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +1 -1
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +1 -1
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +8 -8
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +1 -1
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +7 -7
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +1 -1
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +10 -14
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +1 -1
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +1 -1
- package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js +141 -0
- package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js.map +1 -0
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +1 -1
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +26 -21
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +59 -92
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js +73 -0
- package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js.map +1 -0
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +77 -24
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js.map +1 -1
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +105 -17
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -1
- package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js +129 -0
- package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js.map +1 -0
- package/dist/collection/components/searchcraft-select/searchcraft-select.js +261 -0
- package/dist/collection/components/searchcraft-select/searchcraft-select.js.map +1 -0
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +2 -2
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +72 -12
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +1 -1
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +7 -6
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
- package/dist/collection/index.js +1 -2
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/provider/SearchcraftStore.js +160 -0
- package/dist/collection/provider/SearchcraftStore.js.map +1 -0
- package/dist/collection/provider/SearchcraftStore.types.js +2 -0
- package/dist/collection/provider/SearchcraftStore.types.js.map +1 -0
- package/dist/collection/provider/store.js +2 -136
- package/dist/collection/provider/store.js.map +1 -1
- package/dist/collection/utils/units.js.map +1 -1
- package/dist/components/index.js +11 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-a75ef832.js → p-0e393fe1.js} +2 -2
- package/dist/components/{p-a75ef832.js.map → p-0e393fe1.js.map} +1 -1
- package/dist/components/p-25ee7496.js +58 -0
- package/dist/components/p-25ee7496.js.map +1 -0
- package/dist/components/{p-936e2ed4.js → p-38419178.js} +576 -442
- package/dist/components/p-38419178.js.map +1 -0
- package/dist/components/{p-960ddc89.js → p-3df3ff8b.js} +17 -21
- package/dist/components/p-3df3ff8b.js.map +1 -0
- package/dist/components/{p-1234974c.js → p-433f974c.js} +9 -8
- package/dist/components/p-433f974c.js.map +1 -0
- package/dist/components/{p-4b92ae26.js → p-4e9cd62e.js} +4 -4
- package/dist/components/{p-4b92ae26.js.map → p-4e9cd62e.js.map} +1 -1
- package/dist/components/{p-755f491b.js → p-6104fe5d.js} +2 -2
- package/dist/components/p-6104fe5d.js.map +1 -0
- package/dist/components/{p-b4a8fcbe.js → p-97332d3e.js} +51 -59
- package/dist/components/p-97332d3e.js.map +1 -0
- package/dist/components/p-bf6a086a.js +92 -0
- package/dist/components/p-bf6a086a.js.map +1 -0
- package/dist/components/p-bff4d3fc.js +65 -0
- package/dist/components/p-bff4d3fc.js.map +1 -0
- package/dist/components/{p-521fe971.js → p-d19bf6ff.js} +25 -8
- package/dist/components/p-d19bf6ff.js.map +1 -0
- package/dist/components/p-de4a48b1.js +65 -0
- package/dist/components/p-de4a48b1.js.map +1 -0
- package/dist/components/{p-ca881e5c.js → p-e55a7970.js} +2 -2
- package/dist/components/{p-ca881e5c.js.map → p-e55a7970.js.map} +1 -1
- package/dist/components/p-ec0d230e.js +75 -0
- package/dist/components/p-ec0d230e.js.map +1 -0
- package/dist/components/{p-54998882.js → p-fc7cda96.js} +10 -10
- package/dist/components/p-fc7cda96.js.map +1 -0
- package/dist/components/searchcraft-base-search-result-ad.d.ts +11 -0
- package/dist/components/searchcraft-base-search-result-ad.js +8 -0
- package/dist/components/searchcraft-base-search-result-ad.js.map +1 -0
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +44 -89
- package/dist/components/searchcraft-base-search-results.js.map +1 -1
- package/dist/components/searchcraft-button.js +1 -1
- package/dist/components/searchcraft-error-message.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +9 -9
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-input-label.js +1 -1
- package/dist/components/searchcraft-pagination.d.ts +11 -0
- package/dist/components/searchcraft-pagination.js +135 -0
- package/dist/components/searchcraft-pagination.js.map +1 -0
- package/dist/components/searchcraft-popover-button.js +2 -2
- package/dist/components/searchcraft-popover-form.js +41 -30
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item-ad.d.ts +11 -0
- package/dist/components/searchcraft-popover-list-item-ad.js +8 -0
- package/dist/components/searchcraft-popover-list-item-ad.js.map +1 -0
- 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 +60 -17
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-results-per-page.d.ts +11 -0
- package/dist/components/searchcraft-search-results-per-page.js +105 -0
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -0
- package/dist/components/searchcraft-select.d.ts +11 -0
- package/dist/components/searchcraft-select.js +8 -0
- package/dist/components/searchcraft-select.js.map +1 -0
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.js +34 -13
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/esm/{store-aa071d9c.js → SearchcraftStore-3cfd565a.js} +576 -442
- package/dist/esm/SearchcraftStore-3cfd565a.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/searchcraft-base-search-result_2.entry.js +147 -0
- package/dist/esm/searchcraft-base-search-result_2.entry.js.map +1 -0
- package/dist/esm/searchcraft-base-search-results.entry.js +30 -80
- package/dist/esm/searchcraft-base-search-results.entry.js.map +1 -1
- package/dist/esm/searchcraft-button_3.entry.js +22 -7
- package/dist/esm/searchcraft-button_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-facet-list_3.entry.js +17 -16
- package/dist/esm/searchcraft-facet-list_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-filter-panel.entry.js +5 -5
- package/dist/esm/searchcraft-filter-panel.entry.js.map +1 -1
- package/dist/esm/searchcraft-input-form_2.entry.js +19 -32
- package/dist/esm/searchcraft-input-form_2.entry.js.map +1 -1
- package/dist/esm/searchcraft-javascript-sdk.js +1 -1
- package/dist/esm/searchcraft-pagination.entry.js +102 -0
- package/dist/esm/searchcraft-pagination.entry.js.map +1 -0
- package/dist/esm/searchcraft-popover-button.entry.js +2 -2
- package/dist/esm/searchcraft-popover-form.entry.js +20 -18
- package/dist/esm/searchcraft-popover-form.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-list-item_2.entry.js +96 -0
- package/dist/esm/searchcraft-popover-list-item_2.entry.js.map +1 -0
- package/dist/esm/searchcraft-results-info.entry.js +51 -13
- package/dist/esm/searchcraft-results-info.entry.js.map +1 -1
- package/dist/esm/searchcraft-search-results-per-page.entry.js +71 -0
- package/dist/esm/searchcraft-search-results-per-page.entry.js.map +1 -0
- package/dist/esm/searchcraft-select.entry.js +66 -0
- package/dist/esm/searchcraft-select.entry.js.map +1 -0
- package/dist/esm/searchcraft-theme.entry.js +29 -11
- package/dist/esm/searchcraft-theme.entry.js.map +1 -1
- package/dist/esm/{units-b6eba560.js → units-daaf96f5.js} +2 -2
- package/dist/esm/units-daaf96f5.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-38419178.js +11 -0
- package/dist/searchcraft-javascript-sdk/p-38419178.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/{p-755f491b.js → p-6104fe5d.js} +2 -2
- package/dist/searchcraft-javascript-sdk/p-6104fe5d.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-69da4e58.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-69da4e58.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-7f4dd50c.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-a3074a6d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-a3074a6d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-d2fffca9.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-d2fffca9.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
- package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +20 -41
- package/dist/types/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.d.ts +14 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +9 -18
- package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +17 -6
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +1 -1
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +2 -2
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +1 -1
- package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +33 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +9 -7
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +9 -12
- package/dist/types/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.d.ts +14 -0
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +7 -4
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +26 -4
- package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +33 -0
- package/dist/types/components/searchcraft-select/searchcraft-select.d.ts +64 -0
- package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +11 -2
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +1 -1
- package/dist/types/components.d.ts +444 -170
- package/dist/types/index.d.ts +1 -2
- package/dist/types/provider/SearchcraftStore.d.ts +4 -0
- package/dist/types/provider/SearchcraftStore.types.d.ts +44 -0
- package/dist/types/provider/store.d.ts +2 -34
- package/dist/types/utils/units.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js +0 -117
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js +0 -49
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js.map +0 -1
- package/dist/cjs/store-f6ba3dfb.js.map +0 -1
- package/dist/collection/types/_shared.types.js +0 -2
- package/dist/collection/types/_shared.types.js.map +0 -1
- package/dist/collection/types/index.js +0 -5
- package/dist/collection/types/index.js.map +0 -1
- package/dist/collection/types/searchcraft-base-search-results.types.js +0 -2
- package/dist/collection/types/searchcraft-base-search-results.types.js.map +0 -1
- package/dist/collection/types/searchcraft-filter-panel.types.js +0 -2
- package/dist/collection/types/searchcraft-filter-panel.types.js.map +0 -1
- package/dist/collection/types/searchcraft-popover-form.types.js +0 -2
- package/dist/collection/types/searchcraft-popover-form.types.js.map +0 -1
- package/dist/components/p-0ef4ab33.js +0 -66
- package/dist/components/p-0ef4ab33.js.map +0 -1
- package/dist/components/p-1234974c.js.map +0 -1
- package/dist/components/p-506cdac1.js +0 -58
- package/dist/components/p-506cdac1.js.map +0 -1
- package/dist/components/p-521fe971.js.map +0 -1
- package/dist/components/p-54998882.js.map +0 -1
- package/dist/components/p-755f491b.js.map +0 -1
- package/dist/components/p-936e2ed4.js.map +0 -1
- package/dist/components/p-960ddc89.js.map +0 -1
- package/dist/components/p-b4a8fcbe.js.map +0 -1
- package/dist/esm/searchcraft-base-search-result.entry.js +0 -113
- package/dist/esm/searchcraft-base-search-result.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-list-item.entry.js +0 -45
- package/dist/esm/searchcraft-popover-list-item.entry.js.map +0 -1
- package/dist/esm/store-aa071d9c.js.map +0 -1
- package/dist/esm/units-b6eba560.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-109ab0e0.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-109ab0e0.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-755f491b.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-936e2ed4.js +0 -11
- package/dist/searchcraft-javascript-sdk/p-936e2ed4.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js +0 -2
- package/dist/types/types/_shared.types.d.ts +0 -46
- package/dist/types/types/index.d.ts +0 -5
- package/dist/types/types/searchcraft-base-search-results.types.d.ts +0 -11
- package/dist/types/types/searchcraft-filter-panel.types.d.ts +0 -43
- package/dist/types/types/searchcraft-popover-form.types.d.ts +0 -9
- /package/dist/searchcraft-javascript-sdk/{p-faaa4394.entry.js.map → p-7f4dd50c.entry.js.map} +0 -0
- /package/dist/types/{types → themes}/raw.d.ts +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const
|
|
6
|
+
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
7
7
|
const units = require('./units-fe4d8083.js');
|
|
8
8
|
|
|
9
9
|
const SearchcraftFilterPanel = class {
|
|
@@ -15,11 +15,11 @@ const SearchcraftFilterPanel = class {
|
|
|
15
15
|
*/
|
|
16
16
|
items = [];
|
|
17
17
|
unsubscribe;
|
|
18
|
-
|
|
19
|
-
searchStore =
|
|
18
|
+
lastSearchTerm;
|
|
19
|
+
searchStore = SearchcraftStore.useSearchcraftStore.getState();
|
|
20
20
|
componentDidLoad() {
|
|
21
|
-
this.unsubscribe =
|
|
22
|
-
this.
|
|
21
|
+
this.unsubscribe = SearchcraftStore.useSearchcraftStore.subscribe((state) => {
|
|
22
|
+
this.lastSearchTerm = state.searchTerm || '';
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
disconnectedCallback() {
|
|
@@ -65,7 +65,7 @@ const SearchcraftFilterPanel = class {
|
|
|
65
65
|
* Iterate through `items` and render them based on `type`
|
|
66
66
|
*/
|
|
67
67
|
render() {
|
|
68
|
-
return (index.h("div", { key: '
|
|
68
|
+
return (index.h("div", { key: '7e3e39a09d392e6da9c387d8cd641a50171ddc59', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
|
|
69
69
|
switch (filterItem.type) {
|
|
70
70
|
case 'dateRange': {
|
|
71
71
|
const item = filterItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-filter-panel.entry.cjs.js","mappings":";;;;;;;;MAwBa,sBAAsB;;;;;;;IAIzB,KAAK,GAAiB,EAAE,CAAC;IAExB,WAAW,CAA2B;IACtC,SAAS,CAAqB;IAE/B,WAAW,GAAGA,yBAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAGA,yBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YAIrD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;SACpC,CAAC,CAAC;KACJ;IAED,oBAAoB;QAClB,IAAI,CAAC,WAAW,IAAI,CAAC;KACtB;IAED,sBAAsB,CAAC,SAAiB,EAAE,GAAW,EAAE,GAAW;QAChE,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC;YAC1C,SAAS;YACT,KAAK,EAAE,GAAG,SAAS,KAAK,KAAK,CAAC,WAAW,EAAE,OAAO,GAAG,CAAC,WAAW,EAAE,GAAG;SACvE,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KAC3B;IAED,yBAAyB,CAAC,SAAiB,EAAE,GAAW,EAAE,GAAW;QACnE,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC;YAC1C,SAAS;YACT,KAAK,EAAE,GAAG,SAAS,KAAK,GAAG,OAAO,GAAG,GAAG;SACzC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KAC3B;IAED,2BAA2B,CAAC,SAAiB,EAAE,KAAe;QAC5D,I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,kBAAkB,EAAE;oBACvB,MAAM,IAAI,GAAG,UAAwC,CAAC;oBACtD,QACEA,uCACE,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,eAAe,EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;gBACD,KAAK,kBAAkB,EAAE;oBACvB,MAAM,IAAI,GAAG,UAAwC,CAAC;oBACtD,QACEA,uCACE,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,eAAe,EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;","names":["useSearchcraftStore","h","getMillis"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\nimport type {\n FilterItem,\n DateRangeFilterItem,\n NumericFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n} from '../../types/searchcraft-filter-panel.types';\nimport { useSearchcraftStore } from '@provider/store';\nimport { getMillis } from '@utils';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() unsubscribe: (() => void) | undefined;\n @State() lastQuery: string | undefined;\n\n private searchStore = useSearchcraftStore.getState();\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.lastQuery !== state.query) {\n // A place to put actions to do when the query changes\n }\n this.lastQuery = state.query || '';\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleDateRangeChanged(fieldName: string, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.searchStore.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.searchStore.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.searchStore.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.searchStore.removeFacetPathsForIndexField(fieldName);\n }\n this.searchStore.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.searchStore.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.searchStore.search();\n }\n\n handleMostRecentToggleUpdated(isActive: boolean) {\n this.searchStore.setSortType(isActive ? 'desc' : 'asc');\n this.searchStore.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const min = new Date(item.options.minDate).getTime();\n const max = new Date(item.options.maxDate).getTime();\n const granularityValue = getMillis(item.options.granularity);\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={min}\n max={max}\n granularity={granularityValue}\n dataType='date'\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n granularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(event.detail);\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-filter-panel.entry.cjs.js","mappings":";;;;;;;;MAwBa,sBAAsB;;;;;;;IAIzB,KAAK,GAAiB,EAAE,CAAC;IAExB,WAAW,CAA2B;IACtC,cAAc,CAAqB;IAEpC,WAAW,GAAGA,oCAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAGA,oCAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YAIrD,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;SAC9C,CAAC,CAAC;KACJ;IAED,oBAAoB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AAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;","names":["useSearchcraftStore","h","getMillis"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\nimport type {\n FilterItem,\n DateRangeFilterItem,\n NumericFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n} from '@searchcraft/core';\nimport { useSearchcraftStore } from '@provider/store';\nimport { getMillis } from '@utils';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() unsubscribe: (() => void) | undefined;\n @State() lastSearchTerm: string | undefined;\n\n private searchStore = useSearchcraftStore.getState();\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.lastSearchTerm !== state.searchTerm) {\n // A place to put actions to do when the query changes\n }\n this.lastSearchTerm = state.searchTerm || '';\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleDateRangeChanged(fieldName: string, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.searchStore.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.searchStore.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.searchStore.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.searchStore.removeFacetPathsForIndexField(fieldName);\n }\n this.searchStore.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.searchStore.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.searchStore.search();\n }\n\n handleMostRecentToggleUpdated(isActive: boolean) {\n this.searchStore.setSortType(isActive ? 'desc' : 'asc');\n this.searchStore.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const min = new Date(item.options.minDate).getTime();\n const max = new Date(item.options.maxDate).getTime();\n const granularityValue = getMillis(item.options.granularity);\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={min}\n max={max}\n granularity={granularityValue}\n dataType='date'\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n granularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(event.detail);\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const
|
|
6
|
+
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
7
7
|
const styles = require('./styles-7b2d06f2.js');
|
|
8
8
|
const index$1 = require('./index-5b0b9d4c.js');
|
|
9
|
-
const units = require('./units-fe4d8083.js');
|
|
10
9
|
|
|
11
10
|
const name = "@searchcraft/javascript-sdk";
|
|
12
|
-
const version = "0.
|
|
11
|
+
const version = "0.8.0";
|
|
13
12
|
const description = "Searchcraft Javascript SDK";
|
|
14
13
|
const author = "Searchcraft";
|
|
15
14
|
const license = "Apache-2.0";
|
|
@@ -58,7 +57,7 @@ const dependencies = {
|
|
|
58
57
|
classnames: "^2.3.2"
|
|
59
58
|
};
|
|
60
59
|
const devDependencies = {
|
|
61
|
-
"@searchcraft/core": "^0.
|
|
60
|
+
"@searchcraft/core": "^0.8.0",
|
|
62
61
|
"@searchcraft/javascript-sdk": "*",
|
|
63
62
|
"@stencil/core": "^4.7.0",
|
|
64
63
|
"@stencil/react-output-target": "^0.8.2",
|
|
@@ -156,10 +155,10 @@ const SearchcraftInput = class {
|
|
|
156
155
|
inputValue = this.searchTerm;
|
|
157
156
|
error = false;
|
|
158
157
|
isSearchcraftInitialized = false;
|
|
159
|
-
searchStore =
|
|
158
|
+
searchStore = SearchcraftStore.useSearchcraftStore.getState();
|
|
160
159
|
init() {
|
|
161
160
|
if (this.config && !this.isSearchcraftInitialized) {
|
|
162
|
-
const searchcraft = new
|
|
161
|
+
const searchcraft = new SearchcraftStore.ge(this.config, {
|
|
163
162
|
sdkName: packageJson.name,
|
|
164
163
|
sdkVersion: packageJson.version,
|
|
165
164
|
});
|
|
@@ -177,25 +176,21 @@ const SearchcraftInput = class {
|
|
|
177
176
|
handleOnInput = (event) => {
|
|
178
177
|
const input = event.target;
|
|
179
178
|
this.inputValue = input.value;
|
|
180
|
-
if (input.value.trim() === '') {
|
|
181
|
-
this.inputCleared?.emit();
|
|
182
|
-
this.searchTerm = '';
|
|
183
|
-
this.searchStore.setQuery('');
|
|
184
|
-
this.searchStore.setSearchResults(null);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
179
|
if (!this.autoSearch) {
|
|
188
180
|
return;
|
|
189
181
|
}
|
|
182
|
+
if (input.value.trim() === '') {
|
|
183
|
+
this.inputCleared?.emit();
|
|
184
|
+
}
|
|
190
185
|
this.performSearch(input.value);
|
|
191
186
|
};
|
|
192
187
|
performSearch = async (value) => {
|
|
193
|
-
if (value ===
|
|
188
|
+
if (value === SearchcraftStore.useSearchcraftStore.getState().searchTerm) {
|
|
194
189
|
return;
|
|
195
190
|
}
|
|
196
191
|
this.searchTerm = value.trim();
|
|
197
192
|
this.error = false;
|
|
198
|
-
this.searchStore.
|
|
193
|
+
this.searchStore.setSearchTerm(this.searchTerm);
|
|
199
194
|
this.querySubmit?.emit(this.searchTerm);
|
|
200
195
|
try {
|
|
201
196
|
await this.searchStore.search();
|
|
@@ -208,8 +203,8 @@ const SearchcraftInput = class {
|
|
|
208
203
|
handleClearInput = () => {
|
|
209
204
|
this.inputValue = '';
|
|
210
205
|
this.searchTerm = '';
|
|
211
|
-
this.searchStore.
|
|
212
|
-
this.searchStore.
|
|
206
|
+
this.searchStore.setSearchTerm('');
|
|
207
|
+
this.searchStore.setSearchClientResponseItems([]);
|
|
213
208
|
this.error = false;
|
|
214
209
|
this.inputCleared?.emit();
|
|
215
210
|
};
|
|
@@ -229,9 +224,9 @@ const SearchcraftInput = class {
|
|
|
229
224
|
const inputGridStyles = {
|
|
230
225
|
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
231
226
|
};
|
|
232
|
-
return (index.h("form", { key: '
|
|
227
|
+
return (index.h("form", { key: 'bc665c50db8de601a3c95266bdf063ebb988d6a8', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, index.h("div", { key: 'a6936858c08d866b66b887c7ae03b35961cf04a1', class: inputGridClassNames, style: inputGridStyles }, index.h("div", { key: '915ac892fccb771f1c5338cd2d52f16f1793615d', class: 'searchcraft-input-button-wrapper' }, index.h("searchcraft-button", { key: '81447da28dcb9cb80a8cdf0c6765c909c2746585', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (index.h("div", { key: '939c3407d16075be25ff23bf9b379c05ba1a66d4', class: 'searchcraft-input-label-wrapper' }, index.h("searchcraft-input-label", { key: '9d9c4043c04132b27710cca47abf102a188a80b9', label: this.inputLabel }))), this.error && (index.h("div", { key: '7e309f8a5c81a41bdd593f4e4ee1ba30c531c97d', class: 'searchcraft-input-error-wrapper' }, index.h("searchcraft-error-message", { key: 'de947c04f0948e36786f50ac65720eeb598ae7bf', errorMessage: 'Something went wrong.' }))), index.h("div", { key: 'bcf774e3fa5164ab838b634badf2002495437fe7', class: 'searchcraft-input-wrapper' }, index.h("input", { key: 'fd9759559712a39d3493e069ddddf7c267879c84', autoComplete: 'off', class: 'searchcraft-input', onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
|
|
233
228
|
this.handleOnInput(event);
|
|
234
|
-
}, placeholder: this.placeholderValue, style: validatedCustomStyles, type: 'text', value: this.inputValue }), index.h("div", { key: '
|
|
229
|
+
}, placeholder: this.placeholderValue, style: validatedCustomStyles, type: 'text', value: this.inputValue }), index.h("div", { key: '8564b18962feeea8d9ab8bb46af4ba28a089d8f4', class: 'searchcraft-input-search-icon-wrapper' }, index.h("svg", { key: '90c3636ea306ed70887d76deaf058ab3ace61134', class: 'searchcraft-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, index.h("title", { key: 'c9921263b87df28e06bab9990e324aa1bebac767', id: 'searchcraft-title' }, "Searchcraft Search Icon Light"), index.h("path", { key: 'bb82073fd722ff4a74e1a86c74cdf0dd9a8080b4', d: 'M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (index.h("button", { key: 'e708cb9426171bfdfb29e0a98206d086fa14e15e', type: 'button', class: 'searchcraft-input-clear-button', onClick: this.handleClearInput }, index.h("svg", { key: '243b6eacc68fa8cc57d5e11b9b317d7fe581406f', class: 'searchcraft-input-clear-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, index.h("title", { key: 'd8a8b44fe04345b5b27ba33ec4ba510500eab3bf', id: 'icon-title' }, "Searchcraft Clear Input Icon Light"), index.h("path", { key: '0602cbff7aac6755dabb496b84e6ef3e4e2ac7a6', d: 'M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
|
|
235
230
|
}
|
|
236
231
|
static get watchers() { return {
|
|
237
232
|
"config": ["onConfigChange"]
|
|
@@ -248,22 +243,14 @@ const SearchcraftPopoverListView = class {
|
|
|
248
243
|
*/
|
|
249
244
|
popoverResultMappings;
|
|
250
245
|
/**
|
|
251
|
-
* The
|
|
246
|
+
* The items to render in the list view.
|
|
252
247
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
*/
|
|
258
|
-
const titleContent = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.title);
|
|
259
|
-
const subtitleContent = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.subtitle);
|
|
260
|
-
const href = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.href);
|
|
261
|
-
const imageSource = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageSource);
|
|
262
|
-
const imageAlt = units.getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageAlt);
|
|
263
|
-
return (index.h("searchcraft-popover-list-item", { key: `${document.document_id}-${index$1}`, "title-content": titleContent, "subtitle-content": subtitleContent, "image-src": imageSource, "image-alt": imageAlt, href: href, "document-position": index$1 }));
|
|
264
|
-
}
|
|
248
|
+
searchClientResponseItems;
|
|
249
|
+
adClientResponseItems;
|
|
250
|
+
searchResultsPage;
|
|
251
|
+
searchResultsPerPage;
|
|
265
252
|
render() {
|
|
266
|
-
return (index.h("div", { key: '
|
|
253
|
+
return (index.h("div", { key: 'a869d98e96f6fbbc80ecb79058c4753b4a3a8b1d', class: 'searchcraft-popover-list-view' }, this.adClientResponseItems?.map((item) => (index.h("searchcraft-popover-list-item-ad", { adClientResponseItem: item, key: item.adId }))), this.searchClientResponseItems?.map((item, index$1) => (index.h("searchcraft-popover-list-item", { item: item, key: item.id, popoverResultMappings: this.popoverResultMappings, documentPosition: this.searchResultsPerPage * (this.searchResultsPage - 1) + index$1 })))));
|
|
267
254
|
}
|
|
268
255
|
};
|
|
269
256
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-input-form.searchcraft-popover-list-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AuI,EACzI,MAAM,EAAC,OAAO,kBACD,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;MCvQU,0BAA0B;;;;;;;;IAK7B,qBAAqB,CAAoC;;;;IAIzD,SAAS,CAAwC;IAEzD,cAAc,CAAC,QAAiC,EAAEC,OAAa;;;;QAI7D,MAAM,YAAY,GAAGC,6CAAuC,CAC1D,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAClC,CAAC;QACF,MAAM,eAAe,GAAGA,6CAAuC,CAC7D,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CACrC,CAAC;QACF,MAAM,IAAI,GAAGA,6CAAuC,CAClD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,IAAI,CACjC,CAAC;QACF,MAAM,WAAW,GAAGA,6CAAuC,CACzD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,WAAW,CACxC,CAAC;QACF,MAAM,QAAQ,GAAGA,6CAAuC,CACtD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CACrC,CAAC;QAEF,QACEF,2CACE,GAAG,EAAE,GAAG,QAAQ,CAAC,WAAW,IAAIC,OAAK,EAAE,mBACxB,YAAY,sBACT,eAAe,eACtB,WAAW,eACX,QAAQ,EACnB,IAAI,EAAE,IAAI,uBACSA,OAAK,GACxB,EACF;KACH;IAED,MAAM;QACJ,QACED,kEAAK,KAAK,EAAC,+BAA+B,IACvC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KACnC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CACrC,CACG,EACN;KACH;;;;;;","names":["useSearchcraftStore","SearchcraftCore","parseCustomStyles","classNames","h","index","getDocumentValueFromSearchResultMapping"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx","src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\n\nimport { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport packageJson from '../../../package.json';\n\nimport { parseCustomStyles } from '@utils';\nimport { useSearchcraftStore } from '@provider/store';\nimport classNames from 'classnames';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-input-form placeholder-value=\"Search here\" />\n * ```\n *\n * ```js\n * // index.js\n * const searchInputForm = document.querySelector('searchcraft-input-form');\n *\n * seardchInputForm.config = {\n * index: [],\n * readKey: '',\n * endpointUrl: '',\n * };\n *\n * searchForm.addEventListener('querySubmit', (event) => {\n * console.log('Query submitted', event.detail);\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInput {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel: string | undefined;\n /**\n * A custom styles object to be applied to the input element.\n */\n @Prop() customStyles: string | Record<string, string> = {};\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue = 'Enter Search';\n /**\n * The starting value of the input element.\n */\n @Prop() searchTerm = '';\n /**\n * When the input is cleared.\n */\n @Event() inputCleared?: EventEmitter<void>;\n /**\n * When no results are returned.\n */\n @Event() noResultsReceived?: EventEmitter<void>;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n /**\n * Event emitted when a query has been submitted.\n */\n @Event() querySubmit?: EventEmitter<string>;\n\n @State() inputValue = this.searchTerm;\n @State() error = false;\n @State() isSearchcraftInitialized = false;\n\n private searchStore = useSearchcraftStore.getState();\n\n init() {\n if (this.config && !this.isSearchcraftInitialized) {\n const searchcraft = new SearchcraftCore(this.config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n this.searchStore.initialize(searchcraft, true);\n this.isSearchcraftInitialized = true;\n this.inputInit?.emit();\n }\n }\n\n componentDidLoad() {\n this.init();\n }\n\n @Watch('config')\n onConfigChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (input.value.trim() === '') {\n this.inputCleared?.emit();\n this.searchTerm = '';\n this.searchStore.setQuery('');\n this.searchStore.setSearchResults(null);\n return;\n }\n\n if (!this.autoSearch) {\n return;\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === useSearchcraftStore.getState().query) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setQuery(this.searchTerm);\n this.querySubmit?.emit(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n this.error = true;\n this.inputCleared?.emit();\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setQuery('');\n this.searchStore.setSearchResults(null);\n this.error = false;\n\n this.inputCleared?.emit();\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const validatedCustomStyles = parseCustomStyles(this.customStyles);\n\n const isShowingClearButton = this.inputValue.length > 0;\n\n const inputGridClassNames = classNames('searchcraft-input-grid', {\n 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',\n 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',\n 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',\n });\n\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-button-wrapper'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-label-wrapper'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-error-wrapper'>\n <searchcraft-error-message errorMessage='Something went wrong.' />\n </div>\n )}\n <div class='searchcraft-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n style={validatedCustomStyles}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-search-icon-wrapper'>\n <svg\n class='searchcraft-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title id='searchcraft-title'>\n Searchcraft Search Icon Light\n </title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='#404040'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title id='icon-title'>\n Searchcraft Clear Input Icon Light\n </title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='black'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n","import { Component, h, Prop } from '@stencil/core';\n\nimport { getDocumentValueFromSearchResultMapping } from '@utils';\nimport type { PopoverResultMappings } from 'types';\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 documents to render in the list view.\n */\n @Prop() documents: Record<string, unknown>[] | undefined;\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n const href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n const imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n\n return (\n <searchcraft-popover-list-item\n key={`${document.document_id}-${index}`}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n image-src={imageSource}\n image-alt={imageAlt}\n href={href}\n document-position={index}\n />\n );\n }\n\n render() {\n return (\n <div class='searchcraft-popover-list-view'>\n {this.documents?.map((document, index) =>\n this.renderDocument(document, index),\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-input-form.searchcraft-popover-list-view.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8Ca,gBAAgB;;;;;;;;;;;;;IAInB,MAAM,CAAgC;;;;IAItC,UAAU,GAAG,IAAI,CAAC;;;;IAIlB,eAAe,GAA8B,MAAM,CAAC;;;;IAIpD,WAAW,CAAqB;;;;IAIhC,UAAU,CAAqB;;;;IAI/B,YAAY,GAAoC,EAAE,CAAC;;;;IAInD,gBAAgB,GAAG,cAAc,CAAC;;;;IAIlC,UAAU,GAAG,EAAE,CAAC;;;;IAIf,YAAY,CAAsB;;;;IAIlC,iBAAiB,CAAsB;;;;IAIvC,UAAU,CAAsB;;;;IAIhC,SAAS,CAAsB;;;;IAI/B,SAAS,CAAsB;;;;IAI/B,WAAW,CAAwB;IAEnC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,KAAK,GAAG,KAAK,CAAC;IACd,wBAAwB,GAAG,KAAK,CAAC;IAElC,WAAW,GAAGA,oCAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE;YACjD,MAAM,WAAW,GAAG,IAAIC,mBAAe,CAAC,IAAI,CAAC,MAAM,EAAE;gBACnD,OAAO,EAAE,WAAW,CAAC,IAAI;gBACzB,UAAU,EAAE,WAAW,CAAC,OAAO;aAChC,CAAC,CAAC;YACH,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC;YACrC,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AAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;MChQU,0BAA0B;;;;;;;;IAK7B,qBAAqB,CAAoC;;;;IAIzD,yBAAyB,CAAyC;IAClE,qBAAqB,CAAqC;IAC1D,iBAAiB,CAAU;IAC3B,oBAAoB,CAAU;IAEtC,MAAM;QACJ,QACEA,kEAAK,KAAK,EAAC,+BAA+B,IACvC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,IAAI,MACpCA,8CACE,oBAAoB,EAAE,IAAI,EAC1B,GAAG,EAAE,IAAI,CAAC,IAAI,GACd,CACH,CAAC,EACD,IAAI,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAEC,OAAK,MAC/CD,2CACE,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,gBAAgB,EACd,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAGC,OAAK,GAElE,CACH,CAAC,CACE,EACN;KACH;;;;;;","names":["useSearchcraftStore","SearchcraftCore","parseCustomStyles","classNames","h","index"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx","src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\n\nimport { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport packageJson from '../../../package.json';\n\nimport { parseCustomStyles } from '@utils';\nimport { useSearchcraftStore } from '@provider/store';\nimport classNames from 'classnames';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-input-form placeholder-value=\"Search here\" />\n * ```\n *\n * ```js\n * // index.js\n * const searchInputForm = document.querySelector('searchcraft-input-form');\n *\n * searchInputForm.config = {\n * index: [],\n * readKey: '',\n * endpointUrl: '',\n * };\n *\n * searchForm.addEventListener('querySubmit', (event) => {\n * console.log('Query submitted', event.detail);\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInput {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel: string | undefined;\n /**\n * A custom styles object to be applied to the input element.\n */\n @Prop() customStyles: string | Record<string, string> = {};\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue = 'Enter Search';\n /**\n * The starting value of the input element.\n */\n @Prop() searchTerm = '';\n /**\n * When the input is cleared.\n */\n @Event() inputCleared?: EventEmitter<void>;\n /**\n * When no results are returned.\n */\n @Event() noResultsReceived?: EventEmitter<void>;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n /**\n * Event emitted when a query has been submitted.\n */\n @Event() querySubmit?: EventEmitter<string>;\n\n @State() inputValue = this.searchTerm;\n @State() error = false;\n @State() isSearchcraftInitialized = false;\n\n private searchStore = useSearchcraftStore.getState();\n\n init() {\n if (this.config && !this.isSearchcraftInitialized) {\n const searchcraft = new SearchcraftCore(this.config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n this.searchStore.initialize(searchcraft, true);\n this.isSearchcraftInitialized = true;\n this.inputInit?.emit();\n }\n }\n\n componentDidLoad() {\n this.init();\n }\n\n @Watch('config')\n onConfigChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (!this.autoSearch) {\n return;\n }\n\n if (input.value.trim() === '') {\n this.inputCleared?.emit();\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === useSearchcraftStore.getState().searchTerm) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setSearchTerm(this.searchTerm);\n this.querySubmit?.emit(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n this.error = true;\n this.inputCleared?.emit();\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setSearchTerm('');\n this.searchStore.setSearchClientResponseItems([]);\n this.error = false;\n\n this.inputCleared?.emit();\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const validatedCustomStyles = parseCustomStyles(this.customStyles);\n\n const isShowingClearButton = this.inputValue.length > 0;\n\n const inputGridClassNames = classNames('searchcraft-input-grid', {\n 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',\n 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',\n 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',\n });\n\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-button-wrapper'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-label-wrapper'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-error-wrapper'>\n <searchcraft-error-message errorMessage='Something went wrong.' />\n </div>\n )}\n <div class='searchcraft-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n style={validatedCustomStyles}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-search-icon-wrapper'>\n <svg\n class='searchcraft-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title id='searchcraft-title'>\n Searchcraft Search Icon Light\n </title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title id='icon-title'>\n Searchcraft Clear Input Icon Light\n </title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n","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"],"version":3}
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["searchcraft-
|
|
22
|
+
return index.bootstrapLazy([["searchcraft-base-search-results.cjs",[[4,"searchcraft-base-search-results",{"customStylesForResults":[1,"custom-styles-for-results"],"searchResultMappings":[16],"resultImagePlacement":[1,"result-image-placement"],"buttonLabel":[1,"button-label"],"buttonTarget":[1,"button-target"],"buttonRel":[1,"button-rel"],"containerTarget":[1,"container-target"],"containerRel":[1,"container-rel"],"searchTerm":[32],"searchClientResponseItems":[32],"adClientResponseItems":[32],"searchResultsPerPage":[32],"searchResultsPage":[32]}]]],["searchcraft-filter-panel.cjs",[[0,"searchcraft-filter-panel",{"items":[16],"unsubscribe":[32],"lastSearchTerm":[32]}]]],["searchcraft-pagination.cjs",[[0,"searchcraft-pagination",{"customStyles":[1,"custom-styles"],"searchTerm":[32],"searchResultsPerPage":[32],"searchResultsPage":[32],"searchResultsCount":[32],"searchResultsPagesCount":[32],"searchResultsRangeMin":[32],"searchResultsRangeMax":[32],"setSearchResultsPage":[32]}]]],["searchcraft-search-results-per-page.cjs",[[0,"searchcraft-search-results-per-page",{"increment":[8],"customStyles":[1,"custom-styles"],"searchTerm":[32],"searchResultsPage":[32],"searchResultsPerPage":[32],"searchResultsCount":[32],"searchResultsPagesCount":[32],"initialSearchResultsPerPage":[32],"setSearchResultsPerPage":[32],"setSearchResultsPage":[32]}]]],["searchcraft-popover-button.cjs",[[4,"searchcraft-popover-button"]]],["searchcraft-results-info.cjs",[[0,"searchcraft-results-info",{"customFormatter":[16],"customStyles":[1,"custom-styles"],"searchTerm":[32],"searchResultsPage":[32],"searchResultsPerPage":[32],"searchResultsCount":[32],"count":[32],"range":[32],"responseTime":[32]}]]],["searchcraft-theme.cjs",[[0,"searchcraft-theme",{"theme":[1],"customTheme":[1,"custom-theme"]}]]],["searchcraft-input-form_2.cjs",[[0,"searchcraft-input-form",{"config":[16],"autoSearch":[4,"auto-search"],"buttonPlacement":[1,"button-placement"],"buttonLabel":[1,"button-label"],"inputLabel":[1,"input-label"],"customStyles":[1,"custom-styles"],"placeholderValue":[1,"placeholder-value"],"searchTerm":[1,"search-term"],"inputValue":[32],"error":[32],"isSearchcraftInitialized":[32]},null,{"config":["onConfigChange"]}],[0,"searchcraft-popover-list-view",{"popoverResultMappings":[16],"searchClientResponseItems":[16],"adClientResponseItems":[16],"searchResultsPage":[2,"search-results-page"],"searchResultsPerPage":[2,"search-results-per-page"]}]]],["searchcraft-popover-form.cjs",[[0,"searchcraft-popover-form",{"config":[16],"type":[1],"popoverResultMappings":[16],"hotkey":[1],"hotkeyModifier":[1,"hotkey-modifier"],"isPopoverVisibleInState":[32],"unsubscribe":[32],"searchClientResponseItems":[32],"adClientResponseItems":[32],"searchTerm":[32],"isFocused":[32],"breakpointSm":[32],"breakpointMd":[32],"breakpointLg":[32],"searchResultsPage":[32],"searchResultsPerPage":[32],"modalElement":[32]}]]],["searchcraft-select.cjs",[[0,"searchcraft-select",{"caption":[1],"disabled":[4],"inputId":[1,"input-id"],"label":[1],"labelId":[1,"label-id"],"name":[1],"options":[1],"customStyles":[1,"custom-styles"],"searchResultsPerPage":[32],"setSearchResultsPage":[32],"setSearchResultsPerPage":[32]}]]],["searchcraft-base-search-result_2.cjs",[[0,"searchcraft-base-search-result",{"item":[16],"searchResultMappings":[16],"containerTarget":[1,"container-target"],"containerRel":[1,"container-rel"],"buttonTarget":[1,"button-target"],"buttonRel":[1,"button-rel"],"imagePlacement":[1,"image-placement"],"customStyles":[1,"custom-styles"],"documentPosition":[2,"document-position"],"titleContent":[32],"subtitleContent":[32],"bodyContent":[32],"footerContent":[32],"buttonLabel":[32],"buttonHref":[32],"containerHref":[32],"imageSrc":[32],"imageAlt":[32]}],[0,"searchcraft-base-search-result-ad",{"adClientResponseItem":[16]}]]],["searchcraft-facet-list_3.cjs",[[0,"searchcraft-facet-list",{"fieldName":[1,"field-name"],"baseFacetRoot":[32],"facetRoot":[32],"selectedPaths":[32],"lastTimeTaken":[32],"hasNewSearchTerm":[32],"lastSearchTerm":[32],"lastSearchMode":[32],"lastSortType":[32],"unsubscribe":[32]}],[0,"searchcraft-slider",{"max":[2],"min":[2],"granularity":[2],"dataType":[1,"data-type"],"endValue":[32],"startValue":[32],"lastFocusedHandle":[32]}],[0,"searchcraft-toggle-button",{"label":[1],"subLabel":[1,"sub-label"],"isActive":[32],"unsubscribe":[32],"lastSearchTerm":[32]}]]],["searchcraft-popover-list-item_2.cjs",[[0,"searchcraft-popover-list-item",{"item":[16],"popoverResultMappings":[16],"documentPosition":[2,"document-position"],"href":[32],"imageSrc":[32],"imageAlt":[32],"titleContent":[32],"subtitleContent":[32]}],[0,"searchcraft-popover-list-item-ad",{"adClientResponseItem":[16]}]]],["searchcraft-button_3.cjs",[[0,"searchcraft-input-label",{"inputLabelClassName":[1,"input-label-class-name"],"label":[1]}],[0,"searchcraft-button",{"hierarchy":[1],"disabled":[4],"icon":[16],"iconOnly":[4,"icon-only"],"iconPosition":[1,"icon-position"],"label":[1],"type":[1]}],[0,"searchcraft-error-message",{"errorMessage":[1,"error-message"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,106 @@
|
|
|
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 SearchcraftPagination = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The custom styles object.
|
|
16
|
+
*/
|
|
17
|
+
customStyles;
|
|
18
|
+
// store vars
|
|
19
|
+
searchTerm;
|
|
20
|
+
searchResultsPerPage;
|
|
21
|
+
searchResultsPage;
|
|
22
|
+
searchResultsCount;
|
|
23
|
+
// local vars
|
|
24
|
+
searchResultsPagesCount = 1;
|
|
25
|
+
searchResultsRangeMin = 1;
|
|
26
|
+
searchResultsRangeMax = 1;
|
|
27
|
+
// store functions
|
|
28
|
+
setSearchResultsPage = () => { };
|
|
29
|
+
unsubscribe = () => { };
|
|
30
|
+
componentDidLoad() {
|
|
31
|
+
this.unsubscribe = SearchcraftStore.useSearchcraftStore.subscribe((state) => {
|
|
32
|
+
// store vars
|
|
33
|
+
this.searchTerm = state.searchTerm;
|
|
34
|
+
this.searchResultsPerPage = state.searchResultsPerPage;
|
|
35
|
+
this.searchResultsPage = state.searchResultsPage;
|
|
36
|
+
this.searchResultsCount = state.searchResultsCount;
|
|
37
|
+
// local vars
|
|
38
|
+
this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
|
|
39
|
+
this.searchResultsRangeMin =
|
|
40
|
+
(this.searchResultsPage - 1) * this.searchResultsPerPage + 1;
|
|
41
|
+
this.searchResultsRangeMax =
|
|
42
|
+
(this.searchResultsPerPage - 1) * this.searchResultsPerPage +
|
|
43
|
+
this.searchResultsPerPage;
|
|
44
|
+
// store functions
|
|
45
|
+
this.setSearchResultsPage = state.setSearchResultsPage;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
disconnectedCallback() {
|
|
49
|
+
this.unsubscribe?.();
|
|
50
|
+
}
|
|
51
|
+
handleGoToPage(page) {
|
|
52
|
+
this.setSearchResultsPage(page);
|
|
53
|
+
}
|
|
54
|
+
renderOddPaginationItem(page) {
|
|
55
|
+
return (index.h("li", null, index.h("button", { class: index$1.classNames('searchcraft-pagination-item', {
|
|
56
|
+
'searchcraft-pagination-item-active': this.searchResultsPage === page,
|
|
57
|
+
}), onClick: () => this.handleGoToPage(page), type: 'button' }, page)));
|
|
58
|
+
}
|
|
59
|
+
renderEvenPaginationItem(page) {
|
|
60
|
+
if (this.searchResultsPagesCount <= page) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (this.searchResultsPagesCount <= 5 ||
|
|
64
|
+
page < Math.ceil(this.searchResultsPagesCount / 2) // is the first or second even pagination item
|
|
65
|
+
? this.searchResultsPage <= page + 1
|
|
66
|
+
: this.searchResultsPage >= page - 1) {
|
|
67
|
+
return (index.h("li", null, index.h("button", { class: index$1.classNames('searchcraft-pagination-item', {
|
|
68
|
+
'searchcraft-pagination-item-active': this.searchResultsPage === page,
|
|
69
|
+
}), onClick: () => this.handleGoToPage(page), type: 'button' }, page)));
|
|
70
|
+
}
|
|
71
|
+
return (index.h("li", null, index.h("span", { class: 'searchcraft-pagination-item' }, "...")));
|
|
72
|
+
}
|
|
73
|
+
renderMiddlePaginationItem() {
|
|
74
|
+
if (this.searchResultsPagesCount <= 3) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (this.searchResultsPagesCount <= 5 ||
|
|
78
|
+
this.searchResultsPage <= 3 ||
|
|
79
|
+
this.searchResultsPage >= this.searchResultsPagesCount - 2) {
|
|
80
|
+
return (index.h("li", null, index.h("button", { class: index$1.classNames('searchcraft-pagination-item', {
|
|
81
|
+
'searchcraft-pagination-item-active': this.searchResultsPage === 3 ||
|
|
82
|
+
this.searchResultsPage === this.searchResultsPagesCount - 2,
|
|
83
|
+
}), type: 'button', onClick: () => this.handleGoToPage(this.searchResultsPage >= this.searchResultsPagesCount - 2
|
|
84
|
+
? this.searchResultsPagesCount - 2
|
|
85
|
+
: 3) }, this.searchResultsPage >= this.searchResultsPagesCount - 2
|
|
86
|
+
? this.searchResultsPagesCount - 2
|
|
87
|
+
: 3)));
|
|
88
|
+
}
|
|
89
|
+
return (index.h("li", null, index.h("span", { class: 'searchcraft-pagination-item searchcraft-pagination-item-active' }, this.searchResultsPage)));
|
|
90
|
+
}
|
|
91
|
+
render() {
|
|
92
|
+
// early return if there isn't a searchTerm or there is 1 or fewer pages of results
|
|
93
|
+
if (!this.searchTerm || this.searchResultsPagesCount <= 1) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
return (index.h("div", { class: index$1.classNames('searchcraft-pagination', styles.parseCustomStyles(this.customStyles || {})) }, index.h("div", { class: 'searchcraft-pagination-control' }, index.h("searchcraft-button", { disabled: this.searchResultsPage === 1, hierarchy: 'tertiary', onButtonClick: () => this.handleGoToPage(Math.max(1, this.searchResultsPage - 1)), label: 'PREVIOUS', iconPosition: 'left', icon: index.h("svg", { width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, index.h("title", null, "Previous page icon"), index.h("path", { d: 'M12.5 15L7.5 10L12.5 5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' })) })), index.h("ul", { class: 'searchcraft-pagination-list' }, this.renderOddPaginationItem(1), this.renderEvenPaginationItem(2), this.renderMiddlePaginationItem(), this.renderEvenPaginationItem(this.searchResultsPagesCount > 4
|
|
97
|
+
? this.searchResultsPagesCount - 1
|
|
98
|
+
: 4), this.renderOddPaginationItem(this.searchResultsPagesCount)), index.h("div", { class: 'searchcraft-pagination-control' }, index.h("searchcraft-button", { disabled: this.searchResultsPage === this.searchResultsPagesCount, hierarchy: 'tertiary', onButtonClick: () => {
|
|
99
|
+
this.handleGoToPage(Math.min(this.searchResultsPagesCount, this.searchResultsPage + 1));
|
|
100
|
+
}, label: 'NEXT', iconPosition: 'right', icon: index.h("svg", { width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, index.h("title", null, "Next page icon"), index.h("path", { d: 'M7.5 15L12.5 10L7.5 5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' })) }))));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.searchcraft_pagination = SearchcraftPagination;
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=searchcraft-pagination.cjs.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"searchcraft-pagination.entry.cjs.js","mappings":";;;;;;;;;MAoBa,qBAAqB;;;;;;;IAIxB,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,oBAAoB,CAAC;IACrB,iBAAiB,CAAC;IAClB,kBAAkB,CAAC;;IAGnB,uBAAuB,GAAG,CAAC,CAAC;IAC5B,qBAAqB,GAAG,CAAC,CAAC;IAC1B,qBAAqB,GAAG,CAAC,CAAC;;IAG1B,oBAAoB,GAA2B,SAAQ,CAAC;IAEzD,WAAW,GA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AAC;cAC5B,IAAI,CAAC,uBAAuB,GAAG,CAAC;cAChC,CAAC,CACN,EACA,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CACxD,EACLA,iBAAK,KAAK,EAAC,gCAAgC,IACzCA,gCACE,QAAQ,EAAE,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,uBAAuB,EACjE,SAAS,EAAC,UAAU,EACpB,aAAa,EAAE;gBACb,IAAI,CAAC,cAAc,CACjB,IAAI,CAAC,GAAG,CACN,IAAI,CAAC,uBAAuB,EAC5B,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAC3B,CACF,CAAC;aACH,EACD,KAAK,EAAC,MAAM,EACZ,YAAY,EAAC,OAAO,EACpB,IAAI,EACFA,iBACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,IAElCA,wCAA6B,EAC7BA,kBACE,CAAC,EAAC,uBAAuB,EACzB,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,GAER,CACE,CACF,EACN;KACH;;;;;","names":["useSearchcraftStore","h","classNames","parseCustomStyles"],"sources":["src/components/searchcraft-pagination/searchcraft-pagination.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 facilitate pagination of search results.\n * Once a query is submitted, calculates the number for pages.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-pagination />\n * ```\n */\n@Component({\n tag: 'searchcraft-pagination',\n shadow: false,\n})\nexport class SearchcraftPagination {\n /**\n * The custom styles object.\n */\n @Prop() customStyles?: string;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPerPage;\n @State() searchResultsPage;\n @State() searchResultsCount;\n\n // local vars\n @State() searchResultsPagesCount = 1;\n @State() searchResultsRangeMin = 1;\n @State() searchResultsRangeMax = 1;\n\n // store functions\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 this.searchResultsRangeMin =\n (this.searchResultsPage - 1) * this.searchResultsPerPage + 1;\n this.searchResultsRangeMax =\n (this.searchResultsPerPage - 1) * this.searchResultsPerPage +\n this.searchResultsPerPage;\n\n // store functions\n this.setSearchResultsPage = state.setSearchResultsPage;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleGoToPage(page: number) {\n this.setSearchResultsPage(page);\n }\n\n renderOddPaginationItem(page: number) {\n return (\n <li>\n <button\n class={classNames('searchcraft-pagination-item', {\n 'searchcraft-pagination-item-active':\n this.searchResultsPage === page,\n })}\n onClick={() => this.handleGoToPage(page)}\n type='button'\n >\n {page}\n </button>\n </li>\n );\n }\n\n renderEvenPaginationItem(page: number) {\n if (this.searchResultsPagesCount <= page) {\n return;\n }\n\n if (\n this.searchResultsPagesCount <= 5 ||\n page < Math.ceil(this.searchResultsPagesCount / 2) // is the first or second even pagination item\n ? this.searchResultsPage <= page + 1\n : this.searchResultsPage >= page - 1\n ) {\n return (\n <li>\n <button\n class={classNames('searchcraft-pagination-item', {\n 'searchcraft-pagination-item-active':\n this.searchResultsPage === page,\n })}\n onClick={() => this.handleGoToPage(page)}\n type='button'\n >\n {page}\n </button>\n </li>\n );\n }\n\n return (\n <li>\n <span class='searchcraft-pagination-item'>...</span>\n </li>\n );\n }\n\n renderMiddlePaginationItem() {\n if (this.searchResultsPagesCount <= 3) {\n return;\n }\n\n if (\n this.searchResultsPagesCount <= 5 ||\n this.searchResultsPage <= 3 ||\n this.searchResultsPage >= this.searchResultsPagesCount - 2\n ) {\n return (\n <li>\n <button\n class={classNames('searchcraft-pagination-item', {\n 'searchcraft-pagination-item-active':\n this.searchResultsPage === 3 ||\n this.searchResultsPage === this.searchResultsPagesCount - 2,\n })}\n type='button'\n onClick={() =>\n this.handleGoToPage(\n this.searchResultsPage >= this.searchResultsPagesCount - 2\n ? this.searchResultsPagesCount - 2\n : 3,\n )\n }\n >\n {this.searchResultsPage >= this.searchResultsPagesCount - 2\n ? this.searchResultsPagesCount - 2\n : 3}\n </button>\n </li>\n );\n }\n\n return (\n <li>\n <span class='searchcraft-pagination-item searchcraft-pagination-item-active'>\n {this.searchResultsPage}\n </span>\n </li>\n );\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-pagination',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n <div class='searchcraft-pagination-control'>\n <searchcraft-button\n disabled={this.searchResultsPage === 1}\n hierarchy='tertiary'\n onButtonClick={() =>\n this.handleGoToPage(Math.max(1, this.searchResultsPage - 1))\n }\n label='PREVIOUS'\n iconPosition='left'\n icon={\n <svg\n width='20'\n height='20'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n >\n <title>Previous page icon</title>\n <path\n d='M12.5 15L7.5 10L12.5 5'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n }\n />\n </div>\n <ul class='searchcraft-pagination-list'>\n {this.renderOddPaginationItem(1)}\n {this.renderEvenPaginationItem(2)}\n {this.renderMiddlePaginationItem()}\n {this.renderEvenPaginationItem(\n this.searchResultsPagesCount > 4\n ? this.searchResultsPagesCount - 1\n : 4,\n )}\n {this.renderOddPaginationItem(this.searchResultsPagesCount)}\n </ul>\n <div class='searchcraft-pagination-control'>\n <searchcraft-button\n disabled={this.searchResultsPage === this.searchResultsPagesCount}\n hierarchy='tertiary'\n onButtonClick={() => {\n this.handleGoToPage(\n Math.min(\n this.searchResultsPagesCount,\n this.searchResultsPage + 1,\n ),\n );\n }}\n label='NEXT'\n iconPosition='right'\n icon={\n <svg\n width='20'\n height='20'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n >\n <title>Next page icon</title>\n <path\n d='M7.5 15L12.5 10L7.5 5'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n }\n />\n </div>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-a81df4f0.js');
|
|
6
|
-
const
|
|
6
|
+
const SearchcraftStore = require('./SearchcraftStore-75fac5e0.js');
|
|
7
7
|
|
|
8
8
|
const SearchcraftPopoverButton = class {
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
index.registerInstance(this, hostRef);
|
|
11
11
|
}
|
|
12
12
|
handleOnClick() {
|
|
13
|
-
|
|
13
|
+
SearchcraftStore.useSearchcraftStore.getState().setPopoverVisibility(true);
|
|
14
14
|
}
|
|
15
15
|
render() {
|
|
16
|
-
return (index.h("button", { key: '
|
|
16
|
+
return (index.h("button", { key: '538e1e8506bea196e6ba45482f9daa75d032462f', type: 'button', onClick: this.handleOnClick.bind(this) }, index.h("slot", { key: '788b70da6edcbfb283d373ada36709582ad16e51' })));
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-popover-button.entry.cjs.js","mappings":";;;;;;;MAUa,wBAAwB;;;;IACnC,aAAa;QACXA,
|
|
1
|
+
{"file":"searchcraft-popover-button.entry.cjs.js","mappings":";;;;;;;MAUa,wBAAwB;;;;IACnC,aAAa;QACXA,oCAAmB,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;KAC3D;IAED,MAAM;QACJ,QACEC,qEAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAC1DA,oEAAQ,CACD,EACT;KACH;;;;;","names":["useSearchcraftStore","h"],"sources":["src/components/searchcraft-popover-button/searchcraft-popover-button.tsx"],"sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport { Component, h } from '@stencil/core';\n\n/**\n * Renders a button which, when clicked, turns on popover visibility.\n */\n@Component({\n tag: 'searchcraft-popover-button',\n shadow: false,\n})\nexport class SearchcraftPopoverButton {\n handleOnClick() {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n }\n\n render() {\n return (\n <button type='button' onClick={this.handleOnClick.bind(this)}>\n <slot />\n </button>\n );\n }\n}\n"],"version":3}
|