@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.
Files changed (271) hide show
  1. package/README.md +59 -55
  2. package/dist/cjs/{index-b3b77ea2.js → index-a81df4f0.js} +258 -239
  3. package/dist/cjs/index-a81df4f0.js.map +1 -0
  4. package/dist/cjs/index.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/searchcraft-base-search-result.cjs.entry.js +91 -48
  7. package/dist/cjs/searchcraft-base-search-result.cjs.entry.js.map +1 -1
  8. package/dist/cjs/searchcraft-base-search-results.cjs.entry.js +74 -37
  9. package/dist/cjs/searchcraft-base-search-results.cjs.entry.js.map +1 -1
  10. package/dist/cjs/searchcraft-button_3.cjs.entry.js +37 -27
  11. package/dist/cjs/searchcraft-button_3.cjs.entry.js.map +1 -1
  12. package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js +141 -117
  13. package/dist/cjs/searchcraft-facet-list_3.cjs.entry.js.map +1 -1
  14. package/dist/cjs/searchcraft-filter-panel.cjs.entry.js +11 -13
  15. package/dist/cjs/searchcraft-filter-panel.cjs.entry.js.map +1 -1
  16. package/dist/cjs/searchcraft-input-form_2.cjs.entry.js +128 -82
  17. package/dist/cjs/searchcraft-input-form_2.cjs.entry.js.map +1 -1
  18. package/dist/cjs/searchcraft-javascript-sdk.cjs.js +3 -3
  19. package/dist/cjs/searchcraft-javascript-sdk.cjs.js.map +1 -1
  20. package/dist/cjs/searchcraft-popover-button.cjs.entry.js +3 -7
  21. package/dist/cjs/searchcraft-popover-button.cjs.entry.js.map +1 -1
  22. package/dist/cjs/searchcraft-popover-form.cjs.entry.js +81 -68
  23. package/dist/cjs/searchcraft-popover-form.cjs.entry.js.map +1 -1
  24. package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js +29 -12
  25. package/dist/cjs/searchcraft-popover-list-item.cjs.entry.js.map +1 -1
  26. package/dist/cjs/searchcraft-results-info.cjs.entry.js +9 -13
  27. package/dist/cjs/searchcraft-results-info.cjs.entry.js.map +1 -1
  28. package/dist/cjs/searchcraft-theme.cjs.entry.js +38 -0
  29. package/dist/cjs/searchcraft-theme.cjs.entry.js.map +1 -0
  30. package/dist/cjs/{store-d7ebcf7a.js → store-f6ba3dfb.js} +633 -107
  31. package/dist/cjs/store-f6ba3dfb.js.map +1 -0
  32. package/dist/collection/collection-manifest.json +2 -1
  33. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +134 -66
  34. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
  35. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +100 -49
  36. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
  37. package/dist/collection/components/searchcraft-button/searchcraft-button.js +35 -23
  38. package/dist/collection/components/searchcraft-button/searchcraft-button.js.map +1 -1
  39. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +8 -15
  40. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js.map +1 -1
  41. package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js +61 -59
  42. package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.js.map +1 -1
  43. package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js +11 -19
  44. package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.js.map +1 -1
  45. package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js +126 -76
  46. package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.js.map +1 -1
  47. package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js +14 -18
  48. package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.js.map +1 -1
  49. package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js +1 -11
  50. package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.js.map +1 -1
  51. package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js +93 -77
  52. package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.js.map +1 -1
  53. package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js +47 -25
  54. package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.js.map +1 -1
  55. package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js +23 -25
  56. package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.js.map +1 -1
  57. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +7 -19
  58. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -1
  59. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +65 -55
  60. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -1
  61. package/dist/collection/components/searchcraft-theme/searchcraft-theme.js +27 -0
  62. package/dist/collection/components/searchcraft-theme/searchcraft-theme.js.map +1 -0
  63. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +27 -26
  64. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
  65. package/dist/collection/index.js.map +1 -1
  66. package/dist/collection/provider/store.js +25 -9
  67. package/dist/collection/provider/store.js.map +1 -1
  68. package/dist/collection/utils/facets.js +5 -3
  69. package/dist/collection/utils/facets.js.map +1 -1
  70. package/dist/components/index.js +4 -2
  71. package/dist/components/index.js.map +1 -1
  72. package/dist/components/p-0ef4ab33.js +66 -0
  73. package/dist/components/p-0ef4ab33.js.map +1 -0
  74. package/dist/components/p-1234974c.js +72 -0
  75. package/dist/components/p-1234974c.js.map +1 -0
  76. package/dist/components/p-4b92ae26.js +109 -0
  77. package/dist/components/p-4b92ae26.js.map +1 -0
  78. package/dist/components/{p-85765b81.js → p-506cdac1.js} +18 -16
  79. package/dist/components/p-506cdac1.js.map +1 -0
  80. package/dist/components/p-521fe971.js +60 -0
  81. package/dist/components/p-521fe971.js.map +1 -0
  82. package/dist/components/{p-e4846fa2.js → p-5365011f.js} +215 -231
  83. package/dist/components/p-5365011f.js.map +1 -0
  84. package/dist/components/p-54998882.js +285 -0
  85. package/dist/components/p-54998882.js.map +1 -0
  86. package/dist/components/{p-d6a88eed.js → p-936e2ed4.js} +633 -107
  87. package/dist/components/p-936e2ed4.js.map +1 -0
  88. package/dist/components/p-a75ef832.js +34 -0
  89. package/dist/components/p-a75ef832.js.map +1 -0
  90. package/dist/components/p-b4a8fcbe.js +144 -0
  91. package/dist/components/p-b4a8fcbe.js.map +1 -0
  92. package/dist/components/p-ca881e5c.js +37 -0
  93. package/dist/components/p-ca881e5c.js.map +1 -0
  94. package/dist/components/p-d95bc2a0.js +284 -0
  95. package/dist/components/p-d95bc2a0.js.map +1 -0
  96. package/dist/components/searchcraft-base-search-result.js +1 -1
  97. package/dist/components/searchcraft-base-search-results.js +76 -39
  98. package/dist/components/searchcraft-base-search-results.js.map +1 -1
  99. package/dist/components/searchcraft-button.js +1 -1
  100. package/dist/components/searchcraft-error-message.js +1 -1
  101. package/dist/components/searchcraft-facet-list.js +1 -1
  102. package/dist/components/searchcraft-filter-panel.js +14 -16
  103. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  104. package/dist/components/searchcraft-input-form.js +1 -1
  105. package/dist/components/searchcraft-input-label.js +1 -1
  106. package/dist/components/searchcraft-popover-button.js +3 -7
  107. package/dist/components/searchcraft-popover-button.js.map +1 -1
  108. package/dist/components/searchcraft-popover-form.js +87 -74
  109. package/dist/components/searchcraft-popover-form.js.map +1 -1
  110. package/dist/components/searchcraft-popover-list-item.js +1 -1
  111. package/dist/components/searchcraft-popover-list-view.js +1 -1
  112. package/dist/components/searchcraft-results-info.js +9 -13
  113. package/dist/components/searchcraft-results-info.js.map +1 -1
  114. package/dist/components/searchcraft-slider.js +1 -1
  115. package/dist/components/searchcraft-theme.d.ts +11 -0
  116. package/dist/components/searchcraft-theme.js +51 -0
  117. package/dist/components/searchcraft-theme.js.map +1 -0
  118. package/dist/components/searchcraft-toggle-button.js +1 -1
  119. package/dist/esm/{index-11551663.js → index-3608c57d.js} +258 -239
  120. package/dist/esm/index-3608c57d.js.map +1 -0
  121. package/dist/esm/index.js +1 -1
  122. package/dist/esm/loader.js +3 -3
  123. package/dist/esm/searchcraft-base-search-result.entry.js +91 -48
  124. package/dist/esm/searchcraft-base-search-result.entry.js.map +1 -1
  125. package/dist/esm/searchcraft-base-search-results.entry.js +74 -37
  126. package/dist/esm/searchcraft-base-search-results.entry.js.map +1 -1
  127. package/dist/esm/searchcraft-button_3.entry.js +37 -27
  128. package/dist/esm/searchcraft-button_3.entry.js.map +1 -1
  129. package/dist/esm/searchcraft-facet-list_3.entry.js +141 -117
  130. package/dist/esm/searchcraft-facet-list_3.entry.js.map +1 -1
  131. package/dist/esm/searchcraft-filter-panel.entry.js +11 -13
  132. package/dist/esm/searchcraft-filter-panel.entry.js.map +1 -1
  133. package/dist/esm/searchcraft-input-form_2.entry.js +128 -82
  134. package/dist/esm/searchcraft-input-form_2.entry.js.map +1 -1
  135. package/dist/esm/searchcraft-javascript-sdk.js +4 -4
  136. package/dist/esm/searchcraft-javascript-sdk.js.map +1 -1
  137. package/dist/esm/searchcraft-popover-button.entry.js +3 -7
  138. package/dist/esm/searchcraft-popover-button.entry.js.map +1 -1
  139. package/dist/esm/searchcraft-popover-form.entry.js +81 -68
  140. package/dist/esm/searchcraft-popover-form.entry.js.map +1 -1
  141. package/dist/esm/searchcraft-popover-list-item.entry.js +29 -12
  142. package/dist/esm/searchcraft-popover-list-item.entry.js.map +1 -1
  143. package/dist/esm/searchcraft-results-info.entry.js +9 -13
  144. package/dist/esm/searchcraft-results-info.entry.js.map +1 -1
  145. package/dist/esm/searchcraft-theme.entry.js +34 -0
  146. package/dist/esm/searchcraft-theme.entry.js.map +1 -0
  147. package/dist/esm/{store-1058f7b0.js → store-aa071d9c.js} +633 -107
  148. package/dist/esm/store-aa071d9c.js.map +1 -0
  149. package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
  150. package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js +2 -0
  151. package/dist/searchcraft-javascript-sdk/p-26f5263d.entry.js.map +1 -0
  152. package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js +2 -0
  153. package/dist/searchcraft-javascript-sdk/p-2ff7eb35.entry.js.map +1 -0
  154. package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js +2 -0
  155. package/dist/searchcraft-javascript-sdk/p-36f0532e.entry.js.map +1 -0
  156. package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js +2 -0
  157. package/dist/searchcraft-javascript-sdk/p-41b6bc5d.entry.js.map +1 -0
  158. package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js +2 -0
  159. package/dist/searchcraft-javascript-sdk/p-57eddb07.entry.js.map +1 -0
  160. package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js +2 -0
  161. package/dist/searchcraft-javascript-sdk/p-5d6fbee0.entry.js.map +1 -0
  162. package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js +2 -0
  163. package/dist/searchcraft-javascript-sdk/p-64c5a1d2.entry.js.map +1 -0
  164. package/dist/searchcraft-javascript-sdk/p-7e13c128.js +3 -0
  165. package/dist/searchcraft-javascript-sdk/p-7e13c128.js.map +1 -0
  166. package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js +2 -0
  167. package/dist/searchcraft-javascript-sdk/p-8b0a60b3.entry.js.map +1 -0
  168. package/dist/searchcraft-javascript-sdk/p-936e2ed4.js +11 -0
  169. package/dist/searchcraft-javascript-sdk/p-936e2ed4.js.map +1 -0
  170. package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js +2 -0
  171. package/dist/searchcraft-javascript-sdk/p-c7df8be6.entry.js.map +1 -0
  172. package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js +2 -0
  173. package/dist/searchcraft-javascript-sdk/p-eb6058e8.entry.js.map +1 -0
  174. package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js +2 -0
  175. package/dist/searchcraft-javascript-sdk/p-faaa4394.entry.js.map +1 -0
  176. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
  177. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
  178. package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +1 -0
  179. package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +2 -1
  180. package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +1 -0
  181. package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +1 -0
  182. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +2 -1
  183. package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +1 -0
  184. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +7 -10
  185. package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +2 -1
  186. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +1 -0
  187. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +2 -1
  188. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +2 -0
  189. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +1 -0
  190. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +1 -0
  191. package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +2 -1
  192. package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +5 -0
  193. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +2 -1
  194. package/dist/types/components.d.ts +17 -4
  195. package/dist/types/index.d.ts +2 -1
  196. package/dist/types/provider/store.d.ts +1 -0
  197. package/dist/types/types/_shared.types.d.ts +1 -0
  198. package/dist/types/types/index.d.ts +1 -0
  199. package/dist/types/types/raw.d.ts +4 -0
  200. package/dist/types/types/searchcraft-base-search-results.types.d.ts +1 -0
  201. package/dist/types/types/searchcraft-filter-panel.types.d.ts +1 -0
  202. package/dist/types/types/searchcraft-popover-form.types.d.ts +1 -0
  203. package/dist/types/utils/facets.d.ts +1 -0
  204. package/dist/types/utils/index.d.ts +1 -0
  205. package/dist/types/utils/styles.d.ts +1 -0
  206. package/dist/types/utils/units.d.ts +1 -0
  207. package/package.json +6 -4
  208. package/dist/cjs/index-b3b77ea2.js.map +0 -1
  209. package/dist/cjs/store-d7ebcf7a.js.map +0 -1
  210. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +0 -227
  211. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.module.css +0 -179
  212. package/dist/collection/components/searchcraft-button/searchcraft-button.module.css +0 -174
  213. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.module.css +0 -158
  214. package/dist/collection/components/searchcraft-facet-list/searchcraft-facet-list.module.css +0 -266
  215. package/dist/collection/components/searchcraft-filter-panel/searchcraft-filter-panel.module.css +0 -168
  216. package/dist/collection/components/searchcraft-input-form/searchcraft-input-form.module.css +0 -293
  217. package/dist/collection/components/searchcraft-input-label/searchcraft-input-label.module.css +0 -159
  218. package/dist/collection/components/searchcraft-popover-button/searchcraft-popover-button.module.css +0 -0
  219. package/dist/collection/components/searchcraft-popover-form/searchcraft-popover-form.module.css +0 -322
  220. package/dist/collection/components/searchcraft-popover-list-item/searchcraft-popover-list-item.module.css +0 -209
  221. package/dist/collection/components/searchcraft-popover-list-view/searchcraft-popover-list-view.module.css +0 -0
  222. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.module.css +0 -169
  223. package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +0 -231
  224. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +0 -207
  225. package/dist/components/p-02a16e53.js +0 -240
  226. package/dist/components/p-02a16e53.js.map +0 -1
  227. package/dist/components/p-04c46179.js +0 -101
  228. package/dist/components/p-04c46179.js.map +0 -1
  229. package/dist/components/p-0e38a723.js +0 -99
  230. package/dist/components/p-0e38a723.js.map +0 -1
  231. package/dist/components/p-4c45ef80.js +0 -67
  232. package/dist/components/p-4c45ef80.js.map +0 -1
  233. package/dist/components/p-85765b81.js.map +0 -1
  234. package/dist/components/p-953f4238.js +0 -35
  235. package/dist/components/p-953f4238.js.map +0 -1
  236. package/dist/components/p-a248ad69.js +0 -276
  237. package/dist/components/p-a248ad69.js.map +0 -1
  238. package/dist/components/p-a9bd1872.js +0 -38
  239. package/dist/components/p-a9bd1872.js.map +0 -1
  240. package/dist/components/p-cf4ced92.js +0 -49
  241. package/dist/components/p-cf4ced92.js.map +0 -1
  242. package/dist/components/p-d6a88eed.js.map +0 -1
  243. package/dist/components/p-e4846fa2.js.map +0 -1
  244. package/dist/components/p-f9d778b3.js +0 -48
  245. package/dist/components/p-f9d778b3.js.map +0 -1
  246. package/dist/esm/index-11551663.js.map +0 -1
  247. package/dist/esm/store-1058f7b0.js.map +0 -1
  248. package/dist/searchcraft-javascript-sdk/p-4580e8a4.entry.js +0 -2
  249. package/dist/searchcraft-javascript-sdk/p-4580e8a4.entry.js.map +0 -1
  250. package/dist/searchcraft-javascript-sdk/p-7049b93d.entry.js +0 -2
  251. package/dist/searchcraft-javascript-sdk/p-7049b93d.entry.js.map +0 -1
  252. package/dist/searchcraft-javascript-sdk/p-8e539d62.entry.js +0 -2
  253. package/dist/searchcraft-javascript-sdk/p-8e539d62.entry.js.map +0 -1
  254. package/dist/searchcraft-javascript-sdk/p-98640a6a.entry.js +0 -2
  255. package/dist/searchcraft-javascript-sdk/p-98640a6a.entry.js.map +0 -1
  256. package/dist/searchcraft-javascript-sdk/p-9d0f5c89.entry.js +0 -2
  257. package/dist/searchcraft-javascript-sdk/p-9d0f5c89.entry.js.map +0 -1
  258. package/dist/searchcraft-javascript-sdk/p-b8bd53ce.entry.js +0 -2
  259. package/dist/searchcraft-javascript-sdk/p-b8bd53ce.entry.js.map +0 -1
  260. package/dist/searchcraft-javascript-sdk/p-c27a3673.entry.js +0 -2
  261. package/dist/searchcraft-javascript-sdk/p-c27a3673.entry.js.map +0 -1
  262. package/dist/searchcraft-javascript-sdk/p-cd852b84.entry.js +0 -2
  263. package/dist/searchcraft-javascript-sdk/p-cd852b84.entry.js.map +0 -1
  264. package/dist/searchcraft-javascript-sdk/p-d6a88eed.js +0 -11
  265. package/dist/searchcraft-javascript-sdk/p-d6a88eed.js.map +0 -1
  266. package/dist/searchcraft-javascript-sdk/p-e042deb9.entry.js +0 -2
  267. package/dist/searchcraft-javascript-sdk/p-e042deb9.entry.js.map +0 -1
  268. package/dist/searchcraft-javascript-sdk/p-e0be53df.js +0 -3
  269. package/dist/searchcraft-javascript-sdk/p-e0be53df.js.map +0 -1
  270. package/dist/searchcraft-javascript-sdk/p-efab9f3c.entry.js +0 -2
  271. package/dist/searchcraft-javascript-sdk/p-efab9f3c.entry.js.map +0 -1
