@searchcraft/javascript-sdk 0.15.0 → 0.16.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 (75) hide show
  1. package/dist/components/defineCustomElements.js +24 -24
  2. package/dist/components/index.d.ts +130 -47
  3. package/dist/components/index.js +29 -29
  4. package/dist/components/safeUrl.js +378 -0
  5. package/dist/components/safeUrl.js.map +1 -0
  6. package/dist/components/searchcraft-ad.js +1 -1
  7. package/dist/components/searchcraft-ad2.js +6 -5
  8. package/dist/components/searchcraft-ad2.js.map +1 -1
  9. package/dist/components/searchcraft-button.js +1 -1
  10. package/dist/components/searchcraft-button2.js +2 -2
  11. package/dist/components/searchcraft-error-message.js +1 -1
  12. package/dist/components/searchcraft-error-message2.js +1 -1
  13. package/dist/components/searchcraft-facet-list.js +1 -1
  14. package/dist/components/searchcraft-facet-list2.js +2 -2
  15. package/dist/components/searchcraft-filter-panel.js +5 -5
  16. package/dist/components/searchcraft-input-form.js +1 -1
  17. package/dist/components/searchcraft-input-form2.js +23 -9
  18. package/dist/components/searchcraft-input-form2.js.map +1 -1
  19. package/dist/components/searchcraft-input-label.js +1 -1
  20. package/dist/components/searchcraft-input-label2.js +2 -2
  21. package/dist/components/searchcraft-loading.js +1 -1
  22. package/dist/components/searchcraft-loading2.js +1 -1
  23. package/dist/components/searchcraft-pagination.js +4 -4
  24. package/dist/components/searchcraft-popover-button.js +17 -6
  25. package/dist/components/searchcraft-popover-button.js.map +1 -1
  26. package/dist/components/searchcraft-popover-footer.js +1 -1
  27. package/dist/components/searchcraft-popover-footer2.js +5 -5
  28. package/dist/components/searchcraft-popover-footer2.js.map +1 -1
  29. package/dist/components/searchcraft-popover-form.js +106 -21
  30. package/dist/components/searchcraft-popover-form.js.map +1 -1
  31. package/dist/components/searchcraft-popover-list-item.js +1 -1
  32. package/dist/components/searchcraft-popover-list-item2.js +71 -10
  33. package/dist/components/searchcraft-popover-list-item2.js.map +1 -1
  34. package/dist/components/searchcraft-popover-list-view.js +1 -1
  35. package/dist/components/searchcraft-popover-list-view2.js +13 -8
  36. package/dist/components/searchcraft-popover-list-view2.js.map +1 -1
  37. package/dist/components/searchcraft-results-info.js +5 -5
  38. package/dist/components/searchcraft-results-info.js.map +1 -1
  39. package/dist/components/searchcraft-results-summary.js +1 -1
  40. package/dist/components/searchcraft-results-summary2.js +10 -9
  41. package/dist/components/searchcraft-results-summary2.js.map +1 -1
  42. package/dist/components/searchcraft-search-result.js +1 -1
  43. package/dist/components/searchcraft-search-result2.js +4 -3
  44. package/dist/components/searchcraft-search-result2.js.map +1 -1
  45. package/dist/components/searchcraft-search-results-per-page.js +3 -3
  46. package/dist/components/searchcraft-search-results.js +35 -18
  47. package/dist/components/searchcraft-search-results.js.map +1 -1
  48. package/dist/components/searchcraft-select.js +1 -1
  49. package/dist/components/searchcraft-select2.js +1 -1
  50. package/dist/components/searchcraft-slider.js +1 -1
  51. package/dist/components/searchcraft-slider2.js +5 -5
  52. package/dist/components/searchcraft-summary-box.js +6 -6
  53. package/dist/components/searchcraft-theme.js +3 -3
  54. package/dist/components/searchcraft-theme.js.map +1 -1
  55. package/dist/components/searchcraft-toggle-button.js +1 -1
  56. package/dist/components/searchcraft-toggle-button2.js +5 -5
  57. package/dist/hydrate/index.js +611 -57
  58. package/dist/hydrate/index.mjs +611 -57
  59. package/dist/themes/hologram.css +1 -1
  60. package/dist/themes/hologram.css.map +1 -1
  61. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +7 -0
  62. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +8 -0
  63. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +39 -1
  64. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +22 -1
  65. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +5 -1
  66. package/dist/types/components/searchcraft-results-summary/searchcraft-results-summary.d.ts +2 -2
  67. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +14 -8
  68. package/dist/types/components.d.ts +92 -36
  69. package/dist/types/types/sdk-types/templates.types.d.ts +40 -13
  70. package/dist/types/utils/html.d.ts +22 -0
  71. package/dist/types/utils/index.d.ts +1 -0
  72. package/dist/types/utils/safeUrl.d.ts +17 -0
  73. package/package.json +7 -5
  74. package/dist/components/html.js +0 -18
  75. package/dist/components/html.js.map +0 -1
@@ -1,16 +1,18 @@
1
- import { p as proxyCustomElement, H, h, t as transformTag } from './index2.js?scv=0.15.0';
2
- import { r as registry } from './CoreInstanceRegistry.js?scv=0.15.0';
3
- import { c as classNames } from './index3.js?scv=0.15.0';
4
- import { d as defineCustomElement$b } from './searchcraft-ad2.js?scv=0.15.0';
5
- import { d as defineCustomElement$a } from './searchcraft-button2.js?scv=0.15.0';
6
- import { d as defineCustomElement$9 } from './searchcraft-error-message2.js?scv=0.15.0';
7
- import { d as defineCustomElement$8 } from './searchcraft-input-form2.js?scv=0.15.0';
8
- import { d as defineCustomElement$7 } from './searchcraft-input-label2.js?scv=0.15.0';
9
- import { d as defineCustomElement$6 } from './searchcraft-loading2.js?scv=0.15.0';
10
- import { d as defineCustomElement$5 } from './searchcraft-popover-footer2.js?scv=0.15.0';
11
- import { d as defineCustomElement$4 } from './searchcraft-popover-list-item2.js?scv=0.15.0';
12
- import { d as defineCustomElement$3 } from './searchcraft-popover-list-view2.js?scv=0.15.0';
13
- import { d as defineCustomElement$2 } from './searchcraft-results-summary2.js?scv=0.15.0';
1
+ import { p as proxyCustomElement, H, h, t as transformTag } from './index2.js?scv=0.16.0';
2
+ import { r as registry } from './CoreInstanceRegistry.js?scv=0.16.0';
3
+ import { s as safeUrl, h as html } from './safeUrl.js?scv=0.16.0';
4
+ import { c as classNames } from './index3.js?scv=0.16.0';
5
+ import { p as purify } from './purify.es.js?scv=0.16.0';
6
+ import { d as defineCustomElement$b } from './searchcraft-ad2.js?scv=0.16.0';
7
+ import { d as defineCustomElement$a } from './searchcraft-button2.js?scv=0.16.0';
8
+ import { d as defineCustomElement$9 } from './searchcraft-error-message2.js?scv=0.16.0';
9
+ import { d as defineCustomElement$8 } from './searchcraft-input-form2.js?scv=0.16.0';
10
+ import { d as defineCustomElement$7 } from './searchcraft-input-label2.js?scv=0.16.0';
11
+ import { d as defineCustomElement$6 } from './searchcraft-loading2.js?scv=0.16.0';
12
+ import { d as defineCustomElement$5 } from './searchcraft-popover-footer2.js?scv=0.16.0';
13
+ import { d as defineCustomElement$4 } from './searchcraft-popover-list-item2.js?scv=0.16.0';
14
+ import { d as defineCustomElement$3 } from './searchcraft-popover-list-view2.js?scv=0.16.0';
15
+ import { d as defineCustomElement$2 } from './searchcraft-results-summary2.js?scv=0.16.0';
14
16
 
