@searchcraft/javascript-sdk 0.6.0 → 0.7.1
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 +59 -55
- package/dist/cjs/{index-b3b77ea2.js → index-a81df4f0.js} +258 -239
- package/dist/cjs/index-a81df4f0.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js +91 -48
- package/dist/cjs/searchcraft-base-search-result.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +74 -37
- package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-button_3.cjs.entry.js +37 -27
- package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +141 -117
- package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +11 -13
- package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +128 -82
- package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +1 -1
- 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 +3 -7
- package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js +81 -68
- package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js +29 -12
- package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-results-info.cjs.entry.js +9 -13
- package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +1 -1
- package/dist/cjs/searchcraft-theme.cjs.entry.js +38 -0
- package/dist/cjs/searchcraft-theme.cjs.entry.js.map +1 -0
- package/dist/cjs/{store-d7ebcf7a.js → store-f6ba3dfb.js} +633 -107
- package/dist/cjs/store-f6ba3dfb.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +134 -66
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +100 -49
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
- package/dist/collection/components/searchcraft-button/searchcraft-button.js +35 -23
- package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +1 -1
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +8 -15
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +1 -1
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +61 -59
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +1 -1
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +11 -19
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +1 -1
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +126 -76
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +1 -1
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +14 -18
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +1 -11
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +93 -77
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +47 -25
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +1 -1
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +23 -25
- 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 +7 -19
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -1
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +65 -55
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -1
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +27 -0
- package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +1 -0
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +27 -26
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/provider/store.js +25 -9
- package/dist/collection/provider/store.js.map +1 -1
- package/dist/collection/utils/facets.js +5 -3
- package/dist/collection/utils/facets.js.map +1 -1
- package/dist/components/index.js +4 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-0ef4ab33.js +66 -0
- package/dist/components/p-0ef4ab33.js.map +1 -0
- package/dist/components/p-1234974c.js +72 -0
- package/dist/components/p-1234974c.js.map +1 -0
- package/dist/components/p-4b92ae26.js +109 -0
- package/dist/components/p-4b92ae26.js.map +1 -0
- package/dist/components/{p-85765b81.js → p-506cdac1.js} +18 -16
- package/dist/components/p-506cdac1.js.map +1 -0
- package/dist/components/p-521fe971.js +60 -0
- package/dist/components/p-521fe971.js.map +1 -0
- package/dist/components/{p-e4846fa2.js → p-5365011f.js} +215 -231
- package/dist/components/p-5365011f.js.map +1 -0
- package/dist/components/p-54998882.js +285 -0
- package/dist/components/p-54998882.js.map +1 -0
- package/dist/components/{p-d6a88eed.js → p-936e2ed4.js} +633 -107
- package/dist/components/p-936e2ed4.js.map +1 -0
- package/dist/components/p-a75ef832.js +34 -0
- package/dist/components/p-a75ef832.js.map +1 -0
- package/dist/components/p-b4a8fcbe.js +144 -0
- package/dist/components/p-b4a8fcbe.js.map +1 -0
- package/dist/components/p-ca881e5c.js +37 -0
- package/dist/components/p-ca881e5c.js.map +1 -0
- package/dist/components/p-d95bc2a0.js +284 -0
- package/dist/components/p-d95bc2a0.js.map +1 -0
- package/dist/components/searchcraft-base-search-result.js +1 -1
- package/dist/components/searchcraft-base-search-results.js +76 -39
- 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 +14 -16
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-input-label.js +1 -1
- package/dist/components/searchcraft-popover-button.js +3 -7
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-form.js +87 -74
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +9 -13
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.d.ts +11 -0
- package/dist/components/searchcraft-theme.js +51 -0
- package/dist/components/searchcraft-theme.js.map +1 -0
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/esm/{index-11551663.js → index-3608c57d.js} +258 -239
- package/dist/esm/index-3608c57d.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/searchcraft-base-search-result.entry.js +91 -48
- package/dist/esm/searchcraft-base-search-result.entry.js.map +1 -1
- package/dist/esm/searchcraft-base-search-results.entry.js +74 -37
- package/dist/esm/searchcraft-base-search-results.entry.js.map +1 -1
- package/dist/esm/searchcraft-button_3.entry.js +37 -27
- package/dist/esm/searchcraft-button_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-facet-list_3.entry.js +141 -117
- package/dist/esm/searchcraft-facet-list_3.entry.js.map +1 -1
- package/dist/esm/searchcraft-filter-panel.entry.js +11 -13
- package/dist/esm/searchcraft-filter-panel.entry.js.map +1 -1
- package/dist/esm/searchcraft-input-form_2.entry.js +128 -82
- package/dist/esm/searchcraft-input-form_2.entry.js.map +1 -1
- 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 +3 -7
- package/dist/esm/searchcraft-popover-button.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-form.entry.js +81 -68
- package/dist/esm/searchcraft-popover-form.entry.js.map +1 -1
- package/dist/esm/searchcraft-popover-list-item.entry.js +29 -12
- package/dist/esm/searchcraft-popover-list-item.entry.js.map +1 -1
- package/dist/esm/searchcraft-results-info.entry.js +9 -13
- package/dist/esm/searchcraft-results-info.entry.js.map +1 -1
- package/dist/esm/searchcraft-theme.entry.js +34 -0
- package/dist/esm/searchcraft-theme.entry.js.map +1 -0
- package/dist/esm/{store-1058f7b0.js → store-aa071d9c.js} +633 -107
- package/dist/esm/store-aa071d9c.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js +3 -0
- package/dist/searchcraft-javascript-sdk/p-7e13c128.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-936e2ed4.js +11 -0
- package/dist/searchcraft-javascript-sdk/p-936e2ed4.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js.map +1 -0
- package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js +2 -0
- package/dist/searchcraft-javascript-sdk/p-faaa4394.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 +1 -0
- package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +2 -1
- package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +1 -0
- package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +1 -0
- package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +2 -1
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +1 -0
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +7 -10
- package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +2 -1
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +1 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +2 -1
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +2 -0
- package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +1 -0
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +1 -0
- package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +2 -1
- package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +5 -0
- package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +2 -1
- package/dist/types/components.d.ts +17 -4
- package/dist/types/index.d.ts +2 -1
- package/dist/types/provider/store.d.ts +1 -0
- package/dist/types/types/_shared.types.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/raw.d.ts +4 -0
- package/dist/types/types/searchcraft-base-search-results.types.d.ts +1 -0
- package/dist/types/types/searchcraft-filter-panel.types.d.ts +1 -0
- package/dist/types/types/searchcraft-popover-form.types.d.ts +1 -0
- package/dist/types/utils/facets.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/styles.d.ts +1 -0
- package/dist/types/utils/units.d.ts +1 -0
- package/package.json +6 -4
- package/dist/cjs/index-b3b77ea2.js.map +0 -1
- package/dist/cjs/store-d7ebcf7a.js.map +0 -1
- package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +0 -227
- package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.module.css +0 -179
- package/dist/collection/components/searchcraft-button/searchcraft-button.module.css +0 -174
- package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.module.css +0 -158
- package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.module.css +0 -266
- package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.module.css +0 -168
- package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.module.css +0 -293
- package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.module.css +0 -159
- package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.module.css +0 -0
- package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.module.css +0 -322
- package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.module.css +0 -209
- package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.module.css +0 -0
- package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.module.css +0 -169
- package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +0 -231
- package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +0 -207
- package/dist/components/p-02a16e53.js +0 -240
- package/dist/components/p-02a16e53.js.map +0 -1
- package/dist/components/p-04c46179.js +0 -101
- package/dist/components/p-04c46179.js.map +0 -1
- package/dist/components/p-0e38a723.js +0 -99
- package/dist/components/p-0e38a723.js.map +0 -1
- package/dist/components/p-4c45ef80.js +0 -67
- package/dist/components/p-4c45ef80.js.map +0 -1
- package/dist/components/p-85765b81.js.map +0 -1
- package/dist/components/p-953f4238.js +0 -35
- package/dist/components/p-953f4238.js.map +0 -1
- package/dist/components/p-a248ad69.js +0 -276
- package/dist/components/p-a248ad69.js.map +0 -1
- package/dist/components/p-a9bd1872.js +0 -38
- package/dist/components/p-a9bd1872.js.map +0 -1
- package/dist/components/p-cf4ced92.js +0 -49
- package/dist/components/p-cf4ced92.js.map +0 -1
- package/dist/components/p-d6a88eed.js.map +0 -1
- package/dist/components/p-e4846fa2.js.map +0 -1
- package/dist/components/p-f9d778b3.js +0 -48
- package/dist/components/p-f9d778b3.js.map +0 -1
- package/dist/esm/index-11551663.js.map +0 -1
- package/dist/esm/store-1058f7b0.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-4580e8a4.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-4580e8a4.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-7049b93d.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-7049b93d.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-8e539d62.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-8e539d62.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-98640a6a.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-98640a6a.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-9d0f5c89.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-9d0f5c89.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-b8bd53ce.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-b8bd53ce.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-c27a3673.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-c27a3673.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-cd852b84.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-cd852b84.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-d6a88eed.js +0 -11
- package/dist/searchcraft-javascript-sdk/p-d6a88eed.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-e042deb9.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-e042deb9.entry.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-e0be53df.js +0 -3
- package/dist/searchcraft-javascript-sdk/p-e0be53df.js.map +0 -1
- package/dist/searchcraft-javascript-sdk/p-efab9f3c.entry.js +0 -2
- package/dist/searchcraft-javascript-sdk/p-efab9f3c.entry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-filter-panel.js","mappings":";;;;;;;AAAA,MAAM,+BAA+B,GAAG,2sHAA2sH,C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AC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;gBACD,KAAK,kBAAkB,EAAE;oBACvB,MAAM,IAAI,GAAG,UAAwC,CAAC;oBACtD,QACE,iCACE,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,eAAe,EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftFilterPanel"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.module.scss?tag=searchcraft-filter-panel","src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":[".searchcraft-filter-panel {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.searchcraft-filter-panel-section {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.searchcraft-filter-panel-label {\n @include body-small-bold();\n}\n","import { Component, h, Prop, State } from '@stencil/core';\nimport type {\n FilterItem,\n DateRangeFilterItem,\n NumericFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n} from '../../types/searchcraft-filter-panel.types';\nimport { useSearchcraftStore } from '@provider/store';\nimport { getMillis } from '@utils';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n styleUrl: 'searchcraft-filter-panel.module.scss',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() unsubscribe: (() => void) | undefined;\n @State() lastQuery: string | undefined;\n\n private searchStore = useSearchcraftStore.getState();\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.lastQuery !== state.query) {\n // A place to put actions to do when the query changes\n }\n this.lastQuery = state.query || '';\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleDateRangeChanged(fieldName: string, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.searchStore.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.searchStore.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.searchStore.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.searchStore.removeFacetPathsForIndexField(fieldName);\n }\n this.searchStore.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.searchStore.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.searchStore.search();\n }\n\n handleMostRecentToggleUpdated(isActive: boolean) {\n this.searchStore.setSortType(isActive ? 'desc' : 'asc');\n this.searchStore.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const min = new Date(item.options.minDate).getTime();\n const max = new Date(item.options.maxDate).getTime();\n const granularityValue = getMillis(item.options.granularity);\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={min}\n max={max}\n granularity={granularityValue}\n dataType='date'\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n granularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(event.detail);\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-filter-panel.js","mappings":";;;;;;;MAwBaA,wBAAsB;;;;;;;;IAIzB,KAAK,GAAiB,EAAE,CAAC;IAExB,WAAW,CAA2B;IACtC,SAAS,CAAqB;IAE/B,WAAW,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YAIrD,IAAI,CAAC,SAAS,GAAG,KAAK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EAAE,CAAC,KAAK;4BACrB,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;yBAClD,GACD,EACF;iBACH;aACF;SACF,CAAC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftFilterPanel"],"sources":["src/components/searchcraft-filter-panel/searchcraft-filter-panel.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\nimport type {\n FilterItem,\n DateRangeFilterItem,\n NumericFilterItem,\n ExactMatchToggleFilterItem,\n FacetsFilterItem,\n} from '../../types/searchcraft-filter-panel.types';\nimport { useSearchcraftStore } from '@provider/store';\nimport { getMillis } from '@utils';\n\n/**\n * This web component represents a series of filters that allows users to refine and control their search queries by applying various filter criteria.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-filter-panel />\n * ```\n */\n@Component({\n tag: 'searchcraft-filter-panel',\n shadow: false,\n})\nexport class SearchcraftFilterPanel {\n /**\n * The items to filter.\n */\n @Prop() items: FilterItem[] = [];\n\n @State() unsubscribe: (() => void) | undefined;\n @State() lastQuery: string | undefined;\n\n private searchStore = useSearchcraftStore.getState();\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.lastQuery !== state.query) {\n // A place to put actions to do when the query changes\n }\n this.lastQuery = state.query || '';\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n handleDateRangeChanged(fieldName: string, min: number, max: number) {\n const start = new Date(min);\n const end = new Date(max);\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${start.toISOString()} TO ${end.toISOString()}]`,\n });\n\n this.searchStore.search();\n }\n\n handleNumericRangeChanged(fieldName: string, min: number, max: number) {\n this.searchStore.addRangeValueForIndexField({\n fieldName,\n value: `${fieldName}:[${min} TO ${max}]`,\n });\n this.searchStore.search();\n }\n\n handleFacetSelectionUpdated(fieldName: string, paths: string[]) {\n if (paths.length > 0) {\n this.searchStore.addFacetPathsForIndexField({\n fieldName,\n value: `${fieldName}: IN [${paths.join(' ')}]`,\n });\n } else {\n this.searchStore.removeFacetPathsForIndexField(fieldName);\n }\n this.searchStore.search();\n }\n\n handleExactMatchToggleUpdated(isActive: boolean) {\n this.searchStore.setSearchMode(isActive ? 'exact' : 'fuzzy');\n this.searchStore.search();\n }\n\n handleMostRecentToggleUpdated(isActive: boolean) {\n this.searchStore.setSortType(isActive ? 'desc' : 'asc');\n this.searchStore.search();\n }\n\n /**\n * Iterate through `items` and render them based on `type`\n */\n render() {\n return (\n <div class='searchcraft-filter-panel'>\n {this.items.map((filterItem) => {\n switch (filterItem.type) {\n case 'dateRange': {\n const item = filterItem as DateRangeFilterItem;\n const min = new Date(item.options.minDate).getTime();\n const max = new Date(item.options.maxDate).getTime();\n const granularityValue = getMillis(item.options.granularity);\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={min}\n max={max}\n granularity={granularityValue}\n dataType='date'\n onRangeChanged={(event) => {\n this.handleDateRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'numericRange': {\n const item = filterItem as NumericFilterItem;\n // return date range slider\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-slider\n min={item.options.min}\n max={item.options.max}\n granularity={item.options.granularity}\n onRangeChanged={(event) => {\n this.handleNumericRangeChanged(\n item.fieldName,\n event.detail.startValue,\n event.detail.endValue,\n );\n }}\n />\n </div>\n );\n }\n case 'facets': {\n const item = filterItem as FacetsFilterItem;\n // return \"filters-list\"\n return (\n <div class='searchcraft-filter-panel-section'>\n <p class='searchcraft-filter-panel-label'>\n {filterItem.label}\n </p>\n <searchcraft-facet-list\n fieldName={item.fieldName}\n onFacetSelectionUpdated={(event) => {\n this.handleFacetSelectionUpdated(\n item.fieldName,\n event.detail.paths,\n );\n }}\n />\n </div>\n );\n }\n case 'exactMatchToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleExactMatchToggleUpdated(event.detail);\n }}\n />\n );\n }\n case 'mostRecentToggle': {\n const item = filterItem as ExactMatchToggleFilterItem;\n return (\n <searchcraft-toggle-button\n label={item.label}\n subLabel={item.options.subLabel}\n onToggleUpdated={(event) => {\n this.handleMostRecentToggleUpdated(event.detail);\n }}\n />\n );\n }\n }\n })}\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftInput, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftInput, d as defineCustomElement$1 } from './p-d95bc2a0.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftInputForm = SearchcraftInput;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftInputLabel$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftInputLabel$1, d as defineCustomElement$1 } from './p-ca881e5c.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftInputLabel = SearchcraftInputLabel$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { p as proxyCustomElement, H, h } from './p-
|
|
2
|
-
import { u as useSearchcraftStore } from './p-
|
|
3
|
-
|
|
4
|
-
const searchcraftPopoverButtonModuleCss = "";
|
|
5
|
-
const SearchcraftPopoverButtonStyle0 = searchcraftPopoverButtonModuleCss;
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
+
import { u as useSearchcraftStore } from './p-936e2ed4.js';
|
|
6
3
|
|
|
7
4
|
const SearchcraftPopoverButton$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverButton extends H {
|
|
8
5
|
constructor() {
|
|
@@ -13,9 +10,8 @@ const SearchcraftPopoverButton$1 = /*@__PURE__*/ proxyCustomElement(class Search
|
|
|
13
10
|
useSearchcraftStore.getState().setPopoverVisibility(true);
|
|
14
11
|
}
|
|
15
12
|
render() {
|
|
16
|
-
return (h("button", { key: '
|
|
13
|
+
return (h("button", { key: '3907a514a85a79c320f529840fda06474721871a', type: 'button', onClick: this.handleOnClick.bind(this) }, h("slot", { key: '91bedc41efb5c17a774eab7a95e0abac39497408' })));
|
|
17
14
|
}
|
|
18
|
-
static get style() { return SearchcraftPopoverButtonStyle0; }
|
|
19
15
|
}, [4, "searchcraft-popover-button"]);
|
|
20
16
|
function defineCustomElement$1() {
|
|
21
17
|
if (typeof customElements === "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-popover-button.js","mappings":";;;
|
|
1
|
+
{"file":"searchcraft-popover-button.js","mappings":";;;MAUaA,0BAAwB;;;;;IACnC,aAAa;QACX,mBAAmB,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;KAC3D;IAED,MAAM;QACJ,QACE,+DAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAC1D,8DAAQ,CACD,EACT;KACH;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverButton"],"sources":["src/components/searchcraft-popover-button/searchcraft-popover-button.tsx"],"sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport { Component, h } from '@stencil/core';\n\n/**\n * Renders a button which, when clicked, turns on popover visibility.\n */\n@Component({\n tag: 'searchcraft-popover-button',\n shadow: false,\n})\nexport class SearchcraftPopoverButton {\n handleOnClick() {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n }\n\n render() {\n return (\n <button type='button' onClick={this.handleOnClick.bind(this)}>\n <slot />\n </button>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,70 +1,52 @@
|
|
|
1
|
-
import { p as proxyCustomElement, H, h } from './p-
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
2
|
import { c as classNames } from './p-5cdc6210.js';
|
|
3
|
-
import { u as useSearchcraftStore } from './p-
|
|
4
|
-
import { d as defineCustomElement$7 } from './p-
|
|
5
|
-
import { d as defineCustomElement$6 } from './p-
|
|
6
|
-
import { d as defineCustomElement$5 } from './p-
|
|
7
|
-
import { d as defineCustomElement$4 } from './p-
|
|
8
|
-
import { d as defineCustomElement$3 } from './p-
|
|
9
|
-
import { d as defineCustomElement$2 } from './p-
|
|
10
|
-
|
|
11
|
-
const searchcraftPopoverFormModuleCss = ":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-popover-form{display:flex;flex-direction:column;flex:1}.searchcraft-popover-form .searchcraft-popover-form-input-wrapper{padding:12px;background-color:var(--sc-surface-neutral-secondary);display:flex;flex-direction:row;gap:4px}.searchcraft-popover-form .searchcraft-popover-form-input-wrapper>searchcraft-input-form{flex:1}.searchcraft-popover-form .searchcraft-popover-form-cancel-button{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);border:0;outline:0;padding:0;flex-shrink:0;background:none;cursor:pointer;padding-left:12px;padding-right:12px;border-radius:calc(var(--sc-popover-form-border-radius) * 0.8)}.searchcraft-popover-form .searchcraft-popover-form-cancel-button:hover{background-color:var(--sc-surface-brand-secondary-hover)}.searchcraft-popover-form .searchcraft-popover-form-cancel-button:focus{background-color:var(--sc-surface-brand-secondary-active)}.searchcraft-popover-form-inline .searchcraft-input{border-top-left-radius:var(--sc-popover-form-border-radius);border-top-right-radius:var(--sc-popover-form-border-radius);border-bottom-left-radius:var(--sc-popover-form-border-radius);border-bottom-right-radius:var(--sc-popover-form-border-radius);border:none;outline:none}.searchcraft-popover-form-inline.searchcraft-popover-form-active .searchcraft-input{border-top-left-radius:var(--sc-popover-form-border-radius);border-top-right-radius:var(--sc-popover-form-border-radius);border-bottom-left-radius:0;border-bottom-right-radius:0}.searchcraft-popover-form-inline .searchcraft-popover-inline-wrapper-outer{position:relative}.searchcraft-popover-form-inline .searchcraft-popover-inline-wrapper-inner{position:absolute;height:var(--sc-popover-list-view-height);z-index:1000;width:100%}.searchcraft-popover-form-inline .searchcraft-popover-list-view{display:flex;flex-direction:column;overflow:auto;background-color:var(--sc-surface-neutral-secondary);border-bottom-left-radius:var(--sc-popover-form-border-radius);border-bottom-right-radius:var(--sc-popover-form-border-radius);max-height:var(--sc-popover-list-view-height)}.searchcraft-popover-form-modal{position:fixed;inset:0;z-index:1000;display:flex;align-items:flex-start;justify-content:center;padding:0;background-color:var(--sc-surface-neutral-secondary)}@media (min-width: 576px){.searchcraft-popover-form-modal{padding:16px;background-color:transparent}}.searchcraft-popover-form-modal .searchcraft-input{border-radius:calc(var(--sc-popover-form-border-radius) * 0.8);outline-width:1px;outline-color:var(--sc-border-neutral)}.searchcraft-popover-form-modal .searchcraft-popover-form-modal-backdrop{position:absolute;inset:0;background-color:rgba(0, 0, 0, 0.5);display:none}@media (min-width: 576px){.searchcraft-popover-form-modal .searchcraft-popover-form-modal-backdrop{display:block}}.searchcraft-popover-form-modal .searchcraft-popover-form-modal-inner{position:absolute;inset:0;z-index:1002;margin-top:0px;display:flex;border-radius:var(--sc-popover-form-border-radius);overflow:hidden}@media (min-width: 576px){.searchcraft-popover-form-modal .searchcraft-popover-form-modal-inner{inset:auto;position:relative;width:100%;margin-top:100px;max-width:var(--sc-popover-modal-max-width)}}.searchcraft-popover-form-modal .searchcraft-popover-list-view{display:flex;flex-direction:column;overflow:auto;background-color:var(--sc-surface-neutral-secondary);border-bottom-left-radius:0;border-bottom-right-radius:0}@media (min-width: 576px){.searchcraft-popover-form-modal .searchcraft-popover-list-view{max-height:var(--sc-popover-list-view-height)}}.searchcraft-popover-form-modal searchcraft-popover-list-view{overflow:scroll}@media (min-width: 576px){.searchcraft-popover-form-modal searchcraft-popover-list-view{overflow:auto}}.searchcraft-popover-form-fullscreen{position:fixed;inset:0;z-index:1000;background-color:var(--sc-surface-neutral-secondary)}.searchcraft-popover-form-fullscreen .searchcraft-popover-form{position:absolute;inset:0}.searchcraft-popover-form-fullscreen .searchcraft-input{border-radius:calc(var(--sc-popover-form-border-radius) * 0.8);outline-width:1px;outline-color:var(--sc-border-neutral)}.searchcraft-popover-form-fullscreen searchcraft-popover-list-view{overflow:scroll}";
|
|
12
|
-
const SearchcraftPopoverFormStyle0 = searchcraftPopoverFormModuleCss;
|
|
3
|
+
import { u as useSearchcraftStore } from './p-936e2ed4.js';
|
|
4
|
+
import { d as defineCustomElement$7 } from './p-521fe971.js';
|
|
5
|
+
import { d as defineCustomElement$6 } from './p-a75ef832.js';
|
|
6
|
+
import { d as defineCustomElement$5 } from './p-d95bc2a0.js';
|
|
7
|
+
import { d as defineCustomElement$4 } from './p-ca881e5c.js';
|
|
8
|
+
import { d as defineCustomElement$3 } from './p-0ef4ab33.js';
|
|
9
|
+
import { d as defineCustomElement$2 } from './p-506cdac1.js';
|
|
13
10
|
|
|
14
11
|
const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverForm extends H {
|
|
15
12
|
constructor() {
|
|
16
13
|
super();
|
|
17
14
|
this.__registerHost();
|
|
18
|
-
this.handleDocumentClick = (event) => {
|
|
19
|
-
if (!this.hostElement.contains(event.target)) {
|
|
20
|
-
this.isFocused = false;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Actions to perform when various keys are pressed within the popover form.
|
|
25
|
-
*/
|
|
26
|
-
this.handleDocumentKeyDown = (event) => {
|
|
27
|
-
// Document-scoped actions
|
|
28
|
-
if (event.key === this.hotkey) {
|
|
29
|
-
this.handleHotkeyPressed(event);
|
|
30
|
-
}
|
|
31
|
-
// Document-scoped -> Popover-scoped keyboard event boundary
|
|
32
|
-
if (!this.hostElement.contains(document.activeElement)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// Popover-scoped actions
|
|
36
|
-
switch (event.key) {
|
|
37
|
-
case 'ArrowDown':
|
|
38
|
-
case 'ArrowUp':
|
|
39
|
-
event.preventDefault();
|
|
40
|
-
this.focusOnNextListItem(event.key);
|
|
41
|
-
break;
|
|
42
|
-
case 'Escape':
|
|
43
|
-
useSearchcraftStore.getState().setPopoverVisibility(false);
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
this.handleInputInit = () => {
|
|
50
|
-
const input = this.hostElement.querySelector('.searchcraft-input');
|
|
51
|
-
input === null || input === void 0 ? void 0 : input.focus();
|
|
52
|
-
};
|
|
53
|
-
this.config = undefined;
|
|
54
|
-
this.type = 'inline';
|
|
55
|
-
this.popoverResultMappings = undefined;
|
|
56
|
-
this.hotkey = 'k';
|
|
57
|
-
this.hotkeyModifier = 'meta';
|
|
58
|
-
this.isPopoverVisibleInState = false;
|
|
59
|
-
this.unsubscribe = undefined;
|
|
60
|
-
this.searchResults = undefined;
|
|
61
|
-
this.searchTerm = undefined;
|
|
62
|
-
this.isFocused = false;
|
|
63
|
-
this.breakpointSm = 576;
|
|
64
|
-
this.breakpointMd = 768;
|
|
65
|
-
this.breakpointLg = 992;
|
|
66
|
-
this.modalElement = undefined;
|
|
67
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The Searchcraft config object.
|
|
18
|
+
*/
|
|
19
|
+
config;
|
|
20
|
+
/**
|
|
21
|
+
* The type of popover form to render.
|
|
22
|
+
*
|
|
23
|
+
* - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.
|
|
24
|
+
* - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.
|
|
25
|
+
* - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.
|
|
26
|
+
*/
|
|
27
|
+
type = 'inline';
|
|
28
|
+
/**
|
|
29
|
+
* Formats the content rendered for each result.
|
|
30
|
+
*/
|
|
31
|
+
popoverResultMappings;
|
|
32
|
+
/**
|
|
33
|
+
* The hotkey that activates the popover.
|
|
34
|
+
*/
|
|
35
|
+
hotkey = 'k';
|
|
36
|
+
/**
|
|
37
|
+
* The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
|
|
38
|
+
*/
|
|
39
|
+
hotkeyModifier = 'meta';
|
|
40
|
+
isPopoverVisibleInState = false;
|
|
41
|
+
unsubscribe;
|
|
42
|
+
searchResults;
|
|
43
|
+
searchTerm;
|
|
44
|
+
isFocused = false;
|
|
45
|
+
breakpointSm = 576;
|
|
46
|
+
breakpointMd = 768;
|
|
47
|
+
breakpointLg = 992;
|
|
48
|
+
modalElement;
|
|
49
|
+
get hostElement() { return this; }
|
|
68
50
|
componentDidLoad() {
|
|
69
51
|
// Loads the breakpoint values into state
|
|
70
52
|
const computedStyle = getComputedStyle(document.documentElement);
|
|
@@ -82,16 +64,20 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
82
64
|
if (this.isPopoverVisibleInState !== state.isPopoverVisible) {
|
|
83
65
|
this.handlePopoverVisibilityChange(state.isPopoverVisible);
|
|
84
66
|
}
|
|
85
|
-
this.searchResults =
|
|
67
|
+
this.searchResults = { ...state.searchResults };
|
|
86
68
|
this.searchTerm = state.query;
|
|
87
69
|
});
|
|
88
70
|
}
|
|
89
71
|
disconnectedCallback() {
|
|
90
|
-
|
|
91
|
-
(_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
72
|
+
this.unsubscribe?.();
|
|
92
73
|
document.removeEventListener('click', this.handleDocumentClick);
|
|
93
74
|
document.removeEventListener('keydown', this.handleDocumentKeyDown);
|
|
94
75
|
}
|
|
76
|
+
handleDocumentClick = (event) => {
|
|
77
|
+
if (!this.hostElement.contains(event.target)) {
|
|
78
|
+
this.isFocused = false;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
95
81
|
/**
|
|
96
82
|
* Handles when popover visibility is changed in state
|
|
97
83
|
*/
|
|
@@ -99,6 +85,36 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
99
85
|
this.isPopoverVisibleInState = isVisible;
|
|
100
86
|
document.body.style.overflow = isVisible ? 'hidden' : 'auto';
|
|
101
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Actions to perform when various keys are pressed within the popover form.
|
|
90
|
+
*/
|
|
91
|
+
handleDocumentKeyDown = (event) => {
|
|
92
|
+
// Document-scoped actions
|
|
93
|
+
if (event.key === this.hotkey) {
|
|
94
|
+
this.handleHotkeyPressed(event);
|
|
95
|
+
}
|
|
96
|
+
// Document-scoped -> Popover-scoped keyboard event boundary
|
|
97
|
+
if (!this.hostElement.contains(document.activeElement)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Popover-scoped actions
|
|
101
|
+
switch (event.key) {
|
|
102
|
+
case 'ArrowDown':
|
|
103
|
+
case 'ArrowUp':
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
this.focusOnNextListItem(event.key);
|
|
106
|
+
break;
|
|
107
|
+
case 'Escape':
|
|
108
|
+
useSearchcraftStore.getState().setPopoverVisibility(false);
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
handleInputInit = () => {
|
|
115
|
+
const input = this.hostElement.querySelector('.searchcraft-input');
|
|
116
|
+
input?.focus();
|
|
117
|
+
};
|
|
102
118
|
/**
|
|
103
119
|
* When popover is `inline` and the viewport is at the smallest breakpoint,
|
|
104
120
|
* focusing on the input will open a modal version of the popover form.
|
|
@@ -106,6 +122,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
106
122
|
handleInputFocus() {
|
|
107
123
|
this.isFocused = true;
|
|
108
124
|
if (this.type === 'inline' &&
|
|
125
|
+
window.visualViewport &&
|
|
109
126
|
window.visualViewport.width < this.breakpointSm) {
|
|
110
127
|
useSearchcraftStore.getState().setPopoverVisibility(true);
|
|
111
128
|
// Appends a popover form of type=`modal` to the body
|
|
@@ -132,7 +149,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
132
149
|
event.preventDefault();
|
|
133
150
|
if (this.type === 'inline' && !this.isPopoverVisibleInState) {
|
|
134
151
|
const hostElementInput = this.hostElement.querySelector('.searchcraft-input');
|
|
135
|
-
hostElementInput
|
|
152
|
+
hostElementInput?.focus();
|
|
136
153
|
}
|
|
137
154
|
else {
|
|
138
155
|
useSearchcraftStore
|
|
@@ -151,15 +168,14 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
151
168
|
* @param direction
|
|
152
169
|
*/
|
|
153
170
|
focusOnNextListItem(direction) {
|
|
154
|
-
var _a, _b;
|
|
155
171
|
const listItems = Array.from(document.querySelectorAll('a.searchcraft-popover-list-item')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
|
|
156
172
|
const currentIndex = listItems.indexOf(document.activeElement);
|
|
157
173
|
if (direction === 'ArrowDown') {
|
|
158
|
-
|
|
174
|
+
listItems[(currentIndex + 1) % listItems.length]?.focus();
|
|
159
175
|
}
|
|
160
176
|
else if (direction === 'ArrowUp') {
|
|
161
177
|
if (currentIndex >= 1) {
|
|
162
|
-
|
|
178
|
+
listItems[currentIndex - 1]?.focus();
|
|
163
179
|
}
|
|
164
180
|
else {
|
|
165
181
|
const input = document.querySelector('.searchcraft-input');
|
|
@@ -174,9 +190,9 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
174
190
|
}
|
|
175
191
|
}
|
|
176
192
|
get hasResultsToShow() {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
(
|
|
193
|
+
return (this.searchTerm &&
|
|
194
|
+
this.searchTerm?.trim()?.length > 0 &&
|
|
195
|
+
(this.searchResults?.data?.hits?.length || 0) > 0);
|
|
180
196
|
}
|
|
181
197
|
renderInlinePopover(documents) {
|
|
182
198
|
const isListViewVisible = this.hasResultsToShow && this.isFocused;
|
|
@@ -199,8 +215,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
199
215
|
}
|
|
200
216
|
}
|
|
201
217
|
render() {
|
|
202
|
-
|
|
203
|
-
const documents = (_c = (_b = (_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.map((data, _index) => {
|
|
218
|
+
const documents = this.searchResults?.data?.hits?.map((data, _index) => {
|
|
204
219
|
const { doc: result } = data;
|
|
205
220
|
return result;
|
|
206
221
|
});
|
|
@@ -213,8 +228,6 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
213
228
|
return this.renderFullscreenPopover(documents);
|
|
214
229
|
}
|
|
215
230
|
}
|
|
216
|
-
get hostElement() { return this; }
|
|
217
|
-
static get style() { return SearchcraftPopoverFormStyle0; }
|
|
218
231
|
}, [0, "searchcraft-popover-form", {
|
|
219
232
|
"config": [16],
|
|
220
233
|
"type": [1],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-popover-form.js","mappings":";;;;;;;;;;AAAA,MAAM,+BAA+B,GAAG,+iPAA+iP,CAAC;AACxlP,qCAAe,+BAA+B;;MCyCjCA,wBAAsB;;;;QA4EjC,wBAAmB,GAAG,CAAC,KAAiB;YACtC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,EAAE;gBACpD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;aACxB;SACF,CAAC;;;;QAaF,0BAAqB,GAAG,CAAC,KAAoB;;YAE3C,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,MAAM,EAAE;gBAC7B,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACjC;;YAGD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;gBACtD,OAAO;aACR;;YAGD,QAAQ,KAAK,CAAC,GAAG;gBACf,KAAK,WAAW,CAAC;gBACjB,KAAK,SAAS;oBACZ,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CA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K,EAAC,wCAAwC,IACjD,8BACE,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9C,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAC5C,EACF,cACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,wCAAwC,EAC9C,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,aAGzC,CACL,EACL,IAAI,CAAC,gBAAgB,KACpB,qCACE,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,SAAS,EAAE,SAAS,GACpB,CACH,CACG,CACF,EACN;SACH;KACF;IAED,MAAM;;QACJ,MAAM,SAAS,GACb,MAAA,MAAA,MAAA,IAAI,CAAC,aAAa,0CAAE,IAAI,0CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM;YAC/C,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAC7B,OAAO,MAAM,CAAC;SACf,CAAC,CAAC;QAEL,QAAQ,IAAI,CAAC,IAAI;YACf,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC7C,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC5C,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;SAClD;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.module.scss?tag=searchcraft-popover-form","src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["/**\n * Styles applied to all popover form variants.\n */\n.searchcraft-popover-form {\n display: flex;\n flex-direction: column;\n flex: 1;\n\n & .searchcraft-popover-form-input-wrapper {\n padding: 12px;\n background-color: var(--sc-surface-neutral-secondary);\n display: flex;\n flex-direction: row;\n gap: 4px;\n }\n\n & .searchcraft-popover-form-input-wrapper > searchcraft-input-form {\n flex: 1;\n }\n\n & .searchcraft-popover-form-cancel-button {\n @include body();\n border: 0;\n outline: 0;\n padding: 0;\n flex-shrink: 0;\n background: none;\n cursor: pointer;\n padding-left: 12px;\n padding-right: 12px;\n border-radius: calc(var(--sc-popover-form-border-radius) * 0.8);\n\n &:hover {\n background-color: var(--sc-surface-brand-secondary-hover);\n }\n\n &:focus {\n background-color: var(--sc-surface-brand-secondary-active);\n }\n }\n}\n\n/**\n * Styles applied to `inline` popover forms.\n */\n.searchcraft-popover-form-inline {\n & .searchcraft-input {\n border-top-left-radius: var(--sc-popover-form-border-radius);\n border-top-right-radius: var(--sc-popover-form-border-radius);\n border-bottom-left-radius: var(--sc-popover-form-border-radius);\n border-bottom-right-radius: var(--sc-popover-form-border-radius);\n border: none;\n outline: none;\n }\n\n &.searchcraft-popover-form-active .searchcraft-input {\n border-top-left-radius: var(--sc-popover-form-border-radius);\n border-top-right-radius: var(--sc-popover-form-border-radius);\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n }\n\n & .searchcraft-popover-inline-wrapper-outer {\n position: relative;\n }\n\n & .searchcraft-popover-inline-wrapper-inner {\n position: absolute;\n height: var(--sc-popover-list-view-height);\n z-index: 1000;\n width: 100%;\n }\n\n & .searchcraft-popover-list-view {\n display: flex;\n flex-direction: column;\n overflow: auto;\n background-color: var(--sc-surface-neutral-secondary);\n border-bottom-left-radius: var(--sc-popover-form-border-radius);\n border-bottom-right-radius: var(--sc-popover-form-border-radius);\n max-height: var(--sc-popover-list-view-height)\n }\n}\n\n/**\n * Styles applied to `modal` popover forms.\n */\n.searchcraft-popover-form-modal {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding: 0;\n background-color: var(--sc-surface-neutral-secondary);\n\n @media (min-width: $breakpoint-sm) {\n padding: 16px;\n background-color: transparent;\n }\n\n & .searchcraft-input {\n border-radius: calc(var(--sc-popover-form-border-radius) * 0.8);\n outline-width: 1px;\n outline-color: var(--sc-border-neutral);\n }\n\n & .searchcraft-popover-form-modal-backdrop {\n position: absolute;\n inset: 0;\n background-color: rgba(0,0,0, 0.5);\n display: none;\n\n @media (min-width: $breakpoint-sm) {\n display: block;\n }\n }\n\n & .searchcraft-popover-form-modal-inner {\n position: absolute;\n inset: 0;\n z-index: 1002;\n margin-top: 0px;\n display: flex;\n border-radius: var(--sc-popover-form-border-radius);\n overflow: hidden;\n\n @media (min-width: $breakpoint-sm) {\n inset: auto;\n position: relative;\n width: 100%;\n margin-top: 100px;\n max-width: var(--sc-popover-modal-max-width);\n }\n }\n\n & .searchcraft-popover-list-view {\n display: flex;\n flex-direction: column;\n overflow: auto;\n background-color: var(--sc-surface-neutral-secondary);\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n\n @media (min-width: $breakpoint-sm) {\n max-height: var(--sc-popover-list-view-height)\n }\n }\n\n & searchcraft-popover-list-view {\n overflow: scroll;\n\n @media (min-width: $breakpoint-sm) {\n overflow: auto;\n }\n }\n}\n\n/**\n * Styles applied to `fullscreen` popover forms.\n */\n.searchcraft-popover-form-fullscreen {\n position: fixed;\n inset: 0;\n z-index: 1000;\n background-color: var(--sc-surface-neutral-secondary);\n\n & .searchcraft-popover-form {\n position: absolute;\n inset: 0;\n }\n\n & .searchcraft-input {\n border-radius: calc(var(--sc-popover-form-border-radius) * 0.8);\n outline-width: 1px;\n outline-color: var(--sc-border-neutral);\n }\n\n & searchcraft-popover-list-view {\n overflow: scroll;\n }\n}\n","import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type { SearchcraftConfig, SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\nimport type { PopoverResultMappings } from 'types';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"fullscreen\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.config = {\n * index: [index_name_from_vektron],\n * readKey: 'read_key_from_vektron',\n * endpointUrl: 'enpoint_url_from_vektron',\n * };\n *\n * popoverForm.popoverResultMappings = {\n * containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-form',\n styleUrl: 'searchcraft-popover-form.module.scss',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * The type of popover form to render.\n *\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchResults: SearchcraftResponse | undefined;\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState =\n useSearchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchResults = { ...state.searchResults };\n this.searchTerm = state.query;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n useSearchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport.width < this.breakpointSm\n ) {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.config = this.config;\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n useSearchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n 'a.searchcraft-popover-list-item',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm?.trim()?.length > 0 &&\n this.searchResults?.data?.hits?.length > 0\n );\n }\n\n renderInlinePopover(documents: Record<string, unknown>[]) {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n const popoverFormClassNames = classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n );\n\n return (\n <div class={popoverFormClassNames}>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n {isListViewVisible && (\n <div class='searchcraft-popover-inline-wrapper-outer'>\n <div class='searchcraft-popover-inline-wrapper-inner'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover(documents: Record<string, unknown>[]) {\n if (this.isPopoverVisibleInState) {\n const popoverFormClassNames = classNames('searchcraft-popover-form', {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n });\n\n return (\n <div class='searchcraft-popover-form-modal'>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-inner'>\n <div class={popoverFormClassNames}>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n )}\n </div>\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover(documents: Record<string, unknown>[]) {\n if (this.isPopoverVisibleInState) {\n return (\n <div class='searchcraft-popover-form-fullscreen'>\n <div class='searchcraft-popover-form'>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n )}\n </div>\n </div>\n );\n }\n }\n\n render() {\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 switch (this.type) {\n case 'inline':\n return this.renderInlinePopover(documents);\n case 'modal':\n return this.renderModalPopover(documents);\n case 'fullscreen':\n return this.renderFullscreenPopover(documents);\n }\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"searchcraft-popover-form.js","mappings":";;;;;;;;;;MAyCaA,wBAAsB;;;;;;;;IAIzB,MAAM,CAAgC;;;;;;;;IAQtC,IAAI,GAAsC,QAAQ,CAAC;;;;IAInD,qBAAqB,CAAoC;;;;IAIzD,MAAM,GAAG,GAAG,CAAC;;;;IAIb,cAAc,GAAuC,MAAM,CAAC;IAE3D,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,CAA2B;IACtC,aAAa,CAAkC;IAC/C,UAAU,CAAqB;IAC/B,SAAS,GAAG,KAAK,CAAC;IAClB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IAC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AAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC7C,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC5C,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;SAClD;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type { SearchcraftConfig, SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\nimport type { PopoverResultMappings } from 'types';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"fullscreen\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.config = {\n * index: [index_name_from_vektron],\n * readKey: 'read_key_from_vektron',\n * endpointUrl: 'enpoint_url_from_vektron',\n * };\n *\n * popoverForm.popoverResultMappings = {\n * containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * The type of popover form to render.\n *\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchResults: SearchcraftResponse | undefined;\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState =\n useSearchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchResults = { ...state.searchResults } as SearchcraftResponse;\n this.searchTerm = state.query;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n useSearchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport &&\n window.visualViewport.width < this.breakpointSm\n ) {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.config = this.config;\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n useSearchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n 'a.searchcraft-popover-list-item',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm &&\n this.searchTerm?.trim()?.length > 0 &&\n (this.searchResults?.data?.hits?.length || 0) > 0\n );\n }\n\n renderInlinePopover(documents: Record<string, unknown>[]) {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n const popoverFormClassNames = classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n );\n\n return (\n <div class={popoverFormClassNames}>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n {isListViewVisible && (\n <div class='searchcraft-popover-inline-wrapper-outer'>\n <div class='searchcraft-popover-inline-wrapper-inner'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover(documents: Record<string, unknown>[]) {\n if (this.isPopoverVisibleInState) {\n const popoverFormClassNames = classNames('searchcraft-popover-form', {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n });\n\n return (\n <div class='searchcraft-popover-form-modal'>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-inner'>\n <div class={popoverFormClassNames}>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n )}\n </div>\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover(documents: Record<string, unknown>[]) {\n if (this.isPopoverVisibleInState) {\n return (\n <div class='searchcraft-popover-form-fullscreen'>\n <div class='searchcraft-popover-form'>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n documents={documents}\n />\n )}\n </div>\n </div>\n );\n }\n }\n\n render() {\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n }) as Record<string, unknown>[];\n\n switch (this.type) {\n case 'inline':\n return this.renderInlinePopover(documents);\n case 'modal':\n return this.renderModalPopover(documents);\n case 'fullscreen':\n return this.renderFullscreenPopover(documents);\n }\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './p-0ef4ab33.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftPopoverListItem = SearchcraftPopoverListItem$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './p-506cdac1.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftPopoverListView = SearchcraftPopoverListView$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import { p as proxyCustomElement, H, h } from './p-
|
|
2
|
-
import { u as useSearchcraftStore } from './p-
|
|
1
|
+
import { p as proxyCustomElement, H, h } from './p-5365011f.js';
|
|
2
|
+
import { u as useSearchcraftStore } from './p-936e2ed4.js';
|
|
3
3
|
import { f as formatNumberWithCommas } from './p-755f491b.js';
|
|
4
4
|
|
|
5
|
-
const searchcraftResultsInfoModuleCss = ":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-results-info-container{border-bottom:1px solid var(--sc-surface-disabled);display:flex;justify-content:flex-start}.searchcraft-results-info-content{color:var(--sc-content-primary);font-family:var(--sc-font-family);font-size:18px;font-weight:600;line-height:20px;margin:0px 0 8px}@media (max-width: 768px){.searchcraft-results-info-content{margin:0;margin-bottom:8px}}";
|
|
6
|
-
const SearchcraftResultsInfoStyle0 = searchcraftResultsInfoModuleCss;
|
|
7
|
-
|
|
8
5
|
const SearchcraftResultsInfo$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftResultsInfo extends H {
|
|
9
6
|
constructor() {
|
|
10
7
|
super();
|
|
11
8
|
this.__registerHost();
|
|
12
|
-
this.isRequesting = false;
|
|
13
|
-
this.resultsCount = 0;
|
|
14
|
-
this.responseTime = '';
|
|
15
|
-
this.query = '';
|
|
16
9
|
}
|
|
10
|
+
isRequesting = false;
|
|
11
|
+
resultsCount = 0;
|
|
12
|
+
responseTime = '';
|
|
13
|
+
query = '';
|
|
14
|
+
unsubscribe = () => { };
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.unsubscribe = useSearchcraftStore.subscribe((state) => {
|
|
19
|
-
var _a, _b, _c, _d;
|
|
20
17
|
this.isRequesting = state.isRequesting;
|
|
21
|
-
this.resultsCount =
|
|
22
|
-
this.responseTime = ((
|
|
18
|
+
this.resultsCount = state.searchResults?.data?.count || 0;
|
|
19
|
+
this.responseTime = ((state.searchResults?.data?.time_taken || 0) * 1000).toFixed(2);
|
|
23
20
|
this.query = state.query || '';
|
|
24
21
|
});
|
|
25
22
|
}
|
|
@@ -35,7 +32,6 @@ const SearchcraftResultsInfo$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
|
|
|
35
32
|
const formattedResults = formatNumberWithCommas(this.resultsCount);
|
|
36
33
|
return (h("div", { class: 'searchcraft-results-info-container' }, h("p", { class: 'searchcraft-results-info-content' }, formattedResults, " results found in ", this.responseTime, "ms")));
|
|
37
34
|
}
|
|
38
|
-
static get style() { return SearchcraftResultsInfoStyle0; }
|
|
39
35
|
}, [0, "searchcraft-results-info", {
|
|
40
36
|
"isRequesting": [32],
|
|
41
37
|
"resultsCount": [32],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"searchcraft-results-info.js","mappings":";;;;
|
|
1
|
+
{"file":"searchcraft-results-info.js","mappings":";;;;MAoBaA,wBAAsB;;;;;IACxB,YAAY,GAAG,KAAK,CAAC;IACrB,YAAY,GAAG,CAAC,CAAC;IACjB,YAAY,GAAG,EAAE,CAAC;IAClB,KAAK,GAAG,EAAE,CAAC;IAEpB,WAAW,GAAe,SAAQ,CAAC;IAEnC,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YACrD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC;YAC1D,IAAI,CAAC,YAAY,GAAG,CAClB,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,UAAU,IAAI,CAAC,IAAI,IAAI,EACnD,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;SAChC,CAAC,CAAC;KACJ;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,EAAE,CAAC;SACpB;KACF;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE;YAC1C,OAAO,IAAI,CAAC;SACb;QACD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,QACE,WAAK,KAAK,EAAC,oCAAoC,IAC7C,SAAG,KAAK,EAAC,kCAAkC,IACxC,gBAAgB,wBAAoB,IAAI,CAAC,YAAY,OACpD,CACA,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftResultsInfo"],"sources":["src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"sourcesContent":["import { Component, h, State } from '@stencil/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport { formatNumberWithCommas } from '@utils';\n\n/**\n * This web component is designed to display the number of results returned from a search query.\n * It provides users with real-time feedback on the scale of the results, such as the total number of items found.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-results-info />\n * ```\n */\n@Component({\n tag: 'searchcraft-results-info',\n shadow: false,\n})\nexport class SearchcraftResultsInfo {\n @State() isRequesting = false;\n @State() resultsCount = 0;\n @State() responseTime = '';\n @State() query = '';\n\n unsubscribe: () => void = () => {};\n\n connectedCallback() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n this.isRequesting = state.isRequesting;\n this.resultsCount = state.searchResults?.data?.count || 0;\n this.responseTime = (\n (state.searchResults?.data?.time_taken || 0) * 1000\n ).toFixed(2);\n this.query = state.query || '';\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n render() {\n if (!this.query || this.resultsCount === 0) {\n return null;\n }\n const formattedResults = formatNumberWithCommas(this.resultsCount);\n return (\n <div class='searchcraft-results-info-container'>\n <p class='searchcraft-results-info-content'>\n {formattedResults} results found in {this.responseTime}ms\n </p>\n </div>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SearchcraftSlider$1, d as defineCustomElement$1 } from './p-
|
|
1
|
+
import { S as SearchcraftSlider$1, d as defineCustomElement$1 } from './p-4b92ae26.js';
|
|
2
2
|
|
|
3
3
|
const SearchcraftSlider = SearchcraftSlider$1;
|
|
4
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SearchcraftTheme extends Components.SearchcraftTheme, HTMLElement {}
|
|
4
|
+
export const SearchcraftTheme: {
|
|
5
|
+
prototype: SearchcraftTheme;
|
|
6
|
+
new (): SearchcraftTheme;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|