@searchcraft/javascript-sdk 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/README.md +25 -37
  2. package/dist/components/defineCustomElements.d.ts +1 -0
  3. package/dist/components/defineCustomElements.js +46 -0
  4. package/dist/components/index.d.ts +44 -11
  5. package/dist/components/index.js +104 -53
  6. package/dist/components/index.js.map +1 -1
  7. package/dist/components/p-05872320.js +1462 -0
  8. package/dist/components/p-05872320.js.map +1 -0
  9. package/dist/components/{p-433f974c.js → p-11b05b94.js} +5 -5
  10. package/dist/components/p-11b05b94.js.map +1 -0
  11. package/dist/components/{p-ae78be68.js → p-3026f7d3.js} +18 -127
  12. package/dist/components/p-3026f7d3.js.map +1 -0
  13. package/dist/components/{p-ec0d230e.js → p-3568414f.js} +4 -4
  14. package/dist/components/p-3568414f.js.map +1 -0
  15. package/dist/{cjs/SearchcraftStore-75fac5e0.js → components/p-6d8b0ead.js} +1408 -1350
  16. package/dist/components/p-6d8b0ead.js.map +1 -0
  17. package/dist/components/{p-d19bf6ff.js → p-71cc28c1.js} +2 -2
  18. package/dist/components/p-71cc28c1.js.map +1 -0
  19. package/dist/components/{p-fc7cda96.js → p-7777d986.js} +4 -4
  20. package/dist/components/{p-fc7cda96.js.map → p-7777d986.js.map} +1 -1
  21. package/dist/components/p-b0bc5cee.js +102 -0
  22. package/dist/components/p-b0bc5cee.js.map +1 -0
  23. package/dist/components/{p-4e9cd62e.js → p-bb12ab5a.js} +3 -3
  24. package/dist/components/{p-4e9cd62e.js.map → p-bb12ab5a.js.map} +1 -1
  25. package/dist/components/{p-97332d3e.js → p-cd9ba361.js} +3 -3
  26. package/dist/components/p-cd9ba361.js.map +1 -0
  27. package/dist/components/searchcraft-ad.d.ts +11 -0
  28. package/dist/components/searchcraft-ad.js +8 -0
  29. package/dist/components/searchcraft-ad.js.map +1 -0
  30. package/dist/components/searchcraft-base-search-result.js +1 -1
  31. package/dist/components/searchcraft-base-search-results.js +79 -29
  32. package/dist/components/searchcraft-base-search-results.js.map +1 -1
  33. package/dist/components/searchcraft-button.js +1 -1
  34. package/dist/components/searchcraft-facet-list.js +1 -1
  35. package/dist/components/searchcraft-filter-panel.js +7 -7
  36. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  37. package/dist/components/searchcraft-input-form.js +1 -1
  38. package/dist/components/searchcraft-pagination.js +5 -5
  39. package/dist/components/searchcraft-pagination.js.map +1 -1
  40. package/dist/components/searchcraft-popover-button.js +3 -3
  41. package/dist/components/searchcraft-popover-button.js.map +1 -1
  42. package/dist/components/searchcraft-popover-form.js +28 -35
  43. package/dist/components/searchcraft-popover-form.js.map +1 -1
  44. package/dist/components/searchcraft-popover-list-item.js +1 -1
  45. package/dist/components/searchcraft-popover-list-view.js +1 -1
  46. package/dist/components/searchcraft-results-info.js +2 -2
  47. package/dist/components/searchcraft-results-info.js.map +1 -1
  48. package/dist/components/searchcraft-search-results-per-page.js +3 -3
  49. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  50. package/dist/components/searchcraft-slider.js +1 -1
  51. package/dist/components/searchcraft-theme.js +1 -1
  52. package/dist/components/searchcraft-theme.js.map +1 -1
  53. package/dist/components/searchcraft-toggle-button.js +1 -1
  54. package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +19 -0
  55. package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +10 -7
  56. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +1 -1
  57. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +4 -29
  58. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +1 -11
  59. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +4 -0
  60. package/dist/types/components.d.ts +33 -158
  61. package/dist/types/index.d.ts +10 -1
  62. package/dist/types/store/SearchcraftStore.d.ts +4 -0
  63. package/dist/types/{provider → store}/SearchcraftStore.types.d.ts +2 -1
  64. package/dist/{collection/provider/store.js → types/store/index.d.ts} +2 -2
  65. package/package.json +8 -17
  66. package/dist/cjs/SearchcraftStore-75fac5e0.js.map +0 -1
  67. package/dist/cjs/app-globals-3a1e7e63.js +0 -7
  68. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  69. package/dist/cjs/index-5b0b9d4c.js +0 -84
  70. package/dist/cjs/index-5b0b9d4c.js.map +0 -1
  71. package/dist/cjs/index-a81df4f0.js +0 -1577
  72. package/dist/cjs/index-a81df4f0.js.map +0 -1
  73. package/dist/cjs/index.cjs.js +0 -14
  74. package/dist/cjs/index.cjs.js.map +0 -1
  75. package/dist/cjs/loader.cjs.js +0 -17
  76. package/dist/cjs/loader.cjs.js.map +0 -1
  77. package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js +0 -152
  78. package/dist/cjs/searchcraft-base-search-result_2.cjs.entry.js.map +0 -1
  79. package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +0 -97
  80. package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +0 -1
  81. package/dist/cjs/searchcraft-button_3.cjs.entry.js +0 -88
  82. package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +0 -1
  83. package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +0 -393
  84. package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +0 -1
  85. package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +0 -113
  86. package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +0 -1
  87. package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +0 -260
  88. package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +0 -1
  89. package/dist/cjs/searchcraft-javascript-sdk.cjs.js +0 -27
  90. package/dist/cjs/searchcraft-javascript-sdk.cjs.js.map +0 -1
  91. package/dist/cjs/searchcraft-pagination.cjs.entry.js +0 -106
  92. package/dist/cjs/searchcraft-pagination.cjs.entry.js.map +0 -1
  93. package/dist/cjs/searchcraft-popover-button.cjs.entry.js +0 -22
  94. package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +0 -1
  95. package/dist/cjs/searchcraft-popover-form.cjs.entry.js +0 -234
  96. package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +0 -1
  97. package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js +0 -101
  98. package/dist/cjs/searchcraft-popover-list-item_2.cjs.entry.js.map +0 -1
  99. package/dist/cjs/searchcraft-results-info.cjs.entry.js +0 -80
  100. package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +0 -1
  101. package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js +0 -75
  102. package/dist/cjs/searchcraft-search-results-per-page.cjs.entry.js.map +0 -1
  103. package/dist/cjs/searchcraft-select.cjs.entry.js +0 -70
  104. package/dist/cjs/searchcraft-select.cjs.entry.js.map +0 -1
  105. package/dist/cjs/searchcraft-theme.cjs.entry.js +0 -56
  106. package/dist/cjs/searchcraft-theme.cjs.entry.js.map +0 -1
  107. package/dist/cjs/styles-7b2d06f2.js +0 -28
  108. package/dist/cjs/styles-7b2d06f2.js.map +0 -1
  109. package/dist/cjs/units-fe4d8083.js +0 -88
  110. package/dist/cjs/units-fe4d8083.js.map +0 -1
  111. package/dist/collection/collection-manifest.json +0 -32
  112. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +0 -302
  113. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +0 -1
  114. package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js +0 -73
  115. package/dist/collection/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.js.map +0 -1
  116. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +0 -313
  117. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +0 -1
  118. package/dist/collection/components/searchcraft-button/searchcraft-button.js +0 -217
  119. package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +0 -1
  120. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +0 -44
  121. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +0 -1
  122. package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +0 -200
  123. package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +0 -1
  124. package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +0 -149
  125. package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +0 -1
  126. package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +0 -443
  127. package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +0 -1
  128. package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +0 -67
  129. package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +0 -1
  130. package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js +0 -141
  131. package/dist/collection/components/searchcraft-pagination/searchcraft-pagination.js.map +0 -1
  132. package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +0 -15
  133. package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +0 -1
  134. package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +0 -381
  135. package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +0 -1
  136. package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +0 -128
  137. package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +0 -1
  138. package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js +0 -73
  139. package/dist/collection/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.js.map +0 -1
  140. package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +0 -141
  141. package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js.map +0 -1
  142. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +0 -138
  143. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +0 -1
  144. package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js +0 -129
  145. package/dist/collection/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.js.map +0 -1
  146. package/dist/collection/components/searchcraft-select/searchcraft-select.js +0 -261
  147. package/dist/collection/components/searchcraft-select/searchcraft-select.js.map +0 -1
  148. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +0 -194
  149. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +0 -1
  150. package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +0 -97
  151. package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +0 -1
  152. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +0 -118
  153. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +0 -1
  154. package/dist/collection/index.js +0 -3
  155. package/dist/collection/index.js.map +0 -1
  156. package/dist/collection/provider/SearchcraftStore.js +0 -160
  157. package/dist/collection/provider/SearchcraftStore.js.map +0 -1
  158. package/dist/collection/provider/SearchcraftStore.types.js +0 -2
  159. package/dist/collection/provider/SearchcraftStore.types.js.map +0 -1
  160. package/dist/collection/provider/store.js.map +0 -1
  161. package/dist/collection/utils/facets.js +0 -128
  162. package/dist/collection/utils/facets.js.map +0 -1
  163. package/dist/collection/utils/index.js +0 -4
  164. package/dist/collection/utils/index.js.map +0 -1
  165. package/dist/collection/utils/styles.js +0 -22
  166. package/dist/collection/utils/styles.js.map +0 -1
  167. package/dist/collection/utils/units.js +0 -83
  168. package/dist/collection/utils/units.js.map +0 -1
  169. package/dist/components/p-25ee7496.js +0 -58
  170. package/dist/components/p-25ee7496.js.map +0 -1
  171. package/dist/components/p-38419178.js +0 -1625
  172. package/dist/components/p-38419178.js.map +0 -1
  173. package/dist/components/p-433f974c.js.map +0 -1
  174. package/dist/components/p-97332d3e.js.map +0 -1
  175. package/dist/components/p-ae78be68.js.map +0 -1
  176. package/dist/components/p-bff4d3fc.js +0 -65
  177. package/dist/components/p-bff4d3fc.js.map +0 -1
  178. package/dist/components/p-d19bf6ff.js.map +0 -1
  179. package/dist/components/p-de4a48b1.js +0 -65
  180. package/dist/components/p-de4a48b1.js.map +0 -1
  181. package/dist/components/p-ec0d230e.js.map +0 -1
  182. package/dist/components/searchcraft-base-search-result-ad.d.ts +0 -11
  183. package/dist/components/searchcraft-base-search-result-ad.js +0 -8
  184. package/dist/components/searchcraft-base-search-result-ad.js.map +0 -1
  185. package/dist/components/searchcraft-popover-list-item-ad.d.ts +0 -11
  186. package/dist/components/searchcraft-popover-list-item-ad.js +0 -8
  187. package/dist/components/searchcraft-popover-list-item-ad.js.map +0 -1
  188. package/dist/esm/SearchcraftStore-3cfd565a.js +0 -1625
  189. package/dist/esm/SearchcraftStore-3cfd565a.js.map +0 -1
  190. package/dist/esm/app-globals-0f993ce5.js +0 -5
  191. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  192. package/dist/esm/index-3608c57d.js +0 -1548
  193. package/dist/esm/index-3608c57d.js.map +0 -1
  194. package/dist/esm/index-72ac5051.js +0 -82
  195. package/dist/esm/index-72ac5051.js.map +0 -1
  196. package/dist/esm/index.js +0 -4
  197. package/dist/esm/index.js.map +0 -1
  198. package/dist/esm/loader.js +0 -13
  199. package/dist/esm/loader.js.map +0 -1
  200. package/dist/esm/searchcraft-base-search-result_2.entry.js +0 -147
  201. package/dist/esm/searchcraft-base-search-result_2.entry.js.map +0 -1
  202. package/dist/esm/searchcraft-base-search-results.entry.js +0 -93
  203. package/dist/esm/searchcraft-base-search-results.entry.js.map +0 -1
  204. package/dist/esm/searchcraft-button_3.entry.js +0 -82
  205. package/dist/esm/searchcraft-button_3.entry.js.map +0 -1
  206. package/dist/esm/searchcraft-facet-list_3.entry.js +0 -387
  207. package/dist/esm/searchcraft-facet-list_3.entry.js.map +0 -1
  208. package/dist/esm/searchcraft-filter-panel.entry.js +0 -109
  209. package/dist/esm/searchcraft-filter-panel.entry.js.map +0 -1
  210. package/dist/esm/searchcraft-input-form_2.entry.js +0 -255
  211. package/dist/esm/searchcraft-input-form_2.entry.js.map +0 -1
  212. package/dist/esm/searchcraft-javascript-sdk.js +0 -22
  213. package/dist/esm/searchcraft-javascript-sdk.js.map +0 -1
  214. package/dist/esm/searchcraft-pagination.entry.js +0 -102
  215. package/dist/esm/searchcraft-pagination.entry.js.map +0 -1
  216. package/dist/esm/searchcraft-popover-button.entry.js +0 -18
  217. package/dist/esm/searchcraft-popover-button.entry.js.map +0 -1
  218. package/dist/esm/searchcraft-popover-form.entry.js +0 -230
  219. package/dist/esm/searchcraft-popover-form.entry.js.map +0 -1
  220. package/dist/esm/searchcraft-popover-list-item_2.entry.js +0 -96
  221. package/dist/esm/searchcraft-popover-list-item_2.entry.js.map +0 -1
  222. package/dist/esm/searchcraft-results-info.entry.js +0 -76
  223. package/dist/esm/searchcraft-results-info.entry.js.map +0 -1
  224. package/dist/esm/searchcraft-search-results-per-page.entry.js +0 -71
  225. package/dist/esm/searchcraft-search-results-per-page.entry.js.map +0 -1
  226. package/dist/esm/searchcraft-select.entry.js +0 -66
  227. package/dist/esm/searchcraft-select.entry.js.map +0 -1
  228. package/dist/esm/searchcraft-theme.entry.js +0 -52
  229. package/dist/esm/searchcraft-theme.entry.js.map +0 -1
  230. package/dist/esm/styles-961644ef.js +0 -25
  231. package/dist/esm/styles-961644ef.js.map +0 -1
  232. package/dist/esm/units-daaf96f5.js +0 -84
  233. package/dist/esm/units-daaf96f5.js.map +0 -1
  234. package/dist/index.cjs.js +0 -1
  235. package/dist/index.js +0 -1
  236. package/dist/loader/cdn.js +0 -1
  237. package/dist/loader/index.cjs.js +0 -1
  238. package/dist/loader/index.d.ts +0 -24
  239. package/dist/loader/index.es2017.js +0 -1
  240. package/dist/loader/index.js +0 -2
  241. package/dist/loader/package.json +0 -11
  242. package/dist/searchcraft-javascript-sdk/index.esm.js +0 -2
  243. package/dist/searchcraft-javascript-sdk/index.esm.js.map +0 -1
  244. package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js +0 -2
  245. package/dist/searchcraft-javascript-sdk/p-279f3e15.entry.js.map +0 -1
  246. package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js +0 -2
  247. package/dist/searchcraft-javascript-sdk/p-2bc82b48.entry.js.map +0 -1
  248. package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js +0 -2
  249. package/dist/searchcraft-javascript-sdk/p-2dc07b47.entry.js.map +0 -1
  250. package/dist/searchcraft-javascript-sdk/p-38419178.js +0 -11
  251. package/dist/searchcraft-javascript-sdk/p-38419178.js.map +0 -1
  252. package/dist/searchcraft-javascript-sdk/p-5cdc6210.js +0 -7
  253. package/dist/searchcraft-javascript-sdk/p-5cdc6210.js.map +0 -1
  254. package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js +0 -2
  255. package/dist/searchcraft-javascript-sdk/p-5e064c07.entry.js.map +0 -1
  256. package/dist/searchcraft-javascript-sdk/p-6104fe5d.js +0 -2
  257. package/dist/searchcraft-javascript-sdk/p-6104fe5d.js.map +0 -1
  258. package/dist/searchcraft-javascript-sdk/p-69da4e58.entry.js +0 -2
  259. package/dist/searchcraft-javascript-sdk/p-69da4e58.entry.js.map +0 -1
  260. package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js +0 -2
  261. package/dist/searchcraft-javascript-sdk/p-6bffd3f5.entry.js.map +0 -1
  262. package/dist/searchcraft-javascript-sdk/p-75779e4b.entry.js +0 -2
  263. package/dist/searchcraft-javascript-sdk/p-75779e4b.entry.js.map +0 -1
  264. package/dist/searchcraft-javascript-sdk/p-7e13c128.js +0 -3
  265. package/dist/searchcraft-javascript-sdk/p-7e13c128.js.map +0 -1
  266. package/dist/searchcraft-javascript-sdk/p-7f4dd50c.entry.js +0 -2
  267. package/dist/searchcraft-javascript-sdk/p-7f4dd50c.entry.js.map +0 -1
  268. package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js +0 -2
  269. package/dist/searchcraft-javascript-sdk/p-9340f4e4.entry.js.map +0 -1
  270. package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js +0 -2
  271. package/dist/searchcraft-javascript-sdk/p-a84b1548.entry.js.map +0 -1
  272. package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js +0 -2
  273. package/dist/searchcraft-javascript-sdk/p-b8ea0454.entry.js.map +0 -1
  274. package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js +0 -2
  275. package/dist/searchcraft-javascript-sdk/p-c4a9d8ab.entry.js.map +0 -1
  276. package/dist/searchcraft-javascript-sdk/p-d2fffca9.entry.js +0 -2
  277. package/dist/searchcraft-javascript-sdk/p-d2fffca9.entry.js.map +0 -1
  278. package/dist/searchcraft-javascript-sdk/p-d9551738.js +0 -2
  279. package/dist/searchcraft-javascript-sdk/p-d9551738.js.map +0 -1
  280. package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js +0 -2
  281. package/dist/searchcraft-javascript-sdk/p-e11de2d6.entry.js.map +0 -1
  282. package/dist/searchcraft-javascript-sdk/p-e1255160.js +0 -2
  283. package/dist/searchcraft-javascript-sdk/p-e1255160.js.map +0 -1
  284. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +0 -2
  285. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +0 -1
  286. package/dist/types/components/searchcraft-base-search-result-ad/searchcraft-base-search-result-ad.d.ts +0 -14
  287. package/dist/types/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.d.ts +0 -14
  288. package/dist/types/provider/SearchcraftStore.d.ts +0 -4
  289. package/dist/types/provider/store.d.ts +0 -3