15
17
  const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverForm extends H {
16
18
  constructor(registerHost) {
@@ -30,6 +32,19 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
30
32
  * Formats the content rendered for each result.
31
33
  */
32
34
  popoverResultMappings;
35
+ /**
36
+ * A callback function responsible for rendering a result. When provided, it is used instead of `popoverResultMappings`.
37
+ * Pass URLs from the result through the `safeUrl` helper before placing them in an `href` or `src`.
38
+ * Never place result values in event handler attributes such as `onclick`, or in `style`.
39
+ */
40
+ template;
41
+ /**
42
+ * A callback function responsible for rendering the message shown when a search returns no results.
43
+ * When it is not provided, the popover shows `No results found for "<search term>".`
44
+ * The returned markup is sanitized with DOMPurify, which removes scripts, event handler
45
+ * attributes such as `onclick`, and links with schemes it does not allow, such as an app's own scheme.
46
+ */
47
+ noResultsTemplate;
33
48
  /**
34
49
  * The hotkey that activates the popover.
35
50
  */
@@ -77,6 +92,11 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
77
92
  searchClientResponseItems = [];
78
93
  adClientResponseItems = [];
79
94
  searchTerm;
95
+ isSearchInProgress = false;
96
+ /**
97
+ * The search term of the most recent search response.
98
+ */
99
+ completedSearchTerm;
80
100
  isFocused = false;
81
101
  breakpointSm = 576;
82
102
  breakpointMd = 768;
@@ -108,6 +128,12 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
108
128
  this.searchClientResponseItems = [...state.searchClientResponseItems];
109
129
  this.adClientResponseItems = [...state.adClientResponseItems];
110
130
  this.searchTerm = state.searchTerm;
131
+ this.isSearchInProgress = state.isSearchInProgress;
132
+ const requestProperties = state.searchClientRequestProperties;
133
+ this.completedSearchTerm =
134
+ requestProperties && typeof requestProperties === 'object'
135
+ ? requestProperties.searchTerm
136
+ : undefined;
111
137
  this.searchResultsPage = state.searchResultsPage;
112
138
  this.searchResultsPerPage = state.searchResultsPerPage;
113
139
  });
@@ -189,6 +215,8 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
189
215
  if (!this.modalElement) {
190
216
  this.modalElement = document.createElement('searchcraft-popover-form');
191
217
  this.modalElement.popoverResultMappings = this.popoverResultMappings;
218
+ this.modalElement.template = this.template;
219
+ this.modalElement.noResultsTemplate = this.noResultsTemplate;
192
220
  this.modalElement.setAttribute('type', 'fullscreen');
193
221
  this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);
194
222
  if (this.placeholderValue) {
@@ -207,6 +235,17 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
207
235
  }
208
236
  }
209
237
  }
238
+ /**
239
+ * Passes result rendering changes on to the fullscreen form created for small viewports,
240
+ * which only receives these props when it is first created.
241
+ */
242
+ syncModalElementResultRendering() {
243
+ if (this.modalElement) {
244
+ this.modalElement.popoverResultMappings = this.popoverResultMappings;
245
+ this.modalElement.template = this.template;
246
+ this.modalElement.noResultsTemplate = this.noResultsTemplate;
247
+ }
248
+ }
210
249
  handleModalBackdropClick(_event) {
211
250
  this.core?.store.getState().setPopoverVisibility(false);
212
251
  }
@@ -240,8 +279,17 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
240
279
  * @param direction
241
280
  */
242
281
  focusOnNextListItem(direction) {
243
- const listItems = Array.from(document.querySelectorAll('.searchcraft-popover-list-item-link')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
244
- const currentIndex = listItems.indexOf(document.activeElement);
282
+ // Results rendered by a `template` are reached through the first link in the template.
283
+ const links = Array.from(document.querySelectorAll('.searchcraft-popover-list-item-link, .searchcraft-popover-list-item-template')).map((el) => el.classList.contains('searchcraft-popover-list-item-template')
284
+ ? el.querySelector('a')
285
+ : el);
286
+ const listItems = Array.from(new Set(links)).filter((el) => !!el && !el.hasAttribute('disabled') && el.offsetParent !== null);
287
+ // Focus may be on another link inside a templated result, so match on the result too.
288
+ const activeElement = document.activeElement;
289
+ const currentIndex = listItems.findIndex((el) => el === activeElement ||
290
+ !!el
291
+ .closest('.searchcraft-popover-list-item-template')
292
+ ?.contains(activeElement));
245
293
  if (direction === 'ArrowDown') {
246
294
  listItems[(currentIndex + 1) % listItems.length]?.focus();
247
295
  }
@@ -266,6 +314,28 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
266
314
  this.searchTerm?.trim()?.length > 0 &&
267
315
  this.searchClientResponseItems.length > 0);
268
316
  }
317
+ /**
318
+ * Whether the search for the current search term finished without results.
319
+ */
320
+ get hasNoResultsToShow() {
321
+ const searchTerm = this.searchTerm?.trim();
322
+ return (!!searchTerm &&
323
+ !this.isSearchInProgress &&
324
+ this.searchClientResponseItems.length === 0 &&
325
+ this.completedSearchTerm?.trim() === searchTerm);
326
+ }
327
+ renderNoResults() {
328
+ const searchTerm = this.searchTerm?.trim() || '';
329
+ if (this.noResultsTemplate) {
330
+ try {
331
+ return (h("div", { class: 'searchcraft-popover-form-no-results', innerHTML: purify.sanitize(this.noResultsTemplate({ searchTerm }, { html, safeUrl })) }));
332
+ }
333
+ catch (error) {
334
+ console.error('Invalid popover no results template:', error);
335
+ }
336
+ }
337
+ return (h("div", { class: 'searchcraft-popover-form-no-results' }, h("p", { class: 'searchcraft-popover-form-no-results-message' }, "No results found for \"", searchTerm, "\".")));
338
+ }
269
339
  get viewAllResultsHref() {
270
340
  const baseUrl = this.viewAllResultsBaseUrl;
271
341
  if (!baseUrl) {
@@ -291,22 +361,24 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
291
361
  }
292
362
  renderInlinePopover() {
293
363
  const isListViewVisible = this.hasResultsToShow && this.isFocused;
364
+ const isNoResultsVisible = this.hasNoResultsToShow && this.isFocused;
365
+ const isDropdownVisible = isListViewVisible || isNoResultsVisible;
294
366
  return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
295
- 'searchcraft-popover-form-active': isListViewVisible,
296
- }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-inline-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior })), isListViewVisible && (h("div", { class: 'searchcraft-popover-form-inline-wrapper' }, this.showSummaryBox && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel })))));
367
+ 'searchcraft-popover-form-active': isDropdownVisible,
368
+ }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-inline-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior })), isDropdownVisible && (h("div", { class: 'searchcraft-popover-form-inline-wrapper' }, h("div", { class: 'searchcraft-popover-form-inline-scroll-area' }, isListViewVisible && this.showSummaryBox && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), isListViewVisible ? (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, template: this.template, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId })) : (this.renderNoResults())), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel })))));
297
369
  }
