@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,268 @@
|
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h, F as Fragment } from './p-6cafd48d.js';
|
|
2
|
+
import { c as classNames } from './p-5cdc6210.js';
|
|
3
|
+
import { u as useSearchcraftStore } from './p-01dc5b3b.js';
|
|
4
|
+
|
|
5
|
+
function deepMergeWithSpread(obj1, obj2) {
|
|
6
|
+
const result = Object.assign({}, obj1);
|
|
7
|
+
for (const key in obj2) {
|
|
8
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
|
|
9
|
+
if (obj2.hasOwnProperty(key)) {
|
|
10
|
+
if (obj2[key] instanceof Object && obj1[key] instanceof Object) {
|
|
11
|
+
result[key] = deepMergeWithSpread(obj1[key], obj2[key]);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
result[key] = obj2[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Given an array of facet paths, removes parent facet paths.
|
|
22
|
+
*/
|
|
23
|
+
function removeSubstringMatches(arr) {
|
|
24
|
+
return arr.filter((entry, index, array) => !array.some((otherEntry, otherIndex) => otherIndex !== index && otherEntry.includes(entry)));
|
|
25
|
+
}
|
|
26
|
+
function facetToRecord(facet) {
|
|
27
|
+
const records = {};
|
|
28
|
+
const traverseAndAddToFragments = (facetChild) => {
|
|
29
|
+
var _a;
|
|
30
|
+
records[facetChild.path] = {
|
|
31
|
+
count: facetChild.count,
|
|
32
|
+
path: facetChild.path,
|
|
33
|
+
};
|
|
34
|
+
(_a = facetChild.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
|
|
35
|
+
traverseAndAddToFragments(child);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
traverseAndAddToFragments(facet);
|
|
39
|
+
return records;
|
|
40
|
+
}
|
|
41
|
+
function recordToObject(record) {
|
|
42
|
+
const root = {
|
|
43
|
+
count: 0,
|
|
44
|
+
path: '/',
|
|
45
|
+
children: {},
|
|
46
|
+
};
|
|
47
|
+
Object.keys(record).forEach((key) => {
|
|
48
|
+
const fragment = record[key];
|
|
49
|
+
if (fragment.path === '/') {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const pathParts = fragment.path.substring(1).split('/');
|
|
53
|
+
let currentRoot = root;
|
|
54
|
+
let currentPath = '';
|
|
55
|
+
pathParts.forEach((part, index) => {
|
|
56
|
+
const nextPath = `${currentPath}/${part}`;
|
|
57
|
+
if (!currentRoot.children[nextPath]) {
|
|
58
|
+
currentRoot.children[nextPath] = {
|
|
59
|
+
count: 0,
|
|
60
|
+
path: nextPath,
|
|
61
|
+
children: {},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (index === pathParts.length - 1) {
|
|
65
|
+
currentRoot.children[nextPath].count = fragment.count;
|
|
66
|
+
}
|
|
67
|
+
currentPath = nextPath;
|
|
68
|
+
currentRoot = currentRoot.children[nextPath];
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return root;
|
|
72
|
+
}
|
|
73
|
+
function objectToFacet(childObject) {
|
|
74
|
+
const transformed = {
|
|
75
|
+
count: childObject.count,
|
|
76
|
+
path: childObject.path,
|
|
77
|
+
children: [],
|
|
78
|
+
};
|
|
79
|
+
if (Object.keys(childObject.children).length > 0) {
|
|
80
|
+
transformed.children = Object.values(childObject.children).map((subChildObject) => objectToFacet(subChildObject));
|
|
81
|
+
}
|
|
82
|
+
return transformed;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Filters records with the parent paths from record2 OUT of record1
|
|
86
|
+
*/
|
|
87
|
+
function filterRecordByParentPaths(record1, record2) {
|
|
88
|
+
// Extract all paths (keys) both records
|
|
89
|
+
const paths1 = Object.keys(record1);
|
|
90
|
+
const paths2 = Object.keys(record2);
|
|
91
|
+
// Find all parent paths in record2
|
|
92
|
+
const parentPaths = new Set(paths2
|
|
93
|
+
.filter((path) => path.split('/').length > 2) // Only consider paths with more than one level
|
|
94
|
+
.map((path) => path.substring(0, path.lastIndexOf('/'))));
|
|
95
|
+
// Filter out keys in record1 that share a parent path with any of the identified parent paths
|
|
96
|
+
const filteredRecord = Object.fromEntries(paths1
|
|
97
|
+
.filter((path) => !parentPaths.has(path.substring(0, path.lastIndexOf('/'))))
|
|
98
|
+
.map((path) => [path, record1[path]]));
|
|
99
|
+
return filteredRecord;
|
|
100
|
+
}
|
|
101
|
+
function mergeFacetRoots(fieldName, currentRoot, incomingRoot) {
|
|
102
|
+
const currentArray = currentRoot[fieldName];
|
|
103
|
+
const incomingArray = incomingRoot[fieldName];
|
|
104
|
+
const currentRootFacetChild = {
|
|
105
|
+
count: 0,
|
|
106
|
+
path: '/',
|
|
107
|
+
children: currentArray,
|
|
108
|
+
};
|
|
109
|
+
const incomingRootFacetChild = {
|
|
110
|
+
count: 0,
|
|
111
|
+
path: '/',
|
|
112
|
+
children: incomingArray,
|
|
113
|
+
};
|
|
114
|
+
// Flatten them into records
|
|
115
|
+
const currentRecord = facetToRecord(currentRootFacetChild);
|
|
116
|
+
const incomingRecord = facetToRecord(incomingRootFacetChild);
|
|
117
|
+
// Filter out the records from record1 (the current set of records)
|
|
118
|
+
// that share a parent path with record2 (the incoming records)
|
|
119
|
+
const filteredCurrentRecord = filterRecordByParentPaths(currentRecord, incomingRecord);
|
|
120
|
+
// Deep merge the records together
|
|
121
|
+
const mergedRecord = deepMergeWithSpread(filteredCurrentRecord, incomingRecord);
|
|
122
|
+
// Convert into a heirarchical object
|
|
123
|
+
const mergedObject = recordToObject(mergedRecord);
|
|
124
|
+
// Convert the heirarchical object back to the Facet child structure
|
|
125
|
+
const mergedFacetChild = objectToFacet(mergedObject);
|
|
126
|
+
return {
|
|
127
|
+
[fieldName]: mergedFacetChild.children,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const searchcraftFacetListModuleCss = ":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}.filtersListContainer{width:100%}.filterCheckboxLabel{align-items:center;color:var(--sc-content-primary);display:flex;font-family:var(--sc-font-family);font-size:14px;font-weight:600;gap:14px;position:relative;-webkit-font-smoothing:antialiased}.filterCheckboxLabel input[type=checkbox]{align-items:center;appearance:none;background-color:var(--sc-surface-brand-secondary-hover);border:1px solid var(--sc-surface-disabled);border-radius:8px;cursor:pointer;display:flex;height:24px;justify-content:center;width:24px}.filterCheckboxLabel input[type=checkbox]:focus{outline:2px solid var(--sc-surface-brand-primary)}.filterCheckboxLabel input[type=checkbox]:checked{background-color:var(--sc-surface-brand-primary);position:relative}.filterCheckboxLabel input[type=checkbox]:checked+.checkContainer{display:block}.filterCheckboxLabel input[type=checkbox]:checked+.dashContainer{display:block}.childFilterCheckboxLabel{align-items:center;color:var(--sc-content-primary);display:flex;font-family:var(--sc-font-family);font-size:14px;font-weight:600;gap:12px;margin-left:24px;position:relative}.childFilterCheckboxLabel input[type=checkbox]{align-items:center;appearance:none;background-color:var(--sc-surface-brand-secondary-hover);border:1px solid var(--sc-surface-disabled);border-radius:8px;cursor:pointer;display:flex;height:24px;justify-content:center;position:relative;width:24px;-webkit-font-smoothing:antialiased}.childFilterCheckboxLabel input[type=checkbox]:focus{outline:2px solid var(--sc-surface-brand-primary)}.childFilterCheckboxLabel input[type=checkbox]:checked{background-color:var(--sc-surface-brand-primary);position:relative}.childFilterCheckboxLabel input[type=checkbox]:checked+.checkContainer{display:block}.childFilterCheckboxLabel input[type=checkbox]:checked+.dashContainer{display:block}.checkContainer{display:none;height:16px;width:16px;position:absolute;top:9px;left:8px}.dashContainer{display:none;height:3px;width:14px;position:absolute;top:3px;left:9px}.searchcraft-facet-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-disabled);text-align:center}";
|
|
132
|
+
const SearchcraftFacetListStyle0 = searchcraftFacetListModuleCss;
|
|
133
|
+
|
|
134
|
+
const SearchcraftFacetList = /*@__PURE__*/ proxyCustomElement(class SearchcraftFacetList extends H {
|
|
135
|
+
constructor() {
|
|
136
|
+
super();
|
|
137
|
+
this.__registerHost();
|
|
138
|
+
this.facetSelectionUpdated = createEvent(this, "facetSelectionUpdated", 7);
|
|
139
|
+
this.selectedPaths = {};
|
|
140
|
+
this.hasNewSearchTerm = false;
|
|
141
|
+
this.searchStore = useSearchcraftStore.getState();
|
|
142
|
+
this.formatLabel = (facetChild) => {
|
|
143
|
+
const label = facetChild.path.replace(/^\//, '');
|
|
144
|
+
const count = facetChild.count;
|
|
145
|
+
return `${label.replace(/-/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase())} (${count})`;
|
|
146
|
+
};
|
|
147
|
+
this.formatSubLabel = (facetChild, facetChildAncestor) => {
|
|
148
|
+
const facetChildPath = facetChild.path.substring(facetChildAncestor.path.length);
|
|
149
|
+
const label = facetChildPath.replace(/^\//, '');
|
|
150
|
+
const count = facetChild.count;
|
|
151
|
+
return `${label.replace(/-/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase())} (${count})`;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
handleStateUpdate(state) {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
const facetPrime = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data.facets;
|
|
157
|
+
const timeTaken = (_b = state.searchResults) === null || _b === void 0 ? void 0 : _b.data.time_taken;
|
|
158
|
+
/** Things to do when the state's search term has changed, but before the response received */
|
|
159
|
+
if (state.query !== this.lastQuery ||
|
|
160
|
+
state.searchMode !== this.lastSearchMode ||
|
|
161
|
+
state.sortType !== this.lastSortType) {
|
|
162
|
+
this.selectedPaths = {};
|
|
163
|
+
this.hasNewSearchTerm = true;
|
|
164
|
+
}
|
|
165
|
+
/** Things to do when a new response with a new facet prime has been received */
|
|
166
|
+
if (timeTaken !== this.lastTimeTaken && facetPrime) {
|
|
167
|
+
this.facetRoot = undefined;
|
|
168
|
+
const incomingFacetRoot = facetPrime.find((facet) => this.fieldName === Object.keys(facet)[0]);
|
|
169
|
+
/** Data is from a new search term: completely override our facets */
|
|
170
|
+
if (this.hasNewSearchTerm) {
|
|
171
|
+
this.baseFacetRoot = incomingFacetRoot;
|
|
172
|
+
this.facetRoot = incomingFacetRoot;
|
|
173
|
+
this.hasNewSearchTerm = false;
|
|
174
|
+
}
|
|
175
|
+
else if (this.baseFacetRoot) {
|
|
176
|
+
/** Data is from an existing search term, merge the facets together */
|
|
177
|
+
this.facetRoot = mergeFacetRoots(this.fieldName, this.baseFacetRoot, incomingFacetRoot);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this.lastQuery = state.query;
|
|
181
|
+
this.lastSearchMode = state.searchMode;
|
|
182
|
+
this.lastSortType = state.sortType;
|
|
183
|
+
this.lastTimeTaken = timeTaken;
|
|
184
|
+
}
|
|
185
|
+
connectedCallback() {
|
|
186
|
+
this.handleStateUpdate(this.searchStore);
|
|
187
|
+
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
188
|
+
this.handleStateUpdate(state);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
disconnectedCallback() {
|
|
192
|
+
var _a;
|
|
193
|
+
(_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
194
|
+
}
|
|
195
|
+
handleCheckboxChange(path) {
|
|
196
|
+
const isCheckboxChecked = !this.selectedPaths[path];
|
|
197
|
+
if (isCheckboxChecked) {
|
|
198
|
+
/**
|
|
199
|
+
* Checkbox Checked: Add to the selectedPaths record
|
|
200
|
+
* Uses spread operator here so UI updates.
|
|
201
|
+
*/
|
|
202
|
+
this.selectedPaths = Object.assign(Object.assign({}, this.selectedPaths), { [path]: true });
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
/**
|
|
206
|
+
* Checkbox Uncheck: Remove any paths and sub-paths
|
|
207
|
+
*/
|
|
208
|
+
const updatedPaths = Object.keys(this.selectedPaths).filter((testPath) => !testPath.includes(path));
|
|
209
|
+
this.selectedPaths = updatedPaths.reduce((acc, str) => {
|
|
210
|
+
acc[str] = true;
|
|
211
|
+
return acc;
|
|
212
|
+
}, {});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Emit the paths array, with parent paths removed.
|
|
216
|
+
*/
|
|
217
|
+
const paths = Object.keys(this.selectedPaths).filter((path) => this.selectedPaths[path]);
|
|
218
|
+
const pathsWithParentPathsRemoved = removeSubstringMatches(paths);
|
|
219
|
+
this.facetSelectionUpdated.emit({ paths: pathsWithParentPathsRemoved });
|
|
220
|
+
}
|
|
221
|
+
render() {
|
|
222
|
+
var _a;
|
|
223
|
+
const firstFacet = (_a = this.facetRoot) === null || _a === void 0 ? void 0 : _a[this.fieldName];
|
|
224
|
+
return (h("div", { key: '709834d9f86b75257ae0c67e9340c0fea4131035', class: classNames('filtersListContainer', 'searchcraft-filters-list-container') }, !firstFacet && (h("p", { key: 'a6e2ced40fcc0762ae8ea835c9d6c573aceeb1f1', class: 'searchcraft-facet-message' }, "Enter a search to view facets.")), firstFacet === null || firstFacet === void 0 ? void 0 :
|
|
225
|
+
firstFacet.map((facetChild) => {
|
|
226
|
+
var _a;
|
|
227
|
+
const isChildSelected = facetChild.children
|
|
228
|
+
? (_a = facetChild.children) === null || _a === void 0 ? void 0 : _a.some((child) => this.selectedPaths[child.path])
|
|
229
|
+
: false;
|
|
230
|
+
return (h("div", { key: facetChild.path, class: classNames('searchcraft-filters-list-item') }, h("label", { class: classNames('filterCheckboxLabel', 'searchcraft-filters-list-checkbox-label') }, h("input", { checked: this.selectedPaths[facetChild.path], onChange: (_event) => this.handleCheckboxChange(facetChild.path), type: 'checkbox' }), isChildSelected ? (h("div", { class: classNames('dashContainer', 'searchcraft-filter-list-dash-container') }, h("searchcraft-dash-icon", null))) : (h("div", { class: classNames('checkContainer', 'searchcraft-filter-list-check-container') }, h("searchcraft-check-icon", null))), this.formatLabel(facetChild)), facetChild.children && facetChild.children.length > 0 && (h(Fragment, null, facetChild.children.map((grandchild) => (h("label", { key: grandchild.path, class: classNames('childFilterCheckboxLabel', 'searchcraft-child-filter-checkbox-label'), style: {
|
|
231
|
+
display: this.selectedPaths[facetChild.path]
|
|
232
|
+
? 'flex'
|
|
233
|
+
: 'none',
|
|
234
|
+
} }, h("input", { checked: this.selectedPaths[grandchild.path], onChange: (_event) => {
|
|
235
|
+
this.handleCheckboxChange(grandchild.path);
|
|
236
|
+
}, type: 'checkbox' }), h("div", { class: classNames('checkContainer', 'searchcraft-filter-list-check-container') }, h("searchcraft-check-icon", null)), this.formatSubLabel(grandchild, facetChild))))))));
|
|
237
|
+
})));
|
|
238
|
+
}
|
|
239
|
+
static get style() { return SearchcraftFacetListStyle0; }
|
|
240
|
+
}, [0, "searchcraft-facet-list", {
|
|
241
|
+
"fieldName": [1, "field-name"],
|
|
242
|
+
"baseFacetRoot": [32],
|
|
243
|
+
"facetRoot": [32],
|
|
244
|
+
"selectedPaths": [32],
|
|
245
|
+
"lastTimeTaken": [32],
|
|
246
|
+
"hasNewSearchTerm": [32],
|
|
247
|
+
"lastQuery": [32],
|
|
248
|
+
"lastSearchMode": [32],
|
|
249
|
+
"lastSortType": [32],
|
|
250
|
+
"unsubscribe": [32]
|
|
251
|
+
}]);
|
|
252
|
+
function defineCustomElement() {
|
|
253
|
+
if (typeof customElements === "undefined") {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const components = ["searchcraft-facet-list"];
|
|
257
|
+
components.forEach(tagName => { switch (tagName) {
|
|
258
|
+
case "searchcraft-facet-list":
|
|
259
|
+
if (!customElements.get(tagName)) {
|
|
260
|
+
customElements.define(tagName, SearchcraftFacetList);
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
} });
|
|
264
|
+
}
|
|
265
|
+
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0B,CACtB,EACL,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,CAAC,CACtC,CACT,CAAC,CACO,CACZ,CACG,EACN;aACH,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/utils/facets.ts","src/components/searchcraft-facet-list/searchcraft-facet-list.module.scss?tag=searchcraft-facet-list","src/components/searchcraft-facet-list/searchcraft-facet-list.tsx"],"sourcesContent":["import type {\n FacetChild,\n FacetChildObject,\n FacetRoot,\n} from '@searchcraft/core';\n\nfunction deepMergeWithSpread(obj1, obj2) {\n const result = { ...obj1 };\n\n for (const key in obj2) {\n // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>\n if (obj2.hasOwnProperty(key)) {\n if (obj2[key] instanceof Object && obj1[key] instanceof Object) {\n result[key] = deepMergeWithSpread(obj1[key], obj2[key]);\n } else {\n result[key] = obj2[key];\n }\n }\n }\n\n return result;\n}\n\n/**\n * Given an array of facet paths, removes parent facet paths.\n */\nexport function removeSubstringMatches(arr: string[]): string[] {\n return arr.filter(\n (entry, index, array) =>\n !array.some(\n (otherEntry, otherIndex) =>\n otherIndex !== index && otherEntry.includes(entry),\n ),\n );\n}\n\ntype FacetChildFragment = {\n count: number;\n path: string;\n};\n\nfunction facetToRecord(facet: FacetChild): Record<string, FacetChildFragment> {\n const records: Record<string, FacetChildFragment> = {};\n\n const traverseAndAddToFragments = (facetChild: FacetChild) => {\n records[facetChild.path] = {\n count: facetChild.count,\n path: facetChild.path,\n };\n\n facetChild.children?.forEach((child) => {\n traverseAndAddToFragments(child);\n });\n };\n\n traverseAndAddToFragments(facet);\n\n return records;\n}\n\nfunction recordToObject(\n record: Record<string, FacetChildFragment>,\n): FacetChildObject {\n const root: FacetChildObject = {\n count: 0,\n path: '/',\n children: {},\n };\n\n Object.keys(record).forEach((key) => {\n const fragment = record[key];\n if (fragment.path === '/') {\n return;\n }\n const pathParts = fragment.path.substring(1).split('/');\n let currentRoot = root;\n let currentPath = '';\n\n pathParts.forEach((part, index) => {\n const nextPath = `${currentPath}/${part}`;\n if (!currentRoot.children[nextPath]) {\n currentRoot.children[nextPath] = {\n count: 0,\n path: nextPath,\n children: {},\n };\n }\n\n if (index === pathParts.length - 1) {\n currentRoot.children[nextPath].count = fragment.count;\n }\n\n currentPath = nextPath;\n currentRoot = currentRoot.children[nextPath];\n });\n });\n\n return root;\n}\n\nfunction objectToFacet(childObject: FacetChildObject): FacetChild {\n const transformed: FacetChild = {\n count: childObject.count,\n path: childObject.path,\n children: [],\n };\n\n if (Object.keys(childObject.children).length > 0) {\n transformed.children = Object.values(childObject.children).map(\n (subChildObject) => objectToFacet(subChildObject),\n );\n }\n\n return transformed;\n}\n\n/**\n * Filters records with the parent paths from record2 OUT of record1\n */\nfunction filterRecordByParentPaths(\n record1: Record<string, FacetChild>,\n record2: Record<string, FacetChild>,\n): Record<string, FacetChild> {\n // Extract all paths (keys) both records\n const paths1 = Object.keys(record1);\n const paths2 = Object.keys(record2);\n\n // Find all parent paths in record2\n const parentPaths = new Set(\n paths2\n .filter((path) => path.split('/').length > 2) // Only consider paths with more than one level\n .map((path) => path.substring(0, path.lastIndexOf('/'))),\n );\n\n // Filter out keys in record1 that share a parent path with any of the identified parent paths\n const filteredRecord = Object.fromEntries(\n paths1\n .filter(\n (path) => !parentPaths.has(path.substring(0, path.lastIndexOf('/'))),\n )\n .map((path) => [path, record1[path]]), // Reconstruct the key-value pairs\n );\n\n return filteredRecord;\n}\n\nexport function mergeFacetRoots(\n fieldName: string,\n currentRoot: FacetRoot,\n incomingRoot: FacetRoot,\n): FacetRoot {\n const currentArray = currentRoot[fieldName];\n const incomingArray = incomingRoot[fieldName];\n\n const currentRootFacetChild: FacetChild = {\n count: 0,\n path: '/',\n children: currentArray,\n };\n\n const incomingRootFacetChild: FacetChild = {\n count: 0,\n path: '/',\n children: incomingArray,\n };\n\n // Flatten them into records\n const currentRecord: Record<string, FacetChildFragment> = facetToRecord(\n currentRootFacetChild,\n );\n\n const incomingRecord: Record<string, FacetChildFragment> = facetToRecord(\n incomingRootFacetChild,\n );\n\n // Filter out the records from record1 (the current set of records)\n // that share a parent path with record2 (the incoming records)\n const filteredCurrentRecord = filterRecordByParentPaths(\n currentRecord,\n incomingRecord,\n );\n\n // Deep merge the records together\n const mergedRecord: Record<string, FacetChildFragment> = deepMergeWithSpread(\n filteredCurrentRecord,\n incomingRecord,\n );\n\n // Convert into a heirarchical object\n const mergedObject: FacetChildObject = recordToObject(mergedRecord);\n\n // Convert the heirarchical object back to the Facet child structure\n const mergedFacetChild = objectToFacet(mergedObject);\n\n return {\n [fieldName]: mergedFacetChild.children,\n };\n}\n",".filtersListContainer {\n width: 100%;\n}\n\n.filterCheckboxLabel {\n align-items: center;\n color: var(--sc-content-primary);\n display: flex;\n font-family: var(--sc-font-family);\n font-size: 14px;\n font-weight: 600;\n gap: 14px;\n position: relative;\n -webkit-font-smoothing: antialiased;\n}\n\n.filterCheckboxLabel input[type=\"checkbox\"] {\n align-items: center;\n appearance: none;\n background-color: var(--sc-surface-brand-secondary-hover);\n border: 1px solid var(--sc-surface-disabled);\n border-radius: 8px;\n cursor: pointer;\n display: flex;\n height: 24px;\n justify-content: center;\n width: 24px;\n}\n\n.filterCheckboxLabel input[type=\"checkbox\"]:focus {\n outline: 2px solid var(--sc-surface-brand-primary);\n}\n\n.filterCheckboxLabel input[type=\"checkbox\"]:checked {\n background-color: var(--sc-surface-brand-primary);\n position: relative;\n}\n\n.filterCheckboxLabel input[type=\"checkbox\"]:checked + .checkContainer {\n display: block;\n}\n\n.filterCheckboxLabel input[type=\"checkbox\"]:checked + .dashContainer {\n display: block;\n}\n\n.childFilterCheckboxLabel {\n align-items: center;\n color: var(--sc-content-primary);\n display: flex;\n font-family: var(--sc-font-family);\n font-size: 14px;\n font-weight: 600;\n gap: 12px;\n margin-left: 24px;\n position: relative;\n}\n\n.childFilterCheckboxLabel input[type=\"checkbox\"] {\n align-items: center;\n appearance: none;\n background-color: var(--sc-surface-brand-secondary-hover);\n border: 1px solid var(--sc-surface-disabled);\n border-radius: 8px;\n cursor: pointer;\n display: flex;\n height: 24px;\n justify-content: center;\n position: relative;\n width: 24px;\n -webkit-font-smoothing: antialiased;\n}\n\n.childFilterCheckboxLabel input[type=\"checkbox\"]:focus {\n outline: 2px solid var(--sc-surface-brand-primary);\n}\n\n.childFilterCheckboxLabel input[type=\"checkbox\"]:checked {\n background-color: var(--sc-surface-brand-primary);\n position: relative;\n}\n\n.childFilterCheckboxLabel input[type=\"checkbox\"]:checked + .checkContainer {\n display: block;\n}\n\n.childFilterCheckboxLabel input[type=\"checkbox\"]:checked + .dashContainer {\n display: block;\n}\n\n.checkContainer {\n display: none;\n height: 16px;\n width: 16px;\n position: absolute;\n top: 9px;\n left: 8px;\n}\n\n.dashContainer {\n display: none;\n height: 3px;\n width: 14px;\n position: absolute;\n top: 3px;\n left: 9px;\n}\n\n.searchcraft-facet-message {\n @include body-small();\n color: var(--sc-content-disabled);\n text-align: center;\n}","import {\n Component,\n h,\n State,\n Prop,\n Event,\n type EventEmitter,\n Fragment,\n} from '@stencil/core';\nimport classNames from 'classnames';\n\nimport type { FacetChild, FacetRoot } from '@searchcraft/core';\n\nimport { useSearchcraftStore, type SearchcraftState } from '@provider/store';\nimport { mergeFacetRoots, removeSubstringMatches } from '@utils';\n\n/**\n * This web component is designed to display facets in a search interface, allowing users to refine their search results by applying filters based on various attributes.\n * It is consumed within the `searchcraft-filter-panel`.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-facet-list field-name=\"title\" />\n * ```\n *\n * ```js\n * // index.js\n * const facetList = document.querySelector('searchcraft-facet-list');\n *\n * facetList.addEventListener('facetSelectionUpdated', () => {\n * console.log('Facet selection updated');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-facet-list',\n styleUrl: 'searchcraft-facet-list.module.scss',\n shadow: false,\n})\nexport class SearchcraftFacetList {\n /**\n * The name of the field where facets are applied.\n */\n @Prop() fieldName: string;\n\n /**\n * When the facets are updated.\n */\n @Event() facetSelectionUpdated: EventEmitter<{ paths: string[] }>;\n\n @State() baseFacetRoot: FacetRoot | undefined;\n @State() facetRoot: FacetRoot | undefined;\n @State() selectedPaths: Record<string, boolean> = {};\n @State() lastTimeTaken: number | undefined;\n @State() hasNewSearchTerm = false;\n\n @State() lastQuery: string | undefined;\n @State() lastSearchMode: string | undefined;\n @State() lastSortType: string | undefined;\n\n @State() unsubscribe: (() => void) | undefined;\n\n private searchStore = useSearchcraftStore.getState();\n\n handleStateUpdate(state: SearchcraftState) {\n const facetPrime = state.searchResults?.data.facets;\n const timeTaken = state.searchResults?.data.time_taken;\n\n /** Things to do when the state's search term has changed, but before the response received */\n if (\n state.query !== this.lastQuery ||\n state.searchMode !== this.lastSearchMode ||\n state.sortType !== this.lastSortType\n ) {\n this.selectedPaths = {};\n this.hasNewSearchTerm = true;\n }\n\n /** Things to do when a new response with a new facet prime has been received */\n if (timeTaken !== this.lastTimeTaken && facetPrime) {\n this.facetRoot = undefined;\n const incomingFacetRoot: FacetRoot = facetPrime.find(\n (facet) => this.fieldName === Object.keys(facet)[0],\n );\n\n /** Data is from a new search term: completely override our facets */\n if (this.hasNewSearchTerm) {\n this.baseFacetRoot = incomingFacetRoot;\n this.facetRoot = incomingFacetRoot;\n this.hasNewSearchTerm = false;\n } else if (this.baseFacetRoot) {\n /** Data is from an existing search term, merge the facets together */\n this.facetRoot = mergeFacetRoots(\n this.fieldName,\n this.baseFacetRoot,\n incomingFacetRoot,\n );\n }\n }\n\n this.lastQuery = state.query;\n this.lastSearchMode = state.searchMode;\n this.lastSortType = state.sortType;\n this.lastTimeTaken = timeTaken;\n }\n\n connectedCallback() {\n this.handleStateUpdate(this.searchStore);\n\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n this.handleStateUpdate(state);\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleCheckboxChange(path: string) {\n const isCheckboxChecked = !this.selectedPaths[path];\n\n if (isCheckboxChecked) {\n /**\n * Checkbox Checked: Add to the selectedPaths record\n * Uses spread operator here so UI updates.\n */\n this.selectedPaths = {\n ...this.selectedPaths,\n [path]: true,\n };\n } else {\n /**\n * Checkbox Uncheck: Remove any paths and sub-paths\n */\n const updatedPaths = Object.keys(this.selectedPaths).filter(\n (testPath) => !testPath.includes(path),\n );\n\n this.selectedPaths = updatedPaths.reduce(\n (acc, str) => {\n acc[str] = true;\n return acc;\n },\n {} as Record<string, boolean>,\n );\n }\n\n /**\n * Emit the paths array, with parent paths removed.\n */\n const paths = Object.keys(this.selectedPaths).filter(\n (path) => this.selectedPaths[path],\n );\n const pathsWithParentPathsRemoved = removeSubstringMatches(paths);\n\n this.facetSelectionUpdated.emit({ paths: pathsWithParentPathsRemoved });\n }\n\n formatLabel = (facetChild: FacetChild): string => {\n const label = facetChild.path.replace(/^\\//, '');\n const count = facetChild.count;\n return `${label.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())} (${count})`;\n };\n\n formatSubLabel = (\n facetChild: FacetChild,\n facetChildAncestor: FacetChild,\n ): string => {\n const facetChildPath = facetChild.path.substring(\n facetChildAncestor.path.length,\n );\n const label = facetChildPath.replace(/^\\//, '');\n const count = facetChild.count;\n return `${label.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())} (${count})`;\n };\n\n render() {\n const firstFacet = this.facetRoot?.[this.fieldName];\n\n return (\n <div\n class={classNames(\n 'filtersListContainer',\n 'searchcraft-filters-list-container',\n )}\n >\n {!firstFacet && (\n <p class='searchcraft-facet-message'>\n Enter a search to view facets.\n </p>\n )}\n {firstFacet?.map((facetChild: FacetChild) => {\n const isChildSelected = facetChild.children\n ? facetChild.children?.some(\n (child) => this.selectedPaths[child.path],\n )\n : false;\n\n return (\n <div\n key={facetChild.path}\n class={classNames('searchcraft-filters-list-item')}\n >\n <label\n class={classNames(\n 'filterCheckboxLabel',\n 'searchcraft-filters-list-checkbox-label',\n )}\n >\n <input\n checked={this.selectedPaths[facetChild.path]}\n onChange={(_event: Event) =>\n this.handleCheckboxChange(facetChild.path)\n }\n type='checkbox'\n />\n {isChildSelected ? (\n <div\n class={classNames(\n 'dashContainer',\n 'searchcraft-filter-list-dash-container',\n )}\n >\n <searchcraft-dash-icon />\n </div>\n ) : (\n <div\n class={classNames(\n 'checkContainer',\n 'searchcraft-filter-list-check-container',\n )}\n >\n <searchcraft-check-icon />\n </div>\n )}\n {this.formatLabel(facetChild)}\n </label>\n {facetChild.children && facetChild.children.length > 0 && (\n <Fragment>\n {facetChild.children.map((grandchild) => (\n <label\n key={grandchild.path}\n class={classNames(\n 'childFilterCheckboxLabel',\n 'searchcraft-child-filter-checkbox-label',\n )}\n style={{\n display: this.selectedPaths[facetChild.path]\n ? 'flex'\n : 'none',\n }}\n >\n <input\n checked={this.selectedPaths[grandchild.path]}\n onChange={(_event: Event) => {\n this.handleCheckboxChange(grandchild.path);\n }}\n type='checkbox'\n />\n <div\n class={classNames(\n 'checkContainer',\n 'searchcraft-filter-list-check-container',\n )}\n >\n <searchcraft-check-icon />\n </div>\n {this.formatSubLabel(grandchild, facetChild)}\n </label>\n ))}\n </Fragment>\n )}\n </div>\n );\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { c as classNames } from './p-5cdc6210.js';
|
|
4
|
+
|
|
5
|
+
const searchcraftToggleButtonModuleCss = ":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-toggle-button-container{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}.searchcraft-toggle-button-label{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);margin:0;color:var(--sc-content-neutral-primary)}.searchcraft-toggle-button-sub-label{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);margin:0;color:var(--sc-content-neutral-secondary)}.searchcraft-toggle-button-background{transition:background-color 0.2s;background:var(--sc-surface-disabled);border:none;border-radius:16px;cursor:pointer;height:26px;position:relative;width:44px;flex-shrink:0}.searchcraft-toggle-button-background.active{background:var(--sc-surface-brand-primary);box-shadow:0px 0px 0px 1px rgba(0, 0, 0, 0.05)}.searchcraft-toggle-button-handle{background:var(--sc-surface-neutral-light);border-radius:50%;height:18px;left:4px;position:absolute;top:calc(50% - 9px);transition:transform 0.3s ease;width:18px}.searchcraft-toggle-button-handle.active{transform:translateX(16px)}";
|
|
6
|
+
const SearchcraftToggleButtonStyle0 = searchcraftToggleButtonModuleCss;
|
|
7
|
+
|
|
8
|
+
const SearchcraftToggleButton = /*@__PURE__*/ proxyCustomElement(class SearchcraftToggleButton extends H {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
this.toggleUpdated = createEvent(this, "toggleUpdated", 7);
|
|
13
|
+
/**
|
|
14
|
+
* The label.
|
|
15
|
+
*/
|
|
16
|
+
this.label = 'Toggle';
|
|
17
|
+
this.isActive = false;
|
|
18
|
+
this.handleToggle = async () => {
|
|
19
|
+
this.isActive = !this.isActive;
|
|
20
|
+
this.toggleUpdated.emit(this.isActive);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
/** When the query changes, sets toggle button state back to inactive. */
|
|
25
|
+
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
26
|
+
if (state.query !== this.lastQuery && state.query.trim().length === 0) {
|
|
27
|
+
this.isActive = false;
|
|
28
|
+
}
|
|
29
|
+
this.lastQuery = state.query;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
disconnectedCallback() {
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
return (h("div", { key: '607bbc1adc109ec918effb25c6b91052227a2f7b', class: 'searchcraft-toggle-button-container' }, h("div", { key: 'b452e1690c617020866f6bf3e591f62cc3fce111' }, h("p", { key: '1bd8fa345516e412ea57bdbeac37dc8e26f2feaa', class: 'searchcraft-toggle-button-label' }, this.label), this.subLabel && (h("p", { key: 'fce324a14721bab5f6173838f677ecb290200c8f', class: 'searchcraft-toggle-button-sub-label' }, this.subLabel))), h("button", { key: '7b293a3ef64da88f463e5e6e303dabcbc63589bd', class: classNames('searchcraft-toggle-button-background', {
|
|
38
|
+
active: this.isActive,
|
|
39
|
+
}), onClick: this.handleToggle, type: 'button' }, h("div", { key: '6afd68afeea5bb15ce1bde486ac59f7a958f6752', class: classNames('searchcraft-toggle-button-handle', {
|
|
40
|
+
active: this.isActive,
|
|
41
|
+
}) }))));
|
|
42
|
+
}
|
|
43
|
+
static get style() { return SearchcraftToggleButtonStyle0; }
|
|
44
|
+
}, [0, "searchcraft-toggle-button", {
|
|
45
|
+
"label": [1],
|
|
46
|
+
"subLabel": [1, "sub-label"],
|
|
47
|
+
"isActive": [32],
|
|
48
|
+
"unsubscribe": [32],
|
|
49
|
+
"lastQuery": [32]
|
|
50
|
+
}]);
|
|
51
|
+
function defineCustomElement() {
|
|
52
|
+
if (typeof customElements === "undefined") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const components = ["searchcraft-toggle-button"];
|
|
56
|
+
components.forEach(tagName => { switch (tagName) {
|
|
57
|
+
case "searchcraft-toggle-button":
|
|
58
|
+
if (!customElements.get(tagName)) {
|
|
59
|
+
customElements.define(tagName, SearchcraftToggleButton);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
} });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { SearchcraftToggleButton as S, defineCustomElement as d };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=p-662cb490.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"p-662cb490.js","mappings":";;;;AAAA,MAAM,gCAAgC,GAAG,0jJAA0jJ,CAAC;AACpmJ,sCAAe,gCAAgC;;MCmBlC,uBAAuB;IALpC;;;;;;;QASU,UAAK,GAAG,QAAQ,CAAC;QAWhB,aAAQ,GAAG,KAAK,CAAC;QAIlB,iBAAY,GAAG;YACrB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACxC,CAAC;KAyCH;IAvCC,iBAAiB;;QAEf,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YACrD,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrE,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;aACvB;YACD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC;SAC9B,CAAC,CAAC;KACJ;IAED,oBAAoB;;QAClB,MAAA,IAAI,CAAC,WAAW,oDAAI,CAAC;KACtB;IAED,MAAM;QACJ,QACE,4DAAK,KAAK,EAAC,qCAAqC,IAC9C,8DACE,0DAAG,KAAK,EAAC,iCAAiC,IAAE,IAAI,CAAC,KAAK,CAAK,EAC1D,IAAI,CAAC,QAAQ,KACZ,0DAAG,KAAK,EAAC,qCAAqC,IAAE,IAAI,CAAC,QAAQ,CAAK,CACnE,CACG,EACN,+DACE,KAAK,EAAE,UAAU,CAAC,sCAAsC,EAAE;gBACxD,MAAM,EAAE,IAAI,CAAC,QAAQ;aACtB,CAAC,EACF,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,IAAI,EAAC,QAAQ,IAEb,4DACE,KAAK,EAAE,UAAU,CAAC,kCAAkC,EAAE;gBACpD,MAAM,EAAE,IAAI,CAAC,QAAQ;aACtB,CAAC,GACF,CACK,CACL,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/searchcraft-toggle-button/searchcraft-toggle-button.module.scss?tag=searchcraft-toggle-button","src/components/searchcraft-toggle-button/searchcraft-toggle-button.tsx"],"sourcesContent":[".searchcraft-toggle-button-container {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 10px;\n}\n\n.searchcraft-toggle-button-label {\n @include body();\n margin: 0;\n color: var(--sc-content-neutral-primary);\n}\n\n.searchcraft-toggle-button-sub-label {\n @include body-small();\n margin: 0;\n color: var(--sc-content-neutral-secondary);\n}\n\n.searchcraft-toggle-button-background {\n transition: background-color 0.2s;\n background: var(--sc-surface-disabled);\n border: none;\n border-radius: 16px;\n cursor: pointer;\n height: 26px;\n position: relative;\n width: 44px;\n flex-shrink: 0;\n}\n\n.searchcraft-toggle-button-background.active {\n background: var(--sc-surface-brand-primary);\n box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.05);\n}\n\n.searchcraft-toggle-button-handle {\n background: var(--sc-surface-neutral-light);\n border-radius: 50%;\n height: 18px;\n left: 4px;\n position: absolute;\n top: calc(50% - 18px/2);\n transition: transform 0.3s ease;\n width: 18px;\n}\n\n.searchcraft-toggle-button-handle.active {\n transform: translateX(16px);\n}\n","import { useSearchcraftStore } from '@provider/store';\nimport {\n Component,\n Event,\n h,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\nimport classNames from 'classnames';\n\n/**\n * This web component simulates a light switch functionality, providing a simple and intuitive toggle between two states—on and off.\n * It is consumed within the `searchcraft-filter-panel` component.\n */\n@Component({\n tag: 'searchcraft-toggle-button',\n styleUrl: 'searchcraft-toggle-button.module.scss',\n shadow: false,\n})\nexport class SearchcraftToggleButton {\n /**\n * The label.\n */\n @Prop() label = 'Toggle';\n /**\n * The secondary label displayed below the main label.\n */\n @Prop() subLabel: string | undefined;\n\n /**\n * When the toggle element is changed.\n */\n @Event() toggleUpdated: EventEmitter<boolean>;\n\n @State() isActive = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() lastQuery: string | undefined;\n\n private handleToggle = async () => {\n this.isActive = !this.isActive;\n this.toggleUpdated.emit(this.isActive);\n };\n\n connectedCallback() {\n /** When the query changes, sets toggle button state back to inactive. */\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query !== this.lastQuery && state.query.trim().length === 0) {\n this.isActive = false;\n }\n this.lastQuery = state.query;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n render() {\n return (\n <div class='searchcraft-toggle-button-container'>\n <div>\n <p class='searchcraft-toggle-button-label'>{this.label}</p>\n {this.subLabel && (\n <p class='searchcraft-toggle-button-sub-label'>{this.subLabel}</p>\n )}\n </div>\n <button\n class={classNames('searchcraft-toggle-button-background', {\n active: this.isActive,\n })}\n onClick={this.handleToggle}\n type='button'\n >\n <div\n class={classNames('searchcraft-toggle-button-handle', {\n active: this.isActive,\n })}\n />\n </button>\n </div>\n );\n }\n}\n"],"version":3}
|