@searchcraft/javascript-sdk 0.1.9 → 0.2.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 (192) hide show
  1. package/dist/cjs/{index-d0e71432.js → index-6c5282a0.js} +3 -3
  2. package/dist/cjs/index-6c5282a0.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +2 -2
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/{searchcraft-auto-search-form_16.cjs.entry.js → searchcraft-auto-search-form_17.cjs.entry.js} +177 -68
  6. package/dist/cjs/searchcraft-auto-search-form_17.cjs.entry.js.map +1 -0
  7. package/dist/cjs/searchcraft-base-search-form.cjs.entry.js +4 -4
  8. package/dist/cjs/searchcraft-button-icon.cjs.entry.js +1 -1
  9. package/dist/cjs/searchcraft-button.cjs.entry.js +2 -2
  10. package/dist/cjs/searchcraft-javascript-sdk.cjs.js +2 -2
  11. package/dist/cjs/{store-3f6eab7d.js → store-ccdd30e6.js} +35 -40
  12. package/dist/cjs/store-ccdd30e6.js.map +1 -0
  13. package/dist/cjs/{utils-39791159.js → utils-bd99e8b0.js} +3 -3
  14. package/dist/cjs/utils-bd99e8b0.js.map +1 -0
  15. package/dist/collection/collection-manifest.json +1 -0
  16. package/dist/collection/components/searchcraft-auto-search-form/searchcraft-auto-search-form.js +29 -6
  17. package/dist/collection/components/searchcraft-auto-search-form/searchcraft-auto-search-form.js.map +1 -1
  18. package/dist/collection/components/searchcraft-auto-search-form/searchcraft-auto-search-form.module.css +0 -6
  19. package/dist/collection/components/searchcraft-base-search-form/searchcraft-base-search-form.js +1 -1
  20. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js +2 -2
  21. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.js.map +1 -1
  22. package/dist/collection/components/searchcraft-base-search-result/searchcraft-base-search-result.module.css +13 -6
  23. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js +43 -9
  24. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.js.map +1 -1
  25. package/dist/collection/components/searchcraft-base-search-results/searchcraft-base-search-results.module.css +8 -1
  26. package/dist/collection/components/searchcraft-button/searchcraft-button.js +1 -1
  27. package/dist/collection/components/searchcraft-clear-input-button/searchcraft-clear-input-button.module.css +2 -2
  28. package/dist/collection/components/searchcraft-error-message/searchcraft-error-message.js +1 -1
  29. package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.js +47 -23
  30. package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.js.map +1 -1
  31. package/dist/collection/components/searchcraft-filters-list/searchcraft-filters-list.module.css +37 -2
  32. package/dist/collection/components/searchcraft-input/searchcraft-input.js +2 -2
  33. package/dist/collection/components/searchcraft-input/searchcraft-input.js.map +1 -1
  34. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js +51 -0
  35. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.js.map +1 -0
  36. package/dist/collection/components/searchcraft-results-info/searchcraft-results-info.module.css +16 -0
  37. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js +32 -8
  38. package/dist/collection/components/searchcraft-slider/searchcraft-slider.js.map +1 -1
  39. package/dist/collection/components/searchcraft-slider/searchcraft-slider.module.css +9 -7
  40. package/dist/collection/components/searchcraft-spinner-dark/searchcraft-spinner-dark.js +1 -1
  41. package/dist/collection/components/searchcraft-spinner-light/searchcraft-spinner-light.js +1 -1
  42. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js +22 -9
  43. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.js.map +1 -1
  44. package/dist/collection/components/searchcraft-toggle-button/searchcraft-toggle-button.module.css +0 -7
  45. package/dist/collection/index.js.map +1 -1
  46. package/dist/collection/provider/store.js +3 -7
  47. package/dist/collection/provider/store.js.map +1 -1
  48. package/dist/collection/utils/utils.js +2 -2
  49. package/dist/collection/utils/utils.js.map +1 -1
  50. package/dist/components/index.d.ts +12 -0
  51. package/dist/components/index.js +56 -3
  52. package/dist/components/index.js.map +1 -1
  53. package/dist/components/{p-f2e41d24.js → p-1101288c.js} +3 -4
  54. package/dist/components/p-1101288c.js.map +1 -0
  55. package/dist/components/{p-50ca3fe4.js → p-15dd4fe4.js} +3 -4
  56. package/dist/components/p-15dd4fe4.js.map +1 -0
  57. package/dist/components/{p-37df2122.js → p-2350c0ab.js} +12 -13
  58. package/dist/components/p-2350c0ab.js.map +1 -0
  59. package/dist/components/{p-25bd714c.js → p-6237f03e.js} +2 -3
  60. package/dist/components/p-6237f03e.js.map +1 -0
  61. package/dist/components/{p-05cd002d.js → p-70722ab2.js} +2 -3
  62. package/dist/components/p-70722ab2.js.map +1 -0
  63. package/dist/components/{p-c9cd5533.js → p-7498e493.js} +3 -3
  64. package/dist/components/p-7498e493.js.map +1 -0
  65. package/dist/components/{p-c9629cc3.js → p-848301b7.js} +3 -4
  66. package/dist/components/p-848301b7.js.map +1 -0
  67. package/dist/components/{p-574e8e3c.js → p-85693c64.js} +4 -5
  68. package/dist/components/p-85693c64.js.map +1 -0
  69. package/dist/components/{p-9bb9d6f0.js → p-8fe6289d.js} +2 -3
  70. package/dist/components/p-8fe6289d.js.map +1 -0
  71. package/dist/{esm/store-5f6f8445.js → components/p-99971aa9.js} +124 -129
  72. package/dist/components/p-99971aa9.js.map +1 -0
  73. package/dist/components/{p-71dff048.js → p-a3bd1bc8.js} +2 -3
  74. package/dist/components/p-a3bd1bc8.js.map +1 -0
  75. package/dist/components/{p-17c94ac1.js → p-aff5cd24.js} +3 -3
  76. package/dist/components/p-aff5cd24.js.map +1 -0
  77. package/dist/components/p-bd90d9b4.js +85 -0
  78. package/dist/components/p-bd90d9b4.js.map +1 -0
  79. package/dist/components/{p-403f6115.js → p-c70cd874.js} +6 -7
  80. package/dist/components/p-c70cd874.js.map +1 -0
  81. package/dist/components/{p-e0e0fc94.js → p-c815eb98.js} +3 -4
  82. package/dist/components/p-c815eb98.js.map +1 -0
  83. package/dist/components/searchcraft-auto-search-form.js +30 -22
  84. package/dist/components/searchcraft-auto-search-form.js.map +1 -1
  85. package/dist/components/searchcraft-base-search-form.js +15 -16
  86. package/dist/components/searchcraft-base-search-form.js.map +1 -1
  87. package/dist/components/searchcraft-base-search-result.js +1 -1
  88. package/dist/components/searchcraft-base-search-results.js +28 -15
  89. package/dist/components/searchcraft-base-search-results.js.map +1 -1
  90. package/dist/components/searchcraft-button-icon.js +1 -2
  91. package/dist/components/searchcraft-button-icon.js.map +1 -1
  92. package/dist/components/searchcraft-button.js +1 -1
  93. package/dist/components/searchcraft-clear-icon-set.js +1 -1
  94. package/dist/components/searchcraft-clear-input-button.js +1 -1
  95. package/dist/components/searchcraft-error-message.js +1 -1
  96. package/dist/components/searchcraft-filters-list.js +50 -27
  97. package/dist/components/searchcraft-filters-list.js.map +1 -1
  98. package/dist/components/searchcraft-input-caption.js +1 -1
  99. package/dist/components/searchcraft-input-icon.js +1 -1
  100. package/dist/components/searchcraft-input-label.js +1 -1
  101. package/dist/components/searchcraft-input.js +1 -1
  102. package/dist/components/searchcraft-results-info.d.ts +11 -0
  103. package/dist/components/searchcraft-results-info.js +63 -0
  104. package/dist/components/searchcraft-results-info.js.map +1 -0
  105. package/dist/components/searchcraft-search-icon-set.js +1 -1
  106. package/dist/components/searchcraft-slider.js +35 -12
  107. package/dist/components/searchcraft-slider.js.map +1 -1
  108. package/dist/components/searchcraft-spinner-dark.js +1 -1
  109. package/dist/components/searchcraft-spinner-light.js +1 -1
  110. package/dist/components/searchcraft-toggle-button.js +25 -13
  111. package/dist/components/searchcraft-toggle-button.js.map +1 -1
  112. package/dist/esm/{index-92040c37.js → index-0ac5bb53.js} +3 -3
  113. package/dist/esm/index-0ac5bb53.js.map +1 -0
  114. package/dist/esm/index.js +2 -2
  115. package/dist/esm/loader.js +3 -3
  116. package/dist/esm/{searchcraft-auto-search-form_16.entry.js → searchcraft-auto-search-form_17.entry.js} +177 -69
  117. package/dist/esm/searchcraft-auto-search-form_17.entry.js.map +1 -0
  118. package/dist/esm/searchcraft-base-search-form.entry.js +4 -4
  119. package/dist/esm/searchcraft-button-icon.entry.js +1 -1
  120. package/dist/esm/searchcraft-button.entry.js +2 -2
  121. package/dist/esm/searchcraft-javascript-sdk.js +3 -3
  122. package/dist/{components/p-5aa6335f.js → esm/store-311de204.js} +35 -40
  123. package/dist/esm/store-311de204.js.map +1 -0
  124. package/dist/esm/{utils-7bff0c78.js → utils-e2076797.js} +3 -3
  125. package/dist/esm/utils-e2076797.js.map +1 -0
  126. package/dist/loader/cdn.js +1 -0
  127. package/dist/loader/index.cjs.js +1 -0
  128. package/{loader → dist/loader}/index.d.ts +1 -1
  129. package/dist/loader/index.es2017.js +1 -0
  130. package/{loader → dist/loader}/index.js +1 -1
  131. package/dist/searchcraft-javascript-sdk/index.esm.js +1 -1
  132. package/dist/searchcraft-javascript-sdk/p-0880cfbb.js +3 -0
  133. package/dist/searchcraft-javascript-sdk/p-0880cfbb.js.map +1 -0
  134. package/dist/searchcraft-javascript-sdk/{p-81eaebdc.entry.js → p-5ec960bd.entry.js} +2 -2
  135. package/dist/searchcraft-javascript-sdk/p-6108dd80.entry.js +2 -0
  136. package/dist/searchcraft-javascript-sdk/p-6108dd80.entry.js.map +1 -0
  137. package/dist/searchcraft-javascript-sdk/{p-5aa6335f.js → p-80ea9602.js} +2 -2
  138. package/dist/searchcraft-javascript-sdk/p-80ea9602.js.map +1 -0
  139. package/dist/searchcraft-javascript-sdk/p-a9bac3ca.entry.js +2 -0
  140. package/dist/searchcraft-javascript-sdk/{p-639d019b.entry.js.map → p-a9bac3ca.entry.js.map} +1 -1
  141. package/dist/searchcraft-javascript-sdk/{p-17c94ac1.js → p-aff5cd24.js} +1 -1
  142. package/dist/searchcraft-javascript-sdk/p-aff5cd24.js.map +1 -0
  143. package/dist/searchcraft-javascript-sdk/{p-02f632b6.entry.js → p-cc454542.entry.js} +2 -2
  144. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js +1 -1
  145. package/dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js.map +1 -1
  146. package/dist/types/components/searchcraft-auto-search-form/searchcraft-auto-search-form.d.ts +3 -2
  147. package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +3 -1
  148. package/dist/types/components/searchcraft-filters-list/searchcraft-filters-list.d.ts +7 -0
  149. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +10 -0
  150. package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +7 -1
  151. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +5 -0
  152. package/dist/types/components.d.ts +19 -2
  153. package/dist/types/index.d.ts +1 -0
  154. package/dist/types/utils/utils.d.ts +1 -1
  155. package/package.json +3 -7
  156. package/dist/cjs/index-d0e71432.js.map +0 -1
  157. package/dist/cjs/searchcraft-auto-search-form_16.cjs.entry.js.map +0 -1
  158. package/dist/cjs/store-3f6eab7d.js.map +0 -1
  159. package/dist/cjs/utils-39791159.js.map +0 -1
  160. package/dist/components/p-05cd002d.js.map +0 -1
  161. package/dist/components/p-17c94ac1.js.map +0 -1
  162. package/dist/components/p-25bd714c.js.map +0 -1
  163. package/dist/components/p-37df2122.js.map +0 -1
  164. package/dist/components/p-3cbac2bb.js +0 -86
  165. package/dist/components/p-3cbac2bb.js.map +0 -1
  166. package/dist/components/p-403f6115.js.map +0 -1
  167. package/dist/components/p-50ca3fe4.js.map +0 -1
  168. package/dist/components/p-574e8e3c.js.map +0 -1
  169. package/dist/components/p-5aa6335f.js.map +0 -1
  170. package/dist/components/p-71dff048.js.map +0 -1
  171. package/dist/components/p-9bb9d6f0.js.map +0 -1
  172. package/dist/components/p-c9629cc3.js.map +0 -1
  173. package/dist/components/p-c9cd5533.js.map +0 -1
  174. package/dist/components/p-e0e0fc94.js.map +0 -1
  175. package/dist/components/p-f2e41d24.js.map +0 -1
  176. package/dist/esm/index-92040c37.js.map +0 -1
  177. package/dist/esm/searchcraft-auto-search-form_16.entry.js.map +0 -1
  178. package/dist/esm/store-5f6f8445.js.map +0 -1
  179. package/dist/esm/utils-7bff0c78.js.map +0 -1
  180. package/dist/searchcraft-javascript-sdk/p-05369654.js +0 -3
  181. package/dist/searchcraft-javascript-sdk/p-05369654.js.map +0 -1
  182. package/dist/searchcraft-javascript-sdk/p-17c94ac1.js.map +0 -1
  183. package/dist/searchcraft-javascript-sdk/p-5aa6335f.js.map +0 -1
  184. package/dist/searchcraft-javascript-sdk/p-639d019b.entry.js +0 -2
  185. package/dist/searchcraft-javascript-sdk/p-73265750.entry.js +0 -2
  186. package/dist/searchcraft-javascript-sdk/p-73265750.entry.js.map +0 -1
  187. package/loader/cdn.js +0 -1
  188. package/loader/index.cjs.js +0 -1
  189. package/loader/index.es2017.js +0 -1
  190. /package/{loader → dist/loader}/package.json +0 -0
  191. /package/dist/searchcraft-javascript-sdk/{p-81eaebdc.entry.js.map → p-5ec960bd.entry.js.map} +0 -0
  192. /package/dist/searchcraft-javascript-sdk/{p-02f632b6.entry.js.map → p-cc454542.entry.js.map} +0 -0