298
370
  renderModalPopover() {
299
371
  if (this.isPopoverVisibleInState) {
300
372
  return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
301
- 'searchcraft-popover-form-active': this.hasResultsToShow,
302
- }) }, h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), h("div", { class: 'searchcraft-popover-form-modal-wrapper' }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-modal-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), h("div", { class: 'searchcraft-popover-form-modal-popover-list-view' }, this.showSummaryBox && this.hasResultsToShow && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel }))));
373
+ 'searchcraft-popover-form-active': this.hasResultsToShow || this.hasNoResultsToShow,
374
+ }) }, h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), h("div", { class: 'searchcraft-popover-form-modal-wrapper' }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-modal-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), h("div", { class: 'searchcraft-popover-form-modal-popover-list-view' }, this.showSummaryBox && this.hasResultsToShow && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, template: this.template, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId })), this.hasNoResultsToShow && this.renderNoResults()), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel }))));
303
375
  }
304
376
  }
305
377
  renderFullscreenPopover() {
306
378
  if (this.isPopoverVisibleInState) {
307
379
  return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
308
- 'searchcraft-popover-form-active': this.hasResultsToShow,
309
- }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), h("div", { class: 'searchcraft-popover-form-fullscreen-popover-list-view' }, this.showSummaryBox && this.hasResultsToShow && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId }))), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel })));
380
+ 'searchcraft-popover-form-active': this.hasResultsToShow || this.hasNoResultsToShow,
381
+ }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this), searchcraftId: this.searchcraftId, placeholderValue: this.placeholderValue, placeholderBehavior: this.placeholderBehavior }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), h("div", { class: 'searchcraft-popover-form-fullscreen-popover-list-view' }, this.showSummaryBox && this.hasResultsToShow && (h("searchcraft-results-summary", { searchcraftId: this.searchcraftId })), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, template: this.template, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage, searchcraftId: this.searchcraftId })), this.hasNoResultsToShow && this.renderNoResults()), h("searchcraft-popover-footer", { searchcraftId: this.searchcraftId, sdkVariant: this.sdkVariant, viewAllResultsHref: this.viewAllResultsHref, viewAllResultsLabel: this.resolvedViewAllResultsLabel })));
310
382
  }
311
383
  }
312
384
  render() {
@@ -319,9 +391,16 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
319
391
  return this.renderFullscreenPopover();
320
392
  }
321
393
  }
394
+ static get watchers() { return {
395
+ "popoverResultMappings": ["syncModalElementResultRendering"],
396
+ "template": ["syncModalElementResultRendering"],
397
+ "noResultsTemplate": ["syncModalElementResultRendering"]
398
+ }; }
322
399
  }, [768, "searchcraft-popover-form", {
323
400
  "type": [1],
324
401
  "popoverResultMappings": [16],
402
+ "template": [16],
403
+ "noResultsTemplate": [16],
325
404
  "hotkey": [1],
326
405
  "hotkeyModifier": [1, "hotkey-modifier"],
327
406
  "searchcraftId": [1, "searchcraft-id"],
@@ -335,6 +414,8 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
335
414
  "searchClientResponseItems": [32],
336
415
  "adClientResponseItems": [32],
337
416
  "searchTerm": [32],
417
+ "isSearchInProgress": [32],
418
+ "completedSearchTerm": [32],
338
419
  "isFocused": [32],
339
420
  "breakpointSm": [32],
340
421
  "breakpointMd": [32],
@@ -342,6 +423,10 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
342
423
  "searchResultsPage": [32],
343
424
  "searchResultsPerPage": [32],
344
425
  "modalElement": [32]
426
+ }, undefined, {
427
+ "popoverResultMappings": ["syncModalElementResultRendering"],
428
+ "template": ["syncModalElementResultRendering"],
429
+ "noResultsTemplate": ["syncModalElementResultRendering"]
345
430
  }]);