@@ -0,0 +1,284 @@
1
+ import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
2
+ import { u as useSearchcraftStore, b as ae } from './p-936e2ed4.js';
3
+ import { p as parseCustomStyles } from './p-d9551738.js';
4
+ import { c as classNames } from './p-5cdc6210.js';
5
+ import { d as defineCustomElement$3 } from './p-521fe971.js';
6
+ import { d as defineCustomElement$2 } from './p-a75ef832.js';
7
+ import { d as defineCustomElement$1 } from './p-ca881e5c.js';
8
+
9
+ const name = "@searchcraft/javascript-sdk";
10
+ const version = "0.7.1";
11
+ const description = "Searchcraft Javascript SDK";
12
+ const author = "Searchcraft";
13
+ const license = "Apache-2.0";
14
+ const main = "dist/index.cjs.js";
15
+ const module = "dist/index.js";
16
+ const types = "dist/types/index.d.ts";
17
+ const collection = "dist/collection/collection-manifest.json";
18
+ const unpkg = "dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js";
19
+ const exports = {
20
+ ".": {
21
+ "import": "./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js",
22
+ require: "./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.cjs.js",
23
+ types: "./dist/types/index.d.ts"
24
+ },
25
+ "./components": {
26
+ "import": "./dist/components/index.js",
27
+ types: "./dist/components/index.d.ts"
28
+ },
29
+ "./loader": {
30
+ "import": "./dist/loader/index.js",
31
+ require: "./dist/loader/index.cjs",
32
+ types: "./dist/loader/index.d.ts"
33
+ },
34
+ "./dist/components/*": {
35
+ "import": "./dist/components/*",
36
+ types: "./dist/components/*"
37
+ }
38
+ };
39
+ const repository = {
40
+ type: "git",
41
+ url: "https://bitbucket.org/madebychalk/searchcraft-javascript-sdks/"
42
+ };
43
+ const files = [
44
+ "dist/"
45
+ ];
46
+ const scripts = {
47
+ build: "stencil build && yarn docs",
48
+ docs: "typedoc --options typedoc.json",
49
+ dev: "stencil build --dev --watch",
50
+ test: "stencil test --spec --e2e",
51
+ "test.watch": "stencil test --spec --e2e --watchAll",
52
+ generate: "stencil generate"
53
+ };
54
+ const dependencies = {
55
+ "@stencil/vue-output-target": "^0.9.2",
56
+ classnames: "^2.3.2"
57
+ };
58
+ const devDependencies = {
59
+ "@searchcraft/core": "^0.7.1",
60
+ "@searchcraft/javascript-sdk": "*",
61
+ "@stencil/core": "^4.7.0",
62
+ "@stencil/react-output-target": "^0.8.2",
63
+ "@stencil/sass": "^3.0.12",
64
+ "@types/node": "^16.18.11",
65
+ zustand: "^5.0.1"
66
+ };
67
+ const packageJson = {
68
+ name: name,
69
+ "private": false,
70
+ version: version,
71
+ description: description,
72
+ author: author,
73
+ license: license,
74
+ main: main,
75
+ module: module,
76
+ types: types,
77
+ collection: collection,
78
+ "collection:main": "dist/collection/index.js",
79
+ unpkg: unpkg,
80
+ exports: exports,
81
+ repository: repository,
82
+ files: files,
83
+ scripts: scripts,
84
+ dependencies: dependencies,
85
+ devDependencies: devDependencies
86
+ };
87
+
88
+ const SearchcraftInput = /*@__PURE__*/ proxyCustomElement(class SearchcraftInput extends H {
89
+ constructor() {
90
+ super();
91
+ this.__registerHost();
92
+ this.inputCleared = createEvent(this, "inputCleared", 7);
93
+ this.noResultsReceived = createEvent(this, "noResultsReceived", 7);
94
+ this.inputFocus = createEvent(this, "inputFocus", 7);
95
+ this.inputBlur = createEvent(this, "inputBlur", 7);
96
+ this.inputInit = createEvent(this, "inputInit", 7);
97
+ this.querySubmit = createEvent(this, "querySubmit", 7);
98
+ }
99
+ /**
100
+ * The Searchcraft config object.
101
+ */
102
+ config;
103
+ /**
104
+ * Whether or not to automatically submit the search term when the input changes.
105
+ */
106
+ autoSearch = true;
107
+ /**
108
+ * Where to place the search button.
109
+ */
110
+ buttonPlacement = 'none';
111
+ /**
112
+ * The label for the submit button.
113
+ */
114
+ buttonLabel;
115
+ /**
116
+ * The label rendered above the input.
117
+ */
118
+ inputLabel;
119
+ /**
120
+ * A custom styles object to be applied to the input element.
121
+ */
122
+ customStyles = {};
123
+ /**
124
+ * The input element's placeholder value.
125
+ */
126
+ placeholderValue = 'Enter Search';
127
+ /**
128
+ * The starting value of the input element.
129
+ */
130
+ searchTerm = '';
131
+ /**
132
+ * When the input is cleared.
133
+ */
134
+ inputCleared;
135
+ /**
136
+ * When no results are returned.
137
+ */
138
+ noResultsReceived;
139
+ /**
140
+ * When the input becomes focused.
141
+ */
142
+ inputFocus;
143
+ /**
144
+ * When the input becomes unfocused.
145
+ */
146
+ inputBlur;
147
+ /**
148
+ * Event emitted when input initializes.
149
+ */
150
+ inputInit;
151
+ /**
152
+ * Event emitted when a query has been submitted.
153
+ */
154
+ querySubmit;
155
+ inputValue = this.searchTerm;
156
+ error = false;
157
+ isSearchcraftInitialized = false;
158
+ searchStore = useSearchcraftStore.getState();
159
+ init() {
160
+ if (this.config && !this.isSearchcraftInitialized) {
161
+ const searchcraft = new ae(this.config, {
162
+ sdkName: packageJson.name,
163
+ sdkVersion: packageJson.version,
164
+ });
165
+ this.searchStore.initialize(searchcraft, true);
166
+ this.isSearchcraftInitialized = true;
167
+ this.inputInit?.emit();
168
+ }
169
+ }
170
+ componentDidLoad() {
171
+ this.init();
172
+ }
173
+ onConfigChange() {
174
+ this.init();
175
+ }
176
+ handleOnInput = (event) => {
177
+ const input = event.target;
178
+ this.inputValue = input.value;
179
+ if (input.value.trim() === '') {
180
+ this.inputCleared?.emit();
181
+ this.searchTerm = '';
182
+ this.searchStore.setQuery('');
183
+ this.searchStore.setSearchResults(null);
184
+ return;
185
+ }
186
+ if (!this.autoSearch) {
187
+ return;
188
+ }
189
+ this.performSearch(input.value);
190
+ };
191
+ performSearch = async (value) => {
192
+ if (value === useSearchcraftStore.getState().query) {
193
+ return;
194
+ }
195
+ this.searchTerm = value.trim();
196
+ this.error = false;
197
+ this.searchStore.setQuery(this.searchTerm);
198
+ this.querySubmit?.emit(this.searchTerm);
199
+ try {
200
+ await this.searchStore.search();
201
+ }
202
+ catch (error) {
203
+ this.error = true;
204
+ this.inputCleared?.emit();
205
+ }
206
+ };
207
+ handleClearInput = () => {
208
+ this.inputValue = '';
209
+ this.searchTerm = '';
210
+ this.searchStore.setQuery('');
211
+ this.searchStore.setSearchResults(null);
212
+ this.error = false;
213
+ this.inputCleared?.emit();
214
+ };
215
+ handleFormSubmit = async (event) => {
216
+ event.preventDefault();
217
+ await this.performSearch(this.searchTerm);
218
+ };
219
+ render() {
220
+ const validatedCustomStyles = parseCustomStyles(this.customStyles);
221
+ const isShowingClearButton = this.inputValue.length > 0;
222
+ const inputGridClassNames = classNames('searchcraft-input-grid', {
223
+ 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',
224
+ 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',
225
+ 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',
226
+ });
227
+ const shouldHaveVerticalGap = this.inputLabel || this.error;
228
+ const inputGridStyles = {
229
+ gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',
230
+ };
231
+ return (h("form", { key: 'b23e712102e03332d5958b736133ac5222c571ed', class: 'searchcraft-input-form', onSubmit: this.handleFormSubmit }, h("div", { key: '62e1666b20e3901565241c83cb6b398afbaf14bf', class: inputGridClassNames, style: inputGridStyles }, h("div", { key: '1f78f96f48e354ba434bcd6c8eb20f6940d2281c', class: 'searchcraft-input-button-wrapper' }, h("searchcraft-button", { key: '0e89a333f3d489dccb05d978dde8622ee24a2508', onButtonClick: this.handleFormSubmit, label: this.buttonLabel })), this.inputLabel && (h("div", { key: '1b75214db1a0a9d7144e8974e3467da9a94cc845', class: 'searchcraft-input-label-wrapper' }, h("searchcraft-input-label", { key: 'd7edaa9b980eae47628747488e4966ef62fab574', label: this.inputLabel }))), this.error && (h("div", { key: '936858e238d96838caa3aa34dbb4d86b3f6ad839', class: 'searchcraft-input-error-wrapper' }, h("searchcraft-error-message", { key: '75400c0a6f9d20f5c58ef0125f70a0ba8f2da920', errorMessage: 'Something went wrong.' }))), h("div", { key: '0978f74e9a83c78604c494fca9d8a885f73b5fff', class: 'searchcraft-input-wrapper' }, h("input", { key: '4a9f69a9e21c89c97daea9e4c19e41523c71e0f2', autoComplete: 'off', class: 'searchcraft-input', onFocus: () => this.inputFocus?.emit(), onBlur: () => this.inputBlur?.emit(), onInput: (event) => {
232
+ this.handleOnInput(event);
233
+ }, placeholder: this.placeholderValue, style: validatedCustomStyles, type: 'text', value: this.inputValue }), h("div", { key: '9c215722544c132dc9e302c522d0f7c36c205b74', class: 'searchcraft-input-search-icon-wrapper' }, h("svg", { key: '4f6dfc2a89a888eafcd4aee6d02e40635c2fb78a', class: 'searchcraft-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'searchcraft-title' }, h("title", { key: '6be4ba3b739aeebd27e2ba0f3b7766c1ac6cf2e3', id: 'searchcraft-title' }, "Searchcraft Search Icon Light"), h("path", { key: 'd62f785b5bb2f261a3dbf8e4d91f2db405e36dc4', d: 'M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z', stroke: '#404040', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))), isShowingClearButton && (h("button", { key: '8ca5193982311991eb0bf30a200b5bee25688c54', type: 'button', class: 'searchcraft-input-clear-button', onClick: this.handleClearInput }, h("svg", { key: 'a929aee41d677e850a2568ee08a047f35711b4bf', class: 'searchcraft-input-clear-icon', viewBox: '0 0 22 22', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-labelledby": 'icon-title' }, h("title", { key: '60b50c641ab494c1e8f02f3e1fa19d0a41162859', id: 'icon-title' }, "Searchcraft Clear Input Icon Light"), h("path", { key: '6d47a20770f51f069efe06ee29c1451fd78de357', d: 'M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z', stroke: 'black', "stroke-width": '1.5', "stroke-linecap": 'round', "stroke-linejoin": 'round' }))))))));
234
+ }
235
+ static get watchers() { return {
236
+ "config": ["onConfigChange"]
237
+ }; }
238
+ }, [0, "searchcraft-input-form", {
239
+ "config": [16],
240
+ "autoSearch": [4, "auto-search"],
241
+ "buttonPlacement": [1, "button-placement"],
242
+ "buttonLabel": [1, "button-label"],
243
+ "inputLabel": [1, "input-label"],
244
+ "customStyles": [1, "custom-styles"],
245
+ "placeholderValue": [1, "placeholder-value"],
246
+ "searchTerm": [1, "search-term"],
247
+ "inputValue": [32],
248
+ "error": [32],
249
+ "isSearchcraftInitialized": [32]
250
+ }, undefined, {
251
+ "config": ["onConfigChange"]
252
+ }]);
253
+ function defineCustomElement() {
254
+ if (typeof customElements === "undefined") {
255
+ return;
256
+ }
257
+ const components = ["searchcraft-input-form", "searchcraft-button", "searchcraft-error-message", "searchcraft-input-label"];
258
+ components.forEach(tagName => { switch (tagName) {
259
+ case "searchcraft-input-form":
260
+ if (!customElements.get(tagName)) {
261
+ customElements.define(tagName, SearchcraftInput);
262
+ }
263
+ break;
264
+ case "searchcraft-button":
265
+ if (!customElements.get(tagName)) {
266
+ defineCustomElement$3();
267
+ }
268
+ break;
269
+ case "searchcraft-error-message":
270
+ if (!customElements.get(tagName)) {
271
+ defineCustomElement$2();
272
+ }
273
+ break;
274
+ case "searchcraft-input-label":
275
+ if (!customElements.get(tagName)) {
276
+ defineCustomElement$1();
277
+ }
278
+ break;
279
+ } });
280
+ }
281
+
282
+ export { SearchcraftInput as S, defineCustomElement as d };
283
+
284
+ //# sourceMappingURL=p-d95bc2a0.js.map
@@ -0,0 +1 @@
1
+ {"file":"p-d95bc2a0.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8Ca,gBAAgB;;;;;;;;;;;;;;IAInB,MAAM,CAAgC;;;;IAItC,UAAU,GAAG,IAAI,CAAC;;;;IAIlB,eAAe,GAA8B,MAAM,CAAC;;;;IAIpD,WAAW,CAAqB;;;;IAIhC,UAAU,CAAqB;;;;IAI/B,YAAY,GAAoC,EAAE,CAAC;;;;IAInD,gBAAgB,GAAG,cAAc,CAAC;;;;IAIlC,UAAU,GAAG,EAAE,CAAC;;;;IAIf,YAAY,CAAsB;;;;IAIlC,iBAAiB,CAAsB;;;;IAIvC,UAAU,CAAsB;;;;IAIhC,SAAS,CAAsB;;;;IAI/B,SAAS,CAAsB;;;;IAI/B,WAAW,CAAwB;IAEnC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,KAAK,GAAG,KAAK,CAAC;IACd,wBAAwB,GAAG,KAAK,CAAC;IAElC,WAAW,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE;YACjD,MAAM,WAAW,GAAG,IAAIA,EAAe,CAAC,I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AAmN,EACrN,MAAM,EAAC,SAAS,kBACH,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACF,EACL,oBAAoB,KACnB,+DACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,gCAAgC,EACtC,OAAO,EAAE,IAAI,CAAC,gBAAgB,IAE9B,4DACE,KAAK,EAAC,8BAA8B,EACpC,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,YAAY,IAE5B,8DAAO,EAAE,EAAC,YAAY,yCAEd,EACR,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,OAAO,kBACD,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftCore"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\n\nimport { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport packageJson from '../../../package.json';\n\nimport { parseCustomStyles } from '@utils';\nimport { useSearchcraftStore } from '@provider/store';\nimport classNames from 'classnames';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-input-form placeholder-value=\"Search here\" />\n * ```\n *\n * ```js\n * // index.js\n * const searchInputForm = document.querySelector('searchcraft-input-form');\n *\n * seardchInputForm.config = {\n * index: [],\n * readKey: '',\n * endpointUrl: '',\n * };\n *\n * searchForm.addEventListener('querySubmit', (event) => {\n * console.log('Query submitted', event.detail);\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInput {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel: string | undefined;\n /**\n * A custom styles object to be applied to the input element.\n */\n @Prop() customStyles: string | Record<string, string> = {};\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue = 'Enter Search';\n /**\n * The starting value of the input element.\n */\n @Prop() searchTerm = '';\n /**\n * When the input is cleared.\n */\n @Event() inputCleared?: EventEmitter<void>;\n /**\n * When no results are returned.\n */\n @Event() noResultsReceived?: EventEmitter<void>;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n /**\n * Event emitted when a query has been submitted.\n */\n @Event() querySubmit?: EventEmitter<string>;\n\n @State() inputValue = this.searchTerm;\n @State() error = false;\n @State() isSearchcraftInitialized = false;\n\n private searchStore = useSearchcraftStore.getState();\n\n init() {\n if (this.config && !this.isSearchcraftInitialized) {\n const searchcraft = new SearchcraftCore(this.config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n this.searchStore.initialize(searchcraft, true);\n this.isSearchcraftInitialized = true;\n this.inputInit?.emit();\n }\n }\n\n componentDidLoad() {\n this.init();\n }\n\n @Watch('config')\n onConfigChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (input.value.trim() === '') {\n this.inputCleared?.emit();\n this.searchTerm = '';\n this.searchStore.setQuery('');\n this.searchStore.setSearchResults(null);\n return;\n }\n\n if (!this.autoSearch) {\n return;\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === useSearchcraftStore.getState().query) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setQuery(this.searchTerm);\n this.querySubmit?.emit(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n this.error = true;\n this.inputCleared?.emit();\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setQuery('');\n this.searchStore.setSearchResults(null);\n this.error = false;\n\n this.inputCleared?.emit();\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const validatedCustomStyles = parseCustomStyles(this.customStyles);\n\n const isShowingClearButton = this.inputValue.length > 0;\n\n const inputGridClassNames = classNames('searchcraft-input-grid', {\n 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',\n 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',\n 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',\n });\n\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-button-wrapper'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-label-wrapper'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-error-wrapper'>\n <searchcraft-error-message errorMessage='Something went wrong.' />\n </div>\n )}\n <div class='searchcraft-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n style={validatedCustomStyles}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-search-icon-wrapper'>\n <svg\n class='searchcraft-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title id='searchcraft-title'>\n Searchcraft Search Icon Light\n </title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='#404040'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title id='icon-title'>\n Searchcraft Clear Input Icon Light\n </title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='black'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftBaseSearchResult$1, d as defineCustomElement$1 } from './p-04c46179.js';
1
+ import { S as SearchcraftBaseSearchResult$1, d as defineCustomElement$1 } from './p-b4a8fcbe.js';
2
2
 
3
3
  const SearchcraftBaseSearchResult = SearchcraftBaseSearchResult$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,33 +1,68 @@
1
- import { p as proxyCustomElement, H, c as createEvent, h } from './p-e4846fa2.js';
2
- import { u as useSearchcraftStore } from './p-d6a88eed.js';
1
+ import { p as proxyCustomElement, H, c as createEvent, h } from './p-5365011f.js';
2
+ import { u as useSearchcraftStore } from './p-936e2ed4.js';
3
3
  import { g as getDocumentValueFromSearchResultMapping } from './p-755f491b.js';
4
4
  import { s as serializeStyles } from './p-d9551738.js';
5
- import { d as defineCustomElement$3 } from './p-04c46179.js';
6
- import { d as defineCustomElement$2 } from './p-953f4238.js';
7
-
8
- const searchcraftBaseSearchResultsModuleCss = ":root{--sc-input-border-radius:8px;--sc-input-search-icon-size:20px;--sc-input-clear-icon-size:20px;--sc-input-padding-left:44px;--sc-input-padding-right:44px;--sc-image-border-radius:8px;--sc-popover-form-border-radius:8px;--sc-popover-list-view-height:400px;--sc-popover-list-item-image-size:60px;--sc-popover-list-item-padding-horizontal:8px;--sc-popover-list-item-padding-vertical:8px;--sc-popover-modal-max-width:570px}:root{--sc-surface-disabled:#D9D9D9;--sc-surface-neutral-primary:#FFFFFF;--sc-surface-neutral-secondary:#F3F3F3;--sc-surface-neutral-light:#FFFFFF;--sc-surface-neutral-primary-hover:#FAFAFA;--sc-surface-neutral-primary-active:#F7F7F7;--sc-surface-neutral-secondary-hover:#EDEDED;--sc-surface-neutral-secondary-active:#E6E6E6;--sc-surface-brand-primary:#000000;--sc-surface-brand-secondary:#E6E6E6;--sc-surface-brand-primary-hover:#2E2E2E;--sc-surface-brand-primary-active:#292929;--sc-surface-brand-secondary-hover:#EBEBEB;--sc-surface-brand-secondary-active:#E0E0E0;--sc-surface-success-primary:#008000;--sc-surface-success-secondary:#CCFFCC;--sc-surface-success-primary-hover:#009900;--sc-surface-success-primary-active:#006600;--sc-surface-success-secondary-hover:#E6FFE6;--sc-surface-success-secondary-active:#E6FFE6;--sc-surface-caution-primary:#CC6600;--sc-surface-caution-secondary:#FFD9B3;--sc-surface-caution-primary-hover:#E57300;--sc-surface-caution-primary-active:#B25A00;--sc-surface-caution-secondary-hover:#FFE5CC;--sc-surface-caution-secondary-active:#FFCC99;--sc-surface-danger-primary:#CC0000;--sc-surface-danger-secondary:#FFCCCC;--sc-surface-danger-primary-hover:#E50000;--sc-surface-danger-primary-active:#B30000;--sc-surface-danger-secondary-hover:#FFE7E7;--sc-surface-danger-secondary-active:#FFB3B3;--sc-content-brand:#000000;--sc-content-success:#008000;--sc-content-caution:#994D00;--sc-content-danger:#990000;--sc-content-disabled:#737373;--sc-content-neutral-primary:#292929;--sc-content-neutral-secondary:#404040;--sc-content-brand-on-primary:#FFFFFF;--sc-content-success-on-primary:#FFFFFF;--sc-content-caution-on-primary:#FFFFFF;--sc-content-danger-on-primary:#FFFFFF;--sc-content-disabled-on-disabled:#737373;--sc-border-neutral:rgba(0,0,0, 0.1);--sc-border-brand:#000000;--sc-border-success:#008000;--sc-border-caution:#CC6600;--sc-border-danger:#CC0000;--sc-border-disabled:#737373}:root{--sc-font-family:sans-serif;--sc-heading-1-font-size:32px;--sc-heading-1-line-height:36px;--sc-heading-1-font-weight:700;--sc-heading-2-font-size:29px;--sc-heading-2-line-height:32px;--sc-heading-2-font-weight:700;--sc-heading-3-font-size:26px;--sc-heading-3-line-height:28px;--sc-heading-3-font-weight:700;--sc-heading-4-font-size:23px;--sc-heading-4-line-height:24px;--sc-heading-4-font-weight:700;--sc-heading-5-font-size:20px;--sc-heading-5-line-height:24px;--sc-heading-5-font-weight:700;--sc-heading-6-font-size:10px;--sc-heading-6-line-height:12px;--sc-heading-6-font-weight:700;--sc-body-bold-font-size:16px;--sc-body-bold-line-height:20px;--sc-body-bold-font-weight:700;--sc-body-font-size:16px;--sc-body-line-height:20px;--sc-body-font-weight:400;--sc-body-small-bold-font-size:12px;--sc-body-small-bold-line-height:16px;--sc-body-small-bold-font-weight:700;--sc-body-small-font-size:12px;--sc-body-small-line-height:16px;--sc-body-small-font-weight:400}:root{--sc-breakpoint-sm:576px;--sc-breakpoint-md:768px;--sc-breakpoint-lg:992px}.searchcraft-search-results-container{display:flex;flex-direction:column;justify-content:center;gap:16px}.searchcraft-ad-section{align-items:center;background-color:#F1F1F1;border-radius:16px;display:flex;flex-direction:column;font-size:16px;justify-content:center;min-height:176px;text-align:center}.searchcraft-ad-section p{margin:0;color:var(--sc-content-disabled)}.searchcraft-search-results-empty-state-container{text-align:center}.searchcraft-search-results-error-message-container{text-align:center}";
9
- const SearchcraftBaseSearchResultsStyle0 = searchcraftBaseSearchResultsModuleCss;
5
+ import { d as defineCustomElement$3 } from './p-b4a8fcbe.js';
6
+ import { d as defineCustomElement$2 } from './p-a75ef832.js';
10
7
 
11
8
  const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftBaseSearchResults extends H {
12
9
  constructor() {
13
10
  super();
14
11
  this.__registerHost();
15
12
  this.noResults = createEvent(this, "noResults", 7);
16
- this.adInterval = 4;
17
- this.customStylesForResults = undefined;
18
- this.searchResultMappings = undefined;
19
- this.placeAdAtEnd = false;
20
- this.placeAdAtStart = true;
21
- this.resultImagePlacement = 'right';
22
- this.buttonLabel = undefined;
23
- this.buttonTarget = '_blank';
24
- this.buttonRel = undefined;
25
- this.containerTarget = '_blank';
26
- this.containerRel = undefined;
27
- this.hasSearched = false;
28
- this.query = '';
29
- this.searchResults = null;
30
13
  }
14
+ /**
15
+ * How often ads are injected.
16
+ */
17
+ adInterval = 4;
18
+ /**
19
+ * A custom styles object.
20
+ */
21
+ customStylesForResults;
22
+ /**
23
+ * Formats the content rendered for each result.
24
+ */
25
+ searchResultMappings;
26
+ /**
27
+ * Should an ad be placed at the end of the results.
28
+ */
29
+ placeAdAtEnd = false;
30
+ /**
31
+ * Should an ad be placed at the start of the results.
32
+ */
33
+ placeAdAtStart = true;
34
+ /**
35
+ * The placement of the image for each result.
36
+ */
37
+ resultImagePlacement = 'right';
38
+ /**
39
+ * The label for the button rendered when containerHref is not present for each result.
40
+ */
41
+ buttonLabel;
42
+ /**
43
+ * Where to open the link for the button rendered when containerHref is not present for each result.
44
+ */
45
+ buttonTarget = '_blank';
46
+ /**
47
+ * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.
48
+ */
49
+ buttonRel;
50
+ /**
51
+ * Where to open the link for the containing element for each result.
52
+ */
53
+ containerTarget = '_blank';
54
+ /**
55
+ * The relationship between the current document and the link for the containing element for each result.
56
+ */
57
+ containerRel;
58
+ /**
59
+ * When no results are returned.
60
+ */
61
+ noResults;
62
+ hasSearched = false;
63
+ query = '';
64
+ searchResults = null;
65
+ unsubscribe = () => { };
31
66
  componentDidLoad() {
32
67
  this.unsubscribe = useSearchcraftStore.subscribe((state) => {
33
68
  if (state.query.length > 0) {
@@ -36,7 +71,7 @@ const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class Se
36
71
  else {
37
72
  this.hasSearched = false;
38
73
  }
39
- this.searchResults = Object.assign({}, state.searchResults);
74
+ this.searchResults = { ...state.searchResults };
40
75
  this.query = state.query;
41
76
  });
42
77
  const { searchResults, query } = useSearchcraftStore.getState();
@@ -52,27 +87,30 @@ const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class Se
52
87
  /**
53
88
  * Index field values -> Result container props mappings.
54
89
  */
55
- const titleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.title);
56
- const subtitleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.subtitle);
57
- const bodyContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.body);
58
- const containerHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.containerHref);
59
- const buttonHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.buttonHref);
60
- const imageSource = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.imageSource);
61
- const footerContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings.footer);
62
- const serializedStyles = typeof this.customStylesForResults === 'string'
63
- ? this.customStylesForResults
64
- : serializeStyles(this.customStylesForResults);
90
+ const titleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.title);
91
+ const subtitleContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.subtitle);
92
+ const bodyContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.body);
93
+ const containerHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.containerHref);
94
+ const buttonHref = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.buttonHref);
95
+ const imageSource = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.imageSource);
96
+ const footerContent = getDocumentValueFromSearchResultMapping(document, this.searchResultMappings?.footer);
97
+ let serializedStyles = '';
98
+ if (this.customStylesForResults) {
99
+ serializedStyles =
100
+ typeof this.customStylesForResults === 'string'
101
+ ? this.customStylesForResults
102
+ : serializeStyles(this.customStylesForResults);
103
+ }
65
104
  return (h("searchcraft-base-search-result", { key: `${document.document_id}-${index}`, "custom-styles": serializedStyles, "image-placement": this.resultImagePlacement, "container-rel": this.containerRel, "container-target": this.containerTarget, "button-label": this.buttonLabel || 'View more', "button-rel": this.buttonRel, "button-target": this.buttonTarget, "document-position": index, "title-content": titleContent, "subtitle-content": subtitleContent, "body-content": bodyContent, "footer-content": footerContent, "container-href": containerHref, "button-href": buttonHref, "image-src": imageSource }));
