@searchcraft/javascript-sdk 0.5.3 → 0.7.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 +53 -55
- package/dist/cjs/{index-b76bece0.js → index-d4b4a45e.js} +234 -130
- package/dist/cjs/index-d4b4a45e.js.map +1 -0
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js +15 -19
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +31 -17
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-button_3.cjs.entry.js +72 -0
- package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +163 -35
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +11 -10
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +238 -0
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js +3 -3
- package/dist/cjs/searchcraft-javascript-sdk.cjs.js.map +1 -1
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js +26 -0
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js +206 -5
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js +26 -0
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js.map +1 -0
- package/dist/cjs/searchcraft-results-info.cjs.entry.js +5 -5
- package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +1 -1
- package/dist/cjs/store-abe47006.js +1479 -0
- package/dist/cjs/store-abe47006.js.map +1 -0
- package/dist/cjs/styles-7b2d06f2.js +28 -0
- package/dist/cjs/styles-7b2d06f2.js.map +1 -0
- package/dist/cjs/units-fe4d8083.js +88 -0
- package/dist/cjs/units-fe4d8083.js.map +1 -0
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +65 -32
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +54 -4
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +86 -19
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.module.css +52 -2
- package/dist/collection/components/searchcraft-button/searchcraft-button.js +32 -11
- package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +1 -1
- package/dist/collection/components/searchcraft-button/searchcraft-button.module.css +52 -2
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +13 -5
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +1 -1
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.module.css +52 -2
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +27 -14
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +1 -1
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.module.css +52 -2
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +19 -7
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +1 -1
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.module.css +52 -2
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +106 -61
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +1 -1
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.module.css +56 -6
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +19 -7
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +1 -1
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.module.css +52 -2
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +25 -0
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +1 -0
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +299 -9
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.module.css +322 -0
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +143 -0
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +1 -0
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.module.css +209 -0
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +50 -9
- 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 +11 -1
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -1
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.module.css +53 -3
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +38 -15
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -1
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +52 -2
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +18 -10
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +52 -2
- package/dist/collection/index.js +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/provider/store.js +14 -15
- package/dist/collection/provider/store.js.map +1 -1
- package/dist/collection/types/_shared.types.js +2 -0
- package/dist/collection/types/_shared.types.js.map +1 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/collection/types/index.js.map +1 -1
- package/dist/collection/types/searchcraft-base-search-results.types.js.map +1 -1
- package/dist/collection/types/searchcraft-popover-form.types.js.map +1 -1
- package/dist/collection/utils/{utils.js → facets.js} +7 -105
- package/dist/collection/utils/facets.js.map +1 -0
- package/dist/collection/utils/index.js +4 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/collection/utils/styles.js +22 -0
- package/dist/collection/utils/styles.js.map +1 -0
- package/dist/collection/utils/units.js +83 -0
- package/dist/collection/utils/units.js.map +1 -0
- package/dist/components/index.js +7 -5
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-01dc5b3b.js +1475 -0
- package/dist/components/p-01dc5b3b.js.map +1 -0
- package/dist/components/p-1ae87308.js +43 -0
- package/dist/components/p-1ae87308.js.map +1 -0
- package/dist/components/p-649654b5.js +268 -0
- package/dist/components/p-649654b5.js.map +1 -0
- package/dist/components/p-662cb490.js +67 -0
- package/dist/components/p-662cb490.js.map +1 -0
- package/dist/components/{p-e4846fa2.js → p-6cafd48d.js} +189 -112
- package/dist/components/p-6cafd48d.js.map +1 -0
- package/dist/components/p-755f491b.js +84 -0
- package/dist/components/p-755f491b.js.map +1 -0
- package/dist/components/p-87d1611b.js +97 -0
- package/dist/components/p-87d1611b.js.map +1 -0
- package/dist/components/p-c273e43d.js +40 -0
- package/dist/components/p-c273e43d.js.map +1 -0
- package/dist/components/p-cc9f8c61.js +109 -0
- package/dist/components/p-cc9f8c61.js.map +1 -0
- package/dist/components/p-cf096782.js +56 -0
- package/dist/components/p-cf096782.js.map +1 -0
- package/dist/components/p-d9551738.js +25 -0
- package/dist/components/p-d9551738.js.map +1 -0
- package/dist/components/p-da5b92ef.js +253 -0
- package/dist/components/p-da5b92ef.js.map +1 -0
- package/dist/components/p-e1cf5f9d.js +54 -0
- package/dist/components/p-e1cf5f9d.js.map +1 -0
- package/dist/components/p-f5a06210.js +34 -0
- package/dist/components/p-f5a06210.js.map +1 -0
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +25 -11
- 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 +13 -12
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -241
- package/dist/components/searchcraft-input-form.js.map +1 -1
- package/dist/components/searchcraft-input-label.js +1 -1
- package/dist/components/searchcraft-popover-button.d.ts +11 -0
- package/dist/components/searchcraft-popover-button.js +39 -0
- package/dist/components/searchcraft-popover-button.js.map +1 -0
- package/dist/components/searchcraft-popover-form.js +255 -8
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.d.ts +11 -0
- package/dist/components/searchcraft-popover-list-item.js +8 -0
- package/dist/components/searchcraft-popover-list-item.js.map +1 -0
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +4 -4
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/esm/{index-be042742.js → index-56b713de.js} +234 -131
- package/dist/esm/index-56b713de.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/searchcraft-base-search-result.entry.js +15 -19
- package/dist/esm/searchcraft-base-search-result.entry.js.map +1 -1
- package/dist/esm/searchcraft-base-search-results.entry.js +23 -9
- package/dist/esm/searchcraft-base-search-results.entry.js.map +1 -1
- package/dist/esm/searchcraft-button_3.entry.js +66 -0
- package/dist/esm/searchcraft-button_3.entry.js.map +1 -0
- package/dist/esm/searchcraft-facet-list_3.entry.js +161 -33
- package/dist/esm/searchcraft-facet-list_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-filter-panel.entry.js +10 -9
- package/dist/esm/searchcraft-filter-panel.entry.js.map +1 -1
- package/dist/esm/searchcraft-input-form_2.entry.js +233 -0
- package/dist/esm/searchcraft-input-form_2.entry.js.map +1 -0
- package/dist/esm/searchcraft-javascript-sdk.js +4 -4
- package/dist/esm/searchcraft-javascript-sdk.js.map +1 -1
- package/dist/esm/searchcraft-popover-button.entry.js +22 -0
- package/dist/esm/searchcraft-popover-button.entry.js.map +1 -0
- package/dist/esm/searchcraft-popover-form.entry.js +206 -5
- package/dist/esm/searchcraft-popover-form.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-list-item.entry.js +22 -0
- package/dist/esm/searchcraft-popover-list-item.entry.js.map +1 -0
- package/dist/esm/searchcraft-results-info.entry.js +4 -4
- package/dist/esm/searchcraft-results-info.entry.js.map +1 -1
- package/dist/esm/store-712f0586.js +1475 -0
- package/dist/esm/store-712f0586.js.map +1 -0
- package/dist/esm/styles-961644ef.js +25 -0
- package/dist/esm/styles-961644ef.js.map +1 -0
- package/dist/esm/units-b6eba560.js +84 -0
- package/dist/esm/units-b6eba560.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/p-01dc5b3b.js +11 -0
- package/dist/searchcraft-javascript-sdk/p-01dc5b3b.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-117fcdd3.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-117fcdd3.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-129e6f2c.js +3 -0
- package/dist/searchcraft-javascript-sdk/p-129e6f2c.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-27cb401c.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-27cb401c.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-4df4a29e.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-4df4a29e.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-54248dd8.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-54248dd8.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-69430dbf.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-69430dbf.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-755f491b.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-755f491b.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-a460755d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-a460755d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-bc2c4259.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-bc2c4259.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-caecdcda.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-caecdcda.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-d9551738.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-d9551738.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-f8129731.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-f8129731.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-f839b682.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-f839b682.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 +53 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +68 -0
- package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +20 -0
- package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +12 -0
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +25 -0
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +12 -0
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +37 -13
- package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +13 -1
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +7 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +97 -1
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +22 -0
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +19 -3
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +10 -0
- package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +18 -0
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +11 -3
- package/dist/types/components.d.ts +1023 -30
- package/dist/types/index.d.ts +1 -1
- package/dist/types/provider/store.d.ts +4 -2
- package/dist/types/types/_shared.types.d.ts +45 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/searchcraft-base-search-results.types.d.ts +1 -8
- package/dist/types/types/searchcraft-popover-form.types.d.ts +2 -1
- package/dist/types/utils/facets.d.ts +6 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/styles.d.ts +2 -0
- package/dist/types/utils/{utils.d.ts → units.d.ts} +12 -19
- package/package.json +8 -4
- package/dist/cjs/index-b76bece0.js.map +0 -1
- package/dist/cjs/searchcraft-button_2.cjs.entry.js +0 -51
- package/dist/cjs/searchcraft-button_2.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-error-message.cjs.entry.js +0 -23
- package/dist/cjs/searchcraft-error-message.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-input-form.cjs.entry.js +0 -202
- package/dist/cjs/searchcraft-input-form.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-list-view.cjs.entry.js +0 -26
- package/dist/cjs/searchcraft-popover-list-view.cjs.entry.js.map +0 -1
- package/dist/cjs/searchcraft-popover-result.cjs.entry.js +0 -25
- package/dist/cjs/searchcraft-popover-result.cjs.entry.js.map +0 -1
- package/dist/cjs/store-943576b0.js +0 -956
- package/dist/cjs/store-943576b0.js.map +0 -1
- package/dist/cjs/utils-a17279a2.js +0 -226
- package/dist/cjs/utils-a17279a2.js.map +0 -1
- package/dist/collection/components/searchcraft-popover-result/searchcraft-popover-result.js +0 -21
- package/dist/collection/components/searchcraft-popover-result/searchcraft-popover-result.js.map +0 -1
- package/dist/collection/utils/utils.js.map +0 -1
- package/dist/components/p-16983367.js +0 -35
- package/dist/components/p-16983367.js.map +0 -1
- package/dist/components/p-42bfef5f.js +0 -151
- package/dist/components/p-42bfef5f.js.map +0 -1
- package/dist/components/p-5380505b.js +0 -99
- package/dist/components/p-5380505b.js.map +0 -1
- package/dist/components/p-672354c0.js +0 -38
- package/dist/components/p-672354c0.js.map +0 -1
- package/dist/components/p-9cb3d38b.js +0 -48
- package/dist/components/p-9cb3d38b.js.map +0 -1
- package/dist/components/p-a23d2994.js +0 -67
- package/dist/components/p-a23d2994.js.map +0 -1
- package/dist/components/p-ad4ebde0.js +0 -952
- package/dist/components/p-ad4ebde0.js.map +0 -1
- package/dist/components/p-bd5fede3.js +0 -41
- package/dist/components/p-bd5fede3.js.map +0 -1
- package/dist/components/p-cbdcf6df.js +0 -101
- package/dist/components/p-cbdcf6df.js.map +0 -1
- package/dist/components/p-e4846fa2.js.map +0 -1
- package/dist/components/p-f308d05d.js +0 -218
- package/dist/components/p-f308d05d.js.map +0 -1
- package/dist/components/searchcraft-popover-result.d.ts +0 -11
- package/dist/components/searchcraft-popover-result.js +0 -38
- package/dist/components/searchcraft-popover-result.js.map +0 -1
- package/dist/esm/index-be042742.js.map +0 -1
- package/dist/esm/searchcraft-button_2.entry.js +0 -46
- package/dist/esm/searchcraft-button_2.entry.js.map +0 -1
- package/dist/esm/searchcraft-error-message.entry.js +0 -19
- package/dist/esm/searchcraft-error-message.entry.js.map +0 -1
- package/dist/esm/searchcraft-input-form.entry.js +0 -198
- package/dist/esm/searchcraft-input-form.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-list-view.entry.js +0 -22
- package/dist/esm/searchcraft-popover-list-view.entry.js.map +0 -1
- package/dist/esm/searchcraft-popover-result.entry.js +0 -21
- package/dist/esm/searchcraft-popover-result.entry.js.map +0 -1
- package/dist/esm/store-eb4269d6.js +0 -952
- package/dist/esm/store-eb4269d6.js.map +0 -1
- package/dist/esm/utils-c2ce411f.js +0 -218
- package/dist/esm/utils-c2ce411f.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-04300412.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-04300412.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-09c7fbef.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-09c7fbef.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-32068485.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-32068485.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-4d3682a8.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-4d3682a8.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-61cf9d6c.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-61cf9d6c.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-93b92b65.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-93b92b65.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-a7a7b4e0.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-a7a7b4e0.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-a810aeae.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-a810aeae.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-aa155194.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-aa155194.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-ad4ebde0.js +0 -11
- package/dist/searchcraft-javascript-sdk/p-ad4ebde0.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-adadf38a.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-adadf38a.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-d57eba31.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-d57eba31.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-d7d0b88c.js +0 -3
- package/dist/searchcraft-javascript-sdk/p-d7d0b88c.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-f308d05d.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-f308d05d.js.map +0 -1
- package/dist/types/components/searchcraft-popover-result/searchcraft-popover-result.d.ts +0 -6
- /package/dist/collection/components/{searchcraft-popover-result/searchcraft-popover-result.module.css → searchcraft-popover-button/searchcraft-popover-button.module.css} +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-6cafd48d.js';
|
|
2
|
+
import { u as useSearchcraftStore, b as ae } from './p-01dc5b3b.js';
|
|
3
|
+
import { p as parseCustomStyles } from './p-d9551738.js';
|
|
4
|
+
import { c as classNames } from './p-5cdc6210.js';
|
|
5
|
+
import { d as defineCustomElement$3 } from './p-cf096782.js';
|
|
6
|
+
import { d as defineCustomElement$2 } from './p-f5a06210.js';
|
|
7
|
+
import { d as defineCustomElement$1 } from './p-c273e43d.js';
|
|
8
|
+
|
|
9
|
+
const name = "@searchcraft/javascript-sdk";
|
|
10
|
+
const version = "0.7.0";
|
|
11
|
+
const description = "Searchcraft Javascript SDK";
|
|
12
|
+
const author = "Searchcraft";
|
|
13
|
+
const license = "Apache-2.0";
|
|
14
|
+
const main = "dist/index.cjs.js";
|
|
15
|
+
const module = "dist/index.js";
|
|
16
|
+
const types = "dist/types/index.d.ts";
|
|
17
|
+
const collection = "dist/collection/collection-manifest.json";
|
|
18
|
+
const unpkg = "dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js";
|
|
19
|
+
const exports = {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js",
|
|
22
|
+
require: "./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.cjs.js",
|
|
23
|
+
types: "./dist/types/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./components": {
|
|
26
|
+
"import": "./dist/components/index.js",
|
|
27
|
+
types: "./dist/components/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./loader": {
|
|
30
|
+
"import": "./dist/loader/index.js",
|
|
31
|
+
require: "./dist/loader/index.cjs",
|
|
32
|
+
types: "./dist/loader/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./dist/components/*": {
|
|
35
|
+
"import": "./dist/components/*",
|
|
36
|
+
types: "./dist/components/*"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const repository = {
|
|
40
|
+
type: "git",
|
|
41
|
+
url: "https://bitbucket.org/madebychalk/searchcraft-javascript-sdks/"
|
|
42
|
+
};
|
|
43
|
+
const files = [
|
|
44
|
+
"dist/"
|
|
45
|
+
];
|
|
46
|
+
const scripts = {
|
|
47
|
+
build: "stencil build",
|
|
48
|
+
dev: "stencil build --dev --watch",
|
|
49
|
+
test: "stencil test --spec --e2e",
|
|
50
|
+
"test.watch": "stencil test --spec --e2e --watchAll",
|
|
51
|
+
generate: "stencil generate"
|
|
52
|
+
};
|
|
53
|
+
const dependencies = {
|
|
54
|
+
"@stencil/vue-output-target": "^0.9.2",
|
|
55
|
+
classnames: "^2.3.2"
|
|
56
|
+
};
|
|
57
|
+
const devDependencies = {
|
|
58
|
+
"@searchcraft/core": "^0.7.0",
|
|
59
|
+
"@searchcraft/javascript-sdk": "*",
|
|
60
|
+
"@stencil/core": "^4.7.0",
|
|
61
|
+
"@stencil/react-output-target": "^0.8.2",
|
|
62
|
+
"@stencil/sass": "^3.0.12",
|
|
63
|
+
"@types/node": "^16.18.11",
|
|
64
|
+
zustand: "^5.0.1"
|
|
65
|
+
};
|
|
66
|
+
const packageJson = {
|
|
67
|
+
name: name,
|
|
68
|
+
"private": false,
|
|
69
|
+
version: version,
|
|
70
|
+
description: description,
|
|
71
|
+
author: author,
|
|
72
|
+
license: license,
|
|
73
|
+
main: main,
|
|
74
|
+
module: module,
|
|
75
|
+
types: types,
|
|
76
|
+
collection: collection,
|
|
77
|
+
"collection:main": "dist/collection/index.js",
|
|
78
|
+
unpkg: unpkg,
|
|
79
|
+
exports: exports,
|
|
80
|
+
repository: repository,
|
|
81
|
+
files: files,
|
|
82
|
+
scripts: scripts,
|
|
83
|
+
dependencies: dependencies,
|
|
84
|
+
devDependencies: devDependencies
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const searchcraftInputFormModuleCss = ":root{--sc-input-border-radius:8px;--sc-input-search-icon-size:20px;--sc-input-clear-icon-size:20px;--sc-input-padding-left:44px;--sc-input-padding-right:44px;--sc-image-border-radius:8px;--sc-popover-form-border-radius:8px;--sc-popover-list-view-height:400px;--sc-popover-list-item-image-size:60px;--sc-popover-list-item-padding-horizontal:8px;--sc-popover-list-item-padding-vertical:8px;--sc-popover-modal-max-width:570px}:root{--sc-surface-disabled:#D9D9D9;--sc-surface-neutral-primary:#FFFFFF;--sc-surface-neutral-secondary:#F3F3F3;--sc-surface-neutral-light:#FFFFFF;--sc-surface-neutral-primary-hover:#FAFAFA;--sc-surface-neutral-primary-active:#F7F7F7;--sc-surface-neutral-secondary-hover:#EDEDED;--sc-surface-neutral-secondary-active:#E6E6E6;--sc-surface-brand-primary:#000000;--sc-surface-brand-secondary:#E6E6E6;--sc-surface-brand-primary-hover:#2E2E2E;--sc-surface-brand-primary-active:#292929;--sc-surface-brand-secondary-hover:#EBEBEB;--sc-surface-brand-secondary-active:#E0E0E0;--sc-surface-success-primary:#008000;--sc-surface-success-secondary:#CCFFCC;--sc-surface-success-primary-hover:#009900;--sc-surface-success-primary-active:#006600;--sc-surface-success-secondary-hover:#E6FFE6;--sc-surface-success-secondary-active:#E6FFE6;--sc-surface-caution-primary:#CC6600;--sc-surface-caution-secondary:#FFD9B3;--sc-surface-caution-primary-hover:#E57300;--sc-surface-caution-primary-active:#B25A00;--sc-surface-caution-secondary-hover:#FFE5CC;--sc-surface-caution-secondary-active:#FFCC99;--sc-surface-danger-primary:#CC0000;--sc-surface-danger-secondary:#FFCCCC;--sc-surface-danger-primary-hover:#E50000;--sc-surface-danger-primary-active:#B30000;--sc-surface-danger-secondary-hover:#FFE7E7;--sc-surface-danger-secondary-active:#FFB3B3;--sc-content-brand:#000000;--sc-content-success:#008000;--sc-content-caution:#994D00;--sc-content-danger:#990000;--sc-content-disabled:#737373;--sc-content-neutral-primary:#292929;--sc-content-neutral-secondary:#404040;--sc-content-brand-on-primary:#FFFFFF;--sc-content-success-on-primary:#FFFFFF;--sc-content-caution-on-primary:#FFFFFF;--sc-content-danger-on-primary:#FFFFFF;--sc-content-disabled-on-disabled:#737373;--sc-border-neutral:rgba(0,0,0, 0.1);--sc-border-brand:#000000;--sc-border-success:#008000;--sc-border-caution:#CC6600;--sc-border-danger:#CC0000;--sc-border-disabled:#737373}:root{--sc-font-family:sans-serif;--sc-heading-1-font-size:32px;--sc-heading-1-line-height:36px;--sc-heading-1-font-weight:700;--sc-heading-2-font-size:29px;--sc-heading-2-line-height:32px;--sc-heading-2-font-weight:700;--sc-heading-3-font-size:26px;--sc-heading-3-line-height:28px;--sc-heading-3-font-weight:700;--sc-heading-4-font-size:23px;--sc-heading-4-line-height:24px;--sc-heading-4-font-weight:700;--sc-heading-5-font-size:20px;--sc-heading-5-line-height:24px;--sc-heading-5-font-weight:700;--sc-heading-6-font-size:10px;--sc-heading-6-line-height:12px;--sc-heading-6-font-weight:700;--sc-body-bold-font-size:16px;--sc-body-bold-line-height:20px;--sc-body-bold-font-weight:700;--sc-body-font-size:16px;--sc-body-line-height:20px;--sc-body-font-weight:400;--sc-body-small-bold-font-size:12px;--sc-body-small-bold-line-height:16px;--sc-body-small-bold-font-weight:700;--sc-body-small-font-size:12px;--sc-body-small-line-height:16px;--sc-body-small-font-weight:400}:root{--sc-breakpoint-sm:576px;--sc-breakpoint-md:768px;--sc-breakpoint-lg:992px}.searchcraft-input-grid{display:grid;gap:4px 8px}.searchcraft-input-grid-buttonLeft{grid-template-rows:repeat(3, auto);grid-template-columns:auto 1fr}.searchcraft-input-grid-buttonLeft .searchcraft-input-button-wrapper{grid-column:1/span 1;grid-row:2/span 1}.searchcraft-input-grid-buttonLeft .searchcraft-input-label-wrapper{grid-column:2/span 1;grid-row:1/span 1}.searchcraft-input-grid-buttonLeft .searchcraft-input-error-wrapper{grid-column:2/span 1;grid-row:3/span 1}.searchcraft-input-grid-buttonLeft .searchcraft-input-wrapper{grid-column:2/span 1;grid-row:2/span 1}.searchcraft-input-grid-buttonRight{grid-template-rows:repeat(3, auto);grid-template-columns:1fr auto}.searchcraft-input-grid-buttonRight .searchcraft-input-button-wrapper{grid-column:2/span 1;grid-row:2/span 1}.searchcraft-input-grid-buttonRight .searchcraft-input-label-wrapper{grid-column:1/span 1;grid-row:1/span 1}.searchcraft-input-grid-buttonRight .searchcraft-input-error-wrapper{grid-column:1/span 1;grid-row:3/span 1}.searchcraft-input-grid-buttonRight .searchcraft-input-wrapper{grid-column:1/span 1;grid-row:2/span 1}.searchcraft-input-grid-buttonNone{grid-template-rows:repeat(3, auto);grid-template-columns:auto}.searchcraft-input-grid-buttonNone .searchcraft-input-button-wrapper{display:none}.searchcraft-input-grid-buttonNone .searchcraft-input-label-wrapper{grid-column:1/span 1;grid-row:1/span 1}.searchcraft-input-grid-buttonNone .searchcraft-input-error-wrapper{grid-column:1/span 1;grid-row:3/span 1}.searchcraft-input-grid-buttonNone .searchcraft-input-wrapper{grid-column:1/span 1;grid-row:2/span 1}.searchcraft-input-wrapper{position:relative;display:flex}.searchcraft-input{font-family:var(--sc-font-family);-webkit-font-smoothing:antialiased;font-size:var(--sc-body-font-size);font-weight:var(--sc-body-font-weight);line-height:var(--sc-body-line-height);background-color:var(--sc-surface-neutral-secondary);border-radius:var(--sc-input-border-radius);border:none;color:var(--sc-content-neutral-primary);outline:none;padding-left:var(--sc-input-padding-left);padding-right:var(--sc-input-padding-right);padding-top:12px;padding-bottom:12px;flex:1}.searchcraft-input::placeholder{color:var(--sc-content-disabled)}.searchcraft-input:focus{outline:var(--sc-border-brand) solid 2px}.searchcraft-input:focus::placeholder{opacity:0}.searchcraft-input.error{color:var(--sc-content-danger);outline:var(--sc-border-danger) solid 2px}.searchcraft-input.error:focus{outline:var(--sc-border-danger) solid 2px}.searchcraft-input-search-icon-wrapper{align-items:center;justify-content:center;display:flex;position:absolute;pointer-events:none;bottom:0;left:0;top:0;width:var(--sc-input-padding-left)}.searchcraft-input-search-icon{pointer-events:none;width:var(--sc-input-search-icon-size);height:var(--sc-input-search-icon-size)}.searchcraft-input-clear-button{all:unset;align-items:center;justify-content:center;cursor:pointer;display:flex;position:absolute;border:none;outline:none;bottom:0;right:0;top:0;width:var(--sc-input-padding-right)}.searchcraft-input-clear-icon{width:var(--sc-input-clear-icon-size);height:var(--sc-input-clear-icon-size)}";
|
|
88
|
+
const SearchcraftInputFormStyle0 = searchcraftInputFormModuleCss;
|
|
89
|
+
|
|
90
|
+
const SearchcraftInput = /*@__PURE__*/ proxyCustomElement(class SearchcraftInput extends H {
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
this.__registerHost();
|
|
94
|
+
this.inputCleared = createEvent(this, "inputCleared", 7);
|
|
95
|
+
this.noResultsReceived = createEvent(this, "noResultsReceived", 7);
|
|
96
|
+
this.inputFocus = createEvent(this, "inputFocus", 7);
|
|
97
|
+
this.inputBlur = createEvent(this, "inputBlur", 7);
|
|
98
|
+
this.inputInit = createEvent(this, "inputInit", 7);
|
|
99
|
+
this.querySubmit = createEvent(this, "querySubmit", 7);
|
|
100
|
+
/**
|
|
101
|
+
* Whether or not to automatically submit the search term when the input changes.
|
|
102
|
+
*/
|
|
103
|
+
this.autoSearch = true;
|
|
104
|
+
/**
|
|
105
|
+
* Where to place the search button.
|
|
106
|
+
*/
|
|
107
|
+
this.buttonPlacement = 'none';
|
|
108
|
+
/**
|
|
109
|
+
* A custom styles object to be applied to the input element.
|
|
110
|
+
*/
|
|
111
|
+
this.customStyles = {};
|
|
112
|
+
/**
|
|
113
|
+
* The input element's placeholder value.
|
|
114
|
+
*/
|
|
115
|
+
this.placeholderValue = 'Enter Search';
|
|
116
|
+
/**
|
|
117
|
+
* The starting value of the input element.
|
|
118
|
+
*/
|
|
119
|
+
this.searchTerm = '';
|
|
120
|
+
this.inputValue = this.searchTerm;
|
|
121
|
+
this.error = false;
|
|
122
|
+
this.isSearchcraftInitialized = false;
|
|
123
|
+
this.searchStore = useSearchcraftStore.getState();
|
|
124
|
+
this.handleOnInput = (event) => {
|
|
125
|
+
const input = event.target;
|
|
126
|
+
this.inputValue = input.value;
|
|
127
|
+
if (input.value.trim() === '') {
|
|
128
|
+
this.inputCleared.emit();
|
|
129
|
+
this.searchTerm = '';
|
|
130
|
+
this.searchStore.setQuery('');
|
|
131
|
+
this.searchStore.setSearchResults(null);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!this.autoSearch) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.performSearch(input.value);
|
|
138
|
+
};
|
|
139
|
+
this.performSearch = async (value) => {
|
|
140
|
+
if (value === useSearchcraftStore.getState().query) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.searchTerm = value.trim();
|
|
144
|
+
this.error = false;
|
|
145
|
+
this.searchStore.setQuery(this.searchTerm);
|
|
146
|
+
this.querySubmit.emit(this.searchTerm);
|
|
147
|
+
try {
|
|
148
|
+
await this.searchStore.search();
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
this.error = true;
|
|
152
|
+
this.inputCleared.emit();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
this.handleClearInput = () => {
|
|
156
|
+
this.inputValue = '';
|
|
157
|
+
this.searchTerm = '';
|
|
158
|
+
this.searchStore.setQuery('');
|
|
159
|
+
this.searchStore.setSearchResults(null);
|
|
160
|
+
this.error = false;
|
|
161
|
+
if (this.inputCleared) {
|
|
162
|
+
this.inputCleared.emit();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
this.handleFormSubmit = async (event) => {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
await this.performSearch(this.searchTerm);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
init() {
|
|
171
|
+
if (this.config && !this.isSearchcraftInitialized) {
|
|
172
|
+
const searchcraft = new ae(this.config, {
|
|
173
|
+
sdkName: packageJson.name,
|
|
174
|
+
sdkVersion: packageJson.version,
|
|
175
|
+
});
|
|
176
|
+
this.searchStore.initialize(searchcraft, true);
|
|
177
|
+
this.isSearchcraftInitialized = true;
|
|
178
|
+
this.inputInit.emit();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
componentDidLoad() {
|
|
182
|
+
this.init();
|
|
183
|
+
}
|
|
184
|
+
onConfigChange() {
|
|
185
|
+
this.init();
|
|
186
|
+
}
|
|
187
|
+
render() {
|
|
188
|
+
const validatedCustomStyles = parseCustomStyles(this.customStyles);
|
|
189
|
+
const isShowingClearButton = this.inputValue.length > 0;
|
|
190
|
+
const inputGridClassNames = classNames('searchcraft-input-grid', {
|
|
191
|
+
'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',
|
|
192
|
+
'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',
|
|
193
|
+
'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',
|
|
194
|
+
});
|
|
195
|
+
const shouldHaveVerticalGap = this.inputLabel || this.error;
|
|
196
|
+
const inputGridStyles = {
|
|
197
|
+
gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
|
|
198
|
+
};
|
|
199
|
+
return (h("form", { key: 'd257962d56a583e66bdf8b55786d5dfbae231965', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, h("div", { key: 'd9a8467a4d76433bc473941bd4583d991ae38040', class: inputGridClassNames, style: inputGridStyles }, h("div", { key: 'a94eacc99593ed6a30006532c51cdd38c692c93f', class: 'searchcraft-input-button-wrapper' }, h("searchcraft-button", { key: '43de9d2cd538bbdf2a2bbc9f5165bfb969943831', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (h("div", { key: 'b3554f81577d4526023d8b67de6837386789e9f3', class: 'searchcraft-input-label-wrapper' }, h("searchcraft-input-label", { key: '5cda67f38d0914dfe7e1ea71bee60b69524e9d5c', label: this.inputLabel }))), this.error && (h("div", { key: '22b82da9420159ebaf00fe3bb790d6b07341a79e', class: 'searchcraft-input-error-wrapper' }, h("searchcraft-error-message", { key: '2cc5c322408b976a7043ef9640c812036468435d', errorMessage: 'Something went wrong.' }))), h("div", { key: 'f2741bd0d20604327fa4661c3213e48df7a58249', class: 'searchcraft-input-wrapper' }, h("input", { key: '692822c6a38001ba4c71289b6b7fba13767742b5', autoComplete: 'off', class: 'searchcraft-input', onFocus: () => this.inputFocus.emit(), onBlur: () => this.inputBlur.emit(), onInput: (event) => {
|
|
200
|
+
this.handleOnInput(event);
|
|
201
|
+
}, placeholder: this.placeholderValue, style: validatedCustomStyles, type: 'text', value: this.inputValue }), h("div", { key: '58af613c048e7c072e4a976f71ea1bd7b3632a62', class: 'searchcraft-input-search-icon-wrapper' }, h("svg", { key: 'e6cf67405b45703ca7ddaf46a59adbf5ff926f0e', class: 'searchcraft-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, h("title", { key: 'fa510c85900d9a716076ba79866f5bbe4f1a20ed', id: 'searchcraft-title' }, "Searchcraft Search Icon Light"), h("path", { key: 'ac9d166c19e6644adcbc00fe665e17fcf5449b73', 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: '#404040', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (h("button", { key: '992cf037b6b75200c64c21809915b5ce6f970f5c', type: 'button', class: 'searchcraft-input-clear-button', onClick: this.handleClearInput }, h("svg", { key: 'f09a5f2c1007cc11d89b2df06ec189d923bc634f', class: 'searchcraft-input-clear-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, h("title", { key: '92bd5162ae636aaf6c8051959ff16cd26ee98660', id: 'icon-title' }, "Searchcraft Clear Input Icon Light"), h("path", { key: '9b5a8a4113a3162035d48895f0facf6f6045f266', 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: 'black', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
|
|
202
|
+
}
|
|
203
|
+
static get watchers() { return {
|
|
204
|
+
"config": ["onConfigChange"]
|
|
205
|
+
}; }
|
|
206
|
+
static get style() { return SearchcraftInputFormStyle0; }
|
|
207
|
+
}, [0, "searchcraft-input-form", {
|
|
208
|
+
"config": [16],
|
|
209
|
+
"autoSearch": [4, "auto-search"],
|
|
210
|
+
"buttonPlacement": [1, "button-placement"],
|
|
211
|
+
"buttonLabel": [1, "button-label"],
|
|
212
|
+
"inputLabel": [1, "input-label"],
|
|
213
|
+
"customStyles": [1, "custom-styles"],
|
|
214
|
+
"placeholderValue": [1, "placeholder-value"],
|
|
215
|
+
"searchTerm": [1, "search-term"],
|
|
216
|
+
"inputValue": [32],
|
|
217
|
+
"error": [32],
|
|
218
|
+
"isSearchcraftInitialized": [32]
|
|
219
|
+
}, undefined, {
|
|
220
|
+
"config": ["onConfigChange"]
|
|
221
|
+
}]);
|
|
222
|
+
function defineCustomElement() {
|
|
223
|
+
if (typeof customElements === "undefined") {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const components = ["searchcraft-input-form", "searchcraft-button", "searchcraft-error-message", "searchcraft-input-label"];
|
|
227
|
+
components.forEach(tagName => { switch (tagName) {
|
|
228
|
+
case "searchcraft-input-form":
|
|
229
|
+
if (!customElements.get(tagName)) {
|
|
230
|
+
customElements.define(tagName, SearchcraftInput);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case "searchcraft-button":
|
|
234
|
+
if (!customElements.get(tagName)) {
|
|
235
|
+
defineCustomElement$3();
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
case "searchcraft-error-message":
|
|
239
|
+
if (!customElements.get(tagName)) {
|
|
240
|
+
defineCustomElement$2();
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
case "searchcraft-input-label":
|
|
244
|
+
if (!customElements.get(tagName)) {
|
|
245
|
+
defineCustomElement$1();
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
} });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { SearchcraftInput as S, defineCustomElement as d };
|
|
252
|
+
|
|
253
|
+
//# sourceMappingURL=p-da5b92ef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-da5b92ef.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,6BAA6B,GAAG,k4MAAk4M,CAAC;AACz6M,mCAAe,6BAA6B;;MCmD/B,gBAAgB;IAL7B;;;;;;;;;;;;QAaU,eAAU,GAAG,IAAI,CAAC;;;;QAIlB,oBAAe,GAA8B,MAAM,CAAC;;;;QAYpD,iBAAY,GAAoC,EAAE,CAAC;;;;QAInD,qBAAgB,GAAG,cAAc,CAAC;;;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Aa,CAAC,KAAK,CAAC,CAAC;aAC3B,EACD,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAClC,KAAK,EAAE,qBAAqB,EAC5B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,UAAU,GACtB,EACF,4DAAK,KAAK,EAAC,uCAAuC,IAChD,4DACE,KAAK,EAAC,+BAA+B,EACrC,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,mBAAmB,IAEnC,8DAAO,EAAE,EAAC,mBAAmB,oCAErB,EACR,6DACE,CAAC,EAAC,mNAAmN,EACrN,MAAM,EAAC,SAAS,kBACH,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACF,EACL,oBAAoB,KACnB,+DACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,gCAAgC,EACtC,OAAO,EAAE,IAAI,CAAC,gBAAgB,IAE9B,4DACE,KAAK,EAAC,8BAA8B,EACpC,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,YAAY,IAE5B,8DAAO,EAAE,EAAC,YAAY,yCAEd,EACR,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,OAAO,kBACD,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftCore"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.module.scss?tag=searchcraft-input-form","src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":[".searchcraft-input-grid {\n display: grid;\n gap: 4px 8px;\n}\n\n.searchcraft-input-grid-buttonLeft {\n grid-template-rows: repeat(3, auto);\n grid-template-columns: auto 1fr;\n\n & .searchcraft-input-button-wrapper {\n grid-column: 1 / span 1;\n grid-row: 2 / span 1;\n }\n\n & .searchcraft-input-label-wrapper {\n grid-column: 2 / span 1;\n grid-row: 1 / span 1;\n }\n\n & .searchcraft-input-error-wrapper {\n grid-column: 2 / span 1;\n grid-row: 3 / span 1;\n }\n\n & .searchcraft-input-wrapper {\n grid-column: 2 / span 1;\n grid-row: 2 / span 1;\n }\n}\n\n.searchcraft-input-grid-buttonRight {\n grid-template-rows: repeat(3, auto);\n grid-template-columns: 1fr auto;\n\n & .searchcraft-input-button-wrapper {\n grid-column: 2 / span 1;\n grid-row: 2 / span 1;\n }\n\n & .searchcraft-input-label-wrapper {\n grid-column: 1 / span 1;\n grid-row: 1 / span 1;\n }\n\n & .searchcraft-input-error-wrapper {\n grid-column: 1 / span 1;\n grid-row: 3 / span 1;\n }\n\n & .searchcraft-input-wrapper {\n grid-column: 1 / span 1;\n grid-row: 2 / span 1;\n }\n}\n\n.searchcraft-input-grid-buttonNone {\n grid-template-rows: repeat(3, auto);\n grid-template-columns: auto;\n\n & .searchcraft-input-button-wrapper {\n display: none;\n }\n\n & .searchcraft-input-label-wrapper {\n grid-column: 1 / span 1;\n grid-row: 1 / span 1;\n }\n\n & .searchcraft-input-error-wrapper {\n grid-column: 1 / span 1;\n grid-row: 3 / span 1;\n }\n\n & .searchcraft-input-wrapper {\n grid-column: 1 / span 1;\n grid-row: 2 / span 1;\n }\n}\n\n.searchcraft-input-wrapper {\n position: relative;\n display: flex;\n}\n\n.searchcraft-input {\n @include body();\n background-color: var(--sc-surface-neutral-secondary);\n border-radius: var(--sc-input-border-radius);\n border: none;\n color: var(--sc-content-neutral-primary);\n outline: none;\n padding-left: var(--sc-input-padding-left);\n padding-right: var(--sc-input-padding-right);\n padding-top: 12px;\n padding-bottom: 12px;\n flex: 1;\n\n &::placeholder {\n color: var(--sc-content-disabled);\n }\n\n &:focus {\n outline: var(--sc-border-brand) solid 2px;\n }\n\n &:focus::placeholder {\n opacity: 0;\n }\n}\n\n.searchcraft-input.error {\n color: var(--sc-content-danger);\n outline: var(--sc-border-danger) solid 2px;\n\n &:focus {\n outline: var(--sc-border-danger) solid 2px;\n }\n}\n\n.searchcraft-input-search-icon-wrapper {\n align-items: center;\n justify-content: center;\n display: flex;\n position: absolute;\n pointer-events: none;\n bottom: 0;\n left: 0;\n top: 0;\n width: var(--sc-input-padding-left);\n}\n\n.searchcraft-input-search-icon {\n pointer-events: none;\n width: var(--sc-input-search-icon-size);\n height: var(--sc-input-search-icon-size);\n}\n\n.searchcraft-input-clear-button {\n all: unset;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n display: flex;\n position: absolute;\n border: none;\n outline: none;\n bottom: 0;\n right: 0;\n top: 0;\n width: var(--sc-input-padding-right);\n}\n\n.searchcraft-input-clear-icon {\n width: var(--sc-input-clear-icon-size);\n height: var(--sc-input-clear-icon-size);\n}\n","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\nexport interface ScInputCustomEvent<T> extends CustomEvent<T> {\n detail: T;\n target: HTMLSearchcraftInputFormElement;\n}\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 styleUrl: 'searchcraft-input-form.module.scss',\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 if (this.inputCleared) {\n this.inputCleared.emit();\n }\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"],"version":3}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-6cafd48d.js';
|
|
2
|
+
import { g as getDocumentValueFromSearchResultMapping } from './p-755f491b.js';
|
|
3
|
+
import { d as defineCustomElement$1 } from './p-1ae87308.js';
|
|
4
|
+
|
|
5
|
+
const searchcraftPopoverListViewModuleCss = "";
|
|
6
|
+
const SearchcraftPopoverListViewStyle0 = searchcraftPopoverListViewModuleCss;
|
|
7
|
+
|
|
8
|
+
const SearchcraftPopoverListView = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverListView extends H {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
}
|
|
13
|
+
renderDocument(document, index) {
|
|
14
|
+
/**
|
|
15
|
+
* Index field values -> Result container props mappings.
|
|
16
|
+
*/
|
|
17
|
+
const titleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings.title);
|
|
18
|
+
const subtitleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings.subtitle);
|
|
19
|
+
const href = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings.href);
|
|
20
|
+
const imageSource = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings.imageSource);
|
|
21
|
+
const imageAlt = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings.imageAlt);
|
|
22
|
+
return (h("searchcraft-popover-list-item", { key: `${document.document_id}-${index}`, "title-content": titleContent, "subtitle-content": subtitleContent, "image-src": imageSource, "image-alt": imageAlt, href: href, "document-position": index }));
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
var _a;
|
|
26
|
+
return (h("div", { key: '6e9017370d7079412d6d31fb439be599d689c9c2', class: 'searchcraft-popover-list-view' }, (_a = this.documents) === null || _a === void 0 ? void 0 : _a.map((document, index) => this.renderDocument(document, index))));
|
|
27
|
+
}
|
|
28
|
+
static get style() { return SearchcraftPopoverListViewStyle0; }
|
|
29
|
+
}, [0, "searchcraft-popover-list-view", {
|
|
30
|
+
"popoverResultMappings": [16],
|
|
31
|
+
"documents": [16]
|
|
32
|
+
}]);
|
|
33
|
+
function defineCustomElement() {
|
|
34
|
+
if (typeof customElements === "undefined") {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const components = ["searchcraft-popover-list-view", "searchcraft-popover-list-item"];
|
|
38
|
+
components.forEach(tagName => { switch (tagName) {
|
|
39
|
+
case "searchcraft-popover-list-view":
|
|
40
|
+
if (!customElements.get(tagName)) {
|
|
41
|
+
customElements.define(tagName, SearchcraftPopoverListView);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case "searchcraft-popover-list-item":
|
|
45
|
+
if (!customElements.get(tagName)) {
|
|
46
|
+
defineCustomElement$1();
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
} });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { SearchcraftPopoverListView as S, defineCustomElement as d };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=p-e1cf5f9d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-e1cf5f9d.js","mappings":";;;;AAAA,MAAM,mCAAmC,GAAG,EAAE,CAAC;AAC/C,yCAAe,mCAAmC;;MCmBrC,0BAA0B;;;;;IAWrC,cAAc,CAAC,QAAiC,EAAE,KAAa;;;;QAI7D,MAAM,YAAY,GAAG,uCAAuC,CAC1D,QAAQ,EACR,IAAI,CAAC,qBAAqB,CAAC,KAAK,CACjC,CAAC;QACF,MAAM,eAAe,GAAG,uCAAuC,CAC7D,QAAQ,EACR,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CACpC,CAAC;QACF,MAAM,IAAI,GAAG,uCAAuC,CAClD,QAAQ,EACR,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAChC,CAAC;QACF,MAAM,WAAW,GAAG,uCAAuC,CACzD,QAAQ,EACR,IAAI,CAAC,qBAAqB,CAAC,WAAW,CACvC,CAAC;QACF,MAAM,QAAQ,GAAG,uCAAuC,CACtD,QAAQ,EACR,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CACpC,CAAC;QAEF,QACE,qCACE,GAAG,EAAE,GAAG,QAAQ,CAAC,WAAW,IAAI,KAAK,EAAE,mBACxB,YAAY,sBACT,eAAe,eACtB,WAAW,eACX,QAAQ,EACnB,IAAI,EAAE,IAAI,uBACS,KAAK,GACxB,EACF;KACH;IAED,MAAM;;QACJ,QACE,4DAAK,KAAK,EAAC,+BAA+B,IACvC,MAAA,IAAI,CAAC,SAAS,0CAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KACnC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CACrC,CACG,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.module.scss?tag=searchcraft-popover-list-view","src/components/searchcraft-popover-list-view/searchcraft-popover-list-view.tsx"],"sourcesContent":["","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 styleUrl: 'searchcraft-popover-list-view.module.scss',\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}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-6cafd48d.js';
|
|
2
|
+
|
|
3
|
+
const searchcraftErrorMessageModuleCss = ":root{--sc-input-border-radius:8px;--sc-input-search-icon-size:20px;--sc-input-clear-icon-size:20px;--sc-input-padding-left:44px;--sc-input-padding-right:44px;--sc-image-border-radius:8px;--sc-popover-form-border-radius:8px;--sc-popover-list-view-height:400px;--sc-popover-list-item-image-size:60px;--sc-popover-list-item-padding-horizontal:8px;--sc-popover-list-item-padding-vertical:8px;--sc-popover-modal-max-width:570px}:root{--sc-surface-disabled:#D9D9D9;--sc-surface-neutral-primary:#FFFFFF;--sc-surface-neutral-secondary:#F3F3F3;--sc-surface-neutral-light:#FFFFFF;--sc-surface-neutral-primary-hover:#FAFAFA;--sc-surface-neutral-primary-active:#F7F7F7;--sc-surface-neutral-secondary-hover:#EDEDED;--sc-surface-neutral-secondary-active:#E6E6E6;--sc-surface-brand-primary:#000000;--sc-surface-brand-secondary:#E6E6E6;--sc-surface-brand-primary-hover:#2E2E2E;--sc-surface-brand-primary-active:#292929;--sc-surface-brand-secondary-hover:#EBEBEB;--sc-surface-brand-secondary-active:#E0E0E0;--sc-surface-success-primary:#008000;--sc-surface-success-secondary:#CCFFCC;--sc-surface-success-primary-hover:#009900;--sc-surface-success-primary-active:#006600;--sc-surface-success-secondary-hover:#E6FFE6;--sc-surface-success-secondary-active:#E6FFE6;--sc-surface-caution-primary:#CC6600;--sc-surface-caution-secondary:#FFD9B3;--sc-surface-caution-primary-hover:#E57300;--sc-surface-caution-primary-active:#B25A00;--sc-surface-caution-secondary-hover:#FFE5CC;--sc-surface-caution-secondary-active:#FFCC99;--sc-surface-danger-primary:#CC0000;--sc-surface-danger-secondary:#FFCCCC;--sc-surface-danger-primary-hover:#E50000;--sc-surface-danger-primary-active:#B30000;--sc-surface-danger-secondary-hover:#FFE7E7;--sc-surface-danger-secondary-active:#FFB3B3;--sc-content-brand:#000000;--sc-content-success:#008000;--sc-content-caution:#994D00;--sc-content-danger:#990000;--sc-content-disabled:#737373;--sc-content-neutral-primary:#292929;--sc-content-neutral-secondary:#404040;--sc-content-brand-on-primary:#FFFFFF;--sc-content-success-on-primary:#FFFFFF;--sc-content-caution-on-primary:#FFFFFF;--sc-content-danger-on-primary:#FFFFFF;--sc-content-disabled-on-disabled:#737373;--sc-border-neutral:rgba(0,0,0, 0.1);--sc-border-brand:#000000;--sc-border-success:#008000;--sc-border-caution:#CC6600;--sc-border-danger:#CC0000;--sc-border-disabled:#737373}:root{--sc-font-family:sans-serif;--sc-heading-1-font-size:32px;--sc-heading-1-line-height:36px;--sc-heading-1-font-weight:700;--sc-heading-2-font-size:29px;--sc-heading-2-line-height:32px;--sc-heading-2-font-weight:700;--sc-heading-3-font-size:26px;--sc-heading-3-line-height:28px;--sc-heading-3-font-weight:700;--sc-heading-4-font-size:23px;--sc-heading-4-line-height:24px;--sc-heading-4-font-weight:700;--sc-heading-5-font-size:20px;--sc-heading-5-line-height:24px;--sc-heading-5-font-weight:700;--sc-heading-6-font-size:10px;--sc-heading-6-line-height:12px;--sc-heading-6-font-weight:700;--sc-body-bold-font-size:16px;--sc-body-bold-line-height:20px;--sc-body-bold-font-weight:700;--sc-body-font-size:16px;--sc-body-line-height:20px;--sc-body-font-weight:400;--sc-body-small-bold-font-size:12px;--sc-body-small-bold-line-height:16px;--sc-body-small-bold-font-weight:700;--sc-body-small-font-size:12px;--sc-body-small-line-height:16px;--sc-body-small-font-weight:400}:root{--sc-breakpoint-sm:576px;--sc-breakpoint-md:768px;--sc-breakpoint-lg:992px}.searchcraft-error-message{font-family:var(--sc-font-family);-webkit-font-smoothing:antialiased;font-size:var(--sc-body-small-font-size);font-weight:var(--sc-body-small-font-weight);line-height:var(--sc-body-small-line-height);color:var(--sc-content-danger);margin:0}";
|
|
4
|
+
const SearchcraftErrorMessageStyle0 = searchcraftErrorMessageModuleCss;
|
|
5
|
+
|
|
6
|
+
const SearchcraftErrorMessage = /*@__PURE__*/ proxyCustomElement(class SearchcraftErrorMessage extends H {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
return (h("p", { key: '5bdc428adf6f239d66a9b0f946ee6e582de41e86', class: 'searchcraft-error-message' }, this.errorMessage || 'Search term is required.'));
|
|
13
|
+
}
|
|
14
|
+
static get style() { return SearchcraftErrorMessageStyle0; }
|
|
15
|
+
}, [0, "searchcraft-error-message", {
|
|
16
|
+
"errorMessage": [1, "error-message"]
|
|
17
|
+
}]);
|
|
18
|
+
function defineCustomElement() {
|
|
19
|
+
if (typeof customElements === "undefined") {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const components = ["searchcraft-error-message"];
|
|
23
|
+
components.forEach(tagName => { switch (tagName) {
|
|
24
|
+
case "searchcraft-error-message":
|
|
25
|
+
if (!customElements.get(tagName)) {
|
|
26
|
+
customElements.define(tagName, SearchcraftErrorMessage);
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
} });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { SearchcraftErrorMessage as S, defineCustomElement as d };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=p-f5a06210.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-f5a06210.js","mappings":";;AAAA,MAAM,gCAAgC,GAAG,4kHAA4kH,CAAC;AACtnH,sCAAe,gCAAgC;;MCelC,uBAAuB;;;;;IAMlC,MAAM;QACJ,QACE,0DAAG,KAAK,EAAC,2BAA2B,IACjC,IAAI,CAAC,YAAY,IAAI,0BAA0B,CAC9C,EACJ;KACH;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-error-message/searchcraft-error-message.module.scss?tag=searchcraft-error-message","src/components/searchcraft-error-message/searchcraft-error-message.tsx"],"sourcesContent":[".searchcraft-error-message {\n @include body-small();\n color: var(--sc-content-danger);\n margin: 0;\n}\n","import { Component, Prop, h } from '@stencil/core';\n\n/**\n * This web component is designed to display a user-friendly error message when a search query fails, providing clear feedback to users and enhancing their experience when an issue arises during the search process.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-error-message error-message=\"No search results found for query\" />\n * ```\n */\n@Component({\n tag: 'searchcraft-error-message',\n styleUrl: 'searchcraft-error-message.module.scss',\n shadow: false,\n})\nexport class SearchcraftErrorMessage {\n /**\n * The error message.\n */\n @Prop() errorMessage?: string;\n\n render() {\n return (\n <p class='searchcraft-error-message'>\n {this.errorMessage || 'Search term is required.'}\n </p>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftBaseSearchResult$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftBaseSearchResult$1, d as defineCustomElement$1 } from './p-87d1611b.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftBaseSearchResult = SearchcraftBaseSearchResult$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { p as proxyCustomElement, H, c as createEvent, h } from './p-
|
|
2
|
-
import { u as useSearchcraftStore } from './p-
|
|
3
|
-
import { g as getDocumentValueFromSearchResultMapping
|
|
4
|
-
import {
|
|
5
|
-
import { d as defineCustomElement$
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-6cafd48d.js';
|
|
2
|
+
import { u as useSearchcraftStore } from './p-01dc5b3b.js';
|
|
3
|
+
import { g as getDocumentValueFromSearchResultMapping } from './p-755f491b.js';
|
|
4
|
+
import { s as serializeStyles } from './p-d9551738.js';
|
|
5
|
+
import { d as defineCustomElement$3 } from './p-87d1611b.js';
|
|
6
|
+
import { d as defineCustomElement$2 } from './p-f5a06210.js';
|
|
6
7
|
|
|
7
|
-
const searchcraftBaseSearchResultsModuleCss = ":root{--sc-
|
|
8
|
+
const searchcraftBaseSearchResultsModuleCss = ":root{--sc-input-border-radius:8px;--sc-input-search-icon-size:20px;--sc-input-clear-icon-size:20px;--sc-input-padding-left:44px;--sc-input-padding-right:44px;--sc-image-border-radius:8px;--sc-popover-form-border-radius:8px;--sc-popover-list-view-height:400px;--sc-popover-list-item-image-size:60px;--sc-popover-list-item-padding-horizontal:8px;--sc-popover-list-item-padding-vertical:8px;--sc-popover-modal-max-width:570px}:root{--sc-surface-disabled:#D9D9D9;--sc-surface-neutral-primary:#FFFFFF;--sc-surface-neutral-secondary:#F3F3F3;--sc-surface-neutral-light:#FFFFFF;--sc-surface-neutral-primary-hover:#FAFAFA;--sc-surface-neutral-primary-active:#F7F7F7;--sc-surface-neutral-secondary-hover:#EDEDED;--sc-surface-neutral-secondary-active:#E6E6E6;--sc-surface-brand-primary:#000000;--sc-surface-brand-secondary:#E6E6E6;--sc-surface-brand-primary-hover:#2E2E2E;--sc-surface-brand-primary-active:#292929;--sc-surface-brand-secondary-hover:#EBEBEB;--sc-surface-brand-secondary-active:#E0E0E0;--sc-surface-success-primary:#008000;--sc-surface-success-secondary:#CCFFCC;--sc-surface-success-primary-hover:#009900;--sc-surface-success-primary-active:#006600;--sc-surface-success-secondary-hover:#E6FFE6;--sc-surface-success-secondary-active:#E6FFE6;--sc-surface-caution-primary:#CC6600;--sc-surface-caution-secondary:#FFD9B3;--sc-surface-caution-primary-hover:#E57300;--sc-surface-caution-primary-active:#B25A00;--sc-surface-caution-secondary-hover:#FFE5CC;--sc-surface-caution-secondary-active:#FFCC99;--sc-surface-danger-primary:#CC0000;--sc-surface-danger-secondary:#FFCCCC;--sc-surface-danger-primary-hover:#E50000;--sc-surface-danger-primary-active:#B30000;--sc-surface-danger-secondary-hover:#FFE7E7;--sc-surface-danger-secondary-active:#FFB3B3;--sc-content-brand:#000000;--sc-content-success:#008000;--sc-content-caution:#994D00;--sc-content-danger:#990000;--sc-content-disabled:#737373;--sc-content-neutral-primary:#292929;--sc-content-neutral-secondary:#404040;--sc-content-brand-on-primary:#FFFFFF;--sc-content-success-on-primary:#FFFFFF;--sc-content-caution-on-primary:#FFFFFF;--sc-content-danger-on-primary:#FFFFFF;--sc-content-disabled-on-disabled:#737373;--sc-border-neutral:rgba(0,0,0, 0.1);--sc-border-brand:#000000;--sc-border-success:#008000;--sc-border-caution:#CC6600;--sc-border-danger:#CC0000;--sc-border-disabled:#737373}:root{--sc-font-family:sans-serif;--sc-heading-1-font-size:32px;--sc-heading-1-line-height:36px;--sc-heading-1-font-weight:700;--sc-heading-2-font-size:29px;--sc-heading-2-line-height:32px;--sc-heading-2-font-weight:700;--sc-heading-3-font-size:26px;--sc-heading-3-line-height:28px;--sc-heading-3-font-weight:700;--sc-heading-4-font-size:23px;--sc-heading-4-line-height:24px;--sc-heading-4-font-weight:700;--sc-heading-5-font-size:20px;--sc-heading-5-line-height:24px;--sc-heading-5-font-weight:700;--sc-heading-6-font-size:10px;--sc-heading-6-line-height:12px;--sc-heading-6-font-weight:700;--sc-body-bold-font-size:16px;--sc-body-bold-line-height:20px;--sc-body-bold-font-weight:700;--sc-body-font-size:16px;--sc-body-line-height:20px;--sc-body-font-weight:400;--sc-body-small-bold-font-size:12px;--sc-body-small-bold-line-height:16px;--sc-body-small-bold-font-weight:700;--sc-body-small-font-size:12px;--sc-body-small-line-height:16px;--sc-body-small-font-weight:400}:root{--sc-breakpoint-sm:576px;--sc-breakpoint-md:768px;--sc-breakpoint-lg:992px}.searchcraft-search-results-container{display:flex;flex-direction:column;justify-content:center;gap:16px}.searchcraft-ad-section{align-items:center;background-color:#F1F1F1;border-radius:16px;display:flex;flex-direction:column;font-size:16px;justify-content:center;min-height:176px;text-align:center}.searchcraft-ad-section p{margin:0;color:var(--sc-content-disabled)}.searchcraft-search-results-empty-state-container{text-align:center}.searchcraft-search-results-error-message-container{text-align:center}";
|
|
8
9
|
const SearchcraftBaseSearchResultsStyle0 = searchcraftBaseSearchResultsModuleCss;
|
|
9
10
|
|
|
10
11
|
const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftBaseSearchResults extends H {
|
|
@@ -12,17 +13,30 @@ const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class Se
|
|
|
12
13
|
super();
|
|
13
14
|
this.__registerHost();
|
|
14
15
|
this.noResults = createEvent(this, "noResults", 7);
|
|
16
|
+
/**
|
|
17
|
+
* How often ads are injected.
|
|
18
|
+
*/
|
|
15
19
|
this.adInterval = 4;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Should an ad be placed at the end of the results.
|
|
22
|
+
*/
|
|
18
23
|
this.placeAdAtEnd = false;
|
|
24
|
+
/**
|
|
25
|
+
* Should an ad be placed at the start of the results.
|
|
26
|
+
*/
|
|
19
27
|
this.placeAdAtStart = true;
|
|
28
|
+
/**
|
|
29
|
+
* The placement of the image for each result.
|
|
30
|
+
*/
|
|
20
31
|
this.resultImagePlacement = 'right';
|
|
21
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Where to open the link for the button rendered when containerHref is not present for each result.
|
|
34
|
+
*/
|
|
22
35
|
this.buttonTarget = '_blank';
|
|
23
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Where to open the link for the containing element for each result.
|
|
38
|
+
*/
|
|
24
39
|
this.containerTarget = '_blank';
|
|
25
|
-
this.containerRel = undefined;
|
|
26
40
|
this.hasSearched = false;
|
|
27
41
|
this.query = '';
|
|
28
42
|
this.searchResults = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-base-search-results.js","mappings":";;;;;;AAAA,MAAM,qCAAqC,GAAG,qhHAAqhH,CAAC;AACpkH,2CAAe,qCAAqC;;MCuBvCA,8BAA4B;;;;;0BAClB,CAAC;;;4BAMC,KAAK;8BACH,IAAI;oCACo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Ae,EACf,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YACpB,CAAA,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,IAAI,0CAAE,MAAM,MAAK,CAAC,KAC1C,WAAK,KAAK,EAAC,oDAAoD,IAC7D,kDACiB,gCAAgC,IAAI,CAAC,KAAK,SAAS,GAClE,CACE,CACP,CACC,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftBaseSearchResults"],"sources":["src/components/searchcraft-base-search-results/searchcraft-base-search-results.module.scss?tag=searchcraft-base-search-results","src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"sourcesContent":[".searchcraft-search-results-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 16px;\n}\n\n.searchcraft-ad-section {\n align-items: center;\n background-color: #F1F1F1;\n border-radius: 16px;\n display: flex;\n flex-direction: column;\n font-size: 16px;\n justify-content: center;\n min-height: 176px;\n text-align: center;\n\n p {\n margin: 0;\n color: var(--sc-content-disabled);\n }\n}\n\n.searchcraft-search-results-empty-state-container {\n text-align: center;\n}\n\n.searchcraft-search-results-error-message-container {\n text-align: center;\n}\n","import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils/utils';\nimport type { SearchResultMappings } from 'types';\n\n@Component({\n tag: 'searchcraft-base-search-results',\n styleUrl: 'searchcraft-base-search-results.module.scss',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n @Prop() adInterval = 4;\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n @Prop() placeAdAtEnd = false;\n @Prop() placeAdAtStart = true;\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n @Prop() buttonLabel: string | undefined;\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n @Event() noResults: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void;\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults };\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.footer,\n );\n\n const serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n });\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-base-search-results.js","mappings":";;;;;;;AAAA,MA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B,EAAC,KAAK,EAAC,wBAAwB,IACtD,0BAAiB,CACb,CACP,CAAC;SACH;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAA,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,IAAI,0CAAE,MAAM,MAAK,CAAC,EAAE;YACzE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;SACvB;QAED,QACE,WAAK,KAAK,EAAC,sCAAsC,IAC9C,eAAe,EACf,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YACpB,CAAA,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,IAAI,0CAAE,MAAM,MAAK,CAAC,KAC1C,WAAK,KAAK,EAAC,oDAAoD,IAC7D,kDACiB,gCAAgC,IAAI,CAAC,KAAK,SAAS,GAClE,CACE,CACP,CACC,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftBaseSearchResults"],"sources":["src/components/searchcraft-base-search-results/searchcraft-base-search-results.module.scss?tag=searchcraft-base-search-results","src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"sourcesContent":[".searchcraft-search-results-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 16px;\n}\n\n.searchcraft-ad-section {\n align-items: center;\n background-color: #F1F1F1;\n border-radius: 16px;\n display: flex;\n flex-direction: column;\n font-size: 16px;\n justify-content: center;\n min-height: 176px;\n text-align: center;\n\n p {\n margin: 0;\n color: var(--sc-content-disabled);\n }\n}\n\n.searchcraft-search-results-empty-state-container {\n text-align: center;\n}\n\n.searchcraft-search-results-error-message-container {\n text-align: center;\n}\n","import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils';\nimport type { SearchResultMappings } from 'types';\n\n/**\n * This web component is responsible for displaying the results of a search query.\n * Once a query is submitted, the component formats and presents an ordered list of the results.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-base-search-results\n * ad-interval=\"4\"\n * place-ad-at-start=\"false\"\n * result-image-placement=\"right\"\n * />\n * ```\n *\n * ```js\n * // index.js\n * const baseSearchResults = document.querySelector('searchcraft-base-search-results');\n *\n * baseSearchResults.searchResultMappings = containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n *\n * baseSearchResults.addEventListener('noResults', () => {\n * console.log('No search results found');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-base-search-results',\n styleUrl: 'searchcraft-base-search-results.module.scss',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n /**\n * How often ads are injected.\n */\n @Prop() adInterval = 4;\n /**\n * A custom styles object.\n */\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n /**\n * Formats the content rendered for each result.\n */\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n /**\n * Should an ad be placed at the end of the results.\n */\n @Prop() placeAdAtEnd = false;\n /**\n * Should an ad be placed at the start of the results.\n */\n @Prop() placeAdAtStart = true;\n /**\n * The placement of the image for each result.\n */\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n /**\n * The label for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * Where to open the link for the containing element for each result.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element for each result.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n /**\n * When no results are returned.\n */\n @Event() noResults: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void;\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults };\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.footer,\n );\n\n const serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n });\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftButton$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftButton$1, d as defineCustomElement$1 } from './p-cf096782.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftButton = SearchcraftButton$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftErrorMessage$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftErrorMessage$1, d as defineCustomElement$1 } from './p-f5a06210.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftErrorMessage = SearchcraftErrorMessage$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-649654b5.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftFacetList = SearchcraftFacetList$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|