@@ -1,230 +0,0 @@
1
- import { r as registerInstance, g as getElement, h } from './index-3608c57d.js';
2
- import { c as classNames } from './index-72ac5051.js';
3
- import { u as useSearchcraftStore } from './SearchcraftStore-3cfd565a.js';
4
-
5
- const SearchcraftPopoverForm = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- }
9
- /**
10
- * The Searchcraft config object.
11
- */
12
- config;
13
- /**
14
- * The type of popover form to render.
15
- *
16
- * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.
17
- * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.
18
- * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.
19
- */
20
- type = 'inline';
21
- /**
22
- * Formats the content rendered for each result.
23
- */
24
- popoverResultMappings;
25
- /**
26
- * The hotkey that activates the popover.
27
- */
28
- hotkey = 'k';
29
- /**
30
- * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.
31
- */
32
- hotkeyModifier = 'meta';
33
- isPopoverVisibleInState = false;
34
- unsubscribe;
35
- searchClientResponseItems = [];
36
- adClientResponseItems = [];
37
- searchTerm;
38
- isFocused = false;
39
- breakpointSm = 576;
40
- breakpointMd = 768;
41
- breakpointLg = 992;
42
- searchResultsPage;
43
- searchResultsPerPage;
44
- modalElement;
45
- get hostElement() { return getElement(this); }
46
- componentDidLoad() {
47
- // Loads the breakpoint values into state
48
- const computedStyle = getComputedStyle(document.documentElement);
49
- this.breakpointSm = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-sm').trim());
50
- this.breakpointMd = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-md').trim());
51
- this.breakpointLg = Number.parseFloat(computedStyle.getPropertyValue('--sc-breakpoint-lg').trim());
52
- // Set popover visiblity in state
53
- this.isPopoverVisibleInState =
54
- useSearchcraftStore.getState().isPopoverVisible;
55
- // Add event listeners
56
- document.addEventListener('click', this.handleDocumentClick);
57
- document.addEventListener('keydown', this.handleDocumentKeyDown);
58
- // Subscribe to state events
59
- this.unsubscribe = useSearchcraftStore.subscribe((state) => {
60
- if (this.isPopoverVisibleInState !== state.isPopoverVisible) {
61
- this.handlePopoverVisibilityChange(state.isPopoverVisible);
62
- }
63
- this.searchClientResponseItems = [...state.searchClientResponseItems];
64
- this.adClientResponseItems = [...state.adClientResponseItems];
65
- this.searchTerm = state.searchTerm;
66
- this.searchResultsPage = state.searchResultsPage;
67
- this.searchResultsPerPage = state.searchResultsPerPage;
68
- });
69
- }
70
- disconnectedCallback() {
71
- this.unsubscribe?.();
72
- document.removeEventListener('click', this.handleDocumentClick);
73
- document.removeEventListener('keydown', this.handleDocumentKeyDown);
74
- }
75
- handleDocumentClick = (event) => {
76
- if (!this.hostElement.contains(event.target)) {
77
- this.isFocused = false;
78
- }
79
- };
80
- /**
81
- * Handles when popover visibility is changed in state
82
- */
83
- handlePopoverVisibilityChange(isVisible) {
84
- this.isPopoverVisibleInState = isVisible;
85
- document.body.style.overflow = isVisible ? 'hidden' : 'auto';
86
- }
87
- /**
88
- * Actions to perform when various keys are pressed within the popover form.
89
- */
90
- handleDocumentKeyDown = (event) => {
91
- // Document-scoped actions
92
- if (event.key === this.hotkey) {
93
- this.handleHotkeyPressed(event);
94
- }
95
- // Document-scoped -> Popover-scoped keyboard event boundary
96
- if (!this.hostElement.contains(document.activeElement)) {
97
- return;
98
- }
99
- // Popover-scoped actions
100
- switch (event.key) {
101
- case 'ArrowDown':
102
- case 'ArrowUp':
103
- event.preventDefault();
104
- this.focusOnNextListItem(event.key);
105
- break;
106
- case 'Escape':
107
- useSearchcraftStore.getState().setPopoverVisibility(false);
108
- break;
109
- default:
110
- return;
111
- }
112
- };
113
- handleInputInit = () => {
114
- const input = this.hostElement.querySelector('.searchcraft-input');
115
- input?.focus();
116
- };
117
- /**
118
- * When popover is `inline` and the viewport is at the smallest breakpoint,
119
- * focusing on the input will open a modal version of the popover form.
120
- */
121
- handleInputFocus() {
122
- this.isFocused = true;
123
- if (this.type === 'inline' &&
124
- window.visualViewport &&
125
- window.visualViewport.width < this.breakpointSm) {
126
- useSearchcraftStore.getState().setPopoverVisibility(true);
127
- // Appends a popover form of type=`modal` to the body
128
- if (!this.modalElement) {
129
- this.modalElement = document.createElement('searchcraft-popover-form');
130
- this.modalElement.config = this.config;
131
- this.modalElement.popoverResultMappings = this.popoverResultMappings;
132
- this.modalElement.setAttribute('type', 'fullscreen');
133
- document.body.appendChild(this.modalElement);
134
- }
135
- }
136
- }
137
- handleModalBackdropClick(_event) {
138
- useSearchcraftStore.getState().setPopoverVisibility(false);
139
- }
140
- /**
141
- * When a hotkey is pressed, tests if the modifiers also match.
142
- * If modifiers match, toggles visibility of the popover modal.
143
- */
144
- handleHotkeyPressed(event) {
145
- if ((event.ctrlKey && this.hotkeyModifier === 'ctrl') ||
146
- (event.altKey && this.hotkeyModifier === 'alt') ||
147
- (event.metaKey && this.hotkeyModifier === 'meta')) {
148
- event.preventDefault();
149
- if (this.type === 'inline' && !this.isPopoverVisibleInState) {
150
- const hostElementInput = this.hostElement.querySelector('.searchcraft-input');
151
- hostElementInput?.focus();
152
- }
153
- else {
154
- useSearchcraftStore
155
- .getState()
156
- .setPopoverVisibility(!this.isPopoverVisibleInState);
157
- }
158
- }
159
- }
160
- handleCancelButtonClick() {
161
- useSearchcraftStore.getState().setPopoverVisibility(false);
162
- }
163
- /**
164
- * Moves focus to the next/previous list item in the list view. If you are at the top
165
- * of the list view, it moves focus back to the input.
166
- *
167
- * @param direction
168
- */
169
- focusOnNextListItem(direction) {
170
- const listItems = Array.from(document.querySelectorAll('a.searchcraft-popover-list-item')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
171
- const currentIndex = listItems.indexOf(document.activeElement);
172
- if (direction === 'ArrowDown') {
173
- listItems[(currentIndex + 1) % listItems.length]?.focus();
174
- }
175
- else if (direction === 'ArrowUp') {
176
- if (currentIndex >= 1) {
177
- listItems[currentIndex - 1]?.focus();
178
- }
179
- else {
180
- const input = document.querySelector('.searchcraft-input');
181
- if (input) {
182
- input.focus();
183
- requestAnimationFrame(() => {
184
- input.selectionEnd = input.value.length;
185
- input.selectionStart = input.value.length;
186
- });
187
- }
188
- }
189
- }
190
- }
191
- get hasResultsToShow() {
192
- return (this.searchTerm &&
193
- this.searchTerm?.trim()?.length > 0 &&
194
- this.searchClientResponseItems.length > 0);
195
- }
196
- renderInlinePopover() {
197
- const isListViewVisible = this.hasResultsToShow && this.isFocused;
198
- const popoverFormClassNames = classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
199
- 'searchcraft-popover-form-active': isListViewVisible,
200
- });
201
- return (h("div", { class: popoverFormClassNames }, h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this) }), isListViewVisible && (h("div", { class: 'searchcraft-popover-inline-wrapper-outer' }, h("div", { class: 'searchcraft-popover-inline-wrapper-inner' }, h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
202
- }
203
- renderModalPopover() {
204
- if (this.isPopoverVisibleInState) {
205
- const popoverFormClassNames = classNames('searchcraft-popover-form', {
206
- 'searchcraft-popover-form-active': this.hasResultsToShow,
207
- });
208
- return (h("div", { class: 'searchcraft-popover-form-modal' }, h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), h("div", { class: 'searchcraft-popover-form-modal-inner' }, h("div", { class: popoverFormClassNames }, h("div", { class: 'searchcraft-popover-form-input-wrapper' }, h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
209
- }
210
- }
211
- renderFullscreenPopover() {
212
- if (this.isPopoverVisibleInState) {
213
- return (h("div", { class: 'searchcraft-popover-form-fullscreen' }, h("div", { class: 'searchcraft-popover-form' }, h("div", { class: 'searchcraft-popover-form-input-wrapper' }, h("searchcraft-input-form", { config: this.config, onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage })))));
214
- }
215
- }
216
- render() {
217
- switch (this.type) {
218
- case 'inline':
219
- return this.renderInlinePopover();
220
- case 'modal':
221
- return this.renderModalPopover();
222
- case 'fullscreen':
223
- return this.renderFullscreenPopover();
224
- }
225
- }
226
- };
227
-
228
- export { SearchcraftPopoverForm as searchcraft_popover_form };
229
-
230
- //# sourceMappingURL=searchcraft-popover-form.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"searchcraft-popover-form.entry.js","mappings":";;;;MA6Ca,sBAAsB;;;;;;;IAIzB,MAAM,CAAgC;;;;;;;;IAQtC,IAAI,GAAsC,QAAQ,CAAC;;;;IAInD,qBAAqB,CAAoC;;;;IAIzD,MAAM,GAAG,GAAG,CAAC;;;;IAIb,cAAc,GAAuC,MAAM,CAAC;IAE3D,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,CAA2B;IACtC,yBAAyB,GAA+B,EAAE,CAAC;IAC3D,qBAAqB,GAA2B,EAAE,CAAC;IACnD,UAAU,CAAqB;IAC/B,SAAS,GAAG,KAAK,CAAC;IAClB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IAErB,YAAY,CAAC;;IAItB,gBAAgB;;QAEd,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjE,IAAI,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AAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,GAC/C,CACH,CACG,CACF,EACN;SACH;KACF;IAED,MAAM;QACJ,QAAQ,IAAI,CAAC,IAAI;YACf,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;SACzC;KACF;;;;;","names":[],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type {\n SearchcraftConfig,\n SearchClientResponseItem,\n AdClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field, or when a popover-button is pressed.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"fullscreen\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.config = {\n * index: [index_name_from_vektron],\n * readKey: 'read_key_from_vektron',\n * endpointUrl: 'enpoint_url_from_vektron',\n * };\n *\n * popoverForm.popoverResultMappings = {\n * containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * The type of popover form to render.\n *\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchClientResponseItems: SearchClientResponseItem[] = [];\n @State() adClientResponseItems: AdClientResponseItem[] = [];\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState =\n useSearchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchClientResponseItems = [...state.searchClientResponseItems];\n this.adClientResponseItems = [...state.adClientResponseItems];\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n useSearchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport &&\n window.visualViewport.width < this.breakpointSm\n ) {\n useSearchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.config = this.config;\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n useSearchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n useSearchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n 'a.searchcraft-popover-list-item',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm &&\n this.searchTerm?.trim()?.length > 0 &&\n this.searchClientResponseItems.length > 0\n );\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n const popoverFormClassNames = classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n );\n\n return (\n <div class={popoverFormClassNames}>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n {isListViewVisible && (\n <div class='searchcraft-popover-inline-wrapper-outer'>\n <div class='searchcraft-popover-inline-wrapper-inner'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n const popoverFormClassNames = classNames('searchcraft-popover-form', {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n });\n\n return (\n <div class='searchcraft-popover-form-modal'>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-inner'>\n <div class={popoverFormClassNames}>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div class='searchcraft-popover-form-fullscreen'>\n <div class='searchcraft-popover-form'>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n config={this.config}\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n );\n }\n }\n\n render() {\n switch (this.type) {\n case 'inline':\n return this.renderInlinePopover();\n case 'modal':\n return this.renderModalPopover();\n case 'fullscreen':\n return this.renderFullscreenPopover();\n }\n }\n}\n"],"version":3}
@@ -1,96 +0,0 @@
1
- import { r as registerInstance, h } from './index-3608c57d.js';
2
- import { u as useSearchcraftStore } from './SearchcraftStore-3cfd565a.js';
3
- import { a as getDocumentValueFromSearchResultMapping } from './units-daaf96f5.js';
4
-
5
- const SearchcraftPopoverListItem = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- }
9
- item;
10
- popoverResultMappings;
11
- /** The document position relative to the search results (For Measure) */
12
- documentPosition = 0;
13
- href;
14
- imageSrc;
15
- imageAlt;
16
- titleContent;
17
- subtitleContent;
18
- mapValuesFromDocument(document) {
19
- this.titleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.title);
20
- this.subtitleContent = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.subtitle);
21
- this.href = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.href);
22
- this.imageSrc = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageSource);
23
- this.imageAlt = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageAlt);
24
- }
25
- connectedCallback() {
26
- if (this.item) {
27
- this.mapValuesFromDocument(this.item.document);
28
- }
29
- }
30
- disconnectedCallback() { }
31
- handleLinkClick = () => {
32
- const state = useSearchcraftStore.getState();
33
- const searchcraft = state.getSearchcraftInstance();
34
- if (searchcraft) {
35
- const document_position = this.documentPosition;
36
- const search_term = state.searchTerm;
37
- const number_of_documents = state.searchClientResponseItems.length || 0;
38
- searchcraft.measureClient?.sendMeasureEvent('document_clicked', {
39
- document_position,
40
- number_of_documents,
41
- search_term,
42
- });
43
- }
44
- };
45
- render() {
46
- return (h("a", { key: '77e0a59f0441c7ed717ffc0de7f335e76b7b5f5e', class: 'searchcraft-popover-list-item', href: this.href, onClick: this.handleLinkClick.bind(this) }, this.imageSrc && (h("div", { key: '70fe7167cd9baa5029b1482ac6e71bd46c3171a7', class: 'searchcraft-popover-list-item-image-wrapper' }, h("img", { key: '768f651b06005ecefb9818268664334c6bf0d333', alt: this.imageAlt, src: this.imageSrc, class: 'searchcraft-popover-list-item-image' }))), h("div", { key: 'a34b31b92d232193e9d43c5871ecad0d4ee3f59a', class: 'searchcraft-popover-list-item-info-wrapper' }, h("p", { key: 'f2bd9dab4008d200b4528fde35950be90503d66c', class: 'searchcraft-popover-list-item-title' }, this.titleContent), h("p", { key: '4231966d7c4c48dfaaf4925ad18db3428219edad', class: 'searchcraft-popover-list-item-subtitle' }, this.subtitleContent))));
47
- }
48
- };
49
-
50
- const SearchcraftPopoverListItemAd = class {
51
- constructor(hostRef) {
52
- registerInstance(this, hostRef);
53
- }
54
- adClientResponseItem;
55
- connectedCallback() {
56
- if (this.adClientResponseItem?.admAd?.impression_url) {
57
- fetch(this.adClientResponseItem?.admAd?.impression_url);
58
- }
59
- }
60
- renderADMProductAd() {
61
- const ad = this.adClientResponseItem?.admAd;
62
- if (!ad) {
63
- return;
64
- }
65
- return (h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term), h("p", { class: 'searchcraft-popover-list-item-ad-subtitle' }, ad.price))));
66
- }
67
- renderADMTextAd() {
68
- const ad = this.adClientResponseItem?.admAd;
69
- if (!ad) {
70
- return;
71
- }
72
- return (h("a", { class: 'searchcraft-popover-list-item-ad', href: ad.click_url }, ad.image_url && (h("div", { class: 'searchcraft-popover-list-item-ad-image-wrapper' }, h("img", { alt: ad.term, src: ad.image_url, class: 'searchcraft-popover-list-item-ad-image' }))), h("div", { class: 'searchcraft-popover-list-item-ad-info-wrapper' }, h("p", { class: 'searchcraft-popover-list-item-ad-title' }, ad.term))));
73
- }
74
- renderNativoAd() { }
75
- renderAdPlaceholder() {
76
- return h("p", null, "Ad placeholder");
77
- // return;
78
- }
79
- render() {
80
- if (!this.adClientResponseItem) {
81
- return this.renderAdPlaceholder();
82
- }
83
- switch (this.adClientResponseItem.type) {
84
- case 'adm-product-ad':
85
- return this.renderADMProductAd();
86
- case 'adm-text-ad':
87
- return this.renderADMTextAd();
88
- case 'nativo-ad':
89
- return this.renderNativoAd();
90
- }
91
- }
92
- };
93
-
94
- export { SearchcraftPopoverListItem as searchcraft_popover_list_item, SearchcraftPopoverListItemAd as searchcraft_popover_list_item_ad };
95
-
96
- //# sourceMappingURL=searchcraft-popover-list-item_2.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"searchcraft-popover-list-item.searchcraft-popover-list-item-ad.entry.js","mappings":";;;;MAgBa,0BAA0B;;;;IAC7B,IAAI,CAAuC;IAC3C,qBAAqB,CAAoC;;IAEzD,gBAAgB,GAAG,CAAC,CAAC;IAEpB,IAAI,CAAU;IACd,QAAQ,CAAU;IAClB,QAAQ,CAAU;IAClB,YAAY,CAAU;IACtB,eAAe,CAAU;IAElC,qBAAqB,CAAC,QAAwB;QAC5C,IAAI,CAAC,YAAY,GAAG,uCAAuC,CACzD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAClC,CAAC;QACF,IAAI,CAAC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IAAI,EAAE,EAAE,CAAC,SAAS,IAC3D,EAAE,CAAC,SAAS,KACX,WAAK,KAAK,EAAC,gDAAgD,IACzD,WACE,GAAG,EAAE,EAAE,CAAC,IAAI,EACZ,GAAG,EAAE,EAAE,CAAC,SAAS,EACjB,KAAK,EAAC,wCAAwC,GAC9C,CACE,CACP,EACD,WAAK,KAAK,EAAC,+CAA+C,IACxD,SAAG,KAAK,EAAC,wCAAwC,IAAE,EAAE,CAAC,IAAI,CAAK,CAC3D,CACJ,EACJ;KACH;IAED,cAAc,MAAK;IAEnB,mBAAmB;QACjB,OAAO,8BAAqB,CAAC;;KAE9B;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;SACnC;QAED,QAAQ,IAAI,CAAC,oBAAoB,CAAC,IAAI;YACpC,KAAK,gBAAgB;gBACnB,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;YAChC,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC;SAChC;KACF;;;;;","names":[],"sources":["src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx","src/components/searchcraft-popover-list-item-ad/searchcraft-popover-list-item-ad.tsx"],"sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport type {\n SearchDocument,\n SearchClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\nimport { Component, h, Prop, State } from '@stencil/core';\nimport { getDocumentValueFromSearchResultMapping } from '@utils';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n */\n@Component({\n tag: 'searchcraft-popover-list-item',\n shadow: false,\n})\nexport class SearchcraftPopoverListItem {\n @Prop() item: SearchClientResponseItem | undefined;\n @Prop() popoverResultMappings: PopoverResultMappings | undefined;\n /** The document position relative to the search results (For Measure) */\n @Prop() documentPosition = 0;\n\n @State() href?: string;\n @State() imageSrc?: string;\n @State() imageAlt?: string;\n @State() titleContent?: string;\n @State() subtitleContent?: string;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSrc = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n this.imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n }\n\n connectedCallback() {\n if (this.item) {\n this.mapValuesFromDocument(this.item.document);\n }\n }\n\n disconnectedCallback() {}\n\n handleLinkClick = () => {\n const state = useSearchcraftStore.getState();\n const searchcraft = state.getSearchcraftInstance();\n\n if (searchcraft) {\n const document_position = this.documentPosition;\n const search_term = state.searchTerm;\n const number_of_documents = state.searchClientResponseItems.length || 0;\n\n searchcraft.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n render() {\n return (\n <a\n class='searchcraft-popover-list-item'\n href={this.href}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSrc && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSrc}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-info-wrapper'>\n <p class='searchcraft-popover-list-item-title'>{this.titleContent}</p>\n <p class='searchcraft-popover-list-item-subtitle'>\n {this.subtitleContent}\n </p>\n </div>\n </a>\n );\n }\n}\n","import type {\n AdClientResponseItem,\n ADMProductAd,\n ADMTextAd,\n} from '@searchcraft/core';\nimport { Component, h, Prop } from '@stencil/core';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n */\n@Component({\n tag: 'searchcraft-popover-list-item-ad',\n shadow: false,\n})\nexport class SearchcraftPopoverListItemAd {\n @Prop() adClientResponseItem?: AdClientResponseItem;\n\n connectedCallback() {\n if (this.adClientResponseItem?.admAd?.impression_url) {\n fetch(this.adClientResponseItem?.admAd?.impression_url);\n }\n }\n\n renderADMProductAd() {\n const ad = this.adClientResponseItem?.admAd as ADMProductAd;\n if (!ad) {\n return;\n }\n\n return (\n <a class='searchcraft-popover-list-item-ad' href={ad.click_url}>\n {ad.image_url && (\n <div class='searchcraft-popover-list-item-ad-image-wrapper'>\n <img\n alt={ad.term}\n src={ad.image_url}\n class='searchcraft-popover-list-item-ad-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-ad-info-wrapper'>\n <p class='searchcraft-popover-list-item-ad-title'>{ad.term}</p>\n <p class='searchcraft-popover-list-item-ad-subtitle'>{ad.price}</p>\n </div>\n </a>\n );\n }\n\n renderADMTextAd() {\n const ad = this.adClientResponseItem?.admAd as ADMTextAd;\n if (!ad) {\n return;\n }\n\n return (\n <a class='searchcraft-popover-list-item-ad' href={ad.click_url}>\n {ad.image_url && (\n <div class='searchcraft-popover-list-item-ad-image-wrapper'>\n <img\n alt={ad.term}\n src={ad.image_url}\n class='searchcraft-popover-list-item-ad-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-ad-info-wrapper'>\n <p class='searchcraft-popover-list-item-ad-title'>{ad.term}</p>\n </div>\n </a>\n );\n }\n\n renderNativoAd() {}\n\n renderAdPlaceholder() {\n return <p>Ad placeholder</p>;\n // return;\n }\n\n render() {\n if (!this.adClientResponseItem) {\n return this.renderAdPlaceholder();\n }\n\n switch (this.adClientResponseItem.type) {\n case 'adm-product-ad':\n return this.renderADMProductAd();\n case 'adm-text-ad':\n return this.renderADMTextAd();\n case 'nativo-ad':\n return this.renderNativoAd();\n }\n }\n}\n"],"version":3}
@@ -1,76 +0,0 @@
1
- import { r as registerInstance, h } from './index-3608c57d.js';
2
- import { c as classNames } from './index-72ac5051.js';
3
- import { u as useSearchcraftStore } from './SearchcraftStore-3cfd565a.js';
4
- import { f as formatNumberWithCommas } from './units-daaf96f5.js';
5
- import { p as parseCustomStyles } from './styles-961644ef.js';
6
-
7
- const SearchcraftResultsInfo = class {
8
- constructor(hostRef) {
9
- registerInstance(this, hostRef);
10
- }
11
- /**
12
- * The custom formatter for the resulting string.
13
- *
14
- * @example
15
- * ```ts
16
- * resultsInfo.customFormatter = (range, count, responseTime) =>
17
- * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
18
- * ```
19
- */
20
- customFormatter;
21
- /**
22
- * The custom styles object.
23
- */
24
- customStyles;
25
- // store vars
26
- searchTerm;
27
- searchResultsPage;
28
- searchResultsPerPage;
29
- searchResultsCount;
30
- // local vars
31
- count = 0;
32
- range = [0, 0];
33
- responseTime = '0';
34
- unsubscribe = () => { };
35
- connectedCallback() {
36
- this.unsubscribe = useSearchcraftStore.subscribe((state) => {
37
- // store vars
38
- this.searchTerm = state.searchTerm;
39
- this.searchResultsPage = state.searchResultsPage;
40
- this.searchResultsPerPage = state.searchResultsPerPage;
41
- this.searchResultsCount = state.searchResultsCount;
42
- // local vars
43
- this.count = this.searchResultsCount;
44
- this.range[0] =
45
- this.searchResultsPage <= 1
46
- ? 1
47
- : this.searchResultsPerPage * (this.searchResultsPage - 1);
48
- this.range[1] = this.searchResultsPerPage * this.searchResultsPage;
49
- this.range[1] =
50
- this.range[1] > this.searchResultsCount
51
- ? this.searchResultsCount
52
- : this.range[1];
53
- this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(2);
54
- });
55
- }
56
- disconnectedCallback() {
57
- if (this.unsubscribe) {
58
- this.unsubscribe();
59
- }
60
- }
61
- render() {
62
- if (!this.searchTerm || this.searchResultsCount === 0) {
63
- return null;
64
- }
65
- return (h("p", { class: classNames('searchcraft-results-info', parseCustomStyles(this.customStyles || {})) }, this.customFormatter
66
- ? this.customFormatter([
67
- formatNumberWithCommas(this.range[0]),
68
- formatNumberWithCommas(this.range[1]),
69
- ], formatNumberWithCommas(this.count), this.responseTime)
70
- : `${this.count} results found in ${this.responseTime}ms`));
71
- }
72
- };
73
-
74
- export { SearchcraftResultsInfo as searchcraft_results_info };
75
-
76
- //# sourceMappingURL=searchcraft-results-info.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"searchcraft-results-info.entry.js","mappings":";;;;;;MA0Ba,sBAAsB;;;;;;;;;;;;;IAUzB,eAAe,CAIb;;;;IAIF,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;;IAGnB,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB,YAAY,GAAG,GAAG,CAAC;IAE5B,WAAW,GAAe,SAAQ,CAAC;IAEnC,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;;YAErD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YACnC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;YACjD,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,oBAAoB,CAAC;YACvD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;;YAGnD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,iBAAiB,IAAI,CAAC;sBACvB,CAAC;sBACD,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC;YAC/D,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gBACX,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,kBAAkB;sBACnC,IAAI,CAAC,kBAAkB;sBACvB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,IAAI,IAAI,EAAE,OAAO,CACvE,CAAC,CACF,CAAC;SACH,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,UAAU,IAAI,IAAI,CAAC,kBAAkB,KAAK,CAAC,EAAE;YACrD,OAAO,IAAI,CAAC;SACb;QAED,QACE,SACE,KAAK,EAAE,UAAU,CACf,0BAA0B,EAC1B,iBAAiB,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAC3C,IAEA,IAAI,CAAC,eAAe;cACjB,IAAI,CAAC,eAAe,CAClB;gBACE,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtC,EACD,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAClC,IAAI,CAAC,YAAY,CAClB;cACD,GAAG,IAAI,CAAC,KAAK,qBAAqB,IAAI,CAAC,YAAY,IAAI,CACzD,EACJ;KACH;;;;;","names":[],"sources":["src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"sourcesContent":["import { Component, h, State, Prop } from '@stencil/core';\nimport classNames from 'classnames';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport { formatNumberWithCommas, parseCustomStyles } from '@utils';\n\n/**\n * This web component is designed to display the number of results returned from a search query.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <script>\n * const resultsInfo = document.querySelector('searchcraft-results-info');\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * </script>\n *\n * <searchcraft-results-info />\n * ```\n */\n@Component({\n tag: 'searchcraft-results-info',\n shadow: false,\n})\nexport class SearchcraftResultsInfo {\n /**\n * The custom formatter for the resulting string.\n *\n * @example\n * ```ts\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * ```\n */\n @Prop() customFormatter?: (\n range: [string, string],\n count: string,\n responseTime: string,\n ) => void;\n /**\n * The custom styles object.\n */\n @Prop() customStyles?: string;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n @State() searchResultsCount;\n\n // local vars\n @State() count = 0;\n @State() range: number[] = [0, 0];\n @State() responseTime = '0';\n\n unsubscribe: () => void = () => {};\n\n connectedCallback() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.count = this.searchResultsCount;\n this.range[0] =\n this.searchResultsPage <= 1\n ? 1\n : this.searchResultsPerPage * (this.searchResultsPage - 1);\n this.range[1] = this.searchResultsPerPage * this.searchResultsPage;\n this.range[1] =\n this.range[1] > this.searchResultsCount\n ? this.searchResultsCount\n : this.range[1];\n this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(\n 2,\n );\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n render() {\n if (!this.searchTerm || this.searchResultsCount === 0) {\n return null;\n }\n\n return (\n <p\n class={classNames(\n 'searchcraft-results-info',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n {this.customFormatter\n ? this.customFormatter(\n [\n formatNumberWithCommas(this.range[0]),\n formatNumberWithCommas(this.range[1]),\n ],\n formatNumberWithCommas(this.count),\n this.responseTime,\n )\n : `${this.count} results found in ${this.responseTime}ms`}\n </p>\n );\n }\n}\n"],"version":3}
@@ -1,71 +0,0 @@
1
- import { r as registerInstance, h } from './index-3608c57d.js';
2
- import { u as useSearchcraftStore } from './SearchcraftStore-3cfd565a.js';
3
- import { c as classNames } from './index-72ac5051.js';
4
- import { p as parseCustomStyles } from './styles-961644ef.js';
5
-
6
- const SearchcraftSearchResultsPerPage = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- }
10
- /**
11
- * The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).
12
- * The base value is defined by the `searchResultsPerPage` option in the configuration.
13
- */
14
- increment = 20;
15
- /**
16
- * The custom styles object.
17
- */
18
- customStyles;
19
- // store vars
20
- searchTerm;
21
- searchResultsPage;
22
- searchResultsPerPage;
23
- searchResultsCount;
24
- searchResultsPagesCount;
25
- // local vars
26
- initialSearchResultsPerPage;
27
- // store functions
28
- setSearchResultsPerPage = () => { };
29
- setSearchResultsPage = () => { };
30
- unsubscribe = () => { };
31
- componentDidLoad() {
32
- this.unsubscribe = useSearchcraftStore.subscribe((state) => {
33
- // store vars
34
- this.searchTerm = state.searchTerm;
35
- this.searchResultsPerPage = state.searchResultsPerPage;
36
- this.searchResultsPage = state.searchResultsPage;
37
- this.searchResultsCount = state.searchResultsCount;
38
- // local vars
39
- this.searchResultsPagesCount = Math.ceil(this.searchResultsCount / this.searchResultsPerPage);
40
- // store functions
41
- this.setSearchResultsPage = state.setSearchResultsPage;
42
- this.setSearchResultsPerPage = state.setSearchResultsPerPage;
43
- });
44
- this.initialSearchResultsPerPage =
45
- useSearchcraftStore.getState().searchResultsPerPage;
46
- }
47
- disconnectedCallback() {
48
- this.unsubscribe?.();
49
- }
50
- render() {
51
- // early return if there isn't a searchTerm or there is 1 or fewer pages of results
52
- if (!this.searchTerm || this.searchResultsPagesCount <= 1) {
53
- return;
54
- }
55
- return (h("div", { class: classNames('searchcraft-search-results-per-page', parseCustomStyles(this.customStyles || {})) }, h("div", { class: 'searchcraft-search-results-per-page-select' }, h("label", { class: 'searchcraft-search-results-per-page-select-label', htmlFor: 'searchcraft-search-results-per-page-select-input' }, "Results Per Page"), h("div", { class: 'searchcraft-search-results-per-page-select-input' }, h("searchcraft-select", { inputId: 'searchcraft-search-results-per-page-select-input', name: 'results-per-page', options: [...Array(5)].map((_, index) => {
56
- const value = this.initialSearchResultsPerPage +
57
- Number(this.increment) * index;
58
- return {
59
- label: `${value}`,
60
- value,
61
- };
62
- }), onSelectChange: (event) => {
63
- this.setSearchResultsPerPage(Number(event.detail));
64
- this.setSearchResultsPage(1);
65
- } })))));
66
- }
67
- };
68
-
69
- export { SearchcraftSearchResultsPerPage as searchcraft_search_results_per_page };
70
-
71
- //# sourceMappingURL=searchcraft-search-results-per-page.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"searchcraft-search-results-per-page.entry.js","mappings":";;;;;MAmBa,+BAA+B;;;;;;;;IAKlC,SAAS,GAAoB,EAAE,CAAC;;;;IAIhC,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;IACnB,uBAAuB,CAAC;;IAGxB,2BAA2B,CAAC;;IAG5B,uBAAuB,GAA8B,SAAQ,CAAC;IAC9D,oBAAoB,GAA2B,SAAQ,CAAC;IAEzD,WAAW,GAAe,SAAQ,CAAC;IAE3C,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;;YAErD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YACnC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,oBAAoB,CAAC;YACvD,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;YACjD,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC;;YAGnD,IAAI,CAAC,uBAAuB,GAAG,I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C9B,GACD,CACE,CACF,CACF,EACN;KACH;;;;;","names":[],"sources":["src/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.tsx"],"sourcesContent":["import { useSearchcraftStore } from '@provider/store';\nimport { Component, h, State, Prop } from '@stencil/core';\nimport classNames from 'classnames';\n\nimport { parseCustomStyles } from '@utils';\n\n/**\n * This web component is designed to choose the number of search results displayed.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-search-results-per-page increment=\"20\" />\n * ```\n */\n@Component({\n tag: 'searchcraft-search-results-per-page',\n shadow: false,\n})\nexport class SearchcraftSearchResultsPerPage {\n /**\n * The amount the options will increase (e.g. 20 = [20, 40, 60, 80, 100]).\n * The base value is defined by the `searchResultsPerPage` option in the configuration.\n */\n @Prop() increment: string | number = 20;\n /**\n * The custom styles object.\n */\n @Prop() customStyles?: string;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n @State() searchResultsCount;\n @State() searchResultsPagesCount;\n\n // local vars\n @State() initialSearchResultsPerPage;\n\n // store functions\n @State() setSearchResultsPerPage: (perPage: number) => void = () => {};\n @State() setSearchResultsPage: (page: number) => void = () => {};\n\n private unsubscribe: () => void = () => {};\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.searchResultsPagesCount = Math.ceil(\n this.searchResultsCount / this.searchResultsPerPage,\n );\n\n // store functions\n this.setSearchResultsPage = state.setSearchResultsPage;\n this.setSearchResultsPerPage = state.setSearchResultsPerPage;\n });\n\n this.initialSearchResultsPerPage =\n useSearchcraftStore.getState().searchResultsPerPage;\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n render() {\n // early return if there isn't a searchTerm or there is 1 or fewer pages of results\n if (!this.searchTerm || this.searchResultsPagesCount <= 1) {\n return;\n }\n\n return (\n <div\n class={classNames(\n 'searchcraft-search-results-per-page',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n <div class='searchcraft-search-results-per-page-select'>\n <label\n class='searchcraft-search-results-per-page-select-label'\n htmlFor='searchcraft-search-results-per-page-select-input'\n >\n Results Per Page\n </label>\n <div class='searchcraft-search-results-per-page-select-input'>\n <searchcraft-select\n inputId='searchcraft-search-results-per-page-select-input'\n name='results-per-page'\n options={[...Array(5)].map((_, index) => {\n const value =\n this.initialSearchResultsPerPage +\n Number(this.increment) * index;\n return {\n label: `${value}`,\n value,\n };\n })}\n onSelectChange={(event) => {\n this.setSearchResultsPerPage(Number(event.detail));\n this.setSearchResultsPage(1);\n }}\n />\n </div>\n </div>\n </div>\n );\n }\n}\n"],"version":3}
@@ -1,66 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-3608c57d.js';
2
- import { c as classNames } from './index-72ac5051.js';
3
- import { p as parseCustomStyles } from './styles-961644ef.js';
4
-
5
- const SearchcraftSelect = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.selectChange = createEvent(this, "selectChange", 7);
9
- }
10
- /**
11
- * The caption displayed below the select input.
12
- */
13
- caption;
14
- /**
15
- * Whether the select input is disabled.
16
- */
17
- disabled = false;
18
- /**
19
- * The ID for the select input.
20
- */
21
- inputId;
22
- /**
23
- * The label of the select input.
24
- */
25
- label;
26
- /**
27
- * The ID for the label of the select input.
28
- */
29
- labelId;
30
- /**
31
- * The name of the select input.
32
- */
33
- name;
34
- /**
35
- * The options for the select input.
36
- */
37
- options = [];
38
- /**
39
- * A custom styles object.
40
- */
41
- customStyles;
42
- /**
43
- * The event fired when the select is changed.
44
- */
45
- selectChange;
46
- searchResultsPerPage;
47
- setSearchResultsPage = () => { };
48
- setSearchResultsPerPage = () => { };
49
- handleSelectChange = (event) => {
50
- this.selectChange.emit(event.target.value);
51
- };
52
- handleGoToPage(page) {
53
- this.setSearchResultsPage(page);
54
- }
55
- render() {
56
- return (h("div", { key: '5024d49d89a3649a5de591d37ded304a9dfb36d9', class: classNames('searchcraft-select', parseCustomStyles(this.customStyles || {})) }, this.label && (h("label", { key: '005aea9b190e5a6c041721e20395be23f76faab6', class: 'searchcraft-select-label', id: this.labelId || `${this.inputId}-label`, htmlFor: this.inputId }, this.label)), h("div", { key: '209d56844c0bcd241e73bafcad24fac927fe7ffa', class: 'searchcraft-select-input-wrapper' }, h("select", { key: '010c9e596ef45a303f84c0ac0fa54ab67556d7b6', "aria-labelledby": this.label ? this.labelId || `${this.inputId}-label` : undefined, class: 'searchcraft-select-input', disabled: this.disabled, id: this.inputId, name: this.name, onChange: this.handleSelectChange }, (typeof this.options === 'string'
57
- ? JSON.parse(this.options)
58
- : this.options).map(({ label, value, selected }) => {
59
- return (h("option", { key: value, value: value, selected: selected }, label));
60
- })), h("svg", { key: '51d9fb79381468ee0992475ba376df5a5961116c', class: 'searchcraft-select-input-icon', width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, h("title", { key: '59186138953557764915d41708d4bcc23a9bb97f' }, "Select dropdown icon"), h("path", { key: 'ec2c962df16cb68bdaf3e2c32e57d875a63957a9', d: 'M5 7.5L10 12.5L15 7.5', stroke: 'currentColor', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), this.caption && (h("p", { key: '742bc2dbd8371938894d49bb37d429d1b7a07d7a', class: 'searchcraft-select-caption' }, this.caption))));
61
- }
62
- };
63
-
64
- export { SearchcraftSelect as searchcraft_select };
65
-
66
- //# sourceMappingURL=searchcraft-select.entry.js.map