66
105
  }
67
106
  render() {
68
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
69
107
  if (this.query.trim() === '') {
70
108
  return (h("div", { class: 'searchcraft-search-results-empty-state-container' }, h("slot", { name: 'empty-search' })));
71
109
  }
72
- if (!((_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.data)) {
110
+ if (!this.searchResults?.data) {
73
111
  return;
74
112
  }
75
- const documents = (_d = (_c = (_b = this.searchResults) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.hits) === null || _d === void 0 ? void 0 : _d.map((data, _index) => {
113
+ const documents = this.searchResults?.data?.hits?.map((data, _index) => {
76
114
  const { doc: result } = data;
77
115
  return result;
78
116
  });
@@ -95,13 +133,12 @@ const SearchcraftBaseSearchResults$1 = /*@__PURE__*/ proxyCustomElement(class Se
95
133
  if (this.placeAdAtEnd) {
96
134
  finalComponents.push(h("div", { key: 'ad-section-end', class: 'searchcraft-ad-section' }, h("p", null, "Ad Section")));
97
135
  }
98
- if (this.query.length > 0 && ((_g = (_f = (_e = this.searchResults) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.hits) === null || _g === void 0 ? void 0 : _g.length) === 0) {
99
- this.noResults.emit();
136
+ if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {
137
+ this.noResults?.emit();
100
138
  }
101
139
  return (h("div", { class: 'searchcraft-search-results-container' }, finalComponents, this.query.length > 0 &&
102
- ((_k = (_j = (_h = this.searchResults) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.hits) === null || _k === void 0 ? void 0 : _k.length) === 0 && (h("div", { class: 'searchcraft-search-results-error-message-container' }, h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` })))));
140
+ this.searchResults?.data?.hits?.length === 0 && (h("div", { class: 'searchcraft-search-results-error-message-container' }, h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` })))));
103
141
  }
104
- static get style() { return SearchcraftBaseSearchResultsStyle0; }
105
142
  }, [4, "searchcraft-base-search-results", {
106
143
  "adInterval": [2, "ad-interval"],
107
144
  "customStylesForResults": [1, "custom-styles-for-results"],
@@ -1 +1 @@
1
- {"file":"searchcraft-base-search-results.js","mappings":";;;;;;;AAAA,MAAM,qCAAqC,GAAG,2zHAA2zH,CAAC;AAC12H,2CAAe,qCAAqC;;MCuDvCA,8BAA4B;;;;;0BAIlB,CAAC;;;4BAeC,KAAK;8BAIH,IAAI;oCAIoB,OAAO;;4BAQQ,QAAQ;;+BAQL,QAAQ;;2BAWpD,KAAK;qBACX,EAAE;6BACkC,IAAI;;IAIzD,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YACrD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CA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C,KAAK,SAAS,GAClE,CACE,CACP,CACC,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftBaseSearchResults"],"sources":["src/components/searchcraft-base-search-results/searchcraft-base-search-results.module.scss?tag=searchcraft-base-search-results","src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"sourcesContent":[".searchcraft-search-results-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 16px;\n}\n\n.searchcraft-ad-section {\n align-items: center;\n background-color: #F1F1F1;\n border-radius: 16px;\n display: flex;\n flex-direction: column;\n font-size: 16px;\n justify-content: center;\n min-height: 176px;\n text-align: center;\n\n p {\n margin: 0;\n color: var(--sc-content-disabled);\n }\n}\n\n.searchcraft-search-results-empty-state-container {\n text-align: center;\n}\n\n.searchcraft-search-results-error-message-container {\n text-align: center;\n}\n","import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils';\nimport type { SearchResultMappings } from 'types';\n\n/**\n * This web component is responsible for displaying the results of a search query.\n * Once a query is submitted, the component formats and presents an ordered list of the results.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-base-search-results\n * ad-interval=\"4\"\n * place-ad-at-start=\"false\"\n * result-image-placement=\"right\"\n * />\n * ```\n *\n * ```js\n * // index.js\n * const baseSearchResults = document.querySelector('searchcraft-base-search-results');\n *\n * baseSearchResults.searchResultMappings = containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n *\n * baseSearchResults.addEventListener('noResults', () => {\n * console.log('No search results found');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-base-search-results',\n styleUrl: 'searchcraft-base-search-results.module.scss',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n /**\n * How often ads are injected.\n */\n @Prop() adInterval = 4;\n /**\n * A custom styles object.\n */\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n /**\n * Formats the content rendered for each result.\n */\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n /**\n * Should an ad be placed at the end of the results.\n */\n @Prop() placeAdAtEnd = false;\n /**\n * Should an ad be placed at the start of the results.\n */\n @Prop() placeAdAtStart = true;\n /**\n * The placement of the image for each result.\n */\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n /**\n * The label for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * Where to open the link for the containing element for each result.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element for each result.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n /**\n * When no results are returned.\n */\n @Event() noResults: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void;\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults };\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings.footer,\n );\n\n const serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n });\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"searchcraft-base-search-results.js","mappings":";;;;;;;MAwDaA,8BAA4B;;;;;;;;;IAI/B,UAAU,GAAG,CAAC,CAAC;;;;IAIf,sBAAsB,CAGhB;;;;IAIN,oBAAoB,CAAmC;;;;IAIvD,YAAY,GAAG,KAAK,CAAC;;;;IAIrB,cAAc,GAAG,IAAI,CAAC;;;;IAItB,oBAAoB,GAAqB,OAAO,CAAC;;;;IAIjD,WAAW,CAAqB;;;;IAIhC,YAAY,GAA4C,QAAQ,CAAC;;;;IAIjE,SAAS,CAAqD;;;;IAI9D,eAAe,GAA4C,QAAQ,CAAC;;;;IAIpE,YAAY,CAAqD;;;;IAKhE,SAAS,CAAsB;IAE/B,WAAW,GAAG,KAAK,CAAC;IACpB,KAAK,GAAG,EAAE,CAAC;IACX,aAAa,GAA+B,IAAI,CAAC;IAElD,WAAW,GAAe,SAAQ,CAAC;IAE3C,gBAAgB;QACd,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAK;YACrD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;aACzB;iB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftBaseSearchResults"],"sources":["src/components/searchcraft-base-search-results/searchcraft-base-search-results.tsx"],"sourcesContent":["import {\n Component,\n h,\n Event,\n Prop,\n State,\n type EventEmitter,\n} from '@stencil/core';\n\nimport type { SearchcraftResponse } from '@searchcraft/core';\n\nimport { useSearchcraftStore } from '@provider/store';\n\nimport {\n getDocumentValueFromSearchResultMapping,\n serializeStyles,\n} from '@utils';\nimport type { SearchResultMappings } from 'types';\nimport type { JSX } from '@stencil/core/internal';\n\n/**\n * This web component is responsible for displaying the results of a search query.\n * Once a query is submitted, the component formats and presents an ordered list of the results.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-base-search-results\n * ad-interval=\"4\"\n * place-ad-at-start=\"false\"\n * result-image-placement=\"right\"\n * />\n * ```\n *\n * ```js\n * // index.js\n * const baseSearchResults = document.querySelector('searchcraft-base-search-results');\n *\n * baseSearchResults.searchResultMappings = containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n *\n * baseSearchResults.addEventListener('noResults', () => {\n * console.log('No search results found');\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-base-search-results',\n shadow: false,\n})\nexport class SearchcraftBaseSearchResults {\n /**\n * How often ads are injected.\n */\n @Prop() adInterval = 4;\n /**\n * A custom styles object.\n */\n @Prop() customStylesForResults:\n | string\n | Record<string, Record<string, string>>\n | undefined;\n /**\n * Formats the content rendered for each result.\n */\n @Prop() searchResultMappings: SearchResultMappings | undefined;\n /**\n * Should an ad be placed at the end of the results.\n */\n @Prop() placeAdAtEnd = false;\n /**\n * Should an ad be placed at the start of the results.\n */\n @Prop() placeAdAtStart = true;\n /**\n * The placement of the image for each result.\n */\n @Prop() resultImagePlacement: 'left' | 'right' = 'right';\n /**\n * The label for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * Where to open the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the button rendered when containerHref is not present for each result.\n */\n @Prop() buttonRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n /**\n * Where to open the link for the containing element for each result.\n */\n @Prop() containerTarget: '_blank' | '_self' | '_top' | '_parent' = '_blank';\n /**\n * The relationship between the current document and the link for the containing element for each result.\n */\n @Prop() containerRel: 'noreferrer' | 'noopener' | 'nofollow' | undefined;\n\n /**\n * When no results are returned.\n */\n @Event() noResults?: EventEmitter<void>;\n\n @State() hasSearched = false;\n @State() query = '';\n @State() searchResults: SearchcraftResponse | null = null;\n\n private unsubscribe: () => void = () => {};\n\n componentDidLoad() {\n this.unsubscribe = useSearchcraftStore.subscribe((state) => {\n if (state.query.length > 0) {\n this.hasSearched = true;\n } else {\n this.hasSearched = false;\n }\n this.searchResults = { ...state.searchResults } as SearchcraftResponse;\n this.query = state.query;\n });\n\n const { searchResults, query } = useSearchcraftStore.getState();\n this.searchResults = searchResults;\n this.query = query;\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n renderDocument(document: Record<string, unknown>, index: number) {\n /**\n * Index field values -> Result container props mappings.\n */\n const titleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.title,\n );\n const subtitleContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.subtitle,\n );\n const bodyContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.body,\n );\n const containerHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.containerHref,\n );\n const buttonHref = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.buttonHref,\n );\n const imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.imageSource,\n );\n const footerContent = getDocumentValueFromSearchResultMapping(\n document,\n this.searchResultMappings?.footer,\n );\n\n let serializedStyles = '';\n if (this.customStylesForResults) {\n serializedStyles =\n typeof this.customStylesForResults === 'string'\n ? this.customStylesForResults\n : serializeStyles(this.customStylesForResults);\n }\n\n return (\n <searchcraft-base-search-result\n key={`${document.document_id}-${index}`}\n custom-styles={serializedStyles}\n image-placement={this.resultImagePlacement}\n container-rel={this.containerRel}\n container-target={this.containerTarget}\n button-label={this.buttonLabel || 'View more'}\n button-rel={this.buttonRel}\n button-target={this.buttonTarget}\n document-position={index}\n title-content={titleContent}\n subtitle-content={subtitleContent}\n body-content={bodyContent}\n footer-content={footerContent}\n container-href={containerHref}\n button-href={buttonHref}\n image-src={imageSource}\n />\n );\n }\n\n render() {\n if (this.query.trim() === '') {\n return (\n <div class='searchcraft-search-results-empty-state-container'>\n <slot name='empty-search' />\n </div>\n );\n }\n\n if (!this.searchResults?.data) {\n return;\n }\n\n const documents: Record<string, unknown>[] =\n this.searchResults?.data?.hits?.map((data, _index) => {\n const { doc: result } = data;\n return result;\n }) as Record<string, unknown>[];\n\n const finalComponents: JSX.Element[] = [];\n\n if (this.placeAdAtStart) {\n finalComponents.push(\n <div key='ad-section-start' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.adInterval > 0) {\n documents.forEach((document, index) => {\n finalComponents.push(this.renderDocument(document, index));\n\n if ((index + 1) % this.adInterval === 0) {\n finalComponents.push(\n <div\n key={`ad-section-${index + 1}`}\n class='searchcraft-ad-section '\n >\n <p>Ad Section</p>\n </div>,\n );\n }\n });\n } else {\n const documentElements = documents.map((document, index) =>\n this.renderDocument(document, index),\n );\n finalComponents.push(...documentElements);\n }\n\n if (this.placeAdAtEnd) {\n finalComponents.push(\n <div key='ad-section-end' class='searchcraft-ad-section'>\n <p>Ad Section</p>\n </div>,\n );\n }\n\n if (this.query.length > 0 && this.searchResults?.data?.hits?.length === 0) {\n this.noResults?.emit();\n }\n\n return (\n <div class='searchcraft-search-results-container'>\n {finalComponents}\n {this.query.length > 0 &&\n this.searchResults?.data?.hits?.length === 0 && (\n <div class='searchcraft-search-results-error-message-container'>\n <searchcraft-error-message\n error-message={`No search results found for \"${this.query}\" query`}\n />\n </div>\n )}\n </div>\n );\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftButton$1, d as defineCustomElement$1 } from './p-f9d778b3.js';
1
+ import { S as SearchcraftButton$1, d as defineCustomElement$1 } from './p-521fe971.js';
2
2
 
3
3
  const SearchcraftButton = SearchcraftButton$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftErrorMessage$1, d as defineCustomElement$1 } from './p-953f4238.js';
1
+ import { S as SearchcraftErrorMessage$1, d as defineCustomElement$1 } from './p-a75ef832.js';
2
2
 
3
3
  const SearchcraftErrorMessage = SearchcraftErrorMessage$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-a248ad69.js';
1
+ import { S as SearchcraftFacetList$1, d as defineCustomElement$1 } from './p-54998882.js';
2
2
 
3
3
  const SearchcraftFacetList = SearchcraftFacetList$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,30 +1,29 @@
1
- import { p as proxyCustomElement, H, h } from './p-e4846fa2.js';
2
- import { u as useSearchcraftStore } from './p-d6a88eed.js';
1
+ import { p as proxyCustomElement, H, h } from './p-5365011f.js';
2
+ import { u as useSearchcraftStore } from './p-936e2ed4.js';
3
3
  import { a as getMillis } from './p-755f491b.js';
4
- import { d as defineCustomElement$4 } from './p-a248ad69.js';
5
- import { d as defineCustomElement$3 } from './p-0e38a723.js';
6
- import { d as defineCustomElement$2 } from './p-4c45ef80.js';
7
-
8
- const searchcraftFilterPanelModuleCss = ":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-filter-panel{display:flex;flex-direction:column;gap:16px}.searchcraft-filter-panel-section{display:flex;flex-direction:column;gap:8px}.searchcraft-filter-panel-label{font-family:var(--sc-font-family);-webkit-font-smoothing:antialiased;font-size:var(--sc-body-small-bold-font-size);font-weight:var(--sc-body-small-bold-font-weight);line-height:var(--sc-body-small-bold-line-height)}";
9
- const SearchcraftFilterPanelStyle0 = searchcraftFilterPanelModuleCss;
4
+ import { d as defineCustomElement$4 } from './p-54998882.js';
5
+ import { d as defineCustomElement$3 } from './p-4b92ae26.js';
6
+ import { d as defineCustomElement$2 } from './p-1234974c.js';
10
7
 
11
8
  const SearchcraftFilterPanel$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftFilterPanel extends H {
12
9
  constructor() {
13
10
  super();
14
11
  this.__registerHost();
15
- this.searchStore = useSearchcraftStore.getState();
16
- this.items = [];
17
- this.unsubscribe = undefined;
18
- this.lastQuery = undefined;
19
12
  }
13
+ /**
14
+ * The items to filter.
15
+ */
16
+ items = [];
17
+ unsubscribe;
18
+ lastQuery;
19
+ searchStore = useSearchcraftStore.getState();
20
20
  componentDidLoad() {
21
21
  this.unsubscribe = useSearchcraftStore.subscribe((state) => {
22
22
  this.lastQuery = state.query || '';
23
23
  });
24
24
  }
25
25
  disconnectedCallback() {
26
- var _a;
27
- (_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
26
+ this.unsubscribe?.();
28
27
  }
29
28
  handleDateRangeChanged(fieldName, min, max) {
30
29
  const start = new Date(min);
@@ -66,7 +65,7 @@ const SearchcraftFilterPanel$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
66
65
  * Iterate through `items` and render them based on `type`
67
66
  */
68
67
  render() {
69
- return (h("div", { key: '43bb83b1616c00f46727c7baff2cbc013f88e111', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
68
+ return (h("div", { key: '9b9fcc79913da68b49909965eb75f9a5b1701acb', class: 'searchcraft-filter-panel' }, this.items.map((filterItem) => {
70
69
  switch (filterItem.type) {
71
70
  case 'dateRange': {
72
71
  const item = filterItem;
@@ -107,7 +106,6 @@ const SearchcraftFilterPanel$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
107
106
  }
108
107
  })));
109
108
  }
110
- static get style() { return SearchcraftFilterPanelStyle0; }
111
109
  }, [0, "searchcraft-filter-panel", {
112
110
  "items": [16],
113
111
  "unsubscribe": [32],