346
431
  function defineCustomElement$1() {
347
432
  if (typeof customElements === "undefined") {
@@ -1 +1 @@
1
- {"file":"searchcraft-popover-form.js","mappings":";;;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AAI,CAAC,mBAAmB,EAAE;AACnC,YAAA,KAAK,OAAO;AACV,gBAAA,OAAO,IAAI,CAAC,kBAAkB,EAAE;AAClC,YAAA,KAAK,YAAY;AACf,gBAAA,OAAO,IAAI,CAAC,uBAAuB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm","__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, Element, Prop, State, h } from '@stencil/core';\nimport type {\n AdClientResponseItem,\n PopoverResultMappings,\n SearchClientResponseItem,\n} from '@types';\nimport classNames from 'classnames';\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 * @react-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"inline\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.popoverResultMappings = {};\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" popoverResultMappings={[]} />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" :popoverResultMappings=\"[]\"\" />\n * ```\n *\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The type of popover form to render.\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;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey?: string = '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 * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue?: string = 'Enter Search';\n /**\n * The placeholder's render behavior.\n * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.\n * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.\n */\n @Prop() placeholderBehavior?: 'hide-on-focus' | 'hide-on-text-entered';\n /**\n * Base URL for the \"View all\" footer link. The current search term will be appended (URL encoded).\n *\n * For example, in a CMS-backed site you might set this to `/?s=` so the final URL becomes `/?s=<search-term>`.\n */\n @Prop() viewAllResultsBaseUrl?: string;\n /**\n * Optional label for the \"View All\" footer button. Defaults to \"View All\".\n */\n @Prop() viewAllResultsLabel?: string;\n /**\n * Whether to display the AI generative summary box before the search results.\n * NOTE: This requires the usage of a read key that has \"SUMMARY\" permissions and either a subscription to Searchcraft Cloud with AI features enabled or a self-hosted model connected.\n */\n @Prop() showSummaryBox?: boolean = false;\n /**\n * The SDK variant used to render this component. Used for UTM attribution on the footer link.\n *\n * @internal\n */\n @Prop() sdkVariant?: 'js' | 'react' | 'vue' = 'js';\n\n @State() isPopoverVisibleInState = false;\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 private unsubscribe: (() => void) | undefined;\n private cleanupCore?: () => void;\n core?: SearchcraftCore;\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\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 = core.store.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 = core.store.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 // Set hotkey and hotkeyModifier in state.\n core.store\n .getState()\n .setHotKeyAndHotKeyModifier(this.hotkey, this.hotkeyModifier);\n }\n\n connectedCallback() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\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 this.core?.store.getState().setPopoverVisibility(false);\n break;\n case 'Enter':\n if (\n (event.metaKey || event.ctrlKey) &&\n this.viewAllResultsHref &&\n this.hasResultsToShow\n ) {\n event.preventDefault();\n this.navigateToViewAllResults();\n }\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector(\n '.searchcraft-input-form-input',\n ) as HTMLInputElement | 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 this.core?.store.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.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);\n if (this.placeholderValue) {\n this.modalElement.setAttribute(\n 'placeholder-value',\n this.placeholderValue,\n );\n }\n if (this.placeholderBehavior) {\n this.modalElement.setAttribute(\n 'placeholder-behavior',\n this.placeholderBehavior,\n );\n }\n if (this.viewAllResultsBaseUrl) {\n this.modalElement.setAttribute(\n 'view-all-results-base-url',\n this.viewAllResultsBaseUrl,\n );\n }\n if (this.viewAllResultsLabel) {\n this.modalElement.setAttribute(\n 'view-all-results-label',\n this.viewAllResultsLabel,\n );\n }\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n this.core?.store.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-form-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n this.core?.store\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n this.core?.store.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 '.searchcraft-popover-list-item-link',\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-form-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 get viewAllResultsHref() {\n const baseUrl = this.viewAllResultsBaseUrl;\n if (!baseUrl) {\n return undefined;\n }\n\n const term = this.searchTerm?.trim();\n if (!term) {\n return baseUrl;\n }\n\n return `${baseUrl}${encodeURIComponent(term).replace(/%20/g, '+')}`;\n }\n\n get resolvedViewAllResultsLabel() {\n return this.viewAllResultsLabel ?? 'View All';\n }\n\n navigateToViewAllResults() {\n const href = this.viewAllResultsHref;\n\n if (!href || !this.hasResultsToShow) {\n return;\n }\n\n if (typeof window !== 'undefined') {\n window.location.href = href;\n }\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-inline-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n </div>\n {isListViewVisible && (\n <div class='searchcraft-popover-form-inline-wrapper'>\n {this.showSummaryBox && (\n <searchcraft-results-summary searchcraftId={this.searchcraftId} />\n )}\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 searchcraftId={this.searchcraftId}\n />\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-modal',\n {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n },\n )}\n >\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-wrapper'>\n <div class='searchcraft-popover-form-input searchcraft-popover-form-modal-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n <div class='searchcraft-popover-form-modal-popover-list-view'>\n {this.showSummaryBox && this.hasResultsToShow && (\n <searchcraft-results-summary\n searchcraftId={this.searchcraftId}\n />\n )}\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 searchcraftId={this.searchcraftId}\n />\n )}\n </div>\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-fullscreen',\n {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n <div class='searchcraft-popover-form-fullscreen-popover-list-view'>\n {this.showSummaryBox && this.hasResultsToShow && (\n <searchcraft-results-summary searchcraftId={this.searchcraftId} />\n )}\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 searchcraftId={this.searchcraftId}\n />\n )}\n </div>\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\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
+ {"file":"searchcraft-popover-form.js","mappings":";;;;;;;;;;;;;;;;MAkEaA,wBAAsB,iBAAAC,kBAAA,CAAA,MAAA,sBAAA,SAAAC,CAAA,CAAA;;;;;;;AACjC;;;;;AAKG;IACK,IAAI,GAAuC,QAAQ;AAC3D;;AAEG;AACK,IAAA,qBAAqB;AAC7B;;;;AAIG;AACK,IAAA,QAAQ;AAChB;;;;;AAKG;AACK,IAAA,iBAAiB;AACzB;;AAEG;IACK,MAAM,GAAY,GAAG;AAC7B;;AAEG;IACK,cAAc,GAAwC,MAAM;AACpE;;AAEG;AACK,IAAA,aAAa;AACrB;;AAEG;IACK,gBAAgB,GAAY,cAAc;AAClD;;;;AAIG;AACK,IAA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;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm","__stencil_proxyCustomElement","HTMLElement","DOMPurify"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, Element, Prop, State, Watch, h } from '@stencil/core';\nimport type {\n AdClientResponseItem,\n PopoverNoResultsTemplate,\n PopoverResultMappings,\n SearchClientResponseItem,\n SearchResultTemplate,\n SearchResultTemplateData,\n} from '@types';\nimport { html, safeUrl } from '@utils';\nimport classNames from 'classnames';\nimport DOMPurify from 'dompurify';\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 * @react-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"inline\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.popoverResultMappings = {};\n *\n * // Or render each result with a template instead of `popoverResultMappings`.\n * popoverForm.template = (item, index, { html, safeUrl }) => html`\n * <a href=\"${safeUrl(item.url)}\">${item.title}</a>\n * `;\n *\n * // Change the message shown when a search returns no results.\n * popoverForm.noResultsTemplate = ({ searchTerm }, { html }) => html`\n * <p>Nothing matched \"${searchTerm}\".</p>\n * `;\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" popoverResultMappings={[]} />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" :popoverResultMappings=\"[]\"\" />\n * ```\n *\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The type of popover form to render.\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;\n /**\n * A callback function responsible for rendering a result. When provided, it is used instead of `popoverResultMappings`.\n * Pass URLs from the result through the `safeUrl` helper before placing them in an `href` or `src`.\n * Never place result values in event handler attributes such as `onclick`, or in `style`.\n */\n @Prop() template?: SearchResultTemplate<SearchResultTemplateData>;\n /**\n * A callback function responsible for rendering the message shown when a search returns no results.\n * When it is not provided, the popover shows `No results found for \"<search term>\".`\n * The returned markup is sanitized with DOMPurify, which removes scripts, event handler\n * attributes such as `onclick`, and links with schemes it does not allow, such as an app's own scheme.\n */\n @Prop() noResultsTemplate?: PopoverNoResultsTemplate;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey?: string = '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 * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue?: string = 'Enter Search';\n /**\n * The placeholder's render behavior.\n * 'hide-on-focus' - Hide the placeholder text immediately when the input form gains focus.\n * 'hide-on-text-entered' - Only hide the placeholder when the input form has text entered into it.\n */\n @Prop() placeholderBehavior?: 'hide-on-focus' | 'hide-on-text-entered';\n /**\n * Base URL for the \"View all\" footer link. The current search term will be appended (URL encoded).\n *\n * For example, in a CMS-backed site you might set this to `/?s=` so the final URL becomes `/?s=<search-term>`.\n */\n @Prop() viewAllResultsBaseUrl?: string;\n /**\n * Optional label for the \"View All\" footer button. Defaults to \"View All\".\n */\n @Prop() viewAllResultsLabel?: string;\n /**\n * Whether to display the AI generative summary box before the search results.\n * NOTE: This requires the usage of a read key that has \"SUMMARY\" permissions and either a subscription to Searchcraft Cloud with AI features enabled or a self-hosted model connected.\n */\n @Prop() showSummaryBox?: boolean = false;\n /**\n * The SDK variant used to render this component. Used for UTM attribution on the footer link.\n *\n * @internal\n */\n @Prop() sdkVariant?: 'js' | 'react' | 'vue' = 'js';\n\n @State() isPopoverVisibleInState = false;\n @State() searchClientResponseItems: SearchClientResponseItem[] = [];\n @State() adClientResponseItems: AdClientResponseItem[] = [];\n @State() searchTerm: string | undefined;\n @State() isSearchInProgress = false;\n /**\n * The search term of the most recent search response.\n */\n @State() completedSearchTerm: 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 private unsubscribe: (() => void) | undefined;\n private cleanupCore?: () => void;\n core?: SearchcraftCore;\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\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 = core.store.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 = core.store.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.isSearchInProgress = state.isSearchInProgress;\n const requestProperties = state.searchClientRequestProperties;\n this.completedSearchTerm =\n requestProperties && typeof requestProperties === 'object'\n ? requestProperties.searchTerm\n : undefined;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n });\n\n // Set hotkey and hotkeyModifier in state.\n core.store\n .getState()\n .setHotKeyAndHotKeyModifier(this.hotkey, this.hotkeyModifier);\n }\n\n connectedCallback() {\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n this.cleanupCore?.();\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 this.core?.store.getState().setPopoverVisibility(false);\n break;\n case 'Enter':\n if (\n (event.metaKey || event.ctrlKey) &&\n this.viewAllResultsHref &&\n this.hasResultsToShow\n ) {\n event.preventDefault();\n this.navigateToViewAllResults();\n }\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector(\n '.searchcraft-input-form-input',\n ) as HTMLInputElement | 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 this.core?.store.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.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.template = this.template;\n this.modalElement.noResultsTemplate = this.noResultsTemplate;\n this.modalElement.setAttribute('type', 'fullscreen');\n this.modalElement.setAttribute('searchcraft-id', this.searchcraftId);\n if (this.placeholderValue) {\n this.modalElement.setAttribute(\n 'placeholder-value',\n this.placeholderValue,\n );\n }\n if (this.placeholderBehavior) {\n this.modalElement.setAttribute(\n 'placeholder-behavior',\n this.placeholderBehavior,\n );\n }\n if (this.viewAllResultsBaseUrl) {\n this.modalElement.setAttribute(\n 'view-all-results-base-url',\n this.viewAllResultsBaseUrl,\n );\n }\n if (this.viewAllResultsLabel) {\n this.modalElement.setAttribute(\n 'view-all-results-label',\n this.viewAllResultsLabel,\n );\n }\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n /**\n * Passes result rendering changes on to the fullscreen form created for small viewports,\n * which only receives these props when it is first created.\n */\n @Watch('popoverResultMappings')\n @Watch('template')\n @Watch('noResultsTemplate')\n syncModalElementResultRendering() {\n if (this.modalElement) {\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.template = this.template;\n this.modalElement.noResultsTemplate = this.noResultsTemplate;\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n this.core?.store.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-form-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n this.core?.store\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n this.core?.store.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 // Results rendered by a `template` are reached through the first link in the template.\n const links = Array.from(\n document.querySelectorAll<HTMLElement>(\n '.searchcraft-popover-list-item-link, .searchcraft-popover-list-item-template',\n ),\n ).map((el) =>\n el.classList.contains('searchcraft-popover-list-item-template')\n ? el.querySelector('a')\n : el,\n );\n const listItems = Array.from(new Set(links)).filter(\n (el): el is HTMLAnchorElement =>\n !!el && !el.hasAttribute('disabled') && el.offsetParent !== null,\n );\n\n // Focus may be on another link inside a templated result, so match on the result too.\n const activeElement = document.activeElement;\n const currentIndex = listItems.findIndex(\n (el) =>\n el === activeElement ||\n !!el\n .closest('.searchcraft-popover-list-item-template')\n ?.contains(activeElement),\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-form-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 /**\n * Whether the search for the current search term finished without results.\n */\n get hasNoResultsToShow() {\n const searchTerm = this.searchTerm?.trim();\n\n return (\n !!searchTerm &&\n !this.isSearchInProgress &&\n this.searchClientResponseItems.length === 0 &&\n this.completedSearchTerm?.trim() === searchTerm\n );\n }\n\n renderNoResults() {\n const searchTerm = this.searchTerm?.trim() || '';\n\n if (this.noResultsTemplate) {\n try {\n return (\n <div\n class='searchcraft-popover-form-no-results'\n innerHTML={DOMPurify.sanitize(\n this.noResultsTemplate({ searchTerm }, { html, safeUrl }),\n )}\n />\n );\n } catch (error) {\n console.error('Invalid popover no results template:', error);\n }\n }\n\n return (\n <div class='searchcraft-popover-form-no-results'>\n <p class='searchcraft-popover-form-no-results-message'>\n No results found for \"{searchTerm}\".\n </p>\n </div>\n );\n }\n\n get viewAllResultsHref() {\n const baseUrl = this.viewAllResultsBaseUrl;\n if (!baseUrl) {\n return undefined;\n }\n\n const term = this.searchTerm?.trim();\n if (!term) {\n return baseUrl;\n }\n\n return `${baseUrl}${encodeURIComponent(term).replace(/%20/g, '+')}`;\n }\n\n get resolvedViewAllResultsLabel() {\n return this.viewAllResultsLabel ?? 'View All';\n }\n\n navigateToViewAllResults() {\n const href = this.viewAllResultsHref;\n\n if (!href || !this.hasResultsToShow) {\n return;\n }\n\n if (typeof window !== 'undefined') {\n window.location.href = href;\n }\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n const isNoResultsVisible = this.hasNoResultsToShow && this.isFocused;\n const isDropdownVisible = isListViewVisible || isNoResultsVisible;\n\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isDropdownVisible,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-inline-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n </div>\n {isDropdownVisible && (\n <div class='searchcraft-popover-form-inline-wrapper'>\n <div class='searchcraft-popover-form-inline-scroll-area'>\n {isListViewVisible && this.showSummaryBox && (\n <searchcraft-results-summary\n searchcraftId={this.searchcraftId}\n />\n )}\n {isListViewVisible ? (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n template={this.template}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n searchcraftId={this.searchcraftId}\n />\n ) : (\n this.renderNoResults()\n )}\n </div>\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-modal',\n {\n 'searchcraft-popover-form-active':\n this.hasResultsToShow || this.hasNoResultsToShow,\n },\n )}\n >\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-wrapper'>\n <div class='searchcraft-popover-form-input searchcraft-popover-form-modal-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button searchcraft-popover-form-modal-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n <div class='searchcraft-popover-form-modal-popover-list-view'>\n {this.showSummaryBox && this.hasResultsToShow && (\n <searchcraft-results-summary\n searchcraftId={this.searchcraftId}\n />\n )}\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n template={this.template}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n searchcraftId={this.searchcraftId}\n />\n )}\n {this.hasNoResultsToShow && this.renderNoResults()}\n </div>\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-fullscreen',\n {\n 'searchcraft-popover-form-active':\n this.hasResultsToShow || this.hasNoResultsToShow,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n searchcraftId={this.searchcraftId}\n placeholderValue={this.placeholderValue}\n placeholderBehavior={this.placeholderBehavior}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button searchcraft-popover-form-fullscreen-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n <div class='searchcraft-popover-form-fullscreen-popover-list-view'>\n {this.showSummaryBox && this.hasResultsToShow && (\n <searchcraft-results-summary searchcraftId={this.searchcraftId} />\n )}\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n template={this.template}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n searchcraftId={this.searchcraftId}\n />\n )}\n {this.hasNoResultsToShow && this.renderNoResults()}\n </div>\n <searchcraft-popover-footer\n searchcraftId={this.searchcraftId}\n sdkVariant={this.sdkVariant}\n viewAllResultsHref={this.viewAllResultsHref}\n viewAllResultsLabel={this.resolvedViewAllResultsLabel}\n />\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,4 +1,4 @@
1
- import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './searchcraft-popover-list-item2.js?scv=0.15.0';
1
+ import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './searchcraft-popover-list-item2.js?scv=0.16.0';
2
2
 
3
3
  const SearchcraftPopoverListItem = SearchcraftPopoverListItem$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,7 +1,7 @@
1
- import { p as proxyCustomElement, H, h, t as transformTag } from './index2.js?scv=0.15.0';
2
- import { r as registry } from './CoreInstanceRegistry.js?scv=0.15.0';
3
- import { g as getDocumentValueFromSearchResultMapping } from './units.js?scv=0.15.0';
4
- import './purify.es.js';
1
+ import { p as proxyCustomElement, H, h, t as transformTag } from './index2.js?scv=0.16.0';
2
+ import { r as registry } from './CoreInstanceRegistry.js?scv=0.16.0';
3
+ import { g as getDocumentValueFromSearchResultMapping } from './units.js?scv=0.16.0';
4
+ import { s as safeUrl, h as html } from './safeUrl.js?scv=0.16.0';
5
5
 
6
6
  const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverListItem extends H {
7
7
  constructor(registerHost) {
@@ -12,6 +12,14 @@ const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class Search
12
12
  }
13
13
  item;
14
14
  popoverResultMappings;
15
+ /**
16
+ * A callback function responsible for rendering the result. When provided, it is used instead of `popoverResultMappings`, which are still used if the template throws.
17
+ */
18
+ template;
19
+ /**
20
+ * The index of the result in the list view. Passed to the `template` callback.
21
+ */
22
+ index = 0;
15
23
  /** The document position relative to the search results (For Measure) */
16
24
  documentPosition = 0;
17
25
  /**
@@ -23,6 +31,8 @@ const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class Search
23
31
  href;
24
32
  imageSource;
25
33
  imageAlt;
34
+ templateHtml;
35
+ get hostElement() { return this; }
26
36
  core;
27
37
  cleanupCore;
28
38
  mapValuesFromDocument(document) {
@@ -32,19 +42,40 @@ const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class Search
32
42
  this.imageSource = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageSource);
33
43
  this.imageAlt = getDocumentValueFromSearchResultMapping(document, this.popoverResultMappings?.imageAlt);
34
44
  }
45
+ /**
46
+ * Maps the document values and renders the template, if there is one. The mapped values are
47
+ * always kept so the result can fall back to them if the template throws or is removed.
48
+ */
49
+ updateRenderedValues() {
50
+ this.templateHtml = undefined;
51
+ if (!this.item) {
52
+ return;
53
+ }
54
+ this.mapValuesFromDocument(this.item.document);
55
+ if (this.template) {
56
+ try {
57
+ this.templateHtml = this.template(this.item.document, this.index, {
58
+ html,
59
+ safeUrl,
60
+ source_index: this.item.source_index,
61
+ });
62
+ }
63
+ catch (error) {
64
+ console.error('Invalid popover result template:', error);
65
+ }
66
+ }
67
+ }
35
68
  onCoreAvailable(core) {
36
69
  this.core = core;
37
70
  }
38
71
  connectedCallback() {
39
- if (this.item) {
40
- this.mapValuesFromDocument(this.item.document);
41
- }
72
+ this.updateRenderedValues();
42
73
  this.cleanupCore = registry.useCoreInstance(this.searchcraftId, this.onCoreAvailable.bind(this));
43
74
  }
44
75
  disconnectedCallback() {
45
76
  this.cleanupCore?.();
46
77
  }
47
- handleLinkClick = () => {
78
+ sendDocumentClickedEvent() {
48
79
  if (this.core) {
49
80
  const document_position = this.documentPosition;
50
81
  const search_term = this.core.store.getState().searchTerm;
@@ -55,20 +86,50 @@ const SearchcraftPopoverListItem = /*@__PURE__*/ proxyCustomElement(class Search
55
86
  search_term,
56
87
  });
57
88
  }
89
+ }
90
+ handleLinkClick = () => {
91
+ this.sendDocumentClickedEvent();
92
+ };
93
+ /**
94
+ * Sends the click event when a link inside the rendered template is clicked.
95
+ */
96
+ handleTemplateClick = (event) => {
97
+ const link = event.target?.closest('a');
98
+ if (link && this.hostElement?.contains(link)) {
99
+ this.sendDocumentClickedEvent();
100
+ }
58
101
  };
102
+ handleKeyDown = () => { };
59
103
  render() {
60
- return (h("div", { key: 'd1c9c310b8abc9d2370efb802eac1edf4189519d', class: 'searchcraft-popover-list-item' }, h("a", { key: '30eb1a5076c5b4b95ae43147eaee0bb72ce46179', class: 'searchcraft-popover-list-item-link', href: this.href, onClick: this.handleLinkClick.bind(this) }, this.imageSource && (h("div", { key: 'd18ff55823dc2c61f3786f423936af8b009aeeda', class: 'searchcraft-popover-list-item-image-wrapper' }, h("img", { key: '56f4cc1d472f7da05e64fcf52c560a7ad0cdf7a6', alt: this.imageAlt, src: this.imageSource, class: 'searchcraft-popover-list-item-image' }))), h("div", { key: '78a0f0235d5e71d10076b70ccbaf4b58e0d6fea0', class: 'searchcraft-popover-list-item-content' }, this.title && (h("p", { key: '4489047af56e5aa295cb5f036e970dcad053d3b7', class: 'searchcraft-popover-list-item-content-title' }, this.title)), this.subtitle && (h("p", { key: '4d177c227a1dbf1233022d738403c8eb93ba328d', class: 'searchcraft-popover-list-item-content-subtitle' }, this.subtitle))))));
104
+ if (this.template && typeof this.templateHtml === 'string') {
105
+ return (h("div", { class: 'searchcraft-popover-list-item searchcraft-popover-list-item-template', innerHTML: this.templateHtml, onClick: this.handleTemplateClick, onKeyDown: this.handleKeyDown }));
106
+ }
107
+ return (h("div", { class: 'searchcraft-popover-list-item' }, h("a", { class: 'searchcraft-popover-list-item-link', href: this.href ? safeUrl(this.href) : undefined, onClick: this.handleLinkClick.bind(this) }, this.imageSource && (h("div", { class: 'searchcraft-popover-list-item-image-wrapper' }, h("img", { alt: this.imageAlt, src: this.imageSource, class: 'searchcraft-popover-list-item-image' }))), h("div", { class: 'searchcraft-popover-list-item-content' }, this.title && (h("p", { class: 'searchcraft-popover-list-item-content-title' }, this.title)), this.subtitle && (h("p", { class: 'searchcraft-popover-list-item-content-subtitle' }, this.subtitle))))));
61
108
  }
109
+ static get watchers() { return {
110
+ "item": ["updateRenderedValues"],
111
+ "popoverResultMappings": ["updateRenderedValues"],
112
+ "template": ["updateRenderedValues"],
113
+ "index": ["updateRenderedValues"]
114
+ }; }
62
115
  }, [768, "searchcraft-popover-list-item", {
63
116
  "item": [16],
64
117
  "popoverResultMappings": [16],
118
+ "template": [16],
119
+ "index": [2],
65
120
  "documentPosition": [2, "document-position"],
66
121
  "searchcraftId": [1, "searchcraft-id"],
67
122
  "title": [32],
68
123
  "subtitle": [32],
69
124
  "href": [32],
70
125
  "imageSource": [32],
71
- "imageAlt": [32]
126
+ "imageAlt": [32],
127
+ "templateHtml": [32]
128
+ }, undefined, {
129
+ "item": ["updateRenderedValues"],
130
+ "popoverResultMappings": ["updateRenderedValues"],
131
+ "template": ["updateRenderedValues"],
132
+ "index": ["updateRenderedValues"]
72
133
  }]);
73
134
  function defineCustomElement() {
74
135
  if (typeof customElements === "undefined") {
@@ -1 +1 @@
1
- {"file":"searchcraft-popover-list-item2.js","mappings":";;;;;MAmBa,0BAA0B,iBAAAA,kBAAA,CAAA,MAAA,0BAAA,SAAAC,CAAA,CAAA;;;;;;;AAC7B,IAAA,IAAI;AACJ,IAAA,qBAAqB;;IAErB,gBAAgB,GAAG,CAAC;AAC5B;;AAEG;AACK,IAAA,aAAa;AAEZ,IAAA,KAAK;AACL,IAAA,QAAQ;AACR,IAAA,IAAI;AACJ,IAAA,WAAW;AACX,IAAA,QAAQ;AACjB,IAAA,IAAI;AACI,IAAA,WAAW;AAEnB,IAAA,qBAAqB,CAAC,QAAwB,EAAA;AAC5C,QAAA,IAAI,CAAC,KAAK,GAAG,uCAAuC,CAClD,QAAQ,EACR,IAAI,CAAC,qBAAqB,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;gBAC5D,iBAAiB;gBACjB,mBAAmB;gBACnB,WAAW;AACZ,aAAA,CAAC;;AAEN,KAAC;IAED,MAAM,GAAA;AACJ,QAAA,QACE,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAC,+BAA+B,EAAA,EACxC,CAAA,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,KAAK,EAAC,oCAAoC,EAC1C,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,EAEvC,IAAI,CAAC,WAAW,KACf,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,6CAA6C,EAAA,EACtD,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,KAAK,EAAC,qCAAqC,EAAA,CAC3C,CACE,CACP,EACD,CAAK,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,uCAAuC,EAAA,EAC/C,IAAI,CAAC,KAAK,KACT,CAAG,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,6CAA6C,EACnD,EAAA,IAAI,CAAC,KAAK,CACT,CACL,EACA,IAAI,CAAC,QAAQ,KACZ,CAAG,CAAA,GAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,KAAK,EAAC,gDAAgD,EAAA,EACtD,IAAI,CAAC,QAAQ,CACZ,CACL,CACG,CACJ,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, Prop, State, h } from '@stencil/core';\nimport type {\n PopoverResultMappings,\n SearchClientResponseItem,\n SearchDocument,\n} from '@types';\nimport { getDocumentValueFromSearchResultMapping } from '@utils';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n *\n * @internal\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 * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n\n @State() title?: string;\n @State() subtitle?: string;\n @State() href?: string;\n @State() imageSource?: string;\n @State() imageAlt?: string;\n core?: SearchcraftCore;\n private cleanupCore?: () => void;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.title = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitle = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n this.imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n }\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\n }\n\n connectedCallback() {\n if (this.item) {\n this.mapValuesFromDocument(this.item.document);\n }\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.cleanupCore?.();\n }\n\n handleLinkClick = () => {\n if (this.core) {\n const document_position = this.documentPosition;\n const search_term = this.core.store.getState().searchTerm;\n const number_of_documents =\n this.core.store.getState().searchClientResponseItems.length || 0;\n\n this.core.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n };\n\n render() {\n return (\n <div class='searchcraft-popover-list-item'>\n <a\n class='searchcraft-popover-list-item-link'\n href={this.href}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSource && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSource}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-content'>\n {this.title && (\n <p class='searchcraft-popover-list-item-content-title'>\n {this.title}\n </p>\n )}\n {this.subtitle && (\n <p class='searchcraft-popover-list-item-content-subtitle'>\n {this.subtitle}\n </p>\n )}\n </div>\n </a>\n </div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"searchcraft-popover-list-item2.js","mappings":";;;;;MAqBa,0BAA0B,iBAAAA,kBAAA,CAAA,MAAA,0BAAA,SAAAC,CAAA,CAAA;;;;;;;AAC7B,IAAA,IAAI;AACJ,IAAA,qBAAqB;AAC7B;;AAEG;AACK,IAAA,QAAQ;AAChB;;AAEG;IACK,KAAK,GAAG,CAAC;;IAET,gBAAgB,GAAG,CAAC;AAC5B;;AAEG;AACK,IAAA,aAAa;AAEZ,IAAA,KAAK;AACL,IAAA,QAAQ;AACR,IAAA,IAAI;AACJ,IAAA,WAAW;AACX,IAAA,QAAQ;AACR,IAAA,YAAY;;AAErB,IAAA,IAAI;AACI,IAAA,WAAW;AAEnB,IAAA,qBAAqB,CAAC,QAAwB,EAAA;AAC5C,QAAA,IAAI,CAAC,KAAK,GAAG,uCAAuC,CAClD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAClC;AACD,QAAA,IAAI,CAAC,QAAQ,GAAG,uCAAuC,CACrD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CACrC;AACD,QAAA,IAAI,CAAC,IAAI,GAAG,uCAAuC,CACjD,QAAQ,EACR,IAAI,CAAC,qBAAqB,EAAE,IAAI,CACjC;AACD,QAAA,IAAI,C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eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAA,EAEvC,IAAI,CAAC,WAAW,KACf,CAAK,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,6CAA6C,EAAA,EACtD,CAAA,CAAA,KAAA,EAAA,EACE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAClB,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,KAAK,EAAC,qCAAqC,EAAA,CAC3C,CACE,CACP,EACD,CAAK,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,uCAAuC,EAAA,EAC/C,IAAI,CAAC,KAAK,KACT,CAAG,CAAA,GAAA,EAAA,EAAA,KAAK,EAAC,6CAA6C,EACnD,EAAA,IAAI,CAAC,KAAK,CACT,CACL,EACA,IAAI,CAAC,QAAQ,KACZ,CAAG,CAAA,GAAA,EAAA,EAAA,KAAK,EAAC,gDAAgD,EAAA,EACtD,IAAI,CAAC,QAAQ,CACZ,CACL,CACG,CACJ,CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","HTMLElement"],"sources":["src/components/searchcraft-popover-list-item/searchcraft-popover-list-item.tsx"],"sourcesContent":["import type { SearchcraftCore } from '@classes';\nimport { registry } from '@classes/CoreInstanceRegistry';\nimport { Component, Element, Prop, State, Watch, h } from '@stencil/core';\nimport type {\n PopoverResultMappings,\n SearchClientResponseItem,\n SearchDocument,\n SearchResultTemplate,\n SearchResultTemplateData,\n} from '@types';\nimport { getDocumentValueFromSearchResultMapping, html, safeUrl } from '@utils';\n\n/**\n * A single list item rendered in a searchcraft-popover-list-view.\n *\n * @internal\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 /**\n * A callback function responsible for rendering the result. When provided, it is used instead of `popoverResultMappings`, which are still used if the template throws.\n */\n @Prop() template?: SearchResultTemplate<SearchResultTemplateData>;\n /**\n * The index of the result in the list view. Passed to the `template` callback.\n */\n @Prop() index = 0;\n /** The document position relative to the search results (For Measure) */\n @Prop() documentPosition = 0;\n /**\n * The id of the Searchcraft instance that this component should use.\n */\n @Prop() searchcraftId?: string;\n\n @State() title?: string;\n @State() subtitle?: string;\n @State() href?: string;\n @State() imageSource?: string;\n @State() imageAlt?: string;\n @State() templateHtml: string | undefined;\n @Element() hostElement?: HTMLElement;\n core?: SearchcraftCore;\n private cleanupCore?: () => void;\n\n mapValuesFromDocument(document: SearchDocument) {\n this.title = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.title,\n );\n this.subtitle = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.subtitle,\n );\n this.href = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.href,\n );\n this.imageSource = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageSource,\n );\n this.imageAlt = getDocumentValueFromSearchResultMapping(\n document,\n this.popoverResultMappings?.imageAlt,\n );\n }\n\n /**\n * Maps the document values and renders the template, if there is one. The mapped values are\n * always kept so the result can fall back to them if the template throws or is removed.\n */\n @Watch('item')\n @Watch('popoverResultMappings')\n @Watch('template')\n @Watch('index')\n updateRenderedValues() {\n this.templateHtml = undefined;\n\n if (!this.item) {\n return;\n }\n\n this.mapValuesFromDocument(this.item.document);\n\n if (this.template) {\n try {\n this.templateHtml = this.template(this.item.document, this.index, {\n html,\n safeUrl,\n source_index: this.item.source_index,\n });\n } catch (error) {\n console.error('Invalid popover result template:', error);\n }\n }\n }\n\n onCoreAvailable(core: SearchcraftCore) {\n this.core = core;\n }\n\n connectedCallback() {\n this.updateRenderedValues();\n this.cleanupCore = registry.useCoreInstance(\n this.searchcraftId,\n this.onCoreAvailable.bind(this),\n );\n }\n\n disconnectedCallback() {\n this.cleanupCore?.();\n }\n\n sendDocumentClickedEvent() {\n if (this.core) {\n const document_position = this.documentPosition;\n const search_term = this.core.store.getState().searchTerm;\n const number_of_documents =\n this.core.store.getState().searchClientResponseItems.length || 0;\n\n this.core.measureClient?.sendMeasureEvent('document_clicked', {\n document_position,\n number_of_documents,\n search_term,\n });\n }\n }\n\n handleLinkClick = () => {\n this.sendDocumentClickedEvent();\n };\n\n /**\n * Sends the click event when a link inside the rendered template is clicked.\n */\n handleTemplateClick = (event: MouseEvent) => {\n const link = (event.target as HTMLElement | null)?.closest('a');\n\n if (link && this.hostElement?.contains(link)) {\n this.sendDocumentClickedEvent();\n }\n };\n\n handleKeyDown = () => {};\n\n render() {\n if (this.template && typeof this.templateHtml === 'string') {\n return (\n <div\n class='searchcraft-popover-list-item searchcraft-popover-list-item-template'\n innerHTML={this.templateHtml}\n onClick={this.handleTemplateClick}\n onKeyDown={this.handleKeyDown}\n />\n );\n }\n\n return (\n <div class='searchcraft-popover-list-item'>\n <a\n class='searchcraft-popover-list-item-link'\n href={this.href ? safeUrl(this.href) : undefined}\n onClick={this.handleLinkClick.bind(this)}\n >\n {this.imageSource && (\n <div class='searchcraft-popover-list-item-image-wrapper'>\n <img\n alt={this.imageAlt}\n src={this.imageSource}\n class='searchcraft-popover-list-item-image'\n />\n </div>\n )}\n <div class='searchcraft-popover-list-item-content'>\n {this.title && (\n <p class='searchcraft-popover-list-item-content-title'>\n {this.title}\n </p>\n )}\n {this.subtitle && (\n <p class='searchcraft-popover-list-item-content-subtitle'>\n {this.subtitle}\n </p>\n )}\n </div>\n </a>\n </div>\n );\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './searchcraft-popover-list-view2.js?scv=0.15.0';
1
+ import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './searchcraft-popover-list-view2.js?scv=0.16.0';
2
2
 
3
3
  const SearchcraftPopoverListView = SearchcraftPopoverListView$1;
4
4
  const defineCustomElement = defineCustomElement$1;