@@ -1,25 +1,28 @@
1
- import { r as registerInstance, c as createEvent, h, F as Fragment } from './index-92040c37.js';
2
- import { u as useSearchcraftStore, p } from './store-5f6f8445.js';
3
- import { p as parseCustomStyles, a as parseSearchKeys, s as serializeStyles, e as extractDynamicProperties } from './utils-7bff0c78.js';
1
+ import { r as registerInstance, c as createEvent, h, F as Fragment } from './index-0ac5bb53.js';
2
+ import { u as useSearchcraftStore, g } from './store-311de204.js';
3
+ import { p as parseCustomStyles, a as parseSearchKeys, s as serializeStyles, e as extractDynamicProperties } from './utils-e2076797.js';
4
4
  import { c as classNames } from './index-72ac5051.js';
5
5
 
6
- const searchcraftAutoSearchFormModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.formLTR{text-align:left;width:100%}.formRTL{text-align:right;width:100%}.searchContainer{align-items:center;display:flex;width:100%}";
6
+ const searchcraftAutoSearchFormModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.formLTR{text-align:left;width:100%}.formRTL{text-align:right;width:100%}";
7
7
  const SearchcraftAutoSearchFormStyle0 = searchcraftAutoSearchFormModuleCss;
8
8
 
9
9
  const SearchcraftAutoSearchForm = class {
10
10
  constructor(hostRef) {
11
11
  registerInstance(this, hostRef);
12
12
  this.querySubmit = createEvent(this, "querySubmit", 7);
13
+ this.inputClearedOrNoResults = createEvent(this, "inputClearedOrNoResults", 7);
13
14
  this.debounceTimeout = null;
14
- this.debounceDelay = 300; // 300ms debounce delay
15
+ this.debounceDelay = 0;
15
16
  this.searchStore = useSearchcraftStore.getState();
16
17
  this.handleInputChange = (event) => {
17
18
  this.query = event.detail;
19
+ this.searchStore.setQuery(this.query);
18
20
  this.querySubmit.emit(this.query);
19
21
  };
20
22
  this.handleInputKeyUp = (event) => {
21
23
  const target = event.detail;
22
24
  this.query = target;
25
+ this.searchStore.setQuery(this.query);
23
26
  this.querySubmit.emit(this.query);
24
27
  if (this.debounceTimeout) {
25
28
  clearTimeout(this.debounceTimeout);
@@ -30,6 +33,7 @@ const SearchcraftAutoSearchForm = class {
30
33
  };
31
34
  this.handleClearInput = () => {
32
35
  this.query = '';
36
+ this.searchStore.setQuery('');
33
37
  if (typeof this.clearInput === 'function') {
34
38
  this.clearInput();
35
39
  }
@@ -37,22 +41,22 @@ const SearchcraftAutoSearchForm = class {
37
41
  clearTimeout(this.debounceTimeout);
38
42
  }
39
43
  this.error = false;
40
- this.searchResults = '';
44
+ this.inputClearedOrNoResults.emit();
41
45
  };
42
46
  this.runSearch = async () => {
43
47
  if (this.query.trim() === '') {
44
48
  this.error = true;
45
- this.searchResults = '';
49
+ this.inputClearedOrNoResults.emit();
46
50
  }
47
51
  else {
48
52
  this.error = false;
49
53
  this.searchStore.setQuery(this.query);
50
54
  try {
51
55
  await this.searchStore.search();
52
- this.searchResults = JSON.stringify(this.searchStore.searchResults);
53
56
  }
54
57
  catch (error) {
55
58
  this.error = true;
59
+ this.inputClearedOrNoResults.emit();
56
60
  }
57
61
  }
58
62
  };
@@ -78,13 +82,14 @@ const SearchcraftAutoSearchForm = class {
78
82
  this.error = false;
79
83
  this.isRequesting = false;
80
84
  this.query = '';
81
- this.searchResults = '';
85
+ this.searchResults = null;
82
86
  }
83
87
  componentDidLoad() {
84
- const searchcraft = new p(this.config);
88
+ const searchcraft = new g(this.config);
85
89
  this.searchStore.initialize(searchcraft, true);
86
90
  this.unsubscribe = useSearchcraftStore.subscribe((state) => {
87
91
  this.isRequesting = state.isRequesting;
92
+ this.searchResults = Object.assign({}, state.searchResults);
88
93
  });
89
94
  }
90
95
  disconnectedCallback() {
@@ -93,14 +98,18 @@ const SearchcraftAutoSearchForm = class {
93
98
  }
94
99
  }
95
100
  render() {
101
+ var _a, _b, _c;
96
102
  const formClass = this.rightToLeftOrientation ? 'formRTL' : 'formLTR';
97
103
  const parsedCustomStyles = parseCustomStyles(this.customStylesForInput);
98
- return (h("form", { key: '8a3cf6e3cc1d8cc3f2fcff7ff3b8e90d2e76f400', class: `${formClass}`, onSubmit: this.handleFormSubmit }, h("searchcraft-input-label", { key: 'ab055252710a95574811c9bf82ed2c01fef355d2', label: this.labelForInput }), h("div", { key: '9c397f34ebfe25994de60b7d135cc3167e787499', class: 'searchContainer' }, h("searchcraft-input", { key: '4f3614615c3880fb305e39d511f3ae40e71eed32', customStyles: parsedCustomStyles, "input-caption-value": this.inputCaptionValue, "is-requesting": this.isRequesting, "input-icon-height": this.inputIconHeight, "input-icon-width": this.inputIconWidth, onClearInput: this.handleClearInput, onInputKeyUp: this.handleInputKeyUp, onSearchInputChange: this.handleInputChange, "placeholder-value": this.placeholderValue, query: this.query, "right-to-left-orientation": this.rightToLeftOrientation })), this.error && (h("searchcraft-error-message", { key: '1a297169ed2b12870169e8c533a7112aaa991b93', errorMessage: 'Please enter a search query.' }))));
104
+ if (this.query.length > 0 && ((_c = (_b = (_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.length) === 0) {
105
+ this.inputClearedOrNoResults.emit();
106
+ }
107
+ return (h("form", { key: '49950058e612dc1017fb56235affd3b8077b6926', class: `${formClass}`, onSubmit: this.handleFormSubmit }, h("searchcraft-input-label", { key: 'ce2cb4d74c139fc4f010d1ca51739c49a8e9f6c2', label: this.labelForInput }), h("searchcraft-input", { key: '8fb1eee5dca952ba472f03e768b57663528f5c84', customStyles: parsedCustomStyles, "input-caption-value": this.inputCaptionValue, "is-requesting": this.isRequesting, "input-icon-height": this.inputIconHeight, "input-icon-width": this.inputIconWidth, onClearInput: this.handleClearInput, onInputKeyUp: this.handleInputKeyUp, onSearchInputChange: this.handleInputChange, "placeholder-value": this.placeholderValue, query: this.query, "right-to-left-orientation": this.rightToLeftOrientation }), this.error && (h("searchcraft-error-message", { key: 'd1c893186af4cdb927f31b086aa7d027947c1d2c', errorMessage: 'Please enter a search query.' }))));
99
108
  }
100
109
  };
101
110
  SearchcraftAutoSearchForm.style = SearchcraftAutoSearchFormStyle0;
102
111
 
103
- const searchcraftBaseSearchResultModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.interactiveResultContainerLight{background-color:#FAFAFA;align-items:flex-start;border-radius:16px;display:flex;position:relative;flex-direction:column;gap:16px;padding:8px}@media (min-width: 600px){.interactiveResultContainerLight{flex-direction:row}}.interactiveResultContainerDark{background-color:#2E2E2E;align-items:flex-start;border-radius:16px;display:flex;position:relative;flex-direction:column;gap:16px;padding:8px}@media (min-width: 600px){.interactiveResultContainerDark{flex-direction:row}}.resultContainer{align-items:flex-start;display:flex;flex-direction:column;gap:16px}@media (min-width: 600px){.resultContainer{flex-direction:row}}.interactiveIconLarge{display:inline-block;position:absolute;right:5px;top:8px}@media (max-width: 600px){.interactiveIconLarge{display:none}}.interactiveIconSmall{position:absolute;right:5px;top:-2px;display:inline-block}@media (min-width: 600px){.interactiveIconSmall{display:none}}.imageContainer{max-height:540px;max-width:100%}@media (min-width: 600px){.imageContainer{max-height:175px}}.contentContainer{max-height:100%;max-width:100%}@media (min-width: 600px){.contentContainer{max-width:50%}}.imageLight{aspect-ratio:2/1;border-radius:8px;max-height:100%;max-width:100%;border:1px solid #D9D9D9}.imageDark{aspect-ratio:2/1;border-radius:8px;max-height:100%;max-width:100%;border:1px solid #333}.headingLight{font-family:var(--font-stack);font-size:16px;font-weight:700;line-height:20px;margin-bottom:4px;margin-top:0px;position:relative;color:#292929}.headingDark{font-family:var(--font-stack);font-size:16px;font-weight:700;line-height:20px;margin-bottom:4px;margin-top:0px;position:relative;color:#FFF}.subheadingLight{font-family:var(--font-stack);font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px;margin-top:0px;color:#737373}.subheadingDark{font-family:var(--font-stack);font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px;margin-top:0px;color:#BFBFBF}.primaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.primaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}.secondaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.secondaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}.tertiaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.tertiaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}";
112
+ const searchcraftBaseSearchResultModuleCss = "@charset \"UTF-8\";:root{--font-stack:Helvetica, Arial, sans-serif}.interactiveResultContainerLight{background-color:#FAFAFA;align-items:flex-start;border-radius:16px;display:flex;position:relative;flex-direction:column;gap:16px;padding:8px}@media (min-width: 600px){.interactiveResultContainerLight{flex-direction:row}}.interactiveResultContainerDark{background-color:#2E2E2E;align-items:flex-start;border-radius:16px;display:flex;position:relative;flex-direction:column;gap:16px;padding:8px}@media (min-width: 600px){.interactiveResultContainerDark{flex-direction:row}}.resultContainer{align-items:flex-start;display:flex;flex-direction:column;gap:16px}@media (min-width: 600px){.resultContainer{flex-direction:row}}.interactiveIconLarge{display:inline-block;position:absolute;right:5px;top:8px}@media (max-width: 600px){.interactiveIconLarge{display:none}}.interactiveIconSmall{position:absolute;right:5px;top:-2px;display:inline-block}@media (min-width: 600px){.interactiveIconSmall{display:none}}.imageContainer{max-width:100%}.contentContainer{max-height:100%;max-width:100%}@media (min-width: 600px){.contentContainer{max-width:50%}}.secondaryContentContainer{display:flex}.imageLight{aspect-ratio:2/1;border-radius:8px;max-height:100%;max-width:100%;border:1px solid #D9D9D9}.imageDark{aspect-ratio:2/1;border-radius:8px;max-height:100%;max-width:100%;border:1px solid #333}.headingLight{font-family:var(--font-stack);font-size:16px;font-weight:700;line-height:20px;margin-bottom:4px;margin-top:0px;position:relative;color:#292929}.headingDark{font-family:var(--font-stack);font-size:16px;font-weight:700;line-height:20px;margin-bottom:4px;margin-top:0px;position:relative;color:#FFF}.subheadingLight{font-family:var(--font-stack);font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px;margin-top:0px;color:#737373}.subheadingDark{font-family:var(--font-stack);font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px;margin-top:0px;color:#BFBFBF}.primaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.primaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}.secondaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.secondaryContentLight::after{content:\"•\";color:#404040;font-size:1em;margin-left:5px;margin-right:5px}.secondaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}.tertiaryContentLight{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#404040}.tertiaryContentDark{font-family:var(--font-stack);font-size:16px;font-weight:400;line-height:20px;margin-bottom:4px;margin-top:0px;color:#E6E6E6}";
104
113
  const SearchcraftBaseSearchResultStyle0 = searchcraftBaseSearchResultModuleCss;
105
114
 
106
115
  const SearchcraftBaseSearchResult = class {
@@ -144,16 +153,16 @@ const SearchcraftBaseSearchResult = class {
144
153
  render() {
145
154
  const isLightTheme = this.themeMode === 'light';
146
155
  const styles = this.parseStyles();
147
- return (h("div", { key: 'e16bae2d337d064e057645cfb0ebf52346229b83', class: this.isInteractive
156
+ return (h("div", { key: '91cfc671b0b99082915df3eaafa053a9a7f77929', class: this.isInteractive
148
157
  ? isLightTheme
149
158
  ? 'interactiveResultContainerLight'
150
159
  : 'interactiveResultContainerDark'
151
- : 'resultContainer', style: styles.container || {}, tabindex: '0', onClick: this.handleContainerClick, onKeyDown: this.keyDownCallback }, h("div", { key: 'f2154ce85febbe54956a7f28292b13113e3048dd', class: 'imageContainer' }, h("img", { key: '8063fa3b88ba56b9cba63ded99967c8097b8b185', alt: this.imageDescription, src: this.imageSource, style: styles.image || {}, class: isLightTheme ? 'imageLight' : 'imageDark' })), h("div", { key: 'e04a38165dc98b0d72f215e4252f7065db3664d6', class: 'contentContainer' }, h("h2", { key: '33d2d3483d7c0f4e1ae7e15ba5895a8b15b45a34', style: styles.heading || {}, class: isLightTheme ? 'headingLight' : 'headingDark' }, this.headingText), h("h3", { key: '9587d0acea25ede251eba3e79dba932a5565f51a', style: styles.subheading || {}, class: isLightTheme ? 'subheadingLight' : 'subheadingDark' }, this.subheadingText), h("p", { key: '74f55a23963d5ddc8753d68b164587865da2dd13', style: styles.primaryContent || {}, class: isLightTheme ? 'primaryContentLight' : 'primaryContentDark' }, this.primaryContent), h("div", { key: 'db4e498b08c7075b276e90d8ed233dd48992ecdd' }, h("p", { key: 'c09d3164a15452c5fbfa23a54028f2080dd56550', style: styles.secondaryContent || {}, class: isLightTheme ? 'secondaryContentLight' : 'secondaryContentDark' }, this.secondaryContent), h("p", { key: 'ae78c4f53d9b12d62cad6b408aad5caf103303db', style: styles.tertiaryContent || {}, class: isLightTheme ? 'tertiaryContentLight' : 'tertiaryContentDark' }, this.tertiaryContent)), this.buttonText && (h("button", { key: '3ea036c680f3970e9d6f1b00b3505f11e338922c', onClick: this.handleButtonClick, style: styles.button || {}, type: 'button' }, this.buttonText)))));
160
+ : 'resultContainer', style: styles.container || {}, tabindex: '0', onClick: this.handleContainerClick, onKeyDown: this.keyDownCallback }, h("div", { key: 'ccda236ef60aee285472155889c5490c69a86415', class: 'imageContainer' }, h("img", { key: 'e55d743952e2997d91f6486436e3a7955ffc1dcc', alt: this.imageDescription, src: this.imageSource, style: styles.image || {}, class: isLightTheme ? 'imageLight' : 'imageDark' })), h("div", { key: 'b0e831c0c7bfef46b8b6da4e84536adf3ebd7158', class: 'contentContainer' }, h("h2", { key: '54137612623a39d711f4e3c888bf2015b6fb9500', style: styles.heading || {}, class: isLightTheme ? 'headingLight' : 'headingDark' }, this.headingText), h("h3", { key: 'de46df990be3d0b5d2134d272e1766e911ab094a', style: styles.subheading || {}, class: isLightTheme ? 'subheadingLight' : 'subheadingDark' }, this.subheadingText), h("p", { key: 'd9e7656bc739b0dd2267f86ac51b17d9ca16da6a', style: styles.primaryContent || {}, class: isLightTheme ? 'primaryContentLight' : 'primaryContentDark' }, this.primaryContent), h("div", { key: 'd05813b3da29b8b21c2e370db9c0cbc7b48b9556', class: 'secondaryContentContainer' }, h("p", { key: 'e8d2ede937705a5bd88927779ee24e35ba2efbd8', style: styles.secondaryContent || {}, class: isLightTheme ? 'secondaryContentLight' : 'secondaryContentDark' }, this.secondaryContent), h("p", { key: '2f9b9f603d55bcefe8347675cb31f705b1f7a0e8', style: styles.tertiaryContent || {}, class: isLightTheme ? 'tertiaryContentLight' : 'tertiaryContentDark' }, this.tertiaryContent)), this.buttonText && (h("button", { key: '58724046c9704974cb3ae1c34335ebb7131b91ab', onClick: this.handleButtonClick, style: styles.button || {}, type: 'button' }, this.buttonText)))));
152
161
  }
153
162
  };
154
163
  SearchcraftBaseSearchResult.style = SearchcraftBaseSearchResultStyle0;
155
164
 
156
- const searchcraftBaseSearchResultsModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.resultsContainer{display:flex;flex-direction:column;justify-content:center;margin:100px 20px}.resultsContainer>p{align-self:center}.resultsContainer>div{margin-bottom:20px}.resultsContainer>div img{height:300px;width:200px}.adSection{align-items:center;border:1px solid #DCDDDE;display:flex;flex-direction:column;font-size:16px;justify-content:center;margin:auto;min-height:150px;text-align:center;width:100%}.adSection p{margin-top:5px}.emptyState{text-align:center}";
165
+ const searchcraftBaseSearchResultsModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.resultsContainer{display:flex;flex-direction:column;justify-content:center;margin:16px 0}.resultsContainer>p{align-self:center}.resultsContainer>div{margin-bottom:20px}.resultsContainer>div img{height:300px;width:200px}.adSection{align-items:center;background-color:#F1F1F1;border:1px solid #DCDDDE;border-radius:16px;display:flex;flex-direction:column;font-size:16px;justify-content:center;margin:auto;min-height:150px;text-align:center;width:100%}.adSection p{margin-top:5px}.emptyState{width:100%;text-align:center}.errorMessageContainer{text-align:center}";
157
166
  const SearchcraftBaseSearchResultsStyle0 = searchcraftBaseSearchResultsModuleCss;
158
167
 
159
168
  const SearchcraftBaseSearchResults = class {
@@ -161,19 +170,28 @@ const SearchcraftBaseSearchResults = class {
161
170
  registerInstance(this, hostRef);
162
171
  this.query = '';
163
172
  this.searchResults = null;
164
- this.searchKeys = '';
173
+ this.hasSearched = false;
174
+ this.documentAttributesForDisplay = '';
165
175
  this.customStylesForResults = {};
166
176
  this.placeAdAtStart = true;
167
177
  this.placeAdAtEnd = false;
168
178
  this.adInterval = 4;
169
179
  this.formatTime = true;
180
+ this.fallbackElement = null;
170
181
  }
171
182
  componentDidLoad() {
172
- if (!this.searchKeys || this.searchKeys.length === 0) {
173
- console.warn('No searchKeys provided; using empty keys array.');
174
- this.searchKeys = '';
183
+ if (!this.documentAttributesForDisplay ||
184
+ this.documentAttributesForDisplay.length === 0) {
185
+ console.warn('No document attributes provided; using empty keys array.');
186
+ this.documentAttributesForDisplay = '';
175
187
  }
176
188
  this.unsubscribe = useSearchcraftStore.subscribe((state) => {
189
+ if (state.query.length > 0) {
190
+ this.hasSearched = true;
191
+ }
192
+ else {
193
+ this.hasSearched = false;
194
+ }
177
195
  this.searchResults = Object.assign({}, state.searchResults);
178
196
  this.query = state.query;
179
197
  });
@@ -207,11 +225,14 @@ const SearchcraftBaseSearchResults = class {
207
225
  }
208
226
  render() {
209
227
  var _a, _b, _c, _d, _e, _f, _g;
228
+ if (!this.hasSearched) {
229
+ return (h("div", { class: 'emptyState' }, h("slot", { name: 'empty-search' })));
230
+ }
210
231
  if (!((_a = this.searchResults) === null || _a === void 0 ? void 0 : _a.data)) {
211
232
  console.warn('No search results data available');
212
233
  return h("div", { class: 'emptyState' }, "No results to display.");
213
234
  }
214
- const parsedSearchKeys = parseSearchKeys(this.searchKeys);
235
+ const parsedSearchKeys = parseSearchKeys(this.documentAttributesForDisplay);
215
236
  const serializedStyles = typeof this.customStylesForResults === 'string'
216
237
  ? this.customStylesForResults
217
238
  : serializeStyles(this.customStylesForResults);
@@ -252,7 +273,7 @@ const SearchcraftBaseSearchResults = class {
252
273
  finalComponents.push(h("div", { key: 'ad-section-end', class: 'adSection' }, h("span", null, "##"), h("p", null, " Ad Impressions")));
253
274
  }
254
275
  return (h("div", { class: 'resultsContainer' }, finalComponents, this.query.length > 0 &&
255
- ((_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 && (h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` }))));
276
+ ((_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 && (h("div", { class: 'errorMessageContainer' }, h("searchcraft-error-message", { "error-message": `No search results found for "${this.query}" query` })))));
256
277
  }
257
278
  };
258
279
  SearchcraftBaseSearchResults.style = SearchcraftBaseSearchResultsStyle0;
@@ -278,7 +299,7 @@ const SearchcraftClearIconSet = class {
278
299
  }
279
300
  };
280
301
 
281
- const searchcraftClearInputButtonModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.inputClearButtonLTR{align-items:center;background:none;border:none;display:flex;height:20px;justify-content:center;padding:0;position:absolute;right:25px;top:50%;transform:translateY(-50%);width:20px}.inputClearButtonRTL{align-items:center;background:none;border:none;display:flex;height:20px;justify-content:center;left:25px;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:20px}";
302
+ const searchcraftClearInputButtonModuleCss = ":root{--font-stack:Helvetica, Arial, sans-serif}.inputClearButtonLTR{align-items:center;background:none;border:none;display:flex;height:20px;justify-content:center;padding:0;position:absolute;right:0;top:50%;transform:translateY(-50%);width:20px}.inputClearButtonRTL{align-items:center;background:none;border:none;display:flex;height:20px;justify-content:center;left:0px;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:20px}";
282
303
  const SearchcraftClearInputButtonStyle0 = searchcraftClearInputButtonModuleCss;
283
304
 
284
305
  const SearchcraftClearInputButton = class {
@@ -314,12 +335,12 @@ const SearchcraftErrorMessage = class {
314
335
  }
315
336
  render() {
316
337
  const errorMessageStyle = this.theme === 'light' ? 'errorMessageLight' : 'errorMessageDark';
317
- return (h("p", { key: 'f520ac38f2f42e9780454aef5e25576095ae5ee9', class: classNames(errorMessageStyle) }, this.errorMessage || 'Search term is required.'));
338
+ return (h("p", { key: '544903d700810ed5d6efdefedab646cafed2376d', class: classNames(errorMessageStyle) }, this.errorMessage || 'Search term is required.'));
318
339
  }
319
340
  };
320
341
  SearchcraftErrorMessage.style = SearchcraftErrorMessageStyle0;
321
342
 
322
- const searchcraftFiltersListModuleCss = "@charset \"UTF-8\";.filtersList{padding:16px}.checkboxLabel{align-items:center;color:#292929;display:flex;font-size:14px;font-weight:600;gap:12px}.checkboxLabel input[type=checkbox]{align-items:center;appearance:none;background-color:#EDEDED;border:1px solid #D9D9D9;cursor:pointer;display:flex;height:24px;justify-content:center;width:24px}.checkboxLabel input[type=checkbox]:checked{background-color:#000}.checkboxLabel input[type=checkbox]:checked::before{color:#fff;content:\"✔\";font-size:14px}";
343
+ const searchcraftFiltersListModuleCss = "@charset \"UTF-8\";.filtersList{width:100%}.checkboxLabel{align-items:center;color:#292929;display:flex;font-family:\"Source Sans Pro\";font-size:14px;font-weight:600;gap:14px}.checkboxLabel input[type=checkbox]{align-items:center;appearance:none;background-color:#EDEDED;border:1px solid #D9D9D9;cursor:pointer;display:flex;height:24px;justify-content:center;width:24px}.checkboxLabel input[type=checkbox]:checked{background-color:#000}.checkboxLabel input[type=checkbox]:checked::before{color:#fff;content:\"✔\"}.remainingFilterListCheckbox{margin-left:16px}.childCheckboxLabel{align-items:center;color:#292929;display:flex;font-family:\"Source Sans Pro\";font-size:14px;font-weight:600;gap:12px}.childCheckboxLabel input[type=checkbox]{align-items:center;appearance:none;background-color:#EDEDED;border:1px solid #D9D9D9;cursor:pointer;display:flex;height:24px;justify-content:center;width:24px}.childCheckboxLabel input[type=checkbox]:checked{background-color:#000}.childCheckboxLabel input[type=checkbox]:checked::before{color:#fff;content:\"✔\"}";
323
344
  const SearchcraftFiltersListStyle0 = searchcraftFiltersListModuleCss;
324
345
 
325
346
  const SearchcraftFiltersList = class {
@@ -341,15 +362,20 @@ const SearchcraftFiltersList = class {
341
362
  };
342
363
  this.filters = [];
343
364
  this.dynamicFilters = [];
365
+ this.initialFilters = [];
344
366
  this.isRequesting = false;
345
367
  this.selectedFilters = new Set();
346
368
  this.originalFilterCounts = {};
369
+ this.query = '';
370
+ this.resultsCount = 0;
347
371
  }
348
372
  connectedCallback() {
349
373
  this.unsubscribe = useSearchcraftStore.subscribe((state) => {
350
- var _a;
374
+ var _a, _b, _c, _d;
351
375
  this.isRequesting = state.isRequesting;
352
- const facets = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data.facets;
376
+ this.query = state.query || '';
377
+ this.resultsCount = ((_c = (_b = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.length) || 0;
378
+ const facets = (_d = state.searchResults) === null || _d === void 0 ? void 0 : _d.data.facets;
353
379
  if (facets) {
354
380
  this.populateFiltersFromFacets(facets);
355
381
  }
@@ -361,32 +387,48 @@ const SearchcraftFiltersList = class {
361
387
  }
362
388
  }
363
389
  populateFiltersFromFacets(facets) {
364
- const newFilters = Object.entries(facets).flatMap(([facetKey, facetData]) => Object.entries(facetData.counts).map(([value, count]) => {
365
- const filterValue = `${facetKey}:${value}`;
366
- this.originalFilterCounts[filterValue] = `${count}`; // Store the original count
390
+ var _a;
391
+ const newFilters = Object.entries(((_a = facets.section) === null || _a === void 0 ? void 0 : _a.counts) || {}).map(([key, count]) => {
392
+ const filterValue = key;
393
+ this.originalFilterCounts[filterValue] = `${count}`;
367
394
  return {
368
- label: `${facetKey}: ${value.replace(/^\//, '')} (${count})`,
395
+ label: `${key.replace(/^\//, '')} (${count})`,
369
396
  value: filterValue,
370
397
  };
371
- }));
372
- this.dynamicFilters = newFilters;
398
+ });
399
+ // Update dynamic filters while preserving the initial filters
400
+ const updatedFilters = [
401
+ ...this.initialFilters,
402
+ ...newFilters.filter((filter) => !this.initialFilters.some((initial) => initial.value === filter.value)),
403
+ ];
404
+ this.dynamicFilters = updatedFilters;
405
+ // Store the initial filters only once
406
+ if (this.initialFilters.length === 0) {
407
+ this.initialFilters = [...updatedFilters];
408
+ }
409
+ }
410
+ formatLabel(label) {
411
+ return label
412
+ .replace(/-/g, ' ') // Replace dashes with spaces
413
+ .split(' ') // Split words
414
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize the first letter
415
+ .join(' '); // Join words back into a single string
373
416
  }
374
417
  render() {
375
- const checkedFilters = Array.from(this.selectedFilters).map((value) => {
376
- const count = this.originalFilterCounts[value] || '0';
377
- return {
378
- label: `${value.split(':')[1]} (${count})`,
379
- value,
380
- };
381
- });
382
- const remainingDynamicFilters = this.dynamicFilters.filter((filter) => !this.selectedFilters.has(filter.value));
383
- if (this.isRequesting) {
384
- return h("div", null, "Loading facets");
418
+ if (!this.query || this.resultsCount === 0) {
419
+ return null;
385
420
  }
386
- return (h("div", { class: 'filtersList' }, checkedFilters.map((filter) => (h("label", { class: 'checkboxLabel', key: filter.value }, h("input", { class: 'filterListCheckbox', checked: true, onChange: (event) => this.handleFilterChange(filter.value, event.target.checked), type: 'checkbox', value: filter.value }), filter.label))), remainingDynamicFilters.map((filter) => {
387
- const filterLabel = filter.label.split(':')[1] || filter.label;
388
- return (h("label", { class: 'checkboxLabel', key: filter.value }, h("input", { class: 'filterListCheckbox', checked: this.selectedFilters.has(filter.value), onChange: (event) => this.handleFilterChange(filter.value, event.target.checked), type: 'checkbox', value: filter.value }), filterLabel));
389
- })));
421
+ const filtersToRender = this.initialFilters.map((initialFilter) => {
422
+ const isChecked = this.selectedFilters.has(initialFilter.value);
423
+ const dynamicChildren = this.dynamicFilters.filter((dynamicFilter) => dynamicFilter.value.startsWith(initialFilter.value) &&
424
+ dynamicFilter.value !== initialFilter.value);
425
+ return Object.assign(Object.assign({}, initialFilter), { isChecked, children: dynamicChildren });
426
+ });
427
+ return (h("div", { class: 'filtersList' }, filtersToRender.map((filter) => (h("div", { key: filter.value }, h("label", { class: 'checkboxLabel' }, h("input", { class: 'filterCheckbox', checked: filter.isChecked, onChange: (event) => this.handleFilterChange(filter.value, event.target.checked), type: 'checkbox', value: filter.value }), this.formatLabel(filter.label)), filter.isChecked &&
428
+ filter.children.map((childFilter) => {
429
+ const childLabel = childFilter.label.split('/').pop(); // Get only the part after the last '/'
430
+ return (h("label", { class: 'childCheckboxLabel', key: childFilter.value, style: { marginLeft: '20px' } }, h("input", { class: 'childFilterCheckbox', checked: this.selectedFilters.has(childFilter.value), onChange: (event) => this.handleFilterChange(childFilter.value, event.target.checked), type: 'checkbox', value: childFilter.value }), this.formatLabel(childLabel || '')));
431
+ }))))));
390
432
  }
391
433
  };
392
434
  SearchcraftFiltersList.style = SearchcraftFiltersListStyle0;
@@ -445,11 +487,11 @@ const SearchcraftInput = class {
445
487
  const placeholderStyle = {
446
488
  fontSize: validatedCustomStyles.placeholderFontSize || '16px',
447
489
  };
448
- return (h("div", { key: 'ca2698b808ef606d890817f6b8c133503663570e', class: classNames(containerClassName, this.formClassName, 'searchcraft-input-form') }, this.rightToLeftOrientation ? (h(Fragment, null, h("input", { class: classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), onKeyUp: this.handleInputKeyUp.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), h("style", null, `
490
+ return (h("div", { key: 'ca2698b808ef606d890817f6b8c133503663570e', class: classNames(containerClassName, this.formClassName, 'searchcraft-input-form') }, this.rightToLeftOrientation ? (h(Fragment, null, h("input", { autoComplete: 'off', class: classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), onKeyUp: this.handleInputKeyUp.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), h("style", null, `
449
491
  #searchcraft-input-id::placeholder {
450
492
  font-size: ${placeholderStyle.fontSize};
451
493
  }
452
- `), this.inputCaptionValue && (h("searchcraft-input-caption", { inputCaptionClassName: this.inputCaptionClassName, inputCaptionValue: this.inputCaptionValue, rightToLeftOrientation: this.rightToLeftOrientation })), this.query.length > 0 && (h("searchcraft-clear-input-button", { isRequesting: this.isRequesting, onClearInput: this.handleClearInput, rightToLeftOrientation: this.rightToLeftOrientation })), h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }))) : (h("div", { class: 'inputWrapper' }, h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }), h("input", { class: classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), onKeyUp: this.handleInputKeyUp.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), h("style", null, `
494
+ `), this.inputCaptionValue && (h("searchcraft-input-caption", { inputCaptionClassName: this.inputCaptionClassName, inputCaptionValue: this.inputCaptionValue, rightToLeftOrientation: this.rightToLeftOrientation })), this.query.length > 0 && (h("searchcraft-clear-input-button", { isRequesting: this.isRequesting, onClearInput: this.handleClearInput, rightToLeftOrientation: this.rightToLeftOrientation })), h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }))) : (h(Fragment, null, h("searchcraft-input-icon", { error: this.error, height: this.inputIconHeight, rightToLeftOrientation: this.rightToLeftOrientation, width: this.inputIconWidth }), h("input", { autoComplete: 'off', class: classNames(inputClassName, 'searchcraft-input'), id: 'searchcraft-input-id', onChange: this.handleInputChange.bind(this), onKeyUp: this.handleInputKeyUp.bind(this), placeholder: this.placeholderValue, type: 'text', value: this.query, style: validatedCustomStyles }), h("style", null, `
453
495
  #searchcraft-input-id::placeholder {
454
496
  font-size: ${placeholderStyle.fontSize};
455
497
  }
@@ -536,6 +578,40 @@ const SearchcraftInputLabel = class {
536
578
  };
537
579
  SearchcraftInputLabel.style = SearchcraftInputLabelStyle0;
538
580
 
581
+ const searchcraftResultsInfoModuleCss = ".container{border-bottom:1px solid #D9D9D9;display:flex;justify-content:flex-start;width:100%}.resultsInfo{color:#292929;font-family:\"Brygada 1918\";font-size:18px;font-weight:600;line-height:20px;margin:0;margin-bottom:8px}";
582
+ const SearchcraftResultsInfoStyle0 = searchcraftResultsInfoModuleCss;
583
+
584
+ const SearchcraftResultsInfo = class {
585
+ constructor(hostRef) {
586
+ registerInstance(this, hostRef);
587
+ this.isRequesting = false;
588
+ this.resultsCount = 0;
589
+ this.responseTime = '';
590
+ this.query = '';
591
+ }
592
+ connectedCallback() {
593
+ this.unsubscribe = useSearchcraftStore.subscribe((state) => {
594
+ var _a, _b, _c, _d;
595
+ this.isRequesting = state.isRequesting;
596
+ this.resultsCount = ((_b = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.count) || 0;
597
+ this.responseTime = ((((_d = (_c = state.searchResults) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.time_taken) || 0) * 1000).toFixed(2);
598
+ this.query = state.query || ''; // Update query from store
599
+ });
600
+ }
601
+ disconnectedCallback() {
602
+ if (this.unsubscribe) {
603
+ this.unsubscribe();
604
+ }
605
+ }
606
+ render() {
607
+ if (!this.query || this.resultsCount === 0) {
608
+ return null;
609
+ }
610
+ return (h("div", { class: 'container' }, h("p", { class: 'resultsInfo' }, this.resultsCount, " results found in ", this.responseTime, "ms")));
611
+ }
612
+ };
613
+ SearchcraftResultsInfo.style = SearchcraftResultsInfoStyle0;
614
+
539
615
  const SearchcraftSearchIconSet = class {
540
616
  constructor(hostRef) {
541
617
  registerInstance(this, hostRef);
@@ -560,7 +636,7 @@ const SearchcraftSearchIconSet = class {
560
636
  }
561
637
  };
562
638
 
563
- const searchcraftSliderModuleCss = ".slider-container{display:flex;flex-direction:column;gap:10px;font-family:Arial, sans-serif;align-items:center}label{font-size:14px;font-weight:bold;margin-bottom:10px}.range-container{display:flex;width:100%;align-items:center}.range-slider{width:100%;height:4px;background:#ddd;border-radius:2px;outline:none;margin:0 -1px;position:relative}.range-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:#007bff;border-radius:50%;border:2px solid #fff;cursor:pointer;position:relative}.range-slider::-moz-range-thumb{width:20px;height:20px;background:#007bff;border-radius:50%;border:2px solid #fff;cursor:pointer}.range-slider:before{content:\"\";position:absolute;height:4px;background:#007bff;border-radius:2px;left:0;right:0;z-index:-1}.year-labels{display:flex;justify-content:space-between;width:100%;margin-top:10px;font-size:12px;color:#555}.year-label{min-width:30px;text-align:center}";
639
+ const searchcraftSliderModuleCss = ".slider-container{display:flex;flex-direction:column;gap:10px;font-family:Arial, sans-serif;align-items:center}label{font-size:14px;font-weight:bold;margin-bottom:10px}.range-container{display:flex;width:100%;align-items:center}.range-slider{width:100%;height:4px;background:#ddd;border-radius:2px;outline:none;margin:0 -1px;position:relative}.range-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background-color:#FFF;border-radius:50%;border:1px solid #E6E6E6;cursor:pointer;position:relative}.range-slider::-moz-range-thumb{width:20px;height:20px;background-color:#FFF;border-radius:50%;border:1px solid #E6E6E6;cursor:pointer}.range-slider:before{content:\"\";position:absolute;height:4px;background-color:#FFF;border-radius:2px;left:0;right:0;z-index:-1}.year-labels{display:flex;justify-content:space-between;width:100%;margin-top:10px;font-size:15px;font-weight:600;font-family:\"Source Sans Pro\";color:#666}.year-label{min-width:30px;text-align:center}";
564
640
  const SearchcraftSliderStyle0 = searchcraftSliderModuleCss;
565
641
 
566
642
  const SearchcraftSlider = class {
@@ -568,14 +644,14 @@ const SearchcraftSlider = class {
568
644
  registerInstance(this, hostRef);
569
645
  this.searchStore = useSearchcraftStore.getState();
570
646
  this.updateYears = async () => {
571
- const query = this.searchStore.query; // Get the query from the store
572
647
  this.searchStore.setYearsRange([this.startYear, this.endYear]);
573
648
  try {
574
- if (!query || query.trim() === '') {
575
- console.warn('No query value, search request skipped.');
576
- return;
649
+ if (typeof this.query === 'string' && this.query.trim() !== '') {
650
+ await this.searchStore.search();
651
+ }
652
+ else {
653
+ console.warn('Query is missing or empty, skipping search request.');
577
654
  }
578
- await this.searchStore.search();
579
655
  }
580
656
  catch (error) {
581
657
  console.error('Search failed:', error);
@@ -593,11 +669,32 @@ const SearchcraftSlider = class {
593
669
  };
594
670
  this.minYear = 2000;
595
671
  this.maxYear = new Date().getFullYear();
596
- this.startYear = this.minYear;
597
672
  this.endYear = this.maxYear;
673
+ this.query = '';
674
+ this.startYear = this.minYear;
675
+ this.hasSearched = false;
676
+ this.resultsCount = 0;
677
+ }
678
+ componentDidLoad() {
679
+ this.unsubscribe = useSearchcraftStore.subscribe((state) => {
680
+ var _a, _b, _c;
681
+ if (state.query.length > 0) {
682
+ this.hasSearched = true;
683
+ this.resultsCount = ((_c = (_b = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.length) || 0;
684
+ }
685
+ this.query = state.query;
686
+ });
687
+ }
688
+ disconnectedCallback() {
689
+ if (this.unsubscribe) {
690
+ this.unsubscribe();
691
+ }
598
692
  }
599
693
  render() {
600
- return (h("div", { key: 'cc50ae827183ec2cbf1ab16f4a3514fbd581cf01', class: 'slider-container' }, h("label", { key: '96df103d7a04aa5e0364ddf51e13af653984b8a6' }, "Filter by Year"), h("div", { key: 'dc0b68f7cd3b9a3e2fd37b6204e1542ee9fb0478', class: 'range-container' }, h("input", { key: '8ed75b7de77448d8340a76224609345309c20fe4', type: 'range', min: this.minYear, max: this.maxYear, value: this.startYear, step: '1', onInput: this.handleStartYearChange, class: 'range-slider' }), h("input", { key: '12a3612f9245d6ea290007d094668625907c183d', type: 'range', min: this.minYear, max: this.maxYear, value: this.endYear, step: '1', onInput: this.handleEndYearChange, class: 'range-slider' })), h("div", { key: '3bf225797efb2c5e1d97275e2f012faba14d2550', class: 'year-labels' }, h("span", { key: '524c7f49dc52d68059373ecc1e95b425892f0144', class: 'year-label' }, this.startYear), h("span", { key: 'e7464b4154ab8d26a969b338a5a733a206502f29', class: 'year-label' }, this.endYear))));
694
+ if (!this.query || this.resultsCount === 0) {
695
+ return null;
696
+ }
697
+ return (h("div", { class: 'slider-container' }, h("div", { class: 'range-container' }, h("input", { class: 'range-slider', max: this.maxYear, min: this.minYear, onInput: this.handleStartYearChange, step: '1', type: 'range', value: this.startYear }), h("input", { class: 'range-slider', max: this.maxYear, min: this.minYear, onInput: this.handleEndYearChange, step: '1', type: 'range', value: this.endYear })), h("div", { class: 'year-labels' }, h("span", { class: 'year-label' }, this.startYear), h("span", { class: 'year-label' }, this.endYear))));
601
698
  }
602
699
  };
603
700
  SearchcraftSlider.style = SearchcraftSliderStyle0;
@@ -610,7 +707,7 @@ const SearchcraftSpinnerDark = class {
610
707
  registerInstance(this, hostRef);
611
708
  }
612
709
  render() {
613
- return (h("div", { key: 'fa6235c4bf182daac64d41cd04a995aa3476b59a', class: 'spinnerContainer' }, h("div", { key: '68532114a4f25a5d12c8514e5c6d2984a68573af', class: 'spinnerDark' })));
710
+ return (h("div", { key: '60b629930c2e2795236f6768b40c95ce9390e882', class: 'spinnerContainer' }, h("div", { key: 'bfef3329f2e81ecf6538738ac0213da6259dd1c3', class: 'spinnerDark' })));
614
711
  }
615
712
  };
616
713
  SearchcraftSpinnerDark.style = SearchcraftSpinnerDarkStyle0;
@@ -623,18 +720,17 @@ const SearchcraftSpinnerLight = class {
623
720
  registerInstance(this, hostRef);
624
721
  }
625
722
  render() {
626
- return (h("div", { key: 'f1c941149c07dac7ee09eff1ae98dca00dcdf924', class: 'spinnerContainer' }, h("div", { key: '2f93e299ef12f4f382d189ab58c743ee9e981ce2', class: 'spinnerLight' })));
723
+ return (h("div", { key: 'ad5224c97faf7e329d2a8904488c17dfd7414b9e', class: 'spinnerContainer' }, h("div", { key: '6336ce7737af65eedac46ee290b20291ce5b6096', class: 'spinnerLight' })));
627
724
  }
628
725
  };
629
726
  SearchcraftSpinnerLight.style = SearchcraftSpinnerLightStyle0;
630
727
 
631
- const searchcraftToggleButtonModuleCss = ".toggle-container{display:flex;align-items:center;font-size:14px;color:#333}.toggle-wrapper{box-shadow:0px 0px 0px 1px rgba(0, 0, 0, 0.05);margin-left:10px;border:none;border-radius:16px;width:44px;height:26px;background:#ddd;position:relative;cursor:pointer}.toggle-wrapper.active{box-shadow:0px 0px 0px 1px rgba(0, 0, 0, 0.05);background:#007DB3}.toggle-wrapper .toggle-switch{width:18px;height:18px;background:#fff;border-radius:50%;position:absolute;top:calc(50% - 9px);left:4px;transition:transform 0.3s ease}.toggle-wrapper .toggle-switch.active{transform:translateX(16px)}";
728
+ const searchcraftToggleButtonModuleCss = ".toggle-wrapper{box-shadow:0px 0px 0px 1px rgba(0, 0, 0, 0.05);margin-left:10px;border:none;border-radius:16px;width:44px;height:26px;background:#ddd;position:relative;cursor:pointer}.toggle-wrapper.active{box-shadow:0px 0px 0px 1px rgba(0, 0, 0, 0.05);background:#007DB3}.toggle-wrapper .toggle-switch{width:18px;height:18px;background:#fff;border-radius:50%;position:absolute;top:calc(50% - 9px);left:4px;transition:transform 0.3s ease}.toggle-wrapper .toggle-switch.active{transform:translateX(16px)}";
632
729
  const SearchcraftToggleButtonStyle0 = searchcraftToggleButtonModuleCss;
633
730
 
634
731
  const SearchcraftToggleButton = class {
635
732
  constructor(hostRef) {
636
733
  registerInstance(this, hostRef);
637
- // Zustand store hook
638
734
  this.searchStore = useSearchcraftStore.getState();
639
735
  this.handleToggle = async () => {
640
736
  this.isActive = !this.isActive;
@@ -645,7 +741,7 @@ const SearchcraftToggleButton = class {
645
741
  });
646
742
  }
647
743
  else if (this.type === 'sort') {
648
- const sort = this.isActive ? 'asc' : 'desc';
744
+ const sort = this.isActive ? 'desc' : 'asc';
649
745
  this.searchStore.setSearchParams({
650
746
  sort,
651
747
  });
@@ -659,18 +755,30 @@ const SearchcraftToggleButton = class {
659
755
  };
660
756
  this.type = 'mode';
661
757
  this.isActive = false;
758
+ this.query = '';
759
+ this.resultsCount = 0;
760
+ }
761
+ componentDidLoad() {
762
+ this.unsubscribe = useSearchcraftStore.subscribe((state) => {
763
+ var _a, _b, _c;
764
+ this.query = state.query || '';
765
+ this.resultsCount = ((_c = (_b = (_a = state.searchResults) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hits) === null || _c === void 0 ? void 0 : _c.length) || 0;
766
+ });
767
+ }
768
+ disconnectedCallback() {
769
+ if (this.unsubscribe) {
770
+ this.unsubscribe();
771
+ }
662
772
  }
663
773
  render() {
664
- const label = this.type === 'mode'
665
- ? 'Exact Match'
666
- : this.type === 'sort'
667
- ? 'Sort Order'
668
- : '';
669
- return (h("div", { key: '8bfbd9cf161d3dc285d7309ada79e9fb68624a45', class: 'toggle-container' }, h("span", { key: '99b5f67e53e45ebf97fef2bb2a52e50c804dec4d' }, label), h("button", { key: 'c6444cfcd24ef3558d0d93ebe0d4dcd4ceb8b29e', class: `toggle-wrapper ${this.isActive ? 'active' : ''}`, onClick: this.handleToggle, type: 'button' }, h("div", { key: '801f2e99c695449e161699fc874aa05ee1cf1e07', class: `toggle-switch ${this.isActive ? 'active' : ''}` }))));
774
+ if (!this.query || this.resultsCount === 0) {
775
+ return null;
776
+ }
777
+ return (h("button", { class: `toggle-wrapper ${this.isActive ? 'active' : ''}`, onClick: this.handleToggle, type: 'button' }, h("div", { class: `toggle-switch ${this.isActive ? 'active' : ''}` })));
670
778
  }
671
779
  };
672
780
  SearchcraftToggleButton.style = SearchcraftToggleButtonStyle0;
673
781
 
674
- export { SearchcraftAutoSearchForm as searchcraft_auto_search_form, SearchcraftBaseSearchResult as searchcraft_base_search_result, SearchcraftBaseSearchResults as searchcraft_base_search_results, SearchcraftClearIconSet as searchcraft_clear_icon_set, SearchcraftClearInputButton as searchcraft_clear_input_button, SearchcraftErrorMessage as searchcraft_error_message, SearchcraftFiltersList as searchcraft_filters_list, SearchcraftInput as searchcraft_input, SearchcraftInputCaption as searchcraft_input_caption, SearchcraftInputIcon as searchcraft_input_icon, SearchcraftInputLabel as searchcraft_input_label, SearchcraftSearchIconSet as searchcraft_search_icon_set, SearchcraftSlider as searchcraft_slider, SearchcraftSpinnerDark as searchcraft_spinner_dark, SearchcraftSpinnerLight as searchcraft_spinner_light, SearchcraftToggleButton as searchcraft_toggle_button };
782
+ export { SearchcraftAutoSearchForm as searchcraft_auto_search_form, SearchcraftBaseSearchResult as searchcraft_base_search_result, SearchcraftBaseSearchResults as searchcraft_base_search_results, SearchcraftClearIconSet as searchcraft_clear_icon_set, SearchcraftClearInputButton as searchcraft_clear_input_button, SearchcraftErrorMessage as searchcraft_error_message, SearchcraftFiltersList as searchcraft_filters_list, SearchcraftInput as searchcraft_input, SearchcraftInputCaption as searchcraft_input_caption, SearchcraftInputIcon as searchcraft_input_icon, SearchcraftInputLabel as searchcraft_input_label, SearchcraftResultsInfo as searchcraft_results_info, SearchcraftSearchIconSet as searchcraft_search_icon_set, SearchcraftSlider as searchcraft_slider, SearchcraftSpinnerDark as searchcraft_spinner_dark, SearchcraftSpinnerLight as searchcraft_spinner_light, SearchcraftToggleButton as searchcraft_toggle_button };
675
783
 
676
- //# sourceMappingURL=searchcraft-auto-search-form_16.entry.js.map
784
+ //# sourceMappingURL=searchcraft-auto-search-form_17.entry.js.map